@adia-ai/web-components 0.6.35 → 0.6.36

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.
@@ -161,7 +161,7 @@ parent-template-re-read pattern that works across frameworks.`);return}let t=thi
161
161
  ${t.shortcut?`<span data-shortcut>${t.shortcut}</span>`:""}
162
162
  `,this.#l.set(i,t),i}#y(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#w(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#k(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#w(parseInt(e[r].dataset.idx))}#v(t){this.#O(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#x(){let t=this.#n.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",r=(this.#l.get(t)||this.#m(e))?.category||"";this.#O(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#S=()=>{this.#f(this.#s.value)};#b=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#k(1);break;case"ArrowUp":t.preventDefault(),this.#k(-1);break;case"Enter":t.preventDefault(),this.#x();break;case"Tab":t.preventDefault(),this.#x();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),this.removeEventListener("keydown",this.#b),this.#s?.removeEventListener("input",this.#S),this.#n?.removeEventListener("click",this.#h),this.#n?.removeEventListener("pointerover",this.#u),this.#s=null,this.#n=null,this.#a=null,this.#o=!1}};w("command-ui",Cn);var ta=.4;function ku(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Au(s,t,e){let i=s+.3963377774*t+.2158037573*e,n=s-.1055613458*t-.0638541728*e,r=s-.0894841775*t-1.291485548*e,o=i*i*i,a=n*n*n,l=r*r*r;return[4.0767416621*o-3.3077115913*a+.2309699292*l,-1.2684380046*o+2.6097574011*a-.3413193965*l,-.0041960863*o-.7034186147*a+1.707614701*l]}function oi(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function $u(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function vO(s,t,e){let{a:i,b:n}=ku(s,t,e),[r,o,a]=Au(s,i,n);return[Math.max(0,Math.min(1,oi(r))),Math.max(0,Math.min(1,oi(o))),Math.max(0,Math.min(1,oi(a)))]}function X1(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Pn(s,t,e){let[i,n,r]=vO(s,t,e);return X1(i,n,r)}function D1(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=$u(parseInt(s.slice(0,2),16)/255),e=$u(parseInt(s.slice(2,4),16)/255),i=$u(parseInt(s.slice(4,6),16)/255),n=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),r=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*n+.793617785*r-.0040720468*o,l=1.9779984951*n-2.428592205*r+.4505937099*o,h=.0259040371*n+.7827717662*r-.808675766*o,c=Math.sqrt(l*l+h*h),u=Math.atan2(h,l)*180/Math.PI;return u<0&&(u+=360),{L:a,C:c,H:u}}function xO(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function ea(s,t,e){let{a:i,b:n}=ku(s,t,e),[r,o,a]=Au(s,i,n);if(xO(oi(r),oi(o),oi(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=ku(s,u,e),[p,m,O]=Au(s,d,f);xO(oi(p),oi(m),oi(O))?l=u:h=u}return l}var En=class s extends Z{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...Z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=null;#O=null;#g=null;#y=null;#w=null;#k=[];#v=null;static template=()=>null;#x=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#R("input")};#S=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#X(t))};#b=t=>{this.#a==="area"&&this.#X(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#R("change"))};#$=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#P(t))};#E=t=>{this.#a==="hue"&&this.#P(t)};#Q=()=>{this.#a==="hue"&&(this.#a=null,this.#R("change"))};#L=t=>{if(this.disabled)return;let e=t.shiftKey?.05:.01,i=t.shiftKey?.04:.004;switch(t.key){case"ArrowRight":t.preventDefault(),this.#i=Math.min(ta,this.#i+i);break;case"ArrowLeft":t.preventDefault(),this.#i=Math.max(0,this.#i-i);break;case"ArrowUp":t.preventDefault(),this.#e=Math.min(1,this.#e+e);break;case"ArrowDown":t.preventDefault(),this.#e=Math.max(0,this.#e-e);break;default:return}this.#R("change")};#T=t=>{if(this.disabled)return;let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#s=(this.#s+e)%360;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#s=(this.#s-e+360)%360;break;default:return}this.#R("change")};connected(){if(super.connected(),this.#M(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#x),t.appendChild(c),c};this.#g=e("H","hue",0,360,1),this.#y=e("C","chroma",0,ta,.001),this.#w=e("L","lightness",0,1,.001),this.appendChild(t),this.#d=document.createElement("div"),this.#d.setAttribute("data-hue-track",""),this.#d.setAttribute("tabindex","0"),this.#d.setAttribute("role","slider"),this.#d.setAttribute("aria-label","Hue"),this.#p=document.createElement("div"),this.#p.setAttribute("data-hue-thumb",""),this.#d.appendChild(this.#p),this.appendChild(this.#d);let i=document.createElement("div");i.setAttribute("data-output","");let n=r=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",r);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",r),l.setAttribute("aria-label",`Copy ${r}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#D(r,l);return l.addEventListener("click",h),this.#k.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#f=n("oklch"),this.#m=n("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#S),this.#h.addEventListener("pointermove",this.#b),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#$),this.#d.addEventListener("pointermove",this.#E),this.#d.addEventListener("pointerup",this.#Q),this.#h.addEventListener("keydown",this.#L),this.#d.addEventListener("keydown",this.#T),this.#O=new ResizeObserver(()=>this.#I()),this.#O.observe(this.#h)}disconnected(){super.disconnected(),this.#v!=null&&(clearTimeout(this.#v),this.#v=null),this.#O&&(this.#O.disconnect(),this.#O=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#S),this.#h.removeEventListener("pointermove",this.#b),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#L)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#$),this.#d.removeEventListener("pointermove",this.#E),this.#d.removeEventListener("pointerup",this.#Q),this.#d.removeEventListener("keydown",this.#T)),this.#g?.removeEventListener("input",this.#x),this.#y?.removeEventListener("input",this.#x),this.#w?.removeEventListener("input",this.#x);for(let{el:t,handler:e}of this.#k)t.removeEventListener("click",e);this.#k=[],this.#r=!1}#X(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),n=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*ta,this.#e=1-n,this.#R("input")}#P(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#R("input")}#M(t){if(t){if(t.startsWith("#")){let e=D1(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-picker-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#R(t){let e=[];if(this.#e>this.maxL&&(e.push({axis:"l",requested:this.#e,clamped:this.maxL,reason:"max-l"}),this.#e=this.maxL),this.#e<this.minL&&(e.push({axis:"l",requested:this.#e,clamped:this.minL,reason:"min-l"}),this.#e=this.minL),this.#i>this.maxChroma&&(e.push({axis:"c",requested:this.#i,clamped:this.maxChroma,reason:"max-chroma"}),this.#i=this.maxChroma),Number.isFinite(this.hueDriftMax)){let a=Number.isFinite(this.baseHue)?this.baseHue:Number.isFinite(this.#n)?this.#n:this.#s;Number.isFinite(this.#n)||(this.#n=a);let l=(this.#s-a+540)%360-180,h=this.hueDriftMax;if(l>h){let c=this.#s;this.#s=(a+h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}else if(l<-h){let c=this.#s;this.#s=(a-h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}}let i=ea(this.#e,this.#i,this.#s),n=Pn(this.#e,i,this.#s),r=this.#C();this.#o=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#C(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#D(t,e){let i=t==="oklch"?this.#C():Pn(this.#e,ea(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#v!=null&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#I(){if(!this.#l||!this.#c||!this.#h)return;let t=Math.min(window.devicePixelRatio||1,2)*.5,e=Math.round(this.#h.clientWidth*t),i=Math.round(this.#h.clientHeight*t);if(e<=0||i<=0)return;this.#l.width=e,this.#l.height=i;let n=this.#c.createImageData(e,i),r=n.data,o=this.#s;for(let a=0;a<i;a++){let l=1-a/(i-1);for(let h=0;h<e;h++){let c=h/(e-1)*ta,u=ea(l,c,o),[d,f,p]=vO(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#c.putImageData(n,0,0)}render(){if(this.#o?this.#o=!1:this.#M(this.value),this.#I(),this.#u){let r=this.#i/ta*100,o=(1-this.#e)*100;this.#u.style.left=`${r}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Pn(this.#e,ea(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(Pn(.7,.15,o));this.#d.style.background=`linear-gradient(to right, ${r.join(", ")})`,this.#d.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#p&&(this.#p.style.left=`${this.#s/360*100}%`,this.#p.style.background=Pn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#C());let t=this.querySelector('slider-ui[data-channel="hue"]'),e=this.querySelector('slider-ui[data-channel="chroma"]'),i=this.querySelector('slider-ui[data-channel="lightness"]');t&&(t.value=Math.round(this.#s)),e&&(e.value=+this.#i.toFixed(3)),i&&(i.value=+this.#e.toFixed(3)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let n=Pn(this.#e,ea(this.#e,this.#i,this.#s),this.#s);this.#f&&(this.#f.textContent=this.#C()),this.#m&&(this.#m.textContent=n)}onFormReset(){this.value="#3b82f6"}};w("color-picker-ui",En);var Qn=class extends Z{static get properties(){return{...Z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;connected(){this.#a(),this.#o(),this.#u(),this.syncValue(this.value)}render(){this.#u(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#a(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-picker-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-picker-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#o(){if(this.#r)return;this.#r=!0,this.#i.addEventListener("change",this.#l),this.#i.addEventListener("input",this.#c);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),new MutationObserver(t).observe(this.#t,{attributes:!0,attributeFilter:["open"]})}#l=t=>{this.#h(t.detail,"change")};#c=t=>{this.#h(t.detail,"input")};#h(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#u(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#u(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#n&&(this.#n.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#l),this.#i?.removeEventListener("input",this.#c),this.#r=!1}};w("color-input-ui",Qn);var Cu=0,Tn=class extends A{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#a=!1;#o=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++Cu}`,o={id:r,from:t,to:e,fromPort:i,toPort:n};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),r}disconnect(t){let e=this.#e.findIndex(n=>n.id===t);if(e===-1)return;let[i]=this.#e.splice(e,1);this.#h(),this.dispatchEvent(new CustomEvent("noodle-disconnect",{bubbles:!0,detail:{...i}}))}setConnections(t){this.#e=t.map(e=>({id:e.id||`noodle-${++Cu}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#p()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),this.#s=new ResizeObserver(()=>this.#h()),this.#n=new MutationObserver(()=>{this.#x(),this.#h()}),this.#s.observe(this),this.#u();for(let t of this.#m())this.#s.observe(t);this.#x(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#c?.(),this.#s?.disconnect(),this.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#S(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#p()}))}#u(){this.#n?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#d(){this.#n?.disconnect()}#p(){if(!this.#t)return;this.#d();let t=this.#m();for(let r of t)this.#s.observe(r);this.#b();let e=this.#e.map(r=>{let o=this.#f(r.from),a=this.#f(r.to);if(!o||!a)return null;let l=this.#O(o,r.fromPort),h=this.#O(a,r.toPort);return!l||!h?null:{id:r.id,d:this.#g(l,h,r.fromPort,r.toPort)}}).filter(Boolean),i=new Map;for(let r of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(r.getAttribute("data-noodle-id"),r);let n=new Set(e.map(r=>r.id));for(let[r,o]of i)n.has(r)||o.remove();for(let{id:r,d:o}of e){let a=i.get(r);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",r),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#o&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#u()}#f(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#O(t,e){let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),r=this.offsetWidth&&n.width?n.width/this.offsetWidth:1,o=(i.left-n.left)/r,a=(i.top-n.top)/r,l=i.width/r,h=i.height/r;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#g(t,e,i,n){switch(this.curve){case"step":return this.#k(t,e);case"straight":return this.#v(t,e);default:return this.#y(t,e,i,n)}}#y(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#w(t,i,l),c=this.#w(e,n,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#w(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#k(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#v(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#x(){this.#d(),this.#S();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#$(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#b(),this.#u()}#S(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#b(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#O(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#A(t,e){return t._noodleId||(t._noodleId=`_n${++Cu}`),`${t._noodleId}:${e}`}#$=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#O(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#g(r,{x:c,y:u},i,this.#E(r,{x:c,y:u})),this.#h(),this.#Q(l.clientX,l.clientY,e),this.dispatchEvent(new CustomEvent("noodle-drag",{bubbles:!0,detail:{from:e,fromPort:i,x:c,y:u}}))},a=l=>{try{n.releasePointerCapture(l.pointerId)}catch{}if(n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#L(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#T(),this.#o=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#o=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#T(),this.#l=null,this.#c=null},this.#o={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#E(t,e){let i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"left":"right":n>0?"top":"bottom"}#Q(t,e,i){this.#T();let n=this.#L(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#L(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#m().find(O=>O._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#T(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};w("noodles-ui",Tn);var Ri={};function Oe(s,t){Ri[s]=t}function Ln(s,t){let e=s.firstElementChild;(!e||e.tagName!=="SPAN")&&(s.replaceChildren(),e=s.appendChild(document.createElement("span"))),e.textContent=t,s.title=t}var Pu={basic:(s,t)=>s<t?-1:s>t?1:0,alphanumeric:(s,t)=>String(s??"").localeCompare(String(t??""),void 0,{numeric:!0,sensitivity:"base"}),numeric:(s,t)=>(Number(s)||0)-(Number(t)||0),datetime:(s,t)=>new Date(s||0).getTime()-new Date(t||0).getTime()};Oe("text",{render(s,t,e){Ln(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),Oe("number",{render(s,t,e){Ln(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),Oe("currency",{render(s,t,e,i){Ln(e,s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:i?.currency||"USD"}).format(s):"")},format(s,t,e){return s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:e?.currency||"USD"}).format(s):""},align:"right",sortFn:"numeric"}),Oe("percent",{render(s,t,e){Ln(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var SO={year:"numeric",month:"short",day:"numeric"};Oe("date",{render(s,t,e){Ln(e,s?new Intl.DateTimeFormat("en-US",SO).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",SO).format(new Date(s)):""},align:"left",sortFn:"datetime"});var wO={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};Oe("datetime",{render(s,t,e){Ln(e,s?new Intl.DateTimeFormat("en-US",wO).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",wO).format(new Date(s)):""},align:"left",sortFn:"datetime"}),Oe("boolean",{render(s,t,e){let i=e.querySelector("check-ui");i||(e.textContent="",i=document.createElement("check-ui"),i.setAttribute("disabled",""),e.appendChild(i)),s?i.setAttribute("checked",""):i.removeAttribute("checked")},format(s){return s?"Yes":"No"},align:"center",sortFn:"basic"}),Oe("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let r=i?.variants||{};n.setAttribute("variant",r[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),Oe("avatar",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("avatar-ui");o.setAttribute("size","sm");let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("avatar-ui"),r=i.querySelector("span");n.setAttribute("text",String(s??"")),r.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),Oe("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--a-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),Oe("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),Oe("actions",{render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});function Z1(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function ai(s,t){return typeof t.accessor=="function"?t.accessor(s):Z1(s,t.key)}function Al(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
163
163
  `)?'"'+t.replace(/"/g,'""')+'"':t}var Mn=class extends A{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},density:{type:String,default:"standard",reflect:!0},paginate:{type:Number,default:0,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#u=-1;#d=null;#p=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#y()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#a=0,this.#y()}get data(){return this.#e}get selected(){return[...this.#o].sort((t,e)=>t-e)}set selected(t){if(this.#o.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#o.add(e);this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#a=0,this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#a=0,this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#y()}get expanded(){return[...this.#n]}expandRenderer=null;getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#a,density:this.density}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#a=t.page),t.density&&(this.density=t.density),this.#y()}}#f(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#m(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#O(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#m(),this.#h||(this.#h=!0,this.addEventListener("click",this.#P),this.addEventListener("keydown",this.#q))}disconnected(){this.removeEventListener("click",this.#P),this.removeEventListener("keydown",this.#q),this.#h=!1,this.#I(),this.#g&&(cancelAnimationFrame(this.#g),this.#g=null),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null)}#O(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l)),e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#g=null;#y(){!this.isConnected||this.#g||(this.#g=requestAnimationFrame(()=>{this.#g=null,this.render(),this.#f()}))}get#w(){return this.#t.filter(t=>!t.hidden)}#k(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#w)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#v(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#w.some(r=>{let o=ai(n,r);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[n,{op:r,value:o}]of this.#s){let a=this.#t.find(u=>u.key===n),l=ai(i,a||{key:n}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(r){case"contains":if(!h.includes(c))return!1;break;case"equals":if(h!==c)return!1;break;case"startsWith":if(!h.startsWith(c))return!1;break;case"gt":if(Number(l)<=Number(o))return!1;break;case"lt":if(Number(l)>=Number(o))return!1;break;case"gte":if(Number(l)<Number(o))return!1;break;case"lte":if(Number(l)>Number(o))return!1;break;case"between":{let[u,d]=String(o).split(",").map(Number),f=Number(l);if(f<u||f>d)return!1;break}case"select":{if(!c.split(",").map(d=>d.trim()).includes(h))return!1;break}default:if(!h.includes(c))return!1}}return!0})),this.#i.length&&t.sort((e,i)=>{for(let{key:n,dir:r}of this.#i){let o=this.#t.find(u=>u.key===n),a=ai(this.#e[e],o||{key:n}),l=ai(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ri[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Pu[d]||Pu.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#x(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#S(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#v().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#w;this.style.gridTemplateColumns=this.#k();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#b(e,t),this.#X();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let n=this.#v(),r=this.#x(n),o=[];for(let c of r){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#A(c,t);if(u&&this.#$(u,c,t),this.expandable&&(this.#n.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#n.has(c)){let f=i.querySelector(`:scope > [data-detail-row][data-for="${c}"]`);if(!f&&(f=document.createElement("div"),f.setAttribute("data-detail-row",""),f.dataset.for=c,this.expandRenderer)){let p=this.expandRenderer(this.#e[c],c);p instanceof Node?f.appendChild(p):f.textContent=String(p)}o.push(f)}}let a=[...i.children];for(let c of a)o.includes(c)||c.remove();for(let c=0;c<o.length;c++)i.children[c]!==o[c]&&(i.children[c]?i.insertBefore(o[c],i.children[c]):i.appendChild(o[c]));this.#E(i),this.#Q(i,n,t);let l=this.paginate>0&&this.#e.length>0,h=this.querySelector(":scope > [data-footer]");l?(h||(h=document.createElement("div"),h.setAttribute("data-footer",""),this.appendChild(h)),this.#L(h,n.length)):h&&h.remove()}#b(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,n=[];if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#T(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}for(;t.children.length>n.length;)t.lastChild.remove();for(let r=0;r<n.length;r++)t.children[r]?t.replaceChild(n[r],t.children[r]):t.appendChild(n[r])}#A(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#$(i,t,e),i}#$(t,e,i){let n=this.#e[e],r=this.#o.has(e);t.dataset.index=e,r?(t.setAttribute("data-selected",""),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.removeAttribute("aria-selected"));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col","");let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=ai(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);u instanceof Node?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Ri[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Ri[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}for(;t.children.length>o.length;)t.lastChild.remove();for(let a=0;a<o.length;a++)t.children[a]?t.replaceChild(o[a],t.children[a]):t.appendChild(o[a])}#E(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let n=this.#w,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#Q(t,e,i){let n=i.some(a=>a.aggregate),r=this.querySelector(":scope > [data-agg-row]");if(!n||this.#e.length===0){r&&r.remove();return}r||(r=document.createElement("div"),r.setAttribute("role","row"),r.setAttribute("data-agg-row",""),t.after(r));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}for(let a of i){let l=document.createElement("div");if(l.setAttribute("role","gridcell"),a.aggregate){let h=e.map(d=>{let f=ai(this.#e[d],a);return f!=null?Number(f):NaN}).filter(d=>!isNaN(d)),c;switch(a.aggregate){case"sum":c=h.reduce((d,f)=>d+f,0);break;case"avg":c=h.length?h.reduce((d,f)=>d+f,0)/h.length:0;break;case"min":c=h.length?Math.min(...h):0;break;case"max":c=h.length?Math.max(...h):0;break;case"count":c=e.length;break;default:c=""}let u=Ri[a.type||"text"];typeof c=="number"&&u?.render?u.render(c,{},l,a.meta):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}for(;r.children.length>o.length;)r.lastChild.remove();for(let a=0;a<o.length;a++)r.children[a]?r.replaceChild(o[a],r.children[a]):r.appendChild(o[a])}#L(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",r=>{this.#a=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))}),t.appendChild(i));let n=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#a+1)),i.setAttribute("total",String(n))}#T(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let n=[...new Set(this.#e.map(o=>{let a=ai(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),r=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of n){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=r.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let n=document.createElement("input");n.type="number",n.placeholder="Filter...",n.value=i?.value??"",n.setAttribute("data-filter-input","");let r=document.createElement("select");r.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),r.appendChild(h)}let o=()=>{n.value?this.setFilter(t.key,n.value,r.value):this.setFilter(t.key,null)};n.addEventListener("input",o),r.addEventListener("change",o),e.appendChild(r),e.appendChild(n)}else{let n=document.createElement("input");n.type="text",n.placeholder=`Filter ${t.label||t.key}...`,n.value=i?.value??"",n.setAttribute("data-filter-input",""),n.addEventListener("input",()=>{n.value?this.setFilter(t.key,n.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(n)}if(i){let n=document.createElement("button");n.textContent="Clear",n.setAttribute("data-filter-clear",""),n.addEventListener("click",()=>{this.setFilter(t.key,null),this.#d=null,this.#y()}),e.appendChild(n)}return this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{if(this.#p=null,!this.isConnected)return;let n=e.querySelector("input");n&&n.focus()}),e}#X(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:n,value:r}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=n==="select"?`${r.split(",").length} selected`:r;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#P=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#d=this.#d===c?null:c,this.#y();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#y());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-resize-handle]");if(r&&this.contains(r)){this.#R(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#o.add(u);else this.#o.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#u>=0){let f=Math.min(this.#u,u),p=Math.max(this.#u,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#u=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(O=>O.key===d),m=p?ai(f,p):void 0;this.dispatchEvent(new CustomEvent("cell-click",{bubbles:!0,detail:{key:d,row:f,value:m,dataIndex:u}})),this.dispatchEvent(new CustomEvent("row-click",{bubbles:!0,detail:{row:f,dataIndex:u}}))}}};#M=null;#R(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#M={key:i,col:n,startX:a,startWidth:o},document.addEventListener("mousemove",this.#C),document.addEventListener("mouseup",this.#D)}#C=t=>{if(!this.#M)return;let{key:e,col:i,startX:n,startWidth:r}=this.#M,o=t.clientX-n,a=r+o,l=i.minWidth||48,h=i.maxWidth||1/0;a=Math.max(l,Math.min(h,a)),this.#l.set(e,Math.round(a)),this.style.gridTemplateColumns=this.#k()};#D=t=>{if(!this.#M)return;let{key:e}=this.#M;document.removeEventListener("mousemove",this.#C),document.removeEventListener("mouseup",this.#D),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#M=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#I(){document.removeEventListener("mousemove",this.#C),document.removeEventListener("mouseup",this.#D),this.#M=null}#q=t=>{let i=this.#w.length+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.children.length:0;this.#c||(this.#c={row:0,col:0});let{row:o,col:a}=this.#c,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#c={row:o,col:a},this.#V())};#V(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#c)return;let{row:e,col:i}=this.#c,n;e===-1?n=this.querySelector(":scope > [data-header]")?.children[i]:n=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],n&&(n.setAttribute("data-focused",""),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#w,i=this.#v(),n=e.map(c=>Al(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=ai(u,d);if(typeof d.format=="function")return Al(d.format(f,u));let p=Ri[d.type||"text"];return p?.format?Al(p.format(f,u,d.meta)):Al(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
164
- `),a=new Blob([o],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),h=document.createElement("a");h.href=l,h.download=t,h.style.display="none",document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(l)}};w("table-ui",Mn);var q1=200;function Eu(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-empty",""),t.setAttribute("color","subtle"),t.setAttribute("variant","caption"),t.textContent=s,t}function Qu(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}var B1=50,kO=500;function AO(s,t){if(typeof t?.accessor=="function")return t.accessor(s);let e=t?.key;if(!e||s==null)return;let i=String(e).split("."),n=s;for(let r of i){if(n==null)return;n=n[r]}return n}function N1(s){if(!s)return!1;let t=String(s);return!!(t==="id"||t==="ID"||t==="uuid"||t==="guid"||/[a-z](Id|ID)$/.test(t)||/_id$/i.test(t))}function z1(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(N1(s?.key))return"text";let e=[],i=Math.min(t?.length??0,kO),n=new Set;for(let r=0;r<i;r++){let o=AO(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>B1))return"text"}return e.length?"select":"text"}function V1(s,t){let e=new Set,i=Math.min(t?.length??0,kO);for(let n=0;n<i;n++){let r=AO(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var Rn=class s extends A{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){this.setAttribute("role","toolbar"),this.#a(),this.#h(),this.#o(),this.#O()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#y(),this.#c()}render(){this.#o(),this.#O(),this.#p()}#a(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#o(){let t=this.#l();if(t===this.#t||(this.#c(),!t))return;this.#t=t;let e=()=>this.#b(),i=()=>this.#x();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#l(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#c(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#h(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-title","");let i=document.createElement("span");i.setAttribute("data-heading",""),e.appendChild(i);let n=document.createElement("badge-ui");n.setAttribute("data-count-badge",""),n.setAttribute("size","sm"),n.setAttribute("variant","muted"),n.hidden=!0,e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-controls",""),r.appendChild(this.#d("filter","Filter","funnel-simple")),r.appendChild(this.#d("sort","Sort","arrows-down-up")),r.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(q1)),o.addEventListener("search",this.#m);let a=document.createElement("div");a.setAttribute("data-actions","");for(let l of[...this.children])l!==t&&l.getAttribute?.("slot")==="actions"&&a.appendChild(l);t.appendChild(e),t.appendChild(r),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#p(),this.#f()}#u(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#d(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("size","sm"),n.setAttribute("aria-haspopup","menu"),n.addEventListener("click",r=>{r.stopPropagation(),this.#g(t,n)}),n}#p(){let t=this.querySelector(":scope [data-heading]");if(!t)return;this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0;let e=this.querySelector(":scope [data-count-badge]");if(!e)return;let i=this.count?.toString().trim(),n=this.#t?.data?.length,r=i||(Number.isFinite(n)?String(n):"");r?(e.setAttribute("text",r),e.hidden=!1):e.hidden=!0}#f(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,n)=>{let r=t.querySelector(i);r&&(r.hidden=n)};e('[data-toolbar-btn="filter"]',this.noFilter),e('[data-toolbar-btn="sort"]',this.noSort),e('[data-toolbar-btn="columns"]',this.noColumns),e("[data-search]",this.noSearch)}attributeChanged(t){["no-filter","no-sort","no-columns","no-search"].includes(t)&&this.#f(),t==="placeholder"&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}#m=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#O(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#p()}#g(t,e){if(this.#i?.kind===t){this.#y();return}this.#y();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#v(i),t==="sort"&&this.#S(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=dt(e,i,{placement:"bottom-start",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:n},this.#s||(this.#s=!0,this.#n=requestAnimationFrame(()=>{this.#n=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#w,!0),document.addEventListener("keydown",this.#k,!0))}))}#y(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#w,!0),document.removeEventListener("keydown",this.#k,!0))}}#w=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#y())};#k=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Eu("No filterable columns"));return}let i=e.filters||{};t.appendChild(Qu("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",o.label||o.key);let l=z1(o,r),h=i[o.key];if(l==="select"){let c=document.createElement("select-ui");c.setAttribute("data-filter-input",""),c.setAttribute("multiple",""),c.setAttribute("placeholder","\u2014");let u=V1(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";d?e.setFilter(o.key,d,"select"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;u?e.setFilter(o.key,u,"contains"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#u("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#x()});t.appendChild(o)}}#x(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#S(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Eu("No sortable columns"));return}t.appendChild(Qu("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",o.label||o.key),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#b()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#u("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#b()});t.appendChild(o)}}#b(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#S(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Eu("No columns"));return}t.appendChild(Qu("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",n.label||n.key);let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.columns=a,this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};w("table-toolbar-ui",Rn);var In=class extends A{static properties={orientation:{type:String,default:"vertical",reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll(":scope > timeline-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last","")}},Xn=class extends A{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}connected(){this.querySelector(':scope > [slot="label"]')||(this.innerHTML=`
164
+ `),a=new Blob([o],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),h=document.createElement("a");h.href=l,h.download=t,h.style.display="none",document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(l)}};w("table-ui",Mn);var q1=200;function Eu(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-empty",""),t.setAttribute("color","subtle"),t.setAttribute("variant","caption"),t.textContent=s,t}function Qu(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}var B1=50,kO=500;function AO(s,t){if(typeof t?.accessor=="function")return t.accessor(s);let e=t?.key;if(!e||s==null)return;let i=String(e).split("."),n=s;for(let r of i){if(n==null)return;n=n[r]}return n}function N1(s){if(!s)return!1;let t=String(s);return!!(t==="id"||t==="ID"||t==="uuid"||t==="guid"||/[a-z](Id|ID)$/.test(t)||/_id$/i.test(t))}function z1(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(N1(s?.key))return"text";let e=[],i=Math.min(t?.length??0,kO),n=new Set;for(let r=0;r<i;r++){let o=AO(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>B1))return"text"}return e.length?"select":"text"}function V1(s,t){let e=new Set,i=Math.min(t?.length??0,kO);for(let n=0;n<i;n++){let r=AO(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var Rn=class s extends A{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){this.setAttribute("role","toolbar"),this.#a(),this.#h(),this.#o(),this.#O()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#y(),this.#c()}render(){this.#o(),this.#O(),this.#p()}#a(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#o(){let t=this.#l();if(t===this.#t||(this.#c(),!t))return;this.#t=t;let e=()=>this.#b(),i=()=>this.#x();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#l(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#c(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#h(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-title","");let i=document.createElement("span");i.setAttribute("data-heading",""),e.appendChild(i);let n=document.createElement("badge-ui");n.setAttribute("data-count-badge",""),n.setAttribute("size","sm"),n.setAttribute("variant","muted"),n.hidden=!0,e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-controls",""),r.appendChild(this.#d("filter","Filter","funnel-simple")),r.appendChild(this.#d("sort","Sort","arrows-down-up")),r.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("size","sm"),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(q1)),o.addEventListener("search",this.#m);let a=document.createElement("div");a.setAttribute("data-actions","");for(let l of[...this.children])l!==t&&l.getAttribute?.("slot")==="actions"&&a.appendChild(l);t.appendChild(e),t.appendChild(r),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#p(),this.#f()}#u(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#d(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("size","sm"),n.setAttribute("aria-haspopup","menu"),n.addEventListener("click",r=>{r.stopPropagation(),this.#g(t,n)}),n}#p(){let t=this.querySelector(":scope [data-heading]");if(!t)return;this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0;let e=this.querySelector(":scope [data-count-badge]");if(!e)return;let i=this.count?.toString().trim(),n=this.#t?.data?.length,r=i||(Number.isFinite(n)?String(n):"");r?(e.setAttribute("text",r),e.hidden=!1):e.hidden=!0}#f(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,n)=>{let r=t.querySelector(i);r&&(r.hidden=n)};e('[data-toolbar-btn="filter"]',this.noFilter),e('[data-toolbar-btn="sort"]',this.noSort),e('[data-toolbar-btn="columns"]',this.noColumns),e("[data-search]",this.noSearch)}attributeChanged(t){["no-filter","no-sort","no-columns","no-search"].includes(t)&&this.#f(),t==="placeholder"&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}#m=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#O(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#p()}#g(t,e){if(this.#i?.kind===t){this.#y();return}this.#y();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#v(i),t==="sort"&&this.#S(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=dt(e,i,{placement:"bottom-start",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:n},this.#s||(this.#s=!0,this.#n=requestAnimationFrame(()=>{this.#n=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#w,!0),document.addEventListener("keydown",this.#k,!0))}))}#y(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#w,!0),document.removeEventListener("keydown",this.#k,!0))}}#w=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#y())};#k=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Eu("No filterable columns"));return}let i=e.filters||{};t.appendChild(Qu("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",o.label||o.key);let l=z1(o,r),h=i[o.key];if(l==="select"){let c=document.createElement("select-ui");c.setAttribute("data-filter-input",""),c.setAttribute("multiple",""),c.setAttribute("placeholder","\u2014");let u=V1(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";d?e.setFilter(o.key,d,"select"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;u?e.setFilter(o.key,u,"contains"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#u("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#x()});t.appendChild(o)}}#x(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#S(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Eu("No sortable columns"));return}t.appendChild(Qu("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",o.label||o.key),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#b()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#u("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#b()});t.appendChild(o)}}#b(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#S(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Eu("No columns"));return}t.appendChild(Qu("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",n.label||n.key);let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.columns=a,this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};w("table-toolbar-ui",Rn);var In=class extends A{static properties={orientation:{type:String,default:"vertical",reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll(":scope > timeline-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last","")}},Xn=class extends A{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}connected(){this.querySelector(':scope > [slot="label"]')||(this.innerHTML=`
165
165
  <span slot="label"></span>
166
166
  <span slot="description"></span>
167
167
  <span slot="time"></span>
@@ -172,7 +172,7 @@ parent-template-re-read pattern that works across frameworks.`);return}let t=thi
172
172
  <div data-dropzone tabindex="0" role="button">Drop files here or click to browse</div>
173
173
  <span hint="${this.hint||""}"></span>
174
174
  <div data-filelist></div>
175
- `),this.#e=this.querySelector("[data-dropzone]"),this.#e&&(this.#e.addEventListener("click",this.#i),this.#e.addEventListener("keydown",this.#s),this.#e.addEventListener("dragover",this.#o),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#c))}render(){let t=this.querySelector("[data-filelist]");if(!this.#e||!t)return;let e=this.querySelector("span[hint]");e&&this.hint&&e.setAttribute("hint",this.hint),t.innerHTML="";for(let i of this.#t){let n=document.createElement("span");n.textContent=i.name,t.appendChild(n)}}get files(){return this.#t}#i=()=>{this.disabled||this.#n()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#n())};async#n(){try{if(window.showOpenFilePicker){let t=this.#a(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let n=await Promise.all(i.map(r=>r.getFile()));if(!this.isConnected)return;this.#h(n)}else this.#r()}catch(t){if(t.name!=="AbortError")throw t}}#r(){let t=document.createElement("input");t.type="file",this.accept&&(t.accept=this.accept),this.multiple&&(t.multiple=!0),t.style.display="none",document.body.appendChild(t),t.addEventListener("change",()=>{t.files?.length&&this.#h([...t.files]),t.remove()},{once:!0}),t.addEventListener("cancel",()=>t.remove(),{once:!0}),t.click()}#a(){if(!this.accept)return[];let t={};for(let e of this.accept.split(",")){let i=e.trim();i&&(i.startsWith(".")?(t["application/octet-stream"]=t["application/octet-stream"]||[],t["application/octet-stream"].push(i)):t[i]=t[i]||[])}return Object.keys(t).length?[{accept:t}]:[]}#o=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#c=t=>{if(t.preventDefault(),this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover"),this.disabled)return;let e=t.dataTransfer;e?.files?.length&&this.#h([...e.files])};#h(t){this.#t=t;let e=new FormData;for(let i of this.#t)e.append(this.name||"file",i);this.internals.setFormValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,files:this.files}})),this.render()}disconnected(){super.disconnected(),this.#e&&(this.#e.removeEventListener("click",this.#i),this.#e.removeEventListener("keydown",this.#s),this.#e.removeEventListener("dragover",this.#o),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#c)),this.#e=null}};w("upload-ui",Bn);var Nn=pO({name:"draggable",category:"motion-positioning",description:"Pointer drag to reposition",attributes:["data-draggable-dragging"],events:["drag-end"],config:[],setup({host:s}){let t=!1,e=0,i=0,n=0,r=0;function o(){return s.hasAttribute("disabled")}function a(c){if(o())return;t=!0,e=c.clientX,i=c.clientY;let u=getComputedStyle(s),d=u.translate;if(d&&d!=="none"){let f=d.split(/\s+/).map(parseFloat);n=f[0]||0,r=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);n=f.m41,r=f.m42}s.setPointerCapture(c.pointerId),s.setAttribute("data-draggable-dragging",""),s.style.touchAction="none"}function l(c){if(!t)return;let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.style.translate=`${f}px ${p}px`}function h(c){if(!t)return;t=!1,s.removeAttribute("data-draggable-dragging");let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.dispatchEvent(new CustomEvent("drag-end",{bubbles:!0,detail:{x:f,y:p}}))}return s.addEventListener("pointerdown",a),s.addEventListener("pointermove",l),s.addEventListener("pointerup",h),()=>{s.removeEventListener("pointerdown",a),s.removeEventListener("pointermove",l),s.removeEventListener("pointerup",h),s.removeAttribute("data-draggable-dragging"),s.style.touchAction=""}}});var zn=class extends A{static properties={variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"",reflect:!0},elevation:{type:Number,default:1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Nn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Nn),this.#t=!0)}};w("card-ui",zn);var Vn=class s extends A{static properties={src:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},shape:{type:String,default:"circle",reflect:!0}};get displayName(){return this.text||this.name}static template=()=>null;static#t=!1;#e=null;#i=null;#s=null;connected(){this.setAttribute("role","img"),this.name&&!this.text&&!s.#t&&(s.#t=!0,console.warn('[AdiaUI] <avatar-ui name="\u2026"> is deprecated \u2014 use text="\u2026" instead. Docs: https://ui-kit.exe.xyz/site/components/avatar'))}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#e||(this.#e=document.createElement("img"),this.#e.setAttribute("slot","img"),this.#e.onerror=()=>{this.#e.remove(),this.#e=null,this.#n()}),this.#e.src=this.src,this.#e.alt=this.name||"",this.#e.parentElement||this.appendChild(this.#e),this.#i&&(this.#i.remove(),this.#i=null)):this.icon?(this.#e&&(this.#e.remove(),this.#e=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s)),this.#s.setAttribute("name",this.icon)):(this.#e&&(this.#e.remove(),this.#e=null),this.#s&&(this.#s.remove(),this.#s=null),this.#n()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#n(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","initials"),this.appendChild(this.#i)),this.#i.textContent=t}},jn=class extends A{static properties={max:{type:Number,default:5,reflect:!0},size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Avatar group")}render(){let t=[...this.querySelectorAll("avatar-ui")],e=this.max,i=t.length-e;if(this.size)for(let r of t)r.setAttribute("size",this.size);t.forEach((r,o)=>{r.style.display=o<e?"":"none",r.style.zIndex=String(t.length-o)});let n=this.querySelector('[slot="overflow"]');i>0?(n||(n=document.createElement("span"),n.setAttribute("slot","overflow"),this.appendChild(n)),n.textContent=`+${i}`,n.setAttribute("aria-label",`${i} more`),n.style.zIndex="0"):n&&n.remove()}};w("avatar-ui",Vn),w("avatar-group-ui",jn);var _n=class extends A{static properties={value:{type:Number,default:null,reflect:!0},variant:{type:String,default:"bar",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.variant==="bar"&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","track"),this.#e=document.createElement("div"),this.#e.setAttribute("slot","fill"),this.#t.appendChild(this.#e),this.appendChild(this.#t))}render(){let t=this.value==null||this.value<0,e=Math.max(0,Math.min(100,this.value));this.setAttribute("aria-busy",String(t)),t?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",String(e)),this.#e&&(this.#e.style.width=t?"100%":`${e}%`)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null}};w("progress-ui",_n);var Wn=class extends A{static properties={value:{type:Number,default:0,reflect:!0},total:{type:Number,default:0,reflect:!0},caption:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),!this.querySelector(':scope > [slot="caption"]')&&!this.querySelector(':scope > [slot="track"]')?(this.#t=document.createElement("span"),this.#t.setAttribute("slot","caption"),this.appendChild(this.#t),this.#e=document.createElement("div"),this.#e.setAttribute("slot","track"),this.appendChild(this.#e)):(this.#t=this.querySelector(':scope > [slot="caption"]'),this.#e=this.querySelector(':scope > [slot="track"]'))}render(){let t=Math.max(0,this.total|0),e=Math.max(0,Math.min(t,this.value|0));if(this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(e)),this.#t&&!this.#t.dataset.custom&&(this.#t.textContent=this.caption||"",this.#t.toggleAttribute("hidden",!this.caption)),this.#e){let i=this.#e.children.length;for(;this.#e.children.length<t;)this.#e.appendChild(document.createElement("span"));for(;this.#e.children.length>t;)this.#e.lastElementChild.remove();for(let n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};w("step-progress-ui",Wn);var Yn=class extends A{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},radius:{type:String,default:"sm",reflect:!0},static:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("aria-hidden","true"),this.#t()}render(){this.#t()}#t(){this.style.width=this.width,this.style.height=this.height}};w("skeleton-ui",Yn);var Un=class extends A{static properties={size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"arc",reflect:!0},tone:{type:String,default:"current",reflect:!0},paused:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"Loading",reflect:!1}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-busy")||this.setAttribute("aria-busy","true"),this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}render(){this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}#t(){let t=this.variant==="dots",e=this.querySelectorAll(":scope > [data-spinner-dot]");if(t){if(e.length===3)return;e.forEach(n=>n.remove());let i=document.createDocumentFragment();for(let n=1;n<=3;n++){let r=document.createElement("span");r.setAttribute("data-spinner-dot",String(n)),r.setAttribute("aria-hidden","true"),i.appendChild(r)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};w("spinner-ui",Un);var Fn=class extends A{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let n=!!t.get.call(this);e.call(this,i),!!i!==n&&this.#s(!!i)},configurable:!0})}}connected(){this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.setAttribute("aria-label",this.label||"Loading"),this.#t=this.parentElement,this.active&&this.#s(!0)}disconnected(){this.#a(),this.#i&&this.#r(),this.#t=null}render(){let t=this.label||"Loading";this.setAttribute("aria-label",t);let e=this.querySelector(":scope > spinner-ui[data-loading-overlay-auto]");e&&e.getAttribute("label")!==t&&e.setAttribute("label",t),this.children.length===0&&this.#o()}#s(t){if(this.#a(),t){let e=Math.max(0,Number(this.delay)||0);e===0?this.#n():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#n()},e)}else this.#i&&this.#r()}#n(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#r(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#a(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#o(){let t=document.createElement("spinner-ui");t.setAttribute("size","lg"),t.setAttribute("tone","subtle"),t.setAttribute("label",this.label||"Loading"),t.setAttribute("data-loading-overlay-auto",""),this.appendChild(t)}};w("loading-overlay-ui",Fn);var $O=new Set;function CO(s,t){$O.has(s)||($O.add(s),console.warn(`[alert-ui] ${t}`))}var Gn=class s extends A{static properties={text:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},closable:{type:Boolean,default:!1,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},amount:{type:Number,default:0,reflect:!0},currency:{type:String,default:"USD",reflect:!0},dueAt:{type:String,default:"",reflect:!0,attribute:"due-at"},cardLast4:{type:String,default:"",reflect:!0,attribute:"card-last4"},reason:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>',content:'<span slot="content"></span>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>'};static#t={declined:"x-circle",expired:"clock",insufficient:"wallet",network:"wifi-slash"};static template=()=>null;#e(){this.getAttribute("variant")==="error"&&(CO("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger, muted, neutral]. Mapping to "danger". Fix the source (LLM prompt / corpus pattern) to emit "danger" directly.'),this.setAttribute("variant","danger")),this.hasAttribute("closeable")&&!this.hasAttribute("closable")&&!this.hasAttribute("dismissible")&&(CO("alias-closeable","attribute [closeable] is a misspelled alias of canonical [closable]. Mapping. Fix the source to use [closable] or [dismissible]."),this.setAttribute("closable",""),this.removeAttribute("closeable")),this.hasAttribute("dismissible")&&!this.hasAttribute("closable")&&this.setAttribute("closable","")}#i=t=>{if(t.target.closest('[slot="close"]')){this.#h();return}if(this.pattern==="dunning"){let e=t.target.closest("[data-dunning-action]");if(e&&this.contains(e)){let i=e.getAttribute("data-dunning-action")||"";this.dispatchEvent(new CustomEvent("dunning-action",{bubbles:!0,composed:!0,detail:{action:i,amount:this.amount,currency:this.currency,dueAt:this.dueAt}}))}}};connected(){this.#e(),this.#c(),(this.icon||this.pattern==="dunning"&&this.reason)&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#i)}disconnected(){this.removeEventListener("press",this.#i)}render(){if(this.pattern==="dunning"){this.#s(),this.#c();return}if(this.icon){let e=this.ensure("leading");e&&e.setAttribute("name",this.icon)}else this.drop("leading");let t=this.ensure("content");if(t){let e=t.hasAttribute("data-alert-auto"),i=t.childNodes.length>0;if(!e&&i){if(this.title||this.description){let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#c()}#s(){let t=this.icon||s.#t[this.reason]||"x-circle",e=this.ensure("leading");e&&e.setAttribute("name",t);let i=this.ensure("content");if(!i)return;i.setAttribute("data-alert-auto","dunning"),i.replaceChildren();let n=this.title||this.#n();if(n){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=n,i.appendChild(l)}let r=this.#r(),o=this.#o();if(r||o){if(i.appendChild(document.createTextNode(" ")),r){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=r,i.appendChild(l)}if(r&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[n,r,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#n(){switch(this.reason){case"expired":return"Card expired";case"insufficient":return"Insufficient funds";case"network":return"Network error";case"declined":return"Payment failed";default:return this.variant==="warning"?"Payment due soon":"Payment failed"}}#r(){if(!this.amount&&this.amount!==0||this.amount===0)return"";try{let t=this.getAttribute("lang")||this.lang||void 0;return new Intl.NumberFormat(t,{style:"currency",currency:this.currency||"USD"}).format(this.amount)}catch{return`${this.currency||""} ${this.amount}`.trim()}}#a(){if(!this.dueAt)return"";let t=new Date(this.dueAt);if(Number.isNaN(t.getTime()))return"";try{let e=this.getAttribute("lang")||this.lang||void 0;return new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}).format(t)}catch{return t.toDateString()}}#o(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#a();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#c(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#h(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};w("alert-ui",Gn);var j1={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},Hn=class extends A{static properties={text:{type:String,default:"",reflect:!1},variant:{type:String,default:"default",reflect:!0},icon:{type:String,default:"",reflect:!0},live:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>'};static requiredIcons=["info","check-circle","warning","x-circle"];static template=()=>null;#t(t){return!!(t&&(t._uiPart||t.hasAttribute("data-im-auto")))}connected(){}render(){this.live?this.setAttribute("aria-live",this.live):this.hasAttribute("aria-live")&&this.removeAttribute("aria-live"),this.#e();let t=this.icon||j1[this.variant]||"",e=this.querySelector(':scope > [slot="leading"]');if(!(e&&!this.#t(e)))if(t){let i=this.ensure("leading");i&&(i.setAttribute("data-im-auto",""),i.getAttribute("name")!==t&&i.setAttribute("name",t))}else this.drop("leading")}#e(){let t=this.querySelector(":scope > [data-im-text]");if(Array.from(this.childNodes).some(i=>i===t?!1:i.nodeType===Node.ELEMENT_NODE?!(i.getAttribute&&i.getAttribute("slot")==="leading"):!!(i.nodeType===Node.TEXT_NODE&&i.textContent.trim()))){t&&t.remove();return}this.text?(t||(t=document.createElement("span"),t.setAttribute("data-im-text",""),this.appendChild(t)),t.textContent!==this.text&&(t.textContent=this.text)):t&&t.remove()}};w("inline-message-ui",Hn);var Kn=class extends A{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};w("kbd-ui",Kn);var Jn=class extends A{static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},removable:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={dismiss:'<button slot="dismiss" type="button" aria-label="Remove"><icon-ui name="x"></icon-ui></button>'};static template=()=>null;#t=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#e=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};connected(){this.setAttribute("role","status"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")),this.removable&&!this.disabled){let t=this.ensure("dismiss");t&&t.parentElement!==this&&this.appendChild(t)}else this.drop("dismiss")}};w("tag-ui",Jn);var _1=new Set(["block","dot","square","line","dashed"]),W1=new Set(["sm","md","lg"]),Y1=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),U1={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},F1={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function G1(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&Y1.has(t)):[]}var rs=null;function H1(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!rs){let u=document.createElement("canvas");u.width=1,u.height=1,rs=u.getContext("2d")}rs.fillStyle="#000",rs.clearRect(0,0,1,1),rs.fillStyle=s,rs.fillRect(0,0,1,1);let[t,e,i]=rs.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let n=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},r=n(t),o=n(e),a=n(i),l=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var tr=class extends A{static properties={shape:{type:String,default:"square",reflect:!0},size:{type:String,default:"md",reflect:!0},color:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},detail:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},copyable:{type:Boolean,default:!1,reflect:!0},copyValue:{type:String,default:""},selectable:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},autoContrast:{type:Boolean,default:!1,reflect:!0},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;connected(){this.#d(),this.#k(),this.#u=new MutationObserver(t=>{let e=!1;for(let i of t){for(let n of i.addedNodes)if(n.nodeType===1){if(n.getAttribute?.("slot")==="chrome"){e=!0;break}if(n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#p(),this.#u.takeRecords())}),this.#u.observe(this,{childList:!0})}render(){this.#d(),this.#f(),this.#m(),this.#g(),this.#y(),this.#w(),this.#O()}#d(){if(this.#r)return;let t=Array.from(this.children).filter(r=>r.getAttribute&&r.getAttribute("slot")==="chrome");for(let r of t)r.remove();let e=Array.from(this.children).filter(r=>r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]'));for(let r of e)r.remove();let i=[];for(let r of Array.from(this.childNodes))(r.nodeType===3&&!r.data||r.nodeType===8)&&i.push(r);for(let r of i)r.remove();let n=Array.from(this.childNodes).filter(r=>!(r.nodeType===1&&r.dataset&&(r.dataset.tile!==void 0||r.dataset.label!==void 0||r.dataset.detail!==void 0||r.dataset.badge!==void 0||r.dataset.copy!==void 0))&&!(r.nodeType===3&&!r.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let r of t)this.appendChild(r);for(let r of e)this.appendChild(r);for(let r of i)this.appendChild(r);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),n.length)for(let r of n)this.#e.appendChild(r);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#n=document.createElement("button"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("type","button"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.textContent="\u29C9",this.appendChild(this.#n),this.#r=!0}#p(){if(!this.#t||!this.#s)return;let t=[];for(let e of this.children)if(e!==this.#t){if(e===this.#s)break;e.getAttribute?.("slot")==="chrome"&&t.push(e)}for(let e of Array.from(this.children))e!==this.#t&&e!==this.#s&&e!==this.#e&&e!==this.#i&&e!==this.#n&&e.getAttribute?.("slot")==="chrome"&&this.insertBefore(e,this.#s);for(let e of Array.from(this.children))e===this.#t||e===this.#s||e===this.#e||e===this.#i||e===this.#n||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#f(){if(!this.#t||!this.#e)return;this.#p();let t=_1.has(this.shape)?this.shape:"square",e=W1.has(this.size)?this.size:"md";t!==this.shape&&this.setAttribute("shape",t),e!==this.size&&this.setAttribute("size",e),this.color&&this.style.setProperty("--swatch-color",this.color),!this.#e.firstChild&&this.label?this.#e.textContent=this.label:this.#e.firstChild?.nodeType===3&&this.label&&(this.#e.textContent=this.label);let i=this.#e.textContent.trim().length>0||this.#e.firstElementChild!=null;this.#e.toggleAttribute("hidden",!i)}#m(){if(!this.#s)return;let t=G1(this.badge);if(t.length===0){this.#s.setAttribute("hidden",""),this.#s.replaceChildren();return}this.#s.removeAttribute("hidden");let e=Array.from(this.#s.children).map(r=>r.dataset.badgeVariant);if(e.length===t.length&&e.every((r,o)=>r===t[o]))return;let n=document.createDocumentFragment();for(let r of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",r),o.setAttribute("role","img"),o.setAttribute("aria-label",F1[r]),o.textContent=U1[r],n.appendChild(o)}this.#s.replaceChildren(n)}#O(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#a=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#a)return;this.#a=t;let e=H1(t);if(e==null){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark");return}let i=e<.62;this.#e.toggleAttribute("data-on-dark",i),this.#e.toggleAttribute("data-on-light",!i)}#g(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#y(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#x();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#w(){this.selectable?(this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.setAttribute("aria-pressed",this.selected?"true":"false")):(this.getAttribute("role")==="button"&&this.removeAttribute("role"),this.getAttribute("tabindex")==="0"&&this.removeAttribute("tabindex"),this.removeAttribute("aria-pressed"))}#k(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#v()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#n&&(t.preventDefault(),this.#v()))},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#x();e&&this.#S(e)},this.#n.addEventListener("click",this.#c)}#v(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#x(){return this.copyValue?this.copyValue:this.color?this.color:""}async#S(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#b(e)}#b(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#u&&(this.#u.disconnect(),this.#u=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#c&&this.#n.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};w("swatch-ui",tr);var PO={xs:0,sm:480,md:768,lg:1024,xl:1280},os=Object.keys(PO),Tu=Object.values(PO);function EO(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=os.length-1;t>=0;t--)if(s>=Tu[t])return os[t];return"xs"}var ke=Mi(EO());if(typeof window<"u")for(let s=1;s<Tu.length;s++)window.matchMedia(`(min-width: ${Tu[s]}px)`).addEventListener("change",()=>{ke.value=EO()});function Mt(s,t=ke.value){if(!s)return null;if(!s.includes("@"))return s;let e=null,i=new Map;for(let a of s.trim().split(/\s+/)){let l=a.lastIndexOf("@");l===-1?e=a:i.set(a.slice(l+1),a.slice(0,l))}let n=os.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=os.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}var er=class extends A{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"stretch",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;render(){let t=this.gap,e=this.align,i=this.justify,r=t?.includes("@")||e?.includes("@")||i?.includes("@")?ke.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",tA(Mt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Mt(e,r);this.style.setProperty("--col-align",eA(o)),this.style.textAlign=iA(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",sA(Mt(i,r))):this.style.removeProperty("--col-justify")}},K1={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},J1={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function tA(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function eA(s){return K1[s]??s}function iA(s){return{start:"start",center:"center",end:"end"}[s]??""}function sA(s){return J1[s]??s}w("col-ui",er);var ir=class s extends A{static properties={label:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},align:{type:String,default:"start",reflect:!0}};get error(){return this.#O()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=t=>{let e=this.#O();if(!e)return;let i=this.#g(e);i&&(t.preventDefault(),i.focus())};connected(){this.#u(),this.#d(),this.#p(),this.#f(),this.#c(),this.#t?.addEventListener("click",this.#r),this.#n=new MutationObserver(()=>{this.#f(),this.#c(),this.#m(),this.#a()}),this.#n.observe(this,{childList:!0}),this.#a()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#a(),this.#m()}#a(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#o=()=>{this.#a(),this.#m()};#l=null;#c(){let t=this.#O();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#u(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#v("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#p(){if(this.#s=this.querySelector(":scope > [data-field-error]"),this.#s)return;let t=document.createElement("div");t.setAttribute("slot","error"),t.setAttribute("data-field-error",""),t.setAttribute("id",s.#v("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#f(){if(!this.#t)return;let t=this.#O();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#w()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#O();if(!t)return;let e=new Set;this.#i&&!this.#i.hidden&&e.add(this.#i.id),this.#s&&!this.#s.hidden&&e.add(this.#s.id);let n=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(r=>r&&!r.startsWith("field-hint-")&&!r.startsWith("field-err-")),...e].join(" ").trim();n?t.setAttribute("aria-describedby",n):t.removeAttribute("aria-describedby")}#O(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#g(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#y=0;static#w(){return`field-ctl-${++s.#y}`}static#k=0;static#v(t){return`field-${t}-${++s.#k}`}};w("field-ui",ir);var sr=class extends A{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),this.#t=new MutationObserver(t=>{for(let e of t)if(e.type==="childList"&&(this.#i(e.addedNodes)||this.#i(e.removedNodes))){this.#e();return}}),this.#t.observe(this,{childList:!0})}disconnected(){this.#t?.disconnect(),this.#t=null}render(){this.#e()}#e(){let t=this.hasAttribute("inline");for(let e of this.children)e.localName==="field-ui"&&(t?e.hasAttribute("inline")||e.setAttribute("inline",""):e.hasAttribute("inline")&&e.removeAttribute("inline"))}#i(t){for(let e of t)if(e.nodeType===1&&e.localName==="field-ui")return!0;return!1}};w("fields-ui",sr);var nr=class extends A{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"center",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},wrapAt:{type:String,default:"",reflect:!0,attribute:"wrap-at"},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Nn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Nn),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,n=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!n?ke.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",oA(Mt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",aA(Mt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",lA(Mt(i,o))):this.style.removeProperty("--row-justify"),n){let a=os.indexOf(o),l=os.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},nA={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},rA={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function oA(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function aA(s){return nA[s]??s}function lA(s){return rA[s]??s}w("row-ui",nr);var rr=class extends A{static properties={columns:{type:String,default:"3",reflect:!0},gap:{type:String,default:"md",reflect:!0},columnGap:{type:String,default:"",reflect:!0,attribute:"column-gap"},rowGap:{type:String,default:"",reflect:!0,attribute:"row-gap"}};static template=()=>null;render(){let t=ke.value,e=this.columns;if(e?.includes("@")){let n=Mt(e,t);this.style.gridTemplateColumns=this.#t(n),this.style.gridAutoFlow=n?"row":"",this.style.gridAutoColumns=n?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";let i=this.gap;if(i?.includes("@")){let n=Mt(i,t),r=this.#e(n);this.style.columnGap=r,this.style.rowGap=r}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(12rem, 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(12rem, 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};w("grid-ui",rr);var or=class extends A{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};w("stack-ui",or);function as(s,t,e=5){let n=(t-s||1)/e,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*r,h=Math.floor(s/l)*l,c=Math.ceil(t/l)*l,u=[];for(let d=h;d<=c+l*.5;d+=l)u.push(+d.toFixed(10));return u}function QO(s){if(s==null)return"";let t=+s;return Number.isNaN(t)?String(s):Math.abs(t)>=1e6?(t/1e6).toFixed(1).replace(/\.0$/,"")+"M":Math.abs(t)>=1e3?(t/1e3).toFixed(1).replace(/\.0$/,"")+"K":Number.isInteger(t)?String(t):t.toFixed(1)}function te(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function gt({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${te(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${te(String(i))}"`),n}function ee(s,t,e){return s+t*Math.cos(e)}function ie(s,t,e){return s+t*Math.sin(e)}function hA(s,t,e,i,n){let r=ee(s,e,i),o=ie(t,e,i),a=ee(s,e,n),l=ie(t,e,n),h=n-i>Math.PI?1:0;return`M ${s} ${t} L ${r} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function Lu(s,t,e,i,n,r,o=0){let a=(e-i)/2,l=r-n,h=Math.max(0,Math.min(o,a)),c=()=>{let mt=ee(s,e,n),ut=ie(t,e,n),vt=ee(s,e,r),At=ie(t,e,r),xt=ee(s,i,r),zt=ie(t,i,r),Vt=ee(s,i,n),Li=ie(t,i,n),ts=l>Math.PI?1:0;return`M ${mt} ${ut} A ${e} ${e} 0 ${ts} 1 ${vt} ${At} L ${xt} ${zt} A ${i} ${i} 0 ${ts} 0 ${Vt} ${Li} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,O=r-d,g=p-f>Math.PI?1:0,y=ee(s,e,f),v=ie(t,e,f),x=ee(s,e,p),S=ie(t,e,p),$=ee(s,i,O),k=ie(t,i,O),P=ee(s,i,m),T=ie(t,i,m),E=ee(s,e-h,n),X=ie(t,e-h,n),I=ee(s,i+h,n),V=ie(t,i+h,n),j=ee(s,e-h,r),_=ie(t,e-h,r),tt=ee(s,i+h,r),rt=ie(t,i+h,r);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${x} ${S} A ${h} ${h} 0 0 1 ${j} ${_} L ${tt} ${rt} A ${h} ${h} 0 0 1 ${$} ${k} A ${i} ${i} 0 ${g} 0 ${P} ${T} A ${h} ${h} 0 0 1 ${I} ${V} L ${E} ${X} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function ia(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(n=>`${n.x},${n.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let n=0;n<e-1;n++){let r=s[Math.max(n-1,0)],o=s[n],a=s[n+1],l=s[Math.min(n+2,e-1)],h=o.x+(a.x-r.x)*t/3,c=o.y+(a.y-r.y)*t/3,u=a.x-(l.x-o.x)*t/3,d=a.y-(l.y-o.y)*t/3;i+=` C${h},${c} ${u},${d} ${a.x},${a.y}`}return i}function Mu(s,t,e=.4){let i=ia(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function $l(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}var TO={std:{ratio:4/3},wide:{ratio:16/9},square:{ratio:1},tall:{ratio:3/4}},ar=class extends A{static properties={type:{type:String,default:"bar",reflect:!0},heading:{type:String,default:"",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},hideAverage:{type:Boolean,default:!1,reflect:!0,attribute:"hide-average"},color:{type:String,default:"",reflect:!0},hideGrid:{type:Boolean,default:!1,reflect:!0,attribute:"hide-grid"},hideValues:{type:Boolean,default:!1,reflect:!0,attribute:"hide-values"},radius:{type:Number,default:null,reflect:!0},smooth:{type:Number,default:.4,reflect:!0},aspect:{type:String,default:"std",reflect:!0},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#a=new Set;#o(){if(this.radius!=null)return this.radius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}set data(t){!Array.isArray(t)&&!this.#e&&(this.#e=!0,console.warn(`[chart-ui] .data must be an array of plain objects \u2014 received ${t===null?"null":typeof t}. The {labels, datasets} envelope is the Chart.js API, not the chart-ui API.
175
+ `),this.#e=this.querySelector("[data-dropzone]"),this.#e&&(this.#e.addEventListener("click",this.#i),this.#e.addEventListener("keydown",this.#s),this.#e.addEventListener("dragover",this.#o),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#c))}render(){let t=this.querySelector("[data-filelist]");if(!this.#e||!t)return;let e=this.querySelector("span[hint]");e&&this.hint&&e.setAttribute("hint",this.hint),t.innerHTML="";for(let i of this.#t){let n=document.createElement("span");n.textContent=i.name,t.appendChild(n)}}get files(){return this.#t}#i=()=>{this.disabled||this.#n()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#n())};async#n(){try{if(window.showOpenFilePicker){let t=this.#a(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let n=await Promise.all(i.map(r=>r.getFile()));if(!this.isConnected)return;this.#h(n)}else this.#r()}catch(t){if(t.name!=="AbortError")throw t}}#r(){let t=document.createElement("input");t.type="file",this.accept&&(t.accept=this.accept),this.multiple&&(t.multiple=!0),t.style.display="none",document.body.appendChild(t),t.addEventListener("change",()=>{t.files?.length&&this.#h([...t.files]),t.remove()},{once:!0}),t.addEventListener("cancel",()=>t.remove(),{once:!0}),t.click()}#a(){if(!this.accept)return[];let t={};for(let e of this.accept.split(",")){let i=e.trim();i&&(i.startsWith(".")?(t["application/octet-stream"]=t["application/octet-stream"]||[],t["application/octet-stream"].push(i)):t[i]=t[i]||[])}return Object.keys(t).length?[{accept:t}]:[]}#o=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#c=t=>{if(t.preventDefault(),this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover"),this.disabled)return;let e=t.dataTransfer;e?.files?.length&&this.#h([...e.files])};#h(t){this.#t=t;let e=new FormData;for(let i of this.#t)e.append(this.name||"file",i);this.internals.setFormValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,files:this.files}})),this.render()}disconnected(){super.disconnected(),this.#e&&(this.#e.removeEventListener("click",this.#i),this.#e.removeEventListener("keydown",this.#s),this.#e.removeEventListener("dragover",this.#o),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#c)),this.#e=null}};w("upload-ui",Bn);var Nn=pO({name:"draggable",category:"motion-positioning",description:"Pointer drag to reposition",attributes:["data-draggable-dragging"],events:["drag-end"],config:[],setup({host:s}){let t=!1,e=0,i=0,n=0,r=0;function o(){return s.hasAttribute("disabled")}function a(c){if(o())return;t=!0,e=c.clientX,i=c.clientY;let u=getComputedStyle(s),d=u.translate;if(d&&d!=="none"){let f=d.split(/\s+/).map(parseFloat);n=f[0]||0,r=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);n=f.m41,r=f.m42}s.setPointerCapture(c.pointerId),s.setAttribute("data-draggable-dragging",""),s.style.touchAction="none"}function l(c){if(!t)return;let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.style.translate=`${f}px ${p}px`}function h(c){if(!t)return;t=!1,s.removeAttribute("data-draggable-dragging");let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.dispatchEvent(new CustomEvent("drag-end",{bubbles:!0,detail:{x:f,y:p}}))}return s.addEventListener("pointerdown",a),s.addEventListener("pointermove",l),s.addEventListener("pointerup",h),()=>{s.removeEventListener("pointerdown",a),s.removeEventListener("pointermove",l),s.removeEventListener("pointerup",h),s.removeAttribute("data-draggable-dragging"),s.style.touchAction=""}}});var zn=class extends A{static properties={variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"",reflect:!0},elevation:{type:Number,default:1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Nn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Nn),this.#t=!0)}};w("card-ui",zn);var Vn=class s extends A{static properties={src:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},shape:{type:String,default:"circle",reflect:!0}};get displayName(){return this.text||this.name}static template=()=>null;static#t=!1;#e=null;#i=null;#s=null;connected(){this.setAttribute("role","img"),this.name&&!this.text&&!s.#t&&(s.#t=!0,console.warn('[AdiaUI] <avatar-ui name="\u2026"> is deprecated \u2014 use text="\u2026" instead. Docs: https://ui-kit.exe.xyz/site/components/avatar'))}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#e||(this.#e=document.createElement("img"),this.#e.setAttribute("slot","img"),this.#e.onerror=()=>{this.#e.remove(),this.#e=null,this.#n()}),this.#e.src=this.src,this.#e.alt=this.name||"",this.#e.parentElement||this.appendChild(this.#e),this.#i&&(this.#i.remove(),this.#i=null)):this.icon?(this.#e&&(this.#e.remove(),this.#e=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s)),this.#s.setAttribute("name",this.icon)):(this.#e&&(this.#e.remove(),this.#e=null),this.#s&&(this.#s.remove(),this.#s=null),this.#n()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#n(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","initials"),this.appendChild(this.#i)),this.#i.textContent=t}},jn=class extends A{static properties={max:{type:Number,default:5,reflect:!0},size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Avatar group")}render(){let t=[...this.querySelectorAll("avatar-ui")],e=this.max,i=t.length-e;if(this.size)for(let r of t)r.setAttribute("size",this.size);t.forEach((r,o)=>{r.style.display=o<e?"":"none",r.style.zIndex=String(t.length-o)});let n=this.querySelector('[slot="overflow"]');i>0?(n||(n=document.createElement("span"),n.setAttribute("slot","overflow"),this.appendChild(n)),n.textContent=`+${i}`,n.setAttribute("aria-label",`${i} more`),n.style.zIndex="0"):n&&n.remove()}};w("avatar-ui",Vn),w("avatar-group-ui",jn);var _n=class extends A{static properties={value:{type:Number,default:null,reflect:!0},variant:{type:String,default:"bar",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.variant==="bar"&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","track"),this.#e=document.createElement("div"),this.#e.setAttribute("slot","fill"),this.#t.appendChild(this.#e),this.appendChild(this.#t))}render(){let t=this.value==null||this.value<0,e=Math.max(0,Math.min(100,this.value));this.setAttribute("aria-busy",String(t)),t?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",String(e)),this.#e&&(this.#e.style.width=t?"100%":`${e}%`)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null}};w("progress-ui",_n);var Wn=class extends A{static properties={value:{type:Number,default:0,reflect:!0},total:{type:Number,default:0,reflect:!0},caption:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),!this.querySelector(':scope > [slot="caption"]')&&!this.querySelector(':scope > [slot="track"]')?(this.#t=document.createElement("span"),this.#t.setAttribute("slot","caption"),this.appendChild(this.#t),this.#e=document.createElement("div"),this.#e.setAttribute("slot","track"),this.appendChild(this.#e)):(this.#t=this.querySelector(':scope > [slot="caption"]'),this.#e=this.querySelector(':scope > [slot="track"]'))}render(){let t=Math.max(0,this.total|0),e=Math.max(0,Math.min(t,this.value|0));if(this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(e)),this.#t&&!this.#t.dataset.custom&&(this.#t.textContent=this.caption||"",this.#t.toggleAttribute("hidden",!this.caption)),this.#e){let i=this.#e.children.length;for(;this.#e.children.length<t;)this.#e.appendChild(document.createElement("span"));for(;this.#e.children.length>t;)this.#e.lastElementChild.remove();for(let n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};w("step-progress-ui",Wn);var Yn=class extends A{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},radius:{type:String,default:"sm",reflect:!0},static:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("aria-hidden","true"),this.#t()}render(){this.#t()}#t(){this.style.width=this.width,this.style.height=this.height}};w("skeleton-ui",Yn);var Un=class extends A{static properties={size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"arc",reflect:!0},tone:{type:String,default:"current",reflect:!0},paused:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"Loading",reflect:!1}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-busy")||this.setAttribute("aria-busy","true"),this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}render(){this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}#t(){let t=this.variant==="dots",e=this.querySelectorAll(":scope > [data-spinner-dot]");if(t){if(e.length===3)return;e.forEach(n=>n.remove());let i=document.createDocumentFragment();for(let n=1;n<=3;n++){let r=document.createElement("span");r.setAttribute("data-spinner-dot",String(n)),r.setAttribute("aria-hidden","true"),i.appendChild(r)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};w("spinner-ui",Un);var Fn=class extends A{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let n=!!t.get.call(this);e.call(this,i),!!i!==n&&this.#s(!!i)},configurable:!0})}}connected(){this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.setAttribute("aria-label",this.label||"Loading"),this.#t=this.parentElement,this.active&&this.#s(!0)}disconnected(){this.#a(),this.#i&&this.#r(),this.#t=null}render(){let t=this.label||"Loading";this.setAttribute("aria-label",t);let e=this.querySelector(":scope > spinner-ui[data-loading-overlay-auto]");e&&e.getAttribute("label")!==t&&e.setAttribute("label",t),this.children.length===0&&this.#o()}#s(t){if(this.#a(),t){let e=Math.max(0,Number(this.delay)||0);e===0?this.#n():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#n()},e)}else this.#i&&this.#r()}#n(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#r(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#a(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#o(){let t=document.createElement("spinner-ui");t.setAttribute("size","lg"),t.setAttribute("tone","subtle"),t.setAttribute("label",this.label||"Loading"),t.setAttribute("data-loading-overlay-auto",""),this.appendChild(t)}};w("loading-overlay-ui",Fn);var $O=new Set;function CO(s,t){$O.has(s)||($O.add(s),console.warn(`[alert-ui] ${t}`))}var Gn=class s extends A{static properties={text:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},closable:{type:Boolean,default:!1,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},amount:{type:Number,default:0,reflect:!0},currency:{type:String,default:"USD",reflect:!0},dueAt:{type:String,default:"",reflect:!0,attribute:"due-at"},cardLast4:{type:String,default:"",reflect:!0,attribute:"card-last4"},reason:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>',content:'<span slot="content"></span>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>'};static#t={declined:"x-circle",expired:"clock",insufficient:"wallet",network:"wifi-slash"};static template=()=>null;#e(){this.getAttribute("variant")==="error"&&(CO("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger, muted, neutral]. Mapping to "danger". Fix the source (LLM prompt / corpus pattern) to emit "danger" directly.'),this.setAttribute("variant","danger")),this.hasAttribute("closeable")&&!this.hasAttribute("closable")&&!this.hasAttribute("dismissible")&&(CO("alias-closeable","attribute [closeable] is a misspelled alias of canonical [closable]. Mapping. Fix the source to use [closable] or [dismissible]."),this.setAttribute("closable",""),this.removeAttribute("closeable")),this.hasAttribute("dismissible")&&!this.hasAttribute("closable")&&this.setAttribute("closable","")}#i=t=>{if(t.target.closest('[slot="close"]')){this.#h();return}if(this.pattern==="dunning"){let e=t.target.closest("[data-dunning-action]");if(e&&this.contains(e)){let i=e.getAttribute("data-dunning-action")||"";this.dispatchEvent(new CustomEvent("dunning-action",{bubbles:!0,composed:!0,detail:{action:i,amount:this.amount,currency:this.currency,dueAt:this.dueAt}}))}}};connected(){this.#e(),this.#c(),(this.icon||this.pattern==="dunning"&&this.reason)&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#i)}disconnected(){this.removeEventListener("press",this.#i)}render(){if(this.pattern==="dunning"){this.#s(),this.#c();return}if(this.icon){let e=this.ensure("leading");e&&e.setAttribute("name",this.icon)}else this.drop("leading");let t=this.ensure("content");if(t){let e=t.hasAttribute("data-alert-auto"),i=t.childNodes.length>0;if(!e&&i){if(this.title||this.description){let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#c()}#s(){let t=this.icon||s.#t[this.reason]||"x-circle",e=this.ensure("leading");e&&e.setAttribute("name",t);let i=this.ensure("content");if(!i)return;i.setAttribute("data-alert-auto","dunning"),i.replaceChildren();let n=this.title||this.#n();if(n){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=n,i.appendChild(l)}let r=this.#r(),o=this.#o();if(r||o){if(i.appendChild(document.createTextNode(" ")),r){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=r,i.appendChild(l)}if(r&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[n,r,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#n(){switch(this.reason){case"expired":return"Card expired";case"insufficient":return"Insufficient funds";case"network":return"Network error";case"declined":return"Payment failed";default:return this.variant==="warning"?"Payment due soon":"Payment failed"}}#r(){if(!this.amount&&this.amount!==0||this.amount===0)return"";try{let t=this.getAttribute("lang")||this.lang||void 0;return new Intl.NumberFormat(t,{style:"currency",currency:this.currency||"USD"}).format(this.amount)}catch{return`${this.currency||""} ${this.amount}`.trim()}}#a(){if(!this.dueAt)return"";let t=new Date(this.dueAt);if(Number.isNaN(t.getTime()))return"";try{let e=this.getAttribute("lang")||this.lang||void 0;return new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}).format(t)}catch{return t.toDateString()}}#o(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#a();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#c(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#h(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};w("alert-ui",Gn);var j1={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},Hn=class extends A{static properties={text:{type:String,default:"",reflect:!1},variant:{type:String,default:"default",reflect:!0},icon:{type:String,default:"",reflect:!0},live:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>'};static requiredIcons=["info","check-circle","warning","x-circle"];static template=()=>null;#t(t){return!!(t&&(t._uiPart||t.hasAttribute("data-im-auto")))}connected(){}render(){this.live?this.setAttribute("aria-live",this.live):this.hasAttribute("aria-live")&&this.removeAttribute("aria-live"),this.#e();let t=this.icon||j1[this.variant]||"",e=this.querySelector(':scope > [slot="leading"]');if(!(e&&!this.#t(e)))if(t){let i=this.ensure("leading");i&&(i.setAttribute("data-im-auto",""),i.getAttribute("name")!==t&&i.setAttribute("name",t))}else this.drop("leading")}#e(){let t=this.querySelector(":scope > [data-im-text]");if(Array.from(this.childNodes).some(i=>i===t?!1:i.nodeType===Node.ELEMENT_NODE?!(i.getAttribute&&i.getAttribute("slot")==="leading"):!!(i.nodeType===Node.TEXT_NODE&&i.textContent.trim()))){t&&t.remove();return}this.text?(t||(t=document.createElement("span"),t.setAttribute("data-im-text",""),this.appendChild(t)),t.textContent!==this.text&&(t.textContent=this.text)):t&&t.remove()}};w("inline-message-ui",Hn);var Kn=class extends A{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};w("kbd-ui",Kn);var Jn=class extends A{static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},removable:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={dismiss:'<button slot="dismiss" type="button" aria-label="Remove"><icon-ui name="x" weight="bold"></icon-ui></button>'};static template=()=>null;#t=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#e=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};connected(){this.setAttribute("role","status"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")),this.removable&&!this.disabled){let t=this.ensure("dismiss");t&&t.parentElement!==this&&this.appendChild(t)}else this.drop("dismiss")}};w("tag-ui",Jn);var _1=new Set(["block","dot","square","line","dashed"]),W1=new Set(["sm","md","lg"]),Y1=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),U1={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},F1={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function G1(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&Y1.has(t)):[]}var rs=null;function H1(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!rs){let u=document.createElement("canvas");u.width=1,u.height=1,rs=u.getContext("2d")}rs.fillStyle="#000",rs.clearRect(0,0,1,1),rs.fillStyle=s,rs.fillRect(0,0,1,1);let[t,e,i]=rs.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let n=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},r=n(t),o=n(e),a=n(i),l=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var tr=class extends A{static properties={shape:{type:String,default:"square",reflect:!0},size:{type:String,default:"md",reflect:!0},color:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},detail:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},copyable:{type:Boolean,default:!1,reflect:!0},copyValue:{type:String,default:""},selectable:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},autoContrast:{type:Boolean,default:!1,reflect:!0},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;connected(){this.#d(),this.#k(),this.#u=new MutationObserver(t=>{let e=!1;for(let i of t){for(let n of i.addedNodes)if(n.nodeType===1){if(n.getAttribute?.("slot")==="chrome"){e=!0;break}if(n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#p(),this.#u.takeRecords())}),this.#u.observe(this,{childList:!0})}render(){this.#d(),this.#f(),this.#m(),this.#g(),this.#y(),this.#w(),this.#O()}#d(){if(this.#r)return;let t=Array.from(this.children).filter(r=>r.getAttribute&&r.getAttribute("slot")==="chrome");for(let r of t)r.remove();let e=Array.from(this.children).filter(r=>r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]'));for(let r of e)r.remove();let i=[];for(let r of Array.from(this.childNodes))(r.nodeType===3&&!r.data||r.nodeType===8)&&i.push(r);for(let r of i)r.remove();let n=Array.from(this.childNodes).filter(r=>!(r.nodeType===1&&r.dataset&&(r.dataset.tile!==void 0||r.dataset.label!==void 0||r.dataset.detail!==void 0||r.dataset.badge!==void 0||r.dataset.copy!==void 0))&&!(r.nodeType===3&&!r.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let r of t)this.appendChild(r);for(let r of e)this.appendChild(r);for(let r of i)this.appendChild(r);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),n.length)for(let r of n)this.#e.appendChild(r);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#n=document.createElement("button"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("type","button"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.textContent="\u29C9",this.appendChild(this.#n),this.#r=!0}#p(){if(!this.#t||!this.#s)return;let t=[];for(let e of this.children)if(e!==this.#t){if(e===this.#s)break;e.getAttribute?.("slot")==="chrome"&&t.push(e)}for(let e of Array.from(this.children))e!==this.#t&&e!==this.#s&&e!==this.#e&&e!==this.#i&&e!==this.#n&&e.getAttribute?.("slot")==="chrome"&&this.insertBefore(e,this.#s);for(let e of Array.from(this.children))e===this.#t||e===this.#s||e===this.#e||e===this.#i||e===this.#n||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#f(){if(!this.#t||!this.#e)return;this.#p();let t=_1.has(this.shape)?this.shape:"square",e=W1.has(this.size)?this.size:"md";t!==this.shape&&this.setAttribute("shape",t),e!==this.size&&this.setAttribute("size",e),this.color&&this.style.setProperty("--swatch-color",this.color),!this.#e.firstChild&&this.label?this.#e.textContent=this.label:this.#e.firstChild?.nodeType===3&&this.label&&(this.#e.textContent=this.label);let i=this.#e.textContent.trim().length>0||this.#e.firstElementChild!=null;this.#e.toggleAttribute("hidden",!i)}#m(){if(!this.#s)return;let t=G1(this.badge);if(t.length===0){this.#s.setAttribute("hidden",""),this.#s.replaceChildren();return}this.#s.removeAttribute("hidden");let e=Array.from(this.#s.children).map(r=>r.dataset.badgeVariant);if(e.length===t.length&&e.every((r,o)=>r===t[o]))return;let n=document.createDocumentFragment();for(let r of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",r),o.setAttribute("role","img"),o.setAttribute("aria-label",F1[r]),o.textContent=U1[r],n.appendChild(o)}this.#s.replaceChildren(n)}#O(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#a=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#a)return;this.#a=t;let e=H1(t);if(e==null){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark");return}let i=e<.62;this.#e.toggleAttribute("data-on-dark",i),this.#e.toggleAttribute("data-on-light",!i)}#g(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#y(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#x();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#w(){this.selectable?(this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.setAttribute("aria-pressed",this.selected?"true":"false")):(this.getAttribute("role")==="button"&&this.removeAttribute("role"),this.getAttribute("tabindex")==="0"&&this.removeAttribute("tabindex"),this.removeAttribute("aria-pressed"))}#k(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#v()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#n&&(t.preventDefault(),this.#v()))},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#x();e&&this.#S(e)},this.#n.addEventListener("click",this.#c)}#v(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#x(){return this.copyValue?this.copyValue:this.color?this.color:""}async#S(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#b(e)}#b(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#u&&(this.#u.disconnect(),this.#u=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#c&&this.#n.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};w("swatch-ui",tr);var PO={xs:0,sm:480,md:768,lg:1024,xl:1280},os=Object.keys(PO),Tu=Object.values(PO);function EO(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=os.length-1;t>=0;t--)if(s>=Tu[t])return os[t];return"xs"}var ke=Mi(EO());if(typeof window<"u")for(let s=1;s<Tu.length;s++)window.matchMedia(`(min-width: ${Tu[s]}px)`).addEventListener("change",()=>{ke.value=EO()});function Mt(s,t=ke.value){if(!s)return null;if(!s.includes("@"))return s;let e=null,i=new Map;for(let a of s.trim().split(/\s+/)){let l=a.lastIndexOf("@");l===-1?e=a:i.set(a.slice(l+1),a.slice(0,l))}let n=os.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=os.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}var er=class extends A{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"stretch",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;render(){let t=this.gap,e=this.align,i=this.justify,r=t?.includes("@")||e?.includes("@")||i?.includes("@")?ke.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",tA(Mt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Mt(e,r);this.style.setProperty("--col-align",eA(o)),this.style.textAlign=iA(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",sA(Mt(i,r))):this.style.removeProperty("--col-justify")}},K1={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},J1={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function tA(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function eA(s){return K1[s]??s}function iA(s){return{start:"start",center:"center",end:"end"}[s]??""}function sA(s){return J1[s]??s}w("col-ui",er);var ir=class s extends A{static properties={label:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},align:{type:String,default:"start",reflect:!0}};get error(){return this.#O()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=t=>{let e=this.#O();if(!e)return;let i=this.#g(e);i&&(t.preventDefault(),i.focus())};connected(){this.#u(),this.#d(),this.#p(),this.#f(),this.#c(),this.#t?.addEventListener("click",this.#r),this.#n=new MutationObserver(()=>{this.#f(),this.#c(),this.#m(),this.#a()}),this.#n.observe(this,{childList:!0}),this.#a()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#a(),this.#m()}#a(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#o=()=>{this.#a(),this.#m()};#l=null;#c(){let t=this.#O();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#u(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#v("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#p(){if(this.#s=this.querySelector(":scope > [data-field-error]"),this.#s)return;let t=document.createElement("div");t.setAttribute("slot","error"),t.setAttribute("data-field-error",""),t.setAttribute("id",s.#v("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#f(){if(!this.#t)return;let t=this.#O();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#w()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#O();if(!t)return;let e=new Set;this.#i&&!this.#i.hidden&&e.add(this.#i.id),this.#s&&!this.#s.hidden&&e.add(this.#s.id);let n=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(r=>r&&!r.startsWith("field-hint-")&&!r.startsWith("field-err-")),...e].join(" ").trim();n?t.setAttribute("aria-describedby",n):t.removeAttribute("aria-describedby")}#O(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#g(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#y=0;static#w(){return`field-ctl-${++s.#y}`}static#k=0;static#v(t){return`field-${t}-${++s.#k}`}};w("field-ui",ir);var sr=class extends A{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),this.#t=new MutationObserver(t=>{for(let e of t)if(e.type==="childList"&&(this.#i(e.addedNodes)||this.#i(e.removedNodes))){this.#e();return}}),this.#t.observe(this,{childList:!0})}disconnected(){this.#t?.disconnect(),this.#t=null}render(){this.#e()}#e(){let t=this.hasAttribute("inline");for(let e of this.children)e.localName==="field-ui"&&(t?e.hasAttribute("inline")||e.setAttribute("inline",""):e.hasAttribute("inline")&&e.removeAttribute("inline"))}#i(t){for(let e of t)if(e.nodeType===1&&e.localName==="field-ui")return!0;return!1}};w("fields-ui",sr);var nr=class extends A{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"center",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},wrapAt:{type:String,default:"",reflect:!0,attribute:"wrap-at"},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Nn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Nn),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,n=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!n?ke.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",oA(Mt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",aA(Mt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",lA(Mt(i,o))):this.style.removeProperty("--row-justify"),n){let a=os.indexOf(o),l=os.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},nA={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},rA={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function oA(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function aA(s){return nA[s]??s}function lA(s){return rA[s]??s}w("row-ui",nr);var rr=class extends A{static properties={columns:{type:String,default:"3",reflect:!0},gap:{type:String,default:"md",reflect:!0},columnGap:{type:String,default:"",reflect:!0,attribute:"column-gap"},rowGap:{type:String,default:"",reflect:!0,attribute:"row-gap"}};static template=()=>null;render(){let t=ke.value,e=this.columns;if(e?.includes("@")){let n=Mt(e,t);this.style.gridTemplateColumns=this.#t(n),this.style.gridAutoFlow=n?"row":"",this.style.gridAutoColumns=n?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";let i=this.gap;if(i?.includes("@")){let n=Mt(i,t),r=this.#e(n);this.style.columnGap=r,this.style.rowGap=r}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(12rem, 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(12rem, 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};w("grid-ui",rr);var or=class extends A{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};w("stack-ui",or);function as(s,t,e=5){let n=(t-s||1)/e,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*r,h=Math.floor(s/l)*l,c=Math.ceil(t/l)*l,u=[];for(let d=h;d<=c+l*.5;d+=l)u.push(+d.toFixed(10));return u}function QO(s){if(s==null)return"";let t=+s;return Number.isNaN(t)?String(s):Math.abs(t)>=1e6?(t/1e6).toFixed(1).replace(/\.0$/,"")+"M":Math.abs(t)>=1e3?(t/1e3).toFixed(1).replace(/\.0$/,"")+"K":Number.isInteger(t)?String(t):t.toFixed(1)}function te(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function gt({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${te(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${te(String(i))}"`),n}function ee(s,t,e){return s+t*Math.cos(e)}function ie(s,t,e){return s+t*Math.sin(e)}function hA(s,t,e,i,n){let r=ee(s,e,i),o=ie(t,e,i),a=ee(s,e,n),l=ie(t,e,n),h=n-i>Math.PI?1:0;return`M ${s} ${t} L ${r} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function Lu(s,t,e,i,n,r,o=0){let a=(e-i)/2,l=r-n,h=Math.max(0,Math.min(o,a)),c=()=>{let mt=ee(s,e,n),ut=ie(t,e,n),vt=ee(s,e,r),At=ie(t,e,r),xt=ee(s,i,r),zt=ie(t,i,r),Vt=ee(s,i,n),Li=ie(t,i,n),ts=l>Math.PI?1:0;return`M ${mt} ${ut} A ${e} ${e} 0 ${ts} 1 ${vt} ${At} L ${xt} ${zt} A ${i} ${i} 0 ${ts} 0 ${Vt} ${Li} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,O=r-d,g=p-f>Math.PI?1:0,y=ee(s,e,f),v=ie(t,e,f),x=ee(s,e,p),S=ie(t,e,p),$=ee(s,i,O),k=ie(t,i,O),P=ee(s,i,m),T=ie(t,i,m),E=ee(s,e-h,n),X=ie(t,e-h,n),I=ee(s,i+h,n),V=ie(t,i+h,n),j=ee(s,e-h,r),_=ie(t,e-h,r),tt=ee(s,i+h,r),rt=ie(t,i+h,r);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${x} ${S} A ${h} ${h} 0 0 1 ${j} ${_} L ${tt} ${rt} A ${h} ${h} 0 0 1 ${$} ${k} A ${i} ${i} 0 ${g} 0 ${P} ${T} A ${h} ${h} 0 0 1 ${I} ${V} L ${E} ${X} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function ia(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(n=>`${n.x},${n.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let n=0;n<e-1;n++){let r=s[Math.max(n-1,0)],o=s[n],a=s[n+1],l=s[Math.min(n+2,e-1)],h=o.x+(a.x-r.x)*t/3,c=o.y+(a.y-r.y)*t/3,u=a.x-(l.x-o.x)*t/3,d=a.y-(l.y-o.y)*t/3;i+=` C${h},${c} ${u},${d} ${a.x},${a.y}`}return i}function Mu(s,t,e=.4){let i=ia(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function $l(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}var TO={std:{ratio:4/3},wide:{ratio:16/9},square:{ratio:1},tall:{ratio:3/4}},ar=class extends A{static properties={type:{type:String,default:"bar",reflect:!0},heading:{type:String,default:"",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},hideAverage:{type:Boolean,default:!1,reflect:!0,attribute:"hide-average"},color:{type:String,default:"",reflect:!0},hideGrid:{type:Boolean,default:!1,reflect:!0,attribute:"hide-grid"},hideValues:{type:Boolean,default:!1,reflect:!0,attribute:"hide-values"},radius:{type:Number,default:null,reflect:!0},smooth:{type:Number,default:.4,reflect:!0},aspect:{type:String,default:"std",reflect:!0},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#a=new Set;#o(){if(this.radius!=null)return this.radius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}set data(t){!Array.isArray(t)&&!this.#e&&(this.#e=!0,console.warn(`[chart-ui] .data must be an array of plain objects \u2014 received ${t===null?"null":typeof t}. The {labels, datasets} envelope is the Chart.js API, not the chart-ui API.
176
176
  Correct shape for <chart-ui x="label" y="value">:
177
177
  [{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#c(),this.#p()}get data(){return this.#t}#l=!1;#c(){if(this.#l)return;let t=this.#h();this.#t.length>t&&(console.warn(`[chart-ui] .data has ${this.#t.length} rows which exceeds the recommended perf budget of ${t}. Consider downsampling at the data layer (e.g., LTTB, bucket aggregation). Override the budget via CSS: chart-ui { --chart-perf-budget: 10000 }.`),this.#l=!0)}#h(){let t=getComputedStyle(this).getPropertyValue("--chart-perf-budget").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:5e3}connected(){if(this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.heading||`${this.type} chart`),this.#t.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}document.addEventListener("toggle",this.#k),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#R),this.addEventListener("focus",this.#P),this.addEventListener("blur",this.#M),this.addEventListener("pointerover",this.#D),this.addEventListener("pointermove",this.#I),this.addEventListener("pointerleave",this.#q),this.addEventListener("pointerdown",this.#V),this.addEventListener("click",this.#W),this.#S(),this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let n=Math.round(e),r=Math.round(i);n===this.#n&&(!this.hasAttribute("resize")||r===this.#r)||(this.#n=n,this.#r=r,!this.#s&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.#p()})))}),this.#i.observe(this)}render(){if(this.loading){let e=this.querySelector("skeleton-ui[data-chart-skel]");e||(e=document.createElement("skeleton-ui"),e.setAttribute("data-chart-skel",""),e.style.cssText="display:block;width:100%;height:100%;min-height:4rem;border-radius:var(--a-radius-md)"),this.innerHTML="",this.appendChild(e);return}let t=this.querySelector("skeleton-ui[data-chart-skel]");t&&t.remove(),this.#p()}#u(){let t=this.clientWidth||300,e=this.clientHeight||0,i=TO[this.aspect]||TO.std,n=this.#t.length||1,r=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(r/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(r,a),c=this.size||(h<150?"sm":h<300?"md":"lg"),u=c==="sm"?9:c==="md"?10:11,d=u,f=c==="sm"?8:c==="md"?9:10,p=this.hideGrid,m=p?0:u*3.2,O=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!O||p?2:u*2.2,left:m},y=r-g.left-g.right,v=Math.max(4,y/n*.6);return{width:r,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n,sizeClass:c}}#d=null;#p(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#d&&(this.#d=t.cloneNode(!0)),this.innerHTML="",this.#d&&this.appendChild(this.#d.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}if(this.setAttribute("data-has-data",""),this.#f(),this.heading){let o=document.createElement("div");o.setAttribute("data-chart-heading",""),o.textContent=this.heading,this.appendChild(o)}let e=document.createElement("div");this.type==="sparkline"&&e.setAttribute("data-sparkline",""),this.appendChild(e);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");e.appendChild(i);let n="",r="";switch(this.type){case"bar":({svg:n,viewBox:r}=this.#K());break;case"line":({svg:n,viewBox:r}=this.#tt());break;case"pie":({svg:n,viewBox:r}=this.#et());break;case"donut":({svg:n,viewBox:r}=this.#it());break;case"radar":({svg:n,viewBox:r}=this.#st());break;case"sparkline":({svg:n,viewBox:r}=this.#H());break;case"segments":({svg:n,viewBox:r}=this.#ut());break;case"area":({svg:n,viewBox:r}=this.#j());break;case"scatter":({svg:n,viewBox:r}=this.#nt());break;case"radial-bar":({svg:n,viewBox:r}=this.#rt());break;case"gauge":({svg:n,viewBox:r}=this.#ot());break;case"funnel":({svg:n,viewBox:r}=this.#at());break;case"treemap":({svg:n,viewBox:r}=this.#lt());break;case"sankey":({svg:n,viewBox:r}=this.#ht());break;case"composed":({svg:n,viewBox:r}=this.#ct());break;case"stacked-bar":({svg:n,viewBox:r}=this.#dt());break;case"grouped-bar":({svg:n,viewBox:r}=this.#ft());break;case"multi-line":({svg:n,viewBox:r}=this.#pt());break;default:({svg:n,viewBox:r}=this.#K());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#y()){let o=this.#mt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#f(){let t=this.#Z();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#m(t,e){return e?` data-slice="${t}" data-series-key="${te(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#O(t,e){return e?` data-slice="${t}" data-series-key="${te(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#k),document.removeEventListener("pointerdown",this.#N),this.removeEventListener("keydown",this.#R),this.removeEventListener("focus",this.#P),this.removeEventListener("blur",this.#M),this.removeEventListener("pointerover",this.#D),this.removeEventListener("pointermove",this.#I),this.removeEventListener("pointerleave",this.#q),this.removeEventListener("pointerdown",this.#V),this.removeEventListener("click",this.#W),this.#U()}#y(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#w(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#k=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#a.delete(i):this.#a.add(i),this.#p())};#v(t){return!!t&&this.#a.has(t)}#x=!1;#S(){this.#x||(this.aspect&&this.aspect!=="std"&&(console.warn(`[chart-ui] aspect="${this.aspect}" is deprecated. Parents should size the chart directly (width/height on the card or container). The attribute will be removed in a future major.`),this.#x=!0),this.heading&&(console.warn(`[chart-ui] heading="${this.heading}" is deprecated. Place the title in an enclosing card-ui <header><span slot="heading"> instead. The attribute will be removed in a future major.`),this.#x=!0))}#b(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${QO(e)}`}default:return QO(e)}}#A=-1;#$(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#E(t){let e=this.#$();if(!e.length){this.#L();return}this.#A=Math.max(0,Math.min(t,e.length-1)),this.#Q(),this.#T()}#Q(){let t=this.#$();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#A];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#L(){this.#A=-1;for(let t of this.#$())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#T(){let t=this.#$()[this.#A];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#B(t,i)}#X(){let t=this.#$()[this.#A];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#Y(t,i)}))}#P=()=>{this.#A===-1&&this.#E(0)};#M=()=>{this.#L(),this.#C&&this.#_()};#R=t=>{let e=this.#$();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#E(this.#A+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#E(Math.max(0,this.#A-1));break;case"Home":t.preventDefault(),this.#E(0);break;case"End":t.preventDefault(),this.#E(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#X();break;case"Escape":t.preventDefault(),this.#L(),this.#C&&this.#_();break}};#C=null;#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#J(e,t),this.#B(e,t))};#I=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#C&&this.#_(),this.#U();this.#J(e,t),e!==this.#C&&this.#B(e,t)};#q=t=>{t&&t.pointerType==="touch"||(this.#U(),this.#C&&this.#_())};#V=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#C&&this.#_(),this.#U();this.#J(e,t),e!==this.#C&&this.#B(e,t),document.addEventListener("pointerdown",this.#N)};#N=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#U(),this.#C&&this.#_(),document.removeEventListener("pointerdown",this.#N)))};#W=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#Y(e,t)}))};#B(t,e){this.#C=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#Y(t,e)}))}#_(){this.#C=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#Y(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#G(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#G(t,e){if(t==null)return null;let i=this.x,n=this.#Z();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#J(t,e){if(this.#w())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#g){let O=document.createElement("div");O.setAttribute("popover","manual"),O.setAttribute("role","tooltip"),O.classList.add("chart-tooltip-popup"),document.body.appendChild(O),this.#g=O}let a=[];if(o&&a.push(`<span data-tip-role="series">${te(o)}</span>`),i&&a.push(`<span data-tip-role="label">${te(i)}</span>`),n!==void 0){let O=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#b(n)}${O}</span>`)}this.#g.innerHTML=a.join("");try{this.#g.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#g.offsetWidth||0,f=this.#g.offsetHeight||0,p=c-d/2,m=u-f-l;p<h&&(p=h),p+d>window.innerWidth-h&&(p=window.innerWidth-d-h),m<h&&(m=u+l),this.#g.style.left=`${p}px`,this.#g.style.top=`${m}px`}#U(){if(this.#g){try{this.#g.hidePopover()}catch{}this.#g.remove(),this.#g=null}}#Z(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#F(t,e,i,n,r,o){let a=r,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#b(p)}</text>`}if(n){let m=(t-a.left-a.right)/n.length,g=n.reduce((x,S)=>Math.max(x,String(S).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=n.length-1;for(let x=0;x<n.length;x++){if(x%y!==0&&x!==v||x!==v&&v-x<y)continue;let S=a.left+m*x+m/2;c+=`<text data-x-label x="${S}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${te(n[x])}</text>`}}}return c}#K(){let t=this.#u(),e=this.#t,i=this.#Z()[0]||this.y,n=e.map(v=>+(v[i]??0)),r=e.map(v=>v[this.x]??""),o=as(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/e.length,p=f*.6,m=(f-p)/2,O=this.#F(l,h,o,r,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&n.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let x=n[v],S=a?x/a*u:0,$=c.left+f*v+m,k=c.top+u-S;O+=`<path data-bar${gt({label:r[v],value:x})} d="${$l($,k,p,S,this.#o())}"/>`,g&&(O+=`<text data-value x="${$+p/2}" y="${k-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#b(x)}</text>`)}if(y){let v=n.reduce((S,$)=>S+$,0)/n.length,x=c.top+u-(a?v/a*u:0);O+=`<line data-avg x1="${c.left}" y1="${x}" x2="${l-c.right}" y2="${x}"/>`,O+=`<text data-avg-label x="${l-c.right+2}" y="${x+3}" text-anchor="start" font-size="${t.valueSize}">${this.#b(v)}</text>`,O+=`<line data-hit${gt({label:"Average",value:v})} x1="${c.left}" y1="${x}" x2="${l-c.right}" y2="${x}" stroke="transparent" stroke-width="12"/>`}return{svg:O,viewBox:`0 0 ${l} ${h}`}}#tt(){let t=this.#u(),e=this.#t,i=this.#Z()[0]||this.y,n=e.map(k=>+(k[i]??0)),r=e.map(k=>k[this.x]??""),o=as(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#F(l,h,o,r,c,t),m=n.map((k,P)=>{let T=c.left+f*P,E=c.top+u-(a?k/a*u:0);return{x:T,y:E,v:k,label:r[P]}}),O=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${Mu(m,O,g)}"/>`,p+=`<path data-line d="${ia(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,x=Math.max(v,10),S=!this.hideValues&&!y,$=!this.hideAverage&&n.length>1&&!y&&!this.hideGrid;for(let k of m)p+=`<circle data-dot cx="${k.x}" cy="${k.y}" r="${v}"/>`,p+=`<circle data-hit${gt({label:k.label,value:k.v})} cx="${k.x}" cy="${k.y}" r="${x}" fill="transparent"/>`,S&&(p+=`<text data-value x="${k.x}" y="${k.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#b(k.v)}</text>`);if($){let k=n.reduce((T,E)=>T+E,0)/n.length,P=c.top+u-(a?k/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${P}" x2="${l-c.right}" y2="${P}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${P+3}" text-anchor="start" font-size="${t.valueSize}">${this.#b(k)}</text>`,p+=`<line data-hit${gt({label:"Average",value:k})} x1="${c.left}" y1="${P}" x2="${l-c.right}" y2="${P}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#et(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d="",f=-Math.PI/2;for(let p=0;p<i.length;p++){let m=i[p]/n*Math.PI*2;if(m===0)continue;let O=f+m,g=(i[p]/n*100).toFixed(1),y=` data-slice="${p%10}"${gt({label:r[p],value:i[p],pct:g})}`;Math.abs(m-Math.PI*2)<.001?d+=`<circle${y} cx="${h}" cy="${c}" r="${u}"/>`:d+=`<path${y} d="${hA(h,c,u,f,O)}"/>`,f=O}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#it(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=i.reduce((g,y)=>g+y,0)||1,r=t.map(g=>g[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d=u*.72,f="",p=-Math.PI/2;for(let g=0;g<i.length;g++){let y=i[g]/n*Math.PI*2;if(y===0)continue;let v=p+y,x=(i[g]/n*100).toFixed(1),S=` data-slice="${g%10}"${gt({label:r[g],value:i[g],pct:x})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${S} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${S} d="M ${h-u} ${c} A ${u} ${u} 0 1 1 ${h+u} ${c} A ${u} ${u} 0 1 1 ${h-u} ${c} Z M ${h-d} ${c} A ${d} ${d} 0 1 0 ${h+d} ${c} A ${d} ${d} 0 1 0 ${h-d} ${c} Z" fill-rule="evenodd"/>`):f+=`<path${S} d="${Lu(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),O=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#b(n)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${O}">Total</text>`,this.#z=t.map((g,y)=>({label:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#st(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(S=>+(S[e]??0)),n=t.map(S=>S[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#u(),{width:l,height:h,fontSize:c}=a,u=l/2,d=h/2,f=c*3.5,p=Math.max(40,Math.min(l,h)/2-f),m="",O=Math.PI*2/o;for(let S=1;S<=3;S++){let $=p*S/3,k="";for(let P=0;P<o;P++){let T=-Math.PI/2+O*P,E=u+$*Math.cos(T),X=d+$*Math.sin(T);k+=(P===0?"M":"L")+` ${E} ${X}`}k+=" Z",m+=`<path data-grid d="${k}"/>`}for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=u+p*Math.cos($),P=d+p*Math.sin($);m+=`<line data-grid x1="${u}" y1="${d}" x2="${k}" y2="${P}"/>`}let g="",y=[];for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=i[S]/r*p,P=u+k*Math.cos($),T=d+k*Math.sin($);g+=(S===0?"M":"L")+` ${P} ${T}`,y.push({px:P,py:T})}g+=" Z",m+=`<path data-radar-fill d="${g}"/>`,m+=`<path data-radar-line d="${g}"/>`;let v=Math.max(c,10);for(let S=0;S<o;S++){let{px:$,py:k}=y[S];m+=`<circle data-hit${gt({label:n[S],value:i[S]})} cx="${$}" cy="${k}" r="${v}" fill="transparent"/>`}let x=c*1.3;for(let S=0;S<o;S++){let $=-Math.PI/2+O*S,k=u+(p+x)*Math.cos($),P=d+(p+x)*Math.sin($),T=Math.abs(Math.cos($))<.1?"middle":Math.cos($)>0?"start":"end";m+=`<text data-x-label x="${k}" y="${P}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${te(n[S])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#H(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(y=>+(y[e]??0)),n=Math.max(...i)||1,r=Math.min(...i),o=n-r||1,a=this.clientWidth||120,l=this.clientHeight||32,h=Math.max(40,a),c=Math.max(16,l),u=h/Math.max(i.length-1,1),d=Math.max(2,Math.min(6,c*.1)),f=t.map(y=>y[this.x]??""),p=i.map((y,v)=>({x:u*v,y:c-(y-r)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),O="";O+=`<path data-area d="${Mu(p,c,m)}"/>`,O+=`<path data-line d="${ia(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)O+=`<circle data-hit${gt({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:O,viewBox:`0 0 ${h} ${c}`}}#j(){return this.#tt()}#nt(){let t=this.#u(),e=this.#t,i=this.#Z()[0]||this.y,n=e.map(g=>+(g[i]??0)),r=e.map(g=>g[this.x]??""),o=as(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#F(l,h,o,r,c,t),m=t.sizeClass==="sm"?2.5:4,O=Math.max(m*2,10);for(let g=0;g<n.length;g++){let y=c.left+f*g,v=c.top+u-(a?n[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${gt({label:r[g],value:n[g]})} cx="${y}" cy="${v}" r="${O}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#rt(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=Math.max(...i)||1,o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.45),d=u*.3,f=i.length||1,p=(u-d)/f,m=Math.min(2,p*.15),O="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,x=(y+v)/2,S=v-y,$=2*Math.PI*x,k=Math.max(0,Math.min(1,i[g]/r))*$;if(O+=`<circle data-radial-track cx="${h}" cy="${c}" r="${x}" fill="none" stroke-width="${S}"/>`,k<=0)continue;let P=(i[g]/r*100).toFixed(1),T=gt({label:n[g],value:i[g],pct:P}),E=Math.abs(k-$)<.5,X=E?"butt":"round",I=E?`${$} 0`:`${k} ${$-k}`;O+=`<circle data-slice="${g%10}"${T} data-radial-bar cx="${h}" cy="${c}" r="${x}" fill="none" stroke-width="${S}" stroke-linecap="${X}" stroke-dasharray="${I}" transform="rotate(-90 ${h} ${c})"/>`}return this.#z=t.map((g,y)=>({label:n[y],key:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:O,viewBox:`0 0 ${a} ${l}`}}#ot(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(x=>+(x[e]??0)),n=i.reduce((x,S)=>x+S,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#u(),{width:h,height:c}=l,u=h/2,d=c*.68,f=Math.max(40,Math.min(h*.45,c*.6)),p=f*.72,m=(f-p)/2,O="";if(O+=`<path data-radial-track d="${Lu(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let x=Math.PI+Math.PI*a,S=gt({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});O+=`<path data-slice="0"${S} data-gauge-fill d="${Lu(u,d,f,p,Math.PI,x,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return O+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#b(r)}</text>`,o!==r&&(O+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#b(o)}</text>`),{svg:O,viewBox:`0 0 ${h} ${c}`}}#at(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#u(),{width:l,height:h}=a,c=a.fontSize,u=Math.max(l*.18,80),d=c*.8,f=l-u*2,m=(h-d*2)/r,O=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<r;v++){let x=i[v],S=v<r-1?i[v+1]:i[v],$=x/o*(f/2),k=S/o*(f/2),P=d+m*v+O/2,T=d+m*(v+1)-O/2,E=(x/o*100).toFixed(1),X=gt({label:n[v],value:x,pct:E}),I=`M ${g-$} ${P} L ${g+$} ${P} L ${g+k} ${T} L ${g-k} ${T} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${X} d="${I}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${P+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${te(n[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${P+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#b(x)}</text>`,v>0){let V=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${P+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${V}%</text>`}}return this.#z=t.map((v,x)=>({label:n[x],value:i[x],pct:(i[x]/o*100).toFixed(1),slot:x%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#lt(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(E=>+(E[e]??0)),n=t.map(E=>E[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#u(),{width:a,height:l,fontSize:h}=o,c=i.reduce((E,X)=>E+X,0)||1,u=Array.from({length:r},(E,X)=>X).sort((E,X)=>i[X]-i[E]),d=[],f=a*l,p=u.map(E=>i[E]/c*f),m=0,O=0,g=a,y=l,v=[],x=0,S=(E,X)=>{if(E.length===0)return 1/0;let I=E.reduce((rt,mt)=>rt+mt,0),V=Math.max(...E),j=Math.min(...E),_=X*X,tt=I*I;return Math.max(_*V/tt,tt/(_*j))},$=(E,X,I,V,j,_)=>{let tt=E.reduce((At,xt)=>At+xt,0),rt=j>=_,mt=rt?tt/j:_,ut=rt?j:tt/_,vt=0;for(let At=0;At<E.length;At++){let xt=E[At]/tt,zt=u[X+At];if(rt){let Vt=xt*j;d.push({i:zt,x:I+vt,y:V,w:Vt,h:mt}),vt+=Vt}else{let Vt=xt*_;d.push({i:zt,x:I,y:V+vt,w:ut,h:Vt}),vt+=Vt}}return rt?{x:I,y:V+mt,w:j,h:_-mt}:{x:I+ut,y:V,w:j-ut,h:_}},k=p.slice();for(;k.length>0;){v=[k[0]],x=p.length-k.length;let E=Math.min(g,y),X=1;for(;X<k.length;){let V=v.concat(k[X]);if(S(V,E)>S(v,E))break;v=V,X++}let I=$(v,x,m,O,g,y);m=I.x,O=I.y,g=I.w,y=I.h,k=k.slice(v.length)}let P="",T=2;for(let E of d){let X=(i[E.i]/c*100).toFixed(1),I=gt({label:n[E.i],value:i[E.i],pct:X});P+=`<rect data-slice="${E.i%10}" data-treemap-tile${I} x="${E.x+T}" y="${E.y+T}" width="${Math.max(0,E.w-T*2)}" height="${Math.max(0,E.h-T*2)}" rx="${this.#o()}"/>`;let V=E.x+8,j=E.w>h*4,_=j&&E.h>h*2.5,tt=j&&!_&&E.h>h*1.2;if(_)P+=`<text data-treemap-label x="${V}" y="${E.y+h+4}" font-size="${h}" dominant-baseline="hanging">${te(n[E.i])}</text>`,P+=`<text data-treemap-value x="${V}" y="${E.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#b(i[E.i])}</text>`;else if(tt){let rt=E.y+E.h/2;P+=`<text data-treemap-label x="${V}" y="${rt}" font-size="${h}" dominant-baseline="central">${te(n[E.i])}</text>`}}return this.#z=t.map((E,X)=>({label:n[X],value:i[X],pct:(i[X]/c*100).toFixed(1),slot:X%10})),{svg:P,viewBox:`0 0 ${a} ${l}`}}#ht(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let x of t){let S=x.source??x.from??"",$=x.target??x.to??"",k=+(x.value??x.v??0);e.has(S)||e.set(S,{name:S,flow:0}),i.has($)||i.set($,{name:$,flow:0}),e.get(S).flow+=k,i.get($).flow+=k}let n=this.#u(),{width:r,height:o,fontSize:a}=n,l=Math.max(8,r*.03),h=l+a*5,c=[...e.values()].reduce((x,S)=>x+S.flow,0)||1,u=[...i.values()].reduce((x,S)=>x+S.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),O=o-d*(p.length-1),g=0;for(let x of f){let S=x.flow/c*m;x.y0=g,x.y1=g+S,x.cursor=g,g+=S+d}g=0;for(let x of p){let S=x.flow/u*O;x.y0=g,x.y1=g+S,x.cursor=g,g+=S+d}let y="",v=Math.min(this.#o(),l/2);f.forEach((x,S)=>{y+=`<rect data-sankey-node data-slice="${S%10}" x="${h-l}" y="${x.y0}" width="${l}" height="${x.y1-x.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(x.y0+x.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${te(x.name)}</text>`}),p.forEach((x,S)=>{y+=`<rect data-sankey-node data-slice="${(f.length+S)%10}" x="${r-h}" y="${x.y0}" width="${l}" height="${x.y1-x.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${r-h+l+6}" y="${(x.y0+x.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${te(x.name)}</text>`});for(let x of t){let S=e.get(x.source??x.from??""),$=i.get(x.target??x.to??"");if(!S||!$)continue;let k=+(x.value??x.v??0);if(k<=0)continue;let P=k/c*m,T=k/u*O,E=S.cursor,X=E+P,I=$.cursor,V=I+T;S.cursor+=P,$.cursor+=T;let j=h,_=r-h,tt=(j+_)/2,rt=gt({label:`${S.name} \u2192 ${$.name}`,value:k}),mt=`M ${j} ${E} C ${tt} ${E}, ${tt} ${I}, ${_} ${I} L ${_} ${V} C ${tt} ${V}, ${tt} ${X}, ${j} ${X} Z`;y+=`<path data-sankey-link${rt} d="${mt}"/>`}return{svg:y,viewBox:`0 0 ${r} ${o}`}}#ct(){let t=this.#u(),e=this.#t,i=this.#Z(),n=i[0]||"bar",r=i[1]||"line",o=e.map($=>$[this.x]??""),a=e.map($=>+($[n]??0)),l=e.map($=>+($[r]??0)),h=[...a,...l],c=as(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,O=d-p.left-p.right,g=O/e.length,y=g*.6,v=(g-y)/2,x=O/Math.max(e.length-1,1),S=this.#F(d,f,c,o,p,t);if(!this.#v(n))for(let $=0;$<e.length;$++){let k=a[$],P=u?k/u*m:0,T=p.left+g*$+v,E=p.top+m-P;S+=`<path${this.#m(0,n)}${gt({label:o[$],value:k,series:n})} d="${$l(T,E,y,P,this.#o())}"/>`}if(!this.#v(r)){let $=l.map((P,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?P/u*m:0),v:P,label:o[T]})),k=Math.max(0,Math.min(1,this.smooth));S+=`<path data-line${this.#O(1,r)} d="${ia($,k)}"/>`;for(let P of $)S+=`<circle data-dot${this.#m(1,r)} cx="${P.x}" cy="${P.y}" r="3"/>`,S+=`<circle data-hit${gt({label:P.label,value:P.v,series:r})} cx="${P.x}" cy="${P.y}" r="10" fill="transparent"/>`}return this.#z=[{label:n,key:n,slot:0},{label:r,key:r,slot:1}],{svg:S,viewBox:`0 0 ${d} ${f}`}}#ut(){let t=this.#t,e=this.#Z()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#o(),l/2),c=Math.max(0,parseFloat(o.getPropertyValue("--chart-segments-gap"))||2),u=[],d=0;for(let p=0;p<i.length;p++){let m=p===i.length-1?a:Math.round((d*n+i[p]*a)/n),O=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/n*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/n*a;u.push({x:g,w:Math.max(0,O-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:O}=u[p];if(O<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,O-(y?0:c)),x=(i[p]/n*100).toFixed(1),S=gt({label:r[p],value:i[p],pct:x}),$=`<title>${te(r[p])}: ${i[p]} (${x}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${S} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${$}</rect>`;else{let k=h,P=m+v,T;g?T=`M ${m+k} 0 H ${P} V ${l} H ${m+k} A ${k} ${k} 0 0 1 ${m} ${l-k} V ${k} A ${k} ${k} 0 0 1 ${m+k} 0 Z`:T=`M ${m} 0 H ${P-k} A ${k} ${k} 0 0 1 ${P} ${k} V ${l-k} A ${k} ${k} 0 0 1 ${P-k} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${S} d="${T}">${$}</path>`}}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#dt(){let t=this.#t,e=this.#Z(),i=t.map(g=>g[this.x]??""),n=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),r=as(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=f*.6,m=(f-p)/2,O=this.#F(l,h,r,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let x=0;x<v;x++){if(this.#v(e[x]))continue;let S=+(t[g][e[x]]??0),$=o?S/o*u:0;if($<=0){y-=$;continue}y-=$;let k=c.left+f*g+m,P=y,T=$,E=x===v-1,X=this.#o(),I=`${this.#m(x%10,e[x])}${gt({label:i[g],value:S,series:e[x]})}`;E?O+=`<path${I} d="${$l(k,P,p,T,X)}"/>`:O+=`<rect${I} x="${k}" y="${P}" width="${p}" height="${T}"/>`}}return this.#z=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:O,viewBox:`0 0 ${l} ${h}`}}#ft(){let t=this.#t,e=this.#Z(),i=t.map(v=>v[this.x]??""),n=t.flatMap(v=>e.map(x=>+(v[x]??0))),r=as(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=3,m=f*.7,O=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#F(l,h,r,i,c,a);for(let v=0;v<t.length;v++)for(let x=0;x<e.length;x++){if(this.#v(e[x]))continue;let S=+(t[v][e[x]]??0),$=o?S/o*u:0,k=c.left+f*v+g+(O+p)*x,P=c.top+u-$;y+=`<path${this.#m(x%10,e[x])}${gt({label:i[v],value:S,series:e[x]})} d="${$l(k,P,O,$,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${k+O/2}" y="${P-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#b(S)}</text>`)}return this.#z=e.map((v,x)=>({label:v,key:v,slot:x%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#pt(){let t=this.#t,e=this.#Z(),i=t.map(m=>m[this.x]??""),n=t.flatMap(m=>e.map(O=>+(m[O]??0))),r=as(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(t.length-1,1),p=this.#F(l,h,r,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(x=>+(x[e[m]]??0)).map((x,S)=>{let $=c.left+f*S,k=c.top+u-(o?x/o*u:0);return{x:$,y:k,v:x,label:i[S]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#m(m%10,e[m])} d="${Mu(g,y,v)}"/>`,p+=`<path data-line${this.#O(m%10,e[m])} d="${ia(g,v)}"/>`;for(let x of g)p+=`<circle data-dot${this.#m(m%10,e[m])} cx="${x.x}" cy="${x.y}" r="3"/>`,p+=`<circle data-hit${gt({label:x.label,value:x.v,series:e[m]})} cx="${x.x}" cy="${x.y}" r="10" fill="transparent"/>`}return this.#z=e.map((m,O)=>({label:m,key:m,slot:O%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#z=null;get legendData(){return this.#z?this.#z.map(t=>({...t})):null}#mt(){if(!this.#z||!this.#z.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#z){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};w("chart-ui",ar);var lr=class s extends A{static properties={for:{type:String,default:"",reflect:!0},items:{type:String,default:"",reflect:!1},shape:{type:String,default:"dot",reflect:!0},position:{type:String,default:"bottom",reflect:!0},static:{type:Boolean,default:!1,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#a()}disconnected(){this.#n()}render(){this.#s(),this.#a()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#a(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#a(){let t=this.#r();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",n=e.label??i,r=e.slot!=null?e.slot:0,o=!this.#i.has(i),a=document.createElement("badge-ui");a.setAttribute("data-row",""),a.setAttribute("role",this.static?"listitem":"button"),a.setAttribute("text",n),i&&a.setAttribute("data-key",i),o&&a.setAttribute("data-active",""),this.static||(a.setAttribute("tabindex","0"),a.setAttribute("aria-pressed",o?"true":"false"));let l=this.shape||"dot",h=document.createElement("swatch-ui");h.setAttribute("shape",l),h.setAttribute("size","sm");let c=i?`var(--color-${i}, var(--a-data-${r}))`:`var(--a-data-${r})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#o(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#o(u,i))})),this.appendChild(a)}}#o(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};w("chart-legend-ui",lr);var cA=120,hr=class extends A{static properties={placement:{type:String,default:"bottom",reflect:!0},gap:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#u),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#u))))}render(){this.open?this.#r():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=dt(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#a(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#u=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},cA)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#u),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#u))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};w("popover-ui",hr);var cr=class extends A{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.addEventListener("toggle",this.#t)}disconnected(){this.removeEventListener("toggle",this.#t)}#t=t=>{if(this.multiple)return;let e=t.target;if(!e.open)return;let i=this.querySelectorAll("accordion-item-ui");for(let n of i)n!==e&&n.open&&(n.open=!1)}},ur=class extends A{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){if(!this.querySelector('[slot="header"]')){let t=document.createElement("div");t.setAttribute("slot","header");let e=document.createElement("span");e.setAttribute("slot","header-text"),t.appendChild(e);let i=document.createElement("icon-ui");i.setAttribute("name","caret-down"),i.setAttribute("slot","caret"),t.appendChild(i),this.prepend(t)}if(!this.querySelector('[slot="body"]')){let t=document.createElement("div");t.setAttribute("slot","body");let e=[...this.childNodes].filter(i=>i.nodeType===1?!i.hasAttribute("slot"):i.nodeType===3&&i.textContent.trim());for(let i of e)t.appendChild(i);this.appendChild(t)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e))}disconnected(){this.removeEventListener("click",this.#e),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"]');t&&(t.textContent=this.text)}#e=t=>{let e=this.querySelector('[slot="header"]');!e||!e.contains(t.target)||t.target.closest('[slot="action"], [slot="actions"], [data-no-toggle]')||(this.open=!this.open,this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{open:this.open}})))}};w("accordion-ui",cr),w("accordion-item-ui",ur);var dr=class extends A{static properties={label:{type:String,default:"",reflect:!0},vertical:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","separator")}render(){if(this.vertical?this.setAttribute("aria-orientation","vertical"):this.removeAttribute("aria-orientation"),this.label){let t=this.querySelector('[slot="label"]');t||(t=document.createElement("span"),t.setAttribute("slot","label"),this.appendChild(t)),t.textContent=this.label}else{let t=this.querySelector('[slot="label"]');t&&t.remove()}}};w("divider-ui",dr);var fr=class extends A{static properties={page:{type:Number,default:1,reflect:!0},total:{type:Number,default:1,reflect:!0},siblings:{type:Number,default:1,reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=!1;connected(){this.#t||(this.#t=document.createElement("nav"),this.#t.setAttribute("slot","nav"),this.#t.setAttribute("aria-label","Pagination"),this.appendChild(this.#t)),this.#e||(this.#e=!0,this.#t.addEventListener("click",this.#r))}disconnected(){this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=!1}render(){if(!this.#t)return;let t=Math.max(1,Math.min(this.page,this.total)),e=Math.max(1,this.total),i=Math.max(0,this.siblings),n=this.#i(t,e,i);this.reconcile(this.#t,n,r=>r.key,(r,o,a)=>a?(this.#n(a,r,t),a):this.#s(r,t))}#i(t,e,i){let n=[];n.push({key:"prev",type:"prev",value:t-1}),n.push({key:"page-1",type:"page",value:1});let r=Math.max(2,t-i),o=Math.min(e-1,t+i);r>2&&n.push({key:"ellipsis-start",type:"ellipsis"});for(let a=r;a<=o;a++)n.push({key:`page-${a}`,type:"page",value:a});return o<e-1&&n.push({key:"ellipsis-end",type:"ellipsis"}),e>1&&n.push({key:`page-${e}`,type:"page",value:e}),n.push({key:"next",type:"next",value:t+1}),n}#s(t,e){if(t.type==="ellipsis"){let n=document.createElement("span");return n.setAttribute("data-ellipsis",""),n.textContent="\u2026",n}let i=document.createElement("button");return i.setAttribute("type","button"),t.type==="prev"?(i.setAttribute("data-prev",""),i.setAttribute("aria-label","Previous page"),i.textContent="\u2039"):t.type==="next"?(i.setAttribute("data-next",""),i.setAttribute("aria-label","Next page"),i.textContent="\u203A"):(i.setAttribute("data-page",""),i.dataset.value=String(t.value),i.textContent=String(t.value),i.setAttribute("aria-label",`Page ${t.value}`)),this.#n(i,t,e),i}#n(t,e,i){e.type!=="ellipsis"&&(e.type==="prev"?i<=1?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0")):e.type==="next"?i>=this.total?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0")):(t.dataset.value=String(e.value),t.textContent=String(e.value),t.setAttribute("aria-label",`Page ${e.value}`),e.value===i?(t.setAttribute("data-active",""),t.setAttribute("aria-current","page")):(t.removeAttribute("data-active"),t.removeAttribute("aria-current"))))}#r=t=>{let e=t.target.closest("[data-prev], [data-next], [data-page]");if(!e||e.hasAttribute("disabled")||!this.#t.contains(e))return;let i;e.hasAttribute("data-prev")?i=this.page-1:e.hasAttribute("data-next")?i=this.page+1:e.hasAttribute("data-page")&&(i=Number(e.dataset.value)),!(i==null||i<1||i>this.total||i===this.page)&&(this.page=i,this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:this.page}})))}};w("pagination-ui",fr);var JM=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),t2={js:"javascript",md:"markdown",yml:"yaml"};function vg(s){if(!s)return"";let t=String(s).toLowerCase();return t2[t]??t}var Gr=class s extends A{static formAssociated=!0;static properties={language:{type:String,default:"",reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},text:{type:String,default:"",reflect:!0},lineNumbers:{type:Boolean,default:!1,reflect:!0,attribute:"line-numbers"},editable:{type:Boolean,default:!1,reflect:!0},bare:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=0;#n=!1;#r=null;#a="";#o=null;#l=()=>this.#y();connected(){this.#s+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#c(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#l);let t=vg(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(JM.has(t)||this.editable)&&this.#u()}disconnected(){this.#s+=1,this.#e!=null&&(clearTimeout(this.#e),this.#e=null),this.#t&&(this.#t.removeEventListener("click",this.#l),this.#t=null),this.#i&&(this.#i.destroy(),this.#i=null)}#c(){let t=this.querySelector(":scope > template"),e=this.text?this.text.trim():t?s.#h(t.innerHTML):(this.textContent||"").trim();if(this.textContent="",!this.bare){let l=document.createElement("header"),h=document.createElement("span");h.setAttribute("slot","label"),h.textContent=this.language||"code",l.appendChild(h);let c=document.createElement("div");c.setAttribute("role","button"),c.setAttribute("tabindex","0"),c.setAttribute("slot","copy"),c.textContent="Copy",l.appendChild(c),this.appendChild(l)}let i=document.createElement("pre"),n=document.createElement("code"),r=vg(this.language),o=this.getAttribute("data-line-states");if(o!=null||r==="diff"){n.setAttribute("data-line-state-mode",""),this.lineNumbers&&n.setAttribute("data-line-numbers","");let l=o?.split(",").map(c=>c.trim())??null;e.split(`
178
178
  `).forEach((c,u)=>{let d="unchanged";if(l&&l[u])d=l[u];else if(r==="diff"){let m=c.charAt(0);m==="+"?d="added":m==="-"&&(d="removed")}let f=document.createElement("span");if(f.setAttribute("data-line-state",d),this.lineNumbers){let m=document.createElement("span");m.setAttribute("data-line-num",""),m.textContent=String(u+1),f.appendChild(m)}let p=document.createElement("span");p.setAttribute("data-line-body",""),p.textContent=c,f.appendChild(p),n.appendChild(f)})}else n.textContent=e;i.appendChild(n),this.appendChild(i)}static#h(t){let e=t.replace(/^\n+|\n+$/g,"");if(!e)return"";let i=e.split(`
@@ -186,13 +186,14 @@ Correct shape for <chart-ui x="label" y="value">:
186
186
  <span slot="icon">${this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:""}</span>
187
187
  <span slot="text">${this.text}</span>
188
188
  ${this.badge?`<span slot="badge">${this.badge}</span>`:""}
189
- `),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){let t=this.querySelector('[slot="text"]');t&&(t.textContent=this.text),this.setAttribute("tabindex",this.disabled?"-1":"0"),this.selected?this.setAttribute("aria-current","page"):this.removeAttribute("aria-current")}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};w("nav-item-ui",ao);var lo=class extends Z{static properties={...Z.properties,length:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=[];#e=t=>{let e=this.#t.indexOf(t.currentTarget);e<0||this.#o(t,e)};#i=t=>{let e=this.#t.indexOf(t.currentTarget);e<0||this.#l(t,e)};#s=t=>{this.#c(t)};connected(){super.connected(),this.setAttribute("role","group"),this.setAttribute("aria-label","One-time password"),this.#n(),this.#r()}#n(){let t=this.length||6;this.innerHTML="",this.#t=[];for(let e=0;e<t;e++){let i=document.createElement("input");i.type="text",i.maxLength=1,i.inputMode="numeric",i.autocomplete="one-time-code",i.setAttribute("slot","digit"),i.setAttribute("aria-label",`Digit ${e+1}`),this.appendChild(i),this.#t.push(i)}}#r(){for(let t of this.#t)t.addEventListener("input",this.#e),t.addEventListener("keydown",this.#i),t.addEventListener("paste",this.#s)}#a(){for(let t of this.#t)t.removeEventListener("input",this.#e),t.removeEventListener("keydown",this.#i),t.removeEventListener("paste",this.#s)}render(){if(!this.#t.length)return;let t=this.disabled;for(let e of this.#t)e.disabled=t}#o(t,e){let i=this.#t[e];i.value=i.value.replace(/\D/g,"").slice(0,1),this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),i.value&&e<this.#t.length-1&&this.#t[e+1].focus(),this.#u()}#l(t,e){t.key==="Backspace"&&!this.#t[e].value&&e>0&&(this.#t[e-1].focus(),this.#t[e-1].value="",this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#c(t){t.preventDefault();let e=(t.clipboardData?.getData("text/plain")||"").replace(/\D/g,"");for(let n=0;n<this.#t.length;n++)this.#t[n].value=e[n]||"";this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));let i=this.#t.findIndex(n=>!n.value);i>=0?this.#t[i].focus():this.#t[this.#t.length-1].focus(),this.#u()}#h(){let t=this.#t.map(e=>e.value).join("");this.value=t,this.syncValue(t)}#u(){let t=this.#t.map(e=>e.value).join("");t.length===this.#t.length&&this.dispatchEvent(new CustomEvent("complete",{bubbles:!0,detail:{value:t}}))}focus(){let t=this.#t.findIndex(e=>!e.value);this.#t[t>=0?t:0]?.focus()}clear(){for(let t of this.#t)t.value="";this.value="",this.syncValue(""),this.#t[0]?.focus()}disconnected(){super.disconnected(),this.#a(),this.#t=[]}};w("otp-input-ui",lo);var ho=class extends A{static properties={src:{type:String,default:"",reflect:!0},alt:{type:String,default:"",reflect:!0},width:{type:String,default:"",reflect:!0},height:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},fit:{type:String,default:"cover",reflect:!0},radius:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},fallback:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#e=this.querySelector(':scope > [slot="skeleton"]'),this.#e||(this.#e=document.createElement("skeleton-ui"),this.#e.setAttribute("slot","skeleton"),this.#e.setAttribute("width","100%"),this.#e.setAttribute("height","100%"),this.appendChild(this.#e)),this.#t=this.querySelector(':scope > [slot="image"]'),this.#t||(this.#t=document.createElement("img"),this.#t.setAttribute("slot","image"),this.#t.loading="lazy",this.appendChild(this.#t)),this.#t.addEventListener("load",this.#s),this.#t.addEventListener("error",this.#n),this.#i()}render(){this.#t&&(this.#t.getAttribute("src")!==this.src&&(this.removeAttribute("data-loaded"),this.removeAttribute("data-error"),this.#t.src=this.src||""),this.#t.alt=this.alt||"",this.#i())}#i(){this.width&&(this.style.width=this.width),this.height&&(this.style.height=this.height)}#s=()=>{this.setAttribute("data-loaded",""),this.removeAttribute("data-error")};#n=()=>{this.fallback&&this.#t.src!==this.fallback?this.#t.src=this.fallback:this.setAttribute("data-error","")};disconnected(){this.#t&&(this.#t.removeEventListener("load",this.#s),this.#t.removeEventListener("error",this.#n)),this.#t=null,this.#e=null}};w("image-ui",ho);var co=class extends Z{static properties={...Z.properties,placeholder:{type:String,default:"Search...",reflect:!0},debounce:{type:Number,default:300,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){super.connected(),this.setAttribute("role","search"),this.querySelector("input-ui")||(this.innerHTML=`<input-ui
189
+ `),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){let t=this.querySelector('[slot="text"]');t&&(t.textContent=this.text),this.setAttribute("tabindex",this.disabled?"-1":"0"),this.selected?this.setAttribute("aria-current","page"):this.removeAttribute("aria-current")}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};w("nav-item-ui",ao);var lo=class extends Z{static properties={...Z.properties,length:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=[];#e=t=>{let e=this.#t.indexOf(t.currentTarget);e<0||this.#o(t,e)};#i=t=>{let e=this.#t.indexOf(t.currentTarget);e<0||this.#l(t,e)};#s=t=>{this.#c(t)};connected(){super.connected(),this.setAttribute("role","group"),this.setAttribute("aria-label","One-time password"),this.#n(),this.#r()}#n(){let t=this.length||6;this.innerHTML="",this.#t=[];for(let e=0;e<t;e++){let i=document.createElement("input");i.type="text",i.maxLength=1,i.inputMode="numeric",i.autocomplete="one-time-code",i.setAttribute("slot","digit"),i.setAttribute("aria-label",`Digit ${e+1}`),this.appendChild(i),this.#t.push(i)}}#r(){for(let t of this.#t)t.addEventListener("input",this.#e),t.addEventListener("keydown",this.#i),t.addEventListener("paste",this.#s)}#a(){for(let t of this.#t)t.removeEventListener("input",this.#e),t.removeEventListener("keydown",this.#i),t.removeEventListener("paste",this.#s)}render(){if(!this.#t.length)return;let t=this.disabled;for(let e of this.#t)e.disabled=t}#o(t,e){let i=this.#t[e];i.value=i.value.replace(/\D/g,"").slice(0,1),this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),i.value&&e<this.#t.length-1&&this.#t[e+1].focus(),this.#u()}#l(t,e){t.key==="Backspace"&&!this.#t[e].value&&e>0&&(this.#t[e-1].focus(),this.#t[e-1].value="",this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#c(t){t.preventDefault();let e=(t.clipboardData?.getData("text/plain")||"").replace(/\D/g,"");for(let n=0;n<this.#t.length;n++)this.#t[n].value=e[n]||"";this.#h(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));let i=this.#t.findIndex(n=>!n.value);i>=0?this.#t[i].focus():this.#t[this.#t.length-1].focus(),this.#u()}#h(){let t=this.#t.map(e=>e.value).join("");this.value=t,this.syncValue(t)}#u(){let t=this.#t.map(e=>e.value).join("");t.length===this.#t.length&&this.dispatchEvent(new CustomEvent("complete",{bubbles:!0,detail:{value:t}}))}focus(){let t=this.#t.findIndex(e=>!e.value);this.#t[t>=0?t:0]?.focus()}clear(){for(let t of this.#t)t.value="";this.value="",this.syncValue(""),this.#t[0]?.focus()}disconnected(){super.disconnected(),this.#a(),this.#t=[]}};w("otp-input-ui",lo);var ho=class extends A{static properties={src:{type:String,default:"",reflect:!0},alt:{type:String,default:"",reflect:!0},width:{type:String,default:"",reflect:!0},height:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},fit:{type:String,default:"cover",reflect:!0},radius:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},fallback:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#e=this.querySelector(':scope > [slot="skeleton"]'),this.#e||(this.#e=document.createElement("skeleton-ui"),this.#e.setAttribute("slot","skeleton"),this.#e.setAttribute("width","100%"),this.#e.setAttribute("height","100%"),this.appendChild(this.#e)),this.#t=this.querySelector(':scope > [slot="image"]'),this.#t||(this.#t=document.createElement("img"),this.#t.setAttribute("slot","image"),this.#t.loading="lazy",this.appendChild(this.#t)),this.#t.addEventListener("load",this.#s),this.#t.addEventListener("error",this.#n),this.#i()}render(){this.#t&&(this.#t.getAttribute("src")!==this.src&&(this.removeAttribute("data-loaded"),this.removeAttribute("data-error"),this.#t.src=this.src||""),this.#t.alt=this.alt||"",this.#i())}#i(){this.width&&(this.style.width=this.width),this.height&&(this.style.height=this.height)}#s=()=>{this.setAttribute("data-loaded",""),this.removeAttribute("data-error")};#n=()=>{this.fallback&&this.#t.src!==this.fallback?this.#t.src=this.fallback:this.setAttribute("data-error","")};disconnected(){this.#t&&(this.#t.removeEventListener("load",this.#s),this.#t.removeEventListener("error",this.#n)),this.#t=null,this.#e=null}};w("image-ui",ho);var co=class extends Z{static properties={...Z.properties,placeholder:{type:String,default:"Search...",reflect:!0},debounce:{type:Number,default:300,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(super.connected(),this.setAttribute("role","search"),!this.querySelector("input-ui")){let t=this.getAttribute("size");this.innerHTML=`<input-ui
190
190
  type="search"
191
191
  prefix="magnifying-glass"
192
192
  suffix="x-circle"
193
193
  placeholder="${this.placeholder}"
194
194
  ${this.disabled?"disabled":""}
195
- ></input-ui>`),this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#n),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#r)))}render(){this.#t&&(this.#t.setAttribute("placeholder",this.placeholder),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"),this.setAttribute("value",this.value||""))}#s=()=>{this.value=this.#t.value,this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#n=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#r()};#r=()=>{clearTimeout(this.#i),this.value="",this.#t&&(this.#t.value=""),this.syncValue(""),this.setAttribute("value",""),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:""}})),this.#t?.focus()};focus(){this.#t?.focus()}clear(){this.#r()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#n)),this.#e&&this.#e.removeEventListener("click",this.#r),this.#t=null,this.#e=null}};w("search-ui",co);function Vs(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function o2(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var a2=0,uo=class extends Z{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle","check"];static properties={...Z.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},creatable:{type:Boolean,default:!1,reflect:!0},clearable:{type:Boolean,default:!1,reflect:!0},filterMode:{type:String,default:"substring",reflect:!0,attribute:"filter-mode"},loading:{type:Boolean,default:!1,reflect:!0},maxOptions:{type:Number,default:100,reflect:!0,attribute:"max-options"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=`combobox-${++a2}`;#O=()=>this.#D();#g=t=>this.#I(t);#y=()=>this.#q();#w=t=>this.#V(t);#k=t=>this.#_(t);#v=t=>this.#Y(t);#x=t=>this.#F(t);#S=t=>this.#tt(t);#b=t=>this.#et(t);connected(){super.connected(),this.#t.length===0&&this.#L(),this.#e=this.value||"",this.#A(),this.#P(),this.#j()}disconnected(){super.disconnected(),this.#Q(),this.#p?.(),this.#p=null,this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null),document.removeEventListener("pointerdown",this.#b),this.#o?.hidePopover?.(),this.#o=null,this.#r=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null}render(){this.#r&&(this.#r.setAttribute("aria-expanded",String(this.open)),this.disabled||this.readonly?this.#r.contentEditable="false":this.#r.contentEditable="plaintext-only",this.#a&&(this.#a.textContent=this.label||"",this.#a.style.display=this.label?"":"none"),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#u&&(this.#u.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#st():this.#H())}#A(){if(this.querySelector(":scope > [data-field]")){this.#$(),this.#E();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,n=Array.from(this.querySelectorAll(':scope > [slot="prefix"]')),r=Array.from(this.querySelectorAll(':scope > [slot="suffix"]')),o=Array.from(this.querySelectorAll(':scope > [slot="empty"]')),a=Array.from(this.querySelectorAll(':scope > [slot="loading"]')),l=Array.from(this.querySelectorAll(':scope > [slot="footer"]'));this.innerHTML=`
195
+ ${t?`size="${t}"`:""}
196
+ ></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#n),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#r)))}render(){this.#t&&(this.#t.setAttribute("placeholder",this.placeholder),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"),this.setAttribute("value",this.value||""))}#s=()=>{this.value=this.#t.value,this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#n=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#r()};#r=()=>{clearTimeout(this.#i),this.value="",this.#t&&(this.#t.value=""),this.syncValue(""),this.setAttribute("value",""),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:""}})),this.#t?.focus()};focus(){this.#t?.focus()}clear(){this.#r()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#n)),this.#e&&this.#e.removeEventListener("click",this.#r),this.#t=null,this.#e=null}};w("search-ui",co);function Vs(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function o2(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var a2=0,uo=class extends Z{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle","check"];static properties={...Z.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},creatable:{type:Boolean,default:!1,reflect:!0},clearable:{type:Boolean,default:!1,reflect:!0},filterMode:{type:String,default:"substring",reflect:!0,attribute:"filter-mode"},loading:{type:Boolean,default:!1,reflect:!0},maxOptions:{type:Number,default:100,reflect:!0,attribute:"max-options"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=`combobox-${++a2}`;#O=()=>this.#D();#g=t=>this.#I(t);#y=()=>this.#q();#w=t=>this.#V(t);#k=t=>this.#_(t);#v=t=>this.#Y(t);#x=t=>this.#F(t);#S=t=>this.#tt(t);#b=t=>this.#et(t);connected(){super.connected(),this.#t.length===0&&this.#L(),this.#e=this.value||"",this.#A(),this.#P(),this.#j()}disconnected(){super.disconnected(),this.#Q(),this.#p?.(),this.#p=null,this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null),document.removeEventListener("pointerdown",this.#b),this.#o?.hidePopover?.(),this.#o=null,this.#r=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null}render(){this.#r&&(this.#r.setAttribute("aria-expanded",String(this.open)),this.disabled||this.readonly?this.#r.contentEditable="false":this.#r.contentEditable="plaintext-only",this.#a&&(this.#a.textContent=this.label||"",this.#a.style.display=this.label?"":"none"),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#u&&(this.#u.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#st():this.#H())}#A(){if(this.querySelector(":scope > [data-field]")){this.#$(),this.#E();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,n=Array.from(this.querySelectorAll(':scope > [slot="prefix"]')),r=Array.from(this.querySelectorAll(':scope > [slot="suffix"]')),o=Array.from(this.querySelectorAll(':scope > [slot="empty"]')),a=Array.from(this.querySelectorAll(':scope > [slot="loading"]')),l=Array.from(this.querySelectorAll(':scope > [slot="footer"]'));this.innerHTML=`
196
197
  <span data-label id="${t}"${this.label?"":' style="display:none"'}>${Vs(this.label||"")}</span>
197
198
  <div data-field>
198
199
  <span data-prefix></span>
@@ -236,7 +237,7 @@ Correct shape for <chart-ui x="label" y="value">:
236
237
  <icon-ui name="circle-notch"></icon-ui>
237
238
  </span>
238
239
  <div data-suggestions id="${t}" role="listbox" hidden></div>
239
- `,this.#y(),this.#w()}#y(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#w(){this.#o&&(this.#o.addEventListener("input",this.#u),this.#o.addEventListener("keydown",this.#d),this.#o.addEventListener("paste",this.#p)),this.#a&&this.#a.addEventListener("remove",this.#f),this.#l&&this.#l.addEventListener("click",this.#O),this.addEventListener("mousedown",this.#m)}#k(){this.#o&&(this.#o.removeEventListener("input",this.#u),this.#o.removeEventListener("keydown",this.#d),this.#o.removeEventListener("paste",this.#p)),this.#a&&this.#a.removeEventListener("remove",this.#f),this.#l&&this.#l.removeEventListener("click",this.#O),this.removeEventListener("mousedown",this.#m)}#v(){if(!this.#a)return;let t=Array.from(this.#a.querySelectorAll(":scope > tag-ui"));for(let e=0;e<this.#t.length;e++){let i=this.#t[e],n=t[e];n||(n=document.createElement("tag-ui"),n.setAttribute("role","listitem"),this.#a.appendChild(n)),n.setAttribute("text",i),this.readonly||this.disabled?n.removeAttribute("removable"):n.setAttribute("removable",""),n.setAttribute("data-index",String(e))}for(let e=this.#t.length;e<t.length;e++)t[e].remove()}#x(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(n=>!this.#t.includes(n)).filter(n=>!t||n.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((n,r)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${r}`),o.dataset.value=n,o.textContent=n,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant");for(let n of this.#l.children)n.removeAttribute("data-active")}#S(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.#o.toggleAttribute("data-empty",t),this.toggleAttribute("editing",!t)}#b(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#n)return;let t=this.#o.textContent||"";if(this.delimiter&&this.delimiter!=="enter"&&t.includes(this.delimiter)){let e=t.split(this.delimiter),i=e.pop(),n=!1;for(let r of e)r.length&&this.#P(r,"delimiter")&&(n=!0);this.#n=!0,this.#o.textContent=i||"",this.#n=!1,this.#V(),this.#S(),this.#x(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#S(),this.#x(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#$(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#o&&this.#o.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let n=this.#l?.children[this.#s];if(n){this.#P(n.dataset.value||"","suggestion");return}}i&&this.#P(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#C(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#N(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#N(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#W())}#E(t){if(this.disabled||this.readonly)return;let e=t.clipboardData?.getData("text/plain")||"";if(!e||!this.pasteSplit)return;t.preventDefault();let i=new RegExp(`[${h2(this.pasteSplit)}]+`),n=e.split(i).map(o=>o.trim()).filter(Boolean);if(n.length===0)return;if(n.length===1){document.execCommand("insertText",!1,n[0]),this.#S(),this.#x();return}let r="";for(let o=0;o<n.length;o++){let a=n[o];!this.#P(a,"paste")&&o===n.length-1&&(r=a)}r&&(this.#n=!0,this.#o.textContent=r,this.#n=!1,this.#V(),this.#S(),this.#x())}#Q(t){let e=t.target.closest("tag-ui[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&this.#C(i,"chip-click")}#L(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#o&&(t.preventDefault(),this.#o?.focus(),this.#V())}#T(t){let e=t.target.closest('[role="option"]');e&&this.#P(e.dataset.value||"","suggestion")}#X(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#P(t,e){if(this.disabled||this.readonly)return!1;let i=this.#X(t.trim());if(!i)return this.#q(),!1;if(i.length<this.minLength)return this.#I(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#I(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#q(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#I(i,"max"),!1;let n=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(n))return this.#I(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#M(i,o,e),!1;if(o===!1)return this.#I(i,"validator"),!1}catch{return this.#I(i,"validator"),!1}return this.#R(i,e),!0}#M(t,e,i){let n=++this.#r;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(r=>{if(!(n!==this.#r||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),r===!1){this.#I(t,"validator");return}this.#R(t,i)}},()=>{n!==this.#r||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#I(t,"validator"))})}#R(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#q(),this.#S(),this.#b(),this.#D(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#C(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),n=i.slice();n.splice(t,1),this.#t=n,this.#v(),this.#S(),this.#b(),this.#D(i,n,e),e!=="programmatic"&&this.#o?.focus()}#D(t,e,i){let n=new Set(t),r=new Set(e),o=e.filter(l=>!n.has(l)),a=t.filter(l=>!r.has(l));o.length===0&&a.length===0||this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e.slice(),added:o,removed:a,source:i}}))}#I(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#q(){this.#o&&(this.#n=!0,this.#o.textContent="",this.#n=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#x())}#V(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#N(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let n of e)n.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#W(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#B(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(n=>String(n??""))}catch{}return e.includes(",")?(this.#I(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#B(t);if(e){this.value=e;return}}super.syncValue(t)}};w("tags-input-ui",fo);var cl=class extends A{static properties={value:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},change:{type:String,default:"",reflect:!0},trend:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="icon"]'),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.textContent=this.change,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};customElements.define("stat-ui",cl);var po=class extends A{static properties={label:{type:String,default:"",reflect:!0},value:{type:Number,default:null,reflect:!0},meta:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","group"),this.#t=this.querySelector(':scope > [slot="label"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","label"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="meta"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","meta"),this.appendChild(this.#e)),this.#i=this.querySelector(":scope > progress-ui"),this.#i||(this.#i=document.createElement("progress-ui"),this.value!=null&&this.value>=0&&this.#i.setAttribute("value",String(this.value)),this.appendChild(this.#i))}disconnected(){this.#t=null,this.#e=null,this.#i=null}render(){this.#t&&(this.#t.textContent=this.label,this.#t.hidden=!this.label,this.#e.textContent=this.meta,this.#e.hidden=!this.meta,this.value!=null&&this.value>=0?this.#i.setAttribute("value",String(this.value)):this.#i.removeAttribute("value"),this.label?this.setAttribute("aria-label",this.meta?`${this.label}, ${this.meta}`:this.label):this.removeAttribute("aria-label"))}};w("progress-row-ui",po);var mo=class extends A{static properties={};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),n=i?e.indexOf(i):-1,r=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),r(n+1);break;case"ArrowUp":t.preventDefault(),r(n-1);break;case"Home":t.preventDefault(),r(0);break;case"End":t.preventDefault(),r(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},go=class extends A{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t(),this.#e()}#t(){if(!this.querySelector('[slot="text"]')){if(this.icon){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#e(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.querySelector('[slot="icon"]');if(this.icon)if(t)t.setAttribute("name",this.icon);else{let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else t&&t.remove();let e=this.querySelector('[slot="text"]');e&&(e.textContent=this.text),this.#e()}};w("action-list-ui",mo),w("action-item-ui",go);var Oo=class extends A{static properties={icon:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},minimal:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s(t){return t.dataset.emptyStateStamped="1",t}#n(t){return t?.dataset?.emptyStateStamped==="1"}connected(){this.#t=this.querySelector(':scope > [slot="icon"]'),this.#t||(this.#t=this.#s(document.createElement("icon-ui")),this.#t.setAttribute("slot","icon"),this.minimal||this.#t.setAttribute("size","lg"),this.insertBefore(this.#t,this.firstChild)),this.#e=this.querySelector(':scope > [slot="heading"]'),this.#e||(this.#e=this.#s(document.createElement("span")),this.#e.setAttribute("slot","heading"),this.insertBefore(this.#e,this.querySelector('[slot="action"]'))),this.#i=this.querySelector(':scope > [slot="description"]'),this.#i||(this.#i=this.#s(document.createElement("span")),this.#i.setAttribute("slot","description"),this.insertBefore(this.#i,this.querySelector('[slot="action"]')))}render(){this.#t&&(this.#n(this.#t)&&(this.icon?(this.#t.setAttribute("name",this.icon),this.#t.hidden=!1):this.#t.hidden=!0),this.#n(this.#e)&&(this.heading?(this.#e.textContent=this.heading,this.#e.hidden=!1):this.#e.hidden=!0),this.#n(this.#i)&&(this.description?(this.#i.textContent=this.description,this.#i.hidden=!1):this.#i.hidden=!0))}disconnected(){this.#t=null,this.#e=null,this.#i=null}};w("empty-state-ui",Oo);var c2=["S","M","T","W","T","F","S"],u2=["January","February","March","April","May","June","July","August","September","October","November","December"];function vk(s){return String(s).padStart(2,"0")}function xg(s,t,e){return`${s}-${vk(t+1)}-${vk(e)}`}function Ei(s){if(!s)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s).trim());return t?new Date(+t[1],+t[2]-1,+t[3]):null}function eu(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var bo=class extends A{static requiredIcons=["caret-left","caret-right"];static properties={value:{type:String,default:"",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},rangeStart:{type:String,default:"",reflect:!0,attribute:"range-start"},rangeEnd:{type:String,default:"",reflect:!0,attribute:"range-end"}};static template=()=>null;#t=new Date().getFullYear();#e=new Date().getMonth();#i=null;#s=!1;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Calendar");let t=Ei(this.value);t&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#s||(this.#s=!0,this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#o),this.#s=!1}render(){let t=Ei(this.value);t&&(t.getFullYear()!==this.#t||t.getMonth()!==this.#e)&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#n()}navigate(t){for(this.#e+=t;this.#e>11;)this.#e-=12,this.#t++;for(;this.#e<0;)this.#e+=12,this.#t--;this.#i=null,this.#n()}focusDay(t){let e=new Date(this.#t,this.#e+1,0).getDate();t<1||t>e||(this.#i=t,this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.())}#n(){let t=this.#t,e=this.#e,i=new Date,n=Ei(this.value),r=Ei(this.min),o=Ei(this.max),a=Ei(this.rangeStart),l=Ei(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
240
+ `,this.#y(),this.#w()}#y(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#w(){this.#o&&(this.#o.addEventListener("input",this.#u),this.#o.addEventListener("keydown",this.#d),this.#o.addEventListener("paste",this.#p)),this.#a&&this.#a.addEventListener("remove",this.#f),this.#l&&this.#l.addEventListener("click",this.#O),this.addEventListener("mousedown",this.#m)}#k(){this.#o&&(this.#o.removeEventListener("input",this.#u),this.#o.removeEventListener("keydown",this.#d),this.#o.removeEventListener("paste",this.#p)),this.#a&&this.#a.removeEventListener("remove",this.#f),this.#l&&this.#l.removeEventListener("click",this.#O),this.removeEventListener("mousedown",this.#m)}#v(){if(!this.#a)return;let t=Array.from(this.#a.querySelectorAll(":scope > tag-ui"));for(let e=0;e<this.#t.length;e++){let i=this.#t[e],n=t[e];n||(n=document.createElement("tag-ui"),n.setAttribute("role","listitem"),this.#a.appendChild(n)),n.setAttribute("text",i),this.readonly||this.disabled?n.removeAttribute("removable"):n.setAttribute("removable",""),n.setAttribute("data-index",String(e))}for(let e=this.#t.length;e<t.length;e++)t[e].remove()}#x(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(n=>!this.#t.includes(n)).filter(n=>!t||n.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((n,r)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${r}`),o.dataset.value=n,o.textContent=n,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant");for(let n of this.#l.children)n.removeAttribute("data-active")}#S(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.#o.toggleAttribute("data-empty",t),this.toggleAttribute("editing",!t)}#b(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#n)return;let t=this.#o.textContent||"";if(this.delimiter&&this.delimiter!=="enter"&&t.includes(this.delimiter)){let e=t.split(this.delimiter),i=e.pop(),n=!1;for(let r of e)r.length&&this.#P(r,"delimiter")&&(n=!0);this.#n=!0,this.#o.textContent=i||"",this.#n=!1,this.#V(),this.#S(),this.#x(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#S(),this.#x(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#$(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#o&&this.#o.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let n=this.#l?.children[this.#s];if(n){this.#P(n.dataset.value||"","suggestion");return}}i&&this.#P(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#C(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#N(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#N(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#W())}#E(t){if(this.disabled||this.readonly)return;let e=t.clipboardData?.getData("text/plain")||"";if(!e||!this.pasteSplit)return;t.preventDefault();let i=new RegExp(`[${h2(this.pasteSplit)}]+`),n=e.split(i).map(o=>o.trim()).filter(Boolean);if(n.length===0)return;if(n.length===1){document.execCommand("insertText",!1,n[0]),this.#S(),this.#x();return}let r="";for(let o=0;o<n.length;o++){let a=n[o];!this.#P(a,"paste")&&o===n.length-1&&(r=a)}r&&(this.#n=!0,this.#o.textContent=r,this.#n=!1,this.#V(),this.#S(),this.#x())}#Q(t){let e=t.target.closest("tag-ui[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#C(i,"chip-click"))}#L(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#o&&(t.preventDefault(),this.#o?.focus(),this.#V())}#T(t){let e=t.target.closest('[role="option"]');e&&this.#P(e.dataset.value||"","suggestion")}#X(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#P(t,e){if(this.disabled||this.readonly)return!1;let i=this.#X(t.trim());if(!i)return this.#q(),!1;if(i.length<this.minLength)return this.#I(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#I(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#q(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#I(i,"max"),!1;let n=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(n))return this.#I(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#M(i,o,e),!1;if(o===!1)return this.#I(i,"validator"),!1}catch{return this.#I(i,"validator"),!1}return this.#R(i,e),!0}#M(t,e,i){let n=++this.#r;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(r=>{if(!(n!==this.#r||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),r===!1){this.#I(t,"validator");return}this.#R(t,i)}},()=>{n!==this.#r||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#I(t,"validator"))})}#R(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#q(),this.#S(),this.#b(),this.#D(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#C(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),n=i.slice();n.splice(t,1),this.#t=n,this.#v(),this.#S(),this.#b(),this.#D(i,n,e),e!=="programmatic"&&this.#o?.focus()}#D(t,e,i){let n=new Set(t),r=new Set(e),o=e.filter(l=>!n.has(l)),a=t.filter(l=>!r.has(l));o.length===0&&a.length===0||this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e.slice(),added:o,removed:a,source:i}}))}#I(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#q(){this.#o&&(this.#n=!0,this.#o.textContent="",this.#n=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#x())}#V(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#N(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let n of e)n.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#W(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#B(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(n=>String(n??""))}catch{}return e.includes(",")?(this.#I(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#B(t);if(e){this.value=e;return}}super.syncValue(t)}};w("tags-input-ui",fo);var cl=class extends A{static properties={value:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},change:{type:String,default:"",reflect:!0},trend:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="icon"]'),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.textContent=this.change,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};customElements.define("stat-ui",cl);var po=class extends A{static properties={label:{type:String,default:"",reflect:!0},value:{type:Number,default:null,reflect:!0},meta:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","group"),this.#t=this.querySelector(':scope > [slot="label"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","label"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="meta"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","meta"),this.appendChild(this.#e)),this.#i=this.querySelector(":scope > progress-ui"),this.#i||(this.#i=document.createElement("progress-ui"),this.value!=null&&this.value>=0&&this.#i.setAttribute("value",String(this.value)),this.appendChild(this.#i))}disconnected(){this.#t=null,this.#e=null,this.#i=null}render(){this.#t&&(this.#t.textContent=this.label,this.#t.hidden=!this.label,this.#e.textContent=this.meta,this.#e.hidden=!this.meta,this.value!=null&&this.value>=0?this.#i.setAttribute("value",String(this.value)):this.#i.removeAttribute("value"),this.label?this.setAttribute("aria-label",this.meta?`${this.label}, ${this.meta}`:this.label):this.removeAttribute("aria-label"))}};w("progress-row-ui",po);var mo=class extends A{static properties={};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),n=i?e.indexOf(i):-1,r=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),r(n+1);break;case"ArrowUp":t.preventDefault(),r(n-1);break;case"Home":t.preventDefault(),r(0);break;case"End":t.preventDefault(),r(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},go=class extends A{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t(),this.#e()}#t(){if(!this.querySelector('[slot="text"]')){if(this.icon){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#e(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.querySelector('[slot="icon"]');if(this.icon)if(t)t.setAttribute("name",this.icon);else{let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else t&&t.remove();let e=this.querySelector('[slot="text"]');e&&(e.textContent=this.text),this.#e()}};w("action-list-ui",mo),w("action-item-ui",go);var Oo=class extends A{static properties={icon:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},minimal:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s(t){return t.dataset.emptyStateStamped="1",t}#n(t){return t?.dataset?.emptyStateStamped==="1"}connected(){this.#t=this.querySelector(':scope > [slot="icon"]'),this.#t||(this.#t=this.#s(document.createElement("icon-ui")),this.#t.setAttribute("slot","icon"),this.minimal||this.#t.setAttribute("size","lg"),this.insertBefore(this.#t,this.firstChild)),this.#e=this.querySelector(':scope > [slot="heading"]'),this.#e||(this.#e=this.#s(document.createElement("span")),this.#e.setAttribute("slot","heading"),this.insertBefore(this.#e,this.querySelector('[slot="action"]'))),this.#i=this.querySelector(':scope > [slot="description"]'),this.#i||(this.#i=this.#s(document.createElement("span")),this.#i.setAttribute("slot","description"),this.insertBefore(this.#i,this.querySelector('[slot="action"]')))}render(){this.#t&&(this.#n(this.#t)&&(this.icon?(this.#t.setAttribute("name",this.icon),this.#t.hidden=!1):this.#t.hidden=!0),this.#n(this.#e)&&(this.heading?(this.#e.textContent=this.heading,this.#e.hidden=!1):this.#e.hidden=!0),this.#n(this.#i)&&(this.description?(this.#i.textContent=this.description,this.#i.hidden=!1):this.#i.hidden=!0))}disconnected(){this.#t=null,this.#e=null,this.#i=null}};w("empty-state-ui",Oo);var c2=["S","M","T","W","T","F","S"],u2=["January","February","March","April","May","June","July","August","September","October","November","December"];function vk(s){return String(s).padStart(2,"0")}function xg(s,t,e){return`${s}-${vk(t+1)}-${vk(e)}`}function Ei(s){if(!s)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s).trim());return t?new Date(+t[1],+t[2]-1,+t[3]):null}function eu(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var bo=class extends A{static requiredIcons=["caret-left","caret-right"];static properties={value:{type:String,default:"",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},rangeStart:{type:String,default:"",reflect:!0,attribute:"range-start"},rangeEnd:{type:String,default:"",reflect:!0,attribute:"range-end"}};static template=()=>null;#t=new Date().getFullYear();#e=new Date().getMonth();#i=null;#s=!1;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Calendar");let t=Ei(this.value);t&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#s||(this.#s=!0,this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#o),this.#s=!1}render(){let t=Ei(this.value);t&&(t.getFullYear()!==this.#t||t.getMonth()!==this.#e)&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#n()}navigate(t){for(this.#e+=t;this.#e>11;)this.#e-=12,this.#t++;for(;this.#e<0;)this.#e+=12,this.#t--;this.#i=null,this.#n()}focusDay(t){let e=new Date(this.#t,this.#e+1,0).getDate();t<1||t>e||(this.#i=t,this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.())}#n(){let t=this.#t,e=this.#e,i=new Date,n=Ei(this.value),r=Ei(this.min),o=Ei(this.max),a=Ei(this.rangeStart),l=Ei(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
240
241
  <button data-cal-prev type="button" aria-label="Previous month" tabindex="-1"><icon-ui name="caret-left"></icon-ui></button>
241
242
  <span data-cal-title>${u2[e]} ${t}</span>
242
243
  <button data-cal-next type="button" aria-label="Next month" tabindex="-1"><icon-ui name="caret-right"></icon-ui></button>
@@ -249,7 +250,7 @@ Correct shape for <chart-ui x="label" y="value">:
249
250
  <button data-cal-prev type="button" aria-label="Previous month"><icon-ui name="caret-left"></icon-ui></button>
250
251
  <span data-cal-title>${xk[e]} ${t}</span>
251
252
  <button data-cal-next type="button" aria-label="Next month"><icon-ui name="caret-right"></icon-ui></button>
252
- </div>`;a+=`<div data-cal-weekdays>${d2.map(f=>`<span>${f}</span>`).join("")}</div>`;let l=new Date(t,e,1).getDay(),h=new Date(t,e+1,0).getDate(),c=new Date(t,e,0).getDate();a+="<div data-cal-grid>";for(let f=l-1;f>=0;f--){let p=c-f;a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${p}</button>`}for(let f=1;f<=h;f++){let p=new Date(t,e,f),m=Sk(t,e,f),O=wk(p,i),g=n&&wk(p,n),y=r&&p<r||o&&p>o,v=this.#r===f,x=['type="button"',"data-cal-day",`data-date="${m}"`,O?"data-today":"",g?"data-selected":"",y?"disabled":"",v?"data-focused":"",`tabindex="${v?"0":"-1"}"`].filter(Boolean).join(" ");a+=`<button ${x}>${f}</button>`}let d=(7-(l+h)%7)%7;for(let f=1;f<=d;f++)a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${f}</button>`;a+="</div>",this.#t.innerHTML=a}#u(t){this.#n+=t,this.#n>11&&(this.#n=0,this.#s++),this.#n<0&&(this.#n=11,this.#s--),this.#r=null,this.#h()}#d(t){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.open&&this.#h()}#p=t=>{if(!this.disabled&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!this.open,this.open)){let e=Hi(this.value);if(e)this.#s=e.getFullYear(),this.#n=e.getMonth(),this.#r=e.getDate();else{let i=new Date;this.#s=i.getFullYear(),this.#n=i.getMonth(),this.#r=i.getDate()}}};#f=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!1)};#m=t=>{if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!0);return}if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.#r){let i=Sk(this.#s,this.#n,this.#r),n=new Date(this.#s,this.#n,this.#r),r=Hi(this.min),o=Hi(this.max);(!r||n>=r)&&(!o||n<=o)&&this.#d(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#s,this.#n+1,0).getDate(),n=(this.#r||1)+e[t.key];if(n<1){this.#u(-1);let o=new Date(this.#s,this.#n+1,0).getDate();this.#r=o+n}else n>i?(this.#u(1),this.#r=n-i):this.#r=n;this.#h(),this.#t?.querySelector("[data-focused]")?.focus()}};disconnected(){super.disconnected(),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.removeEventListener("click",this.#p),this.removeEventListener("keydown",this.#m),document.removeEventListener("pointerdown",this.#f),this.#t&&this.#a&&this.#t.removeEventListener("click",this.#l),this.#a=!1,this.#i?.(),this.#i=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null}};w("calendar-picker-ui",yo);var p2=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m2=["January","February","March","April","May","June","July","August","September","October","November","December"];function kk(s){return String(s).padStart(2,"0")}function Ne(s){return s?`${s.getFullYear()}-${kk(s.getMonth()+1)}-${kk(s.getDate())}`:""}function Sg(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}function ri(s){if(s==null)return null;if(typeof s=="object")return!s.from||!s.to?null:{from:String(s.from),to:String(s.to)};if(typeof s!="string"||!s.trim())return null;try{let t=JSON.parse(s);if(t&&t.from&&t.to)return{from:String(t.from),to:String(t.to)}}catch{}return null}function Ak(s){return s?s.from<=s.to:!1}function $k(s,t){let e=Sg(s);if(!e)return"";switch(t){case"long":return`${m2[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${p2[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function g2(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=Ne(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),Ne(l)},n=Ne(new Date(t.getFullYear(),t.getMonth(),1)),r=Ne(new Date(t.getFullYear(),t.getMonth()+1,0)),o=Ne(new Date(t.getFullYear(),0,1));return[{label:"Today",range:{from:e,to:e}},{label:"Last 7 days",range:{from:i(6),to:e}},{label:"Last 30 days",range:{from:i(29),to:e}},{label:"This month",range:{from:n,to:r}},{label:"Year to date",range:{from:o,to:e}}]}function O2(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var vo=class extends Z{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down","arrow-right"];static get properties(){return{...Z.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;get rangeValue(){return ri(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return ri(this.compareValue)}set rangeCompareValue(t){t==null?this.compareValue="":this.compareValue=JSON.stringify({from:String(t.from),to:String(t.to)})}get presets(){return Array.isArray(this.#t)?this.#t:g2()}set presets(t){Qt(()=>{this.#t=Array.isArray(t)?t.slice():null,this.isConnected&&this.#f()})}open$(){this.open=!0}close$(){this.open=!1}openPopover(){this.disabled||this.readonly||this.open||(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.comparison&&(this.compareValue=""),this.#e=null,this.syncValue("")}applyPreset(t){let e=this.presets.find(i=>i.label===t);return!e||!e.range?!1:(this.#b(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=ri(e);if(this.comparison&&this.name){let n=new FormData;i&&n.append(this.name,e),ri(this.compareValue)&&n.append(`${this.name}-compare`,this.compareValue),this.internals.setFormValue(n)}else this.internals.setFormValue(i?e:"");this.#u(i)}#u(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date range.",this),!1):t&&!Ak(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#d(),this.#r.addEventListener("click",this.#O),this.#r.addEventListener("keydown",this.#g,!0),this.#a.addEventListener("click",this.#y),this.#a.addEventListener("keydown",this.#w),this.#l.addEventListener("change",this.#v),this.#c.addEventListener("change",this.#x)),this.syncValue()}disconnected(){super.disconnected(),this.#r&&(this.#r.removeEventListener("click",this.#O),this.#r.removeEventListener("keydown",this.#g,!0)),this.#a&&(this.#a.removeEventListener("click",this.#y),this.#a.removeEventListener("keydown",this.#w),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#v),this.#c&&this.#c.removeEventListener("change",this.#x),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#k),this.#h?.(),this.#h=null,this.#s=!1,this.#n=!1,this.#r=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null}#d(){if(this.#r=this.ensure("trigger"),this.#a=this.ensure("popover"),this.id&&this.#a.setAttribute("aria-labelledby",this.id),!this.#a.querySelector(":scope > [data-calendar-area]")){let n=this.constructor._pp.calArea.cloneNode(!0);this.#a.appendChild(n)}let t=this.querySelector(':scope > [slot="presets"]');if(t&&t.parentElement!==this.#a)this.#a.appendChild(t),this.#o=t;else if(!this.noPresets&&!t){if(!this.#a.querySelector(":scope > [data-preset-rail]")){let n=this.constructor._pp.presets.cloneNode(!0);this.#a.insertBefore(n,this.#a.querySelector(":scope > [data-calendar-area]"))}this.#o=this.#a.querySelector(":scope > [data-preset-rail]")}let e=this.#a.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let n=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(n)}if(!e.querySelector(":scope > [data-cal-to]")){let n=this.constructor._pp.calTo.cloneNode(!0);e.appendChild(n)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=this.querySelector(':scope > [slot="footer"]');i&&i.parentElement!==this.#a&&this.#a.appendChild(i)}render(){if(!this.#r)return;this.#r.setAttribute("text",this.#p()),this.#r.toggleAttribute("disabled",this.disabled),this.#r.setAttribute("aria-haspopup","dialog"),this.#r.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let t=ri(this.value),e=this.#e,i=e?.from||t?.from||"",n=e?.to||t?.to||"",r=o=>{i?o.setAttribute("range-start",i):o.removeAttribute("range-start"),n?o.setAttribute("range-end",n):o.removeAttribute("range-end")};this.#l&&(this.min&&this.#l.setAttribute("min",this.min),this.max&&this.#l.setAttribute("max",this.max),this.#l.value=e?.from||t?.from||"",r(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=e?.to||t?.to||"",r(this.#c)),this.querySelector(':scope > [slot="presets"]')||(this.noPresets?(this.#o?.remove(),this.#o=null):(this.#o||this.#d(),this.#f())),this.#a&&(this.open&&!this.#n?!this.disabled&&!this.readonly?(this.#n=!0,this.#a.showPopover?.(),this.#h?.(),this.#h=dt(this.#r,this.#a,{placement:this.getAttribute("placement")||"bottom-start",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#k),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#n&&(this.#n=!1,this.#h?.(),this.#h=null,this.#a.hidePopover?.(),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#k),this.#r?.focus?.()))}#p(){let t=ri(this.value);if(!t)return this.placeholder;let e=$k(t.from,this.format),i=$k(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#f(){if(this.#o){this.#o.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#o.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#o.appendChild(t);for(let e of O2()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#o.appendChild(i)}}}}#m=!1;#O=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#g=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#y=t=>{if(this.readonly){let n=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),r=t.target.closest("[data-cal-day]");if(n||r){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let n=ri(this.value);if(!n)return;let r=this.#A(i.dataset.comparisonPresetLabel,n);r&&(this.rangeCompareValue=r);return}};#w=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#$();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#k=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#l?.value||"";if(!e)return;let i=ri(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.from=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));let n=this.#e.to||i?.to||null;n&&this.#b({from:e,to:n})};#x=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#c?.value||"";if(!e)return;let i=ri(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from||i?.from||null,to:e}}}));let n=this.#e.from||i?.from||null;n&&this.#b({from:n,to:e})};#S=t=>{this.open&&(this.contains(t.target)||this.#a&&t.composedPath?.().includes(this.#a)||this.closePopover("outside"))};#b(t,e={}){if(!t||!t.from||!t.to)return;if(!Ak(t)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"reversed"}}));return}if(this.min&&t.from<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"below-min"}}));return}if(this.max&&t.to>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"above-max"}}));return}let i=JSON.stringify({from:t.from,to:t.to});this.value=i,this.#e=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:{from:t.from,to:t.to},compareValue:ri(this.compareValue),presetLabel:e.presetLabel||null}}))}#A(t,e){let i=Sg(e.from),n=Sg(e.to);if(!i||!n)return null;let r=Math.round((n-i)/864e5)+1;switch(t){case"Previous period":{let o=new Date(i);o.setDate(o.getDate()-1);let a=new Date(o);return a.setDate(a.getDate()-(r-1)),{from:Ne(a),to:Ne(o)}}case"Same period last year":{let o=new Date(i);o.setFullYear(o.getFullYear()-1);let a=new Date(n);return a.setFullYear(a.getFullYear()-1),{from:Ne(o),to:Ne(a)}}case"Same period last month":{let o=new Date(i);o.setMonth(o.getMonth()-1);let a=new Date(n);return a.setMonth(a.getMonth()-1),{from:Ne(o),to:Ne(a)}}default:return null}}#$(){if(!this.#a)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#a.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};w("date-range-picker-ui",vo);var Ck=23,Pk=12,jV=1,Ek=59,Qk=59,b2=["hour","minute"];function ul(s){if(!s)return null;let t=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(s).trim());if(!t)return null;let e=Number(t[1]),i=Number(t[2]),n=t[3]!=null?Number(t[3]):0;return!Number.isFinite(e)||e<0||e>23||!Number.isFinite(i)||i<0||i>59||!Number.isFinite(n)||n<0||n>59?null:{h:e,m:i,s:n}}function wg({h:s,m:t,s:e},i){let n=r=>String(r).padStart(2,"0");return i==="second"?`${n(s)}:${n(t)}:${n(e)}`:`${n(s)}:${n(t)}`}function xo({h:s,m:t,s:e}){return s*3600+t*60+e}function y2(s){try{let t=s||document?.documentElement?.lang||void 0,i=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions(),n=i.hourCycle||(i.hour12?"h12":"h23");return n==="h11"||n==="h12"?"h12":"h23"}catch{return"h23"}}var wo=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#n(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:y2(this.locale)}get#r(){return this.#n==="h12"}get#a(){return this.precision==="second"}get#o(){return`${this.#n}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#g),this.addEventListener("focusin",this.#y),this.addEventListener("focusout",this.#w)}render(){this.#i&&this.#i!==this.#o&&this.#l(),this.#u(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#g),this.removeEventListener("focusin",this.#y),this.removeEventListener("focusout",this.#w),this.#t=null,this.#e=[],this.#s=null}clear(){this.value="",this.syncValue(""),this.#u()}stepUp(t,e=1){this.#p(t,1*(e|0||1))}stepDown(t,e=1){this.#p(t,-1*(e|0||1))}#l(){let t=this.#n,e=this.#a,i=this.#r,n=[...b2];e&&n.push("second"),i&&n.push("meridiem"),this.#e=n;let r=this.querySelector(':scope > [slot="prefix"]'),o=this.querySelector(':scope > [slot="suffix"]'),a=(c,u,d)=>`<span data-segment="${c}" role="spinbutton" tabindex="0"
253
+ </div>`;a+=`<div data-cal-weekdays>${d2.map(f=>`<span>${f}</span>`).join("")}</div>`;let l=new Date(t,e,1).getDay(),h=new Date(t,e+1,0).getDate(),c=new Date(t,e,0).getDate();a+="<div data-cal-grid>";for(let f=l-1;f>=0;f--){let p=c-f;a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${p}</button>`}for(let f=1;f<=h;f++){let p=new Date(t,e,f),m=Sk(t,e,f),O=wk(p,i),g=n&&wk(p,n),y=r&&p<r||o&&p>o,v=this.#r===f,x=['type="button"',"data-cal-day",`data-date="${m}"`,O?"data-today":"",g?"data-selected":"",y?"disabled":"",v?"data-focused":"",`tabindex="${v?"0":"-1"}"`].filter(Boolean).join(" ");a+=`<button ${x}>${f}</button>`}let d=(7-(l+h)%7)%7;for(let f=1;f<=d;f++)a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${f}</button>`;a+="</div>",this.#t.innerHTML=a}#u(t){this.#n+=t,this.#n>11&&(this.#n=0,this.#s++),this.#n<0&&(this.#n=11,this.#s--),this.#r=null,this.#h()}#d(t){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.open&&this.#h()}#p=t=>{if(!this.disabled&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!this.open,this.open)){let e=Hi(this.value);if(e)this.#s=e.getFullYear(),this.#n=e.getMonth(),this.#r=e.getDate();else{let i=new Date;this.#s=i.getFullYear(),this.#n=i.getMonth(),this.#r=i.getDate()}}};#f=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!1)};#m=t=>{if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!0);return}if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.#r){let i=Sk(this.#s,this.#n,this.#r),n=new Date(this.#s,this.#n,this.#r),r=Hi(this.min),o=Hi(this.max);(!r||n>=r)&&(!o||n<=o)&&this.#d(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#s,this.#n+1,0).getDate(),n=(this.#r||1)+e[t.key];if(n<1){this.#u(-1);let o=new Date(this.#s,this.#n+1,0).getDate();this.#r=o+n}else n>i?(this.#u(1),this.#r=n-i):this.#r=n;this.#h(),this.#t?.querySelector("[data-focused]")?.focus()}};disconnected(){super.disconnected(),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.removeEventListener("click",this.#p),this.removeEventListener("keydown",this.#m),document.removeEventListener("pointerdown",this.#f),this.#t&&this.#a&&this.#t.removeEventListener("click",this.#l),this.#a=!1,this.#i?.(),this.#i=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null}};w("calendar-picker-ui",yo);var p2=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m2=["January","February","March","April","May","June","July","August","September","October","November","December"];function kk(s){return String(s).padStart(2,"0")}function Ne(s){return s?`${s.getFullYear()}-${kk(s.getMonth()+1)}-${kk(s.getDate())}`:""}function Sg(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}function ri(s){if(s==null)return null;if(typeof s=="object")return!s.from||!s.to?null:{from:String(s.from),to:String(s.to)};if(typeof s!="string"||!s.trim())return null;try{let t=JSON.parse(s);if(t&&t.from&&t.to)return{from:String(t.from),to:String(t.to)}}catch{}return null}function Ak(s){return s?s.from<=s.to:!1}function $k(s,t){let e=Sg(s);if(!e)return"";switch(t){case"long":return`${m2[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${p2[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function g2(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=Ne(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),Ne(l)},n=Ne(new Date(t.getFullYear(),t.getMonth(),1)),r=Ne(new Date(t.getFullYear(),t.getMonth()+1,0)),o=Ne(new Date(t.getFullYear(),0,1));return[{label:"Today",range:{from:e,to:e}},{label:"Last 7 days",range:{from:i(6),to:e}},{label:"Last 30 days",range:{from:i(29),to:e}},{label:"This month",range:{from:n,to:r}},{label:"Year to date",range:{from:o,to:e}}]}function O2(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var vo=class extends Z{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down","arrow-right"];static get properties(){return{...Z.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;get rangeValue(){return ri(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return ri(this.compareValue)}set rangeCompareValue(t){t==null?this.compareValue="":this.compareValue=JSON.stringify({from:String(t.from),to:String(t.to)})}get presets(){return Array.isArray(this.#t)?this.#t:g2()}set presets(t){Qt(()=>{this.#t=Array.isArray(t)?t.slice():null,this.isConnected&&this.#f()})}open$(){this.open=!0}close$(){this.open=!1}openPopover(){this.disabled||this.readonly||this.open||(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.comparison&&(this.compareValue=""),this.#e=null,this.syncValue("")}applyPreset(t){let e=this.presets.find(i=>i.label===t);return!e||!e.range?!1:(this.#b(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=ri(e);if(this.comparison&&this.name){let n=new FormData;i&&n.append(this.name,e),ri(this.compareValue)&&n.append(`${this.name}-compare`,this.compareValue),this.internals.setFormValue(n)}else this.internals.setFormValue(i?e:"");this.#u(i)}#u(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date range.",this),!1):t&&!Ak(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#d(),this.#r.addEventListener("click",this.#O),this.#r.addEventListener("keydown",this.#g,!0),this.#a.addEventListener("click",this.#y),this.#a.addEventListener("keydown",this.#w),this.#l.addEventListener("change",this.#v),this.#c.addEventListener("change",this.#x)),this.syncValue()}disconnected(){super.disconnected(),this.#r&&(this.#r.removeEventListener("click",this.#O),this.#r.removeEventListener("keydown",this.#g,!0)),this.#a&&(this.#a.removeEventListener("click",this.#y),this.#a.removeEventListener("keydown",this.#w),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#v),this.#c&&this.#c.removeEventListener("change",this.#x),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#k),this.#h?.(),this.#h=null,this.#s=!1,this.#n=!1,this.#r=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null}#d(){if(this.#r=this.ensure("trigger"),this.#a=this.ensure("popover"),this.id&&this.#a.setAttribute("aria-labelledby",this.id),!this.#a.querySelector(":scope > [data-calendar-area]")){let n=this.constructor._pp.calArea.cloneNode(!0);this.#a.appendChild(n)}let t=this.querySelector(':scope > [slot="presets"]');if(t&&t.parentElement!==this.#a)this.#a.appendChild(t),this.#o=t;else if(!this.noPresets&&!t){if(!this.#a.querySelector(":scope > [data-preset-rail]")){let n=this.constructor._pp.presets.cloneNode(!0);this.#a.insertBefore(n,this.#a.querySelector(":scope > [data-calendar-area]"))}this.#o=this.#a.querySelector(":scope > [data-preset-rail]")}let e=this.#a.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let n=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(n)}if(!e.querySelector(":scope > [data-cal-to]")){let n=this.constructor._pp.calTo.cloneNode(!0);e.appendChild(n)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=this.querySelector(':scope > [slot="footer"]');i&&i.parentElement!==this.#a&&this.#a.appendChild(i)}render(){if(!this.#r)return;this.#r.setAttribute("text",this.#p()),this.#r.toggleAttribute("disabled",this.disabled),this.#r.setAttribute("aria-haspopup","dialog"),this.#r.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let t=ri(this.value),e=this.#e,i=e?.from||t?.from||"",n=e?.to||t?.to||"",r=o=>{i?o.setAttribute("range-start",i):o.removeAttribute("range-start"),n?o.setAttribute("range-end",n):o.removeAttribute("range-end")};this.#l&&(this.min&&this.#l.setAttribute("min",this.min),this.max&&this.#l.setAttribute("max",this.max),this.#l.value=e?.from||t?.from||"",r(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=e?.to||t?.to||"",r(this.#c)),this.querySelector(':scope > [slot="presets"]')||(this.noPresets?(this.#o?.remove(),this.#o=null):(this.#o||this.#d(),this.#f())),this.#a&&(this.open&&!this.#n?!this.disabled&&!this.readonly?(this.#n=!0,this.#a.showPopover?.(),this.#h?.(),this.#h=dt(this.#r,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#k),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#n&&(this.#n=!1,this.#h?.(),this.#h=null,this.#a.hidePopover?.(),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#k),this.#r?.focus?.()))}#p(){let t=ri(this.value);if(!t)return this.placeholder;let e=$k(t.from,this.format),i=$k(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#f(){if(this.#o){this.#o.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#o.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#o.appendChild(t);for(let e of O2()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#o.appendChild(i)}}}}#m=!1;#O=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#g=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#y=t=>{if(this.readonly){let n=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),r=t.target.closest("[data-cal-day]");if(n||r){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let n=ri(this.value);if(!n)return;let r=this.#A(i.dataset.comparisonPresetLabel,n);r&&(this.rangeCompareValue=r);return}};#w=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#$();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#k=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#l?.value||"";if(!e)return;let i=ri(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.from=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));let n=this.#e.to||i?.to||null;n&&this.#b({from:e,to:n})};#x=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#c?.value||"";if(!e)return;let i=ri(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from||i?.from||null,to:e}}}));let n=this.#e.from||i?.from||null;n&&this.#b({from:n,to:e})};#S=t=>{this.open&&(this.contains(t.target)||this.#a&&t.composedPath?.().includes(this.#a)||this.closePopover("outside"))};#b(t,e={}){if(!t||!t.from||!t.to)return;if(!Ak(t)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"reversed"}}));return}if(this.min&&t.from<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"below-min"}}));return}if(this.max&&t.to>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"above-max"}}));return}let i=JSON.stringify({from:t.from,to:t.to});this.value=i,this.#e=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:{from:t.from,to:t.to},compareValue:ri(this.compareValue),presetLabel:e.presetLabel||null}}))}#A(t,e){let i=Sg(e.from),n=Sg(e.to);if(!i||!n)return null;let r=Math.round((n-i)/864e5)+1;switch(t){case"Previous period":{let o=new Date(i);o.setDate(o.getDate()-1);let a=new Date(o);return a.setDate(a.getDate()-(r-1)),{from:Ne(a),to:Ne(o)}}case"Same period last year":{let o=new Date(i);o.setFullYear(o.getFullYear()-1);let a=new Date(n);return a.setFullYear(a.getFullYear()-1),{from:Ne(o),to:Ne(a)}}case"Same period last month":{let o=new Date(i);o.setMonth(o.getMonth()-1);let a=new Date(n);return a.setMonth(a.getMonth()-1),{from:Ne(o),to:Ne(a)}}default:return null}}#$(){if(!this.#a)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#a.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};w("date-range-picker-ui",vo);var Ck=23,Pk=12,jV=1,Ek=59,Qk=59,b2=["hour","minute"];function ul(s){if(!s)return null;let t=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(s).trim());if(!t)return null;let e=Number(t[1]),i=Number(t[2]),n=t[3]!=null?Number(t[3]):0;return!Number.isFinite(e)||e<0||e>23||!Number.isFinite(i)||i<0||i>59||!Number.isFinite(n)||n<0||n>59?null:{h:e,m:i,s:n}}function wg({h:s,m:t,s:e},i){let n=r=>String(r).padStart(2,"0");return i==="second"?`${n(s)}:${n(t)}:${n(e)}`:`${n(s)}:${n(t)}`}function xo({h:s,m:t,s:e}){return s*3600+t*60+e}function y2(s){try{let t=s||document?.documentElement?.lang||void 0,i=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions(),n=i.hourCycle||(i.hour12?"h12":"h23");return n==="h11"||n==="h12"?"h12":"h23"}catch{return"h23"}}var wo=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#n(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:y2(this.locale)}get#r(){return this.#n==="h12"}get#a(){return this.precision==="second"}get#o(){return`${this.#n}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#g),this.addEventListener("focusin",this.#y),this.addEventListener("focusout",this.#w)}render(){this.#i&&this.#i!==this.#o&&this.#l(),this.#u(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#g),this.removeEventListener("focusin",this.#y),this.removeEventListener("focusout",this.#w),this.#t=null,this.#e=[],this.#s=null}clear(){this.value="",this.syncValue(""),this.#u()}stepUp(t,e=1){this.#p(t,1*(e|0||1))}stepDown(t,e=1){this.#p(t,-1*(e|0||1))}#l(){let t=this.#n,e=this.#a,i=this.#r,n=[...b2];e&&n.push("second"),i&&n.push("meridiem"),this.#e=n;let r=this.querySelector(':scope > [slot="prefix"]'),o=this.querySelector(':scope > [slot="suffix"]'),a=(c,u,d)=>`<span data-segment="${c}" role="spinbutton" tabindex="0"
253
254
  aria-label="${u}" aria-valuemin="0" aria-valuemax="${d}"
254
255
  aria-valuenow=""></span>`,l='<span data-separator aria-hidden="true">:</span>',h="";h+=a("hour","Hours",i?Pk:Ck),h+=l,h+=a("minute","Minutes",Ek),e&&(h+=l,h+=a("second","Seconds",Qk)),i&&(h+=`<span data-segment="meridiem" role="spinbutton" tabindex="0"
255
256
  aria-label="AM/PM" aria-valuemin="0" aria-valuemax="1"