@adia-ai/web-modules 0.8.34 → 0.8.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.
@@ -108,7 +108,7 @@ See the JSDoc header of icons-phosphor.js for the full recipe (gh#786).`)},0)}el
108
108
  <div slot="text" contenteditable="plaintext-only" tabindex="0"
109
109
  ${this.value?"":'data-empty=""'}
110
110
  data-placeholder="${this.placeholder}"></div>
111
- `),this.#t=this.querySelector('[slot="text"]'),this.value&&(this.#t.textContent=this.value),this.#t&&(this.#t.addEventListener("input",this.#e),this.#t.addEventListener("keydown",this.#i),this.#t.addEventListener("blur",this.#s),this.#t.addEventListener("paste",this.#r))}render(){if(!this.#t)return;this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let t=this.value||"";this.#t.textContent!==t&&(this.#t.textContent=t,this.#t.toggleAttribute("data-empty",!t));let e=this.querySelector('[slot="label"]');e&&this.label&&e.setAttribute("label",this.label),this.setAttribute("aria-label",this.label||this.placeholder||"")}#e=()=>{let t=this.#t.textContent||"";this.value=t,this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#i=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.flushPendingInput(),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#s=()=>{this.flushPendingInput(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#r=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,e)};focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#t.textContent="",this.#t.setAttribute("data-empty","")),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#e),this.#t.removeEventListener("keydown",this.#i),this.#t.removeEventListener("blur",this.#s),this.#t.removeEventListener("paste",this.#r)),this.#t=null}};C();y("textarea-ui",dr);$();var fr=class extends R{static labelDeprecated=!1;static properties={...R.properties,checked:{type:Boolean,default:!1,reflect:!0},indeterminate:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>Y`<span slot="box"></span>`;connected(){super.connected(),this.setAttribute("role","checkbox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){this.indeterminate?this.setAttribute("aria-checked","mixed"):this.setAttribute("aria-checked",String(this.checked)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.label&&this.setAttribute("aria-label",this.label),this.syncValue(this.checked?this.value||"on":"")}#t=()=>{this.disabled||(this.checked=!this.checked,this.indeterminate=!1,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}})))};#e=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#t())};disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};C();y("check-ui",fr);$();var pr=class extends R{static labelDeprecated=!1;static properties={...R.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>Y`<span slot="dot"></span>`;connected(){super.connected(),this.setAttribute("role","radio"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){this.setAttribute("aria-checked",String(this.checked)),this.label&&this.setAttribute("aria-label",this.label),this.checked&&this.syncValue(this.value||"on")}#t=()=>{if(this.disabled||this.checked)return;let t=this.closest('fieldset, [role="radiogroup"]')||this.parentElement;if(t)for(let e of t.querySelectorAll(`radio-ui[name="${this.name}"]`))e!==this&&e.checked&&(e.checked=!1);this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}}))};#e=t=>{if((t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#t()),t.key==="ArrowDown"||t.key==="ArrowRight"){t.preventDefault();let e=this.#i(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#i(-1);e&&(e.focus(),e.click())}};#i(t){let i=[...(this.closest('fieldset, [role="radiogroup"]')||this.parentElement)?.querySelectorAll(`radio-ui[name="${this.name}"]`)||[]],r=i.indexOf(this);return i[(r+t+i.length)%i.length]||null}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};C();y("radio-ui",pr);$();var mr=class s extends v{static properties={label:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;connected(){this.setAttribute("role","radiogroup"),this.#e(),this.#t?.id&&this.setAttribute("aria-labelledby",this.#t.id)}disconnected(){this.#t=null}render(){this.#t&&(this.#t.textContent=this.label||""),this.required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required")}#e(){if(this.#t=this.querySelector(":scope > [data-radio-group-label]"),!this.#t){let t=document.createElement("div");t.setAttribute("slot","label"),t.setAttribute("data-radio-group-label",""),t.id=s.#s(),t.textContent=this.label||"",this.prepend(t),this.#t=t}}static#i=0;static#s(){return`radio-group-label-${++s.#i}`}};C();y("radio-group-ui",mr);var gr=class extends R{static properties={...R.properties,checked:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},layout:{type:String,default:"default",reflect:!0}};static template=()=>null;connected(){super.connected(),this.setAttribute("role","radio"),this.setAttribute("tabindex","0"),this.#t(),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}render(){this.setAttribute("aria-checked",String(this.checked)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let t=this.querySelector(':scope > [slot="heading"]');t&&t.dataset.fromAttr==="true"&&(t.textContent=this.heading||"");let e=this.querySelector(':scope > [slot="description"]');e&&e.dataset.fromAttr==="true"&&(e.textContent=this.description||"");let i=this.querySelector(':scope > [slot="icon"]');i&&i.dataset.fromAttr==="true"&&i.setAttribute("name",this.icon||""),this.checked?this.syncValue(this.value||"on"):this.syncValue("")}#t(){if(this.heading&&!ot(this,"heading").length){let t=document.createElement("span");t.setAttribute("slot","heading"),t.dataset.fromAttr="true",t.textContent=this.heading,this.appendChild(t)}if(this.description&&!ot(this,"description").length){let t=document.createElement("span");t.setAttribute("slot","description"),t.dataset.fromAttr="true",t.textContent=this.description,this.appendChild(t)}if(this.icon&&!ot(this,"icon").length){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.dataset.fromAttr="true",t.setAttribute("name",this.icon),this.appendChild(t)}}#e=()=>{if(this.disabled||this.readonly||this.checked)return;let t=this.#s();if(t)for(let e of t.querySelectorAll(`option-card-ui[name="${this.name}"]`))e!==this&&e.checked&&(e.checked=!1);this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}}))};#i=t=>{if(t.target===this){if(t.key===" "||t.key==="Enter"){t.preventDefault(),this.#e();return}if(t.key==="ArrowDown"||t.key==="ArrowRight"){t.preventDefault();let e=this.#r(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#r(-1);e&&(e.focus(),e.click())}}};#s(){return this.closest('fieldset, [role="radiogroup"]')||this.parentElement}#r(t){let i=[...this.#s()?.querySelectorAll(`option-card-ui[name="${this.name}"]`)||[]],r=i.indexOf(this);return r<0?null:i[(r+t+i.length)%i.length]||null}};C();y("option-card-ui",gr);$();var Ue=Object.freeze({AVAILABLE:"available",CONNECTED:"connected",ERROR:"error",PENDING:"pending",COMING_SOON:"coming-soon"}),Ry=Object.freeze({available:{event:"press",emits:"connect",label:"Connect",variant:"primary",icon:""},connected:{event:"press",emits:"configure",label:"Configure",variant:"outline",icon:""},error:{event:"press",emits:"retry",label:"Retry",variant:"outline",icon:"arrow-clockwise"},pending:{event:"press",emits:"",label:"Connecting\u2026",variant:"outline",icon:""}}),IC=Object.freeze({connected:{variant:"success",text:"Connected",icon:"check"},error:{variant:"danger",text:"Error",icon:"warning-circle"},pending:{variant:"info",text:"Connecting\u2026",icon:""},"coming-soon":{text:"Coming soon",icon:""}}),DC=Object.freeze({slack:"chat-circle",github:"git-branch",gitlab:"git-branch",linear:"kanban",stripe:"credit-card",zapier:"lightning",figma:"figma-logo",notion:"notion-logo",webhook:"lightning",discord:"discord-logo",google:"google-logo"}),qC="plug",br=class extends v{static requiredIcons=["check","warning-circle","arrow-clockwise"];static properties={provider:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!1},logo:{type:String,default:"",reflect:!1},description:{type:String,default:"",reflect:!1},status:{type:String,default:"available",reflect:!0},"error-message":{type:String,default:"",attribute:"error-message"},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={body:'<div slot="body" data-integration-card-body></div>',logo:'<div slot="logo" data-integration-card-logo></div>',heading:'<div slot="heading" data-integration-card-heading></div>',desc:'<p slot="description" data-integration-card-description></p>',error:'<p slot="error" data-integration-card-error></p>',status:'<badge-ui slot="status" data-integration-card-status></badge-ui>',footer:'<footer slot="footer" data-integration-card-footer></footer>',button:'<button-ui slot="action" data-integration-card-action></button-ui>'};static template=()=>null;#t="";#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;connected(){this.setAttribute("role","group"),this.#e=this.ensure("body"),this.#i=this.ensure("logo"),this.#s=this.ensure("heading"),this.#r=this.ensure("desc"),this.#a=this.ensure("status"),this.#o=this.ensure("footer"),this.#i.parentElement!==this.#e&&this.#e.appendChild(this.#i),this.#s.parentElement!==this.#e&&this.#e.appendChild(this.#s),this.#a.parentElement!==this.#e&&this.#e.appendChild(this.#a),this.#s.id?this.#t=this.#s.id:(this.#t=`integration-card-heading-${Math.random().toString(36).slice(2,9)}`,this.#s.id=this.#t),this.setAttribute("aria-labelledby",this.#t),this.addEventListener("press",this.#m),this.addEventListener("action",this.#g)}disconnected(){this.removeEventListener("press",this.#m),this.removeEventListener("action",this.#g),this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=null}render(){if(!this.#s)return;let t=this.#h();this.name&&this.#s.textContent!==this.name&&(this.#s.textContent=this.name),this.#c()?this.#r.parentElement===this&&this.#r.remove():(this.#r.parentElement||this.appendChild(this.#r),this.description?(this.#r.textContent!==this.description&&(this.#r.textContent=this.description),this.#r.hidden=!1):(this.#r.textContent="",this.#r.hidden=!0)),this.#d(),this.#u(t),this.#f(t),this.#p(t)}#h(){let t=(this.status||"").trim()||Ue.AVAILABLE;return Object.values(Ue).includes(t)?t:Ue.AVAILABLE}#c(){for(let t of this.children)if(t!==this.#e&&t!==this.#r&&t!==this.#n&&t!==this.#o&&!(t.getAttribute&&t.getAttribute("slot")==="actions")&&!(t.dataset&&(t.dataset.integrationCardBody!==void 0||t.dataset.integrationCardDescription!==void 0||t.dataset.integrationCardError!==void 0||t.dataset.integrationCardFooter!==void 0)))return!0;return!1}#d(){if(!this.#i)return;let t=(this.logo||"").trim();if(t.startsWith("{{p:"))return;let e=(this.provider||"").trim().toLowerCase(),i=t||DC[e]||(e?qC:"");if(!i){this.#i.replaceChildren(),this.#i.hidden=!0;return}if(this.#i.hidden=!1,i.includes("/")){let o=this.#i.querySelector(":scope > img");if(o&&o.getAttribute("src")===i){o.setAttribute("alt",`${this.name||this.provider||"Integration"} logo`);return}this.#i.replaceChildren(),o=document.createElement("img"),o.setAttribute("src",i),o.setAttribute("alt",`${this.name||this.provider||"Integration"} logo`),o.setAttribute("data-integration-logo",""),o.setAttribute("loading","lazy"),o.setAttribute("decoding","async"),this.#i.appendChild(o);return}let n=this.#i.querySelector(":scope > icon-ui");n&&n.getAttribute("name")===i||(this.#i.replaceChildren(),n=document.createElement("icon-ui"),n.setAttribute("name",i),n.setAttribute("aria-hidden","true"),this.#i.appendChild(n))}#u(t){if(!this.#a)return;let e=IC[t];if(!e){this.#a.hidden=!0,this.#a.removeAttribute("aria-label");return}this.#a.hidden=!1,e.variant?(this.#a.setAttribute("variant",e.variant),this.#a.removeAttribute("tone")):(this.#a.removeAttribute("variant"),this.#a.setAttribute("tone","muted")),this.#a.setAttribute("text",e.text),this.#a.setAttribute("size","sm"),e.icon?this.#a.setAttribute("icon",e.icon):this.#a.removeAttribute("icon"),this.#a.setAttribute("aria-label",e.text)}#f(t){let e=(this["error-message"]||this.getAttribute("error-message")||"").trim();t===Ue.ERROR&&e?(this.#n||(this.#n=this.ensure("error")),this.#n.parentElement||(this.#r?.parentElement===this?this.#r.after(this.#n):this.#o?.parentElement===this?this.insertBefore(this.#n,this.#o):this.appendChild(this.#n)),this.#n.textContent!==e&&(this.#n.textContent=e),this.#n.hidden=!1,this.#n.setAttribute("role","status")):this.#n&&(this.#n.hidden=!0,this.#n.textContent="")}#p(t){if(t===Ue.COMING_SOON){this.drop("button"),this.#l=null;return}let e=Ry[t];if(!e){this.drop("button"),this.#l=null;return}this.#l||(this.#l=this.ensure("button")),this.#l.parentElement!==this.#o&&this.#o.insertBefore(this.#l,this.#o.firstChild),this.#l.setAttribute("text",e.label),this.#l.setAttribute("variant",e.variant),this.#l.setAttribute("size","sm"),e.icon?this.#l.setAttribute("icon",e.icon):this.#l.removeAttribute("icon"),t===Ue.CONNECTED?this.#l.setAttribute("aria-pressed","true"):t===Ue.AVAILABLE?this.#l.setAttribute("aria-pressed","false"):this.#l.removeAttribute("aria-pressed");let i={available:"Connect to",connected:"Configure",error:"Retry connecting",pending:"Connecting to"}[t]||e.label,r=this.name||this.provider||"integration";this.#l.setAttribute("aria-label",`${i} ${r}`),t===Ue.PENDING||this.disabled?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")}#m=t=>{if(!this.#l||t.target!==this.#l&&!t.composedPath?.().includes(this.#l))return;if(this.disabled){t.stopPropagation();return}let e=this.#h();if(e===Ue.PENDING||e===Ue.COMING_SOON){t.stopPropagation();return}let i=Ry[e];!i||!i.emits||this.dispatchEvent(new CustomEvent(i.emits,{bubbles:!0,detail:{provider:this.provider}}))};#g=t=>{let e=t.detail?.action||t.target?.getAttribute?.("action");if(e&&(e==="disconnect"||e==="reauth"||e==="re-authenticate")){let i=e==="disconnect"?"disconnect":"reauth";this.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:{provider:this.provider}}))}}};C();y("integration-card-ui",br);$();var Or=class s extends R{static labelDeprecated=!1;static properties={...R.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0}};static#t=0;static template=t=>{let e=t.hint?`switch-hint-${++s.#t}`:"";return e?t.setAttribute("aria-describedby",e):t.removeAttribute("aria-describedby"),Y`
111
+ `),this.#t=this.querySelector('[slot="text"]'),this.value&&(this.#t.textContent=this.value),this.#t&&(this.#t.addEventListener("input",this.#e),this.#t.addEventListener("keydown",this.#i),this.#t.addEventListener("blur",this.#s),this.#t.addEventListener("paste",this.#r))}render(){if(!this.#t)return;this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let t=this.value||"";this.#t.textContent!==t&&(this.#t.textContent=t,this.#t.toggleAttribute("data-empty",!t));let e=this.querySelector('[slot="label"]');e&&this.label&&e.setAttribute("label",this.label),this.setAttribute("aria-label",this.label||this.placeholder||"")}#e=()=>{let t=this.#t.textContent||"";this.value=t,this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#i=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.flushPendingInput(),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#s=()=>{this.flushPendingInput(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#r=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,e)};focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#t.textContent="",this.#t.setAttribute("data-empty","")),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#e),this.#t.removeEventListener("keydown",this.#i),this.#t.removeEventListener("blur",this.#s),this.#t.removeEventListener("paste",this.#r)),this.#t=null}};C();y("textarea-ui",dr);$();var fr=class extends R{static labelDeprecated=!1;static properties={...R.properties,checked:{type:Boolean,default:!1,reflect:!0},indeterminate:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},labelHidden:{type:Boolean,default:!1,reflect:!0,attribute:"label-hidden"}};static template=()=>Y`<span slot="box"></span>`;connected(){super.connected(),this.setAttribute("role","checkbox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){this.indeterminate?this.setAttribute("aria-checked","mixed"):this.setAttribute("aria-checked",String(this.checked)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.label&&this.setAttribute("aria-label",this.label),this.syncValue(this.checked?this.value||"on":"")}#t=()=>{this.disabled||(this.checked=!this.checked,this.indeterminate=!1,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}})))};#e=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#t())};disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};C();y("check-ui",fr);$();var pr=class extends R{static labelDeprecated=!1;static properties={...R.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>Y`<span slot="dot"></span>`;connected(){super.connected(),this.setAttribute("role","radio"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}render(){this.setAttribute("aria-checked",String(this.checked)),this.label&&this.setAttribute("aria-label",this.label),this.checked&&this.syncValue(this.value||"on")}#t=()=>{if(this.disabled||this.checked)return;let t=this.closest('fieldset, [role="radiogroup"]')||this.parentElement;if(t)for(let e of t.querySelectorAll(`radio-ui[name="${this.name}"]`))e!==this&&e.checked&&(e.checked=!1);this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}}))};#e=t=>{if((t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#t()),t.key==="ArrowDown"||t.key==="ArrowRight"){t.preventDefault();let e=this.#i(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#i(-1);e&&(e.focus(),e.click())}};#i(t){let i=[...(this.closest('fieldset, [role="radiogroup"]')||this.parentElement)?.querySelectorAll(`radio-ui[name="${this.name}"]`)||[]],r=i.indexOf(this);return i[(r+t+i.length)%i.length]||null}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};C();y("radio-ui",pr);$();var mr=class s extends v{static properties={label:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;connected(){this.setAttribute("role","radiogroup"),this.#e(),this.#t?.id&&this.setAttribute("aria-labelledby",this.#t.id)}disconnected(){this.#t=null}render(){this.#t&&(this.#t.textContent=this.label||""),this.required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required")}#e(){if(this.#t=this.querySelector(":scope > [data-radio-group-label]"),!this.#t){let t=document.createElement("div");t.setAttribute("slot","label"),t.setAttribute("data-radio-group-label",""),t.id=s.#s(),t.textContent=this.label||"",this.prepend(t),this.#t=t}}static#i=0;static#s(){return`radio-group-label-${++s.#i}`}};C();y("radio-group-ui",mr);var gr=class extends R{static properties={...R.properties,checked:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},layout:{type:String,default:"default",reflect:!0}};static template=()=>null;connected(){super.connected(),this.setAttribute("role","radio"),this.setAttribute("tabindex","0"),this.#t(),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}render(){this.setAttribute("aria-checked",String(this.checked)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let t=this.querySelector(':scope > [slot="heading"]');t&&t.dataset.fromAttr==="true"&&(t.textContent=this.heading||"");let e=this.querySelector(':scope > [slot="description"]');e&&e.dataset.fromAttr==="true"&&(e.textContent=this.description||"");let i=this.querySelector(':scope > [slot="icon"]');i&&i.dataset.fromAttr==="true"&&i.setAttribute("name",this.icon||""),this.checked?this.syncValue(this.value||"on"):this.syncValue("")}#t(){if(this.heading&&!ot(this,"heading").length){let t=document.createElement("span");t.setAttribute("slot","heading"),t.dataset.fromAttr="true",t.textContent=this.heading,this.appendChild(t)}if(this.description&&!ot(this,"description").length){let t=document.createElement("span");t.setAttribute("slot","description"),t.dataset.fromAttr="true",t.textContent=this.description,this.appendChild(t)}if(this.icon&&!ot(this,"icon").length){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.dataset.fromAttr="true",t.setAttribute("name",this.icon),this.appendChild(t)}}#e=()=>{if(this.disabled||this.readonly||this.checked)return;let t=this.#s();if(t)for(let e of t.querySelectorAll(`option-card-ui[name="${this.name}"]`))e!==this&&e.checked&&(e.checked=!1);this.checked=!0,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,checked:this.checked}}))};#i=t=>{if(t.target===this){if(t.key===" "||t.key==="Enter"){t.preventDefault(),this.#e();return}if(t.key==="ArrowDown"||t.key==="ArrowRight"){t.preventDefault();let e=this.#r(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#r(-1);e&&(e.focus(),e.click())}}};#s(){return this.closest('fieldset, [role="radiogroup"]')||this.parentElement}#r(t){let i=[...this.#s()?.querySelectorAll(`option-card-ui[name="${this.name}"]`)||[]],r=i.indexOf(this);return r<0?null:i[(r+t+i.length)%i.length]||null}};C();y("option-card-ui",gr);$();var Ue=Object.freeze({AVAILABLE:"available",CONNECTED:"connected",ERROR:"error",PENDING:"pending",COMING_SOON:"coming-soon"}),Ry=Object.freeze({available:{event:"press",emits:"connect",label:"Connect",variant:"primary",icon:""},connected:{event:"press",emits:"configure",label:"Configure",variant:"outline",icon:""},error:{event:"press",emits:"retry",label:"Retry",variant:"outline",icon:"arrow-clockwise"},pending:{event:"press",emits:"",label:"Connecting\u2026",variant:"outline",icon:""}}),IC=Object.freeze({connected:{variant:"success",text:"Connected",icon:"check"},error:{variant:"danger",text:"Error",icon:"warning-circle"},pending:{variant:"info",text:"Connecting\u2026",icon:""},"coming-soon":{text:"Coming soon",icon:""}}),DC=Object.freeze({slack:"chat-circle",github:"git-branch",gitlab:"git-branch",linear:"kanban",stripe:"credit-card",zapier:"lightning",figma:"figma-logo",notion:"notion-logo",webhook:"lightning",discord:"discord-logo",google:"google-logo"}),qC="plug",br=class extends v{static requiredIcons=["check","warning-circle","arrow-clockwise"];static properties={provider:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!1},logo:{type:String,default:"",reflect:!1},description:{type:String,default:"",reflect:!1},status:{type:String,default:"available",reflect:!0},"error-message":{type:String,default:"",attribute:"error-message"},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={body:'<div slot="body" data-integration-card-body></div>',logo:'<div slot="logo" data-integration-card-logo></div>',heading:'<div slot="heading" data-integration-card-heading></div>',desc:'<p slot="description" data-integration-card-description></p>',error:'<p slot="error" data-integration-card-error></p>',status:'<badge-ui slot="status" data-integration-card-status></badge-ui>',footer:'<footer slot="footer" data-integration-card-footer></footer>',button:'<button-ui slot="action" data-integration-card-action></button-ui>'};static template=()=>null;#t="";#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;connected(){this.setAttribute("role","group"),this.#e=this.ensure("body"),this.#i=this.ensure("logo"),this.#s=this.ensure("heading"),this.#r=this.ensure("desc"),this.#a=this.ensure("status"),this.#o=this.ensure("footer"),this.#i.parentElement!==this.#e&&this.#e.appendChild(this.#i),this.#s.parentElement!==this.#e&&this.#e.appendChild(this.#s),this.#a.parentElement!==this.#e&&this.#e.appendChild(this.#a),this.#s.id?this.#t=this.#s.id:(this.#t=`integration-card-heading-${Math.random().toString(36).slice(2,9)}`,this.#s.id=this.#t),this.setAttribute("aria-labelledby",this.#t),this.addEventListener("press",this.#m),this.addEventListener("action",this.#g)}disconnected(){this.removeEventListener("press",this.#m),this.removeEventListener("action",this.#g),this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=null}render(){if(!this.#s)return;let t=this.#h();this.name&&this.#s.textContent!==this.name&&(this.#s.textContent=this.name),this.#c()?this.#r.parentElement===this&&this.#r.remove():(this.#r.parentElement||this.appendChild(this.#r),this.description?(this.#r.textContent!==this.description&&(this.#r.textContent=this.description),this.#r.hidden=!1):(this.#r.textContent="",this.#r.hidden=!0)),this.#d(),this.#u(t),this.#f(t),this.#p(t)}#h(){let t=(this.status||"").trim()||Ue.AVAILABLE;return Object.values(Ue).includes(t)?t:Ue.AVAILABLE}#c(){for(let t of this.children)if(t!==this.#e&&t!==this.#r&&t!==this.#n&&t!==this.#o&&!(t.getAttribute&&t.getAttribute("slot")==="actions")&&!(t.dataset&&(t.dataset.integrationCardBody!==void 0||t.dataset.integrationCardDescription!==void 0||t.dataset.integrationCardError!==void 0||t.dataset.integrationCardFooter!==void 0)))return!0;return!1}#d(){if(!this.#i)return;let t=(this.logo||"").trim();if(t.startsWith("{{p:"))return;let e=(this.provider||"").trim().toLowerCase(),i=t||DC[e]||(e?qC:"");if(!i){this.#i.replaceChildren(),this.#i.hidden=!0;return}if(this.#i.hidden=!1,i.includes("/")){let o=this.#i.querySelector(":scope > img");if(o&&o.getAttribute("src")===i){o.setAttribute("alt",`${this.name||this.provider||"Integration"} logo`);return}this.#i.replaceChildren(),o=document.createElement("img"),o.setAttribute("src",i),o.setAttribute("alt",`${this.name||this.provider||"Integration"} logo`),o.setAttribute("data-integration-logo",""),o.setAttribute("loading","lazy"),o.setAttribute("decoding","async"),this.#i.appendChild(o);return}let n=this.#i.querySelector(":scope > icon-ui");n&&n.getAttribute("name")===i||(this.#i.replaceChildren(),n=document.createElement("icon-ui"),n.setAttribute("name",i),n.setAttribute("aria-hidden","true"),this.#i.appendChild(n))}#u(t){if(!this.#a)return;let e=IC[t];if(!e){this.#a.hidden=!0,this.#a.removeAttribute("aria-label");return}this.#a.hidden=!1,e.variant?(this.#a.setAttribute("variant",e.variant),this.#a.removeAttribute("tone")):(this.#a.removeAttribute("variant"),this.#a.setAttribute("tone","muted")),this.#a.setAttribute("text",e.text),this.#a.setAttribute("size","sm"),e.icon?this.#a.setAttribute("icon",e.icon):this.#a.removeAttribute("icon"),this.#a.setAttribute("aria-label",e.text)}#f(t){let e=(this["error-message"]||this.getAttribute("error-message")||"").trim();t===Ue.ERROR&&e?(this.#n||(this.#n=this.ensure("error")),this.#n.parentElement||(this.#r?.parentElement===this?this.#r.after(this.#n):this.#o?.parentElement===this?this.insertBefore(this.#n,this.#o):this.appendChild(this.#n)),this.#n.textContent!==e&&(this.#n.textContent=e),this.#n.hidden=!1,this.#n.setAttribute("role","status")):this.#n&&(this.#n.hidden=!0,this.#n.textContent="")}#p(t){if(t===Ue.COMING_SOON){this.drop("button"),this.#l=null;return}let e=Ry[t];if(!e){this.drop("button"),this.#l=null;return}this.#l||(this.#l=this.ensure("button")),this.#l.parentElement!==this.#o&&this.#o.insertBefore(this.#l,this.#o.firstChild),this.#l.setAttribute("text",e.label),this.#l.setAttribute("variant",e.variant),this.#l.setAttribute("size","sm"),e.icon?this.#l.setAttribute("icon",e.icon):this.#l.removeAttribute("icon"),t===Ue.CONNECTED?this.#l.setAttribute("aria-pressed","true"):t===Ue.AVAILABLE?this.#l.setAttribute("aria-pressed","false"):this.#l.removeAttribute("aria-pressed");let i={available:"Connect to",connected:"Configure",error:"Retry connecting",pending:"Connecting to"}[t]||e.label,r=this.name||this.provider||"integration";this.#l.setAttribute("aria-label",`${i} ${r}`),t===Ue.PENDING||this.disabled?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")}#m=t=>{if(!this.#l||t.target!==this.#l&&!t.composedPath?.().includes(this.#l))return;if(this.disabled){t.stopPropagation();return}let e=this.#h();if(e===Ue.PENDING||e===Ue.COMING_SOON){t.stopPropagation();return}let i=Ry[e];!i||!i.emits||this.dispatchEvent(new CustomEvent(i.emits,{bubbles:!0,detail:{provider:this.provider}}))};#g=t=>{let e=t.detail?.action||t.target?.getAttribute?.("action");if(e&&(e==="disconnect"||e==="reauth"||e==="re-authenticate")){let i=e==="disconnect"?"disconnect":"reauth";this.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:{provider:this.provider}}))}}};C();y("integration-card-ui",br);$();var Or=class s extends R{static labelDeprecated=!1;static properties={...R.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0}};static#t=0;static template=t=>{let e=t.hint?`switch-hint-${++s.#t}`:"";return e?t.setAttribute("aria-describedby",e):t.removeAttribute("aria-describedby"),Y`
112
112
  <span slot="track"><span slot="thumb"></span></span>
113
113
  ${t.label?Y`<span slot="label">${t.label}</span>`:null}
114
114
  ${t.hint?Y`<span slot="hint" id=${e}>${t.hint}</span>`:null}
@@ -213,7 +213,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
213
213
  <path data-wordmark-glyph fill-rule="evenodd" clip-rule="evenodd" d="M267.953 4.72882H299.978V178.524H267.953V163.876C258.519 175.959 245.113 182 227.735 182C211.019 182 196.703 175.71 184.786 163.131C173.035 150.386 167.16 134.827 167.16 116.454C167.16 98.0817 173.035 82.6057 184.786 70.0262C196.703 57.2812 211.019 50.9087 227.735 50.9087C245.113 50.9087 258.519 56.9502 267.953 69.0331V4.72882ZM208.867 141.779C215.488 148.234 223.763 151.462 233.693 151.462C243.623 151.462 251.816 148.234 258.271 141.779C264.725 135.158 267.953 126.717 267.953 116.454C267.953 106.192 264.725 97.8334 258.271 91.3782C251.816 84.7574 243.623 81.447 233.693 81.447C223.763 81.447 215.488 84.7574 208.867 91.3782C202.413 97.8334 199.185 106.192 199.185 116.454C199.185 126.717 202.413 135.158 208.867 141.779Z"></path>
214
214
  <path data-wordmark-glyph fill-rule="evenodd" clip-rule="evenodd" d="M116.681 147.241L127.108 178.524H164.347L103.275 4.72882H60.8231L0 178.524H36.9904L47.4172 147.241H116.681ZM82.1733 44.2052L106.006 115.213H58.3406L82.1733 44.2052Z"></path>
215
215
  </svg>
216
- `;connected(){this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Adia")}};C();y("adia-wordmark-ui",on);$();var an=class extends v{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}};C();y("progress-ui",an);$();var ln=class extends v{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"),!ot(this,"caption").length&&!ot(this,"track").length?(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=ot(this,"caption")[0],this.#e=ot(this,"track")[0])}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 r=0;r<this.#e.children.length;r++)this.#e.children[r].toggleAttribute("data-active",r<e)}}disconnected(){this.#t=null,this.#e=null}};C();y("step-progress-ui",ln);$();var hn=class extends v{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}};C();y("skeleton-ui",hn);$();var cn=class extends v{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(r=>r.remove());let i=document.createDocumentFragment();for(let r=1;r<=3;r++){let n=document.createElement("span");n.setAttribute("data-spinner-dot",String(r)),n.setAttribute("aria-hidden","true"),i.appendChild(n)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};C();y("spinner-ui",cn);$();var un=class extends v{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 r=!!t.get.call(this);e.call(this,i),!!i!==r&&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.#n(),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.#r():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#r()},e)}else this.#i&&this.#n()}#r(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#n(){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)}};C();y("loading-overlay-ui",un);$();var zy=new Set;function _y(s,t){zy.has(s)||(zy.add(s),console.warn(`[alert-ui] ${t}`))}var dn=class s extends v{static requiredIcons=["x"];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"&&(_y("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger]. 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")&&(_y("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.#c();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.#h(),(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.#h();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 r=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",r)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let n=document.createElement("strong");n.textContent=this.title,t.appendChild(n),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let r=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",r)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#h()}#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 r=this.title||this.#r();if(r){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=r,i.appendChild(l)}let n=this.#n(),o=this.#o();if(n||o){if(i.appendChild(document.createTextNode(" ")),n){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=n,i.appendChild(l)}if(n&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[r,n,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#r(){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"}}#n(){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=/^\d{4}-\d{2}-\d{2}$/.test(this.dueAt)?new Date(`${this.dueAt}T00:00:00`):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""}}#h(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#c(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};C();y("alert-ui",dn);$();var n$={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},fn=class extends v{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||n$[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()}};C();y("inline-message-ui",fn);$();var pn=class extends v{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};C();y("kbd-ui",pn);$();var mn=class extends v{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-ui slot="dismiss" variant="ghost" size="sm" aria-label="Remove"><icon-ui slot="icon" name="x" weight="bold"></icon-ui></button-ui>'};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")}};C();y("tag-ui",mn);$();var o$=new Set(["block","dot","square","line","dashed"]),a$=new Set(["sm","md","lg"]),l$=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),h$={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},c$={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function u$(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&l$.has(t)):[]}var ms=null;function d$(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!ms){let u=document.createElement("canvas");u.width=1,u.height=1,ms=u.getContext("2d")}ms.fillStyle="#000",ms.clearRect(0,0,1,1),ms.fillStyle=s,ms.fillRect(0,0,1,1);let[t,e,i]=ms.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let r=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},n=r(t),o=r(e),a=r(i),l=Math.cbrt(.4122214708*n+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*n+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*n+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var gn=class extends v{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,attribute:"auto-contrast"},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;#o=null;#l=null;#h=null;#c=null;#d=null;connected(){this.#u(),this.#S(),typeof MutationObserver<"u"&&(this.#d=new MutationObserver(t=>{let e=!1;for(let i of t){for(let r of i.addedNodes)if(r.nodeType===1){if(r.getAttribute?.("slot")==="chrome"){e=!0;break}if(r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#d.takeRecords())}),this.#d.observe(this,{childList:!0}))}render(){this.#u(),this.#p(),this.#m(),this.#y(),this.#b(),this.#O(),this.#g()}#u(){if(this.#n)return;let t=Array.from(this.children).filter(n=>n.getAttribute&&n.getAttribute("slot")==="chrome");for(let n of t)n.remove();let e=Array.from(this.children).filter(n=>n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]'));for(let n of e)n.remove();let i=[];for(let n of Array.from(this.childNodes))(n.nodeType===3&&!n.data||n.nodeType===8)&&i.push(n);for(let n of i)n.remove();let r=Array.from(this.childNodes).filter(n=>!(n.nodeType===1&&n.dataset&&(n.dataset.tile!==void 0||n.dataset.label!==void 0||n.dataset.detail!==void 0||n.dataset.badge!==void 0||n.dataset.copy!==void 0))&&!(n.nodeType===3&&!n.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 n of t)this.appendChild(n);for(let n of e)this.appendChild(n);for(let n of i)this.appendChild(n);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",""),r.length)for(let n of r)this.#e.appendChild(n);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#r=document.createElement("button-ui"),this.#r.setAttribute("data-copy",""),this.#r.setAttribute("variant","ghost"),this.#r.setAttribute("size","xs"),this.#r.setAttribute("aria-label","Copy value"),this.#r.setAttribute("hidden",""),this.#r.setAttribute("text","\u29C9"),this.appendChild(this.#r),this.#n=!0}#f(){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.#r&&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.#r||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#p(){if(!this.#t||!this.#e)return;this.#f();let t=o$.has(this.shape)?this.shape:"square",e=a$.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=u$(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(n=>n.dataset.badgeVariant);if(e.length===t.length&&e.every((n,o)=>n===t[o]))return;let r=document.createDocumentFragment();for(let n of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",n),o.setAttribute("role","img"),o.setAttribute("aria-label",c$[n]),o.textContent=h$[n],r.appendChild(o)}this.#s.replaceChildren(r)}#g(){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=d$(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)}#y(){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)}#b(){if(!this.#r)return;if(!this.copyable){this.#r.setAttribute("hidden","");return}this.#r.removeAttribute("hidden");let t=this.#x();t?this.#r.setAttribute("aria-label",`Copy ${t}`):this.#r.setAttribute("aria-label","Copy value")}#O(){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"))}#S(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#r)||this.#v()},this.#l=t=>{!this.selectable||t.key!=="Enter"&&t.key!==" "||(t.composedPath?t.composedPath():[t.target]).includes(this.#r)||(t.preventDefault(),this.#v())},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#h=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#x();e&&this.#w(e)},this.#r.addEventListener("click",this.#h)}#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#w(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#A(e)}#A(t){this.#r&&(this.#c!=null&&clearTimeout(this.#c),this.#r.setAttribute("data-copy-state",t?"ok":"fail"),this.#r.setAttribute("text",t?"\u2713":"\u26A0"),this.#c=setTimeout(()=>{this.#r&&(this.#r.removeAttribute("data-copy-state"),this.#r.setAttribute("text","\u29C9"),this.#c=null)},1200))}disconnected(){this.#c!=null&&(clearTimeout(this.#c),this.#c=null),this.#d&&(this.#d.disconnect(),this.#d=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#r&&this.#h&&this.#r.removeEventListener("click",this.#h),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=!1}};C();y("swatch-ui",gn);Pt();var Vy={xs:0,sm:480,md:768,lg:1024,xl:1280},gs=Object.keys(Vy),ff=Object.values(Vy);function jy(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=gs.length-1;t>=0;t--)if(s>=ff[t])return gs[t];return"xs"}var Pe=zi(jy());if(typeof window<"u")for(let s=1;s<ff.length;s++)window.matchMedia(`(min-width: ${ff[s]}px)`).addEventListener("change",()=>{Pe.value=jy()});function Zt(s,t=Pe.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 r=gs.indexOf(t),n=null,o=-1;for(let[a,l]of i){let h=gs.indexOf(a);h!==-1&&h<=r&&h>o&&(n=l,o=h)}return n??e}$();var bn=class extends v{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,n=t?.includes("@")||e?.includes("@")||i?.includes("@")?Pe.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",m$(Zt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Zt(e,n);this.style.setProperty("--col-align",g$(o)),this.style.textAlign=b$(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",O$(Zt(i,n))):this.style.removeProperty("--col-justify")}},f$={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},p$={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function m$(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function g$(s){return f$[s]??s}function b$(s){return{start:"start",center:"center",end:"end"}[s]??""}function O$(s){return p$[s]??s}C();y("col-ui",bn);$();var On=class s extends v{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.#g()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=t=>{let e=this.#g();if(!e)return;let i=this.#b(e);i&&(t.preventDefault(),i.focus())};connected(){this.#d(),this.#u(),this.#f(),this.#p(),this.#h(),this.#t?.addEventListener("click",this.#n),typeof MutationObserver<"u"&&(this.#r=new MutationObserver(()=>{this.#p(),this.#h(),this.#m(),this.#a()}),this.#r.observe(this,{childList:!0})),this.#a()}disconnected(){this.#r?.disconnect(),this.#r=null,this.#c(),this.#t?.removeEventListener("click",this.#n),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;#h(){let t=this.#g();t!==this.#l&&(this.#c(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#c(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#d(){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}}#u(){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.#x("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#f(){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.#x("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#p(){if(!this.#t)return;let t=this.#g();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#S()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#g();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 r=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(n=>n&&!n.startsWith("field-hint-")&&!n.startsWith("field-err-")),...e].join(" ").trim();r?t.setAttribute("aria-describedby",r):t.removeAttribute("aria-describedby")}#g(){let t=null,e=null;for(let i of this.children)if(!i.hasAttribute("slot")){if(t===null&&(t=i),s.#y.has(i.localName))return i;e===null&&this.#b(i)&&(e=i)}return e??t}static#y=new Set(["input-ui","textarea-ui","select-ui","combobox-ui","search-ui","check-ui","radio-ui","switch-ui","slider-ui","range-ui","otp-input-ui","tags-input-ui","chat-input-ui","autocomplete-input-ui","datetime-picker-ui","date-range-picker-ui","calendar-picker-ui","color-picker-ui","upload-ui","rating-ui","segmented-ui","input","textarea","select"]);#b(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#O=0;static#S(){return`field-ctl-${++s.#O}`}static#v=0;static#x(t){return`field-${t}-${++s.#v}`}};C();y("field-ui",On);$();var yn=class extends v{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),typeof MutationObserver<"u"&&(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}};C();y("fields-ui",yn);$();C();var Wy=0,za=class extends v{static properties={label:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},hint:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=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.insertBefore(this.#t,this.firstChild)),this.#t.id||(this.#t.id=`display-field-label-${++Wy}`),this.#e=this.querySelector(':scope > [slot="value"]'),this.#i=this.querySelector(':scope > [slot="hint"]'),this.#s=this.querySelector(':scope > icon-ui[slot="icon"]')}render(){if(!this.#t)return;this.label?(this.#t.textContent=this.label,this.#t.hidden=!1,this.setAttribute("aria-labelledby",this.#t.id)):(this.#t.hidden=!0,this.removeAttribute("aria-labelledby")),this.querySelector(":scope > :not([slot])")?this.#e&&(this.#e.remove(),this.#e=null):(this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","value"),this.appendChild(this.#e)),this.#e.textContent=this.value),this.hint?(this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","hint"),this.#i.id=`display-field-hint-${++Wy}`,this.appendChild(this.#i)),this.#i.textContent=this.hint,this.setAttribute("aria-describedby",this.#i.id)):this.#i&&(this.#i.remove(),this.#i=null,this.removeAttribute("aria-describedby")),this.icon?(this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.#s.setAttribute("aria-hidden","true"),this.appendChild(this.#s)),this.#s.setAttribute("name",this.icon)):this.#s&&(this.#s.remove(),this.#s=null)}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};y("display-field-ui",za);$();var vn=class extends v{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(tn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(tn),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,r=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!r?Pe.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",x$(Zt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",S$(Zt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",w$(Zt(i,o))):this.style.removeProperty("--row-justify"),r){let a=gs.indexOf(o),l=gs.indexOf(r);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},y$={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},v$={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function x$(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function S$(s){return y$[s]??s}function w$(s){return v$[s]??s}C();y("row-ui",vn);$();var xn=class extends v{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"},minColumnWidth:{type:String,default:"",reflect:!0,attribute:"min-column-width"}};static template=()=>null;render(){let t=Pe.value,e=this.columns;if(e?.includes("@")){let r=Zt(e,t);this.style.gridTemplateColumns=this.#t(r),this.style.gridAutoFlow=r?"row":"",this.style.gridAutoColumns=r?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";this.minColumnWidth?this.style.setProperty("--grid-min-col",this.minColumnWidth):this.style.removeProperty("--grid-min-col");let i=this.gap;if(i?.includes("@")){let r=Zt(i,t),n=this.#e(r);this.style.columnGap=n,this.style.rowGap=n}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(var(--grid-min-col, 12rem), 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(var(--grid-min-col, 12rem), 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};C();y("grid-ui",xn);$();var Sn=class extends v{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};C();y("stack-ui",Sn);$();var wn=class extends v{static properties={};static template=()=>null};C();y("frame-ui",wn);$();function Vi(s,t,e=5){let r=(t-s||1)/e,n=Math.pow(10,Math.floor(Math.log10(r))),o=r/n,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*n,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 Fy(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 ae(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function At({label:s,value:t,pct:e,series:i}){let r="";return s!=null&&(r+=` data-tip-label="${ae(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${ae(String(i))}"`),r}function le(s,t,e){return s+t*Math.cos(e)}function he(s,t,e){return s+t*Math.sin(e)}function A$(s,t,e,i,r){let n=le(s,e,i),o=he(t,e,i),a=le(s,e,r),l=he(t,e,r),h=r-i>Math.PI?1:0;return`M ${s} ${t} L ${n} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function pf(s,t,e,i,r,n,o=0){let a=(e-i)/2,l=n-r,h=Math.max(0,Math.min(o,a)),c=()=>{let ft=le(s,e,r),lt=he(t,e,r),yt=le(s,e,n),wt=he(t,e,n),vt=le(s,i,n),$t=he(t,i,n),Mt=le(s,i,r),Ht=he(t,i,r),us=l>Math.PI?1:0;return`M ${ft} ${lt} A ${e} ${e} 0 ${us} 1 ${yt} ${wt} L ${vt} ${$t} A ${i} ${i} 0 ${us} 0 ${Mt} ${Ht} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=r+u,p=n-u,m=r+d,b=n-d,g=p-f>Math.PI?1:0,x=le(s,e,f),S=he(t,e,f),w=le(s,e,p),A=he(t,e,p),k=le(s,i,b),E=he(t,i,b),P=le(s,i,m),L=he(t,i,m),T=le(s,e-h,r),q=he(t,e-h,r),I=le(s,i+h,r),z=he(t,i+h,r),V=le(s,e-h,n),U=he(t,e-h,n),tt=le(s,i+h,n),nt=he(t,i+h,n);return`M ${x} ${S} A ${e} ${e} 0 ${g} 1 ${w} ${A} A ${h} ${h} 0 0 1 ${V} ${U} L ${tt} ${nt} A ${h} ${h} 0 0 1 ${k} ${E} A ${i} ${i} 0 ${g} 0 ${P} ${L} A ${h} ${h} 0 0 1 ${I} ${z} L ${T} ${q} A ${h} ${h} 0 0 1 ${x} ${S} Z`}function _a(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(r=>`${r.x},${r.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let r=0;r<e-1;r++){let n=s[Math.max(r-1,0)],o=s[r],a=s[r+1],l=s[Math.min(r+2,e-1)],h=o.x+(a.x-n.x)*t/3,c=o.y+(a.y-n.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 mf(s,t,e=.4){let i=_a(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function jh(s,t,e,i,r=0){if(i<=0||e<=0)return"";let n=Math.max(0,Math.min(r,e/2,i));return n===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+n} Q${s},${t} ${s+n},${t} H${s+e-n} Q${s+e},${t} ${s+e},${t+n} V${t+i} Z`}var k$={std:{ratio:4/3}},An=class extends v{static properties={type:{type:String,default:"bar",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},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},dots:{type:String,default:"all",reflect:!0},seriesEmphasis:{type:String,default:"",reflect:!0,attribute:"series-emphasis"}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#r=0;#n=0;#a=new Set;#o=null;#l(){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.
216
+ `;connected(){this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Adia")}};C();y("adia-wordmark-ui",on);$();var an=class extends v{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}};C();y("progress-ui",an);$();var ln=class extends v{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"),!ot(this,"caption").length&&!ot(this,"track").length?(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=ot(this,"caption")[0],this.#e=ot(this,"track")[0])}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 r=0;r<this.#e.children.length;r++)this.#e.children[r].toggleAttribute("data-active",r<e)}}disconnected(){this.#t=null,this.#e=null}};C();y("step-progress-ui",ln);$();var hn=class extends v{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}};C();y("skeleton-ui",hn);$();var cn=class extends v{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(r=>r.remove());let i=document.createDocumentFragment();for(let r=1;r<=3;r++){let n=document.createElement("span");n.setAttribute("data-spinner-dot",String(r)),n.setAttribute("aria-hidden","true"),i.appendChild(n)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};C();y("spinner-ui",cn);$();var un=class extends v{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 r=!!t.get.call(this);e.call(this,i),!!i!==r&&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.#n(),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.#r():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#r()},e)}else this.#i&&this.#n()}#r(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#n(){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)}};C();y("loading-overlay-ui",un);$();var zy=new Set;function _y(s,t){zy.has(s)||(zy.add(s),console.warn(`[alert-ui] ${t}`))}var dn=class s extends v{static requiredIcons=["x"];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"&&(_y("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger]. 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")&&(_y("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.#c();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.#h(),(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.#h();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 r=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",r)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let n=document.createElement("strong");n.textContent=this.title,t.appendChild(n),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let r=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",r)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#h()}#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 r=this.title||this.#r();if(r){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=r,i.appendChild(l)}let n=this.#n(),o=this.#o();if(n||o){if(i.appendChild(document.createTextNode(" ")),n){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=n,i.appendChild(l)}if(n&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[r,n,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#r(){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"}}#n(){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=/^\d{4}-\d{2}-\d{2}$/.test(this.dueAt)?new Date(`${this.dueAt}T00:00:00`):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""}}#h(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#c(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};C();y("alert-ui",dn);$();var n$={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},fn=class extends v{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||n$[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()}};C();y("inline-message-ui",fn);$();var pn=class extends v{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};C();y("kbd-ui",pn);$();var mn=class extends v{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-ui slot="dismiss" variant="ghost" size="sm" aria-label="Remove"><icon-ui slot="icon" name="x" weight="bold" size="0.75rem"></icon-ui></button-ui>'};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")}};C();y("tag-ui",mn);$();var o$=new Set(["block","dot","square","line","dashed"]),a$=new Set(["sm","md","lg"]),l$=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),h$={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},c$={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function u$(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&l$.has(t)):[]}var ms=null;function d$(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!ms){let u=document.createElement("canvas");u.width=1,u.height=1,ms=u.getContext("2d")}ms.fillStyle="#000",ms.clearRect(0,0,1,1),ms.fillStyle=s,ms.fillRect(0,0,1,1);let[t,e,i]=ms.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let r=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},n=r(t),o=r(e),a=r(i),l=Math.cbrt(.4122214708*n+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*n+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*n+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var gn=class extends v{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,attribute:"auto-contrast"},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;#o=null;#l=null;#h=null;#c=null;#d=null;connected(){this.#u(),this.#S(),typeof MutationObserver<"u"&&(this.#d=new MutationObserver(t=>{let e=!1;for(let i of t){for(let r of i.addedNodes)if(r.nodeType===1){if(r.getAttribute?.("slot")==="chrome"){e=!0;break}if(r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#d.takeRecords())}),this.#d.observe(this,{childList:!0}))}render(){this.#u(),this.#p(),this.#m(),this.#y(),this.#b(),this.#O(),this.#g()}#u(){if(this.#n)return;let t=Array.from(this.children).filter(n=>n.getAttribute&&n.getAttribute("slot")==="chrome");for(let n of t)n.remove();let e=Array.from(this.children).filter(n=>n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]'));for(let n of e)n.remove();let i=[];for(let n of Array.from(this.childNodes))(n.nodeType===3&&!n.data||n.nodeType===8)&&i.push(n);for(let n of i)n.remove();let r=Array.from(this.childNodes).filter(n=>!(n.nodeType===1&&n.dataset&&(n.dataset.tile!==void 0||n.dataset.label!==void 0||n.dataset.detail!==void 0||n.dataset.badge!==void 0||n.dataset.copy!==void 0))&&!(n.nodeType===3&&!n.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 n of t)this.appendChild(n);for(let n of e)this.appendChild(n);for(let n of i)this.appendChild(n);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",""),r.length)for(let n of r)this.#e.appendChild(n);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#r=document.createElement("button-ui"),this.#r.setAttribute("data-copy",""),this.#r.setAttribute("variant","ghost"),this.#r.setAttribute("size","xs"),this.#r.setAttribute("aria-label","Copy value"),this.#r.setAttribute("hidden",""),this.#r.setAttribute("text","\u29C9"),this.appendChild(this.#r),this.#n=!0}#f(){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.#r&&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.#r||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#p(){if(!this.#t||!this.#e)return;this.#f();let t=o$.has(this.shape)?this.shape:"square",e=a$.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=u$(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(n=>n.dataset.badgeVariant);if(e.length===t.length&&e.every((n,o)=>n===t[o]))return;let r=document.createDocumentFragment();for(let n of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",n),o.setAttribute("role","img"),o.setAttribute("aria-label",c$[n]),o.textContent=h$[n],r.appendChild(o)}this.#s.replaceChildren(r)}#g(){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=d$(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)}#y(){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)}#b(){if(!this.#r)return;if(!this.copyable){this.#r.setAttribute("hidden","");return}this.#r.removeAttribute("hidden");let t=this.#x();t?this.#r.setAttribute("aria-label",`Copy ${t}`):this.#r.setAttribute("aria-label","Copy value")}#O(){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"))}#S(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#r)||this.#v()},this.#l=t=>{!this.selectable||t.key!=="Enter"&&t.key!==" "||(t.composedPath?t.composedPath():[t.target]).includes(this.#r)||(t.preventDefault(),this.#v())},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#h=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#x();e&&this.#w(e)},this.#r.addEventListener("click",this.#h)}#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#w(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#A(e)}#A(t){this.#r&&(this.#c!=null&&clearTimeout(this.#c),this.#r.setAttribute("data-copy-state",t?"ok":"fail"),this.#r.setAttribute("text",t?"\u2713":"\u26A0"),this.#c=setTimeout(()=>{this.#r&&(this.#r.removeAttribute("data-copy-state"),this.#r.setAttribute("text","\u29C9"),this.#c=null)},1200))}disconnected(){this.#c!=null&&(clearTimeout(this.#c),this.#c=null),this.#d&&(this.#d.disconnect(),this.#d=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#r&&this.#h&&this.#r.removeEventListener("click",this.#h),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#r=null,this.#n=!1}};C();y("swatch-ui",gn);Pt();var Vy={xs:0,sm:480,md:768,lg:1024,xl:1280},gs=Object.keys(Vy),ff=Object.values(Vy);function jy(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=gs.length-1;t>=0;t--)if(s>=ff[t])return gs[t];return"xs"}var Pe=zi(jy());if(typeof window<"u")for(let s=1;s<ff.length;s++)window.matchMedia(`(min-width: ${ff[s]}px)`).addEventListener("change",()=>{Pe.value=jy()});function Zt(s,t=Pe.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 r=gs.indexOf(t),n=null,o=-1;for(let[a,l]of i){let h=gs.indexOf(a);h!==-1&&h<=r&&h>o&&(n=l,o=h)}return n??e}$();var bn=class extends v{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,n=t?.includes("@")||e?.includes("@")||i?.includes("@")?Pe.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",m$(Zt(t,n))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Zt(e,n);this.style.setProperty("--col-align",g$(o)),this.style.textAlign=b$(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",O$(Zt(i,n))):this.style.removeProperty("--col-justify")}},f$={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},p$={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function m$(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function g$(s){return f$[s]??s}function b$(s){return{start:"start",center:"center",end:"end"}[s]??""}function O$(s){return p$[s]??s}C();y("col-ui",bn);$();var On=class s extends v{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.#g()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=t=>{let e=this.#g();if(!e)return;let i=this.#b(e);i&&(t.preventDefault(),i.focus())};connected(){this.#d(),this.#u(),this.#f(),this.#p(),this.#h(),this.#t?.addEventListener("click",this.#n),typeof MutationObserver<"u"&&(this.#r=new MutationObserver(()=>{this.#p(),this.#h(),this.#m(),this.#a()}),this.#r.observe(this,{childList:!0})),this.#a()}disconnected(){this.#r?.disconnect(),this.#r=null,this.#c(),this.#t?.removeEventListener("click",this.#n),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;#h(){let t=this.#g();t!==this.#l&&(this.#c(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#c(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#d(){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}}#u(){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.#x("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#f(){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.#x("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#p(){if(!this.#t)return;let t=this.#g();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#S()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#g();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 r=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(n=>n&&!n.startsWith("field-hint-")&&!n.startsWith("field-err-")),...e].join(" ").trim();r?t.setAttribute("aria-describedby",r):t.removeAttribute("aria-describedby")}#g(){let t=null,e=null;for(let i of this.children)if(!i.hasAttribute("slot")){if(t===null&&(t=i),s.#y.has(i.localName))return i;e===null&&this.#b(i)&&(e=i)}return e??t}static#y=new Set(["input-ui","textarea-ui","select-ui","combobox-ui","search-ui","check-ui","radio-ui","switch-ui","slider-ui","range-ui","otp-input-ui","tags-input-ui","chat-input-ui","autocomplete-input-ui","datetime-picker-ui","date-range-picker-ui","calendar-picker-ui","color-picker-ui","upload-ui","rating-ui","segmented-ui","input","textarea","select"]);#b(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#O=0;static#S(){return`field-ctl-${++s.#O}`}static#v=0;static#x(t){return`field-${t}-${++s.#v}`}};C();y("field-ui",On);$();var yn=class extends v{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),typeof MutationObserver<"u"&&(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}};C();y("fields-ui",yn);$();C();var Wy=0,za=class extends v{static properties={label:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},hint:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=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.insertBefore(this.#t,this.firstChild)),this.#t.id||(this.#t.id=`display-field-label-${++Wy}`),this.#e=this.querySelector(':scope > [slot="value"]'),this.#i=this.querySelector(':scope > [slot="hint"]'),this.#s=this.querySelector(':scope > icon-ui[slot="icon"]')}render(){if(!this.#t)return;this.label?(this.#t.textContent=this.label,this.#t.hidden=!1,this.setAttribute("aria-labelledby",this.#t.id)):(this.#t.hidden=!0,this.removeAttribute("aria-labelledby")),this.querySelector(":scope > :not([slot])")?this.#e&&(this.#e.remove(),this.#e=null):(this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","value"),this.appendChild(this.#e)),this.#e.textContent=this.value),this.hint?(this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","hint"),this.#i.id=`display-field-hint-${++Wy}`,this.appendChild(this.#i)),this.#i.textContent=this.hint,this.setAttribute("aria-describedby",this.#i.id)):this.#i&&(this.#i.remove(),this.#i=null,this.removeAttribute("aria-describedby")),this.icon?(this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.#s.setAttribute("aria-hidden","true"),this.appendChild(this.#s)),this.#s.setAttribute("name",this.icon)):this.#s&&(this.#s.remove(),this.#s=null)}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};y("display-field-ui",za);$();var vn=class extends v{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(tn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(tn),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,r=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!r?Pe.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",x$(Zt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",S$(Zt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",w$(Zt(i,o))):this.style.removeProperty("--row-justify"),r){let a=gs.indexOf(o),l=gs.indexOf(r);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},y$={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},v$={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function x$(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function S$(s){return y$[s]??s}function w$(s){return v$[s]??s}C();y("row-ui",vn);$();var xn=class extends v{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"},minColumnWidth:{type:String,default:"",reflect:!0,attribute:"min-column-width"}};static template=()=>null;render(){let t=Pe.value,e=this.columns;if(e?.includes("@")){let r=Zt(e,t);this.style.gridTemplateColumns=this.#t(r),this.style.gridAutoFlow=r?"row":"",this.style.gridAutoColumns=r?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";this.minColumnWidth?this.style.setProperty("--grid-min-col",this.minColumnWidth):this.style.removeProperty("--grid-min-col");let i=this.gap;if(i?.includes("@")){let r=Zt(i,t),n=this.#e(r);this.style.columnGap=n,this.style.rowGap=n}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(var(--grid-min-col, 12rem), 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(var(--grid-min-col, 12rem), 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};C();y("grid-ui",xn);$();var Sn=class extends v{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};C();y("stack-ui",Sn);$();var wn=class extends v{static properties={};static template=()=>null};C();y("frame-ui",wn);$();function Vi(s,t,e=5){let r=(t-s||1)/e,n=Math.pow(10,Math.floor(Math.log10(r))),o=r/n,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*n,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 Fy(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 ae(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function At({label:s,value:t,pct:e,series:i}){let r="";return s!=null&&(r+=` data-tip-label="${ae(String(s))}"`),t!=null&&(r+=` data-tip-value="${t}"`),e!=null&&(r+=` data-tip-pct="${e}"`),i!=null&&(r+=` data-tip-series="${ae(String(i))}"`),r}function le(s,t,e){return s+t*Math.cos(e)}function he(s,t,e){return s+t*Math.sin(e)}function A$(s,t,e,i,r){let n=le(s,e,i),o=he(t,e,i),a=le(s,e,r),l=he(t,e,r),h=r-i>Math.PI?1:0;return`M ${s} ${t} L ${n} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function pf(s,t,e,i,r,n,o=0){let a=(e-i)/2,l=n-r,h=Math.max(0,Math.min(o,a)),c=()=>{let ft=le(s,e,r),lt=he(t,e,r),yt=le(s,e,n),wt=he(t,e,n),vt=le(s,i,n),$t=he(t,i,n),Mt=le(s,i,r),Ht=he(t,i,r),us=l>Math.PI?1:0;return`M ${ft} ${lt} A ${e} ${e} 0 ${us} 1 ${yt} ${wt} L ${vt} ${$t} A ${i} ${i} 0 ${us} 0 ${Mt} ${Ht} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=r+u,p=n-u,m=r+d,b=n-d,g=p-f>Math.PI?1:0,x=le(s,e,f),S=he(t,e,f),w=le(s,e,p),A=he(t,e,p),k=le(s,i,b),E=he(t,i,b),P=le(s,i,m),L=he(t,i,m),T=le(s,e-h,r),q=he(t,e-h,r),I=le(s,i+h,r),z=he(t,i+h,r),V=le(s,e-h,n),U=he(t,e-h,n),tt=le(s,i+h,n),nt=he(t,i+h,n);return`M ${x} ${S} A ${e} ${e} 0 ${g} 1 ${w} ${A} A ${h} ${h} 0 0 1 ${V} ${U} L ${tt} ${nt} A ${h} ${h} 0 0 1 ${k} ${E} A ${i} ${i} 0 ${g} 0 ${P} ${L} A ${h} ${h} 0 0 1 ${I} ${z} L ${T} ${q} A ${h} ${h} 0 0 1 ${x} ${S} Z`}function _a(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(r=>`${r.x},${r.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let r=0;r<e-1;r++){let n=s[Math.max(r-1,0)],o=s[r],a=s[r+1],l=s[Math.min(r+2,e-1)],h=o.x+(a.x-n.x)*t/3,c=o.y+(a.y-n.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 mf(s,t,e=.4){let i=_a(s,e),r=s[s.length-1],n=s[0];return`${i} L${r.x},${t} L${n.x},${t} Z`}function jh(s,t,e,i,r=0){if(i<=0||e<=0)return"";let n=Math.max(0,Math.min(r,e/2,i));return n===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+n} Q${s},${t} ${s+n},${t} H${s+e-n} Q${s+e},${t} ${s+e},${t+n} V${t+i} Z`}var k$={std:{ratio:4/3}},An=class extends v{static properties={type:{type:String,default:"bar",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},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},dots:{type:String,default:"all",reflect:!0},seriesEmphasis:{type:String,default:"",reflect:!0,attribute:"series-emphasis"}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#r=0;#n=0;#a=new Set;#o=null;#l(){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.
217
217
  Correct shape for <chart-ui x="label" y="value">:
218
218
  [{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#c(),this.#p()}get data(){return this.#t}#h=!1;#c(){if(this.#h)return;let t=this.#d();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.#h=!0)}#d(){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.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.#S),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#M),this.addEventListener("focus",this.#$),this.addEventListener("blur",this.#I),this.addEventListener("pointerover",this.#Q),this.addEventListener("pointermove",this.#P),this.addEventListener("pointerleave",this.#N),this.addEventListener("pointerdown",this.#Z),this.addEventListener("click",this.#V),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let r=Math.round(e),n=Math.round(i);r===this.#r&&(!this.hasAttribute("resize")||n===this.#n)||(this.#r=r,this.#n=n,!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=k$.std,r=this.#t.length||1,n=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(n/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(n,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,b=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!b||p?2:u*2.2,left:m},x=n-g.left-g.right,S=Math.max(4,x/r*.6);return{width:n,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:S,plotW:x,n:r,sizeClass:c}}#f=null;#p(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#f&&(this.#f=t.cloneNode(!0)),this.innerHTML="",this.#f&&this.appendChild(this.#f.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}this.setAttribute("data-has-data",""),this.#o=null;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 r="",n="";switch(this.type){case"bar":({svg:r,viewBox:n}=this.#tt());break;case"line":({svg:r,viewBox:n}=this.#et());break;case"pie":({svg:r,viewBox:n}=this.#it());break;case"donut":({svg:r,viewBox:n}=this.#st());break;case"radar":({svg:r,viewBox:n}=this.#rt());break;case"sparkline":({svg:r,viewBox:n}=this.#K());break;case"segments":({svg:r,viewBox:n}=this.#dt());break;case"area":({svg:r,viewBox:n}=this.#W());break;case"scatter":({svg:r,viewBox:n}=this.#nt());break;case"radial-bar":({svg:r,viewBox:n}=this.#ot());break;case"gauge":({svg:r,viewBox:n}=this.#at());break;case"funnel":({svg:r,viewBox:n}=this.#lt());break;case"treemap":({svg:r,viewBox:n}=this.#ht());break;case"sankey":({svg:r,viewBox:n}=this.#ct());break;case"composed":({svg:r,viewBox:n}=this.#ut());break;case"stacked-bar":({svg:r,viewBox:n}=this.#ft());break;case"grouped-bar":({svg:r,viewBox:n}=this.#pt());break;case"multi-line":({svg:r,viewBox:n}=this.#mt());break;default:({svg:r,viewBox:n}=this.#tt());break}if(i.setAttribute("viewBox",n),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=r,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#b()){let o=this.#gt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#m(t,e){return e?` data-slice="${t}" data-series-key="${ae(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g(t,e){return e?` data-slice="${t}" data-series-key="${ae(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#y=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#S),document.removeEventListener("pointerdown",this.#D),this.removeEventListener("keydown",this.#M),this.removeEventListener("focus",this.#$),this.removeEventListener("blur",this.#I),this.removeEventListener("pointerover",this.#Q),this.removeEventListener("pointermove",this.#P),this.removeEventListener("pointerleave",this.#N),this.removeEventListener("pointerdown",this.#Z),this.removeEventListener("click",this.#V),this.#G()}#b(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#O(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#S=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:r}=t.detail||{};i&&(r?this.#a.delete(i):this.#a.add(i),this.#p())};#v(t){return!!t&&this.#a.has(t)}#x(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 r=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),`${r||"$"}${Fy(e)}`}default:return Fy(e)}}#w=-1;#A(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#k(t){let e=this.#A();if(!e.length){this.#C();return}this.#w=Math.max(0,Math.min(t,e.length-1)),this.#E(),this.#T()}#E(){let t=this.#A();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#w];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#C(){this.#w=-1;for(let t of this.#A())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#T(){let t=this.#A()[this.#w];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#X(t,i)}#L(){let t=this.#A()[this.#w];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.#U(t,i)}))}#$=()=>{this.#w===-1&&this.#k(0)};#I=()=>{this.#C(),this.#R&&this.#q()};#M=t=>{let e=this.#A();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#k(this.#w+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#k(Math.max(0,this.#w-1));break;case"Home":t.preventDefault(),this.#k(0);break;case"End":t.preventDefault(),this.#k(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#L();break;case"Escape":t.preventDefault(),this.#C(),this.#R&&this.#q();break}};#R=null;#Q=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#Y(e,t),this.#X(e,t))};#P=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#R&&this.#q(),this.#G();this.#Y(e,t),e!==this.#R&&this.#X(e,t)};#N=t=>{t&&t.pointerType==="touch"||(this.#G(),this.#R&&this.#q())};#Z=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#R&&this.#q(),this.#G();this.#Y(e,t),e!==this.#R&&this.#X(e,t),document.addEventListener("pointerdown",this.#D)};#D=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#G(),this.#R&&this.#q(),document.removeEventListener("pointerdown",this.#D)))};#V=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#U(e,t)}))};#X(t,e){this.#R=t,this.dots==="hover"&&this.#F(t),this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#U(t,e)}))}#q(){this.#R=null,this.dots==="hover"&&this.#z(),this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#F(t){let e=t?.previousElementSibling;this.#o&&this.#o!==e&&this.#o.removeAttribute("data-dot-active"),e&&e.hasAttribute("data-dot")?(e.setAttribute("data-dot-active",""),this.#o=e):this.#o=null}#z(){this.#o&&this.#o.removeAttribute("data-dot-active"),this.#o=null}#U(t,e){let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=r!=null?Number(r):null,h=n!=null?Number(n):null,c=i??null,u=o??null,d=this.#j(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:r??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:r??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#j(t,e){if(t==null)return null;let i=this.x,r=this.#B();if(!i||r.length===0)return null;let n=this.#t.find(l=>String(l[i]??"")===String(t));if(!n)return null;let o=r.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(n[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#Y(t,e){if(this.#O())return;let{tipLabel:i,tipValue:r,tipPct:n,tipSeries:o}=t.dataset;if(!this.#y){let b=document.createElement("div");b.setAttribute("popover","manual"),b.setAttribute("role","tooltip"),b.classList.add("chart-tooltip-popup"),document.body.appendChild(b),this.#y=b}let a=[];if(o&&a.push(`<span data-tip-role="series">${ae(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ae(i)}</span>`),r!==void 0){let b=n!==void 0?` <span data-tip-role="pct">(${n}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#x(r)}${b}</span>`)}this.#y.innerHTML=a.join("");try{this.#y.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#y.offsetWidth||0,f=this.#y.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.#y.style.left=`${p}px`,this.#y.style.top=`${m}px`}#G(){if(this.#y){try{this.#y.hidePopover()}catch{}this.#y.remove(),this.#y=null}}#B(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#J(t,e){switch(this.dots){case"none":return!1;case"last":return t===e-1;default:return!0}}#H(t,e,i,r,n,o){let a=n,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.#x(p)}</text>`}if(r){let m=(t-a.left-a.right)/r.length,g=r.reduce((w,A)=>Math.max(w,String(A).length),1)*h*.6+h*.75,x=Math.max(1,Math.ceil(g/m)),S=r.length-1;for(let w=0;w<r.length;w++){if(w%x!==0&&w!==S||w!==S&&S-w<x)continue;let A=a.left+m*w+m/2;c+=`<text data-x-label x="${A}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${ae(r[w])}</text>`}}}return c}#tt(){let t=this.#u(),e=this.#t,i=this.#B()[0]||this.y,r=e.map(S=>+(S[i]??0)),n=e.map(S=>S[this.x]??""),o=Vi(0,Math.max(...r),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,b=this.#H(l,h,o,n,c,t),g=!this.hideValues&&t.sizeClass!=="sm",x=!this.hideAverage&&r.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let S=0;S<e.length;S++){let w=r[S],A=a?w/a*u:0,k=c.left+f*S+m,E=c.top+u-A;b+=`<path data-bar${At({label:n[S],value:w})} d="${jh(k,E,p,A,this.#l())}"/>`,g&&(b+=`<text data-value x="${k+p/2}" y="${E-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(w)}</text>`)}if(x){let S=r.reduce((A,k)=>A+k,0)/r.length,w=c.top+u-(a?S/a*u:0);b+=`<line data-avg x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}"/>`,b+=`<text data-avg-label x="${l-c.right+2}" y="${w+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(S)}</text>`,b+=`<line data-hit${At({label:"Average",value:S})} x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}" stroke="transparent" stroke-width="12"/>`}return{svg:b,viewBox:`0 0 ${l} ${h}`}}#et(){let t=this.#u(),e=this.#t,i=this.#B()[0]||this.y,r=e.map(E=>+(E[i]??0)),n=e.map(E=>E[this.x]??""),o=Vi(0,Math.max(...r),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.#H(l,h,o,n,c,t),m=r.map((E,P)=>{let L=c.left+f*P,T=c.top+u-(a?E/a*u:0);return{x:L,y:T,v:E,label:n[P]}}),b=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${mf(m,b,g)}"/>`,p+=`<path data-line d="${_a(m,g)}"/>`;let x=t.sizeClass==="sm",S=x?1.5:3,w=Math.max(S,10),A=!this.hideValues&&!x,k=!this.hideAverage&&r.length>1&&!x&&!this.hideGrid;if(m.forEach((E,P)=>{this.#J(P,m.length)&&(p+=`<circle data-dot cx="${E.x}" cy="${E.y}" r="${S}"/>`),p+=`<circle data-hit${At({label:E.label,value:E.v})} cx="${E.x}" cy="${E.y}" r="${w}" fill="transparent"/>`,A&&(p+=`<text data-value x="${E.x}" y="${E.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(E.v)}</text>`)}),k){let E=r.reduce((L,T)=>L+T,0)/r.length,P=c.top+u-(a?E/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.#x(E)}</text>`,p+=`<line data-hit${At({label:"Average",value:E})} x1="${c.left}" y1="${P}" x2="${l-c.right}" y2="${P}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#it(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(p=>+(p[e]??0)),r=i.reduce((p,m)=>p+m,0)||1,n=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]/r*Math.PI*2;if(m===0)continue;let b=f+m,g=(i[p]/r*100).toFixed(1),x=` data-slice="${p%10}"${At({label:n[p],value:i[p],pct:g})}`;Math.abs(m-Math.PI*2)<.001?d+=`<circle${x} cx="${h}" cy="${c}" r="${u}"/>`:d+=`<path${x} d="${A$(h,c,u,f,b)}"/>`,f=b}return this.#_=t.map((p,m)=>({label:n[m],value:i[m],pct:(i[m]/r*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#st(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=i.reduce((g,x)=>g+x,0)||1,n=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 x=i[g]/r*Math.PI*2;if(x===0)continue;let S=p+x,w=(i[g]/r*100).toFixed(1),A=` data-slice="${g%10}"${At({label:n[g],value:i[g],pct:w})}`;Math.abs(x-Math.PI*2)<.001?(f+=`<circle${A} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${A} 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${A} d="${pf(h,c,u,d,p,S,this.#l())}"/>`,p=S}let m=Math.max(14,Math.round(u*.32)),b=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.#x(r)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${b}">Total</text>`,this.#_=t.map((g,x)=>({label:n[x],value:i[x],pct:(i[x]/r*100).toFixed(1),slot:x%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#rt(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(A=>+(A[e]??0)),r=t.map(A=>A[this.x]??""),n=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="",b=Math.PI*2/o;for(let A=1;A<=3;A++){let k=p*A/3,E="";for(let P=0;P<o;P++){let L=-Math.PI/2+b*P,T=u+k*Math.cos(L),q=d+k*Math.sin(L);E+=(P===0?"M":"L")+` ${T} ${q}`}E+=" Z",m+=`<path data-grid d="${E}"/>`}for(let A=0;A<o;A++){let k=-Math.PI/2+b*A,E=u+p*Math.cos(k),P=d+p*Math.sin(k);m+=`<line data-grid x1="${u}" y1="${d}" x2="${E}" y2="${P}"/>`}let g="",x=[];for(let A=0;A<o;A++){let k=-Math.PI/2+b*A,E=i[A]/n*p,P=u+E*Math.cos(k),L=d+E*Math.sin(k);g+=(A===0?"M":"L")+` ${P} ${L}`,x.push({px:P,py:L})}g+=" Z",m+=`<path data-radar-fill d="${g}"/>`,m+=`<path data-radar-line d="${g}"/>`;let S=Math.max(c,10);for(let A=0;A<o;A++){let{px:k,py:E}=x[A];m+=`<circle data-hit${At({label:r[A],value:i[A]})} cx="${k}" cy="${E}" r="${S}" fill="transparent"/>`}let w=c*1.3;for(let A=0;A<o;A++){let k=-Math.PI/2+b*A,E=u+(p+w)*Math.cos(k),P=d+(p+w)*Math.sin(k),L=Math.abs(Math.cos(k))<.1?"middle":Math.cos(k)>0?"start":"end";m+=`<text data-x-label x="${E}" y="${P}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${ae(r[A])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#K(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=Vi(0,Math.max(...i),5),n=r[r.length-1],o=this.clientWidth||120,a=this.clientHeight||32,l=Math.max(40,o),h=Math.max(16,a),c=l/Math.max(i.length-1,1),u=Math.max(2,Math.min(6,h*.1)),d=t.map(g=>g[this.x]??""),f=i.map((g,x)=>({x:c*x,y:h-(n?g/n*(h-u*2):0)-u,v:g,label:d[x]})),p=Math.max(0,Math.min(1,this.smooth)),m="";m+=`<path data-area d="${mf(f,h,p)}"/>`,m+=`<path data-line d="${_a(f,p)}"/>`;let b=Math.max(c/2,6);for(let g of f)m+=`<circle data-hit${At({label:g.label,value:g.v})} cx="${g.x}" cy="${g.y}" r="${b}" fill="transparent"/>`;return{svg:m,viewBox:`0 0 ${l} ${h}`}}#W(){return this.#et()}#nt(){let t=this.#u(),e=this.#t,i=this.#B()[0]||this.y,r=e.map(g=>+(g[i]??0)),n=e.map(g=>g[this.x]??""),o=Vi(0,Math.max(...r),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.#H(l,h,o,n,c,t),m=t.sizeClass==="sm"?2.5:4,b=Math.max(m*2,10);for(let g=0;g<r.length;g++){let x=c.left+f*g,S=c.top+u-(a?r[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${x}" cy="${S}" r="${m}"/>`,p+=`<circle data-hit${At({label:n[g],value:r[g]})} cx="${x}" cy="${S}" r="${b}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#ot(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(g=>+(g[e]??0)),r=t.map(g=>g[this.x]??""),n=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),b="";for(let g=0;g<i.length;g++){let x=d+p*g+m/2,S=d+p*(g+1)-m/2,w=(x+S)/2,A=S-x,k=2*Math.PI*w,E=Math.max(0,Math.min(1,i[g]/n))*k;if(b+=`<circle data-radial-track cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${A}"/>`,E<=0)continue;let P=(i[g]/n*100).toFixed(1),L=At({label:r[g],value:i[g],pct:P}),T=Math.abs(E-k)<.5,q=T?"butt":"round",I=T?`${k} 0`:`${E} ${k-E}`;b+=`<circle data-slice="${g%10}"${L} data-radial-bar cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${A}" stroke-linecap="${q}" stroke-dasharray="${I}" transform="rotate(-90 ${h} ${c})"/>`}return this.#_=t.map((g,x)=>({label:r[x],key:r[x],value:i[x],pct:(i[x]/n*100).toFixed(1),slot:x%10})),{svg:b,viewBox:`0 0 ${a} ${l}`}}#at(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(w=>+(w[e]??0)),r=i.reduce((w,A)=>w+A,0)||1,n=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(n,1):r,a=Math.max(0,Math.min(1,n/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,b="";if(b+=`<path data-radial-track d="${pf(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let w=Math.PI+Math.PI*a,A=At({label:t[0]?.[this.x]??"Value",value:n,pct:(a*100).toFixed(1)});b+=`<path data-slice="0"${A} data-gauge-fill d="${pf(u,d,f,p,Math.PI,w,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),x=Math.max(10,Math.round(f*.2)),S=d-f*.15;return b+=`<text data-gauge-value x="${u}" y="${S}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#x(n)}</text>`,o!==n&&(b+=`<text data-gauge-max x="${u}" y="${S+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${x}">of ${this.#x(o)}</text>`),{svg:b,viewBox:`0 0 ${h} ${c}`}}#lt(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(S=>+(S[e]??0)),r=t.map(S=>S[this.x]??""),n=i.length;if(n===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)/n,b=Math.max(2,m*.08),g=l/2,x="";for(let S=0;S<n;S++){let w=i[S],A=S<n-1?i[S+1]:i[S],k=w/o*(f/2),E=A/o*(f/2),P=d+m*S+b/2,L=d+m*(S+1)-b/2,T=(w/o*100).toFixed(1),q=At({label:r[S],value:w,pct:T}),I=`M ${g-k} ${P} L ${g+k} ${P} L ${g+E} ${L} L ${g-E} ${L} Z`;if(x+=`<path data-slice="${S%10}" data-funnel-stage${q} d="${I}"/>`,x+=`<text data-funnel-label x="${u-8}" y="${P+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ae(r[S])}</text>`,x+=`<text data-funnel-value x="${l-u+8}" y="${P+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#x(w)}</text>`,S>0){let z=(i[S]/i[0]*100).toFixed(0);x+=`<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}">${z}%</text>`}}return this.#_=t.map((S,w)=>({label:r[w],value:i[w],pct:(i[w]/o*100).toFixed(1),slot:w%10})),{svg:x,viewBox:`0 0 ${l} ${h}`}}#ht(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(T=>+(T[e]??0)),r=t.map(T=>T[this.x]??""),n=i.length;if(n===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#u(),{width:a,height:l,fontSize:h}=o,c=i.reduce((T,q)=>T+q,0)||1,u=Array.from({length:n},(T,q)=>q).sort((T,q)=>i[q]-i[T]),d=[],f=a*l,p=u.map(T=>i[T]/c*f),m=0,b=0,g=a,x=l,S=[],w=0,A=(T,q)=>{if(T.length===0)return 1/0;let I=T.reduce((nt,ft)=>nt+ft,0),z=Math.max(...T),V=Math.min(...T),U=q*q,tt=I*I;return Math.max(U*z/tt,tt/(U*V))},k=(T,q,I,z,V,U)=>{let tt=T.reduce((wt,vt)=>wt+vt,0),nt=V>=U,ft=nt?tt/V:U,lt=nt?V:tt/U,yt=0;for(let wt=0;wt<T.length;wt++){let vt=T[wt]/tt,$t=u[q+wt];if(nt){let Mt=vt*V;d.push({i:$t,x:I+yt,y:z,w:Mt,h:ft}),yt+=Mt}else{let Mt=vt*U;d.push({i:$t,x:I,y:z+yt,w:lt,h:Mt}),yt+=Mt}}return nt?{x:I,y:z+ft,w:V,h:U-ft}:{x:I+lt,y:z,w:V-lt,h:U}},E=p.slice();for(;E.length>0;){S=[E[0]],w=p.length-E.length;let T=Math.min(g,x),q=1;for(;q<E.length;){let z=S.concat(E[q]);if(A(z,T)>A(S,T))break;S=z,q++}let I=k(S,w,m,b,g,x);m=I.x,b=I.y,g=I.w,x=I.h,E=E.slice(S.length)}let P="",L=2;for(let T of d){let q=(i[T.i]/c*100).toFixed(1),I=At({label:r[T.i],value:i[T.i],pct:q});P+=`<rect data-slice="${T.i%10}" data-treemap-tile${I} x="${T.x+L}" y="${T.y+L}" width="${Math.max(0,T.w-L*2)}" height="${Math.max(0,T.h-L*2)}" rx="${this.#l()}"/>`;let z=T.x+8,V=T.w>h*4,U=V&&T.h>h*2.5,tt=V&&!U&&T.h>h*1.2;if(U)P+=`<text data-treemap-label x="${z}" y="${T.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ae(r[T.i])}</text>`,P+=`<text data-treemap-value x="${z}" y="${T.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#x(i[T.i])}</text>`;else if(tt){let nt=T.y+T.h/2;P+=`<text data-treemap-label x="${z}" y="${nt}" font-size="${h}" dominant-baseline="central">${ae(r[T.i])}</text>`}}return this.#_=t.map((T,q)=>({label:r[q],value:i[q],pct:(i[q]/c*100).toFixed(1),slot:q%10})),{svg:P,viewBox:`0 0 ${a} ${l}`}}#ct(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let w of t){let A=w.source??w.from??"",k=w.target??w.to??"",E=+(w.value??w.v??0);e.has(A)||e.set(A,{name:A,flow:0}),i.has(k)||i.set(k,{name:k,flow:0}),e.get(A).flow+=E,i.get(k).flow+=E}let r=this.#u(),{width:n,height:o,fontSize:a}=r,l=Math.max(8,n*.03),h=l+a*5,c=[...e.values()].reduce((w,A)=>w+A.flow,0)||1,u=[...i.values()].reduce((w,A)=>w+A.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),b=o-d*(p.length-1),g=0;for(let w of f){let A=w.flow/c*m;w.y0=g,w.y1=g+A,w.cursor=g,g+=A+d}g=0;for(let w of p){let A=w.flow/u*b;w.y0=g,w.y1=g+A,w.cursor=g,g+=A+d}let x="",S=Math.min(this.#l(),l/2);f.forEach((w,A)=>{x+=`<rect data-sankey-node data-slice="${A%10}" x="${h-l}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${S}"/>`,x+=`<text data-sankey-label x="${h-l-6}" y="${(w.y0+w.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${ae(w.name)}</text>`}),p.forEach((w,A)=>{x+=`<rect data-sankey-node data-slice="${(f.length+A)%10}" x="${n-h}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${S}"/>`,x+=`<text data-sankey-label x="${n-h+l+6}" y="${(w.y0+w.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${ae(w.name)}</text>`});for(let w of t){let A=e.get(w.source??w.from??""),k=i.get(w.target??w.to??"");if(!A||!k)continue;let E=+(w.value??w.v??0);if(E<=0)continue;let P=E/c*m,L=E/u*b,T=A.cursor,q=T+P,I=k.cursor,z=I+L;A.cursor+=P,k.cursor+=L;let V=h,U=n-h,tt=(V+U)/2,nt=At({label:`${A.name} \u2192 ${k.name}`,value:E}),ft=`M ${V} ${T} C ${tt} ${T}, ${tt} ${I}, ${U} ${I} L ${U} ${z} C ${tt} ${z}, ${tt} ${q}, ${V} ${q} Z`;x+=`<path data-sankey-link${nt} d="${ft}"/>`}return{svg:x,viewBox:`0 0 ${n} ${o}`}}#ut(){let t=this.#u(),e=this.#t,i=this.#B(),r=i[0]||"bar",n=i[1]||"line",o=e.map(k=>k[this.x]??""),a=e.map(k=>+(k[r]??0)),l=e.map(k=>+(k[n]??0)),h=[...a,...l],c=Vi(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,b=d-p.left-p.right,g=b/e.length,x=g*.6,S=(g-x)/2,w=b/Math.max(e.length-1,1),A=this.#H(d,f,c,o,p,t);if(!this.#v(r))for(let k=0;k<e.length;k++){let E=a[k],P=u?E/u*m:0,L=p.left+g*k+S,T=p.top+m-P;A+=`<path${this.#m(0,r)}${At({label:o[k],value:E,series:r})} d="${jh(L,T,x,P,this.#l())}"/>`}if(!this.#v(n)){let k=l.map((P,L)=>({x:p.left+g*L+g/2,y:p.top+m-(u?P/u*m:0),v:P,label:o[L]})),E=Math.max(0,Math.min(1,this.smooth));A+=`<path data-line${this.#g(1,n)} d="${_a(k,E)}"/>`;for(let P of k)A+=`<circle data-dot${this.#m(1,n)} cx="${P.x}" cy="${P.y}" r="3"/>`,A+=`<circle data-hit${At({label:P.label,value:P.v,series:n})} cx="${P.x}" cy="${P.y}" r="10" fill="transparent"/>`}return this.#_=[{label:r,key:r,slot:0},{label:n,key:n,slot:1}],{svg:A,viewBox:`0 0 ${d} ${f}`}}#dt(){let t=this.#t,e=this.#B()[0]||this.y,i=t.map(p=>+(p[e]??0)),r=i.reduce((p,m)=>p+m,0)||1,n=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#l(),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*r+i[p]*a)/r),b=p===i.length-1?a:i.slice(0,p+1).reduce((x,S)=>x+S,0)/r*a,g=p===0?0:i.slice(0,p).reduce((x,S)=>x+S,0)/r*a;u.push({x:g,w:Math.max(0,b-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:b}=u[p];if(b<=0)continue;let g=p===0,x=p===u.length-1,S=Math.max(0,b-(x?0:c)),w=(i[p]/r*100).toFixed(1),A=At({label:n[p],value:i[p],pct:w}),k=`<title>${ae(n[p])}: ${i[p]} (${w}%)</title>`;if(g&&x||!g&&!x||h===0)f+=`<rect data-slice="${p%10}"${A} x="${m}" y="0" width="${S}" height="${l}"${(g||x)&&h?` rx="${h}"`:""}>${k}</rect>`;else{let E=h,P=m+S,L;g?L=`M ${m+E} 0 H ${P} V ${l} H ${m+E} A ${E} ${E} 0 0 1 ${m} ${l-E} V ${E} A ${E} ${E} 0 0 1 ${m+E} 0 Z`:L=`M ${m} 0 H ${P-E} A ${E} ${E} 0 0 1 ${P} ${E} V ${l-E} A ${E} ${E} 0 0 1 ${P-E} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${A} d="${L}">${k}</path>`}}return this.#_=t.map((p,m)=>({label:n[m],value:i[m],pct:(i[m]/r*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#ft(){let t=this.#t,e=this.#B(),i=t.map(g=>g[this.x]??""),r=t.map(g=>e.reduce((x,S)=>x+ +(g[S]??0),0)),n=Vi(0,Math.max(...r),5),o=n[n.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,b=this.#H(l,h,n,i,c,a);for(let g=0;g<t.length;g++){let x=c.top+u,S=e.length;for(let w=0;w<S;w++){if(this.#v(e[w]))continue;let A=+(t[g][e[w]]??0),k=o?A/o*u:0;if(k<=0){x-=k;continue}x-=k;let E=c.left+f*g+m,P=x,L=k,T=w===S-1,q=this.#l(),I=`${this.#m(w%10,e[w])}${At({label:i[g],value:A,series:e[w]})}`;T?b+=`<path${I} d="${jh(E,P,p,L,q)}"/>`:b+=`<rect${I} x="${E}" y="${P}" width="${p}" height="${L}"/>`}}return this.#_=e.map((g,x)=>({label:g,key:g,slot:x%10})),{svg:b,viewBox:`0 0 ${l} ${h}`}}#pt(){let t=this.#t,e=this.#B(),i=t.map(S=>S[this.x]??""),r=t.flatMap(S=>e.map(w=>+(S[w]??0))),n=Vi(0,Math.max(...r),5),o=n[n.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,b=(m-p*(e.length-1))/e.length,g=(f-m)/2,x=this.#H(l,h,n,i,c,a);for(let S=0;S<t.length;S++)for(let w=0;w<e.length;w++){if(this.#v(e[w]))continue;let A=+(t[S][e[w]]??0),k=o?A/o*u:0,E=c.left+f*S+g+(b+p)*w,P=c.top+u-k;x+=`<path${this.#m(w%10,e[w])}${At({label:i[S],value:A,series:e[w]})} d="${jh(E,P,b,k,this.#l())}"/>`,this.hideValues||(x+=`<text data-value x="${E+b/2}" y="${P-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#x(A)}</text>`)}return this.#_=e.map((S,w)=>({label:S,key:S,slot:w%10})),{svg:x,viewBox:`0 0 ${l} ${h}`}}#mt(){let t=this.#t,e=this.#B(),i=t.map(m=>m[this.x]??""),r=t.flatMap(m=>e.map(b=>+(m[b]??0))),n=Vi(0,Math.max(...r),5),o=n[n.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.#H(l,h,n,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(E=>+(E[e[m]]??0)).map((E,P)=>{let L=c.left+f*P,T=c.top+u-(o?E/o*u:0);return{x:L,y:T,v:E,label:i[P]}}),x=c.top+u,S=Math.max(0,Math.min(1,this.smooth)),w=this.seriesEmphasis,A=!w||e[m]===w,k=A?"":" data-deemphasized";A&&(p+=`<path data-area${this.#m(m%10,e[m])} d="${mf(g,x,S)}"/>`),p+=`<path data-line${this.#g(m%10,e[m])}${k} d="${_a(g,S)}"/>`,g.forEach((E,P)=>{this.#J(P,g.length)&&(p+=`<circle data-dot${this.#m(m%10,e[m])}${k} cx="${E.x}" cy="${E.y}" r="3"/>`),p+=`<circle data-hit${At({label:E.label,value:E.v,series:e[m]})} cx="${E.x}" cy="${E.y}" r="10" fill="transparent"/>`})}return this.#_=e.map((m,b)=>({label:m,key:m,slot:b%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#_=null;get legendData(){return this.#_?this.#_.map(t=>({...t})):null}#gt(){if(!this.#_||!this.#_.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#_){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let r=document.createElement("span");r.setAttribute("data-legend-dot",""),r.setAttribute("data-slice",String(e.slot)),e.key&&(r.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(r);let n=document.createElement("span");n.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(n),t.appendChild(i)}return t}};C();y("chart-ui",An);$();var kn=class s extends v{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.#r()}render(){this.#s(),this.#a()}#s(){if(this.#r(),!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)}#r(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#n(){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.#n();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",r=e.label??i,n=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",r),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-${n}))`:`var(--a-data-${n})`;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 r=!!this.#i.has(e);r?this.#i.delete(e):this.#i.add(e);let n=t.currentTarget;r?n.setAttribute("data-active",""):n.removeAttribute("data-active"),n.setAttribute("aria-pressed",r?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:r,mode:this.onToggle||"hide"}}))}};C();y("chart-legend-ui",kn);$();var E$=120,En=class extends v{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},matchWidth:{type:Boolean,default:!1,reflect:!0,attribute:"match-width"}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#r=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#u),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#c),this.addEventListener("pointerleave",this.#d),t&&(t.addEventListener("pointerenter",this.#c),t.addEventListener("pointerleave",this.#d))))}render(){this.open?this.#n():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#n(){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,matchWidth:this.matchWidth}),(this.trigger==="click"||this.trigger==="manual")&&(this.#r=requestAnimationFrame(()=>{this.#r=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#h)}))}}#a(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#h)}#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)};#h=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#c=()=>{clearTimeout(this.#i),this.open=!0};#d=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},E$)};#u=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.#c),this.removeEventListener("pointerleave",this.#d),this.#s&&(this.#s.removeEventListener("pointerenter",this.#c),this.#s.removeEventListener("pointerleave",this.#d))),this.#s?.removeEventListener("toggle",this.#u),this.#s=null,this.#e=!1}};C();y("popover-ui",En);$();var Cn=class extends v{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0},variant:{type:String,default:"flat",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 r of i)r!==e&&r.open&&(r.open=!1)}},$n=class extends v{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},variant:{type:String,default:"flat",reflect:!0}};static template=()=>null;#t=!1;connected(){let t=this.querySelector('[slot="header"]');if(t){if(!t.querySelector('[slot="caret"]')){let e=document.createElement("icon-ui");e.setAttribute("name","caret-down"),e.setAttribute("slot","caret"),t.appendChild(e)}}else{let e=document.createElement("div");e.setAttribute("slot","header"),e.setAttribute("tabindex","0"),e.setAttribute("role","button"),e.setAttribute("aria-expanded","false"),e.dataset.autofocusable="";let i=document.createElement("span");i.setAttribute("slot","header-text"),i.dataset.autolabel="",e.appendChild(i);let r=document.createElement("icon-ui");r.setAttribute("name","caret-down"),r.setAttribute("slot","caret"),e.appendChild(r),this.prepend(e)}if(!this.querySelector('[slot="body"]')){let e=document.createElement("div");e.setAttribute("slot","body");let i=[...this.childNodes].filter(r=>r.nodeType===1?!r.hasAttribute("slot"):r.nodeType===3&&r.textContent.trim());for(let r of i)e.appendChild(r);this.appendChild(e)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i))}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"][data-autolabel]');t&&(t.textContent=this.text);let e=this.querySelector('[slot="header"][data-autofocusable]');e&&e.setAttribute("aria-expanded",String(this.open))}#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}})))};#i=t=>{let e=this.querySelector('[slot="header"][data-autofocusable]');!e||t.target!==e||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),e.click())}};C();y("accordion-ui",Cn),y("accordion-item-ui",$n);$();var Pn=class extends v{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()}}};C();y("divider-ui",Pn);$();var Qn=class extends v{static properties={cite:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","blockquote")}render(){let t=this.querySelector('[slot="cite"]:not([data-cite-stamped])'),e=this.querySelector('[slot="cite"][data-cite-stamped]');if(t){e?.remove();return}if(this.cite)if(e)e.textContent=this.cite;else{let i=document.createElement("span");i.setAttribute("slot","cite"),i.setAttribute("data-cite-stamped",""),i.textContent=this.cite,this.appendChild(i)}else e&&e.remove()}};C();y("blockquote-ui",Qn);$();var gf=[{limit:60,unit:"second",divisor:1},{limit:3600,unit:"minute",divisor:60},{limit:3600*24,unit:"hour",divisor:3600},{limit:3600*24*7,unit:"day",divisor:3600*24},{limit:3600*24*30,unit:"week",divisor:3600*24*7},{limit:3600*24*365,unit:"month",divisor:3600*24*30},{limit:1/0,unit:"year",divisor:3600*24*365}],Tn=class extends v{static properties={datetime:{type:String,default:"",reflect:!0},timeStyle:{type:String,default:"long",reflect:!0,attribute:"time-style"},numeric:{type:String,default:"auto",reflect:!0},locale:{type:String,default:"",reflect:!0},updateInterval:{type:Number,default:60,reflect:!0,attribute:"update-interval"}};static template=()=>null;#t=null;#e(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#i(){if(!this.datetime)return"";let t=new Date(this.datetime);if(Number.isNaN(t.getTime()))return"";let e=(t.getTime()-Date.now())/1e3,i=Math.abs(e),r=gf.find(o=>i<=o.limit)||gf[gf.length-1],n=Math.round(e/r.divisor);try{return new Intl.RelativeTimeFormat(this.#e(),{style:this.timeStyle,numeric:this.numeric}).format(n,r.unit)}catch{let o=e<0,a=Math.abs(n);return o?`${a} ${r.unit}${a===1?"":"s"} ago`:`in ${a} ${r.unit}${a===1?"":"s"}`}}#s(){if(!this.datetime)return"";let t=new Date(this.datetime);if(Number.isNaN(t.getTime()))return"";try{return new Intl.DateTimeFormat(this.#e(),{dateStyle:"full",timeStyle:"long"}).format(t)}catch{return t.toString()}}connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","time"),this.#r()}render(){let t=this.#i();this.textContent=t,t&&!this.hasAttribute("data-suppress-title")&&this.setAttribute("title",this.#s()),this.datetime&&this.setAttribute("datetime",this.datetime),this.#r()}#r(){this.#n();let t=Number(this.updateInterval);!Number.isFinite(t)||t<=0||(this.#t=setInterval(()=>{this.textContent=this.#i()},t*1e3))}#n(){this.#t!=null&&(clearInterval(this.#t),this.#t=null)}disconnected(){super.disconnected(),this.#n()}};C();y("relative-time-ui",Tn);$();var Ln=class extends v{static properties={value:{type:Number,default:0,reflect:!0},numberStyle:{type:String,default:"decimal",reflect:!0,attribute:"number-style"},currency:{type:String,default:"",reflect:!0},unit:{type:String,default:"",reflect:!0},notation:{type:String,default:"standard",reflect:!0},compactDisplay:{type:String,default:"short",reflect:!0,attribute:"compact-display"},minimumFractionDigits:{type:Number,default:0,reflect:!0,attribute:"minimum-fraction-digits"},maximumFractionDigits:{type:Number,default:2,reflect:!0,attribute:"maximum-fraction-digits"},locale:{type:String,default:"",reflect:!0},signDisplay:{type:String,default:"auto",reflect:!0,attribute:"sign-display"}};static template=()=>null;#t(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#e(){let t=Number(this.value);if(!Number.isFinite(t)||this.numberStyle==="currency"&&!this.currency||this.numberStyle==="unit"&&!this.unit)return"";let e={style:this.numberStyle,notation:this.notation,signDisplay:this.signDisplay};this.numberStyle==="currency"&&(e.currency=this.currency),this.numberStyle==="unit"&&(e.unit=this.unit),this.notation==="compact"&&(e.compactDisplay=this.compactDisplay),Number.isFinite(this.minimumFractionDigits)&&(e.minimumFractionDigits=this.minimumFractionDigits),Number.isFinite(this.maximumFractionDigits)&&(e.maximumFractionDigits=this.maximumFractionDigits);try{return new Intl.NumberFormat(this.#t(),e).format(t)}catch{return String(t)}}connected(){super.connected()}render(){let t=this.#e();this.textContent=t,t&&Number.isFinite(Number(this.value))?this.setAttribute("aria-label",`${t} (raw: ${this.value})`):this.removeAttribute("aria-label")}};C();y("number-format-ui",Ln);$();var bf=["Weak","Fair","Good","Strong"];function C$(s){if(!s)return-1;let t=0;s.length>=8&&t++,s.length>=12&&t++,s.length>=16&&t++;let e=[/[a-z]/.test(s),/[A-Z]/.test(s),/[0-9]/.test(s),/[^a-zA-Z0-9]/.test(s)].filter(Boolean).length;return e>=2&&t++,e>=3&&t++,e===4&&t++,/(.)\1{2,}/.test(s)&&t--,s.length<8&&(t=Math.min(t,0)),Math.max(0,Math.min(3,t))}var Mn=class extends v{static properties={value:{type:String,default:""},minScore:{type:Number,default:2,reflect:!0,attribute:"min-score"},showLabel:{type:Boolean,default:!0,reflect:!0,attribute:"show-label"}};static template=()=>null;#t=-2;connected(){super.connected(),this.querySelector('[slot="bar"]')||(this.innerHTML=`
219
219
  <div slot="bar" aria-hidden="true">
@@ -254,7 +254,7 @@ Correct shape for <chart-ui x="label" y="value">:
254
254
  <span slot="icon">${this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:""}</span>
255
255
  <span slot="text">${this.text}</span>
256
256
  ${this.badge?`<span slot="badge">${this.badge}</span>`:""}
257
- `),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");let e=this.querySelector('[slot="icon"] icon-ui');e&&e.setAttribute("weight",this.selected?"fill":"regular")}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};C();y("nav-item-ui",Xo);var Bo=class extends R{static properties={...R.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.#h(t)};connected(){super.connected(),this.setAttribute("role","group"),this.setAttribute("aria-label","One-time password"),this.#r(),this.#n()}#r(){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)}}#n(){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.#c(),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.#d()}#l(t,e){t.key==="Backspace"&&!this.#t[e].value&&e>0&&(this.#t[e-1].focus(),this.#t[e-1].value="",this.#c(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h(t){t.preventDefault();let e=(t.clipboardData?.getData("text/plain")||"").replace(/\D/g,"");for(let r=0;r<this.#t.length;r++)this.#t[r].value=e[r]||"";this.#c(),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(r=>!r.value);i>=0?this.#t[i].focus():this.#t[this.#t.length-1].focus(),this.#d()}#c(){let t=this.#t.map(e=>e.value).join("");this.value=t,this.syncValue(t)}#d(){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=[]}};C();y("otp-input-ui",Bo);$();var Zo=class extends v{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.#r),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")};#r=()=>{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.#r)),this.#t=null,this.#e=null}};C();y("image-ui",Zo);var zo=class extends R{static properties={...R.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
257
+ `),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");let e=this.querySelector('[slot="icon"] icon-ui');e&&e.setAttribute("weight",this.selected?"fill":"regular")}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};C();y("nav-item-ui",Xo);var Bo=class extends R{static properties={...R.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.#h(t)};connected(){super.connected(),this.setAttribute("role","group"),this.setAttribute("aria-label","One-time password"),this.#r(),this.#n()}#r(){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)}}#n(){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.#c(),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.#d()}#l(t,e){t.key==="Backspace"&&!this.#t[e].value&&e>0&&(this.#t[e-1].focus(),this.#t[e-1].value="",this.#c(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h(t){t.preventDefault();let e=(t.clipboardData?.getData("text/plain")||"").replace(/\D/g,"");for(let r=0;r<this.#t.length;r++)this.#t[r].value=e[r]||"";this.#c(),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(r=>!r.value);i>=0?this.#t[i].focus():this.#t[this.#t.length-1].focus(),this.#d()}#c(){let t=this.#t.map(e=>e.value).join("");this.value=t,this.syncValue(t)}#d(){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=[]}};C();y("otp-input-ui",Bo);$();var Zo=class extends v{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.#r),this.#t.complete&&this.#t.naturalWidth>0&&this.#s(),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")};#r=()=>{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.#r)),this.#t=null,this.#e=null}};C();y("image-ui",Zo);var zo=class extends R{static properties={...R.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
258
258
  type="search"
259
259
  prefix="magnifying-glass"
260
260
  suffix="x-circle"
@@ -391,7 +391,7 @@ Correct shape for <chart-ui x="label" y="value">:
391
391
  <dd>${cs(e.value!=null?String(e.value):"")}</dd>
392
392
  `).join("")}
393
393
  </dl>
394
- `:typeof t=="string"?t:""}#c(t){let e=t.tone||"neutral",i={success:"var(--a-success-strong)",warning:"var(--a-warning-strong)",danger:"var(--a-danger-strong)",info:"var(--a-primary-strong)",neutral:"var(--a-fg-muted)"}[e]||"var(--a-fg-muted)",r=t.dot===!1?"":`<icon-ui name="circle-fill" data-trace-dot style="color:${i}"></icon-ui>`,n=t.label!=null?String(t.label):"",o=t.value!=null?String(t.value):"",a=o?`${o}${n?` ${n}`:""}`:n;return`<span data-trace-pill>${r}<span>${cs(a)}</span></span>`}};function cs(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function LE(s){return String(s).replace(/"/g,"&quot;")}y("agent-trace-ui",sh);$();function IO({icon:s,text:t="",title:e=""}){let i=document.createElement("button-ui");return i.setAttribute("icon",s),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),t&&i.setAttribute("text",t),!t&&e&&i.setAttribute("title",e),i}var Aa=class extends v{static properties={saveLabel:{type:String,default:"",reflect:!0,attribute:"save-label"},saveIcon:{type:String,default:"bookmark-simple",reflect:!0,attribute:"save-icon"},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#d()}disconnected(){this.#t?.removeEventListener("press",this.#a),this.#e?.removeEventListener("press",this.#o),this.#i?.removeEventListener("press",this.#l),this.#t=this.#e=this.#i=this.#s=null}setStatus(t,{lock:e=""}={}){this.#s&&(this.#s.textContent=t||"",(e==="rate"||e==="all")&&(this.#r=!0,this.#t&&(this.#t.disabled=!0),this.#e&&(this.#e.disabled=!0)),(e==="save"||e==="all")&&(this.#n=!0,this.#i&&(this.#i.disabled=!0)))}reset(){this.#r=!1,this.#n=!1,this.#s&&(this.#s.textContent=""),this.#t&&(this.#t.disabled=!1),this.#e&&(this.#e.disabled=!1),this.#i&&(this.#i.disabled=!1)}#a=()=>{!this.#r&&!this.disabled&&this.#h(5)};#o=()=>{!this.#r&&!this.disabled&&this.#h(2)};#l=()=>{!this.#n&&!this.disabled&&this.#c()};#h(t){this.dispatchEvent(new CustomEvent("feedback-rate",{bubbles:!0,detail:{rating:t}})),this.#s?.textContent||this.setStatus(t>=4?"Thanks!":"Noted",{lock:"rate"})}#c(){this.dispatchEvent(new CustomEvent("feedback-save",{bubbles:!0,detail:{}}))}render(){let t=this.saveLabel,e=this.saveIcon;this.#i&&(t?(this.#i.setAttribute("text",t),this.#i.hidden=!1):this.#i.hidden=!0,e&&this.#i.setAttribute("icon",e))}#d(){this.innerHTML="",this.#t=IO({icon:"thumbs-up",title:"Rate this response positively"}),this.#e=IO({icon:"thumbs-down",title:"Rate this response negatively"}),this.#i=IO({icon:this.saveIcon||"bookmark-simple",text:this.saveLabel||"",title:this.saveLabel?"":"Save this response"}),this.saveLabel||(this.#i.hidden=!0),this.#t.addEventListener("press",this.#a),this.#e.addEventListener("press",this.#o),this.#i.addEventListener("press",this.#l),this.#s=document.createElement("span"),this.#s.setAttribute("data-feedback-status",""),this.append(this.#t,this.#e,this.#i,this.#s)}};C();y("agent-feedback-bar-ui",Aa);$();function QD(s,t){return typeof s!="string"?"":s.length>t?s.slice(0,t-1)+"\u2026":s}var ka=class extends v{static properties={variant:{type:String,default:"outline",reflect:!0},size:{type:String,default:"sm",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];get suggestions(){return this.#t}set suggestions(t){this.#t=Array.isArray(t)?t.slice():[],this.#e()}connected(){this.#e()}disconnected(){this.innerHTML=""}#e(){this.innerHTML="";for(let t=0;t<this.#t.length;t++){let e=this.#t[t],i=typeof e=="string"?e:e.label||e.prompt||"",r=typeof e=="string"?e:e.prompt||e.label||"",n=typeof e=="object"?e.icon:null,o=document.createElement("button-ui");o.setAttribute("text",QD(i,42)),o.setAttribute("variant",this.variant),o.setAttribute("size",this.size),n&&o.setAttribute("icon",n),this.disabled&&o.setAttribute("disabled",""),o.addEventListener("press",()=>{this.disabled||this.dispatchEvent(new CustomEvent("suggestion-select",{bubbles:!0,detail:{label:i,prompt:r,index:t}}))}),this.appendChild(o)}}};C();y("agent-suggestions-ui",ka);$();var Ea=class extends v{static properties={multi:{type:Boolean,default:!1,reflect:!0},question:{type:String,default:"",reflect:!0},helper:{type:String,default:"",reflect:!0},submitLabel:{type:String,default:"Continue",reflect:!0,attribute:"submit-label"}};static template=()=>null;#t=[];#e=new Set;#i=!1;#s=null;#r=null;#n=null;#a=null;get options(){return this.#t}set options(t){this.#t=Array.isArray(t)?t.slice():[],this.#e.clear(),this.#i=!1,this.#l()}connected(){this.#o()}disconnected(){this.#a?.removeEventListener("press",this.#f),this.#n?.removeEventListener("change",this.#h),this.#n?.removeEventListener("click",this.#c,!0),this.#n?.removeEventListener("keydown",this.#d,!0),this.#s=this.#r=this.#n=this.#a=null}render(){this.#s&&(this.#s.textContent=this.question||"",this.#s.hidden=!this.question),this.#r&&(this.#r.textContent=this.helper||"",this.#r.hidden=!this.helper),this.#a&&(this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.hidden=!this.multi)}#o(){this.innerHTML="",this.#s=document.createElement("div"),this.#s.setAttribute("data-questions-q",""),this.question?this.#s.textContent=this.question:this.#s.hidden=!0,this.#r=document.createElement("div"),this.#r.setAttribute("data-questions-helper",""),this.helper?this.#r.textContent=this.helper:this.#r.hidden=!0,this.#n=document.createElement("div"),this.#n.setAttribute("data-questions-options",""),this.#n.addEventListener("change",this.#h),this.#n.addEventListener("click",this.#c,!0),this.#n.addEventListener("keydown",this.#d,!0),this.#a=document.createElement("button-ui"),this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.setAttribute("variant","primary"),this.#a.setAttribute("size","sm"),this.#a.setAttribute("disabled",""),this.multi||(this.#a.hidden=!0),this.#a.addEventListener("press",this.#f),this.append(this.#s,this.#r,this.#n,this.#a),this.#l()}#l(){if(this.#n){this.#n.innerHTML="";for(let t of this.#t){let e=document.createElement("option-card-ui");e.setAttribute("data-questions-option",""),e.setAttribute("data-questions-option-id",t.id),e.name="questions-option",e.value=t.id,e.heading=t.label||"",e.description=t.description||"",e.icon=t.icon||"",this.#n.appendChild(e),this.multi&&e.setAttribute("role","checkbox"),e.checked=this.#e.has(t.id),e.disabled=this.#i}this.#a&&(this.#a.disabled=this.#i||this.#e.size===0)}}#h=t=>{if(this.multi||this.#i)return;let e=t.detail?.value,i=this.#t.find(r=>r.id===e);i&&(this.#e.clear(),this.#e.add(i.id),this.#i=!0,this.#l(),this.dispatchEvent(new CustomEvent("questions-answer",{bubbles:!0,detail:{selected:[i.id],option:i}})))};#c=t=>{if(!this.multi)return;let e=t.target.closest?.("option-card-ui[data-questions-option]");!e||!this.#n.contains(e)||(t.stopPropagation(),this.#u(e))};#d=t=>{if(!this.multi)return;let e=t.target.closest?.("option-card-ui[data-questions-option]");if(!(!e||!this.#n.contains(e))){if(t.key===" "||t.key==="Enter"){t.preventDefault(),t.stopPropagation(),this.#u(e);return}(t.key==="ArrowDown"||t.key==="ArrowUp"||t.key==="ArrowLeft"||t.key==="ArrowRight")&&t.stopPropagation()}};#u(t){if(this.#i)return;let e=t.dataset.questionsOptionId,i=this.#t.find(r=>r.id===e);i&&(this.#e.has(i.id)?this.#e.delete(i.id):this.#e.add(i.id),this.#l())}#f=()=>{if(this.#i||this.#e.size===0)return;this.#i=!0,this.#l();let t=[...this.#e],e=this.#t.find(i=>i.id===t[0])||null;this.dispatchEvent(new CustomEvent("questions-answer",{bubbles:!0,detail:{selected:t,option:e}}))}};C();y("agent-questions-ui",Ea);$();var ME={neutral:"default",accent:"accent",warning:"warning",danger:"danger"},Ca=class extends v{static properties={title:{type:String,default:"",reflect:!0},kind:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},tone:{type:String,default:"neutral",reflect:!0}};static requiredIcons=["caret-right","caret-down"];static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){this.#l()}disconnected(){this.#t?.removeEventListener("click",this.#a),this.#t?.removeEventListener("keydown",this.#o),this.#t=this.#e=this.#i=null,this.#s=this.#r=this.#n=null}#a=t=>{t.target.closest('[slot="primary"], [slot="secondary"]')||(this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("artifact-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.render())};#o=t=>{if(t.key===" "||t.key==="Enter"){if(t.target.closest('[slot="primary"], [slot="secondary"]'))return;t.preventDefault(),this.#a(t)}};render(){this.#t&&(this.#e&&(this.icon?(this.#e.setAttribute("name",this.icon),this.#e.hidden=!1):this.#e.hidden=!0),this.#i&&(this.#i.textContent=this.title||"",this.#i.hidden=!this.title),this.#s&&(this.#s.setAttribute("text",(this.kind||"").toUpperCase()),this.#s.setAttribute("variant",ME[this.tone]||"default"),this.#s.hidden=!this.kind),this.#r&&this.#r.setAttribute("name",this.collapsed?"caret-right":"caret-down"),this.#n&&(this.#n.hidden=this.collapsed),this.#t&&this.#t.setAttribute("aria-expanded",String(!this.collapsed)))}#l(){let t=[],e=[],i=[],r=a=>a.getAttribute("role")==="presentation"||a.style?.display==="contents",n=a=>{for(let l of a){if(l.nodeType===1){let h=l;if(r(h)){n(h.childNodes);continue}let c=h.getAttribute("slot")||"";if(c==="primary"){t.push(h);continue}if(c==="secondary"){e.push(h);continue}}i.push(l)}};n(Array.from(this.childNodes)),this.innerHTML="",this.#t=document.createElement("div"),this.#t.setAttribute("data-artifact-header",""),this.#t.setAttribute("role","button"),this.#t.setAttribute("tabindex","0"),this.#t.setAttribute("aria-expanded",String(!this.collapsed)),this.#t.addEventListener("click",this.#a),this.#t.addEventListener("keydown",this.#o),this.#e=document.createElement("icon-ui"),this.#e.setAttribute("data-artifact-icon",""),this.#e.setAttribute("color","muted"),this.icon?this.#e.setAttribute("name",this.icon):this.#e.hidden=!0,this.#i=document.createElement("span"),this.#i.setAttribute("data-artifact-title",""),this.title?this.#i.textContent=this.title:this.#i.hidden=!0,this.#s=document.createElement("badge-ui"),this.#s.setAttribute("data-artifact-kind",""),this.#s.setAttribute("size","sm"),this.#s.setAttribute("variant",ME[this.tone]||"default"),this.kind?this.#s.setAttribute("text",this.kind.toUpperCase()):this.#s.hidden=!0;let o=document.createElement("span");o.setAttribute("data-artifact-actions","");for(let a of e)o.appendChild(a);for(let a of t)o.appendChild(a);this.#r=document.createElement("icon-ui"),this.#r.setAttribute("color","muted"),this.#r.setAttribute("data-artifact-caret",""),this.#r.setAttribute("name",this.collapsed?"caret-right":"caret-down"),this.#t.append(this.#e,this.#i,this.#s,o,this.#r),this.#n=document.createElement("div"),this.#n.setAttribute("data-artifact-body","");for(let a of i)this.#n.appendChild(a);this.collapsed&&(this.#n.hidden=!0),this.append(this.#t,this.#n)}};C();y("agent-artifact-ui",Ca);C();$();var TD="rounded borderless",rh=class s extends v{static properties={mode:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("mode")||(this.mode=TD),this.addEventListener("click",this.#e),this.#i()}#t(t){return this.querySelector(`admin-sidebar[slot="${t}"], admin-sidebar[name="${t}"]`)}#e=t=>{let e=t.target.closest("[data-sidebar-toggle]");if(e&&this.contains(e)){let r=e.getAttribute("data-sidebar-toggle"),n=this.#t(r);n&&typeof n.toggle!="function"&&this.#r("admin-sidebar",`slot="${r}"`,"Sidebar toggle"),n?.toggle?.();return}let i=t.target.closest("[data-command-trigger]");if(i&&this.contains(i)){t.stopPropagation();let r=this.querySelector("admin-command");if(!r)return;if(typeof r.show!="function"){this.#r("admin-command","","Command palette");return}r.show()}};#i(){let t=this.querySelector("admin-command"),e=this.querySelector("nav-ui");!t||!e||t.addEventListener("command-select",i=>{let r=e.querySelector(`nav-item-ui[value="${i.detail.value}"]`);r&&e.select(r)})}static#s=new WeakSet;#r(t,e,i){let r=e?this.querySelector(`${t}[${e}], ${t}[${e.replace("slot=","name=")}]`):this.querySelector(t);if(!r||s.#s.has(r))return;s.#s.add(r);let n=t==="admin-sidebar"?"shell/admin-sidebar":"shell/admin-command";console.warn(`[admin-shell] <${t}${e?" "+e:""}> is in the DOM but ${t==="admin-sidebar"?"AdminSidebar":"AdminCommand"} is NOT registered \u2014 ${i} will not work. Import the cluster barrel \`@adia-ai/web-modules/shell\` (which registers all shell elements), OR add \`@adia-ai/web-modules/${n}\` alongside \`@adia-ai/web-modules/shell/admin-shell\` on the per-component path. Closes FB-55 silent-failure trap.`)}};y("admin-shell",rh);C();$();var $a=96,RE=160,nh=class s extends v{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;static#t=new WeakSet;#e="";#i=[];#s=null;connected(){this.#a(),this.resizable&&this.#l(),this.#h(),this.#o()}disconnected(){for(let t of this.#i)t();this.#i=[],this.#s?.disconnect(),this.#s=null}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){if(this.collapsed)return;let t=this.style.width||getComputedStyle(this).width;parseFloat(t)>$a&&(this.#e=t);let e=this.minWidth||getComputedStyle(this).minWidth;this.style.width=e,this.#n(e),this.collapsed=!0,this.#c(!1)}expand(){if(!this.collapsed)return;let t=this.#e||"";this.style.width=t,this.#n(t),this.collapsed=!1,this.#c(!0)}#r(){return`adia-sidebar-${this.name||this.getAttribute("slot")||"default"}`}#n(t){try{localStorage.setItem(this.#r(),t)}catch{}}#a(){try{let t=localStorage.getItem(this.#r());if(!t)return;this.style.width=t;let e=parseFloat(t);!isNaN(e)&&e>$a&&(this.#e=t)}catch{}}#o(){let t=this.getBoundingClientRect().width;t!==0&&(this.collapsed=t<=$a)}#l(){let t=this.querySelector(":scope > [data-resize]");if(!t){s.#t.has(this)||(s.#t.add(this),console.warn("[admin-sidebar] `resizable` is set but no `[data-resize]` child was found. Add `<div data-resize></div>` as a direct child to enable drag-to-resize. (Unlike `collapsible`, `resizable` requires this author-supplied handle.)",this));return}let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=$a?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<RE&&(this.style.width=`${RE}px`),this.#n(this.style.width),this.#o(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#i.push(()=>t.removeEventListener("pointerdown",r))}#h(){typeof ResizeObserver>"u"||(this.#s=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize;i>0&&(this.collapsed=i<=$a);for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i<=$a?"right":"bottom-start")}}),this.#s.observe(this))}#c(t){this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:this.name||this.getAttribute("slot")||"default",expanded:t}}))}};y("admin-sidebar",nh);C();$();var oh=class extends v{static properties={open:{type:Boolean,default:!1,reflect:!0},shortcut:{type:String,default:"both",reflect:!0},noShortcut:{type:Boolean,default:!1,reflect:!0,attribute:"no-shortcut"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.#i=this.querySelector(":scope > dialog"),!this.#i){for(this.#i=document.createElement("dialog");this.firstChild;)this.#i.appendChild(this.firstChild);this.appendChild(this.#i)}this.#e=this.querySelector("command-ui"),this.#s(),this.#r(),this.noShortcut||this.#n()}disconnected(){this.#t&&(document.removeEventListener("keydown",this.#t),this.#t=null)}show(){this.#i&&(this.#i.open||(this.#i.showModal(),this.#e&&(this.#e.open=!0,this.#e.value="",this.#e.focus()),this.open=!0))}hide(){this.#i&&this.#i.open&&(this.#i.close(),this.#e&&(this.#e.open=!1),this.open=!1)}toggle(){return this.open?this.hide():this.show(),this.open}#s(){this.#i&&(this.#i.addEventListener("click",t=>{t.target===this.#i&&this.hide()}),this.#i.addEventListener("close",()=>{this.#e&&(this.#e.open=!1),this.open=!1}))}#r(){this.#e&&(this.#e.addEventListener("dismiss",()=>this.hide()),this.#e.addEventListener("select",t=>{this.dispatchEvent(new CustomEvent("command-select",{bubbles:!0,detail:t.detail})),this.hide()}))}#n(){let t=e=>{let i=e.metaKey,r=e.ctrlKey;return e.key!=="k"?!1:this.shortcut==="cmd+k"?i:this.shortcut==="ctrl+k"?r:i||r};this.#t=e=>{t(e)&&(e.preventDefault(),this.toggle())},document.addEventListener("keydown",this.#t)}};y("admin-command",oh);C();$();var ah=class extends v{static template=()=>null;connected(){this.addEventListener("click",this.#t),this.addEventListener("embed:open",this.#e),this.addEventListener("keydown",this.#i)}#t=t=>{let e=t.target.closest?.("[opens]");if(e&&this.contains(e)){this.toggle(e.getAttribute("opens"));return}let i=t.target.closest?.("[close]");i&&this.contains(i)&&this.close()};#e=t=>this.toggle(t.detail?.panel);#i=t=>{t.key==="Escape"&&this.panel&&(t.stopPropagation(),this.close())};get panel(){return this.getAttribute("panel")||""}toggle(t){return this.panel===t?this.close():this.open(t)}open(t){if(!t)return;let e=this.querySelector(`:scope > [panel="${CSS.escape(t)}"]`);if(e){for(let i of this.querySelectorAll(":scope > [panel][active]"))i!==e&&i.removeAttribute("active");e.setAttribute("active",""),this.setAttribute("panel",t),requestAnimationFrame(()=>e.querySelector("[autofocus], [close], button-ui, [tabindex]")?.focus?.({preventScroll:!0})),this.#s(t)}}close(){this.panel&&(this.querySelector(":scope > [panel][active]")?.removeAttribute("active"),this.removeAttribute("panel"),this.#s(""))}#s(t){this.dispatchEvent(new CustomEvent("embed:change",{detail:{panel:t},bubbles:!0}))}};y("embed-shell",ah);C();$();function DO(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var LD=0,lh=class extends v{static properties={streaming:{type:Boolean,default:!1,reflect:!0},provider:{type:String,default:"",reflect:!0},model:{type:String,default:"",reflect:!0},system:{type:String,default:"",reflect:!0},proxyUrl:{type:String,default:"",attribute:"proxy-url",reflect:!0},thinking:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;#i=null;#s=null;#r=null;#n=null;#a="";get messages(){return[...this.#t]}get conversation(){return this.#t.filter(t=>t.role==="user"||t.role==="assistant").map(t=>t.html?{role:t.role,content:t.content,html:!0}:{role:t.role,content:t.content})}set conversation(t){this.clear();for(let e of t)this.appendMessage({role:e.role,content:e.content,render:!e.html,html:!!e.html})}set apiKey(t){this.#a=t}connected(){this.#i=this.querySelector("chat-thread"),this.#s=this.querySelector("chat-composer"),this.#r=this.querySelector("chat-empty"),this.#n=this.querySelector("chat-status"),this.#s?.addEventListener("composer-submit",this.#l)}disconnected(){this.#s?.removeEventListener("composer-submit",this.#l),this.abort()}#o(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}#l=t=>{if(this.streaming)return;let{text:e,model:i}=t.detail||{};e&&(this.#s.clear(),this.#o("submit",{text:e,model:i}),(this.proxyUrl||this.#a)&&this.send(e,i?{model:i}:{}))};appendMessage({role:t,content:e="",render:i=!1,html:r=!1}){let n=`msg_${++LD}`;this.#t.push({id:n,role:t,content:e,html:r});let o=document.createElement("div");if(o.setAttribute("data-role",t),o.setAttribute("data-id",n),t==="user")o.innerHTML=`<div data-bubble>${DO(e)}</div>`;else if(t==="assistant"){let a=i||r,l=r?e:i&&e?di(e):DO(e);o.innerHTML=`
394
+ `:typeof t=="string"?t:""}#c(t){let e=t.tone||"neutral",i={success:"var(--a-success-strong)",warning:"var(--a-warning-strong)",danger:"var(--a-danger-strong)",info:"var(--a-primary-strong)",neutral:"var(--a-fg-muted)"}[e]||"var(--a-fg-muted)",r=t.dot===!1?"":`<icon-ui name="circle-fill" data-trace-dot style="color:${i}"></icon-ui>`,n=t.label!=null?String(t.label):"",o=t.value!=null?String(t.value):"",a=o?`${o}${n?` ${n}`:""}`:n;return`<span data-trace-pill>${r}<span>${cs(a)}</span></span>`}};function cs(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function LE(s){return String(s).replace(/"/g,"&quot;")}y("agent-trace-ui",sh);$();function IO({icon:s,text:t="",title:e=""}){let i=document.createElement("button-ui");return i.setAttribute("icon",s),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),t&&i.setAttribute("text",t),!t&&e&&i.setAttribute("title",e),i}var Aa=class extends v{static properties={saveLabel:{type:String,default:"",reflect:!0,attribute:"save-label"},saveIcon:{type:String,default:"bookmark-simple",reflect:!0,attribute:"save-icon"},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=!1;#n=!1;connected(){this.#d()}disconnected(){this.#t?.removeEventListener("press",this.#a),this.#e?.removeEventListener("press",this.#o),this.#i?.removeEventListener("press",this.#l),this.#t=this.#e=this.#i=this.#s=null}setStatus(t,{lock:e=""}={}){this.#s&&(this.#s.textContent=t||"",(e==="rate"||e==="all")&&(this.#r=!0,this.#t&&(this.#t.disabled=!0),this.#e&&(this.#e.disabled=!0)),(e==="save"||e==="all")&&(this.#n=!0,this.#i&&(this.#i.disabled=!0)))}reset(){this.#r=!1,this.#n=!1,this.#s&&(this.#s.textContent=""),this.#t&&(this.#t.disabled=!1),this.#e&&(this.#e.disabled=!1),this.#i&&(this.#i.disabled=!1)}#a=()=>{!this.#r&&!this.disabled&&this.#h(5)};#o=()=>{!this.#r&&!this.disabled&&this.#h(2)};#l=()=>{!this.#n&&!this.disabled&&this.#c()};#h(t){this.dispatchEvent(new CustomEvent("feedback-rate",{bubbles:!0,detail:{rating:t}})),this.#s?.textContent||this.setStatus(t>=4?"Thanks!":"Noted",{lock:"rate"})}#c(){this.dispatchEvent(new CustomEvent("feedback-save",{bubbles:!0,detail:{}}))}render(){let t=this.saveLabel,e=this.saveIcon;this.#i&&(t?(this.#i.setAttribute("text",t),this.#i.hidden=!1):this.#i.hidden=!0,e&&this.#i.setAttribute("icon",e))}#d(){this.innerHTML="",this.#t=IO({icon:"thumbs-up",title:"Rate this response positively"}),this.#e=IO({icon:"thumbs-down",title:"Rate this response negatively"}),this.#i=IO({icon:this.saveIcon||"bookmark-simple",text:this.saveLabel||"",title:this.saveLabel?"":"Save this response"}),this.saveLabel||(this.#i.hidden=!0),this.#t.addEventListener("press",this.#a),this.#e.addEventListener("press",this.#o),this.#i.addEventListener("press",this.#l),this.#s=document.createElement("span"),this.#s.setAttribute("data-feedback-status",""),this.append(this.#t,this.#e,this.#i,this.#s)}};C();y("agent-feedback-bar-ui",Aa);$();function QD(s,t){return typeof s!="string"?"":s.length>t?s.slice(0,t-1)+"\u2026":s}var ka=class extends v{static properties={variant:{type:String,default:"outline",reflect:!0},size:{type:String,default:"sm",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];get suggestions(){return this.#t}set suggestions(t){this.#t=Array.isArray(t)?t.slice():[],this.#e()}connected(){this.#e()}disconnected(){this.innerHTML=""}#e(){this.innerHTML="";for(let t=0;t<this.#t.length;t++){let e=this.#t[t],i=typeof e=="string"?e:e.label||e.prompt||"",r=typeof e=="string"?e:e.prompt||e.label||"",n=typeof e=="object"?e.icon:null,o=document.createElement("button-ui");o.setAttribute("text",QD(i,42)),o.setAttribute("variant",this.variant),o.setAttribute("size",this.size),n&&o.setAttribute("icon",n),this.disabled&&o.setAttribute("disabled",""),o.addEventListener("press",()=>{this.disabled||this.dispatchEvent(new CustomEvent("suggestion-select",{bubbles:!0,detail:{label:i,prompt:r,index:t}}))}),this.appendChild(o)}}};C();y("agent-suggestions-ui",ka);$();var Ea=class extends v{static properties={multi:{type:Boolean,default:!1,reflect:!0},question:{type:String,default:"",reflect:!0},helper:{type:String,default:"",reflect:!0},submitLabel:{type:String,default:"Continue",reflect:!0,attribute:"submit-label"}};static template=()=>null;#t=[];#e=new Set;#i=!1;#s=null;#r=null;#n=null;#a=null;get options(){return this.#t}set options(t){this.#t=Array.isArray(t)?t.slice():[],this.#e.clear(),this.#i=!1,this.#l()}connected(){this.#o()}disconnected(){this.#a?.removeEventListener("press",this.#f),this.#n?.removeEventListener("change",this.#h),this.#n?.removeEventListener("click",this.#c,!0),this.#n?.removeEventListener("keydown",this.#d,!0),this.#s=this.#r=this.#n=this.#a=null}render(){this.#s&&(this.#s.textContent=this.question||"",this.#s.hidden=!this.question),this.#r&&(this.#r.textContent=this.helper||"",this.#r.hidden=!this.helper),this.#a&&(this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.hidden=!this.multi)}#o(){this.innerHTML="",this.#s=document.createElement("div"),this.#s.setAttribute("data-questions-q",""),this.question?this.#s.textContent=this.question:this.#s.hidden=!0,this.#r=document.createElement("div"),this.#r.setAttribute("data-questions-helper",""),this.helper?this.#r.textContent=this.helper:this.#r.hidden=!0,this.#n=document.createElement("div"),this.#n.setAttribute("data-questions-options",""),this.#n.addEventListener("change",this.#h),this.#n.addEventListener("click",this.#c,!0),this.#n.addEventListener("keydown",this.#d,!0),this.#a=document.createElement("button-ui"),this.#a.setAttribute("text",this.submitLabel||"Continue"),this.#a.setAttribute("variant","primary"),this.#a.setAttribute("disabled",""),this.multi||(this.#a.hidden=!0),this.#a.addEventListener("press",this.#f),this.append(this.#s,this.#r,this.#n,this.#a),this.#l()}#l(){if(this.#n){this.#n.innerHTML="";for(let t of this.#t){let e=document.createElement("option-card-ui");e.setAttribute("data-questions-option",""),e.setAttribute("data-questions-option-id",t.id),e.name="questions-option",e.value=t.id,e.heading=t.label||"",e.description=t.description||"",e.icon=t.icon||"",this.#n.appendChild(e),this.multi&&e.setAttribute("role","checkbox"),e.checked=this.#e.has(t.id),e.disabled=this.#i}this.#a&&(this.#a.disabled=this.#i||this.#e.size===0)}}#h=t=>{if(this.multi||this.#i)return;let e=t.detail?.value,i=this.#t.find(r=>r.id===e);i&&(this.#e.clear(),this.#e.add(i.id),this.#i=!0,this.#l(),this.dispatchEvent(new CustomEvent("questions-answer",{bubbles:!0,detail:{selected:[i.id],option:i}})))};#c=t=>{if(!this.multi)return;let e=t.target.closest?.("option-card-ui[data-questions-option]");!e||!this.#n.contains(e)||(t.stopPropagation(),this.#u(e))};#d=t=>{if(!this.multi)return;let e=t.target.closest?.("option-card-ui[data-questions-option]");if(!(!e||!this.#n.contains(e))){if(t.key===" "||t.key==="Enter"){t.preventDefault(),t.stopPropagation(),this.#u(e);return}(t.key==="ArrowDown"||t.key==="ArrowUp"||t.key==="ArrowLeft"||t.key==="ArrowRight")&&t.stopPropagation()}};#u(t){if(this.#i)return;let e=t.dataset.questionsOptionId,i=this.#t.find(r=>r.id===e);i&&(this.#e.has(i.id)?this.#e.delete(i.id):this.#e.add(i.id),this.#l())}#f=()=>{if(this.#i||this.#e.size===0)return;this.#i=!0,this.#l();let t=[...this.#e],e=this.#t.find(i=>i.id===t[0])||null;this.dispatchEvent(new CustomEvent("questions-answer",{bubbles:!0,detail:{selected:t,option:e}}))}};C();y("agent-questions-ui",Ea);$();var ME={neutral:"default",accent:"accent",warning:"warning",danger:"danger"},Ca=class extends v{static properties={title:{type:String,default:"",reflect:!0},kind:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},tone:{type:String,default:"neutral",reflect:!0}};static requiredIcons=["caret-right","caret-down"];static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;connected(){this.#l()}disconnected(){this.#t?.removeEventListener("click",this.#a),this.#t?.removeEventListener("keydown",this.#o),this.#t=this.#e=this.#i=null,this.#s=this.#r=this.#n=null}#a=t=>{t.target.closest('[slot="primary"], [slot="secondary"]')||(this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("artifact-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.render())};#o=t=>{if(t.key===" "||t.key==="Enter"){if(t.target.closest('[slot="primary"], [slot="secondary"]'))return;t.preventDefault(),this.#a(t)}};render(){this.#t&&(this.#e&&(this.icon?(this.#e.setAttribute("name",this.icon),this.#e.hidden=!1):this.#e.hidden=!0),this.#i&&(this.#i.textContent=this.title||"",this.#i.hidden=!this.title),this.#s&&(this.#s.setAttribute("text",(this.kind||"").toUpperCase()),this.#s.setAttribute("variant",ME[this.tone]||"default"),this.#s.hidden=!this.kind),this.#r&&this.#r.setAttribute("name",this.collapsed?"caret-right":"caret-down"),this.#n&&(this.#n.hidden=this.collapsed),this.#t&&this.#t.setAttribute("aria-expanded",String(!this.collapsed)))}#l(){let t=[],e=[],i=[],r=a=>a.getAttribute("role")==="presentation"||a.style?.display==="contents",n=a=>{for(let l of a){if(l.nodeType===1){let h=l;if(r(h)){n(h.childNodes);continue}let c=h.getAttribute("slot")||"";if(c==="primary"){t.push(h);continue}if(c==="secondary"){e.push(h);continue}}i.push(l)}};n(Array.from(this.childNodes)),this.innerHTML="",this.#t=document.createElement("div"),this.#t.setAttribute("data-artifact-header",""),this.#t.setAttribute("role","button"),this.#t.setAttribute("tabindex","0"),this.#t.setAttribute("aria-expanded",String(!this.collapsed)),this.#t.addEventListener("click",this.#a),this.#t.addEventListener("keydown",this.#o),this.#e=document.createElement("icon-ui"),this.#e.setAttribute("data-artifact-icon",""),this.#e.setAttribute("color","muted"),this.icon?this.#e.setAttribute("name",this.icon):this.#e.hidden=!0,this.#i=document.createElement("span"),this.#i.setAttribute("data-artifact-title",""),this.title?this.#i.textContent=this.title:this.#i.hidden=!0,this.#s=document.createElement("badge-ui"),this.#s.setAttribute("data-artifact-kind",""),this.#s.setAttribute("size","sm"),this.#s.setAttribute("variant",ME[this.tone]||"default"),this.kind?this.#s.setAttribute("text",this.kind.toUpperCase()):this.#s.hidden=!0;let o=document.createElement("span");o.setAttribute("data-artifact-actions","");for(let a of e)o.appendChild(a);for(let a of t)o.appendChild(a);this.#r=document.createElement("icon-ui"),this.#r.setAttribute("color","muted"),this.#r.setAttribute("data-artifact-caret",""),this.#r.setAttribute("name",this.collapsed?"caret-right":"caret-down"),this.#t.append(this.#e,this.#i,this.#s,o,this.#r),this.#n=document.createElement("div"),this.#n.setAttribute("data-artifact-body","");for(let a of i)this.#n.appendChild(a);this.collapsed&&(this.#n.hidden=!0),this.append(this.#t,this.#n)}};C();y("agent-artifact-ui",Ca);C();$();var TD="rounded borderless",rh=class s extends v{static properties={mode:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("mode")||(this.mode=TD),this.addEventListener("click",this.#e),this.#i()}#t(t){return this.querySelector(`admin-sidebar[slot="${t}"], admin-sidebar[name="${t}"]`)}#e=t=>{let e=t.target.closest("[data-sidebar-toggle]");if(e&&this.contains(e)){let r=e.getAttribute("data-sidebar-toggle"),n=this.#t(r);n&&typeof n.toggle!="function"&&this.#r("admin-sidebar",`slot="${r}"`,"Sidebar toggle"),n?.toggle?.();return}let i=t.target.closest("[data-command-trigger]");if(i&&this.contains(i)){t.stopPropagation();let r=this.querySelector("admin-command");if(!r)return;if(typeof r.show!="function"){this.#r("admin-command","","Command palette");return}r.show()}};#i(){let t=this.querySelector("admin-command"),e=this.querySelector("nav-ui");!t||!e||t.addEventListener("command-select",i=>{let r=e.querySelector(`nav-item-ui[value="${i.detail.value}"]`);r&&e.select(r)})}static#s=new WeakSet;#r(t,e,i){let r=e?this.querySelector(`${t}[${e}], ${t}[${e.replace("slot=","name=")}]`):this.querySelector(t);if(!r||s.#s.has(r))return;s.#s.add(r);let n=t==="admin-sidebar"?"shell/admin-sidebar":"shell/admin-command";console.warn(`[admin-shell] <${t}${e?" "+e:""}> is in the DOM but ${t==="admin-sidebar"?"AdminSidebar":"AdminCommand"} is NOT registered \u2014 ${i} will not work. Import the cluster barrel \`@adia-ai/web-modules/shell\` (which registers all shell elements), OR add \`@adia-ai/web-modules/${n}\` alongside \`@adia-ai/web-modules/shell/admin-shell\` on the per-component path. Closes FB-55 silent-failure trap.`)}};y("admin-shell",rh);C();$();var $a=96,RE=160,nh=class s extends v{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;static#t=new WeakSet;#e="";#i=[];#s=null;connected(){this.#a(),this.resizable&&this.#l(),this.#h(),this.#o()}disconnected(){for(let t of this.#i)t();this.#i=[],this.#s?.disconnect(),this.#s=null}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){if(this.collapsed)return;let t=this.style.width||getComputedStyle(this).width;parseFloat(t)>$a&&(this.#e=t);let e=this.minWidth||getComputedStyle(this).minWidth;this.style.width=e,this.#n(e),this.collapsed=!0,this.#c(!1)}expand(){if(!this.collapsed)return;let t=this.#e||"";this.style.width=t,this.#n(t),this.collapsed=!1,this.#c(!0)}#r(){return`adia-sidebar-${this.name||this.getAttribute("slot")||"default"}`}#n(t){try{localStorage.setItem(this.#r(),t)}catch{}}#a(){try{let t=localStorage.getItem(this.#r());if(!t)return;this.style.width=t;let e=parseFloat(t);!isNaN(e)&&e>$a&&(this.#e=t)}catch{}}#o(){let t=this.getBoundingClientRect().width;t!==0&&(this.collapsed=t<=$a)}#l(){let t=this.querySelector(":scope > [data-resize]");if(!t){s.#t.has(this)||(s.#t.add(this),console.warn("[admin-sidebar] `resizable` is set but no `[data-resize]` child was found. Add `<div data-resize></div>` as a direct child to enable drag-to-resize. (Unlike `collapsible`, `resizable` requires this author-supplied handle.)",this));return}let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=$a?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<RE&&(this.style.width=`${RE}px`),this.#n(this.style.width),this.#o(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#i.push(()=>t.removeEventListener("pointerdown",r))}#h(){typeof ResizeObserver>"u"||(this.#s=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize;i>0&&(this.collapsed=i<=$a);for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i<=$a?"right":"bottom-start")}}),this.#s.observe(this))}#c(t){this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:this.name||this.getAttribute("slot")||"default",expanded:t}}))}};y("admin-sidebar",nh);C();$();var oh=class extends v{static properties={open:{type:Boolean,default:!1,reflect:!0},shortcut:{type:String,default:"both",reflect:!0},noShortcut:{type:Boolean,default:!1,reflect:!0,attribute:"no-shortcut"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.#i=this.querySelector(":scope > dialog"),!this.#i){for(this.#i=document.createElement("dialog");this.firstChild;)this.#i.appendChild(this.firstChild);this.appendChild(this.#i)}this.#e=this.querySelector("command-ui"),this.#s(),this.#r(),this.noShortcut||this.#n()}disconnected(){this.#t&&(document.removeEventListener("keydown",this.#t),this.#t=null)}show(){this.#i&&(this.#i.open||(this.#i.showModal(),this.#e&&(this.#e.open=!0,this.#e.value="",this.#e.focus()),this.open=!0))}hide(){this.#i&&this.#i.open&&(this.#i.close(),this.#e&&(this.#e.open=!1),this.open=!1)}toggle(){return this.open?this.hide():this.show(),this.open}#s(){this.#i&&(this.#i.addEventListener("click",t=>{t.target===this.#i&&this.hide()}),this.#i.addEventListener("close",()=>{this.#e&&(this.#e.open=!1),this.open=!1}))}#r(){this.#e&&(this.#e.addEventListener("dismiss",()=>this.hide()),this.#e.addEventListener("select",t=>{this.dispatchEvent(new CustomEvent("command-select",{bubbles:!0,detail:t.detail})),this.hide()}))}#n(){let t=e=>{let i=e.metaKey,r=e.ctrlKey;return e.key!=="k"?!1:this.shortcut==="cmd+k"?i:this.shortcut==="ctrl+k"?r:i||r};this.#t=e=>{t(e)&&(e.preventDefault(),this.toggle())},document.addEventListener("keydown",this.#t)}};y("admin-command",oh);C();$();var ah=class extends v{static template=()=>null;connected(){this.addEventListener("click",this.#t),this.addEventListener("embed:open",this.#e),this.addEventListener("keydown",this.#i)}#t=t=>{let e=t.target.closest?.("[opens]");if(e&&this.contains(e)){this.toggle(e.getAttribute("opens"));return}let i=t.target.closest?.("[close]");i&&this.contains(i)&&this.close()};#e=t=>this.toggle(t.detail?.panel);#i=t=>{t.key==="Escape"&&this.panel&&(t.stopPropagation(),this.close())};get panel(){return this.getAttribute("panel")||""}toggle(t){return this.panel===t?this.close():this.open(t)}open(t){if(!t)return;let e=this.querySelector(`:scope > [panel="${CSS.escape(t)}"]`);if(e){for(let i of this.querySelectorAll(":scope > [panel][active]"))i!==e&&i.removeAttribute("active");e.setAttribute("active",""),this.setAttribute("panel",t),requestAnimationFrame(()=>e.querySelector("[autofocus], [close], button-ui, [tabindex]")?.focus?.({preventScroll:!0})),this.#s(t)}}close(){this.panel&&(this.querySelector(":scope > [panel][active]")?.removeAttribute("active"),this.removeAttribute("panel"),this.#s(""))}#s(t){this.dispatchEvent(new CustomEvent("embed:change",{detail:{panel:t},bubbles:!0}))}};y("embed-shell",ah);C();$();function DO(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var LD=0,lh=class extends v{static properties={streaming:{type:Boolean,default:!1,reflect:!0},provider:{type:String,default:"",reflect:!0},model:{type:String,default:"",reflect:!0},system:{type:String,default:"",reflect:!0},proxyUrl:{type:String,default:"",attribute:"proxy-url",reflect:!0},thinking:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;#i=null;#s=null;#r=null;#n=null;#a="";get messages(){return[...this.#t]}get conversation(){return this.#t.filter(t=>t.role==="user"||t.role==="assistant").map(t=>t.html?{role:t.role,content:t.content,html:!0}:{role:t.role,content:t.content})}set conversation(t){this.clear();for(let e of t)this.appendMessage({role:e.role,content:e.content,render:!e.html,html:!!e.html})}set apiKey(t){this.#a=t}connected(){this.#i=this.querySelector("chat-thread"),this.#s=this.querySelector("chat-composer"),this.#r=this.querySelector("chat-empty"),this.#n=this.querySelector("chat-status"),this.#s?.addEventListener("composer-submit",this.#l)}disconnected(){this.#s?.removeEventListener("composer-submit",this.#l),this.abort()}#o(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}#l=t=>{if(this.streaming)return;let{text:e,model:i}=t.detail||{};e&&(this.#s.clear(),this.#o("submit",{text:e,model:i}),(this.proxyUrl||this.#a)&&this.send(e,i?{model:i}:{}))};appendMessage({role:t,content:e="",render:i=!1,html:r=!1}){let n=`msg_${++LD}`;this.#t.push({id:n,role:t,content:e,html:r});let o=document.createElement("div");if(o.setAttribute("data-role",t),o.setAttribute("data-id",n),t==="user")o.innerHTML=`<div data-bubble>${DO(e)}</div>`;else if(t==="assistant"){let a=i||r,l=r?e:i&&e?di(e):DO(e);o.innerHTML=`
395
395
  <span data-avatar>AI</span>
396
396
  <div data-bubble><div data-content>${l}</div>${a?"":"<span data-cursor></span>"}</div>
397
397
  `}else t==="error"&&(o.innerHTML=`<icon-ui name="warning"></icon-ui><span>${DO(e)}</span>`);return this.#i?.appendChild(o),this.#h(),this.#o("message",{id:n,role:t,content:e}),o}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role!=="assistant")return;e.content+=t;let i=this.#i?.querySelector("[data-role]:last-child [data-content]");i&&i.insertAdjacentText("beforeend",t),this.#h()}setStreamedText(t){let e=this.#t[this.#t.length-1];if(!e||e.role!=="assistant")return;e.content=t;let i=this.#i?.querySelector("[data-role]:last-child [data-content]");i&&(i.textContent=t),this.#h()}deleteMessage(t){let e=this.#t.findIndex(i=>i.id===t);e!==-1&&(this.#t.splice(e,1),this.#i?.querySelector(`[data-id="${t}"]`)?.remove())}clear(){if(this.#t.length=0,this.#i){let t=this.#r;this.#i.innerHTML="",t&&this.#i.appendChild(t)}this.#o("clear")}startStreaming(){this.streaming=!0,this.#s&&(this.#s.disabled=!0),this.#n&&(this.#n.textContent="Typing..."),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!0)}stopStreaming(){this.streaming=!1,this.#s&&(this.#s.disabled=!1),this.#n&&(this.#n.textContent=""),this.#i?.tagName?.toLowerCase()==="chat-thread"&&(this.#i.streaming=!1),this.#i?.querySelector("[data-role]:last-child [data-cursor]")?.remove();let t=this.#t[this.#t.length-1];if(t?.role==="assistant"&&t.content&&!t.html){let e=this.#i?.querySelector("[data-role]:last-child [data-content]");e&&(e.innerHTML=di(t.content),this.#c(e))}this.#s?.focus()}abort(){this.#e&&(this.#e.abort(),this.#e=null,this.#o("abort")),this.streaming&&this.stopStreaming()}async send(t,e={}){let i=e.model||this.model||this.#s?.model;if(!i)throw new Error("No model specified");this.appendMessage({role:"user",content:t}),this.appendMessage({role:"assistant",content:""}),this.startStreaming(),this.#e=new AbortController;try{let r={provider:this.provider||void 0,apiKey:this.#a||void 0,model:i,system:this.system||void 0,proxyUrl:this.proxyUrl||void 0,thinking:this.thinking||void 0,messages:this.conversation.slice(0,-1),signal:this.#e.signal,...e},n;for(let o of["../../../llm/index.js","../../llm/index.js"])try{({streamChat:n}=await import(new URL(o,import.meta.url).href));break}catch{}if(!n){this.appendMessage({role:"error",content:"@adia-ai/llm is not available \u2014 in a fresh checkout run the packages/llm build (see gh#527/gh#541)."}),this.#o("error",{error:new Error("llm build artifact missing")});return}for await(let o of n(r))o.type==="text"?(this.appendChunk(o.text),this.#o("chunk",{text:o.text,snapshot:o.snapshot})):o.type==="thinking"?this.#o("thinking",{text:o.text}):o.type==="done"?this.#o("done",{text:o.text,usage:o.usage,stopReason:o.stopReason}):o.type==="error"&&(this.appendMessage({role:"error",content:o.error.message}),this.#o("error",{error:o.error}))}catch(r){r.name!=="AbortError"&&(this.appendMessage({role:"error",content:r.message}),this.#o("error",{error:r}))}this.#e=null,this.stopStreaming()}export(){return{messages:this.#t.map(t=>({role:t.role,content:t.content})),model:this.model,system:this.system}}import(t){t.model&&(this.model=t.model),t.system&&(this.system=t.system),t.messages&&(this.conversation=t.messages)}#h(){let t=this.#i;t&&requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}#c(t){for(let e of t.querySelectorAll("pre")){let i=e.querySelector("code");if(!i)continue;let r=i.getAttribute("data-lang")||"",n=document.createElement("code-ui");r&&n.setAttribute("language",r),n.textContent=i.textContent,e.replaceWith(n)}}};y("chat-shell",lh);C();$();var MD=40,hh=class extends v{static properties={streaming:{type:Boolean,default:!1,reflect:!0},empty:{type:Boolean,default:!0,reflect:!0}};static template=()=>null;#t=null;#e=!0;#i=null;connected(){this.#s(),this.#r(),this.#n()}disconnected(){this.#t?.disconnect(),this.#t=null,this.#i&&(this.removeEventListener("scroll",this.#i),this.#i=null)}scrollToBottom(){this.scrollTo({top:this.scrollHeight,behavior:"smooth"})}scrollToBottomInstant(){this.scrollTop=this.scrollHeight}#s(){let e=Array.from(this.children).filter(i=>i.tagName.toLowerCase()!=="chat-empty").length===0;this.empty=e,this.toggleAttribute("empty",e)}#r(){typeof MutationObserver>"u"||(this.#t=new MutationObserver(()=>{this.#s(),this.#e&&this.scrollToBottomInstant()}),this.#t.observe(this,{childList:!0}))}#n(){this.#i=()=>{let t=this.scrollHeight-(this.scrollTop+this.clientHeight);this.#e=t<=MD},this.addEventListener("scroll",this.#i,{passive:!0})}};y("chat-thread",hh);C();$();var ch=class extends v{static properties={disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.#t=this.querySelector("chat-input-ui")||this.querySelector("input-ui")||this.querySelector("textarea-ui"),this.#e=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("composer-submit",{bubbles:!0,detail:t.detail||{}}))},this.#t?.addEventListener("submit",this.#e),this.#i()}disconnected(){this.#t&&this.#e&&this.#t.removeEventListener("submit",this.#e),this.#t=null,this.#e=null}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),t==="disabled"&&this.#i()}focus(){this.#t?.focus?.()}clear(){this.#t?.clear?.()}get input(){return this.#t}#i(){this.#t&&(this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"))}};y("chat-composer",ch);C();$();var uh=96,IE=160,dh=class extends v{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0},name:{type:String,default:"",reflect:!0},minWidth:{type:String,default:"",reflect:!0,attribute:"min-width"}};static template=()=>null;#t="";#e=[];#i=null;connected(){this.#n(),this.resizable&&this.#o(),this.#l(),this.#a()}disconnected(){for(let t of this.#e)t();this.#e=[],this.#i?.disconnect(),this.#i=null}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){if(this.collapsed)return;let t=this.style.width||getComputedStyle(this).width;parseFloat(t)>uh&&(this.#t=t);let e=this.minWidth||getComputedStyle(this).minWidth;this.style.width=e,this.#r(e),this.collapsed=!0,this.#h(!1)}expand(){if(!this.collapsed)return;let t=this.#t||"";this.style.width=t,this.#r(t),this.collapsed=!1,this.#h(!0)}#s(){return`adia-chat-sidebar-${this.name||this.getAttribute("slot")||"default"}`}#r(t){try{localStorage.setItem(this.#s(),t)}catch{}}#n(){try{let t=localStorage.getItem(this.#s());if(!t)return;this.style.width=t;let e=parseFloat(t);!isNaN(e)&&e>uh&&(this.#t=t)}catch{}}#a(){let t=this.getBoundingClientRect().width;this.collapsed=t<=uh}#o(){let t=this.querySelector(":scope > [data-resize]");if(!t)return;let e=this.getAttribute("slot"),i=e==="leading",r=n=>{n.preventDefault(),t.setPointerCapture(n.pointerId);let o=n.clientX,a=this.getBoundingClientRect().width;this.resizing=!0,document.documentElement.style.cursor="col-resize";let l=c=>{let u=c.clientX-o,d=parseInt(getComputedStyle(this).getPropertyValue("max-width"))||480,f=Math.max(48,Math.min(d,a+(i?u:-u)));this.style.width=`${f}px`},h=()=>{this.resizing=!1,document.documentElement.style.cursor="",t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",h);let c=this.getBoundingClientRect().width;c<=uh?this.style.width=this.minWidth||getComputedStyle(this).minWidth:c<IE&&(this.style.width=`${IE}px`),this.#r(this.style.width),this.#a(),this.dispatchEvent(new CustomEvent("sidebar-resize",{bubbles:!0,detail:{name:this.name||e,width:this.getBoundingClientRect().width}}))};t.addEventListener("pointermove",l),t.addEventListener("pointerup",h)};t.addEventListener("pointerdown",r),this.#e.push(()=>t.removeEventListener("pointerdown",r))}#l(){typeof ResizeObserver>"u"||(this.#i=new ResizeObserver(t=>{for(let e of t){let i=e.contentBoxSize[0].inlineSize<=uh;for(let r of this.querySelectorAll("select-ui"))r.setAttribute("placement",i?"right":"bottom-start")}}),this.#i.observe(this))}#h(t){this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:this.name||this.getAttribute("slot")||"default",expanded:t}}))}};y("chat-sidebar",dh);C();$();var fh=class extends v{static properties={};static template=()=>null};y("chat-empty",fh);var RD="Closed.",ID="v1.0";function NO({renderer:s,doc:t=document}){if(!s)throw new Error("createSurfaceRegistry: opts.renderer is required");let e=new Map;function i(h,c){let u=e.get(h);if(u)return u;if(!c)throw new Error(`createSurfaceRegistry.route: no bubble element for fresh surfaceId "${h}"`);let d=t.createElement("div");d.setAttribute("data-surface-root",h),c.appendChild(d);let f=s.attachSurface(h,d),p={surfaceId:h,root:d,handle:f,bubbleEl:c,status:"open"};return e.set(h,p),p}function r(h){let c=t.createElement("div");c.setAttribute("data-surface-closed",h.surfaceId),c.textContent=RD,h.bubbleEl.appendChild(c)}function n(h){let c=e.get(h);if(c)return c.status==="closed"||(s.handleFrame(JSON.stringify({version:ID,deleteSurface:{surfaceId:h}})),c.status="closed",r(c)),c}function o(h,c,u){let d=null;try{d=JSON.parse(c)}catch{}if(d&&Object.hasOwn(d,"deleteSurface")){s.handleFrame(c);let f=e.get(h);return f&&f.status!=="closed"&&(f.status="closed",r(f)),f}return s.handleFrame(c),s.surfaces.has(h)?i(h,u):e.get(h)}function a(h){return e.get(h)}function l(){for(let h of e.values())h.handle.detach();e.clear()}return{route:i,close:n,feed:o,get:a,disposeAll:l,hosts:e}}var qO={sent:"Sending\u2026",started:"Thinking\u2026",reasoning:"Reasoning\u2026",content:"Writing\u2026",validating:"Validating\u2026",retry:"Retrying\u2026",tool:"Using a tool\u2026",done:"Done"};function DD(s){let t=s.surfaces.length,e=s.surfaces.map(i=>`${i.surfaceId} \u2014 ${i.rationale}`).join("; ");return`Planning ${t} surface${t===1?"":"s"}: ${e}`}var qD={new:"New",updated:"Updated",closed:"Closed"};function ND(s){let t=["new","updated","closed"].filter(e=>s[e].length>0).map(e=>`${qD[e]}: ${s[e].join(", ")}`);return t.length?`What changed \u2014 ${t.join(" \xB7 ")}`:"What changed \u2014 nothing this turn"}async function XO(s,t,e){let{events:i,statusEl:r=null,isProgressStage:n=c=>Object.hasOwn(qO,c)}=e??{};if(!i)throw new Error("wireAgentEvents: opts.events (AsyncIterable<AgentEvent>) is required");let o=()=>s.querySelector?.("chat-thread")?.querySelector('[data-role="assistant"]:last-child [data-bubble]')??null,a=null,l=()=>{if(a)return a;let c=o();return c?(a=document.createElement("agent-reasoning-ui"),a.collapsed=!0,c.insertBefore(a,c.firstChild),a):null},h=c=>a?.entries?.find(u=>u.kind==="step"&&u.id===c);for await(let c of i)switch(c.type){case"text":c.text===""?s.setStreamedText?.(c.snapshot??""):s.appendChunk?.(c.text);break;case"progress":{if(!n(c.stage))break;r&&(r.textContent=qO[c.stage]??"");break}case"surface":{let u=o();t.feed(c.surfaceId,c.line,u);break}case"step":{if(c.workflow==="plan"&&c.step==="manifest")s.appendMessage?.({role:"assistant",content:DD(c.data),render:!0}),s.appendMessage?.({role:"assistant",content:""});else if(c.workflow==="plan"&&c.step==="synthesis")s.appendMessage?.({role:"assistant",content:ND(c.data),render:!0}),s.appendMessage?.({role:"assistant",content:""});else{let u=l();if(u){let d=`${c.workflow}:${c.step}:${c.data?.round??1}`,f=`${c.workflow}: ${c.step}`;u.addStep({id:d,label:f}),c.data?.accepted?u.completeStep(d):u.failStep(d,c.data?.reason??"fell through")}}break}case"tool_use":{let u=l();if(u){let d=`${c.name}(${JSON.stringify(c.input)})`;h(c.id)?u.updateStep(c.id,{label:d}):u.addStep({id:c.id,label:d})}break}case"tool_input_delta":{let u=l();if(u){let d=`${c.name}(${c.partial})`;h(c.id)?u.updateStep(c.id,{label:d}):u.addStep({id:c.id,label:d})}break}case"tool_result":{let u=l();if(u){let d=String(c.output).slice(0,300);c.isError?u.failStep(c.id,d):(u.updateStep(c.id,{outcomes:[d]}),u.completeStep(c.id))}break}case"guardrail":{let u=l(),d=c.action==="deny"?"blocked":"rewrote",f=c.toolName?`tool call "${c.toolName}"`:"the response";u?.addThought?.(`Guardrail "${c.name}" ${d} ${f}${c.reason?` \u2014 ${c.reason}`:""}`);break}case"thinking":{l()?.addThought?.(c.text);break}case"error":a?.fail?.(c.error?.message??String(c.error)),s.appendMessage?.({role:"error",content:c.error?.message??String(c.error)}),s.stopStreaming?.();break;case"done":a&&(c.stopReason==="guardrail_denied"?a.fail("Blocked by guardrail"):a.finish()),s.stopStreaming?.();break;default:break}s.streaming&&s.stopStreaming?.()}C();$();var ph=class extends v{static properties={focusMode:{type:Boolean,default:!1,reflect:!0,attribute:"focus-mode"}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.#t=this.querySelector("editor-toolbar"),this.#e=this.querySelector("editor-canvas"),this.#s(),this.#i=t=>{let e=t?.detail?.name;e&&(e==="toggle-focus"||e==="full-screen")&&this.toggleFocusMode()},this.addEventListener("toolbar-action",this.#i)}disconnected(){this.#i&&this.removeEventListener("toolbar-action",this.#i),this.#i=null}toggleFocusMode(){this.focusMode=!this.focusMode,this.#t?.tagName?.toLowerCase()==="editor-toolbar"&&(this.#t.fullScreen=this.focusMode),this.#e?.tagName?.toLowerCase()==="editor-canvas"&&(this.focusMode?this.#e.focus?.():this.#e.blur?.()),this.dispatchEvent(new CustomEvent("editor-mode-change",{bubbles:!0,detail:{focusMode:this.focusMode}}))}#s(){for(let t of this.querySelectorAll("select-ui[data-options]"))try{let e=JSON.parse(t.getAttribute("data-options"));t.options=e}catch{}}};y("editor-shell",ph);C();$();var mh=class extends v{static properties={fullScreen:{type:Boolean,default:!1,reflect:!0,attribute:"full-screen"}};static template=()=>null;#t=null;connected(){this.#t=t=>{let e=t.target.closest("[data-toolbar-action]");if(!e||!this.contains(e))return;let i=e.getAttribute("data-toolbar-action");this.dispatchEvent(new CustomEvent("toolbar-action",{bubbles:!0,detail:{name:i}}))},this.addEventListener("click",this.#t)}disconnected(){this.#t&&this.removeEventListener("click",this.#t),this.#t=null}};y("editor-toolbar",mh);C();$();var gh=class extends v{static properties={empty:{type:Boolean,default:!0,reflect:!0},focused:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=1;#e=null;connected(){this.#i(),this.#s()}disconnected(){this.#e?.disconnect(),this.#e=null}get zoom(){return this.#t}set zoom(t){let e=parseFloat(t);!isFinite(e)||e<=0||(this.#t=e,this.style.setProperty("--editor-canvas-zoom",String(e)))}resetView(){this.zoom=1}focus(){super.focus?.(),this.focused=!0}blur(){super.blur?.(),this.focused=!1}#i(){let t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()!=="editor-canvas-empty");this.empty=t.length===0}#s(){typeof MutationObserver>"u"||(this.#e=new MutationObserver(()=>{this.#i()}),this.#e.observe(this,{childList:!0}))}};y("editor-canvas",gh);C();$();var bh=96,XD="adia-editor-sidebar-",Oh=class extends v{static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizing:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=!1;#l=null;connected(){if(this.#t=this.querySelector("pane-ui"),!this.#t)return;let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.#i=`${XD}${e}`,this.#m(),typeof ResizeObserver<"u"&&(this.#e=new ResizeObserver(i=>{if(getComputedStyle(this).display==="none")return;this.#d();let r=this.#t.offsetWidth;r>0&&(this.style.width=`${r}px`)}),this.#e.observe(this.#t)),this.#s=i=>{i.target?.closest?.('[slot="resize"], [data-resize], [class*="handle"]')&&(this.resizing=!0)},this.#t.addEventListener("pointerdown",this.#s),this.#r=()=>{this.resizing&&(this.resizing=!1),this.#f()},document.addEventListener("pointerup",this.#r),this.#n=i=>{i.target!==this.#t||i.propertyName!=="width"||(this.#c(),this.#d())},this.#t.addEventListener("transitionend",this.#n)}disconnected(){this.#a!==null&&(cancelAnimationFrame(this.#a),this.#a=null),this.#l!==null&&(clearTimeout(this.#l),this.#l=null),this.#e?.disconnect(),this.#e=null,this.#s&&this.#t&&(this.#t.removeEventListener("pointerdown",this.#s),this.#s=null),this.#r&&(document.removeEventListener("pointerup",this.#r),this.#r=null),this.#n&&this.#t&&(this.#t.removeEventListener("transitionend",this.#n),this.#n=null)}toggle(){return this.collapsed?this.expand():this.collapse(),this.collapsed}collapse(){this.#t&&(this.collapsed||this.#f(),this.#t.style.width=`${bh}px`,this.collapsed=!0,this.#u())}expand(){if(!this.#t)return;let t=this.#p(),e=t&&t>bh?t:240;this.#t.style.width=`${e}px`,this.collapsed=!1,this.#f(),this.#u(),this.#h()}#h(){this.#l!==null&&(clearTimeout(this.#l),this.#l=null);let t=getComputedStyle(this.#t).transitionDuration.split(",")[0].trim(),e=(parseFloat(t)||0)*(t.endsWith("ms")?1:1e3);e<=0||(this.#o=!0,this.#l=setTimeout(()=>{this.#l=null,this.#c(),this.#d()},e+50))}#c(){this.#o=!1,this.#l!==null&&(clearTimeout(this.#l),this.#l=null)}#d(){if(!this.#t||getComputedStyle(this).display==="none")return;let t=this.#t.getBoundingClientRect();if(t.width!==0){if(t.width>bh){this.#a!==null&&(cancelAnimationFrame(this.#a),this.#a=null),this.collapsed=!1;return}this.#o||this.#a===null&&(this.#a=requestAnimationFrame(()=>{if(this.#a=null,!this.#t||getComputedStyle(this).display==="none"||this.#o)return;let e=this.#t.getBoundingClientRect();e.width>0&&e.width<=bh&&(this.collapsed=!0)}))}}#u(){let t=this.getAttribute("slot")||"leading",e=this.getAttribute("persist")||this.getAttribute("name")||t;this.dispatchEvent(new CustomEvent("sidebar-toggle",{bubbles:!0,detail:{name:e,expanded:!this.collapsed}}))}#f(){if(!(!this.#t||!this.#i))try{let t=this.#t.style.width||"";t&&localStorage.setItem(this.#i,t)}catch{}}#p(){if(!this.#i)return null;try{let t=localStorage.getItem(this.#i);if(!t)return null;let e=parseFloat(t);return isFinite(e)?e:null}catch{return null}}#m(){if(!this.#t)return;let t=this.#p();t&&t>0&&(this.#t.style.width=`${t}px`,this.collapsed=t<=bh)}};y("editor-sidebar",Oh);function BD(){let s=document.activeElement;if(!s)return!1;let t=s.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||s.isContentEditable||t==="INPUT-UI"||t==="TEXTAREA-UI"||t==="OTP-INPUT-UI"||t==="SEARCH-UI")}$();var yh=class extends v{static properties={centered:{type:Boolean,default:!1,reflect:!0},"full-bleed":{type:Boolean,default:!1,reflect:!0}};static template=()=>null};customElements.get("simple-shell")||customElements.define("simple-shell",yh);C();$();var Nd=class extends v{static properties={mode:{type:String,default:"chat",reflect:!0},inspector:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=null;connected(){}render(){this.#t||(this.#t=!0,this.#e=document.createElement("chat-thread-ui"),this.#i=document.createElement("canvas-ui"),this.appendChild(this.#e),this.appendChild(this.#i),this.inspector&&(this.#s=document.createElement("inspector-ui"),this.appendChild(this.#s)))}appendMessage(t){this.#e?.appendMessage(t)}appendCoT(t){this.#e?.appendCoT(t)}pushArtifact(t){this.mode==="chat"&&(this.mode="split"),this.#i?.processAll(t)}setSuggestions(t){this.#e?.setSuggestions(t)}appendResultMessage(t){this.#e?.appendResultMessage(t)}showSavePatternBar(t){this.#e?.showSavePatternBar(t)}showFeedbackWidget(t){this.#e?.showFeedbackWidget(t)}showTyping(){this.#e?.showTyping()}hideTyping(){this.#e?.hideTyping()}appendError(t){this.#e?.appendError(t)}startPipelineStatus(){return this.#e?.startPipelineStatus()}updatePipelineStatus(t){this.#e?.updatePipelineStatus(t)}completePipelineStatus(){this.#e?.completePipelineStatus()}reset(){this.#e?.clear(),this.#i?.reset(),this.mode="chat"}get thread(){return this.#e}get canvas(){return this.#i}get inspect(){return this.#s}};y("gen-root",Nd);MO();C();$();var ZD=["atlas","signal","terrarium","ledger","arcade","meridian","solstice","glacier","ember","botanica","vector","velour"],zD={compact:{density:.85,radius:.75},default:{density:1,radius:1},spacious:{density:1.15,radius:1.25}},BO=["","ui-sm","ui-md","ui-lg","content-sm","content-md","content-lg"],DE=s=>s.length?s[0].toUpperCase()+s.slice(1):s,vh=class extends v{static properties={themes:{type:String,default:ZD.join(" "),reflect:!0},parametric:{type:Boolean,default:!1,reflect:!0},presets:{type:Boolean,default:!1,reflect:!0},schemeToggle:{type:Boolean,default:!1,reflect:!0,attribute:"scheme-toggle"},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},target:{type:String,default:":root",reflect:!0},scheme:{type:String,default:"auto",reflect:!0},activeTheme:{type:String,default:"",reflect:!0,attribute:"active-theme"},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"},activeDensity:{type:String,default:"",reflect:!0,attribute:"active-density"},activeRadius:{type:String,default:"",reflect:!0,attribute:"active-radius"},register:{type:Boolean,default:!1,reflect:!0},activeScale:{type:String,default:"",reflect:!0,attribute:"active-scale"}};static template=()=>null;#t=null;#e=null;#i=[];#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#h=!1;connected(){this.#h||(this.#c(),this.#h=!0,this.#w(),this.#g(),this.#O())}disconnected(){for(let t of this.#i)t();this.#i=[],this.#v(),this.parametric&&this.#x().removeAttribute("data-parametric-scope")}apply(t={}){this.#p(t,"programmatic")}reset(){let t=this.#x();if(t.removeAttribute("theme"),t.style.removeProperty("--a-density"),t.style.removeProperty("--a-radius-k"),t.style.removeProperty("color-scheme"),t.removeAttribute("scale"),this.persist)for(let e of["theme","scheme","density","radius","scale"])try{localStorage.removeItem(`${this.storagePrefix}${e}`)}catch{}this.activeTheme="",this.activeDensity="",this.activeRadius="",this.activeScale="",this.scheme="auto",this.activeScheme=this.#b(),this.#n&&(this.#n.value="auto"),this.#s&&(this.#s.value=1),this.#r&&(this.#r.value=1),this.#a&&(this.#a.value=""),this.#o&&(this.#o.value=""),this.#m("reset")}#c(){let t=document.createDocumentFragment();if(this.schemeToggle){let o=document.createElement("div");o.setAttribute("part","scheme");let a=document.createElement("segmented-ui");a.id=`${this.#A}-scheme`;let l=document.createElement("segment-ui");l.setAttribute("value","auto"),l.setAttribute("text","System");let h=document.createElement("segment-ui");h.setAttribute("value","light"),h.setAttribute("text","Light");let c=document.createElement("segment-ui");c.setAttribute("value","dark"),c.setAttribute("text","Dark"),a.append(l,h,c),o.appendChild(a),t.appendChild(o),this.#n=a}let e=(this.themes||"").trim().split(/\s+/).filter(Boolean);if(e.length){let o=document.createElement("div");o.setAttribute("part","theme-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Theme",o.appendChild(a);let l=document.createElement("select-ui");l.setAttribute("part","themes"),l.setAttribute("size","sm"),l.id=`${this.#A}-theme`;let h=(c,u)=>{let d=document.createElement("option");return d.value=c,d.textContent=u,d};l.append(h("","Default"),...e.map(c=>h(c,DE(c)))),l.setAttribute("value",""),o.appendChild(l),t.appendChild(o),this.#o=l}if(this.parametric){t.appendChild(document.createElement("divider-ui"));let o=document.createElement("text-ui");o.setAttribute("variant","label"),o.textContent="Parametric",t.appendChild(o);let a=document.createElement("slider-ui");a.setAttribute("part","density"),a.setAttribute("label","Density"),a.setAttribute("value","1"),a.setAttribute("min","0.5"),a.setAttribute("max","1.5"),a.setAttribute("step","0.05"),a.setAttribute("suffix","\xD7"),t.appendChild(a),this.#s=a;let l=document.createElement("slider-ui");l.setAttribute("part","radius"),l.setAttribute("label","Radius"),l.setAttribute("value","1"),l.setAttribute("min","0"),l.setAttribute("max","2"),l.setAttribute("step","0.1"),l.setAttribute("suffix","\xD7"),t.appendChild(l),this.#r=l}if(this.presets||this.register){if(t.appendChild(document.createElement("divider-ui")),this.presets){let o=document.createElement("div");o.setAttribute("part","preset-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Preset",o.appendChild(a);let l=document.createElement("div");l.setAttribute("part","presets");for(let h of["compact","default","spacious"]){let c=document.createElement("button-ui");c.setAttribute("data-preset",h),c.setAttribute("text",DE(h)),c.setAttribute("variant","outline"),c.setAttribute("size","sm"),l.appendChild(c)}o.appendChild(l),t.appendChild(o)}if(this.register){let o=document.createElement("div");o.setAttribute("part","preset-row");let a=document.createElement("text-ui");a.setAttribute("variant","label"),a.textContent="Scale",o.appendChild(a);let l=document.createElement("select-ui");l.setAttribute("part","scale"),l.setAttribute("size","sm"),l.id=`${this.#A}-scale`,l.innerHTML=BO.map(h=>`<option value="${h}">${h||"Default"}</option>`).join(""),l.setAttribute("value",""),o.appendChild(l),t.appendChild(o),this.#a=l}}t.appendChild(document.createElement("divider-ui"));let i=document.createElement("div");i.setAttribute("part","reset-row");let r=document.createElement("button-ui");r.setAttribute("part","reset"),r.setAttribute("text","Reset"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),i.appendChild(r),t.appendChild(i),this.#l=r;let n=document.createElement("theme-provider");n.setAttribute("scale","ui-md"),n.appendChild(t),this.appendChild(n),this.#d()}#d(){if(this.#o){let t=e=>{let i=e.detail?.value??this.#o.value;this.#u(i)};this.#o.addEventListener("change",t),this.#i.push(()=>this.#o.removeEventListener("change",t))}if(this.#l){let t=()=>this.reset();this.#l.addEventListener("press",t),this.#l.addEventListener("click",t),this.#i.push(()=>{this.#l.removeEventListener("press",t),this.#l.removeEventListener("click",t)})}if(this.#s){let t=()=>this.#p({density:parseFloat(this.#s.value)},"slider");this.#s.addEventListener("input",t),this.#i.push(()=>this.#s.removeEventListener("input",t))}if(this.#r){let t=()=>this.#p({radius:parseFloat(this.#r.value)},"slider");this.#r.addEventListener("input",t),this.#i.push(()=>this.#r.removeEventListener("input",t))}for(let t of this.querySelectorAll('[part="presets"] button-ui')){let e=t.getAttribute("data-preset"),i=()=>this.#f(e);t.addEventListener("press",i),t.addEventListener("click",i),this.#i.push(()=>{t.removeEventListener("press",i),t.removeEventListener("click",i)})}if(this.#n){let t=e=>{let i=e.detail?.value??this.#n.value;(i==="light"||i==="dark"||i==="auto")&&this.#p({scheme:i},"scheme")};this.#n.addEventListener("change",t),this.#i.push(()=>this.#n.removeEventListener("change",t))}if(this.#a){let t=e=>{let i=e.detail?.value??this.#a.value;this.#p({scale:i},"scale")};this.#a.addEventListener("change",t),this.#i.push(()=>this.#a.removeEventListener("change",t))}}#u(t){let e=this.#x();if(e.style.removeProperty("--a-density"),e.style.removeProperty("--a-radius-k"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}density`),localStorage.removeItem(`${this.storagePrefix}radius`)}catch{}this.#p({theme:t},"theme"),this.#s&&(this.#s.value=1),this.#r&&(this.#r.value=1),this.activeDensity="",this.activeRadius=""}#f(t){let e=zD[t];e&&(this.#p({density:e.density,radius:e.radius},"preset"),this.#s&&(this.#s.value=e.density),this.#r&&(this.#r.value=e.radius))}#p(t,e){let i=this.#x();if(t.theme!==void 0){if(t.theme===""||t.theme==="default"?(i.removeAttribute("theme"),this.activeTheme=""):(i.setAttribute("theme",t.theme),this.activeTheme=t.theme),this.persist)try{this.activeTheme?localStorage.setItem(`${this.storagePrefix}theme`,this.activeTheme):localStorage.removeItem(`${this.storagePrefix}theme`)}catch{}this.#o&&(this.#o.value=this.activeTheme)}if(t.density!==void 0&&(i.style.setProperty("--a-density",t.density),this.activeDensity=String(t.density),this.persist))try{localStorage.setItem(`${this.storagePrefix}density`,String(t.density))}catch{}if(t.radius!==void 0&&(i.style.setProperty("--a-radius-k",t.radius),this.activeRadius=String(t.radius),this.persist))try{localStorage.setItem(`${this.storagePrefix}radius`,String(t.radius))}catch{}if(t.scheme!==void 0){let r=t.scheme;if(r==="auto"){if(i.style.removeProperty("color-scheme"),this.scheme="auto",this.activeScheme=this.#b(),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}this.#S()}else if(r==="light"||r==="dark"){if(i.style.setProperty("color-scheme",r),this.scheme=r,this.activeScheme=r,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,r)}catch{}this.#v()}this.#n&&(this.#n.value=this.scheme)}if(t.scale!==void 0){let r=t.scale;if(r&&BO.includes(r)?(i.setAttribute("scale",r),this.activeScale=r):(i.removeAttribute("scale"),this.activeScale=""),this.persist)try{this.activeScale?localStorage.setItem(`${this.storagePrefix}scale`,this.activeScale):localStorage.removeItem(`${this.storagePrefix}scale`)}catch{}this.#a&&(this.#a.value=this.activeScale)}this.#m(e)}#m(t){this.dispatchEvent(new CustomEvent("theme-change",{bubbles:!0,detail:{theme:this.activeTheme,scheme:this.activeScheme,density:this.activeDensity?parseFloat(this.activeDensity):1,radius:this.activeRadius?parseFloat(this.activeRadius):1,scale:this.activeScale,source:t}}))}#g(){let t=this.#x(),e,i,r,n,o;if(this.persist)try{e=localStorage.getItem(`${this.storagePrefix}theme`)||"",i=localStorage.getItem(`${this.storagePrefix}scheme`)||"";let a=localStorage.getItem(`${this.storagePrefix}density`),l=localStorage.getItem(`${this.storagePrefix}radius`);r=a!=null?parseFloat(a):void 0,n=l!=null?parseFloat(l):void 0,o=localStorage.getItem(`${this.storagePrefix}scale`)||""}catch{}if(e?(t.setAttribute("theme",e),this.activeTheme=e):this.activeTheme=t.getAttribute("theme")||"",this.#o&&(this.#o.value=this.activeTheme),i==="light"||i==="dark")t.style.setProperty("color-scheme",i),this.scheme=i,this.activeScheme=i,this.#n&&(this.#n.value=i);else{let a=this.scheme||"auto";a==="light"||a==="dark"?(t.style.setProperty("color-scheme",a),this.activeScheme=a):(this.scheme="auto",this.activeScheme=this.#b()),this.#n&&(this.#n.value=this.scheme)}if(r!=null&&!Number.isNaN(r))t.style.setProperty("--a-density",r),this.activeDensity=String(r),this.#s&&(this.#s.value=r);else if(this.#s){let a=this.#y(t,"--a-density");this.#s.value=a,this.activeDensity=String(a)}if(n!=null&&!Number.isNaN(n))t.style.setProperty("--a-radius-k",n),this.activeRadius=String(n),this.#r&&(this.#r.value=n);else if(this.#r){let a=this.#y(t,"--a-radius-k");this.#r.value=a,this.activeRadius=String(a)}if(this.#a){let a=BO.includes(o)?o:t.getAttribute("scale")||"";a&&t.setAttribute("scale",a),this.#a.value=a,this.activeScale=a}}#y(t,e){let i=getComputedStyle(t);return parseFloat(i.getPropertyValue(e))||1}#b(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}#O(){if(this.scheme==="auto"){if(this.persist)try{let t=localStorage.getItem(`${this.storagePrefix}scheme`);if(t==="light"||t==="dark")return}catch{}this.#S()}}#S(){if(!(this.#t||typeof matchMedia!="function"))try{this.#t=matchMedia("(prefers-color-scheme: dark)"),this.#e=()=>{let t=this.#t.matches?"dark":"light";this.activeScheme=t,this.#n&&(this.#n.value="auto"),this.#m("scheme")},this.#t.addEventListener("change",this.#e)}catch{}}#v(){if(this.#t&&this.#e)try{this.#t.removeEventListener("change",this.#e)}catch{}this.#t=null,this.#e=null}#x(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#w(){let t=this.#x();t!==document.documentElement&&(this.parametric?t.setAttribute("data-parametric-scope",""):t.removeAttribute("data-parametric-scope"))}get#A(){return this.id||"theme-panel"}};y("theme-panel",vh);$();var qE=["change","input"],xh=class extends v{static properties={label:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0}};static template=()=>null;#t=!1;#e=null;#i=null;#s=null;#r=()=>this.#d();#n=()=>{!this.#e||!this.#s||this.#e.setAttribute("aria-expanded",String(this.#s.hasAttribute("open")))};#a=null;#o=null;connected(){this.#t||(this.#l(),this.#t=!0);for(let t of qE)this.addEventListener(t,this.#r);this.#i&&!this.#o&&(this.#o=new MutationObserver(this.#r),this.#o.observe(this.#i,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["checked"]})),this.#s&&!this.#a&&(this.#a=new MutationObserver(this.#n),this.#a.observe(this.#s,{attributes:!0,attributeFilter:["open"]})),this.#d()}disconnected(){for(let t of qE)this.removeEventListener(t,this.#r);this.#o?.disconnect(),this.#o=null,this.#a?.disconnect(),this.#a=null}updated(t){this.#t&&(t.has("label")&&this.#d(),t.has("heading")&&this.#h(),t.has("placement")&&this.querySelector(":scope > popover-ui")?.setAttribute("placement",this.placement))}get summary(){let t=this.#i?this.#i.querySelectorAll("check-ui"):[],e=[];for(let i of t)(i.hasAttribute("checked")||i.checked)&&e.push(i);return{selected:e.length,total:t.length,checked:e}}#l(){let t=document.createDocumentFragment();for(;this.firstChild;)t.appendChild(this.firstChild);let e=document.createElement("popover-ui");e.setAttribute("placement",this.placement),e.setAttribute("match-width",""),this.#s=e;let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("data-form-popover-trigger",""),i.setAttribute("icon-trailing","caret-down"),i.setAttribute("aria-haspopup","dialog"),i.setAttribute("aria-expanded","false"),this.#e=i,e.appendChild(i);let r=document.createElement("div");r.setAttribute("slot","content"),r.setAttribute("data-form-popover-body",""),r.appendChild(t),this.#i=r,e.appendChild(r),this.appendChild(e),this.#h()}#h(){if(!this.#i)return;let t=this.#i.querySelector(":scope > [data-form-popover-heading]");if(!this.heading){t?.remove();return}t||(t=document.createElement("div"),t.setAttribute("data-form-popover-heading",""),this.#i.prepend(t)),t.textContent=this.heading}#c(t){return(t.getAttribute("label")||t.label||t.textContent||"").trim()}#d(){if(!this.#e)return;let{selected:t,total:e,checked:i}=this.summary,r=this.label;t===1&&i[0]?r=this.#c(i[0])||r:t>1&&(r=r?`${r} (${t})`:`${t}`),r||(r="Options"),this.#e.setAttribute("text",r),this.dispatchEvent(new CustomEvent("summary-change",{bubbles:!0,detail:{selected:t,total:e}}))}};customElements.get("form-popover-ui")||customElements.define("form-popover-ui",xh);$();var Sh=class extends v{static properties={items:{type:Array,default:[]},"storage-key":{type:String,default:"",reflect:!0},storage:{type:String,default:"local",reflect:!0},"dismiss-on-complete":{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},value:{type:Object,default:{}},title:{type:String,default:"Get started",reflect:!0}};static template=t=>t._renderTemplate();#t=`obc-h-${Math.random().toString(36).slice(2,8)}`;#e=`obc-l-${Math.random().toString(36).slice(2,8)}`;#i=!1;#s=!1;#r=null;#n=null;attributeChangedCallback(t,e,i){if(t==="items"||t==="value"){if(i==null)this[t]=t==="items"?[]:{};else try{let r=JSON.parse(i);this[t]=r}catch{this[t]=t==="items"?[]:{}}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#t),this.hasAttribute("items")&&!Array.isArray(this.items))try{this.items=JSON.parse(this.getAttribute("items"))}catch{this.items=[]}if(this.hasAttribute("value")&&(typeof this.value!="object"||Array.isArray(this.value)))try{this.value=JSON.parse(this.getAttribute("value"))}catch{this.value={}}if(this.#i=this.value&&Object.keys(this.value).length>0,!this.#i){let t=this.#S();t&&(this.value=t)}this.#r=this.#o.bind(this),this.#n=this.#l.bind(this),this.addEventListener("change",this.#r),this.addEventListener("click",this.#n),this.#s=this.#p(),this.#m()}disconnected(){this.#r&&this.removeEventListener("change",this.#r),this.#n&&this.removeEventListener("click",this.#n),this.#r=null,this.#n=null,this.#v()}render(){this.#m(),this.#b(),this.#g()}_renderTemplate(){let t=Array.isArray(this.items)?this.items:[],{done:e,total:i,percent:r}=this.#f(),n=this.collapsed?"Expand":"Collapse",o=this.collapsed?"chevron-down":"chevron-up",a=!!this.collapsible,l=this.title||"Get started",h=i>0&&e===i;return Y`
@@ -457,7 +457,7 @@ Correct shape for <chart-ui x="label" y="value">:
457
457
  `}#o(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-check]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"";if(!r)return;let n=this.#d(r),o=!!i.checked;n!==o&&this.#u(r,o,{emit:o})}#l(t){let e=t.target;if(!e||!e.closest)return;let i=e.closest("[data-step-action]");if(!i||!this.contains(i))return;let r=i.getAttribute("data-step-id")||"",n=i.getAttribute("data-href")||"";r&&this.dispatchEvent(new CustomEvent("onboarding-step-action",{bubbles:!0,detail:{id:r,href:n}}))}#h(t){t?.stopPropagation?.();let e=!this.collapsed;this.collapsed=e,e&&this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"collapsed"}}))}#c(t){if(!t)return!1;let e=t.id;return e!=null&&Object.prototype.hasOwnProperty.call(this.value||{},e)?!!this.value[e]:!!t.done}#d(t){let i=(Array.isArray(this.items)?this.items:[]).find(r=>r&&String(r.id)===String(t));return this.#c(i)}#u(t,e,{emit:i=!0}={}){let r={...this.value||{},[t]:!!e};this.value=r,this.#v(),i&&e&&this.dispatchEvent(new CustomEvent("onboarding-step-complete",{bubbles:!0,detail:{id:t,value:r}}))}#f(){let t=Array.isArray(this.items)?this.items:[],e=t.length,i=0;for(let n of t)this.#c(n)&&i++;let r=e===0?0:Math.round(i/e*100);return{done:i,total:e,percent:r}}#p(){let{done:t,total:e}=this.#f();return e>0&&t===e}#m(){this.#p()?this.setAttribute("data-complete",""):this.removeAttribute("data-complete")}#g(){let t=this.#p();t&&!this.#s?(this.#s=!0,this.dispatchEvent(new CustomEvent("onboarding-complete",{bubbles:!0,detail:{value:this.value}})),this["dismiss-on-complete"]&&this.#y("complete")):t||(this.#s=!1)}#y(t="user"){this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:t}}))}#b(){}#O(){if(this.#i||this.storage==="none"||!this["storage-key"]||typeof window>"u")return null;try{return this.storage==="session"?window.sessionStorage:window.localStorage}catch{return null}}#S(){let t=this.#O();if(!t)return null;try{let e=t.getItem(this["storage-key"]);if(!e)return null;let i=JSON.parse(e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}#v(){let t=this.#O();if(t)try{t.setItem(this["storage-key"],JSON.stringify(this.value||{}))}catch{}}complete(t){if(t==null)return;let e=String(t);this.#d(e)||this.#u(e,!0,{emit:!0})}reset(t){if(t==null){this.value={};let i=this.#O();try{i?.removeItem(this["storage-key"])}catch{}this.#s=!1,this.removeAttribute("hidden");return}let e=String(t);Object.prototype.hasOwnProperty.call(this.value||{},e)&&this.#u(e,!1,{emit:!1})}progress(){return this.#f()}};customElements.get("onboarding-checklist-ui")||customElements.define("onboarding-checklist-ui",Sh);$();Pt();var ZO=new Set(["","comfortable","compact","spacious"]),zO=new Set(["2","3","4","5","6"]),NE=new Set(["","2","2:1","3:2","3:1"]),_O=["toolbar","kpis","charts","table","aside"],Xd=class extends v{static get properties(){return{density:{type:String,default:"",reflect:!0},"kpi-columns":{type:String,default:"4",reflect:!0,attribute:"kpi-columns"},"chart-split":{type:String,default:"",reflect:!0,attribute:"chart-split"},loading:{type:Boolean,default:!1,reflect:!0},gap:{type:String,default:"",reflect:!0}}}static template=()=>null;#t={toolbar:!1,kpis:!1,charts:!1,table:!1,aside:!1};#e=null;#i=!1;setDensity(t){let e=ZO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return _O.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),H(()=>this.#s()),this.#r(),this.#n(),this.#a(),typeof MutationObserver<"u"&&(this.#e=new MutationObserver(t=>this.#o(t)),this.#e.observe(this,{childList:!0}))}disconnected(){this.#e&&(this.#e.disconnect(),this.#e=null)}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!this.#i){if(t==="density"&&e!==i){if(!ZO.has(i)){this.#i=!0;try{this.density=""}finally{this.#i=!1}return}this.isConnected&&this.dispatchEvent(new CustomEvent("density-change",{bubbles:!0,detail:{density:i}}));return}if(t==="kpi-columns"&&e!==i){if(i!=null&&!zO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...zO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!NE.has(i)){console.warn(`[dashboard-layout-ui] chart-split="${i}" not in enum \u2014 falling back to "" (single column). Use one of: "" (full), 2, 2:1, 3:2, 3:1.`),this.#i=!0;try{this["chart-split"]=""}finally{this.#i=!1}}return}if(t==="loading"&&e!==i){this.#r();return}if(t==="gap"&&e!==i){this.#n();return}}}#s(){if(!ZO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!zO.has(this["kpi-columns"])){console.warn(`[dashboard-layout-ui] kpi-columns="${this["kpi-columns"]}" out of range \u2014 clamping to "4".`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}if(!NE.has(this["chart-split"])){console.warn(`[dashboard-layout-ui] chart-split="${this["chart-split"]}" not in enum \u2014 clamping to "".`),this.#i=!0;try{this["chart-split"]=""}finally{this.#i=!1}}}#r(){this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy")}#n(){let t=(this.gap||"").trim();if(t===""){this.style.removeProperty("--dashboard-layout-gap");return}/^[1-6]$/.test(t)?this.style.setProperty("--dashboard-layout-gap",`var(--a-space-${t})`):this.style.setProperty("--dashboard-layout-gap",t)}#a(){for(let t of _O)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of _O){let i=this.#t[e],r=!!this.querySelector(`:scope > [slot="${e}"]`);i&&!r&&this.dispatchEvent(new CustomEvent("region-empty",{bubbles:!0,detail:{region:e}})),this.#t[e]=r}}};customElements.get("dashboard-layout-ui")||customElements.define("dashboard-layout-ui",Xd);Pt();var ir=new Set,XE=!1;function BE(s){return String(s).padStart(2,"0")}function Bd(s){return`${s.getFullYear()}-${BE(s.getMonth()+1)}-${BE(s.getDate())}`}function ZE(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}var zE={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},sr=new Set(Object.keys(zE));function wh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=Bd(e),r=n=>{let o=new Date(e);return o.setDate(o.getDate()-n),Bd(o)};switch(s){case"today":return{from:i,to:i};case"7d":return{from:r(6),to:i};case"30d":return{from:r(29),to:i};case"90d":return{from:r(89),to:i};case"qtd":{let n=Math.floor(e.getMonth()/3)*3;return{from:Bd(new Date(e.getFullYear(),n,1)),to:i}}case"ytd":return{from:Bd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function _D(s,t){let e=ZE(s),i=ZE(t);if(!e||!i)return"";let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=e.getFullYear()===i.getFullYear(),o=n&&e.getMonth()===i.getMonth();return n&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()?`${r[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`:o?`${r[e.getMonth()]} ${e.getDate()} \u2013 ${i.getDate()}, ${i.getFullYear()}`:n?`${r[e.getMonth()]} ${e.getDate()} \u2013 ${r[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`:`${r[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()} \u2013 ${r[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`}var Zd=class s extends R{static labelDeprecated=!0;static get properties(){return{...R.properties,value:{type:String,default:"7d",reflect:!0},from:{type:String,default:"",reflect:!0},to:{type:String,default:"",reflect:!0},presets:{type:String,default:"today,7d,30d,90d,qtd,ytd,custom"},broadcast:{type:String,default:"document",reflect:!0},ariaLabelAttr:{type:String,default:"Time period",attribute:"aria-label",reflect:!0},pickerOpen:{type:Boolean,default:!1,attribute:"picker-open",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n={prefix:null,chips:null,picker:null,readout:null,suffix:null};#a=!1;#o=!1;static#l=new WeakSet;setRange(t,e,i){if(t==="custom"){if(!e||!i){console.warn('[date-range-selector-ui] setRange("custom", \u2026) requires from + to ISO dates.');return}let n=this.#p(e,i);this.#u("custom",n.from,n.to);return}if(!sr.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...sr].join(", ")}.`);return}let r=wh(t);r&&this.#u(t,r.from,r.to)}getRange(){return{value:this.value,preset:this.value,from:this.from,to:this.to}}subscribe(t){let e=this.#g();return e?(e.addEventListener("range-change",t),()=>e.removeEventListener("range-change",t)):()=>{}}connected(){super.connected(),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.ariaLabelAttr||"Time period"),this.#t||(this.#h(),this.#d(),this.#t=!0),this.broadcast==="document"&&this.#O(),H(()=>{let t=this.#m();t&&this.#u(this.value,t.from,t.to,{initial:!0})})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0,this.#S()}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#o)){if(t==="presets"){this.#c();return}if(t==="broadcast"){e==="document"&&i!=="document"&&this.#S(),i==="document"?(this.#O(),this.#b()):i==="self"&&this.#b();return}if(t==="value"&&e!==i&&i&&sr.has(i)){if(i!=="custom"){let r=wh(i);r&&this.#u(i,r.from,r.to)}return}}}syncValue(t){let e=this.from&&this.to?`${this.from}:${this.to}`:"";this.internals.setFormValue(e)}render(){if(this.#t){if(this.#i&&this.#i.value!==this.value&&(this.#i.value=this.value),this.#s){this.hasAttribute("min")&&this.#s.setAttribute("min",this.getAttribute("min")),this.hasAttribute("max")&&this.#s.setAttribute("max",this.getAttribute("max"));let t=this.from&&this.to?JSON.stringify({from:this.from,to:this.to}):"";this.#s.value!==t&&(this.#s.value=t)}if(this.#r){let t=_D(this.from,this.to);this.#r.textContent=t,this.#r.hidden=!t}}}#h(){let t=document.createElement("segmented-ui");t.setAttribute("data-region","chips"),t.setAttribute("role","radiogroup"),t.setAttribute("aria-label","Preset ranges"),this.appendChild(t),this.#i=t,this.#n.chips=t;let e=document.createElement("date-range-picker-ui");e.setAttribute("data-region","picker"),e.setAttribute("format","short"),e.setAttribute("placeholder","Custom range"),this.appendChild(e),this.#s=e,this.#n.picker=e;let i=document.createElement("text-ui");i.setAttribute("data-region","readout"),i.setAttribute("part","readout"),i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.hidden=!0,this.appendChild(i),this.#r=i,this.#n.readout=i,this.#c()}#c(){if(!this.#i)return;let t=(this.presets||"").split(",").map(i=>i.trim()).filter(Boolean),e=this.#i.querySelector(":scope > [data-indicator]");this.#i.replaceChildren(),e&&this.#i.appendChild(e);for(let i of t){if(!sr.has(i)){s.#l.has(this)||(s.#l.add(this),console.warn(`[date-range-selector-ui] unknown preset key "${i}" in [presets] \u2014 ignored. Use one of: ${[...sr].join(", ")}.`));continue}let r=document.createElement("segment-ui");r.setAttribute("value",i),r.setAttribute("text",zE[i]),this.#i.appendChild(r)}this.#i.value=this.value}#d(){let t=n=>{let o=n.detail?.value;if(!o||!sr.has(o))return;if(n.stopPropagation(),o==="custom"){this.#v(),this.#f("custom");return}let a=wh(o);a&&this.#u(o,a.from,a.to)};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=n=>{n.stopPropagation();let a=(n.detail||{}).value||null;if(!a||!a.from||!a.to)return;let l=this.#p(a.from,a.to);this.#u("custom",l.from,l.to)};this.#s.addEventListener("change",e),this.#e.push(()=>this.#s.removeEventListener("change",e));let i=()=>{this.pickerOpen=!0},r=()=>{this.pickerOpen=!1};this.#s.addEventListener("open",i),this.#s.addEventListener("close",r),this.#e.push(()=>this.#s.removeEventListener("open",i)),this.#e.push(()=>this.#s.removeEventListener("close",r))}#u(t,e,i,r={}){if(this.from===e&&this.to===i&&this.value===t&&!r.initial)return;this.#o=!0;try{this.from=e,this.to=i,this.value=t}finally{this.#o=!1}this.syncValue(),this.#b();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#g();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#f(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#p(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#p(this.from,this.to):wh("7d");let t=sr.has(this.value)?this.value:"7d";return wh(t)}#g(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#y(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#b(){let t=this.#y();t&&(this.broadcast==="document"&&!this.#a||(this.from?t.setAttribute("data-range-from",this.from):t.removeAttribute("data-range-from"),this.to?t.setAttribute("data-range-to",this.to):t.removeAttribute("data-range-to")))}#O(){if(ir.size>0&&!ir.has(this)){XE||(XE=!0,console.warn('[date-range-selector-ui] multiple instances with broadcast="document" on the same page; only the first writes data-range-from / data-range-to to <html>. Use broadcast="self" for secondary instances. See SPEC-019 \xA76 nesting rules.')),this.#a=!1,ir.add(this);return}ir.add(this),this.#a=!0}#S(){if(ir.has(this)&&(ir.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=ir.values().next().value;t&&(t.#a=!0,t.#b())}}#v(){this.#s&&(typeof this.#s.openPopover=="function"?this.#s.openPopover():this.#s.open=!0)}};customElements.get("date-range-selector-ui")||customElements.define("date-range-selector-ui",Zd);$();var zd=class extends v{static properties={open:{type:Boolean,default:!1,reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},confirmText:{type:String,default:"Confirm",reflect:!0,attribute:"confirm-text"},cancelText:{type:String,default:"Cancel",reflect:!0,attribute:"cancel-text"},confirmVariant:{type:String,default:"primary",reflect:!0,attribute:"confirm-variant"},size:{type:String,default:"sm",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#h=null;#c=[];#d=!1;#u="";#f="";#p=!1;connected(){this.#d||(this.#u=`${this.#b}-title`,this.#f=`${this.#b}-desc`,this.#m(),this.#g(),this.#d=!0)}disconnected(){for(let t of this.#c)try{t()}catch{}this.#c.length=0}show(){this.open=!0}hide(){this.open=!1}render(){if(!this.#d)return;this.#t&&(this.#t.setAttribute("size",this.size||"sm"),this.#t.open=!!this.open),this.#s&&(this.#s.id=this.#u,this.#s.textContent=this.title||""),this.#n&&(this.#n.id=this.#f,this.#n.textContent=this.description||"",this.#n.hidden=!this.description),this.#i&&(this.querySelector(':scope > [slot="icon"]')?this.#i.hidden=!0:this.icon?(this.#i.hidden=!1,this.#i.setAttribute("name",this.icon)):this.#i.hidden=!0);let t=this.#t?.querySelector(':scope > [slot="dialog"]');t&&(t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.title?t.setAttribute("aria-labelledby",this.#u):t.removeAttribute("aria-labelledby"),this.description?t.setAttribute("aria-describedby",this.#f):t.removeAttribute("aria-describedby")),this.#l&&(this.#l.setAttribute("text",this.cancelText||"Cancel"),this.loading?this.#l.setAttribute("disabled",""):this.#l.removeAttribute("disabled")),this.#h&&(this.#h.setAttribute("text",this.confirmText||"Confirm"),this.#h.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),this.loading?(this.#h.setAttribute("disabled",""),this.#h.setAttribute("icon","spinner")):(this.#h.removeAttribute("disabled"),this.#h.removeAttribute("icon"))),this.open&&this.#l&&!this.loading&&this.#y()}#m(){let t=document.createElement("modal-ui");t.setAttribute("size",this.size||"sm");let e=document.createElement("header");e.setAttribute("slot","header");let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.hidden=!0,e.appendChild(i),this.#i=i;let r=document.createElement("text-ui");r.setAttribute("slot","heading"),r.id=this.#u,this.title&&(r.textContent=this.title),e.appendChild(r),this.#s=r,this.#e=e;let n=document.createElement("section");n.setAttribute("slot","body");let o=document.createElement("text-ui");o.setAttribute("slot","description"),o.id=this.#f,this.description?o.textContent=this.description:o.hidden=!0,n.appendChild(o),this.#n=o;let a=document.createElement("div");a.setAttribute("data-extra",""),n.appendChild(a),this.#a=a,this.#r=n;let l=document.createElement("footer");l.setAttribute("slot","footer");let h=document.createElement("button-ui");h.setAttribute("slot","action"),h.setAttribute("data-confirm-action","cancel"),h.setAttribute("variant","ghost"),h.setAttribute("text",this.cancelText||"Cancel"),l.appendChild(h),this.#l=h;let c=document.createElement("button-ui");c.setAttribute("slot","action"),c.setAttribute("data-confirm-action","confirm"),c.setAttribute("variant",this.confirmVariant==="ghost"?"ghost":"primary"),c.setAttribute("text",this.confirmText||"Confirm"),l.appendChild(c),this.#h=c,this.#o=l;let u=[...this.children];for(let d of u){let f=d.getAttribute("slot");f==="icon"?e.appendChild(d):f||a.appendChild(d)}t.appendChild(e),t.appendChild(n),t.appendChild(l),this.appendChild(t),this.#t=t}#g(){let t=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("confirm",{bubbles:!0,detail:{}})))};this.#h.addEventListener("press",t),this.#c.push(()=>this.#h.removeEventListener("press",t));let e=r=>{this.loading||(r.stopPropagation(),this.#p=!0,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.open=!1)};this.#l.addEventListener("press",e),this.#c.push(()=>this.#l.removeEventListener("press",e));let i=r=>{r.stopPropagation(),this.open=!1,this.#p||this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.#p=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{}}))};this.#t.addEventListener("close",i),this.#c.push(()=>this.#t.removeEventListener("close",i))}#y(){let t=()=>{if(!(!this.open||!this.#l||this.loading))try{this.#l.focus()}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):queueMicrotask(t)}get#b(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",zd);$();Pt();var VD=new Set(["active","trialing","past_due","canceled","paused"]),jD={active:"success",trialing:"info",past_due:"danger",paused:"warning"},WD={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},FD={update:"update-card",retry:"retry"};function _E(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function UD(s,t){if(!s)return"";try{let e=s instanceof Date?s:new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"2-digit"}).format(e)}catch{return String(s)}}var Pa=class extends v{static get properties(){return{account:{type:Object,default:null},variant:{type:String,default:"full",reflect:!0},currency:{type:String,default:"USD",reflect:!0},locale:{type:String,default:""},loading:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#h=null;#c=null;#d=null;#u=null;#f=null;#p=null;#m=null;#g=null;#y=null;#b=null;#O=null;#S=null;#v=null;#x=null;#w="";#A=!1;#k=0;async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#k;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#k)return;this.loading=!1;let n=r&&typeof r=="object"&&r.account?r.account:r;this.account=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{account:n}}))}catch(i){if(e!==this.#k)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#E(),this.#T(),this.#Z(),this.#t=!0),H(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),this.#t&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.account,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let i=t?.status||"";if(i==="past_due"?this.setAttribute("past-due",""):this.removeAttribute("past-due"),i==="trialing"?this.setAttribute("trial",""):this.removeAttribute("trial"),i&&!VD.has(i)&&!this.#A&&(this.#A=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#L(null),this.#P(null);return}if(!t){this.#L(null);return}this.#L(t),this.#$(t),this.#I(t),this.#M(t),this.#R(t),this.#Q(t),this.#P(t)}#E(){let t=this.querySelector(':scope > script[type="application/json"][data-account]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.account&&typeof e.account=="object"?e.account:e;this.account=i}}catch(e){console.warn("[billing-overview-ui] failed to parse <script data-account> JSON:",e?.message)}finally{t.remove()}}#C(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#T(){this.#w=`bo-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("card-ui");t.setAttribute("data-header","");let e=document.createElement("header"),i=document.createElement("span");i.setAttribute("slot","icon");let r=document.createElement("avatar-ui");r.setAttribute("icon","credit-card"),i.appendChild(r);let n=document.createElement("span");n.setAttribute("slot","heading");let o=document.createElement("h2");o.id=this.#w,o.setAttribute("data-billing-plan-name",""),n.appendChild(o);let a=document.createElement("tag-ui");a.setAttribute("data-billing-status",""),a.setAttribute("size","md"),n.appendChild(a);let l=document.createElement("span");l.setAttribute("slot","description");let h=document.createElement("div");h.setAttribute("data-billing-plan-meta",""),l.appendChild(h);let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("div");u.setAttribute("data-header-actions",""),c.appendChild(u),e.append(i,n,l,c),t.appendChild(e),this.appendChild(t),this.#i=t,this.#s=o,this.#r=h,this.#n=a,this.#a=u,this.#C("header-actions",u);let d=document.createElement("section");d.setAttribute("data-kpis","");let f=(yt,wt,vt)=>{let $t=document.createElement("card-ui");$t.setAttribute("data-kpi-card",yt);let Mt=document.createElement("section"),Ht=document.createElement("stat-ui");return Ht.setAttribute("data-kpi",yt),Ht.setAttribute("label",wt),Ht.setAttribute("value","\u2014"),Ht.setAttribute("icon",vt),Mt.appendChild(Ht),$t.appendChild(Mt),[$t,Ht]},[p,m]=f("spend","Current month","credit-card"),[b,g]=f("seats","Seats","users-three"),[x,S]=f("next-invoice","Next invoice","calendar");d.append(p,b,x),this.appendChild(d),this.#o=d,this.#l=m,this.#h=g,this.#c=S;let w=document.createElement("section");w.setAttribute("data-dunning",""),w.setAttribute("hidden","");let A=document.createElement("alert-ui");A.setAttribute("pattern","dunning"),A.setAttribute("variant","danger"),w.appendChild(A),this.appendChild(w),this.#d=w,this.#u=A;let k=document.createElement("section");k.setAttribute("data-plan-picker","");let E=document.createElement("h3");E.setAttribute("data-section-heading",""),E.textContent="Plan";let P=document.createElement("plan-picker-ui");P.setAttribute("data-billing-plan-picker",""),P.setAttribute("name","billing-overview-plan"),k.append(E,P),this.appendChild(k),this.#f=k,this.#p=E,this.#m=P;let L=document.createElement("div");L.setAttribute("data-before-plan-picker",""),k.insertBefore(L,E),this.#C("before-plan-picker",L);let T=document.createElement("section");T.setAttribute("data-payment-methods","");let q=document.createElement("h3");q.setAttribute("data-section-heading",""),q.textContent="Payment methods";let I=document.createElement("payment-method-list-ui");I.setAttribute("data-billing-payment-methods",""),I.setAttribute("name","billing-overview-payment-method"),T.append(q,I),this.appendChild(T),this.#g=T,this.#y=q,this.#b=I;let z=document.createElement("section");z.setAttribute("data-invoice-history","");let V=document.createElement("h3");V.setAttribute("data-section-heading",""),V.textContent="Invoice history";let U=document.createElement("invoice-history-ui");U.setAttribute("data-billing-invoice-history",""),z.append(V,U),this.appendChild(z),this.#O=z,this.#S=V,this.#v=U;let tt=document.createElement("div");tt.setAttribute("data-after-invoice-history",""),z.appendChild(tt),this.#C("after-invoice-history",tt);let nt=document.createElement("div");nt.setAttribute("data-empty","");let ft=document.createElement("p");ft.setAttribute("data-empty-heading",""),ft.textContent="No billing account loaded";let lt=document.createElement("p");lt.setAttribute("data-empty-description",""),lt.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",nt.append(ft,lt),this.appendChild(nt),this.#x=nt,this.#C("empty",this)}#L(t){if(!this.#s||!this.#n||!this.#r)return;let e=t?.plan||null,i=e?.name?String(e.name):"Billing overview";this.#s.textContent!==i&&(this.#s.textContent=i);let r=this.#r;if(r.replaceChildren(),e&&Number.isFinite(e.price)){let o=e.currency||this.currency||"USD",a=this.#N(),l=e.cycle==="year"?"/yr":"/mo",h=document.createElement("span");h.setAttribute("data-plan-price",""),h.textContent=`${_E(e.price,o,a)} ${l}`,r.appendChild(h)}if(t?.billingCycle&&t.billingCycle!==e?.cycle){let o=document.createElement("span");o.setAttribute("data-plan-billing-cycle",""),o.textContent=`Billed ${t.billingCycle}ly`,r.appendChild(o)}let n=t?.status||"";if(!n)this.#n.setAttribute("hidden","");else{this.#n.removeAttribute("hidden");let o=jD[n],a=WD[n]||n;o?(this.#n.getAttribute("variant")!==o&&this.#n.setAttribute("variant",o),this.#n.removeAttribute("tone")):(this.#n.removeAttribute("variant"),this.#n.getAttribute("tone")!=="muted"&&this.#n.setAttribute("tone","muted")),this.#n.getAttribute("text")!==a&&this.#n.setAttribute("text",a),this.#n.setAttribute("aria-label",`Account status: ${a}`)}}#$(t){if(!this.#l||!this.#h||!this.#c)return;let e=t?.plan?.currency||this.currency||"USD",i=this.#N();if(Number.isFinite(t?.currentSpend)?this.#l.setAttribute("value",_E(t.currentSpend,e,i)):this.#l.setAttribute("value","\u2014"),t?.seats&&Number.isFinite(t.seats.used)){let r=t.seats.used,n=Number.isFinite(t.seats.total)?t.seats.total:null;this.#h.setAttribute("value",n!=null?`${r} / ${n}`:String(r))}else this.#h.setAttribute("value","\u2014");t?.nextInvoiceDate?this.#c.setAttribute("value",UD(t.nextInvoiceDate,i)):this.#c.setAttribute("value","\u2014");for(let r of[this.#l,this.#h,this.#c])this.loading?r.setAttribute("loading",""):r.removeAttribute("loading")}#I(t){if(!this.#d||!this.#u)return;let e=t?.dunning||null;if(!(t?.status==="past_due")||!e){this.#d.setAttribute("hidden","");return}this.#d.removeAttribute("hidden");let r=Number.isFinite(e.amount)?e.amount:null,n=e.currency||t?.plan?.currency||this.currency||"USD";if(r!=null?this.#u.setAttribute("amount",String(r)):this.#u.removeAttribute("amount"),this.#u.setAttribute("currency",n),e.dueAt&&this.#u.setAttribute("due-at",String(e.dueAt)),e.cardLast4&&this.#u.setAttribute("card-last4",String(e.cardLast4)),e.reason&&this.#u.setAttribute("reason",String(e.reason)),!this.#u.querySelector(':scope > [slot="actions"]')){let o=document.createElement("button-ui");o.setAttribute("slot","actions"),o.setAttribute("data-dunning-action","update"),o.setAttribute("variant","primary"),o.setAttribute("text","Update payment method"),this.#u.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("slot","actions"),a.setAttribute("data-dunning-action","retry"),a.setAttribute("variant","outline"),a.setAttribute("text","Retry charge"),this.#u.appendChild(a)}}#M(t){if(!this.#f||!this.#m)return;let e=this.variant==="full",i=Array.isArray(t?.plans)&&t.plans.length>0;if(!(e&&i)){this.#f.setAttribute("hidden","");return}this.#f.removeAttribute("hidden"),this.#m.plans=t.plans,t?.plan?.id&&this.#m.setAttribute("current",String(t.plan.id)),this.loading?this.#m.setAttribute("loading",""):this.#m.removeAttribute("loading")}#R(t){if(!this.#b)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#b.methods=e,this.loading?this.#b.setAttribute("loading",""):this.#b.removeAttribute("loading")}#Q(t){if(!this.#v)return;let e=Array.isArray(t?.invoices)?t.invoices:[];this.#v.invoices=e;let i=t?.plan?.currency||this.currency||"USD";this.#v.setAttribute("currency",i),this.loading?this.#v.setAttribute("loading",""):this.#v.removeAttribute("loading")}#P(t){this.#w&&this.setAttribute("aria-labelledby",this.#w),!t&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label","No billing account loaded"):t&&this.removeAttribute("aria-label")}#N(){return this.locale?this.locale:typeof document<"u"&&document.documentElement.lang||""}#Z(){let t=u=>{let d=u.target?.closest?.("[data-account-action]");if(!d||!this.contains(d))return;let f=d.getAttribute("data-account-action")||"";f&&(u.stopPropagation(),this.#D(f,"header",{target:d}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=u=>{let d=u.detail?.action||"",f=FD[d]||d||"dunning";this.#D(f,"alert-dunning",u.detail)};this.addEventListener("dunning-action",e),this.#e.push(()=>this.removeEventListener("dunning-action",e));let i=u=>{let d=u.detail?.value??u.detail?.plan?.id??"";this.#D("select-plan","plan-picker",{planId:d,...u.detail})};this.addEventListener("plan-change",i),this.#e.push(()=>this.removeEventListener("plan-change",i));let r=u=>{!this.#m||!this.#m.contains(u.target)&&u.target!==this.#m||this.#D("select-plan","plan-picker",u.detail)};this.addEventListener("change",r),this.#e.push(()=>this.removeEventListener("change",r));let n=()=>{this.#D("add-payment-method","payment-method-list",null)};this.addEventListener("add",n),this.#e.push(()=>this.removeEventListener("add",n));let o=u=>{this.#D("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#D("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#D("view-invoice","invoice-history",u.detail)};this.addEventListener("invoice-row-click",l),this.#e.push(()=>this.removeEventListener("invoice-row-click",l));let h=u=>{this.#D("download-invoice","invoice-history",u.detail)};this.addEventListener("invoice-export",h),this.#e.push(()=>this.removeEventListener("invoice-export",h));let c=u=>{let d=u.detail?.action||"invoice";this.#D(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#D(t,e,i){this.dispatchEvent(new CustomEvent("account-action",{bubbles:!0,detail:{action:t,source:e,payload:i||null}}))}};customElements.get("billing-overview-ui")||customElements.define("billing-overview-ui",Pa);$();Pt();var YD=new Set(["draft","open","paid","past-due","void"]),HD={paid:"success",open:"info","past-due":"danger"},VE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},GD=[{value:"",label:"All"},{value:"paid",label:"Paid"},{value:"open",label:"Open"},{value:"past-due",label:"Past due"},{value:"void",label:"Void"},{value:"draft",label:"Draft"}],jE=["Number","Issued","Due","Amount","Currency","Status"];function WE(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function FE(s,t){if(!s)return"";try{let e=s instanceof Date?s:new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"2-digit"}).format(e)}catch{return String(s)}}function UE(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function Be(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
458
458
  `)?'"'+t.replace(/"/g,'""')+'"':t}var Qa=class extends v{static properties={invoices:{type:Array,default:[]},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},hrefPattern:{type:String,default:"/invoices/{number}",reflect:!0,attribute:"href-pattern"},paginate:{type:Number,default:25,reflect:!0},exportable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""},filter:{type:String,default:"",reflect:!0}};static template=()=>null;static requiredIcons=["download-simple","receipt","magnifying-glass"];#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#h=!1;#c=0;#d=!1;setFilter(t){let e=t||"";return e&&!YD.has(e)?!1:H(()=>{if(this.filter===e)return!0;let i=this.filter;return this.filter=e,this.dispatchEvent(new CustomEvent("invoice-filter-change",{bubbles:!0,detail:{filter:e,previous:i}})),!0})}exportCsv(){let t=this.#m(),e=[jE.join(",")];for(let r of t){let n=[Be(r.number??""),Be(r.issuedAt??""),Be(r.dueAt??""),Be(Number.isFinite(r.amount)?r.amount:""),Be(r.currency||this.currency||"USD"),Be(r.status??"")];e.push(n.join(","))}let i=e.join(`\r
459
459
  `);return new Blob([i],{type:"text/csv;charset=utf-8;"})}getSelected(){if(!this.#o)return[];let t=this.#o.selected||[],e=this.#m();return t.map(i=>e[i]).filter(Boolean)}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#c;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#c)return;this.removeAttribute("loading");let n=Array.isArray(r)?r:Array.isArray(r?.invoices)?r.invoices:[];this.invoices=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:n.length}}))}catch(i){if(e!==this.#c)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected?.(),this.setAttribute("role","region"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Invoice history"),this.#t||(this.#u(),this.#f(),this.#y(),this.#t=!0),H(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#h)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;(Array.isArray(this.invoices)?this.invoices:[]).length===0&&!this.loading?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#p(),this.#o&&(this.#o.columns=this.#g(),this.#o.data=this.#m(),H(()=>{this.#o.density!==this.density&&(this.#o.density=this.density),!!this.#o.loading!=!!this.loading&&(this.#o.loading=!!this.loading),Number(this.#o.paginate||0)!==Number(this.paginate||0)&&(this.#o.paginate=Number(this.paginate||0)),!!this.#o.selectable!=!!this.selectable&&(this.#o.selectable=!!this.selectable)})),this.#s&&this.#s.setAttribute("count",String(this.#m().length)),this.#n&&(this.#n.hidden=!this.exportable)}#u(){let t=this.querySelector(':scope > script[type="application/json"][data-invoices]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.invoices=e)}catch(e){console.warn("[invoice-history-ui] failed to parse <script data-invoices> JSON:",e?.message)}finally{t.remove()}}#f(){let t=document.createElement("div");t.setAttribute("data-toolbar",""),this.appendChild(t),this.#i=t;let e=this.querySelector(':scope > [slot="toolbar"]');if(e)t.appendChild(e);else{let n=document.createElement("table-toolbar-ui");n.setAttribute("data-default-toolbar",""),n.setAttribute("text","Invoices");let o=document.createElement("div");o.setAttribute("data-invoice-filter",""),o.setAttribute("role","group"),o.setAttribute("aria-label","Filter invoices by status"),o.setAttribute("slot","actions"),n.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("data-export",""),a.setAttribute("slot","actions"),a.setAttribute("variant","outline"),a.setAttribute("size","sm"),a.setAttribute("text","Export CSV"),a.setAttribute("icon","download-simple"),n.appendChild(a),t.appendChild(n),this.#s=n,this.#r=o,this.#n=a}let i=document.createElement("div");i.setAttribute("data-table-host",""),this.appendChild(i),this.#a=i;let r=document.createElement("table-ui");if(r.id=this.id?`${this.id}__table`:`invoice-history-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("data-invoice-table",""),r.setAttribute("sortable",""),i.appendChild(r),this.#o=r,this.#s&&this.#s.setAttribute("for",r.id),!this.querySelector(':scope > [slot="empty"]')){let n=document.createElement("empty-state-ui");n.setAttribute("data-empty",""),n.setAttribute("icon","receipt"),n.setAttribute("heading","No invoices yet"),n.setAttribute("description","Invoices will appear here once issued."),this.appendChild(n),this.#l=n}}#p(){if(!this.#r)return;if(this.#r.children.length===0)for(let e of GD){let i=document.createElement("button-ui");i.setAttribute("data-filter-chip",""),i.setAttribute("data-filter-value",e.value),i.setAttribute("size","sm"),i.setAttribute("text",e.label),this.#r.appendChild(i)}let t=this.filter||"";for(let e of this.#r.querySelectorAll("[data-filter-chip]"))(e.getAttribute("data-filter-value")||"")===t?(e.setAttribute("variant","primary"),e.setAttribute("aria-pressed","true")):(e.setAttribute("variant","ghost"),e.setAttribute("aria-pressed","false"))}#m(){let t=Array.isArray(this.invoices)?this.invoices:[],e=this.filter||"";return e?t.filter(i=>(i?.status||"")===e):t}#g(){let t=this.locale||typeof document<"u"&&document.documentElement?.lang||"",e=this.currency||"USD";return[{key:"number",label:"Invoice",sortable:!0,wrap:!1},{key:"issuedAt",label:"Issued",sortable:!0,format:i=>FE(i,t)},{key:"dueAt",label:"Due",sortable:!0,format:i=>FE(i,t)},{key:"amount",label:"Amount",sortable:!0,align:"end",render:(i,r,n)=>{let o=r?.currency||e,a=document.createElement("span");return a.setAttribute("data-invoice-amount",""),a.textContent=WE(i,o,t),n.dataset.align="end",a},format:(i,r)=>WE(i,r?.currency||e,t)},{key:"status",label:"Status",sortable:!0,render:i=>{let r=String(i||"").toLowerCase(),n=HD[r],o=VE[r]||(i?String(i):"\u2014"),a=document.createElement("badge-ui");return a.setAttribute("data-invoice-status",""),n?a.setAttribute("variant",n):a.setAttribute("tone","muted"),a.setAttribute("text",o),a.setAttribute("aria-label",o),a},format:i=>VE[String(i||"").toLowerCase()]||(i?String(i):"")},{key:"actions",label:"",sortable:!1,align:"end",accessor:i=>i,render:(i,r)=>{let n=document.createElement("span");n.setAttribute("data-invoice-actions","");let o=document.createElement("button-ui");o.setAttribute("data-invoice-action","view"),o.setAttribute("data-invoice-id",String(r?.id??r?.number??"")),o.setAttribute("size","sm"),o.setAttribute("variant","ghost"),o.setAttribute("text","View"),n.appendChild(o);let a=document.createElement("button-ui");return a.setAttribute("data-invoice-action","download"),a.setAttribute("data-invoice-id",String(r?.id??r?.number??"")),a.setAttribute("size","sm"),a.setAttribute("variant","ghost"),a.setAttribute("icon","download-simple"),a.setAttribute("aria-label",`Download invoice ${r?.number??""}`),n.appendChild(a),n}}]}#y(){let t=o=>{let a=o.target?.closest?.("[data-filter-chip]");if(!a||!this.#r?.contains(a))return;o.stopPropagation();let l=a.getAttribute("data-filter-value")||"";this.setFilter(l)};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=o=>{let a=o?.detail;if(!a||a.key==="actions")return;let l=a.row;if(!l)return;let h=UE(this.hrefPattern,l),c=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:l,href:h}});if(this.dispatchEvent(c)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(h)}catch{}};this.addEventListener("cell-click",e),this.#e.push(()=>this.removeEventListener("cell-click",e));let i=o=>{let a=o.target?.closest?.("button-ui[data-invoice-action]");if(!a||!this.#a?.contains(a))return;o.stopPropagation();let l=a.getAttribute("data-invoice-action"),h=a.getAttribute("data-invoice-id")||"",c=(this.invoices||[]).find(u=>String(u?.id??u?.number??"")===h);if(c){if(l==="view"){let u=UE(this.hrefPattern,c),d=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:c,href:u}});if(this.dispatchEvent(d)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(u)}catch{}}else if(l==="download"){let u=this.#b(c);this.dispatchEvent(new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:u,rowCount:1,invoice:c}}))}}};this.addEventListener("press",i),this.addEventListener("click",i),this.#e.push(()=>this.removeEventListener("press",i)),this.#e.push(()=>this.removeEventListener("click",i));let r=o=>{let a=o.target?.closest?.("button-ui[data-export]");if(!a||!this.#i?.contains(a))return;o.stopPropagation();let l=this.exportCsv(),h=new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:l,rowCount:this.#m().length}});if(this.dispatchEvent(h)&&typeof document<"u"&&typeof URL<"u")try{let u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download="invoices.csv",document.body.appendChild(d),d.click(),d.remove(),setTimeout(()=>URL.revokeObjectURL(u),0)}catch{}};this.addEventListener("press",r),this.addEventListener("click",r),this.#e.push(()=>this.removeEventListener("press",r)),this.#e.push(()=>this.removeEventListener("click",r));let n=o=>{if(o.target!==this.#o)return;let a=this.getSelected();this.dispatchEvent(new CustomEvent("invoice-selection-change",{bubbles:!0,detail:{selected:a}}))};this.addEventListener("select",n),this.#e.push(()=>this.removeEventListener("select",n))}#b(t){let e=[jE.join(","),[Be(t.number??""),Be(t.issuedAt??""),Be(t.dueAt??""),Be(Number.isFinite(t.amount)?t.amount:""),Be(t.currency||this.currency||"USD"),Be(t.status??"")].join(",")];return new Blob([e.join(`\r
460
- `)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",Qa);$();Pt();var KD=new Set(["draft","open","paid","past-due","void"]),JD={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},tq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function _d(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(i)}catch{return`${t||"$"}${i.toFixed(2)}`}}function YE(s,t){if(!s)return"";try{let e=new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric"}).format(e)}catch{return String(s)}}var Ta=class extends v{static get properties(){return{invoice:{type:Object,default:null},status:{type:String,default:"draft",reflect:!0},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},printable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#h=null;#c=null;#d=null;#u=null;#f=null;#p=null;#m="";#g=!1;#y=!1;#b=0;#O="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#b;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#b)return;this.loading=!1;let n=r&&typeof r=="object"&&r.invoice?r.invoice:r;if(this.invoice=n,n?.status){this.#g=!0;try{this.status=String(n.status)}finally{this.#g=!1}}let o=n?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:o}})),this.#O=o}catch(i){if(e!==this.#b)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#S(),this.#x(),this.#T(),this.#t=!0),H(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#g)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.invoice,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let r=(this.hasAttribute("status")?this.getAttribute("status"):"")||t?.status||this.status||"draft";if(KD.has(r)||this.#y||(this.#y=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#w(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#w(null,r);return}this.#w(t,r),this.#A(t),this.#k(t),this.#E(t),this.#C(t)}#S(){let t=this.querySelector(':scope > script[type="application/json"][data-invoice]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.invoice&&typeof e.invoice=="object"?e.invoice:e;if(this.invoice=i,i?.status){this.#g=!0;try{this.status=String(i.status)}finally{this.#g=!1}}}}catch(e){console.warn("[invoice-detail-ui] failed to parse <script data-invoice> JSON:",e?.message)}finally{t.remove()}}#v(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#x(){this.#m=`inv-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("header");t.setAttribute("data-header","");let e=document.createElement("div");e.setAttribute("data-header-title","");let i=document.createElement("h2");i.id=this.#m,i.setAttribute("data-invoice-number",""),e.appendChild(i);let r=document.createElement("tag-ui");r.setAttribute("data-invoice-status",""),r.setAttribute("size","md"),e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-header-meta","");let o=document.createElement("div");o.setAttribute("data-header-actions",""),o.setAttribute("data-invoice-actions",""),t.append(e,n,o),this.appendChild(t),this.#i=t,this.#s=i,this.#r=r,this.#n=n,this.#a=o,this.#v("header-actions",o);let a=document.createElement("section");a.setAttribute("data-parties","");let l=document.createElement("div");l.setAttribute("data-customer","");let h=document.createElement("div");h.setAttribute("data-customer-default",""),l.appendChild(h),this.#l=h;let c=document.createElement("div");c.setAttribute("data-remit-to","");let u=document.createElement("div");u.setAttribute("data-remit-to-default",""),c.appendChild(u),this.#h=u,a.append(l,c),this.appendChild(a),this.#o=a,this.#v("customer-block",l),this.#v("remit-to-block",c);let d=document.createElement("section");d.setAttribute("data-lines","");let f=document.createElement("card-ui");f.setAttribute("data-lines-card",""),f.setAttribute("padding","none");let p=document.createElement("section");p.setAttribute("bleed",""),f.appendChild(p);let m=document.createElement("table-ui");m.setAttribute("data-lines-table",""),m.setAttribute("density",this.density||"standard"),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#c=d,this.#d=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#u=b;let g=document.createElement("footer");g.setAttribute("data-footer","");let x=document.createElement("div");x.setAttribute("data-footer-notes",""),g.appendChild(x),this.appendChild(g),this.#f=g,this.#v("footer",g);let S=document.createElement("empty-state-ui");S.setAttribute("data-empty",""),S.setAttribute("icon","receipt"),S.setAttribute("heading","No invoice loaded"),S.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(S),this.#p=S}#w(t,e){if(!this.#s||!this.#r||!this.#n)return;let i=t?.number?String(t.number):"";this.#s.textContent!==i&&(this.#s.textContent=i);let r=JD[e]||"default",n=tq[e]||(e?String(e):"Draft");if(this.#r.getAttribute("variant")!==r&&this.#r.setAttribute("variant",r),this.#r.getAttribute("text")!==n&&this.#r.setAttribute("text",n),this.#r.setAttribute("aria-label",`Status: ${n}`),t?this.#r.removeAttribute("hidden"):this.#r.setAttribute("hidden",""),this.#n.replaceChildren(),!t)return;let o=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(t.issuedAt){let a=document.createElement("span");a.setAttribute("data-issued",""),a.textContent=`Issued ${YE(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${YE(t.dueAt,o)}`,this.#n.appendChild(a)}}#A(t){if(!(!this.#l||!this.#h)){if(this.#l.replaceChildren(),t?.customer){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Billed to",this.#l.appendChild(e),t.customer.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.customer.name),this.#l.appendChild(i)}if(t.customer.email){let i=document.createElement("div");i.setAttribute("data-party-email",""),i.textContent=String(t.customer.email),this.#l.appendChild(i)}if(t.customer.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.customer.address),this.#l.appendChild(i)}}if(this.#h.replaceChildren(),t?.remitTo){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Remit to",this.#h.appendChild(e),t.remitTo.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.remitTo.name),this.#h.appendChild(i)}if(t.remitTo.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.remitTo.address),this.#h.appendChild(i)}}}}#k(t){if(!this.#d)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");this.#d.columns=[{key:"description",label:"Description",flex:1},{key:"qty",label:"Qty",width:80,format:n=>String(n??"")},{key:"unitAmount",label:"Unit",width:120,format:n=>_d(n,e,i)},{key:"amount",label:"Amount",width:140,format:n=>_d(n,e,i)}];let r=Array.isArray(t?.lines)?t.lines:[];this.#d.data=r.map((n,o)=>({__row:o,description:n?.description??"",qty:n?.qty??"",unitAmount:n?.unitAmount??0,amount:n?.amount??0})),this.#d.getAttribute("density")!==this.density&&this.#d.setAttribute("density",this.density||"standard")}#E(t){if(!this.#u)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(this.#u.replaceChildren(),!t)return;let r=[{key:"subtotal",label:"Subtotal",value:t.subtotal},{key:"tax",label:"Tax",value:t.tax}];Number.isFinite(t.discount)&&t.discount>0&&r.push({key:"discount",label:"Discount",value:-Math.abs(t.discount)});for(let n of r){if(!Number.isFinite(n.value))continue;let o=document.createElement("div");o.setAttribute("data-totals-row",""),o.setAttribute("data-totals-key",n.key);let a=document.createElement("span");a.setAttribute("data-totals-label",""),a.textContent=n.label;let l=document.createElement("span");l.setAttribute("data-totals-value",""),l.textContent=_d(n.value,e,i),o.append(a,l),this.#u.appendChild(o)}if(Number.isFinite(t.total)){let n=document.createElement("div");n.setAttribute("data-totals-row",""),n.setAttribute("data-totals-key","total"),n.setAttribute("data-grand-total","");let o=document.createElement("span");o.setAttribute("data-totals-label",""),o.textContent="Total";let a=document.createElement("span");a.setAttribute("data-totals-value",""),a.textContent=_d(t.total,e,i),n.append(o,a),this.#u.appendChild(n)}}#C(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#T(){let t=i=>{let r=i.target?.closest?.("[data-invoice-action]");if(!r||!this.contains(r))return;let n=r.getAttribute("data-invoice-action")||"";if(!n)return;let o=this.invoice?.number||"";i.stopPropagation(),this.dispatchEvent(new CustomEvent("invoice-action",{bubbles:!0,detail:{action:n,invoiceNumber:o}}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=i=>{if(!this.#c)return;let n=(i.composedPath?i.composedPath():[]).find(l=>l?.getAttribute&&l.getAttribute("data-row")!=null);if(!n||!this.#c.contains(n))return;let o=Number(n.getAttribute("data-row")),a=Array.isArray(this.invoice?.lines)?this.invoice.lines[o]:null;!Number.isFinite(o)||a==null||this.dispatchEvent(new CustomEvent("line-item-click",{bubbles:!0,detail:{index:o,lineItem:a}}))};this.addEventListener("click",e),this.#e.push(()=>this.removeEventListener("click",e))}};customElements.get("invoice-detail-ui")||customElements.define("invoice-detail-ui",Ta);Pt();var eq=[{brand:"amex",re:/^3[47]/},{brand:"visa",re:/^4/},{brand:"mastercard",re:/^(5[1-5]|2[2-7])/},{brand:"discover",re:/^6(011|5)/}];function Vd(s){if(!s)return"unknown";for(let{brand:t,re:e}of eq)if(e.test(s))return t;return"unknown"}function jd(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function QK(s,t){return s?t==="amex"?s.replace(/^(\d{0,4})(\d{0,6})(\d{0,5}).*$/,(e,i,r,n)=>[i,r,n].filter(Boolean).join(" ")):s.match(/.{1,4}/g)?.join(" ")??"":""}function HE(s){if(!s||s.length<12)return!1;let t=0,e=!1;for(let i=s.length-1;i>=0;i--){let r=s.charCodeAt(i)-48;if(r<0||r>9)return!1;e&&(r*=2,r>9&&(r-=9)),t+=r,e=!e}return t%10===0}function GE(s){if(!s)return null;let t=String(s).replace(/\s+/g,"").match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(!t)return null;let e=Number(t[1]),i=Number(t[2]);return i<100&&(i+=2e3),!Number.isFinite(e)||!Number.isFinite(i)?null:{month:e,year:i}}function KE(s){let t=GE(s);if(!t)return"expiry-format";let{month:e,year:i}=t;if(e<1||e>12)return"expiry-month";let r=new Date,n=r.getFullYear(),o=r.getMonth()+1;return i<n||i===n&&e<o?"expiry-past":i>n+50?"expiry-far":null}function JE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function iq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var sq=["US","CA","GB","DE","FR","AU"],rq={US:"United States",CA:"Canada",GB:"United Kingdom",DE:"Germany",FR:"France",AU:"Australia",JP:"Japan",ES:"Spain",IT:"Italy",NL:"Netherlands",SE:"Sweden",IE:"Ireland",SG:"Singapore",IN:"India",BR:"Brazil",MX:"Mexico"};function nq(s){return rq[s]||s}var La=class extends R{static labelDeprecated=!1;static get properties(){return{...R.properties,name:{type:String,default:"paymentMethod",reflect:!0},value:{type:String,default:"",reflect:!0},prefill:{type:String,default:"",attribute:"prefill"},countries:{type:Array,default:[]},defaultCountry:{type:String,default:"US",reflect:!0,attribute:"default-country"},requireBillingAddress:{type:Boolean,default:!1,reflect:!0,attribute:"require-billing-address"},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},autofocus:{type:Boolean,default:!1,reflect:!0},tokenizing:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#o={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#l="unknown";#h=!1;#c=null;#d=null;#u=!1;async tokenize(){if(this.#u)return Promise.reject(new Error("tokenize-inflight"));this.#u=!0,this.setAttribute("tokenizing","");try{let t=this.#k();if(!t.ok){let r=new Error(t.message);throw r.code=t.code,r.field=t.field,this.dispatchEvent(new CustomEvent("payment-method-error",{bubbles:!0,detail:{message:t.message,code:t.code,field:t.field}})),this.setAttribute("aria-invalid","true"),r}let e=t.detail;this.#h=!0;try{this.value=iq(e.last4)}finally{this.#h=!1}this.syncValue(),this.removeAttribute("aria-invalid");let i={token:this.value,...e};return this.dispatchEvent(new CustomEvent("submit-payment-method",{bubbles:!0,detail:i})),i}finally{this.removeAttribute("tokenizing"),this.#u=!1}}reset(){H(()=>{for(let t of Object.keys(this.#o)){let e=this.#o[t];e&&(e.value="",e.removeAttribute("error"))}this.#o.country&&(this.#o.country.value=this.defaultCountry||"US"),this.#h=!0;try{this.value="",this.error=""}finally{this.#h=!1}this.syncValue(),this.#l="unknown",this.removeAttribute("aria-invalid"),this.removeAttribute("error"),this.#w()})}syncValue(t){this.internals.setFormValue(this.value||""),this.required&&!this.value?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Payment method required.",this):this.internals.setValidity({})}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment method form"),this.#t||(this.#f(),this.#g(),this.#t=!0),H(()=>this.render()),this.autofocus&&requestAnimationFrame(()=>{this.#o.name?.focus?.()})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#h)){if(t==="prefill"&&e!==i)this.render();else if(t==="disabled"&&e!==i)this.#S();else if(t==="error"&&e!==i)this.#v();else if(t==="require-billing-address"&&e!==i)this.#O();else if(t==="default-country"&&e!==i){let r=this.#o.country;r&&!r.value&&(r.value=i||"US")}}}render(){this.#t&&(this.#b(),this.#O(),this.#S(),this.#v(),this.#x(),this.#w())}#f(){let t=document.createElement("alert-ui");t.setAttribute("data-alert",""),t.setAttribute("variant","danger"),t.setAttribute("icon","warning-circle"),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-summary",""),e.hidden=!0;let i=document.createElement("icon-ui");i.setAttribute("name","credit-card"),i.setAttribute("aria-hidden","true"),i.setAttribute("data-summary-icon",""),e.appendChild(i);let r=document.createElement("div");r.setAttribute("data-summary-text",""),e.appendChild(r);let n=document.createElement("button-ui");n.setAttribute("data-summary-edit",""),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("text","Edit card"),e.appendChild(n),this.appendChild(e),this.#s=e,this.#r=n;let o=document.createElement("div");o.setAttribute("data-grid",""),this.appendChild(o),this.#n=o,this.#a.name=this.#p("name",{label:"Name on card",required:!0,area:"name",input:{autocomplete:"cc-name",placeholder:"Pat Doe"}}),this.#o.name=this.#a.name.querySelector("input-ui"),this.#a.cardNumber=this.#p("cardNumber",{label:"Card number",required:!0,area:"card",input:{type:"text",inputmode:"numeric",autocomplete:"cc-number",placeholder:"1234 1234 1234 1234",prefix:"credit-card",maxlength:23}}),this.#o.cardNumber=this.#a.cardNumber.querySelector("input-ui");let a=document.createElement("span");a.setAttribute("slot","trailing"),a.setAttribute("data-brand-badge",""),this.#o.cardNumber.appendChild(a),this.#a.expiry=this.#p("expiry",{label:"Expiry",required:!0,area:"expiry",input:{type:"text",inputmode:"numeric",autocomplete:"cc-exp",placeholder:"MM/YY",maxlength:7}}),this.#o.expiry=this.#a.expiry.querySelector("input-ui"),this.#a.cvc=this.#p("cvc",{label:"CVC",required:!0,area:"cvc",input:{type:"text",inputmode:"numeric",autocomplete:"cc-csc",placeholder:"123",maxlength:4}}),this.#o.cvc=this.#a.cvc.querySelector("input-ui"),this.#a.country=this.#p("country",{label:"Country",required:!0,area:"country",kind:"select",input:{autocomplete:"country"},seedOptions:this.#m(),seedValue:this.defaultCountry||"US"}),this.#o.country=this.#a.country.querySelector("select-ui"),this.#a.postalCode=this.#p("postalCode",{label:"Postal code",required:!0,area:"postal",input:{type:"text",inputmode:"text",autocomplete:"postal-code",placeholder:"94105",maxlength:12}}),this.#o.postalCode=this.#a.postalCode.querySelector("input-ui"),this.#a.addressLine1=this.#p("addressLine1",{label:"Address line 1",required:!1,area:"address1",input:{type:"text",autocomplete:"address-line1",placeholder:"123 Main St",maxlength:100}}),this.#o.addressLine1=this.#a.addressLine1.querySelector("input-ui"),this.#a.addressLine1.hidden=!0,this.#a.addressLine2=this.#p("addressLine2",{label:"Address line 2 (optional)",required:!1,area:"address2",input:{type:"text",autocomplete:"address-line2",placeholder:"Apt 4B",maxlength:100}}),this.#o.addressLine2=this.#a.addressLine2.querySelector("input-ui"),this.#a.addressLine2.hidden=!0;let l=document.createElement("div");l.setAttribute("data-legal",""),this.appendChild(l),this.#c=l;for(let h of[...this.children])h!==l&&h.getAttribute&&h.getAttribute("slot")==="legal"&&l.appendChild(h)}#p(t,e){let i=document.createElement("field-ui");i.setAttribute("label",e.label),e.required&&i.setAttribute("required",""),i.setAttribute("data-field",t),i.style.gridArea=e.area;let r;if(e.kind==="select"){if(r=document.createElement("select-ui"),Array.isArray(e.seedOptions))for(let n of e.seedOptions){let o=document.createElement("option");o.value=n.value,o.textContent=n.label,e.seedValue&&n.value===e.seedValue&&o.setAttribute("selected",""),r.appendChild(o)}}else r=document.createElement("input-ui");r.setAttribute("name",t),r.setAttribute("data-control",t),e.required&&r.setAttribute("required","");for(let[n,o]of Object.entries(e.input||{}))o==null||o===""||r.setAttribute(n,String(o));return i.appendChild(r),this.#n.appendChild(i),i}#m(){return(Array.isArray(this.countries)&&this.countries.length>0?this.countries:sq).map(e=>({value:e,label:nq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=jd(n),a=Vd(o);a!==this.#l&&(this.#l=a,this.#w()),this.#y()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=r=>{r.target!==this&&this.#y()};this.addEventListener("change",e),this.#e.push(()=>this.removeEventListener("change",e));let i=()=>{this.disabled||(this.removeAttribute("prefilled"),this.#s&&(this.#s.hidden=!0),this.#n&&(this.#n.hidden=!1))};this.#r.addEventListener("click",i),this.#r.addEventListener("press",i),this.#e.push(()=>{this.#r.removeEventListener("click",i),this.#r.removeEventListener("press",i)})}#y(){let t=jd(this.#o.cardNumber?.value),e=Vd(t),i=this.#A();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#b(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((r,n)=>r?.value===e[n].value&&r?.label===e[n].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#O(){let t=!!this.requireBillingAddress;this.#a.addressLine1&&(this.#a.addressLine1.hidden=!t),this.#a.addressLine2&&(this.#a.addressLine2.hidden=!t)}#S(){let t=!!this.disabled;for(let e of Object.values(this.#o))e&&(t?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}#v(){if(!this.#i)return;let t=this.error||"";t?(this.#i.setAttribute("text",t),this.#i.hidden=!1,this.setAttribute("aria-invalid","true")):(this.#i.removeAttribute("text"),this.#i.hidden=!0,this.removeAttribute("aria-invalid"))}#x(){if(!this.#s)return;let t=this.#E();if(!t||this.hasAttribute("prefilled-dismissed")){this.#s.hidden=!0,this.#n&&(this.#n.hidden=!1),this.removeAttribute("prefilled");return}let e=this.#s.querySelector(":scope > [data-summary-text]");if(e){let i=(t.brand||"Card").toUpperCase(),r=t.last4||"\u2022\u2022\u2022\u2022",n=t.expMonth&&t.expYear?` \xB7 expires ${String(t.expMonth).padStart(2,"0")}/${String(t.expYear).slice(-2)}`:"";e.textContent=`${i} ending in ${r}${n}`}this.#s.hidden=!1,this.#n&&(this.#n.hidden=!0),this.setAttribute("prefilled","")}#w(){let t=this.#o.cardNumber;if(!t)return;let e=t.querySelector(":scope > [data-brand-badge]");if(!e)return;if(this.#l==="unknown"||!this.#l){e.replaceChildren();return}let i=e.querySelector(":scope > [data-brand]");if(i&&i.getAttribute("data-brand")===this.#l)return;e.replaceChildren();let r=document.createElement("span");r.setAttribute("data-brand",this.#l),r.textContent=this.#l.toUpperCase(),e.appendChild(r)}#A(){let t=jd(this.#o.cardNumber?.value);return t?HE(t)?KE(this.#o.expiry?.value)?{ok:!1}:JE(this.#o.cvc?.value,Vd(t))?{ok:!1}:(this.#o.name?.value||"").trim()?(this.#o.postalCode?.value||"").trim()?{ok:!0}:{ok:!1}:{ok:!1}:{ok:!1}:{ok:!1}}#k(){for(let d of Object.values(this.#o))d?.removeAttribute?.("error");let t=String(this.#o.name?.value||"").trim();if(!t)return this.#o.name?.setAttribute("error","Name on card is required."),{ok:!1,message:"Name on card is required.",code:"validation-failed",field:"name"};let e=this.#o.cardNumber?.value||"",i=jd(e);if(!i)return this.#o.cardNumber?.setAttribute("error","Card number is required."),{ok:!1,message:"Card number is required.",code:"validation-failed",field:"cardNumber"};if(!HE(i))return this.#o.cardNumber?.setAttribute("error","Card number is invalid."),{ok:!1,message:"Card number is invalid.",code:"card-invalid",field:"cardNumber"};let r=KE(this.#o.expiry?.value||"");if(r){let d=r==="expiry-past"?"Card has expired.":r==="expiry-month"?"Expiry month must be 01-12.":r==="expiry-far"?"Expiry year is too far in the future.":"Expiry must be MM/YY.";return this.#o.expiry?.setAttribute("error",d),{ok:!1,message:d,code:r==="expiry-past"?"expired":"validation-failed",field:"expiry"}}let n=Vd(i);if(JE(this.#o.cvc?.value||"",n)){let f=`CVC must be ${n==="amex"?4:3} digits.`;return this.#o.cvc?.setAttribute("error",f),{ok:!1,message:f,code:"cvc-invalid",field:"cvc"}}let a=String(this.#o.country?.value||this.defaultCountry||"US");if(!String(this.#o.postalCode?.value||"").trim())return this.#o.postalCode?.setAttribute("error","Postal code is required."),{ok:!1,message:"Postal code is required.",code:"validation-failed",field:"postalCode"};if(this.requireBillingAddress&&!String(this.#o.addressLine1?.value||"").trim())return this.#o.addressLine1?.setAttribute("error","Address is required."),{ok:!1,message:"Address is required.",code:"validation-failed",field:"addressLine1"};let h=GE(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:n,expMonth:h.month,expYear:h.year,name:t,country:a}}}#E(){let t=this.prefill||this.getAttribute("prefill")||"";if(!t)return null;try{let e=JSON.parse(t);return!e||typeof e!="object"?null:e}catch{return null}}};customElements.get("payment-method-form-ui")||customElements.define("payment-method-form-ui",La);Pt();var oq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),tC=new Set(["card","bank","wallet"]),eC={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},aq={card:"credit-card",bank:"bank",wallet:"credit-card"},iC={visa:"Visa",mastercard:"Mastercard",amex:"American Express",discover:"Discover",jcb:"JCB",unionpay:"UnionPay",diners:"Diners Club",paypal:"PayPal","apple-pay":"Apple Pay","google-pay":"Google Pay",ach:"Bank account",sepa:"SEPA"};function sC(s){let t=(s?.brand||"").toLowerCase();if(eC[t])return eC[t];let e=(s?.type||"card").toLowerCase();return aq[e]||"credit-card"}function rC(s){let t=(s?.brand||"").toLowerCase();if(iC[t])return iC[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function VO(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=rC(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function jO(s){let t=(s?.expiry||"").trim();if(!t)return"";let e="",i="",r=t.match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(r)e=r[1].padStart(2,"0"),i=r[2].length===4?r[2].slice(-2):r[2];else{let n=t.match(/^(\d{4})-(\d{2})-\d{2}$/);n&&(i=n[1].slice(-2),e=n[2])}return!e||!i?"":`Expires ${e}/${i}`}var Ma=class extends R{static get properties(){return{...R.properties,methods:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},"add-label":{type:String,default:"Add payment method",attribute:"add-label"},"add-icon":{type:String,default:"plus",attribute:"add-icon"},"no-add":{type:Boolean,default:!1,reflect:!0,attribute:"no-add"},"no-remove":{type:Boolean,default:!1,reflect:!0,attribute:"no-remove"},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=new Map;#o=!1;setDefault(t){return t?H(()=>{let e=(this.methods||[]).find(r=>r.id===t);if(!e)return!1;if(this.value===t)return!0;let i=this.value||"";this.#o=!0;try{this.value=t}finally{this.#o=!1}return this.syncValue(),this.#m(t,i,e),!0}):!1}remove(t){return t?H(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(r=>r.id===t);if(i<0)return!1;if(e.splice(i,1),this.methods=e,this.value===t){let r=e[0]?.id||"";this.#o=!0;try{this.value=r}finally{this.#o=!1}this.syncValue()}return!0}):!1}add(t){!t||!t.id||H(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(r=>r.id===t.id);if(i>=0?e[i]=t:e.push(t),this.methods=e,t.default){let r=this.value||"";this.#o=!0;try{this.value=t.id}finally{this.#o=!1}this.syncValue(),r!==t.id&&this.#m(t.id,r,t)}})}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment methods"),this.#t||(this.#h(),this.#c(),this.#p(),this.#t=!0),H(()=>this.render())}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.methods)?this.methods:[],e=this.#l(t);if(e&&this.value!==e){this.#o=!0;try{this.value=e}finally{this.#o=!1}this.syncValue()}if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#r&&(this.#r.hidden=!!this["no-add"]),this.#n){this.#n.setAttribute("text",this["add-label"]||"Add payment method");let i=this["add-icon"]||"plus";i?this.#n.setAttribute("icon",i):this.#n.removeAttribute("icon"),this.disabled?this.#n.setAttribute("disabled",""):this.#n.removeAttribute("disabled")}this.#d(t)}#l(t){if(!t.length)return"";if(this.value&&t.some(i=>i.id===this.value))return this.value;let e=t.find(i=>i.default);return e?e.id:t[0].id||""}#h(){let t=this.querySelector(':scope > script[type="application/json"][data-methods]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.methods=e)}catch(e){console.warn("[payment-method-list-ui] failed to parse <script data-methods> JSON:",e?.message)}finally{t.remove()}}#c(){let t=document.createElement("div");if(t.setAttribute("data-rows",""),t.setAttribute("role","presentation"),this.appendChild(t),this.#i=t,!this.querySelector(':scope > [slot="empty"]')){let i=document.createElement("empty-state-ui");i.setAttribute("data-empty",""),i.setAttribute("icon","credit-card"),i.setAttribute("heading","No payment methods"),i.setAttribute("description","Add a method to get started."),this.appendChild(i),this.#s=i}let e=document.createElement("div");if(e.setAttribute("data-add",""),this.appendChild(e),this.#r=e,!this.querySelector(':scope > [slot="add"]')){let i=document.createElement("button-ui");i.setAttribute("data-add-cta",""),i.setAttribute("variant","outline"),i.setAttribute("icon",this["add-icon"]||"plus"),i.setAttribute("text",this["add-label"]||"Add payment method"),e.appendChild(i),this.#n=i}}#d(t){if(!this.#i)return;let e=new Map;for(let i of t){if(!i?.id)continue;let r=this.#a.get(i.id);r||(r=this.#u(i),this.#i.appendChild(r)),this.#f(r,i),e.set(i.id,r)}for(let[i,r]of this.#a)if(!e.has(i))try{r.remove()}catch{}for(let i of t){let r=e.get(i.id);r&&this.#i.appendChild(r)}this.#a=e}#u(t){let e=document.createElement("card-ui");e.setAttribute("data-row",""),e.setAttribute("role","radio"),e.setAttribute("tabindex","0");let i=document.createElement("header"),r=document.createElement("span");r.setAttribute("slot","icon");let n=document.createElement("icon-ui");n.setAttribute("aria-hidden","true"),r.appendChild(n);let o=document.createElement("span");o.setAttribute("slot","heading");let a=document.createElement("span");a.setAttribute("data-primary","");let l=document.createElement("tag-ui");l.setAttribute("data-default-tag",""),l.setAttribute("text","Default"),l.setAttribute("variant","success"),l.setAttribute("size","sm"),l.setAttribute("hidden",""),o.appendChild(a),o.appendChild(l);let h=document.createElement("p");h.setAttribute("slot","description"),h.setAttribute("data-secondary","");let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("button-ui");u.setAttribute("data-action","set-default"),u.setAttribute("variant","ghost"),u.setAttribute("size","sm"),u.setAttribute("text","Set default");let d=document.createElement("button-ui");d.setAttribute("data-action","edit"),d.setAttribute("variant","ghost"),d.setAttribute("size","sm"),d.setAttribute("icon","pencil"),d.setAttribute("aria-label","Edit payment method");let f=document.createElement("button-ui");return f.setAttribute("data-action","remove"),f.setAttribute("variant","ghost"),f.setAttribute("size","sm"),f.setAttribute("icon","trash"),f.setAttribute("aria-label","Remove payment method"),c.appendChild(u),c.appendChild(d),c.appendChild(f),i.appendChild(r),i.appendChild(o),i.appendChild(h),i.appendChild(c),e.appendChild(i),e}#f(t,e){t.setAttribute("data-id",e.id);let i=(e?.brand||"").toLowerCase();i?t.setAttribute("data-brand-key",i):t.removeAttribute("data-brand-key");let r=(e?.type||"card").toLowerCase();tC.has(r)&&t.setAttribute("data-type",r);let n=e.id===this.value;n?(t.setAttribute("data-default",""),t.setAttribute("aria-checked","true"),t.setAttribute("tabindex","0")):(t.removeAttribute("data-default"),t.setAttribute("aria-checked","false"),t.setAttribute("tabindex","-1")),this.disabled?t.setAttribute("aria-disabled","true"):t.removeAttribute("aria-disabled");let o=t.querySelector(':scope > header > [slot="icon"] > icon-ui');if(o){let m=sC(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=VO(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=jO(e);l.textContent=m,m?l.removeAttribute("hidden"):l.setAttribute("hidden","")}let h=t.querySelector(':scope > header > [slot="heading"] > [data-default-tag]');h&&(n?h.removeAttribute("hidden"):h.setAttribute("hidden",""));let c=jO(e),u=[VO(e)];c&&u.push(c),n&&u.push("default"),t.setAttribute("aria-label",u.join(", "));let d=t.querySelector(':scope > header > [slot="action"] > [data-action="set-default"]');d&&(n?d.setAttribute("hidden",""):d.removeAttribute("hidden"),this.disabled?d.setAttribute("disabled",""):d.removeAttribute("disabled"));let f=t.querySelector(':scope > header > [slot="action"] > [data-action="edit"]');f&&(this.disabled?f.setAttribute("disabled",""):f.removeAttribute("disabled"));let p=t.querySelector(':scope > header > [slot="action"] > [data-action="remove"]');p&&(this["no-remove"]?p.setAttribute("hidden",""):p.removeAttribute("hidden"),this.disabled?p.setAttribute("disabled",""):p.removeAttribute("disabled"))}#p(){let t=r=>{let n=r.target?.closest?.("button-ui[data-action]");if(n&&this.#i.contains(n)){let a=n.closest("[data-row]");if(!a)return;let l=a.getAttribute("data-id")||"";if(!l)return;if(this.disabled||n.hasAttribute("disabled")){r.stopPropagation();return}let h=(this.methods||[]).find(u=>u.id===l);if(!h)return;let c=n.getAttribute("data-action");r.stopPropagation(),c==="set-default"?this.setDefault(l):c==="remove"?this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{id:l,method:h}})):c==="edit"&&this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{id:l,method:h}}));return}let o=r.target?.closest?.("button-ui[data-add-cta]");if(o&&this.#r?.contains(o)){if(this.disabled||o.hasAttribute("disabled")){r.stopPropagation();return}r.stopPropagation(),this.dispatchEvent(new CustomEvent("add",{bubbles:!0,detail:{}}))}};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=r=>{if(r.target?.closest?.("button-ui[data-action]")||r.target?.closest?.("button-ui[data-add-cta]"))return;let n=r.target?.closest?.("[data-row]");if(!n||!this.#i.contains(n))return;let o=n.getAttribute("data-id")||"";o&&(this.disabled||this.setDefault(o))};this.#i.addEventListener("click",e),this.#e.push(()=>this.#i.removeEventListener("click",e));let i=r=>{let o=document.activeElement?.closest?.("[data-row]");if(!o||!this.#i.contains(o))return;let a=Array.from(this.#i.querySelectorAll(":scope > [data-row]")),l=a.indexOf(o);if(!(l<0)){if(r.key==="ArrowDown"||r.key==="ArrowRight")r.preventDefault(),a[(l+1)%a.length]?.focus?.();else if(r.key==="ArrowUp"||r.key==="ArrowLeft")r.preventDefault(),a[(l-1+a.length)%a.length]?.focus?.();else if(r.key==="Home")r.preventDefault(),a[0]?.focus?.();else if(r.key==="End")r.preventDefault(),a[a.length-1]?.focus?.();else if(r.key===" "||r.key==="Enter"){r.preventDefault();let h=o.getAttribute("data-id")||"";h&&!this.disabled&&this.setDefault(h)}}};this.#i.addEventListener("keydown",i),this.#e.push(()=>this.#i.removeEventListener("keydown",i))}#m(t,e,i){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,method:i}}))}};customElements.get("payment-method-list-ui")||customElements.define("payment-method-list-ui",Ma);Pt();var Wd=new Set(["monthly","annual"]),lq={monthly:"Monthly",annual:"Annual"},hq={monthly:"/month",annual:"/year"};function cq(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function uq(s,t,e){if(s.cta)return s.cta;if(!e)return`Choose ${s.name||""}`.trim();if(s.id===e)return"Manage";let i=t.find(r=>r.id===e);if(i&&Number.isFinite(i.rank)&&Number.isFinite(s.rank)){if(s.rank>i.rank)return"Upgrade";if(s.rank<i.rank)return"Downgrade"}return`Switch to ${s.name||""}`.trim()}var Ra=class extends R{static labelDeprecated=!0;static get properties(){return{...R.properties,plans:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},current:{type:String,default:"",reflect:!0},cycle:{type:String,default:"monthly",reflect:!0},cycleToggle:{type:Boolean,default:!1,reflect:!0,attribute:"cycle-toggle"},currency:{type:String,default:"USD"},locale:{type:String,default:""},layout:{type:String,default:"grid",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=new Map;#l=!1;#h=!1;#c=!1;#d=0;setValue(t){return t?H(()=>{let e=(this.plans||[]).find(r=>r.id===t);if(!e)return!1;if(e.disabled)return this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}})),!1;if(this.value===t)return!0;let i=this.value||"";return this.value=t,this.syncValue(),this.#O(t,i),!0}):!1}setCycle(t){return Wd.has(t)?H(()=>{if(this.cycle===t)return!0;let e=this.cycle;return this.cycle=t,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:t,previous:e}})),!0}):!1}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#d;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#d)return;this.removeAttribute("loading");let n=Array.isArray(r)?r:Array.isArray(r?.plans)?r.plans:[];this.plans=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:n.length}}))}catch(i){if(e!==this.#d)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Choose a plan"),this.#t||(this.#u(),this.#f(),this.#b(),this.#t=!0),H(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#l)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.plans)?this.plans:[];if(!Wd.has(this.cycle)){this.#h||(this.#h=!0,console.warn(`[plan-picker-ui] unknown cycle "${this.cycle}" \u2014 coercing to "monthly".`)),this.#l=!0;try{this.cycle="monthly"}finally{this.#l=!1}}let e=t.filter(r=>r.recommended);e.length>1&&!this.#c&&(this.#c=!0,console.warn(`[plan-picker-ui] ${e.length} plans carry recommended:true \u2014 using the first ("${e[0].id}"); ignoring the rest.`));let i=e[0]?.id||"";if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#i){let r=this.cycleToggle&&t.length>0;this.#i.hidden=!r,r&&this.#p()}this.#m(t,i)}#u(){let t=this.querySelector(':scope > script[type="application/json"][data-plans]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.plans=e)}catch(e){console.warn("[plan-picker-ui] failed to parse <script data-plans> JSON:",e?.message)}finally{t.remove()}}#f(){let t=document.createElement("div");t.setAttribute("data-toggle",""),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-plans",""),e.setAttribute("role","presentation"),this.appendChild(e),this.#r=e;let i=document.createElement("div");if(i.setAttribute("data-skeleton",""),i.hidden=!0,this.appendChild(i),this.#n=i,!this.querySelector(':scope > [slot="empty"]')){let r=document.createElement("empty-state-ui");r.setAttribute("data-empty",""),r.setAttribute("icon","package"),r.setAttribute("heading","No plans available"),r.setAttribute("description","Plans will appear here once configured."),this.appendChild(r),this.#a=r}}#p(){if(!this.#i)return;let t=this.#s;if(!t){t=document.createElement("segmented-ui"),t.setAttribute("aria-label","Billing cycle"),this.#i.appendChild(t),this.#s=t;for(let e of["monthly","annual"]){let i=document.createElement("segment-ui");i.setAttribute("value",e),i.setAttribute("text",lq[e]),t.appendChild(i)}}t.value!==this.cycle&&(t.value=this.cycle)}#m(t,e){if(!this.#r)return;let i=new Map;for(let r of t){if(!r?.id)continue;let n=this.#o.get(r.id);n||(n=document.createElement("option-card-ui"),n.setAttribute("layout","tile"),this.#r.appendChild(n)),this.#g(n,r,e),i.set(r.id,n)}for(let[r,n]of this.#o)if(!i.has(r))try{n.remove()}catch{}for(let r of t){let n=i.get(r.id);n&&this.#r.appendChild(n)}this.#o=i}#g(t,e,i){t.setAttribute("name",`${this.name||"plan"}__${this.id||"pp"}`),t.setAttribute("value",e.id),t.setAttribute("heading",e.name||""),t.setAttribute("description",e.tagline||""),e.icon?t.setAttribute("icon",e.icon):t.removeAttribute("icon");let r=!!(this.current&&e.id===this.current),n=e.id===i;r?t.setAttribute("data-current",""):t.removeAttribute("data-current"),n?t.setAttribute("data-recommended",""):t.removeAttribute("data-recommended"),e.disabled||this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.value&&this.value===e.id||!this.value&&r?t.setAttribute("checked",""):t.removeAttribute("checked");let a=t.querySelector(":scope > [data-plan-body]");a||(a=document.createElement("div"),a.setAttribute("data-plan-body",""),t.appendChild(a)),this.#y(a,e);let l=t.querySelector(":scope > [data-plan-tags]");if(l||(l=document.createElement("div"),l.setAttribute("data-plan-tags",""),l.setAttribute("slot","heading-suffix"),t.appendChild(l)),l.replaceChildren(),r){let h=document.createElement("tag-ui");h.setAttribute("text","Current plan"),l.appendChild(h)}else if(n){let h=document.createElement("tag-ui");h.setAttribute("text","Recommended"),h.setAttribute("variant","primary"),l.appendChild(h)}}#y(t,e){t.replaceChildren();let i=document.createElement("div");i.setAttribute("data-price-row","");let r=Wd.has(this.cycle)?this.cycle:"monthly",n=e.prices||{},o=n[r]||n.monthly||null;if(o){let l=document.createElement("span");l.setAttribute("data-price","");let h=o.currency||this.currency||"USD";l.textContent=cq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:hq[r];c.textContent=u,i.appendChild(c)}else{let l=document.createElement("span");l.setAttribute("data-price",""),l.textContent="Contact sales",i.appendChild(l)}if(t.appendChild(i),o?.note){let l=document.createElement("span");l.setAttribute("data-price-note",""),l.textContent=o.note,t.appendChild(l)}if(Array.isArray(e.features)&&e.features.length){let l=document.createElement("ul");l.setAttribute("data-features","");for(let h of e.features){let c=document.createElement("li"),u=document.createElement("icon-ui");u.setAttribute("name","check"),u.setAttribute("aria-hidden","true"),c.appendChild(u);let d=document.createElement("span");d.textContent=String(h),c.appendChild(d),l.appendChild(c)}t.appendChild(l)}if(!!!(this.current&&e.id===this.current)||e.cta){let l=document.createElement("button-ui");l.setAttribute("data-cta",""),l.setAttribute("variant",e.recommended?"primary":"outline"),l.setAttribute("text",uq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#b(){let t=r=>{let n=r?.detail?.value;if(!Wd.has(n)||this.cycle===n)return;r.stopPropagation();let o=this.cycle;this.cycle=n,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:n,previous:o}}))};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=r=>{let n=r.target?.closest?.("option-card-ui");if(!n||!this.#r.contains(n))return;let o=n.getAttribute("value")||"";if(!o)return;let a=(this.plans||[]).find(h=>h.id===o);if(!a)return;if(a.disabled||this.disabled){n.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}}));return}r.stopPropagation();let l=this.value||"";if(l!==o){this.#l=!0;try{this.value=o}finally{this.#l=!1}this.syncValue(),this.#O(o,l)}};this.#r.addEventListener("change",e),this.#e.push(()=>this.#r.removeEventListener("change",e));let i=r=>{let n=r.target?.closest?.("button-ui[data-cta]");if(!n||!this.#r.contains(n))return;let o=n.closest("option-card-ui");if(!o)return;let a=o.getAttribute("value")||"";if(!a)return;let l=(this.plans||[]).find(c=>c.id===a);if(!l||l.disabled||this.disabled)return;r.stopPropagation();let h=this.value||"";if(h!==a){this.#l=!0;try{this.value=a}finally{this.#l=!1}this.syncValue(),this.#O(a,h)}this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:a,cycle:this.cycle}}))};this.#r.addEventListener("press",i),this.#r.addEventListener("click",i),this.#e.push(()=>this.#r.removeEventListener("press",i)),this.#e.push(()=>this.#r.removeEventListener("click",i))}#O(t,e){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,cycle:this.cycle}}))}};customElements.get("plan-picker-ui")||customElements.define("plan-picker-ui",Ra);$();var dq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),fq=6,Ah=class extends v{static properties={integrations:{type:Array,default:[]},loading:{type:Boolean,default:!1,reflect:!0},"search-placeholder":{type:String,default:"Search integrations",reflect:!0},"group-by":{type:String,default:"category",reflect:!0},"status-filter":{type:String,default:"all",reflect:!0}};static template=t=>t._renderTemplate();#t="";#e=`intpage-h-${Math.random().toString(36).slice(2,8)}`;#i=null;attributeChangedCallback(t,e,i){if(t==="integrations"){if(i==null)this.integrations=[];else try{let r=JSON.parse(i);this.integrations=Array.isArray(r)?r:[]}catch{this.integrations=[]}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#e),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Integrations"),this.hasAttribute("integrations")&&!Array.isArray(this.integrations))try{this.integrations=JSON.parse(this.getAttribute("integrations"))}catch{this.integrations=[]}this.addEventListener("input",this.#d),this.addEventListener("change",this.#u)}disconnected(){this.removeEventListener("input",this.#d),this.removeEventListener("change",this.#u),this.#i&&(clearTimeout(this.#i),this.#i=null)}render(){this.#c(),this.querySelector('segmented-ui[data-part="filter"]')?.render?.()}_renderTemplate(){let t=this["search-placeholder"]||"Search integrations",e=this["status-filter"]||"all",i=!!this.loading,r=this.#l();return Y`
460
+ `)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",Qa);$();Pt();var KD=new Set(["draft","open","paid","past-due","void"]),JD={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},tq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function _d(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(i)}catch{return`${t||"$"}${i.toFixed(2)}`}}function YE(s,t){if(!s)return"";try{let e=new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric"}).format(e)}catch{return String(s)}}var Ta=class extends v{static get properties(){return{invoice:{type:Object,default:null},status:{type:String,default:"draft",reflect:!0},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},printable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=null;#l=null;#h=null;#c=null;#d=null;#u=null;#f=null;#p=null;#m="";#g=!1;#y=!1;#b=0;#O="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#b;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#b)return;this.loading=!1;let n=r&&typeof r=="object"&&r.invoice?r.invoice:r;if(this.invoice=n,n?.status){this.#g=!0;try{this.status=String(n.status)}finally{this.#g=!1}}let o=n?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:o}})),this.#O=o}catch(i){if(e!==this.#b)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#S(),this.#x(),this.#T(),this.#t=!0),H(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#g)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.invoice,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let r=(this.hasAttribute("status")?this.getAttribute("status"):"")||t?.status||this.status||"draft";if(KD.has(r)||this.#y||(this.#y=!0,console.warn(`[invoice-detail-ui] unknown status "${r}" \u2014 rendering default badge.`)),e){this.#w(null,r),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#w(null,r);return}this.#w(t,r),this.#A(t),this.#k(t),this.#E(t),this.#C(t)}#S(){let t=this.querySelector(':scope > script[type="application/json"][data-invoice]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.invoice&&typeof e.invoice=="object"?e.invoice:e;if(this.invoice=i,i?.status){this.#g=!0;try{this.status=String(i.status)}finally{this.#g=!1}}}}catch(e){console.warn("[invoice-detail-ui] failed to parse <script data-invoice> JSON:",e?.message)}finally{t.remove()}}#v(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let r of i)e.appendChild(r)}#x(){this.#m=`inv-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("header");t.setAttribute("data-header","");let e=document.createElement("div");e.setAttribute("data-header-title","");let i=document.createElement("h2");i.id=this.#m,i.setAttribute("data-invoice-number",""),e.appendChild(i);let r=document.createElement("tag-ui");r.setAttribute("data-invoice-status",""),r.setAttribute("size","md"),e.appendChild(r);let n=document.createElement("div");n.setAttribute("data-header-meta","");let o=document.createElement("div");o.setAttribute("data-header-actions",""),o.setAttribute("data-invoice-actions",""),t.append(e,n,o),this.appendChild(t),this.#i=t,this.#s=i,this.#r=r,this.#n=n,this.#a=o,this.#v("header-actions",o);let a=document.createElement("section");a.setAttribute("data-parties","");let l=document.createElement("div");l.setAttribute("data-customer","");let h=document.createElement("div");h.setAttribute("data-customer-default",""),l.appendChild(h),this.#l=h;let c=document.createElement("div");c.setAttribute("data-remit-to","");let u=document.createElement("div");u.setAttribute("data-remit-to-default",""),c.appendChild(u),this.#h=u,a.append(l,c),this.appendChild(a),this.#o=a,this.#v("customer-block",l),this.#v("remit-to-block",c);let d=document.createElement("section");d.setAttribute("data-lines","");let f=document.createElement("card-ui");f.setAttribute("data-lines-card",""),f.setAttribute("padding","none");let p=document.createElement("section");p.setAttribute("bleed",""),f.appendChild(p);let m=document.createElement("table-ui");m.setAttribute("data-lines-table",""),m.setAttribute("density",this.density||"standard"),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#c=d,this.#d=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#u=b;let g=document.createElement("footer");g.setAttribute("data-footer","");let x=document.createElement("div");x.setAttribute("data-footer-notes",""),g.appendChild(x),this.appendChild(g),this.#f=g,this.#v("footer",g);let S=document.createElement("empty-state-ui");S.setAttribute("data-empty",""),S.setAttribute("icon","receipt"),S.setAttribute("heading","No invoice loaded"),S.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(S),this.#p=S}#w(t,e){if(!this.#s||!this.#r||!this.#n)return;let i=t?.number?String(t.number):"";this.#s.textContent!==i&&(this.#s.textContent=i);let r=JD[e]||"default",n=tq[e]||(e?String(e):"Draft");if(this.#r.getAttribute("variant")!==r&&this.#r.setAttribute("variant",r),this.#r.getAttribute("text")!==n&&this.#r.setAttribute("text",n),this.#r.setAttribute("aria-label",`Status: ${n}`),t?this.#r.removeAttribute("hidden"):this.#r.setAttribute("hidden",""),this.#n.replaceChildren(),!t)return;let o=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(t.issuedAt){let a=document.createElement("span");a.setAttribute("data-issued",""),a.textContent=`Issued ${YE(t.issuedAt,o)}`,this.#n.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${YE(t.dueAt,o)}`,this.#n.appendChild(a)}}#A(t){if(!(!this.#l||!this.#h)){if(this.#l.replaceChildren(),t?.customer){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Billed to",this.#l.appendChild(e),t.customer.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.customer.name),this.#l.appendChild(i)}if(t.customer.email){let i=document.createElement("div");i.setAttribute("data-party-email",""),i.textContent=String(t.customer.email),this.#l.appendChild(i)}if(t.customer.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.customer.address),this.#l.appendChild(i)}}if(this.#h.replaceChildren(),t?.remitTo){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Remit to",this.#h.appendChild(e),t.remitTo.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.remitTo.name),this.#h.appendChild(i)}if(t.remitTo.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.remitTo.address),this.#h.appendChild(i)}}}}#k(t){if(!this.#d)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");this.#d.columns=[{key:"description",label:"Description",flex:1},{key:"qty",label:"Qty",width:80,format:n=>String(n??"")},{key:"unitAmount",label:"Unit",width:120,format:n=>_d(n,e,i)},{key:"amount",label:"Amount",width:140,format:n=>_d(n,e,i)}];let r=Array.isArray(t?.lines)?t.lines:[];this.#d.data=r.map((n,o)=>({__row:o,description:n?.description??"",qty:n?.qty??"",unitAmount:n?.unitAmount??0,amount:n?.amount??0})),this.#d.getAttribute("density")!==this.density&&this.#d.setAttribute("density",this.density||"standard")}#E(t){if(!this.#u)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(this.#u.replaceChildren(),!t)return;let r=[{key:"subtotal",label:"Subtotal",value:t.subtotal},{key:"tax",label:"Tax",value:t.tax}];Number.isFinite(t.discount)&&t.discount>0&&r.push({key:"discount",label:"Discount",value:-Math.abs(t.discount)});for(let n of r){if(!Number.isFinite(n.value))continue;let o=document.createElement("div");o.setAttribute("data-totals-row",""),o.setAttribute("data-totals-key",n.key);let a=document.createElement("span");a.setAttribute("data-totals-label",""),a.textContent=n.label;let l=document.createElement("span");l.setAttribute("data-totals-value",""),l.textContent=_d(n.value,e,i),o.append(a,l),this.#u.appendChild(o)}if(Number.isFinite(t.total)){let n=document.createElement("div");n.setAttribute("data-totals-row",""),n.setAttribute("data-totals-key","total"),n.setAttribute("data-grand-total","");let o=document.createElement("span");o.setAttribute("data-totals-label",""),o.textContent="Total";let a=document.createElement("span");a.setAttribute("data-totals-value",""),a.textContent=_d(t.total,e,i),n.append(o,a),this.#u.appendChild(n)}}#C(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#T(){let t=i=>{let r=i.target?.closest?.("[data-invoice-action]");if(!r||!this.contains(r))return;let n=r.getAttribute("data-invoice-action")||"";if(!n)return;let o=this.invoice?.number||"";i.stopPropagation(),this.dispatchEvent(new CustomEvent("invoice-action",{bubbles:!0,detail:{action:n,invoiceNumber:o}}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=i=>{if(!this.#c)return;let n=(i.composedPath?i.composedPath():[]).find(l=>l?.getAttribute&&l.getAttribute("data-row")!=null);if(!n||!this.#c.contains(n))return;let o=Number(n.getAttribute("data-row")),a=Array.isArray(this.invoice?.lines)?this.invoice.lines[o]:null;!Number.isFinite(o)||a==null||this.dispatchEvent(new CustomEvent("line-item-click",{bubbles:!0,detail:{index:o,lineItem:a}}))};this.addEventListener("click",e),this.#e.push(()=>this.removeEventListener("click",e))}};customElements.get("invoice-detail-ui")||customElements.define("invoice-detail-ui",Ta);Pt();var eq=[{brand:"amex",re:/^3[47]/},{brand:"visa",re:/^4/},{brand:"mastercard",re:/^(5[1-5]|2[2-7])/},{brand:"discover",re:/^6(011|5)/}];function Vd(s){if(!s)return"unknown";for(let{brand:t,re:e}of eq)if(e.test(s))return t;return"unknown"}function jd(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function QK(s,t){return s?t==="amex"?s.replace(/^(\d{0,4})(\d{0,6})(\d{0,5}).*$/,(e,i,r,n)=>[i,r,n].filter(Boolean).join(" ")):s.match(/.{1,4}/g)?.join(" ")??"":""}function HE(s){if(!s||s.length<12)return!1;let t=0,e=!1;for(let i=s.length-1;i>=0;i--){let r=s.charCodeAt(i)-48;if(r<0||r>9)return!1;e&&(r*=2,r>9&&(r-=9)),t+=r,e=!e}return t%10===0}function GE(s){if(!s)return null;let t=String(s).replace(/\s+/g,"").match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(!t)return null;let e=Number(t[1]),i=Number(t[2]);return i<100&&(i+=2e3),!Number.isFinite(e)||!Number.isFinite(i)?null:{month:e,year:i}}function KE(s){let t=GE(s);if(!t)return"expiry-format";let{month:e,year:i}=t;if(e<1||e>12)return"expiry-month";let r=new Date,n=r.getFullYear(),o=r.getMonth()+1;return i<n||i===n&&e<o?"expiry-past":i>n+50?"expiry-far":null}function JE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function iq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var sq=["US","CA","GB","DE","FR","AU"],rq={US:"United States",CA:"Canada",GB:"United Kingdom",DE:"Germany",FR:"France",AU:"Australia",JP:"Japan",ES:"Spain",IT:"Italy",NL:"Netherlands",SE:"Sweden",IE:"Ireland",SG:"Singapore",IN:"India",BR:"Brazil",MX:"Mexico"};function nq(s){return rq[s]||s}var La=class extends R{static labelDeprecated=!1;static get properties(){return{...R.properties,name:{type:String,default:"paymentMethod",reflect:!0},value:{type:String,default:"",reflect:!0},prefill:{type:String,default:"",attribute:"prefill"},countries:{type:Array,default:[]},defaultCountry:{type:String,default:"US",reflect:!0,attribute:"default-country"},requireBillingAddress:{type:Boolean,default:!1,reflect:!0,attribute:"require-billing-address"},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},autofocus:{type:Boolean,default:!1,reflect:!0},tokenizing:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#o={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#l="unknown";#h=!1;#c=null;#d=null;#u=!1;async tokenize(){if(this.#u)return Promise.reject(new Error("tokenize-inflight"));this.#u=!0,this.setAttribute("tokenizing","");try{let t=this.#k();if(!t.ok){let r=new Error(t.message);throw r.code=t.code,r.field=t.field,this.dispatchEvent(new CustomEvent("payment-method-error",{bubbles:!0,detail:{message:t.message,code:t.code,field:t.field}})),this.setAttribute("aria-invalid","true"),r}let e=t.detail;this.#h=!0;try{this.value=iq(e.last4)}finally{this.#h=!1}this.syncValue(),this.removeAttribute("aria-invalid");let i={token:this.value,...e};return this.dispatchEvent(new CustomEvent("submit-payment-method",{bubbles:!0,detail:i})),i}finally{this.removeAttribute("tokenizing"),this.#u=!1}}reset(){H(()=>{for(let t of Object.keys(this.#o)){let e=this.#o[t];e&&(e.value="",e.removeAttribute("error"))}this.#o.country&&(this.#o.country.value=this.defaultCountry||"US"),this.#h=!0;try{this.value="",this.error=""}finally{this.#h=!1}this.syncValue(),this.#l="unknown",this.removeAttribute("aria-invalid"),this.removeAttribute("error"),this.#w()})}syncValue(t){this.internals.setFormValue(this.value||""),this.required&&!this.value?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Payment method required.",this):this.internals.setValidity({})}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment method form"),this.#t||(this.#f(),this.#g(),this.#t=!0),H(()=>this.render()),this.autofocus&&requestAnimationFrame(()=>{this.#o.name?.focus?.()})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#h)){if(t==="prefill"&&e!==i)this.render();else if(t==="disabled"&&e!==i)this.#S();else if(t==="error"&&e!==i)this.#v();else if(t==="require-billing-address"&&e!==i)this.#O();else if(t==="default-country"&&e!==i){let r=this.#o.country;r&&!r.value&&(r.value=i||"US")}}}render(){this.#t&&(this.#b(),this.#O(),this.#S(),this.#v(),this.#x(),this.#w())}#f(){let t=document.createElement("alert-ui");t.setAttribute("data-alert",""),t.setAttribute("variant","danger"),t.setAttribute("icon","warning-circle"),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-summary",""),e.hidden=!0;let i=document.createElement("icon-ui");i.setAttribute("name","credit-card"),i.setAttribute("aria-hidden","true"),i.setAttribute("data-summary-icon",""),e.appendChild(i);let r=document.createElement("div");r.setAttribute("data-summary-text",""),e.appendChild(r);let n=document.createElement("button-ui");n.setAttribute("data-summary-edit",""),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("text","Edit card"),e.appendChild(n),this.appendChild(e),this.#s=e,this.#r=n;let o=document.createElement("div");o.setAttribute("data-grid",""),this.appendChild(o),this.#n=o,this.#a.name=this.#p("name",{label:"Name on card",required:!0,area:"name",input:{autocomplete:"cc-name",placeholder:"Pat Doe"}}),this.#o.name=this.#a.name.querySelector("input-ui"),this.#a.cardNumber=this.#p("cardNumber",{label:"Card number",required:!0,area:"card",input:{type:"text",inputmode:"numeric",autocomplete:"cc-number",placeholder:"1234 1234 1234 1234",prefix:"credit-card",maxlength:23}}),this.#o.cardNumber=this.#a.cardNumber.querySelector("input-ui");let a=document.createElement("span");a.setAttribute("slot","trailing"),a.setAttribute("data-brand-badge",""),this.#o.cardNumber.appendChild(a),this.#a.expiry=this.#p("expiry",{label:"Expiry",required:!0,area:"expiry",input:{type:"text",inputmode:"numeric",autocomplete:"cc-exp",placeholder:"MM/YY",maxlength:7}}),this.#o.expiry=this.#a.expiry.querySelector("input-ui"),this.#a.cvc=this.#p("cvc",{label:"CVC",required:!0,area:"cvc",input:{type:"text",inputmode:"numeric",autocomplete:"cc-csc",placeholder:"123",maxlength:4}}),this.#o.cvc=this.#a.cvc.querySelector("input-ui"),this.#a.country=this.#p("country",{label:"Country",required:!0,area:"country",kind:"select",input:{autocomplete:"country"},seedOptions:this.#m(),seedValue:this.defaultCountry||"US"}),this.#o.country=this.#a.country.querySelector("select-ui"),this.#a.postalCode=this.#p("postalCode",{label:"Postal code",required:!0,area:"postal",input:{type:"text",inputmode:"text",autocomplete:"postal-code",placeholder:"94105",maxlength:12}}),this.#o.postalCode=this.#a.postalCode.querySelector("input-ui"),this.#a.addressLine1=this.#p("addressLine1",{label:"Address line 1",required:!1,area:"address1",input:{type:"text",autocomplete:"address-line1",placeholder:"123 Main St",maxlength:100}}),this.#o.addressLine1=this.#a.addressLine1.querySelector("input-ui"),this.#a.addressLine1.hidden=!0,this.#a.addressLine2=this.#p("addressLine2",{label:"Address line 2 (optional)",required:!1,area:"address2",input:{type:"text",autocomplete:"address-line2",placeholder:"Apt 4B",maxlength:100}}),this.#o.addressLine2=this.#a.addressLine2.querySelector("input-ui"),this.#a.addressLine2.hidden=!0;let l=document.createElement("div");l.setAttribute("data-legal",""),this.appendChild(l),this.#c=l;for(let h of[...this.children])h!==l&&h.getAttribute&&h.getAttribute("slot")==="legal"&&l.appendChild(h)}#p(t,e){let i=document.createElement("field-ui");i.setAttribute("label",e.label),e.required&&i.setAttribute("required",""),i.setAttribute("data-field",t),i.style.gridArea=e.area;let r;if(e.kind==="select"){if(r=document.createElement("select-ui"),Array.isArray(e.seedOptions))for(let n of e.seedOptions){let o=document.createElement("option");o.value=n.value,o.textContent=n.label,e.seedValue&&n.value===e.seedValue&&o.setAttribute("selected",""),r.appendChild(o)}}else r=document.createElement("input-ui");r.setAttribute("name",t),r.setAttribute("data-control",t),e.required&&r.setAttribute("required","");for(let[n,o]of Object.entries(e.input||{}))o==null||o===""||r.setAttribute(n,String(o));return i.appendChild(r),this.#n.appendChild(i),i}#m(){return(Array.isArray(this.countries)&&this.countries.length>0?this.countries:sq).map(e=>({value:e,label:nq(e)}))}#g(){let t=r=>{if(!this.#o.cardNumber||r.target!==this.#o.cardNumber)return;let n=String(this.#o.cardNumber.value||""),o=jd(n),a=Vd(o);a!==this.#l&&(this.#l=a,this.#w()),this.#y()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=r=>{r.target!==this&&this.#y()};this.addEventListener("change",e),this.#e.push(()=>this.removeEventListener("change",e));let i=()=>{this.disabled||(this.removeAttribute("prefilled"),this.#s&&(this.#s.hidden=!0),this.#n&&(this.#n.hidden=!1))};this.#r.addEventListener("click",i),this.#r.addEventListener("press",i),this.#e.push(()=>{this.#r.removeEventListener("click",i),this.#r.removeEventListener("press",i)})}#y(){let t=jd(this.#o.cardNumber?.value),e=Vd(t),i=this.#A();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#b(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((r,n)=>r?.value===e[n].value&&r?.label===e[n].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#O(){let t=!!this.requireBillingAddress;this.#a.addressLine1&&(this.#a.addressLine1.hidden=!t),this.#a.addressLine2&&(this.#a.addressLine2.hidden=!t)}#S(){let t=!!this.disabled;for(let e of Object.values(this.#o))e&&(t?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}#v(){if(!this.#i)return;let t=this.error||"";t?(this.#i.setAttribute("text",t),this.#i.hidden=!1,this.setAttribute("aria-invalid","true")):(this.#i.removeAttribute("text"),this.#i.hidden=!0,this.removeAttribute("aria-invalid"))}#x(){if(!this.#s)return;let t=this.#E();if(!t||this.hasAttribute("prefilled-dismissed")){this.#s.hidden=!0,this.#n&&(this.#n.hidden=!1),this.removeAttribute("prefilled");return}let e=this.#s.querySelector(":scope > [data-summary-text]");if(e){let i=(t.brand||"Card").toUpperCase(),r=t.last4||"\u2022\u2022\u2022\u2022",n=t.expMonth&&t.expYear?` \xB7 expires ${String(t.expMonth).padStart(2,"0")}/${String(t.expYear).slice(-2)}`:"";e.textContent=`${i} ending in ${r}${n}`}this.#s.hidden=!1,this.#n&&(this.#n.hidden=!0),this.setAttribute("prefilled","")}#w(){let t=this.#o.cardNumber;if(!t)return;let e=t.querySelector(":scope > [data-brand-badge]");if(!e)return;if(this.#l==="unknown"||!this.#l){e.replaceChildren();return}let i=e.querySelector(":scope > [data-brand]");if(i&&i.getAttribute("data-brand")===this.#l)return;e.replaceChildren();let r=document.createElement("span");r.setAttribute("data-brand",this.#l),r.textContent=this.#l.toUpperCase(),e.appendChild(r)}#A(){let t=jd(this.#o.cardNumber?.value);return t?HE(t)?KE(this.#o.expiry?.value)?{ok:!1}:JE(this.#o.cvc?.value,Vd(t))?{ok:!1}:(this.#o.name?.value||"").trim()?(this.#o.postalCode?.value||"").trim()?{ok:!0}:{ok:!1}:{ok:!1}:{ok:!1}:{ok:!1}}#k(){for(let d of Object.values(this.#o))d?.removeAttribute?.("error");let t=String(this.#o.name?.value||"").trim();if(!t)return this.#o.name?.setAttribute("error","Name on card is required."),{ok:!1,message:"Name on card is required.",code:"validation-failed",field:"name"};let e=this.#o.cardNumber?.value||"",i=jd(e);if(!i)return this.#o.cardNumber?.setAttribute("error","Card number is required."),{ok:!1,message:"Card number is required.",code:"validation-failed",field:"cardNumber"};if(!HE(i))return this.#o.cardNumber?.setAttribute("error","Card number is invalid."),{ok:!1,message:"Card number is invalid.",code:"card-invalid",field:"cardNumber"};let r=KE(this.#o.expiry?.value||"");if(r){let d=r==="expiry-past"?"Card has expired.":r==="expiry-month"?"Expiry month must be 01-12.":r==="expiry-far"?"Expiry year is too far in the future.":"Expiry must be MM/YY.";return this.#o.expiry?.setAttribute("error",d),{ok:!1,message:d,code:r==="expiry-past"?"expired":"validation-failed",field:"expiry"}}let n=Vd(i);if(JE(this.#o.cvc?.value||"",n)){let f=`CVC must be ${n==="amex"?4:3} digits.`;return this.#o.cvc?.setAttribute("error",f),{ok:!1,message:f,code:"cvc-invalid",field:"cvc"}}let a=String(this.#o.country?.value||this.defaultCountry||"US");if(!String(this.#o.postalCode?.value||"").trim())return this.#o.postalCode?.setAttribute("error","Postal code is required."),{ok:!1,message:"Postal code is required.",code:"validation-failed",field:"postalCode"};if(this.requireBillingAddress&&!String(this.#o.addressLine1?.value||"").trim())return this.#o.addressLine1?.setAttribute("error","Address is required."),{ok:!1,message:"Address is required.",code:"validation-failed",field:"addressLine1"};let h=GE(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:n,expMonth:h.month,expYear:h.year,name:t,country:a}}}#E(){let t=this.prefill||this.getAttribute("prefill")||"";if(!t)return null;try{let e=JSON.parse(t);return!e||typeof e!="object"?null:e}catch{return null}}};customElements.get("payment-method-form-ui")||customElements.define("payment-method-form-ui",La);Pt();var oq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),tC=new Set(["card","bank","wallet"]),eC={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},aq={card:"credit-card",bank:"bank",wallet:"credit-card"},iC={visa:"Visa",mastercard:"Mastercard",amex:"American Express",discover:"Discover",jcb:"JCB",unionpay:"UnionPay",diners:"Diners Club",paypal:"PayPal","apple-pay":"Apple Pay","google-pay":"Google Pay",ach:"Bank account",sepa:"SEPA"};function sC(s){let t=(s?.brand||"").toLowerCase();if(eC[t])return eC[t];let e=(s?.type||"card").toLowerCase();return aq[e]||"credit-card"}function rC(s){let t=(s?.brand||"").toLowerCase();if(iC[t])return iC[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function VO(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=rC(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function jO(s){let t=(s?.expiry||"").trim();if(!t)return"";let e="",i="",r=t.match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(r)e=r[1].padStart(2,"0"),i=r[2].length===4?r[2].slice(-2):r[2];else{let n=t.match(/^(\d{4})-(\d{2})-\d{2}$/);n&&(i=n[1].slice(-2),e=n[2])}return!e||!i?"":`Expires ${e}/${i}`}var Ma=class extends R{static get properties(){return{...R.properties,methods:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},"add-label":{type:String,default:"Add payment method",attribute:"add-label"},"add-icon":{type:String,default:"plus",attribute:"add-icon"},"no-add":{type:Boolean,default:!1,reflect:!0,attribute:"no-add"},"no-remove":{type:Boolean,default:!1,reflect:!0,attribute:"no-remove"},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=new Map;#o=!1;setDefault(t){return t?H(()=>{let e=(this.methods||[]).find(r=>r.id===t);if(!e)return!1;if(this.value===t)return!0;let i=this.value||"";this.#o=!0;try{this.value=t}finally{this.#o=!1}return this.syncValue(),this.#m(t,i,e),!0}):!1}remove(t){return t?H(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(r=>r.id===t);if(i<0)return!1;if(e.splice(i,1),this.methods=e,this.value===t){let r=e[0]?.id||"";this.#o=!0;try{this.value=r}finally{this.#o=!1}this.syncValue()}return!0}):!1}add(t){!t||!t.id||H(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(r=>r.id===t.id);if(i>=0?e[i]=t:e.push(t),this.methods=e,t.default){let r=this.value||"";this.#o=!0;try{this.value=t.id}finally{this.#o=!1}this.syncValue(),r!==t.id&&this.#m(t.id,r,t)}})}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment methods"),this.#t||(this.#h(),this.#c(),this.#p(),this.#t=!0),H(()=>this.render())}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.methods)?this.methods:[],e=this.#l(t);if(e&&this.value!==e){this.#o=!0;try{this.value=e}finally{this.#o=!1}this.syncValue()}if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#r&&(this.#r.hidden=!!this["no-add"]),this.#n){this.#n.setAttribute("text",this["add-label"]||"Add payment method");let i=this["add-icon"]||"plus";i?this.#n.setAttribute("icon",i):this.#n.removeAttribute("icon"),this.disabled?this.#n.setAttribute("disabled",""):this.#n.removeAttribute("disabled")}this.#d(t)}#l(t){if(!t.length)return"";if(this.value&&t.some(i=>i.id===this.value))return this.value;let e=t.find(i=>i.default);return e?e.id:t[0].id||""}#h(){let t=this.querySelector(':scope > script[type="application/json"][data-methods]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.methods=e)}catch(e){console.warn("[payment-method-list-ui] failed to parse <script data-methods> JSON:",e?.message)}finally{t.remove()}}#c(){let t=document.createElement("div");if(t.setAttribute("data-rows",""),t.setAttribute("role","presentation"),this.appendChild(t),this.#i=t,!this.querySelector(':scope > [slot="empty"]')){let i=document.createElement("empty-state-ui");i.setAttribute("data-empty",""),i.setAttribute("icon","credit-card"),i.setAttribute("heading","No payment methods"),i.setAttribute("description","Add a method to get started."),this.appendChild(i),this.#s=i}let e=document.createElement("div");if(e.setAttribute("data-add",""),this.appendChild(e),this.#r=e,!this.querySelector(':scope > [slot="add"]')){let i=document.createElement("button-ui");i.setAttribute("data-add-cta",""),i.setAttribute("variant","outline"),i.setAttribute("icon",this["add-icon"]||"plus"),i.setAttribute("text",this["add-label"]||"Add payment method"),e.appendChild(i),this.#n=i}}#d(t){if(!this.#i)return;let e=new Map;for(let i of t){if(!i?.id)continue;let r=this.#a.get(i.id);r||(r=this.#u(i),this.#i.appendChild(r)),this.#f(r,i),e.set(i.id,r)}for(let[i,r]of this.#a)if(!e.has(i))try{r.remove()}catch{}for(let i of t){let r=e.get(i.id);r&&this.#i.appendChild(r)}this.#a=e}#u(t){let e=document.createElement("card-ui");e.setAttribute("data-row",""),e.setAttribute("role","radio"),e.setAttribute("tabindex","0");let i=document.createElement("header"),r=document.createElement("span");r.setAttribute("slot","icon"),r.setAttribute("data-pml-icon","");let n=document.createElement("icon-ui");n.setAttribute("aria-hidden","true"),r.appendChild(n);let o=document.createElement("span");o.setAttribute("slot","heading");let a=document.createElement("span");a.setAttribute("data-primary","");let l=document.createElement("tag-ui");l.setAttribute("data-default-tag",""),l.setAttribute("text","Default"),l.setAttribute("variant","success"),l.setAttribute("size","sm"),l.setAttribute("hidden",""),o.appendChild(a),o.appendChild(l);let h=document.createElement("p");h.setAttribute("slot","description"),h.setAttribute("data-secondary","");let c=document.createElement("span");c.setAttribute("slot","action"),c.setAttribute("data-pml-action","");let u=document.createElement("button-ui");u.setAttribute("data-action","set-default"),u.setAttribute("variant","ghost"),u.setAttribute("size","sm"),u.setAttribute("text","Set default");let d=document.createElement("button-ui");d.setAttribute("data-action","edit"),d.setAttribute("variant","ghost"),d.setAttribute("size","sm"),d.setAttribute("icon","pencil"),d.setAttribute("aria-label","Edit payment method");let f=document.createElement("button-ui");return f.setAttribute("data-action","remove"),f.setAttribute("variant","ghost"),f.setAttribute("size","sm"),f.setAttribute("icon","trash"),f.setAttribute("aria-label","Remove payment method"),c.appendChild(u),c.appendChild(d),c.appendChild(f),i.appendChild(r),i.appendChild(o),i.appendChild(h),i.appendChild(c),e.appendChild(i),e}#f(t,e){t.setAttribute("data-id",e.id);let i=(e?.brand||"").toLowerCase();i?t.setAttribute("data-brand-key",i):t.removeAttribute("data-brand-key");let r=(e?.type||"card").toLowerCase();tC.has(r)&&t.setAttribute("data-type",r);let n=e.id===this.value;n?(t.setAttribute("data-default",""),t.setAttribute("aria-checked","true"),t.setAttribute("tabindex","0")):(t.removeAttribute("data-default"),t.setAttribute("aria-checked","false"),t.setAttribute("tabindex","-1")),this.disabled?t.setAttribute("aria-disabled","true"):t.removeAttribute("aria-disabled");let o=t.querySelector(':scope > header > [slot="icon"] > icon-ui');if(o){let m=sC(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=VO(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=jO(e);l.textContent=m,m?l.removeAttribute("hidden"):l.setAttribute("hidden","")}let h=t.querySelector(':scope > header > [slot="heading"] > [data-default-tag]');h&&(n?h.removeAttribute("hidden"):h.setAttribute("hidden",""));let c=jO(e),u=[VO(e)];c&&u.push(c),n&&u.push("default"),t.setAttribute("aria-label",u.join(", "));let d=t.querySelector(':scope > header > [slot="action"] > [data-action="set-default"]');d&&(n?d.setAttribute("hidden",""):d.removeAttribute("hidden"),this.disabled?d.setAttribute("disabled",""):d.removeAttribute("disabled"));let f=t.querySelector(':scope > header > [slot="action"] > [data-action="edit"]');f&&(this.disabled?f.setAttribute("disabled",""):f.removeAttribute("disabled"));let p=t.querySelector(':scope > header > [slot="action"] > [data-action="remove"]');p&&(this["no-remove"]?p.setAttribute("hidden",""):p.removeAttribute("hidden"),this.disabled?p.setAttribute("disabled",""):p.removeAttribute("disabled"))}#p(){let t=r=>{let n=r.target?.closest?.("button-ui[data-action]");if(n&&this.#i.contains(n)){let a=n.closest("[data-row]");if(!a)return;let l=a.getAttribute("data-id")||"";if(!l)return;if(this.disabled||n.hasAttribute("disabled")){r.stopPropagation();return}let h=(this.methods||[]).find(u=>u.id===l);if(!h)return;let c=n.getAttribute("data-action");r.stopPropagation(),c==="set-default"?this.setDefault(l):c==="remove"?this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{id:l,method:h}})):c==="edit"&&this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{id:l,method:h}}));return}let o=r.target?.closest?.("button-ui[data-add-cta]");if(o&&this.#r?.contains(o)){if(this.disabled||o.hasAttribute("disabled")){r.stopPropagation();return}r.stopPropagation(),this.dispatchEvent(new CustomEvent("add",{bubbles:!0,detail:{}}))}};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=r=>{if(r.target?.closest?.("button-ui[data-action]")||r.target?.closest?.("button-ui[data-add-cta]"))return;let n=r.target?.closest?.("[data-row]");if(!n||!this.#i.contains(n))return;let o=n.getAttribute("data-id")||"";o&&(this.disabled||this.setDefault(o))};this.#i.addEventListener("click",e),this.#e.push(()=>this.#i.removeEventListener("click",e));let i=r=>{let o=document.activeElement?.closest?.("[data-row]");if(!o||!this.#i.contains(o))return;let a=Array.from(this.#i.querySelectorAll(":scope > [data-row]")),l=a.indexOf(o);if(!(l<0)){if(r.key==="ArrowDown"||r.key==="ArrowRight")r.preventDefault(),a[(l+1)%a.length]?.focus?.();else if(r.key==="ArrowUp"||r.key==="ArrowLeft")r.preventDefault(),a[(l-1+a.length)%a.length]?.focus?.();else if(r.key==="Home")r.preventDefault(),a[0]?.focus?.();else if(r.key==="End")r.preventDefault(),a[a.length-1]?.focus?.();else if(r.key===" "||r.key==="Enter"){r.preventDefault();let h=o.getAttribute("data-id")||"";h&&!this.disabled&&this.setDefault(h)}}};this.#i.addEventListener("keydown",i),this.#e.push(()=>this.#i.removeEventListener("keydown",i))}#m(t,e,i){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,method:i}}))}};customElements.get("payment-method-list-ui")||customElements.define("payment-method-list-ui",Ma);Pt();var Wd=new Set(["monthly","annual"]),lq={monthly:"Monthly",annual:"Annual"},hq={monthly:"/month",annual:"/year"};function cq(s,t,e){let i=Number.isFinite(s)?s:0;try{return new Intl.NumberFormat(e||void 0,{style:"currency",currency:t||"USD",maximumFractionDigits:Number.isInteger(i)?0:2}).format(i)}catch{return`${t||"$"}${i}`}}function uq(s,t,e){if(s.cta)return s.cta;if(!e)return`Choose ${s.name||""}`.trim();if(s.id===e)return"Manage";let i=t.find(r=>r.id===e);if(i&&Number.isFinite(i.rank)&&Number.isFinite(s.rank)){if(s.rank>i.rank)return"Upgrade";if(s.rank<i.rank)return"Downgrade"}return`Switch to ${s.name||""}`.trim()}var Ra=class extends R{static labelDeprecated=!0;static get properties(){return{...R.properties,plans:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},current:{type:String,default:"",reflect:!0},cycle:{type:String,default:"monthly",reflect:!0},cycleToggle:{type:Boolean,default:!1,reflect:!0,attribute:"cycle-toggle"},currency:{type:String,default:"USD"},locale:{type:String,default:""},layout:{type:String,default:"grid",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#r=null;#n=null;#a=null;#o=new Map;#l=!1;#h=!1;#c=!1;#d=0;setValue(t){return t?H(()=>{let e=(this.plans||[]).find(r=>r.id===t);if(!e)return!1;if(e.disabled)return this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}})),!1;if(this.value===t)return!0;let i=this.value||"";return this.value=t,this.syncValue(),this.#O(t,i),!0}):!1}setCycle(t){return Wd.has(t)?H(()=>{if(this.cycle===t)return!0;let e=this.cycle;return this.cycle=t,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:t,previous:e}})),!0}):!1}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#d;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(e!==this.#d)return;this.removeAttribute("loading");let n=Array.isArray(r)?r:Array.isArray(r?.plans)?r.plans:[];this.plans=n,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:n.length}}))}catch(i){if(e!==this.#d)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Choose a plan"),this.#t||(this.#u(),this.#f(),this.#b(),this.#t=!0),H(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#l)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.plans)?this.plans:[];if(!Wd.has(this.cycle)){this.#h||(this.#h=!0,console.warn(`[plan-picker-ui] unknown cycle "${this.cycle}" \u2014 coercing to "monthly".`)),this.#l=!0;try{this.cycle="monthly"}finally{this.#l=!1}}let e=t.filter(r=>r.recommended);e.length>1&&!this.#c&&(this.#c=!0,console.warn(`[plan-picker-ui] ${e.length} plans carry recommended:true \u2014 using the first ("${e[0].id}"); ignoring the rest.`));let i=e[0]?.id||"";if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#i){let r=this.cycleToggle&&t.length>0;this.#i.hidden=!r,r&&this.#p()}this.#m(t,i)}#u(){let t=this.querySelector(':scope > script[type="application/json"][data-plans]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.plans=e)}catch(e){console.warn("[plan-picker-ui] failed to parse <script data-plans> JSON:",e?.message)}finally{t.remove()}}#f(){let t=document.createElement("div");t.setAttribute("data-toggle",""),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-plans",""),e.setAttribute("role","presentation"),this.appendChild(e),this.#r=e;let i=document.createElement("div");if(i.setAttribute("data-skeleton",""),i.hidden=!0,this.appendChild(i),this.#n=i,!this.querySelector(':scope > [slot="empty"]')){let r=document.createElement("empty-state-ui");r.setAttribute("data-empty",""),r.setAttribute("icon","package"),r.setAttribute("heading","No plans available"),r.setAttribute("description","Plans will appear here once configured."),this.appendChild(r),this.#a=r}}#p(){if(!this.#i)return;let t=this.#s;if(!t){t=document.createElement("segmented-ui"),t.setAttribute("aria-label","Billing cycle"),this.#i.appendChild(t),this.#s=t;for(let e of["monthly","annual"]){let i=document.createElement("segment-ui");i.setAttribute("value",e),i.setAttribute("text",lq[e]),t.appendChild(i)}}t.value!==this.cycle&&(t.value=this.cycle)}#m(t,e){if(!this.#r)return;let i=new Map;for(let r of t){if(!r?.id)continue;let n=this.#o.get(r.id);n||(n=document.createElement("option-card-ui"),n.setAttribute("layout","tile"),this.#r.appendChild(n)),this.#g(n,r,e),i.set(r.id,n)}for(let[r,n]of this.#o)if(!i.has(r))try{n.remove()}catch{}for(let r of t){let n=i.get(r.id);n&&this.#r.appendChild(n)}this.#o=i}#g(t,e,i){t.setAttribute("name",`${this.name||"plan"}__${this.id||"pp"}`),t.setAttribute("value",e.id),t.setAttribute("heading",e.name||""),t.setAttribute("description",e.tagline||""),e.icon?t.setAttribute("icon",e.icon):t.removeAttribute("icon");let r=!!(this.current&&e.id===this.current),n=e.id===i;r?t.setAttribute("data-current",""):t.removeAttribute("data-current"),n?t.setAttribute("data-recommended",""):t.removeAttribute("data-recommended"),e.disabled||this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.value&&this.value===e.id||!this.value&&r?t.setAttribute("checked",""):t.removeAttribute("checked");let a=t.querySelector(":scope > [data-plan-body]");a||(a=document.createElement("div"),a.setAttribute("data-plan-body",""),t.appendChild(a)),this.#y(a,e);let l=t.querySelector(":scope > [data-plan-tags]");if(l||(l=document.createElement("div"),l.setAttribute("data-plan-tags",""),l.setAttribute("slot","heading-suffix"),t.appendChild(l)),l.replaceChildren(),r){let h=document.createElement("tag-ui");h.setAttribute("text","Current plan"),l.appendChild(h)}else if(n){let h=document.createElement("tag-ui");h.setAttribute("text","Recommended"),h.setAttribute("variant","primary"),l.appendChild(h)}}#y(t,e){t.replaceChildren();let i=document.createElement("div");i.setAttribute("data-price-row","");let r=Wd.has(this.cycle)?this.cycle:"monthly",n=e.prices||{},o=n[r]||n.monthly||null;if(o){let l=document.createElement("span");l.setAttribute("data-price","");let h=o.currency||this.currency||"USD";l.textContent=cq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:hq[r];c.textContent=u,i.appendChild(c)}else{let l=document.createElement("span");l.setAttribute("data-price",""),l.textContent="Contact sales",i.appendChild(l)}if(t.appendChild(i),o?.note){let l=document.createElement("span");l.setAttribute("data-price-note",""),l.textContent=o.note,t.appendChild(l)}if(Array.isArray(e.features)&&e.features.length){let l=document.createElement("ul");l.setAttribute("data-features","");for(let h of e.features){let c=document.createElement("li"),u=document.createElement("icon-ui");u.setAttribute("name","check"),u.setAttribute("aria-hidden","true"),c.appendChild(u);let d=document.createElement("span");d.textContent=String(h),c.appendChild(d),l.appendChild(c)}t.appendChild(l)}if(!!!(this.current&&e.id===this.current)||e.cta){let l=document.createElement("button-ui");l.setAttribute("data-cta",""),l.setAttribute("variant",e.recommended?"primary":"outline"),l.setAttribute("text",uq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#b(){let t=r=>{let n=r?.detail?.value;if(!Wd.has(n)||this.cycle===n)return;r.stopPropagation();let o=this.cycle;this.cycle=n,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:n,previous:o}}))};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=r=>{let n=r.target?.closest?.("option-card-ui");if(!n||!this.#r.contains(n))return;let o=n.getAttribute("value")||"";if(!o)return;let a=(this.plans||[]).find(h=>h.id===o);if(!a)return;if(a.disabled||this.disabled){n.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}}));return}r.stopPropagation();let l=this.value||"";if(l!==o){this.#l=!0;try{this.value=o}finally{this.#l=!1}this.syncValue(),this.#O(o,l)}};this.#r.addEventListener("change",e),this.#e.push(()=>this.#r.removeEventListener("change",e));let i=r=>{let n=r.target?.closest?.("button-ui[data-cta]");if(!n||!this.#r.contains(n))return;let o=n.closest("option-card-ui");if(!o)return;let a=o.getAttribute("value")||"";if(!a)return;let l=(this.plans||[]).find(c=>c.id===a);if(!l||l.disabled||this.disabled)return;r.stopPropagation();let h=this.value||"";if(h!==a){this.#l=!0;try{this.value=a}finally{this.#l=!1}this.syncValue(),this.#O(a,h)}this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:a,cycle:this.cycle}}))};this.#r.addEventListener("press",i),this.#r.addEventListener("click",i),this.#e.push(()=>this.#r.removeEventListener("press",i)),this.#e.push(()=>this.#r.removeEventListener("click",i))}#O(t,e){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,cycle:this.cycle}}))}};customElements.get("plan-picker-ui")||customElements.define("plan-picker-ui",Ra);$();var dq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),fq=6,Ah=class extends v{static properties={integrations:{type:Array,default:[]},loading:{type:Boolean,default:!1,reflect:!0},"search-placeholder":{type:String,default:"Search integrations",reflect:!0},"group-by":{type:String,default:"category",reflect:!0},"status-filter":{type:String,default:"all",reflect:!0}};static template=t=>t._renderTemplate();#t="";#e=`intpage-h-${Math.random().toString(36).slice(2,8)}`;#i=null;attributeChangedCallback(t,e,i){if(t==="integrations"){if(i==null)this.integrations=[];else try{let r=JSON.parse(i);this.integrations=Array.isArray(r)?r:[]}catch{this.integrations=[]}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#e),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Integrations"),this.hasAttribute("integrations")&&!Array.isArray(this.integrations))try{this.integrations=JSON.parse(this.getAttribute("integrations"))}catch{this.integrations=[]}this.addEventListener("input",this.#d),this.addEventListener("change",this.#u)}disconnected(){this.removeEventListener("input",this.#d),this.removeEventListener("change",this.#u),this.#i&&(clearTimeout(this.#i),this.#i=null)}render(){this.#c(),this.querySelector('segmented-ui[data-part="filter"]')?.render?.()}_renderTemplate(){let t=this["search-placeholder"]||"Search integrations",e=this["status-filter"]||"all",i=!!this.loading,r=this.#l();return Y`
461
461
  <header data-part="header">
462
462
  <h2 data-part="title" id=${this.#e}>Integrations</h2>
463
463
  <slot name="header"></slot>