@zeyos/zx 5.2.0 → 5.3.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.
@@ -1,13 +1,13 @@
1
- var zx=(()=>{var No=Object.defineProperty;var Qp=Object.getOwnPropertyDescriptor;var Xp=Object.getOwnPropertyNames;var Jp=Object.prototype.hasOwnProperty;var Zp=(s,t)=>{for(var e in t)No(s,e,{get:t[e],enumerable:!0})},t_=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Xp(t))!Jp.call(s,n)&&n!==e&&No(s,n,{get:()=>t[n],enumerable:!(i=Qp(t,n))||i.enumerable});return s};var e_=s=>t_(No({},"__esModule",{value:!0}),s);var HS={};Zp(HS,{AVATAR_TONES:()=>Ai,AccountMenu:()=>cr,ActivityItem:()=>Ci,ActivityList:()=>lr,AppIcon:()=>ps,AppSidebar:()=>_r,Aurora:()=>Rn,Avatar:()=>de,BADGE_TONES:()=>ga,Breadcrumb:()=>Qn,CALENDAR_VIEWS:()=>ks,Calendar:()=>Cr,Card:()=>Fn,CardView:()=>Fr,Chart:()=>to,ChartJsAdapter:()=>eo,CheckButton:()=>Ht,Checklist:()=>lt,CodeEditor:()=>He,Component:()=>y,ContextMenu:()=>Di,CopyInput:()=>Dn,DataFilter:()=>oo,DatePicker:()=>se,DateRangeBox:()=>Je,DateRangePicker:()=>Xe,DateTimeBox:()=>cn,Datebox:()=>et,Dialog:()=>qt,Dock:()=>$n,Dropdown:()=>pt,EntityRef:()=>ki,Field:()=>I,FieldUpload:()=>Ze,Fieldset:()=>Be,FileItem:()=>zi,FileList:()=>rr,Filter:()=>Co,FilterPanel:()=>lo,Finder:()=>ro,Form:()=>Io,Grid:()=>Zr,Groupbox:()=>ce,Http:()=>ss,InlineLoading:()=>En,KanbanView:()=>Jr,Launcher:()=>ir,ListToolbar:()=>ho,MOTION_ATTRIBUTE:()=>va,MasterPanel:()=>Bn,MenuButton:()=>at,Message:()=>br,Modal:()=>hi,ModuleBar:()=>ct,MonthPicker:()=>We,MultiValueEditor:()=>ti,NavigationBar:()=>Un,NumberField:()=>Et,Pagination:()=>Zn,Panel:()=>Pn,ProgressBar:()=>bi,Questionnaire:()=>Do,Rating:()=>ei,RecordView:()=>gt,Search:()=>Ot,Select:()=>$,Sheet:()=>yr,SheetStack:()=>wr,Slider:()=>ii,SortControl:()=>uo,SplitView:()=>qn,StatTile:()=>ds,Stepper:()=>Gn,Tabbox:()=>pi,Table:()=>Ft,TableView:()=>Er,TagPicker:()=>re,TimePicker:()=>Ye,Timebox:()=>Dt,Toggle:()=>J,Toolbar:()=>On,Tooltip:()=>mt,TreeView:()=>no,ValueList:()=>si,ViewSettings:()=>go,WorkspaceSwitcher:()=>ur,__:()=>ac,absoluteKanbanIndex:()=>Wr,addCalendarDays:()=>R,addCalendarMonths:()=>vr,addDays:()=>L,addMonths:()=>Vt,allowsKanbanTransition:()=>Ms,appIcon:()=>vi,appendCompact:()=>cc,appendCompactChild:()=>dc,appendContent:()=>lc,applyCompactProperties:()=>Lo,aspect:()=>Bu,avatarInitials:()=>Te,avatarTone:()=>ue,badge:()=>ht,badgeGroup:()=>Rd,billingColumns:()=>Il,breakpointOf:()=>gn,breakpoints:()=>Se,button:()=>j,buttonGroup:()=>_u,calendarDayDifference:()=>At,calendarDayKey:()=>X,calendarEventIntersects:()=>Oi,calendarEventSpansDays:()=>kt,calendarPageDate:()=>Sr,calendarRange:()=>xr,chartSummaryTable:()=>Ml,clamp:()=>q,clampDate:()=>Gs,clampRange:()=>Qe,clampSize:()=>Kt,cloneCalendarEvent:()=>W,cloneChartValue:()=>Ct,cloneFilterAst:()=>js,compactElement:()=>Yi,configureIcons:()=>Zi,copyButton:()=>Mn,copyToClipboard:()=>xn,createKanbanAvatars:()=>Vr,createKanbanCardHead:()=>jr,createKanbanHistory:()=>Ur,createKanbanIndicator:()=>kl,createKanbanProgress:()=>Pr,debounce:()=>ec,deepMerge:()=>te,defaultDateRangePresets:()=>oa,defaultMessages:()=>Wi,defineElements:()=>Eu,describe:()=>Vh,downloadBlob:()=>ou,editorPosition:()=>Wo,emptyFilterAst:()=>wo,emptyState:()=>Nu,escapeRegExp:()=>je,evaluateKanbanMove:()=>qr,faFamilies:()=>Xo,faIconClasses:()=>Xi,faNames:()=>Jo,faStyles:()=>Qs,filterCondition:()=>vo,filterGroup:()=>So,filterOperators:()=>Vs,fireCompactEvent:()=>mc,focusTrap:()=>dn,formatCurrency:()=>oi,formatDate:()=>N,formatFileSize:()=>li,formatNumber:()=>Nt,formatPercent:()=>ai,formatRangeText:()=>aa,formatRelativeTime:()=>eu,fragment:()=>uc,getIconConfig:()=>Ke,getLanguage:()=>dt,getWeekStart:()=>$e,grid:()=>Pu,groupActivityItems:()=>il,groupBy:()=>sc,h:()=>l,highlightMatch:()=>$s,htmlEscape:()=>hc,icon:()=>g,iconNames:()=>tn,icons:()=>Zs,indentSelection:()=>Yo,isActiveValue:()=>me,isBillingLine:()=>Os,isElement:()=>E,isEmptyChartData:()=>io,isSameDay:()=>U,isTruncated:()=>Pa,joinTime:()=>wa,kanbanAvatarLimit:()=>zl,kanbanSearchTerms:()=>$r,kitUrl:()=>Ji,layoutCalendarSpans:()=>zs,layoutTimedCalendarEvents:()=>Ar,loadFontAwesome:()=>Kc,loadFontAwesomeKit:()=>Js,locateKanbanRecord:()=>Ds,matchBreakpoint:()=>bn,matchesKanbanSearch:()=>Kr,moveViewField:()=>wl,normalizeActivityAction:()=>tl,normalizeActivityItems:()=>Rt,normalizeActivityTimestamp:()=>el,normalizeAppItems:()=>Pt,normalizeCalendarEvents:()=>Ee,normalizeEntityRef:()=>nr,normalizeEntityRefActions:()=>ys,normalizeEntityRefLink:()=>gs,normalizeEntityRefMetadata:()=>bs,normalizeFileItem:()=>he,normalizeFileListItems:()=>or,normalizeKanbanRules:()=>Hr,normalizeRange:()=>we,normalizeViewFields:()=>Ir,normalizeViewState:()=>xl,offCompactEvent:()=>_c,onBreakpoint:()=>ni,onCompactEvent:()=>Ro,paginationRange:()=>Ga,parseCompactTag:()=>Fo,parseDate:()=>tt,parseFilterAst:()=>Pe,parseIconSpec:()=>Xs,parseNumber:()=>ve,parseRangeText:()=>ln,parseResult:()=>wn,partitionModules:()=>cl,position:()=>nt,prefersReducedMotion:()=>ri,presentationGlyph:()=>mr,printf:()=>T,priorityIcon:()=>_n,pruneValue:()=>tp,rangeNights:()=>Ge,rangeStateOf:()=>ra,rankLauncherItems:()=>sr,readViewField:()=>Z,reconcileFieldOrder:()=>Fi,registerFieldAdapters:()=>qp,registerIcons:()=>Uc,renderViewField:()=>Ts,reorderKanbanRecords:()=>Yr,reorderTableRows:()=>Na,resolveActivityActions:()=>Za,resolveElement:()=>P,resolveKanbanAssignees:()=>Br,resolveKanbanIndicator:()=>Lr,resolveKanbanProgress:()=>Rr,resolveKanbanRules:()=>Es,resolveModuleColor:()=>dl,resolveSize:()=>_t,rovingTabindex:()=>Mt,serializeFilterValue:()=>co,setButtonBusy:()=>Ta,setLanguage:()=>wc,setTranslator:()=>yc,shiftCalendarEvent:()=>Ni,skeleton:()=>ot,skeletonTable:()=>Lu,skeletonText:()=>yi,snapNumber:()=>ts,snapSize:()=>$a,sortBy:()=>nc,sortViewRecords:()=>vl,spinner:()=>fi,splitTime:()=>ya,stack:()=>Ru,startOfCalendarDay:()=>Y,startOfCalendarWeek:()=>As,statTile:()=>Ju,statusIcon:()=>pn,stepPrecision:()=>ma,storage:()=>ci,stringifyFilterAst:()=>xp,throttle:()=>ic,toArray:()=>$i,toCsv:()=>ru,tooltip:()=>Bh,translate:()=>yt,truncate:()=>Hu,typeahead:()=>ut,uid:()=>x,uniqueBy:()=>rc,useBuiltinIcons:()=>$c,useFontAwesome:()=>ea,validateFilterAst:()=>Ao,viewRecordId:()=>Oe,watchMotion:()=>yn,zeyosService:()=>Wd});function ec(s,t){let e=null;return function(...n){let r=this;e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,s.apply(r,n)},t)}}function ic(s,t,{leading:e=!0,trailing:i=!0}={}){let n=Math.max(0,Number(t)||0),r=null,o=0,a=null,c=null,d=()=>{r=null,o=e?Date.now():0;let u=a,h=c;a=null,c=null,u!==null&&s.apply(h,u)};return function(...h){let f=Date.now();o===0&&!e&&(o=f);let p=n-(f-o);if(p<=0||p>n){r!==null&&(clearTimeout(r),r=null),o=f,a=null,c=null,s.apply(this,h);return}i&&(a=h,c=this,r===null&&(r=setTimeout(d,p)))}}var Jl=0;function x(s="zx"){return Jl+=1,`${s}-${Date.now().toString(36)}-${Jl.toString(36)}`}function te(s,t){let e=qi(s)?oc(s):{};if(!qi(t))return qs(t);for(let[i,n]of Object.entries(t))qi(n)&&qi(e[i])?e[i]=te(e[i],n):e[i]=qs(n);return e}function E(s){return!!(s&&typeof s=="object"&&s.nodeType===1)}function ee(s){if(typeof s!="string")return!1;let t=s.trim();if(!t||t.length>256||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|var)\s*\(/i.test(t))return!1;let e=globalThis.CSS?.supports;if(typeof e=="function")try{return e.call(globalThis.CSS,"color",t)}catch{return!1}return/^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix)\([^;{}]+\))$/i.test(t)}function q(s,t,e){return Math.min(e,Math.max(t,s))}function $i(s){if(s==null)return[];if(Array.isArray(s))return s.slice();let t=s;return typeof s!="string"&&typeof t?.[Symbol.iterator]=="function"||typeof s!="string"&&typeof t?.length=="number"?Array.from(t):[s]}function sc(s,t){let e=Hs(t),i=new Map;for(let n of $i(s)){let r=String(e(n)),o=i.get(r);o===void 0?i.set(r,[n]):o.push(n)}return Object.fromEntries(i)}function nc(s,...t){let e=$i(s),i=t.map(i_);return i.length===0?e:e.sort((n,r)=>{for(let o of i){let a=o(n,r);if(a!==0)return a}return 0})}function rc(s,t){let e=t==null?r=>r:Hs(t),i=new Set,n=[];for(let r of $i(s)){let o=e(r);i.has(o)||(i.add(o),n.push(r))}return n}function je(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Hs(s){if(typeof s=="function")return s;let t=String(s);return e=>e?.[t]}function i_(s){let t,e=1;if(typeof s=="function")t=s;else if(s!==null&&typeof s=="object")t=Hs(s.key),String(s.dir).toLowerCase()==="desc"&&(e=-1);else{let i=String(s);i.startsWith("-")?(e=-1,i=i.slice(1)):i.startsWith("+")&&(i=i.slice(1)),t=Hs(i)}return(i,n)=>{let r=t(i),o=t(n),a=Zl(r),c=Zl(o);return a||c?a&&c?0:a?1:-1:e*s_(r,o)}}function Zl(s){return s==null||typeof s=="number"&&Number.isNaN(s)}function s_(s,t){return s instanceof Date||t instanceof Date?Oo(tc(s)-tc(t)):typeof s=="boolean"||typeof t=="boolean"?Oo(Number(s)-Number(t)):typeof s=="number"&&typeof t=="number"?Oo(s-t):String(s).localeCompare(String(t),void 0,{numeric:!0})}function tc(s){if(s instanceof Date)return s.getTime();let t=Number(s);return Number.isFinite(t)?t:0}function Oo(s){return Number.isNaN(s)?0:s<0?-1:s>0?1:0}function qi(s){if(s===null||typeof s!="object")return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function oc(s){let t={};for(let[e,i]of Object.entries(s))t[e]=qs(i);return t}function qs(s){return qi(s)?oc(s):Array.isArray(s)?s.map(qs):s}var Ki=null,n_=new Set(["href","id","lang","name","rel","src","target","title","value"]),Ui=new WeakMap;function Fo(s){if(typeof s!="string")throw new TypeError("DOM builder tag must be a string");let t=s,e="",i="",n=t.indexOf(".");return n!==-1&&(e=t.slice(n+1),t=t.slice(0,n)),n=t.indexOf("#"),n!==-1&&(i=t.slice(n+1),t=t.slice(0,n)),{tag:t||"div",id:i,className:e}}function Yi(s,t=null,e=null){let i=Fo(s),n=document.createElement(i.tag);if(i.id&&(n.id=i.id),i.className&&(n.className=i.className),i.tag==="a"){let r=n;r.rel="noopener",r.tabIndex=-1}else if(i.tag==="button")n.type="button";else if(i.tag==="input"||i.tag==="textarea"){let r=n;r.autocapitalize="none",r.autocomplete="off",r.autocorrect="off",r.spellcheck=!1}return t&&Lo(n,t),l_(n,e),n}var ac=Yi;function V(s){if(typeof s!="string")return null;let t=s.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function Lo(s,t){for(let e in t??{}){let i=t[e];if(i!=null)if(e[0]==="D")s.setAttribute(`data-${e.slice(1)}`,String(i));else if(e[0]==="S")s.style[e.slice(1)]=i;else if(e.startsWith("on")){if(typeof i!="function")throw new TypeError(`Compact DOM event ${e} must be a function`);Ro(s,e.slice(2),i)}else typeof i=="boolean"||n_.has(e)?s[e]=i:s.setAttribute(e,String(i))}return s}function lc(s,t){if(t==null)return s;let e=pc(t);return e==null||(typeof e=="object"?s.appendChild(e):s.appendChild(document.createTextNode(String(e)))),s}function cc(s,t,e=null,i=null){return s.appendChild(Yi(t,e,i)),s}function dc(s,t,e=null,i=null){let n=Yi(t,e,i);return s.appendChild(n),n}function uc(...s){let t=document.createDocumentFragment();return fc(t,s),t}function l(s,t,...e){let i=document.createElement(s),n=t;r_(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))o_(i,r,o);return fc(i,e),i}l.scope=function(t,e){let i=Ki;Ki=t;try{return e()}finally{Ki=i}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function A(s){return{children:Array.from(s.childNodes),attributes:Array.from(s.attributes,t=>[t.name,t.value])}}function S(s,t){if(t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}}function hc(s){return String(s).replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function $s(s,t,e={}){let{className:i="zx-mark"}=e,n=s==null?"":String(s),r=t==null?"":String(t).trim(),o=document.createDocumentFragment();if(r===""||n==="")return o.append(document.createTextNode(n)),o;let a=new RegExp(je(r),"gi"),c=0;for(let d of n.matchAll(a)){d.index>c&&o.append(document.createTextNode(n.slice(c,d.index)));let u=document.createElement("mark");i&&(u.className=String(i)),u.append(document.createTextNode(d[0])),o.append(u),c=d.index+d[0].length}return c<n.length&&o.append(document.createTextNode(n.slice(c))),o}function P(s){if(s==null)return null;if(E(s))return s;if(typeof s=="string")return document.querySelector(s);if(typeof s.toElement=="function"){let t=s.toElement();return E(t)?t:null}return null}function r_(s){if(s===null||typeof s!="object"||Array.isArray(s))return!1;let t=s;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function o_(s,t,e){if(t==="ref"){Ki&&typeof e=="string"&&(Ki[e]=s);return}if(t==="class"){s.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")s.style.cssText=e;else if(e&&typeof e=="object")for(let[n,r]of Object.entries(e))n.startsWith("--")||n.includes("-")?s.style.setProperty(n,String(r)):s.style[n]=r;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[n,r]of Object.entries(e))r==null?delete s.dataset[n]:s.dataset[n]=String(r);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){s.addEventListener(t.slice(2),e);return}if(e==null)return;let i=a_(t);if(i!==null)s.setAttribute(i,String(e));else if(t in s)try{s[t]=e}catch{s.setAttribute(t,String(e))}else typeof e=="boolean"?e?s.setAttribute(t,""):s.removeAttribute(t):s.setAttribute(t,String(e))}function a_(s){return s.startsWith("aria-")?s:/^aria[A-Z]/.test(s)?"aria-"+s.slice(4).toLowerCase():null}function fc(s,t){let e=s;for(let i of t.flat(1/0)){if(i==null)continue;if(typeof i=="string"||typeof i=="number"){e.append(document.createTextNode(String(i)));continue}if(typeof i!="object")continue;let n=i;if(typeof n.nodeType=="number")e.append(i);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}function l_(s,t){if(t==null)return;let e=pc(t);e!=null&&(typeof e=="object"?s.appendChild(e):s.textContent=String(e))}function pc(s){if(s&&typeof s=="object"){if(typeof s.nodeType=="number")return s;if(typeof s.toElement=="function")return s.toElement()}return s}function Ro(s,t,e,i=!1){if(typeof e!="function")throw new TypeError("Compact DOM event handler must be a function");let n=String(t),r=Ui.get(s);r||(r=new Map,Ui.set(s,r));let o=r.get(n);if(o)return o.handlers.push(e),s;let a=[e],c=d=>gc(s,a,d);r.set(n,{handlers:a,listener:c});try{s.addEventListener(n,c,{passive:i})}catch{s.addEventListener(n,c)}return s}function _c(s,t,e){let i=String(t),n=Ui.get(s),r=n?.get(i);if(!r)return s;let o=r.handlers.indexOf(e);return o===-1||(r.handlers.splice(o,1),r.handlers.length===0&&(s.removeEventListener(i,r.listener),n.delete(i),n.size===0&&Ui.delete(s))),s}function mc(s,t,e=null){let i=String(t),n=Ui.get(s);if(!n?.has(i))return s;let r=e??c_(s,i),o=n.get(String(r.type));return o&&gc(s,o.handlers,r),s}function gc(s,t,e){let i=e,n=String(i.type).startsWith("key")?i.which:i.target;for(let r=t.length-1;r>=0;r-=1)t[r].call(s,e,n)===!1&&i.preventDefault()}function c_(s,t){let e={target:s,type:t,which:-1,defaultPrevented:!1,preventDefault(){e.defaultPrevented=!0}};return e}var Wi=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"}),Po=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 Bo=null,bc="en";function yc(s){if(s!==null&&typeof s!="function")throw new TypeError("Translator must be a function or null");Bo=s}function wc(s){bc=String(s||"en")}function dt(){return bc}function Gi(s){if(!Bo)return null;let t=Bo(s);if(t==null)return null;let e=String(t);return e===s?null:e}function Vo(s){return Object.prototype.hasOwnProperty.call(Wi,s)?Wi[s]:null}function jo(s){return Object.prototype.hasOwnProperty.call(Po,s)?Po[s]:null}function yt(s,t){let e=jo(s),i=Gi(s)??(e?Gi(e):null)??Vo(s)??s;return T(i,t)}function T(s,t){if(t==null)return String(s);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],i=String(s).replace(/%(\d+)/g,(r,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return i=i.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?r:String(a)}if(e&&n<e.length){let a=e[n];return n+=1,a==null?r:String(a)}return r}),i}var Ks=new WeakMap,vc=new WeakMap,y=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let i=this.constructor;this.#e=t===null;let n=P(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=d_(i,e);vc.set(this,{own:qo(e?.msg)?Object.freeze(te({},e.msg)):null,inherited:u_(i)});let o=[];for(let[d,u]of Object.entries(r))/^on[a-z]/.test(d)&&typeof u=="function"&&(o.push([d.slice(2),u]),delete r[d]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[d,u]of o)this.on(d,u);let a;try{a=l.scope(this.refs,()=>this.render())}catch(d){throw this.#t.abort(),d}if(this.#e){let d=E(a)?a:this.el;if(!E(d))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=d}if(!E(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=i.cssName;if(typeof c=="string"&&c){let d=`zx-${c}`;this.#s=!this.el.classList.contains(d),this.el.classList.add(d)}Ks.set(this.el,this)}render(){return this.el??null}on(t,e){return this.addEventListener(t,e,{signal:this.#t.signal}),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0,signal:this.#t.signal}),this}addEvent(t,e){return this.on(t,e)}emit(t,e={},i={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let n=xc(t,e,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=xc(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0});this.el.dispatchEvent(r),i.honorDomCancellation&&r.defaultPrevented&&n.preventDefault()}return n}listen(t,e,i,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return t.addEventListener(e,i,{...r,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let i=this.options?.lang??this.options?.language??dt(),n=jo(t),r=vc.get(this)??{own:qo(this.options?.msg)?this.options.msg:null,inherited:null},o=r.own,a=Ho(o,i,t)??(n?Ho(o,i,n):null)??Gi(t)??(n?Gi(n):null)??Ho(r.inherited,i,t)??Vo(t)??t;return T(a,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),Ks.get(this.el)===this&&Ks.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Ks.get(t)??null}};function d_(s,t){let e=Sc(s),i={},n={},r=!1;for(let o of e)!o||typeof o!="object"||(Object.assign(i,o),o.msg&&typeof o.msg=="object"&&(r=!0,n=te(n,o.msg)));return Object.assign(i,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(r=!0,n=te(n,t.msg)),r&&(i.msg=n),i}function Sc(s){let t=[],e=s;for(;e&&e!==Function.prototype;)Object.prototype.hasOwnProperty.call(e,"defaults")&&t.unshift(e.defaults),e=Object.getPrototypeOf(e);return t}function qo(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function u_(s){let t=null;for(let e of Sc(s))e&&typeof e=="object"&&qo(e.msg)&&(t=te(t??{},e.msg));return t?Object.freeze(t):null}function Ho(s,t,e){if(!s)return null;let i=s[t]?.[e];if(i!=null&&typeof i!="object")return String(i);let n=Object.prototype.hasOwnProperty.call(s,e)?s[e]:null;return n!=null&&typeof n!="object"?String(n):null}function xc(s,t,e){if(typeof CustomEvent=="function")return new CustomEvent(s,{...e,detail:t});let i=new Event(s,e);return Object.defineProperty(i,"detail",{configurable:!0,enumerable:!0,value:t}),i}var I=class s extends y{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#t=new Map;static register(t,e){let i=String(t).trim().toLowerCase();if(!i)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return s.#t.set(i,e),this}static has(t){return s.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??l("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),i=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=__(t,["data-layout","data-field-type","data-disabled","data-readonly","data-state"]),t.dataset.layout=i,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):x("zx-field"),this.name=String(this.options.name??this.options.id??"");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?l("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=l("div",{class:"zx-field__control"}),d=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),u=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),h=l("div",{class:"zx-field__body"},c,d,u);this._ownedNodes.push(a,h),t.append(a,h);let f=s.#t.get(e);if(f)try{this.adapter=f_(f(this,this.options))}catch(m){let b=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${e}" failed: ${b}`),this.adapter=kc(b,this.controlId)}else{let m=this.msg("field.unknown",e);console.warn(`[zx.Field] ${m}`),this.adapter=kc(m,this.controlId)}let p=this.adapter.el;p.id||(p.id=this.controlId);let _=this.adapter.labelTarget??(Us(p)?p:p_(p))??p;return this._labelled=_,_!==p&&Us(_)&&!_.id&&(_.id=`${this.controlId}-input`),a.htmlFor=Us(_)?_.id:p.id,Us(_)||_.setAttribute("aria-labelledby",n),this._baseDescribedBy=_.getAttribute("aria-describedby")??"",c.append(p),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=u,this._syncDescription(),this.initialValue=h_(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.options.readonly&&this.setReadonly(!0),this.listen(p,"change",()=>{this.emit("change",{value:this.getValue()})}),t}getValue(){return this.adapter.get()}setValue(t,{silent:e=!1}={}){return this.adapter.set(t,{silent:e}),e||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(t){let e=!!t;return this.adapter.setDisabled(e),this.el.dataset.disabled=String(e),this}setReadonly(t){let e=!!t;return this.adapter.setReadonly?.(e),this.el.dataset.readonly=String(e),this}setHighlight(t,e="danger"){if(!t)return this.clearHighlight();let i=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=i,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,i==="danger"&&t?(this._highlight.setAttribute("role","alert"),this._labelled.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof y))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(i=>i.split(/\s+/)).filter(Boolean);e.length?this._labelled.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this._labelled.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();m_(this.el,this._rootAttributes??new Map),super.destroy()}};function $o(s){if(typeof s=="number")return Number.isInteger(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=Cc(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function Ko(s){if(typeof s=="number")return Number.isFinite(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=Cc(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function Cc(s){let t=s.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",i=e?t.slice(1):t;if(!/\d/.test(i))return null;let n=[...i.matchAll(/\./g)].map(c=>c.index),r=[...i.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",d=c==="."?",":".",u=i.lastIndexOf(c),h=i.slice(0,u),f=i.slice(u+1);if(!/^\d+$/.test(f)||!Ac(h,d))return null;o=h.split(d).join("")+"."+f}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!Ac(i,c))return null;o=i.split(c).join("")}else r.length===1?o=i.replace(",","."):o=i;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(e+o);return Number.isFinite(a)?a:null}function Ac(s,t){let e=s.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(i=>/^\d{3}$/.test(i))}function h_(s,t){return t!==void 0?t:s==="checkbox"?!1:""}function f_(s){if(!s||typeof s!="object")throw new TypeError("Adapter must return an object");if(!(s.el&&s.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof s[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return s}function kc(s,t){let e=l("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},s);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function Us(s){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(s.tagName)}function p_(s){for(let t of s.querySelectorAll('input:not([type="hidden"]), select, textarea'))if(!(t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby")||[...t.labels??[]].some(i=>i.textContent?.trim())))return t;return null}function __(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function m_(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}function Qi(s,t,e){let i={...t.props??{}};for(let n of Object.keys(i))(/^on[a-z]/i.test(n)||n==="content")&&delete i[n];return{name:s.name||void 0,...i,...e}}function Ys(s,t){return(e,i)=>{let n=l(s,Qi(e,i,{type:s==="input"?t:void 0,placeholder:i.placeholder,required:i.required,disabled:i.disabled}));return{...Uo(n),setReadonly:r=>{n.readOnly=r}}}}function Uo(s){return{el:s,get:()=>s.value,set:t=>{s.value=t==null?"":String(t)},focus:()=>s.focus(),setDisabled:t=>{s.disabled=t}}}function Tc(s){return(t,e)=>{let i=s==="int"?$o:Ko,n=l("input",Qi(t,e,{type:"text",inputMode:s==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(n,"blur",()=>{let r=i(n.value);if(!r.valid){t.setHighlight(t.msg(`field.${s}`),"danger");return}r.value!==""&&(n.value=String(r.value)),t.clearHighlight()}),{...Uo(n),get:()=>i(n.value).value,setReadonly:r=>{n.readOnly=r}}}}var g_=(s,t)=>{let e=l("input",Qi(s,t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:i=>{e.checked=!!i},focus:()=>e.focus(),setDisabled:i=>{e.disabled=i}}},b_=(s,t)=>{let e=l("select",Qi(s,t,{required:t.required,disabled:t.disabled}));for(let[i,n]of Ic(t.options))e.append(l("option",{value:i},n));return Uo(e)},y_=(s,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),i=s.controlId,n=Ic(t.options).map(([r,o],a)=>{let c=l("input",{type:"radio",name:i,value:r,required:!!t.required&&a===0,disabled:t.disabled});return e.append(l("label",{class:"zx-field__option"},c,l("span",{},o))),c});return{el:e,get:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;e.setAttribute("aria-disabled",String(r))}}},w_=(s,t)=>{let e=l("div",Qi(s,t,{class:"zx-field__static",name:void 0})),i=null;return{el:e,get:()=>e.textContent,set:r=>{zc(i),i=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(i={node:r,parent:r.parentNode,next:r.nextSibling},e.replaceChildren(r)):e.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{e.setAttribute("aria-disabled",String(r))},destroy:()=>zc(i)}};function zc(s){s&&(s.parent?s.parent.insertBefore(s.node,s.next?.parentNode===s.parent?s.next:null):s.node.remove())}var v_=(s,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(s,t)};function Ic(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}I.register("text",Ys("input","text"));I.register("password",Ys("input","password"));I.register("textarea",Ys("textarea","text"));I.register("checkbox",g_);I.register("int",Tc("int"));I.register("float",Tc("float"));I.register("select",b_);I.register("optionlist",y_);I.register("hidden",Ys("input","hidden"));I.register("html",w_);I.register("custom",v_);function ie(s,t,e){let i=Ec(t).split(/\s+/).filter(Boolean);return i.length===0?s.slice():s.filter(n=>{let r=x_(n,e).map(Ec);return i.every(o=>r.some(a=>a.includes(o)))})}function x_(s,t){return s===null||typeof s!="object"?[s]:!Array.isArray(t)||t.length===0?[s]:t.map(e=>typeof e=="function"?e(s):s[e])}function Ec(s){return String(s??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var lt=class extends y{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,hideLabel:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let a of["role","aria-label","aria-labelledby","data-state"])this._originalAttributes.set(a,t.getAttribute(a));let e=this._message("checklist.label","Checklist"),i=x("zx-checklist-label"),n=this.options.hideLabel?null:l("div",{class:"zx-checklist__label",id:i},e),r=l("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),o=l("div",{ref:"list",class:"zx-checklist__list"});return o.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(...[n,r,o].filter(Boolean)),t.setAttribute("role","group"),n?t.setAttribute("aria-labelledby",i):t.setAttribute("aria-label",e),this.listen(r,"input",()=>this.search(r.value)),this.listen(o,"change",a=>{let c=a.target;if(!c?.matches?.('input[type="checkbox"][data-index]'))return;let d=this._visibleItems[Number(c.dataset.index)];if(d===void 0)return;let u=this._itemValue(d);c.checked?this._checked.add(u):this._checked.delete(u),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),t}setItems(t){return this._replaceItems(t),this}getValues(){return this._items.map(t=>this._itemValue(t)).filter(t=>this._checked.has(t))}setValues(t){let e=new Set(t==null?[]:Array.from(t)),i=new Set(this._items.map(n=>this._itemValue(n)).filter(n=>e.has(n)));return this._replaceChecked(i),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=ie(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,i]of this._originalAttributes)i===null?t.removeAttribute(e):t.setAttribute(e,i)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=ie(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,i)=>{let n=x("zx-checklist-item"),r=l("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:i}});return l("label",{class:"zx-checklist__item",for:n},r,l("span",{},this._itemLabel(e)))});t.length===0&&t.push(l("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){S_(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let i=this.msg(t);return i===t?e:i}};function S_(s,t){return s.size===t.size&&Array.from(s).every(e=>t.has(e))}function Mc(){I.register("checklist",(s,t)=>{let e=s.own(new lt(null,{hideLabel:!0,...t.props??{}})),i=!1,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(i));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=i};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{n||s.emit("change",{value:o.detail.values})}),e.on("loaded",r),{el:e.el,get:()=>e.getValues(),set:o=>{n=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{i=!!o,r()}}})}var A_=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),He=class extends y{static cssName="code-editor";static defaults={value:"",name:"",language:"text",label:"Code editor",placeholder:"",rows:12,indent:" ",wrap:"off",spellcheck:!1,readOnly:!1,disabled:!1,status:!0};render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._initialChildren=this._createdRoot?[]:[...t.childNodes],this._initialAttributes=new Map(["data-language","data-readonly","data-disabled"].map(e=>[e,t.getAttribute(e)])),this._language=Dc(this.options.language),this._languageLabel=l("span",{class:"zx-code-editor__language"},this._language),this._position=l("span",{class:"zx-code-editor__position",role:"status",ariaLive:"polite"}),this._header=l("div",{class:"zx-code-editor__header"},this._languageLabel,this.options.status?this._position:null),this._input=l("textarea",{class:"zx-code-editor__input",name:this.options.name?String(this.options.name):void 0,ariaLabel:String(this.options.label??"Code editor"),placeholder:String(this.options.placeholder??""),rows:z_(this.options.rows),wrap:C_(this.options.wrap),spellcheck:!!this.options.spellcheck,readOnly:!!this.options.readOnly,disabled:!!this.options.disabled,autocomplete:"off",autocapitalize:"off"}),this._input.value=String(this.options.value??""),t.dataset.language=this._language,t.dataset.readonly=String(!!this.options.readOnly),t.dataset.disabled=String(!!this.options.disabled),t.replaceChildren(this._header,this._input),this._tabReleased=!1,this.listen(this._input,"keydown",e=>this._handleKeydown(e)),this.listen(this._input,"blur",()=>{this._tabReleased=!1}),this.listen(this._input,"input",()=>{this._updatePosition(),this.emit("input",{value:this.getValue()})}),this.listen(this._input,"change",()=>this.emit("change",{value:this.getValue()}));for(let e of["click","keyup","select","focus"])this.listen(this._input,e,()=>this._updatePosition());return this._updatePosition(),t}getValue(){return this._input.value}setValue(t,{silent:e=!1}={}){let i=String(t??"");return this._input.value===i?this:(this._input.value=i,this._updatePosition(),e||this.emit("change",{value:i}),this)}setLanguage(t){return this._language=Dc(t),this.el.dataset.language=this._language,this._languageLabel.textContent=this._language,this}focus(){return this._input.focus(),this}enable(){return this._input.disabled=!1,this.el.dataset.disabled="false",this}disable(){return this._input.disabled=!0,this.el.dataset.disabled="true",this}setReadOnly(t){return this._input.readOnly=!!t,this.el.dataset.readonly=String(!!t),this}_handleKeydown(t){if(t.isComposing||A_.has(t.key))return;if(t.key==="Escape"){this._tabReleased=!0;return}let e=this._tabReleased;if(this._tabReleased=!1,e||t.key!=="Tab"||t.altKey||t.ctrlKey||t.metaKey||this._input.readOnly||this._input.disabled)return;let i=String(this.options.indent??" ");if(!i)return;t.preventDefault();let n=Yo(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0,i,t.shiftKey);n.value!==this._input.value&&(this._input.value=n.value,this._input.setSelectionRange(n.start,n.end),this._updatePosition(),this.emit("input",{value:this.getValue()}))}_updatePosition(){if(!this.options.status)return;let t=Wo(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0);this._position.textContent=t.lines>1?`Ln ${t.line}, Col ${t.column} \xB7 ${t.lines} lines selected`:`Ln ${t.line}, Col ${t.column}`}destroy(){if(!this._createdRoot){this.el.replaceChildren(...this._initialChildren);for(let[t,e]of this._initialAttributes)e===null?this.el.removeAttribute(t):this.el.setAttribute(t,e)}super.destroy()}};function Yo(s,t,e,i=" ",n=!1){let r=String(s??""),o=String(i??""),a=Ws(t,r.length),c=Ws(e,r.length);if(!o)return{value:r,start:a,end:c};if(a===c&&!n)return{value:r.slice(0,a)+o+r.slice(c),start:a+o.length,end:a+o.length};let d=r.lastIndexOf(`
1
+ var zx=(()=>{var Oo=Object.defineProperty;var Xp=Object.getOwnPropertyDescriptor;var Jp=Object.getOwnPropertyNames;var Zp=Object.prototype.hasOwnProperty;var t_=(s,t)=>{for(var e in t)Oo(s,e,{get:t[e],enumerable:!0})},e_=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Jp(t))!Zp.call(s,n)&&n!==e&&Oo(s,n,{get:()=>t[n],enumerable:!(i=Xp(t,n))||i.enumerable});return s};var i_=s=>e_(Oo({},"__esModule",{value:!0}),s);var WS={};t_(WS,{AVATAR_TONES:()=>Ai,AccountMenu:()=>dr,ActivityItem:()=>Ci,ActivityList:()=>cr,AppIcon:()=>ps,AppSidebar:()=>mr,Aurora:()=>Pn,Avatar:()=>de,BADGE_TONES:()=>ba,Breadcrumb:()=>Xn,CALENDAR_VIEWS:()=>ks,Calendar:()=>Tr,Card:()=>Ln,CardView:()=>Lr,Chart:()=>eo,ChartJsAdapter:()=>io,CheckButton:()=>Ht,Checklist:()=>lt,CodeEditor:()=>He,Component:()=>y,ContextMenu:()=>Di,CopyInput:()=>Nn,DataFilter:()=>ao,DatePicker:()=>se,DateRangeBox:()=>Je,DateRangePicker:()=>Xe,DateTimeBox:()=>dn,Datebox:()=>et,Dialog:()=>qt,Dock:()=>Kn,Dropdown:()=>pt,EntityRef:()=>ki,Field:()=>I,FieldUpload:()=>Ze,Fieldset:()=>Be,FileItem:()=>zi,FileList:()=>or,Filter:()=>To,FilterPanel:()=>co,Finder:()=>oo,Form:()=>Eo,Grid:()=>to,Groupbox:()=>ce,Http:()=>ss,InlineLoading:()=>Mn,KanbanView:()=>Zr,Launcher:()=>sr,ListToolbar:()=>fo,MOTION_ATTRIBUTE:()=>xa,MasterPanel:()=>Vn,MenuButton:()=>at,Message:()=>yr,Modal:()=>hi,ModuleBar:()=>ct,MonthPicker:()=>Ge,MultiValueEditor:()=>ti,NavigationBar:()=>Yn,NumberField:()=>Et,Pagination:()=>tr,Panel:()=>Bn,ProgressBar:()=>bi,Questionnaire:()=>No,Rating:()=>ei,RecordView:()=>gt,Search:()=>Ot,Select:()=>$,Sheet:()=>wr,SheetStack:()=>vr,Slider:()=>ii,SortControl:()=>ho,SplitView:()=>$n,StatTile:()=>ds,Stepper:()=>Qn,Tabbox:()=>pi,Table:()=>Ft,TableView:()=>Mr,TagPicker:()=>re,TimePicker:()=>Ye,Timebox:()=>Dt,Toggle:()=>J,Toolbar:()=>Fn,Tooltip:()=>mt,TreeView:()=>ro,ValueList:()=>si,ViewSettings:()=>bo,WorkspaceSwitcher:()=>hr,__:()=>lc,absoluteKanbanIndex:()=>Wr,addCalendarDays:()=>R,addCalendarMonths:()=>xr,addDays:()=>L,addMonths:()=>Vt,allowsKanbanTransition:()=>Ds,appIcon:()=>vi,appendCompact:()=>dc,appendCompactChild:()=>uc,appendContent:()=>cc,applyCompactProperties:()=>Ro,aspect:()=>Vu,avatarInitials:()=>Te,avatarTone:()=>ue,badge:()=>ht,badgeGroup:()=>Pd,billingColumns:()=>El,breakpointOf:()=>bn,breakpoints:()=>Se,button:()=>j,buttonGroup:()=>mu,calendarDayDifference:()=>At,calendarDayKey:()=>X,calendarEventIntersects:()=>Oi,calendarEventSpansDays:()=>kt,calendarPageDate:()=>Ar,calendarRange:()=>Sr,chartSummaryTable:()=>Dl,clamp:()=>q,clampDate:()=>Qs,clampRange:()=>Qe,clampSize:()=>Kt,cloneCalendarEvent:()=>G,cloneChartValue:()=>Ct,cloneFilterAst:()=>Hs,compactElement:()=>Yi,configureIcons:()=>Zi,copyButton:()=>Dn,copyToClipboard:()=>Sn,createKanbanAvatars:()=>jr,createKanbanCardHead:()=>Hr,createKanbanHistory:()=>Yr,createKanbanIndicator:()=>zl,createKanbanProgress:()=>Br,debounce:()=>ic,deepMerge:()=>te,defaultDateRangePresets:()=>aa,defaultMessages:()=>Gi,defineElements:()=>Mu,describe:()=>jh,downloadBlob:()=>au,editorPosition:()=>Wo,emptyFilterAst:()=>vo,emptyState:()=>Ou,escapeRegExp:()=>je,evaluateKanbanMove:()=>$r,faFamilies:()=>Jo,faIconClasses:()=>Xi,faNames:()=>Zo,faStyles:()=>Xs,filterCondition:()=>xo,filterGroup:()=>Ao,filterOperators:()=>js,fireCompactEvent:()=>gc,focusTrap:()=>un,formatCurrency:()=>oi,formatDate:()=>N,formatFileSize:()=>li,formatNumber:()=>Nt,formatPercent:()=>ai,formatRangeText:()=>la,formatRelativeTime:()=>iu,fragment:()=>hc,getIconConfig:()=>Ke,getLanguage:()=>dt,getWeekStart:()=>$e,grid:()=>Bu,groupActivityItems:()=>sl,groupBy:()=>nc,h:()=>l,highlightMatch:()=>Ks,htmlEscape:()=>fc,icon:()=>b,iconNames:()=>en,icons:()=>tn,indentSelection:()=>Go,isActiveValue:()=>me,isBillingLine:()=>Fs,isElement:()=>E,isEmptyChartData:()=>so,isSameDay:()=>U,isTruncated:()=>Ba,joinTime:()=>va,kanbanAvatarLimit:()=>Cl,kanbanSearchTerms:()=>Kr,kitUrl:()=>Ji,layoutCalendarSpans:()=>zs,layoutTimedCalendarEvents:()=>kr,loadFontAwesome:()=>Uc,loadFontAwesomeKit:()=>Zs,locateKanbanRecord:()=>Ns,matchBreakpoint:()=>yn,matchesKanbanSearch:()=>Ur,moveViewField:()=>vl,normalizeActivityAction:()=>el,normalizeActivityItems:()=>Rt,normalizeActivityTimestamp:()=>il,normalizeAppItems:()=>Pt,normalizeCalendarEvents:()=>Ee,normalizeEntityRef:()=>rr,normalizeEntityRefActions:()=>ys,normalizeEntityRefLink:()=>gs,normalizeEntityRefMetadata:()=>bs,normalizeFileItem:()=>he,normalizeFileListItems:()=>ar,normalizeKanbanRules:()=>qr,normalizeRange:()=>we,normalizeViewFields:()=>Er,normalizeViewState:()=>Sl,offCompactEvent:()=>mc,onBreakpoint:()=>ni,onCompactEvent:()=>Po,paginationRange:()=>Qa,parseCompactTag:()=>Lo,parseDate:()=>tt,parseFilterAst:()=>Pe,parseIconSpec:()=>Js,parseNumber:()=>ve,parseRangeText:()=>cn,parseResult:()=>vn,partitionModules:()=>dl,position:()=>nt,prefersReducedMotion:()=>ri,presentationGlyph:()=>gr,printf:()=>T,priorityIcon:()=>mn,pruneValue:()=>ep,rangeNights:()=>We,rangeStateOf:()=>oa,rankLauncherItems:()=>nr,readViewField:()=>Z,reconcileFieldOrder:()=>Fi,registerFieldAdapters:()=>$p,registerIcons:()=>Yc,renderViewField:()=>Ts,reorderKanbanRecords:()=>Gr,reorderTableRows:()=>Oa,resolveActivityActions:()=>tl,resolveElement:()=>P,resolveKanbanAssignees:()=>Vr,resolveKanbanIndicator:()=>Rr,resolveKanbanProgress:()=>Pr,resolveKanbanRules:()=>Ms,resolveModuleColor:()=>ul,resolveSize:()=>_t,rovingTabindex:()=>Mt,serializeFilterValue:()=>uo,setButtonBusy:()=>Ia,setLanguage:()=>vc,setTranslator:()=>wc,shiftCalendarEvent:()=>Ni,skeleton:()=>ot,skeletonTable:()=>Ru,skeletonText:()=>yi,snapNumber:()=>ts,snapSize:()=>Ka,sortBy:()=>rc,sortViewRecords:()=>xl,spinner:()=>fi,splitTime:()=>wa,stack:()=>Pu,startOfCalendarDay:()=>Y,startOfCalendarWeek:()=>As,statTile:()=>Zu,statusIcon:()=>_n,stepPrecision:()=>ga,storage:()=>ci,stringifyFilterAst:()=>Sp,throttle:()=>sc,toArray:()=>$i,toCsv:()=>ou,tooltip:()=>Vh,translate:()=>yt,truncate:()=>qu,typeahead:()=>ut,uid:()=>x,uniqueBy:()=>oc,useBuiltinIcons:()=>Kc,useFontAwesome:()=>ia,validateFilterAst:()=>ko,viewRecordId:()=>Oe,watchMotion:()=>wn,zeyosService:()=>Wd});function ic(s,t){let e=null;return function(...n){let r=this;e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,s.apply(r,n)},t)}}function sc(s,t,{leading:e=!0,trailing:i=!0}={}){let n=Math.max(0,Number(t)||0),r=null,o=0,a=null,c=null,d=()=>{r=null,o=e?Date.now():0;let u=a,h=c;a=null,c=null,u!==null&&s.apply(h,u)};return function(...h){let f=Date.now();o===0&&!e&&(o=f);let p=n-(f-o);if(p<=0||p>n){r!==null&&(clearTimeout(r),r=null),o=f,a=null,c=null,s.apply(this,h);return}i&&(a=h,c=this,r===null&&(r=setTimeout(d,p)))}}var Zl=0;function x(s="zx"){return Zl+=1,`${s}-${Date.now().toString(36)}-${Zl.toString(36)}`}function te(s,t){let e=qi(s)?ac(s):{};if(!qi(t))return $s(t);for(let[i,n]of Object.entries(t))qi(n)&&qi(e[i])?e[i]=te(e[i],n):e[i]=$s(n);return e}function E(s){return!!(s&&typeof s=="object"&&s.nodeType===1)}function ee(s){if(typeof s!="string")return!1;let t=s.trim();if(!t||t.length>256||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|var)\s*\(/i.test(t))return!1;let e=globalThis.CSS?.supports;if(typeof e=="function")try{return e.call(globalThis.CSS,"color",t)}catch{return!1}return/^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix)\([^;{}]+\))$/i.test(t)}function q(s,t,e){return Math.min(e,Math.max(t,s))}function $i(s){if(s==null)return[];if(Array.isArray(s))return s.slice();let t=s;return typeof s!="string"&&typeof t?.[Symbol.iterator]=="function"||typeof s!="string"&&typeof t?.length=="number"?Array.from(t):[s]}function nc(s,t){let e=qs(t),i=new Map;for(let n of $i(s)){let r=String(e(n)),o=i.get(r);o===void 0?i.set(r,[n]):o.push(n)}return Object.fromEntries(i)}function rc(s,...t){let e=$i(s),i=t.map(s_);return i.length===0?e:e.sort((n,r)=>{for(let o of i){let a=o(n,r);if(a!==0)return a}return 0})}function oc(s,t){let e=t==null?r=>r:qs(t),i=new Set,n=[];for(let r of $i(s)){let o=e(r);i.has(o)||(i.add(o),n.push(r))}return n}function je(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qs(s){if(typeof s=="function")return s;let t=String(s);return e=>e?.[t]}function s_(s){let t,e=1;if(typeof s=="function")t=s;else if(s!==null&&typeof s=="object")t=qs(s.key),String(s.dir).toLowerCase()==="desc"&&(e=-1);else{let i=String(s);i.startsWith("-")?(e=-1,i=i.slice(1)):i.startsWith("+")&&(i=i.slice(1)),t=qs(i)}return(i,n)=>{let r=t(i),o=t(n),a=tc(r),c=tc(o);return a||c?a&&c?0:a?1:-1:e*n_(r,o)}}function tc(s){return s==null||typeof s=="number"&&Number.isNaN(s)}function n_(s,t){return s instanceof Date||t instanceof Date?Fo(ec(s)-ec(t)):typeof s=="boolean"||typeof t=="boolean"?Fo(Number(s)-Number(t)):typeof s=="number"&&typeof t=="number"?Fo(s-t):String(s).localeCompare(String(t),void 0,{numeric:!0})}function ec(s){if(s instanceof Date)return s.getTime();let t=Number(s);return Number.isFinite(t)?t:0}function Fo(s){return Number.isNaN(s)?0:s<0?-1:s>0?1:0}function qi(s){if(s===null||typeof s!="object")return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function ac(s){let t={};for(let[e,i]of Object.entries(s))t[e]=$s(i);return t}function $s(s){return qi(s)?ac(s):Array.isArray(s)?s.map($s):s}var Ki=null,r_=new Set(["href","id","lang","name","rel","src","target","title","value"]),Ui=new WeakMap;function Lo(s){if(typeof s!="string")throw new TypeError("DOM builder tag must be a string");let t=s,e="",i="",n=t.indexOf(".");return n!==-1&&(e=t.slice(n+1),t=t.slice(0,n)),n=t.indexOf("#"),n!==-1&&(i=t.slice(n+1),t=t.slice(0,n)),{tag:t||"div",id:i,className:e}}function Yi(s,t=null,e=null){let i=Lo(s),n=document.createElement(i.tag);if(i.id&&(n.id=i.id),i.className&&(n.className=i.className),i.tag==="a"){let r=n;r.rel="noopener",r.tabIndex=-1}else if(i.tag==="button")n.type="button";else if(i.tag==="input"||i.tag==="textarea"){let r=n;r.autocapitalize="none",r.autocomplete="off",r.autocorrect="off",r.spellcheck=!1}return t&&Ro(n,t),c_(n,e),n}var lc=Yi;function V(s){if(typeof s!="string")return null;let t=s.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function Ro(s,t){for(let e in t??{}){let i=t[e];if(i!=null)if(e[0]==="D")s.setAttribute(`data-${e.slice(1)}`,String(i));else if(e[0]==="S")s.style[e.slice(1)]=i;else if(e.startsWith("on")){if(typeof i!="function")throw new TypeError(`Compact DOM event ${e} must be a function`);Po(s,e.slice(2),i)}else typeof i=="boolean"||r_.has(e)?s[e]=i:s.setAttribute(e,String(i))}return s}function cc(s,t){if(t==null)return s;let e=_c(t);return e==null||(typeof e=="object"?s.appendChild(e):s.appendChild(document.createTextNode(String(e)))),s}function dc(s,t,e=null,i=null){return s.appendChild(Yi(t,e,i)),s}function uc(s,t,e=null,i=null){let n=Yi(t,e,i);return s.appendChild(n),n}function hc(...s){let t=document.createDocumentFragment();return pc(t,s),t}function l(s,t,...e){let i=document.createElement(s),n=t;o_(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))a_(i,r,o);return pc(i,e),i}l.scope=function(t,e){let i=Ki;Ki=t;try{return e()}finally{Ki=i}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function A(s){return{children:Array.from(s.childNodes),attributes:Array.from(s.attributes,t=>[t.name,t.value])}}function S(s,t){if(t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}}function fc(s){return String(s).replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function Ks(s,t,e={}){let{className:i="zx-mark"}=e,n=s==null?"":String(s),r=t==null?"":String(t).trim(),o=document.createDocumentFragment();if(r===""||n==="")return o.append(document.createTextNode(n)),o;let a=new RegExp(je(r),"gi"),c=0;for(let d of n.matchAll(a)){d.index>c&&o.append(document.createTextNode(n.slice(c,d.index)));let u=document.createElement("mark");i&&(u.className=String(i)),u.append(document.createTextNode(d[0])),o.append(u),c=d.index+d[0].length}return c<n.length&&o.append(document.createTextNode(n.slice(c))),o}function P(s){if(s==null)return null;if(E(s))return s;if(typeof s=="string")return document.querySelector(s);if(typeof s.toElement=="function"){let t=s.toElement();return E(t)?t:null}return null}function o_(s){if(s===null||typeof s!="object"||Array.isArray(s))return!1;let t=s;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function a_(s,t,e){if(t==="ref"){Ki&&typeof e=="string"&&(Ki[e]=s);return}if(t==="class"){s.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")s.style.cssText=e;else if(e&&typeof e=="object")for(let[n,r]of Object.entries(e))n.startsWith("--")||n.includes("-")?s.style.setProperty(n,String(r)):s.style[n]=r;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[n,r]of Object.entries(e))r==null?delete s.dataset[n]:s.dataset[n]=String(r);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){s.addEventListener(t.slice(2),e);return}if(e==null)return;let i=l_(t);if(i!==null)s.setAttribute(i,String(e));else if(t in s)try{s[t]=e}catch{s.setAttribute(t,String(e))}else typeof e=="boolean"?e?s.setAttribute(t,""):s.removeAttribute(t):s.setAttribute(t,String(e))}function l_(s){return s.startsWith("aria-")?s:/^aria[A-Z]/.test(s)?"aria-"+s.slice(4).toLowerCase():null}function pc(s,t){let e=s;for(let i of t.flat(1/0)){if(i==null)continue;if(typeof i=="string"||typeof i=="number"){e.append(document.createTextNode(String(i)));continue}if(typeof i!="object")continue;let n=i;if(typeof n.nodeType=="number")e.append(i);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}function c_(s,t){if(t==null)return;let e=_c(t);e!=null&&(typeof e=="object"?s.appendChild(e):s.textContent=String(e))}function _c(s){if(s&&typeof s=="object"){if(typeof s.nodeType=="number")return s;if(typeof s.toElement=="function")return s.toElement()}return s}function Po(s,t,e,i=!1){if(typeof e!="function")throw new TypeError("Compact DOM event handler must be a function");let n=String(t),r=Ui.get(s);r||(r=new Map,Ui.set(s,r));let o=r.get(n);if(o)return o.handlers.push(e),s;let a=[e],c=d=>bc(s,a,d);r.set(n,{handlers:a,listener:c});try{s.addEventListener(n,c,{passive:i})}catch{s.addEventListener(n,c)}return s}function mc(s,t,e){let i=String(t),n=Ui.get(s),r=n?.get(i);if(!r)return s;let o=r.handlers.indexOf(e);return o===-1||(r.handlers.splice(o,1),r.handlers.length===0&&(s.removeEventListener(i,r.listener),n.delete(i),n.size===0&&Ui.delete(s))),s}function gc(s,t,e=null){let i=String(t),n=Ui.get(s);if(!n?.has(i))return s;let r=e??d_(s,i),o=n.get(String(r.type));return o&&bc(s,o.handlers,r),s}function bc(s,t,e){let i=e,n=String(i.type).startsWith("key")?i.which:i.target;for(let r=t.length-1;r>=0;r-=1)t[r].call(s,e,n)===!1&&i.preventDefault()}function d_(s,t){let e={target:s,type:t,which:-1,defaultPrevented:!1,preventDefault(){e.defaultPrevented=!0}};return e}var Gi=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"}),Bo=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 Vo=null,yc="en";function wc(s){if(s!==null&&typeof s!="function")throw new TypeError("Translator must be a function or null");Vo=s}function vc(s){yc=String(s||"en")}function dt(){return yc}function Wi(s){if(!Vo)return null;let t=Vo(s);if(t==null)return null;let e=String(t);return e===s?null:e}function jo(s){return Object.prototype.hasOwnProperty.call(Gi,s)?Gi[s]:null}function Ho(s){return Object.prototype.hasOwnProperty.call(Bo,s)?Bo[s]:null}function yt(s,t){let e=Ho(s),i=Wi(s)??(e?Wi(e):null)??jo(s)??s;return T(i,t)}function T(s,t){if(t==null)return String(s);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],i=String(s).replace(/%(\d+)/g,(r,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return i=i.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?r:String(a)}if(e&&n<e.length){let a=e[n];return n+=1,a==null?r:String(a)}return r}),i}var Us=new WeakMap,xc=new WeakMap,y=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let i=this.constructor;this.#e=t===null;let n=P(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=u_(i,e);xc.set(this,{own:$o(e?.msg)?Object.freeze(te({},e.msg)):null,inherited:h_(i)});let o=[];for(let[d,u]of Object.entries(r))/^on[a-z]/.test(d)&&typeof u=="function"&&(o.push([d.slice(2),u]),delete r[d]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[d,u]of o)this.on(d,u);let a;try{a=l.scope(this.refs,()=>this.render())}catch(d){throw this.#t.abort(),d}if(this.#e){let d=E(a)?a:this.el;if(!E(d))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=d}if(!E(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=i.cssName;if(typeof c=="string"&&c){let d=`zx-${c}`;this.#s=!this.el.classList.contains(d),this.el.classList.add(d)}Us.set(this.el,this)}render(){return this.el??null}on(t,e){return this.addEventListener(t,e,{signal:this.#t.signal}),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0,signal:this.#t.signal}),this}addEvent(t,e){return this.on(t,e)}emit(t,e={},i={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let n=Sc(t,e,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=Sc(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0});this.el.dispatchEvent(r),i.honorDomCancellation&&r.defaultPrevented&&n.preventDefault()}return n}listen(t,e,i,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return t.addEventListener(e,i,{...r,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let i=this.options?.lang??this.options?.language??dt(),n=Ho(t),r=xc.get(this)??{own:$o(this.options?.msg)?this.options.msg:null,inherited:null},o=r.own,a=qo(o,i,t)??(n?qo(o,i,n):null)??Wi(t)??(n?Wi(n):null)??qo(r.inherited,i,t)??jo(t)??t;return T(a,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),Us.get(this.el)===this&&Us.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Us.get(t)??null}};function u_(s,t){let e=Ac(s),i={},n={},r=!1;for(let o of e)!o||typeof o!="object"||(Object.assign(i,o),o.msg&&typeof o.msg=="object"&&(r=!0,n=te(n,o.msg)));return Object.assign(i,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(r=!0,n=te(n,t.msg)),r&&(i.msg=n),i}function Ac(s){let t=[],e=s;for(;e&&e!==Function.prototype;)Object.prototype.hasOwnProperty.call(e,"defaults")&&t.unshift(e.defaults),e=Object.getPrototypeOf(e);return t}function $o(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function h_(s){let t=null;for(let e of Ac(s))e&&typeof e=="object"&&$o(e.msg)&&(t=te(t??{},e.msg));return t?Object.freeze(t):null}function qo(s,t,e){if(!s)return null;let i=s[t]?.[e];if(i!=null&&typeof i!="object")return String(i);let n=Object.prototype.hasOwnProperty.call(s,e)?s[e]:null;return n!=null&&typeof n!="object"?String(n):null}function Sc(s,t,e){if(typeof CustomEvent=="function")return new CustomEvent(s,{...e,detail:t});let i=new Event(s,e);return Object.defineProperty(i,"detail",{configurable:!0,enumerable:!0,value:t}),i}var I=class s extends y{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#t=new Map;static register(t,e){let i=String(t).trim().toLowerCase();if(!i)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return s.#t.set(i,e),this}static has(t){return s.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??l("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),i=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=m_(t,["data-layout","data-field-type","data-disabled","data-readonly","data-state"]),t.dataset.layout=i,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):x("zx-field"),this.name=String(this.options.name??this.options.id??"");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?l("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=l("div",{class:"zx-field__control"}),d=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),u=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),h=l("div",{class:"zx-field__body"},c,d,u);this._ownedNodes.push(a,h),t.append(a,h);let f=s.#t.get(e);if(f)try{this.adapter=p_(f(this,this.options))}catch(m){let g=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${e}" failed: ${g}`),this.adapter=zc(g,this.controlId)}else{let m=this.msg("field.unknown",e);console.warn(`[zx.Field] ${m}`),this.adapter=zc(m,this.controlId)}let p=this.adapter.el;p.id||(p.id=this.controlId);let _=this.adapter.labelTarget??(Ys(p)?p:__(p))??p;return this._labelled=_,_!==p&&Ys(_)&&!_.id&&(_.id=`${this.controlId}-input`),a.htmlFor=Ys(_)?_.id:p.id,Ys(_)||_.setAttribute("aria-labelledby",n),this._baseDescribedBy=_.getAttribute("aria-describedby")??"",c.append(p),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=u,this._syncDescription(),this.initialValue=f_(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.options.readonly&&this.setReadonly(!0),this.listen(p,"change",()=>{this.emit("change",{value:this.getValue()})}),t}getValue(){return this.adapter.get()}setValue(t,{silent:e=!1}={}){return this.adapter.set(t,{silent:e}),e||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(t){let e=!!t;return this.adapter.setDisabled(e),this.el.dataset.disabled=String(e),this}setReadonly(t){let e=!!t;return this.adapter.setReadonly?.(e),this.el.dataset.readonly=String(e),this}setHighlight(t,e="danger"){if(!t)return this.clearHighlight();let i=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=i,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,i==="danger"&&t?(this._highlight.setAttribute("role","alert"),this._labelled.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof y))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(i=>i.split(/\s+/)).filter(Boolean);e.length?this._labelled.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this._labelled.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();g_(this.el,this._rootAttributes??new Map),super.destroy()}};function Ko(s){if(typeof s=="number")return Number.isInteger(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=Tc(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function Uo(s){if(typeof s=="number")return Number.isFinite(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=Tc(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function Tc(s){let t=s.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",i=e?t.slice(1):t;if(!/\d/.test(i))return null;let n=[...i.matchAll(/\./g)].map(c=>c.index),r=[...i.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",d=c==="."?",":".",u=i.lastIndexOf(c),h=i.slice(0,u),f=i.slice(u+1);if(!/^\d+$/.test(f)||!kc(h,d))return null;o=h.split(d).join("")+"."+f}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!kc(i,c))return null;o=i.split(c).join("")}else r.length===1?o=i.replace(",","."):o=i;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(e+o);return Number.isFinite(a)?a:null}function kc(s,t){let e=s.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(i=>/^\d{3}$/.test(i))}function f_(s,t){return t!==void 0?t:s==="checkbox"?!1:""}function p_(s){if(!s||typeof s!="object")throw new TypeError("Adapter must return an object");if(!(s.el&&s.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof s[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return s}function zc(s,t){let e=l("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},s);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function Ys(s){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(s.tagName)}function __(s){for(let t of s.querySelectorAll('input:not([type="hidden"]), select, textarea'))if(!(t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby")||[...t.labels??[]].some(i=>i.textContent?.trim())))return t;return null}function m_(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function g_(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}function Qi(s,t,e){let i={...t.props??{}};for(let n of Object.keys(i))(/^on[a-z]/i.test(n)||n==="content")&&delete i[n];return{name:s.name||void 0,...i,...e}}function Gs(s,t){return(e,i)=>{let n=l(s,Qi(e,i,{type:s==="input"?t:void 0,placeholder:i.placeholder,required:i.required,disabled:i.disabled}));return{...Yo(n),setReadonly:r=>{n.readOnly=r}}}}function Yo(s){return{el:s,get:()=>s.value,set:t=>{s.value=t==null?"":String(t)},focus:()=>s.focus(),setDisabled:t=>{s.disabled=t}}}function Ic(s){return(t,e)=>{let i=s==="int"?Ko:Uo,n=l("input",Qi(t,e,{type:"text",inputMode:s==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(n,"blur",()=>{let r=i(n.value);if(!r.valid){t.setHighlight(t.msg(`field.${s}`),"danger");return}r.value!==""&&(n.value=String(r.value)),t.clearHighlight()}),{...Yo(n),get:()=>i(n.value).value,setReadonly:r=>{n.readOnly=r}}}}var b_=(s,t)=>{let e=l("input",Qi(s,t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:i=>{e.checked=!!i},focus:()=>e.focus(),setDisabled:i=>{e.disabled=i}}},y_=(s,t)=>{let e=l("select",Qi(s,t,{required:t.required,disabled:t.disabled}));for(let[i,n]of Ec(t.options))e.append(l("option",{value:i},n));return Yo(e)},w_=(s,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),i=s.controlId,n=Ec(t.options).map(([r,o],a)=>{let c=l("input",{type:"radio",name:i,value:r,required:!!t.required&&a===0,disabled:t.disabled});return e.append(l("label",{class:"zx-field__option"},c,l("span",{},o))),c});return{el:e,get:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;e.setAttribute("aria-disabled",String(r))}}},v_=(s,t)=>{let e=l("div",Qi(s,t,{class:"zx-field__static",name:void 0})),i=null;return{el:e,get:()=>e.textContent,set:r=>{Cc(i),i=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(i={node:r,parent:r.parentNode,next:r.nextSibling},e.replaceChildren(r)):e.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{e.setAttribute("aria-disabled",String(r))},destroy:()=>Cc(i)}};function Cc(s){s&&(s.parent?s.parent.insertBefore(s.node,s.next?.parentNode===s.parent?s.next:null):s.node.remove())}var x_=(s,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(s,t)};function Ec(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}I.register("text",Gs("input","text"));I.register("password",Gs("input","password"));I.register("textarea",Gs("textarea","text"));I.register("checkbox",b_);I.register("int",Ic("int"));I.register("float",Ic("float"));I.register("select",y_);I.register("optionlist",w_);I.register("hidden",Gs("input","hidden"));I.register("html",v_);I.register("custom",x_);function ie(s,t,e){let i=Mc(t).split(/\s+/).filter(Boolean);return i.length===0?s.slice():s.filter(n=>{let r=S_(n,e).map(Mc);return i.every(o=>r.some(a=>a.includes(o)))})}function S_(s,t){return s===null||typeof s!="object"?[s]:!Array.isArray(t)||t.length===0?[s]:t.map(e=>typeof e=="function"?e(s):s[e])}function Mc(s){return String(s??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var lt=class extends y{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,hideLabel:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let a of["role","aria-label","aria-labelledby","data-state"])this._originalAttributes.set(a,t.getAttribute(a));let e=this._message("checklist.label","Checklist"),i=x("zx-checklist-label"),n=this.options.hideLabel?null:l("div",{class:"zx-checklist__label",id:i},e),r=l("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),o=l("div",{ref:"list",class:"zx-checklist__list"});return o.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(...[n,r,o].filter(Boolean)),t.setAttribute("role","group"),n?t.setAttribute("aria-labelledby",i):t.setAttribute("aria-label",e),this.listen(r,"input",()=>this.search(r.value)),this.listen(o,"change",a=>{let c=a.target;if(!c?.matches?.('input[type="checkbox"][data-index]'))return;let d=this._visibleItems[Number(c.dataset.index)];if(d===void 0)return;let u=this._itemValue(d);c.checked?this._checked.add(u):this._checked.delete(u),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),t}setItems(t){return this._replaceItems(t),this}getValues(){return this._items.map(t=>this._itemValue(t)).filter(t=>this._checked.has(t))}setValues(t){let e=new Set(t==null?[]:Array.from(t)),i=new Set(this._items.map(n=>this._itemValue(n)).filter(n=>e.has(n)));return this._replaceChecked(i),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=ie(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,i]of this._originalAttributes)i===null?t.removeAttribute(e):t.setAttribute(e,i)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=ie(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,i)=>{let n=x("zx-checklist-item"),r=l("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:i}});return l("label",{class:"zx-checklist__item",for:n},r,l("span",{},this._itemLabel(e)))});t.length===0&&t.push(l("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){A_(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let i=this.msg(t);return i===t?e:i}};function A_(s,t){return s.size===t.size&&Array.from(s).every(e=>t.has(e))}function Dc(){I.register("checklist",(s,t)=>{let e=s.own(new lt(null,{hideLabel:!0,...t.props??{}})),i=!1,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(i));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=i};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{n||s.emit("change",{value:o.detail.values})}),e.on("loaded",r),{el:e.el,get:()=>e.getValues(),set:o=>{n=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{i=!!o,r()}}})}var k_=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),He=class extends y{static cssName="code-editor";static defaults={value:"",name:"",language:"text",label:"Code editor",placeholder:"",rows:12,indent:" ",wrap:"off",spellcheck:!1,readOnly:!1,disabled:!1,status:!0};render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._initialChildren=this._createdRoot?[]:[...t.childNodes],this._initialAttributes=new Map(["data-language","data-readonly","data-disabled"].map(e=>[e,t.getAttribute(e)])),this._language=Nc(this.options.language),this._languageLabel=l("span",{class:"zx-code-editor__language"},this._language),this._position=l("span",{class:"zx-code-editor__position",role:"status",ariaLive:"polite"}),this._header=l("div",{class:"zx-code-editor__header"},this._languageLabel,this.options.status?this._position:null),this._input=l("textarea",{class:"zx-code-editor__input",name:this.options.name?String(this.options.name):void 0,ariaLabel:String(this.options.label??"Code editor"),placeholder:String(this.options.placeholder??""),rows:C_(this.options.rows),wrap:T_(this.options.wrap),spellcheck:!!this.options.spellcheck,readOnly:!!this.options.readOnly,disabled:!!this.options.disabled,autocomplete:"off",autocapitalize:"off"}),this._input.value=String(this.options.value??""),t.dataset.language=this._language,t.dataset.readonly=String(!!this.options.readOnly),t.dataset.disabled=String(!!this.options.disabled),t.replaceChildren(this._header,this._input),this._tabReleased=!1,this.listen(this._input,"keydown",e=>this._handleKeydown(e)),this.listen(this._input,"blur",()=>{this._tabReleased=!1}),this.listen(this._input,"input",()=>{this._updatePosition(),this.emit("input",{value:this.getValue()})}),this.listen(this._input,"change",()=>this.emit("change",{value:this.getValue()}));for(let e of["click","keyup","select","focus"])this.listen(this._input,e,()=>this._updatePosition());return this._updatePosition(),t}getValue(){return this._input.value}setValue(t,{silent:e=!1}={}){let i=String(t??"");return this._input.value===i?this:(this._input.value=i,this._updatePosition(),e||this.emit("change",{value:i}),this)}setLanguage(t){return this._language=Nc(t),this.el.dataset.language=this._language,this._languageLabel.textContent=this._language,this}focus(){return this._input.focus(),this}enable(){return this._input.disabled=!1,this.el.dataset.disabled="false",this}disable(){return this._input.disabled=!0,this.el.dataset.disabled="true",this}setReadOnly(t){return this._input.readOnly=!!t,this.el.dataset.readonly=String(!!t),this}_handleKeydown(t){if(t.isComposing||k_.has(t.key))return;if(t.key==="Escape"){this._tabReleased=!0;return}let e=this._tabReleased;if(this._tabReleased=!1,e||t.key!=="Tab"||t.altKey||t.ctrlKey||t.metaKey||this._input.readOnly||this._input.disabled)return;let i=String(this.options.indent??" ");if(!i)return;t.preventDefault();let n=Go(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0,i,t.shiftKey);n.value!==this._input.value&&(this._input.value=n.value,this._input.setSelectionRange(n.start,n.end),this._updatePosition(),this.emit("input",{value:this.getValue()}))}_updatePosition(){if(!this.options.status)return;let t=Wo(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0);this._position.textContent=t.lines>1?`Ln ${t.line}, Col ${t.column} \xB7 ${t.lines} lines selected`:`Ln ${t.line}, Col ${t.column}`}destroy(){if(!this._createdRoot){this.el.replaceChildren(...this._initialChildren);for(let[t,e]of this._initialAttributes)e===null?this.el.removeAttribute(t):this.el.setAttribute(t,e)}super.destroy()}};function Go(s,t,e,i=" ",n=!1){let r=String(s??""),o=String(i??""),a=Ws(t,r.length),c=Ws(e,r.length);if(!o)return{value:r,start:a,end:c};if(a===c&&!n)return{value:r.slice(0,a)+o+r.slice(c),start:a+o.length,end:a+o.length};let d=r.lastIndexOf(`
2
2
  `,Math.max(0,a-1))+1,u=r.indexOf(`
3
3
  `,c);u<0&&(u=r.length);let f=r.slice(d,u).split(`
4
- `),p=0,_=0,m=f.map((w,v)=>{if(!n)return _+=o.length,o+w;let z=k_(w,o);return v===0&&(p=z),_-=z,w.slice(z)}).join(`
5
- `),b=n?Math.max(d,a-Math.min(p,a-d)):a+o.length;return{value:r.slice(0,d)+m+r.slice(u),start:b,end:Math.max(b,c+_)}}function Wo(s,t,e=t){let i=String(s??""),n=Ws(t,i.length),r=Ws(e,i.length),o=i.slice(0,n);return{line:o.split(`
4
+ `),p=0,_=0,m=f.map((w,v)=>{if(!n)return _+=o.length,o+w;let z=z_(w,o);return v===0&&(p=z),_-=z,w.slice(z)}).join(`
5
+ `),g=n?Math.max(d,a-Math.min(p,a-d)):a+o.length;return{value:r.slice(0,d)+m+r.slice(u),start:g,end:Math.max(g,c+_)}}function Wo(s,t,e=t){let i=String(s??""),n=Ws(t,i.length),r=Ws(e,i.length),o=i.slice(0,n);return{line:o.split(`
6
6
  `).length,column:n-o.lastIndexOf(`
7
7
  `),lines:i.slice(n,r).split(`
8
- `).length}}function k_(s,t){return s.startsWith(t)?t.length:t===" "?s.startsWith(" ")?1:Math.min(/^ +/.exec(s)?.[0].length??0,2):Math.min(/^\s+/.exec(s)?.[0].length??0,t.length)}function Dc(s){let t=String(s??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(t)?t:"text"}function z_(s){let t=Number(s);return Number.isFinite(t)?Math.max(2,Math.min(100,Math.round(t))):12}function C_(s){return["off","soft","hard"].includes(String(s))?s:"off"}function Ws(s,t){let e=Number(s);return Math.max(0,Math.min(t,Number.isFinite(e)?Math.round(e):0))}function Nc(){I.register("code",(s,t)=>{let e=s.own(new He(null,{label:t.label?String(t.label):"Code editor",placeholder:t.placeholder,readOnly:!!t.props?.readOnly,disabled:!!t.disabled,...t.props??{},value:t.value})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),e.on("input",n=>s.emit("input",{value:n.detail.value})),{el:e.el,get:()=>e.getValue(),set:n=>{i=!0;try{e.setValue(n,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadOnly(n)}}})}var Oc=["January","February","March","April","May","June","July","August","September","October","November","December"],Fc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Pc=/%[demYyHMSaAbBs]/g;function N(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":String(t).replace(Pc,e=>{switch(e){case"%d":return qe(s.getDate());case"%e":return String(s.getDate());case"%m":return qe(s.getMonth()+1);case"%Y":return String(s.getFullYear()).padStart(4,"0");case"%y":return qe(s.getFullYear()%100);case"%H":return qe(s.getHours());case"%M":return qe(s.getMinutes());case"%S":return qe(s.getSeconds());case"%a":return Lc("weekday",s.getDay(),Fc[s.getDay()]);case"%A":return Go("weekday",s.getDay(),Fc[s.getDay()]);case"%b":return Lc("month",s.getMonth(),Oc[s.getMonth()]);case"%B":return Go("month",s.getMonth(),Oc[s.getMonth()]);case"%s":return String(Math.floor(s.getTime()/1e3));default:return e}})}function tt(s,t){let e=[],i="^",n=0;for(let _ of String(t).matchAll(Pc)){i+=Rc(String(t).slice(n,_.index));let m=_[0],b=T_(m);if(b===null)return null;i+=`(${b})`,e.push(m),n=_.index+m.length}i+=Rc(String(t).slice(n))+"$";let r=new RegExp(i).exec(String(s));if(!r)return null;let o=Object.create(null);if(e.forEach((_,m)=>{o[_]=Number(r[m+1])}),o["%s"]!==void 0){let _=o["%s"]*1e3,m=new Date(_);return Number.isNaN(m.getTime())?null:m}let a=o["%Y"]??I_(o["%y"])??1970,c=(o["%m"]??1)-1,d=o["%d"]??o["%e"]??1,u=o["%H"]??0,h=o["%M"]??0,f=o["%S"]??0,p=new Date(0);return p.setHours(0,0,0,0),p.setFullYear(a,c,d),p.setHours(u,h,f,0),Number.isNaN(p.getTime())||o["%Y"]!==void 0&&p.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&p.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&p.getMonth()!==c||o["%d"]!==void 0&&p.getDate()!==d||o["%e"]!==void 0&&p.getDate()!==d||o["%H"]!==void 0&&p.getHours()!==u||o["%M"]!==void 0&&p.getMinutes()!==h||o["%S"]!==void 0&&p.getSeconds()!==f?null:p}function Gs(s,t,e){let i=s.getTime(),n=t instanceof Date?t.getTime():-1/0,r=e instanceof Date?e.getTime():1/0;return new Date(Math.min(r,Math.max(n,i)))}function U(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function L(s,t){let e=new Date(s.getTime());return e.setDate(e.getDate()+t),e}function Vt(s,t){let e=new Date(s.getTime()),i=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(i,n)),e}function $e(s=dt()){if(!s||s.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(s),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function qe(s){return String(s).padStart(2,"0")}function Go(s,t,e){let i=`date.${s}.${t}`,n=yt(i);return n===i?e:n}function Lc(s,t,e){let i=`date.${s}.short.${t}`,n=yt(i);return n!==i?n:Go(s,t,e).slice(0,3)}function T_(s){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[s]??null}function I_(s){if(s!==void 0)return s>=69?1900+s:2e3+s}function Rc(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Qs=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Xo=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Bc=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"}),Jo=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"}),Qo=new Map;function Xs(s){let t=String(s).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let i=t.slice(0,e).toLowerCase(),n=t.slice(e+1);if(i==="builtin"||i==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(Bc,i))return{provider:"fa",name:n,style:Bc[i],classes:null}}return{provider:null,name:t,style:null,classes:null}}function Xi(s,t={}){let{style:e="solid",family:i="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(s).replace(/^fa-/,""),a=r?Jo[o]??o:o,c=[],d=Xo[i];return d&&c.push(d),c.push(Qs[e]??Qs.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function Ji(s){let t=String(s).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${s}`);return`https://kit.fontawesome.com/${t}.js`}function Js(s){let t=Ji(s),e=Qo.get(t);if(e)return e;let i=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(d=>d.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{Qo.delete(t),r(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!a&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return Qo.set(t,i),i}var Hc="http://www.w3.org/2000/svg",qc="0 0 24 24",E_=1.75,M_=1,D=s=>[qc,s,"stroke"];var Zs=Object.freeze({"arrow-up-wide-short":D("M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4"),"arrow-down-wide-short":D("M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4"),"chevron-down":D("M6 9l6 6 6-6"),"chevron-up":D("M18 15l-6-6-6 6"),"chevron-left":D("M15 18l-6-6 6-6"),"chevron-right":D("M9 18l6-6-6-6"),check:D("M20 6 9 17l-5-5"),x:D("M18 6 6 18M6 6l12 12"),plus:D("M5 12h14M12 5v14"),minus:D("M5 12h14"),search:D("M21 21l-4.34-4.34M3 11a8 8 0 1 0 16 0a8 8 0 1 0-16 0z"),calendar:D("M8 2v3M16 2v3M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18"),clock:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 6v6l4 2"),trash:D("M10 11v6M14 11v6M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),gear:D("M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),eye:D("M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),lock:D("M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM7 11V7a5 5 0 0 1 10 0v4"),reload:D("M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8M21 3v5h-5"),list:D("M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"),filter:D("M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"),dots:D("M11 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM18 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM4 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),info:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 16v-4M12 8h.01"),warning:D("M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4M12 17h.01"),error:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 8V12M12 16H12.01"),success:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),upload:D("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),drag:D("M8 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),star:D("M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"),heart:D("M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"),tag:D("M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42zM7 7.5a.5 .5 0 1 0 1 0a.5 .5 0 1 0-1 0z"),folder:D("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"),"folder-open":D("M6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"),file:D("M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2zM14 2v5a1 1 0 0 0 1 1h5"),copy:D("M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2zM4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"),square:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2z"),code:D("M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16"),book:D("M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"),"table-cells-large":D("M4 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM4 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1z"),table:D("M12 3v18M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18M3 15h18"),image:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM7 9a2 2 0 1 0 4 0a2 2 0 1 0-4 0zM21 15l-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),columns:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM9 3v18M15 3v18"),type:D("M12 4v16M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M9 20h6"),hash:D("M4 9h16M4 15h16M10 3L8 21M16 3l-2 18"),mail:D("M22 7l-8.991 5.727a2 2 0 0 1-2.009 0L2 7M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-16a2 2 0 0 1-2-2v-12a2 2 0 0 1 2-2z"),"link-2":D("M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 1 1 0 10h-2M8 12h8"),"circle-chevron-down":D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 10l-4 4-4-4")}),D_=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list",grid:"table-cells-large"}),ta=Object.create(null),jt={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function Ke(){return{...jt}}function Zi(s={}){for(let t of["provider","style","family","fixedWidth","kit"])s[t]!==void 0&&(jt[t]=s[t]);return Ke()}function ea(s={}){return Zi({...s,provider:"fontawesome"})}function $c(){return Zi({provider:"builtin"})}async function Kc(s){let t=typeof s=="string"?{kit:s}:{...s},{kit:e,activate:i=!0,...n}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return Zi({...n,kit:Ji(e)}),await Js(e),i?ea():Ke()}function Uc(s){for(let[t,e]of Object.entries(s)){if(!Array.isArray(e)||e.length!==2&&e.length!==3||e.length===3&&e[2]!=="fill"&&e[2]!=="stroke")throw new TypeError(`Icon "${t}" must be a [viewBox, path] pair or a [viewBox, path, 'stroke'] triple`);ta[t]=e[2]==="stroke"?[String(e[0]),String(e[1]),"stroke"]:[String(e[0]),String(e[1])]}}function tn(){return[...new Set([...Object.keys(Zs),...Object.keys(ta)])].sort()}function g(s,t={}){let e=Xs(s);if(e.classes)return Zo(e.classes,t);let i=D_[e.name]??e.name;return e.provider==="builtin"?Vc(i,t):e.provider==="fa"?Zo(Xi(i,{style:e.style??t.style??jt.style,family:t.family??jt.family,fixedWidth:t.fixedWidth??jt.fixedWidth}),t):jt.provider==="fontawesome"?Zo(Xi(i,{style:t.style??jt.style,family:t.family??jt.family,fixedWidth:t.fixedWidth??jt.fixedWidth}),t):Vc(i,t)}function Vc(s,t){let e=ta[s]??Zs[s];if(!e){if(t.strict)throw new RangeError(`Unknown icon: ${s}`);return L_(s),F_(s,t)}let[i,n,r="fill"]=e,o=Yc(i,r,t),a=document.createElementNS(Hc,"path");return a.setAttribute("d",n),o.append(a),o}function Yc(s,t,e){let{size:i=16}=e,n=document.createElementNS(Hc,"svg");return n.setAttribute("class",Gc("zx-icon",e.class)),n.setAttribute("viewBox",s),n.setAttribute("width",String(i)),n.setAttribute("height",String(i)),t==="stroke"?(n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width",N_(s,i)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),Wc(n,e.label??null),n}function N_(s,t){let[,,e,i]=s.trim().split(/[\s,]+/).map(Number),n=Math.max(e,i)||24,r=E_*n/24,o=typeof t=="number"?t:/^\d*\.?\d+(px)?$/.test(String(t).trim())?parseFloat(String(t)):NaN;return o>0&&(r=Math.max(r,M_*n/o)),String(Math.round(r*1e3)/1e3)}var O_=qc;function F_(s,t){let e=Yc(O_,"stroke",t);return e.setAttribute("data-zx-icon-missing",s),e}var jc=new Set;function L_(s){jc.has(s)||(jc.add(s),console.warn(`[zx.icon] Unknown icon "${s}" \u2014 rendered an empty placeholder. Add it with registerIcons(), or render Font Awesome with useFontAwesome().`))}function Zo(s,t){let{size:e=16}=t,i=document.createElement("i");return i.className=Gc("zx-icon",...s,t.class),i.style.fontSize=typeof e=="number"?`${e}px`:String(e),Wc(i,t.label??null),i}function Wc(s,t){if(t===null){s.setAttribute("aria-hidden","true");return}s.setAttribute("role","img"),s.setAttribute("aria-label",t)}function Gc(...s){return s.flat().filter(Boolean).join(" ")}var R_=5,Ye=class extends y{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??l("div");this.el=t;let e=Qc(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let i=l("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:this._message("timePicker.label","Time")});if(this._content=i,this._addSpin(i,"h",this._message("timePicker.hour","Hour"),23),i.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"m",this._message("timePicker.minute","Minute"),59),this.options.seconds&&(i.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"s",this._message("timePicker.second","Second"),59)),t.append(i),this.options.clock){let n=x("zx-time-picker-clock");i.append(l("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:this._message("timePicker.clock","Pick the time on a clock"),ariaExpanded:"false",ariaControls:n},g("clock",{size:15}))),this._clock=this._buildClock(n),t.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),t}get(){return this._value?{...this._value}:null}set(t,{silent:e=!1}={}){let i=Qc(t);return this._value=i,this._display=i??{h:0,m:0,s:0},this._writeInputs(),!e&&i&&this.emit("change",{time:{...i}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,i,n){let r=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:i,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,i){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?j_(this.options.step):1,o=Ue(t.currentTarget.value,0,i),a=i+1,c=(o+n*r+a*r)%a;t.currentTarget.value=be(c),this._commitFromInputs()}_onInput(t,e,i){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=be(Ue(t.value,0,i)),this._commitFromInputs();let n=this._inputs.indexOf(t);this._inputs[n+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let i of this._inputs){let n=i.dataset.segment,r=n==="h"?23:59;t[n]=Ue(i.value,0,r)}let e=!this._value||!H_(this._value,t);this._value=t,this._display=t,this._writeInputs(),e&&this.emit("change",{time:{...t}})}_writeInputs(){for(let t of this._inputs){let e=t.dataset.segment;t.value=be(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=l("div",{class:"zx-time-picker__clock",id:t,hidden:!0},l("div",{class:"zx-time-picker__clock-head"},l("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectHour","Select the hour"),dataset:{unit:"h"}}),l("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),l("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectMinutes","Select the minutes"),dataset:{unit:"m"}})),l("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},l("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),l("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",i=>{let n=i.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.dataset.value))}),this.listen(this.refs.dial,"keydown",i=>this._onDialKeydown(i)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},i=this._clockUnit==="h";this.set(e),i&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],i=t.target.closest?.(".zx-time-picker__mark"),n=e.indexOf(i);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;r!==void 0?o=(n+r+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=be(this._display.h),this.refs.headMinute.textContent=be(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?this._message("timePicker.hour","Hour"):this._message("timePicker.minutes","Minutes")),!this._clockOpen)return;let e=t?this._display.h:this._display.m,i=t?P_():B_(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==i.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...i.map(a=>this._buildMark(a,e)))}else i.forEach((a,c)=>this._syncMark(n[c],a,e));let r=t&&!V_(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let i=l("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return i.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(i,t,e),i}_syncMark(t,e,i){let n=e.value===i;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}_message(t,e){let i=this.msg(t);return i===t?e:i}};function P_(){let s=[];for(let t=1;t<=12;t+=1)s.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;s.push({value:e,label:be(e),angle:t*30,ring:"inner"})}return s}function B_(){let s=[];for(let t=0;t<60;t+=R_)s.push({value:t,label:be(t),angle:t*6,ring:"outer"});return s}function V_(s){return s>=1&&s<=12}function Qc(s){return s instanceof Date&&!Number.isNaN(s.getTime())?{h:s.getHours(),m:s.getMinutes(),s:s.getSeconds()}:!s||typeof s!="object"?null:{h:Ue(s.h,0,23),m:Ue(s.m,0,59),s:Ue(s.s,0,59)}}function Ue(s,t,e){let i=Number.parseInt(String(s??""),10);return Number.isFinite(i)?Math.max(t,Math.min(e,i)):t}function j_(s){let t=Math.round(Number(s));return Number.isFinite(t)&&t>0&&t<=59?t:5}function be(s){return String(s).padStart(2,"0")}function H_(s,t){return s.h===t.h&&s.m===t.m&&s.s===t.s}var se=class extends y{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??l("div");this._min=wt(en(this.options.min)),this._max=wt(en(this.options.max)),this._value=this._normalizeValue(en(this.options.value)),this._focused=wt(this._value)??this._clampFocus(wt(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=q_(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=l("div",{class:"zx-date-picker__surface"},l("div",{class:"zx-date-picker__header"},l("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousMonth","Previous month")},g("chevron-left")),l("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),l("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextMonth","Next month")},g("chevron-right"))),l("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},l("div",{class:"zx-date-picker__quick-header"},l("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousYear","Previous year")},g("chevron-left")),l("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),l("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextYear","Next year")},g("chevron-right"))),l("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),l("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:this._message("datePicker.calendar","Calendar")},l("thead",{ref:"weekdays"}),l("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",i=>this._onQuickClick(i)),this.listen(this.refs.quickGrid,"keydown",i=>this._onQuickKeydown(i)),this.listen(this.refs.days,"click",i=>this._onDayClick(i)),this.listen(this.refs.days,"keydown",i=>this._onDayKeydown(i)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new Ye(null,{value:this._value,seconds:!1}),this._timePicker.on("change",i=>{let n=i.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return ia(this._value)}set(t,{silent:e=!1}={}){let i=this._normalizeValue(en(t));return this._value=i,i&&(this._focused=wt(i),this._viewYear=i.getFullYear(),this._viewMonth=i.getMonth()),this._timePicker?.set(i,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:ia(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),i=wt(e);return this._min&&i<this._min&&Xc(e,this._min),this._max&&i>this._max&&Xc(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:this._message("datePicker.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=L(e,(this._weekStart+i)%7);t.append(l("th",{scope:"col",ariaLabel:N(n,"%A")},N(n,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,i=L(t,-e);this.refs.heading.textContent=N(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",this._message("datePicker.chooseMonthYear","Choose month and year, %1",N(t,"%B %Y")));let n=[];for(let r=0;r<6;r+=1){let o=L(i,r*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:this._message("datePicker.week","Week %1",Jc(o))},String(Jc(o))));for(let c=0;c<7;c+=1){let d=L(o,c),u=!!(this._value&&U(d,this._value)),h=!this._inRange(d),f=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:U(d,this._focused)?0:-1,ariaSelected:String(u),ariaDisabled:String(h),ariaCurrent:U(d,new Date)?"date":null,ariaLabel:`${N(d,"%e")} ${N(d,"%B %Y")}`,dataset:{date:N(d,"%Y-%m-%d"),otherMonth:d.getMonth()===this._viewMonth?null:"true"}},N(d,"%e"));a.append(l("td",{role:"presentation"},f))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=tt(e.dataset.date,"%Y-%m-%d");i&&this._inRange(i)&&this._selectDate(i)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=tt(e.dataset.date,"%Y-%m-%d");if(!i)return;let n=null;if(t.key==="ArrowLeft")n=L(i,-1);else if(t.key==="ArrowRight")n=L(i,1);else if(t.key==="ArrowUp")n=L(i,-7);else if(t.key==="ArrowDown")n=L(i,7);else if(t.key==="PageUp")n=Vt(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=Vt(i,t.shiftKey?12:1);else if(t.key==="Home")n=L(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=L(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(i)&&this._selectDate(i);return}n&&(t.preventDefault(),this._moveFocus(n))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=wt(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),i=this._timePicker?.get();i?e.setHours(i.h,i.m,i.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=wt(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:ia(e)})}_pageMonth(t){this._closeQuickPick();let e=Vt(this._focused,t);this._focused=wt(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._viewYear,e,1);t.push(l("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},N(i,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let i=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=i-1;else if(t.key==="ArrowRight")n=i+1;else if(t.key==="ArrowUp")n=i-3;else if(t.key==="ArrowDown")n=i+3;else if(t.key==="Home")n=0;else if(t.key==="End")n=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(i);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;t.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=wt(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=wt(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${N(t,"%Y-%m-%d")}"]`)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function en(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function wt(s){return s?new Date(s.getFullYear(),s.getMonth(),s.getDate()):null}function ia(s){return s?new Date(s.getTime()):null}function Xc(s,t){s.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function q_(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:$e()}function Jc(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/864e5+1)/7)}var We=class extends se{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._min=nn(sn(this.options.min)),this._max=nn(sn(this.options.max)),this._value=this._normalizeMonth(sn(this.options.value));let e=this._value??nn(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let i=l("div",{class:"zx-month-picker__surface"},l("div",{class:"zx-month-picker__header"},l("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.previousYear","Previous year")},g("chevron-left")),l("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),l("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.nextYear","Next year")},g("chevron-right"))),l("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:this._message("monthPicker.chooseMonth","Choose month")}));return this._content=i,t.append(i),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(sn(t)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),e||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(t){if(!t)return null;let e=nn(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._year,e,1),n=!!(this._value&&$_(i,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(i)),ariaLabel:N(i,"%B %Y"),dataset:{month:e}},N(i,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let i=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-3;else if(t.key==="ArrowDown")n=3;else if(t.key==="Home")n=-(i%3);else if(t.key==="End")n=2-i%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(i);return}if(n===null)return;t.preventDefault();let r=this._year*12+i+n;this._year=Math.floor(r/12),this._focusedMonth=(r%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function sn(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function nn(s){return s?new Date(s.getFullYear(),s.getMonth(),1):null}function $_(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()}function Zc(){I.register("month",(s,t)=>{let e=s.own(new We(null,{...t.props??{},value:t.value})),i=!1,n=()=>{e.el.setAttribute("aria-disabled",String(i));for(let r of e.el.querySelectorAll("button"))r.disabled=i};return s.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>s.emit("change",{value:r.detail.date})),{el:e.el,get:()=>e.get(),set:r=>{e.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>e.focus(),setDisabled:r=>{i=!!r,n()}}})}var K_=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function nt(s,t,e={}){if(!(s instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let i=K_.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,a=s.getAttribute("style"),c=t.getAttribute("style"),d=t.getAttribute("popover"),u=!1,h=null,f=()=>{},p=()=>{};t.setAttribute("popover","manual");let _=typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a"),m=`--${x("zx-a")}`;if(_){let b=td(s);s.style.setProperty("anchor-name",[...b,m].join(", ")),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",m);let w=U_(i,getComputedStyle(s).direction==="rtl");t.style.setProperty("position-area",w),t.style.setProperty("inset-area",w),t.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let v=i.startsWith("top")?"margin-bottom":i.startsWith("bottom")?"margin-top":i.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(v,`${n}px`),f=()=>{o&&(t.style.minWidth=`${s.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(h=new ResizeObserver(f),h.observe(s))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",f=()=>Y_(s,t,{placement:i,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",f,{capture:!0,passive:!0}),window.addEventListener("resize",f,{passive:!0}),typeof ResizeObserver=="function"&&(h=new ResizeObserver(f),h.observe(s)),p=()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)};return W_(t),f(),{update(){u||f()},destroy(){if(!u){if(u=!0,h?.disconnect(),p(),G_(t),_){let b=td(s).filter(w=>w!==m);b.length?s.style.setProperty("anchor-name",b.join(", ")):s.style.removeProperty("anchor-name"),a===null&&s.getAttribute("style")===""&&s.removeAttribute("style")}id(t,"style",c),id(t,"popover",d)}}}}function td(s){return String(s.style?.getPropertyValue("anchor-name")??"").split(",").map(t=>t.trim()).filter(t=>t&&t!=="none")}function U_(s,t){return{"bottom-start":t?"bottom span-left":"bottom span-right","bottom-end":t?"bottom span-right":"bottom span-left","top-start":t?"top span-left":"top span-right","top-end":t?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[s]}function Y_(s,t,{placement:e,offset:i,flip:n,matchWidth:r}){let o=s.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,d=document.documentElement.clientHeight||window.innerHeight,u=e,h=ed(e),f=o.bottom+i,p=o.top-i-a.height,_=o.right+i,m=o.left-i-a.width;n&&(h==="bottom"&&f+a.height>d&&p>=0?u=rn(e,"bottom","top"):h==="top"&&p<0&&f+a.height<=d?u=rn(e,"top","bottom"):h==="right"&&_+a.width>c&&m>=0?u=rn(e,"right","left"):h==="left"&&m<0&&_+a.width<=c&&(u=rn(e,"left","right")));let b=ed(u),w,v;if(b==="bottom"||b==="top"){let z=getComputedStyle(s).direction==="rtl";u.endsWith("-end")?w=z?o.left:o.right-a.width:u.endsWith("-start")?w=z?o.right-a.width:o.left:w=o.left+(o.width-a.width)/2,v=b==="bottom"?f:p}else w=b==="right"?_:m,u.endsWith("-end")?v=o.bottom-a.height:u.endsWith("-start")?v=o.top:v=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(q(w,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(q(v,0,Math.max(0,d-a.height)))}px`}function ed(s){return s.split("-")[0]}function rn(s,t,e){return s.replace(t,e)}function W_(s){if(typeof s.showPopover=="function")try{s.showPopover()}catch{}}function G_(s){if(typeof s.hidePopover=="function")try{s.hidePopover()}catch{}}function id(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var Q_=6,ld=864e5;function we(s,t){let e=rt(ye(s)),i=rt(ye(t));return e&&i&&e.getTime()>i.getTime()?{start:i,end:e}:{start:e,end:i}}function Ge(s,t){let e=we(s,t);return!e.start||!e.end?0:Math.round((rd(e.end)-rd(e.start))/ld)}function ra(s,t,e){let i=rt(ye(s));if(!i)return null;let n=we(t,e);return!n.start&&!n.end?null:n.end?n.start?i.getTime()<n.start.getTime()||i.getTime()>n.end.getTime()?null:U(i,n.start)?"start":U(i,n.end)?"end":"middle":U(i,n.end)?"end":null:U(i,n.start)?"start":null}function Qe(s,t={}){let e=rt(ye(t.min)),i=rt(ye(t.max)),n=on(t.minNights)??0,r=on(t.maxNights),{start:o,end:a}=we(s?.start,s?.end);return o&&(o=na(o,e,i)),a&&(a=na(a,e,i)),!o||!a?{start:o,end:a}:(r!==null&&Ge(o,a)>r&&(a=L(o,r)),n>0&&Ge(o,a)<n&&(a=L(o,n),i&&a.getTime()>i.getTime()&&(a=new Date(i.getTime()),o=L(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var Xe=class extends y{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._rootAttributes=im(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=rt(ye(this.options.min)),this._max=rt(ye(this.options.max)),this._minNights=on(this.options.minNights)??0,this._maxNights=on(this.options.maxNights),this._weekStart=Z_(this.options.weekStart),this._monthCount=tm(this.options.months),this._presets=J_(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Qe({start:this.options.start,end:this.options.end},this._bounds());this._start=e.start,this._end=e.end,this._picking=!!(e.start&&!e.end),this._remember(),this._focused=ne(this._start)??this._clampFocus(rt(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",K("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let i=l("div",{class:"zx-date-range-picker__surface"},this._presets.length?l("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:K("daterange.presets","Date range presets")},this._presets.map(r=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[i,n],t.append(i,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:ne(this._start),end:ne(this._end)}}set(t={},{silent:e=!1}={}){let i=Qe({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=i.start,this._end=i.end,this._picking=!!(i.start&&!i.end),this._remember(),this._hover=null,i.start?(this._focused=ne(i.start),this._setView(i.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],sm(this.el,this._rootAttributes??new Map),super.destroy()}_bounds(){return{min:this._min,max:this._max,minNights:this._minNights,maxNights:this._maxNights}}_selectable(t){let e=rt(t);if(!e||this._min&&e.getTime()<this._min.getTime()||this._max&&e.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||e.getTime()<=this._start.getTime())return!0;let i=Ge(this._start,e);return!(i<this._minNights||this._maxNights!==null&&i>this._maxNights)}_choose(t){let e=rt(t);if(this._disabled||!e||!this._selectable(e))return;this._picking&&this._start&&e.getTime()>this._start.getTime()?(this._end=e,this._picking=!1,this._remember()):(this._start=e,this._end=null,this._picking=!0),this._focused=e,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),this._picking||this.emit("change",this.get())}_remember(){let t=!!(this._start&&this._end);this._committedStart=t?ne(this._start):null,this._committedEnd=t?ne(this._end):null}_abandon(){return this._picking?(this._start=ne(this._committedStart),this._end=ne(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return na(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let i of t)i.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),i=od(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return!1;let n=i<0?i:i-(e-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),i=od(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return t;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),n))}_moveFocus(t){let e=rt(t);this._focused=e,this._ensureVisible(e)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(e)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(t){let e=t.target?.closest?.("[data-preset]");if(!e||this._disabled)return;let i=this._presets.find(r=>r.name===e.dataset.preset);if(!i)return;let n=i.range();this.set({start:n?.start??null,end:n?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,i=e?.closest?.("[data-nav]");if(i){this._pageView(i.dataset.nav==="next"?1:-1);return}let n=this._cellFor(e);n&&this._choose(n.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?rt(t):null;!e&&!this._hover||e&&this._hover&&U(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let i=e.date,n=null;if(t.key==="ArrowLeft")n=L(i,-1);else if(t.key==="ArrowRight")n=L(i,1);else if(t.key==="ArrowUp")n=L(i,-7);else if(t.key==="ArrowDown")n=L(i,7);else if(t.key==="PageUp")n=Vt(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=Vt(i,t.shiftKey?12:1);else if(t.key==="Home")n=L(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=L(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(i);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!n||this._disabled||(t.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=N(t,"%B %Y"),i=(t.getDay()-this._weekStart+7)%7,n=L(t,-i),r=[];for(let o=0;o<Q_;o+=1){let a=L(n,o*7),c=l("tr"),d=em(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:d?K("daterange.week","Week %1",[ad(a)]):null},d?String(ad(a)):""));for(let u=0;u<7;u+=1){let h=L(a,u),f=l("td",{role:"presentation"});if(h.getMonth()===t.getMonth()&&h.getFullYear()===t.getFullYear()){let p=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:N(h,"%Y-%m-%d")}},N(h,"%e"));f.append(p),this._dayCells.push({date:h,cell:f,button:p})}c.append(f)}r.push(c)}return l("div",{class:"zx-date-range-picker__month"},l("div",{class:"zx-date-range-picker__header"},l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:K("daterange.previousMonth","Previous month")},g("chevron-left")),l("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:K("daterange.nextMonth","Next month")},g("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...r)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:K("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=L(e,(this._weekStart+i)%7);t.append(l("th",{scope:"col",ariaLabel:N(n,"%A")},N(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let i of this._dayCells)U(i.date,this._focused)&&(e=i);e||(e=this._dayCells[0]??null);for(let i of this._dayCells){let{date:n,cell:r,button:o}=i,a=this._dayState(n);sa(r,"range",a.range),sa(r,"rangeEdge",a.edge),sa(o,"range",a.range),o.tabIndex=i===e?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),U(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let i=ra(t,this._start,this._end);if(!i)return{range:null,edge:null};let n=U(this._start,this._end);return i==="start"?{range:i,edge:n?"both":"start"}:i==="end"?{range:i,edge:n?"both":"end"}:{range:i,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return U(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:U(t,e)?"end":null}:{range:null,edge:null}:{range:null,edge:null}}_previewEnd(){if(!this._picking||!this._start||this._disabled)return null;let t=this._hover??this._focused;if(!t)return null;let e=rt(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let i=N(t,"%A, %e %B %Y");return e==="start"?`${i}, ${K("daterange.day.start","range start")}`:e==="end"?`${i}, ${K("daterange.day.end","range end")}`:e==="middle"?`${i}, ${K("daterange.day.middle","in selected range")}`:i}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return K("daterange.status.empty","No date range selected");if(!this._end)return K("daterange.status.start","%1 selected, choose an end date",[N(this._start,"%e %B %Y")]);let t=Ge(this._start,this._end),e=t===1?K("daterange.night","1 night"):K("daterange.nights","%1 nights",[t]);return`${X_(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(i=>i.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>U(e.date,t))?.button??null}};function oa(){return[{name:"today",label:K("daterange.preset.today","Today"),range:()=>sd(It())},{name:"yesterday",label:K("daterange.preset.yesterday","Yesterday"),range:()=>sd(L(It(),-1))},{name:"last7",label:K("daterange.preset.last7","Last 7 days"),range:()=>({start:L(It(),-6),end:It()})},{name:"last30",label:K("daterange.preset.last30","Last 30 days"),range:()=>({start:L(It(),-29),end:It()})},{name:"thisMonth",label:K("daterange.preset.thisMonth","This month"),range:()=>nd(It(),0)},{name:"lastMonth",label:K("daterange.preset.lastMonth","Last month"),range:()=>nd(It(),-1)},{name:"thisQuarter",label:K("daterange.preset.thisQuarter","This quarter"),range:()=>{let s=It(),t=Math.floor(s.getMonth()/3)*3;return{start:new Date(s.getFullYear(),t,1),end:new Date(s.getFullYear(),t+3,0)}}},{name:"thisYear",label:K("daterange.preset.thisYear","This year"),range:()=>{let s=It();return{start:new Date(s.getFullYear(),0,1),end:new Date(s.getFullYear(),11,31)}}}]}function K(s,t,e){let i=yt(s);return T(i===s?t:i,e)}function X_(s,t){if(U(s,t))return N(s,"%e %B %Y");let e=N(t,"%e %B %Y");return s.getFullYear()!==t.getFullYear()?`${N(s,"%e %B %Y")} \u2013 ${e}`:s.getMonth()!==t.getMonth()?`${N(s,"%e %B")} \u2013 ${e}`:`${N(s,"%e")} \u2013 ${e}`}function J_(s){return s===!0?oa():Array.isArray(s)?s.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function It(){return rt(new Date)}function sd(s){return{start:s,end:new Date(s.getTime())}}function nd(s,t){return{start:new Date(s.getFullYear(),s.getMonth()+t,1),end:new Date(s.getFullYear(),s.getMonth()+t+1,0)}}function ye(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function rt(s){return!s||Number.isNaN(s.getTime())?null:new Date(s.getFullYear(),s.getMonth(),s.getDate())}function ne(s){return s?new Date(s.getTime()):null}function na(s,t,e){return t&&s.getTime()<t.getTime()?new Date(t.getTime()):e&&s.getTime()>e.getTime()?new Date(e.getTime()):new Date(s.getTime())}function rd(s){return Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())}function od(s){return s.getFullYear()*12+s.getMonth()}function on(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function Z_(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:$e()}function tm(s){let t=Number(s);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function em(s,t){for(let e=0;e<7;e+=1){let i=L(s,e);if(i.getMonth()===t.getMonth()&&i.getFullYear()===t.getFullYear())return!0}return!1}function ad(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/ld+1)/7)}function sa(s,t,e){e==null?delete s.dataset[t]:s.dataset[t]=e}function im(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function sm(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}var nm={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function ln(s,t,e){let i=String(s??"").trim();if(i==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",d=r===""?[i]:i.split(new RegExp(`${a}${je(r)}${c}`));if(d.length>2)return null;let u=tt(d[0].trim(),t);if(!u)return null;if(d.length===1)return{start:u,end:new Date(u.getTime())};if(d[1].trim()==="")return{start:u,end:null};let h=tt(d[1].trim(),t);return h?we(u,h):null}function aa(s,t,e){let i=s?.start??null,n=s?.end??null;return!i&&!n?"":n?i?`${N(i,t)}${e}${N(n,t)}`:N(n,t):N(i,t)}var Je=class extends y{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._originalClearable=t.getAttribute("data-clearable"),t.toggleAttribute("data-clearable",!!this.options.clearable),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=x("zx-date-range-box-popover"),i=l("div",{class:"zx-date-range-box__content"},l("div",{ref:"control",class:"zx-date-range-box__control"},l("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:cd("daterange.clear","Clear date range")},g("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:cd("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},g("calendar"))),l("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new Xe(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=nt(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(),an(this.el,"data-state",this._originalState),an(this.el,"aria-disabled",this._originalAriaDisabled),an(this.el,"data-clearable",this._originalClearable),super.destroy()}_apply(t,{silent:e=!1,push:i=!0}={}){this._range=t,i&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=ln(t,this._format,this._separator);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this._apply(this._clamp(e))}_coerce(t){return t==null?{start:null,end:null}:typeof t=="string"?this._clamp(ln(t,this._format,this._separator)??{start:null,end:null}):Array.isArray(t)?this._clamp({start:this._toDate(t[0]),end:this._toDate(t[1])}):typeof t!="object"?{start:null,end:null}:this._clamp({start:this._toDate(t.start),end:this._toDate(t.end)})}_toDate(t){return t instanceof Date?Number.isNaN(t.getTime())?null:new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?new Date(t*1e3):typeof t=="string"&&t.trim()!==""?tt(t.trim(),this._format):null}_clamp(t){return Qe(t,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let t=this._format.replace(/%[demYy]/g,e=>nm[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=aa(this._range,this._format,this._separator),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear(),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&an(this.el,"data-state",this._originalState),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}};function cd(s,t,e){let i=yt(s);return T(i===s?t:i,e)}function an(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}function dd(){I.register("daterange",(s,t)=>{let e=s.own(new Je(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:{start:i.detail.start,end:i.detail.end}})),{el:e.el,get:()=>e.get(),set:i=>e.set(i,{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var et=class extends y{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._originalClearable=t.getAttribute("data-clearable"),t.toggleAttribute("data-clearable",!!this.options.clearable),this._format=rm(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=ud(this.options.min),this._max=ud(this.options.max),this._value=this._normalizeValue(this.options.value);let e=x("zx-datebox-popover"),i=l("div",{class:"zx-datebox__content"},l("div",{ref:"control",class:"zx-datebox__control"},l("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??om(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},g("x",{size:13})),l("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},g("calendar"))),l("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new se(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",n=>{this.set(n.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=nt(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),this._originalClearable===null?this.el.removeAttribute("data-clearable"):this.el.setAttribute("data-clearable",this._originalClearable),super.destroy()}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set(null);return}let e=tt(t,this._format);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this.set(e)}_normalizeValue(t){let e=null;return t instanceof Date&&!Number.isNaN(t.getTime())?e=new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?e=new Date(t*1e3):typeof t=="string"&&(e=tt(t,this._format)),!e||Number.isNaN(e.getTime())?null:Gs(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?N(this._value,this._format):"",this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!this._value||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear()}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},cn=function(t,e={}){return new et(t,{...e,time:!0})};function ud(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function rm(s,t){let e=String(s||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function om(s){return s.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function fd(){hd("date",s=>new et(null,s)),hd("datetime",s=>cn(null,s))}function hd(s,t){I.register(s,(e,i)=>{let n=e.own(t({...i.props??{},value:i.value}));return e.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>e.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var Ze=class extends y{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??l("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=x("zx-upload");return this._input=l("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=l("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},l("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),l("span",{class:"zx-field-upload__hint"},am(this.options))),this._preview=l("div",{class:"zx-field-upload__preview"}),this._progress=l("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=l("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=l("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=l("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=l("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragover",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragleave",i=>{(!(i.relatedTarget instanceof Node)||!this._dropzone.contains(i.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",i=>{i.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(i.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let i=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:i}),i)}catch(i){if(e!==this._runId)return null;let n=i instanceof Error?i:new Error(String(i));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),i=this.options.multiple?e:e.slice(0,1);if(i.length===0)return!1;let n=i.find(o=>!cm(o,this.options.accept));if(n)return this._selectionError(new Error(`${n.name} is not an accepted file type.`)),!1;let r=this.options.maxSize==null?null:i.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(`${r.name} exceeds the maximum file size.`)),!1):(this._files=i,this._renderPreview(),this._status.textContent=i.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:i=>this._setProgress(i)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let i=new XMLHttpRequest;this._xhr=i,i.open("POST",String(this.options.url));for(let[n,r]of Object.entries(this.options.headers??{}))i.setRequestHeader(n,String(r));this.listen(i.upload,"progress",n=>{n.lengthComputable&&this._setProgress(n.loaded/n.total*100)}),this.listen(i,"load",()=>{if(i.status<200||i.status>=300){e(new Error(`Upload failed with HTTP ${i.status}`));return}t(um(i.responseText))}),this.listen(i,"error",()=>e(new Error("Upload request failed"))),this.listen(i,"abort",()=>e(hm())),i.send(dm(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(l("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function am(s){let t=[];return s.accept&&t.push(String(s.accept)),s.maxSize!=null&&t.push(`up to ${lm(Number(s.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function lm(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${Math.round(s/(1024*1024))} MB`}function cm(s,t){if(!t)return!0;let e=String(s.type??"").toLowerCase();return String(t).split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).some(i=>i.startsWith(".")?s.name.toLowerCase().endsWith(i):i.endsWith("/*")?e.startsWith(i.slice(0,-1)):e===i)}function dm(s,t,e){let i=new FormData;for(let n of s)i.append(t,n);for(let[n,r]of Object.entries(e??{}))pd(i,n,r);return i}function pd(s,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)pd(s,t,n);return}typeof Blob=="function"&&e instanceof Blob?s.append(t,e):s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function um(s){if(!s)return null;try{return JSON.parse(s)}catch{return s}}function hm(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let s=new Error("Upload aborted");return s.name="AbortError",s}function _d(){I.register("upload",(s,t)=>{let e=s.own(new Ze(null,{...t.props??{}}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("select",()=>s.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:i=>e.setDisabled(i)}})}var md=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),gd=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),ti=class extends y{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??l("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=l("div",{class:"zx-multi-value-editor__rows"}),this._add=l("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return md[this.options.reorder]??md.both}_renderRows(t=-1,e="value"){let i=bd(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((d,u)=>{let h=!n||i.some(([p])=>p===d)?i:[[d,d],...i],f=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${u+1}`,dataset:{index:u}},h.map(([p,_])=>l("option",{value:p,selected:p===d},_))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:d,ariaLabel:`Value ${u+1}`,dataset:{index:u}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:u}},r?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${u+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:u}},g("drag",{size:12})):null,f,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===0),ariaLabel:`Move value ${u+1} up`,dataset:{action:"up",index:u}},g("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===a),ariaLabel:`Move value ${u+1} down`,dataset:{action:"down",index:u}},g("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${u+1}`,dataset:{action:"remove",index:u}},g("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(gd[e]??gd.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.action,n=Number(e.dataset.index);if(i==="add"){let r=bd(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else i==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(i==="up"||i==="down")&&Number.isInteger(n)&&this._move(n,n+(i==="up"?-1:1),i)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let i=Number(e.dataset.index);!Number.isInteger(i)||i<0||i>=this._values.length||(this._values[i]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let i=Number(e.dataset.index),n=t.key==="ArrowUp"?i-1:t.key==="ArrowDown"?i+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(t.preventDefault(),this._move(i,n,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let i=e.closest(".zx-multi-value-editor__row");i&&(i.draggable=!0,this._armed=i)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,i=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,i>e?i-1:i,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[i,n]of e.entries()){let r=n.getBoundingClientRect();if(t<r.top+r.height/2)return i}return e.length}_showDrop(t){let e=[...this._rows.children],i=t===this._dragIndex||t===this._dragIndex+1;for(let[n,r]of e.entries()){let o=r;!i&&n===t?o.dataset.drop="before":!i&&t===e.length&&n===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,i){let n=this._values.length;if(t===e||t<0||e<0||t>=n||e>=n)return!1;let[r]=this._values.splice(t,1);return this._values.splice(e,0,r),this._renderRows(e,i),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function bd(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}function yd(){I.register("multivalueeditor",(s,t)=>{let e=s.own(new ti(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),i=new WeakMap,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(n));for(let o of e.el.querySelectorAll("input, button, select, textarea"))n?(i.has(o)||i.set(o,!!o.disabled),o.disabled=!0):i.has(o)&&(o.disabled=i.get(o),i.delete(o))};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>s.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var Et=class extends y{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t;let e=fm(this.options.step);this._step=e,this._precision=this.options.precision===null?pm(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let i=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=l("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[i,r];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(i,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||this._disabled||this._readonly||(a.preventDefault(),this._stepBy(a.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._coerce(t),n=i!==this._value;return this._value=i,this._syncInput(),n&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return l("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},g(e,{size:13}))}get _rangeMin(){return this._min!==void 0?this._min:this.options.min===null||this.options.min===void 0?null:Number(this.options.min)}get _rangeMax(){return this._max!==void 0?this._max:this.options.max===null||this.options.max===void 0?null:Number(this.options.max)}_coerce(t){let e=ve(t,this.options.group?this._separators():null);return e===null?null:ts(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,i=this._rangeMax,r=ve(this.refs.input.value)??this._value,o=r===null?e??0:r,a=r===null&&t>0&&e!==null?e-this._step*t:o,c=wd(a+this._step*t,this._precision);return this.options.wrap&&e!==null&&i!==null&&(c>i?c=e:c<e&&(c=i)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=ve(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly||t.altKey||t.ctrlKey||t.metaKey)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,i=this._rangeMin,n=this._rangeMax;if(i===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(i)),n===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(n)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let r=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${r}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let i=this.msg(t);return i===t?e:i}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function ve(s,t=null){if(typeof s=="number")return Number.isFinite(s)?s:null;if(s==null)return null;let e=String(s).trim();if(e==="")return null;let i;if(t)i=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");i=r,o>=0&&o>a?i=r.replace(/\./g,"").replace(",","."):o>=0&&(i=r.replace(/,/g,""))}if(!/\d/.test(i))return null;let n=Number(i);return Number.isFinite(n)?n:null}function ts(s,{min:t,max:e,step:i,precision:n}){let r=s;if(i>0){let o=t??0;r=o+Math.round((s-o)/i)*i}return r=wd(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function fm(s){let t=Number(s);return Number.isFinite(t)&&t>0?t:1}function pm(s){let t=String(s),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let i=t.split(".")[1];return i?i.length:0}function wd(s,t){return Number.isFinite(s)?Number(s.toFixed(Math.min(15,Math.max(0,t)))):s}function vd(){I.register("number",(s,t)=>{let e=s.own(new Et(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,name:s.name||null,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{i=!0;try{e.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadonly(n)}}})}var ei=class extends y{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:"Rating",icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=x("zx-rating");let e=l("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let i=1;i<=this._max;i+=1){let n=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},g(this.options.icon,{size:es[this.options.size]??es.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},g(this.options.icon,{size:es[this.options.size]??es.md})));this.options.allowHalf?n.append(this._radio(i-.5,"half"),this._radio(i,"full")):n.append(this._radio(i,"full")),e.append(n)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=es[this.options.size]?this.options.size:"md",this.listen(e,"keydown",i=>this._onKeydown(i)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._clamp(t),n=i!==this._value;return this._value=i,this._preview=null,this._sync(),n&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let i=l("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(i,"click",n=>{this._choose(t,n.detail>0)}),this.listen(i,"pointerenter",()=>this._setPreview(t)),this.listen(i,"focus",()=>this._setPreview(t)),this.listen(i,"blur",()=>this._setPreview(null)),this._radios.push(i),i}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let i=Math.round(t/this._step)-1;if(e[i]!=null)return String(e[i])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,i){let n=this.msg(t,...i);return n===t?T(e,i):n}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],i=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(i.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let i=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,i))}_sync(){for(let e of this._radios){let i=Number(e.dataset.value);e.setAttribute("aria-checked",String(i===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((i,n)=>{let r=Math.min(1,Math.max(0,t-n));i.style.setProperty("--zx-rating-fill",`${r*100}%`),i.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,i=[];this.options.showValue&&i.push(_m(this._value,this._step)),e!=null&&i.push(this._message("rating.count","%1 ratings",[e])),t.textContent=i.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},es={sm:14,md:18,lg:24};function _m(s,t){return t<1?s.toFixed(1):String(s)}function xd(){I.register("rating",(s,t)=>{let e=s.own(new ei(null,{label:t.label?String(t.label):void 0,...t.props??{}})),i=!1;return e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get()||null,set:n=>{i=!0;try{e.set(Number(n)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadonly(n)}}})}var Ad=["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(","),mm=["hidden","disabled","aria-disabled","aria-hidden"],gm=new Set(["button","checkbox","color","file","image","reset","submit"]);function dn(s){let t=!1,e=null;function i(n){if(n.key!=="Tab")return;let r=Sd(s);if(r.length===0){n.preventDefault();return}let o=r[0],a=r[r.length-1];n.shiftKey&&(document.activeElement===o||!s.contains(document.activeElement))?(n.preventDefault(),a.focus()):!n.shiftKey&&(document.activeElement===a||!s.contains(document.activeElement))&&(n.preventDefault(),o.focus())}return{activate(){t||(t=!0,e=document.activeElement,document.addEventListener("keydown",i),Sd(s)[0]?.focus())},deactivate(){t&&(t=!1,document.removeEventListener("keydown",i),e?.isConnected&&typeof e.focus=="function"&&e.focus(),e=null)}}}function Mt(s,t,{orientation:e="vertical",wrap:i=!0,rtl:n="auto"}={}){let r=new AbortController,o=new Map,a=!1;function c(){return Array.from(s.querySelectorAll(t)).filter(m=>(d(m),la(m)))}function d(m){o.has(m)||o.set(m,m.getAttribute("tabindex"))}function u(m=null){let b=c(),w=m&&b.includes(m)?m:b.find(v=>v.tabIndex===0)??b[0];for(let v of b){let z=v===w?0:-1;v.tabIndex!==z&&(v.tabIndex=z)}}function h(m){let b=c(),w=m.target?.closest?.(t)??null,v=b.indexOf(w);if(v<0)return;let z=e==="horizontal"&&vm(s,n),C=bm(m.key,e,z);if(C===null||!wm(m.target,C))return;let k=C==="first"?0:C==="last"?b.length-1:C==="previous"?v-1:v+1;b.length!==0&&(i?k=(k+b.length)%b.length:k=Math.max(0,Math.min(b.length-1,k)),m.preventDefault(),u(b[k]),b[k].focus())}function f(m){let b=m.target?.closest?.(t)??null;b&&s.contains(b)&&u(b)}s.addEventListener("keydown",h,{signal:r.signal}),s.addEventListener("focusin",f,{signal:r.signal});let p=typeof MutationObserver=="function"?new MutationObserver(m=>{m.some(_)&&u()}):null;p?.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:mm}),u();function _(m){if(m.type==="attributes")return m.target instanceof Element&&(m.target.matches(t)||m.target.querySelector(t)!==null);for(let b of m.addedNodes)if(b instanceof Element&&(b.matches(t)||b.querySelector(t)))return!0;for(let b of m.removedNodes)if(b instanceof Element){if(o.has(b))return!0;for(let w of o.keys())if(b.contains(w))return!0}return!1}return{focusFirst(){let m=c()[0];m&&(u(m),m.focus())},focusLast(){let m=c(),b=m[m.length-1];b&&(u(b),b.focus())},destroy(){if(!a){a=!0,r.abort(),p?.disconnect();for(let[m,b]of o)b===null?m.removeAttribute("tabindex"):m.setAttribute("tabindex",b);o.clear()}}}}function un(s,t){let e=s?.ownerDocument?.activeElement??null;if(!e||e===s||!s.contains(e))return null;let i=t(e);if(!i)return null;let n=kd(i.element);return{key:i.key,self:e===i.element,index:n.indexOf(e),signature:zd(e)}}function hn(s,t,e){if(!t||!s)return!1;let i=s.ownerDocument?.activeElement??null;if(i&&i!==s.ownerDocument?.body&&i.isConnected&&s.contains(i))return!1;let n=e(t.key);if(!n)return!1;let r=kd(n),o=t.self?n:r.find(a=>zd(a)===t.signature)??r[t.index]??r.at(-1)??null;return!o||typeof o.focus!="function"?!1:(o.focus({preventScroll:!0}),s.ownerDocument?.activeElement===o)}function kd(s){return Array.from(s.querySelectorAll(`${Ad},[tabindex="-1"]`)).filter(t=>la(t))}function zd(s){let t=Object.entries(s.dataset??{}).map(([i,n])=>`${i}=${n}`).sort().join("&"),e=s.getAttribute("aria-label")??s.textContent?.trim()??"";return`${s.tagName}|${t}|${e}`}function ut(s,t){let e="",i=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;i!==null&&clearTimeout(i),e+=o.toLocaleLowerCase(),e.split("").every(d=>d===e[0])&&(e=e[0]),i=setTimeout(()=>{e="",i=null},500);let a=s(),c=a.findIndex(d=>xm(d).startsWith(e));c>=0&&t(a[c],c)}}function bm(s,t,e=!1){return s==="Home"?"first":s==="End"?"last":t==="horizontal"?s==="ArrowLeft"?e?"next":"previous":s==="ArrowRight"?e?"previous":"next":null:s==="ArrowUp"?"previous":s==="ArrowDown"?"next":null}function ym(s){if(!s||typeof s!="object")return!1;let t=String(s.tagName??"").toUpperCase();return t==="TEXTAREA"||t==="SELECT"?!0:t==="INPUT"?!gm.has(String(s.type??"text").toLowerCase()):!!s.isContentEditable}function wm(s,t){if(!ym(s))return!0;if(t==="first"||t==="last"||String(s?.tagName??"").toUpperCase()!=="INPUT")return!1;let e=s,i,n;try{i=e.selectionStart,n=e.selectionEnd}catch{return!1}return typeof i!="number"||typeof n!="number"||i!==n?!1:t==="previous"?i===0:n===String(e.value??"").length}function vm(s,t){if(t===!0||t===!1)return t;try{return globalThis.getComputedStyle?.(s)?.direction==="rtl"}catch{return!1}}function Sd(s){return Array.from(s.querySelectorAll(Ad)).filter(t=>la(t)&&t.getClientRects().length>0)}function la(s){return!(!(s instanceof HTMLElement)||s.hidden||s.getAttribute("aria-hidden")==="true"||s.matches(":disabled"))}function xm(s){if(typeof s=="string"||typeof s=="number")return String(s).trim().toLocaleLowerCase();if(s&&typeof s=="object"&&"textContent"in s)return String(s.textContent??"").trim().toLocaleLowerCase();if(s&&typeof s=="object"){let t=s,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(s??"").trim().toLocaleLowerCase()}var Sm=/^var\(\s*--[\w-]+\s*\)$/;function fn(s){if(typeof s!="string")return null;let t=s.trim();return Sm.test(t)||ee(t)?t:null}var da=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),ua=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),ha=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"]]),Am=Object.freeze({review:"in-review",cancelled:"canceled"}),ca=4;function km(s,t={}){let e=s&&typeof s=="object"?s:null,i=zm(e?e.ID??e.id:s),n=ha.find(([a])=>a===i),r=String(t.indicator??e?.indicator??n?.[3]??"ring"),o=String(t.tone??e?.tone??n?.[4]??"muted");return{indicator:da.includes(r)?r:"ring",tone:ua.includes(o)?o:"muted"}}function zm(s){let t=String(s??"").trim().toLowerCase();return Am[t]??t}function fa(s){return s==null||s===""?null:Math.max(0,Math.min(ca,Math.trunc(Number(s)||0)))}function pn(s,t={}){let{indicator:e,tone:i}=km(s,t??{}),n=l("span",{class:"zx-status-icon",dataset:{indicator:e,tone:i}});return e==="done"&&n.append(g("check",{size:8})),e==="canceled"&&n.append(g("x",{size:7})),Cd(n,t?.label)}function _n(s,t={}){let e=fa(s),i=l("span",{class:"zx-priority-icon",dataset:{level:e===null?"none":e}},e===ca?null:Array.from({length:ca},(n,r)=>l("span",{dataset:{filled:String(e!==null&&r<=e)}})));return Cd(i,t?.label)}function Cd(s,t){let e=t==null?"":String(t).trim();return e?(s.setAttribute("role","img"),s.setAttribute("aria-label",e)):s.setAttribute("aria-hidden","true"),s}var Cm=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],Td=["Lowest","Low","Medium","High","Highest"],$=class s extends y{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",label:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._snapshot=null,this._pointerModality=!1,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._snapshot=this._createdRoot?null:A(t);let e=x("zx-select-list"),i=l("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",ariaLabel:String(this.options.label||this.options.placeholder||"Select"),autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=l("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=l("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},g("x",{size:13})),o=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},g("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,i,r,o,a),d=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});d.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let u=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},d);return t.replaceChildren(c,u),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=Id(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=ut(()=>this._optionEntries.filter(h=>!h.clear&&!h.action).map(h=>h.element),(h,f)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(f))}),this.listen(i,"click",()=>this.open()),this.listen(i,"input",()=>this._onInput()),this.listen(i,"keydown",h=>{Md(h)||t.removeAttribute("data-focus-origin"),this._onKeydown(h)}),this.listen(i,"focus",()=>{this._pointerModality&&i.readOnly?t.setAttribute("data-focus-origin","pointer"):t.removeAttribute("data-focus-origin")}),this.listen(i,"blur",()=>t.removeAttribute("data-focus-origin")),this.listen(document,"keydown",h=>{Md(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(u,"pointerdown",h=>h.preventDefault()),this.listen(u,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._pointerModality=!0,this._open&&!t.contains(h.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get(){return this.value}get selected(){return this._selected}set(t,{silent:e=!1}={}){let i=this.value,n=t==null?null:this._findItem(t);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!e&&!Object.is(i,r)&&this.emit("change",{value:r,item:n}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setActions(t){return this._actions=Id(t),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=nt(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let i=e.value??null,n=e.clearable??!0,r=null,o=()=>e.noneLabel??(r?r._message("priority.none","No priority"):"No priority");r=new s(t,{...e,clearable:n,value:null,items:[],renderItem(c){return Ed(c,!0)},renderNone:e.renderNone??(()=>Ed({level:null,name:o()},!0)),renderValueAdornment(c){return Nd(c.level)}}),n&&!e.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(Cm.map((c,d)=>{let u=d===2?a.msg("priority.medium"):c;return(u==="priority.medium"||d!==2)&&(u=a._message(c,Td[d])),{ID:d,name:u,level:d}})),r.set(i,{silent:!0}),r}static status(t,e={}){let{items:i=null,value:n=null,...r}=e,o=new s(t,{...r,value:null,items:[],renderItem(c){return Mm(c)},renderValueAdornment(c){return Od(c)}}),a=Array.isArray(i)?i.map(Em).filter(Boolean):ha.map(([c,d,u,h,f],p)=>({ID:c,name:o._message(d,u),indicator:h,tone:f,shortcut:String(p+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(t,e={}){let{recent:i=[],recentLabel:n="Recent",create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:c="description",renderIcon:d=null,fixedItems:u=[],actions:h=[],renderItem:f=null,renderValueAdornment:p=null,..._}=e,m=(v,z=!1)=>{if(typeof d=="function")return d(v,{selected:z});let C=mn(v,o);if(C&&typeof C=="object"&&typeof C.nodeType=="number")return C.cloneNode(!0);if(typeof C!="string"||!C)return null;let k=fn(mn(v,a));return l("span",{class:"zx-select__entity-glyph",style:k?{"--zx-select-entity-color":k}:null,ariaHidden:"true"},g(C,{size:14}))},b=r?Tm(r):null,w=new s(t,{..._,fixedItems:[...Array.isArray(i)?i:[],...Array.isArray(u)?u:[]],fixedLabel:Array.isArray(i)&&i.length?n:_.fixedLabel??null,actions:[...Array.isArray(h)?h:[],...b?[b]:[]],renderItem:f??(v=>{let z=m(v,!1),C=mn(v,c),k=l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(mn(v,_.labelKey??"name")??"")),C==null||C===""?null:l("span",{class:"zx-select__entity-subtitle"},String(C)));return l("span",{class:"zx-select__entity"},z?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},z):null,k)}),renderValueAdornment:p??(v=>m(v,!0))});return w.el.dataset.preset="entity",w}static permission(t,e={}){let{groups:i=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...c}=e,d=typeof i=="function"?i:null,u=d?[]:i,h=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],f=new s(t,{filter:d??a,...c,value:null,items:u,fixedItems:[],valueKey:p=>h.includes(p)?p.ID:_a(p,r),labelKey:p=>h.includes(p)?p.name:String(_a(p,o)??"")});return h[0].name=f._message("permission.private","Private"),h[1].name=f._message("permission.public","Public"),f.setFixedItems(h),f.set(n,{silent:!0}),f}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;!this._createdRoot&&t&&S(t,this._snapshot),super.destroy()}_onKeydown(t){if(!this._disabled){if(this._open&&Dd(t)){let e=this._optionEntries.findIndex(i=>!i.clear&&!i.action&&String(i.item?.shortcut??"")===t.key);if(e>=0){t.preventDefault(),this._setActive(e),this._chooseEntry(this._optionEntries[e]);return}}if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&Dd(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._syncValueAdornment(),this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=ie(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){if(t){if(t.action){let e={id:t.action.id,action:t.action,query:this.refs.input.value,select:this};this.emit("action",e).defaultPrevented||t.action.invoke?.(e),this.close(),this.focus();return}this.set(t.clear?null:t.item),this.close(),this.focus()}}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((i,n)=>{n===this._activeIndex?i.element.setAttribute("data-active","true"):i.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group"),i=this._uniqueItems(this._visibleFixed),n=this._uniqueItems(this._visibleItems,i);this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection")),i.length>0&&this.options.fixedLabel&&t.append(l("div",{class:"zx-select__group",role:"presentation"},String(this.options.fixedLabel)));for(let r of i)this._appendOption(r,!1);i.length>0&&n.length>0&&!this.options.groupKey&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));for(let r of n){if(this.options.groupKey){let o=this._read(r,this.options.groupKey);Object.is(o,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(o??""))),e=o)}this._appendOption(r,!1)}if(this._actions.length>0){(i.length>0||n.length>0||this.options.clearable)&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(t.append(l("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&i.length===0&&this._actions.length===0&&!this._loading&&t.append(l("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,i){let n=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),r=this._optionEntries.length,o=e&&typeof this.options.renderNone=="function"?pa(this.options.renderNone(String(i??""))):e?String(i??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:x("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},l("span",{class:"zx-select__option-content"},o));n&&a.append(g("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,action:null,element:a})}_appendAction(t){let e=this._optionEntries.length,i=Im(t.icon),n=l("div",{class:"zx-select__option zx-select__action",id:x("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},l("span",{class:"zx-select__option-content zx-select__action-content"},i?l("span",{class:"zx-select__action-icon",ariaHidden:"true"},i):null,l("span",{class:"zx-select__action-copy"},l("span",{class:"zx-select__action-label"},t.label),t.description?l("span",{class:"zx-select__action-description"},t.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:t,element:n})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return pa(e)}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},i)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(i)?i.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let t=this.refs.valueAdornment;if(!t)return;let e=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),i=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&i!==e){t.replaceChildren(),t.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=pa(n);t.replaceChildren(r instanceof Node?r:document.createTextNode(r)),t.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,i=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,i.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],i=e.find(r=>r===t);if(i!==void 0)return i;let n=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return _a(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return ie(this._fixedItems,t,this._searchKeys())}_uniqueItems(t,e=[]){let i=e.map(n=>this._itemValue(n));return t.filter(n=>{let r=this._itemValue(n);return i.some(o=>Object.is(o,r))?!1:(i.push(r),!0)})}_selectedEntryIndex(){return this._selected===null?this.options.clearable?0:-1:this._optionEntries.findIndex(t=>!t.clear&&Object.is(this._itemValue(t.item),this.value))}_itemEntryIndex(t){return t+(this.options.clearable?1:0)}_message(t,e){let i=this.msg(t);return i===t?e:i}};function mn(s,t){return typeof t=="function"?t(s):s!==null&&typeof s=="object"&&typeof t=="string"?s[t]:null}function Tm(s){let t=s===!0?{}:s;return{id:t.id??"create",label:t.label??"Create new\u2026",description:t.description,group:t.group??"New",icon:t.icon??"plus",invoke:t.invoke}}function pa(s){return s&&typeof s=="object"&&"nodeType"in s?s:String(s??"")}function Id(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label),description:t.description==null?void 0:String(t.description),group:t.group==null?void 0:String(t.group)})):[]}function Im(s){return typeof s=="string"?g(s):s instanceof Node?s.cloneNode(!0):null}function Ed(s,t){return l("span",{class:"zx-select__priority"},Nd(s.level),t?l("span",{},String(s.name)):null)}function Nd(s){let t=_n(fa(s));return t.classList.add("zx-select__priority-icon"),t}function Em(s){return!s||typeof s!="object"||s.ID==null||s.name==null?null:{...s,name:String(s.name),indicator:da.includes(String(s.indicator))?String(s.indicator):"ring",tone:ua.includes(String(s.tone))?String(s.tone):"muted",description:s.description==null?"":String(s.description),shortcut:s.shortcut==null?"":String(s.shortcut)}}function Mm(s){return l("span",{class:"zx-select__status"},Od(s),l("span",{class:"zx-select__status-copy"},l("span",{class:"zx-select__status-label"},String(s.name)),s.description?l("span",{class:"zx-select__status-description"},s.description):null),s.shortcut?l("kbd",{class:"zx-select__status-shortcut"},s.shortcut):null)}function Od(s){let t=pn({indicator:s.indicator??"ring",tone:s.tone??"muted"});return t.classList.add("zx-select__status-indicator"),t}function _a(s,t){return typeof t=="function"?t(s):s===null||typeof s!="object"?s:s[t]}function Md(s){return["Shift","Control","Alt","Meta","CapsLock"].includes(s.key)||s.ctrlKey||s.metaKey}function Dd(s){return s.key.length===1&&!s.ctrlKey&&!s.metaKey&&!s.altKey}function Fd(){I.register("zxselect",(s,t)=>{let e=t.props??{},i=e.preset,n={...e,value:t.value,label:t.label||e.label,placeholder:e.placeholder??t.placeholder};s.listen(s.el,"click",o=>{o.target.closest?.(".zx-field__label")&&s.adapter.focus()}),delete n.preset,i==="priority"&&e.clearable===void 0&&(n.clearable=!t.required);let r=s.own(i==="priority"?$.priority(null,n):i==="status"?$.status(null,n):new $(null,n));return s.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>s.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var ii=class extends y{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=x("zx-slider");let e=l("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),i=l("div",{class:"zx-slider__track"},e,this._marks()),n=l("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(i),this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),t.replaceChildren(l("div",{class:"zx-slider__head"},l("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),l("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",r=>{this._readonly&&Dm.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._snap(t),n=i!==this._value;return this._value=i,this._paint(),n&&!e&&this.emit("change",{value:i}),this}setRange(t,e,i){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,i!==void 0&&(this._step=Math.abs(Number(i))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=l("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=l("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let i of t){let n=typeof i=="number"?i:Number(i?.value);if(!Number.isFinite(n))continue;let r=typeof i=="number"?this._format(n):String(i.label??this._format(n));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":String(this._ratio(n))}},r))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?ts(e,{min:this._min,max:this._max,step:this._step,precision:ma(this._step)}):this._min}_ratio(t){return q((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${Nm(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},Dm=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function ma(s){let t=String(s),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function Nm(s){return String(Number(s.toFixed(6)))}function Ld(){I.register("slider",(s,t)=>{let e=s.own(new ii(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),e.on("input",n=>s.emit("input",{value:n.detail.value})),{el:e.el,get:()=>e.get(),set:n=>{i=!0;try{e.set(Number(n)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadonly(n)}}})}var Om=Object.freeze(["neutral","accent","success","warning","danger","info"]),Fm=Object.freeze(["soft","solid","outline"]),ga=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Lm=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function ht(s={}){let t={...Lm,...s},e=l("span",{class:"zx-badge",title:t.title,dataset:{kind:Rm(t.kind),variant:Pm(t.variant),size:Bm(t.size),tone:ba(t.tone)??void 0}});return t.dot?e.append(l("span",{class:"zx-badge__dot",ariaHidden:"true"})):t.icon&&e.append(g(t.icon,{size:12,class:"zx-badge__icon"})),t.label!==""&&t.label!=null?e.append(l("span",{class:"zx-badge__label"},String(t.label))):t.title&&(e.setAttribute("role","img"),e.setAttribute("aria-label",t.title)),e}function Rd(s){let t=l("span",{class:"zx-badge-group"});return t.append(...s),t}function Rm(s){return Om.includes(s)?s:"neutral"}function Pm(s){return Fm.includes(s)?s:"soft"}function ba(s){return ga.includes(s)?s:null}function Bm(s){return s==="sm"?"sm":"md"}var re=class extends y{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:A(this.el);let t=this.el??l("div");this.el=t;let e=x("zx-tag-picker-list"),i=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=l("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=l("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},g("chevron-down",{size:15})),o=l("div",{ref:"control",class:"zx-tag-picker__control"},i,n,r),a=l("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=l("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",d=>{let u=d.target;u.closest(".zx-tag-picker__remove")||u.closest(".zx-tag-picker__toggle")||(d.target!==n&&(d.preventDefault(),this.focus()),this._open||this.open())}),this.listen(i,"click",d=>{let u=d.target.closest(".zx-tag-picker__remove");if(!u||this._disabled||this._readonly)return;d.stopPropagation();let h=[...i.children].indexOf(u.closest(".zx-tag-picker__tag")),f=this._selected[h];f!==void 0&&(this.removeValue(this._valueOf(f)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",d=>this._onKeydown(d)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",d=>d.preventDefault()),this.listen(c,"click",d=>this._onOptionClick(d)),this.listen(document,"pointerdown",d=>{this._open&&!t.contains(d.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),t}get values(){return this.getValues()}set values(t){this.setValues(t)}getValues(){return this._selected.map(t=>this._valueOf(t))}getItems(){return this._selected.slice()}setValues(t,{silent:e=!1}={}){let i=Array.isArray(t)?t:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of i){if(r.length>=n)break;let c=this._resolve(a);c!==null&&!r.some(d=>this._sameValue(d,c))&&r.push(c)}let o=!Vm(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let i=this._resolve(t);return i===null?this:this._selected.some(n=>this._sameValue(n,i))?this:(this._selected.push(i),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(i),item:i}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let i=this._valueOf(this._resolve(t)??t),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),i));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=nt(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._entries.length>0?0:-1),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(this.refs.input.value),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._activeId=null,this.refs.input.value="",this._syncInputWidth(),this._applyLocalFilter(""),this.emit("close",{}),this):this}focus(){return this.refs.input.focus(),this}enable(){return this._disabled=!1,this._renderTags(),this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._renderTags(),this._syncDisabled(),this}setReadonly(t){return t&&this.close(),this._readonly=!!t,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let i=this._labelOf(e),n=this._toneOf(e),r=n?null:this._colorOf(e),o=this.options.renderTag?this.options.renderTag(e):[this._iconOf(e),l("span",{class:"zx-tag-picker__tag-label"},i)],a=l("span",{class:"zx-tag-picker__tag",dataset:{colored:String(!!r),tone:n??void 0},style:r?{"--zx-tag-color":r}:null},o);return!this._readonly&&!this._disabled&&a.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[i])},g("x",{size:11}))),a});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:x("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?g("check",{size:13}):null),l("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),l("span",{},this._labelOf(r))]));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let i=this.refs.input.value.trim();if(this._canCreate(i)){let r=l("div",{class:"zx-tag-picker__option",id:x("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},g("plus",{size:13})),l("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[i])));this._entries.push({item:null,element:r,create:!0}),e.push(r)}e.length===0&&e.push(l("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let i=this._entries.find(n=>n.element===e);i&&this._commitEntry(i)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let i=e.value.trim(),n=this._createItem(i);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let i=this._valueOf(t.item);if(this._isSelected(i))this.removeValue(i);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,i]of this._entries.entries()){let n=e===t;i.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",i.element.id),i.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=ie(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},i)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(i)?i.slice():[],this._visible=this._items.slice()}catch(i){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:i})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=i=>i.some(n=>Pd(this._labelOf(n))===Pd(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),i=this._items.find(r=>Object.is(this._valueOf(r),e));if(i!==void 0)return i;let n=this._selected.find(r=>Object.is(this._valueOf(r),e));return n!==void 0?n:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_iconOf(t){let e=this._readItem(t,this.options.iconKey),i=e&&typeof e=="object"&&typeof e.nodeType=="number"?e.cloneNode(!0):typeof e=="string"&&e.trim()?g(e,{size:12}):null;if(!i)return null;let n=this._toneOf(t),r=n?null:this._colorOf(t);return l("span",{class:"zx-tag-picker__visual",dataset:{tone:n??void 0},style:r?{"--zx-tag-color":r}:null,ariaHidden:"true"},i)}_colorOf(t){return fn(this._readItem(t,this.options.colorKey))}_toneOf(t){return ba(this._readItem(t,this.options.toneKey))}_readItem(t,e){return typeof e=="function"?e(t):t!==null&&typeof t=="object"&&typeof e=="string"?t[e]:null}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,i=[]){let n=this.msg(t,...i);return n!==t?n:i.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),e)}};function Pd(s){return String(s??"").trim().toLocaleLowerCase()}function Vm(s,t,e){return s.length!==t.length?!1:s.every((i,n)=>Object.is(e(i),e(t[n])))}function Bd(){I.register("tagpicker",(s,t)=>{let e=s.own(new re(null,{placeholder:t.placeholder,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.values})}),{el:e.el,get:()=>e.getValues(),set:n=>{i=!0;try{e.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadonly(n)}}})}function ya(s,t="minutes"){let e=Math.round(Math.abs(Vd(xe(s),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:xe(s)<0}}function wa(s,t="minutes"){is(t);let e=Math.abs(Math.trunc(xe(s?.hours))),i=Math.abs(Math.trunc(xe(s?.minutes))),n=Math.abs(Math.trunc(xe(s?.seconds))),r=s?.negative?-1:1;return jd(r*(e*3600+i*60+n),t)}var Dt=class extends y{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){is(this.options.unit);let t=this.el??l("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=l("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?this._message("timebox.durationWithSeconds","Duration in hours, minutes, and seconds"):this._message("timebox.duration","Duration in hours and minutes")});return this._content=e,this.options.signed&&(e.append(l("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:this._message("timebox.toggleSign","Toggle duration sign"),ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours",this._message("timebox.hours","Hours"),!1),e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes",this._message("timebox.minutes","Minutes"),!0),this.options.seconds&&(e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds",this._message("timebox.seconds","Seconds"),!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return wa(this._readParts(),t)}set(t,e=this.options.unit,i={}){e&&typeof e=="object"&&(i=e,e=this.options.unit),is(e);let n=xe(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=jd(Math.round(Vd(n,e)/60)*60,e)),this._parts=ya(n,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),i.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,i,n){let r=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:i,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let i=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[i]=Math.max(0,Math.min(n,Math.trunc(xe(e.value))))}return t}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let t of this._inputs){let e=t.dataset.segment;t.value=e==="hours"?String(this._parts[e]):jm(this._parts[e])}this.refs.sign&&(this.refs.sign.textContent=this._parts.negative?"-":"+",this.refs.sign.setAttribute("aria-pressed",String(this._parts.negative)),this.refs.sign.dataset.state=this._parts.negative?"negative":"positive")}_syncDisabled(){for(let t of this._inputs)t.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}_message(t,e){let i=this.msg(t);return i===t?e:i}};function xe(s){let t=Number(s);return Number.isFinite(t)?t:0}function Vd(s,t){return is(t),t==="hours"?s*3600:t==="minutes"?s*60:s}function jd(s,t){return is(t),t==="hours"?s/3600:t==="minutes"?s/60:s}function is(s){if(s!=="hours"&&s!=="minutes"&&s!=="seconds")throw new RangeError(`Unknown time unit: ${s}`)}function jm(s){return String(s).padStart(2,"0")}function Hd(){I.register("time",(s,t)=>{let e=s.own(new Dt(null,{...t.props??{},value:t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.get(),set:i=>e.set(Number(i)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var J=class extends y{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:Hm(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let i=[l("span",{class:"zx-toggle__track",ariaHidden:"true"},l("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&i.push(l("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&qm(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Hm(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function qm(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function qd(){I.register("toggle",(s,t)=>{let e=s.own(new J(null,{...t.props??{},checked:!!t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.getValue(),set:i=>e.set(!!i,{silent:!0}),focus:()=>e.el.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var si=class extends y{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??l("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=$d(this.options.values,!!this.options.unique);let e=x("zx-value-list-instructions");return this._list=l("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:this._message("valueList.values","Values"),ariaOrientation:"horizontal"}),this._input=l("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:this._message("valueList.add","Add value"),ariaDescribedby:e}),this._status=l("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=l("span",{class:"zx-value-list__instructions",id:e},this._message("valueList.instructions","Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.")),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",i=>this._handleInputKeydown(i)),this.listen(this._list,"keydown",i=>this._handleChipKeydown(i)),this.listen(this._list,"click",i=>this._handleChipClick(i)),this.listen(this._list,"dragstart",i=>this._handleDragStart(i)),this.listen(this._list,"dragover",i=>{this._dragIndex>=0&&!this._disabled&&i.preventDefault()}),this.listen(this._list,"drop",i=>this._handleDrop(i)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",i=>{i.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=$d(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError(this._message("valueList.duplicate","This value already exists.")),!1;if(typeof this.options.validate=="function"){let i=this.options.validate(e);if(i!==!0)return this._showError(typeof i=="string"?i:this._message("valueList.invalid","This value is not valid.")),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((i,n)=>l("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?this._message("valueList.removable","%1. Press Delete to remove.",i):i,dataset:{index:n}},l("span",{class:"zx-value-list__value"},i),this.options.deletable?l("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let i=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(i,Math.min(i,this._values.length-2));return}let n=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=n||r;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,i+o));t.ctrlKey&&n&&this.options.sortable?this._move(i,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,i=e?.closest("[data-index]");!i||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(i.dataset.index)):i.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,i=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,i,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,i){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[n]=this._values.splice(t,1);this._values.splice(e,0,n),this._renderChips(i?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[i]=this._values.splice(t,1);i!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:i}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function $d(s,t){if(!Array.isArray(s))return[];let e=s.map(i=>String(i));return t?[...new Set(e)]:e}function Kd(){I.register("valuelist",(s,t)=>{let e=s.own(new si(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.values})),{el:e.el,get:()=>e.getValues(),set:i=>e.setValues(Array.isArray(i)?i:[],{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var Se=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),$m=["xl","lg","md","sm"];function gn(s){let t=Number(s);if(!Number.isFinite(t))return"xs";for(let e of $m)if(t>=Se[e])return e;return"xs"}function bn(s,t){if(s==="xs")return!0;let e=Se[s];if(e===void 0)throw new RangeError(`Unknown breakpoint "${s}"`);return Number(t)>=e}function ni(s,t={}){if(typeof s!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!E(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,i=E(e)?e:null,n=null,r=!1,o=null,a=()=>i?i.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let h=a();if(i&&h===0)return;let f=gn(h);f!==n&&(n=f,s(n,h))};c();let d=0,u=()=>{d||r||(d=requestAnimationFrame(()=>{d=0,c()}))};return i&&typeof ResizeObserver=="function"?(o=new ResizeObserver(u),o.observe(i)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??gn(a()),destroy:()=>{r||(r=!0,d&&cancelAnimationFrame(d),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var va="data-zx-motion",Km='[data-zx-motion="reduced"]',Ud="(prefers-reduced-motion: reduce)";function ri(s){if(Um())return!0;let t=s??globalThis.document?.documentElement??null;return Ym(t)}function yn(s,t,e={}){if(typeof t!="function")throw new TypeError("watchMotion requires a callback");let{signal:i,immediate:n=!1}=e;if(i?.aborted)return()=>{};let r=ri(s),o=!1,a=()=>{if(o)return;let h=ri(s);h!==r&&(r=h,t(h))},c=typeof globalThis.matchMedia=="function"?globalThis.matchMedia(Ud):null;c?.addEventListener?.("change",a);let d=typeof MutationObserver=="function"?new MutationObserver(a):null;if(d)for(let h of Wm(s))d.observe(h,{attributes:!0,attributeFilter:[va],subtree:!0});let u=()=>{o||(o=!0,c?.removeEventListener?.("change",a),d?.disconnect(),i?.removeEventListener("abort",u))};return i?.addEventListener("abort",u,{once:!0}),n&&t(r),u}function Um(){return typeof globalThis.matchMedia=="function"&&globalThis.matchMedia(Ud).matches}function Ym(s){let t=s;for(;t&&typeof t.closest=="function";){if(t.closest(Km))return!0;let e=t.getRootNode?.();t=Yd(e)?e.host:null}return!1}function Wm(s){let t=[],e=s;for(;e&&typeof e.getRootNode=="function";){let n=e.getRootNode();if(!Yd(n))break;t.push(n),e=n.host}let i=(s?.ownerDocument??globalThis.document)?.documentElement;return i&&t.push(i),t}function Yd(s){return!!s&&s.nodeType===11&&"host"in s}var ss=class{base;headers;onError;timeout;constructor({base:t="",headers:e={},onError:i=null,timeout:n=3e4}={}){this.base=String(t),this.headers=Object.freeze({...e}),this.onError=i,this.timeout=Number(n)}async request(t,e={}){let{method:i="GET",data:n=null,files:r=null,query:o=null,headers:a={}}=e,c=new AbortController,d=this.timeout>0?setTimeout(()=>c.abort(),this.timeout):null,u=new Headers(this.headers);for(let[p,_]of Object.entries(a))u.set(p,_);u.set("Accept",u.get("Accept")??"application/json");let h;r!==null?(h=Qm(n,r),u.delete("Content-Type")):n!==null&&i.toUpperCase()!=="GET"&&i.toUpperCase()!=="HEAD"&&(h=JSON.stringify(n),u.set("Content-Type",u.get("Content-Type")??"application/json"));let f=Gm(this.base+t,o);try{let p=await fetch(f,{method:i.toUpperCase(),headers:u,body:h,signal:c.signal}),_=await p.text(),m=null;if(_!=="")try{m=JSON.parse(_)}catch(b){let w=new Error("Invalid JSON response",{cause:b});throw w.response=p,w}if(!p.ok){try{wn(m)}catch(w){throw w.response=p,w}let b=new Error(`HTTP ${p.status} ${p.statusText}`.trim());throw b.response=p,b}return wn(m)}catch(p){let _=p instanceof Error?p:new Error(String(p));if(this.onError)try{this.onError(_,{path:t,options:e})}catch{}throw _}finally{d!==null&&clearTimeout(d)}}get(t,e=null){return this.request(t,{method:"GET",query:e})}post(t,e=null){return this.request(t,{method:"POST",data:e})}put(t,e=null){return this.request(t,{method:"PUT",data:e})}delete(t,e=null){return this.request(t,{method:"DELETE",data:e})}};function Wd(s,t="",e={}){let{apiBase:i="../remotecall/",...n}=e,r=`${i}${s}${t?`:${t}`:""}/`;return new ss({...n,base:r})}function wn(s){if(s&&typeof s=="object"){if(Object.prototype.hasOwnProperty.call(s,"error")&&s.error!=null){let t=typeof s.error=="string"?s.error:JSON.stringify(s.error);throw new Error(t||"Server error")}if(Object.prototype.hasOwnProperty.call(s,"result"))return s.result}return s}function Gm(s,t){if(t==null)return s;let e;if(typeof t=="string")e=t.replace(/^\?/,"");else if(t instanceof URLSearchParams)e=t.toString();else{let i=new URLSearchParams;for(let[n,r]of Object.entries(t))Gd(i,n,r);e=i.toString()}return e?s+(s.includes("?")?"&":"?")+e:s}function Gd(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)Gd(s,t,i);else s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Qm(s,t){let e=new FormData;if(s&&typeof s=="object"&&!Array.isArray(s))for(let[n,r]of Object.entries(s))Qd(e,n,r);else s!=null&&e.append("data",typeof s=="string"?s:JSON.stringify(s));let i=Xm(t)||Array.isArray(t)?Array.from(t):[t];for(let n of i)e.append("files",n);return e}function Qd(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)Qd(s,t,i);else{let i=typeof Blob=="function"&&e instanceof Blob;s.append(t,typeof e=="object"&&!i?JSON.stringify(e):e)}}function Xm(s){return typeof FileList=="function"&&s instanceof FileList}var Jm=0,Zm=20,tg=3,eg=["B","KiB","MiB","GiB","TiB","PiB","EiB"],ig=["B","kB","MB","GB","TB","PB","EB"],xa=[{unit:"second",ms:1e3,limit:45},{unit:"minute",ms:6e4,limit:45},{unit:"hour",ms:36e5,limit:22},{unit:"day",ms:864e5,limit:6},{unit:"week",ms:6048e5,limit:4},{unit:"month",ms:26298e5,limit:11},{unit:"year",ms:315576e5,limit:1/0}],Xd=new Map,Jd=new Map;function Nt(s,t={}){let e=vn(s);if(e===null)return"";let{locale:i=dt(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return Sa(i,Aa({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function oi(s,t,e={}){let i=vn(s);if(i===null)return"";let{locale:n=dt(),decimals:r}=e,o=rg(t);if(o===null)return Nt(i,{locale:n,decimals:r});let a=Aa({decimals:r,group:!0});return Sa(n,{...a,style:"currency",currency:o},i)}function ai(s,t={}){let e=vn(s);if(e===null)return"";let{locale:i=dt(),decimals:n=0}=t;return Sa(i,{...Aa({decimals:n,group:!0}),style:"percent"},e)}function li(s,t={}){let e=vn(s);if(e===null)return"";let{locale:i=dt(),decimals:n=1,standard:r="iec"}=t;if(e===0)return`${Nt(0,{locale:i,decimals:0})} B`;let o=r==="si"?ig:eg,a=r==="si"?1e3:1024,c=Math.abs(e),d=Math.min(o.length-1,Math.max(0,Math.floor(Math.log(c)/Math.log(a)))),u=c/a**d;og(u,d===0?0:n)>=a&&d<o.length-1&&(d+=1,u=c/a**d);let h=e<0?-u:u;return`${Nt(h,{locale:i,minDecimals:0,maxDecimals:d===0?0:n})} ${o[d]}`}function eu(s,t={}){let e=tu(s);if(e===null)return"";let{now:i=new Date,locale:n=dt(),numeric:r="auto"}=t,o=tu(i);if(o===null)return"";let a=e.getTime()-o.getTime(),c=xa.find(({ms:u,limit:h})=>Math.abs(a)/u<h)??xa[xa.length-1],d=Math.round(a/c.ms);return ng(n,r).format(d,c.unit)}function Sa(s,t,e){let i=`${s}\0${JSON.stringify(t)}`,n=Xd.get(i);return n===void 0&&(n=sg(s,t),Xd.set(i,n)),n.format(e)}function sg(s,t){try{return new Intl.NumberFormat(s,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function ng(s,t){let e=`${s}\0${t}`,i=Jd.get(e);if(i===void 0){try{i=new Intl.RelativeTimeFormat(s,{numeric:t})}catch{i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"})}Jd.set(e,i)}return i}function Aa({decimals:s,minDecimals:t,maxDecimals:e,group:i=!0}){let n={useGrouping:i!==!1},r=Zd(t??s),o=Zd(e??s);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,tg)),n}function Zd(s){if(s==null)return null;let t=Number(s);return Number.isFinite(t)?Math.min(Zm,Math.max(Jm,Math.round(t))):null}function vn(s){if(s==null||s==="")return null;let t=typeof s=="number"?s:Number(s);return Number.isFinite(t)?t:null}function rg(s){if(typeof s!="string")return null;let t=s.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function tu(s){if(s instanceof Date)return Number.isNaN(s.getTime())?null:s;if(typeof s=="number")return Number.isFinite(s)?new Date(s*1e3):null;if(typeof s=="string"){let t=s.trim();if(t==="")return null;let e=/^-?\d+$/.test(t)?new Date(Number(t)*1e3):new Date(t);return Number.isNaN(e.getTime())?null:e}return null}function og(s,t){let e=10**t;return Math.round(s*e)/e}var iu="zx:__probe__";function ci(s,t={}){let{area:e="local"}=t,i=`zx:${String(s??"")}:`,n=new Map,r=ag(e),o=u=>{if(r!==null)try{return r.getItem(u)}catch{r=null}return n.has(u)?n.get(u):null},a=(u,h)=>{if(r!==null)try{r.setItem(u,h);return}catch{r=null}n.set(u,h)},c=u=>{if(r!==null)try{r.removeItem(u)}catch{r=null}n.delete(u)},d=()=>{if(r!==null)try{let u=[];for(let h=0;h<r.length;h+=1){let f=r.key(h);typeof f=="string"&&f.startsWith(i)&&u.push(f)}return u}catch{r=null}return[...n.keys()].filter(u=>u.startsWith(i))};return{get(u,h){let f=o(i+u);if(f==null)return h;try{return JSON.parse(f)}catch{return h}},set(u,h){let f;try{f=JSON.stringify(h)}catch{f=void 0}f===void 0?c(i+u):a(i+u,f)},remove(u){c(i+u)},keys(){return d().map(u=>u.slice(i.length))},clear(){for(let u of d())c(u)}}}function ag(s){let t=s==="session"?"sessionStorage":"localStorage";try{let e=globalThis[t];return!e||typeof e.getItem!="function"?null:(e.setItem(iu,"1"),e.removeItem(iu),e)}catch{return null}}var lg=["=","+","-","@"];function ru(s,t,e={}){let{delimiter:i=",",header:n=!0,newline:r=`\r
9
- `}=e,o=dg(t),a=[];n&&a.push(o.map(c=>nu(c.label,i,su(c.label))).join(i));for(let c of s??[]){let d=o.map(u=>{let h=typeof u.value=="function"?u.value(c):ug(c,u.id);return nu(hg(h),i,su(h))});a.push(d.join(i))}return a.join(r)}function ou(s,t,e={}){let{type:i="text/plain;charset=utf-8"}=e,n=fg(t,i),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=String(s??"download"),o.rel="noopener",o.style.display="none",document.body.append(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}async function xn(s){let t=String(s??"");if(globalThis.navigator?.clipboard?.writeText)try{return await navigator.clipboard.writeText(t),!0}catch{}return cg(t)}function cg(s){if(typeof document>"u"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=s,e.setAttribute("readonly",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;inset-block-start:-1000px;opacity:0;pointer-events:none",document.body.append(e);let i=!1;try{e.select(),e.setSelectionRange(0,s.length),i=document.execCommand?.("copy")===!0}catch{i=!1}finally{e.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}return i}function dg(s){return(s??[]).map(t=>{if(typeof t=="string")return{id:t,label:t};let e=String(t?.id??"");return{id:e,label:String(t?.label??e),value:t?.value}})}function ug(s,t){return s?.[t]}function hg(s){if(s==null)return"";if(s instanceof Date)return Number.isNaN(s.getTime())?"":s.toISOString();if(typeof s=="number")return Number.isFinite(s)?String(s):"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="object")try{return JSON.stringify(s)}catch{return String(s)}return String(s)}function su(s){return typeof s!="string"?!1:lg.includes(s.charAt(0))}function nu(s,t,e=!1){let i=e?` ${s}`:s;return i.includes(t)||i.includes('"')||i.includes(`
10
- `)||i.includes("\r")?`"${i.replaceAll('"','""')}"`:i}function fg(s,t){if(typeof Blob=="function"&&s instanceof Blob)return s;let e=typeof s=="string"&&/^text\/csv\b/i.test(t)?["\uFEFF",s]:[s];return new Blob(e,{type:t})}var Ht=class extends y{static cssName="check-button";static defaults={label:"",checked:!1,icon:!0,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("CheckButton target must be a button element");this._createdRoot=t,this._original=t?null:pg(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=au(this.options.label),e.type="button";let i=[];return this.options.icon&&i.push(l("span",{class:"zx-check-button__icon",ariaHidden:"true"},l("span",{class:"zx-check-button__off"},g("square",{size:15})),l("span",{class:"zx-check-button__on"},g("check",{size:15})))),i.push(l("span",{class:"zx-check-button__label",ref:"label"})),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked}),this)}toggle(){return this.set(!this._checked)}setLabel(t){return this._labels=au(t),this._sync(),this}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&_g(this.el,this._original))}_sync(){this.el.setAttribute("aria-pressed",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled),this.refs.label.textContent=this._checked?this._labels.on:this._labels.off}};function au(s){return Array.isArray(s)?{on:String(s[0]??""),off:String(s[1]??"")}:{on:String(s??""),off:String(s??"")}}function pg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function _g(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var mg=".zx-scope, [data-zx-theme], [data-zx-preset]",gg="dialog:modal, dialog[open], dialog:popover-open";function vt(s=null){return cu(lu(s))}function ns(s=null){let t=lu(s);return(s==null?null:di(t))??cu(t)}function oe(s=null,t={}){let e=t.dialog===!1?vt:ns;if(s==null)return e(null);let i=P(s);return i?.isConnected?e(i):null}function di(s){if(!s||typeof s.closest!="function")return null;try{return s.closest(gg)}catch{return s.closest("dialog[open]")}}function lu(s){return s==null?document.activeElement instanceof Element?document.activeElement:null:P(s)}function cu(s){let t=s?.closest?.(mg)??null;return!t||t===document.documentElement||t===document.body?document.body:t}var hu=new Set(["tooltip","toast"]);function ae(s,t){if(!s||!t)return!1;for(let e=t;e;e=e.parentNode??e.host??null)if(e===s)return!0;return!1}function bg(s,t){for(let e=s.length-1;e>=0;e-=1){let i=s[e];if(!hu.has(i.kind)&&t.some(n=>ae(i.root,n)))return i}return null}function rs(s,t,e){return e?ae(t.root,e)||t.inside.some(i=>ae(i,e))?!0:s.some(i=>i.parent===t&&rs(s,i,e)):!1}function ka(s,t=()=>!0){for(let e=s.length-1;e>=0;e-=1){let i=s[e];if(i.kind!=="toast"&&t(i))return i}return null}function yg(s,t=null){let e=[];for(let i=s.length-1;i>=0;i-=1){let n=s[i];if(n.kind==="modal")break;t&&!ae(t,n.root)||typeof n.onEscape=="function"&&e.push(n)}return e}function wg(s,t,e=null){if(s.some(n=>n.kind==="toast"&&ae(n.root,t)))return[];let i=[];for(let n=s.length-1;n>=0;n-=1){let r=s[n];r.kind==="tooltip"&&!rs(s,r,t)&&r.onOutsidePointer&&i.push(r)}for(let n=s.length-1;n>=0;n-=1){let r=s[n];if(!hu.has(r.kind)){if(rs(s,r,t)||r.kind==="modal")break;e&&!ae(e,r.root)||r.onOutsidePointer&&i.push(r)}}return i}var Ca=class{#t=[];#e=0;#i=null;#s=new Set;#r;#n=new WeakMap;constructor(t={}){this.#r=t.target===void 0?typeof document>"u"?null:document:t.target}push(t){let e=du(t.anchor),i={order:++this.#e,kind:t.kind,root:t.root,owner:t.owner??null,anchors:e,inside:du(t.inside),parent:t.kind==="toast"?null:bg(this.#t,e),onEscape:t.onEscape,onOutsidePointer:t.onOutsidePointer,onFocusOutside:t.onFocusOutside,onParentClose:t.onParentClose};this.#t.push(i);let n={entry:i,order:i.order,isOpen:()=>this.#t.includes(i),isTopmost:()=>ka(this.#t)===i,contains:r=>this.#t.includes(i)&&rs(this.#t,i,r),release:()=>this.#o(i)};return this.#n.set(i,n),this.#a(),this.#l(),n}entries(){return this.#t.slice()}topmost(t){return ka(this.#t,t)}topmostModal(){let t=ka(this.#t,i=>i.kind==="modal"&&i.root.isConnected&&vg(i.root,":modal",!0));if(t)return t.root;if(typeof document>"u"||typeof document.querySelectorAll!="function")return null;let e;try{e=document.querySelectorAll("dialog:modal")}catch{return null}return e.length?e[e.length-1]:null}containsNode(t){return this.#t.some(e=>ae(e.root,t)||e.inside.some(i=>ae(i,t)))}subscribe(t){return this.#s.add(t),()=>{this.#s.delete(t)}}handleKeydown(t){if(t.key!=="Escape"||t.defaultPrevented||t.isComposing)return null;for(let e of yg(this.#t,uu(za(t)))){let i=this.#n.get(e);if(!(!i||!this.#t.includes(e))&&e.onEscape?.(t,i)!==!1)return t.preventDefault(),e}return null}handlePointerdown(t){let e=za(t),i=wg(this.#t,e,uu(e));for(let n of i){let r=this.#n.get(n);r&&this.#t.includes(n)&&n.onOutsidePointer?.(t,r)}return i}handleFocusin(t){let e=za(t);for(let i of this.#t.slice().reverse()){if(typeof i.onFocusOutside!="function"||!this.#t.includes(i)||rs(this.#t,i,e))continue;let n=this.#n.get(i);n&&i.onFocusOutside(t,n)}}#o(t){let e=this.#t.indexOf(t);if(e<0)return;this.#t.splice(e,1);let i=this.#t.filter(n=>n.parent===t);for(let n of i)n.parent=t.parent;this.#t.length===0&&this.#c(),this.#l();for(let n of i.reverse()){let r=this.#n.get(n);r&&this.#t.includes(n)&&n.onParentClose?.(r)}}#a(){if(this.#i||!this.#r||typeof this.#r.addEventListener!="function")return;let t=new AbortController;this.#i=t;let{signal:e}=t;this.#r.addEventListener("keydown",i=>this.handleKeydown(i),{signal:e}),this.#r.addEventListener("pointerdown",i=>this.handlePointerdown(i),{capture:!0,signal:e}),this.#r.addEventListener("focusin",i=>this.handleFocusin(i),{signal:e})}#c(){this.#i?.abort(),this.#i=null}#l(){let t=this.#t.slice();for(let e of[...this.#s])try{e(t)}catch(i){queueMicrotask(()=>{throw i})}}},ui=new Ca;function le(s){return ui.push(s)}function du(s){let t=Array.isArray(s)?s:[s];return t.filter((e,i)=>e!=null&&t.indexOf(e)===i)}function uu(s){for(let t=s;t;t=t.parentNode??t.host??null)if(t.localName==="dialog"&&typeof t.matches=="function")try{if(t.matches(":modal"))return t}catch{return null}return null}function za(s){return(typeof s.composedPath=="function"?s.composedPath():[])[0]??s.target??null}function vg(s,t,e){if(typeof s.matches!="function")return e;try{return s.matches(t)}catch{return e}}var xg=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),hi=class extends y{static cssName="modal";static defaults={content:null,width:"auto",closable:!0,lightDismiss:!1,destroyOnClose:!1,scope:null};#t=new Map;#e=!1;#i=0;#s=[];#r=null;#n=null;constructor(t=null,e={}){super(null,e),this.#c(this.options.width),pu(this.refs.content,this.options.content),this.listen(this.el,"cancel",i=>{let n=this.emit("cancel");(!this.options.closable||n.defaultPrevented)&&i.preventDefault()}),this.listen(this.el,"close",()=>{this._settleClose(this.#s.shift())}),this.listen(this.el,"click",i=>{!this.options.lightDismiss||i.target!==this.el||!Ag(this.el,i)||this.close()}),this.on("close",()=>this.#a())}mountTarget(){return vt(this.options.scope)}_show(){this.el.showModal()}_hide(t="",e=this.#i){this.#s.push(e);try{this.el.close(t)}catch(i){throw this.#s.pop(),i}}_present(){this._show(),this.#i+=1,this.#o()}#o(){this.el.matches(":modal")?this.el.setAttribute("aria-modal","true"):this.el.getAttribute("aria-modal")==="true"&&this.el.removeAttribute("aria-modal")}_overlayEntry(){return{kind:this.el.matches(":modal")?"modal":"non-modal",root:this.el,owner:this,anchor:this.#r}}_syncOverlay(){if(this._releaseOverlay(),!this._isShown())return;let t=this._overlayEntry();t&&(this.#n=le(t),this.el.dataset.zxOverlayOrder=String(this.#n.order))}_releaseOverlay(){let t=this.#n;this.#n=null,delete this.el.dataset.zxOverlayOrder,t?.release()}_overlayContains(t){return this.#n?this.#n.contains(t):this.el.contains(t??null)}_dismiss(t=""){this._hide(t,this.#i)}_isShown(){return this.el.open}_isRealClose(t){return t!==void 0&&t!==this.#i?!1:!this._isShown()}_settleClose(t){if(!this._isRealClose(t))return t!==void 0&&this.#t.delete(t),!1;this.el.dataset.state="closed",this._releaseOverlay(),this.el.getAttribute("aria-modal")==="true"&&this.el.removeAttribute("aria-modal");let e=t===void 0?void 0:this.#t.get(t);t!==void 0&&this.#t.delete(t);let i=e?e.result:this.el.returnValue||void 0;return this.emit("close",{result:i}),this.options.destroyOnClose&&!this.#e&&this.destroy(),!0}#a(){let t=this.#r;this.#r=null,t?.isConnected&&typeof t.focus=="function"&&t.focus()}_focusInitial(){if(!this.isOpen())return;let t=Sg(this.el);if(t){t.focus();return}let e=this.el;e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus()}render(){let t=l("dialog",{class:"zx-modal"},l("div",{class:"zx-modal__content",ref:"content"}));return t.dataset.state="closed",this._mountInitial(t),t}_mountInitial(t){this.options.scope!=null&&!oe(this.options.scope)||this.mountTarget().append(t)}open(){if(this.isOpen())return this;this.#r=document.activeElement instanceof Element?document.activeElement:null;let t=this.mountTarget();this.el.parentElement!==t&&t.append(this.el),this.el.returnValue="";try{this._present()}catch(e){throw this.#r=null,e}return this._syncOverlay(),this.el.dataset.state="open",this.emit("open"),queueMicrotask(()=>this._focusInitial()),this}close(t){if(!this.isOpen())return this;let e=this.#i;this.#t.set(e,{result:t});try{this._dismiss(typeof t=="string"?t:"")}catch(i){throw this.#t.delete(e),i}return this}setContent(t){return pu(this.refs.content,t),this}isOpen(){return this._isShown()}destroy(){this.#e||(this.#e=!0,this.isOpen()&&this._dismiss(),this._releaseOverlay(),super.destroy())}#c(t){typeof t=="number"&&Number.isFinite(t)?this.el.style.inlineSize=`${Math.max(0,t)}px`:this.el.style.inlineSize=String(t??"auto")}};function Sg(s){let t=s.querySelector("[autofocus]:not([disabled])");if(t&&fu(t,s))return t;for(let e of s.querySelectorAll(xg))if(fu(e,s))return e;return null}function fu(s,t){if(typeof s.focus!="function")return!1;for(let e=s;e;e=e.parentElement){if(e.hidden||e.getAttribute("aria-hidden")==="true"||e.hasAttribute("inert"))return!1;if(e===t)break}return!0}function pu(s,t){if(s.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}function Ag(s,t){let e=s.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}var kg=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),zg=Object.freeze({sm:!0,md:!0,lg:!0});function fi(s={}){let t={...kg,...s},e=String(t.label??""),i=l("span",{class:"zx-spinner",dataset:{size:zg[t.size]?t.size:"md",kind:t.kind==="current"?"current":"accent"}},l("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return e?(i.setAttribute("role","status"),i.append(l("span",{class:"zx-spinner__label",dataset:{visible:t.showLabel?"true":null}},e))):i.setAttribute("aria-hidden","true"),i}var Cg=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function j(s={}){let t={...Cg,...s},e=l("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title??(t.shortcut?`${t.label} (${t.shortcut.label})`:void 0),ariaKeyshortcuts:t.shortcut?.keys,dataset:{kind:Tg(t.kind),size:Ig(t.size)}});return t.icon&&e.append(g(t.icon,{size:16})),t.label!==""&&e.append(l("span",{class:"zx-btn__label"},String(t.label))),t.shortcut&&e.append(l("kbd",{class:"zx-btn__shortcut",ariaHidden:"true"},t.shortcut.label)),!t.label&&t.title&&e.setAttribute("aria-label",t.title),typeof t.onclick=="function"&&(e.onclick=t.onclick),t.busy&&Ta(e,!0),e}function _u(s){let t=l("div",{class:"zx-btn-group",role:"group"});return t.append(...s),t}function Ta(s,t){if(s.hasAttribute("data-busy-guard")||(s.setAttribute("data-busy-guard",""),s.addEventListener("click",e=>{s.getAttribute("aria-busy")==="true"&&(e.preventDefault(),e.stopImmediatePropagation())},{capture:!0})),s.querySelector(":scope > .zx-btn__spinner")?.remove(),t){s.setAttribute("aria-busy","true"),s.setAttribute("aria-disabled","true");let e=fi({size:"sm",kind:"current"});e.classList.add("zx-btn__spinner"),s.prepend(e)}else s.removeAttribute("aria-busy"),s.removeAttribute("aria-disabled");return s}function Tg(s){return["primary","danger","ghost"].includes(String(s))?s:"default"}function Ig(s){return s==="sm"?"sm":"md"}var qt=class s extends hi{static cssName="dialog";static defaults={title:"",size:"md",buttons:[],closable:!0};#t=new Map;#e=null;#i=[];#s="";constructor(t=null,e={}){super(null,e),this._applySize(this.options.size),this.#s=String(this.options.title??""),this.#n(this.#s),this.#i=Sn(this.options.buttons),this.#o(this.#i),this.refs.close.hidden=!this.options.closable,this.listen(this.refs.close,"click",()=>this.close()),this.listen(this.refs.footer,"click",i=>{let n=i.target.closest?.("[data-dialog-button]");if(!n||!this.refs.footer.contains(n))return;let r=this.#r[Number(n.dataset.dialogButton)];r&&this.#a(r)})}#r=[];render(){let t=x("zx-dialog-title"),e=this._message("dialog.close","Close"),i=l("dialog",{class:"zx-modal zx-dialog",ariaLabelledby:t},l("header",{class:"zx-dialog__header"},l("h2",{class:"zx-dialog__title",id:t,ref:"title"}),l("button",{class:"zx-btn zx-dialog__close",ref:"close",type:"button","data-kind":"ghost",ariaLabel:e,title:e},"\xD7")),l("div",{class:"zx-modal__content zx-dialog__body",ref:"content"}),l("footer",{class:"zx-dialog__footer",ref:"footer"}));return i.dataset.state="closed",this._mountInitial(i),i}open(){return super.open()}setTitle(t){return this.#s=String(t??""),this.#n(this.#s),this}setContent(t){return this.#t.clear(),this.#e=null,Dg(this.refs.content,t),this}setButtons(t){return this.#i=Sn(t),this.#o(this.#i),this}addView(t,e){let i=String(t);this.#t.get(i)?.content.remove();let r=l("section",{class:"zx-dialog__view",hidden:!0,ariaHidden:"true"});gu(r,e?.content??null);let o={key:i,content:r,buttons:e&&Object.hasOwn(e,"buttons")?Sn(e.buttons??[]):null,title:e&&Object.hasOwn(e,"title")?String(e.title??""):null};return this.#t.set(i,o),this.#t.size===1||this.#e?.key===i?this.showView(i):this.refs.content.append(r),o}showView(t){let e=this.#t.get(String(t));if(!e)throw new RangeError(`Unknown dialog view: ${t}`);this.#e||this.refs.content.replaceChildren();for(let i of this.#t.values()){i.content.isConnected||this.refs.content.append(i.content);let n=i===e;i.content.hidden=!n,i.content.setAttribute("aria-hidden",String(!n))}return this.#e=e,this.#n(e.title??this.#s),this.#o(e.buttons??this.#i),e}getView(t){return this.#t.get(String(t))??null}static alert({title:t="",message:e="",okLabel:i}={}){return new Promise(n=>{let r=!1,o=()=>{r||(r=!0,a.close(),n())},a=new s(null,{title:t,content:e});a.setButtons([{label:i??a._message("dialog.ok","OK"),kind:"primary",action:o,autofocus:!0}]),a.once("close",()=>{r||(r=!0,n()),a.destroy()}),a.open()})}static confirm({title:t="",message:e="",okLabel:i,cancelLabel:n,danger:r=!1,confirmText:o=null}={}){return new Promise(a=>{let c=!1,d=_=>{c||(c=!0,h.close(_),a(_))},u=o==null?"":String(o).trim(),h=new s(null,{title:t,content:u?null:e}),f={label:n??h._message("dialog.cancel","Cancel"),action:()=>d(!1),autofocus:r&&!u},p={label:i??h._message("dialog.ok","OK"),kind:r?"danger":"primary",action:()=>d(!0),autofocus:!r&&!u};if(u){let _=l("input",{class:"zx-dialog__confirm-input",id:x("zx-dialog-confirm"),type:"text",autocomplete:"off",autocapitalize:"off",spellcheck:!1,autofocus:!0}),[m,b]=Eg(h._message("dialog.typeToConfirm","Type %1 to confirm"),u),w=l("label",{class:"zx-dialog__confirm-label",for:_.id},m,l("b",{},u),b);h.setContent(l("div",{class:"zx-dialog__confirm"},Mg(e)?null:l("div",{class:"zx-dialog__prompt-message"},e),w,_));let v=!1,z=()=>h.setButtons([f,{...p,autofocus:!1,disabled:!v}]);z(),h.listen(_,"input",()=>{let C=mu(_.value,u);C!==v&&(v=C,z())}),h.listen(_,"keydown",C=>{let k=C;k.key!=="Enter"||k.isComposing||(k.preventDefault(),mu(_.value,u)&&d(!0))})}else h.setButtons([f,p]);h.once("close",()=>{c||(c=!0,a(!1)),h.destroy()}),h.open()})}static prompt({title:t="",message:e="",value:i="",placeholder:n="",okLabel:r,cancelLabel:o}={}){return new Promise(a=>{let c=!1,d=l("input",{class:"zx-dialog__prompt-input",value:String(i),placeholder:String(n),autofocus:!0}),u=l("div",{class:"zx-dialog__prompt"},l("div",{class:"zx-dialog__prompt-message"},e),d),h=p=>{c||(c=!0,f.close(p),a(p))},f=new s(null,{title:t,content:u});d.setAttribute("aria-label",String(t||f._message("dialog.promptValue","Prompt value"))),f.setButtons([{label:o??f._message("dialog.cancel","Cancel"),action:()=>h(null)},{label:r??f._message("dialog.ok","OK"),kind:"primary",action:()=>h(d.value)}]),f.listen(d,"keydown",p=>{p.key==="Enter"&&(p.preventDefault(),h(d.value))}),f.once("close",()=>{c||(c=!0,a(null)),f.destroy()}),f.open()})}_applySize(t){let e={sm:400,md:600,lg:840},i=typeof t=="number"&&Number.isFinite(t)?t:e[t]??e.md;this.el.style.inlineSize=`${Math.max(0,i)}px`}_message(t,e){let i=this.msg(t);return i===t?e:i}#n(t){this.refs.title.textContent=t}#o(t){this.#r=Sn(t),this.refs.footer.replaceChildren(),this.refs.footer.hidden=this.#r.length===0,this.#r.forEach((e,i)=>{let n=j({label:e.label,kind:e.kind,shortcut:e.shortcut,disabled:e.disabled});n.dataset.dialogButton=String(i),n.autofocus=e.autofocus,this.refs.footer.append(n)})}#a(t){if(t.disabled)return;let e=t.action??"close";e==="close"?this.close():e==="cancel"?this.emit("cancel").defaultPrevented||this.close():typeof e=="function"&&e(this)}};function mu(s,t){let e=t==null?"":String(t).trim();return e!==""&&String(s??"").trim()===e}function Eg(s,t){let e=String(s).split("%1");return e.length===1?[`${e[0]} `,""]:[e[0],e.slice(1).join(t)]}function Mg(s){return s==null||s===""}function Sn(s){return Array.isArray(s)?s.map(t=>{let e=!!t?.disabled;return{...t,label:String(t?.label??""),disabled:e,autofocus:!!t?.autofocus&&!e}}):[]}function Dg(s,t){s.replaceChildren(),gu(s,t)}function gu(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}var ce=class extends y{static cssName="groupbox";static defaults={title:"",open:!0};constructor(t,e={}){let i=t,n=null;if(t!==null){let r=P(t);if(r&&r.localName!=="details"){let o=document.createElement("details"),a=Array.from(r.childNodes),c=r.parentNode,d=r.nextSibling;c&&c.insertBefore(o,r),o.append(...a),r.remove(),n={original:r,details:o,children:a,parent:c,next:d},i=o}}try{super(i,e)}catch(r){throw n&&bu(n),r}this._adoption=n}render(){let t=!this.el,e=this.el??l("details");if(e.localName!=="details")throw new TypeError("Groupbox requires a details element");this._createdRoot=t,this._original=t?null:Ng(e);let i=Array.from(e.childNodes).filter(o=>!(o.nodeType===1&&o.localName==="summary")),n=l("summary",{class:"zx-groupbox__summary",ref:"summary"},l("span",{class:"zx-groupbox__chevron",ariaHidden:"true"},g("chevron-right",{size:16})),l("span",{class:"zx-groupbox__title",ref:"title"},String(this.options.title))),r=l("div",{class:"zx-groupbox__content",ref:"content"},i);return e.replaceChildren(n,r),e.open=!!this.options.open,this._lastOpen=e.open,this.listen(e,"toggle",()=>{let o=e.open;o!==this._lastOpen&&(this._lastOpen=o,this.emit(o?"open":"close"))}),e}open(){return this.el.setAttribute("open",""),this}close(){return this.el.removeAttribute("open"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.el.open}setTitle(t){return this.refs.title.textContent=String(t),this}setContent(t){let e=t instanceof y?t.toElement():t;if(this.refs.content.replaceChildren(),typeof e=="string")this.refs.content.append(document.createTextNode(e));else if(e&&typeof e.nodeType=="number")this.refs.content.append(e);else throw new TypeError("Groupbox content must be a string, Node, or Component");return this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._adoption?bu(this._adoption):!this._createdRoot&&this._original&&Og(this.el,this._original))}};function Ng(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Og(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function bu(s){if(s.original.replaceChildren(...s.children),s.details.parentNode)s.details.replaceWith(s.original);else if(s.parent){let t=s.next?.parentNode===s.parent?s.next:null;s.parent.insertBefore(s.original,t)}}var Ot=class extends y{static cssName="search";static defaults={placeholder:"",value:"",clearable:!0,debounce:250};render(){let t=!this.el,e=this.el??l("form");this._createdRoot=t,this._original=t?null:Fg(e),this._inputTimer=null,e.setAttribute("role","search");let i=this._message("search.clear","Clear search"),n=l("input",{class:"zx-search__input",ref:"input",type:"search",placeholder:String(this.options.placeholder),value:String(this.options.value),ariaLabel:String(this.options.placeholder||this._message("search.label","Search"))}),r=this.options.clearable?l("button",{class:"zx-search__clear",ref:"clear",type:"button",ariaLabel:i,title:i},g("x",{size:15})):null,o=l("button",{class:"zx-search__submit",ref:"submit",type:e.localName==="form"?"submit":"button",ariaLabel:this._message("search.submit","Submit search"),title:this._message("search.submitTitle","Search")},g("search",{size:16}));return e.replaceChildren(...[n,r,o].filter(Boolean)),this._syncClear(),this.listen(n,"input",()=>{this._syncClear(),this._scheduleInput()}),e.localName==="form"?this.listen(e,"submit",a=>{a.preventDefault(),this.emit("submit",{value:this.get()})}):(this.listen(n,"keydown",a=>{a.key==="Enter"&&(a.preventDefault(),this.emit("submit",{value:this.get()}))}),this.listen(o,"click",()=>this.emit("submit",{value:this.get()}))),r&&this.listen(r,"click",()=>this.clear()),e}get(){return this.refs.input.value}set(t,{silent:e=!1}={}){return this._inputTimer!==null&&(clearTimeout(this._inputTimer),this._inputTimer=null),this.refs.input.value=String(t),this._syncClear(),e||this._scheduleInput(),this}focus(){return this.refs.input.focus(),this}clear(){return this.set(""),this.emit("clear"),this.focus(),this}destroy(){this._cleaned||(this._cleaned=!0,this._inputTimer!==null&&clearTimeout(this._inputTimer),super.destroy(),!this._createdRoot&&this._original&&Lg(this.el,this._original))}_scheduleInput(){this._inputTimer!==null&&clearTimeout(this._inputTimer);let t=Math.max(0,Number(this.options.debounce)||0);this._inputTimer=setTimeout(()=>{this._inputTimer=null,this.emit("input",{value:this.get()})},t)}_syncClear(){this.refs.clear&&(this.refs.clear.hidden=this.get()==="")}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Fg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Lg(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var Rg=new Set(["divided","bracket","line","segmented"]),pi=class extends y{static cssName="tabbox";static defaults={tabs:[],active:null,variant:"divided",keepAlive:!0};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");if(this.el=e,this._createdRoot=t,this._original=t?null:Bg(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!Rg.has(this.options.variant))throw new RangeError(`Unknown tabbox variant: ${this.options.variant}`);e.dataset.variant=this.options.variant;let i=l("div",{class:"zx-tabbox__tablist",ref:"tablist",role:"tablist",ariaOrientation:"horizontal",ariaLabel:this.options.label||null}),n=l("div",{class:"zx-tabbox__panels",ref:"panels"});if(e.replaceChildren(i,n),!Array.isArray(this.options.tabs))throw new TypeError("Tabbox tabs must be an array");for(let a of this.options.tabs)this.addTab(a);this._initializing=!1;let r=this.options.active===null?null:this._find(this.options.active),o=r&&!r.definition.disabled?r:this._enabledTabs()[0];return o&&this._applyActive(o),this.listen(i,"click",a=>{let c=a.target.closest?.('[role="tab"]');if(!c||!i.contains(c))return;let d=this._recordForTab(c);if(!(!d||d.definition.disabled)){if(a.target.closest?.(".zx-tabbox__close")){this._closeTab(d);return}this._setFocused(d),this.openTab(d.definition.name)}}),this.listen(i,"keydown",a=>this._onKeydown(a)),e}addTab(t,e={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Tab definition must be an object");if(typeof t.name!="string"||t.name==="")throw new TypeError("Tab name must be a non-empty string");if(this._find(t.name))throw new RangeError(`Tab already exists: ${t.name}`);if(!Pg(t.content))throw new TypeError("Tab content must be a Node, Component, or function");let i={name:t.name,title:String(t.title??""),content:t.content,icon:t.icon?String(t.icon):null,closable:!!t.closable,disabled:!!t.disabled},n=x("zx-tab"),r=x("zx-tabpanel"),o=l("span",{class:"zx-tabbox__title"},i.title),a=l("span",{class:"zx-tabbox__badge",hidden:!0}),c=[];i.icon&&c.push(l("span",{class:"zx-tabbox__icon",ariaHidden:"true"},g(i.icon,{size:16}))),c.push(o,a),i.closable&&c.push(l("span",{class:"zx-tabbox__close zx-icon-btn",ariaHidden:"true",title:this._message("tabbox.close","Close")},g("x",{size:14})));let d=l("button",{class:"zx-tabbox__tab",type:"button",id:n,role:"tab",tabindex:"-1",ariaControls:r,ariaSelected:"false",ariaDisabled:i.disabled?"true":null,dataset:{closable:i.closable?"true":null}},c),u=l("div",{class:"zx-tabbox__panel",id:r,role:"tabpanel",tabindex:"0",ariaLabelledby:n,hidden:!0}),h={definition:i,tab:d,title:o,badge:a,panel:u,built:!1},f=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,p=Math.max(0,Math.min(this._tabs.length,f)),_=this._tabs[p]??null;return this._tabs.splice(p,0,h),this.refs.tablist.insertBefore(d,_?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(u,_?.panel??null),!this._initializing&&!this._active&&!i.disabled&&this._applyActive(h),this}removeTab(t){return this._removeTab(t,!1),this}openTab(t){let e=this._find(t);if(!e||e.definition.disabled||e===this._active)return this;let i=this._active?.definition.name??null;return this.emit("change",{name:e.definition.name,previous:i}).defaultPrevented?this:(this._applyActive(e),this)}show(t){return this.openTab(t)}getActive(){return this._active?.definition.name??null}setTitle(t,e){let i=this._require(t);return i.definition.title=String(e??""),i.title.textContent=i.definition.title,this}setBadge(t,e){let i=this._require(t);return i.badge.textContent=e===null?"":String(e),i.badge.hidden=e===null,this}enableTab(t){let e=this._require(t);return e.definition.disabled?(e.definition.disabled=!1,e.tab.removeAttribute("aria-disabled"),this._active||this._applyActive(e),this):this}disableTab(t){let e=this._require(t);if(e.definition.disabled)return this;if(e===this._active){let i=this._enabledTabs().find(n=>n!==e)??null;if(i){if(this.openTab(i.definition.name),this._active===e)return this}else e.tab.setAttribute("aria-selected","false"),e.tab.tabIndex=-1,e.panel.hidden=!0,this._keepAlive||e.panel.remove(),this._active=null}return e.definition.disabled=!0,e.tab.setAttribute("aria-disabled","true"),e.tab.tabIndex=-1,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Vg(this.el,this._original))}_onKeydown(t){let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.tablist.contains(e))return;let i=this._recordForTab(e);if(!i)return;let n=this._enabledTabs();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(i),a=n[(o+r+n.length)%n.length];a&&this._setFocused(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let r=t.key==="Home"?n[0]:n[n.length-1];r&&this._setFocused(r);return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.openTab(i.definition.name);return}t.key==="Delete"&&i.definition.closable&&(t.preventDefault(),this._closeTab(i))}_closeTab(t){let e=this._tabs.indexOf(t),i=t.tab.contains(document.activeElement);if(!this._removeTab(t.definition.name,!0))return;let n=this._tabs[Math.min(e,this._tabs.length-1)]??this._tabs[e-1],r=n&&!n.definition.disabled?n:this._active;r&&this._setFocused(r,i)}_removeTab(t,e){let i=this._find(t);if(!i)return!1;let n=this._tabs.indexOf(i),o=this._tabs.filter(c=>c!==i).filter(c=>!c.definition.disabled),a=o.find(c=>this._tabs.indexOf(c)>n)??o.at(-1)??null;return i===this._active&&a&&this.emit("change",{name:a.definition.name,previous:i.definition.name}).defaultPrevented?!1:(this._tabs.splice(n,1),i.tab.remove(),i.panel.remove(),i===this._active&&(this._active=null,a&&this._applyActive(a)),e&&this.emit("close",{name:i.definition.name}),!0)}_applyActive(t){this._ensureContent(t);let e=this._active;e&&e!==t&&(e.tab.setAttribute("aria-selected","false"),e.panel.hidden=!0,this._keepAlive||e.panel.remove()),this._active=t,t.tab.setAttribute("aria-selected","true"),t.panel.hidden=!1,t.panel.parentNode!==this.refs.panels&&this.refs.panels.append(t.panel),this._setFocused(t,!1)}_ensureContent(t){if(t.built)return;let e=typeof t.definition.content=="function"?t.definition.content():t.definition.content,i=e instanceof y?e.toElement():e;if(!i||typeof i.nodeType!="number")throw new TypeError(`Tab content factory for ${t.definition.name} must return a Node or Component`);t.panel.append(i),t.built=!0}_setFocused(t,e=!0){for(let i of this._tabs)i.tab.tabIndex=i===t?0:-1;e&&t.tab.focus()}_enabledTabs(){return this._tabs.filter(t=>!t.definition.disabled)}_find(t){return this._tabs.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown tab: ${t}`);return e}_recordForTab(t){return this._tabs.find(e=>e.tab===t)??null}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Pg(s){return typeof s=="function"||s instanceof y?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Bg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Vg(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function jg(s,t){return String(s).localeCompare(String(t))}function Hg(s,t){return s-t}function qg(s,t){return s.getTime()-t.getTime()}function $g(s,t,e="asc"){let i=s==null,n=t==null;if(i||n)return i&&n?0:i?1:-1;let r;return s instanceof Date&&t instanceof Date?r=qg(s,t):typeof s=="number"&&typeof t=="number"?r=Hg(s,t):r=jg(s,t),e==="desc"?-r:r}function Kg(s,t="asc"){return(e,i)=>$g(s(e),s(i),t)}function os(s,t,e="asc"){let i=Kg(t,e);return s.map((n,r)=>({row:n,index:r})).sort((n,r)=>i(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var Ug=new Set(["text","number","select","date","checkbox","textarea"]),Yg='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',Ft=class extends y{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(t,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");if(this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._columns=wu(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=lb(this.options.rowKind),this._rowKinds=cb(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=xu(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=hb(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=yb(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||kn(this.options.hierarchy,this._columns)||this._clickListened),this._current=null,this._rovingEl=null,this._extendBase=null,this._hierarchy=kn(this.options.hierarchy,this._columns),this._hiddenColumns=new Set((Array.isArray(this.options.hiddenColumns)?this.options.hiddenColumns:[]).map(String).filter(i=>this._columns.some(n=>n.id===i))),this._hiddenColumns.size>=this._columns.length&&this._columns[0]&&this._hiddenColumns.delete(this._columns[0].id),this._dragId=null,this._grabbedId=null,this._columnControlIds=new Map,this._columnStatus=null,this._expanded=db(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let i of An(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(i);return this._reconcileExpanded(),ub(this.options.variant)==="plain"&&(e.dataset.variant="plain"),this._table=l("table",{class:"zx-table__table"}),this._syncGridRole(),this._colgroup=l("colgroup",{class:"zx-table__columns"}),this._thead=l("thead",{class:"zx-table__head"}),this._tbody=l("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=l("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this._rowMoveMessage=this.options.rowReorder?l("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility||this.options.columnReorder?this._createColumnControls():null,this._editMode===!1?e.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(e.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:x("zx-table-message"),role:"status",ariaLive:"polite"}),e.replaceChildren(...[this._columnControls,this._scroll,this._editMessage,this._rowMoveMessage].filter(Boolean))),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",i=>this._handleBodyClick(i)),this.listen(this._tbody,"dblclick",i=>this._handleBodyDoubleClick(i)),this.options.rowReorder&&(this.listen(this._tbody,"dragstart",i=>this._handleRowDragStart(i)),this.listen(this._tbody,"dragover",i=>this._handleRowDragOver(i)),this.listen(this._tbody,"drop",i=>this._handleRowDrop(i)),this.listen(this._tbody,"dragend",()=>this._clearRowDrag()),this.listen(this._tbody,"keydown",i=>this._handleRowHandleKeydown(i))),this._columnControls&&(this.listen(this._columnControls,"change",i=>{let n=i.target;n?.classList.contains("zx-table__column-toggle")&&this.setColumnVisible(n.value,n.checked)}),this.listen(this._columnControls,"click",i=>this._handleColumnControlClick(i)),this.listen(this._columnControls,"keydown",i=>this._handleColumnControlKeydown(i))),this._editMode!==!1&&(this.listen(this._tbody,"keydown",i=>this._handleEditKeydown(i)),this.listen(document,"pointerdown",i=>this._handleDocumentPointerDown(i),{capture:!0})),this.listen(this._tbody,"keydown",i=>this._handleGridKeydown(i)),this.listen(this._tbody,"focusin",i=>this._handleFocusIn(i)),e}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),Su(t),this._data=[...t],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let e=this._pruneSelection();return this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}addData(t){return Su(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let i=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(i<0)return this;let n=this._selected.delete(t);return this._data[i]=e,n&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(e<0)return this;this._data.splice(e,1),this._reconcileExpanded();let i=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._extendBase=null,this._renderBody(),i&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}getColumns(){return this._columns.map(t=>({...t}))}setColumns(t,e={}){let i=wu(t),n=this.getColumnOrder(),r=this.getHiddenColumns(),o=this.getSort();return this._abortEdit({focus:!1}),this._columns=i,this._hiddenColumns=new Set(r.filter(a=>i.some(c=>c.id===a))),this._hiddenColumns.size>=i.length&&i[0]&&this._hiddenColumns.delete(i[0].id),this._sort=xu(o,i),this._hierarchy=kn(this.options.hierarchy,i),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),e.silent||(zn(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),zn(r,this.getHiddenColumns())||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()})),this}getColumnOrder(){return this._columns.map(t=>t.id)}setColumnOrder(t,e={}){let i=mb(this._columns,t);if(zn(i,this.getColumnOrder()))return this;let n=this._activeColumnControl(),r=new Map(this._columns.map(o=>[o.id,o]));return this._abortEdit({focus:!1}),this._columns=i.map(o=>r.get(o)),this._hierarchy=kn(this.options.hierarchy,this._columns),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(n),e.silent||this.emit("columnorderchange",{order:this.getColumnOrder()}),this}moveColumn(t,e,i="before",n={}){if(i!=="before"&&i!=="after")throw new TypeError('Table column position must be "before" or "after"');let r=gb(this.getColumnOrder(),String(t),String(e),i);if(zn(r,this.getColumnOrder()))return this;if(this.setColumnOrder(r,n),this._columnStatus){let o=this._columns.find(c=>c.id===String(t)),a=this.getColumnOrder().indexOf(String(t));o&&a>=0&&(this._columnStatus.textContent=`Moved ${Cn(o)} to position ${a+1} of ${this._columns.length}.`)}return this}getVisibleColumns(){return this._visibleColumns().map(t=>t.id)}getHiddenColumns(){return this._columns.filter(t=>this._hiddenColumns.has(t.id)).map(t=>t.id)}setColumnVisible(t,e=!0,i={}){let n=String(t);if(!this._columns.find(c=>c.id===n))throw new RangeError(`Unknown table column: ${n}`);let o=this._activeColumnControl();if(!e&&!this._hiddenColumns.has(n)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=e?this._hiddenColumns.delete(n):!this._hiddenColumns.has(n);return!e&&a&&this._hiddenColumns.add(n),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),i.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(t,e={}){return this.setColumnVisible(t,this._hiddenColumns.has(String(t)),e)}moveRow(t,e,i="before"){if(!this.options.rowReorder||this._sort&&this.options.sortMode==="local")return this;let n=this.getRow(t),r=this.getRow(e);if(!n||!r||Object.is(t,e))return this;if(this._isSpanningRow(n))return this;let o=Na(this._data,this.options.rowId,t,e,i,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:t,target:r,targetId:e,position:i}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let c=this._siblingIds(t),d=c.findIndex(u=>Object.is(u,t));this._rowMoveMessage.textContent=`Moved row to position ${d+1} of ${c.length}.`}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(t)?.focus()),this}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,i={}){if(this._spanning)return this._sortWarned||(this._sortWarned=!0,console.warn("[zx.Table] setSort() is inert while the data contains spanning rowKinds rows: sorting would scatter the rows out of the sections that group them.")),this;if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),i.silent||this.emit("sort",{id:t,dir:r}),this}getSort(){return this._sort?{...this._sort}:null}clearSort(t={}){return this._sort?(this._abortEdit({focus:!1}),this._sort=null,this._syncSortHeader(),t.silent||this.emit("sort",{id:null,dir:null}),this):this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=this._selectableIds(),i=new Set;if(this.options.selectable!==!1){for(let n of t)if(e.has(n)&&i.add(n),this.options.selectable==="single"&&i.size>0)break}return this._extendBase=null,Ia(this._selected,i)?this:(this._selected=i,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(t,e={}){return this._expanded.has(t)?this.collapseRow(t,e):this.expandRow(t,e)}expandRow(t,e={}){return this._setRowExpanded(t,!0,e)}collapseRow(t,e={}){return this._setRowExpanded(t,!1,e)}expandAll(t={}){if(!this._hierarchy)return this;let i=An(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of i)this._expanded.add(n);if(i.length&&this._renderBody(),!t.silent)for(let n of i)this._emitRowToggle(n,!0);return this}collapseAll(t={}){if(!this._hierarchy||this._expanded.size===0)return this;let e=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!t.silent)for(let i of e)this._emitRowToggle(i,!1);return this}getExpanded(){return this._data.map(t=>this._idFor(t)).filter(t=>this._expanded.has(t))}startEdit(t,e){if(this._editMode===!1)return this;let i=this._columns.find(f=>f.id===e);if(!i)return this;let n=this._data.find(f=>Object.is(this._idFor(f),t));if(n===void 0)return this;if(this._isSpanningRow(n))return this;let r=this._editMode==="row"&&this._hiddenColumns.has(i.id)?this._visibleColumns().find(f=>_i(f,n)!==!1)??null:i;if(!r||_i(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(f=>Object.is(this._idFor(f),t));if(a<0)return this;let c=this._data[a],d=this._rowElements.get(t)?.[0];if(!d)return this;let u=this._editMode==="row"?this._visibleColumns().filter(f=>_i(f,c)!==!1):[r],h=new Map;for(let f of u){let p=vu(d,f.id);if(!p)continue;let _=this._createEditor(p,f,c,a);_&&h.set(f.id,_)}return h.size===0?this:(this._edit={id:t,columnId:o,row:c,cells:h,tr:d},d.dataset.editing="true",this.emit("editstart",{row:c,id:t,column:r,columnId:o,value:c?.[o]}),this._focusEditor(o),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,i={};for(let[h,f]of t.cells)i[h]=f.read();let n=this._columns.filter(h=>t.cells.has(h.id)),r=ab(i,n,e,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),t.columnId=r.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(h=>h.id===r.columnId)??null,columnId:r.columnId,value:i[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=ob(e,i),a=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(h=>h.id===a)??null,columnId:a,value:i[a],previous:e?.[a],changes:o}).defaultPrevented)return this;let d=this._editHasFocus(),u={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,u),d&&this._focusCell(this._idFor(u),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?eb(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,i=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===i?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return Math.min(this._rendered,this._projectedData().length)}_syncGrowing(){if(!this._growStep)return;let t=this._projectedData().length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=l("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,i){let n=this.msg(t,...i);return n===t?T(e,i):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in Se)||(this._width=ni((e,i)=>this._setStacked(i>0&&i<Se[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}addEventListener(t,e,i){super.addEventListener(t,e,i),!(!e||t!=="rowclick"&&t!=="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 t=this._table,e=this._gridRole();e?t.setAttribute("role",e):t.removeAttribute("role"),this.options.labelledBy?t.setAttribute("aria-labelledby",String(this.options.labelledBy)):(this.options.label!=null||e)&&t.setAttribute("aria-label",this.options.label??this._message("table.label","Table",[])),e&&this.options.selectable==="multi"&&t.setAttribute("aria-multiselectable","true"),e?this.el.dataset.focus=this._focusMode:delete this.el.dataset.focus}_applyStackedRoles(t){let e=this._gridRole();e?this._table.setAttribute("role",e):t?this._table.setAttribute("role","table"):this._table.removeAttribute("role");for(let i of[this._thead,this._tbody])t?i.setAttribute("role","rowgroup"):i.removeAttribute("role");for(let[i,n]of[["tr","row"],["td",e?"gridcell":"cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(i))t?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(S(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(t=>!this._hiddenColumns.has(t.id))}_isSpanningRow(t){return this._rowKind===null||this._rowKinds===null?!1:zu(t,this._rowKind,this._rowKinds)}_hasSpanningRow(){return Jg(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return Zg(this._visibleColumns().length,{selectable:this.options.selectable,rowReorder:this.options.rowReorder})}_selectableData(){let t=this._visibleData();return this._rowKind===null?t:t.filter(e=>!this._isSpanningRow(e))}_createColumnControls(){let t=l("div",{class:"zx-table__column-list"});this._columnList=t,this._columnStatus=l("div",{class:"zx-table__column-status",role:"status",ariaLive:"polite"});let e=l("details",{class:"zx-table__column-controls"},l("summary",{class:"zx-btn",dataset:{size:"sm"}},g("fields"),this._message("table.columns","Columns",[])),t);return this._renderColumnControls(),e}_renderColumnControls(t=null){if(!this._columnList)return;let e=this._visibleColumns(),i=this._columns.map((n,r)=>{let o=!this._hiddenColumns.has(n.id),a=this._columnControlIds.get(n.id);a||(a=x("zx-table-column"),this._columnControlIds.set(n.id,a));let c=this.options.columnVisibility?l("input",{id:a,class:"zx-table__column-toggle",type:"checkbox",value:n.id,checked:o,disabled:o&&e.length===1,dataset:{columnId:n.id,columnAction:"toggle"}}):null,d=Cn(n),u=c?l("label",{for:a},c,l("span",{},d)):l("span",{class:"zx-table__column-label"},d),h=this.options.columnReorder?l("span",{class:"zx-table__column-order",role:"group",ariaLabel:this._message("table.moveColumn","Move %1",[d])},l("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:`Move ${d} earlier`,dataset:{columnId:n.id,columnAction:"up"}},g("chevron-up",{size:11})),l("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:`Move ${d} later`,dataset:{columnId:n.id,columnAction:"down"}},g("chevron-down",{size:11}))):null;return l("div",{class:"zx-table__column-option",dataset:{columnId:n.id}},u,h)});if(this._columnList.replaceChildren(...i,this._columnStatus),t!==null){let n=[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&o.dataset.columnAction===t.action});n?.disabled&&(n=[...this._columnList.querySelectorAll(".zx-table__column-move[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})??[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})),queueMicrotask(()=>{n?.isConnected&&n.focus()})}}_activeColumnControl(){let t=typeof document>"u"?null:document.activeElement;if(!t||!this._columnList?.contains(t))return null;let e=t.dataset.columnId,i=t.dataset.columnAction;return e&&i?{id:e,action:i}:null}_handleColumnControlClick(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let i=e.dataset.columnId,n=e.dataset.columnAction,r=this.getColumnOrder().indexOf(String(i));n==="up"&&r>0&&this.moveColumn(String(i),this._columns[r-1].id,"before"),n==="down"&&r>=0&&r<this._columns.length-1&&this.moveColumn(String(i),this._columns[r+1].id,"after")}_handleColumnControlKeydown(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let i=String(e.dataset.columnId),n=this.getColumnOrder(),r=n.indexOf(i);r<0||(t.key==="ArrowUp"||t.key==="ArrowLeft"?(t.preventDefault(),r>0&&this.moveColumn(i,n[r-1],"before")):t.key==="ArrowDown"||t.key==="ArrowRight"?(t.preventDefault(),r<n.length-1&&this.moveColumn(i,n[r+1],"after")):t.key==="Home"?(t.preventDefault(),r>0&&this.moveColumn(i,n[0],"before")):t.key==="End"&&(t.preventDefault(),r<n.length-1&&this.moveColumn(i,n.at(-1),"after")))}_handleRowDragStart(t){let e=t.target?.closest?.(".zx-table__row-handle"),i=e?.closest("tr[data-row]"),n=i?this._rowMeta.get(i):null;if(!e||!n||this._sort&&this.options.sortMode==="local"){t.preventDefault();return}this._dragId=n.id,i.dataset.dragging="true",t.dataTransfer?.setData("text/plain","zx-table-row"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleRowDragOver(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),i=e?this._rowMeta.get(e):null;if(!i||Object.is(i.id,this._dragId)||!this._canMoveTogether(this._dragId,i.id))return;t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._clearDropMarkers();let n=e.getBoundingClientRect();e.dataset.drop=t.clientY>=n.top+n.height/2?"after":"before"}_handleRowDrop(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),i=e?this._rowMeta.get(e):null,n=e?.dataset.drop==="after"?"after":"before";i&&this._canMoveTogether(this._dragId,i.id)&&(t.preventDefault(),this.moveRow(this._dragId,i.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(t){let e=t.target?.closest?.(".zx-table__row-handle"),i=e?.closest("tr[data-row]"),n=i?this._rowMeta.get(i):null;if(!e||!n)return;if(t.key===" "||t.key==="Enter"){t.preventDefault(),this._grabbedId=Object.is(this._grabbedId,n.id)?null:n.id,e.setAttribute("aria-pressed",String(this._grabbedId!=null));let c=this._rowMoveMessage??this._editMessage;c&&(c.textContent=this._grabbedId==null?"Row dropped":"Row grabbed. Use the arrow keys to move it.");return}if(t.key==="Escape"&&this._grabbedId!=null){t.preventDefault(),this._grabbedId=null,e.setAttribute("aria-pressed","false");return}if(!Object.is(this._grabbedId,n.id)||!["ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let r=this._siblingIds(n.id),o=r.findIndex(c=>Object.is(c,n.id)),a=r[o+(t.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,t.key==="ArrowUp"?"before":"after")}_siblingIds(t){let e=this.getRow(t);if(!e)return[];let i=this._hierarchy?ft(this._hierarchy.parentId,e):null;return this._data.filter(n=>!this._hierarchy||Ma(ft(this._hierarchy.parentId,n),i)).map(n=>this._idFor(n))}_canMoveTogether(t,e){if(!this._hierarchy)return!0;let i=this.getRow(t),n=this.getRow(e);return!!(i&&n&&Ma(ft(this._hierarchy.parentId,i),ft(this._hierarchy.parentId,n)))}_rowHandle(t){return this._rowElements.get(t)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let t of this._tbody.querySelectorAll("tr[data-drop]"))delete t.dataset.drop}_clearRowDrag(){for(let t of this._tbody.querySelectorAll("tr[data-dragging]"))delete t.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(t=>t.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let t=document.createDocumentFragment();this.options.rowReorder&&t.append(l("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&t.append(l("col",{class:"zx-table__selection-column"}));let e=this._visibleColumns(),i=e.map(r=>bb(r.width)),n=i.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0?"fixed":"auto",e.forEach((r,o)=>{let a=l("col");i[o]>0?a.style.width=`${i[o]/n*100}%`:r.width&&r.width!=="auto"&&(a.style.width=String(r.width)),t.append(a)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=l("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.rowReorder&&t.append(l("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:"Row order"})),this.options.selectable==="multi"){this._selectAll=l("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:this._message("table.selectAll","Select all rows",[])});let e=l("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let i of this._selectableData())this._selected.add(this._idFor(i));else for(let i of this._selectableData())this._selected.delete(this._idFor(i));this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map,this._headerSpanning=this._spanning;for(let e of this._visibleColumns()){let i=l("th",{scope:"col",dataset:{column:e.id}}),n=e.align??(Ea(e)?"end":null);n&&(i.dataset.align=n),e.headerTitle&&(i.title=e.headerTitle);let r=pb(e);if(r!==null&&i.setAttribute("aria-label",r),e.sortable&&!this._spanning){let o=l("button",{class:"zx-table__sort-button",type:"button",ariaLabel:r??void 0},l("span",{class:"zx-table__header-label"},e.label));this.listen(o,"click",()=>{let a=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,a)}),i.append(o)}else i.append(l("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,i),t.append(i)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){let t=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 e=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._rovingEl=null;let i=this._projectedData();this._hierarchyMeta=new Map(i.map(n=>[n.id,n])),this._data.length===0?e.append(l("tr",{class:"zx-table__empty-row"},l("td",{class:"zx-table__empty",colspan:this._spanColspan()},this._emptyContent()))):this._visibleEntries().forEach((n,r)=>{e.append(this._createRow(n.row,n.index,{...n,visibleIndex:r}))}),this._tbody.replaceChildren(e),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(i.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0),this._syncRoving(t)}_emptyContent(){let t=this.options.emptyText;return t==null?this.msg("table.empty"):typeof t=="function"?t():t}_createRow(t,e,i){let n=this._idFor(t),r=l("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(i.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean));let a=this._rowKind===null?null:Au(t,this._rowKind),c=a===null?null:ku(this._rowKinds,a),d=!!c?.span;a!==null&&(r.dataset.rowKind=a),c?.class&&r.classList.add(...String(c.class).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&!d&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(i.depth+1)),i.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._interactive&&(this._focusMode==="row"||this._hierarchy)&&(r.tabIndex=-1),this._rowMeta.set(r,{row:t,id:n,index:e,visibleIndex:i.visibleIndex});let u=this._rowElements.get(n)??[];if(u.push(r),this._rowElements.set(n,u),d){r.dataset.span="true";let h=l("th",{class:"zx-table__section-cell",scope:"colgroup",colspan:this._spanColspan()}),f=tb(t,c,this._visibleColumns(),e);return f&&typeof f=="object"&&typeof f.nodeType=="number"?h.append(f):f!=null&&h.append(document.createTextNode(String(f))),this._focusMode==="cell"&&(h.tabIndex=-1),r.append(h),r}if(this.options.rowReorder){let h=l("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},g("drag",{size:14}));r.append(l("td",{class:"zx-table__reorder-cell"},h))}if(this.options.selectable==="multi"){let h=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",tabIndex:-1,checked:this._selected.has(n)});r.append(l("td",{class:"zx-table__selection-cell"},h))}return this._visibleColumns().forEach(h=>{let f=l("td"),p=h.align??(Ea(h)?"end":null);p&&(f.dataset.align=p),f.dataset.label=h.label,f.dataset.column=h.id,h.popin===!1&&(f.dataset.popin="false"),this._focusMode==="cell"&&(f.tabIndex=-1),this._editMode!==!1&&_i(h,t)!==!1&&(f.dataset.editable="true"),this._renderCellContent(f,h,t,e,i),r.append(f)}),this._rowNames.set(r,Xg([...r.cells].map(h=>h.textContent))),this._labelRowControls(r),r}_labelRowControls(t){let e=this._rowMeta.get(t);if(!e)return;let i=this._rowNames.get(t)??this._message("table.row","row %1",[e.index+1]);t.querySelector(".zx-table__row-checkbox")?.setAttribute("aria-label",this._message("table.selectRow","Select %1",[i])),t.querySelector(".zx-table__row-handle")?.setAttribute("aria-label",this._message("table.moveRow","Move %1",[i]));let r=t.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",[i]):this._message("table.expandRow","Expand %1",[i]))}}_renderCellContent(t,e,i,n,r=this._hierarchyMeta?.get(this._idFor(i))){let o=Da(e,i,n),a=l("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchyColumn()||!r){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let d=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",tabIndex:-1,ariaExpanded:String(d)},g(d?"chevron-down":"chevron-right",{size:14})))}else c.append(l("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(a),t.replaceChildren(c),t.parentElement&&this._labelRowControls(t.parentElement)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&as(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(!n||e.closest(".zx-table__row-handle")||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,t.shiftKey);return}if(!(this._editMode!==!1&&yu(e))){if(this._editMode!==!1&&this._editTrigger==="single"){let a=e?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this._activateRow(n,t)}}_activateRow(t,e){this.emit("rowclick",{...t,event:e}),this.options.selectable==="single"&&!this._selected.has(t.id)&&!this._isSpanningRow(t.row)&&(this._selected=new Set([t.id]),this._selectionAnchorId=t.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&as(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(n&&!(this._editMode!==!1&&yu(e))){if(this._editMode!==!1&&this._editTrigger==="double"){let r=e?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:t})}}_createEditor(t,e,i,n){let r=_i(e,i);if(r===!1)return null;let o=i?.[e.id],a=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=l("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let d=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,d),t.dataset.editing="true";let u={column:e,type:r,td:t,host:d,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){u.custom=o,u.read=()=>Ae(e,u.custom,i);let p={value:o,row:i,column:e,commit:m=>{u.custom=m,this.commitEdit()},cancel:()=>this.cancelEdit()},_=e.editor(i,p);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(u.component=_),d.append(_.toElement())):_&&d.append(_),u.control=d.querySelector(Yg)??d,u}if(r==="number"){let p=ke(e.locale,i),_=Cu(e,i),m=e.type==="currency"?ke(e.currency,i):e.type==="unit"?ke(e.unit,i):null,b={...p!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:p}:{},..._!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:_}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(m)}:{}},w=new Et(null,{...b,...a,value:o??null});return d.append(w.el),u.component=w,u.control=w.getInput(),u.read=()=>(w.set(w.getInput().value,{silent:!0}),Ae(e,w.get(),i)),u}if(r==="select"){let p=sb(e.options,i),_=p.find(b=>Object.is(b.value,o))??p.find(b=>String(b.value)===String(o??"")),m=new $(null,{...a,items:p,valueKey:"value",labelKey:"label",value:_?_.value:null});return d.append(m.el),u.component=m,u.control=m.refs.input,u.read=()=>Ae(e,m.value,i),u}if(r==="date"){let p=new et(null,{...a,value:o??null});d.append(p.el),u.component=p;let _=p.refs.input;return u.control=_,u.read=()=>{let m=String(_.value??"").trim(),b=p.get();return m===""?Ae(e,null,i):(p.set(m,{silent:!0}),p.get()===null&&p.set(b,{silent:!0}),Ae(e,p.get(),i))},u}if(r==="checkbox"){let p=new J(null,{...a,checked:!!o});return d.append(p.el),u.component=p,u.control=p.el,u.read=()=>Ae(e,p.get(),i),u}let h=r==="textarea",f=l(h?"textarea":"input",{...a,class:h?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...h?{}:{type:"text"},ariaLabel:a.ariaLabel??`${Cn(e)} row ${n+1}`,value:nb(e,o,i)});return d.append(f),u.control=f,u.read=()=>Ae(e,f.value,i),u}_focusEditor(t){let e=this._edit?.cells.get(t),i=e?.control;!i||typeof i.focus!="function"||(i.focus(),_b(e.type)&&typeof i.select=="function"&&i.select())}_focusCell(t,e){let i=this._rowElements.get(t)?.[0];(i?vu(i,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(n=>Object.is(this._idFor(n),t.id)),i=e<0?t.row:this._data[e];for(let n of t.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,i,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let i=t&&this._editHasFocus(),n=this.getRow(e.id)??e.row,r=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),i&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:n,id:e.id,column:r,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let i=this._edit?.cells.get(t);i&&(i.td.dataset.invalid="true",i.control?.setAttribute("aria-invalid","true"),this._editMessage&&(i.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&as(e)){if(fb(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let i=e.closest('td[data-editable="true"]');if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i.parentElement);n&&(t.preventDefault(),this.startEdit(n.id,String(i.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let i=t.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),r=this._nextEditableCell(n,e.columnId,i);if(r&&Object.is(r.id,e.id)&&e.cells.has(r.columnId)){t.preventDefault(),e.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(t,e,i){let n=this._visibleColumns(),r=n.length;if(t<0||r===0)return null;let o=this._visibleData(),a=this._idFor(this._data[t]),c=o.findIndex(h=>Object.is(this._idFor(h),a));if(c<0)return null;let d=n.findIndex(h=>h.id===e),u=o.length*r+r;for(let h=0;h<u;h+=1){if(d+=i,d>=r?(c+=1,d=0):d<0&&(c-=1,d=r-1),c<0||c>=o.length)return null;let f=o[c],p=n[d];if(!this._isSpanningRow(f)&&_i(p,f)!==!1)return{id:this._idFor(f),columnId:p.id,index:this._data.indexOf(f)}}return null}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&as(e)||e&&this._tbody.contains(e)||this.commitEdit()}_navRows(){return[...this._tbody.children].filter(t=>t.hasAttribute("data-row"))}_navCells(t){return[...t.cells].filter(e=>e.hasAttribute("data-column")||e.classList.contains("zx-table__section-cell"))}_cellFor(t){let e=this._navCells(t);if(e.length===0)return t;let i=this._current?.columnId;return(i==null?null:e.find(r=>r.dataset.column===i))??e[Math.min(Math.max(this._current?.columnIndex??0,0),e.length-1)]}_rovingTarget(t){return this._focusMode==="row"||this._hierarchy&&this._current?.onRow?t:this._cellFor(t)}_setRoving(t){this._rovingEl&&this._rovingEl!==t&&(this._rovingEl.tabIndex=-1),t.tabIndex=0,this._rovingEl=t}_captureFocus(){let t=typeof document>"u"?null:document.activeElement;if(t&&t===this._scroll&&this._scroll.hasAttribute("data-empty-focus"))return{part:"row"};if(!t||!this._tbody?.contains(t))return null;let e=t.closest("tr[data-row]");return e?t===e?{part:"row"}:t.closest(".zx-table__row-checkbox")?{part:"checkbox"}:t.closest(".zx-table__tree-toggle")?{part:"toggle"}:t.closest(".zx-table__row-handle")?{part:"handle"}:{part:this._focusMode==="cell"?"cell":"row"}:null}_syncRoving(t){if(!this._interactive)return;let e=this._navRows();if(this._syncEmptyFocus(e.length===0&&t!==null),e.length===0)return;let i=this._current?this._rowElements.get(this._current.id)?.[0]:void 0;if(!i&&this._current&&this._hierarchy&&(i=this._renderedAncestor(this._current.id),i)){let a=this._rowMeta.get(i);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex,onRow:!0}}if(!i&&(i=e[Math.min(Math.max(this._current?.visibleIndex??0,0),e.length-1)],this._current)){let a=this._rowMeta.get(i);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex}}let n=this._rovingTarget(i);if(this._setRoving(n),!t)return;let r={checkbox:".zx-table__row-checkbox",toggle:".zx-table__tree-toggle",handle:".zx-table__row-handle:not(:disabled)"}[t.part];(r?i.querySelector(r)??n:n).focus({preventScroll:!0})}_renderedAncestor(t){if(!this._hierarchy)return;let e=new Set,i=this.getRow(t);for(;i;){let n=ft(this._hierarchy.parentId,i);if(n==null||e.has(n))return;e.add(n);let r=this._rowElements.get(n)?.[0];if(r)return r;i=this.getRow(n)}}_syncEmptyFocus(t){let e=this._scroll;t?(e.hasAttribute("tabindex")||(e.tabIndex=-1,e.setAttribute("data-empty-focus","")),e.focus({preventScroll:!0})):e.hasAttribute("data-empty-focus")&&(e.removeAttribute("tabindex"),e.removeAttribute("data-empty-focus"))}_handleFocusIn(t){if(!this._interactive)return;let e=t.target?.nodeType===1?t.target:null,i=e?.closest("tr[data-row]")??null;if(!i||i.parentElement!==this._tbody)return;let n=this._rowMeta.get(i);if(!n)return;let r={id:n.id,visibleIndex:n.visibleIndex,columnId:this._current?.columnId??null,columnIndex:this._current?.columnIndex??0,onRow:!1},o=i;if(this._focusMode==="cell"){let a=this._navCells(i),c=a.find(d=>d===e||d.contains(e))??null;e===i&&this._hierarchy?r.onRow=!0:c?(o=c,c.dataset.column&&(r.columnId=c.dataset.column,r.columnIndex=a.indexOf(c))):(this._current=r,o=this._cellFor(i))}this._current=r,this._setRoving(o)}_handleGridKeydown(t){if(!this._interactive||t.defaultPrevented||t.altKey)return;let e=t.target?.nodeType===1?t.target:null;if(!e||this._edit&&as(e))return;let i=e.closest("tr[data-row]");if(!i||i.parentElement!==this._tbody)return;let n=this._rowMeta.get(i);if(!n)return;let r=this._focusMode==="cell",o=r?this._navCells(i):[],a=e===i,c=o.includes(e),d=e.matches(".zx-table__row-checkbox, .zx-table__tree-toggle");if(!a&&!c&&!d)return;let u=t.key,h=t.ctrlKey||t.metaKey;if(h&&(u==="a"||u==="A")){if(this.options.selectable!=="multi")return;t.preventDefault(),this._selectAllRendered();return}if((u==="Enter"||u===" ")&&!d){if(h)return;t.preventDefault(),u===" "&&this.options.selectable!==!1&&!this._isSpanningRow(n.row)?this._toggleRowSelection(n):this._activateRow(n,t);return}if(this._hierarchy&&(u==="ArrowLeft"||u==="ArrowRight")&&!h){let v=this._hierarchyMeta?.get(n.id);if(!v)return;t.preventDefault();let z=Qg(u,{focus:c?"cell":"row",cells:r,column:c?o.indexOf(e):0,columns:o.length,hasChildren:v.hasChildren,expanded:this._expanded.has(n.id),hasParent:v.parentId!=null});z&&this._applyTreeAction(z,i,n,v.parentId);return}let f=this._navRows(),p=f.indexOf(i),_=r&&!a,m=c?o.indexOf(e):Math.max(0,o.indexOf(this._cellFor(i))),b=Wg({row:p,column:m},u,{rows:f.length,columns:_?o.length:1,page:this._pageSize(f),ctrl:h,cells:_});if(!b)return;t.preventDefault();let w=f[b.row];if(!_)w.focus();else if(b.row===p||u==="Home"||u==="End"){let v=this._navCells(w),z=b.column>=o.length-1&&u!=="Home";v[z?v.length-1:Math.min(b.column,v.length-1)]?.focus()}else this._cellFor(w).focus();t.shiftKey&&this.options.selectable==="multi"&&b.row!==p&&this._extendSelection(n,this._rowMeta.get(w))}_applyTreeAction(t,e,i,n){if(t.action==="expand")this.expandRow(i.id);else if(t.action==="collapse")this.collapseRow(i.id);else if(t.action==="parent")this._rowElements.get(n)?.[0]?.focus();else if(t.action==="child"){let r=this._navRows();r[r.indexOf(e)+1]?.focus()}else t.action==="row"?e.focus():t.action==="cell"&&this._navCells(e)[t.column??0]?.focus()}_pageSize(t){let e=this._scroll;if(!e||!t[0]||e.scrollHeight<=e.clientHeight+1)return 10;let i=this.options.stickyHeader?this._thead.getBoundingClientRect().height:0;return Gg(e.clientHeight-i,t[0].getBoundingClientRect().height)}_toggleRowSelection(t){let e=this._selected.has(t.id);if(this.options.selectable==="multi"){this._toggleMultiSelection(t,!e,!1);return}this._selected=e?new Set:new Set([t.id]),this._selectionAnchorId=t.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_selectAllRendered(){let t=new Set(this._selected);for(let e of this._selectableData())t.add(this._idFor(e));this._extendBase=null,!Ia(t,this._selected)&&(this._selected=t,this._syncSelection(),this._emitSelectionChange())}_extendSelection(t,e){if(!e)return;let i=this._visibleData(),n=c=>i.findIndex(d=>Object.is(this._idFor(d),c));this._extendBase===null&&(this._extendBase=new Set(this._selected),n(this._selectionAnchorId)<0&&(this._selectionAnchorId=t.id));let r=n(this._selectionAnchorId),o=n(e.id);if(r<0||o<0)return;let a=new Set(this._extendBase);for(let c=Math.min(r,o);c<=Math.max(r,o);c+=1)this._isSpanningRow(i[c])||a.add(this._idFor(i[c]));Ia(a,this._selected)||(this._selected=a,this._syncSelection(),this._emitSelectionChange())}_msgOr(t,e){let i=this.msg(t);return i===t?e:i}_toggleMultiSelection(t,e,i){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(i&&r>=0){let o=t.visibleIndex??n.findIndex(d=>Object.is(this._idFor(d),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let d=a;d<=c;d+=1){if(this._isSpanningRow(n[d]))continue;let u=this._idFor(n[d]);e?this._selected.add(u):this._selected.delete(u)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let i=this._selected.has(t);for(let n of e){if(n.hasAttribute("data-span"))continue;n.setAttribute("aria-selected",String(i));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=i)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._selectableData(),e=t.reduce((i,n)=>i+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)!this._spanning&&this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(this._spanning=this._hasSpanningRow(),!this._sort||this._spanning)return;let t=this._columns.find(i=>i.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:i=>i?.[t.id];this._data=this._hierarchy?ib(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):os(this._data,e,this._sort.dir)}_setRowExpanded(t,e,i){return this._hierarchy?An(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,t))?this._expanded.has(t)===e?this:(e?this._expanded.add(t):this._expanded.delete(t),this._renderBody(),i.silent||this._emitRowToggle(t,e),this):this:this}_emitRowToggle(t,e){let i=this.getRow(t);i&&this.emit("rowtoggle",{row:i,id:t,expanded:e})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let t=An(this._data,this.options.rowId,this._hierarchy.parentId),e=new Set(t);for(let i of this._expanded)e.has(i)||this._expanded.delete(i)}_selectableIds(){let t=new Set;for(let e of this._data)this._isSpanningRow(e)||t.add(this._idFor(e));return t}_pruneSelection(){let t=this._selectableIds(),e=this._selected.size;for(let i of this._selected)t.has(i)||this._selected.delete(i);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),this._extendBase=null,e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function Wg(s,t,e){let i=Math.trunc(Number(e?.rows)||0);if(i<=0)return null;let n=Math.max(1,Math.trunc(Number(e?.columns)||1)),r=Math.max(1,Math.trunc(Number(e?.page)||10)),o=(h,f)=>Math.min(Math.max(Math.trunc(Number(h)||0),0),f),a=o(s?.row,i-1),c=o(s?.column,n-1),d=!!e?.cells,u=!!e?.ctrl;switch(t){case"ArrowUp":return{row:Math.max(0,a-1),column:c};case"ArrowDown":return{row:Math.min(i-1,a+1),column:c};case"PageUp":return{row:Math.max(0,a-r),column:c};case"PageDown":return{row:Math.min(i-1,a+r),column:c};case"ArrowLeft":return d?{row:a,column:Math.max(0,c-1)}:null;case"ArrowRight":return d?{row:a,column:Math.min(n-1,c+1)}:null;case"Home":return d?u?{row:0,column:0}:{row:a,column:0}:{row:0,column:c};case"End":return d?u?{row:i-1,column:n-1}:{row:a,column:n-1}:{row:i-1,column:c};default:return null}}function Gg(s,t,e=10){let i=Number(s),n=Number(t);return!(i>0)||!(n>0)?Math.max(1,Math.trunc(e)||10):Math.max(1,Math.floor(i/n)-1)}function Qg(s,t){let e=s==="ArrowRight";if(!e&&s!=="ArrowLeft")return null;if(t?.focus==="cell"){let r=Math.max(0,Math.trunc(Number(t.column)||0)),o=Math.max(1,Math.trunc(Number(t.columns)||1));return e?r<o-1?{action:"cell",column:r+1}:null:r>0?{action:"cell",column:r-1}:{action:"row"}}let i=!!t?.hasChildren,n=i&&!!t?.expanded;return e?i&&!n?{action:"expand"}:t?.cells?{action:"cell",column:0}:n?{action:"child"}:null:n?{action:"collapse"}:t?.hasParent?{action:"parent"}:null}function Xg(s,t=80){for(let e of Array.isArray(s)?s:[]){let i=String(e??"").replace(/\s+/g," ").trim();if(i)return i.length>t?`${i.slice(0,Math.max(1,t-1)).trimEnd()}\u2026`:i}return null}function Au(s,t){if(t==null||t==="")return null;let e=typeof t=="function"?t(s):s?.[t];return e==null?null:String(e)}function ku(s,t){if(t===null||s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,t))return null;let e=s[t];return e&&typeof e=="object"?e:null}function zu(s,t,e){return!!ku(e,Au(s,t))?.span}function Jg(s,t,e){return!Array.isArray(s)||t==null||e==null?!1:s.some(i=>zu(i,t,e))}function Zg(s,t={}){let e=Number.isFinite(Number(s))?Math.max(0,Math.trunc(Number(s))):0,i=(t.selectable==="multi"?1:0)+(t.rowReorder?1:0);return Math.max(1,e+i)}function tb(s,t,e,i=0){if(typeof t?.render=="function")return t.render(s,i);let n=e?.[0];return n?s?.[n.id]:null}function Da(s,t,e=0){if(typeof s?.render=="function")return s.render(t,e);let i=t?.[s?.id],n=s?.type??"text";if(n==="text")return i;let r=ke(s.locale,t),o=Cu(s,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return Nt(i,a);if(n==="currency"){let c=ke(s.currency,t);return oi(i,c==null?null:String(c),a)}if(n==="percent")return ai(i,a);if(n==="unit"){let c=Nt(i,a),d=ke(s.unit,t);return c&&d!=null&&String(d)!==""?`${c}\xA0${d}`:c}return i}function eb(s,t,e,i=[]){let n=Tn(s,t,e),r=i instanceof Set?i:new Set(i),o=[],a=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:d}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:d,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let u=c.children.length-1;u>=0;u-=1)a.push({node:c.children[u],depth:d+1})}return o}function ib(s,t,e,i,n){let r=Tn(s,t,e),o=d=>os(d,u=>i(u.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let d=c.pop();a.push(d.row);let u=o(d.children);for(let h=u.length-1;h>=0;h-=1)c.push(u[h])}return a}function Na(s,t,e,i,n="before",r=null){if(!Array.isArray(s)||Object.is(e,i))return null;let o=s.findIndex(h=>Object.is(ft(t,h),e)),a=s.findIndex(h=>Object.is(ft(t,h),i));if(o<0||a<0||r&&!Ma(ft(r,s[o]),ft(r,s[a])))return null;if(r){let h=Tn(s,t,r),f=h.nodes[o],p=h.nodes[a];if(!f||!p||f.parent!==p.parent)return null;let _=k=>{let M=[],it=[k];for(;it.length;){let F=it.pop();M.push(F);for(let st=F.children.length-1;st>=0;st-=1)it.push(F.children[st])}return M},m=new Set(_(f).map(k=>k.index)),b=new Set(_(p).map(k=>k.index)),w=s.filter((k,M)=>m.has(M)),v=s.filter((k,M)=>!m.has(M)),z=s.map((k,M)=>M).filter(k=>!m.has(k)),C=z.findIndex(k=>k===a);if(n==="after"){let k=z.map((M,it)=>b.has(M)?it:-1).filter(M=>M>=0);C=Math.max(...k)+1}return C<0?null:(v.splice(C,0,...w),v)}let c=[...s],[d]=c.splice(o,1),u=c.findIndex(h=>Object.is(ft(t,h),i));return c.splice(u+(n==="after"?1:0),0,d),c}function _i(s,t){if(!s||typeof s!="object")return!1;if(typeof s.editor=="function")return typeof s.editable=="function"&&s.editable(t)===!1?!1:"custom";let e=typeof s.editable=="function"?s.editable(t):s.editable;return e===!0?Ea(s)?"number":"text":typeof e=="string"&&Ug.has(e)?e:!1}function sb(s,t){let e=typeof s=="function"?s(t):s;return Array.isArray(e)?e.map(i=>i!==null&&typeof i=="object"?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([i,n])=>({value:i,label:String(n??"")})):[]}function nb(s,t,e){if(typeof s?.format=="function"){let i=s.format(t,e);return i==null?"":String(i)}return t==null?"":String(t)}function Ae(s,t,e){return typeof s?.parse=="function"?s.parse(t,e):t}function rb(s,t){return Object.is(s,t)?!0:s instanceof Date&&t instanceof Date?s.getTime()===t.getTime():!1}function ob(s,t){let e={};for(let[i,n]of Object.entries(t??{}))rb(s?.[i],n)||(e[i]=n);return e}function ab(s,t,e,i="Invalid value"){for(let n of t??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(s??{},n.id))continue;let r=n.validate(s[n.id],e);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:i}}return null}function ke(s,t){return typeof s=="function"?s(t):s}function Cu(s,t){let e=ke(s?.decimals,t);if(e==null)return null;let i=Number(e);return Number.isFinite(i)?Math.max(0,Math.trunc(i)):null}function Ea(s){return["number","currency","percent","unit"].includes(s?.type)}function Tn(s,t,e){let i=(Array.isArray(s)?s:[]).map((a,c)=>({row:a,id:ft(t,a),index:c,parent:null,children:[]})),n=new Map;for(let a of i)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of i){let c=ft(e,a.row),d=c==null?null:n.get(c)??null;r.set(a,d===a?null:d)}for(let a of i){let c=new Set([a]),d=r.get(a)??null;for(;d;){if(c.has(d)){r.set(d,null);break}c.add(d),d=r.get(d)??null}}let o=[];for(let a of i)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:i}}function An(s,t,e){return Tn(s,t,e).nodes.filter(i=>i.children.length>0).map(i=>i.id)}function ft(s,t){return typeof s=="function"?s(t):t?.[s]}function Ma(s,t){return s==null&&t==null||Object.is(s,t)}function kn(s,t){if(!s||typeof s!="object")return null;let e=s.parentId;if(typeof e!="string"&&typeof e!="function")return null;let i=typeof s.column=="string"?s.column:null,n=t.some(r=>r.id===i)?i:t[0]?.id;return n?{...s,parentId:e,column:n}:null}function lb(s){return typeof s=="function"||typeof s=="string"&&s!==""?s:null}function cb(s){return!s||typeof s!="object"||Array.isArray(s)?null:s}function db(s){return new Set(Array.isArray(s)?s:[])}function ub(s){return s==="plain"?"plain":"default"}function hb(s){return s==="cell"||s==="row"?s:s===!0?"cell":!1}function as(s){return!!s?.closest?.(".zx-table__editor")}function yu(s){let t=s?.closest?.("td[data-column]"),e=s?.closest?.(["a[href]","button","input","select","textarea","summary",'[contenteditable="true"]','[role="button"]','[role="link"]','[tabindex]:not([tabindex="-1"])',"[data-zx-table-no-edit]"].join(","));return!!(t&&e&&e!==t&&t.contains(e))}function fb(s){return s.closest("[popover]")?!0:s.getAttribute?.("aria-expanded")==="true"}function wu(s){if(!Array.isArray(s))throw new TypeError("Table columns must be an array");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Table column at index ${i} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Table column at index ${i} requires an id`);if(t.has(n))throw new TypeError(`Duplicate table column: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??n)}})}function Cn(s){for(let t of[s?.ariaLabel,s?.label]){let e=t==null?"":String(t).trim();if(e)return e}return String(s?.id??"")}function pb(s){let t=s?.label==null?"":String(s.label).trim(),e=s?.ariaLabel==null?"":String(s.ariaLabel).trim();return e||(t?null:Cn(s)||null)}function _b(s){return s==="text"||s==="number"||s==="date"}function mb(s,t){let e=s.map(a=>a.id),i=new Set(e),n=Array.isArray(t)?t.map(String):[],r=new Set,o=[];for(let a of n)i.has(a)&&!r.has(a)&&(r.add(a),o.push(a));for(let a of e)r.has(a)||o.push(a);return o}function gb(s,t,e,i="before"){let n=[...s],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(i==="after"?1:0);return n.splice(a,0,t),n}function vu(s,t){for(let e of s.cells)if(e.dataset.column===t)return e;return null}function xu(s,t){return!s||typeof s!="object"||!t.some(e=>e.id===s.id)?null:{id:s.id,dir:s.dir==="desc"?"desc":"asc"}}function bb(s){if(typeof s!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(s.trim());return t?Math.max(0,Number(t[1])):0}function Su(s){if(!Array.isArray(s))throw new TypeError("Table data must be an array")}function Ia(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function zn(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function yb(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:null}var xt=Symbol("invalid attribute");function mi(s,t="string",e=console.warn){if(Tu(t),t==="boolean")return s!==null;if(s!==null){if(t==="string")return s;if(t==="number"){let i=Number(s);return Number.isFinite(i)?i:(e(`Ignoring invalid number attribute: ${JSON.stringify(s)}`),xt)}try{return JSON.parse(s)}catch{return e(`Ignoring invalid JSON attribute: ${JSON.stringify(s)}`),xt}}}function Oa(s,t="string",e=console.warn){if(Tu(t),t==="boolean")return s?"":null;if(s==null)return null;if(t==="number"){let i=Number(s);return Number.isFinite(i)?String(i):(e(`Ignoring invalid number property: ${String(s)}`),xt)}if(t==="json"){try{let i=JSON.stringify(s);if(i!==void 0)return i}catch{}return e("Ignoring property that cannot be serialized as JSON"),xt}return String(s)}function Tu(s){if(!["string","number","boolean","json"].includes(String(s)))throw new TypeError(`Unknown reflected attribute type: ${String(s)}`)}var wb=Object.freeze(["change","input","submit","clear","open","close","cancel","invalid","query","loaded","rowclick","rowdblclick","sort","selectionchange","datachange"]),vb=St({checked:H({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:O({default:!0}),label:O({default:null,rebuild:!0}),disabled:H({always:!0,set:ls})}),xb=St({checked:H({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:O({option:null,default:"on"}),label:O({default:"",set:(s,t)=>s.setLabel(t)}),icon:H({rebuild:!0}),disabled:H({always:!0,set:ls})}),Sb=St({items:$t({default:[],set:(s,t)=>s.setItems(t)}),value:O({default:null,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.value}),"value-key":O({property:"valueKey",default:"ID",rebuild:!0}),"label-key":O({property:"labelKey",default:"name",rebuild:!0}),placeholder:O({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:H({default:!1,rebuild:!0}),filter:O({default:!1,normalize:Lb,rebuild:!0}),"search-keys":$t({property:"searchKeys",default:null,rebuild:!0}),"min-query":gi({property:"minQuery",default:0,rebuild:!0}),debounce:gi({default:200,rebuild:!0}),"list-height":gi({property:"listHeight",default:280,rebuild:!0}),disabled:H({always:!0,set:ls}),required:H({option:null,always:!0}),name:O({option:null,default:""})}),Ab=St({items:$t({default:[],set:(s,t)=>s.setItems(t)}),value:$t({option:null,default:[],set:(s,t)=>s.setValues(t),get:s=>s.getValues()}),"value-key":O({property:"valueKey",default:"ID",rebuild:!0}),"label-key":O({property:"labelKey",default:"name",rebuild:!0}),"checked-key":O({property:"checkedKey",default:"on",rebuild:!0}),search:H({rebuild:!0}),height:gi({default:280,rebuild:!0}),"default-checked":H({property:"defaultChecked",default:!1,rebuild:!0}),disabled:H({option:null,always:!0,set:Fb}),name:O({option:null,default:""})}),kb=St({format:O({default:"%d.%m.%Y",rebuild:!0}),time:H({always:!0,rebuild:!0}),value:O({option:null,default:null,normalize:Vb,set:(s,t)=>s.set(t,{silent:!0}),get:(s,t)=>La(s.get(),!!t.time),serialize:jb}),placeholder:O({default:null,rebuild:!0}),clearable:H({rebuild:!0}),disabled:H({always:!0,set:ls}),required:H({option:null,always:!0}),name:O({option:null,default:""})}),zb=St({value:gi({default:0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),unit:O({default:"minutes",rebuild:!0}),seconds:H({always:!0,rebuild:!0}),signed:H({always:!0,rebuild:!0}),disabled:H({always:!0,set:ls}),name:O({option:null,default:""})}),Cb=St({value:O({default:"",set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),placeholder:O({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:H({rebuild:!0}),debounce:gi({default:250,rebuild:!0})}),Tb=St({title:O({default:"",set:(s,t)=>s.setTitle(t)}),open:H({default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),Ib=St({tabs:$t({default:[],normalize:Pb,rebuild:!0}),active:O({default:null,set:(s,t)=>{t!==null&&s.openTab(t)},get:s=>s.getActive()}),variant:O({default:"divided",rebuild:!0}),"keep-alive":H({property:"keepAlive",rebuild:!0})}),Eb=St({columns:$t({default:[],rebuild:!0}),data:$t({default:[],set:(s,t)=>s.setData(t),get:s=>s.getData()}),"row-id":O({property:"rowId",default:"ID",rebuild:!0}),sort:$t({default:null,rebuild:!0}),"sort-mode":O({property:"sortMode",default:"local",rebuild:!0}),selectable:O({default:!1,normalize:Rb,rebuild:!0}),"sticky-header":H({property:"stickyHeader",rebuild:!0}),height:O({default:null,normalize:Du,rebuild:!0}),"empty-text":O({property:"emptyText",default:null,rebuild:!0}),zebra:H({rebuild:!0})}),Mb=St({title:O({default:"",set:(s,t)=>s.setTitle(t)}),size:O({default:"md",normalize:Du,rebuild:!0}),buttons:$t({default:[],set:(s,t)=>s.setButtons(t)}),closable:H({rebuild:!0}),open:H({option:null,default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),Db=Object.freeze([["toggle",J,{formAssociated:!0,attrs:vb}],["check-button",Ht,{formAssociated:!0,attrs:xb}],["select",$,{formAssociated:!0,attrs:Sb}],["checklist",lt,{formAssociated:!0,attrs:Ab}],["datebox",et,{formAssociated:!0,attrs:kb}],["timebox",Dt,{formAssociated:!0,attrs:zb}],["search",Ot,{formAssociated:!1,attrs:Cb}],["groupbox",ce,{formAssociated:!1,attrs:Tb}],["tabbox",pi,{formAssociated:!1,attrs:Ib}],["table",Ft,{formAssociated:!1,attrs:Eb}],["dialog",qt,{formAssociated:!1,attrs:Mb}]]);function Nb(s,{formAssociated:t=!1,attrs:e={}}={}){let i=Mu(e),n=Object.freeze(Object.keys(i)),r=s===ce||s===qt;class o extends HTMLElement{static formAssociated=!!t;static get observedAttributes(){return n}constructor(){super(),this._component=null,this._bridgeAbort=null,this._reflecting=new Set,this._propertyValues=new Map,this._defaults=null,this._contentNodes=null,this._disabledByForm=!1,this._applying=!1,this._internals=t&&typeof this.attachInternals=="function"?this.attachInternals():null}connectedCallback(){this._component||(this._upgradeProperties(i),r&&this._contentNodes===null&&(this._contentNodes=Array.from(this.childNodes)),t&&this._defaults===null&&this._captureDefaults(i),this._createComponent(s,i,r))}disconnectedCallback(){this._destroyComponent()}attributeChangedCallback(c,d,u){if(this._reflecting.has(c))return;let h=i[c];if(!h)return;let f=mi(u,h.type);if(f===xt)return;this._propertyValues.delete(h.property);let p=f===void 0?In(h.default):f;this._applyValue(c,h,p)}formDisabledCallback(c){this._disabledByForm=!!c,this._syncEffectiveDisabled(i),this._syncFormState(s)}formResetCallback(){if(!this._defaults)return;let c=Fa(s);!c||!this._defaults.has(c)||this._applyControlValue(i,c,In(this._defaults.get(c)))}formStateRestoreCallback(c,d){if(typeof c!="string")return;let u=qb(s,c);if(u===xt)return;let h=Fa(s);h&&this._applyControlValue(i,h,u)}get component(){return this._component}get form(){return this._internals?.form??null}get labels(){return this._internals?.labels??null}get validity(){return this._internals?.validity??null}get validationMessage(){return this._internals?.validationMessage??""}get willValidate(){return this._internals?.willValidate??!1}checkValidity(){return this._internals?.checkValidity()??!0}reportValidity(){return this._internals?.reportValidity()??!0}_upgradeProperties(c){for(let d of Object.values(c)){let u=d.property;if(!Object.prototype.hasOwnProperty.call(this,u))continue;let h=this[u];delete this[u],this[u]=h}}_captureDefaults(c){this._defaults=new Map;let d=Fa(s);if(d){let u=Object.values(c).find(h=>h.property===d);u&&this._defaults.set(d,In(this._readProperty(u)))}}_createComponent(c,d,u){let h={};for(let[_,m]of Object.entries(d)){if(!(this._propertyValues.has(m.property)||this.hasAttribute(_)||m.always)||m.option===null)continue;let w=this._currentValue(_,m);w===xt||w===void 0||(h[m.option]=Iu(m,w,this))}let f=null;u&&(f=document.createDocumentFragment(),f.append(...this._contentNodes),h.content=f);let p=new c(null,h);this._component=p,s===ce&&f&&p.setContent(f),this.append(p.el),this._bridgeEvents(p,s);for(let[_,m]of Object.entries(d)){if(m.option!==null||!m.set||!(this._propertyValues.has(m.property)||this.hasAttribute(_)||m.always))continue;let w=this._currentValue(_,m);w!==xt&&w!==void 0&&this._applyValue(_,m,w,!0)}this._syncEffectiveDisabled(d),this._syncFormState(s)}_bridgeEvents(c,d){this._bridgeAbort?.abort(),this._bridgeAbort=new AbortController;for(let u of wb)c.on(u,h=>{if(this._applying)return;this._syncFormState(d);let f=new CustomEvent(`zx-${u}`,{detail:h.detail??{},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(f),f.defaultPrevented&&h.preventDefault()}),c.el.addEventListener(`zx-${u}`,h=>h.stopPropagation(),{signal:this._bridgeAbort.signal})}_destroyComponent(){this._bridgeAbort?.abort(),this._bridgeAbort=null,this._component&&(this._component.destroy(),this._component=null)}_rebuildComponent(c,d=r){this._component&&(d&&this._contentNodes&&document.createDocumentFragment().append(...this._contentNodes),this._destroyComponent(),this._createComponent(s,c,d))}_applyValue(c,d,u,h=!1){if(this._component){if(d.rebuild&&!h){this._rebuildComponent(i);return}if(!d.set){this._syncFormState(s);return}this._applying=!0;try{d.set(this._component,Iu(d,u,this),this)}finally{this._applying=!1}c!=="disabled"&&this._syncEffectiveDisabled(i),this._syncFormState(s)}}_syncEffectiveDisabled(c){if(!(!this._component||!c.disabled?.set)){this._applying=!0;try{c.disabled.set(this._component,this.hasAttribute("disabled")||this._disabledByForm,this)}finally{this._applying=!1}}}_syncFormState(c){if(!this._internals||!this._component)return;let{formValue:d,state:u,empty:h}=Hb(c,this._component,this);if(this._internals.setFormValue(d,u),(c===$||c===et)&&this.hasAttribute("required")&&h){let f=c===et?"Please enter a date.":"Please select a value.";this._internals.setValidity({valueMissing:!0},f,this._component.refs.input)}else this._internals.setValidity({})}_applyControlValue(c,d,u){let h=Object.entries(c).find(([,f])=>f.property===d);h&&this._applyValue(h[0],h[1],u)}_currentValue(c,d){if(this._propertyValues.has(d.property))return this._propertyValues.get(d.property);let u=mi(this.getAttribute(c),d.type);return u===void 0?d.default:u}_readProperty(c){if(this._component&&c.get)return c.get(this._component,this);if(this._propertyValues.has(c.property))return this._propertyValues.get(c.property);let d=mi(this.getAttribute(c.attribute),c.type);return d===xt||d===void 0?In(c.default):d}_writeProperty(c,d){this._propertyValues.set(c.property,d);let u=c.serialize?c.serialize(d,this):Oa(d,c.type);if(u!==xt){this._reflecting.add(c.attribute);try{u===null?this.removeAttribute(c.attribute):this.setAttribute(c.attribute,u)}finally{this._reflecting.delete(c.attribute)}}this._applyValue(c.attribute,c,d)}}for(let a of Object.values(i))Object.prototype.hasOwnProperty.call(o.prototype,a.property)||Object.defineProperty(o.prototype,a.property,{configurable:!0,enumerable:!0,get(){return this._readProperty(a)},set(c){this._writeProperty(a,c)}});return o}function Eu(s="zx"){if(typeof customElements>"u")throw new Error("Custom elements are not available in this environment");let t=String(s).trim();for(let[e,i,n]of Db){let r=`${t}-${e}`;customElements.get(r)||customElements.define(r,Nb(i,n))}}function Mu(s){let t={};for(let[e,i]of Object.entries(s)){let n=typeof i=="string"?{type:i}:{...i},r=n.property??Ob(e);t[e]=Object.freeze({type:n.type??"string",option:Object.prototype.hasOwnProperty.call(n,"option")?n.option:r,property:r,default:n.default,always:!!n.always,rebuild:!!n.rebuild,normalize:n.normalize,serialize:n.serialize,set:n.set,get:n.get,attribute:e})}return Object.freeze(t)}function St(s){return Mu(s)}function O(s={}){return{type:"string",...s}}function gi(s={}){return{type:"number",...s}}function H(s={}){return{type:"boolean",default:!1,always:!0,...s}}function $t(s={}){return{type:"json",...s}}function Ob(s){return s.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Iu(s,t,e){return s.normalize?s.normalize(t,e):t}function ls(s,t){t?s.disable():s.enable()}function Fb(s,t){s.el.setAttribute("aria-disabled",String(t)),s.refs.search&&(s.refs.search.disabled=t);for(let e of s.refs.list?.querySelectorAll("input")??[])e.disabled=t}function Lb(s){return s===""||s==="true"?"local":s==="false"?!1:s}function Rb(s){return s===""||s==="true"?"single":s==="false"?!1:s}function Du(s){if(typeof s!="string"||s.trim()==="")return s;let t=Number(s);return Number.isFinite(t)?t:s}function Pb(s){return Array.isArray(s)?s.map(t=>!t||typeof t!="object"||Bb(t.content)||typeof t.content=="function"?t:{...t,content:document.createTextNode(String(t.content??""))}):s}function Bb(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Vb(s){return typeof s!="string"?s:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(s)?tt(s,"%Y-%m-%dT%H:%M"):/^\d{4}-\d{2}-\d{2}$/.test(s)?tt(s,"%Y-%m-%d"):s}function jb(s,t){return s instanceof Date?La(s,!!t.time):Oa(s,"string")}function La(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":N(s,t?"%Y-%m-%dT%H:%M":"%Y-%m-%d")}function Fa(s){return s===J||s===Ht?"checked":[$,lt,et,Dt].includes(s)?"value":null}function Hb(s,t,e){if(s===J||s===Ht){let n=t.get(),r=s===J?!0:"on";return e._propertyValues.has("value")?r=e._propertyValues.get("value"):e.hasAttribute("value")&&(r=e.getAttribute("value")),{formValue:n?String(r):null,state:String(n),empty:!n}}if(s===$){let n=t.value;return{formValue:n===null?null:String(n),state:JSON.stringify(n),empty:n===null||n===""}}if(s===lt){let n=JSON.stringify(t.getValues());return{formValue:n,state:n,empty:n==="[]"}}if(s===et){let n=La(t.get(),!!e.time);return{formValue:n||null,state:n,empty:n===""}}let i=String(t.get());return{formValue:i,state:i,empty:!1}}function qb(s,t){return s===J||s===Ht?t==="true":s===$||s===lt?mi(t,"json"):s===Dt?mi(t,"number"):t}function In(s){return Array.isArray(s)?s.slice():s instanceof Date?new Date(s.getTime()):s}var $b=Object.freeze({md:40,sm:28}),Kb=Object.freeze({icon:"folder-open",title:"",description:"",actions:[],size:"md",align:"center"});function Nu(s={}){let t={...Kb,...s},e=Yb(t.size),i=l("div",{class:"zx-empty-state",dataset:{size:e,align:Wb(t.align)}});t.icon&&i.append(l("div",{class:"zx-empty-state__icon",ariaHidden:"true"},g(t.icon,{size:$b[e]}))),t.title&&i.append(l("p",{class:"zx-empty-state__title"},String(t.title))),t.description&&i.append(l("p",{class:"zx-empty-state__description"},String(t.description)));let n=Ub(t.actions);return n.length>0&&i.append(l("div",{class:"zx-empty-state__actions"},n)),i}function Ub(s){if(!Array.isArray(s))throw new TypeError("emptyState actions must be an array");return s.map(t=>{if(E(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("emptyState actions must be Elements or button descriptors");return j(t)})}function Yb(s){return s==="sm"?"sm":"md"}function Wb(s){return s==="start"?"start":"center"}var bi=class extends y{static cssName="progress-bar";static defaults={value:0,max:100,label:"",helperText:"",status:"active",indeterminate:!1,size:"md",hideLabel:!1,showValue:!0,formatValue:null};render(){this._value=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Number(this.options.max)||100),this._status=Ou(this.options.status),this._indeterminate=!!this.options.indeterminate,this._labelId=x("zx-progress-label");let e=l("div",{ref:"head",class:"zx-progress-bar__head"},l("span",{ref:"label",class:"zx-progress-bar__label",id:this._labelId},String(this.options.label??"")),l("span",{ref:"value",class:"zx-progress-bar__value"})),i=l("div",{ref:"track",class:"zx-progress-bar__track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(this._max),ariaLabelledby:this._labelId},l("div",{ref:"fill",class:"zx-progress-bar__fill"}));return t.replaceChildren(e,i,l("p",{ref:"helper",class:"zx-progress-bar__helper"},String(this.options.helperText??""))),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.set(this.options.value,{silent:!0}),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=Number(t),n=q(Number.isFinite(i)?i:0,0,this._max),r=n!==this._value,o=r&&n>=this._max;return this._value=n,this._sync(),!e&&r&&this.emit("change",{value:n,percent:this.percent()}),!e&&o&&this.emit("complete",{value:n}),this}percent(){return this._value/this._max*100}setMax(t){return this._max=Math.max(1,Number(t)||1),this.refs.track.setAttribute("aria-valuemax",String(this._max)),this.set(this._value,{silent:!0})}setStatus(t,e){return this._status=Ou(t),e!==void 0&&this.setHelperText(e),this._sync(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}setHelperText(t){return this.refs.helper.textContent=String(t??""),this}setIndeterminate(t=!0){return this._indeterminate=!!t,this._sync(),this}_sync(){let{track:t,fill:e,value:i}=this.refs;if(this.el.dataset.status=this._status,this.el.toggleAttribute("data-indeterminate",this._indeterminate),this._indeterminate){t.removeAttribute("aria-valuenow"),t.removeAttribute("aria-valuetext"),e.style.removeProperty("--zx-progress-fill"),i.textContent="";return}let n=this._format();t.setAttribute("aria-valuenow",String(this._value)),t.setAttribute("aria-valuetext",n),e.style.setProperty("--zx-progress-fill",`${this.percent()}%`),i.replaceChildren(...this._readout(n))}_format(){let t=this.options.formatValue;return typeof t=="function"?String(t(this._value,this._max)):`${Math.round(this.percent())}%`}_readout(t){if(!this.options.showValue)return[];let e=[];return this._status!=="active"&&e.push(g(this._status==="success"?"success":"error",{size:14})),e.push(l("span",{class:"zx-progress-bar__percent"},t)),e}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function Ou(s){return s==="success"||s==="error"?s:"active"}var Gb=new Set(["inactive","active","success","error"]),En=class extends y{static cssName="inline-loading";static defaults={status:"active",description:"",size:"sm",live:!0};render(){this._status="inactive",this._description="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("span");return this.el=t,t.replaceChildren(l("span",{ref:"indicator",class:"zx-inline-loading__indicator"}),l("span",{ref:"description",class:"zx-inline-loading__description"})),t.dataset.size=this.options.size==="md"?"md":"sm",this.options.live!==!1&&(t.setAttribute("role","status"),t.setAttribute("aria-live","polite")),this.set(this.options.status,this.options.description,{silent:!0}),t}get(){return this._status}getDescription(){return this._description}set(t,e,{silent:i=!1}={}){let n=Gb.has(t)?t:"inactive";e!==void 0&&(this._description=String(e??""));let r=n!==this._status;return this._status=n,this._sync(),r&&!i&&this.emit("statuschange",{status:this._status,description:this._description}),this}setDescription(t){return this._description=String(t??""),this.refs.description.textContent=this._description,this}_sync(){this.el.dataset.status=this._status,this.refs.description.textContent=this._description,this.refs.indicator.replaceChildren(...this._indicator())}_indicator(){let t=this.el.dataset.size==="md"?18:16;return this._status==="active"?[fi({size:"sm",kind:"current"})]:this._status==="success"?[g("success",{size:t})]:this._status==="error"?[g("error",{size:t})]:[]}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function ot(s={}){let t={width:"100%",height:"1rem",radius:"sm",...s};return l("span",{class:"zx-skeleton",ariaHidden:"true",dataset:{radius:Qb.has(t.radius)?t.radius:"sm"},style:{"inline-size":Ra(t.width),"block-size":Ra(t.height)}})}function yi(s={}){let t={lines:3,width:"100%",heading:!1,lastLineWidth:"60%",...s},e=q(Math.trunc(Number(t.lines)||0),1,20),i=l("div",{class:"zx-skeleton-text",ariaHidden:"true",style:{"inline-size":Ra(t.width)}});for(let n=0;n<e;n+=1){let r=t.heading&&n===0,o=n===e-1&&e>1;i.append(ot({width:o?t.lastLineWidth:"100%",height:r?"1.5rem":"0.75rem"}))}return i}function Lu(s={}){let t={rows:5,columns:4,header:!0,...s},e=q(Math.trunc(Number(t.rows)||0),1,50),i=q(Math.trunc(Number(t.columns)||0),1,20),n=l("div",{class:"zx-skeleton-table",ariaHidden:"true",style:{"--zx-skeleton-columns":String(i)}});t.header!==!1&&n.append(Fu(i,"header"));for(let r=0;r<e;r+=1)n.append(Fu(i,"body"));return n}var Qb=new Set(["sm","md","full"]);function Fu(s,t){let e=l("div",{class:"zx-skeleton-table__row",dataset:{kind:t}});for(let i=0;i<s;i+=1)e.append(l("span",{class:"zx-skeleton-table__cell"},ot({width:Xb(i,s),height:"0.75rem"})));return e}function Xb(s,t){return s===t-1?"55%":s%2===0?"80%":"65%"}function Ra(s){return typeof s=="number"?`${s}px`:String(s??"")}function Ru(s={},...t){return l("div",{class:["zx-stack",s.class??""],dataset:{direction:s.direction==="row"?"row":null,align:Vu.has(s.align)?s.align:null,justify:Jb.has(s.justify)?s.justify:null,wrap:s.wrap?"true":null,inline:s.inline?"true":null},style:ju("--zx-stack-gap",s.gap)},t)}function Pu(s={},...t){let e=Number(s.columns),i={...ju("--zx-grid-gap",s.gap),"--zx-grid-min":ty(s.min??"16rem")};return Number.isFinite(e)&&e>=1&&(i["--zx-grid-columns"]=String(Math.trunc(e))),l("div",{class:["zx-grid",s.class??""],dataset:{columns:Number.isFinite(e)&&e>=1?"true":null,align:Vu.has(s.align)?s.align:null},style:i},t)}function Bu(s={},...t){return l("div",{class:["zx-aspect",s.class??""],style:{"--zx-aspect-ratio":String(s.ratio??"16 / 9"),"--zx-aspect-fit":Zb.has(s.fit)?s.fit:"cover"}},t)}var Vu=new Set(["start","center","end","stretch","baseline"]),Jb=new Set(["start","center","end","between","around"]),Zb=new Set(["cover","contain","fill"]);function ju(s,t){if(t==null||t==="")return{};let e=Number(t);return Number.isInteger(e)&&e>=1&&e<=8?{[s]:`var(--zx-space-${e})`}:{[s]:String(t)}}function ty(s){return typeof s=="number"?`${s}px`:String(s)}function Hu(s,t={}){let e=P(s);if(!e)throw new TypeError("truncate() target could not be resolved");let i=q(Math.trunc(Number(t.lines)||1),1,10),n=t.title!==!1,r=e.classList.contains("zx-truncate"),o=e.getAttribute("title"),a=!1,c=null;e.classList.add("zx-truncate"),i>1&&(e.dataset.lines=String(i),e.style.setProperty("--zx-truncate-lines",String(i)));let d=()=>(a=Pa(e),n&&(a?e.setAttribute("title",e.textContent?.trim()??""):o===null?e.removeAttribute("title"):e.setAttribute("title",o)),a);return d(),typeof ResizeObserver=="function"&&(c=new ResizeObserver(d),c.observe(e)),{update:d,isTruncated:()=>a,destroy:()=>{c?.disconnect(),c=null,r||e.classList.remove("zx-truncate"),delete e.dataset.lines,e.style.removeProperty("--zx-truncate-lines"),n&&(o===null?e.removeAttribute("title"):e.setAttribute("title",o))}}}function Pa(s){return s.scrollWidth-s.clientWidth>1||s.scrollHeight-s.clientHeight>1}var ey=Object.freeze({text:"",label:"",title:"Copy",feedback:"Copied",feedbackDuration:2e3,size:"md",kind:"ghost"});function Mn(s={}){let t={...ey,...s},e=!t.label,i=l("button",{class:["zx-copy-button",e?"zx-icon-btn":"zx-btn"],type:"button",dataset:{size:t.size==="sm"?"sm":"md",kind:e?null:t.kind},title:e?String(t.title):null,ariaLabel:e?String(t.title):null}),n=l("span",{class:"zx-copy-button__icon",ariaHidden:"true"},g("copy",{size:t.size==="sm"?12:14})),r=l("span",{class:"zx-copy-button__status",role:"status"});i.append(n),e||i.append(l("span",{class:"zx-copy-button__label"},String(t.label))),i.append(r);let o=0;return i.addEventListener("click",async()=>{let a=typeof t.text=="function"?String(t.text()):String(t.text??""),c=await xn(a);t.oncopy?.(a,c),c&&(clearTimeout(o),i.dataset.copied="true",n.replaceChildren(g("check",{size:t.size==="sm"?12:14})),r.textContent=String(t.feedback),o=setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,n.replaceChildren(g("copy",{size:t.size==="sm"?12:14})),r.textContent="")},Math.max(0,Number(t.feedbackDuration)||0)))}),i}var Dn=class extends y{static cssName="copy-input";static defaults={value:"",label:"",hideLabel:!1,feedback:"Copied",buttonTitle:"Copy",size:"md"};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t;let e=x("zx-copy-input"),i=l("input",{ref:"input",class:"zx-copy-input__field",type:"text",id:e,readOnly:!0,value:String(this.options.value??"")}),n=Mn({text:()=>this.get(),title:String(this.options.buttonTitle),feedback:String(this.options.feedback),size:this.options.size==="sm"?"sm":"md",oncopy:(r,o)=>this.emit("copy",{value:r,copied:o})});return t.replaceChildren(l("label",{ref:"label",class:"zx-copy-input__label",for:e},String(this.options.label??"")),l("div",{class:"zx-copy-input__box"},i,n)),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(i,"focus",()=>i.select()),t}get(){return this.refs.input.value}set(t){return this.refs.input.value=String(t??""),this}focus(){return this.refs.input.focus(),this.refs.input.select(),this}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};var Lt=['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]'].join(",");function cs(s){return!!(s&&s!=="-"&&typeof s=="object"&&!["heading","separator","choice"].includes(String(s.type??"")))}function iy(s){return["menuitemcheckbox","menuitemradio"].includes(String(s.role))?s.role:"menuitem"}function Nn(s,t,{choices:e=!1}={}){let i=[];return s.forEach((n,r)=>{if(n==="-"||n&&typeof n=="object"&&n.type==="separator"){i.push(l("div",{class:`zx-${t}__separator`,role:"separator"}));return}if(n&&typeof n=="object"&&n.type==="heading"){i.push(l("div",{class:`zx-${t}__heading`,role:"presentation"},String(n.label??"")));return}if(n&&typeof n=="object"&&n.type==="choice"){e&&i.push(sy(n,r,t));return}if(!cs(n))return;let o=iy(n),a=V(n.href),c=n.target==null?null:String(n.target),d=n.rel==null?c==="_blank"?"noopener noreferrer":null:String(n.rel),u=[],h=[];o!=="menuitem"&&h.push(l("span",{class:`zx-${t}__check`,"data-check-kind":o==="menuitemradio"?"radio":"checkbox"})),n.icon&&h.push(g(n.icon)),u.push(l("span",{class:`zx-${t}__leading`,ariaHidden:"true"},h)),u.push(l("span",{class:`zx-${t}__body`},l("span",{class:`zx-${t}__label`},String(n.label??"")),n.description==null||n.description===""?null:l("span",{class:`zx-${t}__description`},String(n.description))));let f=[];if(n.badge!=null&&f.push(l("span",{class:`zx-${t}__badge`},String(n.badge))),n.shortcut&&f.push(l("kbd",{class:`zx-${t}__shortcut`},String(n.shortcut))),n.adornment!=null){let _=n.adornment&&typeof n.adornment=="object"&&"nodeType"in n.adornment?n.adornment:String(n.adornment);f.push(l("span",{class:`zx-${t}__adornment`},_))}f.length&&u.push(l("span",{class:`zx-${t}__meta`},f));let p={class:`zx-${t}__item`,role:o,tabindex:"-1","data-menu-item":String(r),"data-danger":n.danger?"true":null,ariaDisabled:n.disabled?"true":null,ariaChecked:o==="menuitem"?null:String(!!n.checked)};a?i.push(l("a",{...p,href:a,target:c,rel:d},u)):i.push(l("button",{...p,type:"button"},u))}),i}function sy(s,t,e){let i=x(`zx-${e}-choice`),n=Array.isArray(s.options)?s.options:[];return l("div",{class:`zx-${e}__choice`,role:"group",ariaLabelledby:i},l("span",{class:`zx-${e}__choice-label`,id:i},String(s.label??"")),l("span",{class:`zx-${e}__choice-options`},n.map((r,o)=>{let a=typeof r.glyph=="function"?r.glyph():r.glyph;return l("button",{class:`zx-${e}__choice-option`,type:"button",role:"menuitemradio",tabindex:"-1",title:String(r.label??""),ariaLabel:String(r.label??""),ariaChecked:String(Object.is(r.value,s.value)),ariaDisabled:r.disabled?"true":null,"data-menu-item":String(t),"data-menu-option":String(o)},a&&typeof a=="object"&&"nodeType"in a?a:r.icon?g(r.icon):String(r.label??""))})))}var ny=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe",'[contenteditable="true"]',"[tabindex]"].map(s=>`${s}:not([tabindex^="-"])`).join(","),pt=class extends y{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1,scope:null};#t;#e=null;#i=new Map;#s=null;#r=null;#n=!0;#o=!1;constructor(t,e={}){let i=P(t);if(!i)throw new TypeError("Dropdown anchor could not be resolved");super(null,e),this.#t=i,oe(this.options.scope??i,{dialog:!1})?.append(this.el),this.#f("aria-expanded"),this.#f("aria-controls"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#t,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()}),this.listen(this.#t,"keydown",n=>this.#l(n)),this.listen(this.el,"keydown",n=>this.#d(n))}render(){let t=l("div",{id:x("zx-dropdown"),popover:"manual"});return t.dataset.state="closed",t}open(){if(this.isOpen()||this.#o)return this;let t=this.#a();return this.el.parentElement!==t&&t.append(this.el),this.#e=nt(this.#t,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.#s=le({kind:"popup",root:this.el,owner:this,anchor:[this.#t,P(this.options.scope)],inside:[this.#t],onEscape:e=>this.#c(e),onOutsidePointer:()=>this.close(),onParentClose:()=>this.close()}),this.el.dataset.zxOverlayOrder=String(this.#s.order),this.#t.setAttribute("aria-expanded","true"),this.emit("open"),this}close(){if(!this.isOpen())return this;let t=this.el.contains(document.activeElement);this.#e?.destroy(),this.#e=null,this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let e=this.#s;return this.#s=null,this.#t.setAttribute("aria-expanded","false"),t&&this.#n&&this.#t instanceof HTMLElement&&this.#t.focus(),di(this.el.parentElement)&&this.el.parentElement?.isConnected&&vt(this.options.scope??this.#t).append(this.el),e?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return ry(this.el,t),this.#e?.update(),this}getPanel(){return this.el}destroy(){if(!this.#o){this.#o=!0,this.close();for(let[t,e]of this.#i)ly(this.#t,t,e);super.destroy()}}_configure(t){return"onEscape"in t&&(this.#r=t.onEscape??null),"tabReach"in t&&(this.#n=!!t.tabReach),this}#a(){return di(this.#t)??di(P(this.options.scope))??ns(this.options.scope??this.#t)}#c(t){if(this.#r){this.#r(t);return}let e=this.el.contains(document.activeElement);this.close(),e&&this.#t instanceof HTMLElement&&this.#t.focus()}#l(t){if(t.key!=="Tab"||t.shiftKey||t.defaultPrevented||!this.#n||!this.isOpen())return;let e=Ba(this.el)[0]??(this.el.hasAttribute("tabindex")?this.el:null);e instanceof HTMLElement&&(t.preventDefault(),e.focus())}#d(t){if(t.key!=="Tab"||t.defaultPrevented||!this.#n||!this.isOpen())return;let e=Ba(this.el),i=document.activeElement;if((i&&i!==this.el?e.filter(o=>!o.contains(i)&&(t.shiftKey?!!(i.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING):!!(i.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)&&!i.contains(o))):t.shiftKey?[]:e).length>0)return;if(t.shiftKey){if(!(this.#t instanceof HTMLElement))return;t.preventDefault(),this.#t.focus();return}let r=oy(this.#t,this.el);r&&(t.preventDefault(),r.focus())}#f(t){this.#i.set(t,this.#t.getAttribute(t))}};function ry(s,t){if(s.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}function Ba(s){return Array.from(s.querySelectorAll(ny)).filter(t=>ay(t))}function oy(s,t){let e=di(s)??s.ownerDocument.body??s.ownerDocument.documentElement,i=Ba(e).filter(o=>!t.contains(o)),n=i.findIndex(o=>o===s||s.contains(o));if(n<0)return null;let r=n+1;for(;r<i.length&&s.contains(i[r]);)r+=1;return i[r]??null}function ay(s){let t=s;if(typeof t.focus!="function"||t.tabIndex<0||t.disabled||s.closest('[inert], [hidden], [aria-hidden="true"], fieldset[disabled]'))return!1;if(t instanceof HTMLInputElement&&t.type==="radio"&&t.name&&!t.checked){let e=t.form??t.getRootNode(),i=Array.from(e.querySelectorAll?.('input[type="radio"]')??[]).filter(n=>n.name===t.name&&(n.form??n.getRootNode())===e);if(i.some(n=>n.checked)||i[0]!==t)return!1}return typeof t.checkVisibility=="function"?t.checkVisibility({visibilityProperty:!0}):t.getClientRects().length>0}function ly(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var at=class extends y{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#i;#s;#r=[];#n=null;#o=!0;#a=!1;#c=!1;constructor(t=null,e={}){let i=t===null?null:P(t);if(t!==null&&(!i||i.tagName!=="BUTTON"))throw new TypeError("MenuButton target must resolve to a button");let n=i?{attributes:Array.from(i.attributes,o=>[o.name,o.value]),children:Array.from(i.childNodes)}:null,r=Object.hasOwn(e,"label");super(t,e),this.#a=i===null,this.#n=n,this.el.classList.add("zx-btn"),this.el.setAttribute("type","button"),this.el.setAttribute("data-kind",String(this.options.kind)),this.el.setAttribute("data-size","md"),this.#t=new pt(this.el,{openOn:"manual",placement:this.options.placement,content:null}),this.#e=this.#t.getPanel(),this.#t._configure({onEscape:()=>this.#f(),tabReach:!1}),this.#e.classList.add("zx-menu-button__menu"),this.#e.setAttribute("role","menu"),this.el.id||(this.el.id=x("zx-menu-button")),this.#e.setAttribute("aria-labelledby",this.el.id),this.el.setAttribute("aria-haspopup","menu"),i&&r&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#i=Mt(this.#e,Lt),this.#s=ut(()=>this.#g(),o=>o.focus()),this.#t.on("open",()=>this.emit("open")),this.#t.on("close",()=>{this.#o=!0,this.emit("close")}),this.listen(this.el,"click",()=>{this.isOpen()?this.close():(this.open(),this.#h())}),this.listen(this.el,"keydown",o=>this.#l(o)),this.listen(this.#e,"click",o=>{let a=o.target.closest?.(Lt);a&&this.#e.contains(a)&&this.#_(a,o)}),this.listen(this.#e,"keydown",o=>this.#d(o)),this.listen(this.#e,"keydown",o=>this.#u(o),{capture:!0})}render(){return this.el?this.el:l("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},qu(this.options.label,this.options.icon))}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(...Nn(this.#r,"menu-button",{choices:!0})),this}open(t={}){return this.isOpen()||(this.#o=t?.returnFocus??!0),this.#t.open(),this}close(){return this.#t.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#t.isOpen()}getTrigger(){return this.el}getPanel(){return this.#e}focusFirst(t={}){return this.open(t),this.#h(),this}focusLast(t={}){return this.open(t),this.#i.focusLast(),this}setLabel(t){return this.el.replaceChildren(...qu(t,this.options.icon)),this}destroy(){if(!this.#c&&(this.#c=!0,this.#i.destroy(),this.#t.destroy(),super.destroy(),!this.#a&&this.#n)){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,e]of this.#n.attributes)this.el.setAttribute(t,e);this.el.replaceChildren(...this.#n.children)}}#l(t){["ArrowDown","ArrowUp","Enter"," "].includes(t.key)&&(t.preventDefault(),this.open(),t.key==="ArrowUp"?this.#i.focusLast():this.#h())}#d(t){if(t.key==="Tab"){this.close();return}if(t.key==="Enter"||t.key===" "){let e=t.target.closest?.(Lt);if(!e||!this.#e.contains(e)||t.key==="Enter"&&e.tagName==="A")return;t.preventDefault(),e.click();return}this.#s(t)}#f(){let t=document.activeElement,e=!t||t===document.body||this.#e.contains(t),i=this.#m();this.close(),e&&i?.focus()}#h(){this.#i.focusFirst();let t=this.#g()[0],e=t?.hasAttribute("data-menu-option")?t.parentElement?.querySelector('[aria-checked="true"]'):null;e instanceof HTMLElement&&e.focus()}#u(t){let e=t.target?.closest?.("[data-menu-option]");if(!(e instanceof HTMLElement)||!this.#e.contains(e)){if(t.key!=="ArrowDown"&&t.key!=="ArrowUp")return;let c=this.#g(),d=c.indexOf(t.target);if(d<0)return;let u=c[(d+(t.key==="ArrowDown"?1:-1)+c.length)%c.length],h=u?.hasAttribute("data-menu-option")?u.parentElement:null;if(!h)return;t.preventDefault(),t.stopPropagation(),(h.querySelector('[aria-checked="true"]')??u).focus();return}let i=[...e.parentElement?.children??[]],n=this.#g(),r=null;if(t.key==="ArrowLeft")r=i[(i.indexOf(e)-1+i.length)%i.length];else if(t.key==="ArrowRight")r=i[(i.indexOf(e)+1)%i.length];else if(t.key==="ArrowDown")r=n[(n.indexOf(i.at(-1))+1)%n.length];else if(t.key==="ArrowUp")r=n[(n.indexOf(i[0])-1+n.length)%n.length];else return;t.preventDefault(),t.stopPropagation();let o=r?.closest('[role="group"]')?.querySelector('[data-menu-option][aria-checked="true"]');(t.key==="ArrowDown"||t.key==="ArrowUp"?o??r:r)?.focus()}#p(t,e,i){let n=e.options?.[Number(t.getAttribute("data-menu-option"))];if(!n||n.disabled){i?.preventDefault();return}for(let r of t.parentElement?.children??[])r.setAttribute("aria-checked",String(r===t));t.focus(),e.onselect?.(n.value,e,this),!this.isOpen()&&(t.contains(document.activeElement)||document.activeElement===document.body)&&this.#m()?.focus()}#_(t,e=null){let i=Number(t.getAttribute("data-menu-item")),n=this.#r[i];if(n&&typeof n=="object"&&n.type==="choice"){this.#p(t,n,e);return}if(!cs(n)||n.disabled){e?.preventDefault();return}let r=this.#m(),o=document.activeElement,a=!!r&&(!o||o===document.body||this.#e.contains(o));if(a&&r?.focus(),this.emit("select",{value:n.value,item:n}).defaultPrevented){e?.preventDefault(),a&&document.activeElement===r&&t instanceof HTMLElement&&t.focus();return}try{n.onselect?.(n.value,n,this)}finally{this.close()}}#m(){let t=this.#o;return t===!1?null:t instanceof HTMLElement&&t.isConnected?t:this.el}#g(){return Array.from(this.#e.querySelectorAll(Lt))}};function qu(s,t){let e=[];return t&&e.push(l("span",{class:"zx-btn__icon"},g(t))),e.push(l("span",{class:"zx-btn__label"},String(s??""))),e}var cy=["button","a[href]","input","select","textarea","[tabindex]"],dy=cy.flatMap(s=>[`.zx-toolbar > ${s}`,`.zx-toolbar > [role="group"] > ${s}`]).join(","),On=class extends y{static cssName="toolbar";static defaults={items:[],align:"start",label:"Toolbar",overflow:!0,overflowLabel:"More",dense:!1};#t;#e=null;#i=null;#s=!1;#r=-1;#n=-1;#o=0;#a=!1;constructor(t=null,e={}){if(super(t,e),this.options.overflow){this.#e=new at(null,{icon:"dots",label:"",kind:"ghost",placement:"bottom-end"});let i=this.#e.toElement();i.classList.add("zx-toolbar__overflow"),i.setAttribute("aria-label",String(this.options.overflowLabel)),i.setAttribute("title",String(this.options.overflowLabel)),this.options.dense&&i.setAttribute("data-size","sm"),i.hidden=!0}this.#t=Mt(this.el,dy,{orientation:"horizontal"}),this.listen(this.el,"click",i=>this.#l(i)),this.setItems(this._initialItems),this.#e&&typeof ResizeObserver=="function"&&(this.#i=new ResizeObserver(()=>this.#f()),this.#i.observe(this.el))}render(){this._records=[],this._named=new Map,this._createdRoot=!this.el;let t=this.el??l("div");this.el=t,this._snapshot=this._createdRoot?null:A(t);let e=this.options.items;return this._initialItems=Array.isArray(e)&&e.length===0?Array.from(t.children):e,t.setAttribute("role","toolbar"),t.setAttribute("aria-label",String(this.options.label)),t.dataset.align=hy(this.options.align),t.dataset.overflow=this.options.overflow?"true":"false",this.options.dense&&(t.dataset.dense="true"),t}setItems(t){for(let i of this._records)i.type==="element"&&(i.element.hidden=i.userHidden);this._records=uy(t).map(i=>this.#c(i)),this._named=new Map;for(let i of this._records)i.name!==null&&!this._named.has(i.name)&&this._named.set(i.name,i);let e=this._records.map(i=>i.element);if(this.#e){this.#e.setItems([]);let i=this.#e.toElement();i.hidden=!0,e.push(i)}return this.el.replaceChildren(...e),this.#r=-1,this.#n=-1,this.#h(),this}getItem(t){return this._named.get(String(t))?.element??null}enable(t){return this.#d(t,!1)}disable(t){return this.#d(t,!0)}setActive(t,e=!0){let i=this._named.get(String(t));return i&&i.element.setAttribute("aria-pressed",e?"true":"false"),this}destroy(){if(!this.#a){this.#a=!0,this.#i?.disconnect(),this.#i=null,this.#o!==0&&cancelAnimationFrame(this.#o),this.#o=0,this.#t.destroy(),this.#e?.destroy(),this.#e=null;for(let t of this._records)t.type==="element"&&(t.element.hidden=t.userHidden);super.destroy(),this._createdRoot||S(this.el,this._snapshot)}}#c(t){if(t.type==="separator")return{type:"separator",element:l("span",{class:"zx-toolbar__separator",role:"separator",ariaOrientation:"vertical",dataset:{separator:"true"}}),name:null,label:"",icon:null,onclick:null,userHidden:!1};if(t.type==="element"){let a=t.element;return{type:"element",element:a,name:a.dataset?.name??null,label:Ku(a),icon:null,onclick:null,userHidden:!!a.hidden}}let{name:e=null,active:i,onclick:n,...r}=t.descriptor,o=j({size:this.options.dense?"sm":"md",...r});return i!==void 0&&o.setAttribute("aria-pressed",i?"true":"false"),e!==null&&(o.dataset.name=String(e)),{type:"descriptor",element:o,name:e===null?null:String(e),label:String(r.label??r.title??""),icon:r.icon??null,onclick:typeof n=="function"?n:null,userHidden:!1}}#l(t){let e=t.target;if(!e)return;let i=this._records.find(n=>n.type==="descriptor"&&n.element.contains(e));i&&(this.emit("action",{name:i.name,item:i.element}),i.onclick?.(t))}#d(t,e){let i=this._named.get(String(t));if(!i)return this;let n=i.element;return"disabled"in n?n.disabled=e:e?n.setAttribute("aria-disabled","true"):n.removeAttribute("aria-disabled"),this.#u(),this}#f(){if(!(this.#o!==0||this.#a)){if(typeof requestAnimationFrame!="function"){this.#h();return}this.#o=requestAnimationFrame(()=>{this.#o=0,this.#h()})}}#h(){if(this.#s||this.#a||!this.#e)return;let t=this.el;if(typeof getComputedStyle!="function"||!t.isConnected)return;let e=getComputedStyle(t),i=parseFloat(e.columnGap)||0,n=(parseFloat(e.paddingInlineStart)||0)+(parseFloat(e.paddingInlineEnd)||0),r=t.clientWidth-n,o=t.clientHeight;if(!(!(r>0)||r===this.#r&&o===this.#n)){this.#s=!0;try{let a=this.#e.toElement(),c=this._records.filter(_=>!_.userHidden);for(let _ of c)_.element.hidden=!1;a.hidden=!1;let d=c.map(_=>_.element.getBoundingClientRect().width),u=d.reduce((_,m)=>_+m,0)+i*Math.max(0,d.length-1),h=a.getBoundingClientRect().width,f=[];if(u>r){let _=r-h-i,m=0,b=!1;for(c.forEach((w,v)=>{let z=m+d[v]+(m>0?i:0);if(!b&&z<=_){m=z;return}b=!0,w.element.hidden=!0,f.push(w)});c.length>f.length;){let w=c[c.length-f.length-1];if(w.type!=="separator")break;w.element.hidden=!0,f.unshift(w)}}let p=$u(f);this.#e.setItems(p),a.hidden=p.length===0,this.#r=r,this.#n=t.clientHeight}finally{this.#s=!1}}}#u(){if(!this.#e)return;let t=this._records.filter(e=>!e.userHidden&&e.element.hidden);this.#e.setItems($u(t))}};function uy(s){if(s!=null&&!Array.isArray(s))throw new TypeError("Toolbar items must be an array");let t=[];for(let e of s??[])if(e!=null){if(e==="-"){t.length>0&&t[t.length-1].type!=="separator"&&t.push({type:"separator"});continue}if(E(e)){t.push({type:"element",element:e});continue}if(typeof e!="object"||Array.isArray(e))throw new TypeError('Toolbar items must be Elements, item descriptors, or "-"');t.push({type:"descriptor",descriptor:{...e}})}for(;t.length>0&&t[t.length-1].type==="separator";)t.pop();return t}function $u(s){let t=[];for(let e of s){if(e.type==="separator"){t.length>0&&t[t.length-1]!=="-"&&t.push("-");continue}let i=e.element;t.push({label:e.label||Ku(i)||"\u2026",icon:e.icon??void 0,value:e.name,disabled:!!i.disabled||i.getAttribute("aria-disabled")==="true",onselect:()=>i.click()})}for(;t.length>0&&t[t.length-1]==="-";)t.pop();return t}function Ku(s){return(s.getAttribute("aria-label")??s.getAttribute("title")??s.textContent??"").trim()}function hy(s){return["end","between"].includes(s)?s:"start"}var Fn=class extends y{static cssName="card";static defaults={title:"",media:null,content:null,actions:[],footer:null,link:null,variant:"outlined",orientation:"vertical",headingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("article");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._title="",this._link=null,this._actionAbort=null,this._linkAbort=null;let i=t?[]:Array.from(e.childNodes);try{let n=my(this.options.headingLevel),r=x("zx-card-heading"),o=l(`h${n}`,{ref:"heading",class:"zx-card__heading",id:r}),a=l("div",{ref:"media",class:"zx-card__media",hidden:!0}),c=l("div",{ref:"actions",class:"zx-card__actions",role:"group",ariaLabel:this._message("card.actions","Card actions"),hidden:!0}),d=l("div",{ref:"content",class:"zx-card__content",hidden:!0}),u=l("footer",{ref:"footer",class:"zx-card__footer",hidden:!0}),h=l("header",{ref:"header",class:"zx-card__header"},o,c);return e.replaceChildren(l("div",{class:"zx-card__layout"},a,l("div",{class:"zx-card__inner"},h,d,u))),e.dataset.variant=py(this.options.variant),e.dataset.orientation=_y(this.options.orientation),this.setTitle(this.options.title),this.setMedia(this.options.media),this.options.content!==null?this.setContent(this.options.content):i.length&&(d.replaceChildren(...i),d.hidden=!1),this.setActions(this.options.actions),this.setFooter(this.options.footer),this.setLink(this.options.link),e}catch(n){throw this._actionAbort?.abort(),this._linkAbort?.abort(),t||S(e,this._original),n}}setTitle(t){let e=String(t??"");if(this._link&&!e.trim())throw new TypeError("A linked Card requires a non-empty title");return this._title=e,this._renderHeading(),this}setMedia(t){return Va(this.refs.media,t,"Card media"),this.refs.media.hidden=t===null,this}setContent(t){return Va(this.refs.content,t,"Card content"),this.refs.content.hidden=t===null,this}setActions(t){if(!Array.isArray(t))throw new TypeError("Card actions must be an array");let e=new AbortController,i;try{i=t.map(n=>{if(E(n))return n;if(!n||typeof n!="object"||Array.isArray(n))throw new TypeError("Card actions must be Elements or button descriptors");let r={...n},o=r.onclick;delete r.onclick;let a=j(r);if(o!==void 0&&typeof o!="function")throw new TypeError("Card action onclick must be a function");return o&&a.addEventListener("click",o,{signal:e.signal}),a})}catch(n){throw e.abort(),n}return this._actionAbort?.abort(),this._actionAbort=e,this.refs.actions.replaceChildren(...i),this.refs.actions.hidden=i.length===0,this._syncHeader(),this}setFooter(t){return Va(this.refs.footer,t,"Card footer"),this.refs.footer.hidden=t===null,this}setLink(t){let e=fy(t);if(e&&!this._title.trim())throw new TypeError("A linked Card requires a non-empty title");return this._link=e,this.el.dataset.linked=e?"true":"false",this._renderHeading(),this}destroy(){this._cleaned||(this._cleaned=!0,this._actionAbort?.abort(),this._linkAbort?.abort(),super.destroy(),this._createdRoot||S(this.el,this._original))}_renderHeading(){let t=this._title,e=new AbortController,i=this._link?l("a",{class:"zx-card__primary",href:this._link.href,target:this._link.target,rel:this._link.rel},t):l("span",{class:"zx-card__title"},t);this._link?.onclick&&i.addEventListener("click",this._link.onclick,{signal:e.signal}),this._linkAbort?.abort(),this._linkAbort=e,this.refs.heading.replaceChildren(i),this.refs.heading.hidden=t==="",t?this.el.setAttribute("aria-labelledby",this.refs.heading.id):this.el.removeAttribute("aria-labelledby"),this._syncHeader()}_syncHeader(){this.refs.header&&(this.refs.header.hidden=this._title===""&&this.refs.actions.childElementCount===0)}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Va(s,t,e){if(t===null){s.replaceChildren();return}if(typeof t=="string"){s.textContent=t;return}let i=t instanceof y?t.toElement():t;if(i instanceof Node){s.replaceChildren(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function fy(s){if(s===null)return null;let t=typeof s=="string"?{href:s}:s;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Card link must be a URL string, descriptor, or null");let e=V(t.href);if(e===null)throw new TypeError("Card link requires a safe non-empty href");if(t.onclick!==void 0&&typeof t.onclick!="function")throw new TypeError("Card link onclick must be a function");let i=t.target==null?void 0:String(t.target),n=t.rel==null?"":String(t.rel).trim();return i==="_blank"&&!/(^|\s)noopener(\s|$)/i.test(n)&&(n=`${n} noopener`.trim()),{href:e,target:i,rel:n||void 0,onclick:t.onclick}}function py(s){return["raised","filled"].includes(String(s))?s:"outlined"}function _y(s){return s==="horizontal"?"horizontal":"vertical"}function my(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}var gy=Object.freeze(["neutral","accent","success","warning","danger","info"]),by=Object.freeze(["positive","negative","neutral"]),yy=Object.freeze({"statTile.up":"up %1","statTile.down":"down %1","statTile.unchanged":"no change","statTile.loading":"Loading"}),wy=Object.freeze({up:"chevron-up",down:"chevron-down",flat:"minus"}),Xu=100,qa=30,vy=2,xy=Object.freeze({label:"",value:null,format:"number",currency:null,caption:"",delta:null,deltaKind:"neutral",deltaLabel:"",trend:[],icon:null,kind:"neutral",href:null,clickable:!1,loading:!1}),Uu="http://www.w3.org/2000/svg",ds=class extends y{static cssName="stat-tile";static defaults=xy;constructor(t=null,e={}){super(t,{...e,clickable:e?.clickable===!0||typeof e?.onclick=="function"})}render(){let t=ja(this.options);if(this._createdRoot=this.el===null,!this._createdRoot&&this.el.tagName.toLowerCase()!==t)throw new TypeError(`StatTile needs a <${t}> for these options, but the target is a <${this.el.tagName.toLowerCase()}>. Pass null as the target to let it build its own.`);let e=this.el??l(t);return this.el=e,this._snapshot=this._createdRoot?null:A(e),this._closed=!1,this._state={...this.options},t==="button"&&(e.type="button"),Wu(e,this._state,(i,...n)=>this._message(i,...n)),t!=="div"&&this.listen(e,"click",i=>{this.emit("click",{event:i})}),e}update(t={}){let e={...this._state,...t},i=this.el.tagName.toLowerCase();if(ja(e)!==i)throw new TypeError(`StatTile cannot change from <${i}> to <${ja(e)}> in place: href and clickable decide the element, and an element's tag is fixed once it exists.`);return this._state=e,Wu(this.el,e,(n,...r)=>this._message(n,...r)),this}getAccessibleName(){return this.el.getAttribute("aria-label")??""}destroy(){if(this._closed)return;this._closed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_message(t,...e){let i=this.msg(t,...e);return i===t?T(yy[t]??t,e):i}};function Ju(s={}){return new ds(null,s)}function Zu(s,t={}){let{format:e="number",locale:i,currency:n=null}=t;if(typeof e=="function")return ze(e(s));if(typeof s=="string")return s;if(s==null)return"";switch(e){case"currency":return oi(s,n,{locale:i});case"percent":return ai(s,{locale:i});case"fileSize":return li(s,{locale:i});case"number":return Nt(s,{locale:i});default:return ze(s)}}function Sy(s,t={}){let e=ih(s);if(e===null)return null;let i=e>0?"up":e<0?"down":"flat",n=i==="up"?"+":i==="down"?"\u2212":"",r=Zu(Math.abs(e),t);return{direction:i,sign:n,magnitude:r,text:`${n}${r}`}}function ja(s={}){return V(s.href)?"a":s.clickable===!0||typeof s.onclick=="function"?"button":"div"}function Yu(s={}){let t=[s.value,s.caption].map(Ha).filter(Boolean).join(" "),e=[s.delta,s.deltaLabel].map(Ha).filter(Boolean).join(" ");return[Ha(s.label),t,e].filter(Boolean).join(", ")}function th(s,t={}){let{width:e=Xu,height:i=qa,inset:n=vy}=t,r=(Array.isArray(s)?s:[]).map(ih).filter(f=>f!==null);if(r.length<2)return null;let o=Math.min(...r),a=Math.max(...r),c=n,d=Math.max(n,i-n),u=a-o,h=e/(r.length-1);return r.map((f,p)=>{let _=p===r.length-1?e:p*h,m=u===0?(c+d)/2:d-(f-o)/u*(d-c);return`${Qu(_)},${Qu(m)}`}).join(" ")}function Wu(s,t,e){let i=eh(t.kind,gy,"neutral"),n=ze(t.label),r=t.loading===!0;if(s.classList.add("zx-stat-tile"),s.dataset.kind=i,s.dataset.loading=String(r),s.tagName.toLowerCase()==="a"){let _=V(t.href);_?s.setAttribute("href",_):s.removeAttribute("href")}if(r){s.setAttribute("aria-busy","true"),Gu(s,Yu({label:n,value:e("statTile.loading")})),s.replaceChildren(zy(t));return}s.removeAttribute("aria-busy");let o=Zu(t.value,t),a=Sy(t.delta,{format:t.deltaFormat??t.format,locale:t.locale,currency:t.currency}),c=ze(t.deltaLabel),d=ze(t.caption).trim();Gu(s,Yu({label:n,value:o,caption:d,delta:a===null?"":Ty(a,e),deltaLabel:c}));let u=l("div",{class:"zx-stat-tile__header"},l("span",{class:"zx-stat-tile__label"},n)),h=Cy(t.icon);h&&u.append(l("span",{class:"zx-stat-tile__icon"},h));let f=[u,l("div",{class:"zx-stat-tile__value"},o)];d&&f.push(l("div",{class:"zx-stat-tile__caption"},d)),a!==null&&f.push(Ay(a,c,t.deltaKind));let p=ky(t.trend);p&&f.push(p),s.replaceChildren(...f)}function Ay(s,t,e){let i=l("div",{class:"zx-stat-tile__delta",ariaHidden:"true",dataset:{kind:eh(e,by,"neutral"),direction:s.direction}},g(wy[s.direction],{size:12}),l("span",{class:"zx-stat-tile__delta-value"},s.text));return t&&i.append(l("span",{class:"zx-stat-tile__delta-label"},t)),i}function ky(s){let t=th(s);if(t===null)return null;let e=document.createElementNS(Uu,"svg");e.setAttribute("class","zx-stat-tile__trend"),e.setAttribute("viewBox",`0 0 ${Xu} ${qa}`),e.setAttribute("preserveAspectRatio","none"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");let i=document.createElementNS(Uu,"polyline");return i.setAttribute("points",t),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("vector-effect","non-scaling-stroke"),e.append(i),e}function zy(s){let t=[l("div",{class:"zx-stat-tile__header"},ot({width:"55%",height:"0.75rem"})),ot({width:"70%",height:"1.75rem",radius:"md"})];return ze(s.caption).trim()&&t.push(ot({width:"35%",height:"0.75rem"})),s.delta!==null&&s.delta!==void 0&&t.push(ot({width:"40%",height:"0.75rem"})),th(s.trend)!==null&&t.push(ot({width:"100%",height:`${qa}px`,radius:"md"})),l("div",{class:"zx-stat-tile__loading"},...t)}function Cy(s){return s?g(String(s),{size:16}):null}function Ty(s,t){return s.direction==="flat"?t("statTile.unchanged"):t(s.direction==="up"?"statTile.up":"statTile.down",s.magnitude)}function Gu(s,t){let e=s.tagName.toLowerCase()==="div";if(t){s.setAttribute("aria-label",t),e&&s.setAttribute("role","group");return}s.removeAttribute("aria-label"),e&&s.removeAttribute("role")}function eh(s,t,e){return t.includes(s)?s:e}function ih(s){if(typeof s=="number")return Number.isFinite(s)?s:null;if(typeof s!="string")return null;let t=s.trim();if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function ze(s){return s==null?"":String(s)}function Ha(s){return ze(s).trim()}function Qu(s){return Math.round(q(s,-1e6,1e6)*100)/100}var Iy=Object.freeze(["source","confluence","horizon","diagonal","edge","curtain"]),Ey=Object.freeze(["subtle","balanced","vivid"]),Ln=Object.freeze(["--zx-aurora-color-1","--zx-aurora-color-2","--zx-aurora-color-3","--zx-aurora-color-4"]),Rn=class extends y{static cssName="aurora";static defaults={preset:"source",colors:[],intensity:"subtle"};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("div");return this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._initialColors=Ln.map(i=>({property:i,value:e.style.getPropertyValue(i),priority:e.style.getPropertyPriority(i)})),this._colors=[],this.setPreset(this.options.preset),this.setIntensity(this.options.intensity),this.setColors(this.options.colors),e}setPreset(t){return this.el.dataset.preset=My(t),this}setColors(t){let e=Ny(t),i=Oy(e);if(this._colors=[...e],this.el.dataset.colors=e.length===0?"semantic":String(e.length),i.length===0){for(let n of this._initialColors)n.value?this.el.style.setProperty(n.property,n.value,n.priority):this.el.style.removeProperty(n.property);return this}for(let n=0;n<Ln.length;n+=1)this.el.style.setProperty(Ln[n],i[n]);return this}setIntensity(t){return this.el.dataset.intensity=Dy(t),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._createdRoot||S(this.el,this._original))}};function My(s){let t=String(s??"").trim().toLowerCase();if(!Iy.includes(t))throw new TypeError(`Unknown Aurora preset: ${s}`);return t}function Dy(s){let t=String(s??"").trim().toLowerCase();if(!Ey.includes(t))throw new TypeError(`Unknown Aurora intensity: ${s}`);return t}function Ny(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Aurora colors must be an array");if(s.length>Ln.length)throw new TypeError("Aurora accepts at most four colors");return s.map(t=>{if(!ee(t))throw new TypeError(`Invalid Aurora color: ${t}`);return t.trim()})}function Oy(s){return s.length===0?[]:s.length===1?[s[0],s[0],s[0],s[0]]:s.length===2?[s[0],s[1],s[0],s[1]]:s.length===3?[s[0],s[1],s[2],s[1]]:[...s]}var Pn=class extends y{static cssName="panel";static defaults={title:"",content:null,open:!0,collapsible:!0,buttons:[],footer:null,footerButtons:[]};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:Fy(e),this._cleaned=!1,this._open=!!this.options.open,this._collapsible=!!this.options.collapsible,this._hasFooterContent=!1;let i=t?[]:Array.from(e.childNodes),n=x("zx-panel-body"),r=l("span",{class:"zx-panel__title",ref:"title"}),o=[];this._collapsible&&o.push(l("span",{class:"zx-panel__chevron",ariaHidden:"true"},g("chevron-right",{size:16}))),o.push(r);let a=this._collapsible?l("button",{class:"zx-panel__toggle",ref:"toggle",type:"button",ariaControls:n,ariaExpanded:String(this._open)},o):l("div",{class:"zx-panel__toggle",ref:"toggle"},o),c=l("div",{class:"zx-panel__header",ref:"header"},a,l("div",{class:"zx-panel__buttons",ref:"buttons",role:"group",ariaLabel:this._message("panel.actions","Panel actions")})),d=l("div",{class:"zx-panel__content",ref:"content"}),u=l("div",{class:"zx-panel__body",ref:"body",id:n},d),h=l("div",{class:"zx-panel__footer",ref:"footer",hidden:!0},l("div",{class:"zx-panel__footer-content",ref:"footerContent"}),l("div",{class:"zx-panel__footer-buttons",ref:"footerButtons",role:"group",ariaLabel:this._message("panel.footerActions","Panel footer actions")}));return e.replaceChildren(c,u,h),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):d.append(...i),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),this.setFooterButtons(this.options.footerButtons),this._syncOpenState(),this._collapsible&&this.listen(a,"click",()=>this.toggle()),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return sh(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return sh(this.refs.footerContent,t,"Panel footer"),this._hasFooterContent=t!==null,this._syncFooter(),this}setFooterButtons(t){return this.refs.footerButtons.replaceChildren(...this._buildButtons(t,"Panel footer buttons")),this._syncFooter(),this}open(){return this._open?this:(this._open=!0,this._syncOpenState(),this.emit("open"),this)}close(){return this._open?(this._open=!1,this._syncOpenState(),this.emit("close"),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this._open}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Ly(this.el,this._original))}_syncOpenState(){this.el.setAttribute("data-state",this._open?"open":"closed"),this.refs.body.hidden=!this._open,this._collapsible&&this.refs.toggle.setAttribute("aria-expanded",String(this._open))}_syncFooter(){this.refs.footer.hidden=!this._hasFooterContent&&this.refs.footerButtons.childElementCount===0}_buildButtons(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);return t.map(i=>{if(E(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be Elements or button descriptors`);let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o})}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Fy(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Ly(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function sh(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof y?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Ry=Object.freeze(["default","settings","accounts","billing","calendar","campaigns","clocking","collection","contacts","contracts","enhancements","inventory","links","mailinglists","messages","notes","opportunities","pricelists","procurement","projects","tasks","tickets","pwd","system","usermgmt","usersettings","users","groups"]),Bn=class extends y{static cssName="master-panel";static defaults={title:"",content:null,buttons:[],module:null,footer:null};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:Py(e),this._cleaned=!1;let i=t?[]:Array.from(e.childNodes),n=l("header",{class:"zx-master-panel__header"},l("h1",{class:"zx-master-panel__title",ref:"title"}),l("div",{class:"zx-master-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),r=l("div",{class:"zx-master-panel__content",ref:"content"}),o=l("footer",{class:"zx-master-panel__footer",ref:"footer",hidden:!0});e.replaceChildren(n,r,o);let a=Vy(this.options.module);return e.dataset.module=a,this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):r.append(...i),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return nh(this.refs.content,t,"MasterPanel content"),this}setButtons(t){if(!Array.isArray(t))throw new TypeError("MasterPanel buttons must be an array");let e=t.map(i=>{if(E(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("MasterPanel buttons must be Elements or button descriptors");let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.buttons.replaceChildren(...e),this}setFooter(t){return nh(this.refs.footer,t,"MasterPanel footer"),this.refs.footer.hidden=t===null,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&By(this.el,this._original))}};function Py(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function By(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function nh(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof y?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Vy(s){let t=String(s??"default").toLowerCase();return Ry.includes(t)?t:"default"}function wi(s,t){if(!s)throw new TypeError("dragAxis requires a handle element");if(typeof t?.onMove!="function")throw new TypeError("dragAxis requires an onMove callback");let e=t.orientation==="vertical",i=new AbortController,{signal:n}=i,r=!1,o=null,a=0,c=0,d=!1,u=0,h=w=>e?w.clientY:w.clientX,f=()=>!!t.disabled?.(),p=()=>{let w=o;if(o=null,w!==null)try{s.releasePointerCapture(w)}catch{}},_=()=>{u!==0&&(cancelAnimationFrame(u),u=0)},m=()=>{r=!1,d=!1,_(),p()};s.addEventListener("pointerdown",w=>{let v=w;if(!(f()||r||v.button!==0)&&t.onStart?.(v)!==!1){r=!0,o=v.pointerId,a=h(v),c=a,d=!1;try{s.setPointerCapture(v.pointerId)}catch{}}},{signal:n}),s.addEventListener("pointermove",w=>{let v=w;!r||v.pointerId!==o||(c=h(v),c!==a&&(d=!0),u===0&&(u=requestAnimationFrame(()=>{u=0,r&&t.onMove(c-a)})))},{signal:n});let b=w=>{let v=w;if(!r||v.pointerId!==o)return;_(),c=h(v);let z=d,C=c-a;m(),t.onEnd?.(C,z)};return s.addEventListener("pointerup",b,{signal:n}),s.addEventListener("pointercancel",b,{signal:n}),s.addEventListener("keydown",w=>{let v=w;if(f())return;if((v.key==="Enter"||v.key===" ")&&t.onActivate){v.preventDefault(),t.onActivate();return}if(v.key==="Home"||v.key==="End"){if(!t.onJump)return;v.preventDefault(),t.onJump(v.key==="Home"?"min":"max");return}let z=e?"ArrowUp":"ArrowLeft",C=e?"ArrowDown":"ArrowRight";v.key!==z&&v.key!==C||t.onStep&&(v.preventDefault(),t.onStep(v.key===C?1:-1,v.shiftKey))},{signal:n}),{isDragging:()=>r,cancel(){r&&m()},destroy(){m(),i.abort()}}}function _t(s,t){if(typeof s=="number")return Number.isFinite(s)?s:Number.NaN;if(typeof s!="string")return Number.NaN;let e=/^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)?$/i.exec(s.trim());if(!e)return Number.NaN;let i=Number(e[1]);if(!Number.isFinite(i))return Number.NaN;if((e[2]??"").toLowerCase()!=="%")return i;let n=Number(t);return Number.isFinite(n)?i/100*n:Number.NaN}var jy="split-view",qn=class extends y{static cssName="split-view";static defaults={orientation:"horizontal",start:null,end:null,size:"38%",min:160,max:null,collapsible:!1,collapsed:!1,snap:0,storageKey:null,disabled:!1,label:"Resize panes"};#t=null;#e=null;#i=null;constructor(t=null,e={}){super(t,e);let i=this.options.storageKey;if(i!=null&&i!==""){this.#e=ci(jy);let o=this.#e.get(String(i));typeof o=="number"&&Number.isFinite(o)&&o>=0&&this.setSize(o)}let n=this.options.collapsed;n==="start"||n==="end"?this.#o(n,!1):n===!0&&this.options.collapsible&&this.#o(this.options.collapsible==="end"?"end":"start",!1);let r=this.refs.divider;this.#i=wi(r,{orientation:this._orientation,disabled:()=>this._disabled,onStart:()=>{this._startSize=this.getSize(),this.el.dataset.dragging="true"},onMove:o=>this.#a(o,!1),onEnd:(o,a)=>{a&&this.#a(o,!0),delete this.el.dataset.dragging,a&&(this.#p(),this.#_())},onStep:(o,a)=>this.#c(o*(a?64:16)),onJump:o=>this.#l(o),onActivate:()=>{this.options.collapsible&&(this._collapsed===null?this.collapse(this.options.collapsible):this.expand())}}),this.listen(r,"dblclick",()=>this.#h()),typeof ResizeObserver=="function"&&(this.#t=new ResizeObserver(()=>this.#u()),this.#t.observe(this.el)),this.#n()}render(){let t=this.options;this._orientation=t.orientation==="vertical"?"vertical":"horizontal";let e=_t(t.size,Number.NaN);this._size=Number.isFinite(e)?Math.max(0,e):null,this._collapsed=null,this._disabled=!!t.disabled,this._destroyed=!1,this._startSize=0,this._lastTotal=-1,this._createdRoot=!this.el;let i=this.el??l("div");this.el=i,this._snapshot=this._createdRoot?null:A(i);let n=this._createdRoot||t.start!=null||t.end!=null?[]:Array.from(i.children),r=x("zx-split-start"),o=l("div",{class:"zx-split-view__pane",id:r,ref:"start",dataset:{pane:"start"}}),a=l("div",{class:"zx-split-view__divider",ref:"divider",role:"separator",tabindex:this._disabled?-1:0,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(t.label??"Resize panes"),ariaControls:r}),c=l("div",{class:"zx-split-view__pane",ref:"end",dataset:{pane:"end"}});return i.replaceChildren(o,a,c),i.dataset.orientation=this._orientation,this._disabled&&a.setAttribute("aria-disabled","true"),i.style.setProperty("--zx-split-size",Vn(t.size)),t.start!=null?jn(o,t.start,"SplitView start"):n[0]&&o.append(n[0]),t.end!=null?jn(c,t.end,"SplitView end"):n[1]&&c.append(...n.slice(1)),i}setSize(t){let{total:e,divider:i,min:n,max:r}=this.#s(),o=_t(t,e>0?e:Number.NaN);return Number.isFinite(o)?(this.#r(Kt({size:o,min:n,max:r,total:e,divider:i})),this):(this._size=null,this.el.style.setProperty("--zx-split-size",Vn(t)),this.#n(),this)}getSize(){if(this._collapsed==="start")return 0;let{total:t,divider:e}=this.#s();if(this._collapsed==="end")return Math.max(0,t-e);if(this._size!==null)return this._size;let i=rh(this.refs.start,this._orientation);if(i>0)return i;let n=_t(this.options.size,t);return Number.isFinite(n)?Math.max(0,n):0}getRatio(){let{total:t}=this.#s();return t>0?this.getSize()/t:0}setStart(t){return jn(this.refs.start,t,"SplitView start"),this}setEnd(t){return jn(this.refs.end,t,"SplitView end"),this}collapse(t){let e=this.options.collapsible==="end"?"end":"start";return this.#o(t==="end"?"end":t==="start"?"start":e,!0)}expand(){return this._collapsed===null?this:(this._collapsed=null,delete this.el.dataset.collapsed,this.#n(),this.emit("expand"),this)}isCollapsed(){return this._collapsed??!1}enable(){return this._disabled=!1,this.refs.divider.removeAttribute("aria-disabled"),this.refs.divider.setAttribute("tabindex","0"),this}disable(){return this._disabled=!0,this.#i?.cancel(),delete this.el.dataset.dragging,this.refs.divider.setAttribute("aria-disabled","true"),this.refs.divider.setAttribute("tabindex","-1"),this}isDisabled(){return this._disabled}destroy(){this._destroyed||(this._destroyed=!0,this.#i?.destroy(),this.#i=null,this.#t?.disconnect(),this.#t=null,super.destroy(),!this._createdRoot&&this._snapshot&&S(this.el,this._snapshot))}#s(){let t=this.el,e=this._orientation==="vertical"?t.clientHeight:t.clientWidth,i=this.options.max==null?null:Number(this.options.max);return{total:Number.isFinite(e)&&e>0?e:0,divider:rh(this.refs.divider,this._orientation),min:Math.max(0,Number(this.options.min)||0),max:Number.isFinite(i)?i:null}}#r(t){this._size=t,this.el.style.setProperty("--zx-split-size",`${t}px`),this.#n()}#n(){let{total:t,divider:e,min:i,max:n}=this.#s(),r=Hn({min:i,max:n,total:t,divider:e}),o=this.refs.divider;o.setAttribute("aria-valuemin",String(Math.round(r.min))),o.setAttribute("aria-valuemax",String(Math.round(r.max))),o.setAttribute("aria-valuenow",String(Math.round(this.getSize())))}#o(t,e){return this._collapsed===t?this:(this._collapsed=t,this.el.dataset.collapsed=t,this.#n(),e&&this.emit("collapse",{pane:t}),this)}#a(t,e){if(this._destroyed)return;let{total:i,divider:n,min:r,max:o}=this.#s();if(i<=0)return;this._collapsed!==null&&this.expand();let a=Kt({size:this._startSize+t,min:r,max:o,total:i,divider:n});e&&(a=Kt({size:$a(a,this.#f(i,n),Number(this.options.snap)),min:r,max:o,total:i,divider:n})),a!==this._size&&(this.#r(a),this.emit("resize",{size:a,ratio:a/i}))}#c(t){let{total:e,divider:i,min:n,max:r}=this.#s();e<=0||(this._collapsed!==null&&this.expand(),this.#d(Kt({size:this.getSize()+t,min:n,max:r,total:e,divider:i}),e))}#l(t){let{total:e,divider:i,min:n,max:r}=this.#s();if(e<=0)return;this._collapsed!==null&&this.expand();let o=Hn({min:n,max:r,total:e,divider:i});this.#d(Kt({size:o[t],min:n,max:r,total:e,divider:i}),e)}#d(t,e){t!==this._size&&(this.#r(t),this.emit("resize",{size:t,ratio:t/e}),this.#p(),this.#_())}#f(t,e){let{min:i,max:n}=this.#s(),r=Hn({min:i,max:n,total:t,divider:e}),o=[r.min,r.max],a=_t(this.options.size,t);return Number.isFinite(a)&&o.unshift(a),o}#h(){if(this._disabled)return;this._collapsed!==null&&this.expand();let t=_t(this.options.size,Number.NaN);Number.isFinite(t)?this.setSize(t):(this._size=null,this.el.style.setProperty("--zx-split-size",Vn(this.options.size)),this._lastTotal=-1,this.#u());let{total:e}=this.#s(),i=this.getSize();this.emit("resize",{size:i,ratio:e>0?i/e:0}),this.#p(),this.#_()}#u(){if(this._destroyed||this.#i?.isDragging())return;let{total:t,divider:e,min:i,max:n}=this.#s();if(t<=0||t===this._lastTotal)return;if(this._lastTotal=t,this._size===null){let o=_t(this.options.size,t);if(Number.isFinite(o)){let a=Kt({size:o,min:i,max:n,total:t,divider:e});this.el.style.setProperty("--zx-split-size",Math.abs(a-o)>.5?`${a}px`:Vn(this.options.size))}this.#n();return}let r=Kt({size:this._size,min:i,max:n,total:t,divider:e});if(r===this._size){this.#n();return}this.#r(r),this.emit("resize",{size:r,ratio:r/t})}#p(){let t=this.options.storageKey;!this.#e||t==null||t===""||(this._size===null?this.#e.remove(String(t)):this.#e.set(String(t),Math.round(this._size)))}#_(){let{total:t}=this.#s(),e=this.getSize();this.emit("resizeend",{size:e,ratio:t>0?e/t:0})}};function Kt({size:s,min:t=0,max:e=null,total:i=0,divider:n=0}){let r=Number(s),o=Hn({min:t,max:e,total:i,divider:n});return Math.max(0,(Number(i)||0)-Math.max(0,Number(n)||0))>0?Number.isFinite(r)?Math.min(o.max,Math.max(o.min,r)):o.min:Number.isFinite(r)?Math.max(0,r):o.min}function $a(s,t,e){let i=Number(s),n=Number(e);if(!Number.isFinite(i)||!Number.isFinite(n)||n<=0)return i;let r=Array.isArray(t)?t:t==null?[]:[t],o=i,a=Number.POSITIVE_INFINITY;for(let c of r){let d=Number(c);if(!Number.isFinite(d))continue;let u=Math.abs(d-i);u<=n&&u<a&&(a=u,o=d)}return o}function Hn({min:s=0,max:t=null,total:e=0,divider:i=0}){let n=Math.max(0,(Number(e)||0)-Math.max(0,Number(i)||0)),r=t==null||!Number.isFinite(Number(t))?n:Math.min(n,Math.max(0,Number(t)));return{min:Math.min(Math.max(0,Number(s)||0),r),max:r}}function rh(s,t){let e=s.getBoundingClientRect(),i=t==="vertical"?e.height:e.width;return Number.isFinite(i)&&i>0?i:0}function Vn(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function jn(s,t,e){if(s.replaceChildren(),t==null)return;if(typeof t=="string"||typeof t=="number"){s.append(document.createTextNode(String(t)));return}let i=t instanceof y?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Hy="dock",$n=class extends y{static cssName="dock";static defaults={orientation:"vertical",content:null,panes:[],resizable:!0,collapsible:!0,lazy:!0,storageKey:null,label:"Resize panes"};constructor(t=null,e={}){super(t,e);let i=this.options.storageKey;if(i!=null&&i!==""){this._store=ci(Hy);let n=this._store.get(String(i));n&&typeof n=="object"&&this.setState(n)}this._syncGrow(),this._syncDividers()}render(){let t=this.options;this._orientation=t.orientation==="horizontal"?"horizontal":"vertical",this._resizable=t.resizable!==!1,this._lazy=t.lazy!==!1,this._destroyed=!1,this._panes=new Map,this._store=null,this._drag=null,this._dividerDrags=[],this._createdRoot=!this.el;let e=this.el??l("div");this.el=e,this._snapshot=this._createdRoot?null:A(e),e.dataset.orientation=this._orientation,e.replaceChildren(),this._content=t.content==null?null:l("div",{class:"zx-dock__content",ref:"content"}),this._content&&Ua(this._content,t.content,!1);for(let i of Array.isArray(t.panes)?t.panes:[])this._panes.set(String(i.name),this._buildPane(i));return this._layout(),e}pane(t){return this._panes.get(String(t))??null}names(){return[...this._panes.keys()]}add(t,e={}){let i=String(t?.name??"");if(!i)throw new TypeError("Dock pane requires a name");this._panes.has(i)&&this.remove(i);let n=this._buildPane(t),r=[...this._panes.entries()],o=Number.isInteger(e.index)?q(Number(e.index),0,r.length):r.length;return r.splice(o,0,[i,n]),this._panes=new Map(r),this._layout(),this._syncGrow(),this._syncDividers(),n}remove(t){let e=this._panes.get(String(t));return e?e.kind==="sheet"?this.release(e.sheet):(e.roving?.destroy(),e.element.remove(),this._panes.delete(String(t)),this._layout(),this._syncGrow(),this._syncDividers(),this):this}collapse(t){let e=this._panes.get(String(t));return!e||!e.collapsible||e.collapsed?this:(e.collapsed=!0,this._syncPaneState(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("collapse",{name:e.name}),this)}expand(t){let e=this._panes.get(String(t));return!e||!e.collapsed?this:(e.collapsed=!1,this._syncPaneState(e),this._materialize(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("expand",{name:e.name}),this)}toggle(t){let e=this._panes.get(String(t));return e?e.collapsed?this.expand(t):this.collapse(t):this}isCollapsed(t){return!!this._panes.get(String(t))?.collapsed}reveal(t){let e=String(t),i=this._panes.get(e);if(i)this.expand(e);else for(let n of this._panes.values())if(n.tabs?.has(e)){i=n,this.expand(n.name),this.activate(n.name,e);break}return i?(i.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.emit("reveal",{name:i.name}),this):this}setSize(t,e){let i=this._panes.get(String(t));if(!i)return this;let n=Ka(e);return n===null?i.element.style.removeProperty("--zx-pane-size"):i.element.style.setProperty("--zx-pane-size",n),this._syncDividers(),this._persist(),this}getSize(t){let e=this._panes.get(String(t));return e?this._axisSize(e.element):0}activate(t,e){let i=this._panes.get(String(t)),n=i?.tabs?.get(String(e));if(!n||i.active===n.name)return this;let r=i.active;i.active=n.name;for(let o of i.tabs.values()){let a=o===n;o.tab.setAttribute("aria-selected",String(a)),o.tab.tabIndex=a?0:-1,o.panel.hidden=!a}return this._materialize(i),this._persist(),this.emit("tabchange",{pane:i.name,tab:n.name,previous:r}),this}getActive(t){return this._panes.get(String(t))?.active??null}state(){let t={sizes:{},collapsed:[],active:{}};for(let e of this._panes.values())if(e.kind!=="sheet"){if(e.collapsed)t.collapsed.push(e.name);else if(!e.grow){let i=this._axisSize(e.element);i>0&&(t.sizes[e.name]=i)}e.active&&(t.active[e.name]=e.active)}return t}setState(t){if(!t||typeof t!="object")return this;let e=new Set(Array.isArray(t.collapsed)?t.collapsed.map(String):[]);for(let i of this._panes.values()){if(i.kind==="sheet")continue;let n=t.sizes?.[i.name];typeof n=="number"&&Number.isFinite(n)&&n>0&&i.element.style.setProperty("--zx-pane-size",`${n}px`);let r=t.active?.[i.name];r&&i.tabs?.has(String(r))&&this.activate(i.name,String(r));let o=e.has(i.name);o!==i.collapsed&&i.collapsible&&(i.collapsed=o,this._syncPaneState(i))}return this._syncGrow(),this._syncDividers(),this}destroy(){if(!this._destroyed){this._destroyed=!0;for(let t of this._dividerDrags)t.destroy();this._dividerDrags=[];for(let t of this._panes.values())t.roving?.destroy(),t.breakpoint?.destroy(),t.kind==="sheet"&&t.sheet._setDock(null);super.destroy(),!this._createdRoot&&this._snapshot&&S(this.el,this._snapshot)}}_buildPane(t){let e=String(t.name),i=String(t.title??""),n=t.collapsible??this.options.collapsible!==!1,r=x("zx-dock-body"),o=Array.isArray(t.tabs)&&t.tabs.length>0,a=l("span",{class:"zx-dock__chevron",ariaHidden:"true"},g("chevron-right",{size:14})),c=l("button",{class:"zx-dock__toggle",type:"button",ariaControls:r,ariaExpanded:"true",ariaLabel:o?i||e:null},a,o?null:l("span",{class:"zx-dock__title"},i));n||(c.disabled=!0);let d=l("div",{class:"zx-dock__header"},c),u=l("div",{class:"zx-dock__body",id:r}),h=l("section",{class:"zx-dock__pane",dataset:{name:e,state:"open"}},d,u),f={name:e,title:i,element:h,header:d,body:u,toggle:c,collapsible:n,collapsed:!1,grow:!!t.grow,side:t.side==="end"?"end":"start",min:Number.isFinite(t.min)?Math.max(0,Number(t.min)):0,tabs:null,active:null,content:null,built:!1,roving:null};if(o){f.tabs=new Map;let _=l("div",{class:"zx-dock__tabs",role:"tablist",ariaOrientation:"horizontal",ariaLabel:i||e});for(let w of t.tabs){let v=String(w.name),z=x("zx-dock-tab"),C=x("zx-dock-panel"),k=l("button",{class:"zx-dock__tab",type:"button",role:"tab",id:z,ariaControls:C,ariaSelected:"false",tabindex:-1},String(w.title??v)),M=l("div",{class:"zx-dock__panel",role:"tabpanel",id:C,ariaLabelledby:z,tabindex:0,hidden:!0});_.append(k),u.append(M),f.tabs.set(v,{name:v,tab:k,panel:M,content:w.content,built:!1})}d.append(_),f.roving=Mt(_,".zx-dock__tab",{orientation:"horizontal"}),this.listen(_,"click",w=>{let v=w.target.closest?.(".zx-dock__tab");if(!v||!_.contains(v))return;let z=[...f.tabs.values()].find(C=>C.tab===v);z&&this.activate(f.name,z.name)});let m=String(t.active??""),b=f.tabs.has(m)?m:[...f.tabs.keys()][0];f.active=b;for(let w of f.tabs.values()){let v=w.name===b;w.tab.setAttribute("aria-selected",String(v)),w.tab.tabIndex=v?0:-1,w.panel.hidden=!v}}else f.content=l("div",{class:"zx-dock__pane-content"}),u.append(f.content),f.factory=t.content;let p=Ka(t.size);return p!==null&&h.style.setProperty("--zx-pane-size",p),n&&this.listen(c,"click",()=>this.toggle(f.name)),t.collapsed&&n&&(f.collapsed=!0,this._syncPaneState(f)),(!this._lazy||!f.collapsed)&&this._materialize(f),f}_materialize(t){if(!t.collapsed){if(t.tabs){let e=t.tabs.get(t.active);if(!e||e.built)return;e.built=!0,Ua(e.panel,e.content,!0);return}t.built||(t.built=!0,Ua(t.content,t.factory,!0))}}_layout(){let t=[...this._panes.values()].filter(n=>n.kind!=="sheet"||n.sheet.isDocked()),e=this._content?[...t.filter(n=>n.side==="start"),this._content,...t.filter(n=>n.side==="end")]:t;for(let n of this._dividerDrags)n.destroy();this._dividerDrags=[];let i=[];e.forEach((n,r)=>{r>0&&i.push(this._divider()),i.push(n instanceof Element?n:n.element)}),this.el.replaceChildren(...i)}_divider(){let t=l("div",{class:"zx-dock__divider",role:"separator",tabindex:this._resizable?0:-1,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(this.options.label??"Resize panes")});return this._dividerDrags.push(wi(t,{orientation:this._orientation,disabled:()=>!this._resizable,onStart:()=>{let{before:e,after:i}=this._neighbours(t),n=this._resizeSubject(e,i);return n?(this._drag={subject:n,startSize:this._axisSize(n.element),oppositeStart:n.opposite?this._axisSize(n.opposite.element):0},this.el.dataset.dragging="true",!0):!1},onMove:e=>this._trackDelta(e),onEnd:(e,i)=>{i&&this._trackDelta(e),this._drag=null,delete this.el.dataset.dragging,i&&this._persist()},onStep:(e,i)=>this._stepDivider(t,e*(i?64:16)),onActivate:()=>{let{before:e}=this._neighbours(t);e?.collapsible&&this.toggle(e.name)}})),t}_isHidden(t){return t.kind==="sheet"?!t.sheet.isOpen():!!t.collapsed}adopt(t,e={}){if(!t||typeof t._setDock!="function"||!t.el)throw new TypeError("Dock.adopt expects a Sheet");let i=String(e.name??t.el.id??"")||x("zx-dock-sheet"),n={kind:"sheet",name:i,sheet:t,element:t.el,side:e.side==="end"?"end":"start",min:Number.isFinite(e.min)?Math.max(0,Number(e.min)):0,grow:!1,collapsed:!1,collapsible:!1,breakpoint:null,resync:null},r=[...this._panes.entries()],o=Number.isInteger(e.index)?q(Number(e.index),0,r.length):r.length;r.splice(o,0,[i,n]),this._panes=new Map(r);let a=Ka(e.size);a!==null&&t.el.style.setProperty("--zx-pane-size",a),n.resync=()=>{this._syncGrow(),this._syncDividers()},t.on("open",n.resync),t.on("close",n.resync);let c=e.dockAt??null;return c?n.breakpoint=ni((d,u)=>{this._applyDockAt(n,bn(c,u))},{target:this.el}):this._applyDockAt(n,!0),n}release(t){let e=[...this._panes.values()].find(i=>i.sheet===t);return e?(e.breakpoint?.destroy(),e.breakpoint=null,this._panes.delete(e.name),t.off("open",e.resync),t.off("close",e.resync),t.el.style.removeProperty("--zx-pane-size"),t._setDock(null),this._layout(),this._syncGrow(),this._syncDividers(),this):this}_forget(t){let e=[...this._panes.values()].find(i=>i.sheet===t);e&&(e.breakpoint?.destroy(),this._panes.delete(e.name),!this._destroyed&&(this._layout(),this._syncGrow(),this._syncDividers()))}_applyDockAt(t,e){t.sheet.isDocked()!==e&&(t.sheet._setDock(e?this:null),this._layout(),this._syncGrow(),this._syncDividers())}_syncGrow(){let t=[...this._panes.values()];for(let n of t)n.element.removeAttribute("data-grow");if(this._content)return;let e=t.filter(n=>!this._isHidden(n));if(e.length===0)return;let i=e.find(n=>n.grow);(i??e[e.length-1]).element.dataset.grow="true"}_syncDividers(){for(let t of this._dividers()){let{before:e,after:i}=this._neighbours(t),n=this._resizeSubject(e,i),r=this._resizable&&n!==null;if(t.toggleAttribute("data-disabled",!r),t.tabIndex=r?0:-1,!r){t.removeAttribute("aria-valuenow");continue}let o=this._axisSize(this.el);t.setAttribute("aria-valuenow",String(Math.round(this._axisSize(n.element)))),t.setAttribute("aria-valuemin",String(Math.round(this._minSize(n)))),t.setAttribute("aria-valuemax",String(Math.round(o))),t.setAttribute("aria-controls",n.element.id||qy(n.element))}}_syncPaneState(t){t.element.dataset.state=t.collapsed?"collapsed":"open",t.toggle.setAttribute("aria-expanded",String(!t.collapsed))}_dividers(){return[...this.el.querySelectorAll(":scope > .zx-dock__divider")]}_neighbours(t){let e=i=>{if(!i)return null;for(let n of this._panes.values())if(n.element===i)return n;return null};return{before:e(t.previousElementSibling),after:e(t.nextElementSibling)}}_resizeSubject(t,e){let i=n=>!!n&&!this._isHidden(n)&&n.element.dataset.grow!=="true";return i(t)?{element:t.element,record:t,sign:1,opposite:i(e)?e:null}:i(e)?{element:e.element,record:e,sign:-1,opposite:null}:null}_minSize(t){let i=(t.record.header??t.record.element.querySelector(".zx-dialog__header")??t.record.element).getBoundingClientRect(),n=this._orientation==="vertical"?i.height:i.width;return Math.max(t.record.min,n)}_axisSize(t){let e=t.getBoundingClientRect();return this._orientation==="vertical"?e.height:e.width}_trackDelta(t){if(!this._drag||this._destroyed)return;let{subject:e,startSize:i,oppositeStart:n}=this._drag,r=this._minSize(e),o=Math.max(r,i+t*e.sign);if(e.opposite){let a=this._minSize({record:e.opposite,element:e.opposite.element});o=Math.max(r,Math.min(o,i+n-a)),e.opposite.element.style.setProperty("--zx-pane-size",`${i+n-o}px`)}e.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this.emit("resize",{name:e.record.name,size:o})}_stepDivider(t,e){let{before:i,after:n}=this._neighbours(t),r=this._resizeSubject(i,n);if(!r)return;let o=Math.max(this._minSize(r),this._axisSize(r.element)+e*r.sign);r.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this._persist(),this.emit("resize",{name:r.record.name,size:o})}_persist(){let t=this.options.storageKey;!this._store||t===null||t===void 0||t===""||this._store.set(String(t),this.state())}};function qy(s){let t=x("zx-dock-pane");return s.id=t,t}function Ka(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}function Ua(s,t,e){let i=e&&typeof t=="function"?t():t;if(i==null)return;if(typeof i=="string"||typeof i=="number"){s.append(document.createTextNode(String(i)));return}let n=i instanceof y?i.toElement():i;n&&typeof n.nodeType=="number"&&s.append(n)}var Kn="44rem",ah=/^\d+(?:\.\d+)?(?:px|rem)$/,Un=class extends y{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[],overflow:!0,overflowBelow:Kn,minVisible:0};constructor(t,e={}){super(t,e),this._overflow=new at(this.refs.moreTrigger,{label:"More",icon:"dots",kind:"ghost",items:[],placement:"bottom-end"}),this._overflow.on("select",i=>{let n=this._find(String(i.detail.value));!n||n.definition.disabled||(this.setActive(n.definition.name),n.definition.onselect?.(n.definition.name,n.definition,this),n.definition.href&&globalThis.location?.assign(n.definition.href))}),this._syncOverflow(),this._observeWidth()}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:Yy(e),this._cleaned=!1,this._items=[],this._activeName=null,this._tabMode=!1,this._overflow=null,this._observer=null,this._frame=0;let i=l("header",{class:"zx-navigation-bar__bar"},l("div",{class:"zx-navigation-bar__brand",ref:"title"}),l("nav",{class:"zx-navigation-bar__navigation",ariaLabel:"Primary navigation"},l("div",{class:"zx-navigation-bar__items",ref:"items"}),l("div",{class:"zx-navigation-bar__more",ref:"more"},l("button",{class:"zx-navigation-bar__more-trigger",ref:"moreTrigger"}))),l("div",{class:"zx-navigation-bar__actions",ref:"actions",role:"group",ariaLabel:"Application actions"})),n=l("div",{class:"zx-navigation-bar__panels",ref:"panels",hidden:!0});return e.replaceChildren(i,n),this.setTitle(this.options.title),this.setItems(this.options.items),this.setActions(this.options.actions),this.listen(this.refs.items,"keydown",r=>this._onTabKeydown(r)),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setItems(t){if(!Array.isArray(t))throw new TypeError("NavigationBar items must be an array");let e=this._activeName,i=new Set,n=t.map(d=>{if(!d||typeof d!="object"||Array.isArray(d))throw new TypeError("Navigation item must be an object");if(typeof d.name!="string"||d.name==="")throw new TypeError("Navigation item name must be a non-empty string");if(i.has(d.name))throw new RangeError(`Navigation item already exists: ${d.name}`);if(i.add(d.name),Object.hasOwn(d,"content")&&!Uy(d.content))throw new TypeError(`Navigation panel content for ${d.name} is invalid`);let u={name:d.name,title:String(d.title??""),badge:d.badge==null?null:String(d.badge),href:d.href==null?void 0:String(d.href),disabled:!!d.disabled,onselect:typeof d.onselect=="function"?d.onselect:void 0};return Object.hasOwn(d,"content")&&(u.content=d.content),u}),r=n.some(d=>Object.hasOwn(d,"content"));if(r&&n.some(d=>!Object.hasOwn(d,"content")))throw new TypeError("NavigationBar panel items must all define content");this._items=[],this._activeName=null,this._tabMode=r,this.refs.items.replaceChildren(),this.refs.panels.replaceChildren(),this.refs.panels.hidden=!this._tabMode,this._tabMode?(this.refs.items.setAttribute("role","tablist"),this.refs.items.setAttribute("aria-orientation","horizontal")):(this.refs.items.removeAttribute("role"),this.refs.items.removeAttribute("aria-orientation"));for(let d of n)this._appendItem(d);let o=e??this.options.active,a=o===null?null:this._find(o),c=a&&!a.definition.disabled?a:this._enabledItems()[0];return c&&this._applyActive(c),this._syncOverflow(),this}setActive(t){let e=this._find(t);return!e||e.definition.disabled||t===this._activeName?this:(this._applyActive(e),this.emit("change",{name:e.definition.name}),this)}setBadge(t,e){let i=this._require(t);return i.definition.badge=e===null?null:String(e),i.badge.textContent=i.definition.badge??"",i.badge.hidden=i.definition.badge===null,this._syncOverflow(),this}setActions(t){if(!Array.isArray(t))throw new TypeError("NavigationBar actions must be an array");let e=t.map(i=>{if(E(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("NavigationBar actions must be Elements or button descriptors");let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.actions.replaceChildren(...e),this}destroy(){this._cleaned||(this._cleaned=!0,this._frame&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this._frame),this._frame=0,this._observer?.disconnect(),this._observer=null,this._overflow?.destroy(),super.destroy(),!this._createdRoot&&this._original&&Wy(this.el,this._original))}_appendItem(t){let e=x("zx-navigation-item"),i=x("zx-navigation-panel"),n=l("span",{class:"zx-navigation-bar__badge",hidden:t.badge===null},t.badge??""),r={class:"zx-navigation-bar__item",id:e,ariaDisabled:t.disabled?"true":null},o;this._tabMode?o=l("button",{...r,type:"button",role:"tab",tabindex:"-1",ariaControls:i,ariaSelected:"false"},l("span",{class:"zx-navigation-bar__label"},t.title),n):t.href?o=l("a",{...r,href:t.href},l("span",{class:"zx-navigation-bar__label"},t.title),n):o=l("button",{...r,type:"button"},l("span",{class:"zx-navigation-bar__label"},t.title),n);let a=null;this._tabMode&&(a=l("div",{class:"zx-navigation-bar__panel",id:i,role:"tabpanel",tabindex:"0",ariaLabelledby:e,hidden:!0}),this.refs.panels.append(a));let c={definition:t,item:o,badge:n,panel:a,built:!1};this._items.push(c),this.refs.items.append(o),this.listen(o,"click",d=>{if(c.definition.disabled){d.preventDefault();return}this.setActive(c.definition.name),c.definition.onselect?.(c.definition.name,c.definition,this)})}_applyActive(t){this._tabMode&&this._ensurePanel(t);for(let e of this._items){let i=e===t;this._tabMode?(e.item.setAttribute("aria-selected",String(i)),e.item.tabIndex=i?0:-1,e.panel&&(e.panel.hidden=!i)):i?e.item.setAttribute("aria-current","page"):e.item.removeAttribute("aria-current")}this._activeName=t.definition.name}_ensurePanel(t){if(!t.panel||t.built)return;let e=t.definition.content,i=typeof e=="function"?e():e,n=i instanceof y?i.toElement():i;if(!n||typeof n.nodeType!="number")throw new TypeError(`Navigation panel factory for ${t.definition.name} must return a Node or Component`);t.panel.append(n),t.built=!0}_onTabKeydown(t){if(!this._tabMode)return;let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.items.contains(e))return;let i=this._items.find(r=>r.item===e);if(!i)return;let n=this._enabledItems();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(i),a=n[(o+r+n.length)%n.length];a&&this._focusTab(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let r=t.key==="Home"?n[0]:n[n.length-1];r&&this._focusTab(r);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.setActive(i.definition.name))}_syncOverflow(){let t=oh(this.options),e=t===null?this._items.length:$y(this.options,this._items.length),i=this._items.slice(e),n=this.el;for(let[r,o]of this._items.entries())o.item.dataset.collapsed=String(r>=e);n.dataset.overflow=t===null?"off":e===0?"all":"partial",t===null||t===Kn?delete n.dataset.overflowBelow:n.dataset.overflowBelow=t,this._overflow&&(this.refs.more.dataset.empty=i.length===0?"true":"false",this._overflow.setItems(i.map(r=>({label:r.definition.badge===null?r.definition.title:`${r.definition.title} (${r.definition.badge})`,value:r.definition.name,disabled:r.definition.disabled}))))}_observeWidth(){let t=oh(this.options);if(t===null||t===Kn||typeof ResizeObserver!="function")return;let e=this.el,i=()=>{let n=e.getBoundingClientRect().width;if(!n)return;let r=globalThis.document?.documentElement,o=r?Number.parseFloat(globalThis.getComputedStyle(r).fontSize):Number.NaN;e.dataset.narrow=String(n<=Ky(t,o))};this._observer=new ResizeObserver(()=>{if(this._frame||typeof requestAnimationFrame!="function"){typeof requestAnimationFrame!="function"&&i();return}this._frame=requestAnimationFrame(()=>{this._frame=0,i()})}),this._observer.observe(e),i()}_focusTab(t){for(let e of this._items)e.item.tabIndex=e===t?0:-1;t.item.focus()}_enabledItems(){return this._items.filter(t=>!t.definition.disabled)}_find(t){return this._items.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown navigation item: ${t}`);return e}};function oh(s={}){let t=s.overflow??!0;if(typeof t!="boolean")throw new TypeError("NavigationBar overflow must be a boolean");let e=s.overflowBelow??Kn;if(!t||e===!1)return null;if(typeof e=="number"){if(!Number.isFinite(e)||e<0)throw new RangeError(`NavigationBar overflowBelow must not be negative: ${e}`);return`${e}px`}if(typeof e!="string"||!ah.test(e.trim()))throw new TypeError(`NavigationBar overflowBelow must be a px or rem length, a number of pixels, or false: ${String(e)}`);return e.trim()}function $y(s={},t=0){let e=s.minVisible??0;if(!Number.isInteger(e)||e<0)throw new TypeError(`NavigationBar minVisible must be a non-negative integer: ${String(e)}`);let i=Number.isInteger(t)&&t>0?t:0;return Math.min(e,i)}function Ky(s,t=16){let e=typeof s=="number"?`${s}px`:String(s).trim();if(!ah.test(e))throw new TypeError(`NavigationBar cannot measure the length "${String(s)}"`);let i=Number.parseFloat(e);if(!e.endsWith("rem"))return i;let n=Number(t);return i*(Number.isFinite(n)&&n>0?n:16)}function Uy(s){return typeof s=="function"||s instanceof y?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Yy(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Wy(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function ch(s){if(!Array.isArray(s))throw new TypeError("Stepper steps must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Step definition must be an object");if(typeof e.name!="string"||e.name==="")throw new TypeError("Step name must be a non-empty string");if(t.has(e.name))throw new RangeError(`Step already exists: ${e.name}`);return t.add(e.name),{name:e.name,title:String(e.title??""),description:e.description==null?null:String(e.description),optional:!!e.optional,disabled:!!e.disabled}})}function Yn(s,t){return t===null?-1:s.findIndex(e=>e.name===t)}function Wn(s,t,e){let i=e<0?-1:1,n=t<0?i>0?0:s.length-1:t+i;for(;n>=0&&n<s.length;){if(!s[n].disabled)return n;n+=i}return-1}function dh(s,t,e){return t<0||e<=t?[]:s.slice(t,e).map(i=>i.name)}function uh(s,t,e={}){let{activeIndex:i=-1,completed:n,errored:r}=e;return lh(r,s.name)?"error":t===i?"active":lh(n,s.name)?"complete":"upcoming"}function lh(s,t){return s?s instanceof Set?s.has(t):s.includes(t):!1}var Gy=new Set(["horizontal","vertical"]),Qy=new Set(["completed","all",!1]),Gn=class extends y{static cssName="stepper";static defaults={steps:[],active:null,orientation:"horizontal",clickable:"completed",showNumbers:!0,counter:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._steps=[],this._records=[],this._activeIndex=-1,this._completed=new Set,this._errored=new Set,!Gy.has(this.options.orientation))throw new RangeError(`Unknown stepper orientation: ${this.options.orientation}`);if(!Qy.has(this.options.clickable))throw new RangeError(`Unknown stepper clickable mode: ${this.options.clickable}`);let t=this.el??l("div");this.el=t,t.dataset.orientation=this.options.orientation;let e=l("p",{class:"zx-stepper__counter",ref:"counter",ariaLive:"polite",hidden:!0}),i=l("ol",{class:"zx-stepper__list",ref:"list"});return t.replaceChildren(...this.options.counter?[e,i]:[i]),this.setSteps(this.options.steps),this.listen(i,"click",n=>{let r=n.target.closest?.(".zx-stepper__control");if(!r||!i.contains(r)||r.tagName!=="BUTTON")return;let o=r.dataset.step;typeof o=="string"&&this.goTo(o)}),t}setSteps(t){let e=this.getActive(),i=ch(t),n=new Set(i.map(a=>a.name));this._steps=i,this._completed=new Set([...this._completed].filter(a=>n.has(a))),this._errored=new Set([...this._errored].filter(a=>n.has(a)));let r=e??(this.options.active===null?null:String(this.options.active)),o=r===null?-1:Yn(i,r);return o>=0&&i[o].disabled&&(o=-1),o<0&&(o=Wn(i,-1,1)),this._activeIndex=o,this._records=i.map(a=>this._createRecord(a)),this.refs.list.replaceChildren(...this._records.map(a=>a.item)),this._sync(),this}goTo(t){let e=Yn(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._activate(e)}next(){return this._activate(Wn(this._steps,this._activeIndex,1))}previous(){return this._activate(Wn(this._steps,this._activeIndex,-1))}getActive(){return this._activeIndex<0?null:this._steps[this._activeIndex].name}getIndex(){return this._activeIndex}complete(t){return this._require(t),this._completed.add(t),this._sync(),this}uncomplete(t){return this._require(t),this._completed.delete(t),this._sync(),this}setError(t,e=!0){return this._require(t),e?this._errored.add(t):this._errored.delete(t),this._sync(),this}setDisabled(t,e=!0){return this._require(t).disabled=!!e,this._sync(),this}getState(){return{active:this.getActive(),index:this._activeIndex,completed:this._steps.filter(t=>this._completed.has(t.name)).map(t=>t.name),errored:this._steps.filter(t=>this._errored.has(t.name)).map(t=>t.name)}}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_activate(t){if(t<0||t>=this._steps.length||t===this._activeIndex)return this;let e=this._steps[t];if(e.disabled)return this;let i=this._activeIndex;if(this.emit("change",{name:e.name,previous:i<0?null:this._steps[i].name,index:t}).defaultPrevented)return this;for(let r of dh(this._steps,i,t))this._completed.add(r);return this._activeIndex=t,this._sync(),this}_createRecord(t){let e=l("span",{class:"zx-stepper__marker",ariaHidden:"true"}),i=l("span",{class:"zx-stepper__status"}),n=[l("span",{class:"zx-stepper__title"},t.title)];t.description&&n.push(l("span",{class:"zx-stepper__description"},t.description)),t.optional&&n.push(l("span",{class:"zx-stepper__optional"},this._message("stepper.optional","Optional")));let r=[e,l("span",{class:"zx-stepper__text"},n),i],o=this.options.clickable===!1?l("span",{class:"zx-stepper__control"},r):l("button",{class:"zx-stepper__control",type:"button",dataset:{step:t.name}},r);return{step:t,item:l("li",{class:"zx-stepper__step"},o),control:o,marker:e,status:i}}_sync(){this._records.forEach((t,e)=>{let i=this._stateFor(t.step,e);t.item.dataset.state=i,e===this._activeIndex?t.item.setAttribute("aria-current","step"):t.item.removeAttribute("aria-current"),t.item.toggleAttribute("data-disabled",t.step.disabled),t.marker.replaceChildren(...this._markerContent(i,e)),t.status.textContent=this._statusText(i),t.control.tagName==="BUTTON"&&(t.control.disabled=!this._isClickable(t.step))}),this._syncCounter()}_stateFor(t,e){return uh(t,e,{activeIndex:this._activeIndex,completed:this._completed,errored:this._errored})}_markerContent(t,e){return t==="complete"?[g("check",{size:12})]:t==="error"?[g("warning",{size:12})]:this.options.showNumbers?[String(e+1)]:[]}_statusText(t){return t==="complete"?this._message("stepper.completed","Completed"):t==="error"?this._message("stepper.error","Error"):t==="active"?this._message("stepper.current","Current step"):""}_isClickable(t){return t.disabled?!1:this.options.clickable==="all"?!0:this.options.clickable==="completed"?this._completed.has(t.name):!1}_syncCounter(){if(!this.options.counter)return;let t=this.refs.counter;t.hidden=this._activeIndex<0,t.textContent=this._activeIndex<0?"":this._message("stepper.counter","Step %1 of %2",this._activeIndex+1,this._steps.length)}_require(t){let e=Yn(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._steps[e]}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};var Xy=new Set(["chevron","slash"]),Qn=class extends y{static cssName="breadcrumb";static defaults={items:[],maxVisible:0,separator:"chevron",rootIcon:null};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._items=[],this._overflow=null,!Xy.has(this.options.separator))throw new RangeError(`Unknown breadcrumb separator: ${this.options.separator}`);let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("breadcrumb.label","Breadcrumb"));let e=l("ol",{class:"zx-breadcrumb__list",ref:"list"});return t.replaceChildren(e),this.setItems(this.options.items),this.listen(e,"click",i=>{let n=i.target.closest?.("[data-crumb]");!n||!e.contains(n)||this._select(n.dataset.crumb)}),t}setItems(t){if(!Array.isArray(t))throw new TypeError("Breadcrumb items must be an array");let e=new Set;return this._items=t.map(i=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Breadcrumb item must be an object");if(typeof i.name!="string"||i.name==="")throw new TypeError("Breadcrumb item name must be a non-empty string");if(e.has(i.name))throw new RangeError(`Breadcrumb item already exists: ${i.name}`);return e.add(i.name),{name:i.name,label:String(i.label??""),icon:i.icon?String(i.icon):null,href:i.href==null?null:String(i.href)}}),this._build(),this}getItems(){return this._items.map(t=>({...t}))}push(t){return this.setItems([...this._items,t])}pop(){if(this._items.length===0)return null;let t=this._items[this._items.length-1];return this.setItems(this._items.slice(0,-1)),t}truncateTo(t){let e=this._items.findIndex(i=>i.name===t);if(e<0)throw new RangeError(`Unknown breadcrumb item: ${t}`);return this.setItems(this._items.slice(0,e+1))}destroy(){if(this._destroyed)return;this._destroyed=!0,this._overflow?.destroy(),this._overflow=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_build(){let{head:t,hidden:e,tail:i}=this._split(),n=this._items[this._items.length-1]??null,r=[];for(let o of t)r.push(this._renderItem(o,o===n));e.length>0&&r.push(this._renderOverflow(e));for(let o of i)r.push(this._renderItem(o,o===n));this.refs.list.replaceChildren(...r.map((o,a)=>l("li",{class:"zx-breadcrumb__item"},a===0?o:[this._renderSeparator(),o]))),e.length===0&&this._overflow?.toElement().remove()}_split(){let t=this._items,e=Math.trunc(Number(this.options.maxVisible)||0);if(e<=0||t.length<=e)return{head:t,hidden:[],tail:[]};let i=Math.max(2,e);if(t.length<=i)return{head:t,hidden:[],tail:[]};let n=i-1;return{head:t.slice(0,1),hidden:t.slice(1,t.length-n),tail:t.slice(t.length-n)}}_renderItem(t,e){let i=[],n=t.icon??(t===this._items[0]?this.options.rootIcon:null);return n&&i.push(l("span",{class:"zx-breadcrumb__icon",ariaHidden:"true"},g(String(n),{size:13}))),i.push(l("span",{class:"zx-breadcrumb__label"},t.label)),e?l("span",{class:"zx-breadcrumb__current",ariaCurrent:"page"},i):t.href!==null?l("a",{class:"zx-breadcrumb__link",href:t.href,dataset:{crumb:t.name}},i):l("button",{class:"zx-breadcrumb__link",type:"button",dataset:{crumb:t.name}},i)}_renderOverflow(t){if(!this._overflow){this._overflow=new at(null,{label:"",icon:"dots",kind:"ghost",placement:"bottom-start"});let e=this._overflow.toElement();e.classList.add("zx-breadcrumb__more"),e.setAttribute("aria-label",this._message("breadcrumb.more","Show hidden levels")),this._overflow.on("select",i=>this._select(String(i.detail.value)))}return this._overflow.setItems(t.map(e=>({label:e.label,value:e.name,icon:e.icon??void 0}))),this._overflow.toElement()}_renderSeparator(){return l("span",{class:"zx-breadcrumb__separator",ariaHidden:"true"},this.options.separator==="slash"?"/":g("chevron-right",{size:11}))}_select(t){let e=this._items.findIndex(i=>i.name===t);e<0||this.emit("select",{name:this._items[e].name,item:{...this._items[e]},index:e})}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};var Jn="\u2026",Jy=new Set(["pages","loadmore"]);function Ga({page:s=1,pages:t=1,siblings:e=1,boundaries:i=1}={}){let n=Ce(t);if(n<=0)return[];let r=Wa(Ce(s)||1,1,n),o=Math.max(0,Ce(e)),a=Math.max(0,Ce(i)),c=a*2+o*2+3;if(n<=c)return Xn(1,n);let d=Xn(1,Math.min(a,n)),u=Xn(Math.max(n-a+1,a+1),n),h=Math.max(Math.min(r-o,n-a-o*2-1),a+2),f=Math.min(Math.max(r+o,a+o*2+2),u.length>0?u[0]-2:n-1);return[...d,...h>a+2?[Jn]:a+1<n-a?[a+1]:[],...Xn(h,f),...f<n-a-1?[Jn]:n-a>a?[n-a]:[],...u]}var Zn=class extends y{static cssName="pagination";static defaults={page:1,pageSize:25,total:0,pageSizes:[25,50,100],siblings:1,boundaries:1,showPageSize:!0,showSummary:!0,mode:"pages",disabled:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._pageSize=Ya(this.options.pageSize,25),this._total=Math.max(0,Ce(this.options.total)),this._page=Math.max(1,Ce(this.options.page)||1),this._disabled=!!this.options.disabled,this._sizeKey="",this._pageSizes=(Array.isArray(this.options.pageSizes)?this.options.pageSizes:[]).map(i=>Ya(i,0)).filter(i=>i>0),!Jy.has(this.options.mode))throw new RangeError(`Unknown pagination mode: ${this.options.mode}`);this._page=Wa(this._page,1,this._pageCount());let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("pagination.label","Pagination")),t.dataset.mode=this.options.mode;let e=[];return this.options.showSummary&&e.push(l("span",{class:"zx-pagination__summary",ref:"summary",ariaLive:"polite"})),this.options.showPageSize&&e.push(this._renderPageSize()),e.push(l("span",{class:"zx-pagination__spacer"})),e.push(this.options.mode==="pages"?this._renderPages():this._renderLoadMore()),t.replaceChildren(...e),this._sync(),this._wire(),t}setPage(t){return this.setState({page:t})}setTotal(t){return this.setState({total:t},{silent:!0})}setPageSize(t){return this.setState({pageSize:t,page:1})}setState(t={},{silent:e=!1}={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pagination state must be an object");let i=this._page,n=this._pageSize;if(Object.hasOwn(t,"total")&&(this._total=Math.max(0,Ce(t.total))),Object.hasOwn(t,"pageSize")&&(this._pageSize=Ya(t.pageSize,this._pageSize)),Object.hasOwn(t,"page")){let r=Math.trunc(Number(t.page));Number.isFinite(r)&&(this._page=r)}return this._page=Wa(this._page,1,this._pageCount()),this._sync(),!e&&(this._page!==i||this._pageSize!==n)&&this.emit("change",this.getState()),this}getState(){let t=this._pageCount();return{page:this._page,pageSize:this._pageSize,total:this._total,pages:t,offset:(this._page-1)*this._pageSize}}enable(){return this._disabled=!1,this._sync(),this}disable(){return this._disabled=!0,this._sync(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_pageCount(){return this._total<=0?1:Math.ceil(this._total/this._pageSize)}_renderPageSize(){let t=this._message("pagination.pageSize","Rows per page");return l("label",{class:"zx-pagination__size"},l("span",{class:"zx-pagination__size-label"},t),l("select",{class:"zx-pagination__select",ref:"select",ariaLabel:t}))}_renderPages(){return l("div",{class:"zx-pagination__controls"},this._navButton("prev","chevron-left",this._message("pagination.previous","Previous page")),l("div",{class:"zx-pagination__pages",ref:"pages"}),this._navButton("next","chevron-right",this._message("pagination.next","Next page")))}_navButton(t,e,i){return l("button",{class:"zx-btn zx-pagination__nav",type:"button",ref:t,ariaLabel:i,dataset:{kind:"default",size:"sm"}},g(e,{size:14}))}_renderLoadMore(){return l("button",{class:"zx-btn zx-pagination__more",type:"button",ref:"more",dataset:{kind:"default",size:"md"}},l("span",{class:"zx-btn__label"},this._message("pagination.loadMore","Load more")))}_wire(){if(this.refs.select&&this.listen(this.refs.select,"change",()=>{this.setPageSize(Number(this.refs.select.value))}),this.options.mode==="pages"){this.listen(this.refs.prev,"click",()=>this.setPage(this._page-1)),this.listen(this.refs.next,"click",()=>this.setPage(this._page+1)),this.listen(this.refs.pages,"click",t=>{let e=t.target.closest?.("[data-page]");!e||!this.refs.pages.contains(e)||this.setPage(Number(e.dataset.page))});return}this.listen(this.refs.more,"click",()=>this.setPage(this._page+1))}_sync(){let t=this._pageCount();if(this.el.dataset.disabled=this._disabled?"true":"false",this.refs.summary&&(this.refs.summary.textContent=this._summary()),this.refs.select&&this._syncPageSize(),this.options.mode==="pages"){this.refs.prev.disabled=this._disabled||this._page<=1,this.refs.next.disabled=this._disabled||this._page>=t,this._syncPages(t);return}this.refs.more.disabled=this._disabled||this._page>=t}_summary(){if(this._total<=0)return this._message("pagination.empty","0 of 0");let t=(this._page-1)*this._pageSize,e=Math.min(t+this._pageSize,this._total);return this.options.mode==="loadmore"?this._message("pagination.loaded","%1 of %2",fs(e),fs(this._total)):this._message("pagination.summary","%1\u2013%2 of %3",fs(t+1),fs(e),fs(this._total))}_syncPageSize(){let t=this.refs.select,e=[...new Set([...this._pageSizes,this._pageSize])].sort((n,r)=>n-r),i=e.join(",");i!==this._sizeKey&&(this._sizeKey=i,t.replaceChildren(...e.map(n=>l("option",{value:String(n)},String(n))))),t.value=String(this._pageSize),t.disabled=this._disabled}_syncPages(t){let e=this.refs.pages,i=this.el.ownerDocument?.activeElement??null,n=i&&e.contains(i)?i.dataset.page??null:null,r=Ga({page:this._page,pages:t,siblings:this.options.siblings,boundaries:this.options.boundaries});if(e.replaceChildren(...r.map(a=>a===Jn?l("span",{class:"zx-pagination__ellipsis",ariaHidden:"true"},Jn):l("button",{class:"zx-btn zx-pagination__page",type:"button",disabled:this._disabled,ariaCurrent:a===this._page?"page":null,ariaLabel:this._message("pagination.page","Page %1",a),dataset:{kind:"default",size:"sm",page:String(a)}},String(a)))),n===null)return;let o=e.querySelector(`[data-page="${n}"]`);o&&!o.disabled&&o.focus()}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function Ce(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:0}function Ya(s,t){let e=Math.trunc(Number(s));return Number.isFinite(e)&&e>0?e:t}function Wa(s,t,e){return Math.min(Math.max(s,t),e)}function Xn(s,t){return t<s?[]:Array.from({length:t-s+1},(e,i)=>s+i)}function fs(s){return s.toLocaleString()}var _s=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),ps=class extends y{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 t=this.el??l("span");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._interactiveRoot=t.matches('a[href], button, input, select, textarea, [role="button"], [role="link"]'),this._state={...this.options},this._appliedClasses=[],this._sync(),t}set(t={}){return!t||typeof t!="object"?this:(Object.assign(this._state,t),this._sync(),this)}destroy(){let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&S(t,e)}_sync(){let t=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[t.class].flat().flatMap(d=>String(d??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let e=hh(t.size,"36px"),i=hh(t.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",e),this.el.style.setProperty("--zx-app-icon-glyph-size",i),ee(t.color)?this.el.style.setProperty("--zx-app-icon-color",String(t.color)):this.el.style.removeProperty("--zx-app-icon-color"),_s.includes(t.tone)?this.el.dataset.tone=t.tone:delete this.el.dataset.tone,this.el.dataset.glass=tw(t.glass),this.el.dataset.shape=ew(t.shape),this.el.toggleAttribute("data-selected",!!t.selected);let n=t.label==null?"":String(t.label).trim();if(this._interactiveRoot){let d=fh(this._snapshot,"role"),u=fh(this._snapshot,"aria-label");d===null?this.el.removeAttribute("role"):this.el.setAttribute("role",d),n?this.el.setAttribute("aria-label",n):u===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",u),this.el.removeAttribute("aria-hidden")}else n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=Zy(t.icon),o=t.badge==null||t.badge===""?null:l("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(t.badge)),c=[l("span",{class:"zx-app-icon__surface",ariaHidden:"true"},l("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),l("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r))];o&&c.push(o),this.el.replaceChildren(...c)}};function vi(s={}){return new ps(null,s).toElement()}function Zy(s){let t=typeof s=="function"?s():s;return typeof t=="string"?g(t,{size:"1em"}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t:null}function hh(s,t){if(typeof s=="number"&&Number.isFinite(s))return`${Math.max(1,s)}px`;let e=String(s??"").trim();return e&&!/[;{}]/.test(e)?e:t}function tw(s){return s===!1||s==="none"?"none":s==="strong"?"strong":"subtle"}function ew(s){return s==="circle"?"circle":"tile"}function fh(s,t){return s?.attributes.find(([e])=>e===t)?.[1]??null}var ir=class extends y{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:null,label:null,closeLabel:null,resultsLabel:null,emptyText:null,loadingText:null,shortcut:"mod+k",hints:null,scope:null};constructor(t=null,e={}){super(t,e)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null,this._overlay=null;let t=this.el??l("dialog");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,_=>[_.name,_.value]),children:Array.from(t.childNodes)},this._items=ms(this.options.items),this._sources=mh(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._settled=!0,this._pages=[],this._restoreActiveId=null,this._announcePending=!1,this._announceToggle=!1,this._destroyed=!1;let e=x("zx-launcher-results"),i=String(this.options.label??this._message("launcher.label","Launcher")),n=String(this.options.placeholder??this._message("launcher.placeholder","Search applications and records"));this._label=i,this._placeholder=n;let r=l("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:e,ariaExpanded:"false",ariaLabel:i,placeholder:n,value:this._query}),o=l("button",{ref:"scopeBack",class:"zx-icon-btn zx-launcher__scope-back",type:"button"},g("x")),a=l("span",{ref:"scope",class:"zx-launcher__scope",hidden:!0},l("span",{ref:"scopeLabel",class:"zx-launcher__scope-label"}),o),c=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel??this._message("launcher.close","Close launcher")},g("x")),d=l("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),u=l("div",{ref:"announce",class:"zx-launcher__announce",role:"status",ariaLive:"polite",ariaAtomic:"true"}),h=l("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:this.options.resultsLabel??this._message("launcher.results","Launcher results")}),f=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},iw()):null,p=sw(this.options.hints,{move:this._message("launcher.hintMove","Move"),open:this._message("launcher.hintOpen","Open"),back:this._message("launcher.hintBack","Back"),close:this._message("launcher.hintClose","Close")});return t.setAttribute("aria-label",i),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search",dataset:{shortcut:f?"true":"false"}},g("search"),a,r,f,c),d,h,p,u)),t.dataset.state="closed",this._createdRoot&&oe(this.options.scope,{dialog:!1})?.append(t),this.listen(r,"input",()=>{this._query=r.value,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(r,"keydown",_=>this._onKeydown(_)),this.listen(o,"click",()=>{this.back(),r.focus()}),this.listen(c,"click",()=>this.close()),this.listen(h,"click",_=>{let m=_.target?.closest?.("[data-launcher-index]");!m||!h.contains(m)||this._activate(Number(m.getAttribute("data-launcher-index")),_)}),this.listen(h,"pointermove",_=>{let m=_.target?.closest?.("[data-launcher-index]");if(!m||!h.contains(m))return;let b=Number(m.getAttribute("data-launcher-index"));!Number.isInteger(b)||this._results[b]?.disabled||b===this._active||(this._active=b,this._syncActive())}),this.listen(t,"cancel",_=>{_.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.open||this._releaseOverlay(),t.dataset.state="closed",r.setAttribute("aria-expanded","false"),this._abortRequest(),this._pages.length&&!t.open&&(this._unwind(),this._announcePending=!1,this._syncPage(),this._renderResults(),this._emitPage()),this.emit("close")}),this.listen(document,"keydown",_=>this._onDocumentKeydown(_)),this._renderResults(),t}open(t={}){if(this._destroyed)return this;let e=t&&typeof t=="object"?t.page:void 0;if(this.isOpen()){let r=e==null?[]:this._pagePath(e);return r.length&&this._goTo(r),this}if(this._createdRoot){let r=vt(this.options.scope);this.el.parentElement!==r&&r.append(this.el)}let i=this._pages.map(r=>r.page),n=document.activeElement;return this.el.showModal(),this._releaseOverlay(),this._overlay=le({kind:"modal",root:this.el,owner:this,anchor:n}),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._goTo(e==null?[]:this._pagePath(e),{emit:!1}),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),ph(i,this._pages.map(r=>r.page))||this._emitPage(),this}back(){if(!this._pages.length)return this;let t=this._popPage();return this._syncPage(),this._announcePending=this.isOpen(),t?this._renderResults():this._refresh(!0),this._emitPage(),this}getPage(){return this._pages.at(-1)?.page??null}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=ms(t),this._renderResults(),this}setCurrent(t){let e=t==null?null:String(t);return this._items=this._items.map(i=>({...i,current:e!==null&&String(i.id)===e})),this._renderResults(),this}setSources(t){return this._sources=mh(t),this._pages.length?(this._pages[0].parent.sourceItems=null,this):(this._abortRequest(),this._sourceItems.clear(),this._refresh(),this)}_releaseOverlay(){let t=this._overlay;this._overlay=null,t?.release()}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),this._releaseOverlay(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_refresh(t=!1){this._abortRequest(),this._sourceItems.clear();let{sources:e}=this._level();if(this._settled=e.length===0,t&&e.length&&this._loadSources(),this._renderResults(),t||e.length===0)return;let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),i)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._pages?.at(-1)?.page??null,i=this._level().sources.filter(o=>tr(o.when,t)&&t.length>=Math.max(o._page?0:Number(this.options.minQuery)||0,Number(o.minQuery)||0));if(i.length===0){this._settled=!0;return}let n=new AbortController,r=++this._requestSequence;this._request=n,this._setBusy(!0),await Promise.all(i.map(async o=>{try{let a=await o.load(t,{signal:n.signal});if(n.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(o.id,ms(a).map((c,d)=>({...c,_source:o._page?null:o.id,_sourceOrder:o.order==="source",group:c.group??o.label??"",itemOrder:c.itemOrder??(o.order==="source"?d:void 0)}))),this._renderResults()}catch(a){if(n.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:o,error:a,page:e})}})),!(n.signal.aborted||r!==this._requestSequence)&&(this._request=null,this._settled=!0,this._setBusy(!1))}_level(){return this._pages?.at(-1)??{items:this._items,sources:this._sources}}_openPage(t){this._pushPage(t),this._syncPage(),this._announcePending=this.isOpen(),this._refresh(!0),this._emitPage()}_goTo(t,{emit:e=!0}={}){let i=this._pages.map(n=>n.page);if(this._unwind(),t.length){this._abortRequest(),this._sourceItems.clear(),this._settled=!1;for(let n of t)this._pushPage(n)}this._syncPage(),this._announcePending=this.isOpen()&&t.length>0,this._refresh(t.length>0),e&&!ph(i,t)&&this._emitPage()}_unwind(){for(;this._pages.length;)this._popPage()}_pushPage(t){let e=this._active>=0?this._results[this._active]:null;this._pages.push({page:t,items:Array.isArray(t.items)?ms(t.items):[],sources:typeof t.items=="function"?[aw(t)]:[],parent:{query:this._query,activeId:e?String(e.id):null,sourceItems:this._settled?new Map(this._sourceItems):null}}),this._setInputQuery("")}_popPage(){let t=this._pages.pop();if(!t)return!0;this._announcePending=!1,this._abortRequest();let{parent:e}=t;return this._setInputQuery(e.query),this._sourceItems=e.sourceItems?new Map(e.sourceItems):new Map,this._settled=e.sourceItems!==null,this._restoreActiveId=e.activeId,this._settled}_setInputQuery(t){this._query=t,this.refs.input.value=t,this._renderedQuery=null}_syncPage(){let t=this.getPage(),{input:e,scope:i,scopeLabel:n,scopeBack:r,backHint:o}=this.refs;if(i.hidden=t===null,o&&(o.hidden=t===null),this.el.toggleAttribute("data-page",t!==null),t===null){e.setAttribute("aria-label",this._label),e.setAttribute("placeholder",this._placeholder),n.textContent="";return}let a=this._pages.at(-2)?.page.label??this._label;n.textContent=t.label,r.setAttribute("aria-label",this._message("launcher.back","Back to %1",a)),e.setAttribute("aria-label",this._message("launcher.pageLabel","Search %1",t.label)),e.setAttribute("placeholder",t.placeholder!=null?String(t.placeholder):this._message("launcher.pagePlaceholder","Search"))}_emitPage(){let t=this._pages.map(e=>e.page);this.emit("page",{page:t.at(-1)??null,path:t})}_pagePath(t){if(t&&typeof t=="object"){let e=t;return!xi(e)||e.label==null?[]:[gh({...e,id:e.id??e.label})]}return nw(this._items,t)}_pageStatus(){let t=this.getPage()?.label??this._label,e=this._results.length;return e===0?this._message("launcher.pageEmpty","%1, no results",t):e===1?this._message("launcher.pageResult","%1, 1 result",t):this._message("launcher.pageResults","%1, %2 results",t,e)}_setBusy(t){this._busy=t,this.el.setAttribute("aria-busy",String(t)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let t=this._query,e=this._restoreActiveId??null;this._restoreActiveId=null;let i=e??(this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null),n=this._query.trim(),r=this._level(),o=r.items.filter(m=>tr(m.when,n)),a=sr(o,n,this.options.maxResults),c=r.sources.flatMap(m=>{let b=this._sourceItems.get(String(m.id))??[];return m.order==="source"?b.filter(w=>tr(w.when,n)):sr(b.filter(w=>tr(w.when,n)),n,this.options.maxResults)}),d=new Set,u=[...a.map(m=>({...m,_source:null})),...c].filter(m=>{let b=String(m.id);return d.has(b)?!1:(d.add(b),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let m of u){let b=String(m.group??"");h.has(b)||h.set(b,[]),h.get(b).push(m)}this._results=[...h.values()].flat(),this._renderedQuery=t;let f=i===null?-1:this._results.findIndex(m=>!m.disabled&&String(m.id)===i);this._active=f>=0?f:this._results.findIndex(m=>!m.disabled);let p=[],_=0;for(let[m,b]of h){let w=b.map(v=>this._option(v,_++));m?p.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:m,dataset:{layout:b.every(v=>v.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},m),w)):p.push(...w)}this.refs.results.replaceChildren(...p),this._syncActive(),this._renderStatus()}_option(t,e){let i=xi(t),n=i?null:V(t.href),r=n?"a":"button",o=[],a=lw(t);a&&o.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},a)),o.push(l("span",{class:"zx-launcher__copy"},l("span",{class:"zx-launcher__label"},t.label),t.description?l("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&o.push(l("span",{class:"zx-launcher__badge"},String(t.badge))),t.hint!=null&&t.hint!==""&&o.push(l("span",{class:"zx-launcher__hint"},String(t.hint)));let c=ow(t),d=rw(t.shortcut);return d.length&&o.push(l("span",{class:"zx-launcher__keys",ariaHidden:c?"true":null},d.map(u=>l("kbd",{class:"zx-launcher__key"},u)))),i&&o.push(l("span",{class:"zx-launcher__chevron",ariaHidden:"true"},g("chevron-right"))),l(r,{class:"zx-launcher__option",type:r==="button"?"button":null,href:n,target:t.target??null,rel:r==="a"?"noopener":null,role:"option",id:x("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,ariaKeyShortcuts:c,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:cw(t.kind),page:i?"true":null}},o)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText??this._message("launcher.loading","Searching\u2026")):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText??this._message("launcher.empty","No results")):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent,this._announcePending&&!this._busy&&this._renderedQuery===this._query&&(this._announcePending=!1,this._announceToggle=!this._announceToggle,this.refs.announce.textContent=this._pageStatus()+(this._announceToggle?"\xA0":""))}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let i of t){let n=Number(i.getAttribute("data-launcher-index"))===this._active;i.setAttribute("aria-selected",String(n))}let e=t.find(i=>Number(i.getAttribute("data-launcher-index"))===this._active);e?this.refs.input.setAttribute("aria-activedescendant",e.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(t){if(t.key==="Escape"){this.close();return}let e=!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(t.key==="Backspace"&&e&&!t.repeat&&this._pages.length&&this._query===""){t.preventDefault(),this.back();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let i=this._results.map((r,o)=>r.disabled?-1:o).filter(r=>r>=0);if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let r=i.length?this._spatialIndex(t.key,i):null;if(r!==null){t.preventDefault(),this._active=r,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight"){e&&!t.repeat&&this._pageKey(t.key)&&t.preventDefault();return}}if(i.length===0)return;let n=i.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")n=0;else if(t.key==="End"||t.key==="PageDown")n=i.length-1;else if(t.key==="ArrowDown")n=(n+1+i.length)%i.length;else if(t.key==="ArrowUp")n=(n-1+i.length)%i.length;else return;t.preventDefault(),this._active=i[n],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_pageKey(t){if(t==="ArrowLeft")return!this._pages.length||this._query!==""?!1:(this.back(),!0);let e=this._active>=0?this._results[this._active]:null;if(!e||e.disabled||!xi(e)||e.kind==="application")return!1;let i=this.refs.input,n=i.value.length;return i.selectionStart!==n||i.selectionEnd!==n?!1:(this._openPage(e),!0)}_spatialIndex(t,e){let i=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(i instanceof HTMLElement)||(t==="ArrowLeft"||t==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>e.includes(Number(o.getAttribute("data-launcher-index")))&&(t!=="ArrowLeft"&&t!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=dw(n,i,t);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(t,e){let i=this._results[t];if(!i||i.disabled){e.preventDefault();return}if(xi(i)){e.preventDefault(),this._openPage(i),this.refs.input.focus();return}if(this.emit("select",{item:i,value:i.value??i.id,source:i._source??null,query:this._query.trim(),page:this.getPage()}).defaultPrevented){e.preventDefault();return}this.close(),i.href||(e.preventDefault(),i.invoke?.())}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let i=document.querySelector("dialog:modal");i&&i!==this.el||(t.preventDefault(),this.open())}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function iw(){let s=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(s)?"\u2318 K":"Ctrl K"}function sw(s,t){if(s===!1)return null;let e=s&&typeof s=="object"?s:{};return l("footer",{class:"zx-launcher__hints",ariaHidden:"true"},l("span",{},l("kbd",{},"\u2191\u2193\u2190\u2192"),e.move??t.move),l("span",{},l("kbd",{},"\u21B5"),e.open??t.open),l("span",{ref:"backHint",hidden:!0},l("kbd",{},"\u232B"),e.back??t.back),l("span",{},l("kbd",{},"Esc"),e.close??t.close))}function xi(s){let t=s?.items;return!!s&&typeof s=="object"&&(Array.isArray(t)||typeof t=="function")}function nw(s,t){if(t==null)return[];let e=String(t),i=new Set,n=(r,o)=>{if(!Array.isArray(r)||i.has(r))return null;i.add(r);for(let a of ms(r)){if(!xi(a))continue;let c=[...o,a];if(String(a.id)===e)return c;let d=n(a.items,c);if(d)return d}return null};return n(s,[])??[]}function rw(s){let t=s&&typeof s=="object"&&!Array.isArray(s)?s.label:s;return(Array.isArray(t)?t:t==null?[]:[t]).filter(i=>i!=null&&String(i).trim()!=="").map(i=>String(i).trim())}function ow(s){let t=s.shortcut,e=s.keys??(t&&typeof t=="object"&&!Array.isArray(t)?t.keys:null);return typeof e=="string"&&e.trim()?e.trim():null}function aw(s){return{id:`page:${String(s.id)}`,load:s.items,order:s.order==="source"?"source":"rank",_page:!0}}function ph(s,t){return s.length===t.length&&s.every((e,i)=>e===t[i]||String(e.id)===String(t[i].id))}function lw(s){let t=s.icon;if(typeof t=="function"&&(t=t(s)),typeof t=="string")return g(t);if(t instanceof Node)return t.cloneNode(!0);if(t&&typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();return e instanceof Node?e.cloneNode(!0):null}return null}function cw(s){return s==="application"||s==="record"?s:"action"}function tr(s,t){return s==="empty"?t==="":s==="query"?t!=="":!0}function dw(s,t,e){let i=t.getBoundingClientRect();if(i.width===0&&i.height===0)return null;let n=i.left+i.width/2,r=i.top+i.height/2,o=null,a=1/0;for(let c of s){if(c===t)continue;let d=c.getBoundingClientRect(),u=d.left+d.width/2-n,h=d.top+d.height/2-r,f=!1,p=1/0;e==="ArrowLeft"?(f=u<-2&&Math.abs(h)<Math.max(i.height,d.height)/2,p=Math.abs(u)+Math.abs(h)*4):e==="ArrowRight"?(f=u>2&&Math.abs(h)<Math.max(i.height,d.height)/2,p=Math.abs(u)+Math.abs(h)*4):e==="ArrowUp"?(f=h<-2,p=Math.abs(h)*10+Math.abs(u)):e==="ArrowDown"&&(f=h>2,p=Math.abs(h)*10+Math.abs(u)),f&&p<a&&(o=c,a=p)}return o}function sr(s,t,e=100){let i=Si(t).trim(),n=s.map((o,a)=>({item:o,order:a,score:uw(o,i)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=er(o.item.groupOrder),d=er(a.item.groupOrder);if(c!==d)return c-d;if(i===""){let u=_h(o.item.pinned,o.order),h=_h(a.item.pinned,a.order);if(u!==h)return u-h}return o.score-a.score||er(o.item.itemOrder)-er(a.item.itemOrder)||hw(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function uw(s,t){if(!t)return s.pinned?-1:0;let e=Si(s.label),i=Si(s.id),n=Si(Array.isArray(s.keywords)?s.keywords.join(" "):s.keywords??"");return e===t?0:e.startsWith(t)?10:e.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(t))?20:e.includes(t)||n.includes(t)?30:i.includes(t)?40:e.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(t)?50:1/0}function _h(s,t){return typeof s=="number"&&Number.isFinite(s)?s:s?t:Number.MAX_SAFE_INTEGER}function er(s){return typeof s=="number"&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER}function Si(s){return String(s??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function hw(s,t){let e=Si(s),i=Si(t);if(e<i)return-1;if(e>i)return 1;let n=String(s??"").normalize("NFC"),r=String(t??"").normalize("NFC");return n<r?-1:n>r?1:0}function ms(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>gh(t)):[]}function gh(s){let t={...s,label:String(s.label)};if(s.href==null)return t;let e=V(s.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&!xi(t)&&(t.disabled=!0)),t}function mh(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&typeof t.load=="function").map(t=>({...t,id:String(t.id)})):[]}var Ai=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),bh=Object.freeze(Ai.filter(s=>s!=="slate")),fw=24,de=class extends y{static cssName="avatar";static defaults={src:null,name:"",initials:null,label:null,size:"md",shape:"circle",tone:null,status:null,statusLabel:null};render(){this._createdRoot=this.el===null;let t=this.el??l("span");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,r=>[r.name,r.value]),children:Array.from(t.childNodes)},this._state={src:this.options.src,name:String(this.options.name??""),initials:this.options.initials,label:this.options.label,size:this.options.size,shape:this.options.shape,tone:this.options.tone,status:this.options.status,statusLabel:this.options.statusLabel};let e=l("img",{ref:"image",class:"zx-avatar__image",alt:"",draggable:!1}),i=l("span",{ref:"fallback",class:"zx-avatar__fallback",ariaHidden:"true"}),n=l("span",{ref:"status",class:"zx-avatar__status",ariaHidden:"true",hidden:!0});return t.replaceChildren(e,i,n),this.listen(e,"load",()=>{this._isCurrentImageSource()&&this._showImage(!0)}),this.listen(e,"error",()=>{this._isCurrentImageSource()&&this._showImage(!1)}),this._sync(),t}set(t={}){if(!t||typeof t!="object")return this;for(let e of["src","name","initials","label","size","shape","tone","status","statusLabel"])Object.hasOwn(t,e)&&(this._state[e]=t[e]);return this._sync(),this}setStatus(t,e=null){return this._state.status=t,this._state.statusLabel=e,this._syncLabel(),this._syncStatus(),this}hasImage(){return!this.refs.image.hidden}destroy(){let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_sync(){let{size:t,shape:e,label:i}=this._state;this.el.dataset.size=typeof t=="string"?t:"custom",this.el.dataset.shape=["circle","rounded","square"].includes(e)?e:"circle",typeof t=="number"&&Number.isFinite(t)?this.el.style.setProperty("--zx-avatar-size",`${Math.max(1,t)}px`):this.el.style.removeProperty("--zx-avatar-size"),this._syncLabel();let n=String(this._state.name??""),r=typeof t=="number"&&t<fw?1:2;this.refs.fallback.textContent=this._state.initials?pw(String(this._state.initials),r):Te(n,r);let o=Ai.includes(this._state.tone)?this._state.tone:ue(n.trim()?n:this._state.initials);this.el.dataset.tone=o;let a=this._state.src==null?"":String(this._state.src).trim();a?(this.refs.image.setAttribute("src",a),this._showImage(this.refs.image.complete&&this.refs.image.naturalWidth>0)):(this.refs.image.removeAttribute("src"),this._showImage(!1)),this._syncStatus()}_syncLabel(){let{label:t,status:e,statusLabel:i}=this._state;if(t){let n=["online","away","busy","offline"].includes(e)?i:null;this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",[t,n].filter(Boolean).join(", ")),this.el.removeAttribute("aria-hidden")}else this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true")}_showImage(t){this.refs.image.hidden=!t,this.refs.fallback.hidden=t,this.el.dataset.fallback=String(!t)}_isCurrentImageSource(){let t=this.refs.image,e=t.getAttribute("src");if(!e)return!1;try{return t.currentSrc===new URL(e,document.baseURI).href}catch{return t.currentSrc===e}}_syncStatus(){let e=["online","away","busy","offline"].includes(this._state.status)?this._state.status:null;this.refs.status.hidden=e===null,e?this.refs.status.dataset.status=e:delete this.refs.status.dataset.status;let i=this._state.statusLabel;i?this.refs.status.setAttribute("title",String(i)):this.refs.status.removeAttribute("title")}};function Te(s,t=2){let e=String(s??"").trim().split(/\s+/u).filter(Boolean);if(e.length===0)return"?";let i=yh(e[0]),n=t>1&&e.length>1?yh(e[e.length-1]):"";return`${i}${n}`}function ue(s){let t=String(s??"").trim().normalize("NFC").toLowerCase();if(!t)return"slate";let e=2166136261;for(let i=0;i<t.length;i+=1)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return bh[(e>>>0)%bh.length]}function pw(s,t){return t>1?s:Qa(s.trim())||s}function yh(s){return Qa(Qa(s).toUpperCase())}function Qa(s){return typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(s)[Symbol.iterator]().next().value?.segment??"":Array.from(s)[0]??""}var ki=class extends y{static cssName="entity-ref";static defaults={id:null,title:"",subtitle:null,icon:null,metadata:[],link:null,actions:[],size:"md",wrap:!1,actionsLabel:"Entity actions"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._state=nr(this.options),this._renderedActions=[],t.replaceChildren(l("span",{ref:"icon",class:"zx-entity-ref__icon",ariaHidden:"true"}),l("div",{class:"zx-entity-ref__body"},l("span",{ref:"title",class:"zx-entity-ref__title"}),l("span",{ref:"subtitle",class:"zx-entity-ref__subtitle"}),l("dl",{ref:"metadata",class:"zx-entity-ref__metadata"})),l("div",{ref:"actions",class:"zx-entity-ref__actions",role:"group"})),this.listen(t,"click",e=>this._handleClick(e)),this._sync(),t}set(t={}){return!t||typeof t!="object"||Array.isArray(t)?this:(this._state=nr({...this._state,...t}),this._sync(),this)}setMetadata(t){return this.set({metadata:t})}setActions(t){return this.set({actions:t})}setLink(t){return this.set({link:t})}getEntity(){return vw(this._state)}focus(){let t=this.refs.title.querySelector("a[href]")??this.refs.actions.querySelector("a[href], button:not(:disabled)");return t&&typeof t.focus=="function"&&t.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_sync(){let t=this._state,e=this.el,i=this.refs.icon,n=this.refs.title,r=this.refs.subtitle,o=this.refs.metadata,a=this.refs.actions;e.dataset.size=t.size,e.dataset.wrap=String(t.wrap);let c=gw(t.icon);i.replaceChildren(...c===null?[]:[c]),i.hidden=c===null;let d=t.link?l("a",{class:"zx-entity-ref__primary",href:t.link.href,target:t.link.target,rel:t.link.rel,download:t.link.download===!0?"":t.link.download,dataset:{entityPrimary:""}},t.title):l("span",{class:"zx-entity-ref__name"},t.title);n.replaceChildren(d),n.hidden=t.title==="",bw(r,t.subtitle),r.hidden=xh(t.subtitle),o.replaceChildren(...t.metadata.map(u=>l("div",{class:"zx-entity-ref__field",dataset:{labelVisible:String(u.showLabel!==!1)}},l("dt",{class:"zx-entity-ref__label"},u.label),l("dd",{class:"zx-entity-ref__value"},u.icon?g(u.icon,{size:12}):null,vh(u.value))))),o.hidden=t.metadata.length===0,this._renderedActions=t.actions,a.setAttribute("aria-label",t.actionsLabel),a.replaceChildren(...t.actions.map((u,h)=>E(u)?u:_w(u,h))),a.hidden=t.actions.length===0}_handleClick(t){let e=t.target instanceof Element?t.target:null;if(!e)return;let i=e.closest("[data-entity-primary]");if(i&&this.el.contains(i)&&this._state.link){let a={id:this._state.id,entity:this.getEntity(),href:this._state.link.href,event:t};if(this.emit("activate",a,{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}this._state.link.onclick?.(t,this.getEntity(),this);return}let n=e.closest("[data-entity-action]");if(!n||!this.refs.actions.contains(n))return;let r=this._renderedActions[Number(n.dataset.entityAction)];if(!r||E(r)||r.disabled)return;if(this.emit("action",{id:r.id,action:{...r},entity:this.getEntity(),event:t},{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}r.onselect?.(r.id,{...r},this.getEntity(),this)}};function nr(s={}){let t=s&&typeof s=="object"&&!Array.isArray(s)?s:{},e=String(t.title??""),i=gs(t.link);if(i&&!e.trim())throw new TypeError("A linked EntityRef requires a non-empty title");return{id:t.id??null,title:e,subtitle:wh(t.subtitle),icon:mw(t.icon),metadata:bs(t.metadata),link:i,actions:ys(t.actions),size:yw(t.size),wrap:!!t.wrap,actionsLabel:String(t.actionsLabel||"Entity actions")}}function gs(s){if(s==null)return null;let t=typeof s=="string"?{href:s}:s;if(!t||typeof t!="object"||Array.isArray(t))return null;let e=V(t.href);if(e===null)return null;let i=t.target==null?void 0:String(t.target),n=Sh(t.rel,i),r=t.onclick;if(r!==void 0&&typeof r!="function")throw new TypeError("EntityRef link onclick must be a function");let o=t.download,a=o===!0?!0:typeof o=="string"?o:void 0;return{href:e,...i?{target:i}:{},...n?{rel:n}:{},...a!==void 0?{download:a}:{},...r?{onclick:r}:{}}}function bs(s){return Array.isArray(s)?s.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];let e=t,i=String(e.label??"").trim(),n=wh(e.value);return!i||xh(n)?[]:[{label:i,value:n,icon:e.icon==null?null:String(e.icon),showLabel:e.showLabel!==!1}]}):[]}function ys(s){if(!Array.isArray(s))return[];let t=new Set,e=[];for(let i of s){if(E(i)){e.push(i);continue}if(!i||typeof i!="object"||Array.isArray(i))continue;let n=i,r=String(n.id??"").trim(),o=String(n.label??""),a=String(n.title??o).trim();if(!r||!a||t.has(r)||n.href!=null&&V(n.href)===null)continue;if(n.onselect!==void 0&&typeof n.onselect!="function")throw new TypeError(`EntityRef action ${r} onselect must be a function`);t.add(r);let c=n.href==null?void 0:V(n.href),d=n.target==null?void 0:String(n.target),u=Sh(n.rel,d);e.push({...n,id:r,label:o,title:a,icon:n.icon==null?null:String(n.icon),kind:ww(n.kind),disabled:!!n.disabled,...c?{href:c}:{},...d?{target:d}:{},...u?{rel:u}:{}})}return e}function _w(s,t){let e=[s.icon?g(s.icon,{size:14}):null,s.label?l("span",{class:"zx-entity-ref__action-label"},s.label):null],i={class:"zx-entity-ref__action",title:s.title,ariaLabel:s.label||s.title,dataset:{entityAction:String(t),kind:s.kind}};return s.href&&!s.disabled?l("a",{...i,href:s.href,target:s.target,rel:s.rel},e):l("button",{...i,type:"button",disabled:!!s.disabled},e)}function mw(s){return s==null||typeof s=="string"||typeof s=="function"?s??null:ws(s)||s instanceof y?s:null}function gw(s){let t=typeof s=="function"?s():s;return typeof t=="string"?g(t,{size:18}):t instanceof y?t.toElement():ws(t)?t:null}function wh(s){return s==null?null:typeof s=="string"||typeof s=="number"||ws(s)||s instanceof y?s:String(s)}function bw(s,t){s.replaceChildren(vh(t))}function vh(s){return s instanceof y?s.toElement():ws(s)?s:s==null?"":String(s)}function xh(s){return s==null||!ws(s)&&!(s instanceof y)&&String(s)===""}function ws(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function yw(s){return s==="sm"||s==="lg"?s:"md"}function ww(s){return s==="default"||s==="primary"||s==="danger"?s:"ghost"}function Sh(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function vw(s){return Object.freeze({...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:s.actions.map(t=>E(t)?t:{...t})})}var xw=new Set(["ready","temporary","waiting","uploading","processing","success","error"]),Sw=Object.freeze({ready:"",temporary:"Temporary",waiting:"Waiting",uploading:"Uploading",processing:"Processing",success:"Complete",error:"Failed"}),zi=class extends y{static cssName="file-item";static defaults={id:null,name:"",size:null,mime:"",typeLabel:null,subtitle:null,icon:"file",metadata:[],link:null,actions:[],status:"ready",statusLabel:null,progress:null,indeterminate:!1,identitySize:"md",wrap:!1,actionsLabel:"File actions"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._state=he(this.options);let e=l("div",{ref:"entity",class:"zx-file-item__entity"});return t.replaceChildren(e,l("div",{ref:"status",class:"zx-file-item__status",role:"status"}),l("div",{ref:"progress",class:"zx-file-item__progress"},l("div",{ref:"progressHead",class:"zx-file-item__progress-head"}),l("div",{ref:"progressTrack",class:"zx-file-item__progress-track",role:"progressbar",ariaValuemin:"0",ariaValuemax:"100"},l("div",{ref:"progressFill",class:"zx-file-item__progress-fill"})))),this._entity=new ki(e,Ah(this._state)),this.listen(this._entity.el,"zx-activate",i=>this._forwardActivate(i)),this.listen(this._entity.el,"zx-action",i=>this._forwardAction(i)),this._sync(),t}set(t={}){return!t||typeof t!="object"||Array.isArray(t)?this:(this._state=he({...this._state,...t}),this._sync(),this)}setStatus(t,e){return this.set({status:t,...e===void 0?{}:{statusLabel:e}})}setProgress(t,{indeterminate:e=!1}={}){return this.set({progress:t,indeterminate:e})}getFile(){return Nw(this._state)}focus(){return this._entity.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;this._entity?.destroy(),super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_sync(){let t=this._state,e=this.el,i=this.refs.status,n=this.refs.progress,r=this.refs.progressTrack,o=this.refs.progressFill;e.dataset.status=t.status,e.dataset.identitySize=t.identitySize,this._entity.set(Ah(t));let a=Iw(t);i.replaceChildren(...a?[ht({label:a,kind:Ew(t.status),size:"sm",dot:t.status!=="ready"})]:[]),i.hidden=a==="";let c=t.indeterminate||t.progress!==null;if(n.hidden=!c,n.toggleAttribute("data-indeterminate",t.indeterminate),!c)return;let d=`${a||"Progress"}${t.indeterminate||t.progress===null?"":` \u2014 ${Math.round(t.progress)}%`}`;if(this.refs.progressHead.textContent=d,r.setAttribute("aria-label",`${t.name||"File"}: ${a||"Progress"}`),t.indeterminate)r.removeAttribute("aria-valuenow"),r.removeAttribute("aria-valuetext"),o.style.removeProperty("--zx-file-progress");else{let u=t.progress??0;r.setAttribute("aria-valuenow",String(u)),r.setAttribute("aria-valuetext",`${Math.round(u)}%`),o.style.setProperty("--zx-file-progress",`${u}%`)}}_forwardActivate(t){let e=t.detail??{};this.emit("activate",{id:this._state.id,file:this.getFile(),href:String(e.href??""),event:e.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_forwardAction(t){let e=t.detail??{};this.emit("action",{id:String(e.id??""),fileId:this._state.id,action:e.action??{},file:this.getFile(),event:e.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}};function he(s={}){let t=s&&typeof s=="object"&&!Array.isArray(s)?s:{},e=t.size==null||t.size===""?null:Number(t.size),i=t.progress==null?null:Number(t.progress),n=xw.has(String(t.status))?String(t.status):"ready";return{id:t.id??null,name:String(t.name??""),size:e!==null&&Number.isFinite(e)&&e>=0?e:null,mime:String(t.mime??""),typeLabel:t.typeLabel==null?null:String(t.typeLabel),subtitle:Mw(t.subtitle),icon:t.icon===void 0?"file":t.icon,metadata:bs(t.metadata),link:gs(t.link),actions:ys(t.actions),status:n,statusLabel:t.statusLabel==null?null:String(t.statusLabel),progress:i===null||!Number.isFinite(i)?null:Math.min(100,Math.max(0,i)),indeterminate:!!t.indeterminate,identitySize:t.identitySize==="sm"||t.identitySize==="lg"?t.identitySize:"md",wrap:!!t.wrap,actionsLabel:String(t.actionsLabel||"File actions"),locale:Dw(t.locale)}}function Ah(s){let t=[],e=s.typeLabel??Cw(s.mime,s.name);return e&&t.push({label:"Type",value:e,showLabel:!1}),s.size!==null&&t.push({label:"Size",value:li(s.size,{locale:s.locale}),showLabel:!1}),t.push(...s.metadata),{id:s.id,title:s.name,subtitle:s.subtitle,icon:s.icon==="file"?Tw(s.mime):s.icon,metadata:t,link:s.link,actions:s.actions,size:s.identitySize,wrap:s.wrap,actionsLabel:s.actionsLabel}}var Aw=Object.freeze({pdf:{label:"PDF",icons:["file-pdf"]},csv:{label:"CSV",icons:["file-csv","file-excel"]},tsv:{label:"TSV",icons:["file-csv","file-excel"]},spreadsheet:{label:"Spreadsheet",icons:["file-excel"]},document:{label:"Document",icons:["file-word","file-lines"]},presentation:{label:"Presentation",icons:["file-powerpoint"]},text:{label:"Text",icons:["file-lines"]},markdown:{label:"Markdown",icons:["file-lines"]},html:{label:"HTML",icons:["file-code","code"]},css:{label:"CSS",icons:["file-code","code"]},javascript:{label:"JavaScript",icons:["file-code","code"]},json:{label:"JSON",icons:["file-code","code"]},xml:{label:"XML",icons:["file-code","code"]},zip:{label:"ZIP",icons:["file-zipper"]},gzip:{label:"GZIP",icons:["file-zipper"]},tar:{label:"TAR",icons:["file-zipper"]},rar:{label:"RAR",icons:["file-zipper"]},sevenZip:{label:"7Z",icons:["file-zipper"]},email:{label:"Email",icons:["envelope"]},calendar:{label:"Calendar",icons:["calendar"]},contact:{label:"Contact",icons:["address-card"]},image:{label:"Image",icons:["file-image","image"]},video:{label:"Video",icons:["file-video","video"]},audio:{label:"Audio",icons:["file-audio"]},font:{label:"Font",icons:["font"]}}),kw=new Map(Object.entries({"application/pdf":"pdf","text/csv":"csv","application/csv":"csv","text/comma-separated-values":"csv","text/tab-separated-values":"tsv","application/vnd.ms-excel":"spreadsheet","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"spreadsheet","application/vnd.oasis.opendocument.spreadsheet":"spreadsheet","application/msword":"document","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"document","application/vnd.oasis.opendocument.text":"document","application/rtf":"document","text/rtf":"document","application/vnd.ms-powerpoint":"presentation","application/vnd.openxmlformats-officedocument.presentationml.presentation":"presentation","application/vnd.oasis.opendocument.presentation":"presentation","text/plain":"text","text/markdown":"markdown","text/x-markdown":"markdown","text/html":"html","application/xhtml+xml":"html","text/css":"css","text/javascript":"javascript","application/javascript":"javascript","application/json":"json","application/ld+json":"json","application/xml":"xml","text/xml":"xml","application/zip":"zip","application/x-zip-compressed":"zip","application/gzip":"gzip","application/x-gzip":"gzip","application/x-tar":"tar","application/vnd.rar":"rar","application/x-rar-compressed":"rar","application/x-7z-compressed":"sevenZip","message/rfc822":"email","text/calendar":"calendar","text/vcard":"contact","text/x-vcard":"contact"})),zw=new Map([["image","image"],["video","video"],["audio","audio"],["font","font"],["text","text"]]);function kh(s){let t=String(s??"").split(";")[0].trim().toLowerCase();if(!t)return null;let e=kw.get(t)??zw.get(t.split("/")[0]);return e?Aw[e]:null}function Cw(s,t=""){if(!String(s??"").trim())return"";let e=kh(s);if(e)return e.label;let i=/\.([a-z0-9]{1,5})$/i.exec(String(t??""))?.[1];return i?i.toUpperCase():""}function Tw(s){let t=kh(s)?.icons??[];if(!t.length)return"file";if(Ke().provider==="fontawesome")return t[0];let e=new Set(tn());return t.find(i=>e.has(i))??"file"}function Iw(s){return s.statusLabel===null?Sw[s.status]:s.statusLabel}function Ew(s){return s==="error"?"danger":s==="success"?"success":s==="temporary"||s==="waiting"?"warning":s==="uploading"?"info":s==="processing"?"accent":"neutral"}function Mw(s){return s==null?null:typeof s=="string"||typeof s=="number"||s instanceof y||typeof s=="object"&&typeof s.nodeType=="number"?s:String(s)}function Dw(s){if(typeof s=="string"&&s.trim())return s}function Nw(s){return Object.freeze({...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:s.actions.map(t=>E(t)?t:{...t})})}var rr=class extends y{static cssName="file-list";static defaults={items:[],label:"Files",loading:!1,loadingCount:3,loadingText:"Loading files",emptyText:"No files"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("section");this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._items=or(this.options.items),this._loading=!!this.options.loading,this._itemComponents=[],this._itemRecords=new Map,this._itemList=null,this._emptyRegion=null,this._loadingRegion=null,this._loadingPlaceholders=!1,t.setAttribute("aria-label",String(this.options.label||"Files")),this.listen(t,"zx-activate",e=>this._forwardActivate(e)),this.listen(t,"zx-action",e=>this._forwardAction(e));try{return this._renderList(),t}catch(e){throw this._destroyItems(),this._createdRoot||S(t,this._snapshot),e}}setItems(t,e={}){return this._items=or(t),this._renderList(),e.silent||this._emitDataChange(),this}getItems(){return this._itemComponents.map(t=>t.getFile())}getItem(t){return this._itemComponents.find(i=>Object.is(i.getFile().id,t))?.getFile()??null}addItem(t,e=this._items.length,i={}){let n=Math.max(0,Math.min(this._items.length,Math.trunc(Number(e))||0)),r=this._items.slice();return r.splice(n,0,he(t)),this.setItems(r,i)}updateItem(t,e,i={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("FileList update values must be an object");let n=this._items.findIndex(o=>Object.is(o.id,t));if(n<0)return this;let r=this._items.slice();return r[n]=he({...r[n],...e}),this.setItems(r,i)}removeItem(t,e={}){let i=this._items.findIndex(r=>Object.is(r.id,t));if(i<0)return this;let n=this._items.slice();return n.splice(i,1),this.setItems(n,e)}setLoading(t){let e=!!t;return e===this._loading?this:(this._loading=e,this._renderList(),this)}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;this._destroyItems(),super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_renderList(){let t=this.el,e=un(t,n=>{let r=this._itemComponents.findIndex(o=>o.el?.contains(n));return r<0?null:{key:{component:this._itemComponents[r],index:r},element:this._itemComponents[r].el}});t.setAttribute("aria-busy",String(this._loading));try{this._reconcileItems()}catch(n){throw this._destroyItems(),n}let i=[];this._items.length?i.push(this._itemList):this._loading||(this._emptyRegion??=l("div",{class:"zx-file-list__empty",role:"status"},Fw(this.options.emptyText,"FileList emptyText")),i.push(this._emptyRegion)),this._loading&&i.push(this._createLoading(this._items.length===0)),zh(t,i),hn(t,e,n=>{let r=n;return this._itemComponents.includes(r.component)?r.component.el:this._itemComponents[Math.min(r.index,this._itemComponents.length-1)]?.el??null})}_reconcileItems(){let t=this._itemComponents,e=new Map;for(let o of t){let a=this._itemRecords.get(o)?.state.id??null;a!==null&&e.set(a,o)}let i=[];for(let o of this._items){let a=o.id===null?void 0:e.get(o.id);if(a){e.delete(o.id);let d=this._itemRecords.get(a);Xa(d.state,o)||a.set(o),d.state=o,i.push(a);continue}let c=new zi(null,o);this._itemRecords.set(c,{row:l("li",{class:"zx-file-list__item"},c),state:o}),i.push(c)}let n=new Set(i);for(let o of t)n.has(o)||(this._itemRecords.get(o)?.row.remove(),this._itemRecords.delete(o),o.destroy());if(this._itemComponents=i,i.length===0)return;let r=this._itemList??=l("ol",{class:"zx-file-list__items"});zh(r,i.map(o=>this._itemRecords.get(o).row))}_createLoading(t){return this._loadingRegion&&this._loadingPlaceholders===t?this._loadingRegion:(this._loadingPlaceholders=t,this._loadingRegion=this._buildLoading(t),this._loadingRegion)}_buildLoading(t){let e=l("div",{class:"zx-file-list__loading",role:"status",ariaLive:"polite"},l("span",{class:"zx-file-list__loading-label"},String(this.options.loadingText)));if(!t)return e;let i=l("div",{class:"zx-file-list__skeletons",ariaHidden:"true"});for(let n=0;n<Lw(this.options.loadingCount);n+=1)i.append(l("div",{class:"zx-file-list__skeleton"},ot({width:"2rem",height:"2rem",radius:"md"}),yi({lines:2,lastLineWidth:n%2?"48%":"64%"})));return e.append(i),e}_destroyItems(){for(let t of this._itemComponents)t.destroy();this._itemComponents=[],this._itemRecords?.clear(),this._itemList?.replaceChildren()}_forwardActivate(t){let e=this._componentForEvent(t);if(!e)return;let i=this._itemComponents.indexOf(e),n=t.detail??{},r=e.getFile();this.emit("activate",{id:r.id,index:i,file:r,href:String(n.href??""),event:n.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_forwardAction(t){let e=this._componentForEvent(t);if(!e)return;let i=this._itemComponents.indexOf(e),n=t.detail??{},r=e.getFile();this.emit("action",{id:String(n.id??""),fileId:r.id,index:i,action:n.action??{},file:r,event:n.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_componentForEvent(t){return t.target===this.el?null:this._itemComponents.find(e=>t.target===e.el)??null}_emitDataChange(){this.emit("datachange",{items:this.getItems()})}};function or(s){if(!Array.isArray(s))throw new TypeError("FileList items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("FileList items must be descriptor objects");let i=he(e);if(i.id!==null){if(t.has(i.id))throw new RangeError(`Duplicate FileList id: ${String(i.id)}`);t.add(i.id)}return Ow(i)})}function Ow(s){return{...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:[...s.actions],locale:s.locale}}function zh(s,t){let e=new Set(t);for(let i of[...s.childNodes])e.has(i)||i.remove();t.forEach((i,n)=>{let r=s.childNodes[n]??null;r!==i&&s.insertBefore(i,r)})}function Xa(s,t){if(Object.is(s,t))return!0;if(Array.isArray(s)&&Array.isArray(t))return s.length===t.length&&s.every((i,n)=>Xa(i,t[n]));if(!Ch(s)||!Ch(t))return!1;let e=Object.keys(s);return e.length===Object.keys(t).length&&e.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Xa(s[i],t[i]))}function Ch(s){if(!s||typeof s!="object")return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function Fw(s,t){if(s==null)return"";if(typeof s=="string"||typeof s=="number")return String(s);if(s instanceof y)return s.toElement();if(typeof s=="object"&&typeof s.nodeType=="number")return s;throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function Lw(s){let t=Math.trunc(Number(s));return Number.isFinite(t)?Math.max(1,Math.min(12,t)):3}var Ci=class extends y{static cssName="activity-item";static defaults={id:null,actor:"",avatar:null,title:"",content:null,timestamp:null,timeLabel:null,metadata:[],attachments:[],actions:[],kind:"default",state:"default",stateLabel:null,headingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("li");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._headingId=x("zx-activity-item-heading"),this._avatarComponent=null,this._actionsByKey=new Map,this._activity=Ih(this.options);try{return this.listen(e,"click",i=>this._onClick(i)),this._renderActivity(),e}catch(i){throw this._avatarComponent?.destroy(),this._avatarComponent=null,t||S(e,this._original),i}}setActivity(t={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("ActivityItem values must be an object");return this._activity=Ih({...this._activity,...t}),this._renderActivity(),this}getActivity(){return Eh(this._activity)}destroy(){this._cleaned||(this._cleaned=!0,this._avatarComponent?.destroy(),this._avatarComponent=null,super.destroy(),this._createdRoot||S(this.el,this._original))}_renderActivity(){this._avatarComponent?.destroy(),this._avatarComponent=null,this._actionsByKey.clear();let t=this._activity,e=this.el,i=qw(t.id);i===null?delete e.dataset.activityId:e.dataset.activityId=i,e.dataset.kind=$w(t.kind);let n=Rw(t.state,t.stateLabel);e.dataset.state=n.state,n.busy?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy");let r=vs(t.actor,"Activity actor"),o=vs(t.title,"Activity title"),a=[];r!==null&&a.push(l("span",{class:"zx-activity-item__actor"},r)),o!==null&&(a.length&&a.push(" "),a.push(l("span",{class:"zx-activity-item__title"},o)));let c=a.length?l(`h${Yw(t.headingLevel)}`,{class:"zx-activity-item__heading",id:this._headingId},a):null,d=Bw(t.timestamp,t.timeLabel),u=this._createStateBadge(n),h=c||d||u?l("header",{class:"zx-activity-item__header"},c,u,d):null,f=vs(t.content,"Activity content"),p=f===null?null:l("div",{class:"zx-activity-item__body"},f),_=Vw(t.metadata,"zx-activity-item__metadata","Activity metadata",this._message("activityItem.metadata","Activity metadata")),m=jw(t.attachments,"zx-activity-item__attachments","Attachments",this._message("activityItem.attachments","Attachments")),b=this._createActions(t.actions),w=l("div",{class:"zx-activity-item__main"},h,p,_,m,b),v=this._createAvatar(t.avatar,t.actor),z=l("article",{class:"zx-activity-item__article",ariaLabelledby:c?this._headingId:void 0,ariaLabel:c?void 0:this._message("activityItem.label","Activity")},v?l("div",{class:"zx-activity-item__avatar"},v):null,w);e.replaceChildren(z)}_createStateBadge(t){if(t.key===null||t.fallback===null)return null;let e=ht({label:t.label??this._message(t.key,t.fallback),kind:t.kind,size:"sm"});return e.classList.add("zx-activity-item__state"),e}_createAvatar(t,e){if(t===null)return null;if(E(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("ActivityItem avatar must be an Element, descriptor, or null");let i={...t,name:t.name||Ja(e),label:t.label??null,size:t.size??"md"};return this._avatarComponent=new de(null,i),this._avatarComponent.toElement()}_createActions(t){let e=Za(t);if(e.length===0)return null;let i=e.map((r,o)=>{if(E(r))return r;let a=String(o);return this._actionsByKey.set(a,r),Pw(r,a)}),n=Hw(this._activity,this._message("activityItem.untitled","activity"));return l("div",{class:"zx-activity-item__actions",role:"group",ariaLabel:this._message("activityItem.actions","Actions for %1",n)},i)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}_onClick(t){let i=(t.target&&typeof t.target=="object"?t.target:null)?.closest?.("[data-activity-action]")??null;if(!i||!this.el.contains(i))return;let n=this._actionsByKey.get(i.dataset.activityAction??"");if(!n||n.disabled){t.preventDefault();return}if(this.emit("action",{id:n.id,action:n,event:t},{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}n.onselect?.(t)}};function Za(s){if(!Array.isArray(s))return[];let t=[],e=new Set;for(let i of s){if(E(i)){t.push(i);continue}let n=tl(i);!n||e.has(n.id)||(e.add(n.id),t.push(n))}return t}function tl(s){if(!s||typeof s!="object"||Array.isArray(s))return null;let t=s;if(t.id===null||t.id===void 0)return null;let e=String(t.id).trim();if(!e)return null;let i=t.label==null?"":String(t.label),n=t.icon==null?null:String(t.icon).trim()||null,r=t.title==null?void 0:String(t.title);if(!i&&!r)return null;let o=t.href!==null&&t.href!==void 0,a=o?V(t.href):null;if(o&&a===null||t.onselect!==void 0&&typeof t.onselect!="function")return null;let c=t.target==null?void 0:String(t.target);return{id:e,label:i,icon:n,href:a,target:c,rel:Uw(t.rel,c),title:r,disabled:!!t.disabled,kind:Kw(t.kind),onselect:t.onselect}}var Th=Object.freeze({pending:Object.freeze({busy:!0,key:"activityItem.pending",fallback:"Sending\u2026",kind:"neutral"}),failed:Object.freeze({busy:!1,key:"activityItem.failed",fallback:"Failed",kind:"danger"})});function Rw(s,t){let e=String(s??"default"),i=Object.prototype.hasOwnProperty.call(Th,e)?Th[e]:null;return i?{state:e,busy:i.busy,key:i.key,fallback:i.fallback,kind:i.kind,label:t==null||t===""?null:String(t)}:{state:"default",busy:!1,key:null,fallback:null,kind:"neutral",label:null}}function el(s,t){let e=t==null?"":String(t).trim();if(s==null||s==="")return e?{dateTime:null,label:e}:null;let i=s instanceof Date?new Date(s.getTime()):new Date(s);if(Number.isNaN(i.getTime())){let n=e||(typeof s=="string"?s.trim():"");return n?{dateTime:null,label:n}:null}return{dateTime:i.toISOString(),label:e||Ww(i)}}function Ih(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ActivityItem options must be an object");for(let t of["metadata","attachments","actions"])if(!Array.isArray(s[t]))throw new TypeError(`ActivityItem ${t} must be an array`);return Eh(s)}function Eh(s){let t=s.avatar&&!E(s.avatar)?{...s.avatar}:s.avatar??null;return{...s,avatar:t,metadata:[...s.metadata??[]],attachments:[...s.attachments??[]],actions:[...s.actions??[]]}}function Pw(s,t){if(s.href&&!s.disabled){let i=l("a",{class:"zx-btn zx-activity-item__action",href:s.href,target:s.target,rel:s.rel,title:s.title,dataset:{activityAction:t,kind:s.kind,size:"sm"}});return s.icon&&i.append(g(s.icon,{size:16})),s.label&&i.append(l("span",{class:"zx-btn__label"},s.label)),!s.label&&s.title&&i.setAttribute("aria-label",s.title),i}let e=j({label:s.label,icon:s.icon,kind:s.kind,size:"sm",disabled:s.disabled,title:s.title});return e.classList.add("zx-activity-item__action"),e.dataset.activityAction=t,e}function Bw(s,t){let e=el(s,t);return e?e.dateTime===null?l("span",{class:"zx-activity-item__time"},e.label):l("time",{class:"zx-activity-item__time",dateTime:e.dateTime,title:e.label},e.label):null}function Vw(s,t,e,i){return s.length===0?null:l("ul",{class:t,ariaLabel:i},s.map(n=>l("li",{class:`${t}-item`},vs(n,e))))}function jw(s,t,e,i){return s.length===0?null:l("div",{class:t,role:"group",ariaLabel:i},s.map(n=>l("div",{class:`${t}-item`},vs(n,e))))}function vs(s,t){if(s===null||s==="")return null;if(typeof s=="string"||typeof s=="number")return String(s);if(s&&typeof s=="object"&&typeof s.nodeType=="number")return s;if(s instanceof y)return s.toElement();throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function Ja(s){return s===null?"":typeof s=="string"||typeof s=="number"?String(s).trim():s&&typeof s=="object"&&typeof s.nodeType=="number"?s.textContent?.trim()??"":s instanceof y?s.toElement().textContent?.trim()??"":""}function Hw(s,t){return Ja(s.title)||Ja(s.actor)||t}function qw(s){return typeof s=="string"||typeof s=="number"?String(s):null}function $w(s){return String(s??"default").trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-")||"default"}function Kw(s){return["default","primary","danger"].includes(String(s))?s:"ghost"}function Uw(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function Yw(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}function Ww(s){try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(s)}catch{return s.toLocaleString()}}var lr=class extends y{static cssName="activity-list";static defaults={items:[],groupBy:null,groupLabel:null,label:"Activity",variant:"default",loading:!1,loadingCount:3,loadingText:"Loading activity",emptyText:"No activity yet",groupHeadingLevel:2,itemHeadingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._items=Rt(this.options.items),this._loading=!!this.options.loading,this._itemComponents=[],this._groupSequence=0,e.setAttribute("aria-label",String(this.options.label||"Activity")),this._variant=Qw(this.options.variant),this._variant==="compact"&&(e.dataset.variant="compact");try{return this._renderList(),e}catch(i){throw this._destroyItems(),t||S(e,this._original),i}}setItems(t,e={}){return this._items=Rt(t),this._renderList(),e.silent||this._emitDataChange(),this}getItems(){return this._items.map(ar)}getItem(t){let e=this._items.find(i=>Object.is(i.id,t));return e?ar(e):null}appendItems(t,e={}){let i=Rt(Array.isArray(t)?t:[t]);return i.length===0?this:(this._items=Rt([...this._items,...i]),this._renderList(),e.silent||this._emitDataChange(),this)}prependItems(t,e={}){let i=Rt(Array.isArray(t)?t:[t]);return i.length===0?this:(this._items=Rt([...i,...this._items]),this._renderList(),e.silent||this._emitDataChange(),this)}updateItem(t,e,i={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("ActivityList update values must be an object");let n=this._items.findIndex(o=>Object.is(o.id,t));if(n<0)return this;let r=this._items.slice();return r[n]={...r[n],...e},this._items=Rt(r),this._renderList(),i.silent||this._emitDataChange(),this}removeItem(t,e={}){let i=this._items.findIndex(n=>Object.is(n.id,t));return i<0?this:(this._items.splice(i,1),this._renderList(),e.silent||this._emitDataChange(),this)}setLoading(t){let e=!!t;return e===this._loading?this:(this._loading=e,this._renderList(),this)}destroy(){this._cleaned||(this._cleaned=!0,this._destroyItems(),super.destroy(),this._createdRoot||S(this.el,this._original))}_renderList(){let t=this.el,e=un(t,i=>{let n=this._itemComponents.findIndex(o=>o.el?.contains(i));if(n<0)return null;let r=this._itemComponents[n];return{key:{id:r.getActivity().id??null,index:n},element:r.el}});this._renderItems(),hn(t,e,i=>{let n=i;return((n.id===null?void 0:this._itemComponents.find(a=>Object.is(a.getActivity().id??null,n.id)))??this._itemComponents[Math.min(n.index,this._itemComponents.length-1)])?.el??null})}_renderItems(){this._destroyItems(),this._groupSequence=0;let t=this.el;t.setAttribute("aria-busy",String(this._loading));let e=[];try{if(this._items.length>0){let i=this.options.groupBy??null,n=il(this._items,i),r=i!==null;for(let o of n)e.push(this._createGroup(o,r))}else this._loading||e.push(l("div",{class:"zx-activity-list__empty",role:"status"},Mh(this.options.emptyText,"ActivityList emptyText")));this._loading&&e.push(this._createLoading(this._items.length===0)),t.replaceChildren(...e)}catch(i){throw this._destroyItems(),i}}_createGroup(t,e){let i=l("ol",{class:"zx-activity-list__items"});for(let o of t.items){let a=new Ci(null,{...o,avatar:this._variant==="compact"?Xw(o.avatar):o.avatar,headingLevel:o.headingLevel??this.options.itemHeadingLevel});this._itemComponents.push(a),i.append(a.toElement())}if(!e)return i;this._groupSequence+=1;let n=x(`zx-activity-list-group-${this._groupSequence}`),r=this.options.groupLabel?this.options.groupLabel(t.id,t.items.map(ar)):String(t.id??"Other");return i.setAttribute("aria-labelledby",n),l("section",{class:"zx-activity-list__group",ariaLabelledby:n},l(`h${Gw(this.options.groupHeadingLevel,2)}`,{class:"zx-activity-list__group-heading",id:n},Mh(r,"ActivityList groupLabel")),i)}_createLoading(t){let e=l("div",{class:"zx-activity-list__loading",role:"status",ariaLive:"polite"},l("span",{class:"zx-activity-list__loading-label"},String(this.options.loadingText)));if(!t)return e;let i=l("div",{class:"zx-activity-list__skeletons",ariaHidden:"true"}),n=Jw(this.options.loadingCount);for(let r=0;r<n;r+=1)i.append(l("div",{class:"zx-activity-list__skeleton"},ot({width:"2.25rem",height:"2.25rem",radius:"full"}),yi({lines:2,heading:!0,lastLineWidth:r%2?"58%":"72%"})));return e.append(i),e}_destroyItems(){for(let t of this._itemComponents)t.destroy();this._itemComponents.length=0}_emitDataChange(){this.emit("datachange",{items:this.getItems()})}};function il(s,t=null){let e=Rt(s);if(t===null)return e.length?[{id:null,items:e}]:[];if(typeof t!="string"&&typeof t!="function")throw new TypeError("ActivityList groupBy must be a property, function, or null");let i=new Map;return e.forEach((n,r)=>{let o=typeof t=="function"?t(n,r):n[t];i.has(o)||i.set(o,[]),i.get(o).push(n)}),Array.from(i,([n,r])=>({id:n,items:r}))}function Rt(s){if(!Array.isArray(s))throw new TypeError("ActivityList items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("ActivityList items must be descriptor objects");for(let n of["metadata","attachments","actions"])if(e[n]!==void 0&&!Array.isArray(e[n]))throw new TypeError(`ActivityList item ${n} must be an array`);let i=e;if(i.id!==null&&i.id!==void 0){if(t.has(i.id))throw new RangeError(`Duplicate ActivityList id: ${String(i.id)}`);t.add(i.id)}return ar(i)})}function ar(s){let t=s.avatar&&Dh(s.avatar)?{...s.avatar}:s.avatar;return{...s,avatar:t,metadata:[...s.metadata??[]],attachments:[...s.attachments??[]],actions:[...s.actions??[]]}}function Mh(s,t){if(s===null)return"";if(typeof s=="string"||typeof s=="number")return String(s);if(s&&typeof s=="object"&&typeof s.nodeType=="number")return s;if(s instanceof y)return s.toElement();throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function Dh(s){return!s||typeof s!="object"||Array.isArray(s)?!1:typeof s.nodeType!="number"&&!(s instanceof y)}function Gw(s,t){let e=Math.trunc(Number(s));return e>=1&&e<=6?e:t}function Qw(s){return s==="compact"?"compact":"default"}function Xw(s){if(!Dh(s))return s;let t=s;return t.size==null?{...t,size:"sm"}:t}function Jw(s){let t=Math.trunc(Number(s));return Number.isFinite(t)?Math.max(1,Math.min(12,t)):3}var cr=class extends y{static cssName="account-menu";static defaults={account:{},items:[],compact:!1,label:null,placement:"top-start"};constructor(t=null,e={}){super(t,e);for(let i of["select","open","close"])this.listen(this.refs.trigger,`zx-${i}`,n=>n.stopPropagation());this._avatar=new de(this.refs.avatar,Oh(this._account)),this._menu=new at(this.refs.trigger,{items:this.options.items,placement:this.options.placement}),this._menu.on("select",i=>{this.emit("select",i.detail).defaultPrevented&&i.preventDefault()}),this._menu.on("open",()=>this.emit("open")),this._menu.on("close",()=>this.emit("close")),this._renderIdentity()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._account=Nh(this.options.account),t.dataset.compact=String(!!this.options.compact),t.replaceChildren(l("button",{ref:"trigger",class:"zx-account-menu__trigger",type:"button"},l("span",{ref:"avatar",class:"zx-account-menu__avatar"}),l("span",{class:"zx-account-menu__identity"},l("span",{ref:"name",class:"zx-account-menu__name"}),l("span",{ref:"secondary",class:"zx-account-menu__secondary"})),l("span",{class:"zx-account-menu__chevron",ariaHidden:"true"},g("chevron-down")))),t}open(){return this._menu.open(),this}close(){return this._menu.close(),this}toggle(){return this._menu.toggle(),this}isOpen(){return this._menu.isOpen()}setAccount(t){return this._account=Nh(t),this._avatar.set(Oh(this._account)),this._renderIdentity(),this}setCompact(t){return this.el.dataset.compact=String(!!t),this}setItems(t){return this._menu.setItems(t),this._renderPanelHeader(),this}focus(){return this._menu.getTrigger().focus(),this}getPanel(){return this._menu.getPanel()}destroy(){let t=this._original;if(this._menu.destroy(),this._avatar.destroy(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_renderIdentity(){this.refs.name.textContent=this._account.name,this.refs.secondary.textContent=this._account.secondary,this.refs.secondary.hidden=!this._account.secondary;let e=["online","away","busy","offline"].includes(this._account.status)&&this._account.statusLabel?`, ${this._account.statusLabel}`:"",i=this.options.label||`Account menu${this._account.name?` for ${this._account.name}`:""}${e}`;this.refs.trigger.setAttribute("aria-label",i),this._renderPanelHeader()}_renderPanelHeader(){let t=this._menu.getPanel();t.querySelector(".zx-account-menu__panel-identity")?.remove(),t.prepend(l("div",{class:"zx-account-menu__panel-identity",role:"presentation"},l("strong",{},this._account.name||"Account"),this._account.secondary?l("span",{},this._account.secondary):null))}};function Nh(s){let t=s&&typeof s=="object"?s:{};return{...t,name:String(t.name??""),secondary:String(t.secondary??"")}}function Oh(s){return{name:s.name,src:s.src??null,initials:s.initials??null,status:s.status??null,statusLabel:s.statusLabel??null,label:null,size:"md"}}var ur=class extends y{static cssName="workspace-switcher";static defaults={workspaces:[],active:null,items:[],compact:!1,heading:null,label:null,placement:"bottom-start"};constructor(t=null,e={}){super(t,e);for(let i of["select","open","close"])this.listen(this.refs.trigger,`zx-${i}`,n=>n.stopPropagation());this._menu=new at(this.refs.trigger,{items:[],placement:this.options.placement}),this._menu.getPanel().classList.add("zx-workspace-switcher__menu"),this._menu.on("select",i=>this._onMenuSelect(i)),this._menu.on("open",()=>this.emit("open")),this._menu.on("close",()=>this.emit("close")),this._sync()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._workspaces=Fh(this.options.workspaces),this._activeId=Lh(this._workspaces,this.options.active),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._entries=new Map,t.dataset.compact=String(!!this.options.compact),t.replaceChildren(l("button",{ref:"trigger",class:"zx-workspace-switcher__trigger",type:"button"},l("span",{ref:"tile",class:"zx-workspace-switcher__tile",ariaHidden:"true"}),l("span",{class:"zx-workspace-switcher__text"},l("span",{ref:"name",class:"zx-workspace-switcher__name"}),l("span",{ref:"secondary",class:"zx-workspace-switcher__secondary"})),l("span",{class:"zx-workspace-switcher__chevron",ariaHidden:"true"},g("chevron-down")))),t}getActive(){return sl(this._workspaces,this._activeId)}setActive(t,{silent:e=!0}={}){let i=sl(this._workspaces,t);return!i||i.disabled||dr(i.id,this._activeId)?this:!e&&this._emitSelect(i).defaultPrevented?this:(this._activeId=i.id,this._sync(),this)}setWorkspaces(t){return this._workspaces=Fh(t),this._activeId=Lh(this._workspaces,this._activeId),this._sync(),this}setItems(t){return this._items=Array.isArray(t)?t.slice():[],this._renderMenu(),this}setCompact(t){return this.el.dataset.compact=String(!!t),this._renderTrigger(),this}open(){return this._menu.open(),this}close(){return this._menu.close(),this}toggle(){return this._menu.isOpen()?this._menu.close():this._menu.open(),this}isOpen(){return this._menu.isOpen()}focus(){return this._menu.getTrigger().focus(),this}getPanel(){return this._menu.getPanel()}destroy(){let t=this.el,e=this._snapshot;this._menu?.destroy(),super.destroy(),!this._createdRoot&&t&&S(t,e)}_sync(){this._renderTrigger(),this._renderMenu()}_renderTrigger(){let t=this.getActive(),e=t?.label??"";this.refs.tile.replaceChildren(...t?[Rh(t)]:[]),this.refs.tile.hidden=!t,this.refs.name.textContent=e,this.refs.secondary.textContent=t?.secondary??"",this.refs.secondary.hidden=!t?.secondary;let i=this.options.label?ev(this.options.label,e):e?this._message("workspaceSwitcher.label","Switch workspace: %1",e):this._message("workspaceSwitcher.labelEmpty","Switch workspace");this.refs.trigger.setAttribute("aria-label",i),this.el.dataset.compact==="true"&&e?this.refs.trigger.setAttribute("title",e):this.refs.trigger.removeAttribute("title")}_renderMenu(){this._entries=new Map;let t=[],e=this.options.heading==null?this._message("workspaceSwitcher.heading","Workspaces"):String(this.options.heading);e&&this._workspaces.length&&t.push({type:"heading",label:e});let i=[];for(let r of this._workspaces){let o={label:r.label,value:r.id,role:"menuitemradio",checked:dr(r.id,this._activeId),description:r.secondary||void 0,badge:r.badge??void 0,disabled:r.disabled,adornment:l("span",{class:"zx-workspace-switcher__check",ariaHidden:"true"},g("check"))};this._entries.set(o,r),i.push([t.length,r]),t.push(o)}this._workspaces.length&&this._items.length&&!iv(this._items[0])&&t.push("-"),t.push(...this._items),this._menu.setItems(t);let n=this._menu.getPanel();for(let[r,o]of i){let a=n.querySelector(`[data-menu-item="${r}"]`);a&&(a.classList.add("zx-workspace-switcher__option"),a.querySelector(".zx-menu-button__leading")?.replaceChildren(Rh(o)))}}_onMenuSelect(t){let e=this._entries.get(t.detail.item);if(!e){this.emit("action",t.detail,{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault();return}if(!dr(e.id,this._activeId)){if(this._emitSelect(e).defaultPrevented){t.preventDefault();return}this._activeId=e.id,this._sync()}}_emitSelect(t){return this.emit("select",{workspace:t,id:t.id,previous:this.getActive()},{honorDomCancellation:!0})}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function Zw(s){if(!s||typeof s!="object")return null;let t=s,e=t.id;if((typeof e!="string"||e==="")&&(typeof e!="number"||!Number.isFinite(e)))return null;let i=String(t.label??e).trim()||String(e),n=typeof t.color=="string"&&t.color.trim()?t.color.trim():null,r=_s.includes(t.tone)?t.tone:n?null:ue(i),o=typeof t.src=="string"&&t.src.trim()?t.src.trim():null,a=t.badge==null||t.badge===""?void 0:t.badge;return{...t,id:e,label:i,secondary:t.secondary==null?"":String(t.secondary),tone:r,color:n,src:o,badge:a,initials:tv(i,t.initials),disabled:!!t.disabled}}function Fh(s){if(!Array.isArray(s))return[];let t=new Set,e=[];for(let i of s){let n=Zw(i);!n||t.has(String(n.id))||(t.add(String(n.id)),e.push(n))}return e}function Lh(s,t){let e=t==null?null:sl(s,t);return e&&!e.disabled?e.id:(s.find(i=>!i.disabled)??null)?.id??null}function tv(s,t){let e=typeof t=="string"?t.trim():"";return e?Array.from(e).slice(0,2).join(""):Te(s,1)}function ev(s,t){return T(String(s),[t==null?"":String(t)])}function sl(s,t){return t==null?null:s.find(e=>dr(e.id,t))??null}function dr(s,t){return s!=null&&t!=null&&String(s)===String(t)}function iv(s){return s==="-"||!!(s&&typeof s=="object"&&s.type==="separator")}function Rh(s){if(s.src)return l("span",{class:"zx-workspace-switcher__image"},l("img",{src:s.src,alt:"",decoding:"async"}));let t=s.icon&&typeof s.icon=="object"&&"nodeType"in s.icon?s.icon.cloneNode(!0):typeof s.icon=="string"&&s.icon?s.icon:l("span",{class:"zx-workspace-switcher__initials"},s.initials??"");return vi({icon:t,tone:s.tone??null,color:s.color??null,size:"var(--zx-workspace-switcher-tile)",iconSize:typeof t=="string"?"58%":"50%",glass:"subtle"})}var sv=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),nv=new Set(["hover","focus","both","manual"]),mt=class extends y{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#t;#e;#i=null;#s=null;#r=0;#n=0;#o=!1;#a=!1;#c=null;#l=!1;#d=!1;constructor(t,e={}){let i=P(t);if(!i)throw new TypeError("Tooltip anchor could not be resolved");super(null,e),this.#t=i,oe(i,{dialog:!1})?.append(this.el),this.#e=this.options.content,this.#l=!!this.options.disabled,this.#s=i.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",av(this.options.maxWidth));let n=nv.has(this.options.trigger)?this.options.trigger:"both";if(n!=="manual"){this.#a=!0,(n==="hover"||n==="both")&&(this.listen(this.#t,"pointerenter",r=>{r.pointerType!=="touch"&&this.#f(Number(this.options.delay))}),this.listen(this.#t,"pointerleave",()=>this.#h(Number(this.options.hideDelay)))),(n==="focus"||n==="both")&&(this.listen(this.#t,"focusin",()=>{this.#o||!lv(this.#t)||this.#f(0)}),this.listen(this.#t,"focusout",()=>this.#h(Number(this.options.hideDelay)))),this.listen(this.#t,"pointerdown",()=>{this.#o=!0,this.#u(),this.hide()});for(let r of["pointerup","pointercancel","pointerleave"])this.listen(this.#t,r,()=>{this.#o=!1})}}render(){let t=l("div",{id:x("zx-tooltip"),role:"tooltip",popover:"manual"});return t.dataset.state="closed",t}show(){if(this.#d||this.#l||this.isOpen())return this;this.#u();let t=ns(this.#t);this.el.parentElement!==t&&t.append(this.el);let e=Ph(this.#e);if(e===null)return this;this.el.replaceChildren(e);let i=sv.has(this.options.placement)?this.options.placement:"top";return this.#i=nt(this.#t,this.el,{placement:i,offset:Number(this.options.offset),flip:!0}),/^(left|right)/.test(i)&&this.el.style.getPropertyValue("position-try-fallbacks")&&this.el.style.setProperty("position-try-fallbacks","flip-inline, top span-all, bottom span-all"),this.el.dataset.state="open",this.#t.setAttribute("aria-describedby",ov(this.#s,this.el.id)),this.#c=le({kind:"tooltip",root:this.el,owner:this,anchor:this.#t,inside:[this.#t],onEscape:this.#a?()=>{this.hide()}:void 0,onOutsidePointer:this.#a?()=>this.hide():void 0,onFocusOutside:this.#a?()=>this.hide():void 0,onParentClose:()=>this.hide()}),this.emit("open"),this}hide(){if(this.#u(),!this.isOpen())return this;this.#i?.destroy(),this.#i=null,this.el.dataset.state="closed",this.el.replaceChildren(),this.#p();let t=this.#c;return this.#c=null,t?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.hide():this.show()}isOpen(){return this.#i!==null}setContent(t){if(this.#e=t,!this.isOpen())return this;let e=Ph(t);return e===null?this.hide():(this.el.replaceChildren(e),this.#i?.update(),this)}enable(){return this.#l=!1,this}disable(){return this.#l=!0,this.hide()}isDisabled(){return this.#l}getAnchor(){return this.#t}destroy(){this.#d||(this.#d=!0,this.hide(),this.#p(),super.destroy())}#f(t){if(this.#u(),this.#d||this.#l||this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.show();return}this.#r=setTimeout(()=>{this.#r=0,this.show()},e)}#h(t){if(this.#u(),!this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.hide();return}this.#n=setTimeout(()=>{this.#n=0,this.hide()},e)}#u(){this.#r!==0&&clearTimeout(this.#r),this.#n!==0&&clearTimeout(this.#n),this.#r=0,this.#n=0}#p(){this.#s===null?this.#t.removeAttribute("aria-describedby"):this.#t.setAttribute("aria-describedby",this.#s)}};function Bh(s,t=""){return new mt(s,rv(t)?t:{content:t})}function Vh(s,t){return new mt(s,{content:String(t??"")})}function rv(s){return s===null||typeof s!="object"||Array.isArray(s)||typeof s.nodeType=="number"?!1:typeof s.toElement!="function"}function Ph(s){let t=typeof s=="function"?s():s;if(t==null)return null;if(typeof t=="object"&&typeof t.nodeType=="number")return t;if(typeof t=="object"&&typeof t.toElement=="function")return t.toElement();let e=String(t);return e===""?null:document.createTextNode(e)}function ov(s,t){let e=String(s??"").split(/\s+/).filter(Boolean);return e.includes(t)||e.push(t),e.join(" ")}function av(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function lv(s){try{return s.matches(":focus-visible")}catch{return!0}}var Ti=class extends y{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(t=null,e={}){super(t,e),this._rebuild()}render(){this._createdRoot=this.el===null;let t=this.el??l("nav");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,o=>[o.name,o.value]),children:Array.from(t.childNodes)},this._items=Pt(this.options.items),this._active=this.options.active,this._flyouts=new Map,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._openTimers=new Map,this._closeTimers=new Map,this._pointerFocus=new WeakSet,this._silenceFlyoutEvents=!1,t.setAttribute("aria-label",String(this.options.label)),t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.dataset.orientation=this.options.orientation==="horizontal"?"horizontal":"vertical";let e=t.dataset.orientation==="horizontal"?["top","bottom"]:["left","right"];t.dataset.side=e.includes(this.options.side)?this.options.side:e[0];let i=this._partBlock(),n=l("div",{class:`${i}__header`}),r=l("div",{class:`${i}__footer`});return qh(n,this.options.header),qh(r,this.options.footer),n.hidden=!n.hasChildNodes(),r.hidden=!r.hasChildNodes(),t.replaceChildren(n,l("ul",{ref:"list",class:`${i}__list`}),r),this.listen(t,"keydown",o=>this._onRailKeydown(o)),t}setItems(t){return this._items=Pt(t),this._rebuild(),this}setActive(t){return this._active=t,this._syncActive(),this}getItems(){return this._items.map(t=>({...t,children:t.children?.map(e=>({...e}))}))}openFlyout(t,{focus:e=!1}={}){let i=this._resolveFlyout(t);if(!i)return this;let n=[i],r=i.parentKey===null?null:this._flyouts.get(i.parentKey)??null;for(;r;)n.unshift(r),r=r.parentKey===null?null:this._flyouts.get(r.parentKey)??null;if(n.some(o=>o.item.disabled))return this;this._cancelFlyoutTimers(i,!0);for(let[o,a]of this._flyouts)o!==i.key&&a.dropdown.isOpen()&&!this._isAncestor(a,i)&&this.closeFlyout(o);for(let o of n)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return e&&Hh(i.panel)?.focus(),this}closeFlyout(t){let e=this._resolveFlyout(t);if(!e)return this;for(let i of[...this._flyouts.values()].reverse())i!==e&&this._isAncestor(e,i)&&(this._cancelTimers(i.key),i.dropdown.close());return this._cancelTimers(e.key),e.dropdown.close(),this}closeAllFlyouts(){for(let t of this._flyouts.values())t.parentKey===null&&this.closeFlyout(t.key);for(let t of[...this._flyouts.values()].reverse())this._cancelTimers(t.key),t.dropdown.isOpen()&&t.dropdown.close();return this}isFlyoutOpen(t){return this._resolveFlyout(t)?.dropdown.isOpen()??!1}focus(){return Hh(this.refs.list)?.focus(),this}_containsNode(t){return!!(t&&(this.el.contains(t)||[...this._flyouts.values()].some(e=>e.panel.contains(t))))}destroy(){let t=this._original;if(this._clearArtifacts(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new nl(this.el);let t=!1;for(let e of rl(this._items)){if(e===$h){t&&this.refs.list.append(l("li",{class:`${this._partBlock()}__separator`,ariaHidden:"true"}));continue}t=!0;let i=Array.isArray(e.children)&&e.children.length>0&&this._flyoutsFor(e),n=this._renderControl(e,i),r=l("li",{class:`${this._partBlock()}__row`},n);if(this.refs.list.append(r),this._tooltipFor(e)){let o=new mt(n,{content:e.label,placement:fv(this.el.dataset.side),delay:450});this._tooltips.push(o),this._tooltipById.set(String(e.id),o)}i?this._buildFlyout(e,n,String(e.id),null):this._interaction.listen(n,"click",o=>{if(!this._select(e,o).defaultPrevented)for(let c of this._flyouts.values())c.parentKey===null&&c.dropdown.isOpen()&&this.closeFlyout(c.key)})}this._afterRebuild(),this._syncActive()}_partBlock(){return this.constructor.partBlock}_renderControl(t,e){return jh(t,{className:"zx-app-rail__item",index:String(t.id),iconOnly:!0,disclosure:e,disclosureIcon:cv(this.el.dataset.side),visual:Ii(t,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:"root"})})}_flyoutsFor(t){return!0}_tooltipFor(t){return!0}_afterRebuild(){}_buildFlyout(t,e,i,n){let r=l("ul",{class:"zx-app-rail__flyout-list"});for(let h of rl(t.children??[],!0)){if(h.section){r.append(l("li",{class:"zx-app-rail__flyout-section"},h.label));continue}let f=`${i}/${h.id}`,p=!!h.children?.length,_=jh(h,{className:"zx-app-rail__flyout-item",index:f,iconOnly:!1,disclosure:p,disclosureIcon:dv(this.el.dataset.side),visual:Ii(h,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:f.split("/").length,location:"flyout"})});r.append(l("li",{},_)),p?this._buildFlyout(h,_,f,i):this._interaction.listen(_,"click",m=>{this._select(h,m).defaultPrevented||this._closeFlyoutChain(i)})}let o=l("div",{class:"zx-app-rail__flyout"},l("div",{class:"zx-app-rail__flyout-title"},t.label),r),a=new pt(e,{openOn:"manual",placement:n===null?uv(this.el.dataset.side):hv(this.el.dataset.side),content:o,offset:6}),c=a.getPanel();a._configure({tabReach:!1,onEscape:()=>{let h=c.contains(document.activeElement);this.closeFlyout(i),h&&this._restoreFocus(e)}}),c.classList.add("zx-app-rail__popover"),c.dataset.side=this.el.dataset.side,c.setAttribute("role","region"),c.setAttribute("aria-label",this._message("appRail.subNavigation","%1 sub-navigation",t.label));let d={key:i,parentKey:n,item:t,trigger:e,panel:c,dropdown:a};this._flyouts.set(i,d);let u=n===null?this._tooltipById.get(String(t.id)):null;a.on("open",()=>{u?.disable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!0})}),a.on("close",()=>{u?.enable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!1})}),this._interaction.listen(e,"pointerdown",()=>{this._pointerFocus.add(e),queueMicrotask(()=>this._pointerFocus.delete(e))}),this._interaction.listen(e,"pointerenter",h=>{h.pointerType!=="touch"&&this._scheduleOpen(i)}),this._interaction.listen(e,"pointerleave",()=>this._scheduleClose(i)),this._interaction.listen(e,"focus",()=>{this._pointerFocus.has(e)||this.openFlyout(i)}),this._interaction.listen(e,"focusout",h=>{c.contains(h.relatedTarget)||this._scheduleClose(i)}),this._interaction.listen(e,"click",h=>{h.preventDefault(),h instanceof MouseEvent&&h.detail===0?this.openFlyout(i,{focus:!0}):this.openFlyout(i)}),this._interaction.listen(c,"pointerenter",()=>this._cancelFlyoutTimers(d,!0)),this._interaction.listen(c,"pointerleave",()=>this._scheduleFlyoutClose(d,!0)),this._interaction.listen(c,"focusin",()=>this._cancelFlyoutTimers(d,!0)),this._interaction.listen(c,"focusout",h=>{h.relatedTarget!==e&&!c.contains(h.relatedTarget)&&this._scheduleFlyoutClose(d,!0)}),this._interaction.listen(c,"keydown",h=>this._onFlyoutKeydown(h,d))}_select(t,e){if(t.disabled){e.preventDefault();let n=new Event("select",{cancelable:!0});return n.preventDefault(),n}let i=this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e});return i.defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.()),i}_onRailKeydown(t){let e=pv(this.refs.list),i=t.target?.closest?.("[data-app-nav-id]"),n=e.indexOf(i);if(n<0)return;let r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",c={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],d=i.getAttribute("data-app-nav-id");if(t.key===c&&this._flyouts.has(String(d))){t.preventDefault(),this.openFlyout(String(d),{focus:!0});return}let u;if(t.key==="Home")u=0;else if(t.key==="End")u=e.length-1;else if(t.key===o)u=(n-1+e.length)%e.length;else if(t.key===a)u=(n+1)%e.length;else return;t.preventDefault(),e[u]?.focus()}_onFlyoutKeydown(t,e){let i=Kh(e.panel),n=t.target?.closest?.("a, button"),r=i.indexOf(n),o=[...this._flyouts.values()].find(u=>u.trigger===n),a=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",c=a==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&t.key===a){t.preventDefault(),t.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if((e.parentKey!==null||this.el.dataset.orientation==="vertical")&&t.key===c){t.preventDefault(),t.stopPropagation(),this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}if(i.length===0)return;let d;if(t.key==="Home")d=0;else if(t.key==="End")d=i.length-1;else if(t.key==="ArrowDown")d=(r+1+i.length)%i.length;else if(t.key==="ArrowUp")d=(r-1+i.length)%i.length;else return;t.preventDefault(),i[d]?.focus()}_scheduleOpen(t){let e=String(t);this._cancelTimer(this._closeTimers,e),this._cancelTimer(this._openTimers,e);let i=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(e,setTimeout(()=>{this._openTimers.delete(e),this.openFlyout(t)},i))}_scheduleClose(t){let e=String(t);this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e);let i=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(e,setTimeout(()=>{this._closeTimers.delete(e);let n=this._flyouts.get(e);n&&(this._branchInteracting(n)||this.closeFlyout(e))},i))}_scheduleFlyoutClose(t,e){let i=t;for(;i&&(this._scheduleClose(i.key),!(!e||i.parentKey===null));)i=this._flyouts.get(i.parentKey)??null}_resolveFlyout(t){let e=String(t);return this._flyouts.get(e)??[...this._flyouts.values()].find(i=>String(i.item.id)===e)??null}_closeFlyoutChain(t){let e=this._flyouts.get(t)??null;for(;e?.parentKey!==null;)e=this._flyouts.get(e.parentKey)??null;e&&this.closeFlyout(e.key)}_isAncestor(t,e){let i=e.parentKey;for(;i!==null;){if(i===t.key)return!0;i=this._flyouts.get(i)?.parentKey??null}return!1}_cancelFlyoutTimers(t,e){let i=t;for(;i&&(this._cancelTimers(i.key),!(!e||i.parentKey===null));)i=this._flyouts.get(i.parentKey)??null}_branchInteracting(t){return t.trigger.matches(":hover")||t.panel.matches(":hover")||t.trigger===document.activeElement||t.panel.contains(document.activeElement)?!0:[...this._flyouts.values()].some(e=>this._isAncestor(t,e)&&e.dropdown.isOpen()&&(e.trigger.matches(":hover")||e.panel.matches(":hover")||e.trigger===document.activeElement||e.panel.contains(document.activeElement)))}_restoreFocus(t){this._pointerFocus.add(t),t.focus(),queueMicrotask(()=>this._pointerFocus.delete(t))}_cancelTimers(t){this._cancelTimer(this._openTimers,t),this._cancelTimer(this._closeTimers,t)}_cancelTimer(t,e){let i=t.get(e);i!==void 0&&clearTimeout(i),t.delete(e)}_syncActive(){let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let i=t!==null&&e.getAttribute("data-app-nav-value-id")===t,n=this._flyouts.get(String(e.getAttribute("data-app-nav-id"))),r=t!==null&&n?ol(n.item.children??[],t):!1;i?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),r?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}for(let e of this._flyouts.values()){t!==null&&ol(e.item.children??[],t)?e.trigger.dataset.activeDescendant="true":delete e.trigger.dataset.activeDescendant;for(let n of e.panel.querySelectorAll("[data-app-nav-value-id]"))t!==null&&n.getAttribute("data-app-nav-value-id")===t?n.setAttribute("aria-current","page"):n.removeAttribute("aria-current")}}_clearArtifacts(){for(let t of this._openTimers?this._openTimers.values():[])clearTimeout(t);for(let t of this._closeTimers?this._closeTimers.values():[])clearTimeout(t);this._openTimers?.clear?.(),this._closeTimers?.clear?.(),this._interaction?.destroy?.();for(let t of this._tooltips??[])t.destroy();this._silenceFlyoutEvents=!0;for(let t of this._flyouts?.values?.()??[])t.dropdown.destroy();this._silenceFlyoutEvents=!1,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._flyouts=new Map}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}},nl=class extends y{constructor(t){super(null),t.append(this.el)}render(){return l("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}},$h=Object.freeze({});function rl(s,t=!1){return s.flatMap(e=>e.section?[t?e:$h,...rl(e.children??[],t)]:[e])}function Pt(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.label!=null&&(t.id!=null||t.section===!0)).map((t,e)=>{let i={...t,id:t.id??`section:${e}:${t.label}`,label:String(t.label),children:Array.isArray(t.children)?Pt(t.children):[]};if(t.section===!0)return i.section=!0,delete i.href,i;if(t.href==null)return i;let n=V(t.href);return n!==null?i.href=n:(delete i.href,i.children.length===0&&typeof i.invoke!="function"&&(i.disabled=!0)),i}):[]}function Ii(s,t,e){let i=typeof t=="function"?t(s,e):null;if(i==null&&(i=s.icon),typeof i=="function"&&(i=i(e,s)),typeof i=="string")return g(i);if(i instanceof Node)return i.cloneNode(!0);if(i&&typeof i=="object"&&typeof i.toElement=="function"){let n=i.toElement();return n instanceof Node?n.cloneNode(!0):null}return null}function jh(s,{className:t,index:e,iconOnly:i,disclosure:n,disclosureIcon:r,visual:o}){let a=V(s.href),c=a&&!n?"a":"button";return l(c,{class:t,type:c==="button"?"button":null,href:c==="a"?a:null,target:c==="a"?s.target??null:null,rel:c==="a"?"noopener":null,ariaLabel:i?s.label:null,ariaDisabled:s.disabled?"true":null,dataset:{appNavId:e,appNavValueId:String(s.id)}},o?l("span",{class:`${t}-icon`,ariaHidden:"true"},o):null,l("span",{class:`${t}-label`},s.label),s.badge!=null?l("span",{class:`${t}-badge`},String(s.badge)):null,n?l("span",{class:`${t}-disclosure`,ariaHidden:"true"},g(r)):null)}function cv(s){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[s]??"chevron-right"}function dv(s){return s==="right"?"chevron-left":"chevron-right"}function uv(s){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[s]??"right-start"}function hv(s){return s==="right"?"left-start":"right-start"}function fv(s){return{left:"right",right:"left",top:"bottom",bottom:"top"}[s]??"right"}function Kh(s){return[...s.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function Hh(s){return Kh(s)[0]??null}function pv(s){return[...s.children].map(t=>t.querySelector("[data-app-nav-id]")).filter(Boolean)}function ol(s,t){return s.some(e=>String(e.id)===t||ol(e.children??[],t))}function qh(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&s.append(t)}var _v=["tint","solid","plain"],mv=12,gv=600,ct=class extends Ti{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(t=null,e={}){super(t,e)}render(){let t=super.render();return this._sections=new Map,this._items=xs(this._items,this._sections),this._appearance=_v.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},t.setAttribute("aria-label",this._labelText()),t.dataset.appearance=this._appearance,t.dataset.menus=this._menus,t.dataset.allModules=["always","never"].includes(this.options.allModules)?this.options.allModules:"auto",t.dataset.labels=al(this.options.labels,t.dataset.orientation),t}setItems(t){let e=new Map,i=xs(Pt(t),e);return this._sections=e,super.setItems(i)}getItems(){return super.getItems()}setActive(t){return super.setActive(t)}openFlyout(t,e={}){return super.openFlyout(t,e)}closeFlyout(t){return super.closeFlyout(t)}closeAllFlyouts(){return super.closeAllFlyouts()}isFlyoutOpen(t){return super.isFlyoutOpen(t)}setExpanded(t){return this._expandedId=t??null,this._syncExpanded(),this._layout(),this}setBadge(t,e){let i=Ut(this._items,t);if(!i)return this;e==null||e===""?delete i.badge:i.badge=e;let n=String(t);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,i);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&&ll(a,i,"zx-app-rail__flyout-item");let r=this._catalogueEntry(n);return r&&ll(r,i,"zx-module-bar__entry"),this}setLayout(t={}){let e=t.orientation==="horizontal"||t.orientation==="vertical"?t.orientation:this.el.dataset.orientation,i=e==="horizontal"?["top","bottom"]:["left","right"],n=i.includes(t.side??this.el.dataset.side)?t.side??this.el.dataset.side:i[0];return e===this.el.dataset.orientation&&n===this.el.dataset.side?this:(this.el.dataset.orientation=e,this.el.dataset.side=n,this.el.dataset.labels=al(this._labels,e),this._rebuild(),this)}setLabels(t){this._labels=t;let e=al(t,this.el.dataset.orientation);if(e===this.el.dataset.labels)return this;let i=document.activeElement,n=i instanceof HTMLElement&&this.refs.list.contains(i)&&i.matches(".zx-module-bar__item")?hr(i):null;return this.el.dataset.labels=e,this._rebuild(),n!==null&&[...this.refs.list.querySelectorAll(".zx-module-bar__item")].find(r=>hr(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(t){return super._containsNode(t)||!!(t&&this._catalogue?.getPanel().contains(t))}_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(t){return this._menus==="flyout"&&!t.disabled}_tooltipFor(){return this.el.dataset.labels==="hidden"}_renderControl(t){let e=!!t.children?.length,i=t.href&&!e?"a":"button",n=this.el.dataset.labels!=="hidden",r=l(i,{class:"zx-module-bar__item",type:i==="button"?"button":null,href:i==="a"?t.href:null,target:i==="a"?t.target??null:null,rel:i==="a"&&t.target?"noopener":null,ariaDisabled:t.disabled?"true":null,tabIndex:-1,dataset:{appNavId:String(t.id),appNavValueId:String(t.id)}},this._renderTile(t,"bar"),n?l("span",{class:"zx-module-bar__label"},t.label):null);return this._applyTileBadge(r,t),r}_afterRebuild(){let t=this.refs.list,e=Gh(this._items),i=new Map;for(let r of[...t.children]){let o=r.querySelector("[data-app-nav-value-id]")?.getAttribute("data-app-nav-value-id");o!=null&&(r.dataset.moduleId=o,i.set(o,r))}let n=null;for(let r of e){let o=i.get(String(r.id));if(!o)continue;let a=this._sections.get(String(r.id))??null;a!==null&&a!==n&&t.append(l("li",{class:"zx-module-bar__heading",dataset:{section:a}},l("span",{class:"zx-module-bar__heading-label"},a))),n=a,t.append(o)}this._promoted!==null&&!Ut(this._items,this._promoted)&&(this._promoted=null),this._buildCatalogue(),this._interaction.listen(t,"focusin",r=>{let o=r.target.closest?.(".zx-module-bar__item");o instanceof HTMLElement&&this._setRovingStop(o)}),this._interaction.listen(t,"focusout",r=>{t.contains(r.relatedTarget)||(this._rovingId=null,this._syncRoving())}),typeof ResizeObserver=="function"&&(this._observer=new ResizeObserver(()=>this._layout()),this._observer.observe(t))}_syncActive(){super._syncActive();let t=this._active==null?null:String(this._active);for(let e of this._tiles()){let i=Ut(this._items,e.getAttribute("data-app-nav-value-id"));if(!i)continue;let n=Wh(i,t);n?e.setAttribute("aria-current",n):e.removeAttribute("aria-current"),n==="true"?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}for(let e of this._catalogueEntries()){let i=Ut(this._items,e.dataset.moduleId),n=i?Wh(i,t):null;n?e.setAttribute("aria-current",n):e.removeAttribute("aria-current")}this._syncExpanded(),this._layout()}_layout(){let t=this.refs.list;if(!t||!this._items)return;let e=[...t.querySelectorAll(":scope > [data-module-id]")],i=t.querySelector(":scope > [data-module-bar-more]"),n=this.el.dataset.allModules,r=[fr(this._items,this._active)?.id,this._expandedId,this._promoted],o=1/0;if(n!=="never"&&t.isConnected){for(let h of e)h.hidden=!1;i&&(i.hidden=!1),Uh(t),o=bv(t,this.el.dataset.orientation==="horizontal",e.length+1)}let a=cl(this._items,o,r,n==="always"),c=new Set(a.visible.map(h=>String(h.id)));for(let h of e)h.hidden=!c.has(h.dataset.moduleId);Uh(t),i&&(i.hidden=n==="never"||n==="auto"&&!a.more);let d={visible:a.visible.map(h=>h.id),overflow:a.overflow.map(h=>h.id)},u=d.visible.join("\0")!==this._partition.visible.join("\0")||d.overflow.join("\0")!==this._partition.overflow.join("\0");this._partition=d,this._syncRoving(),u&&t.isConnected&&this.emit("overflowchange",{...d})}_renderTile(t,e){let i=Ii(t,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:e==="bar"?"module":"catalogue"})??l("span",{class:"zx-module-bar__initial"},t.label.trim().charAt(0).toUpperCase()),{tone:n,color:r}=dl(t),o=l("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:this._appearance,...n?{tone:n}:{},...r?{color:""}:{}}});return this._appearance==="solid"?o.append(vi({icon:i,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(i)),o}_applyTileBadge(t,e){t.querySelector(":scope > .zx-module-bar__badge")?.remove();let i=e.badge==null||e.badge===""?null:String(e.badge);t.setAttribute("aria-label",i===null?e.label:this._message("moduleBar.itemBadge","%1 (%2)",e.label,i)),i!==null&&t.append(l("span",{class:"zx-module-bar__badge",ariaHidden:"true",dataset:{zxBadge:i.length>2&&this.el.dataset.labels!=="beside"?"dot":"count"}},i))}_buildCatalogue(){let t=this._message("moduleBar.more","All modules"),e=this.el.dataset.labels!=="hidden",i=l("button",{class:"zx-module-bar__item",type:"button",ariaLabel:t,tabIndex:-1,dataset:{moduleBarMore:""}},l("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:"plain"}},g("grid")),e?l("span",{class:"zx-module-bar__label"},t):null);this.refs.list.append(l("li",{class:"zx-module-bar__row",dataset:{moduleBarMore:""}},i)),e||(this._catalogueTooltip=new mt(i,{content:t,placement:{left:"right",right:"left",top:"bottom",bottom:"top"}[this.el.dataset.side]??"right",delay:450}));let n=this._items.length>mv?l("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 f of this._items){let p=typeof f.group=="string"?f.group:this._sections.get(String(f.id))??"";r.has(p)||r.set(p,[]),r.get(p).push(f)}let o=[...r].map(([f,p])=>{let _=f?x("zx-module-bar-group"):null;return l("div",{class:"zx-module-bar__group"},f?l("div",{class:"zx-module-bar__group-label",id:_},f):null,l("ul",{class:"zx-module-bar__grid",ariaLabelledby:_},p.map(m=>l("li",{dataset:{moduleId:String(m.id)}},this._catalogueControl(m)))))}),a=l("p",{class:"zx-module-bar__empty",hidden:!0},this._message("moduleBar.empty","No modules")),c=l("div",{class:"zx-module-bar__catalogue"},n,...o,a),d={left:"right-start",right:"left-start",top:"bottom-end",bottom:"top-end"}[this.el.dataset.side]??"right-start",u=new pt(i,{content:c,placement:d,offset:6}),h=u.getPanel();h.classList.add("zx-module-bar__popover"),h.setAttribute("role","region"),h.setAttribute("aria-label",t),this._catalogue=u,u.on("open",()=>{this.closeAllFlyouts(),this._catalogueTooltip?.hide(),this.emit("allmodules",{open:!0})}),u.on("close",()=>{n instanceof HTMLInputElement&&n.value&&(n.value="",this._filterCatalogue("")),this._silenceCatalogue||this.emit("allmodules",{open:!1})}),this._interaction.listen(i,"click",()=>{u.isOpen()&&this._focusCatalogue()}),n&&this._interaction.listen(n,"input",()=>this._filterCatalogue(n.value)),this._interaction.listen(h,"click",f=>this._onCatalogueClick(f)),this._interaction.listen(h,"focusout",f=>{let p=f.relatedTarget;p&&!h.contains(p)&&p!==i&&u.close()}),this._interaction.listen(h,"keydown",f=>this._onCatalogueKeydown(f)),this._interaction.listen(h,"focusin",f=>{let p=f.target.closest?.(".zx-module-bar__entry");p instanceof HTMLElement&&this._syncCatalogueStop(p)}),this._syncCatalogueStop()}_syncCatalogueStop(t){let e=this._catalogueEntries(),i=e.filter(r=>!r.closest("li")?.hidden),n=(t&&i.includes(t)?t:null)??i.find(r=>r.tabIndex===0&&r.dataset.catalogueStop==="true")??i.find(r=>r.hasAttribute("aria-current"))??i[0];for(let r of e)r.tabIndex=r===n?0:-1,r===n?r.dataset.catalogueStop="true":delete r.dataset.catalogueStop}_catalogueControl(t){let e=!!t.children?.length,i=t.href&&!e?"a":"button",n=l(i,{class:"zx-module-bar__entry",type:i==="button"?"button":null,href:i==="a"?t.href:null,target:i==="a"?t.target??null:null,rel:i==="a"&&t.target?"noopener":null,title:typeof t.description=="string"?t.description:null,ariaDisabled:t.disabled?"true":null,dataset:{moduleId:String(t.id)}},this._renderTile(t,"catalogue"),l("span",{class:"zx-module-bar__entry-label"},t.label));return ll(n,t,"zx-module-bar__entry"),n}_onCatalogueClick(t){let e=t.target.closest?.(".zx-module-bar__entry");if(!(e instanceof HTMLElement))return;let i=Ut(this._items,e.dataset.moduleId);if(!i||i.disabled){t.preventDefault();return}if(i.children?.length&&this._menus==="flyout"){t.preventDefault(),this._catalogue?.close(),this._promoted=i.id,this._layout();let o=t instanceof MouseEvent&&t.detail===0;this.openFlyout(i.id,{focus:o}),o||this._tiles().find(a=>a.getAttribute("data-app-nav-value-id")===String(i.id))?.focus();return}this._select(i,t);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(i.id)&&!a.closest("li")?.hidden)??this.refs.list.querySelector("[data-module-bar-more] .zx-module-bar__item"))?.focus()}_onCatalogueKeydown(t){let e=this._catalogue?.getPanel();if(!e||t.altKey||t.ctrlKey||t.metaKey)return;let i=e.querySelector(".zx-module-bar__filter"),n=this._catalogueEntries().filter(c=>!c.closest("li")?.hidden),r=t.target.closest?.(".zx-module-bar__entry");if(t.target===i){t.key==="ArrowDown"&&n[0]&&(t.preventDefault(),n[0].focus());return}if(!(r instanceof HTMLElement))return;let o=n.indexOf(r),a=null;if(t.key==="ArrowRight")a=n[Math.min(n.length-1,o+1)];else if(t.key==="ArrowLeft")a=n[Math.max(0,o-1)];else if(t.key==="Home")a=n[0];else if(t.key==="End")a=n.at(-1);else if(t.key==="ArrowDown"||t.key==="ArrowUp")a=yv(n,r,t.key==="ArrowDown"?1:-1),!a&&t.key==="ArrowUp"&&i instanceof HTMLElement&&(a=i);else if(i instanceof HTMLElement&&t.key.length===1&&t.key!==" "){i.focus();return}else return;t.preventDefault(),a?.focus()}_filterCatalogue(t){let e=this._catalogue?.getPanel();if(!e)return;let i=t.trim().toLocaleLowerCase(),n=0;for(let o of e.querySelectorAll(".zx-module-bar__group")){let a=0;for(let c of o.querySelectorAll("li[data-module-id]")){let d=Ut(this._items,c.dataset.moduleId),u=`${d?.label??""} ${d?.description??""} ${d?.group??""}`.toLocaleLowerCase(),h=!i||u.includes(i);c.hidden=!h,h&&(a+=1)}o.hidden=a===0,n+=a}let r=e.querySelector(".zx-module-bar__empty");r instanceof HTMLElement&&(r.hidden=n>0),this._syncCatalogueStop()}_focusCatalogue(){let t=this._catalogue?.getPanel();if(!t||!this._catalogue?.isOpen())return;let i=t.querySelector(".zx-module-bar__filter")??this._catalogueEntries().find(n=>n.hasAttribute("aria-current"))??this._catalogueEntries()[0];i instanceof HTMLElement&&i.focus()}_onRailKeydown(t){let e=t.target.closest?.(".zx-module-bar__item");if(!(e instanceof HTMLElement)||!this.refs.list.contains(e)||t.altKey||t.ctrlKey||t.metaKey)return;let i=this._rovingControls(),n=i.indexOf(e),r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",c={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],d=e.getAttribute("data-app-nav-id");if(t.key===c&&d!==null&&this._flyouts.has(d)){t.preventDefault(),this.openFlyout(d,{focus:!0});return}let u=null;if(t.key==="Home")u=i[0];else if(t.key==="End")u=i.at(-1);else if(t.key===o)u=i[(n-1+i.length)%i.length];else if(t.key===a)u=i[(n+1)%i.length];else if(t.key.length===1&&t.key!==" ")u=this._typeaheadTarget(t.key,i,n);else return;u&&(t.preventDefault(),this._setRovingStop(u),u.focus())}_typeaheadTarget(t,e,i){let n=Date.now(),r=n-this._typeahead.at>gv?t:this._typeahead.text+t;this._typeahead={text:r,at:n};let o=r.toLocaleLowerCase(),a=[...o].every(h=>h===o[0]),c=h=>(Ut(this._items,h.getAttribute("data-app-nav-value-id"))?.label??h.getAttribute("aria-label")??"").toLocaleLowerCase(),d=[...e.slice(i+1),...e.slice(0,i+1)],u=d.find(h=>c(h).startsWith(o))??(a?d.find(h=>c(h).startsWith(o[0])):null);return u||r.length===1?u??null:(this._typeahead={text:t,at:n},d.find(h=>c(h).startsWith(t.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 t=this._rovingControls();if(this._rovingId!==null){let e=t.find(i=>hr(i)===this._rovingId);if(e)return e}return t.find(e=>e.hasAttribute("aria-current"))??t.find(e=>e.getAttribute("aria-expanded")==="true"&&e.hasAttribute("data-app-nav-value-id"))??t[0]??null}_setRovingStop(t){this._rovingId=hr(t),this._syncRoving()}_syncRoving(){let t=this._rovingStop();for(let e of this.refs.list.querySelectorAll(":scope > li > .zx-module-bar__item"))e.tabIndex=e===t?0:-1}_syncExpanded(){if(this._menus!=="none")return;let t=this._expandedId==null?null:String(this._expandedId);for(let e of this._tiles()){let i=e.getAttribute("data-app-nav-value-id"),n=Ut(this._items,i);(n?.children?.length||n?.header||n?.content||i===t)&&(e.setAttribute("aria-expanded",String(i===t)),this.options.controls&&e.setAttribute("aria-controls",String(this.options.controls)))}}_catalogueEntries(){let t=this._catalogue?.getPanel();return t?[...t.querySelectorAll(".zx-module-bar__entry")]:[]}_catalogueEntry(t){return this._catalogueEntries().find(e=>e.dataset.moduleId===t)??null}_labelText(){let t=this.options.label;return t==null||t===""?this._message("moduleBar.label","Modules"):String(t)}};function cl(s,t=1/0,e=[],i=!1){let n=Array.isArray(s)?s.filter(_=>_&&_.id!=null):[],r=Gh(n),a=n.some(Yh)?r.filter(Yh):r,c=Number.isFinite(t)?Math.max(1,Math.floor(t)):1/0,u=i||a.length<n.length||a.length>c?Math.max(0,c-1):c,h=a.slice(0,u),f=new Set([e].flat().filter(_=>_!=null).map(String));for(let _ of f){let m=n.find(b=>String(b.id)===_);if(!(!m||h.includes(m))){if(h.length>=u){let b=h.findLastIndex(w=>!f.has(String(w.id)));b>=0&&h.splice(b,1)}h.push(m)}}h.sort((_,m)=>r.indexOf(_)-r.indexOf(m));let p=n.filter(_=>!h.includes(_));return{visible:h,overflow:p,more:p.length>0}}function dl(s){let t=ee(s?.color)?String(s.color).trim():null;return t?{tone:null,color:t}:{tone:_s.includes(s?.tone)?s.tone:null,color:null}}function xs(s,t=new Map,e=null){return s.flatMap(i=>i.section?xs(i.children??[],t,i.label):(e!==null&&t.set(String(i.id),e),[i]))}function Uh(s){let t=null,e=!1,i=!0,n=()=>{t&&(t.hidden=!e)};for(let r of[...s.children]){if(r.classList.contains("zx-module-bar__heading")){n(),t=r,e=!1,i?r.dataset.leading="":delete r.dataset.leading;continue}r.hasAttribute("data-module-id")&&!r.hidden&&(e=!0,i=!1)}n()}function al(s,t){return t!=="vertical"?"hidden":s==="below"||s==="beside"?s:"hidden"}function Yh(s){return s.pinned===!0||typeof s.pinned=="number"&&Number.isFinite(s.pinned)}function Gh(s){let t=e=>typeof e.pinned=="number"&&Number.isFinite(e.pinned)?e.pinned:e.pinned===!0?Number.MAX_SAFE_INTEGER-1:Number.MAX_SAFE_INTEGER;return s.map((e,i)=>({item:e,index:i})).sort((e,i)=>t(e.item)-t(i.item)||e.index-i.index).map(({item:e})=>e)}function bv(s,t,e){if(!(t?s.scrollWidth>s.clientWidth+1:s.scrollHeight>s.clientHeight+1))return 1/0;let n=[...s.querySelectorAll(":scope > li:not([hidden]):not(.zx-module-bar__heading)")];if(!n.length)return 1/0;let r=[...s.querySelectorAll(":scope > li.zx-module-bar__heading:not([hidden])")],o=getComputedStyle(s),a=Number.parseFloat(t?o.columnGap:o.rowGap)||0,c=t?(Number.parseFloat(o.paddingInlineStart)||0)+(Number.parseFloat(o.paddingInlineEnd)||0):(Number.parseFloat(o.paddingBlockStart)||0)+(Number.parseFloat(o.paddingBlockEnd)||0),d=Math.max(...n.map(f=>t?f.offsetWidth:f.offsetHeight)),u=r.reduce((f,p)=>f+a+(t?p.offsetWidth:p.offsetHeight)+(Number.parseFloat(t?getComputedStyle(p).marginInlineStart:getComputedStyle(p).marginBlockStart)||0)+(Number.parseFloat(t?getComputedStyle(p).marginInlineEnd:getComputedStyle(p).marginBlockEnd)||0),0),h=(t?s.clientWidth:s.clientHeight)-c-u;return d<=0||h<=0?e:Math.max(1,Math.floor((h+a)/(d+a)))}function yv(s,t,e){let i=t.getBoundingClientRect(),n=i.left+i.width/2,r=null,o=1/0,a=1/0;for(let c of s){if(c===t)continue;let d=c.getBoundingClientRect(),u=e>0?d.top-i.bottom+1:i.top-d.bottom+1;if(u<0)continue;let h=Math.abs(d.left+d.width/2-n);(u<o-1||Math.abs(u-o)<=1&&h<a)&&(r=c,o=u,a=h)}return r}function hr(s){return s.getAttribute("data-app-nav-value-id")??"\0more"}function Wh(s,t){return t===null?null:String(s.id)===t?"page":ul(s.children??[],t)?"true":null}function ll(s,t,e){let i=s.querySelector(`:scope > .${e}-badge`),n=t.badge==null||t.badge===""?null:String(t.badge);if(n===null){i?.remove();return}i?i.textContent=n:s.querySelector(`:scope > .${e}-label`)?.after(l("span",{class:`${e}-badge`},n))}function fr(s,t){if(t==null||!Array.isArray(s))return null;let e=String(t);return s.find(i=>String(i.id)===e||ul(i.children??[],e))??null}function Ut(s,t){if(t==null)return null;for(let e of s??[]){if(String(e.id)===String(t))return e;let i=Ut(e.children??[],t);if(i)return i}return null}function ul(s,t){return s.some(e=>String(e.id)===t||ul(e.children??[],t))}var pr=Object.freeze(["expanded","compact","collapsed"]),_r=class extends y{static cssName="app-sidebar";static defaults={items:[],active:null,expanded:[],collapsed:!1,collapsible:!0,orientation:"vertical",side:"left",layout:"tree",module:null,moduleBar:{},presentation:null,presentations:["expanded","compact","collapsed"],presentationSwitch:!0,label:"Applications",header:null,footer:null,railHeader:null,railFooter:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(t=null,e={}){super(t,e),this._rail=null,this._railExpandButton=null,this._renderMode()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._items=Pt(this.options.items),this._active=this.options.active,this._expanded=new Set(Array.isArray(this.options.expanded)?this.options.expanded.map(String):[]),this._collapsed=!!this.options.collapsed,this._orientation=this.options.orientation==="horizontal"?"horizontal":"vertical",this._side=Xh(this._orientation,this.options.side),this._modules=this.options.layout==="modules",this._moduleLabels=this.options.moduleBar?.labels??"auto",this._compact=!1,this._presentationGroup=null,this._stripTooltips=[],this._modules&&pr.includes(this.options.presentation)&&(this._collapsed=this.options.presentation==="collapsed",this._compact=this.options.presentation==="compact"),this._shownId=this._modules?this._resolveShown(this.options.module):null,this._modeAbort=null,t.replaceChildren(),t}setItems(t){return this._items=Pt(t),this._reconcileExpanded(),this._modules?(this._shownId=this._resolveShown(this._shownId),this._rail?.setItems(this._items),this._rail instanceof ct&&!this.isCollapsed()&&this._rail.setExpanded(this._shownId),this.refs.list&&this._renderPanelContent()):this._rail?(this._rail.setItems(this._items),this._decorateRail()):this._renderTree(),this}getItems(){return Zh(this._items)}setActive(t){if(this._active=t,this._rail&&this._rail.setActive(t),this._modules){let e=fr(this._moduleList(),t);if(e&&Ei(e)&&String(e.id)!==String(this._shownId))return this._shownId=e.id,this._rail instanceof ct&&!this.isCollapsed()&&this._rail.setExpanded(e.id),this.refs.list&&this._renderPanelContent(),this}return this.refs.list&&this._syncActive(),this}setBadge(t,e){let i=Ie(this._items,t);return i?(e==null||e===""?delete i.badge:i.badge=e,this._rail instanceof ct?this._rail.setBadge(t,e):this._rail&&(this._rail.setItems(this._items),this._decorateRail()),this.refs.list&&this._renderTree(),this):this}setModule(t,{silent:e=!1}={}){return this._showModule(t,{silent:e}),this}getModule(){return this._shownId}setModuleLabels(t){return this._moduleLabels=t,this._rail instanceof ct&&this._rail.setLabels(this._stripLabels()),this._syncPresentationSwitch(),this}getPresentation(){return this.isCollapsed()?"collapsed":this._modules&&this._stripLabels()==="hidden"?"compact":"expanded"}setPresentation(t,{silent:e=!1}={}){return pr.includes(t)?this._present(t==="collapsed",t==="collapsed"?this._compact:this._modules&&t==="compact",{silent:e}):this}togglePresentation(){return this.setPresentation(this._nextPresentation())}setExpanded(t,{silent:e=!1}={}){return this._expanded=new Set(Array.isArray(t)?t.map(String):[]),this._reconcileExpanded(),this.refs.list&&this._renderTree(),e||this.emit("branchchange",{item:null,id:null,expanded:null,ids:this.getExpanded()}),this}getExpanded(){let t=[];return hl(this._items,e=>{this._expanded.has(String(e.id))&&t.push(e.id)}),t}toggleBranch(t,{silent:e=!1}={}){let i=Ie(this._items,t);if(!i?.children?.length||i.section)return this;let n=String(t),r=!this._expanded.has(n);return r?this._expanded.add(n):this._expanded.delete(n),this.refs.list&&(this._renderTree(),r&&this._markBranchMotion(n)),e||this.emit("branchchange",{item:i,id:i.id,expanded:r,ids:this.getExpanded()}),this}expand(t={}){return this.setCollapsed(!1,t)}collapse(t={}){return this.setCollapsed(!0,t)}setCollapsed(t,{silent:e=!1}={}){return this._present(!!t,this._compact,{silent:e})}_present(t,e,{silent:i=!1}){let n={collapsed:this.isCollapsed(),presentation:this.getPresentation()},r=document.activeElement,o=!!(r&&(this.el.contains(r)||this._rail?._containsNode(r)));this._collapsed=t,this._compact=!!e;let a=this.isCollapsed();if(n.collapsed!==a){if(this._renderMode(),o){let d=a?this._railExpandButton:this.refs.collapse;d?.isConnected?d.focus():this.focus()}}else this._rail instanceof ct&&(this._rail.setLabels(this._stripLabels()),this._syncPresentationSwitch());let c=this.getPresentation();return i||(n.collapsed!==a&&this.emit("collapsechange",{collapsed:a}),n.presentation!==c&&this.emit("presentationchange",{presentation:c,previous:n.presentation})),this}isCollapsed(){return this._orientation==="horizontal"||this._collapsed}setLayout(t={},{silent:e=!1}={}){let i=t.orientation==="horizontal"?"horizontal":t.orientation==="vertical"?"vertical":this._orientation,n=Xh(i,t.side??this._side);if(i===this._orientation&&n===this._side)return this;let r=this.isCollapsed(),o=document.activeElement,a=!!(o&&(this.el.contains(o)||this._rail?._containsNode(o))),c=a&&o instanceof Element?o.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id")??null:null;this._orientation=i,this._side=n,this._renderMode();let d=this.isCollapsed();if(a){let u=c===null?null:[...this.el.querySelectorAll("[data-app-nav-id]")].find(h=>h.getAttribute("data-app-nav-id")===c)??null;u instanceof HTMLElement?u.focus():d?this.focus():this.refs.collapse instanceof HTMLElement&&!this.refs.collapse.hidden?this.refs.collapse.focus():Mi(this.refs.list)[0]?.focus()}return r!==d&&!e&&this.emit("collapsechange",{collapsed:d}),this}openFlyout(t,e={}){return this._rail?.openFlyout(t,e),this}closeFlyout(t){return this._rail?.closeFlyout(t),this}closeAllFlyouts(){return this._rail?.closeAllFlyouts(),this}isFlyoutOpen(t){return this._rail?.isFlyoutOpen(t)??!1}focus(){return this._rail?this._rail.focus():Mi(this.refs.list)[0]?.focus(),this}destroy(){let t=this._original;this._modeAbort?.abort(),this._modeAbort=null;for(let e of this._stripTooltips.splice(0))e.destroy();if(this._rail?.destroy(),this._rail=null,super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_renderMode(){this._modeAbort?.abort(),this._modeAbort=new AbortController;for(let t of this._stripTooltips.splice(0))t.destroy();this._presentationGroup=null,this._rail?.destroy(),this._rail=null,this._railExpandButton=null;for(let t of["expanded","list","collapse","rail","panelTitle","panelLead","panelContent","panelNav"])delete this.refs[t];this.el.replaceChildren(),this.el.dataset.orientation=this._orientation,this.el.dataset.side=this._side,this.el.dataset.collapsed=String(this.isCollapsed()),this.el.dataset.layout=this._modules?"modules":"tree",this._modules?this._renderModules():this.isCollapsed()?this._renderRail():this._renderExpanded()}_renderExpanded(){let t=l("div",{class:"zx-app-sidebar__header-content"});fe(t,this.options.header);let e=this._collapseButton(),i=l("footer",{class:"zx-app-sidebar__footer"});fe(i,this.options.footer),i.hidden=!i.hasChildNodes();let n=l("ul",{class:"zx-app-sidebar__list"}),r=l("div",{class:"zx-app-sidebar__expanded"},l("header",{class:"zx-app-sidebar__header"},t,e),l("nav",{class:"zx-app-sidebar__nav",ariaLabel:this.options.label},n),i);this.refs.expanded=r,this.refs.list=n,this.refs.collapse=e,this.el.append(r),this._listenTree(n),this._renderTree()}_collapseButton(){let t=l("button",{class:"zx-app-sidebar__collapse zx-icon-btn",type:"button",ariaLabel:this._message("appSidebar.minimize","Minimize application sidebar")},g(this._side==="right"?"chevron-right":"chevron-left"));return t.hidden=!this.options.collapsible,this._listenMode(t,"click",()=>this.collapse()),t}_expandButton(){let t=l("button",{class:"zx-app-sidebar__rail-toggle zx-icon-btn",type:"button",ariaLabel:this._message("appSidebar.expand","Expand application sidebar")},g(this._side==="right"?"chevron-left":"chevron-right"));return this._railExpandButton=t,this._listenMode(t,"click",()=>this.expand()),t}_listenTree(t){this._listenMode(t,"click",e=>this._onTreeClick(e)),this._listenMode(t,"keydown",e=>this._onTreeKeydown(e))}_renderRail(){let t=l("nav",{class:"zx-app-sidebar__rail"});this.el.append(t),this.refs.rail=t;let e=this._orientation==="vertical"&&!!this.options.collapsible,i=l("div",{class:"zx-app-sidebar__rail-header"});e&&i.append(this._expandButton()),fe(i,this.options.railHeader),this._rail=new Ti(t,{items:this._items,active:this._active,orientation:this._orientation,side:this._side,label:this.options.label,header:i.hasChildNodes()?i:null,footer:this.options.railFooter,openDelay:this.options.openDelay,closeDelay:this.options.closeDelay,renderIcon:this.options.renderIcon,onselect:n=>{this.emit("select",n.detail).defaultPrevented&&n.preventDefault()},onflyoutchange:n=>this.emit("flyoutchange",n.detail)}),this._listenMode(t,"zx-select",n=>n.stopPropagation()),this._listenMode(t,"zx-flyoutchange",n=>n.stopPropagation()),this._decorateRail()}_renderModules(){let t=!this.isCollapsed(),e=l("div",{class:"zx-app-sidebar__rail-header"});fe(e,this.options.railHeader);let i=l("div",{class:"zx-app-sidebar__strip-foot"});this._orientation==="vertical"&&this.options.collapsible&&this.options.presentationSwitch!==!1&&i.append(this._presentationSwitch(t)),fe(i,this.options.railFooter);let n=l("nav",{class:"zx-app-sidebar__strip"}),r=t?x("zx-app-sidebar-panel"):null,o=t?l("div",{class:"zx-app-sidebar__modules"},n):n;this.el.append(o),this.refs.rail=n;let a=this.options.moduleBar&&typeof this.options.moduleBar=="object"?this.options.moduleBar:{},c={items:this._items,active:this._active,orientation:this._orientation,side:this._side,menus:t?"none":"flyout",expanded:t?this._shownId:null,controls:r,header:e.hasChildNodes()?e:null,footer:i.hasChildNodes()?i:null,openDelay:this.options.openDelay,closeDelay:this.options.closeDelay,renderIcon:this.options.renderIcon,onselect:d=>this._onModuleSelect(d,t),onflyoutchange:d=>this.emit("flyoutchange",d.detail)};for(let d of["appearance","allModules","label"])a[d]!=null&&(c[d]=a[d]);c.labels=this._stripLabels(),this._rail=new ct(n,c);for(let d of["zx-select","zx-flyoutchange","zx-overflowchange","zx-allmodules"])this._listenMode(n,d,u=>u.stopPropagation());t&&(this._listenMode(n,"keydown",d=>this._onStripKeydown(d)),o.append(this._renderPanel(r)))}_presentationSwitch(t){let e=this._presentationLabels(),i=l("div",{class:"zx-app-sidebar__presentation",role:"radiogroup",ariaLabel:this._message("appSidebar.presentation","Navigation layout")});for(let r of this._presentationCycle()){let o=l("button",{class:"zx-app-sidebar__presentation-option",type:"button",role:"radio",ariaLabel:e[r],dataset:{presentation:r}},mr(r));i.append(o),this._stripTooltips.push(new mt(o,{content:e[r],placement:this._side==="right"?"left":"right",delay:450}))}this._listenMode(i,"click",r=>{let o=r.target.closest?.(".zx-app-sidebar__presentation-option");o instanceof HTMLElement&&this.setPresentation(o.dataset.presentation)}),this._listenMode(i,"keydown",r=>this._onPresentationKeydown(r)),this._presentationGroup=i,this._syncPresentationSwitch();let n=i.querySelector('[aria-checked="true"]');return t?this.refs.collapse=n??i:this._railExpandButton=n??i,i}presentationChoice({label:t}={}){let e=this._presentationLabels();return{type:"choice",label:t??this._message("appSidebar.presentation","Navigation layout"),value:this.getPresentation(),options:this._presentationCycle().map(i=>({value:i,label:e[i],glyph:()=>mr(i)})),onselect:i=>this.setPresentation(i)}}_presentationLabels(){return{expanded:this._message("appSidebar.presentationExpanded","Both menus expanded"),compact:this._message("appSidebar.presentationCompact","Module menu collapsed"),collapsed:this._message("appSidebar.presentationCollapsed","Both menus collapsed")}}_onPresentationKeydown(t){let e=[...this._presentationGroup?.querySelectorAll(".zx-app-sidebar__presentation-option")??[]],i=e.indexOf(t.target);if(i<0||t.altKey||t.ctrlKey||t.metaKey)return;let n;if(t.key==="ArrowDown"||t.key==="ArrowRight")n=e[(i+1)%e.length];else if(t.key==="ArrowUp"||t.key==="ArrowLeft")n=e[(i-1+e.length)%e.length];else if(t.key==="Home")n=e[0];else if(t.key==="End")n=e.at(-1);else return;t.preventDefault();let r=n.dataset.presentation;n.focus(),this.setPresentation(r);let o=this._presentationGroup?.querySelector(`.zx-app-sidebar__presentation-option[data-presentation="${r}"]`);o instanceof HTMLElement&&o!==document.activeElement&&o.focus()}_syncPresentationSwitch(){let t=this._presentationGroup;if(!t)return;let e=this.getPresentation();for(let i of[...t.querySelectorAll(".zx-app-sidebar__presentation-option")]){let n=i.dataset.presentation===e;i.setAttribute("aria-checked",String(n)),i.tabIndex=n?0:-1}if(!t.querySelector('[aria-checked="true"]')){let i=t.querySelector(".zx-app-sidebar__presentation-option");i&&(i.tabIndex=0)}}_presentationCycle(){let t=Array.isArray(this.options.presentations)?this.options.presentations:pr,e=this._moduleLabels==="hidden"?"expanded":this._moduleLabels==="below"?"compact":null,i=[...new Set(t)].filter(n=>pr.includes(n)&&(n!=="compact"||this._modules)&&n!==e);return i.length>=2?i:["expanded","collapsed"]}_nextPresentation(){let t=this._presentationCycle(),e=t.indexOf(this.getPresentation());return t[(e+1)%t.length]}_stripLabels(){let t=this._moduleLabels;return t==="below"?"below":this.isCollapsed()||this._compact||t==="hidden"?"hidden":"beside"}_moduleList(){return xs(this._items)}_renderPanel(t){let e=x("zx-app-sidebar-module"),i=l("div",{class:"zx-app-sidebar__panel-title",id:e}),n=l("div",{class:"zx-app-sidebar__panel-lead"}),r=l("ul",{class:"zx-app-sidebar__list"}),o=l("nav",{class:"zx-app-sidebar__nav",ariaLabelledby:e},r),a=l("div",{class:"zx-app-sidebar__panel-content"}),c=l("footer",{class:"zx-app-sidebar__footer"});fe(c,this.options.footer),c.hidden=!c.hasChildNodes();let d=l("div",{class:"zx-app-sidebar__panel",id:t},l("header",{class:"zx-app-sidebar__header"},l("div",{class:"zx-app-sidebar__header-content"},i)),l("div",{class:"zx-app-sidebar__panel-body"},n,o,a),c);return Object.assign(this.refs,{expanded:d,list:r,panelTitle:i,panelLead:n,panelContent:a,panelNav:o}),this._listenTree(r),this._renderPanelContent(),d}_renderPanelContent(){let t=this._shownModule(),{panelTitle:e,panelLead:i,panelContent:n,panelNav:r}=this.refs;e&&(e.textContent=t?.label??"",Qh(i,[this.options.header,t?.header]),Qh(n,[t?.content]),r.hidden=!t?.children?.length,this._renderTree())}_showModule(t,{silent:e=!1}={}){if(!this._modules)return!1;let i=this._moduleList().find(r=>String(r.id)===String(t));if(!i||!Ei(i)||i.disabled)return!1;if(String(i.id)===String(this._shownId))return!0;let n=this._shownId;if(!e&&this.emit("modulechange",{item:i,id:i.id,previous:n}).defaultPrevented)return!1;if(this._shownId=i.id,this._rail instanceof ct&&!this.isCollapsed()&&this._rail.setExpanded(i.id),this.refs.list){this._renderPanelContent();let r=this.refs.expanded?.querySelector(".zx-app-sidebar__panel-body");r instanceof HTMLElement&&(delete r.dataset.moduleMotion,r.offsetWidth,r.dataset.moduleMotion="enter")}return!0}_onModuleSelect(t,e){let i=this._moduleList().find(r=>String(r.id)===String(t.detail.id));if(i&&Ei(i)){t.preventDefault(),this._showModule(i.id)&&!e&&this._orientation==="vertical"&&(this.expand(),Mi(this.refs.list)[0]?.focus());return}this.emit("select",t.detail).defaultPrevented&&t.preventDefault()}_onStripKeydown(t){let e=this._side==="right"?"ArrowLeft":"ArrowRight";if(t.key!==e||t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey)return;let i=t.target.closest?.(".zx-module-bar__item[data-app-nav-value-id]");if(!i)return;let n=this._moduleList().find(o=>String(o.id)===i.getAttribute("data-app-nav-value-id"));if(!n||!Ei(n)||!this._showModule(n.id))return;t.preventDefault();let r=Mi(this.refs.list)[0]??this.refs.expanded?.querySelector('.zx-app-sidebar__panel-body :is(a[href], button, input, select, textarea, [tabindex="0"])');r instanceof HTMLElement&&r.focus()}_shownModule(){return this._moduleList().find(t=>String(t.id)===String(this._shownId))??null}_resolveShown(t){let e=i=>{if(i==null)return null;let n=this._moduleList().find(r=>String(r.id)===String(i));return n&&Ei(n)?n:null};return e(t)?.id??e(fr(this._moduleList(),this._active)?.id)?.id??this._moduleList().find(Ei)?.id??null}_treeItems(){return this._modules?this._shownModule()?.children??[]:this._items}_decorateRail(){let t=this.refs.rail;if(t)for(let e of t.querySelectorAll(".zx-app-rail__item[data-app-nav-value-id]")){let i=e.querySelector(":scope > .zx-app-rail__item-badge");if(!i)continue;let n=Ie(this._items,e.getAttribute("data-app-nav-value-id"));if(!n||n.badge==null)continue;let r=String(n.badge);i.dataset.zxBadge=r.length>2?"dot":"count",e.setAttribute("aria-label",this._message("appSidebar.itemBadge","%1 (%2)",n.label,r))}}_listenMode(t,e,i){t.addEventListener(e,i,{signal:this._modeAbort.signal})}_renderTree(){if(!this.refs.list)return;let t=this.refs.list.contains(document.activeElement)?document.activeElement.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id"):null;if(this.refs.list.replaceChildren(...this._treeItems().map(e=>this._treeRow(e,1))),this._syncActive(),t!==null){let e=[...this.refs.list.querySelectorAll("[data-app-nav-id]")].find(i=>i.getAttribute("data-app-nav-id")===t)??null;vv(e)?.focus()}}_treeRow(t,e){if(t.section)return this._sectionRow(t,e);let i=t.children??[],n=i.length>0,r=String(t.id),o=n&&this._expanded.has(r),a=n?x("zx-app-sidebar-branch"):null,c=Ii(t,this.options.renderIcon,{orientation:this._orientation,collapsed:!1,side:this._side,level:e,location:e===1?"root":"inline"}),d=wv(t,n,o,a,c),u=l("li",{class:"zx-app-sidebar__row",dataset:{level:e}},d);return n&&u.append(l("ul",{class:"zx-app-sidebar__sublist",id:a,hidden:!o},i.map(h=>this._treeRow(h,e+1)))),u}_sectionRow(t,e){let i=x("zx-app-sidebar-section"),n=l("div",{class:"zx-app-sidebar__section-header"},l("span",{class:"zx-app-sidebar__section-label",id:i},t.label));if(t.actions){let r=l("span",{class:"zx-app-sidebar__section-actions"});fe(r,t.actions),n.append(r)}return l("li",{class:"zx-app-sidebar__section"},n,l("ul",{class:"zx-app-sidebar__section-list",ariaLabelledby:i},(t.children??[]).map(r=>this._treeRow(r,e))))}_onTreeClick(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!e||!this.refs.list.contains(e))return;let i=Ie(this._items,e.getAttribute("data-app-nav-id"));if(!i||i.disabled){t.preventDefault();return}i.children?.length?this.toggleBranch(i.id):this._select(i,t)}_onTreeKeydown(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!(e instanceof HTMLElement))return;let i=Ie(this._items,e.getAttribute("data-app-nav-id")),n=Mi(this.refs.list),r=n.indexOf(e);if(t.key==="ArrowRight"&&i?.children?.length){t.preventDefault(),this._expanded.has(String(i.id))?Mi(e.parentElement?.querySelector(".zx-app-sidebar__sublist"))[0]?.focus():this.toggleBranch(i.id);return}if(t.key==="ArrowLeft"){if(i?.children?.length&&this._expanded.has(String(i.id))){t.preventDefault(),this.toggleBranch(i.id);return}let c=e.closest(".zx-app-sidebar__sublist")?.parentElement?.querySelector(":scope > [data-app-nav-id]");if(c instanceof HTMLElement){t.preventDefault(),c.focus();return}if(this._modules&&this._side==="left"&&this._rail instanceof ct){let d=this._rail._tiles().find(u=>u.getAttribute("data-app-nav-value-id")===String(this._shownId));d&&(t.preventDefault(),d.focus())}return}let o;if(t.key==="Home")o=0;else if(t.key==="End")o=n.length-1;else if(t.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(t.key==="ArrowUp")o=Math.max(0,r-1);else return;t.preventDefault(),n[o]?.focus()}_select(t,e){if(t.disabled){e.preventDefault();return}this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e}).defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.())}_syncActive(){if(!this.refs.list)return;let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let i=Ie(this._items,e.getAttribute("data-app-nav-id")),n=t!==null&&e.getAttribute("data-app-nav-id")===t,r=t!==null&&i?Jh(i.children??[],t):!1;n?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),r?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}}_markBranchMotion(t){if(!this.refs.list)return;let i=([...this.refs.list.querySelectorAll("[data-app-nav-id]")].find(n=>n.getAttribute("data-app-nav-id")===t)??null)?.parentElement?.querySelector(":scope > .zx-app-sidebar__sublist");i instanceof HTMLElement&&(i.dataset.branchMotion="expand")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}_reconcileExpanded(){let t=new Set;hl(this._items,e=>{e.children?.length&&!e.section&&t.add(String(e.id))});for(let e of this._expanded)t.has(e)||this._expanded.delete(e)}};function mr(s){return l("span",{class:"zx-app-sidebar__presentation-glyph",ariaHidden:"true",dataset:{presentation:s}},l("span",{class:"zx-app-sidebar__presentation-strip"}),l("span",{class:"zx-app-sidebar__presentation-panel"}))}function Ei(s){return!!(s.children?.length||s.header||s.content)}function wv(s,t,e,i,n){let r=s.href&&!t?"a":"button";return l(r,{class:"zx-app-sidebar__item",type:r==="button"?"button":null,href:r==="a"?s.href:null,target:r==="a"?s.target??null:null,ariaDisabled:s.disabled?"true":null,ariaExpanded:t?String(e):null,ariaControls:i,dataset:{appNavId:String(s.id)}},n?l("span",{class:"zx-app-sidebar__item-icon",ariaHidden:"true"},n):null,l("span",{class:"zx-app-sidebar__item-label"},s.label),s.badge!=null?l("span",{class:"zx-app-sidebar__item-badge"},String(s.badge)):null,t?l("span",{class:"zx-app-sidebar__item-disclosure",ariaHidden:"true"},g(e?"chevron-down":"chevron-right")):null)}function Mi(s){return s?[...s.querySelectorAll("[data-app-nav-id]")].filter(t=>!t.closest(".zx-app-sidebar__sublist[hidden]")):[]}function vv(s){let t=s;for(;t;){let e=t.closest(".zx-app-sidebar__sublist[hidden]");if(!e)return t;t=e.parentElement?.firstElementChild??null}return null}function Ie(s,t){for(let e of s){if(String(e.id)===String(t))return e;let i=Ie(e.children??[],t);if(i)return i}return null}function hl(s,t){for(let e of s)t(e),hl(e.children??[],t)}function Jh(s,t){return s.some(e=>String(e.id)===t||Jh(e.children??[],t))}function fe(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&s.append(t)}function Qh(s,t){let e=document.createDocumentFragment(),i=t.flatMap(r=>{if(r==null)return[];if(typeof r=="object"&&typeof r.toElement=="function"){let o=r.toElement();return o?[o]:[]}return typeof r=="object"&&typeof r.nodeType=="number"?[r]:(fe(e,r),[...e.childNodes])}),n=[...s.childNodes];(i.length!==n.length||i.some((r,o)=>r!==n[o]))&&s.replaceChildren(...i),s.hidden=!s.hasChildNodes()}function Xh(s,t){return s==="horizontal"?t==="bottom"?"bottom":"top":t==="right"?"right":"left"}function Zh(s){return s.map(t=>{let{children:e,...i}=t;return e?.length?{...i,children:Zh(e)}:i})}var xv=8e3,pl=class{#t;#e=[];#i=[];#s;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let i=this.#e.indexOf(t);if(i===-1)return null;if(this.#e.splice(i,1),this.#i.length>0){let n=this.#i.shift();this.#e.push(n),this.#s(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},br=class s extends y{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};render(){let t=!this.el,e=this.el??l("div");return this._createdRoot=t,this._original=t?null:Dv(e),this._entries=new Set,this._floatingHost=null,this._placedIn=null,this._overlay=null,this._unfollow=null,this._queue=new pl(Iv(this.options.maxVisible),i=>{this._activate(i)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let i=zv(e.action),n={kind:Sv(e.kind??this.options.kind),timeout:kv(e.timeout??this.options.timeout,i!==null),closable:e.closable??!!this.options.closable,action:i,leading:Cv(e.leading)},r=this._createEntry(t,n);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#t(e.scope).show(t,e)}static progress(t,e={}){return this.#t(e.scope)._progress(t)}static disposeRegion(t){if(t==null)return!1;let e=P(t);if(!e)return!1;let i=s.#e(vt(e));return i?(i._disposeFloating(),!0):!1}destroy(){if(this._cleaned)return;this._cleaned=!0,this._unfollow?.(),this._unfollow=null;let t=this._overlay;this._overlay=null,t?.release(),this._floatingHost=null,this._placedIn=null;for(let e of this._entries)fl(e),e.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Nv(this.el,this._original)}_progress(t){let e={pct:0,text:String(t)},i=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(i),this._queue.enqueue(i);let n=!1;return{update:(r,o)=>{n||i.closed||(e.pct=Ev(r),o!==void 0&&(e.text=String(o)),gr(i,e))},done:()=>{n||i.closed||(n=!0,e.pct=100,gr(i,e),i.remaining=600,this._queue.isActive(i)&&this._schedule(i))},fail:r=>{n||i.closed||(n=!0,r!==void 0&&(e.text=String(r)),i.kind="error",i.node.dataset.kind="error",i.node.setAttribute("role","alert"),i.iconHost.replaceChildren(g("error",{size:18})),gr(i,e),i.remaining=4e3,this._queue.isActive(i)&&this._schedule(i))}}}_createEntry(t,e,i=null){let n=l("span",{class:"zx-message__icon",ariaHidden:"true"},e.leading??g(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});Ss(t)?r.append(t):r.append(document.createTextNode(String(t)));let o=l("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,hovered:!1,focused:!1,returnFocus:null,progressBar:null,progressFill:null};if(e.leading&&(o.dataset.leading=""),i){o.dataset.progress="";let c=l("span",{class:"zx-message__progress-fill"}),d=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:i.text},c);r.append(d),a.progressBar=d,a.progressFill=c,gr(a,i)}if(e.action){let{label:c,kind:d,onclick:u}=e.action,h=j({label:c,kind:d,size:"sm"});h.classList.add("zx-message__action"),o.append(h),this.listen(h,"click",f=>{if(!a.closed)try{u?.(f)}finally{this._close(a)}})}if(e.closable){let c=l("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:this._message("message.close","Close message"),title:this._message("message.closeTitle","Close")},g("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>{a.hovered=!0,this._pause(a)}),this.listen(o,"mouseleave",()=>{a.hovered=!1,this._resume(a)}),this.listen(o,"focusin",c=>{if(!a.focused){let d=c.relatedTarget;a.returnFocus=Ss(d)&&!o.contains(d)?d:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",c=>{let d=c.relatedTarget;Ss(d)&&o.contains(d)||(a.focused=!1,this._resume(a))}),a}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||t.hovered||t.focused||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null||t.hovered||t.focused)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,fl(t),Tv(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t),this._releaseIfEmpty();return}if(t.node.dataset.state="closing",!Mv()){this._finish(t);return}let e=i=>{i.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(fl(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t),this._releaseIfEmpty())}_releaseIfEmpty(){!this._floatingHost||this._entries.size>0||s.#i(this)}_rehome(){let t=this._floatingHost;if(!t)return;let e=ui.topmostModal()??t;if(this.el.parentElement===e&&this._placedIn===e)return;e.append(this.el),this._placedIn=e;let i=this.el;typeof i.showPopover=="function"&&!i.matches(":popover-open")&&i.showPopover()}_disposeFloating(){let t=this.el;this.destroy(),t.remove()}_message(t,e){let i=this.msg(t);return i===t?e:i}static#t(t){let e=vt(t??null);e.isConnected||(e=vt(null));let i=this.#e(e);if(i&&i.el.isConnected&&i.el.parentElement===i._placedIn)return i._rehome(),i;i?._disposeFloating();let n=l("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"}),r=new s(n);return r._floatingHost=e,r._overlay=ui.push({kind:"toast",root:n,owner:r}),r._unfollow=ui.subscribe(()=>r._rehome()),r._rehome(),r}static#e(t){for(let e of ui.entries())if(e.kind==="toast"&&e.owner instanceof s&&e.owner._floatingHost===t)return e.owner;return null}static#i(t){t._disposeFloating()}};function Sv(s){return s==="danger"?"error":["success","warning","error"].includes(String(s))?s:"info"}function Av(s){let t=Number(s);return Number.isFinite(t)?Math.max(0,t):4e3}function kv(s,t=!1){let e=Av(s);return t&&e>0?Math.max(e,xv):e}function zv(s){if(!s||typeof s!="object")return null;let t=s,e=t.label==null?"":String(t.label).trim();if(!e)return null;let i=["primary","danger","ghost"].includes(String(t.kind))?t.kind:"default";return{label:e,kind:i,onclick:typeof t.onclick=="function"?t.onclick:null}}function Cv(s){if(Ss(s))return s;if(s&&typeof s=="object"&&typeof s.toElement=="function"){let t=s.toElement();return Ss(t)?t:null}return null}function Tv(s){let e=s.node.getRootNode?.()?.activeElement??globalThis.document?.activeElement;if(!e||!s.node.contains(e))return;let i=s.returnFocus;s.returnFocus=null,i?.isConnected&&typeof i.focus=="function"&&i.focus({preventScroll:!0})}function Iv(s){let t=Number(s);return Number.isInteger(t)&&t>0?t:5}function Ss(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Ev(s){let t=Number(s);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function gr(s,t){s.content.firstChild.textContent=t.text,s.progressBar?.setAttribute("aria-valuenow",String(t.pct)),s.progressBar?.setAttribute("aria-label",t.text),s.progressFill&&(s.progressFill.style.inlineSize=`${t.pct}%`)}function fl(s){s.timer!==null&&clearTimeout(s.timer),s.exitTimer!==null&&clearTimeout(s.exitTimer),s.timer=null,s.exitTimer=null}function Mv(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Dv(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Nv(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var Ov=new Set(["start","end","top","bottom"]),Fv=new Set(["dim","blur","none"]),Lv=Object.freeze({start:1,end:-1,top:1,bottom:-1}),yr=class extends qt{static cssName="sheet";static defaults={side:"end",modal:!0,backdrop:"dim",size:null,closeButton:!0,resizable:!1,min:160,max:null,handle:"auto",snap:null,lightDismiss:!0};#t=null;#e=null;#i=0;constructor(t=null,e={}){super(null,e),this._dock=null,this._openedFrom=null,this.setSide(this.options.side),this.el.dataset.backdrop=Fv.has(this.options.backdrop)?this.options.backdrop:"dim",this.el.dataset.modality=Bv(this.options.modal),this.refs.close.hidden=!this.options.closeButton,this.on("close",()=>this.#t?.deactivate()),this.on("close",()=>{let i=super.mountTarget();!this._dock&&this.el.parentElement!==i&&this.el.parentElement?.closest("dialog")&&i.append(this.el)}),this.#s()&&this.#r()}#s(){let t=this.options.handle,e=this.getSide(),i=t===!0||t==="auto"&&(e==="top"||e==="bottom");return!!this.options.resizable||Array.isArray(this.options.snap)||i}#r(){let t=this.getSide()==="top"||this.getSide()==="bottom",e=l("div",{class:"zx-sheet__handle",ref:"handle",role:"separator",tabindex:0,ariaOrientation:t?"horizontal":"vertical",ariaLabel:this._message("sheet.resize","Resize sheet")});this.el.append(e),this.refs.handle=e,this.#l(),this.#e=wi(e,{orientation:t?"vertical":"horizontal",disabled:()=>this.isDocked(),onStart:()=>{this.#i=this.getSize(),this.el.dataset.dragging="true"},onMove:i=>this.#n(i,!1),onEnd:(i,n)=>{delete this.el.dataset.dragging,n&&this.#n(i,!0)},onStep:(i,n)=>{this.#i=this.getSize(),this.#n(i*(n?64:16),!0)}})}#n(t,e){let i=this.#o(),{min:n,max:r}=this.#a(i),a=!!this.options.resizable||this.#c(i).length>0?r:Math.min(r,this.#i),c=q(this.#i+t*Lv[this.getSide()],0,a);if(!e){this._applySize(c),this.#l();return}if(this.options.closable&&c<n/2){this._applySize(this.#i),this.close();return}let d=this.#c(i),u=d.length>0?Pv(c,d):c;this._applySize(q(u,n,a)),this.#l(),this.emit("resize",{size:this.getSize(),ratio:i>0?this.getSize()/i:0})}snapTo(t){let e=this.#o(),i=this.#c(e);if(i.length===0)return this;let n=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<i.length?i[t]:tf(t,e);if(!Number.isFinite(n))return this;let{min:r,max:o}=this.#a(e);return this._applySize(q(n,r,o)),this.#l(),this.emit("resize",{size:this.getSize(),ratio:e>0?this.getSize()/e:0}),this}getSize(){let t=this.el.getBoundingClientRect();return this.getSide()==="top"||this.getSide()==="bottom"?t.height:t.width}_message(t,e){let i=this.msg(t);return i===t?e:i}#o(){return this.getSide()==="top"||this.getSide()==="bottom"?window.innerHeight:window.innerWidth}#a(t){let e=this.#c(t),i=Math.max(0,Number(this.options.min)||0),n=this.options.max==null?t:Math.min(t,Number(this.options.max)||t),r=e.length>0?Math.max(i,Math.min(...e)):i;return{min:Math.min(r,n),max:n}}#c(t){let e=this.options.snap;return Array.isArray(e)?e.map(i=>tf(i,t)).filter(i=>Number.isFinite(i)&&i>0).sort((i,n)=>i-n):[]}#l(){let t=this.refs.handle;if(!t)return;let e=this.#o(),{min:i,max:n}=this.#a(e);t.setAttribute("aria-valuenow",String(Math.round(this.getSize()))),t.setAttribute("aria-valuemin",String(Math.round(i))),t.setAttribute("aria-valuemax",String(Math.round(n)))}mountTarget(){if(this._dock)return this._dock.el;if(this.el&&this.options.modal!==!0){let t=this._openedFrom??P(this.options.scope),e=Rv(t,this.el);if(e)return e}return super.mountTarget()}isDocked(){return!!this._dock}_setDock(t){this._dock!==t&&(this._dock=t??null,this.el.toggleAttribute("data-docked",!!this._dock),this._rehost(),this.emit("dockchange",{docked:!!this._dock,dock:this._dock}))}_rehost(){let t=this.isOpen();t&&this._dismiss(),this.mountTarget().append(this.el),t&&(this.el.returnValue="",this._present(),this.el.dataset.state="open",this._syncOverlay())}_overlayEntry(){if(this._dock)return null;let t=super._overlayEntry();return!t||this.options.modal===!0?t:{...t,onEscape:e=>{if(!this.options.closable||!this._overlayContains(e.target))return!1;this.emit("cancel").defaultPrevented||this.close()},onOutsidePointer:this.options.lightDismiss?()=>{this.close()}:void 0,onParentClose:()=>{let e=this.el.parentElement?.closest("dialog");e&&!e.open&&!e.matches(":popover-open")&&this.close()}}}open(){if(this.isOpen())return this;this._openedFrom=document.activeElement,this.options.modal==="trap-focus"&&(this.#t??=dn(this.el),this.#t.activate());try{super.open()}finally{this._openedFrom=null}return this.#l(),this}close(t){return this.#t?.deactivate(),super.close(t)}setSide(t){return this.el.dataset.side=Ov.has(t)?t:"end",this}getSide(){return this.el.dataset.side}setSize(t){return this._applySize(t),this}isModal(){return this.options.modal===!0}_applySize(t){this.el.style.removeProperty("inline-size"),this.el.style.removeProperty("block-size");let e=Vv(t);e===null?this.el.style.removeProperty("--zx-sheet-size"):this.el.style.setProperty("--zx-sheet-size",e)}_show(){if(this.options.modal===!0&&!this._dock){this.el.removeAttribute("popover"),this.el.removeAttribute("aria-modal"),super._show();return}if(this.el.setAttribute("aria-modal","false"),this._dock){this.el.removeAttribute("popover"),this.el.show();return}this.el.setAttribute("popover","manual"),this.el.showPopover()}_hide(t="",e){if(!this.el.matches(":popover-open")){super._hide(t,e);return}this.el.returnValue=t,this.el.hidePopover(),queueMicrotask(()=>this._settleClose(e))}_isShown(){return this.el.matches(":popover-open")||super._isShown()}destroy(){this.#t?.deactivate(),this.#t=null,this.#e?.destroy(),this.#e=null,this._dock?._forget(this),this._dock=null,super.destroy()}};function Rv(s,t){if(!s||typeof s.closest!="function"||t.contains(s))return null;try{return s.closest("dialog:modal")}catch{return null}}function tf(s,t){return typeof s=="number"&&Number.isFinite(s)&&s>0&&s<=1?s*t:_t(s,t)}function Pv(s,t){let e=s,i=Number.POSITIVE_INFINITY;for(let n of t){let r=Math.abs(n-s);r<i&&(i=r,e=n)}return e}function Bv(s){return s===!0?"modal":s==="trap-focus"?"trap-focus":"none"}function Vv(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}var wr=class s extends EventTarget{static defaults=Object.freeze({layout:"stack",offset:24,scale:.04,max:3});#t=[];#e=new WeakMap;#i=!1;constructor(t={}){super();let e={...s.defaults,...t&&typeof t=="object"?t:{}};for(let[i,n]of Object.entries(e))!/^on[a-z]/.test(i)||typeof n!="function"||(this.on(i.slice(2),n),delete e[i]);this.options=Object.freeze(e)}push(t){if(!t||typeof t.open!="function")throw new TypeError("SheetStack.push expects a Sheet");let e=this.#t.indexOf(t);if(e!==-1&&this.#t.splice(e,1),this.#t.push(t),!this.#e.has(t)){let i=()=>this.#s(t);this.#e.set(t,i),t.on("close",i)}return t.isOpen()||t.open(),this.#n(),this.#o("push",{sheet:t,depth:0}),this}pop(){let t=this.top();return t?(this.#r(t),t.close(),t):null}popTo(t){let e=this.#t.indexOf(t);if(e===-1)return this;for(;this.#t.length>e+1;)this.pop();return this}clear(){for(;this.#t.length>0;)this.pop();return this}top(){return this.#t[this.#t.length-1]??null}size(){return this.#t.length}sheets(){return[...this.#t]}has(t){return this.#t.includes(t)}on(t,e){return this.addEventListener(t,e),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0}),this}destroy(){if(!this.#i){this.#i=!0;for(let t of this.#t){let e=this.#e.get(t);e&&t.off("close",e),ef(t)}this.#t=[]}}#s(t){this.#t.includes(t)&&this.#r(t)}#r(t){let e=this.#t.indexOf(t);if(e===-1)return;this.#t.splice(e,1);let i=this.#e.get(t);i&&t.off("close",i),this.#e.delete(t),ef(t),this.#n(),this.#o("pop",{sheet:t})}#n(){let{layout:t,offset:e,scale:i,max:n}=this.options,r=t==="cascade",o=0;for(let a=0;a<this.#t.length;a+=1){let c=this.#t[this.#t.length-1-a],d=c.el;d.dataset.stack=r?"cascade":"stack",d.dataset.depth=String(a),d.style.setProperty("--zx-sheet-depth",String(a)),d.style.setProperty("--zx-sheet-stack-offset",`${Number(e)||0}px`),d.style.setProperty("--zx-sheet-stack-scale",String(Number(i)||0)),d.toggleAttribute("data-stack-hidden",a>=Math.max(1,Number(n)||1)),d.inert=!r&&a>0,r?(d.style.setProperty("--zx-sheet-depth-offset",`${o}px`),o+=c.getSize()):d.style.removeProperty("--zx-sheet-depth-offset")}}#o(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}};function ef(s){let t=s.el;if(t){delete t.dataset.stack,delete t.dataset.depth,t.removeAttribute("data-stack-hidden"),t.inert=!1;for(let e of["--zx-sheet-depth","--zx-sheet-stack-offset","--zx-sheet-stack-scale","--zx-sheet-depth-offset"])t.style.removeProperty(e)}}var Di=class extends y{static defaults={items:[],selector:null};#t;#e;#i;#s;#r;#n=[];#o=null;#a=null;#c=!1;constructor(t,e={}){let i=P(t);if(!i)throw new TypeError("ContextMenu target could not be resolved");super(null,e),this.#t=i,document.body.append(this.el),this.#e=new pt(this.el,{openOn:"manual",placement:"bottom-start",scope:i}),this.#i=this.#e.getPanel(),this.#e._configure({onEscape:()=>this.close(),tabReach:!1}),this.#i.classList.add("zx-context-menu"),this.#i.setAttribute("role","menu"),Array.isArray(this.options.items)&&this.setItems(this.options.items),this.#s=Mt(this.#i,Lt),this.#r=ut(()=>this.#m(),n=>n.focus()),this.#e.on("close",()=>{this.#o=null;let n=this.#a;this.#a=null,n instanceof HTMLElement&&n.isConnected&&n.focus(),this.emit("close")}),this.listen(this.#t,"contextmenu",n=>this.#f(n)),this.listen(this.#t,"keydown",n=>this.#h(n)),this.listen(this.#i,"click",n=>{let r=n.target.closest?.(Lt);r&&this.#i.contains(r)&&this.#_(r,n)}),this.listen(this.#i,"keydown",n=>this.#p(n))}render(){return l("span",{class:"zx-context-menu__anchor",ariaHidden:"true"})}setItems(t){return this.#n=Array.isArray(t)?t.slice():[],this.#i.replaceChildren(...Nn(this.#n,"context-menu")),this}openAt(t,e,i=null){return this.#l(i)?(this.#d(t,e,i),this):this}openAtElement(t){let e=t.getBoundingClientRect();return this.openAt(e.left,e.bottom,t)}close(){return this.#e.close(),this}isOpen(){return this.#e.isOpen()}getContext(){return this.#o}destroy(){this.#c||(this.#c=!0,this.#s.destroy(),this.#e.destroy(),super.destroy())}#l(t){let e=this.options.items;if(typeof e=="function"){let i=e(t);if(!Array.isArray(i)||i.length===0)return!1;this.setItems(i)}return this.#n.length>0}#d(t,e,i){let n=this.el;n.style.left=`${t}px`,n.style.top=`${e}px`,this.#o=i,this.#a=document.activeElement,this.#e.open(),this.#s.focusFirst(),this.emit("open",{context:i})}#f(t){let e=t,i=this.#u(e.target);!i||!this.#l(i)||(t.preventDefault(),this.#d(e.clientX,e.clientY,i))}#h(t){let e=t;if(e.key!=="ContextMenu"&&!(e.key==="F10"&&e.shiftKey))return;let i=this.#u(e.target);if(!i||!this.#l(i))return;t.preventDefault();let n=i.getBoundingClientRect();this.#d(n.left,n.bottom,i)}#u(t){if(!this.options.selector)return this.#t;let e=t?.closest?.(String(this.options.selector));return e&&this.#t.contains(e)?e:null}#p(t){let e=t;if(e.key==="Tab"){t.preventDefault(),this.close();return}if(e.key==="Enter"||e.key===" "){let i=e.target.closest?.(Lt);if(!i||!this.#i.contains(i)||e.key==="Enter"&&i.tagName==="A")return;t.preventDefault(),i.click();return}this.#r(e)}#_(t,e=null){let i=Number(t.getAttribute("data-menu-item")),n=this.#n[i];if(!cs(n)||n.disabled){e?.preventDefault();return}let r=this.#o;if(this.emit("select",{value:n.value,item:n,context:r}).defaultPrevented){e?.preventDefault();return}try{n.onselect?.(n.value,n,this)}finally{this.close()}}#m(){return Array.from(this.#i.querySelectorAll(Lt))}};var ks=Object.freeze(["agenda","day","week","month","year"]),jv=864e5;function xr(s,t,e={}){let i=Me(t,"Calendar date"),n=cf(e.weekStart??1),r,o;if(s==="agenda")r=Y(i),o=R(r,kr(e.agendaDays??14,"agendaDays"));else if(s==="day")r=Y(i),o=R(r,1);else if(s==="week")r=As(i,n),o=R(r,7);else if(s==="month"){let a=new Date(i.getFullYear(),i.getMonth(),1),c=new Date(i.getFullYear(),i.getMonth()+1,0);r=As(a,n),o=R(As(c,n),7)}else if(s==="year")r=new Date(i.getFullYear(),0,1),o=new Date(i.getFullYear()+1,0,1);else throw new RangeError(`Unknown calendar view: ${s}`);return{start:r,end:o}}function Sr(s,t,e,i={}){let n=Me(t,"Calendar date"),r=Wt(e,"direction");if(s==="day")n.setDate(n.getDate()+r);else if(s==="agenda")n.setDate(n.getDate()+r*kr(i.agendaDays??14,"agendaDays"));else if(s==="week")n.setDate(n.getDate()+r*7);else{if(s==="month")return vr(n,r);if(s==="year")return vr(n,r*12);throw new RangeError(`Unknown calendar view: ${s}`)}return n}function vr(s,t){let e=Me(s,"Calendar date"),i=e.getDate();return e.setDate(1),e.setMonth(e.getMonth()+Wt(t,"month amount")),e.setDate(Math.min(i,Hv(e.getFullYear(),e.getMonth()))),e}function Hv(s,t){return new Date(s,t+1,0).getDate()}function Ee(s,t={}){if(!Array.isArray(s))throw new TypeError("Calendar events must be an array");let e={id:t.eventId??"id",title:t.eventTitle??"title",start:t.eventStart??"start",end:t.eventEnd??"end",allDay:t.eventAllDay??"allDay",color:t.eventColor??"color",location:t.eventLocation??"location",editable:t.eventEditable??"editable",durationEditable:t.eventDurationEditable??"durationEditable"},i=t.dateUnit==="seconds"?"seconds":"milliseconds",n=new Set;return s.map((r,o)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError(`Calendar event at index ${o} must be an object`);let a=Yt(r,e.id);if(a==null||a==="")throw new TypeError(`Calendar event at index ${o} requires an id`);let c=String(a);if(n.has(c))throw new RangeError(`Duplicate Calendar event id: ${c}`);n.add(c);let d=nf(Yt(r,e.start),i,`event ${c} start`),u=Yt(r,e.end),h=u==null||u===""?new Date(d.getTime()):nf(u,i,`event ${c} end`);if(h<d)throw new RangeError(`Calendar event ${c} ends before it starts`);let f=String(Yt(r,e.title)??"").trim()||"Untitled event",p=String(Yt(r,e.location)??"").trim(),_=rf(Yt(r,e.editable)),m=rf(Yt(r,e.durationEditable));return{id:a,title:f,start:d,end:h,allDay:!!Yt(r,e.allDay),color:$v(Yt(r,e.color)),location:p,editable:_,durationEditable:m,data:r}})}function W(s){return{...s,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())}}function Ar(s,t,e={}){let i=lf(e.minMinutes??0,"minMinutes"),n=lf(e.maxMinutes??1440,"maxMinutes",!0),r=kr(e.minimumMinutes??30,"minimumMinutes");if(n<=i)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=Y(t),a=of(o,i),c=of(o,n),d=s.filter(p=>!kt(p)&&_l(p,a,c)).map(p=>{let _=new Date(Math.max(p.start.getTime(),a.getTime())),m=new Date(Math.min(p.end.getTime(),c.getTime()));return m<=_&&(m=new Date(Math.min(c.getTime(),_.getTime()+r*6e4))),{event:p,start:_,end:m,startMinutes:af(o,_),endMinutes:af(o,m),column:0,columns:1}}).sort((p,_)=>p.start-_.start||_.end-p.end||String(p.event.id).localeCompare(String(_.event.id))),u=[],h=-1/0,f=()=>{if(!u.length)return;let p=[],_=1;for(let m of u){let b=p.findIndex(w=>w<=m.start.getTime());b===-1&&(b=p.length),p[b]=m.end.getTime(),m.column=b,_=Math.max(_,b+1)}for(let m of u)m.columns=_;u=[],h=-1/0};for(let p of d)u.length&&p.start.getTime()>=h&&f(),u.push(p),h=Math.max(h,p.end.getTime());return f(),d}function zs(s,t,e){let i=Y(t),n=R(i,kr(e,"days")),r=s.filter(a=>kt(a)&&_l(a,i,n)).map(a=>{let c=Y(a.start),d=qv(a);return{event:a,start:Math.max(0,At(i,c)),end:Math.min(e,At(i,d)),lane:0}}).filter(a=>a.end>a.start).sort((a,c)=>a.start-c.start||c.end-a.end||String(a.event.id).localeCompare(String(c.event.id))),o=[];for(let a of r){let c=o.findIndex(d=>d<=a.start);c===-1&&(c=o.length),a.lane=c,o[c]=a.end}return r}function Ni(s,t={}){let e=Wt(t.days??0,"days"),i=Wt(t.minutes??0,"minutes"),n=Wt(t.endDays??e,"endDays"),r=Wt(t.endMinutes??i,"endMinutes"),o=W(s);if(o.start=sf(o.start,e,i),o.end=sf(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function Y(s){let t=Me(s,"Calendar date");return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function R(s,t){let e=Me(s,"Calendar date"),i=new Date(e.getTime());return i.setDate(i.getDate()+Wt(t,"day amount")),i}function As(s,t=1){let e=Y(s),i=cf(t);return R(e,-((e.getDay()-i+7)%7))}function At(s,t){let e=Y(s),i=Y(t),n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate());return Math.round((r-n)/jv)}function X(s){let t=Me(s,"Calendar date"),e=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function kt(s){if(s.allDay)return!0;if(s.end<=s.start)return!1;let t=new Date(s.end.getTime()-1);return X(s.start)!==X(t)}function Oi(s,t,e){return _l(s,t,e)}function sf(s,t,e){let i=new Date(s.getTime());return i.setDate(i.getDate()+t),i.setMinutes(i.getMinutes()+e),i}function qv(s){if(s.end<=s.start)return R(Y(s.start),1);let t=Y(s.end);return s.end.getTime()===t.getTime()?t:R(t,1)}function _l(s,t,e){let i=s.end>s.start?s.end:new Date(s.start.getTime()+1);return s.start<e&&i>t}function Yt(s,t){return typeof t=="function"?t(s):s[t]}function nf(s,t,e){let i;if(s instanceof Date)i=new Date(s.getTime());else if(typeof s=="number"||typeof s=="string"&&/^-?\d+(?:\.\d+)?$/.test(s.trim())){let n=Number(s);i=new Date(n*(t==="seconds"?1e3:1))}else i=new Date(s);return Me(i,e)}function rf(s){return s==null?null:!!s}function $v(s){let t=String(s??"").trim();return!t||t.length>100||/[;{}]|url\s*\(|image\s*\(/i.test(t)?null:/^#[\da-f]{3,8}$/i.test(t)||/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\([^{};]+\)$/i.test(t)||/^var\(--[\w-]+\)$/i.test(t)||/^[a-z]+$/i.test(t)?t:null}function of(s,t){let e=Y(s);return e.setMinutes(t),e}function af(s,t){return(t.getTime()-s.getTime())/6e4}function Me(s,t){if(!(s instanceof Date)||Number.isNaN(s.getTime()))throw new TypeError(`${t} must be a valid Date`);return new Date(s.getTime())}function cf(s){let t=Number(s);if(!Number.isInteger(t)||t<0||t>6)throw new RangeError("weekStart must be from 0 through 6");return t}function Wt(s,t){let e=Number(s);if(!Number.isInteger(e))throw new TypeError(`${t} must be an integer`);return e}function kr(s,t){let e=Wt(s,t);if(e<=0)throw new RangeError(`${t} must be greater than zero`);return e}function lf(s,t,e=!1){let i=Wt(s,t),n=e?1440:1439;if(i<0||i>n)throw new RangeError(`${t} must be from 0 through ${n}`);return i}var Cr=class extends y{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...ks],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 t=!this.el,e=this.el??l("section");this.el||(this.el=e),this._createdRoot=t,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes).map(({name:h,value:f})=>[h,f]),children:Array.from(e.childNodes)},this._views=Kv(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=df(this.options.date,this.options.dateUnit,this._now()),this._events=Ee(this.options.events,this._normalizeOptions()),this._loading=!1,this._destroyed=!1,this._pointer=null,this._keyboardEdit=null,this._mutationVersions=new Map,this._mutationSerial=0,this._suppressClickId=null,this._suppressDateClick=!1,this._focusedSlot=null,this._selection=null,this._nowTimer=null;let i=l("div",{class:"zx-calendar__navigation"},this._toolbarButton("previous",this.msg("calendar.previous"),"chevron-left"),this._toolbarButton("today",this.msg("calendar.today")),this._toolbarButton("next",this.msg("calendar.next"),"chevron-right")),n=l("h2",{ref:"heading",class:"zx-calendar__heading",ariaLive:"polite"}),r=l("div",{ref:"views",class:"zx-calendar__views",role:"group",ariaLabel:this._message("calendar.viewSwitch","Calendar view")},this._views.map(h=>l("button",{type:"button",class:"zx-calendar__view-button",dataset:{calendarAction:"view",view:h},disabled:this.options.disabled},this.msg(`calendar.${h}`)))),o=l("div",{class:"zx-calendar__commands"},r,l("button",{type:"button",class:"zx-calendar__new",dataset:{calendarAction:"new"},disabled:this.options.disabled},g("plus"),l("span",{},this.msg("calendar.new")))),a=l("header",{class:"zx-calendar__toolbar"},i,n,o),c=l("div",{ref:"body",class:"zx-calendar__body"}),d=l("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("calendar.loading")),u=l("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return e.replaceChildren(a,c,d,u),e.setAttribute("aria-label",this.msg("calendar.label")),e.dataset.view=this._view,e.dataset.state="ready",this.listen(e,"click",h=>this._onClick(h)),this.listen(e,"dblclick",h=>this._onDoubleClick(h)),this.listen(e,"keydown",h=>this._onKeydown(h)),this.listen(e,"pointerdown",h=>this._onPointerDown(h)),this.listen(e,"pointermove",h=>this._onPointerMove(h)),this.listen(e,"pointerup",h=>this._onPointerUp(h)),this.listen(e,"pointercancel",h=>this._cancelPointer(h)),this.listen(e,"dragstart",h=>h.preventDefault()),this._renderView({emitDates:!0,scroll:!0}),this.options.nowIndicator&&(this._nowTimer=setInterval(()=>this._refreshNowIndicator(),6e4)),e}getEvents(){return this._events.map(W)}setEvents(t,e={}){let i=Ee(t,this._normalizeOptions());return this._events=i,this._mutationVersions.clear(),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}addEvent(t,e={}){let[i]=Ee([t],this._normalizeOptions());if(this._eventById(i.id))throw new RangeError(`Duplicate Calendar event id: ${i.id}`);return this._events=[...this._events,i],this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}updateEvent(t,e,i={}){let n=this._eventIndex(t);if(n<0)throw new RangeError(`Unknown Calendar event id: ${t}`);let r=this._events[n],o={id:r.id,title:e.title??r.title,start:e.start??r.start,end:e.end??r.end,allDay:e.allDay??r.allDay,color:Object.prototype.hasOwnProperty.call(e,"color")?e.color:r.color,location:e.location??r.location,editable:Object.prototype.hasOwnProperty.call(e,"editable")?e.editable:r.editable,durationEditable:Object.prototype.hasOwnProperty.call(e,"durationEditable")?e.durationEditable:r.durationEditable,data:e.data??r.data},[a]=Ee([o],{dateUnit:this.options.dateUnit});return a.data=o.data,this._events=this._events.map((c,d)=>d===n?a:c),this._mutationVersions.delete(String(t)),this._renderView({preserveFocus:!0}),i.silent||this.emit("eventschange",{events:this.getEvents()}),this}removeEvent(t,e={}){let i=String(t),n=this._events.filter(r=>String(r.id)!==i);return n.length===this._events.length?this:(this._events=n,this._mutationVersions.delete(i),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this)}getDate(){return new Date(this._date.getTime())}setDate(t,e={}){return this._date=df(t,this.options.dateUnit,this._now()),this._renderView({emitDates:!e.silent,preserveFocus:!0,scroll:!0}),this}getView(){return this._view}setView(t,e={}){if(!this._views.includes(t))throw new RangeError(`Calendar view is not enabled: ${t}`);if(t===this._view)return this;let i=this._view;return this._view=t,this.el.dataset.view=t,this._renderView({emitDates:!0,preserveFocus:!0,scroll:!0}),e.silent||this.emit("viewchange",{view:t,oldView:i}),this}prev(){return this._page(-1)}next(){return this._page(1)}today(){return this.setDate(this._now())}setLoading(t=!0){return this._loading=!!t,this.el.dataset.state=this._loading?"loading":"ready",this.el.setAttribute("aria-busy",String(this._loading)),this.refs.loading.hidden=!this._loading,this}focusEvent(t){return this.el.querySelector(`[data-event-action][data-event-id="${zr(String(t))}"]`)?.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._nowTimer&&clearInterval(this._nowTimer),this._nowTimer=null;let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_toolbarButton(t,e,i=null){return l("button",{type:"button",class:"zx-calendar__toolbar-button",dataset:{calendarAction:t},ariaLabel:i?e:null,disabled:this.options.disabled},i?g(i):e)}_normalizeOptions(){return{eventId:this.options.eventId,eventTitle:this.options.eventTitle,eventStart:this.options.eventStart,eventEnd:this.options.eventEnd,eventAllDay:this.options.eventAllDay,eventColor:this.options.eventColor,eventLocation:this.options.eventLocation,eventEditable:this.options.eventEditable,eventDurationEditable:this.options.eventDurationEditable,dateUnit:this.options.dateUnit}}_renderView(t={}){if(!this.refs?.body||this._destroyed)return;let e=t.preserveFocus?this._focusIdentity():null,i=xr(this._view,this._date,{weekStart:this.options.weekStart,agendaDays:this.options.agendaDays});this._range=i,this.refs.heading.textContent=this._rangeTitle(i);for(let r of this.refs.views.querySelectorAll("[data-view]"))r.setAttribute("aria-pressed",String(r.dataset.view===this._view));let n=this._view==="agenda"?this._renderAgenda(i):this._view==="day"||this._view==="week"?this._renderTimeGrid(i):this._view==="month"?this._renderMonth(i):this._renderYear(i);this.refs.body.replaceChildren(n),t.scroll&&this._scrollTimeGrid(),e&&this._restoreFocus(e),t.emitDates&&this.emit("dateschange",{view:this._view,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())})}_renderAgenda(t){let e=l("div",{class:"zx-calendar__agenda",role:"grid",ariaLabel:this._rangeTitle(t)}),i=At(t.start,t.end);for(let n=0;n<i;n+=1){let r=R(t.start,n),o=R(r,1),a=this._events.filter(u=>Oi(u,r,o)?u.start>=r||n===0:!1).sort(Wv),c=l("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:X(r)}},l("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:X(r),dateCell:"true"},ariaCurrent:Ne(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),d=l("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)d.append(l("p",{class:"zx-calendar__agenda-empty"},this.msg("calendar.noEvents")));else for(let u of a)d.append(this._eventElement(u,{variant:"agenda",day:r}));c.append(d),e.append(c)}return e}_renderTimeGrid(t){let e=Array.from({length:At(t.start,t.end)},(w,v)=>R(t.start,v)),i=this._view==="week"&&this.options.workweek?e.filter(w=>w.getDay()>0&&w.getDay()<6):e,n=Gt(this.options.slotMinTime,0),r=Gt(this.options.slotMaxTime,1440,!0),o=zt(this.options.slotDuration);if(r<=n)throw new RangeError("slotMaxTime must exceed slotMinTime");let a=Math.ceil((r-n)/o),c=l("div",{class:"zx-calendar__time-surface",style:{"--zx-calendar-day-count":String(i.length)}}),d=l("div",{class:"zx-calendar__time-header"},l("span",{class:"zx-calendar__time-corner",ariaHidden:"true"}),l("div",{class:"zx-calendar__day-headings",role:"row"},i.map(w=>l("button",{type:"button",class:"zx-calendar__day-heading",role:"columnheader",dataset:{calendarAction:"date",date:X(w),dateCell:"true"},ariaCurrent:Ne(w,this._now())?"date":null,disabled:this.options.disabled},l("span",{class:"zx-calendar__day-weekday"},this._format(w,{weekday:"short"})),l("span",{class:"zx-calendar__day-number"},this._format(w,{day:"numeric",month:"short"})))))),u=this._renderAllDayRail(i),h=l("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),f=l("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),p=l("div",{class:"zx-calendar__time-grid",role:"grid",ariaLabel:this._rangeTitle(t),ariaRowcount:String(a),ariaColcount:String(i.length),style:{"--zx-calendar-slot-count":String(a)}}),_=l("div",{ref:"slots",class:"zx-calendar__slots"}),m=!0;for(let w=0;w<a;w+=1){let v=n+w*o;f.append(l("span",{class:"zx-calendar__time-label"},v%60===0?ml(v,this.options.locale):""));for(let z=0;z<i.length;z+=1){let C=Yv(i[z],v),k=String(C.getTime()),M=this._focusedSlot?this._focusedSlot===k:m;M&&(m=!1),_.append(l("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:M?0:-1,dataset:{calendarAction:"date",slot:k,dateTime:k,dayIndex:String(z),rowIndex:String(w),major:v%60===0?"true":null},ariaLabel:this._dateTimeLabel(C),disabled:this.options.disabled}))}}let b=l("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return i.forEach((w,v)=>{let z=Ar(this._events,w,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let C of z){let k=(C.startMinutes-n)/(r-n)*100,M=Math.max(o/(r-n)*100,(C.endMinutes-C.startMinutes)/(r-n)*100),it=100/i.length,F=it/C.columns,st=v*it+C.column*F,bt=this._eventElement(C.event,{variant:"timed",day:w,resizable:!0});bt.style.insetInlineStart=`${st}%`,bt.style.inlineSize=`${F}%`,bt.style.insetBlockStart=`${k}%`,bt.style.blockSize=`${M}%`,b.append(bt)}}),p.append(_,b,this._nowLine(i,n,r)),h.append(f,p),c.append(d,u,h),c}_renderAllDayRail(t){let e=l("div",{class:"zx-calendar__all-day"},l("span",{class:"zx-calendar__all-day-label"},this.msg("calendar.allDay"))),i=l("div",{class:"zx-calendar__all-day-grid",role:"row",style:{"--zx-calendar-day-count":String(t.length)}});for(let r of t)i.append(l("span",{class:"zx-calendar__all-day-cell",dataset:{date:X(r)},ariaHidden:"true"}));let n=zs(this._events,t[0],t.length);for(let r of n){let o=this._eventElement(r.event,{variant:"span",day:t[r.start]});o.style.gridColumn=`${r.start+1} / ${r.end+1}`,o.style.gridRow=String(r.lane+1),i.append(o)}return e.append(i),e}_renderMonth(t){let e=l("div",{class:"zx-calendar__month"}),i=l("div",{class:"zx-calendar__month-weekdays",role:"row"});this.options.weekNumbers&&i.append(l("span",{class:"zx-calendar__month-week-gutter",ariaHidden:"true"}));for(let r=0;r<7;r+=1){let o=R(t.start,r);i.append(l("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}e.append(i);let n=At(t.start,t.end)/7;for(let r=0;r<n;r+=1){let o=R(t.start,r*7),a=zs(this._events.map(m=>({...m,allDay:!0})),o,7),c=Uv(this.options.eventLimit),d=a.filter(m=>m.lane<c),u=a.filter(m=>m.lane>=c),h=l("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:X(o)}});this.options.weekNumbers&&h.append(l("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:X(o)},ariaLabel:this.msg("calendar.weekNumber",hf(o)),disabled:this.options.disabled},String(hf(o))));let f=l("div",{class:"zx-calendar__month-days"});for(let m=0;m<7;m+=1){let b=R(o,m),w=this._events.filter(v=>Oi(v,b,R(b,1))).length;f.append(l("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:X(b),dateCell:"true",otherMonth:b.getMonth()===this._date.getMonth()?null:"true",eventCount:String(w)},ariaCurrent:Ne(b,this._now())?"date":null,ariaLabel:this._dayCountLabel(b,w),disabled:this.options.disabled},this._format(b,{day:"numeric"})))}let p=l("div",{class:"zx-calendar__month-events"});for(let m of d){let b=this._eventElement(m.event,{variant:"month",day:R(o,m.start)});b.style.gridColumn=`${m.start+1} / ${m.end+1}`,b.style.gridRow=String(m.lane+1),p.append(b)}let _=Array.from({length:7},(m,b)=>u.filter(w=>w.start<=b&&w.end>b).length);for(let m=0;m<_.length;m+=1){let b=_[m];if(!b)continue;let w=R(o,m);p.append(l("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:X(w),count:String(b)},style:{gridColumn:String(m+1),gridRow:String(c+1)},disabled:this.options.disabled},this.msg("calendar.more",b)))}h.append(f,p),e.append(h)}return e.setAttribute("role","grid"),e.setAttribute("aria-label",this._rangeTitle(t)),e}_renderYear(t){let e=t.start.getFullYear(),i=l("div",{class:"zx-calendar__year",ariaLabel:String(e)});for(let n=0;n<12;n+=1){let r=new Date(e,n,1),o=(r.getDay()-this.options.weekStart+7)%7,a=R(r,-o),c=l("div",{class:"zx-calendar__year-grid",role:"grid",ariaLabel:this._format(r,{month:"long"})},l("h3",{class:"zx-calendar__year-heading"},this._format(r,{month:"long"})));for(let d=0;d<7;d+=1){let u=R(a,d);c.append(l("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(u,{weekday:"narrow"})))}for(let d=0;d<42;d+=1){let u=R(a,d);if(u.getMonth()!==n){c.append(l("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}let h=this._events.filter(f=>Oi(f,u,R(u,1))).length;c.append(l("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:X(u),dateCell:"true",activity:String(Math.min(3,h))},ariaCurrent:Ne(u,this._now())?"date":null,ariaLabel:this._dayCountLabel(u,h),disabled:this.options.disabled},String(u.getDate())))}i.append(c)}return i}_eventElement(t,e){let i=String(t.id),n=l("div",{class:"zx-calendar__event",dataset:{eventId:i,variant:e.variant,allDay:t.allDay?"true":null,draggable:this._canMove(t)?"true":null},style:t.color?{"--zx-calendar-event-color":t.color}:null}),r=l("button",{type:"button",class:"zx-calendar__event-action",dataset:{eventAction:"activate",eventId:i},ariaLabel:this._eventLabel(t),disabled:this.options.disabled}),o=typeof this.options.renderEvent=="function"?this.options.renderEvent(W(t)):null;if(o instanceof Node)r.append(o);else if(typeof o=="string")r.append(document.createTextNode(o));else{let a=l("span",{class:"zx-calendar__event-time"},this._eventTime(t,e.day)),c=l("span",{class:"zx-calendar__event-title"},t.title);r.append(a,c),t.location&&r.append(l("span",{class:"zx-calendar__event-location"},t.location))}return n.append(r),e.resizable&&this._canResize(t)&&n.append(l("button",{type:"button",class:"zx-calendar__event-resize",dataset:{eventAction:"resize",eventId:i},ariaLabel:this.msg("calendar.resize",t.title),disabled:this.options.disabled},l("span",{ariaHidden:"true"}))),n}_nowLine(t,e,i){let n=this._now(),r=t.findIndex(c=>Ne(c,n)),o=n.getHours()*60+n.getMinutes(),a=this.options.nowIndicator&&r>=0&&o>=e&&o<=i;return l("div",{ref:"nowLine",class:"zx-calendar__now",hidden:!a,ariaHidden:"true",style:a?{insetBlockStart:`${(o-e)/(i-e)*100}%`,"--zx-calendar-now-day":String(r)}:null},l("span",{class:"zx-calendar__now-time"},ml(o,this.options.locale)))}_onClick(t){let e=t.target?.closest?.("button");if(!e||!this.el.contains(e))return;let i=e.dataset.eventId;if(i!=null&&this._suppressClickId===i){this._suppressClickId=null,t.preventDefault();return}if(e.dataset.eventAction==="activate"){let r=this._eventById(i);r&&this.emit("eventclick",{event:W(r),jsEvent:t});return}if(e.dataset.eventAction==="resize")return;let n=e.dataset.calendarAction;if(n){if(n==="previous")this.prev();else if(n==="next")this.next();else if(n==="today")this.today();else if(n==="view")this.setView(e.dataset.view);else if(n==="new")this.emit("new",{date:this.getDate(),view:this._view,jsEvent:t});else if(n==="week"){let r=pe(e.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=pe(e.dataset.date);if(!r)return;!this.emit("moreclick",{date:r,count:Number(e.dataset.count),jsEvent:t}).defaultPrevented&&this._views.includes("agenda")&&this.setDate(r).setView("agenda")}else if(n==="date"){if(this._suppressDateClick){this._suppressDateClick=!1,t.preventDefault();return}let r=this._dateFromTarget(e);if(!r)return;this._rememberFocusedDate(e),this.emit("dateclick",{date:r,allDay:!e.dataset.dateTime,view:this._view,jsEvent:t})}}}_onDoubleClick(t){let e=t.target?.closest?.('[data-event-action="activate"]');if(e){let a=this._eventById(e.dataset.eventId);a&&this.emit("eventdblclick",{event:W(a),jsEvent:t});return}let i=t.target?.closest?.('[data-calendar-action="date"]');if(!i)return;let n=this._dateFromTarget(i);if(!n)return;let r=!i.dataset.dateTime,o=r?R(n,1):De(n,zt(this.options.slotDuration));this.emit("select",{start:n,end:o,allDay:r,view:this._view,jsEvent:t})}_onKeydown(t){let e=t.target?.closest?.("[data-event-action]");if(e){this._onEventKeydown(t,e);return}let i=t.target?.closest?.("[data-slot]");if(i){this._onSlotKeydown(t,i);return}let n=t.target?.closest?.("[data-date-cell]");n&&this._onDayKeydown(t,n)}_onEventKeydown(t,e){let i=this._eventById(e.dataset.eventId);if(!i)return;let n=e.dataset.eventAction==="resize";if(t.key==="Enter"&&!this._keyboardEdit&&!n){t.preventDefault(),this.emit("eventclick",{event:W(i),jsEvent:t});return}if(t.key===" "&&!this._keyboardEdit){if(n?!this._canResize(i):!this._canMove(i))return;t.preventDefault(),this._keyboardEdit={oldEvent:W(i),event:W(i),action:n?"resize":"move",control:e},e.setAttribute("aria-grabbed","true"),e.closest(".zx-calendar__event")?.setAttribute("data-state","grabbed"),this._announce(this.msg(n?"calendar.resizeStarted":"calendar.moveStarted",i.title));return}if(!this._keyboardEdit||String(this._keyboardEdit.event.id)!==String(i.id))return;if(t.key==="Escape"){t.preventDefault(),this._cancelKeyboardEdit();return}if(t.key===" "){t.preventDefault();let d=this._keyboardEdit;this._keyboardEdit=null,d.control.removeAttribute("aria-grabbed"),this._commitMutation(d.oldEvent,d.event,d.action,t);return}let r=0,o=0,a=!kt(i)&&(this._view==="day"||this._view==="week");if(t.key==="ArrowLeft")r=-1;else if(t.key==="ArrowRight")r=1;else if(t.key==="ArrowUp")a?o=-zt(this.options.slotDuration):r=-7;else if(t.key==="ArrowDown")a?o=zt(this.options.slotDuration):r=7;else return;t.preventDefault();let c=this._keyboardEdit;if(c.action==="move")c.event=Ni(c.event,{days:r,minutes:o});else{let d=Ni(c.event,{days:0,minutes:0,endDays:r,endMinutes:o});d.end>d.start&&(c.event=d)}c.control.closest(".zx-calendar__event")?.setAttribute("data-preview",this._eventTime(c.event,c.event.start)),this._announce(this.msg("calendar.editPreview",c.event.title,this._dateTimeLabel(c.event.start),this._dateTimeLabel(c.event.end)))}_onSlotKeydown(t,e){let i=Number(e.dataset.rowIndex),n=Number(e.dataset.dayIndex),r=e.closest('[role="grid"]'),o=Number(r?.getAttribute("aria-colcount"))||1,a=Number(r?.getAttribute("aria-rowcount"))||1,c=i,d=n;if(t.key==="ArrowLeft")d-=1;else if(t.key==="ArrowRight")d+=1;else if(t.key==="ArrowUp")c-=1;else if(t.key==="ArrowDown")c+=1;else if(t.key==="Home")d=0;else if(t.key==="End")d=o-1;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault();let h=this._dateFromTarget(e);h&&this.emit("dateclick",{date:h,allDay:!1,view:this._view,jsEvent:t});return}else return;t.preventDefault(),c=Math.max(0,Math.min(a-1,c)),d=Math.max(0,Math.min(o-1,d));let u=r?.querySelector(`[data-row-index="${c}"][data-day-index="${d}"]`);u&&(e.tabIndex=-1,u.tabIndex=0,this._focusedSlot=u.dataset.slot,u.focus())}_onDayKeydown(t,e){let i=pe(e.dataset.date);if(!i)return;let n=0;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-7;else if(t.key==="ArrowDown")n=7;else if(t.key==="Home")n=-((i.getDay()-this.options.weekStart+7)%7);else if(t.key==="End")n=6-(i.getDay()-this.options.weekStart+7)%7;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else return;t.preventDefault();let r=R(i,n),o=this.el.querySelector(`[data-date-cell][data-date="${X(r)}"]`);o?o.focus():this.setDate(r)}_onPointerDown(t){if(this.options.disabled||t.button!==0)return;let e=t.target?.closest?.("[data-event-action]");if(e){let r=this._eventById(e.dataset.eventId),o=e.dataset.eventAction==="resize"?"resize":"move";if(!r||(o==="move"?!this._canMove(r):!this._canResize(r)))return;t.preventDefault(),this._capturePointer(t.pointerId);let a=o==="move"?this._dragOffsetForEvent(r,t.clientX,t.clientY):null;this._pointer={type:"event",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,oldEvent:W(r),event:W(r),action:o,control:e,timeOffsetMinutes:a?.minutes??0,dayOffset:a?.days??0,moved:!1};return}let i=t.target?.closest?.("[data-slot]");if(!i||!this.options.selectable)return;let n=this._dateFromTarget(i);n&&(t.preventDefault(),this._capturePointer(t.pointerId),this._pointer={type:"selection",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,start:n,end:De(n,zt(this.options.slotDuration)),control:i,moved:!1})}_onPointerMove(t){let e=this._pointer;if(!e||e.pointerId!==t.pointerId||!e.moved&&Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<5)return;if(e.moved=!0,t.preventDefault(),e.type==="selection"){let r=this._timeAtPoint(t.clientX,t.clientY);if(!r)return;let o=zt(this.options.slotDuration);e.end=De(r,o),this._previewSelection(e.start,e.end);return}let i=this._proposalAtPoint(e.oldEvent,e.action,t.clientX,t.clientY);if(!i)return;e.event=i;let n=e.control.closest(".zx-calendar__event");if(n){if(n.dataset.state="dragging",e.action==="resize"){n.style.transform="";let r=this._timedPreviewHeight(i);r&&(n.style.blockSize=r)}else n.style.transform=`translate(${t.clientX-e.startX}px, ${t.clientY-e.startY}px)`;n.dataset.preview=this._eventTime(i,i.start)}this._announce(this.msg("calendar.editPreview",i.title,this._dateTimeLabel(i.start),this._dateTimeLabel(i.end)))}_onPointerUp(t){let e=this._pointer;if(!(!e||e.pointerId!==t.pointerId)&&(this._pointer=null,this._releasePointerCapture(e.pointerId),this._clearSelectionPreview(),!!e.moved)){if(t.preventDefault(),e.type==="selection"){this._suppressDateClick=!0;let i=e.start<e.end?e.start:De(e.end,-zt(this.options.slotDuration)),n=e.start<e.end?e.end:De(e.start,zt(this.options.slotDuration));this.emit("select",{start:new Date(i),end:new Date(n),allDay:!1,view:this._view,jsEvent:t});return}this._suppressClickId=String(e.oldEvent.id),this._commitMutation(e.oldEvent,e.event,e.action,t)}}_cancelPointer(t){if(!this._pointer||this._pointer.pointerId!==t.pointerId)return;let e=this._pointer.control;this._releasePointerCapture(this._pointer.pointerId),this._pointer=null,this._clearSelectionPreview(),e.closest?.(".zx-calendar__event")?.removeAttribute("data-state"),this._renderView({preserveFocus:!0})}_proposalAtPoint(t,e,i,n){let r=e==="resize"&&!kt(t),o=this._timeAtPoint(i,n,r?t.start:null);if(o&&!kt(t)){if(e==="move"){let p=t.end.getTime()-t.start.getTime(),_=W(t);return _.start=De(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+p),_}let f=W(t);return f.end=De(o,zt(this.options.slotDuration)),f.end>f.start?f:null}let a=this._dayAtPoint(i,n);if(!a)return null;let c=R(a,-Number(this._pointer?.dayOffset??0)),d=At(Y(t.start),c);if(e==="move")return Ni(t,{days:d,minutes:0});let u=W(t),h=R(a,1);return u.end=new Date(h.getTime()),u.end>u.start?u:null}_timeAtPoint(t,e,i=null){let n=this.refs.body.querySelector(".zx-calendar__slots");if(!n)return null;let r=n.getBoundingClientRect(),a=n.closest(".zx-calendar__time-scroller")?.getBoundingClientRect(),c=a?Math.max(r.left,a.left):r.left,d=a?Math.min(r.right,a.right):r.right,u=a?Math.max(r.top,a.top):r.top,h=a?Math.min(r.bottom,a.bottom):r.bottom;if(t<c||t>d||e<u||e>h||r.width<=0||r.height<=0)return null;let f=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,p=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,_=i?this._timeGridDayIndex(i):-1,m=_>=0?_:Math.max(0,Math.min(f-1,Math.floor((t-r.left)/r.width*f))),b=Math.max(0,Math.min(p-1,Math.floor((e-r.top)/r.height*p))),w=n.querySelector(`[data-row-index="${b}"][data-day-index="${m}"]`);return w?this._dateFromTarget(w):null}_dayAtPoint(t,e){let i=this.refs.body.querySelector(".zx-calendar__all-day-grid");if(i){let r=i.getBoundingClientRect();if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom){let o=i.querySelectorAll("[data-date]"),a=Math.max(0,Math.min(o.length-1,Math.floor((t-r.left)/r.width*o.length)));return pe(o[a]?.dataset.date)}}for(let r of this.refs.body.querySelectorAll(".zx-calendar__month-events")){let o=r.getBoundingClientRect();if(t<o.left||t>o.right||e<o.top||e>o.bottom||o.width<=0)continue;let a=pe(r.closest(".zx-calendar__month-week")?.dataset.weekStart);if(!a)continue;let c=Math.max(0,Math.min(6,Math.floor((t-o.left)/o.width*7)));return R(a,c)}for(let r of this.refs.body.querySelectorAll(".zx-calendar__agenda-day")){let o=r.getBoundingClientRect();if(!(t<o.left||t>o.right||e<o.top||e>o.bottom))return pe(r.dataset.date)}let n=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(t,e):[];for(let r of n){let o=r instanceof HTMLElement?r.closest("[data-date]"):null,a=o instanceof HTMLElement?o.dataset.date:null;if(a)return pe(a)}return null}_dragOffsetForEvent(t,e,i){if(!kt(t)){let o=this._timeAtPoint(e,i);if(o){let a=zt(this.options.slotDuration),c=Math.max(0,Math.round((t.end.getTime()-t.start.getTime())/6e4)),d=Math.max(0,c-a),u=Math.round((o.getTime()-t.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(d,u)),days:0}}}let n=this._dayAtPoint(e,i),r=n?At(Y(t.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(t){let e=X(t);return[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")].findIndex(n=>n.dataset.date===e)}_timedPreviewHeight(t){if(!this.refs.body.querySelector(".zx-calendar__time-grid")||kt(t))return null;let i=Gt(this.options.slotMinTime,0),n=Gt(this.options.slotMaxTime,1440,!0),r=zt(this.options.slotDuration),o=t.start.getHours()*60+t.start.getMinutes(),a=t.end.getHours()*60+t.end.getMinutes();return`${Math.max(r,Math.min(n,a)-Math.max(i,o))/(n-i)*100}%`}_capturePointer(t){try{this.el.setPointerCapture?.(t)}catch{}}_releasePointerCapture(t){this.el.hasPointerCapture?.(t)&&this.el.releasePointerCapture?.(t)}_previewSelection(t,e){let i=Math.min(t.getTime(),e.getTime()),n=Math.max(t.getTime(),e.getTime());for(let r of this.refs.body.querySelectorAll("[data-slot]")){let o=Number(r.dataset.dateTime);r.setAttribute("aria-selected",String(o>=i&&o<n))}}_clearSelectionPreview(){for(let t of this.refs.body.querySelectorAll("[data-slot][aria-selected]"))t.removeAttribute("aria-selected")}_cancelKeyboardEdit(){let t=this._keyboardEdit;t&&(t.control.removeAttribute("aria-grabbed"),t.control.closest(".zx-calendar__event")?.removeAttribute("data-state"),this._keyboardEdit=null,this._announce(this.msg("calendar.editCancelled")),this._renderView({preserveFocus:!0}))}_commitMutation(t,e,i,n){if(!(t.start.getTime()!==e.start.getTime()||t.end.getTime()!==e.end.getTime())){this._renderView({preserveFocus:!0});return}let o=String(t.id),a=++this._mutationSerial,c=!1;this.options.optimistic?(this._replaceNormalizedEvent(e),this._mutationVersions.set(o,a),this._renderView({preserveFocus:!0})):this._renderView({preserveFocus:!0});let d=()=>{if(c||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let f=this._eventById(o);return!f||f.start.getTime()!==e.start.getTime()||f.end.getTime()!==e.end.getTime()?!1:(c=!0,this._replaceNormalizedEvent(t),this._mutationVersions.delete(o),this._renderView({preserveFocus:!0}),this._announce(this.msg("calendar.editCancelled")),!0)},u={event:W(e),oldEvent:W(t),action:i,delta:Gv(t,e),jsEvent:n,revert:d};this.emit("eventchange",u).defaultPrevented?d():this._announce(this.msg("calendar.editCommitted",e.title))}_replaceNormalizedEvent(t){let e=String(t.id);this._events=this._events.map(i=>String(i.id)===e?W(t):i)}_canMove(t){return this.options.disabled?!1:t.editable!=null?t.editable:this.options.eventStartEditable!=null?!!this.options.eventStartEditable:!!this.options.editable}_canResize(t){return this.options.disabled?!1:t.durationEditable!=null?t.durationEditable:this.options.eventDurationEditable!=null?!!this.options.eventDurationEditable:!!this.options.editable}_eventById(t){let e=this._eventIndex(t);return e<0?null:this._events[e]}_eventIndex(t){let e=String(t);return this._events.findIndex(i=>String(i.id)===e)}_page(t){return this.setDate(Sr(this._view,this._date,t,{agendaDays:this.options.agendaDays}))}_rangeTitle(t){if(this._view==="day")return this._format(t.start,{weekday:"long",day:"numeric",month:"long",year:"numeric"});if(this._view==="month")return this._format(this._date,{month:"long",year:"numeric"});if(this._view==="year")return this._format(this._date,{year:"numeric"});let e=R(t.end,-1),i=new Intl.DateTimeFormat(this.options.locale,{day:"numeric",month:"long",year:"numeric"});return typeof i.formatRange=="function"?i.formatRange(t.start,e):t.start.getFullYear()!==e.getFullYear()?`${this._format(t.start,{day:"numeric",month:"short",year:"numeric"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:t.start.getMonth()!==e.getMonth()?`${this._format(t.start,{day:"numeric",month:"short"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:`${this._format(t.start,{day:"numeric"})}\u2013${this._format(e,{day:"numeric",month:"long",year:"numeric"})}`}_eventTime(t,e){if(t.allDay)return this.msg("calendar.allDay");if(kt(t))return Ne(t.start,e)?`${Cs(t.start,this.options.locale)} \u2192`:Ne(t.end,e)?`\u2192 ${Cs(t.end,this.options.locale)}`:this.msg("calendar.allDay");let i=gl(t.start,this.options.locale);return t.end<=t.start?i:`${i}\u2013${gl(t.end,this.options.locale)}`}_eventLabel(t){let e=t.location?`, ${t.location}`:"";return`${t.title}, ${Cs(t.start,this.options.locale)} to ${Cs(t.end,this.options.locale)}${e}`}_dateTimeLabel(t){return Cs(t,this.options.locale)}_format(t,e){return new Intl.DateTimeFormat(this.options.locale,e).format(t)}_now(){let t=typeof this.options.now=="function"?this.options.now():this.options.now,e=t??new Date;if(!(e instanceof Date)||Number.isNaN(e.getTime()))throw new TypeError("Calendar now must return a valid Date");return new Date(e.getTime())}_dateFromTarget(t){if(t.dataset.dateTime){let e=new Date(Number(t.dataset.dateTime));return Number.isNaN(e.getTime())?null:e}return pe(t.dataset.date)}_rememberFocusedDate(t){t.dataset.slot&&(this._focusedSlot=t.dataset.slot)}_focusIdentity(){let t=document.activeElement;return!(t instanceof HTMLElement)||!this.el.contains(t)?null:{eventId:t.dataset.eventId,eventAction:t.dataset.eventAction,date:t.dataset.date,slot:t.dataset.slot}}_restoreFocus(t){let e=null;t.eventId&&(e=this.el.querySelector(`[data-event-id="${zr(t.eventId)}"][data-event-action="${t.eventAction??"activate"}"]`)),!e&&t.slot&&(e=this.el.querySelector(`[data-slot="${zr(t.slot)}"]`)),!e&&t.date&&(e=this.el.querySelector(`[data-date-cell][data-date="${zr(t.date)}"]`)),e?.focus?.()}_scrollTimeGrid(){let t=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!t)return;let e=Gt(this.options.slotMinTime,0),i=Gt(this.options.slotMaxTime,1440,!0),n=Gt(this.options.scrollTime,480,!0),r=Math.max(0,Math.min(1,(n-e)/(i-e)));requestAnimationFrame(()=>{t.isConnected&&(t.scrollTop=Math.max(0,r*t.scrollHeight-t.clientHeight/4))})}_refreshNowIndicator(){if(this._destroyed||!this.options.nowIndicator||!["day","week"].includes(this._view))return;let t=this.refs.body.querySelector(".zx-calendar__now"),e=[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")];if(!t||!e.length)return;let i=this._now(),n=e.findIndex(d=>d.dataset.date===X(i)),r=Gt(this.options.slotMinTime,0),o=Gt(this.options.slotMaxTime,1440,!0),a=i.getHours()*60+i.getMinutes(),c=n>=0&&a>=r&&a<=o;t.hidden=!c,c&&(t.style.insetBlockStart=`${(a-r)/(o-r)*100}%`,t.style.setProperty("--zx-calendar-now-day",String(n)),t.querySelector(".zx-calendar__now-time").textContent=ml(a,this.options.locale))}_announce(t){this.refs.status.textContent="",requestAnimationFrame(()=>{this._destroyed||(this.refs.status.textContent=t)})}_dayCountLabel(t,e){let i=this._format(t,{dateStyle:"full"});return e===1?this._message("calendar.dayEvent","%1, %2 event",i,e):this._message("calendar.dayEvents","%1, %2 events",i,e)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function Kv(s){if(!Array.isArray(s)||s.length===0)throw new TypeError("Calendar views must be a non-empty array");let t=[...new Set(s.map(String))];for(let e of t)if(!ks.includes(e))throw new RangeError(`Unknown Calendar view: ${e}`);return t}function df(s,t,e){if(s==null)return e;if(s instanceof Date){if(Number.isNaN(s.getTime()))throw new TypeError("Calendar date must be valid");return new Date(s.getTime())}let i=typeof s=="number"?s:typeof s=="string"&&/^-?\d+(?:\.\d+)?$/.test(s.trim())?Number(s):null,n=i==null?new Date(s):new Date(i*(t==="seconds"?1e3:1));if(Number.isNaN(n.getTime()))throw new TypeError("Calendar date must be valid");return n}function zt(s){let t=Number(s);if(!Number.isInteger(t)||t<=0||t>720||1440%t!==0)throw new RangeError("Calendar slotDuration must be a positive divisor of 1440");return t}function Uv(s){let t=Number(s);if(!Number.isInteger(t)||t<1||t>20)throw new RangeError("Calendar eventLimit must be an integer from 1 through 20");return t}function Gt(s,t,e=!1){let i=Number(s??t),n=e?1440:1439;if(!Number.isInteger(i)||i<0||i>n)throw new RangeError(`Calendar minute must be from 0 through ${n}`);return i}function Yv(s,t){let e=Y(s);return e.setMinutes(t),e}function De(s,t){let e=new Date(s.getTime());return e.setMinutes(e.getMinutes()+t),e}function uf(s){return`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}`}function Ne(s,t){return uf(s)===uf(t)}function pe(s){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s??""));if(!t)return null;let e=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return X(e)===s?e:null}function Wv(s,t){return s.start-t.start||t.end-s.end||s.title.localeCompare(t.title)}function ml(s,t){let e=new Date(2026,0,1);return e.setHours(Math.floor(s/60)%24,s%60,0,0),gl(e,t)}function gl(s,t){return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit"}).format(s)}function Cs(s,t){return new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(s)}function hf(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t-i)/864e5+1)/7)}function Gv(s,t){let e=t.start.getTime()-s.start.getTime();return{milliseconds:e,days:At(Y(s.start),Y(t.start)),minutes:Math.round(e/6e4),endMilliseconds:t.end.getTime()-s.end.getTime()}}function zr(s){return globalThis.CSS?.escape?CSS.escape(s):s.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`)}var gt=class extends y{static cssName="record-view";static defaults={fields:[],data:[],recordId:"ID",sort:null,sortMode:"local",selectable:!1,selection:[],fieldOrder:[],hiddenFields:[],fieldControls:!0,emptyText:null};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("div");return this._recordViewOriginal=t?null:A(e),this._recordViewDestroyed=!1,this._initRecordView(e),e}destroy(){if(this._recordViewDestroyed)return;this._recordViewDestroyed=!0;let t=this.el,e=this._recordViewOriginal;this._removeViewFieldControls(),super.destroy(),e&&t&&S(t,e)}_initRecordView(t){this.el=t,t.classList.add("zx-record-view"),this._viewFields=Ir(this.options.fields),this._viewFieldOrder=Fi(this._viewFields,this.options.fieldOrder),this._viewHidden=yl(this._viewFields,this.options.hiddenFields,!0),this._viewData=bl(this.options.data),this._viewSort=Tr(this.options.sort,this._viewFields),this._viewSelected=new Set,this._viewSelectionAnchor=null,this._viewFieldControls=null,this._viewFieldList=null,this._viewFieldStatus=null,this._viewFieldHome=null,this._viewNativeMounted=null,this._viewFieldFocus=null,this._viewFieldSettings=Qt(this.options.fieldControls),this._viewFieldControlsTarget=P(this._viewFieldSettings.target),this._viewInitialized=!0,this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._setInitialSelection(this.options.selection)}setData(t){this._viewData=bl(t),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData();let e=this._pruneViewSelection();return this.setLoading(!1),this._refreshView("data"),e&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}addData(t){return this._viewData.push(...bl(t)),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),this.emit("datachange",{records:this.getData()}),this}updateRecord(t,e){_f(e);let i=this._viewData.findIndex(o=>Object.is(this._viewRecordId(o),t));if(i<0)return this;let n=this._viewSelected.delete(t);this._viewData[i]=e;let r=this._viewRecordId(e);return n&&this._viewSelected.add(r),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),n&&!Object.is(t,r)&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}removeRecord(t){let e=this._viewData.findIndex(n=>Object.is(this._viewRecordId(n),t));if(e<0)return this;this._viewData.splice(e,1);let i=this._viewSelected.delete(t);return Object.is(this._viewSelectionAnchor,t)&&(this._viewSelectionAnchor=null),this._refreshView("data"),i&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}getRecord(t){return this._viewData.find(e=>Object.is(this._viewRecordId(e),t))??null}getData(){return[...this._viewData]}setFields(t){let e=this.getFieldOrder(),i=this.getHiddenFields();return this._viewFields=Ir(t),this._viewFieldOrder=Fi(this._viewFields,e),this._viewHidden=yl(this._viewFields,i),this._viewSort=Tr(this._viewSort,this._viewFields),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("fields"),this._renderViewFieldControls(),this._emitViewState("fields"),this}getFields(){let t=new Map(this._viewFields.map(e=>[e.id,e]));return this._viewFieldOrder.map(e=>({...t.get(e)}))}getVisibleFields(){return this.getFields().filter(t=>!this._viewHidden.has(t.id))}getHiddenFields(){return this._viewFieldOrder.filter(t=>this._viewHidden.has(t))}getFieldOrder(){return[...this._viewFieldOrder]}getFieldControls(){return this._viewFieldControls?this._viewFieldControls:this._nativeFieldControls()}mountFieldControls(t){let e=this.getFieldControls();if(!e)return null;if(t==null){let n=this._viewFieldHome;return n&&(this._viewFieldHome=null,e===this._viewNativeMounted&&(this._viewNativeMounted=null),n.parent?n.parent.insertBefore(e,n.next?.parentNode===n.parent?n.next:null):e.remove(),n.mounted===void 0?delete e.dataset.mounted:e.dataset.mounted=n.mounted),e}let i=P(t);return i?(e.parentNode===i||(this._viewFieldHome||(this._viewFieldHome={parent:e.parentNode,next:e.nextSibling,mounted:e.dataset.mounted}),e!==this._viewFieldControls&&(this._viewNativeMounted=e),e.dataset.mounted="external",i.append(e)),e):null}setFieldVisible(t,e=!0,i={}){let n=String(t);if(!this._viewFields.some(o=>o.id===n))throw new RangeError(`Unknown view field: ${n}`);if(!e&&!this._viewHidden.has(n)&&this.getVisibleFields().length<=1)return this._renderViewFieldControls(n),this;let r=e?this._viewHidden.delete(n):!this._viewHidden.has(n);return!e&&r&&this._viewHidden.add(n),r?(this._refreshView("fields"),this._renderViewFieldControls(n),i.silent||(this.emit("fieldvisibilitychange",{visible:this.getVisibleFields().map(o=>o.id),hidden:this.getHiddenFields()}),this._emitViewState("fieldvisibility")),this):this}toggleField(t,e={}){return this.setFieldVisible(t,this._viewHidden.has(String(t)),e)}moveField(t,e,i="before",n={}){let r=wl(this._viewFieldOrder,String(t),String(e),i);return ff(r,this._viewFieldOrder)?this:this.setFieldOrder(r,n)}setFieldOrder(t,e={}){let i=Fi(this._viewFields,t);return ff(i,this._viewFieldOrder)?this:(this._viewFieldOrder=i,this._refreshView("fields"),this._renderViewFieldControls(this._viewFieldFocus??null),e.silent||(this.emit("fieldorderchange",{order:this.getFieldOrder()}),this._emitViewState("fieldorder")),this)}setSort(t,e="asc",i={}){let n=t==null?null:Tr({id:String(t),dir:e},this._viewFields);if(t!=null&&!n)throw new RangeError(`Unknown or unsortable view field: ${t}`);return Jv(n,this._viewSort)?this:(this._viewSort=n,n&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("sort"),i.silent||(this.emit("sortchange",n?{...n}:{id:null,dir:null}),this._emitViewState("sort")),this)}getSort(){return this._viewSort?{...this._viewSort}:null}getSelection(){return this._viewData.filter(t=>this._viewSelected.has(this._viewRecordId(t)))}getSelectionIds(){return this.getSelection().map(t=>this._viewRecordId(t))}setSelection(t,e={}){let i=new Set(Array.isArray(t)?t:[]),r=this._viewData.map(o=>this._viewRecordId(o)).filter(o=>i.has(o));return this.options.selectable===!1&&(r=[]),this.options.selectable==="single"&&(r=r.slice(0,1)),pf(this._viewSelected,new Set(r))?this:(this._viewSelected=new Set(r),this._viewSelectionAnchor=r.at(-1)??null,this._refreshView("selection"),e.silent||this._emitViewSelection(),this)}clearSelection(t={}){return this.setSelection([],t)}toggleSelection(t,e={}){if(this.options.selectable===!1||!this.getRecord(t))return this;let i=e.selected??!this._viewSelected.has(t);if(this.options.selectable==="single")this._viewSelected=i?new Set([t]):new Set;else if(e.range&&this._viewSelectionAnchor!=null){let n=this._viewData.map(a=>this._viewRecordId(a)),r=n.findIndex(a=>Object.is(a,this._viewSelectionAnchor)),o=n.findIndex(a=>Object.is(a,t));if(r>=0&&o>=0)for(let a of n.slice(Math.min(r,o),Math.max(r,o)+1))i?this._viewSelected.add(a):this._viewSelected.delete(a)}else i?this._viewSelected.add(t):this._viewSelected.delete(t);return this._viewSelectionAnchor=t,this._refreshView("selection"),this._emitViewSelection(),this}setLoading(t=!0){return t?this.el.setAttribute("data-loading","true"):this.el.removeAttribute("data-loading"),this.el.setAttribute("aria-busy",String(!!t)),this._refreshView("loading"),this}getViewState(){return{version:1,fieldOrder:this.getFieldOrder(),hiddenFields:this.getHiddenFields(),sort:this.getSort()}}setViewState(t,e={}){let i=xl(t,this._viewFields);return this._viewFieldOrder=i.fieldOrder,this._viewHidden=new Set(i.hiddenFields),this._viewSort=i.sort,this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("state"),this._renderViewFieldControls(),e.silent||this._emitViewState("restore"),this}_createViewFieldControls(t=null){let e=t??this._viewFieldControlsLabel(),i=l("div",{class:"zx-record-view__field-list"}),n=l("div",{class:"zx-record-view__field-status",role:"status",ariaLive:"polite",style:{position:"absolute",inlineSize:"1px",blockSize:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}}),r=l("summary",{class:"zx-btn",dataset:{size:"sm",kind:"ghost"}},g("fields"),e),o=l("details",{class:"zx-record-view__field-controls"},r,i,n);return this._viewFieldControls=o,this._viewFieldList=i,this._viewFieldStatus=n,this._renderViewFieldControls(),this.listen(o,"keydown",a=>{let c=a;c.key!=="Escape"||!o.open||(c.preventDefault(),c.stopPropagation(),o.open=!1,r.focus())}),this.listen(i,"change",a=>{let c=a.target;c?.classList.contains("zx-record-view__field-toggle")&&this.setFieldVisible(c.value,c.checked)}),this.listen(i,"click",a=>{let c=a.target?.closest?.("[data-view-field-action]");if(!c)return;let d=c.dataset.fieldId,u=c.dataset.viewFieldAction;this._moveViewFieldFromChooser(String(d),u==="up"?-1:1)}),o}_mountViewFieldControls(t,e=null){let i=this._createViewFieldControls(e),n=this._viewFieldControlsTarget;return n&&(i.dataset.mounted="external"),(n??t).append(i),i}_removeViewFieldControls(){this._viewFieldControls?.remove?.(),this._viewNativeMounted&&!this.el?.contains(this._viewNativeMounted)&&this._viewNativeMounted.remove(),this._viewNativeMounted=null,this._viewFieldHome=null,this._viewFieldControls=null,this._viewFieldList=null,this._viewFieldStatus=null,this._viewFieldControlsTarget=null}_nativeFieldControls(){if(!this._viewFieldSettings?.enabled)return null;let t=this,i=(typeof t.getTable=="function"?t.getTable():null)?.el;return!i||typeof i.querySelector!="function"?null:i.querySelector(".zx-table__column-controls")??this._viewNativeMounted}_moveViewFieldFromChooser(t,e){let i=this._viewFieldOrder,n=i.indexOf(t);if(n<0)return;let r=i[n+e],o=e<0?"up":"down";if(r===void 0){this._renderViewFieldControls({id:t,action:o});return}this._viewFieldFocus={id:t,action:o};try{this.moveField(t,r,e<0?"before":"after")}finally{this._viewFieldFocus=null}let a=this._viewFields.find(d=>d.id===t),c=this._viewFieldOrder.indexOf(t)+1;this._viewFieldStatus&&a&&(this._viewFieldStatus.textContent=this._message("recordView.fieldMoved","%1 moved to position %2 of %3",a.label,c,this._viewFieldOrder.length))}_viewFieldControlsLabel(){return(this._viewFieldSettings??Qt(this.options.fieldControls)).label??this._message("recordView.fields","Fields")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}_refreshView(t){}_viewRecordId(t){return Oe(t,this.options.recordId)}_isViewSelected(t){return this._viewSelected.has(t)}_sortViewData(){this._viewSort&&(this._viewData=vl(this._viewData,this._viewFields,this._viewSort))}_setInitialSelection(t){let e=new Set(Array.isArray(t)?t:[]),n=this._viewData.map(r=>this._viewRecordId(r)).filter(r=>e.has(r));this.options.selectable===!1&&(n=[]),this.options.selectable==="single"&&(n=n.slice(0,1)),this._viewSelected=new Set(n),this._viewSelectionAnchor=n.at(-1)??null}_pruneViewSelection(){let t=new Set(this._viewData.map(n=>this._viewRecordId(n))),e=new Set([...this._viewSelected].filter(n=>t.has(n))),i=!pf(e,this._viewSelected);return this._viewSelected=e,this._viewSelectionAnchor!=null&&!t.has(this._viewSelectionAnchor)&&(this._viewSelectionAnchor=null),i}_emitViewSelection(){this.emit("selectionchange",{records:this.getSelection(),ids:this.getSelectionIds()})}_emitViewState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}_renderViewFieldControls(t=null){if(!this._viewFieldList)return;let e=this.getFields(),i=e.filter(a=>!this._viewHidden.has(a.id));this._viewFieldControls.hidden=e.length===0;let n=e.map((a,c)=>{let d=l("input",{class:"zx-record-view__field-toggle",type:"checkbox",value:a.id,checked:!this._viewHidden.has(a.id),disabled:!this._viewHidden.has(a.id)&&i.length===1,dataset:{viewFieldAction:"toggle",fieldId:a.id}}),u=l("button",{class:"zx-record-view__field-move",type:"button",ariaLabel:this._message("recordView.moveFieldUp","Move %1 up",a.label),disabled:c===0,dataset:{viewFieldAction:"up",fieldId:a.id}},g("chevron-up",{size:11})),h=l("button",{class:"zx-record-view__field-move",type:"button",ariaLabel:this._message("recordView.moveFieldDown","Move %1 down",a.label),disabled:c===e.length-1,dataset:{viewFieldAction:"down",fieldId:a.id}},g("chevron-down",{size:11}));return l("div",{class:"zx-record-view__field-option"},l("label",{},d,l("span",{},a.label)),l("span",{class:"zx-record-view__field-order"},u,h))});if(this._viewFieldList.replaceChildren(...n),t==null)return;let o=Qv(n,typeof t=="string"?{id:t,action:"toggle"}:t);o&&(o.focus(),queueMicrotask(()=>{o.isConnected&&o.ownerDocument?.activeElement!==o&&o.focus()}))}};function Qv(s,t){let e=[];for(let o of s)for(let a of o.querySelectorAll?.("[data-view-field-action]")??[])a.dataset.fieldId===t.id&&e.push(a);let i=o=>!o.disabled,n=e.find(o=>o.dataset.viewFieldAction===t.action);if(n&&i(n))return n;let r=e.find(o=>o.dataset.viewFieldAction!=="toggle"&&i(o));return t.action!=="toggle"&&r?r:e.find(i)??null}function Qt(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)?{enabled:!0,custom:!0,label:s.label==null?null:String(s.label),target:s.target??null}:{enabled:!!s,custom:!1,label:null,target:null}}function Ir(s){if(!Array.isArray(s))throw new TypeError("Record view fields must be an array");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Record view field at index ${i} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Record view field at index ${i} requires an id`);if(t.has(n))throw new TypeError(`Duplicate record view field: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??Xv(n)),sortable:!!e.sortable,type:String(e.type??"text")}})}function Fi(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Array.isArray(t)?t.map(String):[];return[...new Set(n.filter(r=>i.has(r))),...e.filter(r=>!n.includes(r))]}function wl(s,t,e,i="before"){let n=[...s],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(i==="after"?1:0);return a=Math.max(0,Math.min(n.length,a)),n.splice(a,0,t),n}function Z(s,t,e=0){return typeof s.get=="function"?s.get(t,e):t?.[s.id]}function Ts(s,t,e=0){let i=Z(s,t,e);return typeof s.render=="function"?s.render(t,e,i):i==null?"":String(i)}function vl(s,t,e){if(!e)return[...s];let i=t.find(r=>r.id===e.id);if(!i)return[...s];let n=new WeakMap(s.map((r,o)=>[r,o]));return os(s,r=>typeof i.sortValue=="function"?i.sortValue(r,n.get(r)??0):Z(i,r,n.get(r)??0),e.dir)}function xl(s,t){let e=s&&typeof s=="object"?s:{};return{version:1,fieldOrder:Fi(t,e.fieldOrder),hiddenFields:[...yl(t,e.hiddenFields)],sort:Tr(e.sort,t)}}function Oe(s,t){return typeof t=="function"?t(s):s?.[String(t??"ID")]}function Tr(s,t){if(!s||typeof s!="object")return null;let e=String(s.id??""),i=t.find(n=>n.id===e);return!i||!i.sortable?null:{id:e,dir:s.dir==="desc"?"desc":"asc"}}function yl(s,t,e=!1){let i=new Set(s.map(r=>r.id)),n=new Set(Array.isArray(t)?t.map(String).filter(r=>i.has(r)):[]);if(e)for(let r of s)r.visible===!1&&n.add(r.id);return n.size>=s.length&&s[0]&&n.delete(s[0].id),n}function bl(s){if(!Array.isArray(s))throw new TypeError("Record view data must be an array");return s.forEach(_f),[...s]}function _f(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Record view data entries must be objects")}function Xv(s){let t=String(s).split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Jv(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function ff(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function pf(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}var Er=class extends gt{static cssName="table-view";static defaults={table:{}};constructor(t=null,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");this.el=e,this._createdTableViewRoot=t,this._tableViewOriginal=t?null:A(e),this._tableViewRestored=!1,this._tableSyncDepth=0,this._tableViewDestroyed=!1,this._tableHost=l("div",{class:"zx-table-view__table"}),this._initRecordView(e);let i=Qt(this.options.fieldControls);this._tableViewToolbar=i.custom&&!this._viewFieldControlsTarget?l("div",{class:"zx-record-view__toolbar zx-table-view__toolbar"}):null;try{e.replaceChildren(...[this._tableViewToolbar,this._tableHost].filter(Boolean));let n=this.options,r=Zv(n.table,{fields:this.getFields(),data:this.getData(),recordId:this.options.recordId,sort:this.getSort(),sortMode:this.options.sortMode,selectable:this.options.selectable,hiddenFields:this.getHiddenFields(),fieldControls:this.options.fieldControls,emptyText:this.options.emptyText});return this.table=new Ft(this._tableHost,r),this.table.setSelection(this.getSelectionIds()),this._bridgeTableEvents(),i.custom&&this._mountViewFieldControls(this._tableViewToolbar??e),e}catch(n){throw this.table?.destroy(),this._removeViewFieldControls(),t||S(e,this._tableViewOriginal),n}}getTable(){return this.table}_refreshView(t){!this.table||this._tableSyncDepth>0||this._withTableSync(()=>{if((t==="fields"||t==="state")&&(this.table.setColumns(mf(this.getFields()),{silent:!0}),this._syncTableFieldState()),(t==="data"||t==="fields"||t==="sort"||t==="state")&&this.table.setData(this.getData()),t==="sort"||t==="fields"||t==="state"){let e=this.getSort();e?this.table.setSort(e.id,e.dir,{silent:!0}):this.table.clearSort({silent:!0})}(t==="selection"||t==="data"||t==="state")&&this.table.setSelection(this.getSelectionIds()),t==="loading"&&this.table.setLoading(this.el.dataset.loading==="true")})}destroy(){this._tableViewDestroyed||(this._tableViewDestroyed=!0,this.table?.destroy(),!this._tableViewRestored&&!this._createdTableViewRoot&&(S(this.el,this._tableViewOriginal),this._tableViewRestored=!0),super.destroy())}_withTableSync(t){this._tableSyncDepth+=1;try{t()}finally{this._tableSyncDepth-=1}}_syncTableFieldState(){let t=new Set(this.getHiddenFields());for(let e of this.getFieldOrder())t.has(e)||this.table.setColumnVisible(e,!0,{silent:!0});for(let e of this.getFieldOrder())t.has(e)&&this.table.setColumnVisible(e,!1,{silent:!0})}_bridgeTableEvents(){this.listen(this._tableHost,"zx-datachange",t=>t.stopPropagation()),this.listen(this._tableHost,"zx-selectionchange",t=>t.stopPropagation()),this.listen(this.table,"rowclick",t=>{let e=t.detail;this.emit("recordclick",{...e,record:e.row})}),this.listen(this.table,"rowdblclick",t=>{let e=t.detail;this.emit("recorddblclick",{...e,record:e.row})}),this.listen(this.table,"sort",t=>this._tableSortChanged(t.detail)),this.listen(this.table,"selectionchange",t=>this._tableSelectionChanged(t.detail)),this.listen(this.table,"datachange",()=>this._tableDataChanged()),this.listen(this.table,"columnvisibilitychange",t=>this._tableVisibilityChanged(t.detail)),this.listen(this.table,"columnorderchange",t=>this._tableOrderChanged(t.detail))}_tableSortChanged(t){if(this._tableSyncDepth>0)return;let e=t.id==null?null:{id:String(t.id),dir:t.dir==="desc"?"desc":"asc"};tx(e,this._viewSort)||(this._viewSort=e,this.options.sortMode==="local"&&(this._viewData=this.table.getData()),this.emit("sortchange",e?{...e}:{id:null,dir:null}),this._emitTableViewState("sort"))}_tableSelectionChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(t.ids);Sl(e,this._viewSelected)||(this._viewSelected=e,this._viewSelectionAnchor=t.ids.at(-1)??null,this._emitTableViewSelection())}_tableDataChanged(){if(this._tableSyncDepth>0)return;this._viewData=this.table.getData();let t=new Set(this._viewData.map(n=>this._viewRecordId(n))),e=new Set([...this._viewSelected].filter(n=>t.has(n))),i=!Sl(e,this._viewSelected);this._viewSelected=e,this._viewSelectionAnchor!=null&&!t.has(this._viewSelectionAnchor)&&(this._viewSelectionAnchor=null),i&&this._emitTableViewSelection(),this.emit("datachange",{records:this.getData()})}_tableVisibilityChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(this.getFieldOrder()),i=new Set(t.hidden.filter(n=>e.has(n)));Sl(i,this._viewHidden)||(this._viewHidden=i,this.emit("fieldvisibilitychange",{visible:this.getVisibleFields().map(n=>n.id),hidden:this.getHiddenFields()}),this._emitTableViewState("fieldvisibility"))}_tableOrderChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(this.getFieldOrder()),i=[...new Set(t.order.filter(n=>e.has(n))),...this.getFieldOrder().filter(n=>!t.order.includes(n))];ex(i,this._viewFieldOrder)||(this._viewFieldOrder=i,this.emit("fieldorderchange",{order:this.getFieldOrder()}),this._emitTableViewState("fieldorder"))}_emitTableViewSelection(){this.emit("selectionchange",{records:this.getSelection(),ids:this.getSelectionIds()})}_emitTableViewState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}};function mf(s){return s.map(t=>{let e=t.view&&typeof t.view=="object"&&t.view.table&&typeof t.view.table=="object"?t.view.table:{},i={...t,...e,id:t.id,label:t.label,sortable:!!t.sortable};if(delete i.get,delete i.visible,delete i.duplicate,delete i.view,typeof t.render=="function")i.render=(n,r)=>t.render(n,r,Z(t,n,r));else if(typeof e.render!="function"&&typeof t.get=="function"){let n={...i};delete n.render,i.render=(r,o)=>Da(n,{...r,[t.id]:Z(t,r,o)},o)}return typeof t.sortValue=="function"?i.sortValue=n=>t.sortValue(n,0):typeof e.sortValue!="function"&&typeof t.get=="function"&&(i.sortValue=n=>Z(t,n,0)),i})}function Zv(s,t){let e=Qt(t.fieldControls),i=e.enabled&&!e.custom;return{...s&&typeof s=="object"?s:{},columns:mf(t.fields),data:[...t.data],rowId:t.recordId,sort:t.sort?{...t.sort}:null,sortMode:t.sortMode,selectable:t.selectable,hiddenColumns:[...t.hiddenFields],columnVisibility:i,columnReorder:i,emptyText:t.emptyText}}function tx(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function Sl(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function ex(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Nr(s,t,e={}){let i=Array.isArray(e.fields)?e.fields:[],n=Array.isArray(e.visibleFields)?e.visibleFields:i,r=e.titleField??i[0]?.id??null,o=e.subtitleField??null,a=gf(s,t,r,i),c=gf(s,t,o,i),d=sx(s,t,e.preview,e.previewAlt,i),u=nx(s,t,e.link),h=Is(s,t,e.actions),f=hx(e.controls),p=px(e.selectable),_=!!e.selected,m=x("zx-record-card-title"),b=mx(e.headingLevel),w=typeof e.message=="function"?e.message:(Wp,...Gp)=>yt(Wp,Gp),v=ux(a)||w("recordCard.untitled"),z=u?l("a",{class:"zx-record-card__primary",href:u.href,target:u.target,rel:u.rel},Mr(a)):l("span",{class:"zx-record-card__title"},Mr(a)),C=l(`h${b}`,{class:"zx-record-card__heading",id:m},z),k=ix(n,r,o),M=ox(s,t,k.eyebrowStart,k.eyebrowEnd),it=Dr(s,t,k.titlePrefix,"zx-record-card__title-prefix","title-prefix"),F=it?l("div",{class:"zx-record-card__title-row"},it,C):C,st=p==="multi"&&e.selectionTrigger!=="card"?l("label",{class:"zx-record-card__selection"},l("input",{type:"checkbox",checked:_,dataset:{recordSelection:""},ariaLabel:w("recordCard.select",v)})):null,bt=h.map(lx),$p=bt.length||f.length?l("div",{class:"zx-record-card__actions",role:"group",ariaLabel:w("recordCard.actions",v)},f,bt):null,Kp=l("header",{class:"zx-record-card__header"},st,l("div",{class:"zx-record-card__titles"},F,dx(c)?null:l("p",{class:"zx-record-card__subtitle"},Mr(c))),$p),Up=Dr(s,t,k.metadata,"zx-record-card__metadata"),Yp=l("div",{class:"zx-record-card__body"},M,Kp,Up);return l("li",{class:"zx-record-card",tabindex:0,ariaDescription:p?w(_?"recordCard.selected":"recordCard.notSelected"):void 0,ariaLabelledby:m,ariaKeyshortcuts:p&&e.selectionTrigger==="card"?"Space Enter":void 0,dataset:{recordIndex:String(t),variant:_x(e.variant),selected:String(_),selectionTrigger:p&&e.selectionTrigger==="card"?"card":"checkbox"}},d?rx(d):null,Yp)}function ix(s,t=null,e=null){let i={eyebrowStart:[],eyebrowEnd:[],titlePrefix:[],metadata:[]},n=typeof t=="string"?t:null,r=typeof e=="string"?e:null;for(let o of Array.isArray(s)?s:[]){if(!o.duplicate&&(o.id===n||o.id===r))continue;let a=ax(o);a==="eyebrow-start"?i.eyebrowStart.push(o):a==="eyebrow-end"?i.eyebrowEnd.push(o):a==="title-prefix"?i.titlePrefix.push(o):i.metadata.push(o)}return i}function sx(s,t,e,i,n=[]){if(e==null)return null;let r=typeof e=="function"?e(s,t):bf(s,t,e,n,!1);if(r==null||r==="")return null;let o=cx(s,t,i,n);if(Or(r))return{node:r,src:null,alt:o,fit:"cover",rejected:!1};let a=typeof r=="object"&&!Array.isArray(r)?r:{src:String(r)},c=typeof a.src=="string"?a.src:"",d=fx(c);return{node:null,src:d,alt:a.alt==null?o:String(a.alt),fit:gx(a.fit),rejected:d===null}}function nx(s,t,e){let i=typeof e=="function"?e(s,t):e;if(i==null)return null;let n=typeof i=="string"?{href:i}:i;if(!n||typeof n!="object"||Array.isArray(n))return null;let r=V(n.href);if(r===null)return null;let o=n.target==null?void 0:String(n.target),a=yf(n.rel,o);return{href:r,...o?{target:o}:{},...a?{rel:a}:{}}}function Is(s,t,e){let i=typeof e=="function"?e(s,t):e;return Array.isArray(i)?i.flatMap(n=>{if(!n||typeof n!="object"||Array.isArray(n))return[];let r=String(n.id??"").trim(),o=String(n.label??""),a=n.title==null?"":String(n.title);return!r||!o&&!a?[]:n.href!=null&&V(n.href)===null?[]:[{...n,id:r,label:o,...a?{title:a}:{}}]}):[]}function rx(s){let t=l("span",{class:"zx-record-card__preview-fallback",ariaHidden:"true"},g("file",{size:24}));if(s.node)return l("div",{class:"zx-record-card__preview"},s.node);let e=s.src?l("img",{class:"zx-record-card__preview-image",src:s.src,alt:s.alt,loading:"lazy",decoding:"async",dataset:{recordPreview:""},style:{objectFit:s.fit}}):null;return l("div",{class:"zx-record-card__preview",dataset:{failed:String(s.rejected)}},t,e)}function ox(s,t,e,i){let n=Dr(s,t,e,"zx-record-card__eyebrow-group","eyebrow-start"),r=Dr(s,t,i,"zx-record-card__eyebrow-group","eyebrow-end");return n||r?l("div",{class:"zx-record-card__eyebrow"},n,r):null}function Dr(s,t,e,i,n=null){return e.length===0?null:l("dl",{class:i,dataset:n?{cardSlot:n}:void 0},e.map(r=>l("div",{class:"zx-record-card__field",dataset:{fieldId:r.id,...n?{cardSlot:n}:{}}},l("dt",{class:"zx-record-card__label"},r.label),l("dd",{class:"zx-record-card__value"},Mr(Ts(r,s,t))))))}function ax(s){let t=s?.view;if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t.card;if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e.slot;return i==="eyebrow-start"||i==="eyebrow-end"||i==="title-prefix"?i:null}function lx(s){let t=String(s.label??""),e=String(s.title??(t||s.id)),i=[s.icon?g(String(s.icon),{size:14}):null,t?l("span",{class:"zx-record-card__action-label"},t):null],n=s.href==null?null:V(s.href);if(n&&!s.disabled){let r=s.target==null?void 0:String(s.target);return l("a",{class:"zx-record-card__action",href:n,target:r,rel:yf(s.rel,r),title:e,ariaLabel:t||e,dataset:{recordAction:s.id}},i)}return l("button",{class:"zx-record-card__action",type:"button",disabled:!!s.disabled,title:e,ariaLabel:t||e,dataset:{recordAction:s.id}},i)}function gf(s,t,e,i){if(e==null)return"";if(typeof e=="function")return e(s,t);let n=i.find(r=>r.id===e);return n?Ts(n,s,t):s?.[e]??""}function bf(s,t,e,i,n){let r=i.find(o=>o.id===e);return r?Z(r,s,t):Object.prototype.hasOwnProperty.call(s,e)?s[e]:n?e:null}function cx(s,t,e,i){if(e==null)return"";let n=typeof e=="function"?e(s,t):bf(s,t,e,i,!0);return n==null?"":String(n)}function Mr(s){return Or(s)?s:s==null?"":String(s)}function dx(s){return s==null||typeof s!="object"&&String(s)===""}function ux(s){return Or(s)?s.textContent?.trim()??"":s==null?"":String(s).trim()}function Or(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function hx(s){return Array.isArray(s)?s.filter(Or):[]}function fx(s){let t=V(s);if(!t)return null;try{let e=globalThis.location?.href??"https://zx.invalid/",i=new URL(t,e).protocol.toLowerCase();return["http:","https:","blob:"].includes(i)?t:null}catch{return null}}function yf(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function px(s){return s==="single"||s==="multi"?s:!1}function _x(s){return s==="raised"||s==="filled"?s:"outlined"}function mx(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function gx(s){return["contain","fill","none","scale-down"].includes(String(s))?s:"cover"}var Fr=class extends gt{static cssName="card-view";static defaults={...gt.defaults,selectionTrigger:"checkbox",titleField:null,subtitleField:null,preview:void 0,previewAlt:null,link:void 0,actions:[],groupBy:null,groupOrder:[],minCardWidth:"15rem",maxColumns:null,variant:"outlined",loadingCount:6,headingLevel:3,label:null};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._cardCreatedRoot=t,this._cardOriginal=t?null:A(e),this._cardCleaned=!1,this._cardNodesById=new Map;let i=this._cardOptions();this._cardGroupOrder=Al(i.groupOrder),this._cardMinWidth=wf(i.minCardWidth),this._cardMaxColumns=vf(i.maxColumns),this._cardVariant=xf(i.variant),this._cardLoadingCount=wx(i.loadingCount),this._cardHeadingLevel=vx(i.headingLevel);try{this._initRecordView(e),e.setAttribute("aria-label",String(i.label||this.msg("cardView.label")));let n=l("label",{ref:"sortWrap",class:"zx-card-view__sort"},l("span",{class:"zx-card-view__sort-label"},this._message("cardView.sort","Sort")),l("select",{ref:"sort",ariaLabel:this._message("cardView.sortCards","Sort cards")})),r=l("div",{class:"zx-record-view__toolbar zx-card-view__toolbar"},n);Qt(this.options.fieldControls).enabled&&this._mountViewFieldControls(r);let o=l("div",{ref:"content",class:"zx-card-view__content"});return e.replaceChildren(r,o),this.listen(this.refs.sort,"change",()=>this._changeCardSort()),this.listen(o,"click",a=>this._cardClick(a)),this.listen(o,"dblclick",a=>this._cardDoubleClick(a)),this.listen(o,"keydown",a=>this._cardKeydown(a)),this.listen(o,"error",a=>this._cardPreviewError(a),!0),this._applyCardLayout(),this._renderCardSort(),this._renderCards(),e}catch(n){throw this._removeViewFieldControls(),t||S(e,this._cardOriginal),n}}getViewState(){return{...super.getViewState(),groupOrder:[...this._cardGroupOrder],minCardWidth:this._cardMinWidth,maxColumns:this._cardMaxColumns,variant:this._cardVariant}}setViewState(t,e={}){let i=t&&typeof t=="object"?t:{};return Object.prototype.hasOwnProperty.call(i,"groupOrder")&&(this._cardGroupOrder=Al(i.groupOrder)),Object.prototype.hasOwnProperty.call(i,"minCardWidth")&&(this._cardMinWidth=wf(i.minCardWidth)),Object.prototype.hasOwnProperty.call(i,"maxColumns")&&(this._cardMaxColumns=vf(i.maxColumns)),Object.prototype.hasOwnProperty.call(i,"variant")&&(this._cardVariant=xf(i.variant)),this._applyCardLayout(),super.setViewState(i,e)}destroy(){this._cardCleaned||(this._cardCleaned=!0,super.destroy(),this._cardCreatedRoot||S(this.el,this._cardOriginal))}_refreshView(t){this.refs?.content&&(t==="selection"?this._syncCardSelection():this._renderCards(),this._renderCardSort())}_applyCardLayout(){if(!this.el)return;let t=this.el;t.style.setProperty("--zx-card-view-min-card-width",this._cardMinWidth);let e=this._cardMaxColumns?`${100/this._cardMaxColumns}%`:"0%";t.style.setProperty("--zx-card-view-column-basis",e),this._cardMaxColumns?t.dataset.maxColumns=String(this._cardMaxColumns):delete t.dataset.maxColumns}_renderCardSort(){if(!this.refs?.sort||!this.refs?.sortWrap)return;let t=this.refs.sort,e=this.getSort(),i=[l("option",{value:"",selected:e===null},this._message("cardView.unsorted","Unsorted"))];for(let n of this.getFields().filter(r=>r.sortable))i.push(l("option",{selected:e?.id===n.id&&e.dir==="asc",dataset:{sortId:n.id,sortDir:"asc"}},this._message("cardView.sortAscending","%1 (ascending)",n.label))),i.push(l("option",{selected:e?.id===n.id&&e.dir==="desc",dataset:{sortId:n.id,sortDir:"desc"}},this._message("cardView.sortDescending","%1 (descending)",n.label)));t.replaceChildren(...i),this.refs.sortWrap.hidden=i.length===1}_changeCardSort(){let e=this.refs.sort.selectedOptions[0],i=e?.dataset.sortId;i?this.setSort(i,e.dataset.sortDir==="desc"?"desc":"asc"):this.setSort(null)}_renderCards(){let t=this.refs.content,e=t.querySelector(".zx-record-card:focus"),i=e?Number(e.dataset.recordIndex):-1,n=i>=0?this._viewData[i]:null,r=n?this._viewRecordId(n):null;if(this._cardNodesById=new Map,this.el.dataset.loading==="true"){t.replaceChildren(this._createCardSkeletons());return}let o=bx(this._viewData,this._cardOptions().groupBy,this._cardGroupOrder,this._viewFields,this.msg("cardView.ungrouped"));if(this._viewData.length===0&&o.length===0){t.replaceChildren(this._createCardEmpty());return}let a=this.getFields(),c=this.getVisibleFields(),d=o.map((u,h)=>this._createCardGroup(u,a,c,h));if(t.replaceChildren(...d),r!==null){let u=this._cardNodesById.get(r);u&&queueMicrotask(()=>u.isConnected&&u.focus())}}_createCardGroup(t,e,i,n){let r=this._cardOptions(),o=t.id===null?null:`zx-card-view-group-${Sx(t.id)}-${n}`,a=l("ul",{class:"zx-card-view__list",ariaLabelledby:o??void 0});for(let c of t.records){let d=this._viewData.indexOf(c),u=this._viewRecordId(c),h=Nr(c,d,{fields:e,visibleFields:i,titleField:r.titleField,subtitleField:r.subtitleField,preview:r.preview,previewAlt:r.previewAlt,link:r.link,actions:r.actions,selectable:this.options.selectable,selectionTrigger:r.selectionTrigger,selected:this._isViewSelected(u),variant:this._cardVariant,headingLevel:this._cardHeadingLevel,message:(f,...p)=>this.msg(f,...p)});this._cardNodesById.set(u,h),a.append(h)}return t.records.length===0&&a.append(l("li",{class:"zx-card-view__group-empty"},this.msg("cardView.groupEmpty"))),t.id===null?a:l("section",{class:"zx-card-view__group",ariaLabelledby:o},l("h2",{class:"zx-card-view__group-heading",id:o},t.label),a)}_createCardSkeletons(){let t=l("ul",{class:"zx-card-view__list zx-card-view__skeletons",ariaHidden:"true"});for(let e=0;e<this._cardLoadingCount;e+=1)t.append(l("li",{class:"zx-record-card zx-card-view__skeleton",tabindex:-1},l("span",{class:"zx-card-view__skeleton-preview zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"})));return t}_createCardEmpty(){let t=this.options.emptyText,e=typeof t=="function"?t():t??this.msg("table.empty");return l("div",{class:"zx-card-view__empty",role:"status"},xx(e)?e:String(e))}_syncCardSelection(){for(let[t,e]of this._cardNodesById){let i=this._isViewSelected(t);e.dataset.selected=String(i),this.options.selectable&&e.setAttribute("aria-description",this.msg(i?"recordCard.selected":"recordCard.notSelected"));let n=e.querySelector("[data-record-selection]");n&&(n.checked=i)}}_cardClick(t){let e=t.target,i=e?.closest?.(".zx-record-card");if(!i||!this.refs.content.contains(i))return;let n=Number(i.dataset.recordIndex),r=this._viewData[n];if(!r)return;let o=this._viewRecordId(r),a=e?.closest?.("[data-record-selection]");if(a){this.toggleSelection(o,{selected:a.checked,range:t.shiftKey});return}let c=e?.closest?.("[data-record-action]");if(c){this._activateCardAction(r,o,n,c.dataset.recordAction,t);return}if(!(Sf(e,i)||Af(i))){if(this.options.selectable&&this._cardOptions().selectionTrigger==="card"){this.toggleSelection(o,{range:t.shiftKey}),i.focus({preventScroll:!0});return}this._activateCard(r,o,n,t),this.options.selectable==="single"&&this.toggleSelection(o,{selected:!0})}}_cardDoubleClick(t){let e=t.target,i=e?.closest?.(".zx-record-card");if(!i||Sf(e,i)||Af(i))return;let n=Number(i.dataset.recordIndex),r=this._viewData[n];r&&this.emit("recorddblclick",{record:r,id:this._viewRecordId(r),index:n,event:t})}_cardKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-record-card"):null;if(!e||t.target!==e)return;let i=Number(e.dataset.recordIndex),n=this._viewData[i];if(!n)return;let r=this._viewRecordId(n);t.key==="Enter"?(t.preventDefault(),this.options.selectable&&this._cardOptions().selectionTrigger==="card"?this.toggleSelection(r):this._activateCard(n,r,i,t)):t.key===" "&&this.options.selectable&&(t.preventDefault(),this.toggleSelection(r))}_activateCard(t,e,i,n){this.emit("recordclick",{record:t,id:e,index:i,event:n})}_activateCardAction(t,e,i,n,r){let o=Is(t,i,this._cardOptions().actions).find(c=>c.id===n);if(!o||o.disabled){r.preventDefault();return}typeof o.onclick=="function"&&o.onclick(t,i,r),this.emit("recordaction",{record:t,id:e,index:i,action:{...o},event:r}).defaultPrevented&&r.preventDefault()}_cardPreviewError(t){let e=t.target;if(!e?.matches?.("[data-record-preview]"))return;let i=e.closest(".zx-record-card__preview");i&&(i.dataset.failed="true"),e.hidden=!0}_cardOptions(){return this.options}};function bx(s,t,e=[],i=[],n="Ungrouped"){if(!Array.isArray(s))throw new TypeError("Card view records must be an array");if(t==null)return s.length?[{id:null,label:"",records:[...s]}]:[];let r=Al(e),o=new Map(r.map(a=>[a,[]]));for(let[a,c]of s.entries()){let d=typeof t=="function"?t(c,a):yx(c,a,t,i),u=kf(d);o.has(u)||o.set(u,[]),o.get(u).push(c)}return[...o].map(([a,c])=>({id:a,label:a||n,records:c}))}function yx(s,t,e,i){let n=i.find(r=>r.id===e);return n?Z(n,s,t):s?.[e]}function Al(s){return Array.isArray(s)?[...new Set(s.map(kf))]:[]}function kf(s){return s==null||s===""?"":String(s)}function wf(s){if(typeof s=="number")return Number.isFinite(s)&&s>0?`${s}px`:"15rem";let t=String(s??"").trim();return!t||t.length>128||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|expression)\s*\(/i.test(t)||typeof globalThis.CSS?.supports=="function"&&!globalThis.CSS.supports("width",t)?"15rem":t}function vf(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(1,Math.min(12,Math.floor(t))):null}function xf(s){return s==="raised"||s==="filled"?s:"outlined"}function wx(s){let t=Number(s??6);return Number.isFinite(t)?Math.max(1,Math.min(50,Math.floor(t))):6}function vx(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function Sf(s,t){let e=s?.closest?.('a,button,input,select,textarea,summary,[contenteditable="true"],[role="button"]');return!!(e&&e!==t&&t.contains(e))}function Af(s){let t=globalThis.getSelection?.();return!!(t&&!t.isCollapsed&&(t.anchorNode&&s.contains(t.anchorNode)||t.focusNode&&s.contains(t.focusNode)))}function xx(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Sx(s){return s.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"empty"}var zf=Object.freeze(["neutral","accent","success","warning","danger","info"]);function Lr(s,t={}){if(s==null||s==="")return null;let e=t&&typeof t=="object"?t:{},i=typeof s=="object"&&!("nodeType"in s)?s:{label:s},n=i.label==null?"":String(i.label);if(!n)return null;let r=e[n],o=zf.includes(i.tone)?i.tone:zf.includes(r)?r:"neutral";return{label:n,tone:o,icon:i.icon==null?null:String(i.icon),dot:i.dot!==!1&&i.icon==null,...i.title==null?{}:{title:String(i.title)}}}function kl(s){return ht({label:s.label,kind:s.tone,icon:s.icon??void 0,dot:s.dot,size:"sm",variant:"soft",...s.title==null?{}:{title:s.title}})}function Rr(s,t=100){if(s==null||s==="")return null;let e=typeof s=="object"&&!("nodeType"in s)?s:{value:s},i=Number(e.max??t),n=Number(e.value);if(!Number.isFinite(n)||!Number.isFinite(i)||i<=0)return null;let r=Math.max(0,Math.min(i,n)),o=e.label==null?"":String(e.label).trim();return{value:r,max:i,percent:Math.round(r/i*100),label:o||null}}function Pr(s,t,e){let i=l("div",{class:"zx-kanban-view__progress-track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(s.max),ariaValuenow:String(s.value),ariaValuetext:e,ariaLabel:t},l("div",{class:"zx-kanban-view__progress-fill"}));return i.firstElementChild.style.inlineSize=`${s.percent}%`,l("div",{class:"zx-kanban-view__progress"},l("div",{class:"zx-kanban-view__progress-head"},l("span",{class:"zx-kanban-view__progress-label"},t),l("span",{class:"zx-kanban-view__progress-value"},e)),i)}function Br(s){return s==null||s===""?[]:(Array.isArray(s)?s:[s]).map(e=>{if(e==null||e==="")return null;let i=typeof e=="object"&&!("nodeType"in e)?e:{name:e},n=String(i.name??i.label??"").trim();if(!n)return null;let r=V(i.src??i.image??null),o=i.initials==null?Te(n):String(i.initials),a=Ai.includes(i.tone)?i.tone:ue(n);return{name:n,src:r,initials:o,tone:a}}).filter(Boolean)}function zl(s,t){let e=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,i=Number.isFinite(s)?Math.max(1,Math.floor(s)):e,n=Math.min(e,i);return{shown:n,hidden:Math.max(0,e-n)}}function Vr(s,t,e,i){if(!s.length)return null;let n=zl(t,s.length),r=s.slice(0,n.shown),o=n.hidden,a=r.map(c=>l("span",{class:"zx-kanban-view__avatar",ariaHidden:"true",title:c.name||void 0,dataset:{tone:c.tone??ue(c.name)}},c.src?l("img",{class:"zx-kanban-view__avatar-image",src:c.src,alt:"",draggable:!1}):l("span",{class:"zx-kanban-view__avatar-initials"},c.initials)));return o>0&&a.push(l("span",{class:"zx-kanban-view__avatar",ariaHidden:"true",dataset:{overflow:"true"}},l("span",{class:"zx-kanban-view__avatar-initials"},i(o)))),l("span",{class:"zx-kanban-view__avatars",role:"img",ariaLabel:e},a)}function jr(s){let t=[];s.entityIcon&&t.push(l("span",{class:"zx-kanban-view__entity",ariaHidden:"true"},g(s.entityIcon,{size:12}))),s.identifier&&t.push(l("span",{class:"zx-kanban-view__identifier"},s.identifierPrefix?l("span",{class:"zx-kanban-view__hint"},`${s.identifierPrefix} `):null,s.identifier));let e=(s.flags??[]).map(i=>{if(i.indicator==null)return null;let n=typeof i.indicator=="object"&&"nodeType"in i.indicator?i.indicator:kl(i.indicator);return i.prefix?l("span",{class:"zx-kanban-view__flag"},l("span",{class:"zx-kanban-view__hint"},`${i.prefix} `),n):n}).filter(Boolean);return!t.length&&!e.length?null:l("div",{class:"zx-kanban-view__card-head"},t.length?l("span",{class:"zx-kanban-view__card-lead"},t):null,e.length?l("span",{class:"zx-kanban-view__card-flags"},e):null)}var Ax=Object.freeze(["neutral","accent","success","warning","danger","info"]);function Hr(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Kanban rules must be an array or null");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Kanban rule at index ${i} must be an object`);let n=e,r=String(n.id??"").trim();if(!r)throw new TypeError(`Kanban rule at index ${i} requires an id`);if(t.has(r))throw new TypeError(`Duplicate Kanban rule: ${r}`);if(typeof n.when!="function")throw new TypeError(`Kanban rule ${r} requires a when predicate`);return t.add(r),{id:r,when:n.when,tone:Ax.includes(n.tone)?n.tone:"accent",label:n.label==null?"":String(n.label),icon:n.icon==null?null:String(n.icon),description:n.description==null?"":String(n.description)}})}function Es(s,t,e){return!Array.isArray(s)||!s.length?[]:s.filter(i=>{try{return i.when(t,e)===!0}catch{return!1}})}function qr(s){let{records:t,column:e,swimlane:i,context:n,from:r}=s,o=Math.max(1,t.length),a=e?.wipPolicy==="block"||e?.wipPolicy==="warn"?e.wipPolicy:s.policy==="block"?"block":"warn",c=(_,m={})=>({allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:a,...m}),d=Ms(e,i,r);if(d)return c(d);for(let _ of t){if(e.accept&&e.accept(_,n)===!1)return c("accept");if(i?.accept&&i.accept(_,n)===!1)return c("lane-accept")}let u=[];e.limit!=null&&u.push({reason:"wip",limit:e.limit,count:s.columnCount+o});let h=i?kx(e.laneLimits,i.id):null;h!=null&&u.push({reason:"wip",limit:h,count:s.cellCount+o}),i?.limit!=null&&u.push({reason:"lane-wip",limit:i.limit,count:s.laneCount+o});let f=u.find(_=>_.count>_.limit),p=f??u.find(_=>_.count===_.limit)??u[0];return f&&a==="block"?c(f.reason,{limit:f.limit,count:f.count,limitExceeded:!0}):{allowed:!0,reason:null,limit:p?p.limit:null,count:p?p.count:0,limitExceeded:!!f,limitReached:!!(p&&!f&&p.count===p.limit),policy:a}}function Ms(s,t,e){return s.id!==e.column&&!Cf(s.from,e.column)?"transition":t&&t.id!==e.lane&&!Cf(t.from,e.lane)?"lane-transition":null}function $r(s){let t=s==null?"":String(s).trim().toLowerCase();return t?[...t.matchAll(/"([^"]*)"|(\S+)/g)].map(e=>(e[1]??e[2]??"").trim()).filter(Boolean):[]}function Kr(s,t){if(!t.length)return!0;let e=s.toLowerCase();return t.every(i=>e.includes(i))}function Ur(s=50){let t=Number.isFinite(Number(s))&&Number(s)>0?Math.floor(Number(s)):50,e=[],i=[];return{push(n){e.push(n),e.length>t&&(e=e.slice(-t)),i=[]},undo(n){let r=e.pop();return r?(i.push(n),i.length>t&&(i=i.slice(-t)),r):null},redo(n){let r=i.pop();return r?(e.push(n),e.length>t&&(e=e.slice(-t)),r):null},canUndo:()=>e.length>0,canRedo:()=>i.length>0,clear(){e=[],i=[]},depth:()=>({undo:e.length,redo:i.length})}}function Yr(s,t,e){if(!Array.isArray(s)||!Array.isArray(t)||!t.length)return null;let i=t.map(u=>({...u,index:s.findIndex(h=>Object.is(Oe(h,e.recordId),u.id))}));if(i.some(u=>u.index<0||!u.record||typeof u.record!="object"))return null;i.sort((u,h)=>u.index-h.index);let n=i.map(u=>({id:u.id,from:Ds(s,u.index,e)})),r=new Set(i.map(u=>u.index)),o=s.filter((u,h)=>!r.has(h)),a=o.filter((u,h)=>G(_e(u,h,e.columnBy))===e.destination.column&&(e.swimlaneBy==null||G(_e(u,h,e.swimlaneBy))===e.destination.lane)),c=Ns(e.destination.index,a.length),d=o.length;return a[c]?d=o.indexOf(a[c]):a.length&&(d=o.indexOf(a.at(-1))+1),o.splice(d,0,...i.map(u=>u.record)),{records:o,moves:n,to:{column:e.destination.column,lane:e.swimlaneBy==null?null:e.destination.lane,index:c}}}function Ds(s,t,e){let i=s[t],n=G(_e(i,t,e.columnBy)),r=e.swimlaneBy==null?null:G(_e(i,t,e.swimlaneBy)),o=s.filter((c,d)=>G(_e(c,d,e.columnBy))===n&&(e.swimlaneBy==null||G(_e(c,d,e.swimlaneBy))===r)),a=Oe(i,e.recordId);return{column:n,lane:r,index:o.findIndex(c=>Object.is(Oe(c,e.recordId),a))}}function Wr(s,t){let e=Ns(t,s.filter(Boolean).length),i=0;for(let n=0;n<s.length;n+=1)if(s[n]){if(i===e)return n;i+=1}return s.length}function _e(s,t,e){return typeof e=="function"?e(s,t):e==null?null:s?.[e]}function G(s){return s==null?"":String(s)}function Ns(s,t){return s==null||!Number.isFinite(Number(s))?t:Math.max(0,Math.min(t,Math.trunc(Number(s))))}function Cf(s,t){return s==null||!Array.isArray(s)?!0:s.length?s.some(e=>String(e)==="*"||String(e)===G(t)):!1}function kx(s,t){if(!s||typeof s!="object")return null;let e=s[t];if(e==null||e==="")return null;let i=Number(e);return Number.isFinite(i)&&i>=0?Math.floor(i):null}var Cl='a, button, input, select, textarea, summary, [contenteditable="true"]',zx=4,Cx=350,Tx=120,Gr=56,Qr=18,Ix=Object.freeze({fields:"Fields",search:"Search board",searchPlaceholder:"Search cards",clearSearch:"Clear search",searchSummary:"%count% of %total% cards match.",undo:"Undo",redo:"Redo",add:"Add card",addTo:"Add card to %target%",move:"Move %name%",moveMultiple:"Move %count% selected cards",collapseColumn:"Collapse column %label%",expandColumn:"Expand column %label%",collapseLane:"Collapse swim lane %label%",expandLane:"Expand swim lane %label%",count:"%count% records",countFiltered:"%count% of %total% records",countLimit:"%count% records, work-in-progress limit %limit%",countLimitInLane:"%count% records in this lane, %total% of work-in-progress limit %limit% in the column",empty:"No records",columnEmpty:"Drop a card here",identifier:"Record",priorityLabel:"Priority",statusLabel:"Status",progress:"Progress",progressValue:"%percent%%",assignees:"Assigned to %names%",assigneeOverflow:"+%count%",selected:"Selected",notSelected:"Not selected",noMatches:"No cards match the current search.",record:"record",grabbed:"Grabbed %name%. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.",grabbedMultiple:"Grabbed %count% cards. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.",target:"Target %target%, position %position% of %total%.",moved:"Moved %name% to %target%.%wip%",movedMultiple:"Moved %count% cards to %target%.%wip%",moveRequested:"Move requested for %name% to %target%.%wip%",moveCanceled:"Move canceled for %name%.",moveCanceledPlain:"Move canceled.",limitReached:" Work-in-progress limit %limit% reached.",limitExceeded:" Work-in-progress limit %limit% exceeded.",rejectAccept:"Move rejected: %target% does not accept %name%.",rejectTransition:"Move rejected: %target% does not accept cards from %origin%.",rejectWip:"Move rejected: %target% is at its work-in-progress limit of %limit%.",rejectDestination:"Move rejected: the destination is not available.",rejectGrouping:"Move rejected: callback grouping requires external move mode.",undone:"Move undone.",redone:"Move redone.",nothingToUndo:"Nothing to undo.",nothingToRedo:"Nothing to redo.",menuMoveTo:"Move to %target%",menuMoveToLane:"Move to lane %target%",dragPreview:"%count% cards"}),Jr=class extends gt{static cssName="kanban-view";static defaults={...gt.defaults,selectionTrigger:"checkbox",columnBy:"status",columns:null,swimlaneBy:null,swimlanes:null,titleField:null,subtitleField:null,preview:null,previewAlt:null,link:null,actions:[],moveMode:"local",dragFrom:"card",moveHandle:"keyboard",entityIcon:null,identifier:null,status:null,statusTones:{},priority:null,priorityTones:{},progress:null,progressMax:100,assignees:null,maxAvatars:3,multiMove:!0,autoScroll:!0,wipPolicy:"warn",rules:[],search:"",searchFields:null,filter:null,searchControl:!1,history:!0,historyLimit:50,historyControls:!1,columnHeight:null,allowAdd:!1,contextMenu:!1,renderCard:null,renderColumnHeader:null,renderSwimlaneHeader:null,renderColumnEmpty:null,renderDragPreview:null,labels:{},columnOrder:[],swimlaneOrder:[],collapsedColumns:[],collapsedSwimlanes:[],showCounts:!0,showEmptyColumns:!0,variant:"outlined",label:"Kanban board"};constructor(t=null,e={}){super(t,e)}render(){let t=!!this.el,e=this.el??l("div"),i=this._kanbanOptions();this._kanbanSnapshot=t?A(e):null,this._kanbanDestroyed=!1;try{if(this._initRecordView(e),this._kanbanColumns=i.columns===null?null:Xr(i.columns,"column"),this._kanbanSwimlanes=i.swimlanes===null?null:Xr(i.swimlanes,"swimlane"),this._kanbanColumnOrder=Bt(i.columnOrder),this._kanbanSwimlaneOrder=Bt(i.swimlaneOrder),this._collapsedColumns=new Set(Bt(i.collapsedColumns)),this._collapsedSwimlanes=new Set(Bt(i.collapsedSwimlanes)),this._kanbanRules=Hr(i.rules),this._kanbanSearch=i.search==null?"":String(i.search),this._kanbanFilter=typeof i.filter=="function"?i.filter:null,this._kanbanHistory=Ur(i.historyLimit),this._keyboardMove=null,this._dragIds=[],this._dragDestination=null,this._pointerStart=null,this._pointerHold=0,this._dragFrame=0,this._dragPreview=null,this._dragPointer=null,this._dragCaptured=!1,this._searchTimer=0,this._dragPoint={x:0,y:0},this._suppressClick=!1,this._announcementToken=0,this._cardMeta=new WeakMap,this._sectionMeta=new WeakMap,this._cardsById=new Map,this._visibleIds=new Set,this._cardSources={identifier:null,status:null,priority:null,progress:null,assignees:null,entityIcon:null,fieldIds:new Set,any:!1},this._fieldIndex=null,this._cardFields=null,this._kanbanMenu=null,this._searchInput=null,this._undoButton=null,this._redoButton=null,this._toolbar=l("div",{class:"zx-record-view__toolbar zx-kanban-view__toolbar"}),i.fieldControls){let n=Qt(i.fieldControls).label;this._mountViewFieldControls(this._toolbar,n??this._text("fields"))}return i.searchControl&&this._toolbar.append(this._createSearchControl()),i.historyControls&&this._toolbar.append(this._createHistoryControls()),this._board=l("div",{class:"zx-kanban-view__board",role:"region",ariaLabel:i.label}),this._live=l("div",{class:"zx-kanban-view__live",role:"status",ariaLive:"polite",ariaAtomic:"true"}),e.replaceChildren(this._toolbar,this._board,this._live),i.columnHeight&&(e.style.setProperty("--zx-kanban-column-height",String(i.columnHeight)),e.dataset.columnScroll="true"),this.listen(this._board,"click",n=>this._handleBoardClick(n)),this.listen(this._board,"dblclick",n=>this._handleBoardDoubleClick(n)),this.listen(this._board,"keydown",n=>this._handleBoardKeydown(n)),this.listen(this._board,"error",n=>this._handlePreviewError(n),{capture:!0}),this.listen(this._board,"pointerdown",n=>this._handlePointerDown(n)),this.listen(this._board,"pointermove",n=>this._handlePointerMove(n)),this.listen(this._board,"pointerup",n=>this._handlePointerUp(n)),this.listen(this._board,"pointercancel",()=>this._clearDrag()),this.listen(this._board,"dragstart",n=>n.preventDefault()),this._refreshView("init"),i.contextMenu&&this._createContextMenu(),e}catch(n){throw this._removeViewFieldControls(),this._kanbanSnapshot&&S(e,this._kanbanSnapshot),n}}getColumns(){return this._resolvedColumns().map(t=>({...t}))}setColumns(t){this._kanbanColumns=t===null?null:Xr(t,"column");let e=this._rawColumns();if(this._kanbanColumnOrder=Li(e,this._kanbanColumnOrder,this._kanbanColumns===null),this._kanbanColumns!==null){let i=new Set(e.map(n=>n.id));this._collapsedColumns=new Set([...this._collapsedColumns].filter(n=>i.has(n)))}return this._refreshView("columns"),this._emitKanbanState("columns"),this}getSwimlanes(){return this._resolvedSwimlanes().map(t=>({...t}))}setSwimlanes(t){this._kanbanSwimlanes=t===null?null:Xr(t,"swimlane");let e=this._rawSwimlanes(),i=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;if(this._kanbanSwimlaneOrder=Li(e,this._kanbanSwimlaneOrder,i),!i){let n=new Set(e.map(r=>r.id));this._collapsedSwimlanes=new Set([...this._collapsedSwimlanes].filter(r=>n.has(r)))}return this._refreshView("swimlanes"),this._emitKanbanState("swimlanes"),this}getColumnOrder(){return this._resolvedColumns().map(t=>t.id)}setColumnOrder(t,e={}){let i=this._rawColumns(),n=this.getColumnOrder(),r=Tl(i,t);return Of(r,n)?this:(this._kanbanColumnOrder=Nf(this._kanbanColumnOrder,i,r,this._kanbanColumns===null),this._refreshView("columnorder"),e.silent||this._emitKanbanState("columnorder"),this)}moveColumn(t,e,i="before"){return this.setColumnOrder(Df(this.getColumnOrder(),t,e,i))}getSwimlaneOrder(){return this._resolvedSwimlanes().map(t=>t.id)}setSwimlaneOrder(t,e={}){let i=this._rawSwimlanes(),n=this.getSwimlaneOrder(),r=Tl(i,t);if(Of(r,n))return this;let o=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=Nf(this._kanbanSwimlaneOrder,i,r,o),this._refreshView("swimlaneorder"),e.silent||this._emitKanbanState("swimlaneorder"),this}moveSwimlane(t,e,i="before"){return this.setSwimlaneOrder(Df(this.getSwimlaneOrder(),t,e,i))}getCollapsedColumns(){return this.getColumnOrder().filter(t=>this._collapsedColumns.has(t))}setColumnCollapsed(t,e=!0,i={}){let n=String(t);if(!this.getColumnOrder().includes(n))throw new RangeError(`Unknown Kanban column: ${n}`);return(e?!this._collapsedColumns.has(n):this._collapsedColumns.has(n))?(e?this._collapsedColumns.add(n):this._collapsedColumns.delete(n),this._refreshView("columncollapse"),i.silent||this._emitKanbanState("columncollapse"),this):this}toggleColumn(t){return this.setColumnCollapsed(t,!this._collapsedColumns.has(String(t)))}getCollapsedSwimlanes(){return this.getSwimlaneOrder().filter(t=>this._collapsedSwimlanes.has(t))}setSwimlaneCollapsed(t,e=!0,i={}){let n=String(t);if(!this.getSwimlaneOrder().includes(n))throw new RangeError(`Unknown Kanban lane: ${n}`);return(e?!this._collapsedSwimlanes.has(n):this._collapsedSwimlanes.has(n))?(e?this._collapsedSwimlanes.add(n):this._collapsedSwimlanes.delete(n),this._refreshView("swimlanecollapse"),i.silent||this._emitKanbanState("swimlanecollapse"),this):this}toggleSwimlane(t){return this.setSwimlaneCollapsed(t,!this._collapsedSwimlanes.has(String(t)))}moveRecord(t,e){return this.moveRecords([t],e)}moveRecords(t,e){let i=this._kanbanOptions();if(!Array.isArray(t)||!e||typeof e!="object")return this;let n=this._orderedIds(t);if(!n.length)return this;let r=n.map(F=>this.getRecord(F)),o=n.map(F=>this._recordLocation(F)),a=o[0],c=this._resolvedColumns(),d=this._resolvedSwimlanes(),u=e.column==null?a.column:String(e.column),h=i.swimlaneBy==null?null:e.lane===void 0?a.lane:G(e.lane),f=c.find(F=>F.id===u),p=i.swimlaneBy==null?null:d.find(F=>F.id===h)??null;if(!f||i.swimlaneBy!=null&&!p)return this._rejectMove("destination",{ids:n,records:r,from:a,to:null,column:null,swimlane:null}),this;let _=new Set(n),m=this._recordsIn(u,h).filter(F=>!_.has(this._viewRecordId(F.record))).length,b=Ns(e.index,m),w={column:u,lane:h,index:b};if(n.length===1&&Dx(a,w))return this;let v={id:n[0],from:{...a},to:{...w},column:{...f},swimlane:p?{...p}:null},z=this._evaluateMove(r,o,f,p,w,v,_);if(!z.allowed)return this._rejectMove(z.reason,{ids:n,records:r,from:a,to:w,column:f,swimlane:p,evaluation:z}),this;let C=[];for(let F=0;F<n.length;F+=1){let st=r[F],bt=i.moveMode==="local"?this._localMovedRecord(st,o[F],w,f,p):st;if(!bt)return this._rejectMove("grouping",{ids:n,records:r,from:a,to:w,column:f,swimlane:p}),this;C.push({id:n[F],record:bt})}let k=Yr(this._viewData,C,{recordId:i.recordId,columnBy:(F,st)=>this._readAxis(i.columnBy,F,st),swimlaneBy:i.swimlaneBy==null?null:(F,st)=>this._readAxis(i.swimlaneBy,F,st),destination:w});if(!k)return this._rejectMove("destination",{ids:n,records:r,from:a,to:w,column:f,swimlane:p}),this;let M=this._wipAnnouncement(z);return this.emit("recordmove",{record:r[0],id:n[0],records:[...r],ids:[...n],moves:k.moves.map(F=>({id:F.id,from:{...F.from}})),from:{...a},to:{...k.to},column:{...f},swimlane:p?{...p}:null,limitExceeded:z.limitExceeded},{honorDomCancellation:!0}).defaultPrevented?(this._announce(this._text("moveCanceled",{name:this._movingName(r)})),this):i.moveMode==="external"?(this._announce(this._text("moveRequested",{name:this._movingName(r),target:this._targetName(k.to),wip:M})),this):(this._commitLocalRecords(k.records),this._announce(n.length>1?this._text("movedMultiple",{count:n.length,target:this._targetName(k.to),wip:M}):this._text("moved",{name:this._recordName(C[0].record,k.to.index),target:this._targetName(k.to),wip:M})),queueMicrotask(()=>this._moveHandle(n[0])?.focus()),this)}canUndo(){return this._kanbanOptions().history!==!1&&this._kanbanHistory.canUndo()}canRedo(){return this._kanbanOptions().history!==!1&&this._kanbanHistory.canRedo()}undo(){return this._travelHistory("undo")}redo(){return this._travelHistory("redo")}clearHistory(){return this._kanbanHistory.clear(),this._syncHistoryControls(),this._emitHistory(),this}getSearch(){return this._kanbanSearch}setSearch(t,e={}){let i=t==null?"":String(t);return i===this._kanbanSearch?this:(this._kanbanSearch=i,this._searchInput&&this._searchInput.value!==i&&(this._searchInput.value=i),this._refreshView("search"),e.silent||this.emit("searchchange",{search:i}),this)}setFilter(t){if(t!=null&&typeof t!="function")throw new TypeError("Kanban filter must be a function or null");return this._kanbanFilter=t??null,this._refreshView("filter"),this}getVisibleRecords(){return this._viewData.filter(t=>this._visibleIds.has(this._viewRecordId(t)))}setData(t){return this._resetHistory(),super.setData(t)}addData(t){return this._resetHistory(),super.addData(t)}updateRecord(t,e){return this._resetHistory(),super.updateRecord(t,e)}removeRecord(t){return this._resetHistory(),super.removeRecord(t)}getViewState(){this.getColumnOrder(),this.getSwimlaneOrder();let t=this._kanbanColumns===null,e=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return{...super.getViewState(),columnOrder:t?[...this._kanbanColumnOrder]:this.getColumnOrder(),swimlaneOrder:e?[...this._kanbanSwimlaneOrder]:this.getSwimlaneOrder(),collapsedColumns:t?[...this._collapsedColumns]:this.getCollapsedColumns(),collapsedSwimlanes:e?[...this._collapsedSwimlanes]:this.getCollapsedSwimlanes()}}setViewState(t,e={}){let i=t&&typeof t=="object"?t:{};super.setViewState(i,{silent:!0});let n=this._rawColumns(),r=this._rawSwimlanes(),o=this._kanbanColumns===null,a=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;this._kanbanColumnOrder=Li(n,Array.isArray(i.columnOrder)?i.columnOrder:this._kanbanColumnOrder,o),this._kanbanSwimlaneOrder=Li(r,Array.isArray(i.swimlaneOrder)?i.swimlaneOrder:this._kanbanSwimlaneOrder,a);let c=new Set(n.map(u=>u.id)),d=new Set(r.map(u=>u.id));if(Array.isArray(i.collapsedColumns)){let u=Bt(i.collapsedColumns);this._collapsedColumns=new Set(o?u:u.filter(h=>c.has(h)))}if(Array.isArray(i.collapsedSwimlanes)){let u=Bt(i.collapsedSwimlanes);this._collapsedSwimlanes=new Set(a?u:u.filter(h=>d.has(h)))}return this._refreshView("state"),e.silent||this._emitKanbanState("restore"),this}destroy(){if(this._kanbanDestroyed)return;this._kanbanDestroyed=!0,this._clearDrag(),clearTimeout(this._pointerHold),clearTimeout(this._searchTimer),this._kanbanMenu?.destroy(),this._kanbanMenu=null;let t=this.el,e=this._kanbanSnapshot;super.destroy(),e&&t&&S(t,e)}_refreshView(t){if(!this._board)return;if(t==="selection"){this._syncCardSelection();return}if(t==="loading")return;let e=this._kanbanOptions(),i=document.activeElement,n=this._metaForTarget(document.activeElement),r=!!document.activeElement?.classList?.contains("zx-kanban-view__move-handle"),o=i instanceof Element?i.closest("[data-kanban-collapse]"):null,a=o?.closest(".zx-kanban-view__column"),c=o&&this._board.contains(o)?{axis:o.dataset.kanbanCollapse,id:String(o.dataset.kanbanId),lane:a?this._sectionMeta.get(a)?.lane??null:null}:null;this._fieldIndex=null,this._cardFields=null;let d=this._resolvedColumns(),u=this._resolvedSwimlanes();this._resolveCardSources(),this._cardMeta=new WeakMap,this._sectionMeta=new WeakMap,this._cardsById=new Map,this._resolveVisibility();let h=[];e.swimlaneBy==null?h.push(this._renderColumns(d,null,!1)):u.forEach(f=>h.push(this._renderLane(f,d))),this._viewData.length?this._visibleIds.size||h.push(this._emptyContent(this._text("noMatches"))):h.push(this._emptyContent(this._text("empty"))),this._board.replaceChildren(...h),this._keyboardMove&&(this._keyboardMove.ids=this._keyboardMove.ids.filter(f=>this.getRecord(f)),this._keyboardMove.ids.length||(this._keyboardMove=null)),this._syncKeyboardTarget(),(c||n)&&queueMicrotask(()=>{if(c){this._collapseControl(c.axis,c.id,c.lane)?.focus();return}if(!n)return;if(n.lane!=null&&this._collapsedSwimlanes.has(n.lane)){this._collapseControl("swimlane",n.lane)?.focus();return}if(this._collapsedColumns.has(n.column)){this._collapseControl("column",n.column,n.lane)?.focus();return}let f=this._cardsById.get(n.id),p=r?f?.querySelector(".zx-kanban-view__move-handle"):f;p?.isConnected&&p.focus()})}_renderLane(t,e){let i=this._kanbanOptions(),n=this._collapsedSwimlanes.has(t.id),r=x("zx-kanban-lane"),o=x("zx-kanban-lane-body"),a=this._viewData.filter((b,w)=>G(this._readAxis(i.swimlaneBy,b,w))===t.id),c=a.length,d=a.filter(b=>this._visibleIds.has(this._viewRecordId(b))).length,u=l("button",{class:"zx-kanban-view__collapse",type:"button",ariaExpanded:String(!n),ariaControls:o,ariaLabel:this._text(n?"expandLane":"collapseLane",{label:t.label}),dataset:{kanbanCollapse:"swimlane",kanbanId:t.id}},g(n?"chevron-right":"chevron-down",{size:13})),h=t.limit??null,f=If(c,h),p=this._renderHook("renderSwimlaneHeader",{swimlane:{...t},count:d,total:c,columnTotal:c,limit:h,wip:f,collapsed:n}),_=l("h2",{class:"zx-kanban-view__lane-heading",id:r},u,p??[l("span",{},t.label),i.showCounts||h!=null?this._countIndicator(d,c,h):null]),m=this._renderColumns(e,t,!0);return m.id=o,m.hidden=n,l("section",{class:"zx-kanban-view__lane",ariaLabelledby:r,dataset:{collapsed:String(n),wip:f}},_,m)}_renderColumns(t,e,i){let n=this._kanbanOptions(),r=l("div",{class:"zx-kanban-view__columns"});for(let o of t){let a=this._recordsIn(o.id,e?.id??null);!n.showEmptyColumns&&a.length===0||r.append(this._renderColumn(o,e,a,i))}return r}_renderColumn(t,e,i,n){let r=this._kanbanOptions(),o=this._collapsedColumns.has(t.id),a=x("zx-kanban-column"),c=x("zx-kanban-column-list"),u=this._viewData.filter((M,it)=>G(this._readAxis(r.columnBy,M,it))===t.id).length,h=i.filter(M=>this._visibleIds.has(this._viewRecordId(M.record))),f=e?Mx(t,e.id):null,p=f??t.limit??null,_=If(f==null?u:i.length,p),m=l("button",{class:"zx-kanban-view__collapse",type:"button",ariaExpanded:String(!o),ariaControls:c,ariaLabel:this._text(o?"expandColumn":"collapseColumn",{label:t.label}),dataset:{kanbanCollapse:"column",kanbanId:t.id}},g(o?"chevron-right":"chevron-down",{size:13})),b=this._renderHook("renderColumnHeader",{column:{...t},swimlane:e?{...e}:null,count:h.length,total:i.length,columnTotal:u,limit:p,wip:_,collapsed:o}),w=r.showCounts||p!=null?this._columnIndicator(h.length,i.length,u,p,n&&f==null):null,v=l(n?"h3":"h2",{class:"zx-kanban-view__column-heading",id:a},m,b??[l("span",{class:"zx-kanban-view__column-label"},t.label),w]),z=l("ul",{class:"zx-kanban-view__cards",id:c,ariaLabel:`${t.label}${e?`, ${e.label}`:""}`});if(h.forEach(M=>z.append(this._renderCard(M.record,M.index,t.id,e?.id??null,n))),!h.length){let M=this._renderHook("renderColumnEmpty",{column:{...t},swimlane:e?{...e}:null,count:0,total:i.length,columnTotal:u,limit:p,wip:_,collapsed:o})??this._placeholderText();M&&z.append(l("li",{class:"zx-kanban-view__column-empty",role:"presentation"},M))}z.hidden=o;let C=this._allowsAdd(t,e)?l("button",{class:"zx-kanban-view__add",type:"button",ariaLabel:this._text("addTo",{target:`${t.label}${e?`, ${e.label}`:""}`}),dataset:{kanbanAdd:t.id,kanbanLane:e?.id??""}},g("plus",{size:13}),l("span",{},this._text("add"))):null;C&&(C.hidden=o);let k=l("section",{class:"zx-kanban-view__column",ariaLabelledby:a,dataset:{column:t.id,collapsed:String(o),wip:_}},v,z,C);return this._sectionMeta.set(k,{column:t.id,lane:e?.id??null,list:z}),k}_renderCard(t,e,i,n,r){let o=this._kanbanOptions(),a=this._viewRecordId(t),c=!!this._keyboardMove?.ids.some(b=>Object.is(b,a)),d=Es(this._kanbanRules,t,{index:e,column:i,lane:n}),u=c&&this._keyboardMove?this._keyboardMove.ids.length:1,h=o.moveHandle==="always"||o.dragFrom==="handle"?"always":"keyboard",f=l("button",{class:"zx-kanban-view__move-handle",type:"button",ariaPressed:String(c),dataset:{reveal:h},ariaLabel:u>1?this._text("moveMultiple",{count:u}):this._text("move",{name:this._recordName(t,e)})},g("drag",{size:13})),p=this._resolvedCardFields(),_=Nr(t,e,{fields:p.all,visibleFields:p.metadata,titleField:o.titleField,subtitleField:o.subtitleField,preview:o.preview??void 0,previewAlt:o.previewAlt,link:o.link??void 0,actions:o.actions,selectable:o.selectable,selectionTrigger:o.selectionTrigger,selected:this._isViewSelected(a),variant:o.variant,headingLevel:r?4:3,controls:[f]});_.tabIndex=0,c&&(_.dataset.grabbed="true"),this._applyCardContent(_,{record:t,id:a,index:e,column:i,lane:n,rules:d,selected:this._isViewSelected(a)}),this._applyCardRules(_,d),this._applyCardAnatomy(_,t,e),this._applyCardDescription(_,a);let m={record:t,id:a,index:e,column:i,lane:n};return this._cardMeta.set(_,m),this._cardsById.set(a,_),_}_resolvedCardFields(){return this._cardFields||(this._cardFields={all:this.getFields(),metadata:this._cardMetadataFields()}),this._cardFields}_cardMetadataFields(){let t=this._cardSources?.fieldIds,e=this.getVisibleFields();return t?.size?e.filter(i=>!t.has(i.id)||i.duplicate===!0):e}_resolveCardSources(){let t=this._kanbanOptions(),e=this.getFields(),i=new Set,n=o=>{if(o==null)return null;if(typeof o=="function")return o;if(typeof o=="object")return()=>o;let a=String(o),c=e.find(d=>d.id===a);return i.add(a),c?(d,u)=>Z(c,d,u):d=>d?.[a]},r={identifier:n(t.identifier),status:n(t.status),priority:n(t.priority),progress:n(t.progress),assignees:n(t.assignees),entityIcon:typeof t.entityIcon=="function"?t.entityIcon:t.entityIcon==null?null:()=>t.entityIcon};this._cardSources={...r,fieldIds:i,any:Object.values(r).some(Boolean)}}_applyCardAnatomy(t,e,i){let n=this._kanbanOptions(),r=this._cardSources;if(!r?.any)return;let o=t.querySelector(".zx-record-card__body");if(!o)return;let a=r.entityIcon?.(e,i),c=r.identifier?.(e,i),d=jr({entityIcon:a==null||a===""?null:String(a),identifier:c==null?"":String(c),identifierPrefix:this._text("identifier"),flags:[{indicator:this._cardIndicator(r.status,n.statusTones,e,i),prefix:this._text("statusLabel")},{indicator:this._cardIndicator(r.priority,n.priorityTones,e,i),prefix:this._text("priorityLabel")}]});d&&o.prepend(d);let u=[],h=Rr(r.progress?.(e,i),Number(n.progressMax));h&&u.push(Pr(h,h.label??this._text("progress"),this._text("progressValue",{percent:h.percent})));let f=Br(r.assignees?.(e,i)),p=Vr(f,Number(n.maxAvatars),this._text("assignees",{names:f.map(_=>_.name).filter(Boolean).join(", ")}),_=>this._text("assigneeOverflow",{count:_}));p&&u.push(p),u.length&&o.append(l("div",{class:"zx-kanban-view__card-footer"},u))}_cardIndicator(t,e,i,n){if(!t)return null;let r=t(i,n);return r&&typeof r=="object"&&"nodeType"in r?r:Lr(r,e??{})}_applyCardContent(t,e){let i=this._renderHook("renderCard",e);if(!i)return;let n=t.querySelector(".zx-record-card__body"),r=t.querySelector(".zx-record-card__titles");!n||!r||(r.replaceChildren(i),n.querySelector(".zx-record-card__eyebrow")?.remove(),n.querySelector(".zx-record-card__metadata")?.remove(),t.removeAttribute("aria-labelledby"),t.setAttribute("aria-label",this._recordName(e.record,e.index)),t.dataset.customCard="true")}_applyCardRules(t,e){if(!e.length)return;t.dataset.rule=e.map(r=>r.id).join(" "),t.dataset.ruleTone=e[0].tone;let i=e.filter(r=>r.label);if(i.length){let r=l("p",{class:"zx-kanban-view__rules"},i.map(o=>ht({label:o.label,icon:o.icon??void 0,kind:o.tone,size:"sm",variant:"soft"})));t.querySelector(".zx-record-card__body")?.append(r)}let n=e.map(r=>r.description).filter(Boolean).join(". ");n&&(t.dataset.ruleDescription=n)}_applyCardDescription(t,e){let i=[];this.options.selectable&&i.push(this._text(this._isViewSelected(e)?"selected":"notSelected")),t.dataset.ruleDescription&&i.push(t.dataset.ruleDescription),i.length?t.setAttribute("aria-description",i.join(". ")):t.removeAttribute("aria-description")}_emptyContent(t){let i=(typeof this.options.emptyText=="function"?this.options.emptyText():this.options.emptyText)??t;return l("div",{class:"zx-kanban-view__empty",role:"status"},i&&typeof i=="object"&&"nodeType"in i?i:String(i))}_placeholderText(){return this._text("columnEmpty")}_countIndicator(t,e,i){let n=t!==e;return l("span",{class:"zx-kanban-view__count",ariaLabel:i!=null?this._text("countLimit",{count:e,limit:i}):n?this._text("countFiltered",{count:t,total:e}):this._text("count",{count:t})},i!=null?`${e} / ${i}`:n?`${t} / ${e}`:String(t))}_columnIndicator(t,e,i,n,r){let o=t!==e,a=n==null?o?this._text("countFiltered",{count:t,total:e}):this._text("count",{count:t}):r?this._text("countLimitInLane",{count:e,total:i,limit:n}):this._text("countLimit",{count:e,limit:n}),c=n==null?o?`${t} / ${e}`:String(t):r?`${e} \xB7 ${i} / ${n}`:`${e} / ${n}`;return l("span",{class:"zx-kanban-view__count",ariaLabel:a},c)}_rawColumns(){let t=this._kanbanOptions();return this._kanbanColumns===null?Tf(this._viewData,(e,i)=>this._readAxis(t.columnBy,e,i)):this._kanbanColumns.map(e=>({...e}))}_resolvedColumns(){let t=this._rawColumns();return this._kanbanColumnOrder=Li(t,this._kanbanColumnOrder,this._kanbanColumns===null),Mf(t,this._kanbanColumnOrder)}_rawSwimlanes(){let t=this._kanbanOptions();return t.swimlaneBy==null?[]:this._kanbanSwimlanes===null?Tf(this._viewData,(e,i)=>this._readAxis(t.swimlaneBy,e,i)):this._kanbanSwimlanes.map(e=>({...e}))}_resolvedSwimlanes(){let t=this._rawSwimlanes(),e=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=Li(t,this._kanbanSwimlaneOrder,e),Mf(t,this._kanbanSwimlaneOrder)}_readAxis(t,e,i){if(typeof t=="function")return t(e,i);if(t==null)return null;let n=this._axisField(String(t));return n?Z(n,e,i):e?.[t]}_axisField(t){return this._fieldIndex||(this._fieldIndex=new Map(this.getFields().map(e=>[e.id,e]))),this._fieldIndex.get(t)}_recordsIn(t,e){let i=this._kanbanOptions(),n=[];return this._viewData.forEach((r,o)=>{G(this._readAxis(i.columnBy,r,o))===t&&(i.swimlaneBy!=null&&G(this._readAxis(i.swimlaneBy,r,o))!==e||n.push({record:r,index:o}))}),n}_recordLocation(t){let e=this._kanbanOptions(),i=this._viewData.findIndex(n=>Object.is(this._viewRecordId(n),t));return i<0?null:Ds(this._viewData,i,{recordId:e.recordId,columnBy:(n,r)=>this._readAxis(e.columnBy,n,r),swimlaneBy:e.swimlaneBy==null?null:(n,r)=>this._readAxis(e.swimlaneBy,n,r)})}_resolveVisibility(){let t=$r(this._kanbanSearch),e=this._kanbanFilter,i=t.length?this._searchSources():null;this._visibleIds=new Set,this._viewData.forEach((n,r)=>{e&&e(n,r)!==!0||i&&!Kr(this._searchableText(n,r,i),t)||this._visibleIds.add(this._viewRecordId(n))})}_searchSources(){let t=this._kanbanOptions(),e=Array.isArray(t.searchFields)?t.searchFields.map(String):null,i=this.getFields();if(e)return{fields:i.filter(a=>e.includes(a.id)),readers:[]};let n=this.getVisibleFields(),r=new Set(n.map(a=>a.id)),o=[];for(let a of[t.titleField,t.subtitleField]){if(a==null)continue;if(typeof a=="function"){o.push(a);continue}if(r.has(a))continue;let c=i.find(d=>d.id===a);c?n.push(c):o.push(d=>d?.[a])}return{fields:n,readers:o}}_searchableText(t,e,i){let n=i.fields.map(r=>Ef(Z(r,t,e)));for(let r of i.readers)n.push(Ef(r(t,e)));return n.filter(Boolean).join(" ")}_absoluteIndex(t,e,i,n){let r=this._recordsIn(t,e).filter(o=>!n.has(this._viewRecordId(o.record)));return Wr(r.map(o=>this._visibleIds.has(this._viewRecordId(o.record))),i)}_localMovedRecord(t,e,i,n,r){let o=this._kanbanOptions(),a={...t};if(e.column!==i.column){if(typeof o.columnBy!="string")return null;a[o.columnBy]=Object.prototype.hasOwnProperty.call(n,"value")?n.value:n.id}if(e.lane!==i.lane){if(typeof o.swimlaneBy!="string"||!r)return null;a[o.swimlaneBy]=Object.prototype.hasOwnProperty.call(r,"value")?r.value:r.id}let c=this._viewData.indexOf(t);return G(this._readAxis(o.columnBy,a,c))!==i.column||o.swimlaneBy!=null&&G(this._readAxis(o.swimlaneBy,a,c))!==i.lane?null:a}_evaluateMove(t,e,i,n,r,o,a){let c=this._kanbanOptions();for(let p of e){let _=Ms(i,n,p);if(_)return{allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:i.wipPolicy??(c.wipPolicy==="block"?"block":"warn")}}let d=p=>!a.has(this._viewRecordId(p)),u=this._viewData.filter((p,_)=>G(this._readAxis(c.columnBy,p,_))===r.column&&d(p)).length,h=c.swimlaneBy==null?0:this._viewData.filter((p,_)=>G(this._readAxis(c.swimlaneBy,p,_))===r.lane&&d(p)).length,f=this._recordsIn(r.column,r.lane).filter(p=>d(p.record)).length;return qr({records:t,column:i,swimlane:n,context:o,from:e[0],columnCount:u,laneCount:h,cellCount:f,policy:c.wipPolicy==="block"?"block":"warn"})}_rejectMove(t,e){let i=e.to?this._targetName(e.to):"",n=this._movingName(e.records),r=t==="destination"?this._text("rejectDestination"):t==="grouping"?this._text("rejectGrouping"):t==="transition"||t==="lane-transition"?this._text("rejectTransition",{target:i,origin:e.from?this._targetName(e.from):""}):t==="wip"||t==="lane-wip"?this._text("rejectWip",{target:i,limit:e.evaluation?.limit??""}):this._text("rejectAccept",{target:i,name:n});this._announce(r),this.emit("movereject",{reason:t,ids:[...e.ids],records:[...e.records],record:e.records[0]??null,id:e.ids[0],from:e.from?{...e.from}:null,to:e.to?{...e.to}:null,column:e.column?{...e.column}:null,swimlane:e.swimlane?{...e.swimlane}:null,limit:e.evaluation?.limit??null,count:e.evaluation?.count??0,message:r})}_commitLocalRecords(t){let e=this._kanbanOptions();e.history!==!1&&(this._kanbanHistory.push({records:[...this._viewData],selection:this.getSelectionIds()}),this._syncHistoryControls()),this._viewData=t,e.sortMode==="local"&&this.getSort()?this.setSort(null):this._refreshView("move"),this.emit("datachange",{records:this.getData()}),e.history!==!1&&this._emitHistory()}_travelHistory(t){if(this._kanbanOptions().history===!1)return this;let e={records:[...this._viewData],selection:this.getSelectionIds()},i=t==="undo"?this._kanbanHistory.undo(e):this._kanbanHistory.redo(e);return i?(this._viewData=[...i.records],this._refreshView(t),this.setSelection(i.selection),this._syncHistoryControls(),this.emit("datachange",{records:this.getData()}),this._emitHistory(),this._announce(this._text(t==="undo"?"undone":"redone")),this):(this._announce(this._text(t==="undo"?"nothingToUndo":"nothingToRedo")),this)}_resetHistory(){if(!this._kanbanHistory)return;let t=this._kanbanHistory.canUndo()||this._kanbanHistory.canRedo();this._kanbanHistory.clear(),this._syncHistoryControls(),t&&this._emitHistory()}_emitHistory(){this.emit("historychange",{canUndo:this.canUndo(),canRedo:this.canRedo(),depth:this._kanbanHistory.depth()})}_syncHistoryControls(){this._undoButton&&(this._undoButton.disabled=!this.canUndo()),this._redoButton&&(this._redoButton.disabled=!this.canRedo())}_createSearchControl(){let t=l("input",{class:"zx-kanban-view__search-input",type:"search",value:this._kanbanSearch,ariaLabel:this._text("search"),placeholder:this._text("searchPlaceholder")});return this._searchInput=t,this.listen(t,"input",()=>{clearTimeout(this._searchTimer),this._searchTimer=setTimeout(()=>{this._searchTimer=0,this._kanbanDestroyed||this.setSearch(t.value)},Tx)}),this.listen(t,"keydown",e=>{e.key!=="Escape"||!t.value||(e.stopPropagation(),clearTimeout(this._searchTimer),this._searchTimer=0,this.setSearch(""))}),l("div",{class:"zx-kanban-view__search"},g("search",{size:13}),t)}_createHistoryControls(){this._undoButton=l("button",{class:"zx-btn",type:"button",disabled:!0,dataset:{kanbanHistory:"undo",size:"sm",kind:"ghost"}},this._text("undo")),this._redoButton=l("button",{class:"zx-btn",type:"button",disabled:!0,dataset:{kanbanHistory:"redo",size:"sm",kind:"ghost"}},this._text("redo"));let t=l("div",{class:"zx-kanban-view__history",role:"group"},this._undoButton,this._redoButton);return this.listen(t,"click",e=>{let i=e.target?.closest?.("[data-kanban-history]");i&&(i.dataset.kanbanHistory==="undo"?this.undo():this.redo())}),t}_createContextMenu(){this._kanbanMenu=new Di(this._board,{selector:".zx-record-card",items:t=>this._menuItems(t),onselect:({detail:t})=>this._handleMenuSelect(t)})}_menuItems(t){let e=t?this._cardMeta.get(t):null;if(!e)return[];let i=this._kanbanOptions(),n=this._movingIds(e.id),r=[];for(let a of this._resolvedColumns())a.id!==e.column&&r.push({label:this._text("menuMoveTo",{target:a.label}),value:{kind:"column",id:a.id,ids:n},disabled:!this._canMove(n,{column:a.id})});if(i.swimlaneBy!=null)for(let a of this._resolvedSwimlanes())a.id!==e.lane&&r.push({label:this._text("menuMoveToLane",{target:a.label}),value:{kind:"lane",id:a.id,ids:n},disabled:!this._canMove(n,{lane:a.id})});let o=typeof i.contextMenu=="function"?i.contextMenu({record:e.record,id:e.id,index:e.index,column:e.column,lane:e.lane,rules:Es(this._kanbanRules,e.record,e),selected:this._isViewSelected(e.id)}):Array.isArray(i.contextMenu)?i.contextMenu:[];return Array.isArray(o)&&o.length&&r.push("-",...o),r}_handleMenuSelect(t){let e=t.value;!e||typeof e!="object"||!e.kind||!Array.isArray(e.ids)||this.moveRecords(e.ids,e.kind==="lane"?{lane:e.id}:{column:e.id})}_canMove(t,e){let i=this._kanbanOptions(),n=this._orderedIds(t);if(!n.length)return!1;let r=n.map(m=>this.getRecord(m)),o=n.map(m=>this._recordLocation(m)),a=o[0],c=e.column==null?a.column:String(e.column),d=i.swimlaneBy==null?null:e.lane===void 0?a.lane:G(e.lane),u=this._resolvedColumns().find(m=>m.id===c),h=i.swimlaneBy==null?null:this._resolvedSwimlanes().find(m=>m.id===d)??null;if(!u||i.swimlaneBy!=null&&!h)return!1;let f=new Set(n),p={column:c,lane:d,index:0},_={id:n[0],from:{...a},to:{...p},column:{...u},swimlane:h?{...h}:null};return this._evaluateMove(r,o,u,h,p,_,f).allowed}_movingIds(t){let e=this._kanbanOptions();if(e.multiMove===!1||e.selectable!=="multi"||!this._isViewSelected(t))return[t];let i=this.getSelectionIds();return i.length>1?i:[t]}_orderedIds(t){let e=new Set(t);return this._viewData.map(i=>this._viewRecordId(i)).filter(i=>e.has(i))}_handleBoardClick(t){if(this._suppressClick){this._suppressClick=!1;return}let e=Ri(t),i=e?.closest("[data-kanban-collapse]");if(i){let c=i;c.dataset.kanbanCollapse==="column"?this.toggleColumn(String(c.dataset.kanbanId)):this.toggleSwimlane(String(c.dataset.kanbanId));return}let n=e?.closest("[data-kanban-add]");if(n){let c=n,d=String(c.dataset.kanbanAdd),u=c.dataset.kanbanLane||null;this.emit("recordadd",{column:this._resolvedColumns().find(h=>h.id===d)??null,swimlane:u==null?null:this._resolvedSwimlanes().find(h=>h.id===u)??null,columnId:d,laneId:u,event:t});return}let r=this._metaForTarget(e);if(!r)return;let o=e?.closest("input[data-record-selection]");if(o){this.toggleSelection(r.id,{selected:o.checked,range:t.shiftKey});return}let a=e?.closest("[data-record-action]");if(a){let c=a.dataset.recordAction,d=Is(r.record,r.index,this._kanbanOptions().actions).find(h=>h.id===c);if(!d||d.disabled){t.preventDefault();return}typeof d.onclick=="function"&&d.onclick(r.record,r.index,t),this.emit("recordaction",{record:r.record,id:r.id,index:r.index,action:{...d},event:t}).defaultPrevented&&t.preventDefault();return}if(!e?.closest(".zx-kanban-view__move-handle, .zx-record-card__selection, [data-record-select]")&&!(e?.closest(Cl)||Lf())){if(this.options.selectable&&this._kanbanOptions().selectionTrigger==="card"){this.toggleSelection(r.id,{range:t.shiftKey}),e?.closest(".zx-record-card")?.focus({preventScroll:!0});return}this.emit("recordclick",{...r,event:t}),this.options.selectable==="single"&&!this._isViewSelected(r.id)&&this.setSelection([r.id])}}_handleBoardDoubleClick(t){let e=Ri(t),i=this._metaForTarget(e);!i||e?.closest(Cl)||Lf()||this.emit("recorddblclick",{...i,event:t})}_handleBoardKeydown(t){if(this._dragIds.length&&t.key==="Escape"){t.preventDefault(),this._clearDrag(),this._announce(this._text("moveCanceledPlain"));return}let e=Ri(t);if(this._handleHistoryKeydown(t,e))return;let i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i);if(i&&n){this._handleMoveKeydown(t,i,n);return}let r=e?.closest(".zx-record-card"),o=r?this._cardMeta.get(r):null;if(!(!o||e!==r))if(t.key==="Enter"){if(t.preventDefault(),this.options.selectable&&this._kanbanOptions().selectionTrigger==="card"){this.toggleSelection(o.id);return}this.emit("recordclick",{...o,event:t}),this.options.selectable==="single"&&this.setSelection([o.id])}else t.key===" "&&this.options.selectable!==!1&&(t.preventDefault(),this.toggleSelection(o.id))}_handleHistoryKeydown(t,e){if(this._kanbanOptions().history===!1||!(t.ctrlKey||t.metaKey)||e?.closest('input, textarea, [contenteditable="true"]'))return!1;let i=t.key.toLowerCase();return i==="z"&&!t.shiftKey&&this.canUndo()?(t.preventDefault(),this.undo(),!0):(i==="y"||i==="z"&&t.shiftKey)&&this.canRedo()?(t.preventDefault(),this.redo(),!0):!1}_handleMoveKeydown(t,e,i){if(t.key===" "||t.key==="Enter"){if(t.preventDefault(),this._keyboardMove?.ids.some(a=>Object.is(a,i.id))){let a=this._keyboardMove;this._keyboardMove=null,e.setAttribute("aria-pressed","false");let c=e.closest(".zx-record-card");c&&delete c.dataset.grabbed,this._syncKeyboardTarget(),this._commitInteractionMove(a.ids,a.to)}else{let a=this._recordLocation(i.id);if(!a)return;let c=this._movingIds(i.id),d={...a,index:this._visibleIndex(i.id)};this._keyboardMove={ids:c,from:{...a},to:d},e.setAttribute("aria-pressed","true");let u=e.closest(".zx-record-card");u&&(u.dataset.grabbed="true"),this._syncKeyboardTarget(),this._announce(c.length>1?this._text("grabbedMultiple",{count:c.length}):this._text("grabbed",{name:this._recordName(i.record,i.index)}))}return}if(t.key==="Escape"&&this._keyboardMove){t.preventDefault();let a=this._keyboardMove.ids.map(d=>this.getRecord(d)).filter(Boolean);this._keyboardMove=null,e.setAttribute("aria-pressed","false");let c=e.closest(".zx-record-card");c&&delete c.dataset.grabbed,this._syncKeyboardTarget(),this._announce(a.length?this._text("moveCanceled",{name:this._movingName(a)}):this._text("moveCanceledPlain"));return}if(!this._keyboardMove||!this._keyboardMove.ids.some(a=>Object.is(a,i.id))||!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let n=this._keyboardMove,r=t.altKey||t.ctrlKey||t.metaKey;if((t.key==="ArrowLeft"||t.key==="ArrowRight")&&!r){let a=this.getColumnOrder(),c=a.indexOf(n.to.column),d=a[c+(t.key==="ArrowLeft"?-1:1)];d!=null&&(n.to.column=d)}else if((t.key==="ArrowUp"||t.key==="ArrowDown")&&r&&this._kanbanOptions().swimlaneBy!=null){let a=this.getSwimlaneOrder(),c=a.indexOf(String(n.to.lane)),d=a[c+(t.key==="ArrowUp"?-1:1)];d!=null&&(n.to.lane=d)}else(t.key==="ArrowUp"||t.key==="ArrowDown")&&(n.to.index+=t.key==="ArrowUp"?-1:1);let o=this._visibleCount(n.to.column,n.to.lane,new Set(n.ids));n.to.index=Ns(n.to.index,o),this._syncKeyboardTarget(),this._announce(this._text("target",{target:this._targetName(n.to),position:n.to.index+1,total:o+1}))}_handlePreviewError(t){let e=Ri(t)?.closest("img[data-record-preview]");if(!e)return;let i=e.closest(".zx-record-card__preview");i&&(i.dataset.failed="true"),e.hidden=!0}_handlePointerDown(t){if(this._suppressClick=!1,t.button!=null&&t.button!==0)return;let e=Ri(t),i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i??e);if(!n||!i&&(this._kanbanOptions().dragFrom!=="card"||e?.closest(Cl)||e?.closest(".zx-record-card__selection")))return;let r=this._movingIds(n.id);this._pointerStart={x:t.clientX,y:t.clientY,id:t.pointerId,ids:r,touch:t.pointerType==="touch"},this._dragPoint={x:t.clientX,y:t.clientY},clearTimeout(this._pointerHold),!(t.pointerType!=="touch"||i)&&(this._pointerHold=setTimeout(()=>this._beginDrag(this._dragPoint.x,this._dragPoint.y),Cx))}_handlePointerMove(t){let e=this._pointerStart;if(!this._dragIds.length){if(!e||t.pointerId!==e.id)return;let i=Math.hypot(t.clientX-e.x,t.clientY-e.y);if(this._dragPoint={x:t.clientX,y:t.clientY},i<=zx)return;if(e.touch&&this._pointerHold){clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null;return}if(this._beginDrag(t.clientX,t.clientY),!this._dragIds.length)return}this._dragPointer!=null&&t.pointerId!==this._dragPointer||(t.preventDefault(),this._dragPoint={x:t.clientX,y:t.clientY},this._positionDragPreview(),this._updateDropTarget(t.clientX,t.clientY))}_handlePointerUp(t){if(this._dragIds.length&&this._dragPointer!=null&&t.pointerId!==this._dragPointer||(clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null,!this._dragIds.length))return;t.preventDefault();let e=[...this._dragIds],i=this._dragDestination?{...this._dragDestination}:null;this._clearDrag(),this._suppressClick=!0,i&&this._commitInteractionMove(e,i)}_beginDrag(t,e){let i=this._pointerStart;if(!(!i||this._dragIds.length)&&(this._pointerHold=0,this._dragIds=i.ids.filter(n=>this.getRecord(n)),!!this._dragIds.length)){this._dragPoint={x:t,y:e},this._board.dataset.dragging="true";for(let n of this._dragIds){let r=this._cardsById.get(n);r&&(r.dataset.dragging="true")}this._dragPointer=i.id;try{this._board.setPointerCapture(i.id),this._dragCaptured=!0}catch{}globalThis.getSelection?.()?.removeAllRanges(),this._dragPreview=this._createDragPreview(),this.el.append(this._dragPreview),this._positionDragPreview(),this._updateDropTarget(t,e),this._kanbanOptions().autoScroll!==!1&&this._scheduleAutoScroll()}}_createDragPreview(){let t=this._dragIds.map(n=>this.getRecord(n)),i=this._renderHook("renderDragPreview",{records:t,ids:[...this._dragIds],count:this._dragIds.length})??(this._dragIds.length>1?this._text("dragPreview",{count:this._dragIds.length}):this._movingName(t));return l("div",{class:"zx-kanban-view__drag-preview",ariaHidden:"true",dataset:{count:String(this._dragIds.length)}},i)}_positionDragPreview(){this._dragPreview&&(this._dragPreview.style.transform=`translate3d(${Math.round(this._dragPoint.x)}px, ${Math.round(this._dragPoint.y)}px, 0)`)}_updateDropTarget(t,e){let n=document.elementFromPoint(t,e)?.closest(".zx-kanban-view__column"),r=n&&this._board.contains(n)?this._sectionMeta.get(n):null;if(this._clearDropMarkers(),!r||this._collapsedColumns.has(r.column)){this._dragDestination=null;return}let o=this._draggableCards(r.list),a=o.findIndex(d=>{let u=d.getBoundingClientRect();return e<u.top+u.height/2}),c=a<0?o.length:a;o[c]?o[c].dataset.drop="before":o.length?o[o.length-1].dataset.drop="after":r.list.dataset.drop="append",this._dragDestination={column:r.column,lane:r.lane,index:c}}_scheduleAutoScroll(){this._dragFrame||(this._dragFrame=requestAnimationFrame(()=>{this._dragFrame=0,this._dragIds.length&&(this._autoScroll(),this._scheduleAutoScroll())}))}_autoScroll(){let{x:t,y:e}=this._dragPoint,i=this._board.getBoundingClientRect();t<i.left+Gr?this._board.scrollLeft-=Qr:t>i.right-Gr&&(this._board.scrollLeft+=Qr);let n=document.elementFromPoint(t,e)?.closest(".zx-kanban-view__cards");if(!n||!this._board.contains(n)||n.scrollHeight<=n.clientHeight)return;let r=n.getBoundingClientRect();e<r.top+Gr?n.scrollTop-=Qr:e>r.bottom-Gr&&(n.scrollTop+=Qr)}_commitInteractionMove(t,e){let i=new Set(t);this.moveRecords(t,{column:e.column,lane:e.lane,index:this._absoluteIndex(e.column,e.lane,e.index,i)})}_clearDrag(){if(this._dragFrame&&cancelAnimationFrame(this._dragFrame),this._dragFrame=0,clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null,this._dragPreview?.remove(),this._dragPreview=null,this._dragIds=[],this._dragDestination=null,this._board){if(this._dragCaptured&&this._dragPointer!=null)try{this._board.releasePointerCapture(this._dragPointer)}catch{}this._clearDropMarkers(),delete this._board.dataset.dragging;for(let t of this._board.querySelectorAll("[data-dragging]"))delete t.dataset.dragging}this._dragPointer=null,this._dragCaptured=!1}_clearDropMarkers(){for(let t of this._board.querySelectorAll("[data-drop]"))delete t.dataset.drop}_draggableCards(t){let e=new Set(this._dragIds.length?this._dragIds:this._keyboardMove?.ids??[]);return[...t.querySelectorAll(":scope > .zx-record-card")].filter(i=>!Ff(e,this._cardMeta.get(i)?.id))}_visibleCount(t,e,i){return this._recordsIn(t,e).filter(n=>{let r=this._viewRecordId(n.record);return!Ff(i,r)&&this._visibleIds.has(r)}).length}_visibleIndex(t){let e=this._recordLocation(t);if(!e)return 0;let i=this._recordsIn(e.column,e.lane).filter(r=>this._visibleIds.has(this._viewRecordId(r.record))),n=i.findIndex(r=>Object.is(this._viewRecordId(r.record),t));return n<0?i.length:n}_syncKeyboardTarget(){for(let o of this._board.querySelectorAll("[data-keyboard-target]"))delete o.dataset.keyboardTarget;let t=this._keyboardMove;if(!t)return;let e=[...this._board.querySelectorAll(".zx-kanban-view__column")].find(o=>{let a=this._sectionMeta.get(o);return a?.column===t.to.column&&a?.lane===t.to.lane}),i=e?this._sectionMeta.get(e):null;if(!i)return;let r=this._draggableCards(i.list)[t.to.index];r?r.dataset.keyboardTarget="before":i.list.dataset.keyboardTarget="append"}_syncCardSelection(){for(let[t,e]of this._cardsById){let i=this._isViewSelected(t);e.dataset.selected=String(i),this._applyCardDescription(e,t);let n=e.querySelector("[data-record-selection]");n&&(n.checked=i)}}_metaForTarget(t){let e=Ri({target:t})?.closest(".zx-record-card");return e?this._cardMeta.get(e)??null:null}_moveHandle(t){return this._cardsById.get(t)?.querySelector(".zx-kanban-view__move-handle")??null}_collapseControl(t,e,i=null){return[...this._board.querySelectorAll("[data-kanban-collapse]")].find(n=>{let r=n;if(r.dataset.kanbanCollapse!==t||r.dataset.kanbanId!==e)return!1;if(t!=="column")return!0;let o=r.closest(".zx-kanban-view__column");return o?this._sectionMeta.get(o)?.lane===i:!1})??null}_renderHook(t,e){let i=this._kanbanOptions()[t];if(typeof i!="function")return null;let n=i(e);return n&&typeof n=="object"&&"nodeType"in n?n:null}_allowsAdd(t,e){let i=this._kanbanOptions().allowAdd;return typeof i=="function"?i(t,e)===!0:i===!0}_recordName(t,e){let i=this._kanbanOptions().titleField,n=typeof i=="function"?i(t,e):typeof i=="string"?this._readAxis(i,t,e):this._viewRecordId(t);return n&&typeof n=="object"&&"nodeType"in n?n.textContent?.trim()||this._text("record"):String(n??this._text("record"))}_movingName(t){return t.length?t.length===1?this._recordName(t[0],this._viewData.indexOf(t[0])):this._text("dragPreview",{count:t.length}):this._text("record")}_targetName(t){let e=this._resolvedColumns().find(n=>n.id===t.column),i=t.lane==null?null:this._resolvedSwimlanes().find(n=>n.id===t.lane);return`${e?.label??t.column}${i?`, ${i.label}`:""}`}_wipAnnouncement(t){return t.limit==null?"":t.limitExceeded?this._text("limitExceeded",{limit:t.limit}):t.limitReached?this._text("limitReached",{limit:t.limit}):""}_text(t,e){let i=this._kanbanOptions().labels,n=i&&typeof i=="object"&&t in i?i[t]:Ix[t];return T(n==null?String(t):String(n),e)}_announce(t){let e=++this._announcementToken;this._live.textContent="",queueMicrotask(()=>{e===this._announcementToken&&this._live?.isConnected&&(this._live.textContent=t)})}_emitKanbanState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}_kanbanOptions(){return this.options}};function Xr(s,t="column"){if(!Array.isArray(s))throw new TypeError(`Kanban ${t}s must be an array or null`);let e=new Set;return s.map((i,n)=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`Kanban ${t} at index ${n} must be an object`);let r=i,o=String(r.id??"").trim();if(!o&&r.id!=="")throw new TypeError(`Kanban ${t} at index ${n} requires an id`);if(e.has(o))throw new TypeError(`Duplicate Kanban ${t}: ${o}`);if(r.accept!=null&&typeof r.accept!="function")throw new TypeError(`Kanban ${t} ${o} accept must be a function`);if(r.from!=null&&!Array.isArray(r.from))throw new TypeError(`Kanban ${t} ${o} from must be an array or null`);e.add(o);let a={...r,id:o,label:String(r.label??Rf(r.id)),limit:Pf(r.limit),from:Array.isArray(r.from)?r.from.map(String):null,...Object.prototype.hasOwnProperty.call(r,"value")?{}:{value:r.id}};if(t==="column"){let c=Ex(r.laneLimits);c&&(a.laneLimits=c),(r.wipPolicy==="block"||r.wipPolicy==="warn")&&(a.wipPolicy=r.wipPolicy)}else delete a.laneLimits,delete a.wipPolicy;return a})}function Tf(s,t){let e=[],i=new Set;return s.forEach((n,r)=>{let o=_e(n,r,t),a=G(o);i.has(a)||(i.add(a),e.push({id:a,label:Rf(o),value:o,limit:null}))}),e}function Tl(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Bt(t).filter(r=>i.has(r));return[...new Set(n),...e.filter(r=>!n.includes(r))]}function Li(s,t,e=!1){if(!e)return Tl(s,t);let i=Bt(t),n=s.map(r=>r.id);return[...i,...n.filter(r=>!i.includes(r))]}function Rf(s){return s==null||String(s).trim()===""?"Unassigned":String(s)}function Pf(s){if(s==null||s==="")return null;let t=Number(s);if(!Number.isFinite(t)||t<0)throw new TypeError("Kanban column limit must be a non-negative number");return Math.floor(t)}function Ex(s){if(s==null)return;if(typeof s!="object"||Array.isArray(s))throw new TypeError("Kanban column laneLimits must be an object");let t={};for(let[e,i]of Object.entries(s)){let n=Pf(i);n!=null&&(t[e]=n)}return t}function Mx(s,t){let e=s.laneLimits;if(!e||typeof e!="object")return null;let i=e[t];return typeof i=="number"&&Number.isFinite(i)?i:null}function If(s,t){return t==null?"none":s>t?"exceeded":s===t?"limit":"within"}function Bt(s){return Array.isArray(s)?[...new Set(s.map(String))]:[]}function Ef(s){return s==null?"":typeof s=="object"?"nodeType"in s?String(s.textContent??""):"":String(s)}function Mf(s,t){let e=new Map(s.map(i=>[i.id,i]));return t.map(i=>e.get(i)).filter(Boolean)}function Df(s,t,e,i){let n=[...s],r=n.indexOf(String(t));if(r<0||!n.includes(String(e))||String(t)===String(e))return n;n.splice(r,1);let o=n.indexOf(String(e));return n.splice(o+(i==="after"?1:0),0,String(t)),n}function Nf(s,t,e,i){if(!i)return[...e];let n=new Set(t.map(c=>c.id)),r=[...e],o=0,a=Bt(s).flatMap(c=>n.has(c)?o<r.length?[r[o++]]:[]:[c]);return a.push(...r.slice(o)),Bt(a)}function Dx(s,t){return s.column===t.column&&s.lane===t.lane&&s.index===t.index}function Of(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Ff(s,t){for(let e of s)if(Object.is(e,t))return!0;return!1}function Ri(s){let t=s.target;return t?t instanceof Element?t:t.parentElement:null}function Lf(){let s=globalThis.getSelection?.();return!!(s&&!s.isCollapsed&&String(s).trim())}var Zr=class s extends Ft{static cssName="table";constructor(t=null,e={}){super(t,{editTrigger:"single",...e})}static BillingItems(t,e={}){let i=new s(t,Nx(e));return i.el.dataset.preset="billing-items",i}};function Nx(s={}){let{fields:t={},units:e=[],currencies:i=[],currency:n="EUR",locale:r,decimals:o=2,columnOverrides:a={},lineTotal:c=null,columns:d,oneditcommit:u,rowClass:h,...f}=s,p={...jf,...t},_=typeof c=="function"?c:b=>{let w=Vf(b?.[p.quantity]),v=Vf(b?.[p.unitPrice]);return w!==null&&v!==null?w*v:null},m=Array.isArray(d)?d.map(b=>({...b})):Il(p,{units:e,currencies:i,currency:n,locale:r,decimals:o,columnOverrides:a});return{rowId:p.id,editMode:"cell",editTrigger:"single",rowReorder:!0,columnVisibility:!0,hierarchy:{parentId:p.parent,column:p.item,expanded:!0},responsive:"sm",...f,columns:m,rowClass(b){let w=Os(b,p)?"":"zx-grid-billing__summary",v=typeof h=="function"?h(b):"";return[w,v].filter(Boolean).join(" ")},oneditcommit(b){let{row:w,changes:v}=b.detail;if(Os(w,p)){let z={...w,...v},C=_(z,v);C!=null&&Number.isFinite(Number(C))&&(v[p.total]=Number(C))}u?.(b)}}}var jf=Object.freeze({id:"id",parent:"parent",item:"item",kind:"kind",quantity:"quantity",unit:"unit",unitPrice:"unitPrice",currency:"currency",total:"total"});function Os(s,t=jf){let e=String(s?.[t.kind]??"line").toLowerCase();return!["group","subtotal","header","section"].includes(e)}function Il(s,{units:t,currencies:e,currency:i,locale:n,decimals:r,columnOverrides:o}){let a=h=>f=>Os(f,s)?h:!1,c=h=>String(h?.[s.currency]||i),d=h=>String(h?.[s.unit]??""),u={item:{id:s.item,label:"Item",width:"2fr",sortable:!0,editable:a("text")},quantity:{id:s.quantity,label:"Quantity",width:"1fr",type:"unit",locale:n,unit:d,editable:a("number"),editorProps:{min:0,step:.01}},unit:{id:s.unit,label:"Unit",width:".8fr",editable:a(Bf(t)?"select":"text"),options:t},unitPrice:{id:s.unitPrice,label:"Unit price",width:"1fr",type:"currency",locale:n,decimals:r,currency:c,editable:a("number"),editorProps:{min:0,step:.01}},currency:{id:s.currency,label:"Currency",width:".8fr",editable:a(Bf(e)?"select":"text"),options:e},total:{id:s.total,label:"Line total",width:"1fr",type:"currency",locale:n,decimals:r,currency:c}};return Object.entries(u).map(([h,f])=>({...f,...o?.[h]??{}}))}function Bf(s){return Array.isArray(s)?s.length>0:!!(s&&typeof s=="object"&&Object.keys(s).length)}function Vf(s){if(s==null||typeof s=="string"&&s.trim()==="")return null;let t=Number(s);return Number.isFinite(t)?t:null}var to=class extends y{static cssName="chart";static defaults={adapter:null,type:"bar",data:{labels:[],datasets:[]},chartOptions:{},label:"Chart",description:"",summary:"hidden",loading:!1,emptyText:"No chart data",loadingText:"Loading chart\u2026",errorText:"Unable to render chart",aspectRatio:"16 / 9"};constructor(t=null,e={}){super(t,e),this._mountOrUpdate(!1)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,c=>[c.name,c.value]),children:Array.from(t.childNodes)},this._adapter=this.options.adapter,this._type=String(this.options.type||"bar"),this._data=qf(this.options.data),this._label=Ox(this.options.label),this._chartOptions=Ct(this.options.chartOptions),this._loading=!!this.options.loading,this._error=null,this._hasError=!1,this._handle=null,this._destroyed=!1;let e=x("zx-chart-description"),i=l("canvas",{ref:"canvas",class:"zx-chart__canvas",role:"img",ariaLabel:this._label,ariaDescribedby:e}),n=l("div",{ref:"viewport",class:"zx-chart__viewport"},i);n.style.setProperty("--zx-chart-aspect-ratio",String(this.options.aspectRatio));let r=l("p",{ref:"description",class:"zx-chart__description",id:e},this.options.description),o=l("div",{ref:"status",class:"zx-chart__status",role:"status",ariaLive:"polite"}),a=l("div",{ref:"summary",class:"zx-chart__summary",dataset:{summary:this.options.summary==="visible"?"visible":"hidden"}});return t.replaceChildren(n,r,o,a),this._renderSummary(),this._syncState(),this._observer=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.resize()):null,this._observer?.observe(n),this._stopWatchingMotion=yn(t,()=>this._mountOrUpdate(!1)),t}setData(t){return this._data=qf(t),this._error=null,this._hasError=!1,this._loading=!1,this._renderSummary(),this._mountOrUpdate(!0),this}setType(t){return this._type=String(t||"bar"),this._mountOrUpdate(!0),this}update(t){return this._chartOptions=Ct(t&&typeof t=="object"?t:{}),this._mountOrUpdate(!0),this}setAdapter(t){return this._destroyHandle(),this._adapter=t,this._mountOrUpdate(!1),this}setLoading(t=!0){return this._loading=!!t,this._loading?this._destroyHandle():this._mountOrUpdate(!1),this._syncState(),this}setError(t){return this._error=t??new Error(String(this.options.errorText)),this._hasError=!0,this._loading=!1,this._destroyHandle(),this._syncState(),this.emit("error",{error:this._error}),this}clearError(){return this._error=null,this._hasError=!1,this._mountOrUpdate(!1),this}resize(){try{this._handle?.resize?.()}catch(t){this.setError(t)}return this}refreshTheme(){return this._mountOrUpdate(!0),this}getInstance(){return this._handle?.instance??null}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._observer?.disconnect(),this._stopWatchingMotion?.(),this._destroyHandle(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_mountOrUpdate(t){if(this._syncState(),this._loading||this._hasError||io(this._data)){this._destroyHandle();return}if(!this._adapter||typeof this._adapter.create!="function"){this._destroyHandle();return}let e=this._spec();try{if(this._handle)this._handle.update(e);else{if(this._handle=this._adapter.create(this.refs.canvas,e),!this._handle||typeof this._handle.destroy!="function")throw new TypeError("Chart adapter create() must return a lifecycle handle");this.emit("ready",{instance:this.getInstance()})}t&&this.emit("update",{data:this._data,type:this._type})}catch(i){this.setError(i)}}_spec(){return{type:this._type,data:Ct(this._data),options:{...Rx(this.el),...Ct(this._chartOptions)},reducedMotion:ri(this.el),onSelect:t=>this.emit("select",t)}}_destroyHandle(){if(!this._handle)return;let t=this._handle;this._handle=null;try{t.destroy()}catch{}}_syncState(){let t=io(this._data),e=this._loading?"loading":this._hasError?"error":t?"empty":"ready";this.el.dataset.state=e,this.refs.viewport.hidden=e!=="ready";let i="";e==="loading"?i=String(this.options.loadingText):e==="error"?i=Px(this._error,this.options.errorText):e==="empty"&&(i=String(this.options.emptyText)),this.refs.status.textContent=i,this.refs.status.hidden=!i}_renderSummary(){this.refs.summary.replaceChildren(Ml(this._data,this._label))}};function Ox(s){return String(s??"").trim()||"Chart"}var eo=class{constructor(t,e={}){let i=typeof t=="function"?t:t?.Chart;if(typeof i!="function")throw new TypeError("ChartJsAdapter requires an injected Chart.js constructor");this.engine=i,this.defaults=Ct(e)}create(t,e){let i=this.engine,n=null,r="",o=!1,a=c=>{let d=null,u=Hf(c,this.defaults,()=>d);d=new i(t,u),n=d,r=c.type};return a(e),{get instance(){return n},update:c=>{if(o)return;if(c.type!==r){let u=n;n=null,u?.destroy?.(),a(c);return}let d=Hf(c,this.defaults,()=>n);n.data=d.data,n.options=d.options,n.update()},resize:()=>{o||n?.resize?.()},destroy:()=>{o||(o=!0,n?.destroy?.(),n=null)}}}};function Hf(s,t,e){let i=Ct(s.options),n={responsive:!0,maintainAspectRatio:!1,...Ct(t),...i};s.reducedMotion&&(n.animation=!1);let r=n.onClick;return n.onClick=(o,a,c)=>{typeof r=="function"&&r(o,a,c);let d=e()??c,h=(Array.isArray(a)&&a.length?a:d?.getElementsAtEventForMode?.(o,"nearest",{intersect:!0},!0)??[])[0];if(!h)return;let f=s.data.datasets?.[h.datasetIndex]??null;s.onSelect({datasetIndex:h.datasetIndex,index:h.index,dataset:f,label:s.data.labels?.[h.index],value:f?.data?.[h.index],nativeEvent:o?.native??o??null})},{type:s.type,data:Ct(s.data),options:n}}function Ct(s){return El(s,new WeakMap)}function El(s,t){if(Array.isArray(s)){if(t.has(s))return t.get(s);let e=[];return t.set(s,e),e.push(...s.map(i=>El(i,t))),e}if(s&&typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype){if(t.has(s))return t.get(s);let e={};t.set(s,e);for(let[i,n]of Object.entries(s))e[i]=El(n,t);return e}return s}function qf(s){return!s||typeof s!="object"?{labels:[],datasets:[]}:Ct({...s,labels:Array.isArray(s.labels)?s.labels:[],datasets:Array.isArray(s.datasets)?s.datasets:[]})}function io(s){return!Array.isArray(s?.datasets)||!s.datasets.some(t=>Array.isArray(t?.data)&&t.data.length>0)}function Ml(s,t="Chart data"){let e=Fx(s);return l("table",{class:"zx-chart__table"},l("caption",{},t),l("thead",{},l("tr",{},l("th",{scope:"col"},"Label"),e.headers.map(n=>l("th",{scope:"col"},n)))),l("tbody",{},e.rows.map(n=>l("tr",{},l("th",{scope:"row"},n.label),n.values.map(r=>l("td",{},r))))))}function Fx(s){let t=Array.isArray(s?.datasets)?s.datasets:[],e=Array.isArray(s?.labels)?s.labels:[],i=Math.max(e.length,...t.map(n=>Array.isArray(n.data)?n.data.length:0),0);return{headers:t.map((n,r)=>String(n.label??`Series ${r+1}`)),rows:Array.from({length:i},(n,r)=>({label:String(e[r]??r+1),values:t.map(o=>Lx(o.data?.[r]))}))}}function Lx(s){if(s==null)return"";if(typeof s=="object"){if("y"in s)return String(s.y??"");if("r"in s)return String(s.r??"");try{return JSON.stringify(s)}catch{return String(s)}}return String(s)}function Rx(s){if(typeof getComputedStyle!="function")return{};let t=getComputedStyle(s),e=t.getPropertyValue("--zx-color-text").trim(),i=t.getPropertyValue("--zx-color-border").trim();return{color:e||void 0,borderColor:i||void 0}}function Px(s,t){let e=s&&typeof s=="object"&&"message"in s?String(s.message):"";return e.trim()?e:String(t)}function so({valueKey:s="ID",labelKey:t="name",childrenKey:e="children"}={}){return{value:i=>typeof s=="function"?s(i):i?.[s],label:i=>String((typeof t=="function"?t(i):i?.[t])??""),children:i=>{let n=i?.[e];return Array.isArray(n)?n:null}}}function Q(s,t){if(s?.hasChildren===!0)return!0;let e=t.children(s);return Array.isArray(e)&&e.length>0}function Pi(s,t,e,{level:i=1,parent:n=null}={}){s.forEach((r,o)=>{e(r,{level:i,parent:n,index:o,siblings:s});let a=t.children(r);a&&Pi(a,t,e,{level:i+1,parent:r})})}function $f(s,t,e){let i=null;return Pi(s,e,n=>{i===null&&Object.is(e.value(n),t)&&(i=n)}),i}function Fs(s,t,e){for(let i of s){if(Object.is(e.value(i),t))return[i];let n=e.children(i);if(!n)continue;let r=Fs(n,t,e);if(r.length>0)return[i,...r]}return[]}function Kf(s,t){let e=[],i=t.children(s);return i&&Pi(i,t,n=>e.push(n)),e}function Uf(s,t,e){let i=[],n=(r,o,a)=>{r.forEach((c,d)=>{let u=t.value(c);if(i.push({node:c,id:u,level:o,parent:a,posinset:d+1,setsize:r.length}),!e.has(u))return;let h=t.children(c);h&&h.length>0&&n(h,o+1,c)})};return n(s,1,null),i}function Dl(s,t,e,i){let n=[];for(let r of s){let o=t.children(r)??[],a=Dl(o,t,e,i);(e(r)||a.length>0)&&n.push(a.length>0||o.length>0?{...r,[i]:a}:r)}return n}var no=class extends y{static cssName="tree";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",expanded:[],selection:"single",selected:[],checkboxes:!1,checked:[],icons:!0,renderLabel:null,load:null,filter:"",label:"Tree",emptyText:"Nothing to show",height:null};render(){this._items=[],this._rows=[],this._expanded=new Set,this._selected=new Set,this._checked=new Set,this._loading=new Map,this._focusId=null,this._filter="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._readers=so(this.options),this._childrenKey=this.options.childrenKey??"children",t.setAttribute("role","tree"),t.setAttribute("aria-label",String(this.options.label??"Tree")),t.tabIndex=0,this.options.selection==="multi"&&t.setAttribute("aria-multiselectable","true"),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height),t.style.overflowY="auto"),this._items=Nl(this.options.items);for(let i of Ls(this.options.expanded))this._expanded.add(i);for(let i of Ls(this.options.selected))this._selected.add(i);let[e]=this._selected;if(e!==void 0){this._focusId=e;for(let i of this.getPath(e).slice(0,-1))this._expanded.add(this._readers.value(i))}for(let i of Ls(this.options.checked))this._applyCheck(i,!0,{silent:!0});return this._handleTypeahead=ut(()=>this._rotatedRows().map(i=>this._readers.label(i.node)),(i,n)=>this._focusNodeId(this._rotatedRows()[n]?.id)),this.listen(t,"keydown",i=>this._onKeydown(i)),this.listen(t,"click",i=>this._onClick(i)),this.listen(t,"dblclick",i=>this._onDoubleClick(i)),this.listen(t,"focus",()=>{this._rows.length>0&&!this._rowElement(this._focusId)&&this._focusRow(0)}),String(this.options.filter??"")!==""?this.setFilter(this.options.filter):this._renderRows(),t}setItems(t){return this._items=Nl(t),this._renderRows(),this}getItems(){return this._items}getNode(t){return $f(this._items,t,this._readers)}getPath(t){return Fs(this._items,t,this._readers)}setFilter(t){if(this._filter=String(t??""),this._filter!=="")for(let e of this._visibleItems())Pi([e],this._readers,i=>this._expanded.add(this._readers.value(i)));return this._renderRows(),this}async expand(t){let e=this.getNode(t);if(!e||!Q(e,this._readers))return this;let i=this._readers.children(e),n=!!this.options.load&&(!i||i.length===0);return this._expanded.has(t)&&!n?this:await this._ensureChildren(e,t)?(this._expanded.add(t),this._renderRows(),this.emit("expand",{node:e,id:t}),this):this}collapse(t){if(!this._expanded.delete(t))return this;let e=this.getNode(t);return this._renderRows(),e&&this.emit("collapse",{node:e,id:t}),this}async toggle(t){return this._expanded.has(t)?this.collapse(t):this.expand(t)}expandAll(){return Pi(this._items,this._readers,t=>{Q(t,this._readers)&&this._expanded.add(this._readers.value(t))}),this._renderRows(),this}collapseAll(){return this._expanded.clear(),this._renderRows(),this}reveal(t){let e=this.getPath(t);for(let i of e.slice(0,-1))this._expanded.add(this._readers.value(i));return this._renderRows(),this}select(t,{silent:e=!1,additive:i=!1}={}){if(this.options.selection===!1)return this;let n=this.getNode(t);return n?(this.options.selection==="multi"&&i?this._selected.has(t)?this._selected.delete(t):this._selected.add(t):(this._selected.clear(),this._selected.add(t)),this._syncRows(),e||this.emit("select",{node:n,id:t,ids:this.getSelection()}),this):this}getSelection(){return[...this._selected]}setSelection(t,{silent:e=!0}={}){let i=Ls(t);if(this._selected=new Set(this.options.selection==="multi"?i:i.slice(0,1)),this._syncRows(),!e){let[n]=this._selected;this.emit("select",{node:this.getNode(n)??null,id:n,ids:this.getSelection()})}return this}clearSelection(){return this._selected.clear(),this._syncRows(),this}getChecked({leavesOnly:t=!1}={}){return t?[...this._checked].filter(e=>{let i=this.getNode(e);return i!==null&&!Q(i,this._readers)}):[...this._checked]}setChecked(t,{silent:e=!0}={}){this._checked.clear();for(let i of Ls(t))this._applyCheck(i,!0,{silent:!0});return this._syncRows(),e||this.emit("check",{ids:this.getChecked(),node:null}),this}check(t,e,{silent:i=!1}={}){let n=this._applyCheck(t,e,{silent:!0});return this._syncRows(),!i&&n&&this.emit("check",{ids:this.getChecked(),node:n}),this}focusNode(t){this.reveal(t);let e=this._rows.findIndex(i=>Object.is(i.id,t));return e>=0&&this._focusRow(e),this}_visibleItems(){if(this._filter==="")return this._items;let t=this._filter.trim().toLocaleLowerCase();return t===""?this._items:Dl(this._items,this._readers,e=>this._readers.label(e).toLocaleLowerCase().includes(t),this._childrenKey)}_renderRows(){let t=this._visibleItems();if(this._rows=Uf(t,this._readers,this._expanded),this._rows.length===0){this.el.replaceChildren(l("div",{class:"zx-tree__empty"},this._message("tree.empty",this.options.emptyText)));return}this.el.replaceChildren(...this._rows.map(e=>this._renderRow(e))),this._syncRows()}_renderRow(t){let e=Q(t.node,this._readers),i=e&&this._expanded.has(t.id),n=l("div",{class:"zx-tree__row",role:"treeitem",id:x("zx-tree-item"),tabIndex:-1,ariaLevel:String(t.level),ariaSetSize:String(t.setsize),ariaPosInSet:String(t.posinset),dataset:{level:String(t.level)}});n.style.setProperty("--zx-tree-level",String(t.level-1));let r=l("span",{class:"zx-tree__twisty",ariaHidden:"true"},e?g("chevron-right",{size:12}):null);if(r.dataset.action="twisty",n.append(r),this.options.checkboxes){let a=l("input",{class:"zx-tree__checkbox",type:"checkbox",tabIndex:-1,ariaHidden:"true"});a.dataset.action="checkbox",n.append(a)}this.options.icons&&n.append(l("span",{class:"zx-tree__icon",ariaHidden:"true"},g(e?i?"folder-open":"folder":"file",{size:14})));let o=this.options.renderLabel?this.options.renderLabel(t.node):this._readers.label(t.node);return n.append(l("span",{class:"zx-tree__label"},o)),t.node.badge!=null&&n.append(l("span",{class:"zx-tree__badge"},String(t.node.badge))),n}_syncRows(){let t=this.el.querySelectorAll(".zx-tree__row"),e=this._rows.findIndex(i=>Object.is(i.id,this._focusId));e<0&&(e=0),t.forEach((i,n)=>{let r=this._rows[n];if(!r)return;let o=Q(r.node,this._readers),a=o&&this._expanded.has(r.id);o?i.setAttribute("aria-expanded",String(a)):i.removeAttribute("aria-expanded"),this.options.selection!==!1&&i.setAttribute("aria-selected",String(this._selected.has(r.id))),i.toggleAttribute("data-branch",o),i.toggleAttribute("data-loading",this._loading.has(r.id)),i.tabIndex=n===e?0:-1;let c=i.querySelector(".zx-tree__checkbox");if(c){let u=this._checkState(this.getNode(r.id)??r.node);c.checked=u==="checked",c.indeterminate=u==="partial",i.setAttribute("aria-checked",u==="partial"?"mixed":String(c.checked))}let d=i.querySelector(".zx-tree__icon");d&&this.options.icons&&d.replaceChildren(g(o?a?"folder-open":"folder":"file",{size:14}))}),this._focusId=this._rows[e]?.id??null,this.el.tabIndex=this._rows.length===0?0:-1}_onClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let i=this._rowIndex(e);if(i<0)return;let n=this._rows[i];this._focusRow(i);let r=t.target.closest("[data-action]");if(r?.dataset.action==="twisty"){Q(n.node,this._readers)&&this.toggle(n.id).then(()=>this._focusNodeId(n.id));return}let o=this.getNode(n.id)??n.node;if(r?.dataset.action==="checkbox"){this.check(n.id,this._checkState(o)!=="checked");return}if(this.options.checkboxes&&this.options.selection===!1){this.check(n.id,this._checkState(o)!=="checked");return}this.select(n.id,{additive:t.ctrlKey||t.metaKey})}_onDoubleClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let i=this._rows[this._rowIndex(e)];i&&(Q(i.node,this._readers)?this.toggle(i.id).then(()=>this._focusNodeId(i.id)):this.emit("activate",{node:i.node,id:i.id}))}_onKeydown(t){let e=this._rows.findIndex(o=>Object.is(o.id,this._focusId));if(e<0||this._rows.length===0)return;let i=this._rows[e],n=Q(i.node,this._readers),r=n&&this._expanded.has(i.id);switch(t.key){case"ArrowDown":t.preventDefault(),this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowUp":t.preventDefault(),this._focusRow(Math.max(0,e-1));return;case"ArrowRight":t.preventDefault(),n&&!r?this.expand(i.id).then(()=>this._focusNodeId(i.id)):r&&this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowLeft":{t.preventDefault(),r?(this.collapse(i.id),this._focusNodeId(i.id)):i.parent&&this._focusNodeId(this._readers.value(i.parent));return}case"Home":t.preventDefault(),this._focusRow(0);return;case"End":t.preventDefault(),this._focusRow(this._rows.length-1);return;case"Enter":t.preventDefault(),this.options.selection!==!1&&this.select(i.id),this.emit("activate",{node:i.node,id:i.id});return;case" ":t.preventDefault(),this.options.checkboxes?this.check(i.id,this._checkState(this.getNode(i.id)??i.node)!=="checked"):this.options.selection!==!1&&this.select(i.id,{additive:this.options.selection==="multi"});return;case"*":t.preventDefault(),this._expandSiblings(i);return;default:if(!Bx(t)||Vx(t.target))return;t.preventDefault(),this._handleTypeahead(t)}}_expandSiblings(t){let e=t.parent?this._readers.children(t.parent)??[]:this._visibleItems(),i=this._focusId;for(let n of e)Q(n,this._readers)&&this._expanded.add(this._readers.value(n));this._renderRows(),this._focusNodeId(i)}async _ensureChildren(t,e){let i=this._readers.children(t);if(!this.options.load||i&&i.length>0)return!0;if(this._loading.has(e))return await this._loading.get(e),Array.isArray(this._readers.children(t));let n=(async()=>{try{let o=await this.options.load(t);return t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1),!0}catch(o){return this.emit("error",{error:o,node:t,id:e}),!1}finally{this._loading.delete(e)}})();this._loading.set(e,n),this._syncRows();let r=await n;return this._syncRows(),r}_applyCheck(t,e,{silent:i}){let n=this.getNode(t);if(!n)return null;let r=[t,...Kf(n,this._readers).map(o=>this._readers.value(o))];for(let o of r)e?this._checked.add(o):this._checked.delete(o);return i||this._syncRows(),n}_checkState(t){let e=this._readers.children(t);if(!e||e.length===0)return this._checked.has(this._readers.value(t))?"checked":"unchecked";let i=e.map(n=>this._checkState(n));return i.every(n=>n==="checked")?"checked":i.every(n=>n==="unchecked")?"unchecked":"partial"}_rotatedRows(){let t=this._rows.findIndex(e=>Object.is(e.id,this._focusId));return t<0?this._rows:[...this._rows.slice(t+1),...this._rows.slice(0,t+1)]}_rowIndex(t){return[...this.el.querySelectorAll(".zx-tree__row")].indexOf(t)}_rowElement(t){let e=this._rows.findIndex(i=>Object.is(i.id,t));return e<0?null:this.el.querySelectorAll(".zx-tree__row")[e]??null}_focusRow(t){let e=this._rows[t];if(!e)return;this._focusId=e.id,this._syncRows();let i=this._rowElement(e.id);i?.focus(),i?.scrollIntoView({block:"nearest"})}_focusNodeId(t){if(t===void 0)return;let e=this._rows.findIndex(i=>Object.is(i.id,t));e>=0&&this._focusRow(e)}_message(t,e){let i=this.msg(t);return i===t?e:i}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function Nl(s){return Array.isArray(s)?s.map(t=>{if(t===null||typeof t!="object")return t;let e={...t};for(let[i,n]of Object.entries(e))Array.isArray(n)&&(e[i]=Nl(n));return e}):[]}function Ls(s){return Array.isArray(s)?s:[]}function Bx(s){if(!s||s.ctrlKey||s.metaKey||s.altKey)return!1;let t=typeof s.key=="string"?s.key:"";return t.length===1&&!/\s/.test(t)}function Vx(s){let t=s&&s.nodeType===1?s:null;return t?t.isContentEditable||t.localName==="textarea"||t.localName==="select"?!0:t.localName!=="input"?!1:!["checkbox","radio","button","submit","reset","image","range","color","file"].includes(t.type):!1}var ro=class extends y{static cssName="finder";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",path:[],load:null,preview:null,rootLabel:"",columnWidth:220,height:320,icons:!0,renderItem:null,emptyText:"Empty"};render(){this._items=[],this._path=[],this._columns=[],this._activeColumn=0,this._loading=new Map,this._pathSequence=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");return this.el=t,this._readers=so(this.options),this._childrenKey=this.options.childrenKey??"children",t.style.setProperty("--zx-finder-column",`${Number(this.options.columnWidth)||220}px`),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._handleTypeahead=ut(()=>this._columnNodes(this._activeColumn).map(e=>this._readers.label(e)),(e,i)=>this._selectAt(this._activeColumn,i,{focus:!0})),this.listen(t,"click",e=>this._onClick(e)),this.listen(t,"dblclick",e=>this._onDoubleClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this._render({}),this.setPath(this.options.path,{silent:!0}),t}getPath(){return this._path.slice()}getNodes(){let t=this._items,e=[];for(let i of this._path){let n=t.find(r=>Object.is(this._readers.value(r),i));if(!n)break;e.push(n),t=this._readers.children(n)??[]}return e}getSelection(){let t=this.getNodes();return t.length>0?t[t.length-1]:null}async setPath(t,{silent:e=!1,focus:i=!1}={}){let n=this._pathSequence+1;this._pathSequence=n;let r=Array.isArray(t)?t.slice():[],o=[],a=this._items;for(let c of r){let d=a.find(u=>Object.is(this._readers.value(u),c));if(!d||(o.push(c),!Q(d,this._readers)))break;if(await this._ensureChildren(d),n!==this._pathSequence)return this;a=this._readers.children(d)??[]}return this._path=o,this._activeColumn=Math.max(0,o.length-1),this._render({focus:i}),e||this._emitChange(),this}async reveal(t,{silent:e=!1}={}){let i=Fs(this._items,t,this._readers);return i.length===0?this:this.setPath(i.map(n=>this._readers.value(n)),{silent:e})}setItems(t){return this._items=Array.isArray(t)?t.slice():[],this._path=[],this._render({}),this}focus(){return(this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0))?.focus(),this}_render({focus:t=!1}){let e=this.getNodes(),i=[{nodes:this._items,selectedId:this._path[0],owner:null}];e.forEach((a,c)=>{if(!Q(a,this._readers))return;let d=this._readers.children(a)??[];i.push({nodes:d,selectedId:this._path[c+1],owner:a})}),this._columns=i,this._activeColumn=Math.min(this._activeColumn,i.length-1);let n=i.map((a,c)=>this._renderColumn(a,c)),r=e[e.length-1]??null;if(this.options.preview&&r&&!Q(r,this._readers)){let a=this.options.preview(r);a&&n.push(l("div",{class:"zx-finder__preview"},a))}this.el.replaceChildren(...n),this._syncTabStop(),this.el.lastElementChild?.scrollIntoView({block:"nearest",inline:"nearest"}),t&&this.focus()}_renderColumn(t,e){let i=t.owner?this._readers.label(t.owner):String(this.options.rootLabel||this._message("finder.root","Root")),n=l("div",{class:"zx-finder__list",role:"listbox",ariaLabel:i,dataset:{column:String(e)}});if(t.nodes.length===0){let r=t.owner!==null&&this._loading.has(this._readers.value(t.owner));n.append(l("div",{class:"zx-finder__empty"},r?this._message("finder.loading","Loading\u2026"):this._message("finder.empty",this.options.emptyText)))}for(let r of t.nodes){let o=this._readers.value(r),a=Q(r,this._readers),c=t.selectedId!==void 0&&Object.is(o,t.selectedId),d=l("div",{class:"zx-finder__row",id:x("zx-finder-row"),role:"option",tabIndex:-1,ariaSelected:String(c)});this.options.icons&&d.append(l("span",{class:"zx-finder__icon",ariaHidden:"true"},g(a?"folder":"file",{size:14}))),d.append(l("span",{class:"zx-finder__label"},this.options.renderItem?this.options.renderItem(r):this._readers.label(r))),a&&d.append(l("span",{class:"zx-finder__chevron",ariaHidden:"true"},g("chevron-right",{size:11}))),d.toggleAttribute("data-branch",a),n.append(d)}return l("div",{class:"zx-finder__column"},n)}_syncTabStop(){let t=this.el.querySelectorAll(".zx-finder__row");t.forEach(i=>{i.tabIndex=-1});let e=this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0)??t[0];e&&(e.tabIndex=0)}_onClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:i,index:n}=this._locate(e);i<0||this._selectAt(i,n,{focus:!0})}_onDoubleClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:i,index:n}=this._locate(e),r=this._columnNodes(i)[n];r&&(Q(r,this._readers)?this._enter(i,n):this.emit("activate",{node:r,id:this._readers.value(r)}))}_onKeydown(t){if(t.target.closest(".zx-finder__preview"))return;let e=this._activeColumn,i=this._columnNodes(e);if(i.length===0&&!["ArrowLeft"].includes(t.key))return;let n=Math.max(0,i.findIndex(r=>Object.is(this._readers.value(r),this._columns[e]?.selectedId)));switch(t.key){case"ArrowDown":t.preventDefault(),this._selectAt(e,Math.min(i.length-1,n+1),{focus:!0});return;case"ArrowUp":t.preventDefault(),this._selectAt(e,Math.max(0,n-1),{focus:!0});return;case"Home":t.preventDefault(),this._selectAt(e,0,{focus:!0});return;case"End":t.preventDefault(),this._selectAt(e,i.length-1,{focus:!0});return;case"ArrowRight":{t.preventDefault();let r=i[n];if(!r||!Q(r,this._readers))return;this._enter(e,n);return}case"ArrowLeft":if(t.preventDefault(),e===0)return;this._path=this._path.slice(0,e),this._activeColumn=e-1,this._render({focus:!0}),this._emitChange();return;case"Enter":{t.preventDefault();let r=i[n];if(!r)return;Q(r,this._readers)?this._enter(e,n):this.emit("activate",{node:r,id:this._readers.value(r)});return}default:this._handleTypeahead(t)}}async _selectAt(t,e,{focus:i=!1}={}){let n=this._columnNodes(t)[e];if(!n)return;let r=this._readers.value(n);if(this._path.length===t+1&&Object.is(this._path[t],r)){this._activeColumn=t,this._syncTabStop(),i&&this.focus();return}this._path=[...this._path.slice(0,t),r],this._activeColumn=t,Q(n,this._readers)&&await this._ensureChildren(n),this._render({focus:i}),this._emitChange()}async _enter(t,e){if(await this._selectAt(t,e),this._columnNodes(t+1).length===0){this._activeColumn=t,this._syncTabStop(),this.focus();return}this._activeColumn=t+1,this._path.length<=t+1?await this._selectAt(t+1,0,{focus:!0}):(this._syncTabStop(),this.focus())}async _ensureChildren(t){let e=this._readers.children(t);if(!this.options.load||e&&e.length>0)return;let i=this._readers.value(t),n=this._loading.get(i);if(n)return n;let r=(async()=>{try{let o=await this.options.load(t);t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1)}catch(o){t[this._childrenKey]=[],this.emit("error",{error:o,node:t,id:i})}finally{this._loading.delete(i)}})();return this._loading.set(i,r),r}_columnNodes(t){return this._columns[t]?.nodes??[]}_locate(t){let e=t.closest(".zx-finder__list");return e?{column:Number(e.dataset.column),index:[...e.querySelectorAll(".zx-finder__row")].indexOf(t)}:{column:-1,index:-1}}_rowAt(t,e){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelectorAll(".zx-finder__row")[e]??null}_activeRow(t){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelector('[aria-selected="true"]')??null}_emitChange(){let t=this.getNodes();this.emit("change",{path:this.getPath(),nodes:t,node:t.length>0?t[t.length-1]:null})}_message(t,e){let i=this.msg(t);return i===t?e:i}destroy(){this._pathSequence+=1;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function Yf(s){return String(s??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function jx(s,t){let e=Yf(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let i=Yf(s.flat(1/0).join(" "));return e.every(n=>i.includes(n))}function Fl(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function Wf(s,t){if(typeof t.get=="function")return Ol(t.get(s));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(n=>Ol(typeof n=="function"?n(s):n==null?void 0:s?.[n]))}function Gf(s,t){let e=[],i=new Map;for(let n of s)for(let r of Wf(n,t)){let o=Qf(r);o.value==null||o.value===""||i.has(o.value)||(i.set(o.value,!0),e.push(o))}return e}function Fe(s,t,e){return s.filter(i=>t.every(n=>{let r=e?.[n.id];if(!Fl(r))return!0;if(n.type==="custom")return typeof n.predicate!="function"||!!n.predicate(i,r);let o=Wf(i,n);return n.type==="text"?jx(o,r):n.type==="select"?o.some(a=>Hx(Qf(a).value,r)):!0}))}function Ol(s){return Array.isArray(s)?s.flat(1/0):[s]}function Qf(s){if(s&&typeof s=="object"&&!(s instanceof Date)){if(Object.prototype.hasOwnProperty.call(s,"value"))return{value:s.value,label:String(s.label??s.value??"")};if(Object.prototype.hasOwnProperty.call(s,"field"))return{value:s.field,label:String(s.label??s.field??"")}}return{value:s,label:String(s??"")}}function Hx(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}var oo=class extends y{static cssName="data-filter";static defaults={filters:[],data:[],autoApply:!0,clearLabel:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._filters=Array.isArray(this.options.filters)?this.options.filters.map(i=>({...i})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._state={},this._entries=new Map,this._customOrigins=new Map,this._restored=!1;let e=new Set;for(let i of this._filters){if(Ll(i),e.has(i.id))throw new RangeError(`Duplicate filter id: ${i.id}`);e.add(i.id),i.type==="custom"&&!this._customOrigins.has(i.element)&&this._customOrigins.set(i.element,{parent:i.element.parentNode,nextSibling:i.element.nextSibling}),this._state[i.id]=i.type==="custom"?Rl(i.element):""}this._filtered=Fe(this._data,this._filters,this._state),this._controls=l("div",{class:"zx-data-filter__controls"}),this._badge=l("span",{class:"zx-data-filter__badge",ariaLive:"polite",hidden:!0},"0"),this._clearButton=l("button",{class:"zx-data-filter__clear",type:"button",hidden:!0},this.options.clearLabel==null?this.msg("dataFilter.clear"):String(this.options.clearLabel)),t.replaceChildren(this._controls,this._badge,this._clearButton),this.listen(this._clearButton,"click",()=>this.clear());for(let i of this._filters)this._appendFilter(i);return this._syncActiveState(),t}setData(t){Kx(t),this._data=[...t];for(let e of this._filters){if(e.type!=="select")continue;let i=this._entries.get(e.id);i&&this._populateSelect(e,i)}return this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Fe(this._data,this._filters,this._state),this}apply(){this._filtered=Fe(this._data,this._filters,this._state);let t=[...this._filtered];return this.emit("filter",{rows:t,state:this.getState()}),t}clear(){for(let t of this._filters)this._state[t.id]="";return this._syncControls(),this._syncActiveState(),this.apply(),this}getState(){return{...this._state}}setState(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("DataFilter state must be an object");for(let e of this._filters)this._state[e.id]=Object.prototype.hasOwnProperty.call(t,e.id)?t[e.id]:"";return this._syncControls(),this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Fe(this._data,this._filters,this._state),this}addFilter(t){Ll(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?Rl(e.element):"",this._appendFilter(e),this._filtered=Fe(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),Ux(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(Ll(t),this._entries.has(t.id))throw new RangeError(`Duplicate filter id: ${t.id}`);let e,i={element:null,options:[]};if(t.type==="select")e=l("select",{ariaLabel:t.label}),i.element=e,this._populateSelect(t,i),this.listen(e,"change",()=>{let r=Number(e.value)-1;this._state[t.id]=r>=0?i.options[r]?.value??"":"",this._controlChanged()});else if(t.type==="text")e=l("input",{type:"search",placeholder:t.placeholder??"",ariaLabel:t.label,autocomplete:"off"}),i.element=e,this.listen(e,"input",()=>{this._state[t.id]=e.value,this._controlChanged()});else{e=t.element,this._customOrigins.has(e)||this._customOrigins.set(e,{parent:e.parentNode,nextSibling:e.nextSibling}),i.element=e;let r=e.matches?.('input:not([type="checkbox"]):not([type="radio"]), textarea')?"input":"change";this.listen(e,r,()=>{this._state[t.id]=Rl(e),this._controlChanged()})}this._entries.set(t.id,i);let n=l("label",{class:"zx-data-filter__field"},l("span",{class:"zx-data-filter__label"},t.label),e);this._controls.append(n)}_populateSelect(t,e){let i=this._state[t.id];e.options=Array.isArray(t.options)?t.options.map(qx):Gf(this._data,t);let n=l("option",{value:""},t.emptyLabel??this.msg("dataFilter.all")),r=document.createDocumentFragment();r.append(n),e.options.forEach((a,c)=>{r.append(l("option",{value:String(c+1)},a.label))}),e.element.replaceChildren(r);let o=e.options.findIndex(a=>Xf(a.value,i));e.element.value=o>=0?String(o+1):"",o<0&&(this._state[t.id]="")}_controlChanged(){this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Fe(this._data,this._filters,this._state)}_syncControls(){for(let t of this._filters){let e=this._entries.get(t.id);if(!e)continue;let i=this._state[t.id];if(t.type==="select"){let n=e.options.findIndex(r=>Xf(r.value,i));e.element.value=n>=0?String(n+1):"",n<0&&(this._state[t.id]="")}else $x(e.element,i)}}_syncActiveState(){let t=this._filters.reduce((e,i)=>e+Number(Fl(this._state[i.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function Ll(s){if(!s||typeof s!="object")throw new TypeError("Filter definition must be an object");if(!["select","text","custom"].includes(s.type))throw new TypeError(`Unknown filter type: ${s.type}`);if(typeof s.id!="string"||!s.id)throw new TypeError("Filter definition requires an id");if(s.type==="custom"){if(!s.element||s.element.nodeType!==1)throw new TypeError("Custom filter requires an Element");if(typeof s.predicate!="function")throw new TypeError("Custom filter requires a predicate")}}function qx(s){return s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"value")?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}}function Rl(s){return"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked:"value"in s?s.value:s.getAttribute("data-value")??""}function $x(s,t){"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked=!!t:"value"in s?s.value=t==null?"":String(t):t==null||t===""?s.removeAttribute("data-value"):s.setAttribute("data-value",String(t))}function Xf(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}function Kx(s){if(!Array.isArray(s))throw new TypeError("DataFilter data must be an array")}function Ux(s){let t=[...s];for(let e=t.length;t.length>0&&e>=0;e-=1){let i=0;for(let n=t.length-1;n>=0;n-=1){let[r,o]=t[n];if(!o.parent)r.remove();else{if(o.nextSibling&&o.nextSibling.parentNode!==o.parent)continue;o.parent.insertBefore(r,o.nextSibling)}t.splice(n,1),i+=1}if(i===0)break}for(let[e,i]of t)i.parent?i.parent.append(e):e.remove()}var Yx=8,Wx=1e11,Gx=.01,lo=class extends y{static cssName="filter-panel";static defaults={fields:{},order:null,value:{},mode:"draft",serialize:"seconds",timeZone:null,emptyText:null};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._restored=!1,this._entries=[],this._children=[],this._writing=!1,this._draft={},this._applied={},this._appliedDraft="";let t=this.el??l("div");this.el=t,this._timeZone=Jx(this.options.timeZone),this._fields=Qx(this.options.fields,this.options.order),this._draft=Rs(this.options.value,this.options.fields,this._timeZone),this._applied=co(this._draft,this.options.fields,this.options.serialize,this._timeZone),this._appliedDraft=jl(this._draft);let e=[];if(this._fields.length===0)e.push(l("p",{ref:"empty",class:"zx-filter-panel__empty",role:"status"},this.options.emptyText==null?this._message("filterPanel.empty","No filters are available here."):String(this.options.emptyText)));else{let i=l("div",{ref:"fields",class:"zx-filter-panel__fields"});for(let{key:n,field:r,spec:o}of this._fields)i.append(this._buildField(n,r,o));e.push(i,this._buildActions())}return t.replaceChildren(...e),t.setAttribute("role","group"),t.setAttribute("aria-label",this._message("filterPanel.label","Filters")),t.setAttribute("data-mode",this.options.mode==="live"?"live":"draft"),this.listen(t,"keydown",i=>{i.key!=="Enter"||this.options.mode==="live"||!i.target?.matches?.('input:not([type="checkbox"]):not([type="radio"])')||(i.preventDefault(),this.apply())}),this._syncActions(),t}getValue(){return tS(this._applied)}setValue(t){return this._draft=Rs(t,this.options.fields,this._timeZone),this._commit(this._draftValue()),this._writeControls(),this._syncActions(),this.emit("change",{value:this.getValue(),field:null}),this}apply(){let t=this._draftValue();return this._commit(t),this._syncActions(t),this.emit("apply",{value:this.getValue()}),this}reset(){return this._replaceDraft(Rs(this.options.value,this.options.fields,this._timeZone))}clear(){return this._replaceDraft(Rs({},this.options.fields,this._timeZone),{commit:!0})}destroy(){for(let t of this._children)t.destroy();this._children=[],!this._restored&&!this._createdRoot&&(S(this.el,this._snapshot),this._restored=!0),super.destroy()}_buildActions(){let t=l("div",{ref:"actions",class:"zx-filter-panel__actions"});if(this.options.mode!=="live"){let i=l("button",{ref:"apply",class:"zx-btn zx-filter-panel__apply",type:"button",dataset:{kind:"primary",size:"md"}},l("span",{class:"zx-btn__label"},this._message("filterPanel.apply","Apply")));this.listen(i,"click",()=>this.apply()),t.append(i)}let e=l("button",{ref:"clear",class:"zx-btn zx-filter-panel__clear",type:"button",dataset:{kind:"ghost",size:"md"}},l("span",{class:"zx-btn__label"},this._message("filterPanel.clear","Clear all")));return this.listen(e,"click",()=>this.clear()),t.append(e),t}_buildField(t,e,i){let n=String(e.label??t),r=l("div",{class:"zx-filter-panel__field",dataset:{field:t,type:String(e.type??"")}});return i?(i.kind==="select"?r.append(this._buildSelect(t,e,n)):i.kind==="text"?r.append(...this._buildText(t,e,n)):i.kind==="date"?r.append(...this._buildDate(t,e,n,i)):r.append(...this._buildNumber(t,e,n,i)),r):(r.setAttribute("data-state","unsupported"),r.append(l("span",{class:"zx-filter-panel__label"},n),l("p",{class:"zx-filter-panel__unsupported",role:"note"},this._message("filterPanel.unsupported","Unsupported filter type: %1",String(e.type??"")))),r)}_buildSelect(t,e,i){let n=ep(e.options),r=this._draft[t]??[],o=new lt(null,{items:n.map(a=>({...a,on:r.some(c=>ip(c,a.value))})),valueKey:"value",labelKey:"label",search:typeof e.search=="boolean"?e.search:n.length>Yx,height:220,msg:{"checklist.label":i}});return o.on("change",()=>this._edited(t,o.getValues())),this._isolate(o),this._children.push(o),this._entries.push({key:t,write:a=>o.setValues(a??[])}),o.toElement()}_buildText(t,e,i){let n=x("zx-filter-panel-text"),r=l("input",{id:n,class:"zx-filter-panel__input",type:"search",autocomplete:"off",placeholder:String(e.placeholder??""),value:String(this._draft[t]??"")});return this.listen(r,"input",()=>this._edited(t,r.value)),this._entries.push({key:t,write:o=>{r.value=o==null?"":String(o)}}),[l("label",{class:"zx-filter-panel__label",for:n},i),r]}_buildDate(t,e,i,n){if(!n.range){let d=x("zx-filter-panel-date"),u=this._dateInput(String(this._draft[t]??""),{id:d});return this.listen(u,"change",()=>this._edited(t,u.value)),this._entries.push({key:t,write:h=>{u.value=h==null?"":String(h)}}),[l("label",{class:"zx-filter-panel__label",for:d},i),u]}let r=x("zx-filter-panel-label"),o=this._draft[t]??{},a={},c=["from","to"].map(d=>{let u=x("zx-filter-panel-date"),h=this._dateInput(String(o[d]??""),{id:u,ariaLabel:this._edgeName(i,d)});return a[d]=h,this.listen(h,"change",()=>this._editedEdge(t,d,h.value)),l("div",{class:"zx-filter-panel__edge"},l("label",{class:"zx-filter-panel__edge-label",for:u},this._edgeLabel(d)),h)});return this._entries.push({key:t,write:d=>{let u=d??{};for(let h of["from","to"])a[h].value=u[h]==null?"":String(u[h])}}),[l("span",{class:"zx-filter-panel__label",id:r},i),l("div",{class:"zx-filter-panel__range",role:"group",ariaLabelledby:r},c)]}_dateInput(t,e){return l("input",{class:"zx-filter-panel__input",type:"date",autocomplete:"off",value:t,...e})}_buildNumber(t,e,i,n){let r=x("zx-filter-panel-label");if(!n.range){let d=this._numberField(e,n,i,this._draft[t]??null);return d.on("change",()=>this._edited(t,d.get())),this._entries.push({key:t,write:u=>d.set(u??null,{silent:!0})}),[l("span",{class:"zx-filter-panel__label",id:r},i),d.toElement()]}let o=this._draft[t]??{},a={},c=["from","to"].map(d=>{let u=this._numberField(e,n,this._edgeName(i,d),o[d]??null);return a[d]=u,u.on("change",()=>this._editedEdge(t,d,u.get())),l("div",{class:"zx-filter-panel__edge"},l("span",{class:"zx-filter-panel__edge-label"},this._edgeLabel(d)),u.toElement())});return this._entries.push({key:t,write:d=>{let u=d??{};for(let h of["from","to"])a[h].set(u[h]??null,{silent:!0})}}),[l("span",{class:"zx-filter-panel__label",id:r},i),l("div",{class:"zx-filter-panel__range",role:"group",ariaLabelledby:r},c)]}_numberField(t,e,i,n){let r=Number.isFinite(Number(t.step))&&Number(t.step)>0?Number(t.step):e.integer?1:Gx,o=new Et(null,{value:n,min:t.min==null?null:Number(t.min),max:t.max==null?null:Number(t.max),step:r,precision:e.integer?0:null,placeholder:String(t.placeholder??""),label:i});return this._isolate(o),this._children.push(o),o}_edgeLabel(t){return t==="from"?this._message("filterPanel.from","From"):this._message("filterPanel.to","To")}_edgeName(t,e){return e==="from"?this._message("filterPanel.rangeFrom","%1 from",t):this._message("filterPanel.rangeTo","%1 to",t)}_edited(t,e){this._writing||(this._draft[t]=e,this._afterEdit(t))}_editedEdge(t,e,i){if(this._writing)return;let n=this._draft[t],r=n!==null&&typeof n=="object"&&!Array.isArray(n)?{...n}:{};r[e]=i,this._draft[t]=r,this._afterEdit(t)}_afterEdit(t){let e=this._draftValue();this._syncActions(e),this.emit("change",{value:e,field:t}),this.options.mode==="live"&&this.apply()}_isolate(t){for(let e of["zx-change","zx-input"])this.listen(t.el,e,i=>i.stopPropagation())}_replaceDraft(t,{commit:e=!1}={}){this._draft=t,this._writeControls();let i=this._draftValue(),n=e||this.options.mode==="live";return n&&this._commit(i),this._syncActions(i),this.emit("change",{value:i,field:null}),n&&this.emit("apply",{value:this.getValue()}),this}_commit(t){this._applied=t,this._appliedDraft=jl(this._draft)}_draftValue(){return co(this._draft,this.options.fields,this.options.serialize,this._timeZone)}_writeControls(){this._writing=!0;try{for(let t of this._entries)t.write(this._draft[t.key])}finally{this._writing=!1}}_syncActions(t=this._draftValue()){let e=Object.keys(t).length>0,i=this.refs.clear;if(i&&(i.disabled=!e),this.options.mode==="live"||this._fields.length===0)return;jl(this._draft)!==this._appliedDraft?this.el.setAttribute("data-state","dirty"):this.el.removeAttribute("data-state")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function ql(s){switch(String(s??"").trim().toLowerCase()){case"text":return{kind:"text",range:!1,integer:!1};case"select":return{kind:"select",range:!1,integer:!1};case"date":return{kind:"date",range:!1,integer:!1};case"date:range":return{kind:"date",range:!0,integer:!1};case"int":return{kind:"number",range:!1,integer:!0};case"float":case"number":return{kind:"number",range:!1,integer:!1};case"int:range":return{kind:"number",range:!0,integer:!0};case"float:range":case"number:range":return{kind:"number",range:!0,integer:!1};default:return null}}function me(s){return s==null?!1:s instanceof Date?!Number.isNaN(s.getTime()):Array.isArray(s)?s.some(t=>me(t)):typeof s=="string"?s.trim()!=="":typeof s=="number"?Number.isFinite(s):typeof s=="boolean"?s:typeof s=="object"?Object.values(s).some(t=>me(t)):!0}function tp(s){let t={};if(!Bi(s))return t;for(let[e,i]of Object.entries(s)){if(Bi(i)){let n={};for(let[r,o]of Object.entries(i))me(o)&&(n[r]=o);Object.keys(n).length>0&&(t[e]=n);continue}me(i)&&(t[e]=i)}return t}function Ps(s,t=null){if(s==null||s==="")return"";if(s instanceof Date)return Number.isNaN(s.getTime())?"":Vl(s.getTime(),null);if(typeof s=="number")return Number.isFinite(s)?Vl(Math.abs(s)<Wx?s*1e3:s,t):"";let e=String(s).trim();if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;if(/^-?\d+(\.\d+)?$/.test(e))return Ps(Number(e),t);let i=new Date(e);return Number.isNaN(i.getTime())?"":Vl(i.getTime(),t)}function Pl(s,t,e="seconds",i=null){let n=Ps(s,i);if(!n)return null;let[r,o,a]=n.split("-").map(Number),c=new Date(Zx(r,o-1,a,t,i));return typeof e=="function"?e(c,t):e==="ms"?c.getTime():e==="iso"?c.toISOString():Math.floor(c.getTime()/1e3)}function ep(s){if(!Array.isArray(s))return[];let t=[];for(let e of s){if(e!==null&&typeof e=="object"){let i=e,n="value"in i?i.value:i.ID;if(n===void 0)continue;let r=i.label??i.name??i.title;t.push({value:n,label:r==null?String(n):String(r)});continue}e!==void 0&&t.push({value:e,label:String(e)})}return t}function Rs(s,t,e=null){let i=Bi(s)?s:{},n={};for(let[r,o]of Object.entries(t??{})){let a=o??{},c=ql(a.type);if(!c)continue;let d=i[r];c.kind==="text"?n[r]=d==null?"":String(d).trim():c.kind==="select"?n[r]=Xx(d,ep(a.options)):c.kind==="date"?n[r]=c.range?{from:Ps(ao(d,"from"),e),to:Ps(ao(d,"to"),e)}:Ps(d,e):n[r]=c.range?{from:Bl(ao(d,"from"),c),to:Bl(ao(d,"to"),c)}:Bl(d,c)}return n}function co(s,t,e="seconds",i=null){let n=Rs(s,t,i),r={};for(let[o,a]of Object.entries(t??{})){let c=ql((a??{}).type);if(!c)continue;let d=n[o];if(c.kind==="text"){d!==""&&(r[o]=d);continue}if(c.kind==="select"){let f=d;f.length>0&&(r[o]=f.slice());continue}if(c.kind==="date"){if(!c.range){d&&(r[o]=Pl(d,"from",e,i));continue}let f=d,p={};f.from&&(p.from=Pl(f.from,"from",e,i)),f.to&&(p.to=Pl(f.to,"to",e,i)),Object.keys(p).length>0&&(r[o]=p);continue}if(!c.range){d!==null&&(r[o]=d);continue}let u=d,h={};u.from!==null&&(h.from=u.from),u.to!==null&&(h.to=u.to),Object.keys(h).length>0&&(r[o]=h)}return r}function Qx(s,t){let e=Bi(s)?s:{},i=Object.keys(e),n=Array.isArray(t)?t.filter(o=>i.includes(o)):[],r=new Set(n);return[...n,...i.filter(o=>!r.has(o))].map(o=>({key:o,field:e[o]??{},spec:ql(e[o]?.type)}))}function Xx(s,t){let e=Array.isArray(s)?s:me(s)?[s]:[];return t.length===0?e.filter(i=>me(i)):t.filter(i=>e.some(n=>ip(n,i.value))).map(i=>i.value)}function ao(s,t){return s==null?null:Array.isArray(s)?(t==="from"?s[0]:s[1])??null:Bi(s)?t in s?s[t]:null:t==="from"?s:null}function Bl(s,t){let e=ve(s);return e===null?null:t.integer?Math.trunc(e):e}function Jx(s){if(s==null||s==="")return null;try{return new Intl.DateTimeFormat("en-US",{timeZone:String(s)}).resolvedOptions().timeZone}catch{throw new RangeError(`Unknown time zone "${String(s)}"`)}}function Vl(s,t){if(!t){let i=new Date(s);return Zf(i.getFullYear(),i.getMonth(),i.getDate())}let e=Hl(s,t);return Zf(e.year,e.month,e.day)}function Zx(s,t,e,i,n){if(!n)return(i==="to"?new Date(s,t,e,23,59,59,999):new Date(s,t,e,0,0,0,0)).getTime();if(i!=="to")return Jf(s,t,e,n);let r=new Date(Date.UTC(s,t,e+1));return Jf(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),n)-1}function Jf(s,t,e,i){let n=Date.UTC(s,t,e),r=d=>{let u=Hl(d,i);return Date.UTC(u.year,u.month,u.day)+u.seconds*1e3-Math.floor(d/1e3)*1e3},o=n-r(n),a=n-r(o),c=null;for(let d of[a,o]){let u=Hl(d,i);u.year!==s||u.month!==t||u.day!==e||(!c||u.seconds<c.seconds)&&(c={candidate:d,seconds:u.seconds})}return c?c.candidate:a}function Hl(s,t){let e=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),i={};for(let n of e.formatToParts(new Date(s)))i[n.type]=Number(n.value);return{year:i.year,month:i.month-1,day:i.day,seconds:i.hour%24*3600+i.minute*60+i.second}}function Zf(s,t,e){return`${String(s).padStart(4,"0")}-${String(t+1).padStart(2,"0")}-${String(e).padStart(2,"0")}`}function Bi(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)}function ip(s,t){return Object.is(s,t)?!0:s==null||t===null||t===void 0?!1:String(s)===String(t)}function tS(s){let t={};for(let[e,i]of Object.entries(s))Array.isArray(i)?t[e]=i.slice():Bi(i)?t[e]={...i}:t[e]=i;return t}function jl(s){return JSON.stringify(Object.keys(s).sort().map(t=>[t,s[t]]))}var uo=class extends y{static cssName="sort-control";static defaults={fields:[],value:null,label:"Sort by",labels:{},disabled:!1};render(){let t=this.el??l("div");return this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(t),this.el=t,this._value=sp(this.options.value,this.options.fields),this._disabled=!!(this.options.disabled||!this.options.fields.length),this._direction=j({kind:"ghost",disabled:this._disabled}),this._direction.classList.add("zx-sort-control__direction"),this.listen(this._direction,"click",()=>{this._disabled||!this._value||this.setValue({id:this._value.id,dir:this._value.dir==="asc"?"desc":"asc"})}),this._select=new $(null,{items:eS(this.options.fields),valueKey:"id",labelKey:"label",value:this._value?.id??null,label:this.options.label,filter:"local",disabled:this._disabled,onchange:({detail:e})=>{e.item&&this.setValue({id:e.item.id,dir:this._value?.dir??"asc"})}}),this.listen(this._select.el,"zx-change",e=>e.stopPropagation()),t.replaceChildren(this._direction,this._select.el),this._syncDirection(),t}getValue(){return this._value?{...this._value}:null}setValue(t,{silent:e=!1}={}){let i=sp(t,this.options.fields),n=np(i)!==np(this._value);return this._value=i,this._select.set(i?.id??null,{silent:!0}),this._syncDirection(),n&&!e&&this.emit("change",{value:this.getValue()}),this}enable(){return this._disabled=!this.options.fields.length,this._disabled||this._select.enable(),this._direction.disabled=this._disabled,this}disable(){return this._disabled=!0,this._select.disable(),this._direction.disabled=!0,this}_syncDirection(){let t=this._value?.dir??"asc",e=t==="asc"?"desc":"asc",i={asc:"Ascending",desc:"Descending",...this.options.labels};this._direction.replaceChildren(g(t==="asc"?"arrow-up-wide-short":"arrow-down-wide-short")),this._direction.dataset.direction=t,this._direction.setAttribute("aria-label",`${this.options.label}: ${i[t]}`),this._direction.title=`${i[t]} \u2192 ${i[e]}`}focus(){return this._select.focus(),this}destroy(){this._select?.destroy(),super.destroy(),this._createdRoot||S(this.el,this._snapshot)}};function sp(s,t){if(!t.length)return null;if(s==null)return{id:String(t[0].id),dir:"asc"};if(!t.some(e=>String(e.id)===String(s.id)))throw new RangeError("Unknown sort field");if(s.dir!=="asc"&&s.dir!=="desc")throw new RangeError("Unknown sort direction");return{id:String(s.id),dir:s.dir}}function eS(s){return s.map(t=>({id:String(t.id),label:t.label}))}function np(s){return s?JSON.stringify([s.id,s.dir]):""}var rp=Object.freeze({auto:{icon:null,key:"listToolbar.viewAuto",fallback:"Auto"},table:{icon:"table",key:"listToolbar.viewTable",fallback:"Table"},list:{icon:"list",key:"listToolbar.viewList",fallback:"List"},cards:{icon:"grid",key:"listToolbar.viewCards",fallback:"Cards"},gallery:{icon:"image",key:"listToolbar.viewGallery",fallback:"Gallery"},board:{icon:"columns",key:"listToolbar.viewBoard",fallback:"Board"}}),ho=class extends y{static cssName="list-toolbar";static defaults={search:{},count:null,countText:null,views:[],view:null,tools:[],label:null};constructor(t=null,e={}){super(t,e),this.refs.tools&&this.listen(this.refs.tools,"click",i=>this._toolClick(i)),this.refs.views&&this.listen(this.refs.views,"click",i=>this._viewClick(i)),this.on("viewchange",i=>{let n=this._bound,r=n?.capabilities.setShape;r&&n.view[r](i.detail.view)})}render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._tools=new Map,this._views=rS(this.options.views),this._view=op(this._views,this.options.view,null),this._count=null,this._search=null,this._bound=null,this._adopted=[],this._chooser=null;let t=this.el??l("div");this.el=t,t.setAttribute("role","group"),t.setAttribute("aria-label",this.options.label??this._message("listToolbar.label","List controls"));let e=[],i=this._searchOptions();if(i){this._search=new Ot(null,i);let n=this._search.toElement();n.classList.add("zx-list-toolbar__search"),this._search.on("input",r=>this.emit("search",{value:cp(r)})),this._search.on("submit",r=>this.emit("search",{value:cp(r)})),e.push(n)}return e.push(l("span",{class:"zx-list-toolbar__count",ref:"count",role:"status",ariaLive:"polite",ariaAtomic:"true"})),e.push(l("span",{class:"zx-list-toolbar__spacer"})),e.push(l("div",{class:"zx-list-toolbar__tools",ref:"tools"})),this._views.length>0&&e.push(l("div",{class:"zx-list-toolbar__views",ref:"views",role:"group",ariaLabel:this._message("listToolbar.views","View")})),t.replaceChildren(...e),this.setTools(this.options.tools),this._syncViews(),this.setCount(this.options.count),t}setCount(t){return this._count=up(t),this.refs.count.textContent=oS(t,this._countFormat()),this}getCount(){return this._count}setBadge(t,e){let i=this._tools.get(String(t));return i?(i.badge=dp(e),this._syncTool(i),this):this}setPressed(t,e=!0){let i=this._tools.get(String(t));return i?.toggle?(i.pressed=!!e,i.element.setAttribute("aria-pressed",i.pressed?"true":"false"),this):this}setToolDisabled(t,e=!0){let i=this._tools.get(String(t));return i&&(i.element.disabled=!!e),this}setTools(t){for(let i of this._tools.values())i.element.remove();this._tools=new Map;let e=[];for(let i of nS(t)){let n=this._createTool(i);this._tools.set(n.id,n),e.push(n.element)}return this.refs.tools.prepend(...e),this}getTool(t){return this._tools.get(String(t))?.element??null}getToolsElement(){return this.refs.tools}addTool(t){if(!E(t))throw new TypeError("ListToolbar.addTool() needs an Element");return this.refs.tools.contains(t)?this:(this._adopted.push(ap(t)),this.refs.tools.append(t),this)}setView(t,{silent:e=!1}={}){let i=op(this._views,t,this._view);if(i===null||i===this._view)return this;let n=this._view;return this._view=i,this._syncViews(),e||this.emit("viewchange",{view:i,previous:n}),this}getView(){return this._view}getSearch(){return this._search?this._search.get():""}setSearch(t,e={}){return this._search?.set(t,e),this}focusSearch(){return this._search?.focus(),this}bind(t){if(t===null||typeof t!="object")throw new TypeError("ListToolbar.bind() needs a record view");this.unbind();let e=iS(t);if(this._bound={view:t,capabilities:e},e.getShape){let i=t[e.getShape]();i!=null&&this.setView(String(i),{silent:!0})}return this._mountFieldControls(t),this}unbind(){let t=this._bound;if(this._bound=null,this._chooser){let e=this._chooser;this._chooser=null;let i=t?.view;e.viaView&&i&&typeof i.mountFieldControls=="function"?this.el.contains(e.element)&&i.mountFieldControls(null):lp(e,this.el)}return this}destroy(){if(this._destroyed)return;this._destroyed=!0,this.unbind();for(let e of this._adopted.reverse())lp(e,this.el);this._adopted=[],this._search?.destroy(),this._search=null;let t=this.el;super.destroy(),this._createdRoot||S(t,this._snapshot)}_searchOptions(){let t=this.options.search;if(t===!1||t===null)return null;let e=t===!0||t===void 0?{}:t;if(typeof e!="object"||Array.isArray(e))throw new TypeError("ListToolbar search must be an options object or false");return{...e,placeholder:String(e.placeholder??this._message("listToolbar.search","Search"))}}_countFormat(){let t=this.options.countText;return typeof t=="function"?e=>String(t(e)):e=>this._message("listToolbar.results","%1 results",e.toLocaleString())}_createTool(t){let e=l("button",{class:"zx-list-toolbar__tool",type:"button",disabled:t.disabled,dataset:{toolId:t.id},ariaPressed:t.pressed===null?null:String(t.pressed)});t.icon&&e.append(g(t.icon,{size:16})),t.label!==""&&e.append(l("span",{class:"zx-list-toolbar__tool-label"},t.label));let i={id:t.id,element:e,label:t.label||t.title||t.id,title:t.title,badge:t.badge,badgeKind:t.badgeKind,badgeEl:null,toggle:t.pressed!==null,pressed:!!t.pressed,onclick:t.onclick};return this._syncTool(i),i}_syncTool(t){if(t.badgeEl?.remove(),t.badgeEl=null,t.badge!==null){let i=ht({label:t.badge,kind:t.badgeKind,size:"sm"});i.classList.add("zx-list-toolbar__badge"),i.setAttribute("aria-hidden","true"),t.badgeEl=i,t.element.append(i)}let e=sS(t.label,t.badge,this._message("listToolbar.toolBadge","%1 (%2)"));t.element.setAttribute("aria-label",e),t.element.setAttribute("title",t.title??e)}_toolClick(t){let i=t.target?.closest?.("[data-tool-id]");if(!i||!this.refs.tools.contains(i))return;let n=this._tools.get(String(i.dataset.toolId));n&&(n.toggle&&this.setPressed(n.id,!n.pressed),this.emit("action",{id:n.id,pressed:n.toggle?n.pressed:null,tool:n.element}),n.onclick?.(t))}_viewClick(t){let i=t.target?.closest?.("[data-view]");!i||!this.refs.views.contains(i)||this.setView(String(i.dataset.view))}_syncViews(){if(!this.refs.views)return;let t=this.refs.views;t.childElementCount!==this._views.length&&t.replaceChildren(...this._views.map(e=>{let i=e.label??this._viewLabel(e.id),n=l("button",{class:"zx-list-toolbar__view",type:"button",title:i,dataset:{view:e.id}}),r=e.icon===void 0?rp[e.id]?.icon??null:e.icon;return r&&n.append(g(r,{size:16})),n.append(l("span",{class:"zx-list-toolbar__view-label"},i)),n}));for(let e of t.children){let i=e.dataset.view===this._view;e.setAttribute("aria-pressed",i?"true":"false")}}_viewLabel(t){let e=rp[t];return e?this._message(e.key,e.fallback):t}_mountFieldControls(t){if(t.options?.fieldControls===!1)return;let e=this._findFieldControls(t);if(!(!e||this.el.contains(e))){if(typeof t.mountFieldControls=="function"){let i=t.mountFieldControls(this.refs.tools);E(i)&&this.el.contains(i)&&(this._chooser={element:i,parent:null,next:null,viaView:!0});return}this._chooser=ap(e),this.refs.tools.append(e)}}_findFieldControls(t){if(typeof t.getFieldControls=="function"){let i=t.getFieldControls();return E(i)?i:null}let e=typeof t.toElement=="function"?t.toElement():null;return E(e)?e.querySelector(".zx-record-view__field-controls"):null}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function iS(s){let t=s,e=n=>!!t&&typeof t[n]=="function",i=(...n)=>n.find(e)??null;return{isRecordView:e("setViewState")&&e("getViewState")&&e("on")&&e("toElement"),setShape:i("setView","setViewShape"),getShape:i("getView","getViewShape"),events:e("on")&&e("emit"),fieldControls:e("getFieldControls")}}function dp(s){return s==null||s===!1||s===""?null:String(s)}function sS(s,t,e="%1 (%2)"){let i=String(s??"");return t==null||t===""?i:T(e,[i,String(t)])}function nS(s){if(s!=null&&!Array.isArray(s))throw new TypeError("ListToolbar tools must be an array");let t=new Set,e=[];for(let i of s??[]){if(i==null)continue;if(typeof i!="object"||Array.isArray(i))throw new TypeError("ListToolbar tools must be tool descriptors");let n=String(i.id??"").trim();if(!n)throw new TypeError("Every ListToolbar tool needs an id");if(t.has(n))throw new TypeError(`Duplicate ListToolbar tool: ${n}`);t.add(n),e.push({id:n,label:String(i.label??""),icon:i.icon??null,badge:dp(i.badge),badgeKind:String(i.badgeKind??"accent"),pressed:i.pressed===void 0?null:!!i.pressed,disabled:!!i.disabled,title:i.title===void 0?null:String(i.title),onclick:typeof i.onclick=="function"?i.onclick:null})}return e}function rS(s){if(s!=null&&!Array.isArray(s))throw new TypeError("ListToolbar views must be an array");let t=new Set,e=[];for(let i of s??[]){if(i==null)continue;let n=typeof i=="object"?i:{id:i},r=String(n.id??"").trim();if(!r||t.has(r))continue;t.add(r);let o={id:r};n.label!==void 0&&(o.label=String(n.label)),n.icon!==void 0&&(o.icon=n.icon),e.push(o)}return e}function op(s,t,e){let i=s.map(n=>n.id);return i.length===0?null:t!=null&&i.includes(String(t))?String(t):e===null?i[0]:i.includes(e)?e:i[0]}function oS(s,t){let e=up(s);return e===null?"":String(t(e))}function up(s){if(s==null||s===""||typeof s=="boolean")return null;let t=Number(s);return Number.isFinite(t)?t:null}function ap(s){return{element:s,parent:s.parentNode,next:s.nextSibling}}function lp(s,t){let{element:e,parent:i,next:n}=s;if(t?.contains(e)){if(!i){e.remove();return}n&&n.parentNode===i?i.insertBefore(e,n):i.appendChild(e)}}function cp(s){return String(s.detail?.value??"")}var hp=Object.freeze({text:{icon:"type",key:"viewSettings.typeText",label:"Text"},number:{icon:"hash",key:"viewSettings.typeNumber",label:"Number"},money:{icon:"hash",key:"viewSettings.typeMoney",label:"Money"},date:{icon:"calendar",key:"viewSettings.typeDate",label:"Date"},datetime:{icon:"calendar",key:"viewSettings.typeDatetime",label:"Date and time"},time:{icon:"clock",key:"viewSettings.typeTime",label:"Time"},boolean:{icon:"check",key:"viewSettings.typeBoolean",label:"Checkbox"},select:{icon:"circle-chevron-down",key:"viewSettings.typeSelect",label:"Select"},status:{icon:"circle-chevron-down",key:"viewSettings.typeStatus",label:"Status"},priority:{icon:"circle-chevron-down",key:"viewSettings.typePriority",label:"Priority"},entity:{icon:"folder",key:"viewSettings.typeEntity",label:"Linked record"},tags:{icon:"tag",key:"viewSettings.typeTags",label:"Tags"},url:{icon:"link-2",key:"viewSettings.typeUrl",label:"URL"},email:{icon:"mail",key:"viewSettings.typeEmail",label:"Email"},image:{icon:"image",key:"viewSettings.typeImage",label:"Image"},file:{icon:"file",key:"viewSettings.typeFile",label:"File"},rating:{icon:"star",key:"viewSettings.typeRating",label:"Rating"}}),mo=Object.freeze({string:"text",textarea:"text",int:"number",integer:"number",float:"number",decimal:"number",percent:"number",currency:"money",enum:"select",bool:"boolean",checkbox:"boolean",link:"url"}),aS=new Set(["text","select","status","priority","boolean","entity"]),fp=Object.freeze(["fields","grouping","board"]),lS=4,bp=32,yp=12,go=class extends y{static cssName="view-settings";static defaults={fields:[],fieldOrder:[],hiddenFields:[],groupBy:null,grouping:!0,board:!1,types:{},searchThreshold:8,headingLevel:3,label:null};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._fields=$l(this.options.fields),this._ownIds=new Set(this._fields.map(r=>r.id)),this._order=po(this._fields,this.options.fieldOrder),this._hidden=_o(this._fields,this.options.hiddenFields,!0);let t=this._fields.length?this._fields.map(r=>r.id):null;this._groupBy=Re(this.options.groupBy,t),this._board=Le(this.options.board,t);let e=this.options.board;this._boardFields=e&&Array.isArray(e.fields)?e.fields.map(String):null,this._sections=gS(this.options.sections,this.options),this._query="",this._search=null,this._groupSelect=null,this._columnSelect=null,this._laneSelect=null,this._emptyToggle=null,this._bound=null,this._syncing=!1,this._rendering=!1,this._grab=null,this._drag=null,this._announceToken=0,this._level=bS(this.options.headingLevel);let i=this.el??l("div");this.el=i,i.setAttribute("role","region"),i.setAttribute("aria-label",this.options.label??this._message("viewSettings.label","View settings")),this._instructionsId=x("zx-view-settings-help");let n=[];for(let r of this._sections)r==="fields"&&n.push(this._buildFieldsSection()),r==="grouping"&&n.push(this._buildGroupSection()),r==="board"&&n.push(this._buildBoardSection());if(n.push(l("span",{class:"zx-view-settings__instructions",id:this._instructionsId,hidden:!0},this._message("viewSettings.instructions","Press Space to pick the field up, the arrow keys to move it, Space again to drop it, or Escape to cancel."))),n.push(l("div",{class:"zx-view-settings__status",ref:"status",role:"status",ariaLive:"polite",ariaAtomic:"true"})),i.replaceChildren(...n),this.refs.list){let r=this.refs.list;this.listen(r,"click",o=>this._onShownClick(o)),this.listen(r,"keydown",o=>this._onHandleKeydown(o)),this.listen(r,"focusout",o=>this._onHandleFocusout(o)),this.listen(r,"pointerdown",o=>this._onPointerDown(o)),this.listen(r,"pointermove",o=>this._onPointerMove(o)),this.listen(r,"pointerup",o=>this._onPointerUp(o)),this.listen(r,"pointercancel",()=>this._cancelDrag()),this.listen(r,"lostpointercapture",()=>{this._drag&&!this._drag.ending&&this._cancelDrag()}),this.listen(this.refs.hidden,"click",o=>this._onHiddenClick(o)),this.listen(i.ownerDocument??document,"keydown",o=>{let a=o;a.key!=="Escape"||!this._drag?.active||(a.preventDefault(),a.stopPropagation(),this._cancelDrag(!0))},{capture:!0}),this._syncSearch(),this._renderFields()}return this._syncGroupControls(),i}getState(){return{fieldOrder:[...this._order],hiddenFields:this._order.filter(t=>this._hidden.has(t)),groupBy:this._groupBy,board:this._board?{...this._board}:null}}setState(t,{silent:e=!1}={}){this._settle();let i=t&&typeof t=="object"?t:{},n=this._fields.length?this._fields.map(d=>d.id):null,r=!1,o=!1;if(Array.isArray(i.fieldOrder)){let d=po(this._fields,i.fieldOrder);r=!Vi(d,this._order),this._order=d}if(Array.isArray(i.hiddenFields)){let d=_o(this._fields,i.hiddenFields,!1);o=!yS(d,this._hidden),this._hidden=d}let a=!1;if(Object.hasOwn(i,"groupBy")){let d=Re(i.groupBy,n);a=d!==this._groupBy,this._groupBy=d}let c=!1;if(Object.hasOwn(i,"board")&&this._board){let d=Le({...this._board,...i.board??{}},n);c=!gp(d,this._board),this._board=d}return this._renderFields(),this._syncGroupControls(),(r||o)&&this._pushToView(),e?this:(r&&this._emitOrder(),o&&this._emitVisibility(),a&&this._emitGroup(),c&&this._emitBoard(),this)}setFields(t){this._settle();let e=this._order.filter(a=>this._hidden.has(a)),i=[...this._order];this._fields=$l(t),this._ownIds=new Set(this._fields.map(a=>a.id)),this._order=po(this._fields,i);let n=new Set(i),r=[...e,...this._fields.filter(a=>!n.has(a.id)&&a.visible===!1).map(a=>a.id)];this._hidden=_o(this._fields,r,!1);let o=this._fields.map(a=>a.id);return this._groupBy=Re(this._groupBy,o),this._board&&(this._board=Le(this._board,o)),this._syncSearch(),this._renderFields(),this._syncGroupControls(),this}getFields(){let t=new Map(this._fields.map(e=>[e.id,e]));return this._order.map(e=>({...t.get(e)}))}showField(t){let e=String(t);if(!this._hidden.has(e))return this;this._settle();let i=uS(this._order,this._hidden,e),n=!Vi(i.order,this._order);return this._order=i.order,this._hidden=new Set(i.hidden),this._renderFields(),this._pushToView(),n&&this._emitOrder(!1),this._emitVisibility(),this}hideField(t){let e=String(t);return this._canHide(e)?(this._settle(),this._hidden.add(e),this._renderFields(),this._pushToView(),this._emitVisibility(),this):this}moveField(t,e){this._settle();let i=fo(this._order,this._hidden,this._lockedIds(),String(t),e);return Vi(i,this._order)?this:(this._order=i,this._renderFields(),this._pushToView(),this._emitOrder(),this)}bind(t,e={}){let i=t;if(!i||typeof i.getFields!="function"||typeof i.setFieldOrder!="function"||typeof i.setFieldVisible!="function"||typeof i.getHiddenFields!="function")throw new TypeError("ViewSettings.bind() needs a record view");this.unbind();let n=new AbortController;this._bound={view:i,controller:n},i.addEventListener("statechange",a=>{if(this._syncing)return;let c=a.detail?.reason;this._pullFromView(c==="fields"||c==="restore")},{signal:n.signal}),this._pullFromView(!0);let r=i.options??{},o=this._fields.map(a=>a.id);return typeof r.groupBy=="string"&&(this._groupBy=Re(r.groupBy,o)),this._board&&(e.board?this._board=Le(e.board,o):typeof r.columnBy=="string"&&(this._board=Le({columnBy:r.columnBy,swimlaneBy:typeof r.swimlaneBy=="string"?r.swimlaneBy:null,showEmptyColumns:r.showEmptyColumns!==!1},o))),this._syncGroupControls(),this}unbind(){return this._bound&&(this._bound.controller.abort(),this._bound=null),this}focus(){return this._search?(this._search.focus(),this):(this.el.querySelector(".zx-view-settings__list button:not(:disabled), .zx-view-settings__hidden button:not(:disabled), .zx-select__input, .zx-toggle")?.focus(),this)}destroy(){if(this._destroyed)return;this._destroyed=!0,this.unbind(),this._drag&&this._endDrag(this._drag);for(let e of[this._search,this._groupSelect,this._columnSelect,this._laneSelect,this._emptyToggle])e?.destroy();this._search=null,this._groupSelect=null,this._columnSelect=null,this._laneSelect=null,this._emptyToggle=null;let t=this.el;super.destroy(),this._createdRoot||S(t,this._snapshot)}_heading(t,e=0,i="zx-view-settings__heading"){let n=x("zx-view-settings-heading"),r=Math.min(6,this._level+e);return{element:l(`h${r}`,{class:i,id:n},t),id:n}}_buildFieldsSection(){let t=this._heading(this._message("viewSettings.fields","Fields")),e=this._heading("",1,"zx-view-settings__subheading"),i=this._heading("",1,"zx-view-settings__subheading");return this.refs.shownHeading=e.element,this.refs.hiddenHeading=i.element,l("section",{class:"zx-view-settings__section",ref:"fieldsSection",dataset:{section:"fields"},ariaLabelledby:t.id},t.element,e.element,l("div",{class:"zx-view-settings__frame",ref:"frame"},l("ul",{class:"zx-view-settings__list",ref:"list",ariaLabelledby:e.id}),l("div",{class:"zx-view-settings__drop-indicator",ref:"indicator",ariaHidden:"true",hidden:!0})),i.element,l("div",{class:"zx-view-settings__search-slot",ref:"searchSlot"}),l("ul",{class:"zx-view-settings__hidden",ref:"hidden",ariaLabelledby:i.id}),l("p",{class:"zx-view-settings__empty",ref:"empty",hidden:!0}))}_buildGroupSection(){let t=this._message("viewSettings.group","Group by"),e=this._heading(t);this._groupSelect=new $(null,{items:[],clearable:!0,noneLabel:this._message("viewSettings.none","None"),placeholder:this._message("viewSettings.none","None"),label:t,renderItem:n=>this._optionContent(n),renderValueAdornment:n=>this._typeGlyph(n.type),msg:this.options.msg}),this._groupSelect.on("change",n=>{let r=n.detail.value;this._setGroup(r==null?null:String(r))});let i=this._groupSelect.toElement();return i.classList.add("zx-view-settings__group"),l("section",{class:"zx-view-settings__section",dataset:{section:"grouping"},ariaLabelledby:e.id},e.element,i)}_buildBoardSection(){let t=this._heading(this._message("viewSettings.board","Board")),e=this._message("viewSettings.columns","Columns"),i=this._message("viewSettings.swimlanes","Swim lanes"),n=a=>this._optionContent(a),r=a=>this._typeGlyph(a.type);this._columnSelect=new $(null,{items:[],placeholder:this._message("viewSettings.chooseField","Choose a field"),label:e,renderItem:n,renderValueAdornment:r,msg:this.options.msg}),this._laneSelect=new $(null,{items:[],clearable:!0,noneLabel:this._message("viewSettings.none","None"),placeholder:this._message("viewSettings.none","None"),label:i,renderItem:n,renderValueAdornment:r,msg:this.options.msg}),this._emptyToggle=new J(null,{label:this._message("viewSettings.emptyColumns","Show empty columns"),checked:this._board?.showEmptyColumns!==!1}),this._columnSelect.on("change",a=>{let c=a.detail.value;this._setBoard({columnBy:c==null?null:String(c)})}),this._laneSelect.on("change",a=>{let c=a.detail.value;this._setBoard({swimlaneBy:c==null?null:String(c)})}),this._emptyToggle.on("change",a=>{this._setBoard({showEmptyColumns:!!a.detail.checked})});let o=this._emptyToggle.toElement();return o.classList.add("zx-view-settings__toggle"),l("section",{class:"zx-view-settings__section zx-view-settings__board",dataset:{section:"board"},ariaLabelledby:t.id},t.element,l("div",{class:"zx-view-settings__setting"},l("span",{class:"zx-view-settings__setting-label",ariaHidden:"true"},e),this._columnSelect.toElement()),l("div",{class:"zx-view-settings__setting"},l("span",{class:"zx-view-settings__setting-label",ariaHidden:"true"},i),this._laneSelect.toElement()),o)}_syncSearch(){let t=this.refs.searchSlot;if(!t)return;let e=this._fields.length>Math.max(0,Number(this.options.searchThreshold)||0);if(e&&!this._search){let i=this._message("viewSettings.search","Find a field");this._search=new Ot(null,{placeholder:i,debounce:0,msg:this.options.msg});let n=this._search.toElement();n.classList.add("zx-view-settings__search"),n.setAttribute("aria-label",i);let r=this._search.refs.input;this.listen(r,"input",()=>this._setQuery(r.value)),this._search.on("clear",()=>this._setQuery("")),this._search.on("submit",()=>this._addFirstMatch()),t.replaceChildren(n)}else!e&&this._search&&(this._search.destroy(),this._search=null,t.replaceChildren(),this._query="")}_renderFields(t=null,{keepGrab:e=!1}={}){let i=this.refs.list;if(!i)return;if(this._drag&&this._endDrag(this._drag),this._grab&&!e){let h=this._grab.id;this._grab=null,this._announceCanceled(h)}let n=t??this._activePart();this._rendering=!0;let r=new Map(this._fields.map(h=>[h.id,h])),o=this._order.filter(h=>!this._hidden.has(h)),a=this._order.filter(h=>this._hidden.has(h)),c=o.length>1;i.replaceChildren(...o.map(h=>this._shownRow(r.get(h),c))),this.refs.shownHeading.textContent=this._message("viewSettings.shown","Shown (%1)",o.length),this.refs.hiddenHeading.textContent=this._message("viewSettings.hidden","Hidden (%1)",a.length);let d=a.map(h=>r.get(h)).filter(h=>dS(h,this._query,this._typeLabel(h.type)));this.refs.hidden.replaceChildren(...d.map(h=>this._hiddenRow(h)));let u=this.refs.empty;if(d.length===0?(u.textContent=a.length===0?this._message("viewSettings.allShown","Every field is shown."):this._message("viewSettings.noMatch","No hidden field matches \u201C%1\u201D.",this._query.trim()),u.hidden=!1):u.hidden=!0,this.refs.hidden.hidden=d.length===0,this._grab){let h=this._row(this._grab.id);h&&(h.dataset.state="grabbed"),h?.querySelector(".zx-view-settings__handle")?.setAttribute("aria-pressed","true")}this._rendering=!1,n&&this._focusPart(n)}_shownRow(t,e){let i=!!t.locked,n=this._message("viewSettings.reorder","Reorder %1",t.label),r=this._message("viewSettings.hide","Hide %1",t.label),o=i?l("span",{class:"zx-view-settings__handle",dataset:{placeholder:"true"},ariaHidden:"true"}):l("button",{class:"zx-view-settings__handle",type:"button",ariaLabel:n,ariaDescribedby:this._instructionsId,ariaPressed:"false",title:n,dataset:{action:"handle"}},g("drag",{size:16})),a=i?l("span",{class:"zx-view-settings__lock",title:this._message("viewSettings.locked","Always shown")},g("lock",{size:14}),l("span",{class:"zx-view-settings__sr"},this._message("viewSettings.locked","Always shown"))):l("button",{class:"zx-view-settings__hide",type:"button",ariaLabel:r,title:e?r:this._message("viewSettings.lastField","At least one field stays shown"),disabled:!e,dataset:{action:"hide"}},g("eye",{size:16}));return l("li",{class:"zx-view-settings__row",dataset:{fieldId:t.id,locked:i?"true":null}},o,l("span",{class:"zx-view-settings__label"},t.label),this._typeBadge(t.type),a)}_hiddenRow(t){let e=this._message("viewSettings.addField","Add %1",t.label);return l("li",{class:"zx-view-settings__row",dataset:{fieldId:t.id}},l("span",{class:"zx-view-settings__label"},$s(t.label,this._query)),this._typeBadge(t.type),l("button",{class:"zx-btn zx-view-settings__add",type:"button",ariaLabel:e,title:e,dataset:{kind:"ghost",size:"sm",action:"add"}},g("plus",{size:14}),l("span",{},this._message("viewSettings.add","Add"))))}_typeBadge(t){let e=this._typeLabel(t);return l("span",{class:"zx-view-settings__type",title:e},this._typeGlyph(t),l("span",{class:"zx-view-settings__sr"},`, ${e}`))}_typeGlyph(t){return g(pp(t,this.options.types).icon,{size:14})}_typeLabel(t){let e=pp(t,this.options.types);return e.key?this._message(e.key,e.label):e.label}_optionContent(t){return l("span",{class:"zx-view-settings__option",title:this._typeLabel(t.type)},this._typeGlyph(t.type),l("span",{},t.name))}_syncGroupControls(){let t=_p(this._fields,this.options.grouping),e=_p(this._fields,this._boardFields?{fields:this._boardFields}:this.options.grouping),i=n=>n.map(r=>{let o=this._fields.find(a=>a.id===r);return{ID:o.id,name:o.label,type:o.type}});this._groupSelect&&(this._groupSelect.setItems(i(t)),this._groupSelect.set(this._groupBy,{silent:!0})),this._board&&this._columnSelect&&this._laneSelect&&this._emptyToggle&&(this._columnSelect.setItems(i(e)),this._columnSelect.set(this._board.columnBy,{silent:!0}),this._laneSelect.setItems(i(e.filter(n=>n!==this._board?.columnBy))),this._laneSelect.set(this._board.swimlaneBy,{silent:!0}),this._emptyToggle.set(this._board.showEmptyColumns!==!1,{silent:!0}))}_setQuery(t){t!==this._query&&(this._query=t,this._renderFields())}_addFirstMatch(){let e=this.refs.hidden?.querySelector(".zx-view-settings__row")?.dataset.fieldId;e&&this._addFromPanel(e,!1)}_addFromPanel(t,e){let i=[...this.refs.hidden.querySelectorAll(".zx-view-settings__row")],n=i.findIndex(c=>c.dataset.fieldId===t),r=(i[n+1]??i[n-1])?.dataset.fieldId;this.showField(t);let o=this._field(t),a=this._order.filter(c=>!this._hidden.has(c));this._announce(this._message("viewSettings.added","%1 added at position %2 of %3",o?.label??t,a.indexOf(t)+1,a.length)),e&&(r?this._focusPart({id:r,part:"add"}):this._search?this._search.focus():this._focusPart({id:t,part:"hide"}))}_onHiddenClick(t){let n=t.target?.closest?.('[data-action="add"]')?.closest(".zx-view-settings__row")?.dataset.fieldId;n&&this._addFromPanel(n,!0)}_onShownClick(t){let n=t.target?.closest?.('[data-action="hide"]')?.closest(".zx-view-settings__row")?.dataset.fieldId;if(!n||!this._canHide(n))return;let r=this._order.filter(d=>!this._hidden.has(d)),o=r.indexOf(n),c=[...r.slice(o+1),...r.slice(0,o).reverse()].find(d=>this._canHideAfter(d,n));this.hideField(n),this._announce(this._message("viewSettings.hiddenField","%1 hidden",this._field(n)?.label??n)),c?this._focusPart({id:c,part:"hide"}):this.focus()}_onHandleKeydown(t){let i=t.target?.closest?.('[data-action="handle"]')?.closest(".zx-view-settings__row")?.dataset.fieldId;if(!i)return;let n=this._movableIds(),r=n.indexOf(i);if(r<0)return;let o=this._grab?.id===i,a=null;if(t.key==="ArrowUp"?a=r-1:t.key==="ArrowDown"?a=r+1:t.key==="Home"?a=0:t.key==="End"&&(a=n.length-1),a!==null){if(t.preventDefault(),a<0||a>=n.length||a===r)return;this._moveFromKeyboard(i,a,!o);return}if(t.key===" "||t.key==="Enter"){t.preventDefault(),o?this._drop():this._pickUp(i);return}t.key==="Escape"&&o&&(t.preventDefault(),t.stopPropagation(),this._cancelGrab())}_onHandleFocusout(t){if(this._rendering||!this._grab)return;t.target?.closest?.('[data-action="handle"]')?.closest(".zx-view-settings__row")?.dataset.fieldId===this._grab.id&&this._drop(this._partOf(t.relatedTarget))}_moveFromKeyboard(t,e,i){let n=fo(this._order,this._hidden,this._lockedIds(),t,e);Vi(n,this._order)||(this._order=n,this._renderFields({id:t,part:"handle"},{keepGrab:!i}),this._announceMove(t),i&&(this._pushToView(),this._emitOrder()))}_pickUp(t){this._grab={id:t,original:[...this._order]},this._renderFields({id:t,part:"handle"},{keepGrab:!0});let{position:e,total:i}=this._position(t);this._announce(this._message("viewSettings.grabbed","%1 picked up, position %2 of %3. Use the arrow keys to move it, Space to drop it, Escape to cancel.",this._field(t)?.label??t,e,i))}_drop(t){let e=this._grab;if(!e)return;this._grab=null;let i=!Vi(e.original,this._order),n=this._row(e.id)?.contains(this.el.ownerDocument?.activeElement??null);this._renderFields(t!==void 0?t:n?{id:e.id,part:"handle"}:null);let{position:r,total:o}=this._position(e.id);this._announce(this._message("viewSettings.dropped","%1 dropped at position %2 of %3",this._field(e.id)?.label??e.id,r,o)),i&&(this._pushToView(),this._emitOrder())}_cancelGrab(){let t=this._grab;t&&(this._grab=null,this._order=t.original,this._renderFields({id:t.id,part:"handle"}),this._announceCanceled(t.id))}_settle(){this._drag&&this._cancelDrag(!0),this._grab&&this._cancelGrab()}_announceCanceled(t){let{position:e,total:i}=this._position(t);this._announce(this._message("viewSettings.canceled","Move canceled. %1 is back at position %2 of %3",this._field(t)?.label??t,e,i))}_onPointerDown(t){if(t.button!==0||this._drag)return;let e=t.target?.closest?.('[data-action="handle"]'),i=e?.closest(".zx-view-settings__row")??null,n=i?.dataset.fieldId;if(!(!e||!i||!n)&&!(this._grab&&(this._drop(),i=this._row(n),e=i?.querySelector('[data-action="handle"]')??null,!i||!e))){this._drag={id:n,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,y:t.clientY,active:!1,ending:!1,handle:e,row:i,target:null,scroller:null,startScroll:0,lastScroll:0,frame:0};try{e.setPointerCapture(t.pointerId)}catch{}}}_onPointerMove(t){let e=this._drag;if(!(!e||t.pointerId!==e.pointerId)){if(!e.row.isConnected){this._cancelDrag();return}if(e.y=t.clientY,!e.active){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<=lS)return;this._beginDrag(e)}t.preventDefault(),this._positionDrag(e)}}_onPointerUp(t){let e=this._drag;if(!e||t.pointerId!==e.pointerId)return;if(!e.active||!e.row.isConnected){this._endDrag(e);return}t.preventDefault(),e.y=t.clientY,this._positionDrag(e);let i=e.target;this._endDrag(e);let n=i===null?this._order:fo(this._order,this._hidden,this._lockedIds(),e.id,i);if(Vi(n,this._order)){this._renderFields({id:e.id,part:"handle"});return}this._order=n,this._renderFields({id:e.id,part:"handle"}),this._announceMove(e.id),this._pushToView(),this._emitOrder()}_beginDrag(t){t.active=!0,t.row.dataset.dragging="true",this.el.setAttribute("data-dragging","true"),this.el.ownerDocument?.getSelection?.()?.removeAllRanges(),t.scroller=_S(this.refs.list),t.startScroll=t.scroller.scrollTop,t.lastScroll=t.startScroll,this._scheduleAutoScroll(t);let{position:e,total:i}=this._position(t.id);this._announce(this._message("viewSettings.dragging","%1 picked up, position %2 of %3",this._field(t.id)?.label??t.id,e,i))}_scheduleAutoScroll(t){t.frame=requestAnimationFrame(()=>{if(t.frame=0,this._drag!==t||!t.active||!t.scroller)return;let e=pS(t.y,mS(t.scroller),this.refs.list.getBoundingClientRect(),bp,yp);e!==0&&(t.scroller.scrollTop+=e),t.scroller.scrollTop!==t.lastScroll&&this._positionDrag(t),this._scheduleAutoScroll(t)})}_positionDrag(t){let e=t.scroller?t.scroller.scrollTop:0;t.lastScroll=e;let i=t.y-t.startY+(e-t.startScroll);t.row.style.transform=`translateY(${Math.round(i)}px)`,this._updateDropTarget(t,t.y)}_updateDropTarget(t,e){let i=this.refs.frame.getBoundingClientRect(),n=[...this.refs.list.children].filter(_=>_!==t.row).map(_=>{let m=_.getBoundingClientRect();return{id:_.dataset.fieldId??"",top:m.top-i.top,bottom:m.bottom-i.top,middle:m.top+m.height/2}}),r=hS(n.map(_=>_.middle),e),o=this._lockedIds(),a=n.slice(0,r).filter(_=>!o.includes(_.id)).length;t.target=a;let c=fo(this._order,this._hidden,o,t.id,a).filter(_=>!this._hidden.has(_)),d=c[c.indexOf(t.id)+1],u=n.find(_=>_.id===d),h=n.at(-1),f=this.refs.indicator,p=u?u.top:h?h.bottom:0;f.style.insetBlockStart=`${Math.round(p)}px`,f.hidden=!1}_endDrag(t){t.ending=!0,t.frame&&cancelAnimationFrame(t.frame),t.frame=0;try{t.handle.releasePointerCapture(t.pointerId)}catch{}t.row.style.transform="",delete t.row.dataset.dragging,this.el.removeAttribute("data-dragging");let e=this.refs.indicator;e&&(e.hidden=!0),this._drag===t&&(this._drag=null)}_cancelDrag(t=!1){let e=this._drag;if(!e)return;let i=e.active;if(this._endDrag(e),!!i&&t){let{position:n,total:r}=this._position(e.id);this._announce(this._message("viewSettings.canceled","Move canceled. %1 is back at position %2 of %3",this._field(e.id)?.label??e.id,n,r))}}_setGroup(t){t!==this._groupBy&&(this._groupBy=t,this._emitGroup())}_setBoard(t){if(!this._board)return;let e=this._fields.map(n=>n.id),i=Le({...this._board,...t},e);gp(i,this._board)||(this._board=i,this._syncGroupControls(),this._emitBoard())}_emitOrder(t=!0){this.emit("fieldorderchange",{order:[...this._order]}),t&&this._emitChange("order")}_emitVisibility(){let t=this.getState();this.emit("fieldvisibilitychange",{visible:t.fieldOrder.filter(e=>!this._hidden.has(e)),hidden:t.hiddenFields}),this._emitChange("visibility")}_emitGroup(){this.emit("groupchange",{field:this._groupBy}),this._emitChange("group")}_emitBoard(){this._board&&(this.emit("boardchange",{board:{...this._board}}),this._emitChange("board"))}_emitChange(t){this.emit("change",{state:this.getState(),reason:t})}_pushToView(){let t=this._bound;if(!t)return;let e=t.view;this._syncing=!0;try{let i=new Set((e.getFieldOrder?.()??[]).map(String)),n=this._order.filter(o=>i.size===0||i.has(o));e.setFieldOrder(n);let r=new Set((e.getHiddenFields()??[]).map(String));for(let o of n)!this._hidden.has(o)&&r.has(o)&&e.setFieldVisible(o,!0);for(let o of n)this._hidden.has(o)&&!r.has(o)&&e.setFieldVisible(o,!1)}finally{this._syncing=!1}}_pullFromView(t){let e=this._bound;if(!e)return;let i=e.view;if(this._settle(),t){let r=new Map(this._fields.map(a=>[a.id,a])),o=i.getFields().filter(a=>this._ownIds.size===0||this._ownIds.has(String(a.id))).map(a=>fS(r.get(String(a.id))??null,a));this._fields=$l(o),this._syncSearch()}this._order=po(this._fields,i.getFieldOrder?.()??this._order),this._hidden=_o(this._fields,i.getHiddenFields(),!1,!0);let n=this._fields.map(r=>r.id);this._groupBy=Re(this._groupBy,n),this._board&&(this._board=Le(this._board,n)),this._renderFields(),t&&this._syncGroupControls()}_lockedIds(){return this._fields.filter(t=>t.locked).map(t=>t.id)}_movableIds(){let t=new Set(this._lockedIds());return this._order.filter(e=>!this._hidden.has(e)&&!t.has(e))}_field(t){return this._fields.find(e=>e.id===t)}_canHide(t){let e=this._field(t);return!e||e.locked||this._hidden.has(t)?!1:this._order.filter(i=>!this._hidden.has(i)).length>1}_canHideAfter(t,e){let i=this._field(t);return!i||i.locked?!1:this._order.filter(n=>!this._hidden.has(n)&&n!==e).length>1}_row(t){return[...this.refs.list?.children??[]].find(e=>e.dataset.fieldId===t)??null}_position(t){let e=this._order.filter(i=>!this._hidden.has(i));return{position:e.indexOf(t)+1,total:e.length}}_announceMove(t){let{position:e,total:i}=this._position(t);this._announce(this._message("viewSettings.moved","%1 moved to position %2 of %3",this._field(t)?.label??t,e,i))}_activePart(){return this._partOf(this.el.ownerDocument?.activeElement??null)}_partOf(t){let e=t;if(!e||!this.el.contains(e))return null;let i=e.dataset?.action,n=e.closest(".zx-view-settings__row")?.dataset.fieldId;return!n||i!=="handle"&&i!=="hide"&&i!=="add"?null:{id:n,part:i}}_focusPart(t){let i=[...(t.part==="add"?this.refs.hidden:this.refs.list)?.children??[]].find(r=>r.dataset.fieldId===t.id),n=i?.querySelector(`[data-action="${t.part}"]`)??null;n&&n.disabled&&(n=null),!n&&i&&(n=i.querySelector("button:not(:disabled)")),n?.focus()}_announce(t){let e=this.refs.status;if(!e)return;let i=++this._announceToken;e.textContent="",queueMicrotask(()=>{i===this._announceToken&&e.isConnected&&(e.textContent=t)})}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function $l(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("ViewSettings fields must be an array");let t=new Set,e=[];return s.forEach((i,n)=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`ViewSettings field at index ${n} must be an object`);let r=String(i.id??"").trim();if(!r)throw new TypeError(`ViewSettings field at index ${n} requires an id`);if(t.has(r))throw new TypeError(`Duplicate ViewSettings field: ${r}`);t.add(r);let o={...i,id:r,label:String(i.label??wp(r)),type:String(i.type??"text").trim()||"text",locked:!!i.locked};i.groupable!==void 0&&(o.groupable=!!i.groupable),e.push(o)}),e}function pp(s,t=null){let e=String(s??"").trim()||"text",i=Object.hasOwn(mo,e)?mo[e]:e,n=Object.hasOwn(hp,i)?hp[i]:null,r=t&&typeof t=="object"?Object.hasOwn(t,e)?t[e]:Object.hasOwn(t,i)?t[i]:null:null,o=n?i:e,a=String(r?.icon??n?.icon??"type");return r?.label!=null?{type:o,icon:a,label:String(r.label),key:null}:n?{type:o,icon:a,label:n.label,key:n.key}:{type:o,icon:a,label:wp(e),key:null}}function cS(s){let t=String(s??"").trim()||"text";return aS.has(Object.hasOwn(mo,t)?mo[t]:t)}function _p(s,t){if(t&&typeof t=="object"&&Array.isArray(t.fields)){let e=new Set(s.map(i=>i.id));return[...new Set(t.fields.map(String))].filter(i=>e.has(i))}return s.filter(e=>e.groupable===!0||e.groupable!==!1&&cS(e.type)).map(e=>e.id)}function dS(s,t,e=""){let i=mp(t).split(/\s+/).filter(Boolean);if(i.length===0)return!0;let n=mp(`${s.label??""} ${s.id} ${e}`);return i.every(r=>n.includes(r))}function fo(s,t,e,i,n){let r=new Set(t),o=new Set(e),a=s.filter(m=>!r.has(m)),c=a.filter(m=>!o.has(m)),d=c.indexOf(i);if(d<0)return[...s];let u=Number.isFinite(Number(n))?Math.round(Number(n)):d,h=Math.max(0,Math.min(c.length-1,u));if(h===d)return[...s];c.splice(d,1),c.splice(h,0,i);let f=0,p=a.map(m=>o.has(m)?m:c[f++]),_=0;return s.map(m=>r.has(m)?m:p[_++])}function uS(s,t,e){let i=new Set(t);if(!s.includes(e)||!i.has(e))return{order:[...s],hidden:[...i]};i.delete(e);let n=s.filter(o=>o!==e),r=-1;return n.forEach((o,a)=>{i.has(o)||(r=a)}),n.splice(r+1,0,e),{order:n,hidden:n.filter(o=>i.has(o))}}function hS(s,t){let e=s.findIndex(i=>t<i);return e<0?s.length:e}function fS(s,t){if(!s)return{...t};let e=t.type==null?"":String(t.type).trim(),i=e&&e!=="text"?e:s.type??(e||"text");return{...s,...t,label:t.label??s.label,type:i}}function pS(s,t,e,i=bp,n=yp){return s<t.top+i&&e.top<t.top?-n:s>t.bottom-i&&e.bottom>t.bottom?n:0}function _S(s){let t=s.ownerDocument.scrollingElement??s.ownerDocument.documentElement,e=s.parentElement;for(;e&&e!==t&&e!==s.ownerDocument.body;){let i=getComputedStyle(e).overflowY;if(/(auto|scroll|overlay)/.test(i)&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return t}function mS(s){let t=s.ownerDocument.defaultView;if(s===s.ownerDocument.scrollingElement||s===s.ownerDocument.documentElement)return{top:0,bottom:t?.innerHeight??s.clientHeight};let e=s.getBoundingClientRect();return{top:e.top,bottom:e.bottom}}function gS(s,t={}){let e=Array.isArray(s)?s.map(String):[...fp];return[...new Set(e)].filter(n=>fp.includes(n)).filter(n=>n==="grouping"?t.grouping!==!1&&t.grouping!=null:n==="board"?!!t.board&&typeof t.board=="object":!0)}function Le(s,t=null){if(!s||typeof s!="object")return null;let e=s,i=Re(e.columnBy,t),n=Re(e.swimlaneBy,t);return n!==null&&n===i&&(n=null),{columnBy:i,swimlaneBy:n,showEmptyColumns:e.showEmptyColumns!==!1}}function Re(s,t){if(s==null||s==="")return null;let e=String(s);return t&&!t.includes(e)?null:e}function po(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Array.isArray(t)?[...new Set(t.map(String))].filter(r=>i.has(r)):[];return[...n,...e.filter(r=>!n.includes(r))]}function _o(s,t,e,i=!1){let n=new Set(s.filter(o=>i||!o.locked).map(o=>o.id)),r=new Set(Array.isArray(t)?t.map(String).filter(o=>n.has(o)):[]);if(e)for(let o of s)o.visible===!1&&n.has(o.id)&&r.add(o.id);return s.length&&r.size>=s.length&&r.delete(s[0].id),r}function bS(s){let t=Number(s??3);return Number.isInteger(t)&&t>=2&&t<=6?t:3}function mp(s){return String(s??"").normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().trim()}function wp(s){let t=String(s).split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Vi(s,t){return s.length===t.length&&s.every((e,i)=>e===t[i])}function yS(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function gp(s,t){return!s||!t?s===t:s.columnBy===t.columnBy&&s.swimlaneBy===t.swimlaneBy&&s.showEmptyColumns===t.showEmptyColumns}var Vs=Object.freeze([B("contains","contains","single",["text"]),B("notContains","does not contain","single",["text"]),B("eq","is","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),B("neq","is not","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),B("startsWith","starts with","single",["text"]),B("endsWith","ends with","single",["text"]),B("lt","is less than","single",["number","money"]),B("lte","is at most","single",["number","money"]),B("gt","is greater than","single",["number","money"]),B("gte","is at least","single",["number","money"]),B("on","is on","single",["date","datetime"]),B("notOn","is not on","single",["date","datetime"]),B("before","is before","single",["date","datetime"]),B("onOrBefore","is on or before","single",["date","datetime"]),B("after","is after","single",["date","datetime"]),B("onOrAfter","is on or after","single",["date","datetime"]),B("between","is between","pair",["number","money","date","datetime"]),B("notBetween","is not between","pair",["number","money","date","datetime"]),B("withinLast","is within the last","pair",["date","datetime"]),B("withinNext","is within the next","pair",["date","datetime"]),B("anyOf","is any of","many",["enum","status","priority","country","currency","unit","entity"]),B("noneOf","is none of","many",["enum","status","priority","country","currency","unit","entity"]),B("containsAny","contains any","many",["tags"]),B("containsAll","contains all","many",["tags"]),B("containsNone","contains none","many",["tags"]),B("isEmpty","is empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"]),B("isNotEmpty","is not empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"])]);function wo(){return{version:1,root:{kind:"group",id:x("filter-root"),logic:"and",children:[]}}}function vo(s={}){return{kind:"condition",id:String(s.id||x("filter-condition")),field:String(s.field??""),operator:String(s.operator??""),value:xo(s.value??null)}}function xo(s){return yo(s)}function So(s="and",t=[]){return{kind:"group",id:x("filter-group"),logic:s,children:t}}function Pe(s,t={}){let e=vp(t.maxDepth,3),i=vp(t.maxConditions,50);if(!bo(s)||s.version!==1||!bo(s.root))throw new TypeError("Filter AST must have version 1 and a root group");let n=new Set,r=0,o=(c,d,u=!1)=>{if(!bo(c))throw new TypeError("Filter nodes must be plain objects");let h=String(c.id??"").trim();if(!h||n.has(h))throw new TypeError("Filter node IDs must be non-empty and unique");if(n.add(h),c.kind==="group"){if(d>e)throw new RangeError("Filter group depth exceeds maxDepth");if(c.logic!=="and"&&c.logic!=="or")throw new TypeError("Filter group logic must be and or or");if(!Array.isArray(c.children))throw new TypeError("Filter group children must be an array");return{kind:"group",id:h,logic:c.logic,children:c.children.map(f=>o(f,d+1,!1))}}if(u||c.kind!=="condition")throw new TypeError("Filter root must be a group");if(r+=1,r>i)throw new RangeError("Filter condition count exceeds maxConditions");return{kind:"condition",id:h,field:String(c.field??""),operator:String(c.operator??""),value:yo(c.value)}},a=o(s.root,0,!0);if(a.kind!=="group")throw new TypeError("Filter root must be a group");return{version:1,root:a}}function js(s){return Pe(s,{maxDepth:1/0,maxConditions:1/0})}function xp(s){return JSON.stringify(js(s))}function Ao(s,t,e=Vs){let i=[],n=new Map((Array.isArray(t)?t:[]).map(a=>[String(a.id),a])),r=new Map((Array.isArray(e)?e:[]).map(a=>[String(a.id),a])),o=(a,c=!1)=>{if(a.kind==="group"){!c&&a.children.length===0&&i.push(Bs(a.id,"empty-group","Nested groups need at least one condition")),a.children.forEach(h=>o(h));return}let d=n.get(a.field);d||i.push(Bs(a.id,"unknown-field",a.field?`Unavailable field: ${a.field}`:"Choose a field"));let u=r.get(a.operator);if(!u){i.push(Bs(a.id,"unknown-operator",a.operator?`Unavailable operator: ${a.operator}`:"Choose an operator"));return}d&&(!(Array.isArray(d.operators)&&d.operators.length?d.operators:e.filter(f=>f.types.includes(d.type)).map(f=>f.id)).includes(u.id)||!u.types.includes(d.type))&&i.push(Bs(a.id,"operator-type",`${u.label} is not available for ${d.label}`)),wS(u.arity,a.value)||i.push(Bs(a.id,"value",u.arity==="pair"?"Enter both values":u.arity==="many"?"Choose at least one value":u.arity==="none"?"This operator does not accept a value":"Enter a value"))};return o(s.root,!0),{valid:i.length===0,errors:i}}function B(s,t,e,i){return Object.freeze({id:s,label:t,arity:e,types:Object.freeze(i)})}function Bs(s,t,e){return{nodeId:s,code:t,message:e}}function wS(s,t){return s==="none"?t===null:s==="pair"?Array.isArray(t)&&t.length===2&&t.every(Kl):s==="many"?Array.isArray(t)&&t.length>0&&t.every(Kl):Kl(t)}function Kl(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function yo(s,t=new WeakSet){if(s===null||typeof s=="string"||typeof s=="boolean")return s;if(typeof s=="number"){if(!Number.isFinite(s))throw new TypeError("Filter values cannot contain non-finite numbers");return s}if(typeof s!="object"||s instanceof Date||typeof s.nodeType=="number")throw new TypeError("Filter values must be JSON-safe");if(t.has(s))throw new TypeError("Filter values cannot contain cycles");if(t.add(s),Array.isArray(s)){let i=s.map(n=>yo(n,t));return t.delete(s),i}if(!bo(s))throw new TypeError("Filter values must be plain JSON objects");let e={};for(let[i,n]of Object.entries(s))Object.defineProperty(e,i,{value:yo(n,t),enumerable:!0,configurable:!0,writable:!0});return t.delete(s),e}function bo(s){if(!s||typeof s!="object"||Array.isArray(s))return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function vp(s,t){if(s===1/0)return 1/0;let e=Number(s);return Number.isFinite(e)&&e>=0?Math.floor(e):t}var vS=new Set(["withinLast","withinNext"]),ji=Object.freeze(["days","weeks","months"]),xS=Object.freeze({days:"days",weeks:"weeks",months:"months"}),Cp=Object.freeze({choose:"Choose\u2026",yes:"True",no:"False",commaSeparated:"Comma-separated values",value:s=>`${s} value`,valueAt:(s,t)=>`${s} value ${t}`}),Co=class extends y{static cssName="filter";static defaults={fields:[],value:null,operators:[],allowGroups:!0,maxDepth:3,maxConditions:50,autoApply:!1,readonly:!1,disabled:!1,searchable:!1,layout:"standard",rootLogic:null,showApply:!0,showRootActions:!0,applyLabel:null,clearLabel:null};render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._fields=(Array.isArray(this.options.fields)?this.options.fields:[]).map(e=>({...e})),this._operators=MS(Vs,this.options.operators),this._readonly=!!this.options.readonly,this._disabled=!!this.options.disabled,this._async=new Map,this._customEditors=[],this._selectEditors=[],this._disposed=!1,t.dataset.layout=this.options.layout==="compact"?"compact":"standard",this._value=this.options.value==null?wo():Pe(this.options.value,this._limits()),this.listen(t,"change",e=>this._handleChange(e)),this.listen(t,"input",e=>this._handleInput(e)),this.listen(t,"click",e=>this._handleClick(e)),this._render(),t}getValue(){return js(this._value)}setValue(t,{silent:e=!1}={}){let i=Pe(t,this._limits());return this._abortAll(),this._value=i,this._render(),e||this._changed("set",this._value.root.id),this}addCondition(t=null,e={}){if(!this._canMutate()||Ep(this._value.root)>=Number(this.options.maxConditions))return null;let i=zo(this._value.root,t??this._value.root.id);if(!i)return null;let n=this._fields[0],r=String(e.field??n?.id??""),o=this._field(r),a=vo({...e,field:r,operator:String(e.operator??this._defaultOperator(o)??"")});return i.children.push(a),this._render(),this._changed("add",a.id),this.focus(a.id),a.id}addGroup(t=null,e="and"){if(!this._canMutate()||!this.options.allowGroups)return null;let i=zo(this._value.root,t??this._value.root.id);if(!i||Mp(this._value.root,i.id)>=Number(this.options.maxDepth))return null;let n=So(e==="or"?"or":"and");return i.children.push(n),this._render(),this._changed("add",n.id),this.focus(n.id),n.id}update(t,e={}){if(!this._canMutate())return this;let i=Tt(this._value.root,t);return i?(i.kind==="group"?(e.logic==="and"||e.logic==="or")&&(i.logic=e.logic):(Object.hasOwn(e,"field")&&(i.field=String(e.field??"")),Object.hasOwn(e,"operator")&&(i.operator=String(e.operator??"")),Object.hasOwn(e,"value")&&(i.value=zp(e.value))),this._abort(t),this._render(),this._changed("update",t),this):this}remove(t){if(!this._canMutate()||t===this._value.root.id)return this;let e=Wl(this._value.root,t);if(!e)return this;let i=e.children.findIndex(a=>a.id===t),n=e.children[i+1]?.id??e.children[i-1]?.id??e.id,r=Ip(this._value.root,t);if(!r)return this;this._abortTree(r),this._render();let o=r.kind==="condition"?this._field(r.field)?.label??this._message("filter.conditionNoun","Filter"):this._message("filter.groupNoun","Filter group");return this._announce(this._message("filter.removed","%1 removed",o)),this._changed("remove",t),this.focus(n),this}move(t,e,i){let n=Tt(this._value.root,t),r=zo(this._value.root,e),o=Wl(this._value.root,t);if(!this._canMutate()||t===this._value.root.id||!n||!r||!o||ES(n,e))return this;let a=o.children.findIndex(d=>d.id===t),c=o.children.splice(a,1)[0];r.children.splice(Math.max(0,Math.min(r.children.length,Number(i)||0)),0,c);try{Pe(this._value,this._limits())}catch{return r.children.splice(r.children.indexOf(c),1),o.children.splice(a,0,c),this}return this._render(),this._changed("move",t),this}validate(){let t=Ao(this._value,this._fields,this._operators);for(let i of Tp(this._value.root)){if(!Yl(this._operator(i.operator))||zS(i.value)===null)continue;let n=this._message("filter.relativeInvalid","Enter a whole number of days, weeks or months"),r=t.errors.find(o=>o.nodeId===i.id&&o.code==="value");r?r.message=n:t.errors.push({nodeId:i.id,code:"value",message:n}),t.valid=!1}let e=DS(this._value,this.options.rootLogic);return e&&(t.valid=!1,t.errors.push(e)),t}apply(){if(this._disabled)return null;let t=this.validate();if(!t.valid)return this.emit("invalid",{errors:t.errors}),this.focus(t.errors[0]?.nodeId),null;let e=this.getValue();return this.emit("apply",{value:e}),e}clear({silent:t=!1}={}){return this._canMutate()?(this._abortAll(),this._value.root.children=[],this._render(),t||this._changed("clear",this._value.root.id),this.refs.add?.focus(),this):this}focus(t=null){let e=t?`[data-node-id="${Xt(t)}"] :is([data-filter-field], [data-filter-focus="field"], [data-filter-logic], [data-filter-action="add"])`:'[data-filter-action="add"]';return queueMicrotask(()=>{if(this._disposed)return;(this.el.querySelector(e)??this.refs.add)?.focus()}),this}setReadonly(t){return this._readonly=!!t,this._render(),this}enable(){return this._disabled=!1,this._render(),this}disable(){return this._disabled=!0,this._abortAll(),this._render(),this}destroy(){this._disposed=!0,this._renderVersion+=1,this._abortAll(),this._destroyEditors();let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&S(t,e)}_render(){this._destroyEditors(),this._renderVersion=(this._renderVersion??0)+1;let t=l("div",{ref:"status",class:"zx-filter__status",role:"status",ariaLive:"polite"}),e=this._renderGroup(this._value.root,0,!0),i=l("div",{class:"zx-filter__actions"},ge("add",this._value.root.id,"plus",this._message("filter.addFilter","Add filter"),{ref:"add",disabled:this._blocked()}),this.options.allowGroups?ge("add-group",this._value.root.id,"folder",this._message("filter.addGroup","Add group"),{disabled:this._blocked()}):null,ge("clear","","x",String(this.options.clearLabel??this._message("filter.clear","Clear")),{disabled:this._blocked()}),this.options.showApply?ge("apply","","check",String(this.options.applyLabel??this._message("filter.apply","Apply filters")),{kind:"primary",disabled:this._disabled}):null);this.el.replaceChildren(t,e,i),this.refs.status=t,this.refs.add=this.el.querySelector('[data-filter-action="add"]'),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-disabled",this._disabled);let n=this.validate();this.el.dataset.valid=String(n.valid);for(let r of n.errors)this.el.querySelector(`[data-node-id="${Xt(r.nodeId)}"]`)?.setAttribute("data-invalid","")}_renderGroup(t,e,i){let n=l("ol",{class:"zx-filter__children"},t.children.map((c,d)=>{let u=c.kind==="group"?this._renderGroup(c,e+1,!1):this._renderCondition(c);return d>0&&this.options.layout==="compact"&&u.prepend(this._connector(t,i)),u})),r=l("select",{class:"zx-filter__logic",dataset:{filterLogic:"",nodeId:t.id},ariaLabel:i?this._message("filter.rootLogic","Root filter logic"):this._message("filter.groupLogic","Group filter logic"),disabled:this._blocked()},l("option",{value:"and",selected:t.logic==="and"},this._message("filter.matchAll","Match all")),l("option",{value:"or",selected:t.logic==="or"},this._message("filter.matchAny","Match any"))),o=l("legend",{class:"zx-filter__legend"},i&&this.options.rootLogic?t.logic==="or"?this._message("filter.matchAnyConditions","Match any conditions"):this._message("filter.matchAllConditions","Match all conditions"):[r,l("span",{},i?this._message("filter.conditions","conditions"):this._message("filter.inThisGroup","in this group"))]),a=l("div",{class:"zx-filter__group-actions"},ge("add",t.id,"plus",this._message("filter.addFilter","Add filter"),{disabled:this._blocked()}),this.options.allowGroups&&e<Number(this.options.maxDepth)?ge("add-group",t.id,"folder",this._message("filter.addSubgroup","Add subgroup"),{disabled:this._blocked()}):null,i?null:ge("remove",t.id,"trash",this._message("filter.removeGroup","Remove group"),{disabled:this._blocked(),ariaLabel:this._message("filter.removeGroup","Remove group")}));return l(i?"fieldset":"li",{class:"zx-filter__group",dataset:{nodeId:t.id,depth:String(e)}},i?o:l("fieldset",{},o,n,a),i?n:null,i&&this.options.showRootActions?a:null)}_connector(t,e){let{word:i,name:n}=Sp(t.logic,(r,o,...a)=>this._message(r,o,...a));return this._blocked()||e&&this.options.rootLogic?l("span",{class:"zx-filter__connector",ariaHidden:"true",dataset:{connector:t.id}},i):l("button",{type:"button",class:"zx-filter__connector",tabindex:"-1",dataset:{filterAction:"toggle-logic",nodeId:t.id,connector:t.id},ariaLabel:n},i)}_syncConnectors(t){let{word:e,name:i}=Sp(t.logic,(n,r,...o)=>this._message(n,r,...o));for(let n of this.el.querySelectorAll(`[data-connector="${Xt(t.id)}"]`))n.textContent=e,n.tagName==="BUTTON"&&n.setAttribute("aria-label",i)}_renderCondition(t){let e=this._field(t.field),i=this._operatorsFor(e),n=this._operator(t.operator),r=this._fields.map(d=>({value:d.id,label:d.label,icon:d.icon}));t.field&&!e&&r.push({value:t.field,label:this._unavailable(t.field)});let o=i.map(d=>({value:d.id,label:d.label}));t.operator&&!i.some(d=>d.id===t.operator)&&o.push({value:t.operator,label:this._unavailable(t.operator)});let a=this.options.searchable?this._searchSelect(r,t.field,this._message("filter.field","Filter field"),t.id,"field",d=>{let u=this._field(String(d));this.update(t.id,{field:String(d),operator:this._defaultOperator(u)??"",value:null}),this.focus(t.id)}):l("select",{class:"zx-filter__field",dataset:{filterField:"",nodeId:t.id},ariaLabel:this._message("filter.field","Filter field"),disabled:this._blocked()},l("option",{value:"",selected:!t.field},this._message("filter.chooseField","Choose a field\u2026")),this._fields.map(d=>l("option",{value:d.id,selected:d.id===t.field},d.label)),t.field&&!e?l("option",{value:t.field,selected:!0},this._unavailable(t.field)):null),c=this.options.searchable?this._searchSelect(o,t.operator,this._message("filter.operator","Filter operator"),t.id,"operator",d=>{this.update(t.id,{operator:String(d),value:null}),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${Xt(t.id)}"] :is([data-filter-value], [data-filter-focus="value"])`)?.focus())}):l("select",{class:"zx-filter__operator",dataset:{filterOperator:"",nodeId:t.id},ariaLabel:this._message("filter.operator","Filter operator"),disabled:this._blocked()},l("option",{value:"",selected:!t.operator},this._message("filter.chooseOperator","Choose an operator\u2026")),i.map(d=>l("option",{value:d.id,selected:d.id===t.operator},d.label)),t.operator&&!i.some(d=>d.id===t.operator)?l("option",{value:t.operator,selected:!0},this._unavailable(t.operator)):null);return l("li",{class:"zx-filter__condition",dataset:{nodeId:t.id}},a,c,this._renderValue(t,e,n),this._removeConditionButton(t,e))}_renderValue(t,e,i){let n=l("div",{class:"zx-filter__value"});if(!e||!i)return n;if(i.arity==="none")return l("div",{class:"zx-filter__value zx-filter__value--empty"},this._message("filter.noValue","No value"));if(e.type==="custom"&&typeof e.editor=="function"){let d=this._renderVersion;return queueMicrotask(()=>{if(d!==this._renderVersion||!this.el.contains(n))return;let u=e.editor(n,{value:t.value,field:e,conditionId:t.id,setValue:h=>this._setNodeValue(t.id,zp(h))});u&&typeof u.destroy=="function"&&this._customEditors.push(u)}),n}let r=this._valueMessages();if(Yl(i))return this._relativeDateEditor(t,e);let o=i.arity==="pair"?Array.isArray(t.value)?t.value:[null,null]:[t.value];if(i.arity==="many"){if(this.options.searchable&&Array.isArray(e.choices)&&e.choices.length)return l("div",{class:"zx-filter__value",dataset:{arity:"many"}},this._tagPicker(e,t,r));let d=Ap(e,t,o[0],!0,this._blocked(),0,r);return d?l("div",{class:"zx-filter__value"},d):l("div",{class:"zx-filter__value"},kp(e,t.id,Array.isArray(t.value)?t.value.join(", "):"",0,this._blocked(),!0,r))}let a=e.choices?.length?e.choices:e.type==="boolean"?[{value:!0,label:r.yes},{value:!1,label:r.no}]:null,c=o.map((d,u)=>this.options.searchable&&a?this._searchSelect(a,d,i.arity==="pair"?r.valueAt(e.label,u+1):r.value(e.label),t.id,"value",h=>{let f=i.arity==="pair"?Array.isArray(t.value)?[...t.value]:[null,null]:null;f&&(f[u]=h),this._setNodeValue(t.id,f??h)}):Ap(e,t,d,!1,this._blocked(),u,r)??kp(e,t.id,d,u,this._blocked(),!1,r));return l("div",{class:"zx-filter__value",dataset:{arity:i.arity}},c)}_relativeDateEditor(t,e){let i=kS(t.value),n=l("input",{type:"number",min:"1",step:"1",inputMode:"numeric",value:i.amount===null?"":String(i.amount),dataset:{filterValue:"",filterRelative:"amount",nodeId:t.id,valueIndex:"0"},ariaLabel:this._message("filter.relativeAmount","%1: number of units",e.label),disabled:this._blocked()}),r=l("select",{dataset:{filterValue:"",filterRelative:"unit",nodeId:t.id,valueIndex:"1"},ariaLabel:this._message("filter.relativeUnit","%1: unit",e.label),disabled:this._blocked()},ji.map(o=>l("option",{value:o,selected:o===i.unit},this._message(`filter.unit.${o}`,xS[o]))));return l("div",{class:"zx-filter__value",dataset:{arity:"relative"}},l("span",{class:"zx-filter__value-control"},n),l("span",{class:"zx-filter__value-control"},r))}_searchSelect(t,e,i,n,r,o){let a=this._renderVersion,c=t.some(u=>Ul(u)!==null)?{renderItem:u=>l("span",{class:"zx-filter__choice"},Ul(u)??l("span",{class:"zx-filter__choice-icon"}),l("span",{class:"zx-filter__choice-label"},String(u.label??""))),renderValueAdornment:u=>Ul(u)}:{},d=new $(null,{items:t,valueKey:"value",labelKey:"label",value:e,label:i,filter:"local",disabled:this._blocked(),placeholder:this._message("filter.choosePart","Choose %1\u2026",r),...c,onchange:({detail:u})=>queueMicrotask(()=>{!this._disposed&&a===this._renderVersion&&this._canMutate()&&o(u.value)})});return this._selectEditors.push(d),d.el.classList.add("zx-filter__picker"),d.refs.input.dataset.filterFocus=r,d.refs.input.dataset.nodeId=n,d.el}_tagPicker(t,e,i){let n=this.options,r=n.lang??n.language,o=new re(null,{items:CS(t.choices),valueKey:"value",labelKey:"label",values:Array.isArray(e.value)?e.value:[],disabled:this._blocked(),placeholder:i.choose,msg:IS(this.options.msg,"tagPicker.input",i.value(t.label)),...r?{lang:r}:{},onchange:({detail:a})=>{!this._disposed&&this._canMutate()&&this._setNodeValue(e.id,TS(a.values))}});return this._selectEditors.push(o),o.el.classList.add("zx-filter__picker"),o.refs.input&&(o.refs.input.dataset.filterFocus="value",o.refs.input.dataset.nodeId=e.id),o.el}_handleChange(t){if(!this._canMutate())return;let e=t.target,i=e?.dataset.nodeId;if(!(!e||!i))if(e.dataset.filterField!==void 0){let n=Tt(this._value.root,i);if(n?.kind!=="condition")return;n.field=e.value;let r=this._field(n.field);n.operator=this._defaultOperator(r)??"",n.value=null,this._abort(i),this._render(),this._changed("update",i),this.focus(i)}else if(e.dataset.filterOperator!==void 0){let n=Tt(this._value.root,i);if(n?.kind!=="condition")return;n.operator=e.value,n.value=null,this._abort(i),this._render(),this._changed("update",i),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${Xt(i)}"] [data-filter-value]`)?.focus())}else if(e.dataset.filterLogic!==void 0){let n=Tt(this._value.root,i);n?.kind==="group"&&!(n===this._value.root&&this.options.rootLogic)&&(n.logic=e.value==="or"?"or":"and"),n?.kind==="group"&&this._syncConnectors(n),this._changed("update",i)}else e.dataset.filterValue!==void 0&&this._valueInput(e)}_handleInput(t){if(!this._canMutate())return;let e=t.target;if(!e||e.dataset.filterValue===void 0)return;this._valueInput(e);let i=e.dataset.nodeId,n=Tt(this._value.root,i),r=n?.kind==="condition"?this._field(n.field):null;r?.loadChoices&&this._scheduleChoices(n.id,r,e.value)}_valueInput(t){let e=Tt(this._value.root,t.dataset.nodeId);if(e?.kind!=="condition")return;let i=this._operator(e.operator),n=this._field(e.field);if(!i||!n)return;let r;if(Yl(i)){let o=t.closest(".zx-filter__value"),a=o?.querySelector('[data-filter-relative="amount"]')??null,c=o?.querySelector('[data-filter-relative="unit"]')??null;r=AS(a?.value??"",c?.value??ji[0])}else if(t instanceof HTMLSelectElement&&t.multiple)r=Array.from(t.selectedOptions,o=>ko(o.value,n.type));else if(i.arity==="many")r=t.value.split(",").map(o=>o.trim()).filter(Boolean).map(o=>ko(o,n.type));else if(i.arity==="pair"){let o=Array.isArray(e.value)?[...e.value]:[null,null];o[Number(t.dataset.valueIndex)||0]=ko(t.value,n.type),r=o}else r=ko(t.value,n.type);this._setNodeValue(e.id,r)}_handleClick(t){let e=t.target?.closest?.("[data-filter-action]");if(!e||!this.el.contains(e))return;let i=e.dataset.filterAction,n=e.dataset.nodeId||null;if(i==="add")this.addCondition(n);else if(i==="add-group")this.addGroup(n);else if(i==="remove"&&n)this.remove(n);else if(i==="clear")this.clear();else if(i==="toggle-logic"&&n){let r=SS(this._value,n,this.options.rootLogic);if(!r)return;this.update(n,{logic:r}),this.focus(n)}else i==="apply"&&this.apply()}_setNodeValue(t,e){let i=Tt(this._value.root,t);if(i?.kind!=="condition")return;i.value=e;let n=this.validate();this.el.dataset.valid=String(n.valid),this.el.querySelector(`[data-node-id="${Xt(t)}"]`)?.toggleAttribute("data-invalid",n.errors.some(o=>o.nodeId===t)),this._changed("update",t)}_changed(t,e){let i=this.validate(),n=this.getValue();this.emit("change",{value:n,valid:i.valid,errors:i.errors,reason:t,nodeId:e}),this.options.autoApply&&i.valid&&this.emit("apply",{value:n})}_scheduleChoices(t,e,i){if(this._abort(t),i.length<Number(e.minQuery??0))return;let n=new AbortController;this._setAsyncBusy(t,!0);let r={controller:n,timer:setTimeout(async()=>{this.emit("query",{conditionId:t,fieldId:e.id,query:i});try{let o=await e.loadChoices({query:i,signal:n.signal,conditionId:t,field:e});if(n.signal.aborted||this._async.get(t)?.controller!==n)return;let c=this.el.querySelector(`[data-node-id="${Xt(t)}"] [data-filter-value]`)?.getAttribute("list"),d=c?this.el.querySelector(`#${Xt(c)}`):null;d&&d.replaceChildren(...(Array.isArray(o)?o:[]).map(u=>l("option",{value:u.value},u.label))),this.emit("loaded",{conditionId:t,fieldId:e.id,query:i,choices:o})}catch(o){n.signal.aborted||this.emit("error",{conditionId:t,fieldId:e.id,query:i,error:o instanceof Error?o:new Error(String(o))})}finally{this._async.get(t)?.controller===n&&(this._async.delete(t),this._setAsyncBusy(t,!1))}},Math.max(0,Number(e.debounce??200)))};this._async.set(t,r)}_abort(t){let e=this._async.get(t);e&&(clearTimeout(e.timer),e.controller.abort(),this._async.delete(t),this._setAsyncBusy(t,!1))}_setAsyncBusy(t,e){let i=this.el.querySelector(`[data-node-id="${Xt(t)}"] [data-filter-value]`);e?i?.setAttribute("aria-busy","true"):i?.removeAttribute("aria-busy")}_abortTree(t){t.kind==="condition"?this._abort(t.id):t.children.forEach(e=>this._abortTree(e))}_abortAll(){for(let t of[...this._async.keys()])this._abort(t)}_destroyEditors(){for(let t of[...this._customEditors??[],...this._selectEditors??[]])t.destroy?.();this._customEditors=[],this._selectEditors=[]}_blocked(){return this._readonly||this._disabled}_canMutate(){return!this._blocked()}_limits(){return{maxDepth:Number(this.options.maxDepth),maxConditions:Number(this.options.maxConditions)}}_field(t){return this._fields.find(e=>e.id===t)??null}_operator(t){return this._operators.find(e=>e.id===t)??null}_operatorsFor(t){if(!t)return[];let e=t.operators?.length?t.operators:null;return this._operators.filter(i=>e?e.includes(i.id):i.types.includes(t.type))}_defaultOperator(t){return t?.defaultOperator&&this._operatorsFor(t).some(e=>e.id===t.defaultOperator)?t.defaultOperator:this._operatorsFor(t)[0]?.id??null}_announce(t){this.refs.status&&(this.refs.status.textContent=t)}_unavailable(t){return this._message("filter.unavailable","Unavailable: %1",t)}_removeConditionButton(t,e){let i=this._message("filter.remove","Remove %1",e?.label??this._message("filter.filterNoun","filter"));return ge("remove",t.id,"trash",i,{disabled:this._blocked(),ariaLabel:i})}_valueMessages(){return{choose:this._message("filter.choose","Choose\u2026"),yes:this._message("filter.booleanTrue","True"),no:this._message("filter.booleanFalse","False"),commaSeparated:this._message("filter.commaSeparated","Comma-separated values"),value:t=>this._message("filter.fieldValue","%1 value",t),valueAt:(t,e)=>this._message("filter.fieldValueAt","%1 value %2",t,e)}}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function ge(s,t,e,i,n={}){let{kind:r,...o}=n;return l("button",{type:"button",class:"zx-btn",...o,dataset:{filterAction:s,nodeId:t,size:"sm",...r?{kind:r}:{}}},g(e),l("span",{},i))}function Sp(s,t=(e,i,...n)=>T(i,n)){let e=s==="or"?t("filter.or","or"):t("filter.and","and"),i=s==="or"?t("filter.switchToAll","%1 \u2014 switch to all",e):t("filter.switchToAny","%1 \u2014 switch to any",e);return{word:e,name:i}}function SS(s,t,e=null){let i=zo(s?.root,t);return!i||i===s.root&&e?null:i.logic==="or"?"and":"or"}function AS(s,t){let e=String(s??"").trim(),i=e===""?NaN:Number(e),n=ji.includes(String(t))?String(t):ji[0];return[Number.isFinite(i)?i:null,n]}function kS(s){return!Array.isArray(s)||s.length!==2||!ji.includes(String(s[1]))?{amount:null,unit:"days"}:{amount:typeof s[0]=="number"&&Number.isFinite(s[0])?s[0]:null,unit:String(s[1])}}function zS(s){return!Array.isArray(s)||s.length!==2?"shape":!ji.includes(String(s[1]))||typeof s[1]!="string"?"unit":typeof s[0]!="number"||!Number.isInteger(s[0])||s[0]<1?"amount":null}function CS(s){return(Array.isArray(s)?s:[]).map(t=>({value:t.value,label:t.label,...t.icon?{icon:t.icon}:{},...t.color?{color:t.color}:{}}))}function TS(s){return xo(Array.isArray(s)?[...s]:[])}function IS(s,t,e){let i={};for(let[n,r]of Object.entries(s&&typeof s=="object"?s:{}))i[n]=r&&typeof r=="object"?{...r,[t]:e}:r;return i[t]=e,i}function Ul(s){let t=s?.icon,e=typeof t=="string"&&t?g(t,{size:14}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t.cloneNode(!0):null;return e?l("span",{class:"zx-filter__choice-icon",ariaHidden:"true"},e):null}function Ap(s,t,e,i,n,r=0,o=Cp){let a=Array.isArray(s.choices)&&s.choices.length?s.choices:s.type==="boolean"?[{value:!0,label:o.yes},{value:!1,label:o.no}]:null;if(!a)return null;let c=new Set(Array.isArray(e)?e.map(String):[String(e??"")]);return l("select",{dataset:{filterValue:"",nodeId:t.id,valueIndex:String(r)},ariaLabel:o.value(s.label),multiple:i,disabled:n},i?null:l("option",{value:"",selected:!c.has(String(e))||e==null},o.choose),a.map(d=>l("option",{value:d.value,selected:c.has(String(d.value))},d.label)))}function kp(s,t,e,i,n,r=!1,o=Cp){let a=r?"text":["number","money"].includes(s.type)?"number":s.type==="date"?"date":s.type==="datetime"?"datetime-local":"text",c=s.loadChoices?`zx-filter-choices-${t}-${i}`:null,d=l("input",{type:a,value:e??"",dataset:{filterValue:"",nodeId:t,valueIndex:String(i)},ariaLabel:i?o.valueAt(s.label,i+1):o.value(s.label),disabled:n,placeholder:r?o.commaSeparated:"",list:c});return l("span",{class:"zx-filter__value-control"},d,c?l("datalist",{id:c}):null)}function Yl(s){return!!s&&(vS.has(String(s.id))||s.arity==="relative")}function Tp(s){return s?s.kind==="condition"?[s]:s.children.flatMap(t=>Tp(t)):[]}function ko(s,t){if(s==="")return null;if(["number","money"].includes(t)){let e=Number(s);return Number.isFinite(e)?e:null}return t==="boolean"?s==="true":s}function zp(s){return xo(s===void 0?null:s)}function Tt(s,t){if(!s||s.id===t)return s??null;if(s.kind==="group")for(let e of s.children){let i=Tt(e,t);if(i)return i}return null}function zo(s,t){if(!s)return null;let e=Tt(s,t);return e?.kind==="group"?e:null}function Wl(s,t){if(s?.kind!=="group")return null;if(s.children.some(e=>e.id===t))return s;for(let e of s.children){let i=Wl(e,t);if(i)return i}return null}function Ip(s,t){if(s.kind!=="group")return null;let e=s.children.findIndex(i=>i.id===t);if(e>=0)return s.children.splice(e,1)[0];for(let i of s.children){let n=Ip(i,t);if(n)return n}return null}function ES(s,t){return!!(s&&Tt(s,t))}function Ep(s){return s.kind==="condition"?1:s.children.reduce((t,e)=>t+Ep(e),0)}function Mp(s,t,e=0){if(s.id===t)return e;if(s.kind==="group"){for(let i of s.children)if(i.kind==="group"){let n=Mp(i,t,e+1);if(n>=0)return n}}return-1}function MS(s,t){let e=new Map(s.map(i=>[i.id,{...i,types:[...i.types]}]));for(let i of Array.isArray(t)?t:[])i?.id&&e.set(String(i.id),{...i,id:String(i.id),types:Array.isArray(i.types)?[...i.types]:[]});return[...e.values()]}function Xt(s){return globalThis.CSS?.escape?CSS.escape(s):String(s).replaceAll(/[^a-zA-Z0-9_-]/g,"\\$&")}function DS(s,t){return!t||s.root.logic===t?null:{nodeId:s.root.id,code:"root-logic",message:`This filter requires match ${t==="or"?"any":"all"} conditions.`}}var Dp=Object.freeze([Object.freeze(["getValue","setValue"]),Object.freeze(["get","set"]),Object.freeze(["getValues","setValues"]),Object.freeze(["isChecked","setChecked"])]),NS=Object.freeze(["value","values","checked"]),Np="input, select, textarea, button",OS="input, textarea";function To(s){if(E(s))return s;let t=s;if(typeof t.toElement=="function")return t.toElement();if(E(t.el))return t.el;throw new TypeError("External field source must be an Element or a Component")}function Op(s){return Lp(s,To(s)).get()}function Gl(s){let t=To(s),e=E(s)?null:s;if(e&&Jt(e,"isDisabled",0))return!!e.isDisabled();if(e&&typeof e.disabled=="boolean")return e.disabled;if(Hi(t,"disabled"))return!!t.disabled||t.hasAttribute("disabled");if(t.getAttribute("aria-disabled")==="true")return!0;let i=t.getAttribute("data-disabled");if(i!==null&&i!=="false")return!0;let n=[...t.querySelectorAll(Np)];return n.length>0&&n.every(r=>r.disabled)}function Ql(s){let t=To(s),e=E(s)?null:s;for(let n of["readonly","readOnly"])if(e&&typeof e[n]=="boolean")return e[n];if(Hi(t,"readOnly"))return!!t.readOnly||t.hasAttribute("readonly");if(t.getAttribute("aria-readonly")==="true")return!0;let i=t.getAttribute("data-readonly");return i!==null&&i!=="false"}function Fp(s,t=null){let e=To(s),i=E(s)?null:s,n=e.parentNode,r=e.nextSibling,o=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(k=>[k,e.getAttribute(k)])),a=i===null,c=a&&Hi(e,"value")?e.value:void 0,d=a&&Pp(e)?e.checked:void 0,u=Gl(s),h=Ql(s),f=new Map,p=Lp(s,e),_=FS(i,e,f),m=LS(i,e,f),b=u,w=h,v=!1,z=p.get();t&&i&&typeof i.addEventListener=="function"&&(t.listen(i,"change",()=>{v||(z=p.get(),t.emit("change",{value:z}))}),t.listen(e,"change",k=>{let M=p.get();RS(M,z)?k.stopImmediatePropagation():z=M}));let C={el:e,get:()=>p.get(),set:(k,M)=>{v=!0;try{p.set(k,M)}finally{v=!1}z=p.get()},focus:()=>{i&&Jt(i,"focus",0)?i.focus():typeof e.focus=="function"&&e.focus()},setDisabled:k=>{b=!!k,_(b)},destroy:()=>{w!==h&&m&&m(h),b!==u&&_(u);for(let[k,M]of f)M.disabled!==void 0&&(k.disabled=M.disabled),M.readOnly!==void 0&&(k.readOnly=M.readOnly);f.clear();for(let[k,M]of o)M===null?e.removeAttribute(k):e.setAttribute(k,M);c!==void 0&&(e.value=c),d!==void 0&&(e.checked=d),n?n.insertBefore(e,r?.parentNode===n?r:null):e.remove()}};return m&&(C.setReadonly=k=>{w=!!k,m(w)}),C}function Lp(s,t){let e=E(s)?null:s;if(e){let i=Dp.find(([o])=>Jt(e,o,0)),n=i?Jt(e,i[1],2)?i[1]:Dp.map(([,o])=>o).find(o=>Jt(e,o,1)):void 0;if(i)return{get:()=>e[i[0]](),set:(o,a={})=>{n&&e[n](o,{...a,silent:!!a.silent})}};let r=NS.find(o=>o in e);if(r)return{get:()=>e[r],set:o=>{e[r]=o}}}return Pp(t)?{get:()=>!!t.checked,set:i=>{t.checked=!!i}}:Hi(t,"value")?{get:()=>t.value,set:i=>{t.value=i??""}}:{get:()=>null,set:()=>{}}}function FS(s,t,e){return s&&Jt(s,"setDisabled",1)?i=>s.setDisabled(i):s&&Jt(s,"enable",0)&&Jt(s,"disable",0)?i=>i?s.disable():s.enable():s&&typeof s.disabled=="boolean"?i=>{s.disabled=i}:Hi(t,"disabled")?i=>{t.disabled=i}:i=>{t.setAttribute("aria-disabled",String(i));for(let n of t.querySelectorAll(Np))Rp(e,n,"disabled"),n.disabled=i||!!e.get(n)?.disabled}}function LS(s,t,e){if(s){for(let n of["setReadonly","setReadOnly"])if(Jt(s,n,1))return r=>s[n](r);for(let n of["readonly","readOnly"])if(typeof s[n]=="boolean")return r=>{s[n]=r};return null}if(Hi(t,"readOnly"))return n=>{t.readOnly=n};let i=[...t.querySelectorAll(OS)];return i.length?n=>{for(let r of i)Rp(e,r,"readOnly"),r.readOnly=n||!!e.get(r)?.readOnly}:null}function Rp(s,t,e){let i=s.get(t)??{};i[e]===void 0&&(i[e]=!!t[e]),s.set(t,i)}function Jt(s,t,e){let i=s[t];return typeof i=="function"&&i.length<=e}function Hi(s,t){return["INPUT","SELECT","TEXTAREA","BUTTON","FIELDSET","OUTPUT"].includes(s.tagName)&&t in s}function Pp(s){let t=String(s.type??"").toLowerCase();return s.tagName==="INPUT"&&(t==="checkbox"||t==="radio")}function RS(s,t){if(Object.is(s,t))return!0;if(s instanceof Date&&t instanceof Date)return s.getTime()===t.getTime();if(s&&t&&typeof s=="object"&&typeof t=="object")try{return JSON.stringify(s)===JSON.stringify(t)}catch{return!1}return!1}var Be=class extends y{static cssName="fieldset";static defaults={title:"",columns:1,fields:{},idPrefix:null};render(){let t=this.el??l("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):x("zx-fieldset"),this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let n=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}this._grid=l("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let i=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[n,r]of Object.entries(i))this.addField(n,r);return t}addField(t,e){let i=String(t);if(this._fields.has(i))throw new Error(`Field "${i}" already exists`);let n,r=!1;if(e instanceof I)n=e;else if(E(e)||e instanceof y){let o=e;n=new I(null,{id:this._controlId(i),name:i,type:"custom",label:i,value:Op(o),disabled:Gl(o),readonly:Ql(o),adapter:a=>Fp(o,a)}),r=!0}else{let o=e&&typeof e=="object"?e:{},a=o.id!=null&&String(o.id)!==""&&String(o.id)!==i;n=new I(null,{...o,id:a?String(o.id):this._controlId(i),name:o.name??i}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(i,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=i,this._grid.append(n.el),n}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,i]of this._fields)t[e]=i.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,n]of Object.entries(t))this._fields.get(i)?.setValue(n,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let i=0;for(let[n,r]of this._fields){let o=t?.[n];o?(r.setHighlight(String(o),e),i+=1):r.clearHighlight()}return i}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_controlId(t){return`${this._idPrefix}-${t.trim().replace(/\s+/g,"-")}`}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let i=this._origins.get(t);i?.parent?i.parent.insertBefore(t.el,i.next?.parentNode===i.parent?i.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};var Io=class extends y{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,idPrefix:null,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??l("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):x("zx-form"),this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=l("div",{class:"zx-form__body"}),this._actions=l("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",i=>{i.preventDefault(),this.submit()}),this.listen(t,"reset",i=>{i.preventDefault(),this.reset()}),this.listen(this._actions,"click",i=>this._handleAction(i));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let i of e)this.addFieldset(i);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof Be),i=e?new Be(null,{...t??{},idPrefix:t?.idPrefix??this._idPrefix}):t;return this._fieldsets.includes(i)||(e?this._ownedFieldsets.add(i):this._origins.set(i,{parent:i.el.parentNode,next:i.el.nextSibling}),this._fieldsets.push(i),this._body.append(i.el),this.listen(i.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:i.getValue(o)})})),i}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,i)=>{let n=String(e.label??e.id??"Action");return l("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!n&&e.title?e.title:void 0,dataset:{actionIndex:i,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?g(e.icon,{size:16}):null,n?l("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let i of this._fieldsets)i.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let i=e.getField(t);if(i)return i}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((i,n)=>i+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),c="";if(o.options.required&&Xl(a))c=this.msg("form.required");else if(!Xl(a)&&o.options.type==="int"){let d=$o(a);d.valid?o.setValue(d.value,{silent:!0}):c=this.msg("form.int")}else if(!Xl(a)&&o.options.type==="float"){let d=Ko(a);d.valid?o.setValue(d.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let i=this._actionDescriptors[Number(e.dataset.actionIndex)],n=i?.onClick??i?.onclick??i?.handler;typeof n=="function"&&n(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function Xl(s){return s==null||s===""||s===!1||Array.isArray(s)&&s.length===0}var Eo="123456789abcdefghijklmnopqrstuvwxyz";function Bp(s){if(!Array.isArray(s))throw new TypeError("Questionnaire items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Each questionnaire item must be an object");if(typeof e.name!="string"||e.name.trim()==="")throw new TypeError("Each questionnaire item needs a non-empty string name");let i=e.name;if(t.has(i))throw new TypeError(`Item already exists: ${i}`);t.add(i);let n=PS(e.choices??[],i),r=e.field&&typeof e.field=="object"?{...e.field}:null,o=VS(e.input);if(n.length===0&&!r&&!o)throw new TypeError(`Item "${i}" needs choices, an input, or a field`);return{name:i,prompt:String(e.prompt??i),description:e.description==null||e.description===""?null:String(e.description),section:e.section==null?"":String(e.section),required:!!e.required,multiple:!!e.multiple,skippable:!!e.skippable,choices:n,input:o,field:r,when:typeof e.when=="function"?e.when:null,next:typeof e.next=="function"||typeof e.next=="string"&&e.next?e.next:null,validate:typeof e.validate=="function"?e.validate:null}})}function PS(s,t=""){if(!Array.isArray(s))throw new TypeError("Questionnaire choices must be an array");let e=new Set,i=s.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))throw new TypeError("Each questionnaire choice must be an object");if(o.value==null||o.value==="")throw new TypeError(`Each choice of "${t}" needs a value`);let a=typeof o.value=="number"?o.value:String(o.value),c=String(a);if(e.has(c))throw new TypeError(`Choice already exists in "${t}": ${c}`);return e.add(c),{value:a,label:String(o.label??a),description:o.description==null||o.description===""?null:String(o.description),icon:o.icon==null||o.icon===""?null:String(o.icon),key:typeof o.key=="string"&&o.key?o.key.slice(0,1).toLowerCase():"",disabled:!!o.disabled,exclusive:!!o.exclusive}}),n=new Set(i.map(o=>o.key).filter(Boolean)),r=0;for(let o of i)if(!o.key){for(;r<Eo.length&&n.has(Eo[r]);)r+=1;if(r>=Eo.length)break;o.key=Eo[r],n.add(o.key),r+=1}return i}function BS(s,t){if(typeof s.when!="function")return!0;try{return s.when(t)!==!1}catch{return!0}}function Zt(s,t){let e={},i=[];for(let n of s)BS(n,e)&&(i.push(n),Object.prototype.hasOwnProperty.call(t,n.name)&&(e[n.name]=t[n.name]));return{answers:e,visible:i}}function Mo(s,t,e){let{answers:i,visible:n}=Zt(s,e),r=new Set(n.map(c=>c.name)),o=null;if(typeof t.next=="string")o=t.next;else if(typeof t.next=="function"){let c=t.next(i[t.name],i);o=c==null||c===""?null:String(c)}let a=s.indexOf(t);if(o!==null){let c=s.findIndex(d=>d.name===o);if(c<0)throw new RangeError(`Unknown questionnaire item: ${o}`);if(r.has(o))return o;a=c}for(let c=a+1;c<s.length;c+=1)if(r.has(s[c].name))return s[c].name;return null}function Ve(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.every(t=>Ve(t)):!1}function Vp(s,t,e){return!s.required||!Ve(t)?null:e(s.choices.length>0?"questionnaire.required":"questionnaire.requiredInput")}function jp(s,t,e=null){let i=new Set(t.map(r=>String(r))),n=new Set(s.filter(r=>r.exclusive).map(r=>String(r.value)));return n.size>0&&e!==null&&i.has(String(e))&&(n.has(String(e))?i.forEach(r=>r!==String(e)&&i.delete(r)):n.forEach(r=>i.delete(r))),s.filter(r=>i.has(String(r.value))).map(r=>r.value)}function Hp(s,t,e){let{answers:i,visible:n}=Zt(s,t),r=new Map(n.map(p=>[p.name,p])),o=e.filter(p=>r.has(p)),a=o.length>0?r.get(o[o.length-1]):null,c=o.filter(p=>!Ve(i[p])).length,d=new Set(o),u=a?n.indexOf(a):-1,h=n.slice(u+1).filter(p=>!d.has(p.name)).length,f=o.length+h;return{index:Math.max(0,o.length-1),answered:c,total:f,percent:f===0?0:Math.round(c/f*100),section:a?.section??""}}function VS(s){if(!s)return null;let t=typeof s=="object"&&!Array.isArray(s)?s:{};return{label:String(t.label??"Other"),placeholder:String(t.placeholder??""),multiline:!!t.multiline,maxLength:Math.max(0,Number(t.maxLength)||0)}}var jS=260,Do=class extends y{static cssName="questionnaire";static defaults={items:[],answers:{},active:null,progress:!0,review:!1,advance:"manual",shortcuts:!0,allowBack:!0,msg:{"questionnaire.next":"Continue","questionnaire.previous":"Back","questionnaire.skip":"Skip","questionnaire.submit":"Submit","questionnaire.review":"Review answers","questionnaire.reviewTitle":"Check your answers","questionnaire.edit":"Edit","questionnaire.counter":"Question %1 of %2","questionnaire.required":"Choose an answer to continue.","questionnaire.requiredInput":"Enter an answer to continue.","questionnaire.noAnswer":"Skipped","questionnaire.empty":"There is nothing to answer."}};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._items=[],this._selected=new Map,this._freeform=new Map,this._fields=new Map,this._path=[],this._status="asking",this._returnToReview=!1,this._busy=!1,this._error="",this._advanceTimer=0,this._uid=x("zx-questionnaire");let t=this.el??l("form");if(this.el=t,this._form=t.localName==="form"?t:l("form",{class:"zx-questionnaire__form"}),this._form.setAttribute("novalidate",""),this._progressHost=l("div",{class:"zx-questionnaire__progress",hidden:!this.options.progress}),this._itemHost=l("fieldset",{class:"zx-questionnaire__item",tabIndex:-1}),this._reviewHost=l("div",{class:"zx-questionnaire__review",tabIndex:-1,hidden:!0}),this._actionsHost=l("div",{class:"zx-questionnaire__actions"}),this.refs.item=this._itemHost,this.refs.review=this._reviewHost,this.refs.actions=this._actionsHost,this._bar=new bi(null,{max:100,value:0,size:"sm",showValue:!1}),this._progressHost.append(this._bar.el),this._back=this._action("previous",this.msg("questionnaire.previous"),"chevron-left","default"),this._skip=this._action("skip",this.msg("questionnaire.skip"),null,"ghost"),this._forward=this._action("next",this.msg("questionnaire.next"),"chevron-right","primary"),this._actionsHost.append(this._back,l("span",{class:"zx-questionnaire__spacer"}),this._skip,this._forward),this._form.replaceChildren(this._progressHost,this._itemHost,this._reviewHost,this._actionsHost),this._form!==t&&t.replaceChildren(this._form),this.listen(this._form,"submit",e=>{e.preventDefault(),this.next()}),this.listen(this._itemHost,"change",e=>this._onControlChange(e)),this.listen(this._itemHost,"input",e=>this._onFreeformInput(e)),this.listen(this._actionsHost,"click",e=>this._onActionClick(e)),this.listen(this._reviewHost,"click",e=>this._onReviewClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this.setItems(this.options.items),this.options.answers&&typeof this.options.answers=="object"&&this.setAnswers(this.options.answers,{silent:!0}),this.options.active!=null){let e=String(this.options.active);Zt(this._items,this._rawAnswers()).visible.some(n=>n.name===e)&&(this._path=[e])}return this._paint(),t}setItems(t){let e=this.getActive(),i=Bp(t),n=new Set(i.map(a=>a.name));this._items=i;for(let a of[this._selected,this._freeform])for(let c of[...a.keys()])n.has(c)||a.delete(c);for(let[a,c]of[...this._fields])n.has(a)||(c.destroy(),this._fields.delete(a));let r=Zt(i,this._rawAnswers()).visible,o=this._path.filter(a=>r.some(c=>c.name===a));return e&&o[o.length-1]===e?this._path=o:this._path=r.length>0?[r[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}getItems(){return this._items.map(t=>({...t,choices:t.choices.map(e=>({...e})),input:t.input?{...t.input}:null}))}goTo(t){let e=this._items.find(r=>r.name===t);if(!e)throw new RangeError(`Unknown questionnaire item: ${t}`);if(!Zt(this._items,this._rawAnswers()).visible.includes(e))return!1;let n=this._returnToReview;return this._returnToReview=n||this._status==="review",this._navigate(t,"goto")?!0:(this._returnToReview=n,!1)}async next(){if(this._busy||this._status==="complete")return!1;if(this._status==="review")return this.submit();if(!await this._validateActive()||this._destroyed)return!1;if(this._returnToReview)return this._returnToReview=!1,this._enterReview();let t=this._activeItem(),e=t?Mo(this._items,t,this._rawAnswers()):null;return e?this._navigate(e,"next"):this.options.review?this._enterReview():this.submit()}previous(){if(this._busy)return!1;if(this._status==="review"||this._status==="complete"){let n=this._path[this._path.length-1];return!n||this.emit("navigate",{from:null,to:n,reason:"previous"}).defaultPrevented?!1:(this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}if(!this.options.allowBack||this._path.length<=1)return!1;let t=this.getActive(),e=this._path[this._path.length-2];return this.emit("navigate",{from:t,to:e,reason:"previous"}).defaultPrevented?!1:(this._path.pop(),this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}async skip(){let t=this._activeItem();if(!t||!t.skippable||this._busy)return!1;if(this.setAnswer(t.name,null,{silent:!0}),this.emit("skip",{name:t.name}),this._returnToReview)return this._returnToReview=!1,this._enterReview();let e=Mo(this._items,t,this._rawAnswers());return e?this._navigate(e,"skip"):this.options.review?this._enterReview():this.submit()}async submit(){if(this._busy||this._status==="complete"||this._status!=="review"&&!await this._validateActive()||this._destroyed)return!1;let t={answers:this.getAnswers(),path:this.getPath()};return this.emit("submit",t).defaultPrevented?!1:(this._status="complete",this._paint(),this.emit("complete",{answers:t.answers,path:t.path}),!0)}getAnswers(){return Zt(this._items,this._rawAnswers()).answers}getAnswer(t){let e=this._items.find(i=>i.name===t);return e?this._answerOf(e):null}setAnswers(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,n]of Object.entries(t))this._items.some(r=>r.name===i)&&this.setAnswer(i,n,{silent:!0});if(this._paint(),!e){let i=this.getAnswers();for(let n of Object.keys(t))n in i&&this.emit("change",{name:n,value:i[n],answers:i})}return this}setAnswer(t,e,{silent:i=!1}={}){let n=this._items.find(r=>r.name===t);if(!n)throw new RangeError(`Unknown questionnaire item: ${t}`);if(n.field)this._field(n).setValue(e===void 0?null:e,{silent:!0});else{let r=Array.isArray(e)?e:e==null||e===""?[]:[e],o=new Set(r.map(c=>String(c))),a=n.choices.filter(c=>o.has(String(c.value)));for(let c of a)o.delete(String(c.value));this._selected.set(t,a.map(c=>c.value)),this._freeform.set(t,n.input?[...o][0]??"":"")}return this._paint(),i||this._emitChange(n),this}getActive(){return this._status!=="asking"?null:this._path[this._path.length-1]??null}getPath(){return[...this._path]}getProgress(){return Hp(this._items,this._rawAnswers(),this._path)}getState(){return{active:this.getActive(),status:this._status,answers:this.getAnswers(),path:this.getPath(),progress:this.getProgress()}}toFormData(){let t=new FormData;for(let[e,i]of Object.entries(this.getAnswers()))if(Array.isArray(i))for(let n of i)t.append(e,String(n));else i instanceof File||i instanceof Blob?t.append(e,i):t.append(e,i==null?"":String(i));return t}reset(){this._selected.clear(),this._freeform.clear();for(let[e,i]of this._fields){let n=this._items.find(r=>r.name===e);i.setValue(n?.field?.value??null,{silent:!0})}let t=Zt(this._items,this._rawAnswers()).visible;return this._path=t.length>0?[t[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}focus(){return this._focusItem(),this}destroy(){if(!this._destroyed){this._destroyed=!0,clearTimeout(this._advanceTimer);for(let t of this._fields.values())t.destroy();this._fields.clear(),this._bar?.destroy(),super.destroy(),this._createdRoot||S(this.el,this._snapshot)}}_activeItem(){let t=this._path[this._path.length-1];return this._items.find(e=>e.name===t)??null}_rawAnswers(){let t={};for(let e of this._items){let i=this._answerOf(e);Ve(i)||(t[e.name]=i)}return t}_answerOf(t){if(t.field)return this._fields.get(t.name)?.getValue()??null;let e=this._selected.get(t.name)??[],i=(this._freeform.get(t.name)??"").trim();return t.multiple?i?[...e,i]:[...e]:i||(e.length>0?e[0]:null)}_field(t){let e=this._fields.get(t.name);if(e)return e;let i=t.field??{};return e=new I(null,{...i,label:i.label??t.prompt,required:t.required}),e.el.classList.add("zx-questionnaire__field"),i.label==null&&e.el.setAttribute("data-hide-label",""),e.on("change",()=>{this._error="",this._paintError(t),this._emitChange(t)}),this._fields.set(t.name,e),e}_navigate(t,e){let i=this.getActive();if(i===t&&this._status==="asking"||this.emit("navigate",{from:i,to:t,reason:e}).defaultPrevented)return!1;let n=this._path.indexOf(t);return n>=0?this._path=this._path.slice(0,n+1):this._path.push(t),this._status="asking",this._error="",this._paint(),this._focusItem(),!0}_enterReview(){return this.emit("navigate",{from:this.getActive(),to:null,reason:"review"}).defaultPrevented?!1:(this._status="review",this._error="",this._paint(),this._reviewHost.focus?.(),!0)}async _validateActive(){let t=this._activeItem();if(!t)return!0;let e=this._answerOf(t),i=Vp(t,e,n=>this.msg(n));if(!i&&typeof t.validate=="function"){this._setBusy(!0);try{i=await t.validate(e,this.getAnswers())}catch(n){i=n instanceof Error?n.message:String(n)}finally{this._destroyed||this._setBusy(!1)}}return this._destroyed?!1:(this._error=i?String(i):"",this._paintError(t),this._error?(this.emit("invalid",{name:t.name,message:this._error}),this._focusControl(),!1):!0)}_setBusy(t){this._busy=t,t?this.el.setAttribute("aria-busy","true"):this.el.removeAttribute("aria-busy"),this._syncState(),this._paintActions()}_paint(){this._destroyed||(this._syncState(),this._paintProgress(),this._status==="review"?this._paintReview():this._paintItem(),this._itemHost.hidden=this._status==="review",this._reviewHost.hidden=this._status!=="review",this._paintActions())}_syncState(){this.el.dataset.state=this._busy?"checking":this._status}_paintProgress(){if(this._progressHost.hidden=!this.options.progress||this._items.length===0,this._progressHost.hidden)return;let t=this.getProgress(),e=this.msg("questionnaire.counter",t.index+1,Math.max(t.total,1));this._bar.setLabel(t.section?`${e} \xB7 ${t.section}`:e),this._bar.set(this._status==="asking"?t.percent:100,{silent:!0}),this._bar.setStatus(this._status==="complete"?"success":"active")}_paintItem(){let t=this._activeItem();if(this._itemHost.toggleAttribute("data-empty",!t),!t){this._itemHost.replaceChildren(l("p",{class:"zx-questionnaire__prompt"},this.msg("questionnaire.empty")));return}let e=`${this._uid}-prompt`,i=`${this._uid}-description`,n=`${this._uid}-error`,r=[l("legend",{class:"zx-questionnaire__prompt",id:e},t.prompt)];t.description&&r.push(l("p",{class:"zx-questionnaire__description",id:i},t.description)),r.push(t.field?this._field(t).el:this._choices(t)),r.push(l("p",{class:"zx-questionnaire__error",id:n,role:"alert",hidden:!0})),this._itemHost.replaceChildren(...r),this._itemHost.dataset.item=t.name,this._itemHost.setAttribute("aria-describedby",[t.description?i:"",n].filter(Boolean).join(" ")),this._paintError(t)}_choices(t){let e=new Set((this._selected.get(t.name)??[]).map(n=>String(n))),i=l("div",{class:"zx-questionnaire__choices"});if(i.append(...t.choices.map((n,r)=>l("label",{class:"zx-questionnaire__choice",dataset:{disabled:n.disabled?"true":null}},l("input",{type:t.multiple?"checkbox":"radio",class:"zx-questionnaire__control",name:t.name,value:String(n.value),checked:e.has(String(n.value)),disabled:n.disabled,dataset:{index:r}}),l("span",{class:"zx-questionnaire__marker",ariaHidden:"true"}),n.icon?g(n.icon,{size:16}):null,l("span",{class:"zx-questionnaire__text"},l("span",{class:"zx-questionnaire__label"},n.label),n.description?l("span",{class:"zx-questionnaire__hint"},n.description):null),n.key?l("kbd",{class:"zx-questionnaire__key",ariaHidden:"true"},n.key):null))),t.input){let n=`${this._uid}-freeform`,r=this._freeform.get(t.name)??"",o=l(t.input.multiline?"textarea":"input",{type:t.input.multiline?void 0:"text",class:"zx-questionnaire__freeform-input",id:n,name:t.choices.length>0?`${t.name}__other`:t.name,placeholder:t.input.placeholder||void 0,maxLength:t.input.maxLength>0?t.input.maxLength:void 0,rows:t.input.multiline?3:void 0,autocomplete:"off",value:r});i.append(l("div",{class:"zx-questionnaire__freeform"},l("label",{class:"zx-questionnaire__freeform-label",htmlFor:n},t.input.label),o))}return i}_paintError(t){let e=this._itemHost.querySelector(".zx-questionnaire__error");e instanceof HTMLElement&&(e.textContent=this._error,e.hidden=!this._error),this._error?this._itemHost.setAttribute("aria-invalid","true"):this._itemHost.removeAttribute("aria-invalid");let i=t?.field?this._fields.get(t.name):null;i&&(this._error?i.setHighlight(this._error,"danger"):i.clearHighlight(),e instanceof HTMLElement&&(e.hidden=!0))}_paintReview(){let{answers:t,visible:e}=Zt(this._items,this._rawAnswers()),i=this._path.map(n=>e.find(r=>r.name===n)).filter(n=>!!n).map(n=>l("div",{class:"zx-questionnaire__answer"},l("dt",{class:"zx-questionnaire__answer-prompt"},n.prompt),l("dd",{class:"zx-questionnaire__answer-value",dataset:{empty:Ve(t[n.name])?"true":null}},this._formatAnswer(n,t[n.name])),j({label:this.msg("questionnaire.edit"),kind:"ghost",size:"sm"})));for(let[n,r]of i.entries()){let o=r.querySelector("button");o instanceof HTMLElement&&(o.dataset.edit=this._path[n])}this._reviewHost.replaceChildren(l("p",{class:"zx-questionnaire__review-title"},this.msg("questionnaire.reviewTitle")),l("dl",{class:"zx-questionnaire__answers"},...i))}_formatAnswer(t,e){if(Ve(e))return this.msg("questionnaire.noAnswer");let i=new Map(t.choices.map(r=>[String(r.value),r.label]));return(Array.isArray(e)?e:[e]).map(r=>i.get(String(r))??String(r)).join(", ")}_paintActions(){let t=this._activeItem(),e=this._status==="review",i=this._status==="complete",n=!1;try{n=!!t&&Mo(this._items,t,this._rawAnswers())!==null}catch{n=!1}this._back.hidden=i||!e&&(!this.options.allowBack||this._path.length<=1),this._back.disabled=this._busy,this._skip.hidden=e||i||!t?.skippable,this._skip.disabled=this._busy,this._forward.hidden=i,this._forward.disabled=this._busy||!t&&!e;let r=e?"submit":this._returnToReview||!n&&this.options.review?"review":n?"next":"submit";if(this._forward.dataset.role!==r){this._forward.dataset.role=r;let o=r==="next"?"chevron-right":r==="review"?"list":"check";this._forward.replaceChildren(g(o,{size:16}),l("span",{class:"zx-btn__label"},this.msg(`questionnaire.${r}`)))}}_action(t,e,i,n){let r=j({label:e,icon:i,kind:n});return r.dataset.action=t,r}_onControlChange(t){let e=t.target;if(!(e instanceof HTMLInputElement)||!e.classList.contains("zx-questionnaire__control"))return;let i=this._activeItem();if(!i)return;let n=i.choices[Number(e.dataset.index)];if(n){if(i.multiple){let r=[...this._itemHost.querySelectorAll(".zx-questionnaire__control")].filter(c=>c.checked).map(c=>i.choices[Number(c.dataset.index)].value),o=jp(i.choices,r,e.checked?n.value:null);this._selected.set(i.name,o);let a=new Set(o.map(c=>String(c)));for(let c of this._itemHost.querySelectorAll(".zx-questionnaire__control"))c.checked=a.has(c.value)}else{this._selected.set(i.name,[n.value]),this._freeform.set(i.name,"");let r=this._itemHost.querySelector(".zx-questionnaire__freeform-input");(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="")}this._error="",this._paintError(i),this._paintProgress(),this._paintActions(),this._emitChange(i),this._maybeAutoAdvance(i)}}_onFreeformInput(t){let e=t.target;if(!((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.classList.contains("zx-questionnaire__freeform-input")))return;let n=this._activeItem();if(n){if(this._freeform.set(n.name,e.value),!n.multiple&&e.value.trim()!==""){this._selected.set(n.name,[]);for(let r of this._itemHost.querySelectorAll(".zx-questionnaire__control"))r.checked=!1}this._error="",this._paintError(n),this._paintProgress(),this._paintActions(),this._emitChange(n)}}_onActionClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;!(e instanceof HTMLElement)||!this._actionsHost.contains(e)||(e.dataset.action==="previous"?this.previous():e.dataset.action==="skip"?this.skip():this.next())}_onReviewClick(t){let e=t.target instanceof Element?t.target.closest("[data-edit]"):null;e instanceof HTMLElement&&this.goTo(String(e.dataset.edit))}_onKeydown(t){if(t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey)return;let e=t.target,i=e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["radio","checkbox"].includes(e.type)||e instanceof HTMLElement&&e.isContentEditable;if(t.key==="Enter"){if(e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement)return;t.preventDefault(),this.next();return}if(!this.options.shortcuts||i||t.key.length!==1)return;let n=this._activeItem();if(!n||this._status!=="asking")return;let r=t.key.toLowerCase(),o=n.choices.findIndex(c=>c.key===r&&!c.disabled);if(o<0)return;let a=this._itemHost.querySelector(`.zx-questionnaire__control[data-index="${o}"]`);a instanceof HTMLInputElement&&(t.preventDefault(),a.checked=n.multiple?!a.checked:!0,a.focus(),a.dispatchEvent(new Event("change",{bubbles:!0})))}_maybeAutoAdvance(t){this.options.advance!=="auto"||t.multiple||t.input||(clearTimeout(this._advanceTimer),this._advanceTimer=setTimeout(()=>{!this._destroyed&&this._activeItem()===t&&this.next()},jS))}_emitChange(t){let e=this.getAnswers();this.emit("change",{name:t.name,value:this._answerOf(t),answers:e})}_focusItem(){this._status==="asking"&&this._itemHost.focus?.()}_focusControl(){let t=this._activeItem(),e=t?.field?this._fields.get(t.name):null;if(e){e.focus();return}let i=this._itemHost.querySelector(".zx-questionnaire__control:not(:disabled), .zx-questionnaire__freeform-input");i instanceof HTMLElement?i.focus():this._focusItem()}};function qp(){Fd(),Mc(),Nc(),fd(),Zc(),dd(),Hd(),Kd(),yd(),_d(),qd(),vd(),xd(),Bd(),Ld()}qp();return e_(HS);})();
8
+ `).length}}function z_(s,t){return s.startsWith(t)?t.length:t===" "?s.startsWith(" ")?1:Math.min(/^ +/.exec(s)?.[0].length??0,2):Math.min(/^\s+/.exec(s)?.[0].length??0,t.length)}function Nc(s){let t=String(s??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(t)?t:"text"}function C_(s){let t=Number(s);return Number.isFinite(t)?Math.max(2,Math.min(100,Math.round(t))):12}function T_(s){return["off","soft","hard"].includes(String(s))?s:"off"}function Ws(s,t){let e=Number(s);return Math.max(0,Math.min(t,Number.isFinite(e)?Math.round(e):0))}function Oc(){I.register("code",(s,t)=>{let e=s.own(new He(null,{label:t.label?String(t.label):"Code editor",placeholder:t.placeholder,readOnly:!!t.props?.readOnly,disabled:!!t.disabled,...t.props??{},value:t.value})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),e.on("input",n=>s.emit("input",{value:n.detail.value})),{el:e.el,get:()=>e.getValue(),set:n=>{i=!0;try{e.setValue(n,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadOnly(n)}}})}var Fc=["January","February","March","April","May","June","July","August","September","October","November","December"],Lc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Bc=/%[demYyHMSaAbBs]/g;function N(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":String(t).replace(Bc,e=>{switch(e){case"%d":return qe(s.getDate());case"%e":return String(s.getDate());case"%m":return qe(s.getMonth()+1);case"%Y":return String(s.getFullYear()).padStart(4,"0");case"%y":return qe(s.getFullYear()%100);case"%H":return qe(s.getHours());case"%M":return qe(s.getMinutes());case"%S":return qe(s.getSeconds());case"%a":return Rc("weekday",s.getDay(),Lc[s.getDay()]);case"%A":return Qo("weekday",s.getDay(),Lc[s.getDay()]);case"%b":return Rc("month",s.getMonth(),Fc[s.getMonth()]);case"%B":return Qo("month",s.getMonth(),Fc[s.getMonth()]);case"%s":return String(Math.floor(s.getTime()/1e3));default:return e}})}function tt(s,t){let e=[],i="^",n=0;for(let _ of String(t).matchAll(Bc)){i+=Pc(String(t).slice(n,_.index));let m=_[0],g=I_(m);if(g===null)return null;i+=`(${g})`,e.push(m),n=_.index+m.length}i+=Pc(String(t).slice(n))+"$";let r=new RegExp(i).exec(String(s));if(!r)return null;let o=Object.create(null);if(e.forEach((_,m)=>{o[_]=Number(r[m+1])}),o["%s"]!==void 0){let _=o["%s"]*1e3,m=new Date(_);return Number.isNaN(m.getTime())?null:m}let a=o["%Y"]??E_(o["%y"])??1970,c=(o["%m"]??1)-1,d=o["%d"]??o["%e"]??1,u=o["%H"]??0,h=o["%M"]??0,f=o["%S"]??0,p=new Date(0);return p.setHours(0,0,0,0),p.setFullYear(a,c,d),p.setHours(u,h,f,0),Number.isNaN(p.getTime())||o["%Y"]!==void 0&&p.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&p.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&p.getMonth()!==c||o["%d"]!==void 0&&p.getDate()!==d||o["%e"]!==void 0&&p.getDate()!==d||o["%H"]!==void 0&&p.getHours()!==u||o["%M"]!==void 0&&p.getMinutes()!==h||o["%S"]!==void 0&&p.getSeconds()!==f?null:p}function Qs(s,t,e){let i=s.getTime(),n=t instanceof Date?t.getTime():-1/0,r=e instanceof Date?e.getTime():1/0;return new Date(Math.min(r,Math.max(n,i)))}function U(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function L(s,t){let e=new Date(s.getTime());return e.setDate(e.getDate()+t),e}function Vt(s,t){let e=new Date(s.getTime()),i=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(i,n)),e}function $e(s=dt()){if(!s||s.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(s),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function qe(s){return String(s).padStart(2,"0")}function Qo(s,t,e){let i=`date.${s}.${t}`,n=yt(i);return n===i?e:n}function Rc(s,t,e){let i=`date.${s}.short.${t}`,n=yt(i);return n!==i?n:Qo(s,t,e).slice(0,3)}function I_(s){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[s]??null}function E_(s){if(s!==void 0)return s>=69?1900+s:2e3+s}function Pc(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Xs=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Jo=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Vc=Object.freeze({fa:null,fas:"solid",far:"regular",fal:"light",fat:"thin",fad:"duotone",fab:"brands",fak:"kit",solid:"solid",regular:"regular",light:"light",thin:"thin",duotone:"duotone",brands:"brands",kit:"kit",custom:"kit"}),Zo=Object.freeze({x:"xmark",search:"magnifying-glass",calendar:"calendar-days",reload:"arrows-rotate",dots:"ellipsis",info:"circle-info",warning:"triangle-exclamation",error:"circle-exclamation",success:"circle-check",drag:"grip-vertical",type:"font",hash:"hashtag",mail:"envelope","link-2":"link"}),Xo=new Map;function Js(s){let t=String(s).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let i=t.slice(0,e).toLowerCase(),n=t.slice(e+1);if(i==="builtin"||i==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(Vc,i))return{provider:"fa",name:n,style:Vc[i],classes:null}}return{provider:null,name:t,style:null,classes:null}}function Xi(s,t={}){let{style:e="solid",family:i="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(s).replace(/^fa-/,""),a=r?Zo[o]??o:o,c=[],d=Jo[i];return d&&c.push(d),c.push(Xs[e]??Xs.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function Ji(s){let t=String(s).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${s}`);return`https://kit.fontawesome.com/${t}.js`}function Zs(s){let t=Ji(s),e=Xo.get(t);if(e)return e;let i=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(d=>d.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{Xo.delete(t),r(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!a&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return Xo.set(t,i),i}var qc="http://www.w3.org/2000/svg",$c="0 0 24 24",M_=1.75,D_=1,D=s=>[$c,s,"stroke"];var tn=Object.freeze({"arrow-up-wide-short":D("M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4"),"arrow-down-wide-short":D("M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4"),"chevron-down":D("M6 9l6 6 6-6"),"chevron-up":D("M18 15l-6-6-6 6"),"chevron-left":D("M15 18l-6-6 6-6"),"chevron-right":D("M9 18l6-6-6-6"),check:D("M20 6 9 17l-5-5"),x:D("M18 6 6 18M6 6l12 12"),plus:D("M5 12h14M12 5v14"),minus:D("M5 12h14"),search:D("M21 21l-4.34-4.34M3 11a8 8 0 1 0 16 0a8 8 0 1 0-16 0z"),calendar:D("M8 2v3M16 2v3M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18"),clock:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 6v6l4 2"),trash:D("M10 11v6M14 11v6M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),gear:D("M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),eye:D("M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),lock:D("M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM7 11V7a5 5 0 0 1 10 0v4"),reload:D("M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8M21 3v5h-5"),list:D("M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"),filter:D("M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"),dots:D("M11 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM18 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM4 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),info:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 16v-4M12 8h.01"),warning:D("M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4M12 17h.01"),error:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 8V12M12 16H12.01"),success:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),upload:D("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),drag:D("M8 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),star:D("M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"),heart:D("M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"),tag:D("M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42zM7 7.5a.5 .5 0 1 0 1 0a.5 .5 0 1 0-1 0z"),folder:D("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"),"folder-open":D("M6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"),file:D("M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2zM14 2v5a1 1 0 0 0 1 1h5"),copy:D("M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2zM4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"),square:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2z"),code:D("M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16"),book:D("M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"),"table-cells-large":D("M4 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM4 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1z"),table:D("M12 3v18M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18M3 15h18"),image:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM7 9a2 2 0 1 0 4 0a2 2 0 1 0-4 0zM21 15l-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),columns:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM9 3v18M15 3v18"),type:D("M12 4v16M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M9 20h6"),hash:D("M4 9h16M4 15h16M10 3L8 21M16 3l-2 18"),mail:D("M22 7l-8.991 5.727a2 2 0 0 1-2.009 0L2 7M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-16a2 2 0 0 1-2-2v-12a2 2 0 0 1 2-2z"),"link-2":D("M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 1 1 0 10h-2M8 12h8"),"circle-chevron-down":D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 10l-4 4-4-4")}),N_=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list",grid:"table-cells-large"}),ea=Object.create(null),jt={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function Ke(){return{...jt}}function Zi(s={}){for(let t of["provider","style","family","fixedWidth","kit"])s[t]!==void 0&&(jt[t]=s[t]);return Ke()}function ia(s={}){return Zi({...s,provider:"fontawesome"})}function Kc(){return Zi({provider:"builtin"})}async function Uc(s){let t=typeof s=="string"?{kit:s}:{...s},{kit:e,activate:i=!0,...n}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return Zi({...n,kit:Ji(e)}),await Zs(e),i?ia():Ke()}function Yc(s){for(let[t,e]of Object.entries(s)){if(!Array.isArray(e)||e.length!==2&&e.length!==3||e.length===3&&e[2]!=="fill"&&e[2]!=="stroke")throw new TypeError(`Icon "${t}" must be a [viewBox, path] pair or a [viewBox, path, 'stroke'] triple`);ea[t]=e[2]==="stroke"?[String(e[0]),String(e[1]),"stroke"]:[String(e[0]),String(e[1])]}}function en(){return[...new Set([...Object.keys(tn),...Object.keys(ea)])].sort()}function b(s,t={}){let e=Js(s);if(e.classes)return ta(e.classes,t);let i=N_[e.name]??e.name;return e.provider==="builtin"?jc(i,t):e.provider==="fa"?ta(Xi(i,{style:e.style??t.style??jt.style,family:t.family??jt.family,fixedWidth:t.fixedWidth??jt.fixedWidth}),t):jt.provider==="fontawesome"?ta(Xi(i,{style:t.style??jt.style,family:t.family??jt.family,fixedWidth:t.fixedWidth??jt.fixedWidth}),t):jc(i,t)}function jc(s,t){let e=ea[s]??tn[s];if(!e){if(t.strict)throw new RangeError(`Unknown icon: ${s}`);return R_(s),L_(s,t)}let[i,n,r="fill"]=e,o=Gc(i,r,t),a=document.createElementNS(qc,"path");return a.setAttribute("d",n),o.append(a),o}function Gc(s,t,e){let{size:i=16}=e,n=document.createElementNS(qc,"svg");return n.setAttribute("class",Qc("zx-icon",e.class)),n.setAttribute("viewBox",s),n.setAttribute("width",String(i)),n.setAttribute("height",String(i)),t==="stroke"?(n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width",O_(s,i)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),Wc(n,e.label??null),n}function O_(s,t){let[,,e,i]=s.trim().split(/[\s,]+/).map(Number),n=Math.max(e,i)||24,r=M_*n/24,o=typeof t=="number"?t:/^\d*\.?\d+(px)?$/.test(String(t).trim())?parseFloat(String(t)):NaN;return o>0&&(r=Math.max(r,D_*n/o)),String(Math.round(r*1e3)/1e3)}var F_=$c;function L_(s,t){let e=Gc(F_,"stroke",t);return e.setAttribute("data-zx-icon-missing",s),e}var Hc=new Set;function R_(s){Hc.has(s)||(Hc.add(s),console.warn(`[zx.icon] Unknown icon "${s}" \u2014 rendered an empty placeholder. Add it with registerIcons(), or render Font Awesome with useFontAwesome().`))}function ta(s,t){let{size:e=16}=t,i=document.createElement("i");return i.className=Qc("zx-icon",...s,t.class),i.style.fontSize=typeof e=="number"?`${e}px`:String(e),Wc(i,t.label??null),i}function Wc(s,t){if(t===null){s.setAttribute("aria-hidden","true");return}s.setAttribute("role","img"),s.setAttribute("aria-label",t)}function Qc(...s){return s.flat().filter(Boolean).join(" ")}var P_=5,Ye=class extends y{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??l("div");this.el=t;let e=Xc(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let i=l("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:this._message("timePicker.label","Time")});if(this._content=i,this._addSpin(i,"h",this._message("timePicker.hour","Hour"),23),i.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"m",this._message("timePicker.minute","Minute"),59),this.options.seconds&&(i.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"s",this._message("timePicker.second","Second"),59)),t.append(i),this.options.clock){let n=x("zx-time-picker-clock");i.append(l("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:this._message("timePicker.clock","Pick the time on a clock"),ariaExpanded:"false",ariaControls:n},b("clock",{size:15}))),this._clock=this._buildClock(n),t.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),t}get(){return this._value?{...this._value}:null}set(t,{silent:e=!1}={}){let i=Xc(t);return this._value=i,this._display=i??{h:0,m:0,s:0},this._writeInputs(),!e&&i&&this.emit("change",{time:{...i}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,i,n){let r=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:i,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,i){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?H_(this.options.step):1,o=Ue(t.currentTarget.value,0,i),a=i+1,c=(o+n*r+a*r)%a;t.currentTarget.value=be(c),this._commitFromInputs()}_onInput(t,e,i){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=be(Ue(t.value,0,i)),this._commitFromInputs();let n=this._inputs.indexOf(t);this._inputs[n+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let i of this._inputs){let n=i.dataset.segment,r=n==="h"?23:59;t[n]=Ue(i.value,0,r)}let e=!this._value||!q_(this._value,t);this._value=t,this._display=t,this._writeInputs(),e&&this.emit("change",{time:{...t}})}_writeInputs(){for(let t of this._inputs){let e=t.dataset.segment;t.value=be(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=l("div",{class:"zx-time-picker__clock",id:t,hidden:!0},l("div",{class:"zx-time-picker__clock-head"},l("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectHour","Select the hour"),dataset:{unit:"h"}}),l("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),l("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectMinutes","Select the minutes"),dataset:{unit:"m"}})),l("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},l("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),l("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",i=>{let n=i.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.dataset.value))}),this.listen(this.refs.dial,"keydown",i=>this._onDialKeydown(i)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},i=this._clockUnit==="h";this.set(e),i&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],i=t.target.closest?.(".zx-time-picker__mark"),n=e.indexOf(i);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;r!==void 0?o=(n+r+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=be(this._display.h),this.refs.headMinute.textContent=be(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?this._message("timePicker.hour","Hour"):this._message("timePicker.minutes","Minutes")),!this._clockOpen)return;let e=t?this._display.h:this._display.m,i=t?B_():V_(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==i.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...i.map(a=>this._buildMark(a,e)))}else i.forEach((a,c)=>this._syncMark(n[c],a,e));let r=t&&!j_(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let i=l("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return i.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(i,t,e),i}_syncMark(t,e,i){let n=e.value===i;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}_message(t,e){let i=this.msg(t);return i===t?e:i}};function B_(){let s=[];for(let t=1;t<=12;t+=1)s.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;s.push({value:e,label:be(e),angle:t*30,ring:"inner"})}return s}function V_(){let s=[];for(let t=0;t<60;t+=P_)s.push({value:t,label:be(t),angle:t*6,ring:"outer"});return s}function j_(s){return s>=1&&s<=12}function Xc(s){return s instanceof Date&&!Number.isNaN(s.getTime())?{h:s.getHours(),m:s.getMinutes(),s:s.getSeconds()}:!s||typeof s!="object"?null:{h:Ue(s.h,0,23),m:Ue(s.m,0,59),s:Ue(s.s,0,59)}}function Ue(s,t,e){let i=Number.parseInt(String(s??""),10);return Number.isFinite(i)?Math.max(t,Math.min(e,i)):t}function H_(s){let t=Math.round(Number(s));return Number.isFinite(t)&&t>0&&t<=59?t:5}function be(s){return String(s).padStart(2,"0")}function q_(s,t){return s.h===t.h&&s.m===t.m&&s.s===t.s}var se=class extends y{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??l("div");this._min=wt(sn(this.options.min)),this._max=wt(sn(this.options.max)),this._value=this._normalizeValue(sn(this.options.value)),this._focused=wt(this._value)??this._clampFocus(wt(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=$_(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=l("div",{class:"zx-date-picker__surface"},l("div",{class:"zx-date-picker__header"},l("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousMonth","Previous month")},b("chevron-left")),l("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),l("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextMonth","Next month")},b("chevron-right"))),l("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},l("div",{class:"zx-date-picker__quick-header"},l("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousYear","Previous year")},b("chevron-left")),l("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),l("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextYear","Next year")},b("chevron-right"))),l("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),l("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:this._message("datePicker.calendar","Calendar")},l("thead",{ref:"weekdays"}),l("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",i=>this._onQuickClick(i)),this.listen(this.refs.quickGrid,"keydown",i=>this._onQuickKeydown(i)),this.listen(this.refs.days,"click",i=>this._onDayClick(i)),this.listen(this.refs.days,"keydown",i=>this._onDayKeydown(i)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new Ye(null,{value:this._value,seconds:!1}),this._timePicker.on("change",i=>{let n=i.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return sa(this._value)}set(t,{silent:e=!1}={}){let i=this._normalizeValue(sn(t));return this._value=i,i&&(this._focused=wt(i),this._viewYear=i.getFullYear(),this._viewMonth=i.getMonth()),this._timePicker?.set(i,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:sa(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),i=wt(e);return this._min&&i<this._min&&Jc(e,this._min),this._max&&i>this._max&&Jc(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:this._message("datePicker.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=L(e,(this._weekStart+i)%7);t.append(l("th",{scope:"col",ariaLabel:N(n,"%A")},N(n,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,i=L(t,-e);this.refs.heading.textContent=N(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",this._message("datePicker.chooseMonthYear","Choose month and year, %1",N(t,"%B %Y")));let n=[];for(let r=0;r<6;r+=1){let o=L(i,r*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:this._message("datePicker.week","Week %1",Zc(o))},String(Zc(o))));for(let c=0;c<7;c+=1){let d=L(o,c),u=!!(this._value&&U(d,this._value)),h=!this._inRange(d),f=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:U(d,this._focused)?0:-1,ariaSelected:String(u),ariaDisabled:String(h),ariaCurrent:U(d,new Date)?"date":null,ariaLabel:`${N(d,"%e")} ${N(d,"%B %Y")}`,dataset:{date:N(d,"%Y-%m-%d"),otherMonth:d.getMonth()===this._viewMonth?null:"true"}},N(d,"%e"));a.append(l("td",{role:"presentation"},f))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=tt(e.dataset.date,"%Y-%m-%d");i&&this._inRange(i)&&this._selectDate(i)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=tt(e.dataset.date,"%Y-%m-%d");if(!i)return;let n=null;if(t.key==="ArrowLeft")n=L(i,-1);else if(t.key==="ArrowRight")n=L(i,1);else if(t.key==="ArrowUp")n=L(i,-7);else if(t.key==="ArrowDown")n=L(i,7);else if(t.key==="PageUp")n=Vt(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=Vt(i,t.shiftKey?12:1);else if(t.key==="Home")n=L(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=L(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(i)&&this._selectDate(i);return}n&&(t.preventDefault(),this._moveFocus(n))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=wt(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),i=this._timePicker?.get();i?e.setHours(i.h,i.m,i.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=wt(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:sa(e)})}_pageMonth(t){this._closeQuickPick();let e=Vt(this._focused,t);this._focused=wt(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._viewYear,e,1);t.push(l("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},N(i,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let i=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=i-1;else if(t.key==="ArrowRight")n=i+1;else if(t.key==="ArrowUp")n=i-3;else if(t.key==="ArrowDown")n=i+3;else if(t.key==="Home")n=0;else if(t.key==="End")n=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(i);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;t.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=wt(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=wt(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${N(t,"%Y-%m-%d")}"]`)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function sn(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function wt(s){return s?new Date(s.getFullYear(),s.getMonth(),s.getDate()):null}function sa(s){return s?new Date(s.getTime()):null}function Jc(s,t){s.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function $_(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:$e()}function Zc(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/864e5+1)/7)}var Ge=class extends se{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._min=rn(nn(this.options.min)),this._max=rn(nn(this.options.max)),this._value=this._normalizeMonth(nn(this.options.value));let e=this._value??rn(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let i=l("div",{class:"zx-month-picker__surface"},l("div",{class:"zx-month-picker__header"},l("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.previousYear","Previous year")},b("chevron-left")),l("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),l("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.nextYear","Next year")},b("chevron-right"))),l("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:this._message("monthPicker.chooseMonth","Choose month")}));return this._content=i,t.append(i),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(nn(t)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),e||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(t){if(!t)return null;let e=rn(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._year,e,1),n=!!(this._value&&K_(i,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(i)),ariaLabel:N(i,"%B %Y"),dataset:{month:e}},N(i,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let i=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-3;else if(t.key==="ArrowDown")n=3;else if(t.key==="Home")n=-(i%3);else if(t.key==="End")n=2-i%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(i);return}if(n===null)return;t.preventDefault();let r=this._year*12+i+n;this._year=Math.floor(r/12),this._focusedMonth=(r%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function nn(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function rn(s){return s?new Date(s.getFullYear(),s.getMonth(),1):null}function K_(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()}function td(){I.register("month",(s,t)=>{let e=s.own(new Ge(null,{...t.props??{},value:t.value})),i=!1,n=()=>{e.el.setAttribute("aria-disabled",String(i));for(let r of e.el.querySelectorAll("button"))r.disabled=i};return s.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>s.emit("change",{value:r.detail.date})),{el:e.el,get:()=>e.get(),set:r=>{e.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>e.focus(),setDisabled:r=>{i=!!r,n()}}})}var U_=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function nt(s,t,e={}){if(!(s instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let i=U_.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,a=s.getAttribute("style"),c=t.getAttribute("style"),d=t.getAttribute("popover"),u=!1,h=null,f=()=>{},p=()=>{};t.setAttribute("popover","manual");let _=typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a"),m=`--${x("zx-a")}`;if(_){let g=ed(s);s.style.setProperty("anchor-name",[...g,m].join(", ")),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",m);let w=Y_(i,getComputedStyle(s).direction==="rtl");t.style.setProperty("position-area",w),t.style.setProperty("inset-area",w),t.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let v=i.startsWith("top")?"margin-bottom":i.startsWith("bottom")?"margin-top":i.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(v,`${n}px`),f=()=>{o&&(t.style.minWidth=`${s.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(h=new ResizeObserver(f),h.observe(s))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",f=()=>G_(s,t,{placement:i,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",f,{capture:!0,passive:!0}),window.addEventListener("resize",f,{passive:!0}),typeof ResizeObserver=="function"&&(h=new ResizeObserver(f),h.observe(s)),p=()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)};return W_(t),f(),{update(){u||f()},destroy(){if(!u){if(u=!0,h?.disconnect(),p(),Q_(t),_){let g=ed(s).filter(w=>w!==m);g.length?s.style.setProperty("anchor-name",g.join(", ")):s.style.removeProperty("anchor-name"),a===null&&s.getAttribute("style")===""&&s.removeAttribute("style")}sd(t,"style",c),sd(t,"popover",d)}}}}function ed(s){return String(s.style?.getPropertyValue("anchor-name")??"").split(",").map(t=>t.trim()).filter(t=>t&&t!=="none")}function Y_(s,t){return{"bottom-start":t?"bottom span-left":"bottom span-right","bottom-end":t?"bottom span-right":"bottom span-left","top-start":t?"top span-left":"top span-right","top-end":t?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[s]}function G_(s,t,{placement:e,offset:i,flip:n,matchWidth:r}){let o=s.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,d=document.documentElement.clientHeight||window.innerHeight,u=e,h=id(e),f=o.bottom+i,p=o.top-i-a.height,_=o.right+i,m=o.left-i-a.width;n&&(h==="bottom"&&f+a.height>d&&p>=0?u=on(e,"bottom","top"):h==="top"&&p<0&&f+a.height<=d?u=on(e,"top","bottom"):h==="right"&&_+a.width>c&&m>=0?u=on(e,"right","left"):h==="left"&&m<0&&_+a.width<=c&&(u=on(e,"left","right")));let g=id(u),w,v;if(g==="bottom"||g==="top"){let z=getComputedStyle(s).direction==="rtl";u.endsWith("-end")?w=z?o.left:o.right-a.width:u.endsWith("-start")?w=z?o.right-a.width:o.left:w=o.left+(o.width-a.width)/2,v=g==="bottom"?f:p}else w=g==="right"?_:m,u.endsWith("-end")?v=o.bottom-a.height:u.endsWith("-start")?v=o.top:v=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(q(w,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(q(v,0,Math.max(0,d-a.height)))}px`}function id(s){return s.split("-")[0]}function on(s,t,e){return s.replace(t,e)}function W_(s){if(typeof s.showPopover=="function")try{s.showPopover()}catch{}}function Q_(s){if(typeof s.hidePopover=="function")try{s.hidePopover()}catch{}}function sd(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var X_=6,cd=864e5;function we(s,t){let e=rt(ye(s)),i=rt(ye(t));return e&&i&&e.getTime()>i.getTime()?{start:i,end:e}:{start:e,end:i}}function We(s,t){let e=we(s,t);return!e.start||!e.end?0:Math.round((od(e.end)-od(e.start))/cd)}function oa(s,t,e){let i=rt(ye(s));if(!i)return null;let n=we(t,e);return!n.start&&!n.end?null:n.end?n.start?i.getTime()<n.start.getTime()||i.getTime()>n.end.getTime()?null:U(i,n.start)?"start":U(i,n.end)?"end":"middle":U(i,n.end)?"end":null:U(i,n.start)?"start":null}function Qe(s,t={}){let e=rt(ye(t.min)),i=rt(ye(t.max)),n=an(t.minNights)??0,r=an(t.maxNights),{start:o,end:a}=we(s?.start,s?.end);return o&&(o=ra(o,e,i)),a&&(a=ra(a,e,i)),!o||!a?{start:o,end:a}:(r!==null&&We(o,a)>r&&(a=L(o,r)),n>0&&We(o,a)<n&&(a=L(o,n),i&&a.getTime()>i.getTime()&&(a=new Date(i.getTime()),o=L(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var Xe=class extends y{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._rootAttributes=sm(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=rt(ye(this.options.min)),this._max=rt(ye(this.options.max)),this._minNights=an(this.options.minNights)??0,this._maxNights=an(this.options.maxNights),this._weekStart=tm(this.options.weekStart),this._monthCount=em(this.options.months),this._presets=Z_(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Qe({start:this.options.start,end:this.options.end},this._bounds());this._start=e.start,this._end=e.end,this._picking=!!(e.start&&!e.end),this._remember(),this._focused=ne(this._start)??this._clampFocus(rt(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",K("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let i=l("div",{class:"zx-date-range-picker__surface"},this._presets.length?l("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:K("daterange.presets","Date range presets")},this._presets.map(r=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[i,n],t.append(i,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:ne(this._start),end:ne(this._end)}}set(t={},{silent:e=!1}={}){let i=Qe({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=i.start,this._end=i.end,this._picking=!!(i.start&&!i.end),this._remember(),this._hover=null,i.start?(this._focused=ne(i.start),this._setView(i.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],nm(this.el,this._rootAttributes??new Map),super.destroy()}_bounds(){return{min:this._min,max:this._max,minNights:this._minNights,maxNights:this._maxNights}}_selectable(t){let e=rt(t);if(!e||this._min&&e.getTime()<this._min.getTime()||this._max&&e.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||e.getTime()<=this._start.getTime())return!0;let i=We(this._start,e);return!(i<this._minNights||this._maxNights!==null&&i>this._maxNights)}_choose(t){let e=rt(t);if(this._disabled||!e||!this._selectable(e))return;this._picking&&this._start&&e.getTime()>this._start.getTime()?(this._end=e,this._picking=!1,this._remember()):(this._start=e,this._end=null,this._picking=!0),this._focused=e,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),this._picking||this.emit("change",this.get())}_remember(){let t=!!(this._start&&this._end);this._committedStart=t?ne(this._start):null,this._committedEnd=t?ne(this._end):null}_abandon(){return this._picking?(this._start=ne(this._committedStart),this._end=ne(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return ra(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let i of t)i.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),i=ad(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return!1;let n=i<0?i:i-(e-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),i=ad(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return t;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),n))}_moveFocus(t){let e=rt(t);this._focused=e,this._ensureVisible(e)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(e)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(t){let e=t.target?.closest?.("[data-preset]");if(!e||this._disabled)return;let i=this._presets.find(r=>r.name===e.dataset.preset);if(!i)return;let n=i.range();this.set({start:n?.start??null,end:n?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,i=e?.closest?.("[data-nav]");if(i){this._pageView(i.dataset.nav==="next"?1:-1);return}let n=this._cellFor(e);n&&this._choose(n.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?rt(t):null;!e&&!this._hover||e&&this._hover&&U(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let i=e.date,n=null;if(t.key==="ArrowLeft")n=L(i,-1);else if(t.key==="ArrowRight")n=L(i,1);else if(t.key==="ArrowUp")n=L(i,-7);else if(t.key==="ArrowDown")n=L(i,7);else if(t.key==="PageUp")n=Vt(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=Vt(i,t.shiftKey?12:1);else if(t.key==="Home")n=L(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=L(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(i);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!n||this._disabled||(t.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=N(t,"%B %Y"),i=(t.getDay()-this._weekStart+7)%7,n=L(t,-i),r=[];for(let o=0;o<X_;o+=1){let a=L(n,o*7),c=l("tr"),d=im(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:d?K("daterange.week","Week %1",[ld(a)]):null},d?String(ld(a)):""));for(let u=0;u<7;u+=1){let h=L(a,u),f=l("td",{role:"presentation"});if(h.getMonth()===t.getMonth()&&h.getFullYear()===t.getFullYear()){let p=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:N(h,"%Y-%m-%d")}},N(h,"%e"));f.append(p),this._dayCells.push({date:h,cell:f,button:p})}c.append(f)}r.push(c)}return l("div",{class:"zx-date-range-picker__month"},l("div",{class:"zx-date-range-picker__header"},l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:K("daterange.previousMonth","Previous month")},b("chevron-left")),l("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:K("daterange.nextMonth","Next month")},b("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...r)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:K("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=L(e,(this._weekStart+i)%7);t.append(l("th",{scope:"col",ariaLabel:N(n,"%A")},N(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let i of this._dayCells)U(i.date,this._focused)&&(e=i);e||(e=this._dayCells[0]??null);for(let i of this._dayCells){let{date:n,cell:r,button:o}=i,a=this._dayState(n);na(r,"range",a.range),na(r,"rangeEdge",a.edge),na(o,"range",a.range),o.tabIndex=i===e?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),U(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let i=oa(t,this._start,this._end);if(!i)return{range:null,edge:null};let n=U(this._start,this._end);return i==="start"?{range:i,edge:n?"both":"start"}:i==="end"?{range:i,edge:n?"both":"end"}:{range:i,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return U(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:U(t,e)?"end":null}:{range:null,edge:null}:{range:null,edge:null}}_previewEnd(){if(!this._picking||!this._start||this._disabled)return null;let t=this._hover??this._focused;if(!t)return null;let e=rt(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let i=N(t,"%A, %e %B %Y");return e==="start"?`${i}, ${K("daterange.day.start","range start")}`:e==="end"?`${i}, ${K("daterange.day.end","range end")}`:e==="middle"?`${i}, ${K("daterange.day.middle","in selected range")}`:i}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return K("daterange.status.empty","No date range selected");if(!this._end)return K("daterange.status.start","%1 selected, choose an end date",[N(this._start,"%e %B %Y")]);let t=We(this._start,this._end),e=t===1?K("daterange.night","1 night"):K("daterange.nights","%1 nights",[t]);return`${J_(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(i=>i.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>U(e.date,t))?.button??null}};function aa(){return[{name:"today",label:K("daterange.preset.today","Today"),range:()=>nd(It())},{name:"yesterday",label:K("daterange.preset.yesterday","Yesterday"),range:()=>nd(L(It(),-1))},{name:"last7",label:K("daterange.preset.last7","Last 7 days"),range:()=>({start:L(It(),-6),end:It()})},{name:"last30",label:K("daterange.preset.last30","Last 30 days"),range:()=>({start:L(It(),-29),end:It()})},{name:"thisMonth",label:K("daterange.preset.thisMonth","This month"),range:()=>rd(It(),0)},{name:"lastMonth",label:K("daterange.preset.lastMonth","Last month"),range:()=>rd(It(),-1)},{name:"thisQuarter",label:K("daterange.preset.thisQuarter","This quarter"),range:()=>{let s=It(),t=Math.floor(s.getMonth()/3)*3;return{start:new Date(s.getFullYear(),t,1),end:new Date(s.getFullYear(),t+3,0)}}},{name:"thisYear",label:K("daterange.preset.thisYear","This year"),range:()=>{let s=It();return{start:new Date(s.getFullYear(),0,1),end:new Date(s.getFullYear(),11,31)}}}]}function K(s,t,e){let i=yt(s);return T(i===s?t:i,e)}function J_(s,t){if(U(s,t))return N(s,"%e %B %Y");let e=N(t,"%e %B %Y");return s.getFullYear()!==t.getFullYear()?`${N(s,"%e %B %Y")} \u2013 ${e}`:s.getMonth()!==t.getMonth()?`${N(s,"%e %B")} \u2013 ${e}`:`${N(s,"%e")} \u2013 ${e}`}function Z_(s){return s===!0?aa():Array.isArray(s)?s.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function It(){return rt(new Date)}function nd(s){return{start:s,end:new Date(s.getTime())}}function rd(s,t){return{start:new Date(s.getFullYear(),s.getMonth()+t,1),end:new Date(s.getFullYear(),s.getMonth()+t+1,0)}}function ye(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function rt(s){return!s||Number.isNaN(s.getTime())?null:new Date(s.getFullYear(),s.getMonth(),s.getDate())}function ne(s){return s?new Date(s.getTime()):null}function ra(s,t,e){return t&&s.getTime()<t.getTime()?new Date(t.getTime()):e&&s.getTime()>e.getTime()?new Date(e.getTime()):new Date(s.getTime())}function od(s){return Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())}function ad(s){return s.getFullYear()*12+s.getMonth()}function an(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function tm(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:$e()}function em(s){let t=Number(s);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function im(s,t){for(let e=0;e<7;e+=1){let i=L(s,e);if(i.getMonth()===t.getMonth()&&i.getFullYear()===t.getFullYear())return!0}return!1}function ld(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/cd+1)/7)}function na(s,t,e){e==null?delete s.dataset[t]:s.dataset[t]=e}function sm(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function nm(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}var rm={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function cn(s,t,e){let i=String(s??"").trim();if(i==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",d=r===""?[i]:i.split(new RegExp(`${a}${je(r)}${c}`));if(d.length>2)return null;let u=tt(d[0].trim(),t);if(!u)return null;if(d.length===1)return{start:u,end:new Date(u.getTime())};if(d[1].trim()==="")return{start:u,end:null};let h=tt(d[1].trim(),t);return h?we(u,h):null}function la(s,t,e){let i=s?.start??null,n=s?.end??null;return!i&&!n?"":n?i?`${N(i,t)}${e}${N(n,t)}`:N(n,t):N(i,t)}var Je=class extends y{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._originalClearable=t.getAttribute("data-clearable"),t.toggleAttribute("data-clearable",!!this.options.clearable),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=x("zx-date-range-box-popover"),i=l("div",{class:"zx-date-range-box__content"},l("div",{ref:"control",class:"zx-date-range-box__control"},l("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:dd("daterange.clear","Clear date range")},b("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:dd("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},b("calendar"))),l("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new Xe(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=nt(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(),ln(this.el,"data-state",this._originalState),ln(this.el,"aria-disabled",this._originalAriaDisabled),ln(this.el,"data-clearable",this._originalClearable),super.destroy()}_apply(t,{silent:e=!1,push:i=!0}={}){this._range=t,i&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=cn(t,this._format,this._separator);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this._apply(this._clamp(e))}_coerce(t){return t==null?{start:null,end:null}:typeof t=="string"?this._clamp(cn(t,this._format,this._separator)??{start:null,end:null}):Array.isArray(t)?this._clamp({start:this._toDate(t[0]),end:this._toDate(t[1])}):typeof t!="object"?{start:null,end:null}:this._clamp({start:this._toDate(t.start),end:this._toDate(t.end)})}_toDate(t){return t instanceof Date?Number.isNaN(t.getTime())?null:new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?new Date(t*1e3):typeof t=="string"&&t.trim()!==""?tt(t.trim(),this._format):null}_clamp(t){return Qe(t,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let t=this._format.replace(/%[demYy]/g,e=>rm[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=la(this._range,this._format,this._separator),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear(),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&ln(this.el,"data-state",this._originalState),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}};function dd(s,t,e){let i=yt(s);return T(i===s?t:i,e)}function ln(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}function ud(){I.register("daterange",(s,t)=>{let e=s.own(new Je(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:{start:i.detail.start,end:i.detail.end}})),{el:e.el,get:()=>e.get(),set:i=>e.set(i,{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var et=class extends y{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._originalClearable=t.getAttribute("data-clearable"),t.toggleAttribute("data-clearable",!!this.options.clearable),this._format=om(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=hd(this.options.min),this._max=hd(this.options.max),this._value=this._normalizeValue(this.options.value);let e=x("zx-datebox-popover"),i=l("div",{class:"zx-datebox__content"},l("div",{ref:"control",class:"zx-datebox__control"},l("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??am(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},b("x",{size:13})),l("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},b("calendar"))),l("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new se(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",n=>{this.set(n.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=nt(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),this._originalClearable===null?this.el.removeAttribute("data-clearable"):this.el.setAttribute("data-clearable",this._originalClearable),super.destroy()}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set(null);return}let e=tt(t,this._format);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this.set(e)}_normalizeValue(t){let e=null;return t instanceof Date&&!Number.isNaN(t.getTime())?e=new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?e=new Date(t*1e3):typeof t=="string"&&(e=tt(t,this._format)),!e||Number.isNaN(e.getTime())?null:Qs(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?N(this._value,this._format):"",this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!this._value||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear()}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},dn=function(t,e={}){return new et(t,{...e,time:!0})};function hd(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function om(s,t){let e=String(s||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function am(s){return s.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function pd(){fd("date",s=>new et(null,s)),fd("datetime",s=>dn(null,s))}function fd(s,t){I.register(s,(e,i)=>{let n=e.own(t({...i.props??{},value:i.value}));return e.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>e.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var Ze=class extends y{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??l("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=x("zx-upload");return this._input=l("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=l("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},l("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),l("span",{class:"zx-field-upload__hint"},lm(this.options))),this._preview=l("div",{class:"zx-field-upload__preview"}),this._progress=l("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=l("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=l("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=l("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=l("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragover",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragleave",i=>{(!(i.relatedTarget instanceof Node)||!this._dropzone.contains(i.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",i=>{i.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(i.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let i=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:i}),i)}catch(i){if(e!==this._runId)return null;let n=i instanceof Error?i:new Error(String(i));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),i=this.options.multiple?e:e.slice(0,1);if(i.length===0)return!1;let n=i.find(o=>!dm(o,this.options.accept));if(n)return this._selectionError(new Error(`${n.name} is not an accepted file type.`)),!1;let r=this.options.maxSize==null?null:i.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(`${r.name} exceeds the maximum file size.`)),!1):(this._files=i,this._renderPreview(),this._status.textContent=i.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:i=>this._setProgress(i)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let i=new XMLHttpRequest;this._xhr=i,i.open("POST",String(this.options.url));for(let[n,r]of Object.entries(this.options.headers??{}))i.setRequestHeader(n,String(r));this.listen(i.upload,"progress",n=>{n.lengthComputable&&this._setProgress(n.loaded/n.total*100)}),this.listen(i,"load",()=>{if(i.status<200||i.status>=300){e(new Error(`Upload failed with HTTP ${i.status}`));return}t(hm(i.responseText))}),this.listen(i,"error",()=>e(new Error("Upload request failed"))),this.listen(i,"abort",()=>e(fm())),i.send(um(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(l("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function lm(s){let t=[];return s.accept&&t.push(String(s.accept)),s.maxSize!=null&&t.push(`up to ${cm(Number(s.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function cm(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${Math.round(s/(1024*1024))} MB`}function dm(s,t){if(!t)return!0;let e=String(s.type??"").toLowerCase();return String(t).split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).some(i=>i.startsWith(".")?s.name.toLowerCase().endsWith(i):i.endsWith("/*")?e.startsWith(i.slice(0,-1)):e===i)}function um(s,t,e){let i=new FormData;for(let n of s)i.append(t,n);for(let[n,r]of Object.entries(e??{}))_d(i,n,r);return i}function _d(s,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)_d(s,t,n);return}typeof Blob=="function"&&e instanceof Blob?s.append(t,e):s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function hm(s){if(!s)return null;try{return JSON.parse(s)}catch{return s}}function fm(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let s=new Error("Upload aborted");return s.name="AbortError",s}function md(){I.register("upload",(s,t)=>{let e=s.own(new Ze(null,{...t.props??{}}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("select",()=>s.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:i=>e.setDisabled(i)}})}var gd=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),bd=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),ti=class extends y{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??l("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=l("div",{class:"zx-multi-value-editor__rows"}),this._add=l("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return gd[this.options.reorder]??gd.both}_renderRows(t=-1,e="value"){let i=yd(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((d,u)=>{let h=!n||i.some(([p])=>p===d)?i:[[d,d],...i],f=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${u+1}`,dataset:{index:u}},h.map(([p,_])=>l("option",{value:p,selected:p===d},_))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:d,ariaLabel:`Value ${u+1}`,dataset:{index:u}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:u}},r?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${u+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:u}},b("drag",{size:12})):null,f,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===0),ariaLabel:`Move value ${u+1} up`,dataset:{action:"up",index:u}},b("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===a),ariaLabel:`Move value ${u+1} down`,dataset:{action:"down",index:u}},b("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${u+1}`,dataset:{action:"remove",index:u}},b("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(bd[e]??bd.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.action,n=Number(e.dataset.index);if(i==="add"){let r=yd(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else i==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(i==="up"||i==="down")&&Number.isInteger(n)&&this._move(n,n+(i==="up"?-1:1),i)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let i=Number(e.dataset.index);!Number.isInteger(i)||i<0||i>=this._values.length||(this._values[i]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let i=Number(e.dataset.index),n=t.key==="ArrowUp"?i-1:t.key==="ArrowDown"?i+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(t.preventDefault(),this._move(i,n,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let i=e.closest(".zx-multi-value-editor__row");i&&(i.draggable=!0,this._armed=i)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,i=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,i>e?i-1:i,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[i,n]of e.entries()){let r=n.getBoundingClientRect();if(t<r.top+r.height/2)return i}return e.length}_showDrop(t){let e=[...this._rows.children],i=t===this._dragIndex||t===this._dragIndex+1;for(let[n,r]of e.entries()){let o=r;!i&&n===t?o.dataset.drop="before":!i&&t===e.length&&n===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,i){let n=this._values.length;if(t===e||t<0||e<0||t>=n||e>=n)return!1;let[r]=this._values.splice(t,1);return this._values.splice(e,0,r),this._renderRows(e,i),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function yd(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}function wd(){I.register("multivalueeditor",(s,t)=>{let e=s.own(new ti(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),i=new WeakMap,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(n));for(let o of e.el.querySelectorAll("input, button, select, textarea"))n?(i.has(o)||i.set(o,!!o.disabled),o.disabled=!0):i.has(o)&&(o.disabled=i.get(o),i.delete(o))};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>s.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var Et=class extends y{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t;let e=pm(this.options.step);this._step=e,this._precision=this.options.precision===null?_m(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let i=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=l("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[i,r];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(i,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||this._disabled||this._readonly||(a.preventDefault(),this._stepBy(a.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._coerce(t),n=i!==this._value;return this._value=i,this._syncInput(),n&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return l("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},b(e,{size:13}))}get _rangeMin(){return this._min!==void 0?this._min:this.options.min===null||this.options.min===void 0?null:Number(this.options.min)}get _rangeMax(){return this._max!==void 0?this._max:this.options.max===null||this.options.max===void 0?null:Number(this.options.max)}_coerce(t){let e=ve(t,this.options.group?this._separators():null);return e===null?null:ts(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,i=this._rangeMax,r=ve(this.refs.input.value)??this._value,o=r===null?e??0:r,a=r===null&&t>0&&e!==null?e-this._step*t:o,c=vd(a+this._step*t,this._precision);return this.options.wrap&&e!==null&&i!==null&&(c>i?c=e:c<e&&(c=i)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=ve(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly||t.altKey||t.ctrlKey||t.metaKey)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,i=this._rangeMin,n=this._rangeMax;if(i===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(i)),n===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(n)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let r=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${r}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let i=this.msg(t);return i===t?e:i}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function ve(s,t=null){if(typeof s=="number")return Number.isFinite(s)?s:null;if(s==null)return null;let e=String(s).trim();if(e==="")return null;let i;if(t)i=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");i=r,o>=0&&o>a?i=r.replace(/\./g,"").replace(",","."):o>=0&&(i=r.replace(/,/g,""))}if(!/\d/.test(i))return null;let n=Number(i);return Number.isFinite(n)?n:null}function ts(s,{min:t,max:e,step:i,precision:n}){let r=s;if(i>0){let o=t??0;r=o+Math.round((s-o)/i)*i}return r=vd(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function pm(s){let t=Number(s);return Number.isFinite(t)&&t>0?t:1}function _m(s){let t=String(s),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let i=t.split(".")[1];return i?i.length:0}function vd(s,t){return Number.isFinite(s)?Number(s.toFixed(Math.min(15,Math.max(0,t)))):s}function xd(){I.register("number",(s,t)=>{let e=s.own(new Et(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,name:s.name||null,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{i=!0;try{e.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadonly(n)}}})}var ei=class extends y{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:"Rating",icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=x("zx-rating");let e=l("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let i=1;i<=this._max;i+=1){let n=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},b(this.options.icon,{size:es[this.options.size]??es.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},b(this.options.icon,{size:es[this.options.size]??es.md})));this.options.allowHalf?n.append(this._radio(i-.5,"half"),this._radio(i,"full")):n.append(this._radio(i,"full")),e.append(n)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=es[this.options.size]?this.options.size:"md",this.listen(e,"keydown",i=>this._onKeydown(i)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._clamp(t),n=i!==this._value;return this._value=i,this._preview=null,this._sync(),n&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let i=l("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(i,"click",n=>{this._choose(t,n.detail>0)}),this.listen(i,"pointerenter",()=>this._setPreview(t)),this.listen(i,"focus",()=>this._setPreview(t)),this.listen(i,"blur",()=>this._setPreview(null)),this._radios.push(i),i}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let i=Math.round(t/this._step)-1;if(e[i]!=null)return String(e[i])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,i){let n=this.msg(t,...i);return n===t?T(e,i):n}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],i=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(i.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let i=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,i))}_sync(){for(let e of this._radios){let i=Number(e.dataset.value);e.setAttribute("aria-checked",String(i===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((i,n)=>{let r=Math.min(1,Math.max(0,t-n));i.style.setProperty("--zx-rating-fill",`${r*100}%`),i.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,i=[];this.options.showValue&&i.push(mm(this._value,this._step)),e!=null&&i.push(this._message("rating.count","%1 ratings",[e])),t.textContent=i.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},es={sm:14,md:18,lg:24};function mm(s,t){return t<1?s.toFixed(1):String(s)}function Sd(){I.register("rating",(s,t)=>{let e=s.own(new ei(null,{label:t.label?String(t.label):void 0,...t.props??{}})),i=!1;return e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get()||null,set:n=>{i=!0;try{e.set(Number(n)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadonly(n)}}})}var kd=["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(","),gm=["hidden","disabled","aria-disabled","aria-hidden"],bm=new Set(["button","checkbox","color","file","image","reset","submit"]);function un(s){let t=!1,e=null;function i(n){if(n.key!=="Tab")return;let r=Ad(s);if(r.length===0){n.preventDefault();return}let o=r[0],a=r[r.length-1];n.shiftKey&&(document.activeElement===o||!s.contains(document.activeElement))?(n.preventDefault(),a.focus()):!n.shiftKey&&(document.activeElement===a||!s.contains(document.activeElement))&&(n.preventDefault(),o.focus())}return{activate(){t||(t=!0,e=document.activeElement,document.addEventListener("keydown",i),Ad(s)[0]?.focus())},deactivate(){t&&(t=!1,document.removeEventListener("keydown",i),e?.isConnected&&typeof e.focus=="function"&&e.focus(),e=null)}}}function Mt(s,t,{orientation:e="vertical",wrap:i=!0,rtl:n="auto"}={}){let r=new AbortController,o=new Map,a=!1;function c(){return Array.from(s.querySelectorAll(t)).filter(m=>(d(m),ca(m)))}function d(m){o.has(m)||o.set(m,m.getAttribute("tabindex"))}function u(m=null){let g=c(),w=m&&g.includes(m)?m:g.find(v=>v.tabIndex===0)??g[0];for(let v of g){let z=v===w?0:-1;v.tabIndex!==z&&(v.tabIndex=z)}}function h(m){let g=c(),w=m.target?.closest?.(t)??null,v=g.indexOf(w);if(v<0)return;let z=e==="horizontal"&&xm(s,n),C=ym(m.key,e,z);if(C===null||!vm(m.target,C))return;let k=C==="first"?0:C==="last"?g.length-1:C==="previous"?v-1:v+1;g.length!==0&&(i?k=(k+g.length)%g.length:k=Math.max(0,Math.min(g.length-1,k)),m.preventDefault(),u(g[k]),g[k].focus())}function f(m){let g=m.target?.closest?.(t)??null;g&&s.contains(g)&&u(g)}s.addEventListener("keydown",h,{signal:r.signal}),s.addEventListener("focusin",f,{signal:r.signal});let p=typeof MutationObserver=="function"?new MutationObserver(m=>{m.some(_)&&u()}):null;p?.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:gm}),u();function _(m){if(m.type==="attributes")return m.target instanceof Element&&(m.target.matches(t)||m.target.querySelector(t)!==null);for(let g of m.addedNodes)if(g instanceof Element&&(g.matches(t)||g.querySelector(t)))return!0;for(let g of m.removedNodes)if(g instanceof Element){if(o.has(g))return!0;for(let w of o.keys())if(g.contains(w))return!0}return!1}return{focusFirst(){let m=c()[0];m&&(u(m),m.focus())},focusLast(){let m=c(),g=m[m.length-1];g&&(u(g),g.focus())},destroy(){if(!a){a=!0,r.abort(),p?.disconnect();for(let[m,g]of o)g===null?m.removeAttribute("tabindex"):m.setAttribute("tabindex",g);o.clear()}}}}function hn(s,t){let e=s?.ownerDocument?.activeElement??null;if(!e||e===s||!s.contains(e))return null;let i=t(e);if(!i)return null;let n=zd(i.element);return{key:i.key,self:e===i.element,index:n.indexOf(e),signature:Cd(e)}}function fn(s,t,e){if(!t||!s)return!1;let i=s.ownerDocument?.activeElement??null;if(i&&i!==s.ownerDocument?.body&&i.isConnected&&s.contains(i))return!1;let n=e(t.key);if(!n)return!1;let r=zd(n),o=t.self?n:r.find(a=>Cd(a)===t.signature)??r[t.index]??r.at(-1)??null;return!o||typeof o.focus!="function"?!1:(o.focus({preventScroll:!0}),s.ownerDocument?.activeElement===o)}function zd(s){return Array.from(s.querySelectorAll(`${kd},[tabindex="-1"]`)).filter(t=>ca(t))}function Cd(s){let t=Object.entries(s.dataset??{}).map(([i,n])=>`${i}=${n}`).sort().join("&"),e=s.getAttribute("aria-label")??s.textContent?.trim()??"";return`${s.tagName}|${t}|${e}`}function ut(s,t){let e="",i=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;i!==null&&clearTimeout(i),e+=o.toLocaleLowerCase(),e.split("").every(d=>d===e[0])&&(e=e[0]),i=setTimeout(()=>{e="",i=null},500);let a=s(),c=a.findIndex(d=>Sm(d).startsWith(e));c>=0&&t(a[c],c)}}function ym(s,t,e=!1){return s==="Home"?"first":s==="End"?"last":t==="horizontal"?s==="ArrowLeft"?e?"next":"previous":s==="ArrowRight"?e?"previous":"next":null:s==="ArrowUp"?"previous":s==="ArrowDown"?"next":null}function wm(s){if(!s||typeof s!="object")return!1;let t=String(s.tagName??"").toUpperCase();return t==="TEXTAREA"||t==="SELECT"?!0:t==="INPUT"?!bm.has(String(s.type??"text").toLowerCase()):!!s.isContentEditable}function vm(s,t){if(!wm(s))return!0;if(t==="first"||t==="last"||String(s?.tagName??"").toUpperCase()!=="INPUT")return!1;let e=s,i,n;try{i=e.selectionStart,n=e.selectionEnd}catch{return!1}return typeof i!="number"||typeof n!="number"||i!==n?!1:t==="previous"?i===0:n===String(e.value??"").length}function xm(s,t){if(t===!0||t===!1)return t;try{return globalThis.getComputedStyle?.(s)?.direction==="rtl"}catch{return!1}}function Ad(s){return Array.from(s.querySelectorAll(kd)).filter(t=>ca(t)&&t.getClientRects().length>0)}function ca(s){return!(!(s instanceof HTMLElement)||s.hidden||s.getAttribute("aria-hidden")==="true"||s.matches(":disabled"))}function Sm(s){if(typeof s=="string"||typeof s=="number")return String(s).trim().toLocaleLowerCase();if(s&&typeof s=="object"&&"textContent"in s)return String(s.textContent??"").trim().toLocaleLowerCase();if(s&&typeof s=="object"){let t=s,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(s??"").trim().toLocaleLowerCase()}var Am=/^var\(\s*--[\w-]+\s*\)$/;function pn(s){if(typeof s!="string")return null;let t=s.trim();return Am.test(t)||ee(t)?t:null}var ua=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),ha=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),fa=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"]]),km=Object.freeze({review:"in-review",cancelled:"canceled"}),da=4;function zm(s,t={}){let e=s&&typeof s=="object"?s:null,i=Cm(e?e.ID??e.id:s),n=fa.find(([a])=>a===i),r=String(t.indicator??e?.indicator??n?.[3]??"ring"),o=String(t.tone??e?.tone??n?.[4]??"muted");return{indicator:ua.includes(r)?r:"ring",tone:ha.includes(o)?o:"muted"}}function Cm(s){let t=String(s??"").trim().toLowerCase();return km[t]??t}function pa(s){return s==null||s===""?null:Math.max(0,Math.min(da,Math.trunc(Number(s)||0)))}function _n(s,t={}){let{indicator:e,tone:i}=zm(s,t??{}),n=l("span",{class:"zx-status-icon",dataset:{indicator:e,tone:i}});return e==="done"&&n.append(b("check",{size:8})),e==="canceled"&&n.append(b("x",{size:7})),Td(n,t?.label)}function mn(s,t={}){let e=pa(s),i=l("span",{class:"zx-priority-icon",dataset:{level:e===null?"none":e}},e===da?null:Array.from({length:da},(n,r)=>l("span",{dataset:{filled:String(e!==null&&r<=e)}})));return Td(i,t?.label)}function Td(s,t){let e=t==null?"":String(t).trim();return e?(s.setAttribute("role","img"),s.setAttribute("aria-label",e)):s.setAttribute("aria-hidden","true"),s}var Tm=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],Id=["Lowest","Low","Medium","High","Highest"],$=class s extends y{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",label:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._snapshot=null,this._pointerModality=!1,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._snapshot=this._createdRoot?null:A(t);let e=x("zx-select-list"),i=l("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",ariaLabel:String(this.options.label||this.options.placeholder||"Select"),autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=l("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=l("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},b("x",{size:13})),o=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},b("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,i,r,o,a),d=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});d.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let u=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},d);return t.replaceChildren(c,u),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=Ed(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=ut(()=>this._optionEntries.filter(h=>!h.clear&&!h.action).map(h=>h.element),(h,f)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(f))}),this.listen(i,"click",()=>this.open()),this.listen(i,"input",()=>this._onInput()),this.listen(i,"keydown",h=>{Dd(h)||t.removeAttribute("data-focus-origin"),this._onKeydown(h)}),this.listen(i,"focus",()=>{this._pointerModality&&i.readOnly?t.setAttribute("data-focus-origin","pointer"):t.removeAttribute("data-focus-origin")}),this.listen(i,"blur",()=>t.removeAttribute("data-focus-origin")),this.listen(document,"keydown",h=>{Dd(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(u,"pointerdown",h=>h.preventDefault()),this.listen(u,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._pointerModality=!0,this._open&&!t.contains(h.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get(){return this.value}get selected(){return this._selected}set(t,{silent:e=!1}={}){let i=this.value,n=t==null?null:this._findItem(t);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!e&&!Object.is(i,r)&&this.emit("change",{value:r,item:n}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setActions(t){return this._actions=Ed(t),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=nt(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let i=e.value??null,n=e.clearable??!0,r=null,o=()=>e.noneLabel??(r?r._message("priority.none","No priority"):"No priority");r=new s(t,{...e,clearable:n,value:null,items:[],renderItem(c){return Md(c,!0)},renderNone:e.renderNone??(()=>Md({level:null,name:o()},!0)),renderValueAdornment(c){return Od(c.level)}}),n&&!e.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(Tm.map((c,d)=>{let u=d===2?a.msg("priority.medium"):c;return(u==="priority.medium"||d!==2)&&(u=a._message(c,Id[d])),{ID:d,name:u,level:d}})),r.set(i,{silent:!0}),r}static status(t,e={}){let{items:i=null,value:n=null,...r}=e,o=new s(t,{...r,value:null,items:[],renderItem(c){return Dm(c)},renderValueAdornment(c){return Fd(c)}}),a=Array.isArray(i)?i.map(Mm).filter(Boolean):fa.map(([c,d,u,h,f],p)=>({ID:c,name:o._message(d,u),indicator:h,tone:f,shortcut:String(p+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(t,e={}){let{recent:i=[],recentLabel:n="Recent",create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:c="description",renderIcon:d=null,fixedItems:u=[],actions:h=[],renderItem:f=null,renderValueAdornment:p=null,..._}=e,m=(v,z=!1)=>{if(typeof d=="function")return d(v,{selected:z});let C=gn(v,o);if(C&&typeof C=="object"&&typeof C.nodeType=="number")return C.cloneNode(!0);if(typeof C!="string"||!C)return null;let k=pn(gn(v,a));return l("span",{class:"zx-select__entity-glyph",style:k?{"--zx-select-entity-color":k}:null,ariaHidden:"true"},b(C,{size:14}))},g=r?Im(r):null,w=new s(t,{..._,fixedItems:[...Array.isArray(i)?i:[],...Array.isArray(u)?u:[]],fixedLabel:Array.isArray(i)&&i.length?n:_.fixedLabel??null,actions:[...Array.isArray(h)?h:[],...g?[g]:[]],renderItem:f??(v=>{let z=m(v,!1),C=gn(v,c),k=l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(gn(v,_.labelKey??"name")??"")),C==null||C===""?null:l("span",{class:"zx-select__entity-subtitle"},String(C)));return l("span",{class:"zx-select__entity"},z?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},z):null,k)}),renderValueAdornment:p??(v=>m(v,!0))});return w.el.dataset.preset="entity",w}static permission(t,e={}){let{groups:i=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...c}=e,d=typeof i=="function"?i:null,u=d?[]:i,h=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],f=new s(t,{filter:d??a,...c,value:null,items:u,fixedItems:[],valueKey:p=>h.includes(p)?p.ID:ma(p,r),labelKey:p=>h.includes(p)?p.name:String(ma(p,o)??"")});return h[0].name=f._message("permission.private","Private"),h[1].name=f._message("permission.public","Public"),f.setFixedItems(h),f.set(n,{silent:!0}),f}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;!this._createdRoot&&t&&S(t,this._snapshot),super.destroy()}_onKeydown(t){if(!this._disabled){if(this._open&&Nd(t)){let e=this._optionEntries.findIndex(i=>!i.clear&&!i.action&&String(i.item?.shortcut??"")===t.key);if(e>=0){t.preventDefault(),this._setActive(e),this._chooseEntry(this._optionEntries[e]);return}}if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&Nd(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._syncValueAdornment(),this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=ie(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){if(t){if(t.action){let e={id:t.action.id,action:t.action,query:this.refs.input.value,select:this};this.emit("action",e).defaultPrevented||t.action.invoke?.(e),this.close(),this.focus();return}this.set(t.clear?null:t.item),this.close(),this.focus()}}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((i,n)=>{n===this._activeIndex?i.element.setAttribute("data-active","true"):i.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group"),i=this._uniqueItems(this._visibleFixed),n=this._uniqueItems(this._visibleItems,i);this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection")),i.length>0&&this.options.fixedLabel&&t.append(l("div",{class:"zx-select__group",role:"presentation"},String(this.options.fixedLabel)));for(let r of i)this._appendOption(r,!1);i.length>0&&n.length>0&&!this.options.groupKey&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));for(let r of n){if(this.options.groupKey){let o=this._read(r,this.options.groupKey);Object.is(o,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(o??""))),e=o)}this._appendOption(r,!1)}if(this._actions.length>0){(i.length>0||n.length>0||this.options.clearable)&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(t.append(l("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&i.length===0&&this._actions.length===0&&!this._loading&&t.append(l("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,i){let n=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),r=this._optionEntries.length,o=e&&typeof this.options.renderNone=="function"?_a(this.options.renderNone(String(i??""))):e?String(i??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:x("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},l("span",{class:"zx-select__option-content"},o));n&&a.append(b("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,action:null,element:a})}_appendAction(t){let e=this._optionEntries.length,i=Em(t.icon),n=l("div",{class:"zx-select__option zx-select__action",id:x("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},l("span",{class:"zx-select__option-content zx-select__action-content"},i?l("span",{class:"zx-select__action-icon",ariaHidden:"true"},i):null,l("span",{class:"zx-select__action-copy"},l("span",{class:"zx-select__action-label"},t.label),t.description?l("span",{class:"zx-select__action-description"},t.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:t,element:n})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return _a(e)}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},i)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(i)?i.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let t=this.refs.valueAdornment;if(!t)return;let e=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),i=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&i!==e){t.replaceChildren(),t.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=_a(n);t.replaceChildren(r instanceof Node?r:document.createTextNode(r)),t.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,i=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,i.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],i=e.find(r=>r===t);if(i!==void 0)return i;let n=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return ma(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return ie(this._fixedItems,t,this._searchKeys())}_uniqueItems(t,e=[]){let i=e.map(n=>this._itemValue(n));return t.filter(n=>{let r=this._itemValue(n);return i.some(o=>Object.is(o,r))?!1:(i.push(r),!0)})}_selectedEntryIndex(){return this._selected===null?this.options.clearable?0:-1:this._optionEntries.findIndex(t=>!t.clear&&Object.is(this._itemValue(t.item),this.value))}_itemEntryIndex(t){return t+(this.options.clearable?1:0)}_message(t,e){let i=this.msg(t);return i===t?e:i}};function gn(s,t){return typeof t=="function"?t(s):s!==null&&typeof s=="object"&&typeof t=="string"?s[t]:null}function Im(s){let t=s===!0?{}:s;return{id:t.id??"create",label:t.label??"Create new\u2026",description:t.description,group:t.group??"New",icon:t.icon??"plus",invoke:t.invoke}}function _a(s){return s&&typeof s=="object"&&"nodeType"in s?s:String(s??"")}function Ed(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label),description:t.description==null?void 0:String(t.description),group:t.group==null?void 0:String(t.group)})):[]}function Em(s){return typeof s=="string"?b(s):s instanceof Node?s.cloneNode(!0):null}function Md(s,t){return l("span",{class:"zx-select__priority"},Od(s.level),t?l("span",{},String(s.name)):null)}function Od(s){let t=mn(pa(s));return t.classList.add("zx-select__priority-icon"),t}function Mm(s){return!s||typeof s!="object"||s.ID==null||s.name==null?null:{...s,name:String(s.name),indicator:ua.includes(String(s.indicator))?String(s.indicator):"ring",tone:ha.includes(String(s.tone))?String(s.tone):"muted",description:s.description==null?"":String(s.description),shortcut:s.shortcut==null?"":String(s.shortcut)}}function Dm(s){return l("span",{class:"zx-select__status"},Fd(s),l("span",{class:"zx-select__status-copy"},l("span",{class:"zx-select__status-label"},String(s.name)),s.description?l("span",{class:"zx-select__status-description"},s.description):null),s.shortcut?l("kbd",{class:"zx-select__status-shortcut"},s.shortcut):null)}function Fd(s){let t=_n({indicator:s.indicator??"ring",tone:s.tone??"muted"});return t.classList.add("zx-select__status-indicator"),t}function ma(s,t){return typeof t=="function"?t(s):s===null||typeof s!="object"?s:s[t]}function Dd(s){return["Shift","Control","Alt","Meta","CapsLock"].includes(s.key)||s.ctrlKey||s.metaKey}function Nd(s){return s.key.length===1&&!s.ctrlKey&&!s.metaKey&&!s.altKey}function Ld(){I.register("zxselect",(s,t)=>{let e=t.props??{},i=e.preset,n={...e,value:t.value,label:t.label||e.label,placeholder:e.placeholder??t.placeholder};s.listen(s.el,"click",o=>{o.target.closest?.(".zx-field__label")&&s.adapter.focus()}),delete n.preset,i==="priority"&&e.clearable===void 0&&(n.clearable=!t.required);let r=s.own(i==="priority"?$.priority(null,n):i==="status"?$.status(null,n):new $(null,n));return s.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>s.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var ii=class extends y{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=x("zx-slider");let e=l("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),i=l("div",{class:"zx-slider__track"},e,this._marks()),n=l("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(i),this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),t.replaceChildren(l("div",{class:"zx-slider__head"},l("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),l("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",r=>{this._readonly&&Nm.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._snap(t),n=i!==this._value;return this._value=i,this._paint(),n&&!e&&this.emit("change",{value:i}),this}setRange(t,e,i){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,i!==void 0&&(this._step=Math.abs(Number(i))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=l("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=l("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let i of t){let n=typeof i=="number"?i:Number(i?.value);if(!Number.isFinite(n))continue;let r=typeof i=="number"?this._format(n):String(i.label??this._format(n));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":String(this._ratio(n))}},r))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?ts(e,{min:this._min,max:this._max,step:this._step,precision:ga(this._step)}):this._min}_ratio(t){return q((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${Om(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},Nm=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function ga(s){let t=String(s),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function Om(s){return String(Number(s.toFixed(6)))}function Rd(){I.register("slider",(s,t)=>{let e=s.own(new ii(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),e.on("input",n=>s.emit("input",{value:n.detail.value})),{el:e.el,get:()=>e.get(),set:n=>{i=!0;try{e.set(Number(n)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadonly(n)}}})}var Fm=Object.freeze(["neutral","accent","success","warning","danger","info"]),Lm=Object.freeze(["soft","solid","outline"]),ba=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Rm=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function ht(s={}){let t={...Rm,...s},e=l("span",{class:"zx-badge",title:t.title,dataset:{kind:Pm(t.kind),variant:Bm(t.variant),size:Vm(t.size),tone:ya(t.tone)??void 0}});return t.dot?e.append(l("span",{class:"zx-badge__dot",ariaHidden:"true"})):t.icon&&e.append(b(t.icon,{size:12,class:"zx-badge__icon"})),t.label!==""&&t.label!=null?e.append(l("span",{class:"zx-badge__label"},String(t.label))):t.title&&(e.setAttribute("role","img"),e.setAttribute("aria-label",t.title)),e}function Pd(s){let t=l("span",{class:"zx-badge-group"});return t.append(...s),t}function Pm(s){return Fm.includes(s)?s:"neutral"}function Bm(s){return Lm.includes(s)?s:"soft"}function ya(s){return ba.includes(s)?s:null}function Vm(s){return s==="sm"?"sm":"md"}var re=class extends y{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:A(this.el);let t=this.el??l("div");this.el=t;let e=x("zx-tag-picker-list"),i=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=l("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=l("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},b("chevron-down",{size:15})),o=l("div",{ref:"control",class:"zx-tag-picker__control"},i,n,r),a=l("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=l("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",d=>{let u=d.target;u.closest(".zx-tag-picker__remove")||u.closest(".zx-tag-picker__toggle")||(d.target!==n&&(d.preventDefault(),this.focus()),this._open||this.open())}),this.listen(i,"click",d=>{let u=d.target.closest(".zx-tag-picker__remove");if(!u||this._disabled||this._readonly)return;d.stopPropagation();let h=[...i.children].indexOf(u.closest(".zx-tag-picker__tag")),f=this._selected[h];f!==void 0&&(this.removeValue(this._valueOf(f)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",d=>this._onKeydown(d)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",d=>d.preventDefault()),this.listen(c,"click",d=>this._onOptionClick(d)),this.listen(document,"pointerdown",d=>{this._open&&!t.contains(d.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),t}get values(){return this.getValues()}set values(t){this.setValues(t)}getValues(){return this._selected.map(t=>this._valueOf(t))}getItems(){return this._selected.slice()}setValues(t,{silent:e=!1}={}){let i=Array.isArray(t)?t:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of i){if(r.length>=n)break;let c=this._resolve(a);c!==null&&!r.some(d=>this._sameValue(d,c))&&r.push(c)}let o=!jm(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let i=this._resolve(t);return i===null?this:this._selected.some(n=>this._sameValue(n,i))?this:(this._selected.push(i),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(i),item:i}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let i=this._valueOf(this._resolve(t)??t),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),i));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=nt(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._entries.length>0?0:-1),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(this.refs.input.value),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._activeId=null,this.refs.input.value="",this._syncInputWidth(),this._applyLocalFilter(""),this.emit("close",{}),this):this}focus(){return this.refs.input.focus(),this}enable(){return this._disabled=!1,this._renderTags(),this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._renderTags(),this._syncDisabled(),this}setReadonly(t){return t&&this.close(),this._readonly=!!t,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let i=this._labelOf(e),n=this._toneOf(e),r=n?null:this._colorOf(e),o=this.options.renderTag?this.options.renderTag(e):[this._iconOf(e),l("span",{class:"zx-tag-picker__tag-label"},i)],a=l("span",{class:"zx-tag-picker__tag",dataset:{colored:String(!!r),tone:n??void 0},style:r?{"--zx-tag-color":r}:null},o);return!this._readonly&&!this._disabled&&a.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[i])},b("x",{size:11}))),a});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:x("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?b("check",{size:13}):null),l("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),l("span",{},this._labelOf(r))]));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let i=this.refs.input.value.trim();if(this._canCreate(i)){let r=l("div",{class:"zx-tag-picker__option",id:x("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},b("plus",{size:13})),l("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[i])));this._entries.push({item:null,element:r,create:!0}),e.push(r)}e.length===0&&e.push(l("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let i=this._entries.find(n=>n.element===e);i&&this._commitEntry(i)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let i=e.value.trim(),n=this._createItem(i);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let i=this._valueOf(t.item);if(this._isSelected(i))this.removeValue(i);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,i]of this._entries.entries()){let n=e===t;i.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",i.element.id),i.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=ie(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},i)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(i)?i.slice():[],this._visible=this._items.slice()}catch(i){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:i})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=i=>i.some(n=>Bd(this._labelOf(n))===Bd(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),i=this._items.find(r=>Object.is(this._valueOf(r),e));if(i!==void 0)return i;let n=this._selected.find(r=>Object.is(this._valueOf(r),e));return n!==void 0?n:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_iconOf(t){let e=this._readItem(t,this.options.iconKey),i=e&&typeof e=="object"&&typeof e.nodeType=="number"?e.cloneNode(!0):typeof e=="string"&&e.trim()?b(e,{size:12}):null;if(!i)return null;let n=this._toneOf(t),r=n?null:this._colorOf(t);return l("span",{class:"zx-tag-picker__visual",dataset:{tone:n??void 0},style:r?{"--zx-tag-color":r}:null,ariaHidden:"true"},i)}_colorOf(t){return pn(this._readItem(t,this.options.colorKey))}_toneOf(t){return ya(this._readItem(t,this.options.toneKey))}_readItem(t,e){return typeof e=="function"?e(t):t!==null&&typeof t=="object"&&typeof e=="string"?t[e]:null}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,i=[]){let n=this.msg(t,...i);return n!==t?n:i.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),e)}};function Bd(s){return String(s??"").trim().toLocaleLowerCase()}function jm(s,t,e){return s.length!==t.length?!1:s.every((i,n)=>Object.is(e(i),e(t[n])))}function Vd(){I.register("tagpicker",(s,t)=>{let e=s.own(new re(null,{placeholder:t.placeholder,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.values})}),{el:e.el,get:()=>e.getValues(),set:n=>{i=!0;try{e.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable(),setReadonly:n=>{e.setReadonly(n)}}})}function wa(s,t="minutes"){let e=Math.round(Math.abs(jd(xe(s),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:xe(s)<0}}function va(s,t="minutes"){is(t);let e=Math.abs(Math.trunc(xe(s?.hours))),i=Math.abs(Math.trunc(xe(s?.minutes))),n=Math.abs(Math.trunc(xe(s?.seconds))),r=s?.negative?-1:1;return Hd(r*(e*3600+i*60+n),t)}var Dt=class extends y{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){is(this.options.unit);let t=this.el??l("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=l("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?this._message("timebox.durationWithSeconds","Duration in hours, minutes, and seconds"):this._message("timebox.duration","Duration in hours and minutes")});return this._content=e,this.options.signed&&(e.append(l("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:this._message("timebox.toggleSign","Toggle duration sign"),ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours",this._message("timebox.hours","Hours"),!1),e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes",this._message("timebox.minutes","Minutes"),!0),this.options.seconds&&(e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds",this._message("timebox.seconds","Seconds"),!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return va(this._readParts(),t)}set(t,e=this.options.unit,i={}){e&&typeof e=="object"&&(i=e,e=this.options.unit),is(e);let n=xe(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=Hd(Math.round(jd(n,e)/60)*60,e)),this._parts=wa(n,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),i.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,i,n){let r=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:i,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let i=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[i]=Math.max(0,Math.min(n,Math.trunc(xe(e.value))))}return t}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let t of this._inputs){let e=t.dataset.segment;t.value=e==="hours"?String(this._parts[e]):Hm(this._parts[e])}this.refs.sign&&(this.refs.sign.textContent=this._parts.negative?"-":"+",this.refs.sign.setAttribute("aria-pressed",String(this._parts.negative)),this.refs.sign.dataset.state=this._parts.negative?"negative":"positive")}_syncDisabled(){for(let t of this._inputs)t.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}_message(t,e){let i=this.msg(t);return i===t?e:i}};function xe(s){let t=Number(s);return Number.isFinite(t)?t:0}function jd(s,t){return is(t),t==="hours"?s*3600:t==="minutes"?s*60:s}function Hd(s,t){return is(t),t==="hours"?s/3600:t==="minutes"?s/60:s}function is(s){if(s!=="hours"&&s!=="minutes"&&s!=="seconds")throw new RangeError(`Unknown time unit: ${s}`)}function Hm(s){return String(s).padStart(2,"0")}function qd(){I.register("time",(s,t)=>{let e=s.own(new Dt(null,{...t.props??{},value:t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.get(),set:i=>e.set(Number(i)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var J=class extends y{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:qm(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let i=[l("span",{class:"zx-toggle__track",ariaHidden:"true"},l("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&i.push(l("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&$m(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function qm(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function $m(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function $d(){I.register("toggle",(s,t)=>{let e=s.own(new J(null,{...t.props??{},checked:!!t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.getValue(),set:i=>e.set(!!i,{silent:!0}),focus:()=>e.el.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var si=class extends y{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??l("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=Kd(this.options.values,!!this.options.unique);let e=x("zx-value-list-instructions");return this._list=l("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:this._message("valueList.values","Values"),ariaOrientation:"horizontal"}),this._input=l("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:this._message("valueList.add","Add value"),ariaDescribedby:e}),this._status=l("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=l("span",{class:"zx-value-list__instructions",id:e},this._message("valueList.instructions","Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.")),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",i=>this._handleInputKeydown(i)),this.listen(this._list,"keydown",i=>this._handleChipKeydown(i)),this.listen(this._list,"click",i=>this._handleChipClick(i)),this.listen(this._list,"dragstart",i=>this._handleDragStart(i)),this.listen(this._list,"dragover",i=>{this._dragIndex>=0&&!this._disabled&&i.preventDefault()}),this.listen(this._list,"drop",i=>this._handleDrop(i)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",i=>{i.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Kd(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError(this._message("valueList.duplicate","This value already exists.")),!1;if(typeof this.options.validate=="function"){let i=this.options.validate(e);if(i!==!0)return this._showError(typeof i=="string"?i:this._message("valueList.invalid","This value is not valid.")),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((i,n)=>l("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?this._message("valueList.removable","%1. Press Delete to remove.",i):i,dataset:{index:n}},l("span",{class:"zx-value-list__value"},i),this.options.deletable?l("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let i=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(i,Math.min(i,this._values.length-2));return}let n=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=n||r;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,i+o));t.ctrlKey&&n&&this.options.sortable?this._move(i,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,i=e?.closest("[data-index]");!i||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(i.dataset.index)):i.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,i=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,i,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,i){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[n]=this._values.splice(t,1);this._values.splice(e,0,n),this._renderChips(i?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[i]=this._values.splice(t,1);i!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:i}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function Kd(s,t){if(!Array.isArray(s))return[];let e=s.map(i=>String(i));return t?[...new Set(e)]:e}function Ud(){I.register("valuelist",(s,t)=>{let e=s.own(new si(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.values})),{el:e.el,get:()=>e.getValues(),set:i=>e.setValues(Array.isArray(i)?i:[],{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var Se=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),Km=["xl","lg","md","sm"];function bn(s){let t=Number(s);if(!Number.isFinite(t))return"xs";for(let e of Km)if(t>=Se[e])return e;return"xs"}function yn(s,t){if(s==="xs")return!0;let e=Se[s];if(e===void 0)throw new RangeError(`Unknown breakpoint "${s}"`);return Number(t)>=e}function ni(s,t={}){if(typeof s!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!E(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,i=E(e)?e:null,n=null,r=!1,o=null,a=()=>i?i.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let h=a();if(i&&h===0)return;let f=bn(h);f!==n&&(n=f,s(n,h))};c();let d=0,u=()=>{d||r||(d=requestAnimationFrame(()=>{d=0,c()}))};return i&&typeof ResizeObserver=="function"?(o=new ResizeObserver(u),o.observe(i)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??bn(a()),destroy:()=>{r||(r=!0,d&&cancelAnimationFrame(d),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var xa="data-zx-motion",Um='[data-zx-motion="reduced"]',Yd="(prefers-reduced-motion: reduce)";function ri(s){if(Ym())return!0;let t=s??globalThis.document?.documentElement??null;return Gm(t)}function wn(s,t,e={}){if(typeof t!="function")throw new TypeError("watchMotion requires a callback");let{signal:i,immediate:n=!1}=e;if(i?.aborted)return()=>{};let r=ri(s),o=!1,a=()=>{if(o)return;let h=ri(s);h!==r&&(r=h,t(h))},c=typeof globalThis.matchMedia=="function"?globalThis.matchMedia(Yd):null;c?.addEventListener?.("change",a);let d=typeof MutationObserver=="function"?new MutationObserver(a):null;if(d)for(let h of Wm(s))d.observe(h,{attributes:!0,attributeFilter:[xa],subtree:!0});let u=()=>{o||(o=!0,c?.removeEventListener?.("change",a),d?.disconnect(),i?.removeEventListener("abort",u))};return i?.addEventListener("abort",u,{once:!0}),n&&t(r),u}function Ym(){return typeof globalThis.matchMedia=="function"&&globalThis.matchMedia(Yd).matches}function Gm(s){let t=s;for(;t&&typeof t.closest=="function";){if(t.closest(Um))return!0;let e=t.getRootNode?.();t=Gd(e)?e.host:null}return!1}function Wm(s){let t=[],e=s;for(;e&&typeof e.getRootNode=="function";){let n=e.getRootNode();if(!Gd(n))break;t.push(n),e=n.host}let i=(s?.ownerDocument??globalThis.document)?.documentElement;return i&&t.push(i),t}function Gd(s){return!!s&&s.nodeType===11&&"host"in s}var ss=class{base;headers;onError;timeout;constructor({base:t="",headers:e={},onError:i=null,timeout:n=3e4}={}){this.base=String(t),this.headers=Object.freeze({...e}),this.onError=i,this.timeout=Number(n)}async request(t,e={}){let{method:i="GET",data:n=null,files:r=null,query:o=null,headers:a={}}=e,c=new AbortController,d=this.timeout>0?setTimeout(()=>c.abort(),this.timeout):null,u=new Headers(this.headers);for(let[p,_]of Object.entries(a))u.set(p,_);u.set("Accept",u.get("Accept")??"application/json");let h;r!==null?(h=Xm(n,r),u.delete("Content-Type")):n!==null&&i.toUpperCase()!=="GET"&&i.toUpperCase()!=="HEAD"&&(h=JSON.stringify(n),u.set("Content-Type",u.get("Content-Type")??"application/json"));let f=Qm(this.base+t,o);try{let p=await fetch(f,{method:i.toUpperCase(),headers:u,body:h,signal:c.signal}),_=await p.text(),m=null;if(_!=="")try{m=JSON.parse(_)}catch(g){let w=new Error("Invalid JSON response",{cause:g});throw w.response=p,w}if(!p.ok){try{vn(m)}catch(w){throw w.response=p,w}let g=new Error(`HTTP ${p.status} ${p.statusText}`.trim());throw g.response=p,g}return vn(m)}catch(p){let _=p instanceof Error?p:new Error(String(p));if(this.onError)try{this.onError(_,{path:t,options:e})}catch{}throw _}finally{d!==null&&clearTimeout(d)}}get(t,e=null){return this.request(t,{method:"GET",query:e})}post(t,e=null){return this.request(t,{method:"POST",data:e})}put(t,e=null){return this.request(t,{method:"PUT",data:e})}delete(t,e=null){return this.request(t,{method:"DELETE",data:e})}};function Wd(s,t="",e={}){let{apiBase:i="../remotecall/",...n}=e,r=`${i}${s}${t?`:${t}`:""}/`;return new ss({...n,base:r})}function vn(s){if(s&&typeof s=="object"){if(Object.prototype.hasOwnProperty.call(s,"error")&&s.error!=null){let t=typeof s.error=="string"?s.error:JSON.stringify(s.error);throw new Error(t||"Server error")}if(Object.prototype.hasOwnProperty.call(s,"result"))return s.result}return s}function Qm(s,t){if(t==null)return s;let e;if(typeof t=="string")e=t.replace(/^\?/,"");else if(t instanceof URLSearchParams)e=t.toString();else{let i=new URLSearchParams;for(let[n,r]of Object.entries(t))Qd(i,n,r);e=i.toString()}return e?s+(s.includes("?")?"&":"?")+e:s}function Qd(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)Qd(s,t,i);else s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Xm(s,t){let e=new FormData;if(s&&typeof s=="object"&&!Array.isArray(s))for(let[n,r]of Object.entries(s))Xd(e,n,r);else s!=null&&e.append("data",typeof s=="string"?s:JSON.stringify(s));let i=Jm(t)||Array.isArray(t)?Array.from(t):[t];for(let n of i)e.append("files",n);return e}function Xd(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)Xd(s,t,i);else{let i=typeof Blob=="function"&&e instanceof Blob;s.append(t,typeof e=="object"&&!i?JSON.stringify(e):e)}}function Jm(s){return typeof FileList=="function"&&s instanceof FileList}var Zm=0,tg=20,eg=3,ig=["B","KiB","MiB","GiB","TiB","PiB","EiB"],sg=["B","kB","MB","GB","TB","PB","EB"],Sa=[{unit:"second",ms:1e3,limit:45},{unit:"minute",ms:6e4,limit:45},{unit:"hour",ms:36e5,limit:22},{unit:"day",ms:864e5,limit:6},{unit:"week",ms:6048e5,limit:4},{unit:"month",ms:26298e5,limit:11},{unit:"year",ms:315576e5,limit:1/0}],Jd=new Map,Zd=new Map;function Nt(s,t={}){let e=xn(s);if(e===null)return"";let{locale:i=dt(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return Aa(i,ka({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function oi(s,t,e={}){let i=xn(s);if(i===null)return"";let{locale:n=dt(),decimals:r}=e,o=og(t);if(o===null)return Nt(i,{locale:n,decimals:r});let a=ka({decimals:r,group:!0});return Aa(n,{...a,style:"currency",currency:o},i)}function ai(s,t={}){let e=xn(s);if(e===null)return"";let{locale:i=dt(),decimals:n=0}=t;return Aa(i,{...ka({decimals:n,group:!0}),style:"percent"},e)}function li(s,t={}){let e=xn(s);if(e===null)return"";let{locale:i=dt(),decimals:n=1,standard:r="iec"}=t;if(e===0)return`${Nt(0,{locale:i,decimals:0})} B`;let o=r==="si"?sg:ig,a=r==="si"?1e3:1024,c=Math.abs(e),d=Math.min(o.length-1,Math.max(0,Math.floor(Math.log(c)/Math.log(a)))),u=c/a**d;ag(u,d===0?0:n)>=a&&d<o.length-1&&(d+=1,u=c/a**d);let h=e<0?-u:u;return`${Nt(h,{locale:i,minDecimals:0,maxDecimals:d===0?0:n})} ${o[d]}`}function iu(s,t={}){let e=eu(s);if(e===null)return"";let{now:i=new Date,locale:n=dt(),numeric:r="auto"}=t,o=eu(i);if(o===null)return"";let a=e.getTime()-o.getTime(),c=Sa.find(({ms:u,limit:h})=>Math.abs(a)/u<h)??Sa[Sa.length-1],d=Math.round(a/c.ms);return rg(n,r).format(d,c.unit)}function Aa(s,t,e){let i=`${s}\0${JSON.stringify(t)}`,n=Jd.get(i);return n===void 0&&(n=ng(s,t),Jd.set(i,n)),n.format(e)}function ng(s,t){try{return new Intl.NumberFormat(s,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function rg(s,t){let e=`${s}\0${t}`,i=Zd.get(e);if(i===void 0){try{i=new Intl.RelativeTimeFormat(s,{numeric:t})}catch{i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"})}Zd.set(e,i)}return i}function ka({decimals:s,minDecimals:t,maxDecimals:e,group:i=!0}){let n={useGrouping:i!==!1},r=tu(t??s),o=tu(e??s);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,eg)),n}function tu(s){if(s==null)return null;let t=Number(s);return Number.isFinite(t)?Math.min(tg,Math.max(Zm,Math.round(t))):null}function xn(s){if(s==null||s==="")return null;let t=typeof s=="number"?s:Number(s);return Number.isFinite(t)?t:null}function og(s){if(typeof s!="string")return null;let t=s.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function eu(s){if(s instanceof Date)return Number.isNaN(s.getTime())?null:s;if(typeof s=="number")return Number.isFinite(s)?new Date(s*1e3):null;if(typeof s=="string"){let t=s.trim();if(t==="")return null;let e=/^-?\d+$/.test(t)?new Date(Number(t)*1e3):new Date(t);return Number.isNaN(e.getTime())?null:e}return null}function ag(s,t){let e=10**t;return Math.round(s*e)/e}var su="zx:__probe__";function ci(s,t={}){let{area:e="local"}=t,i=`zx:${String(s??"")}:`,n=new Map,r=lg(e),o=u=>{if(r!==null)try{return r.getItem(u)}catch{r=null}return n.has(u)?n.get(u):null},a=(u,h)=>{if(r!==null)try{r.setItem(u,h);return}catch{r=null}n.set(u,h)},c=u=>{if(r!==null)try{r.removeItem(u)}catch{r=null}n.delete(u)},d=()=>{if(r!==null)try{let u=[];for(let h=0;h<r.length;h+=1){let f=r.key(h);typeof f=="string"&&f.startsWith(i)&&u.push(f)}return u}catch{r=null}return[...n.keys()].filter(u=>u.startsWith(i))};return{get(u,h){let f=o(i+u);if(f==null)return h;try{return JSON.parse(f)}catch{return h}},set(u,h){let f;try{f=JSON.stringify(h)}catch{f=void 0}f===void 0?c(i+u):a(i+u,f)},remove(u){c(i+u)},keys(){return d().map(u=>u.slice(i.length))},clear(){for(let u of d())c(u)}}}function lg(s){let t=s==="session"?"sessionStorage":"localStorage";try{let e=globalThis[t];return!e||typeof e.getItem!="function"?null:(e.setItem(su,"1"),e.removeItem(su),e)}catch{return null}}var cg=["=","+","-","@"];function ou(s,t,e={}){let{delimiter:i=",",header:n=!0,newline:r=`\r
9
+ `}=e,o=ug(t),a=[];n&&a.push(o.map(c=>ru(c.label,i,nu(c.label))).join(i));for(let c of s??[]){let d=o.map(u=>{let h=typeof u.value=="function"?u.value(c):hg(c,u.id);return ru(fg(h),i,nu(h))});a.push(d.join(i))}return a.join(r)}function au(s,t,e={}){let{type:i="text/plain;charset=utf-8"}=e,n=pg(t,i),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=String(s??"download"),o.rel="noopener",o.style.display="none",document.body.append(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}async function Sn(s){let t=String(s??"");if(globalThis.navigator?.clipboard?.writeText)try{return await navigator.clipboard.writeText(t),!0}catch{}return dg(t)}function dg(s){if(typeof document>"u"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=s,e.setAttribute("readonly",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;inset-block-start:-1000px;opacity:0;pointer-events:none",document.body.append(e);let i=!1;try{e.select(),e.setSelectionRange(0,s.length),i=document.execCommand?.("copy")===!0}catch{i=!1}finally{e.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}return i}function ug(s){return(s??[]).map(t=>{if(typeof t=="string")return{id:t,label:t};let e=String(t?.id??"");return{id:e,label:String(t?.label??e),value:t?.value}})}function hg(s,t){return s?.[t]}function fg(s){if(s==null)return"";if(s instanceof Date)return Number.isNaN(s.getTime())?"":s.toISOString();if(typeof s=="number")return Number.isFinite(s)?String(s):"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="object")try{return JSON.stringify(s)}catch{return String(s)}return String(s)}function nu(s){return typeof s!="string"?!1:cg.includes(s.charAt(0))}function ru(s,t,e=!1){let i=e?` ${s}`:s;return i.includes(t)||i.includes('"')||i.includes(`
10
+ `)||i.includes("\r")?`"${i.replaceAll('"','""')}"`:i}function pg(s,t){if(typeof Blob=="function"&&s instanceof Blob)return s;let e=typeof s=="string"&&/^text\/csv\b/i.test(t)?["\uFEFF",s]:[s];return new Blob(e,{type:t})}var Ht=class extends y{static cssName="check-button";static defaults={label:"",checked:!1,icon:!0,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("CheckButton target must be a button element");this._createdRoot=t,this._original=t?null:_g(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=lu(this.options.label),e.type="button";let i=[];return this.options.icon&&i.push(l("span",{class:"zx-check-button__icon",ariaHidden:"true"},l("span",{class:"zx-check-button__off"},b("square",{size:15})),l("span",{class:"zx-check-button__on"},b("check",{size:15})))),i.push(l("span",{class:"zx-check-button__label",ref:"label"})),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked}),this)}toggle(){return this.set(!this._checked)}setLabel(t){return this._labels=lu(t),this._sync(),this}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&mg(this.el,this._original))}_sync(){this.el.setAttribute("aria-pressed",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled),this.refs.label.textContent=this._checked?this._labels.on:this._labels.off}};function lu(s){return Array.isArray(s)?{on:String(s[0]??""),off:String(s[1]??"")}:{on:String(s??""),off:String(s??"")}}function _g(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function mg(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var gg=".zx-scope, [data-zx-theme], [data-zx-preset]",bg="dialog:modal, dialog[open], dialog:popover-open";function vt(s=null){return du(cu(s))}function ns(s=null){let t=cu(s);return(s==null?null:di(t))??du(t)}function oe(s=null,t={}){let e=t.dialog===!1?vt:ns;if(s==null)return e(null);let i=P(s);return i?.isConnected?e(i):null}function di(s){if(!s||typeof s.closest!="function")return null;try{return s.closest(bg)}catch{return s.closest("dialog[open]")}}function cu(s){return s==null?document.activeElement instanceof Element?document.activeElement:null:P(s)}function du(s){let t=s?.closest?.(gg)??null;return!t||t===document.documentElement||t===document.body?document.body:t}var fu=new Set(["tooltip","toast"]);function ae(s,t){if(!s||!t)return!1;for(let e=t;e;e=e.parentNode??e.host??null)if(e===s)return!0;return!1}function yg(s,t){for(let e=s.length-1;e>=0;e-=1){let i=s[e];if(!fu.has(i.kind)&&t.some(n=>ae(i.root,n)))return i}return null}function rs(s,t,e){return e?ae(t.root,e)||t.inside.some(i=>ae(i,e))?!0:s.some(i=>i.parent===t&&rs(s,i,e)):!1}function za(s,t=()=>!0){for(let e=s.length-1;e>=0;e-=1){let i=s[e];if(i.kind!=="toast"&&t(i))return i}return null}function wg(s,t=null){let e=[];for(let i=s.length-1;i>=0;i-=1){let n=s[i];if(n.kind==="modal")break;t&&!ae(t,n.root)||typeof n.onEscape=="function"&&e.push(n)}return e}function vg(s,t,e=null){if(s.some(n=>n.kind==="toast"&&ae(n.root,t)))return[];let i=[];for(let n=s.length-1;n>=0;n-=1){let r=s[n];r.kind==="tooltip"&&!rs(s,r,t)&&r.onOutsidePointer&&i.push(r)}for(let n=s.length-1;n>=0;n-=1){let r=s[n];if(!fu.has(r.kind)){if(rs(s,r,t)||r.kind==="modal")break;e&&!ae(e,r.root)||r.onOutsidePointer&&i.push(r)}}return i}var Ta=class{#t=[];#e=0;#i=null;#s=new Set;#r;#n=new WeakMap;constructor(t={}){this.#r=t.target===void 0?typeof document>"u"?null:document:t.target}push(t){let e=uu(t.anchor),i={order:++this.#e,kind:t.kind,root:t.root,owner:t.owner??null,anchors:e,inside:uu(t.inside),parent:t.kind==="toast"?null:yg(this.#t,e),onEscape:t.onEscape,onOutsidePointer:t.onOutsidePointer,onFocusOutside:t.onFocusOutside,onParentClose:t.onParentClose};this.#t.push(i);let n={entry:i,order:i.order,isOpen:()=>this.#t.includes(i),isTopmost:()=>za(this.#t)===i,contains:r=>this.#t.includes(i)&&rs(this.#t,i,r),release:()=>this.#o(i)};return this.#n.set(i,n),this.#a(),this.#l(),n}entries(){return this.#t.slice()}topmost(t){return za(this.#t,t)}topmostModal(){let t=za(this.#t,i=>i.kind==="modal"&&i.root.isConnected&&xg(i.root,":modal",!0));if(t)return t.root;if(typeof document>"u"||typeof document.querySelectorAll!="function")return null;let e;try{e=document.querySelectorAll("dialog:modal")}catch{return null}return e.length?e[e.length-1]:null}containsNode(t){return this.#t.some(e=>ae(e.root,t)||e.inside.some(i=>ae(i,t)))}subscribe(t){return this.#s.add(t),()=>{this.#s.delete(t)}}handleKeydown(t){if(t.key!=="Escape"||t.defaultPrevented||t.isComposing)return null;for(let e of wg(this.#t,hu(Ca(t)))){let i=this.#n.get(e);if(!(!i||!this.#t.includes(e))&&e.onEscape?.(t,i)!==!1)return t.preventDefault(),e}return null}handlePointerdown(t){let e=Ca(t),i=vg(this.#t,e,hu(e));for(let n of i){let r=this.#n.get(n);r&&this.#t.includes(n)&&n.onOutsidePointer?.(t,r)}return i}handleFocusin(t){let e=Ca(t);for(let i of this.#t.slice().reverse()){if(typeof i.onFocusOutside!="function"||!this.#t.includes(i)||rs(this.#t,i,e))continue;let n=this.#n.get(i);n&&i.onFocusOutside(t,n)}}#o(t){let e=this.#t.indexOf(t);if(e<0)return;this.#t.splice(e,1);let i=this.#t.filter(n=>n.parent===t);for(let n of i)n.parent=t.parent;this.#t.length===0&&this.#c(),this.#l();for(let n of i.reverse()){let r=this.#n.get(n);r&&this.#t.includes(n)&&n.onParentClose?.(r)}}#a(){if(this.#i||!this.#r||typeof this.#r.addEventListener!="function")return;let t=new AbortController;this.#i=t;let{signal:e}=t;this.#r.addEventListener("keydown",i=>this.handleKeydown(i),{signal:e}),this.#r.addEventListener("pointerdown",i=>this.handlePointerdown(i),{capture:!0,signal:e}),this.#r.addEventListener("focusin",i=>this.handleFocusin(i),{signal:e})}#c(){this.#i?.abort(),this.#i=null}#l(){let t=this.#t.slice();for(let e of[...this.#s])try{e(t)}catch(i){queueMicrotask(()=>{throw i})}}},ui=new Ta;function le(s){return ui.push(s)}function uu(s){let t=Array.isArray(s)?s:[s];return t.filter((e,i)=>e!=null&&t.indexOf(e)===i)}function hu(s){for(let t=s;t;t=t.parentNode??t.host??null)if(t.localName==="dialog"&&typeof t.matches=="function")try{if(t.matches(":modal"))return t}catch{return null}return null}function Ca(s){return(typeof s.composedPath=="function"?s.composedPath():[])[0]??s.target??null}function xg(s,t,e){if(typeof s.matches!="function")return e;try{return s.matches(t)}catch{return e}}var Sg=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),hi=class extends y{static cssName="modal";static defaults={content:null,width:"auto",closable:!0,lightDismiss:!1,destroyOnClose:!1,scope:null};#t=new Map;#e=!1;#i=0;#s=[];#r=null;#n=null;constructor(t=null,e={}){super(null,e),this.#c(this.options.width),_u(this.refs.content,this.options.content),this.listen(this.el,"cancel",i=>{let n=this.emit("cancel");(!this.options.closable||n.defaultPrevented)&&i.preventDefault()}),this.listen(this.el,"close",()=>{this._settleClose(this.#s.shift())}),this.listen(this.el,"click",i=>{!this.options.lightDismiss||i.target!==this.el||!kg(this.el,i)||this.close()}),this.on("close",()=>this.#a())}mountTarget(){return vt(this.options.scope)}_show(){this.el.showModal()}_hide(t="",e=this.#i){this.#s.push(e);try{this.el.close(t)}catch(i){throw this.#s.pop(),i}}_present(){this._show(),this.#i+=1,this.#o()}#o(){this.el.matches(":modal")?this.el.setAttribute("aria-modal","true"):this.el.getAttribute("aria-modal")==="true"&&this.el.removeAttribute("aria-modal")}_overlayEntry(){return{kind:this.el.matches(":modal")?"modal":"non-modal",root:this.el,owner:this,anchor:this.#r}}_syncOverlay(){if(this._releaseOverlay(),!this._isShown())return;let t=this._overlayEntry();t&&(this.#n=le(t),this.el.dataset.zxOverlayOrder=String(this.#n.order))}_releaseOverlay(){let t=this.#n;this.#n=null,delete this.el.dataset.zxOverlayOrder,t?.release()}_overlayContains(t){return this.#n?this.#n.contains(t):this.el.contains(t??null)}_dismiss(t=""){this._hide(t,this.#i)}_isShown(){return this.el.open}_isRealClose(t){return t!==void 0&&t!==this.#i?!1:!this._isShown()}_settleClose(t){if(!this._isRealClose(t))return t!==void 0&&this.#t.delete(t),!1;this.el.dataset.state="closed",this._releaseOverlay(),this.el.getAttribute("aria-modal")==="true"&&this.el.removeAttribute("aria-modal");let e=t===void 0?void 0:this.#t.get(t);t!==void 0&&this.#t.delete(t);let i=e?e.result:this.el.returnValue||void 0;return this.emit("close",{result:i}),this.options.destroyOnClose&&!this.#e&&this.destroy(),!0}#a(){let t=this.#r;this.#r=null,t?.isConnected&&typeof t.focus=="function"&&t.focus()}_focusInitial(){if(!this.isOpen())return;let t=Ag(this.el);if(t){t.focus();return}let e=this.el;e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus()}render(){let t=l("dialog",{class:"zx-modal"},l("div",{class:"zx-modal__content",ref:"content"}));return t.dataset.state="closed",this._mountInitial(t),t}_mountInitial(t){this.options.scope!=null&&!oe(this.options.scope)||this.mountTarget().append(t)}open(){if(this.isOpen())return this;this.#r=document.activeElement instanceof Element?document.activeElement:null;let t=this.mountTarget();this.el.parentElement!==t&&t.append(this.el),this.el.returnValue="";try{this._present()}catch(e){throw this.#r=null,e}return this._syncOverlay(),this.el.dataset.state="open",this.emit("open"),queueMicrotask(()=>this._focusInitial()),this}close(t){if(!this.isOpen())return this;let e=this.#i;this.#t.set(e,{result:t});try{this._dismiss(typeof t=="string"?t:"")}catch(i){throw this.#t.delete(e),i}return this}setContent(t){return _u(this.refs.content,t),this}isOpen(){return this._isShown()}destroy(){this.#e||(this.#e=!0,this.isOpen()&&this._dismiss(),this._releaseOverlay(),super.destroy())}#c(t){typeof t=="number"&&Number.isFinite(t)?this.el.style.inlineSize=`${Math.max(0,t)}px`:this.el.style.inlineSize=String(t??"auto")}};function Ag(s){let t=s.querySelector("[autofocus]:not([disabled])");if(t&&pu(t,s))return t;for(let e of s.querySelectorAll(Sg))if(pu(e,s))return e;return null}function pu(s,t){if(typeof s.focus!="function")return!1;for(let e=s;e;e=e.parentElement){if(e.hidden||e.getAttribute("aria-hidden")==="true"||e.hasAttribute("inert"))return!1;if(e===t)break}return!0}function _u(s,t){if(s.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}function kg(s,t){let e=s.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}var zg=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),Cg=Object.freeze({sm:!0,md:!0,lg:!0});function fi(s={}){let t={...zg,...s},e=String(t.label??""),i=l("span",{class:"zx-spinner",dataset:{size:Cg[t.size]?t.size:"md",kind:t.kind==="current"?"current":"accent"}},l("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return e?(i.setAttribute("role","status"),i.append(l("span",{class:"zx-spinner__label",dataset:{visible:t.showLabel?"true":null}},e))):i.setAttribute("aria-hidden","true"),i}var Tg=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function j(s={}){let t={...Tg,...s},e=l("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title??(t.shortcut?`${t.label} (${t.shortcut.label})`:void 0),ariaKeyshortcuts:t.shortcut?.keys,dataset:{kind:Ig(t.kind),size:Eg(t.size)}});return t.icon&&e.append(b(t.icon,{size:16})),t.label!==""&&e.append(l("span",{class:"zx-btn__label"},String(t.label))),t.shortcut&&e.append(l("kbd",{class:"zx-btn__shortcut",ariaHidden:"true"},t.shortcut.label)),!t.label&&t.title&&e.setAttribute("aria-label",t.title),typeof t.onclick=="function"&&(e.onclick=t.onclick),t.busy&&Ia(e,!0),e}function mu(s){let t=l("div",{class:"zx-btn-group",role:"group"});return t.append(...s),t}function Ia(s,t){if(s.hasAttribute("data-busy-guard")||(s.setAttribute("data-busy-guard",""),s.addEventListener("click",e=>{s.getAttribute("aria-busy")==="true"&&(e.preventDefault(),e.stopImmediatePropagation())},{capture:!0})),s.querySelector(":scope > .zx-btn__spinner")?.remove(),t){s.setAttribute("aria-busy","true"),s.setAttribute("aria-disabled","true");let e=fi({size:"sm",kind:"current"});e.classList.add("zx-btn__spinner"),s.prepend(e)}else s.removeAttribute("aria-busy"),s.removeAttribute("aria-disabled");return s}function Ig(s){return["primary","danger","ghost"].includes(String(s))?s:"default"}function Eg(s){return s==="sm"?"sm":"md"}var qt=class s extends hi{static cssName="dialog";static defaults={title:"",size:"md",buttons:[],closable:!0};#t=new Map;#e=null;#i=[];#s="";constructor(t=null,e={}){super(null,e),this._applySize(this.options.size),this.#s=String(this.options.title??""),this.#n(this.#s),this.#i=An(this.options.buttons),this.#o(this.#i),this.refs.close.hidden=!this.options.closable,this.listen(this.refs.close,"click",()=>this.close()),this.listen(this.refs.footer,"click",i=>{let n=i.target.closest?.("[data-dialog-button]");if(!n||!this.refs.footer.contains(n))return;let r=this.#r[Number(n.dataset.dialogButton)];r&&this.#a(r)})}#r=[];render(){let t=x("zx-dialog-title"),e=this._message("dialog.close","Close"),i=l("dialog",{class:"zx-modal zx-dialog",ariaLabelledby:t},l("header",{class:"zx-dialog__header"},l("h2",{class:"zx-dialog__title",id:t,ref:"title"}),l("button",{class:"zx-btn zx-dialog__close",ref:"close",type:"button","data-kind":"ghost",ariaLabel:e,title:e},"\xD7")),l("div",{class:"zx-modal__content zx-dialog__body",ref:"content"}),l("footer",{class:"zx-dialog__footer",ref:"footer"}));return i.dataset.state="closed",this._mountInitial(i),i}open(){return super.open()}setTitle(t){return this.#s=String(t??""),this.#n(this.#s),this}setContent(t){return this.#t.clear(),this.#e=null,Ng(this.refs.content,t),this}setButtons(t){return this.#i=An(t),this.#o(this.#i),this}addView(t,e){let i=String(t);this.#t.get(i)?.content.remove();let r=l("section",{class:"zx-dialog__view",hidden:!0,ariaHidden:"true"});bu(r,e?.content??null);let o={key:i,content:r,buttons:e&&Object.hasOwn(e,"buttons")?An(e.buttons??[]):null,title:e&&Object.hasOwn(e,"title")?String(e.title??""):null};return this.#t.set(i,o),this.#t.size===1||this.#e?.key===i?this.showView(i):this.refs.content.append(r),o}showView(t){let e=this.#t.get(String(t));if(!e)throw new RangeError(`Unknown dialog view: ${t}`);this.#e||this.refs.content.replaceChildren();for(let i of this.#t.values()){i.content.isConnected||this.refs.content.append(i.content);let n=i===e;i.content.hidden=!n,i.content.setAttribute("aria-hidden",String(!n))}return this.#e=e,this.#n(e.title??this.#s),this.#o(e.buttons??this.#i),e}getView(t){return this.#t.get(String(t))??null}static alert({title:t="",message:e="",okLabel:i}={}){return new Promise(n=>{let r=!1,o=()=>{r||(r=!0,a.close(),n())},a=new s(null,{title:t,content:e});a.setButtons([{label:i??a._message("dialog.ok","OK"),kind:"primary",action:o,autofocus:!0}]),a.once("close",()=>{r||(r=!0,n()),a.destroy()}),a.open()})}static confirm({title:t="",message:e="",okLabel:i,cancelLabel:n,danger:r=!1,confirmText:o=null}={}){return new Promise(a=>{let c=!1,d=_=>{c||(c=!0,h.close(_),a(_))},u=o==null?"":String(o).trim(),h=new s(null,{title:t,content:u?null:e}),f={label:n??h._message("dialog.cancel","Cancel"),action:()=>d(!1),autofocus:r&&!u},p={label:i??h._message("dialog.ok","OK"),kind:r?"danger":"primary",action:()=>d(!0),autofocus:!r&&!u};if(u){let _=l("input",{class:"zx-dialog__confirm-input",id:x("zx-dialog-confirm"),type:"text",autocomplete:"off",autocapitalize:"off",spellcheck:!1,autofocus:!0}),[m,g]=Mg(h._message("dialog.typeToConfirm","Type %1 to confirm"),u),w=l("label",{class:"zx-dialog__confirm-label",for:_.id},m,l("b",{},u),g);h.setContent(l("div",{class:"zx-dialog__confirm"},Dg(e)?null:l("div",{class:"zx-dialog__prompt-message"},e),w,_));let v=!1,z=()=>h.setButtons([f,{...p,autofocus:!1,disabled:!v}]);z(),h.listen(_,"input",()=>{let C=gu(_.value,u);C!==v&&(v=C,z())}),h.listen(_,"keydown",C=>{let k=C;k.key!=="Enter"||k.isComposing||(k.preventDefault(),gu(_.value,u)&&d(!0))})}else h.setButtons([f,p]);h.once("close",()=>{c||(c=!0,a(!1)),h.destroy()}),h.open()})}static prompt({title:t="",message:e="",value:i="",placeholder:n="",okLabel:r,cancelLabel:o}={}){return new Promise(a=>{let c=!1,d=l("input",{class:"zx-dialog__prompt-input",value:String(i),placeholder:String(n),autofocus:!0}),u=l("div",{class:"zx-dialog__prompt"},l("div",{class:"zx-dialog__prompt-message"},e),d),h=p=>{c||(c=!0,f.close(p),a(p))},f=new s(null,{title:t,content:u});d.setAttribute("aria-label",String(t||f._message("dialog.promptValue","Prompt value"))),f.setButtons([{label:o??f._message("dialog.cancel","Cancel"),action:()=>h(null)},{label:r??f._message("dialog.ok","OK"),kind:"primary",action:()=>h(d.value)}]),f.listen(d,"keydown",p=>{p.key==="Enter"&&(p.preventDefault(),h(d.value))}),f.once("close",()=>{c||(c=!0,a(null)),f.destroy()}),f.open()})}_applySize(t){let e={sm:400,md:600,lg:840},i=typeof t=="number"&&Number.isFinite(t)?t:e[t]??e.md;this.el.style.inlineSize=`${Math.max(0,i)}px`}_message(t,e){let i=this.msg(t);return i===t?e:i}#n(t){this.refs.title.textContent=t}#o(t){this.#r=An(t),this.refs.footer.replaceChildren(),this.refs.footer.hidden=this.#r.length===0,this.#r.forEach((e,i)=>{let n=j({label:e.label,kind:e.kind,shortcut:e.shortcut,disabled:e.disabled});n.dataset.dialogButton=String(i),n.autofocus=e.autofocus,this.refs.footer.append(n)})}#a(t){if(t.disabled)return;let e=t.action??"close";e==="close"?this.close():e==="cancel"?this.emit("cancel").defaultPrevented||this.close():typeof e=="function"&&e(this)}};function gu(s,t){let e=t==null?"":String(t).trim();return e!==""&&String(s??"").trim()===e}function Mg(s,t){let e=String(s).split("%1");return e.length===1?[`${e[0]} `,""]:[e[0],e.slice(1).join(t)]}function Dg(s){return s==null||s===""}function An(s){return Array.isArray(s)?s.map(t=>{let e=!!t?.disabled;return{...t,label:String(t?.label??""),disabled:e,autofocus:!!t?.autofocus&&!e}}):[]}function Ng(s,t){s.replaceChildren(),bu(s,t)}function bu(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}var ce=class extends y{static cssName="groupbox";static defaults={title:"",open:!0};constructor(t,e={}){let i=t,n=null;if(t!==null){let r=P(t);if(r&&r.localName!=="details"){let o=document.createElement("details"),a=Array.from(r.childNodes),c=r.parentNode,d=r.nextSibling;c&&c.insertBefore(o,r),o.append(...a),r.remove(),n={original:r,details:o,children:a,parent:c,next:d},i=o}}try{super(i,e)}catch(r){throw n&&yu(n),r}this._adoption=n}render(){let t=!this.el,e=this.el??l("details");if(e.localName!=="details")throw new TypeError("Groupbox requires a details element");this._createdRoot=t,this._original=t?null:Og(e);let i=Array.from(e.childNodes).filter(o=>!(o.nodeType===1&&o.localName==="summary")),n=l("summary",{class:"zx-groupbox__summary",ref:"summary"},l("span",{class:"zx-groupbox__chevron",ariaHidden:"true"},b("chevron-right",{size:16})),l("span",{class:"zx-groupbox__title",ref:"title"},String(this.options.title))),r=l("div",{class:"zx-groupbox__content",ref:"content"},i);return e.replaceChildren(n,r),e.open=!!this.options.open,this._lastOpen=e.open,this.listen(e,"toggle",()=>{let o=e.open;o!==this._lastOpen&&(this._lastOpen=o,this.emit(o?"open":"close"))}),e}open(){return this.el.setAttribute("open",""),this}close(){return this.el.removeAttribute("open"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.el.open}setTitle(t){return this.refs.title.textContent=String(t),this}setContent(t){let e=t instanceof y?t.toElement():t;if(this.refs.content.replaceChildren(),typeof e=="string")this.refs.content.append(document.createTextNode(e));else if(e&&typeof e.nodeType=="number")this.refs.content.append(e);else throw new TypeError("Groupbox content must be a string, Node, or Component");return this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._adoption?yu(this._adoption):!this._createdRoot&&this._original&&Fg(this.el,this._original))}};function Og(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Fg(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function yu(s){if(s.original.replaceChildren(...s.children),s.details.parentNode)s.details.replaceWith(s.original);else if(s.parent){let t=s.next?.parentNode===s.parent?s.next:null;s.parent.insertBefore(s.original,t)}}var Ot=class extends y{static cssName="search";static defaults={placeholder:"",value:"",clearable:!0,debounce:250};render(){let t=!this.el,e=this.el??l("form");this._createdRoot=t,this._original=t?null:Lg(e),this._inputTimer=null,e.setAttribute("role","search");let i=this._message("search.clear","Clear search"),n=l("input",{class:"zx-search__input",ref:"input",type:"search",placeholder:String(this.options.placeholder),value:String(this.options.value),ariaLabel:String(this.options.placeholder||this._message("search.label","Search"))}),r=this.options.clearable?l("button",{class:"zx-search__clear",ref:"clear",type:"button",ariaLabel:i,title:i},b("x",{size:15})):null,o=l("button",{class:"zx-search__submit",ref:"submit",type:e.localName==="form"?"submit":"button",ariaLabel:this._message("search.submit","Submit search"),title:this._message("search.submitTitle","Search")},b("search",{size:16}));return e.replaceChildren(...[n,r,o].filter(Boolean)),this._syncClear(),this.listen(n,"input",()=>{this._syncClear(),this._scheduleInput()}),e.localName==="form"?this.listen(e,"submit",a=>{a.preventDefault(),this.emit("submit",{value:this.get()})}):(this.listen(n,"keydown",a=>{a.key==="Enter"&&(a.preventDefault(),this.emit("submit",{value:this.get()}))}),this.listen(o,"click",()=>this.emit("submit",{value:this.get()}))),r&&this.listen(r,"click",()=>this.clear()),e}get(){return this.refs.input.value}set(t,{silent:e=!1}={}){return this._inputTimer!==null&&(clearTimeout(this._inputTimer),this._inputTimer=null),this.refs.input.value=String(t),this._syncClear(),e||this._scheduleInput(),this}focus(){return this.refs.input.focus(),this}clear(){return this.set(""),this.emit("clear"),this.focus(),this}destroy(){this._cleaned||(this._cleaned=!0,this._inputTimer!==null&&clearTimeout(this._inputTimer),super.destroy(),!this._createdRoot&&this._original&&Rg(this.el,this._original))}_scheduleInput(){this._inputTimer!==null&&clearTimeout(this._inputTimer);let t=Math.max(0,Number(this.options.debounce)||0);this._inputTimer=setTimeout(()=>{this._inputTimer=null,this.emit("input",{value:this.get()})},t)}_syncClear(){this.refs.clear&&(this.refs.clear.hidden=this.get()==="")}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Lg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Rg(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var Pg=new Set(["divided","bracket","line","segmented"]),pi=class extends y{static cssName="tabbox";static defaults={tabs:[],active:null,variant:"divided",keepAlive:!0};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");if(this.el=e,this._createdRoot=t,this._original=t?null:Vg(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!Pg.has(this.options.variant))throw new RangeError(`Unknown tabbox variant: ${this.options.variant}`);e.dataset.variant=this.options.variant;let i=l("div",{class:"zx-tabbox__tablist",ref:"tablist",role:"tablist",ariaOrientation:"horizontal",ariaLabel:this.options.label||null}),n=l("div",{class:"zx-tabbox__panels",ref:"panels"});if(e.replaceChildren(i,n),!Array.isArray(this.options.tabs))throw new TypeError("Tabbox tabs must be an array");for(let a of this.options.tabs)this.addTab(a);this._initializing=!1;let r=this.options.active===null?null:this._find(this.options.active),o=r&&!r.definition.disabled?r:this._enabledTabs()[0];return o&&this._applyActive(o),this.listen(i,"click",a=>{let c=a.target.closest?.('[role="tab"]');if(!c||!i.contains(c))return;let d=this._recordForTab(c);if(!(!d||d.definition.disabled)){if(a.target.closest?.(".zx-tabbox__close")){this._closeTab(d);return}this._setFocused(d),this.openTab(d.definition.name)}}),this.listen(i,"keydown",a=>this._onKeydown(a)),e}addTab(t,e={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Tab definition must be an object");if(typeof t.name!="string"||t.name==="")throw new TypeError("Tab name must be a non-empty string");if(this._find(t.name))throw new RangeError(`Tab already exists: ${t.name}`);if(!Bg(t.content))throw new TypeError("Tab content must be a Node, Component, or function");let i={name:t.name,title:String(t.title??""),content:t.content,icon:t.icon?String(t.icon):null,closable:!!t.closable,disabled:!!t.disabled},n=x("zx-tab"),r=x("zx-tabpanel"),o=l("span",{class:"zx-tabbox__title"},i.title),a=l("span",{class:"zx-tabbox__badge",hidden:!0}),c=[];i.icon&&c.push(l("span",{class:"zx-tabbox__icon",ariaHidden:"true"},b(i.icon,{size:16}))),c.push(o,a),i.closable&&c.push(l("span",{class:"zx-tabbox__close zx-icon-btn",ariaHidden:"true",title:this._message("tabbox.close","Close")},b("x",{size:14})));let d=l("button",{class:"zx-tabbox__tab",type:"button",id:n,role:"tab",tabindex:"-1",ariaControls:r,ariaSelected:"false",ariaDisabled:i.disabled?"true":null,dataset:{closable:i.closable?"true":null}},c),u=l("div",{class:"zx-tabbox__panel",id:r,role:"tabpanel",tabindex:"0",ariaLabelledby:n,hidden:!0}),h={definition:i,tab:d,title:o,badge:a,panel:u,built:!1},f=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,p=Math.max(0,Math.min(this._tabs.length,f)),_=this._tabs[p]??null;return this._tabs.splice(p,0,h),this.refs.tablist.insertBefore(d,_?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(u,_?.panel??null),!this._initializing&&!this._active&&!i.disabled&&this._applyActive(h),this}removeTab(t){return this._removeTab(t,!1),this}openTab(t){let e=this._find(t);if(!e||e.definition.disabled||e===this._active)return this;let i=this._active?.definition.name??null;return this.emit("change",{name:e.definition.name,previous:i}).defaultPrevented?this:(this._applyActive(e),this)}show(t){return this.openTab(t)}getActive(){return this._active?.definition.name??null}setTitle(t,e){let i=this._require(t);return i.definition.title=String(e??""),i.title.textContent=i.definition.title,this}setBadge(t,e){let i=this._require(t);return i.badge.textContent=e===null?"":String(e),i.badge.hidden=e===null,this}enableTab(t){let e=this._require(t);return e.definition.disabled?(e.definition.disabled=!1,e.tab.removeAttribute("aria-disabled"),this._active||this._applyActive(e),this):this}disableTab(t){let e=this._require(t);if(e.definition.disabled)return this;if(e===this._active){let i=this._enabledTabs().find(n=>n!==e)??null;if(i){if(this.openTab(i.definition.name),this._active===e)return this}else e.tab.setAttribute("aria-selected","false"),e.tab.tabIndex=-1,e.panel.hidden=!0,this._keepAlive||e.panel.remove(),this._active=null}return e.definition.disabled=!0,e.tab.setAttribute("aria-disabled","true"),e.tab.tabIndex=-1,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&jg(this.el,this._original))}_onKeydown(t){let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.tablist.contains(e))return;let i=this._recordForTab(e);if(!i)return;let n=this._enabledTabs();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(i),a=n[(o+r+n.length)%n.length];a&&this._setFocused(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let r=t.key==="Home"?n[0]:n[n.length-1];r&&this._setFocused(r);return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.openTab(i.definition.name);return}t.key==="Delete"&&i.definition.closable&&(t.preventDefault(),this._closeTab(i))}_closeTab(t){let e=this._tabs.indexOf(t),i=t.tab.contains(document.activeElement);if(!this._removeTab(t.definition.name,!0))return;let n=this._tabs[Math.min(e,this._tabs.length-1)]??this._tabs[e-1],r=n&&!n.definition.disabled?n:this._active;r&&this._setFocused(r,i)}_removeTab(t,e){let i=this._find(t);if(!i)return!1;let n=this._tabs.indexOf(i),o=this._tabs.filter(c=>c!==i).filter(c=>!c.definition.disabled),a=o.find(c=>this._tabs.indexOf(c)>n)??o.at(-1)??null;return i===this._active&&a&&this.emit("change",{name:a.definition.name,previous:i.definition.name}).defaultPrevented?!1:(this._tabs.splice(n,1),i.tab.remove(),i.panel.remove(),i===this._active&&(this._active=null,a&&this._applyActive(a)),e&&this.emit("close",{name:i.definition.name}),!0)}_applyActive(t){this._ensureContent(t);let e=this._active;e&&e!==t&&(e.tab.setAttribute("aria-selected","false"),e.panel.hidden=!0,this._keepAlive||e.panel.remove()),this._active=t,t.tab.setAttribute("aria-selected","true"),t.panel.hidden=!1,t.panel.parentNode!==this.refs.panels&&this.refs.panels.append(t.panel),this._setFocused(t,!1)}_ensureContent(t){if(t.built)return;let e=typeof t.definition.content=="function"?t.definition.content():t.definition.content,i=e instanceof y?e.toElement():e;if(!i||typeof i.nodeType!="number")throw new TypeError(`Tab content factory for ${t.definition.name} must return a Node or Component`);t.panel.append(i),t.built=!0}_setFocused(t,e=!0){for(let i of this._tabs)i.tab.tabIndex=i===t?0:-1;e&&t.tab.focus()}_enabledTabs(){return this._tabs.filter(t=>!t.definition.disabled)}_find(t){return this._tabs.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown tab: ${t}`);return e}_recordForTab(t){return this._tabs.find(e=>e.tab===t)??null}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Bg(s){return typeof s=="function"||s instanceof y?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Vg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function jg(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function Hg(s,t){return String(s).localeCompare(String(t))}function qg(s,t){return s-t}function $g(s,t){return s.getTime()-t.getTime()}function Kg(s,t,e="asc"){let i=s==null,n=t==null;if(i||n)return i&&n?0:i?1:-1;let r;return s instanceof Date&&t instanceof Date?r=$g(s,t):typeof s=="number"&&typeof t=="number"?r=qg(s,t):r=Hg(s,t),e==="desc"?-r:r}function Ug(s,t="asc"){return(e,i)=>Kg(s(e),s(i),t)}function os(s,t,e="asc"){let i=Ug(t,e);return s.map((n,r)=>({row:n,index:r})).sort((n,r)=>i(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var Yg=new Set(["text","number","select","date","checkbox","textarea"]),Gg='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',Ft=class extends y{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(t,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");if(this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._columns=vu(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=cb(this.options.rowKind),this._rowKinds=db(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=Su(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=fb(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=wb(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||zn(this.options.hierarchy,this._columns)||this._clickListened),this._current=null,this._rovingEl=null,this._extendBase=null,this._hierarchy=zn(this.options.hierarchy,this._columns),this._hiddenColumns=new Set((Array.isArray(this.options.hiddenColumns)?this.options.hiddenColumns:[]).map(String).filter(i=>this._columns.some(n=>n.id===i))),this._hiddenColumns.size>=this._columns.length&&this._columns[0]&&this._hiddenColumns.delete(this._columns[0].id),this._dragId=null,this._grabbedId=null,this._columnControlIds=new Map,this._columnStatus=null,this._expanded=ub(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let i of kn(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(i);return this._reconcileExpanded(),hb(this.options.variant)==="plain"&&(e.dataset.variant="plain"),this._table=l("table",{class:"zx-table__table"}),this._syncGridRole(),this._colgroup=l("colgroup",{class:"zx-table__columns"}),this._thead=l("thead",{class:"zx-table__head"}),this._tbody=l("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=l("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this._rowMoveMessage=this.options.rowReorder?l("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility||this.options.columnReorder?this._createColumnControls():null,this._editMode===!1?e.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(e.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:x("zx-table-message"),role:"status",ariaLive:"polite"}),e.replaceChildren(...[this._columnControls,this._scroll,this._editMessage,this._rowMoveMessage].filter(Boolean))),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",i=>this._handleBodyClick(i)),this.listen(this._tbody,"dblclick",i=>this._handleBodyDoubleClick(i)),this.options.rowReorder&&(this.listen(this._tbody,"dragstart",i=>this._handleRowDragStart(i)),this.listen(this._tbody,"dragover",i=>this._handleRowDragOver(i)),this.listen(this._tbody,"drop",i=>this._handleRowDrop(i)),this.listen(this._tbody,"dragend",()=>this._clearRowDrag()),this.listen(this._tbody,"keydown",i=>this._handleRowHandleKeydown(i))),this._columnControls&&(this.listen(this._columnControls,"change",i=>{let n=i.target;n?.classList.contains("zx-table__column-toggle")&&this.setColumnVisible(n.value,n.checked)}),this.listen(this._columnControls,"click",i=>this._handleColumnControlClick(i)),this.listen(this._columnControls,"keydown",i=>this._handleColumnControlKeydown(i))),this._editMode!==!1&&(this.listen(this._tbody,"keydown",i=>this._handleEditKeydown(i)),this.listen(document,"pointerdown",i=>this._handleDocumentPointerDown(i),{capture:!0})),this.listen(this._tbody,"keydown",i=>this._handleGridKeydown(i)),this.listen(this._tbody,"focusin",i=>this._handleFocusIn(i)),e}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),Au(t),this._data=[...t],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let e=this._pruneSelection();return this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}addData(t){return Au(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let i=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(i<0)return this;let n=this._selected.delete(t);return this._data[i]=e,n&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(e<0)return this;this._data.splice(e,1),this._reconcileExpanded();let i=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._extendBase=null,this._renderBody(),i&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}getColumns(){return this._columns.map(t=>({...t}))}setColumns(t,e={}){let i=vu(t),n=this.getColumnOrder(),r=this.getHiddenColumns(),o=this.getSort();return this._abortEdit({focus:!1}),this._columns=i,this._hiddenColumns=new Set(r.filter(a=>i.some(c=>c.id===a))),this._hiddenColumns.size>=i.length&&i[0]&&this._hiddenColumns.delete(i[0].id),this._sort=Su(o,i),this._hierarchy=zn(this.options.hierarchy,i),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),e.silent||(Cn(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),Cn(r,this.getHiddenColumns())||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()})),this}getColumnOrder(){return this._columns.map(t=>t.id)}setColumnOrder(t,e={}){let i=gb(this._columns,t);if(Cn(i,this.getColumnOrder()))return this;let n=this._activeColumnControl(),r=new Map(this._columns.map(o=>[o.id,o]));return this._abortEdit({focus:!1}),this._columns=i.map(o=>r.get(o)),this._hierarchy=zn(this.options.hierarchy,this._columns),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(n),e.silent||this.emit("columnorderchange",{order:this.getColumnOrder()}),this}moveColumn(t,e,i="before",n={}){if(i!=="before"&&i!=="after")throw new TypeError('Table column position must be "before" or "after"');let r=bb(this.getColumnOrder(),String(t),String(e),i);if(Cn(r,this.getColumnOrder()))return this;if(this.setColumnOrder(r,n),this._columnStatus){let o=this._columns.find(c=>c.id===String(t)),a=this.getColumnOrder().indexOf(String(t));o&&a>=0&&(this._columnStatus.textContent=`Moved ${Tn(o)} to position ${a+1} of ${this._columns.length}.`)}return this}getVisibleColumns(){return this._visibleColumns().map(t=>t.id)}getHiddenColumns(){return this._columns.filter(t=>this._hiddenColumns.has(t.id)).map(t=>t.id)}setColumnVisible(t,e=!0,i={}){let n=String(t);if(!this._columns.find(c=>c.id===n))throw new RangeError(`Unknown table column: ${n}`);let o=this._activeColumnControl();if(!e&&!this._hiddenColumns.has(n)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=e?this._hiddenColumns.delete(n):!this._hiddenColumns.has(n);return!e&&a&&this._hiddenColumns.add(n),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),i.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(t,e={}){return this.setColumnVisible(t,this._hiddenColumns.has(String(t)),e)}moveRow(t,e,i="before"){if(!this.options.rowReorder||this._sort&&this.options.sortMode==="local")return this;let n=this.getRow(t),r=this.getRow(e);if(!n||!r||Object.is(t,e))return this;if(this._isSpanningRow(n))return this;let o=Oa(this._data,this.options.rowId,t,e,i,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:t,target:r,targetId:e,position:i}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let c=this._siblingIds(t),d=c.findIndex(u=>Object.is(u,t));this._rowMoveMessage.textContent=`Moved row to position ${d+1} of ${c.length}.`}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(t)?.focus()),this}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,i={}){if(this._spanning)return this._sortWarned||(this._sortWarned=!0,console.warn("[zx.Table] setSort() is inert while the data contains spanning rowKinds rows: sorting would scatter the rows out of the sections that group them.")),this;if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),i.silent||this.emit("sort",{id:t,dir:r}),this}getSort(){return this._sort?{...this._sort}:null}clearSort(t={}){return this._sort?(this._abortEdit({focus:!1}),this._sort=null,this._syncSortHeader(),t.silent||this.emit("sort",{id:null,dir:null}),this):this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=this._selectableIds(),i=new Set;if(this.options.selectable!==!1){for(let n of t)if(e.has(n)&&i.add(n),this.options.selectable==="single"&&i.size>0)break}return this._extendBase=null,Ea(this._selected,i)?this:(this._selected=i,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(t,e={}){return this._expanded.has(t)?this.collapseRow(t,e):this.expandRow(t,e)}expandRow(t,e={}){return this._setRowExpanded(t,!0,e)}collapseRow(t,e={}){return this._setRowExpanded(t,!1,e)}expandAll(t={}){if(!this._hierarchy)return this;let i=kn(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of i)this._expanded.add(n);if(i.length&&this._renderBody(),!t.silent)for(let n of i)this._emitRowToggle(n,!0);return this}collapseAll(t={}){if(!this._hierarchy||this._expanded.size===0)return this;let e=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!t.silent)for(let i of e)this._emitRowToggle(i,!1);return this}getExpanded(){return this._data.map(t=>this._idFor(t)).filter(t=>this._expanded.has(t))}startEdit(t,e){if(this._editMode===!1)return this;let i=this._columns.find(f=>f.id===e);if(!i)return this;let n=this._data.find(f=>Object.is(this._idFor(f),t));if(n===void 0)return this;if(this._isSpanningRow(n))return this;let r=this._editMode==="row"&&this._hiddenColumns.has(i.id)?this._visibleColumns().find(f=>_i(f,n)!==!1)??null:i;if(!r||_i(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(f=>Object.is(this._idFor(f),t));if(a<0)return this;let c=this._data[a],d=this._rowElements.get(t)?.[0];if(!d)return this;let u=this._editMode==="row"?this._visibleColumns().filter(f=>_i(f,c)!==!1):[r],h=new Map;for(let f of u){let p=xu(d,f.id);if(!p)continue;let _=this._createEditor(p,f,c,a);_&&h.set(f.id,_)}return h.size===0?this:(this._edit={id:t,columnId:o,row:c,cells:h,tr:d},d.dataset.editing="true",this.emit("editstart",{row:c,id:t,column:r,columnId:o,value:c?.[o]}),this._focusEditor(o),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,i={};for(let[h,f]of t.cells)i[h]=f.read();let n=this._columns.filter(h=>t.cells.has(h.id)),r=lb(i,n,e,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),t.columnId=r.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(h=>h.id===r.columnId)??null,columnId:r.columnId,value:i[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=ab(e,i),a=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(h=>h.id===a)??null,columnId:a,value:i[a],previous:e?.[a],changes:o}).defaultPrevented)return this;let d=this._editHasFocus(),u={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,u),d&&this._focusCell(this._idFor(u),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?ib(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,i=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===i?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return Math.min(this._rendered,this._projectedData().length)}_syncGrowing(){if(!this._growStep)return;let t=this._projectedData().length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=l("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,i){let n=this.msg(t,...i);return n===t?T(e,i):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in Se)||(this._width=ni((e,i)=>this._setStacked(i>0&&i<Se[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}addEventListener(t,e,i){super.addEventListener(t,e,i),!(!e||t!=="rowclick"&&t!=="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 t=this._table,e=this._gridRole();e?t.setAttribute("role",e):t.removeAttribute("role"),this.options.labelledBy?t.setAttribute("aria-labelledby",String(this.options.labelledBy)):(this.options.label!=null||e)&&t.setAttribute("aria-label",this.options.label??this._message("table.label","Table",[])),e&&this.options.selectable==="multi"&&t.setAttribute("aria-multiselectable","true"),e?this.el.dataset.focus=this._focusMode:delete this.el.dataset.focus}_applyStackedRoles(t){let e=this._gridRole();e?this._table.setAttribute("role",e):t?this._table.setAttribute("role","table"):this._table.removeAttribute("role");for(let i of[this._thead,this._tbody])t?i.setAttribute("role","rowgroup"):i.removeAttribute("role");for(let[i,n]of[["tr","row"],["td",e?"gridcell":"cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(i))t?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(S(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(t=>!this._hiddenColumns.has(t.id))}_isSpanningRow(t){return this._rowKind===null||this._rowKinds===null?!1:Cu(t,this._rowKind,this._rowKinds)}_hasSpanningRow(){return Zg(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return tb(this._visibleColumns().length,{selectable:this.options.selectable,rowReorder:this.options.rowReorder})}_selectableData(){let t=this._visibleData();return this._rowKind===null?t:t.filter(e=>!this._isSpanningRow(e))}_createColumnControls(){let t=l("div",{class:"zx-table__column-list"});this._columnList=t,this._columnStatus=l("div",{class:"zx-table__column-status",role:"status",ariaLive:"polite"});let e=l("details",{class:"zx-table__column-controls"},l("summary",{class:"zx-btn",dataset:{size:"sm"}},b("fields"),this._message("table.columns","Columns",[])),t);return this._renderColumnControls(),e}_renderColumnControls(t=null){if(!this._columnList)return;let e=this._visibleColumns(),i=this._columns.map((n,r)=>{let o=!this._hiddenColumns.has(n.id),a=this._columnControlIds.get(n.id);a||(a=x("zx-table-column"),this._columnControlIds.set(n.id,a));let c=this.options.columnVisibility?l("input",{id:a,class:"zx-table__column-toggle",type:"checkbox",value:n.id,checked:o,disabled:o&&e.length===1,dataset:{columnId:n.id,columnAction:"toggle"}}):null,d=Tn(n),u=c?l("label",{for:a},c,l("span",{},d)):l("span",{class:"zx-table__column-label"},d),h=this.options.columnReorder?l("span",{class:"zx-table__column-order",role:"group",ariaLabel:this._message("table.moveColumn","Move %1",[d])},l("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:`Move ${d} earlier`,dataset:{columnId:n.id,columnAction:"up"}},b("chevron-up",{size:11})),l("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:`Move ${d} later`,dataset:{columnId:n.id,columnAction:"down"}},b("chevron-down",{size:11}))):null;return l("div",{class:"zx-table__column-option",dataset:{columnId:n.id}},u,h)});if(this._columnList.replaceChildren(...i,this._columnStatus),t!==null){let n=[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&o.dataset.columnAction===t.action});n?.disabled&&(n=[...this._columnList.querySelectorAll(".zx-table__column-move[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})??[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})),queueMicrotask(()=>{n?.isConnected&&n.focus()})}}_activeColumnControl(){let t=typeof document>"u"?null:document.activeElement;if(!t||!this._columnList?.contains(t))return null;let e=t.dataset.columnId,i=t.dataset.columnAction;return e&&i?{id:e,action:i}:null}_handleColumnControlClick(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let i=e.dataset.columnId,n=e.dataset.columnAction,r=this.getColumnOrder().indexOf(String(i));n==="up"&&r>0&&this.moveColumn(String(i),this._columns[r-1].id,"before"),n==="down"&&r>=0&&r<this._columns.length-1&&this.moveColumn(String(i),this._columns[r+1].id,"after")}_handleColumnControlKeydown(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let i=String(e.dataset.columnId),n=this.getColumnOrder(),r=n.indexOf(i);r<0||(t.key==="ArrowUp"||t.key==="ArrowLeft"?(t.preventDefault(),r>0&&this.moveColumn(i,n[r-1],"before")):t.key==="ArrowDown"||t.key==="ArrowRight"?(t.preventDefault(),r<n.length-1&&this.moveColumn(i,n[r+1],"after")):t.key==="Home"?(t.preventDefault(),r>0&&this.moveColumn(i,n[0],"before")):t.key==="End"&&(t.preventDefault(),r<n.length-1&&this.moveColumn(i,n.at(-1),"after")))}_handleRowDragStart(t){let e=t.target?.closest?.(".zx-table__row-handle"),i=e?.closest("tr[data-row]"),n=i?this._rowMeta.get(i):null;if(!e||!n||this._sort&&this.options.sortMode==="local"){t.preventDefault();return}this._dragId=n.id,i.dataset.dragging="true",t.dataTransfer?.setData("text/plain","zx-table-row"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleRowDragOver(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),i=e?this._rowMeta.get(e):null;if(!i||Object.is(i.id,this._dragId)||!this._canMoveTogether(this._dragId,i.id))return;t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._clearDropMarkers();let n=e.getBoundingClientRect();e.dataset.drop=t.clientY>=n.top+n.height/2?"after":"before"}_handleRowDrop(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),i=e?this._rowMeta.get(e):null,n=e?.dataset.drop==="after"?"after":"before";i&&this._canMoveTogether(this._dragId,i.id)&&(t.preventDefault(),this.moveRow(this._dragId,i.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(t){let e=t.target?.closest?.(".zx-table__row-handle"),i=e?.closest("tr[data-row]"),n=i?this._rowMeta.get(i):null;if(!e||!n)return;if(t.key===" "||t.key==="Enter"){t.preventDefault(),this._grabbedId=Object.is(this._grabbedId,n.id)?null:n.id,e.setAttribute("aria-pressed",String(this._grabbedId!=null));let c=this._rowMoveMessage??this._editMessage;c&&(c.textContent=this._grabbedId==null?"Row dropped":"Row grabbed. Use the arrow keys to move it.");return}if(t.key==="Escape"&&this._grabbedId!=null){t.preventDefault(),this._grabbedId=null,e.setAttribute("aria-pressed","false");return}if(!Object.is(this._grabbedId,n.id)||!["ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let r=this._siblingIds(n.id),o=r.findIndex(c=>Object.is(c,n.id)),a=r[o+(t.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,t.key==="ArrowUp"?"before":"after")}_siblingIds(t){let e=this.getRow(t);if(!e)return[];let i=this._hierarchy?ft(this._hierarchy.parentId,e):null;return this._data.filter(n=>!this._hierarchy||Da(ft(this._hierarchy.parentId,n),i)).map(n=>this._idFor(n))}_canMoveTogether(t,e){if(!this._hierarchy)return!0;let i=this.getRow(t),n=this.getRow(e);return!!(i&&n&&Da(ft(this._hierarchy.parentId,i),ft(this._hierarchy.parentId,n)))}_rowHandle(t){return this._rowElements.get(t)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let t of this._tbody.querySelectorAll("tr[data-drop]"))delete t.dataset.drop}_clearRowDrag(){for(let t of this._tbody.querySelectorAll("tr[data-dragging]"))delete t.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(t=>t.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let t=document.createDocumentFragment();this.options.rowReorder&&t.append(l("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&t.append(l("col",{class:"zx-table__selection-column"}));let e=this._visibleColumns(),i=e.map(r=>yb(r.width)),n=i.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0?"fixed":"auto",e.forEach((r,o)=>{let a=l("col");i[o]>0?a.style.width=`${i[o]/n*100}%`:r.width&&r.width!=="auto"&&(a.style.width=String(r.width)),t.append(a)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=l("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.rowReorder&&t.append(l("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:"Row order"})),this.options.selectable==="multi"){this._selectAll=l("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:this._message("table.selectAll","Select all rows",[])});let e=l("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let i of this._selectableData())this._selected.add(this._idFor(i));else for(let i of this._selectableData())this._selected.delete(this._idFor(i));this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map,this._headerSpanning=this._spanning;for(let e of this._visibleColumns()){let i=l("th",{scope:"col",dataset:{column:e.id}}),n=e.align??(Ma(e)?"end":null);n&&(i.dataset.align=n),e.headerTitle&&(i.title=e.headerTitle);let r=_b(e);if(r!==null&&i.setAttribute("aria-label",r),e.sortable&&!this._spanning){let o=l("button",{class:"zx-table__sort-button",type:"button",ariaLabel:r??void 0},l("span",{class:"zx-table__header-label"},e.label));this.listen(o,"click",()=>{let a=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,a)}),i.append(o)}else i.append(l("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,i),t.append(i)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){let t=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 e=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._rovingEl=null;let i=this._projectedData();this._hierarchyMeta=new Map(i.map(n=>[n.id,n])),this._data.length===0?e.append(l("tr",{class:"zx-table__empty-row"},l("td",{class:"zx-table__empty",colspan:this._spanColspan()},this._emptyContent()))):this._visibleEntries().forEach((n,r)=>{e.append(this._createRow(n.row,n.index,{...n,visibleIndex:r}))}),this._tbody.replaceChildren(e),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(i.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0),this._syncRoving(t)}_emptyContent(){let t=this.options.emptyText;return t==null?this.msg("table.empty"):typeof t=="function"?t():t}_createRow(t,e,i){let n=this._idFor(t),r=l("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(i.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean));let a=this._rowKind===null?null:ku(t,this._rowKind),c=a===null?null:zu(this._rowKinds,a),d=!!c?.span;a!==null&&(r.dataset.rowKind=a),c?.class&&r.classList.add(...String(c.class).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&!d&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(i.depth+1)),i.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._interactive&&(this._focusMode==="row"||this._hierarchy)&&(r.tabIndex=-1),this._rowMeta.set(r,{row:t,id:n,index:e,visibleIndex:i.visibleIndex});let u=this._rowElements.get(n)??[];if(u.push(r),this._rowElements.set(n,u),d){r.dataset.span="true";let h=l("th",{class:"zx-table__section-cell",scope:"colgroup",colspan:this._spanColspan()}),f=eb(t,c,this._visibleColumns(),e);return f&&typeof f=="object"&&typeof f.nodeType=="number"?h.append(f):f!=null&&h.append(document.createTextNode(String(f))),this._focusMode==="cell"&&(h.tabIndex=-1),r.append(h),r}if(this.options.rowReorder){let h=l("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},b("drag",{size:14}));r.append(l("td",{class:"zx-table__reorder-cell"},h))}if(this.options.selectable==="multi"){let h=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",tabIndex:-1,checked:this._selected.has(n)});r.append(l("td",{class:"zx-table__selection-cell"},h))}return this._visibleColumns().forEach(h=>{let f=l("td"),p=h.align??(Ma(h)?"end":null);p&&(f.dataset.align=p),f.dataset.label=h.label,f.dataset.column=h.id,h.popin===!1&&(f.dataset.popin="false"),this._focusMode==="cell"&&(f.tabIndex=-1),this._editMode!==!1&&_i(h,t)!==!1&&(f.dataset.editable="true"),this._renderCellContent(f,h,t,e,i),r.append(f)}),this._rowNames.set(r,Jg([...r.cells].map(h=>h.textContent))),this._labelRowControls(r),r}_labelRowControls(t){let e=this._rowMeta.get(t);if(!e)return;let i=this._rowNames.get(t)??this._message("table.row","row %1",[e.index+1]);t.querySelector(".zx-table__row-checkbox")?.setAttribute("aria-label",this._message("table.selectRow","Select %1",[i])),t.querySelector(".zx-table__row-handle")?.setAttribute("aria-label",this._message("table.moveRow","Move %1",[i]));let r=t.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",[i]):this._message("table.expandRow","Expand %1",[i]))}}_renderCellContent(t,e,i,n,r=this._hierarchyMeta?.get(this._idFor(i))){let o=Na(e,i,n),a=l("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchyColumn()||!r){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let d=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",tabIndex:-1,ariaExpanded:String(d)},b(d?"chevron-down":"chevron-right",{size:14})))}else c.append(l("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(a),t.replaceChildren(c),t.parentElement&&this._labelRowControls(t.parentElement)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&as(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(!n||e.closest(".zx-table__row-handle")||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,t.shiftKey);return}if(!(this._editMode!==!1&&wu(e))){if(this._editMode!==!1&&this._editTrigger==="single"){let a=e?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this._activateRow(n,t)}}_activateRow(t,e){this.emit("rowclick",{...t,event:e}),this.options.selectable==="single"&&!this._selected.has(t.id)&&!this._isSpanningRow(t.row)&&(this._selected=new Set([t.id]),this._selectionAnchorId=t.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&as(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(n&&!(this._editMode!==!1&&wu(e))){if(this._editMode!==!1&&this._editTrigger==="double"){let r=e?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:t})}}_createEditor(t,e,i,n){let r=_i(e,i);if(r===!1)return null;let o=i?.[e.id],a=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=l("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let d=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,d),t.dataset.editing="true";let u={column:e,type:r,td:t,host:d,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){u.custom=o,u.read=()=>Ae(e,u.custom,i);let p={value:o,row:i,column:e,commit:m=>{u.custom=m,this.commitEdit()},cancel:()=>this.cancelEdit()},_=e.editor(i,p);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(u.component=_),d.append(_.toElement())):_&&d.append(_),u.control=d.querySelector(Gg)??d,u}if(r==="number"){let p=ke(e.locale,i),_=Tu(e,i),m=e.type==="currency"?ke(e.currency,i):e.type==="unit"?ke(e.unit,i):null,g={...p!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:p}:{},..._!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:_}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(m)}:{}},w=new Et(null,{...g,...a,value:o??null});return d.append(w.el),u.component=w,u.control=w.getInput(),u.read=()=>(w.set(w.getInput().value,{silent:!0}),Ae(e,w.get(),i)),u}if(r==="select"){let p=nb(e.options,i),_=p.find(g=>Object.is(g.value,o))??p.find(g=>String(g.value)===String(o??"")),m=new $(null,{...a,items:p,valueKey:"value",labelKey:"label",value:_?_.value:null});return d.append(m.el),u.component=m,u.control=m.refs.input,u.read=()=>Ae(e,m.value,i),u}if(r==="date"){let p=new et(null,{...a,value:o??null});d.append(p.el),u.component=p;let _=p.refs.input;return u.control=_,u.read=()=>{let m=String(_.value??"").trim(),g=p.get();return m===""?Ae(e,null,i):(p.set(m,{silent:!0}),p.get()===null&&p.set(g,{silent:!0}),Ae(e,p.get(),i))},u}if(r==="checkbox"){let p=new J(null,{...a,checked:!!o});return d.append(p.el),u.component=p,u.control=p.el,u.read=()=>Ae(e,p.get(),i),u}let h=r==="textarea",f=l(h?"textarea":"input",{...a,class:h?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...h?{}:{type:"text"},ariaLabel:a.ariaLabel??`${Tn(e)} row ${n+1}`,value:rb(e,o,i)});return d.append(f),u.control=f,u.read=()=>Ae(e,f.value,i),u}_focusEditor(t){let e=this._edit?.cells.get(t),i=e?.control;!i||typeof i.focus!="function"||(i.focus(),mb(e.type)&&typeof i.select=="function"&&i.select())}_focusCell(t,e){let i=this._rowElements.get(t)?.[0];(i?xu(i,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(n=>Object.is(this._idFor(n),t.id)),i=e<0?t.row:this._data[e];for(let n of t.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,i,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let i=t&&this._editHasFocus(),n=this.getRow(e.id)??e.row,r=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),i&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:n,id:e.id,column:r,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let i=this._edit?.cells.get(t);i&&(i.td.dataset.invalid="true",i.control?.setAttribute("aria-invalid","true"),this._editMessage&&(i.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&as(e)){if(pb(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let i=e.closest('td[data-editable="true"]');if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i.parentElement);n&&(t.preventDefault(),this.startEdit(n.id,String(i.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let i=t.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),r=this._nextEditableCell(n,e.columnId,i);if(r&&Object.is(r.id,e.id)&&e.cells.has(r.columnId)){t.preventDefault(),e.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(t,e,i){let n=this._visibleColumns(),r=n.length;if(t<0||r===0)return null;let o=this._visibleData(),a=this._idFor(this._data[t]),c=o.findIndex(h=>Object.is(this._idFor(h),a));if(c<0)return null;let d=n.findIndex(h=>h.id===e),u=o.length*r+r;for(let h=0;h<u;h+=1){if(d+=i,d>=r?(c+=1,d=0):d<0&&(c-=1,d=r-1),c<0||c>=o.length)return null;let f=o[c],p=n[d];if(!this._isSpanningRow(f)&&_i(p,f)!==!1)return{id:this._idFor(f),columnId:p.id,index:this._data.indexOf(f)}}return null}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&as(e)||e&&this._tbody.contains(e)||this.commitEdit()}_navRows(){return[...this._tbody.children].filter(t=>t.hasAttribute("data-row"))}_navCells(t){return[...t.cells].filter(e=>e.hasAttribute("data-column")||e.classList.contains("zx-table__section-cell"))}_cellFor(t){let e=this._navCells(t);if(e.length===0)return t;let i=this._current?.columnId;return(i==null?null:e.find(r=>r.dataset.column===i))??e[Math.min(Math.max(this._current?.columnIndex??0,0),e.length-1)]}_rovingTarget(t){return this._focusMode==="row"||this._hierarchy&&this._current?.onRow?t:this._cellFor(t)}_setRoving(t){this._rovingEl&&this._rovingEl!==t&&(this._rovingEl.tabIndex=-1),t.tabIndex=0,this._rovingEl=t}_captureFocus(){let t=typeof document>"u"?null:document.activeElement;if(t&&t===this._scroll&&this._scroll.hasAttribute("data-empty-focus"))return{part:"row"};if(!t||!this._tbody?.contains(t))return null;let e=t.closest("tr[data-row]");return e?t===e?{part:"row"}:t.closest(".zx-table__row-checkbox")?{part:"checkbox"}:t.closest(".zx-table__tree-toggle")?{part:"toggle"}:t.closest(".zx-table__row-handle")?{part:"handle"}:{part:this._focusMode==="cell"?"cell":"row"}:null}_syncRoving(t){if(!this._interactive)return;let e=this._navRows();if(this._syncEmptyFocus(e.length===0&&t!==null),e.length===0)return;let i=this._current?this._rowElements.get(this._current.id)?.[0]:void 0;if(!i&&this._current&&this._hierarchy&&(i=this._renderedAncestor(this._current.id),i)){let a=this._rowMeta.get(i);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex,onRow:!0}}if(!i&&(i=e[Math.min(Math.max(this._current?.visibleIndex??0,0),e.length-1)],this._current)){let a=this._rowMeta.get(i);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex}}let n=this._rovingTarget(i);if(this._setRoving(n),!t)return;let r={checkbox:".zx-table__row-checkbox",toggle:".zx-table__tree-toggle",handle:".zx-table__row-handle:not(:disabled)"}[t.part];(r?i.querySelector(r)??n:n).focus({preventScroll:!0})}_renderedAncestor(t){if(!this._hierarchy)return;let e=new Set,i=this.getRow(t);for(;i;){let n=ft(this._hierarchy.parentId,i);if(n==null||e.has(n))return;e.add(n);let r=this._rowElements.get(n)?.[0];if(r)return r;i=this.getRow(n)}}_syncEmptyFocus(t){let e=this._scroll;t?(e.hasAttribute("tabindex")||(e.tabIndex=-1,e.setAttribute("data-empty-focus","")),e.focus({preventScroll:!0})):e.hasAttribute("data-empty-focus")&&(e.removeAttribute("tabindex"),e.removeAttribute("data-empty-focus"))}_handleFocusIn(t){if(!this._interactive)return;let e=t.target?.nodeType===1?t.target:null,i=e?.closest("tr[data-row]")??null;if(!i||i.parentElement!==this._tbody)return;let n=this._rowMeta.get(i);if(!n)return;let r={id:n.id,visibleIndex:n.visibleIndex,columnId:this._current?.columnId??null,columnIndex:this._current?.columnIndex??0,onRow:!1},o=i;if(this._focusMode==="cell"){let a=this._navCells(i),c=a.find(d=>d===e||d.contains(e))??null;e===i&&this._hierarchy?r.onRow=!0:c?(o=c,c.dataset.column&&(r.columnId=c.dataset.column,r.columnIndex=a.indexOf(c))):(this._current=r,o=this._cellFor(i))}this._current=r,this._setRoving(o)}_handleGridKeydown(t){if(!this._interactive||t.defaultPrevented||t.altKey)return;let e=t.target?.nodeType===1?t.target:null;if(!e||this._edit&&as(e))return;let i=e.closest("tr[data-row]");if(!i||i.parentElement!==this._tbody)return;let n=this._rowMeta.get(i);if(!n)return;let r=this._focusMode==="cell",o=r?this._navCells(i):[],a=e===i,c=o.includes(e),d=e.matches(".zx-table__row-checkbox, .zx-table__tree-toggle");if(!a&&!c&&!d)return;let u=t.key,h=t.ctrlKey||t.metaKey;if(h&&(u==="a"||u==="A")){if(this.options.selectable!=="multi")return;t.preventDefault(),this._selectAllRendered();return}if((u==="Enter"||u===" ")&&!d){if(h)return;t.preventDefault(),u===" "&&this.options.selectable!==!1&&!this._isSpanningRow(n.row)?this._toggleRowSelection(n):this._activateRow(n,t);return}if(this._hierarchy&&(u==="ArrowLeft"||u==="ArrowRight")&&!h){let v=this._hierarchyMeta?.get(n.id);if(!v)return;t.preventDefault();let z=Xg(u,{focus:c?"cell":"row",cells:r,column:c?o.indexOf(e):0,columns:o.length,hasChildren:v.hasChildren,expanded:this._expanded.has(n.id),hasParent:v.parentId!=null});z&&this._applyTreeAction(z,i,n,v.parentId);return}let f=this._navRows(),p=f.indexOf(i),_=r&&!a,m=c?o.indexOf(e):Math.max(0,o.indexOf(this._cellFor(i))),g=Wg({row:p,column:m},u,{rows:f.length,columns:_?o.length:1,page:this._pageSize(f),ctrl:h,cells:_});if(!g)return;t.preventDefault();let w=f[g.row];if(!_)w.focus();else if(g.row===p||u==="Home"||u==="End"){let v=this._navCells(w),z=g.column>=o.length-1&&u!=="Home";v[z?v.length-1:Math.min(g.column,v.length-1)]?.focus()}else this._cellFor(w).focus();t.shiftKey&&this.options.selectable==="multi"&&g.row!==p&&this._extendSelection(n,this._rowMeta.get(w))}_applyTreeAction(t,e,i,n){if(t.action==="expand")this.expandRow(i.id);else if(t.action==="collapse")this.collapseRow(i.id);else if(t.action==="parent")this._rowElements.get(n)?.[0]?.focus();else if(t.action==="child"){let r=this._navRows();r[r.indexOf(e)+1]?.focus()}else t.action==="row"?e.focus():t.action==="cell"&&this._navCells(e)[t.column??0]?.focus()}_pageSize(t){let e=this._scroll;if(!e||!t[0]||e.scrollHeight<=e.clientHeight+1)return 10;let i=this.options.stickyHeader?this._thead.getBoundingClientRect().height:0;return Qg(e.clientHeight-i,t[0].getBoundingClientRect().height)}_toggleRowSelection(t){let e=this._selected.has(t.id);if(this.options.selectable==="multi"){this._toggleMultiSelection(t,!e,!1);return}this._selected=e?new Set:new Set([t.id]),this._selectionAnchorId=t.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_selectAllRendered(){let t=new Set(this._selected);for(let e of this._selectableData())t.add(this._idFor(e));this._extendBase=null,!Ea(t,this._selected)&&(this._selected=t,this._syncSelection(),this._emitSelectionChange())}_extendSelection(t,e){if(!e)return;let i=this._visibleData(),n=c=>i.findIndex(d=>Object.is(this._idFor(d),c));this._extendBase===null&&(this._extendBase=new Set(this._selected),n(this._selectionAnchorId)<0&&(this._selectionAnchorId=t.id));let r=n(this._selectionAnchorId),o=n(e.id);if(r<0||o<0)return;let a=new Set(this._extendBase);for(let c=Math.min(r,o);c<=Math.max(r,o);c+=1)this._isSpanningRow(i[c])||a.add(this._idFor(i[c]));Ea(a,this._selected)||(this._selected=a,this._syncSelection(),this._emitSelectionChange())}_msgOr(t,e){let i=this.msg(t);return i===t?e:i}_toggleMultiSelection(t,e,i){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(i&&r>=0){let o=t.visibleIndex??n.findIndex(d=>Object.is(this._idFor(d),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let d=a;d<=c;d+=1){if(this._isSpanningRow(n[d]))continue;let u=this._idFor(n[d]);e?this._selected.add(u):this._selected.delete(u)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let i=this._selected.has(t);for(let n of e){if(n.hasAttribute("data-span"))continue;n.setAttribute("aria-selected",String(i));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=i)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._selectableData(),e=t.reduce((i,n)=>i+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)!this._spanning&&this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(this._spanning=this._hasSpanningRow(),!this._sort||this._spanning)return;let t=this._columns.find(i=>i.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:i=>i?.[t.id];this._data=this._hierarchy?sb(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):os(this._data,e,this._sort.dir)}_setRowExpanded(t,e,i){return this._hierarchy?kn(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,t))?this._expanded.has(t)===e?this:(e?this._expanded.add(t):this._expanded.delete(t),this._renderBody(),i.silent||this._emitRowToggle(t,e),this):this:this}_emitRowToggle(t,e){let i=this.getRow(t);i&&this.emit("rowtoggle",{row:i,id:t,expanded:e})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let t=kn(this._data,this.options.rowId,this._hierarchy.parentId),e=new Set(t);for(let i of this._expanded)e.has(i)||this._expanded.delete(i)}_selectableIds(){let t=new Set;for(let e of this._data)this._isSpanningRow(e)||t.add(this._idFor(e));return t}_pruneSelection(){let t=this._selectableIds(),e=this._selected.size;for(let i of this._selected)t.has(i)||this._selected.delete(i);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),this._extendBase=null,e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function Wg(s,t,e){let i=Math.trunc(Number(e?.rows)||0);if(i<=0)return null;let n=Math.max(1,Math.trunc(Number(e?.columns)||1)),r=Math.max(1,Math.trunc(Number(e?.page)||10)),o=(h,f)=>Math.min(Math.max(Math.trunc(Number(h)||0),0),f),a=o(s?.row,i-1),c=o(s?.column,n-1),d=!!e?.cells,u=!!e?.ctrl;switch(t){case"ArrowUp":return{row:Math.max(0,a-1),column:c};case"ArrowDown":return{row:Math.min(i-1,a+1),column:c};case"PageUp":return{row:Math.max(0,a-r),column:c};case"PageDown":return{row:Math.min(i-1,a+r),column:c};case"ArrowLeft":return d?{row:a,column:Math.max(0,c-1)}:null;case"ArrowRight":return d?{row:a,column:Math.min(n-1,c+1)}:null;case"Home":return d?u?{row:0,column:0}:{row:a,column:0}:{row:0,column:c};case"End":return d?u?{row:i-1,column:n-1}:{row:a,column:n-1}:{row:i-1,column:c};default:return null}}function Qg(s,t,e=10){let i=Number(s),n=Number(t);return!(i>0)||!(n>0)?Math.max(1,Math.trunc(e)||10):Math.max(1,Math.floor(i/n)-1)}function Xg(s,t){let e=s==="ArrowRight";if(!e&&s!=="ArrowLeft")return null;if(t?.focus==="cell"){let r=Math.max(0,Math.trunc(Number(t.column)||0)),o=Math.max(1,Math.trunc(Number(t.columns)||1));return e?r<o-1?{action:"cell",column:r+1}:null:r>0?{action:"cell",column:r-1}:{action:"row"}}let i=!!t?.hasChildren,n=i&&!!t?.expanded;return e?i&&!n?{action:"expand"}:t?.cells?{action:"cell",column:0}:n?{action:"child"}:null:n?{action:"collapse"}:t?.hasParent?{action:"parent"}:null}function Jg(s,t=80){for(let e of Array.isArray(s)?s:[]){let i=String(e??"").replace(/\s+/g," ").trim();if(i)return i.length>t?`${i.slice(0,Math.max(1,t-1)).trimEnd()}\u2026`:i}return null}function ku(s,t){if(t==null||t==="")return null;let e=typeof t=="function"?t(s):s?.[t];return e==null?null:String(e)}function zu(s,t){if(t===null||s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,t))return null;let e=s[t];return e&&typeof e=="object"?e:null}function Cu(s,t,e){return!!zu(e,ku(s,t))?.span}function Zg(s,t,e){return!Array.isArray(s)||t==null||e==null?!1:s.some(i=>Cu(i,t,e))}function tb(s,t={}){let e=Number.isFinite(Number(s))?Math.max(0,Math.trunc(Number(s))):0,i=(t.selectable==="multi"?1:0)+(t.rowReorder?1:0);return Math.max(1,e+i)}function eb(s,t,e,i=0){if(typeof t?.render=="function")return t.render(s,i);let n=e?.[0];return n?s?.[n.id]:null}function Na(s,t,e=0){if(typeof s?.render=="function")return s.render(t,e);let i=t?.[s?.id],n=s?.type??"text";if(n==="text")return i;let r=ke(s.locale,t),o=Tu(s,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return Nt(i,a);if(n==="currency"){let c=ke(s.currency,t);return oi(i,c==null?null:String(c),a)}if(n==="percent")return ai(i,a);if(n==="unit"){let c=Nt(i,a),d=ke(s.unit,t);return c&&d!=null&&String(d)!==""?`${c}\xA0${d}`:c}return i}function ib(s,t,e,i=[]){let n=In(s,t,e),r=i instanceof Set?i:new Set(i),o=[],a=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:d}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:d,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let u=c.children.length-1;u>=0;u-=1)a.push({node:c.children[u],depth:d+1})}return o}function sb(s,t,e,i,n){let r=In(s,t,e),o=d=>os(d,u=>i(u.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let d=c.pop();a.push(d.row);let u=o(d.children);for(let h=u.length-1;h>=0;h-=1)c.push(u[h])}return a}function Oa(s,t,e,i,n="before",r=null){if(!Array.isArray(s)||Object.is(e,i))return null;let o=s.findIndex(h=>Object.is(ft(t,h),e)),a=s.findIndex(h=>Object.is(ft(t,h),i));if(o<0||a<0||r&&!Da(ft(r,s[o]),ft(r,s[a])))return null;if(r){let h=In(s,t,r),f=h.nodes[o],p=h.nodes[a];if(!f||!p||f.parent!==p.parent)return null;let _=k=>{let M=[],it=[k];for(;it.length;){let F=it.pop();M.push(F);for(let st=F.children.length-1;st>=0;st-=1)it.push(F.children[st])}return M},m=new Set(_(f).map(k=>k.index)),g=new Set(_(p).map(k=>k.index)),w=s.filter((k,M)=>m.has(M)),v=s.filter((k,M)=>!m.has(M)),z=s.map((k,M)=>M).filter(k=>!m.has(k)),C=z.findIndex(k=>k===a);if(n==="after"){let k=z.map((M,it)=>g.has(M)?it:-1).filter(M=>M>=0);C=Math.max(...k)+1}return C<0?null:(v.splice(C,0,...w),v)}let c=[...s],[d]=c.splice(o,1),u=c.findIndex(h=>Object.is(ft(t,h),i));return c.splice(u+(n==="after"?1:0),0,d),c}function _i(s,t){if(!s||typeof s!="object")return!1;if(typeof s.editor=="function")return typeof s.editable=="function"&&s.editable(t)===!1?!1:"custom";let e=typeof s.editable=="function"?s.editable(t):s.editable;return e===!0?Ma(s)?"number":"text":typeof e=="string"&&Yg.has(e)?e:!1}function nb(s,t){let e=typeof s=="function"?s(t):s;return Array.isArray(e)?e.map(i=>i!==null&&typeof i=="object"?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([i,n])=>({value:i,label:String(n??"")})):[]}function rb(s,t,e){if(typeof s?.format=="function"){let i=s.format(t,e);return i==null?"":String(i)}return t==null?"":String(t)}function Ae(s,t,e){return typeof s?.parse=="function"?s.parse(t,e):t}function ob(s,t){return Object.is(s,t)?!0:s instanceof Date&&t instanceof Date?s.getTime()===t.getTime():!1}function ab(s,t){let e={};for(let[i,n]of Object.entries(t??{}))ob(s?.[i],n)||(e[i]=n);return e}function lb(s,t,e,i="Invalid value"){for(let n of t??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(s??{},n.id))continue;let r=n.validate(s[n.id],e);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:i}}return null}function ke(s,t){return typeof s=="function"?s(t):s}function Tu(s,t){let e=ke(s?.decimals,t);if(e==null)return null;let i=Number(e);return Number.isFinite(i)?Math.max(0,Math.trunc(i)):null}function Ma(s){return["number","currency","percent","unit"].includes(s?.type)}function In(s,t,e){let i=(Array.isArray(s)?s:[]).map((a,c)=>({row:a,id:ft(t,a),index:c,parent:null,children:[]})),n=new Map;for(let a of i)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of i){let c=ft(e,a.row),d=c==null?null:n.get(c)??null;r.set(a,d===a?null:d)}for(let a of i){let c=new Set([a]),d=r.get(a)??null;for(;d;){if(c.has(d)){r.set(d,null);break}c.add(d),d=r.get(d)??null}}let o=[];for(let a of i)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:i}}function kn(s,t,e){return In(s,t,e).nodes.filter(i=>i.children.length>0).map(i=>i.id)}function ft(s,t){return typeof s=="function"?s(t):t?.[s]}function Da(s,t){return s==null&&t==null||Object.is(s,t)}function zn(s,t){if(!s||typeof s!="object")return null;let e=s.parentId;if(typeof e!="string"&&typeof e!="function")return null;let i=typeof s.column=="string"?s.column:null,n=t.some(r=>r.id===i)?i:t[0]?.id;return n?{...s,parentId:e,column:n}:null}function cb(s){return typeof s=="function"||typeof s=="string"&&s!==""?s:null}function db(s){return!s||typeof s!="object"||Array.isArray(s)?null:s}function ub(s){return new Set(Array.isArray(s)?s:[])}function hb(s){return s==="plain"?"plain":"default"}function fb(s){return s==="cell"||s==="row"?s:s===!0?"cell":!1}function as(s){return!!s?.closest?.(".zx-table__editor")}function wu(s){let t=s?.closest?.("td[data-column]"),e=s?.closest?.(["a[href]","button","input","select","textarea","summary",'[contenteditable="true"]','[role="button"]','[role="link"]','[tabindex]:not([tabindex="-1"])',"[data-zx-table-no-edit]"].join(","));return!!(t&&e&&e!==t&&t.contains(e))}function pb(s){return s.closest("[popover]")?!0:s.getAttribute?.("aria-expanded")==="true"}function vu(s){if(!Array.isArray(s))throw new TypeError("Table columns must be an array");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Table column at index ${i} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Table column at index ${i} requires an id`);if(t.has(n))throw new TypeError(`Duplicate table column: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??n)}})}function Tn(s){for(let t of[s?.ariaLabel,s?.label]){let e=t==null?"":String(t).trim();if(e)return e}return String(s?.id??"")}function _b(s){let t=s?.label==null?"":String(s.label).trim(),e=s?.ariaLabel==null?"":String(s.ariaLabel).trim();return e||(t?null:Tn(s)||null)}function mb(s){return s==="text"||s==="number"||s==="date"}function gb(s,t){let e=s.map(a=>a.id),i=new Set(e),n=Array.isArray(t)?t.map(String):[],r=new Set,o=[];for(let a of n)i.has(a)&&!r.has(a)&&(r.add(a),o.push(a));for(let a of e)r.has(a)||o.push(a);return o}function bb(s,t,e,i="before"){let n=[...s],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(i==="after"?1:0);return n.splice(a,0,t),n}function xu(s,t){for(let e of s.cells)if(e.dataset.column===t)return e;return null}function Su(s,t){return!s||typeof s!="object"||!t.some(e=>e.id===s.id)?null:{id:s.id,dir:s.dir==="desc"?"desc":"asc"}}function yb(s){if(typeof s!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(s.trim());return t?Math.max(0,Number(t[1])):0}function Au(s){if(!Array.isArray(s))throw new TypeError("Table data must be an array")}function Ea(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function Cn(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function wb(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:null}var xt=Symbol("invalid attribute");function mi(s,t="string",e=console.warn){if(Iu(t),t==="boolean")return s!==null;if(s!==null){if(t==="string")return s;if(t==="number"){let i=Number(s);return Number.isFinite(i)?i:(e(`Ignoring invalid number attribute: ${JSON.stringify(s)}`),xt)}try{return JSON.parse(s)}catch{return e(`Ignoring invalid JSON attribute: ${JSON.stringify(s)}`),xt}}}function Fa(s,t="string",e=console.warn){if(Iu(t),t==="boolean")return s?"":null;if(s==null)return null;if(t==="number"){let i=Number(s);return Number.isFinite(i)?String(i):(e(`Ignoring invalid number property: ${String(s)}`),xt)}if(t==="json"){try{let i=JSON.stringify(s);if(i!==void 0)return i}catch{}return e("Ignoring property that cannot be serialized as JSON"),xt}return String(s)}function Iu(s){if(!["string","number","boolean","json"].includes(String(s)))throw new TypeError(`Unknown reflected attribute type: ${String(s)}`)}var vb=Object.freeze(["change","input","submit","clear","open","close","cancel","invalid","query","loaded","rowclick","rowdblclick","sort","selectionchange","datachange"]),xb=St({checked:H({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:O({default:!0}),label:O({default:null,rebuild:!0}),disabled:H({always:!0,set:ls})}),Sb=St({checked:H({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:O({option:null,default:"on"}),label:O({default:"",set:(s,t)=>s.setLabel(t)}),icon:H({rebuild:!0}),disabled:H({always:!0,set:ls})}),Ab=St({items:$t({default:[],set:(s,t)=>s.setItems(t)}),value:O({default:null,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.value}),"value-key":O({property:"valueKey",default:"ID",rebuild:!0}),"label-key":O({property:"labelKey",default:"name",rebuild:!0}),placeholder:O({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:H({default:!1,rebuild:!0}),filter:O({default:!1,normalize:Rb,rebuild:!0}),"search-keys":$t({property:"searchKeys",default:null,rebuild:!0}),"min-query":gi({property:"minQuery",default:0,rebuild:!0}),debounce:gi({default:200,rebuild:!0}),"list-height":gi({property:"listHeight",default:280,rebuild:!0}),disabled:H({always:!0,set:ls}),required:H({option:null,always:!0}),name:O({option:null,default:""})}),kb=St({items:$t({default:[],set:(s,t)=>s.setItems(t)}),value:$t({option:null,default:[],set:(s,t)=>s.setValues(t),get:s=>s.getValues()}),"value-key":O({property:"valueKey",default:"ID",rebuild:!0}),"label-key":O({property:"labelKey",default:"name",rebuild:!0}),"checked-key":O({property:"checkedKey",default:"on",rebuild:!0}),search:H({rebuild:!0}),height:gi({default:280,rebuild:!0}),"default-checked":H({property:"defaultChecked",default:!1,rebuild:!0}),disabled:H({option:null,always:!0,set:Lb}),name:O({option:null,default:""})}),zb=St({format:O({default:"%d.%m.%Y",rebuild:!0}),time:H({always:!0,rebuild:!0}),value:O({option:null,default:null,normalize:jb,set:(s,t)=>s.set(t,{silent:!0}),get:(s,t)=>Ra(s.get(),!!t.time),serialize:Hb}),placeholder:O({default:null,rebuild:!0}),clearable:H({rebuild:!0}),disabled:H({always:!0,set:ls}),required:H({option:null,always:!0}),name:O({option:null,default:""})}),Cb=St({value:gi({default:0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),unit:O({default:"minutes",rebuild:!0}),seconds:H({always:!0,rebuild:!0}),signed:H({always:!0,rebuild:!0}),disabled:H({always:!0,set:ls}),name:O({option:null,default:""})}),Tb=St({value:O({default:"",set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),placeholder:O({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:H({rebuild:!0}),debounce:gi({default:250,rebuild:!0})}),Ib=St({title:O({default:"",set:(s,t)=>s.setTitle(t)}),open:H({default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),Eb=St({tabs:$t({default:[],normalize:Bb,rebuild:!0}),active:O({default:null,set:(s,t)=>{t!==null&&s.openTab(t)},get:s=>s.getActive()}),variant:O({default:"divided",rebuild:!0}),"keep-alive":H({property:"keepAlive",rebuild:!0})}),Mb=St({columns:$t({default:[],rebuild:!0}),data:$t({default:[],set:(s,t)=>s.setData(t),get:s=>s.getData()}),"row-id":O({property:"rowId",default:"ID",rebuild:!0}),sort:$t({default:null,rebuild:!0}),"sort-mode":O({property:"sortMode",default:"local",rebuild:!0}),selectable:O({default:!1,normalize:Pb,rebuild:!0}),"sticky-header":H({property:"stickyHeader",rebuild:!0}),height:O({default:null,normalize:Nu,rebuild:!0}),"empty-text":O({property:"emptyText",default:null,rebuild:!0}),zebra:H({rebuild:!0})}),Db=St({title:O({default:"",set:(s,t)=>s.setTitle(t)}),size:O({default:"md",normalize:Nu,rebuild:!0}),buttons:$t({default:[],set:(s,t)=>s.setButtons(t)}),closable:H({rebuild:!0}),open:H({option:null,default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),Nb=Object.freeze([["toggle",J,{formAssociated:!0,attrs:xb}],["check-button",Ht,{formAssociated:!0,attrs:Sb}],["select",$,{formAssociated:!0,attrs:Ab}],["checklist",lt,{formAssociated:!0,attrs:kb}],["datebox",et,{formAssociated:!0,attrs:zb}],["timebox",Dt,{formAssociated:!0,attrs:Cb}],["search",Ot,{formAssociated:!1,attrs:Tb}],["groupbox",ce,{formAssociated:!1,attrs:Ib}],["tabbox",pi,{formAssociated:!1,attrs:Eb}],["table",Ft,{formAssociated:!1,attrs:Mb}],["dialog",qt,{formAssociated:!1,attrs:Db}]]);function Ob(s,{formAssociated:t=!1,attrs:e={}}={}){let i=Du(e),n=Object.freeze(Object.keys(i)),r=s===ce||s===qt;class o extends HTMLElement{static formAssociated=!!t;static get observedAttributes(){return n}constructor(){super(),this._component=null,this._bridgeAbort=null,this._reflecting=new Set,this._propertyValues=new Map,this._defaults=null,this._contentNodes=null,this._disabledByForm=!1,this._applying=!1,this._internals=t&&typeof this.attachInternals=="function"?this.attachInternals():null}connectedCallback(){this._component||(this._upgradeProperties(i),r&&this._contentNodes===null&&(this._contentNodes=Array.from(this.childNodes)),t&&this._defaults===null&&this._captureDefaults(i),this._createComponent(s,i,r))}disconnectedCallback(){this._destroyComponent()}attributeChangedCallback(c,d,u){if(this._reflecting.has(c))return;let h=i[c];if(!h)return;let f=mi(u,h.type);if(f===xt)return;this._propertyValues.delete(h.property);let p=f===void 0?En(h.default):f;this._applyValue(c,h,p)}formDisabledCallback(c){this._disabledByForm=!!c,this._syncEffectiveDisabled(i),this._syncFormState(s)}formResetCallback(){if(!this._defaults)return;let c=La(s);!c||!this._defaults.has(c)||this._applyControlValue(i,c,En(this._defaults.get(c)))}formStateRestoreCallback(c,d){if(typeof c!="string")return;let u=$b(s,c);if(u===xt)return;let h=La(s);h&&this._applyControlValue(i,h,u)}get component(){return this._component}get form(){return this._internals?.form??null}get labels(){return this._internals?.labels??null}get validity(){return this._internals?.validity??null}get validationMessage(){return this._internals?.validationMessage??""}get willValidate(){return this._internals?.willValidate??!1}checkValidity(){return this._internals?.checkValidity()??!0}reportValidity(){return this._internals?.reportValidity()??!0}_upgradeProperties(c){for(let d of Object.values(c)){let u=d.property;if(!Object.prototype.hasOwnProperty.call(this,u))continue;let h=this[u];delete this[u],this[u]=h}}_captureDefaults(c){this._defaults=new Map;let d=La(s);if(d){let u=Object.values(c).find(h=>h.property===d);u&&this._defaults.set(d,En(this._readProperty(u)))}}_createComponent(c,d,u){let h={};for(let[_,m]of Object.entries(d)){if(!(this._propertyValues.has(m.property)||this.hasAttribute(_)||m.always)||m.option===null)continue;let w=this._currentValue(_,m);w===xt||w===void 0||(h[m.option]=Eu(m,w,this))}let f=null;u&&(f=document.createDocumentFragment(),f.append(...this._contentNodes),h.content=f);let p=new c(null,h);this._component=p,s===ce&&f&&p.setContent(f),this.append(p.el),this._bridgeEvents(p,s);for(let[_,m]of Object.entries(d)){if(m.option!==null||!m.set||!(this._propertyValues.has(m.property)||this.hasAttribute(_)||m.always))continue;let w=this._currentValue(_,m);w!==xt&&w!==void 0&&this._applyValue(_,m,w,!0)}this._syncEffectiveDisabled(d),this._syncFormState(s)}_bridgeEvents(c,d){this._bridgeAbort?.abort(),this._bridgeAbort=new AbortController;for(let u of vb)c.on(u,h=>{if(this._applying)return;this._syncFormState(d);let f=new CustomEvent(`zx-${u}`,{detail:h.detail??{},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(f),f.defaultPrevented&&h.preventDefault()}),c.el.addEventListener(`zx-${u}`,h=>h.stopPropagation(),{signal:this._bridgeAbort.signal})}_destroyComponent(){this._bridgeAbort?.abort(),this._bridgeAbort=null,this._component&&(this._component.destroy(),this._component=null)}_rebuildComponent(c,d=r){this._component&&(d&&this._contentNodes&&document.createDocumentFragment().append(...this._contentNodes),this._destroyComponent(),this._createComponent(s,c,d))}_applyValue(c,d,u,h=!1){if(this._component){if(d.rebuild&&!h){this._rebuildComponent(i);return}if(!d.set){this._syncFormState(s);return}this._applying=!0;try{d.set(this._component,Eu(d,u,this),this)}finally{this._applying=!1}c!=="disabled"&&this._syncEffectiveDisabled(i),this._syncFormState(s)}}_syncEffectiveDisabled(c){if(!(!this._component||!c.disabled?.set)){this._applying=!0;try{c.disabled.set(this._component,this.hasAttribute("disabled")||this._disabledByForm,this)}finally{this._applying=!1}}}_syncFormState(c){if(!this._internals||!this._component)return;let{formValue:d,state:u,empty:h}=qb(c,this._component,this);if(this._internals.setFormValue(d,u),(c===$||c===et)&&this.hasAttribute("required")&&h){let f=c===et?"Please enter a date.":"Please select a value.";this._internals.setValidity({valueMissing:!0},f,this._component.refs.input)}else this._internals.setValidity({})}_applyControlValue(c,d,u){let h=Object.entries(c).find(([,f])=>f.property===d);h&&this._applyValue(h[0],h[1],u)}_currentValue(c,d){if(this._propertyValues.has(d.property))return this._propertyValues.get(d.property);let u=mi(this.getAttribute(c),d.type);return u===void 0?d.default:u}_readProperty(c){if(this._component&&c.get)return c.get(this._component,this);if(this._propertyValues.has(c.property))return this._propertyValues.get(c.property);let d=mi(this.getAttribute(c.attribute),c.type);return d===xt||d===void 0?En(c.default):d}_writeProperty(c,d){this._propertyValues.set(c.property,d);let u=c.serialize?c.serialize(d,this):Fa(d,c.type);if(u!==xt){this._reflecting.add(c.attribute);try{u===null?this.removeAttribute(c.attribute):this.setAttribute(c.attribute,u)}finally{this._reflecting.delete(c.attribute)}}this._applyValue(c.attribute,c,d)}}for(let a of Object.values(i))Object.prototype.hasOwnProperty.call(o.prototype,a.property)||Object.defineProperty(o.prototype,a.property,{configurable:!0,enumerable:!0,get(){return this._readProperty(a)},set(c){this._writeProperty(a,c)}});return o}function Mu(s="zx"){if(typeof customElements>"u")throw new Error("Custom elements are not available in this environment");let t=String(s).trim();for(let[e,i,n]of Nb){let r=`${t}-${e}`;customElements.get(r)||customElements.define(r,Ob(i,n))}}function Du(s){let t={};for(let[e,i]of Object.entries(s)){let n=typeof i=="string"?{type:i}:{...i},r=n.property??Fb(e);t[e]=Object.freeze({type:n.type??"string",option:Object.prototype.hasOwnProperty.call(n,"option")?n.option:r,property:r,default:n.default,always:!!n.always,rebuild:!!n.rebuild,normalize:n.normalize,serialize:n.serialize,set:n.set,get:n.get,attribute:e})}return Object.freeze(t)}function St(s){return Du(s)}function O(s={}){return{type:"string",...s}}function gi(s={}){return{type:"number",...s}}function H(s={}){return{type:"boolean",default:!1,always:!0,...s}}function $t(s={}){return{type:"json",...s}}function Fb(s){return s.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Eu(s,t,e){return s.normalize?s.normalize(t,e):t}function ls(s,t){t?s.disable():s.enable()}function Lb(s,t){s.el.setAttribute("aria-disabled",String(t)),s.refs.search&&(s.refs.search.disabled=t);for(let e of s.refs.list?.querySelectorAll("input")??[])e.disabled=t}function Rb(s){return s===""||s==="true"?"local":s==="false"?!1:s}function Pb(s){return s===""||s==="true"?"single":s==="false"?!1:s}function Nu(s){if(typeof s!="string"||s.trim()==="")return s;let t=Number(s);return Number.isFinite(t)?t:s}function Bb(s){return Array.isArray(s)?s.map(t=>!t||typeof t!="object"||Vb(t.content)||typeof t.content=="function"?t:{...t,content:document.createTextNode(String(t.content??""))}):s}function Vb(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function jb(s){return typeof s!="string"?s:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(s)?tt(s,"%Y-%m-%dT%H:%M"):/^\d{4}-\d{2}-\d{2}$/.test(s)?tt(s,"%Y-%m-%d"):s}function Hb(s,t){return s instanceof Date?Ra(s,!!t.time):Fa(s,"string")}function Ra(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":N(s,t?"%Y-%m-%dT%H:%M":"%Y-%m-%d")}function La(s){return s===J||s===Ht?"checked":[$,lt,et,Dt].includes(s)?"value":null}function qb(s,t,e){if(s===J||s===Ht){let n=t.get(),r=s===J?!0:"on";return e._propertyValues.has("value")?r=e._propertyValues.get("value"):e.hasAttribute("value")&&(r=e.getAttribute("value")),{formValue:n?String(r):null,state:String(n),empty:!n}}if(s===$){let n=t.value;return{formValue:n===null?null:String(n),state:JSON.stringify(n),empty:n===null||n===""}}if(s===lt){let n=JSON.stringify(t.getValues());return{formValue:n,state:n,empty:n==="[]"}}if(s===et){let n=Ra(t.get(),!!e.time);return{formValue:n||null,state:n,empty:n===""}}let i=String(t.get());return{formValue:i,state:i,empty:!1}}function $b(s,t){return s===J||s===Ht?t==="true":s===$||s===lt?mi(t,"json"):s===Dt?mi(t,"number"):t}function En(s){return Array.isArray(s)?s.slice():s instanceof Date?new Date(s.getTime()):s}var Kb=Object.freeze({md:40,sm:28}),Ub=Object.freeze({icon:"folder-open",title:"",description:"",actions:[],size:"md",align:"center"});function Ou(s={}){let t={...Ub,...s},e=Gb(t.size),i=l("div",{class:"zx-empty-state",dataset:{size:e,align:Wb(t.align)}});t.icon&&i.append(l("div",{class:"zx-empty-state__icon",ariaHidden:"true"},b(t.icon,{size:Kb[e]}))),t.title&&i.append(l("p",{class:"zx-empty-state__title"},String(t.title))),t.description&&i.append(l("p",{class:"zx-empty-state__description"},String(t.description)));let n=Yb(t.actions);return n.length>0&&i.append(l("div",{class:"zx-empty-state__actions"},n)),i}function Yb(s){if(!Array.isArray(s))throw new TypeError("emptyState actions must be an array");return s.map(t=>{if(E(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("emptyState actions must be Elements or button descriptors");return j(t)})}function Gb(s){return s==="sm"?"sm":"md"}function Wb(s){return s==="start"?"start":"center"}var bi=class extends y{static cssName="progress-bar";static defaults={value:0,max:100,label:"",helperText:"",status:"active",indeterminate:!1,size:"md",hideLabel:!1,showValue:!0,formatValue:null};render(){this._value=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Number(this.options.max)||100),this._status=Fu(this.options.status),this._indeterminate=!!this.options.indeterminate,this._labelId=x("zx-progress-label");let e=l("div",{ref:"head",class:"zx-progress-bar__head"},l("span",{ref:"label",class:"zx-progress-bar__label",id:this._labelId},String(this.options.label??"")),l("span",{ref:"value",class:"zx-progress-bar__value"})),i=l("div",{ref:"track",class:"zx-progress-bar__track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(this._max),ariaLabelledby:this._labelId},l("div",{ref:"fill",class:"zx-progress-bar__fill"}));return t.replaceChildren(e,i,l("p",{ref:"helper",class:"zx-progress-bar__helper"},String(this.options.helperText??""))),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.set(this.options.value,{silent:!0}),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=Number(t),n=q(Number.isFinite(i)?i:0,0,this._max),r=n!==this._value,o=r&&n>=this._max;return this._value=n,this._sync(),!e&&r&&this.emit("change",{value:n,percent:this.percent()}),!e&&o&&this.emit("complete",{value:n}),this}percent(){return this._value/this._max*100}setMax(t){return this._max=Math.max(1,Number(t)||1),this.refs.track.setAttribute("aria-valuemax",String(this._max)),this.set(this._value,{silent:!0})}setStatus(t,e){return this._status=Fu(t),e!==void 0&&this.setHelperText(e),this._sync(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}setHelperText(t){return this.refs.helper.textContent=String(t??""),this}setIndeterminate(t=!0){return this._indeterminate=!!t,this._sync(),this}_sync(){let{track:t,fill:e,value:i}=this.refs;if(this.el.dataset.status=this._status,this.el.toggleAttribute("data-indeterminate",this._indeterminate),this._indeterminate){t.removeAttribute("aria-valuenow"),t.removeAttribute("aria-valuetext"),e.style.removeProperty("--zx-progress-fill"),i.textContent="";return}let n=this._format();t.setAttribute("aria-valuenow",String(this._value)),t.setAttribute("aria-valuetext",n),e.style.setProperty("--zx-progress-fill",`${this.percent()}%`),i.replaceChildren(...this._readout(n))}_format(){let t=this.options.formatValue;return typeof t=="function"?String(t(this._value,this._max)):`${Math.round(this.percent())}%`}_readout(t){if(!this.options.showValue)return[];let e=[];return this._status!=="active"&&e.push(b(this._status==="success"?"success":"error",{size:14})),e.push(l("span",{class:"zx-progress-bar__percent"},t)),e}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function Fu(s){return s==="success"||s==="error"?s:"active"}var Qb=new Set(["inactive","active","success","error"]),Mn=class extends y{static cssName="inline-loading";static defaults={status:"active",description:"",size:"sm",live:!0};render(){this._status="inactive",this._description="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("span");return this.el=t,t.replaceChildren(l("span",{ref:"indicator",class:"zx-inline-loading__indicator"}),l("span",{ref:"description",class:"zx-inline-loading__description"})),t.dataset.size=this.options.size==="md"?"md":"sm",this.options.live!==!1&&(t.setAttribute("role","status"),t.setAttribute("aria-live","polite")),this.set(this.options.status,this.options.description,{silent:!0}),t}get(){return this._status}getDescription(){return this._description}set(t,e,{silent:i=!1}={}){let n=Qb.has(t)?t:"inactive";e!==void 0&&(this._description=String(e??""));let r=n!==this._status;return this._status=n,this._sync(),r&&!i&&this.emit("statuschange",{status:this._status,description:this._description}),this}setDescription(t){return this._description=String(t??""),this.refs.description.textContent=this._description,this}_sync(){this.el.dataset.status=this._status,this.refs.description.textContent=this._description,this.refs.indicator.replaceChildren(...this._indicator())}_indicator(){let t=this.el.dataset.size==="md"?18:16;return this._status==="active"?[fi({size:"sm",kind:"current"})]:this._status==="success"?[b("success",{size:t})]:this._status==="error"?[b("error",{size:t})]:[]}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function ot(s={}){let t={width:"100%",height:"1rem",radius:"sm",...s};return l("span",{class:"zx-skeleton",ariaHidden:"true",dataset:{radius:Xb.has(t.radius)?t.radius:"sm"},style:{"inline-size":Pa(t.width),"block-size":Pa(t.height)}})}function yi(s={}){let t={lines:3,width:"100%",heading:!1,lastLineWidth:"60%",...s},e=q(Math.trunc(Number(t.lines)||0),1,20),i=l("div",{class:"zx-skeleton-text",ariaHidden:"true",style:{"inline-size":Pa(t.width)}});for(let n=0;n<e;n+=1){let r=t.heading&&n===0,o=n===e-1&&e>1;i.append(ot({width:o?t.lastLineWidth:"100%",height:r?"1.5rem":"0.75rem"}))}return i}function Ru(s={}){let t={rows:5,columns:4,header:!0,...s},e=q(Math.trunc(Number(t.rows)||0),1,50),i=q(Math.trunc(Number(t.columns)||0),1,20),n=l("div",{class:"zx-skeleton-table",ariaHidden:"true",style:{"--zx-skeleton-columns":String(i)}});t.header!==!1&&n.append(Lu(i,"header"));for(let r=0;r<e;r+=1)n.append(Lu(i,"body"));return n}var Xb=new Set(["sm","md","full"]);function Lu(s,t){let e=l("div",{class:"zx-skeleton-table__row",dataset:{kind:t}});for(let i=0;i<s;i+=1)e.append(l("span",{class:"zx-skeleton-table__cell"},ot({width:Jb(i,s),height:"0.75rem"})));return e}function Jb(s,t){return s===t-1?"55%":s%2===0?"80%":"65%"}function Pa(s){return typeof s=="number"?`${s}px`:String(s??"")}function Pu(s={},...t){return l("div",{class:["zx-stack",s.class??""],dataset:{direction:s.direction==="row"?"row":null,align:ju.has(s.align)?s.align:null,justify:Zb.has(s.justify)?s.justify:null,wrap:s.wrap?"true":null,inline:s.inline?"true":null},style:Hu("--zx-stack-gap",s.gap)},t)}function Bu(s={},...t){let e=Number(s.columns),i={...Hu("--zx-grid-gap",s.gap),"--zx-grid-min":ey(s.min??"16rem")};return Number.isFinite(e)&&e>=1&&(i["--zx-grid-columns"]=String(Math.trunc(e))),l("div",{class:["zx-grid",s.class??""],dataset:{columns:Number.isFinite(e)&&e>=1?"true":null,align:ju.has(s.align)?s.align:null},style:i},t)}function Vu(s={},...t){return l("div",{class:["zx-aspect",s.class??""],style:{"--zx-aspect-ratio":String(s.ratio??"16 / 9"),"--zx-aspect-fit":ty.has(s.fit)?s.fit:"cover"}},t)}var ju=new Set(["start","center","end","stretch","baseline"]),Zb=new Set(["start","center","end","between","around"]),ty=new Set(["cover","contain","fill"]);function Hu(s,t){if(t==null||t==="")return{};let e=Number(t);return Number.isInteger(e)&&e>=1&&e<=8?{[s]:`var(--zx-space-${e})`}:{[s]:String(t)}}function ey(s){return typeof s=="number"?`${s}px`:String(s)}function qu(s,t={}){let e=P(s);if(!e)throw new TypeError("truncate() target could not be resolved");let i=q(Math.trunc(Number(t.lines)||1),1,10),n=t.title!==!1,r=e.classList.contains("zx-truncate"),o=e.getAttribute("title"),a=!1,c=null;e.classList.add("zx-truncate"),i>1&&(e.dataset.lines=String(i),e.style.setProperty("--zx-truncate-lines",String(i)));let d=()=>(a=Ba(e),n&&(a?e.setAttribute("title",e.textContent?.trim()??""):o===null?e.removeAttribute("title"):e.setAttribute("title",o)),a);return d(),typeof ResizeObserver=="function"&&(c=new ResizeObserver(d),c.observe(e)),{update:d,isTruncated:()=>a,destroy:()=>{c?.disconnect(),c=null,r||e.classList.remove("zx-truncate"),delete e.dataset.lines,e.style.removeProperty("--zx-truncate-lines"),n&&(o===null?e.removeAttribute("title"):e.setAttribute("title",o))}}}function Ba(s){return s.scrollWidth-s.clientWidth>1||s.scrollHeight-s.clientHeight>1}var iy=Object.freeze({text:"",label:"",title:"Copy",feedback:"Copied",feedbackDuration:2e3,size:"md",kind:"ghost"});function Dn(s={}){let t={...iy,...s},e=!t.label,i=l("button",{class:["zx-copy-button",e?"zx-icon-btn":"zx-btn"],type:"button",dataset:{size:t.size==="sm"?"sm":"md",kind:e?null:t.kind},title:e?String(t.title):null,ariaLabel:e?String(t.title):null}),n=l("span",{class:"zx-copy-button__icon",ariaHidden:"true"},b("copy",{size:t.size==="sm"?12:14})),r=l("span",{class:"zx-copy-button__status",role:"status"});i.append(n),e||i.append(l("span",{class:"zx-copy-button__label"},String(t.label))),i.append(r);let o=0;return i.addEventListener("click",async()=>{let a=typeof t.text=="function"?String(t.text()):String(t.text??""),c=await Sn(a);t.oncopy?.(a,c),c&&(clearTimeout(o),i.dataset.copied="true",n.replaceChildren(b("check",{size:t.size==="sm"?12:14})),r.textContent=String(t.feedback),o=setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,n.replaceChildren(b("copy",{size:t.size==="sm"?12:14})),r.textContent="")},Math.max(0,Number(t.feedbackDuration)||0)))}),i}var Nn=class extends y{static cssName="copy-input";static defaults={value:"",label:"",hideLabel:!1,feedback:"Copied",buttonTitle:"Copy",size:"md"};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t;let e=x("zx-copy-input"),i=l("input",{ref:"input",class:"zx-copy-input__field",type:"text",id:e,readOnly:!0,value:String(this.options.value??"")}),n=Dn({text:()=>this.get(),title:String(this.options.buttonTitle),feedback:String(this.options.feedback),size:this.options.size==="sm"?"sm":"md",oncopy:(r,o)=>this.emit("copy",{value:r,copied:o})});return t.replaceChildren(l("label",{ref:"label",class:"zx-copy-input__label",for:e},String(this.options.label??"")),l("div",{class:"zx-copy-input__box"},i,n)),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(i,"focus",()=>i.select()),t}get(){return this.refs.input.value}set(t){return this.refs.input.value=String(t??""),this}focus(){return this.refs.input.focus(),this.refs.input.select(),this}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};var Lt=['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]'].join(",");function cs(s){return!!(s&&s!=="-"&&typeof s=="object"&&!["heading","separator","choice"].includes(String(s.type??"")))}function sy(s){return["menuitemcheckbox","menuitemradio"].includes(String(s.role))?s.role:"menuitem"}function On(s,t,{choices:e=!1}={}){let i=[];return s.forEach((n,r)=>{if(n==="-"||n&&typeof n=="object"&&n.type==="separator"){i.push(l("div",{class:`zx-${t}__separator`,role:"separator"}));return}if(n&&typeof n=="object"&&n.type==="heading"){i.push(l("div",{class:`zx-${t}__heading`,role:"presentation"},String(n.label??"")));return}if(n&&typeof n=="object"&&n.type==="choice"){e&&i.push(ny(n,r,t));return}if(!cs(n))return;let o=sy(n),a=V(n.href),c=n.target==null?null:String(n.target),d=n.rel==null?c==="_blank"?"noopener noreferrer":null:String(n.rel),u=[],h=[];o!=="menuitem"&&h.push(l("span",{class:`zx-${t}__check`,"data-check-kind":o==="menuitemradio"?"radio":"checkbox"})),n.icon&&h.push(b(n.icon)),u.push(l("span",{class:`zx-${t}__leading`,ariaHidden:"true"},h)),u.push(l("span",{class:`zx-${t}__body`},l("span",{class:`zx-${t}__label`},String(n.label??"")),n.description==null||n.description===""?null:l("span",{class:`zx-${t}__description`},String(n.description))));let f=[];if(n.badge!=null&&f.push(l("span",{class:`zx-${t}__badge`},String(n.badge))),n.shortcut&&f.push(l("kbd",{class:`zx-${t}__shortcut`},String(n.shortcut))),n.adornment!=null){let _=n.adornment&&typeof n.adornment=="object"&&"nodeType"in n.adornment?n.adornment:String(n.adornment);f.push(l("span",{class:`zx-${t}__adornment`},_))}f.length&&u.push(l("span",{class:`zx-${t}__meta`},f));let p={class:`zx-${t}__item`,role:o,tabindex:"-1","data-menu-item":String(r),"data-danger":n.danger?"true":null,ariaDisabled:n.disabled?"true":null,ariaChecked:o==="menuitem"?null:String(!!n.checked)};a?i.push(l("a",{...p,href:a,target:c,rel:d},u)):i.push(l("button",{...p,type:"button"},u))}),i}function ny(s,t,e){let i=x(`zx-${e}-choice`),n=Array.isArray(s.options)?s.options:[];return l("div",{class:`zx-${e}__choice`,role:"group",ariaLabelledby:i},l("span",{class:`zx-${e}__choice-label`,id:i},String(s.label??"")),l("span",{class:`zx-${e}__choice-options`},n.map((r,o)=>{let a=typeof r.glyph=="function"?r.glyph():r.glyph;return l("button",{class:`zx-${e}__choice-option`,type:"button",role:"menuitemradio",tabindex:"-1",title:String(r.label??""),ariaLabel:String(r.label??""),ariaChecked:String(Object.is(r.value,s.value)),ariaDisabled:r.disabled?"true":null,"data-menu-item":String(t),"data-menu-option":String(o)},a&&typeof a=="object"&&"nodeType"in a?a:r.icon?b(r.icon):String(r.label??""))})))}var ry=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe",'[contenteditable="true"]',"[tabindex]"].map(s=>`${s}:not([tabindex^="-"])`).join(","),pt=class extends y{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1,scope:null};#t;#e=null;#i=new Map;#s=null;#r=null;#n=!0;#o=!1;constructor(t,e={}){let i=P(t);if(!i)throw new TypeError("Dropdown anchor could not be resolved");super(null,e),this.#t=i,oe(this.options.scope??i,{dialog:!1})?.append(this.el),this.#f("aria-expanded"),this.#f("aria-controls"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#t,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()}),this.listen(this.#t,"keydown",n=>this.#l(n)),this.listen(this.el,"keydown",n=>this.#d(n))}render(){let t=l("div",{id:x("zx-dropdown"),popover:"manual"});return t.dataset.state="closed",t}open(){if(this.isOpen()||this.#o)return this;let t=this.#a();return this.el.parentElement!==t&&t.append(this.el),this.#e=nt(this.#t,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.#s=le({kind:"popup",root:this.el,owner:this,anchor:[this.#t,P(this.options.scope)],inside:[this.#t],onEscape:e=>this.#c(e),onOutsidePointer:()=>this.close(),onParentClose:()=>this.close()}),this.el.dataset.zxOverlayOrder=String(this.#s.order),this.#t.setAttribute("aria-expanded","true"),this.emit("open"),this}close(){if(!this.isOpen())return this;let t=this.el.contains(document.activeElement);this.#e?.destroy(),this.#e=null,this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let e=this.#s;return this.#s=null,this.#t.setAttribute("aria-expanded","false"),t&&this.#n&&this.#t instanceof HTMLElement&&this.#t.focus(),di(this.el.parentElement)&&this.el.parentElement?.isConnected&&vt(this.options.scope??this.#t).append(this.el),e?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return oy(this.el,t),this.#e?.update(),this}getPanel(){return this.el}destroy(){if(!this.#o){this.#o=!0,this.close();for(let[t,e]of this.#i)cy(this.#t,t,e);super.destroy()}}_configure(t){return"onEscape"in t&&(this.#r=t.onEscape??null),"tabReach"in t&&(this.#n=!!t.tabReach),this}#a(){return di(this.#t)??di(P(this.options.scope))??ns(this.options.scope??this.#t)}#c(t){if(this.#r){this.#r(t);return}let e=this.el.contains(document.activeElement);this.close(),e&&this.#t instanceof HTMLElement&&this.#t.focus()}#l(t){if(t.key!=="Tab"||t.shiftKey||t.defaultPrevented||!this.#n||!this.isOpen())return;let e=Va(this.el)[0]??(this.el.hasAttribute("tabindex")?this.el:null);e instanceof HTMLElement&&(t.preventDefault(),e.focus())}#d(t){if(t.key!=="Tab"||t.defaultPrevented||!this.#n||!this.isOpen())return;let e=Va(this.el),i=document.activeElement;if((i&&i!==this.el?e.filter(o=>!o.contains(i)&&(t.shiftKey?!!(i.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING):!!(i.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)&&!i.contains(o))):t.shiftKey?[]:e).length>0)return;if(t.shiftKey){if(!(this.#t instanceof HTMLElement))return;t.preventDefault(),this.#t.focus();return}let r=ay(this.#t,this.el);r&&(t.preventDefault(),r.focus())}#f(t){this.#i.set(t,this.#t.getAttribute(t))}};function oy(s,t){if(s.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}function Va(s){return Array.from(s.querySelectorAll(ry)).filter(t=>ly(t))}function ay(s,t){let e=di(s)??s.ownerDocument.body??s.ownerDocument.documentElement,i=Va(e).filter(o=>!t.contains(o)),n=i.findIndex(o=>o===s||s.contains(o));if(n<0)return null;let r=n+1;for(;r<i.length&&s.contains(i[r]);)r+=1;return i[r]??null}function ly(s){let t=s;if(typeof t.focus!="function"||t.tabIndex<0||t.disabled||s.closest('[inert], [hidden], [aria-hidden="true"], fieldset[disabled]'))return!1;if(t instanceof HTMLInputElement&&t.type==="radio"&&t.name&&!t.checked){let e=t.form??t.getRootNode(),i=Array.from(e.querySelectorAll?.('input[type="radio"]')??[]).filter(n=>n.name===t.name&&(n.form??n.getRootNode())===e);if(i.some(n=>n.checked)||i[0]!==t)return!1}return typeof t.checkVisibility=="function"?t.checkVisibility({visibilityProperty:!0}):t.getClientRects().length>0}function cy(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var at=class extends y{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#i;#s;#r=[];#n=null;#o=!0;#a=!1;#c=!1;constructor(t=null,e={}){let i=t===null?null:P(t);if(t!==null&&(!i||i.tagName!=="BUTTON"))throw new TypeError("MenuButton target must resolve to a button");let n=i?{attributes:Array.from(i.attributes,o=>[o.name,o.value]),children:Array.from(i.childNodes)}:null,r=Object.hasOwn(e,"label");super(t,e),this.#a=i===null,this.#n=n,this.el.classList.add("zx-btn"),this.el.setAttribute("type","button"),this.el.setAttribute("data-kind",String(this.options.kind)),this.el.setAttribute("data-size","md"),this.#t=new pt(this.el,{openOn:"manual",placement:this.options.placement,content:null}),this.#e=this.#t.getPanel(),this.#t._configure({onEscape:()=>this.#f(),tabReach:!1}),this.#e.classList.add("zx-menu-button__menu"),this.#e.setAttribute("role","menu"),this.el.id||(this.el.id=x("zx-menu-button")),this.#e.setAttribute("aria-labelledby",this.el.id),this.el.setAttribute("aria-haspopup","menu"),i&&r&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#i=Mt(this.#e,Lt),this.#s=ut(()=>this.#g(),o=>o.focus()),this.#t.on("open",()=>this.emit("open")),this.#t.on("close",()=>{this.#o=!0,this.emit("close")}),this.listen(this.el,"click",()=>{this.isOpen()?this.close():(this.open(),this.#h())}),this.listen(this.el,"keydown",o=>this.#l(o)),this.listen(this.#e,"click",o=>{let a=o.target.closest?.(Lt);a&&this.#e.contains(a)&&this.#_(a,o)}),this.listen(this.#e,"keydown",o=>this.#d(o)),this.listen(this.#e,"keydown",o=>this.#u(o),{capture:!0})}render(){return this.el?this.el:l("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},$u(this.options.label,this.options.icon))}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(...On(this.#r,"menu-button",{choices:!0})),this}open(t={}){return this.isOpen()||(this.#o=t?.returnFocus??!0),this.#t.open(),this}close(){return this.#t.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#t.isOpen()}getTrigger(){return this.el}getPanel(){return this.#e}focusFirst(t={}){return this.open(t),this.#h(),this}focusLast(t={}){return this.open(t),this.#i.focusLast(),this}setLabel(t){return this.el.replaceChildren(...$u(t,this.options.icon)),this}destroy(){if(!this.#c&&(this.#c=!0,this.#i.destroy(),this.#t.destroy(),super.destroy(),!this.#a&&this.#n)){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,e]of this.#n.attributes)this.el.setAttribute(t,e);this.el.replaceChildren(...this.#n.children)}}#l(t){["ArrowDown","ArrowUp","Enter"," "].includes(t.key)&&(t.preventDefault(),this.open(),t.key==="ArrowUp"?this.#i.focusLast():this.#h())}#d(t){if(t.key==="Tab"){this.close();return}if(t.key==="Enter"||t.key===" "){let e=t.target.closest?.(Lt);if(!e||!this.#e.contains(e)||t.key==="Enter"&&e.tagName==="A")return;t.preventDefault(),e.click();return}this.#s(t)}#f(){let t=document.activeElement,e=!t||t===document.body||this.#e.contains(t),i=this.#m();this.close(),e&&i?.focus()}#h(){this.#i.focusFirst();let t=this.#g()[0],e=t?.hasAttribute("data-menu-option")?t.parentElement?.querySelector('[aria-checked="true"]'):null;e instanceof HTMLElement&&e.focus()}#u(t){let e=t.target?.closest?.("[data-menu-option]");if(!(e instanceof HTMLElement)||!this.#e.contains(e)){if(t.key!=="ArrowDown"&&t.key!=="ArrowUp")return;let c=this.#g(),d=c.indexOf(t.target);if(d<0)return;let u=c[(d+(t.key==="ArrowDown"?1:-1)+c.length)%c.length],h=u?.hasAttribute("data-menu-option")?u.parentElement:null;if(!h)return;t.preventDefault(),t.stopPropagation(),(h.querySelector('[aria-checked="true"]')??u).focus();return}let i=[...e.parentElement?.children??[]],n=this.#g(),r=null;if(t.key==="ArrowLeft")r=i[(i.indexOf(e)-1+i.length)%i.length];else if(t.key==="ArrowRight")r=i[(i.indexOf(e)+1)%i.length];else if(t.key==="ArrowDown")r=n[(n.indexOf(i.at(-1))+1)%n.length];else if(t.key==="ArrowUp")r=n[(n.indexOf(i[0])-1+n.length)%n.length];else return;t.preventDefault(),t.stopPropagation();let o=r?.closest('[role="group"]')?.querySelector('[data-menu-option][aria-checked="true"]');(t.key==="ArrowDown"||t.key==="ArrowUp"?o??r:r)?.focus()}#p(t,e,i){let n=e.options?.[Number(t.getAttribute("data-menu-option"))];if(!n||n.disabled){i?.preventDefault();return}for(let r of t.parentElement?.children??[])r.setAttribute("aria-checked",String(r===t));t.focus(),e.onselect?.(n.value,e,this),!this.isOpen()&&(t.contains(document.activeElement)||document.activeElement===document.body)&&this.#m()?.focus()}#_(t,e=null){let i=Number(t.getAttribute("data-menu-item")),n=this.#r[i];if(n&&typeof n=="object"&&n.type==="choice"){this.#p(t,n,e);return}if(!cs(n)||n.disabled){e?.preventDefault();return}let r=this.#m(),o=document.activeElement,a=!!r&&(!o||o===document.body||this.#e.contains(o));if(a&&r?.focus(),this.emit("select",{value:n.value,item:n}).defaultPrevented){e?.preventDefault(),a&&document.activeElement===r&&t instanceof HTMLElement&&t.focus();return}try{n.onselect?.(n.value,n,this)}finally{this.close()}}#m(){let t=this.#o;return t===!1?null:t instanceof HTMLElement&&t.isConnected?t:this.el}#g(){return Array.from(this.#e.querySelectorAll(Lt))}};function $u(s,t){let e=[];return t&&e.push(l("span",{class:"zx-btn__icon"},b(t))),e.push(l("span",{class:"zx-btn__label"},String(s??""))),e}var dy=["button","a[href]","input","select","textarea","[tabindex]"],uy=dy.flatMap(s=>[`.zx-toolbar > ${s}`,`.zx-toolbar > [role="group"] > ${s}`]).join(","),Fn=class extends y{static cssName="toolbar";static defaults={items:[],align:"start",label:"Toolbar",overflow:!0,overflowLabel:"More",dense:!1};#t;#e=null;#i=null;#s=!1;#r=-1;#n=-1;#o=0;#a=!1;constructor(t=null,e={}){if(super(t,e),this.options.overflow){this.#e=new at(null,{icon:"dots",label:"",kind:"ghost",placement:"bottom-end"});let i=this.#e.toElement();i.classList.add("zx-toolbar__overflow"),i.setAttribute("aria-label",String(this.options.overflowLabel)),i.setAttribute("title",String(this.options.overflowLabel)),this.options.dense&&i.setAttribute("data-size","sm"),i.hidden=!0}this.#t=Mt(this.el,uy,{orientation:"horizontal"}),this.listen(this.el,"click",i=>this.#l(i)),this.setItems(this._initialItems),this.#e&&typeof ResizeObserver=="function"&&(this.#i=new ResizeObserver(()=>this.#f()),this.#i.observe(this.el))}render(){this._records=[],this._named=new Map,this._createdRoot=!this.el;let t=this.el??l("div");this.el=t,this._snapshot=this._createdRoot?null:A(t);let e=this.options.items;return this._initialItems=Array.isArray(e)&&e.length===0?Array.from(t.children):e,t.setAttribute("role","toolbar"),t.setAttribute("aria-label",String(this.options.label)),t.dataset.align=fy(this.options.align),t.dataset.overflow=this.options.overflow?"true":"false",this.options.dense&&(t.dataset.dense="true"),t}setItems(t){for(let i of this._records)i.type==="element"&&(i.element.hidden=i.userHidden);this._records=hy(t).map(i=>this.#c(i)),this._named=new Map;for(let i of this._records)i.name!==null&&!this._named.has(i.name)&&this._named.set(i.name,i);let e=this._records.map(i=>i.element);if(this.#e){this.#e.setItems([]);let i=this.#e.toElement();i.hidden=!0,e.push(i)}return this.el.replaceChildren(...e),this.#r=-1,this.#n=-1,this.#h(),this}getItem(t){return this._named.get(String(t))?.element??null}enable(t){return this.#d(t,!1)}disable(t){return this.#d(t,!0)}setActive(t,e=!0){let i=this._named.get(String(t));return i&&i.element.setAttribute("aria-pressed",e?"true":"false"),this}destroy(){if(!this.#a){this.#a=!0,this.#i?.disconnect(),this.#i=null,this.#o!==0&&cancelAnimationFrame(this.#o),this.#o=0,this.#t.destroy(),this.#e?.destroy(),this.#e=null;for(let t of this._records)t.type==="element"&&(t.element.hidden=t.userHidden);super.destroy(),this._createdRoot||S(this.el,this._snapshot)}}#c(t){if(t.type==="separator")return{type:"separator",element:l("span",{class:"zx-toolbar__separator",role:"separator",ariaOrientation:"vertical",dataset:{separator:"true"}}),name:null,label:"",icon:null,onclick:null,userHidden:!1};if(t.type==="element"){let a=t.element;return{type:"element",element:a,name:a.dataset?.name??null,label:Uu(a),icon:null,onclick:null,userHidden:!!a.hidden}}let{name:e=null,active:i,onclick:n,...r}=t.descriptor,o=j({size:this.options.dense?"sm":"md",...r});return i!==void 0&&o.setAttribute("aria-pressed",i?"true":"false"),e!==null&&(o.dataset.name=String(e)),{type:"descriptor",element:o,name:e===null?null:String(e),label:String(r.label??r.title??""),icon:r.icon??null,onclick:typeof n=="function"?n:null,userHidden:!1}}#l(t){let e=t.target;if(!e)return;let i=this._records.find(n=>n.type==="descriptor"&&n.element.contains(e));i&&(this.emit("action",{name:i.name,item:i.element}),i.onclick?.(t))}#d(t,e){let i=this._named.get(String(t));if(!i)return this;let n=i.element;return"disabled"in n?n.disabled=e:e?n.setAttribute("aria-disabled","true"):n.removeAttribute("aria-disabled"),this.#u(),this}#f(){if(!(this.#o!==0||this.#a)){if(typeof requestAnimationFrame!="function"){this.#h();return}this.#o=requestAnimationFrame(()=>{this.#o=0,this.#h()})}}#h(){if(this.#s||this.#a||!this.#e)return;let t=this.el;if(typeof getComputedStyle!="function"||!t.isConnected)return;let e=getComputedStyle(t),i=parseFloat(e.columnGap)||0,n=(parseFloat(e.paddingInlineStart)||0)+(parseFloat(e.paddingInlineEnd)||0),r=t.clientWidth-n,o=t.clientHeight;if(!(!(r>0)||r===this.#r&&o===this.#n)){this.#s=!0;try{let a=this.#e.toElement(),c=this._records.filter(_=>!_.userHidden);for(let _ of c)_.element.hidden=!1;a.hidden=!1;let d=c.map(_=>_.element.getBoundingClientRect().width),u=d.reduce((_,m)=>_+m,0)+i*Math.max(0,d.length-1),h=a.getBoundingClientRect().width,f=[];if(u>r){let _=r-h-i,m=0,g=!1;for(c.forEach((w,v)=>{let z=m+d[v]+(m>0?i:0);if(!g&&z<=_){m=z;return}g=!0,w.element.hidden=!0,f.push(w)});c.length>f.length;){let w=c[c.length-f.length-1];if(w.type!=="separator")break;w.element.hidden=!0,f.unshift(w)}}let p=Ku(f);this.#e.setItems(p),a.hidden=p.length===0,this.#r=r,this.#n=t.clientHeight}finally{this.#s=!1}}}#u(){if(!this.#e)return;let t=this._records.filter(e=>!e.userHidden&&e.element.hidden);this.#e.setItems(Ku(t))}};function hy(s){if(s!=null&&!Array.isArray(s))throw new TypeError("Toolbar items must be an array");let t=[];for(let e of s??[])if(e!=null){if(e==="-"){t.length>0&&t[t.length-1].type!=="separator"&&t.push({type:"separator"});continue}if(E(e)){t.push({type:"element",element:e});continue}if(typeof e!="object"||Array.isArray(e))throw new TypeError('Toolbar items must be Elements, item descriptors, or "-"');t.push({type:"descriptor",descriptor:{...e}})}for(;t.length>0&&t[t.length-1].type==="separator";)t.pop();return t}function Ku(s){let t=[];for(let e of s){if(e.type==="separator"){t.length>0&&t[t.length-1]!=="-"&&t.push("-");continue}let i=e.element;t.push({label:e.label||Uu(i)||"\u2026",icon:e.icon??void 0,value:e.name,disabled:!!i.disabled||i.getAttribute("aria-disabled")==="true",onselect:()=>i.click()})}for(;t.length>0&&t[t.length-1]==="-";)t.pop();return t}function Uu(s){return(s.getAttribute("aria-label")??s.getAttribute("title")??s.textContent??"").trim()}function fy(s){return["end","between"].includes(s)?s:"start"}var Ln=class extends y{static cssName="card";static defaults={title:"",media:null,content:null,actions:[],footer:null,link:null,variant:"outlined",orientation:"vertical",headingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("article");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._title="",this._link=null,this._actionAbort=null,this._linkAbort=null;let i=t?[]:Array.from(e.childNodes);try{let n=gy(this.options.headingLevel),r=x("zx-card-heading"),o=l(`h${n}`,{ref:"heading",class:"zx-card__heading",id:r}),a=l("div",{ref:"media",class:"zx-card__media",hidden:!0}),c=l("div",{ref:"actions",class:"zx-card__actions",role:"group",ariaLabel:this._message("card.actions","Card actions"),hidden:!0}),d=l("div",{ref:"content",class:"zx-card__content",hidden:!0}),u=l("footer",{ref:"footer",class:"zx-card__footer",hidden:!0}),h=l("header",{ref:"header",class:"zx-card__header"},o,c);return e.replaceChildren(l("div",{class:"zx-card__layout"},a,l("div",{class:"zx-card__inner"},h,d,u))),e.dataset.variant=_y(this.options.variant),e.dataset.orientation=my(this.options.orientation),this.setTitle(this.options.title),this.setMedia(this.options.media),this.options.content!==null?this.setContent(this.options.content):i.length&&(d.replaceChildren(...i),d.hidden=!1),this.setActions(this.options.actions),this.setFooter(this.options.footer),this.setLink(this.options.link),e}catch(n){throw this._actionAbort?.abort(),this._linkAbort?.abort(),t||S(e,this._original),n}}setTitle(t){let e=String(t??"");if(this._link&&!e.trim())throw new TypeError("A linked Card requires a non-empty title");return this._title=e,this._renderHeading(),this}setMedia(t){return ja(this.refs.media,t,"Card media"),this.refs.media.hidden=t===null,this}setContent(t){return ja(this.refs.content,t,"Card content"),this.refs.content.hidden=t===null,this}setActions(t){if(!Array.isArray(t))throw new TypeError("Card actions must be an array");let e=new AbortController,i;try{i=t.map(n=>{if(E(n))return n;if(!n||typeof n!="object"||Array.isArray(n))throw new TypeError("Card actions must be Elements or button descriptors");let r={...n},o=r.onclick;delete r.onclick;let a=j(r);if(o!==void 0&&typeof o!="function")throw new TypeError("Card action onclick must be a function");return o&&a.addEventListener("click",o,{signal:e.signal}),a})}catch(n){throw e.abort(),n}return this._actionAbort?.abort(),this._actionAbort=e,this.refs.actions.replaceChildren(...i),this.refs.actions.hidden=i.length===0,this._syncHeader(),this}setFooter(t){return ja(this.refs.footer,t,"Card footer"),this.refs.footer.hidden=t===null,this}setLink(t){let e=py(t);if(e&&!this._title.trim())throw new TypeError("A linked Card requires a non-empty title");return this._link=e,this.el.dataset.linked=e?"true":"false",this._renderHeading(),this}destroy(){this._cleaned||(this._cleaned=!0,this._actionAbort?.abort(),this._linkAbort?.abort(),super.destroy(),this._createdRoot||S(this.el,this._original))}_renderHeading(){let t=this._title,e=new AbortController,i=this._link?l("a",{class:"zx-card__primary",href:this._link.href,target:this._link.target,rel:this._link.rel},t):l("span",{class:"zx-card__title"},t);this._link?.onclick&&i.addEventListener("click",this._link.onclick,{signal:e.signal}),this._linkAbort?.abort(),this._linkAbort=e,this.refs.heading.replaceChildren(i),this.refs.heading.hidden=t==="",t?this.el.setAttribute("aria-labelledby",this.refs.heading.id):this.el.removeAttribute("aria-labelledby"),this._syncHeader()}_syncHeader(){this.refs.header&&(this.refs.header.hidden=this._title===""&&this.refs.actions.childElementCount===0)}_message(t,e){let i=this.msg(t);return i===t?e:i}};function ja(s,t,e){if(t===null){s.replaceChildren();return}if(typeof t=="string"){s.textContent=t;return}let i=t instanceof y?t.toElement():t;if(i instanceof Node){s.replaceChildren(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function py(s){if(s===null)return null;let t=typeof s=="string"?{href:s}:s;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Card link must be a URL string, descriptor, or null");let e=V(t.href);if(e===null)throw new TypeError("Card link requires a safe non-empty href");if(t.onclick!==void 0&&typeof t.onclick!="function")throw new TypeError("Card link onclick must be a function");let i=t.target==null?void 0:String(t.target),n=t.rel==null?"":String(t.rel).trim();return i==="_blank"&&!/(^|\s)noopener(\s|$)/i.test(n)&&(n=`${n} noopener`.trim()),{href:e,target:i,rel:n||void 0,onclick:t.onclick}}function _y(s){return["raised","filled"].includes(String(s))?s:"outlined"}function my(s){return s==="horizontal"?"horizontal":"vertical"}function gy(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}var by=Object.freeze(["neutral","accent","success","warning","danger","info"]),yy=Object.freeze(["positive","negative","neutral"]),wy=Object.freeze({"statTile.up":"up %1","statTile.down":"down %1","statTile.unchanged":"no change","statTile.loading":"Loading"}),vy=Object.freeze({up:"chevron-up",down:"chevron-down",flat:"minus"}),Ju=100,$a=30,xy=2,Sy=Object.freeze({label:"",value:null,format:"number",currency:null,caption:"",delta:null,deltaKind:"neutral",deltaLabel:"",trend:[],icon:null,kind:"neutral",href:null,clickable:!1,loading:!1}),Yu="http://www.w3.org/2000/svg",ds=class extends y{static cssName="stat-tile";static defaults=Sy;constructor(t=null,e={}){super(t,{...e,clickable:e?.clickable===!0||typeof e?.onclick=="function"})}render(){let t=Ha(this.options);if(this._createdRoot=this.el===null,!this._createdRoot&&this.el.tagName.toLowerCase()!==t)throw new TypeError(`StatTile needs a <${t}> for these options, but the target is a <${this.el.tagName.toLowerCase()}>. Pass null as the target to let it build its own.`);let e=this.el??l(t);return this.el=e,this._snapshot=this._createdRoot?null:A(e),this._closed=!1,this._state={...this.options},t==="button"&&(e.type="button"),Wu(e,this._state,(i,...n)=>this._message(i,...n)),t!=="div"&&this.listen(e,"click",i=>{this.emit("click",{event:i})}),e}update(t={}){let e={...this._state,...t},i=this.el.tagName.toLowerCase();if(Ha(e)!==i)throw new TypeError(`StatTile cannot change from <${i}> to <${Ha(e)}> in place: href and clickable decide the element, and an element's tag is fixed once it exists.`);return this._state=e,Wu(this.el,e,(n,...r)=>this._message(n,...r)),this}getAccessibleName(){return this.el.getAttribute("aria-label")??""}destroy(){if(this._closed)return;this._closed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_message(t,...e){let i=this.msg(t,...e);return i===t?T(wy[t]??t,e):i}};function Zu(s={}){return new ds(null,s)}function th(s,t={}){let{format:e="number",locale:i,currency:n=null}=t;if(typeof e=="function")return ze(e(s));if(typeof s=="string")return s;if(s==null)return"";switch(e){case"currency":return oi(s,n,{locale:i});case"percent":return ai(s,{locale:i});case"fileSize":return li(s,{locale:i});case"number":return Nt(s,{locale:i});default:return ze(s)}}function Ay(s,t={}){let e=sh(s);if(e===null)return null;let i=e>0?"up":e<0?"down":"flat",n=i==="up"?"+":i==="down"?"\u2212":"",r=th(Math.abs(e),t);return{direction:i,sign:n,magnitude:r,text:`${n}${r}`}}function Ha(s={}){return V(s.href)?"a":s.clickable===!0||typeof s.onclick=="function"?"button":"div"}function Gu(s={}){let t=[s.value,s.caption].map(qa).filter(Boolean).join(" "),e=[s.delta,s.deltaLabel].map(qa).filter(Boolean).join(" ");return[qa(s.label),t,e].filter(Boolean).join(", ")}function eh(s,t={}){let{width:e=Ju,height:i=$a,inset:n=xy}=t,r=(Array.isArray(s)?s:[]).map(sh).filter(f=>f!==null);if(r.length<2)return null;let o=Math.min(...r),a=Math.max(...r),c=n,d=Math.max(n,i-n),u=a-o,h=e/(r.length-1);return r.map((f,p)=>{let _=p===r.length-1?e:p*h,m=u===0?(c+d)/2:d-(f-o)/u*(d-c);return`${Xu(_)},${Xu(m)}`}).join(" ")}function Wu(s,t,e){let i=ih(t.kind,by,"neutral"),n=ze(t.label),r=t.loading===!0;if(s.classList.add("zx-stat-tile"),s.dataset.kind=i,s.dataset.loading=String(r),s.tagName.toLowerCase()==="a"){let _=V(t.href);_?s.setAttribute("href",_):s.removeAttribute("href")}if(r){s.setAttribute("aria-busy","true"),Qu(s,Gu({label:n,value:e("statTile.loading")})),s.replaceChildren(Cy(t));return}s.removeAttribute("aria-busy");let o=th(t.value,t),a=Ay(t.delta,{format:t.deltaFormat??t.format,locale:t.locale,currency:t.currency}),c=ze(t.deltaLabel),d=ze(t.caption).trim();Qu(s,Gu({label:n,value:o,caption:d,delta:a===null?"":Iy(a,e),deltaLabel:c}));let u=l("div",{class:"zx-stat-tile__header"},l("span",{class:"zx-stat-tile__label"},n)),h=Ty(t.icon);h&&u.append(l("span",{class:"zx-stat-tile__icon"},h));let f=[u,l("div",{class:"zx-stat-tile__value"},o)];d&&f.push(l("div",{class:"zx-stat-tile__caption"},d)),a!==null&&f.push(ky(a,c,t.deltaKind));let p=zy(t.trend);p&&f.push(p),s.replaceChildren(...f)}function ky(s,t,e){let i=l("div",{class:"zx-stat-tile__delta",ariaHidden:"true",dataset:{kind:ih(e,yy,"neutral"),direction:s.direction}},b(vy[s.direction],{size:12}),l("span",{class:"zx-stat-tile__delta-value"},s.text));return t&&i.append(l("span",{class:"zx-stat-tile__delta-label"},t)),i}function zy(s){let t=eh(s);if(t===null)return null;let e=document.createElementNS(Yu,"svg");e.setAttribute("class","zx-stat-tile__trend"),e.setAttribute("viewBox",`0 0 ${Ju} ${$a}`),e.setAttribute("preserveAspectRatio","none"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");let i=document.createElementNS(Yu,"polyline");return i.setAttribute("points",t),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("vector-effect","non-scaling-stroke"),e.append(i),e}function Cy(s){let t=[l("div",{class:"zx-stat-tile__header"},ot({width:"55%",height:"0.75rem"})),ot({width:"70%",height:"1.75rem",radius:"md"})];return ze(s.caption).trim()&&t.push(ot({width:"35%",height:"0.75rem"})),s.delta!==null&&s.delta!==void 0&&t.push(ot({width:"40%",height:"0.75rem"})),eh(s.trend)!==null&&t.push(ot({width:"100%",height:`${$a}px`,radius:"md"})),l("div",{class:"zx-stat-tile__loading"},...t)}function Ty(s){return s?b(String(s),{size:16}):null}function Iy(s,t){return s.direction==="flat"?t("statTile.unchanged"):t(s.direction==="up"?"statTile.up":"statTile.down",s.magnitude)}function Qu(s,t){let e=s.tagName.toLowerCase()==="div";if(t){s.setAttribute("aria-label",t),e&&s.setAttribute("role","group");return}s.removeAttribute("aria-label"),e&&s.removeAttribute("role")}function ih(s,t,e){return t.includes(s)?s:e}function sh(s){if(typeof s=="number")return Number.isFinite(s)?s:null;if(typeof s!="string")return null;let t=s.trim();if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function ze(s){return s==null?"":String(s)}function qa(s){return ze(s).trim()}function Xu(s){return Math.round(q(s,-1e6,1e6)*100)/100}var Ey=Object.freeze(["source","confluence","horizon","diagonal","edge","curtain"]),My=Object.freeze(["subtle","balanced","vivid"]),Rn=Object.freeze(["--zx-aurora-color-1","--zx-aurora-color-2","--zx-aurora-color-3","--zx-aurora-color-4"]),Pn=class extends y{static cssName="aurora";static defaults={preset:"source",colors:[],intensity:"subtle"};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("div");return this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._initialColors=Rn.map(i=>({property:i,value:e.style.getPropertyValue(i),priority:e.style.getPropertyPriority(i)})),this._colors=[],this.setPreset(this.options.preset),this.setIntensity(this.options.intensity),this.setColors(this.options.colors),e}setPreset(t){return this.el.dataset.preset=Dy(t),this}setColors(t){let e=Oy(t),i=Fy(e);if(this._colors=[...e],this.el.dataset.colors=e.length===0?"semantic":String(e.length),i.length===0){for(let n of this._initialColors)n.value?this.el.style.setProperty(n.property,n.value,n.priority):this.el.style.removeProperty(n.property);return this}for(let n=0;n<Rn.length;n+=1)this.el.style.setProperty(Rn[n],i[n]);return this}setIntensity(t){return this.el.dataset.intensity=Ny(t),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._createdRoot||S(this.el,this._original))}};function Dy(s){let t=String(s??"").trim().toLowerCase();if(!Ey.includes(t))throw new TypeError(`Unknown Aurora preset: ${s}`);return t}function Ny(s){let t=String(s??"").trim().toLowerCase();if(!My.includes(t))throw new TypeError(`Unknown Aurora intensity: ${s}`);return t}function Oy(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Aurora colors must be an array");if(s.length>Rn.length)throw new TypeError("Aurora accepts at most four colors");return s.map(t=>{if(!ee(t))throw new TypeError(`Invalid Aurora color: ${t}`);return t.trim()})}function Fy(s){return s.length===0?[]:s.length===1?[s[0],s[0],s[0],s[0]]:s.length===2?[s[0],s[1],s[0],s[1]]:s.length===3?[s[0],s[1],s[2],s[1]]:[...s]}var Bn=class extends y{static cssName="panel";static defaults={title:"",content:null,open:!0,collapsible:!0,buttons:[],footer:null,footerButtons:[]};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:Ly(e),this._cleaned=!1,this._open=!!this.options.open,this._collapsible=!!this.options.collapsible,this._hasFooterContent=!1;let i=t?[]:Array.from(e.childNodes),n=x("zx-panel-body"),r=l("span",{class:"zx-panel__title",ref:"title"}),o=[];this._collapsible&&o.push(l("span",{class:"zx-panel__chevron",ariaHidden:"true"},b("chevron-right",{size:16}))),o.push(r);let a=this._collapsible?l("button",{class:"zx-panel__toggle",ref:"toggle",type:"button",ariaControls:n,ariaExpanded:String(this._open)},o):l("div",{class:"zx-panel__toggle",ref:"toggle"},o),c=l("div",{class:"zx-panel__header",ref:"header"},a,l("div",{class:"zx-panel__buttons",ref:"buttons",role:"group",ariaLabel:this._message("panel.actions","Panel actions")})),d=l("div",{class:"zx-panel__content",ref:"content"}),u=l("div",{class:"zx-panel__body",ref:"body",id:n},d),h=l("div",{class:"zx-panel__footer",ref:"footer",hidden:!0},l("div",{class:"zx-panel__footer-content",ref:"footerContent"}),l("div",{class:"zx-panel__footer-buttons",ref:"footerButtons",role:"group",ariaLabel:this._message("panel.footerActions","Panel footer actions")}));return e.replaceChildren(c,u,h),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):d.append(...i),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),this.setFooterButtons(this.options.footerButtons),this._syncOpenState(),this._collapsible&&this.listen(a,"click",()=>this.toggle()),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return nh(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return nh(this.refs.footerContent,t,"Panel footer"),this._hasFooterContent=t!==null,this._syncFooter(),this}setFooterButtons(t){return this.refs.footerButtons.replaceChildren(...this._buildButtons(t,"Panel footer buttons")),this._syncFooter(),this}open(){return this._open?this:(this._open=!0,this._syncOpenState(),this.emit("open"),this)}close(){return this._open?(this._open=!1,this._syncOpenState(),this.emit("close"),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this._open}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Ry(this.el,this._original))}_syncOpenState(){this.el.setAttribute("data-state",this._open?"open":"closed"),this.refs.body.hidden=!this._open,this._collapsible&&this.refs.toggle.setAttribute("aria-expanded",String(this._open))}_syncFooter(){this.refs.footer.hidden=!this._hasFooterContent&&this.refs.footerButtons.childElementCount===0}_buildButtons(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);return t.map(i=>{if(E(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be Elements or button descriptors`);let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o})}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Ly(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Ry(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function nh(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof y?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Py=Object.freeze(["default","settings","accounts","billing","calendar","campaigns","clocking","collection","contacts","contracts","enhancements","inventory","links","mailinglists","messages","notes","opportunities","pricelists","procurement","projects","tasks","tickets","pwd","system","usermgmt","usersettings","users","groups"]),Vn=class extends y{static cssName="master-panel";static defaults={title:"",content:null,buttons:[],module:null,footer:null};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:By(e),this._cleaned=!1;let i=t?[]:Array.from(e.childNodes),n=l("header",{class:"zx-master-panel__header"},l("h1",{class:"zx-master-panel__title",ref:"title"}),l("div",{class:"zx-master-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),r=l("div",{class:"zx-master-panel__content",ref:"content"}),o=l("footer",{class:"zx-master-panel__footer",ref:"footer",hidden:!0});e.replaceChildren(n,r,o);let a=jy(this.options.module);return e.dataset.module=a,this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):r.append(...i),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return rh(this.refs.content,t,"MasterPanel content"),this}setButtons(t){if(!Array.isArray(t))throw new TypeError("MasterPanel buttons must be an array");let e=t.map(i=>{if(E(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("MasterPanel buttons must be Elements or button descriptors");let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.buttons.replaceChildren(...e),this}setFooter(t){return rh(this.refs.footer,t,"MasterPanel footer"),this.refs.footer.hidden=t===null,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Vy(this.el,this._original))}};function By(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Vy(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function rh(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof y?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function jy(s){let t=String(s??"default").toLowerCase();return Py.includes(t)?t:"default"}function wi(s,t){if(!s)throw new TypeError("dragAxis requires a handle element");if(typeof t?.onMove!="function")throw new TypeError("dragAxis requires an onMove callback");let e=t.orientation==="vertical",i=new AbortController,{signal:n}=i,r=!1,o=null,a=0,c=0,d=!1,u=0,h=w=>e?w.clientY:w.clientX,f=()=>!!t.disabled?.(),p=()=>{let w=o;if(o=null,w!==null)try{s.releasePointerCapture(w)}catch{}},_=()=>{u!==0&&(cancelAnimationFrame(u),u=0)},m=()=>{r=!1,d=!1,_(),p()};s.addEventListener("pointerdown",w=>{let v=w;if(!(f()||r||v.button!==0)&&t.onStart?.(v)!==!1){r=!0,o=v.pointerId,a=h(v),c=a,d=!1;try{s.setPointerCapture(v.pointerId)}catch{}}},{signal:n}),s.addEventListener("pointermove",w=>{let v=w;!r||v.pointerId!==o||(c=h(v),c!==a&&(d=!0),u===0&&(u=requestAnimationFrame(()=>{u=0,r&&t.onMove(c-a)})))},{signal:n});let g=w=>{let v=w;if(!r||v.pointerId!==o)return;_(),c=h(v);let z=d,C=c-a;m(),t.onEnd?.(C,z)};return s.addEventListener("pointerup",g,{signal:n}),s.addEventListener("pointercancel",g,{signal:n}),s.addEventListener("keydown",w=>{let v=w;if(f())return;if((v.key==="Enter"||v.key===" ")&&t.onActivate){v.preventDefault(),t.onActivate();return}if(v.key==="Home"||v.key==="End"){if(!t.onJump)return;v.preventDefault(),t.onJump(v.key==="Home"?"min":"max");return}let z=e?"ArrowUp":"ArrowLeft",C=e?"ArrowDown":"ArrowRight";v.key!==z&&v.key!==C||t.onStep&&(v.preventDefault(),t.onStep(v.key===C?1:-1,v.shiftKey))},{signal:n}),{isDragging:()=>r,cancel(){r&&m()},destroy(){m(),i.abort()}}}function _t(s,t){if(typeof s=="number")return Number.isFinite(s)?s:Number.NaN;if(typeof s!="string")return Number.NaN;let e=/^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)?$/i.exec(s.trim());if(!e)return Number.NaN;let i=Number(e[1]);if(!Number.isFinite(i))return Number.NaN;if((e[2]??"").toLowerCase()!=="%")return i;let n=Number(t);return Number.isFinite(n)?i/100*n:Number.NaN}var Hy="split-view",$n=class extends y{static cssName="split-view";static defaults={orientation:"horizontal",start:null,end:null,size:"38%",min:160,max:null,collapsible:!1,collapsed:!1,snap:0,storageKey:null,disabled:!1,label:"Resize panes"};#t=null;#e=null;#i=null;constructor(t=null,e={}){super(t,e);let i=this.options.storageKey;if(i!=null&&i!==""){this.#e=ci(Hy);let o=this.#e.get(String(i));typeof o=="number"&&Number.isFinite(o)&&o>=0&&this.setSize(o)}let n=this.options.collapsed;n==="start"||n==="end"?this.#o(n,!1):n===!0&&this.options.collapsible&&this.#o(this.options.collapsible==="end"?"end":"start",!1);let r=this.refs.divider;this.#i=wi(r,{orientation:this._orientation,disabled:()=>this._disabled,onStart:()=>{this._startSize=this.getSize(),this.el.dataset.dragging="true"},onMove:o=>this.#a(o,!1),onEnd:(o,a)=>{a&&this.#a(o,!0),delete this.el.dataset.dragging,a&&(this.#p(),this.#_())},onStep:(o,a)=>this.#c(o*(a?64:16)),onJump:o=>this.#l(o),onActivate:()=>{this.options.collapsible&&(this._collapsed===null?this.collapse(this.options.collapsible):this.expand())}}),this.listen(r,"dblclick",()=>this.#h()),typeof ResizeObserver=="function"&&(this.#t=new ResizeObserver(()=>this.#u()),this.#t.observe(this.el)),this.#n()}render(){let t=this.options;this._orientation=t.orientation==="vertical"?"vertical":"horizontal";let e=_t(t.size,Number.NaN);this._size=Number.isFinite(e)?Math.max(0,e):null,this._collapsed=null,this._disabled=!!t.disabled,this._destroyed=!1,this._startSize=0,this._lastTotal=-1,this._createdRoot=!this.el;let i=this.el??l("div");this.el=i,this._snapshot=this._createdRoot?null:A(i);let n=this._createdRoot||t.start!=null||t.end!=null?[]:Array.from(i.children),r=x("zx-split-start"),o=l("div",{class:"zx-split-view__pane",id:r,ref:"start",dataset:{pane:"start"}}),a=l("div",{class:"zx-split-view__divider",ref:"divider",role:"separator",tabindex:this._disabled?-1:0,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(t.label??"Resize panes"),ariaControls:r}),c=l("div",{class:"zx-split-view__pane",ref:"end",dataset:{pane:"end"}});return i.replaceChildren(o,a,c),i.dataset.orientation=this._orientation,this._disabled&&a.setAttribute("aria-disabled","true"),i.style.setProperty("--zx-split-size",jn(t.size)),t.start!=null?Hn(o,t.start,"SplitView start"):n[0]&&o.append(n[0]),t.end!=null?Hn(c,t.end,"SplitView end"):n[1]&&c.append(...n.slice(1)),i}setSize(t){let{total:e,divider:i,min:n,max:r}=this.#s(),o=_t(t,e>0?e:Number.NaN);return Number.isFinite(o)?(this.#r(Kt({size:o,min:n,max:r,total:e,divider:i})),this):(this._size=null,this.el.style.setProperty("--zx-split-size",jn(t)),this.#n(),this)}getSize(){if(this._collapsed==="start")return 0;let{total:t,divider:e}=this.#s();if(this._collapsed==="end")return Math.max(0,t-e);if(this._size!==null)return this._size;let i=oh(this.refs.start,this._orientation);if(i>0)return i;let n=_t(this.options.size,t);return Number.isFinite(n)?Math.max(0,n):0}getRatio(){let{total:t}=this.#s();return t>0?this.getSize()/t:0}setStart(t){return Hn(this.refs.start,t,"SplitView start"),this}setEnd(t){return Hn(this.refs.end,t,"SplitView end"),this}collapse(t){let e=this.options.collapsible==="end"?"end":"start";return this.#o(t==="end"?"end":t==="start"?"start":e,!0)}expand(){return this._collapsed===null?this:(this._collapsed=null,delete this.el.dataset.collapsed,this.#n(),this.emit("expand"),this)}isCollapsed(){return this._collapsed??!1}enable(){return this._disabled=!1,this.refs.divider.removeAttribute("aria-disabled"),this.refs.divider.setAttribute("tabindex","0"),this}disable(){return this._disabled=!0,this.#i?.cancel(),delete this.el.dataset.dragging,this.refs.divider.setAttribute("aria-disabled","true"),this.refs.divider.setAttribute("tabindex","-1"),this}isDisabled(){return this._disabled}destroy(){this._destroyed||(this._destroyed=!0,this.#i?.destroy(),this.#i=null,this.#t?.disconnect(),this.#t=null,super.destroy(),!this._createdRoot&&this._snapshot&&S(this.el,this._snapshot))}#s(){let t=this.el,e=this._orientation==="vertical"?t.clientHeight:t.clientWidth,i=this.options.max==null?null:Number(this.options.max);return{total:Number.isFinite(e)&&e>0?e:0,divider:oh(this.refs.divider,this._orientation),min:Math.max(0,Number(this.options.min)||0),max:Number.isFinite(i)?i:null}}#r(t){this._size=t,this.el.style.setProperty("--zx-split-size",`${t}px`),this.#n()}#n(){let{total:t,divider:e,min:i,max:n}=this.#s(),r=qn({min:i,max:n,total:t,divider:e}),o=this.refs.divider;o.setAttribute("aria-valuemin",String(Math.round(r.min))),o.setAttribute("aria-valuemax",String(Math.round(r.max))),o.setAttribute("aria-valuenow",String(Math.round(this.getSize())))}#o(t,e){return this._collapsed===t?this:(this._collapsed=t,this.el.dataset.collapsed=t,this.#n(),e&&this.emit("collapse",{pane:t}),this)}#a(t,e){if(this._destroyed)return;let{total:i,divider:n,min:r,max:o}=this.#s();if(i<=0)return;this._collapsed!==null&&this.expand();let a=Kt({size:this._startSize+t,min:r,max:o,total:i,divider:n});e&&(a=Kt({size:Ka(a,this.#f(i,n),Number(this.options.snap)),min:r,max:o,total:i,divider:n})),a!==this._size&&(this.#r(a),this.emit("resize",{size:a,ratio:a/i}))}#c(t){let{total:e,divider:i,min:n,max:r}=this.#s();e<=0||(this._collapsed!==null&&this.expand(),this.#d(Kt({size:this.getSize()+t,min:n,max:r,total:e,divider:i}),e))}#l(t){let{total:e,divider:i,min:n,max:r}=this.#s();if(e<=0)return;this._collapsed!==null&&this.expand();let o=qn({min:n,max:r,total:e,divider:i});this.#d(Kt({size:o[t],min:n,max:r,total:e,divider:i}),e)}#d(t,e){t!==this._size&&(this.#r(t),this.emit("resize",{size:t,ratio:t/e}),this.#p(),this.#_())}#f(t,e){let{min:i,max:n}=this.#s(),r=qn({min:i,max:n,total:t,divider:e}),o=[r.min,r.max],a=_t(this.options.size,t);return Number.isFinite(a)&&o.unshift(a),o}#h(){if(this._disabled)return;this._collapsed!==null&&this.expand();let t=_t(this.options.size,Number.NaN);Number.isFinite(t)?this.setSize(t):(this._size=null,this.el.style.setProperty("--zx-split-size",jn(this.options.size)),this._lastTotal=-1,this.#u());let{total:e}=this.#s(),i=this.getSize();this.emit("resize",{size:i,ratio:e>0?i/e:0}),this.#p(),this.#_()}#u(){if(this._destroyed||this.#i?.isDragging())return;let{total:t,divider:e,min:i,max:n}=this.#s();if(t<=0||t===this._lastTotal)return;if(this._lastTotal=t,this._size===null){let o=_t(this.options.size,t);if(Number.isFinite(o)){let a=Kt({size:o,min:i,max:n,total:t,divider:e});this.el.style.setProperty("--zx-split-size",Math.abs(a-o)>.5?`${a}px`:jn(this.options.size))}this.#n();return}let r=Kt({size:this._size,min:i,max:n,total:t,divider:e});if(r===this._size){this.#n();return}this.#r(r),this.emit("resize",{size:r,ratio:r/t})}#p(){let t=this.options.storageKey;!this.#e||t==null||t===""||(this._size===null?this.#e.remove(String(t)):this.#e.set(String(t),Math.round(this._size)))}#_(){let{total:t}=this.#s(),e=this.getSize();this.emit("resizeend",{size:e,ratio:t>0?e/t:0})}};function Kt({size:s,min:t=0,max:e=null,total:i=0,divider:n=0}){let r=Number(s),o=qn({min:t,max:e,total:i,divider:n});return Math.max(0,(Number(i)||0)-Math.max(0,Number(n)||0))>0?Number.isFinite(r)?Math.min(o.max,Math.max(o.min,r)):o.min:Number.isFinite(r)?Math.max(0,r):o.min}function Ka(s,t,e){let i=Number(s),n=Number(e);if(!Number.isFinite(i)||!Number.isFinite(n)||n<=0)return i;let r=Array.isArray(t)?t:t==null?[]:[t],o=i,a=Number.POSITIVE_INFINITY;for(let c of r){let d=Number(c);if(!Number.isFinite(d))continue;let u=Math.abs(d-i);u<=n&&u<a&&(a=u,o=d)}return o}function qn({min:s=0,max:t=null,total:e=0,divider:i=0}){let n=Math.max(0,(Number(e)||0)-Math.max(0,Number(i)||0)),r=t==null||!Number.isFinite(Number(t))?n:Math.min(n,Math.max(0,Number(t)));return{min:Math.min(Math.max(0,Number(s)||0),r),max:r}}function oh(s,t){let e=s.getBoundingClientRect(),i=t==="vertical"?e.height:e.width;return Number.isFinite(i)&&i>0?i:0}function jn(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function Hn(s,t,e){if(s.replaceChildren(),t==null)return;if(typeof t=="string"||typeof t=="number"){s.append(document.createTextNode(String(t)));return}let i=t instanceof y?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var qy="dock",Kn=class extends y{static cssName="dock";static defaults={orientation:"vertical",content:null,panes:[],resizable:!0,collapsible:!0,lazy:!0,storageKey:null,label:"Resize panes"};constructor(t=null,e={}){super(t,e);let i=this.options.storageKey;if(i!=null&&i!==""){this._store=ci(qy);let n=this._store.get(String(i));n&&typeof n=="object"&&this.setState(n)}this._syncGrow(),this._syncDividers()}render(){let t=this.options;this._orientation=t.orientation==="horizontal"?"horizontal":"vertical",this._resizable=t.resizable!==!1,this._lazy=t.lazy!==!1,this._destroyed=!1,this._panes=new Map,this._store=null,this._drag=null,this._dividerDrags=[],this._createdRoot=!this.el;let e=this.el??l("div");this.el=e,this._snapshot=this._createdRoot?null:A(e),e.dataset.orientation=this._orientation,e.replaceChildren(),this._content=t.content==null?null:l("div",{class:"zx-dock__content",ref:"content"}),this._content&&Ya(this._content,t.content,!1);for(let i of Array.isArray(t.panes)?t.panes:[])this._panes.set(String(i.name),this._buildPane(i));return this._layout(),e}pane(t){return this._panes.get(String(t))??null}names(){return[...this._panes.keys()]}add(t,e={}){let i=String(t?.name??"");if(!i)throw new TypeError("Dock pane requires a name");this._panes.has(i)&&this.remove(i);let n=this._buildPane(t),r=[...this._panes.entries()],o=Number.isInteger(e.index)?q(Number(e.index),0,r.length):r.length;return r.splice(o,0,[i,n]),this._panes=new Map(r),this._layout(),this._syncGrow(),this._syncDividers(),n}remove(t){let e=this._panes.get(String(t));return e?e.kind==="sheet"?this.release(e.sheet):(e.roving?.destroy(),e.element.remove(),this._panes.delete(String(t)),this._layout(),this._syncGrow(),this._syncDividers(),this):this}collapse(t){let e=this._panes.get(String(t));return!e||!e.collapsible||e.collapsed?this:(e.collapsed=!0,this._syncPaneState(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("collapse",{name:e.name}),this)}expand(t){let e=this._panes.get(String(t));return!e||!e.collapsed?this:(e.collapsed=!1,this._syncPaneState(e),this._materialize(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("expand",{name:e.name}),this)}toggle(t){let e=this._panes.get(String(t));return e?e.collapsed?this.expand(t):this.collapse(t):this}isCollapsed(t){return!!this._panes.get(String(t))?.collapsed}reveal(t){let e=String(t),i=this._panes.get(e);if(i)this.expand(e);else for(let n of this._panes.values())if(n.tabs?.has(e)){i=n,this.expand(n.name),this.activate(n.name,e);break}return i?(i.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.emit("reveal",{name:i.name}),this):this}setSize(t,e){let i=this._panes.get(String(t));if(!i)return this;let n=Ua(e);return n===null?i.element.style.removeProperty("--zx-pane-size"):i.element.style.setProperty("--zx-pane-size",n),this._syncDividers(),this._persist(),this}getSize(t){let e=this._panes.get(String(t));return e?this._axisSize(e.element):0}activate(t,e){let i=this._panes.get(String(t)),n=i?.tabs?.get(String(e));if(!n||i.active===n.name)return this;let r=i.active;i.active=n.name;for(let o of i.tabs.values()){let a=o===n;o.tab.setAttribute("aria-selected",String(a)),o.tab.tabIndex=a?0:-1,o.panel.hidden=!a}return this._materialize(i),this._persist(),this.emit("tabchange",{pane:i.name,tab:n.name,previous:r}),this}getActive(t){return this._panes.get(String(t))?.active??null}state(){let t={sizes:{},collapsed:[],active:{}};for(let e of this._panes.values())if(e.kind!=="sheet"){if(e.collapsed)t.collapsed.push(e.name);else if(!e.grow){let i=this._axisSize(e.element);i>0&&(t.sizes[e.name]=i)}e.active&&(t.active[e.name]=e.active)}return t}setState(t){if(!t||typeof t!="object")return this;let e=new Set(Array.isArray(t.collapsed)?t.collapsed.map(String):[]);for(let i of this._panes.values()){if(i.kind==="sheet")continue;let n=t.sizes?.[i.name];typeof n=="number"&&Number.isFinite(n)&&n>0&&i.element.style.setProperty("--zx-pane-size",`${n}px`);let r=t.active?.[i.name];r&&i.tabs?.has(String(r))&&this.activate(i.name,String(r));let o=e.has(i.name);o!==i.collapsed&&i.collapsible&&(i.collapsed=o,this._syncPaneState(i))}return this._syncGrow(),this._syncDividers(),this}destroy(){if(!this._destroyed){this._destroyed=!0;for(let t of this._dividerDrags)t.destroy();this._dividerDrags=[];for(let t of this._panes.values())t.roving?.destroy(),t.breakpoint?.destroy(),t.kind==="sheet"&&t.sheet._setDock(null);super.destroy(),!this._createdRoot&&this._snapshot&&S(this.el,this._snapshot)}}_buildPane(t){let e=String(t.name),i=String(t.title??""),n=t.collapsible??this.options.collapsible!==!1,r=x("zx-dock-body"),o=Array.isArray(t.tabs)&&t.tabs.length>0,a=l("span",{class:"zx-dock__chevron",ariaHidden:"true"},b("chevron-right",{size:14})),c=l("button",{class:"zx-dock__toggle",type:"button",ariaControls:r,ariaExpanded:"true",ariaLabel:o?i||e:null},a,o?null:l("span",{class:"zx-dock__title"},i));n||(c.disabled=!0);let d=l("div",{class:"zx-dock__header"},c),u=l("div",{class:"zx-dock__body",id:r}),h=l("section",{class:"zx-dock__pane",dataset:{name:e,state:"open"}},d,u),f={name:e,title:i,element:h,header:d,body:u,toggle:c,collapsible:n,collapsed:!1,grow:!!t.grow,side:t.side==="end"?"end":"start",min:Number.isFinite(t.min)?Math.max(0,Number(t.min)):0,tabs:null,active:null,content:null,built:!1,roving:null};if(o){f.tabs=new Map;let _=l("div",{class:"zx-dock__tabs",role:"tablist",ariaOrientation:"horizontal",ariaLabel:i||e});for(let w of t.tabs){let v=String(w.name),z=x("zx-dock-tab"),C=x("zx-dock-panel"),k=l("button",{class:"zx-dock__tab",type:"button",role:"tab",id:z,ariaControls:C,ariaSelected:"false",tabindex:-1},String(w.title??v)),M=l("div",{class:"zx-dock__panel",role:"tabpanel",id:C,ariaLabelledby:z,tabindex:0,hidden:!0});_.append(k),u.append(M),f.tabs.set(v,{name:v,tab:k,panel:M,content:w.content,built:!1})}d.append(_),f.roving=Mt(_,".zx-dock__tab",{orientation:"horizontal"}),this.listen(_,"click",w=>{let v=w.target.closest?.(".zx-dock__tab");if(!v||!_.contains(v))return;let z=[...f.tabs.values()].find(C=>C.tab===v);z&&this.activate(f.name,z.name)});let m=String(t.active??""),g=f.tabs.has(m)?m:[...f.tabs.keys()][0];f.active=g;for(let w of f.tabs.values()){let v=w.name===g;w.tab.setAttribute("aria-selected",String(v)),w.tab.tabIndex=v?0:-1,w.panel.hidden=!v}}else f.content=l("div",{class:"zx-dock__pane-content"}),u.append(f.content),f.factory=t.content;let p=Ua(t.size);return p!==null&&h.style.setProperty("--zx-pane-size",p),n&&this.listen(c,"click",()=>this.toggle(f.name)),t.collapsed&&n&&(f.collapsed=!0,this._syncPaneState(f)),(!this._lazy||!f.collapsed)&&this._materialize(f),f}_materialize(t){if(!t.collapsed){if(t.tabs){let e=t.tabs.get(t.active);if(!e||e.built)return;e.built=!0,Ya(e.panel,e.content,!0);return}t.built||(t.built=!0,Ya(t.content,t.factory,!0))}}_layout(){let t=[...this._panes.values()].filter(n=>n.kind!=="sheet"||n.sheet.isDocked()),e=this._content?[...t.filter(n=>n.side==="start"),this._content,...t.filter(n=>n.side==="end")]:t;for(let n of this._dividerDrags)n.destroy();this._dividerDrags=[];let i=[];e.forEach((n,r)=>{r>0&&i.push(this._divider()),i.push(n instanceof Element?n:n.element)}),this.el.replaceChildren(...i)}_divider(){let t=l("div",{class:"zx-dock__divider",role:"separator",tabindex:this._resizable?0:-1,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(this.options.label??"Resize panes")});return this._dividerDrags.push(wi(t,{orientation:this._orientation,disabled:()=>!this._resizable,onStart:()=>{let{before:e,after:i}=this._neighbours(t),n=this._resizeSubject(e,i);return n?(this._drag={subject:n,startSize:this._axisSize(n.element),oppositeStart:n.opposite?this._axisSize(n.opposite.element):0},this.el.dataset.dragging="true",!0):!1},onMove:e=>this._trackDelta(e),onEnd:(e,i)=>{i&&this._trackDelta(e),this._drag=null,delete this.el.dataset.dragging,i&&this._persist()},onStep:(e,i)=>this._stepDivider(t,e*(i?64:16)),onActivate:()=>{let{before:e}=this._neighbours(t);e?.collapsible&&this.toggle(e.name)}})),t}_isHidden(t){return t.kind==="sheet"?!t.sheet.isOpen():!!t.collapsed}adopt(t,e={}){if(!t||typeof t._setDock!="function"||!t.el)throw new TypeError("Dock.adopt expects a Sheet");let i=String(e.name??t.el.id??"")||x("zx-dock-sheet"),n={kind:"sheet",name:i,sheet:t,element:t.el,side:e.side==="end"?"end":"start",min:Number.isFinite(e.min)?Math.max(0,Number(e.min)):0,grow:!1,collapsed:!1,collapsible:!1,breakpoint:null,resync:null},r=[...this._panes.entries()],o=Number.isInteger(e.index)?q(Number(e.index),0,r.length):r.length;r.splice(o,0,[i,n]),this._panes=new Map(r);let a=Ua(e.size);a!==null&&t.el.style.setProperty("--zx-pane-size",a),n.resync=()=>{this._syncGrow(),this._syncDividers()},t.on("open",n.resync),t.on("close",n.resync);let c=e.dockAt??null;return c?n.breakpoint=ni((d,u)=>{this._applyDockAt(n,yn(c,u))},{target:this.el}):this._applyDockAt(n,!0),n}release(t){let e=[...this._panes.values()].find(i=>i.sheet===t);return e?(e.breakpoint?.destroy(),e.breakpoint=null,this._panes.delete(e.name),t.off("open",e.resync),t.off("close",e.resync),t.el.style.removeProperty("--zx-pane-size"),t._setDock(null),this._layout(),this._syncGrow(),this._syncDividers(),this):this}_forget(t){let e=[...this._panes.values()].find(i=>i.sheet===t);e&&(e.breakpoint?.destroy(),this._panes.delete(e.name),!this._destroyed&&(this._layout(),this._syncGrow(),this._syncDividers()))}_applyDockAt(t,e){t.sheet.isDocked()!==e&&(t.sheet._setDock(e?this:null),this._layout(),this._syncGrow(),this._syncDividers())}_syncGrow(){let t=[...this._panes.values()];for(let n of t)n.element.removeAttribute("data-grow");if(this._content)return;let e=t.filter(n=>!this._isHidden(n));if(e.length===0)return;let i=e.find(n=>n.grow);(i??e[e.length-1]).element.dataset.grow="true"}_syncDividers(){for(let t of this._dividers()){let{before:e,after:i}=this._neighbours(t),n=this._resizeSubject(e,i),r=this._resizable&&n!==null;if(t.toggleAttribute("data-disabled",!r),t.tabIndex=r?0:-1,!r){t.removeAttribute("aria-valuenow");continue}let o=this._axisSize(this.el);t.setAttribute("aria-valuenow",String(Math.round(this._axisSize(n.element)))),t.setAttribute("aria-valuemin",String(Math.round(this._minSize(n)))),t.setAttribute("aria-valuemax",String(Math.round(o))),t.setAttribute("aria-controls",n.element.id||$y(n.element))}}_syncPaneState(t){t.element.dataset.state=t.collapsed?"collapsed":"open",t.toggle.setAttribute("aria-expanded",String(!t.collapsed))}_dividers(){return[...this.el.querySelectorAll(":scope > .zx-dock__divider")]}_neighbours(t){let e=i=>{if(!i)return null;for(let n of this._panes.values())if(n.element===i)return n;return null};return{before:e(t.previousElementSibling),after:e(t.nextElementSibling)}}_resizeSubject(t,e){let i=n=>!!n&&!this._isHidden(n)&&n.element.dataset.grow!=="true";return i(t)?{element:t.element,record:t,sign:1,opposite:i(e)?e:null}:i(e)?{element:e.element,record:e,sign:-1,opposite:null}:null}_minSize(t){let i=(t.record.header??t.record.element.querySelector(".zx-dialog__header")??t.record.element).getBoundingClientRect(),n=this._orientation==="vertical"?i.height:i.width;return Math.max(t.record.min,n)}_axisSize(t){let e=t.getBoundingClientRect();return this._orientation==="vertical"?e.height:e.width}_trackDelta(t){if(!this._drag||this._destroyed)return;let{subject:e,startSize:i,oppositeStart:n}=this._drag,r=this._minSize(e),o=Math.max(r,i+t*e.sign);if(e.opposite){let a=this._minSize({record:e.opposite,element:e.opposite.element});o=Math.max(r,Math.min(o,i+n-a)),e.opposite.element.style.setProperty("--zx-pane-size",`${i+n-o}px`)}e.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this.emit("resize",{name:e.record.name,size:o})}_stepDivider(t,e){let{before:i,after:n}=this._neighbours(t),r=this._resizeSubject(i,n);if(!r)return;let o=Math.max(this._minSize(r),this._axisSize(r.element)+e*r.sign);r.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this._persist(),this.emit("resize",{name:r.record.name,size:o})}_persist(){let t=this.options.storageKey;!this._store||t===null||t===void 0||t===""||this._store.set(String(t),this.state())}};function $y(s){let t=x("zx-dock-pane");return s.id=t,t}function Ua(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}function Ya(s,t,e){let i=e&&typeof t=="function"?t():t;if(i==null)return;if(typeof i=="string"||typeof i=="number"){s.append(document.createTextNode(String(i)));return}let n=i instanceof y?i.toElement():i;n&&typeof n.nodeType=="number"&&s.append(n)}var Un="44rem",lh=/^\d+(?:\.\d+)?(?:px|rem)$/,Yn=class extends y{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[],overflow:!0,overflowBelow:Un,minVisible:0};constructor(t,e={}){super(t,e),this._overflow=new at(this.refs.moreTrigger,{label:"More",icon:"dots",kind:"ghost",items:[],placement:"bottom-end"}),this._overflow.on("select",i=>{let n=this._find(String(i.detail.value));!n||n.definition.disabled||(this.setActive(n.definition.name),n.definition.onselect?.(n.definition.name,n.definition,this),n.definition.href&&globalThis.location?.assign(n.definition.href))}),this._syncOverflow(),this._observeWidth()}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:Gy(e),this._cleaned=!1,this._items=[],this._activeName=null,this._tabMode=!1,this._overflow=null,this._observer=null,this._frame=0;let i=l("header",{class:"zx-navigation-bar__bar"},l("div",{class:"zx-navigation-bar__brand",ref:"title"}),l("nav",{class:"zx-navigation-bar__navigation",ariaLabel:"Primary navigation"},l("div",{class:"zx-navigation-bar__items",ref:"items"}),l("div",{class:"zx-navigation-bar__more",ref:"more"},l("button",{class:"zx-navigation-bar__more-trigger",ref:"moreTrigger"}))),l("div",{class:"zx-navigation-bar__actions",ref:"actions",role:"group",ariaLabel:"Application actions"})),n=l("div",{class:"zx-navigation-bar__panels",ref:"panels",hidden:!0});return e.replaceChildren(i,n),this.setTitle(this.options.title),this.setItems(this.options.items),this.setActions(this.options.actions),this.listen(this.refs.items,"keydown",r=>this._onTabKeydown(r)),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setItems(t){if(!Array.isArray(t))throw new TypeError("NavigationBar items must be an array");let e=this._activeName,i=new Set,n=t.map(d=>{if(!d||typeof d!="object"||Array.isArray(d))throw new TypeError("Navigation item must be an object");if(typeof d.name!="string"||d.name==="")throw new TypeError("Navigation item name must be a non-empty string");if(i.has(d.name))throw new RangeError(`Navigation item already exists: ${d.name}`);if(i.add(d.name),Object.hasOwn(d,"content")&&!Yy(d.content))throw new TypeError(`Navigation panel content for ${d.name} is invalid`);let u={name:d.name,title:String(d.title??""),badge:d.badge==null?null:String(d.badge),href:d.href==null?void 0:String(d.href),disabled:!!d.disabled,onselect:typeof d.onselect=="function"?d.onselect:void 0};return Object.hasOwn(d,"content")&&(u.content=d.content),u}),r=n.some(d=>Object.hasOwn(d,"content"));if(r&&n.some(d=>!Object.hasOwn(d,"content")))throw new TypeError("NavigationBar panel items must all define content");this._items=[],this._activeName=null,this._tabMode=r,this.refs.items.replaceChildren(),this.refs.panels.replaceChildren(),this.refs.panels.hidden=!this._tabMode,this._tabMode?(this.refs.items.setAttribute("role","tablist"),this.refs.items.setAttribute("aria-orientation","horizontal")):(this.refs.items.removeAttribute("role"),this.refs.items.removeAttribute("aria-orientation"));for(let d of n)this._appendItem(d);let o=e??this.options.active,a=o===null?null:this._find(o),c=a&&!a.definition.disabled?a:this._enabledItems()[0];return c&&this._applyActive(c),this._syncOverflow(),this}setActive(t){let e=this._find(t);return!e||e.definition.disabled||t===this._activeName?this:(this._applyActive(e),this.emit("change",{name:e.definition.name}),this)}setBadge(t,e){let i=this._require(t);return i.definition.badge=e===null?null:String(e),i.badge.textContent=i.definition.badge??"",i.badge.hidden=i.definition.badge===null,this._syncOverflow(),this}setActions(t){if(!Array.isArray(t))throw new TypeError("NavigationBar actions must be an array");let e=t.map(i=>{if(E(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("NavigationBar actions must be Elements or button descriptors");let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.actions.replaceChildren(...e),this}destroy(){this._cleaned||(this._cleaned=!0,this._frame&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this._frame),this._frame=0,this._observer?.disconnect(),this._observer=null,this._overflow?.destroy(),super.destroy(),!this._createdRoot&&this._original&&Wy(this.el,this._original))}_appendItem(t){let e=x("zx-navigation-item"),i=x("zx-navigation-panel"),n=l("span",{class:"zx-navigation-bar__badge",hidden:t.badge===null},t.badge??""),r={class:"zx-navigation-bar__item",id:e,ariaDisabled:t.disabled?"true":null},o;this._tabMode?o=l("button",{...r,type:"button",role:"tab",tabindex:"-1",ariaControls:i,ariaSelected:"false"},l("span",{class:"zx-navigation-bar__label"},t.title),n):t.href?o=l("a",{...r,href:t.href},l("span",{class:"zx-navigation-bar__label"},t.title),n):o=l("button",{...r,type:"button"},l("span",{class:"zx-navigation-bar__label"},t.title),n);let a=null;this._tabMode&&(a=l("div",{class:"zx-navigation-bar__panel",id:i,role:"tabpanel",tabindex:"0",ariaLabelledby:e,hidden:!0}),this.refs.panels.append(a));let c={definition:t,item:o,badge:n,panel:a,built:!1};this._items.push(c),this.refs.items.append(o),this.listen(o,"click",d=>{if(c.definition.disabled){d.preventDefault();return}this.setActive(c.definition.name),c.definition.onselect?.(c.definition.name,c.definition,this)})}_applyActive(t){this._tabMode&&this._ensurePanel(t);for(let e of this._items){let i=e===t;this._tabMode?(e.item.setAttribute("aria-selected",String(i)),e.item.tabIndex=i?0:-1,e.panel&&(e.panel.hidden=!i)):i?e.item.setAttribute("aria-current","page"):e.item.removeAttribute("aria-current")}this._activeName=t.definition.name}_ensurePanel(t){if(!t.panel||t.built)return;let e=t.definition.content,i=typeof e=="function"?e():e,n=i instanceof y?i.toElement():i;if(!n||typeof n.nodeType!="number")throw new TypeError(`Navigation panel factory for ${t.definition.name} must return a Node or Component`);t.panel.append(n),t.built=!0}_onTabKeydown(t){if(!this._tabMode)return;let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.items.contains(e))return;let i=this._items.find(r=>r.item===e);if(!i)return;let n=this._enabledItems();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(i),a=n[(o+r+n.length)%n.length];a&&this._focusTab(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let r=t.key==="Home"?n[0]:n[n.length-1];r&&this._focusTab(r);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.setActive(i.definition.name))}_syncOverflow(){let t=ah(this.options),e=t===null?this._items.length:Ky(this.options,this._items.length),i=this._items.slice(e),n=this.el;for(let[r,o]of this._items.entries())o.item.dataset.collapsed=String(r>=e);n.dataset.overflow=t===null?"off":e===0?"all":"partial",t===null||t===Un?delete n.dataset.overflowBelow:n.dataset.overflowBelow=t,this._overflow&&(this.refs.more.dataset.empty=i.length===0?"true":"false",this._overflow.setItems(i.map(r=>({label:r.definition.badge===null?r.definition.title:`${r.definition.title} (${r.definition.badge})`,value:r.definition.name,disabled:r.definition.disabled}))))}_observeWidth(){let t=ah(this.options);if(t===null||t===Un||typeof ResizeObserver!="function")return;let e=this.el,i=()=>{let n=e.getBoundingClientRect().width;if(!n)return;let r=globalThis.document?.documentElement,o=r?Number.parseFloat(globalThis.getComputedStyle(r).fontSize):Number.NaN;e.dataset.narrow=String(n<=Uy(t,o))};this._observer=new ResizeObserver(()=>{if(this._frame||typeof requestAnimationFrame!="function"){typeof requestAnimationFrame!="function"&&i();return}this._frame=requestAnimationFrame(()=>{this._frame=0,i()})}),this._observer.observe(e),i()}_focusTab(t){for(let e of this._items)e.item.tabIndex=e===t?0:-1;t.item.focus()}_enabledItems(){return this._items.filter(t=>!t.definition.disabled)}_find(t){return this._items.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown navigation item: ${t}`);return e}};function ah(s={}){let t=s.overflow??!0;if(typeof t!="boolean")throw new TypeError("NavigationBar overflow must be a boolean");let e=s.overflowBelow??Un;if(!t||e===!1)return null;if(typeof e=="number"){if(!Number.isFinite(e)||e<0)throw new RangeError(`NavigationBar overflowBelow must not be negative: ${e}`);return`${e}px`}if(typeof e!="string"||!lh.test(e.trim()))throw new TypeError(`NavigationBar overflowBelow must be a px or rem length, a number of pixels, or false: ${String(e)}`);return e.trim()}function Ky(s={},t=0){let e=s.minVisible??0;if(!Number.isInteger(e)||e<0)throw new TypeError(`NavigationBar minVisible must be a non-negative integer: ${String(e)}`);let i=Number.isInteger(t)&&t>0?t:0;return Math.min(e,i)}function Uy(s,t=16){let e=typeof s=="number"?`${s}px`:String(s).trim();if(!lh.test(e))throw new TypeError(`NavigationBar cannot measure the length "${String(s)}"`);let i=Number.parseFloat(e);if(!e.endsWith("rem"))return i;let n=Number(t);return i*(Number.isFinite(n)&&n>0?n:16)}function Yy(s){return typeof s=="function"||s instanceof y?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Gy(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Wy(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function dh(s){if(!Array.isArray(s))throw new TypeError("Stepper steps must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Step definition must be an object");if(typeof e.name!="string"||e.name==="")throw new TypeError("Step name must be a non-empty string");if(t.has(e.name))throw new RangeError(`Step already exists: ${e.name}`);return t.add(e.name),{name:e.name,title:String(e.title??""),description:e.description==null?null:String(e.description),optional:!!e.optional,disabled:!!e.disabled}})}function Gn(s,t){return t===null?-1:s.findIndex(e=>e.name===t)}function Wn(s,t,e){let i=e<0?-1:1,n=t<0?i>0?0:s.length-1:t+i;for(;n>=0&&n<s.length;){if(!s[n].disabled)return n;n+=i}return-1}function uh(s,t,e){return t<0||e<=t?[]:s.slice(t,e).map(i=>i.name)}function hh(s,t,e={}){let{activeIndex:i=-1,completed:n,errored:r}=e;return ch(r,s.name)?"error":t===i?"active":ch(n,s.name)?"complete":"upcoming"}function ch(s,t){return s?s instanceof Set?s.has(t):s.includes(t):!1}var Qy=new Set(["horizontal","vertical"]),Xy=new Set(["completed","all",!1]),Qn=class extends y{static cssName="stepper";static defaults={steps:[],active:null,orientation:"horizontal",clickable:"completed",showNumbers:!0,counter:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._steps=[],this._records=[],this._activeIndex=-1,this._completed=new Set,this._errored=new Set,!Qy.has(this.options.orientation))throw new RangeError(`Unknown stepper orientation: ${this.options.orientation}`);if(!Xy.has(this.options.clickable))throw new RangeError(`Unknown stepper clickable mode: ${this.options.clickable}`);let t=this.el??l("div");this.el=t,t.dataset.orientation=this.options.orientation;let e=l("p",{class:"zx-stepper__counter",ref:"counter",ariaLive:"polite",hidden:!0}),i=l("ol",{class:"zx-stepper__list",ref:"list"});return t.replaceChildren(...this.options.counter?[e,i]:[i]),this.setSteps(this.options.steps),this.listen(i,"click",n=>{let r=n.target.closest?.(".zx-stepper__control");if(!r||!i.contains(r)||r.tagName!=="BUTTON")return;let o=r.dataset.step;typeof o=="string"&&this.goTo(o)}),t}setSteps(t){let e=this.getActive(),i=dh(t),n=new Set(i.map(a=>a.name));this._steps=i,this._completed=new Set([...this._completed].filter(a=>n.has(a))),this._errored=new Set([...this._errored].filter(a=>n.has(a)));let r=e??(this.options.active===null?null:String(this.options.active)),o=r===null?-1:Gn(i,r);return o>=0&&i[o].disabled&&(o=-1),o<0&&(o=Wn(i,-1,1)),this._activeIndex=o,this._records=i.map(a=>this._createRecord(a)),this.refs.list.replaceChildren(...this._records.map(a=>a.item)),this._sync(),this}goTo(t){let e=Gn(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._activate(e)}next(){return this._activate(Wn(this._steps,this._activeIndex,1))}previous(){return this._activate(Wn(this._steps,this._activeIndex,-1))}getActive(){return this._activeIndex<0?null:this._steps[this._activeIndex].name}getIndex(){return this._activeIndex}complete(t){return this._require(t),this._completed.add(t),this._sync(),this}uncomplete(t){return this._require(t),this._completed.delete(t),this._sync(),this}setError(t,e=!0){return this._require(t),e?this._errored.add(t):this._errored.delete(t),this._sync(),this}setDisabled(t,e=!0){return this._require(t).disabled=!!e,this._sync(),this}getState(){return{active:this.getActive(),index:this._activeIndex,completed:this._steps.filter(t=>this._completed.has(t.name)).map(t=>t.name),errored:this._steps.filter(t=>this._errored.has(t.name)).map(t=>t.name)}}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_activate(t){if(t<0||t>=this._steps.length||t===this._activeIndex)return this;let e=this._steps[t];if(e.disabled)return this;let i=this._activeIndex;if(this.emit("change",{name:e.name,previous:i<0?null:this._steps[i].name,index:t}).defaultPrevented)return this;for(let r of uh(this._steps,i,t))this._completed.add(r);return this._activeIndex=t,this._sync(),this}_createRecord(t){let e=l("span",{class:"zx-stepper__marker",ariaHidden:"true"}),i=l("span",{class:"zx-stepper__status"}),n=[l("span",{class:"zx-stepper__title"},t.title)];t.description&&n.push(l("span",{class:"zx-stepper__description"},t.description)),t.optional&&n.push(l("span",{class:"zx-stepper__optional"},this._message("stepper.optional","Optional")));let r=[e,l("span",{class:"zx-stepper__text"},n),i],o=this.options.clickable===!1?l("span",{class:"zx-stepper__control"},r):l("button",{class:"zx-stepper__control",type:"button",dataset:{step:t.name}},r);return{step:t,item:l("li",{class:"zx-stepper__step"},o),control:o,marker:e,status:i}}_sync(){this._records.forEach((t,e)=>{let i=this._stateFor(t.step,e);t.item.dataset.state=i,e===this._activeIndex?t.item.setAttribute("aria-current","step"):t.item.removeAttribute("aria-current"),t.item.toggleAttribute("data-disabled",t.step.disabled),t.marker.replaceChildren(...this._markerContent(i,e)),t.status.textContent=this._statusText(i),t.control.tagName==="BUTTON"&&(t.control.disabled=!this._isClickable(t.step))}),this._syncCounter()}_stateFor(t,e){return hh(t,e,{activeIndex:this._activeIndex,completed:this._completed,errored:this._errored})}_markerContent(t,e){return t==="complete"?[b("check",{size:12})]:t==="error"?[b("warning",{size:12})]:this.options.showNumbers?[String(e+1)]:[]}_statusText(t){return t==="complete"?this._message("stepper.completed","Completed"):t==="error"?this._message("stepper.error","Error"):t==="active"?this._message("stepper.current","Current step"):""}_isClickable(t){return t.disabled?!1:this.options.clickable==="all"?!0:this.options.clickable==="completed"?this._completed.has(t.name):!1}_syncCounter(){if(!this.options.counter)return;let t=this.refs.counter;t.hidden=this._activeIndex<0,t.textContent=this._activeIndex<0?"":this._message("stepper.counter","Step %1 of %2",this._activeIndex+1,this._steps.length)}_require(t){let e=Gn(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._steps[e]}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};var Jy=new Set(["chevron","slash"]),Xn=class extends y{static cssName="breadcrumb";static defaults={items:[],maxVisible:0,separator:"chevron",rootIcon:null};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._items=[],this._overflow=null,!Jy.has(this.options.separator))throw new RangeError(`Unknown breadcrumb separator: ${this.options.separator}`);let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("breadcrumb.label","Breadcrumb"));let e=l("ol",{class:"zx-breadcrumb__list",ref:"list"});return t.replaceChildren(e),this.setItems(this.options.items),this.listen(e,"click",i=>{let n=i.target.closest?.("[data-crumb]");!n||!e.contains(n)||this._select(n.dataset.crumb)}),t}setItems(t){if(!Array.isArray(t))throw new TypeError("Breadcrumb items must be an array");let e=new Set;return this._items=t.map(i=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Breadcrumb item must be an object");if(typeof i.name!="string"||i.name==="")throw new TypeError("Breadcrumb item name must be a non-empty string");if(e.has(i.name))throw new RangeError(`Breadcrumb item already exists: ${i.name}`);return e.add(i.name),{name:i.name,label:String(i.label??""),icon:i.icon?String(i.icon):null,href:i.href==null?null:String(i.href)}}),this._build(),this}getItems(){return this._items.map(t=>({...t}))}push(t){return this.setItems([...this._items,t])}pop(){if(this._items.length===0)return null;let t=this._items[this._items.length-1];return this.setItems(this._items.slice(0,-1)),t}truncateTo(t){let e=this._items.findIndex(i=>i.name===t);if(e<0)throw new RangeError(`Unknown breadcrumb item: ${t}`);return this.setItems(this._items.slice(0,e+1))}destroy(){if(this._destroyed)return;this._destroyed=!0,this._overflow?.destroy(),this._overflow=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_build(){let{head:t,hidden:e,tail:i}=this._split(),n=this._items[this._items.length-1]??null,r=[];for(let o of t)r.push(this._renderItem(o,o===n));e.length>0&&r.push(this._renderOverflow(e));for(let o of i)r.push(this._renderItem(o,o===n));this.refs.list.replaceChildren(...r.map((o,a)=>l("li",{class:"zx-breadcrumb__item"},a===0?o:[this._renderSeparator(),o]))),e.length===0&&this._overflow?.toElement().remove()}_split(){let t=this._items,e=Math.trunc(Number(this.options.maxVisible)||0);if(e<=0||t.length<=e)return{head:t,hidden:[],tail:[]};let i=Math.max(2,e);if(t.length<=i)return{head:t,hidden:[],tail:[]};let n=i-1;return{head:t.slice(0,1),hidden:t.slice(1,t.length-n),tail:t.slice(t.length-n)}}_renderItem(t,e){let i=[],n=t.icon??(t===this._items[0]?this.options.rootIcon:null);return n&&i.push(l("span",{class:"zx-breadcrumb__icon",ariaHidden:"true"},b(String(n),{size:13}))),i.push(l("span",{class:"zx-breadcrumb__label"},t.label)),e?l("span",{class:"zx-breadcrumb__current",ariaCurrent:"page"},i):t.href!==null?l("a",{class:"zx-breadcrumb__link",href:t.href,dataset:{crumb:t.name}},i):l("button",{class:"zx-breadcrumb__link",type:"button",dataset:{crumb:t.name}},i)}_renderOverflow(t){if(!this._overflow){this._overflow=new at(null,{label:"",icon:"dots",kind:"ghost",placement:"bottom-start"});let e=this._overflow.toElement();e.classList.add("zx-breadcrumb__more"),e.setAttribute("aria-label",this._message("breadcrumb.more","Show hidden levels")),this._overflow.on("select",i=>this._select(String(i.detail.value)))}return this._overflow.setItems(t.map(e=>({label:e.label,value:e.name,icon:e.icon??void 0}))),this._overflow.toElement()}_renderSeparator(){return l("span",{class:"zx-breadcrumb__separator",ariaHidden:"true"},this.options.separator==="slash"?"/":b("chevron-right",{size:11}))}_select(t){let e=this._items.findIndex(i=>i.name===t);e<0||this.emit("select",{name:this._items[e].name,item:{...this._items[e]},index:e})}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};var Zn="\u2026",Zy=new Set(["pages","loadmore"]);function Qa({page:s=1,pages:t=1,siblings:e=1,boundaries:i=1}={}){let n=Ce(t);if(n<=0)return[];let r=Wa(Ce(s)||1,1,n),o=Math.max(0,Ce(e)),a=Math.max(0,Ce(i)),c=a*2+o*2+3;if(n<=c)return Jn(1,n);let d=Jn(1,Math.min(a,n)),u=Jn(Math.max(n-a+1,a+1),n),h=Math.max(Math.min(r-o,n-a-o*2-1),a+2),f=Math.min(Math.max(r+o,a+o*2+2),u.length>0?u[0]-2:n-1);return[...d,...h>a+2?[Zn]:a+1<n-a?[a+1]:[],...Jn(h,f),...f<n-a-1?[Zn]:n-a>a?[n-a]:[],...u]}var tr=class extends y{static cssName="pagination";static defaults={page:1,pageSize:25,total:0,pageSizes:[25,50,100],siblings:1,boundaries:1,showPageSize:!0,showSummary:!0,mode:"pages",disabled:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._pageSize=Ga(this.options.pageSize,25),this._total=Math.max(0,Ce(this.options.total)),this._page=Math.max(1,Ce(this.options.page)||1),this._disabled=!!this.options.disabled,this._sizeKey="",this._pageSizes=(Array.isArray(this.options.pageSizes)?this.options.pageSizes:[]).map(i=>Ga(i,0)).filter(i=>i>0),!Zy.has(this.options.mode))throw new RangeError(`Unknown pagination mode: ${this.options.mode}`);this._page=Wa(this._page,1,this._pageCount());let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("pagination.label","Pagination")),t.dataset.mode=this.options.mode;let e=[];return this.options.showSummary&&e.push(l("span",{class:"zx-pagination__summary",ref:"summary",ariaLive:"polite"})),this.options.showPageSize&&e.push(this._renderPageSize()),e.push(l("span",{class:"zx-pagination__spacer"})),e.push(this.options.mode==="pages"?this._renderPages():this._renderLoadMore()),t.replaceChildren(...e),this._sync(),this._wire(),t}setPage(t){return this.setState({page:t})}setTotal(t){return this.setState({total:t},{silent:!0})}setPageSize(t){return this.setState({pageSize:t,page:1})}setState(t={},{silent:e=!1}={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pagination state must be an object");let i=this._page,n=this._pageSize;if(Object.hasOwn(t,"total")&&(this._total=Math.max(0,Ce(t.total))),Object.hasOwn(t,"pageSize")&&(this._pageSize=Ga(t.pageSize,this._pageSize)),Object.hasOwn(t,"page")){let r=Math.trunc(Number(t.page));Number.isFinite(r)&&(this._page=r)}return this._page=Wa(this._page,1,this._pageCount()),this._sync(),!e&&(this._page!==i||this._pageSize!==n)&&this.emit("change",this.getState()),this}getState(){let t=this._pageCount();return{page:this._page,pageSize:this._pageSize,total:this._total,pages:t,offset:(this._page-1)*this._pageSize}}enable(){return this._disabled=!1,this._sync(),this}disable(){return this._disabled=!0,this._sync(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_pageCount(){return this._total<=0?1:Math.ceil(this._total/this._pageSize)}_renderPageSize(){let t=this._message("pagination.pageSize","Rows per page");return l("label",{class:"zx-pagination__size"},l("span",{class:"zx-pagination__size-label"},t),l("select",{class:"zx-pagination__select",ref:"select",ariaLabel:t}))}_renderPages(){return l("div",{class:"zx-pagination__controls"},this._navButton("prev","chevron-left",this._message("pagination.previous","Previous page")),l("div",{class:"zx-pagination__pages",ref:"pages"}),this._navButton("next","chevron-right",this._message("pagination.next","Next page")))}_navButton(t,e,i){return l("button",{class:"zx-btn zx-pagination__nav",type:"button",ref:t,ariaLabel:i,dataset:{kind:"default",size:"sm"}},b(e,{size:14}))}_renderLoadMore(){return l("button",{class:"zx-btn zx-pagination__more",type:"button",ref:"more",dataset:{kind:"default",size:"md"}},l("span",{class:"zx-btn__label"},this._message("pagination.loadMore","Load more")))}_wire(){if(this.refs.select&&this.listen(this.refs.select,"change",()=>{this.setPageSize(Number(this.refs.select.value))}),this.options.mode==="pages"){this.listen(this.refs.prev,"click",()=>this.setPage(this._page-1)),this.listen(this.refs.next,"click",()=>this.setPage(this._page+1)),this.listen(this.refs.pages,"click",t=>{let e=t.target.closest?.("[data-page]");!e||!this.refs.pages.contains(e)||this.setPage(Number(e.dataset.page))});return}this.listen(this.refs.more,"click",()=>this.setPage(this._page+1))}_sync(){let t=this._pageCount();if(this.el.dataset.disabled=this._disabled?"true":"false",this.refs.summary&&(this.refs.summary.textContent=this._summary()),this.refs.select&&this._syncPageSize(),this.options.mode==="pages"){this.refs.prev.disabled=this._disabled||this._page<=1,this.refs.next.disabled=this._disabled||this._page>=t,this._syncPages(t);return}this.refs.more.disabled=this._disabled||this._page>=t}_summary(){if(this._total<=0)return this._message("pagination.empty","0 of 0");let t=(this._page-1)*this._pageSize,e=Math.min(t+this._pageSize,this._total);return this.options.mode==="loadmore"?this._message("pagination.loaded","%1 of %2",fs(e),fs(this._total)):this._message("pagination.summary","%1\u2013%2 of %3",fs(t+1),fs(e),fs(this._total))}_syncPageSize(){let t=this.refs.select,e=[...new Set([...this._pageSizes,this._pageSize])].sort((n,r)=>n-r),i=e.join(",");i!==this._sizeKey&&(this._sizeKey=i,t.replaceChildren(...e.map(n=>l("option",{value:String(n)},String(n))))),t.value=String(this._pageSize),t.disabled=this._disabled}_syncPages(t){let e=this.refs.pages,i=this.el.ownerDocument?.activeElement??null,n=i&&e.contains(i)?i.dataset.page??null:null,r=Qa({page:this._page,pages:t,siblings:this.options.siblings,boundaries:this.options.boundaries});if(e.replaceChildren(...r.map(a=>a===Zn?l("span",{class:"zx-pagination__ellipsis",ariaHidden:"true"},Zn):l("button",{class:"zx-btn zx-pagination__page",type:"button",disabled:this._disabled,ariaCurrent:a===this._page?"page":null,ariaLabel:this._message("pagination.page","Page %1",a),dataset:{kind:"default",size:"sm",page:String(a)}},String(a)))),n===null)return;let o=e.querySelector(`[data-page="${n}"]`);o&&!o.disabled&&o.focus()}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function Ce(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:0}function Ga(s,t){let e=Math.trunc(Number(s));return Number.isFinite(e)&&e>0?e:t}function Wa(s,t,e){return Math.min(Math.max(s,t),e)}function Jn(s,t){return t<s?[]:Array.from({length:t-s+1},(e,i)=>s+i)}function fs(s){return s.toLocaleString()}var _s=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),ps=class extends y{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 t=this.el??l("span");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._interactiveRoot=t.matches('a[href], button, input, select, textarea, [role="button"], [role="link"]'),this._state={...this.options},this._appliedClasses=[],this._sync(),t}set(t={}){return!t||typeof t!="object"?this:(Object.assign(this._state,t),this._sync(),this)}destroy(){let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&S(t,e)}_sync(){let t=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[t.class].flat().flatMap(d=>String(d??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let e=fh(t.size,"36px"),i=fh(t.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",e),this.el.style.setProperty("--zx-app-icon-glyph-size",i),ee(t.color)?this.el.style.setProperty("--zx-app-icon-color",String(t.color)):this.el.style.removeProperty("--zx-app-icon-color"),_s.includes(t.tone)?this.el.dataset.tone=t.tone:delete this.el.dataset.tone,this.el.dataset.glass=ew(t.glass),this.el.dataset.shape=iw(t.shape),this.el.toggleAttribute("data-selected",!!t.selected);let n=t.label==null?"":String(t.label).trim();if(this._interactiveRoot){let d=ph(this._snapshot,"role"),u=ph(this._snapshot,"aria-label");d===null?this.el.removeAttribute("role"):this.el.setAttribute("role",d),n?this.el.setAttribute("aria-label",n):u===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",u),this.el.removeAttribute("aria-hidden")}else n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=tw(t.icon),o=t.badge==null||t.badge===""?null:l("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(t.badge)),c=[l("span",{class:"zx-app-icon__surface",ariaHidden:"true"},l("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),l("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r))];o&&c.push(o),this.el.replaceChildren(...c)}};function vi(s={}){return new ps(null,s).toElement()}function tw(s){let t=typeof s=="function"?s():s;return typeof t=="string"?b(t,{size:"1em"}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t:null}function fh(s,t){if(typeof s=="number"&&Number.isFinite(s))return`${Math.max(1,s)}px`;let e=String(s??"").trim();return e&&!/[;{}]/.test(e)?e:t}function ew(s){return s===!1||s==="none"?"none":s==="strong"?"strong":"subtle"}function iw(s){return s==="circle"?"circle":"tile"}function ph(s,t){return s?.attributes.find(([e])=>e===t)?.[1]??null}var sr=class extends y{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:null,label:null,closeLabel:null,resultsLabel:null,emptyText:null,loadingText:null,shortcut:"mod+k",hints:null,scope:null};constructor(t=null,e={}){super(t,e)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null,this._overlay=null;let t=this.el??l("dialog");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,_=>[_.name,_.value]),children:Array.from(t.childNodes)},this._items=ms(this.options.items),this._sources=gh(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._settled=!0,this._pages=[],this._restoreActiveId=null,this._announcePending=!1,this._announceToggle=!1,this._destroyed=!1;let e=x("zx-launcher-results"),i=String(this.options.label??this._message("launcher.label","Launcher")),n=String(this.options.placeholder??this._message("launcher.placeholder","Search applications and records"));this._label=i,this._placeholder=n;let r=l("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:e,ariaExpanded:"false",ariaLabel:i,placeholder:n,value:this._query}),o=l("button",{ref:"scopeBack",class:"zx-icon-btn zx-launcher__scope-back",type:"button"},b("x")),a=l("span",{ref:"scope",class:"zx-launcher__scope",hidden:!0},l("span",{ref:"scopeLabel",class:"zx-launcher__scope-label"}),o),c=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel??this._message("launcher.close","Close launcher")},b("x")),d=l("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),u=l("div",{ref:"announce",class:"zx-launcher__announce",role:"status",ariaLive:"polite",ariaAtomic:"true"}),h=l("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:this.options.resultsLabel??this._message("launcher.results","Launcher results")}),f=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},sw()):null,p=nw(this.options.hints,{move:this._message("launcher.hintMove","Move"),open:this._message("launcher.hintOpen","Open"),back:this._message("launcher.hintBack","Back"),close:this._message("launcher.hintClose","Close")});return t.setAttribute("aria-label",i),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search",dataset:{shortcut:f?"true":"false"}},b("search"),a,r,f,c),d,h,p,u)),t.dataset.state="closed",this._createdRoot&&oe(this.options.scope,{dialog:!1})?.append(t),this.listen(r,"input",()=>{this._query=r.value,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(r,"keydown",_=>this._onKeydown(_)),this.listen(o,"click",()=>{this.back(),r.focus()}),this.listen(c,"click",()=>this.close()),this.listen(h,"click",_=>{let m=_.target?.closest?.("[data-launcher-index]");!m||!h.contains(m)||this._activate(Number(m.getAttribute("data-launcher-index")),_)}),this.listen(h,"pointermove",_=>{let m=_.target?.closest?.("[data-launcher-index]");if(!m||!h.contains(m))return;let g=Number(m.getAttribute("data-launcher-index"));!Number.isInteger(g)||this._results[g]?.disabled||g===this._active||(this._active=g,this._syncActive())}),this.listen(t,"cancel",_=>{_.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.open||this._releaseOverlay(),t.dataset.state="closed",r.setAttribute("aria-expanded","false"),this._abortRequest(),this._pages.length&&!t.open&&(this._unwind(),this._announcePending=!1,this._syncPage(),this._renderResults(),this._emitPage()),this.emit("close")}),this.listen(document,"keydown",_=>this._onDocumentKeydown(_)),this._renderResults(),t}open(t={}){if(this._destroyed)return this;let e=t&&typeof t=="object"?t.page:void 0;if(this.isOpen()){let r=e==null?[]:this._pagePath(e);return r.length&&this._goTo(r),this}if(this._createdRoot){let r=vt(this.options.scope);this.el.parentElement!==r&&r.append(this.el)}let i=this._pages.map(r=>r.page),n=document.activeElement;return this.el.showModal(),this._releaseOverlay(),this._overlay=le({kind:"modal",root:this.el,owner:this,anchor:n}),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._goTo(e==null?[]:this._pagePath(e),{emit:!1}),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),_h(i,this._pages.map(r=>r.page))||this._emitPage(),this}back(){if(!this._pages.length)return this;let t=this._popPage();return this._syncPage(),this._announcePending=this.isOpen(),t?this._renderResults():this._refresh(!0),this._emitPage(),this}getPage(){return this._pages.at(-1)?.page??null}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=ms(t),this._renderResults(),this}setCurrent(t){let e=t==null?null:String(t);return this._items=this._items.map(i=>({...i,current:e!==null&&String(i.id)===e})),this._renderResults(),this}setSources(t){return this._sources=gh(t),this._pages.length?(this._pages[0].parent.sourceItems=null,this):(this._abortRequest(),this._sourceItems.clear(),this._refresh(),this)}_releaseOverlay(){let t=this._overlay;this._overlay=null,t?.release()}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),this._releaseOverlay(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_refresh(t=!1){this._abortRequest(),this._sourceItems.clear();let{sources:e}=this._level();if(this._settled=e.length===0,t&&e.length&&this._loadSources(),this._renderResults(),t||e.length===0)return;let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),i)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._pages?.at(-1)?.page??null,i=this._level().sources.filter(o=>er(o.when,t)&&t.length>=Math.max(o._page?0:Number(this.options.minQuery)||0,Number(o.minQuery)||0));if(i.length===0){this._settled=!0;return}let n=new AbortController,r=++this._requestSequence;this._request=n,this._setBusy(!0),await Promise.all(i.map(async o=>{try{let a=await o.load(t,{signal:n.signal});if(n.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(o.id,ms(a).map((c,d)=>({...c,_source:o._page?null:o.id,_sourceOrder:o.order==="source",group:c.group??o.label??"",itemOrder:c.itemOrder??(o.order==="source"?d:void 0)}))),this._renderResults()}catch(a){if(n.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:o,error:a,page:e})}})),!(n.signal.aborted||r!==this._requestSequence)&&(this._request=null,this._settled=!0,this._setBusy(!1))}_level(){return this._pages?.at(-1)??{items:this._items,sources:this._sources}}_openPage(t){this._pushPage(t),this._syncPage(),this._announcePending=this.isOpen(),this._refresh(!0),this._emitPage()}_goTo(t,{emit:e=!0}={}){let i=this._pages.map(n=>n.page);if(this._unwind(),t.length){this._abortRequest(),this._sourceItems.clear(),this._settled=!1;for(let n of t)this._pushPage(n)}this._syncPage(),this._announcePending=this.isOpen()&&t.length>0,this._refresh(t.length>0),e&&!_h(i,t)&&this._emitPage()}_unwind(){for(;this._pages.length;)this._popPage()}_pushPage(t){let e=this._active>=0?this._results[this._active]:null;this._pages.push({page:t,items:Array.isArray(t.items)?ms(t.items):[],sources:typeof t.items=="function"?[lw(t)]:[],parent:{query:this._query,activeId:e?String(e.id):null,sourceItems:this._settled?new Map(this._sourceItems):null}}),this._setInputQuery("")}_popPage(){let t=this._pages.pop();if(!t)return!0;this._announcePending=!1,this._abortRequest();let{parent:e}=t;return this._setInputQuery(e.query),this._sourceItems=e.sourceItems?new Map(e.sourceItems):new Map,this._settled=e.sourceItems!==null,this._restoreActiveId=e.activeId,this._settled}_setInputQuery(t){this._query=t,this.refs.input.value=t,this._renderedQuery=null}_syncPage(){let t=this.getPage(),{input:e,scope:i,scopeLabel:n,scopeBack:r,backHint:o}=this.refs;if(i.hidden=t===null,o&&(o.hidden=t===null),this.el.toggleAttribute("data-page",t!==null),t===null){e.setAttribute("aria-label",this._label),e.setAttribute("placeholder",this._placeholder),n.textContent="";return}let a=this._pages.at(-2)?.page.label??this._label;n.textContent=t.label,r.setAttribute("aria-label",this._message("launcher.back","Back to %1",a)),e.setAttribute("aria-label",this._message("launcher.pageLabel","Search %1",t.label)),e.setAttribute("placeholder",t.placeholder!=null?String(t.placeholder):this._message("launcher.pagePlaceholder","Search"))}_emitPage(){let t=this._pages.map(e=>e.page);this.emit("page",{page:t.at(-1)??null,path:t})}_pagePath(t){if(t&&typeof t=="object"){let e=t;return!xi(e)||e.label==null?[]:[bh({...e,id:e.id??e.label})]}return rw(this._items,t)}_pageStatus(){let t=this.getPage()?.label??this._label,e=this._results.length;return e===0?this._message("launcher.pageEmpty","%1, no results",t):e===1?this._message("launcher.pageResult","%1, 1 result",t):this._message("launcher.pageResults","%1, %2 results",t,e)}_setBusy(t){this._busy=t,this.el.setAttribute("aria-busy",String(t)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let t=this._query,e=this._restoreActiveId??null;this._restoreActiveId=null;let i=e??(this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null),n=this._query.trim(),r=this._level(),o=r.items.filter(m=>er(m.when,n)),a=nr(o,n,this.options.maxResults),c=r.sources.flatMap(m=>{let g=this._sourceItems.get(String(m.id))??[];return m.order==="source"?g.filter(w=>er(w.when,n)):nr(g.filter(w=>er(w.when,n)),n,this.options.maxResults)}),d=new Set,u=[...a.map(m=>({...m,_source:null})),...c].filter(m=>{let g=String(m.id);return d.has(g)?!1:(d.add(g),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let m of u){let g=String(m.group??"");h.has(g)||h.set(g,[]),h.get(g).push(m)}this._results=[...h.values()].flat(),this._renderedQuery=t;let f=i===null?-1:this._results.findIndex(m=>!m.disabled&&String(m.id)===i);this._active=f>=0?f:this._results.findIndex(m=>!m.disabled);let p=[],_=0;for(let[m,g]of h){let w=g.map(v=>this._option(v,_++));m?p.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:m,dataset:{layout:g.every(v=>v.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},m),w)):p.push(...w)}this.refs.results.replaceChildren(...p),this._syncActive(),this._renderStatus()}_option(t,e){let i=xi(t),n=i?null:V(t.href),r=n?"a":"button",o=[],a=cw(t);a&&o.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},a)),o.push(l("span",{class:"zx-launcher__copy"},l("span",{class:"zx-launcher__label"},t.label),t.description?l("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&o.push(l("span",{class:"zx-launcher__badge"},String(t.badge))),t.hint!=null&&t.hint!==""&&o.push(l("span",{class:"zx-launcher__hint"},String(t.hint)));let c=aw(t),d=ow(t.shortcut);return d.length&&o.push(l("span",{class:"zx-launcher__keys",ariaHidden:c?"true":null},d.map(u=>l("kbd",{class:"zx-launcher__key"},u)))),i&&o.push(l("span",{class:"zx-launcher__chevron",ariaHidden:"true"},b("chevron-right"))),l(r,{class:"zx-launcher__option",type:r==="button"?"button":null,href:n,target:t.target??null,rel:r==="a"?"noopener":null,role:"option",id:x("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,ariaKeyShortcuts:c,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:dw(t.kind),page:i?"true":null}},o)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText??this._message("launcher.loading","Searching\u2026")):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText??this._message("launcher.empty","No results")):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent,this._announcePending&&!this._busy&&this._renderedQuery===this._query&&(this._announcePending=!1,this._announceToggle=!this._announceToggle,this.refs.announce.textContent=this._pageStatus()+(this._announceToggle?"\xA0":""))}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let i of t){let n=Number(i.getAttribute("data-launcher-index"))===this._active;i.setAttribute("aria-selected",String(n))}let e=t.find(i=>Number(i.getAttribute("data-launcher-index"))===this._active);e?this.refs.input.setAttribute("aria-activedescendant",e.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(t){if(t.key==="Escape"){this.close();return}let e=!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(t.key==="Backspace"&&e&&!t.repeat&&this._pages.length&&this._query===""){t.preventDefault(),this.back();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let i=this._results.map((r,o)=>r.disabled?-1:o).filter(r=>r>=0);if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let r=i.length?this._spatialIndex(t.key,i):null;if(r!==null){t.preventDefault(),this._active=r,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight"){e&&!t.repeat&&this._pageKey(t.key)&&t.preventDefault();return}}if(i.length===0)return;let n=i.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")n=0;else if(t.key==="End"||t.key==="PageDown")n=i.length-1;else if(t.key==="ArrowDown")n=(n+1+i.length)%i.length;else if(t.key==="ArrowUp")n=(n-1+i.length)%i.length;else return;t.preventDefault(),this._active=i[n],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_pageKey(t){if(t==="ArrowLeft")return!this._pages.length||this._query!==""?!1:(this.back(),!0);let e=this._active>=0?this._results[this._active]:null;if(!e||e.disabled||!xi(e)||e.kind==="application")return!1;let i=this.refs.input,n=i.value.length;return i.selectionStart!==n||i.selectionEnd!==n?!1:(this._openPage(e),!0)}_spatialIndex(t,e){let i=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(i instanceof HTMLElement)||(t==="ArrowLeft"||t==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>e.includes(Number(o.getAttribute("data-launcher-index")))&&(t!=="ArrowLeft"&&t!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=uw(n,i,t);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(t,e){let i=this._results[t];if(!i||i.disabled){e.preventDefault();return}if(xi(i)){e.preventDefault(),this._openPage(i),this.refs.input.focus();return}if(this.emit("select",{item:i,value:i.value??i.id,source:i._source??null,query:this._query.trim(),page:this.getPage()}).defaultPrevented){e.preventDefault();return}this.close(),i.href||(e.preventDefault(),i.invoke?.())}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let i=document.querySelector("dialog:modal");i&&i!==this.el||(t.preventDefault(),this.open())}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function sw(){let s=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(s)?"\u2318 K":"Ctrl K"}function nw(s,t){if(s===!1)return null;let e=s&&typeof s=="object"?s:{};return l("footer",{class:"zx-launcher__hints",ariaHidden:"true"},l("span",{},l("kbd",{},"\u2191\u2193\u2190\u2192"),e.move??t.move),l("span",{},l("kbd",{},"\u21B5"),e.open??t.open),l("span",{ref:"backHint",hidden:!0},l("kbd",{},"\u232B"),e.back??t.back),l("span",{},l("kbd",{},"Esc"),e.close??t.close))}function xi(s){let t=s?.items;return!!s&&typeof s=="object"&&(Array.isArray(t)||typeof t=="function")}function rw(s,t){if(t==null)return[];let e=String(t),i=new Set,n=(r,o)=>{if(!Array.isArray(r)||i.has(r))return null;i.add(r);for(let a of ms(r)){if(!xi(a))continue;let c=[...o,a];if(String(a.id)===e)return c;let d=n(a.items,c);if(d)return d}return null};return n(s,[])??[]}function ow(s){let t=s&&typeof s=="object"&&!Array.isArray(s)?s.label:s;return(Array.isArray(t)?t:t==null?[]:[t]).filter(i=>i!=null&&String(i).trim()!=="").map(i=>String(i).trim())}function aw(s){let t=s.shortcut,e=s.keys??(t&&typeof t=="object"&&!Array.isArray(t)?t.keys:null);return typeof e=="string"&&e.trim()?e.trim():null}function lw(s){return{id:`page:${String(s.id)}`,load:s.items,order:s.order==="source"?"source":"rank",_page:!0}}function _h(s,t){return s.length===t.length&&s.every((e,i)=>e===t[i]||String(e.id)===String(t[i].id))}function cw(s){let t=s.icon;if(typeof t=="function"&&(t=t(s)),typeof t=="string")return b(t);if(t instanceof Node)return t.cloneNode(!0);if(t&&typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();return e instanceof Node?e.cloneNode(!0):null}return null}function dw(s){return s==="application"||s==="record"?s:"action"}function er(s,t){return s==="empty"?t==="":s==="query"?t!=="":!0}function uw(s,t,e){let i=t.getBoundingClientRect();if(i.width===0&&i.height===0)return null;let n=i.left+i.width/2,r=i.top+i.height/2,o=null,a=1/0;for(let c of s){if(c===t)continue;let d=c.getBoundingClientRect(),u=d.left+d.width/2-n,h=d.top+d.height/2-r,f=!1,p=1/0;e==="ArrowLeft"?(f=u<-2&&Math.abs(h)<Math.max(i.height,d.height)/2,p=Math.abs(u)+Math.abs(h)*4):e==="ArrowRight"?(f=u>2&&Math.abs(h)<Math.max(i.height,d.height)/2,p=Math.abs(u)+Math.abs(h)*4):e==="ArrowUp"?(f=h<-2,p=Math.abs(h)*10+Math.abs(u)):e==="ArrowDown"&&(f=h>2,p=Math.abs(h)*10+Math.abs(u)),f&&p<a&&(o=c,a=p)}return o}function nr(s,t,e=100){let i=Si(t).trim(),n=s.map((o,a)=>({item:o,order:a,score:hw(o,i)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=ir(o.item.groupOrder),d=ir(a.item.groupOrder);if(c!==d)return c-d;if(i===""){let u=mh(o.item.pinned,o.order),h=mh(a.item.pinned,a.order);if(u!==h)return u-h}return o.score-a.score||ir(o.item.itemOrder)-ir(a.item.itemOrder)||fw(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function hw(s,t){if(!t)return s.pinned?-1:0;let e=Si(s.label),i=Si(s.id),n=Si(Array.isArray(s.keywords)?s.keywords.join(" "):s.keywords??"");return e===t?0:e.startsWith(t)?10:e.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(t))?20:e.includes(t)||n.includes(t)?30:i.includes(t)?40:e.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(t)?50:1/0}function mh(s,t){return typeof s=="number"&&Number.isFinite(s)?s:s?t:Number.MAX_SAFE_INTEGER}function ir(s){return typeof s=="number"&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER}function Si(s){return String(s??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function fw(s,t){let e=Si(s),i=Si(t);if(e<i)return-1;if(e>i)return 1;let n=String(s??"").normalize("NFC"),r=String(t??"").normalize("NFC");return n<r?-1:n>r?1:0}function ms(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>bh(t)):[]}function bh(s){let t={...s,label:String(s.label)};if(s.href==null)return t;let e=V(s.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&!xi(t)&&(t.disabled=!0)),t}function gh(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&typeof t.load=="function").map(t=>({...t,id:String(t.id)})):[]}var Ai=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),yh=Object.freeze(Ai.filter(s=>s!=="slate")),pw=24,de=class extends y{static cssName="avatar";static defaults={src:null,name:"",initials:null,label:null,size:"md",shape:"circle",tone:null,status:null,statusLabel:null};render(){this._createdRoot=this.el===null;let t=this.el??l("span");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,r=>[r.name,r.value]),children:Array.from(t.childNodes)},this._state={src:this.options.src,name:String(this.options.name??""),initials:this.options.initials,label:this.options.label,size:this.options.size,shape:this.options.shape,tone:this.options.tone,status:this.options.status,statusLabel:this.options.statusLabel};let e=l("img",{ref:"image",class:"zx-avatar__image",alt:"",draggable:!1}),i=l("span",{ref:"fallback",class:"zx-avatar__fallback",ariaHidden:"true"}),n=l("span",{ref:"status",class:"zx-avatar__status",ariaHidden:"true",hidden:!0});return t.replaceChildren(e,i,n),this.listen(e,"load",()=>{this._isCurrentImageSource()&&this._showImage(!0)}),this.listen(e,"error",()=>{this._isCurrentImageSource()&&this._showImage(!1)}),this._sync(),t}set(t={}){if(!t||typeof t!="object")return this;for(let e of["src","name","initials","label","size","shape","tone","status","statusLabel"])Object.hasOwn(t,e)&&(this._state[e]=t[e]);return this._sync(),this}setStatus(t,e=null){return this._state.status=t,this._state.statusLabel=e,this._syncLabel(),this._syncStatus(),this}hasImage(){return!this.refs.image.hidden}destroy(){let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_sync(){let{size:t,shape:e,label:i}=this._state;this.el.dataset.size=typeof t=="string"?t:"custom",this.el.dataset.shape=["circle","rounded","square"].includes(e)?e:"circle",typeof t=="number"&&Number.isFinite(t)?this.el.style.setProperty("--zx-avatar-size",`${Math.max(1,t)}px`):this.el.style.removeProperty("--zx-avatar-size"),this._syncLabel();let n=String(this._state.name??""),r=typeof t=="number"&&t<pw?1:2;this.refs.fallback.textContent=this._state.initials?_w(String(this._state.initials),r):Te(n,r);let o=Ai.includes(this._state.tone)?this._state.tone:ue(n.trim()?n:this._state.initials);this.el.dataset.tone=o;let a=this._state.src==null?"":String(this._state.src).trim();a?(this.refs.image.setAttribute("src",a),this._showImage(this.refs.image.complete&&this.refs.image.naturalWidth>0)):(this.refs.image.removeAttribute("src"),this._showImage(!1)),this._syncStatus()}_syncLabel(){let{label:t,status:e,statusLabel:i}=this._state;if(t){let n=["online","away","busy","offline"].includes(e)?i:null;this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",[t,n].filter(Boolean).join(", ")),this.el.removeAttribute("aria-hidden")}else this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true")}_showImage(t){this.refs.image.hidden=!t,this.refs.fallback.hidden=t,this.el.dataset.fallback=String(!t)}_isCurrentImageSource(){let t=this.refs.image,e=t.getAttribute("src");if(!e)return!1;try{return t.currentSrc===new URL(e,document.baseURI).href}catch{return t.currentSrc===e}}_syncStatus(){let e=["online","away","busy","offline"].includes(this._state.status)?this._state.status:null;this.refs.status.hidden=e===null,e?this.refs.status.dataset.status=e:delete this.refs.status.dataset.status;let i=this._state.statusLabel;i?this.refs.status.setAttribute("title",String(i)):this.refs.status.removeAttribute("title")}};function Te(s,t=2){let e=String(s??"").trim().split(/\s+/u).filter(Boolean);if(e.length===0)return"?";let i=wh(e[0]),n=t>1&&e.length>1?wh(e[e.length-1]):"";return`${i}${n}`}function ue(s){let t=String(s??"").trim().normalize("NFC").toLowerCase();if(!t)return"slate";let e=2166136261;for(let i=0;i<t.length;i+=1)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return yh[(e>>>0)%yh.length]}function _w(s,t){return t>1?s:Xa(s.trim())||s}function wh(s){return Xa(Xa(s).toUpperCase())}function Xa(s){return typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(s)[Symbol.iterator]().next().value?.segment??"":Array.from(s)[0]??""}var ki=class extends y{static cssName="entity-ref";static defaults={id:null,title:"",subtitle:null,icon:null,metadata:[],link:null,actions:[],size:"md",wrap:!1,actionsLabel:"Entity actions"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._state=rr(this.options),this._renderedActions=[],t.replaceChildren(l("span",{ref:"icon",class:"zx-entity-ref__icon",ariaHidden:"true"}),l("div",{class:"zx-entity-ref__body"},l("span",{ref:"title",class:"zx-entity-ref__title"}),l("span",{ref:"subtitle",class:"zx-entity-ref__subtitle"}),l("dl",{ref:"metadata",class:"zx-entity-ref__metadata"})),l("div",{ref:"actions",class:"zx-entity-ref__actions",role:"group"})),this.listen(t,"click",e=>this._handleClick(e)),this._sync(),t}set(t={}){return!t||typeof t!="object"||Array.isArray(t)?this:(this._state=rr({...this._state,...t}),this._sync(),this)}setMetadata(t){return this.set({metadata:t})}setActions(t){return this.set({actions:t})}setLink(t){return this.set({link:t})}getEntity(){return xw(this._state)}focus(){let t=this.refs.title.querySelector("a[href]")??this.refs.actions.querySelector("a[href], button:not(:disabled)");return t&&typeof t.focus=="function"&&t.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_sync(){let t=this._state,e=this.el,i=this.refs.icon,n=this.refs.title,r=this.refs.subtitle,o=this.refs.metadata,a=this.refs.actions;e.dataset.size=t.size,e.dataset.wrap=String(t.wrap);let c=bw(t.icon);i.replaceChildren(...c===null?[]:[c]),i.hidden=c===null;let d=t.link?l("a",{class:"zx-entity-ref__primary",href:t.link.href,target:t.link.target,rel:t.link.rel,download:t.link.download===!0?"":t.link.download,dataset:{entityPrimary:""}},t.title):l("span",{class:"zx-entity-ref__name"},t.title);n.replaceChildren(d),n.hidden=t.title==="",yw(r,t.subtitle),r.hidden=Sh(t.subtitle),o.replaceChildren(...t.metadata.map(u=>l("div",{class:"zx-entity-ref__field",dataset:{labelVisible:String(u.showLabel!==!1)}},l("dt",{class:"zx-entity-ref__label"},u.label),l("dd",{class:"zx-entity-ref__value"},u.icon?b(u.icon,{size:12}):null,xh(u.value))))),o.hidden=t.metadata.length===0,this._renderedActions=t.actions,a.setAttribute("aria-label",t.actionsLabel),a.replaceChildren(...t.actions.map((u,h)=>E(u)?u:mw(u,h))),a.hidden=t.actions.length===0}_handleClick(t){let e=t.target instanceof Element?t.target:null;if(!e)return;let i=e.closest("[data-entity-primary]");if(i&&this.el.contains(i)&&this._state.link){let a={id:this._state.id,entity:this.getEntity(),href:this._state.link.href,event:t};if(this.emit("activate",a,{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}this._state.link.onclick?.(t,this.getEntity(),this);return}let n=e.closest("[data-entity-action]");if(!n||!this.refs.actions.contains(n))return;let r=this._renderedActions[Number(n.dataset.entityAction)];if(!r||E(r)||r.disabled)return;if(this.emit("action",{id:r.id,action:{...r},entity:this.getEntity(),event:t},{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}r.onselect?.(r.id,{...r},this.getEntity(),this)}};function rr(s={}){let t=s&&typeof s=="object"&&!Array.isArray(s)?s:{},e=String(t.title??""),i=gs(t.link);if(i&&!e.trim())throw new TypeError("A linked EntityRef requires a non-empty title");return{id:t.id??null,title:e,subtitle:vh(t.subtitle),icon:gw(t.icon),metadata:bs(t.metadata),link:i,actions:ys(t.actions),size:ww(t.size),wrap:!!t.wrap,actionsLabel:String(t.actionsLabel||"Entity actions")}}function gs(s){if(s==null)return null;let t=typeof s=="string"?{href:s}:s;if(!t||typeof t!="object"||Array.isArray(t))return null;let e=V(t.href);if(e===null)return null;let i=t.target==null?void 0:String(t.target),n=Ah(t.rel,i),r=t.onclick;if(r!==void 0&&typeof r!="function")throw new TypeError("EntityRef link onclick must be a function");let o=t.download,a=o===!0?!0:typeof o=="string"?o:void 0;return{href:e,...i?{target:i}:{},...n?{rel:n}:{},...a!==void 0?{download:a}:{},...r?{onclick:r}:{}}}function bs(s){return Array.isArray(s)?s.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];let e=t,i=String(e.label??"").trim(),n=vh(e.value);return!i||Sh(n)?[]:[{label:i,value:n,icon:e.icon==null?null:String(e.icon),showLabel:e.showLabel!==!1}]}):[]}function ys(s){if(!Array.isArray(s))return[];let t=new Set,e=[];for(let i of s){if(E(i)){e.push(i);continue}if(!i||typeof i!="object"||Array.isArray(i))continue;let n=i,r=String(n.id??"").trim(),o=String(n.label??""),a=String(n.title??o).trim();if(!r||!a||t.has(r)||n.href!=null&&V(n.href)===null)continue;if(n.onselect!==void 0&&typeof n.onselect!="function")throw new TypeError(`EntityRef action ${r} onselect must be a function`);t.add(r);let c=n.href==null?void 0:V(n.href),d=n.target==null?void 0:String(n.target),u=Ah(n.rel,d);e.push({...n,id:r,label:o,title:a,icon:n.icon==null?null:String(n.icon),kind:vw(n.kind),disabled:!!n.disabled,...c?{href:c}:{},...d?{target:d}:{},...u?{rel:u}:{}})}return e}function mw(s,t){let e=[s.icon?b(s.icon,{size:14}):null,s.label?l("span",{class:"zx-entity-ref__action-label"},s.label):null],i={class:"zx-entity-ref__action",title:s.title,ariaLabel:s.label||s.title,dataset:{entityAction:String(t),kind:s.kind}};return s.href&&!s.disabled?l("a",{...i,href:s.href,target:s.target,rel:s.rel},e):l("button",{...i,type:"button",disabled:!!s.disabled},e)}function gw(s){return s==null||typeof s=="string"||typeof s=="function"?s??null:ws(s)||s instanceof y?s:null}function bw(s){let t=typeof s=="function"?s():s;return typeof t=="string"?b(t,{size:18}):t instanceof y?t.toElement():ws(t)?t:null}function vh(s){return s==null?null:typeof s=="string"||typeof s=="number"||ws(s)||s instanceof y?s:String(s)}function yw(s,t){s.replaceChildren(xh(t))}function xh(s){return s instanceof y?s.toElement():ws(s)?s:s==null?"":String(s)}function Sh(s){return s==null||!ws(s)&&!(s instanceof y)&&String(s)===""}function ws(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function ww(s){return s==="sm"||s==="lg"?s:"md"}function vw(s){return s==="default"||s==="primary"||s==="danger"?s:"ghost"}function Ah(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function xw(s){return Object.freeze({...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:s.actions.map(t=>E(t)?t:{...t})})}var Sw=new Set(["ready","temporary","waiting","uploading","processing","success","error"]),Aw=Object.freeze({ready:"",temporary:"Temporary",waiting:"Waiting",uploading:"Uploading",processing:"Processing",success:"Complete",error:"Failed"}),zi=class extends y{static cssName="file-item";static defaults={id:null,name:"",size:null,mime:"",typeLabel:null,subtitle:null,icon:"file",metadata:[],link:null,actions:[],status:"ready",statusLabel:null,progress:null,indeterminate:!1,identitySize:"md",wrap:!1,actionsLabel:"File actions"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._state=he(this.options);let e=l("div",{ref:"entity",class:"zx-file-item__entity"});return t.replaceChildren(e,l("div",{ref:"status",class:"zx-file-item__status",role:"status"}),l("div",{ref:"progress",class:"zx-file-item__progress"},l("div",{ref:"progressHead",class:"zx-file-item__progress-head"}),l("div",{ref:"progressTrack",class:"zx-file-item__progress-track",role:"progressbar",ariaValuemin:"0",ariaValuemax:"100"},l("div",{ref:"progressFill",class:"zx-file-item__progress-fill"})))),this._entity=new ki(e,kh(this._state)),this.listen(this._entity.el,"zx-activate",i=>this._forwardActivate(i)),this.listen(this._entity.el,"zx-action",i=>this._forwardAction(i)),this._sync(),t}set(t={}){return!t||typeof t!="object"||Array.isArray(t)?this:(this._state=he({...this._state,...t}),this._sync(),this)}setStatus(t,e){return this.set({status:t,...e===void 0?{}:{statusLabel:e}})}setProgress(t,{indeterminate:e=!1}={}){return this.set({progress:t,indeterminate:e})}getFile(){return Ow(this._state)}focus(){return this._entity.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;this._entity?.destroy(),super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_sync(){let t=this._state,e=this.el,i=this.refs.status,n=this.refs.progress,r=this.refs.progressTrack,o=this.refs.progressFill;e.dataset.status=t.status,e.dataset.identitySize=t.identitySize,this._entity.set(kh(t));let a=Ew(t);i.replaceChildren(...a?[ht({label:a,kind:Mw(t.status),size:"sm",dot:t.status!=="ready"})]:[]),i.hidden=a==="";let c=t.indeterminate||t.progress!==null;if(n.hidden=!c,n.toggleAttribute("data-indeterminate",t.indeterminate),!c)return;let d=`${a||"Progress"}${t.indeterminate||t.progress===null?"":` \u2014 ${Math.round(t.progress)}%`}`;if(this.refs.progressHead.textContent=d,r.setAttribute("aria-label",`${t.name||"File"}: ${a||"Progress"}`),t.indeterminate)r.removeAttribute("aria-valuenow"),r.removeAttribute("aria-valuetext"),o.style.removeProperty("--zx-file-progress");else{let u=t.progress??0;r.setAttribute("aria-valuenow",String(u)),r.setAttribute("aria-valuetext",`${Math.round(u)}%`),o.style.setProperty("--zx-file-progress",`${u}%`)}}_forwardActivate(t){let e=t.detail??{};this.emit("activate",{id:this._state.id,file:this.getFile(),href:String(e.href??""),event:e.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_forwardAction(t){let e=t.detail??{};this.emit("action",{id:String(e.id??""),fileId:this._state.id,action:e.action??{},file:this.getFile(),event:e.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}};function he(s={}){let t=s&&typeof s=="object"&&!Array.isArray(s)?s:{},e=t.size==null||t.size===""?null:Number(t.size),i=t.progress==null?null:Number(t.progress),n=Sw.has(String(t.status))?String(t.status):"ready";return{id:t.id??null,name:String(t.name??""),size:e!==null&&Number.isFinite(e)&&e>=0?e:null,mime:String(t.mime??""),typeLabel:t.typeLabel==null?null:String(t.typeLabel),subtitle:Dw(t.subtitle),icon:t.icon===void 0?"file":t.icon,metadata:bs(t.metadata),link:gs(t.link),actions:ys(t.actions),status:n,statusLabel:t.statusLabel==null?null:String(t.statusLabel),progress:i===null||!Number.isFinite(i)?null:Math.min(100,Math.max(0,i)),indeterminate:!!t.indeterminate,identitySize:t.identitySize==="sm"||t.identitySize==="lg"?t.identitySize:"md",wrap:!!t.wrap,actionsLabel:String(t.actionsLabel||"File actions"),locale:Nw(t.locale)}}function kh(s){let t=[],e=s.typeLabel??Tw(s.mime,s.name);return e&&t.push({label:"Type",value:e,showLabel:!1}),s.size!==null&&t.push({label:"Size",value:li(s.size,{locale:s.locale}),showLabel:!1}),t.push(...s.metadata),{id:s.id,title:s.name,subtitle:s.subtitle,icon:s.icon==="file"?Iw(s.mime):s.icon,metadata:t,link:s.link,actions:s.actions,size:s.identitySize,wrap:s.wrap,actionsLabel:s.actionsLabel}}var kw=Object.freeze({pdf:{label:"PDF",icons:["file-pdf"]},csv:{label:"CSV",icons:["file-csv","file-excel"]},tsv:{label:"TSV",icons:["file-csv","file-excel"]},spreadsheet:{label:"Spreadsheet",icons:["file-excel"]},document:{label:"Document",icons:["file-word","file-lines"]},presentation:{label:"Presentation",icons:["file-powerpoint"]},text:{label:"Text",icons:["file-lines"]},markdown:{label:"Markdown",icons:["file-lines"]},html:{label:"HTML",icons:["file-code","code"]},css:{label:"CSS",icons:["file-code","code"]},javascript:{label:"JavaScript",icons:["file-code","code"]},json:{label:"JSON",icons:["file-code","code"]},xml:{label:"XML",icons:["file-code","code"]},zip:{label:"ZIP",icons:["file-zipper"]},gzip:{label:"GZIP",icons:["file-zipper"]},tar:{label:"TAR",icons:["file-zipper"]},rar:{label:"RAR",icons:["file-zipper"]},sevenZip:{label:"7Z",icons:["file-zipper"]},email:{label:"Email",icons:["envelope"]},calendar:{label:"Calendar",icons:["calendar"]},contact:{label:"Contact",icons:["address-card"]},image:{label:"Image",icons:["file-image","image"]},video:{label:"Video",icons:["file-video","video"]},audio:{label:"Audio",icons:["file-audio"]},font:{label:"Font",icons:["font"]}}),zw=new Map(Object.entries({"application/pdf":"pdf","text/csv":"csv","application/csv":"csv","text/comma-separated-values":"csv","text/tab-separated-values":"tsv","application/vnd.ms-excel":"spreadsheet","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"spreadsheet","application/vnd.oasis.opendocument.spreadsheet":"spreadsheet","application/msword":"document","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"document","application/vnd.oasis.opendocument.text":"document","application/rtf":"document","text/rtf":"document","application/vnd.ms-powerpoint":"presentation","application/vnd.openxmlformats-officedocument.presentationml.presentation":"presentation","application/vnd.oasis.opendocument.presentation":"presentation","text/plain":"text","text/markdown":"markdown","text/x-markdown":"markdown","text/html":"html","application/xhtml+xml":"html","text/css":"css","text/javascript":"javascript","application/javascript":"javascript","application/json":"json","application/ld+json":"json","application/xml":"xml","text/xml":"xml","application/zip":"zip","application/x-zip-compressed":"zip","application/gzip":"gzip","application/x-gzip":"gzip","application/x-tar":"tar","application/vnd.rar":"rar","application/x-rar-compressed":"rar","application/x-7z-compressed":"sevenZip","message/rfc822":"email","text/calendar":"calendar","text/vcard":"contact","text/x-vcard":"contact"})),Cw=new Map([["image","image"],["video","video"],["audio","audio"],["font","font"],["text","text"]]);function zh(s){let t=String(s??"").split(";")[0].trim().toLowerCase();if(!t)return null;let e=zw.get(t)??Cw.get(t.split("/")[0]);return e?kw[e]:null}function Tw(s,t=""){if(!String(s??"").trim())return"";let e=zh(s);if(e)return e.label;let i=/\.([a-z0-9]{1,5})$/i.exec(String(t??""))?.[1];return i?i.toUpperCase():""}function Iw(s){let t=zh(s)?.icons??[];if(!t.length)return"file";if(Ke().provider==="fontawesome")return t[0];let e=new Set(en());return t.find(i=>e.has(i))??"file"}function Ew(s){return s.statusLabel===null?Aw[s.status]:s.statusLabel}function Mw(s){return s==="error"?"danger":s==="success"?"success":s==="temporary"||s==="waiting"?"warning":s==="uploading"?"info":s==="processing"?"accent":"neutral"}function Dw(s){return s==null?null:typeof s=="string"||typeof s=="number"||s instanceof y||typeof s=="object"&&typeof s.nodeType=="number"?s:String(s)}function Nw(s){if(typeof s=="string"&&s.trim())return s}function Ow(s){return Object.freeze({...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:s.actions.map(t=>E(t)?t:{...t})})}var or=class extends y{static cssName="file-list";static defaults={items:[],label:"Files",loading:!1,loadingCount:3,loadingText:"Loading files",emptyText:"No files"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("section");this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._items=ar(this.options.items),this._loading=!!this.options.loading,this._itemComponents=[],this._itemRecords=new Map,this._itemList=null,this._emptyRegion=null,this._loadingRegion=null,this._loadingPlaceholders=!1,t.setAttribute("aria-label",String(this.options.label||"Files")),this.listen(t,"zx-activate",e=>this._forwardActivate(e)),this.listen(t,"zx-action",e=>this._forwardAction(e));try{return this._renderList(),t}catch(e){throw this._destroyItems(),this._createdRoot||S(t,this._snapshot),e}}setItems(t,e={}){return this._items=ar(t),this._renderList(),e.silent||this._emitDataChange(),this}getItems(){return this._itemComponents.map(t=>t.getFile())}getItem(t){return this._itemComponents.find(i=>Object.is(i.getFile().id,t))?.getFile()??null}addItem(t,e=this._items.length,i={}){let n=Math.max(0,Math.min(this._items.length,Math.trunc(Number(e))||0)),r=this._items.slice();return r.splice(n,0,he(t)),this.setItems(r,i)}updateItem(t,e,i={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("FileList update values must be an object");let n=this._items.findIndex(o=>Object.is(o.id,t));if(n<0)return this;let r=this._items.slice();return r[n]=he({...r[n],...e}),this.setItems(r,i)}removeItem(t,e={}){let i=this._items.findIndex(r=>Object.is(r.id,t));if(i<0)return this;let n=this._items.slice();return n.splice(i,1),this.setItems(n,e)}setLoading(t){let e=!!t;return e===this._loading?this:(this._loading=e,this._renderList(),this)}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;this._destroyItems(),super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_renderList(){let t=this.el,e=hn(t,n=>{let r=this._itemComponents.findIndex(o=>o.el?.contains(n));return r<0?null:{key:{component:this._itemComponents[r],index:r},element:this._itemComponents[r].el}});t.setAttribute("aria-busy",String(this._loading));try{this._reconcileItems()}catch(n){throw this._destroyItems(),n}let i=[];this._items.length?i.push(this._itemList):this._loading||(this._emptyRegion??=l("div",{class:"zx-file-list__empty",role:"status"},Lw(this.options.emptyText,"FileList emptyText")),i.push(this._emptyRegion)),this._loading&&i.push(this._createLoading(this._items.length===0)),Ch(t,i),fn(t,e,n=>{let r=n;return this._itemComponents.includes(r.component)?r.component.el:this._itemComponents[Math.min(r.index,this._itemComponents.length-1)]?.el??null})}_reconcileItems(){let t=this._itemComponents,e=new Map;for(let o of t){let a=this._itemRecords.get(o)?.state.id??null;a!==null&&e.set(a,o)}let i=[];for(let o of this._items){let a=o.id===null?void 0:e.get(o.id);if(a){e.delete(o.id);let d=this._itemRecords.get(a);Ja(d.state,o)||a.set(o),d.state=o,i.push(a);continue}let c=new zi(null,o);this._itemRecords.set(c,{row:l("li",{class:"zx-file-list__item"},c),state:o}),i.push(c)}let n=new Set(i);for(let o of t)n.has(o)||(this._itemRecords.get(o)?.row.remove(),this._itemRecords.delete(o),o.destroy());if(this._itemComponents=i,i.length===0)return;let r=this._itemList??=l("ol",{class:"zx-file-list__items"});Ch(r,i.map(o=>this._itemRecords.get(o).row))}_createLoading(t){return this._loadingRegion&&this._loadingPlaceholders===t?this._loadingRegion:(this._loadingPlaceholders=t,this._loadingRegion=this._buildLoading(t),this._loadingRegion)}_buildLoading(t){let e=l("div",{class:"zx-file-list__loading",role:"status",ariaLive:"polite"},l("span",{class:"zx-file-list__loading-label"},String(this.options.loadingText)));if(!t)return e;let i=l("div",{class:"zx-file-list__skeletons",ariaHidden:"true"});for(let n=0;n<Rw(this.options.loadingCount);n+=1)i.append(l("div",{class:"zx-file-list__skeleton"},ot({width:"2rem",height:"2rem",radius:"md"}),yi({lines:2,lastLineWidth:n%2?"48%":"64%"})));return e.append(i),e}_destroyItems(){for(let t of this._itemComponents)t.destroy();this._itemComponents=[],this._itemRecords?.clear(),this._itemList?.replaceChildren()}_forwardActivate(t){let e=this._componentForEvent(t);if(!e)return;let i=this._itemComponents.indexOf(e),n=t.detail??{},r=e.getFile();this.emit("activate",{id:r.id,index:i,file:r,href:String(n.href??""),event:n.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_forwardAction(t){let e=this._componentForEvent(t);if(!e)return;let i=this._itemComponents.indexOf(e),n=t.detail??{},r=e.getFile();this.emit("action",{id:String(n.id??""),fileId:r.id,index:i,action:n.action??{},file:r,event:n.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_componentForEvent(t){return t.target===this.el?null:this._itemComponents.find(e=>t.target===e.el)??null}_emitDataChange(){this.emit("datachange",{items:this.getItems()})}};function ar(s){if(!Array.isArray(s))throw new TypeError("FileList items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("FileList items must be descriptor objects");let i=he(e);if(i.id!==null){if(t.has(i.id))throw new RangeError(`Duplicate FileList id: ${String(i.id)}`);t.add(i.id)}return Fw(i)})}function Fw(s){return{...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:[...s.actions],locale:s.locale}}function Ch(s,t){let e=new Set(t);for(let i of[...s.childNodes])e.has(i)||i.remove();t.forEach((i,n)=>{let r=s.childNodes[n]??null;r!==i&&s.insertBefore(i,r)})}function Ja(s,t){if(Object.is(s,t))return!0;if(Array.isArray(s)&&Array.isArray(t))return s.length===t.length&&s.every((i,n)=>Ja(i,t[n]));if(!Th(s)||!Th(t))return!1;let e=Object.keys(s);return e.length===Object.keys(t).length&&e.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Ja(s[i],t[i]))}function Th(s){if(!s||typeof s!="object")return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function Lw(s,t){if(s==null)return"";if(typeof s=="string"||typeof s=="number")return String(s);if(s instanceof y)return s.toElement();if(typeof s=="object"&&typeof s.nodeType=="number")return s;throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function Rw(s){let t=Math.trunc(Number(s));return Number.isFinite(t)?Math.max(1,Math.min(12,t)):3}var Ci=class extends y{static cssName="activity-item";static defaults={id:null,actor:"",avatar:null,title:"",content:null,timestamp:null,timeLabel:null,metadata:[],attachments:[],actions:[],kind:"default",state:"default",stateLabel:null,headingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("li");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._headingId=x("zx-activity-item-heading"),this._avatarComponent=null,this._actionsByKey=new Map,this._activity=Eh(this.options);try{return this.listen(e,"click",i=>this._onClick(i)),this._renderActivity(),e}catch(i){throw this._avatarComponent?.destroy(),this._avatarComponent=null,t||S(e,this._original),i}}setActivity(t={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("ActivityItem values must be an object");return this._activity=Eh({...this._activity,...t}),this._renderActivity(),this}getActivity(){return Mh(this._activity)}destroy(){this._cleaned||(this._cleaned=!0,this._avatarComponent?.destroy(),this._avatarComponent=null,super.destroy(),this._createdRoot||S(this.el,this._original))}_renderActivity(){this._avatarComponent?.destroy(),this._avatarComponent=null,this._actionsByKey.clear();let t=this._activity,e=this.el,i=$w(t.id);i===null?delete e.dataset.activityId:e.dataset.activityId=i,e.dataset.kind=Kw(t.kind);let n=Pw(t.state,t.stateLabel);e.dataset.state=n.state,n.busy?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy");let r=vs(t.actor,"Activity actor"),o=vs(t.title,"Activity title"),a=[];r!==null&&a.push(l("span",{class:"zx-activity-item__actor"},r)),o!==null&&(a.length&&a.push(" "),a.push(l("span",{class:"zx-activity-item__title"},o)));let c=a.length?l(`h${Gw(t.headingLevel)}`,{class:"zx-activity-item__heading",id:this._headingId},a):null,d=Vw(t.timestamp,t.timeLabel),u=this._createStateBadge(n),h=c||d||u?l("header",{class:"zx-activity-item__header"},c,u,d):null,f=vs(t.content,"Activity content"),p=f===null?null:l("div",{class:"zx-activity-item__body"},f),_=jw(t.metadata,"zx-activity-item__metadata","Activity metadata",this._message("activityItem.metadata","Activity metadata")),m=Hw(t.attachments,"zx-activity-item__attachments","Attachments",this._message("activityItem.attachments","Attachments")),g=this._createActions(t.actions),w=l("div",{class:"zx-activity-item__main"},h,p,_,m,g),v=this._createAvatar(t.avatar,t.actor),z=l("article",{class:"zx-activity-item__article",ariaLabelledby:c?this._headingId:void 0,ariaLabel:c?void 0:this._message("activityItem.label","Activity")},v?l("div",{class:"zx-activity-item__avatar"},v):null,w);e.replaceChildren(z)}_createStateBadge(t){if(t.key===null||t.fallback===null)return null;let e=ht({label:t.label??this._message(t.key,t.fallback),kind:t.kind,size:"sm"});return e.classList.add("zx-activity-item__state"),e}_createAvatar(t,e){if(t===null)return null;if(E(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("ActivityItem avatar must be an Element, descriptor, or null");let i={...t,name:t.name||Za(e),label:t.label??null,size:t.size??"md"};return this._avatarComponent=new de(null,i),this._avatarComponent.toElement()}_createActions(t){let e=tl(t);if(e.length===0)return null;let i=e.map((r,o)=>{if(E(r))return r;let a=String(o);return this._actionsByKey.set(a,r),Bw(r,a)}),n=qw(this._activity,this._message("activityItem.untitled","activity"));return l("div",{class:"zx-activity-item__actions",role:"group",ariaLabel:this._message("activityItem.actions","Actions for %1",n)},i)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}_onClick(t){let i=(t.target&&typeof t.target=="object"?t.target:null)?.closest?.("[data-activity-action]")??null;if(!i||!this.el.contains(i))return;let n=this._actionsByKey.get(i.dataset.activityAction??"");if(!n||n.disabled){t.preventDefault();return}if(this.emit("action",{id:n.id,action:n,event:t},{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}n.onselect?.(t)}};function tl(s){if(!Array.isArray(s))return[];let t=[],e=new Set;for(let i of s){if(E(i)){t.push(i);continue}let n=el(i);!n||e.has(n.id)||(e.add(n.id),t.push(n))}return t}function el(s){if(!s||typeof s!="object"||Array.isArray(s))return null;let t=s;if(t.id===null||t.id===void 0)return null;let e=String(t.id).trim();if(!e)return null;let i=t.label==null?"":String(t.label),n=t.icon==null?null:String(t.icon).trim()||null,r=t.title==null?void 0:String(t.title);if(!i&&!r)return null;let o=t.href!==null&&t.href!==void 0,a=o?V(t.href):null;if(o&&a===null||t.onselect!==void 0&&typeof t.onselect!="function")return null;let c=t.target==null?void 0:String(t.target);return{id:e,label:i,icon:n,href:a,target:c,rel:Yw(t.rel,c),title:r,disabled:!!t.disabled,kind:Uw(t.kind),onselect:t.onselect}}var Ih=Object.freeze({pending:Object.freeze({busy:!0,key:"activityItem.pending",fallback:"Sending\u2026",kind:"neutral"}),failed:Object.freeze({busy:!1,key:"activityItem.failed",fallback:"Failed",kind:"danger"})});function Pw(s,t){let e=String(s??"default"),i=Object.prototype.hasOwnProperty.call(Ih,e)?Ih[e]:null;return i?{state:e,busy:i.busy,key:i.key,fallback:i.fallback,kind:i.kind,label:t==null||t===""?null:String(t)}:{state:"default",busy:!1,key:null,fallback:null,kind:"neutral",label:null}}function il(s,t){let e=t==null?"":String(t).trim();if(s==null||s==="")return e?{dateTime:null,label:e}:null;let i=s instanceof Date?new Date(s.getTime()):new Date(s);if(Number.isNaN(i.getTime())){let n=e||(typeof s=="string"?s.trim():"");return n?{dateTime:null,label:n}:null}return{dateTime:i.toISOString(),label:e||Ww(i)}}function Eh(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ActivityItem options must be an object");for(let t of["metadata","attachments","actions"])if(!Array.isArray(s[t]))throw new TypeError(`ActivityItem ${t} must be an array`);return Mh(s)}function Mh(s){let t=s.avatar&&!E(s.avatar)?{...s.avatar}:s.avatar??null;return{...s,avatar:t,metadata:[...s.metadata??[]],attachments:[...s.attachments??[]],actions:[...s.actions??[]]}}function Bw(s,t){if(s.href&&!s.disabled){let i=l("a",{class:"zx-btn zx-activity-item__action",href:s.href,target:s.target,rel:s.rel,title:s.title,dataset:{activityAction:t,kind:s.kind,size:"sm"}});return s.icon&&i.append(b(s.icon,{size:16})),s.label&&i.append(l("span",{class:"zx-btn__label"},s.label)),!s.label&&s.title&&i.setAttribute("aria-label",s.title),i}let e=j({label:s.label,icon:s.icon,kind:s.kind,size:"sm",disabled:s.disabled,title:s.title});return e.classList.add("zx-activity-item__action"),e.dataset.activityAction=t,e}function Vw(s,t){let e=il(s,t);return e?e.dateTime===null?l("span",{class:"zx-activity-item__time"},e.label):l("time",{class:"zx-activity-item__time",dateTime:e.dateTime,title:e.label},e.label):null}function jw(s,t,e,i){return s.length===0?null:l("ul",{class:t,ariaLabel:i},s.map(n=>l("li",{class:`${t}-item`},vs(n,e))))}function Hw(s,t,e,i){return s.length===0?null:l("div",{class:t,role:"group",ariaLabel:i},s.map(n=>l("div",{class:`${t}-item`},vs(n,e))))}function vs(s,t){if(s===null||s==="")return null;if(typeof s=="string"||typeof s=="number")return String(s);if(s&&typeof s=="object"&&typeof s.nodeType=="number")return s;if(s instanceof y)return s.toElement();throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function Za(s){return s===null?"":typeof s=="string"||typeof s=="number"?String(s).trim():s&&typeof s=="object"&&typeof s.nodeType=="number"?s.textContent?.trim()??"":s instanceof y?s.toElement().textContent?.trim()??"":""}function qw(s,t){return Za(s.title)||Za(s.actor)||t}function $w(s){return typeof s=="string"||typeof s=="number"?String(s):null}function Kw(s){return String(s??"default").trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-")||"default"}function Uw(s){return["default","primary","danger"].includes(String(s))?s:"ghost"}function Yw(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function Gw(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}function Ww(s){try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(s)}catch{return s.toLocaleString()}}var cr=class extends y{static cssName="activity-list";static defaults={items:[],groupBy:null,groupLabel:null,label:"Activity",variant:"default",loading:!1,loadingCount:3,loadingText:"Loading activity",emptyText:"No activity yet",groupHeadingLevel:2,itemHeadingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._items=Rt(this.options.items),this._loading=!!this.options.loading,this._itemComponents=[],this._groupSequence=0,e.setAttribute("aria-label",String(this.options.label||"Activity")),this._variant=Xw(this.options.variant),this._variant==="compact"&&(e.dataset.variant="compact");try{return this._renderList(),e}catch(i){throw this._destroyItems(),t||S(e,this._original),i}}setItems(t,e={}){return this._items=Rt(t),this._renderList(),e.silent||this._emitDataChange(),this}getItems(){return this._items.map(lr)}getItem(t){let e=this._items.find(i=>Object.is(i.id,t));return e?lr(e):null}appendItems(t,e={}){let i=Rt(Array.isArray(t)?t:[t]);return i.length===0?this:(this._items=Rt([...this._items,...i]),this._renderList(),e.silent||this._emitDataChange(),this)}prependItems(t,e={}){let i=Rt(Array.isArray(t)?t:[t]);return i.length===0?this:(this._items=Rt([...i,...this._items]),this._renderList(),e.silent||this._emitDataChange(),this)}updateItem(t,e,i={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("ActivityList update values must be an object");let n=this._items.findIndex(o=>Object.is(o.id,t));if(n<0)return this;let r=this._items.slice();return r[n]={...r[n],...e},this._items=Rt(r),this._renderList(),i.silent||this._emitDataChange(),this}removeItem(t,e={}){let i=this._items.findIndex(n=>Object.is(n.id,t));return i<0?this:(this._items.splice(i,1),this._renderList(),e.silent||this._emitDataChange(),this)}setLoading(t){let e=!!t;return e===this._loading?this:(this._loading=e,this._renderList(),this)}destroy(){this._cleaned||(this._cleaned=!0,this._destroyItems(),super.destroy(),this._createdRoot||S(this.el,this._original))}_renderList(){let t=this.el,e=hn(t,i=>{let n=this._itemComponents.findIndex(o=>o.el?.contains(i));if(n<0)return null;let r=this._itemComponents[n];return{key:{id:r.getActivity().id??null,index:n},element:r.el}});this._renderItems(),fn(t,e,i=>{let n=i;return((n.id===null?void 0:this._itemComponents.find(a=>Object.is(a.getActivity().id??null,n.id)))??this._itemComponents[Math.min(n.index,this._itemComponents.length-1)])?.el??null})}_renderItems(){this._destroyItems(),this._groupSequence=0;let t=this.el;t.setAttribute("aria-busy",String(this._loading));let e=[];try{if(this._items.length>0){let i=this.options.groupBy??null,n=sl(this._items,i),r=i!==null;for(let o of n)e.push(this._createGroup(o,r))}else this._loading||e.push(l("div",{class:"zx-activity-list__empty",role:"status"},Dh(this.options.emptyText,"ActivityList emptyText")));this._loading&&e.push(this._createLoading(this._items.length===0)),t.replaceChildren(...e)}catch(i){throw this._destroyItems(),i}}_createGroup(t,e){let i=l("ol",{class:"zx-activity-list__items"});for(let o of t.items){let a=new Ci(null,{...o,avatar:this._variant==="compact"?Jw(o.avatar):o.avatar,headingLevel:o.headingLevel??this.options.itemHeadingLevel});this._itemComponents.push(a),i.append(a.toElement())}if(!e)return i;this._groupSequence+=1;let n=x(`zx-activity-list-group-${this._groupSequence}`),r=this.options.groupLabel?this.options.groupLabel(t.id,t.items.map(lr)):String(t.id??"Other");return i.setAttribute("aria-labelledby",n),l("section",{class:"zx-activity-list__group",ariaLabelledby:n},l(`h${Qw(this.options.groupHeadingLevel,2)}`,{class:"zx-activity-list__group-heading",id:n},Dh(r,"ActivityList groupLabel")),i)}_createLoading(t){let e=l("div",{class:"zx-activity-list__loading",role:"status",ariaLive:"polite"},l("span",{class:"zx-activity-list__loading-label"},String(this.options.loadingText)));if(!t)return e;let i=l("div",{class:"zx-activity-list__skeletons",ariaHidden:"true"}),n=Zw(this.options.loadingCount);for(let r=0;r<n;r+=1)i.append(l("div",{class:"zx-activity-list__skeleton"},ot({width:"2.25rem",height:"2.25rem",radius:"full"}),yi({lines:2,heading:!0,lastLineWidth:r%2?"58%":"72%"})));return e.append(i),e}_destroyItems(){for(let t of this._itemComponents)t.destroy();this._itemComponents.length=0}_emitDataChange(){this.emit("datachange",{items:this.getItems()})}};function sl(s,t=null){let e=Rt(s);if(t===null)return e.length?[{id:null,items:e}]:[];if(typeof t!="string"&&typeof t!="function")throw new TypeError("ActivityList groupBy must be a property, function, or null");let i=new Map;return e.forEach((n,r)=>{let o=typeof t=="function"?t(n,r):n[t];i.has(o)||i.set(o,[]),i.get(o).push(n)}),Array.from(i,([n,r])=>({id:n,items:r}))}function Rt(s){if(!Array.isArray(s))throw new TypeError("ActivityList items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("ActivityList items must be descriptor objects");for(let n of["metadata","attachments","actions"])if(e[n]!==void 0&&!Array.isArray(e[n]))throw new TypeError(`ActivityList item ${n} must be an array`);let i=e;if(i.id!==null&&i.id!==void 0){if(t.has(i.id))throw new RangeError(`Duplicate ActivityList id: ${String(i.id)}`);t.add(i.id)}return lr(i)})}function lr(s){let t=s.avatar&&Nh(s.avatar)?{...s.avatar}:s.avatar;return{...s,avatar:t,metadata:[...s.metadata??[]],attachments:[...s.attachments??[]],actions:[...s.actions??[]]}}function Dh(s,t){if(s===null)return"";if(typeof s=="string"||typeof s=="number")return String(s);if(s&&typeof s=="object"&&typeof s.nodeType=="number")return s;if(s instanceof y)return s.toElement();throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function Nh(s){return!s||typeof s!="object"||Array.isArray(s)?!1:typeof s.nodeType!="number"&&!(s instanceof y)}function Qw(s,t){let e=Math.trunc(Number(s));return e>=1&&e<=6?e:t}function Xw(s){return s==="compact"?"compact":"default"}function Jw(s){if(!Nh(s))return s;let t=s;return t.size==null?{...t,size:"sm"}:t}function Zw(s){let t=Math.trunc(Number(s));return Number.isFinite(t)?Math.max(1,Math.min(12,t)):3}var dr=class extends y{static cssName="account-menu";static defaults={account:{},items:[],compact:!1,label:null,placement:"top-start"};constructor(t=null,e={}){super(t,e);for(let i of["select","open","close"])this.listen(this.refs.trigger,`zx-${i}`,n=>n.stopPropagation());this._avatar=new de(this.refs.avatar,Fh(this._account)),this._menu=new at(this.refs.trigger,{items:this.options.items,placement:this.options.placement}),this._menu.on("select",i=>{this.emit("select",i.detail).defaultPrevented&&i.preventDefault()}),this._menu.on("open",()=>this.emit("open")),this._menu.on("close",()=>this.emit("close")),this._renderIdentity()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._account=Oh(this.options.account),t.dataset.compact=String(!!this.options.compact),t.replaceChildren(l("button",{ref:"trigger",class:"zx-account-menu__trigger",type:"button"},l("span",{ref:"avatar",class:"zx-account-menu__avatar"}),l("span",{class:"zx-account-menu__identity"},l("span",{ref:"name",class:"zx-account-menu__name"}),l("span",{ref:"secondary",class:"zx-account-menu__secondary"})),l("span",{class:"zx-account-menu__chevron",ariaHidden:"true"},b("chevron-down")))),t}open(){return this._menu.open(),this}close(){return this._menu.close(),this}toggle(){return this._menu.toggle(),this}isOpen(){return this._menu.isOpen()}setAccount(t){return this._account=Oh(t),this._avatar.set(Fh(this._account)),this._renderIdentity(),this}setCompact(t){return this.el.dataset.compact=String(!!t),this}setItems(t){return this._menu.setItems(t),this._renderPanelHeader(),this}focus(){return this._menu.getTrigger().focus(),this}getPanel(){return this._menu.getPanel()}destroy(){let t=this._original;if(this._menu.destroy(),this._avatar.destroy(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_renderIdentity(){this.refs.name.textContent=this._account.name,this.refs.secondary.textContent=this._account.secondary,this.refs.secondary.hidden=!this._account.secondary;let e=["online","away","busy","offline"].includes(this._account.status)&&this._account.statusLabel?`, ${this._account.statusLabel}`:"",i=this.options.label||`Account menu${this._account.name?` for ${this._account.name}`:""}${e}`;this.refs.trigger.setAttribute("aria-label",i),this._renderPanelHeader()}_renderPanelHeader(){let t=this._menu.getPanel();t.querySelector(".zx-account-menu__panel-identity")?.remove(),t.prepend(l("div",{class:"zx-account-menu__panel-identity",role:"presentation"},l("strong",{},this._account.name||"Account"),this._account.secondary?l("span",{},this._account.secondary):null))}};function Oh(s){let t=s&&typeof s=="object"?s:{};return{...t,name:String(t.name??""),secondary:String(t.secondary??"")}}function Fh(s){return{name:s.name,src:s.src??null,initials:s.initials??null,status:s.status??null,statusLabel:s.statusLabel??null,label:null,size:"md"}}var hr=class extends y{static cssName="workspace-switcher";static defaults={workspaces:[],active:null,items:[],compact:!1,heading:null,label:null,placement:"bottom-start"};constructor(t=null,e={}){super(t,e);for(let i of["select","open","close"])this.listen(this.refs.trigger,`zx-${i}`,n=>n.stopPropagation());this._menu=new at(this.refs.trigger,{items:[],placement:this.options.placement}),this._menu.getPanel().classList.add("zx-workspace-switcher__menu"),this._menu.on("select",i=>this._onMenuSelect(i)),this._menu.on("open",()=>this.emit("open")),this._menu.on("close",()=>this.emit("close")),this._sync()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._workspaces=Lh(this.options.workspaces),this._activeId=Rh(this._workspaces,this.options.active),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._entries=new Map,t.dataset.compact=String(!!this.options.compact),t.replaceChildren(l("button",{ref:"trigger",class:"zx-workspace-switcher__trigger",type:"button"},l("span",{ref:"tile",class:"zx-workspace-switcher__tile",ariaHidden:"true"}),l("span",{class:"zx-workspace-switcher__text"},l("span",{ref:"name",class:"zx-workspace-switcher__name"}),l("span",{ref:"secondary",class:"zx-workspace-switcher__secondary"})),l("span",{class:"zx-workspace-switcher__chevron",ariaHidden:"true"},b("chevron-down")))),t}getActive(){return nl(this._workspaces,this._activeId)}setActive(t,{silent:e=!0}={}){let i=nl(this._workspaces,t);return!i||i.disabled||ur(i.id,this._activeId)?this:!e&&this._emitSelect(i).defaultPrevented?this:(this._activeId=i.id,this._sync(),this)}setWorkspaces(t){return this._workspaces=Lh(t),this._activeId=Rh(this._workspaces,this._activeId),this._sync(),this}setItems(t){return this._items=Array.isArray(t)?t.slice():[],this._renderMenu(),this}setCompact(t){return this.el.dataset.compact=String(!!t),this._renderTrigger(),this}open(){return this._menu.open(),this}close(){return this._menu.close(),this}toggle(){return this._menu.isOpen()?this._menu.close():this._menu.open(),this}isOpen(){return this._menu.isOpen()}focus(){return this._menu.getTrigger().focus(),this}getPanel(){return this._menu.getPanel()}destroy(){let t=this.el,e=this._snapshot;this._menu?.destroy(),super.destroy(),!this._createdRoot&&t&&S(t,e)}_sync(){this._renderTrigger(),this._renderMenu()}_renderTrigger(){let t=this.getActive(),e=t?.label??"";this.refs.tile.replaceChildren(...t?[Ph(t)]:[]),this.refs.tile.hidden=!t,this.refs.name.textContent=e,this.refs.secondary.textContent=t?.secondary??"",this.refs.secondary.hidden=!t?.secondary;let i=this.options.label?iv(this.options.label,e):e?this._message("workspaceSwitcher.label","Switch workspace: %1",e):this._message("workspaceSwitcher.labelEmpty","Switch workspace");this.refs.trigger.setAttribute("aria-label",i),this.el.dataset.compact==="true"&&e?this.refs.trigger.setAttribute("title",e):this.refs.trigger.removeAttribute("title")}_renderMenu(){this._entries=new Map;let t=[],e=this.options.heading==null?this._message("workspaceSwitcher.heading","Workspaces"):String(this.options.heading);e&&this._workspaces.length&&t.push({type:"heading",label:e});let i=[];for(let r of this._workspaces){let o={label:r.label,value:r.id,role:"menuitemradio",checked:ur(r.id,this._activeId),description:r.secondary||void 0,badge:r.badge??void 0,disabled:r.disabled,adornment:l("span",{class:"zx-workspace-switcher__check",ariaHidden:"true"},b("check"))};this._entries.set(o,r),i.push([t.length,r]),t.push(o)}this._workspaces.length&&this._items.length&&!sv(this._items[0])&&t.push("-"),t.push(...this._items),this._menu.setItems(t);let n=this._menu.getPanel();for(let[r,o]of i){let a=n.querySelector(`[data-menu-item="${r}"]`);a&&(a.classList.add("zx-workspace-switcher__option"),a.querySelector(".zx-menu-button__leading")?.replaceChildren(Ph(o)))}}_onMenuSelect(t){let e=this._entries.get(t.detail.item);if(!e){this.emit("action",t.detail,{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault();return}if(!ur(e.id,this._activeId)){if(this._emitSelect(e).defaultPrevented){t.preventDefault();return}this._activeId=e.id,this._sync()}}_emitSelect(t){return this.emit("select",{workspace:t,id:t.id,previous:this.getActive()},{honorDomCancellation:!0})}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function tv(s){if(!s||typeof s!="object")return null;let t=s,e=t.id;if((typeof e!="string"||e==="")&&(typeof e!="number"||!Number.isFinite(e)))return null;let i=String(t.label??e).trim()||String(e),n=typeof t.color=="string"&&t.color.trim()?t.color.trim():null,r=_s.includes(t.tone)?t.tone:n?null:ue(i),o=typeof t.src=="string"&&t.src.trim()?t.src.trim():null,a=t.badge==null||t.badge===""?void 0:t.badge;return{...t,id:e,label:i,secondary:t.secondary==null?"":String(t.secondary),tone:r,color:n,src:o,badge:a,initials:ev(i,t.initials),disabled:!!t.disabled}}function Lh(s){if(!Array.isArray(s))return[];let t=new Set,e=[];for(let i of s){let n=tv(i);!n||t.has(String(n.id))||(t.add(String(n.id)),e.push(n))}return e}function Rh(s,t){let e=t==null?null:nl(s,t);return e&&!e.disabled?e.id:(s.find(i=>!i.disabled)??null)?.id??null}function ev(s,t){let e=typeof t=="string"?t.trim():"";return e?Array.from(e).slice(0,2).join(""):Te(s,1)}function iv(s,t){return T(String(s),[t==null?"":String(t)])}function nl(s,t){return t==null?null:s.find(e=>ur(e.id,t))??null}function ur(s,t){return s!=null&&t!=null&&String(s)===String(t)}function sv(s){return s==="-"||!!(s&&typeof s=="object"&&s.type==="separator")}function Ph(s){if(s.src)return l("span",{class:"zx-workspace-switcher__image"},l("img",{src:s.src,alt:"",decoding:"async"}));let t=s.icon&&typeof s.icon=="object"&&"nodeType"in s.icon?s.icon.cloneNode(!0):typeof s.icon=="string"&&s.icon?s.icon:l("span",{class:"zx-workspace-switcher__initials"},s.initials??"");return vi({icon:t,tone:s.tone??null,color:s.color??null,size:"var(--zx-workspace-switcher-tile)",iconSize:typeof t=="string"?"58%":"50%",glass:"subtle"})}var nv=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),rv=new Set(["hover","focus","both","manual"]),mt=class extends y{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#t;#e;#i=null;#s=null;#r=0;#n=0;#o=!1;#a=!1;#c=null;#l=!1;#d=!1;constructor(t,e={}){let i=P(t);if(!i)throw new TypeError("Tooltip anchor could not be resolved");super(null,e),this.#t=i,oe(i,{dialog:!1})?.append(this.el),this.#e=this.options.content,this.#l=!!this.options.disabled,this.#s=i.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",lv(this.options.maxWidth));let n=rv.has(this.options.trigger)?this.options.trigger:"both";if(n!=="manual"){this.#a=!0,(n==="hover"||n==="both")&&(this.listen(this.#t,"pointerenter",r=>{r.pointerType!=="touch"&&this.#f(Number(this.options.delay))}),this.listen(this.#t,"pointerleave",()=>this.#h(Number(this.options.hideDelay)))),(n==="focus"||n==="both")&&(this.listen(this.#t,"focusin",()=>{this.#o||!cv(this.#t)||this.#f(0)}),this.listen(this.#t,"focusout",()=>this.#h(Number(this.options.hideDelay)))),this.listen(this.#t,"pointerdown",()=>{this.#o=!0,this.#u(),this.hide()});for(let r of["pointerup","pointercancel","pointerleave"])this.listen(this.#t,r,()=>{this.#o=!1})}}render(){let t=l("div",{id:x("zx-tooltip"),role:"tooltip",popover:"manual"});return t.dataset.state="closed",t}show(){if(this.#d||this.#l||this.isOpen())return this;this.#u();let t=ns(this.#t);this.el.parentElement!==t&&t.append(this.el);let e=Bh(this.#e);if(e===null)return this;this.el.replaceChildren(e);let i=nv.has(this.options.placement)?this.options.placement:"top";return this.#i=nt(this.#t,this.el,{placement:i,offset:Number(this.options.offset),flip:!0}),/^(left|right)/.test(i)&&this.el.style.getPropertyValue("position-try-fallbacks")&&this.el.style.setProperty("position-try-fallbacks","flip-inline, top span-all, bottom span-all"),this.el.dataset.state="open",this.#t.setAttribute("aria-describedby",av(this.#s,this.el.id)),this.#c=le({kind:"tooltip",root:this.el,owner:this,anchor:this.#t,inside:[this.#t],onEscape:this.#a?()=>{this.hide()}:void 0,onOutsidePointer:this.#a?()=>this.hide():void 0,onFocusOutside:this.#a?()=>this.hide():void 0,onParentClose:()=>this.hide()}),this.emit("open"),this}hide(){if(this.#u(),!this.isOpen())return this;this.#i?.destroy(),this.#i=null,this.el.dataset.state="closed",this.el.replaceChildren(),this.#p();let t=this.#c;return this.#c=null,t?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.hide():this.show()}isOpen(){return this.#i!==null}setContent(t){if(this.#e=t,!this.isOpen())return this;let e=Bh(t);return e===null?this.hide():(this.el.replaceChildren(e),this.#i?.update(),this)}enable(){return this.#l=!1,this}disable(){return this.#l=!0,this.hide()}isDisabled(){return this.#l}getAnchor(){return this.#t}destroy(){this.#d||(this.#d=!0,this.hide(),this.#p(),super.destroy())}#f(t){if(this.#u(),this.#d||this.#l||this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.show();return}this.#r=setTimeout(()=>{this.#r=0,this.show()},e)}#h(t){if(this.#u(),!this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.hide();return}this.#n=setTimeout(()=>{this.#n=0,this.hide()},e)}#u(){this.#r!==0&&clearTimeout(this.#r),this.#n!==0&&clearTimeout(this.#n),this.#r=0,this.#n=0}#p(){this.#s===null?this.#t.removeAttribute("aria-describedby"):this.#t.setAttribute("aria-describedby",this.#s)}};function Vh(s,t=""){return new mt(s,ov(t)?t:{content:t})}function jh(s,t){return new mt(s,{content:String(t??"")})}function ov(s){return s===null||typeof s!="object"||Array.isArray(s)||typeof s.nodeType=="number"?!1:typeof s.toElement!="function"}function Bh(s){let t=typeof s=="function"?s():s;if(t==null)return null;if(typeof t=="object"&&typeof t.nodeType=="number")return t;if(typeof t=="object"&&typeof t.toElement=="function")return t.toElement();let e=String(t);return e===""?null:document.createTextNode(e)}function av(s,t){let e=String(s??"").split(/\s+/).filter(Boolean);return e.includes(t)||e.push(t),e.join(" ")}function lv(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function cv(s){try{return s.matches(":focus-visible")}catch{return!0}}var Ti=class extends y{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(t=null,e={}){super(t,e),this._rebuild()}render(){this._createdRoot=this.el===null;let t=this.el??l("nav");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,o=>[o.name,o.value]),children:Array.from(t.childNodes)},this._items=Pt(this.options.items),this._active=this.options.active,this._flyouts=new Map,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._openTimers=new Map,this._closeTimers=new Map,this._pointerFocus=new WeakSet,this._silenceFlyoutEvents=!1,t.setAttribute("aria-label",String(this.options.label)),t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.dataset.orientation=this.options.orientation==="horizontal"?"horizontal":"vertical";let e=t.dataset.orientation==="horizontal"?["top","bottom"]:["left","right"];t.dataset.side=e.includes(this.options.side)?this.options.side:e[0];let i=this._partBlock(),n=l("div",{class:`${i}__header`}),r=l("div",{class:`${i}__footer`});return $h(n,this.options.header),$h(r,this.options.footer),n.hidden=!n.hasChildNodes(),r.hidden=!r.hasChildNodes(),t.replaceChildren(n,l("ul",{ref:"list",class:`${i}__list`}),r),this.listen(t,"keydown",o=>this._onRailKeydown(o)),t}setItems(t){return this._items=Pt(t),this._rebuild(),this}setActive(t){return this._active=t,this._syncActive(),this}getItems(){return this._items.map(t=>({...t,children:t.children?.map(e=>({...e}))}))}openFlyout(t,{focus:e=!1}={}){let i=this._resolveFlyout(t);if(!i)return this;let n=[i],r=i.parentKey===null?null:this._flyouts.get(i.parentKey)??null;for(;r;)n.unshift(r),r=r.parentKey===null?null:this._flyouts.get(r.parentKey)??null;if(n.some(o=>o.item.disabled))return this;this._cancelFlyoutTimers(i,!0);for(let[o,a]of this._flyouts)o!==i.key&&a.dropdown.isOpen()&&!this._isAncestor(a,i)&&this.closeFlyout(o);for(let o of n)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return e&&qh(i.panel)?.focus(),this}closeFlyout(t){let e=this._resolveFlyout(t);if(!e)return this;for(let i of[...this._flyouts.values()].reverse())i!==e&&this._isAncestor(e,i)&&(this._cancelTimers(i.key),i.dropdown.close());return this._cancelTimers(e.key),e.dropdown.close(),this}closeAllFlyouts(){for(let t of this._flyouts.values())t.parentKey===null&&this.closeFlyout(t.key);for(let t of[...this._flyouts.values()].reverse())this._cancelTimers(t.key),t.dropdown.isOpen()&&t.dropdown.close();return this}isFlyoutOpen(t){return this._resolveFlyout(t)?.dropdown.isOpen()??!1}focus(){return qh(this.refs.list)?.focus(),this}_containsNode(t){return!!(t&&(this.el.contains(t)||[...this._flyouts.values()].some(e=>e.panel.contains(t))))}destroy(){let t=this._original;if(this._clearArtifacts(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new rl(this.el);let t=!1;for(let e of ol(this._items)){if(e===Kh){t&&this.refs.list.append(l("li",{class:`${this._partBlock()}__separator`,ariaHidden:"true"}));continue}t=!0;let i=Array.isArray(e.children)&&e.children.length>0&&this._flyoutsFor(e),n=this._renderControl(e,i),r=l("li",{class:`${this._partBlock()}__row`},n);if(this.refs.list.append(r),this._tooltipFor(e)){let o=new mt(n,{content:e.label,placement:pv(this.el.dataset.side),delay:450});this._tooltips.push(o),this._tooltipById.set(String(e.id),o)}i?this._buildFlyout(e,n,String(e.id),null):this._interaction.listen(n,"click",o=>{if(!this._select(e,o).defaultPrevented)for(let c of this._flyouts.values())c.parentKey===null&&c.dropdown.isOpen()&&this.closeFlyout(c.key)})}this._afterRebuild(),this._syncActive()}_partBlock(){return this.constructor.partBlock}_renderControl(t,e){return Hh(t,{className:"zx-app-rail__item",index:String(t.id),iconOnly:!0,disclosure:e,disclosureIcon:dv(this.el.dataset.side),visual:Ii(t,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:"root"})})}_flyoutsFor(t){return!0}_tooltipFor(t){return!0}_afterRebuild(){}_buildFlyout(t,e,i,n){let r=l("ul",{class:"zx-app-rail__flyout-list"});for(let h of ol(t.children??[],!0)){if(h.section){r.append(l("li",{class:"zx-app-rail__flyout-section"},h.label));continue}let f=`${i}/${h.id}`,p=!!h.children?.length,_=Hh(h,{className:"zx-app-rail__flyout-item",index:f,iconOnly:!1,disclosure:p,disclosureIcon:uv(this.el.dataset.side),visual:Ii(h,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:f.split("/").length,location:"flyout"})});r.append(l("li",{},_)),p?this._buildFlyout(h,_,f,i):this._interaction.listen(_,"click",m=>{this._select(h,m).defaultPrevented||this._closeFlyoutChain(i)})}let o=l("div",{class:"zx-app-rail__flyout"},l("div",{class:"zx-app-rail__flyout-title"},t.label),r),a=new pt(e,{openOn:"manual",placement:n===null?hv(this.el.dataset.side):fv(this.el.dataset.side),content:o,offset:6}),c=a.getPanel();a._configure({tabReach:!1,onEscape:()=>{let h=c.contains(document.activeElement);this.closeFlyout(i),h&&this._restoreFocus(e)}}),c.classList.add("zx-app-rail__popover"),c.dataset.side=this.el.dataset.side,c.setAttribute("role","region"),c.setAttribute("aria-label",this._message("appRail.subNavigation","%1 sub-navigation",t.label));let d={key:i,parentKey:n,item:t,trigger:e,panel:c,dropdown:a};this._flyouts.set(i,d);let u=n===null?this._tooltipById.get(String(t.id)):null;a.on("open",()=>{u?.disable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!0})}),a.on("close",()=>{u?.enable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!1})}),this._interaction.listen(e,"pointerdown",()=>{this._pointerFocus.add(e),queueMicrotask(()=>this._pointerFocus.delete(e))}),this._interaction.listen(e,"pointerenter",h=>{h.pointerType!=="touch"&&this._scheduleOpen(i)}),this._interaction.listen(e,"pointerleave",()=>this._scheduleClose(i)),this._interaction.listen(e,"focus",()=>{this._pointerFocus.has(e)||this.openFlyout(i)}),this._interaction.listen(e,"focusout",h=>{c.contains(h.relatedTarget)||this._scheduleClose(i)}),this._interaction.listen(e,"click",h=>{h.preventDefault(),h instanceof MouseEvent&&h.detail===0?this.openFlyout(i,{focus:!0}):this.openFlyout(i)}),this._interaction.listen(c,"pointerenter",()=>this._cancelFlyoutTimers(d,!0)),this._interaction.listen(c,"pointerleave",()=>this._scheduleFlyoutClose(d,!0)),this._interaction.listen(c,"focusin",()=>this._cancelFlyoutTimers(d,!0)),this._interaction.listen(c,"focusout",h=>{h.relatedTarget!==e&&!c.contains(h.relatedTarget)&&this._scheduleFlyoutClose(d,!0)}),this._interaction.listen(c,"keydown",h=>this._onFlyoutKeydown(h,d))}_select(t,e){if(t.disabled){e.preventDefault();let n=new Event("select",{cancelable:!0});return n.preventDefault(),n}let i=this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e});return i.defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.()),i}_onRailKeydown(t){let e=_v(this.refs.list),i=t.target?.closest?.("[data-app-nav-id]"),n=e.indexOf(i);if(n<0)return;let r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",c={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],d=i.getAttribute("data-app-nav-id");if(t.key===c&&this._flyouts.has(String(d))){t.preventDefault(),this.openFlyout(String(d),{focus:!0});return}let u;if(t.key==="Home")u=0;else if(t.key==="End")u=e.length-1;else if(t.key===o)u=(n-1+e.length)%e.length;else if(t.key===a)u=(n+1)%e.length;else return;t.preventDefault(),e[u]?.focus()}_onFlyoutKeydown(t,e){let i=Uh(e.panel),n=t.target?.closest?.("a, button"),r=i.indexOf(n),o=[...this._flyouts.values()].find(u=>u.trigger===n),a=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",c=a==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&t.key===a){t.preventDefault(),t.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if((e.parentKey!==null||this.el.dataset.orientation==="vertical")&&t.key===c){t.preventDefault(),t.stopPropagation(),this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}if(i.length===0)return;let d;if(t.key==="Home")d=0;else if(t.key==="End")d=i.length-1;else if(t.key==="ArrowDown")d=(r+1+i.length)%i.length;else if(t.key==="ArrowUp")d=(r-1+i.length)%i.length;else return;t.preventDefault(),i[d]?.focus()}_scheduleOpen(t){let e=String(t);this._cancelTimer(this._closeTimers,e),this._cancelTimer(this._openTimers,e);let i=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(e,setTimeout(()=>{this._openTimers.delete(e),this.openFlyout(t)},i))}_scheduleClose(t){let e=String(t);this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e);let i=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(e,setTimeout(()=>{this._closeTimers.delete(e);let n=this._flyouts.get(e);n&&(this._branchInteracting(n)||this.closeFlyout(e))},i))}_scheduleFlyoutClose(t,e){let i=t;for(;i&&(this._scheduleClose(i.key),!(!e||i.parentKey===null));)i=this._flyouts.get(i.parentKey)??null}_resolveFlyout(t){let e=String(t);return this._flyouts.get(e)??[...this._flyouts.values()].find(i=>String(i.item.id)===e)??null}_closeFlyoutChain(t){let e=this._flyouts.get(t)??null;for(;e?.parentKey!==null;)e=this._flyouts.get(e.parentKey)??null;e&&this.closeFlyout(e.key)}_isAncestor(t,e){let i=e.parentKey;for(;i!==null;){if(i===t.key)return!0;i=this._flyouts.get(i)?.parentKey??null}return!1}_cancelFlyoutTimers(t,e){let i=t;for(;i&&(this._cancelTimers(i.key),!(!e||i.parentKey===null));)i=this._flyouts.get(i.parentKey)??null}_branchInteracting(t){return t.trigger.matches(":hover")||t.panel.matches(":hover")||t.trigger===document.activeElement||t.panel.contains(document.activeElement)?!0:[...this._flyouts.values()].some(e=>this._isAncestor(t,e)&&e.dropdown.isOpen()&&(e.trigger.matches(":hover")||e.panel.matches(":hover")||e.trigger===document.activeElement||e.panel.contains(document.activeElement)))}_restoreFocus(t){this._pointerFocus.add(t),t.focus(),queueMicrotask(()=>this._pointerFocus.delete(t))}_cancelTimers(t){this._cancelTimer(this._openTimers,t),this._cancelTimer(this._closeTimers,t)}_cancelTimer(t,e){let i=t.get(e);i!==void 0&&clearTimeout(i),t.delete(e)}_syncActive(){let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let i=t!==null&&e.getAttribute("data-app-nav-value-id")===t,n=this._flyouts.get(String(e.getAttribute("data-app-nav-id"))),r=t!==null&&n?al(n.item.children??[],t):!1;i?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),r?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}for(let e of this._flyouts.values()){t!==null&&al(e.item.children??[],t)?e.trigger.dataset.activeDescendant="true":delete e.trigger.dataset.activeDescendant;for(let n of e.panel.querySelectorAll("[data-app-nav-value-id]"))t!==null&&n.getAttribute("data-app-nav-value-id")===t?n.setAttribute("aria-current","page"):n.removeAttribute("aria-current")}}_clearArtifacts(){for(let t of this._openTimers?this._openTimers.values():[])clearTimeout(t);for(let t of this._closeTimers?this._closeTimers.values():[])clearTimeout(t);this._openTimers?.clear?.(),this._closeTimers?.clear?.(),this._interaction?.destroy?.();for(let t of this._tooltips??[])t.destroy();this._silenceFlyoutEvents=!0;for(let t of this._flyouts?.values?.()??[])t.dropdown.destroy();this._silenceFlyoutEvents=!1,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._flyouts=new Map}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}},rl=class extends y{constructor(t){super(null),t.append(this.el)}render(){return l("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}},Kh=Object.freeze({});function ol(s,t=!1){return s.flatMap(e=>e.section?[t?e:Kh,...ol(e.children??[],t)]:[e])}function Pt(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.label!=null&&(t.id!=null||t.section===!0)).map((t,e)=>{let i={...t,id:t.id??`section:${e}:${t.label}`,label:String(t.label),children:Array.isArray(t.children)?Pt(t.children):[]};if(t.section===!0)return i.section=!0,delete i.href,i;if(t.href==null)return i;let n=V(t.href);return n!==null?i.href=n:(delete i.href,i.children.length===0&&typeof i.invoke!="function"&&(i.disabled=!0)),i}):[]}function Ii(s,t,e){let i=typeof t=="function"?t(s,e):null;if(i==null&&(i=s.icon),typeof i=="function"&&(i=i(e,s)),typeof i=="string")return b(i);if(i instanceof Node)return i.cloneNode(!0);if(i&&typeof i=="object"&&typeof i.toElement=="function"){let n=i.toElement();return n instanceof Node?n.cloneNode(!0):null}return null}function Hh(s,{className:t,index:e,iconOnly:i,disclosure:n,disclosureIcon:r,visual:o}){let a=V(s.href),c=a&&!n?"a":"button";return l(c,{class:t,type:c==="button"?"button":null,href:c==="a"?a:null,target:c==="a"?s.target??null:null,rel:c==="a"?"noopener":null,ariaLabel:i?s.label:null,ariaDisabled:s.disabled?"true":null,dataset:{appNavId:e,appNavValueId:String(s.id)}},o?l("span",{class:`${t}-icon`,ariaHidden:"true"},o):null,l("span",{class:`${t}-label`},s.label),s.badge!=null?l("span",{class:`${t}-badge`},String(s.badge)):null,n?l("span",{class:`${t}-disclosure`,ariaHidden:"true"},b(r)):null)}function dv(s){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[s]??"chevron-right"}function uv(s){return s==="right"?"chevron-left":"chevron-right"}function hv(s){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[s]??"right-start"}function fv(s){return s==="right"?"left-start":"right-start"}function pv(s){return{left:"right",right:"left",top:"bottom",bottom:"top"}[s]??"right"}function Uh(s){return[...s.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function qh(s){return Uh(s)[0]??null}function _v(s){return[...s.children].map(t=>t.querySelector("[data-app-nav-id]")).filter(Boolean)}function al(s,t){return s.some(e=>String(e.id)===t||al(e.children??[],t))}function $h(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&s.append(t)}var mv=["tint","solid","plain"],gv=12,bv=600,ct=class extends Ti{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(t=null,e={}){super(t,e)}render(){let t=super.render();return this._sections=new Map,this._items=xs(this._items,this._sections),this._appearance=mv.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},t.setAttribute("aria-label",this._labelText()),t.dataset.appearance=this._appearance,t.dataset.menus=this._menus,t.dataset.allModules=["always","never"].includes(this.options.allModules)?this.options.allModules:"auto",t.dataset.labels=ll(this.options.labels,t.dataset.orientation),t}setItems(t){let e=new Map,i=xs(Pt(t),e);return this._sections=e,super.setItems(i)}getItems(){return super.getItems()}setActive(t){return super.setActive(t)}openFlyout(t,e={}){return super.openFlyout(t,e)}closeFlyout(t){return super.closeFlyout(t)}closeAllFlyouts(){return super.closeAllFlyouts()}isFlyoutOpen(t){return super.isFlyoutOpen(t)}setExpanded(t){return this._expandedId=t??null,this._syncExpanded(),this._layout(),this}setBadge(t,e){let i=Ut(this._items,t);if(!i)return this;e==null||e===""?delete i.badge:i.badge=e;let n=String(t);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,i);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&&cl(a,i,"zx-app-rail__flyout-item");let r=this._catalogueEntry(n);return r&&cl(r,i,"zx-module-bar__entry"),this}setLayout(t={}){let e=t.orientation==="horizontal"||t.orientation==="vertical"?t.orientation:this.el.dataset.orientation,i=e==="horizontal"?["top","bottom"]:["left","right"],n=i.includes(t.side??this.el.dataset.side)?t.side??this.el.dataset.side:i[0];return e===this.el.dataset.orientation&&n===this.el.dataset.side?this:(this.el.dataset.orientation=e,this.el.dataset.side=n,this.el.dataset.labels=ll(this._labels,e),this._rebuild(),this)}setLabels(t){this._labels=t;let e=ll(t,this.el.dataset.orientation);if(e===this.el.dataset.labels)return this;let i=document.activeElement,n=i instanceof HTMLElement&&this.refs.list.contains(i)&&i.matches(".zx-module-bar__item")?fr(i):null;return this.el.dataset.labels=e,this._rebuild(),n!==null&&[...this.refs.list.querySelectorAll(".zx-module-bar__item")].find(r=>fr(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(t){return super._containsNode(t)||!!(t&&this._catalogue?.getPanel().contains(t))}_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(t){return this._menus==="flyout"&&!t.disabled}_tooltipFor(){return this.el.dataset.labels==="hidden"}_renderControl(t){let e=!!t.children?.length,i=t.href&&!e?"a":"button",n=this.el.dataset.labels!=="hidden",r=l(i,{class:"zx-module-bar__item",type:i==="button"?"button":null,href:i==="a"?t.href:null,target:i==="a"?t.target??null:null,rel:i==="a"&&t.target?"noopener":null,ariaDisabled:t.disabled?"true":null,tabIndex:-1,dataset:{appNavId:String(t.id),appNavValueId:String(t.id)}},this._renderTile(t,"bar"),n?l("span",{class:"zx-module-bar__label"},t.label):null);return this._applyTileBadge(r,t),r}_afterRebuild(){let t=this.refs.list,e=Qh(this._items),i=new Map;for(let r of[...t.children]){let o=r.querySelector("[data-app-nav-value-id]")?.getAttribute("data-app-nav-value-id");o!=null&&(r.dataset.moduleId=o,i.set(o,r))}let n=null;for(let r of e){let o=i.get(String(r.id));if(!o)continue;let a=this._sections.get(String(r.id))??null;a!==null&&a!==n&&t.append(l("li",{class:"zx-module-bar__heading",dataset:{section:a}},l("span",{class:"zx-module-bar__heading-label"},a))),n=a,t.append(o)}this._promoted!==null&&!Ut(this._items,this._promoted)&&(this._promoted=null),this._buildCatalogue(),this._interaction.listen(t,"focusin",r=>{let o=r.target.closest?.(".zx-module-bar__item");o instanceof HTMLElement&&this._setRovingStop(o)}),this._interaction.listen(t,"focusout",r=>{t.contains(r.relatedTarget)||(this._rovingId=null,this._syncRoving())}),typeof ResizeObserver=="function"&&(this._observer=new ResizeObserver(()=>this._layout()),this._observer.observe(t))}_syncActive(){super._syncActive();let t=this._active==null?null:String(this._active);for(let e of this._tiles()){let i=Ut(this._items,e.getAttribute("data-app-nav-value-id"));if(!i)continue;let n=Wh(i,t);n?e.setAttribute("aria-current",n):e.removeAttribute("aria-current"),n==="true"?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}for(let e of this._catalogueEntries()){let i=Ut(this._items,e.dataset.moduleId),n=i?Wh(i,t):null;n?e.setAttribute("aria-current",n):e.removeAttribute("aria-current")}this._syncExpanded(),this._layout()}_layout(){let t=this.refs.list;if(!t||!this._items)return;let e=[...t.querySelectorAll(":scope > [data-module-id]")],i=t.querySelector(":scope > [data-module-bar-more]"),n=this.el.dataset.allModules,r=[pr(this._items,this._active)?.id,this._expandedId,this._promoted],o=1/0;if(n!=="never"&&t.isConnected){for(let h of e)h.hidden=!1;i&&(i.hidden=!1),Yh(t),o=yv(t,this.el.dataset.orientation==="horizontal",e.length+1)}let a=dl(this._items,o,r,n==="always"),c=new Set(a.visible.map(h=>String(h.id)));for(let h of e)h.hidden=!c.has(h.dataset.moduleId);Yh(t),i&&(i.hidden=n==="never"||n==="auto"&&!a.more);let d={visible:a.visible.map(h=>h.id),overflow:a.overflow.map(h=>h.id)},u=d.visible.join("\0")!==this._partition.visible.join("\0")||d.overflow.join("\0")!==this._partition.overflow.join("\0");this._partition=d,this._syncRoving(),u&&t.isConnected&&this.emit("overflowchange",{...d})}_renderTile(t,e){let i=Ii(t,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:e==="bar"?"module":"catalogue"})??l("span",{class:"zx-module-bar__initial"},t.label.trim().charAt(0).toUpperCase()),{tone:n,color:r}=ul(t),o=l("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:this._appearance,...n?{tone:n}:{},...r?{color:""}:{}}});return this._appearance==="solid"?o.append(vi({icon:i,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(i)),o}_applyTileBadge(t,e){t.querySelector(":scope > .zx-module-bar__badge")?.remove();let i=e.badge==null||e.badge===""?null:String(e.badge);t.setAttribute("aria-label",i===null?e.label:this._message("moduleBar.itemBadge","%1 (%2)",e.label,i)),i!==null&&t.append(l("span",{class:"zx-module-bar__badge",ariaHidden:"true",dataset:{zxBadge:i.length>2&&this.el.dataset.labels!=="beside"?"dot":"count"}},i))}_buildCatalogue(){let t=this._message("moduleBar.more","All modules"),e=this.el.dataset.labels!=="hidden",i=l("button",{class:"zx-module-bar__item",type:"button",ariaLabel:t,tabIndex:-1,dataset:{moduleBarMore:""}},l("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:"plain"}},b("grid")),e?l("span",{class:"zx-module-bar__label"},t):null);this.refs.list.append(l("li",{class:"zx-module-bar__row",dataset:{moduleBarMore:""}},i)),e||(this._catalogueTooltip=new mt(i,{content:t,placement:{left:"right",right:"left",top:"bottom",bottom:"top"}[this.el.dataset.side]??"right",delay:450}));let n=this._items.length>gv?l("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 f of this._items){let p=typeof f.group=="string"?f.group:this._sections.get(String(f.id))??"";r.has(p)||r.set(p,[]),r.get(p).push(f)}let o=[...r].map(([f,p])=>{let _=f?x("zx-module-bar-group"):null;return l("div",{class:"zx-module-bar__group"},f?l("div",{class:"zx-module-bar__group-label",id:_},f):null,l("ul",{class:"zx-module-bar__grid",ariaLabelledby:_},p.map(m=>l("li",{dataset:{moduleId:String(m.id)}},this._catalogueControl(m)))))}),a=l("p",{class:"zx-module-bar__empty",hidden:!0},this._message("moduleBar.empty","No modules")),c=l("div",{class:"zx-module-bar__catalogue"},n,...o,a),d={left:"right-start",right:"left-start",top:"bottom-end",bottom:"top-end"}[this.el.dataset.side]??"right-start",u=new pt(i,{content:c,placement:d,offset:6}),h=u.getPanel();h.classList.add("zx-module-bar__popover"),h.setAttribute("role","region"),h.setAttribute("aria-label",t),this._catalogue=u,u.on("open",()=>{this.closeAllFlyouts(),this._catalogueTooltip?.hide(),this.emit("allmodules",{open:!0})}),u.on("close",()=>{n instanceof HTMLInputElement&&n.value&&(n.value="",this._filterCatalogue("")),this._silenceCatalogue||this.emit("allmodules",{open:!1})}),this._interaction.listen(i,"click",()=>{u.isOpen()&&this._focusCatalogue()}),n&&this._interaction.listen(n,"input",()=>this._filterCatalogue(n.value)),this._interaction.listen(h,"click",f=>this._onCatalogueClick(f)),this._interaction.listen(h,"focusout",f=>{let p=f.relatedTarget;p&&!h.contains(p)&&p!==i&&u.close()}),this._interaction.listen(h,"keydown",f=>this._onCatalogueKeydown(f)),this._interaction.listen(h,"focusin",f=>{let p=f.target.closest?.(".zx-module-bar__entry");p instanceof HTMLElement&&this._syncCatalogueStop(p)}),this._syncCatalogueStop()}_syncCatalogueStop(t){let e=this._catalogueEntries(),i=e.filter(r=>!r.closest("li")?.hidden),n=(t&&i.includes(t)?t:null)??i.find(r=>r.tabIndex===0&&r.dataset.catalogueStop==="true")??i.find(r=>r.hasAttribute("aria-current"))??i[0];for(let r of e)r.tabIndex=r===n?0:-1,r===n?r.dataset.catalogueStop="true":delete r.dataset.catalogueStop}_catalogueControl(t){let e=!!t.children?.length,i=t.href&&!e?"a":"button",n=l(i,{class:"zx-module-bar__entry",type:i==="button"?"button":null,href:i==="a"?t.href:null,target:i==="a"?t.target??null:null,rel:i==="a"&&t.target?"noopener":null,title:typeof t.description=="string"?t.description:null,ariaDisabled:t.disabled?"true":null,dataset:{moduleId:String(t.id)}},this._renderTile(t,"catalogue"),l("span",{class:"zx-module-bar__entry-label"},t.label));return cl(n,t,"zx-module-bar__entry"),n}_onCatalogueClick(t){let e=t.target.closest?.(".zx-module-bar__entry");if(!(e instanceof HTMLElement))return;let i=Ut(this._items,e.dataset.moduleId);if(!i||i.disabled){t.preventDefault();return}if(i.children?.length&&this._menus==="flyout"){t.preventDefault(),this._catalogue?.close(),this._promoted=i.id,this._layout();let o=t instanceof MouseEvent&&t.detail===0;this.openFlyout(i.id,{focus:o}),o||this._tiles().find(a=>a.getAttribute("data-app-nav-value-id")===String(i.id))?.focus();return}this._select(i,t);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(i.id)&&!a.closest("li")?.hidden)??this.refs.list.querySelector("[data-module-bar-more] .zx-module-bar__item"))?.focus()}_onCatalogueKeydown(t){let e=this._catalogue?.getPanel();if(!e||t.altKey||t.ctrlKey||t.metaKey)return;let i=e.querySelector(".zx-module-bar__filter"),n=this._catalogueEntries().filter(c=>!c.closest("li")?.hidden),r=t.target.closest?.(".zx-module-bar__entry");if(t.target===i){t.key==="ArrowDown"&&n[0]&&(t.preventDefault(),n[0].focus());return}if(!(r instanceof HTMLElement))return;let o=n.indexOf(r),a=null;if(t.key==="ArrowRight")a=n[Math.min(n.length-1,o+1)];else if(t.key==="ArrowLeft")a=n[Math.max(0,o-1)];else if(t.key==="Home")a=n[0];else if(t.key==="End")a=n.at(-1);else if(t.key==="ArrowDown"||t.key==="ArrowUp")a=wv(n,r,t.key==="ArrowDown"?1:-1),!a&&t.key==="ArrowUp"&&i instanceof HTMLElement&&(a=i);else if(i instanceof HTMLElement&&t.key.length===1&&t.key!==" "){i.focus();return}else return;t.preventDefault(),a?.focus()}_filterCatalogue(t){let e=this._catalogue?.getPanel();if(!e)return;let i=t.trim().toLocaleLowerCase(),n=0;for(let o of e.querySelectorAll(".zx-module-bar__group")){let a=0;for(let c of o.querySelectorAll("li[data-module-id]")){let d=Ut(this._items,c.dataset.moduleId),u=`${d?.label??""} ${d?.description??""} ${d?.group??""}`.toLocaleLowerCase(),h=!i||u.includes(i);c.hidden=!h,h&&(a+=1)}o.hidden=a===0,n+=a}let r=e.querySelector(".zx-module-bar__empty");r instanceof HTMLElement&&(r.hidden=n>0),this._syncCatalogueStop()}_focusCatalogue(){let t=this._catalogue?.getPanel();if(!t||!this._catalogue?.isOpen())return;let i=t.querySelector(".zx-module-bar__filter")??this._catalogueEntries().find(n=>n.hasAttribute("aria-current"))??this._catalogueEntries()[0];i instanceof HTMLElement&&i.focus()}_onRailKeydown(t){let e=t.target.closest?.(".zx-module-bar__item");if(!(e instanceof HTMLElement)||!this.refs.list.contains(e)||t.altKey||t.ctrlKey||t.metaKey)return;let i=this._rovingControls(),n=i.indexOf(e),r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",c={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],d=e.getAttribute("data-app-nav-id");if(t.key===c&&d!==null&&this._flyouts.has(d)){t.preventDefault(),this.openFlyout(d,{focus:!0});return}let u=null;if(t.key==="Home")u=i[0];else if(t.key==="End")u=i.at(-1);else if(t.key===o)u=i[(n-1+i.length)%i.length];else if(t.key===a)u=i[(n+1)%i.length];else if(t.key.length===1&&t.key!==" ")u=this._typeaheadTarget(t.key,i,n);else return;u&&(t.preventDefault(),this._setRovingStop(u),u.focus())}_typeaheadTarget(t,e,i){let n=Date.now(),r=n-this._typeahead.at>bv?t:this._typeahead.text+t;this._typeahead={text:r,at:n};let o=r.toLocaleLowerCase(),a=[...o].every(h=>h===o[0]),c=h=>(Ut(this._items,h.getAttribute("data-app-nav-value-id"))?.label??h.getAttribute("aria-label")??"").toLocaleLowerCase(),d=[...e.slice(i+1),...e.slice(0,i+1)],u=d.find(h=>c(h).startsWith(o))??(a?d.find(h=>c(h).startsWith(o[0])):null);return u||r.length===1?u??null:(this._typeahead={text:t,at:n},d.find(h=>c(h).startsWith(t.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 t=this._rovingControls();if(this._rovingId!==null){let e=t.find(i=>fr(i)===this._rovingId);if(e)return e}return t.find(e=>e.hasAttribute("aria-current"))??t.find(e=>e.getAttribute("aria-expanded")==="true"&&e.hasAttribute("data-app-nav-value-id"))??t[0]??null}_setRovingStop(t){this._rovingId=fr(t),this._syncRoving()}_syncRoving(){let t=this._rovingStop();for(let e of this.refs.list.querySelectorAll(":scope > li > .zx-module-bar__item"))e.tabIndex=e===t?0:-1}_syncExpanded(){if(this._menus!=="none")return;let t=this._expandedId==null?null:String(this._expandedId);for(let e of this._tiles()){let i=e.getAttribute("data-app-nav-value-id"),n=Ut(this._items,i);(n?.children?.length||n?.header||n?.content||i===t)&&(e.setAttribute("aria-expanded",String(i===t)),this.options.controls&&e.setAttribute("aria-controls",String(this.options.controls)))}}_catalogueEntries(){let t=this._catalogue?.getPanel();return t?[...t.querySelectorAll(".zx-module-bar__entry")]:[]}_catalogueEntry(t){return this._catalogueEntries().find(e=>e.dataset.moduleId===t)??null}_labelText(){let t=this.options.label;return t==null||t===""?this._message("moduleBar.label","Modules"):String(t)}};function dl(s,t=1/0,e=[],i=!1){let n=Array.isArray(s)?s.filter(_=>_&&_.id!=null):[],r=Qh(n),a=n.some(Gh)?r.filter(Gh):r,c=Number.isFinite(t)?Math.max(1,Math.floor(t)):1/0,u=i||a.length<n.length||a.length>c?Math.max(0,c-1):c,h=a.slice(0,u),f=new Set([e].flat().filter(_=>_!=null).map(String));for(let _ of f){let m=n.find(g=>String(g.id)===_);if(!(!m||h.includes(m))){if(h.length>=u){let g=h.findLastIndex(w=>!f.has(String(w.id)));g>=0&&h.splice(g,1)}h.push(m)}}h.sort((_,m)=>r.indexOf(_)-r.indexOf(m));let p=n.filter(_=>!h.includes(_));return{visible:h,overflow:p,more:p.length>0}}function ul(s){let t=ee(s?.color)?String(s.color).trim():null;return t?{tone:null,color:t}:{tone:_s.includes(s?.tone)?s.tone:null,color:null}}function xs(s,t=new Map,e=null){return s.flatMap(i=>i.section?xs(i.children??[],t,i.label):(e!==null&&t.set(String(i.id),e),[i]))}function Yh(s){let t=null,e=!1,i=!0,n=()=>{t&&(t.hidden=!e)};for(let r of[...s.children]){if(r.classList.contains("zx-module-bar__heading")){n(),t=r,e=!1,i?r.dataset.leading="":delete r.dataset.leading;continue}r.hasAttribute("data-module-id")&&!r.hidden&&(e=!0,i=!1)}n()}function ll(s,t){return t!=="vertical"?"hidden":s==="below"||s==="beside"?s:"hidden"}function Gh(s){return s.pinned===!0||typeof s.pinned=="number"&&Number.isFinite(s.pinned)}function Qh(s){let t=e=>typeof e.pinned=="number"&&Number.isFinite(e.pinned)?e.pinned:e.pinned===!0?Number.MAX_SAFE_INTEGER-1:Number.MAX_SAFE_INTEGER;return s.map((e,i)=>({item:e,index:i})).sort((e,i)=>t(e.item)-t(i.item)||e.index-i.index).map(({item:e})=>e)}function yv(s,t,e){if(!(t?s.scrollWidth>s.clientWidth+1:s.scrollHeight>s.clientHeight+1))return 1/0;let n=[...s.querySelectorAll(":scope > li:not([hidden]):not(.zx-module-bar__heading)")];if(!n.length)return 1/0;let r=[...s.querySelectorAll(":scope > li.zx-module-bar__heading:not([hidden])")],o=getComputedStyle(s),a=Number.parseFloat(t?o.columnGap:o.rowGap)||0,c=t?(Number.parseFloat(o.paddingInlineStart)||0)+(Number.parseFloat(o.paddingInlineEnd)||0):(Number.parseFloat(o.paddingBlockStart)||0)+(Number.parseFloat(o.paddingBlockEnd)||0),d=Math.max(...n.map(f=>t?f.offsetWidth:f.offsetHeight)),u=r.reduce((f,p)=>f+a+(t?p.offsetWidth:p.offsetHeight)+(Number.parseFloat(t?getComputedStyle(p).marginInlineStart:getComputedStyle(p).marginBlockStart)||0)+(Number.parseFloat(t?getComputedStyle(p).marginInlineEnd:getComputedStyle(p).marginBlockEnd)||0),0),h=(t?s.clientWidth:s.clientHeight)-c-u;return d<=0||h<=0?e:Math.max(1,Math.floor((h+a)/(d+a)))}function wv(s,t,e){let i=t.getBoundingClientRect(),n=i.left+i.width/2,r=null,o=1/0,a=1/0;for(let c of s){if(c===t)continue;let d=c.getBoundingClientRect(),u=e>0?d.top-i.bottom+1:i.top-d.bottom+1;if(u<0)continue;let h=Math.abs(d.left+d.width/2-n);(u<o-1||Math.abs(u-o)<=1&&h<a)&&(r=c,o=u,a=h)}return r}function fr(s){return s.getAttribute("data-app-nav-value-id")??"\0more"}function Wh(s,t){return t===null?null:String(s.id)===t?"page":hl(s.children??[],t)?"true":null}function cl(s,t,e){let i=s.querySelector(`:scope > .${e}-badge`),n=t.badge==null||t.badge===""?null:String(t.badge);if(n===null){i?.remove();return}i?i.textContent=n:s.querySelector(`:scope > .${e}-label`)?.after(l("span",{class:`${e}-badge`},n))}function pr(s,t){if(t==null||!Array.isArray(s))return null;let e=String(t);return s.find(i=>String(i.id)===e||hl(i.children??[],e))??null}function Ut(s,t){if(t==null)return null;for(let e of s??[]){if(String(e.id)===String(t))return e;let i=Ut(e.children??[],t);if(i)return i}return null}function hl(s,t){return s.some(e=>String(e.id)===t||hl(e.children??[],t))}var _r=Object.freeze(["expanded","compact","collapsed"]),mr=class extends y{static cssName="app-sidebar";static defaults={items:[],active:null,expanded:[],collapsed:!1,collapsible:!0,orientation:"vertical",side:"left",layout:"tree",module:null,moduleBar:{},presentation:null,presentations:["expanded","compact","collapsed"],presentationSwitch:!0,label:"Applications",header:null,footer:null,railHeader:null,railFooter:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(t=null,e={}){super(t,e),this._rail=null,this._railExpandButton=null,this._renderMode()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._items=Pt(this.options.items),this._active=this.options.active,this._expanded=new Set(Array.isArray(this.options.expanded)?this.options.expanded.map(String):[]),this._collapsed=!!this.options.collapsed,this._orientation=this.options.orientation==="horizontal"?"horizontal":"vertical",this._side=Jh(this._orientation,this.options.side),this._modules=this.options.layout==="modules",this._moduleLabels=this.options.moduleBar?.labels??"auto",this._compact=!1,this._presentationGroup=null,this._stripTooltips=[],this._modules&&_r.includes(this.options.presentation)&&(this._collapsed=this.options.presentation==="collapsed",this._compact=this.options.presentation==="compact"),this._shownId=this._modules?this._resolveShown(this.options.module):null,this._modeAbort=null,t.replaceChildren(),t}setItems(t){return this._items=Pt(t),this._reconcileExpanded(),this._modules?(this._shownId=this._resolveShown(this._shownId),this._rail?.setItems(this._items),this._rail instanceof ct&&!this.isCollapsed()&&this._rail.setExpanded(this._shownId),this.refs.list&&this._renderPanelContent()):this._rail?(this._rail.setItems(this._items),this._decorateRail()):this._renderTree(),this}getItems(){return tf(this._items)}setActive(t){if(this._active=t,this._rail&&this._rail.setActive(t),this._modules){let e=pr(this._moduleList(),t);if(e&&Ei(e)&&String(e.id)!==String(this._shownId))return this._shownId=e.id,this._rail instanceof ct&&!this.isCollapsed()&&this._rail.setExpanded(e.id),this.refs.list&&this._renderPanelContent(),this}return this.refs.list&&this._syncActive(),this}setBadge(t,e){let i=Ie(this._items,t);return i?(e==null||e===""?delete i.badge:i.badge=e,this._rail instanceof ct?this._rail.setBadge(t,e):this._rail&&(this._rail.setItems(this._items),this._decorateRail()),this.refs.list&&this._renderTree(),this):this}setModule(t,{silent:e=!1}={}){return this._showModule(t,{silent:e}),this}getModule(){return this._shownId}setModuleLabels(t){return this._moduleLabels=t,this._rail instanceof ct&&this._rail.setLabels(this._stripLabels()),this._syncPresentationSwitch(),this}getPresentation(){return this.isCollapsed()?"collapsed":this._modules&&this._stripLabels()==="hidden"?"compact":"expanded"}setPresentation(t,{silent:e=!1}={}){return _r.includes(t)?this._present(t==="collapsed",t==="collapsed"?this._compact:this._modules&&t==="compact",{silent:e}):this}togglePresentation(){return this.setPresentation(this._nextPresentation())}setExpanded(t,{silent:e=!1}={}){return this._expanded=new Set(Array.isArray(t)?t.map(String):[]),this._reconcileExpanded(),this.refs.list&&this._renderTree(),e||this.emit("branchchange",{item:null,id:null,expanded:null,ids:this.getExpanded()}),this}getExpanded(){let t=[];return fl(this._items,e=>{this._expanded.has(String(e.id))&&t.push(e.id)}),t}toggleBranch(t,{silent:e=!1}={}){let i=Ie(this._items,t);if(!i?.children?.length||i.section)return this;let n=String(t),r=!this._expanded.has(n);return r?this._expanded.add(n):this._expanded.delete(n),this.refs.list&&(this._renderTree(),r&&this._markBranchMotion(n)),e||this.emit("branchchange",{item:i,id:i.id,expanded:r,ids:this.getExpanded()}),this}expand(t={}){return this.setCollapsed(!1,t)}collapse(t={}){return this.setCollapsed(!0,t)}setCollapsed(t,{silent:e=!1}={}){return this._present(!!t,this._compact,{silent:e})}_present(t,e,{silent:i=!1}){let n={collapsed:this.isCollapsed(),presentation:this.getPresentation()},r=document.activeElement,o=!!(r&&(this.el.contains(r)||this._rail?._containsNode(r)));this._collapsed=t,this._compact=!!e;let a=this.isCollapsed();if(n.collapsed!==a){if(this._renderMode(),o){let d=a?this._railExpandButton:this.refs.collapse;d?.isConnected?d.focus():this.focus()}}else this._rail instanceof ct&&(this._rail.setLabels(this._stripLabels()),this._syncPresentationSwitch());let c=this.getPresentation();return i||(n.collapsed!==a&&this.emit("collapsechange",{collapsed:a}),n.presentation!==c&&this.emit("presentationchange",{presentation:c,previous:n.presentation})),this}isCollapsed(){return this._orientation==="horizontal"||this._collapsed}setLayout(t={},{silent:e=!1}={}){let i=t.orientation==="horizontal"?"horizontal":t.orientation==="vertical"?"vertical":this._orientation,n=Jh(i,t.side??this._side);if(i===this._orientation&&n===this._side)return this;let r=this.isCollapsed(),o=document.activeElement,a=!!(o&&(this.el.contains(o)||this._rail?._containsNode(o))),c=a&&o instanceof Element?o.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id")??null:null;this._orientation=i,this._side=n,this._renderMode();let d=this.isCollapsed();if(a){let u=c===null?null:[...this.el.querySelectorAll("[data-app-nav-id]")].find(h=>h.getAttribute("data-app-nav-id")===c)??null;u instanceof HTMLElement?u.focus():d?this.focus():this.refs.collapse instanceof HTMLElement&&!this.refs.collapse.hidden?this.refs.collapse.focus():Mi(this.refs.list)[0]?.focus()}return r!==d&&!e&&this.emit("collapsechange",{collapsed:d}),this}openFlyout(t,e={}){return this._rail?.openFlyout(t,e),this}closeFlyout(t){return this._rail?.closeFlyout(t),this}closeAllFlyouts(){return this._rail?.closeAllFlyouts(),this}isFlyoutOpen(t){return this._rail?.isFlyoutOpen(t)??!1}focus(){return this._rail?this._rail.focus():Mi(this.refs.list)[0]?.focus(),this}destroy(){let t=this._original;this._modeAbort?.abort(),this._modeAbort=null;for(let e of this._stripTooltips.splice(0))e.destroy();if(this._rail?.destroy(),this._rail=null,super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_renderMode(){this._modeAbort?.abort(),this._modeAbort=new AbortController;for(let t of this._stripTooltips.splice(0))t.destroy();this._presentationGroup=null,this._rail?.destroy(),this._rail=null,this._railExpandButton=null;for(let t of["expanded","list","collapse","rail","panelTitle","panelLead","panelContent","panelNav"])delete this.refs[t];this.el.replaceChildren(),this.el.dataset.orientation=this._orientation,this.el.dataset.side=this._side,this.el.dataset.collapsed=String(this.isCollapsed()),this.el.dataset.layout=this._modules?"modules":"tree",this._modules?this._renderModules():this.isCollapsed()?this._renderRail():this._renderExpanded()}_renderExpanded(){let t=l("div",{class:"zx-app-sidebar__header-content"});fe(t,this.options.header);let e=this._collapseButton(),i=l("footer",{class:"zx-app-sidebar__footer"});fe(i,this.options.footer),i.hidden=!i.hasChildNodes();let n=l("ul",{class:"zx-app-sidebar__list"}),r=l("div",{class:"zx-app-sidebar__expanded"},l("header",{class:"zx-app-sidebar__header"},t,e),l("nav",{class:"zx-app-sidebar__nav",ariaLabel:this.options.label},n),i);this.refs.expanded=r,this.refs.list=n,this.refs.collapse=e,this.el.append(r),this._listenTree(n),this._renderTree()}_collapseButton(){let t=l("button",{class:"zx-app-sidebar__collapse zx-icon-btn",type:"button",ariaLabel:this._message("appSidebar.minimize","Minimize application sidebar")},b(this._side==="right"?"chevron-right":"chevron-left"));return t.hidden=!this.options.collapsible,this._listenMode(t,"click",()=>this.collapse()),t}_expandButton(){let t=l("button",{class:"zx-app-sidebar__rail-toggle zx-icon-btn",type:"button",ariaLabel:this._message("appSidebar.expand","Expand application sidebar")},b(this._side==="right"?"chevron-left":"chevron-right"));return this._railExpandButton=t,this._listenMode(t,"click",()=>this.expand()),t}_listenTree(t){this._listenMode(t,"click",e=>this._onTreeClick(e)),this._listenMode(t,"keydown",e=>this._onTreeKeydown(e))}_renderRail(){let t=l("nav",{class:"zx-app-sidebar__rail"});this.el.append(t),this.refs.rail=t;let e=this._orientation==="vertical"&&!!this.options.collapsible,i=l("div",{class:"zx-app-sidebar__rail-header"});e&&i.append(this._expandButton()),fe(i,this.options.railHeader),this._rail=new Ti(t,{items:this._items,active:this._active,orientation:this._orientation,side:this._side,label:this.options.label,header:i.hasChildNodes()?i:null,footer:this.options.railFooter,openDelay:this.options.openDelay,closeDelay:this.options.closeDelay,renderIcon:this.options.renderIcon,onselect:n=>{this.emit("select",n.detail).defaultPrevented&&n.preventDefault()},onflyoutchange:n=>this.emit("flyoutchange",n.detail)}),this._listenMode(t,"zx-select",n=>n.stopPropagation()),this._listenMode(t,"zx-flyoutchange",n=>n.stopPropagation()),this._decorateRail()}_renderModules(){let t=!this.isCollapsed(),e=l("div",{class:"zx-app-sidebar__rail-header"});fe(e,this.options.railHeader);let i=l("div",{class:"zx-app-sidebar__strip-foot"});this._orientation==="vertical"&&this.options.collapsible&&this.options.presentationSwitch!==!1&&i.append(this._presentationSwitch(t)),fe(i,this.options.railFooter);let n=l("nav",{class:"zx-app-sidebar__strip"}),r=t?x("zx-app-sidebar-panel"):null,o=t?l("div",{class:"zx-app-sidebar__modules"},n):n;this.el.append(o),this.refs.rail=n;let a=this.options.moduleBar&&typeof this.options.moduleBar=="object"?this.options.moduleBar:{},c={items:this._items,active:this._active,orientation:this._orientation,side:this._side,menus:t?"none":"flyout",expanded:t?this._shownId:null,controls:r,header:e.hasChildNodes()?e:null,footer:i.hasChildNodes()?i:null,openDelay:this.options.openDelay,closeDelay:this.options.closeDelay,renderIcon:this.options.renderIcon,onselect:d=>this._onModuleSelect(d,t),onflyoutchange:d=>this.emit("flyoutchange",d.detail)};for(let d of["appearance","allModules","label"])a[d]!=null&&(c[d]=a[d]);c.labels=this._stripLabels(),this._rail=new ct(n,c);for(let d of["zx-select","zx-flyoutchange","zx-overflowchange","zx-allmodules"])this._listenMode(n,d,u=>u.stopPropagation());t&&(this._listenMode(n,"keydown",d=>this._onStripKeydown(d)),o.append(this._renderPanel(r)))}_presentationSwitch(t){let e=this._presentationLabels(),i=l("div",{class:"zx-app-sidebar__presentation",role:"radiogroup",ariaLabel:this._message("appSidebar.presentation","Navigation layout")});for(let r of this._presentationCycle()){let o=l("button",{class:"zx-app-sidebar__presentation-option",type:"button",role:"radio",ariaLabel:e[r],dataset:{presentation:r}},gr(r));i.append(o),this._stripTooltips.push(new mt(o,{content:e[r],placement:this._side==="right"?"left":"right",delay:450}))}this._listenMode(i,"click",r=>{let o=r.target.closest?.(".zx-app-sidebar__presentation-option");o instanceof HTMLElement&&this.setPresentation(o.dataset.presentation)}),this._listenMode(i,"keydown",r=>this._onPresentationKeydown(r)),this._presentationGroup=i,this._syncPresentationSwitch();let n=i.querySelector('[aria-checked="true"]');return t?this.refs.collapse=n??i:this._railExpandButton=n??i,i}presentationChoice({label:t}={}){let e=this._presentationLabels();return{type:"choice",label:t??this._message("appSidebar.presentation","Navigation layout"),value:this.getPresentation(),options:this._presentationCycle().map(i=>({value:i,label:e[i],glyph:()=>gr(i)})),onselect:i=>this.setPresentation(i)}}_presentationLabels(){return{expanded:this._message("appSidebar.presentationExpanded","Both menus expanded"),compact:this._message("appSidebar.presentationCompact","Module menu collapsed"),collapsed:this._message("appSidebar.presentationCollapsed","Both menus collapsed")}}_onPresentationKeydown(t){let e=[...this._presentationGroup?.querySelectorAll(".zx-app-sidebar__presentation-option")??[]],i=e.indexOf(t.target);if(i<0||t.altKey||t.ctrlKey||t.metaKey)return;let n;if(t.key==="ArrowDown"||t.key==="ArrowRight")n=e[(i+1)%e.length];else if(t.key==="ArrowUp"||t.key==="ArrowLeft")n=e[(i-1+e.length)%e.length];else if(t.key==="Home")n=e[0];else if(t.key==="End")n=e.at(-1);else return;t.preventDefault();let r=n.dataset.presentation;n.focus(),this.setPresentation(r);let o=this._presentationGroup?.querySelector(`.zx-app-sidebar__presentation-option[data-presentation="${r}"]`);o instanceof HTMLElement&&o!==document.activeElement&&o.focus()}_syncPresentationSwitch(){let t=this._presentationGroup;if(!t)return;let e=this.getPresentation();for(let i of[...t.querySelectorAll(".zx-app-sidebar__presentation-option")]){let n=i.dataset.presentation===e;i.setAttribute("aria-checked",String(n)),i.tabIndex=n?0:-1}if(!t.querySelector('[aria-checked="true"]')){let i=t.querySelector(".zx-app-sidebar__presentation-option");i&&(i.tabIndex=0)}}_presentationCycle(){let t=Array.isArray(this.options.presentations)?this.options.presentations:_r,e=this._moduleLabels==="hidden"?"expanded":this._moduleLabels==="below"?"compact":null,i=[...new Set(t)].filter(n=>_r.includes(n)&&(n!=="compact"||this._modules)&&n!==e);return i.length>=2?i:["expanded","collapsed"]}_nextPresentation(){let t=this._presentationCycle(),e=t.indexOf(this.getPresentation());return t[(e+1)%t.length]}_stripLabels(){let t=this._moduleLabels;return t==="below"?"below":this.isCollapsed()||this._compact||t==="hidden"?"hidden":"beside"}_moduleList(){return xs(this._items)}_renderPanel(t){let e=x("zx-app-sidebar-module"),i=l("div",{class:"zx-app-sidebar__panel-title",id:e}),n=l("div",{class:"zx-app-sidebar__panel-lead"}),r=l("ul",{class:"zx-app-sidebar__list"}),o=l("nav",{class:"zx-app-sidebar__nav",ariaLabelledby:e},r),a=l("div",{class:"zx-app-sidebar__panel-content"}),c=l("footer",{class:"zx-app-sidebar__footer"});fe(c,this.options.footer),c.hidden=!c.hasChildNodes();let d=l("div",{class:"zx-app-sidebar__panel",id:t},l("header",{class:"zx-app-sidebar__header"},l("div",{class:"zx-app-sidebar__header-content"},i)),l("div",{class:"zx-app-sidebar__panel-body"},n,o,a),c);return Object.assign(this.refs,{expanded:d,list:r,panelTitle:i,panelLead:n,panelContent:a,panelNav:o}),this._listenTree(r),this._renderPanelContent(),d}_renderPanelContent(){let t=this._shownModule(),{panelTitle:e,panelLead:i,panelContent:n,panelNav:r}=this.refs;e&&(e.textContent=t?.label??"",Xh(i,[this.options.header,t?.header]),Xh(n,[t?.content]),r.hidden=!t?.children?.length,this._renderTree())}_showModule(t,{silent:e=!1}={}){if(!this._modules)return!1;let i=this._moduleList().find(r=>String(r.id)===String(t));if(!i||!Ei(i)||i.disabled)return!1;if(String(i.id)===String(this._shownId))return!0;let n=this._shownId;if(!e&&this.emit("modulechange",{item:i,id:i.id,previous:n}).defaultPrevented)return!1;if(this._shownId=i.id,this._rail instanceof ct&&!this.isCollapsed()&&this._rail.setExpanded(i.id),this.refs.list){this._renderPanelContent();let r=this.refs.expanded?.querySelector(".zx-app-sidebar__panel-body");r instanceof HTMLElement&&(delete r.dataset.moduleMotion,r.offsetWidth,r.dataset.moduleMotion="enter")}return!0}_onModuleSelect(t,e){let i=this._moduleList().find(r=>String(r.id)===String(t.detail.id));if(i&&Ei(i)){t.preventDefault(),this._showModule(i.id)&&!e&&this._orientation==="vertical"&&(this.expand(),Mi(this.refs.list)[0]?.focus());return}this.emit("select",t.detail).defaultPrevented&&t.preventDefault()}_onStripKeydown(t){let e=this._side==="right"?"ArrowLeft":"ArrowRight";if(t.key!==e||t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey)return;let i=t.target.closest?.(".zx-module-bar__item[data-app-nav-value-id]");if(!i)return;let n=this._moduleList().find(o=>String(o.id)===i.getAttribute("data-app-nav-value-id"));if(!n||!Ei(n)||!this._showModule(n.id))return;t.preventDefault();let r=Mi(this.refs.list)[0]??this.refs.expanded?.querySelector('.zx-app-sidebar__panel-body :is(a[href], button, input, select, textarea, [tabindex="0"])');r instanceof HTMLElement&&r.focus()}_shownModule(){return this._moduleList().find(t=>String(t.id)===String(this._shownId))??null}_resolveShown(t){let e=i=>{if(i==null)return null;let n=this._moduleList().find(r=>String(r.id)===String(i));return n&&Ei(n)?n:null};return e(t)?.id??e(pr(this._moduleList(),this._active)?.id)?.id??this._moduleList().find(Ei)?.id??null}_treeItems(){return this._modules?this._shownModule()?.children??[]:this._items}_decorateRail(){let t=this.refs.rail;if(t)for(let e of t.querySelectorAll(".zx-app-rail__item[data-app-nav-value-id]")){let i=e.querySelector(":scope > .zx-app-rail__item-badge");if(!i)continue;let n=Ie(this._items,e.getAttribute("data-app-nav-value-id"));if(!n||n.badge==null)continue;let r=String(n.badge);i.dataset.zxBadge=r.length>2?"dot":"count",e.setAttribute("aria-label",this._message("appSidebar.itemBadge","%1 (%2)",n.label,r))}}_listenMode(t,e,i){t.addEventListener(e,i,{signal:this._modeAbort.signal})}_renderTree(){if(!this.refs.list)return;let t=this.refs.list.contains(document.activeElement)?document.activeElement.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id"):null;if(this.refs.list.replaceChildren(...this._treeItems().map(e=>this._treeRow(e,1))),this._syncActive(),t!==null){let e=[...this.refs.list.querySelectorAll("[data-app-nav-id]")].find(i=>i.getAttribute("data-app-nav-id")===t)??null;xv(e)?.focus()}}_treeRow(t,e){if(t.section)return this._sectionRow(t,e);let i=t.children??[],n=i.length>0,r=String(t.id),o=n&&this._expanded.has(r),a=n?x("zx-app-sidebar-branch"):null,c=Ii(t,this.options.renderIcon,{orientation:this._orientation,collapsed:!1,side:this._side,level:e,location:e===1?"root":"inline"}),d=vv(t,n,o,a,c),u=l("li",{class:"zx-app-sidebar__row",dataset:{level:e}},d);return n&&u.append(l("ul",{class:"zx-app-sidebar__sublist",id:a,hidden:!o},i.map(h=>this._treeRow(h,e+1)))),u}_sectionRow(t,e){let i=x("zx-app-sidebar-section"),n=l("div",{class:"zx-app-sidebar__section-header"},l("span",{class:"zx-app-sidebar__section-label",id:i},t.label));if(t.actions){let r=l("span",{class:"zx-app-sidebar__section-actions"});fe(r,t.actions),n.append(r)}return l("li",{class:"zx-app-sidebar__section"},n,l("ul",{class:"zx-app-sidebar__section-list",ariaLabelledby:i},(t.children??[]).map(r=>this._treeRow(r,e))))}_onTreeClick(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!e||!this.refs.list.contains(e))return;let i=Ie(this._items,e.getAttribute("data-app-nav-id"));if(!i||i.disabled){t.preventDefault();return}i.children?.length?this.toggleBranch(i.id):this._select(i,t)}_onTreeKeydown(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!(e instanceof HTMLElement))return;let i=Ie(this._items,e.getAttribute("data-app-nav-id")),n=Mi(this.refs.list),r=n.indexOf(e);if(t.key==="ArrowRight"&&i?.children?.length){t.preventDefault(),this._expanded.has(String(i.id))?Mi(e.parentElement?.querySelector(".zx-app-sidebar__sublist"))[0]?.focus():this.toggleBranch(i.id);return}if(t.key==="ArrowLeft"){if(i?.children?.length&&this._expanded.has(String(i.id))){t.preventDefault(),this.toggleBranch(i.id);return}let c=e.closest(".zx-app-sidebar__sublist")?.parentElement?.querySelector(":scope > [data-app-nav-id]");if(c instanceof HTMLElement){t.preventDefault(),c.focus();return}if(this._modules&&this._side==="left"&&this._rail instanceof ct){let d=this._rail._tiles().find(u=>u.getAttribute("data-app-nav-value-id")===String(this._shownId));d&&(t.preventDefault(),d.focus())}return}let o;if(t.key==="Home")o=0;else if(t.key==="End")o=n.length-1;else if(t.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(t.key==="ArrowUp")o=Math.max(0,r-1);else return;t.preventDefault(),n[o]?.focus()}_select(t,e){if(t.disabled){e.preventDefault();return}this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e}).defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.())}_syncActive(){if(!this.refs.list)return;let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let i=Ie(this._items,e.getAttribute("data-app-nav-id")),n=t!==null&&e.getAttribute("data-app-nav-id")===t,r=t!==null&&i?Zh(i.children??[],t):!1;n?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),r?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}}_markBranchMotion(t){if(!this.refs.list)return;let i=([...this.refs.list.querySelectorAll("[data-app-nav-id]")].find(n=>n.getAttribute("data-app-nav-id")===t)??null)?.parentElement?.querySelector(":scope > .zx-app-sidebar__sublist");i instanceof HTMLElement&&(i.dataset.branchMotion="expand")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}_reconcileExpanded(){let t=new Set;fl(this._items,e=>{e.children?.length&&!e.section&&t.add(String(e.id))});for(let e of this._expanded)t.has(e)||this._expanded.delete(e)}};function gr(s){return l("span",{class:"zx-app-sidebar__presentation-glyph",ariaHidden:"true",dataset:{presentation:s}},l("span",{class:"zx-app-sidebar__presentation-strip"}),l("span",{class:"zx-app-sidebar__presentation-panel"}))}function Ei(s){return!!(s.children?.length||s.header||s.content)}function vv(s,t,e,i,n){let r=s.href&&!t?"a":"button";return l(r,{class:"zx-app-sidebar__item",type:r==="button"?"button":null,href:r==="a"?s.href:null,target:r==="a"?s.target??null:null,ariaDisabled:s.disabled?"true":null,ariaExpanded:t?String(e):null,ariaControls:i,dataset:{appNavId:String(s.id)}},n?l("span",{class:"zx-app-sidebar__item-icon",ariaHidden:"true"},n):null,l("span",{class:"zx-app-sidebar__item-label"},s.label),s.badge!=null?l("span",{class:"zx-app-sidebar__item-badge"},String(s.badge)):null,t?l("span",{class:"zx-app-sidebar__item-disclosure",ariaHidden:"true"},b(e?"chevron-down":"chevron-right")):null)}function Mi(s){return s?[...s.querySelectorAll("[data-app-nav-id]")].filter(t=>!t.closest(".zx-app-sidebar__sublist[hidden]")):[]}function xv(s){let t=s;for(;t;){let e=t.closest(".zx-app-sidebar__sublist[hidden]");if(!e)return t;t=e.parentElement?.firstElementChild??null}return null}function Ie(s,t){for(let e of s){if(String(e.id)===String(t))return e;let i=Ie(e.children??[],t);if(i)return i}return null}function fl(s,t){for(let e of s)t(e),fl(e.children??[],t)}function Zh(s,t){return s.some(e=>String(e.id)===t||Zh(e.children??[],t))}function fe(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&s.append(t)}function Xh(s,t){let e=document.createDocumentFragment(),i=t.flatMap(r=>{if(r==null)return[];if(typeof r=="object"&&typeof r.toElement=="function"){let o=r.toElement();return o?[o]:[]}return typeof r=="object"&&typeof r.nodeType=="number"?[r]:(fe(e,r),[...e.childNodes])}),n=[...s.childNodes];(i.length!==n.length||i.some((r,o)=>r!==n[o]))&&s.replaceChildren(...i),s.hidden=!s.hasChildNodes()}function Jh(s,t){return s==="horizontal"?t==="bottom"?"bottom":"top":t==="right"?"right":"left"}function tf(s){return s.map(t=>{let{children:e,...i}=t;return e?.length?{...i,children:tf(e)}:i})}var Sv=8e3,_l=class{#t;#e=[];#i=[];#s;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let i=this.#e.indexOf(t);if(i===-1)return null;if(this.#e.splice(i,1),this.#i.length>0){let n=this.#i.shift();this.#e.push(n),this.#s(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},yr=class s extends y{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};render(){let t=!this.el,e=this.el??l("div");return this._createdRoot=t,this._original=t?null:Nv(e),this._entries=new Set,this._floatingHost=null,this._placedIn=null,this._overlay=null,this._unfollow=null,this._queue=new _l(Ev(this.options.maxVisible),i=>{this._activate(i)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let i=Cv(e.action),n={kind:Av(e.kind??this.options.kind),timeout:zv(e.timeout??this.options.timeout,i!==null),closable:e.closable??!!this.options.closable,action:i,leading:Tv(e.leading)},r=this._createEntry(t,n);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#t(e.scope).show(t,e)}static progress(t,e={}){return this.#t(e.scope)._progress(t)}static disposeRegion(t){if(t==null)return!1;let e=P(t);if(!e)return!1;let i=s.#e(vt(e));return i?(i._disposeFloating(),!0):!1}destroy(){if(this._cleaned)return;this._cleaned=!0,this._unfollow?.(),this._unfollow=null;let t=this._overlay;this._overlay=null,t?.release(),this._floatingHost=null,this._placedIn=null;for(let e of this._entries)pl(e),e.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Ov(this.el,this._original)}_progress(t){let e={pct:0,text:String(t)},i=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(i),this._queue.enqueue(i);let n=!1;return{update:(r,o)=>{n||i.closed||(e.pct=Mv(r),o!==void 0&&(e.text=String(o)),br(i,e))},done:()=>{n||i.closed||(n=!0,e.pct=100,br(i,e),i.remaining=600,this._queue.isActive(i)&&this._schedule(i))},fail:r=>{n||i.closed||(n=!0,r!==void 0&&(e.text=String(r)),i.kind="error",i.node.dataset.kind="error",i.node.setAttribute("role","alert"),i.iconHost.replaceChildren(b("error",{size:18})),br(i,e),i.remaining=4e3,this._queue.isActive(i)&&this._schedule(i))}}}_createEntry(t,e,i=null){let n=l("span",{class:"zx-message__icon",ariaHidden:"true"},e.leading??b(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});Ss(t)?r.append(t):r.append(document.createTextNode(String(t)));let o=l("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,hovered:!1,focused:!1,returnFocus:null,progressBar:null,progressFill:null};if(e.leading&&(o.dataset.leading=""),i){o.dataset.progress="";let c=l("span",{class:"zx-message__progress-fill"}),d=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:i.text},c);r.append(d),a.progressBar=d,a.progressFill=c,br(a,i)}if(e.action){let{label:c,kind:d,onclick:u}=e.action,h=j({label:c,kind:d,size:"sm"});h.classList.add("zx-message__action"),o.append(h),this.listen(h,"click",f=>{if(!a.closed)try{u?.(f)}finally{this._close(a)}})}if(e.closable){let c=l("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:this._message("message.close","Close message"),title:this._message("message.closeTitle","Close")},b("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>{a.hovered=!0,this._pause(a)}),this.listen(o,"mouseleave",()=>{a.hovered=!1,this._resume(a)}),this.listen(o,"focusin",c=>{if(!a.focused){let d=c.relatedTarget;a.returnFocus=Ss(d)&&!o.contains(d)?d:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",c=>{let d=c.relatedTarget;Ss(d)&&o.contains(d)||(a.focused=!1,this._resume(a))}),a}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||t.hovered||t.focused||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null||t.hovered||t.focused)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,pl(t),Iv(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t),this._releaseIfEmpty();return}if(t.node.dataset.state="closing",!Dv()){this._finish(t);return}let e=i=>{i.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(pl(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t),this._releaseIfEmpty())}_releaseIfEmpty(){!this._floatingHost||this._entries.size>0||s.#i(this)}_rehome(){let t=this._floatingHost;if(!t)return;let e=ui.topmostModal()??t;if(this.el.parentElement===e&&this._placedIn===e)return;e.append(this.el),this._placedIn=e;let i=this.el;typeof i.showPopover=="function"&&!i.matches(":popover-open")&&i.showPopover()}_disposeFloating(){let t=this.el;this.destroy(),t.remove()}_message(t,e){let i=this.msg(t);return i===t?e:i}static#t(t){let e=vt(t??null);e.isConnected||(e=vt(null));let i=this.#e(e);if(i&&i.el.isConnected&&i.el.parentElement===i._placedIn)return i._rehome(),i;i?._disposeFloating();let n=l("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"}),r=new s(n);return r._floatingHost=e,r._overlay=ui.push({kind:"toast",root:n,owner:r}),r._unfollow=ui.subscribe(()=>r._rehome()),r._rehome(),r}static#e(t){for(let e of ui.entries())if(e.kind==="toast"&&e.owner instanceof s&&e.owner._floatingHost===t)return e.owner;return null}static#i(t){t._disposeFloating()}};function Av(s){return s==="danger"?"error":["success","warning","error"].includes(String(s))?s:"info"}function kv(s){let t=Number(s);return Number.isFinite(t)?Math.max(0,t):4e3}function zv(s,t=!1){let e=kv(s);return t&&e>0?Math.max(e,Sv):e}function Cv(s){if(!s||typeof s!="object")return null;let t=s,e=t.label==null?"":String(t.label).trim();if(!e)return null;let i=["primary","danger","ghost"].includes(String(t.kind))?t.kind:"default";return{label:e,kind:i,onclick:typeof t.onclick=="function"?t.onclick:null}}function Tv(s){if(Ss(s))return s;if(s&&typeof s=="object"&&typeof s.toElement=="function"){let t=s.toElement();return Ss(t)?t:null}return null}function Iv(s){let e=s.node.getRootNode?.()?.activeElement??globalThis.document?.activeElement;if(!e||!s.node.contains(e))return;let i=s.returnFocus;s.returnFocus=null,i?.isConnected&&typeof i.focus=="function"&&i.focus({preventScroll:!0})}function Ev(s){let t=Number(s);return Number.isInteger(t)&&t>0?t:5}function Ss(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Mv(s){let t=Number(s);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function br(s,t){s.content.firstChild.textContent=t.text,s.progressBar?.setAttribute("aria-valuenow",String(t.pct)),s.progressBar?.setAttribute("aria-label",t.text),s.progressFill&&(s.progressFill.style.inlineSize=`${t.pct}%`)}function pl(s){s.timer!==null&&clearTimeout(s.timer),s.exitTimer!==null&&clearTimeout(s.exitTimer),s.timer=null,s.exitTimer=null}function Dv(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Nv(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Ov(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var Fv=new Set(["start","end","top","bottom"]),Lv=new Set(["dim","blur","none"]),Rv=Object.freeze({start:1,end:-1,top:1,bottom:-1}),wr=class extends qt{static cssName="sheet";static defaults={side:"end",modal:!0,backdrop:"dim",size:null,closeButton:!0,resizable:!1,min:160,max:null,handle:"auto",snap:null,lightDismiss:!0};#t=null;#e=null;#i=0;constructor(t=null,e={}){super(null,e),this._dock=null,this._openedFrom=null,this.setSide(this.options.side),this.el.dataset.backdrop=Lv.has(this.options.backdrop)?this.options.backdrop:"dim",this.el.dataset.modality=Vv(this.options.modal),this.refs.close.hidden=!this.options.closeButton,this.on("close",()=>this.#t?.deactivate()),this.on("close",()=>{let i=super.mountTarget();!this._dock&&this.el.parentElement!==i&&this.el.parentElement?.closest("dialog")&&i.append(this.el)}),this.#s()&&this.#r()}#s(){let t=this.options.handle,e=this.getSide(),i=t===!0||t==="auto"&&(e==="top"||e==="bottom");return!!this.options.resizable||Array.isArray(this.options.snap)||i}#r(){let t=this.getSide()==="top"||this.getSide()==="bottom",e=l("div",{class:"zx-sheet__handle",ref:"handle",role:"separator",tabindex:0,ariaOrientation:t?"horizontal":"vertical",ariaLabel:this._message("sheet.resize","Resize sheet")});this.el.append(e),this.refs.handle=e,this.#l(),this.#e=wi(e,{orientation:t?"vertical":"horizontal",disabled:()=>this.isDocked(),onStart:()=>{this.#i=this.getSize(),this.el.dataset.dragging="true"},onMove:i=>this.#n(i,!1),onEnd:(i,n)=>{delete this.el.dataset.dragging,n&&this.#n(i,!0)},onStep:(i,n)=>{this.#i=this.getSize(),this.#n(i*(n?64:16),!0)}})}#n(t,e){let i=this.#o(),{min:n,max:r}=this.#a(i),a=!!this.options.resizable||this.#c(i).length>0?r:Math.min(r,this.#i),c=q(this.#i+t*Rv[this.getSide()],0,a);if(!e){this._applySize(c),this.#l();return}if(this.options.closable&&c<n/2){this._applySize(this.#i),this.close();return}let d=this.#c(i),u=d.length>0?Bv(c,d):c;this._applySize(q(u,n,a)),this.#l(),this.emit("resize",{size:this.getSize(),ratio:i>0?this.getSize()/i:0})}snapTo(t){let e=this.#o(),i=this.#c(e);if(i.length===0)return this;let n=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<i.length?i[t]:ef(t,e);if(!Number.isFinite(n))return this;let{min:r,max:o}=this.#a(e);return this._applySize(q(n,r,o)),this.#l(),this.emit("resize",{size:this.getSize(),ratio:e>0?this.getSize()/e:0}),this}getSize(){let t=this.el.getBoundingClientRect();return this.getSide()==="top"||this.getSide()==="bottom"?t.height:t.width}_message(t,e){let i=this.msg(t);return i===t?e:i}#o(){return this.getSide()==="top"||this.getSide()==="bottom"?window.innerHeight:window.innerWidth}#a(t){let e=this.#c(t),i=Math.max(0,Number(this.options.min)||0),n=this.options.max==null?t:Math.min(t,Number(this.options.max)||t),r=e.length>0?Math.max(i,Math.min(...e)):i;return{min:Math.min(r,n),max:n}}#c(t){let e=this.options.snap;return Array.isArray(e)?e.map(i=>ef(i,t)).filter(i=>Number.isFinite(i)&&i>0).sort((i,n)=>i-n):[]}#l(){let t=this.refs.handle;if(!t)return;let e=this.#o(),{min:i,max:n}=this.#a(e);t.setAttribute("aria-valuenow",String(Math.round(this.getSize()))),t.setAttribute("aria-valuemin",String(Math.round(i))),t.setAttribute("aria-valuemax",String(Math.round(n)))}mountTarget(){if(this._dock)return this._dock.el;if(this.el&&this.options.modal!==!0){let t=this._openedFrom??P(this.options.scope),e=Pv(t,this.el);if(e)return e}return super.mountTarget()}isDocked(){return!!this._dock}_setDock(t){this._dock!==t&&(this._dock=t??null,this.el.toggleAttribute("data-docked",!!this._dock),this._rehost(),this.emit("dockchange",{docked:!!this._dock,dock:this._dock}))}_rehost(){let t=this.isOpen();t&&this._dismiss(),this.mountTarget().append(this.el),t&&(this.el.returnValue="",this._present(),this.el.dataset.state="open",this._syncOverlay())}_overlayEntry(){if(this._dock)return null;let t=super._overlayEntry();return!t||this.options.modal===!0?t:{...t,onEscape:e=>{if(!this.options.closable||!this._overlayContains(e.target))return!1;this.emit("cancel").defaultPrevented||this.close()},onOutsidePointer:this.options.lightDismiss?()=>{this.close()}:void 0,onParentClose:()=>{let e=this.el.parentElement?.closest("dialog");e&&!e.open&&!e.matches(":popover-open")&&this.close()}}}open(){if(this.isOpen())return this;this._openedFrom=document.activeElement,this.options.modal==="trap-focus"&&(this.#t??=un(this.el),this.#t.activate());try{super.open()}finally{this._openedFrom=null}return this.#l(),this}close(t){return this.#t?.deactivate(),super.close(t)}setSide(t){return this.el.dataset.side=Fv.has(t)?t:"end",this}getSide(){return this.el.dataset.side}setSize(t){return this._applySize(t),this}isModal(){return this.options.modal===!0}_applySize(t){this.el.style.removeProperty("inline-size"),this.el.style.removeProperty("block-size");let e=jv(t);e===null?this.el.style.removeProperty("--zx-sheet-size"):this.el.style.setProperty("--zx-sheet-size",e)}_show(){if(this.options.modal===!0&&!this._dock){this.el.removeAttribute("popover"),this.el.removeAttribute("aria-modal"),super._show();return}if(this.el.setAttribute("aria-modal","false"),this._dock){this.el.removeAttribute("popover"),this.el.show();return}this.el.setAttribute("popover","manual"),this.el.showPopover()}_hide(t="",e){if(!this.el.matches(":popover-open")){super._hide(t,e);return}this.el.returnValue=t,this.el.hidePopover(),queueMicrotask(()=>this._settleClose(e))}_isShown(){return this.el.matches(":popover-open")||super._isShown()}destroy(){this.#t?.deactivate(),this.#t=null,this.#e?.destroy(),this.#e=null,this._dock?._forget(this),this._dock=null,super.destroy()}};function Pv(s,t){if(!s||typeof s.closest!="function"||t.contains(s))return null;try{return s.closest("dialog:modal")}catch{return null}}function ef(s,t){return typeof s=="number"&&Number.isFinite(s)&&s>0&&s<=1?s*t:_t(s,t)}function Bv(s,t){let e=s,i=Number.POSITIVE_INFINITY;for(let n of t){let r=Math.abs(n-s);r<i&&(i=r,e=n)}return e}function Vv(s){return s===!0?"modal":s==="trap-focus"?"trap-focus":"none"}function jv(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}var vr=class s extends EventTarget{static defaults=Object.freeze({layout:"stack",offset:24,scale:.04,max:3});#t=[];#e=new WeakMap;#i=!1;constructor(t={}){super();let e={...s.defaults,...t&&typeof t=="object"?t:{}};for(let[i,n]of Object.entries(e))!/^on[a-z]/.test(i)||typeof n!="function"||(this.on(i.slice(2),n),delete e[i]);this.options=Object.freeze(e)}push(t){if(!t||typeof t.open!="function")throw new TypeError("SheetStack.push expects a Sheet");let e=this.#t.indexOf(t);if(e!==-1&&this.#t.splice(e,1),this.#t.push(t),!this.#e.has(t)){let i=()=>this.#s(t);this.#e.set(t,i),t.on("close",i)}return t.isOpen()||t.open(),this.#n(),this.#o("push",{sheet:t,depth:0}),this}pop(){let t=this.top();return t?(this.#r(t),t.close(),t):null}popTo(t){let e=this.#t.indexOf(t);if(e===-1)return this;for(;this.#t.length>e+1;)this.pop();return this}clear(){for(;this.#t.length>0;)this.pop();return this}top(){return this.#t[this.#t.length-1]??null}size(){return this.#t.length}sheets(){return[...this.#t]}has(t){return this.#t.includes(t)}on(t,e){return this.addEventListener(t,e),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0}),this}destroy(){if(!this.#i){this.#i=!0;for(let t of this.#t){let e=this.#e.get(t);e&&t.off("close",e),sf(t)}this.#t=[]}}#s(t){this.#t.includes(t)&&this.#r(t)}#r(t){let e=this.#t.indexOf(t);if(e===-1)return;this.#t.splice(e,1);let i=this.#e.get(t);i&&t.off("close",i),this.#e.delete(t),sf(t),this.#n(),this.#o("pop",{sheet:t})}#n(){let{layout:t,offset:e,scale:i,max:n}=this.options,r=t==="cascade",o=0;for(let a=0;a<this.#t.length;a+=1){let c=this.#t[this.#t.length-1-a],d=c.el;d.dataset.stack=r?"cascade":"stack",d.dataset.depth=String(a),d.style.setProperty("--zx-sheet-depth",String(a)),d.style.setProperty("--zx-sheet-stack-offset",`${Number(e)||0}px`),d.style.setProperty("--zx-sheet-stack-scale",String(Number(i)||0)),d.toggleAttribute("data-stack-hidden",a>=Math.max(1,Number(n)||1)),d.inert=!r&&a>0,r?(d.style.setProperty("--zx-sheet-depth-offset",`${o}px`),o+=c.getSize()):d.style.removeProperty("--zx-sheet-depth-offset")}}#o(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}};function sf(s){let t=s.el;if(t){delete t.dataset.stack,delete t.dataset.depth,t.removeAttribute("data-stack-hidden"),t.inert=!1;for(let e of["--zx-sheet-depth","--zx-sheet-stack-offset","--zx-sheet-stack-scale","--zx-sheet-depth-offset"])t.style.removeProperty(e)}}var Di=class extends y{static defaults={items:[],selector:null};#t;#e;#i;#s;#r;#n=[];#o=null;#a=null;#c=!1;constructor(t,e={}){let i=P(t);if(!i)throw new TypeError("ContextMenu target could not be resolved");super(null,e),this.#t=i,document.body.append(this.el),this.#e=new pt(this.el,{openOn:"manual",placement:"bottom-start",scope:i}),this.#i=this.#e.getPanel(),this.#e._configure({onEscape:()=>this.close(),tabReach:!1}),this.#i.classList.add("zx-context-menu"),this.#i.setAttribute("role","menu"),Array.isArray(this.options.items)&&this.setItems(this.options.items),this.#s=Mt(this.#i,Lt),this.#r=ut(()=>this.#m(),n=>n.focus()),this.#e.on("close",()=>{this.#o=null;let n=this.#a;this.#a=null,n instanceof HTMLElement&&n.isConnected&&n.focus(),this.emit("close")}),this.listen(this.#t,"contextmenu",n=>this.#f(n)),this.listen(this.#t,"keydown",n=>this.#h(n)),this.listen(this.#i,"click",n=>{let r=n.target.closest?.(Lt);r&&this.#i.contains(r)&&this.#_(r,n)}),this.listen(this.#i,"keydown",n=>this.#p(n))}render(){return l("span",{class:"zx-context-menu__anchor",ariaHidden:"true"})}setItems(t){return this.#n=Array.isArray(t)?t.slice():[],this.#i.replaceChildren(...On(this.#n,"context-menu")),this}openAt(t,e,i=null){return this.#l(i)?(this.#d(t,e,i),this):this}openAtElement(t){let e=t.getBoundingClientRect();return this.openAt(e.left,e.bottom,t)}close(){return this.#e.close(),this}isOpen(){return this.#e.isOpen()}getContext(){return this.#o}destroy(){this.#c||(this.#c=!0,this.#s.destroy(),this.#e.destroy(),super.destroy())}#l(t){let e=this.options.items;if(typeof e=="function"){let i=e(t);if(!Array.isArray(i)||i.length===0)return!1;this.setItems(i)}return this.#n.length>0}#d(t,e,i){let n=this.el;n.style.left=`${t}px`,n.style.top=`${e}px`,this.#o=i,this.#a=document.activeElement,this.#e.open(),this.#s.focusFirst(),this.emit("open",{context:i})}#f(t){let e=t,i=this.#u(e.target);!i||!this.#l(i)||(t.preventDefault(),this.#d(e.clientX,e.clientY,i))}#h(t){let e=t;if(e.key!=="ContextMenu"&&!(e.key==="F10"&&e.shiftKey))return;let i=this.#u(e.target);if(!i||!this.#l(i))return;t.preventDefault();let n=i.getBoundingClientRect();this.#d(n.left,n.bottom,i)}#u(t){if(!this.options.selector)return this.#t;let e=t?.closest?.(String(this.options.selector));return e&&this.#t.contains(e)?e:null}#p(t){let e=t;if(e.key==="Tab"){t.preventDefault(),this.close();return}if(e.key==="Enter"||e.key===" "){let i=e.target.closest?.(Lt);if(!i||!this.#i.contains(i)||e.key==="Enter"&&i.tagName==="A")return;t.preventDefault(),i.click();return}this.#r(e)}#_(t,e=null){let i=Number(t.getAttribute("data-menu-item")),n=this.#n[i];if(!cs(n)||n.disabled){e?.preventDefault();return}let r=this.#o;if(this.emit("select",{value:n.value,item:n,context:r}).defaultPrevented){e?.preventDefault();return}try{n.onselect?.(n.value,n,this)}finally{this.close()}}#m(){return Array.from(this.#i.querySelectorAll(Lt))}};var ks=Object.freeze(["agenda","day","week","month","year"]),Hv=864e5;function Sr(s,t,e={}){let i=Me(t,"Calendar date"),n=df(e.weekStart??1),r,o;if(s==="agenda")r=Y(i),o=R(r,zr(e.agendaDays??14,"agendaDays"));else if(s==="day")r=Y(i),o=R(r,1);else if(s==="week")r=As(i,n),o=R(r,7);else if(s==="month"){let a=new Date(i.getFullYear(),i.getMonth(),1),c=new Date(i.getFullYear(),i.getMonth()+1,0);r=As(a,n),o=R(As(c,n),7)}else if(s==="year")r=new Date(i.getFullYear(),0,1),o=new Date(i.getFullYear()+1,0,1);else throw new RangeError(`Unknown calendar view: ${s}`);return{start:r,end:o}}function Ar(s,t,e,i={}){let n=Me(t,"Calendar date"),r=Gt(e,"direction");if(s==="day")n.setDate(n.getDate()+r);else if(s==="agenda")n.setDate(n.getDate()+r*zr(i.agendaDays??14,"agendaDays"));else if(s==="week")n.setDate(n.getDate()+r*7);else{if(s==="month")return xr(n,r);if(s==="year")return xr(n,r*12);throw new RangeError(`Unknown calendar view: ${s}`)}return n}function xr(s,t){let e=Me(s,"Calendar date"),i=e.getDate();return e.setDate(1),e.setMonth(e.getMonth()+Gt(t,"month amount")),e.setDate(Math.min(i,qv(e.getFullYear(),e.getMonth()))),e}function qv(s,t){return new Date(s,t+1,0).getDate()}function Ee(s,t={}){if(!Array.isArray(s))throw new TypeError("Calendar events must be an array");let e={id:t.eventId??"id",title:t.eventTitle??"title",start:t.eventStart??"start",end:t.eventEnd??"end",allDay:t.eventAllDay??"allDay",color:t.eventColor??"color",location:t.eventLocation??"location",editable:t.eventEditable??"editable",durationEditable:t.eventDurationEditable??"durationEditable"},i=t.dateUnit==="seconds"?"seconds":"milliseconds",n=new Set;return s.map((r,o)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError(`Calendar event at index ${o} must be an object`);let a=Yt(r,e.id);if(a==null||a==="")throw new TypeError(`Calendar event at index ${o} requires an id`);let c=String(a);if(n.has(c))throw new RangeError(`Duplicate Calendar event id: ${c}`);n.add(c);let d=rf(Yt(r,e.start),i,`event ${c} start`),u=Yt(r,e.end),h=u==null||u===""?new Date(d.getTime()):rf(u,i,`event ${c} end`);if(h<d)throw new RangeError(`Calendar event ${c} ends before it starts`);let f=String(Yt(r,e.title)??"").trim()||"Untitled event",p=String(Yt(r,e.location)??"").trim(),_=of(Yt(r,e.editable)),m=of(Yt(r,e.durationEditable));return{id:a,title:f,start:d,end:h,allDay:!!Yt(r,e.allDay),color:Kv(Yt(r,e.color)),location:p,editable:_,durationEditable:m,data:r}})}function G(s){return{...s,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())}}function kr(s,t,e={}){let i=cf(e.minMinutes??0,"minMinutes"),n=cf(e.maxMinutes??1440,"maxMinutes",!0),r=zr(e.minimumMinutes??30,"minimumMinutes");if(n<=i)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=Y(t),a=af(o,i),c=af(o,n),d=s.filter(p=>!kt(p)&&ml(p,a,c)).map(p=>{let _=new Date(Math.max(p.start.getTime(),a.getTime())),m=new Date(Math.min(p.end.getTime(),c.getTime()));return m<=_&&(m=new Date(Math.min(c.getTime(),_.getTime()+r*6e4))),{event:p,start:_,end:m,startMinutes:lf(o,_),endMinutes:lf(o,m),column:0,columns:1}}).sort((p,_)=>p.start-_.start||_.end-p.end||String(p.event.id).localeCompare(String(_.event.id))),u=[],h=-1/0,f=()=>{if(!u.length)return;let p=[],_=1;for(let m of u){let g=p.findIndex(w=>w<=m.start.getTime());g===-1&&(g=p.length),p[g]=m.end.getTime(),m.column=g,_=Math.max(_,g+1)}for(let m of u)m.columns=_;u=[],h=-1/0};for(let p of d)u.length&&p.start.getTime()>=h&&f(),u.push(p),h=Math.max(h,p.end.getTime());return f(),d}function zs(s,t,e){let i=Y(t),n=R(i,zr(e,"days")),r=s.filter(a=>kt(a)&&ml(a,i,n)).map(a=>{let c=Y(a.start),d=$v(a);return{event:a,start:Math.max(0,At(i,c)),end:Math.min(e,At(i,d)),lane:0}}).filter(a=>a.end>a.start).sort((a,c)=>a.start-c.start||c.end-a.end||String(a.event.id).localeCompare(String(c.event.id))),o=[];for(let a of r){let c=o.findIndex(d=>d<=a.start);c===-1&&(c=o.length),a.lane=c,o[c]=a.end}return r}function Ni(s,t={}){let e=Gt(t.days??0,"days"),i=Gt(t.minutes??0,"minutes"),n=Gt(t.endDays??e,"endDays"),r=Gt(t.endMinutes??i,"endMinutes"),o=G(s);if(o.start=nf(o.start,e,i),o.end=nf(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function Y(s){let t=Me(s,"Calendar date");return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function R(s,t){let e=Me(s,"Calendar date"),i=new Date(e.getTime());return i.setDate(i.getDate()+Gt(t,"day amount")),i}function As(s,t=1){let e=Y(s),i=df(t);return R(e,-((e.getDay()-i+7)%7))}function At(s,t){let e=Y(s),i=Y(t),n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate());return Math.round((r-n)/Hv)}function X(s){let t=Me(s,"Calendar date"),e=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function kt(s){if(s.allDay)return!0;if(s.end<=s.start)return!1;let t=new Date(s.end.getTime()-1);return X(s.start)!==X(t)}function Oi(s,t,e){return ml(s,t,e)}function nf(s,t,e){let i=new Date(s.getTime());return i.setDate(i.getDate()+t),i.setMinutes(i.getMinutes()+e),i}function $v(s){if(s.end<=s.start)return R(Y(s.start),1);let t=Y(s.end);return s.end.getTime()===t.getTime()?t:R(t,1)}function ml(s,t,e){let i=s.end>s.start?s.end:new Date(s.start.getTime()+1);return s.start<e&&i>t}function Yt(s,t){return typeof t=="function"?t(s):s[t]}function rf(s,t,e){let i;if(s instanceof Date)i=new Date(s.getTime());else if(typeof s=="number"||typeof s=="string"&&/^-?\d+(?:\.\d+)?$/.test(s.trim())){let n=Number(s);i=new Date(n*(t==="seconds"?1e3:1))}else i=new Date(s);return Me(i,e)}function of(s){return s==null?null:!!s}function Kv(s){let t=String(s??"").trim();return!t||t.length>100||/[;{}]|url\s*\(|image\s*\(/i.test(t)?null:/^#[\da-f]{3,8}$/i.test(t)||/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\([^{};]+\)$/i.test(t)||/^var\(--[\w-]+\)$/i.test(t)||/^[a-z]+$/i.test(t)?t:null}function af(s,t){let e=Y(s);return e.setMinutes(t),e}function lf(s,t){return(t.getTime()-s.getTime())/6e4}function Me(s,t){if(!(s instanceof Date)||Number.isNaN(s.getTime()))throw new TypeError(`${t} must be a valid Date`);return new Date(s.getTime())}function df(s){let t=Number(s);if(!Number.isInteger(t)||t<0||t>6)throw new RangeError("weekStart must be from 0 through 6");return t}function Gt(s,t){let e=Number(s);if(!Number.isInteger(e))throw new TypeError(`${t} must be an integer`);return e}function zr(s,t){let e=Gt(s,t);if(e<=0)throw new RangeError(`${t} must be greater than zero`);return e}function cf(s,t,e=!1){let i=Gt(s,t),n=e?1440:1439;if(i<0||i>n)throw new RangeError(`${t} must be from 0 through ${n}`);return i}var Tr=class extends y{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...ks],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 t=!this.el,e=this.el??l("section");this.el||(this.el=e),this._createdRoot=t,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes).map(({name:h,value:f})=>[h,f]),children:Array.from(e.childNodes)},this._views=Uv(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=uf(this.options.date,this.options.dateUnit,this._now()),this._events=Ee(this.options.events,this._normalizeOptions()),this._loading=!1,this._destroyed=!1,this._pointer=null,this._keyboardEdit=null,this._mutationVersions=new Map,this._mutationSerial=0,this._suppressClickId=null,this._suppressDateClick=!1,this._focusedSlot=null,this._selection=null,this._nowTimer=null;let i=l("div",{class:"zx-calendar__navigation"},this._toolbarButton("previous",this.msg("calendar.previous"),"chevron-left"),this._toolbarButton("today",this.msg("calendar.today")),this._toolbarButton("next",this.msg("calendar.next"),"chevron-right")),n=l("h2",{ref:"heading",class:"zx-calendar__heading",ariaLive:"polite"}),r=l("div",{ref:"views",class:"zx-calendar__views",role:"group",ariaLabel:this._message("calendar.viewSwitch","Calendar view")},this._views.map(h=>l("button",{type:"button",class:"zx-calendar__view-button",dataset:{calendarAction:"view",view:h},disabled:this.options.disabled},this.msg(`calendar.${h}`)))),o=l("div",{class:"zx-calendar__commands"},r,l("button",{type:"button",class:"zx-calendar__new",dataset:{calendarAction:"new"},disabled:this.options.disabled},b("plus"),l("span",{},this.msg("calendar.new")))),a=l("header",{class:"zx-calendar__toolbar"},i,n,o),c=l("div",{ref:"body",class:"zx-calendar__body"}),d=l("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("calendar.loading")),u=l("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return e.replaceChildren(a,c,d,u),e.setAttribute("aria-label",this.msg("calendar.label")),e.dataset.view=this._view,e.dataset.state="ready",this.listen(e,"click",h=>this._onClick(h)),this.listen(e,"dblclick",h=>this._onDoubleClick(h)),this.listen(e,"keydown",h=>this._onKeydown(h)),this.listen(e,"pointerdown",h=>this._onPointerDown(h)),this.listen(e,"pointermove",h=>this._onPointerMove(h)),this.listen(e,"pointerup",h=>this._onPointerUp(h)),this.listen(e,"pointercancel",h=>this._cancelPointer(h)),this.listen(e,"dragstart",h=>h.preventDefault()),this._renderView({emitDates:!0,scroll:!0}),this.options.nowIndicator&&(this._nowTimer=setInterval(()=>this._refreshNowIndicator(),6e4)),e}getEvents(){return this._events.map(G)}setEvents(t,e={}){let i=Ee(t,this._normalizeOptions());return this._events=i,this._mutationVersions.clear(),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}addEvent(t,e={}){let[i]=Ee([t],this._normalizeOptions());if(this._eventById(i.id))throw new RangeError(`Duplicate Calendar event id: ${i.id}`);return this._events=[...this._events,i],this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}updateEvent(t,e,i={}){let n=this._eventIndex(t);if(n<0)throw new RangeError(`Unknown Calendar event id: ${t}`);let r=this._events[n],o={id:r.id,title:e.title??r.title,start:e.start??r.start,end:e.end??r.end,allDay:e.allDay??r.allDay,color:Object.prototype.hasOwnProperty.call(e,"color")?e.color:r.color,location:e.location??r.location,editable:Object.prototype.hasOwnProperty.call(e,"editable")?e.editable:r.editable,durationEditable:Object.prototype.hasOwnProperty.call(e,"durationEditable")?e.durationEditable:r.durationEditable,data:e.data??r.data},[a]=Ee([o],{dateUnit:this.options.dateUnit});return a.data=o.data,this._events=this._events.map((c,d)=>d===n?a:c),this._mutationVersions.delete(String(t)),this._renderView({preserveFocus:!0}),i.silent||this.emit("eventschange",{events:this.getEvents()}),this}removeEvent(t,e={}){let i=String(t),n=this._events.filter(r=>String(r.id)!==i);return n.length===this._events.length?this:(this._events=n,this._mutationVersions.delete(i),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this)}getDate(){return new Date(this._date.getTime())}setDate(t,e={}){return this._date=uf(t,this.options.dateUnit,this._now()),this._renderView({emitDates:!e.silent,preserveFocus:!0,scroll:!0}),this}getView(){return this._view}setView(t,e={}){if(!this._views.includes(t))throw new RangeError(`Calendar view is not enabled: ${t}`);if(t===this._view)return this;let i=this._view;return this._view=t,this.el.dataset.view=t,this._renderView({emitDates:!0,preserveFocus:!0,scroll:!0}),e.silent||this.emit("viewchange",{view:t,oldView:i}),this}prev(){return this._page(-1)}next(){return this._page(1)}today(){return this.setDate(this._now())}setLoading(t=!0){return this._loading=!!t,this.el.dataset.state=this._loading?"loading":"ready",this.el.setAttribute("aria-busy",String(this._loading)),this.refs.loading.hidden=!this._loading,this}focusEvent(t){return this.el.querySelector(`[data-event-action][data-event-id="${Cr(String(t))}"]`)?.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._nowTimer&&clearInterval(this._nowTimer),this._nowTimer=null;let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_toolbarButton(t,e,i=null){return l("button",{type:"button",class:"zx-calendar__toolbar-button",dataset:{calendarAction:t},ariaLabel:i?e:null,disabled:this.options.disabled},i?b(i):e)}_normalizeOptions(){return{eventId:this.options.eventId,eventTitle:this.options.eventTitle,eventStart:this.options.eventStart,eventEnd:this.options.eventEnd,eventAllDay:this.options.eventAllDay,eventColor:this.options.eventColor,eventLocation:this.options.eventLocation,eventEditable:this.options.eventEditable,eventDurationEditable:this.options.eventDurationEditable,dateUnit:this.options.dateUnit}}_renderView(t={}){if(!this.refs?.body||this._destroyed)return;let e=t.preserveFocus?this._focusIdentity():null,i=Sr(this._view,this._date,{weekStart:this.options.weekStart,agendaDays:this.options.agendaDays});this._range=i,this.refs.heading.textContent=this._rangeTitle(i);for(let r of this.refs.views.querySelectorAll("[data-view]"))r.setAttribute("aria-pressed",String(r.dataset.view===this._view));let n=this._view==="agenda"?this._renderAgenda(i):this._view==="day"||this._view==="week"?this._renderTimeGrid(i):this._view==="month"?this._renderMonth(i):this._renderYear(i);this.refs.body.replaceChildren(n),t.scroll&&this._scrollTimeGrid(),e&&this._restoreFocus(e),t.emitDates&&this.emit("dateschange",{view:this._view,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())})}_renderAgenda(t){let e=l("div",{class:"zx-calendar__agenda",role:"grid",ariaLabel:this._rangeTitle(t)}),i=At(t.start,t.end);for(let n=0;n<i;n+=1){let r=R(t.start,n),o=R(r,1),a=this._events.filter(u=>Oi(u,r,o)?u.start>=r||n===0:!1).sort(Wv),c=l("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:X(r)}},l("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:X(r),dateCell:"true"},ariaCurrent:Ne(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),d=l("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)d.append(l("p",{class:"zx-calendar__agenda-empty"},this.msg("calendar.noEvents")));else for(let u of a)d.append(this._eventElement(u,{variant:"agenda",day:r}));c.append(d),e.append(c)}return e}_renderTimeGrid(t){let e=Array.from({length:At(t.start,t.end)},(w,v)=>R(t.start,v)),i=this._view==="week"&&this.options.workweek?e.filter(w=>w.getDay()>0&&w.getDay()<6):e,n=Wt(this.options.slotMinTime,0),r=Wt(this.options.slotMaxTime,1440,!0),o=zt(this.options.slotDuration);if(r<=n)throw new RangeError("slotMaxTime must exceed slotMinTime");let a=Math.ceil((r-n)/o),c=l("div",{class:"zx-calendar__time-surface",style:{"--zx-calendar-day-count":String(i.length)}}),d=l("div",{class:"zx-calendar__time-header"},l("span",{class:"zx-calendar__time-corner",ariaHidden:"true"}),l("div",{class:"zx-calendar__day-headings",role:"row"},i.map(w=>l("button",{type:"button",class:"zx-calendar__day-heading",role:"columnheader",dataset:{calendarAction:"date",date:X(w),dateCell:"true"},ariaCurrent:Ne(w,this._now())?"date":null,disabled:this.options.disabled},l("span",{class:"zx-calendar__day-weekday"},this._format(w,{weekday:"short"})),l("span",{class:"zx-calendar__day-number"},this._format(w,{day:"numeric",month:"short"})))))),u=this._renderAllDayRail(i),h=l("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),f=l("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),p=l("div",{class:"zx-calendar__time-grid",role:"grid",ariaLabel:this._rangeTitle(t),ariaRowcount:String(a),ariaColcount:String(i.length),style:{"--zx-calendar-slot-count":String(a)}}),_=l("div",{ref:"slots",class:"zx-calendar__slots"}),m=!0;for(let w=0;w<a;w+=1){let v=n+w*o;f.append(l("span",{class:"zx-calendar__time-label"},v%60===0?gl(v,this.options.locale):""));for(let z=0;z<i.length;z+=1){let C=Gv(i[z],v),k=String(C.getTime()),M=this._focusedSlot?this._focusedSlot===k:m;M&&(m=!1),_.append(l("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:M?0:-1,dataset:{calendarAction:"date",slot:k,dateTime:k,dayIndex:String(z),rowIndex:String(w),major:v%60===0?"true":null},ariaLabel:this._dateTimeLabel(C),disabled:this.options.disabled}))}}let g=l("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return i.forEach((w,v)=>{let z=kr(this._events,w,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let C of z){let k=(C.startMinutes-n)/(r-n)*100,M=Math.max(o/(r-n)*100,(C.endMinutes-C.startMinutes)/(r-n)*100),it=100/i.length,F=it/C.columns,st=v*it+C.column*F,bt=this._eventElement(C.event,{variant:"timed",day:w,resizable:!0});bt.style.insetInlineStart=`${st}%`,bt.style.inlineSize=`${F}%`,bt.style.insetBlockStart=`${k}%`,bt.style.blockSize=`${M}%`,g.append(bt)}}),p.append(_,g,this._nowLine(i,n,r)),h.append(f,p),c.append(d,u,h),c}_renderAllDayRail(t){let e=l("div",{class:"zx-calendar__all-day"},l("span",{class:"zx-calendar__all-day-label"},this.msg("calendar.allDay"))),i=l("div",{class:"zx-calendar__all-day-grid",role:"row",style:{"--zx-calendar-day-count":String(t.length)}});for(let r of t)i.append(l("span",{class:"zx-calendar__all-day-cell",dataset:{date:X(r)},ariaHidden:"true"}));let n=zs(this._events,t[0],t.length);for(let r of n){let o=this._eventElement(r.event,{variant:"span",day:t[r.start]});o.style.gridColumn=`${r.start+1} / ${r.end+1}`,o.style.gridRow=String(r.lane+1),i.append(o)}return e.append(i),e}_renderMonth(t){let e=l("div",{class:"zx-calendar__month"}),i=l("div",{class:"zx-calendar__month-weekdays",role:"row"});this.options.weekNumbers&&i.append(l("span",{class:"zx-calendar__month-week-gutter",ariaHidden:"true"}));for(let r=0;r<7;r+=1){let o=R(t.start,r);i.append(l("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}e.append(i);let n=At(t.start,t.end)/7;for(let r=0;r<n;r+=1){let o=R(t.start,r*7),a=zs(this._events.map(m=>({...m,allDay:!0})),o,7),c=Yv(this.options.eventLimit),d=a.filter(m=>m.lane<c),u=a.filter(m=>m.lane>=c),h=l("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:X(o)}});this.options.weekNumbers&&h.append(l("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:X(o)},ariaLabel:this.msg("calendar.weekNumber",ff(o)),disabled:this.options.disabled},String(ff(o))));let f=l("div",{class:"zx-calendar__month-days"});for(let m=0;m<7;m+=1){let g=R(o,m),w=this._events.filter(v=>Oi(v,g,R(g,1))).length;f.append(l("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:X(g),dateCell:"true",otherMonth:g.getMonth()===this._date.getMonth()?null:"true",eventCount:String(w)},ariaCurrent:Ne(g,this._now())?"date":null,ariaLabel:this._dayCountLabel(g,w),disabled:this.options.disabled},this._format(g,{day:"numeric"})))}let p=l("div",{class:"zx-calendar__month-events"});for(let m of d){let g=this._eventElement(m.event,{variant:"month",day:R(o,m.start)});g.style.gridColumn=`${m.start+1} / ${m.end+1}`,g.style.gridRow=String(m.lane+1),p.append(g)}let _=Array.from({length:7},(m,g)=>u.filter(w=>w.start<=g&&w.end>g).length);for(let m=0;m<_.length;m+=1){let g=_[m];if(!g)continue;let w=R(o,m);p.append(l("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:X(w),count:String(g)},style:{gridColumn:String(m+1),gridRow:String(c+1)},disabled:this.options.disabled},this.msg("calendar.more",g)))}h.append(f,p),e.append(h)}return e.setAttribute("role","grid"),e.setAttribute("aria-label",this._rangeTitle(t)),e}_renderYear(t){let e=t.start.getFullYear(),i=l("div",{class:"zx-calendar__year",ariaLabel:String(e)});for(let n=0;n<12;n+=1){let r=new Date(e,n,1),o=(r.getDay()-this.options.weekStart+7)%7,a=R(r,-o),c=l("div",{class:"zx-calendar__year-grid",role:"grid",ariaLabel:this._format(r,{month:"long"})},l("h3",{class:"zx-calendar__year-heading"},this._format(r,{month:"long"})));for(let d=0;d<7;d+=1){let u=R(a,d);c.append(l("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(u,{weekday:"narrow"})))}for(let d=0;d<42;d+=1){let u=R(a,d);if(u.getMonth()!==n){c.append(l("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}let h=this._events.filter(f=>Oi(f,u,R(u,1))).length;c.append(l("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:X(u),dateCell:"true",activity:String(Math.min(3,h))},ariaCurrent:Ne(u,this._now())?"date":null,ariaLabel:this._dayCountLabel(u,h),disabled:this.options.disabled},String(u.getDate())))}i.append(c)}return i}_eventElement(t,e){let i=String(t.id),n=l("div",{class:"zx-calendar__event",dataset:{eventId:i,variant:e.variant,allDay:t.allDay?"true":null,draggable:this._canMove(t)?"true":null},style:t.color?{"--zx-calendar-event-color":t.color}:null}),r=l("button",{type:"button",class:"zx-calendar__event-action",dataset:{eventAction:"activate",eventId:i},ariaLabel:this._eventLabel(t),disabled:this.options.disabled}),o=typeof this.options.renderEvent=="function"?this.options.renderEvent(G(t)):null;if(o instanceof Node)r.append(o);else if(typeof o=="string")r.append(document.createTextNode(o));else{let a=l("span",{class:"zx-calendar__event-time"},this._eventTime(t,e.day)),c=l("span",{class:"zx-calendar__event-title"},t.title);r.append(a,c),t.location&&r.append(l("span",{class:"zx-calendar__event-location"},t.location))}return n.append(r),e.resizable&&this._canResize(t)&&n.append(l("button",{type:"button",class:"zx-calendar__event-resize",dataset:{eventAction:"resize",eventId:i},ariaLabel:this.msg("calendar.resize",t.title),disabled:this.options.disabled},l("span",{ariaHidden:"true"}))),n}_nowLine(t,e,i){let n=this._now(),r=t.findIndex(c=>Ne(c,n)),o=n.getHours()*60+n.getMinutes(),a=this.options.nowIndicator&&r>=0&&o>=e&&o<=i;return l("div",{ref:"nowLine",class:"zx-calendar__now",hidden:!a,ariaHidden:"true",style:a?{insetBlockStart:`${(o-e)/(i-e)*100}%`,"--zx-calendar-now-day":String(r)}:null},l("span",{class:"zx-calendar__now-time"},gl(o,this.options.locale)))}_onClick(t){let e=t.target?.closest?.("button");if(!e||!this.el.contains(e))return;let i=e.dataset.eventId;if(i!=null&&this._suppressClickId===i){this._suppressClickId=null,t.preventDefault();return}if(e.dataset.eventAction==="activate"){let r=this._eventById(i);r&&this.emit("eventclick",{event:G(r),jsEvent:t});return}if(e.dataset.eventAction==="resize")return;let n=e.dataset.calendarAction;if(n){if(n==="previous")this.prev();else if(n==="next")this.next();else if(n==="today")this.today();else if(n==="view")this.setView(e.dataset.view);else if(n==="new")this.emit("new",{date:this.getDate(),view:this._view,jsEvent:t});else if(n==="week"){let r=pe(e.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=pe(e.dataset.date);if(!r)return;!this.emit("moreclick",{date:r,count:Number(e.dataset.count),jsEvent:t}).defaultPrevented&&this._views.includes("agenda")&&this.setDate(r).setView("agenda")}else if(n==="date"){if(this._suppressDateClick){this._suppressDateClick=!1,t.preventDefault();return}let r=this._dateFromTarget(e);if(!r)return;this._rememberFocusedDate(e),this.emit("dateclick",{date:r,allDay:!e.dataset.dateTime,view:this._view,jsEvent:t})}}}_onDoubleClick(t){let e=t.target?.closest?.('[data-event-action="activate"]');if(e){let a=this._eventById(e.dataset.eventId);a&&this.emit("eventdblclick",{event:G(a),jsEvent:t});return}let i=t.target?.closest?.('[data-calendar-action="date"]');if(!i)return;let n=this._dateFromTarget(i);if(!n)return;let r=!i.dataset.dateTime,o=r?R(n,1):De(n,zt(this.options.slotDuration));this.emit("select",{start:n,end:o,allDay:r,view:this._view,jsEvent:t})}_onKeydown(t){let e=t.target?.closest?.("[data-event-action]");if(e){this._onEventKeydown(t,e);return}let i=t.target?.closest?.("[data-slot]");if(i){this._onSlotKeydown(t,i);return}let n=t.target?.closest?.("[data-date-cell]");n&&this._onDayKeydown(t,n)}_onEventKeydown(t,e){let i=this._eventById(e.dataset.eventId);if(!i)return;let n=e.dataset.eventAction==="resize";if(t.key==="Enter"&&!this._keyboardEdit&&!n){t.preventDefault(),this.emit("eventclick",{event:G(i),jsEvent:t});return}if(t.key===" "&&!this._keyboardEdit){if(n?!this._canResize(i):!this._canMove(i))return;t.preventDefault(),this._keyboardEdit={oldEvent:G(i),event:G(i),action:n?"resize":"move",control:e},e.setAttribute("aria-grabbed","true"),e.closest(".zx-calendar__event")?.setAttribute("data-state","grabbed"),this._announce(this.msg(n?"calendar.resizeStarted":"calendar.moveStarted",i.title));return}if(!this._keyboardEdit||String(this._keyboardEdit.event.id)!==String(i.id))return;if(t.key==="Escape"){t.preventDefault(),this._cancelKeyboardEdit();return}if(t.key===" "){t.preventDefault();let d=this._keyboardEdit;this._keyboardEdit=null,d.control.removeAttribute("aria-grabbed"),this._commitMutation(d.oldEvent,d.event,d.action,t);return}let r=0,o=0,a=!kt(i)&&(this._view==="day"||this._view==="week");if(t.key==="ArrowLeft")r=-1;else if(t.key==="ArrowRight")r=1;else if(t.key==="ArrowUp")a?o=-zt(this.options.slotDuration):r=-7;else if(t.key==="ArrowDown")a?o=zt(this.options.slotDuration):r=7;else return;t.preventDefault();let c=this._keyboardEdit;if(c.action==="move")c.event=Ni(c.event,{days:r,minutes:o});else{let d=Ni(c.event,{days:0,minutes:0,endDays:r,endMinutes:o});d.end>d.start&&(c.event=d)}c.control.closest(".zx-calendar__event")?.setAttribute("data-preview",this._eventTime(c.event,c.event.start)),this._announce(this.msg("calendar.editPreview",c.event.title,this._dateTimeLabel(c.event.start),this._dateTimeLabel(c.event.end)))}_onSlotKeydown(t,e){let i=Number(e.dataset.rowIndex),n=Number(e.dataset.dayIndex),r=e.closest('[role="grid"]'),o=Number(r?.getAttribute("aria-colcount"))||1,a=Number(r?.getAttribute("aria-rowcount"))||1,c=i,d=n;if(t.key==="ArrowLeft")d-=1;else if(t.key==="ArrowRight")d+=1;else if(t.key==="ArrowUp")c-=1;else if(t.key==="ArrowDown")c+=1;else if(t.key==="Home")d=0;else if(t.key==="End")d=o-1;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault();let h=this._dateFromTarget(e);h&&this.emit("dateclick",{date:h,allDay:!1,view:this._view,jsEvent:t});return}else return;t.preventDefault(),c=Math.max(0,Math.min(a-1,c)),d=Math.max(0,Math.min(o-1,d));let u=r?.querySelector(`[data-row-index="${c}"][data-day-index="${d}"]`);u&&(e.tabIndex=-1,u.tabIndex=0,this._focusedSlot=u.dataset.slot,u.focus())}_onDayKeydown(t,e){let i=pe(e.dataset.date);if(!i)return;let n=0;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-7;else if(t.key==="ArrowDown")n=7;else if(t.key==="Home")n=-((i.getDay()-this.options.weekStart+7)%7);else if(t.key==="End")n=6-(i.getDay()-this.options.weekStart+7)%7;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else return;t.preventDefault();let r=R(i,n),o=this.el.querySelector(`[data-date-cell][data-date="${X(r)}"]`);o?o.focus():this.setDate(r)}_onPointerDown(t){if(this.options.disabled||t.button!==0)return;let e=t.target?.closest?.("[data-event-action]");if(e){let r=this._eventById(e.dataset.eventId),o=e.dataset.eventAction==="resize"?"resize":"move";if(!r||(o==="move"?!this._canMove(r):!this._canResize(r)))return;t.preventDefault(),this._capturePointer(t.pointerId);let a=o==="move"?this._dragOffsetForEvent(r,t.clientX,t.clientY):null;this._pointer={type:"event",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,oldEvent:G(r),event:G(r),action:o,control:e,timeOffsetMinutes:a?.minutes??0,dayOffset:a?.days??0,moved:!1};return}let i=t.target?.closest?.("[data-slot]");if(!i||!this.options.selectable)return;let n=this._dateFromTarget(i);n&&(t.preventDefault(),this._capturePointer(t.pointerId),this._pointer={type:"selection",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,start:n,end:De(n,zt(this.options.slotDuration)),control:i,moved:!1})}_onPointerMove(t){let e=this._pointer;if(!e||e.pointerId!==t.pointerId||!e.moved&&Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<5)return;if(e.moved=!0,t.preventDefault(),e.type==="selection"){let r=this._timeAtPoint(t.clientX,t.clientY);if(!r)return;let o=zt(this.options.slotDuration);e.end=De(r,o),this._previewSelection(e.start,e.end);return}let i=this._proposalAtPoint(e.oldEvent,e.action,t.clientX,t.clientY);if(!i)return;e.event=i;let n=e.control.closest(".zx-calendar__event");if(n){if(n.dataset.state="dragging",e.action==="resize"){n.style.transform="";let r=this._timedPreviewHeight(i);r&&(n.style.blockSize=r)}else n.style.transform=`translate(${t.clientX-e.startX}px, ${t.clientY-e.startY}px)`;n.dataset.preview=this._eventTime(i,i.start)}this._announce(this.msg("calendar.editPreview",i.title,this._dateTimeLabel(i.start),this._dateTimeLabel(i.end)))}_onPointerUp(t){let e=this._pointer;if(!(!e||e.pointerId!==t.pointerId)&&(this._pointer=null,this._releasePointerCapture(e.pointerId),this._clearSelectionPreview(),!!e.moved)){if(t.preventDefault(),e.type==="selection"){this._suppressDateClick=!0;let i=e.start<e.end?e.start:De(e.end,-zt(this.options.slotDuration)),n=e.start<e.end?e.end:De(e.start,zt(this.options.slotDuration));this.emit("select",{start:new Date(i),end:new Date(n),allDay:!1,view:this._view,jsEvent:t});return}this._suppressClickId=String(e.oldEvent.id),this._commitMutation(e.oldEvent,e.event,e.action,t)}}_cancelPointer(t){if(!this._pointer||this._pointer.pointerId!==t.pointerId)return;let e=this._pointer.control;this._releasePointerCapture(this._pointer.pointerId),this._pointer=null,this._clearSelectionPreview(),e.closest?.(".zx-calendar__event")?.removeAttribute("data-state"),this._renderView({preserveFocus:!0})}_proposalAtPoint(t,e,i,n){let r=e==="resize"&&!kt(t),o=this._timeAtPoint(i,n,r?t.start:null);if(o&&!kt(t)){if(e==="move"){let p=t.end.getTime()-t.start.getTime(),_=G(t);return _.start=De(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+p),_}let f=G(t);return f.end=De(o,zt(this.options.slotDuration)),f.end>f.start?f:null}let a=this._dayAtPoint(i,n);if(!a)return null;let c=R(a,-Number(this._pointer?.dayOffset??0)),d=At(Y(t.start),c);if(e==="move")return Ni(t,{days:d,minutes:0});let u=G(t),h=R(a,1);return u.end=new Date(h.getTime()),u.end>u.start?u:null}_timeAtPoint(t,e,i=null){let n=this.refs.body.querySelector(".zx-calendar__slots");if(!n)return null;let r=n.getBoundingClientRect(),a=n.closest(".zx-calendar__time-scroller")?.getBoundingClientRect(),c=a?Math.max(r.left,a.left):r.left,d=a?Math.min(r.right,a.right):r.right,u=a?Math.max(r.top,a.top):r.top,h=a?Math.min(r.bottom,a.bottom):r.bottom;if(t<c||t>d||e<u||e>h||r.width<=0||r.height<=0)return null;let f=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,p=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,_=i?this._timeGridDayIndex(i):-1,m=_>=0?_:Math.max(0,Math.min(f-1,Math.floor((t-r.left)/r.width*f))),g=Math.max(0,Math.min(p-1,Math.floor((e-r.top)/r.height*p))),w=n.querySelector(`[data-row-index="${g}"][data-day-index="${m}"]`);return w?this._dateFromTarget(w):null}_dayAtPoint(t,e){let i=this.refs.body.querySelector(".zx-calendar__all-day-grid");if(i){let r=i.getBoundingClientRect();if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom){let o=i.querySelectorAll("[data-date]"),a=Math.max(0,Math.min(o.length-1,Math.floor((t-r.left)/r.width*o.length)));return pe(o[a]?.dataset.date)}}for(let r of this.refs.body.querySelectorAll(".zx-calendar__month-events")){let o=r.getBoundingClientRect();if(t<o.left||t>o.right||e<o.top||e>o.bottom||o.width<=0)continue;let a=pe(r.closest(".zx-calendar__month-week")?.dataset.weekStart);if(!a)continue;let c=Math.max(0,Math.min(6,Math.floor((t-o.left)/o.width*7)));return R(a,c)}for(let r of this.refs.body.querySelectorAll(".zx-calendar__agenda-day")){let o=r.getBoundingClientRect();if(!(t<o.left||t>o.right||e<o.top||e>o.bottom))return pe(r.dataset.date)}let n=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(t,e):[];for(let r of n){let o=r instanceof HTMLElement?r.closest("[data-date]"):null,a=o instanceof HTMLElement?o.dataset.date:null;if(a)return pe(a)}return null}_dragOffsetForEvent(t,e,i){if(!kt(t)){let o=this._timeAtPoint(e,i);if(o){let a=zt(this.options.slotDuration),c=Math.max(0,Math.round((t.end.getTime()-t.start.getTime())/6e4)),d=Math.max(0,c-a),u=Math.round((o.getTime()-t.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(d,u)),days:0}}}let n=this._dayAtPoint(e,i),r=n?At(Y(t.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(t){let e=X(t);return[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")].findIndex(n=>n.dataset.date===e)}_timedPreviewHeight(t){if(!this.refs.body.querySelector(".zx-calendar__time-grid")||kt(t))return null;let i=Wt(this.options.slotMinTime,0),n=Wt(this.options.slotMaxTime,1440,!0),r=zt(this.options.slotDuration),o=t.start.getHours()*60+t.start.getMinutes(),a=t.end.getHours()*60+t.end.getMinutes();return`${Math.max(r,Math.min(n,a)-Math.max(i,o))/(n-i)*100}%`}_capturePointer(t){try{this.el.setPointerCapture?.(t)}catch{}}_releasePointerCapture(t){this.el.hasPointerCapture?.(t)&&this.el.releasePointerCapture?.(t)}_previewSelection(t,e){let i=Math.min(t.getTime(),e.getTime()),n=Math.max(t.getTime(),e.getTime());for(let r of this.refs.body.querySelectorAll("[data-slot]")){let o=Number(r.dataset.dateTime);r.setAttribute("aria-selected",String(o>=i&&o<n))}}_clearSelectionPreview(){for(let t of this.refs.body.querySelectorAll("[data-slot][aria-selected]"))t.removeAttribute("aria-selected")}_cancelKeyboardEdit(){let t=this._keyboardEdit;t&&(t.control.removeAttribute("aria-grabbed"),t.control.closest(".zx-calendar__event")?.removeAttribute("data-state"),this._keyboardEdit=null,this._announce(this.msg("calendar.editCancelled")),this._renderView({preserveFocus:!0}))}_commitMutation(t,e,i,n){if(!(t.start.getTime()!==e.start.getTime()||t.end.getTime()!==e.end.getTime())){this._renderView({preserveFocus:!0});return}let o=String(t.id),a=++this._mutationSerial,c=!1;this.options.optimistic?(this._replaceNormalizedEvent(e),this._mutationVersions.set(o,a),this._renderView({preserveFocus:!0})):this._renderView({preserveFocus:!0});let d=()=>{if(c||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let f=this._eventById(o);return!f||f.start.getTime()!==e.start.getTime()||f.end.getTime()!==e.end.getTime()?!1:(c=!0,this._replaceNormalizedEvent(t),this._mutationVersions.delete(o),this._renderView({preserveFocus:!0}),this._announce(this.msg("calendar.editCancelled")),!0)},u={event:G(e),oldEvent:G(t),action:i,delta:Qv(t,e),jsEvent:n,revert:d};this.emit("eventchange",u).defaultPrevented?d():this._announce(this.msg("calendar.editCommitted",e.title))}_replaceNormalizedEvent(t){let e=String(t.id);this._events=this._events.map(i=>String(i.id)===e?G(t):i)}_canMove(t){return this.options.disabled?!1:t.editable!=null?t.editable:this.options.eventStartEditable!=null?!!this.options.eventStartEditable:!!this.options.editable}_canResize(t){return this.options.disabled?!1:t.durationEditable!=null?t.durationEditable:this.options.eventDurationEditable!=null?!!this.options.eventDurationEditable:!!this.options.editable}_eventById(t){let e=this._eventIndex(t);return e<0?null:this._events[e]}_eventIndex(t){let e=String(t);return this._events.findIndex(i=>String(i.id)===e)}_page(t){return this.setDate(Ar(this._view,this._date,t,{agendaDays:this.options.agendaDays}))}_rangeTitle(t){if(this._view==="day")return this._format(t.start,{weekday:"long",day:"numeric",month:"long",year:"numeric"});if(this._view==="month")return this._format(this._date,{month:"long",year:"numeric"});if(this._view==="year")return this._format(this._date,{year:"numeric"});let e=R(t.end,-1),i=new Intl.DateTimeFormat(this.options.locale,{day:"numeric",month:"long",year:"numeric"});return typeof i.formatRange=="function"?i.formatRange(t.start,e):t.start.getFullYear()!==e.getFullYear()?`${this._format(t.start,{day:"numeric",month:"short",year:"numeric"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:t.start.getMonth()!==e.getMonth()?`${this._format(t.start,{day:"numeric",month:"short"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:`${this._format(t.start,{day:"numeric"})}\u2013${this._format(e,{day:"numeric",month:"long",year:"numeric"})}`}_eventTime(t,e){if(t.allDay)return this.msg("calendar.allDay");if(kt(t))return Ne(t.start,e)?`${Cs(t.start,this.options.locale)} \u2192`:Ne(t.end,e)?`\u2192 ${Cs(t.end,this.options.locale)}`:this.msg("calendar.allDay");let i=bl(t.start,this.options.locale);return t.end<=t.start?i:`${i}\u2013${bl(t.end,this.options.locale)}`}_eventLabel(t){let e=t.location?`, ${t.location}`:"";return`${t.title}, ${Cs(t.start,this.options.locale)} to ${Cs(t.end,this.options.locale)}${e}`}_dateTimeLabel(t){return Cs(t,this.options.locale)}_format(t,e){return new Intl.DateTimeFormat(this.options.locale,e).format(t)}_now(){let t=typeof this.options.now=="function"?this.options.now():this.options.now,e=t??new Date;if(!(e instanceof Date)||Number.isNaN(e.getTime()))throw new TypeError("Calendar now must return a valid Date");return new Date(e.getTime())}_dateFromTarget(t){if(t.dataset.dateTime){let e=new Date(Number(t.dataset.dateTime));return Number.isNaN(e.getTime())?null:e}return pe(t.dataset.date)}_rememberFocusedDate(t){t.dataset.slot&&(this._focusedSlot=t.dataset.slot)}_focusIdentity(){let t=document.activeElement;return!(t instanceof HTMLElement)||!this.el.contains(t)?null:{eventId:t.dataset.eventId,eventAction:t.dataset.eventAction,date:t.dataset.date,slot:t.dataset.slot}}_restoreFocus(t){let e=null;t.eventId&&(e=this.el.querySelector(`[data-event-id="${Cr(t.eventId)}"][data-event-action="${t.eventAction??"activate"}"]`)),!e&&t.slot&&(e=this.el.querySelector(`[data-slot="${Cr(t.slot)}"]`)),!e&&t.date&&(e=this.el.querySelector(`[data-date-cell][data-date="${Cr(t.date)}"]`)),e?.focus?.()}_scrollTimeGrid(){let t=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!t)return;let e=Wt(this.options.slotMinTime,0),i=Wt(this.options.slotMaxTime,1440,!0),n=Wt(this.options.scrollTime,480,!0),r=Math.max(0,Math.min(1,(n-e)/(i-e)));requestAnimationFrame(()=>{t.isConnected&&(t.scrollTop=Math.max(0,r*t.scrollHeight-t.clientHeight/4))})}_refreshNowIndicator(){if(this._destroyed||!this.options.nowIndicator||!["day","week"].includes(this._view))return;let t=this.refs.body.querySelector(".zx-calendar__now"),e=[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")];if(!t||!e.length)return;let i=this._now(),n=e.findIndex(d=>d.dataset.date===X(i)),r=Wt(this.options.slotMinTime,0),o=Wt(this.options.slotMaxTime,1440,!0),a=i.getHours()*60+i.getMinutes(),c=n>=0&&a>=r&&a<=o;t.hidden=!c,c&&(t.style.insetBlockStart=`${(a-r)/(o-r)*100}%`,t.style.setProperty("--zx-calendar-now-day",String(n)),t.querySelector(".zx-calendar__now-time").textContent=gl(a,this.options.locale))}_announce(t){this.refs.status.textContent="",requestAnimationFrame(()=>{this._destroyed||(this.refs.status.textContent=t)})}_dayCountLabel(t,e){let i=this._format(t,{dateStyle:"full"});return e===1?this._message("calendar.dayEvent","%1, %2 event",i,e):this._message("calendar.dayEvents","%1, %2 events",i,e)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function Uv(s){if(!Array.isArray(s)||s.length===0)throw new TypeError("Calendar views must be a non-empty array");let t=[...new Set(s.map(String))];for(let e of t)if(!ks.includes(e))throw new RangeError(`Unknown Calendar view: ${e}`);return t}function uf(s,t,e){if(s==null)return e;if(s instanceof Date){if(Number.isNaN(s.getTime()))throw new TypeError("Calendar date must be valid");return new Date(s.getTime())}let i=typeof s=="number"?s:typeof s=="string"&&/^-?\d+(?:\.\d+)?$/.test(s.trim())?Number(s):null,n=i==null?new Date(s):new Date(i*(t==="seconds"?1e3:1));if(Number.isNaN(n.getTime()))throw new TypeError("Calendar date must be valid");return n}function zt(s){let t=Number(s);if(!Number.isInteger(t)||t<=0||t>720||1440%t!==0)throw new RangeError("Calendar slotDuration must be a positive divisor of 1440");return t}function Yv(s){let t=Number(s);if(!Number.isInteger(t)||t<1||t>20)throw new RangeError("Calendar eventLimit must be an integer from 1 through 20");return t}function Wt(s,t,e=!1){let i=Number(s??t),n=e?1440:1439;if(!Number.isInteger(i)||i<0||i>n)throw new RangeError(`Calendar minute must be from 0 through ${n}`);return i}function Gv(s,t){let e=Y(s);return e.setMinutes(t),e}function De(s,t){let e=new Date(s.getTime());return e.setMinutes(e.getMinutes()+t),e}function hf(s){return`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}`}function Ne(s,t){return hf(s)===hf(t)}function pe(s){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s??""));if(!t)return null;let e=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return X(e)===s?e:null}function Wv(s,t){return s.start-t.start||t.end-s.end||s.title.localeCompare(t.title)}function gl(s,t){let e=new Date(2026,0,1);return e.setHours(Math.floor(s/60)%24,s%60,0,0),bl(e,t)}function bl(s,t){return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit"}).format(s)}function Cs(s,t){return new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(s)}function ff(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t-i)/864e5+1)/7)}function Qv(s,t){let e=t.start.getTime()-s.start.getTime();return{milliseconds:e,days:At(Y(s.start),Y(t.start)),minutes:Math.round(e/6e4),endMilliseconds:t.end.getTime()-s.end.getTime()}}function Cr(s){return globalThis.CSS?.escape?CSS.escape(s):s.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`)}var gt=class extends y{static cssName="record-view";static defaults={fields:[],data:[],recordId:"ID",sort:null,sortMode:"local",selectable:!1,selection:[],fieldOrder:[],hiddenFields:[],fieldControls:!0,emptyText:null};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("div");return this._recordViewOriginal=t?null:A(e),this._recordViewDestroyed=!1,this._initRecordView(e),e}destroy(){if(this._recordViewDestroyed)return;this._recordViewDestroyed=!0;let t=this.el,e=this._recordViewOriginal;this._removeViewFieldControls(),super.destroy(),e&&t&&S(t,e)}_initRecordView(t){this.el=t,t.classList.add("zx-record-view"),this._viewFields=Er(this.options.fields),this._viewFieldOrder=Fi(this._viewFields,this.options.fieldOrder),this._viewHidden=wl(this._viewFields,this.options.hiddenFields,!0),this._viewData=yl(this.options.data),this._viewSort=Ir(this.options.sort,this._viewFields),this._viewSelected=new Set,this._viewSelectionAnchor=null,this._viewFieldControls=null,this._viewFieldList=null,this._viewFieldStatus=null,this._viewFieldHome=null,this._viewNativeMounted=null,this._viewFieldFocus=null,this._viewFieldSettings=Qt(this.options.fieldControls),this._viewFieldControlsTarget=P(this._viewFieldSettings.target),this._viewInitialized=!0,this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._setInitialSelection(this.options.selection)}setData(t){this._viewData=yl(t),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData();let e=this._pruneViewSelection();return this.setLoading(!1),this._refreshView("data"),e&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}addData(t){return this._viewData.push(...yl(t)),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),this.emit("datachange",{records:this.getData()}),this}updateRecord(t,e){mf(e);let i=this._viewData.findIndex(o=>Object.is(this._viewRecordId(o),t));if(i<0)return this;let n=this._viewSelected.delete(t);this._viewData[i]=e;let r=this._viewRecordId(e);return n&&this._viewSelected.add(r),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),n&&!Object.is(t,r)&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}removeRecord(t){let e=this._viewData.findIndex(n=>Object.is(this._viewRecordId(n),t));if(e<0)return this;this._viewData.splice(e,1);let i=this._viewSelected.delete(t);return Object.is(this._viewSelectionAnchor,t)&&(this._viewSelectionAnchor=null),this._refreshView("data"),i&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}getRecord(t){return this._viewData.find(e=>Object.is(this._viewRecordId(e),t))??null}getData(){return[...this._viewData]}setFields(t){let e=this.getFieldOrder(),i=this.getHiddenFields();return this._viewFields=Er(t),this._viewFieldOrder=Fi(this._viewFields,e),this._viewHidden=wl(this._viewFields,i),this._viewSort=Ir(this._viewSort,this._viewFields),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("fields"),this._renderViewFieldControls(),this._emitViewState("fields"),this}getFields(){let t=new Map(this._viewFields.map(e=>[e.id,e]));return this._viewFieldOrder.map(e=>({...t.get(e)}))}getVisibleFields(){return this.getFields().filter(t=>!this._viewHidden.has(t.id))}getHiddenFields(){return this._viewFieldOrder.filter(t=>this._viewHidden.has(t))}getFieldOrder(){return[...this._viewFieldOrder]}getFieldControls(){return this._viewFieldControls?this._viewFieldControls:this._nativeFieldControls()}mountFieldControls(t){let e=this.getFieldControls();if(!e)return null;if(t==null){let n=this._viewFieldHome;return n&&(this._viewFieldHome=null,e===this._viewNativeMounted&&(this._viewNativeMounted=null),n.parent?n.parent.insertBefore(e,n.next?.parentNode===n.parent?n.next:null):e.remove(),n.mounted===void 0?delete e.dataset.mounted:e.dataset.mounted=n.mounted),e}let i=P(t);return i?(e.parentNode===i||(this._viewFieldHome||(this._viewFieldHome={parent:e.parentNode,next:e.nextSibling,mounted:e.dataset.mounted}),e!==this._viewFieldControls&&(this._viewNativeMounted=e),e.dataset.mounted="external",i.append(e)),e):null}setFieldVisible(t,e=!0,i={}){let n=String(t);if(!this._viewFields.some(o=>o.id===n))throw new RangeError(`Unknown view field: ${n}`);if(!e&&!this._viewHidden.has(n)&&this.getVisibleFields().length<=1)return this._renderViewFieldControls(n),this;let r=e?this._viewHidden.delete(n):!this._viewHidden.has(n);return!e&&r&&this._viewHidden.add(n),r?(this._refreshView("fields"),this._renderViewFieldControls(n),i.silent||(this.emit("fieldvisibilitychange",{visible:this.getVisibleFields().map(o=>o.id),hidden:this.getHiddenFields()}),this._emitViewState("fieldvisibility")),this):this}toggleField(t,e={}){return this.setFieldVisible(t,this._viewHidden.has(String(t)),e)}moveField(t,e,i="before",n={}){let r=vl(this._viewFieldOrder,String(t),String(e),i);return pf(r,this._viewFieldOrder)?this:this.setFieldOrder(r,n)}setFieldOrder(t,e={}){let i=Fi(this._viewFields,t);return pf(i,this._viewFieldOrder)?this:(this._viewFieldOrder=i,this._refreshView("fields"),this._renderViewFieldControls(this._viewFieldFocus??null),e.silent||(this.emit("fieldorderchange",{order:this.getFieldOrder()}),this._emitViewState("fieldorder")),this)}setSort(t,e="asc",i={}){let n=t==null?null:Ir({id:String(t),dir:e},this._viewFields);if(t!=null&&!n)throw new RangeError(`Unknown or unsortable view field: ${t}`);return Zv(n,this._viewSort)?this:(this._viewSort=n,n&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("sort"),i.silent||(this.emit("sortchange",n?{...n}:{id:null,dir:null}),this._emitViewState("sort")),this)}getSort(){return this._viewSort?{...this._viewSort}:null}getSelection(){return this._viewData.filter(t=>this._viewSelected.has(this._viewRecordId(t)))}getSelectionIds(){return this.getSelection().map(t=>this._viewRecordId(t))}setSelection(t,e={}){let i=new Set(Array.isArray(t)?t:[]),r=this._viewData.map(o=>this._viewRecordId(o)).filter(o=>i.has(o));return this.options.selectable===!1&&(r=[]),this.options.selectable==="single"&&(r=r.slice(0,1)),_f(this._viewSelected,new Set(r))?this:(this._viewSelected=new Set(r),this._viewSelectionAnchor=r.at(-1)??null,this._refreshView("selection"),e.silent||this._emitViewSelection(),this)}clearSelection(t={}){return this.setSelection([],t)}toggleSelection(t,e={}){if(this.options.selectable===!1||!this.getRecord(t))return this;let i=e.selected??!this._viewSelected.has(t);if(this.options.selectable==="single")this._viewSelected=i?new Set([t]):new Set;else if(e.range&&this._viewSelectionAnchor!=null){let n=this._viewData.map(a=>this._viewRecordId(a)),r=n.findIndex(a=>Object.is(a,this._viewSelectionAnchor)),o=n.findIndex(a=>Object.is(a,t));if(r>=0&&o>=0)for(let a of n.slice(Math.min(r,o),Math.max(r,o)+1))i?this._viewSelected.add(a):this._viewSelected.delete(a)}else i?this._viewSelected.add(t):this._viewSelected.delete(t);return this._viewSelectionAnchor=t,this._refreshView("selection"),this._emitViewSelection(),this}setLoading(t=!0){return t?this.el.setAttribute("data-loading","true"):this.el.removeAttribute("data-loading"),this.el.setAttribute("aria-busy",String(!!t)),this._refreshView("loading"),this}getViewState(){return{version:1,fieldOrder:this.getFieldOrder(),hiddenFields:this.getHiddenFields(),sort:this.getSort()}}setViewState(t,e={}){let i=Sl(t,this._viewFields);return this._viewFieldOrder=i.fieldOrder,this._viewHidden=new Set(i.hiddenFields),this._viewSort=i.sort,this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("state"),this._renderViewFieldControls(),e.silent||this._emitViewState("restore"),this}_createViewFieldControls(t=null){let e=t??this._viewFieldControlsLabel(),i=l("div",{class:"zx-record-view__field-list"}),n=l("div",{class:"zx-record-view__field-status",role:"status",ariaLive:"polite",style:{position:"absolute",inlineSize:"1px",blockSize:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}}),r=l("summary",{class:"zx-btn",dataset:{size:"sm",kind:"ghost"}},b("fields"),e),o=l("details",{class:"zx-record-view__field-controls"},r,i,n);return this._viewFieldControls=o,this._viewFieldList=i,this._viewFieldStatus=n,this._renderViewFieldControls(),this.listen(o,"keydown",a=>{let c=a;c.key!=="Escape"||!o.open||(c.preventDefault(),c.stopPropagation(),o.open=!1,r.focus())}),this.listen(i,"change",a=>{let c=a.target;c?.classList.contains("zx-record-view__field-toggle")&&this.setFieldVisible(c.value,c.checked)}),this.listen(i,"click",a=>{let c=a.target?.closest?.("[data-view-field-action]");if(!c)return;let d=c.dataset.fieldId,u=c.dataset.viewFieldAction;this._moveViewFieldFromChooser(String(d),u==="up"?-1:1)}),o}_mountViewFieldControls(t,e=null){let i=this._createViewFieldControls(e),n=this._viewFieldControlsTarget;return n&&(i.dataset.mounted="external"),(n??t).append(i),i}_removeViewFieldControls(){this._viewFieldControls?.remove?.(),this._viewNativeMounted&&!this.el?.contains(this._viewNativeMounted)&&this._viewNativeMounted.remove(),this._viewNativeMounted=null,this._viewFieldHome=null,this._viewFieldControls=null,this._viewFieldList=null,this._viewFieldStatus=null,this._viewFieldControlsTarget=null}_nativeFieldControls(){if(!this._viewFieldSettings?.enabled)return null;let t=this,i=(typeof t.getTable=="function"?t.getTable():null)?.el;return!i||typeof i.querySelector!="function"?null:i.querySelector(".zx-table__column-controls")??this._viewNativeMounted}_moveViewFieldFromChooser(t,e){let i=this._viewFieldOrder,n=i.indexOf(t);if(n<0)return;let r=i[n+e],o=e<0?"up":"down";if(r===void 0){this._renderViewFieldControls({id:t,action:o});return}this._viewFieldFocus={id:t,action:o};try{this.moveField(t,r,e<0?"before":"after")}finally{this._viewFieldFocus=null}let a=this._viewFields.find(d=>d.id===t),c=this._viewFieldOrder.indexOf(t)+1;this._viewFieldStatus&&a&&(this._viewFieldStatus.textContent=this._message("recordView.fieldMoved","%1 moved to position %2 of %3",a.label,c,this._viewFieldOrder.length))}_viewFieldControlsLabel(){return(this._viewFieldSettings??Qt(this.options.fieldControls)).label??this._message("recordView.fields","Fields")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}_refreshView(t){}_viewRecordId(t){return Oe(t,this.options.recordId)}_isViewSelected(t){return this._viewSelected.has(t)}_sortViewData(){this._viewSort&&(this._viewData=xl(this._viewData,this._viewFields,this._viewSort))}_setInitialSelection(t){let e=new Set(Array.isArray(t)?t:[]),n=this._viewData.map(r=>this._viewRecordId(r)).filter(r=>e.has(r));this.options.selectable===!1&&(n=[]),this.options.selectable==="single"&&(n=n.slice(0,1)),this._viewSelected=new Set(n),this._viewSelectionAnchor=n.at(-1)??null}_pruneViewSelection(){let t=new Set(this._viewData.map(n=>this._viewRecordId(n))),e=new Set([...this._viewSelected].filter(n=>t.has(n))),i=!_f(e,this._viewSelected);return this._viewSelected=e,this._viewSelectionAnchor!=null&&!t.has(this._viewSelectionAnchor)&&(this._viewSelectionAnchor=null),i}_emitViewSelection(){this.emit("selectionchange",{records:this.getSelection(),ids:this.getSelectionIds()})}_emitViewState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}_renderViewFieldControls(t=null){if(!this._viewFieldList)return;let e=this.getFields(),i=e.filter(a=>!this._viewHidden.has(a.id));this._viewFieldControls.hidden=e.length===0;let n=e.map((a,c)=>{let d=l("input",{class:"zx-record-view__field-toggle",type:"checkbox",value:a.id,checked:!this._viewHidden.has(a.id),disabled:!this._viewHidden.has(a.id)&&i.length===1,dataset:{viewFieldAction:"toggle",fieldId:a.id}}),u=l("button",{class:"zx-record-view__field-move",type:"button",ariaLabel:this._message("recordView.moveFieldUp","Move %1 up",a.label),disabled:c===0,dataset:{viewFieldAction:"up",fieldId:a.id}},b("chevron-up",{size:11})),h=l("button",{class:"zx-record-view__field-move",type:"button",ariaLabel:this._message("recordView.moveFieldDown","Move %1 down",a.label),disabled:c===e.length-1,dataset:{viewFieldAction:"down",fieldId:a.id}},b("chevron-down",{size:11}));return l("div",{class:"zx-record-view__field-option"},l("label",{},d,l("span",{},a.label)),l("span",{class:"zx-record-view__field-order"},u,h))});if(this._viewFieldList.replaceChildren(...n),t==null)return;let o=Xv(n,typeof t=="string"?{id:t,action:"toggle"}:t);o&&(o.focus(),queueMicrotask(()=>{o.isConnected&&o.ownerDocument?.activeElement!==o&&o.focus()}))}};function Xv(s,t){let e=[];for(let o of s)for(let a of o.querySelectorAll?.("[data-view-field-action]")??[])a.dataset.fieldId===t.id&&e.push(a);let i=o=>!o.disabled,n=e.find(o=>o.dataset.viewFieldAction===t.action);if(n&&i(n))return n;let r=e.find(o=>o.dataset.viewFieldAction!=="toggle"&&i(o));return t.action!=="toggle"&&r?r:e.find(i)??null}function Qt(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)?{enabled:!0,custom:!0,label:s.label==null?null:String(s.label),target:s.target??null}:{enabled:!!s,custom:!1,label:null,target:null}}function Er(s){if(!Array.isArray(s))throw new TypeError("Record view fields must be an array");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Record view field at index ${i} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Record view field at index ${i} requires an id`);if(t.has(n))throw new TypeError(`Duplicate record view field: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??Jv(n)),sortable:!!e.sortable,type:String(e.type??"text")}})}function Fi(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Array.isArray(t)?t.map(String):[];return[...new Set(n.filter(r=>i.has(r))),...e.filter(r=>!n.includes(r))]}function vl(s,t,e,i="before"){let n=[...s],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(i==="after"?1:0);return a=Math.max(0,Math.min(n.length,a)),n.splice(a,0,t),n}function Z(s,t,e=0){return typeof s.get=="function"?s.get(t,e):t?.[s.id]}function Ts(s,t,e=0){let i=Z(s,t,e);return typeof s.render=="function"?s.render(t,e,i):i==null?"":String(i)}function xl(s,t,e){if(!e)return[...s];let i=t.find(r=>r.id===e.id);if(!i)return[...s];let n=new WeakMap(s.map((r,o)=>[r,o]));return os(s,r=>typeof i.sortValue=="function"?i.sortValue(r,n.get(r)??0):Z(i,r,n.get(r)??0),e.dir)}function Sl(s,t){let e=s&&typeof s=="object"?s:{};return{version:1,fieldOrder:Fi(t,e.fieldOrder),hiddenFields:[...wl(t,e.hiddenFields)],sort:Ir(e.sort,t)}}function Oe(s,t){return typeof t=="function"?t(s):s?.[String(t??"ID")]}function Ir(s,t){if(!s||typeof s!="object")return null;let e=String(s.id??""),i=t.find(n=>n.id===e);return!i||!i.sortable?null:{id:e,dir:s.dir==="desc"?"desc":"asc"}}function wl(s,t,e=!1){let i=new Set(s.map(r=>r.id)),n=new Set(Array.isArray(t)?t.map(String).filter(r=>i.has(r)):[]);if(e)for(let r of s)r.visible===!1&&n.add(r.id);return n.size>=s.length&&s[0]&&n.delete(s[0].id),n}function yl(s){if(!Array.isArray(s))throw new TypeError("Record view data must be an array");return s.forEach(mf),[...s]}function mf(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Record view data entries must be objects")}function Jv(s){let t=String(s).split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Zv(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function pf(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function _f(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}var Mr=class extends gt{static cssName="table-view";static defaults={table:{}};constructor(t=null,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");this.el=e,this._createdTableViewRoot=t,this._tableViewOriginal=t?null:A(e),this._tableViewRestored=!1,this._tableSyncDepth=0,this._tableViewDestroyed=!1,this._tableHost=l("div",{class:"zx-table-view__table"}),this._initRecordView(e);let i=Qt(this.options.fieldControls);this._tableViewToolbar=i.custom&&!this._viewFieldControlsTarget?l("div",{class:"zx-record-view__toolbar zx-table-view__toolbar"}):null;try{e.replaceChildren(...[this._tableViewToolbar,this._tableHost].filter(Boolean));let n=this.options,r=tx(n.table,{fields:this.getFields(),data:this.getData(),recordId:this.options.recordId,sort:this.getSort(),sortMode:this.options.sortMode,selectable:this.options.selectable,hiddenFields:this.getHiddenFields(),fieldControls:this.options.fieldControls,emptyText:this.options.emptyText});return this.table=new Ft(this._tableHost,r),this.table.setSelection(this.getSelectionIds()),this._bridgeTableEvents(),i.custom&&this._mountViewFieldControls(this._tableViewToolbar??e),e}catch(n){throw this.table?.destroy(),this._removeViewFieldControls(),t||S(e,this._tableViewOriginal),n}}getTable(){return this.table}_refreshView(t){!this.table||this._tableSyncDepth>0||this._withTableSync(()=>{if((t==="fields"||t==="state")&&(this.table.setColumns(gf(this.getFields()),{silent:!0}),this._syncTableFieldState()),(t==="data"||t==="fields"||t==="sort"||t==="state")&&this.table.setData(this.getData()),t==="sort"||t==="fields"||t==="state"){let e=this.getSort();e?this.table.setSort(e.id,e.dir,{silent:!0}):this.table.clearSort({silent:!0})}(t==="selection"||t==="data"||t==="state")&&this.table.setSelection(this.getSelectionIds()),t==="loading"&&this.table.setLoading(this.el.dataset.loading==="true")})}destroy(){this._tableViewDestroyed||(this._tableViewDestroyed=!0,this.table?.destroy(),!this._tableViewRestored&&!this._createdTableViewRoot&&(S(this.el,this._tableViewOriginal),this._tableViewRestored=!0),super.destroy())}_withTableSync(t){this._tableSyncDepth+=1;try{t()}finally{this._tableSyncDepth-=1}}_syncTableFieldState(){let t=new Set(this.getHiddenFields());for(let e of this.getFieldOrder())t.has(e)||this.table.setColumnVisible(e,!0,{silent:!0});for(let e of this.getFieldOrder())t.has(e)&&this.table.setColumnVisible(e,!1,{silent:!0})}_bridgeTableEvents(){this.listen(this._tableHost,"zx-datachange",t=>t.stopPropagation()),this.listen(this._tableHost,"zx-selectionchange",t=>t.stopPropagation()),this.listen(this.table,"rowclick",t=>{let e=t.detail;this.emit("recordclick",{...e,record:e.row})}),this.listen(this.table,"rowdblclick",t=>{let e=t.detail;this.emit("recorddblclick",{...e,record:e.row})}),this.listen(this.table,"sort",t=>this._tableSortChanged(t.detail)),this.listen(this.table,"selectionchange",t=>this._tableSelectionChanged(t.detail)),this.listen(this.table,"datachange",()=>this._tableDataChanged()),this.listen(this.table,"columnvisibilitychange",t=>this._tableVisibilityChanged(t.detail)),this.listen(this.table,"columnorderchange",t=>this._tableOrderChanged(t.detail))}_tableSortChanged(t){if(this._tableSyncDepth>0)return;let e=t.id==null?null:{id:String(t.id),dir:t.dir==="desc"?"desc":"asc"};ex(e,this._viewSort)||(this._viewSort=e,this.options.sortMode==="local"&&(this._viewData=this.table.getData()),this.emit("sortchange",e?{...e}:{id:null,dir:null}),this._emitTableViewState("sort"))}_tableSelectionChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(t.ids);Al(e,this._viewSelected)||(this._viewSelected=e,this._viewSelectionAnchor=t.ids.at(-1)??null,this._emitTableViewSelection())}_tableDataChanged(){if(this._tableSyncDepth>0)return;this._viewData=this.table.getData();let t=new Set(this._viewData.map(n=>this._viewRecordId(n))),e=new Set([...this._viewSelected].filter(n=>t.has(n))),i=!Al(e,this._viewSelected);this._viewSelected=e,this._viewSelectionAnchor!=null&&!t.has(this._viewSelectionAnchor)&&(this._viewSelectionAnchor=null),i&&this._emitTableViewSelection(),this.emit("datachange",{records:this.getData()})}_tableVisibilityChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(this.getFieldOrder()),i=new Set(t.hidden.filter(n=>e.has(n)));Al(i,this._viewHidden)||(this._viewHidden=i,this.emit("fieldvisibilitychange",{visible:this.getVisibleFields().map(n=>n.id),hidden:this.getHiddenFields()}),this._emitTableViewState("fieldvisibility"))}_tableOrderChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(this.getFieldOrder()),i=[...new Set(t.order.filter(n=>e.has(n))),...this.getFieldOrder().filter(n=>!t.order.includes(n))];ix(i,this._viewFieldOrder)||(this._viewFieldOrder=i,this.emit("fieldorderchange",{order:this.getFieldOrder()}),this._emitTableViewState("fieldorder"))}_emitTableViewSelection(){this.emit("selectionchange",{records:this.getSelection(),ids:this.getSelectionIds()})}_emitTableViewState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}};function gf(s){return s.map(t=>{let e=t.view&&typeof t.view=="object"&&t.view.table&&typeof t.view.table=="object"?t.view.table:{},i={...t,...e,id:t.id,label:t.label,sortable:!!t.sortable};if(delete i.get,delete i.visible,delete i.duplicate,delete i.view,typeof t.render=="function")i.render=(n,r)=>t.render(n,r,Z(t,n,r));else if(typeof e.render!="function"&&typeof t.get=="function"){let n={...i};delete n.render,i.render=(r,o)=>Na(n,{...r,[t.id]:Z(t,r,o)},o)}return typeof t.sortValue=="function"?i.sortValue=n=>t.sortValue(n,0):typeof e.sortValue!="function"&&typeof t.get=="function"&&(i.sortValue=n=>Z(t,n,0)),i})}function tx(s,t){let e=Qt(t.fieldControls),i=e.enabled&&!e.custom;return{...s&&typeof s=="object"?s:{},columns:gf(t.fields),data:[...t.data],rowId:t.recordId,sort:t.sort?{...t.sort}:null,sortMode:t.sortMode,selectable:t.selectable,hiddenColumns:[...t.hiddenFields],columnVisibility:i,columnReorder:i,emptyText:t.emptyText}}function ex(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function Al(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function ix(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Or(s,t,e={}){let i=Array.isArray(e.fields)?e.fields:[],n=Array.isArray(e.visibleFields)?e.visibleFields:i,r=e.titleField??i[0]?.id??null,o=e.subtitleField??null,a=bf(s,t,r,i),c=bf(s,t,o,i),d=nx(s,t,e.preview,e.previewAlt,i),u=rx(s,t,e.link),h=Is(s,t,e.actions),f=fx(e.controls),p=_x(e.selectable),_=!!e.selected,m=x("zx-record-card-title"),g=gx(e.headingLevel),w=typeof e.message=="function"?e.message:(Wp,...Qp)=>yt(Wp,Qp),v=hx(a)||w("recordCard.untitled"),z=u?l("a",{class:"zx-record-card__primary",href:u.href,target:u.target,rel:u.rel},Dr(a)):l("span",{class:"zx-record-card__title"},Dr(a)),C=l(`h${g}`,{class:"zx-record-card__heading",id:m},z),k=sx(n,r,o),M=ax(s,t,k.eyebrowStart,k.eyebrowEnd),it=Nr(s,t,k.titlePrefix,"zx-record-card__title-prefix","title-prefix"),F=it?l("div",{class:"zx-record-card__title-row"},it,C):C,st=p==="multi"&&e.selectionTrigger!=="card"?l("label",{class:"zx-record-card__selection"},l("input",{type:"checkbox",checked:_,dataset:{recordSelection:""},ariaLabel:w("recordCard.select",v)})):null,bt=h.map(cx),Kp=bt.length||f.length?l("div",{class:"zx-record-card__actions",role:"group",ariaLabel:w("recordCard.actions",v)},f,bt):null,Up=l("header",{class:"zx-record-card__header"},st,l("div",{class:"zx-record-card__titles"},F,ux(c)?null:l("p",{class:"zx-record-card__subtitle"},Dr(c))),Kp),Yp=Nr(s,t,k.metadata,"zx-record-card__metadata"),Gp=l("div",{class:"zx-record-card__body"},M,Up,Yp);return l("li",{class:"zx-record-card",tabindex:0,ariaDescription:p?w(_?"recordCard.selected":"recordCard.notSelected"):void 0,ariaLabelledby:m,ariaKeyshortcuts:p&&e.selectionTrigger==="card"?"Space Enter":void 0,dataset:{recordIndex:String(t),variant:mx(e.variant),selected:String(_),selectionTrigger:p&&e.selectionTrigger==="card"?"card":"checkbox"}},d?ox(d):null,Gp)}function sx(s,t=null,e=null){let i={eyebrowStart:[],eyebrowEnd:[],titlePrefix:[],metadata:[]},n=typeof t=="string"?t:null,r=typeof e=="string"?e:null;for(let o of Array.isArray(s)?s:[]){if(!o.duplicate&&(o.id===n||o.id===r))continue;let a=lx(o);a==="eyebrow-start"?i.eyebrowStart.push(o):a==="eyebrow-end"?i.eyebrowEnd.push(o):a==="title-prefix"?i.titlePrefix.push(o):i.metadata.push(o)}return i}function nx(s,t,e,i,n=[]){if(e==null)return null;let r=typeof e=="function"?e(s,t):yf(s,t,e,n,!1);if(r==null||r==="")return null;let o=dx(s,t,i,n);if(Fr(r))return{node:r,src:null,alt:o,fit:"cover",rejected:!1};let a=typeof r=="object"&&!Array.isArray(r)?r:{src:String(r)},c=typeof a.src=="string"?a.src:"",d=px(c);return{node:null,src:d,alt:a.alt==null?o:String(a.alt),fit:bx(a.fit),rejected:d===null}}function rx(s,t,e){let i=typeof e=="function"?e(s,t):e;if(i==null)return null;let n=typeof i=="string"?{href:i}:i;if(!n||typeof n!="object"||Array.isArray(n))return null;let r=V(n.href);if(r===null)return null;let o=n.target==null?void 0:String(n.target),a=wf(n.rel,o);return{href:r,...o?{target:o}:{},...a?{rel:a}:{}}}function Is(s,t,e){let i=typeof e=="function"?e(s,t):e;return Array.isArray(i)?i.flatMap(n=>{if(!n||typeof n!="object"||Array.isArray(n))return[];let r=String(n.id??"").trim(),o=String(n.label??""),a=n.title==null?"":String(n.title);return!r||!o&&!a?[]:n.href!=null&&V(n.href)===null?[]:[{...n,id:r,label:o,...a?{title:a}:{}}]}):[]}function ox(s){let t=l("span",{class:"zx-record-card__preview-fallback",ariaHidden:"true"},b("file",{size:24}));if(s.node)return l("div",{class:"zx-record-card__preview"},s.node);let e=s.src?l("img",{class:"zx-record-card__preview-image",src:s.src,alt:s.alt,loading:"lazy",decoding:"async",dataset:{recordPreview:""},style:{objectFit:s.fit}}):null;return l("div",{class:"zx-record-card__preview",dataset:{failed:String(s.rejected)}},t,e)}function ax(s,t,e,i){let n=Nr(s,t,e,"zx-record-card__eyebrow-group","eyebrow-start"),r=Nr(s,t,i,"zx-record-card__eyebrow-group","eyebrow-end");return n||r?l("div",{class:"zx-record-card__eyebrow"},n,r):null}function Nr(s,t,e,i,n=null){return e.length===0?null:l("dl",{class:i,dataset:n?{cardSlot:n}:void 0},e.map(r=>l("div",{class:"zx-record-card__field",dataset:{fieldId:r.id,...n?{cardSlot:n}:{}}},l("dt",{class:"zx-record-card__label"},r.label),l("dd",{class:"zx-record-card__value"},Dr(Ts(r,s,t))))))}function lx(s){let t=s?.view;if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t.card;if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e.slot;return i==="eyebrow-start"||i==="eyebrow-end"||i==="title-prefix"?i:null}function cx(s){let t=String(s.label??""),e=String(s.title??(t||s.id)),i=[s.icon?b(String(s.icon),{size:14}):null,t?l("span",{class:"zx-record-card__action-label"},t):null],n=s.href==null?null:V(s.href);if(n&&!s.disabled){let r=s.target==null?void 0:String(s.target);return l("a",{class:"zx-record-card__action",href:n,target:r,rel:wf(s.rel,r),title:e,ariaLabel:t||e,dataset:{recordAction:s.id}},i)}return l("button",{class:"zx-record-card__action",type:"button",disabled:!!s.disabled,title:e,ariaLabel:t||e,dataset:{recordAction:s.id}},i)}function bf(s,t,e,i){if(e==null)return"";if(typeof e=="function")return e(s,t);let n=i.find(r=>r.id===e);return n?Ts(n,s,t):s?.[e]??""}function yf(s,t,e,i,n){let r=i.find(o=>o.id===e);return r?Z(r,s,t):Object.prototype.hasOwnProperty.call(s,e)?s[e]:n?e:null}function dx(s,t,e,i){if(e==null)return"";let n=typeof e=="function"?e(s,t):yf(s,t,e,i,!0);return n==null?"":String(n)}function Dr(s){return Fr(s)?s:s==null?"":String(s)}function ux(s){return s==null||typeof s!="object"&&String(s)===""}function hx(s){return Fr(s)?s.textContent?.trim()??"":s==null?"":String(s).trim()}function Fr(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function fx(s){return Array.isArray(s)?s.filter(Fr):[]}function px(s){let t=V(s);if(!t)return null;try{let e=globalThis.location?.href??"https://zx.invalid/",i=new URL(t,e).protocol.toLowerCase();return["http:","https:","blob:"].includes(i)?t:null}catch{return null}}function wf(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function _x(s){return s==="single"||s==="multi"?s:!1}function mx(s){return s==="raised"||s==="filled"?s:"outlined"}function gx(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function bx(s){return["contain","fill","none","scale-down"].includes(String(s))?s:"cover"}var Lr=class extends gt{static cssName="card-view";static defaults={...gt.defaults,selectionTrigger:"checkbox",titleField:null,subtitleField:null,preview:void 0,previewAlt:null,link:void 0,actions:[],groupBy:null,groupOrder:[],minCardWidth:"15rem",maxColumns:null,variant:"outlined",loadingCount:6,headingLevel:3,label:null,keyboard:"tabs",collapsibleGroups:!1,collapsedGroups:[],renderGroupHeading:null};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._cardCreatedRoot=t,this._cardOriginal=t?null:A(e),this._cardCleaned=!1,this._cardNodesById=new Map;let i=this._cardOptions();this._cardGroupOrder=Es(i.groupOrder),this._cardMinWidth=vf(i.minCardWidth),this._cardMaxColumns=xf(i.maxColumns),this._cardVariant=Sf(i.variant),this._cardLoadingCount=Tx(i.loadingCount),this._cardHeadingLevel=Ix(i.headingLevel),this._cardRoving=i.keyboard==="roving",this._cardIdPrefix=x("zx-card-view"),this._cardCollapsed=new Set(Es(i.collapsedGroups)),this._cardCurrent=null,this._cardCurrentIndex=0,this._cardTabStop=null,this._cardStickyX=null,this._cardMoving=!1,this._cardHeadersById=new Map,this._cardGroupOfId=new Map,this._cardSectionIds=new Map,this._cardIdOfNode=new WeakMap,this._cardRoving&&(e.dataset.keyboard="roving");try{this._initRecordView(e),e.setAttribute("aria-label",String(i.label||this.msg("cardView.label")));let n=l("label",{ref:"sortWrap",class:"zx-card-view__sort"},l("span",{class:"zx-card-view__sort-label"},this._message("cardView.sort","Sort")),l("select",{ref:"sort",ariaLabel:this._message("cardView.sortCards","Sort cards")})),r=l("div",{class:"zx-record-view__toolbar zx-card-view__toolbar"},n);Qt(this.options.fieldControls).enabled&&this._mountViewFieldControls(r);let o=l("div",{ref:"content",class:"zx-card-view__content"});return e.replaceChildren(r,o),this.listen(this.refs.sort,"change",()=>this._changeCardSort()),this.listen(o,"click",a=>this._cardClick(a)),this.listen(o,"dblclick",a=>this._cardDoubleClick(a)),this.listen(o,"keydown",a=>{this._cardRoving?this._cardRovingKeydown(a):this._cardKeydown(a)}),this._cardRoving&&this.listen(o,"focusin",a=>this._cardFocusIn(a)),this.listen(o,"error",a=>this._cardPreviewError(a),!0),this._applyCardLayout(),this._renderCardSort(),this._renderCards(),e}catch(n){throw this._removeViewFieldControls(),t||S(e,this._cardOriginal),n}}getViewState(){return{...super.getViewState(),groupOrder:[...this._cardGroupOrder],minCardWidth:this._cardMinWidth,maxColumns:this._cardMaxColumns,variant:this._cardVariant,collapsedGroups:[...this._cardCollapsed]}}setViewState(t,e={}){let i=t&&typeof t=="object"?t:{};return Object.prototype.hasOwnProperty.call(i,"groupOrder")&&(this._cardGroupOrder=Es(i.groupOrder)),Object.prototype.hasOwnProperty.call(i,"minCardWidth")&&(this._cardMinWidth=vf(i.minCardWidth)),Object.prototype.hasOwnProperty.call(i,"maxColumns")&&(this._cardMaxColumns=xf(i.maxColumns)),Object.prototype.hasOwnProperty.call(i,"variant")&&(this._cardVariant=Sf(i.variant)),Object.prototype.hasOwnProperty.call(i,"collapsedGroups")&&(this._cardCollapsed=new Set(Es(i.collapsedGroups))),this._applyCardLayout(),super.setViewState(i,e)}setGroupCollapsed(t,e=!0,i={}){let n=kl(t);return this._cardCollapsed.has(n)===!!e?this:(e?this._cardCollapsed.add(n):this._cardCollapsed.delete(n),this._renderCards(),i.silent||(this.emit("groupcollapse",{id:n,collapsed:!!e,collapsedGroups:[...this._cardCollapsed]}),this.emit("statechange",{state:this.getViewState(),reason:"groupcollapse"})),this)}getCollapsedGroups(){return[...this._cardCollapsed]}destroy(){this._cardCleaned||(this._cardCleaned=!0,super.destroy(),this._cardCreatedRoot||S(this.el,this._cardOriginal))}_refreshView(t){this.refs?.content&&(t==="selection"?this._syncCardSelection():this._renderCards(),this._renderCardSort())}_applyCardLayout(){if(!this.el)return;let t=this.el;t.style.setProperty("--zx-card-view-min-card-width",this._cardMinWidth);let e=this._cardMaxColumns?`${100/this._cardMaxColumns}%`:"0%";t.style.setProperty("--zx-card-view-column-basis",e),this._cardMaxColumns?t.dataset.maxColumns=String(this._cardMaxColumns):delete t.dataset.maxColumns}_renderCardSort(){if(!this.refs?.sort||!this.refs?.sortWrap)return;let t=this.refs.sort,e=this.getSort(),i=[l("option",{value:"",selected:e===null},this._message("cardView.unsorted","Unsorted"))];for(let n of this.getFields().filter(r=>r.sortable))i.push(l("option",{selected:e?.id===n.id&&e.dir==="asc",dataset:{sortId:n.id,sortDir:"asc"}},this._message("cardView.sortAscending","%1 (ascending)",n.label))),i.push(l("option",{selected:e?.id===n.id&&e.dir==="desc",dataset:{sortId:n.id,sortDir:"desc"}},this._message("cardView.sortDescending","%1 (descending)",n.label)));t.replaceChildren(...i),this.refs.sortWrap.hidden=i.length===1}_changeCardSort(){let e=this.refs.sort.selectedOptions[0],i=e?.dataset.sortId;i?this.setSort(i,e.dataset.sortDir==="desc"?"desc":"asc"):this.setSort(null)}_renderCards(){let t=this.refs.content,e=t.ownerDocument,i=e?.activeElement??null,n=!!(i&&i!==e.body&&t.contains(i)),r=t.querySelector(".zx-record-card:focus"),o=r&&this._cardIdOfNode.has(r)?this._cardIdOfNode.get(r):null;if(this._cardNodesById=new Map,this._cardHeadersById=new Map,this._cardGroupOfId=new Map,this._cardSectionIds=new Map,this._cardTabStop=null,this._cardRoving&&(t.removeAttribute("role"),t.removeAttribute("aria-label"),t.removeAttribute("aria-multiselectable")),this.el.dataset.loading==="true"){t.replaceChildren(this._createCardSkeletons()),this._syncCardEmptyFocus(n);return}let a=zx(this._viewData,this._cardOptions().groupBy,this._cardGroupOrder,this._viewFields,this.msg("cardView.ungrouped"));if(this._viewData.length===0&&a.length===0){t.replaceChildren(this._createCardEmpty()),this._syncCardEmptyFocus(n);return}let c=this.getFields(),d=this.getVisibleFields(),u=a.map((h,f)=>this._createCardGroup(h,c,d,f));if(t.replaceChildren(...u),this._cardRoving){t.setAttribute("role","grid"),t.setAttribute("aria-label",this.el.getAttribute("aria-label")??""),this.options.selectable==="multi"&&t.setAttribute("aria-multiselectable","true"),this._syncCardEmptyFocus(!1),this._syncCardRoving(n);return}if(o!==null){let h=this._cardNodesById.get(o);h&&queueMicrotask(()=>h.isConnected&&h.focus())}}_createCardGroup(t,e,i,n){let r=this._cardOptions(),o=this._cardRoving,a=t.id===null?null:`${this._cardIdPrefix}-group-${Ex(t.id)}-${n}`,c=t.id!==null&&!!r.collapsibleGroups,d=c&&this._cardCollapsed.has(t.id),u=l("ul",{class:"zx-card-view__list",id:a?`${a}-list`:void 0,role:o?t.id===null?"rowgroup":"none":void 0,ariaLabelledby:a??void 0,hidden:d});for(let p of t.records){let _=this._viewRecordId(p);if(t.id!==null&&this._cardGroupOfId.set(_,t.id),d)continue;let m=this._viewData.indexOf(p),g=Or(p,m,{fields:e,visibleFields:i,titleField:r.titleField,subtitleField:r.subtitleField,preview:r.preview,previewAlt:r.previewAlt,link:r.link,actions:r.actions,selectable:this.options.selectable,selectionTrigger:r.selectionTrigger,selected:this._isViewSelected(_),variant:this._cardVariant,headingLevel:this._cardHeadingLevel,message:(w,...v)=>this.msg(w,...v)});o&&this._makeCardRow(g,_),this._cardNodesById.set(_,g),this._cardIdOfNode.set(g,_),u.append(g)}if(t.records.length===0&&!d){let p=this.msg("cardView.groupEmpty");u.append(o?l("li",{class:"zx-card-view__group-empty",role:"row"},l("span",{role:"gridcell"},p)):l("li",{class:"zx-card-view__group-empty"},p))}if(t.id===null)return u;let h=this._createGroupHeader(t,a,c,d),f=l("section",{class:"zx-card-view__group",role:o?"rowgroup":void 0,ariaLabelledby:a,dataset:{collapsed:c?String(d):null}},h,u);return this._cardSectionIds.set(f,t.id),f}_createGroupHeader(t,e,i,n){let r=t.id,o=this._cardOptions().renderGroupHeading,a=typeof o=="function"?o({id:r,label:t.label,count:t.records.length,records:[...t.records],collapsed:n,toggle:()=>this.setGroupCollapsed(r,!this._cardCollapsed.has(r))}):null,c=a==null?t.label:zf(a)?a:String(a),d=l("span",{class:"zx-card-view__group-label"},c),u=this._cardRoving,h=i?l("button",{class:"zx-card-view__group-toggle",type:"button",tabindex:u?-1:void 0,ariaExpanded:String(!n),ariaControls:`${e}-list`,dataset:{groupToggle:""}},b("chevron-down",{size:14}),d):d,f=l("h2",{class:"zx-card-view__group-heading",id:e},h),p=l("div",{class:"zx-card-view__group-header",role:u?"row":void 0,ariaExpanded:u&&i?String(!n):void 0,ariaLabelledby:u?e:void 0,tabindex:u&&i?-1:void 0,dataset:{cardItem:u&&i?"group":null}},l("div",{class:"zx-card-view__group-cell",role:u?"rowheader":void 0},f));return u&&i&&this._cardHeadersById.set(r,p),p}_makeCardRow(t,e){t.setAttribute("role","row"),t.tabIndex=-1,t.dataset.cardItem="card",t.removeAttribute("aria-description"),t.removeAttribute("aria-keyshortcuts"),this.options.selectable&&t.setAttribute("aria-selected",String(this._isViewSelected(e)));for(let i of t.children)i.setAttribute("role","gridcell");for(let i of t.querySelectorAll(yx))i!==t&&(i.tabIndex=-1)}_syncCardRoving(t){let e=this._cardItems();if(e.length===0){this._syncCardEmptyFocus(t);return}let i=this._cardItemFor(this._cardCurrent);if(!i&&this._cardCurrent?.kind==="card"){let n=this._cardGroupOfId.get(this._cardCurrent.id);i=n===void 0?null:this._cardHeadersById.get(n)??null}i||(i=e[Math.min(Math.max(this._cardCurrentIndex,0),e.length-1)]),this._setCardTabStop(i,e),t&&i.focus({preventScroll:!0})}_setCardTabStop(t,e=this._cardItems()){for(let n of e)n!==t&&(n.tabIndex=-1);t.tabIndex=0,this._cardTabStop=t;let i=this._cardItemKey(t);i&&(this._cardCurrent=i),this._cardCurrentIndex=Math.max(0,e.indexOf(t))}_syncCardEmptyFocus(t){if(!this._cardRoving)return;let e=this.refs.content;t?(e.hasAttribute("tabindex")||(e.tabIndex=-1,e.setAttribute("data-empty-focus","")),e.focus({preventScroll:!0})):e.hasAttribute("data-empty-focus")&&(e.removeAttribute("tabindex"),e.removeAttribute("data-empty-focus"))}_cardItems(){return[...this.refs.content.querySelectorAll("[data-card-item]")]}_cardItemKey(t){if(t.dataset.cardItem==="group"){for(let[e,i]of this._cardHeadersById)if(i===t)return{kind:"group",id:e};return null}return this._cardIdOfNode.has(t)?{kind:"card",id:this._cardIdOfNode.get(t)}:null}_cardItemFor(t){return t?t.kind==="group"?this._cardHeadersById.get(t.id)??null:this._cardNodesById.get(t.id)??null:null}_cardFocusIn(t){let i=t.target?.closest?.("[data-card-item]")??null;!i||!this.refs.content.contains(i)||(this._cardTabStop!==i&&this._setCardTabStop(i),this._cardMoving||(this._cardStickyX=i.getBoundingClientRect().left))}_cardRovingKeydown(t){let e=t.target,i=e?.closest?.("[data-card-item]")??null;if(!i||!this.refs.content.contains(i))return;let n=e===i;if(!n&&e?.matches?.(wx))return;let r=this._cardItems(),o=r.indexOf(i),a=i.dataset.cardItem,c=t.key,d=this.options.selectable==="multi";if((t.ctrlKey||t.metaKey)&&(c==="a"||c==="A")){if(!d)return;t.preventDefault(),this.setSelection(this._cardIdsOf(r));return}if(n&&(c==="Enter"||c===" ")){if(t.preventDefault(),a==="group"){let v=this._cardItemKey(i)?.id;this.setGroupCollapsed(v,!this._cardCollapsed.has(v));return}let g=this._viewData[Number(i.dataset.recordIndex)];if(!g)return;let w=this._viewRecordId(g);if(c===" "&&this.options.selectable){this.toggleSelection(w);return}this._activateCard(g,w,Number(i.dataset.recordIndex),t),this.options.selectable==="single"&&this.toggleSelection(w,{selected:!0});return}if(a==="group"&&n&&(c==="ArrowLeft"||c==="ArrowRight")){t.preventDefault();let g=this._cardItemKey(i)?.id;this.setGroupCollapsed(g,c==="ArrowLeft");return}if(!vx.has(c))return;let u=r.map(g=>g.getBoundingClientRect()),h=c==="ArrowUp"||c==="ArrowDown"||c==="PageUp"||c==="PageDown",f=h?this._cardStickyX??u[o].left:u[o].left,p=Ax(kx(this.refs.content),u[o].height),_=Sx(u,o,c,{page:p,x:f});if(_===null||(t.preventDefault(),_===o))return;let m=r[_];h||(this._cardStickyX=u[_].left),this._cardMoving=!0;try{this._setCardTabStop(m,r),m.focus({preventScroll:!0}),m.scrollIntoView?.({block:"nearest",inline:"nearest"})}finally{this._cardMoving=!1}if(t.shiftKey&&d){let g=r.slice(Math.min(o,_),Math.max(o,_)+1);this.setSelection([...this.getSelectionIds(),...this._cardIdsOf(g)])}}_cardIdsOf(t){return t.filter(e=>e.dataset.cardItem==="card").map(e=>this._viewData[Number(e.dataset.recordIndex)]).filter(Boolean).map(e=>this._viewRecordId(e))}_createCardSkeletons(){let t=l("ul",{class:"zx-card-view__list zx-card-view__skeletons",ariaHidden:"true"});for(let e=0;e<this._cardLoadingCount;e+=1)t.append(l("li",{class:"zx-record-card zx-card-view__skeleton",tabindex:-1},l("span",{class:"zx-card-view__skeleton-preview zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"})));return t}_createCardEmpty(){let t=this.options.emptyText,e=typeof t=="function"?t():t??this.msg("table.empty");return l("div",{class:"zx-card-view__empty",role:"status"},zf(e)?e:String(e))}_syncCardSelection(){for(let[t,e]of this._cardNodesById){let i=this._isViewSelected(t);e.dataset.selected=String(i),this._cardRoving?this.options.selectable&&e.setAttribute("aria-selected",String(i)):this.options.selectable&&e.setAttribute("aria-description",this.msg(i?"recordCard.selected":"recordCard.notSelected"));let n=e.querySelector("[data-record-selection]");n&&(n.checked=i)}}_cardClick(t){let e=t.target,i=e?.closest?.("[data-group-toggle]");if(i&&this.refs.content.contains(i)){let u=i.closest(".zx-card-view__group"),h=u?this._cardSectionIds.get(u):void 0;h!==void 0&&this.setGroupCollapsed(h,!this._cardCollapsed.has(h));return}let n=e?.closest?.(".zx-record-card");if(!n||!this.refs.content.contains(n))return;let r=Number(n.dataset.recordIndex),o=this._viewData[r];if(!o)return;let a=this._viewRecordId(o),c=e?.closest?.("[data-record-selection]");if(c){this.toggleSelection(a,{selected:c.checked,range:t.shiftKey});return}let d=e?.closest?.("[data-record-action]");if(d){this._activateCardAction(o,a,r,d.dataset.recordAction,t);return}if(!(Af(e,n)||kf(n))){if(this.options.selectable&&this._cardOptions().selectionTrigger==="card"){this.toggleSelection(a,{range:t.shiftKey}),n.focus({preventScroll:!0});return}this._activateCard(o,a,r,t),this.options.selectable==="single"&&this.toggleSelection(a,{selected:!0})}}_cardDoubleClick(t){let e=t.target,i=e?.closest?.(".zx-record-card");if(!i||Af(e,i)||kf(i))return;let n=Number(i.dataset.recordIndex),r=this._viewData[n];r&&this.emit("recorddblclick",{record:r,id:this._viewRecordId(r),index:n,event:t})}_cardKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-record-card"):null;if(!e||t.target!==e)return;let i=Number(e.dataset.recordIndex),n=this._viewData[i];if(!n)return;let r=this._viewRecordId(n);t.key==="Enter"?(t.preventDefault(),this.options.selectable&&this._cardOptions().selectionTrigger==="card"?this.toggleSelection(r):this._activateCard(n,r,i,t)):t.key===" "&&this.options.selectable&&(t.preventDefault(),this.toggleSelection(r))}_activateCard(t,e,i,n){this.emit("recordclick",{record:t,id:e,index:i,event:n})}_activateCardAction(t,e,i,n,r){let o=Is(t,i,this._cardOptions().actions).find(c=>c.id===n);if(!o||o.disabled){r.preventDefault();return}typeof o.onclick=="function"&&o.onclick(t,i,r),this.emit("recordaction",{record:t,id:e,index:i,action:{...o},event:r}).defaultPrevented&&r.preventDefault()}_cardPreviewError(t){let e=t.target;if(!e?.matches?.("[data-record-preview]"))return;let i=e.closest(".zx-record-card__preview");i&&(i.dataset.failed="true"),e.hidden=!0}_cardOptions(){return this.options}},yx='a[href],button,input,select,textarea,summary,[tabindex]:not([tabindex="-1"]),[contenteditable="true"]',wx='input:not([type="checkbox"]):not([type="radio"]),select,textarea,[contenteditable="true"]',vx=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function xx(s,t=4){let e=s.map((n,r)=>({index:r,top:Number(n.top)||0,left:Number(n.left)||0})).sort((n,r)=>n.top-r.top||n.left-r.left),i=[];for(let n of e){let r=i.at(-1);r&&Math.abs(n.top-r.top)<=t?r.items.push(n):i.push({top:n.top,items:[n]})}return i.map(n=>n.items.sort((r,o)=>r.left-o.left).map(r=>r.index))}function Sx(s,t,e,i={}){if(s.length===0)return null;let n=Math.min(Math.max(Math.trunc(Number(t)||0),0),s.length-1);if(e==="Home")return 0;if(e==="End")return s.length-1;let r=xx(s),o=r.findIndex(p=>p.includes(n)),a=r[o];if(e==="ArrowLeft"||e==="ArrowRight"){let p=a.indexOf(n)+(e==="ArrowLeft"?-1:1);return p<0||p>=a.length?n:a[p]}let c=Math.max(1,Math.trunc(Number(i.page)||10)),d={ArrowUp:-1,ArrowDown:1,PageUp:-c,PageDown:c}[e];if(d===void 0)return null;let u=r[Math.min(Math.max(o+d,0),r.length-1)];if(u===a)return n;let h=Number.isFinite(Number(i.x))?Number(i.x):Number(s[n].left)||0,f=u[0];for(let p of u)Math.abs((Number(s[p].left)||0)-h)<Math.abs((Number(s[f].left)||0)-h)&&(f=p);return f}function Ax(s,t,e=10){let i=Number(s),n=Number(t);return!(i>0)||!(n>0)?Math.max(1,Math.trunc(e)||10):Math.max(1,Math.floor(i/n)-1)}function kx(s){let t=s.parentElement;for(;t&&t!==s.ownerDocument.body;){let e=getComputedStyle(t).overflowY;if(/(auto|scroll|overlay)/.test(e)&&t.scrollHeight>t.clientHeight)return t.clientHeight;t=t.parentElement}return s.ownerDocument.defaultView?.innerHeight??0}function zx(s,t,e=[],i=[],n="Ungrouped"){if(!Array.isArray(s))throw new TypeError("Card view records must be an array");if(t==null)return s.length?[{id:null,label:"",records:[...s]}]:[];let r=Es(e),o=new Map(r.map(a=>[a,[]]));for(let[a,c]of s.entries()){let d=typeof t=="function"?t(c,a):Cx(c,a,t,i),u=kl(d);o.has(u)||o.set(u,[]),o.get(u).push(c)}return[...o].map(([a,c])=>({id:a,label:a||n,records:c}))}function Cx(s,t,e,i){let n=i.find(r=>r.id===e);return n?Z(n,s,t):s?.[e]}function Es(s){return Array.isArray(s)?[...new Set(s.map(kl))]:[]}function kl(s){return s==null||s===""?"":String(s)}function vf(s){if(typeof s=="number")return Number.isFinite(s)&&s>0?`${s}px`:"15rem";let t=String(s??"").trim();return!t||t.length>128||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|expression)\s*\(/i.test(t)||typeof globalThis.CSS?.supports=="function"&&!globalThis.CSS.supports("width",t)?"15rem":t}function xf(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(1,Math.min(12,Math.floor(t))):null}function Sf(s){return s==="raised"||s==="filled"?s:"outlined"}function Tx(s){let t=Number(s??6);return Number.isFinite(t)?Math.max(1,Math.min(50,Math.floor(t))):6}function Ix(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function Af(s,t){let e=s?.closest?.('a,button,input,select,textarea,summary,[contenteditable="true"],[role="button"]');return!!(e&&e!==t&&t.contains(e))}function kf(s){let t=globalThis.getSelection?.();return!!(t&&!t.isCollapsed&&(t.anchorNode&&s.contains(t.anchorNode)||t.focusNode&&s.contains(t.focusNode)))}function zf(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Ex(s){return s.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"empty"}var Cf=Object.freeze(["neutral","accent","success","warning","danger","info"]);function Rr(s,t={}){if(s==null||s==="")return null;let e=t&&typeof t=="object"?t:{},i=typeof s=="object"&&!("nodeType"in s)?s:{label:s},n=i.label==null?"":String(i.label);if(!n)return null;let r=e[n],o=Cf.includes(i.tone)?i.tone:Cf.includes(r)?r:"neutral";return{label:n,tone:o,icon:i.icon==null?null:String(i.icon),dot:i.dot!==!1&&i.icon==null,...i.title==null?{}:{title:String(i.title)}}}function zl(s){return ht({label:s.label,kind:s.tone,icon:s.icon??void 0,dot:s.dot,size:"sm",variant:"soft",...s.title==null?{}:{title:s.title}})}function Pr(s,t=100){if(s==null||s==="")return null;let e=typeof s=="object"&&!("nodeType"in s)?s:{value:s},i=Number(e.max??t),n=Number(e.value);if(!Number.isFinite(n)||!Number.isFinite(i)||i<=0)return null;let r=Math.max(0,Math.min(i,n)),o=e.label==null?"":String(e.label).trim();return{value:r,max:i,percent:Math.round(r/i*100),label:o||null}}function Br(s,t,e){let i=l("div",{class:"zx-kanban-view__progress-track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(s.max),ariaValuenow:String(s.value),ariaValuetext:e,ariaLabel:t},l("div",{class:"zx-kanban-view__progress-fill"}));return i.firstElementChild.style.inlineSize=`${s.percent}%`,l("div",{class:"zx-kanban-view__progress"},l("div",{class:"zx-kanban-view__progress-head"},l("span",{class:"zx-kanban-view__progress-label"},t),l("span",{class:"zx-kanban-view__progress-value"},e)),i)}function Vr(s){return s==null||s===""?[]:(Array.isArray(s)?s:[s]).map(e=>{if(e==null||e==="")return null;let i=typeof e=="object"&&!("nodeType"in e)?e:{name:e},n=String(i.name??i.label??"").trim();if(!n)return null;let r=V(i.src??i.image??null),o=i.initials==null?Te(n):String(i.initials),a=Ai.includes(i.tone)?i.tone:ue(n);return{name:n,src:r,initials:o,tone:a}}).filter(Boolean)}function Cl(s,t){let e=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,i=Number.isFinite(s)?Math.max(1,Math.floor(s)):e,n=Math.min(e,i);return{shown:n,hidden:Math.max(0,e-n)}}function jr(s,t,e,i){if(!s.length)return null;let n=Cl(t,s.length),r=s.slice(0,n.shown),o=n.hidden,a=r.map(c=>l("span",{class:"zx-kanban-view__avatar",ariaHidden:"true",title:c.name||void 0,dataset:{tone:c.tone??ue(c.name)}},c.src?l("img",{class:"zx-kanban-view__avatar-image",src:c.src,alt:"",draggable:!1}):l("span",{class:"zx-kanban-view__avatar-initials"},c.initials)));return o>0&&a.push(l("span",{class:"zx-kanban-view__avatar",ariaHidden:"true",dataset:{overflow:"true"}},l("span",{class:"zx-kanban-view__avatar-initials"},i(o)))),l("span",{class:"zx-kanban-view__avatars",role:"img",ariaLabel:e},a)}function Hr(s){let t=[];s.entityIcon&&t.push(l("span",{class:"zx-kanban-view__entity",ariaHidden:"true"},b(s.entityIcon,{size:12}))),s.identifier&&t.push(l("span",{class:"zx-kanban-view__identifier"},s.identifierPrefix?l("span",{class:"zx-kanban-view__hint"},`${s.identifierPrefix} `):null,s.identifier));let e=(s.flags??[]).map(i=>{if(i.indicator==null)return null;let n=typeof i.indicator=="object"&&"nodeType"in i.indicator?i.indicator:zl(i.indicator);return i.prefix?l("span",{class:"zx-kanban-view__flag"},l("span",{class:"zx-kanban-view__hint"},`${i.prefix} `),n):n}).filter(Boolean);return!t.length&&!e.length?null:l("div",{class:"zx-kanban-view__card-head"},t.length?l("span",{class:"zx-kanban-view__card-lead"},t):null,e.length?l("span",{class:"zx-kanban-view__card-flags"},e):null)}var Mx=Object.freeze(["neutral","accent","success","warning","danger","info"]);function qr(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Kanban rules must be an array or null");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Kanban rule at index ${i} must be an object`);let n=e,r=String(n.id??"").trim();if(!r)throw new TypeError(`Kanban rule at index ${i} requires an id`);if(t.has(r))throw new TypeError(`Duplicate Kanban rule: ${r}`);if(typeof n.when!="function")throw new TypeError(`Kanban rule ${r} requires a when predicate`);return t.add(r),{id:r,when:n.when,tone:Mx.includes(n.tone)?n.tone:"accent",label:n.label==null?"":String(n.label),icon:n.icon==null?null:String(n.icon),description:n.description==null?"":String(n.description)}})}function Ms(s,t,e){return!Array.isArray(s)||!s.length?[]:s.filter(i=>{try{return i.when(t,e)===!0}catch{return!1}})}function $r(s){let{records:t,column:e,swimlane:i,context:n,from:r}=s,o=Math.max(1,t.length),a=e?.wipPolicy==="block"||e?.wipPolicy==="warn"?e.wipPolicy:s.policy==="block"?"block":"warn",c=(_,m={})=>({allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:a,...m}),d=Ds(e,i,r);if(d)return c(d);for(let _ of t){if(e.accept&&e.accept(_,n)===!1)return c("accept");if(i?.accept&&i.accept(_,n)===!1)return c("lane-accept")}let u=[];e.limit!=null&&u.push({reason:"wip",limit:e.limit,count:s.columnCount+o});let h=i?Dx(e.laneLimits,i.id):null;h!=null&&u.push({reason:"wip",limit:h,count:s.cellCount+o}),i?.limit!=null&&u.push({reason:"lane-wip",limit:i.limit,count:s.laneCount+o});let f=u.find(_=>_.count>_.limit),p=f??u.find(_=>_.count===_.limit)??u[0];return f&&a==="block"?c(f.reason,{limit:f.limit,count:f.count,limitExceeded:!0}):{allowed:!0,reason:null,limit:p?p.limit:null,count:p?p.count:0,limitExceeded:!!f,limitReached:!!(p&&!f&&p.count===p.limit),policy:a}}function Ds(s,t,e){return s.id!==e.column&&!Tf(s.from,e.column)?"transition":t&&t.id!==e.lane&&!Tf(t.from,e.lane)?"lane-transition":null}function Kr(s){let t=s==null?"":String(s).trim().toLowerCase();return t?[...t.matchAll(/"([^"]*)"|(\S+)/g)].map(e=>(e[1]??e[2]??"").trim()).filter(Boolean):[]}function Ur(s,t){if(!t.length)return!0;let e=s.toLowerCase();return t.every(i=>e.includes(i))}function Yr(s=50){let t=Number.isFinite(Number(s))&&Number(s)>0?Math.floor(Number(s)):50,e=[],i=[];return{push(n){e.push(n),e.length>t&&(e=e.slice(-t)),i=[]},undo(n){let r=e.pop();return r?(i.push(n),i.length>t&&(i=i.slice(-t)),r):null},redo(n){let r=i.pop();return r?(e.push(n),e.length>t&&(e=e.slice(-t)),r):null},canUndo:()=>e.length>0,canRedo:()=>i.length>0,clear(){e=[],i=[]},depth:()=>({undo:e.length,redo:i.length})}}function Gr(s,t,e){if(!Array.isArray(s)||!Array.isArray(t)||!t.length)return null;let i=t.map(u=>({...u,index:s.findIndex(h=>Object.is(Oe(h,e.recordId),u.id))}));if(i.some(u=>u.index<0||!u.record||typeof u.record!="object"))return null;i.sort((u,h)=>u.index-h.index);let n=i.map(u=>({id:u.id,from:Ns(s,u.index,e)})),r=new Set(i.map(u=>u.index)),o=s.filter((u,h)=>!r.has(h)),a=o.filter((u,h)=>W(_e(u,h,e.columnBy))===e.destination.column&&(e.swimlaneBy==null||W(_e(u,h,e.swimlaneBy))===e.destination.lane)),c=Os(e.destination.index,a.length),d=o.length;return a[c]?d=o.indexOf(a[c]):a.length&&(d=o.indexOf(a.at(-1))+1),o.splice(d,0,...i.map(u=>u.record)),{records:o,moves:n,to:{column:e.destination.column,lane:e.swimlaneBy==null?null:e.destination.lane,index:c}}}function Ns(s,t,e){let i=s[t],n=W(_e(i,t,e.columnBy)),r=e.swimlaneBy==null?null:W(_e(i,t,e.swimlaneBy)),o=s.filter((c,d)=>W(_e(c,d,e.columnBy))===n&&(e.swimlaneBy==null||W(_e(c,d,e.swimlaneBy))===r)),a=Oe(i,e.recordId);return{column:n,lane:r,index:o.findIndex(c=>Object.is(Oe(c,e.recordId),a))}}function Wr(s,t){let e=Os(t,s.filter(Boolean).length),i=0;for(let n=0;n<s.length;n+=1)if(s[n]){if(i===e)return n;i+=1}return s.length}function _e(s,t,e){return typeof e=="function"?e(s,t):e==null?null:s?.[e]}function W(s){return s==null?"":String(s)}function Os(s,t){return s==null||!Number.isFinite(Number(s))?t:Math.max(0,Math.min(t,Math.trunc(Number(s))))}function Tf(s,t){return s==null||!Array.isArray(s)?!0:s.length?s.some(e=>String(e)==="*"||String(e)===W(t)):!1}function Dx(s,t){if(!s||typeof s!="object")return null;let e=s[t];if(e==null||e==="")return null;let i=Number(e);return Number.isFinite(i)&&i>=0?Math.floor(i):null}var Tl='a, button, input, select, textarea, summary, [contenteditable="true"]',Nx=4,Ox=350,Fx=120,Qr=56,Xr=18,Lx=Object.freeze({fields:"Fields",search:"Search board",searchPlaceholder:"Search cards",clearSearch:"Clear search",searchSummary:"%count% of %total% cards match.",undo:"Undo",redo:"Redo",add:"Add card",addTo:"Add card to %target%",move:"Move %name%",moveMultiple:"Move %count% selected cards",collapseColumn:"Collapse column %label%",expandColumn:"Expand column %label%",collapseLane:"Collapse swim lane %label%",expandLane:"Expand swim lane %label%",count:"%count% records",countFiltered:"%count% of %total% records",countLimit:"%count% records, work-in-progress limit %limit%",countLimitInLane:"%count% records in this lane, %total% of work-in-progress limit %limit% in the column",empty:"No records",columnEmpty:"Drop a card here",identifier:"Record",priorityLabel:"Priority",statusLabel:"Status",progress:"Progress",progressValue:"%percent%%",assignees:"Assigned to %names%",assigneeOverflow:"+%count%",selected:"Selected",notSelected:"Not selected",noMatches:"No cards match the current search.",record:"record",grabbed:"Grabbed %name%. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.",grabbedMultiple:"Grabbed %count% cards. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.",target:"Target %target%, position %position% of %total%.",moved:"Moved %name% to %target%.%wip%",movedMultiple:"Moved %count% cards to %target%.%wip%",moveRequested:"Move requested for %name% to %target%.%wip%",moveCanceled:"Move canceled for %name%.",moveCanceledPlain:"Move canceled.",limitReached:" Work-in-progress limit %limit% reached.",limitExceeded:" Work-in-progress limit %limit% exceeded.",rejectAccept:"Move rejected: %target% does not accept %name%.",rejectTransition:"Move rejected: %target% does not accept cards from %origin%.",rejectWip:"Move rejected: %target% is at its work-in-progress limit of %limit%.",rejectDestination:"Move rejected: the destination is not available.",rejectGrouping:"Move rejected: callback grouping requires external move mode.",undone:"Move undone.",redone:"Move redone.",nothingToUndo:"Nothing to undo.",nothingToRedo:"Nothing to redo.",menuMoveTo:"Move to %target%",menuMoveToLane:"Move to lane %target%",dragPreview:"%count% cards"}),Zr=class extends gt{static cssName="kanban-view";static defaults={...gt.defaults,selectionTrigger:"checkbox",columnBy:"status",columns:null,swimlaneBy:null,swimlanes:null,titleField:null,subtitleField:null,preview:null,previewAlt:null,link:null,actions:[],moveMode:"local",dragFrom:"card",moveHandle:"keyboard",entityIcon:null,identifier:null,status:null,statusTones:{},priority:null,priorityTones:{},progress:null,progressMax:100,assignees:null,maxAvatars:3,multiMove:!0,autoScroll:!0,wipPolicy:"warn",rules:[],search:"",searchFields:null,filter:null,searchControl:!1,history:!0,historyLimit:50,historyControls:!1,columnHeight:null,allowAdd:!1,contextMenu:!1,renderCard:null,renderColumnHeader:null,renderSwimlaneHeader:null,renderColumnEmpty:null,renderDragPreview:null,labels:{},columnOrder:[],swimlaneOrder:[],collapsedColumns:[],collapsedSwimlanes:[],showCounts:!0,showEmptyColumns:!0,variant:"outlined",label:"Kanban board"};constructor(t=null,e={}){super(t,e)}render(){let t=!!this.el,e=this.el??l("div"),i=this._kanbanOptions();this._kanbanSnapshot=t?A(e):null,this._kanbanDestroyed=!1;try{if(this._initRecordView(e),this._kanbanColumns=i.columns===null?null:Jr(i.columns,"column"),this._kanbanSwimlanes=i.swimlanes===null?null:Jr(i.swimlanes,"swimlane"),this._kanbanColumnOrder=Bt(i.columnOrder),this._kanbanSwimlaneOrder=Bt(i.swimlaneOrder),this._collapsedColumns=new Set(Bt(i.collapsedColumns)),this._collapsedSwimlanes=new Set(Bt(i.collapsedSwimlanes)),this._kanbanRules=qr(i.rules),this._kanbanSearch=i.search==null?"":String(i.search),this._kanbanFilter=typeof i.filter=="function"?i.filter:null,this._kanbanHistory=Yr(i.historyLimit),this._keyboardMove=null,this._dragIds=[],this._dragDestination=null,this._pointerStart=null,this._pointerHold=0,this._dragFrame=0,this._dragPreview=null,this._dragPointer=null,this._dragCaptured=!1,this._searchTimer=0,this._dragPoint={x:0,y:0},this._suppressClick=!1,this._announcementToken=0,this._cardMeta=new WeakMap,this._sectionMeta=new WeakMap,this._cardsById=new Map,this._visibleIds=new Set,this._cardSources={identifier:null,status:null,priority:null,progress:null,assignees:null,entityIcon:null,fieldIds:new Set,any:!1},this._fieldIndex=null,this._cardFields=null,this._kanbanMenu=null,this._searchInput=null,this._undoButton=null,this._redoButton=null,this._toolbar=l("div",{class:"zx-record-view__toolbar zx-kanban-view__toolbar"}),i.fieldControls){let n=Qt(i.fieldControls).label;this._mountViewFieldControls(this._toolbar,n??this._text("fields"))}return i.searchControl&&this._toolbar.append(this._createSearchControl()),i.historyControls&&this._toolbar.append(this._createHistoryControls()),this._board=l("div",{class:"zx-kanban-view__board",role:"region",ariaLabel:i.label}),this._live=l("div",{class:"zx-kanban-view__live",role:"status",ariaLive:"polite",ariaAtomic:"true"}),e.replaceChildren(this._toolbar,this._board,this._live),i.columnHeight&&(e.style.setProperty("--zx-kanban-column-height",String(i.columnHeight)),e.dataset.columnScroll="true"),this.listen(this._board,"click",n=>this._handleBoardClick(n)),this.listen(this._board,"dblclick",n=>this._handleBoardDoubleClick(n)),this.listen(this._board,"keydown",n=>this._handleBoardKeydown(n)),this.listen(this._board,"error",n=>this._handlePreviewError(n),{capture:!0}),this.listen(this._board,"pointerdown",n=>this._handlePointerDown(n)),this.listen(this._board,"pointermove",n=>this._handlePointerMove(n)),this.listen(this._board,"pointerup",n=>this._handlePointerUp(n)),this.listen(this._board,"pointercancel",()=>this._clearDrag()),this.listen(this._board,"dragstart",n=>n.preventDefault()),this._refreshView("init"),i.contextMenu&&this._createContextMenu(),e}catch(n){throw this._removeViewFieldControls(),this._kanbanSnapshot&&S(e,this._kanbanSnapshot),n}}getColumns(){return this._resolvedColumns().map(t=>({...t}))}setColumns(t){this._kanbanColumns=t===null?null:Jr(t,"column");let e=this._rawColumns();if(this._kanbanColumnOrder=Li(e,this._kanbanColumnOrder,this._kanbanColumns===null),this._kanbanColumns!==null){let i=new Set(e.map(n=>n.id));this._collapsedColumns=new Set([...this._collapsedColumns].filter(n=>i.has(n)))}return this._refreshView("columns"),this._emitKanbanState("columns"),this}getSwimlanes(){return this._resolvedSwimlanes().map(t=>({...t}))}setSwimlanes(t){this._kanbanSwimlanes=t===null?null:Jr(t,"swimlane");let e=this._rawSwimlanes(),i=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;if(this._kanbanSwimlaneOrder=Li(e,this._kanbanSwimlaneOrder,i),!i){let n=new Set(e.map(r=>r.id));this._collapsedSwimlanes=new Set([...this._collapsedSwimlanes].filter(r=>n.has(r)))}return this._refreshView("swimlanes"),this._emitKanbanState("swimlanes"),this}getColumnOrder(){return this._resolvedColumns().map(t=>t.id)}setColumnOrder(t,e={}){let i=this._rawColumns(),n=this.getColumnOrder(),r=Il(i,t);return Ff(r,n)?this:(this._kanbanColumnOrder=Of(this._kanbanColumnOrder,i,r,this._kanbanColumns===null),this._refreshView("columnorder"),e.silent||this._emitKanbanState("columnorder"),this)}moveColumn(t,e,i="before"){return this.setColumnOrder(Nf(this.getColumnOrder(),t,e,i))}getSwimlaneOrder(){return this._resolvedSwimlanes().map(t=>t.id)}setSwimlaneOrder(t,e={}){let i=this._rawSwimlanes(),n=this.getSwimlaneOrder(),r=Il(i,t);if(Ff(r,n))return this;let o=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=Of(this._kanbanSwimlaneOrder,i,r,o),this._refreshView("swimlaneorder"),e.silent||this._emitKanbanState("swimlaneorder"),this}moveSwimlane(t,e,i="before"){return this.setSwimlaneOrder(Nf(this.getSwimlaneOrder(),t,e,i))}getCollapsedColumns(){return this.getColumnOrder().filter(t=>this._collapsedColumns.has(t))}setColumnCollapsed(t,e=!0,i={}){let n=String(t);if(!this.getColumnOrder().includes(n))throw new RangeError(`Unknown Kanban column: ${n}`);return(e?!this._collapsedColumns.has(n):this._collapsedColumns.has(n))?(e?this._collapsedColumns.add(n):this._collapsedColumns.delete(n),this._refreshView("columncollapse"),i.silent||this._emitKanbanState("columncollapse"),this):this}toggleColumn(t){return this.setColumnCollapsed(t,!this._collapsedColumns.has(String(t)))}getCollapsedSwimlanes(){return this.getSwimlaneOrder().filter(t=>this._collapsedSwimlanes.has(t))}setSwimlaneCollapsed(t,e=!0,i={}){let n=String(t);if(!this.getSwimlaneOrder().includes(n))throw new RangeError(`Unknown Kanban lane: ${n}`);return(e?!this._collapsedSwimlanes.has(n):this._collapsedSwimlanes.has(n))?(e?this._collapsedSwimlanes.add(n):this._collapsedSwimlanes.delete(n),this._refreshView("swimlanecollapse"),i.silent||this._emitKanbanState("swimlanecollapse"),this):this}toggleSwimlane(t){return this.setSwimlaneCollapsed(t,!this._collapsedSwimlanes.has(String(t)))}moveRecord(t,e){return this.moveRecords([t],e)}moveRecords(t,e){let i=this._kanbanOptions();if(!Array.isArray(t)||!e||typeof e!="object")return this;let n=this._orderedIds(t);if(!n.length)return this;let r=n.map(F=>this.getRecord(F)),o=n.map(F=>this._recordLocation(F)),a=o[0],c=this._resolvedColumns(),d=this._resolvedSwimlanes(),u=e.column==null?a.column:String(e.column),h=i.swimlaneBy==null?null:e.lane===void 0?a.lane:W(e.lane),f=c.find(F=>F.id===u),p=i.swimlaneBy==null?null:d.find(F=>F.id===h)??null;if(!f||i.swimlaneBy!=null&&!p)return this._rejectMove("destination",{ids:n,records:r,from:a,to:null,column:null,swimlane:null}),this;let _=new Set(n),m=this._recordsIn(u,h).filter(F=>!_.has(this._viewRecordId(F.record))).length,g=Os(e.index,m),w={column:u,lane:h,index:g};if(n.length===1&&Bx(a,w))return this;let v={id:n[0],from:{...a},to:{...w},column:{...f},swimlane:p?{...p}:null},z=this._evaluateMove(r,o,f,p,w,v,_);if(!z.allowed)return this._rejectMove(z.reason,{ids:n,records:r,from:a,to:w,column:f,swimlane:p,evaluation:z}),this;let C=[];for(let F=0;F<n.length;F+=1){let st=r[F],bt=i.moveMode==="local"?this._localMovedRecord(st,o[F],w,f,p):st;if(!bt)return this._rejectMove("grouping",{ids:n,records:r,from:a,to:w,column:f,swimlane:p}),this;C.push({id:n[F],record:bt})}let k=Gr(this._viewData,C,{recordId:i.recordId,columnBy:(F,st)=>this._readAxis(i.columnBy,F,st),swimlaneBy:i.swimlaneBy==null?null:(F,st)=>this._readAxis(i.swimlaneBy,F,st),destination:w});if(!k)return this._rejectMove("destination",{ids:n,records:r,from:a,to:w,column:f,swimlane:p}),this;let M=this._wipAnnouncement(z);return this.emit("recordmove",{record:r[0],id:n[0],records:[...r],ids:[...n],moves:k.moves.map(F=>({id:F.id,from:{...F.from}})),from:{...a},to:{...k.to},column:{...f},swimlane:p?{...p}:null,limitExceeded:z.limitExceeded},{honorDomCancellation:!0}).defaultPrevented?(this._announce(this._text("moveCanceled",{name:this._movingName(r)})),this):i.moveMode==="external"?(this._announce(this._text("moveRequested",{name:this._movingName(r),target:this._targetName(k.to),wip:M})),this):(this._commitLocalRecords(k.records),this._announce(n.length>1?this._text("movedMultiple",{count:n.length,target:this._targetName(k.to),wip:M}):this._text("moved",{name:this._recordName(C[0].record,k.to.index),target:this._targetName(k.to),wip:M})),queueMicrotask(()=>this._moveHandle(n[0])?.focus()),this)}canUndo(){return this._kanbanOptions().history!==!1&&this._kanbanHistory.canUndo()}canRedo(){return this._kanbanOptions().history!==!1&&this._kanbanHistory.canRedo()}undo(){return this._travelHistory("undo")}redo(){return this._travelHistory("redo")}clearHistory(){return this._kanbanHistory.clear(),this._syncHistoryControls(),this._emitHistory(),this}getSearch(){return this._kanbanSearch}setSearch(t,e={}){let i=t==null?"":String(t);return i===this._kanbanSearch?this:(this._kanbanSearch=i,this._searchInput&&this._searchInput.value!==i&&(this._searchInput.value=i),this._refreshView("search"),e.silent||this.emit("searchchange",{search:i}),this)}setFilter(t){if(t!=null&&typeof t!="function")throw new TypeError("Kanban filter must be a function or null");return this._kanbanFilter=t??null,this._refreshView("filter"),this}getVisibleRecords(){return this._viewData.filter(t=>this._visibleIds.has(this._viewRecordId(t)))}setData(t){return this._resetHistory(),super.setData(t)}addData(t){return this._resetHistory(),super.addData(t)}updateRecord(t,e){return this._resetHistory(),super.updateRecord(t,e)}removeRecord(t){return this._resetHistory(),super.removeRecord(t)}getViewState(){this.getColumnOrder(),this.getSwimlaneOrder();let t=this._kanbanColumns===null,e=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return{...super.getViewState(),columnOrder:t?[...this._kanbanColumnOrder]:this.getColumnOrder(),swimlaneOrder:e?[...this._kanbanSwimlaneOrder]:this.getSwimlaneOrder(),collapsedColumns:t?[...this._collapsedColumns]:this.getCollapsedColumns(),collapsedSwimlanes:e?[...this._collapsedSwimlanes]:this.getCollapsedSwimlanes()}}setViewState(t,e={}){let i=t&&typeof t=="object"?t:{};super.setViewState(i,{silent:!0});let n=this._rawColumns(),r=this._rawSwimlanes(),o=this._kanbanColumns===null,a=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;this._kanbanColumnOrder=Li(n,Array.isArray(i.columnOrder)?i.columnOrder:this._kanbanColumnOrder,o),this._kanbanSwimlaneOrder=Li(r,Array.isArray(i.swimlaneOrder)?i.swimlaneOrder:this._kanbanSwimlaneOrder,a);let c=new Set(n.map(u=>u.id)),d=new Set(r.map(u=>u.id));if(Array.isArray(i.collapsedColumns)){let u=Bt(i.collapsedColumns);this._collapsedColumns=new Set(o?u:u.filter(h=>c.has(h)))}if(Array.isArray(i.collapsedSwimlanes)){let u=Bt(i.collapsedSwimlanes);this._collapsedSwimlanes=new Set(a?u:u.filter(h=>d.has(h)))}return this._refreshView("state"),e.silent||this._emitKanbanState("restore"),this}destroy(){if(this._kanbanDestroyed)return;this._kanbanDestroyed=!0,this._clearDrag(),clearTimeout(this._pointerHold),clearTimeout(this._searchTimer),this._kanbanMenu?.destroy(),this._kanbanMenu=null;let t=this.el,e=this._kanbanSnapshot;super.destroy(),e&&t&&S(t,e)}_refreshView(t){if(!this._board)return;if(t==="selection"){this._syncCardSelection();return}if(t==="loading")return;let e=this._kanbanOptions(),i=document.activeElement,n=this._metaForTarget(document.activeElement),r=!!document.activeElement?.classList?.contains("zx-kanban-view__move-handle"),o=i instanceof Element?i.closest("[data-kanban-collapse]"):null,a=o?.closest(".zx-kanban-view__column"),c=o&&this._board.contains(o)?{axis:o.dataset.kanbanCollapse,id:String(o.dataset.kanbanId),lane:a?this._sectionMeta.get(a)?.lane??null:null}:null;this._fieldIndex=null,this._cardFields=null;let d=this._resolvedColumns(),u=this._resolvedSwimlanes();this._resolveCardSources(),this._cardMeta=new WeakMap,this._sectionMeta=new WeakMap,this._cardsById=new Map,this._resolveVisibility();let h=[];e.swimlaneBy==null?h.push(this._renderColumns(d,null,!1)):u.forEach(f=>h.push(this._renderLane(f,d))),this._viewData.length?this._visibleIds.size||h.push(this._emptyContent(this._text("noMatches"))):h.push(this._emptyContent(this._text("empty"))),this._board.replaceChildren(...h),this._keyboardMove&&(this._keyboardMove.ids=this._keyboardMove.ids.filter(f=>this.getRecord(f)),this._keyboardMove.ids.length||(this._keyboardMove=null)),this._syncKeyboardTarget(),(c||n)&&queueMicrotask(()=>{if(c){this._collapseControl(c.axis,c.id,c.lane)?.focus();return}if(!n)return;if(n.lane!=null&&this._collapsedSwimlanes.has(n.lane)){this._collapseControl("swimlane",n.lane)?.focus();return}if(this._collapsedColumns.has(n.column)){this._collapseControl("column",n.column,n.lane)?.focus();return}let f=this._cardsById.get(n.id),p=r?f?.querySelector(".zx-kanban-view__move-handle"):f;p?.isConnected&&p.focus()})}_renderLane(t,e){let i=this._kanbanOptions(),n=this._collapsedSwimlanes.has(t.id),r=x("zx-kanban-lane"),o=x("zx-kanban-lane-body"),a=this._viewData.filter((g,w)=>W(this._readAxis(i.swimlaneBy,g,w))===t.id),c=a.length,d=a.filter(g=>this._visibleIds.has(this._viewRecordId(g))).length,u=l("button",{class:"zx-kanban-view__collapse",type:"button",ariaExpanded:String(!n),ariaControls:o,ariaLabel:this._text(n?"expandLane":"collapseLane",{label:t.label}),dataset:{kanbanCollapse:"swimlane",kanbanId:t.id}},b(n?"chevron-right":"chevron-down",{size:13})),h=t.limit??null,f=Ef(c,h),p=this._renderHook("renderSwimlaneHeader",{swimlane:{...t},count:d,total:c,columnTotal:c,limit:h,wip:f,collapsed:n}),_=l("h2",{class:"zx-kanban-view__lane-heading",id:r},u,p??[l("span",{},t.label),i.showCounts||h!=null?this._countIndicator(d,c,h):null]),m=this._renderColumns(e,t,!0);return m.id=o,m.hidden=n,l("section",{class:"zx-kanban-view__lane",ariaLabelledby:r,dataset:{collapsed:String(n),wip:f}},_,m)}_renderColumns(t,e,i){let n=this._kanbanOptions(),r=l("div",{class:"zx-kanban-view__columns"});for(let o of t){let a=this._recordsIn(o.id,e?.id??null);!n.showEmptyColumns&&a.length===0||r.append(this._renderColumn(o,e,a,i))}return r}_renderColumn(t,e,i,n){let r=this._kanbanOptions(),o=this._collapsedColumns.has(t.id),a=x("zx-kanban-column"),c=x("zx-kanban-column-list"),u=this._viewData.filter((M,it)=>W(this._readAxis(r.columnBy,M,it))===t.id).length,h=i.filter(M=>this._visibleIds.has(this._viewRecordId(M.record))),f=e?Px(t,e.id):null,p=f??t.limit??null,_=Ef(f==null?u:i.length,p),m=l("button",{class:"zx-kanban-view__collapse",type:"button",ariaExpanded:String(!o),ariaControls:c,ariaLabel:this._text(o?"expandColumn":"collapseColumn",{label:t.label}),dataset:{kanbanCollapse:"column",kanbanId:t.id}},b(o?"chevron-right":"chevron-down",{size:13})),g=this._renderHook("renderColumnHeader",{column:{...t},swimlane:e?{...e}:null,count:h.length,total:i.length,columnTotal:u,limit:p,wip:_,collapsed:o}),w=r.showCounts||p!=null?this._columnIndicator(h.length,i.length,u,p,n&&f==null):null,v=l(n?"h3":"h2",{class:"zx-kanban-view__column-heading",id:a},m,g??[l("span",{class:"zx-kanban-view__column-label"},t.label),w]),z=l("ul",{class:"zx-kanban-view__cards",id:c,ariaLabel:`${t.label}${e?`, ${e.label}`:""}`});if(h.forEach(M=>z.append(this._renderCard(M.record,M.index,t.id,e?.id??null,n))),!h.length){let M=this._renderHook("renderColumnEmpty",{column:{...t},swimlane:e?{...e}:null,count:0,total:i.length,columnTotal:u,limit:p,wip:_,collapsed:o})??this._placeholderText();M&&z.append(l("li",{class:"zx-kanban-view__column-empty",role:"presentation"},M))}z.hidden=o;let C=this._allowsAdd(t,e)?l("button",{class:"zx-kanban-view__add",type:"button",ariaLabel:this._text("addTo",{target:`${t.label}${e?`, ${e.label}`:""}`}),dataset:{kanbanAdd:t.id,kanbanLane:e?.id??""}},b("plus",{size:13}),l("span",{},this._text("add"))):null;C&&(C.hidden=o);let k=l("section",{class:"zx-kanban-view__column",ariaLabelledby:a,dataset:{column:t.id,collapsed:String(o),wip:_}},v,z,C);return this._sectionMeta.set(k,{column:t.id,lane:e?.id??null,list:z}),k}_renderCard(t,e,i,n,r){let o=this._kanbanOptions(),a=this._viewRecordId(t),c=!!this._keyboardMove?.ids.some(g=>Object.is(g,a)),d=Ms(this._kanbanRules,t,{index:e,column:i,lane:n}),u=c&&this._keyboardMove?this._keyboardMove.ids.length:1,h=o.moveHandle==="always"||o.dragFrom==="handle"?"always":"keyboard",f=l("button",{class:"zx-kanban-view__move-handle",type:"button",ariaPressed:String(c),dataset:{reveal:h},ariaLabel:u>1?this._text("moveMultiple",{count:u}):this._text("move",{name:this._recordName(t,e)})},b("drag",{size:13})),p=this._resolvedCardFields(),_=Or(t,e,{fields:p.all,visibleFields:p.metadata,titleField:o.titleField,subtitleField:o.subtitleField,preview:o.preview??void 0,previewAlt:o.previewAlt,link:o.link??void 0,actions:o.actions,selectable:o.selectable,selectionTrigger:o.selectionTrigger,selected:this._isViewSelected(a),variant:o.variant,headingLevel:r?4:3,controls:[f]});_.tabIndex=0,c&&(_.dataset.grabbed="true"),this._applyCardContent(_,{record:t,id:a,index:e,column:i,lane:n,rules:d,selected:this._isViewSelected(a)}),this._applyCardRules(_,d),this._applyCardAnatomy(_,t,e),this._applyCardDescription(_,a);let m={record:t,id:a,index:e,column:i,lane:n};return this._cardMeta.set(_,m),this._cardsById.set(a,_),_}_resolvedCardFields(){return this._cardFields||(this._cardFields={all:this.getFields(),metadata:this._cardMetadataFields()}),this._cardFields}_cardMetadataFields(){let t=this._cardSources?.fieldIds,e=this.getVisibleFields();return t?.size?e.filter(i=>!t.has(i.id)||i.duplicate===!0):e}_resolveCardSources(){let t=this._kanbanOptions(),e=this.getFields(),i=new Set,n=o=>{if(o==null)return null;if(typeof o=="function")return o;if(typeof o=="object")return()=>o;let a=String(o),c=e.find(d=>d.id===a);return i.add(a),c?(d,u)=>Z(c,d,u):d=>d?.[a]},r={identifier:n(t.identifier),status:n(t.status),priority:n(t.priority),progress:n(t.progress),assignees:n(t.assignees),entityIcon:typeof t.entityIcon=="function"?t.entityIcon:t.entityIcon==null?null:()=>t.entityIcon};this._cardSources={...r,fieldIds:i,any:Object.values(r).some(Boolean)}}_applyCardAnatomy(t,e,i){let n=this._kanbanOptions(),r=this._cardSources;if(!r?.any)return;let o=t.querySelector(".zx-record-card__body");if(!o)return;let a=r.entityIcon?.(e,i),c=r.identifier?.(e,i),d=Hr({entityIcon:a==null||a===""?null:String(a),identifier:c==null?"":String(c),identifierPrefix:this._text("identifier"),flags:[{indicator:this._cardIndicator(r.status,n.statusTones,e,i),prefix:this._text("statusLabel")},{indicator:this._cardIndicator(r.priority,n.priorityTones,e,i),prefix:this._text("priorityLabel")}]});d&&o.prepend(d);let u=[],h=Pr(r.progress?.(e,i),Number(n.progressMax));h&&u.push(Br(h,h.label??this._text("progress"),this._text("progressValue",{percent:h.percent})));let f=Vr(r.assignees?.(e,i)),p=jr(f,Number(n.maxAvatars),this._text("assignees",{names:f.map(_=>_.name).filter(Boolean).join(", ")}),_=>this._text("assigneeOverflow",{count:_}));p&&u.push(p),u.length&&o.append(l("div",{class:"zx-kanban-view__card-footer"},u))}_cardIndicator(t,e,i,n){if(!t)return null;let r=t(i,n);return r&&typeof r=="object"&&"nodeType"in r?r:Rr(r,e??{})}_applyCardContent(t,e){let i=this._renderHook("renderCard",e);if(!i)return;let n=t.querySelector(".zx-record-card__body"),r=t.querySelector(".zx-record-card__titles");!n||!r||(r.replaceChildren(i),n.querySelector(".zx-record-card__eyebrow")?.remove(),n.querySelector(".zx-record-card__metadata")?.remove(),t.removeAttribute("aria-labelledby"),t.setAttribute("aria-label",this._recordName(e.record,e.index)),t.dataset.customCard="true")}_applyCardRules(t,e){if(!e.length)return;t.dataset.rule=e.map(r=>r.id).join(" "),t.dataset.ruleTone=e[0].tone;let i=e.filter(r=>r.label);if(i.length){let r=l("p",{class:"zx-kanban-view__rules"},i.map(o=>ht({label:o.label,icon:o.icon??void 0,kind:o.tone,size:"sm",variant:"soft"})));t.querySelector(".zx-record-card__body")?.append(r)}let n=e.map(r=>r.description).filter(Boolean).join(". ");n&&(t.dataset.ruleDescription=n)}_applyCardDescription(t,e){let i=[];this.options.selectable&&i.push(this._text(this._isViewSelected(e)?"selected":"notSelected")),t.dataset.ruleDescription&&i.push(t.dataset.ruleDescription),i.length?t.setAttribute("aria-description",i.join(". ")):t.removeAttribute("aria-description")}_emptyContent(t){let i=(typeof this.options.emptyText=="function"?this.options.emptyText():this.options.emptyText)??t;return l("div",{class:"zx-kanban-view__empty",role:"status"},i&&typeof i=="object"&&"nodeType"in i?i:String(i))}_placeholderText(){return this._text("columnEmpty")}_countIndicator(t,e,i){let n=t!==e;return l("span",{class:"zx-kanban-view__count",ariaLabel:i!=null?this._text("countLimit",{count:e,limit:i}):n?this._text("countFiltered",{count:t,total:e}):this._text("count",{count:t})},i!=null?`${e} / ${i}`:n?`${t} / ${e}`:String(t))}_columnIndicator(t,e,i,n,r){let o=t!==e,a=n==null?o?this._text("countFiltered",{count:t,total:e}):this._text("count",{count:t}):r?this._text("countLimitInLane",{count:e,total:i,limit:n}):this._text("countLimit",{count:e,limit:n}),c=n==null?o?`${t} / ${e}`:String(t):r?`${e} \xB7 ${i} / ${n}`:`${e} / ${n}`;return l("span",{class:"zx-kanban-view__count",ariaLabel:a},c)}_rawColumns(){let t=this._kanbanOptions();return this._kanbanColumns===null?If(this._viewData,(e,i)=>this._readAxis(t.columnBy,e,i)):this._kanbanColumns.map(e=>({...e}))}_resolvedColumns(){let t=this._rawColumns();return this._kanbanColumnOrder=Li(t,this._kanbanColumnOrder,this._kanbanColumns===null),Df(t,this._kanbanColumnOrder)}_rawSwimlanes(){let t=this._kanbanOptions();return t.swimlaneBy==null?[]:this._kanbanSwimlanes===null?If(this._viewData,(e,i)=>this._readAxis(t.swimlaneBy,e,i)):this._kanbanSwimlanes.map(e=>({...e}))}_resolvedSwimlanes(){let t=this._rawSwimlanes(),e=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=Li(t,this._kanbanSwimlaneOrder,e),Df(t,this._kanbanSwimlaneOrder)}_readAxis(t,e,i){if(typeof t=="function")return t(e,i);if(t==null)return null;let n=this._axisField(String(t));return n?Z(n,e,i):e?.[t]}_axisField(t){return this._fieldIndex||(this._fieldIndex=new Map(this.getFields().map(e=>[e.id,e]))),this._fieldIndex.get(t)}_recordsIn(t,e){let i=this._kanbanOptions(),n=[];return this._viewData.forEach((r,o)=>{W(this._readAxis(i.columnBy,r,o))===t&&(i.swimlaneBy!=null&&W(this._readAxis(i.swimlaneBy,r,o))!==e||n.push({record:r,index:o}))}),n}_recordLocation(t){let e=this._kanbanOptions(),i=this._viewData.findIndex(n=>Object.is(this._viewRecordId(n),t));return i<0?null:Ns(this._viewData,i,{recordId:e.recordId,columnBy:(n,r)=>this._readAxis(e.columnBy,n,r),swimlaneBy:e.swimlaneBy==null?null:(n,r)=>this._readAxis(e.swimlaneBy,n,r)})}_resolveVisibility(){let t=Kr(this._kanbanSearch),e=this._kanbanFilter,i=t.length?this._searchSources():null;this._visibleIds=new Set,this._viewData.forEach((n,r)=>{e&&e(n,r)!==!0||i&&!Ur(this._searchableText(n,r,i),t)||this._visibleIds.add(this._viewRecordId(n))})}_searchSources(){let t=this._kanbanOptions(),e=Array.isArray(t.searchFields)?t.searchFields.map(String):null,i=this.getFields();if(e)return{fields:i.filter(a=>e.includes(a.id)),readers:[]};let n=this.getVisibleFields(),r=new Set(n.map(a=>a.id)),o=[];for(let a of[t.titleField,t.subtitleField]){if(a==null)continue;if(typeof a=="function"){o.push(a);continue}if(r.has(a))continue;let c=i.find(d=>d.id===a);c?n.push(c):o.push(d=>d?.[a])}return{fields:n,readers:o}}_searchableText(t,e,i){let n=i.fields.map(r=>Mf(Z(r,t,e)));for(let r of i.readers)n.push(Mf(r(t,e)));return n.filter(Boolean).join(" ")}_absoluteIndex(t,e,i,n){let r=this._recordsIn(t,e).filter(o=>!n.has(this._viewRecordId(o.record)));return Wr(r.map(o=>this._visibleIds.has(this._viewRecordId(o.record))),i)}_localMovedRecord(t,e,i,n,r){let o=this._kanbanOptions(),a={...t};if(e.column!==i.column){if(typeof o.columnBy!="string")return null;a[o.columnBy]=Object.prototype.hasOwnProperty.call(n,"value")?n.value:n.id}if(e.lane!==i.lane){if(typeof o.swimlaneBy!="string"||!r)return null;a[o.swimlaneBy]=Object.prototype.hasOwnProperty.call(r,"value")?r.value:r.id}let c=this._viewData.indexOf(t);return W(this._readAxis(o.columnBy,a,c))!==i.column||o.swimlaneBy!=null&&W(this._readAxis(o.swimlaneBy,a,c))!==i.lane?null:a}_evaluateMove(t,e,i,n,r,o,a){let c=this._kanbanOptions();for(let p of e){let _=Ds(i,n,p);if(_)return{allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:i.wipPolicy??(c.wipPolicy==="block"?"block":"warn")}}let d=p=>!a.has(this._viewRecordId(p)),u=this._viewData.filter((p,_)=>W(this._readAxis(c.columnBy,p,_))===r.column&&d(p)).length,h=c.swimlaneBy==null?0:this._viewData.filter((p,_)=>W(this._readAxis(c.swimlaneBy,p,_))===r.lane&&d(p)).length,f=this._recordsIn(r.column,r.lane).filter(p=>d(p.record)).length;return $r({records:t,column:i,swimlane:n,context:o,from:e[0],columnCount:u,laneCount:h,cellCount:f,policy:c.wipPolicy==="block"?"block":"warn"})}_rejectMove(t,e){let i=e.to?this._targetName(e.to):"",n=this._movingName(e.records),r=t==="destination"?this._text("rejectDestination"):t==="grouping"?this._text("rejectGrouping"):t==="transition"||t==="lane-transition"?this._text("rejectTransition",{target:i,origin:e.from?this._targetName(e.from):""}):t==="wip"||t==="lane-wip"?this._text("rejectWip",{target:i,limit:e.evaluation?.limit??""}):this._text("rejectAccept",{target:i,name:n});this._announce(r),this.emit("movereject",{reason:t,ids:[...e.ids],records:[...e.records],record:e.records[0]??null,id:e.ids[0],from:e.from?{...e.from}:null,to:e.to?{...e.to}:null,column:e.column?{...e.column}:null,swimlane:e.swimlane?{...e.swimlane}:null,limit:e.evaluation?.limit??null,count:e.evaluation?.count??0,message:r})}_commitLocalRecords(t){let e=this._kanbanOptions();e.history!==!1&&(this._kanbanHistory.push({records:[...this._viewData],selection:this.getSelectionIds()}),this._syncHistoryControls()),this._viewData=t,e.sortMode==="local"&&this.getSort()?this.setSort(null):this._refreshView("move"),this.emit("datachange",{records:this.getData()}),e.history!==!1&&this._emitHistory()}_travelHistory(t){if(this._kanbanOptions().history===!1)return this;let e={records:[...this._viewData],selection:this.getSelectionIds()},i=t==="undo"?this._kanbanHistory.undo(e):this._kanbanHistory.redo(e);return i?(this._viewData=[...i.records],this._refreshView(t),this.setSelection(i.selection),this._syncHistoryControls(),this.emit("datachange",{records:this.getData()}),this._emitHistory(),this._announce(this._text(t==="undo"?"undone":"redone")),this):(this._announce(this._text(t==="undo"?"nothingToUndo":"nothingToRedo")),this)}_resetHistory(){if(!this._kanbanHistory)return;let t=this._kanbanHistory.canUndo()||this._kanbanHistory.canRedo();this._kanbanHistory.clear(),this._syncHistoryControls(),t&&this._emitHistory()}_emitHistory(){this.emit("historychange",{canUndo:this.canUndo(),canRedo:this.canRedo(),depth:this._kanbanHistory.depth()})}_syncHistoryControls(){this._undoButton&&(this._undoButton.disabled=!this.canUndo()),this._redoButton&&(this._redoButton.disabled=!this.canRedo())}_createSearchControl(){let t=l("input",{class:"zx-kanban-view__search-input",type:"search",value:this._kanbanSearch,ariaLabel:this._text("search"),placeholder:this._text("searchPlaceholder")});return this._searchInput=t,this.listen(t,"input",()=>{clearTimeout(this._searchTimer),this._searchTimer=setTimeout(()=>{this._searchTimer=0,this._kanbanDestroyed||this.setSearch(t.value)},Fx)}),this.listen(t,"keydown",e=>{e.key!=="Escape"||!t.value||(e.stopPropagation(),clearTimeout(this._searchTimer),this._searchTimer=0,this.setSearch(""))}),l("div",{class:"zx-kanban-view__search"},b("search",{size:13}),t)}_createHistoryControls(){this._undoButton=l("button",{class:"zx-btn",type:"button",disabled:!0,dataset:{kanbanHistory:"undo",size:"sm",kind:"ghost"}},this._text("undo")),this._redoButton=l("button",{class:"zx-btn",type:"button",disabled:!0,dataset:{kanbanHistory:"redo",size:"sm",kind:"ghost"}},this._text("redo"));let t=l("div",{class:"zx-kanban-view__history",role:"group"},this._undoButton,this._redoButton);return this.listen(t,"click",e=>{let i=e.target?.closest?.("[data-kanban-history]");i&&(i.dataset.kanbanHistory==="undo"?this.undo():this.redo())}),t}_createContextMenu(){this._kanbanMenu=new Di(this._board,{selector:".zx-record-card",items:t=>this._menuItems(t),onselect:({detail:t})=>this._handleMenuSelect(t)})}_menuItems(t){let e=t?this._cardMeta.get(t):null;if(!e)return[];let i=this._kanbanOptions(),n=this._movingIds(e.id),r=[];for(let a of this._resolvedColumns())a.id!==e.column&&r.push({label:this._text("menuMoveTo",{target:a.label}),value:{kind:"column",id:a.id,ids:n},disabled:!this._canMove(n,{column:a.id})});if(i.swimlaneBy!=null)for(let a of this._resolvedSwimlanes())a.id!==e.lane&&r.push({label:this._text("menuMoveToLane",{target:a.label}),value:{kind:"lane",id:a.id,ids:n},disabled:!this._canMove(n,{lane:a.id})});let o=typeof i.contextMenu=="function"?i.contextMenu({record:e.record,id:e.id,index:e.index,column:e.column,lane:e.lane,rules:Ms(this._kanbanRules,e.record,e),selected:this._isViewSelected(e.id)}):Array.isArray(i.contextMenu)?i.contextMenu:[];return Array.isArray(o)&&o.length&&r.push("-",...o),r}_handleMenuSelect(t){let e=t.value;!e||typeof e!="object"||!e.kind||!Array.isArray(e.ids)||this.moveRecords(e.ids,e.kind==="lane"?{lane:e.id}:{column:e.id})}_canMove(t,e){let i=this._kanbanOptions(),n=this._orderedIds(t);if(!n.length)return!1;let r=n.map(m=>this.getRecord(m)),o=n.map(m=>this._recordLocation(m)),a=o[0],c=e.column==null?a.column:String(e.column),d=i.swimlaneBy==null?null:e.lane===void 0?a.lane:W(e.lane),u=this._resolvedColumns().find(m=>m.id===c),h=i.swimlaneBy==null?null:this._resolvedSwimlanes().find(m=>m.id===d)??null;if(!u||i.swimlaneBy!=null&&!h)return!1;let f=new Set(n),p={column:c,lane:d,index:0},_={id:n[0],from:{...a},to:{...p},column:{...u},swimlane:h?{...h}:null};return this._evaluateMove(r,o,u,h,p,_,f).allowed}_movingIds(t){let e=this._kanbanOptions();if(e.multiMove===!1||e.selectable!=="multi"||!this._isViewSelected(t))return[t];let i=this.getSelectionIds();return i.length>1?i:[t]}_orderedIds(t){let e=new Set(t);return this._viewData.map(i=>this._viewRecordId(i)).filter(i=>e.has(i))}_handleBoardClick(t){if(this._suppressClick){this._suppressClick=!1;return}let e=Ri(t),i=e?.closest("[data-kanban-collapse]");if(i){let c=i;c.dataset.kanbanCollapse==="column"?this.toggleColumn(String(c.dataset.kanbanId)):this.toggleSwimlane(String(c.dataset.kanbanId));return}let n=e?.closest("[data-kanban-add]");if(n){let c=n,d=String(c.dataset.kanbanAdd),u=c.dataset.kanbanLane||null;this.emit("recordadd",{column:this._resolvedColumns().find(h=>h.id===d)??null,swimlane:u==null?null:this._resolvedSwimlanes().find(h=>h.id===u)??null,columnId:d,laneId:u,event:t});return}let r=this._metaForTarget(e);if(!r)return;let o=e?.closest("input[data-record-selection]");if(o){this.toggleSelection(r.id,{selected:o.checked,range:t.shiftKey});return}let a=e?.closest("[data-record-action]");if(a){let c=a.dataset.recordAction,d=Is(r.record,r.index,this._kanbanOptions().actions).find(h=>h.id===c);if(!d||d.disabled){t.preventDefault();return}typeof d.onclick=="function"&&d.onclick(r.record,r.index,t),this.emit("recordaction",{record:r.record,id:r.id,index:r.index,action:{...d},event:t}).defaultPrevented&&t.preventDefault();return}if(!e?.closest(".zx-kanban-view__move-handle, .zx-record-card__selection, [data-record-select]")&&!(e?.closest(Tl)||Rf())){if(this.options.selectable&&this._kanbanOptions().selectionTrigger==="card"){this.toggleSelection(r.id,{range:t.shiftKey}),e?.closest(".zx-record-card")?.focus({preventScroll:!0});return}this.emit("recordclick",{...r,event:t}),this.options.selectable==="single"&&!this._isViewSelected(r.id)&&this.setSelection([r.id])}}_handleBoardDoubleClick(t){let e=Ri(t),i=this._metaForTarget(e);!i||e?.closest(Tl)||Rf()||this.emit("recorddblclick",{...i,event:t})}_handleBoardKeydown(t){if(this._dragIds.length&&t.key==="Escape"){t.preventDefault(),this._clearDrag(),this._announce(this._text("moveCanceledPlain"));return}let e=Ri(t);if(this._handleHistoryKeydown(t,e))return;let i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i);if(i&&n){this._handleMoveKeydown(t,i,n);return}let r=e?.closest(".zx-record-card"),o=r?this._cardMeta.get(r):null;if(!(!o||e!==r))if(t.key==="Enter"){if(t.preventDefault(),this.options.selectable&&this._kanbanOptions().selectionTrigger==="card"){this.toggleSelection(o.id);return}this.emit("recordclick",{...o,event:t}),this.options.selectable==="single"&&this.setSelection([o.id])}else t.key===" "&&this.options.selectable!==!1&&(t.preventDefault(),this.toggleSelection(o.id))}_handleHistoryKeydown(t,e){if(this._kanbanOptions().history===!1||!(t.ctrlKey||t.metaKey)||e?.closest('input, textarea, [contenteditable="true"]'))return!1;let i=t.key.toLowerCase();return i==="z"&&!t.shiftKey&&this.canUndo()?(t.preventDefault(),this.undo(),!0):(i==="y"||i==="z"&&t.shiftKey)&&this.canRedo()?(t.preventDefault(),this.redo(),!0):!1}_handleMoveKeydown(t,e,i){if(t.key===" "||t.key==="Enter"){if(t.preventDefault(),this._keyboardMove?.ids.some(a=>Object.is(a,i.id))){let a=this._keyboardMove;this._keyboardMove=null,e.setAttribute("aria-pressed","false");let c=e.closest(".zx-record-card");c&&delete c.dataset.grabbed,this._syncKeyboardTarget(),this._commitInteractionMove(a.ids,a.to)}else{let a=this._recordLocation(i.id);if(!a)return;let c=this._movingIds(i.id),d={...a,index:this._visibleIndex(i.id)};this._keyboardMove={ids:c,from:{...a},to:d},e.setAttribute("aria-pressed","true");let u=e.closest(".zx-record-card");u&&(u.dataset.grabbed="true"),this._syncKeyboardTarget(),this._announce(c.length>1?this._text("grabbedMultiple",{count:c.length}):this._text("grabbed",{name:this._recordName(i.record,i.index)}))}return}if(t.key==="Escape"&&this._keyboardMove){t.preventDefault();let a=this._keyboardMove.ids.map(d=>this.getRecord(d)).filter(Boolean);this._keyboardMove=null,e.setAttribute("aria-pressed","false");let c=e.closest(".zx-record-card");c&&delete c.dataset.grabbed,this._syncKeyboardTarget(),this._announce(a.length?this._text("moveCanceled",{name:this._movingName(a)}):this._text("moveCanceledPlain"));return}if(!this._keyboardMove||!this._keyboardMove.ids.some(a=>Object.is(a,i.id))||!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let n=this._keyboardMove,r=t.altKey||t.ctrlKey||t.metaKey;if((t.key==="ArrowLeft"||t.key==="ArrowRight")&&!r){let a=this.getColumnOrder(),c=a.indexOf(n.to.column),d=a[c+(t.key==="ArrowLeft"?-1:1)];d!=null&&(n.to.column=d)}else if((t.key==="ArrowUp"||t.key==="ArrowDown")&&r&&this._kanbanOptions().swimlaneBy!=null){let a=this.getSwimlaneOrder(),c=a.indexOf(String(n.to.lane)),d=a[c+(t.key==="ArrowUp"?-1:1)];d!=null&&(n.to.lane=d)}else(t.key==="ArrowUp"||t.key==="ArrowDown")&&(n.to.index+=t.key==="ArrowUp"?-1:1);let o=this._visibleCount(n.to.column,n.to.lane,new Set(n.ids));n.to.index=Os(n.to.index,o),this._syncKeyboardTarget(),this._announce(this._text("target",{target:this._targetName(n.to),position:n.to.index+1,total:o+1}))}_handlePreviewError(t){let e=Ri(t)?.closest("img[data-record-preview]");if(!e)return;let i=e.closest(".zx-record-card__preview");i&&(i.dataset.failed="true"),e.hidden=!0}_handlePointerDown(t){if(this._suppressClick=!1,t.button!=null&&t.button!==0)return;let e=Ri(t),i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i??e);if(!n||!i&&(this._kanbanOptions().dragFrom!=="card"||e?.closest(Tl)||e?.closest(".zx-record-card__selection")))return;let r=this._movingIds(n.id);this._pointerStart={x:t.clientX,y:t.clientY,id:t.pointerId,ids:r,touch:t.pointerType==="touch"},this._dragPoint={x:t.clientX,y:t.clientY},clearTimeout(this._pointerHold),!(t.pointerType!=="touch"||i)&&(this._pointerHold=setTimeout(()=>this._beginDrag(this._dragPoint.x,this._dragPoint.y),Ox))}_handlePointerMove(t){let e=this._pointerStart;if(!this._dragIds.length){if(!e||t.pointerId!==e.id)return;let i=Math.hypot(t.clientX-e.x,t.clientY-e.y);if(this._dragPoint={x:t.clientX,y:t.clientY},i<=Nx)return;if(e.touch&&this._pointerHold){clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null;return}if(this._beginDrag(t.clientX,t.clientY),!this._dragIds.length)return}this._dragPointer!=null&&t.pointerId!==this._dragPointer||(t.preventDefault(),this._dragPoint={x:t.clientX,y:t.clientY},this._positionDragPreview(),this._updateDropTarget(t.clientX,t.clientY))}_handlePointerUp(t){if(this._dragIds.length&&this._dragPointer!=null&&t.pointerId!==this._dragPointer||(clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null,!this._dragIds.length))return;t.preventDefault();let e=[...this._dragIds],i=this._dragDestination?{...this._dragDestination}:null;this._clearDrag(),this._suppressClick=!0,i&&this._commitInteractionMove(e,i)}_beginDrag(t,e){let i=this._pointerStart;if(!(!i||this._dragIds.length)&&(this._pointerHold=0,this._dragIds=i.ids.filter(n=>this.getRecord(n)),!!this._dragIds.length)){this._dragPoint={x:t,y:e},this._board.dataset.dragging="true";for(let n of this._dragIds){let r=this._cardsById.get(n);r&&(r.dataset.dragging="true")}this._dragPointer=i.id;try{this._board.setPointerCapture(i.id),this._dragCaptured=!0}catch{}globalThis.getSelection?.()?.removeAllRanges(),this._dragPreview=this._createDragPreview(),this.el.append(this._dragPreview),this._positionDragPreview(),this._updateDropTarget(t,e),this._kanbanOptions().autoScroll!==!1&&this._scheduleAutoScroll()}}_createDragPreview(){let t=this._dragIds.map(n=>this.getRecord(n)),i=this._renderHook("renderDragPreview",{records:t,ids:[...this._dragIds],count:this._dragIds.length})??(this._dragIds.length>1?this._text("dragPreview",{count:this._dragIds.length}):this._movingName(t));return l("div",{class:"zx-kanban-view__drag-preview",ariaHidden:"true",dataset:{count:String(this._dragIds.length)}},i)}_positionDragPreview(){this._dragPreview&&(this._dragPreview.style.transform=`translate3d(${Math.round(this._dragPoint.x)}px, ${Math.round(this._dragPoint.y)}px, 0)`)}_updateDropTarget(t,e){let n=document.elementFromPoint(t,e)?.closest(".zx-kanban-view__column"),r=n&&this._board.contains(n)?this._sectionMeta.get(n):null;if(this._clearDropMarkers(),!r||this._collapsedColumns.has(r.column)){this._dragDestination=null;return}let o=this._draggableCards(r.list),a=o.findIndex(d=>{let u=d.getBoundingClientRect();return e<u.top+u.height/2}),c=a<0?o.length:a;o[c]?o[c].dataset.drop="before":o.length?o[o.length-1].dataset.drop="after":r.list.dataset.drop="append",this._dragDestination={column:r.column,lane:r.lane,index:c}}_scheduleAutoScroll(){this._dragFrame||(this._dragFrame=requestAnimationFrame(()=>{this._dragFrame=0,this._dragIds.length&&(this._autoScroll(),this._scheduleAutoScroll())}))}_autoScroll(){let{x:t,y:e}=this._dragPoint,i=this._board.getBoundingClientRect();t<i.left+Qr?this._board.scrollLeft-=Xr:t>i.right-Qr&&(this._board.scrollLeft+=Xr);let n=document.elementFromPoint(t,e)?.closest(".zx-kanban-view__cards");if(!n||!this._board.contains(n)||n.scrollHeight<=n.clientHeight)return;let r=n.getBoundingClientRect();e<r.top+Qr?n.scrollTop-=Xr:e>r.bottom-Qr&&(n.scrollTop+=Xr)}_commitInteractionMove(t,e){let i=new Set(t);this.moveRecords(t,{column:e.column,lane:e.lane,index:this._absoluteIndex(e.column,e.lane,e.index,i)})}_clearDrag(){if(this._dragFrame&&cancelAnimationFrame(this._dragFrame),this._dragFrame=0,clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null,this._dragPreview?.remove(),this._dragPreview=null,this._dragIds=[],this._dragDestination=null,this._board){if(this._dragCaptured&&this._dragPointer!=null)try{this._board.releasePointerCapture(this._dragPointer)}catch{}this._clearDropMarkers(),delete this._board.dataset.dragging;for(let t of this._board.querySelectorAll("[data-dragging]"))delete t.dataset.dragging}this._dragPointer=null,this._dragCaptured=!1}_clearDropMarkers(){for(let t of this._board.querySelectorAll("[data-drop]"))delete t.dataset.drop}_draggableCards(t){let e=new Set(this._dragIds.length?this._dragIds:this._keyboardMove?.ids??[]);return[...t.querySelectorAll(":scope > .zx-record-card")].filter(i=>!Lf(e,this._cardMeta.get(i)?.id))}_visibleCount(t,e,i){return this._recordsIn(t,e).filter(n=>{let r=this._viewRecordId(n.record);return!Lf(i,r)&&this._visibleIds.has(r)}).length}_visibleIndex(t){let e=this._recordLocation(t);if(!e)return 0;let i=this._recordsIn(e.column,e.lane).filter(r=>this._visibleIds.has(this._viewRecordId(r.record))),n=i.findIndex(r=>Object.is(this._viewRecordId(r.record),t));return n<0?i.length:n}_syncKeyboardTarget(){for(let o of this._board.querySelectorAll("[data-keyboard-target]"))delete o.dataset.keyboardTarget;let t=this._keyboardMove;if(!t)return;let e=[...this._board.querySelectorAll(".zx-kanban-view__column")].find(o=>{let a=this._sectionMeta.get(o);return a?.column===t.to.column&&a?.lane===t.to.lane}),i=e?this._sectionMeta.get(e):null;if(!i)return;let r=this._draggableCards(i.list)[t.to.index];r?r.dataset.keyboardTarget="before":i.list.dataset.keyboardTarget="append"}_syncCardSelection(){for(let[t,e]of this._cardsById){let i=this._isViewSelected(t);e.dataset.selected=String(i),this._applyCardDescription(e,t);let n=e.querySelector("[data-record-selection]");n&&(n.checked=i)}}_metaForTarget(t){let e=Ri({target:t})?.closest(".zx-record-card");return e?this._cardMeta.get(e)??null:null}_moveHandle(t){return this._cardsById.get(t)?.querySelector(".zx-kanban-view__move-handle")??null}_collapseControl(t,e,i=null){return[...this._board.querySelectorAll("[data-kanban-collapse]")].find(n=>{let r=n;if(r.dataset.kanbanCollapse!==t||r.dataset.kanbanId!==e)return!1;if(t!=="column")return!0;let o=r.closest(".zx-kanban-view__column");return o?this._sectionMeta.get(o)?.lane===i:!1})??null}_renderHook(t,e){let i=this._kanbanOptions()[t];if(typeof i!="function")return null;let n=i(e);return n&&typeof n=="object"&&"nodeType"in n?n:null}_allowsAdd(t,e){let i=this._kanbanOptions().allowAdd;return typeof i=="function"?i(t,e)===!0:i===!0}_recordName(t,e){let i=this._kanbanOptions().titleField,n=typeof i=="function"?i(t,e):typeof i=="string"?this._readAxis(i,t,e):this._viewRecordId(t);return n&&typeof n=="object"&&"nodeType"in n?n.textContent?.trim()||this._text("record"):String(n??this._text("record"))}_movingName(t){return t.length?t.length===1?this._recordName(t[0],this._viewData.indexOf(t[0])):this._text("dragPreview",{count:t.length}):this._text("record")}_targetName(t){let e=this._resolvedColumns().find(n=>n.id===t.column),i=t.lane==null?null:this._resolvedSwimlanes().find(n=>n.id===t.lane);return`${e?.label??t.column}${i?`, ${i.label}`:""}`}_wipAnnouncement(t){return t.limit==null?"":t.limitExceeded?this._text("limitExceeded",{limit:t.limit}):t.limitReached?this._text("limitReached",{limit:t.limit}):""}_text(t,e){let i=this._kanbanOptions().labels,n=i&&typeof i=="object"&&t in i?i[t]:Lx[t];return T(n==null?String(t):String(n),e)}_announce(t){let e=++this._announcementToken;this._live.textContent="",queueMicrotask(()=>{e===this._announcementToken&&this._live?.isConnected&&(this._live.textContent=t)})}_emitKanbanState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}_kanbanOptions(){return this.options}};function Jr(s,t="column"){if(!Array.isArray(s))throw new TypeError(`Kanban ${t}s must be an array or null`);let e=new Set;return s.map((i,n)=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`Kanban ${t} at index ${n} must be an object`);let r=i,o=String(r.id??"").trim();if(!o&&r.id!=="")throw new TypeError(`Kanban ${t} at index ${n} requires an id`);if(e.has(o))throw new TypeError(`Duplicate Kanban ${t}: ${o}`);if(r.accept!=null&&typeof r.accept!="function")throw new TypeError(`Kanban ${t} ${o} accept must be a function`);if(r.from!=null&&!Array.isArray(r.from))throw new TypeError(`Kanban ${t} ${o} from must be an array or null`);e.add(o);let a={...r,id:o,label:String(r.label??Pf(r.id)),limit:Bf(r.limit),from:Array.isArray(r.from)?r.from.map(String):null,...Object.prototype.hasOwnProperty.call(r,"value")?{}:{value:r.id}};if(t==="column"){let c=Rx(r.laneLimits);c&&(a.laneLimits=c),(r.wipPolicy==="block"||r.wipPolicy==="warn")&&(a.wipPolicy=r.wipPolicy)}else delete a.laneLimits,delete a.wipPolicy;return a})}function If(s,t){let e=[],i=new Set;return s.forEach((n,r)=>{let o=_e(n,r,t),a=W(o);i.has(a)||(i.add(a),e.push({id:a,label:Pf(o),value:o,limit:null}))}),e}function Il(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Bt(t).filter(r=>i.has(r));return[...new Set(n),...e.filter(r=>!n.includes(r))]}function Li(s,t,e=!1){if(!e)return Il(s,t);let i=Bt(t),n=s.map(r=>r.id);return[...i,...n.filter(r=>!i.includes(r))]}function Pf(s){return s==null||String(s).trim()===""?"Unassigned":String(s)}function Bf(s){if(s==null||s==="")return null;let t=Number(s);if(!Number.isFinite(t)||t<0)throw new TypeError("Kanban column limit must be a non-negative number");return Math.floor(t)}function Rx(s){if(s==null)return;if(typeof s!="object"||Array.isArray(s))throw new TypeError("Kanban column laneLimits must be an object");let t={};for(let[e,i]of Object.entries(s)){let n=Bf(i);n!=null&&(t[e]=n)}return t}function Px(s,t){let e=s.laneLimits;if(!e||typeof e!="object")return null;let i=e[t];return typeof i=="number"&&Number.isFinite(i)?i:null}function Ef(s,t){return t==null?"none":s>t?"exceeded":s===t?"limit":"within"}function Bt(s){return Array.isArray(s)?[...new Set(s.map(String))]:[]}function Mf(s){return s==null?"":typeof s=="object"?"nodeType"in s?String(s.textContent??""):"":String(s)}function Df(s,t){let e=new Map(s.map(i=>[i.id,i]));return t.map(i=>e.get(i)).filter(Boolean)}function Nf(s,t,e,i){let n=[...s],r=n.indexOf(String(t));if(r<0||!n.includes(String(e))||String(t)===String(e))return n;n.splice(r,1);let o=n.indexOf(String(e));return n.splice(o+(i==="after"?1:0),0,String(t)),n}function Of(s,t,e,i){if(!i)return[...e];let n=new Set(t.map(c=>c.id)),r=[...e],o=0,a=Bt(s).flatMap(c=>n.has(c)?o<r.length?[r[o++]]:[]:[c]);return a.push(...r.slice(o)),Bt(a)}function Bx(s,t){return s.column===t.column&&s.lane===t.lane&&s.index===t.index}function Ff(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Lf(s,t){for(let e of s)if(Object.is(e,t))return!0;return!1}function Ri(s){let t=s.target;return t?t instanceof Element?t:t.parentElement:null}function Rf(){let s=globalThis.getSelection?.();return!!(s&&!s.isCollapsed&&String(s).trim())}var to=class s extends Ft{static cssName="table";constructor(t=null,e={}){super(t,{editTrigger:"single",...e})}static BillingItems(t,e={}){let i=new s(t,Vx(e));return i.el.dataset.preset="billing-items",i}};function Vx(s={}){let{fields:t={},units:e=[],currencies:i=[],currency:n="EUR",locale:r,decimals:o=2,columnOverrides:a={},lineTotal:c=null,columns:d,oneditcommit:u,rowClass:h,...f}=s,p={...Hf,...t},_=typeof c=="function"?c:g=>{let w=jf(g?.[p.quantity]),v=jf(g?.[p.unitPrice]);return w!==null&&v!==null?w*v:null},m=Array.isArray(d)?d.map(g=>({...g})):El(p,{units:e,currencies:i,currency:n,locale:r,decimals:o,columnOverrides:a});return{rowId:p.id,editMode:"cell",editTrigger:"single",rowReorder:!0,columnVisibility:!0,hierarchy:{parentId:p.parent,column:p.item,expanded:!0},responsive:"sm",...f,columns:m,rowClass(g){let w=Fs(g,p)?"":"zx-grid-billing__summary",v=typeof h=="function"?h(g):"";return[w,v].filter(Boolean).join(" ")},oneditcommit(g){let{row:w,changes:v}=g.detail;if(Fs(w,p)){let z={...w,...v},C=_(z,v);C!=null&&Number.isFinite(Number(C))&&(v[p.total]=Number(C))}u?.(g)}}}var Hf=Object.freeze({id:"id",parent:"parent",item:"item",kind:"kind",quantity:"quantity",unit:"unit",unitPrice:"unitPrice",currency:"currency",total:"total"});function Fs(s,t=Hf){let e=String(s?.[t.kind]??"line").toLowerCase();return!["group","subtotal","header","section"].includes(e)}function El(s,{units:t,currencies:e,currency:i,locale:n,decimals:r,columnOverrides:o}){let a=h=>f=>Fs(f,s)?h:!1,c=h=>String(h?.[s.currency]||i),d=h=>String(h?.[s.unit]??""),u={item:{id:s.item,label:"Item",width:"2fr",sortable:!0,editable:a("text")},quantity:{id:s.quantity,label:"Quantity",width:"1fr",type:"unit",locale:n,unit:d,editable:a("number"),editorProps:{min:0,step:.01}},unit:{id:s.unit,label:"Unit",width:".8fr",editable:a(Vf(t)?"select":"text"),options:t},unitPrice:{id:s.unitPrice,label:"Unit price",width:"1fr",type:"currency",locale:n,decimals:r,currency:c,editable:a("number"),editorProps:{min:0,step:.01}},currency:{id:s.currency,label:"Currency",width:".8fr",editable:a(Vf(e)?"select":"text"),options:e},total:{id:s.total,label:"Line total",width:"1fr",type:"currency",locale:n,decimals:r,currency:c}};return Object.entries(u).map(([h,f])=>({...f,...o?.[h]??{}}))}function Vf(s){return Array.isArray(s)?s.length>0:!!(s&&typeof s=="object"&&Object.keys(s).length)}function jf(s){if(s==null||typeof s=="string"&&s.trim()==="")return null;let t=Number(s);return Number.isFinite(t)?t:null}var eo=class extends y{static cssName="chart";static defaults={adapter:null,type:"bar",data:{labels:[],datasets:[]},chartOptions:{},label:"Chart",description:"",summary:"hidden",loading:!1,emptyText:"No chart data",loadingText:"Loading chart\u2026",errorText:"Unable to render chart",aspectRatio:"16 / 9"};constructor(t=null,e={}){super(t,e),this._mountOrUpdate(!1)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,c=>[c.name,c.value]),children:Array.from(t.childNodes)},this._adapter=this.options.adapter,this._type=String(this.options.type||"bar"),this._data=$f(this.options.data),this._label=jx(this.options.label),this._chartOptions=Ct(this.options.chartOptions),this._loading=!!this.options.loading,this._error=null,this._hasError=!1,this._handle=null,this._destroyed=!1;let e=x("zx-chart-description"),i=l("canvas",{ref:"canvas",class:"zx-chart__canvas",role:"img",ariaLabel:this._label,ariaDescribedby:e}),n=l("div",{ref:"viewport",class:"zx-chart__viewport"},i);n.style.setProperty("--zx-chart-aspect-ratio",String(this.options.aspectRatio));let r=l("p",{ref:"description",class:"zx-chart__description",id:e},this.options.description),o=l("div",{ref:"status",class:"zx-chart__status",role:"status",ariaLive:"polite"}),a=l("div",{ref:"summary",class:"zx-chart__summary",dataset:{summary:this.options.summary==="visible"?"visible":"hidden"}});return t.replaceChildren(n,r,o,a),this._renderSummary(),this._syncState(),this._observer=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.resize()):null,this._observer?.observe(n),this._stopWatchingMotion=wn(t,()=>this._mountOrUpdate(!1)),t}setData(t){return this._data=$f(t),this._error=null,this._hasError=!1,this._loading=!1,this._renderSummary(),this._mountOrUpdate(!0),this}setType(t){return this._type=String(t||"bar"),this._mountOrUpdate(!0),this}update(t){return this._chartOptions=Ct(t&&typeof t=="object"?t:{}),this._mountOrUpdate(!0),this}setAdapter(t){return this._destroyHandle(),this._adapter=t,this._mountOrUpdate(!1),this}setLoading(t=!0){return this._loading=!!t,this._loading?this._destroyHandle():this._mountOrUpdate(!1),this._syncState(),this}setError(t){return this._error=t??new Error(String(this.options.errorText)),this._hasError=!0,this._loading=!1,this._destroyHandle(),this._syncState(),this.emit("error",{error:this._error}),this}clearError(){return this._error=null,this._hasError=!1,this._mountOrUpdate(!1),this}resize(){try{this._handle?.resize?.()}catch(t){this.setError(t)}return this}refreshTheme(){return this._mountOrUpdate(!0),this}getInstance(){return this._handle?.instance??null}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._observer?.disconnect(),this._stopWatchingMotion?.(),this._destroyHandle(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_mountOrUpdate(t){if(this._syncState(),this._loading||this._hasError||so(this._data)){this._destroyHandle();return}if(!this._adapter||typeof this._adapter.create!="function"){this._destroyHandle();return}let e=this._spec();try{if(this._handle)this._handle.update(e);else{if(this._handle=this._adapter.create(this.refs.canvas,e),!this._handle||typeof this._handle.destroy!="function")throw new TypeError("Chart adapter create() must return a lifecycle handle");this.emit("ready",{instance:this.getInstance()})}t&&this.emit("update",{data:this._data,type:this._type})}catch(i){this.setError(i)}}_spec(){return{type:this._type,data:Ct(this._data),options:{...$x(this.el),...Ct(this._chartOptions)},reducedMotion:ri(this.el),onSelect:t=>this.emit("select",t)}}_destroyHandle(){if(!this._handle)return;let t=this._handle;this._handle=null;try{t.destroy()}catch{}}_syncState(){let t=so(this._data),e=this._loading?"loading":this._hasError?"error":t?"empty":"ready";this.el.dataset.state=e,this.refs.viewport.hidden=e!=="ready";let i="";e==="loading"?i=String(this.options.loadingText):e==="error"?i=Kx(this._error,this.options.errorText):e==="empty"&&(i=String(this.options.emptyText)),this.refs.status.textContent=i,this.refs.status.hidden=!i}_renderSummary(){this.refs.summary.replaceChildren(Dl(this._data,this._label))}};function jx(s){return String(s??"").trim()||"Chart"}var io=class{constructor(t,e={}){let i=typeof t=="function"?t:t?.Chart;if(typeof i!="function")throw new TypeError("ChartJsAdapter requires an injected Chart.js constructor");this.engine=i,this.defaults=Ct(e)}create(t,e){let i=this.engine,n=null,r="",o=!1,a=c=>{let d=null,u=qf(c,this.defaults,()=>d);d=new i(t,u),n=d,r=c.type};return a(e),{get instance(){return n},update:c=>{if(o)return;if(c.type!==r){let u=n;n=null,u?.destroy?.(),a(c);return}let d=qf(c,this.defaults,()=>n);n.data=d.data,n.options=d.options,n.update()},resize:()=>{o||n?.resize?.()},destroy:()=>{o||(o=!0,n?.destroy?.(),n=null)}}}};function qf(s,t,e){let i=Ct(s.options),n={responsive:!0,maintainAspectRatio:!1,...Ct(t),...i};s.reducedMotion&&(n.animation=!1);let r=n.onClick;return n.onClick=(o,a,c)=>{typeof r=="function"&&r(o,a,c);let d=e()??c,h=(Array.isArray(a)&&a.length?a:d?.getElementsAtEventForMode?.(o,"nearest",{intersect:!0},!0)??[])[0];if(!h)return;let f=s.data.datasets?.[h.datasetIndex]??null;s.onSelect({datasetIndex:h.datasetIndex,index:h.index,dataset:f,label:s.data.labels?.[h.index],value:f?.data?.[h.index],nativeEvent:o?.native??o??null})},{type:s.type,data:Ct(s.data),options:n}}function Ct(s){return Ml(s,new WeakMap)}function Ml(s,t){if(Array.isArray(s)){if(t.has(s))return t.get(s);let e=[];return t.set(s,e),e.push(...s.map(i=>Ml(i,t))),e}if(s&&typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype){if(t.has(s))return t.get(s);let e={};t.set(s,e);for(let[i,n]of Object.entries(s))e[i]=Ml(n,t);return e}return s}function $f(s){return!s||typeof s!="object"?{labels:[],datasets:[]}:Ct({...s,labels:Array.isArray(s.labels)?s.labels:[],datasets:Array.isArray(s.datasets)?s.datasets:[]})}function so(s){return!Array.isArray(s?.datasets)||!s.datasets.some(t=>Array.isArray(t?.data)&&t.data.length>0)}function Dl(s,t="Chart data"){let e=Hx(s);return l("table",{class:"zx-chart__table"},l("caption",{},t),l("thead",{},l("tr",{},l("th",{scope:"col"},"Label"),e.headers.map(n=>l("th",{scope:"col"},n)))),l("tbody",{},e.rows.map(n=>l("tr",{},l("th",{scope:"row"},n.label),n.values.map(r=>l("td",{},r))))))}function Hx(s){let t=Array.isArray(s?.datasets)?s.datasets:[],e=Array.isArray(s?.labels)?s.labels:[],i=Math.max(e.length,...t.map(n=>Array.isArray(n.data)?n.data.length:0),0);return{headers:t.map((n,r)=>String(n.label??`Series ${r+1}`)),rows:Array.from({length:i},(n,r)=>({label:String(e[r]??r+1),values:t.map(o=>qx(o.data?.[r]))}))}}function qx(s){if(s==null)return"";if(typeof s=="object"){if("y"in s)return String(s.y??"");if("r"in s)return String(s.r??"");try{return JSON.stringify(s)}catch{return String(s)}}return String(s)}function $x(s){if(typeof getComputedStyle!="function")return{};let t=getComputedStyle(s),e=t.getPropertyValue("--zx-color-text").trim(),i=t.getPropertyValue("--zx-color-border").trim();return{color:e||void 0,borderColor:i||void 0}}function Kx(s,t){let e=s&&typeof s=="object"&&"message"in s?String(s.message):"";return e.trim()?e:String(t)}function no({valueKey:s="ID",labelKey:t="name",childrenKey:e="children"}={}){return{value:i=>typeof s=="function"?s(i):i?.[s],label:i=>String((typeof t=="function"?t(i):i?.[t])??""),children:i=>{let n=i?.[e];return Array.isArray(n)?n:null}}}function Q(s,t){if(s?.hasChildren===!0)return!0;let e=t.children(s);return Array.isArray(e)&&e.length>0}function Pi(s,t,e,{level:i=1,parent:n=null}={}){s.forEach((r,o)=>{e(r,{level:i,parent:n,index:o,siblings:s});let a=t.children(r);a&&Pi(a,t,e,{level:i+1,parent:r})})}function Kf(s,t,e){let i=null;return Pi(s,e,n=>{i===null&&Object.is(e.value(n),t)&&(i=n)}),i}function Ls(s,t,e){for(let i of s){if(Object.is(e.value(i),t))return[i];let n=e.children(i);if(!n)continue;let r=Ls(n,t,e);if(r.length>0)return[i,...r]}return[]}function Uf(s,t){let e=[],i=t.children(s);return i&&Pi(i,t,n=>e.push(n)),e}function Yf(s,t,e){let i=[],n=(r,o,a)=>{r.forEach((c,d)=>{let u=t.value(c);if(i.push({node:c,id:u,level:o,parent:a,posinset:d+1,setsize:r.length}),!e.has(u))return;let h=t.children(c);h&&h.length>0&&n(h,o+1,c)})};return n(s,1,null),i}function Nl(s,t,e,i){let n=[];for(let r of s){let o=t.children(r)??[],a=Nl(o,t,e,i);(e(r)||a.length>0)&&n.push(a.length>0||o.length>0?{...r,[i]:a}:r)}return n}var ro=class extends y{static cssName="tree";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",expanded:[],selection:"single",selected:[],checkboxes:!1,checked:[],icons:!0,renderLabel:null,load:null,filter:"",label:"Tree",emptyText:"Nothing to show",height:null};render(){this._items=[],this._rows=[],this._expanded=new Set,this._selected=new Set,this._checked=new Set,this._loading=new Map,this._focusId=null,this._filter="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._readers=no(this.options),this._childrenKey=this.options.childrenKey??"children",t.setAttribute("role","tree"),t.setAttribute("aria-label",String(this.options.label??"Tree")),t.tabIndex=0,this.options.selection==="multi"&&t.setAttribute("aria-multiselectable","true"),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height),t.style.overflowY="auto"),this._items=Ol(this.options.items);for(let i of Rs(this.options.expanded))this._expanded.add(i);for(let i of Rs(this.options.selected))this._selected.add(i);let[e]=this._selected;if(e!==void 0){this._focusId=e;for(let i of this.getPath(e).slice(0,-1))this._expanded.add(this._readers.value(i))}for(let i of Rs(this.options.checked))this._applyCheck(i,!0,{silent:!0});return this._handleTypeahead=ut(()=>this._rotatedRows().map(i=>this._readers.label(i.node)),(i,n)=>this._focusNodeId(this._rotatedRows()[n]?.id)),this.listen(t,"keydown",i=>this._onKeydown(i)),this.listen(t,"click",i=>this._onClick(i)),this.listen(t,"dblclick",i=>this._onDoubleClick(i)),this.listen(t,"focus",()=>{this._rows.length>0&&!this._rowElement(this._focusId)&&this._focusRow(0)}),String(this.options.filter??"")!==""?this.setFilter(this.options.filter):this._renderRows(),t}setItems(t){return this._items=Ol(t),this._renderRows(),this}getItems(){return this._items}getNode(t){return Kf(this._items,t,this._readers)}getPath(t){return Ls(this._items,t,this._readers)}setFilter(t){if(this._filter=String(t??""),this._filter!=="")for(let e of this._visibleItems())Pi([e],this._readers,i=>this._expanded.add(this._readers.value(i)));return this._renderRows(),this}async expand(t){let e=this.getNode(t);if(!e||!Q(e,this._readers))return this;let i=this._readers.children(e),n=!!this.options.load&&(!i||i.length===0);return this._expanded.has(t)&&!n?this:await this._ensureChildren(e,t)?(this._expanded.add(t),this._renderRows(),this.emit("expand",{node:e,id:t}),this):this}collapse(t){if(!this._expanded.delete(t))return this;let e=this.getNode(t);return this._renderRows(),e&&this.emit("collapse",{node:e,id:t}),this}async toggle(t){return this._expanded.has(t)?this.collapse(t):this.expand(t)}expandAll(){return Pi(this._items,this._readers,t=>{Q(t,this._readers)&&this._expanded.add(this._readers.value(t))}),this._renderRows(),this}collapseAll(){return this._expanded.clear(),this._renderRows(),this}reveal(t){let e=this.getPath(t);for(let i of e.slice(0,-1))this._expanded.add(this._readers.value(i));return this._renderRows(),this}select(t,{silent:e=!1,additive:i=!1}={}){if(this.options.selection===!1)return this;let n=this.getNode(t);return n?(this.options.selection==="multi"&&i?this._selected.has(t)?this._selected.delete(t):this._selected.add(t):(this._selected.clear(),this._selected.add(t)),this._syncRows(),e||this.emit("select",{node:n,id:t,ids:this.getSelection()}),this):this}getSelection(){return[...this._selected]}setSelection(t,{silent:e=!0}={}){let i=Rs(t);if(this._selected=new Set(this.options.selection==="multi"?i:i.slice(0,1)),this._syncRows(),!e){let[n]=this._selected;this.emit("select",{node:this.getNode(n)??null,id:n,ids:this.getSelection()})}return this}clearSelection(){return this._selected.clear(),this._syncRows(),this}getChecked({leavesOnly:t=!1}={}){return t?[...this._checked].filter(e=>{let i=this.getNode(e);return i!==null&&!Q(i,this._readers)}):[...this._checked]}setChecked(t,{silent:e=!0}={}){this._checked.clear();for(let i of Rs(t))this._applyCheck(i,!0,{silent:!0});return this._syncRows(),e||this.emit("check",{ids:this.getChecked(),node:null}),this}check(t,e,{silent:i=!1}={}){let n=this._applyCheck(t,e,{silent:!0});return this._syncRows(),!i&&n&&this.emit("check",{ids:this.getChecked(),node:n}),this}focusNode(t){this.reveal(t);let e=this._rows.findIndex(i=>Object.is(i.id,t));return e>=0&&this._focusRow(e),this}_visibleItems(){if(this._filter==="")return this._items;let t=this._filter.trim().toLocaleLowerCase();return t===""?this._items:Nl(this._items,this._readers,e=>this._readers.label(e).toLocaleLowerCase().includes(t),this._childrenKey)}_renderRows(){let t=this._visibleItems();if(this._rows=Yf(t,this._readers,this._expanded),this._rows.length===0){this.el.replaceChildren(l("div",{class:"zx-tree__empty"},this._message("tree.empty",this.options.emptyText)));return}this.el.replaceChildren(...this._rows.map(e=>this._renderRow(e))),this._syncRows()}_renderRow(t){let e=Q(t.node,this._readers),i=e&&this._expanded.has(t.id),n=l("div",{class:"zx-tree__row",role:"treeitem",id:x("zx-tree-item"),tabIndex:-1,ariaLevel:String(t.level),ariaSetSize:String(t.setsize),ariaPosInSet:String(t.posinset),dataset:{level:String(t.level)}});n.style.setProperty("--zx-tree-level",String(t.level-1));let r=l("span",{class:"zx-tree__twisty",ariaHidden:"true"},e?b("chevron-right",{size:12}):null);if(r.dataset.action="twisty",n.append(r),this.options.checkboxes){let a=l("input",{class:"zx-tree__checkbox",type:"checkbox",tabIndex:-1,ariaHidden:"true"});a.dataset.action="checkbox",n.append(a)}this.options.icons&&n.append(l("span",{class:"zx-tree__icon",ariaHidden:"true"},b(e?i?"folder-open":"folder":"file",{size:14})));let o=this.options.renderLabel?this.options.renderLabel(t.node):this._readers.label(t.node);return n.append(l("span",{class:"zx-tree__label"},o)),t.node.badge!=null&&n.append(l("span",{class:"zx-tree__badge"},String(t.node.badge))),n}_syncRows(){let t=this.el.querySelectorAll(".zx-tree__row"),e=this._rows.findIndex(i=>Object.is(i.id,this._focusId));e<0&&(e=0),t.forEach((i,n)=>{let r=this._rows[n];if(!r)return;let o=Q(r.node,this._readers),a=o&&this._expanded.has(r.id);o?i.setAttribute("aria-expanded",String(a)):i.removeAttribute("aria-expanded"),this.options.selection!==!1&&i.setAttribute("aria-selected",String(this._selected.has(r.id))),i.toggleAttribute("data-branch",o),i.toggleAttribute("data-loading",this._loading.has(r.id)),i.tabIndex=n===e?0:-1;let c=i.querySelector(".zx-tree__checkbox");if(c){let u=this._checkState(this.getNode(r.id)??r.node);c.checked=u==="checked",c.indeterminate=u==="partial",i.setAttribute("aria-checked",u==="partial"?"mixed":String(c.checked))}let d=i.querySelector(".zx-tree__icon");d&&this.options.icons&&d.replaceChildren(b(o?a?"folder-open":"folder":"file",{size:14}))}),this._focusId=this._rows[e]?.id??null,this.el.tabIndex=this._rows.length===0?0:-1}_onClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let i=this._rowIndex(e);if(i<0)return;let n=this._rows[i];this._focusRow(i);let r=t.target.closest("[data-action]");if(r?.dataset.action==="twisty"){Q(n.node,this._readers)&&this.toggle(n.id).then(()=>this._focusNodeId(n.id));return}let o=this.getNode(n.id)??n.node;if(r?.dataset.action==="checkbox"){this.check(n.id,this._checkState(o)!=="checked");return}if(this.options.checkboxes&&this.options.selection===!1){this.check(n.id,this._checkState(o)!=="checked");return}this.select(n.id,{additive:t.ctrlKey||t.metaKey})}_onDoubleClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let i=this._rows[this._rowIndex(e)];i&&(Q(i.node,this._readers)?this.toggle(i.id).then(()=>this._focusNodeId(i.id)):this.emit("activate",{node:i.node,id:i.id}))}_onKeydown(t){let e=this._rows.findIndex(o=>Object.is(o.id,this._focusId));if(e<0||this._rows.length===0)return;let i=this._rows[e],n=Q(i.node,this._readers),r=n&&this._expanded.has(i.id);switch(t.key){case"ArrowDown":t.preventDefault(),this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowUp":t.preventDefault(),this._focusRow(Math.max(0,e-1));return;case"ArrowRight":t.preventDefault(),n&&!r?this.expand(i.id).then(()=>this._focusNodeId(i.id)):r&&this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowLeft":{t.preventDefault(),r?(this.collapse(i.id),this._focusNodeId(i.id)):i.parent&&this._focusNodeId(this._readers.value(i.parent));return}case"Home":t.preventDefault(),this._focusRow(0);return;case"End":t.preventDefault(),this._focusRow(this._rows.length-1);return;case"Enter":t.preventDefault(),this.options.selection!==!1&&this.select(i.id),this.emit("activate",{node:i.node,id:i.id});return;case" ":t.preventDefault(),this.options.checkboxes?this.check(i.id,this._checkState(this.getNode(i.id)??i.node)!=="checked"):this.options.selection!==!1&&this.select(i.id,{additive:this.options.selection==="multi"});return;case"*":t.preventDefault(),this._expandSiblings(i);return;default:if(!Ux(t)||Yx(t.target))return;t.preventDefault(),this._handleTypeahead(t)}}_expandSiblings(t){let e=t.parent?this._readers.children(t.parent)??[]:this._visibleItems(),i=this._focusId;for(let n of e)Q(n,this._readers)&&this._expanded.add(this._readers.value(n));this._renderRows(),this._focusNodeId(i)}async _ensureChildren(t,e){let i=this._readers.children(t);if(!this.options.load||i&&i.length>0)return!0;if(this._loading.has(e))return await this._loading.get(e),Array.isArray(this._readers.children(t));let n=(async()=>{try{let o=await this.options.load(t);return t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1),!0}catch(o){return this.emit("error",{error:o,node:t,id:e}),!1}finally{this._loading.delete(e)}})();this._loading.set(e,n),this._syncRows();let r=await n;return this._syncRows(),r}_applyCheck(t,e,{silent:i}){let n=this.getNode(t);if(!n)return null;let r=[t,...Uf(n,this._readers).map(o=>this._readers.value(o))];for(let o of r)e?this._checked.add(o):this._checked.delete(o);return i||this._syncRows(),n}_checkState(t){let e=this._readers.children(t);if(!e||e.length===0)return this._checked.has(this._readers.value(t))?"checked":"unchecked";let i=e.map(n=>this._checkState(n));return i.every(n=>n==="checked")?"checked":i.every(n=>n==="unchecked")?"unchecked":"partial"}_rotatedRows(){let t=this._rows.findIndex(e=>Object.is(e.id,this._focusId));return t<0?this._rows:[...this._rows.slice(t+1),...this._rows.slice(0,t+1)]}_rowIndex(t){return[...this.el.querySelectorAll(".zx-tree__row")].indexOf(t)}_rowElement(t){let e=this._rows.findIndex(i=>Object.is(i.id,t));return e<0?null:this.el.querySelectorAll(".zx-tree__row")[e]??null}_focusRow(t){let e=this._rows[t];if(!e)return;this._focusId=e.id,this._syncRows();let i=this._rowElement(e.id);i?.focus(),i?.scrollIntoView({block:"nearest"})}_focusNodeId(t){if(t===void 0)return;let e=this._rows.findIndex(i=>Object.is(i.id,t));e>=0&&this._focusRow(e)}_message(t,e){let i=this.msg(t);return i===t?e:i}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function Ol(s){return Array.isArray(s)?s.map(t=>{if(t===null||typeof t!="object")return t;let e={...t};for(let[i,n]of Object.entries(e))Array.isArray(n)&&(e[i]=Ol(n));return e}):[]}function Rs(s){return Array.isArray(s)?s:[]}function Ux(s){if(!s||s.ctrlKey||s.metaKey||s.altKey)return!1;let t=typeof s.key=="string"?s.key:"";return t.length===1&&!/\s/.test(t)}function Yx(s){let t=s&&s.nodeType===1?s:null;return t?t.isContentEditable||t.localName==="textarea"||t.localName==="select"?!0:t.localName!=="input"?!1:!["checkbox","radio","button","submit","reset","image","range","color","file"].includes(t.type):!1}var oo=class extends y{static cssName="finder";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",path:[],load:null,preview:null,rootLabel:"",columnWidth:220,height:320,icons:!0,renderItem:null,emptyText:"Empty"};render(){this._items=[],this._path=[],this._columns=[],this._activeColumn=0,this._loading=new Map,this._pathSequence=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");return this.el=t,this._readers=no(this.options),this._childrenKey=this.options.childrenKey??"children",t.style.setProperty("--zx-finder-column",`${Number(this.options.columnWidth)||220}px`),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._handleTypeahead=ut(()=>this._columnNodes(this._activeColumn).map(e=>this._readers.label(e)),(e,i)=>this._selectAt(this._activeColumn,i,{focus:!0})),this.listen(t,"click",e=>this._onClick(e)),this.listen(t,"dblclick",e=>this._onDoubleClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this._render({}),this.setPath(this.options.path,{silent:!0}),t}getPath(){return this._path.slice()}getNodes(){let t=this._items,e=[];for(let i of this._path){let n=t.find(r=>Object.is(this._readers.value(r),i));if(!n)break;e.push(n),t=this._readers.children(n)??[]}return e}getSelection(){let t=this.getNodes();return t.length>0?t[t.length-1]:null}async setPath(t,{silent:e=!1,focus:i=!1}={}){let n=this._pathSequence+1;this._pathSequence=n;let r=Array.isArray(t)?t.slice():[],o=[],a=this._items;for(let c of r){let d=a.find(u=>Object.is(this._readers.value(u),c));if(!d||(o.push(c),!Q(d,this._readers)))break;if(await this._ensureChildren(d),n!==this._pathSequence)return this;a=this._readers.children(d)??[]}return this._path=o,this._activeColumn=Math.max(0,o.length-1),this._render({focus:i}),e||this._emitChange(),this}async reveal(t,{silent:e=!1}={}){let i=Ls(this._items,t,this._readers);return i.length===0?this:this.setPath(i.map(n=>this._readers.value(n)),{silent:e})}setItems(t){return this._items=Array.isArray(t)?t.slice():[],this._path=[],this._render({}),this}focus(){return(this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0))?.focus(),this}_render({focus:t=!1}){let e=this.getNodes(),i=[{nodes:this._items,selectedId:this._path[0],owner:null}];e.forEach((a,c)=>{if(!Q(a,this._readers))return;let d=this._readers.children(a)??[];i.push({nodes:d,selectedId:this._path[c+1],owner:a})}),this._columns=i,this._activeColumn=Math.min(this._activeColumn,i.length-1);let n=i.map((a,c)=>this._renderColumn(a,c)),r=e[e.length-1]??null;if(this.options.preview&&r&&!Q(r,this._readers)){let a=this.options.preview(r);a&&n.push(l("div",{class:"zx-finder__preview"},a))}this.el.replaceChildren(...n),this._syncTabStop(),this.el.lastElementChild?.scrollIntoView({block:"nearest",inline:"nearest"}),t&&this.focus()}_renderColumn(t,e){let i=t.owner?this._readers.label(t.owner):String(this.options.rootLabel||this._message("finder.root","Root")),n=l("div",{class:"zx-finder__list",role:"listbox",ariaLabel:i,dataset:{column:String(e)}});if(t.nodes.length===0){let r=t.owner!==null&&this._loading.has(this._readers.value(t.owner));n.append(l("div",{class:"zx-finder__empty"},r?this._message("finder.loading","Loading\u2026"):this._message("finder.empty",this.options.emptyText)))}for(let r of t.nodes){let o=this._readers.value(r),a=Q(r,this._readers),c=t.selectedId!==void 0&&Object.is(o,t.selectedId),d=l("div",{class:"zx-finder__row",id:x("zx-finder-row"),role:"option",tabIndex:-1,ariaSelected:String(c)});this.options.icons&&d.append(l("span",{class:"zx-finder__icon",ariaHidden:"true"},b(a?"folder":"file",{size:14}))),d.append(l("span",{class:"zx-finder__label"},this.options.renderItem?this.options.renderItem(r):this._readers.label(r))),a&&d.append(l("span",{class:"zx-finder__chevron",ariaHidden:"true"},b("chevron-right",{size:11}))),d.toggleAttribute("data-branch",a),n.append(d)}return l("div",{class:"zx-finder__column"},n)}_syncTabStop(){let t=this.el.querySelectorAll(".zx-finder__row");t.forEach(i=>{i.tabIndex=-1});let e=this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0)??t[0];e&&(e.tabIndex=0)}_onClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:i,index:n}=this._locate(e);i<0||this._selectAt(i,n,{focus:!0})}_onDoubleClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:i,index:n}=this._locate(e),r=this._columnNodes(i)[n];r&&(Q(r,this._readers)?this._enter(i,n):this.emit("activate",{node:r,id:this._readers.value(r)}))}_onKeydown(t){if(t.target.closest(".zx-finder__preview"))return;let e=this._activeColumn,i=this._columnNodes(e);if(i.length===0&&!["ArrowLeft"].includes(t.key))return;let n=Math.max(0,i.findIndex(r=>Object.is(this._readers.value(r),this._columns[e]?.selectedId)));switch(t.key){case"ArrowDown":t.preventDefault(),this._selectAt(e,Math.min(i.length-1,n+1),{focus:!0});return;case"ArrowUp":t.preventDefault(),this._selectAt(e,Math.max(0,n-1),{focus:!0});return;case"Home":t.preventDefault(),this._selectAt(e,0,{focus:!0});return;case"End":t.preventDefault(),this._selectAt(e,i.length-1,{focus:!0});return;case"ArrowRight":{t.preventDefault();let r=i[n];if(!r||!Q(r,this._readers))return;this._enter(e,n);return}case"ArrowLeft":if(t.preventDefault(),e===0)return;this._path=this._path.slice(0,e),this._activeColumn=e-1,this._render({focus:!0}),this._emitChange();return;case"Enter":{t.preventDefault();let r=i[n];if(!r)return;Q(r,this._readers)?this._enter(e,n):this.emit("activate",{node:r,id:this._readers.value(r)});return}default:this._handleTypeahead(t)}}async _selectAt(t,e,{focus:i=!1}={}){let n=this._columnNodes(t)[e];if(!n)return;let r=this._readers.value(n);if(this._path.length===t+1&&Object.is(this._path[t],r)){this._activeColumn=t,this._syncTabStop(),i&&this.focus();return}this._path=[...this._path.slice(0,t),r],this._activeColumn=t,Q(n,this._readers)&&await this._ensureChildren(n),this._render({focus:i}),this._emitChange()}async _enter(t,e){if(await this._selectAt(t,e),this._columnNodes(t+1).length===0){this._activeColumn=t,this._syncTabStop(),this.focus();return}this._activeColumn=t+1,this._path.length<=t+1?await this._selectAt(t+1,0,{focus:!0}):(this._syncTabStop(),this.focus())}async _ensureChildren(t){let e=this._readers.children(t);if(!this.options.load||e&&e.length>0)return;let i=this._readers.value(t),n=this._loading.get(i);if(n)return n;let r=(async()=>{try{let o=await this.options.load(t);t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1)}catch(o){t[this._childrenKey]=[],this.emit("error",{error:o,node:t,id:i})}finally{this._loading.delete(i)}})();return this._loading.set(i,r),r}_columnNodes(t){return this._columns[t]?.nodes??[]}_locate(t){let e=t.closest(".zx-finder__list");return e?{column:Number(e.dataset.column),index:[...e.querySelectorAll(".zx-finder__row")].indexOf(t)}:{column:-1,index:-1}}_rowAt(t,e){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelectorAll(".zx-finder__row")[e]??null}_activeRow(t){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelector('[aria-selected="true"]')??null}_emitChange(){let t=this.getNodes();this.emit("change",{path:this.getPath(),nodes:t,node:t.length>0?t[t.length-1]:null})}_message(t,e){let i=this.msg(t);return i===t?e:i}destroy(){this._pathSequence+=1;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function Gf(s){return String(s??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function Gx(s,t){let e=Gf(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let i=Gf(s.flat(1/0).join(" "));return e.every(n=>i.includes(n))}function Ll(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function Wf(s,t){if(typeof t.get=="function")return Fl(t.get(s));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(n=>Fl(typeof n=="function"?n(s):n==null?void 0:s?.[n]))}function Qf(s,t){let e=[],i=new Map;for(let n of s)for(let r of Wf(n,t)){let o=Xf(r);o.value==null||o.value===""||i.has(o.value)||(i.set(o.value,!0),e.push(o))}return e}function Fe(s,t,e){return s.filter(i=>t.every(n=>{let r=e?.[n.id];if(!Ll(r))return!0;if(n.type==="custom")return typeof n.predicate!="function"||!!n.predicate(i,r);let o=Wf(i,n);return n.type==="text"?Gx(o,r):n.type==="select"?o.some(a=>Wx(Xf(a).value,r)):!0}))}function Fl(s){return Array.isArray(s)?s.flat(1/0):[s]}function Xf(s){if(s&&typeof s=="object"&&!(s instanceof Date)){if(Object.prototype.hasOwnProperty.call(s,"value"))return{value:s.value,label:String(s.label??s.value??"")};if(Object.prototype.hasOwnProperty.call(s,"field"))return{value:s.field,label:String(s.label??s.field??"")}}return{value:s,label:String(s??"")}}function Wx(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}var ao=class extends y{static cssName="data-filter";static defaults={filters:[],data:[],autoApply:!0,clearLabel:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._filters=Array.isArray(this.options.filters)?this.options.filters.map(i=>({...i})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._state={},this._entries=new Map,this._customOrigins=new Map,this._restored=!1;let e=new Set;for(let i of this._filters){if(Rl(i),e.has(i.id))throw new RangeError(`Duplicate filter id: ${i.id}`);e.add(i.id),i.type==="custom"&&!this._customOrigins.has(i.element)&&this._customOrigins.set(i.element,{parent:i.element.parentNode,nextSibling:i.element.nextSibling}),this._state[i.id]=i.type==="custom"?Pl(i.element):""}this._filtered=Fe(this._data,this._filters,this._state),this._controls=l("div",{class:"zx-data-filter__controls"}),this._badge=l("span",{class:"zx-data-filter__badge",ariaLive:"polite",hidden:!0},"0"),this._clearButton=l("button",{class:"zx-data-filter__clear",type:"button",hidden:!0},this.options.clearLabel==null?this.msg("dataFilter.clear"):String(this.options.clearLabel)),t.replaceChildren(this._controls,this._badge,this._clearButton),this.listen(this._clearButton,"click",()=>this.clear());for(let i of this._filters)this._appendFilter(i);return this._syncActiveState(),t}setData(t){Jx(t),this._data=[...t];for(let e of this._filters){if(e.type!=="select")continue;let i=this._entries.get(e.id);i&&this._populateSelect(e,i)}return this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Fe(this._data,this._filters,this._state),this}apply(){this._filtered=Fe(this._data,this._filters,this._state);let t=[...this._filtered];return this.emit("filter",{rows:t,state:this.getState()}),t}clear(){for(let t of this._filters)this._state[t.id]="";return this._syncControls(),this._syncActiveState(),this.apply(),this}getState(){return{...this._state}}setState(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("DataFilter state must be an object");for(let e of this._filters)this._state[e.id]=Object.prototype.hasOwnProperty.call(t,e.id)?t[e.id]:"";return this._syncControls(),this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Fe(this._data,this._filters,this._state),this}addFilter(t){Rl(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?Pl(e.element):"",this._appendFilter(e),this._filtered=Fe(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),Zx(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(Rl(t),this._entries.has(t.id))throw new RangeError(`Duplicate filter id: ${t.id}`);let e,i={element:null,options:[]};if(t.type==="select")e=l("select",{ariaLabel:t.label}),i.element=e,this._populateSelect(t,i),this.listen(e,"change",()=>{let r=Number(e.value)-1;this._state[t.id]=r>=0?i.options[r]?.value??"":"",this._controlChanged()});else if(t.type==="text")e=l("input",{type:"search",placeholder:t.placeholder??"",ariaLabel:t.label,autocomplete:"off"}),i.element=e,this.listen(e,"input",()=>{this._state[t.id]=e.value,this._controlChanged()});else{e=t.element,this._customOrigins.has(e)||this._customOrigins.set(e,{parent:e.parentNode,nextSibling:e.nextSibling}),i.element=e;let r=e.matches?.('input:not([type="checkbox"]):not([type="radio"]), textarea')?"input":"change";this.listen(e,r,()=>{this._state[t.id]=Pl(e),this._controlChanged()})}this._entries.set(t.id,i);let n=l("label",{class:"zx-data-filter__field"},l("span",{class:"zx-data-filter__label"},t.label),e);this._controls.append(n)}_populateSelect(t,e){let i=this._state[t.id];e.options=Array.isArray(t.options)?t.options.map(Qx):Qf(this._data,t);let n=l("option",{value:""},t.emptyLabel??this.msg("dataFilter.all")),r=document.createDocumentFragment();r.append(n),e.options.forEach((a,c)=>{r.append(l("option",{value:String(c+1)},a.label))}),e.element.replaceChildren(r);let o=e.options.findIndex(a=>Jf(a.value,i));e.element.value=o>=0?String(o+1):"",o<0&&(this._state[t.id]="")}_controlChanged(){this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Fe(this._data,this._filters,this._state)}_syncControls(){for(let t of this._filters){let e=this._entries.get(t.id);if(!e)continue;let i=this._state[t.id];if(t.type==="select"){let n=e.options.findIndex(r=>Jf(r.value,i));e.element.value=n>=0?String(n+1):"",n<0&&(this._state[t.id]="")}else Xx(e.element,i)}}_syncActiveState(){let t=this._filters.reduce((e,i)=>e+Number(Ll(this._state[i.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function Rl(s){if(!s||typeof s!="object")throw new TypeError("Filter definition must be an object");if(!["select","text","custom"].includes(s.type))throw new TypeError(`Unknown filter type: ${s.type}`);if(typeof s.id!="string"||!s.id)throw new TypeError("Filter definition requires an id");if(s.type==="custom"){if(!s.element||s.element.nodeType!==1)throw new TypeError("Custom filter requires an Element");if(typeof s.predicate!="function")throw new TypeError("Custom filter requires a predicate")}}function Qx(s){return s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"value")?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}}function Pl(s){return"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked:"value"in s?s.value:s.getAttribute("data-value")??""}function Xx(s,t){"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked=!!t:"value"in s?s.value=t==null?"":String(t):t==null||t===""?s.removeAttribute("data-value"):s.setAttribute("data-value",String(t))}function Jf(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}function Jx(s){if(!Array.isArray(s))throw new TypeError("DataFilter data must be an array")}function Zx(s){let t=[...s];for(let e=t.length;t.length>0&&e>=0;e-=1){let i=0;for(let n=t.length-1;n>=0;n-=1){let[r,o]=t[n];if(!o.parent)r.remove();else{if(o.nextSibling&&o.nextSibling.parentNode!==o.parent)continue;o.parent.insertBefore(r,o.nextSibling)}t.splice(n,1),i+=1}if(i===0)break}for(let[e,i]of t)i.parent?i.parent.append(e):e.remove()}var tS=8,eS=1e11,iS=.01,co=class extends y{static cssName="filter-panel";static defaults={fields:{},order:null,value:{},mode:"draft",serialize:"seconds",timeZone:null,emptyText:null};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._restored=!1,this._entries=[],this._children=[],this._writing=!1,this._draft={},this._applied={},this._appliedDraft="";let t=this.el??l("div");this.el=t,this._timeZone=rS(this.options.timeZone),this._fields=sS(this.options.fields,this.options.order),this._draft=Ps(this.options.value,this.options.fields,this._timeZone),this._applied=uo(this._draft,this.options.fields,this.options.serialize,this._timeZone),this._appliedDraft=Hl(this._draft);let e=[];if(this._fields.length===0)e.push(l("p",{ref:"empty",class:"zx-filter-panel__empty",role:"status"},this.options.emptyText==null?this._message("filterPanel.empty","No filters are available here."):String(this.options.emptyText)));else{let i=l("div",{ref:"fields",class:"zx-filter-panel__fields"});for(let{key:n,field:r,spec:o}of this._fields)i.append(this._buildField(n,r,o));e.push(i,this._buildActions())}return t.replaceChildren(...e),t.setAttribute("role","group"),t.setAttribute("aria-label",this._message("filterPanel.label","Filters")),t.setAttribute("data-mode",this.options.mode==="live"?"live":"draft"),this.listen(t,"keydown",i=>{i.key!=="Enter"||this.options.mode==="live"||!i.target?.matches?.('input:not([type="checkbox"]):not([type="radio"])')||(i.preventDefault(),this.apply())}),this._syncActions(),t}getValue(){return aS(this._applied)}setValue(t){return this._draft=Ps(t,this.options.fields,this._timeZone),this._commit(this._draftValue()),this._writeControls(),this._syncActions(),this.emit("change",{value:this.getValue(),field:null}),this}apply(){let t=this._draftValue();return this._commit(t),this._syncActions(t),this.emit("apply",{value:this.getValue()}),this}reset(){return this._replaceDraft(Ps(this.options.value,this.options.fields,this._timeZone))}clear(){return this._replaceDraft(Ps({},this.options.fields,this._timeZone),{commit:!0})}destroy(){for(let t of this._children)t.destroy();this._children=[],!this._restored&&!this._createdRoot&&(S(this.el,this._snapshot),this._restored=!0),super.destroy()}_buildActions(){let t=l("div",{ref:"actions",class:"zx-filter-panel__actions"});if(this.options.mode!=="live"){let i=l("button",{ref:"apply",class:"zx-btn zx-filter-panel__apply",type:"button",dataset:{kind:"primary",size:"md"}},l("span",{class:"zx-btn__label"},this._message("filterPanel.apply","Apply")));this.listen(i,"click",()=>this.apply()),t.append(i)}let e=l("button",{ref:"clear",class:"zx-btn zx-filter-panel__clear",type:"button",dataset:{kind:"ghost",size:"md"}},l("span",{class:"zx-btn__label"},this._message("filterPanel.clear","Clear all")));return this.listen(e,"click",()=>this.clear()),t.append(e),t}_buildField(t,e,i){let n=String(e.label??t),r=l("div",{class:"zx-filter-panel__field",dataset:{field:t,type:String(e.type??"")}});return i?(i.kind==="select"?r.append(this._buildSelect(t,e,n)):i.kind==="text"?r.append(...this._buildText(t,e,n)):i.kind==="date"?r.append(...this._buildDate(t,e,n,i)):r.append(...this._buildNumber(t,e,n,i)),r):(r.setAttribute("data-state","unsupported"),r.append(l("span",{class:"zx-filter-panel__label"},n),l("p",{class:"zx-filter-panel__unsupported",role:"note"},this._message("filterPanel.unsupported","Unsupported filter type: %1",String(e.type??"")))),r)}_buildSelect(t,e,i){let n=ip(e.options),r=this._draft[t]??[],o=new lt(null,{items:n.map(a=>({...a,on:r.some(c=>sp(c,a.value))})),valueKey:"value",labelKey:"label",search:typeof e.search=="boolean"?e.search:n.length>tS,height:220,msg:{"checklist.label":i}});return o.on("change",()=>this._edited(t,o.getValues())),this._isolate(o),this._children.push(o),this._entries.push({key:t,write:a=>o.setValues(a??[])}),o.toElement()}_buildText(t,e,i){let n=x("zx-filter-panel-text"),r=l("input",{id:n,class:"zx-filter-panel__input",type:"search",autocomplete:"off",placeholder:String(e.placeholder??""),value:String(this._draft[t]??"")});return this.listen(r,"input",()=>this._edited(t,r.value)),this._entries.push({key:t,write:o=>{r.value=o==null?"":String(o)}}),[l("label",{class:"zx-filter-panel__label",for:n},i),r]}_buildDate(t,e,i,n){if(!n.range){let d=x("zx-filter-panel-date"),u=this._dateInput(String(this._draft[t]??""),{id:d});return this.listen(u,"change",()=>this._edited(t,u.value)),this._entries.push({key:t,write:h=>{u.value=h==null?"":String(h)}}),[l("label",{class:"zx-filter-panel__label",for:d},i),u]}let r=x("zx-filter-panel-label"),o=this._draft[t]??{},a={},c=["from","to"].map(d=>{let u=x("zx-filter-panel-date"),h=this._dateInput(String(o[d]??""),{id:u,ariaLabel:this._edgeName(i,d)});return a[d]=h,this.listen(h,"change",()=>this._editedEdge(t,d,h.value)),l("div",{class:"zx-filter-panel__edge"},l("label",{class:"zx-filter-panel__edge-label",for:u},this._edgeLabel(d)),h)});return this._entries.push({key:t,write:d=>{let u=d??{};for(let h of["from","to"])a[h].value=u[h]==null?"":String(u[h])}}),[l("span",{class:"zx-filter-panel__label",id:r},i),l("div",{class:"zx-filter-panel__range",role:"group",ariaLabelledby:r},c)]}_dateInput(t,e){return l("input",{class:"zx-filter-panel__input",type:"date",autocomplete:"off",value:t,...e})}_buildNumber(t,e,i,n){let r=x("zx-filter-panel-label");if(!n.range){let d=this._numberField(e,n,i,this._draft[t]??null);return d.on("change",()=>this._edited(t,d.get())),this._entries.push({key:t,write:u=>d.set(u??null,{silent:!0})}),[l("span",{class:"zx-filter-panel__label",id:r},i),d.toElement()]}let o=this._draft[t]??{},a={},c=["from","to"].map(d=>{let u=this._numberField(e,n,this._edgeName(i,d),o[d]??null);return a[d]=u,u.on("change",()=>this._editedEdge(t,d,u.get())),l("div",{class:"zx-filter-panel__edge"},l("span",{class:"zx-filter-panel__edge-label"},this._edgeLabel(d)),u.toElement())});return this._entries.push({key:t,write:d=>{let u=d??{};for(let h of["from","to"])a[h].set(u[h]??null,{silent:!0})}}),[l("span",{class:"zx-filter-panel__label",id:r},i),l("div",{class:"zx-filter-panel__range",role:"group",ariaLabelledby:r},c)]}_numberField(t,e,i,n){let r=Number.isFinite(Number(t.step))&&Number(t.step)>0?Number(t.step):e.integer?1:iS,o=new Et(null,{value:n,min:t.min==null?null:Number(t.min),max:t.max==null?null:Number(t.max),step:r,precision:e.integer?0:null,placeholder:String(t.placeholder??""),label:i});return this._isolate(o),this._children.push(o),o}_edgeLabel(t){return t==="from"?this._message("filterPanel.from","From"):this._message("filterPanel.to","To")}_edgeName(t,e){return e==="from"?this._message("filterPanel.rangeFrom","%1 from",t):this._message("filterPanel.rangeTo","%1 to",t)}_edited(t,e){this._writing||(this._draft[t]=e,this._afterEdit(t))}_editedEdge(t,e,i){if(this._writing)return;let n=this._draft[t],r=n!==null&&typeof n=="object"&&!Array.isArray(n)?{...n}:{};r[e]=i,this._draft[t]=r,this._afterEdit(t)}_afterEdit(t){let e=this._draftValue();this._syncActions(e),this.emit("change",{value:e,field:t}),this.options.mode==="live"&&this.apply()}_isolate(t){for(let e of["zx-change","zx-input"])this.listen(t.el,e,i=>i.stopPropagation())}_replaceDraft(t,{commit:e=!1}={}){this._draft=t,this._writeControls();let i=this._draftValue(),n=e||this.options.mode==="live";return n&&this._commit(i),this._syncActions(i),this.emit("change",{value:i,field:null}),n&&this.emit("apply",{value:this.getValue()}),this}_commit(t){this._applied=t,this._appliedDraft=Hl(this._draft)}_draftValue(){return uo(this._draft,this.options.fields,this.options.serialize,this._timeZone)}_writeControls(){this._writing=!0;try{for(let t of this._entries)t.write(this._draft[t.key])}finally{this._writing=!1}}_syncActions(t=this._draftValue()){let e=Object.keys(t).length>0,i=this.refs.clear;if(i&&(i.disabled=!e),this.options.mode==="live"||this._fields.length===0)return;Hl(this._draft)!==this._appliedDraft?this.el.setAttribute("data-state","dirty"):this.el.removeAttribute("data-state")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function $l(s){switch(String(s??"").trim().toLowerCase()){case"text":return{kind:"text",range:!1,integer:!1};case"select":return{kind:"select",range:!1,integer:!1};case"date":return{kind:"date",range:!1,integer:!1};case"date:range":return{kind:"date",range:!0,integer:!1};case"int":return{kind:"number",range:!1,integer:!0};case"float":case"number":return{kind:"number",range:!1,integer:!1};case"int:range":return{kind:"number",range:!0,integer:!0};case"float:range":case"number:range":return{kind:"number",range:!0,integer:!1};default:return null}}function me(s){return s==null?!1:s instanceof Date?!Number.isNaN(s.getTime()):Array.isArray(s)?s.some(t=>me(t)):typeof s=="string"?s.trim()!=="":typeof s=="number"?Number.isFinite(s):typeof s=="boolean"?s:typeof s=="object"?Object.values(s).some(t=>me(t)):!0}function ep(s){let t={};if(!Bi(s))return t;for(let[e,i]of Object.entries(s)){if(Bi(i)){let n={};for(let[r,o]of Object.entries(i))me(o)&&(n[r]=o);Object.keys(n).length>0&&(t[e]=n);continue}me(i)&&(t[e]=i)}return t}function Bs(s,t=null){if(s==null||s==="")return"";if(s instanceof Date)return Number.isNaN(s.getTime())?"":jl(s.getTime(),null);if(typeof s=="number")return Number.isFinite(s)?jl(Math.abs(s)<eS?s*1e3:s,t):"";let e=String(s).trim();if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;if(/^-?\d+(\.\d+)?$/.test(e))return Bs(Number(e),t);let i=new Date(e);return Number.isNaN(i.getTime())?"":jl(i.getTime(),t)}function Bl(s,t,e="seconds",i=null){let n=Bs(s,i);if(!n)return null;let[r,o,a]=n.split("-").map(Number),c=new Date(oS(r,o-1,a,t,i));return typeof e=="function"?e(c,t):e==="ms"?c.getTime():e==="iso"?c.toISOString():Math.floor(c.getTime()/1e3)}function ip(s){if(!Array.isArray(s))return[];let t=[];for(let e of s){if(e!==null&&typeof e=="object"){let i=e,n="value"in i?i.value:i.ID;if(n===void 0)continue;let r=i.label??i.name??i.title;t.push({value:n,label:r==null?String(n):String(r)});continue}e!==void 0&&t.push({value:e,label:String(e)})}return t}function Ps(s,t,e=null){let i=Bi(s)?s:{},n={};for(let[r,o]of Object.entries(t??{})){let a=o??{},c=$l(a.type);if(!c)continue;let d=i[r];c.kind==="text"?n[r]=d==null?"":String(d).trim():c.kind==="select"?n[r]=nS(d,ip(a.options)):c.kind==="date"?n[r]=c.range?{from:Bs(lo(d,"from"),e),to:Bs(lo(d,"to"),e)}:Bs(d,e):n[r]=c.range?{from:Vl(lo(d,"from"),c),to:Vl(lo(d,"to"),c)}:Vl(d,c)}return n}function uo(s,t,e="seconds",i=null){let n=Ps(s,t,i),r={};for(let[o,a]of Object.entries(t??{})){let c=$l((a??{}).type);if(!c)continue;let d=n[o];if(c.kind==="text"){d!==""&&(r[o]=d);continue}if(c.kind==="select"){let f=d;f.length>0&&(r[o]=f.slice());continue}if(c.kind==="date"){if(!c.range){d&&(r[o]=Bl(d,"from",e,i));continue}let f=d,p={};f.from&&(p.from=Bl(f.from,"from",e,i)),f.to&&(p.to=Bl(f.to,"to",e,i)),Object.keys(p).length>0&&(r[o]=p);continue}if(!c.range){d!==null&&(r[o]=d);continue}let u=d,h={};u.from!==null&&(h.from=u.from),u.to!==null&&(h.to=u.to),Object.keys(h).length>0&&(r[o]=h)}return r}function sS(s,t){let e=Bi(s)?s:{},i=Object.keys(e),n=Array.isArray(t)?t.filter(o=>i.includes(o)):[],r=new Set(n);return[...n,...i.filter(o=>!r.has(o))].map(o=>({key:o,field:e[o]??{},spec:$l(e[o]?.type)}))}function nS(s,t){let e=Array.isArray(s)?s:me(s)?[s]:[];return t.length===0?e.filter(i=>me(i)):t.filter(i=>e.some(n=>sp(n,i.value))).map(i=>i.value)}function lo(s,t){return s==null?null:Array.isArray(s)?(t==="from"?s[0]:s[1])??null:Bi(s)?t in s?s[t]:null:t==="from"?s:null}function Vl(s,t){let e=ve(s);return e===null?null:t.integer?Math.trunc(e):e}function rS(s){if(s==null||s==="")return null;try{return new Intl.DateTimeFormat("en-US",{timeZone:String(s)}).resolvedOptions().timeZone}catch{throw new RangeError(`Unknown time zone "${String(s)}"`)}}function jl(s,t){if(!t){let i=new Date(s);return tp(i.getFullYear(),i.getMonth(),i.getDate())}let e=ql(s,t);return tp(e.year,e.month,e.day)}function oS(s,t,e,i,n){if(!n)return(i==="to"?new Date(s,t,e,23,59,59,999):new Date(s,t,e,0,0,0,0)).getTime();if(i!=="to")return Zf(s,t,e,n);let r=new Date(Date.UTC(s,t,e+1));return Zf(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),n)-1}function Zf(s,t,e,i){let n=Date.UTC(s,t,e),r=d=>{let u=ql(d,i);return Date.UTC(u.year,u.month,u.day)+u.seconds*1e3-Math.floor(d/1e3)*1e3},o=n-r(n),a=n-r(o),c=null;for(let d of[a,o]){let u=ql(d,i);u.year!==s||u.month!==t||u.day!==e||(!c||u.seconds<c.seconds)&&(c={candidate:d,seconds:u.seconds})}return c?c.candidate:a}function ql(s,t){let e=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),i={};for(let n of e.formatToParts(new Date(s)))i[n.type]=Number(n.value);return{year:i.year,month:i.month-1,day:i.day,seconds:i.hour%24*3600+i.minute*60+i.second}}function tp(s,t,e){return`${String(s).padStart(4,"0")}-${String(t+1).padStart(2,"0")}-${String(e).padStart(2,"0")}`}function Bi(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)}function sp(s,t){return Object.is(s,t)?!0:s==null||t===null||t===void 0?!1:String(s)===String(t)}function aS(s){let t={};for(let[e,i]of Object.entries(s))Array.isArray(i)?t[e]=i.slice():Bi(i)?t[e]={...i}:t[e]=i;return t}function Hl(s){return JSON.stringify(Object.keys(s).sort().map(t=>[t,s[t]]))}var ho=class extends y{static cssName="sort-control";static defaults={fields:[],value:null,label:"Sort by",labels:{},disabled:!1};render(){let t=this.el??l("div");return this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(t),this.el=t,this._value=np(this.options.value,this.options.fields),this._disabled=!!(this.options.disabled||!this.options.fields.length),this._direction=j({kind:"ghost",disabled:this._disabled}),this._direction.classList.add("zx-sort-control__direction"),this.listen(this._direction,"click",()=>{this._disabled||!this._value||this.setValue({id:this._value.id,dir:this._value.dir==="asc"?"desc":"asc"})}),this._select=new $(null,{items:lS(this.options.fields),valueKey:"id",labelKey:"label",value:this._value?.id??null,label:this.options.label,filter:"local",disabled:this._disabled,onchange:({detail:e})=>{e.item&&this.setValue({id:e.item.id,dir:this._value?.dir??"asc"})}}),this.listen(this._select.el,"zx-change",e=>e.stopPropagation()),t.replaceChildren(this._direction,this._select.el),this._syncDirection(),t}getValue(){return this._value?{...this._value}:null}setValue(t,{silent:e=!1}={}){let i=np(t,this.options.fields),n=rp(i)!==rp(this._value);return this._value=i,this._select.set(i?.id??null,{silent:!0}),this._syncDirection(),n&&!e&&this.emit("change",{value:this.getValue()}),this}enable(){return this._disabled=!this.options.fields.length,this._disabled||this._select.enable(),this._direction.disabled=this._disabled,this}disable(){return this._disabled=!0,this._select.disable(),this._direction.disabled=!0,this}_syncDirection(){let t=this._value?.dir??"asc",e=t==="asc"?"desc":"asc",i={asc:"Ascending",desc:"Descending",...this.options.labels};this._direction.replaceChildren(b(t==="asc"?"arrow-up-wide-short":"arrow-down-wide-short")),this._direction.dataset.direction=t,this._direction.setAttribute("aria-label",`${this.options.label}: ${i[t]}`),this._direction.title=`${i[t]} \u2192 ${i[e]}`}focus(){return this._select.focus(),this}destroy(){this._select?.destroy(),super.destroy(),this._createdRoot||S(this.el,this._snapshot)}};function np(s,t){if(!t.length)return null;if(s==null)return{id:String(t[0].id),dir:"asc"};if(!t.some(e=>String(e.id)===String(s.id)))throw new RangeError("Unknown sort field");if(s.dir!=="asc"&&s.dir!=="desc")throw new RangeError("Unknown sort direction");return{id:String(s.id),dir:s.dir}}function lS(s){return s.map(t=>({id:String(t.id),label:t.label}))}function rp(s){return s?JSON.stringify([s.id,s.dir]):""}var op=Object.freeze({auto:{icon:null,key:"listToolbar.viewAuto",fallback:"Auto"},table:{icon:"table",key:"listToolbar.viewTable",fallback:"Table"},list:{icon:"list",key:"listToolbar.viewList",fallback:"List"},cards:{icon:"grid",key:"listToolbar.viewCards",fallback:"Cards"},gallery:{icon:"image",key:"listToolbar.viewGallery",fallback:"Gallery"},board:{icon:"columns",key:"listToolbar.viewBoard",fallback:"Board"}}),fo=class extends y{static cssName="list-toolbar";static defaults={search:{},count:null,countText:null,views:[],view:null,tools:[],label:null};constructor(t=null,e={}){super(t,e),this.refs.tools&&this.listen(this.refs.tools,"click",i=>this._toolClick(i)),this.refs.views&&this.listen(this.refs.views,"click",i=>this._viewClick(i)),this.on("viewchange",i=>{let n=this._bound,r=n?.capabilities.setShape;r&&n.view[r](i.detail.view)})}render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._tools=new Map,this._views=hS(this.options.views),this._view=ap(this._views,this.options.view,null),this._count=null,this._search=null,this._bound=null,this._adopted=[],this._chooser=null;let t=this.el??l("div");this.el=t,t.setAttribute("role","group"),t.setAttribute("aria-label",this.options.label??this._message("listToolbar.label","List controls"));let e=[],i=this._searchOptions();if(i){this._search=new Ot(null,i);let n=this._search.toElement();n.classList.add("zx-list-toolbar__search"),this._search.on("input",r=>this.emit("search",{value:dp(r)})),this._search.on("submit",r=>this.emit("search",{value:dp(r)})),e.push(n)}return e.push(l("span",{class:"zx-list-toolbar__count",ref:"count",role:"status",ariaLive:"polite",ariaAtomic:"true"})),e.push(l("span",{class:"zx-list-toolbar__spacer"})),e.push(l("div",{class:"zx-list-toolbar__tools",ref:"tools"})),this._views.length>0&&e.push(l("div",{class:"zx-list-toolbar__views",ref:"views",role:"group",ariaLabel:this._message("listToolbar.views","View")})),t.replaceChildren(...e),this.setTools(this.options.tools),this._syncViews(),this.setCount(this.options.count),t}setCount(t){return this._count=hp(t),this.refs.count.textContent=fS(t,this._countFormat()),this}getCount(){return this._count}setBadge(t,e){let i=this._tools.get(String(t));return i?(i.badge=up(e),this._syncTool(i),this):this}setPressed(t,e=!0){let i=this._tools.get(String(t));return i?.toggle?(i.pressed=!!e,i.element.setAttribute("aria-pressed",i.pressed?"true":"false"),this):this}setToolDisabled(t,e=!0){let i=this._tools.get(String(t));return i&&(i.element.disabled=!!e),this}setTools(t){for(let i of this._tools.values())i.element.remove();this._tools=new Map;let e=[];for(let i of uS(t)){let n=this._createTool(i);this._tools.set(n.id,n),e.push(n.element)}return this.refs.tools.prepend(...e),this}getTool(t){return this._tools.get(String(t))?.element??null}getToolsElement(){return this.refs.tools}addTool(t){if(!E(t))throw new TypeError("ListToolbar.addTool() needs an Element");return this.refs.tools.contains(t)?this:(this._adopted.push(lp(t)),this.refs.tools.append(t),this)}setView(t,{silent:e=!1}={}){let i=ap(this._views,t,this._view);if(i===null||i===this._view)return this;let n=this._view;return this._view=i,this._syncViews(),e||this.emit("viewchange",{view:i,previous:n}),this}getView(){return this._view}getSearch(){return this._search?this._search.get():""}setSearch(t,e={}){return this._search?.set(t,e),this}focusSearch(){return this._search?.focus(),this}bind(t){if(t===null||typeof t!="object")throw new TypeError("ListToolbar.bind() needs a record view");this.unbind();let e=cS(t);if(this._bound={view:t,capabilities:e},e.getShape){let i=t[e.getShape]();i!=null&&this.setView(String(i),{silent:!0})}return this._mountFieldControls(t),this}unbind(){let t=this._bound;if(this._bound=null,this._chooser){let e=this._chooser;this._chooser=null;let i=t?.view;e.viaView&&i&&typeof i.mountFieldControls=="function"?this.el.contains(e.element)&&i.mountFieldControls(null):cp(e,this.el)}return this}destroy(){if(this._destroyed)return;this._destroyed=!0,this.unbind();for(let e of this._adopted.reverse())cp(e,this.el);this._adopted=[],this._search?.destroy(),this._search=null;let t=this.el;super.destroy(),this._createdRoot||S(t,this._snapshot)}_searchOptions(){let t=this.options.search;if(t===!1||t===null)return null;let e=t===!0||t===void 0?{}:t;if(typeof e!="object"||Array.isArray(e))throw new TypeError("ListToolbar search must be an options object or false");return{...e,placeholder:String(e.placeholder??this._message("listToolbar.search","Search"))}}_countFormat(){let t=this.options.countText;return typeof t=="function"?e=>String(t(e)):e=>this._message("listToolbar.results","%1 results",e.toLocaleString())}_createTool(t){let e=l("button",{class:"zx-list-toolbar__tool",type:"button",disabled:t.disabled,dataset:{toolId:t.id},ariaPressed:t.pressed===null?null:String(t.pressed)});t.icon&&e.append(b(t.icon,{size:16})),t.label!==""&&e.append(l("span",{class:"zx-list-toolbar__tool-label"},t.label));let i={id:t.id,element:e,label:t.label||t.title||t.id,title:t.title,badge:t.badge,badgeKind:t.badgeKind,badgeEl:null,toggle:t.pressed!==null,pressed:!!t.pressed,onclick:t.onclick};return this._syncTool(i),i}_syncTool(t){if(t.badgeEl?.remove(),t.badgeEl=null,t.badge!==null){let i=ht({label:t.badge,kind:t.badgeKind,size:"sm"});i.classList.add("zx-list-toolbar__badge"),i.setAttribute("aria-hidden","true"),t.badgeEl=i,t.element.append(i)}let e=dS(t.label,t.badge,this._message("listToolbar.toolBadge","%1 (%2)"));t.element.setAttribute("aria-label",e),t.element.setAttribute("title",t.title??e)}_toolClick(t){let i=t.target?.closest?.("[data-tool-id]");if(!i||!this.refs.tools.contains(i))return;let n=this._tools.get(String(i.dataset.toolId));n&&(n.toggle&&this.setPressed(n.id,!n.pressed),this.emit("action",{id:n.id,pressed:n.toggle?n.pressed:null,tool:n.element}),n.onclick?.(t))}_viewClick(t){let i=t.target?.closest?.("[data-view]");!i||!this.refs.views.contains(i)||this.setView(String(i.dataset.view))}_syncViews(){if(!this.refs.views)return;let t=this.refs.views;t.childElementCount!==this._views.length&&t.replaceChildren(...this._views.map(e=>{let i=e.label??this._viewLabel(e.id),n=l("button",{class:"zx-list-toolbar__view",type:"button",title:i,dataset:{view:e.id}}),r=e.icon===void 0?op[e.id]?.icon??null:e.icon;return r&&n.append(b(r,{size:16})),n.append(l("span",{class:"zx-list-toolbar__view-label"},i)),n}));for(let e of t.children){let i=e.dataset.view===this._view;e.setAttribute("aria-pressed",i?"true":"false")}}_viewLabel(t){let e=op[t];return e?this._message(e.key,e.fallback):t}_mountFieldControls(t){if(t.options?.fieldControls===!1)return;let e=this._findFieldControls(t);if(!(!e||this.el.contains(e))){if(typeof t.mountFieldControls=="function"){let i=t.mountFieldControls(this.refs.tools);E(i)&&this.el.contains(i)&&(this._chooser={element:i,parent:null,next:null,viaView:!0});return}this._chooser=lp(e),this.refs.tools.append(e)}}_findFieldControls(t){if(typeof t.getFieldControls=="function"){let i=t.getFieldControls();return E(i)?i:null}let e=typeof t.toElement=="function"?t.toElement():null;return E(e)?e.querySelector(".zx-record-view__field-controls"):null}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function cS(s){let t=s,e=n=>!!t&&typeof t[n]=="function",i=(...n)=>n.find(e)??null;return{isRecordView:e("setViewState")&&e("getViewState")&&e("on")&&e("toElement"),setShape:i("setView","setViewShape"),getShape:i("getView","getViewShape"),events:e("on")&&e("emit"),fieldControls:e("getFieldControls")}}function up(s){return s==null||s===!1||s===""?null:String(s)}function dS(s,t,e="%1 (%2)"){let i=String(s??"");return t==null||t===""?i:T(e,[i,String(t)])}function uS(s){if(s!=null&&!Array.isArray(s))throw new TypeError("ListToolbar tools must be an array");let t=new Set,e=[];for(let i of s??[]){if(i==null)continue;if(typeof i!="object"||Array.isArray(i))throw new TypeError("ListToolbar tools must be tool descriptors");let n=String(i.id??"").trim();if(!n)throw new TypeError("Every ListToolbar tool needs an id");if(t.has(n))throw new TypeError(`Duplicate ListToolbar tool: ${n}`);t.add(n),e.push({id:n,label:String(i.label??""),icon:i.icon??null,badge:up(i.badge),badgeKind:String(i.badgeKind??"accent"),pressed:i.pressed===void 0?null:!!i.pressed,disabled:!!i.disabled,title:i.title===void 0?null:String(i.title),onclick:typeof i.onclick=="function"?i.onclick:null})}return e}function hS(s){if(s!=null&&!Array.isArray(s))throw new TypeError("ListToolbar views must be an array");let t=new Set,e=[];for(let i of s??[]){if(i==null)continue;let n=typeof i=="object"?i:{id:i},r=String(n.id??"").trim();if(!r||t.has(r))continue;t.add(r);let o={id:r};n.label!==void 0&&(o.label=String(n.label)),n.icon!==void 0&&(o.icon=n.icon),e.push(o)}return e}function ap(s,t,e){let i=s.map(n=>n.id);return i.length===0?null:t!=null&&i.includes(String(t))?String(t):e===null?i[0]:i.includes(e)?e:i[0]}function fS(s,t){let e=hp(s);return e===null?"":String(t(e))}function hp(s){if(s==null||s===""||typeof s=="boolean")return null;let t=Number(s);return Number.isFinite(t)?t:null}function lp(s){return{element:s,parent:s.parentNode,next:s.nextSibling}}function cp(s,t){let{element:e,parent:i,next:n}=s;if(t?.contains(e)){if(!i){e.remove();return}n&&n.parentNode===i?i.insertBefore(e,n):i.appendChild(e)}}function dp(s){return String(s.detail?.value??"")}var fp=Object.freeze({text:{icon:"type",key:"viewSettings.typeText",label:"Text"},number:{icon:"hash",key:"viewSettings.typeNumber",label:"Number"},money:{icon:"hash",key:"viewSettings.typeMoney",label:"Money"},date:{icon:"calendar",key:"viewSettings.typeDate",label:"Date"},datetime:{icon:"calendar",key:"viewSettings.typeDatetime",label:"Date and time"},time:{icon:"clock",key:"viewSettings.typeTime",label:"Time"},boolean:{icon:"check",key:"viewSettings.typeBoolean",label:"Checkbox"},select:{icon:"circle-chevron-down",key:"viewSettings.typeSelect",label:"Select"},status:{icon:"circle-chevron-down",key:"viewSettings.typeStatus",label:"Status"},priority:{icon:"circle-chevron-down",key:"viewSettings.typePriority",label:"Priority"},entity:{icon:"folder",key:"viewSettings.typeEntity",label:"Linked record"},tags:{icon:"tag",key:"viewSettings.typeTags",label:"Tags"},url:{icon:"link-2",key:"viewSettings.typeUrl",label:"URL"},email:{icon:"mail",key:"viewSettings.typeEmail",label:"Email"},image:{icon:"image",key:"viewSettings.typeImage",label:"Image"},file:{icon:"file",key:"viewSettings.typeFile",label:"File"},rating:{icon:"star",key:"viewSettings.typeRating",label:"Rating"}}),go=Object.freeze({string:"text",textarea:"text",int:"number",integer:"number",float:"number",decimal:"number",percent:"number",currency:"money",enum:"select",bool:"boolean",checkbox:"boolean",link:"url"}),pS=new Set(["text","select","status","priority","boolean","entity"]),pp=Object.freeze(["fields","grouping","board"]),_S=4,yp=32,wp=12,bo=class extends y{static cssName="view-settings";static defaults={fields:[],fieldOrder:[],hiddenFields:[],groupBy:null,grouping:!0,board:!1,types:{},searchThreshold:8,headingLevel:3,label:null};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._fields=Kl(this.options.fields),this._ownIds=new Set(this._fields.map(r=>r.id)),this._order=_o(this._fields,this.options.fieldOrder),this._hidden=mo(this._fields,this.options.hiddenFields,!0);let t=this._fields.length?this._fields.map(r=>r.id):null;this._groupBy=Re(this.options.groupBy,t),this._board=Le(this.options.board,t);let e=this.options.board;this._boardFields=e&&Array.isArray(e.fields)?e.fields.map(String):null,this._sections=AS(this.options.sections,this.options),this._query="",this._search=null,this._groupSelect=null,this._columnSelect=null,this._laneSelect=null,this._emptyToggle=null,this._bound=null,this._syncing=!1,this._rendering=!1,this._grab=null,this._drag=null,this._announceToken=0,this._level=kS(this.options.headingLevel);let i=this.el??l("div");this.el=i,i.setAttribute("role","region"),i.setAttribute("aria-label",this.options.label??this._message("viewSettings.label","View settings")),this._instructionsId=x("zx-view-settings-help");let n=[];for(let r of this._sections)r==="fields"&&n.push(this._buildFieldsSection()),r==="grouping"&&n.push(this._buildGroupSection()),r==="board"&&n.push(this._buildBoardSection());if(n.push(l("span",{class:"zx-view-settings__instructions",id:this._instructionsId,hidden:!0},this._message("viewSettings.instructions","Press Space to pick the field up, the arrow keys to move it, Space again to drop it, or Escape to cancel."))),n.push(l("div",{class:"zx-view-settings__status",ref:"status",role:"status",ariaLive:"polite",ariaAtomic:"true"})),i.replaceChildren(...n),this.refs.list){let r=this.refs.list;this.listen(r,"click",o=>this._onShownClick(o)),this.listen(r,"keydown",o=>this._onHandleKeydown(o)),this.listen(r,"focusout",o=>this._onHandleFocusout(o)),this.listen(r,"pointerdown",o=>this._onPointerDown(o)),this.listen(r,"pointermove",o=>this._onPointerMove(o)),this.listen(r,"pointerup",o=>this._onPointerUp(o)),this.listen(r,"pointercancel",()=>this._cancelDrag()),this.listen(r,"lostpointercapture",()=>{this._drag&&!this._drag.ending&&this._cancelDrag()}),this.listen(this.refs.hidden,"click",o=>this._onHiddenClick(o)),this.listen(i.ownerDocument??document,"keydown",o=>{let a=o;a.key!=="Escape"||!this._drag?.active||(a.preventDefault(),a.stopPropagation(),this._cancelDrag(!0))},{capture:!0}),this._syncSearch(),this._renderFields()}return this._syncGroupControls(),i}getState(){return{fieldOrder:[...this._order],hiddenFields:this._order.filter(t=>this._hidden.has(t)),groupBy:this._groupBy,board:this._board?{...this._board}:null}}setState(t,{silent:e=!1}={}){this._settle();let i=t&&typeof t=="object"?t:{},n=this._fields.length?this._fields.map(d=>d.id):null,r=!1,o=!1;if(Array.isArray(i.fieldOrder)){let d=_o(this._fields,i.fieldOrder);r=!Vi(d,this._order),this._order=d}if(Array.isArray(i.hiddenFields)){let d=mo(this._fields,i.hiddenFields,!1);o=!zS(d,this._hidden),this._hidden=d}let a=!1;if(Object.hasOwn(i,"groupBy")){let d=Re(i.groupBy,n);a=d!==this._groupBy,this._groupBy=d}let c=!1;if(Object.hasOwn(i,"board")&&this._board){let d=Le({...this._board,...i.board??{}},n);c=!bp(d,this._board),this._board=d}return this._renderFields(),this._syncGroupControls(),(r||o)&&this._pushToView(),e?this:(r&&this._emitOrder(),o&&this._emitVisibility(),a&&this._emitGroup(),c&&this._emitBoard(),this)}setFields(t){this._settle();let e=this._order.filter(a=>this._hidden.has(a)),i=[...this._order];this._fields=Kl(t),this._ownIds=new Set(this._fields.map(a=>a.id)),this._order=_o(this._fields,i);let n=new Set(i),r=[...e,...this._fields.filter(a=>!n.has(a.id)&&a.visible===!1).map(a=>a.id)];this._hidden=mo(this._fields,r,!1);let o=this._fields.map(a=>a.id);return this._groupBy=Re(this._groupBy,o),this._board&&(this._board=Le(this._board,o)),this._syncSearch(),this._renderFields(),this._syncGroupControls(),this}getFields(){let t=new Map(this._fields.map(e=>[e.id,e]));return this._order.map(e=>({...t.get(e)}))}showField(t){let e=String(t);if(!this._hidden.has(e))return this;this._settle();let i=bS(this._order,this._hidden,e),n=!Vi(i.order,this._order);return this._order=i.order,this._hidden=new Set(i.hidden),this._renderFields(),this._pushToView(),n&&this._emitOrder(!1),this._emitVisibility(),this}hideField(t){let e=String(t);return this._canHide(e)?(this._settle(),this._hidden.add(e),this._renderFields(),this._pushToView(),this._emitVisibility(),this):this}moveField(t,e){this._settle();let i=po(this._order,this._hidden,this._lockedIds(),String(t),e);return Vi(i,this._order)?this:(this._order=i,this._renderFields(),this._pushToView(),this._emitOrder(),this)}bind(t,e={}){let i=t;if(!i||typeof i.getFields!="function"||typeof i.setFieldOrder!="function"||typeof i.setFieldVisible!="function"||typeof i.getHiddenFields!="function")throw new TypeError("ViewSettings.bind() needs a record view");this.unbind();let n=new AbortController;this._bound={view:i,controller:n},i.addEventListener("statechange",a=>{if(this._syncing)return;let c=a.detail?.reason;this._pullFromView(c==="fields"||c==="restore")},{signal:n.signal}),this._pullFromView(!0);let r=i.options??{},o=this._fields.map(a=>a.id);return typeof r.groupBy=="string"&&(this._groupBy=Re(r.groupBy,o)),this._board&&(e.board?this._board=Le(e.board,o):typeof r.columnBy=="string"&&(this._board=Le({columnBy:r.columnBy,swimlaneBy:typeof r.swimlaneBy=="string"?r.swimlaneBy:null,showEmptyColumns:r.showEmptyColumns!==!1},o))),this._syncGroupControls(),this}unbind(){return this._bound&&(this._bound.controller.abort(),this._bound=null),this}focus(){return this._search?(this._search.focus(),this):(this.el.querySelector(".zx-view-settings__list button:not(:disabled), .zx-view-settings__hidden button:not(:disabled), .zx-select__input, .zx-toggle")?.focus(),this)}destroy(){if(this._destroyed)return;this._destroyed=!0,this.unbind(),this._drag&&this._endDrag(this._drag);for(let e of[this._search,this._groupSelect,this._columnSelect,this._laneSelect,this._emptyToggle])e?.destroy();this._search=null,this._groupSelect=null,this._columnSelect=null,this._laneSelect=null,this._emptyToggle=null;let t=this.el;super.destroy(),this._createdRoot||S(t,this._snapshot)}_heading(t,e=0,i="zx-view-settings__heading"){let n=x("zx-view-settings-heading"),r=Math.min(6,this._level+e);return{element:l(`h${r}`,{class:i,id:n},t),id:n}}_buildFieldsSection(){let t=this._heading(this._message("viewSettings.fields","Fields")),e=this._heading("",1,"zx-view-settings__subheading"),i=this._heading("",1,"zx-view-settings__subheading");return this.refs.shownHeading=e.element,this.refs.hiddenHeading=i.element,l("section",{class:"zx-view-settings__section",ref:"fieldsSection",dataset:{section:"fields"},ariaLabelledby:t.id},t.element,e.element,l("div",{class:"zx-view-settings__frame",ref:"frame"},l("ul",{class:"zx-view-settings__list",ref:"list",ariaLabelledby:e.id}),l("div",{class:"zx-view-settings__drop-indicator",ref:"indicator",ariaHidden:"true",hidden:!0})),i.element,l("div",{class:"zx-view-settings__search-slot",ref:"searchSlot"}),l("ul",{class:"zx-view-settings__hidden",ref:"hidden",ariaLabelledby:i.id}),l("p",{class:"zx-view-settings__empty",ref:"empty",hidden:!0}))}_buildGroupSection(){let t=this._message("viewSettings.group","Group by"),e=this._heading(t);this._groupSelect=new $(null,{items:[],clearable:!0,noneLabel:this._message("viewSettings.none","None"),placeholder:this._message("viewSettings.none","None"),label:t,renderItem:n=>this._optionContent(n),renderValueAdornment:n=>this._typeGlyph(n.type),msg:this.options.msg}),this._groupSelect.on("change",n=>{let r=n.detail.value;this._setGroup(r==null?null:String(r))});let i=this._groupSelect.toElement();return i.classList.add("zx-view-settings__group"),l("section",{class:"zx-view-settings__section",dataset:{section:"grouping"},ariaLabelledby:e.id},e.element,i)}_buildBoardSection(){let t=this._heading(this._message("viewSettings.board","Board")),e=this._message("viewSettings.columns","Columns"),i=this._message("viewSettings.swimlanes","Swim lanes"),n=a=>this._optionContent(a),r=a=>this._typeGlyph(a.type);this._columnSelect=new $(null,{items:[],placeholder:this._message("viewSettings.chooseField","Choose a field"),label:e,renderItem:n,renderValueAdornment:r,msg:this.options.msg}),this._laneSelect=new $(null,{items:[],clearable:!0,noneLabel:this._message("viewSettings.none","None"),placeholder:this._message("viewSettings.none","None"),label:i,renderItem:n,renderValueAdornment:r,msg:this.options.msg}),this._emptyToggle=new J(null,{label:this._message("viewSettings.emptyColumns","Show empty columns"),checked:this._board?.showEmptyColumns!==!1}),this._columnSelect.on("change",a=>{let c=a.detail.value;this._setBoard({columnBy:c==null?null:String(c)})}),this._laneSelect.on("change",a=>{let c=a.detail.value;this._setBoard({swimlaneBy:c==null?null:String(c)})}),this._emptyToggle.on("change",a=>{this._setBoard({showEmptyColumns:!!a.detail.checked})});let o=this._emptyToggle.toElement();return o.classList.add("zx-view-settings__toggle"),l("section",{class:"zx-view-settings__section zx-view-settings__board",dataset:{section:"board"},ariaLabelledby:t.id},t.element,l("div",{class:"zx-view-settings__setting"},l("span",{class:"zx-view-settings__setting-label",ariaHidden:"true"},e),this._columnSelect.toElement()),l("div",{class:"zx-view-settings__setting"},l("span",{class:"zx-view-settings__setting-label",ariaHidden:"true"},i),this._laneSelect.toElement()),o)}_syncSearch(){let t=this.refs.searchSlot;if(!t)return;let e=this._fields.length>Math.max(0,Number(this.options.searchThreshold)||0);if(e&&!this._search){let i=this._message("viewSettings.search","Find a field");this._search=new Ot(null,{placeholder:i,debounce:0,msg:this.options.msg});let n=this._search.toElement();n.classList.add("zx-view-settings__search"),n.setAttribute("aria-label",i);let r=this._search.refs.input;this.listen(r,"input",()=>this._setQuery(r.value)),this._search.on("clear",()=>this._setQuery("")),this._search.on("submit",()=>this._addFirstMatch()),t.replaceChildren(n)}else!e&&this._search&&(this._search.destroy(),this._search=null,t.replaceChildren(),this._query="")}_renderFields(t=null,{keepGrab:e=!1}={}){let i=this.refs.list;if(!i)return;if(this._drag&&this._endDrag(this._drag),this._grab&&!e){let h=this._grab.id;this._grab=null,this._announceCanceled(h)}let n=t??this._activePart();this._rendering=!0;let r=new Map(this._fields.map(h=>[h.id,h])),o=this._order.filter(h=>!this._hidden.has(h)),a=this._order.filter(h=>this._hidden.has(h)),c=o.length>1;i.replaceChildren(...o.map(h=>this._shownRow(r.get(h),c))),this.refs.shownHeading.textContent=this._message("viewSettings.shown","Shown (%1)",o.length),this.refs.hiddenHeading.textContent=this._message("viewSettings.hidden","Hidden (%1)",a.length);let d=a.map(h=>r.get(h)).filter(h=>gS(h,this._query,this._typeLabel(h.type)));this.refs.hidden.replaceChildren(...d.map(h=>this._hiddenRow(h)));let u=this.refs.empty;if(d.length===0?(u.textContent=a.length===0?this._message("viewSettings.allShown","Every field is shown."):this._message("viewSettings.noMatch","No hidden field matches \u201C%1\u201D.",this._query.trim()),u.hidden=!1):u.hidden=!0,this.refs.hidden.hidden=d.length===0,this._grab){let h=this._row(this._grab.id);h&&(h.dataset.state="grabbed"),h?.querySelector(".zx-view-settings__handle")?.setAttribute("aria-pressed","true")}this._rendering=!1,n&&this._focusPart(n)}_shownRow(t,e){let i=!!t.locked,n=this._message("viewSettings.reorder","Reorder %1",t.label),r=this._message("viewSettings.hide","Hide %1",t.label),o=i?l("span",{class:"zx-view-settings__handle",dataset:{placeholder:"true"},ariaHidden:"true"}):l("button",{class:"zx-view-settings__handle",type:"button",ariaLabel:n,ariaDescribedby:this._instructionsId,ariaPressed:"false",title:n,dataset:{action:"handle"}},b("drag",{size:16})),a=i?l("span",{class:"zx-view-settings__lock",title:this._message("viewSettings.locked","Always shown")},b("lock",{size:14}),l("span",{class:"zx-view-settings__sr"},this._message("viewSettings.locked","Always shown"))):l("button",{class:"zx-view-settings__hide",type:"button",ariaLabel:r,title:e?r:this._message("viewSettings.lastField","At least one field stays shown"),disabled:!e,dataset:{action:"hide"}},b("eye",{size:16}));return l("li",{class:"zx-view-settings__row",dataset:{fieldId:t.id,locked:i?"true":null}},o,l("span",{class:"zx-view-settings__label"},t.label),this._typeBadge(t.type),a)}_hiddenRow(t){let e=this._message("viewSettings.addField","Add %1",t.label);return l("li",{class:"zx-view-settings__row",dataset:{fieldId:t.id}},l("span",{class:"zx-view-settings__label"},Ks(t.label,this._query)),this._typeBadge(t.type),l("button",{class:"zx-btn zx-view-settings__add",type:"button",ariaLabel:e,title:e,dataset:{kind:"ghost",size:"sm",action:"add"}},b("plus",{size:14}),l("span",{},this._message("viewSettings.add","Add"))))}_typeBadge(t){let e=this._typeLabel(t);return l("span",{class:"zx-view-settings__type",title:e},this._typeGlyph(t),l("span",{class:"zx-view-settings__sr"},`, ${e}`))}_typeGlyph(t){return b(_p(t,this.options.types).icon,{size:14})}_typeLabel(t){let e=_p(t,this.options.types);return e.key?this._message(e.key,e.label):e.label}_optionContent(t){return l("span",{class:"zx-view-settings__option",title:this._typeLabel(t.type)},this._typeGlyph(t.type),l("span",{},t.name))}_syncGroupControls(){let t=mp(this._fields,this.options.grouping),e=mp(this._fields,this._boardFields?{fields:this._boardFields}:this.options.grouping),i=n=>n.map(r=>{let o=this._fields.find(a=>a.id===r);return{ID:o.id,name:o.label,type:o.type}});this._groupSelect&&(this._groupSelect.setItems(i(t)),this._groupSelect.set(this._groupBy,{silent:!0})),this._board&&this._columnSelect&&this._laneSelect&&this._emptyToggle&&(this._columnSelect.setItems(i(e)),this._columnSelect.set(this._board.columnBy,{silent:!0}),this._laneSelect.setItems(i(e.filter(n=>n!==this._board?.columnBy))),this._laneSelect.set(this._board.swimlaneBy,{silent:!0}),this._emptyToggle.set(this._board.showEmptyColumns!==!1,{silent:!0}))}_setQuery(t){t!==this._query&&(this._query=t,this._renderFields())}_addFirstMatch(){let e=this.refs.hidden?.querySelector(".zx-view-settings__row")?.dataset.fieldId;e&&this._addFromPanel(e,!1)}_addFromPanel(t,e){let i=[...this.refs.hidden.querySelectorAll(".zx-view-settings__row")],n=i.findIndex(c=>c.dataset.fieldId===t),r=(i[n+1]??i[n-1])?.dataset.fieldId;this.showField(t);let o=this._field(t),a=this._order.filter(c=>!this._hidden.has(c));this._announce(this._message("viewSettings.added","%1 added at position %2 of %3",o?.label??t,a.indexOf(t)+1,a.length)),e&&(r?this._focusPart({id:r,part:"add"}):this._search?this._search.focus():this._focusPart({id:t,part:"hide"}))}_onHiddenClick(t){let n=t.target?.closest?.('[data-action="add"]')?.closest(".zx-view-settings__row")?.dataset.fieldId;n&&this._addFromPanel(n,!0)}_onShownClick(t){let n=t.target?.closest?.('[data-action="hide"]')?.closest(".zx-view-settings__row")?.dataset.fieldId;if(!n||!this._canHide(n))return;let r=this._order.filter(d=>!this._hidden.has(d)),o=r.indexOf(n),c=[...r.slice(o+1),...r.slice(0,o).reverse()].find(d=>this._canHideAfter(d,n));this.hideField(n),this._announce(this._message("viewSettings.hiddenField","%1 hidden",this._field(n)?.label??n)),c?this._focusPart({id:c,part:"hide"}):this.focus()}_onHandleKeydown(t){let i=t.target?.closest?.('[data-action="handle"]')?.closest(".zx-view-settings__row")?.dataset.fieldId;if(!i)return;let n=this._movableIds(),r=n.indexOf(i);if(r<0)return;let o=this._grab?.id===i,a=null;if(t.key==="ArrowUp"?a=r-1:t.key==="ArrowDown"?a=r+1:t.key==="Home"?a=0:t.key==="End"&&(a=n.length-1),a!==null){if(t.preventDefault(),a<0||a>=n.length||a===r)return;this._moveFromKeyboard(i,a,!o);return}if(t.key===" "||t.key==="Enter"){t.preventDefault(),o?this._drop():this._pickUp(i);return}t.key==="Escape"&&o&&(t.preventDefault(),t.stopPropagation(),this._cancelGrab())}_onHandleFocusout(t){if(this._rendering||!this._grab)return;t.target?.closest?.('[data-action="handle"]')?.closest(".zx-view-settings__row")?.dataset.fieldId===this._grab.id&&this._drop(this._partOf(t.relatedTarget))}_moveFromKeyboard(t,e,i){let n=po(this._order,this._hidden,this._lockedIds(),t,e);Vi(n,this._order)||(this._order=n,this._renderFields({id:t,part:"handle"},{keepGrab:!i}),this._announceMove(t),i&&(this._pushToView(),this._emitOrder()))}_pickUp(t){this._grab={id:t,original:[...this._order]},this._renderFields({id:t,part:"handle"},{keepGrab:!0});let{position:e,total:i}=this._position(t);this._announce(this._message("viewSettings.grabbed","%1 picked up, position %2 of %3. Use the arrow keys to move it, Space to drop it, Escape to cancel.",this._field(t)?.label??t,e,i))}_drop(t){let e=this._grab;if(!e)return;this._grab=null;let i=!Vi(e.original,this._order),n=this._row(e.id)?.contains(this.el.ownerDocument?.activeElement??null);this._renderFields(t!==void 0?t:n?{id:e.id,part:"handle"}:null);let{position:r,total:o}=this._position(e.id);this._announce(this._message("viewSettings.dropped","%1 dropped at position %2 of %3",this._field(e.id)?.label??e.id,r,o)),i&&(this._pushToView(),this._emitOrder())}_cancelGrab(){let t=this._grab;t&&(this._grab=null,this._order=t.original,this._renderFields({id:t.id,part:"handle"}),this._announceCanceled(t.id))}_settle(){this._drag&&this._cancelDrag(!0),this._grab&&this._cancelGrab()}_announceCanceled(t){let{position:e,total:i}=this._position(t);this._announce(this._message("viewSettings.canceled","Move canceled. %1 is back at position %2 of %3",this._field(t)?.label??t,e,i))}_onPointerDown(t){if(t.button!==0||this._drag)return;let e=t.target?.closest?.('[data-action="handle"]'),i=e?.closest(".zx-view-settings__row")??null,n=i?.dataset.fieldId;if(!(!e||!i||!n)&&!(this._grab&&(this._drop(),i=this._row(n),e=i?.querySelector('[data-action="handle"]')??null,!i||!e))){this._drag={id:n,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,y:t.clientY,active:!1,ending:!1,handle:e,row:i,target:null,scroller:null,startScroll:0,lastScroll:0,frame:0};try{e.setPointerCapture(t.pointerId)}catch{}}}_onPointerMove(t){let e=this._drag;if(!(!e||t.pointerId!==e.pointerId)){if(!e.row.isConnected){this._cancelDrag();return}if(e.y=t.clientY,!e.active){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<=_S)return;this._beginDrag(e)}t.preventDefault(),this._positionDrag(e)}}_onPointerUp(t){let e=this._drag;if(!e||t.pointerId!==e.pointerId)return;if(!e.active||!e.row.isConnected){this._endDrag(e);return}t.preventDefault(),e.y=t.clientY,this._positionDrag(e);let i=e.target;this._endDrag(e);let n=i===null?this._order:po(this._order,this._hidden,this._lockedIds(),e.id,i);if(Vi(n,this._order)){this._renderFields({id:e.id,part:"handle"});return}this._order=n,this._renderFields({id:e.id,part:"handle"}),this._announceMove(e.id),this._pushToView(),this._emitOrder()}_beginDrag(t){t.active=!0,t.row.dataset.dragging="true",this.el.setAttribute("data-dragging","true"),this.el.ownerDocument?.getSelection?.()?.removeAllRanges(),t.scroller=xS(this.refs.list),t.startScroll=t.scroller.scrollTop,t.lastScroll=t.startScroll,this._scheduleAutoScroll(t);let{position:e,total:i}=this._position(t.id);this._announce(this._message("viewSettings.dragging","%1 picked up, position %2 of %3",this._field(t.id)?.label??t.id,e,i))}_scheduleAutoScroll(t){t.frame=requestAnimationFrame(()=>{if(t.frame=0,this._drag!==t||!t.active||!t.scroller)return;let e=vS(t.y,SS(t.scroller),this.refs.list.getBoundingClientRect(),yp,wp);e!==0&&(t.scroller.scrollTop+=e),t.scroller.scrollTop!==t.lastScroll&&this._positionDrag(t),this._scheduleAutoScroll(t)})}_positionDrag(t){let e=t.scroller?t.scroller.scrollTop:0;t.lastScroll=e;let i=t.y-t.startY+(e-t.startScroll);t.row.style.transform=`translateY(${Math.round(i)}px)`,this._updateDropTarget(t,t.y)}_updateDropTarget(t,e){let i=this.refs.frame.getBoundingClientRect(),n=[...this.refs.list.children].filter(_=>_!==t.row).map(_=>{let m=_.getBoundingClientRect();return{id:_.dataset.fieldId??"",top:m.top-i.top,bottom:m.bottom-i.top,middle:m.top+m.height/2}}),r=yS(n.map(_=>_.middle),e),o=this._lockedIds(),a=n.slice(0,r).filter(_=>!o.includes(_.id)).length;t.target=a;let c=po(this._order,this._hidden,o,t.id,a).filter(_=>!this._hidden.has(_)),d=c[c.indexOf(t.id)+1],u=n.find(_=>_.id===d),h=n.at(-1),f=this.refs.indicator,p=u?u.top:h?h.bottom:0;f.style.insetBlockStart=`${Math.round(p)}px`,f.hidden=!1}_endDrag(t){t.ending=!0,t.frame&&cancelAnimationFrame(t.frame),t.frame=0;try{t.handle.releasePointerCapture(t.pointerId)}catch{}t.row.style.transform="",delete t.row.dataset.dragging,this.el.removeAttribute("data-dragging");let e=this.refs.indicator;e&&(e.hidden=!0),this._drag===t&&(this._drag=null)}_cancelDrag(t=!1){let e=this._drag;if(!e)return;let i=e.active;if(this._endDrag(e),!!i&&t){let{position:n,total:r}=this._position(e.id);this._announce(this._message("viewSettings.canceled","Move canceled. %1 is back at position %2 of %3",this._field(e.id)?.label??e.id,n,r))}}_setGroup(t){t!==this._groupBy&&(this._groupBy=t,this._emitGroup())}_setBoard(t){if(!this._board)return;let e=this._fields.map(n=>n.id),i=Le({...this._board,...t},e);bp(i,this._board)||(this._board=i,this._syncGroupControls(),this._emitBoard())}_emitOrder(t=!0){this.emit("fieldorderchange",{order:[...this._order]}),t&&this._emitChange("order")}_emitVisibility(){let t=this.getState();this.emit("fieldvisibilitychange",{visible:t.fieldOrder.filter(e=>!this._hidden.has(e)),hidden:t.hiddenFields}),this._emitChange("visibility")}_emitGroup(){this.emit("groupchange",{field:this._groupBy}),this._emitChange("group")}_emitBoard(){this._board&&(this.emit("boardchange",{board:{...this._board}}),this._emitChange("board"))}_emitChange(t){this.emit("change",{state:this.getState(),reason:t})}_pushToView(){let t=this._bound;if(!t)return;let e=t.view;this._syncing=!0;try{let i=new Set((e.getFieldOrder?.()??[]).map(String)),n=this._order.filter(o=>i.size===0||i.has(o));e.setFieldOrder(n);let r=new Set((e.getHiddenFields()??[]).map(String));for(let o of n)!this._hidden.has(o)&&r.has(o)&&e.setFieldVisible(o,!0);for(let o of n)this._hidden.has(o)&&!r.has(o)&&e.setFieldVisible(o,!1)}finally{this._syncing=!1}}_pullFromView(t){let e=this._bound;if(!e)return;let i=e.view;if(this._settle(),t){let r=new Map(this._fields.map(a=>[a.id,a])),o=i.getFields().filter(a=>this._ownIds.size===0||this._ownIds.has(String(a.id))).map(a=>wS(r.get(String(a.id))??null,a));this._fields=Kl(o),this._syncSearch()}this._order=_o(this._fields,i.getFieldOrder?.()??this._order),this._hidden=mo(this._fields,i.getHiddenFields(),!1,!0);let n=this._fields.map(r=>r.id);this._groupBy=Re(this._groupBy,n),this._board&&(this._board=Le(this._board,n)),this._renderFields(),t&&this._syncGroupControls()}_lockedIds(){return this._fields.filter(t=>t.locked).map(t=>t.id)}_movableIds(){let t=new Set(this._lockedIds());return this._order.filter(e=>!this._hidden.has(e)&&!t.has(e))}_field(t){return this._fields.find(e=>e.id===t)}_canHide(t){let e=this._field(t);return!e||e.locked||this._hidden.has(t)?!1:this._order.filter(i=>!this._hidden.has(i)).length>1}_canHideAfter(t,e){let i=this._field(t);return!i||i.locked?!1:this._order.filter(n=>!this._hidden.has(n)&&n!==e).length>1}_row(t){return[...this.refs.list?.children??[]].find(e=>e.dataset.fieldId===t)??null}_position(t){let e=this._order.filter(i=>!this._hidden.has(i));return{position:e.indexOf(t)+1,total:e.length}}_announceMove(t){let{position:e,total:i}=this._position(t);this._announce(this._message("viewSettings.moved","%1 moved to position %2 of %3",this._field(t)?.label??t,e,i))}_activePart(){return this._partOf(this.el.ownerDocument?.activeElement??null)}_partOf(t){let e=t;if(!e||!this.el.contains(e))return null;let i=e.dataset?.action,n=e.closest(".zx-view-settings__row")?.dataset.fieldId;return!n||i!=="handle"&&i!=="hide"&&i!=="add"?null:{id:n,part:i}}_focusPart(t){let i=[...(t.part==="add"?this.refs.hidden:this.refs.list)?.children??[]].find(r=>r.dataset.fieldId===t.id),n=i?.querySelector(`[data-action="${t.part}"]`)??null;n&&n.disabled&&(n=null),!n&&i&&(n=i.querySelector("button:not(:disabled)")),n?.focus()}_announce(t){let e=this.refs.status;if(!e)return;let i=++this._announceToken;e.textContent="",queueMicrotask(()=>{i===this._announceToken&&e.isConnected&&(e.textContent=t)})}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function Kl(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("ViewSettings fields must be an array");let t=new Set,e=[];return s.forEach((i,n)=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`ViewSettings field at index ${n} must be an object`);let r=String(i.id??"").trim();if(!r)throw new TypeError(`ViewSettings field at index ${n} requires an id`);if(t.has(r))throw new TypeError(`Duplicate ViewSettings field: ${r}`);t.add(r);let o={...i,id:r,label:String(i.label??vp(r)),type:String(i.type??"text").trim()||"text",locked:!!i.locked};i.groupable!==void 0&&(o.groupable=!!i.groupable),e.push(o)}),e}function _p(s,t=null){let e=String(s??"").trim()||"text",i=Object.hasOwn(go,e)?go[e]:e,n=Object.hasOwn(fp,i)?fp[i]:null,r=t&&typeof t=="object"?Object.hasOwn(t,e)?t[e]:Object.hasOwn(t,i)?t[i]:null:null,o=n?i:e,a=String(r?.icon??n?.icon??"type");return r?.label!=null?{type:o,icon:a,label:String(r.label),key:null}:n?{type:o,icon:a,label:n.label,key:n.key}:{type:o,icon:a,label:vp(e),key:null}}function mS(s){let t=String(s??"").trim()||"text";return pS.has(Object.hasOwn(go,t)?go[t]:t)}function mp(s,t){if(t&&typeof t=="object"&&Array.isArray(t.fields)){let e=new Set(s.map(i=>i.id));return[...new Set(t.fields.map(String))].filter(i=>e.has(i))}return s.filter(e=>e.groupable===!0||e.groupable!==!1&&mS(e.type)).map(e=>e.id)}function gS(s,t,e=""){let i=gp(t).split(/\s+/).filter(Boolean);if(i.length===0)return!0;let n=gp(`${s.label??""} ${s.id} ${e}`);return i.every(r=>n.includes(r))}function po(s,t,e,i,n){let r=new Set(t),o=new Set(e),a=s.filter(m=>!r.has(m)),c=a.filter(m=>!o.has(m)),d=c.indexOf(i);if(d<0)return[...s];let u=Number.isFinite(Number(n))?Math.round(Number(n)):d,h=Math.max(0,Math.min(c.length-1,u));if(h===d)return[...s];c.splice(d,1),c.splice(h,0,i);let f=0,p=a.map(m=>o.has(m)?m:c[f++]),_=0;return s.map(m=>r.has(m)?m:p[_++])}function bS(s,t,e){let i=new Set(t);if(!s.includes(e)||!i.has(e))return{order:[...s],hidden:[...i]};i.delete(e);let n=s.filter(o=>o!==e),r=-1;return n.forEach((o,a)=>{i.has(o)||(r=a)}),n.splice(r+1,0,e),{order:n,hidden:n.filter(o=>i.has(o))}}function yS(s,t){let e=s.findIndex(i=>t<i);return e<0?s.length:e}function wS(s,t){if(!s)return{...t};let e=t.type==null?"":String(t.type).trim(),i=e&&e!=="text"?e:s.type??(e||"text");return{...s,...t,label:t.label??s.label,type:i}}function vS(s,t,e,i=yp,n=wp){return s<t.top+i&&e.top<t.top?-n:s>t.bottom-i&&e.bottom>t.bottom?n:0}function xS(s){let t=s.ownerDocument.scrollingElement??s.ownerDocument.documentElement,e=s.parentElement;for(;e&&e!==t&&e!==s.ownerDocument.body;){let i=getComputedStyle(e).overflowY;if(/(auto|scroll|overlay)/.test(i)&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return t}function SS(s){let t=s.ownerDocument.defaultView;if(s===s.ownerDocument.scrollingElement||s===s.ownerDocument.documentElement)return{top:0,bottom:t?.innerHeight??s.clientHeight};let e=s.getBoundingClientRect();return{top:e.top,bottom:e.bottom}}function AS(s,t={}){let e=Array.isArray(s)?s.map(String):[...pp];return[...new Set(e)].filter(n=>pp.includes(n)).filter(n=>n==="grouping"?t.grouping!==!1&&t.grouping!=null:n==="board"?!!t.board&&typeof t.board=="object":!0)}function Le(s,t=null){if(!s||typeof s!="object")return null;let e=s,i=Re(e.columnBy,t),n=Re(e.swimlaneBy,t);return n!==null&&n===i&&(n=null),{columnBy:i,swimlaneBy:n,showEmptyColumns:e.showEmptyColumns!==!1}}function Re(s,t){if(s==null||s==="")return null;let e=String(s);return t&&!t.includes(e)?null:e}function _o(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Array.isArray(t)?[...new Set(t.map(String))].filter(r=>i.has(r)):[];return[...n,...e.filter(r=>!n.includes(r))]}function mo(s,t,e,i=!1){let n=new Set(s.filter(o=>i||!o.locked).map(o=>o.id)),r=new Set(Array.isArray(t)?t.map(String).filter(o=>n.has(o)):[]);if(e)for(let o of s)o.visible===!1&&n.has(o.id)&&r.add(o.id);return s.length&&r.size>=s.length&&r.delete(s[0].id),r}function kS(s){let t=Number(s??3);return Number.isInteger(t)&&t>=2&&t<=6?t:3}function gp(s){return String(s??"").normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().trim()}function vp(s){let t=String(s).split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Vi(s,t){return s.length===t.length&&s.every((e,i)=>e===t[i])}function zS(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function bp(s,t){return!s||!t?s===t:s.columnBy===t.columnBy&&s.swimlaneBy===t.swimlaneBy&&s.showEmptyColumns===t.showEmptyColumns}var js=Object.freeze([B("contains","contains","single",["text"]),B("notContains","does not contain","single",["text"]),B("eq","is","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),B("neq","is not","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),B("startsWith","starts with","single",["text"]),B("endsWith","ends with","single",["text"]),B("lt","is less than","single",["number","money"]),B("lte","is at most","single",["number","money"]),B("gt","is greater than","single",["number","money"]),B("gte","is at least","single",["number","money"]),B("on","is on","single",["date","datetime"]),B("notOn","is not on","single",["date","datetime"]),B("before","is before","single",["date","datetime"]),B("onOrBefore","is on or before","single",["date","datetime"]),B("after","is after","single",["date","datetime"]),B("onOrAfter","is on or after","single",["date","datetime"]),B("between","is between","pair",["number","money","date","datetime"]),B("notBetween","is not between","pair",["number","money","date","datetime"]),B("withinLast","is within the last","pair",["date","datetime"]),B("withinNext","is within the next","pair",["date","datetime"]),B("anyOf","is any of","many",["enum","status","priority","country","currency","unit","entity"]),B("noneOf","is none of","many",["enum","status","priority","country","currency","unit","entity"]),B("containsAny","contains any","many",["tags"]),B("containsAll","contains all","many",["tags"]),B("containsNone","contains none","many",["tags"]),B("isEmpty","is empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"]),B("isNotEmpty","is not empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"])]);function vo(){return{version:1,root:{kind:"group",id:x("filter-root"),logic:"and",children:[]}}}function xo(s={}){return{kind:"condition",id:String(s.id||x("filter-condition")),field:String(s.field??""),operator:String(s.operator??""),value:So(s.value??null)}}function So(s){return wo(s)}function Ao(s="and",t=[]){return{kind:"group",id:x("filter-group"),logic:s,children:t}}function Pe(s,t={}){let e=xp(t.maxDepth,3),i=xp(t.maxConditions,50);if(!yo(s)||s.version!==1||!yo(s.root))throw new TypeError("Filter AST must have version 1 and a root group");let n=new Set,r=0,o=(c,d,u=!1)=>{if(!yo(c))throw new TypeError("Filter nodes must be plain objects");let h=String(c.id??"").trim();if(!h||n.has(h))throw new TypeError("Filter node IDs must be non-empty and unique");if(n.add(h),c.kind==="group"){if(d>e)throw new RangeError("Filter group depth exceeds maxDepth");if(c.logic!=="and"&&c.logic!=="or")throw new TypeError("Filter group logic must be and or or");if(!Array.isArray(c.children))throw new TypeError("Filter group children must be an array");return{kind:"group",id:h,logic:c.logic,children:c.children.map(f=>o(f,d+1,!1))}}if(u||c.kind!=="condition")throw new TypeError("Filter root must be a group");if(r+=1,r>i)throw new RangeError("Filter condition count exceeds maxConditions");return{kind:"condition",id:h,field:String(c.field??""),operator:String(c.operator??""),value:wo(c.value)}},a=o(s.root,0,!0);if(a.kind!=="group")throw new TypeError("Filter root must be a group");return{version:1,root:a}}function Hs(s){return Pe(s,{maxDepth:1/0,maxConditions:1/0})}function Sp(s){return JSON.stringify(Hs(s))}function ko(s,t,e=js){let i=[],n=new Map((Array.isArray(t)?t:[]).map(a=>[String(a.id),a])),r=new Map((Array.isArray(e)?e:[]).map(a=>[String(a.id),a])),o=(a,c=!1)=>{if(a.kind==="group"){!c&&a.children.length===0&&i.push(Vs(a.id,"empty-group","Nested groups need at least one condition")),a.children.forEach(h=>o(h));return}let d=n.get(a.field);d||i.push(Vs(a.id,"unknown-field",a.field?`Unavailable field: ${a.field}`:"Choose a field"));let u=r.get(a.operator);if(!u){i.push(Vs(a.id,"unknown-operator",a.operator?`Unavailable operator: ${a.operator}`:"Choose an operator"));return}d&&(!(Array.isArray(d.operators)&&d.operators.length?d.operators:e.filter(f=>f.types.includes(d.type)).map(f=>f.id)).includes(u.id)||!u.types.includes(d.type))&&i.push(Vs(a.id,"operator-type",`${u.label} is not available for ${d.label}`)),CS(u.arity,a.value)||i.push(Vs(a.id,"value",u.arity==="pair"?"Enter both values":u.arity==="many"?"Choose at least one value":u.arity==="none"?"This operator does not accept a value":"Enter a value"))};return o(s.root,!0),{valid:i.length===0,errors:i}}function B(s,t,e,i){return Object.freeze({id:s,label:t,arity:e,types:Object.freeze(i)})}function Vs(s,t,e){return{nodeId:s,code:t,message:e}}function CS(s,t){return s==="none"?t===null:s==="pair"?Array.isArray(t)&&t.length===2&&t.every(Ul):s==="many"?Array.isArray(t)&&t.length>0&&t.every(Ul):Ul(t)}function Ul(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function wo(s,t=new WeakSet){if(s===null||typeof s=="string"||typeof s=="boolean")return s;if(typeof s=="number"){if(!Number.isFinite(s))throw new TypeError("Filter values cannot contain non-finite numbers");return s}if(typeof s!="object"||s instanceof Date||typeof s.nodeType=="number")throw new TypeError("Filter values must be JSON-safe");if(t.has(s))throw new TypeError("Filter values cannot contain cycles");if(t.add(s),Array.isArray(s)){let i=s.map(n=>wo(n,t));return t.delete(s),i}if(!yo(s))throw new TypeError("Filter values must be plain JSON objects");let e={};for(let[i,n]of Object.entries(s))Object.defineProperty(e,i,{value:wo(n,t),enumerable:!0,configurable:!0,writable:!0});return t.delete(s),e}function yo(s){if(!s||typeof s!="object"||Array.isArray(s))return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function xp(s,t){if(s===1/0)return 1/0;let e=Number(s);return Number.isFinite(e)&&e>=0?Math.floor(e):t}var TS=new Set(["withinLast","withinNext"]),ji=Object.freeze(["days","weeks","months"]),IS=Object.freeze({days:"days",weeks:"weeks",months:"months"}),Tp=Object.freeze({choose:"Choose\u2026",yes:"True",no:"False",commaSeparated:"Comma-separated values",value:s=>`${s} value`,valueAt:(s,t)=>`${s} value ${t}`}),To=class extends y{static cssName="filter";static defaults={fields:[],value:null,operators:[],allowGroups:!0,maxDepth:3,maxConditions:50,autoApply:!1,readonly:!1,disabled:!1,searchable:!1,layout:"standard",rootLogic:null,showApply:!0,showRootActions:!0,applyLabel:null,clearLabel:null};render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._fields=(Array.isArray(this.options.fields)?this.options.fields:[]).map(e=>({...e})),this._operators=PS(js,this.options.operators),this._readonly=!!this.options.readonly,this._disabled=!!this.options.disabled,this._async=new Map,this._customEditors=[],this._selectEditors=[],this._disposed=!1,t.dataset.layout=this.options.layout==="compact"?"compact":"standard",this._value=this.options.value==null?vo():Pe(this.options.value,this._limits()),this.listen(t,"change",e=>this._handleChange(e)),this.listen(t,"input",e=>this._handleInput(e)),this.listen(t,"click",e=>this._handleClick(e)),this._render(),t}getValue(){return Hs(this._value)}setValue(t,{silent:e=!1}={}){let i=Pe(t,this._limits());return this._abortAll(),this._value=i,this._render(),e||this._changed("set",this._value.root.id),this}addCondition(t=null,e={}){if(!this._canMutate()||Mp(this._value.root)>=Number(this.options.maxConditions))return null;let i=Co(this._value.root,t??this._value.root.id);if(!i)return null;let n=this._fields[0],r=String(e.field??n?.id??""),o=this._field(r),a=xo({...e,field:r,operator:String(e.operator??this._defaultOperator(o)??"")});return i.children.push(a),this._render(),this._changed("add",a.id),this.focus(a.id),a.id}addGroup(t=null,e="and"){if(!this._canMutate()||!this.options.allowGroups)return null;let i=Co(this._value.root,t??this._value.root.id);if(!i||Dp(this._value.root,i.id)>=Number(this.options.maxDepth))return null;let n=Ao(e==="or"?"or":"and");return i.children.push(n),this._render(),this._changed("add",n.id),this.focus(n.id),n.id}update(t,e={}){if(!this._canMutate())return this;let i=Tt(this._value.root,t);return i?(i.kind==="group"?(e.logic==="and"||e.logic==="or")&&(i.logic=e.logic):(Object.hasOwn(e,"field")&&(i.field=String(e.field??"")),Object.hasOwn(e,"operator")&&(i.operator=String(e.operator??"")),Object.hasOwn(e,"value")&&(i.value=Cp(e.value))),this._abort(t),this._render(),this._changed("update",t),this):this}remove(t){if(!this._canMutate()||t===this._value.root.id)return this;let e=Wl(this._value.root,t);if(!e)return this;let i=e.children.findIndex(a=>a.id===t),n=e.children[i+1]?.id??e.children[i-1]?.id??e.id,r=Ep(this._value.root,t);if(!r)return this;this._abortTree(r),this._render();let o=r.kind==="condition"?this._field(r.field)?.label??this._message("filter.conditionNoun","Filter"):this._message("filter.groupNoun","Filter group");return this._announce(this._message("filter.removed","%1 removed",o)),this._changed("remove",t),this.focus(n),this}move(t,e,i){let n=Tt(this._value.root,t),r=Co(this._value.root,e),o=Wl(this._value.root,t);if(!this._canMutate()||t===this._value.root.id||!n||!r||!o||RS(n,e))return this;let a=o.children.findIndex(d=>d.id===t),c=o.children.splice(a,1)[0];r.children.splice(Math.max(0,Math.min(r.children.length,Number(i)||0)),0,c);try{Pe(this._value,this._limits())}catch{return r.children.splice(r.children.indexOf(c),1),o.children.splice(a,0,c),this}return this._render(),this._changed("move",t),this}validate(){let t=ko(this._value,this._fields,this._operators);for(let i of Ip(this._value.root)){if(!Gl(this._operator(i.operator))||NS(i.value)===null)continue;let n=this._message("filter.relativeInvalid","Enter a whole number of days, weeks or months"),r=t.errors.find(o=>o.nodeId===i.id&&o.code==="value");r?r.message=n:t.errors.push({nodeId:i.id,code:"value",message:n}),t.valid=!1}let e=BS(this._value,this.options.rootLogic);return e&&(t.valid=!1,t.errors.push(e)),t}apply(){if(this._disabled)return null;let t=this.validate();if(!t.valid)return this.emit("invalid",{errors:t.errors}),this.focus(t.errors[0]?.nodeId),null;let e=this.getValue();return this.emit("apply",{value:e}),e}clear({silent:t=!1}={}){return this._canMutate()?(this._abortAll(),this._value.root.children=[],this._render(),t||this._changed("clear",this._value.root.id),this.refs.add?.focus(),this):this}focus(t=null){let e=t?`[data-node-id="${Xt(t)}"] :is([data-filter-field], [data-filter-focus="field"], [data-filter-logic], [data-filter-action="add"])`:'[data-filter-action="add"]';return queueMicrotask(()=>{if(this._disposed)return;(this.el.querySelector(e)??this.refs.add)?.focus()}),this}setReadonly(t){return this._readonly=!!t,this._render(),this}enable(){return this._disabled=!1,this._render(),this}disable(){return this._disabled=!0,this._abortAll(),this._render(),this}destroy(){this._disposed=!0,this._renderVersion+=1,this._abortAll(),this._destroyEditors();let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&S(t,e)}_render(){this._destroyEditors(),this._renderVersion=(this._renderVersion??0)+1;let t=l("div",{ref:"status",class:"zx-filter__status",role:"status",ariaLive:"polite"}),e=this._renderGroup(this._value.root,0,!0),i=l("div",{class:"zx-filter__actions"},ge("add",this._value.root.id,"plus",this._message("filter.addFilter","Add filter"),{ref:"add",disabled:this._blocked()}),this.options.allowGroups?ge("add-group",this._value.root.id,"folder",this._message("filter.addGroup","Add group"),{disabled:this._blocked()}):null,ge("clear","","x",String(this.options.clearLabel??this._message("filter.clear","Clear")),{disabled:this._blocked()}),this.options.showApply?ge("apply","","check",String(this.options.applyLabel??this._message("filter.apply","Apply filters")),{kind:"primary",disabled:this._disabled}):null);this.el.replaceChildren(t,e,i),this.refs.status=t,this.refs.add=this.el.querySelector('[data-filter-action="add"]'),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-disabled",this._disabled);let n=this.validate();this.el.dataset.valid=String(n.valid);for(let r of n.errors)this.el.querySelector(`[data-node-id="${Xt(r.nodeId)}"]`)?.setAttribute("data-invalid","")}_renderGroup(t,e,i){let n=l("ol",{class:"zx-filter__children"},t.children.map((c,d)=>{let u=c.kind==="group"?this._renderGroup(c,e+1,!1):this._renderCondition(c);return d>0&&this.options.layout==="compact"&&u.prepend(this._connector(t,i)),u})),r=l("select",{class:"zx-filter__logic",dataset:{filterLogic:"",nodeId:t.id},ariaLabel:i?this._message("filter.rootLogic","Root filter logic"):this._message("filter.groupLogic","Group filter logic"),disabled:this._blocked()},l("option",{value:"and",selected:t.logic==="and"},this._message("filter.matchAll","Match all")),l("option",{value:"or",selected:t.logic==="or"},this._message("filter.matchAny","Match any"))),o=l("legend",{class:"zx-filter__legend"},i&&this.options.rootLogic?t.logic==="or"?this._message("filter.matchAnyConditions","Match any conditions"):this._message("filter.matchAllConditions","Match all conditions"):[r,l("span",{},i?this._message("filter.conditions","conditions"):this._message("filter.inThisGroup","in this group"))]),a=l("div",{class:"zx-filter__group-actions"},ge("add",t.id,"plus",this._message("filter.addFilter","Add filter"),{disabled:this._blocked()}),this.options.allowGroups&&e<Number(this.options.maxDepth)?ge("add-group",t.id,"folder",this._message("filter.addSubgroup","Add subgroup"),{disabled:this._blocked()}):null,i?null:ge("remove",t.id,"trash",this._message("filter.removeGroup","Remove group"),{disabled:this._blocked(),ariaLabel:this._message("filter.removeGroup","Remove group")}));return l(i?"fieldset":"li",{class:"zx-filter__group",dataset:{nodeId:t.id,depth:String(e)}},i?o:l("fieldset",{},o,n,a),i?n:null,i&&this.options.showRootActions?a:null)}_connector(t,e){let{word:i,name:n}=Ap(t.logic,(r,o,...a)=>this._message(r,o,...a));return this._blocked()||e&&this.options.rootLogic?l("span",{class:"zx-filter__connector",ariaHidden:"true",dataset:{connector:t.id}},i):l("button",{type:"button",class:"zx-filter__connector",tabindex:"-1",dataset:{filterAction:"toggle-logic",nodeId:t.id,connector:t.id},ariaLabel:n},i)}_syncConnectors(t){let{word:e,name:i}=Ap(t.logic,(n,r,...o)=>this._message(n,r,...o));for(let n of this.el.querySelectorAll(`[data-connector="${Xt(t.id)}"]`))n.textContent=e,n.tagName==="BUTTON"&&n.setAttribute("aria-label",i)}_renderCondition(t){let e=this._field(t.field),i=this._operatorsFor(e),n=this._operator(t.operator),r=this._fields.map(d=>({value:d.id,label:d.label,icon:d.icon}));t.field&&!e&&r.push({value:t.field,label:this._unavailable(t.field)});let o=i.map(d=>({value:d.id,label:d.label}));t.operator&&!i.some(d=>d.id===t.operator)&&o.push({value:t.operator,label:this._unavailable(t.operator)});let a=this.options.searchable?this._searchSelect(r,t.field,this._message("filter.field","Filter field"),t.id,"field",d=>{let u=this._field(String(d));this.update(t.id,{field:String(d),operator:this._defaultOperator(u)??"",value:null}),this.focus(t.id)}):l("select",{class:"zx-filter__field",dataset:{filterField:"",nodeId:t.id},ariaLabel:this._message("filter.field","Filter field"),disabled:this._blocked()},l("option",{value:"",selected:!t.field},this._message("filter.chooseField","Choose a field\u2026")),this._fields.map(d=>l("option",{value:d.id,selected:d.id===t.field},d.label)),t.field&&!e?l("option",{value:t.field,selected:!0},this._unavailable(t.field)):null),c=this.options.searchable?this._searchSelect(o,t.operator,this._message("filter.operator","Filter operator"),t.id,"operator",d=>{this.update(t.id,{operator:String(d),value:null}),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${Xt(t.id)}"] :is([data-filter-value], [data-filter-focus="value"])`)?.focus())}):l("select",{class:"zx-filter__operator",dataset:{filterOperator:"",nodeId:t.id},ariaLabel:this._message("filter.operator","Filter operator"),disabled:this._blocked()},l("option",{value:"",selected:!t.operator},this._message("filter.chooseOperator","Choose an operator\u2026")),i.map(d=>l("option",{value:d.id,selected:d.id===t.operator},d.label)),t.operator&&!i.some(d=>d.id===t.operator)?l("option",{value:t.operator,selected:!0},this._unavailable(t.operator)):null);return l("li",{class:"zx-filter__condition",dataset:{nodeId:t.id}},a,c,this._renderValue(t,e,n),this._removeConditionButton(t,e))}_renderValue(t,e,i){let n=l("div",{class:"zx-filter__value"});if(!e||!i)return n;if(i.arity==="none")return l("div",{class:"zx-filter__value zx-filter__value--empty"},this._message("filter.noValue","No value"));if(e.type==="custom"&&typeof e.editor=="function"){let d=this._renderVersion;return queueMicrotask(()=>{if(d!==this._renderVersion||!this.el.contains(n))return;let u=e.editor(n,{value:t.value,field:e,conditionId:t.id,setValue:h=>this._setNodeValue(t.id,Cp(h))});u&&typeof u.destroy=="function"&&this._customEditors.push(u)}),n}let r=this._valueMessages();if(Gl(i))return this._relativeDateEditor(t,e);let o=i.arity==="pair"?Array.isArray(t.value)?t.value:[null,null]:[t.value];if(i.arity==="many"){if(this.options.searchable&&Array.isArray(e.choices)&&e.choices.length)return l("div",{class:"zx-filter__value",dataset:{arity:"many"}},this._tagPicker(e,t,r));let d=kp(e,t,o[0],!0,this._blocked(),0,r);return d?l("div",{class:"zx-filter__value"},d):l("div",{class:"zx-filter__value"},zp(e,t.id,Array.isArray(t.value)?t.value.join(", "):"",0,this._blocked(),!0,r))}let a=e.choices?.length?e.choices:e.type==="boolean"?[{value:!0,label:r.yes},{value:!1,label:r.no}]:null,c=o.map((d,u)=>this.options.searchable&&a?this._searchSelect(a,d,i.arity==="pair"?r.valueAt(e.label,u+1):r.value(e.label),t.id,"value",h=>{let f=i.arity==="pair"?Array.isArray(t.value)?[...t.value]:[null,null]:null;f&&(f[u]=h),this._setNodeValue(t.id,f??h)}):kp(e,t,d,!1,this._blocked(),u,r)??zp(e,t.id,d,u,this._blocked(),!1,r));return l("div",{class:"zx-filter__value",dataset:{arity:i.arity}},c)}_relativeDateEditor(t,e){let i=DS(t.value),n=l("input",{type:"number",min:"1",step:"1",inputMode:"numeric",value:i.amount===null?"":String(i.amount),dataset:{filterValue:"",filterRelative:"amount",nodeId:t.id,valueIndex:"0"},ariaLabel:this._message("filter.relativeAmount","%1: number of units",e.label),disabled:this._blocked()}),r=l("select",{dataset:{filterValue:"",filterRelative:"unit",nodeId:t.id,valueIndex:"1"},ariaLabel:this._message("filter.relativeUnit","%1: unit",e.label),disabled:this._blocked()},ji.map(o=>l("option",{value:o,selected:o===i.unit},this._message(`filter.unit.${o}`,IS[o]))));return l("div",{class:"zx-filter__value",dataset:{arity:"relative"}},l("span",{class:"zx-filter__value-control"},n),l("span",{class:"zx-filter__value-control"},r))}_searchSelect(t,e,i,n,r,o){let a=this._renderVersion,c=t.some(u=>Yl(u)!==null)?{renderItem:u=>l("span",{class:"zx-filter__choice"},Yl(u)??l("span",{class:"zx-filter__choice-icon"}),l("span",{class:"zx-filter__choice-label"},String(u.label??""))),renderValueAdornment:u=>Yl(u)}:{},d=new $(null,{items:t,valueKey:"value",labelKey:"label",value:e,label:i,filter:"local",disabled:this._blocked(),placeholder:this._message("filter.choosePart","Choose %1\u2026",r),...c,onchange:({detail:u})=>queueMicrotask(()=>{!this._disposed&&a===this._renderVersion&&this._canMutate()&&o(u.value)})});return this._selectEditors.push(d),d.el.classList.add("zx-filter__picker"),d.refs.input.dataset.filterFocus=r,d.refs.input.dataset.nodeId=n,d.el}_tagPicker(t,e,i){let n=this.options,r=n.lang??n.language,o=new re(null,{items:OS(t.choices),valueKey:"value",labelKey:"label",values:Array.isArray(e.value)?e.value:[],disabled:this._blocked(),placeholder:i.choose,msg:LS(this.options.msg,"tagPicker.input",i.value(t.label)),...r?{lang:r}:{},onchange:({detail:a})=>{!this._disposed&&this._canMutate()&&this._setNodeValue(e.id,FS(a.values))}});return this._selectEditors.push(o),o.el.classList.add("zx-filter__picker"),o.refs.input&&(o.refs.input.dataset.filterFocus="value",o.refs.input.dataset.nodeId=e.id),o.el}_handleChange(t){if(!this._canMutate())return;let e=t.target,i=e?.dataset.nodeId;if(!(!e||!i))if(e.dataset.filterField!==void 0){let n=Tt(this._value.root,i);if(n?.kind!=="condition")return;n.field=e.value;let r=this._field(n.field);n.operator=this._defaultOperator(r)??"",n.value=null,this._abort(i),this._render(),this._changed("update",i),this.focus(i)}else if(e.dataset.filterOperator!==void 0){let n=Tt(this._value.root,i);if(n?.kind!=="condition")return;n.operator=e.value,n.value=null,this._abort(i),this._render(),this._changed("update",i),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${Xt(i)}"] [data-filter-value]`)?.focus())}else if(e.dataset.filterLogic!==void 0){let n=Tt(this._value.root,i);n?.kind==="group"&&!(n===this._value.root&&this.options.rootLogic)&&(n.logic=e.value==="or"?"or":"and"),n?.kind==="group"&&this._syncConnectors(n),this._changed("update",i)}else e.dataset.filterValue!==void 0&&this._valueInput(e)}_handleInput(t){if(!this._canMutate())return;let e=t.target;if(!e||e.dataset.filterValue===void 0)return;this._valueInput(e);let i=e.dataset.nodeId,n=Tt(this._value.root,i),r=n?.kind==="condition"?this._field(n.field):null;r?.loadChoices&&this._scheduleChoices(n.id,r,e.value)}_valueInput(t){let e=Tt(this._value.root,t.dataset.nodeId);if(e?.kind!=="condition")return;let i=this._operator(e.operator),n=this._field(e.field);if(!i||!n)return;let r;if(Gl(i)){let o=t.closest(".zx-filter__value"),a=o?.querySelector('[data-filter-relative="amount"]')??null,c=o?.querySelector('[data-filter-relative="unit"]')??null;r=MS(a?.value??"",c?.value??ji[0])}else if(t instanceof HTMLSelectElement&&t.multiple)r=Array.from(t.selectedOptions,o=>zo(o.value,n.type));else if(i.arity==="many")r=t.value.split(",").map(o=>o.trim()).filter(Boolean).map(o=>zo(o,n.type));else if(i.arity==="pair"){let o=Array.isArray(e.value)?[...e.value]:[null,null];o[Number(t.dataset.valueIndex)||0]=zo(t.value,n.type),r=o}else r=zo(t.value,n.type);this._setNodeValue(e.id,r)}_handleClick(t){let e=t.target?.closest?.("[data-filter-action]");if(!e||!this.el.contains(e))return;let i=e.dataset.filterAction,n=e.dataset.nodeId||null;if(i==="add")this.addCondition(n);else if(i==="add-group")this.addGroup(n);else if(i==="remove"&&n)this.remove(n);else if(i==="clear")this.clear();else if(i==="toggle-logic"&&n){let r=ES(this._value,n,this.options.rootLogic);if(!r)return;this.update(n,{logic:r}),this.focus(n)}else i==="apply"&&this.apply()}_setNodeValue(t,e){let i=Tt(this._value.root,t);if(i?.kind!=="condition")return;i.value=e;let n=this.validate();this.el.dataset.valid=String(n.valid),this.el.querySelector(`[data-node-id="${Xt(t)}"]`)?.toggleAttribute("data-invalid",n.errors.some(o=>o.nodeId===t)),this._changed("update",t)}_changed(t,e){let i=this.validate(),n=this.getValue();this.emit("change",{value:n,valid:i.valid,errors:i.errors,reason:t,nodeId:e}),this.options.autoApply&&i.valid&&this.emit("apply",{value:n})}_scheduleChoices(t,e,i){if(this._abort(t),i.length<Number(e.minQuery??0))return;let n=new AbortController;this._setAsyncBusy(t,!0);let r={controller:n,timer:setTimeout(async()=>{this.emit("query",{conditionId:t,fieldId:e.id,query:i});try{let o=await e.loadChoices({query:i,signal:n.signal,conditionId:t,field:e});if(n.signal.aborted||this._async.get(t)?.controller!==n)return;let c=this.el.querySelector(`[data-node-id="${Xt(t)}"] [data-filter-value]`)?.getAttribute("list"),d=c?this.el.querySelector(`#${Xt(c)}`):null;d&&d.replaceChildren(...(Array.isArray(o)?o:[]).map(u=>l("option",{value:u.value},u.label))),this.emit("loaded",{conditionId:t,fieldId:e.id,query:i,choices:o})}catch(o){n.signal.aborted||this.emit("error",{conditionId:t,fieldId:e.id,query:i,error:o instanceof Error?o:new Error(String(o))})}finally{this._async.get(t)?.controller===n&&(this._async.delete(t),this._setAsyncBusy(t,!1))}},Math.max(0,Number(e.debounce??200)))};this._async.set(t,r)}_abort(t){let e=this._async.get(t);e&&(clearTimeout(e.timer),e.controller.abort(),this._async.delete(t),this._setAsyncBusy(t,!1))}_setAsyncBusy(t,e){let i=this.el.querySelector(`[data-node-id="${Xt(t)}"] [data-filter-value]`);e?i?.setAttribute("aria-busy","true"):i?.removeAttribute("aria-busy")}_abortTree(t){t.kind==="condition"?this._abort(t.id):t.children.forEach(e=>this._abortTree(e))}_abortAll(){for(let t of[...this._async.keys()])this._abort(t)}_destroyEditors(){for(let t of[...this._customEditors??[],...this._selectEditors??[]])t.destroy?.();this._customEditors=[],this._selectEditors=[]}_blocked(){return this._readonly||this._disabled}_canMutate(){return!this._blocked()}_limits(){return{maxDepth:Number(this.options.maxDepth),maxConditions:Number(this.options.maxConditions)}}_field(t){return this._fields.find(e=>e.id===t)??null}_operator(t){return this._operators.find(e=>e.id===t)??null}_operatorsFor(t){if(!t)return[];let e=t.operators?.length?t.operators:null;return this._operators.filter(i=>e?e.includes(i.id):i.types.includes(t.type))}_defaultOperator(t){return t?.defaultOperator&&this._operatorsFor(t).some(e=>e.id===t.defaultOperator)?t.defaultOperator:this._operatorsFor(t)[0]?.id??null}_announce(t){this.refs.status&&(this.refs.status.textContent=t)}_unavailable(t){return this._message("filter.unavailable","Unavailable: %1",t)}_removeConditionButton(t,e){let i=this._message("filter.remove","Remove %1",e?.label??this._message("filter.filterNoun","filter"));return ge("remove",t.id,"trash",i,{disabled:this._blocked(),ariaLabel:i})}_valueMessages(){return{choose:this._message("filter.choose","Choose\u2026"),yes:this._message("filter.booleanTrue","True"),no:this._message("filter.booleanFalse","False"),commaSeparated:this._message("filter.commaSeparated","Comma-separated values"),value:t=>this._message("filter.fieldValue","%1 value",t),valueAt:(t,e)=>this._message("filter.fieldValueAt","%1 value %2",t,e)}}_message(t,e,...i){let n=this.msg(t,...i);return n===t?T(e,i):n}};function ge(s,t,e,i,n={}){let{kind:r,...o}=n;return l("button",{type:"button",class:"zx-btn",...o,dataset:{filterAction:s,nodeId:t,size:"sm",...r?{kind:r}:{}}},b(e),l("span",{},i))}function Ap(s,t=(e,i,...n)=>T(i,n)){let e=s==="or"?t("filter.or","or"):t("filter.and","and"),i=s==="or"?t("filter.switchToAll","%1 \u2014 switch to all",e):t("filter.switchToAny","%1 \u2014 switch to any",e);return{word:e,name:i}}function ES(s,t,e=null){let i=Co(s?.root,t);return!i||i===s.root&&e?null:i.logic==="or"?"and":"or"}function MS(s,t){let e=String(s??"").trim(),i=e===""?NaN:Number(e),n=ji.includes(String(t))?String(t):ji[0];return[Number.isFinite(i)?i:null,n]}function DS(s){return!Array.isArray(s)||s.length!==2||!ji.includes(String(s[1]))?{amount:null,unit:"days"}:{amount:typeof s[0]=="number"&&Number.isFinite(s[0])?s[0]:null,unit:String(s[1])}}function NS(s){return!Array.isArray(s)||s.length!==2?"shape":!ji.includes(String(s[1]))||typeof s[1]!="string"?"unit":typeof s[0]!="number"||!Number.isInteger(s[0])||s[0]<1?"amount":null}function OS(s){return(Array.isArray(s)?s:[]).map(t=>({value:t.value,label:t.label,...t.icon?{icon:t.icon}:{},...t.color?{color:t.color}:{}}))}function FS(s){return So(Array.isArray(s)?[...s]:[])}function LS(s,t,e){let i={};for(let[n,r]of Object.entries(s&&typeof s=="object"?s:{}))i[n]=r&&typeof r=="object"?{...r,[t]:e}:r;return i[t]=e,i}function Yl(s){let t=s?.icon,e=typeof t=="string"&&t?b(t,{size:14}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t.cloneNode(!0):null;return e?l("span",{class:"zx-filter__choice-icon",ariaHidden:"true"},e):null}function kp(s,t,e,i,n,r=0,o=Tp){let a=Array.isArray(s.choices)&&s.choices.length?s.choices:s.type==="boolean"?[{value:!0,label:o.yes},{value:!1,label:o.no}]:null;if(!a)return null;let c=new Set(Array.isArray(e)?e.map(String):[String(e??"")]);return l("select",{dataset:{filterValue:"",nodeId:t.id,valueIndex:String(r)},ariaLabel:o.value(s.label),multiple:i,disabled:n},i?null:l("option",{value:"",selected:!c.has(String(e))||e==null},o.choose),a.map(d=>l("option",{value:d.value,selected:c.has(String(d.value))},d.label)))}function zp(s,t,e,i,n,r=!1,o=Tp){let a=r?"text":["number","money"].includes(s.type)?"number":s.type==="date"?"date":s.type==="datetime"?"datetime-local":"text",c=s.loadChoices?`zx-filter-choices-${t}-${i}`:null,d=l("input",{type:a,value:e??"",dataset:{filterValue:"",nodeId:t,valueIndex:String(i)},ariaLabel:i?o.valueAt(s.label,i+1):o.value(s.label),disabled:n,placeholder:r?o.commaSeparated:"",list:c});return l("span",{class:"zx-filter__value-control"},d,c?l("datalist",{id:c}):null)}function Gl(s){return!!s&&(TS.has(String(s.id))||s.arity==="relative")}function Ip(s){return s?s.kind==="condition"?[s]:s.children.flatMap(t=>Ip(t)):[]}function zo(s,t){if(s==="")return null;if(["number","money"].includes(t)){let e=Number(s);return Number.isFinite(e)?e:null}return t==="boolean"?s==="true":s}function Cp(s){return So(s===void 0?null:s)}function Tt(s,t){if(!s||s.id===t)return s??null;if(s.kind==="group")for(let e of s.children){let i=Tt(e,t);if(i)return i}return null}function Co(s,t){if(!s)return null;let e=Tt(s,t);return e?.kind==="group"?e:null}function Wl(s,t){if(s?.kind!=="group")return null;if(s.children.some(e=>e.id===t))return s;for(let e of s.children){let i=Wl(e,t);if(i)return i}return null}function Ep(s,t){if(s.kind!=="group")return null;let e=s.children.findIndex(i=>i.id===t);if(e>=0)return s.children.splice(e,1)[0];for(let i of s.children){let n=Ep(i,t);if(n)return n}return null}function RS(s,t){return!!(s&&Tt(s,t))}function Mp(s){return s.kind==="condition"?1:s.children.reduce((t,e)=>t+Mp(e),0)}function Dp(s,t,e=0){if(s.id===t)return e;if(s.kind==="group"){for(let i of s.children)if(i.kind==="group"){let n=Dp(i,t,e+1);if(n>=0)return n}}return-1}function PS(s,t){let e=new Map(s.map(i=>[i.id,{...i,types:[...i.types]}]));for(let i of Array.isArray(t)?t:[])i?.id&&e.set(String(i.id),{...i,id:String(i.id),types:Array.isArray(i.types)?[...i.types]:[]});return[...e.values()]}function Xt(s){return globalThis.CSS?.escape?CSS.escape(s):String(s).replaceAll(/[^a-zA-Z0-9_-]/g,"\\$&")}function BS(s,t){return!t||s.root.logic===t?null:{nodeId:s.root.id,code:"root-logic",message:`This filter requires match ${t==="or"?"any":"all"} conditions.`}}var Np=Object.freeze([Object.freeze(["getValue","setValue"]),Object.freeze(["get","set"]),Object.freeze(["getValues","setValues"]),Object.freeze(["isChecked","setChecked"])]),VS=Object.freeze(["value","values","checked"]),Op="input, select, textarea, button",jS="input, textarea";function Io(s){if(E(s))return s;let t=s;if(typeof t.toElement=="function")return t.toElement();if(E(t.el))return t.el;throw new TypeError("External field source must be an Element or a Component")}function Fp(s){return Rp(s,Io(s)).get()}function Ql(s){let t=Io(s),e=E(s)?null:s;if(e&&Jt(e,"isDisabled",0))return!!e.isDisabled();if(e&&typeof e.disabled=="boolean")return e.disabled;if(Hi(t,"disabled"))return!!t.disabled||t.hasAttribute("disabled");if(t.getAttribute("aria-disabled")==="true")return!0;let i=t.getAttribute("data-disabled");if(i!==null&&i!=="false")return!0;let n=[...t.querySelectorAll(Op)];return n.length>0&&n.every(r=>r.disabled)}function Xl(s){let t=Io(s),e=E(s)?null:s;for(let n of["readonly","readOnly"])if(e&&typeof e[n]=="boolean")return e[n];if(Hi(t,"readOnly"))return!!t.readOnly||t.hasAttribute("readonly");if(t.getAttribute("aria-readonly")==="true")return!0;let i=t.getAttribute("data-readonly");return i!==null&&i!=="false"}function Lp(s,t=null){let e=Io(s),i=E(s)?null:s,n=e.parentNode,r=e.nextSibling,o=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(k=>[k,e.getAttribute(k)])),a=i===null,c=a&&Hi(e,"value")?e.value:void 0,d=a&&Bp(e)?e.checked:void 0,u=Ql(s),h=Xl(s),f=new Map,p=Rp(s,e),_=HS(i,e,f),m=qS(i,e,f),g=u,w=h,v=!1,z=p.get();t&&i&&typeof i.addEventListener=="function"&&(t.listen(i,"change",()=>{v||(z=p.get(),t.emit("change",{value:z}))}),t.listen(e,"change",k=>{let M=p.get();$S(M,z)?k.stopImmediatePropagation():z=M}));let C={el:e,get:()=>p.get(),set:(k,M)=>{v=!0;try{p.set(k,M)}finally{v=!1}z=p.get()},focus:()=>{i&&Jt(i,"focus",0)?i.focus():typeof e.focus=="function"&&e.focus()},setDisabled:k=>{g=!!k,_(g)},destroy:()=>{w!==h&&m&&m(h),g!==u&&_(u);for(let[k,M]of f)M.disabled!==void 0&&(k.disabled=M.disabled),M.readOnly!==void 0&&(k.readOnly=M.readOnly);f.clear();for(let[k,M]of o)M===null?e.removeAttribute(k):e.setAttribute(k,M);c!==void 0&&(e.value=c),d!==void 0&&(e.checked=d),n?n.insertBefore(e,r?.parentNode===n?r:null):e.remove()}};return m&&(C.setReadonly=k=>{w=!!k,m(w)}),C}function Rp(s,t){let e=E(s)?null:s;if(e){let i=Np.find(([o])=>Jt(e,o,0)),n=i?Jt(e,i[1],2)?i[1]:Np.map(([,o])=>o).find(o=>Jt(e,o,1)):void 0;if(i)return{get:()=>e[i[0]](),set:(o,a={})=>{n&&e[n](o,{...a,silent:!!a.silent})}};let r=VS.find(o=>o in e);if(r)return{get:()=>e[r],set:o=>{e[r]=o}}}return Bp(t)?{get:()=>!!t.checked,set:i=>{t.checked=!!i}}:Hi(t,"value")?{get:()=>t.value,set:i=>{t.value=i??""}}:{get:()=>null,set:()=>{}}}function HS(s,t,e){return s&&Jt(s,"setDisabled",1)?i=>s.setDisabled(i):s&&Jt(s,"enable",0)&&Jt(s,"disable",0)?i=>i?s.disable():s.enable():s&&typeof s.disabled=="boolean"?i=>{s.disabled=i}:Hi(t,"disabled")?i=>{t.disabled=i}:i=>{t.setAttribute("aria-disabled",String(i));for(let n of t.querySelectorAll(Op))Pp(e,n,"disabled"),n.disabled=i||!!e.get(n)?.disabled}}function qS(s,t,e){if(s){for(let n of["setReadonly","setReadOnly"])if(Jt(s,n,1))return r=>s[n](r);for(let n of["readonly","readOnly"])if(typeof s[n]=="boolean")return r=>{s[n]=r};return null}if(Hi(t,"readOnly"))return n=>{t.readOnly=n};let i=[...t.querySelectorAll(jS)];return i.length?n=>{for(let r of i)Pp(e,r,"readOnly"),r.readOnly=n||!!e.get(r)?.readOnly}:null}function Pp(s,t,e){let i=s.get(t)??{};i[e]===void 0&&(i[e]=!!t[e]),s.set(t,i)}function Jt(s,t,e){let i=s[t];return typeof i=="function"&&i.length<=e}function Hi(s,t){return["INPUT","SELECT","TEXTAREA","BUTTON","FIELDSET","OUTPUT"].includes(s.tagName)&&t in s}function Bp(s){let t=String(s.type??"").toLowerCase();return s.tagName==="INPUT"&&(t==="checkbox"||t==="radio")}function $S(s,t){if(Object.is(s,t))return!0;if(s instanceof Date&&t instanceof Date)return s.getTime()===t.getTime();if(s&&t&&typeof s=="object"&&typeof t=="object")try{return JSON.stringify(s)===JSON.stringify(t)}catch{return!1}return!1}var Be=class extends y{static cssName="fieldset";static defaults={title:"",columns:1,fields:{},idPrefix:null};render(){let t=this.el??l("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):x("zx-fieldset"),this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let n=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}this._grid=l("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let i=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[n,r]of Object.entries(i))this.addField(n,r);return t}addField(t,e){let i=String(t);if(this._fields.has(i))throw new Error(`Field "${i}" already exists`);let n,r=!1;if(e instanceof I)n=e;else if(E(e)||e instanceof y){let o=e;n=new I(null,{id:this._controlId(i),name:i,type:"custom",label:i,value:Fp(o),disabled:Ql(o),readonly:Xl(o),adapter:a=>Lp(o,a)}),r=!0}else{let o=e&&typeof e=="object"?e:{},a=o.id!=null&&String(o.id)!==""&&String(o.id)!==i;n=new I(null,{...o,id:a?String(o.id):this._controlId(i),name:o.name??i}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(i,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=i,this._grid.append(n.el),n}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,i]of this._fields)t[e]=i.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,n]of Object.entries(t))this._fields.get(i)?.setValue(n,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let i=0;for(let[n,r]of this._fields){let o=t?.[n];o?(r.setHighlight(String(o),e),i+=1):r.clearHighlight()}return i}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_controlId(t){return`${this._idPrefix}-${t.trim().replace(/\s+/g,"-")}`}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let i=this._origins.get(t);i?.parent?i.parent.insertBefore(t.el,i.next?.parentNode===i.parent?i.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};var Eo=class extends y{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,idPrefix:null,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??l("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):x("zx-form"),this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=l("div",{class:"zx-form__body"}),this._actions=l("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",i=>{i.preventDefault(),this.submit()}),this.listen(t,"reset",i=>{i.preventDefault(),this.reset()}),this.listen(this._actions,"click",i=>this._handleAction(i));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let i of e)this.addFieldset(i);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof Be),i=e?new Be(null,{...t??{},idPrefix:t?.idPrefix??this._idPrefix}):t;return this._fieldsets.includes(i)||(e?this._ownedFieldsets.add(i):this._origins.set(i,{parent:i.el.parentNode,next:i.el.nextSibling}),this._fieldsets.push(i),this._body.append(i.el),this.listen(i.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:i.getValue(o)})})),i}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,i)=>{let n=String(e.label??e.id??"Action");return l("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!n&&e.title?e.title:void 0,dataset:{actionIndex:i,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?b(e.icon,{size:16}):null,n?l("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let i of this._fieldsets)i.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let i=e.getField(t);if(i)return i}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((i,n)=>i+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),c="";if(o.options.required&&Jl(a))c=this.msg("form.required");else if(!Jl(a)&&o.options.type==="int"){let d=Ko(a);d.valid?o.setValue(d.value,{silent:!0}):c=this.msg("form.int")}else if(!Jl(a)&&o.options.type==="float"){let d=Uo(a);d.valid?o.setValue(d.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let i=this._actionDescriptors[Number(e.dataset.actionIndex)],n=i?.onClick??i?.onclick??i?.handler;typeof n=="function"&&n(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function Jl(s){return s==null||s===""||s===!1||Array.isArray(s)&&s.length===0}var Mo="123456789abcdefghijklmnopqrstuvwxyz";function Vp(s){if(!Array.isArray(s))throw new TypeError("Questionnaire items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Each questionnaire item must be an object");if(typeof e.name!="string"||e.name.trim()==="")throw new TypeError("Each questionnaire item needs a non-empty string name");let i=e.name;if(t.has(i))throw new TypeError(`Item already exists: ${i}`);t.add(i);let n=KS(e.choices??[],i),r=e.field&&typeof e.field=="object"?{...e.field}:null,o=YS(e.input);if(n.length===0&&!r&&!o)throw new TypeError(`Item "${i}" needs choices, an input, or a field`);return{name:i,prompt:String(e.prompt??i),description:e.description==null||e.description===""?null:String(e.description),section:e.section==null?"":String(e.section),required:!!e.required,multiple:!!e.multiple,skippable:!!e.skippable,choices:n,input:o,field:r,when:typeof e.when=="function"?e.when:null,next:typeof e.next=="function"||typeof e.next=="string"&&e.next?e.next:null,validate:typeof e.validate=="function"?e.validate:null}})}function KS(s,t=""){if(!Array.isArray(s))throw new TypeError("Questionnaire choices must be an array");let e=new Set,i=s.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))throw new TypeError("Each questionnaire choice must be an object");if(o.value==null||o.value==="")throw new TypeError(`Each choice of "${t}" needs a value`);let a=typeof o.value=="number"?o.value:String(o.value),c=String(a);if(e.has(c))throw new TypeError(`Choice already exists in "${t}": ${c}`);return e.add(c),{value:a,label:String(o.label??a),description:o.description==null||o.description===""?null:String(o.description),icon:o.icon==null||o.icon===""?null:String(o.icon),key:typeof o.key=="string"&&o.key?o.key.slice(0,1).toLowerCase():"",disabled:!!o.disabled,exclusive:!!o.exclusive}}),n=new Set(i.map(o=>o.key).filter(Boolean)),r=0;for(let o of i)if(!o.key){for(;r<Mo.length&&n.has(Mo[r]);)r+=1;if(r>=Mo.length)break;o.key=Mo[r],n.add(o.key),r+=1}return i}function US(s,t){if(typeof s.when!="function")return!0;try{return s.when(t)!==!1}catch{return!0}}function Zt(s,t){let e={},i=[];for(let n of s)US(n,e)&&(i.push(n),Object.prototype.hasOwnProperty.call(t,n.name)&&(e[n.name]=t[n.name]));return{answers:e,visible:i}}function Do(s,t,e){let{answers:i,visible:n}=Zt(s,e),r=new Set(n.map(c=>c.name)),o=null;if(typeof t.next=="string")o=t.next;else if(typeof t.next=="function"){let c=t.next(i[t.name],i);o=c==null||c===""?null:String(c)}let a=s.indexOf(t);if(o!==null){let c=s.findIndex(d=>d.name===o);if(c<0)throw new RangeError(`Unknown questionnaire item: ${o}`);if(r.has(o))return o;a=c}for(let c=a+1;c<s.length;c+=1)if(r.has(s[c].name))return s[c].name;return null}function Ve(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.every(t=>Ve(t)):!1}function jp(s,t,e){return!s.required||!Ve(t)?null:e(s.choices.length>0?"questionnaire.required":"questionnaire.requiredInput")}function Hp(s,t,e=null){let i=new Set(t.map(r=>String(r))),n=new Set(s.filter(r=>r.exclusive).map(r=>String(r.value)));return n.size>0&&e!==null&&i.has(String(e))&&(n.has(String(e))?i.forEach(r=>r!==String(e)&&i.delete(r)):n.forEach(r=>i.delete(r))),s.filter(r=>i.has(String(r.value))).map(r=>r.value)}function qp(s,t,e){let{answers:i,visible:n}=Zt(s,t),r=new Map(n.map(p=>[p.name,p])),o=e.filter(p=>r.has(p)),a=o.length>0?r.get(o[o.length-1]):null,c=o.filter(p=>!Ve(i[p])).length,d=new Set(o),u=a?n.indexOf(a):-1,h=n.slice(u+1).filter(p=>!d.has(p.name)).length,f=o.length+h;return{index:Math.max(0,o.length-1),answered:c,total:f,percent:f===0?0:Math.round(c/f*100),section:a?.section??""}}function YS(s){if(!s)return null;let t=typeof s=="object"&&!Array.isArray(s)?s:{};return{label:String(t.label??"Other"),placeholder:String(t.placeholder??""),multiline:!!t.multiline,maxLength:Math.max(0,Number(t.maxLength)||0)}}var GS=260,No=class extends y{static cssName="questionnaire";static defaults={items:[],answers:{},active:null,progress:!0,review:!1,advance:"manual",shortcuts:!0,allowBack:!0,msg:{"questionnaire.next":"Continue","questionnaire.previous":"Back","questionnaire.skip":"Skip","questionnaire.submit":"Submit","questionnaire.review":"Review answers","questionnaire.reviewTitle":"Check your answers","questionnaire.edit":"Edit","questionnaire.counter":"Question %1 of %2","questionnaire.required":"Choose an answer to continue.","questionnaire.requiredInput":"Enter an answer to continue.","questionnaire.noAnswer":"Skipped","questionnaire.empty":"There is nothing to answer."}};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._items=[],this._selected=new Map,this._freeform=new Map,this._fields=new Map,this._path=[],this._status="asking",this._returnToReview=!1,this._busy=!1,this._error="",this._advanceTimer=0,this._uid=x("zx-questionnaire");let t=this.el??l("form");if(this.el=t,this._form=t.localName==="form"?t:l("form",{class:"zx-questionnaire__form"}),this._form.setAttribute("novalidate",""),this._progressHost=l("div",{class:"zx-questionnaire__progress",hidden:!this.options.progress}),this._itemHost=l("fieldset",{class:"zx-questionnaire__item",tabIndex:-1}),this._reviewHost=l("div",{class:"zx-questionnaire__review",tabIndex:-1,hidden:!0}),this._actionsHost=l("div",{class:"zx-questionnaire__actions"}),this.refs.item=this._itemHost,this.refs.review=this._reviewHost,this.refs.actions=this._actionsHost,this._bar=new bi(null,{max:100,value:0,size:"sm",showValue:!1}),this._progressHost.append(this._bar.el),this._back=this._action("previous",this.msg("questionnaire.previous"),"chevron-left","default"),this._skip=this._action("skip",this.msg("questionnaire.skip"),null,"ghost"),this._forward=this._action("next",this.msg("questionnaire.next"),"chevron-right","primary"),this._actionsHost.append(this._back,l("span",{class:"zx-questionnaire__spacer"}),this._skip,this._forward),this._form.replaceChildren(this._progressHost,this._itemHost,this._reviewHost,this._actionsHost),this._form!==t&&t.replaceChildren(this._form),this.listen(this._form,"submit",e=>{e.preventDefault(),this.next()}),this.listen(this._itemHost,"change",e=>this._onControlChange(e)),this.listen(this._itemHost,"input",e=>this._onFreeformInput(e)),this.listen(this._actionsHost,"click",e=>this._onActionClick(e)),this.listen(this._reviewHost,"click",e=>this._onReviewClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this.setItems(this.options.items),this.options.answers&&typeof this.options.answers=="object"&&this.setAnswers(this.options.answers,{silent:!0}),this.options.active!=null){let e=String(this.options.active);Zt(this._items,this._rawAnswers()).visible.some(n=>n.name===e)&&(this._path=[e])}return this._paint(),t}setItems(t){let e=this.getActive(),i=Vp(t),n=new Set(i.map(a=>a.name));this._items=i;for(let a of[this._selected,this._freeform])for(let c of[...a.keys()])n.has(c)||a.delete(c);for(let[a,c]of[...this._fields])n.has(a)||(c.destroy(),this._fields.delete(a));let r=Zt(i,this._rawAnswers()).visible,o=this._path.filter(a=>r.some(c=>c.name===a));return e&&o[o.length-1]===e?this._path=o:this._path=r.length>0?[r[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}getItems(){return this._items.map(t=>({...t,choices:t.choices.map(e=>({...e})),input:t.input?{...t.input}:null}))}goTo(t){let e=this._items.find(r=>r.name===t);if(!e)throw new RangeError(`Unknown questionnaire item: ${t}`);if(!Zt(this._items,this._rawAnswers()).visible.includes(e))return!1;let n=this._returnToReview;return this._returnToReview=n||this._status==="review",this._navigate(t,"goto")?!0:(this._returnToReview=n,!1)}async next(){if(this._busy||this._status==="complete")return!1;if(this._status==="review")return this.submit();if(!await this._validateActive()||this._destroyed)return!1;if(this._returnToReview)return this._returnToReview=!1,this._enterReview();let t=this._activeItem(),e=t?Do(this._items,t,this._rawAnswers()):null;return e?this._navigate(e,"next"):this.options.review?this._enterReview():this.submit()}previous(){if(this._busy)return!1;if(this._status==="review"||this._status==="complete"){let n=this._path[this._path.length-1];return!n||this.emit("navigate",{from:null,to:n,reason:"previous"}).defaultPrevented?!1:(this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}if(!this.options.allowBack||this._path.length<=1)return!1;let t=this.getActive(),e=this._path[this._path.length-2];return this.emit("navigate",{from:t,to:e,reason:"previous"}).defaultPrevented?!1:(this._path.pop(),this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}async skip(){let t=this._activeItem();if(!t||!t.skippable||this._busy)return!1;if(this.setAnswer(t.name,null,{silent:!0}),this.emit("skip",{name:t.name}),this._returnToReview)return this._returnToReview=!1,this._enterReview();let e=Do(this._items,t,this._rawAnswers());return e?this._navigate(e,"skip"):this.options.review?this._enterReview():this.submit()}async submit(){if(this._busy||this._status==="complete"||this._status!=="review"&&!await this._validateActive()||this._destroyed)return!1;let t={answers:this.getAnswers(),path:this.getPath()};return this.emit("submit",t).defaultPrevented?!1:(this._status="complete",this._paint(),this.emit("complete",{answers:t.answers,path:t.path}),!0)}getAnswers(){return Zt(this._items,this._rawAnswers()).answers}getAnswer(t){let e=this._items.find(i=>i.name===t);return e?this._answerOf(e):null}setAnswers(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,n]of Object.entries(t))this._items.some(r=>r.name===i)&&this.setAnswer(i,n,{silent:!0});if(this._paint(),!e){let i=this.getAnswers();for(let n of Object.keys(t))n in i&&this.emit("change",{name:n,value:i[n],answers:i})}return this}setAnswer(t,e,{silent:i=!1}={}){let n=this._items.find(r=>r.name===t);if(!n)throw new RangeError(`Unknown questionnaire item: ${t}`);if(n.field)this._field(n).setValue(e===void 0?null:e,{silent:!0});else{let r=Array.isArray(e)?e:e==null||e===""?[]:[e],o=new Set(r.map(c=>String(c))),a=n.choices.filter(c=>o.has(String(c.value)));for(let c of a)o.delete(String(c.value));this._selected.set(t,a.map(c=>c.value)),this._freeform.set(t,n.input?[...o][0]??"":"")}return this._paint(),i||this._emitChange(n),this}getActive(){return this._status!=="asking"?null:this._path[this._path.length-1]??null}getPath(){return[...this._path]}getProgress(){return qp(this._items,this._rawAnswers(),this._path)}getState(){return{active:this.getActive(),status:this._status,answers:this.getAnswers(),path:this.getPath(),progress:this.getProgress()}}toFormData(){let t=new FormData;for(let[e,i]of Object.entries(this.getAnswers()))if(Array.isArray(i))for(let n of i)t.append(e,String(n));else i instanceof File||i instanceof Blob?t.append(e,i):t.append(e,i==null?"":String(i));return t}reset(){this._selected.clear(),this._freeform.clear();for(let[e,i]of this._fields){let n=this._items.find(r=>r.name===e);i.setValue(n?.field?.value??null,{silent:!0})}let t=Zt(this._items,this._rawAnswers()).visible;return this._path=t.length>0?[t[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}focus(){return this._focusItem(),this}destroy(){if(!this._destroyed){this._destroyed=!0,clearTimeout(this._advanceTimer);for(let t of this._fields.values())t.destroy();this._fields.clear(),this._bar?.destroy(),super.destroy(),this._createdRoot||S(this.el,this._snapshot)}}_activeItem(){let t=this._path[this._path.length-1];return this._items.find(e=>e.name===t)??null}_rawAnswers(){let t={};for(let e of this._items){let i=this._answerOf(e);Ve(i)||(t[e.name]=i)}return t}_answerOf(t){if(t.field)return this._fields.get(t.name)?.getValue()??null;let e=this._selected.get(t.name)??[],i=(this._freeform.get(t.name)??"").trim();return t.multiple?i?[...e,i]:[...e]:i||(e.length>0?e[0]:null)}_field(t){let e=this._fields.get(t.name);if(e)return e;let i=t.field??{};return e=new I(null,{...i,label:i.label??t.prompt,required:t.required}),e.el.classList.add("zx-questionnaire__field"),i.label==null&&e.el.setAttribute("data-hide-label",""),e.on("change",()=>{this._error="",this._paintError(t),this._emitChange(t)}),this._fields.set(t.name,e),e}_navigate(t,e){let i=this.getActive();if(i===t&&this._status==="asking"||this.emit("navigate",{from:i,to:t,reason:e}).defaultPrevented)return!1;let n=this._path.indexOf(t);return n>=0?this._path=this._path.slice(0,n+1):this._path.push(t),this._status="asking",this._error="",this._paint(),this._focusItem(),!0}_enterReview(){return this.emit("navigate",{from:this.getActive(),to:null,reason:"review"}).defaultPrevented?!1:(this._status="review",this._error="",this._paint(),this._reviewHost.focus?.(),!0)}async _validateActive(){let t=this._activeItem();if(!t)return!0;let e=this._answerOf(t),i=jp(t,e,n=>this.msg(n));if(!i&&typeof t.validate=="function"){this._setBusy(!0);try{i=await t.validate(e,this.getAnswers())}catch(n){i=n instanceof Error?n.message:String(n)}finally{this._destroyed||this._setBusy(!1)}}return this._destroyed?!1:(this._error=i?String(i):"",this._paintError(t),this._error?(this.emit("invalid",{name:t.name,message:this._error}),this._focusControl(),!1):!0)}_setBusy(t){this._busy=t,t?this.el.setAttribute("aria-busy","true"):this.el.removeAttribute("aria-busy"),this._syncState(),this._paintActions()}_paint(){this._destroyed||(this._syncState(),this._paintProgress(),this._status==="review"?this._paintReview():this._paintItem(),this._itemHost.hidden=this._status==="review",this._reviewHost.hidden=this._status!=="review",this._paintActions())}_syncState(){this.el.dataset.state=this._busy?"checking":this._status}_paintProgress(){if(this._progressHost.hidden=!this.options.progress||this._items.length===0,this._progressHost.hidden)return;let t=this.getProgress(),e=this.msg("questionnaire.counter",t.index+1,Math.max(t.total,1));this._bar.setLabel(t.section?`${e} \xB7 ${t.section}`:e),this._bar.set(this._status==="asking"?t.percent:100,{silent:!0}),this._bar.setStatus(this._status==="complete"?"success":"active")}_paintItem(){let t=this._activeItem();if(this._itemHost.toggleAttribute("data-empty",!t),!t){this._itemHost.replaceChildren(l("p",{class:"zx-questionnaire__prompt"},this.msg("questionnaire.empty")));return}let e=`${this._uid}-prompt`,i=`${this._uid}-description`,n=`${this._uid}-error`,r=[l("legend",{class:"zx-questionnaire__prompt",id:e},t.prompt)];t.description&&r.push(l("p",{class:"zx-questionnaire__description",id:i},t.description)),r.push(t.field?this._field(t).el:this._choices(t)),r.push(l("p",{class:"zx-questionnaire__error",id:n,role:"alert",hidden:!0})),this._itemHost.replaceChildren(...r),this._itemHost.dataset.item=t.name,this._itemHost.setAttribute("aria-describedby",[t.description?i:"",n].filter(Boolean).join(" ")),this._paintError(t)}_choices(t){let e=new Set((this._selected.get(t.name)??[]).map(n=>String(n))),i=l("div",{class:"zx-questionnaire__choices"});if(i.append(...t.choices.map((n,r)=>l("label",{class:"zx-questionnaire__choice",dataset:{disabled:n.disabled?"true":null}},l("input",{type:t.multiple?"checkbox":"radio",class:"zx-questionnaire__control",name:t.name,value:String(n.value),checked:e.has(String(n.value)),disabled:n.disabled,dataset:{index:r}}),l("span",{class:"zx-questionnaire__marker",ariaHidden:"true"}),n.icon?b(n.icon,{size:16}):null,l("span",{class:"zx-questionnaire__text"},l("span",{class:"zx-questionnaire__label"},n.label),n.description?l("span",{class:"zx-questionnaire__hint"},n.description):null),n.key?l("kbd",{class:"zx-questionnaire__key",ariaHidden:"true"},n.key):null))),t.input){let n=`${this._uid}-freeform`,r=this._freeform.get(t.name)??"",o=l(t.input.multiline?"textarea":"input",{type:t.input.multiline?void 0:"text",class:"zx-questionnaire__freeform-input",id:n,name:t.choices.length>0?`${t.name}__other`:t.name,placeholder:t.input.placeholder||void 0,maxLength:t.input.maxLength>0?t.input.maxLength:void 0,rows:t.input.multiline?3:void 0,autocomplete:"off",value:r});i.append(l("div",{class:"zx-questionnaire__freeform"},l("label",{class:"zx-questionnaire__freeform-label",htmlFor:n},t.input.label),o))}return i}_paintError(t){let e=this._itemHost.querySelector(".zx-questionnaire__error");e instanceof HTMLElement&&(e.textContent=this._error,e.hidden=!this._error),this._error?this._itemHost.setAttribute("aria-invalid","true"):this._itemHost.removeAttribute("aria-invalid");let i=t?.field?this._fields.get(t.name):null;i&&(this._error?i.setHighlight(this._error,"danger"):i.clearHighlight(),e instanceof HTMLElement&&(e.hidden=!0))}_paintReview(){let{answers:t,visible:e}=Zt(this._items,this._rawAnswers()),i=this._path.map(n=>e.find(r=>r.name===n)).filter(n=>!!n).map(n=>l("div",{class:"zx-questionnaire__answer"},l("dt",{class:"zx-questionnaire__answer-prompt"},n.prompt),l("dd",{class:"zx-questionnaire__answer-value",dataset:{empty:Ve(t[n.name])?"true":null}},this._formatAnswer(n,t[n.name])),j({label:this.msg("questionnaire.edit"),kind:"ghost",size:"sm"})));for(let[n,r]of i.entries()){let o=r.querySelector("button");o instanceof HTMLElement&&(o.dataset.edit=this._path[n])}this._reviewHost.replaceChildren(l("p",{class:"zx-questionnaire__review-title"},this.msg("questionnaire.reviewTitle")),l("dl",{class:"zx-questionnaire__answers"},...i))}_formatAnswer(t,e){if(Ve(e))return this.msg("questionnaire.noAnswer");let i=new Map(t.choices.map(r=>[String(r.value),r.label]));return(Array.isArray(e)?e:[e]).map(r=>i.get(String(r))??String(r)).join(", ")}_paintActions(){let t=this._activeItem(),e=this._status==="review",i=this._status==="complete",n=!1;try{n=!!t&&Do(this._items,t,this._rawAnswers())!==null}catch{n=!1}this._back.hidden=i||!e&&(!this.options.allowBack||this._path.length<=1),this._back.disabled=this._busy,this._skip.hidden=e||i||!t?.skippable,this._skip.disabled=this._busy,this._forward.hidden=i,this._forward.disabled=this._busy||!t&&!e;let r=e?"submit":this._returnToReview||!n&&this.options.review?"review":n?"next":"submit";if(this._forward.dataset.role!==r){this._forward.dataset.role=r;let o=r==="next"?"chevron-right":r==="review"?"list":"check";this._forward.replaceChildren(b(o,{size:16}),l("span",{class:"zx-btn__label"},this.msg(`questionnaire.${r}`)))}}_action(t,e,i,n){let r=j({label:e,icon:i,kind:n});return r.dataset.action=t,r}_onControlChange(t){let e=t.target;if(!(e instanceof HTMLInputElement)||!e.classList.contains("zx-questionnaire__control"))return;let i=this._activeItem();if(!i)return;let n=i.choices[Number(e.dataset.index)];if(n){if(i.multiple){let r=[...this._itemHost.querySelectorAll(".zx-questionnaire__control")].filter(c=>c.checked).map(c=>i.choices[Number(c.dataset.index)].value),o=Hp(i.choices,r,e.checked?n.value:null);this._selected.set(i.name,o);let a=new Set(o.map(c=>String(c)));for(let c of this._itemHost.querySelectorAll(".zx-questionnaire__control"))c.checked=a.has(c.value)}else{this._selected.set(i.name,[n.value]),this._freeform.set(i.name,"");let r=this._itemHost.querySelector(".zx-questionnaire__freeform-input");(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="")}this._error="",this._paintError(i),this._paintProgress(),this._paintActions(),this._emitChange(i),this._maybeAutoAdvance(i)}}_onFreeformInput(t){let e=t.target;if(!((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.classList.contains("zx-questionnaire__freeform-input")))return;let n=this._activeItem();if(n){if(this._freeform.set(n.name,e.value),!n.multiple&&e.value.trim()!==""){this._selected.set(n.name,[]);for(let r of this._itemHost.querySelectorAll(".zx-questionnaire__control"))r.checked=!1}this._error="",this._paintError(n),this._paintProgress(),this._paintActions(),this._emitChange(n)}}_onActionClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;!(e instanceof HTMLElement)||!this._actionsHost.contains(e)||(e.dataset.action==="previous"?this.previous():e.dataset.action==="skip"?this.skip():this.next())}_onReviewClick(t){let e=t.target instanceof Element?t.target.closest("[data-edit]"):null;e instanceof HTMLElement&&this.goTo(String(e.dataset.edit))}_onKeydown(t){if(t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey)return;let e=t.target,i=e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["radio","checkbox"].includes(e.type)||e instanceof HTMLElement&&e.isContentEditable;if(t.key==="Enter"){if(e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement)return;t.preventDefault(),this.next();return}if(!this.options.shortcuts||i||t.key.length!==1)return;let n=this._activeItem();if(!n||this._status!=="asking")return;let r=t.key.toLowerCase(),o=n.choices.findIndex(c=>c.key===r&&!c.disabled);if(o<0)return;let a=this._itemHost.querySelector(`.zx-questionnaire__control[data-index="${o}"]`);a instanceof HTMLInputElement&&(t.preventDefault(),a.checked=n.multiple?!a.checked:!0,a.focus(),a.dispatchEvent(new Event("change",{bubbles:!0})))}_maybeAutoAdvance(t){this.options.advance!=="auto"||t.multiple||t.input||(clearTimeout(this._advanceTimer),this._advanceTimer=setTimeout(()=>{!this._destroyed&&this._activeItem()===t&&this.next()},GS))}_emitChange(t){let e=this.getAnswers();this.emit("change",{name:t.name,value:this._answerOf(t),answers:e})}_focusItem(){this._status==="asking"&&this._itemHost.focus?.()}_focusControl(){let t=this._activeItem(),e=t?.field?this._fields.get(t.name):null;if(e){e.focus();return}let i=this._itemHost.querySelector(".zx-questionnaire__control:not(:disabled), .zx-questionnaire__freeform-input");i instanceof HTMLElement?i.focus():this._focusItem()}};function $p(){Ld(),Dc(),Oc(),pd(),td(),ud(),qd(),Ud(),wd(),md(),$d(),xd(),Sd(),Vd(),Rd()}$p();return i_(WS);})();
11
11
  /*
12
12
  * @license Lucide 1.53.0 (ISC), including icons derived from Feather (MIT) — notices below.
13
13
  *