@adia-ai/web-components 0.8.46 → 0.8.47

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.
@@ -38,7 +38,7 @@ var GA=Object.defineProperty;var W=(s,t,e)=>()=>{if(e)throw e[0];try{return s&&(
38
38
  `?"":e;else{let n=e.indexOf(`
39
39
  `);i=n<0?e:e.slice(0,n)}return t+i.length>this.to?i.slice(0,this.to-t):i}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(t,e,i=0){this.block=hu.create(t,i,this.lineStart+e,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(t,e,i=0){this.startContext(this.parser.getNodeType(t),e,i)}addNode(t,e,i){typeof t=="number"&&(t=new J(this.parser.nodeSet.types[t],bo,bo,(i??this.prevLineEnd())-e)),this.block.addChild(t,e-this.block.from)}addElement(t){this.block.addChild(t.toTree(this.parser.nodeSet),t.from-this.block.from)}addLeafElement(t,e){this.addNode(this.buffer.writeElements(Og(e.children,t.marks),-e.from).finish(e.type,e.to-e.from),e.from)}finishContext(){let t=this.stack.pop(),e=this.stack[this.stack.length-1];e.addChild(t.toTree(this.parser.nodeSet),t.from-e.from),this.block=e}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(t){return this.ranges.length>1?ww(this.ranges,0,t.topNode,this.ranges[0].from,this.reusePlaceholders):t}finishLeaf(t){for(let i of t.parsers)if(i.finish(this,t))return;let e=Og(this.parser.parseInline(t.content,t.start),t.marks);this.addNode(this.buffer.writeElements(e,-t.start).finish(q.Paragraph,t.content.length),t.start)}elt(t,e,i,n){return typeof t=="string"?nt(this.parser.getNodeType(t),e,i,n):new gu(t,e)}get buffer(){return new mu(this.parser.nodeSet)}};vo=class s extends ei{constructor(t,e,i,n,r,o,a,l,h){super(),this.nodeSet=t,this.blockParsers=e,this.leafBlockParsers=i,this.blockNames=n,this.endLeafBlock=r,this.skipContextMarkup=o,this.inlineParsers=a,this.inlineNames=l,this.wrappers=h,this.nodeTypes=Object.create(null);for(let c of t.types)this.nodeTypes[c.name]=c.id}createParse(t,e,i){let n=new fu(this,t,e,i);for(let r of this.wrappers)n=r(n,t,e,i);return n}configure(t){let e=mg(t);if(!e)return this;let{nodeSet:i,skipContextMarkup:n}=this,r=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),a=this.blockNames.slice(),l=this.inlineParsers.slice(),h=this.inlineNames.slice(),c=this.endLeafBlock.slice(),u=this.wrappers;if(Xl(e.defineNodes)){n=Object.assign({},n);let d=i.types.slice(),f;for(let p of e.defineNodes){let{name:m,block:g,composite:O,style:w}=typeof p=="string"?{name:p}:p;if(d.some(v=>v.name==m))continue;O&&(n[d.length]=(v,k,b)=>O(k,b,v.value));let x=d.length,S=O?["Block","BlockContext"]:g?x>=q.ATXHeading1&&x<=q.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;d.push(gt.define({id:x,name:m,props:S&&[[F.group,S]]})),w&&(f||(f={}),Array.isArray(w)||w instanceof me?f[m]=w:Object.assign(f,w))}i=new ti(d),f&&(i=i.extend(It(f)))}if(Xl(e.props)&&(i=i.extend(...e.props)),Xl(e.remove))for(let d of e.remove){let f=this.blockNames.indexOf(d),p=this.inlineNames.indexOf(d);f>-1&&(r[f]=o[f]=void 0),p>-1&&(l[p]=void 0)}if(Xl(e.parseBlock))for(let d of e.parseBlock){let f=a.indexOf(d.name);if(f>-1)r[f]=d.parse,o[f]=d.leaf;else{let p=d.before?pu(a,d.before):d.after?pu(a,d.after)+1:a.length-1;r.splice(p,0,d.parse),o.splice(p,0,d.leaf),a.splice(p,0,d.name)}d.endLeaf&&c.push(d.endLeaf)}if(Xl(e.parseInline))for(let d of e.parseInline){let f=h.indexOf(d.name);if(f>-1)l[f]=d.parse;else{let p=d.before?pu(h,d.before):d.after?pu(h,d.after)+1:h.length-1;l.splice(p,0,d.parse),h.splice(p,0,d.name)}}return e.wrap&&(u=u.concat(e.wrap)),new s(i,r,o,a,c,n,l,h,u)}getNodeType(t){let e=this.nodeTypes[t];if(e==null)throw new RangeError(`Unknown node type '${t}'`);return e}parseInline(t,e){let i=new yo(this,t,e);t:for(let n=e;n<i.end;){let r=i.char(n);for(let o of this.inlineParsers)if(o){let a=o(i,r,n);if(a>=0){n=a;continue t}}n++}return i.resolveMarkers(0)}};kw=[gt.none];for(let s=1,t;t=q[s];s++)kw[s]=gt.define({id:s,name:t,props:s>=q.Escape?[]:[[F.group,s in uw?["Block","BlockContext"]:["Block","LeafBlock"]]],top:t=="Document"});bo=[],mu=class{constructor(t){this.nodeSet=t,this.content=[],this.nodes=[]}write(t,e,i,n=0){return this.content.push(t,e,i,4+n*4),this}writeElements(t,e=0){for(let i of t)i.writeTo(this,e);return this}finish(t,e){return J.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:t,length:e})}},cs=class{constructor(t,e,i,n=bo){this.type=t,this.from=e,this.to=i,this.children=n}writeTo(t,e){let i=t.content.length;t.writeElements(this.children,e),t.content.push(this.type,this.from+e,this.to+e,t.content.length+4-i)}toTree(t){return new mu(t).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},gu=class{constructor(t,e){this.tree=t,this.from=e}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return bo}writeTo(t,e){t.nodes.push(this.tree),t.content.push(t.nodes.length-1,this.from+e,this.to+e,-1)}toTree(){return this.tree}};Aw={resolve:"Emphasis",mark:"EmphasisMark"},$w={resolve:"Emphasis",mark:"EmphasisMark"},Gs={},Ou={},he=class{constructor(t,e,i,n){this.type=t,this.from=e,this.to=i,this.side=n}},Cw="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",ql=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{ql=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}gg={Escape(s,t,e){if(t!=92||e==s.end-1)return-1;let i=s.char(e+1);for(let n=0;n<Cw.length;n++)if(Cw.charCodeAt(n)==i)return s.append(nt(q.Escape,e,e+2));return-1},Entity(s,t,e){if(t!=38)return-1;let i=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(s.slice(e+1,e+31));return i?s.append(nt(q.Entity,e,e+1+i[0].length)):-1},InlineCode(s,t,e){if(t!=96||e&&s.char(e-1)==96)return-1;let i=e+1;for(;i<s.end&&s.char(i)==96;)i++;let n=i-e,r=0;for(;i<s.end;i++)if(s.char(i)==96){if(r++,r==n&&s.char(i+1)!=96)return s.append(nt(q.InlineCode,e,i+1,[nt(q.CodeMark,e,e+n),nt(q.CodeMark,i+1-n,i+1)]))}else r=0;return-1},HTMLTag(s,t,e){if(t!=60||e==s.end-1)return-1;let i=s.slice(e+1,s.end),n=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(i);if(n)return s.append(nt(q.Autolink,e,e+1+n[0].length,[nt(q.LinkMark,e,e+1),nt(q.URL,e+1,e+n[0].length),nt(q.LinkMark,e+n[0].length,e+1+n[0].length)]));let r=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);if(r)return s.append(nt(q.Comment,e,e+1+r[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return s.append(nt(q.ProcessingInstruction,e,e+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return a?s.append(nt(q.HTMLTag,e,e+1+a[0].length)):-1},Emphasis(s,t,e){if(t!=95&&t!=42)return-1;let i=e+1;for(;s.char(i)==t;)i++;let n=s.slice(e-1,e),r=s.slice(i,i+1),o=ql.test(n),a=ql.test(r),l=/\s|^$/.test(n),h=/\s|^$/.test(r),c=!h&&(!a||l||o),u=!l&&(!o||h||a),d=c&&(t==42||!u||o),f=u&&(t==42||!c||a);return s.append(new he(t==95?Aw:$w,e,i,(d?1:0)|(f?2:0)))},HardBreak(s,t,e){if(t==92&&s.char(e+1)==10)return s.append(nt(q.HardBreak,e,e+2));if(t==32){let i=e+1;for(;s.char(i)==32;)i++;if(s.char(i)==10&&i>=e+2)return s.append(nt(q.HardBreak,e,i+1))}return-1},Link(s,t,e){return t==91?s.append(new he(Gs,e,e+1,1)):-1},Image(s,t,e){return t==33&&s.char(e+1)==91?s.append(new he(Ou,e,e+2,1)):-1},LinkEnd(s,t,e){if(t!=93)return-1;for(let i=s.parts.length-1;i>=0;i--){let n=s.parts[i];if(n instanceof he&&(n.type==Gs||n.type==Ou)){if(!n.side||s.skipSpace(n.to)==e&&!/[(\[]/.test(s.slice(e+1,e+2)))return s.parts[i]=null,-1;let r=s.takeContent(i),o=s.parts[i]=$M(s,r,n.type==Gs?q.Link:q.Image,n.from,e+1);if(n.type==Gs)for(let a=0;a<i;a++){let l=s.parts[a];l instanceof he&&l.type==Gs&&(l.side=0)}return o.to}}return-1}};yo=class{constructor(t,e,i){this.parser=t,this.text=e,this.offset=i,this.parts=[]}char(t){return t>=this.end?-1:this.text.charCodeAt(t-this.offset)}get end(){return this.offset+this.text.length}slice(t,e){return this.text.slice(t-this.offset,e-this.offset)}append(t){return this.parts.push(t),t.to}addDelimiter(t,e,i,n,r){return this.append(new he(t,e,i,(n?1:0)|(r?2:0)))}get hasOpenLink(){for(let t=this.parts.length-1;t>=0;t--){let e=this.parts[t];if(e instanceof he&&(e.type==Gs||e.type==Ou))return!0}return!1}addElement(t){return this.append(t)}resolveMarkers(t){for(let i=t;i<this.parts.length;i++){let n=this.parts[i];if(!(n instanceof he&&n.type.resolve&&n.side&2))continue;let r=n.type==Aw||n.type==$w,o=n.to-n.from,a,l=i-1;for(;l>=t;l--){let m=this.parts[l];if(m instanceof he&&m.side&1&&m.type==n.type&&!(r&&(n.side&1||m.side&2)&&(m.to-m.from+o)%3==0&&((m.to-m.from)%3||o%3))){a=m;break}}if(!a)continue;let h=n.type.resolve,c=[],u=a.from,d=n.to;if(r){let m=Math.min(2,a.to-a.from,o);u=a.to-m,d=n.from+m,h=m==1?"Emphasis":"StrongEmphasis"}a.type.mark&&c.push(this.elt(a.type.mark,u,a.to));for(let m=l+1;m<i;m++)this.parts[m]instanceof cs&&c.push(this.parts[m]),this.parts[m]=null;n.type.mark&&c.push(this.elt(n.type.mark,n.from,d));let f=this.elt(h,u,d,c);this.parts[l]=r&&a.from!=u?new he(a.type,a.from,u,a.side):null,(this.parts[i]=r&&n.to!=d?new he(n.type,d,n.to,n.side):null)?this.parts.splice(i,0,f):this.parts[i]=f}let e=[];for(let i=t;i<this.parts.length;i++){let n=this.parts[i];n instanceof cs&&e.push(n)}return e}findOpeningDelimiter(t){for(let e=this.parts.length-1;e>=0;e--){let i=this.parts[e];if(i instanceof he&&i.type==t&&i.side&1)return e}return null}takeContent(t){let e=this.resolveMarkers(t);return this.parts.length=t,e}getDelimiterAt(t){let e=this.parts[t];return e instanceof he?e:null}skipSpace(t){return Dl(this.text,t-this.offset)+this.offset}elt(t,e,i,n){return typeof t=="string"?nt(this.parser.getNodeType(t),e,i,n):new gu(t,e)}};yo.linkStart=Gs,yo.imageStart=Ou;CM=[q.CodeBlock,q.ListItem,q.OrderedList,q.BulletList],bg=class{constructor(t,e){this.fragments=t,this.input=e,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,t.length&&(this.fragment=t[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(t,e){for(;this.fragment&&this.fragment.to<=t;)this.nextFragment();if(!this.fragment||this.fragment.from>(t?t-1:0))return!1;if(this.fragmentEnd<0){let r=this.fragment.to;for(;r>0&&this.input.read(r-1,r)!=`
40
40
  `;)r--;this.fragmentEnd=r?r-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let n=t+this.fragment.offset;for(;i.to<=n;)if(!i.parent())return!1;for(;;){if(i.from>=n)return this.fragment.from<=e;if(!i.childAfter(n))return!1}}matches(t){let e=this.cursor.tree;return e&&e.prop(F.contextHash)==t}takeNodes(t){let e=this.cursor,i=this.fragment.offset,n=this.fragmentEnd-(this.fragment.openEnd?1:0),r=t.absoluteLineStart,o=r,a=t.block.children.length,l=o,h=a;for(;;){if(e.to-i>n){if(e.type.isAnonymous&&e.firstChild())continue;break}let c=Tw(e.from-i,t.ranges);if(e.to-i<=t.ranges[t.rangeI].to)t.addNode(e.tree,c);else{let u=new J(t.parser.nodeSet.types[q.Paragraph],[],[],0,t.block.hashProp);t.reusePlaceholders.set(u,e.tree),t.addNode(u,c)}if(e.type.is("Block")&&(CM.indexOf(e.type.id)<0?(o=e.to-i,a=t.block.children.length):(o=l,a=h),l=e.to-i,h=t.block.children.length),!e.nextSibling())break}for(;t.block.children.length>a;)t.block.children.pop(),t.block.positions.pop();return o-r}};EM=It({"Blockquote/...":y.quote,HorizontalRule:y.contentSeparator,"ATXHeading1/... SetextHeading1/...":y.heading1,"ATXHeading2/... SetextHeading2/...":y.heading2,"ATXHeading3/...":y.heading3,"ATXHeading4/...":y.heading4,"ATXHeading5/...":y.heading5,"ATXHeading6/...":y.heading6,"Comment CommentBlock":y.comment,Escape:y.escape,Entity:y.character,"Emphasis/...":y.emphasis,"StrongEmphasis/...":y.strong,"Link/... Image/...":y.link,"OrderedList/... BulletList/...":y.list,"BlockQuote/...":y.quote,"InlineCode CodeText":y.monospace,"URL Autolink":y.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":y.processingInstruction,"CodeInfo LinkLabel":y.labelName,LinkTitle:y.string,Paragraph:y.content}),vg=new vo(new ti(kw).extend(EM),Object.keys(du).map(s=>du[s]),Object.keys(du).map(s=>Sw[s]),Object.keys(du),kM,uw,Object.keys(gg).map(s=>gg[s]),Object.keys(gg),[]);QM={resolve:"Strikethrough",mark:"StrikethroughMark"},Lw={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":y.strikethrough}},{name:"StrikethroughMark",style:y.processingInstruction}],parseInline:[{name:"Strikethrough",parse(s,t,e){if(t!=126||s.char(e+1)!=126||s.char(e+2)==126)return-1;let i=s.slice(e-1,e),n=s.slice(e+2,e+3),r=/\s|^$/.test(i),o=/\s|^$/.test(n),a=ql.test(i),l=ql.test(n);return s.addDelimiter(QM,e,e+2,!o&&(!l||r||a),!r&&(!a||o||l))},after:"Emphasis"}]};Rw=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,bu=class{constructor(){this.rows=null}nextLine(t,e,i){if(this.rows==null){this.rows=!1;let n;if((e.next==45||e.next==58||e.next==124)&&Rw.test(n=e.text.slice(e.pos))){let r=[];Zl(t,i.content,0,r,i.start)==Zl(t,n,e.pos)&&(this.rows=[t.elt("TableHeader",i.start,i.start+i.content.length,r),t.elt("TableDelimiter",t.lineStart+e.pos,t.lineStart+e.text.length)])}}else if(this.rows){let n=[];Zl(t,e.text,e.pos,n,t.lineStart),this.rows.push(t.elt("TableRow",t.lineStart+e.pos,t.lineStart+e.text.length,n))}return!1}finish(t,e){return this.rows?(t.addLeafElement(e,t.elt("Table",e.start,e.start+e.content.length,this.rows)),!0):!1}},Iw={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":y.heading}},"TableRow",{name:"TableCell",style:y.content},{name:"TableDelimiter",style:y.processingInstruction}],parseBlock:[{name:"Table",leaf(s,t){return Mw(t.content,0)?new bu:null},endLeaf(s,t,e){if(e.parsers.some(n=>n instanceof bu)||!Mw(t.text,t.basePos))return!1;let i=s.peekLine();return Rw.test(i)&&Zl(s,t.text,t.basePos)==Zl(s,i,t.basePos)},before:"SetextHeading"}]},yg=class{nextLine(){return!1}finish(t,e){return t.addLeafElement(e,t.elt("Task",e.start,e.start+e.content.length,[t.elt("TaskMarker",e.start,e.start+3),...t.parser.parseInline(e.content.slice(3),e.start+3)])),!0}},Dw={defineNodes:[{name:"Task",block:!0,style:y.list},{name:"TaskMarker",style:y.atom}],parseBlock:[{name:"TaskList",leaf(s,t){return/^\[[ xX]\][ \t]/.test(t.content)&&s.parentType().name=="ListItem"?new yg:null},after:"SetextHeading"}]},Xw=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,qw=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,TM=/[\w-]+\.[\w-]+($|\/)/,Zw=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,Nw=/\/[a-zA-Z\d@.]+/gy;Vw={parseInline:[{name:"Autolink",parse(s,t,e){let i=e-s.offset;if(i&&/\w/.test(s.text[i-1]))return-1;Xw.lastIndex=i;let n=Xw.exec(s.text),r=-1;if(!n)return-1;if(n[1]||n[2]){if(r=LM(s.text,i+n[0].length),r>-1&&s.hasOpenLink){let o=/([^\[\]]|\[[^\]]*\])*/.exec(s.text.slice(i,r));r=i+o[0].length}}else n[3]?r=Bw(s.text,i):(r=Bw(s.text,i+n[0].length),r>-1&&n[0]=="xmpp:"&&(Nw.lastIndex=r,n=Nw.exec(s.text),n&&(r=n.index+n[0].length)));return r<0?-1:(s.addElement(s.elt("URL",e,r+s.offset)),r+s.offset)}}]},Sg=[Iw,Dw,Lw,Vw];wg={defineNodes:[{name:"Superscript",style:y.special(y.content)},{name:"SuperscriptMark",style:y.processingInstruction}],parseInline:[{name:"Superscript",parse:_w(94,"Superscript","SuperscriptMark")}]},kg={defineNodes:[{name:"Subscript",style:y.special(y.content)},{name:"SubscriptMark",style:y.processingInstruction}],parseInline:[{name:"Subscript",parse:_w(126,"Subscript","SubscriptMark")}]},Ag={defineNodes:[{name:"Emoji",style:y.character}],parseInline:[{name:"Emoji",parse(s,t,e){let i;return t!=58||!(i=/^[a-zA-Z_0-9]+:/.exec(s.slice(e+1,s.end)))?-1:s.addElement(s.elt("Emoji",e,e+1+i[0].length))}}]}});var e1={};Jt(e1,{commonmarkLanguage:()=>Tg,deleteMarkupBackward:()=>Rg,insertNewlineContinueMarkup:()=>Mg,insertNewlineContinueMarkupCommand:()=>Lg,markdown:()=>t1,markdownKeymap:()=>Ig,markdownLanguage:()=>xo,pasteURLAsLink:()=>Dg});function $g(s){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return t?+t[1]:void 0}function MM(s){return s.name=="OrderedList"||s.name=="BulletList"}function RM(s,t){let e=s;for(;;){let i=e.nextSibling,n;if(!i||(n=$g(i.type))!=null&&n<=t)break;e=i}return e.to}function Cg(s){return new Tt(Ww,s,[],"markdown")}function XM(s,t){return e=>{if(e&&s){let i=null;if(e=/\S*/.exec(e)[0],typeof s=="function"?i=s(e):i=uo.matchLanguageName(s,e,!0),i instanceof uo)return i.support?i.support.language.parser:as.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}function Yw(s,t){let e=[],i=[];for(let n=s;n;n=n.parent){if(n.name=="FencedCode")return i;(n.name=="ListItem"||n.name=="Blockquote")&&e.push(n)}for(let n=e.length-1;n>=0;n--){let r=e[n],o,a=t.lineAt(r.from),l=r.from-a.from;if(r.name=="Blockquote"&&(o=/^ *>( ?)/.exec(a.text.slice(l))))i.push(new Nl(r,l,l+o[0].length,"",o[1],">",null));else if(r.name=="ListItem"&&r.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(a.text.slice(l)))){let h=o[3],c=o[0].length;h.length>=4&&(h=h.slice(0,h.length-4),c-=4),i.push(new Nl(r.parent,l,l+c,o[1],h,o[2],r))}else if(r.name=="ListItem"&&r.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))){let h=o[4],c=o[0].length;h.length>4&&(h=h.slice(0,h.length-4),c-=4);let u=o[2];o[3]&&(u+=o[3].replace(/[xX]/," ")),i.push(new Nl(r.parent,l,l+c,o[1],h,u,r))}}return i}function Hw(s,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(s.from,s.from+10))}function Eg(s,t,e,i=0){for(let n=-1,r=s;;){if(r.name=="ListItem"){let a=Hw(r,t),l=+a[2];if(n>=0){if(l!=n+1)return;e.push({from:r.from+a[1].length,to:r.from+a[0].length,insert:String(n+2+i)})}n=l}let o=r.nextSibling;if(!o)break;r=o}}function Pg(s,t){let e=/^[ \t]*/.exec(s)[0].length;if(!e||t.facet(Ri)!=" ")return s;let i=Ut(s,4,e),n="";for(let r=i;r>0;)r>=4?(n+=" ",r-=4):(n+=" ",r--);return n+s.slice(e)}function Gw(s){return s.name=="QuoteMark"||s.name=="ListMark"}function qM(s,t){if(s.name!="OrderedList"&&s.name!="BulletList")return!1;let e=s.firstChild,i=s.getChild("ListItem","ListItem");if(!i)return!1;let n=t.lineAt(e.to),r=t.lineAt(i.from),o=/^[\s>]*$/.test(n.text);return n.number+(o?0:1)<r.number}function Kw(s,t,e){let i="";for(let n=0,r=s.length-2;n<=r;n++)i+=s[n].blank(n<r?Ut(e.text,4,s[n+1].from)-i.length:null,n<r);return Pg(i,t)}function ZM(s,t){let e=s.resolveInner(t,-1),i=t;Gw(e)&&(i=e.from,e=e.parent);for(let n;n=e.childBefore(i);)if(Gw(n))i=n.from;else if(n.name=="OrderedList"||n.name=="BulletList")e=n.lastChild,i=e.to;else break;return e}function t1(s={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:i=!0,base:{parser:n}=Tg,completeHTMLTags:r=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=Jw}=s;if(!(n instanceof vo))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],h=[a.support,IM],c;o&&h.push(Dg),e instanceof kt?(h.push(e.support),c=e.language):e&&(c=e);let u=t||c?XM(t,c):void 0;l.push(xg({codeParser:u,htmlParser:a.language.parser})),i&&h.push(ge.high(ci.of(Ig)));let d=Cg(n.configure(l));return r&&h.push(d.data.of({autocomplete:NM})),new kt(d,h)}function NM(s){let{state:t,pos:e}=s,i=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(e-25,e));if(!i)return null;let n=et(t).resolveInner(e,-1);for(;n&&!n.type.isTop;){if(n.name=="CodeBlock"||n.name=="FencedCode"||n.name=="ProcessingInstructionBlock"||n.name=="CommentBlock"||n.name=="Link"||n.name=="Image")return null;n=n.parent}return{from:e-i[0].length,to:e,options:zM(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}function zM(){if(Qg)return Qg;let s=au(new Us(ht.create({extensions:Jw}),0,!0));return Qg=s?s.options:[]}var Ww,Fw,Uw,IM,Tg,DM,xo,Nl,Lg,Mg,Rg,Ig,Jw,Qg,BM,Dg,i1=W(()=>{ai();Ei();fi();Wm();jw();og();We();Ww=Vs({commentTokens:{block:{open:"<!--",close:"-->"}}}),Fw=new F,Uw=vg.configure({props:[le.add(s=>!s.is("Block")||s.is("Document")||$g(s)!=null||MM(s)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),Fw.add($g),ae.add({Document:()=>null}),ui.add({Document:Ww})]});IM=Bc.of((s,t,e)=>{for(let i=et(s).resolveInner(e,-1);i&&!(i.from<t);i=i.parent){let n=i.type.prop(Fw);if(n==null)continue;let r=RM(i,n);if(r>e)return{from:e,to:r}}return null});Tg=Cg(Uw),DM=Uw.configure([Sg,kg,wg,Ag,{props:[le.add({Table:(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}]),xo=Cg(DM);Nl=class{constructor(t,e,i,n,r,o,a){this.node=t,this.from=e,this.to=i,this.spaceBefore=n,this.spaceAfter=r,this.type=o,this.item=a}blank(t,e=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;i.length<t;)i+=" ";return i}else{for(let n=this.to-this.from-i.length-this.spaceAfter.length;n>0;n--)i+=" ";return i+(e?this.spaceAfter:"")}}marker(t,e){let i=this.node.name=="OrderedList"?String(+Hw(this.item,t)[2]+e):"";return this.spaceBefore+i+this.type+this.spaceAfter}};Lg=(s={})=>({state:t,dispatch:e})=>{let i=et(t),{doc:n}=t,r=null,o=t.changeByRange(a=>{if(!a.empty||!xo.isActiveAt(t,a.from,-1)&&!xo.isActiveAt(t,a.from,1))return r={range:a};let l=a.from,h=n.lineAt(l),c=Yw(i.resolveInner(l,-1),n);for(;c.length&&c[c.length-1].from>l-h.from;)c.pop();if(!c.length)return r={range:a};let u=c[c.length-1];if(u.to-u.spaceAfter.length>l-h.from)return r={range:a};let d=l>=u.to-u.spaceAfter.length&&!/\S/.test(h.text.slice(u.to));if(u.item&&d){if(u.item.from<h.from&&!/^[\s>]*$/.test(h.text.slice(0,u.to)))return r={range:a};let O=u.node.firstChild,w=u.node.getChild("ListItem","ListItem");if(O.to>=l||w&&w.to<l||h.from>0&&!/[^\s>]/.test(n.lineAt(h.from-1).text)||s.nonTightLists===!1){let x=c.length>1?c[c.length-2]:null,S,v="";x&&x.item?(S=h.from+x.from,v=x.marker(n,1)):S=h.from+(x?x.to:0);let k=[{from:S,to:l,insert:v}];return u.node.name=="OrderedList"&&Eg(u.item,n,k,-2),x&&x.node.name=="OrderedList"&&Eg(x.item,n,k),{range:R.cursor(S+v.length),changes:k}}else{let x=Kw(c,t,h);return{range:R.cursor(l+x.length+1),changes:{from:h.from,insert:x+t.lineBreak}}}}if(u.node.name=="Blockquote"&&d&&h.from){let O=n.lineAt(h.from-1),w=/>\s*$/.exec(O.text);if(w&&w.index==u.from){let x=t.changes([{from:O.from+w.index,to:O.to},{from:h.from+u.from,to:h.to}]);return{range:a.map(x),changes:x}}}let f=[];u.node.name=="OrderedList"&&Eg(u.item,n,f);let p=u.item&&u.item.from<h.from,m="";if(!p||/^[\s\d.)\-+*>]*/.exec(h.text)[0].length>=u.to)for(let O=0,w=c.length-1;O<=w;O++)m+=O==w&&!p?c[O].marker(n,1):c[O].blank(O<w?Ut(h.text,4,c[O+1].from)-m.length:null);let g=l;for(;g>h.from&&/\s/.test(h.text.charAt(g-h.from-1));)g--;return m=Pg(m,t),qM(u.node,t.doc)&&(m=Kw(c,t,h)+t.lineBreak+m),f.push({from:g,to:l,insert:t.lineBreak+m}),{range:R.cursor(g+m.length+1),changes:f}});return r?!1:(e(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},Mg=Lg();Rg=({state:s,dispatch:t})=>{let e=et(s),i=null,n=s.changeByRange(r=>{let o=r.from,{doc:a}=s;if(r.empty&&xo.isActiveAt(s,r.from)){let l=a.lineAt(o),h=Yw(ZM(e,o),a);if(h.length){let c=h[h.length-1],u=c.to-c.spaceAfter.length+(c.spaceAfter?1:0);if(o-l.from>u&&!/\S/.test(l.text.slice(u,o-l.from)))return{range:R.cursor(l.from+u),changes:{from:l.from+u,to:o}};if(o-l.from==u&&(c.item&&l.from<=c.item.from||/^[\s>]*$/.test(l.text.slice(0,c.to)))){let d=l.from+c.from;if(c.item&&c.node.from<c.item.from&&/\S/.test(l.text.slice(c.from,c.to))){let f=c.blank(Ut(l.text,4,c.to)-Ut(l.text,4,c.from));return d==l.from&&(f=Pg(f,s)),{range:R.cursor(d+f.length),changes:{from:d,to:l.from+c.to,insert:f}}}if(d<o)return{range:R.cursor(d),changes:{from:d,to:o}}}}}return i={range:r}});return i?!1:(t(s.update(n,{scrollIntoView:!0,userEvent:"delete"})),!0)},Ig=[{key:"Enter",run:Mg},{key:"Backspace",run:Rg}],Jw=lu({matchClosingTags:!1});Qg=null;BM=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Dg=Z.domEventHandlers({paste:(s,t)=>{var e;let{main:i}=t.state.selection;if(i.empty)return!1;let n=(e=s.clipboardData)===null||e===void 0?void 0:e.getData("text/plain");if(!n||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(n)||(/^www\./.test(n)&&(n="https://"+n),!xo.isActiveAt(t.state,i.from,1)))return!1;let r=et(t.state),o=!1;return r.iterate({from:i.from,to:i.to,enter:a=>{(a.from>i.from||BM.test(a.name))&&(o=!0)},leave:a=>{a.to<i.to&&(o=!0)}}),o?!1:(t.dispatch({changes:[{from:i.from,insert:"["},{from:i.to,insert:`](${n})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}})});function Bl(s,t){for(let e=0,i=t-s.pos-1;;i--,e++){let n=s.peek(i);if(Zi(n)||n==-1)return e}}function Ng(s){return s==32||s==9}function Zi(s){return s==10||s==13}function l1(s){return Ng(s)||Zi(s)}function Ks(s){return s<0||l1(s)}function wo(s,t,e=0){return s.peek(e)==t&&s.peek(e+1)==t&&s.peek(e+2)==t&&Ks(s.peek(e+3))}function cR(s){return s>32&&s<127&&s!=34&&s!=37&&s!=44&&s!=60&&s!=62&&s!=92&&s!=94&&s!=96&&s!=123&&s!=124&&s!=125}function h1(s){return s>=48&&s<=57||s>=97&&s<=102||s>=65&&s<=70}function c1(s,t){return s.next==37?(s.advance(),h1(s.next)&&s.advance(),h1(s.next)&&s.advance(),!0):cR(s.next)||t&&s.next==44?(s.advance(),!0):!1}function u1(s){if(s.advance(),s.next==60){for(s.advance();;)if(!c1(s,!0)){s.next==62&&s.advance();break}}else for(;c1(s,!1););}function zg(s){for(s.advance();!Ks(s.next)&&yu(s.next)!="f";)s.advance()}function Bg(s,t){let e=s.next,i=!1,n=s.pos;for(s.advance();;){let r=s.next;if(r<0)break;if(s.advance(),r==e)if(r==39)if(s.next==39)s.advance();else break;else break;else if(r==92&&e==34)s.next>=0&&s.advance();else if(Zi(r)){if(t)return!1;i=!0}else if(t&&s.pos>=n+1024)return!1}return!i}function uR(s){for(let t=[],e=s.pos+1024;;)if(s.next==91||s.next==123)t.push(s.next),s.advance();else if(s.next==39||s.next==34){if(!Bg(s,!0))return!1}else if(s.next==93||s.next==125){if(t[t.length-1]!=s.next-2)return!1;if(t.pop(),s.advance(),!t.length)return!0}else{if(s.next<0||s.pos>e||Zi(s.next))return!1;s.advance()}}function yu(s){return s<33?"u":s>125?"s":dR[s-33]}function Vg(s,t){let e=yu(s);return e!="u"&&!(t&&e=="f")}function d1(s,t,e,i){if(yu(s.next)=="s"||(s.next==63||s.next==58||s.next==45)&&Vg(s.peek(1),e))s.advance();else return!1;let n=s.pos;for(;;){let r=s.next,o=0,a=i+1;for(;l1(r);){if(Zi(r)){if(t)return!1;a=0}else a++;r=s.peek(++o)}if(!(r>=0&&(r==58?Vg(s.peek(o+1),e):r==35?s.peek(o-1)!=32:Vg(r,e)))||!e&&a<=i||a==0&&!e&&(wo(s,45,o)||wo(s,46,o)))break;if(t&&yu(r)=="f")return!1;for(let h=o;h>=0;h--)s.advance();if(t&&s.pos>n+1024)return!1}return!0}var So,s1,VM,_M,n1,jM,r1,WM,FM,o1,UM,YM,HM,GM,KM,JM,a1,tR,eR,iR,sR,nR,rR,oR,Xg,qg,zl,Zg,qi,aR,lR,hR,dR,fR,pR,mR,_g,f1=W(()=>{Cs();ri();So=63,s1=64,VM=1,_M=2,n1=3,jM=4,r1=5,WM=6,FM=7,o1=65,UM=66,YM=8,HM=9,GM=10,KM=11,JM=12,a1=13,tR=19,eR=20,iR=29,sR=33,nR=34,rR=47,oR=0,Xg=1,qg=2,zl=3,Zg=4,qi=class{constructor(t,e,i){this.parent=t,this.depth=e,this.type=i,this.hash=(t?t.hash+t.hash<<8:0)+e+(e<<4)+i}};qi.top=new qi(null,-1,oR);aR=new wi({start:qi.top,reduce(s,t){return s.type==zl&&(t==eR||t==nR)?s.parent:s},shift(s,t,e,i){if(t==n1)return new qi(s,Bl(i,i.pos),Xg);if(t==o1||t==r1)return new qi(s,Bl(i,i.pos),qg);if(t==So)return s.parent;if(t==tR||t==sR)return new qi(s,0,zl);if(t==a1&&s.type==Zg)return s.parent;if(t==rR){let n=/[1-9]/.exec(i.read(i.pos,e.pos));if(n)return new qi(s,s.depth+ +n[0],Zg)}return s},hash(s){return s.hash}});lR=new Ot((s,t)=>{if(s.next==-1&&t.canShift(s1))return s.acceptToken(s1);let e=s.peek(-1);if((Zi(e)||e<0)&&t.context.type!=zl){if(wo(s,45))if(t.canShift(So))s.acceptToken(So);else return s.acceptToken(VM,3);if(wo(s,46))if(t.canShift(So))s.acceptToken(So);else return s.acceptToken(_M,3);let i=0;for(;s.next==32;)i++,s.advance();(i<t.context.depth||i==t.context.depth&&t.context.type==Xg&&(s.next!=45||!Ks(s.peek(1))))&&s.next!=-1&&!Zi(s.next)&&s.next!=35&&s.acceptToken(So,-i)}},{contextual:!0}),hR=new Ot((s,t)=>{if(t.context.type==zl){s.next==63&&(s.advance(),Ks(s.next)&&s.acceptToken(FM));return}if(s.next==45)s.advance(),Ks(s.next)&&s.acceptToken(t.context.type==Xg&&t.context.depth==Bl(s,s.pos-1)?jM:n1);else if(s.next==63)s.advance(),Ks(s.next)&&s.acceptToken(t.context.type==qg&&t.context.depth==Bl(s,s.pos-1)?WM:r1);else{let e=s.pos;for(;;)if(Ng(s.next)){if(s.pos==e)return;s.advance()}else if(s.next==33)u1(s);else if(s.next==38)zg(s);else if(s.next==42){zg(s);break}else if(s.next==39||s.next==34){if(Bg(s,!0))break;return}else if(s.next==91||s.next==123){if(!uR(s))return;break}else{d1(s,!0,!1,0);break}for(;Ng(s.next);)s.advance();if(s.next==58){if(s.pos==e&&t.canShift(iR))return;let i=s.peek(1);Ks(i)&&s.acceptTokenTo(t.context.type==qg&&t.context.depth==Bl(s,e)?UM:o1,e)}}},{contextual:!0});dR="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";fR=new Ot((s,t)=>{if(s.next==33)u1(s),s.acceptToken(JM);else if(s.next==38||s.next==42){let e=s.next==38?GM:KM;zg(s),s.acceptToken(e)}else s.next==39||s.next==34?(Bg(s,!1),s.acceptToken(HM)):d1(s,!1,t.context.type==zl,t.context.depth)&&s.acceptToken(YM)}),pR=new Ot((s,t)=>{let e=t.context.type==Zg?t.context.depth:-1,i=s.pos;t:for(;;){let n=0,r=s.next;for(;r==32;)r=s.peek(++n);if(!n&&(wo(s,45,n)||wo(s,46,n))||!Zi(r)&&(e<0&&(e=Math.max(t.context.depth+1,n)),n<e))break;for(;;){if(s.next<0)break t;let o=Zi(s.next);if(s.advance(),o)continue t;i=s.pos}}s.acceptTokenTo(a1,i)}),mR=It({DirectiveName:y.keyword,DirectiveContent:y.attributeValue,"DirectiveEnd DocEnd":y.meta,QuotedLiteral:y.string,BlockLiteralHeader:y.special(y.string),BlockLiteralContent:y.content,Literal:y.content,"Key/Literal Key/QuotedLiteral":y.definition(y.propertyName),"Anchor Alias":y.labelName,Tag:y.typeName,Comment:y.lineComment,": , -":y.separator,"?":y.punctuation,"[ ]":y.squareBracket,"{ }":y.brace}),_g=ee.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"\u26A0 DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:aR,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[mR],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[lR,hR,fR,pR,0,1],topRules:{Stream:[0,15]},tokenPrec:0})});var g1={};Jt(g1,{yaml:()=>p1,yamlFrontmatter:()=>m1,yamlLanguage:()=>vu});function p1(){return new kt(vu)}function m1(s){let{language:t,support:e}=s.content instanceof kt?s.content:{language:s.content,support:[]};return new kt(OR.configure({wrap:$s(i=>i.name=="FrontmatterContent"?{parser:vu.parser}:i.name=="Body"?{parser:t.parser}:null)}),e)}var gR,vu,OR,O1=W(()=>{f1();fi();We();ri();Cs();gR=ee.deserialize({version:14,states:"!vOQOPOOO]OPO'#C_OhOPO'#C^OOOO'#Cc'#CcOpOPO'#CaQOOOOOO{OPOOOOOO'#Cb'#CbO!WOPO'#C`O!`OPO,58xOOOO-E6a-E6aOOOO-E6`-E6`OOOO'#C_'#C_OOOO1G.d1G.d",stateData:"!h~OXPOYROWTP~OWVXXRXYRX~OYVOXSP~OXROYROWTX~OXROYROWTP~OYVOXSX~OX[O~OXY~",goto:"vWPPX[beioRUOQQOR]XRXQTTOUQWQRZWSSOURYS",nodeNames:"\u26A0 Document Frontmatter DashLine FrontmatterContent Body",maxTerm:10,skippedNodes:[0],repeatNodeCount:2,tokenData:"$z~RXOYnYZ!^Z]n]^!^^}n}!O!i!O;'Sn;'S;=`!c<%lOn~qXOYnYZ!^Z]n]^!^^;'Sn;'S;=`!c<%l~n~On~~!^~!cOY~~!fP;=`<%ln~!lZOYnYZ!^Z]n]^!^^}n}!O#_!O;'Sn;'S;=`!c<%l~n~On~~!^~#bZOYnYZ!^Z]n]^!^^}n}!O$T!O;'Sn;'S;=`!c<%l~n~On~~!^~$WXOYnYZ$sZ]n]^$s^;'Sn;'S;=`!c<%l~n~On~~$s~$zOX~Y~",tokenizers:[0],topRules:{Document:[0,1]},tokenPrec:67}),vu=ye.define({name:"yaml",parser:_g.configure({props:[ae.add({Stream:s=>{for(let t=s.node.resolve(s.pos,-1);t&&t.to>=s.pos;t=t.parent){if(t.name=="BlockLiteralContent"&&t.from<t.to)return s.baseIndentFor(t);if(t.name=="BlockLiteral")return s.baseIndentFor(t)+s.unit;if(t.name=="BlockSequence"||t.name=="BlockMapping")return s.column(t.firstChild.from,1);if(t.name=="QuotedLiteral")return null;if(t.name=="Literal"){let e=s.column(t.from,1);if(e==s.lineIndent(t.from,1))return e;if(t.to>s.pos)return null}}return null},FlowMapping:po({closing:"}"}),FlowSequence:po({closing:"]"})}),le.add({"FlowMapping FlowSequence":Ii,"Item Pair BlockLiteral":(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});OR=ye.define({name:"yaml-frontmatter",parser:gR.configure({props:[It({DashLine:y.meta})]})})});function Js(s,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=s(t,e);return n?(i(e.update(n)),!0):!1}}function jg(s,t){let e=s.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}function SR(s,{open:t,close:e},i,n){let r=s.sliceDoc(i-Vl,i),o=s.sliceDoc(n,n+Vl),a=/\s*$/.exec(r)[0].length,l=/^\s*/.exec(o)[0].length,h=r.length-a;if(r.slice(h-t.length,h)==t&&o.slice(l,l+e.length)==e)return{open:{pos:i-a,margin:a&&1},close:{pos:n+l,margin:l&&1}};let c,u;n-i<=2*Vl?c=u=s.sliceDoc(i,n):(c=s.sliceDoc(i,i+Vl),u=s.sliceDoc(n-Vl,n));let d=/^\s*/.exec(c)[0].length,f=/\s*$/.exec(u)[0].length,p=u.length-f-e.length;return c.slice(d,d+t.length)==t&&u.slice(p,p+e.length)==e?{open:{pos:i+d+t.length,margin:/\s/.test(c.charAt(d+t.length))?1:0},close:{pos:n-f-e.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function wR(s){let t=[];for(let e of s.selection.ranges){let i=s.doc.lineAt(e.from),n=e.to<=i.to?i:s.doc.lineAt(e.to);n.from>i.from&&n.from==e.to&&(n=e.to==i.to+1?i:s.doc.lineAt(e.to-1));let r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=n.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return t}function xu(s,t,e=t.selection.ranges){let i=e.map(r=>jg(t,r.from).block);if(!i.every(r=>r))return null;let n=e.map((r,o)=>SR(t,i[o],r.from,r.to));if(s!=2&&!n.every(r=>r))return{changes:t.changes(e.map((r,o)=>n[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(s!=1&&n.some(r=>r)){let r=[];for(let o=0,a;o<n.length;o++)if(a=n[o]){let l=i[o],{open:h,close:c}=a;r.push({from:h.pos-l.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+l.close.length})}return{changes:r}}return null}function Wg(s,t,e=t.selection.ranges){let i=[],n=-1;t:for(let{from:r,to:o}of e){let a=i.length,l=1e9,h;for(let c=r;c<=o;){let u=t.doc.lineAt(c);if(h==null&&(h=jg(t,u.from).line,!h))continue t;if(u.from>n&&(r==o||o>u.from)){n=u.from;let d=/^\s*/.exec(u.text)[0].length,f=d==u.length,p=u.text.slice(d,d+h.length)==h?d:-1;d<u.text.length&&d<l&&(l=d),i.push({line:u,comment:p,token:h,indent:d,empty:f,single:!1})}c=u.to+1}if(l<1e9)for(let c=a;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=l);i.length==a+1&&(i[a].single=!0)}if(s!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:a,token:l,indent:h,empty:c,single:u}of i)(u||!c)&&r.push({from:a.from+h,insert:l+" "});let o=t.changes(r);return{changes:o,selection:t.selection.map(o,1)}}else if(s!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:a,token:l}of i)if(a>=0){let h=o.from+a,c=h+l.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}function Du(s={}){return[Su,k1.of(s),Z.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?Ug:t.inputType=="historyRedo"?ku:null;return i?(t.preventDefault(),i(e)):!1}})]}function wu(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let n=e.field(Su,!1);if(!n)return!1;let r=n.pop(s,e,t);return r?(i(r),!0):!1}}function C1(s){return function(t){let e=t.field(Su,!1);if(!e)return 0;let i=s==0?e.done:e.undone;return i.length-(i.length&&!i[0].changes?1:0)}}function Au(s,t,e,i){let n=t+1>e+20?t-e-1:0,r=s.slice(n,t);return r.push(i),r}function CR(s,t){let e=[],i=!1;return s.iterChangedRanges((n,r)=>e.push(n,r)),t.iterChangedRanges((n,r,o,a)=>{for(let l=0;l<e.length;){let h=e[l++],c=e[l++];a>=h&&o<=c&&(i=!0)}}),i}function ER(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function E1(s,t){return s.length?t.length?s.concat(t):s:t}function P1(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-PR));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),Au(s,s.length-1,1e9,e.setSelAfter(i)))}else return[Ue.selection([t])]}function QR(s){let t=s[s.length-1],e=s.slice();return e[s.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function Yg(s,t){if(!s.length)return s;let e=s.length,i=Ne;for(;e;){let n=TR(s[e-1],t,i);if(n.changes&&!n.changes.empty||n.effects.length){let r=s.slice(0,e);return r[e-1]=n,r}else t=n.mapped,e--,i=n.selectionsAfter}return i.length?[Ue.selection(i)]:Ne}function TR(s,t,e){let i=E1(s.selectionsAfter.length?s.selectionsAfter.map(a=>a.map(t)):Ne,e);if(!s.changes)return Ue.selection(i);let n=s.changes.map(t),r=t.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(r):r;return new Ue(n,Y.mapEffects(s.effects,t),o,s.startSelection.map(r),i)}function ko(s,t){return R.create(s.ranges.map(t),s.mainIndex)}function Ye(s,t){return s.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function xe({state:s,dispatch:t},e){let i=ko(s.selection,e);return i.eq(s.selection,!0)?!1:(t(Ye(s,i)),!0)}function en(s,t){return R.cursor(t?s.to:s.from)}function $u(s,t){return xe(s,e=>e.empty?s.moveByChar(e,t):en(e,t))}function Ht(s){return s.textDirectionAt(s.state.selection.main.head)==rt.LTR}function Kg(s,t,e){let i=t.head,n=s.doc.lineAt(i);return i==(e?n.to:n.from)?i=e?Math.min(s.doc.length,n.to+1):Math.max(0,n.from-1):i=n.from+Ct(n.text,i-n.from,e),R.cursor(i,e?-1:1)}function Q1(s,t){return xe(s,e=>e.empty?Kg(s.state,e,t):en(e,t))}function Cu(s,t){return xe(s,e=>e.empty?s.moveByGroup(e,t):en(e,t))}function Jg(s,t,e){let i=s.state.charCategorizer(t),n=i(e),r=n!=bt.Space;return o=>{let a=i(o);return a!=bt.Space?r&&a==n:(r=!1,!0)}}function R1(s,t,e){let i=s.state.charCategorizer(t.from),n=bt.Space,r=t.from,o=0,a=!1,l=!1,h=!1,c=d=>{if(a)return!1;r+=e?d.length:-d.length;let f=i(d),p;if(f==bt.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(f=-1),n==bt.Space&&(n=f),n!=f)return!1;if(n==bt.Word)if(d.toLowerCase()==d){if(!e&&l)return!1;h=!0}else if(h){if(e)return!1;a=!0}else{if(l&&e&&i(p=s.state.sliceDoc(r,r+1))==bt.Word&&p.toLowerCase()==p)return!1;l=!0}return o++,!0},u=s.moveByChar(t,e,d=>(c(d),c));if(M1&&n==bt.Word&&u.from==t.from+o*(e?1:-1)){let d=Math.min(t.head,u.head),f=Math.max(t.head,u.head),p=s.state.sliceDoc(d,f);if(p.length>1&&/[\u4E00-\uffff]/.test(p)){let m=Array.from(M1.segment(p));if(m.length>1)return e?R.cursor(t.head+m[1].index,-1):R.cursor(u.head+m[m.length-1].index,1)}}return u}function I1(s,t){return xe(s,e=>e.empty?R1(s,e,t):en(e,t))}function BR(s,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(t.from,t.to)))||t.firstChild}function Eu(s,t,e){let i=et(s).resolveInner(t.head),n=e?F.closedBy:F.openedBy;for(let l=t.head;;){let h=e?i.childAfter(l):i.childBefore(l);if(!h)break;BR(s,h,n)?i=h:l=e?h.to:h.from}let r=i.type.prop(n),o,a;return r&&(o=e?qe(s,i.from,1):qe(s,i.to,-1))&&o.matched?a=e?o.end.to:o.end.from:a=e?i.to:i.from,R.cursor(a,e?-1:1)}function q1(s,t){return xe(s,e=>{if(!e.empty)return en(e,t);let i=s.moveVertically(e,t);return i.head!=e.head?i:s.moveToLineBoundary(e,t)})}function Z1(s){let t=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,e=0,i=0,n;if(t){for(let r of s.state.facet(Z.scrollMargins)){let o=r(s);o?.top&&(e=Math.max(o?.top,e)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=s.scrollDOM.clientHeight-e-i}else n=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(s.defaultLineHeight,n-5)}}function N1(s,t){let e=Z1(s),{state:i}=s,n=ko(i.selection,o=>o.empty?s.moveVertically(o,t,e.height):en(o,t));if(n.eq(i.selection))return!1;let r;if(e.selfScroll){let o=s.coordsAtPos(i.selection.main.head),a=s.scrollDOM.getBoundingClientRect(),l=a.top+e.marginTop,h=a.bottom-e.marginBottom;o&&o.top>l&&o.bottom<h&&(r=Z.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-l}))}return s.dispatch(Ye(i,n),{effects:r}),!0}function us(s,t,e){let i=s.lineBlockAt(t.head),n=s.moveToLineBoundary(t,e);if(n.head==t.head&&n.head!=(e?i.to:i.from)&&(n=s.moveToLineBoundary(t,e,!1)),!e&&n.head==i.from&&i.length){let r=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&t.head!=i.from+r&&(n=R.cursor(i.from+r))}return n}function F1(s,t,e){let i=!1,n=ko(s.selection,r=>{let o=qe(s,r.head,-1)||qe(s,r.head,1)||r.head>0&&qe(s,r.head-1,1)||r.head<s.doc.length&&qe(s,r.head+1,-1);if(!o||!o.end)return r;i=!0;let a=o.start.from==r.head?o.end.to:o.end.from;return e?R.range(r.anchor,a):R.cursor(a)});return i?(t(Ye(s,n)),!0):!1}function Gt(s,t,e){let i=ko(s.state.selection,n=>{n.undirectional&&n.head>=n.anchor!=t&&(n=R.range(n.head,n.anchor));let r=e(n);return R.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(s.state.selection)?!1:(s.dispatch(Ye(s.state,i)),!0)}function Qu(s,t){return Gt(s,t,e=>s.moveByChar(e,t))}function Tu(s,t){return Gt(s,t,e=>s.moveByGroup(e,t))}function G1(s,t){return Gt(s,t,e=>R1(s,e,t))}function tk(s,t){return Gt(s,t,e=>s.moveVertically(e,t))}function ek(s,t){return Gt(s,t,e=>s.moveVertically(e,t,Z1(s).height))}function uk(s,t){let{state:e}=s,i=e.selection,n=e.selection.ranges.slice();for(let r of e.selection.ranges){let o=e.doc.lineAt(r.head);if(t?o.to<s.state.doc.length:o.from>0)for(let a=r;;){let l=s.moveVertically(a,t);if(l.head<o.from||l.head>o.to){n.some(h=>h.head==l.head)||n.push(l);break}else{if(l.head==a.head)break;a=l}}}return n.length==i.ranges.length?!1:(s.dispatch(Ye(e,R.create(n,n.length-1))),!0)}function sn(s,t){if(s.state.readOnly)return!1;let e="delete.selection",{state:i}=s,n=i.changeByRange(r=>{let{from:o,to:a}=r;if(o==a){let l=t(r);l<o?(e="delete.backward",l=Lu(s,l,!1)):l>o&&(e="delete.forward",l=Lu(s,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Lu(s,o,!1),a=Lu(s,a,!0);return o==a?{range:r}:{changes:{from:o,to:a},range:R.cursor(o,o<r.head?-1:1)}});return n.changes.empty?!1:(s.dispatch(i.update(n,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?Z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Lu(s,t,e){if(s instanceof Z)for(let i of s.state.facet(Z.atomicRanges).map(n=>n(s)))i.between(t,t,(n,r)=>{n<t&&r>t&&(t=e?r:n)});return t}function Ru(s){let t=[],e=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.from),r=s.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=s.doc.lineAt(i.to-1)),e>=n.number){let o=t[t.length-1];o.to=r.to,o.ranges.push(i)}else t.push({from:n.from,to:r.to,ranges:[i]});e=r.number+1}return t}function Sk(s,t,e){if(s.readOnly)return!1;let i=[],n=[];for(let r of Ru(s)){if(e?r.to==s.doc.length:r.from==0)continue;let o=s.doc.lineAt(e?r.to+1:r.from-1),a=o.length+1;if(e){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+s.lineBreak});for(let l of r.ranges)n.push(R.range(Math.min(s.doc.length,l.anchor+a),Math.min(s.doc.length,l.head+a)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:s.lineBreak+o.text});for(let l of r.ranges)n.push(R.range(l.anchor-a,l.head-a))}}return i.length?(t(s.update({changes:i,scrollIntoView:!0,selection:R.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}function Ak(s,t,e){if(s.readOnly)return!1;let i=[];for(let r of Ru(s))e?i.push({from:r.from,insert:s.doc.slice(r.from,r.to)+s.lineBreak}):i.push({from:r.to,insert:s.lineBreak+s.doc.slice(r.from,r.to)});let n=s.changes(i);return t(s.update({changes:n,selection:s.selection.map(n,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}function rI(s,t){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=et(s).resolveInner(t),i=e.childBefore(t),n=e.childAfter(t),r;return i&&n&&i.to<=t&&n.from>=t&&(r=i.type.prop(F.closedBy))&&r.indexOf(n.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(n.from).from&&!/\S/.test(s.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}function Qk(s){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{let{from:r,to:o}=n,a=t.doc.lineAt(r),l=!s&&r==o&&rI(t,r);s&&(r=o=(o<=a.to?a:t.doc.lineAt(o)).to);let h=new Ti(t,{simulateBreak:r,simulateDoubleBreak:!!l}),c=fo(h,r);for(c==null&&(c=Ut(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:r,to:o}=l:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let u=["",ls(t,c)];return l&&u.push(ls(t,h.lineIndent(a.from,-1))),{changes:{from:r,to:o,insert:it.of(u)},range:R.cursor(r+1+u[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function OO(s,t){let e=-1;return s.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let a=s.doc.lineAt(o);a.number>e&&(i.empty||i.to>a.from)&&(t(a,n,i),e=a.number),o=a.to+1}let r=s.changes(n);return{changes:n,range:R.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}var b1,y1,bR,yR,v1,vR,xR,x1,Vl,Fg,S1,w1,k1,Su,kR,Ug,ku,A1,$1,AR,$R,Ue,Ne,PR,LR,tn,Xu,Hg,Gg,MR,RR,IR,DR,T1,L1,XR,qR,ZR,M1,NR,zR,D1,X1,tO,eO,iO,Pu,z1,B1,V1,_1,j1,W1,U1,VR,sO,nO,_R,jR,WR,FR,Y1,H1,UR,YR,HR,GR,KR,K1,J1,rO,oO,aO,lO,ik,sk,nk,rk,ok,ak,hO,cO,uO,dO,lk,hk,ck,dk,fk,pk,fO,Mu,JR,pO,mk,mO,gk,tI,Ok,eI,bk,yk,iI,vk,xk,wk,kk,$k,Ck,Ek,sI,nI,gO,Pk,Tk,Iu,bO,Lk,oI,aI,Mk,Rk,qu,Zu,Ik=W(()=>{ai();Ei();fi();We();b1=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.from),i=jg(s.state,e.from);return i.line?y1(s):i.block?x1(s):!1};y1=Js(Wg,0),bR=Js(Wg,1),yR=Js(Wg,2),v1=Js(xu,0),vR=Js(xu,1),xR=Js(xu,2),x1=Js((s,t)=>xu(s,t,wR(t)),0);Vl=50;Fg=ie.define(),S1=ie.define(),w1=N.define(),k1=N.define({combine(s){return se(s,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}}),Su=yt.define({create(){return tn.empty},update(s,t){let e=t.state.facet(k1),i=t.annotation(Fg);if(i){let l=Ue.fromTransaction(t,i.selection),h=i.side,c=h==0?s.undone:s.done;return l?c=Au(c,c.length,e.minDepth,l):c=P1(c,t.startState.selection),new tn(h==0?i.rest:c,h==0?c:i.rest)}let n=t.annotation(S1);if((n=="full"||n=="before")&&(s=s.isolate()),t.annotation(wt.addToHistory)===!1)return t.changes.empty?s:s.addMapping(t.changes.desc);let r=Ue.fromTransaction(t),o=t.annotation(wt.time),a=t.annotation(wt.userEvent);return r?s=s.addChanges(r,o,a,e,t):t.selection&&(s=s.addSelection(t.startState.selection,o,a,e.newGroupDelay)),(n=="full"||n=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(t=>t.toJSON()),undone:s.undone.map(t=>t.toJSON())}},fromJSON(s){return new tn(s.done.map(Ue.fromJSON),s.undone.map(Ue.fromJSON))}});kR=Su;Ug=wu(0,!1),ku=wu(1,!1),A1=wu(0,!0),$1=wu(1,!0);AR=C1(0),$R=C1(1),Ue=class s{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new s(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(t){return new s(t.changes&&Wt.fromJSON(t.changes),[],t.mapped&&oi.fromJSON(t.mapped),t.startSelection&&R.fromJSON(t.startSelection),t.selectionsAfter.map(R.fromJSON))}static fromTransaction(t,e){let i=Ne;for(let n of t.startState.facet(w1)){let r=n(t);r.length&&(i=i.concat(r))}return!i.length&&t.changes.empty?null:new s(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,Ne)}static selection(t){return new s(void 0,Ne,void 0,void 0,t)}};Ne=[],PR=200;LR=/^(input\.type|delete)($|\.)/,tn=class s{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new s(this.done,this.undone):this}addChanges(t,e,i,n,r){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!i||LR.test(i))&&(!a.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,CR(a.changes,t.changes))||i=="input.type.compose")?o=Au(o,o.length-1,n.minDepth,new Ue(t.changes.compose(a.changes),E1(Y.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,Ne)):o=Au(o,o.length,n.minDepth,t),new s(o,Ne,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Ne;return r.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&ER(r[r.length-1],t)?this:new s(P1(this.done,t),this.undone,e,i)}addMapping(t){return new s(Yg(this.done,t),Yg(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=t==0?this.done:this.undone;if(n.length==0)return null;let r=n[n.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):e.selection);if(i&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Fg.of({side:t,rest:QR(n),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let a=n.length==1?Ne:n.slice(0,n.length-1);return r.mapped&&(a=Yg(a,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Fg.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};tn.empty=new tn(Ne,Ne);Xu=[{key:"Mod-z",run:Ug,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ku,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ku,preventDefault:!0},{key:"Mod-u",run:A1,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:$1,preventDefault:!0}];Hg=s=>$u(s,!Ht(s)),Gg=s=>$u(s,Ht(s)),MR=s=>$u(s,!0),RR=s=>$u(s,!1);IR=s=>Q1(s,!0),DR=s=>Q1(s,!1);T1=s=>Cu(s,!Ht(s)),L1=s=>Cu(s,Ht(s)),XR=s=>Cu(s,!0),qR=s=>Cu(s,!1);ZR=s=>xe(s,t=>t.empty?s.moveByChar(t,!0,e=>Jg(s,t.head,e)):en(t,!0)),M1=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;NR=s=>I1(s,!0),zR=s=>I1(s,!1);D1=s=>xe(s,t=>Eu(s.state,t,!Ht(s))),X1=s=>xe(s,t=>Eu(s.state,t,Ht(s)));tO=s=>q1(s,!1),eO=s=>q1(s,!0);iO=s=>N1(s,!1),Pu=s=>N1(s,!0);z1=s=>xe(s,t=>us(s,t,!0)),B1=s=>xe(s,t=>us(s,t,!1)),V1=s=>xe(s,t=>us(s,t,!Ht(s))),_1=s=>xe(s,t=>us(s,t,Ht(s))),j1=s=>xe(s,t=>R.cursor(s.lineBlockAt(t.head).from,1)),W1=s=>xe(s,t=>R.cursor(s.lineBlockAt(t.head).to,-1));U1=({state:s,dispatch:t})=>F1(s,t,!1),VR=({state:s,dispatch:t})=>F1(s,t,!0);sO=s=>Qu(s,!Ht(s)),nO=s=>Qu(s,Ht(s)),_R=s=>Qu(s,!0),jR=s=>Qu(s,!1),WR=s=>Gt(s,!0,t=>Kg(s.state,t,!0)),FR=s=>Gt(s,!1,t=>Kg(s.state,t,!1));Y1=s=>Tu(s,!Ht(s)),H1=s=>Tu(s,Ht(s)),UR=s=>Tu(s,!0),YR=s=>Tu(s,!1),HR=s=>Gt(s,!0,t=>s.moveByChar(t,!0,e=>Jg(s,t.head,e)));GR=s=>G1(s,!0),KR=s=>G1(s,!1),K1=s=>{let t=!Ht(s);return Gt(s,t,e=>Eu(s.state,e,t))},J1=s=>{let t=Ht(s);return Gt(s,t,e=>Eu(s.state,e,t))};rO=s=>tk(s,!1),oO=s=>tk(s,!0);aO=s=>ek(s,!1),lO=s=>ek(s,!0),ik=s=>Gt(s,!0,t=>us(s,t,!0)),sk=s=>Gt(s,!1,t=>us(s,t,!1)),nk=s=>{let t=!Ht(s);return Gt(s,t,e=>us(s,e,t))},rk=s=>{let t=Ht(s);return Gt(s,t,e=>us(s,e,t))},ok=s=>Gt(s,!1,t=>R.cursor(s.lineBlockAt(t.head).from)),ak=s=>Gt(s,!0,t=>R.cursor(s.lineBlockAt(t.head).to)),hO=({state:s,dispatch:t})=>(t(Ye(s,{anchor:0})),!0),cO=({state:s,dispatch:t})=>(t(Ye(s,{anchor:s.doc.length})),!0),uO=({state:s,dispatch:t})=>(t(Ye(s,{anchor:s.selection.main.anchor,head:0})),!0),dO=({state:s,dispatch:t})=>(t(Ye(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),lk=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),hk=({state:s,dispatch:t})=>{let e=Ru(s).map(({from:i,to:n})=>R.range(i,Math.min(n+1,s.doc.length)));return t(s.update({selection:R.create(e),userEvent:"select"})),!0},ck=({state:s,dispatch:t})=>{let e=ko(s.selection,i=>{let n=et(s),r=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:a}=o;if((a.from<i.from&&a.to>=i.to||a.to>i.to&&a.from<=i.from)&&o.next)return R.range(a.to,a.from)}return i});return e.eq(s.selection)?!1:(t(Ye(s,e)),!0)};dk=s=>uk(s,!1),fk=s=>uk(s,!0),pk=({state:s,dispatch:t})=>{let e=s.selection,i=null;return e.ranges.length>1?i=R.create([e.main]):e.main.empty||(i=R.create([R.cursor(e.main.head)])),i?(t(Ye(s,i)),!0):!1};fO=(s,t,e)=>sn(s,i=>{let n=i.from,{state:r}=s,o=r.doc.lineAt(n),a,l;if(e&&!t&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,n-o.from))){if(a[a.length-1]==" ")return n-1;let h=Ut(a,r.tabSize),c=h%Li(r)||Li(r);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)n--;l=n}else l=Ct(o.text,n-o.from,t,t)+o.from,l==n&&o.number!=(t?r.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,n-o.from))&&(l=Ct(o.text,l-o.from,!1,!1)+o.from);return l}),Mu=s=>fO(s,!1,!0),JR=s=>fO(s,!1,!1),pO=s=>fO(s,!0,!1),mk=(s,t)=>sn(s,e=>{let i=e.head,{state:n}=s,r=n.doc.lineAt(i),o=n.charCategorizer(i);for(let a=null;;){if(i==(t?r.to:r.from)){i==e.head&&r.number!=(t?n.doc.lines:1)&&(i+=t?1:-1);break}let l=Ct(r.text,i-r.from,t)+r.from,h=r.text.slice(Math.min(i,l)-r.from,Math.max(i,l)-r.from),c=o(h);if(a!=null&&c!=a)break;(h!=" "||i!=e.head)&&(a=c),i=l}return i}),mO=s=>mk(s,!1),gk=s=>mk(s,!0),tI=s=>sn(s,t=>s.moveByChar(t,!0,e=>Jg(s,t.head,e)).head),Ok=s=>sn(s,t=>{let e=s.lineBlockAt(t.head).to;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),eI=s=>sn(s,t=>{let e=s.lineBlockAt(t.head).from;return t.head>e?e:Math.max(0,t.head-1)}),bk=s=>sn(s,t=>{let e=s.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),yk=s=>sn(s,t=>{let e=s.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),iI=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=[];for(let i=0,n="",r=s.doc.iter();;){if(r.next(),r.lineBreak||r.done){let o=n.search(/\s+$/);if(o>-1&&e.push({from:i-(n.length-o),to:i}),r.done)break;n=""}else n=r.value;i+=r.value.length}return e.length?(t(s.update({changes:e,userEvent:"delete"})),!0):!1},vk=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:it.of(["",""])},range:R.cursor(i.from)}));return t(s.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},xk=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let n=i.from,r=s.doc.lineAt(n),o=n==r.from?n-1:Ct(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:Ct(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:a,insert:s.doc.slice(n,a).append(s.doc.slice(o,n))},range:R.cursor(a)}});return e.changes.empty?!1:(t(s.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};wk=({state:s,dispatch:t})=>Sk(s,t,!1),kk=({state:s,dispatch:t})=>Sk(s,t,!0);$k=({state:s,dispatch:t})=>Ak(s,t,!1),Ck=({state:s,dispatch:t})=>Ak(s,t,!0),Ek=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(Ru(t).map(({from:n,to:r})=>(n>0?n--:r<t.doc.length&&r++,{from:n,to:r}))),i=ko(t.selection,n=>{let r;if(s.lineWrapping){let o=s.lineBlockAt(n.head),a=s.coordsAtPos(n.head,n.assoc||1);a&&(r=o.bottom+s.documentTop-a.bottom+s.defaultLineHeight/2)}return s.moveVertically(n,!0,r)}).map(e);return s.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0},sI=({state:s,dispatch:t})=>(t(s.update(s.replaceSelection(s.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),nI=({state:s,dispatch:t})=>(t(s.update(s.changeByRange(e=>{let i=/^\s*/.exec(s.doc.lineAt(e.from).text)[0];return{changes:{from:e.from,to:e.to,insert:s.lineBreak+i},range:R.cursor(e.from+i.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);gO=Qk(!1),Pk=Qk(!0);Tk=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=Object.create(null),i=new Ti(s,{overrideIndentation:r=>{let o=e[r];return o??-1}}),n=OO(s,(r,o,a)=>{let l=fo(i,r.from);if(l==null)return;/\S/.test(r.text)||(l=0);let h=/^\s*/.exec(r.text)[0],c=ls(s,l);(h!=c||a.from<r.from+h.length)&&(e[r.from]=l,o.push({from:r.from,to:r.from+h.length,insert:c}))});return n.changes.empty||t(s.update(n,{userEvent:"indent"})),!0},Iu=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(OO(s,(e,i)=>{i.push({from:e.from,insert:s.facet(Ri)})}),{userEvent:"input.indent"})),!0),bO=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(OO(s,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=Ut(n,s.tabSize),o=0,a=ls(s,Math.max(0,r-Li(s)));for(;o<n.length&&o<a.length&&n.charCodeAt(o)==a.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+n.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),Lk=s=>(s.setTabFocusMode(),!0),oI=s=>(s.setTabFocusMode(2e3),!0),aI=({state:s,dispatch:t})=>s.selection.ranges.some(e=>!e.empty)?Iu({state:s,dispatch:t}):(t(s.update(s.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),Mk=[{key:"Ctrl-b",run:Hg,shift:sO,preventDefault:!0},{key:"Ctrl-f",run:Gg,shift:nO},{key:"Ctrl-p",run:tO,shift:rO},{key:"Ctrl-n",run:eO,shift:oO},{key:"Ctrl-a",run:j1,shift:ok},{key:"Ctrl-e",run:W1,shift:ak},{key:"Ctrl-d",run:pO},{key:"Ctrl-h",run:Mu},{key:"Ctrl-k",run:Ok},{key:"Ctrl-Alt-h",run:mO},{key:"Ctrl-o",run:vk},{key:"Ctrl-t",run:xk},{key:"Ctrl-v",run:Pu}],Rk=[{key:"ArrowLeft",run:Hg,shift:sO,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:T1,shift:Y1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:V1,shift:nk,preventDefault:!0},{key:"ArrowRight",run:Gg,shift:nO,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:L1,shift:H1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:_1,shift:rk,preventDefault:!0},{key:"ArrowUp",run:tO,shift:rO,preventDefault:!0},{mac:"Cmd-ArrowUp",run:hO,shift:uO},{mac:"Ctrl-ArrowUp",run:iO,shift:aO},{key:"ArrowDown",run:eO,shift:oO,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cO,shift:dO},{mac:"Ctrl-ArrowDown",run:Pu,shift:lO},{key:"PageUp",run:iO,shift:aO},{key:"PageDown",run:Pu,shift:lO},{key:"Home",run:B1,shift:sk,preventDefault:!0},{key:"Mod-Home",run:hO,shift:uO},{key:"End",run:z1,shift:ik,preventDefault:!0},{key:"Mod-End",run:cO,shift:dO},{key:"Enter",run:gO,shift:gO},{key:"Mod-a",run:lk},{key:"Backspace",run:Mu,shift:Mu,preventDefault:!0},{key:"Delete",run:pO,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:mO,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:gk,preventDefault:!0},{mac:"Mod-Backspace",run:bk,preventDefault:!0},{mac:"Mod-Delete",run:yk,preventDefault:!0}].concat(Mk.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),qu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:D1,shift:K1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:X1,shift:J1},{key:"Alt-ArrowUp",run:wk},{key:"Shift-Alt-ArrowUp",run:$k},{key:"Alt-ArrowDown",run:kk},{key:"Shift-Alt-ArrowDown",run:Ck},{key:"Mod-Alt-ArrowUp",run:dk},{key:"Mod-Alt-ArrowDown",run:fk},{key:"Escape",run:pk},{key:"Mod-Enter",run:Pk},{key:"Alt-l",mac:"Ctrl-l",run:hk},{key:"Mod-i",run:ck,preventDefault:!0},{key:"Mod-[",run:bO},{key:"Mod-]",run:Iu},{key:"Mod-Alt-\\",run:Tk},{key:"Shift-Mod-k",run:Ek},{key:"Shift-Mod-\\",run:U1},{key:"Mod-/",run:b1},{key:"Alt-A",run:v1},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Lk}].concat(Rk),Zu={key:"Tab",run:Iu,shift:bO}});function ds(s,t=null,e=0){let i=null;return s.between(e,1e9,(n,r,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(!i)i=new Nu(n,r,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Nu(i.from,r,i.diagnostic)}}),i}function Dk(s,t){let e=t.pos,i=t.end||e,n=s.state.facet(pi).hideOn(s,e,i);if(n!=null)return n;let r=s.startState.doc.lineAt(t.pos);return!!(s.effects.some(o=>o.is(_l))||s.changes.touchesRange(r.from,Math.max(r.to,i)))}function Xk(s,t){return s.field(Kt,!1)?t:t.concat(Y.appendConfig.of(Yk))}function qk(s,t){return{effects:Xk(s,[_l.of(t)])}}function lI(s){let t=s.field(Kt,!1);return t?t.diagnostics.size:0}function cI(s,t,e){let{diagnostics:i}=s.state.field(Kt),n,r=-1,o=-1;i.between(t-(e<0?1:0),t+(e>0?1:0),(l,h,{spec:c})=>{if(t>=l&&t<=h&&(l==h||(t>l||e>0)&&(t<h||e<0)))return n=c.diagnostics,r=l,o=h,!1});let a=s.state.facet(pi).tooltipFilter;return n&&a&&(n=a(n,s.state)),n?{pos:r,end:o,above:!0,create(){return{dom:Nk(s,n)}}}:null}function Nk(s,t){return Pt("ul",{class:"cm-tooltip-lint"},t.map(e=>Wk(s,e,!1)))}function fI(s,t,e){let i=[],n=-1;for(let r of s)r.then(o=>{i.push(o),clearTimeout(n),i.length==s.length?t(i):n=setTimeout(()=>t(i),200)},e)}function _k(s,t){return s?t?(e,i)=>t(s(e,i),i):s:t}function Wl(s,t={}){return[pi.of({source:s,config:t}),Vk,Yk]}function pI(s){let t=s.plugin(Vk);t&&t.force()}function jk(s){let t=[];if(s)t:for(let{name:e}of s){for(let i=0;i<e.length;i++){let n=e[i];if(/[a-zA-Z]/.test(n)&&!t.some(r=>r.toLowerCase()==n.toLowerCase())){t.push(n);continue t}}t.push("")}return t}function Wk(s,t,e){var i;let n=e?jk(t.actions):[];return Pt("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Pt("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(s):t.message),(i=t.actions)===null||i===void 0?void 0:i.map((r,o)=>{let a=!1,l=f=>{if(f.preventDefault(),a)return;a=!0;let p=ds(s.state.field(Kt).diagnostics,t);p&&r.apply(s,p.from,p.to)},{name:h}=r,c=n[o]?h.indexOf(n[o]):-1,u=c<0?h:[h.slice(0,c),Pt("u",h.slice(c,c+1)),h.slice(c+1)],d=r.markClass?" "+r.markClass:"";return Pt("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[o]})"`}.`},u)}),t.source&&Pt("div",{class:"cm-diagnosticSource"},t.source))}function Bu(s,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(s)}</svg>')`}function Vu(s){return Bu(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${s}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}function gI(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function Fk(s){let t="hint",e=1;for(let i of s){let n=gI(i.severity);n>e&&(e=n,t=i.severity)}return t}function OI(s,t){let e=i=>{let n=t.getBoundingClientRect();if(!(i.clientX>n.left-10&&i.clientX<n.right+10&&i.clientY>n.top-10&&i.clientY<n.bottom+10)){for(let r=i.target;r;r=r.parentNode)if(r.nodeType==1&&r.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",e),s.state.field(Uk)&&s.dispatch({effects:wO.of(null)})}};window.addEventListener("mousemove",e)}function bI(s,t,e){function i(){let o=s.elementAtHeight(t.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:wO.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Nk(s,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,OI(s,t)}let{hoverTime:n}=s.state.facet(ju),r=setTimeout(i,n);t.onmouseout=()=>{clearTimeout(r),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,n)}}function yI(s,t){let e=Object.create(null);for(let n of t){let r=s.lineAt(n.from);(e[r.from]||(e[r.from]=[])).push(n)}let i=[];for(let n in e)i.push(new _u(e[n]).range(+n));return tt.of(i,!0)}function Wu(s={}){return[ju.of(s),SO,vI,xI,Uk]}function SI(s,t){let e=s.field(Kt,!1);if(e&&e.diagnostics.size){let i=[],n=[],r=-1;for(let o=tt.iter([e.diagnostics]);;o.next()){for(let a=0;a<i.length;a++)(!o.value||o.value.spec.diagnostics.indexOf(i[a])<0)&&(t(i[a],n[a],r),i.splice(a,1),n.splice(a--,1));if(!o.value)break;for(let a of o.value.spec.diagnostics)i.indexOf(a)<0&&(i.push(a),n.push(o.from));r=o.to}}}var Nu,nn,_l,yO,Zk,Kt,hI,zk,vO,Bk,uI,dI,Vk,pi,xO,zu,jl,mI,_u,vI,SO,wO,Uk,xI,kO,Yk,ju,Hk=W(()=>{Ei();ai();Qf();Nu=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},nn=class s{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=i.facet(pi).markerFilter;n&&(t=n(t,i));let r=t.slice().sort((f,p)=>f.from-p.from||f.to-p.to),o=new Ee,a=[],l=0,h=i.doc.iter(),c=0,u=i.doc.length;for(let f=0;;){let p=f==r.length?null:r[f];if(!p&&!a.length)break;let m,g;if(a.length)m=l,g=a.reduce((x,S)=>Math.min(x,S.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;g=p.to,a.push(p),f++}for(;f<r.length;){let x=r[f];if(x.from==m&&(x.to>x.from||x.to==m))a.push(x),f++,g=Math.min(x.to,g);else{g=Math.min(x.from,g);break}}g=Math.min(g,u);let O=!1;if(a.some(x=>x.from==m&&(x.to==g||g==u))&&(O=m==g,!O&&g-m<10)){let x=m-(c+h.value.length);x>0&&(h.next(x),c=m);for(let S=m;;){if(S>=g){O=!0;break}if(!h.lineBreak&&c+h.value.length>S)break;S=c+h.value.length,c+=h.value.length,h.next()}}let w=Fk(a);if(O)o.add(m,m,U.widget({widget:new xO(w),diagnostics:a.slice()}));else{let x=a.reduce((S,v)=>v.markClass?S+" "+v.markClass:S,"");o.add(m,g,U.mark({class:"cm-lintRange cm-lintRange-"+w+x,diagnostics:a.slice(),inclusiveEnd:a.some(S=>S.to>g)}))}if(l=g,l==u)break;for(let x=0;x<a.length;x++)a[x].to<=l&&a.splice(x--,1)}let d=o.finish();return new s(d,e,ds(d))}};_l=Y.define(),yO=Y.define(),Zk=Y.define(),Kt=yt.define({create(){return new nn(U.none,null,null)},update(s,t){if(t.docChanged&&s.diagnostics.size){let e=s.diagnostics.map(t.changes),i=null,n=s.panel;if(s.selected){let r=t.changes.mapPos(s.selected.from,1);i=ds(e,s.selected.diagnostic,r)||ds(e,null,r)}!e.size&&n&&t.state.facet(pi).autoPanel&&(n=null),s=new nn(e,n,i)}for(let e of t.effects)if(e.is(_l)){let i=t.state.facet(pi).autoPanel?e.value.length?jl.open:null:s.panel;s=nn.init(e.value,i,t.state)}else e.is(yO)?s=new nn(s.diagnostics,e.value?jl.open:null,s.selected):e.is(Zk)&&(s=new nn(s.diagnostics,s.panel,e.value));return s},provide:s=>[lo.from(s,t=>t.panel),Z.decorations.from(s,t=>t.diagnostics)]});hI=U.mark({class:"cm-lintRange cm-lintRange-active"});zk=s=>{let t=s.state.field(Kt,!1);(!t||!t.panel)&&s.dispatch({effects:Xk(s.state,[yO.of(!0)])});let e=Pc(s,jl.open);return e&&e.dom.querySelector(".cm-panel-lint ul").focus(),!0},vO=s=>{let t=s.state.field(Kt,!1);return!t||!t.panel?!1:(s.dispatch({effects:yO.of(!1)}),!0)},Bk=s=>{let t=s.state.field(Kt,!1);if(!t)return!1;let e=s.state.selection.main,i=ds(t.diagnostics,null,e.to+1);return!i&&(i=ds(t.diagnostics,null,0),!i||i.from==e.from&&i.to==e.to)?!1:(s.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),Mc(s,i.from,1,{tooltip:kO,until:n=>n.docChanged||n.newSelection.main.head<i.from||n.newSelection.main.head>i.to}),!0)},uI=s=>{var t;let{state:e}=s,i=e.field(Kt,!1);if(!i)return!1;let n=e.selection.main,r,o,a,l;if(i.diagnostics.between(0,e.doc.length,(u,d)=>{d<n.to&&(r==null||r<u)&&(r=u,o=d),(a==null||u>a)&&(a=u,l=d)}),a==null||r==null&&a==n.from)return!1;let h=r??a,c=(t=o??l)!==null&&t!==void 0?t:h;return s.dispatch({selection:{anchor:h,head:c},scrollIntoView:!0}),Mc(s,h,1,{tooltip:kO,until:u=>u.docChanged||u.newSelection.main.head<h||u.newSelection.main.head>c}),!0},dI=[{key:"Mod-Shift-m",run:zk,preventDefault:!0},{key:"F8",run:Bk}],Vk=ft.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:t}=s.state.facet(pi);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let s=Date.now();if(s<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-s);else{this.set=!1;let{state:t}=this.view,{sources:e}=t.facet(pi);e.length&&fI(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(qk(this.view.state,i.reduce((n,r)=>n.concat(r))))},i=>{Qt(this.view.state,i)})}}update(s){let t=s.state.facet(pi);(s.docChanged||t!=s.startState.facet(pi)||t.needsRefresh&&t.needsRefresh(s))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});pi=N.define({combine(s){return{sources:s.map(t=>t.source).filter(t=>t!=null),...se(s.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:_k,tooltipFilter:_k,needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e,hideOn:(t,e)=>t?e?(i,n,r)=>t(i,n,r)||e(i,n,r):t:e,autoPanel:(t,e)=>t||e})}}});xO=class extends Nt{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Pt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},zu=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Wk(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},jl=class s{constructor(t){this.view=t,this.items=[];let e=n=>{if(!(n.ctrlKey||n.altKey||n.metaKey)){if(n.keyCode==27)vO(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=jk(r.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==n.keyCode){let l=ds(this.view.state.field(Kt).diagnostics,r);l&&r.actions[a].apply(t,l.from,l.to)}}else return;n.preventDefault()}},i=n=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(n.target)&&this.moveSelection(r)};this.list=Pt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=Pt("div",{class:"cm-panel-lint"},this.list,Pt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>vO(this.view)},"\xD7")),this.update()}get selectedIndex(){let t=this.view.state.field(Kt).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(Kt),i=0,n=!1,r=null,o=new Set;for(t.between(0,this.view.state.doc.length,(a,l,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let u=-1,d;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==c){u=f;break}u<0?(d=new zu(this.view,c),this.items.splice(i,0,d),n=!0):(d=this.items[u],u>i&&(this.items.splice(i,u-i),n=!0)),e&&d.diagnostic==e.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),r=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new zu(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let h=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/h:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let t=this.list.firstChild;function e(){let i=t;t=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=this.view.state.field(Kt),i=ds(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Zk.of(i)})}static open(t){return new s(t)}};mI=Z.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Vu("#f11")},".cm-lintRange-warning":{backgroundImage:Vu("orange")},".cm-lintRange-info":{backgroundImage:Vu("#999")},".cm-lintRange-hint":{backgroundImage:Vu("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});_u=class extends oe{constructor(t){super(),this.diagnostics=t,this.severity=Fk(t)}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=t.state.facet(ju).tooltipFilter;return n&&(i=n(i,t.state)),i.length&&(e.onmouseover=()=>bI(t,e,i)),e}};vI=bl({class:"cm-gutter-lint",markers:s=>s.state.field(SO),widgetMarker:(s,t,e)=>{let i=[];return s.state.field(SO).between(e.from,e.to,(n,r,o)=>{n>e.from&&n<e.to&&i.push(...o.diagnostics)}),i.length?new _u(i):null}}),SO=yt.define({create(){return tt.empty},update(s,t){s=s.map(t.changes);let e=t.state.facet(ju).markerFilter;for(let i of t.effects)if(i.is(_l)){let n=i.value;e&&(n=e(n||[],t.state)),s=yI(t.state.doc,n.slice(0))}return s}}),wO=Y.define(),Uk=yt.define({create(){return null},update(s,t){return s&&t.docChanged&&(s=Dk(t,s)?null:{...s,pos:t.changes.mapPos(s.pos)}),t.effects.reduce((e,i)=>i.is(wO)?i.value:e,s)},provide:s=>zs.from(s)}),xI=Z.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Bu('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Bu('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Bu('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),kO=_p(cI,{hideOn:Dk}),Yk=[Kt,Z.decorations.compute([Kt],s=>{let{selected:t,panel:e}=s.field(Kt);return!t||!e||t.from==t.to?U.none:U.set([hI.range(t.from,t.to)])}),kO,mI],ju=N.define({combine(s){return se(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}})});var $O={};Jt($O,{Compartment:()=>es,EditorSelection:()=>R,EditorState:()=>ht,EditorView:()=>Z,HighlightStyle:()=>Mi,LOAD_TIMEOUT_MS:()=>AO,LanguageSupport:()=>kt,StateEffect:()=>Y,adiaBaseTheme:()=>wI,adiaHighlightStyle:()=>kI,defaultHighlightStyle:()=>jc,defaultKeymap:()=>qu,drawSelection:()=>Qc,highlightActiveLine:()=>Tc,highlightActiveLineGutter:()=>Dc,history:()=>Du,historyKeymap:()=>Xu,importWithTimeout:()=>$I,indentWithTab:()=>Zu,jsonLinter:()=>CI,keymap:()=>ci,languages:()=>AI,lineNumbers:()=>Ic,lintGutter:()=>Wu,linter:()=>Wl,placeholder:()=>Lc,syntaxHighlighting:()=>_c});function $I(s,t){return Promise.race([s(),new Promise((e,i)=>setTimeout(()=>i(new Error(`code-editor: ${t} load timed out after ${AO}ms`)),AO))])}function EI(s,t){let e=t.length,i=s.match(/at position (\d+)/);if(i){let o=Math.min(e,Number(i[1]));return{from:o,to:Math.min(e,o+1)}}let n=s.match(/line (\d+) column (\d+)/);if(n){let o=Number(n[1]),a=Number(n[2]),l=0,h=1;for(let u=0;u<t.length&&h<o;u++)t[u]===`
41
- `&&(h++,l=u+1);let c=Math.min(e,l+Math.max(0,a-1));return{from:c,to:Math.min(e,c+1)}}let r=Math.max(0,e);return{from:Math.max(0,r-1),to:r}}var wI,kI,AI,AO,CI,CO=W(()=>{"use strict";ai();Ei();Ik();fi();Hk();ri();wI=Z.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{caretColor:"inherit"},".cm-focused":{outline:"none"}}),kI=Mi.define([{tag:[y.comment,y.lineComment,y.blockComment,y.docComment],class:"tok-comment"},{tag:[y.keyword,y.controlKeyword,y.modifier,y.operatorKeyword],class:"tok-keyword"},{tag:[y.string,y.character,y.regexp,y.escape,y.special(y.string)],class:"tok-string"},{tag:[y.number,y.integer,y.float],class:"tok-number"},{tag:[y.bool,y.null,y.atom],class:"tok-boolean"},{tag:[y.operator,y.logicOperator,y.arithmeticOperator,y.compareOperator,y.updateOperator,y.definitionOperator],class:"tok-operator"},{tag:[y.punctuation,y.bracket,y.paren,y.brace,y.squareBracket,y.angleBracket,y.separator],class:"tok-punctuation"},{tag:[y.function(y.variableName),y.function(y.propertyName),y.macroName],class:"tok-function"},{tag:[y.variableName,y.local(y.variableName),y.self],class:"tok-variable"},{tag:[y.typeName,y.className,y.namespace],class:"tok-type"},{tag:[y.propertyName,y.labelName,y.definition(y.variableName)],class:"tok-property"},{tag:[y.tagName,y.heading,y.contentSeparator],class:"tok-tag"},{tag:[y.attributeName,y.attributeValue],class:"tok-attribute"},{tag:[y.url,y.link],class:"tok-url"},{tag:[y.invalid,y.deleted],class:"tok-invalid"}]),AI={json:()=>Promise.resolve().then(()=>(Tx(),Qx)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(og(),hw)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(Jm(),GS)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(km(),aS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(i1(),e1)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(O1(),g1)).then(s=>({extension:s.yaml()}))},AO=1e4;CI=Wl(s=>{let t=s.state.doc.toString();if(t.trim()==="")return[];try{return JSON.parse(t),[]}catch(e){let i=e instanceof Error?e.message:String(e),{from:n,to:r}=EI(i,t);return[{from:n,to:r,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function Hu(s){return zt.get(s)||null}function pA(s,t){zt.set(s,t)}var zt,qO=W(()=>{"use strict";zt=new Map([["Row","row-ui"],["Column","col-ui"],["List","list-ui"],["ListItem","list-item-ui"],["Grid","grid-ui"],["Stack","stack-ui"],["Block","block-ui"],["Text","text-ui"],["Image","image-ui"],["Icon","icon-ui"],["Divider","divider-ui"],["Badge","badge-ui"],["Avatar","avatar-ui"],["AvatarGroup","avatar-group-ui"],["Progress","progress-ui"],["DateRangePicker","date-range-picker-ui"],["CalendarGrid","calendar-grid-ui"],["CalendarPicker","calendar-picker-ui"],["Combobox","combobox-ui"],["Skeleton","skeleton-ui"],["Stepper","stepper-ui"],["StepperItem","stepper-item-ui"],["Tour","tour-ui"],["TourStep","tour-step-ui"],["IntegrationCard","integration-card-ui"],["Code","code-ui"],["Stat","stat-ui"],["EmptyState","empty-state-ui"],["Input","input-ui"],["TextField","input-ui"],["TextArea","textarea-ui"],["Field","field-ui"],["CheckBox","check-ui"],["Toggle","switch-ui"],["Switch","switch-ui"],["Slider","slider-ui"],["Range","range-ui"],["Rating","rating-ui"],["ChoicePicker","select-ui"],["Select","select-ui"],["Radio","radio-ui"],["RadioGroup","radio-group-ui"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorArea","color-area-ui"],["Upload","upload-ui"],["OtpInput","otp-input-ui"],["Button","button-ui"],["LoadingIndicator","progress-ui"],["ErrorContainer","card-ui"],["Card","card-ui"],["Tabs","tabs-ui"],["Tab","tab-ui"],["Panel","pane-ui"],["Pane","pane-ui"],["Modal","modal-ui"],["Dialog","modal-ui"],["Drawer","drawer-ui"],["Toast","toast-ui"],["AnchorBar","anchor-bar-ui"],["Popover","popover-ui"],["Accordion","accordion-ui"],["AccordionItem","accordion-item-ui"],["Alert","alert-ui"],["Tooltip","tooltip-ui"],["Menu","menu-ui"],["Section","section"],["Header","header"],["Footer","footer"],["Stream","stream-ui"],["Table","table-ui"],["ColDef","col-def"],["Chart","chart-ui"],["Embed","embed-ui"],["Swiper","swiper-ui"],["Slideshow","swiper-ui"],["Carousel","swiper-ui"],["Breadcrumb","breadcrumb-ui"],["Drilldown","drilldown-ui"],["Link","link-ui"],["Anchor","link-ui"],["Hyperlink","link-ui"],["NavLink","link-ui"],["Nav","nav-ui"],["NavGroup","nav-group-ui"],["NavItem","nav-item-ui"],["Noodles","noodles-ui"],["Pagination","pagination-ui"],["SegmentedControl","segmented-ui"],["Segment","segment-ui"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-ui"],["ToolbarGroup","toolbar-group-ui"],["Tag","tag-ui"],["Timeline","timeline-ui"],["TimelineItem","timeline-item-ui"],["button-ui","button-ui"],["card-ui","card-ui"],["text-ui","text-ui"],["input-ui","input-ui"],["text-field-ui","input-ui"],["select-ui","select-ui"],["toggle-ui","switch-ui"],["check-ui","check-ui"],["slider-ui","slider-ui"],["badge-ui","badge-ui"],["avatar-ui","avatar-ui"],["icon-ui","icon-ui"],["image-ui","image-ui"],["divider-ui","divider-ui"],["progress-ui","progress-ui"],["skeleton-ui","skeleton-ui"],["tabs-ui","tabs-ui"],["tab-ui","tab-ui"],["modal-ui","modal-ui"],["dialog-ui","modal-ui"],["drawer-ui","drawer-ui"],["toast-ui","toast-ui"],["popover-ui","popover-ui"],["panel-ui","pane-ui"],["accordion-ui","accordion-ui"],["alert-ui","alert-ui"],["tooltip-ui","tooltip-ui"],["menu-ui","menu-ui"],["table-ui","table-ui"],["chart-ui","chart-ui"],["code-ui","code-ui"],["textarea-ui","textarea-ui"],["radio-ui","radio-ui"],["tag-ui","tag-ui"],["search-ui","search-ui"],["upload-ui","upload-ui"],["breadcrumb-ui","breadcrumb-ui"],["link-ui","link-ui"],["nav-ui","nav-ui"],["noodles-ui","noodles-ui"],["pagination-ui","pagination-ui"],["segmented-control-ui","segmented-ui"],["segment-ui","segment-ui"],["command-ui","command-ui"],["calendar-picker-ui","calendar-picker-ui"],["color-area-ui","color-area-ui"],["kbd-ui","kbd-ui"],["toolbar-ui","toolbar-ui"],["otp-input-ui","otp-input-ui"],["embed-ui","embed-ui"],["stream-ui","stream-ui"],["row-ui","row-ui"],["col-ui","col-ui"],["grid-ui","grid-ui"],["stack-ui","stack-ui"],["block-ui","block-ui"],["list-ui","list-ui"],["range-ui","range-ui"],["datetime-ui","calendar-picker-ui"],["timeline-ui","timeline-ui"],["timeline-item-ui","timeline-item-ui"],["avatar-group-ui","avatar-group-ui"],["Keyboard","kbd-ui"],["DatePicker","calendar-picker-ui"],["CommandPalette","command-ui"],["FormContainer","form"],["Sidebar","admin-sidebar"],["Segmented","segmented-ui"],["OTP","otp-input-ui"],["Textarea","textarea-ui"],["RichText","richtext-ui"],["Richtext","richtext-ui"],["DescriptionList","description-list-ui"],["ActionItem","action-item-ui"],["ActionList","action-list-ui"],["Inspector","inspector-ui"],["Heatmap","heatmap-ui"],["ChatThread","chat-thread"],["UIChatThread","chat-thread-ui"],["ChatInput","chat-input-ui"],["OptionCard","option-card-ui"],["Option","option-card-ui"],["AdminCommand","admin-command"],["AdminContent","admin-content"],["AdminPage","admin-page"],["AdminPageBody","admin-page-body"],["AdminPageHeader","admin-page-header"],["AdminScroll","admin-scroll"],["AdminShell","admin-shell"],["AdminSidebar","admin-sidebar"],["AdminStatusbar","admin-statusbar"],["AdminTopbar","admin-topbar"],["ChatComposer","chat-composer"],["ChatEmpty","chat-empty"],["ChatHeader","chat-header"],["ChatShell","chat-shell"],["ChatSidebar","chat-sidebar"],["ChatStatus","chat-status"],["EditorCanvas","editor-canvas"],["EditorCanvasEmpty","editor-canvas-empty"],["EditorShell","editor-shell"],["EditorSidebar","editor-sidebar"],["EditorStatusbar","editor-statusbar"],["EditorToolbar","editor-toolbar"],["GenRoot","gen-root"],["SimpleContent","simple-content"],["SimpleHero","simple-hero"],["SimpleShell","simple-shell"],["ThemePanel","theme-panel"],["AdiaMark","adia-mark-ui"],["AdiaWordmark","adia-wordmark-ui"],["AgentArtifact","agent-artifact-ui"],["AgentFeedbackBar","agent-feedback-bar-ui"],["AgentQuestions","agent-questions-ui"],["AgentReasoning","agent-reasoning-ui"],["AgentSuggestions","agent-suggestions-ui"],["AgentTrace","agent-trace-ui"],["Aside","aside-ui"],["Blockquote","blockquote-ui"],["Canvas","canvas-ui"],["ChartLegend","chart-legend-ui"],["ColorInput","color-input-ui"],["ContextMenu","context-menu-ui"],["DemoToggle","demo-toggle-ui"],["DisplayField","display-field-ui"],["Feed","feed-ui"],["FeedItem","feed-item-ui"],["Fields","fields-ui"],["Frame","frame-ui"],["InlineEdit","inline-edit-ui"],["InlineMessage","inline-message-ui"],["ListWindow","list-window-ui"],["LoadingOverlay","loading-overlay-ui"],["Mark","mark-ui"],["MenuDivider","menu-divider-ui"],["MenuItem","menu-item-ui"],["MenuLabel","menu-label-ui"],["NumberFormat","number-format-ui"],["Page","page-ui"],["PasswordStrength","password-strength-ui"],["PipelineStatus","pipeline-status-ui"],["Preview","preview-ui"],["QRCode","qr-code-ui"],["RelativeTime","relative-time-ui"],["Search","search-ui"],["SkipNav","skip-nav-ui"],["Spinner","spinner-ui"],["StepProgress","step-progress-ui"],["Swatch","swatch-ui"],["TableFooter","table-footer-ui"],["TableOfContents","toc-ui"],["TableToolbar","table-toolbar-ui"],["TagsInput","tags-input-ui"],["ThemeProvider","theme-provider"],["TimePicker","time-picker-ui"],["ToggleScheme","toggle-scheme-ui"],["Tree","tree-ui"],["TreeItem","tree-item-ui"],["VisuallyHidden","visually-hidden-ui"],["AdminEntityItem","admin-entity-item"],["AdminRoster","admin-roster-ui"],["AdminSettings","admin-settings-ui"],["AgentAdmin","agent-admin-ui"],["AppShell","embed-shell"],["BillingOverview","billing-overview-ui"],["ConfirmDialog","confirm-dialog-ui"],["DashboardLayout","dashboard-layout-ui"],["DateRangeSelector","date-range-selector-ui"],["FormPopover","form-popover-ui"],["IntegrationsPage","integrations-page-ui"],["InvoiceDetail","invoice-detail-ui"],["InvoiceHistory","invoice-history-ui"],["NotificationPreferences","notification-preferences-ui"],["OnboardingChecklist","onboarding-checklist-ui"],["PaymentMethodForm","payment-method-form-ui"],["PaymentMethodList","payment-method-list-ui"],["PlanPicker","plan-picker-ui"],["chat-thread-ui","chat-thread-ui"],["section-ui","section-ui"],["DescriptionTerm","dt"],["DescriptionDetail","dd"]])});function Gu(s){return!s||s==="/"}function ZO(s){return s.split("/").filter(Boolean)}function mA(s){return s.replace(/^\//,"").split("/")}function gA(s,t){return Gu(t)?s:ZO(t).reduce((e,i)=>e?.[i],s)}function OA(s,t,e){if(Gu(t))return;let i=ZO(t),n=s;for(let r=0;r<i.length-1;r++)n[i[r]]==null&&(n[i[r]]={}),n=n[i[r]];n[i[i.length-1]]=e}function NO(s,t){if(Gu(t))return s;let e=mA(t),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function bA(s,t,e){if(Gu(t))return;let i=mA(t),n=s;for(let r=0;r<i.length-1;r++){let o=i[r];n[o]==null&&(n[o]={}),n=n[o]}n[i[i.length-1]]=e}function yA(s,t){if(!t||!s)return;let e=ZO(t),i=s;for(let n of e){if(i==null||typeof i!="object")return;i=i[n]}return i}var Ku=W(()=>{"use strict"});var Ju,da,zO=W(()=>{"use strict";Ku();Ju={provider:0,controller:1,source:2,action:3,lifecycle:4},da=class{surfaceId;#t=new Map;#e={};#i={};#s=new Map;#n;#r;constructor(t,e,i){this.surfaceId=t,this.#n=e,this.#r=i}get context(){return{surfaceId:this.surfaceId,getElement:t=>this.#r.get(t)||null,getRootElement:()=>this.#n,getModel:t=>t?NO(this.#e,t):this.#e,setModel:(t,e)=>this.#o(t,e),getDockable:(t,e)=>this.#l(t,e),listDockables:t=>this.#c(t),emit:t=>this.#h(t),getParam:t=>this.#i[t],watchModel:(t,e)=>this.#a(t,e)}}dock(t){this.#t.has(t.id)&&this.undock(t.id);let e=t.dock(this.context);this.#t.set(t.id,{dockable:t,cleanup:typeof e=="function"?e:null})}dockAll(t){let e=[...t].sort((i,n)=>(Ju[i.kind]??9)-(Ju[n.kind]??9));for(let i of e)this.dock(i)}undock(t){let e=this.#t.get(t);e&&(e.cleanup?.(),e.dockable.undock(),this.#t.delete(t))}undockAll(){let t=[...this.#t.entries()].sort((e,i)=>(Ju[i[1].dockable.kind]??9)-(Ju[e[1].dockable.kind]??9));for(let[e]of t)this.undock(e)}undockMany(t){for(let e of t)this.undock(e)}setInitialModel(t){Object.assign(this.#e,t)}setParams(t){Object.assign(this.#i,t)}updateElements(t){this.#r=t}#o(t,e){bA(this.#e,t,e);for(let[i,n]of this.#s)if(t===i||t.startsWith(i+"/"))for(let r of n)r(NO(this.#e,i))}#a(t,e){return this.#s.has(t)||this.#s.set(t,new Set),this.#s.get(t).add(e),()=>{let i=this.#s.get(t);i?.delete(e),i?.size===0&&this.#s.delete(t)}}#l(t,e){let i=this.#t.get(e);return i&&i.dockable.kind===t?i.dockable:null}#c(t){let e=[];for(let{dockable:i}of this.#t.values())(!t||i.kind===t)&&e.push(i);return e}#h(t){let e=t.target?this.#r.get(t.target):this.#n;e&&e.dispatchEvent(new CustomEvent(t.event,{bubbles:!0,detail:t}))}}});var Se,an=W(()=>{"use strict";Se=class{get kind(){throw new Error("Dockable subclass must define kind")}get id(){throw new Error("Dockable subclass must define id")}dock(t){throw new Error("Dockable subclass must implement dock()")}undock(){}}});var fa,BO=W(()=>{"use strict";an();fa=class extends Se{kind="controller";id;type;hostId;config;bind;controller=null;#t;constructor(t,e){super(),this.id=t.id,this.type=t.type,this.hostId=t.host,this.config=t.config||{},this.bind=t.bind||null,this.#t=e}async dock(t){let e=t.getElement(this.hostId);if(!e){console.warn(`ControllerDock: host element "${this.hostId}" not found`);return}let i=await this.#t(this.type);if(!i){console.warn(`ControllerDock: unknown controller type "${this.type}"`);return}this.controller=new i(this.config),this.controller.connect(e);let n=[];if(this.bind)for(let[r,o]of Object.entries(this.bind)){if(this.controller.subscribe){let l=this.controller.subscribe(r,h=>{t.setModel(o,h)});l&&n.push(l)}let a=t.getModel(o);a!==void 0&&this.controller.setState&&this.controller.setState(r,a)}return e.controller=this.controller,()=>{e.controller=null,n.forEach(r=>r())}}undock(){this.controller&&(this.controller.disconnect?.(),this.controller=null)}}});var pa,VO=W(()=>{"use strict";an();pa=class extends Se{kind="source";id;uri;path;refresh;#t;#e=null;constructor(t,e){super(),this.id=t.id,this.uri=t.uri,this.path=t.path,this.refresh=t.refresh||"once",this.#t=e}dock(t){if(this.#e=t,this.#i(t),this.refresh==="on-focus"){let e=()=>this.#i(t);return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)}if(this.refresh.startsWith("interval:")){let e=parseInt(this.refresh.split(":")[1],10);if(e>0){let i=setInterval(()=>this.#i(t),e);return()=>clearInterval(i)}}if(this.refresh==="stream"){let e=this.#s(t);try{let i=new EventSource(e);return i.onmessage=n=>{try{t.setModel(this.path,JSON.parse(n.data))}catch{}},()=>i.close()}catch{console.warn(`DataSourceDock: stream failed for ${e}`)}}}undock(){this.#e=null}refetch(){this.#e&&this.#i(this.#e)}async#i(t){let e=this.#s(t);try{let i=await this.#t(e,t);i!==void 0&&t.setModel(this.path,i)}catch(i){console.warn(`DataSourceDock: fetch failed for ${e}`,i)}}#s(t){return this.uri.replace(/\{(\w+)\}/g,(e,i)=>t.getParam(i)??t.getModel("/"+i)??"")}}});var td,ma,_O=W(()=>{"use strict";an();td={press:"click",submit:"submit",input:"input",change:"change",select:"select",toggle:"change",dismiss:"close",navigate:"click",mount:"connectedCallback",unmount:"disconnectedCallback",focus:"focusin",blur:"focusout",drag:"dragstart",drop:"drop"},ma=class extends Se{kind="action";id;event;handler;config;onSuccess;onError;#t;constructor(t,e){super(),this.event=t.event,this.handler=t.handler,this.config=t.config||{},this.onSuccess=t.onSuccess||null,this.onError=t.onError||null,this.#t=e,this.id=`action:${this.event.event}:${this.event.target||"root"}:${this.handler}`}dock(t){let e=this.event.target?t.getElement(this.event.target):t.getRootElement();if(!e){console.warn(`ActionDock: target "${this.event.target}" not found`);return}let i=td[this.event.event]||this.event.event,n=this.#t(this.handler);if(!n){console.warn(`ActionDock: unknown handler "${this.handler}"`);return}let r=async o=>{if(this.event.condition){let a=t.getModel(this.event.condition.path);if("equals"in this.event.condition&&a!==this.event.condition.equals||"notEquals"in this.event.condition&&a===this.event.condition.notEquals||"exists"in this.event.condition&&this.event.condition.exists&&a==null)return}try{let a=await n(this.config,t,o);if(this.onSuccess)for(let l of this.onSuccess){let h=this.#t(l.handler);h&&await h(l.config||{},t,a)}}catch(a){if(this.onError)for(let l of this.onError){let h=this.#t(l.handler);h&&await h(l.config||{},t,a)}else console.error(`ActionDock: handler "${this.handler}" failed`,a)}};if(this.event.debounce>0){let o=r,a;r=(...l)=>{clearTimeout(a),a=setTimeout(()=>o(...l),this.event.debounce)}}if(this.event.throttle>0){let o=r,a=0;r=(...l)=>{let h=Date.now();h-a>=this.event.throttle&&(a=h,o(...l))}}return e.addEventListener(i,r),()=>e.removeEventListener(i,r)}undock(){}}});var ga,jO=W(()=>{"use strict";an();ga=class extends Se{kind="provider";id;hostId;value;constructor(t){super(),this.id=`provider:${t.name}`,this.hostId=t.host||null,this.value=t.value??null}dock(t){let e=this.hostId?t.getElement(this.hostId):t.getRootElement();if(!e){console.warn(`ProviderDock: host "${this.hostId}" not found`);return}let i=document.createElement("a2ui-provider");return i.setAttribute("name",this.id.replace("provider:","")),i.value=this.value,e.parentNode?.insertBefore(i,e),i.appendChild(e),()=>{i.parentNode&&(i.parentNode.insertBefore(e,i),i.remove())}}undock(){}}});var Oa,WO=W(()=>{"use strict";an();Oa=class extends Se{kind="lifecycle";id="lifecycle";onMount;onUnmount;onModelChange;#t;#e=null;constructor(t,e){super(),this.onMount=t.onMount||[],this.onUnmount=t.onUnmount||[],this.onModelChange=t.onModelChange||[],this.#t=e}dock(t){this.#e=t;for(let i of this.onMount)this.#i(i,t);let e=this.onModelChange.map(i=>{let n=()=>this.#i(i,t);if(i.debounce>0){let r=n,o;n=()=>{clearTimeout(o),o=setTimeout(r,i.debounce)}}return t.watchModel(i.path,n)});return()=>e.forEach(i=>i())}undock(){if(this.#e){for(let t of this.onUnmount)this.#i(t,this.#e);this.#e=null}}async#i(t,e){let i=this.#t(t.handler);if(i)try{await i(t.config||{},e)}catch(n){console.warn(`LifecycleDock: ${t.handler} failed`,n)}}}});var vA,we,ln=W(()=>{"use strict";vA=new WeakSet,we=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!vA.has(e)&&e!==s&&(vA.add(e),e.schema||console.warn(`AdiaUI: ${e.name} extends BaseController without static schema`),this.getState===s.prototype.getState&&console.error(`AdiaUI: ${e.schema?.name??e.name} must implement getState()`)),this.#t&&this.#t!==t&&console.warn(`AdiaUI: ${e.schema?.name??e.name} already connected to a different host`),this.#t=t,this.onConnect(t),this.reflect()}disconnect(t){let e=t??this.#t;e&&(this.onDisconnect(e),this.#t=null)}subscribe(t){return this.#e.add(t),()=>this.#e.delete(t)}notify(){this.reflect();for(let t of this.#e)t()}onConnect(t){}onDisconnect(t){}reflect(){}getState(){throw new Error(`${this.constructor.schema?.name??this.constructor.name}: getState() not implemented`)}}});var xA={};Jt(xA,{FormController:()=>FO});var FO,SA=W(()=>{"use strict";ln();FO=class extends we{static schema=Object.freeze({name:"form",state:{values:"object",errors:"object",dirty:"boolean",valid:"boolean"},commands:["set","validate","reset","setInitial"],attributes:["data-form-valid","data-form-invalid","data-form-dirty"]});#t={};#e={};#i={};#s={};constructor(t={}){super(),this.#t={...t},this.#e={...t}}onDisconnect(t){t.removeAttribute("data-form-valid"),t.removeAttribute("data-form-invalid"),t.removeAttribute("data-form-dirty")}getState(){let t=Object.keys(this.#e).some(i=>this.#e[i]!==this.#t[i]),e=Object.keys(this.#i).length===0;return{values:{...this.#e},errors:{...this.#i},dirty:t,valid:e}}reflect(){if(!this.host)return;let{dirty:t,valid:e}=this.getState();e?(this.host.setAttribute("data-form-valid",""),this.host.removeAttribute("data-form-invalid")):(this.host.setAttribute("data-form-invalid",""),this.host.removeAttribute("data-form-valid")),t?this.host.setAttribute("data-form-dirty",""):this.host.removeAttribute("data-form-dirty")}#n(t){let e=this.#s[t];if(!e){delete this.#i[t];return}let i=e(this.#e[t]);i===!0||i==null?delete this.#i[t]:this.#i[t]=typeof i=="string"?i:"Invalid"}commands={set:(t,e)=>{this.#e[t]=e,this.#n(t),this.notify()},validate:(t,e)=>{this.#s[t]=e,this.#n(t),this.notify()},reset:()=>{this.#e={...this.#t},this.#i={};for(let t of Object.keys(this.#s))this.#n(t);this.notify()},setInitial:t=>{this.#t={...t}}}}});var wA={};Jt(wA,{DataStreamController:()=>UO});var UO,kA=W(()=>{"use strict";ln();UO=class extends we{static schema=Object.freeze({name:"data-stream",state:{data:"array",status:"string",error:"string"},commands:["push","pushMany","connect","poll","consume","stop","clear"],attributes:["data-stream-status"]});#t=[];#e;#i="idle";#s=null;#n=null;#r=0;#o=1;#a=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:n=[]}={}){super(),this.#e=t,this.#r=e,this.#o=Math.max(1,Math.round(i)),this.#t=n.slice(-t)}getState(){return{data:this.#t,status:this.#i,error:this.#s}}reflect(){this.host&&this.host.setAttribute("data-stream-status",this.#i)}onDisconnect(){this.commands.stop()}#c(t){this.#l++,!(this.#o>1&&this.#l%this.#o!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u())}#h(t){if(this.#o>1){let e=[];for(let i of t)this.#l++,this.#l%this.#o===0&&e.push(i);this.#t.push(...e)}else this.#t.push(...t);this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u()}#u(){if(this.#r<=0){this.notify();return}this.#a===null&&(this.#a=setTimeout(()=>{this.#a=null,this.notify()},this.#r))}#d(t,e=null){this.#i=t,this.#s=e,this.notify()}commands={push:t=>{this.#c(t)},pushMany:t=>{this.#h(t)},connect:(t,e)=>{this.commands.stop(),this.#n=new AbortController,t==="sse"?this.#f(e):t==="ws"?this.#p(e):this.#d("error",`Unknown stream type: ${t}`)},poll:(t,e=2e3)=>{this.commands.stop(),this.#n=new AbortController,this.#m(t,e)},consume:t=>{this.commands.stop(),this.#n=new AbortController,this.#O(t)},stop:()=>{this.#n&&(this.#n.abort(),this.#n=null),this.#a!==null&&(clearTimeout(this.#a),this.#a=null),(this.#i==="streaming"||this.#i==="connecting")&&this.#d("stopped")},clear:()=>{this.#t=[],this.notify()}};#f(t){this.#d("connecting");let e=new EventSource(t),i=this.#n.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=n=>{try{let r=JSON.parse(n.data);this.#c(r)}catch{}},e.onerror=()=>{i.aborted||(this.#d("error","SSE connection lost"),e.close())}}#p(t){this.#d("connecting");let e=new WebSocket(t),i=this.#n.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=n=>{try{let r=JSON.parse(n.data);Array.isArray(r)?this.#h(r):this.#c(r)}catch{}},e.onerror=()=>{i.aborted||this.#d("error","WebSocket error")},e.onclose=()=>{i.aborted||this.#d("stopped")}}async#m(t,e){this.#d("streaming");let i=this.#n.signal;for(;!i.aborted;){try{let r=await(await fetch(t,{signal:i})).json();Array.isArray(r)?this.#h(r):this.#c(r)}catch(n){if(i.aborted)break;this.#d("error",n.message);break}await new Promise(n=>setTimeout(n,e))}}async#O(t){this.#d("streaming");let e=this.#n.signal;try{for await(let i of t){if(e.aborted)break;Array.isArray(i)?this.#h(i):this.#c(i)}e.aborted||this.#d("idle")}catch(i){e.aborted||this.#d("error",i.message)}}}});var AA={};Jt(AA,{SelectionController:()=>YO});var YO,$A=W(()=>{"use strict";ln();YO=class extends we{static schema=Object.freeze({name:"selection",state:{selected:"Set",multiple:"boolean"},commands:["select","deselect","toggle","clear","selectAll"],attributes:["data-selection-active","data-selection-selected"]});#t=new Set;#e=!1;constructor({multiple:t=!1,initial:e=[]}={}){super(),this.#e=t;for(let i of e)this.#t.add(String(i))}onConnect(t){t.setAttribute("data-selection-active","")}onDisconnect(t){this.#i(t),t.removeAttribute("data-selection-active")}getState(){return{selected:new Set(this.#t),multiple:this.#e}}reflect(){if(!this.host)return;let t=this.host.querySelectorAll("[data-selection-key]");for(let e of t){let i=e.getAttribute("data-selection-key");this.#t.has(i)?e.setAttribute("data-selection-selected",""):e.removeAttribute("data-selection-selected")}}#i(t){let e=t.querySelectorAll("[data-selection-selected]");for(let i of e)i.removeAttribute("data-selection-selected")}commands={select:t=>{t=String(t),this.#e||this.#t.clear(),this.#t.add(t),this.notify()},deselect:t=>{this.#t.delete(String(t)),this.notify()},toggle:t=>{t=String(t),this.#t.has(t)?this.#t.delete(t):(this.#e||this.#t.clear(),this.#t.add(t)),this.notify()},clear:()=>{this.#t.clear(),this.notify()},selectAll:t=>{if(this.#e){for(let e of t)this.#t.add(String(e));this.notify()}}}}});var CA={};Jt(CA,{ToggleController:()=>HO});var HO,EA=W(()=>{"use strict";ln();HO=class extends we{static schema=Object.freeze({name:"toggle",state:{on:"boolean"},commands:["toggle","set"],attributes:["data-toggle-on"]});#t=!1;constructor(t=!1){super(),this.#t=t}getState(){return{on:this.#t}}onDisconnect(t){t.removeAttribute("data-toggle-on")}reflect(){this.host&&(this.#t?this.host.setAttribute("data-toggle-on",""):this.host.removeAttribute("data-toggle-on"))}commands={toggle:()=>{this.#t=!this.#t,this.notify()},set:t=>{this.#t=!!t,this.notify()}}}});var PA={};Jt(PA,{AccordionController:()=>GO});var GO,QA=W(()=>{"use strict";ln();GO=class extends we{static schema=Object.freeze({name:"accordion",state:{expanded:"Set",multiple:"boolean"},commands:["toggle","expand","collapse","collapseAll","expandAll"],attributes:["data-accordion-expanded"]});#t=new Set;#e=!1;constructor({multiple:t=!1,initial:e=[]}={}){super(),this.#e=t;for(let i of e)this.#t.add(String(i))}onDisconnect(t){let e=t.querySelectorAll("[data-accordion-expanded]");for(let i of e)i.removeAttribute("data-accordion-expanded")}getState(){return{expanded:new Set(this.#t),multiple:this.#e}}reflect(){if(!this.host)return;let t=this.host.querySelectorAll("[data-accordion-key]");for(let e of t){let i=e.getAttribute("data-accordion-key");this.#t.has(i)?e.setAttribute("data-accordion-expanded",""):e.removeAttribute("data-accordion-expanded")}}commands={toggle:t=>{t=String(t),this.#t.has(t)?this.#t.delete(t):(this.#e||this.#t.clear(),this.#t.add(t)),this.notify()},expand:t=>{t=String(t),this.#e||this.#t.clear(),this.#t.add(t),this.notify()},collapse:t=>{this.#t.delete(String(t)),this.notify()},collapseAll:()=>{this.#t.clear(),this.notify()},expandAll:t=>{if(this.#e){for(let e of t)this.#t.add(String(e));this.notify()}}}}});var TA={};Jt(TA,{StateMachineController:()=>KO});var KO,LA=W(()=>{"use strict";ln();KO=class extends we{static schema={name:"state-machine",state:{current:"string",history:"string[]"},commands:["send","transition","reset"],attributes:["data-state"],config:{initial:"string",states:"object"}};#t="";#e="";#i={};#s=[];onConnect(t){let e=this.config||{};this.#e=e.initial||t.dataset?.initial||Object.keys(e.states||{})[0]||"",this.#i=this._validateStates(e.states||{}),this.#t=this.#e,this.#s=this.#t?[this.#t]:[],this.#t&&this._emit("stateEntered",{state:this.#t,initial:!0})}getState(){return{current:this.#t,history:[...this.#s]}}reflect(){this.host&&(this.#t?this.host.setAttribute("data-state",this.#t):this.host.removeAttribute("data-state"))}commands={send:t=>{if(!t||!this.#t)return;let i=(this.#i[this.#t]?.on||{})[t];i&&this._moveTo(i,{event:t})},transition:t=>{!t||!(t in this.#i)||this._moveTo(t,{forced:!0})},reset:()=>{this.#e&&this._moveTo(this.#e,{reset:!0})}};_moveTo(t,e){if(t===this.#t)return;let i=this.#t;i&&this._emit("stateExited",{state:i,target:t,...e}),this.#t=t,this.#s.push(t),this.notify(),this._emit("stateEntered",{state:t,from:i,...e})}_emit(t,e){this.host&&this.host.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}_validateStates(t){let e={},i=Object.keys(t);for(let n of i){let r=t[n]||{},o={};for(let[a,l]of Object.entries(r.on||{})){if(typeof l!="string"||!(l in t)){console.warn(`[state-machine] state "${n}" transition "${a}" \u2192 "${l}" \u2014 target not declared`);continue}o[a]=l}e[n]={on:o}}return e}}});function MA(s,t){Vi.controllers.set(s,t)}function RA(s,t){Vi.handlers.set(s,t)}function IA(s,t){Vi.resolvers.set(s,t)}async function ed(s){let t=Vi.controllers.get(s);return t?t():null}function id(s){return Vi.handlers.get(s)||null}async function Hl(s,t={}){let e=s;for(let[o,a]of Object.entries(t))e=e.replace(`{${o}}`,encodeURIComponent(a));let i=e.indexOf("://");if(i===-1)throw new Error(`Invalid URI: ${s}`);let n=e.slice(0,i),r=Vi.resolvers.get(n);if(!r)throw new Error(`No resolver for scheme "${n}"`);return r(e,t)}async function i5(s){let{action:t,params:e}=s,i=JO(t.body,s),n=t.uri;for(let[c,u]of Object.entries(e))n=n.replace(`{${c}}`,encodeURIComponent(u));let r=n.indexOf("://"),o=r>-1?n.slice(0,r):"api",a=Vi.resolvers.get(o),l=n.replace(/^\w+:\/\//,"/api/"),h=await fetch(l,{method:t.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!h.ok){let c=await h.text().catch(()=>"Request failed");throw new Error(c)}return h.json().catch(()=>({}))}async function s5(s){let{action:t}=s,e=JO(t.value,s);s.updateModel(t.path,e)}async function n5(s){let{action:t,params:e}=s,i=t.navigate||t.path||"";for(let[n,r]of Object.entries(e))i=i.replace(`{${n}}`,encodeURIComponent(r));i==="back"?history.back():i&&(location.hash=i)}async function r5(){history.back()}async function o5(s){let{action:t,controllers:e}=s,i=e[t.controllerId];if(!i?.commands?.[t.command]){console.warn(`Wiring: controller "${t.controllerId}" or command "${t.command}" not found`);return}return i.commands[t.command](t.args)}async function a5(s){let{action:t,source:e}=s,i=JO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function l5(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function h5(s){let{action:t}=s,e=typeof t=="string"?t:t.message||t.notify;document.dispatchEvent(new CustomEvent("a2ui-notify",{bubbles:!0,detail:{message:e,variant:t.variant||"info"}}))}function JO(s,t){if(s){if(typeof s!="object")return s;switch(s.from){case"event-detail":return s.key?t.event?.detail?.[s.key]:t.event?.detail;case"event-target":return s.key?t.source?.[s.key]:t.source?.value;case"model":return yA(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}async function c5(s,t){let e=s.replace(/^resource:\/\//,"/api/"),i=await fetch(e);if(!i.ok)throw new Error(`Resource fetch failed: ${i.status}`);return i.json()}async function u5(s,t){let e=s.replace(/^api:\/\//,"https://"),i=await fetch(e);if(!i.ok)throw new Error(`API fetch failed: ${i.status}`);return i.json()}async function d5(s,t){return{_source:s,_mock:!0}}var Vi,tb=W(()=>{"use strict";Ku();Vi={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(SA(),xA))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(kA(),wA))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>($A(),AA))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(EA(),CA))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(QA(),PA))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(LA(),TA))).StateMachineController]]),handlers:new Map([["submit-resource",i5],["update-model",s5],["navigate",n5],["navigate-back",r5],["controller-command",o5],["emit-event",a5],["refresh-source",l5],["notify",h5]]),resolvers:new Map([["resource",c5],["api",u5],["mock",d5]])}});function f5(s){return async(t,e,i)=>{let n={action:t,event:i instanceof Event?i:null,source:i instanceof Event?i.target:null,dataModel:e.getModel(),updateModel:(r,o)=>e.setModel(r,o),controllers:Object.fromEntries(e.listDockables("controller").map(r=>[r.id,r.controller])),params:{},resolveData:Hl};return s(n)}}function p5(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=id(t);if(!e)return null;let i=f5(e);return s.set(t,i),i}}function m5(){return async s=>ed(s)}function g5(){return async(s,t)=>Hl(s,{})}function sd(s){let t=[],e=p5(),i=m5(),n=g5();if(s.data?.sources)for(let o of s.data.sources)t.push(new pa(o,n));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new fa(o,i));if(s.actions)for(let o of s.actions)t.push(new ma(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new ga(a))}s.lifecycle&&t.push(new Oa(s.lifecycle,e));let r=s.state?.model||null;return{dockables:t,initialModel:r}}var eb=W(()=>{"use strict";BO();VO();_O();jO();WO();tb()});var DA={};Jt(DA,{WiringEngine:()=>Gl});var Gl,ib=W(()=>{"use strict";zO();eb();Gl=class{#t=new Map;#e;#i;constructor({updateDataModel:t,getElement:e}){this.#e=t,this.#i=e}async process(t){let{surfaceId:e}=t;if(!e)return;let i=this.#t.get(e);i||(i=this.#s(e),this.#t.set(e,i));try{t.data?.params&&i.setParams(this.#n(t.data.params));let{dockables:n,initialModel:r}=sd(t);r&&i.setInitialModel(r),t.undock&&i.undockMany(t.undock);for(let o of n)await i.dock(o)}catch(n){console.warn(`Wiring: error processing wireComponents for "${e}":`,n.message)}}teardown(t){let e=this.#t.get(t);e&&(e.undockAll(),this.#t.delete(t))}undockIds(t,e){let i=this.#t.get(t);i&&i.undockMany(e)}teardownAll(){for(let t of this.#t.keys())this.teardown(t)}getSurface(t){return this.#t.get(t)||null}getSurfaceState(t){let e=this.#t.get(t);if(!e)return null;let i=e.context.listDockables();return{surfaceId:t,controllerCount:i.filter(n=>n.kind==="controller").length,sourceCount:i.filter(n=>n.kind==="source").length,actionCount:i.filter(n=>n.kind==="action").length,providerCount:i.filter(n=>n.kind==="provider").length,hasLifecycle:i.some(n=>n.kind==="lifecycle"),totalDocked:i.length}}#s(t){let e={get:h=>this.#i(t,h),has:h=>!!this.#i(t,h)},i=this.#i(t,"root")||document.createElement("div"),n=new Proxy(new Map,{get(h,c){return c==="get"?u=>e.get(u):c==="has"?u=>e.has(u):h[c]}}),r=new da(t,i,n),o=r.context,a=o.setModel,l=this.#e;return Object.defineProperty(r,"context",{get(){return{...o,setModel(c,u){a(c,u),l(t,c,u)}}}}),r}#n(t){let e={};for(let[i,n]of Object.entries(t))switch(n.from){case"route":{let o=location.hash.slice(1).match(new RegExp(`${n.key}/([^/]+)`));o&&(e[i]=o[1]);break}case"query":{let o=new URL(location.href).searchParams.get(n.key);o&&(e[i]=o);break}case"literal":e[i]=n.value;break;default:typeof n=="string"&&(e[i]=n)}return e}}});function fs(s){return y5.has(s.toLowerCase())?s.toLowerCase():s.replace(/([A-Z])/g,"-$1").toLowerCase()}function nd(s,t,e){if(t==="style"&&typeof e=="string"){s.style.cssText=e;return}if(O5.has(t)&&e!=null){if(t==="textContent"&&!b5.has(s.localName)){s.setAttribute("text",String(e));return}let i=e;if(typeof i=="string"&&(i.startsWith("[")||i.startsWith("{")))try{i=JSON.parse(i)}catch{}s[t]=i;return}if(typeof e=="boolean"){e?s.setAttribute(fs(t),""):s.removeAttribute(fs(t));return}e!=null?s.setAttribute(fs(t),String(e)):s.removeAttribute(fs(t))}var O5,b5,y5,sb=W(()=>{"use strict";O5=new Set(["data","columns","options","itemRenderer","textContent","pageSizeOptions"]),b5=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui","kbd-ui"]),y5=new Set(["autocomplete","autofocus","autocapitalize","autocorrect","inputmode","enterkeyhint","spellcheck","maxlength","minlength","readonly","novalidate","formnovalidate","formaction","formenctype","formmethod","formtarget","multiple","pattern","placeholder","required","tabindex","accesskey","autoplay","autopictureinpicture","controls","crossorigin","disablepictureinpicture","disableremoteplayback","loop","muted","playsinline","preload","srcset","srcdoc","srclang","sizes","loading","decoding","fetchpriority","ismap","usemap","hreflang","referrerpolicy","download","contenteditable","contextmenu","draggable","dirname","colspan","rowspan","headers","allowfullscreen","allowpaymentrequest","itemid","itemprop","itemref","itemscope","itemtype","nomodule","nonce"])});var ps,XA=W(()=>{"use strict";qO();sb();Ku();ps=class s{#t;#e;#i=new Map;#s=new Map;#n=new Map;#r=[];#o=null;#a=!1;constructor(t,e=zt,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#a=i}process(t){t&&(this.#a?(this.#r.push(t),this.#o===null&&(this.#o=requestAnimationFrame(()=>this.#l()))):this.#h(t))}#l(){this.#o=null;let t=this.#r.splice(0);for(let e of t)try{this.#h(e)}catch(i){console.error("A2UI: message failed during batch flush",i),this.#z(null,"a2ui-message-error",{error:i,messageType:e?.type||e?.messageType})}}static#c=new Set(["updateComponents","updateDataModel","wireComponents","updateStyles","removeStyles"]);#h(t){let e=t.type||t.messageType,i=t.surfaceId;if(i&&s.#c.has(e)){let n=this.#i.get(i);if(n&&!n.synthetic&&this.#d(n)){n.lifecycle.buffer.push(t);return}}this.#u(t)}#u(t){switch(t.type||t.messageType){case"createSurface":this.#m(t);return;case"updateComponents":this.#O(t);return;case"updateDataModel":this.#k(t);return;case"wireComponents":return this.#p(t);case"deleteSurface":this.#y(t);return;case"updateStyles":this.#R(t);return;case"removeStyles":this.#X(t);return;case"meta":return;default:console.warn("A2UI: unknown message type",t.type);return}}#d(t){return t.lifecycle.state==="pending-first"||t.lifecycle.state==="pending-stale"}#f=null;async#p(t){if(!this.#f){let{WiringEngine:e}=await Promise.resolve().then(()=>(ib(),DA));this.#f=new e({updateDataModel:(i,n,r)=>{this.#k({surfaceId:i,path:n,value:r})},getElement:(i,n)=>this.#i.get(i)?.elements.get(n)||null})}await this.#f.process(t)}async processStream(t){for await(let e of t)this.process(e)}#m({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t)){let r=this.#i.get(t);this.#z(r.root,"a2ui-duplicate-surface-id",{surfaceId:t});let o=new Error(`A2UI: duplicate createSurface for surfaceId "${t}" \u2014 REQ-002 (spec-a2ui-v1-conformance.md) makes this a hard error. Regenerate an existing surface with renderer.beginSurfaceUpdate(surfaceId) \u2192 applyTo \u2192 commitSurfaceUpdate instead (spec-a2ui-surface-lifecycle.md).`);throw o.code="DUPLICATE_SURFACE_ID",o.surfaceId=t,o}let n=document.createElement("div");n.setAttribute("data-a2ui-surface",t),e&&n.setAttribute("data-catalog",e),this.#t.appendChild(n),this.#i.set(t,{root:n,rootId:typeof i=="string"&&i?i:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets:new Map,synthetic:!1,lifecycle:{state:"empty",generationId:null,buffer:null,mode:"replace",reason:null,hadError:!1}})}#O({surfaceId:t,components:e}){let i=this.#i.get(t);i||(i={root:this.#t,rootId:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets:new Map,synthetic:!0,lifecycle:null},this.#i.set(t,i),this.#t&&typeof this.#t.setAttribute=="function"&&this.#t.setAttribute("data-a2ui-surface",t));for(let l of e)if(!(!l.id&&l.id!==0)){if(l.component==="ContextBindings"){i.contextBindings=l;continue}try{let h=i.elements.get(l.id),c=l.component==="Text"?this.#$(l.variant,l):Hu(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-id",l.id),h.id=l.id,h.setAttribute("data-a2ui-unknown",l.component),h.textContent=`[unknown: ${l.component}]`,i.elements.set(l.id,h),this.#s.set(l.id,h));continue}if(!h)h=document.createElement(c),h.setAttribute("data-a2ui-id",l.id),h.id=l.id,i.elements.set(l.id,h),this.#s.set(l.id,h);else if(h.localName!==c){let d=document.createElement(c);d.setAttribute("data-a2ui-id",l.id),d.id=l.id,h.replaceWith(d),h=d,i.elements.set(l.id,h),this.#s.set(l.id,h)}l._surfaceId=t,Object.values(l).some(d=>d&&typeof d=="object"&&d.path)&&i.bindings.set(l.id,l),this.#C(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#w(e);let n=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])n.set(h,l.id);l.child&&n.set(l.child,l.id)}let r=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=n.get(u)}return!1};for(let l of e){let h=i.elements.get(l.id);if(h)try{let c=Array.isArray(l.children)?l.children:[];for(let u of c){if(u===l.id||r(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!r(l.id,l.child)){let u=i.elements.get(l.child);u&&u.parentElement!==h&&h.appendChild(u)}}catch(c){console.warn(`A2UI: tree build failed for "${l.id}":`,c.message)}}let o=i.rootId??"root";if(e.find(l=>l.id===o)){let l=i.elements.get(o);l&&l.parentElement!==i.root&&i.root.appendChild(l)}}static#g=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#S=new Set(["Header","Section","Footer"]);static#v=new Set(["header","body","footer"]);#x=new Set;#w(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let n=i.component==="Card"||i.component==="ErrorContainer",r=i.component==="Drawer";if(!n&&!r)continue;let o=r?s.#S:s.#g,a=r?"<drawer-ui>":"<card-ui>",l=Array.isArray(i.children)?i.children:[];for(let h of l){let c=e.get(h);if(!c||typeof c.slot=="string"&&s.#v.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#x.has(u)||(this.#x.add(u),console.warn(`A2UI: ${a} (id="${i.id}") body must wrap "${c.component}" (id="${h}") in <Section>. Direct flow children bypass the canonical body slot and lose --card-inset margin. Canonical children: ${[...o].join(", ")}`+(r?', or slot="header|body|footer".':".")))}}}static#b={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};#$(t,e){return!e?.slot&&s.#b[t]?s.#b[t]:"text-ui"}#C(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#b[e.variant]&&i.add("variant");let n=this.#n.get(e.id),r={};for(let[o,a]of Object.entries(e)){if(i.has(o))continue;let l=a&&typeof a=="object"&&a.path,h=this.#P(a,e._surfaceId);r[o]=h,!(n&&Object.is(n[o],h))&&(h==null&&!l||nd(t,o,h))}if(n)for(let o of Object.keys(n))!(o in r)&&!i.has(o)&&t.removeAttribute(fs(o));this.#n.set(e.id,r)}#P(t,e){if(t==null)return null;if(typeof t!="object")return t;if(t.path){let i=e?this.#i.get(e):null;return i?gA(i.dataModel,t.path):t.path}return t}#k({surfaceId:t,path:e,value:i}){let n=this.#i.get(t);if(n){!e||e==="/"?n.dataModel=i??{}:OA(n.dataModel,e,i);for(let[r,o]of n.bindings){let a=n.elements.get(r);a&&this.#C(a,o)}}}#y({surfaceId:t}){let e=this.#i.get(t);if(e){this.#f?.teardown(t);for(let[i]of e.elements)this.#s.delete(i);if(e.adoptedSheets&&e.adoptedSheets.size>0){let i=new Set;for(let n of e.adoptedSheets.values())i.add(n.sheet);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(n=>!i.has(n)),e.adoptedSheets.clear()}e.root.remove(),this.#i.delete(t)}}#A=0;#T(){return this.#A+=1,`g${this.#A}-${Date.now().toString(36)}`}#E(t,e){t.root?.setAttribute?.("data-a2ui-lifecycle",e)}#L(t,e,i){let n=t||this.#t;if(!(!n||typeof CustomEvent>"u"))try{n.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!1}))}catch{}}beginSurfaceUpdate(t,{generationId:e,reason:i=null,mode:n="replace"}={}){let r=this.#i.get(t);if(!r)return console.warn(`A2UI: beginSurfaceUpdate \u2014 no such surface "${t}"`),null;if(r.synthetic)return console.warn(`A2UI: beginSurfaceUpdate \u2014 surfaceId "${t}" is synthetic (no prior createSurface); lifecycle is a no-op here. Send createSurface first.`),null;let o=r.lifecycle,a=o.state==="error-empty"||o.state==="error-stale",h=o.state==="live"||o.state==="error-stale"?"pending-stale":"pending-first";return o.state=h,o.generationId=typeof e=="string"&&e?e:this.#T(),o.buffer=[],o.mode=n==="patch"?"patch":"replace",o.reason=i,o.hadError=a,this.#E(r,h),this.#L(r.root,"surface-pending",{surfaceId:t,generationId:o.generationId,reason:i,firstRender:h==="pending-first"}),o.generationId}applyTo(t,e){let i=Array.isArray(e)?e:[e];for(let n of i)this.#h({...n,surfaceId:t})}async commitSurfaceUpdate(t,e){let i=this.#i.get(t);if(!i||i.synthetic)return console.warn(`A2UI: commitSurfaceUpdate \u2014 no such lifecycle surface "${t}"`),!1;let n=i.lifecycle;if(!this.#d(i))return console.warn(`A2UI: commitSurfaceUpdate \u2014 surface "${t}" has no in-flight generation to commit`),!1;if(e!=null&&e!==n.generationId)return!1;let r=n.buffer||[],o=n.generationId,a=n.hadError,l=[],h=[];if(n.mode==="replace"){let c=new Set,u=!1,d=new Set,f=!1;for(let p of r){let m=p.type||p.messageType;if(m==="updateComponents"){u=!0;for(let g of p.components||[])g.id!=null&&c.add(g.id)}else m==="updateStyles"&&(f=!0,typeof p.styleId=="string"&&d.add(p.styleId))}for(let p of r)await this.#u(p);u&&(l=this.#M(t,c)),f&&(h=this.#Q(t,d))}else for(let c of r)await this.#u(c);return n.state="live",n.buffer=null,n.generationId=null,n.reason=null,n.hadError=!1,this.#E(i,"live"),this.#L(i.root,"surface-committed",{surfaceId:t,generationId:o,healed:a,swept:l,stylesSwept:h}),!0}#Q(t,e){let i=this.#i.get(t);if(!i||!i.adoptedSheets||i.adoptedSheets.size===0)return[];let n=[];for(let r of[...i.adoptedSheets.keys()]){if(e.has(r))continue;let o=i.adoptedSheets.get(r);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet),i.adoptedSheets.delete(r),this.#D(i.root,"styles-removed",{surfaceId:t,styleId:r}),n.push(r)}return n}#M(t,e){let i=this.#i.get(t);if(!i)return[];let n=[];for(let r of[...i.elements.keys()]){if(e.has(r))continue;i.elements.get(r)?.remove(),i.elements.delete(r),this.#s.delete(r),i.bindings.delete(r),this.#n.delete(r),n.push(r)}return n.length>0&&this.#f?.undockIds(t,n),n}abortSurfaceUpdate(t,e,i){let n=this.#i.get(t);if(!n||n.synthetic)return console.warn(`A2UI: abortSurfaceUpdate \u2014 no such lifecycle surface "${t}"`),!1;let r=n.lifecycle;if(!this.#d(n))return console.warn(`A2UI: abortSurfaceUpdate \u2014 surface "${t}" has no in-flight generation to abort`),!1;if(e!=null&&e!==r.generationId)return!1;let o=r.generationId,a=r.state==="pending-first"?"error-empty":"error-stale";return r.state=a,r.buffer=null,r.generationId=null,r.reason=null,r.hadError=!0,this.#E(n,a),this.#L(n.root,"surface-aborted",{surfaceId:t,generationId:o,error:i??null}),!0}getLifecycle(t){let e=this.#i.get(t);return e&&!e.synthetic?e.lifecycle:null}isPending(t){let e=this.getLifecycle(t);return e?.state==="pending-first"||e?.state==="pending-stale"}get pendingSurfaces(){let t=[];for(let[e,i]of this.#i)!i.synthetic&&this.#d(i)&&t.push(e);return t}static#I=new Set(["root","html","body"]);#R({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#D(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#D(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: css must be a string"});return}let n=this.#i.get(t);if(!n){this.#D(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let r=this.#N(i,t);if(r.rejected){this.#D(n.root,"styles-rejected",{surfaceId:t,styleId:e,reason:r.reason});return}let o=n.adoptedSheets.get(e);o&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet)),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r.sheet],n.adoptedSheets.set(e,{sheet:r.sheet,ruleCount:r.sheet.cssRules.length,appliedAt:typeof performance<"u"?performance.now():Date.now()}),this.#D(n.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:r.sheet.cssRules.length,validationWarnings:r.warnings})}#X({surfaceId:t,styleId:e}){let i=this.#i.get(t);if(!i)return;let n=i.adoptedSheets.get(e);n&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>r!==n.sheet),i.adoptedSheets.delete(e),this.#D(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#N(t,e){let i=[];if(/^\s*@import\b/im.test(t))return{rejected:!0,reason:"forbidden-import"};if(/^\s*@charset\b/im.test(t))return{rejected:!0,reason:"forbidden-charset"};let n=new CSSStyleSheet;try{n.replaceSync(t)}catch(l){return{rejected:!0,reason:"parse-error: "+(l?.message||String(l))}}for(let l of n.cssRules){let h=this.#Z(l);if(h)return{rejected:!0,reason:h}}if(/url\s*\(\s*["']?\s*(?:https?:|\/\/)/i.test(t))return{rejected:!0,reason:"external-url"};for(let l of n.cssRules)if(l.constructor?.name==="CSSPropertyRule"||l.cssText?.startsWith("@property")){let h=l.cssText.match(/@property\s+(--[\w-]+)/);h&&i.push({kind:"property-registered-globally",name:h[1]})}let r=this.#q(n,e),o=this.#F(n,e),a=new CSSStyleSheet;try{a.replaceSync(o)}catch(l){return{rejected:!0,reason:"scope-wrap-failed: "+(l?.message||String(l))}}return r.length>0&&i.push({kind:"animations-namespaced",count:r.length}),{rejected:!1,sheet:a,warnings:i}}#Z(t){let e=t.cssText||"";if(/^@import\b/i.test(e))return"forbidden-import";if(/^@charset\b/i.test(e))return"forbidden-charset";if(/^@scope\b/i.test(e))return"forbidden-scope-directive";if(t.selectorText){let i=this.#B(t.selectorText);for(let n of i){let r=n.trim().replace(/^:scope\s*/,"");if(r.startsWith(":root"))return"forbidden-root-selector";let o=r.match(/^([a-zA-Z*][\w-]*)/);if(!o)continue;let a=o[1].toLowerCase();if(s.#I.has(a))return`forbidden-${a}-selector`}}return null}#B(t){let e=[],i=0,n=0;for(let r=0;r<t.length;r++){let o=t[r];o==="("?i++:o===")"?i--:o===","&&i===0&&(e.push(t.slice(n,r)),n=r+1)}return e.push(t.slice(n)),e}#q(t,e){let i=[],n=String(e).replace(/[^a-zA-Z0-9_-]/g,"_");for(let o=0;o<t.cssRules.length;o++){let a=t.cssRules[o];if(a.constructor?.name==="CSSKeyframesRule"||a.cssText?.startsWith("@keyframes")){let l=a.name;if(!l)continue;let h=`${n}_${l}`;try{a.name=h}catch{let c=a.cssText.replace(/@keyframes\s+[\w-]+/,`@keyframes ${h}`);t.deleteRule(o),t.insertRule(c,o)}i.push({from:l,to:h})}}if(i.length===0)return i;let r=new Map(i.map(o=>[o.from,o.to]));for(let o of t.cssRules)if(o.style)for(let a of["animation","animation-name"]){let l=o.style.getPropertyValue(a);if(!l)continue;let h=l.replace(/\b([\w-]+)\b/g,c=>r.has(c)?r.get(c):c);h!==l&&o.style.setProperty(a,h)}return i}#F(t,e){let i=[];for(let r of t.cssRules)i.push(r.cssText);return`@scope ([data-a2ui-surface="${String(e).replace(/"/g,'\\"')}"]) {
41
+ `&&(h++,l=u+1);let c=Math.min(e,l+Math.max(0,a-1));return{from:c,to:Math.min(e,c+1)}}let r=Math.max(0,e);return{from:Math.max(0,r-1),to:r}}var wI,kI,AI,AO,CI,CO=W(()=>{"use strict";ai();Ei();Ik();fi();Hk();ri();wI=Z.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{caretColor:"inherit"},".cm-focused":{outline:"none"}}),kI=Mi.define([{tag:[y.comment,y.lineComment,y.blockComment,y.docComment],class:"tok-comment"},{tag:[y.keyword,y.controlKeyword,y.modifier,y.operatorKeyword],class:"tok-keyword"},{tag:[y.string,y.character,y.regexp,y.escape,y.special(y.string)],class:"tok-string"},{tag:[y.number,y.integer,y.float],class:"tok-number"},{tag:[y.bool,y.null,y.atom],class:"tok-boolean"},{tag:[y.operator,y.logicOperator,y.arithmeticOperator,y.compareOperator,y.updateOperator,y.definitionOperator],class:"tok-operator"},{tag:[y.punctuation,y.bracket,y.paren,y.brace,y.squareBracket,y.angleBracket,y.separator],class:"tok-punctuation"},{tag:[y.function(y.variableName),y.function(y.propertyName),y.macroName],class:"tok-function"},{tag:[y.variableName,y.local(y.variableName),y.self],class:"tok-variable"},{tag:[y.typeName,y.className,y.namespace],class:"tok-type"},{tag:[y.propertyName,y.labelName,y.definition(y.variableName)],class:"tok-property"},{tag:[y.tagName,y.heading,y.contentSeparator],class:"tok-tag"},{tag:[y.attributeName,y.attributeValue],class:"tok-attribute"},{tag:[y.url,y.link],class:"tok-url"},{tag:[y.invalid,y.deleted],class:"tok-invalid"}]),AI={json:()=>Promise.resolve().then(()=>(Tx(),Qx)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(og(),hw)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(Jm(),GS)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(km(),aS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(i1(),e1)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(O1(),g1)).then(s=>({extension:s.yaml()}))},AO=1e4;CI=Wl(s=>{let t=s.state.doc.toString();if(t.trim()==="")return[];try{return JSON.parse(t),[]}catch(e){let i=e instanceof Error?e.message:String(e),{from:n,to:r}=EI(i,t);return[{from:n,to:r,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function Hu(s){return zt.get(s)||null}function pA(s,t){zt.set(s,t)}var zt,qO=W(()=>{"use strict";zt=new Map([["Row","row-ui"],["Column","col-ui"],["List","list-ui"],["ListItem","list-item-ui"],["Grid","grid-ui"],["Stack","stack-ui"],["Block","block-ui"],["Text","text-ui"],["Image","image-ui"],["Icon","icon-ui"],["Divider","divider-ui"],["Badge","badge-ui"],["Avatar","avatar-ui"],["AvatarGroup","avatar-group-ui"],["Progress","progress-ui"],["DateRangePicker","date-range-picker-ui"],["CalendarGrid","calendar-grid-ui"],["CalendarPicker","calendar-picker-ui"],["Combobox","combobox-ui"],["Skeleton","skeleton-ui"],["Stepper","stepper-ui"],["StepperItem","stepper-item-ui"],["Tour","tour-ui"],["TourStep","tour-step-ui"],["IntegrationCard","integration-card-ui"],["Code","code-ui"],["Stat","stat-ui"],["EmptyState","empty-state-ui"],["Input","input-ui"],["TextField","input-ui"],["TextArea","textarea-ui"],["Field","field-ui"],["CheckBox","check-ui"],["Toggle","switch-ui"],["Switch","switch-ui"],["Slider","slider-ui"],["Range","range-ui"],["Rating","rating-ui"],["ChoicePicker","select-ui"],["Select","select-ui"],["Radio","radio-ui"],["RadioGroup","radio-group-ui"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorArea","color-area-ui"],["Upload","upload-ui"],["OtpInput","otp-input-ui"],["Button","button-ui"],["LoadingIndicator","progress-ui"],["ErrorContainer","card-ui"],["Card","card-ui"],["Tabs","tabs-ui"],["Tab","tab-ui"],["Panel","pane-ui"],["Pane","pane-ui"],["Modal","modal-ui"],["Dialog","modal-ui"],["Drawer","drawer-ui"],["Toast","toast-ui"],["AnchorBar","anchor-bar-ui"],["Popover","popover-ui"],["Accordion","accordion-ui"],["AccordionItem","accordion-item-ui"],["Alert","alert-ui"],["Tooltip","tooltip-ui"],["Menu","menu-ui"],["Section","section"],["Header","header"],["Footer","footer"],["Stream","stream-ui"],["Table","table-ui"],["ColDef","col-def"],["Chart","chart-ui"],["Embed","embed-ui"],["Swiper","swiper-ui"],["Slideshow","swiper-ui"],["Carousel","swiper-ui"],["Breadcrumb","breadcrumb-ui"],["Drilldown","drilldown-ui"],["Link","link-ui"],["Anchor","link-ui"],["Hyperlink","link-ui"],["NavLink","link-ui"],["Nav","nav-ui"],["NavGroup","nav-group-ui"],["NavItem","nav-item-ui"],["Noodles","noodles-ui"],["Pagination","pagination-ui"],["SegmentedControl","segmented-ui"],["Segment","segment-ui"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-ui"],["ToolbarGroup","toolbar-group-ui"],["Tag","tag-ui"],["Timeline","timeline-ui"],["TimelineItem","timeline-item-ui"],["button-ui","button-ui"],["card-ui","card-ui"],["text-ui","text-ui"],["input-ui","input-ui"],["text-field-ui","input-ui"],["select-ui","select-ui"],["toggle-ui","switch-ui"],["check-ui","check-ui"],["slider-ui","slider-ui"],["badge-ui","badge-ui"],["avatar-ui","avatar-ui"],["icon-ui","icon-ui"],["image-ui","image-ui"],["divider-ui","divider-ui"],["progress-ui","progress-ui"],["skeleton-ui","skeleton-ui"],["tabs-ui","tabs-ui"],["tab-ui","tab-ui"],["modal-ui","modal-ui"],["dialog-ui","modal-ui"],["drawer-ui","drawer-ui"],["toast-ui","toast-ui"],["popover-ui","popover-ui"],["panel-ui","pane-ui"],["accordion-ui","accordion-ui"],["alert-ui","alert-ui"],["tooltip-ui","tooltip-ui"],["menu-ui","menu-ui"],["table-ui","table-ui"],["chart-ui","chart-ui"],["code-ui","code-ui"],["textarea-ui","textarea-ui"],["radio-ui","radio-ui"],["tag-ui","tag-ui"],["search-ui","search-ui"],["upload-ui","upload-ui"],["breadcrumb-ui","breadcrumb-ui"],["link-ui","link-ui"],["nav-ui","nav-ui"],["noodles-ui","noodles-ui"],["pagination-ui","pagination-ui"],["segmented-control-ui","segmented-ui"],["segment-ui","segment-ui"],["command-ui","command-ui"],["calendar-picker-ui","calendar-picker-ui"],["color-area-ui","color-area-ui"],["kbd-ui","kbd-ui"],["toolbar-ui","toolbar-ui"],["otp-input-ui","otp-input-ui"],["embed-ui","embed-ui"],["stream-ui","stream-ui"],["row-ui","row-ui"],["col-ui","col-ui"],["grid-ui","grid-ui"],["stack-ui","stack-ui"],["block-ui","block-ui"],["list-ui","list-ui"],["range-ui","range-ui"],["datetime-ui","calendar-picker-ui"],["timeline-ui","timeline-ui"],["timeline-item-ui","timeline-item-ui"],["avatar-group-ui","avatar-group-ui"],["Keyboard","kbd-ui"],["DatePicker","calendar-picker-ui"],["CommandPalette","command-ui"],["FormContainer","form"],["Sidebar","admin-sidebar"],["Segmented","segmented-ui"],["OTP","otp-input-ui"],["Textarea","textarea-ui"],["RichText","richtext-ui"],["Richtext","richtext-ui"],["DescriptionList","description-list-ui"],["ActionItem","action-item-ui"],["ActionList","action-list-ui"],["Inspector","inspector-ui"],["Heatmap","heatmap-ui"],["ChatThread","chat-thread"],["UIChatThread","chat-thread-ui"],["ChatInput","chat-input-ui"],["OptionCard","option-card-ui"],["Option","option-card-ui"],["AdminCommand","admin-command"],["AdminContent","admin-content"],["AdminPage","admin-page"],["AdminPageBody","admin-page-body"],["AdminPageHeader","admin-page-header"],["AdminScroll","admin-scroll"],["AdminShell","admin-shell"],["AdminSidebar","admin-sidebar"],["AdminStatusbar","admin-statusbar"],["AdminTopbar","admin-topbar"],["ChatComposer","chat-composer"],["ChatEmpty","chat-empty"],["ChatHeader","chat-header"],["ChatShell","chat-shell"],["ChatSidebar","chat-sidebar"],["ChatStatus","chat-status"],["EditorCanvas","editor-canvas"],["EditorCanvasEmpty","editor-canvas-empty"],["EditorShell","editor-shell"],["EditorSidebar","editor-sidebar"],["EditorStatusbar","editor-statusbar"],["EditorToolbar","editor-toolbar"],["GenRoot","gen-root"],["SimpleContent","simple-content"],["SimpleHero","simple-hero"],["SimpleShell","simple-shell"],["ThemePanel","theme-panel"],["AdiaMark","adia-mark-ui"],["AdiaWordmark","adia-wordmark-ui"],["AgentArtifact","agent-artifact-ui"],["AgentFeedbackBar","agent-feedback-bar-ui"],["AgentQuestions","agent-questions-ui"],["AgentReasoning","agent-reasoning-ui"],["AgentSuggestions","agent-suggestions-ui"],["AgentTrace","agent-trace-ui"],["Aside","aside-ui"],["Blockquote","blockquote-ui"],["Canvas","canvas-ui"],["ChartLegend","chart-legend-ui"],["ColorInput","color-input-ui"],["ContextMenu","context-menu-ui"],["DemoToggle","demo-toggle-ui"],["DisplayField","display-field-ui"],["Feed","feed-ui"],["FeedItem","feed-item-ui"],["Fields","fields-ui"],["Frame","frame-ui"],["InlineEdit","inline-edit-ui"],["InlineMessage","inline-message-ui"],["ListWindow","list-window-ui"],["LoadingOverlay","loading-overlay-ui"],["Mark","mark-ui"],["MenuDivider","menu-divider-ui"],["MenuItem","menu-item-ui"],["MenuLabel","menu-label-ui"],["NumberFormat","number-format-ui"],["Page","page-ui"],["PasswordStrength","password-strength-ui"],["PipelineStatus","pipeline-status-ui"],["Preview","preview-ui"],["QRCode","qr-code-ui"],["RelativeTime","relative-time-ui"],["Search","search-ui"],["SkipNav","skip-nav-ui"],["Spinner","spinner-ui"],["StepProgress","step-progress-ui"],["Swatch","swatch-ui"],["TableFooter","table-footer-ui"],["TableOfContents","toc-ui"],["TableToolbar","table-toolbar-ui"],["TagsInput","tags-input-ui"],["ThemeProvider","theme-provider"],["TimePicker","time-picker-ui"],["ToggleScheme","toggle-scheme-ui"],["Tree","tree-ui"],["TreeItem","tree-item-ui"],["VisuallyHidden","visually-hidden-ui"],["AdminEntityItem","admin-entity-item"],["AdminRoster","admin-roster-ui"],["AdminSettings","admin-settings-ui"],["AgentAdmin","agent-admin-ui"],["AppShell","embed-shell"],["BillingOverview","billing-overview-ui"],["ConfirmDialog","confirm-dialog-ui"],["DashboardLayout","dashboard-layout-ui"],["DateRangeSelector","date-range-selector-ui"],["FormPopover","form-popover-ui"],["IntegrationsPage","integrations-page-ui"],["InvoiceDetail","invoice-detail-ui"],["InvoiceHistory","invoice-history-ui"],["NotificationPreferences","notification-preferences-ui"],["OnboardingChecklist","onboarding-checklist-ui"],["PaymentMethodForm","payment-method-form-ui"],["PaymentMethodList","payment-method-list-ui"],["PlanPicker","plan-picker-ui"],["chat-thread-ui","chat-thread-ui"],["section-ui","section-ui"],["DescriptionTerm","dt"],["DescriptionDetail","dd"]])});function Gu(s){return!s||s==="/"}function ZO(s){return s.split("/").filter(Boolean)}function mA(s){return s.replace(/^\//,"").split("/")}function gA(s,t){return Gu(t)?s:ZO(t).reduce((e,i)=>e?.[i],s)}function OA(s,t,e){if(Gu(t))return;let i=ZO(t),n=s;for(let r=0;r<i.length-1;r++)n[i[r]]==null&&(n[i[r]]={}),n=n[i[r]];n[i[i.length-1]]=e}function NO(s,t){if(Gu(t))return s;let e=mA(t),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function bA(s,t,e){if(Gu(t))return;let i=mA(t),n=s;for(let r=0;r<i.length-1;r++){let o=i[r];n[o]==null&&(n[o]={}),n=n[o]}n[i[i.length-1]]=e}function yA(s,t){if(!t||!s)return;let e=ZO(t),i=s;for(let n of e){if(i==null||typeof i!="object")return;i=i[n]}return i}var Ku=W(()=>{"use strict"});var Ju,da,zO=W(()=>{"use strict";Ku();Ju={provider:0,controller:1,source:2,action:3,lifecycle:4},da=class{surfaceId;#t=new Map;#e={};#i={};#s=new Map;#n;#r;constructor(t,e,i){this.surfaceId=t,this.#n=e,this.#r=i}get context(){return{surfaceId:this.surfaceId,getElement:t=>this.#r.get(t)||null,getRootElement:()=>this.#n,getModel:t=>t?NO(this.#e,t):this.#e,setModel:(t,e)=>this.#o(t,e),getDockable:(t,e)=>this.#l(t,e),listDockables:t=>this.#c(t),emit:t=>this.#h(t),getParam:t=>this.#i[t],watchModel:(t,e)=>this.#a(t,e)}}dock(t){this.#t.has(t.id)&&this.undock(t.id);let e=t.dock(this.context);this.#t.set(t.id,{dockable:t,cleanup:typeof e=="function"?e:null})}dockAll(t){let e=[...t].sort((i,n)=>(Ju[i.kind]??9)-(Ju[n.kind]??9));for(let i of e)this.dock(i)}undock(t){let e=this.#t.get(t);e&&(e.cleanup?.(),e.dockable.undock(),this.#t.delete(t))}undockAll(){let t=[...this.#t.entries()].sort((e,i)=>(Ju[i[1].dockable.kind]??9)-(Ju[e[1].dockable.kind]??9));for(let[e]of t)this.undock(e)}undockMany(t){for(let e of t)this.undock(e)}setInitialModel(t){Object.assign(this.#e,t)}setParams(t){Object.assign(this.#i,t)}updateElements(t){this.#r=t}#o(t,e){bA(this.#e,t,e);for(let[i,n]of this.#s)if(t===i||t.startsWith(i+"/"))for(let r of n)r(NO(this.#e,i))}#a(t,e){return this.#s.has(t)||this.#s.set(t,new Set),this.#s.get(t).add(e),()=>{let i=this.#s.get(t);i?.delete(e),i?.size===0&&this.#s.delete(t)}}#l(t,e){let i=this.#t.get(e);return i&&i.dockable.kind===t?i.dockable:null}#c(t){let e=[];for(let{dockable:i}of this.#t.values())(!t||i.kind===t)&&e.push(i);return e}#h(t){let e=t.target?this.#r.get(t.target):this.#n;e&&e.dispatchEvent(new CustomEvent(t.event,{bubbles:!0,detail:t}))}}});var Se,an=W(()=>{"use strict";Se=class{get kind(){throw new Error("Dockable subclass must define kind")}get id(){throw new Error("Dockable subclass must define id")}dock(t){throw new Error("Dockable subclass must implement dock()")}undock(){}}});var fa,BO=W(()=>{"use strict";an();fa=class extends Se{kind="controller";id;type;hostId;config;bind;controller=null;#t;constructor(t,e){super(),this.id=t.id,this.type=t.type,this.hostId=t.host,this.config=t.config||{},this.bind=t.bind||null,this.#t=e}async dock(t){let e=t.getElement(this.hostId);if(!e){console.warn(`ControllerDock: host element "${this.hostId}" not found`);return}let i=await this.#t(this.type);if(!i){console.warn(`ControllerDock: unknown controller type "${this.type}"`);return}this.controller=new i(this.config),this.controller.connect(e);let n=[];if(this.bind)for(let[r,o]of Object.entries(this.bind)){if(this.controller.subscribe){let l=this.controller.subscribe(r,h=>{t.setModel(o,h)});l&&n.push(l)}let a=t.getModel(o);a!==void 0&&this.controller.setState&&this.controller.setState(r,a)}return e.controller=this.controller,()=>{e.controller=null,n.forEach(r=>r())}}undock(){this.controller&&(this.controller.disconnect?.(),this.controller=null)}}});var pa,VO=W(()=>{"use strict";an();pa=class extends Se{kind="source";id;uri;path;refresh;#t;#e=null;constructor(t,e){super(),this.id=t.id,this.uri=t.uri,this.path=t.path,this.refresh=t.refresh||"once",this.#t=e}dock(t){if(this.#e=t,this.#i(t),this.refresh==="on-focus"){let e=()=>this.#i(t);return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)}if(this.refresh.startsWith("interval:")){let e=parseInt(this.refresh.split(":")[1],10);if(e>0){let i=setInterval(()=>this.#i(t),e);return()=>clearInterval(i)}}if(this.refresh==="stream"){let e=this.#s(t);try{let i=new EventSource(e);return i.onmessage=n=>{try{t.setModel(this.path,JSON.parse(n.data))}catch{}},()=>i.close()}catch{console.warn(`DataSourceDock: stream failed for ${e}`)}}}undock(){this.#e=null}refetch(){this.#e&&this.#i(this.#e)}async#i(t){let e=this.#s(t);try{let i=await this.#t(e,t);i!==void 0&&t.setModel(this.path,i)}catch(i){console.warn(`DataSourceDock: fetch failed for ${e}`,i)}}#s(t){return this.uri.replace(/\{(\w+)\}/g,(e,i)=>t.getParam(i)??t.getModel("/"+i)??"")}}});var td,ma,_O=W(()=>{"use strict";an();td={press:"click",submit:"submit",input:"input",change:"change",select:"select",toggle:"change",dismiss:"close",navigate:"click",mount:"connectedCallback",unmount:"disconnectedCallback",focus:"focusin",blur:"focusout",drag:"dragstart",drop:"drop"},ma=class extends Se{kind="action";id;event;handler;config;onSuccess;onError;#t;constructor(t,e){super(),this.event=t.event,this.handler=t.handler,this.config=t.config||{},this.onSuccess=t.onSuccess||null,this.onError=t.onError||null,this.#t=e,this.id=`action:${this.event.event}:${this.event.target||"root"}:${this.handler}`}dock(t){let e=this.event.target?t.getElement(this.event.target):t.getRootElement();if(!e){console.warn(`ActionDock: target "${this.event.target}" not found`);return}let i=td[this.event.event]||this.event.event,n=this.#t(this.handler);if(!n){console.warn(`ActionDock: unknown handler "${this.handler}"`);return}let r=async o=>{if(this.event.condition){let a=t.getModel(this.event.condition.path);if("equals"in this.event.condition&&a!==this.event.condition.equals||"notEquals"in this.event.condition&&a===this.event.condition.notEquals||"exists"in this.event.condition&&this.event.condition.exists&&a==null)return}try{let a=await n(this.config,t,o);if(this.onSuccess)for(let l of this.onSuccess){let h=this.#t(l.handler);h&&await h(l.config||{},t,a)}}catch(a){if(this.onError)for(let l of this.onError){let h=this.#t(l.handler);h&&await h(l.config||{},t,a)}else console.error(`ActionDock: handler "${this.handler}" failed`,a)}};if(this.event.debounce>0){let o=r,a;r=(...l)=>{clearTimeout(a),a=setTimeout(()=>o(...l),this.event.debounce)}}if(this.event.throttle>0){let o=r,a=0;r=(...l)=>{let h=Date.now();h-a>=this.event.throttle&&(a=h,o(...l))}}return e.addEventListener(i,r),()=>e.removeEventListener(i,r)}undock(){}}});var ga,jO=W(()=>{"use strict";an();ga=class extends Se{kind="provider";id;hostId;value;constructor(t){super(),this.id=`provider:${t.name}`,this.hostId=t.host||null,this.value=t.value??null}dock(t){let e=this.hostId?t.getElement(this.hostId):t.getRootElement();if(!e){console.warn(`ProviderDock: host "${this.hostId}" not found`);return}let i=document.createElement("a2ui-provider");return i.setAttribute("name",this.id.replace("provider:","")),i.value=this.value,e.parentNode?.insertBefore(i,e),i.appendChild(e),()=>{i.parentNode&&(i.parentNode.insertBefore(e,i),i.remove())}}undock(){}}});var Oa,WO=W(()=>{"use strict";an();Oa=class extends Se{kind="lifecycle";id="lifecycle";onMount;onUnmount;onModelChange;#t;#e=null;constructor(t,e){super(),this.onMount=t.onMount||[],this.onUnmount=t.onUnmount||[],this.onModelChange=t.onModelChange||[],this.#t=e}dock(t){this.#e=t;for(let i of this.onMount)this.#i(i,t);let e=this.onModelChange.map(i=>{let n=()=>this.#i(i,t);if(i.debounce>0){let r=n,o;n=()=>{clearTimeout(o),o=setTimeout(r,i.debounce)}}return t.watchModel(i.path,n)});return()=>e.forEach(i=>i())}undock(){if(this.#e){for(let t of this.onUnmount)this.#i(t,this.#e);this.#e=null}}async#i(t,e){let i=this.#t(t.handler);if(i)try{await i(t.config||{},e)}catch(n){console.warn(`LifecycleDock: ${t.handler} failed`,n)}}}});var vA,we,ln=W(()=>{"use strict";vA=new WeakSet,we=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!vA.has(e)&&e!==s&&(vA.add(e),e.schema||console.warn(`AdiaUI: ${e.name} extends BaseController without static schema`),this.getState===s.prototype.getState&&console.error(`AdiaUI: ${e.schema?.name??e.name} must implement getState()`)),this.#t&&this.#t!==t&&console.warn(`AdiaUI: ${e.schema?.name??e.name} already connected to a different host`),this.#t=t,this.onConnect(t),this.reflect()}disconnect(t){let e=t??this.#t;e&&(this.onDisconnect(e),this.#t=null)}subscribe(t){return this.#e.add(t),()=>this.#e.delete(t)}notify(){this.reflect();for(let t of this.#e)t()}onConnect(t){}onDisconnect(t){}reflect(){}getState(){throw new Error(`${this.constructor.schema?.name??this.constructor.name}: getState() not implemented`)}}});var xA={};Jt(xA,{FormController:()=>FO});var FO,SA=W(()=>{"use strict";ln();FO=class extends we{static schema=Object.freeze({name:"form",state:{values:"object",errors:"object",dirty:"boolean",valid:"boolean"},commands:["set","validate","reset","setInitial"],attributes:["data-form-valid","data-form-invalid","data-form-dirty"]});#t={};#e={};#i={};#s={};constructor(t={}){super(),this.#t={...t},this.#e={...t}}onDisconnect(t){t.removeAttribute("data-form-valid"),t.removeAttribute("data-form-invalid"),t.removeAttribute("data-form-dirty")}getState(){let t=Object.keys(this.#e).some(i=>this.#e[i]!==this.#t[i]),e=Object.keys(this.#i).length===0;return{values:{...this.#e},errors:{...this.#i},dirty:t,valid:e}}reflect(){if(!this.host)return;let{dirty:t,valid:e}=this.getState();e?(this.host.setAttribute("data-form-valid",""),this.host.removeAttribute("data-form-invalid")):(this.host.setAttribute("data-form-invalid",""),this.host.removeAttribute("data-form-valid")),t?this.host.setAttribute("data-form-dirty",""):this.host.removeAttribute("data-form-dirty")}#n(t){let e=this.#s[t];if(!e){delete this.#i[t];return}let i=e(this.#e[t]);i===!0||i==null?delete this.#i[t]:this.#i[t]=typeof i=="string"?i:"Invalid"}commands={set:(t,e)=>{this.#e[t]=e,this.#n(t),this.notify()},validate:(t,e)=>{this.#s[t]=e,this.#n(t),this.notify()},reset:()=>{this.#e={...this.#t},this.#i={};for(let t of Object.keys(this.#s))this.#n(t);this.notify()},setInitial:t=>{this.#t={...t}}}}});var wA={};Jt(wA,{DataStreamController:()=>UO});var UO,kA=W(()=>{"use strict";ln();UO=class extends we{static schema=Object.freeze({name:"data-stream",state:{data:"array",status:"string",error:"string"},commands:["push","pushMany","connect","poll","consume","stop","clear"],attributes:["data-stream-status"]});#t=[];#e;#i="idle";#s=null;#n=null;#r=0;#o=1;#a=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:n=[]}={}){super(),this.#e=t,this.#r=e,this.#o=Math.max(1,Math.round(i)),this.#t=n.slice(-t)}getState(){return{data:this.#t,status:this.#i,error:this.#s}}reflect(){this.host&&this.host.setAttribute("data-stream-status",this.#i)}onDisconnect(){this.commands.stop()}#c(t){this.#l++,!(this.#o>1&&this.#l%this.#o!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u())}#h(t){if(this.#o>1){let e=[];for(let i of t)this.#l++,this.#l%this.#o===0&&e.push(i);this.#t.push(...e)}else this.#t.push(...t);this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u()}#u(){if(this.#r<=0){this.notify();return}this.#a===null&&(this.#a=setTimeout(()=>{this.#a=null,this.notify()},this.#r))}#d(t,e=null){this.#i=t,this.#s=e,this.notify()}commands={push:t=>{this.#c(t)},pushMany:t=>{this.#h(t)},connect:(t,e)=>{this.commands.stop(),this.#n=new AbortController,t==="sse"?this.#f(e):t==="ws"?this.#p(e):this.#d("error",`Unknown stream type: ${t}`)},poll:(t,e=2e3)=>{this.commands.stop(),this.#n=new AbortController,this.#m(t,e)},consume:t=>{this.commands.stop(),this.#n=new AbortController,this.#g(t)},stop:()=>{this.#n&&(this.#n.abort(),this.#n=null),this.#a!==null&&(clearTimeout(this.#a),this.#a=null),(this.#i==="streaming"||this.#i==="connecting")&&this.#d("stopped")},clear:()=>{this.#t=[],this.notify()}};#f(t){this.#d("connecting");let e=new EventSource(t),i=this.#n.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=n=>{try{let r=JSON.parse(n.data);this.#c(r)}catch{}},e.onerror=()=>{i.aborted||(this.#d("error","SSE connection lost"),e.close())}}#p(t){this.#d("connecting");let e=new WebSocket(t),i=this.#n.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=n=>{try{let r=JSON.parse(n.data);Array.isArray(r)?this.#h(r):this.#c(r)}catch{}},e.onerror=()=>{i.aborted||this.#d("error","WebSocket error")},e.onclose=()=>{i.aborted||this.#d("stopped")}}async#m(t,e){this.#d("streaming");let i=this.#n.signal;for(;!i.aborted;){try{let r=await(await fetch(t,{signal:i})).json();Array.isArray(r)?this.#h(r):this.#c(r)}catch(n){if(i.aborted)break;this.#d("error",n.message);break}await new Promise(n=>setTimeout(n,e))}}async#g(t){this.#d("streaming");let e=this.#n.signal;try{for await(let i of t){if(e.aborted)break;Array.isArray(i)?this.#h(i):this.#c(i)}e.aborted||this.#d("idle")}catch(i){e.aborted||this.#d("error",i.message)}}}});var AA={};Jt(AA,{SelectionController:()=>YO});var YO,$A=W(()=>{"use strict";ln();YO=class extends we{static schema=Object.freeze({name:"selection",state:{selected:"Set",multiple:"boolean"},commands:["select","deselect","toggle","clear","selectAll"],attributes:["data-selection-active","data-selection-selected"]});#t=new Set;#e=!1;constructor({multiple:t=!1,initial:e=[]}={}){super(),this.#e=t;for(let i of e)this.#t.add(String(i))}onConnect(t){t.setAttribute("data-selection-active","")}onDisconnect(t){this.#i(t),t.removeAttribute("data-selection-active")}getState(){return{selected:new Set(this.#t),multiple:this.#e}}reflect(){if(!this.host)return;let t=this.host.querySelectorAll("[data-selection-key]");for(let e of t){let i=e.getAttribute("data-selection-key");this.#t.has(i)?e.setAttribute("data-selection-selected",""):e.removeAttribute("data-selection-selected")}}#i(t){let e=t.querySelectorAll("[data-selection-selected]");for(let i of e)i.removeAttribute("data-selection-selected")}commands={select:t=>{t=String(t),this.#e||this.#t.clear(),this.#t.add(t),this.notify()},deselect:t=>{this.#t.delete(String(t)),this.notify()},toggle:t=>{t=String(t),this.#t.has(t)?this.#t.delete(t):(this.#e||this.#t.clear(),this.#t.add(t)),this.notify()},clear:()=>{this.#t.clear(),this.notify()},selectAll:t=>{if(this.#e){for(let e of t)this.#t.add(String(e));this.notify()}}}}});var CA={};Jt(CA,{ToggleController:()=>HO});var HO,EA=W(()=>{"use strict";ln();HO=class extends we{static schema=Object.freeze({name:"toggle",state:{on:"boolean"},commands:["toggle","set"],attributes:["data-toggle-on"]});#t=!1;constructor(t=!1){super(),this.#t=t}getState(){return{on:this.#t}}onDisconnect(t){t.removeAttribute("data-toggle-on")}reflect(){this.host&&(this.#t?this.host.setAttribute("data-toggle-on",""):this.host.removeAttribute("data-toggle-on"))}commands={toggle:()=>{this.#t=!this.#t,this.notify()},set:t=>{this.#t=!!t,this.notify()}}}});var PA={};Jt(PA,{AccordionController:()=>GO});var GO,QA=W(()=>{"use strict";ln();GO=class extends we{static schema=Object.freeze({name:"accordion",state:{expanded:"Set",multiple:"boolean"},commands:["toggle","expand","collapse","collapseAll","expandAll"],attributes:["data-accordion-expanded"]});#t=new Set;#e=!1;constructor({multiple:t=!1,initial:e=[]}={}){super(),this.#e=t;for(let i of e)this.#t.add(String(i))}onDisconnect(t){let e=t.querySelectorAll("[data-accordion-expanded]");for(let i of e)i.removeAttribute("data-accordion-expanded")}getState(){return{expanded:new Set(this.#t),multiple:this.#e}}reflect(){if(!this.host)return;let t=this.host.querySelectorAll("[data-accordion-key]");for(let e of t){let i=e.getAttribute("data-accordion-key");this.#t.has(i)?e.setAttribute("data-accordion-expanded",""):e.removeAttribute("data-accordion-expanded")}}commands={toggle:t=>{t=String(t),this.#t.has(t)?this.#t.delete(t):(this.#e||this.#t.clear(),this.#t.add(t)),this.notify()},expand:t=>{t=String(t),this.#e||this.#t.clear(),this.#t.add(t),this.notify()},collapse:t=>{this.#t.delete(String(t)),this.notify()},collapseAll:()=>{this.#t.clear(),this.notify()},expandAll:t=>{if(this.#e){for(let e of t)this.#t.add(String(e));this.notify()}}}}});var TA={};Jt(TA,{StateMachineController:()=>KO});var KO,LA=W(()=>{"use strict";ln();KO=class extends we{static schema={name:"state-machine",state:{current:"string",history:"string[]"},commands:["send","transition","reset"],attributes:["data-state"],config:{initial:"string",states:"object"}};#t="";#e="";#i={};#s=[];onConnect(t){let e=this.config||{};this.#e=e.initial||t.dataset?.initial||Object.keys(e.states||{})[0]||"",this.#i=this._validateStates(e.states||{}),this.#t=this.#e,this.#s=this.#t?[this.#t]:[],this.#t&&this._emit("stateEntered",{state:this.#t,initial:!0})}getState(){return{current:this.#t,history:[...this.#s]}}reflect(){this.host&&(this.#t?this.host.setAttribute("data-state",this.#t):this.host.removeAttribute("data-state"))}commands={send:t=>{if(!t||!this.#t)return;let i=(this.#i[this.#t]?.on||{})[t];i&&this._moveTo(i,{event:t})},transition:t=>{!t||!(t in this.#i)||this._moveTo(t,{forced:!0})},reset:()=>{this.#e&&this._moveTo(this.#e,{reset:!0})}};_moveTo(t,e){if(t===this.#t)return;let i=this.#t;i&&this._emit("stateExited",{state:i,target:t,...e}),this.#t=t,this.#s.push(t),this.notify(),this._emit("stateEntered",{state:t,from:i,...e})}_emit(t,e){this.host&&this.host.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}_validateStates(t){let e={},i=Object.keys(t);for(let n of i){let r=t[n]||{},o={};for(let[a,l]of Object.entries(r.on||{})){if(typeof l!="string"||!(l in t)){console.warn(`[state-machine] state "${n}" transition "${a}" \u2192 "${l}" \u2014 target not declared`);continue}o[a]=l}e[n]={on:o}}return e}}});function MA(s,t){Vi.controllers.set(s,t)}function RA(s,t){Vi.handlers.set(s,t)}function IA(s,t){Vi.resolvers.set(s,t)}async function ed(s){let t=Vi.controllers.get(s);return t?t():null}function id(s){return Vi.handlers.get(s)||null}async function Hl(s,t={}){let e=s;for(let[o,a]of Object.entries(t))e=e.replace(`{${o}}`,encodeURIComponent(a));let i=e.indexOf("://");if(i===-1)throw new Error(`Invalid URI: ${s}`);let n=e.slice(0,i),r=Vi.resolvers.get(n);if(!r)throw new Error(`No resolver for scheme "${n}"`);return r(e,t)}async function i5(s){let{action:t,params:e}=s,i=JO(t.body,s),n=t.uri;for(let[c,u]of Object.entries(e))n=n.replace(`{${c}}`,encodeURIComponent(u));let r=n.indexOf("://"),o=r>-1?n.slice(0,r):"api",a=Vi.resolvers.get(o),l=n.replace(/^\w+:\/\//,"/api/"),h=await fetch(l,{method:t.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!h.ok){let c=await h.text().catch(()=>"Request failed");throw new Error(c)}return h.json().catch(()=>({}))}async function s5(s){let{action:t}=s,e=JO(t.value,s);s.updateModel(t.path,e)}async function n5(s){let{action:t,params:e}=s,i=t.navigate||t.path||"";for(let[n,r]of Object.entries(e))i=i.replace(`{${n}}`,encodeURIComponent(r));i==="back"?history.back():i&&(location.hash=i)}async function r5(){history.back()}async function o5(s){let{action:t,controllers:e}=s,i=e[t.controllerId];if(!i?.commands?.[t.command]){console.warn(`Wiring: controller "${t.controllerId}" or command "${t.command}" not found`);return}return i.commands[t.command](t.args)}async function a5(s){let{action:t,source:e}=s,i=JO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function l5(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function h5(s){let{action:t}=s,e=typeof t=="string"?t:t.message||t.notify;document.dispatchEvent(new CustomEvent("a2ui-notify",{bubbles:!0,detail:{message:e,variant:t.variant||"info"}}))}function JO(s,t){if(s){if(typeof s!="object")return s;switch(s.from){case"event-detail":return s.key?t.event?.detail?.[s.key]:t.event?.detail;case"event-target":return s.key?t.source?.[s.key]:t.source?.value;case"model":return yA(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}async function c5(s,t){let e=s.replace(/^resource:\/\//,"/api/"),i=await fetch(e);if(!i.ok)throw new Error(`Resource fetch failed: ${i.status}`);return i.json()}async function u5(s,t){let e=s.replace(/^api:\/\//,"https://"),i=await fetch(e);if(!i.ok)throw new Error(`API fetch failed: ${i.status}`);return i.json()}async function d5(s,t){return{_source:s,_mock:!0}}var Vi,tb=W(()=>{"use strict";Ku();Vi={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(SA(),xA))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(kA(),wA))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>($A(),AA))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(EA(),CA))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(QA(),PA))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(LA(),TA))).StateMachineController]]),handlers:new Map([["submit-resource",i5],["update-model",s5],["navigate",n5],["navigate-back",r5],["controller-command",o5],["emit-event",a5],["refresh-source",l5],["notify",h5]]),resolvers:new Map([["resource",c5],["api",u5],["mock",d5]])}});function f5(s){return async(t,e,i)=>{let n={action:t,event:i instanceof Event?i:null,source:i instanceof Event?i.target:null,dataModel:e.getModel(),updateModel:(r,o)=>e.setModel(r,o),controllers:Object.fromEntries(e.listDockables("controller").map(r=>[r.id,r.controller])),params:{},resolveData:Hl};return s(n)}}function p5(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=id(t);if(!e)return null;let i=f5(e);return s.set(t,i),i}}function m5(){return async s=>ed(s)}function g5(){return async(s,t)=>Hl(s,{})}function sd(s){let t=[],e=p5(),i=m5(),n=g5();if(s.data?.sources)for(let o of s.data.sources)t.push(new pa(o,n));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new fa(o,i));if(s.actions)for(let o of s.actions)t.push(new ma(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new ga(a))}s.lifecycle&&t.push(new Oa(s.lifecycle,e));let r=s.state?.model||null;return{dockables:t,initialModel:r}}var eb=W(()=>{"use strict";BO();VO();_O();jO();WO();tb()});var DA={};Jt(DA,{WiringEngine:()=>Gl});var Gl,ib=W(()=>{"use strict";zO();eb();Gl=class{#t=new Map;#e;#i;constructor({updateDataModel:t,getElement:e}){this.#e=t,this.#i=e}async process(t){let{surfaceId:e}=t;if(!e)return;let i=this.#t.get(e);i||(i=this.#s(e),this.#t.set(e,i));try{t.data?.params&&i.setParams(this.#n(t.data.params));let{dockables:n,initialModel:r}=sd(t);r&&i.setInitialModel(r),t.undock&&i.undockMany(t.undock);for(let o of n)await i.dock(o)}catch(n){console.warn(`Wiring: error processing wireComponents for "${e}":`,n.message)}}teardown(t){let e=this.#t.get(t);e&&(e.undockAll(),this.#t.delete(t))}undockIds(t,e){let i=this.#t.get(t);i&&i.undockMany(e)}teardownAll(){for(let t of this.#t.keys())this.teardown(t)}getSurface(t){return this.#t.get(t)||null}getSurfaceState(t){let e=this.#t.get(t);if(!e)return null;let i=e.context.listDockables();return{surfaceId:t,controllerCount:i.filter(n=>n.kind==="controller").length,sourceCount:i.filter(n=>n.kind==="source").length,actionCount:i.filter(n=>n.kind==="action").length,providerCount:i.filter(n=>n.kind==="provider").length,hasLifecycle:i.some(n=>n.kind==="lifecycle"),totalDocked:i.length}}#s(t){let e={get:h=>this.#i(t,h),has:h=>!!this.#i(t,h)},i=this.#i(t,"root")||document.createElement("div"),n=new Proxy(new Map,{get(h,c){return c==="get"?u=>e.get(u):c==="has"?u=>e.has(u):h[c]}}),r=new da(t,i,n),o=r.context,a=o.setModel,l=this.#e;return Object.defineProperty(r,"context",{get(){return{...o,setModel(c,u){a(c,u),l(t,c,u)}}}}),r}#n(t){let e={};for(let[i,n]of Object.entries(t))switch(n.from){case"route":{let o=location.hash.slice(1).match(new RegExp(`${n.key}/([^/]+)`));o&&(e[i]=o[1]);break}case"query":{let o=new URL(location.href).searchParams.get(n.key);o&&(e[i]=o);break}case"literal":e[i]=n.value;break;default:typeof n=="string"&&(e[i]=n)}return e}}});function fs(s){return y5.has(s.toLowerCase())?s.toLowerCase():s.replace(/([A-Z])/g,"-$1").toLowerCase()}function nd(s,t,e){if(t==="style"&&typeof e=="string"){s.style.cssText=e;return}if(O5.has(t)&&e!=null){if(t==="textContent"&&!b5.has(s.localName)){s.setAttribute("text",String(e));return}let i=e;if(typeof i=="string"&&(i.startsWith("[")||i.startsWith("{")))try{i=JSON.parse(i)}catch{}s[t]=i;return}if(typeof e=="boolean"){e?s.setAttribute(fs(t),""):s.removeAttribute(fs(t));return}e!=null?s.setAttribute(fs(t),String(e)):s.removeAttribute(fs(t))}var O5,b5,y5,sb=W(()=>{"use strict";O5=new Set(["data","columns","options","itemRenderer","textContent","pageSizeOptions"]),b5=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui","kbd-ui"]),y5=new Set(["autocomplete","autofocus","autocapitalize","autocorrect","inputmode","enterkeyhint","spellcheck","maxlength","minlength","readonly","novalidate","formnovalidate","formaction","formenctype","formmethod","formtarget","multiple","pattern","placeholder","required","tabindex","accesskey","autoplay","autopictureinpicture","controls","crossorigin","disablepictureinpicture","disableremoteplayback","loop","muted","playsinline","preload","srcset","srcdoc","srclang","sizes","loading","decoding","fetchpriority","ismap","usemap","hreflang","referrerpolicy","download","contenteditable","contextmenu","draggable","dirname","colspan","rowspan","headers","allowfullscreen","allowpaymentrequest","itemid","itemprop","itemref","itemscope","itemtype","nomodule","nonce"])});var ps,XA=W(()=>{"use strict";qO();sb();Ku();ps=class s{#t;#e;#i=new Map;#s=new Map;#n=new Map;#r=[];#o=null;#a=!1;constructor(t,e=zt,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#a=i}process(t){t&&(this.#a?(this.#r.push(t),this.#o===null&&(this.#o=requestAnimationFrame(()=>this.#l()))):this.#h(t))}#l(){this.#o=null;let t=this.#r.splice(0);for(let e of t)try{this.#h(e)}catch(i){console.error("A2UI: message failed during batch flush",i),this.#z(null,"a2ui-message-error",{error:i,messageType:e?.type||e?.messageType})}}static#c=new Set(["updateComponents","updateDataModel","wireComponents","updateStyles","removeStyles"]);#h(t){let e=t.type||t.messageType,i=t.surfaceId;if(i&&s.#c.has(e)){let n=this.#i.get(i);if(n&&!n.synthetic&&this.#d(n)){n.lifecycle.buffer.push(t);return}}this.#u(t)}#u(t){switch(t.type||t.messageType){case"createSurface":this.#m(t);return;case"updateComponents":this.#g(t);return;case"updateDataModel":this.#k(t);return;case"wireComponents":return this.#p(t);case"deleteSurface":this.#v(t);return;case"updateStyles":this.#L(t);return;case"removeStyles":this.#X(t);return;case"meta":return;default:console.warn("A2UI: unknown message type",t.type);return}}#d(t){return t.lifecycle.state==="pending-first"||t.lifecycle.state==="pending-stale"}#f=null;async#p(t){if(!this.#f){let{WiringEngine:e}=await Promise.resolve().then(()=>(ib(),DA));this.#f=new e({updateDataModel:(i,n,r)=>{this.#k({surfaceId:i,path:n,value:r})},getElement:(i,n)=>this.#i.get(i)?.elements.get(n)||null})}await this.#f.process(t)}async processStream(t){for await(let e of t)this.process(e)}#m({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t)){let r=this.#i.get(t);this.#z(r.root,"a2ui-duplicate-surface-id",{surfaceId:t});let o=new Error(`A2UI: duplicate createSurface for surfaceId "${t}" \u2014 REQ-002 (spec-a2ui-v1-conformance.md) makes this a hard error. Regenerate an existing surface with renderer.beginSurfaceUpdate(surfaceId) \u2192 applyTo \u2192 commitSurfaceUpdate instead (spec-a2ui-surface-lifecycle.md).`);throw o.code="DUPLICATE_SURFACE_ID",o.surfaceId=t,o}let n=document.createElement("div");n.setAttribute("data-a2ui-surface",t),e&&n.setAttribute("data-catalog",e),this.#t.appendChild(n),this.#i.set(t,{root:n,rootId:typeof i=="string"&&i?i:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets:new Map,synthetic:!1,lifecycle:{state:"empty",generationId:null,buffer:null,mode:"replace",reason:null,hadError:!1}})}#g({surfaceId:t,components:e}){let i=this.#i.get(t);i||(i={root:this.#t,rootId:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets:new Map,synthetic:!0,lifecycle:null},this.#i.set(t,i),this.#t&&typeof this.#t.setAttribute=="function"&&this.#t.setAttribute("data-a2ui-surface",t));for(let l of e)if(!(!l.id&&l.id!==0)){if(l.component==="ContextBindings"){i.contextBindings=l;continue}try{let h=i.elements.get(l.id),c=l.component==="Text"?this.#A(l.variant,l):Hu(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-id",l.id),h.id=l.id,h.setAttribute("data-a2ui-unknown",l.component),h.textContent=`[unknown: ${l.component}]`,i.elements.set(l.id,h),this.#s.set(l.id,h));continue}if(!h)h=document.createElement(c),h.setAttribute("data-a2ui-id",l.id),h.id=l.id,i.elements.set(l.id,h),this.#s.set(l.id,h);else if(h.localName!==c){let d=document.createElement(c);d.setAttribute("data-a2ui-id",l.id),d.id=l.id,h.replaceWith(d),h=d,i.elements.set(l.id,h),this.#s.set(l.id,h)}l._surfaceId=t,Object.values(l).some(d=>d&&typeof d=="object"&&d.path)&&i.bindings.set(l.id,l),this.#E(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#w(e);let n=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])n.set(h,l.id);l.child&&n.set(l.child,l.id)}let r=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=n.get(u)}return!1};for(let l of e){let h=i.elements.get(l.id);if(h)try{let c=Array.isArray(l.children)?l.children:[];for(let u of c){if(u===l.id||r(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!r(l.id,l.child)){let u=i.elements.get(l.child);u&&u.parentElement!==h&&h.appendChild(u)}}catch(c){console.warn(`A2UI: tree build failed for "${l.id}":`,c.message)}}let o=i.rootId??"root";if(e.find(l=>l.id===o)){let l=i.elements.get(o);l&&l.parentElement!==i.root&&i.root.appendChild(l)}}static#O=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#S=new Set(["Header","Section","Footer"]);static#b=new Set(["header","body","footer"]);#x=new Set;#w(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let n=i.component==="Card"||i.component==="ErrorContainer",r=i.component==="Drawer";if(!n&&!r)continue;let o=r?s.#S:s.#O,a=r?"<drawer-ui>":"<card-ui>",l=Array.isArray(i.children)?i.children:[];for(let h of l){let c=e.get(h);if(!c||typeof c.slot=="string"&&s.#b.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#x.has(u)||(this.#x.add(u),console.warn(`A2UI: ${a} (id="${i.id}") body must wrap "${c.component}" (id="${h}") in <Section>. Direct flow children bypass the canonical body slot and lose --card-inset margin. Canonical children: ${[...o].join(", ")}`+(r?', or slot="header|body|footer".':".")))}}}static#y={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};#A(t,e){return!e?.slot&&s.#y[t]?s.#y[t]:"text-ui"}#E(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#y[e.variant]&&i.add("variant");let n=this.#n.get(e.id),r={};for(let[o,a]of Object.entries(e)){if(i.has(o))continue;let l=a&&typeof a=="object"&&a.path,h=this.#P(a,e._surfaceId);r[o]=h,!(n&&Object.is(n[o],h))&&(h==null&&!l||nd(t,o,h))}if(n)for(let o of Object.keys(n))!(o in r)&&!i.has(o)&&t.removeAttribute(fs(o));this.#n.set(e.id,r)}#P(t,e){if(t==null)return null;if(typeof t!="object")return t;if(t.path){let i=e?this.#i.get(e):null;return i?gA(i.dataModel,t.path):t.path}return t}#k({surfaceId:t,path:e,value:i}){let n=this.#i.get(t);if(n){!e||e==="/"?n.dataModel=i??{}:OA(n.dataModel,e,i);for(let[r,o]of n.bindings){let a=n.elements.get(r);a&&this.#E(a,o)}}}#v({surfaceId:t}){let e=this.#i.get(t);if(e){this.#f?.teardown(t);for(let[i]of e.elements)this.#s.delete(i);if(e.adoptedSheets&&e.adoptedSheets.size>0){let i=new Set;for(let n of e.adoptedSheets.values())i.add(n.sheet);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(n=>!i.has(n)),e.adoptedSheets.clear()}e.root.remove(),this.#i.delete(t)}}#$=0;#T(){return this.#$+=1,`g${this.#$}-${Date.now().toString(36)}`}#C(t,e){t.root?.setAttribute?.("data-a2ui-lifecycle",e)}#M(t,e,i){let n=t||this.#t;if(!(!n||typeof CustomEvent>"u"))try{n.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!1}))}catch{}}beginSurfaceUpdate(t,{generationId:e,reason:i=null,mode:n="replace"}={}){let r=this.#i.get(t);if(!r)return console.warn(`A2UI: beginSurfaceUpdate \u2014 no such surface "${t}"`),null;if(r.synthetic)return console.warn(`A2UI: beginSurfaceUpdate \u2014 surfaceId "${t}" is synthetic (no prior createSurface); lifecycle is a no-op here. Send createSurface first.`),null;let o=r.lifecycle,a=o.state==="error-empty"||o.state==="error-stale",h=o.state==="live"||o.state==="error-stale"?"pending-stale":"pending-first";return o.state=h,o.generationId=typeof e=="string"&&e?e:this.#T(),o.buffer=[],o.mode=n==="patch"?"patch":"replace",o.reason=i,o.hadError=a,this.#C(r,h),this.#M(r.root,"surface-pending",{surfaceId:t,generationId:o.generationId,reason:i,firstRender:h==="pending-first"}),o.generationId}applyTo(t,e){let i=Array.isArray(e)?e:[e];for(let n of i)this.#h({...n,surfaceId:t})}async commitSurfaceUpdate(t,e){let i=this.#i.get(t);if(!i||i.synthetic)return console.warn(`A2UI: commitSurfaceUpdate \u2014 no such lifecycle surface "${t}"`),!1;let n=i.lifecycle;if(!this.#d(i))return console.warn(`A2UI: commitSurfaceUpdate \u2014 surface "${t}" has no in-flight generation to commit`),!1;if(e!=null&&e!==n.generationId)return!1;let r=n.buffer||[],o=n.generationId,a=n.hadError,l=[],h=[];if(n.mode==="replace"){let c=new Set,u=!1,d=new Set,f=!1;for(let p of r){let m=p.type||p.messageType;if(m==="updateComponents"){u=!0;for(let g of p.components||[])g.id!=null&&c.add(g.id)}else m==="updateStyles"&&(f=!0,typeof p.styleId=="string"&&d.add(p.styleId))}for(let p of r)await this.#u(p);u&&(l=this.#R(t,c)),f&&(h=this.#Q(t,d))}else for(let c of r)await this.#u(c);return n.state="live",n.buffer=null,n.generationId=null,n.reason=null,n.hadError=!1,this.#C(i,"live"),this.#M(i.root,"surface-committed",{surfaceId:t,generationId:o,healed:a,swept:l,stylesSwept:h}),!0}#Q(t,e){let i=this.#i.get(t);if(!i||!i.adoptedSheets||i.adoptedSheets.size===0)return[];let n=[];for(let r of[...i.adoptedSheets.keys()]){if(e.has(r))continue;let o=i.adoptedSheets.get(r);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet),i.adoptedSheets.delete(r),this.#D(i.root,"styles-removed",{surfaceId:t,styleId:r}),n.push(r)}return n}#R(t,e){let i=this.#i.get(t);if(!i)return[];let n=[];for(let r of[...i.elements.keys()]){if(e.has(r))continue;i.elements.get(r)?.remove(),i.elements.delete(r),this.#s.delete(r),i.bindings.delete(r),this.#n.delete(r),n.push(r)}return n.length>0&&this.#f?.undockIds(t,n),n}abortSurfaceUpdate(t,e,i){let n=this.#i.get(t);if(!n||n.synthetic)return console.warn(`A2UI: abortSurfaceUpdate \u2014 no such lifecycle surface "${t}"`),!1;let r=n.lifecycle;if(!this.#d(n))return console.warn(`A2UI: abortSurfaceUpdate \u2014 surface "${t}" has no in-flight generation to abort`),!1;if(e!=null&&e!==r.generationId)return!1;let o=r.generationId,a=r.state==="pending-first"?"error-empty":"error-stale";return r.state=a,r.buffer=null,r.generationId=null,r.reason=null,r.hadError=!0,this.#C(n,a),this.#M(n.root,"surface-aborted",{surfaceId:t,generationId:o,error:i??null}),!0}getLifecycle(t){let e=this.#i.get(t);return e&&!e.synthetic?e.lifecycle:null}isPending(t){let e=this.getLifecycle(t);return e?.state==="pending-first"||e?.state==="pending-stale"}get pendingSurfaces(){let t=[];for(let[e,i]of this.#i)!i.synthetic&&this.#d(i)&&t.push(e);return t}static#I=new Set(["root","html","body"]);#L({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#D(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#D(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: css must be a string"});return}let n=this.#i.get(t);if(!n){this.#D(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let r=this.#N(i,t);if(r.rejected){this.#D(n.root,"styles-rejected",{surfaceId:t,styleId:e,reason:r.reason});return}let o=n.adoptedSheets.get(e);o&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet)),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r.sheet],n.adoptedSheets.set(e,{sheet:r.sheet,ruleCount:r.sheet.cssRules.length,appliedAt:typeof performance<"u"?performance.now():Date.now()}),this.#D(n.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:r.sheet.cssRules.length,validationWarnings:r.warnings})}#X({surfaceId:t,styleId:e}){let i=this.#i.get(t);if(!i)return;let n=i.adoptedSheets.get(e);n&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>r!==n.sheet),i.adoptedSheets.delete(e),this.#D(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#N(t,e){let i=[];if(/^\s*@import\b/im.test(t))return{rejected:!0,reason:"forbidden-import"};if(/^\s*@charset\b/im.test(t))return{rejected:!0,reason:"forbidden-charset"};let n=new CSSStyleSheet;try{n.replaceSync(t)}catch(l){return{rejected:!0,reason:"parse-error: "+(l?.message||String(l))}}for(let l of n.cssRules){let h=this.#Z(l);if(h)return{rejected:!0,reason:h}}if(/url\s*\(\s*["']?\s*(?:https?:|\/\/)/i.test(t))return{rejected:!0,reason:"external-url"};for(let l of n.cssRules)if(l.constructor?.name==="CSSPropertyRule"||l.cssText?.startsWith("@property")){let h=l.cssText.match(/@property\s+(--[\w-]+)/);h&&i.push({kind:"property-registered-globally",name:h[1]})}let r=this.#q(n,e),o=this.#F(n,e),a=new CSSStyleSheet;try{a.replaceSync(o)}catch(l){return{rejected:!0,reason:"scope-wrap-failed: "+(l?.message||String(l))}}return r.length>0&&i.push({kind:"animations-namespaced",count:r.length}),{rejected:!1,sheet:a,warnings:i}}#Z(t){let e=t.cssText||"";if(/^@import\b/i.test(e))return"forbidden-import";if(/^@charset\b/i.test(e))return"forbidden-charset";if(/^@scope\b/i.test(e))return"forbidden-scope-directive";if(t.selectorText){let i=this.#B(t.selectorText);for(let n of i){let r=n.trim().replace(/^:scope\s*/,"");if(r.startsWith(":root"))return"forbidden-root-selector";let o=r.match(/^([a-zA-Z*][\w-]*)/);if(!o)continue;let a=o[1].toLowerCase();if(s.#I.has(a))return`forbidden-${a}-selector`}}return null}#B(t){let e=[],i=0,n=0;for(let r=0;r<t.length;r++){let o=t[r];o==="("?i++:o===")"?i--:o===","&&i===0&&(e.push(t.slice(n,r)),n=r+1)}return e.push(t.slice(n)),e}#q(t,e){let i=[],n=String(e).replace(/[^a-zA-Z0-9_-]/g,"_");for(let o=0;o<t.cssRules.length;o++){let a=t.cssRules[o];if(a.constructor?.name==="CSSKeyframesRule"||a.cssText?.startsWith("@keyframes")){let l=a.name;if(!l)continue;let h=`${n}_${l}`;try{a.name=h}catch{let c=a.cssText.replace(/@keyframes\s+[\w-]+/,`@keyframes ${h}`);t.deleteRule(o),t.insertRule(c,o)}i.push({from:l,to:h})}}if(i.length===0)return i;let r=new Map(i.map(o=>[o.from,o.to]));for(let o of t.cssRules)if(o.style)for(let a of["animation","animation-name"]){let l=o.style.getPropertyValue(a);if(!l)continue;let h=l.replace(/\b([\w-]+)\b/g,c=>r.has(c)?r.get(c):c);h!==l&&o.style.setProperty(a,h)}return i}#F(t,e){let i=[];for(let r of t.cssRules)i.push(r.cssText);return`@scope ([data-a2ui-surface="${String(e).replace(/"/g,'\\"')}"]) {
42
42
  ${i.join(`
43
43
  `)}
44
44
  }`}#D(t,e,i){let n=t||this.#t;if(!(!n||typeof CustomEvent>"u"))try{n.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!1}))}catch{}}#z(t,e,i){let n=t||this.#t;if(!(!n||typeof CustomEvent>"u"))try{n.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!1}))}catch{}}getSurface(t){return this.#i.get(t)}getElement(t){return this.#s.get(t)}get surfaces(){return[...this.#i.keys()]}getStylesheets(t){return this.#i.get(t)?.adoptedSheets??new Map}reset(){this.#o!==null&&(cancelAnimationFrame(this.#o),this.#o=null),this.#r.length=0;let t=new Set;for(let[,e]of this.#i)if(e.adoptedSheets)for(let i of e.adoptedSheets.values())t.add(i.sheet);t.size>0&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>!t.has(e)));for(let[,e]of this.#i)e.root===this.#t?e.root.innerHTML="":e.root.remove();this.#i.clear(),this.#s.clear(),this.#n.clear()}set batching(t){this.#a=!!t}get batching(){return this.#a}}});function rd(s,t={}){let e=s;if(t.catalog){let i=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog),n=s.includes("?")?"&":"?";e=`${s}${n}a2ui_catalog=${encodeURIComponent(i.join(","))}`}return{[Symbol.asyncIterator](){let i=new EventSource(e),n=[],r=null,o=!1;return i.onmessage=a=>{try{let l=JSON.parse(a.data);if(r){let h=r;r=null,h({value:l,done:!1})}else n.push(l)}catch{console.warn("A2UI SSE: invalid JSON",a.data)}},i.onerror=()=>{if(o=!0,i.close(),r){let a=r;r=null,a({value:void 0,done:!0})}},t.signal&&t.signal.addEventListener("abort",()=>{if(o=!0,i.close(),r){let a=r;r=null,a({value:void 0,done:!0})}}),{next(){return n.length>0?Promise.resolve({value:n.shift(),done:!1}):o?Promise.resolve({value:void 0,done:!0}):new Promise(a=>{r=a})},return(){return o=!0,i.close(),Promise.resolve({value:void 0,done:!0})}}}}}function od(s,t={}){return{[Symbol.asyncIterator](){let e=new WebSocket(s),i=[],n=null,r=!1;return e.onopen=()=>{if(t.catalog){let o=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog);e.send(JSON.stringify({type:"a2ui:catalog",supportedTypes:o}))}},e.onmessage=o=>{try{let a=JSON.parse(o.data);if(n){let l=n;n=null,l({value:a,done:!1})}else i.push(a)}catch{console.warn("A2UI WS: invalid JSON",o.data)}},e.onclose=()=>{if(r=!0,n){let o=n;n=null,o({value:void 0,done:!0})}},e.onerror=()=>{r=!0,e.close()},{next(){return i.length>0?Promise.resolve({value:i.shift(),done:!1}):r?Promise.resolve({value:void 0,done:!0}):new Promise(o=>{n=o})},return(){return r=!0,e.close(),Promise.resolve({value:void 0,done:!0})}}}}}function NA(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function ad(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?v5(s,t):ZA(s,t)}function qA(s,t){if(s.result?.content){for(let e of s.result.content)if(e.type==="resource"&&(e.resource?.mimeType==="application/a2ui+json"||e.resource?.mimeType==="application/json+a2ui"))try{let i=JSON.parse(e.resource.text);for(let n of Array.isArray(i)?i:[i])t(n)}catch{}else if(e.type==="text")try{let i=JSON.parse(e.text);i.type&&(i.type.startsWith("create")||i.type.startsWith("update")||i.type.startsWith("delete"))&&t(i)}catch{}}}function v5(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=new WebSocket(s);if(await new Promise((c,u)=>{r.onopen=c,r.onerror=u,e&&e.addEventListener("abort",()=>{r.close(),u(new DOMException("Aborted","AbortError"))},{once:!0})}),i){let c=i instanceof Map?[...i.keys()]:Object.keys(i);r.send(JSON.stringify({jsonrpc:"2.0",method:"a2ui/catalog",params:{supportedTypes:c}}))}let o=[],a=null,l=!1,h=c=>{if(a){let u=a;a=null,u({value:c,done:!1})}else o.push(c)};for(r.onmessage=c=>{try{let u=JSON.parse(c.data);qA(u,h),u.method==="a2ui/action"&&n&&n(u.params?.name,u.params?.arguments).then(d=>{r.send(JSON.stringify({jsonrpc:"2.0",id:u.id,result:d}))}).catch(d=>{r.send(JSON.stringify({jsonrpc:"2.0",id:u.id,error:{code:-1,message:d.message}}))})}catch{console.warn("A2UI MCP: invalid message",c.data)}},r.onclose=()=>{if(l=!0,a){let c=a;a=null,c({value:void 0,done:!0})}},r.onerror=()=>{l=!0,r.close()},e&&e.addEventListener("abort",()=>{if(l=!0,r.close(),a){let c=a;a=null,c({value:void 0,done:!0})}});!l||o.length>0;)if(o.length>0)yield o.shift();else{if(l)break;{let c=await new Promise(u=>{a=u});if(c.done)break;yield c.value}}}}}function ZA(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=[],o=null,a=!1,l=O=>{if(o){let w=o;o=null,w({value:O,done:!1})}else r.push(O)},h=()=>{if(a=!0,o){let O=o;o=null,O({value:void 0,done:!0})}},c={jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:"a2ui",version:"0.0.0"}}},u;try{u=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream"},body:JSON.stringify(c),signal:e})}catch(O){console.warn("A2UI MCP HTTP: initialize failed",O);return}if(!u.ok){console.warn(`A2UI MCP HTTP: initialize returned ${u.status}`);return}let d=u.headers.get("mcp-session-id");if(!d){console.warn("A2UI MCP HTTP: server did not return mcp-session-id header");try{await u.text()}catch{}return}try{if((u.headers.get("content-type")||"").includes("text/event-stream")){let w=u.body.getReader(),x=new TextDecoder,S="";for(;;){let{done:v,value:k}=await w.read();if(v||(S+=x.decode(k,{stream:!0}),S.includes(`
@@ -79,7 +79,7 @@ See the JSDoc header of icons-phosphor.js for the full recipe (gh#786).`)},0)}el
79
79
  aria-label="Undo" \u2190 explicit accessible name
80
80
  title="Undo" \u2190 auto-mirrored to aria-label + tooltip
81
81
  aria-labelledby="..." \u2190 reference an existing label element
82
- Without an accessible name screen readers announce nothing meaningful.`)))}}static#t=new WeakSet;static#e=new WeakSet;#i=t=>{if(this.disabled){t.stopPropagation();return}if(this.type==="submit"){let e=this.closest("form");e?.requestSubmit&&e.requestSubmit()}else if(this.type==="reset"){let e=this.closest("form");e?.reset&&e.reset()}this.dispatchEvent(new Event("press",{bubbles:!0}))};#s=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.click())};disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}};M();A("button-ui",fn);X();var pn=class extends C{static properties={text:{type:String,default:"",reflect:!0},href:{type:String,default:"",reflect:!0},target:{type:String,default:"",reflect:!0},rel:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},block:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=t=>{if(this.disabled){t.preventDefault();return}let e={href:this.href,target:this.target},i=new CustomEvent("press",{bubbles:!0,cancelable:!0,detail:e});this.dispatchEvent(i)||t.preventDefault()};#e=t=>{this.disabled&&t.key==="Enter"&&t.preventDefault()};#i(){let t=this.querySelector(":scope > a");t||(t=document.createElement("a"),t.dataset.autostamped="true",this.appendChild(t));let e=[];for(let i of this.childNodes)i!==t&&i.parentNode===this&&e.push(i);for(let i of e)t.appendChild(i);return t}connected(){let t=this.#i();this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e),this.disabled&&this.setAttribute("aria-disabled","true")}render(){let t=this.querySelector(":scope > a");if(!t)return;let e=t.dataset.autostamped==="true";if(e&&(this.href?t.setAttribute("href",this.href):t.removeAttribute("href"),this.target?t.setAttribute("target",this.target):t.removeAttribute("target"),this.rel?t.setAttribute("rel",this.rel):this.target==="_blank"?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel")),this.disabled?(this.setAttribute("aria-disabled","true"),t.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),t.removeAttribute("tabindex")),e){let i=this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:"",n=this.text?`<span>${this.text}</span>`:"";t.innerHTML=`${i}${n}`}}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};M();A("link-ui",pn);X();var _=class s extends C{static formAssociated=!0;static get properties(){return{name:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},minlength:{type:Number,default:null,reflect:!0},maxlength:{type:Number,default:null,reflect:!0},throttle:{type:Number,default:0,reflect:!0}}}#t=!1;#e=null;#i=void 0;get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}syncValue(t){t=t??this.value??"",this.internals.setFormValue(t),this.#s(t)}setValid(){this.internals.setValidity({}),this.removeAttribute("aria-invalid"),this.error&&(this.error="")}setInvalid(t,e){this.internals.setValidity({customError:!0},t||"Invalid",e||this),this.setAttribute("aria-invalid","true"),this.error=t||"Invalid"}validate(){let t=this.#s(this.value??"");return t?(this.removeAttribute("aria-invalid"),this.error&&(this.error="")):(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),t}scheduleThrottledInput(t=null){let e=Number(this.throttle)||0,i=()=>new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}});if(e>0){this.#e!=null&&clearTimeout(this.#e),this.#i=this.value,this.#e=setTimeout(()=>{this.#e=null,this.#i=void 0,this.dispatchEvent(i())},e);return}this.dispatchEvent(i())}flushPendingInput(t=null){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}})))}dropPendingInput(){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0)}#s(t){t=t??this.value??"";let e=String(t);if(this.required&&!e.trim())return this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),!1;if(this.pattern&&e)try{if(!new RegExp(`^(?:${this.pattern})$`).test(e))return this.internals.setValidity({patternMismatch:!0},this.getAttribute("data-msg-pattern")||"Please match the requested format.",this),!1}catch{}return this.minlength!=null&&this.minlength>0&&e.length>0&&e.length<this.minlength?(this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-minlength")||`Please use at least ${this.minlength} characters.`,this),!1):this.maxlength!=null&&this.maxlength>0&&e.length>this.maxlength?(this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-maxlength")||`Please use no more than ${this.maxlength} characters.`,this),!1):(this.internals.setValidity({}),!0)}#n=t=>{t.preventDefault(),this.setAttribute("aria-invalid","true"),this.error=this.validationMessage};#r=()=>{this.#t=!0,this.error&&this.validate()};#o=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#n),this.addEventListener("input",this.#r),this.addEventListener("blur",this.#o,!0),this.#a()}#a(){let t=this.constructor;t.labelDeprecated!==!1&&t.properties?.label&&this.hasAttribute("label")&&(s.#l.has(t)||(s.#l.add(t),console.warn(`[AdiaUI] <${this.localName} label="\u2026"> is deprecated \u2014 wrap in <field-ui label="\u2026"> for proper label association. Docs: https://ui-kit.exe.xyz/site/components/field`)))}static#l=new Set;disconnected(){super.disconnected(),this.removeEventListener("invalid",this.#n),this.removeEventListener("input",this.#r),this.removeEventListener("blur",this.#o,!0),this.dropPendingInput()}formResetCallback(){this.#t=!1,this.setValid(),this.onFormReset()}formDisabledCallback(t){this.disabled=t,this.onFormDisabled(t)}formAssociatedCallback(t){this.onFormAssociated(t)}formStateRestoreCallback(t,e){this.onFormStateRestore(t,e)}onFormReset(){}onFormDisabled(t){}onFormAssociated(t){}onFormStateRestore(t,e){}};var x$=s=>s.getAttribute?.("role")==="presentation"||s.style?.display==="contents";function S$(s){let t=[],e=i=>{for(let n of i)if(n.nodeType===1){if(x$(n)){e(n.children);continue}t.push(n)}};return s&&e(s.children),t}function lt(s,t){return S$(s).filter(e=>e.getAttribute("slot")===t)}function Zt(s,t,e){let i=s.getAttribute("aria-label");if(t!==void 0&&i!==t&&(t=void 0),i!==null&&t===void 0)return t;if(e)return i!==e&&s.setAttribute("aria-label",e),e;i!==null&&s.removeAttribute("aria-label")}var Ib=s=>rh(s)?`<icon-ui name="${s}"></icon-ui>`:s,mn=class s extends _{static labelDeprecated=!1;static requiredIcons=["caret-up","caret-down"];static properties={..._.properties,placeholder:{type:String,default:"",reflect:!0},type:{type:String,default:"text",reflect:!0},label:{type:String,default:"",reflect:!0},prefix:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},min:{type:Number,default:null,reflect:!0},max:{type:Number,default:null,reflect:!0},step:{type:Number,default:1,reflect:!0},precision:{type:Number,default:null,reflect:!0},locale:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n="";#r=null;#o=null;#a=".";#l="";#c=null;static#h=0;#u=void 0;static#d=400;static#f=60;get#p(){return this.type==="password"}get#m(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#y(t);if(e==="-"||e==="."||e==="-.")return NaN;let i=Number(e);return Number.isFinite(i)?i:NaN}set valueAsNumber(t){if(!Number.isFinite(t)){this.value="";return}this.value=this.#A(t)}connected(){super.connected(),this.setAttribute("role",this.#m?"spinbutton":"textbox");let t=lt(this,"leading"),e=lt(this,"trailing");this.querySelector('[slot="text"]')||this.#O(t,e),this.#t=this.querySelector('[slot="text"]'),this.#e=this.querySelector('[slot="label"]'),this.#i=this.querySelector('[data-step="up"]'),this.#s=this.querySelector('[data-step="down"]'),!this.#p&&this.value&&(this.#t.textContent=this.#m?this.#E(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#M),this.#t.addEventListener("keydown",this.#B),this.#t.addEventListener("blur",this.#F),this.#t.addEventListener("focus",this.#q),this.#t.addEventListener("paste",this.#_),this.#m&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#j),this.#s?.addEventListener("pointerdown",this.#U),(this.prefix||this.suffix)&&Ea.then(()=>this.#x())}#O(t,e){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#S(i),this.#v(t,e)}#g(){if(this.#p||!this.#t||!!this.querySelector(':scope > [slot="field"] [data-controls]')===this.#m)return;this.#t.removeEventListener("input",this.#M),this.#t.removeEventListener("keydown",this.#B),this.#t.removeEventListener("blur",this.#F),this.#t.removeEventListener("focus",this.#q),this.#t.removeEventListener("paste",this.#_),this.#t.removeEventListener("beforeinput",this.#I);let e=this.querySelector(':scope > [slot="field"]'),i=e?[...e.querySelectorAll(':scope > [slot="leading"]')]:[],n=e?[...e.querySelectorAll(':scope > [slot="trailing"]')]:[];this.#O(i,n),this.setAttribute("role",this.#m?"spinbutton":"textbox"),this.#t=this.querySelector('[slot="text"]'),this.#e=this.querySelector('[slot="label"]'),this.#i=this.querySelector('[data-step="up"]'),this.#s=this.querySelector('[data-step="down"]'),this.#t&&(this.#t.addEventListener("input",this.#M),this.#t.addEventListener("keydown",this.#B),this.#t.addEventListener("blur",this.#F),this.#t.addEventListener("focus",this.#q),this.#t.addEventListener("paste",this.#_),this.#m&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#j),this.#s?.addEventListener("pointerdown",this.#U),(this.prefix||this.suffix)&&Ea.then(()=>this.#x())}#S(t){let e=this.prefix?`<span slot="prefix">${Ib(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",n=this.suffix?`<span slot="suffix">${Ib(this.suffix)}</span>`:"",r=t?`aria-labelledby="${t}"`:"";if(this.#p)return`
82
+ Without an accessible name screen readers announce nothing meaningful.`)))}}static#t=new WeakSet;static#e=new WeakSet;#i=t=>{if(this.disabled){t.stopPropagation();return}if(this.type==="submit"){let e=this.closest("form");e?.requestSubmit&&e.requestSubmit()}else if(this.type==="reset"){let e=this.closest("form");e?.reset&&e.reset()}this.dispatchEvent(new Event("press",{bubbles:!0}))};#s=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.click())};disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}};M();A("button-ui",fn);X();var pn=class extends C{static properties={text:{type:String,default:"",reflect:!0},href:{type:String,default:"",reflect:!0},target:{type:String,default:"",reflect:!0},rel:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},block:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=t=>{if(this.disabled){t.preventDefault();return}let e={href:this.href,target:this.target},i=new CustomEvent("press",{bubbles:!0,cancelable:!0,detail:e});this.dispatchEvent(i)||t.preventDefault()};#e=t=>{this.disabled&&t.key==="Enter"&&t.preventDefault()};#i(){let t=this.querySelector(":scope > a");t||(t=document.createElement("a"),t.dataset.autostamped="true",this.appendChild(t));let e=[];for(let i of this.childNodes)i!==t&&i.parentNode===this&&e.push(i);for(let i of e)t.appendChild(i);return t}connected(){let t=this.#i();this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e),this.disabled&&this.setAttribute("aria-disabled","true")}render(){let t=this.querySelector(":scope > a");if(!t)return;let e=t.dataset.autostamped==="true";if(e&&(this.href?t.setAttribute("href",this.href):t.removeAttribute("href"),this.target?t.setAttribute("target",this.target):t.removeAttribute("target"),this.rel?t.setAttribute("rel",this.rel):this.target==="_blank"?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel")),this.disabled?(this.setAttribute("aria-disabled","true"),t.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),t.removeAttribute("tabindex")),e){let i=this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:"",n=this.text?`<span>${this.text}</span>`:"";t.innerHTML=`${i}${n}`}}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};M();A("link-ui",pn);X();var _=class s extends C{static formAssociated=!0;static get properties(){return{name:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},minlength:{type:Number,default:null,reflect:!0},maxlength:{type:Number,default:null,reflect:!0},throttle:{type:Number,default:0,reflect:!0}}}#t=!1;#e=null;#i=void 0;get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}syncValue(t){t=t??this.value??"",this.internals.setFormValue(t),this.#s(t)}setValid(){this.internals.setValidity({}),this.removeAttribute("aria-invalid"),this.error&&(this.error="")}setInvalid(t,e){this.internals.setValidity({customError:!0},t||"Invalid",e||this),this.setAttribute("aria-invalid","true"),this.error=t||"Invalid"}validate(){let t=this.#s(this.value??"");return t?(this.removeAttribute("aria-invalid"),this.error&&(this.error="")):(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),t}scheduleThrottledInput(t=null){let e=Number(this.throttle)||0,i=()=>new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}});if(e>0){this.#e!=null&&clearTimeout(this.#e),this.#i=this.value,this.#e=setTimeout(()=>{this.#e=null,this.#i=void 0,this.dispatchEvent(i())},e);return}this.dispatchEvent(i())}flushPendingInput(t=null){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}})))}dropPendingInput(){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0)}#s(t){t=t??this.value??"";let e=String(t);if(this.required&&!e.trim())return this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),!1;if(this.pattern&&e)try{if(!new RegExp(`^(?:${this.pattern})$`).test(e))return this.internals.setValidity({patternMismatch:!0},this.getAttribute("data-msg-pattern")||"Please match the requested format.",this),!1}catch{}return this.minlength!=null&&this.minlength>0&&e.length>0&&e.length<this.minlength?(this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-minlength")||`Please use at least ${this.minlength} characters.`,this),!1):this.maxlength!=null&&this.maxlength>0&&e.length>this.maxlength?(this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-maxlength")||`Please use no more than ${this.maxlength} characters.`,this),!1):(this.internals.setValidity({}),!0)}#n=t=>{t.preventDefault(),this.setAttribute("aria-invalid","true"),this.error=this.validationMessage};#r=()=>{this.#t=!0,this.error&&this.validate()};#o=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#n),this.addEventListener("input",this.#r),this.addEventListener("blur",this.#o,!0),this.#a()}#a(){let t=this.constructor;t.labelDeprecated!==!1&&t.properties?.label&&this.hasAttribute("label")&&(s.#l.has(t)||(s.#l.add(t),console.warn(`[AdiaUI] <${this.localName} label="\u2026"> is deprecated \u2014 wrap in <field-ui label="\u2026"> for proper label association. Docs: https://ui-kit.exe.xyz/site/components/field`)))}static#l=new Set;disconnected(){super.disconnected(),this.removeEventListener("invalid",this.#n),this.removeEventListener("input",this.#r),this.removeEventListener("blur",this.#o,!0),this.dropPendingInput()}formResetCallback(){this.#t=!1,this.setValid(),this.onFormReset()}formDisabledCallback(t){this.disabled=t,this.onFormDisabled(t)}formAssociatedCallback(t){this.onFormAssociated(t)}formStateRestoreCallback(t,e){this.onFormStateRestore(t,e)}onFormReset(){}onFormDisabled(t){}onFormAssociated(t){}onFormStateRestore(t,e){}};var x$=s=>s.getAttribute?.("role")==="presentation"||s.style?.display==="contents";function S$(s){let t=[],e=i=>{for(let n of i)if(n.nodeType===1){if(x$(n)){e(n.children);continue}t.push(n)}};return s&&e(s.children),t}function lt(s,t){return S$(s).filter(e=>e.getAttribute("slot")===t)}function Zt(s,t,e){let i=s.getAttribute("aria-label");if(t!==void 0&&i!==t&&(t=void 0),i!==null&&t===void 0)return t;if(e)return i!==e&&s.setAttribute("aria-label",e),e;i!==null&&s.removeAttribute("aria-label")}var Ib=s=>rh(s)?`<icon-ui name="${s}"></icon-ui>`:s,mn=class s extends _{static labelDeprecated=!1;static requiredIcons=["caret-up","caret-down"];static properties={..._.properties,placeholder:{type:String,default:"",reflect:!0},type:{type:String,default:"text",reflect:!0},label:{type:String,default:"",reflect:!0},prefix:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},min:{type:Number,default:null,reflect:!0},max:{type:Number,default:null,reflect:!0},step:{type:Number,default:1,reflect:!0},precision:{type:Number,default:null,reflect:!0},locale:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n="";#r=null;#o=null;#a=".";#l="";#c=null;static#h=0;#u=void 0;static#d=400;static#f=60;get#p(){return this.type==="password"}get#m(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#v(t);if(e==="-"||e==="."||e==="-.")return NaN;let i=Number(e);return Number.isFinite(i)?i:NaN}set valueAsNumber(t){if(!Number.isFinite(t)){this.value="";return}this.value=this.#$(t)}connected(){super.connected(),this.setAttribute("role",this.#m?"spinbutton":"textbox");let t=lt(this,"leading"),e=lt(this,"trailing");this.querySelector('[slot="text"]')||this.#g(t,e),this.#t=this.querySelector('[slot="text"]'),this.#e=this.querySelector('[slot="label"]'),this.#i=this.querySelector('[data-step="up"]'),this.#s=this.querySelector('[data-step="down"]'),!this.#p&&this.value&&(this.#t.textContent=this.#m?this.#C(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#R),this.#t.addEventListener("keydown",this.#B),this.#t.addEventListener("blur",this.#F),this.#t.addEventListener("focus",this.#q),this.#t.addEventListener("paste",this.#_),this.#m&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#j),this.#s?.addEventListener("pointerdown",this.#U),(this.prefix||this.suffix)&&Ea.then(()=>this.#x())}#g(t,e){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#S(i),this.#b(t,e)}#O(){if(this.#p||!this.#t||!!this.querySelector(':scope > [slot="field"] [data-controls]')===this.#m)return;this.#t.removeEventListener("input",this.#R),this.#t.removeEventListener("keydown",this.#B),this.#t.removeEventListener("blur",this.#F),this.#t.removeEventListener("focus",this.#q),this.#t.removeEventListener("paste",this.#_),this.#t.removeEventListener("beforeinput",this.#I);let e=this.querySelector(':scope > [slot="field"]'),i=e?[...e.querySelectorAll(':scope > [slot="leading"]')]:[],n=e?[...e.querySelectorAll(':scope > [slot="trailing"]')]:[];this.#g(i,n),this.setAttribute("role",this.#m?"spinbutton":"textbox"),this.#t=this.querySelector('[slot="text"]'),this.#e=this.querySelector('[slot="label"]'),this.#i=this.querySelector('[data-step="up"]'),this.#s=this.querySelector('[data-step="down"]'),this.#t&&(this.#t.addEventListener("input",this.#R),this.#t.addEventListener("keydown",this.#B),this.#t.addEventListener("blur",this.#F),this.#t.addEventListener("focus",this.#q),this.#t.addEventListener("paste",this.#_),this.#m&&this.#t.addEventListener("beforeinput",this.#I)),this.#i?.addEventListener("pointerdown",this.#j),this.#s?.addEventListener("pointerdown",this.#U),(this.prefix||this.suffix)&&Ea.then(()=>this.#x())}#S(t){let e=this.prefix?`<span slot="prefix">${Ib(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",n=this.suffix?`<span slot="suffix">${Ib(this.suffix)}</span>`:"",r=t?`aria-labelledby="${t}"`:"";if(this.#p)return`
83
83
  <div slot="field">
84
84
  ${e}${i}
85
85
  <input slot="text" type="password" tabindex="0"
@@ -106,12 +106,12 @@ See the JSDoc header of icons-phosphor.js for the full recipe (gh#786).`)},0)}el
106
106
  <div slot="field">
107
107
  ${e}${i}${o}${n}${a}
108
108
  </div>
109
- `}#v(t,e){let i=this.querySelector(':scope > [slot="field"]');if(i){if(t.length){let n=i.querySelector(':scope > [slot="label"]')||i.querySelector(':scope > [slot="prefix"]');if(n){let r=n;for(let o of t)r.after(o),r=o}else for(let r of t.slice().reverse())i.prepend(r)}if(e.length){let n=i.querySelector(':scope > [slot="controls"]'),r=i.querySelector(':scope > [slot="suffix"]')||i.querySelector(':scope > [slot="text"]');if(r){let o=r;for(let a of e)o.after(a),o=a}else if(n){let o=n.previousElementSibling||n;for(let a of e)o.after(a),o=a}else for(let o of e)i.appendChild(o)}}}#x(){if(this.isConnected)for(let t of["prefix","suffix"]){let e=this[t];if(!e)continue;let i=this.querySelector(`:scope [slot="${t}"]`);if(i&&!i.querySelector(":scope > icon-ui")&&rh(e)){i.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",e),i.appendChild(n)}}}#w(){for(let t of["prefix","suffix"]){let e=this.querySelector(`:scope > [slot="field"] > [slot="${t}"]`);if(!e)continue;let i=this[t]||"",n=e.querySelector(":scope > icon-ui");if(i&&rh(i))if(n)n.getAttribute("name")!==i&&n.setAttribute("name",i);else{e.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",i),e.appendChild(r)}else n&&e.replaceChildren(),e.textContent!==i&&(e.textContent=i)}}render(){if(!this.#t)return;this.#g();let t=this.value??"";if(this.#p)this.#t.placeholder=this.placeholder,this.#t.disabled=this.disabled,this.#t.readOnly=this.readonly,this.#t.value!==t&&(this.#t.value=t);else{this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let i=this.#m&&document.activeElement!==this.#t?this.#E(t):String(t);this.#t.textContent!==i&&(this.#t.textContent=i,this.#t.toggleAttribute("data-empty",!i))}this.#e&&(this.#e.textContent=this.label||""),this.#w();let e=this.label?"":this.placeholder||"";if(this.#u=Zt(this,this.#u,e),this.#m){let i=this.valueAsNumber;Number.isFinite(i)?(this.setAttribute("aria-valuenow",String(i)),this.setAttribute("aria-valuetext",`${this.#A(i)}${this.suffix?" "+this.suffix:""}`)):(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuetext")),this.min!=null?this.setAttribute("aria-valuemin",String(this.min)):this.removeAttribute("aria-valuemin"),this.max!=null?this.setAttribute("aria-valuemax",String(this.max)):this.removeAttribute("aria-valuemax");let n=this.disabled||this.readonly||this.max!=null&&Number.isFinite(i)&&i>=this.max,r=this.disabled||this.readonly||this.min!=null&&Number.isFinite(i)&&i<=this.min;this.#i?.toggleAttribute("disabled",!!n),this.#s?.toggleAttribute("disabled",!!r)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#m&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#m)return t;if(!t)return!1;let e=this.#b(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#b(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#y(e),n=Number(i);return Number.isFinite(n)?this.min!=null&&n<this.min?(this.internals.setValidity({rangeUnderflow:!0},this.getAttribute("data-msg-min")||`Value must be ${this.min} or greater.`,this),!1):this.max!=null&&n>this.max?(this.internals.setValidity({rangeOverflow:!0},this.getAttribute("data-msg-max")||`Value must be ${this.max} or less.`,this),!1):!0:(this.internals.setValidity({badInput:!0},this.getAttribute("data-msg-bad-input")||"Please enter a valid number.",this),!1)}#$(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#C(){return this.locale?this.#c===this.locale?this.#a:(this.#k(),this.#a):"."}#P(){return this.locale?this.#c===this.locale?this.#l:(this.#k(),this.#l):""}#k(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#a=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#a=".",this.#l=""}this.#c=this.locale}#y(t){let e=this.#C(),i=this.#P(),n=String(t);return i&&(n=n.split(i).join("")),e!=="."&&(n=n.replace(new RegExp(`\\${e}`,"g"),".")),n}#A(t){if(!Number.isFinite(t))return"";let e=this.#$();if(this.locale)try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!1}).format(t)}catch{}return e>0?t.toFixed(e):String(Math.round(t))}#T(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#A(t);let e=this.#$();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#A(t)}}#E(t){let e=String(t??"");if(!e)return"";let i=Number(this.#y(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#A(i):this.#T(i):e}#L(t){let e=this.step||1,i=this.min!=null?this.min:0,n=Math.round((t-i)/e)*e+i,r=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,n));return parseFloat(r.toFixed(10))}#Q(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,n=this.#L(i+e);n!==this.valueAsNumber&&(this.value=this.#A(n),this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#M=()=>{let t;if(this.#p)t=this.#t.value||"";else if(this.#m){let e=this.#t.textContent||"";t=this.#X(e),t!==e&&(this.#t.textContent=t,this.#Z())}else t=this.#t.textContent||"";this.value=t,this.#p||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#I=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let n=this.#t.textContent||"",r=window.getSelection(),o=n.length,a=n.length;if(r&&r.rangeCount&&this.#t.contains(r.anchorNode)){let h=r.getRangeAt(0);o=this.#N(h.startContainer,h.startOffset),a=this.#N(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=n.slice(0,o)+i+n.slice(a);this.#R(l)||t.preventDefault()};#R(t){let e=this.#y(t);return e===""||e==="-"||e==="."||e==="-."?e===""||e==="-"||this.min==null||this.min<0:!(!/^-?\d*\.?\d*$/.test(e)||e.startsWith("-")&&this.min!=null&&this.min>=0)}#X(t){let e=this.#C(),i="",n=!1;for(let r=0;r<t.length;r++){let o=t[r];o>="0"&&o<="9"||o==="-"&&i===""&&(this.min==null||this.min<0)?i+=o:o===e&&!n&&(i+=e,n=!0)}return i}#N(t,e){if(!this.#t.contains(t))return 0;let i=0,n=document.createTreeWalker(this.#t,NodeFilter.SHOW_TEXT),r;for(;r=n.nextNode();){if(r===t)return i+e;i+=r.textContent.length}return t===this.#t?e:i}#Z(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#B=t=>{if(this.#m){switch(t.key){case"ArrowUp":t.preventDefault(),this.#Q(1);return;case"ArrowDown":t.preventDefault(),this.#Q(-1);return;case"PageUp":t.preventDefault(),this.#Q(10);return;case"PageDown":t.preventDefault(),this.#Q(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#z(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#z(this.max));return;case"Escape":t.preventDefault(),this.value=this.#n,this.#t.textContent=this.#E(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#D(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0}));return}return}t.key==="Enter"&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#q=()=>{if(this.#n=this.value??"",this.#m&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#y(t));if(!Number.isFinite(e))return;let i=this.#A(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#F=()=>{this.#m&&this.#D(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#D(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#y(t));if(!Number.isFinite(e))return;let i=this.#L(e),n=this.#A(i),r=this.#T(i);this.value!==n&&(this.value=n,this.syncValue(n),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==r&&(this.#t.textContent=r,this.#t.toggleAttribute("data-empty",!r))}#z(t){let e=this.#L(t);e!==this.valueAsNumber&&(this.value=this.#A(e),this.syncValue(this.value),this.#t.textContent=this.value,this.#t.toggleAttribute("data-empty",!this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#_=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#m?this.#X(e):e;document.execCommand("insertText",!1,i)};#j=t=>this.#et(t,1);#U=t=>this.#et(t,-1);#et(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#Q(e),this.#Y(),document.addEventListener("pointerup",this.#G,{once:!0}),document.addEventListener("pointercancel",this.#G,{once:!0}),this.#o=window.setTimeout(()=>{this.#o=null,this.#r=window.setInterval(()=>{let i=this.valueAsNumber;this.#Q(e),this.valueAsNumber===i&&this.#Y()},s.#f)},s.#d))}#G=()=>this.#Y();#Y(){this.#o!=null&&(window.clearTimeout(this.#o),this.#o=null),this.#r!=null&&(window.clearInterval(this.#r),this.#r=null),document.removeEventListener("pointerup",this.#G),document.removeEventListener("pointercancel",this.#G)}focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#p?this.#t.value="":(this.#t.textContent="",this.#t.setAttribute("data-empty",""))),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#M),this.#t.removeEventListener("keydown",this.#B),this.#t.removeEventListener("blur",this.#F),this.#t.removeEventListener("focus",this.#q),this.#t.removeEventListener("paste",this.#_),this.#t.removeEventListener("beforeinput",this.#I)),this.#i?.removeEventListener("pointerdown",this.#j),this.#s?.removeEventListener("pointerdown",this.#U),this.#Y(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};M();A("input-ui",mn);var gn=class extends _{static labelDeprecated=!1;static properties={..._.properties,placeholder:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},rows:{type:Number,default:3,reflect:!0},resize:{type:String,default:"vertical",reflect:!0}};static template=()=>null;#t=null;#e=void 0;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
109
+ `}#b(t,e){let i=this.querySelector(':scope > [slot="field"]');if(i){if(t.length){let n=i.querySelector(':scope > [slot="label"]')||i.querySelector(':scope > [slot="prefix"]');if(n){let r=n;for(let o of t)r.after(o),r=o}else for(let r of t.slice().reverse())i.prepend(r)}if(e.length){let n=i.querySelector(':scope > [slot="controls"]'),r=i.querySelector(':scope > [slot="suffix"]')||i.querySelector(':scope > [slot="text"]');if(r){let o=r;for(let a of e)o.after(a),o=a}else if(n){let o=n.previousElementSibling||n;for(let a of e)o.after(a),o=a}else for(let o of e)i.appendChild(o)}}}#x(){if(this.isConnected)for(let t of["prefix","suffix"]){let e=this[t];if(!e)continue;let i=this.querySelector(`:scope [slot="${t}"]`);if(i&&!i.querySelector(":scope > icon-ui")&&rh(e)){i.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",e),i.appendChild(n)}}}#w(){for(let t of["prefix","suffix"]){let e=this.querySelector(`:scope > [slot="field"] > [slot="${t}"]`);if(!e)continue;let i=this[t]||"",n=e.querySelector(":scope > icon-ui");if(i&&rh(i))if(n)n.getAttribute("name")!==i&&n.setAttribute("name",i);else{e.replaceChildren();let r=document.createElement("icon-ui");r.setAttribute("name",i),e.appendChild(r)}else n&&e.replaceChildren(),e.textContent!==i&&(e.textContent=i)}}render(){if(!this.#t)return;this.#O();let t=this.value??"";if(this.#p)this.#t.placeholder=this.placeholder,this.#t.disabled=this.disabled,this.#t.readOnly=this.readonly,this.#t.value!==t&&(this.#t.value=t);else{this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let i=this.#m&&document.activeElement!==this.#t?this.#C(t):String(t);this.#t.textContent!==i&&(this.#t.textContent=i,this.#t.toggleAttribute("data-empty",!i))}this.#e&&(this.#e.textContent=this.label||""),this.#w();let e=this.label?"":this.placeholder||"";if(this.#u=Zt(this,this.#u,e),this.#m){let i=this.valueAsNumber;Number.isFinite(i)?(this.setAttribute("aria-valuenow",String(i)),this.setAttribute("aria-valuetext",`${this.#$(i)}${this.suffix?" "+this.suffix:""}`)):(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuetext")),this.min!=null?this.setAttribute("aria-valuemin",String(this.min)):this.removeAttribute("aria-valuemin"),this.max!=null?this.setAttribute("aria-valuemax",String(this.max)):this.removeAttribute("aria-valuemax");let n=this.disabled||this.readonly||this.max!=null&&Number.isFinite(i)&&i>=this.max,r=this.disabled||this.readonly||this.min!=null&&Number.isFinite(i)&&i<=this.min;this.#i?.toggleAttribute("disabled",!!n),this.#s?.toggleAttribute("disabled",!!r)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#m&&this.#y(String(t))}validate(){let t=super.validate();if(!this.#m)return t;if(!t)return!1;let e=this.#y(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#y(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#v(e),n=Number(i);return Number.isFinite(n)?this.min!=null&&n<this.min?(this.internals.setValidity({rangeUnderflow:!0},this.getAttribute("data-msg-min")||`Value must be ${this.min} or greater.`,this),!1):this.max!=null&&n>this.max?(this.internals.setValidity({rangeOverflow:!0},this.getAttribute("data-msg-max")||`Value must be ${this.max} or less.`,this),!1):!0:(this.internals.setValidity({badInput:!0},this.getAttribute("data-msg-bad-input")||"Please enter a valid number.",this),!1)}#A(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#E(){return this.locale?this.#c===this.locale?this.#a:(this.#k(),this.#a):"."}#P(){return this.locale?this.#c===this.locale?this.#l:(this.#k(),this.#l):""}#k(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#a=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#a=".",this.#l=""}this.#c=this.locale}#v(t){let e=this.#E(),i=this.#P(),n=String(t);return i&&(n=n.split(i).join("")),e!=="."&&(n=n.replace(new RegExp(`\\${e}`,"g"),".")),n}#$(t){if(!Number.isFinite(t))return"";let e=this.#A();if(this.locale)try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!1}).format(t)}catch{}return e>0?t.toFixed(e):String(Math.round(t))}#T(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#$(t);let e=this.#A();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#$(t)}}#C(t){let e=String(t??"");if(!e)return"";let i=Number(this.#v(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#$(i):this.#T(i):e}#M(t){let e=this.step||1,i=this.min!=null?this.min:0,n=Math.round((t-i)/e)*e+i,r=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,n));return parseFloat(r.toFixed(10))}#Q(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,n=this.#M(i+e);n!==this.valueAsNumber&&(this.value=this.#$(n),this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#R=()=>{let t;if(this.#p)t=this.#t.value||"";else if(this.#m){let e=this.#t.textContent||"";t=this.#X(e),t!==e&&(this.#t.textContent=t,this.#Z())}else t=this.#t.textContent||"";this.value=t,this.#p||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#I=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let n=this.#t.textContent||"",r=window.getSelection(),o=n.length,a=n.length;if(r&&r.rangeCount&&this.#t.contains(r.anchorNode)){let h=r.getRangeAt(0);o=this.#N(h.startContainer,h.startOffset),a=this.#N(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=n.slice(0,o)+i+n.slice(a);this.#L(l)||t.preventDefault()};#L(t){let e=this.#v(t);return e===""||e==="-"||e==="."||e==="-."?e===""||e==="-"||this.min==null||this.min<0:!(!/^-?\d*\.?\d*$/.test(e)||e.startsWith("-")&&this.min!=null&&this.min>=0)}#X(t){let e=this.#E(),i="",n=!1;for(let r=0;r<t.length;r++){let o=t[r];o>="0"&&o<="9"||o==="-"&&i===""&&(this.min==null||this.min<0)?i+=o:o===e&&!n&&(i+=e,n=!0)}return i}#N(t,e){if(!this.#t.contains(t))return 0;let i=0,n=document.createTreeWalker(this.#t,NodeFilter.SHOW_TEXT),r;for(;r=n.nextNode();){if(r===t)return i+e;i+=r.textContent.length}return t===this.#t?e:i}#Z(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#B=t=>{if(this.#m){switch(t.key){case"ArrowUp":t.preventDefault(),this.#Q(1);return;case"ArrowDown":t.preventDefault(),this.#Q(-1);return;case"PageUp":t.preventDefault(),this.#Q(10);return;case"PageDown":t.preventDefault(),this.#Q(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#z(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#z(this.max));return;case"Escape":t.preventDefault(),this.value=this.#n,this.#t.textContent=this.#C(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#D(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0}));return}return}t.key==="Enter"&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#q=()=>{if(this.#n=this.value??"",this.#m&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#v(t));if(!Number.isFinite(e))return;let i=this.#$(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#F=()=>{this.#m&&this.#D(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#D(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#v(t));if(!Number.isFinite(e))return;let i=this.#M(e),n=this.#$(i),r=this.#T(i);this.value!==n&&(this.value=n,this.syncValue(n),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==r&&(this.#t.textContent=r,this.#t.toggleAttribute("data-empty",!r))}#z(t){let e=this.#M(t);e!==this.valueAsNumber&&(this.value=this.#$(e),this.syncValue(this.value),this.#t.textContent=this.value,this.#t.toggleAttribute("data-empty",!this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#_=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#m?this.#X(e):e;document.execCommand("insertText",!1,i)};#j=t=>this.#et(t,1);#U=t=>this.#et(t,-1);#et(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#Q(e),this.#Y(),document.addEventListener("pointerup",this.#G,{once:!0}),document.addEventListener("pointercancel",this.#G,{once:!0}),this.#o=window.setTimeout(()=>{this.#o=null,this.#r=window.setInterval(()=>{let i=this.valueAsNumber;this.#Q(e),this.valueAsNumber===i&&this.#Y()},s.#f)},s.#d))}#G=()=>this.#Y();#Y(){this.#o!=null&&(window.clearTimeout(this.#o),this.#o=null),this.#r!=null&&(window.clearInterval(this.#r),this.#r=null),document.removeEventListener("pointerup",this.#G),document.removeEventListener("pointercancel",this.#G)}focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#p?this.#t.value="":(this.#t.textContent="",this.#t.setAttribute("data-empty",""))),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#R),this.#t.removeEventListener("keydown",this.#B),this.#t.removeEventListener("blur",this.#F),this.#t.removeEventListener("focus",this.#q),this.#t.removeEventListener("paste",this.#_),this.#t.removeEventListener("beforeinput",this.#I)),this.#i?.removeEventListener("pointerdown",this.#j),this.#s?.removeEventListener("pointerdown",this.#U),this.#Y(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};M();A("input-ui",mn);var gn=class extends _{static labelDeprecated=!1;static properties={..._.properties,placeholder:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},rows:{type:Number,default:3,reflect:!0},resize:{type:String,default:"vertical",reflect:!0}};static template=()=>null;#t=null;#e=void 0;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
110
110
  ${this.label?`<label slot="label" label="${this.label}"></label>`:""}
111
111
  <div slot="text" contenteditable="plaintext-only" tabindex="0"
112
112
  ${this.value?"":'data-empty=""'}
113
113
  data-placeholder="${this.placeholder}"></div>
114
- `),this.#t=this.querySelector('[slot="text"]'),this.value&&(this.#t.textContent=this.value),this.#t&&(this.#t.addEventListener("input",this.#i),this.#t.addEventListener("keydown",this.#s),this.#t.addEventListener("blur",this.#n),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);let i=this.label||this.placeholder||"";this.#e=Zt(this,this.#e,i)}#i=()=>{let t=this.#t.textContent||"";this.value=t,this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#s=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.flushPendingInput(),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#n=()=>{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.#i),this.#t.removeEventListener("keydown",this.#s),this.#t.removeEventListener("blur",this.#n),this.#t.removeEventListener("paste",this.#r)),this.#t=null}};M();A("textarea-ui",gn);X();var On=class extends _{static labelDeprecated=!1;static properties={..._.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=()=>At`<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)}};M();A("check-ui",On);X();var bn=class extends _{static labelDeprecated=!1;static properties={..._.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>At`<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}"]`)||[]],n=i.indexOf(this);return i[(n+t+i.length)%i.length]||null}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};M();A("radio-ui",bn);X();var yn=class s extends C{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}`}};M();A("radio-group-ui",yn);var vn=class extends _{static properties={..._.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&&!lt(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&&!lt(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&&!lt(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.#n(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#n(-1);e&&(e.focus(),e.click())}}};#s(){return this.closest('fieldset, [role="radiogroup"]')||this.parentElement}#n(t){let i=[...this.#s()?.querySelectorAll(`option-card-ui[name="${this.name}"]`)||[]],n=i.indexOf(this);return n<0?null:i[(n+t+i.length)%i.length]||null}};M();A("option-card-ui",vn);X();var Ke=Object.freeze({AVAILABLE:"available",CONNECTED:"connected",ERROR:"error",PENDING:"pending",COMING_SOON:"coming-soon"}),Db=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:""}}),w$=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:""}}),k$=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"}),A$="plug",xn=class extends C{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;#n=null;#r=null;#o=null;#a=null;#l=null;connected(){this.setAttribute("role","group"),this.#e=this.ensure("body"),this.#i=this.ensure("logo"),this.#s=this.ensure("heading"),this.#n=this.ensure("desc"),this.#o=this.ensure("status"),this.#a=this.ensure("footer"),this.#i.parentElement!==this.#e&&this.#e.appendChild(this.#i),this.#s.parentElement!==this.#e&&this.#e.appendChild(this.#s),this.#o.parentElement!==this.#e&&this.#e.appendChild(this.#o),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.#O)}disconnected(){this.removeEventListener("press",this.#m),this.removeEventListener("action",this.#O),this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=null,this.#o=null,this.#a=null,this.#l=null}render(){if(!this.#s)return;let t=this.#c();this.name&&this.#s.textContent!==this.name&&(this.#s.textContent=this.name),this.#h()?this.#n.parentElement===this&&this.#n.remove():(this.#n.parentElement||this.appendChild(this.#n),this.description?(this.#n.textContent!==this.description&&(this.#n.textContent=this.description),this.#n.hidden=!1):(this.#n.textContent="",this.#n.hidden=!0)),this.#u(),this.#d(t),this.#f(t),this.#p(t)}#c(){let t=(this.status||"").trim()||Ke.AVAILABLE;return Object.values(Ke).includes(t)?t:Ke.AVAILABLE}#h(){for(let t of this.children)if(t!==this.#e&&t!==this.#n&&t!==this.#r&&t!==this.#a&&!(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}#u(){if(!this.#i)return;let t=(this.logo||"").trim();if(t.startsWith("{{p:"))return;let e=(this.provider||"").trim().toLowerCase(),i=t||k$[e]||(e?A$:"");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 r=this.#i.querySelector(":scope > icon-ui");r&&r.getAttribute("name")===i||(this.#i.replaceChildren(),r=document.createElement("icon-ui"),r.setAttribute("name",i),r.setAttribute("aria-hidden","true"),this.#i.appendChild(r))}#d(t){if(!this.#o)return;let e=w$[t];if(!e){this.#o.hidden=!0,this.#o.removeAttribute("aria-label");return}this.#o.hidden=!1,e.variant?(this.#o.setAttribute("variant",e.variant),this.#o.removeAttribute("tone")):(this.#o.removeAttribute("variant"),this.#o.setAttribute("tone","muted")),this.#o.setAttribute("text",e.text),this.#o.setAttribute("size","sm"),e.icon?this.#o.setAttribute("icon",e.icon):this.#o.removeAttribute("icon"),this.#o.setAttribute("aria-label",e.text)}#f(t){let e=(this["error-message"]||this.getAttribute("error-message")||"").trim();t===Ke.ERROR&&e?(this.#r||(this.#r=this.ensure("error")),this.#r.parentElement||(this.#n?.parentElement===this?this.#n.after(this.#r):this.#a?.parentElement===this?this.insertBefore(this.#r,this.#a):this.appendChild(this.#r)),this.#r.textContent!==e&&(this.#r.textContent=e),this.#r.hidden=!1,this.#r.setAttribute("role","status")):this.#r&&(this.#r.hidden=!0,this.#r.textContent="")}#p(t){if(t===Ke.COMING_SOON){this.drop("button"),this.#l=null;return}let e=Db[t];if(!e){this.drop("button"),this.#l=null;return}this.#l||(this.#l=this.ensure("button")),this.#l.parentElement!==this.#a&&this.#a.insertBefore(this.#l,this.#a.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===Ke.CONNECTED?this.#l.setAttribute("aria-pressed","true"):t===Ke.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,n=this.name||this.provider||"integration";this.#l.setAttribute("aria-label",`${i} ${n}`),t===Ke.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.#c();if(e===Ke.PENDING||e===Ke.COMING_SOON){t.stopPropagation();return}let i=Db[e];!i||!i.emits||this.dispatchEvent(new CustomEvent(i.emits,{bubbles:!0,detail:{provider:this.provider}}))};#O=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}}))}}};M();A("integration-card-ui",xn);X();var Sn=class s extends _{static labelDeprecated=!1;static properties={..._.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"),At`
114
+ `),this.#t=this.querySelector('[slot="text"]'),this.value&&(this.#t.textContent=this.value),this.#t&&(this.#t.addEventListener("input",this.#i),this.#t.addEventListener("keydown",this.#s),this.#t.addEventListener("blur",this.#n),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);let i=this.label||this.placeholder||"";this.#e=Zt(this,this.#e,i)}#i=()=>{let t=this.#t.textContent||"";this.value=t,this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#s=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.flushPendingInput(),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#n=()=>{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.#i),this.#t.removeEventListener("keydown",this.#s),this.#t.removeEventListener("blur",this.#n),this.#t.removeEventListener("paste",this.#r)),this.#t=null}};M();A("textarea-ui",gn);X();var On=class extends _{static labelDeprecated=!1;static properties={..._.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=()=>At`<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)}};M();A("check-ui",On);X();var bn=class extends _{static labelDeprecated=!1;static properties={..._.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>At`<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}"]`)||[]],n=i.indexOf(this);return i[(n+t+i.length)%i.length]||null}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};M();A("radio-ui",bn);X();var yn=class s extends C{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}`}};M();A("radio-group-ui",yn);var vn=class extends _{static properties={..._.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&&!lt(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&&!lt(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&&!lt(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.#n(1);e&&(e.focus(),e.click())}if(t.key==="ArrowUp"||t.key==="ArrowLeft"){t.preventDefault();let e=this.#n(-1);e&&(e.focus(),e.click())}}};#s(){return this.closest('fieldset, [role="radiogroup"]')||this.parentElement}#n(t){let i=[...this.#s()?.querySelectorAll(`option-card-ui[name="${this.name}"]`)||[]],n=i.indexOf(this);return n<0?null:i[(n+t+i.length)%i.length]||null}};M();A("option-card-ui",vn);X();var Ke=Object.freeze({AVAILABLE:"available",CONNECTED:"connected",ERROR:"error",PENDING:"pending",COMING_SOON:"coming-soon"}),Db=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:""}}),w$=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:""}}),k$=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"}),A$="plug",xn=class extends C{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;#n=null;#r=null;#o=null;#a=null;#l=null;connected(){this.setAttribute("role","group"),this.#e=this.ensure("body"),this.#i=this.ensure("logo"),this.#s=this.ensure("heading"),this.#n=this.ensure("desc"),this.#o=this.ensure("status"),this.#a=this.ensure("footer"),this.#i.parentElement!==this.#e&&this.#e.appendChild(this.#i),this.#s.parentElement!==this.#e&&this.#e.appendChild(this.#s),this.#o.parentElement!==this.#e&&this.#e.appendChild(this.#o),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.#n=null,this.#r=null,this.#o=null,this.#a=null,this.#l=null}render(){if(!this.#s)return;let t=this.#c();this.name&&this.#s.textContent!==this.name&&(this.#s.textContent=this.name),this.#h()?this.#n.parentElement===this&&this.#n.remove():(this.#n.parentElement||this.appendChild(this.#n),this.description?(this.#n.textContent!==this.description&&(this.#n.textContent=this.description),this.#n.hidden=!1):(this.#n.textContent="",this.#n.hidden=!0)),this.#u(),this.#d(t),this.#f(t),this.#p(t)}#c(){let t=(this.status||"").trim()||Ke.AVAILABLE;return Object.values(Ke).includes(t)?t:Ke.AVAILABLE}#h(){for(let t of this.children)if(t!==this.#e&&t!==this.#n&&t!==this.#r&&t!==this.#a&&!(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}#u(){if(!this.#i)return;let t=(this.logo||"").trim();if(t.startsWith("{{p:"))return;let e=(this.provider||"").trim().toLowerCase(),i=t||k$[e]||(e?A$:"");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 r=this.#i.querySelector(":scope > icon-ui");r&&r.getAttribute("name")===i||(this.#i.replaceChildren(),r=document.createElement("icon-ui"),r.setAttribute("name",i),r.setAttribute("aria-hidden","true"),this.#i.appendChild(r))}#d(t){if(!this.#o)return;let e=w$[t];if(!e){this.#o.hidden=!0,this.#o.removeAttribute("aria-label");return}this.#o.hidden=!1,e.variant?(this.#o.setAttribute("variant",e.variant),this.#o.removeAttribute("tone")):(this.#o.removeAttribute("variant"),this.#o.setAttribute("tone","muted")),this.#o.setAttribute("text",e.text),this.#o.setAttribute("size","sm"),e.icon?this.#o.setAttribute("icon",e.icon):this.#o.removeAttribute("icon"),this.#o.setAttribute("aria-label",e.text)}#f(t){let e=(this["error-message"]||this.getAttribute("error-message")||"").trim();t===Ke.ERROR&&e?(this.#r||(this.#r=this.ensure("error")),this.#r.parentElement||(this.#n?.parentElement===this?this.#n.after(this.#r):this.#a?.parentElement===this?this.insertBefore(this.#r,this.#a):this.appendChild(this.#r)),this.#r.textContent!==e&&(this.#r.textContent=e),this.#r.hidden=!1,this.#r.setAttribute("role","status")):this.#r&&(this.#r.hidden=!0,this.#r.textContent="")}#p(t){if(t===Ke.COMING_SOON){this.drop("button"),this.#l=null;return}let e=Db[t];if(!e){this.drop("button"),this.#l=null;return}this.#l||(this.#l=this.ensure("button")),this.#l.parentElement!==this.#a&&this.#a.insertBefore(this.#l,this.#a.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===Ke.CONNECTED?this.#l.setAttribute("aria-pressed","true"):t===Ke.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,n=this.name||this.provider||"integration";this.#l.setAttribute("aria-label",`${i} ${n}`),t===Ke.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.#c();if(e===Ke.PENDING||e===Ke.COMING_SOON){t.stopPropagation();return}let i=Db[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}}))}}};M();A("integration-card-ui",xn);X();var Sn=class s extends _{static labelDeprecated=!1;static properties={..._.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"),At`
115
115
  <span slot="track"><span slot="thumb"></span></span>
116
116
  ${t.label?At`<span slot="label">${t.label}</span>`:null}
117
117
  ${t.hint?At`<span slot="hint" id=${e}>${t.hint}</span>`:null}
@@ -128,12 +128,12 @@ See the JSDoc header of icons-phosphor.js for the full recipe (gh#786).`)},0)}el
128
128
  ${o}
129
129
  </div>
130
130
  ${this.hint?`<span slot="hint" id="${e}">${this.hint}</span>`:""}
131
- `,this.hint&&this.setAttribute("aria-describedby",e)}this.#e=this.querySelector('[slot="track"]'),t?(this.#s=this.querySelector('[slot="thumb"][data-thumb="lower"]'),this.#n=this.querySelector('[slot="thumb"][data-thumb="upper"]'),this.#s?.addEventListener("pointerdown",this.#v),this.#n?.addEventListener("pointerdown",this.#v)):(this.#i=this.querySelector('[slot="thumb"]'),this.#i?.addEventListener("pointerdown",this.#v)),this.#e?.addEventListener("click",this.#$),this.addEventListener("keydown",this.#C)}render(){if(!this.#e)return;if(typeof this.value=="function"||typeof this.lowerValue=="function"||typeof this.upperValue=="function"){console.warn(`[slider-ui] .value / .lowerValue / .upperValue received a function. Did you mean:
131
+ `,this.hint&&this.setAttribute("aria-describedby",e)}this.#e=this.querySelector('[slot="track"]'),t?(this.#s=this.querySelector('[slot="thumb"][data-thumb="lower"]'),this.#n=this.querySelector('[slot="thumb"][data-thumb="upper"]'),this.#s?.addEventListener("pointerdown",this.#b),this.#n?.addEventListener("pointerdown",this.#b)):(this.#i=this.querySelector('[slot="thumb"]'),this.#i?.addEventListener("pointerdown",this.#b)),this.#e?.addEventListener("click",this.#A),this.addEventListener("keydown",this.#E)}render(){if(!this.#e)return;if(typeof this.value=="function"||typeof this.lowerValue=="function"||typeof this.upperValue=="function"){console.warn(`[slider-ui] .value / .lowerValue / .upperValue received a function. Did you mean:
132
132
  .value=\${fn()} \u2190 call the function to get the current value
133
133
  .value=\${signal.value} \u2190 read the signal's current value
134
134
  Functions are not auto-invoked at render time; the slider reads
135
135
  .value synchronously. See USAGE.md "Reactive binding" for the
136
- parent-template-re-read pattern that works across frameworks.`);return}if(this.dual){if(this.lowerValue>this.upperValue){let a=!Number.isNaN(this.#l)&&this.lowerValue!==this.#l;!Number.isNaN(this.#c)&&this.upperValue!==this.#c&&!a?this.upperValue=this.lowerValue:this.lowerValue=this.upperValue}this.#l=this.lowerValue,this.#c=this.upperValue;let i=this.#h(this.lowerValue),n=this.#h(this.upperValue);this.style.setProperty("--slider-pct-lower",String(i)),this.style.setProperty("--slider-pct-upper",String(n));let r=this.querySelector('[slot="value-lower"]'),o=this.querySelector('[slot="value-upper"]');r&&(r.textContent=this.#u(this.lowerValue)),o&&(o.textContent=this.#u(this.upperValue)),this.#s&&(this.#s.setAttribute("aria-valuenow",this.lowerValue),this.#s.setAttribute("aria-valuetext",`${this.#u(this.lowerValue)}${this.suffix?" "+this.suffix:""}`)),this.#n&&(this.#n.setAttribute("aria-valuenow",this.upperValue),this.#n.setAttribute("aria-valuetext",`${this.#u(this.upperValue)}${this.suffix?" "+this.suffix:""}`)),this.syncValue(`${this.lowerValue},${this.upperValue}`)}else{let i=this.#h(this.value);this.style.setProperty("--slider-pct",String(i));let n=this.querySelector('[slot="value"]');n&&(n.textContent=this.#u(this.value)),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.#u(this.value)}${this.suffix?" "+this.suffix:""}`),this.syncValue(String(this.value))}let t=this.querySelector('[slot="label"]');if(t)t.textContent=this.label;else if(this.label){let i=this.querySelector('[slot="header"]');if(i){let n=document.createElement("span");n.slot="label",n.textContent=this.label,i.prepend(n)}}this.label&&this.setAttribute("aria-label",this.label);let e=this.querySelector('[slot="suffix"]');e&&(e.textContent=this.suffix)}#d(t,e=null){let i=this.#i||this.#s||this.#n;if(!this.#e||!i)return this.min;let n=this.#e.getBoundingClientRect(),r=i.getBoundingClientRect().width,o=n.width,a,l;if(this.dual?(a=o-2*r,l=e==="upper"?1.5*r:.5*r):(a=o-r,l=.5*r),a<=0)return this.min;let h=t-n.left,c=Math.max(0,Math.min(1,(h-l)/a)),u=this.min+c*(this.max-this.min);return this.#p(u)}#f(t){if(!this.#e)return 0;let e=this.#i||this.#s||this.#n;if(!e)return 0;let i=this.#e.getBoundingClientRect(),n=e.getBoundingClientRect().width,r=i.width;if(this.dual){let o=r-2*n,a=t==="upper"?this.#h(this.upperValue):this.#h(this.lowerValue),l=t==="upper"?1.5*n:.5*n;return i.left+l+a*o}else return i.left+.5*n+this.#h(this.value)*(r-n)}#p(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#m(t){t!==this.value&&(this.value=t,this.scheduleThrottledInput())}#O(t){let e=Math.min(Math.max(t,this.min),this.upperValue);e!==this.lowerValue&&(this.lowerValue=e,this.scheduleThrottledInput())}#g(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#S(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#v=t=>{if(this.disabled)return;t.preventDefault(),this.#r=!0,this.setAttribute("dragging","");let e;if(this.dual){let i=t.currentTarget?.dataset?.thumb;this.#o=i==="upper"?"upper":"lower",e=this.#o==="lower"?this.#s:this.#n,e?.setAttribute("data-active","")}else e=this.#i;if(this.#e&&e){let i=this.dual?this.#o:null;this.#a=t.clientX-this.#f(i)}else this.#a=0;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.#x),e.addEventListener("pointerup",this.#b),e.addEventListener("pointercancel",this.#w),e.addEventListener("lostpointercapture",this.#w)};#x=t=>{if(!this.#r)return;let e=t.clientX-this.#a;if(this.dual){let i=this.#d(e,this.#o);this.#o==="lower"?this.#O(i):this.#g(i)}else this.#m(this.#d(e))};#w=t=>{this.#r&&this.#b(t)};#b=t=>{this.#r=!1,this.#a=0,this.removeAttribute("dragging");let e=this.dual?this.#o==="lower"?this.#s:this.#n:this.#i;try{e?.releasePointerCapture(t.pointerId)}catch{}e?.removeEventListener("pointermove",this.#x),e?.removeEventListener("pointerup",this.#b),e?.removeEventListener("pointercancel",this.#w),e?.removeEventListener("lostpointercapture",this.#w),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#S(),this.#o=null};#$=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#n)return;let e=Math.abs(t.clientX-this.#f("lower")),i=Math.abs(t.clientX-this.#f("upper"));e<=i?this.#O(this.#d(t.clientX,"lower")):this.#g(this.#d(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#d(t.clientX))}this.flushPendingInput(),this.#S()}};#C=t=>{if(this.disabled)return;let e=0,i=null;switch(t.key){case"ArrowRight":case"ArrowUp":e=this.step;break;case"ArrowLeft":case"ArrowDown":e=-this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"PageUp":e=this.step*10;break;case"PageDown":e=-this.step*10;break;default:return}if(t.preventDefault(),this.dual){let r=this.ownerDocument?.activeElement===this.#n?"upper":"lower",o=r==="lower"?this.lowerValue:this.upperValue,a=i!==null?i:o+e;a=this.#p(a),r==="lower"?this.#O(a):this.#g(a)}else{let n=i!==null?i:this.value+e;this.#m(this.#p(n))}this.flushPendingInput(),this.#S()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#v),this.#s?.removeEventListener("pointerdown",this.#v),this.#n?.removeEventListener("pointerdown",this.#v),this.#e?.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#C),this.#e=null,this.#i=null,this.#s=null,this.#n=null}};M();A("slider-ui",wn);var $$=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,C$=0;function mt(s,t,e={}){let{placement:i="bottom-start",gap:n=4,matchWidth:r=!1}=e;return $$?E$(s,t,{placement:i,gap:n,matchWidth:r}):T$(s,t,{placement:i,gap:n,matchWidth:r})}function E$(s,t,{placement:e,gap:i,matchWidth:n}){let r=`--a-anchor-${++C$}`,o=s.style.anchorName,a={position:t.style.position,positionAnchor:t.style.positionAnchor,positionArea:t.style.positionArea,positionTryFallbacks:t.style.positionTryFallbacks,margin:t.style.margin,width:t.style.width,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,overflowY:t.style.overflowY,top:t.style.top,left:t.style.left};s.style.anchorName=r;let l=e;if(e.startsWith("bottom")||e.startsWith("top")){let h=s.getBoundingClientRect(),u=window.innerHeight-h.bottom-i*2,d=h.top-i*2,f=xd(getComputedStyle(t).getPropertyValue("--popover-max-height")),p=Number.isFinite(f)?f:t.scrollHeight||0,m=e.startsWith("bottom"),g=p<=u,O=p<=d,w=m;m&&!g?w=O?!1:u>=d:!m&&!O&&(w=g?!0:u>d),l=e.replace(/^(bottom|top)/,w?"bottom":"top");let x=Math.max(40,Math.floor(w?u:d));t.style.maxHeight=`${Number.isFinite(f)?Math.min(f,x):x}px`}return t.style.position="fixed",t.style.positionAnchor=r,t.style.positionArea=Q$(l),t.style.margin=P$(l,i),t.style.positionTryFallbacks="flip-block, flip-inline, flip-block flip-inline",t.style.width=n?`anchor-size(${r} width)`:"max-content",t.style.maxWidth="min(calc(100vw - 1rem), var(--popover-max-width, 32rem))",!l.startsWith("bottom")&&!l.startsWith("top")&&(t.style.maxHeight="calc(100vh - 3rem)"),t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[h,c]of Object.entries(a))t.style[h]=c}}function xd(s){let t=String(s||"").trim();if(!t)return NaN;let e=/^(-?\d+(?:\.\d+)?)(px|rem)$/.exec(t);if(!e)return NaN;let i=parseFloat(e[1]);if(e[2]==="px")return i;let n=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return i*n}function P$(s,t){return s.startsWith("bottom")?`${t}px 0 0 0`:s.startsWith("top")?`0 0 ${t}px 0`:s.startsWith("left")?`0 ${t}px 0 0`:s.startsWith("right")?`0 0 0 ${t}px`:`${t}px`}function Q$(s){switch(s){case"bottom":return"bottom span-all";case"bottom-start":return"bottom span-right";case"bottom-end":return"bottom span-left";case"top":return"top span-all";case"top-start":return"top span-right";case"top-end":return"top span-left";case"left":return"left span-all";case"left-start":return"left span-bottom";case"left-end":return"left span-top";case"right":return"right span-all";case"right-start":return"right span-bottom";case"right-end":return"right span-top";default:return"bottom span-right"}}function T$(s,t,{placement:e,gap:i,matchWidth:n}){let r=t.style.maxHeight,o=t.style.overflowY;function a(){if(!s||!t)return;t.style.maxHeight=r,t.style.overflowY=o;let h=s.getBoundingClientRect(),c=t.getBoundingClientRect(),u=window.innerWidth,d=window.innerHeight,f=e;if(f.startsWith("bottom")||f.startsWith("top")){let g=d-h.bottom-i*2,O=h.top-i*2,w=f.startsWith("bottom"),x=c.height<=g,S=c.height<=O,v=w;w&&!x?v=S?!1:g>=O:!w&&!S&&(v=x?!0:g>O),f=f.replace(/^(bottom|top)/,v?"bottom":"top");let k=Math.max(0,Math.floor(v?g:O));c.height>k&&(t.style.maxHeight=`${k}px`,t.style.overflowY="auto",c=t.getBoundingClientRect())}let p,m;f.startsWith("top")?p=h.top-c.height-i:f.startsWith("bottom")?p=h.bottom+i:f.startsWith("left")?(m=h.left-c.width-i,f==="left-start"?p=h.top:f==="left-end"?p=h.bottom-c.height:p=h.top+(h.height-c.height)/2):f.startsWith("right")&&(m=h.right+i,f==="right-start"?p=h.top:f==="right-end"?p=h.bottom-c.height:p=h.top+(h.height-c.height)/2),m===void 0&&(f.endsWith("-start")?m=h.left:f.endsWith("-end")?m=h.right-c.width:m=h.left+(h.width-c.width)/2),m+c.width>u-i&&(m=h.right-c.width),m<i&&(m=h.left),(f.startsWith("left")||f.startsWith("right"))&&(p=Math.max(i,Math.min(p,d-c.height-i))),m=Math.max(i,Math.min(m,u-c.width-i)),t.style.position="fixed",t.style.top=`${p}px`,t.style.left=`${m}px`,n&&(t.style.width=`${h.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{a(),t.style.opacity=""});let l=L$(s);for(let h of l)h.addEventListener("scroll",a,{passive:!0});return window.addEventListener("resize",a,{passive:!0}),()=>{for(let h of l)h.removeEventListener("scroll",a);window.removeEventListener("resize",a),t.style.maxHeight=r,t.style.overflowY=o}}function L$(s){let t=[document],e=s?.parentElement;for(;e;){let i=getComputedStyle(e);/auto|scroll/.test(i.overflow+i.overflowX+i.overflowY)&&t.push(e),e=e.parentElement}return t}mi();function Rt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var kn=class s extends _{static labelDeprecated=!1;static requiredIcons=["caret-down","check","x"];static#t=new WeakSet;static properties={..._.properties,placeholder:{type:String,default:"Select...",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},labelHidden:{type:Boolean,default:!1,reflect:!0,attribute:"label-hidden"},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",reflect:!0},mark:{type:Boolean,default:!1,reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},searchable:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},divider:{type:Boolean,default:!1,reflect:!0},noRadio:{type:Boolean,default:!1,reflect:!0,attribute:"no-radio"},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},summaryLabel:{type:String,default:"",reflect:!0,attribute:"summary-label"},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:0,reflect:!0},selectAll:{type:Boolean,default:!1,reflect:!0,attribute:"select-all"},clearable:{type:Boolean,default:!1,reflect:!0}};static#e=0;static template=()=>null;#i=[];#s=!1;#n=null;#r=null;#o="";#a=null;#l=null;#c=null;#h=()=>{this.disabled||(this.open=!0)};#u=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#d=t=>{let e=t.currentTarget;t.stopPropagation();let i=e.__adiaOption;if(i&&!i.disabled){if(i.action){this.open=!1,this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{action:i.action}}));return}if(this.multiple){this.toggle(i.value);return}this.value=i.value,this.open=!1,this.#o="",this.syncValue(i.value),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}};syncValue(t){if(!this.multiple)return super.syncValue(t);let e=t??this.value??"";this.internals.setFormValue(e);let i=String(e).split(",").map(n=>n.trim()).filter(Boolean);if(this.min>0&&i.length<this.min){this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please select at least ${this.min}.`,this);return}if(this.max>0&&i.length>this.max){this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-max")||`Please select no more than ${this.max}.`,this);return}if(this.required&&i.length===0){this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this);return}this.internals.setValidity({})}#f(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#p(t){let e=new Set,i=[];for(let n of t){if(n==null||n==="")continue;let r=String(n);e.has(r)||(e.add(r),i.push(r))}return i.join(",")}toggle(t){if(!this.multiple){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}let e=this.#f(),i=e.indexOf(String(t)),n=e.slice(),r=[],o=[];if(i>=0)e.splice(i,1),o=[String(t)];else{if(this.max>0&&e.length>=this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:n,reason:"max"}}));return}e.push(String(t)),r=[String(t)]}let a=this.#p(e);this.value=a,this.syncValue(a),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e,added:r,removed:o}}))}selectAllOptions(){if(!this.multiple)return;let t=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null),e=this.#p(t.map(o=>o.value));if(e===this.value)return;let i=this.#f();this.value=e,this.syncValue(e),this.render();let n=this.#f(),r=n.filter(o=>!i.includes(o));this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,added:r,removed:[]}}))}clear(){if(!this.multiple){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:""}}));return}let t=this.#f();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#m(){let t=this.#f();if(t.length===0)return;let e=t.pop(),i=this.#p(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#O=t=>{if(!this.multiple)return;let e=t.target;if(!e||e.tagName!=="TAG-UI")return;let i=e.dataset.chipValue;if(!i)return;t.stopPropagation();let n=this.#f().filter(o=>o!==i),r=this.#p(n);this.value=r,this.syncValue(r),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,added:[],removed:[i]}}))};#g=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#S=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#v=t=>{if(t.stopPropagation(),this.disabled||this.readonly)return;let i=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null).map(o=>String(o.value)),n=new Set(this.#f());i.length>0&&i.every(o=>n.has(o))?this.clear():this.selectAllOptions()};#x=void 0;#w(){let t="Select...";if(this.labelHidden&&this.label){this.#x=Zt(this,this.#x,this.label);return}let n=!(!!this.label||this.hasAttribute("aria-labelledby"))&&this.placeholder&&this.placeholder!==t?this.placeholder:"";this.#x=Zt(this,this.#x,n)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#I),this.addEventListener("remove",this.#O),this.#i.length===0&&this.#C(),!this.#c&&typeof MutationObserver<"u"&&(this.#c=new MutationObserver(()=>{this.#i.length||!this.#$().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP")||(this.#C(),this.#i.length&&(this.#y(),this.#b()))})),this.#c?.observe(this,{childList:!0,subtree:!0})}render(){if(this.#w(),this.querySelector('[slot="trigger"]'))this.#b();else{this.#s=!0;let e=this.#n;e?.parentNode===this&&this.removeChild(e);let i=this.mark?'<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':this.avatar?`<img slot="leading" data-select-leading src="${Rt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${Rt(this.icon)}"></icon-ui>`:"",n=this.#L()===this.placeholder?"":this.#L(),r=this.searchable?`<span slot="display" contenteditable="plaintext-only" role="combobox" aria-autocomplete="list" tabindex="0" data-placeholder="${Rt(this.placeholder||"")}"${n?"":" data-empty"}>${Rt(n)}</span>`:`<span slot="display">${Rt(this.#L())}</span>`,o=this.hint?`select-hint-${++s.#e}`:"",a=this.hint?`<span slot="hint" id="${o}">${Rt(this.hint)}</span>`:"";this.innerHTML=`
136
+ parent-template-re-read pattern that works across frameworks.`);return}if(this.dual){if(this.lowerValue>this.upperValue){let a=!Number.isNaN(this.#l)&&this.lowerValue!==this.#l;!Number.isNaN(this.#c)&&this.upperValue!==this.#c&&!a?this.upperValue=this.lowerValue:this.lowerValue=this.upperValue}this.#l=this.lowerValue,this.#c=this.upperValue;let i=this.#h(this.lowerValue),n=this.#h(this.upperValue);this.style.setProperty("--slider-pct-lower",String(i)),this.style.setProperty("--slider-pct-upper",String(n));let r=this.querySelector('[slot="value-lower"]'),o=this.querySelector('[slot="value-upper"]');r&&(r.textContent=this.#u(this.lowerValue)),o&&(o.textContent=this.#u(this.upperValue)),this.#s&&(this.#s.setAttribute("aria-valuenow",this.lowerValue),this.#s.setAttribute("aria-valuetext",`${this.#u(this.lowerValue)}${this.suffix?" "+this.suffix:""}`)),this.#n&&(this.#n.setAttribute("aria-valuenow",this.upperValue),this.#n.setAttribute("aria-valuetext",`${this.#u(this.upperValue)}${this.suffix?" "+this.suffix:""}`)),this.syncValue(`${this.lowerValue},${this.upperValue}`)}else{let i=this.#h(this.value);this.style.setProperty("--slider-pct",String(i));let n=this.querySelector('[slot="value"]');n&&(n.textContent=this.#u(this.value)),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.#u(this.value)}${this.suffix?" "+this.suffix:""}`),this.syncValue(String(this.value))}let t=this.querySelector('[slot="label"]');if(t)t.textContent=this.label;else if(this.label){let i=this.querySelector('[slot="header"]');if(i){let n=document.createElement("span");n.slot="label",n.textContent=this.label,i.prepend(n)}}this.label&&this.setAttribute("aria-label",this.label);let e=this.querySelector('[slot="suffix"]');e&&(e.textContent=this.suffix)}#d(t,e=null){let i=this.#i||this.#s||this.#n;if(!this.#e||!i)return this.min;let n=this.#e.getBoundingClientRect(),r=i.getBoundingClientRect().width,o=n.width,a,l;if(this.dual?(a=o-2*r,l=e==="upper"?1.5*r:.5*r):(a=o-r,l=.5*r),a<=0)return this.min;let h=t-n.left,c=Math.max(0,Math.min(1,(h-l)/a)),u=this.min+c*(this.max-this.min);return this.#p(u)}#f(t){if(!this.#e)return 0;let e=this.#i||this.#s||this.#n;if(!e)return 0;let i=this.#e.getBoundingClientRect(),n=e.getBoundingClientRect().width,r=i.width;if(this.dual){let o=r-2*n,a=t==="upper"?this.#h(this.upperValue):this.#h(this.lowerValue),l=t==="upper"?1.5*n:.5*n;return i.left+l+a*o}else return i.left+.5*n+this.#h(this.value)*(r-n)}#p(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#m(t){t!==this.value&&(this.value=t,this.scheduleThrottledInput())}#g(t){let e=Math.min(Math.max(t,this.min),this.upperValue);e!==this.lowerValue&&(this.lowerValue=e,this.scheduleThrottledInput())}#O(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#S(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#b=t=>{if(this.disabled)return;t.preventDefault(),this.#r=!0,this.setAttribute("dragging","");let e;if(this.dual){let i=t.currentTarget?.dataset?.thumb;this.#o=i==="upper"?"upper":"lower",e=this.#o==="lower"?this.#s:this.#n,e?.setAttribute("data-active","")}else e=this.#i;if(this.#e&&e){let i=this.dual?this.#o:null;this.#a=t.clientX-this.#f(i)}else this.#a=0;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.#x),e.addEventListener("pointerup",this.#y),e.addEventListener("pointercancel",this.#w),e.addEventListener("lostpointercapture",this.#w)};#x=t=>{if(!this.#r)return;let e=t.clientX-this.#a;if(this.dual){let i=this.#d(e,this.#o);this.#o==="lower"?this.#g(i):this.#O(i)}else this.#m(this.#d(e))};#w=t=>{this.#r&&this.#y(t)};#y=t=>{this.#r=!1,this.#a=0,this.removeAttribute("dragging");let e=this.dual?this.#o==="lower"?this.#s:this.#n:this.#i;try{e?.releasePointerCapture(t.pointerId)}catch{}e?.removeEventListener("pointermove",this.#x),e?.removeEventListener("pointerup",this.#y),e?.removeEventListener("pointercancel",this.#w),e?.removeEventListener("lostpointercapture",this.#w),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#S(),this.#o=null};#A=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#n)return;let e=Math.abs(t.clientX-this.#f("lower")),i=Math.abs(t.clientX-this.#f("upper"));e<=i?this.#g(this.#d(t.clientX,"lower")):this.#O(this.#d(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#d(t.clientX))}this.flushPendingInput(),this.#S()}};#E=t=>{if(this.disabled)return;let e=0,i=null;switch(t.key){case"ArrowRight":case"ArrowUp":e=this.step;break;case"ArrowLeft":case"ArrowDown":e=-this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"PageUp":e=this.step*10;break;case"PageDown":e=-this.step*10;break;default:return}if(t.preventDefault(),this.dual){let r=this.ownerDocument?.activeElement===this.#n?"upper":"lower",o=r==="lower"?this.lowerValue:this.upperValue,a=i!==null?i:o+e;a=this.#p(a),r==="lower"?this.#g(a):this.#O(a)}else{let n=i!==null?i:this.value+e;this.#m(this.#p(n))}this.flushPendingInput(),this.#S()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#b),this.#s?.removeEventListener("pointerdown",this.#b),this.#n?.removeEventListener("pointerdown",this.#b),this.#e?.removeEventListener("click",this.#A),this.removeEventListener("keydown",this.#E),this.#e=null,this.#i=null,this.#s=null,this.#n=null}};M();A("slider-ui",wn);var $$=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,C$=0;function mt(s,t,e={}){let{placement:i="bottom-start",gap:n=4,matchWidth:r=!1}=e;return $$?E$(s,t,{placement:i,gap:n,matchWidth:r}):T$(s,t,{placement:i,gap:n,matchWidth:r})}function E$(s,t,{placement:e,gap:i,matchWidth:n}){let r=`--a-anchor-${++C$}`,o=s.style.anchorName,a={position:t.style.position,positionAnchor:t.style.positionAnchor,positionArea:t.style.positionArea,positionTryFallbacks:t.style.positionTryFallbacks,margin:t.style.margin,width:t.style.width,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,overflowY:t.style.overflowY,top:t.style.top,left:t.style.left};s.style.anchorName=r;let l=e;if(e.startsWith("bottom")||e.startsWith("top")){let h=s.getBoundingClientRect(),u=window.innerHeight-h.bottom-i*2,d=h.top-i*2,f=xd(getComputedStyle(t).getPropertyValue("--popover-max-height")),p=Number.isFinite(f)?f:t.scrollHeight||0,m=e.startsWith("bottom"),g=p<=u,O=p<=d,w=m;m&&!g?w=O?!1:u>=d:!m&&!O&&(w=g?!0:u>d),l=e.replace(/^(bottom|top)/,w?"bottom":"top");let x=Math.max(40,Math.floor(w?u:d));t.style.maxHeight=`${Number.isFinite(f)?Math.min(f,x):x}px`}return t.style.position="fixed",t.style.positionAnchor=r,t.style.positionArea=Q$(l),t.style.margin=P$(l,i),t.style.positionTryFallbacks="flip-block, flip-inline, flip-block flip-inline",t.style.width=n?`anchor-size(${r} width)`:"max-content",t.style.maxWidth="min(calc(100vw - 1rem), var(--popover-max-width, 32rem))",!l.startsWith("bottom")&&!l.startsWith("top")&&(t.style.maxHeight="calc(100vh - 3rem)"),t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName===r&&(s.style.anchorName=o);for(let[h,c]of Object.entries(a))t.style[h]=c}}function xd(s){let t=String(s||"").trim();if(!t)return NaN;let e=/^(-?\d+(?:\.\d+)?)(px|rem)$/.exec(t);if(!e)return NaN;let i=parseFloat(e[1]);if(e[2]==="px")return i;let n=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return i*n}function P$(s,t){return s.startsWith("bottom")?`${t}px 0 0 0`:s.startsWith("top")?`0 0 ${t}px 0`:s.startsWith("left")?`0 ${t}px 0 0`:s.startsWith("right")?`0 0 0 ${t}px`:`${t}px`}function Q$(s){switch(s){case"bottom":return"bottom span-all";case"bottom-start":return"bottom span-right";case"bottom-end":return"bottom span-left";case"top":return"top span-all";case"top-start":return"top span-right";case"top-end":return"top span-left";case"left":return"left span-all";case"left-start":return"left span-bottom";case"left-end":return"left span-top";case"right":return"right span-all";case"right-start":return"right span-bottom";case"right-end":return"right span-top";default:return"bottom span-right"}}function T$(s,t,{placement:e,gap:i,matchWidth:n}){let r=t.style.maxHeight,o=t.style.overflowY;function a(){if(!s||!t)return;t.style.maxHeight=r,t.style.overflowY=o;let h=s.getBoundingClientRect(),c=t.getBoundingClientRect(),u=window.innerWidth,d=window.innerHeight,f=e;if(f.startsWith("bottom")||f.startsWith("top")){let g=d-h.bottom-i*2,O=h.top-i*2,w=f.startsWith("bottom"),x=c.height<=g,S=c.height<=O,v=w;w&&!x?v=S?!1:g>=O:!w&&!S&&(v=x?!0:g>O),f=f.replace(/^(bottom|top)/,v?"bottom":"top");let k=Math.max(0,Math.floor(v?g:O));c.height>k&&(t.style.maxHeight=`${k}px`,t.style.overflowY="auto",c=t.getBoundingClientRect())}let p,m;f.startsWith("top")?p=h.top-c.height-i:f.startsWith("bottom")?p=h.bottom+i:f.startsWith("left")?(m=h.left-c.width-i,f==="left-start"?p=h.top:f==="left-end"?p=h.bottom-c.height:p=h.top+(h.height-c.height)/2):f.startsWith("right")&&(m=h.right+i,f==="right-start"?p=h.top:f==="right-end"?p=h.bottom-c.height:p=h.top+(h.height-c.height)/2),m===void 0&&(f.endsWith("-start")?m=h.left:f.endsWith("-end")?m=h.right-c.width:m=h.left+(h.width-c.width)/2),m+c.width>u-i&&(m=h.right-c.width),m<i&&(m=h.left),(f.startsWith("left")||f.startsWith("right"))&&(p=Math.max(i,Math.min(p,d-c.height-i))),m=Math.max(i,Math.min(m,u-c.width-i)),t.style.position="fixed",t.style.top=`${p}px`,t.style.left=`${m}px`,n&&(t.style.width=`${h.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{a(),t.style.opacity=""});let l=L$(s);for(let h of l)h.addEventListener("scroll",a,{passive:!0});return window.addEventListener("resize",a,{passive:!0}),()=>{for(let h of l)h.removeEventListener("scroll",a);window.removeEventListener("resize",a),t.style.maxHeight=r,t.style.overflowY=o}}function L$(s){let t=[document],e=s?.parentElement;for(;e;){let i=getComputedStyle(e);/auto|scroll/.test(i.overflow+i.overflowX+i.overflowY)&&t.push(e),e=e.parentElement}return t}mi();function Rt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var kn=class s extends _{static labelDeprecated=!1;static requiredIcons=["caret-down","check","x"];static#t=new WeakSet;static properties={..._.properties,placeholder:{type:String,default:"Select...",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},labelHidden:{type:Boolean,default:!1,reflect:!0,attribute:"label-hidden"},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",reflect:!0},mark:{type:Boolean,default:!1,reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},searchable:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},divider:{type:Boolean,default:!1,reflect:!0},noRadio:{type:Boolean,default:!1,reflect:!0,attribute:"no-radio"},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},summaryLabel:{type:String,default:"",reflect:!0,attribute:"summary-label"},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:0,reflect:!0},selectAll:{type:Boolean,default:!1,reflect:!0,attribute:"select-all"},clearable:{type:Boolean,default:!1,reflect:!0}};static#e=0;static template=()=>null;#i=[];#s=!1;#n=null;#r=null;#o="";#a=null;#l=null;#c=null;#h=()=>{this.disabled||(this.open=!0)};#u=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#d=t=>{let e=t.currentTarget;t.stopPropagation();let i=e.__adiaOption;if(i&&!i.disabled){if(i.action){this.open=!1,this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{action:i.action}}));return}if(this.multiple){this.toggle(i.value);return}this.value=i.value,this.open=!1,this.#o="",this.syncValue(i.value),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}};syncValue(t){if(!this.multiple)return super.syncValue(t);let e=t??this.value??"";this.internals.setFormValue(e);let i=String(e).split(",").map(n=>n.trim()).filter(Boolean);if(this.min>0&&i.length<this.min){this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please select at least ${this.min}.`,this);return}if(this.max>0&&i.length>this.max){this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-max")||`Please select no more than ${this.max}.`,this);return}if(this.required&&i.length===0){this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this);return}this.internals.setValidity({})}#f(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#p(t){let e=new Set,i=[];for(let n of t){if(n==null||n==="")continue;let r=String(n);e.has(r)||(e.add(r),i.push(r))}return i.join(",")}toggle(t){if(!this.multiple){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}let e=this.#f(),i=e.indexOf(String(t)),n=e.slice(),r=[],o=[];if(i>=0)e.splice(i,1),o=[String(t)];else{if(this.max>0&&e.length>=this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:n,reason:"max"}}));return}e.push(String(t)),r=[String(t)]}let a=this.#p(e);this.value=a,this.syncValue(a),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e,added:r,removed:o}}))}selectAllOptions(){if(!this.multiple)return;let t=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null),e=this.#p(t.map(o=>o.value));if(e===this.value)return;let i=this.#f();this.value=e,this.syncValue(e),this.render();let n=this.#f(),r=n.filter(o=>!i.includes(o));this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,added:r,removed:[]}}))}clear(){if(!this.multiple){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:""}}));return}let t=this.#f();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#m(){let t=this.#f();if(t.length===0)return;let e=t.pop(),i=this.#p(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#g=t=>{if(!this.multiple)return;let e=t.target;if(!e||e.tagName!=="TAG-UI")return;let i=e.dataset.chipValue;if(!i)return;t.stopPropagation();let n=this.#f().filter(o=>o!==i),r=this.#p(n);this.value=r,this.syncValue(r),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,added:[],removed:[i]}}))};#O=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#S=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#b=t=>{if(t.stopPropagation(),this.disabled||this.readonly)return;let i=this.#i.flatMap(o=>o.options||[o]).filter(o=>!o.disabled&&!o.separator&&!o.header&&o.value!=null).map(o=>String(o.value)),n=new Set(this.#f());i.length>0&&i.every(o=>n.has(o))?this.clear():this.selectAllOptions()};#x=void 0;#w(){let t="Select...";if(this.labelHidden&&this.label){this.#x=Zt(this,this.#x,this.label);return}let n=!(!!this.label||this.hasAttribute("aria-labelledby"))&&this.placeholder&&this.placeholder!==t?this.placeholder:"";this.#x=Zt(this,this.#x,n)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#I),this.addEventListener("remove",this.#g),this.#i.length===0&&this.#E(),!this.#c&&typeof MutationObserver<"u"&&(this.#c=new MutationObserver(()=>{this.#i.length||!this.#A().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP")||(this.#E(),this.#i.length&&(this.#v(),this.#y()))})),this.#c?.observe(this,{childList:!0,subtree:!0})}render(){if(this.#w(),this.querySelector('[slot="trigger"]'))this.#y();else{this.#s=!0;let e=this.#n;e?.parentNode===this&&this.removeChild(e);let i=this.mark?'<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':this.avatar?`<img slot="leading" data-select-leading src="${Rt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${Rt(this.icon)}"></icon-ui>`:"",n=this.#M()===this.placeholder?"":this.#M(),r=this.searchable?`<span slot="display" contenteditable="plaintext-only" role="combobox" aria-autocomplete="list" tabindex="0" data-placeholder="${Rt(this.placeholder||"")}"${n?"":" data-empty"}>${Rt(n)}</span>`:`<span slot="display">${Rt(this.#M())}</span>`,o=this.hint?`select-hint-${++s.#e}`:"",a=this.hint?`<span slot="hint" id="${o}">${Rt(this.hint)}</span>`:"";this.innerHTML=`
137
137
  <span slot="trigger">
138
138
  ${i}
139
139
  <span data-chips></span>
@@ -142,7 +142,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
142
142
  <icon-ui name="caret-down" slot="caret"></icon-ui>
143
143
  </span>
144
144
  ${a}
145
- `,this.hint&&this.setAttribute("aria-describedby",o);let l=this.querySelector("[data-clear-all]");l&&(l.removeEventListener("click",this.#S),l.addEventListener("click",this.#S)),this.searchable&&(this.#a&&(this.#a.removeEventListener("input",this.#R),this.#a.removeEventListener("focus",this.#h),this.#a.removeEventListener("click",this.#u)),this.#a=this.querySelector('[slot="display"][contenteditable]'),this.#a&&(this.#a.addEventListener("input",this.#R),this.#a.addEventListener("focus",this.#h),this.#a.addEventListener("click",this.#u))),e&&this.appendChild(e)}this.#k(),this.multiple&&this.#T();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#f().length>0&&!this.disabled&&!this.readonly?t.removeAttribute("hidden"):t.setAttribute("hidden","")),this.#n||(this.#n=this.querySelector('[slot="listbox"]'),this.#n||(this.#n=document.createElement("div"),this.#n.setAttribute("slot","listbox"),this.#n.setAttribute("role","listbox"),this.#n.setAttribute("popover","manual"),this.appendChild(this.#n)),this.#y()),this.#n){let e=this.multiple?new Set(this.value.split(",").map(i=>i.trim()).filter(Boolean)):null;for(let i of this.#n.querySelectorAll('[role="option"]')){let n=i.getAttribute("data-value");n!==null&&(e?e.has(n):n===this.value)?i.setAttribute("aria-selected","true"):i.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#n?.showPopover?.();let e=this.querySelector('[slot="trigger"]')||this;this.#n.style.minWidth=`${e.getBoundingClientRect().width}px`,this.#n.style.width="max-content",this.#r=mt(e,this.#n,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#M,{once:!0})})}else this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#M)}#b(){let t=this.querySelector('[slot="display"]');if(t)if(this.multiple){let e=this.#f().length>0;t.hasAttribute("contenteditable")?(t.setAttribute("data-placeholder",e?"":this.placeholder||""),this.#o||(t.textContent="",t.toggleAttribute("data-empty",!0))):t.textContent=e?"":this.placeholder||""}else if(t.hasAttribute("contenteditable")){if(!this.#o){let e=this.#L()===this.placeholder?"":this.#L();t.textContent=e,t.toggleAttribute("data-empty",!e)}}else t.textContent=this.#L()}#$(){let t=[],e=i=>{for(let n of i.children)if(!n.hasAttribute("slot")){if(n.tagName==="OPTION"||n.tagName==="OPTGROUP"){t.push(n);continue}if(n.matches('[role="presentation"]')||n.style?.display==="contents"){e(n);continue}t.push(n)}};return e(this),t}#C(){this.#i=[];let t=new Set,e=[];for(let i of this.#$())if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled,icon:r.getAttribute("icon")||"",avatar:r.getAttribute("avatar")||"",mark:r.hasAttribute("mark")}),r.hasAttribute("selected")&&e.push(r.value);this.#i.push(n)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled,icon:i.getAttribute("icon")||"",avatar:i.getAttribute("avatar")||"",mark:i.hasAttribute("mark")}),i.hasAttribute("selected")&&e.push(i.value)):i.hasAttribute("slot")||t.add(i.tagName.toLowerCase());for(let i of[...this.querySelectorAll("option, optgroup")])i.remove();!this.value&&e.length&&(this.value=this.multiple?e.join(","):e[0]),t.size>0&&!s.#t.has(this)&&(s.#t.add(this),console.warn(`<select-ui>: ignoring unrecognized child element(s) [${[...t].join(", ")}]. Consumer-authored children must be native <option> or <optgroup>, NOT <select-option> or other <*-ui> shapes. Or set element.options = [...] programmatically. (Once-per-element warn; see select.yaml usage: for details.)`))}set options(t){Mt(()=>{this.#i=t,this.#n||(this.#n=this.querySelector('[slot="listbox"]'),this.#n||(this.#n=document.createElement("div"),this.#n.setAttribute("slot","listbox"),this.#n.setAttribute("role","listbox"),this.#n.setAttribute("popover","manual"),this.appendChild(this.#n))),this.#y(),this.#b(),this.#k()})}get options(){return this.#i}static#P(t){return t?t.mark?'<adia-mark-ui data-select-mark size="sm"></adia-mark-ui>':t.avatar?`<img data-option-avatar src="${Rt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Rt(t.icon)}"></icon-ui>`:"":""}#k(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(u=>u.options||[u]).find(u=>!u.header&&!u.separator&&u.value===this.value),n=i&&i.mark||this.mark||!1,r=i&&i.avatar||this.avatar||"",o=i&&i.icon||this.icon||"",a=t.querySelector(":scope > [data-select-leading]"),l="";if(n?l='<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':r?l=`<img slot="leading" data-select-leading src="${Rt(r)}" alt="" />`:o&&(l=`<icon-ui slot="leading" data-select-leading name="${Rt(o)}"></icon-ui>`),!l){a?.remove();return}let h=document.createElement("template");h.innerHTML=l;let c=h.content.firstElementChild;a?a.tagName===c.tagName?c.tagName==="IMG"?a.getAttribute("src")!==c.getAttribute("src")&&a.setAttribute("src",c.getAttribute("src")):a.getAttribute("name")!==c.getAttribute("name")&&a.setAttribute("name",c.getAttribute("name")):a.replaceWith(c):t.insertBefore(c,t.firstChild)}#y(){if(!this.#n)return;if(this.#n.innerHTML="",this.multiple?this.#n.setAttribute("aria-multiselectable","true"):this.#n.removeAttribute("aria-multiselectable"),this.multiple&&this.selectAll){let e=document.createElement("div");e.setAttribute("data-select-all","");let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("size","xs"),i.dataset.selectAllBtn="",i.setAttribute("text",this.#A()?"Clear":"Select all"),i.addEventListener("click",this.#v),e.appendChild(i),this.#n.appendChild(e)}let t=e=>{if(e.separator){let a=document.createElement("hr");return a.setAttribute("data-separator",""),a}let i=document.createElement("div");i.setAttribute("role","option"),e.action||i.setAttribute("data-value",e.value||"");let n=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,r=!e.action&&(n?n.has(e.value):e.value===this.value),o=s.#P(e);if(e.action){i.setAttribute("data-action-option","");let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Rt(e.label)}`:a.textContent=e.label,i.appendChild(a)}else if(this.multiple){i.setAttribute("data-multi-option","");let a=document.createElement("span");a.setAttribute("data-checkbox",""),a.innerHTML='<icon-ui name="check" aria-hidden="true"></icon-ui>',i.appendChild(a);let l=document.createElement("span");l.setAttribute("data-option-label",""),o?l.innerHTML=`${o}${Rt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else{if(i.setAttribute("data-single-option",""),!(this.noRadio||this.mark)){let l=document.createElement("span");l.setAttribute("data-radio",""),l.setAttribute("aria-hidden","true"),i.appendChild(l)}let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Rt(e.label)}`:a.textContent=e.label,i.appendChild(a)}return r&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#d),i};for(let e of this.#i)if(e.separator)this.#n.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${Rt(e.label)}</strong><span>${Rt(e.description||"")}</span></div>`:`<div><strong>${Rt(e.label)}</strong><span>${Rt(e.description||"")}</span></div>`,this.#n.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${Rt(e.label)}</div>`;for(let n of e.options)i.appendChild(t(n));this.#n.appendChild(i)}else this.#n.appendChild(t(e));if(this.#i.length===0){let e=document.createElement("div");e.setAttribute("data-empty",""),e.textContent="No options",this.#n.appendChild(e)}this.#o&&this.#X()}#A(){if(!this.multiple)return!1;let t=this.#i.flatMap(i=>i.options||[i]).filter(i=>!i.disabled&&!i.separator&&!i.header&&i.value!=null);if(t.length===0)return!1;let e=new Set(this.#f());return t.every(i=>e.has(String(i.value)))}#T(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;if(this.summaryLabel){for(;t.firstChild;)t.removeChild(t.firstChild);return}let e=this.#f(),i=Number(this.maxChips)||0,n=i>0&&e.length>i?e.slice(0,i):e,r=i>0&&e.length>i?e.length-i:0,o=a=>this.#E(a);for(;t.firstChild;)t.removeChild(t.firstChild);for(let a of n){let l=document.createElement("tag-ui");l.setAttribute("size","sm"),!this.disabled&&!this.readonly&&l.setAttribute("removable",""),l.dataset.chipValue=String(a),l.setAttribute("text",o(a)),t.appendChild(l)}if(r>0){let a=document.createElement("button-ui");a.setAttribute("variant","ghost"),a.setAttribute("size","xs"),a.dataset.more="",a.setAttribute("text",`+${r} more`),a.addEventListener("click",this.#g),t.appendChild(a)}}#E(t){let i=this.#i.flatMap(n=>n.options||[n]).filter(n=>!n.separator&&!n.header&&n.value!=null).find(n=>String(n.value)===String(t));return i?i.label:String(t)}#L(){if(this.multiple){if(this.summaryLabel){let i=this.#f();return i.length===0?this.placeholder:i.length===1?this.#E(i[0]):`${this.summaryLabel} (${i.length})`}return this.value?"":this.placeholder}return this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#Q=t=>{this.disabled||this.#n&&t.composedPath().includes(this.#n)||(this.open=!this.open)};#M=t=>{!this.contains(t.target)&&!(this.#n&&t.composedPath().includes(this.#n))&&(this.open=!1)};#I=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.hasAttribute?.("contenteditable")&&e.getAttribute("slot")==="display",n=!this.#o||this.#o.length===0;if((!i||n)&&this.#f().length>0){t.preventDefault(),this.#m();return}}if(t.key==="Escape"){if(this.searchable&&this.#o){this.#o="";let e=this.querySelector('[slot="display"][contenteditable]');e&&(e.textContent="",e.toggleAttribute("data-empty",!0)),this.#X();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#n?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click(),this.multiple&&(this.open=!1);else if(this.searchable&&this.freeText&&this.#o){let i=this.#o;this.value=i,this.#o="",this.open=!1,this.syncValue?.(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}else this.open=!1}else this.open=!0;return}if(t.key===" "&&!this.searchable){if(t.preventDefault(),this.open){let e=this.#n?.querySelector('[role="option"][data-focused]');e?e.click():this.multiple||(this.open=!1)}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#N(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#N(-1))};#R=t=>{let e=t.target.textContent||"";this.#o=e,t.target.toggleAttribute("data-empty",!e),this.open||(this.open=!0),this.#X()};#X(){if(!this.#n)return;let t=o=>o.toLowerCase().replace(/_/g," "),e=t(this.#o),i=this.#n.querySelectorAll('[role="option"]'),n=!1;for(let o of i){let a=t(o.textContent||"");!e||a.includes(e)?(o.removeAttribute("data-filtered-out"),o.style.display="",n=!0):(o.setAttribute("data-filtered-out",""),o.style.display="none")}for(let o of this.#n.querySelectorAll('[role="group"]')){let a=o.querySelectorAll('[role="option"]:not([data-filtered-out])').length;o.style.display=a?"":"none"}let r=this.#n.querySelector('[role="option"][data-focused]');r&&r.hasAttribute("data-filtered-out")&&r.removeAttribute("data-focused")}#N(t){if(!this.#n)return;let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#n.querySelector('[role="option"][data-focused]'),n=i?e.indexOf(i):-1,r=e[(n+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),r&&(r.setAttribute("data-focused",""),r.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#I),this.removeEventListener("remove",this.#O),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#M),this.#a&&(this.#a.removeEventListener("input",this.#R),this.#a.removeEventListener("focus",this.#h),this.#a.removeEventListener("click",this.#u),this.#a=null),this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#n=null}};M();A("select-ui",kn);X();var An=class extends C{static properties={value:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","radio"),this.getAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.setAttribute("aria-checked",this.selected?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t?.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("aria-hidden","true"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};M();A("segment-ui",An);var $n=class s extends _{static properties={..._.properties,multiple:{type:Boolean,default:!1,reflect:!0},value:{type:String,default:"",reflect:!0},allowEmpty:{type:Boolean,default:!1,reflect:!0,attribute:"allow-empty"}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role",this.multiple?"group":"radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#u),this.addEventListener("keydown",this.#f)),!this.multiple&&!this.value&&!this.allowEmpty){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#c(this.#o)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#c(this.#o)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n?.disconnect(),this.#n=null,this.#r&&(this.#r=null),this.removeEventListener("click",this.#u),this.removeEventListener("keydown",this.#f),this.#e=null,this.#i=!1}get#o(){return[...this.querySelectorAll("segment-ui")]}get#a(){return this.#o.filter(t=>!t.disabled)}get#l(){return new Set(this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[])}render(){if(this.setAttribute("role",this.multiple?"group":"radiogroup"),!s.#t.has(this)){let n=[...this.children].find(r=>r.tagName!=="SEGMENT-UI"&&!r.hasAttribute("data-indicator")&&!(r.tagName==="SPAN"&&r.style.display==="contents"));n&&(s.#t.add(this),console.warn(`[segmented-ui] child <${n.tagName.toLowerCase()}> is not <segment-ui> \u2014 bare <segment> tags render text but receive no sliding indicator or aria-checked state. Use <segment-ui>.`))}let t=this.#o;if(!t.length)return;let e=this.multiple?this.#l:null,i=!1;for(let n of t){let r=n.value||n.getAttribute("value")||"",o=this.multiple?e.has(r):r===this.value;n.setAttribute("role",this.multiple?"checkbox":"radio"),o?(n.setAttribute("selected",""),i=!0):n.removeAttribute("selected"),n.setAttribute("tabindex",o?"0":"-1")}i||t.find(r=>!r.disabled)?.setAttribute("tabindex","0"),this.label&&this.setAttribute("aria-label",this.label),this.#c(t)}#c(t){if(this.multiple){for(let n of this.querySelectorAll(":scope > [data-indicator]"))n.remove();this.#e=null,this.removeAttribute("data-indicator-ready");return}let e=t.findIndex(n=>(n.value||n.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e||!this.contains(this.#e);if(i){for(let n of this.querySelectorAll(":scope > [data-indicator]"))n.remove();this.#e=document.createElement("span"),this.#e.setAttribute("data-indicator",""),this.prepend(this.#e)}this.style.setProperty("--_segment-count",`${t.length}`),i?(this.#e.style.transition="none",this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#e&&(this.#e.style.transition="")})):(this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""))}#h(t){if(t.disabled)return;let e=t.value||t.getAttribute("value")||"";if(this.multiple){if(!e)return;let i=this.#l;i.has(e)?i.delete(e):i.add(e),this.value=[...i].join(",")}else this.value=e;this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}#u=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#h(e)};#d(t,e){let i=this.#a,n=i.indexOf(t);if(n<0)return null;switch(e){case"ArrowRight":case"ArrowDown":return i[n<i.length-1?n+1:0];case"ArrowLeft":case"ArrowUp":return i[n>0?n-1:i.length-1];case"Home":return i[0];case"End":return i[i.length-1];default:return null}}#f=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;if(this.multiple){if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.#h(e);return}let n=this.#d(e,t.key);if(!n)return;t.preventDefault(),n.focus();return}let i=this.#d(e,t.key);i&&(t.preventDefault(),i.focus(),this.#h(i))}};M();A("segmented-ui",$n);var Cn=class extends _{static labelDeprecated=!1;static properties={..._.properties,value:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:100,reflect:!0},step:{type:Number,default:1,reflect:!0},label:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=0;#n=0;#r=void 0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
145
+ `,this.hint&&this.setAttribute("aria-describedby",o);let l=this.querySelector("[data-clear-all]");l&&(l.removeEventListener("click",this.#S),l.addEventListener("click",this.#S)),this.searchable&&(this.#a&&(this.#a.removeEventListener("input",this.#L),this.#a.removeEventListener("focus",this.#h),this.#a.removeEventListener("click",this.#u)),this.#a=this.querySelector('[slot="display"][contenteditable]'),this.#a&&(this.#a.addEventListener("input",this.#L),this.#a.addEventListener("focus",this.#h),this.#a.addEventListener("click",this.#u))),e&&this.appendChild(e)}this.#k(),this.multiple&&this.#T();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#f().length>0&&!this.disabled&&!this.readonly?t.removeAttribute("hidden"):t.setAttribute("hidden","")),this.#n||(this.#n=this.querySelector('[slot="listbox"]'),this.#n||(this.#n=document.createElement("div"),this.#n.setAttribute("slot","listbox"),this.#n.setAttribute("role","listbox"),this.#n.setAttribute("popover","manual"),this.appendChild(this.#n)),this.#v()),this.#n){let e=this.multiple?new Set(this.value.split(",").map(i=>i.trim()).filter(Boolean)):null;for(let i of this.#n.querySelectorAll('[role="option"]')){let n=i.getAttribute("data-value");n!==null&&(e?e.has(n):n===this.value)?i.setAttribute("aria-selected","true"):i.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#n?.showPopover?.();let e=this.querySelector('[slot="trigger"]')||this;this.#n.style.minWidth=`${e.getBoundingClientRect().width}px`,this.#n.style.width="max-content",this.#r=mt(e,this.#n,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#R,{once:!0})})}else this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#R)}#y(){let t=this.querySelector('[slot="display"]');if(t)if(this.multiple){let e=this.#f().length>0;t.hasAttribute("contenteditable")?(t.setAttribute("data-placeholder",e?"":this.placeholder||""),this.#o||(t.textContent="",t.toggleAttribute("data-empty",!0))):t.textContent=e?"":this.placeholder||""}else if(t.hasAttribute("contenteditable")){if(!this.#o){let e=this.#M()===this.placeholder?"":this.#M();t.textContent=e,t.toggleAttribute("data-empty",!e)}}else t.textContent=this.#M()}#A(){let t=[],e=i=>{for(let n of i.children)if(!n.hasAttribute("slot")){if(n.tagName==="OPTION"||n.tagName==="OPTGROUP"){t.push(n);continue}if(n.matches('[role="presentation"]')||n.style?.display==="contents"){e(n);continue}t.push(n)}};return e(this),t}#E(){this.#i=[];let t=new Set,e=[];for(let i of this.#A())if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled,icon:r.getAttribute("icon")||"",avatar:r.getAttribute("avatar")||"",mark:r.hasAttribute("mark")}),r.hasAttribute("selected")&&e.push(r.value);this.#i.push(n)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled,icon:i.getAttribute("icon")||"",avatar:i.getAttribute("avatar")||"",mark:i.hasAttribute("mark")}),i.hasAttribute("selected")&&e.push(i.value)):i.hasAttribute("slot")||t.add(i.tagName.toLowerCase());for(let i of[...this.querySelectorAll("option, optgroup")])i.remove();!this.value&&e.length&&(this.value=this.multiple?e.join(","):e[0]),t.size>0&&!s.#t.has(this)&&(s.#t.add(this),console.warn(`<select-ui>: ignoring unrecognized child element(s) [${[...t].join(", ")}]. Consumer-authored children must be native <option> or <optgroup>, NOT <select-option> or other <*-ui> shapes. Or set element.options = [...] programmatically. (Once-per-element warn; see select.yaml usage: for details.)`))}set options(t){Mt(()=>{this.#i=t,this.#n||(this.#n=this.querySelector('[slot="listbox"]'),this.#n||(this.#n=document.createElement("div"),this.#n.setAttribute("slot","listbox"),this.#n.setAttribute("role","listbox"),this.#n.setAttribute("popover","manual"),this.appendChild(this.#n))),this.#v(),this.#y(),this.#k()})}get options(){return this.#i}static#P(t){return t?t.mark?'<adia-mark-ui data-select-mark size="sm"></adia-mark-ui>':t.avatar?`<img data-option-avatar src="${Rt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Rt(t.icon)}"></icon-ui>`:"":""}#k(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(u=>u.options||[u]).find(u=>!u.header&&!u.separator&&u.value===this.value),n=i&&i.mark||this.mark||!1,r=i&&i.avatar||this.avatar||"",o=i&&i.icon||this.icon||"",a=t.querySelector(":scope > [data-select-leading]"),l="";if(n?l='<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':r?l=`<img slot="leading" data-select-leading src="${Rt(r)}" alt="" />`:o&&(l=`<icon-ui slot="leading" data-select-leading name="${Rt(o)}"></icon-ui>`),!l){a?.remove();return}let h=document.createElement("template");h.innerHTML=l;let c=h.content.firstElementChild;a?a.tagName===c.tagName?c.tagName==="IMG"?a.getAttribute("src")!==c.getAttribute("src")&&a.setAttribute("src",c.getAttribute("src")):a.getAttribute("name")!==c.getAttribute("name")&&a.setAttribute("name",c.getAttribute("name")):a.replaceWith(c):t.insertBefore(c,t.firstChild)}#v(){if(!this.#n)return;if(this.#n.innerHTML="",this.multiple?this.#n.setAttribute("aria-multiselectable","true"):this.#n.removeAttribute("aria-multiselectable"),this.multiple&&this.selectAll){let e=document.createElement("div");e.setAttribute("data-select-all","");let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("size","xs"),i.dataset.selectAllBtn="",i.setAttribute("text",this.#$()?"Clear":"Select all"),i.addEventListener("click",this.#b),e.appendChild(i),this.#n.appendChild(e)}let t=e=>{if(e.separator){let a=document.createElement("hr");return a.setAttribute("data-separator",""),a}let i=document.createElement("div");i.setAttribute("role","option"),e.action||i.setAttribute("data-value",e.value||"");let n=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,r=!e.action&&(n?n.has(e.value):e.value===this.value),o=s.#P(e);if(e.action){i.setAttribute("data-action-option","");let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Rt(e.label)}`:a.textContent=e.label,i.appendChild(a)}else if(this.multiple){i.setAttribute("data-multi-option","");let a=document.createElement("span");a.setAttribute("data-checkbox",""),a.innerHTML='<icon-ui name="check" aria-hidden="true"></icon-ui>',i.appendChild(a);let l=document.createElement("span");l.setAttribute("data-option-label",""),o?l.innerHTML=`${o}${Rt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else{if(i.setAttribute("data-single-option",""),!(this.noRadio||this.mark)){let l=document.createElement("span");l.setAttribute("data-radio",""),l.setAttribute("aria-hidden","true"),i.appendChild(l)}let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Rt(e.label)}`:a.textContent=e.label,i.appendChild(a)}return r&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#d),i};for(let e of this.#i)if(e.separator)this.#n.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${Rt(e.label)}</strong><span>${Rt(e.description||"")}</span></div>`:`<div><strong>${Rt(e.label)}</strong><span>${Rt(e.description||"")}</span></div>`,this.#n.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${Rt(e.label)}</div>`;for(let n of e.options)i.appendChild(t(n));this.#n.appendChild(i)}else this.#n.appendChild(t(e));if(this.#i.length===0){let e=document.createElement("div");e.setAttribute("data-empty",""),e.textContent="No options",this.#n.appendChild(e)}this.#o&&this.#X()}#$(){if(!this.multiple)return!1;let t=this.#i.flatMap(i=>i.options||[i]).filter(i=>!i.disabled&&!i.separator&&!i.header&&i.value!=null);if(t.length===0)return!1;let e=new Set(this.#f());return t.every(i=>e.has(String(i.value)))}#T(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;if(this.summaryLabel){for(;t.firstChild;)t.removeChild(t.firstChild);return}let e=this.#f(),i=Number(this.maxChips)||0,n=i>0&&e.length>i?e.slice(0,i):e,r=i>0&&e.length>i?e.length-i:0,o=a=>this.#C(a);for(;t.firstChild;)t.removeChild(t.firstChild);for(let a of n){let l=document.createElement("tag-ui");l.setAttribute("size","sm"),!this.disabled&&!this.readonly&&l.setAttribute("removable",""),l.dataset.chipValue=String(a),l.setAttribute("text",o(a)),t.appendChild(l)}if(r>0){let a=document.createElement("button-ui");a.setAttribute("variant","ghost"),a.setAttribute("size","xs"),a.dataset.more="",a.setAttribute("text",`+${r} more`),a.addEventListener("click",this.#O),t.appendChild(a)}}#C(t){let i=this.#i.flatMap(n=>n.options||[n]).filter(n=>!n.separator&&!n.header&&n.value!=null).find(n=>String(n.value)===String(t));return i?i.label:String(t)}#M(){if(this.multiple){if(this.summaryLabel){let i=this.#f();return i.length===0?this.placeholder:i.length===1?this.#C(i[0]):`${this.summaryLabel} (${i.length})`}return this.value?"":this.placeholder}return this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#Q=t=>{this.disabled||this.#n&&t.composedPath().includes(this.#n)||(this.open=!this.open)};#R=t=>{!this.contains(t.target)&&!(this.#n&&t.composedPath().includes(this.#n))&&(this.open=!1)};#I=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.hasAttribute?.("contenteditable")&&e.getAttribute("slot")==="display",n=!this.#o||this.#o.length===0;if((!i||n)&&this.#f().length>0){t.preventDefault(),this.#m();return}}if(t.key==="Escape"){if(this.searchable&&this.#o){this.#o="";let e=this.querySelector('[slot="display"][contenteditable]');e&&(e.textContent="",e.toggleAttribute("data-empty",!0)),this.#X();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#n?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click(),this.multiple&&(this.open=!1);else if(this.searchable&&this.freeText&&this.#o){let i=this.#o;this.value=i,this.#o="",this.open=!1,this.syncValue?.(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}else this.open=!1}else this.open=!0;return}if(t.key===" "&&!this.searchable){if(t.preventDefault(),this.open){let e=this.#n?.querySelector('[role="option"][data-focused]');e?e.click():this.multiple||(this.open=!1)}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#N(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#N(-1))};#L=t=>{let e=t.target.textContent||"";this.#o=e,t.target.toggleAttribute("data-empty",!e),this.open||(this.open=!0),this.#X()};#X(){if(!this.#n)return;let t=o=>o.toLowerCase().replace(/_/g," "),e=t(this.#o),i=this.#n.querySelectorAll('[role="option"]'),n=!1;for(let o of i){let a=t(o.textContent||"");!e||a.includes(e)?(o.removeAttribute("data-filtered-out"),o.style.display="",n=!0):(o.setAttribute("data-filtered-out",""),o.style.display="none")}for(let o of this.#n.querySelectorAll('[role="group"]')){let a=o.querySelectorAll('[role="option"]:not([data-filtered-out])').length;o.style.display=a?"":"none"}let r=this.#n.querySelector('[role="option"][data-focused]');r&&r.hasAttribute("data-filtered-out")&&r.removeAttribute("data-focused")}#N(t){if(!this.#n)return;let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#n.querySelector('[role="option"][data-focused]'),n=i?e.indexOf(i):-1,r=e[(n+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),r&&(r.setAttribute("data-focused",""),r.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#I),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#R),this.#a&&(this.#a.removeEventListener("input",this.#L),this.#a.removeEventListener("focus",this.#h),this.#a.removeEventListener("click",this.#u),this.#a=null),this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#n=null}};M();A("select-ui",kn);X();var An=class extends C{static properties={value:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","radio"),this.getAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.setAttribute("aria-checked",this.selected?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t?.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("aria-hidden","true"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};M();A("segment-ui",An);var $n=class s extends _{static properties={..._.properties,multiple:{type:Boolean,default:!1,reflect:!0},value:{type:String,default:"",reflect:!0},allowEmpty:{type:Boolean,default:!1,reflect:!0,attribute:"allow-empty"}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role",this.multiple?"group":"radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#u),this.addEventListener("keydown",this.#f)),!this.multiple&&!this.value&&!this.allowEmpty){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#c(this.#o)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#c(this.#o)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n?.disconnect(),this.#n=null,this.#r&&(this.#r=null),this.removeEventListener("click",this.#u),this.removeEventListener("keydown",this.#f),this.#e=null,this.#i=!1}get#o(){return[...this.querySelectorAll("segment-ui")]}get#a(){return this.#o.filter(t=>!t.disabled)}get#l(){return new Set(this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[])}render(){if(this.setAttribute("role",this.multiple?"group":"radiogroup"),!s.#t.has(this)){let n=[...this.children].find(r=>r.tagName!=="SEGMENT-UI"&&!r.hasAttribute("data-indicator")&&!(r.tagName==="SPAN"&&r.style.display==="contents"));n&&(s.#t.add(this),console.warn(`[segmented-ui] child <${n.tagName.toLowerCase()}> is not <segment-ui> \u2014 bare <segment> tags render text but receive no sliding indicator or aria-checked state. Use <segment-ui>.`))}let t=this.#o;if(!t.length)return;let e=this.multiple?this.#l:null,i=!1;for(let n of t){let r=n.value||n.getAttribute("value")||"",o=this.multiple?e.has(r):r===this.value;n.setAttribute("role",this.multiple?"checkbox":"radio"),o?(n.setAttribute("selected",""),i=!0):n.removeAttribute("selected"),n.setAttribute("tabindex",o?"0":"-1")}i||t.find(r=>!r.disabled)?.setAttribute("tabindex","0"),this.label&&this.setAttribute("aria-label",this.label),this.#c(t)}#c(t){if(this.multiple){for(let n of this.querySelectorAll(":scope > [data-indicator]"))n.remove();this.#e=null,this.removeAttribute("data-indicator-ready");return}let e=t.findIndex(n=>(n.value||n.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e||!this.contains(this.#e);if(i){for(let n of this.querySelectorAll(":scope > [data-indicator]"))n.remove();this.#e=document.createElement("span"),this.#e.setAttribute("data-indicator",""),this.prepend(this.#e)}this.style.setProperty("--_segment-count",`${t.length}`),i?(this.#e.style.transition="none",this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#e&&(this.#e.style.transition="")})):(this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""))}#h(t){if(t.disabled)return;let e=t.value||t.getAttribute("value")||"";if(this.multiple){if(!e)return;let i=this.#l;i.has(e)?i.delete(e):i.add(e),this.value=[...i].join(",")}else this.value=e;this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}#u=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#h(e)};#d(t,e){let i=this.#a,n=i.indexOf(t);if(n<0)return null;switch(e){case"ArrowRight":case"ArrowDown":return i[n<i.length-1?n+1:0];case"ArrowLeft":case"ArrowUp":return i[n>0?n-1:i.length-1];case"Home":return i[0];case"End":return i[i.length-1];default:return null}}#f=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;if(this.multiple){if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.#h(e);return}let n=this.#d(e,t.key);if(!n)return;t.preventDefault(),n.focus();return}let i=this.#d(e,t.key);i&&(t.preventDefault(),i.focus(),this.#h(i))}};M();A("segmented-ui",$n);var Cn=class extends _{static labelDeprecated=!1;static properties={..._.properties,value:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:100,reflect:!0},step:{type:Number,default:1,reflect:!0},label:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=0;#n=0;#r=void 0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
146
146
  <span slot="label">${this.label}</span>
147
147
  <span slot="value">${this.#o(this.value)}</span>
148
148
  ${this.suffix?`<span slot="suffix">${this.suffix}</span>`:""}
@@ -151,7 +151,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
151
151
  <div slot="layer" data-layer="base">${t}</div>
152
152
  <div slot="layer" data-layer="fill" aria-hidden="true">${t}</div>
153
153
  </div>
154
- `}this.#t=this.querySelector('[slot="field"]'),this.#e=this.querySelector('[data-layer="base"] [slot="value"]'),this.#t&&this.#t.addEventListener("pointerdown",this.#h),this.addEventListener("keydown",this.#f)}render(){if(!this.#t)return;let t=this.#o(this.value);this.#e&&(this.#e.textContent=t);let e=this.querySelector('[data-layer="fill"] [slot="value"]');e&&(e.textContent=t);let i=this.max-this.min,n=i>0?(this.value-this.min)/i*100:0;this.style.setProperty("--range-fill-pct",`${n}%`),this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.value}${this.suffix?" "+this.suffix:""}`),this.#r=Zt(this,this.#r,this.label||""),this.syncValue(String(this.value))}#o(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}#a(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#l(t){let e=this.#a(t);e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})))}#c(t){let e=this.#t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-e.left)/e.width));return this.#a(this.min+i*(this.max-this.min))}#h=t=>{this.disabled||(t.preventDefault(),this.#l(this.#c(t.clientX)),this.#i=!0,this.#s=t.clientX,this.#n=this.value,this.setAttribute("dragging",""),this.#t.setPointerCapture(t.pointerId),this.#t.addEventListener("pointermove",this.#u),this.#t.addEventListener("pointerup",this.#d))};#u=t=>{if(!this.#i)return;let e=t.clientX-this.#s,i=this.#t.getBoundingClientRect().width,n=this.max-this.min,r=e/i*n;this.#l(this.#n+r)};#d=t=>{this.#i=!1,this.removeAttribute("dragging"),this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#u),this.#t.removeEventListener("pointerup",this.#d),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#f=t=>{if(this.disabled)return;let e=this.value;switch(t.key){case"ArrowRight":case"ArrowUp":e+=this.step;break;case"ArrowLeft":case"ArrowDown":e-=this.step;break;case"Home":e=this.min;break;case"End":e=this.max;break;case"PageUp":e+=this.step*10;break;case"PageDown":e-=this.step*10;break;default:return}t.preventDefault(),this.#l(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};disconnected(){super.disconnected(),this.#t?.removeEventListener("pointerdown",this.#h),this.#t?.removeEventListener("pointermove",this.#u),this.#t?.removeEventListener("pointerup",this.#d),this.removeEventListener("keydown",this.#f),this.#t=null,this.#e=null}};M();A("range-ui",Cn);X();Ge();var En=class extends C{static requiredIcons=["caret-right"];static template=()=>null;connected(){this.setAttribute("role","tree"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}get selectedItem(){return this.querySelector("tree-item-ui[selected]")}select(t,e=null){let i=this.selectedItem;i&&i!==t&&i.removeAttribute("selected"),t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("tree-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value,ctrlKey:!!e?.ctrlKey,metaKey:!!e?.metaKey,shiftKey:!!e?.shiftKey}}))}#t(t){if(!t)return null;if(te(t))return t.matches?.("tree-item-ui")?t:null;if(typeof t=="string"){let e=t.replace(/"/g,'\\"');return this.querySelector(`tree-item-ui[value="${e}"]`)||this.querySelector(`tree-item-ui[text="${e}"]`)||null}return null}expand(t){let e=this.#t(t);e&&e.hasChildren&&!e.open&&(e.open=!0)}collapse(t){let e=this.#t(t);e&&e.open&&(e.open=!1)}expandAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.hasChildren&&!t.open&&(t.open=!0)}collapseAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.open&&(t.open=!1)}expandTo(t){let e=this.#t(t);if(!e)return;let i=e.parentElement?.closest("tree-item-ui");for(;i;)i.hasChildren&&!i.open&&(i.open=!0),i=i.parentElement?.closest("tree-item-ui");e.querySelector(':scope > [slot="row"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})}#e=t=>{let e=t.target.closest("tree-item-ui");if(!e||!this.contains(e)||t.target.closest('[slot="actions"] *'))return;let i=e.querySelector(':scope > [slot="row"]');!i||!(t.target===i||i.contains(t.target))||(this.select(e,t),e.hasChildren&&(e.open=!e.open))};#i=t=>{let e=t.target.closest("tree-item-ui");if(e)switch(t.key){case"ArrowRight":if(t.preventDefault(),e.hasChildren&&!e.open)e.open=!0;else{let i=e.querySelector(":scope > tree-item-ui");i&&i.querySelector('[slot="row"]')?.focus()}break;case"ArrowLeft":if(t.preventDefault(),e.hasChildren&&e.open)e.open=!1;else{let i=e.parentElement?.closest("tree-item-ui");i&&i.querySelector(':scope > [slot="row"]')?.focus()}break;case"ArrowDown":{t.preventDefault();let i=this.#s(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"ArrowUp":{t.preventDefault();let i=this.#n(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"Enter":case" ":t.preventDefault(),this.select(e,t);break}};#s(t){if(t.open&&t.hasChildren)return t.querySelector(":scope > tree-item-ui");let e=t;for(;e;){let i=e.nextElementSibling;if(i&&i.matches("tree-item-ui"))return i;e=e.parentElement?.closest("tree-item-ui")}return null}#n(t){let e=t.previousElementSibling;if(e&&e.matches("tree-item-ui")){let n=e;for(;n.open&&n.hasChildren;){let r=n.querySelectorAll(":scope > tree-item-ui");n=r[r.length-1]}return n}return t.parentElement?.closest("tree-item-ui")||null}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}},Pn=class extends C{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},badge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;get hasChildren(){return this.querySelector(":scope > tree-item-ui")!==null}get depth(){let t=0,e=this.parentElement;for(;e;)e.matches("tree-item-ui")&&t++,e=e.parentElement;return t}connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="row"]')||this.#i();let t=this.querySelector(':scope > [slot="row"]');t&&(t.setAttribute("role","treeitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0")),this.#n(),typeof MutationObserver<"u"&&(this.#t=new MutationObserver(()=>this.#n()),this.#t.observe(this,{childList:!0,subtree:!0}))}#i(){let t=document.createElement("div");t.setAttribute("slot","row"),t.setAttribute("tabindex","0");let e=this.#s("caret")[0];if(e)t.appendChild(e);else{let o=document.createElement("icon-ui");o.setAttribute("slot","caret"),o.setAttribute("name","caret-right"),o.dataset.treeCaretDefault="1",t.appendChild(o)}if(this.icon){let o=document.createElement("icon-ui");o.setAttribute("name",this.icon),o.setAttribute("slot","icon"),t.appendChild(o)}let i=document.createElement("span");i.setAttribute("slot","text"),i.textContent=this.text,t.appendChild(i);let n=document.createElement("span");n.setAttribute("slot","badge"),this.badge&&(n.textContent=this.badge),t.appendChild(n);let r=document.createElement("span");r.setAttribute("slot","actions"),r.dataset.treeActionsPlaceholder="1",t.appendChild(r),this.prepend(t)}render(){let t=this.querySelector(':scope > [slot="row"]');if(!t)return;t.style.paddingInlineStart=`${this.depth*16+4}px`,this.hasChildren?t.setAttribute("aria-expanded",String(this.open)):t.removeAttribute("aria-expanded"),this.selected?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected");let e=t.querySelector('[slot="text"]');e&&this.text&&(e.textContent=this.text);let i=t.querySelector('[slot="badge"]');i&&(i.textContent=this.badge||"")}#s(t){let e=[],i=n=>{for(let r of n.children)if(!r.matches("tree-item-ui")){if(r.getAttribute("slot")===t){e.push(r);continue}(r.matches('[role="presentation"]')||r.style?.display==="contents")&&i(r)}};return i(this),e}#n(){if(this.#e)return;let t=this.querySelector(':scope > [slot="row"]');if(t){this.#e=!0;try{let e=this.#s("actions").filter(n=>!n.dataset.treeActionsPlaceholder&&n.parentElement!==t);if(e.length){t.querySelector(':scope > [slot="actions"][data-tree-actions-placeholder]')?.remove();for(let n of e)t.appendChild(n)}let i=this.#s("caret").find(n=>!n.dataset.treeCaretDefault&&n.parentElement!==t);i&&(t.querySelector(':scope > [slot="caret"][data-tree-caret-default]')?.remove(),t.prepend(i))}finally{this.#t?.takeRecords(),this.#e=!1}}}disconnected(){this.#t?.disconnect(),this.#t=null}};M();A("tree-ui",En),A("tree-item-ui",Pn);X();Ge();var Qn=class extends C{static requiredIcons=["caret-left","caret-right","magnifying-glass"];static properties={rootLabel:{type:String,default:"",reflect:!0,attribute:"root-label"},filterable:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Filter\u2026",reflect:!0},selectOnDrill:{type:Boolean,default:!1,reflect:!0,attribute:"select-on-drill"},static:{type:Boolean,default:!1,reflect:!0}};static get observedAttributes(){return[...super.observedAttributes,"path"]}static template=()=>null;#t=[];#e=new WeakMap;#i=new WeakMap;#s=[];#n="";#r=!1;#o=null;#a=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=new WeakMap;#O=null;#g=null;#S=[];#v=!1;get items(){return this.#t}set items(t){this.#t=Array.isArray(t)?t:[],this.#e=new WeakMap,this.#i=new WeakMap,this.#r&&this.#y(null)}get path(){return[...this.#S]}set path(t){this.#x(Array.isArray(t)?t.map(String):[],!1)}#x(t,e){let i=this.#S,n=i.length!==t.length||t.some((o,a)=>o!==i[a]),r=null;n&&(t.length>i.length&&i.every((o,a)=>o===t[a])?r="forward":i.length>t.length&&t.every((o,a)=>o===i[a])&&(r="backward")),this.#S=t,e||(this.#v=!0,t.length?this.setAttribute("path",JSON.stringify(t)):this.removeAttribute("path"),this.#v=!1),this.#r&&(this.#y(r),n&&this.dispatchEvent(new CustomEvent("navigate",{bubbles:!0,detail:{path:[...t]}})))}attributeChangedCallback(t,e,i){if(t==="path"){if(this.#v)return;let n=[];try{let r=JSON.parse(i??"[]");Array.isArray(r)&&(n=r.map(String))}catch{}this.#x(n,!0);return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","group"),this.addEventListener("keydown",this.#q),this.hasAttribute("path")){let t=[];try{let e=JSON.parse(this.getAttribute("path")??"[]");Array.isArray(e)&&(t=e.map(String))}catch{}this.#S=t}}render(){this.#r||this.#w(),this.#y(null)}disconnected(){this.removeEventListener("keydown",this.#q),this.#u?.removeEventListener("input",this.#Z),this.#o?.removeEventListener("click",this.#N),this.#d?.removeEventListener("click",this.#B),this.#d=null,this.#u=null,this.#o=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#f=null,this.#p=null}#w(){this.innerHTML=`
154
+ `}this.#t=this.querySelector('[slot="field"]'),this.#e=this.querySelector('[data-layer="base"] [slot="value"]'),this.#t&&this.#t.addEventListener("pointerdown",this.#h),this.addEventListener("keydown",this.#f)}render(){if(!this.#t)return;let t=this.#o(this.value);this.#e&&(this.#e.textContent=t);let e=this.querySelector('[data-layer="fill"] [slot="value"]');e&&(e.textContent=t);let i=this.max-this.min,n=i>0?(this.value-this.min)/i*100:0;this.style.setProperty("--range-fill-pct",`${n}%`),this.setAttribute("aria-valuemin",this.min),this.setAttribute("aria-valuemax",this.max),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.value}${this.suffix?" "+this.suffix:""}`),this.#r=Zt(this,this.#r,this.label||""),this.syncValue(String(this.value))}#o(t){let e=(String(this.step).split(".")[1]||"").length;return e>0?t.toFixed(e):String(t)}#a(t){let e=Math.round((t-this.min)/this.step)*this.step+this.min;return Math.max(this.min,Math.min(this.max,parseFloat(e.toFixed(10))))}#l(t){let e=this.#a(t);e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})))}#c(t){let e=this.#t.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t-e.left)/e.width));return this.#a(this.min+i*(this.max-this.min))}#h=t=>{this.disabled||(t.preventDefault(),this.#l(this.#c(t.clientX)),this.#i=!0,this.#s=t.clientX,this.#n=this.value,this.setAttribute("dragging",""),this.#t.setPointerCapture(t.pointerId),this.#t.addEventListener("pointermove",this.#u),this.#t.addEventListener("pointerup",this.#d))};#u=t=>{if(!this.#i)return;let e=t.clientX-this.#s,i=this.#t.getBoundingClientRect().width,n=this.max-this.min,r=e/i*n;this.#l(this.#n+r)};#d=t=>{this.#i=!1,this.removeAttribute("dragging"),this.#t.releasePointerCapture(t.pointerId),this.#t.removeEventListener("pointermove",this.#u),this.#t.removeEventListener("pointerup",this.#d),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#f=t=>{if(this.disabled)return;let e=this.value;switch(t.key){case"ArrowRight":case"ArrowUp":e+=this.step;break;case"ArrowLeft":case"ArrowDown":e-=this.step;break;case"Home":e=this.min;break;case"End":e=this.max;break;case"PageUp":e+=this.step*10;break;case"PageDown":e-=this.step*10;break;default:return}t.preventDefault(),this.#l(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};disconnected(){super.disconnected(),this.#t?.removeEventListener("pointerdown",this.#h),this.#t?.removeEventListener("pointermove",this.#u),this.#t?.removeEventListener("pointerup",this.#d),this.removeEventListener("keydown",this.#f),this.#t=null,this.#e=null}};M();A("range-ui",Cn);X();Ge();var En=class extends C{static requiredIcons=["caret-right"];static template=()=>null;connected(){this.setAttribute("role","tree"),this.addEventListener("click",this.#e),this.addEventListener("keydown",this.#i)}get selectedItem(){return this.querySelector("tree-item-ui[selected]")}select(t,e=null){let i=this.selectedItem;i&&i!==t&&i.removeAttribute("selected"),t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("tree-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value,ctrlKey:!!e?.ctrlKey,metaKey:!!e?.metaKey,shiftKey:!!e?.shiftKey}}))}#t(t){if(!t)return null;if(te(t))return t.matches?.("tree-item-ui")?t:null;if(typeof t=="string"){let e=t.replace(/"/g,'\\"');return this.querySelector(`tree-item-ui[value="${e}"]`)||this.querySelector(`tree-item-ui[text="${e}"]`)||null}return null}expand(t){let e=this.#t(t);e&&e.hasChildren&&!e.open&&(e.open=!0)}collapse(t){let e=this.#t(t);e&&e.open&&(e.open=!1)}expandAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.hasChildren&&!t.open&&(t.open=!0)}collapseAll(){for(let t of this.querySelectorAll("tree-item-ui"))t.open&&(t.open=!1)}expandTo(t){let e=this.#t(t);if(!e)return;let i=e.parentElement?.closest("tree-item-ui");for(;i;)i.hasChildren&&!i.open&&(i.open=!0),i=i.parentElement?.closest("tree-item-ui");e.querySelector(':scope > [slot="row"]')?.scrollIntoView?.({block:"nearest",inline:"nearest"})}#e=t=>{let e=t.target.closest("tree-item-ui");if(!e||!this.contains(e)||t.target.closest('[slot="actions"] *'))return;let i=e.querySelector(':scope > [slot="row"]');!i||!(t.target===i||i.contains(t.target))||(this.select(e,t),e.hasChildren&&(e.open=!e.open))};#i=t=>{let e=t.target.closest("tree-item-ui");if(e)switch(t.key){case"ArrowRight":if(t.preventDefault(),e.hasChildren&&!e.open)e.open=!0;else{let i=e.querySelector(":scope > tree-item-ui");i&&i.querySelector('[slot="row"]')?.focus()}break;case"ArrowLeft":if(t.preventDefault(),e.hasChildren&&e.open)e.open=!1;else{let i=e.parentElement?.closest("tree-item-ui");i&&i.querySelector(':scope > [slot="row"]')?.focus()}break;case"ArrowDown":{t.preventDefault();let i=this.#s(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"ArrowUp":{t.preventDefault();let i=this.#n(e);i&&i.querySelector(':scope > [slot="row"]')?.focus();break}case"Enter":case" ":t.preventDefault(),this.select(e,t);break}};#s(t){if(t.open&&t.hasChildren)return t.querySelector(":scope > tree-item-ui");let e=t;for(;e;){let i=e.nextElementSibling;if(i&&i.matches("tree-item-ui"))return i;e=e.parentElement?.closest("tree-item-ui")}return null}#n(t){let e=t.previousElementSibling;if(e&&e.matches("tree-item-ui")){let n=e;for(;n.open&&n.hasChildren;){let r=n.querySelectorAll(":scope > tree-item-ui");n=r[r.length-1]}return n}return t.parentElement?.closest("tree-item-ui")||null}disconnected(){this.removeEventListener("click",this.#e),this.removeEventListener("keydown",this.#i)}},Pn=class extends C{static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},badge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;get hasChildren(){return this.querySelector(":scope > tree-item-ui")!==null}get depth(){let t=0,e=this.parentElement;for(;e;)e.matches("tree-item-ui")&&t++,e=e.parentElement;return t}connected(){this.setAttribute("role","group"),this.querySelector(':scope > [slot="row"]')||this.#i();let t=this.querySelector(':scope > [slot="row"]');t&&(t.setAttribute("role","treeitem"),t.hasAttribute("tabindex")||t.setAttribute("tabindex","0")),this.#n(),typeof MutationObserver<"u"&&(this.#t=new MutationObserver(()=>this.#n()),this.#t.observe(this,{childList:!0,subtree:!0}))}#i(){let t=document.createElement("div");t.setAttribute("slot","row"),t.setAttribute("tabindex","0");let e=this.#s("caret")[0];if(e)t.appendChild(e);else{let o=document.createElement("icon-ui");o.setAttribute("slot","caret"),o.setAttribute("name","caret-right"),o.dataset.treeCaretDefault="1",t.appendChild(o)}if(this.icon){let o=document.createElement("icon-ui");o.setAttribute("name",this.icon),o.setAttribute("slot","icon"),t.appendChild(o)}let i=document.createElement("span");i.setAttribute("slot","text"),i.textContent=this.text,t.appendChild(i);let n=document.createElement("span");n.setAttribute("slot","badge"),this.badge&&(n.textContent=this.badge),t.appendChild(n);let r=document.createElement("span");r.setAttribute("slot","actions"),r.dataset.treeActionsPlaceholder="1",t.appendChild(r),this.prepend(t)}render(){let t=this.querySelector(':scope > [slot="row"]');if(!t)return;t.style.paddingInlineStart=`${this.depth*16+4}px`,this.hasChildren?t.setAttribute("aria-expanded",String(this.open)):t.removeAttribute("aria-expanded"),this.selected?t.setAttribute("aria-selected","true"):t.removeAttribute("aria-selected");let e=t.querySelector('[slot="text"]');e&&this.text&&(e.textContent=this.text);let i=t.querySelector('[slot="badge"]');i&&(i.textContent=this.badge||"")}#s(t){let e=[],i=n=>{for(let r of n.children)if(!r.matches("tree-item-ui")){if(r.getAttribute("slot")===t){e.push(r);continue}(r.matches('[role="presentation"]')||r.style?.display==="contents")&&i(r)}};return i(this),e}#n(){if(this.#e)return;let t=this.querySelector(':scope > [slot="row"]');if(t){this.#e=!0;try{let e=this.#s("actions").filter(n=>!n.dataset.treeActionsPlaceholder&&n.parentElement!==t);if(e.length){t.querySelector(':scope > [slot="actions"][data-tree-actions-placeholder]')?.remove();for(let n of e)t.appendChild(n)}let i=this.#s("caret").find(n=>!n.dataset.treeCaretDefault&&n.parentElement!==t);i&&(t.querySelector(':scope > [slot="caret"][data-tree-caret-default]')?.remove(),t.prepend(i))}finally{this.#t?.takeRecords(),this.#e=!1}}}disconnected(){this.#t?.disconnect(),this.#t=null}};M();A("tree-ui",En),A("tree-item-ui",Pn);X();Ge();var Qn=class extends C{static requiredIcons=["caret-left","caret-right","magnifying-glass"];static properties={rootLabel:{type:String,default:"",reflect:!0,attribute:"root-label"},filterable:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Filter\u2026",reflect:!0},selectOnDrill:{type:Boolean,default:!1,reflect:!0,attribute:"select-on-drill"},static:{type:Boolean,default:!1,reflect:!0}};static get observedAttributes(){return[...super.observedAttributes,"path"]}static template=()=>null;#t=[];#e=new WeakMap;#i=new WeakMap;#s=[];#n="";#r=!1;#o=null;#a=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=new WeakMap;#g=null;#O=null;#S=[];#b=!1;get items(){return this.#t}set items(t){this.#t=Array.isArray(t)?t:[],this.#e=new WeakMap,this.#i=new WeakMap,this.#r&&this.#v(null)}get path(){return[...this.#S]}set path(t){this.#x(Array.isArray(t)?t.map(String):[],!1)}#x(t,e){let i=this.#S,n=i.length!==t.length||t.some((o,a)=>o!==i[a]),r=null;n&&(t.length>i.length&&i.every((o,a)=>o===t[a])?r="forward":i.length>t.length&&t.every((o,a)=>o===i[a])&&(r="backward")),this.#S=t,e||(this.#b=!0,t.length?this.setAttribute("path",JSON.stringify(t)):this.removeAttribute("path"),this.#b=!1),this.#r&&(this.#v(r),n&&this.dispatchEvent(new CustomEvent("navigate",{bubbles:!0,detail:{path:[...t]}})))}attributeChangedCallback(t,e,i){if(t==="path"){if(this.#b)return;let n=[];try{let r=JSON.parse(i??"[]");Array.isArray(r)&&(n=r.map(String))}catch{}this.#x(n,!0);return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","group"),this.addEventListener("keydown",this.#q),this.hasAttribute("path")){let t=[];try{let e=JSON.parse(this.getAttribute("path")??"[]");Array.isArray(e)&&(t=e.map(String))}catch{}this.#S=t}}render(){this.#r||this.#w(),this.#v(null)}disconnected(){this.removeEventListener("keydown",this.#q),this.#u?.removeEventListener("input",this.#Z),this.#o?.removeEventListener("click",this.#N),this.#d?.removeEventListener("click",this.#B),this.#d=null,this.#u=null,this.#o=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#f=null,this.#p=null}#w(){this.innerHTML=`
155
155
  <div slot="header">
156
156
  <button-ui slot="back" icon="caret-left" variant="ghost" size="sm" hidden>
157
157
  <span data-back-label></span>
@@ -170,13 +170,13 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
170
170
  <div slot="panel" role="listbox"></div>
171
171
  </div>
172
172
  <div slot="live" aria-live="polite" data-visually-hidden></div>
173
- `,this.#o=this.querySelector('[slot="back"]'),this.#a=this.querySelector("[data-back-label]"),this.#l=this.querySelector("[data-level-title]"),this.#c=this.querySelector("[data-level-count]"),this.#h=this.querySelector('[slot="filter"]'),this.#u=this.querySelector('[slot="filter"] input-ui'),this.#d=this.querySelector('[slot="panel"]'),this.#f=this.querySelector('[slot="live"]'),this.#p=this.querySelector('[slot="breadcrumb"]');let t=[...this.children].find(e=>e.getAttribute("slot")==="breadcrumb"&&e.parentElement===this);t&&t!==this.#p&&(this.#p.replaceWith(t),this.#p=t),this.#o.addEventListener("click",this.#N),this.#u.addEventListener("input",this.#Z),this.#d.addEventListener("click",this.#B),this.#r=!0}#b(){this.#h.hidden=!this.filterable,this.#u.setAttribute("placeholder",this.placeholder)}#$(t,e){return(t||[]).find(i=>String(i.value)===String(e))||null}#C(t){if(!t||t.leaf)return[];let e=t.children;if(e==null)return[];if(Array.isArray(e))return e;if(typeof e=="function"){if(this.#e.has(t))return this.#e.get(t);if(this.#i.has(t))return"loading";let i;try{i=e(t)}catch{i=[]}if(i&&typeof i.then=="function")return this.#i.set(t,i),i.then(r=>{this.#i.delete(t),this.#e.set(t,Array.isArray(r)?r:[]),this.#y(null)}).catch(()=>{this.#i.delete(t),this.#e.set(t,[]),this.#y(null)}),"loading";let n=Array.isArray(i)?i:[];return this.#e.set(t,n),n}return[]}#P(t){return!t||t.leaf?!1:Array.isArray(t.children)?t.children.length>0:typeof t.children=="function"}#k(t){let e=this.#t,i=null;for(let n of t){if(i=this.#$(e,n),!i)return{item:null,list:[]};let r=this.#C(i);if(e=r==="loading"?"loading":r,e==="loading")return{item:i,list:"loading"}}return{item:i,list:e}}#y(t){this.#r&&Mt(()=>this.#A(t))}#A(t){this.#b();let e=this.path,{item:i,list:n}=this.#k(e),r=i?i.label??"":this.rootLabel||"";if(this.#l.textContent=r,this.#o.hidden=e.length===0,e.length>0){let{item:d}=this.#k(e.slice(0,-1));this.#a.textContent=d?d.label??"":this.rootLabel||""}let o=n==="loading",a=o?[]:n,l=this.#n.trim().toLowerCase(),h=l?a.filter(d=>(d.label||"").toLowerCase().includes(l)||(d.meta||"").toLowerCase().includes(l)):a;if(this.#c.textContent=o?"":String(a.length),this.#d.setAttribute("aria-busy",String(o)),this.#d.setAttribute("aria-label",r||"Items"),this.#d.innerHTML="",this.#d.removeAttribute("data-anim"),o)for(let d=0;d<4;d++){let f=document.createElement("skeleton-ui");f.setAttribute("height","2.25rem"),f.setAttribute("data-drilldown-skeleton",""),this.#d.appendChild(f)}else if(h.length)for(let d of h)this.#d.appendChild(this.#L(d));else{let d=document.createElement("empty-state-ui");d.setAttribute("minimal",""),d.setAttribute("heading",l?"No matches":"No items"),this.#d.appendChild(d)}this.static||(t==="forward"?this.#d.setAttribute("data-anim","forward"):t==="backward"&&this.#d.setAttribute("data-anim","backward"));let c=[...this.#d.querySelectorAll('[role="option"]')];if(this.#g==="first"&&c[0])this.#Q(c[0]),c[0].focus();else if(this.#g&&this.#g.restoreValue!=null){let d=c.find(f=>f.dataset.value===String(this.#g.restoreValue));d?(this.#Q(d),d.focus()):c[0]&&this.#Q(c[0])}else{let d=c.find(f=>f.dataset.value===this.#O);d?this.#Q(d):c[0]&&this.#Q(c[0])}this.#g=null;let u=o?"":` \u2014 ${a.length} item${a.length===1?"":"s"}`;this.#f.textContent=`${r||"Root"}${u}`}#T(t){return String(t??"").replace(/"/g,"&quot;")}#E(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#L(t){let e=this.#P(t),i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("tabindex","-1"),i.setAttribute("aria-selected","false"),i.dataset.value=String(t.value),e||i.setAttribute("data-leaf","");let n="";t.dot&&(n+=`<span slot="dot" data-tone="${this.#T(t.dot)}"></span>`),n+=`<div slot="main"><span slot="label">${this.#E(t.label)}</span>`,t.meta&&(n+=`<span slot="meta">${this.#E(t.meta)}</span>`),n+="</div>";let r=Array.isArray(t.counts)?t.counts:[];return r.length&&(n+=`<span slot="counts">${r.map(o=>`<span data-drilldown-chip data-tone="${this.#T(o.variant||"neutral")}">${this.#E(o.value)}</span>`).join("")}</span>`),e&&(n+='<icon-ui name="caret-right" slot="chevron"></icon-ui>'),i.innerHTML=n,this.#m.set(i,t),i}#Q(t){let e=this.#d.querySelector('[role="option"][tabindex="0"]');e&&e!==t&&e.setAttribute("tabindex","-1"),t.setAttribute("tabindex","0"),this.#O=t.dataset.value}#M(t){let e=[...this.#d.querySelectorAll('[role="option"]')];if(!e.length)return;let i=this.#d.querySelector('[role="option"][tabindex="0"]'),n=i?e.indexOf(i):-1;n=(n+t+e.length)%e.length,this.#Q(e[n]),e[n].focus()}#I(t){let e=this.path;this.#s[e.length]=t.value,this.#g="first",this.path=[...e,t.value]}back(){let t=this.path;if(!t.length)return;let e=this.#s[t.length-1];this.#g={restoreValue:e},this.path=t.slice(0,-1)}#R(t){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{path:this.path,item:t}}))}#X(t){if(!this.#P(t)){this.#R(t);return}this.selectOnDrill&&this.#R(t),this.#I(t)}#N=()=>this.back();#Z=()=>{this.#n=this.#u.value,this.#y(null)};#B=t=>{let e=te(t.target)?t.target.closest('[role="option"]'):null;if(!e)return;let i=this.#m.get(e);i&&(this.#Q(e),this.#X(i))};#q=t=>{let e=te(t.target)?t.target.closest('[role="option"]'):null;switch(t.key){case"ArrowDown":t.preventDefault(),this.#M(1);break;case"ArrowUp":t.preventDefault(),this.#M(-1);break;case"ArrowRight":{if(!e)break;t.preventDefault();let i=this.#m.get(e);i&&this.#P(i)&&this.#X(i);break}case"ArrowLeft":case"Backspace":if(t.key==="Backspace"&&this.#u?.contains(t.target))break;t.preventDefault(),this.back();break;case"Enter":case" ":if(!e)break;t.preventDefault();{let i=this.#m.get(e);i&&this.#X(i)}break}}};M();A("drilldown-ui",Qn);X();var Tn=class extends C{static requiredIcons=["caret-right"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},minWidth:{type:Number,default:200,attribute:"min-width",reflect:!0},maxWidth:{type:Number,default:9999,attribute:"max-width",reflect:!0},edge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=0;#s=0;#n=null;#r="";#o=!1;connected(){this.#o||(this.#o=!0,this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l)),this.resizable&&!this.querySelector('[slot="resize"]')&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","resize"),this.appendChild(this.#t)),(this.#t||this.resizable)&&(this.#t=this.#t||this.querySelector('[slot="resize"]'),this.#t?.addEventListener("pointerdown",this.#c))}render(){let t=this.querySelector(":scope > header");if(t&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-expanded",String(!this.collapsed)),!t.querySelector('[slot="caret"]'))){let e=document.createElement("icon-ui");e.setAttribute("slot","caret"),e.setAttribute("name","caret-right"),t.append(e)}}toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new Event("toggle",{bubbles:!0}))}#a=t=>{let e=this.querySelector(":scope > header");e&&(t.target===e||e.contains(t.target))&&this.toggle()};#l=t=>{t.target===this.querySelector(":scope > header")&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.toggle())};#c=t=>{if(t.isPrimary){t.preventDefault(),this.#e=!0,this.#i=t.clientX,this.#s=this.getBoundingClientRect().width,this.#n=t.pointerId,this.setAttribute("resizing","");try{this.#t.setPointerCapture(t.pointerId)}catch{}this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#u,{once:!0}),this.#t.addEventListener("pointercancel",this.#u,{once:!0}),this.#r=document.documentElement.style.cursor,document.documentElement.style.cursor="col-resize"}};#h=t=>{if(!this.#e)return;let e=this.edge==="trailing"?-1:1,i=(t.clientX-this.#i)*e,n=Math.max(this.minWidth,Math.min(this.maxWidth,this.#s+i));this.style.width=`${n}px`};#u=()=>{if(this.#e){this.#e=!1,this.removeAttribute("resizing");try{this.#t?.releasePointerCapture(this.#n)}catch{}this.#n=null,this.#t?.removeEventListener("pointermove",this.#h),document.documentElement.style.cursor=this.#r}};disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#l),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#e&&(document.documentElement.style.cursor=this.#r),this.#o=!1}};M();A("pane-ui",Tn);X();var Ln=class extends C{static properties={scroll:{type:Boolean,default:!1,reflect:!0},maxWidth:{type:String,default:"",attribute:"max-width",reflect:!0},padding:{type:String,default:"",reflect:!0},stickyHeader:{type:Boolean,default:!1,attribute:"sticky-header",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.stickyHeader&&this.#i()}disconnected(){this.#s()}render(){this.stickyHeader&&!this.#t&&this.#i(),!this.stickyHeader&&this.#t&&this.#s()}#i(){let t=this.querySelector(":scope > :is(header, header-ui)");t&&(this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-page-sentinel",""),this.#t.style.cssText="height: 0; width: 0; pointer-events: none;",t.insertAdjacentElement("beforebegin",this.#t)),!this.#e&&typeof IntersectionObserver<"u"&&(this.#e=new IntersectionObserver(e=>{this.toggleAttribute("data-header-stuck",!e[0].isIntersecting)},{threshold:0})),this.#e?.observe(this.#t))}#s(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null,this.removeAttribute("data-header-stuck")}};M();A("page-ui",Ln);M();X();var Ma=class extends C{static properties={disabled:{type:Boolean,default:!1,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Type a message...",reflect:!0},model:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=[];#r=[];#o=null;#a=null;#l=null;#c=()=>this.#a?.click();#h=()=>{this.#a?.files?.length&&this.#m(this.#a.files),this.#a&&(this.#a.value="")};get value(){return this.#t?.value?.trim()??""}get attachments(){return[...this.#r]}set models(t){this.#n=t||[],this.#i&&(this.#i.options=this.#n,this.model&&(this.#i.value=this.model))}get models(){return this.#n}connected(){this.querySelector('[slot="toolbar"]')||(this.innerHTML=`
173
+ `,this.#o=this.querySelector('[slot="back"]'),this.#a=this.querySelector("[data-back-label]"),this.#l=this.querySelector("[data-level-title]"),this.#c=this.querySelector("[data-level-count]"),this.#h=this.querySelector('[slot="filter"]'),this.#u=this.querySelector('[slot="filter"] input-ui'),this.#d=this.querySelector('[slot="panel"]'),this.#f=this.querySelector('[slot="live"]'),this.#p=this.querySelector('[slot="breadcrumb"]');let t=[...this.children].find(e=>e.getAttribute("slot")==="breadcrumb"&&e.parentElement===this);t&&t!==this.#p&&(this.#p.replaceWith(t),this.#p=t),this.#o.addEventListener("click",this.#N),this.#u.addEventListener("input",this.#Z),this.#d.addEventListener("click",this.#B),this.#r=!0}#y(){this.#h.hidden=!this.filterable,this.#u.setAttribute("placeholder",this.placeholder)}#A(t,e){return(t||[]).find(i=>String(i.value)===String(e))||null}#E(t){if(!t||t.leaf)return[];let e=t.children;if(e==null)return[];if(Array.isArray(e))return e;if(typeof e=="function"){if(this.#e.has(t))return this.#e.get(t);if(this.#i.has(t))return"loading";let i;try{i=e(t)}catch{i=[]}if(i&&typeof i.then=="function")return this.#i.set(t,i),i.then(r=>{this.#i.delete(t),this.#e.set(t,Array.isArray(r)?r:[]),this.#v(null)}).catch(()=>{this.#i.delete(t),this.#e.set(t,[]),this.#v(null)}),"loading";let n=Array.isArray(i)?i:[];return this.#e.set(t,n),n}return[]}#P(t){return!t||t.leaf?!1:Array.isArray(t.children)?t.children.length>0:typeof t.children=="function"}#k(t){let e=this.#t,i=null;for(let n of t){if(i=this.#A(e,n),!i)return{item:null,list:[]};let r=this.#E(i);if(e=r==="loading"?"loading":r,e==="loading")return{item:i,list:"loading"}}return{item:i,list:e}}#v(t){this.#r&&Mt(()=>this.#$(t))}#$(t){this.#y();let e=this.path,{item:i,list:n}=this.#k(e),r=i?i.label??"":this.rootLabel||"";if(this.#l.textContent=r,this.#o.hidden=e.length===0,e.length>0){let{item:d}=this.#k(e.slice(0,-1));this.#a.textContent=d?d.label??"":this.rootLabel||""}let o=n==="loading",a=o?[]:n,l=this.#n.trim().toLowerCase(),h=l?a.filter(d=>(d.label||"").toLowerCase().includes(l)||(d.meta||"").toLowerCase().includes(l)):a;if(this.#c.textContent=o?"":String(a.length),this.#d.setAttribute("aria-busy",String(o)),this.#d.setAttribute("aria-label",r||"Items"),this.#d.innerHTML="",this.#d.removeAttribute("data-anim"),o)for(let d=0;d<4;d++){let f=document.createElement("skeleton-ui");f.setAttribute("height","2.25rem"),f.setAttribute("data-drilldown-skeleton",""),this.#d.appendChild(f)}else if(h.length)for(let d of h)this.#d.appendChild(this.#M(d));else{let d=document.createElement("empty-state-ui");d.setAttribute("minimal",""),d.setAttribute("heading",l?"No matches":"No items"),this.#d.appendChild(d)}this.static||(t==="forward"?this.#d.setAttribute("data-anim","forward"):t==="backward"&&this.#d.setAttribute("data-anim","backward"));let c=[...this.#d.querySelectorAll('[role="option"]')];if(this.#O==="first"&&c[0])this.#Q(c[0]),c[0].focus();else if(this.#O&&this.#O.restoreValue!=null){let d=c.find(f=>f.dataset.value===String(this.#O.restoreValue));d?(this.#Q(d),d.focus()):c[0]&&this.#Q(c[0])}else{let d=c.find(f=>f.dataset.value===this.#g);d?this.#Q(d):c[0]&&this.#Q(c[0])}this.#O=null;let u=o?"":` \u2014 ${a.length} item${a.length===1?"":"s"}`;this.#f.textContent=`${r||"Root"}${u}`}#T(t){return String(t??"").replace(/"/g,"&quot;")}#C(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#M(t){let e=this.#P(t),i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("tabindex","-1"),i.setAttribute("aria-selected","false"),i.dataset.value=String(t.value),e||i.setAttribute("data-leaf","");let n="";t.dot&&(n+=`<span slot="dot" data-tone="${this.#T(t.dot)}"></span>`),n+=`<div slot="main"><span slot="label">${this.#C(t.label)}</span>`,t.meta&&(n+=`<span slot="meta">${this.#C(t.meta)}</span>`),n+="</div>";let r=Array.isArray(t.counts)?t.counts:[];return r.length&&(n+=`<span slot="counts">${r.map(o=>`<span data-drilldown-chip data-tone="${this.#T(o.variant||"neutral")}">${this.#C(o.value)}</span>`).join("")}</span>`),e&&(n+='<icon-ui name="caret-right" slot="chevron"></icon-ui>'),i.innerHTML=n,this.#m.set(i,t),i}#Q(t){let e=this.#d.querySelector('[role="option"][tabindex="0"]');e&&e!==t&&e.setAttribute("tabindex","-1"),t.setAttribute("tabindex","0"),this.#g=t.dataset.value}#R(t){let e=[...this.#d.querySelectorAll('[role="option"]')];if(!e.length)return;let i=this.#d.querySelector('[role="option"][tabindex="0"]'),n=i?e.indexOf(i):-1;n=(n+t+e.length)%e.length,this.#Q(e[n]),e[n].focus()}#I(t){let e=this.path;this.#s[e.length]=t.value,this.#O="first",this.path=[...e,t.value]}back(){let t=this.path;if(!t.length)return;let e=this.#s[t.length-1];this.#O={restoreValue:e},this.path=t.slice(0,-1)}#L(t){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{path:this.path,item:t}}))}#X(t){if(!this.#P(t)){this.#L(t);return}this.selectOnDrill&&this.#L(t),this.#I(t)}#N=()=>this.back();#Z=()=>{this.#n=this.#u.value,this.#v(null)};#B=t=>{let e=te(t.target)?t.target.closest('[role="option"]'):null;if(!e)return;let i=this.#m.get(e);i&&(this.#Q(e),this.#X(i))};#q=t=>{let e=te(t.target)?t.target.closest('[role="option"]'):null;switch(t.key){case"ArrowDown":t.preventDefault(),this.#R(1);break;case"ArrowUp":t.preventDefault(),this.#R(-1);break;case"ArrowRight":{if(!e)break;t.preventDefault();let i=this.#m.get(e);i&&this.#P(i)&&this.#X(i);break}case"ArrowLeft":case"Backspace":if(t.key==="Backspace"&&this.#u?.contains(t.target))break;t.preventDefault(),this.back();break;case"Enter":case" ":if(!e)break;t.preventDefault();{let i=this.#m.get(e);i&&this.#X(i)}break}}};M();A("drilldown-ui",Qn);X();var Tn=class extends C{static requiredIcons=["caret-right"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},resizable:{type:Boolean,default:!1,reflect:!0},minWidth:{type:Number,default:200,attribute:"min-width",reflect:!0},maxWidth:{type:Number,default:9999,attribute:"max-width",reflect:!0},edge:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=0;#s=0;#n=null;#r="";#o=!1;connected(){this.#o||(this.#o=!0,this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l)),this.resizable&&!this.querySelector('[slot="resize"]')&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","resize"),this.appendChild(this.#t)),(this.#t||this.resizable)&&(this.#t=this.#t||this.querySelector('[slot="resize"]'),this.#t?.addEventListener("pointerdown",this.#c))}render(){let t=this.querySelector(":scope > header");if(t&&(t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-expanded",String(!this.collapsed)),!t.querySelector('[slot="caret"]'))){let e=document.createElement("icon-ui");e.setAttribute("slot","caret"),e.setAttribute("name","caret-right"),t.append(e)}}toggle(){this.collapsed=!this.collapsed,this.dispatchEvent(new Event("toggle",{bubbles:!0}))}#a=t=>{let e=this.querySelector(":scope > header");e&&(t.target===e||e.contains(t.target))&&this.toggle()};#l=t=>{t.target===this.querySelector(":scope > header")&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.toggle())};#c=t=>{if(t.isPrimary){t.preventDefault(),this.#e=!0,this.#i=t.clientX,this.#s=this.getBoundingClientRect().width,this.#n=t.pointerId,this.setAttribute("resizing","");try{this.#t.setPointerCapture(t.pointerId)}catch{}this.#t.addEventListener("pointermove",this.#h),this.#t.addEventListener("pointerup",this.#u,{once:!0}),this.#t.addEventListener("pointercancel",this.#u,{once:!0}),this.#r=document.documentElement.style.cursor,document.documentElement.style.cursor="col-resize"}};#h=t=>{if(!this.#e)return;let e=this.edge==="trailing"?-1:1,i=(t.clientX-this.#i)*e,n=Math.max(this.minWidth,Math.min(this.maxWidth,this.#s+i));this.style.width=`${n}px`};#u=()=>{if(this.#e){this.#e=!1,this.removeAttribute("resizing");try{this.#t?.releasePointerCapture(this.#n)}catch{}this.#n=null,this.#t?.removeEventListener("pointermove",this.#h),document.documentElement.style.cursor=this.#r}};disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#l),this.#t?.removeEventListener("pointerdown",this.#c),this.#t?.removeEventListener("pointermove",this.#h),this.#e&&(document.documentElement.style.cursor=this.#r),this.#o=!1}};M();A("pane-ui",Tn);X();var Ln=class extends C{static properties={scroll:{type:Boolean,default:!1,reflect:!0},maxWidth:{type:String,default:"",attribute:"max-width",reflect:!0},padding:{type:String,default:"",reflect:!0},stickyHeader:{type:Boolean,default:!1,attribute:"sticky-header",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.stickyHeader&&this.#i()}disconnected(){this.#s()}render(){this.stickyHeader&&!this.#t&&this.#i(),!this.stickyHeader&&this.#t&&this.#s()}#i(){let t=this.querySelector(":scope > :is(header, header-ui)");t&&(this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("data-page-sentinel",""),this.#t.style.cssText="height: 0; width: 0; pointer-events: none;",t.insertAdjacentElement("beforebegin",this.#t)),!this.#e&&typeof IntersectionObserver<"u"&&(this.#e=new IntersectionObserver(e=>{this.toggleAttribute("data-header-stuck",!e[0].isIntersecting)},{threshold:0})),this.#e?.observe(this.#t))}#s(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null,this.removeAttribute("data-header-stuck")}};M();A("page-ui",Ln);M();X();var Ma=class extends C{static properties={disabled:{type:Boolean,default:!1,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Type a message...",reflect:!0},model:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=[];#r=[];#o=null;#a=null;#l=null;#c=()=>this.#a?.click();#h=()=>{this.#a?.files?.length&&this.#m(this.#a.files),this.#a&&(this.#a.value="")};get value(){return this.#t?.value?.trim()??""}get attachments(){return[...this.#r]}set models(t){this.#n=t||[],this.#i&&(this.#i.options=this.#n,this.model&&(this.#i.value=this.model))}get models(){return this.#n}connected(){this.querySelector('[slot="toolbar"]')||(this.innerHTML=`
174
174
  <textarea-ui placeholder="${this.placeholder}" rows="1"></textarea-ui>
175
175
  <div slot="toolbar">
176
176
  <select-ui slot="model" placeholder="Model" aria-label="Select model" divider></select-ui>
177
177
  <button-ui icon="paper-plane-right" variant="ghost" slot="send" aria-label="Send message"></button-ui>
178
178
  </div>
179
- `),this.#t=this.querySelector("textarea-ui"),this.#e=this.querySelector('[slot="send"]'),this.#i=this.querySelector('[slot="model"]'),this.#e&&!this.#e.hasAttribute("aria-label")&&this.#e.setAttribute("aria-label","Send message"),this.#i&&!this.#i.hasAttribute("aria-label")&&this.#i.setAttribute("aria-label","Select model"),this.#n.length&&this.#i&&(this.#i.options=this.#n,this.model&&(this.#i.value=this.model));let t=this.querySelector('[slot="toolbar"]');if(t&&!t.querySelector('[slot="attach"]')){this.#a=document.createElement("input"),this.#a.type="file",this.#a.accept="image/*",this.#a.multiple=!0,this.#a.style.display="none",this.appendChild(this.#a),this.#s=document.createElement("button-ui"),this.#s.setAttribute("icon","image"),this.#s.setAttribute("variant","ghost"),this.#s.setAttribute("slot","attach"),this.#s.setAttribute("size","sm"),this.#s.setAttribute("aria-label","Attach image");let e=t.querySelector('[slot="send"]');t.insertBefore(this.#s,e),this.#s.addEventListener("press",this.#c),this.#a.addEventListener("change",this.#h)}this.#o=document.createElement("div"),this.#o.setAttribute("slot","preview"),this.#o.hidden=!0,this.insertBefore(this.#o,this.querySelector('[slot="toolbar"]')),this.addEventListener("paste",this.#p),this.#e?.addEventListener("press",this.#f),this.#t?.addEventListener("submit",this.#f),this.#i?.addEventListener("change",this.#d),this.addEventListener("pointerdown",this.#u)}render(){this.#t&&(this.#t.disabled=this.disabled,this.#t.placeholder=this.placeholder),this.#e&&(this.#e.disabled=this.disabled||this.loading),this.#i&&this.model&&this.#i.value!==this.model&&(this.#i.value=this.model)}#u=t=>{t.target.closest("button-ui, select-ui, input-ui, a")||(this.#l=requestAnimationFrame(()=>{this.#l=null,this.#t?.focus()}))};#d=()=>{this.model=this.#i?.value||""};#f=t=>{if(t?.type==="submit"&&t.stopPropagation(),this.disabled||this.loading)return;let e=this.value;!e&&!this.#r.length||this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:e,model:this.model,attachments:this.attachments}}))};#p=t=>{let e=t.clipboardData?.items;if(!e)return;let i=[...e].filter(r=>r.type.startsWith("image/"));if(i.length===0)return;t.preventDefault();let n=i.map(r=>r.getAsFile()).filter(Boolean);n.length&&this.#m(n)};#m(t){for(let e of t){let i=new FileReader;i.onload=()=>{this.#r.push({type:"image",dataUrl:i.result,name:e.name}),this.#g()},i.readAsDataURL(e)}}#O(t){this.#r.splice(t,1),this.#g()}#g(){this.#o&&(this.#o.innerHTML="",this.#o.hidden=this.#r.length===0,this.#r.forEach((t,e)=>{let i=document.createElement("div");i.setAttribute("data-preview-item","");let n=document.createElement("img");n.src=t.dataUrl,n.alt=t.name||"attachment";let r=document.createElement("button-ui");r.setAttribute("variant","ghost"),r.setAttribute("size","xs"),r.setAttribute("icon","x"),r.setAttribute("aria-label",`Remove ${t.name||"attachment"}`),r.setAttribute("data-preview-remove",""),r.addEventListener("click",()=>this.#O(e)),i.appendChild(n),i.appendChild(r),this.#o.appendChild(i)}))}clear(){this.#t?.clear(),this.#r=[],this.#o&&(this.#o.innerHTML="",this.#o.hidden=!0)}focus(){this.#t?.focus()}disconnected(){this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.removeEventListener("paste",this.#p),this.#e?.removeEventListener("press",this.#f),this.#t?.removeEventListener("submit",this.#f),this.#i?.removeEventListener("change",this.#d),this.#s?.removeEventListener("press",this.#c),this.#a?.removeEventListener("change",this.#h),this.removeEventListener("pointerdown",this.#u),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#o=null,this.#a=null}};A("chat-input-ui",Ma);var M$={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},Xb=s=>s.replace(/[&<>"]/g,t=>M$[t]);function Rn(s){let t=s.split(`
179
+ `),this.#t=this.querySelector("textarea-ui"),this.#e=this.querySelector('[slot="send"]'),this.#i=this.querySelector('[slot="model"]'),this.#e&&!this.#e.hasAttribute("aria-label")&&this.#e.setAttribute("aria-label","Send message"),this.#i&&!this.#i.hasAttribute("aria-label")&&this.#i.setAttribute("aria-label","Select model"),this.#n.length&&this.#i&&(this.#i.options=this.#n,this.model&&(this.#i.value=this.model));let t=this.querySelector('[slot="toolbar"]');if(t&&!t.querySelector('[slot="attach"]')){this.#a=document.createElement("input"),this.#a.type="file",this.#a.accept="image/*",this.#a.multiple=!0,this.#a.style.display="none",this.appendChild(this.#a),this.#s=document.createElement("button-ui"),this.#s.setAttribute("icon","image"),this.#s.setAttribute("variant","ghost"),this.#s.setAttribute("slot","attach"),this.#s.setAttribute("size","sm"),this.#s.setAttribute("aria-label","Attach image");let e=t.querySelector('[slot="send"]');t.insertBefore(this.#s,e),this.#s.addEventListener("press",this.#c),this.#a.addEventListener("change",this.#h)}this.#o=document.createElement("div"),this.#o.setAttribute("slot","preview"),this.#o.hidden=!0,this.insertBefore(this.#o,this.querySelector('[slot="toolbar"]')),this.addEventListener("paste",this.#p),this.#e?.addEventListener("press",this.#f),this.#t?.addEventListener("submit",this.#f),this.#i?.addEventListener("change",this.#d),this.addEventListener("pointerdown",this.#u)}render(){this.#t&&(this.#t.disabled=this.disabled,this.#t.placeholder=this.placeholder),this.#e&&(this.#e.disabled=this.disabled||this.loading),this.#i&&this.model&&this.#i.value!==this.model&&(this.#i.value=this.model)}#u=t=>{t.target.closest("button-ui, select-ui, input-ui, a")||(this.#l=requestAnimationFrame(()=>{this.#l=null,this.#t?.focus()}))};#d=()=>{this.model=this.#i?.value||""};#f=t=>{if(t?.type==="submit"&&t.stopPropagation(),this.disabled||this.loading)return;let e=this.value;!e&&!this.#r.length||this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:e,model:this.model,attachments:this.attachments}}))};#p=t=>{let e=t.clipboardData?.items;if(!e)return;let i=[...e].filter(r=>r.type.startsWith("image/"));if(i.length===0)return;t.preventDefault();let n=i.map(r=>r.getAsFile()).filter(Boolean);n.length&&this.#m(n)};#m(t){for(let e of t){let i=new FileReader;i.onload=()=>{this.#r.push({type:"image",dataUrl:i.result,name:e.name}),this.#O()},i.readAsDataURL(e)}}#g(t){this.#r.splice(t,1),this.#O()}#O(){this.#o&&(this.#o.innerHTML="",this.#o.hidden=this.#r.length===0,this.#r.forEach((t,e)=>{let i=document.createElement("div");i.setAttribute("data-preview-item","");let n=document.createElement("img");n.src=t.dataUrl,n.alt=t.name||"attachment";let r=document.createElement("button-ui");r.setAttribute("variant","ghost"),r.setAttribute("size","xs"),r.setAttribute("icon","x"),r.setAttribute("aria-label",`Remove ${t.name||"attachment"}`),r.setAttribute("data-preview-remove",""),r.addEventListener("click",()=>this.#g(e)),i.appendChild(n),i.appendChild(r),this.#o.appendChild(i)}))}clear(){this.#t?.clear(),this.#r=[],this.#o&&(this.#o.innerHTML="",this.#o.hidden=!0)}focus(){this.#t?.focus()}disconnected(){this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.removeEventListener("paste",this.#p),this.#e?.removeEventListener("press",this.#f),this.#t?.removeEventListener("submit",this.#f),this.#i?.removeEventListener("change",this.#d),this.#s?.removeEventListener("press",this.#c),this.#a?.removeEventListener("change",this.#h),this.removeEventListener("pointerdown",this.#u),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#o=null,this.#a=null}};A("chat-input-ui",Ma);var M$={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},Xb=s=>s.replace(/[&<>"]/g,t=>M$[t]);function Rn(s){let t=s.split(`
180
180
  `),e=[],i=0;for(;i<t.length;){let n=t[i],r=n.match(/^```(\w*)/);if(r){let l=r[1],h=[];for(i++;i<t.length&&!t[i].startsWith("```");)h.push(Xb(t[i])),i++;i++;let c=h.join(`
181
181
  `);e.push(l?`<code-ui language="${l}">${c}</code-ui>`:`<pre><code>${c}</code></pre>`);continue}if(!n.trim()){i++;continue}let o=n.match(/^(#{1,6})\s+(.+)/);if(o){let l=o[1].length;e.push(`<h${l}>${Mn(o[2])}</h${l}>`),i++;continue}if(/^[-*]\s/.test(n)){let l=[];for(;i<t.length&&/^[-*]\s/.test(t[i]);)l.push(`<li>${Mn(t[i].replace(/^[-*]\s/,""))}</li>`),i++;e.push(`<ul>${l.join("")}</ul>`);continue}if(/^\d+\.\s/.test(n)){let l=[];for(;i<t.length&&/^\d+\.\s/.test(t[i]);)l.push(`<li>${Mn(t[i].replace(/^\d+\.\s/,""))}</li>`),i++;e.push(`<ol>${l.join("")}</ol>`);continue}let a=[];for(;i<t.length&&t[i].trim()&&!/^```|^#{1,6}\s|^[-*]\s|^\d+\.\s/.test(t[i]);)a.push(t[i]),i++;e.push(`<p>${Mn(a.join(" "))}</p>`)}return e.join(`
182
182
  `)}var R$=s=>`\0CODE${s}\0`,I$=/\0CODE(\d+)\0/g;function Mn(s){let t=Xb(s),e=[],i=t.replace(/`([^`]+)`/g,(n,r)=>{let o=e.length;return e.push(r),R$(o)});return i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/_(.+?)_/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),i=i.replace(I$,(n,r)=>`<code>${e[Number(r)]}</code>`),i}X();function D$(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var In=class extends C{static properties={streaming:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;#i=null;#s=null;get messages(){return[...this.#t]}connected(){!this.querySelector("header")&&!this.querySelector("section")&&(this.innerHTML=`
@@ -191,7 +191,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
191
191
  `),this.#e=this.querySelector("section"),this.#i=this.querySelector("chat-input-ui"),this.#i?.addEventListener("submit",this.#n)}disconnected(){this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#i?.removeEventListener("submit",this.#n),this.#e=null,this.#i=null}#n=t=>{if(t?.type==="submit"&&t.stopPropagation(),this.streaming)return;let{text:e,model:i}=t.detail||{};e&&(this.#i.clear(),this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:e,model:i}})))};appendMessage({role:t,content:e="",render:i=!1}){this.#t.push({role:t,content:e});let n=document.createElement("div");n.setAttribute("data-role",t);let r=i?Rn(e):D$(e);if(t==="user")n.innerHTML=`<div slot="bubble">${r}</div>`;else{let o=i?"":'<span slot="cursor"></span>';n.innerHTML=`
192
192
  <span slot="avatar">${t==="assistant"?"AI":t[0].toUpperCase()}</span>
193
193
  <div slot="bubble">${r}${o}</div>
194
- `}return this.#e?.appendChild(n),this.#r(),n}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role==="user")return;e.content+=t;let i=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');if(i){let n=i.querySelector('[slot="cursor"]');n&&n.remove(),i.insertAdjacentText("beforeend",t),i.insertAdjacentHTML("beforeend",'<span slot="cursor"></span>')}this.#r()}startStreaming(){this.streaming=!0,this.#i&&(this.#i.disabled=!0)}stopStreaming(){this.streaming=!1,this.#i&&(this.#i.disabled=!1),this.#e?.querySelector('[data-role]:last-child [slot="cursor"]')?.remove();let t=this.#t[this.#t.length-1];if(t&&t.role==="assistant"&&t.content){let e=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');e&&(e.innerHTML=Rn(t.content))}this.#i?.focus()}clear(){this.#t.length=0,this.#e&&(this.#e.innerHTML="")}#r(){let t=this.#e;t&&(this.#s!=null&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.isConnected&&(t.scrollTop=t.scrollHeight)}))}};M();A("chat-thread-ui",In);X();var Dn=class extends C{#t=!1;#e=!1;#i=null;#s=null;#n=null;#r=null;#o="programmatic";static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},side:{type:String,default:"right",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"open");if(t?.set){let e=t.set;Object.defineProperty(this,"open",{get:t.get,set:i=>{e.call(this,i),this.#f()},configurable:!0})}}#a=t=>{t.target.closest('[slot="close"]')&&(this.#o="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#o="escape",this.permanent||(this.open=!1)};#c=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#o;this.#o="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#r&&!this.permanent&&(this.#o="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#a);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h))}disconnected(){this.removeEventListener("press",this.#a),this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#c),this.#r.removeEventListener("click",this.#h)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#n!=null&&(clearTimeout(this.#n),this.#n=null),this.#t=!1,this.#r=null}#u(){let t=getComputedStyle(this).getPropertyValue("--drawer-duration").trim();return parseFloat(t)||200}#d(t,e,i="append"){let n={header:"header",body:"section",footer:"footer"}[t],r=h=>h.getAttribute("slot")===t||n&&!h.getAttribute("slot")&&h.localName===n,o=[...this.children].find(r),a=[...e.children].find(h=>h.getAttribute("slot")===t);o&&a&&o!==a&&a.remove();let l=o||a||(()=>{let h=this.constructor._pp?.[t];if(!h)return null;let c=h.cloneNode(!0);return c.setAttribute("data-stamped",""),c})();return l?(l.getAttribute("slot")!==t&&l.setAttribute("slot",t),l.parentElement!==e&&(i==="prepend"?e.prepend(l):e.appendChild(l)),l):null}render(){let t=this.ensure("dialog");t!==this.#r&&(this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#c),this.#r.removeEventListener("click",this.#h)),this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h)),this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=this.#d("header",e,"prepend");if(i){let o=i.querySelector(':scope > [slot="heading"][data-stamped]'),a=[...i.children].some(l=>!l.hasAttribute("data-stamped")&&(l.getAttribute("slot")==="heading"||/^h[1-6]$/.test(l.localName)));this.text&&!a?(o||(o=document.createElement("span"),o.setAttribute("slot","heading"),o.setAttribute("data-stamped",""),i.prepend(o)),o.textContent!==this.text&&(o.textContent=this.text)):o&&o.remove()}if(this.permanent)this.drop("close");else{let o=this.ensure("close");i&&o.parentElement!==i&&i.appendChild(o)}let n=[...this.children].filter(o=>o.getAttribute("slot")==="body"||o.localName==="section"&&!o.getAttribute("slot"));if(n.length===0)this.#d("body",e,"append");else for(let o of n)o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o);let r=[...this.children].find(o=>o.getAttribute("slot")==="footer"||!o.getAttribute("slot")&&o.localName==="footer");r&&(r.getAttribute("slot")!=="footer"&&r.setAttribute("slot","footer"),r.parentElement!==e&&e.appendChild(r)),this.#f()}#f(){let t=this.#r;if(t&&t.isConnected)if(this.open&&!t.open){this.#e=!1,this.#i=document.activeElement;try{t.showModal()}catch(e){console.error("[drawer-ui] showModal() failed \u2014 dialog may be detached:",e)}t.offsetHeight,t.setAttribute("data-open",""),this.#n!=null&&clearTimeout(this.#n),this.#n=setTimeout(()=>{this.#n=null,this.dispatchEvent(new CustomEvent("opened",{bubbles:!0}))},this.#u())}else!this.open&&t.open&&!this.#e&&this.#p(t)}#p(t){this.#e=!0,this.#n!=null&&(clearTimeout(this.#n),this.#n=null),t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close()},this.#u())}show(){this.open=!0}hide(){this.open=!1}};M();A("drawer-ui",Dn);X();var Xn=class s extends C{#t=!1;#e=!1;#i=null;#s=null;#n=null;#r=!1;static#o=0;static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};#a=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#l=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#c=()=>{this.#h()};#h=()=>{this.#r||(this.#r=!0,this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0})))};#u=t=>{t.target===this.#n&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#a);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#u))}disconnected(){this.removeEventListener("press",this.#a),this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#u)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),(this.open||this.#e||this.#n?.open)&&this.#h(),this.#e=!1,this.#t=!1,this.#n=null}#d(){let e=getComputedStyle(this).getPropertyValue("--modal-duration").trim(),i=/ms\s*$/.test(e)?parseFloat(e):/s\s*$/.test(e)?parseFloat(e)*1e3:parseFloat(e);return i>0?i:200}render(){let t=this.ensure("dialog");this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=[...this.children].find(c=>c.getAttribute("slot")==="header"||!c.getAttribute("slot")&&c.localName==="header"),n;i?(i.getAttribute("slot")!=="header"&&i.setAttribute("slot","header"),i.parentElement!==e&&e.prepend(i),e.querySelector(':scope > [slot="header"][data-stamped]')?.remove(),n=i):(n=this.ensure("header"),n.setAttribute("data-stamped",""),n.parentElement!==e&&e.prepend(n)),this.text?n.setAttribute("text",this.text):n.removeAttribute("text");let r=lt(n,"heading")[0];if(!this.text&&r?(r.id||(r.id=`modal-heading-${++s.#o}`),t.getAttribute("aria-labelledby")!==r.id&&t.setAttribute("aria-labelledby",r.id)):t.removeAttribute("aria-labelledby"),this.permanent)this.drop("close");else{let c=this.ensure("close");c.parentElement!==n&&n.appendChild(c)}let o=[...this.children].find(c=>c.getAttribute("slot")==="body"||!c.getAttribute("slot")&&c.localName==="section"),a=[...this.children].filter(c=>!c.getAttribute("slot")&&c.localName!=="section"&&c.localName!=="dialog"&&c.localName!=="footer"),l;o?(o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),l=o):(l=this.ensure("body"),l.setAttribute("data-stamped",""),l.parentElement!==e&&e.appendChild(l));for(let c of a)c!==l&&l.appendChild(c);let h=[...this.children].find(c=>c.getAttribute("slot")==="footer"||!c.getAttribute("slot")&&c.localName==="footer");if(h)h.getAttribute("slot")!=="footer"&&h.setAttribute("slot","footer"),h.parentElement!==e&&e.appendChild(h),e.querySelector(':scope > [slot="footer"][data-stamped]')?.remove();else{let c=this.ensure("footer");c.setAttribute("data-stamped",""),c.parentElement!==e&&e.appendChild(c)}this.open&&!t.open?(this.#e=!1,this.#r=!1,this.#i=document.activeElement,t.showModal(),t.offsetHeight,t.setAttribute("data-open","")):!this.open&&t.open&&!this.#e&&this.#f(t)}#f(t){this.#e=!0,t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close(),this.#h()},this.#d())}show(){this.open=!0}hide(){this.open=!1}};M();A("modal-ui",Xn);X();var qn=class extends C{static requiredIcons=["x"];static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>At``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},Zn=class s extends C{#t=null;#e=!1;#i=null;#s=null;static properties={text:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},action:{type:String,default:"",reflect:!0}};static parts={body:'<div slot="body"></div>'};static template=()=>At``;#n=t=>{if(t.target.closest("[data-feed-close]")){this.dismiss();return}if(t.target.closest("[data-feed-action]")){try{this.#r?.()}catch(e){console.warn("[feed-item] action handler threw:",e)}this.dismiss()}};#r=null;#o=null;#a=null;connected(){this.addEventListener("press",this.#n)}#l(){let t=getComputedStyle(this).getPropertyValue("--feed-item-duration").trim();return parseFloat(t)||200}render(){let t=this.ensure("body");if(t.textContent="",this.heading){let h=document.createElement("strong");h.textContent=this.heading,h.style.display="block",t.appendChild(h)}if(this.text){let h=document.createElement("span");h.textContent=this.text,t.appendChild(h)}let e=!this.duration||this.duration<=0,i=this.variant==="danger"||this.variant==="warning",n=e&&!!this.action,r="status";n?r="alertdialog":e&&i&&(r="alert"),this.setAttribute("role",r),this.setAttribute("aria-live",r==="alert"||r==="alertdialog"?"assertive":"polite"),n&&this.setAttribute("aria-modal","false");let o=this.dismissible||e,a=this.querySelector(":scope > [data-feed-close]");o&&!a?(a=document.createElement("button-ui"),a.setAttribute("data-feed-close",""),a.setAttribute("icon","x"),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label","Dismiss"),this.appendChild(a)):!o&&a&&a.remove();let l=this.querySelector(":scope > [data-feed-action]");this.action?(l||(l=document.createElement("button-ui"),l.setAttribute("data-feed-action",""),l.setAttribute("variant","ghost"),l.setAttribute("size","sm"),a&&a.parentElement===this?this.insertBefore(l,a):this.appendChild(l)),l.setAttribute("text",this.action)):l&&l.remove(),n?this.#h():this.#u(),!this.hasAttribute("open")&&!this.#e&&(typeof requestAnimationFrame=="function"?this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("open","")}):this.setAttribute("open","")),this.#c()}#c(){this.#t&&clearTimeout(this.#t),this.duration&&this.duration>0&&(this.#t=setTimeout(()=>this.dismiss(),this.duration))}dismiss(){this.#e||(this.#e=!0,this.#t&&(clearTimeout(this.#t),this.#t=null),this.removeAttribute("open"),this.setAttribute("closing",""),this.#i=setTimeout(()=>{this.#i=null;let t=this.parentElement;this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove(),t?.matches?.("feed-ui")&&_e.releaseContainerIfEmpty(t)},this.#l()))}update(t){if(!(!t||typeof t!="object")){for(let e of Object.keys(t))e in s.properties&&(this[e]=t[e]);typeof t.onAction=="function"&&(this.#r=t.onAction),this.#c()}}#h(){if(this.#a)return;this.#o=document.activeElement;let t=()=>[...this.querySelectorAll('button, button-ui, [tabindex]:not([tabindex="-1"]), input, [data-feed-action], [data-feed-close]')].filter(e=>!e.hasAttribute("disabled")&&e.offsetParent!==null);this.#a=e=>{if(e.key==="Escape"){e.stopPropagation(),this.dismiss();return}if(e.key!=="Tab")return;let i=t();if(!i.length)return;let n=i[0],r=i[i.length-1],o=document.activeElement;e.shiftKey&&o===n?(e.preventDefault(),r.focus()):!e.shiftKey&&o===r&&(e.preventDefault(),n.focus())},this.addEventListener("keydown",this.#a,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#u(){if(this.#a){this.removeEventListener("keydown",this.#a,!0),this.#a=null;try{this.#o?.focus?.()}catch{}this.#o=null}}disconnected(){this.removeEventListener("press",this.#n),this.#t&&(clearTimeout(this.#t),this.#t=null),this.#i&&(clearTimeout(this.#i),this.#i=null),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#u()}},_e=class s{static#t=new Map;static get(t="bottom-right"){let e=s.#t.get(t);if(e&&e.isConnected)return e;e=document.createElement("feed-ui"),e.setAttribute("position",t),"popover"in HTMLElement.prototype&&e.setAttribute("popover","manual"),document.body.appendChild(e);try{e.showPopover?.()}catch{}return s.#t.set(t,e),e}static post(t={}){let{text:e="",heading:i="",icon:n="",variant:r="default",duration:o=4e3,position:a="bottom-right",dismissible:l,id:h,action:c="",onAction:u}=t,d=r==="error"?"danger":r,f=s.get(a),p=parseInt(f.getAttribute("max")||"5",10),m=[...f.children].filter(w=>w.tagName==="FEED-ITEM-UI"&&!w.hasAttribute("queued")).length,g=document.createElement("feed-item-ui");h&&g.setAttribute("data-id",h),g.text=e,g.heading=i,g.icon=n,g.variant=d;let O="duration"in t;return g.duration=c&&!O?0:o,l!=null&&(g.dismissible=!!l),c&&(g.action=c),m>=p&&g.setAttribute("queued",""),f.appendChild(g),typeof u=="function"&&g.update({onAction:u}),{id:h??null,dismiss:()=>g.dismiss(),update:w=>g.update(w)}}static clear(t="bottom-right"){let e=s.#t.get(t);if(e)for(let i of[...e.children])i.tagName==="FEED-ITEM-UI"&&i.dismiss?.()}static purge(){for(let t of s.#t.values()){try{t.hidePopover?.()}catch{}t.remove()}s.#t.clear()}static releaseContainerIfEmpty(t){if(!t)return;let e=t.querySelector("feed-item-ui[queued]");if(e&&e.removeAttribute("queued"),!(t.children.length>0)){try{t.hidePopover?.()}catch{}t.remove();for(let[i,n]of s.#t)n===t&&s.#t.delete(i)}}};M();A("feed-ui",qn),A("feed-item-ui",Zn),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&_e.post(s.detail)}));X();var ys=class extends C{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"info",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},position:{type:String,default:"bottom-right",reflect:!0}};static template=()=>At``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,_e.post({text:this.text,variant:this.variant==="error"?"danger":this.variant,duration:this.duration,position:this.position}),queueMicrotask(()=>{try{this.remove()}catch{}}))}static show(t={}){let{text:e,variant:i="info",position:n="bottom-right",action:r,onAction:o}=t,a=_e.get(n);a&&!a.hasAttribute("data-spawned-by")&&a.setAttribute("data-spawned-by","toast");let l={text:e,variant:i==="error"?"danger":i,position:n};return"duration"in t&&(l.duration=t.duration),"dismissible"in t&&(l.dismissible=!!t.dismissible),r&&(l.action=r),typeof o=="function"&&(l.onAction=o),_e.post(l)}};M();A("toast-ui",ys),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&ys.show(s.detail)}));X();var Nn=class extends C{static properties={anchor:{type:String,default:"bottom",reflect:!0},align:{type:String,default:"center",reflect:!0},viewport:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.viewport&&this.#e()}updated(t){t.has("viewport")&&(this.viewport?this.#e():this.#i()),t.has("open")&&(this.#s(),this.dispatchEvent(new Event(this.open?"open":"close",{bubbles:!0})))}render(){this.viewport&&this.#s()}disconnected(){if(this.viewport&&this.matches(":popover-open"))try{this.hidePopover()}catch{}this.#t&&(this.#t=!1,this.removeEventListener("toggle",this.#n))}#e(){this.hasAttribute("popover")||this.setAttribute("popover","manual"),this.#t||(this.#t=!0,this.addEventListener("toggle",this.#n)),this.#s()}#i(){if(this.matches(":popover-open"))try{this.hidePopover()}catch{}this.#t&&(this.#t=!1,this.removeEventListener("toggle",this.#n)),this.removeAttribute("popover")}#s(){if(this.viewport){if(this.open&&!this.matches(":popover-open"))try{this.showPopover()}catch{}else if(!this.open&&this.matches(":popover-open"))try{this.hidePopover()}catch{}}}#n=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)}};M();A("anchor-bar-ui",Nn);M();X();var Ra=class extends C{static properties={text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","tabpanel")}render(){this.text&&this.setAttribute("aria-label",this.text),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}};A("tab-ui",Ra);X();var zn=class extends C{static properties={value:{type:String,default:"",reflect:!0},orientation:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.setAttribute("role","tablist"),this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l),!this.value){let t=this.querySelector("tab-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}}disconnected(){this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null),this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#l),this.#t=null,this.#e=null}get#s(){return[...this.querySelectorAll("tab-ui")]}get#n(){return this.#s.filter(t=>!t.disabled)}render(){let t=this.#s;if(t.length){this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("slot","strip"),this.#t.setAttribute("role","presentation")),this.#t.parentElement!==this&&this.prepend(this.#t),this.reconcile(this.#t,t,e=>e.value||e.getAttribute("value")||"",(e,i,n)=>{let r=e.value||e.getAttribute("value")||"",o=e.text||e.getAttribute("text")||"",a=e.icon||e.getAttribute("icon")||"",l=r===this.value,h=e.disabled||e.hasAttribute("disabled");if(n){if(n.textContent="",a){let u=document.createElement("icon-ui");u.setAttribute("name",a),n.appendChild(u)}return o&&n.appendChild(document.createTextNode(o)),n.setAttribute("aria-selected",String(l)),n.setAttribute("tabindex",l?"0":"-1"),h?n.setAttribute("disabled",""):n.removeAttribute("disabled"),l?n.setAttribute("data-active",""):n.removeAttribute("data-active"),n.dataset.value=r,n}let c=document.createElement("div");if(c.setAttribute("role","tab"),c.setAttribute("slot","tab-button"),c.dataset.value=r,c.setAttribute("aria-selected",String(l)),c.setAttribute("tabindex",l?"0":"-1"),h&&c.setAttribute("disabled",""),l&&c.setAttribute("data-active",""),a){let u=document.createElement("icon-ui");u.setAttribute("name",a),c.appendChild(u)}return o&&c.appendChild(document.createTextNode(o)),c}),this.#r();for(let e of t)(e.value||e.getAttribute("value")||"")===this.value?(e.setAttribute("selected",""),e.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):(e.removeAttribute("selected"),e.setAttribute("hidden",""))}}#r(){let t=this.#t?.querySelector('[slot="tab-button"][data-active]');if(!t){this.#e&&(this.#e.style.opacity="0");return}let e=!this.#e;e&&(this.#e=document.createElement("span"),this.#e.setAttribute("slot","indicator"),this.#t.appendChild(this.#e));let i=this.#t.getBoundingClientRect(),n=t.getBoundingClientRect(),r=this.orientation==="vertical",o=()=>{if(r){let a=n.top-i.top;this.#e.style.transform=`translateY(${a}px)`,this.#e.style.height=`${n.height}px`,this.#e.style.width=""}else{let a=n.left-i.left;this.#e.style.transform=`translateX(${a}px)`,this.#e.style.width=`${n.width}px`,this.#e.style.height=""}this.#e.style.opacity="1"};e?(this.#e.style.transition="none",o(),this.#i=requestAnimationFrame(()=>{this.#i=null,this.#e&&(this.#e.style.transition="")})):o()}#o(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#a=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#o(e.dataset.value)};#l=t=>{let e=t.target.closest('[slot="tab-button"]');if(!e||!this.contains(e))return;let i=[...this.#t.querySelectorAll('[slot="tab-button"]:not([disabled])')],n=i.indexOf(e);if(n<0)return;let r=this.orientation==="vertical",o=r?"ArrowDown":"ArrowRight",a=r?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=n<i.length-1?n+1:0;break;case a:l=n>0?n-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;default:return}t.preventDefault(),i[l].focus(),this.#o(i[l].dataset.value)}};M();A("tabs-ui",zn);X();var Bn=class s extends C{static properties={text:{type:String,default:"",reflect:!0},placement:{type:String,default:"top",reflect:!0},delay:{type:Number,default:400,reflect:!0},follows:{type:String,default:"trigger",reflect:!0},for:{type:String,default:"",reflect:!0},indicator:{type:String,default:"none",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;connected(){this.follows==="pointer"?this.#c():(this.addEventListener("mouseenter",this.#r),this.addEventListener("focusin",this.#r),this.addEventListener("mouseleave",this.#o),this.addEventListener("focusout",this.#o))}disconnected(){this.removeEventListener("mouseenter",this.#r),this.removeEventListener("focusin",this.#r),this.removeEventListener("mouseleave",this.#o),this.removeEventListener("focusout",this.#o),this.#h(),this.#l()}render(){this.#t&&this.follows!=="pointer"&&(this.#t.textContent=this.text),this.#t&&this.follows==="pointer"&&this.#n&&this.#m(this.#n)}#r=()=>{this.text&&(this.#e&&clearTimeout(this.#e),this.#e=setTimeout(()=>this.#a(),this.delay))};#o=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#a(){if(this.#t)return;let t=document.createElement("div"),e=`tooltip-${Date.now()}`;t.id=e,t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.classList.add("tooltip-popup"),t.textContent=this.text,document.body.appendChild(t),this.setAttribute("aria-describedby",e);try{t.showPopover()}catch{}this.#t=t,this.#i=mt(this,t,{placement:this.placement,gap:6})}#l(){if(this.#e&&(clearTimeout(this.#e),this.#e=null),!!this.#t){this.removeAttribute("aria-describedby"),this.#i?.(),this.#i=null;try{this.#t.hidePopover()}catch{}this.#t.remove(),this.#t=null,this.#n=null}}#c(){if(this.#h(),!this.for)return;let t=this.getRootNode();if(this.#s=t&&t.getElementById?t.getElementById(this.for):document.getElementById(this.for),!this.#s){s._warnedMissing||(s._warnedMissing=new WeakSet),s._warnedMissing.has(this)||(console.warn(`[tooltip-ui] follows="pointer" [for="${this.for}"] did not resolve to an element.`),s._warnedMissing.add(this));return}this.#s.addEventListener("chart-hover",this.#d),this.#s.addEventListener("chart-leave",this.#u)}#h(){this.#s&&(this.#s.removeEventListener("chart-hover",this.#d),this.#s.removeEventListener("chart-leave",this.#u)),this.#s=null}#u=()=>this.#l();#d=t=>{let e=t.detail;if(e){if(this.#n=e,!this.#t){this.#t=this.#f(),this.#p();try{this.#t.showPopover()}catch{}}this.#m(e),this.#O(e.pointerX,e.pointerY)}};#f(){let t=document.createElement("div");return t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.setAttribute("data-follows","pointer"),t.setAttribute("data-indicator",this.indicator||"none"),t.classList.add("tooltip-popup"),document.body.appendChild(t),t}#p(){if(!this.#s||!this.#t)return;let t=getComputedStyle(this.#s),e=Array.isArray(this.#s.legendData)?this.#s.legendData.map(i=>i.key).filter(Boolean):[];for(let i of e){let n=t.getPropertyValue(`--color-${i}`).trim();n&&this.#t.style.setProperty(`--color-${i}`,n)}for(let i=0;i<10;i++){let n=t.getPropertyValue(`--chart-${i}`).trim();n&&this.#t.style.setProperty(`--chart-${i}`,n)}}#m(t){if(!this.#t)return;let{label:e,value:i,pct:n,series:r,slot:o,payload:a}=t,l=this.indicator||"none",h=Array.isArray(a)&&a.length>0?a:[{series:r,label:e,value:i,pct:n,slot:o,hovered:!0}],c=[];e!=null&&c.push(`<span data-tip-role="label">${this.#g(String(e))}</span>`);for(let u of h){let d=u.series??null,f=u.value,p=u.pct,m=u.slot!=null?u.slot:0,g=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let O=f!=null?this.#g(String(f)):"",w=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",x=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${g}"></span>`:"",S=d?`<span data-tip-role="name">${this.#g(d)}</span>`:"",v=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${v}>${x}${S}<span data-tip-role="value">${O}${w}</span></span>`)}this.#t.setAttribute("data-indicator",l),this.#t.setAttribute("aria-live","polite"),this.#t.innerHTML=c.join("")}#O(t,e){if(!this.#t||t==null||e==null)return;let i=12,n=8,r=this.#t;r.style.position="fixed",r.style.left="0",r.style.top="0";let o=r.offsetWidth||0,a=r.offsetHeight||0,l=t-o/2,h=e-a-i;l<n&&(l=n),l+o>window.innerWidth-n&&(l=window.innerWidth-o-n),h<n&&(h=e+i),r.style.left=`${l}px`,r.style.top=`${h}px`}#g(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}};M();A("tooltip-ui",Bn);X();var X$={new:{variant:"success",text:"New"},updated:{variant:"info",text:"Updated"},deprecated:{variant:"warning",text:"Deprecated"},removed:{variant:"danger",text:"Removed"},beta:{variant:"primary",text:"Beta"}},Vn=class extends C{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","status")}render(){if(this.status){let t=X$[this.status];t&&(this.variant!==t.variant&&(this.variant=t.variant),this.text!==t.text&&(this.text=t.text))}if(this.text&&this.setAttribute("aria-label",this.text),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t&&t.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("size","sm"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};M();A("badge-ui",Vn);X();var _n=class extends C{static properties={separator:{type:String,default:"/",reflect:!0},collapse:{type:Boolean,default:!1,reflect:!0},collapseKeepLeading:{type:Number,default:1,attribute:"collapse-keep-leading",reflect:!0},collapseKeepTrailing:{type:Number,default:2,attribute:"collapse-keep-trailing",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","navigation"),this.setAttribute("aria-label","Breadcrumb")}render(){this.querySelectorAll("[data-sep], [data-overflow]").forEach(l=>l.remove());let t=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-overflow")),e=t.length-1;t.forEach((l,h)=>{l.setAttribute("data-item",""),l.removeAttribute("data-collapsed"),h===e?l.setAttribute("aria-current","page"):l.removeAttribute("aria-current")});let i=Math.max(0,this.collapseKeepLeading|0),n=Math.max(0,this.collapseKeepTrailing|0),r=i+n+1;if(this.collapse&&t.length>=Math.max(r,4)){let l=t.slice(i,t.length-n);l.forEach(c=>c.setAttribute("data-collapsed",""));let h=this.#t(l);i>0?t[i-1].after(h):this.prepend(h)}let a=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-collapsed"));for(let l=0;l<a.length-1;l++){let h=document.createElement("span");h.setAttribute("data-sep",""),h.setAttribute("aria-hidden","true"),h.textContent=this.separator,a[l].after(h)}}#t(t){let e=document.createElement("menu-ui");e.setAttribute("data-overflow",""),e.setAttribute("data-item",""),e.setAttribute("placement","bottom-start");let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("text","\u2026"),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("aria-label","Show collapsed crumbs"),e.appendChild(i);for(let n of t){let r=document.createElement("menu-item-ui");r.setAttribute("text",n.textContent.trim()),n.tagName==="A"&&n.hasAttribute("href")&&r.setAttribute("value",n.getAttribute("href")),e.appendChild(r)}return e.addEventListener("action",n=>{let r=n.detail?.value;r&&r!=="#"&&(window.location.href=r)}),e}};M();A("breadcrumb-ui",_n);X();Ge();function q$(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Z$=0,jn=class s extends C{static requiredIcons=["magnifying-glass"];static properties={placeholder:{type:String,default:"Type a command...",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=[];#i=-1;#s=null;#n=null;#r=null;#o=null;#a=!1;#l=new WeakMap;#c=[];#h=`command-${++Z$}`;static#u=3;#d=t=>{let e=te(t.target)?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=this.#l.get(e);i&&this.#k(i)};#f=t=>{let e=te(t.target)?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=parseInt(e.dataset.idx);Number.isFinite(i)&&i!==this.#i&&this.#C(i)};connected(){this.#a||(this.#a=!0,this.addEventListener("keydown",this.#T))}render(){if(!this.#s){this.#t.length===0&&this.#g(),this.#c=lt(this,"empty");let t=`${this.#h}-list`;this.innerHTML=`
194
+ `}return this.#e?.appendChild(n),this.#r(),n}appendChunk(t){let e=this.#t[this.#t.length-1];if(!e||e.role==="user")return;e.content+=t;let i=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');if(i){let n=i.querySelector('[slot="cursor"]');n&&n.remove(),i.insertAdjacentText("beforeend",t),i.insertAdjacentHTML("beforeend",'<span slot="cursor"></span>')}this.#r()}startStreaming(){this.streaming=!0,this.#i&&(this.#i.disabled=!0)}stopStreaming(){this.streaming=!1,this.#i&&(this.#i.disabled=!1),this.#e?.querySelector('[data-role]:last-child [slot="cursor"]')?.remove();let t=this.#t[this.#t.length-1];if(t&&t.role==="assistant"&&t.content){let e=this.#e?.querySelector('[data-role]:last-child [slot="bubble"]');e&&(e.innerHTML=Rn(t.content))}this.#i?.focus()}clear(){this.#t.length=0,this.#e&&(this.#e.innerHTML="")}#r(){let t=this.#e;t&&(this.#s!=null&&cancelAnimationFrame(this.#s),this.#s=requestAnimationFrame(()=>{this.#s=null,this.isConnected&&(t.scrollTop=t.scrollHeight)}))}};M();A("chat-thread-ui",In);X();var Dn=class extends C{#t=!1;#e=!1;#i=null;#s=null;#n=null;#r=null;#o="programmatic";static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},side:{type:String,default:"right",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"open");if(t?.set){let e=t.set;Object.defineProperty(this,"open",{get:t.get,set:i=>{e.call(this,i),this.#f()},configurable:!0})}}#a=t=>{t.target.closest('[slot="close"]')&&(this.#o="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#o="escape",this.permanent||(this.open=!1)};#c=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#o;this.#o="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#r&&!this.permanent&&(this.#o="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#a);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h))}disconnected(){this.removeEventListener("press",this.#a),this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#c),this.#r.removeEventListener("click",this.#h)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#n!=null&&(clearTimeout(this.#n),this.#n=null),this.#t=!1,this.#r=null}#u(){let t=getComputedStyle(this).getPropertyValue("--drawer-duration").trim();return parseFloat(t)||200}#d(t,e,i="append"){let n={header:"header",body:"section",footer:"footer"}[t],r=h=>h.getAttribute("slot")===t||n&&!h.getAttribute("slot")&&h.localName===n,o=[...this.children].find(r),a=[...e.children].find(h=>h.getAttribute("slot")===t);o&&a&&o!==a&&a.remove();let l=o||a||(()=>{let h=this.constructor._pp?.[t];if(!h)return null;let c=h.cloneNode(!0);return c.setAttribute("data-stamped",""),c})();return l?(l.getAttribute("slot")!==t&&l.setAttribute("slot",t),l.parentElement!==e&&(i==="prepend"?e.prepend(l):e.appendChild(l)),l):null}render(){let t=this.ensure("dialog");t!==this.#r&&(this.#r&&(this.#r.removeEventListener("cancel",this.#l),this.#r.removeEventListener("close",this.#c),this.#r.removeEventListener("click",this.#h)),this.#r=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#h)),this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=this.#d("header",e,"prepend");if(i){let o=i.querySelector(':scope > [slot="heading"][data-stamped]'),a=[...i.children].some(l=>!l.hasAttribute("data-stamped")&&(l.getAttribute("slot")==="heading"||/^h[1-6]$/.test(l.localName)));this.text&&!a?(o||(o=document.createElement("span"),o.setAttribute("slot","heading"),o.setAttribute("data-stamped",""),i.prepend(o)),o.textContent!==this.text&&(o.textContent=this.text)):o&&o.remove()}if(this.permanent)this.drop("close");else{let o=this.ensure("close");i&&o.parentElement!==i&&i.appendChild(o)}let n=[...this.children].filter(o=>o.getAttribute("slot")==="body"||o.localName==="section"&&!o.getAttribute("slot"));if(n.length===0)this.#d("body",e,"append");else for(let o of n)o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o);let r=[...this.children].find(o=>o.getAttribute("slot")==="footer"||!o.getAttribute("slot")&&o.localName==="footer");r&&(r.getAttribute("slot")!=="footer"&&r.setAttribute("slot","footer"),r.parentElement!==e&&e.appendChild(r)),this.#f()}#f(){let t=this.#r;if(t&&t.isConnected)if(this.open&&!t.open){this.#e=!1,this.#i=document.activeElement;try{t.showModal()}catch(e){console.error("[drawer-ui] showModal() failed \u2014 dialog may be detached:",e)}t.offsetHeight,t.setAttribute("data-open",""),this.#n!=null&&clearTimeout(this.#n),this.#n=setTimeout(()=>{this.#n=null,this.dispatchEvent(new CustomEvent("opened",{bubbles:!0}))},this.#u())}else!this.open&&t.open&&!this.#e&&this.#p(t)}#p(t){this.#e=!0,this.#n!=null&&(clearTimeout(this.#n),this.#n=null),t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close()},this.#u())}show(){this.open=!0}hide(){this.open=!1}};M();A("drawer-ui",Dn);X();var Xn=class s extends C{#t=!1;#e=!1;#i=null;#s=null;#n=null;#r=!1;static#o=0;static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},permanent:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static parts={dialog:'<dialog slot="dialog"></dialog>',panel:'<div slot="panel"></div>',header:'<header slot="header"></header>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',body:'<section slot="body"></section>',footer:'<footer slot="footer"></footer>'};#a=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#l=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#c=()=>{this.#h()};#h=()=>{this.#r||(this.#r=!0,this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0})))};#u=t=>{t.target===this.#n&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#a);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#l),t.addEventListener("close",this.#c),t.addEventListener("click",this.#u))}disconnected(){this.removeEventListener("press",this.#a),this.#n&&(this.#n.removeEventListener("cancel",this.#l),this.#n.removeEventListener("close",this.#c),this.#n.removeEventListener("click",this.#u)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),(this.open||this.#e||this.#n?.open)&&this.#h(),this.#e=!1,this.#t=!1,this.#n=null}#d(){let e=getComputedStyle(this).getPropertyValue("--modal-duration").trim(),i=/ms\s*$/.test(e)?parseFloat(e):/s\s*$/.test(e)?parseFloat(e)*1e3:parseFloat(e);return i>0?i:200}render(){let t=this.ensure("dialog");this.text?(t.setAttribute("aria-label",this.text),this.setAttribute("aria-label",this.text)):(t.removeAttribute("aria-label"),this.removeAttribute("aria-label"));let e=this.ensure("panel");e.parentElement!==t&&t.appendChild(e);let i=[...this.children].find(c=>c.getAttribute("slot")==="header"||!c.getAttribute("slot")&&c.localName==="header"),n;i?(i.getAttribute("slot")!=="header"&&i.setAttribute("slot","header"),i.parentElement!==e&&e.prepend(i),e.querySelector(':scope > [slot="header"][data-stamped]')?.remove(),n=i):(n=this.ensure("header"),n.setAttribute("data-stamped",""),n.parentElement!==e&&e.prepend(n)),this.text?n.setAttribute("text",this.text):n.removeAttribute("text");let r=lt(n,"heading")[0];if(!this.text&&r?(r.id||(r.id=`modal-heading-${++s.#o}`),t.getAttribute("aria-labelledby")!==r.id&&t.setAttribute("aria-labelledby",r.id)):t.removeAttribute("aria-labelledby"),this.permanent)this.drop("close");else{let c=this.ensure("close");c.parentElement!==n&&n.appendChild(c)}let o=[...this.children].find(c=>c.getAttribute("slot")==="body"||!c.getAttribute("slot")&&c.localName==="section"),a=[...this.children].filter(c=>!c.getAttribute("slot")&&c.localName!=="section"&&c.localName!=="dialog"&&c.localName!=="footer"),l;o?(o.getAttribute("slot")!=="body"&&o.setAttribute("slot","body"),o.parentElement!==e&&e.appendChild(o),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),l=o):(l=this.ensure("body"),l.setAttribute("data-stamped",""),l.parentElement!==e&&e.appendChild(l));for(let c of a)c!==l&&l.appendChild(c);let h=[...this.children].find(c=>c.getAttribute("slot")==="footer"||!c.getAttribute("slot")&&c.localName==="footer");if(h)h.getAttribute("slot")!=="footer"&&h.setAttribute("slot","footer"),h.parentElement!==e&&e.appendChild(h),e.querySelector(':scope > [slot="footer"][data-stamped]')?.remove();else{let c=this.ensure("footer");c.setAttribute("data-stamped",""),c.parentElement!==e&&e.appendChild(c)}this.open&&!t.open?(this.#e=!1,this.#r=!1,this.#i=document.activeElement,t.showModal(),t.offsetHeight,t.setAttribute("data-open","")):!this.open&&t.open&&!this.#e&&this.#f(t)}#f(t){this.#e=!0,t.setAttribute("data-closing",""),t.offsetHeight,t.removeAttribute("data-open"),this.#s=setTimeout(()=>{this.#s=null,this.#e=!1,t.removeAttribute("data-closing"),t.open&&t.close(),this.#h()},this.#d())}show(){this.open=!0}hide(){this.open=!1}};M();A("modal-ui",Xn);X();var qn=class extends C{static requiredIcons=["x"];static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>At``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},Zn=class s extends C{#t=null;#e=!1;#i=null;#s=null;static properties={text:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},action:{type:String,default:"",reflect:!0}};static parts={body:'<div slot="body"></div>'};static template=()=>At``;#n=t=>{if(t.target.closest("[data-feed-close]")){this.dismiss();return}if(t.target.closest("[data-feed-action]")){try{this.#r?.()}catch(e){console.warn("[feed-item] action handler threw:",e)}this.dismiss()}};#r=null;#o=null;#a=null;connected(){this.addEventListener("press",this.#n)}#l(){let t=getComputedStyle(this).getPropertyValue("--feed-item-duration").trim();return parseFloat(t)||200}render(){let t=this.ensure("body");if(t.textContent="",this.heading){let h=document.createElement("strong");h.textContent=this.heading,h.style.display="block",t.appendChild(h)}if(this.text){let h=document.createElement("span");h.textContent=this.text,t.appendChild(h)}let e=!this.duration||this.duration<=0,i=this.variant==="danger"||this.variant==="warning",n=e&&!!this.action,r="status";n?r="alertdialog":e&&i&&(r="alert"),this.setAttribute("role",r),this.setAttribute("aria-live",r==="alert"||r==="alertdialog"?"assertive":"polite"),n&&this.setAttribute("aria-modal","false");let o=this.dismissible||e,a=this.querySelector(":scope > [data-feed-close]");o&&!a?(a=document.createElement("button-ui"),a.setAttribute("data-feed-close",""),a.setAttribute("icon","x"),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label","Dismiss"),this.appendChild(a)):!o&&a&&a.remove();let l=this.querySelector(":scope > [data-feed-action]");this.action?(l||(l=document.createElement("button-ui"),l.setAttribute("data-feed-action",""),l.setAttribute("variant","ghost"),l.setAttribute("size","sm"),a&&a.parentElement===this?this.insertBefore(l,a):this.appendChild(l)),l.setAttribute("text",this.action)):l&&l.remove(),n?this.#h():this.#u(),!this.hasAttribute("open")&&!this.#e&&(typeof requestAnimationFrame=="function"?this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("open","")}):this.setAttribute("open","")),this.#c()}#c(){this.#t&&clearTimeout(this.#t),this.duration&&this.duration>0&&(this.#t=setTimeout(()=>this.dismiss(),this.duration))}dismiss(){this.#e||(this.#e=!0,this.#t&&(clearTimeout(this.#t),this.#t=null),this.removeAttribute("open"),this.setAttribute("closing",""),this.#i=setTimeout(()=>{this.#i=null;let t=this.parentElement;this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove(),t?.matches?.("feed-ui")&&_e.releaseContainerIfEmpty(t)},this.#l()))}update(t){if(!(!t||typeof t!="object")){for(let e of Object.keys(t))e in s.properties&&(this[e]=t[e]);typeof t.onAction=="function"&&(this.#r=t.onAction),this.#c()}}#h(){if(this.#a)return;this.#o=document.activeElement;let t=()=>[...this.querySelectorAll('button, button-ui, [tabindex]:not([tabindex="-1"]), input, [data-feed-action], [data-feed-close]')].filter(e=>!e.hasAttribute("disabled")&&e.offsetParent!==null);this.#a=e=>{if(e.key==="Escape"){e.stopPropagation(),this.dismiss();return}if(e.key!=="Tab")return;let i=t();if(!i.length)return;let n=i[0],r=i[i.length-1],o=document.activeElement;e.shiftKey&&o===n?(e.preventDefault(),r.focus()):!e.shiftKey&&o===r&&(e.preventDefault(),n.focus())},this.addEventListener("keydown",this.#a,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#u(){if(this.#a){this.removeEventListener("keydown",this.#a,!0),this.#a=null;try{this.#o?.focus?.()}catch{}this.#o=null}}disconnected(){this.removeEventListener("press",this.#n),this.#t&&(clearTimeout(this.#t),this.#t=null),this.#i&&(clearTimeout(this.#i),this.#i=null),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#u()}},_e=class s{static#t=new Map;static get(t="bottom-right"){let e=s.#t.get(t);if(e&&e.isConnected)return e;e=document.createElement("feed-ui"),e.setAttribute("position",t),"popover"in HTMLElement.prototype&&e.setAttribute("popover","manual"),document.body.appendChild(e);try{e.showPopover?.()}catch{}return s.#t.set(t,e),e}static post(t={}){let{text:e="",heading:i="",icon:n="",variant:r="default",duration:o=4e3,position:a="bottom-right",dismissible:l,id:h,action:c="",onAction:u}=t,d=r==="error"?"danger":r,f=s.get(a),p=parseInt(f.getAttribute("max")||"5",10),m=[...f.children].filter(w=>w.tagName==="FEED-ITEM-UI"&&!w.hasAttribute("queued")).length,g=document.createElement("feed-item-ui");h&&g.setAttribute("data-id",h),g.text=e,g.heading=i,g.icon=n,g.variant=d;let O="duration"in t;return g.duration=c&&!O?0:o,l!=null&&(g.dismissible=!!l),c&&(g.action=c),m>=p&&g.setAttribute("queued",""),f.appendChild(g),typeof u=="function"&&g.update({onAction:u}),{id:h??null,dismiss:()=>g.dismiss(),update:w=>g.update(w)}}static clear(t="bottom-right"){let e=s.#t.get(t);if(e)for(let i of[...e.children])i.tagName==="FEED-ITEM-UI"&&i.dismiss?.()}static purge(){for(let t of s.#t.values()){try{t.hidePopover?.()}catch{}t.remove()}s.#t.clear()}static releaseContainerIfEmpty(t){if(!t)return;let e=t.querySelector("feed-item-ui[queued]");if(e&&e.removeAttribute("queued"),!(t.children.length>0)){try{t.hidePopover?.()}catch{}t.remove();for(let[i,n]of s.#t)n===t&&s.#t.delete(i)}}};M();A("feed-ui",qn),A("feed-item-ui",Zn),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&_e.post(s.detail)}));X();var ys=class extends C{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"info",reflect:!0},duration:{type:Number,default:4e3,reflect:!0},position:{type:String,default:"bottom-right",reflect:!0}};static template=()=>At``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,_e.post({text:this.text,variant:this.variant==="error"?"danger":this.variant,duration:this.duration,position:this.position}),queueMicrotask(()=>{try{this.remove()}catch{}}))}static show(t={}){let{text:e,variant:i="info",position:n="bottom-right",action:r,onAction:o}=t,a=_e.get(n);a&&!a.hasAttribute("data-spawned-by")&&a.setAttribute("data-spawned-by","toast");let l={text:e,variant:i==="error"?"danger":i,position:n};return"duration"in t&&(l.duration=t.duration),"dismissible"in t&&(l.dismissible=!!t.dismissible),r&&(l.action=r),typeof o=="function"&&(l.onAction=o),_e.post(l)}};M();A("toast-ui",ys),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&ys.show(s.detail)}));X();var Nn=class extends C{static properties={anchor:{type:String,default:"bottom",reflect:!0},align:{type:String,default:"center",reflect:!0},viewport:{type:Boolean,default:!1,reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.viewport&&this.#e()}updated(t){t.has("viewport")&&(this.viewport?this.#e():this.#i()),t.has("open")&&(this.#s(),this.dispatchEvent(new Event(this.open?"open":"close",{bubbles:!0})))}render(){this.viewport&&this.#s()}disconnected(){if(this.viewport&&this.matches(":popover-open"))try{this.hidePopover()}catch{}this.#t&&(this.#t=!1,this.removeEventListener("toggle",this.#n))}#e(){this.hasAttribute("popover")||this.setAttribute("popover","manual"),this.#t||(this.#t=!0,this.addEventListener("toggle",this.#n)),this.#s()}#i(){if(this.matches(":popover-open"))try{this.hidePopover()}catch{}this.#t&&(this.#t=!1,this.removeEventListener("toggle",this.#n)),this.removeAttribute("popover")}#s(){if(this.viewport){if(this.open&&!this.matches(":popover-open"))try{this.showPopover()}catch{}else if(!this.open&&this.matches(":popover-open"))try{this.hidePopover()}catch{}}}#n=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)}};M();A("anchor-bar-ui",Nn);M();X();var Ra=class extends C{static properties={text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","tabpanel")}render(){this.text&&this.setAttribute("aria-label",this.text),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}};A("tab-ui",Ra);X();var zn=class extends C{static properties={value:{type:String,default:"",reflect:!0},orientation:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){if(this.setAttribute("role","tablist"),this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l),!this.value){let t=this.querySelector("tab-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}}disconnected(){this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null),this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#l),this.#t=null,this.#e=null}get#s(){return[...this.querySelectorAll("tab-ui")]}get#n(){return this.#s.filter(t=>!t.disabled)}render(){let t=this.#s;if(t.length){this.#t||(this.#t=document.createElement("div"),this.#t.setAttribute("slot","strip"),this.#t.setAttribute("role","presentation")),this.#t.parentElement!==this&&this.prepend(this.#t),this.reconcile(this.#t,t,e=>e.value||e.getAttribute("value")||"",(e,i,n)=>{let r=e.value||e.getAttribute("value")||"",o=e.text||e.getAttribute("text")||"",a=e.icon||e.getAttribute("icon")||"",l=r===this.value,h=e.disabled||e.hasAttribute("disabled");if(n){if(n.textContent="",a){let u=document.createElement("icon-ui");u.setAttribute("name",a),n.appendChild(u)}return o&&n.appendChild(document.createTextNode(o)),n.setAttribute("aria-selected",String(l)),n.setAttribute("tabindex",l?"0":"-1"),h?n.setAttribute("disabled",""):n.removeAttribute("disabled"),l?n.setAttribute("data-active",""):n.removeAttribute("data-active"),n.dataset.value=r,n}let c=document.createElement("div");if(c.setAttribute("role","tab"),c.setAttribute("slot","tab-button"),c.dataset.value=r,c.setAttribute("aria-selected",String(l)),c.setAttribute("tabindex",l?"0":"-1"),h&&c.setAttribute("disabled",""),l&&c.setAttribute("data-active",""),a){let u=document.createElement("icon-ui");u.setAttribute("name",a),c.appendChild(u)}return o&&c.appendChild(document.createTextNode(o)),c}),this.#r();for(let e of t)(e.value||e.getAttribute("value")||"")===this.value?(e.setAttribute("selected",""),e.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):(e.removeAttribute("selected"),e.setAttribute("hidden",""))}}#r(){let t=this.#t?.querySelector('[slot="tab-button"][data-active]');if(!t){this.#e&&(this.#e.style.opacity="0");return}let e=!this.#e;e&&(this.#e=document.createElement("span"),this.#e.setAttribute("slot","indicator"),this.#t.appendChild(this.#e));let i=this.#t.getBoundingClientRect(),n=t.getBoundingClientRect(),r=this.orientation==="vertical",o=()=>{if(r){let a=n.top-i.top;this.#e.style.transform=`translateY(${a}px)`,this.#e.style.height=`${n.height}px`,this.#e.style.width=""}else{let a=n.left-i.left;this.#e.style.transform=`translateX(${a}px)`,this.#e.style.width=`${n.width}px`,this.#e.style.height=""}this.#e.style.opacity="1"};e?(this.#e.style.transition="none",o(),this.#i=requestAnimationFrame(()=>{this.#i=null,this.#e&&(this.#e.style.transition="")})):o()}#o(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#a=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#o(e.dataset.value)};#l=t=>{let e=t.target.closest('[slot="tab-button"]');if(!e||!this.contains(e))return;let i=[...this.#t.querySelectorAll('[slot="tab-button"]:not([disabled])')],n=i.indexOf(e);if(n<0)return;let r=this.orientation==="vertical",o=r?"ArrowDown":"ArrowRight",a=r?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=n<i.length-1?n+1:0;break;case a:l=n>0?n-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;default:return}t.preventDefault(),i[l].focus(),this.#o(i[l].dataset.value)}};M();A("tabs-ui",zn);X();var Bn=class s extends C{static properties={text:{type:String,default:"",reflect:!0},placement:{type:String,default:"top",reflect:!0},delay:{type:Number,default:400,reflect:!0},follows:{type:String,default:"trigger",reflect:!0},for:{type:String,default:"",reflect:!0},indicator:{type:String,default:"none",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;connected(){this.follows==="pointer"?this.#c():(this.addEventListener("mouseenter",this.#r),this.addEventListener("focusin",this.#r),this.addEventListener("mouseleave",this.#o),this.addEventListener("focusout",this.#o))}disconnected(){this.removeEventListener("mouseenter",this.#r),this.removeEventListener("focusin",this.#r),this.removeEventListener("mouseleave",this.#o),this.removeEventListener("focusout",this.#o),this.#h(),this.#l()}render(){this.#t&&this.follows!=="pointer"&&(this.#t.textContent=this.text),this.#t&&this.follows==="pointer"&&this.#n&&this.#m(this.#n)}#r=()=>{this.text&&(this.#e&&clearTimeout(this.#e),this.#e=setTimeout(()=>this.#a(),this.delay))};#o=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#a(){if(this.#t)return;let t=document.createElement("div"),e=`tooltip-${Date.now()}`;t.id=e,t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.classList.add("tooltip-popup"),t.textContent=this.text,document.body.appendChild(t),this.setAttribute("aria-describedby",e);try{t.showPopover()}catch{}this.#t=t,this.#i=mt(this,t,{placement:this.placement,gap:6})}#l(){if(this.#e&&(clearTimeout(this.#e),this.#e=null),!!this.#t){this.removeAttribute("aria-describedby"),this.#i?.(),this.#i=null;try{this.#t.hidePopover()}catch{}this.#t.remove(),this.#t=null,this.#n=null}}#c(){if(this.#h(),!this.for)return;let t=this.getRootNode();if(this.#s=t&&t.getElementById?t.getElementById(this.for):document.getElementById(this.for),!this.#s){s._warnedMissing||(s._warnedMissing=new WeakSet),s._warnedMissing.has(this)||(console.warn(`[tooltip-ui] follows="pointer" [for="${this.for}"] did not resolve to an element.`),s._warnedMissing.add(this));return}this.#s.addEventListener("chart-hover",this.#d),this.#s.addEventListener("chart-leave",this.#u)}#h(){this.#s&&(this.#s.removeEventListener("chart-hover",this.#d),this.#s.removeEventListener("chart-leave",this.#u)),this.#s=null}#u=()=>this.#l();#d=t=>{let e=t.detail;if(e){if(this.#n=e,!this.#t){this.#t=this.#f(),this.#p();try{this.#t.showPopover()}catch{}}this.#m(e),this.#g(e.pointerX,e.pointerY)}};#f(){let t=document.createElement("div");return t.setAttribute("popover","manual"),t.setAttribute("role","tooltip"),t.setAttribute("data-follows","pointer"),t.setAttribute("data-indicator",this.indicator||"none"),t.classList.add("tooltip-popup"),document.body.appendChild(t),t}#p(){if(!this.#s||!this.#t)return;let t=getComputedStyle(this.#s),e=Array.isArray(this.#s.legendData)?this.#s.legendData.map(i=>i.key).filter(Boolean):[];for(let i of e){let n=t.getPropertyValue(`--color-${i}`).trim();n&&this.#t.style.setProperty(`--color-${i}`,n)}for(let i=0;i<10;i++){let n=t.getPropertyValue(`--chart-${i}`).trim();n&&this.#t.style.setProperty(`--chart-${i}`,n)}}#m(t){if(!this.#t)return;let{label:e,value:i,pct:n,series:r,slot:o,payload:a}=t,l=this.indicator||"none",h=Array.isArray(a)&&a.length>0?a:[{series:r,label:e,value:i,pct:n,slot:o,hovered:!0}],c=[];e!=null&&c.push(`<span data-tip-role="label">${this.#O(String(e))}</span>`);for(let u of h){let d=u.series??null,f=u.value,p=u.pct,m=u.slot!=null?u.slot:0,g=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let O=f!=null?this.#O(String(f)):"",w=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",x=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${g}"></span>`:"",S=d?`<span data-tip-role="name">${this.#O(d)}</span>`:"",v=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${v}>${x}${S}<span data-tip-role="value">${O}${w}</span></span>`)}this.#t.setAttribute("data-indicator",l),this.#t.setAttribute("aria-live","polite"),this.#t.innerHTML=c.join("")}#g(t,e){if(!this.#t||t==null||e==null)return;let i=12,n=8,r=this.#t;r.style.position="fixed",r.style.left="0",r.style.top="0";let o=r.offsetWidth||0,a=r.offsetHeight||0,l=t-o/2,h=e-a-i;l<n&&(l=n),l+o>window.innerWidth-n&&(l=window.innerWidth-o-n),h<n&&(h=e+i),r.style.left=`${l}px`,r.style.top=`${h}px`}#O(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}};M();A("tooltip-ui",Bn);X();var X$={new:{variant:"success",text:"New"},updated:{variant:"info",text:"Updated"},deprecated:{variant:"warning",text:"Deprecated"},removed:{variant:"danger",text:"Removed"},beta:{variant:"primary",text:"Beta"}},Vn=class extends C{static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","status")}render(){if(this.status){let t=X$[this.status];t&&(this.variant!==t.variant&&(this.variant=t.variant),this.text!==t.text&&(this.text=t.text))}if(this.text&&this.setAttribute("aria-label",this.text),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t&&t.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("size","sm"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};M();A("badge-ui",Vn);X();var _n=class extends C{static properties={separator:{type:String,default:"/",reflect:!0},collapse:{type:Boolean,default:!1,reflect:!0},collapseKeepLeading:{type:Number,default:1,attribute:"collapse-keep-leading",reflect:!0},collapseKeepTrailing:{type:Number,default:2,attribute:"collapse-keep-trailing",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","navigation"),this.setAttribute("aria-label","Breadcrumb")}render(){this.querySelectorAll("[data-sep], [data-overflow]").forEach(l=>l.remove());let t=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-overflow")),e=t.length-1;t.forEach((l,h)=>{l.setAttribute("data-item",""),l.removeAttribute("data-collapsed"),h===e?l.setAttribute("aria-current","page"):l.removeAttribute("aria-current")});let i=Math.max(0,this.collapseKeepLeading|0),n=Math.max(0,this.collapseKeepTrailing|0),r=i+n+1;if(this.collapse&&t.length>=Math.max(r,4)){let l=t.slice(i,t.length-n);l.forEach(c=>c.setAttribute("data-collapsed",""));let h=this.#t(l);i>0?t[i-1].after(h):this.prepend(h)}let a=Array.from(this.children).filter(l=>!l.hasAttribute("data-sep")&&!l.hasAttribute("data-collapsed"));for(let l=0;l<a.length-1;l++){let h=document.createElement("span");h.setAttribute("data-sep",""),h.setAttribute("aria-hidden","true"),h.textContent=this.separator,a[l].after(h)}}#t(t){let e=document.createElement("menu-ui");e.setAttribute("data-overflow",""),e.setAttribute("data-item",""),e.setAttribute("placement","bottom-start");let i=document.createElement("button-ui");i.setAttribute("slot","trigger"),i.setAttribute("text","\u2026"),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("aria-label","Show collapsed crumbs"),e.appendChild(i);for(let n of t){let r=document.createElement("menu-item-ui");r.setAttribute("text",n.textContent.trim()),n.tagName==="A"&&n.hasAttribute("href")&&r.setAttribute("value",n.getAttribute("href")),e.appendChild(r)}return e.addEventListener("action",n=>{let r=n.detail?.value;r&&r!=="#"&&(window.location.href=r)}),e}};M();A("breadcrumb-ui",_n);X();Ge();function q$(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Z$=0,jn=class s extends C{static requiredIcons=["magnifying-glass"];static properties={placeholder:{type:String,default:"Type a command...",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=[];#i=-1;#s=null;#n=null;#r=null;#o=null;#a=!1;#l=new WeakMap;#c=[];#h=`command-${++Z$}`;static#u=3;#d=t=>{let e=te(t.target)?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=this.#l.get(e);i&&this.#k(i)};#f=t=>{let e=te(t.target)?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=parseInt(e.dataset.idx);Number.isFinite(i)&&i!==this.#i&&this.#E(i)};connected(){this.#a||(this.#a=!0,this.addEventListener("keydown",this.#T))}render(){if(!this.#s){this.#t.length===0&&this.#O(),this.#c=lt(this,"empty");let t=`${this.#h}-list`;this.innerHTML=`
195
195
  <header>
196
196
  <icon-ui name="magnifying-glass" slot="icon"></icon-ui>
197
197
  <span contenteditable="plaintext-only" role="combobox" tabindex="0"
@@ -205,13 +205,13 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
205
205
  <span data-hint><kbd>\u21B5</kbd> Select</span>
206
206
  <span data-hint><kbd>\u238B</kbd> Close</span>
207
207
  </footer>
208
- `,this.#s=this.querySelector('[slot="input"]'),this.#n=this.querySelector('[slot="list"]'),this.#o=this.querySelector("footer"),this.#s.addEventListener("input",this.#A),this.#n.addEventListener("click",this.#d),this.#n.addEventListener("pointerover",this.#f),this.#v()}this.#s&&this.#s.setAttribute("aria-expanded",String(this.open)),this.open&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#s?.focus()}))}get value(){return this.#s?.textContent||""}set value(t){if(!this.#s)return;let e=t??"";this.#s.textContent=e,this.#s.toggleAttribute("data-empty",!e),this.#v(e)}focus(){this.#s?.focus()}setItems(t){this.#t=t,this.#v()}set options(t){this.#t=this.#p(Array.isArray(t)?t:[]),this.#n&&this.#v(this.#s?.value||"")}get options(){return this.#t}#p(t){let e=[];for(let i of t)if(i&&Array.isArray(i.options)){let n=i.label||"";e.push({label:n,items:i.options.map(r=>this.#m(r,n))})}else i&&e.push(this.#m(i,""));return e}#m(t,e=""){return{value:t.value,label:t.label??t.value,icon:t.icon||"",shortcut:t.shortcut||"",keywords:t.keywords||"",disabled:!!t.disabled,category:e}}#O(){let t=[],e=i=>{for(let n of i.children)if(!n.hasAttribute("slot")){if(n.tagName==="OPTION"||n.tagName==="OPTGROUP"){t.push(n);continue}if(n.matches('[role="presentation"]')||n.style?.display==="contents"){e(n);continue}}};return e(this),t}#g(){let t=[];for(let e of this.#O())if(e.tagName==="OPTGROUP"){let i=e.label,n={label:i,items:[]};for(let r of e.querySelectorAll("option"))n.items.push(this.#S(r,i));t.push(n)}else e.tagName==="OPTION"&&t.push(this.#S(e,""));this.#t=t}#S(t,e=""){return{value:t.value,label:t.textContent.trim(),icon:t.dataset.icon||"",shortcut:t.dataset.shortcut||"",keywords:t.dataset.keywords||"",disabled:t.disabled,category:e}}#v(t=""){if(!this.#n)return;this.#n.innerHTML="",this.#i=-1;let e=t.toLowerCase(),i=this.#t,n=0;if(!e&&this.#e.length){let r=this.#e.map(o=>this.#x(o)).filter(o=>o&&!o.disabled);if(r.length){let o=document.createElement("div");o.setAttribute("data-group",""),o.setAttribute("data-recent",""),o.innerHTML="<div data-group-label>Recent</div>";for(let a of r)o.appendChild(this.#b(a,n)),n++;this.#n.appendChild(o)}}for(let r of i)if(r.items){let o=r.items.filter(l=>this.#$(l,e));if(!o.length)continue;let a=document.createElement("div");a.setAttribute("data-group",""),a.innerHTML=`<div data-group-label>${r.label}</div>`;for(let l of o)a.appendChild(this.#b(l,n)),n++;this.#n.appendChild(a)}else{if(!this.#$(r,e))continue;this.#n.appendChild(this.#b(r,n)),n++}if(!n){let r=document.createElement("div");r.setAttribute("data-empty",""),this.#c.length?r.append(...this.#c):r.textContent="No results found.",this.#n.appendChild(r)}n>0&&this.#C(0)}#x(t){for(let e of this.#t)if(e.items){let i=e.items.find(n=>n.value===t);if(i)return i}else if(e.value===t)return e;return null}#w(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#u))}#b(t,e){let i=document.createElement("div");return i.setAttribute("role","option"),i.setAttribute("data-value",t.value),i.setAttribute("data-idx",e),t.disabled&&i.setAttribute("aria-disabled","true"),i.innerHTML=`
208
+ `,this.#s=this.querySelector('[slot="input"]'),this.#n=this.querySelector('[slot="list"]'),this.#o=this.querySelector("footer"),this.#s.addEventListener("input",this.#$),this.#n.addEventListener("click",this.#d),this.#n.addEventListener("pointerover",this.#f),this.#b()}this.#s&&this.#s.setAttribute("aria-expanded",String(this.open)),this.open&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#s?.focus()}))}get value(){return this.#s?.textContent||""}set value(t){if(!this.#s)return;let e=t??"";this.#s.textContent=e,this.#s.toggleAttribute("data-empty",!e),this.#b(e)}focus(){this.#s?.focus()}setItems(t){this.#t=t,this.#b()}set options(t){this.#t=this.#p(Array.isArray(t)?t:[]),this.#n&&this.#b(this.#s?.value||"")}get options(){return this.#t}#p(t){let e=[];for(let i of t)if(i&&Array.isArray(i.options)){let n=i.label||"";e.push({label:n,items:i.options.map(r=>this.#m(r,n))})}else i&&e.push(this.#m(i,""));return e}#m(t,e=""){return{value:t.value,label:t.label??t.value,icon:t.icon||"",shortcut:t.shortcut||"",keywords:t.keywords||"",disabled:!!t.disabled,category:e}}#g(){let t=[],e=i=>{for(let n of i.children)if(!n.hasAttribute("slot")){if(n.tagName==="OPTION"||n.tagName==="OPTGROUP"){t.push(n);continue}if(n.matches('[role="presentation"]')||n.style?.display==="contents"){e(n);continue}}};return e(this),t}#O(){let t=[];for(let e of this.#g())if(e.tagName==="OPTGROUP"){let i=e.label,n={label:i,items:[]};for(let r of e.querySelectorAll("option"))n.items.push(this.#S(r,i));t.push(n)}else e.tagName==="OPTION"&&t.push(this.#S(e,""));this.#t=t}#S(t,e=""){return{value:t.value,label:t.textContent.trim(),icon:t.dataset.icon||"",shortcut:t.dataset.shortcut||"",keywords:t.dataset.keywords||"",disabled:t.disabled,category:e}}#b(t=""){if(!this.#n)return;this.#n.innerHTML="",this.#i=-1;let e=t.toLowerCase(),i=this.#t,n=0;if(!e&&this.#e.length){let r=this.#e.map(o=>this.#x(o)).filter(o=>o&&!o.disabled);if(r.length){let o=document.createElement("div");o.setAttribute("data-group",""),o.setAttribute("data-recent",""),o.innerHTML="<div data-group-label>Recent</div>";for(let a of r)o.appendChild(this.#y(a,n)),n++;this.#n.appendChild(o)}}for(let r of i)if(r.items){let o=r.items.filter(l=>this.#A(l,e));if(!o.length)continue;let a=document.createElement("div");a.setAttribute("data-group",""),a.innerHTML=`<div data-group-label>${r.label}</div>`;for(let l of o)a.appendChild(this.#y(l,n)),n++;this.#n.appendChild(a)}else{if(!this.#A(r,e))continue;this.#n.appendChild(this.#y(r,n)),n++}if(!n){let r=document.createElement("div");r.setAttribute("data-empty",""),this.#c.length?r.append(...this.#c):r.textContent="No results found.",this.#n.appendChild(r)}n>0&&this.#E(0)}#x(t){for(let e of this.#t)if(e.items){let i=e.items.find(n=>n.value===t);if(i)return i}else if(e.value===t)return e;return null}#w(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#u))}#y(t,e){let i=document.createElement("div");return i.setAttribute("role","option"),i.setAttribute("data-value",t.value),i.setAttribute("data-idx",e),t.disabled&&i.setAttribute("aria-disabled","true"),i.innerHTML=`
209
209
  ${t.icon?`<icon-ui name="${t.icon}"></icon-ui>`:""}
210
210
  <span data-text>${t.label}</span>
211
211
  ${t.shortcut?`<span data-shortcut>${t.shortcut}</span>`:""}
212
- `,this.#l.set(i,t),i}#$(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#C(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#P(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#C(parseInt(e[r].dataset.idx))}#k(t){this.#w(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#y(){let t=this.#n.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",r=(this.#l.get(t)||this.#x(e))?.category||"";this.#w(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#A=()=>{let t=this.#s.textContent||"";this.#s.toggleAttribute("data-empty",!t),this.#v(t)};#T=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#P(1);break;case"ArrowUp":t.preventDefault(),this.#P(-1);break;case"Enter":t.preventDefault(),this.#y();break;case"Tab":t.preventDefault(),this.#y();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),this.removeEventListener("keydown",this.#T),this.#s?.removeEventListener("input",this.#A),this.#n?.removeEventListener("click",this.#d),this.#n?.removeEventListener("pointerover",this.#f),this.#s=null,this.#n=null,this.#o=null,this.#a=!1}};M();A("command-ui",jn);var Ia=.4;function Sd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function wd(s,t,e){let i=s+.3963377774*t+.2158037573*e,n=s-.1055613458*t-.0638541728*e,r=s-.0894841775*t-1.291485548*e,o=i*i*i,a=n*n*n,l=r*r*r;return[4.0767416621*o-3.3077115913*a+.2309699292*l,-1.2684380046*o+2.6097574011*a-.3413193965*l,-.0041960863*o-.7034186147*a+1.707614701*l]}function Oi(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function kd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function qb(s,t,e){let{a:i,b:n}=Sd(s,t,e),[r,o,a]=wd(s,i,n);return[Math.max(0,Math.min(1,Oi(r))),Math.max(0,Math.min(1,Oi(o))),Math.max(0,Math.min(1,Oi(a)))]}function N$(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Wn(s,t,e){let[i,n,r]=qb(s,t,e);return N$(i,n,r)}function z$(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=kd(parseInt(s.slice(0,2),16)/255),e=kd(parseInt(s.slice(2,4),16)/255),i=kd(parseInt(s.slice(4,6),16)/255),n=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),r=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*n+.793617785*r-.0040720468*o,l=1.9779984951*n-2.428592205*r+.4505937099*o,h=.0259040371*n+.7827717662*r-.808675766*o,c=Math.sqrt(l*l+h*h),u=Math.atan2(h,l)*180/Math.PI;return u<0&&(u+=360),{L:a,C:c,H:u}}function Zb(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Da(s,t,e){let{a:i,b:n}=Sd(s,t,e),[r,o,a]=wd(s,i,n);if(Zb(Oi(r),Oi(o),Oi(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=Sd(s,u,e),[p,m,g]=wd(s,d,f);Zb(Oi(p),Oi(m),Oi(g))?l=u:h=u}return l}var Fn=class s extends _{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={..._.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#o=null;#a=!1;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=null;#O=null;#g=null;#S=null;#v=null;#x=[];#w=null;static template=()=>null;#b=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#I("input")};#$=t=>{this.disabled||(this.#o="area",this.#h.setPointerCapture(t.pointerId),this.#L(t))};#C=t=>{this.#o==="area"&&this.#L(t)};#P=()=>{this.#o==="area"&&(this.#o=null,this.#I("change"))};#k=t=>{this.disabled||(this.#o="hue",this.#d.setPointerCapture(t.pointerId),this.#Q(t))};#y=t=>{this.#o==="hue"&&this.#Q(t)};#A=()=>{this.#o==="hue"&&(this.#o=null,this.#I("change"))};#T=t=>{if(this.disabled)return;let e=t.shiftKey?.05:.01,i=t.shiftKey?.04:.004;switch(t.key){case"ArrowRight":t.preventDefault(),this.#i=Math.min(Ia,this.#i+i);break;case"ArrowLeft":t.preventDefault(),this.#i=Math.max(0,this.#i-i);break;case"ArrowUp":t.preventDefault(),this.#e=Math.min(1,this.#e+e);break;case"ArrowDown":t.preventDefault(),this.#e=Math.max(0,this.#e-e);break;default:return}this.#I("change")};#E=t=>{if(this.disabled)return;let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#s=(this.#s+e)%360;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#s=(this.#s-e+360)%360;break;default:return}this.#I("change")};connected(){if(super.connected(),this.#M(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#b),t.appendChild(c),c};this.#g=e("H","hue",0,360,1),this.#S=e("C","chroma",0,Ia,.001),this.#v=e("L","lightness",0,1,.001),this.appendChild(t),this.#d=document.createElement("div"),this.#d.setAttribute("data-hue-track",""),this.#d.setAttribute("tabindex","0"),this.#d.setAttribute("role","slider"),this.#d.setAttribute("aria-label","Hue"),this.#f=document.createElement("div"),this.#f.setAttribute("data-hue-thumb",""),this.#d.appendChild(this.#f),this.appendChild(this.#d);let i=document.createElement("div");i.setAttribute("data-output","");let n=r=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",r);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",r),l.setAttribute("aria-label",`Copy ${r}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#X(r,l);return l.addEventListener("click",h),this.#x.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#p=n("oklch"),this.#m=n("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#$),this.#h.addEventListener("pointermove",this.#C),this.#h.addEventListener("pointerup",this.#P),this.#d.addEventListener("pointerdown",this.#k),this.#d.addEventListener("pointermove",this.#y),this.#d.addEventListener("pointerup",this.#A),this.#h.addEventListener("keydown",this.#T),this.#d.addEventListener("keydown",this.#E),typeof ResizeObserver<"u"&&(this.#O=new ResizeObserver(()=>this.#N()),this.#O.observe(this.#h))}disconnected(){super.disconnected(),this.#w!=null&&(clearTimeout(this.#w),this.#w=null),this.#O&&(this.#O.disconnect(),this.#O=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#$),this.#h.removeEventListener("pointermove",this.#C),this.#h.removeEventListener("pointerup",this.#P),this.#h.removeEventListener("keydown",this.#T)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#k),this.#d.removeEventListener("pointermove",this.#y),this.#d.removeEventListener("pointerup",this.#A),this.#d.removeEventListener("keydown",this.#E)),this.#g?.removeEventListener("input",this.#b),this.#S?.removeEventListener("input",this.#b),this.#v?.removeEventListener("input",this.#b);for(let{el:t,handler:e}of this.#x)t.removeEventListener("click",e);this.#x=[],this.#r=!1}#L(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),n=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*Ia,this.#e=1-n,this.#I("input")}#Q(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#I("input")}#M(t){if(t){if(t.startsWith("#")){let e=z$(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-area-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#I(t){let e=[];if(this.#e>this.maxL&&(e.push({axis:"l",requested:this.#e,clamped:this.maxL,reason:"max-l"}),this.#e=this.maxL),this.#e<this.minL&&(e.push({axis:"l",requested:this.#e,clamped:this.minL,reason:"min-l"}),this.#e=this.minL),this.#i>this.maxChroma&&(e.push({axis:"c",requested:this.#i,clamped:this.maxChroma,reason:"max-chroma"}),this.#i=this.maxChroma),Number.isFinite(this.hueDriftMax)){let a=Number.isFinite(this.baseHue)?this.baseHue:Number.isFinite(this.#n)?this.#n:this.#s;Number.isFinite(this.#n)||(this.#n=a);let l=(this.#s-a+540)%360-180,h=this.hueDriftMax;if(l>h){let c=this.#s;this.#s=(a+h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}else if(l<-h){let c=this.#s;this.#s=(a-h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}}let i=Da(this.#e,this.#i,this.#s),n=Wn(this.#e,i,this.#s),r=this.#R();this.#a=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#R(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#X(t,e){let i=t==="oklch"?this.#R():Wn(this.#e,Da(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#w!=null&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.#w=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#N(){if(!this.#l||!this.#c||!this.#h)return;let t=Math.min(window.devicePixelRatio||1,2)*.5,e=Math.round(this.#h.clientWidth*t),i=Math.round(this.#h.clientHeight*t);if(e<=0||i<=0)return;this.#l.width=e,this.#l.height=i;let n=this.#c.createImageData(e,i),r=n.data,o=this.#s;for(let a=0;a<i;a++){let l=1-a/(i-1);for(let h=0;h<e;h++){let c=h/(e-1)*Ia,u=Da(l,c,o),[d,f,p]=qb(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#c.putImageData(n,0,0)}render(){if(this.#a?this.#a=!1:this.#M(this.value),this.#N(),this.#u){let r=this.#i/Ia*100,o=(1-this.#e)*100;this.#u.style.left=`${r}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Wn(this.#e,Da(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(Wn(.7,.15,o));this.#d.style.background=`linear-gradient(to right, ${r.join(", ")})`,this.#d.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#f&&(this.#f.style.left=`${this.#s/360*100}%`,this.#f.style.background=Wn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#R());let t=this.querySelector('slider-ui[data-channel="hue"]'),e=this.querySelector('slider-ui[data-channel="chroma"]'),i=this.querySelector('slider-ui[data-channel="lightness"]');t&&(t.value=Math.round(this.#s)),e&&(e.value=+this.#i.toFixed(3)),i&&(i.value=+this.#e.toFixed(3)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let n=Wn(this.#e,Da(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#R()),this.#m&&(this.#m.textContent=n)}onFormReset(){this.value="#3b82f6"}};M();A("color-area-ui",Fn);var Un=class extends _{static get properties(){return{..._.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#o=null;connected(){this.#a(),this.#l(),this.#d(),this.syncValue(this.value)}render(){this.#d(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#a(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-area-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-area-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#l(){if(this.#r)return;this.#r=!0,this.#i.addEventListener("change",this.#c),this.#i.addEventListener("input",this.#h);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),typeof MutationObserver<"u"&&(this.#o=new MutationObserver(t),this.#o.observe(this.#t,{attributes:!0,attributeFilter:["open"]}))}#c=t=>{this.#u(t.detail,"change")};#h=t=>{this.#u(t.detail,"input")};#u(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#d(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#d(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#n&&(this.#n.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#c),this.#i?.removeEventListener("input",this.#h),this.#o?.disconnect(),this.#o=null,this.#r=!1}};M();A("color-input-ui",Un);X();Ge();var Ad=0,Yn=class extends C{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#o=!1;#a=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++Ad}`,o={id:r,from:t,to:e,fromPort:i,toPort:n};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),r}disconnect(t){let e=this.#e.findIndex(n=>n.id===t);if(e===-1)return;let[i]=this.#e.splice(e,1);this.#h(),this.dispatchEvent(new CustomEvent("noodle-disconnect",{bubbles:!0,detail:{...i}}))}setConnections(t){this.#e=t.map(e=>({id:e.id||`noodle-${++Ad}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#f()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),typeof ResizeObserver<"u"&&(this.#s=new ResizeObserver(()=>this.#h()),this.#s.observe(this)),typeof MutationObserver<"u"&&(this.#n=new MutationObserver(()=>{this.#b(),this.#h()})),this.#u();for(let t of this.#m())this.#s?.observe(t);this.#b(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#c?.(),this.#s?.disconnect(),this.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#$(),this.#t?.remove(),this.#t=null,this.#o=!1}#h(){this.#r||typeof requestAnimationFrame=="function"&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#f()}))}#u(){this.#n?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#d(){this.#n?.disconnect()}#f(){if(!this.#t)return;this.#d();let t=this.#m();for(let r of t)this.#s?.observe(r);this.#C();let e=this.#e.map(r=>{let o=this.#p(r.from),a=this.#p(r.to);if(!o||!a)return null;let l=this.#O(o,r.fromPort),h=this.#O(a,r.toPort);return!l||!h?null:{id:r.id,d:this.#g(l,h,r.fromPort,r.toPort)}}).filter(Boolean),i=new Map;for(let r of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(r.getAttribute("data-noodle-id"),r);let n=new Set(e.map(r=>r.id));for(let[r,o]of i)n.has(r)||o.remove();for(let{id:r,d:o}of e){let a=i.get(r);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",r),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#a&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#u()}#p(t){return te(t)?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#O(t,e){let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),r=this.offsetWidth&&n.width?n.width/this.offsetWidth:1,o=(i.left-n.left)/r,a=(i.top-n.top)/r,l=i.width/r,h=i.height/r;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#g(t,e,i,n){switch(this.curve){case"step":return this.#x(t,e);case"straight":return this.#w(t,e);default:return this.#S(t,e,i,n)}}#S(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#v(t,i,l),c=this.#v(e,n,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#v(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#x(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#w(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#b(){this.#d(),this.#$();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#P(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#k(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#C(),this.#u()}#$(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#C(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#P(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#O(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#P(t,e){return t._noodleId||(t._noodleId=`_n${++Ad}`),`${t._noodleId}:${e}`}#k=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#O(e,i),o=l=>{if(!this.#a)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#g(r,{x:c,y:u},i,this.#y(r,{x:c,y:u})),this.#h(),this.#A(l.clientX,l.clientY,e),this.dispatchEvent(new CustomEvent("noodle-drag",{bubbles:!0,detail:{from:e,fromPort:i,x:c,y:u}}))},a=l=>{try{n.releasePointerCapture(l.pointerId)}catch{}if(n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#T(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#E(),this.#a=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#a=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#E(),this.#l=null,this.#c=null},this.#a={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#y(t,e){let i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"left":"right":n>0?"top":"bottom"}#A(t,e,i){this.#E();let n=this.#T(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#T(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#m().find(g=>g._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#E(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};M();A("noodles-ui",Yn);var Ui={};function de(s,t){Ui[s]=t}function Hn(s,t){let e=s.firstElementChild;(!e||e.tagName!=="SPAN")&&(s.replaceChildren(),e=s.appendChild(document.createElement("span"))),e.textContent=t,s.title=t}var $d={basic:(s,t)=>s<t?-1:s>t?1:0,alphanumeric:(s,t)=>String(s??"").localeCompare(String(t??""),void 0,{numeric:!0,sensitivity:"base"}),numeric:(s,t)=>(Number(s)||0)-(Number(t)||0),datetime:(s,t)=>new Date(s||0).getTime()-new Date(t||0).getTime()};de("text",{render(s,t,e){Hn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("number",{render(s,t,e){Hn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),de("currency",{render(s,t,e,i){Hn(e,s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:i?.currency||"USD"}).format(s):"")},format(s,t,e){return s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:e?.currency||"USD"}).format(s):""},align:"right",sortFn:"numeric"}),de("percent",{render(s,t,e){Hn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var Nb={year:"numeric",month:"short",day:"numeric"};de("date",{render(s,t,e){Hn(e,s?new Intl.DateTimeFormat("en-US",Nb).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",Nb).format(new Date(s)):""},align:"left",sortFn:"datetime"});var zb={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};de("datetime",{render(s,t,e){Hn(e,s?new Intl.DateTimeFormat("en-US",zb).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",zb).format(new Date(s)):""},align:"left",sortFn:"datetime"}),de("boolean",{render(s,t,e){let i=e.querySelector("check-ui");i||(e.textContent="",i=document.createElement("check-ui"),i.setAttribute("disabled",""),e.appendChild(i)),s?i.setAttribute("checked",""):i.removeAttribute("checked")},format(s){return s?"Yes":"No"},align:"center",sortFn:"basic"}),de("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let o=(i?.variants||{})[s];o?(n.setAttribute("variant",o),n.removeAttribute("tone")):(n.removeAttribute("variant"),n.setAttribute("tone","muted"))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("avatar",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("avatar-ui");o.setAttribute("size","sm");let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("avatar-ui"),r=i.querySelector("span");n.setAttribute("text",String(s??"")),r.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--md-sys-color-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("markdown",{render(s,t,e){let i=e.firstElementChild;(!i||i.tagName!=="SPAN")&&(e.replaceChildren(),i=e.appendChild(document.createElement("span"))),i.innerHTML=Mn(String(s??"")),e.title=i.textContent},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center"),i.style.flex="1",i.style.minWidth="0";let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");a.style.flexShrink="0",i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),de("actions",{attachesListeners:!0,render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});X();Ge();function B$(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function bi(s,t){return typeof t.accessor=="function"?t.accessor(s):B$(s,t.key)}function fh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
213
- `)?'"'+t.replace(/"/g,'""')+'"':t}function Xa(s,t,e){s.getAttribute(t)!==e&&s.setAttribute(t,e)}function Bb(s,t){s.hasAttribute(t)&&s.removeAttribute(t)}var ph=new WeakSet;function Cd(s,t){for(;s.children.length>t.length;)s.lastChild.remove();for(let e=0;e<t.length;e++){let i=s.children[e],n=t[e];i?(ph.has(n)||!i.isEqualNode(n))&&s.replaceChild(n,i):s.appendChild(n)}}var Gn=class extends C{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},valign:{type:String,default:"center",reflect:!0},frameless:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},paginate:{type:Number,default:0,reflect:!0},noPager:{type:Boolean,default:!1,reflect:!0,attribute:"no-pager"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0},clickableRows:{type:Boolean,default:!1,reflect:!0,attribute:"clickable-rows"}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#o=0;#a=new Set;#l=new Map;#c=null;#h=!1;#u=-1;#d=null;#f=null;get#p(){return this.hasAttribute("range-total")}#m(){let t=Number(this.rangeTotal);return Number.isFinite(t)&&t>0?Math.trunc(t):0}set columns(t){this.#t=Array.isArray(t)?t:[],this.#y()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#a.clear(),this.#p||(this.#o=0),this.#y()}get data(){return this.#e}get selected(){return[...this.#a].sort((t,e)=>t-e)}set selected(t){if(this.#a.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#a.add(e);this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#a.size!==0&&(this.#a.clear(),this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#p||(this.#o=0),this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#p||(this.#o=0),this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}#O=t=>{t.target===this&&(this.search=t.detail?.value??"")};#g=t=>{if(t.target!==this)return;let{key:e,value:i,op:n}=t.detail||{};e&&this.setFilter(e,i,n)};#S=t=>{t.target===this&&this.clearFilters()};#v=t=>{if(t.target!==this)return;let e=t.detail?.columns;Array.isArray(e)&&(this.columns=e)};#x=t=>{t.target===this&&(this.paginate=Number(t.detail?.pageSize)||0)};#w=t=>{if(t.target!==this||!(this.paginate>0))return;let e=Number(t.detail?.page);if(!Number.isFinite(e))return;let i=Math.max(1,Math.min(Math.trunc(e),this.#Q));this.#o=i-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#o}}))};get filteredCount(){return this.#E().length}toggleExpand(t){!this.#b(t)&&!this.#n.has(t)||(this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#y())}get expanded(){return[...this.#n]}expandRenderer=null;rowExpandable=null;#b(t){return this.expandable?typeof this.rowExpandable=="function"?!!this.rowExpandable(this.#e[t],t):!0:!1}getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#o}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#o=t.page),this.#y()}}#$(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#C(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){if(this.#P(),this.#e.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}Xa(this,"role","grid"),Xa(this,"tabindex","0"),this.#C(),this.#h||(this.#h=!0,this.addEventListener("click",this.#D),this.addEventListener("keydown",this.#G),this.addEventListener("pointerdown",this.#F),this.addEventListener("toolbar-search",this.#O),this.addEventListener("toolbar-filter-set",this.#g),this.addEventListener("toolbar-filter-clear",this.#S),this.addEventListener("toolbar-columns-set",this.#v),this.addEventListener("toolbar-paginate",this.#x),this.addEventListener("footer-page",this.#w))}disconnected(){this.removeEventListener("click",this.#D),this.removeEventListener("keydown",this.#G),this.removeEventListener("pointerdown",this.#F),this.removeEventListener("toolbar-search",this.#O),this.removeEventListener("toolbar-filter-set",this.#g),this.removeEventListener("toolbar-filter-clear",this.#S),this.removeEventListener("toolbar-columns-set",this.#v),this.removeEventListener("toolbar-paginate",this.#x),this.removeEventListener("footer-page",this.#w),this.#h=!1,this.#et(),this.#k&&(cancelAnimationFrame(this.#k),this.#k=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#y()}#P(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null,valign:i.getAttribute("valign")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l));let h=i.getAttribute("meta");if(h)try{n.meta=JSON.parse(h)}catch{}e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#k=null;#y(){!this.isConnected||this.#k||(this.#k=requestAnimationFrame(()=>{this.#k=null,this.render(),this.#$()}))}get#A(){return this.#t.filter(t=>!t.hidden)}#T(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#A)if(this.#l.has(e.key))t.push(`${this.#l.get(e.key)}px`);else if(e.width)t.push(`${e.width}px`);else{let i=e.minWidth?`${e.minWidth}px`:"6rem",n=e.maxWidth?`${e.maxWidth}px`:`${e.flex||1}fr`;t.push(`minmax(${i}, ${n})`)}return t.join(" ")}#E(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#A.some(r=>{let o=bi(n,r);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[n,{op:r,value:o}]of this.#s){let a=this.#t.find(u=>u.key===n),l=bi(i,a||{key:n}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(r){case"contains":if(!h.includes(c))return!1;break;case"equals":if(h!==c)return!1;break;case"startsWith":if(!h.startsWith(c))return!1;break;case"gt":if(Number(l)<=Number(o))return!1;break;case"lt":if(Number(l)>=Number(o))return!1;break;case"gte":if(Number(l)<Number(o))return!1;break;case"lte":if(Number(l)>Number(o))return!1;break;case"between":{let[u,d]=String(o).split(",").map(Number),f=Number(l);if(f<u||f>d)return!1;break}case"select":{if(!c.split(",").map(d=>d.trim()).includes(h))return!1;break}default:if(!h.includes(c))return!1}}return!0})),this.#i.length&&t.sort((e,i)=>{for(let{key:n,dir:r}of this.#i){let o=this.#t.find(u=>u.key===n),a=bi(this.#e[e],o||{key:n}),l=bi(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ui[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=$d[d]||$d.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#L(t){if(this.#p||!this.paginate||this.paginate<=0)return t;let e=this.#o*this.paginate;return t.slice(e,e+this.paginate)}get#Q(){if(!this.paginate||this.paginate<=0)return 1;if(this.#p)return Math.max(1,Math.ceil(this.#m()/this.paginate));let t=this.#E().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#A,e=this.#T();this.style.gridTemplateColumns!==e&&(this.style.gridTemplateColumns=e);let i=this.querySelector(":scope > [data-header]");i||(i=document.createElement("div"),i.setAttribute("role","row"),i.setAttribute("data-header",""),this.prepend(i)),this.#M(i,t),this.#q();let n=this.querySelector(":scope > [data-body]");n||(n=document.createElement("div"),n.setAttribute("role","rowgroup"),n.setAttribute("data-body",""),i.after(n));let r=this.#E(),o=this.#L(r),a=[];for(let u of o){let d=n.querySelector(`:scope > [role="row"][data-index="${u}"]`),f=d||this.#I(u,t);if(d&&this.#R(d,u,t),this.#b(u)&&this.#n.has(u)?Xa(f,"data-expanded",""):Bb(f,"data-expanded"),a.push(f),this.#b(u)&&this.#n.has(u)){let p=n.querySelector(`:scope > [data-detail-row][data-for="${u}"]`);if(!p&&(p=document.createElement("div"),p.setAttribute("data-detail-row",""),p.dataset.for=u,this.expandRenderer)){let m=this.expandRenderer(this.#e[u],u);Wi(m)?p.appendChild(m):p.textContent=String(m)}a.push(p)}}let l=[...n.children];for(let u of l)a.includes(u)||u.remove();for(let u=0;u<a.length;u++)n.children[u]!==a[u]&&(n.children[u]?n.insertBefore(a[u],n.children[u]):n.appendChild(a[u]));this.#X(n),this.#N(n,r,t);let h=this.paginate>0&&!this.noPager&&(this.#p?this.#m()>0:this.#e.length>0),c=this.querySelector(":scope > [data-footer]");h?(c||(c=document.createElement("div"),c.setAttribute("data-footer",""),this.appendChild(c)),this.#Z(c)):c&&c.remove()}#M(t,e){let i=this.#e.length>0&&this.#a.size===this.#e.length,n=[];if(this.expandable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-expand-col",""),r.setAttribute("aria-label","Expand"),n.push(r)}if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-column-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#B(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}Cd(t,n)}#I(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#R(i,t,e),i}#R(t,e,i){let n=this.#e[e],r=this.#a.has(e);Xa(t,"data-index",String(e)),r?Xa(t,"aria-selected","true"):Bb(t,"aria-selected");let o=[];if(this.expandable){let a=document.createElement("div");if(a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col",""),this.#b(e)){let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l)}o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=bi(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);Wi(u)?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u),ph.add(l)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Ui[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta),u.attachesListeners&&ph.add(l);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Ui[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.valign&&(l.dataset.valign=a.valign),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}Cd(t,o)}#X(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let n=this.#A,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("corner-radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#N(t,e,i){let n=i.some(a=>a.aggregate),r=this.querySelector(":scope > [data-agg-row]");if(!n||this.#e.length===0){r&&r.remove();return}r||(r=document.createElement("div"),r.setAttribute("role","row"),r.setAttribute("data-agg-row",""),t.after(r));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}for(let a of i){let l=document.createElement("div");if(l.setAttribute("role","gridcell"),a.aggregate){let h=e.map(d=>{let f=bi(this.#e[d],a);return f!=null?Number(f):NaN}).filter(d=>!isNaN(d)),c;switch(a.aggregate){case"sum":c=h.reduce((d,f)=>d+f,0);break;case"avg":c=h.length?h.reduce((d,f)=>d+f,0)/h.length:0;break;case"min":c=h.length?Math.min(...h):0;break;case"max":c=h.length?Math.max(...h):0;break;case"count":c=e.length;break;default:c=""}let u=Ui[a.type||"text"];typeof c=="number"&&u?.render?(u.render(c,{},l,a.meta),u.attachesListeners&&ph.add(l)):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}Cd(r,o)}#Z(t){let e=t.querySelector("pagination-ui");e||(t.innerHTML="",e=document.createElement("pagination-ui"),e.addEventListener("page-change",r=>{this.#o=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#o}}))}),t.appendChild(e));let i=this.#Q,n=Math.min(this.#o,i-1);e.setAttribute("page",String(n+1)),e.setAttribute("total",String(i))}#B(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let n=[...new Set(this.#e.map(o=>{let a=bi(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),r=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of n){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=r.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let n=document.createElement("input");n.type="number",n.placeholder="Filter...",n.value=i?.value??"",n.setAttribute("data-filter-input","");let r=document.createElement("select");r.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),r.appendChild(h)}let o=()=>{n.value?this.setFilter(t.key,n.value,r.value):this.setFilter(t.key,null)};n.addEventListener("input",o),r.addEventListener("change",o),e.appendChild(r),e.appendChild(n)}else{let n=document.createElement("input");n.type="text",n.placeholder=`Filter ${t.label||t.key}...`,n.value=i?.value??"",n.setAttribute("data-filter-input",""),n.addEventListener("input",()=>{n.value?this.setFilter(t.key,n.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(n)}if(i){let n=document.createElement("button");n.textContent="Clear",n.setAttribute("data-filter-clear",""),n.addEventListener("click",()=>{this.setFilter(t.key,null),this.#d=null,this.#y()}),e.appendChild(n)}return this.#f!=null&&cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{if(this.#f=null,!this.isConnected)return;let n=e.querySelector("input");n&&n.focus()}),e}#q(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:n,value:r}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=n==="select"?`${r.split(",").length} selected`:r;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#F=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-column-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#_(t,e))};#D=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#d=this.#d===c?null:c,this.#y();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#y());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-column-resize-handle]");if(r&&this.contains(r)){this.#_(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#a.add(u);else this.#a.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#u>=0){let f=Math.min(this.#u,u),p=Math.max(this.#u,u);for(let m=f;m<=p;m++)d?this.#a.add(m):this.#a.delete(m)}else d?this.#a.add(u):this.#a.delete(u);this.#u=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(g=>g.key===d),m=p?bi(f,p):void 0;this.dispatchEvent(new CustomEvent("cell-click",{bubbles:!0,detail:{key:d,row:f,value:m,dataIndex:u}})),this.dispatchEvent(new CustomEvent("row-click",{bubbles:!0,detail:{row:f,dataIndex:u}}))}}};#z=null;#_(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;e.setAttribute("data-resizing",""),this.#z={key:i,col:n,startX:a,startWidth:o,handle:e},document.addEventListener("pointermove",this.#j),document.addEventListener("pointerup",this.#U)}#j=t=>{if(!this.#z)return;let{key:e,col:i,startX:n,startWidth:r}=this.#z,o=t.clientX-n,a=r+o,l=i.minWidth||48,h=i.maxWidth||1/0;a=Math.max(l,Math.min(h,a)),this.#l.set(e,Math.round(a)),this.style.gridTemplateColumns=this.#T()};#U=t=>{if(!this.#z)return;let{key:e,handle:i}=this.#z;document.removeEventListener("pointermove",this.#j),document.removeEventListener("pointerup",this.#U),i.removeAttribute("data-resizing");let n=this.#l.get(e);this.#z=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:n}})),this.render()};#et(){document.removeEventListener("pointermove",this.#j),document.removeEventListener("pointerup",this.#U),this.#z=null}#G=t=>{let i=this.#A.length+(this.expandable?1:0)+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.children.length:0;this.#c||(this.#c={row:0,col:0});let{row:o,col:a}=this.#c,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#c={row:o,col:a},this.#Y())};#Y(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#c)return;let{row:e,col:i}=this.#c,n;e===-1?n=this.querySelector(":scope > [data-header]")?.children[i]:n=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],n&&(n.setAttribute("data-focused",""),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#A,i=this.#E(),n=e.map(c=>fh(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=bi(u,d);if(typeof d.format=="function")return fh(d.format(f,u));let p=Ui[d.type||"text"];return p?.format?fh(p.format(f,u,d.meta)):fh(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
214
- `),a=new Blob([o],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),h=document.createElement("a");h.href=l,h.download=t,h.style.display="none",document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(l)}};M();A("table-ui",Gn);X();var V$=200,_$=896,j$=640,W$=416;function Ed(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-empty",""),t.setAttribute("color","subtle"),t.setAttribute("variant","caption"),t.textContent=s,t}function Pd(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}function Qd(s){let t=s.label;return typeof t=="string"&&t.trim()?t:s.key}var F$=50,Vb=500;function _b(s,t){if(typeof t?.accessor=="function")return t.accessor(s);let e=t?.key;if(!e||s==null)return;let i=String(e).split("."),n=s;for(let r of i){if(n==null)return;n=n[r]}return n}function U$(s){if(!s)return!1;let t=String(s);return!!(t==="id"||t==="ID"||t==="uuid"||t==="guid"||/[a-z](Id|ID)$/.test(t)||/_id$/i.test(t))}function Y$(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(U$(s?.key))return"text";let e=[],i=Math.min(t?.length??0,Vb),n=new Set;for(let r=0;r<i;r++){let o=_b(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>F$))return"text"}return e.length?"select":"text"}function H$(s,t){let e=new Set,i=Math.min(t?.length??0,Vb);for(let n=0;n<i;n++){let r=_b(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var Kn=class s extends C{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},rangeStart:{type:Number,default:0,reflect:!0,attribute:"range-start"},rangeEnd:{type:Number,default:0,reflect:!0,attribute:"range-end"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},pageSize:{type:Number,default:0,reflect:!0,attribute:"page-size"},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},chromeOnly:{type:Boolean,default:!1,reflect:!0,attribute:"chrome-only"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0},stage:{type:String,default:"",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down","dots-three-vertical"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;#o=[];#a=null;#l=null;#c=null;set pageSizeOptions(t){this.#o=Array.isArray(t)?t.map(Number).filter(e=>Number.isFinite(e)):[],this.#b()}get pageSizeOptions(){return this.#o}static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){if(this.setAttribute("role","toolbar"),this.#d(),this.#o.length===0&&this.hasAttribute("page-size-options"))try{let t=JSON.parse(this.getAttribute("page-size-options"));Array.isArray(t)&&(this.pageSizeOptions=t)}catch{}this.#O(),this.#f(),this.#k(),this.#l=this.clientWidth||null,this.#u(),typeof ResizeObserver<"u"&&(this.#a=new ResizeObserver(t=>{let{inlineSize:e}=t[0].contentBoxSize[0];this.#l=e,!this.#c&&(this.#c=requestAnimationFrame(()=>{this.#c=null,this.#u()}))}),this.#a.observe(this))}updated(t){(t.has("noFilter")||t.has("noSort")||t.has("noColumns")||t.has("noSearch")||t.has("chromeOnly"))&&this.#C(),t.has("placeholder")&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#w(),t==="stage"&&this.#u()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#A(),this.#m(),this.#c!=null&&(cancelAnimationFrame(this.#c),this.#c=null),this.#a?.disconnect(),this.#a=null}#h(t){let e=getComputedStyle(this),i=(a,l)=>{let h=xd(a);return Number.isFinite(h)?h:l},n=i(e.getPropertyValue("--table-toolbar-bp-search-tight"),_$),r=i(e.getPropertyValue("--table-toolbar-bp-icon-only"),j$),o=i(e.getPropertyValue("--table-toolbar-bp-overflow"),W$);return t<=o?"overflow":t<=r?"icon-only":t<=n?"search-tight":"full"}#u(){let t=this.stage||(this.#l==null?"full":this.#h(this.#l));this.getAttribute("data-stage-resolved")!==t&&this.setAttribute("data-stage-resolved",t)}render(){this.#f(),this.#k(),this.#x(),this.#w(),this.#b()}#d(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#f(){let t=this.#p();if(t===this.#t||(this.#m(),!t))return;this.#t=t;let e=()=>this.#I(),i=()=>this.#Q();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#p(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#m(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#O(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-scope","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="scope"&&e.appendChild(m);let i=document.createElement("div");i.setAttribute("data-title","");let n=document.createElement("span");n.setAttribute("data-heading",""),i.appendChild(n);let r=document.createElement("badge-ui");r.setAttribute("data-toolbar-count-badge",""),r.setAttribute("size","sm"),r.setAttribute("tone","muted"),r.hidden=!0,i.appendChild(r);let o=document.createElement("div");o.setAttribute("data-summary",""),o.hidden=!0;let a=document.createElement("span");a.setAttribute("data-summary-text",""),o.appendChild(a);let l=document.createElement("span");l.setAttribute("data-summary-compact",""),l.hidden=!0,o.appendChild(l);let h=document.createElement("div");h.setAttribute("data-summary-empty",""),h.hidden=!0;for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="empty"&&h.appendChild(m);o.appendChild(h);let c=document.createElement("div");c.setAttribute("data-controls",""),c.appendChild(this.#S("filter","Filter","funnel-simple")),c.appendChild(this.#S("sort","Sort","arrows-down-up")),c.appendChild(this.#S("columns","Columns","columns")),c.appendChild(this.#v());let u=document.createElement("search-ui");u.setAttribute("data-search",""),u.setAttribute("size","sm"),u.setAttribute("placeholder",this.placeholder),u.setAttribute("debounce",String(V$)),u.addEventListener("search",this.#P);let d=document.createElement("select-ui");d.setAttribute("data-page-size",""),d.setAttribute("size","sm"),d.setAttribute("aria-label","Rows per page"),d.hidden=!0,d.addEventListener("change",this.#$);let f=document.createElement("div");f.setAttribute("data-actions-leading","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="actions-leading"&&f.appendChild(m);let p=document.createElement("div");p.setAttribute("data-actions","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="actions"&&p.appendChild(m);t.appendChild(e),t.appendChild(i),t.appendChild(o),t.appendChild(c),t.appendChild(u),t.appendChild(f),t.appendChild(d),t.appendChild(p),this.appendChild(t),this.#x(),this.#w(),this.#C(),this.#b()}#g(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#S(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("size","sm"),n.setAttribute("aria-haspopup","menu"),n.setAttribute("title",e),n.addEventListener("click",r=>{r.stopPropagation(),this.#y(t,n)}),n}#v(){let t=document.createElement("menu-ui");t.setAttribute("data-toolbar-overflow","");let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("icon","dots-three-vertical"),e.setAttribute("variant","outline"),e.setAttribute("size","sm"),e.setAttribute("aria-label","More table actions"),e.setAttribute("aria-haspopup","menu"),t.appendChild(e);for(let[i,n,r]of[["filter","Filter","funnel-simple"],["sort","Sort","arrows-down-up"],["columns","Columns","columns"]]){let o=document.createElement("menu-item-ui");o.setAttribute("icon",r),o.setAttribute("text",n),o.setAttribute("value",i),t.appendChild(o)}return t.addEventListener("action",i=>{this.#y(i.detail.value,e)}),t}#x(){let t=this.querySelector(":scope [data-heading]");t&&(this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0);let e=this.querySelector(":scope [data-toolbar-count-badge]");if(e){let n=this.count?.toString().trim(),r=this.#t?.data?.length,o=n||(Number.isFinite(r)?String(r):"");o?(e.setAttribute("text",o),e.hidden=!1):e.hidden=!0}let i=this.querySelector(":scope > [data-toolbar] > [data-title]");i&&(i.hidden=Array.from(i.children).every(n=>n.hidden))}#w(){let t=this.querySelector(":scope > [data-toolbar] > [data-summary]");if(!t)return;let e=t.querySelector(":scope > [data-summary-text]"),i=t.querySelector(":scope > [data-summary-compact]"),n=t.querySelector(":scope > [data-summary-empty]"),r=Number(this.rangeStart)||0,o=Number(this.rangeEnd)||0,a=Number(this.rangeTotal)||0;if(r>0&&o>0&&a>0){e&&(e.textContent=`Showing ${r}\u2013${o} of ${a}`),e&&(e.hidden=!1),i&&(i.textContent=`${r}\u2013${o}/${a}`),i&&(i.hidden=!1),n&&(n.hidden=!0),t.hidden=!1;return}let l=this.hasAttribute("range-total")&&this.getAttribute("range-total")==="0",h=!!n&&n.childNodes.length>0;if(l&&h){e&&(e.hidden=!0),i&&(i.hidden=!0),n.hidden=!1,t.hidden=!1;return}e&&(e.hidden=!0),i&&(i.hidden=!0),n&&(n.hidden=!0),t.hidden=!0}#b(){let t=this.querySelector(":scope > [data-toolbar] > [data-page-size]");if(!t)return;let e=this.#o;if(!e.length){t.hidden=!0;return}t.hidden=!1;let i=e.map(o=>({value:String(o),label:`${o} / page`}));t.options=i;let n=Number(this.pageSize)||0,r=e.includes(n)?n:e[0];t.value=String(r)}#$=t=>{let e=Number(t.detail?.value??this.querySelector(":scope [data-page-size]")?.value)||0;this.pageSize=e,this.#t&&this.#t.dispatchEvent(new CustomEvent("toolbar-paginate",{bubbles:!0,detail:{pageSize:e}})),this.dispatchEvent(new CustomEvent("page-size-change",{bubbles:!0,detail:{pageSize:e}}))};#C(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=this.chromeOnly,i=(l,h)=>{let c=t.querySelector(l);c&&(c.hidden=h)},n=e||this.noFilter,r=e||this.noSort,o=e||this.noColumns;i('[data-toolbar-btn="filter"]',n),i('[data-toolbar-btn="sort"]',r),i('[data-toolbar-btn="columns"]',o),i("[data-search]",e||this.noSearch);let a=t.querySelector("[data-toolbar-overflow]");if(a){let l={filter:n,sort:r,columns:o};for(let h of a.querySelectorAll("menu-item-ui"))h.hidden=!!l[h.getAttribute("value")];a.hidden=n&&r&&o}}#P=t=>{let e=t.detail?.value??"";this.#t&&this.#t.dispatchEvent(new CustomEvent("toolbar-search",{bubbles:!0,detail:{value:e}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#k(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#x()}#y(t,e){if(this.#i?.kind===t){this.#A();return}this.#A();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#L(i),t==="sort"&&this.#M(i),t==="columns"&&this.#R(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=mt(e,i,{placement:"bottom",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:n},this.#s||(this.#s=!0,this.#n=requestAnimationFrame(()=>{this.#n=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#T,!0),document.addEventListener("keydown",this.#E,!0))}))}#A(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#T,!0),document.removeEventListener("keydown",this.#E,!0))}}#T=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#A())};#E=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#A(),this.#i?.btn?.focus?.({preventScroll:!0}))};#L(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ed("No filterable columns"));return}let i=e.filters||{};t.appendChild(Pd("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",Qd(o));let l=Y$(o,r),h=i[o.key];if(l==="select"){let c=document.createElement("select-ui");c.setAttribute("data-filter-input",""),c.setAttribute("multiple",""),c.setAttribute("placeholder","\u2014");let u=H$(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";e.dispatchEvent(new CustomEvent("toolbar-filter-set",{bubbles:!0,detail:{key:o.key,value:d||null,op:"select"}})),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;e.dispatchEvent(new CustomEvent("toolbar-filter-set",{bubbles:!0,detail:{key:o.key,value:u||null,op:"contains"}})),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#g("Clear all filters",()=>{e.dispatchEvent(new CustomEvent("toolbar-filter-clear",{bubbles:!0})),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#Q()});t.appendChild(o)}}#Q(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#L(t.panel))}#M(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ed("No sortable columns"));return}t.appendChild(Pd("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",Qd(o)),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#I()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#g("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#I()});t.appendChild(o)}}#I(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#M(t.panel))}#R(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ed("No columns"));return}t.appendChild(Pd("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",Qd(n));let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.dispatchEvent(new CustomEvent("toolbar-columns-set",{bubbles:!0,detail:{columns:a}})),this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};M();A("table-toolbar-ui",Kn);X();var Jn=class extends C{static properties={for:{type:String,default:"",reflect:!0},page:{type:Number,default:1,reflect:!0},pageSize:{type:Number,default:0,reflect:!0,attribute:"page-size"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},siblings:{type:Number,default:1,reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;#t=null;connected(){this.#e()}render(){this.#s(),this.#l()}disconnected(){this.#r()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#l()}#e(){if(this.querySelector(":scope > [data-row]"))return;let t=document.createElement("div");t.setAttribute("data-row","");let e=document.createElement("div");e.setAttribute("data-range",""),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true");let i=document.createElement("span");i.setAttribute("data-range-text",""),e.appendChild(i);let n=document.createElement("div");n.setAttribute("data-range-empty",""),n.hidden=!0;for(let a of[...this.children])a!==t&&a.getAttribute?.("slot")==="empty"&&n.appendChild(a);e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-pager","");let o=document.createElement("pagination-ui");o.setAttribute("data-footer-pager",""),o.addEventListener("page-change",this.#i),r.appendChild(o),t.appendChild(e),t.appendChild(r),this.appendChild(t)}#i=t=>{t.stopPropagation();let e=Number(t.detail?.page);Number.isFinite(e)&&(this.hasAttribute("range-total")||(this.page=e),this.#t&&this.#t.dispatchEvent(new CustomEvent("footer-page",{bubbles:!0,composed:!0,detail:{page:e}})),this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:e}})))};#s(){let t=this.#n();t!==this.#t&&(this.#r(),t&&(this.#t=t,t.addEventListener("page",this.#o),t.addEventListener("filter-change",this.#a),t.addEventListener("sort",this.#a)))}#n(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope > table-ui")||null}#r(){this.#t&&(this.#t.removeEventListener("page",this.#o),this.#t.removeEventListener("filter-change",this.#a),this.#t.removeEventListener("sort",this.#a)),this.#t=null}#o=t=>{let e=Number(t.detail?.page);Number.isFinite(e)&&(this.page=e+1)};#a=()=>{this.#l()};#l(){let t=this.querySelector(":scope > [data-row]");if(!t)return;let e=t.querySelector(":scope > [data-range]"),i=e?.querySelector(":scope > [data-range-text]"),n=e?.querySelector(":scope > [data-range-empty]"),r=t.querySelector(":scope > [data-pager]"),o=r?.querySelector(":scope > pagination-ui"),a=this.#t,l=!!a&&a.hasAttribute("range-total"),h=!!a&&!l&&Number(a.paginate)>0,c=this.hasAttribute("range-total"),u=this.hasAttribute("page-size"),d=c||l||h,f=S=>{let v=Number(S);return Number.isFinite(v)&&v>0?Math.trunc(v):0},p=c?f(this.rangeTotal):l?f(a.rangeTotal):h&&Number(a.filteredCount)||0,m=u?Number(this.pageSize)||0:l||h?Number(a.paginate)||0:Number(this.pageSize)||0;if(!e)return;if(!d){e.hidden=!0,r&&(r.hidden=!0);return}if(e.hidden=!1,p===0){let S=!!n&&n.childNodes.length>0;i&&(i.hidden=!0),n&&(n.hidden=!S),r&&(r.hidden=!0);return}if(n&&(n.hidden=!0),m<=0){i&&(i.hidden=!1,i.textContent=`${p} items`),r&&(r.hidden=!0);return}let g=Math.max(1,Math.ceil(p/m)),O=Math.max(1,Math.min(Number(this.page)||1,g)),w=(O-1)*m+1,x=Math.min(O*m,p);i&&(i.hidden=!1,i.textContent=`Showing ${w}\u2013${x} of ${p}`),r&&(r.hidden=g<=1),o&&(o.setAttribute("page",String(O)),o.setAttribute("total",String(g)),o.setAttribute("siblings",String(Math.max(0,Number(this.siblings)||0))),o.setAttribute("size",this.size||"md"))}};M();A("table-footer-ui",Jn);X();var tr=class extends C{static properties={orientation:{type:String,default:"vertical",reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll(":scope > timeline-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last","")}},er=class extends C{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}#i(t){return t.dataset.timelineItemStamped="1",t}#s(t){return t?.dataset?.timelineItemStamped==="1"}connected(){for(let t of["label","description","time"]){if(lt(this,t).length)continue;let e=this.#i(document.createElement("span"));e.setAttribute("slot",t),this.appendChild(e)}}render(){let t=this.querySelector(':scope > [slot="label"]'),e=this.querySelector(':scope > [slot="description"]'),i=this.querySelector(':scope > [slot="time"]');this.#s(t)&&(t.textContent=this.text),this.#s(e)&&(e.textContent=this.description),this.#s(i)&&(i.textContent=this.duration||this.time);let n=this.querySelector(':scope > [slot="icon"]');if(this.icon)if(n)this.#s(n)&&n.setAttribute("name",this.icon);else{let o=this.#i(document.createElement("icon-ui"));o.setAttribute("slot","icon"),o.setAttribute("name",this.icon),this.prepend(o)}else this.#s(n)&&n.remove();let r=this.querySelector(':scope > [slot="outcomes"]');if(this.#t.length>0){r||(r=document.createElement("ul"),r.setAttribute("slot","outcomes"),this.appendChild(r)),r.innerHTML="";for(let a of this.#t){let l=document.createElement("li");l.textContent=a,r.appendChild(l)}r.hidden=!this.#e;let o=this.querySelector(":scope > [data-timeline-toggle]");o||(o=document.createElement("button-ui"),o.setAttribute("variant","ghost"),o.setAttribute("size","xs"),o.setAttribute("data-timeline-toggle",""),o.setAttribute("aria-label","Toggle details"),o.addEventListener("click",a=>{a.stopPropagation(),this.#e=!this.#e,this.render(),this.dispatchEvent(new CustomEvent("timeline-toggle",{bubbles:!0,detail:{expanded:this.#e}}))}),this.appendChild(o)),o.setAttribute("icon",this.#e?"caret-down":"caret-right")}else this.querySelector(":scope > [data-timeline-toggle]")?.remove(),r?.remove()}};M();A("timeline-ui",tr),A("timeline-item-ui",er);X();function ir(s){return s.disabled||s.hasAttribute("disabled")}var sr=class extends C{static properties={step:{type:Number,default:0,reflect:!0},orientation:{type:String,default:"horizontal",reflect:!0},interactive:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=()=>this.render();#e=null;connected(){this.addEventListener("click",this.#r),this.addEventListener("keydown",this.#o),!this.#e&&typeof MutationObserver<"u"&&(this.#e=new MutationObserver(this.#t),this.#e.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled"]}))}disconnected(){this.removeEventListener("click",this.#r),this.removeEventListener("keydown",this.#o),this.#e?.disconnect(),this.#e=null}render(){let t=[...this.querySelectorAll("stepper-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];if(e&&e.setAttribute("data-last",""),t.forEach((i,n)=>{i.setAttribute("data-index",n),n<this.step?i.setAttribute("status","completed"):n===this.step?i.setAttribute("status","active"):i.setAttribute("status","idle"),this.interactive?(i.setAttribute("role","button"),n===this.step?i.setAttribute("aria-current","step"):i.removeAttribute("aria-current")):(i.removeAttribute("role"),i.removeAttribute("tabindex"),i.removeAttribute("aria-current"),i.removeAttribute("aria-disabled"))}),this.interactive){let i=t.filter(o=>!ir(o)),n=t[this.step],r=n&&!ir(n)?n:i[0];for(let o of t)ir(o)?(o.setAttribute("aria-disabled","true"),o.removeAttribute("tabindex")):(o.removeAttribute("aria-disabled"),o.setAttribute("tabindex",o===r?"0":"-1"))}}next(){let t=this.querySelectorAll("stepper-item-ui").length;this.step<t-1&&this.step++}prev(){this.step>0&&this.step--}goTo(t){let e=this.querySelectorAll("stepper-item-ui").length-1;this.step=Math.max(0,Math.min(t,e))}get#i(){return[...this.querySelectorAll("stepper-item-ui")]}get#s(){return this.#i.filter(t=>!ir(t))}#n(t){let e=this.#i,i=e.length-1,n=Math.max(0,Math.min(t,i));if(n===this.step||e[n]&&ir(e[n]))return!1;let r=this.step;return this.dispatchEvent(new CustomEvent("step-request",{bubbles:!0,cancelable:!0,detail:{step:n,previous:r}}))?(this.step=n,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{step:this.step}})),!0):!1}#r=t=>{if(!this.interactive)return;let e=t.target.closest("stepper-item-ui");if(!e||!this.contains(e)||ir(e))return;let i=this.#i.indexOf(e);i<0||this.#n(i)};#o=t=>{if(!this.interactive)return;let e=t.target.closest("stepper-item-ui");if(!e||!this.contains(e))return;let i=this.#s,n=i.indexOf(e);if(n<0)return;let r=this.orientation==="vertical",o=r?"ArrowDown":"ArrowRight",a=r?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=n<i.length-1?n+1:0;break;case a:l=n>0?n-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;case"Enter":case" ":t.preventDefault(),this.#n(this.#i.indexOf(e));return;default:return}t.preventDefault();let h=i[l];this.#n(this.#i.indexOf(h))&&h.focus()}},nr=class extends C{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"idle",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t(t){return t.dataset.stepperItemStamped="1",t}#e(t){return t?.dataset?.stepperItemStamped==="1"}connected(){for(let t of["label","description"]){if(this.querySelector(`[slot="${t}"]`))continue;let e=this.#t(document.createElement("span"));e.setAttribute("slot",t),this.appendChild(e)}}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');this.#e(t)&&(t.textContent=this.text),this.#e(e)&&(e.textContent=this.description);let i=this.querySelector('[slot="icon"]');if(this.icon)if(i)this.#e(i)&&i.setAttribute("name",this.icon);else{let n=this.#t(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#e(i)&&i.remove()}};M();A("stepper-ui",sr),A("stepper-item-ui",nr);X();var rr=class extends C{static requiredIcons=["caret-left","caret-right"];static properties={autoplay:{type:Boolean,default:!1,reflect:!0},interval:{type:Number,default:5e3,reflect:!0},noPauseOnHover:{type:Boolean,default:!1,reflect:!0,attribute:"no-pause-on-hover"},loop:{type:Boolean,default:!1,reflect:!0},peek:{type:Boolean,default:!1,reflect:!0},snap:{type:String,default:"start",reflect:!0},gap:{type:String,default:"",reflect:!0},slidesPerView:{type:String,default:"",reflect:!0,attribute:"slides-per-view"},chrome:{type:String,default:"default",reflect:!0},label:{type:String,default:""},counter:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=0;#r=!1;#o=!1;#a=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#n}connected(){if(!this.#t){for(this.#t=document.createElement("div"),this.#t.setAttribute("data-swiper-track","");this.firstChild;)this.#t.appendChild(this.firstChild);this.appendChild(this.#t)}this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.getAttribute("aria-label")||this.setAttribute("aria-label","Carousel"),this.#l(),this.#c(),this.#O(),this.#r||(this.#r=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#b),this.addEventListener("pointerleave",this.#$),this.addEventListener("focusin",this.#C),this.addEventListener("focusout",this.#P)),this.addEventListener("keydown",this.#k),this.#t.addEventListener("pointerdown",this.#A),this.#t.addEventListener("pointermove",this.#T),this.#t.addEventListener("pointerup",this.#E),this.#t.addEventListener("pointercancel",this.#E),this.#t.addEventListener("click",this.#L,!0),this.#t.addEventListener("dragstart",this.#Q)),this.autoplay&&this.play()}render(){if(this.gap&&this.#t){let e=/^[0-9]+$/.test(this.gap)?`var(--a-space-${this.gap})`:this.gap;this.style.setProperty("--swiper-gap",e)}}disconnected(){this.pause(),this.#i?.disconnect(),this.#i=null,this.#t&&this.#s&&this.#t.removeEventListener("scroll",this.#s),this.#s=null,this.removeEventListener("pointerenter",this.#b),this.removeEventListener("pointerleave",this.#$),this.removeEventListener("focusin",this.#C),this.removeEventListener("focusout",this.#P),this.removeEventListener("keydown",this.#k),this.#t&&(this.#t.removeEventListener("pointerdown",this.#A),this.#t.removeEventListener("pointermove",this.#T),this.#t.removeEventListener("pointerup",this.#E),this.#t.removeEventListener("pointercancel",this.#E),this.#t.removeEventListener("click",this.#L,!0),this.#t.removeEventListener("dragstart",this.#Q)),this.#a=null,this.#t=null,this.#r=!1}next(){let t=this.#u()-1,e=this.#m(this.#n),i=Math.min(e+1,t);if(i!==e||this.loop){let n=this.loop&&i===e?0:i;this.goTo(this.#p(n))}}prev(){let t=this.#u()-1,e=this.#m(this.#n),i=Math.max(e-1,0);if(i!==e||this.loop){let n=this.loop&&i===e?t:i;this.goTo(this.#p(n))}}goTo(t){let e=this.slides[t];if(!e||!this.#t)return;let i=Math.max(0,this.#d(e));this.#t.scrollTo({left:i,behavior:"smooth"})}play(){this.pause(),!(typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: reduce)").matches)&&(this.#e=setInterval(()=>{let t=this.#u()-1,i=this.#m(this.#n)>=t;i&&this.loop?this.goTo(this.#p(0)):i?this.pause():this.next()},this.interval||5e3))}pause(){this.#e&&(clearInterval(this.#e),this.#e=null)}#l(){let t=this.slides;t.forEach((e,i)=>{e.setAttribute("role","group"),e.setAttribute("aria-roledescription","slide"),e.getAttribute("aria-label")||e.setAttribute("aria-label",`${i+1} of ${t.length}`)})}#c(){this.#s=()=>{let t=this.#f();t!==this.#n&&(this.#n=t,this.#w(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{index:t,slide:this.slides[t]}})))},this.#t.addEventListener("scroll",this.#s,{passive:!0}),this.#n=this.#f()}#h(){if(!this.#t)return 1;let e=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").trim(),i=parseInt(e,10);return Number.isFinite(i)&&i>0?i:1}#u(){let t=this.slides.length;return t===0?0:this.snap==="center"?t:Math.max(1,t-this.#h()+1)}#d(t){let e=this.#t.clientWidth,i=t.offsetLeft-this.#t.offsetLeft,n=t.offsetWidth;return this.snap==="center"?i+n/2-e/2:this.snap==="end"?i+n-e:i}#f(){if(!this.#t)return 0;let t=this.slides;if(t.length===0)return 0;let e=this.#t.scrollLeft,i=Math.max(0,this.#t.scrollWidth-this.#t.clientWidth),n=0,r=1/0;for(let o=0;o<t.length;o++){let a=Math.max(0,Math.min(i,this.#d(t[o]))),l=Math.abs(e-a);l<r&&(r=l,n=o)}return n}#p(t){if(this.snap!=="end")return t;let e=this.#h();return Math.min(this.slides.length-1,t+e-1)}#m(t){if(this.snap!=="end")return t;let e=this.#h();return Math.max(0,t-e+1)}#O(){this.#o||(this.#o=!0,this.chrome==="toolbar"?this.#S():this.#g(),this.#x(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#x()),this.#i.observe(this)))}#g(){let t=document.createElement("button-ui");t.setAttribute("data-swiper-btn",""),t.setAttribute("data-swiper-prev",""),t.setAttribute("icon","caret-left"),t.setAttribute("variant","ghost"),t.setAttribute("aria-label","Previous slide"),t.addEventListener("press",()=>this.prev());let e=document.createElement("button-ui");e.setAttribute("data-swiper-btn",""),e.setAttribute("data-swiper-next",""),e.setAttribute("icon","caret-right"),e.setAttribute("variant","ghost"),e.setAttribute("aria-label","Next slide"),e.addEventListener("press",()=>this.next()),this.appendChild(t),this.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-dots",""),i.setAttribute("role","tablist"),i.setAttribute("aria-label","Slide indicators"),this.appendChild(i)}#S(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let n=document.createElement("button-ui");n.setAttribute("icon","caret-left"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Previous slide"),n.addEventListener("press",()=>this.prev());let r=document.createElement("button-ui");r.setAttribute("icon","caret-right"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Next slide"),r.addEventListener("press",()=>this.next()),i.appendChild(n),i.appendChild(r),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#v()}#v(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#m(this.#n)+1,i=this.#u();t.textContent=`${e} / ${i}`}#x(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#u();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let n=document.createElement("button-ui");n.setAttribute("variant","ghost"),n.setAttribute("role","tab"),n.setAttribute("aria-label",`Page ${i+1}`),n.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(n)}}this.#w()}#w(){if(!this.#o)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#u()-1,i=Math.min(Math.max(this.#m(this.#n),0),e);[...t.children].forEach((n,r)=>{n.setAttribute("aria-current",r===i?"true":"false")})}this.#v()}#b=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#$=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#C=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#P=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#k=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#y=5;#A=t=>{t.pointerType!=="touch"&&t.button===0&&(t.target.closest("button, button-ui, a, input, select, textarea")||(this.#a={pointerId:t.pointerId,startX:t.clientX,startScrollLeft:this.#t.scrollLeft,hasMoved:!1},this.#t.style.scrollBehavior="auto",this.#t.setAttribute("data-dragging","")))};#T=t=>{if(!this.#a||t.pointerId!==this.#a.pointerId)return;let e=t.clientX-this.#a.startX;if(Math.abs(e)>=this.#y){if(!this.#a.hasMoved){this.#a.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#a.startScrollLeft-e,t.preventDefault()}};#E=t=>{if(!this.#a||t.pointerId!==this.#a.pointerId)return;let e=this.#a.hasMoved;if(e)try{this.#t.releasePointerCapture(t.pointerId)}catch{}this.#a=null,this.#t.style.scrollBehavior="",this.#t.removeAttribute("data-dragging"),e&&(this.#t.setAttribute("data-just-dragged",""),requestAnimationFrame(()=>this.#t?.removeAttribute("data-just-dragged")))};#L=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#Q=t=>{this.#a&&t.preventDefault()}};M();A("swiper-ui",rr);var or=class extends _{static labelDeprecated=!1;static requiredIcons=["upload-simple"];static properties={..._.properties,label:{type:String,default:"",reflect:!0},accept:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},compact:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;connected(){super.connected(),this.querySelector("[data-dropzone]")||(this.innerHTML=`
212
+ `,this.#l.set(i,t),i}#A(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#E(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#P(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#E(parseInt(e[r].dataset.idx))}#k(t){this.#w(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#v(){let t=this.#n.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",r=(this.#l.get(t)||this.#x(e))?.category||"";this.#w(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#$=()=>{let t=this.#s.textContent||"";this.#s.toggleAttribute("data-empty",!t),this.#b(t)};#T=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#P(1);break;case"ArrowUp":t.preventDefault(),this.#P(-1);break;case"Enter":t.preventDefault(),this.#v();break;case"Tab":t.preventDefault(),this.#v();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),this.removeEventListener("keydown",this.#T),this.#s?.removeEventListener("input",this.#$),this.#n?.removeEventListener("click",this.#d),this.#n?.removeEventListener("pointerover",this.#f),this.#s=null,this.#n=null,this.#o=null,this.#a=!1}};M();A("command-ui",jn);var Ia=.4;function Sd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function wd(s,t,e){let i=s+.3963377774*t+.2158037573*e,n=s-.1055613458*t-.0638541728*e,r=s-.0894841775*t-1.291485548*e,o=i*i*i,a=n*n*n,l=r*r*r;return[4.0767416621*o-3.3077115913*a+.2309699292*l,-1.2684380046*o+2.6097574011*a-.3413193965*l,-.0041960863*o-.7034186147*a+1.707614701*l]}function Oi(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function kd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function qb(s,t,e){let{a:i,b:n}=Sd(s,t,e),[r,o,a]=wd(s,i,n);return[Math.max(0,Math.min(1,Oi(r))),Math.max(0,Math.min(1,Oi(o))),Math.max(0,Math.min(1,Oi(a)))]}function N$(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Wn(s,t,e){let[i,n,r]=qb(s,t,e);return N$(i,n,r)}function z$(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=kd(parseInt(s.slice(0,2),16)/255),e=kd(parseInt(s.slice(2,4),16)/255),i=kd(parseInt(s.slice(4,6),16)/255),n=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),r=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*n+.793617785*r-.0040720468*o,l=1.9779984951*n-2.428592205*r+.4505937099*o,h=.0259040371*n+.7827717662*r-.808675766*o,c=Math.sqrt(l*l+h*h),u=Math.atan2(h,l)*180/Math.PI;return u<0&&(u+=360),{L:a,C:c,H:u}}function Zb(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function Da(s,t,e){let{a:i,b:n}=Sd(s,t,e),[r,o,a]=wd(s,i,n);if(Zb(Oi(r),Oi(o),Oi(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=Sd(s,u,e),[p,m,g]=wd(s,d,f);Zb(Oi(p),Oi(m),Oi(g))?l=u:h=u}return l}var Fn=class s extends _{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={..._.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#o=null;#a=!1;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=null;#g=null;#O=null;#S=null;#b=null;#x=[];#w=null;static template=()=>null;#y=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#I("input")};#A=t=>{this.disabled||(this.#o="area",this.#h.setPointerCapture(t.pointerId),this.#M(t))};#E=t=>{this.#o==="area"&&this.#M(t)};#P=()=>{this.#o==="area"&&(this.#o=null,this.#I("change"))};#k=t=>{this.disabled||(this.#o="hue",this.#d.setPointerCapture(t.pointerId),this.#Q(t))};#v=t=>{this.#o==="hue"&&this.#Q(t)};#$=()=>{this.#o==="hue"&&(this.#o=null,this.#I("change"))};#T=t=>{if(this.disabled)return;let e=t.shiftKey?.05:.01,i=t.shiftKey?.04:.004;switch(t.key){case"ArrowRight":t.preventDefault(),this.#i=Math.min(Ia,this.#i+i);break;case"ArrowLeft":t.preventDefault(),this.#i=Math.max(0,this.#i-i);break;case"ArrowUp":t.preventDefault(),this.#e=Math.min(1,this.#e+e);break;case"ArrowDown":t.preventDefault(),this.#e=Math.max(0,this.#e-e);break;default:return}this.#I("change")};#C=t=>{if(this.disabled)return;let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#s=(this.#s+e)%360;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#s=(this.#s-e+360)%360;break;default:return}this.#I("change")};connected(){if(super.connected(),this.#R(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#y),t.appendChild(c),c};this.#O=e("H","hue",0,360,1),this.#S=e("C","chroma",0,Ia,.001),this.#b=e("L","lightness",0,1,.001),this.appendChild(t),this.#d=document.createElement("div"),this.#d.setAttribute("data-hue-track",""),this.#d.setAttribute("tabindex","0"),this.#d.setAttribute("role","slider"),this.#d.setAttribute("aria-label","Hue"),this.#f=document.createElement("div"),this.#f.setAttribute("data-hue-thumb",""),this.#d.appendChild(this.#f),this.appendChild(this.#d);let i=document.createElement("div");i.setAttribute("data-output","");let n=r=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",r);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",r),l.setAttribute("aria-label",`Copy ${r}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#X(r,l);return l.addEventListener("click",h),this.#x.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#p=n("oklch"),this.#m=n("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#A),this.#h.addEventListener("pointermove",this.#E),this.#h.addEventListener("pointerup",this.#P),this.#d.addEventListener("pointerdown",this.#k),this.#d.addEventListener("pointermove",this.#v),this.#d.addEventListener("pointerup",this.#$),this.#h.addEventListener("keydown",this.#T),this.#d.addEventListener("keydown",this.#C),typeof ResizeObserver<"u"&&(this.#g=new ResizeObserver(()=>this.#N()),this.#g.observe(this.#h))}disconnected(){super.disconnected(),this.#w!=null&&(clearTimeout(this.#w),this.#w=null),this.#g&&(this.#g.disconnect(),this.#g=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#A),this.#h.removeEventListener("pointermove",this.#E),this.#h.removeEventListener("pointerup",this.#P),this.#h.removeEventListener("keydown",this.#T)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#k),this.#d.removeEventListener("pointermove",this.#v),this.#d.removeEventListener("pointerup",this.#$),this.#d.removeEventListener("keydown",this.#C)),this.#O?.removeEventListener("input",this.#y),this.#S?.removeEventListener("input",this.#y),this.#b?.removeEventListener("input",this.#y);for(let{el:t,handler:e}of this.#x)t.removeEventListener("click",e);this.#x=[],this.#r=!1}#M(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),n=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*Ia,this.#e=1-n,this.#I("input")}#Q(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#I("input")}#R(t){if(t){if(t.startsWith("#")){let e=z$(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-area-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#I(t){let e=[];if(this.#e>this.maxL&&(e.push({axis:"l",requested:this.#e,clamped:this.maxL,reason:"max-l"}),this.#e=this.maxL),this.#e<this.minL&&(e.push({axis:"l",requested:this.#e,clamped:this.minL,reason:"min-l"}),this.#e=this.minL),this.#i>this.maxChroma&&(e.push({axis:"c",requested:this.#i,clamped:this.maxChroma,reason:"max-chroma"}),this.#i=this.maxChroma),Number.isFinite(this.hueDriftMax)){let a=Number.isFinite(this.baseHue)?this.baseHue:Number.isFinite(this.#n)?this.#n:this.#s;Number.isFinite(this.#n)||(this.#n=a);let l=(this.#s-a+540)%360-180,h=this.hueDriftMax;if(l>h){let c=this.#s;this.#s=(a+h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}else if(l<-h){let c=this.#s;this.#s=(a-h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}}let i=Da(this.#e,this.#i,this.#s),n=Wn(this.#e,i,this.#s),r=this.#L();this.#a=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#L(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#X(t,e){let i=t==="oklch"?this.#L():Wn(this.#e,Da(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#w!=null&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.#w=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#N(){if(!this.#l||!this.#c||!this.#h)return;let t=Math.min(window.devicePixelRatio||1,2)*.5,e=Math.round(this.#h.clientWidth*t),i=Math.round(this.#h.clientHeight*t);if(e<=0||i<=0)return;this.#l.width=e,this.#l.height=i;let n=this.#c.createImageData(e,i),r=n.data,o=this.#s;for(let a=0;a<i;a++){let l=1-a/(i-1);for(let h=0;h<e;h++){let c=h/(e-1)*Ia,u=Da(l,c,o),[d,f,p]=qb(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#c.putImageData(n,0,0)}render(){if(this.#a?this.#a=!1:this.#R(this.value),this.#N(),this.#u){let r=this.#i/Ia*100,o=(1-this.#e)*100;this.#u.style.left=`${r}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Wn(this.#e,Da(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(Wn(.7,.15,o));this.#d.style.background=`linear-gradient(to right, ${r.join(", ")})`,this.#d.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#f&&(this.#f.style.left=`${this.#s/360*100}%`,this.#f.style.background=Wn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#L());let t=this.querySelector('slider-ui[data-channel="hue"]'),e=this.querySelector('slider-ui[data-channel="chroma"]'),i=this.querySelector('slider-ui[data-channel="lightness"]');t&&(t.value=Math.round(this.#s)),e&&(e.value=+this.#i.toFixed(3)),i&&(i.value=+this.#e.toFixed(3)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let n=Wn(this.#e,Da(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#L()),this.#m&&(this.#m.textContent=n)}onFormReset(){this.value="#3b82f6"}};M();A("color-area-ui",Fn);var Un=class extends _{static get properties(){return{..._.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#o=null;connected(){this.#a(),this.#l(),this.#d(),this.syncValue(this.value)}render(){this.#d(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#a(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-area-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-area-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#l(){if(this.#r)return;this.#r=!0,this.#i.addEventListener("change",this.#c),this.#i.addEventListener("input",this.#h);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),typeof MutationObserver<"u"&&(this.#o=new MutationObserver(t),this.#o.observe(this.#t,{attributes:!0,attributeFilter:["open"]}))}#c=t=>{this.#u(t.detail,"change")};#h=t=>{this.#u(t.detail,"input")};#u(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#d(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#d(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#n&&(this.#n.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#c),this.#i?.removeEventListener("input",this.#h),this.#o?.disconnect(),this.#o=null,this.#r=!1}};M();A("color-input-ui",Un);X();Ge();var Ad=0,Yn=class extends C{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#o=!1;#a=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++Ad}`,o={id:r,from:t,to:e,fromPort:i,toPort:n};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),r}disconnect(t){let e=this.#e.findIndex(n=>n.id===t);if(e===-1)return;let[i]=this.#e.splice(e,1);this.#h(),this.dispatchEvent(new CustomEvent("noodle-disconnect",{bubbles:!0,detail:{...i}}))}setConnections(t){this.#e=t.map(e=>({id:e.id||`noodle-${++Ad}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#f()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),typeof ResizeObserver<"u"&&(this.#s=new ResizeObserver(()=>this.#h()),this.#s.observe(this)),typeof MutationObserver<"u"&&(this.#n=new MutationObserver(()=>{this.#y(),this.#h()})),this.#u();for(let t of this.#m())this.#s?.observe(t);this.#y(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#c?.(),this.#s?.disconnect(),this.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#A(),this.#t?.remove(),this.#t=null,this.#o=!1}#h(){this.#r||typeof requestAnimationFrame=="function"&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#f()}))}#u(){this.#n?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#d(){this.#n?.disconnect()}#f(){if(!this.#t)return;this.#d();let t=this.#m();for(let r of t)this.#s?.observe(r);this.#E();let e=this.#e.map(r=>{let o=this.#p(r.from),a=this.#p(r.to);if(!o||!a)return null;let l=this.#g(o,r.fromPort),h=this.#g(a,r.toPort);return!l||!h?null:{id:r.id,d:this.#O(l,h,r.fromPort,r.toPort)}}).filter(Boolean),i=new Map;for(let r of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(r.getAttribute("data-noodle-id"),r);let n=new Set(e.map(r=>r.id));for(let[r,o]of i)n.has(r)||o.remove();for(let{id:r,d:o}of e){let a=i.get(r);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",r),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#a&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#u()}#p(t){return te(t)?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#g(t,e){let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),r=this.offsetWidth&&n.width?n.width/this.offsetWidth:1,o=(i.left-n.left)/r,a=(i.top-n.top)/r,l=i.width/r,h=i.height/r;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#O(t,e,i,n){switch(this.curve){case"step":return this.#x(t,e);case"straight":return this.#w(t,e);default:return this.#S(t,e,i,n)}}#S(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#b(t,i,l),c=this.#b(e,n,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#b(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#x(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#w(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#y(){this.#d(),this.#A();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#P(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#k(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#E(),this.#u()}#A(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#E(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#P(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#g(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#P(t,e){return t._noodleId||(t._noodleId=`_n${++Ad}`),`${t._noodleId}:${e}`}#k=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#g(e,i),o=l=>{if(!this.#a)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#O(r,{x:c,y:u},i,this.#v(r,{x:c,y:u})),this.#h(),this.#$(l.clientX,l.clientY,e),this.dispatchEvent(new CustomEvent("noodle-drag",{bubbles:!0,detail:{from:e,fromPort:i,x:c,y:u}}))},a=l=>{try{n.releasePointerCapture(l.pointerId)}catch{}if(n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#T(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#C(),this.#a=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#a=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#C(),this.#l=null,this.#c=null},this.#a={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#v(t,e){let i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"left":"right":n>0?"top":"bottom"}#$(t,e,i){this.#C();let n=this.#T(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#T(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#m().find(g=>g._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#C(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};M();A("noodles-ui",Yn);var Ui={};function de(s,t){Ui[s]=t}function Hn(s,t){let e=s.firstElementChild;(!e||e.tagName!=="SPAN")&&(s.replaceChildren(),e=s.appendChild(document.createElement("span"))),e.textContent=t,s.title=t}var $d={basic:(s,t)=>s<t?-1:s>t?1:0,alphanumeric:(s,t)=>String(s??"").localeCompare(String(t??""),void 0,{numeric:!0,sensitivity:"base"}),numeric:(s,t)=>(Number(s)||0)-(Number(t)||0),datetime:(s,t)=>new Date(s||0).getTime()-new Date(t||0).getTime()};de("text",{render(s,t,e){Hn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("number",{render(s,t,e){Hn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),de("currency",{render(s,t,e,i){Hn(e,s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:i?.currency||"USD"}).format(s):"")},format(s,t,e){return s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:e?.currency||"USD"}).format(s):""},align:"right",sortFn:"numeric"}),de("percent",{render(s,t,e){Hn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var Nb={year:"numeric",month:"short",day:"numeric"};de("date",{render(s,t,e){Hn(e,s?new Intl.DateTimeFormat("en-US",Nb).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",Nb).format(new Date(s)):""},align:"left",sortFn:"datetime"});var zb={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};de("datetime",{render(s,t,e){Hn(e,s?new Intl.DateTimeFormat("en-US",zb).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",zb).format(new Date(s)):""},align:"left",sortFn:"datetime"}),de("boolean",{render(s,t,e){let i=e.querySelector("check-ui");i||(e.textContent="",i=document.createElement("check-ui"),i.setAttribute("disabled",""),e.appendChild(i)),s?i.setAttribute("checked",""):i.removeAttribute("checked")},format(s){return s?"Yes":"No"},align:"center",sortFn:"basic"}),de("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let o=(i?.variants||{})[s];o?(n.setAttribute("variant",o),n.removeAttribute("tone")):(n.removeAttribute("variant"),n.setAttribute("tone","muted"))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("avatar",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("avatar-ui");o.setAttribute("size","sm");let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("avatar-ui"),r=i.querySelector("span");n.setAttribute("text",String(s??"")),r.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--md-sys-color-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("markdown",{render(s,t,e){let i=e.firstElementChild;(!i||i.tagName!=="SPAN")&&(e.replaceChildren(),i=e.appendChild(document.createElement("span"))),i.innerHTML=Mn(String(s??"")),e.title=i.textContent},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),de("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center"),i.style.flex="1",i.style.minWidth="0";let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");a.style.flexShrink="0",i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),de("actions",{attachesListeners:!0,render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});X();Ge();function B$(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function bi(s,t){return typeof t.accessor=="function"?t.accessor(s):B$(s,t.key)}function fh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
213
+ `)?'"'+t.replace(/"/g,'""')+'"':t}function Xa(s,t,e){s.getAttribute(t)!==e&&s.setAttribute(t,e)}function Bb(s,t){s.hasAttribute(t)&&s.removeAttribute(t)}var ph=new WeakSet;function Cd(s,t){for(;s.children.length>t.length;)s.lastChild.remove();for(let e=0;e<t.length;e++){let i=s.children[e],n=t[e];i?(ph.has(n)||!i.isEqualNode(n))&&s.replaceChild(n,i):s.appendChild(n)}}var Gn=class extends C{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},valign:{type:String,default:"center",reflect:!0},frameless:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},paginate:{type:Number,default:0,reflect:!0},noPager:{type:Boolean,default:!1,reflect:!0,attribute:"no-pager"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0},clickableRows:{type:Boolean,default:!1,reflect:!0,attribute:"clickable-rows"}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#o=0;#a=new Set;#l=new Map;#c=null;#h=!1;#u=-1;#d=null;#f=null;get#p(){return this.hasAttribute("range-total")}#m(){let t=Number(this.rangeTotal);return Number.isFinite(t)&&t>0?Math.trunc(t):0}set columns(t){this.#t=Array.isArray(t)?t:[],this.#v()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#a.clear(),this.#p||(this.#o=0),this.#v()}get data(){return this.#e}get selected(){return[...this.#a].sort((t,e)=>t-e)}set selected(t){if(this.#a.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#a.add(e);this.#v(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#a.size!==0&&(this.#a.clear(),this.#v(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#p||(this.#o=0),this.#v(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#p||(this.#o=0),this.#v(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}#g=t=>{t.target===this&&(this.search=t.detail?.value??"")};#O=t=>{if(t.target!==this)return;let{key:e,value:i,op:n}=t.detail||{};e&&this.setFilter(e,i,n)};#S=t=>{t.target===this&&this.clearFilters()};#b=t=>{if(t.target!==this)return;let e=t.detail?.columns;Array.isArray(e)&&(this.columns=e)};#x=t=>{t.target===this&&(this.paginate=Number(t.detail?.pageSize)||0)};#w=t=>{if(t.target!==this||!(this.paginate>0))return;let e=Number(t.detail?.page);if(!Number.isFinite(e))return;let i=Math.max(1,Math.min(Math.trunc(e),this.#Q));this.#o=i-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#o}}))};get filteredCount(){return this.#C().length}toggleExpand(t){!this.#y(t)&&!this.#n.has(t)||(this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#v())}get expanded(){return[...this.#n]}expandRenderer=null;rowExpandable=null;#y(t){return this.expandable?typeof this.rowExpandable=="function"?!!this.rowExpandable(this.#e[t],t):!0:!1}getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#o}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#o=t.page),this.#v()}}#A(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#E(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){if(this.#P(),this.#e.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}Xa(this,"role","grid"),Xa(this,"tabindex","0"),this.#E(),this.#h||(this.#h=!0,this.addEventListener("click",this.#D),this.addEventListener("keydown",this.#G),this.addEventListener("pointerdown",this.#F),this.addEventListener("toolbar-search",this.#g),this.addEventListener("toolbar-filter-set",this.#O),this.addEventListener("toolbar-filter-clear",this.#S),this.addEventListener("toolbar-columns-set",this.#b),this.addEventListener("toolbar-paginate",this.#x),this.addEventListener("footer-page",this.#w))}disconnected(){this.removeEventListener("click",this.#D),this.removeEventListener("keydown",this.#G),this.removeEventListener("pointerdown",this.#F),this.removeEventListener("toolbar-search",this.#g),this.removeEventListener("toolbar-filter-set",this.#O),this.removeEventListener("toolbar-filter-clear",this.#S),this.removeEventListener("toolbar-columns-set",this.#b),this.removeEventListener("toolbar-paginate",this.#x),this.removeEventListener("footer-page",this.#w),this.#h=!1,this.#et(),this.#k&&(cancelAnimationFrame(this.#k),this.#k=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#v()}#P(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null,valign:i.getAttribute("valign")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l));let h=i.getAttribute("meta");if(h)try{n.meta=JSON.parse(h)}catch{}e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#k=null;#v(){!this.isConnected||this.#k||(this.#k=requestAnimationFrame(()=>{this.#k=null,this.render(),this.#A()}))}get#$(){return this.#t.filter(t=>!t.hidden)}#T(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#$)if(this.#l.has(e.key))t.push(`${this.#l.get(e.key)}px`);else if(e.width)t.push(`${e.width}px`);else{let i=e.minWidth?`${e.minWidth}px`:"6rem",n=e.maxWidth?`${e.maxWidth}px`:`${e.flex||1}fr`;t.push(`minmax(${i}, ${n})`)}return t.join(" ")}#C(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#$.some(r=>{let o=bi(n,r);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[n,{op:r,value:o}]of this.#s){let a=this.#t.find(u=>u.key===n),l=bi(i,a||{key:n}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(r){case"contains":if(!h.includes(c))return!1;break;case"equals":if(h!==c)return!1;break;case"startsWith":if(!h.startsWith(c))return!1;break;case"gt":if(Number(l)<=Number(o))return!1;break;case"lt":if(Number(l)>=Number(o))return!1;break;case"gte":if(Number(l)<Number(o))return!1;break;case"lte":if(Number(l)>Number(o))return!1;break;case"between":{let[u,d]=String(o).split(",").map(Number),f=Number(l);if(f<u||f>d)return!1;break}case"select":{if(!c.split(",").map(d=>d.trim()).includes(h))return!1;break}default:if(!h.includes(c))return!1}}return!0})),this.#i.length&&t.sort((e,i)=>{for(let{key:n,dir:r}of this.#i){let o=this.#t.find(u=>u.key===n),a=bi(this.#e[e],o||{key:n}),l=bi(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Ui[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=$d[d]||$d.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#M(t){if(this.#p||!this.paginate||this.paginate<=0)return t;let e=this.#o*this.paginate;return t.slice(e,e+this.paginate)}get#Q(){if(!this.paginate||this.paginate<=0)return 1;if(this.#p)return Math.max(1,Math.ceil(this.#m()/this.paginate));let t=this.#C().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#$,e=this.#T();this.style.gridTemplateColumns!==e&&(this.style.gridTemplateColumns=e);let i=this.querySelector(":scope > [data-header]");i||(i=document.createElement("div"),i.setAttribute("role","row"),i.setAttribute("data-header",""),this.prepend(i)),this.#R(i,t),this.#q();let n=this.querySelector(":scope > [data-body]");n||(n=document.createElement("div"),n.setAttribute("role","rowgroup"),n.setAttribute("data-body",""),i.after(n));let r=this.#C(),o=this.#M(r),a=[];for(let u of o){let d=n.querySelector(`:scope > [role="row"][data-index="${u}"]`),f=d||this.#I(u,t);if(d&&this.#L(d,u,t),this.#y(u)&&this.#n.has(u)?Xa(f,"data-expanded",""):Bb(f,"data-expanded"),a.push(f),this.#y(u)&&this.#n.has(u)){let p=n.querySelector(`:scope > [data-detail-row][data-for="${u}"]`);if(!p&&(p=document.createElement("div"),p.setAttribute("data-detail-row",""),p.dataset.for=u,this.expandRenderer)){let m=this.expandRenderer(this.#e[u],u);Wi(m)?p.appendChild(m):p.textContent=String(m)}a.push(p)}}let l=[...n.children];for(let u of l)a.includes(u)||u.remove();for(let u=0;u<a.length;u++)n.children[u]!==a[u]&&(n.children[u]?n.insertBefore(a[u],n.children[u]):n.appendChild(a[u]));this.#X(n),this.#N(n,r,t);let h=this.paginate>0&&!this.noPager&&(this.#p?this.#m()>0:this.#e.length>0),c=this.querySelector(":scope > [data-footer]");h?(c||(c=document.createElement("div"),c.setAttribute("data-footer",""),this.appendChild(c)),this.#Z(c)):c&&c.remove()}#R(t,e){let i=this.#e.length>0&&this.#a.size===this.#e.length,n=[];if(this.expandable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-expand-col",""),r.setAttribute("aria-label","Expand"),n.push(r)}if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-column-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#B(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}Cd(t,n)}#I(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#L(i,t,e),i}#L(t,e,i){let n=this.#e[e],r=this.#a.has(e);Xa(t,"data-index",String(e)),r?Xa(t,"aria-selected","true"):Bb(t,"aria-selected");let o=[];if(this.expandable){let a=document.createElement("div");if(a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col",""),this.#y(e)){let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l)}o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=bi(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);Wi(u)?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u),ph.add(l)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Ui[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta),u.attachesListeners&&ph.add(l);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Ui[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.valign&&(l.dataset.valign=a.valign),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}Cd(t,o)}#X(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let n=this.#$,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("corner-radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#N(t,e,i){let n=i.some(a=>a.aggregate),r=this.querySelector(":scope > [data-agg-row]");if(!n||this.#e.length===0){r&&r.remove();return}r||(r=document.createElement("div"),r.setAttribute("role","row"),r.setAttribute("data-agg-row",""),t.after(r));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}for(let a of i){let l=document.createElement("div");if(l.setAttribute("role","gridcell"),a.aggregate){let h=e.map(d=>{let f=bi(this.#e[d],a);return f!=null?Number(f):NaN}).filter(d=>!isNaN(d)),c;switch(a.aggregate){case"sum":c=h.reduce((d,f)=>d+f,0);break;case"avg":c=h.length?h.reduce((d,f)=>d+f,0)/h.length:0;break;case"min":c=h.length?Math.min(...h):0;break;case"max":c=h.length?Math.max(...h):0;break;case"count":c=e.length;break;default:c=""}let u=Ui[a.type||"text"];typeof c=="number"&&u?.render?(u.render(c,{},l,a.meta),u.attachesListeners&&ph.add(l)):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}Cd(r,o)}#Z(t){let e=t.querySelector("pagination-ui");e||(t.innerHTML="",e=document.createElement("pagination-ui"),e.addEventListener("page-change",r=>{this.#o=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#o}}))}),t.appendChild(e));let i=this.#Q,n=Math.min(this.#o,i-1);e.setAttribute("page",String(n+1)),e.setAttribute("total",String(i))}#B(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let n=[...new Set(this.#e.map(o=>{let a=bi(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),r=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of n){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=r.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let n=document.createElement("input");n.type="number",n.placeholder="Filter...",n.value=i?.value??"",n.setAttribute("data-filter-input","");let r=document.createElement("select");r.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),r.appendChild(h)}let o=()=>{n.value?this.setFilter(t.key,n.value,r.value):this.setFilter(t.key,null)};n.addEventListener("input",o),r.addEventListener("change",o),e.appendChild(r),e.appendChild(n)}else{let n=document.createElement("input");n.type="text",n.placeholder=`Filter ${t.label||t.key}...`,n.value=i?.value??"",n.setAttribute("data-filter-input",""),n.addEventListener("input",()=>{n.value?this.setFilter(t.key,n.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(n)}if(i){let n=document.createElement("button");n.textContent="Clear",n.setAttribute("data-filter-clear",""),n.addEventListener("click",()=>{this.setFilter(t.key,null),this.#d=null,this.#v()}),e.appendChild(n)}return this.#f!=null&&cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{if(this.#f=null,!this.isConnected)return;let n=e.querySelector("input");n&&n.focus()}),e}#q(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:n,value:r}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=n==="select"?`${r.split(",").length} selected`:r;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#F=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-column-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#_(t,e))};#D=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#d=this.#d===c?null:c,this.#v();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#v());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-column-resize-handle]");if(r&&this.contains(r)){this.#_(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#a.add(u);else this.#a.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#u>=0){let f=Math.min(this.#u,u),p=Math.max(this.#u,u);for(let m=f;m<=p;m++)d?this.#a.add(m):this.#a.delete(m)}else d?this.#a.add(u):this.#a.delete(u);this.#u=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(g=>g.key===d),m=p?bi(f,p):void 0;this.dispatchEvent(new CustomEvent("cell-click",{bubbles:!0,detail:{key:d,row:f,value:m,dataIndex:u}})),this.dispatchEvent(new CustomEvent("row-click",{bubbles:!0,detail:{row:f,dataIndex:u}}))}}};#z=null;#_(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;e.setAttribute("data-resizing",""),this.#z={key:i,col:n,startX:a,startWidth:o,handle:e},document.addEventListener("pointermove",this.#j),document.addEventListener("pointerup",this.#U)}#j=t=>{if(!this.#z)return;let{key:e,col:i,startX:n,startWidth:r}=this.#z,o=t.clientX-n,a=r+o,l=i.minWidth||48,h=i.maxWidth||1/0;a=Math.max(l,Math.min(h,a)),this.#l.set(e,Math.round(a)),this.style.gridTemplateColumns=this.#T()};#U=t=>{if(!this.#z)return;let{key:e,handle:i}=this.#z;document.removeEventListener("pointermove",this.#j),document.removeEventListener("pointerup",this.#U),i.removeAttribute("data-resizing");let n=this.#l.get(e);this.#z=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:n}})),this.render()};#et(){document.removeEventListener("pointermove",this.#j),document.removeEventListener("pointerup",this.#U),this.#z=null}#G=t=>{let i=this.#$.length+(this.expandable?1:0)+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.children.length:0;this.#c||(this.#c={row:0,col:0});let{row:o,col:a}=this.#c,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#c={row:o,col:a},this.#Y())};#Y(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#c)return;let{row:e,col:i}=this.#c,n;e===-1?n=this.querySelector(":scope > [data-header]")?.children[i]:n=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],n&&(n.setAttribute("data-focused",""),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#$,i=this.#C(),n=e.map(c=>fh(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=bi(u,d);if(typeof d.format=="function")return fh(d.format(f,u));let p=Ui[d.type||"text"];return p?.format?fh(p.format(f,u,d.meta)):fh(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
214
+ `),a=new Blob([o],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),h=document.createElement("a");h.href=l,h.download=t,h.style.display="none",document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(l)}};M();A("table-ui",Gn);X();var V$=200,_$=896,j$=640,W$=416;function Ed(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-empty",""),t.setAttribute("color","subtle"),t.setAttribute("variant","caption"),t.textContent=s,t}function Pd(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}function Qd(s){let t=s.label;return typeof t=="string"&&t.trim()?t:s.key}var F$=50,Vb=500;function _b(s,t){if(typeof t?.accessor=="function")return t.accessor(s);let e=t?.key;if(!e||s==null)return;let i=String(e).split("."),n=s;for(let r of i){if(n==null)return;n=n[r]}return n}function U$(s){if(!s)return!1;let t=String(s);return!!(t==="id"||t==="ID"||t==="uuid"||t==="guid"||/[a-z](Id|ID)$/.test(t)||/_id$/i.test(t))}function Y$(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(U$(s?.key))return"text";let e=[],i=Math.min(t?.length??0,Vb),n=new Set;for(let r=0;r<i;r++){let o=_b(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>F$))return"text"}return e.length?"select":"text"}function H$(s,t){let e=new Set,i=Math.min(t?.length??0,Vb);for(let n=0;n<i;n++){let r=_b(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var Kn=class s extends C{static properties={for:{type:String,default:"",reflect:!0},size:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},rangeStart:{type:Number,default:0,reflect:!0,attribute:"range-start"},rangeEnd:{type:Number,default:0,reflect:!0,attribute:"range-end"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},pageSize:{type:Number,default:0,reflect:!0,attribute:"page-size"},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},chromeOnly:{type:Boolean,default:!1,reflect:!0,attribute:"chrome-only"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0},stage:{type:String,default:"",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down","dots-three-vertical"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;#o=[];#a=null;#l=null;#c=null;set pageSizeOptions(t){this.#o=Array.isArray(t)?t.map(Number).filter(e=>Number.isFinite(e)):[],this.#A()}get pageSizeOptions(){return this.#o}static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){if(this.setAttribute("role","toolbar"),this.hasAttribute("size")||this.setAttribute("size",this.size||"sm"),this.#d(),this.#o.length===0&&this.hasAttribute("page-size-options"))try{let t=JSON.parse(this.getAttribute("page-size-options"));Array.isArray(t)&&(this.pageSizeOptions=t)}catch{}this.#O(),this.#f(),this.#v(),this.#l=this.clientWidth||null,this.#u(),typeof ResizeObserver<"u"&&(this.#a=new ResizeObserver(t=>{let{inlineSize:e}=t[0].contentBoxSize[0];this.#l=e,!this.#c&&(this.#c=requestAnimationFrame(()=>{this.#c=null,this.#u()}))}),this.#a.observe(this))}updated(t){(t.has("noFilter")||t.has("noSort")||t.has("noColumns")||t.has("noSearch")||t.has("chromeOnly"))&&this.#P(),t.has("placeholder")&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#y(),t==="stage"&&this.#u()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#T(),this.#m(),this.#c!=null&&(cancelAnimationFrame(this.#c),this.#c=null),this.#a?.disconnect(),this.#a=null}#h(t){let e=getComputedStyle(this),i=(a,l)=>{let h=xd(a);return Number.isFinite(h)?h:l},n=i(e.getPropertyValue("--table-toolbar-bp-search-tight"),_$),r=i(e.getPropertyValue("--table-toolbar-bp-icon-only"),j$),o=i(e.getPropertyValue("--table-toolbar-bp-overflow"),W$);return t<=o?"overflow":t<=r?"icon-only":t<=n?"search-tight":"full"}#u(){let t=this.stage||(this.#l==null?"full":this.#h(this.#l));this.getAttribute("data-stage-resolved")!==t&&this.setAttribute("data-stage-resolved",t)}render(){this.#f(),this.#v(),this.#w(),this.#y(),this.#A()}#d(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#f(){let t=this.#p();if(t===this.#t||(this.#m(),!t))return;this.#t=t;let e=()=>this.#L(),i=()=>this.#R();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#p(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#m(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#g(){return this.size||"sm"}#O(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-scope","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="scope"&&e.appendChild(m);let i=document.createElement("div");i.setAttribute("data-title","");let n=document.createElement("span");n.setAttribute("data-heading",""),i.appendChild(n);let r=document.createElement("badge-ui");r.setAttribute("data-toolbar-count-badge",""),r.setAttribute("tone","muted"),r.hidden=!0,i.appendChild(r);let o=document.createElement("div");o.setAttribute("data-summary",""),o.hidden=!0;let a=document.createElement("span");a.setAttribute("data-summary-text",""),o.appendChild(a);let l=document.createElement("span");l.setAttribute("data-summary-compact",""),l.hidden=!0,o.appendChild(l);let h=document.createElement("div");h.setAttribute("data-summary-empty",""),h.hidden=!0;for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="empty"&&h.appendChild(m);o.appendChild(h);let c=document.createElement("div");c.setAttribute("data-controls",""),c.appendChild(this.#b("filter","Filter","funnel-simple")),c.appendChild(this.#b("sort","Sort","arrows-down-up")),c.appendChild(this.#b("columns","Columns","columns")),c.appendChild(this.#x());let u=document.createElement("search-ui");u.setAttribute("data-search",""),u.setAttribute("placeholder",this.placeholder),u.setAttribute("debounce",String(V$)),u.addEventListener("search",this.#k);let d=document.createElement("select-ui");d.setAttribute("data-page-size",""),d.setAttribute("aria-label","Rows per page"),d.hidden=!0,d.addEventListener("change",this.#E);let f=document.createElement("div");f.setAttribute("data-actions-leading","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="actions-leading"&&f.appendChild(m);let p=document.createElement("div");p.setAttribute("data-actions","");for(let m of[...this.children])m!==t&&m.getAttribute?.("slot")==="actions"&&p.appendChild(m);t.appendChild(e),t.appendChild(i),t.appendChild(o),t.appendChild(c),t.appendChild(u),t.appendChild(f),t.appendChild(d),t.appendChild(p),this.appendChild(t),this.#w(),this.#y(),this.#P(),this.#A()}#S(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size",this.#g()),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#b(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("aria-haspopup","menu"),n.setAttribute("title",e),n.addEventListener("click",r=>{r.stopPropagation(),this.#$(t,n)}),n}#x(){let t=document.createElement("menu-ui");t.setAttribute("data-toolbar-overflow","");let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("icon","dots-three-vertical"),e.setAttribute("variant","outline"),e.setAttribute("aria-label","More table actions"),e.setAttribute("aria-haspopup","menu"),t.appendChild(e);for(let[i,n,r]of[["filter","Filter","funnel-simple"],["sort","Sort","arrows-down-up"],["columns","Columns","columns"]]){let o=document.createElement("menu-item-ui");o.setAttribute("icon",r),o.setAttribute("text",n),o.setAttribute("value",i),t.appendChild(o)}return t.addEventListener("action",i=>{this.#$(i.detail.value,e)}),t}#w(){let t=this.querySelector(":scope [data-heading]");t&&(this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0);let e=this.querySelector(":scope [data-toolbar-count-badge]");if(e){let n=this.count?.toString().trim(),r=this.#t?.data?.length,o=n||(Number.isFinite(r)?String(r):"");o?(e.setAttribute("text",o),e.hidden=!1):e.hidden=!0}let i=this.querySelector(":scope > [data-toolbar] > [data-title]");i&&(i.hidden=Array.from(i.children).every(n=>n.hidden))}#y(){let t=this.querySelector(":scope > [data-toolbar] > [data-summary]");if(!t)return;let e=t.querySelector(":scope > [data-summary-text]"),i=t.querySelector(":scope > [data-summary-compact]"),n=t.querySelector(":scope > [data-summary-empty]"),r=Number(this.rangeStart)||0,o=Number(this.rangeEnd)||0,a=Number(this.rangeTotal)||0;if(r>0&&o>0&&a>0){e&&(e.textContent=`Showing ${r}\u2013${o} of ${a}`),e&&(e.hidden=!1),i&&(i.textContent=`${r}\u2013${o}/${a}`),i&&(i.hidden=!1),n&&(n.hidden=!0),t.hidden=!1;return}let l=this.hasAttribute("range-total")&&this.getAttribute("range-total")==="0",h=!!n&&n.childNodes.length>0;if(l&&h){e&&(e.hidden=!0),i&&(i.hidden=!0),n.hidden=!1,t.hidden=!1;return}e&&(e.hidden=!0),i&&(i.hidden=!0),n&&(n.hidden=!0),t.hidden=!0}#A(){let t=this.querySelector(":scope > [data-toolbar] > [data-page-size]");if(!t)return;let e=this.#o;if(!e.length){t.hidden=!0;return}t.hidden=!1;let i=e.map(o=>({value:String(o),label:`${o} / page`}));t.options=i;let n=Number(this.pageSize)||0,r=e.includes(n)?n:e[0];t.value=String(r)}#E=t=>{let e=Number(t.detail?.value??this.querySelector(":scope [data-page-size]")?.value)||0;this.pageSize=e,this.#t&&this.#t.dispatchEvent(new CustomEvent("toolbar-paginate",{bubbles:!0,detail:{pageSize:e}})),this.dispatchEvent(new CustomEvent("page-size-change",{bubbles:!0,detail:{pageSize:e}}))};#P(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=this.chromeOnly,i=(l,h)=>{let c=t.querySelector(l);c&&(c.hidden=h)},n=e||this.noFilter,r=e||this.noSort,o=e||this.noColumns;i('[data-toolbar-btn="filter"]',n),i('[data-toolbar-btn="sort"]',r),i('[data-toolbar-btn="columns"]',o),i("[data-search]",e||this.noSearch);let a=t.querySelector("[data-toolbar-overflow]");if(a){let l={filter:n,sort:r,columns:o};for(let h of a.querySelectorAll("menu-item-ui"))h.hidden=!!l[h.getAttribute("value")];a.hidden=n&&r&&o}}#k=t=>{let e=t.detail?.value??"";this.#t&&this.#t.dispatchEvent(new CustomEvent("toolbar-search",{bubbles:!0,detail:{value:e}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#v(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#w()}#$(t,e){if(this.#i?.kind===t){this.#T();return}this.#T();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#Q(i),t==="sort"&&this.#I(i),t==="columns"&&this.#X(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=mt(e,i,{placement:"bottom",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:n},this.#s||(this.#s=!0,this.#n=requestAnimationFrame(()=>{this.#n=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#C,!0),document.addEventListener("keydown",this.#M,!0))}))}#T(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#C,!0),document.removeEventListener("keydown",this.#M,!0))}}#C=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#T())};#M=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#T(),this.#i?.btn?.focus?.({preventScroll:!0}))};#Q(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ed("No filterable columns"));return}let i=e.filters||{};t.appendChild(Pd("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",Qd(o));let l=Y$(o,r),h=i[o.key];if(l==="select"){let c=document.createElement("select-ui");c.setAttribute("data-filter-input",""),c.setAttribute("multiple",""),c.setAttribute("placeholder","\u2014");let u=H$(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";e.dispatchEvent(new CustomEvent("toolbar-filter-set",{bubbles:!0,detail:{key:o.key,value:d||null,op:"select"}})),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size",this.#g()),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;e.dispatchEvent(new CustomEvent("toolbar-filter-set",{bubbles:!0,detail:{key:o.key,value:u||null,op:"contains"}})),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#S("Clear all filters",()=>{e.dispatchEvent(new CustomEvent("toolbar-filter-clear",{bubbles:!0})),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#R()});t.appendChild(o)}}#R(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#Q(t.panel))}#I(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ed("No sortable columns"));return}t.appendChild(Pd("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",Qd(o)),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#L()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#S("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#L()});t.appendChild(o)}}#L(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#I(t.panel))}#X(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Ed("No columns"));return}t.appendChild(Pd("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",Qd(n));let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.dispatchEvent(new CustomEvent("toolbar-columns-set",{bubbles:!0,detail:{columns:a}})),this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};M();A("table-toolbar-ui",Kn);X();var Jn=class extends C{static properties={for:{type:String,default:"",reflect:!0},page:{type:Number,default:1,reflect:!0},pageSize:{type:Number,default:0,reflect:!0,attribute:"page-size"},rangeTotal:{type:Number,default:0,reflect:!0,attribute:"range-total"},siblings:{type:Number,default:1,reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;#t=null;connected(){this.#e()}render(){this.#s(),this.#l()}disconnected(){this.#r()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="range-total"&&this.#l()}#e(){if(this.querySelector(":scope > [data-row]"))return;let t=document.createElement("div");t.setAttribute("data-row","");let e=document.createElement("div");e.setAttribute("data-range",""),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true");let i=document.createElement("span");i.setAttribute("data-range-text",""),e.appendChild(i);let n=document.createElement("div");n.setAttribute("data-range-empty",""),n.hidden=!0;for(let a of[...this.children])a!==t&&a.getAttribute?.("slot")==="empty"&&n.appendChild(a);e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-pager","");let o=document.createElement("pagination-ui");o.setAttribute("data-footer-pager",""),o.addEventListener("page-change",this.#i),r.appendChild(o),t.appendChild(e),t.appendChild(r),this.appendChild(t)}#i=t=>{t.stopPropagation();let e=Number(t.detail?.page);Number.isFinite(e)&&(this.hasAttribute("range-total")||(this.page=e),this.#t&&this.#t.dispatchEvent(new CustomEvent("footer-page",{bubbles:!0,composed:!0,detail:{page:e}})),this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:e}})))};#s(){let t=this.#n();t!==this.#t&&(this.#r(),t&&(this.#t=t,t.addEventListener("page",this.#o),t.addEventListener("filter-change",this.#a),t.addEventListener("sort",this.#a)))}#n(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope > table-ui")||null}#r(){this.#t&&(this.#t.removeEventListener("page",this.#o),this.#t.removeEventListener("filter-change",this.#a),this.#t.removeEventListener("sort",this.#a)),this.#t=null}#o=t=>{let e=Number(t.detail?.page);Number.isFinite(e)&&(this.page=e+1)};#a=()=>{this.#l()};#l(){let t=this.querySelector(":scope > [data-row]");if(!t)return;let e=t.querySelector(":scope > [data-range]"),i=e?.querySelector(":scope > [data-range-text]"),n=e?.querySelector(":scope > [data-range-empty]"),r=t.querySelector(":scope > [data-pager]"),o=r?.querySelector(":scope > pagination-ui"),a=this.#t,l=!!a&&a.hasAttribute("range-total"),h=!!a&&!l&&Number(a.paginate)>0,c=this.hasAttribute("range-total"),u=this.hasAttribute("page-size"),d=c||l||h,f=S=>{let v=Number(S);return Number.isFinite(v)&&v>0?Math.trunc(v):0},p=c?f(this.rangeTotal):l?f(a.rangeTotal):h&&Number(a.filteredCount)||0,m=u?Number(this.pageSize)||0:l||h?Number(a.paginate)||0:Number(this.pageSize)||0;if(!e)return;if(!d){e.hidden=!0,r&&(r.hidden=!0);return}if(e.hidden=!1,p===0){let S=!!n&&n.childNodes.length>0;i&&(i.hidden=!0),n&&(n.hidden=!S),r&&(r.hidden=!0);return}if(n&&(n.hidden=!0),m<=0){i&&(i.hidden=!1,i.textContent=`${p} items`),r&&(r.hidden=!0);return}let g=Math.max(1,Math.ceil(p/m)),O=Math.max(1,Math.min(Number(this.page)||1,g)),w=(O-1)*m+1,x=Math.min(O*m,p);i&&(i.hidden=!1,i.textContent=`Showing ${w}\u2013${x} of ${p}`),r&&(r.hidden=g<=1),o&&(o.setAttribute("page",String(O)),o.setAttribute("total",String(g)),o.setAttribute("siblings",String(Math.max(0,Number(this.siblings)||0))),o.setAttribute("size",this.size||"md"))}};M();A("table-footer-ui",Jn);X();var tr=class extends C{static properties={orientation:{type:String,default:"vertical",reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll(":scope > timeline-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last","")}},er=class extends C{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}#i(t){return t.dataset.timelineItemStamped="1",t}#s(t){return t?.dataset?.timelineItemStamped==="1"}connected(){for(let t of["label","description","time"]){if(lt(this,t).length)continue;let e=this.#i(document.createElement("span"));e.setAttribute("slot",t),this.appendChild(e)}}render(){let t=this.querySelector(':scope > [slot="label"]'),e=this.querySelector(':scope > [slot="description"]'),i=this.querySelector(':scope > [slot="time"]');this.#s(t)&&(t.textContent=this.text),this.#s(e)&&(e.textContent=this.description),this.#s(i)&&(i.textContent=this.duration||this.time);let n=this.querySelector(':scope > [slot="icon"]');if(this.icon)if(n)this.#s(n)&&n.setAttribute("name",this.icon);else{let o=this.#i(document.createElement("icon-ui"));o.setAttribute("slot","icon"),o.setAttribute("name",this.icon),this.prepend(o)}else this.#s(n)&&n.remove();let r=this.querySelector(':scope > [slot="outcomes"]');if(this.#t.length>0){r||(r=document.createElement("ul"),r.setAttribute("slot","outcomes"),this.appendChild(r)),r.innerHTML="";for(let a of this.#t){let l=document.createElement("li");l.textContent=a,r.appendChild(l)}r.hidden=!this.#e;let o=this.querySelector(":scope > [data-timeline-toggle]");o||(o=document.createElement("button-ui"),o.setAttribute("variant","ghost"),o.setAttribute("size","xs"),o.setAttribute("data-timeline-toggle",""),o.setAttribute("aria-label","Toggle details"),o.addEventListener("click",a=>{a.stopPropagation(),this.#e=!this.#e,this.render(),this.dispatchEvent(new CustomEvent("timeline-toggle",{bubbles:!0,detail:{expanded:this.#e}}))}),this.appendChild(o)),o.setAttribute("icon",this.#e?"caret-down":"caret-right")}else this.querySelector(":scope > [data-timeline-toggle]")?.remove(),r?.remove()}};M();A("timeline-ui",tr),A("timeline-item-ui",er);X();function ir(s){return s.disabled||s.hasAttribute("disabled")}var sr=class extends C{static properties={step:{type:Number,default:0,reflect:!0},orientation:{type:String,default:"horizontal",reflect:!0},interactive:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=()=>this.render();#e=null;connected(){this.addEventListener("click",this.#r),this.addEventListener("keydown",this.#o),!this.#e&&typeof MutationObserver<"u"&&(this.#e=new MutationObserver(this.#t),this.#e.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled"]}))}disconnected(){this.removeEventListener("click",this.#r),this.removeEventListener("keydown",this.#o),this.#e?.disconnect(),this.#e=null}render(){let t=[...this.querySelectorAll("stepper-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];if(e&&e.setAttribute("data-last",""),t.forEach((i,n)=>{i.setAttribute("data-index",n),n<this.step?i.setAttribute("status","completed"):n===this.step?i.setAttribute("status","active"):i.setAttribute("status","idle"),this.interactive?(i.setAttribute("role","button"),n===this.step?i.setAttribute("aria-current","step"):i.removeAttribute("aria-current")):(i.removeAttribute("role"),i.removeAttribute("tabindex"),i.removeAttribute("aria-current"),i.removeAttribute("aria-disabled"))}),this.interactive){let i=t.filter(o=>!ir(o)),n=t[this.step],r=n&&!ir(n)?n:i[0];for(let o of t)ir(o)?(o.setAttribute("aria-disabled","true"),o.removeAttribute("tabindex")):(o.removeAttribute("aria-disabled"),o.setAttribute("tabindex",o===r?"0":"-1"))}}next(){let t=this.querySelectorAll("stepper-item-ui").length;this.step<t-1&&this.step++}prev(){this.step>0&&this.step--}goTo(t){let e=this.querySelectorAll("stepper-item-ui").length-1;this.step=Math.max(0,Math.min(t,e))}get#i(){return[...this.querySelectorAll("stepper-item-ui")]}get#s(){return this.#i.filter(t=>!ir(t))}#n(t){let e=this.#i,i=e.length-1,n=Math.max(0,Math.min(t,i));if(n===this.step||e[n]&&ir(e[n]))return!1;let r=this.step;return this.dispatchEvent(new CustomEvent("step-request",{bubbles:!0,cancelable:!0,detail:{step:n,previous:r}}))?(this.step=n,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{step:this.step}})),!0):!1}#r=t=>{if(!this.interactive)return;let e=t.target.closest("stepper-item-ui");if(!e||!this.contains(e)||ir(e))return;let i=this.#i.indexOf(e);i<0||this.#n(i)};#o=t=>{if(!this.interactive)return;let e=t.target.closest("stepper-item-ui");if(!e||!this.contains(e))return;let i=this.#s,n=i.indexOf(e);if(n<0)return;let r=this.orientation==="vertical",o=r?"ArrowDown":"ArrowRight",a=r?"ArrowUp":"ArrowLeft",l;switch(t.key){case o:l=n<i.length-1?n+1:0;break;case a:l=n>0?n-1:i.length-1;break;case"Home":l=0;break;case"End":l=i.length-1;break;case"Enter":case" ":t.preventDefault(),this.#n(this.#i.indexOf(e));return;default:return}t.preventDefault();let h=i[l];this.#n(this.#i.indexOf(h))&&h.focus()}},nr=class extends C{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"idle",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t(t){return t.dataset.stepperItemStamped="1",t}#e(t){return t?.dataset?.stepperItemStamped==="1"}connected(){for(let t of["label","description"]){if(this.querySelector(`[slot="${t}"]`))continue;let e=this.#t(document.createElement("span"));e.setAttribute("slot",t),this.appendChild(e)}}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');this.#e(t)&&(t.textContent=this.text),this.#e(e)&&(e.textContent=this.description);let i=this.querySelector('[slot="icon"]');if(this.icon)if(i)this.#e(i)&&i.setAttribute("name",this.icon);else{let n=this.#t(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#e(i)&&i.remove()}};M();A("stepper-ui",sr),A("stepper-item-ui",nr);X();var rr=class extends C{static requiredIcons=["caret-left","caret-right"];static properties={autoplay:{type:Boolean,default:!1,reflect:!0},interval:{type:Number,default:5e3,reflect:!0},noPauseOnHover:{type:Boolean,default:!1,reflect:!0,attribute:"no-pause-on-hover"},loop:{type:Boolean,default:!1,reflect:!0},peek:{type:Boolean,default:!1,reflect:!0},snap:{type:String,default:"start",reflect:!0},gap:{type:String,default:"",reflect:!0},slidesPerView:{type:String,default:"",reflect:!0,attribute:"slides-per-view"},chrome:{type:String,default:"default",reflect:!0},label:{type:String,default:""},counter:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=0;#r=!1;#o=!1;#a=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#n}connected(){if(!this.#t){for(this.#t=document.createElement("div"),this.#t.setAttribute("data-swiper-track","");this.firstChild;)this.#t.appendChild(this.firstChild);this.appendChild(this.#t)}this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.getAttribute("aria-label")||this.setAttribute("aria-label","Carousel"),this.#l(),this.#c(),this.#g(),this.#r||(this.#r=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#y),this.addEventListener("pointerleave",this.#A),this.addEventListener("focusin",this.#E),this.addEventListener("focusout",this.#P)),this.addEventListener("keydown",this.#k),this.#t.addEventListener("pointerdown",this.#$),this.#t.addEventListener("pointermove",this.#T),this.#t.addEventListener("pointerup",this.#C),this.#t.addEventListener("pointercancel",this.#C),this.#t.addEventListener("click",this.#M,!0),this.#t.addEventListener("dragstart",this.#Q)),this.autoplay&&this.play()}render(){if(this.gap&&this.#t){let e=/^[0-9]+$/.test(this.gap)?`var(--a-space-${this.gap})`:this.gap;this.style.setProperty("--swiper-gap",e)}}disconnected(){this.pause(),this.#i?.disconnect(),this.#i=null,this.#t&&this.#s&&this.#t.removeEventListener("scroll",this.#s),this.#s=null,this.removeEventListener("pointerenter",this.#y),this.removeEventListener("pointerleave",this.#A),this.removeEventListener("focusin",this.#E),this.removeEventListener("focusout",this.#P),this.removeEventListener("keydown",this.#k),this.#t&&(this.#t.removeEventListener("pointerdown",this.#$),this.#t.removeEventListener("pointermove",this.#T),this.#t.removeEventListener("pointerup",this.#C),this.#t.removeEventListener("pointercancel",this.#C),this.#t.removeEventListener("click",this.#M,!0),this.#t.removeEventListener("dragstart",this.#Q)),this.#a=null,this.#t=null,this.#r=!1}next(){let t=this.#u()-1,e=this.#m(this.#n),i=Math.min(e+1,t);if(i!==e||this.loop){let n=this.loop&&i===e?0:i;this.goTo(this.#p(n))}}prev(){let t=this.#u()-1,e=this.#m(this.#n),i=Math.max(e-1,0);if(i!==e||this.loop){let n=this.loop&&i===e?t:i;this.goTo(this.#p(n))}}goTo(t){let e=this.slides[t];if(!e||!this.#t)return;let i=Math.max(0,this.#d(e));this.#t.scrollTo({left:i,behavior:"smooth"})}play(){this.pause(),!(typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: reduce)").matches)&&(this.#e=setInterval(()=>{let t=this.#u()-1,i=this.#m(this.#n)>=t;i&&this.loop?this.goTo(this.#p(0)):i?this.pause():this.next()},this.interval||5e3))}pause(){this.#e&&(clearInterval(this.#e),this.#e=null)}#l(){let t=this.slides;t.forEach((e,i)=>{e.setAttribute("role","group"),e.setAttribute("aria-roledescription","slide"),e.getAttribute("aria-label")||e.setAttribute("aria-label",`${i+1} of ${t.length}`)})}#c(){this.#s=()=>{let t=this.#f();t!==this.#n&&(this.#n=t,this.#w(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{index:t,slide:this.slides[t]}})))},this.#t.addEventListener("scroll",this.#s,{passive:!0}),this.#n=this.#f()}#h(){if(!this.#t)return 1;let e=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").trim(),i=parseInt(e,10);return Number.isFinite(i)&&i>0?i:1}#u(){let t=this.slides.length;return t===0?0:this.snap==="center"?t:Math.max(1,t-this.#h()+1)}#d(t){let e=this.#t.clientWidth,i=t.offsetLeft-this.#t.offsetLeft,n=t.offsetWidth;return this.snap==="center"?i+n/2-e/2:this.snap==="end"?i+n-e:i}#f(){if(!this.#t)return 0;let t=this.slides;if(t.length===0)return 0;let e=this.#t.scrollLeft,i=Math.max(0,this.#t.scrollWidth-this.#t.clientWidth),n=0,r=1/0;for(let o=0;o<t.length;o++){let a=Math.max(0,Math.min(i,this.#d(t[o]))),l=Math.abs(e-a);l<r&&(r=l,n=o)}return n}#p(t){if(this.snap!=="end")return t;let e=this.#h();return Math.min(this.slides.length-1,t+e-1)}#m(t){if(this.snap!=="end")return t;let e=this.#h();return Math.max(0,t-e+1)}#g(){this.#o||(this.#o=!0,this.chrome==="toolbar"?this.#S():this.#O(),this.#x(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#x()),this.#i.observe(this)))}#O(){let t=document.createElement("button-ui");t.setAttribute("data-swiper-btn",""),t.setAttribute("data-swiper-prev",""),t.setAttribute("icon","caret-left"),t.setAttribute("variant","ghost"),t.setAttribute("aria-label","Previous slide"),t.addEventListener("press",()=>this.prev());let e=document.createElement("button-ui");e.setAttribute("data-swiper-btn",""),e.setAttribute("data-swiper-next",""),e.setAttribute("icon","caret-right"),e.setAttribute("variant","ghost"),e.setAttribute("aria-label","Next slide"),e.addEventListener("press",()=>this.next()),this.appendChild(t),this.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-dots",""),i.setAttribute("role","tablist"),i.setAttribute("aria-label","Slide indicators"),this.appendChild(i)}#S(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let n=document.createElement("button-ui");n.setAttribute("icon","caret-left"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Previous slide"),n.addEventListener("press",()=>this.prev());let r=document.createElement("button-ui");r.setAttribute("icon","caret-right"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Next slide"),r.addEventListener("press",()=>this.next()),i.appendChild(n),i.appendChild(r),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#b()}#b(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#m(this.#n)+1,i=this.#u();t.textContent=`${e} / ${i}`}#x(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#u();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let n=document.createElement("button-ui");n.setAttribute("variant","ghost"),n.setAttribute("role","tab"),n.setAttribute("aria-label",`Page ${i+1}`),n.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(n)}}this.#w()}#w(){if(!this.#o)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#u()-1,i=Math.min(Math.max(this.#m(this.#n),0),e);[...t.children].forEach((n,r)=>{n.setAttribute("aria-current",r===i?"true":"false")})}this.#b()}#y=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#A=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#E=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#P=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#k=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#v=5;#$=t=>{t.pointerType!=="touch"&&t.button===0&&(t.target.closest("button, button-ui, a, input, select, textarea")||(this.#a={pointerId:t.pointerId,startX:t.clientX,startScrollLeft:this.#t.scrollLeft,hasMoved:!1},this.#t.style.scrollBehavior="auto",this.#t.setAttribute("data-dragging","")))};#T=t=>{if(!this.#a||t.pointerId!==this.#a.pointerId)return;let e=t.clientX-this.#a.startX;if(Math.abs(e)>=this.#v){if(!this.#a.hasMoved){this.#a.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#a.startScrollLeft-e,t.preventDefault()}};#C=t=>{if(!this.#a||t.pointerId!==this.#a.pointerId)return;let e=this.#a.hasMoved;if(e)try{this.#t.releasePointerCapture(t.pointerId)}catch{}this.#a=null,this.#t.style.scrollBehavior="",this.#t.removeAttribute("data-dragging"),e&&(this.#t.setAttribute("data-just-dragged",""),requestAnimationFrame(()=>this.#t?.removeAttribute("data-just-dragged")))};#M=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#Q=t=>{this.#a&&t.preventDefault()}};M();A("swiper-ui",rr);var or=class extends _{static labelDeprecated=!1;static requiredIcons=["upload-simple"];static properties={..._.properties,label:{type:String,default:"",reflect:!0},accept:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},compact:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;connected(){super.connected(),this.querySelector("[data-dropzone]")||(this.innerHTML=`
215
215
  <div data-dropzone tabindex="0" role="button"><icon-ui data-upload-icon name="upload-simple"></icon-ui><span data-upload-text>Drop files here or click to browse</span></div>
216
216
  <span hint="${this.hint||""}"></span>
217
217
  <div data-filelist></div>
@@ -231,9 +231,9 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
231
231
  <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>
232
232
  <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>
233
233
  </svg>
234
- `;connected(){this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Adia")}};M();A("adia-wordmark-ui",dr);X();var fr=class extends C{static properties={value:{type:Number,default:null,reflect:!0},label:{type:String,default:"",reflect:!0},meta:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=void 0;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.#i=this.querySelector(':scope > [slot="label"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","label"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="meta"]'),this.#s||(this.#s=document.createElement("span"),this.#s.setAttribute("slot","meta"),this.appendChild(this.#s)),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}%`),this.#i&&(this.#i.textContent=this.label,this.#i.hidden=!this.label),this.#s&&(this.label?this.meta?(this.#s.textContent=this.meta,this.#s.hidden=!1):this.#s.hidden=!this.#s.hasChildNodes():this.#s.hidden=!0);let i=this.label?this.meta?`${this.label}, ${this.meta}`:this.label:"";this.#n=Zt(this,this.#n,i)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};M();A("progress-ui",fr);X();var pr=class extends C{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"),!lt(this,"caption").length&&!lt(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=lt(this,"caption")[0],this.#e=lt(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 n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};M();A("step-progress-ui",pr);X();var mr=class extends C{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},cornerRadius:{type:String,default:"sm",reflect:!0,attribute:"corner-radius"},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}};M();A("skeleton-ui",mr);X();var gr=class extends C{static properties={size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"arc",reflect:!0},tone:{type:String,default:"current",reflect:!0},paused:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"Loading",reflect:!1}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-busy")||this.setAttribute("aria-busy","true"),this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}render(){this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}#t(){let t=this.variant==="dots",e=this.querySelectorAll(":scope > [data-spinner-dot]");if(t){if(e.length===3)return;e.forEach(n=>n.remove());let i=document.createDocumentFragment();for(let n=1;n<=3;n++){let r=document.createElement("span");r.setAttribute("data-spinner-dot",String(n)),r.setAttribute("aria-hidden","true"),i.appendChild(r)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};M();A("spinner-ui",gr);X();var Or=class extends C{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let n=!!t.get.call(this);e.call(this,i),!!i!==n&&this.#s(!!i)},configurable:!0})}}connected(){this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.setAttribute("aria-label",this.label||"Loading"),this.#t=this.parentElement,this.active&&this.#s(!0)}disconnected(){this.#o(),this.#i&&this.#r(),this.#t=null}render(){let t=this.label||"Loading";this.setAttribute("aria-label",t);let e=this.querySelector(":scope > spinner-ui[data-loading-overlay-auto]");e&&e.getAttribute("label")!==t&&e.setAttribute("label",t),this.children.length===0&&this.#a()}#s(t){if(this.#o(),t){let e=Math.max(0,Number(this.delay)||0);e===0?this.#n():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#n()},e)}else this.#i&&this.#r()}#n(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#r(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#o(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#a(){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)}};M();A("loading-overlay-ui",Or);X();var jb=new Set;function Wb(s,t){jb.has(s)||(jb.add(s),console.warn(`[alert-ui] ${t}`))}var br=class s extends C{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"&&(Wb("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")&&(Wb("alias-closeable","attribute [closeable] is a misspelled alias of canonical [closable]. Mapping. Fix the source to use [closable] or [dismissible]."),this.setAttribute("closable",""),this.removeAttribute("closeable")),this.hasAttribute("dismissible")&&!this.hasAttribute("closable")&&this.setAttribute("closable","")}#i=t=>{if(t.target.closest('[slot="close"]')){this.#h();return}if(this.pattern==="dunning"){let e=t.target.closest("[data-dunning-action]");if(e&&this.contains(e)){let i=e.getAttribute("data-dunning-action")||"";this.dispatchEvent(new CustomEvent("dunning-action",{bubbles:!0,composed:!0,detail:{action:i,amount:this.amount,currency:this.currency,dueAt:this.dueAt}}))}}};connected(){this.#e(),this.#c(),(this.icon||this.pattern==="dunning"&&this.reason)&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#i)}disconnected(){this.removeEventListener("press",this.#i)}render(){if(this.pattern==="dunning"){this.#s(),this.#c();return}if(this.icon){let e=this.ensure("leading");e&&e.setAttribute("name",this.icon)}else this.drop("leading");let t=this.ensure("content");if(t){let e=t.hasAttribute("data-alert-auto"),i=t.childNodes.length>0;if(!e&&i){if(this.title||this.description){let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#c()}#s(){let t=this.icon||s.#t[this.reason]||"x-circle",e=this.ensure("leading");e&&e.setAttribute("name",t);let i=this.ensure("content");if(!i)return;i.setAttribute("data-alert-auto","dunning"),i.replaceChildren();let n=this.title||this.#n();if(n){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=n,i.appendChild(l)}let r=this.#r(),o=this.#a();if(r||o){if(i.appendChild(document.createTextNode(" ")),r){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=r,i.appendChild(l)}if(r&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[n,r,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#n(){switch(this.reason){case"expired":return"Card expired";case"insufficient":return"Insufficient funds";case"network":return"Network error";case"declined":return"Payment failed";default:return this.variant==="warning"?"Payment due soon":"Payment failed"}}#r(){if(!this.amount&&this.amount!==0||this.amount===0)return"";try{let t=this.getAttribute("lang")||this.lang||void 0;return new Intl.NumberFormat(t,{style:"currency",currency:this.currency||"USD"}).format(this.amount)}catch{return`${this.currency||""} ${this.amount}`.trim()}}#o(){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()}}#a(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#o();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#c(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#h(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};M();A("alert-ui",br);X();var G$={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},yr=class extends C{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||G$[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()}};M();A("inline-message-ui",yr);X();var vr=class extends C{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};M();A("kbd-ui",vr);X();var xr=class extends C{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=void 0;#e(){this.#t=Zt(this,this.#t,this.text||"")}#i=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#s=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.#i),this.addEventListener("keydown",this.#s)}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}render(){if(this.#e(),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")}};M();A("tag-ui",xr);X();var K$=new Set(["block","dot","square","line","dashed"]),J$=new Set(["sm","md","lg"]),tC=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),eC={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},iC={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function sC(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&tC.has(t)):[]}var vs=null;function nC(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!vs){let u=document.createElement("canvas");u.width=1,u.height=1,vs=u.getContext("2d")}vs.fillStyle="#000",vs.clearRect(0,0,1,1),vs.fillStyle=s,vs.fillRect(0,0,1,1);let[t,e,i]=vs.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let n=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},r=n(t),o=n(e),a=n(i),l=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var Sr=class extends C{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;#n=null;#r=!1;#o=null;#a=null;#l=null;#c=null;#h=null;#u=null;connected(){this.#d(),this.#x(),typeof MutationObserver<"u"&&(this.#u=new MutationObserver(t=>{let e=!1;for(let i of t){for(let n of i.addedNodes)if(n.nodeType===1){if(n.getAttribute?.("slot")==="chrome"){e=!0;break}if(n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#u.takeRecords())}),this.#u.observe(this,{childList:!0}))}render(){this.#d(),this.#p(),this.#m(),this.#g(),this.#S(),this.#v(),this.#O()}#d(){if(this.#r)return;let t=Array.from(this.children).filter(r=>r.getAttribute&&r.getAttribute("slot")==="chrome");for(let r of t)r.remove();let e=Array.from(this.children).filter(r=>r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]'));for(let r of e)r.remove();let i=[];for(let r of Array.from(this.childNodes))(r.nodeType===3&&!r.data||r.nodeType===8)&&i.push(r);for(let r of i)r.remove();let n=Array.from(this.childNodes).filter(r=>!(r.nodeType===1&&r.dataset&&(r.dataset.tile!==void 0||r.dataset.label!==void 0||r.dataset.detail!==void 0||r.dataset.badge!==void 0||r.dataset.copy!==void 0))&&!(r.nodeType===3&&!r.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let r of t)this.appendChild(r);for(let r of e)this.appendChild(r);for(let r of i)this.appendChild(r);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),n.length)for(let r of n)this.#e.appendChild(r);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#n=document.createElement("button-ui"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("variant","ghost"),this.#n.setAttribute("size","xs"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.setAttribute("text","\u29C9"),this.appendChild(this.#n),this.#r=!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.#n&&e.getAttribute?.("slot")==="chrome"&&this.insertBefore(e,this.#s);for(let e of Array.from(this.children))e===this.#t||e===this.#s||e===this.#e||e===this.#i||e===this.#n||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#p(){if(!this.#t||!this.#e)return;this.#f();let t=K$.has(this.shape)?this.shape:"square",e=J$.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=sC(this.badge);if(t.length===0){this.#s.setAttribute("hidden",""),this.#s.replaceChildren();return}this.#s.removeAttribute("hidden");let e=Array.from(this.#s.children).map(r=>r.dataset.badgeVariant);if(e.length===t.length&&e.every((r,o)=>r===t[o]))return;let n=document.createDocumentFragment();for(let r of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",r),o.setAttribute("role","img"),o.setAttribute("aria-label",iC[r]),o.textContent=eC[r],n.appendChild(o)}this.#s.replaceChildren(n)}#O(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#o=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#o)return;this.#o=t;let e=nC(t);if(e==null){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark");return}let i=e<.62;this.#e.toggleAttribute("data-on-dark",i),this.#e.toggleAttribute("data-on-light",!i)}#g(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#S(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#b();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#v(){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"))}#x(){this.#a=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#w()},this.#l=t=>{!this.selectable||t.key!=="Enter"&&t.key!==" "||(t.composedPath?t.composedPath():[t.target]).includes(this.#n)||(t.preventDefault(),this.#w())},this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#b();e&&this.#$(e)},this.#n.addEventListener("click",this.#c)}#w(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#b(){return this.copyValue?this.copyValue:this.color?this.color:""}async#$(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#C(e)}#C(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.setAttribute("text",t?"\u2713":"\u26A0"),this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.setAttribute("text","\u29C9"),this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#u&&(this.#u.disconnect(),this.#u=null),this.#a&&this.removeEventListener("click",this.#a),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#c&&this.#n.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};M();A("swatch-ui",Sr);mi();var Fb={xs:0,sm:480,md:768,lg:1024,xl:1280},xs=Object.keys(Fb),Td=Object.values(Fb);function Ub(){let s=typeof window<"u"?window.innerWidth:void 0;if(typeof s!="number")return"lg";for(let t=xs.length-1;t>=0;t--)if(s>=Td[t])return xs[t];return"xs"}var Te=ji(Ub());if(typeof window<"u"&&typeof window.matchMedia=="function")for(let s=1;s<Td.length;s++)window.matchMedia(`(min-width: ${Td[s]}px)`).addEventListener("change",()=>{Te.value=Ub()});function Bt(s,t=Te.value){if(!s)return null;if(!s.includes("@"))return s;let e=null,i=new Map;for(let a of s.trim().split(/\s+/)){let l=a.lastIndexOf("@");l===-1?e=a:i.set(a.slice(l+1),a.slice(0,l))}let n=xs.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=xs.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}X();var wr=class extends C{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"stretch",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;render(){let t=this.gap,e=this.align,i=this.justify,r=t?.includes("@")||e?.includes("@")||i?.includes("@")?Te.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",aC(Bt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Bt(e,r);this.style.setProperty("--col-align",lC(o)),this.style.textAlign=hC(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",cC(Bt(i,r))):this.style.removeProperty("--col-justify")}},rC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},oC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function aC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function lC(s){return rC[s]??s}function hC(s){return{start:"start",center:"center",end:"end"}[s]??""}function cC(s){return oC[s]??s}M();A("col-ui",wr);X();var kr=class s extends C{static properties={label:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},align:{type:String,default:"start",reflect:!0}};get error(){return this.#O()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=t=>{let e=this.#O();if(!e)return;let i=this.#S(e);i&&(t.preventDefault(),i.focus())};connected(){this.#u(),this.#d(),this.#f(),this.#p(),this.#c(),this.#t?.addEventListener("click",this.#r),typeof MutationObserver<"u"&&(this.#n=new MutationObserver(()=>{this.#p(),this.#c(),this.#m(),this.#o()}),this.#n.observe(this,{childList:!0})),this.#o()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#o(),this.#m()}#o(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#a=()=>{this.#o(),this.#m()};#l=null;#c(){let t=this.#O();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#a,!0),t.addEventListener("change",this.#a),t.addEventListener("input",this.#a)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#a,!0),t.removeEventListener("change",this.#a),t.removeEventListener("input",this.#a),this.#l=null)}#u(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#b("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.#b("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#p(){if(!this.#t)return;let t=this.#O();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#x()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#O();if(!t)return;let e=new Set;this.#i&&!this.#i.hidden&&e.add(this.#i.id),this.#s&&!this.#s.hidden&&e.add(this.#s.id);let n=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(r=>r&&!r.startsWith("field-hint-")&&!r.startsWith("field-err-")),...e].join(" ").trim();n?t.setAttribute("aria-describedby",n):t.removeAttribute("aria-describedby")}#O(){let t=null,e=null;for(let i of this.children)if(!i.hasAttribute("slot")){if(t===null&&(t=i),s.#g.has(i.localName))return i;e===null&&this.#S(i)&&(e=i)}return e??t}static#g=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","date-range-picker-ui","calendar-picker-ui","color-area-ui","upload-ui","rating-ui","segmented-ui","input","textarea","select"]);#S(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#v=0;static#x(){return`field-ctl-${++s.#v}`}static#w=0;static#b(t){return`field-${t}-${++s.#w}`}};M();A("field-ui",kr);X();var Ar=class extends C{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}};M();A("fields-ui",Ar);X();M();var Yb=0,qa=class extends C{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-${++Yb}`),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-${++Yb}`,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}};A("display-field-ui",qa);X();var $r=class extends C{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(ar),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(ar),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,n=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!n?Te.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",fC(Bt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",pC(Bt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",mC(Bt(i,o))):this.style.removeProperty("--row-justify"),n){let a=xs.indexOf(o),l=xs.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},uC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},dC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function fC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function pC(s){return uC[s]??s}function mC(s){return dC[s]??s}M();A("row-ui",$r);X();var Cr=class extends C{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=Te.value,e=this.columns;if(e?.includes("@")){let n=Bt(e,t);this.style.gridTemplateColumns=this.#t(n),this.style.gridAutoFlow=n?"row":"",this.style.gridAutoColumns=n?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";this.minColumnWidth?this.style.setProperty("--grid-min-col",this.minColumnWidth):this.style.removeProperty("--grid-min-col");let i=this.gap;if(i?.includes("@")){let n=Bt(i,t),r=this.#e(n);this.style.columnGap=r,this.style.rowGap=r}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(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})`}};M();A("grid-ui",Cr);X();var Er=class extends C{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};M();A("stack-ui",Er);X();var Pr=class extends C{static properties={};static template=()=>null};M();A("frame-ui",Pr);X();function Yi(s,t,e=5){let n=(t-s||1)/e,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*r,h=Math.floor(s/l)*l,c=Math.ceil(t/l)*l,u=[];for(let d=h;d<=c+l*.5;d+=l)u.push(+d.toFixed(10));return u}function Hb(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 ct(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function je(s,t){let e=String(s);return e.length>t?e.slice(0,Math.max(1,t-1))+"\u2026":e}function at({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${ct(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${ct(String(i))}"`),n}function Vt(s,t,e){return s+t*Math.cos(e)}function _t(s,t,e){return s+t*Math.sin(e)}function gC(s,t,e,i,n){let r=Vt(s,e,i),o=_t(t,e,i),a=Vt(s,e,n),l=_t(t,e,n),h=n-i>Math.PI?1:0;return`M ${s} ${t} L ${r} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function Ld(s,t,e,i,n,r,o=0){let a=(e-i)/2,l=r-n,h=Math.max(0,Math.min(o,a)),c=()=>{let G=Vt(s,e,n),K=_t(t,e,n),ot=Vt(s,e,r),pt=_t(t,e,r),St=Vt(s,i,r),Lt=_t(t,i,r),ce=Vt(s,i,n),ue=_t(t,i,n),Be=l>Math.PI?1:0;return`M ${G} ${K} A ${e} ${e} 0 ${Be} 1 ${ot} ${pt} L ${St} ${Lt} A ${i} ${i} 0 ${Be} 0 ${ce} ${ue} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,g=r-d,O=p-f>Math.PI?1:0,w=Vt(s,e,f),x=_t(t,e,f),S=Vt(s,e,p),v=_t(t,e,p),k=Vt(s,i,g),b=_t(t,i,g),E=Vt(s,i,m),$=_t(t,i,m),Q=Vt(s,e-h,n),T=_t(t,e-h,n),P=Vt(s,i+h,n),L=_t(t,i+h,n),I=Vt(s,e-h,r),D=_t(t,e-h,r),V=Vt(s,i+h,r),H=_t(t,i+h,r);return`M ${w} ${x} A ${e} ${e} 0 ${O} 1 ${S} ${v} A ${h} ${h} 0 0 1 ${I} ${D} L ${V} ${H} A ${h} ${h} 0 0 1 ${k} ${b} A ${i} ${i} 0 ${O} 0 ${E} ${$} A ${h} ${h} 0 0 1 ${P} ${L} L ${Q} ${T} A ${h} ${h} 0 0 1 ${w} ${x} Z`}function Ss(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(n=>`${n.x},${n.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let n=0;n<e-1;n++){let r=s[Math.max(n-1,0)],o=s[n],a=s[n+1],l=s[Math.min(n+2,e-1)],h=o.x+(a.x-r.x)*t/3,c=o.y+(a.y-r.y)*t/3,u=a.x-(l.x-o.x)*t/3,d=a.y-(l.y-o.y)*t/3;i+=` C${h},${c} ${u},${d} ${a.x},${a.y}`}return i}function Md(s,t,e=.4){let i=Ss(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function mh(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}function Rd(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,i/2,e));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i-r} Q${s+e},${t+i} ${s+e-r},${t+i} H${s} Z`}function Gb(s,t,e,i){if(t.length<=e)return{labels:s,vals:t};let n=Math.max(1,e-1),r=t.map((c,u)=>u),o=i?r.slice().sort((c,u)=>t[u]-t[c]).slice(0,n).sort((c,u)=>c-u):r.slice(0,n),a=new Set(o),l=r.filter(c=>!a.has(c)),h=l.reduce((c,u)=>c+t[u],0);return{labels:o.map(c=>s[c]).concat([`+${l.length} more`]),vals:o.map(c=>t[c]).concat([h])}}var Kb=6,Jb=5,OC={std:{ratio:4/3}},bC={"3:2":3/2,"1:1":1,"2:3":2/3},ty={wide:5/4,tall:4/5},Qr=class extends C{static properties={type:{type:String,default:"bar",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},noAverage:{type:Boolean,default:!1,reflect:!0,attribute:"no-average"},color:{type:String,default:"",reflect:!0},noGrid:{type:Boolean,default:!1,reflect:!0,attribute:"no-grid"},noValues:{type:Boolean,default:!1,reflect:!0,attribute:"no-values"},cornerRadius:{type:Number,default:null,reflect:!0,attribute:"corner-radius"},smooth:{type:Number,default:.4,reflect:!0},size:{type:String,default:"",reflect:!0},ratio:{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"},yMin:{type:Number,default:null,reflect:!0,attribute:"y-min"},yMax:{type:Number,default:null,reflect:!0,attribute:"y-max"},labels:{type:String,default:"",reflect:!0},today:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#o=new Set;#a=null;#l(){if(this.cornerRadius!=null)return this.cornerRadius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}#c(t){let e=this.yMin!=null&&Number.isFinite(this.yMin)?this.yMin:0,i=this.yMax!=null&&Number.isFinite(this.yMax)?this.yMax:Math.max(...t);return[e,i]}#h(t,e){return Math.min(Math.max(t,0),e)}#u(t,e,i){return Math.min(Math.max(t,e),i)}#d(t,e){let i=getComputedStyle(this).getPropertyValue(t).trim();if(!i)return e;if(/^-?\d*\.?\d+(px)?$/.test(i)){let o=parseFloat(i);return Number.isFinite(o)?o:e}let n=document.createElement("span");n.style.cssText="position:absolute; visibility:hidden; pointer-events:none; height:0; width:"+i,this.appendChild(n);let r=parseFloat(getComputedStyle(n).width);return n.remove(),Number.isFinite(r)?r:e}#f(){return this.labels==="chip"?"chip":"outside"}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.
234
+ `;connected(){this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Adia")}};M();A("adia-wordmark-ui",dr);X();var fr=class extends C{static properties={value:{type:Number,default:null,reflect:!0},label:{type:String,default:"",reflect:!0},meta:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=void 0;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.#i=this.querySelector(':scope > [slot="label"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","label"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="meta"]'),this.#s||(this.#s=document.createElement("span"),this.#s.setAttribute("slot","meta"),this.appendChild(this.#s)),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}%`),this.#i&&(this.#i.textContent=this.label,this.#i.hidden=!this.label),this.#s&&(this.label?this.meta?(this.#s.textContent=this.meta,this.#s.hidden=!1):this.#s.hidden=!this.#s.hasChildNodes():this.#s.hidden=!0);let i=this.label?this.meta?`${this.label}, ${this.meta}`:this.label:"";this.#n=Zt(this,this.#n,i)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};M();A("progress-ui",fr);X();var pr=class extends C{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"),!lt(this,"caption").length&&!lt(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=lt(this,"caption")[0],this.#e=lt(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 n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};M();A("step-progress-ui",pr);X();var mr=class extends C{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},cornerRadius:{type:String,default:"sm",reflect:!0,attribute:"corner-radius"},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}};M();A("skeleton-ui",mr);X();var gr=class extends C{static properties={size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"arc",reflect:!0},tone:{type:String,default:"current",reflect:!0},paused:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"Loading",reflect:!1}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-busy")||this.setAttribute("aria-busy","true"),this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}render(){this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}#t(){let t=this.variant==="dots",e=this.querySelectorAll(":scope > [data-spinner-dot]");if(t){if(e.length===3)return;e.forEach(n=>n.remove());let i=document.createDocumentFragment();for(let n=1;n<=3;n++){let r=document.createElement("span");r.setAttribute("data-spinner-dot",String(n)),r.setAttribute("aria-hidden","true"),i.appendChild(r)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};M();A("spinner-ui",gr);X();var Or=class extends C{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let n=!!t.get.call(this);e.call(this,i),!!i!==n&&this.#s(!!i)},configurable:!0})}}connected(){this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.setAttribute("aria-label",this.label||"Loading"),this.#t=this.parentElement,this.active&&this.#s(!0)}disconnected(){this.#o(),this.#i&&this.#r(),this.#t=null}render(){let t=this.label||"Loading";this.setAttribute("aria-label",t);let e=this.querySelector(":scope > spinner-ui[data-loading-overlay-auto]");e&&e.getAttribute("label")!==t&&e.setAttribute("label",t),this.children.length===0&&this.#a()}#s(t){if(this.#o(),t){let e=Math.max(0,Number(this.delay)||0);e===0?this.#n():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#n()},e)}else this.#i&&this.#r()}#n(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#r(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#o(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#a(){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)}};M();A("loading-overlay-ui",Or);X();var jb=new Set;function Wb(s,t){jb.has(s)||(jb.add(s),console.warn(`[alert-ui] ${t}`))}var br=class s extends C{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"&&(Wb("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")&&(Wb("alias-closeable","attribute [closeable] is a misspelled alias of canonical [closable]. Mapping. Fix the source to use [closable] or [dismissible]."),this.setAttribute("closable",""),this.removeAttribute("closeable")),this.hasAttribute("dismissible")&&!this.hasAttribute("closable")&&this.setAttribute("closable","")}#i=t=>{if(t.target.closest('[slot="close"]')){this.#h();return}if(this.pattern==="dunning"){let e=t.target.closest("[data-dunning-action]");if(e&&this.contains(e)){let i=e.getAttribute("data-dunning-action")||"";this.dispatchEvent(new CustomEvent("dunning-action",{bubbles:!0,composed:!0,detail:{action:i,amount:this.amount,currency:this.currency,dueAt:this.dueAt}}))}}};connected(){this.#e(),this.#c(),(this.icon||this.pattern==="dunning"&&this.reason)&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#i)}disconnected(){this.removeEventListener("press",this.#i)}render(){if(this.pattern==="dunning"){this.#s(),this.#c();return}if(this.icon){let e=this.ensure("leading");e&&e.setAttribute("name",this.icon)}else this.drop("leading");let t=this.ensure("content");if(t){let e=t.hasAttribute("data-alert-auto"),i=t.childNodes.length>0;if(!e&&i){if(this.title||this.description){let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#c()}#s(){let t=this.icon||s.#t[this.reason]||"x-circle",e=this.ensure("leading");e&&e.setAttribute("name",t);let i=this.ensure("content");if(!i)return;i.setAttribute("data-alert-auto","dunning"),i.replaceChildren();let n=this.title||this.#n();if(n){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=n,i.appendChild(l)}let r=this.#r(),o=this.#a();if(r||o){if(i.appendChild(document.createTextNode(" ")),r){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=r,i.appendChild(l)}if(r&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[n,r,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#n(){switch(this.reason){case"expired":return"Card expired";case"insufficient":return"Insufficient funds";case"network":return"Network error";case"declined":return"Payment failed";default:return this.variant==="warning"?"Payment due soon":"Payment failed"}}#r(){if(!this.amount&&this.amount!==0||this.amount===0)return"";try{let t=this.getAttribute("lang")||this.lang||void 0;return new Intl.NumberFormat(t,{style:"currency",currency:this.currency||"USD"}).format(this.amount)}catch{return`${this.currency||""} ${this.amount}`.trim()}}#o(){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()}}#a(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#o();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#c(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#h(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};M();A("alert-ui",br);X();var G$={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},yr=class extends C{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||G$[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()}};M();A("inline-message-ui",yr);X();var vr=class extends C{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};M();A("kbd-ui",vr);X();var xr=class extends C{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=void 0;#e(){this.#t=Zt(this,this.#t,this.text||"")}#i=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#s=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.#i),this.addEventListener("keydown",this.#s)}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}render(){if(this.#e(),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")}};M();A("tag-ui",xr);X();var K$=new Set(["block","dot","square","line","dashed"]),J$=new Set(["sm","md","lg"]),tC=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),eC={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},iC={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function sC(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&tC.has(t)):[]}var vs=null;function nC(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!vs){let u=document.createElement("canvas");u.width=1,u.height=1,vs=u.getContext("2d")}vs.fillStyle="#000",vs.clearRect(0,0,1,1),vs.fillStyle=s,vs.fillRect(0,0,1,1);let[t,e,i]=vs.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let n=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},r=n(t),o=n(e),a=n(i),l=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var Sr=class extends C{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;#n=null;#r=!1;#o=null;#a=null;#l=null;#c=null;#h=null;#u=null;connected(){this.#d(),this.#x(),typeof MutationObserver<"u"&&(this.#u=new MutationObserver(t=>{let e=!1;for(let i of t){for(let n of i.addedNodes)if(n.nodeType===1){if(n.getAttribute?.("slot")==="chrome"){e=!0;break}if(n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#u.takeRecords())}),this.#u.observe(this,{childList:!0}))}render(){this.#d(),this.#p(),this.#m(),this.#O(),this.#S(),this.#b(),this.#g()}#d(){if(this.#r)return;let t=Array.from(this.children).filter(r=>r.getAttribute&&r.getAttribute("slot")==="chrome");for(let r of t)r.remove();let e=Array.from(this.children).filter(r=>r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]'));for(let r of e)r.remove();let i=[];for(let r of Array.from(this.childNodes))(r.nodeType===3&&!r.data||r.nodeType===8)&&i.push(r);for(let r of i)r.remove();let n=Array.from(this.childNodes).filter(r=>!(r.nodeType===1&&r.dataset&&(r.dataset.tile!==void 0||r.dataset.label!==void 0||r.dataset.detail!==void 0||r.dataset.badge!==void 0||r.dataset.copy!==void 0))&&!(r.nodeType===3&&!r.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let r of t)this.appendChild(r);for(let r of e)this.appendChild(r);for(let r of i)this.appendChild(r);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),n.length)for(let r of n)this.#e.appendChild(r);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#n=document.createElement("button-ui"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("variant","ghost"),this.#n.setAttribute("size","xs"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.setAttribute("text","\u29C9"),this.appendChild(this.#n),this.#r=!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.#n&&e.getAttribute?.("slot")==="chrome"&&this.insertBefore(e,this.#s);for(let e of Array.from(this.children))e===this.#t||e===this.#s||e===this.#e||e===this.#i||e===this.#n||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#p(){if(!this.#t||!this.#e)return;this.#f();let t=K$.has(this.shape)?this.shape:"square",e=J$.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=sC(this.badge);if(t.length===0){this.#s.setAttribute("hidden",""),this.#s.replaceChildren();return}this.#s.removeAttribute("hidden");let e=Array.from(this.#s.children).map(r=>r.dataset.badgeVariant);if(e.length===t.length&&e.every((r,o)=>r===t[o]))return;let n=document.createDocumentFragment();for(let r of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",r),o.setAttribute("role","img"),o.setAttribute("aria-label",iC[r]),o.textContent=eC[r],n.appendChild(o)}this.#s.replaceChildren(n)}#g(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#o=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#o)return;this.#o=t;let e=nC(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)}#O(){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)}#S(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#y();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#b(){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"))}#x(){this.#a=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#w()},this.#l=t=>{!this.selectable||t.key!=="Enter"&&t.key!==" "||(t.composedPath?t.composedPath():[t.target]).includes(this.#n)||(t.preventDefault(),this.#w())},this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#y();e&&this.#A(e)},this.#n.addEventListener("click",this.#c)}#w(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#y(){return this.copyValue?this.copyValue:this.color?this.color:""}async#A(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#E(e)}#E(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.setAttribute("text",t?"\u2713":"\u26A0"),this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.setAttribute("text","\u29C9"),this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#u&&(this.#u.disconnect(),this.#u=null),this.#a&&this.removeEventListener("click",this.#a),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#c&&this.#n.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};M();A("swatch-ui",Sr);mi();var Fb={xs:0,sm:480,md:768,lg:1024,xl:1280},xs=Object.keys(Fb),Td=Object.values(Fb);function Ub(){let s=typeof window<"u"?window.innerWidth:void 0;if(typeof s!="number")return"lg";for(let t=xs.length-1;t>=0;t--)if(s>=Td[t])return xs[t];return"xs"}var Te=ji(Ub());if(typeof window<"u"&&typeof window.matchMedia=="function")for(let s=1;s<Td.length;s++)window.matchMedia(`(min-width: ${Td[s]}px)`).addEventListener("change",()=>{Te.value=Ub()});function Bt(s,t=Te.value){if(!s)return null;if(!s.includes("@"))return s;let e=null,i=new Map;for(let a of s.trim().split(/\s+/)){let l=a.lastIndexOf("@");l===-1?e=a:i.set(a.slice(l+1),a.slice(0,l))}let n=xs.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=xs.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}X();var wr=class extends C{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"stretch",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;render(){let t=this.gap,e=this.align,i=this.justify,r=t?.includes("@")||e?.includes("@")||i?.includes("@")?Te.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",aC(Bt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Bt(e,r);this.style.setProperty("--col-align",lC(o)),this.style.textAlign=hC(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",cC(Bt(i,r))):this.style.removeProperty("--col-justify")}},rC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},oC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function aC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function lC(s){return rC[s]??s}function hC(s){return{start:"start",center:"center",end:"end"}[s]??""}function cC(s){return oC[s]??s}M();A("col-ui",wr);X();var kr=class s extends C{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;#n=null;#r=t=>{let e=this.#g();if(!e)return;let i=this.#S(e);i&&(t.preventDefault(),i.focus())};connected(){this.#u(),this.#d(),this.#f(),this.#p(),this.#c(),this.#t?.addEventListener("click",this.#r),typeof MutationObserver<"u"&&(this.#n=new MutationObserver(()=>{this.#p(),this.#c(),this.#m(),this.#o()}),this.#n.observe(this,{childList:!0})),this.#o()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#o(),this.#m()}#o(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#a=()=>{this.#o(),this.#m()};#l=null;#c(){let t=this.#g();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#a,!0),t.addEventListener("change",this.#a),t.addEventListener("input",this.#a)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#a,!0),t.removeEventListener("change",this.#a),t.removeEventListener("input",this.#a),this.#l=null)}#u(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#y("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.#y("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.#x()),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 n=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(r=>r&&!r.startsWith("field-hint-")&&!r.startsWith("field-err-")),...e].join(" ").trim();n?t.setAttribute("aria-describedby",n):t.removeAttribute("aria-describedby")}#g(){let t=null,e=null;for(let i of this.children)if(!i.hasAttribute("slot")){if(t===null&&(t=i),s.#O.has(i.localName))return i;e===null&&this.#S(i)&&(e=i)}return e??t}static#O=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","date-range-picker-ui","calendar-picker-ui","color-area-ui","upload-ui","rating-ui","segmented-ui","input","textarea","select"]);#S(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#b=0;static#x(){return`field-ctl-${++s.#b}`}static#w=0;static#y(t){return`field-${t}-${++s.#w}`}};M();A("field-ui",kr);X();var Ar=class extends C{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}};M();A("fields-ui",Ar);X();M();var Yb=0,qa=class extends C{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-${++Yb}`),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-${++Yb}`,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}};A("display-field-ui",qa);X();var $r=class extends C{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(ar),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(ar),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,n=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!n?Te.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",fC(Bt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",pC(Bt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",mC(Bt(i,o))):this.style.removeProperty("--row-justify"),n){let a=xs.indexOf(o),l=xs.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},uC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},dC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function fC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function pC(s){return uC[s]??s}function mC(s){return dC[s]??s}M();A("row-ui",$r);X();var Cr=class extends C{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=Te.value,e=this.columns;if(e?.includes("@")){let n=Bt(e,t);this.style.gridTemplateColumns=this.#t(n),this.style.gridAutoFlow=n?"row":"",this.style.gridAutoColumns=n?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";this.minColumnWidth?this.style.setProperty("--grid-min-col",this.minColumnWidth):this.style.removeProperty("--grid-min-col");let i=this.gap;if(i?.includes("@")){let n=Bt(i,t),r=this.#e(n);this.style.columnGap=r,this.style.rowGap=r}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(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})`}};M();A("grid-ui",Cr);X();var Er=class extends C{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};M();A("stack-ui",Er);X();var Pr=class extends C{static properties={};static template=()=>null};M();A("frame-ui",Pr);X();function Yi(s,t,e=5){let n=(t-s||1)/e,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*r,h=Math.floor(s/l)*l,c=Math.ceil(t/l)*l,u=[];for(let d=h;d<=c+l*.5;d+=l)u.push(+d.toFixed(10));return u}function Hb(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 ct(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function je(s,t){let e=String(s);return e.length>t?e.slice(0,Math.max(1,t-1))+"\u2026":e}function at({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${ct(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${ct(String(i))}"`),n}function Vt(s,t,e){return s+t*Math.cos(e)}function _t(s,t,e){return s+t*Math.sin(e)}function gC(s,t,e,i,n){let r=Vt(s,e,i),o=_t(t,e,i),a=Vt(s,e,n),l=_t(t,e,n),h=n-i>Math.PI?1:0;return`M ${s} ${t} L ${r} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function Ld(s,t,e,i,n,r,o=0){let a=(e-i)/2,l=r-n,h=Math.max(0,Math.min(o,a)),c=()=>{let G=Vt(s,e,n),K=_t(t,e,n),ot=Vt(s,e,r),pt=_t(t,e,r),St=Vt(s,i,r),Lt=_t(t,i,r),ce=Vt(s,i,n),ue=_t(t,i,n),Be=l>Math.PI?1:0;return`M ${G} ${K} A ${e} ${e} 0 ${Be} 1 ${ot} ${pt} L ${St} ${Lt} A ${i} ${i} 0 ${Be} 0 ${ce} ${ue} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,g=r-d,O=p-f>Math.PI?1:0,w=Vt(s,e,f),x=_t(t,e,f),S=Vt(s,e,p),v=_t(t,e,p),k=Vt(s,i,g),b=_t(t,i,g),E=Vt(s,i,m),$=_t(t,i,m),Q=Vt(s,e-h,n),T=_t(t,e-h,n),P=Vt(s,i+h,n),L=_t(t,i+h,n),I=Vt(s,e-h,r),D=_t(t,e-h,r),V=Vt(s,i+h,r),H=_t(t,i+h,r);return`M ${w} ${x} A ${e} ${e} 0 ${O} 1 ${S} ${v} A ${h} ${h} 0 0 1 ${I} ${D} L ${V} ${H} A ${h} ${h} 0 0 1 ${k} ${b} A ${i} ${i} 0 ${O} 0 ${E} ${$} A ${h} ${h} 0 0 1 ${P} ${L} L ${Q} ${T} A ${h} ${h} 0 0 1 ${w} ${x} Z`}function Ss(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(n=>`${n.x},${n.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let n=0;n<e-1;n++){let r=s[Math.max(n-1,0)],o=s[n],a=s[n+1],l=s[Math.min(n+2,e-1)],h=o.x+(a.x-r.x)*t/3,c=o.y+(a.y-r.y)*t/3,u=a.x-(l.x-o.x)*t/3,d=a.y-(l.y-o.y)*t/3;i+=` C${h},${c} ${u},${d} ${a.x},${a.y}`}return i}function Md(s,t,e=.4){let i=Ss(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function mh(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}function Rd(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,i/2,e));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i-r} Q${s+e},${t+i} ${s+e-r},${t+i} H${s} Z`}function Gb(s,t,e,i){if(t.length<=e)return{labels:s,vals:t};let n=Math.max(1,e-1),r=t.map((c,u)=>u),o=i?r.slice().sort((c,u)=>t[u]-t[c]).slice(0,n).sort((c,u)=>c-u):r.slice(0,n),a=new Set(o),l=r.filter(c=>!a.has(c)),h=l.reduce((c,u)=>c+t[u],0);return{labels:o.map(c=>s[c]).concat([`+${l.length} more`]),vals:o.map(c=>t[c]).concat([h])}}var Kb=6,Jb=5,OC={std:{ratio:4/3}},bC={"3:2":3/2,"1:1":1,"2:3":2/3},ty={wide:5/4,tall:4/5},Qr=class extends C{static properties={type:{type:String,default:"bar",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},noAverage:{type:Boolean,default:!1,reflect:!0,attribute:"no-average"},color:{type:String,default:"",reflect:!0},noGrid:{type:Boolean,default:!1,reflect:!0,attribute:"no-grid"},noValues:{type:Boolean,default:!1,reflect:!0,attribute:"no-values"},cornerRadius:{type:Number,default:null,reflect:!0,attribute:"corner-radius"},smooth:{type:Number,default:.4,reflect:!0},size:{type:String,default:"",reflect:!0},ratio:{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"},yMin:{type:Number,default:null,reflect:!0,attribute:"y-min"},yMax:{type:Number,default:null,reflect:!0,attribute:"y-max"},labels:{type:String,default:"",reflect:!0},today:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#o=new Set;#a=null;#l(){if(this.cornerRadius!=null)return this.cornerRadius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}#c(t){let e=this.yMin!=null&&Number.isFinite(this.yMin)?this.yMin:0,i=this.yMax!=null&&Number.isFinite(this.yMax)?this.yMax:Math.max(...t);return[e,i]}#h(t,e){return Math.min(Math.max(t,0),e)}#u(t,e,i){return Math.min(Math.max(t,e),i)}#d(t,e){let i=getComputedStyle(this).getPropertyValue(t).trim();if(!i)return e;if(/^-?\d*\.?\d+(px)?$/.test(i)){let o=parseFloat(i);return Number.isFinite(o)?o:e}let n=document.createElement("span");n.style.cssText="position:absolute; visibility:hidden; pointer-events:none; height:0; width:"+i,this.appendChild(n);let r=parseFloat(getComputedStyle(n).width);return n.remove(),Number.isFinite(r)?r:e}#f(){return this.labels==="chip"?"chip":"outside"}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.
235
235
  Correct shape for <chart-ui x="label" y="value">:
236
- [{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#m(),this.#v()}get data(){return this.#t}#p=!1;#m(){if(this.#p)return;let t=this.#O();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.#p=!0)}#O(){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.#P),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#N),this.addEventListener("focus",this.#R),this.addEventListener("blur",this.#X),this.addEventListener("pointerover",this.#B),this.addEventListener("pointermove",this.#q),this.addEventListener("pointerleave",this.#F),this.addEventListener("pointerdown",this.#D),this.addEventListener("click",this.#_),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let n=Math.round(e),r=Math.round(i);n===this.#n&&(!this.hasAttribute("resize")||r===this.#r)||(this.#n=n,this.#r=r,!this.#s&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.#v()})))}),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.#v()}#g(){let t=this.clientWidth||300,e=this.clientHeight||0,i=OC.std,n=this.#t.length||1,r=Math.max(t,120),o=this.hasAttribute("resize")||this.style.height,a=bC[this.ratio],l=a?Math.round(r/a):o&&e>40?e:Math.round(r/i.ratio),h=parseFloat(getComputedStyle(this).maxHeight);isFinite(h)&&h>0&&l>h&&(l=Math.round(h));let c=r/Math.max(l,1),u=a?this.ratio:c>=ty.wide?"3:2":c<=ty.tall?"2:3":"1:1";this.getAttribute("data-ratio-resolved")!==u&&this.setAttribute("data-ratio-resolved",u);let d=Math.min(r,l),f=this.size||(d<150?"sm":d<300?"md":"lg"),p=f==="sm"?9:f==="md"?10:11,m=p,g=f==="sm"?8:f==="md"?9:10,O=this.#f();this.getAttribute("data-labels-resolved")!==O&&this.setAttribute("data-labels-resolved",O);let w=O==="chip",x=this.#d("--chart-chrome-inset",8),S=this.#d("--chart-band-gap",4),v=Math.max(x,this.#d("--card-radius",x)),k=this.#d("--chart-chip-font-size",p),b=this.#d("--chart-chip-pad-x",6),E=this.#d("--chart-chip-pad-y",4),$=this.#d("--chart-min-plot-height-chips",180),Q=this.#d("--chart-min-plot-height-grid",120),T=w?l<Q?"bare":l<$?"no-x-chrome":"full":"full",P=this.noGrid,L=u==="3:2"?1:.8,I=P?0:p*3.2*L,D=!!this.x,V=w?{top:0,right:0,bottom:0,left:0}:{top:P?2:p*1.6,right:P?2:p*1.2,bottom:!D||P?2:p*2.2*L,left:I},H=r-V.left-V.right,G=Math.max(4,H/n*.6);return{width:r,height:l,pad:V,fontSize:p,labelSize:m,valueSize:g,barMinW:G,plotW:H,n,sizeClass:f,ratioResolved:u,labelsResolved:O,chipMode:w,chromeInset:x,bandGap:S,cornerClearance:v,chipFontSize:k,chipPadX:b,chipPadY:E,minPlotHeightChips:$,minPlotHeightGrid:Q,degradeStage:T}}#S=null;#v(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#S&&(this.#S=t.cloneNode(!0)),this.innerHTML="",this.#S&&this.appendChild(this.#S.cloneNode(!0)),!this.#t.length){this.removeAttribute("has-data");return}this.setAttribute("has-data",""),this.#a=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 n="",r="";switch(this.type){case"bar":({svg:n,viewBox:r}=this.#ct());break;case"line":({svg:n,viewBox:r}=this.#ut());break;case"pie":({svg:n,viewBox:r}=this.#ft());break;case"donut":({svg:n,viewBox:r}=this.#pt());break;case"radar":({svg:n,viewBox:r}=this.#mt());break;case"sparkline":({svg:n,viewBox:r}=this.#gt());break;case"segments":({svg:n,viewBox:r}=this.#At());break;case"area":({svg:n,viewBox:r}=this.#Ot());break;case"scatter":({svg:n,viewBox:r}=this.#bt());break;case"radial-bar":({svg:n,viewBox:r}=this.#yt());break;case"gauge":({svg:n,viewBox:r}=this.#vt());break;case"funnel":({svg:n,viewBox:r}=this.#xt());break;case"treemap":({svg:n,viewBox:r}=this.#St());break;case"sankey":({svg:n,viewBox:r}=this.#wt());break;case"composed":({svg:n,viewBox:r}=this.#kt());break;case"stacked-bar":({svg:n,viewBox:r}=this.#Ct());break;case"grouped-bar":({svg:n,viewBox:r}=this.#Pt());break;case"multi-line":({svg:n,viewBox:r}=this.#Tt());break;default:({svg:n,viewBox:r}=this.#ct());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#$()){let o=this.#Lt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#x(t,e){return e?` data-slice="${t}" data-series-key="${ct(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#w(t,e){return e?` data-slice="${t}" data-series-key="${ct(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#b=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#P),document.removeEventListener("pointerdown",this.#z),this.removeEventListener("keydown",this.#N),this.removeEventListener("focus",this.#R),this.removeEventListener("blur",this.#X),this.removeEventListener("pointerover",this.#B),this.removeEventListener("pointermove",this.#q),this.removeEventListener("pointerleave",this.#F),this.removeEventListener("pointerdown",this.#D),this.removeEventListener("click",this.#_),this.#J()}#$(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#C(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#P=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#o.delete(i):this.#o.add(i),this.#v())};#k(t){return!!t&&this.#o.has(t)}#y(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${Hb(e)}`}default:return Hb(e)}}#A=-1;#T(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#E(t){let e=this.#T();if(!e.length){this.#Q();return}this.#A=Math.max(0,Math.min(t,e.length-1)),this.#L(),this.#M()}#L(){let t=this.#T();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#A];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#Q(){this.#A=-1;for(let t of this.#T())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#M(){let t=this.#T()[this.#A];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#j(t,i)}#I(){let t=this.#T()[this.#A];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#Y(t,i)}))}#R=()=>{this.#A===-1&&this.#E(0)};#X=()=>{this.#Q(),this.#Z&&this.#U()};#N=t=>{let e=this.#T();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#E(this.#A+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#E(Math.max(0,this.#A-1));break;case"Home":t.preventDefault(),this.#E(0);break;case"End":t.preventDefault(),this.#E(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#I();break;case"Escape":t.preventDefault(),this.#Q(),this.#Z&&this.#U();break}};#Z=null;#B=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#rt(e,t),this.#j(e,t))};#q=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#Z&&this.#U(),this.#J();this.#rt(e,t),e!==this.#Z&&this.#j(e,t)};#F=t=>{t&&t.pointerType==="touch"||(this.#J(),this.#Z&&this.#U())};#D=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#Z&&this.#U(),this.#J();this.#rt(e,t),e!==this.#Z&&this.#j(e,t),document.addEventListener("pointerdown",this.#z)};#z=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#J(),this.#Z&&this.#U(),document.removeEventListener("pointerdown",this.#z)))};#_=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#Y(e,t)}))};#j(t,e){this.#Z=t,this.dots==="hover"&&this.#et(t),this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#Y(t,e)}))}#U(){this.#Z=null,this.dots==="hover"&&this.#G(),this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#et(t){let e=t?.previousElementSibling;this.#a&&this.#a!==e&&this.#a.removeAttribute("data-dot-active"),e&&e.hasAttribute("data-dot")?(e.setAttribute("data-dot-active",""),this.#a=e):this.#a=null}#G(){this.#a&&this.#a.removeAttribute("data-dot-active"),this.#a=null}#Y(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#nt(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#nt(t,e){if(t==null)return null;let i=this.x,n=this.#W();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#k(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#rt(t,e){if(this.#C())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#b){let g=document.createElement("div");g.setAttribute("popover","manual"),g.setAttribute("role","tooltip"),g.classList.add("chart-tooltip-popup"),document.body.appendChild(g),this.#b=g}let a=[];if(o&&a.push(`<span data-tip-role="series">${ct(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ct(i)}</span>`),n!==void 0){let g=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#y(n)}${g}</span>`)}this.#b.innerHTML=a.join("");try{this.#b.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#b.offsetWidth||0,f=this.#b.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.#b.style.left=`${p}px`,this.#b.style.top=`${m}px`}#J(){if(this.#b){try{this.#b.hidePopover()}catch{}this.#b.remove(),this.#b=null}}#W(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#ot(t,e){switch(this.dots){case"none":return!1;case"last":return t===e-1;default:return!0}}#tt(t,e,i,n,r,o,a={}){let l=r,h=o?.fontSize||10,c=o?.labelSize||h,u=!!o?.chipMode,d=o?.degradeStage||"full",f="",p="",m=i;if((o?.sizeClass==="sm"||a.thinGrid)&&i.length>4&&(m=i.filter((g,O)=>O%2===0||O===i.length-1)),!this.noGrid&&d!=="bare"){let O=i[i.length-1]-i[0]||1;if(a.vertical){if(n&&n.length){let w=t-l.left-l.right,x=n.length-1,S=a.pointAligned?w/Math.max(x,1):w/n.length,v=Math.max(1,Math.round(n.length/3));for(let k=0;k<n.length;k++){if(k%v!==0&&k!==x)continue;let b=a.pointAligned?l.left+S*k:l.left+S*k+S/2;f+=`<line data-chart-grid x1="${b}" y1="${l.top}" x2="${b}" y2="${e-l.bottom}"/>`}}}else for(let w of m){let x=l.top+(e-l.top-l.bottom)*(1-(w-i[0])/O);f+=`<line data-chart-grid x1="${l.left}" y1="${x}" x2="${t-l.right}" y2="${x}"/>`}if(u)p+=this.#at(m,i,O,t,e,l,o);else for(let w of m){let x=l.top+(e-l.top-l.bottom)*(1-(w-i[0])/O);f+=`<text data-y-label x="${l.left-4}" y="${x+h*.35}" text-anchor="end" font-size="${h}">${this.#y(w)}</text>`}if(n&&d!=="no-x-chrome")if(u)p+=this.#it(n,t,e,l,o,a);else{let w=t-l.left-l.right,x=w/n.length,S=n.length-1,v=new Set;if(a.xTickMode==="sparse"&&S>1)v.add(0),v.add(Math.round(S/2)),v.add(S);else if(a.xTickMode==="everyNth"&&S>1){let b=Math.max(2,Math.ceil(n.length/4));for(let E=0;E<=S;E+=b)v.add(E);v.add(S)}else{let E=n.reduce((Q,T)=>Math.max(Q,String(T).length),1)*c*.6+c*.75,$=Math.max(1,Math.ceil(E/x));for(let Q=0;Q<n.length;Q++)Q%$!==0&&Q!==S||Q!==S&&S-Q<$||v.add(Q)}let k=w/Math.max(S,1);for(let b of v){let E=a.pointAligned?l.left+k*b:l.left+x*b+x/2,$=ct(a.abbreviateLabels?je(n[b],4):n[b]);f+=`<text data-x-label x="${E}" y="${e-h*.5}" text-anchor="middle" font-size="${c}">${$}</text>`}}}return{svg:f,chipSvg:p}}#at(t,e,i,n,r,o,a){let{chromeInset:l,chipFontSize:h,chipPadX:c,chipPadY:u,cornerClearance:d}=a,f=h*.6+u,p=h*1.2+u*2,m=t.map(S=>{let v=o.top+(r-o.top-o.bottom)*(1-(S-e[0])/i),k=Math.min(Math.max(v,l+f),r-l-f),E=k-f<=d||k+f>=r-d?d:l,$=this.#y(S),Q=String($).length*h*.6+c*2;return{cy:k,cx:E,rw:Q,text:$}});if(!m.length)return"";let g=m.length-1,O=[m[0]];for(let S=1;S<g;S++){let v=m[S],k=O[O.length-1];Math.abs(v.cy-k.cy)>=p&&O.push(v)}for(m.length>1&&O.push(m[g]);O.length>2;){let S=O[O.length-2],v=O[O.length-1];if(Math.abs(v.cy-S.cy)<p)O.splice(O.length-2,1);else break}if(O.length===2){let[S,v]=O;if(Math.abs(S.cy-v.cy)<p){let k=(S.cy+v.cy)/2,[b,E]=S.cy<=v.cy?[S,v]:[v,S];b.cy=Math.min(b.cy,k-p/2),E.cy=Math.max(E.cy,k+p/2)}}let w=O,x="";for(let S of w)x+=`<rect data-chip data-chip-axis="y" x="${S.cx}" y="${S.cy-p/2}" width="${S.rw}" height="${p}"/>`,x+=`<text data-chip-label data-chip-axis="y" x="${S.cx+c}" y="${S.cy}" dominant-baseline="central" font-size="${h}">${S.text}</text>`;return x}#it(t,e,i,n,r,o){let{chromeInset:a,bandGap:l,chipFontSize:h,chipPadX:c,chipPadY:u,cornerClearance:d}=r,f=e-n.left-n.right,p=t.length-1,m=o.pointAligned?f/Math.max(p,1):f/t.length,g=h*1.2+u*2,O=i-Math.max(a,l)-g/2,w=t.map((v,k)=>{let b=o.pointAligned?n.left+m*k:n.left+m*k+m/2,E=o.abbreviateLabels?je(v,4):v,$=ct(E),Q=String(E).length*h*.6+c*2;return{cx0:b,rw:Q,text:$}});if(!w.length)return"";for(let v of w)v.cx=Math.min(Math.max(v.cx0,a+v.rw/2),e-a-v.rw/2);w[0].cx=Math.max(w[0].cx,d+w[0].rw/2),w[p].cx=Math.min(w[p].cx,e-d-w[p].rw/2);let x=[w[0]];for(let v=1;v<w.length-1;v++){let k=w[v],b=x[x.length-1];k.cx-k.rw/2>=b.cx+b.rw/2&&x.push(k)}for(w.length>1&&x.push(w[p]);x.length>2;){let v=x[x.length-2],k=x[x.length-1];if(k.cx-k.rw/2<v.cx+v.rw/2)x.splice(x.length-2,1);else break}if(x.length===2){let[v,k]=x;if(v.cx+v.rw/2>k.cx-k.rw/2){let b=(v.cx+k.cx)/2;v.cx=Math.min(v.cx,b-v.rw/2),k.cx=Math.max(k.cx,b+k.rw/2)}}let S="";for(let v of x)S+=`<rect data-chip data-chip-axis="x" x="${v.cx-v.rw/2}" y="${O-g/2}" width="${v.rw}" height="${g}"/>`,S+=`<text data-chip-label data-chip-axis="x" x="${v.cx}" y="${O}" text-anchor="middle" dominant-baseline="central" font-size="${h}">${v.text}</text>`;return S}#V(){let t=this.x,e=this.#t;if(this.today){for(let i=0;i<e.length;i++)if(String(e[i]?.[t]??"")===String(this.today))return i;return-1}return e.findIndex(i=>i&&i.today)}#st(t,e,i){let n=i.sizeClass==="sm"?2.5:3.5,r=Math.max(6,i.fontSize),o=i.chipMode?-1:1,a=i.chipMode?e-Math.max(i.chromeInset??0,n):e;return`<circle data-today-dot cx="${t}" cy="${a}" r="${n}"/><line data-today-tick x1="${t}" y1="${a}" x2="${t}" y2="${a+o*r}"/>`}#lt(t,e,i){let n=i.sizeClass==="sm"?2.5:3.5,r=Math.max(6,i.fontSize);return`<circle data-today-dot cx="${e}" cy="${t}" r="${n}"/><line data-today-tick x1="${e}" y1="${t}" x2="${e-r}" y2="${t}"/>`}#K(t){return t&&t.provisional?" data-provisional":""}#ht(t,e,i,n,r){let o="",a=-1,l=h=>{if(a<0)return;let c=Math.max(a-1,0),u=t.slice(c,h);if(u.length>=2){let d=u[0].x,f=u[u.length-1].x,p=Math.min(...u.map(m=>m.y));o+=`<rect data-area-provisional-fade x="${d}" y="${p}" width="${Math.max(f-d,0)}" height="${Math.max(i-p,0)}"/>`,o+=`<path data-line-provisional d="${Ss(u,r)}"/>`}a=-1};for(let h=0;h<t.length;h++){let c=!!(e[h]&&e[h].provisional);c&&a<0?a=h:!c&&a>=0&&l(h)}return l(t.length),o}#ct(){let t=this.#g(),e=this.#t,i=this.#W()[0]||this.y,n=e.map(b=>+(b[i]??0)),r=e.map(b=>b[this.x]??""),o=n,a=t.ratioResolved==="1:1"&&n.length>Kb;a&&({labels:r,vals:n}=Gb(r,n,Kb,!1));let l=Yi(...this.#c(n),5),h=l[l.length-1],c=l[0];if(t.ratioResolved==="2:3")return this.#dt(t,r,n,l,h,a?[]:e);let{width:u,height:d,pad:f}=t,p=d-f.top-f.bottom,g=(u-f.left-f.right)/r.length,O=g*.6,w=(g-O)/2,{svg:x,chipSvg:S}=this.#tt(u,d,l,r,f,t,{abbreviateLabels:t.ratioResolved==="1:1"}),v=!this.noValues&&t.sizeClass!=="sm",k=!this.noAverage&&o.length>1&&t.sizeClass!=="sm"&&!this.noGrid;for(let b=0;b<r.length;b++){let E=n[b],$=h-c?(E-c)/(h-c)*p:0,Q=this.#h($,p),T=f.left+g*b+w,P=f.top+p-Q,L=a?"":this.#K(e[b]);x+=`<path data-bar${L}${at({label:r[b],value:E})} d="${mh(T,P,O,Q,this.#l())}"/>`,v&&(x+=`<text data-value x="${T+O/2}" y="${P-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#y(E)}</text>`)}if(k){let b=o.reduce((Q,T)=>Q+T,0)/o.length,E=h-c?(b-c)/(h-c)*p:0,$=f.top+p-this.#h(E,p);x+=`<line data-avg x1="${f.left}" y1="${$}" x2="${u-f.right}" y2="${$}"/>`,x+=`<text data-avg-label x="${u-f.right+2}" y="${$+3}" text-anchor="start" font-size="${t.valueSize}">${this.#y(b)}</text>`,x+=`<line data-hit${at({label:"Average",value:b})} x1="${f.left}" y1="${$}" x2="${u-f.right}" y2="${$}" stroke="transparent" stroke-width="12"/>`}if(!a){let b=this.#V();b>-1&&b<r.length&&(x+=this.#st(f.left+g*b+w+O/2,f.top+p,t))}return x+=S,{svg:x,viewBox:`0 0 ${u} ${d}`}}#dt(t,e,i,n,r,o=[]){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce(($,Q)=>Math.max($,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,O=(l-p.top-p.bottom)/e.length,w=O*.6,x=(O-w)/2,S="";if(!u){let $=n[n.length-1]-n[0]||1;for(let Q of n){let T=p.left+m*((Q-n[0])/$);S+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,S+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#y(Q)}</text>`}}let v=!this.noValues,k=!this.noAverage&&i.length>1&&!u,b=n[0];for(let $=0;$<e.length;$++){let Q=i[$],T=r-b?(Q-b)/(r-b)*m:0,P=this.#h(T,m),L=p.top+O*$+x,I=p.left,D=this.#K(o[$]);S+=`<text data-x-label x="${p.left-6}" y="${L+w/2+h*.35}" text-anchor="end" font-size="${c}">${ct(e[$])}</text>`,S+=`<path data-bar${D}${at({label:e[$],value:Q})} d="${Rd(I,L,P,w,this.#l())}"/>`,v&&(S+=`<text data-value x="${I+P+4}" y="${L+w/2+h*.35}" text-anchor="start" font-size="${t.valueSize}">${this.#y(Q)}</text>`)}if(k){let $=i.reduce((P,L)=>P+L,0)/i.length,Q=r-b?($-b)/(r-b)*m:0,T=p.left+this.#h(Q,m);S+=`<line data-avg x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,S+=`<line data-hit${at({label:"Average",value:$})} x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}" stroke="transparent" stroke-width="12"/>`}let E=this.#V();return E>-1&&E<e.length&&o.length&&(S+=this.#lt(p.top+O*E+x+w/2,p.left,t)),{svg:S,viewBox:`0 0 ${a} ${l}`}}#ut(){let t=this.#g(),e=this.#t,i=this.#W()[0]||this.y,n=e.map(P=>+(P[i]??0)),r=e.map(P=>P[this.x]??""),o=Yi(...this.#c(n),5),a=o[o.length-1],l=o[0],{width:h,height:c,pad:u}=t,d=c-u.top-u.bottom,p=(h-u.left-u.right)/Math.max(e.length-1,1),m=this.type==="area",g=t.ratioResolved,{svg:O,chipSvg:w}=this.#tt(h,c,o,r,u,t,{thinGrid:g!=="3:2",vertical:m&&g==="2:3",xTickMode:g==="2:3"?"sparse":g==="1:1"?"everyNth":void 0,pointAligned:!0}),x=n.map((P,L)=>{let I=u.left+p*L,D=u.top+d-(a-l?(P-l)/(a-l)*d:0),V=this.#u(D,u.top,u.top+d);return{x:I,y:V,v:P,label:r[L]}}),S=u.top+d,v=Math.max(0,Math.min(1,this.smooth));O+=`<path data-area d="${Md(x,S,v)}"/>`,O+=`<path data-line d="${Ss(x,v)}"/>`,O+=this.#ht(x,e,S,t,v);let k=t.sizeClass==="sm",b=k?1.5:3,E=Math.max(b,10),$=!this.noValues&&!k,Q=!this.noAverage&&n.length>1&&!k&&!this.noGrid;if(x.forEach((P,L)=>{let I=this.#K(e[L]);this.#ot(L,x.length)&&(O+=`<circle data-dot${I} cx="${P.x}" cy="${P.y}" r="${b}"/>`),O+=`<circle data-hit${at({label:P.label,value:P.v})} cx="${P.x}" cy="${P.y}" r="${E}" fill="transparent"/>`,$&&(O+=`<text data-value x="${P.x}" y="${P.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#y(P.v)}</text>`)}),Q){let P=n.reduce((D,V)=>D+V,0)/n.length,L=u.top+d-(a-l?(P-l)/(a-l)*d:0),I=this.#u(L,u.top,u.top+d);O+=`<line data-avg x1="${u.left}" y1="${I}" x2="${h-u.right}" y2="${I}"/>`,O+=`<text data-avg-label x="${h-u.right+2}" y="${I+3}" text-anchor="start" font-size="${t.valueSize}">${this.#y(P)}</text>`,O+=`<line data-hit${at({label:"Average",value:P})} x1="${u.left}" y1="${I}" x2="${h-u.right}" y2="${I}" stroke="transparent" stroke-width="12"/>`}let T=this.#V();return T>-1&&T<x.length&&(O+=this.#st(x[T].x,S,t)),O+=w,{svg:O,viewBox:`0 0 ${h} ${c}`}}#ft(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(P=>+(P[e]??0)),n=i.reduce((P,L)=>P+L,0)||1,r=t.map(P=>P[this.x]??""),o=this.#g(),{width:a,height:l,fontSize:h,valueSize:c}=o,u=o.ratioResolved,d=h,f=8,p=20,m=P=>(P+f)*c*.62+d+4,g=c*1.2+d+4,O=Math.max(0,a/2-p),w=Math.floor((O-d-4)/(c*.62))-f,x=r.reduce((P,L)=>Math.max(P,String(L).length),1),S=Math.max(4,Math.min(14,w,x)),v=m(S),k=u==="1:1"?Math.max(p,Math.min(a/2-v,l/2-g)):Math.max(30,Math.min(a,l)*.42),b=u==="3:2"?Math.max(k+8,a*.32):a/2,E=u==="2:3"?Math.min(l/2,k+h*1.5):l/2,$=u==="1:1",Q="",T=-Math.PI/2;for(let P=0;P<i.length;P++){let L=i[P]/n*Math.PI*2;if(L===0)continue;let I=T+L,D=(i[P]/n*100).toFixed(1),V=` data-slice="${P%10}"${at({label:r[P],value:i[P],pct:D})}`;if(Math.abs(L-Math.PI*2)<.001?Q+=`<circle${V} cx="${b}" cy="${E}" r="${k}"/>`:Q+=`<path${V} d="${gC(b,E,k,T,I)}"/>`,$){let H=T+L/2,G=Vt(b,k+d,H),K=_t(E,k+d,H),ot=Math.cos(H),pt=Math.abs(ot)<.15?"middle":ot>0?"start":"end",St=`${ct(je(r[P],S))} (${D}%)`;Q+=`<text data-ring-label x="${G}" y="${K}" text-anchor="${pt}" dominant-baseline="central" font-size="${c}">${St}</text>`}T=I}return this.#H=t.map((P,L)=>({label:r[L],value:i[L],pct:(i[L]/n*100).toFixed(1),slot:L%10})),{svg:Q,viewBox:`0 0 ${a} ${l}`}}#pt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(x=>+(x[e]??0)),n=i.reduce((x,S)=>x+S,0)||1,r=t.map(x=>x[this.x]??""),o=this.#g(),{width:a,height:l,fontSize:h}=o,c=o.ratioResolved,u=Math.max(30,Math.min(a,l)*(c==="1:1"?.46:.42)),d=u*.72,f=c==="3:2"?Math.max(u+8,a*.32):a/2,p=c==="2:3"?Math.min(l/2,u+h*1.5):l/2,m="",g=-Math.PI/2;for(let x=0;x<i.length;x++){let S=i[x]/n*Math.PI*2;if(S===0)continue;let v=g+S,k=(i[x]/n*100).toFixed(1),b=` data-slice="${x%10}"${at({label:r[x],value:i[x],pct:k})}`;Math.abs(S-Math.PI*2)<.001?(m+=`<circle${b} cx="${f}" cy="${p}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,m+=`<path${b} d="M ${f-u} ${p} A ${u} ${u} 0 1 1 ${f+u} ${p} A ${u} ${u} 0 1 1 ${f-u} ${p} Z M ${f-d} ${p} A ${d} ${d} 0 1 0 ${f+d} ${p} A ${d} ${d} 0 1 0 ${f-d} ${p} Z" fill-rule="evenodd"/>`):m+=`<path${b} d="${Ld(f,p,u,d,g,v,this.#l())}"/>`,g=v}let O=Math.max(14,Math.round(u*.32)),w=Math.max(9,Math.round(u*.16));return m+=`<text data-donut-total x="${f}" y="${p}" text-anchor="middle" dominant-baseline="central" font-size="${O}">${this.#y(n)}</text>`,m+=`<text data-donut-label x="${f}" y="${p+O}" text-anchor="middle" dominant-baseline="central" font-size="${w}">Total</text>`,this.#H=t.map((x,S)=>({label:r[S],value:i[S],pct:(i[S]/n*100).toFixed(1),slot:S%10})),{svg:m,viewBox:`0 0 ${a} ${l}`}}#mt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map($=>+($[e]??0)),n=t.map($=>$[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#g(),{width:l,height:h,fontSize:c}=a,u=a.ratioResolved,d=u==="1:1",f=u==="2:3",p=d?c*1.8:c*3.5,m=f?h*.6:h,g=l/2,O=f?m/2:h/2,w=Math.max(40,Math.min(l,m)/2-p),x="",S=Math.PI*2/o;for(let $=1;$<=3;$++){let Q=w*$/3,T="";for(let P=0;P<o;P++){let L=-Math.PI/2+S*P,I=g+Q*Math.cos(L),D=O+Q*Math.sin(L);T+=(P===0?"M":"L")+` ${I} ${D}`}T+=" Z",x+=`<path data-chart-grid d="${T}"/>`}for(let $=0;$<o;$++){let Q=-Math.PI/2+S*$,T=g+w*Math.cos(Q),P=O+w*Math.sin(Q);x+=`<line data-chart-grid x1="${g}" y1="${O}" x2="${T}" y2="${P}"/>`}let v="",k=[];for(let $=0;$<o;$++){let Q=-Math.PI/2+S*$,T=i[$]/r*w,P=g+T*Math.cos(Q),L=O+T*Math.sin(Q);v+=($===0?"M":"L")+` ${P} ${L}`,k.push({px:P,py:L})}v+=" Z",x+=`<path data-radar-fill d="${v}"/>`,x+=`<path data-radar-line d="${v}"/>`;let b=Math.max(c,10);for(let $=0;$<o;$++){let{px:Q,py:T}=k[$];x+=`<circle data-hit${at({label:n[$],value:i[$]})} cx="${Q}" cy="${T}" r="${b}" fill="transparent"/>`}let E=d?c*.6:c*1.3;for(let $=0;$<o;$++){let Q=-Math.PI/2+S*$,T=g+(w+E)*Math.cos(Q),P=O+(w+E)*Math.sin(Q),L=Math.abs(Math.cos(Q))<.1?"middle":Math.cos(Q)>0?"start":"end",I=ct(f?je(n[$],5):n[$]);x+=`<text data-x-label x="${T}" y="${P}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${I}</text>`}return{svg:x,viewBox:`0 0 ${l} ${h}`}}#gt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(O=>+(O[e]??0)),n=Yi(0,Math.max(...i),5),r=n[n.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(O=>O[this.x]??""),f=i.map((O,w)=>({x:c*w,y:h-(r?O/r*(h-u*2):0)-u,v:O,label:d[w]})),p=Math.max(0,Math.min(1,this.smooth)),m="";m+=`<path data-area d="${Md(f,h,p)}"/>`,m+=`<path data-line d="${Ss(f,p)}"/>`;let g=Math.max(c/2,6);for(let O of f)m+=`<circle data-hit${at({label:O.label,value:O.v})} cx="${O.x}" cy="${O.y}" r="${g}" fill="transparent"/>`;return{svg:m,viewBox:`0 0 ${l} ${h}`}}#Ot(){return this.#ut()}#bt(){let t=this.#g(),e=this.#t,i=this.#W()[0]||this.y,n=e.map(b=>+(b[i]??0)),r=e.map(b=>b[this.x]??""),o=t.ratioResolved,a=o==="2:3"?8:5,l=Yi(...this.#c(n),a),h=l[l.length-1],c=l[0],{width:u,height:d,pad:f}=t,p=d-f.top-f.bottom,g=(u-f.left-f.right)/Math.max(e.length-1,1),{svg:O,chipSvg:w}=this.#tt(u,d,l,r,f,t,{abbreviateLabels:o==="1:1"}),x=t.sizeClass==="sm"?2.5:4,S=o==="1:1"?x*.85:x,v=Math.max(S*2,10);for(let b=0;b<n.length;b++){let E=f.left+g*b,$=f.top+p-(h-c?(n[b]-c)/(h-c)*p:0),Q=this.#u($,f.top,f.top+p),T=this.#K(e[b]);O+=`<circle data-dot data-scatter${T} cx="${E}" cy="${Q}" r="${S}"/>`,O+=`<circle data-hit${at({label:r[b],value:n[b]})} cx="${E}" cy="${Q}" r="${v}" fill="transparent"/>`}let k=this.#V();return k>-1&&k<n.length&&(O+=this.#st(f.left+g*k,f.top+p,t)),O+=w,{svg:O,viewBox:`0 0 ${u} ${d}`}}#yt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(b=>+(b[e]??0)),n=t.map(b=>b[this.x]??""),r=Math.max(...i)||1,o=this.#g(),{width:a,height:l,fontSize:h,valueSize:c}=o,u=o.ratioResolved,d=a/2,f=l/2,p=Math.max(30,Math.min(a,l)*.45),m=p*.3,g=i.length||1,O=(p-m)/g,w=Math.min(2,O*.15),x=u==="1:1",S=u==="3:2"?0:-Math.PI/2,v=b=>x?-Math.PI/2+Math.PI*2*b/g:S,k="";for(let b=0;b<i.length;b++){let E=m+O*b+w/2,$=m+O*(b+1)-w/2,Q=(E+$)/2,T=$-E,P=2*Math.PI*Q,L=Math.max(0,Math.min(1,i[b]/r))*P,D=v(b)*180/Math.PI;if(k+=`<circle data-radial-track cx="${d}" cy="${f}" r="${Q}" fill="none" stroke-width="${T}"/>`,L<=0)continue;let V=(i[b]/r*100).toFixed(1),H=at({label:n[b],value:i[b],pct:V}),G=Math.abs(L-P)<.5,K=G?"butt":"round",ot=G?`${P} 0`:`${L} ${P-L}`;k+=`<circle data-slice="${b%10}"${H} data-radial-bar cx="${d}" cy="${f}" r="${Q}" fill="none" stroke-width="${T}" stroke-linecap="${K}" stroke-dasharray="${ot}" transform="rotate(${D} ${d} ${f})"/>`}if(x){let b=h;for(let E=0;E<i.length;E++){let $=v(E),Q=Vt(d,p+b,$),T=_t(f,p+b,$),P=Math.cos($),L=Math.abs(P)<.15?"middle":P>0?"start":"end";k+=`<text data-ring-label x="${Q}" y="${T}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${ct(n[E])}</text>`}}return this.#H=t.map((b,E)=>({label:n[E],key:n[E],value:i[E],pct:(i[E]/r*100).toFixed(1),slot:E%10})),{svg:k,viewBox:`0 0 ${a} ${l}`}}#vt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(Q=>+(Q[e]??0)),n=i.reduce((Q,T)=>Q+T,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#g(),{width:h,height:c,fontSize:u}=l,d=l.ratioResolved,f=d==="3:2",p=d==="2:3",m=Math.max(40,Math.min(h*(d==="1:1"?.48:.45),c*(p?.46:.6))),g=m*.72,O=(m-g)/2,w=f?Math.max(m+8,h*.34):h/2,x=p?Math.min(c*.5,m+u*1.3):c*.68,S="";if(S+=`<path data-radial-track d="${Ld(w,x,m,g,Math.PI,2*Math.PI,O)}"/>`,a>0){let Q=Math.PI+Math.PI*a,T=at({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});S+=`<path data-slice="0"${T} data-gauge-fill d="${Ld(w,x,m,g,Math.PI,Q,O)}"/>`}let v=Math.max(18,Math.round(m*.42)),k=Math.max(10,Math.round(m*.2)),b,E,$;return f?(b=w+m+u*1.2,E=x-m*.15,$="start"):p?(b=w,E=x+v*.7,$="middle"):(b=w,E=x-m*.15,$="middle"),S+=`<text data-gauge-value x="${b}" y="${E}" text-anchor="${$}" dominant-baseline="central" font-size="${v}">${this.#y(r)}</text>`,o!==r&&(S+=`<text data-gauge-max x="${b}" y="${E+v*.8}" text-anchor="${$}" dominant-baseline="central" font-size="${k}">of ${this.#y(o)}</text>`),{svg:S,viewBox:`0 0 ${h} ${c}`}}#xt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(b=>+(b[e]??0)),n=t.map(b=>b[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#g(),{width:l,height:h}=a,c=a.fontSize,u=a.ratioResolved;this.#H=t.map((b,E)=>({label:n[E],value:i[E],pct:(i[E]/o*100).toFixed(1),slot:E%10}));let d="";if(u==="3:2"){let b=Math.max(h*.16,c*2.2),E=c*.8,$=l-E*2,Q=h-b*2,T=$/r,P=Math.max(2,T*.08),L=b+Q/2;for(let I=0;I<r;I++){let D=i[I],V=I<r-1?i[I+1]:i[I],H=D/o*(Q/2),G=V/o*(Q/2),K=E+T*I+P/2,ot=E+T*(I+1)-P/2,pt=(K+ot)/2,St=(D/o*100).toFixed(1),Lt=at({label:n[I],value:D,pct:St}),ce=`M ${K} ${L-H} L ${ot} ${L-G} L ${ot} ${L+G} L ${K} ${L+H} Z`;if(d+=`<path data-slice="${I%10}" data-funnel-stage${Lt} d="${ce}"/>`,d+=`<text data-funnel-label x="${pt}" y="${b-c*.6}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${c}">${ct(n[I])}</text>`,d+=`<text data-funnel-value x="${pt}" y="${h-b+c*1.3}" text-anchor="middle" dominant-baseline="hanging" font-size="${c}">${this.#y(D)}</text>`,I>0){let ue=(i[I]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${pt}" y="${h-b+c*2.5}" text-anchor="middle" dominant-baseline="hanging" font-size="${c*.85}">${ue}%</text>`}}return{svg:d,viewBox:`0 0 ${l} ${h}`}}let f=u==="1:1",p=u==="2:3",m=f||p?c*.8:Math.max(l*.18,80),g=p?Math.max(l*.3,c*6):Math.max(l*.18,80),O=c*.8,w=l-m-g,S=(h-O*2)/r,v=Math.max(2,S*.08),k=m+w/2;for(let b=0;b<r;b++){let E=i[b],$=b<r-1?i[b+1]:i[b],Q=E/o*(w/2),T=$/o*(w/2),P=O+S*b+v/2,L=O+S*(b+1)-v/2,I=P+S/2-v/2,D=(E/o*100).toFixed(1),V=at({label:n[b],value:E,pct:D}),H=`M ${k-Q} ${P} L ${k+Q} ${P} L ${k+T} ${L} L ${k-T} ${L} Z`;if(d+=`<path data-slice="${b%10}" data-funnel-stage${V} d="${H}"/>`,f){let G=(Q+T)/2,K=Math.floor((G*2-c)/(c*.6));K>=2&&(d+=`<text data-funnel-label data-funnel-label-inline x="${k}" y="${I}" text-anchor="middle" dominant-baseline="central" font-size="${c}">${ct(je(n[b],K))}</text>`)}else d+=`<text data-funnel-label x="${m-8}" y="${I}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ct(n[b])}</text>`;if(p){if(d+=`<text data-funnel-label data-funnel-label-right x="${l-g+8}" y="${I-c*.6}" text-anchor="start" dominant-baseline="central" font-size="${c}">${ct(n[b])}</text>`,d+=`<text data-funnel-value x="${l-g+8}" y="${I+c*.6}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#y(E)}</text>`,b>0){let G=(i[b]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${l-g+8}" y="${I+c*1.7}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${G}%</text>`}}else if(d+=`<text data-funnel-value x="${l-g+8}" y="${I}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#y(E)}</text>`,b>0){let G=(i[b]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${l-g+8}" y="${I+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${G}%</text>`}}return{svg:d,viewBox:`0 0 ${l} ${h}`}}#St(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#g(),{width:a,height:l,fontSize:h}=o,c=i.reduce((v,k)=>v+k,0)||1,u=o.ratioResolved,d=Array.from({length:r},(v,k)=>k).sort((v,k)=>i[k]-i[v]),f=u==="3:2"?Math.max(2,Math.ceil(Math.sqrt(r*2))):u==="2:3"?Math.max(1,Math.floor(Math.sqrt(r/2))):Math.max(1,Math.round(Math.sqrt(r))),p=[];for(let v=0;v<d.length;v+=f)p.push(d.slice(v,v+f));let m=p.map(v=>v.reduce((k,b)=>k+i[b],0)),g=m.reduce((v,k)=>v+k,0)||1,O=[],w=0;for(let v=0;v<p.length;v++){let k=m[v]/g*l,b=m[v]||1,E=0;for(let $ of p[v]){let Q=i[$]/b*a;O.push({i:$,x:E,y:w,w:Q,h:k}),E+=Q}w+=k}let x="",S=2;for(let v of O){let k=(i[v.i]/c*100).toFixed(1),b=at({label:n[v.i],value:i[v.i],pct:k});x+=`<rect data-slice="${v.i%10}" data-treemap-tile${b} x="${v.x+S}" y="${v.y+S}" width="${Math.max(0,v.w-S*2)}" height="${Math.max(0,v.h-S*2)}" rx="${this.#l()}"/>`;let E=v.x+8,$=v.w>h*4,Q=$&&v.h>h*2.5,T=$&&!Q&&v.h>h*1.2,P=u==="2:3"?8:20;if(Q)x+=`<text data-treemap-label x="${E}" y="${v.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ct(je(n[v.i],P))}</text>`,x+=`<text data-treemap-value x="${E}" y="${v.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#y(i[v.i])}</text>`;else if(T){let L=v.y+v.h/2;x+=`<text data-treemap-label x="${E}" y="${L}" font-size="${h}" dominant-baseline="central">${ct(je(n[v.i],P))}</text>`}}return this.#H=t.map((v,k)=>({label:n[k],value:i[k],pct:(i[k]/c*100).toFixed(1),slot:k%10})),{svg:x,viewBox:`0 0 ${a} ${l}`}}#wt(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let b of t){let E=b.source??b.from??"",$=b.target??b.to??"",Q=+(b.value??b.v??0);e.has(E)||e.set(E,{name:E,flow:0}),i.has($)||i.set($,{name:$,flow:0}),e.get(E).flow+=Q,i.get($).flow+=Q}let n=this.#g(),{width:r,height:o,fontSize:a}=n,l=n.ratioResolved,h=[...e.values()],c=[...i.values()],u=h.reduce((b,E)=>b+E.flow,0)||1,d=c.reduce((b,E)=>b+E.flow,0)||1,f="";if(l==="2:3"){let b=Math.max(8,o*.05),E=b+a*1.8,$=r*.5,Q=Math.min(a*.8,$/Math.max(1,Math.max(h.length,c.length)-1)),T=Math.max(1,r-Q*Math.max(0,h.length-1)),P=Math.max(1,r-Q*Math.max(0,c.length-1)),L=0;for(let D of h){let V=D.flow/u*T;D.x0=L,D.x1=L+V,D.cursor=L,L+=V+Q}L=0;for(let D of c){let V=D.flow/d*P;D.x0=L,D.x1=L+V,D.cursor=L,L+=V+Q}let I=Math.min(this.#l(),b/2);h.forEach((D,V)=>{let H=at({label:D.name,value:D.flow});f+=`<rect data-sankey-node data-slice="${V%10}"${H} x="${D.x0}" y="${E-b}" width="${D.x1-D.x0}" height="${b}" rx="${I}"/>`,f+=`<text data-sankey-label x="${(D.x0+D.x1)/2}" y="${E-b-6}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${a}">${ct(je(D.name,10))}</text>`}),c.forEach((D,V)=>{let H=at({label:D.name,value:D.flow});f+=`<rect data-sankey-node data-slice="${(h.length+V)%10}"${H} x="${D.x0}" y="${o-E}" width="${D.x1-D.x0}" height="${b}" rx="${I}"/>`,f+=`<text data-sankey-label x="${(D.x0+D.x1)/2}" y="${o-E+b+a+2}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${a}">${ct(je(D.name,10))}</text>`});for(let D of t){let V=e.get(D.source??D.from??""),H=i.get(D.target??D.to??"");if(!V||!H)continue;let G=+(D.value??D.v??0);if(G<=0)continue;let K=G/u*T,ot=G/d*P,pt=V.cursor,St=pt+K,Lt=H.cursor,ce=Lt+ot;V.cursor+=K,H.cursor+=ot;let ue=E,Be=o-E,gs=(ue+Be)/2,YA=at({label:`${V.name} \u2192 ${H.name}`,value:G}),HA=`M ${pt} ${ue} C ${pt} ${gs}, ${Lt} ${gs}, ${Lt} ${Be} L ${ce} ${Be} C ${ce} ${gs}, ${St} ${gs}, ${St} ${ue} Z`;f+=`<path data-sankey-link${YA} d="${HA}"/>`}return{svg:f,viewBox:`0 0 ${r} ${o}`}}let p=l==="1:1",m=Math.max(8,r*.03),g=m+a*(p?2.2:5),O=p?6:24,w=a*.6,x=o-w*Math.max(0,h.length-1),S=o-w*Math.max(0,c.length-1),v=0;for(let b of h){let E=b.flow/u*x;b.y0=v,b.y1=v+E,b.cursor=v,v+=E+w}v=0;for(let b of c){let E=b.flow/d*S;b.y0=v,b.y1=v+E,b.cursor=v,v+=E+w}let k=Math.min(this.#l(),m/2);h.forEach((b,E)=>{let $=at({label:b.name,value:b.flow});f+=`<rect data-sankey-node data-slice="${E%10}"${$} x="${g-m}" y="${b.y0}" width="${m}" height="${b.y1-b.y0}" rx="${k}"/>`,f+=`<text data-sankey-label x="${g-m-6}" y="${(b.y0+b.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${ct(je(b.name,O))}</text>`}),c.forEach((b,E)=>{let $=at({label:b.name,value:b.flow});f+=`<rect data-sankey-node data-slice="${(h.length+E)%10}"${$} x="${r-g}" y="${b.y0}" width="${m}" height="${b.y1-b.y0}" rx="${k}"/>`,f+=`<text data-sankey-label x="${r-g+m+6}" y="${(b.y0+b.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${ct(je(b.name,O))}</text>`});for(let b of t){let E=e.get(b.source??b.from??""),$=i.get(b.target??b.to??"");if(!E||!$)continue;let Q=+(b.value??b.v??0);if(Q<=0)continue;let T=Q/u*x,P=Q/d*S,L=E.cursor,I=L+T,D=$.cursor,V=D+P;E.cursor+=T,$.cursor+=P;let H=g,G=r-g,K=(H+G)/2,ot=at({label:`${E.name} \u2192 ${$.name}`,value:Q}),pt=`M ${H} ${L} C ${K} ${L}, ${K} ${D}, ${G} ${D} L ${G} ${V} C ${K} ${V}, ${K} ${I}, ${H} ${I} Z`;f+=`<path data-sankey-link${ot} d="${pt}"/>`}return{svg:f,viewBox:`0 0 ${r} ${o}`}}#kt(){let t=this.#g(),e=this.#t,i=t.ratioResolved,n=this.#W(),r=n[0]||"bar",o=n[1]||"line",a=e.map($=>$[this.x]??""),l=e.map($=>+($[r]??0)),h=e.map($=>+($[o]??0)),c=[...l,...h],u=Yi(...this.#c(c),5),d=u[u.length-1],f=u[0],{width:p,height:m,pad:g}=t,O=m-g.top-g.bottom,w=p-g.left-g.right,x=w/e.length,S=x*.6,v=(x-S)/2,{svg:k,chipSvg:b}=this.#tt(p,m,u,a,g,t);if(!this.#k(r))for(let $=0;$<e.length;$++){let Q=l[$],T=d-f?(Q-f)/(d-f)*O:0,P=this.#h(T,O),L=g.left+x*$+v,I=g.top+O-P,D=this.#K(e[$]);k+=`<path${D}${this.#x(0,r)}${at({label:a[$],value:Q,series:r})} d="${mh(L,I,S,P,this.#l())}"/>`}if(!this.#k(o))if(i==="2:3"){let $=w*.34,Q=Math.min(O*.26,$*.6),T=g.left+w-$-2,P=g.top+2,L=Math.min(...h),D=Math.max(...h)-L||1,V=h.map((G,K)=>({x:T+(h.length>1?K/(h.length-1)*$:$/2),y:P+Q-(G-L)/D*Q,v:G,label:a[K]})),H=Math.max(0,Math.min(1,this.smooth));k+=`<rect data-composed-inset-bg x="${T-4}" y="${P-4}" width="${$+8}" height="${Q+8}" rx="${this.#l()}"/>`,k+=`<path data-composed-inset-line${this.#w(1,o)} d="${Ss(V,H)}"/>`;for(let G of V)k+=`<circle data-hit${at({label:G.label,value:G.v,series:o})} cx="${G.x}" cy="${G.y}" r="6" fill="transparent"/>`;k+=`<text data-composed-inset-label x="${T}" y="${P-6}" text-anchor="start" font-size="${t.valueSize}">${ct(o)}</text>`}else{let $=h.map((I,D)=>{let V=g.top+O-(d-f?(I-f)/(d-f)*O:0);return{x:g.left+x*D+x/2,y:this.#u(V,g.top,g.top+O),v:I,label:a[D]}}),Q=Math.max(0,Math.min(1,this.smooth)),T=i==="1:1",P=T?' data-slice="1" data-deemphasized-tint style="stroke: var(--md-sys-color-neutral-on-surface-variant)"':this.#w(1,o),L=T?' data-slice="1" data-deemphasized-tint style="fill: var(--md-sys-color-neutral-on-surface-variant)"':this.#x(1,o);k+=`<path data-line${P} d="${Ss($,Q)}"/>`,k+=this.#ht($,e,g.top+O,t,Q),$.forEach((I,D)=>{let V=this.#K(e[D]);k+=`<circle data-dot${L}${V} cx="${I.x}" cy="${I.y}" r="3"/>`,k+=`<circle data-hit${at({label:I.label,value:I.v,series:o})} cx="${I.x}" cy="${I.y}" r="10" fill="transparent"/>`})}let E=this.#V();return E>-1&&E<e.length&&(k+=this.#st(g.left+x*E+x/2,g.top+O,t)),this.#H=[{label:r,key:r,slot:0},{label:o,key:o,slot:1,deemphasized:i==="1:1"}],k+=b,{svg:k,viewBox:`0 0 ${p} ${m}`}}#At(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=i.reduce((g,O)=>g+O,0)||1,o=this.#g(),a=o.ratioResolved;if(a==="1:1"&&i.length>Jb&&({labels:n,vals:i}=Gb(n,i,Jb,!0)),this.#H=n.map((g,O)=>({label:g,value:i[O],pct:(i[O]/r*100).toFixed(1),slot:O%10})),a==="2:3")return this.#$t(o,n,i,r);let l=getComputedStyle(this),h=Math.max(40,this.clientWidth||200),c=24,u=Math.min(this.#l(),c/2),d=Math.max(0,parseFloat(l.getPropertyValue("--chart-segments-gap"))||2),f=[],p=0;for(let g=0;g<i.length;g++){let O=g===i.length-1?h:Math.round((p*r+i[g]*h)/r),w=g===i.length-1?h:i.slice(0,g+1).reduce((S,v)=>S+v,0)/r*h,x=g===0?0:i.slice(0,g).reduce((S,v)=>S+v,0)/r*h;f.push({x,w:Math.max(0,w-x)}),p=O}let m="";for(let g=0;g<f.length;g++){let{x:O,w}=f[g];if(w<=0)continue;let x=g===0,S=g===f.length-1,v=Math.max(0,w-(S?0:d)),k=(i[g]/r*100).toFixed(1),b=at({label:n[g],value:i[g],pct:k}),E=`<title>${ct(n[g])}: ${i[g]} (${k}%)</title>`;if(x&&S||!x&&!S||u===0)m+=`<rect data-slice="${g%10}"${b} x="${O}" y="0" width="${v}" height="${c}"${(x||S)&&u?` rx="${u}"`:""}>${E}</rect>`;else{let $=u,Q=O+v,T;x?T=`M ${O+$} 0 H ${Q} V ${c} H ${O+$} A ${$} ${$} 0 0 1 ${O} ${c-$} V ${$} A ${$} ${$} 0 0 1 ${O+$} 0 Z`:T=`M ${O} 0 H ${Q-$} A ${$} ${$} 0 0 1 ${Q} ${$} V ${c-$} A ${$} ${$} 0 0 1 ${Q-$} ${c} H ${O} Z`,m+=`<path data-slice="${g%10}"${b} d="${T}">${E}</path>`}}return{svg:m,viewBox:`0 0 ${h} ${c}`}}#$t(t,e,i,n){let o=Math.max(60,t.height),a=Math.min(this.#l(),24/2),l=getComputedStyle(this),h=Math.max(0,parseFloat(l.getPropertyValue("--chart-segments-gap"))||2),c=[];for(let d=0;d<i.length;d++){let f=d===i.length-1?o:i.slice(0,d+1).reduce((m,g)=>m+g,0)/n*o,p=d===0?0:i.slice(0,d).reduce((m,g)=>m+g,0)/n*o;c.push({y:p,h:Math.max(0,f-p)})}let u="";for(let d=0;d<c.length;d++){let{y:f,h:p}=c[d];if(p<=0)continue;let m=d===0,g=d===c.length-1,O=Math.max(0,p-(g?0:h)),w=(i[d]/n*100).toFixed(1),x=at({label:e[d],value:i[d],pct:w}),S=`<title>${ct(e[d])}: ${i[d]} (${w}%)</title>`;if(m&&g||!m&&!g||a===0)u+=`<rect data-slice="${d%10}"${x} x="0" y="${f}" width="24" height="${O}"${(m||g)&&a?` rx="${a}"`:""}>${S}</rect>`;else{let v=a,k=f+O,b;m?b=`M 0 ${f+v} A ${v} ${v} 0 0 1 ${v} ${f} H ${24-v} A ${v} ${v} 0 0 1 24 ${f+v} V ${k} H 0 Z`:b=`M 0 ${f} H 24 V ${k-v} A ${v} ${v} 0 0 1 ${24-v} ${k} H ${v} A ${v} ${v} 0 0 1 0 ${k-v} Z`,u+=`<path data-slice="${d%10}"${x} d="${b}">${S}</path>`}}return{svg:u,viewBox:`0 0 24 ${o}`}}#Ct(){let t=this.#t,e=this.#W(),i=t.map(b=>b[this.x]??""),n=t.map(b=>e.reduce((E,$)=>E+ +(b[$]??0),0)),r=Yi(...this.#c(n),5),o=r[r.length-1],a=r[0],l=this.#g(),h=l.ratioResolved;if(this.#H=e.map((b,E)=>({label:b,key:b,slot:E%10})),h==="2:3")return this.#Et(l,i,e,t,o,r);let{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/t.length,g=m*.6,O=(m-g)/2,{svg:w,chipSvg:x}=this.#tt(c,u,r,i,d,l,{abbreviateLabels:h==="1:1"}),S=o-a?f/(o-a):0,v=this.#u(d.top+f+a*S,d.top,d.top+f);for(let b=0;b<t.length;b++){let E=v,$=e.length;for(let Q=0;Q<$;Q++){if(this.#k(e[Q]))continue;let T=+(t[b][e[Q]]??0),P=T*S;if(P<=0){E=this.#u(E-P,d.top,d.top+f);continue}let L=Math.max(E-P,d.top),I=E-L,D=d.left+m*b+O,V=L;E=L;let H=Q===$-1,G=this.#l(),ot=`${this.#K(t[b])}${this.#x(Q%10,e[Q])}${at({label:i[b],value:T,series:e[Q]})}`;H?w+=`<path${ot} d="${mh(D,V,g,I,G)}"/>`:w+=`<rect${ot} x="${D}" y="${V}" width="${g}" height="${I}"/>`}}let k=this.#V();return k>-1&&k<t.length&&(w+=this.#st(d.left+m*k+m/2,d.top+f,l)),w+=x,{svg:w,viewBox:`0 0 ${c} ${u}`}}#Et(t,e,i,n,r,o){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce(($,Q)=>Math.max($,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,O=(l-p.top-p.bottom)/e.length,w=O*.6,x=(O-w)/2,S=o[0],v=r-S?m/(r-S):0,k=this.#u(p.left-S*v,p.left,p.left+m),b="";if(!u){let $=o[o.length-1]-o[0]||1;for(let Q of o){let T=p.left+m*((Q-o[0])/$);b+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,b+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#y(Q)}</text>`}}for(let $=0;$<e.length;$++){let Q=p.top+O*$+x;b+=`<text data-x-label x="${p.left-6}" y="${Q+w/2+h*.35}" text-anchor="end" font-size="${c}">${ct(e[$])}</text>`;let T=k,P=i.length;for(let L=0;L<P;L++){if(this.#k(i[L]))continue;let I=+(n[$][i[L]]??0),D=I*v;if(D<=0)continue;let V=T,H=Math.min(T+D,p.left+m),G=H-V;T=H;let K=L===P-1,pt=`${this.#K(n[$])}${this.#x(L%10,i[L])}${at({label:e[$],value:I,series:i[L]})}`;K?b+=`<path${pt} d="${Rd(V,Q,G,w,this.#l())}"/>`:b+=`<rect${pt} x="${V}" y="${Q}" width="${G}" height="${w}"/>`}}let E=this.#V();return E>-1&&E<e.length&&(b+=this.#lt(p.top+O*E+O/2,p.left,t)),{svg:b,viewBox:`0 0 ${a} ${l}`}}#Pt(){let t=this.#t,e=this.#W(),i=t.map(b=>b[this.x]??""),n=t.flatMap(b=>e.map(E=>+(b[E]??0))),r=Yi(...this.#c(n),5),o=r[r.length-1],a=r[0],l=this.#g(),h=l.ratioResolved;if(this.#H=e.map((b,E)=>({label:b,key:b,slot:E%10})),h==="2:3")return this.#Qt(l,i,e,t,o,r);let{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/t.length,g=3,O=m*.7,w=(O-g*(e.length-1))/e.length,x=(m-O)/2,{svg:S,chipSvg:v}=this.#tt(c,u,r,i,d,l,{abbreviateLabels:h==="1:1"});for(let b=0;b<t.length;b++){let E=this.#K(t[b]);for(let $=0;$<e.length;$++){if(this.#k(e[$]))continue;let Q=+(t[b][e[$]]??0),T=o-a?(Q-a)/(o-a)*f:0,P=this.#h(T,f),L=d.left+m*b+x+(w+g)*$,I=d.top+f-P;S+=`<path${E}${this.#x($%10,e[$])}${at({label:i[b],value:Q,series:e[$]})} d="${mh(L,I,w,P,this.#l())}"/>`,this.noValues||(S+=`<text data-value x="${L+w/2}" y="${I-4}" text-anchor="middle" font-size="${l.valueSize}">${this.#y(Q)}</text>`)}}let k=this.#V();return k>-1&&k<t.length&&(S+=this.#st(d.left+m*k+m/2,d.top+f,l)),S+=v,{svg:S,viewBox:`0 0 ${c} ${u}`}}#Qt(t,e,i,n,r,o){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce(($,Q)=>Math.max($,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,O=(l-p.top-p.bottom)/e.length,w=3,x=O*.7,S=(x-w*(i.length-1))/i.length,v=(O-x)/2,k=o[0],b="";if(!u){let $=o[o.length-1]-o[0]||1;for(let Q of o){let T=p.left+m*((Q-o[0])/$);b+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,b+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#y(Q)}</text>`}}for(let $=0;$<e.length;$++){let Q=p.top+O*$,T=this.#K(n[$]);b+=`<text data-x-label x="${p.left-6}" y="${Q+O/2+h*.35}" text-anchor="end" font-size="${c}">${ct(e[$])}</text>`;for(let P=0;P<i.length;P++){if(this.#k(i[P]))continue;let L=+(n[$][i[P]]??0),I=r-k?(L-k)/(r-k)*m:0,D=this.#h(I,m),V=Q+v+(S+w)*P;b+=`<path${T}${this.#x(P%10,i[P])}${at({label:e[$],value:L,series:i[P]})} d="${Rd(p.left,V,D,S,this.#l())}"/>`,this.noValues||(b+=`<text data-value x="${p.left+D+4}" y="${V+S/2+h*.35}" text-anchor="start" font-size="${t.valueSize}">${this.#y(L)}</text>`)}}let E=this.#V();return E>-1&&E<e.length&&(b+=this.#lt(p.top+O*E+O/2,p.left,t)),{svg:b,viewBox:`0 0 ${a} ${l}`}}#Tt(){let t=this.#t,e=this.#W(),i=t.map(S=>S[this.x]??""),n=t.flatMap(S=>e.map(v=>+(S[v]??0))),r=Yi(...this.#c(n),5),o=r[r.length-1],a=r[0],l=this.#g(),h=l.ratioResolved,{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/Math.max(t.length-1,1),{svg:g,chipSvg:O}=this.#tt(c,u,r,i,d,l,{pointAligned:!0}),w=h==="3:2";for(let S=0;S<e.length;S++){if(this.#k(e[S]))continue;let k=t.map(P=>+(P[e[S]]??0)).map((P,L)=>{let I=d.left+m*L,D=d.top+f-(o-a?(P-a)/(o-a)*f:0),V=this.#u(D,d.top,d.top+f);return{x:I,y:V,v:P,label:i[L]}}),b=d.top+f,E=Math.max(0,Math.min(1,this.smooth)),$=this.seriesEmphasis,Q=!$||e[S]===$,T=Q?"":" data-deemphasized";if(Q&&(g+=`<path data-area${this.#x(S%10,e[S])} d="${Md(k,b,E)}"/>`),g+=`<path data-line${this.#w(S%10,e[S])}${T} d="${Ss(k,E)}"/>`,g+=this.#ht(k,t,b,l,E),k.forEach((P,L)=>{let I=this.#K(t[L]);this.#ot(L,k.length)&&(g+=`<circle data-dot${this.#x(S%10,e[S])}${T}${I} cx="${P.x}" cy="${P.y}" r="3"/>`),g+=`<circle data-hit${at({label:P.label,value:P.v,series:e[S]})} cx="${P.x}" cy="${P.y}" r="10" fill="transparent"/>`}),w&&k.length){let P=k[k.length-1];g+=`<text data-series-end-label${this.#x(S%10,e[S])} x="${P.x+6}" y="${P.y}" text-anchor="start" dominant-baseline="central" font-size="${l.labelSize}">${ct(e[S])}</text>`}}let x=this.#V();return x>-1&&x<t.length&&(g+=this.#st(d.left+m*x,d.top+f,l)),this.#H=e.map((S,v)=>({label:S,key:S,slot:v%10})),g+=O,{svg:g,viewBox:`0 0 ${c} ${u}`}}#H=null;get legendData(){return this.#H?this.#H.map(t=>({...t})):null}#Lt(){if(!this.#H||!this.#H.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#H){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.deemphasized?(n.setAttribute("data-deemphasized-tint",""),n.style.background="var(--md-sys-color-neutral-on-surface-variant)"):e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};M();A("chart-ui",Qr);X();var ey=new Set(["3:2","1:1","2:3"]),Tr=class s extends C{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},ratio:{type:String,default:"",reflect:!0},interactive:{type:Boolean,default:!0,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#a()}disconnected(){this.#n()}render(){this.#s(),this.#a()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#a(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(ey.has(this.ratio))return this.ratio;if(this.#t){let t=this.#t.getAttribute("data-ratio-resolved");if(ey.has(t))return t}return""}#o(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#a(){let t=this.#r();t?this.getAttribute("data-ratio-resolved")!==t&&this.setAttribute("data-ratio-resolved",t):this.hasAttribute("data-ratio-resolved")&&this.removeAttribute("data-ratio-resolved");let e=this.#o();if(this.innerHTML="",!!e.length)for(let i of e){let n=i.key??i.label??"",r=i.label??n,o=i.slot!=null?i.slot:0,a=!this.#i.has(n),l=document.createElement("badge-ui");l.setAttribute("data-row",""),l.setAttribute("role",this.interactive?"button":"listitem"),l.setAttribute("text",r),n&&l.setAttribute("data-key",n),a&&l.setAttribute("data-active",""),i.deemphasized&&l.setAttribute("data-deemphasized",""),this.interactive&&(l.setAttribute("tabindex","0"),l.setAttribute("aria-pressed",a?"true":"false"));let h=this.shape||"dot",c=document.createElement("swatch-ui");c.setAttribute("shape",h),c.setAttribute("size","sm");let u=i.deemphasized?"var(--md-sys-color-neutral-on-surface-variant)":n?`var(--color-${n}, var(--a-data-${o}))`:`var(--a-data-${o})`;c.style.setProperty("--swatch-color",u),l.appendChild(c),this.interactive&&(l.addEventListener("click",d=>this.#l(d,n)),l.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),this.#l(d,n))})),this.appendChild(l)}}#l(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};M();A("chart-legend-ui",Tr);X();var yC=120,Lr=class extends C{static properties={placement:{type:String,default:"bottom",reflect:!0},offset:{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;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#a),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#u),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#u))))}render(){this.open?this.#r():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=mt(t,e,{placement:this.placement,gap:this.offset,matchWidth:this.matchWidth}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#o(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#a=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#u=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},yC)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#o(),this.trigger==="click"&&this.removeEventListener("click",this.#a),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#u),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#u))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};M();A("popover-ui",Lr);X();var Mr=class extends C{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 n of i)n!==e&&n.open&&(n.open=!1)}},Rr=class extends C{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 n=document.createElement("icon-ui");n.setAttribute("name","caret-down"),n.setAttribute("slot","caret"),e.appendChild(n),this.prepend(e)}if(!this.querySelector('[slot="body"]')){let e=document.createElement("div");e.setAttribute("slot","body");let i=[...this.childNodes].filter(n=>n.nodeType===1?!n.hasAttribute("slot"):n.nodeType===3&&n.textContent.trim());for(let n of i)e.appendChild(n);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())}};M();A("accordion-ui",Mr),A("accordion-item-ui",Rr);X();var Ir=class extends C{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()}}};M();A("divider-ui",Ir);X();var Dr=class extends C{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()}};M();A("blockquote-ui",Dr);X();var Id=[{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}],Xr=class extends C{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),n=Id.find(o=>i<=o.limit)||Id[Id.length-1],r=Math.round(e/n.divisor);try{return new Intl.RelativeTimeFormat(this.#e(),{style:this.timeStyle,numeric:this.numeric}).format(r,n.unit)}catch{let o=e<0,a=Math.abs(r);return o?`${a} ${n.unit}${a===1?"":"s"} ago`:`in ${a} ${n.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.#n()}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.#n()}#n(){this.#r();let t=Number(this.updateInterval);!Number.isFinite(t)||t<=0||(this.#t=setInterval(()=>{this.textContent=this.#i()},t*1e3))}#r(){this.#t!=null&&(clearInterval(this.#t),this.#t=null)}disconnected(){super.disconnected(),this.#r()}};M();A("relative-time-ui",Xr);X();var qr=class extends C{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")}};M();A("number-format-ui",qr);X();var Dd=["Weak","Fair","Good","Strong"];function vC(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 Zr=class extends C{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=`
236
+ [{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#m(),this.#b()}get data(){return this.#t}#p=!1;#m(){if(this.#p)return;let t=this.#g();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.#p=!0)}#g(){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.#P),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#N),this.addEventListener("focus",this.#L),this.addEventListener("blur",this.#X),this.addEventListener("pointerover",this.#B),this.addEventListener("pointermove",this.#q),this.addEventListener("pointerleave",this.#F),this.addEventListener("pointerdown",this.#D),this.addEventListener("click",this.#_),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let n=Math.round(e),r=Math.round(i);n===this.#n&&(!this.hasAttribute("resize")||r===this.#r)||(this.#n=n,this.#r=r,!this.#s&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.#b()})))}),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.#b()}#O(){let t=this.clientWidth||300,e=this.clientHeight||0,i=OC.std,n=this.#t.length||1,r=Math.max(t,120),o=this.hasAttribute("resize")||this.style.height,a=bC[this.ratio],l=a?Math.round(r/a):o&&e>40?e:Math.round(r/i.ratio),h=parseFloat(getComputedStyle(this).maxHeight);isFinite(h)&&h>0&&l>h&&(l=Math.round(h));let c=r/Math.max(l,1),u=a?this.ratio:c>=ty.wide?"3:2":c<=ty.tall?"2:3":"1:1";this.getAttribute("data-ratio-resolved")!==u&&this.setAttribute("data-ratio-resolved",u);let d=Math.min(r,l),f=this.size||(d<150?"sm":d<300?"md":"lg"),p=f==="sm"?9:f==="md"?10:11,m=p,g=f==="sm"?8:f==="md"?9:10,O=this.#f();this.getAttribute("data-labels-resolved")!==O&&this.setAttribute("data-labels-resolved",O);let w=O==="chip",x=this.#d("--chart-chrome-inset",8),S=this.#d("--chart-band-gap",4),v=Math.max(x,this.#d("--card-radius",x)),k=this.#d("--chart-chip-font-size",p),b=this.#d("--chart-chip-pad-x",6),E=this.#d("--chart-chip-pad-y",4),$=this.#d("--chart-min-plot-height-chips",180),Q=this.#d("--chart-min-plot-height-grid",120),T=w?l<Q?"bare":l<$?"no-x-chrome":"full":"full",P=this.noGrid,L=u==="3:2"?1:.8,I=P?0:p*3.2*L,D=!!this.x,V=w?{top:0,right:0,bottom:0,left:0}:{top:P?2:p*1.6,right:P?2:p*1.2,bottom:!D||P?2:p*2.2*L,left:I},H=r-V.left-V.right,G=Math.max(4,H/n*.6);return{width:r,height:l,pad:V,fontSize:p,labelSize:m,valueSize:g,barMinW:G,plotW:H,n,sizeClass:f,ratioResolved:u,labelsResolved:O,chipMode:w,chromeInset:x,bandGap:S,cornerClearance:v,chipFontSize:k,chipPadX:b,chipPadY:E,minPlotHeightChips:$,minPlotHeightGrid:Q,degradeStage:T}}#S=null;#b(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#S&&(this.#S=t.cloneNode(!0)),this.innerHTML="",this.#S&&this.appendChild(this.#S.cloneNode(!0)),!this.#t.length){this.removeAttribute("has-data");return}this.setAttribute("has-data",""),this.#a=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 n="",r="";switch(this.type){case"bar":({svg:n,viewBox:r}=this.#ct());break;case"line":({svg:n,viewBox:r}=this.#ut());break;case"pie":({svg:n,viewBox:r}=this.#ft());break;case"donut":({svg:n,viewBox:r}=this.#pt());break;case"radar":({svg:n,viewBox:r}=this.#mt());break;case"sparkline":({svg:n,viewBox:r}=this.#gt());break;case"segments":({svg:n,viewBox:r}=this.#At());break;case"area":({svg:n,viewBox:r}=this.#Ot());break;case"scatter":({svg:n,viewBox:r}=this.#bt());break;case"radial-bar":({svg:n,viewBox:r}=this.#yt());break;case"gauge":({svg:n,viewBox:r}=this.#vt());break;case"funnel":({svg:n,viewBox:r}=this.#xt());break;case"treemap":({svg:n,viewBox:r}=this.#St());break;case"sankey":({svg:n,viewBox:r}=this.#wt());break;case"composed":({svg:n,viewBox:r}=this.#kt());break;case"stacked-bar":({svg:n,viewBox:r}=this.#Ct());break;case"grouped-bar":({svg:n,viewBox:r}=this.#Pt());break;case"multi-line":({svg:n,viewBox:r}=this.#Tt());break;default:({svg:n,viewBox:r}=this.#ct());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#A()){let o=this.#Lt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#x(t,e){return e?` data-slice="${t}" data-series-key="${ct(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#w(t,e){return e?` data-slice="${t}" data-series-key="${ct(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.#P),document.removeEventListener("pointerdown",this.#z),this.removeEventListener("keydown",this.#N),this.removeEventListener("focus",this.#L),this.removeEventListener("blur",this.#X),this.removeEventListener("pointerover",this.#B),this.removeEventListener("pointermove",this.#q),this.removeEventListener("pointerleave",this.#F),this.removeEventListener("pointerdown",this.#D),this.removeEventListener("click",this.#_),this.#J()}#A(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#E(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#P=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#o.delete(i):this.#o.add(i),this.#b())};#k(t){return!!t&&this.#o.has(t)}#v(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${Hb(e)}`}default:return Hb(e)}}#$=-1;#T(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#C(t){let e=this.#T();if(!e.length){this.#Q();return}this.#$=Math.max(0,Math.min(t,e.length-1)),this.#M(),this.#R()}#M(){let t=this.#T();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#$];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#Q(){this.#$=-1;for(let t of this.#T())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#R(){let t=this.#T()[this.#$];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#j(t,i)}#I(){let t=this.#T()[this.#$];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#Y(t,i)}))}#L=()=>{this.#$===-1&&this.#C(0)};#X=()=>{this.#Q(),this.#Z&&this.#U()};#N=t=>{let e=this.#T();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#C(this.#$+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#C(Math.max(0,this.#$-1));break;case"Home":t.preventDefault(),this.#C(0);break;case"End":t.preventDefault(),this.#C(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#I();break;case"Escape":t.preventDefault(),this.#Q(),this.#Z&&this.#U();break}};#Z=null;#B=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#rt(e,t),this.#j(e,t))};#q=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#Z&&this.#U(),this.#J();this.#rt(e,t),e!==this.#Z&&this.#j(e,t)};#F=t=>{t&&t.pointerType==="touch"||(this.#J(),this.#Z&&this.#U())};#D=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#Z&&this.#U(),this.#J();this.#rt(e,t),e!==this.#Z&&this.#j(e,t),document.addEventListener("pointerdown",this.#z)};#z=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#J(),this.#Z&&this.#U(),document.removeEventListener("pointerdown",this.#z)))};#_=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#Y(e,t)}))};#j(t,e){this.#Z=t,this.dots==="hover"&&this.#et(t),this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#Y(t,e)}))}#U(){this.#Z=null,this.dots==="hover"&&this.#G(),this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#et(t){let e=t?.previousElementSibling;this.#a&&this.#a!==e&&this.#a.removeAttribute("data-dot-active"),e&&e.hasAttribute("data-dot")?(e.setAttribute("data-dot-active",""),this.#a=e):this.#a=null}#G(){this.#a&&this.#a.removeAttribute("data-dot-active"),this.#a=null}#Y(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#nt(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#nt(t,e){if(t==null)return null;let i=this.x,n=this.#W();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#k(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#rt(t,e){if(this.#E())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#y){let g=document.createElement("div");g.setAttribute("popover","manual"),g.setAttribute("role","tooltip"),g.classList.add("chart-tooltip-popup"),document.body.appendChild(g),this.#y=g}let a=[];if(o&&a.push(`<span data-tip-role="series">${ct(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ct(i)}</span>`),n!==void 0){let g=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#v(n)}${g}</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`}#J(){if(this.#y){try{this.#y.hidePopover()}catch{}this.#y.remove(),this.#y=null}}#W(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#ot(t,e){switch(this.dots){case"none":return!1;case"last":return t===e-1;default:return!0}}#tt(t,e,i,n,r,o,a={}){let l=r,h=o?.fontSize||10,c=o?.labelSize||h,u=!!o?.chipMode,d=o?.degradeStage||"full",f="",p="",m=i;if((o?.sizeClass==="sm"||a.thinGrid)&&i.length>4&&(m=i.filter((g,O)=>O%2===0||O===i.length-1)),!this.noGrid&&d!=="bare"){let O=i[i.length-1]-i[0]||1;if(a.vertical){if(n&&n.length){let w=t-l.left-l.right,x=n.length-1,S=a.pointAligned?w/Math.max(x,1):w/n.length,v=Math.max(1,Math.round(n.length/3));for(let k=0;k<n.length;k++){if(k%v!==0&&k!==x)continue;let b=a.pointAligned?l.left+S*k:l.left+S*k+S/2;f+=`<line data-chart-grid x1="${b}" y1="${l.top}" x2="${b}" y2="${e-l.bottom}"/>`}}}else for(let w of m){let x=l.top+(e-l.top-l.bottom)*(1-(w-i[0])/O);f+=`<line data-chart-grid x1="${l.left}" y1="${x}" x2="${t-l.right}" y2="${x}"/>`}if(u)p+=this.#at(m,i,O,t,e,l,o);else for(let w of m){let x=l.top+(e-l.top-l.bottom)*(1-(w-i[0])/O);f+=`<text data-y-label x="${l.left-4}" y="${x+h*.35}" text-anchor="end" font-size="${h}">${this.#v(w)}</text>`}if(n&&d!=="no-x-chrome")if(u)p+=this.#it(n,t,e,l,o,a);else{let w=t-l.left-l.right,x=w/n.length,S=n.length-1,v=new Set;if(a.xTickMode==="sparse"&&S>1)v.add(0),v.add(Math.round(S/2)),v.add(S);else if(a.xTickMode==="everyNth"&&S>1){let b=Math.max(2,Math.ceil(n.length/4));for(let E=0;E<=S;E+=b)v.add(E);v.add(S)}else{let E=n.reduce((Q,T)=>Math.max(Q,String(T).length),1)*c*.6+c*.75,$=Math.max(1,Math.ceil(E/x));for(let Q=0;Q<n.length;Q++)Q%$!==0&&Q!==S||Q!==S&&S-Q<$||v.add(Q)}let k=w/Math.max(S,1);for(let b of v){let E=a.pointAligned?l.left+k*b:l.left+x*b+x/2,$=ct(a.abbreviateLabels?je(n[b],4):n[b]);f+=`<text data-x-label x="${E}" y="${e-h*.5}" text-anchor="middle" font-size="${c}">${$}</text>`}}}return{svg:f,chipSvg:p}}#at(t,e,i,n,r,o,a){let{chromeInset:l,chipFontSize:h,chipPadX:c,chipPadY:u,cornerClearance:d}=a,f=h*.6+u,p=h*1.2+u*2,m=t.map(S=>{let v=o.top+(r-o.top-o.bottom)*(1-(S-e[0])/i),k=Math.min(Math.max(v,l+f),r-l-f),E=k-f<=d||k+f>=r-d?d:l,$=this.#v(S),Q=String($).length*h*.6+c*2;return{cy:k,cx:E,rw:Q,text:$}});if(!m.length)return"";let g=m.length-1,O=[m[0]];for(let S=1;S<g;S++){let v=m[S],k=O[O.length-1];Math.abs(v.cy-k.cy)>=p&&O.push(v)}for(m.length>1&&O.push(m[g]);O.length>2;){let S=O[O.length-2],v=O[O.length-1];if(Math.abs(v.cy-S.cy)<p)O.splice(O.length-2,1);else break}if(O.length===2){let[S,v]=O;if(Math.abs(S.cy-v.cy)<p){let k=(S.cy+v.cy)/2,[b,E]=S.cy<=v.cy?[S,v]:[v,S];b.cy=Math.min(b.cy,k-p/2),E.cy=Math.max(E.cy,k+p/2)}}let w=O,x="";for(let S of w)x+=`<rect data-chip data-chip-axis="y" x="${S.cx}" y="${S.cy-p/2}" width="${S.rw}" height="${p}"/>`,x+=`<text data-chip-label data-chip-axis="y" x="${S.cx+c}" y="${S.cy}" dominant-baseline="central" font-size="${h}">${S.text}</text>`;return x}#it(t,e,i,n,r,o){let{chromeInset:a,bandGap:l,chipFontSize:h,chipPadX:c,chipPadY:u,cornerClearance:d}=r,f=e-n.left-n.right,p=t.length-1,m=o.pointAligned?f/Math.max(p,1):f/t.length,g=h*1.2+u*2,O=i-Math.max(a,l)-g/2,w=t.map((v,k)=>{let b=o.pointAligned?n.left+m*k:n.left+m*k+m/2,E=o.abbreviateLabels?je(v,4):v,$=ct(E),Q=String(E).length*h*.6+c*2;return{cx0:b,rw:Q,text:$}});if(!w.length)return"";for(let v of w)v.cx=Math.min(Math.max(v.cx0,a+v.rw/2),e-a-v.rw/2);w[0].cx=Math.max(w[0].cx,d+w[0].rw/2),w[p].cx=Math.min(w[p].cx,e-d-w[p].rw/2);let x=[w[0]];for(let v=1;v<w.length-1;v++){let k=w[v],b=x[x.length-1];k.cx-k.rw/2>=b.cx+b.rw/2&&x.push(k)}for(w.length>1&&x.push(w[p]);x.length>2;){let v=x[x.length-2],k=x[x.length-1];if(k.cx-k.rw/2<v.cx+v.rw/2)x.splice(x.length-2,1);else break}if(x.length===2){let[v,k]=x;if(v.cx+v.rw/2>k.cx-k.rw/2){let b=(v.cx+k.cx)/2;v.cx=Math.min(v.cx,b-v.rw/2),k.cx=Math.max(k.cx,b+k.rw/2)}}let S="";for(let v of x)S+=`<rect data-chip data-chip-axis="x" x="${v.cx-v.rw/2}" y="${O-g/2}" width="${v.rw}" height="${g}"/>`,S+=`<text data-chip-label data-chip-axis="x" x="${v.cx}" y="${O}" text-anchor="middle" dominant-baseline="central" font-size="${h}">${v.text}</text>`;return S}#V(){let t=this.x,e=this.#t;if(this.today){for(let i=0;i<e.length;i++)if(String(e[i]?.[t]??"")===String(this.today))return i;return-1}return e.findIndex(i=>i&&i.today)}#st(t,e,i){let n=i.sizeClass==="sm"?2.5:3.5,r=Math.max(6,i.fontSize),o=i.chipMode?-1:1,a=i.chipMode?e-Math.max(i.chromeInset??0,n):e;return`<circle data-today-dot cx="${t}" cy="${a}" r="${n}"/><line data-today-tick x1="${t}" y1="${a}" x2="${t}" y2="${a+o*r}"/>`}#lt(t,e,i){let n=i.sizeClass==="sm"?2.5:3.5,r=Math.max(6,i.fontSize);return`<circle data-today-dot cx="${e}" cy="${t}" r="${n}"/><line data-today-tick x1="${e}" y1="${t}" x2="${e-r}" y2="${t}"/>`}#K(t){return t&&t.provisional?" data-provisional":""}#ht(t,e,i,n,r){let o="",a=-1,l=h=>{if(a<0)return;let c=Math.max(a-1,0),u=t.slice(c,h);if(u.length>=2){let d=u[0].x,f=u[u.length-1].x,p=Math.min(...u.map(m=>m.y));o+=`<rect data-area-provisional-fade x="${d}" y="${p}" width="${Math.max(f-d,0)}" height="${Math.max(i-p,0)}"/>`,o+=`<path data-line-provisional d="${Ss(u,r)}"/>`}a=-1};for(let h=0;h<t.length;h++){let c=!!(e[h]&&e[h].provisional);c&&a<0?a=h:!c&&a>=0&&l(h)}return l(t.length),o}#ct(){let t=this.#O(),e=this.#t,i=this.#W()[0]||this.y,n=e.map(b=>+(b[i]??0)),r=e.map(b=>b[this.x]??""),o=n,a=t.ratioResolved==="1:1"&&n.length>Kb;a&&({labels:r,vals:n}=Gb(r,n,Kb,!1));let l=Yi(...this.#c(n),5),h=l[l.length-1],c=l[0];if(t.ratioResolved==="2:3")return this.#dt(t,r,n,l,h,a?[]:e);let{width:u,height:d,pad:f}=t,p=d-f.top-f.bottom,g=(u-f.left-f.right)/r.length,O=g*.6,w=(g-O)/2,{svg:x,chipSvg:S}=this.#tt(u,d,l,r,f,t,{abbreviateLabels:t.ratioResolved==="1:1"}),v=!this.noValues&&t.sizeClass!=="sm",k=!this.noAverage&&o.length>1&&t.sizeClass!=="sm"&&!this.noGrid;for(let b=0;b<r.length;b++){let E=n[b],$=h-c?(E-c)/(h-c)*p:0,Q=this.#h($,p),T=f.left+g*b+w,P=f.top+p-Q,L=a?"":this.#K(e[b]);x+=`<path data-bar${L}${at({label:r[b],value:E})} d="${mh(T,P,O,Q,this.#l())}"/>`,v&&(x+=`<text data-value x="${T+O/2}" y="${P-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#v(E)}</text>`)}if(k){let b=o.reduce((Q,T)=>Q+T,0)/o.length,E=h-c?(b-c)/(h-c)*p:0,$=f.top+p-this.#h(E,p);x+=`<line data-avg x1="${f.left}" y1="${$}" x2="${u-f.right}" y2="${$}"/>`,x+=`<text data-avg-label x="${u-f.right+2}" y="${$+3}" text-anchor="start" font-size="${t.valueSize}">${this.#v(b)}</text>`,x+=`<line data-hit${at({label:"Average",value:b})} x1="${f.left}" y1="${$}" x2="${u-f.right}" y2="${$}" stroke="transparent" stroke-width="12"/>`}if(!a){let b=this.#V();b>-1&&b<r.length&&(x+=this.#st(f.left+g*b+w+O/2,f.top+p,t))}return x+=S,{svg:x,viewBox:`0 0 ${u} ${d}`}}#dt(t,e,i,n,r,o=[]){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce(($,Q)=>Math.max($,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,O=(l-p.top-p.bottom)/e.length,w=O*.6,x=(O-w)/2,S="";if(!u){let $=n[n.length-1]-n[0]||1;for(let Q of n){let T=p.left+m*((Q-n[0])/$);S+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,S+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#v(Q)}</text>`}}let v=!this.noValues,k=!this.noAverage&&i.length>1&&!u,b=n[0];for(let $=0;$<e.length;$++){let Q=i[$],T=r-b?(Q-b)/(r-b)*m:0,P=this.#h(T,m),L=p.top+O*$+x,I=p.left,D=this.#K(o[$]);S+=`<text data-x-label x="${p.left-6}" y="${L+w/2+h*.35}" text-anchor="end" font-size="${c}">${ct(e[$])}</text>`,S+=`<path data-bar${D}${at({label:e[$],value:Q})} d="${Rd(I,L,P,w,this.#l())}"/>`,v&&(S+=`<text data-value x="${I+P+4}" y="${L+w/2+h*.35}" text-anchor="start" font-size="${t.valueSize}">${this.#v(Q)}</text>`)}if(k){let $=i.reduce((P,L)=>P+L,0)/i.length,Q=r-b?($-b)/(r-b)*m:0,T=p.left+this.#h(Q,m);S+=`<line data-avg x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,S+=`<line data-hit${at({label:"Average",value:$})} x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}" stroke="transparent" stroke-width="12"/>`}let E=this.#V();return E>-1&&E<e.length&&o.length&&(S+=this.#lt(p.top+O*E+x+w/2,p.left,t)),{svg:S,viewBox:`0 0 ${a} ${l}`}}#ut(){let t=this.#O(),e=this.#t,i=this.#W()[0]||this.y,n=e.map(P=>+(P[i]??0)),r=e.map(P=>P[this.x]??""),o=Yi(...this.#c(n),5),a=o[o.length-1],l=o[0],{width:h,height:c,pad:u}=t,d=c-u.top-u.bottom,p=(h-u.left-u.right)/Math.max(e.length-1,1),m=this.type==="area",g=t.ratioResolved,{svg:O,chipSvg:w}=this.#tt(h,c,o,r,u,t,{thinGrid:g!=="3:2",vertical:m&&g==="2:3",xTickMode:g==="2:3"?"sparse":g==="1:1"?"everyNth":void 0,pointAligned:!0}),x=n.map((P,L)=>{let I=u.left+p*L,D=u.top+d-(a-l?(P-l)/(a-l)*d:0),V=this.#u(D,u.top,u.top+d);return{x:I,y:V,v:P,label:r[L]}}),S=u.top+d,v=Math.max(0,Math.min(1,this.smooth));O+=`<path data-area d="${Md(x,S,v)}"/>`,O+=`<path data-line d="${Ss(x,v)}"/>`,O+=this.#ht(x,e,S,t,v);let k=t.sizeClass==="sm",b=k?1.5:3,E=Math.max(b,10),$=!this.noValues&&!k,Q=!this.noAverage&&n.length>1&&!k&&!this.noGrid;if(x.forEach((P,L)=>{let I=this.#K(e[L]);this.#ot(L,x.length)&&(O+=`<circle data-dot${I} cx="${P.x}" cy="${P.y}" r="${b}"/>`),O+=`<circle data-hit${at({label:P.label,value:P.v})} cx="${P.x}" cy="${P.y}" r="${E}" fill="transparent"/>`,$&&(O+=`<text data-value x="${P.x}" y="${P.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#v(P.v)}</text>`)}),Q){let P=n.reduce((D,V)=>D+V,0)/n.length,L=u.top+d-(a-l?(P-l)/(a-l)*d:0),I=this.#u(L,u.top,u.top+d);O+=`<line data-avg x1="${u.left}" y1="${I}" x2="${h-u.right}" y2="${I}"/>`,O+=`<text data-avg-label x="${h-u.right+2}" y="${I+3}" text-anchor="start" font-size="${t.valueSize}">${this.#v(P)}</text>`,O+=`<line data-hit${at({label:"Average",value:P})} x1="${u.left}" y1="${I}" x2="${h-u.right}" y2="${I}" stroke="transparent" stroke-width="12"/>`}let T=this.#V();return T>-1&&T<x.length&&(O+=this.#st(x[T].x,S,t)),O+=w,{svg:O,viewBox:`0 0 ${h} ${c}`}}#ft(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(P=>+(P[e]??0)),n=i.reduce((P,L)=>P+L,0)||1,r=t.map(P=>P[this.x]??""),o=this.#O(),{width:a,height:l,fontSize:h,valueSize:c}=o,u=o.ratioResolved,d=h,f=8,p=20,m=P=>(P+f)*c*.62+d+4,g=c*1.2+d+4,O=Math.max(0,a/2-p),w=Math.floor((O-d-4)/(c*.62))-f,x=r.reduce((P,L)=>Math.max(P,String(L).length),1),S=Math.max(4,Math.min(14,w,x)),v=m(S),k=u==="1:1"?Math.max(p,Math.min(a/2-v,l/2-g)):Math.max(30,Math.min(a,l)*.42),b=u==="3:2"?Math.max(k+8,a*.32):a/2,E=u==="2:3"?Math.min(l/2,k+h*1.5):l/2,$=u==="1:1",Q="",T=-Math.PI/2;for(let P=0;P<i.length;P++){let L=i[P]/n*Math.PI*2;if(L===0)continue;let I=T+L,D=(i[P]/n*100).toFixed(1),V=` data-slice="${P%10}"${at({label:r[P],value:i[P],pct:D})}`;if(Math.abs(L-Math.PI*2)<.001?Q+=`<circle${V} cx="${b}" cy="${E}" r="${k}"/>`:Q+=`<path${V} d="${gC(b,E,k,T,I)}"/>`,$){let H=T+L/2,G=Vt(b,k+d,H),K=_t(E,k+d,H),ot=Math.cos(H),pt=Math.abs(ot)<.15?"middle":ot>0?"start":"end",St=`${ct(je(r[P],S))} (${D}%)`;Q+=`<text data-ring-label x="${G}" y="${K}" text-anchor="${pt}" dominant-baseline="central" font-size="${c}">${St}</text>`}T=I}return this.#H=t.map((P,L)=>({label:r[L],value:i[L],pct:(i[L]/n*100).toFixed(1),slot:L%10})),{svg:Q,viewBox:`0 0 ${a} ${l}`}}#pt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(x=>+(x[e]??0)),n=i.reduce((x,S)=>x+S,0)||1,r=t.map(x=>x[this.x]??""),o=this.#O(),{width:a,height:l,fontSize:h}=o,c=o.ratioResolved,u=Math.max(30,Math.min(a,l)*(c==="1:1"?.46:.42)),d=u*.72,f=c==="3:2"?Math.max(u+8,a*.32):a/2,p=c==="2:3"?Math.min(l/2,u+h*1.5):l/2,m="",g=-Math.PI/2;for(let x=0;x<i.length;x++){let S=i[x]/n*Math.PI*2;if(S===0)continue;let v=g+S,k=(i[x]/n*100).toFixed(1),b=` data-slice="${x%10}"${at({label:r[x],value:i[x],pct:k})}`;Math.abs(S-Math.PI*2)<.001?(m+=`<circle${b} cx="${f}" cy="${p}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,m+=`<path${b} d="M ${f-u} ${p} A ${u} ${u} 0 1 1 ${f+u} ${p} A ${u} ${u} 0 1 1 ${f-u} ${p} Z M ${f-d} ${p} A ${d} ${d} 0 1 0 ${f+d} ${p} A ${d} ${d} 0 1 0 ${f-d} ${p} Z" fill-rule="evenodd"/>`):m+=`<path${b} d="${Ld(f,p,u,d,g,v,this.#l())}"/>`,g=v}let O=Math.max(14,Math.round(u*.32)),w=Math.max(9,Math.round(u*.16));return m+=`<text data-donut-total x="${f}" y="${p}" text-anchor="middle" dominant-baseline="central" font-size="${O}">${this.#v(n)}</text>`,m+=`<text data-donut-label x="${f}" y="${p+O}" text-anchor="middle" dominant-baseline="central" font-size="${w}">Total</text>`,this.#H=t.map((x,S)=>({label:r[S],value:i[S],pct:(i[S]/n*100).toFixed(1),slot:S%10})),{svg:m,viewBox:`0 0 ${a} ${l}`}}#mt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map($=>+($[e]??0)),n=t.map($=>$[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#O(),{width:l,height:h,fontSize:c}=a,u=a.ratioResolved,d=u==="1:1",f=u==="2:3",p=d?c*1.8:c*3.5,m=f?h*.6:h,g=l/2,O=f?m/2:h/2,w=Math.max(40,Math.min(l,m)/2-p),x="",S=Math.PI*2/o;for(let $=1;$<=3;$++){let Q=w*$/3,T="";for(let P=0;P<o;P++){let L=-Math.PI/2+S*P,I=g+Q*Math.cos(L),D=O+Q*Math.sin(L);T+=(P===0?"M":"L")+` ${I} ${D}`}T+=" Z",x+=`<path data-chart-grid d="${T}"/>`}for(let $=0;$<o;$++){let Q=-Math.PI/2+S*$,T=g+w*Math.cos(Q),P=O+w*Math.sin(Q);x+=`<line data-chart-grid x1="${g}" y1="${O}" x2="${T}" y2="${P}"/>`}let v="",k=[];for(let $=0;$<o;$++){let Q=-Math.PI/2+S*$,T=i[$]/r*w,P=g+T*Math.cos(Q),L=O+T*Math.sin(Q);v+=($===0?"M":"L")+` ${P} ${L}`,k.push({px:P,py:L})}v+=" Z",x+=`<path data-radar-fill d="${v}"/>`,x+=`<path data-radar-line d="${v}"/>`;let b=Math.max(c,10);for(let $=0;$<o;$++){let{px:Q,py:T}=k[$];x+=`<circle data-hit${at({label:n[$],value:i[$]})} cx="${Q}" cy="${T}" r="${b}" fill="transparent"/>`}let E=d?c*.6:c*1.3;for(let $=0;$<o;$++){let Q=-Math.PI/2+S*$,T=g+(w+E)*Math.cos(Q),P=O+(w+E)*Math.sin(Q),L=Math.abs(Math.cos(Q))<.1?"middle":Math.cos(Q)>0?"start":"end",I=ct(f?je(n[$],5):n[$]);x+=`<text data-x-label x="${T}" y="${P}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${I}</text>`}return{svg:x,viewBox:`0 0 ${l} ${h}`}}#gt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(O=>+(O[e]??0)),n=Yi(0,Math.max(...i),5),r=n[n.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(O=>O[this.x]??""),f=i.map((O,w)=>({x:c*w,y:h-(r?O/r*(h-u*2):0)-u,v:O,label:d[w]})),p=Math.max(0,Math.min(1,this.smooth)),m="";m+=`<path data-area d="${Md(f,h,p)}"/>`,m+=`<path data-line d="${Ss(f,p)}"/>`;let g=Math.max(c/2,6);for(let O of f)m+=`<circle data-hit${at({label:O.label,value:O.v})} cx="${O.x}" cy="${O.y}" r="${g}" fill="transparent"/>`;return{svg:m,viewBox:`0 0 ${l} ${h}`}}#Ot(){return this.#ut()}#bt(){let t=this.#O(),e=this.#t,i=this.#W()[0]||this.y,n=e.map(b=>+(b[i]??0)),r=e.map(b=>b[this.x]??""),o=t.ratioResolved,a=o==="2:3"?8:5,l=Yi(...this.#c(n),a),h=l[l.length-1],c=l[0],{width:u,height:d,pad:f}=t,p=d-f.top-f.bottom,g=(u-f.left-f.right)/Math.max(e.length-1,1),{svg:O,chipSvg:w}=this.#tt(u,d,l,r,f,t,{abbreviateLabels:o==="1:1"}),x=t.sizeClass==="sm"?2.5:4,S=o==="1:1"?x*.85:x,v=Math.max(S*2,10);for(let b=0;b<n.length;b++){let E=f.left+g*b,$=f.top+p-(h-c?(n[b]-c)/(h-c)*p:0),Q=this.#u($,f.top,f.top+p),T=this.#K(e[b]);O+=`<circle data-dot data-scatter${T} cx="${E}" cy="${Q}" r="${S}"/>`,O+=`<circle data-hit${at({label:r[b],value:n[b]})} cx="${E}" cy="${Q}" r="${v}" fill="transparent"/>`}let k=this.#V();return k>-1&&k<n.length&&(O+=this.#st(f.left+g*k,f.top+p,t)),O+=w,{svg:O,viewBox:`0 0 ${u} ${d}`}}#yt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(b=>+(b[e]??0)),n=t.map(b=>b[this.x]??""),r=Math.max(...i)||1,o=this.#O(),{width:a,height:l,fontSize:h,valueSize:c}=o,u=o.ratioResolved,d=a/2,f=l/2,p=Math.max(30,Math.min(a,l)*.45),m=p*.3,g=i.length||1,O=(p-m)/g,w=Math.min(2,O*.15),x=u==="1:1",S=u==="3:2"?0:-Math.PI/2,v=b=>x?-Math.PI/2+Math.PI*2*b/g:S,k="";for(let b=0;b<i.length;b++){let E=m+O*b+w/2,$=m+O*(b+1)-w/2,Q=(E+$)/2,T=$-E,P=2*Math.PI*Q,L=Math.max(0,Math.min(1,i[b]/r))*P,D=v(b)*180/Math.PI;if(k+=`<circle data-radial-track cx="${d}" cy="${f}" r="${Q}" fill="none" stroke-width="${T}"/>`,L<=0)continue;let V=(i[b]/r*100).toFixed(1),H=at({label:n[b],value:i[b],pct:V}),G=Math.abs(L-P)<.5,K=G?"butt":"round",ot=G?`${P} 0`:`${L} ${P-L}`;k+=`<circle data-slice="${b%10}"${H} data-radial-bar cx="${d}" cy="${f}" r="${Q}" fill="none" stroke-width="${T}" stroke-linecap="${K}" stroke-dasharray="${ot}" transform="rotate(${D} ${d} ${f})"/>`}if(x){let b=h;for(let E=0;E<i.length;E++){let $=v(E),Q=Vt(d,p+b,$),T=_t(f,p+b,$),P=Math.cos($),L=Math.abs(P)<.15?"middle":P>0?"start":"end";k+=`<text data-ring-label x="${Q}" y="${T}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${ct(n[E])}</text>`}}return this.#H=t.map((b,E)=>({label:n[E],key:n[E],value:i[E],pct:(i[E]/r*100).toFixed(1),slot:E%10})),{svg:k,viewBox:`0 0 ${a} ${l}`}}#vt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(Q=>+(Q[e]??0)),n=i.reduce((Q,T)=>Q+T,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#O(),{width:h,height:c,fontSize:u}=l,d=l.ratioResolved,f=d==="3:2",p=d==="2:3",m=Math.max(40,Math.min(h*(d==="1:1"?.48:.45),c*(p?.46:.6))),g=m*.72,O=(m-g)/2,w=f?Math.max(m+8,h*.34):h/2,x=p?Math.min(c*.5,m+u*1.3):c*.68,S="";if(S+=`<path data-radial-track d="${Ld(w,x,m,g,Math.PI,2*Math.PI,O)}"/>`,a>0){let Q=Math.PI+Math.PI*a,T=at({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});S+=`<path data-slice="0"${T} data-gauge-fill d="${Ld(w,x,m,g,Math.PI,Q,O)}"/>`}let v=Math.max(18,Math.round(m*.42)),k=Math.max(10,Math.round(m*.2)),b,E,$;return f?(b=w+m+u*1.2,E=x-m*.15,$="start"):p?(b=w,E=x+v*.7,$="middle"):(b=w,E=x-m*.15,$="middle"),S+=`<text data-gauge-value x="${b}" y="${E}" text-anchor="${$}" dominant-baseline="central" font-size="${v}">${this.#v(r)}</text>`,o!==r&&(S+=`<text data-gauge-max x="${b}" y="${E+v*.8}" text-anchor="${$}" dominant-baseline="central" font-size="${k}">of ${this.#v(o)}</text>`),{svg:S,viewBox:`0 0 ${h} ${c}`}}#xt(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(b=>+(b[e]??0)),n=t.map(b=>b[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#O(),{width:l,height:h}=a,c=a.fontSize,u=a.ratioResolved;this.#H=t.map((b,E)=>({label:n[E],value:i[E],pct:(i[E]/o*100).toFixed(1),slot:E%10}));let d="";if(u==="3:2"){let b=Math.max(h*.16,c*2.2),E=c*.8,$=l-E*2,Q=h-b*2,T=$/r,P=Math.max(2,T*.08),L=b+Q/2;for(let I=0;I<r;I++){let D=i[I],V=I<r-1?i[I+1]:i[I],H=D/o*(Q/2),G=V/o*(Q/2),K=E+T*I+P/2,ot=E+T*(I+1)-P/2,pt=(K+ot)/2,St=(D/o*100).toFixed(1),Lt=at({label:n[I],value:D,pct:St}),ce=`M ${K} ${L-H} L ${ot} ${L-G} L ${ot} ${L+G} L ${K} ${L+H} Z`;if(d+=`<path data-slice="${I%10}" data-funnel-stage${Lt} d="${ce}"/>`,d+=`<text data-funnel-label x="${pt}" y="${b-c*.6}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${c}">${ct(n[I])}</text>`,d+=`<text data-funnel-value x="${pt}" y="${h-b+c*1.3}" text-anchor="middle" dominant-baseline="hanging" font-size="${c}">${this.#v(D)}</text>`,I>0){let ue=(i[I]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${pt}" y="${h-b+c*2.5}" text-anchor="middle" dominant-baseline="hanging" font-size="${c*.85}">${ue}%</text>`}}return{svg:d,viewBox:`0 0 ${l} ${h}`}}let f=u==="1:1",p=u==="2:3",m=f||p?c*.8:Math.max(l*.18,80),g=p?Math.max(l*.3,c*6):Math.max(l*.18,80),O=c*.8,w=l-m-g,S=(h-O*2)/r,v=Math.max(2,S*.08),k=m+w/2;for(let b=0;b<r;b++){let E=i[b],$=b<r-1?i[b+1]:i[b],Q=E/o*(w/2),T=$/o*(w/2),P=O+S*b+v/2,L=O+S*(b+1)-v/2,I=P+S/2-v/2,D=(E/o*100).toFixed(1),V=at({label:n[b],value:E,pct:D}),H=`M ${k-Q} ${P} L ${k+Q} ${P} L ${k+T} ${L} L ${k-T} ${L} Z`;if(d+=`<path data-slice="${b%10}" data-funnel-stage${V} d="${H}"/>`,f){let G=(Q+T)/2,K=Math.floor((G*2-c)/(c*.6));K>=2&&(d+=`<text data-funnel-label data-funnel-label-inline x="${k}" y="${I}" text-anchor="middle" dominant-baseline="central" font-size="${c}">${ct(je(n[b],K))}</text>`)}else d+=`<text data-funnel-label x="${m-8}" y="${I}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ct(n[b])}</text>`;if(p){if(d+=`<text data-funnel-label data-funnel-label-right x="${l-g+8}" y="${I-c*.6}" text-anchor="start" dominant-baseline="central" font-size="${c}">${ct(n[b])}</text>`,d+=`<text data-funnel-value x="${l-g+8}" y="${I+c*.6}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#v(E)}</text>`,b>0){let G=(i[b]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${l-g+8}" y="${I+c*1.7}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${G}%</text>`}}else if(d+=`<text data-funnel-value x="${l-g+8}" y="${I}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#v(E)}</text>`,b>0){let G=(i[b]/i[0]*100).toFixed(0);d+=`<text data-funnel-drop x="${l-g+8}" y="${I+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${G}%</text>`}}return{svg:d,viewBox:`0 0 ${l} ${h}`}}#St(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#O(),{width:a,height:l,fontSize:h}=o,c=i.reduce((v,k)=>v+k,0)||1,u=o.ratioResolved,d=Array.from({length:r},(v,k)=>k).sort((v,k)=>i[k]-i[v]),f=u==="3:2"?Math.max(2,Math.ceil(Math.sqrt(r*2))):u==="2:3"?Math.max(1,Math.floor(Math.sqrt(r/2))):Math.max(1,Math.round(Math.sqrt(r))),p=[];for(let v=0;v<d.length;v+=f)p.push(d.slice(v,v+f));let m=p.map(v=>v.reduce((k,b)=>k+i[b],0)),g=m.reduce((v,k)=>v+k,0)||1,O=[],w=0;for(let v=0;v<p.length;v++){let k=m[v]/g*l,b=m[v]||1,E=0;for(let $ of p[v]){let Q=i[$]/b*a;O.push({i:$,x:E,y:w,w:Q,h:k}),E+=Q}w+=k}let x="",S=2;for(let v of O){let k=(i[v.i]/c*100).toFixed(1),b=at({label:n[v.i],value:i[v.i],pct:k});x+=`<rect data-slice="${v.i%10}" data-treemap-tile${b} x="${v.x+S}" y="${v.y+S}" width="${Math.max(0,v.w-S*2)}" height="${Math.max(0,v.h-S*2)}" rx="${this.#l()}"/>`;let E=v.x+8,$=v.w>h*4,Q=$&&v.h>h*2.5,T=$&&!Q&&v.h>h*1.2,P=u==="2:3"?8:20;if(Q)x+=`<text data-treemap-label x="${E}" y="${v.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ct(je(n[v.i],P))}</text>`,x+=`<text data-treemap-value x="${E}" y="${v.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#v(i[v.i])}</text>`;else if(T){let L=v.y+v.h/2;x+=`<text data-treemap-label x="${E}" y="${L}" font-size="${h}" dominant-baseline="central">${ct(je(n[v.i],P))}</text>`}}return this.#H=t.map((v,k)=>({label:n[k],value:i[k],pct:(i[k]/c*100).toFixed(1),slot:k%10})),{svg:x,viewBox:`0 0 ${a} ${l}`}}#wt(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let b of t){let E=b.source??b.from??"",$=b.target??b.to??"",Q=+(b.value??b.v??0);e.has(E)||e.set(E,{name:E,flow:0}),i.has($)||i.set($,{name:$,flow:0}),e.get(E).flow+=Q,i.get($).flow+=Q}let n=this.#O(),{width:r,height:o,fontSize:a}=n,l=n.ratioResolved,h=[...e.values()],c=[...i.values()],u=h.reduce((b,E)=>b+E.flow,0)||1,d=c.reduce((b,E)=>b+E.flow,0)||1,f="";if(l==="2:3"){let b=Math.max(8,o*.05),E=b+a*1.8,$=r*.5,Q=Math.min(a*.8,$/Math.max(1,Math.max(h.length,c.length)-1)),T=Math.max(1,r-Q*Math.max(0,h.length-1)),P=Math.max(1,r-Q*Math.max(0,c.length-1)),L=0;for(let D of h){let V=D.flow/u*T;D.x0=L,D.x1=L+V,D.cursor=L,L+=V+Q}L=0;for(let D of c){let V=D.flow/d*P;D.x0=L,D.x1=L+V,D.cursor=L,L+=V+Q}let I=Math.min(this.#l(),b/2);h.forEach((D,V)=>{let H=at({label:D.name,value:D.flow});f+=`<rect data-sankey-node data-slice="${V%10}"${H} x="${D.x0}" y="${E-b}" width="${D.x1-D.x0}" height="${b}" rx="${I}"/>`,f+=`<text data-sankey-label x="${(D.x0+D.x1)/2}" y="${E-b-6}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${a}">${ct(je(D.name,10))}</text>`}),c.forEach((D,V)=>{let H=at({label:D.name,value:D.flow});f+=`<rect data-sankey-node data-slice="${(h.length+V)%10}"${H} x="${D.x0}" y="${o-E}" width="${D.x1-D.x0}" height="${b}" rx="${I}"/>`,f+=`<text data-sankey-label x="${(D.x0+D.x1)/2}" y="${o-E+b+a+2}" text-anchor="middle" dominant-baseline="alphabetic" font-size="${a}">${ct(je(D.name,10))}</text>`});for(let D of t){let V=e.get(D.source??D.from??""),H=i.get(D.target??D.to??"");if(!V||!H)continue;let G=+(D.value??D.v??0);if(G<=0)continue;let K=G/u*T,ot=G/d*P,pt=V.cursor,St=pt+K,Lt=H.cursor,ce=Lt+ot;V.cursor+=K,H.cursor+=ot;let ue=E,Be=o-E,gs=(ue+Be)/2,YA=at({label:`${V.name} \u2192 ${H.name}`,value:G}),HA=`M ${pt} ${ue} C ${pt} ${gs}, ${Lt} ${gs}, ${Lt} ${Be} L ${ce} ${Be} C ${ce} ${gs}, ${St} ${gs}, ${St} ${ue} Z`;f+=`<path data-sankey-link${YA} d="${HA}"/>`}return{svg:f,viewBox:`0 0 ${r} ${o}`}}let p=l==="1:1",m=Math.max(8,r*.03),g=m+a*(p?2.2:5),O=p?6:24,w=a*.6,x=o-w*Math.max(0,h.length-1),S=o-w*Math.max(0,c.length-1),v=0;for(let b of h){let E=b.flow/u*x;b.y0=v,b.y1=v+E,b.cursor=v,v+=E+w}v=0;for(let b of c){let E=b.flow/d*S;b.y0=v,b.y1=v+E,b.cursor=v,v+=E+w}let k=Math.min(this.#l(),m/2);h.forEach((b,E)=>{let $=at({label:b.name,value:b.flow});f+=`<rect data-sankey-node data-slice="${E%10}"${$} x="${g-m}" y="${b.y0}" width="${m}" height="${b.y1-b.y0}" rx="${k}"/>`,f+=`<text data-sankey-label x="${g-m-6}" y="${(b.y0+b.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${ct(je(b.name,O))}</text>`}),c.forEach((b,E)=>{let $=at({label:b.name,value:b.flow});f+=`<rect data-sankey-node data-slice="${(h.length+E)%10}"${$} x="${r-g}" y="${b.y0}" width="${m}" height="${b.y1-b.y0}" rx="${k}"/>`,f+=`<text data-sankey-label x="${r-g+m+6}" y="${(b.y0+b.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${ct(je(b.name,O))}</text>`});for(let b of t){let E=e.get(b.source??b.from??""),$=i.get(b.target??b.to??"");if(!E||!$)continue;let Q=+(b.value??b.v??0);if(Q<=0)continue;let T=Q/u*x,P=Q/d*S,L=E.cursor,I=L+T,D=$.cursor,V=D+P;E.cursor+=T,$.cursor+=P;let H=g,G=r-g,K=(H+G)/2,ot=at({label:`${E.name} \u2192 ${$.name}`,value:Q}),pt=`M ${H} ${L} C ${K} ${L}, ${K} ${D}, ${G} ${D} L ${G} ${V} C ${K} ${V}, ${K} ${I}, ${H} ${I} Z`;f+=`<path data-sankey-link${ot} d="${pt}"/>`}return{svg:f,viewBox:`0 0 ${r} ${o}`}}#kt(){let t=this.#O(),e=this.#t,i=t.ratioResolved,n=this.#W(),r=n[0]||"bar",o=n[1]||"line",a=e.map($=>$[this.x]??""),l=e.map($=>+($[r]??0)),h=e.map($=>+($[o]??0)),c=[...l,...h],u=Yi(...this.#c(c),5),d=u[u.length-1],f=u[0],{width:p,height:m,pad:g}=t,O=m-g.top-g.bottom,w=p-g.left-g.right,x=w/e.length,S=x*.6,v=(x-S)/2,{svg:k,chipSvg:b}=this.#tt(p,m,u,a,g,t);if(!this.#k(r))for(let $=0;$<e.length;$++){let Q=l[$],T=d-f?(Q-f)/(d-f)*O:0,P=this.#h(T,O),L=g.left+x*$+v,I=g.top+O-P,D=this.#K(e[$]);k+=`<path${D}${this.#x(0,r)}${at({label:a[$],value:Q,series:r})} d="${mh(L,I,S,P,this.#l())}"/>`}if(!this.#k(o))if(i==="2:3"){let $=w*.34,Q=Math.min(O*.26,$*.6),T=g.left+w-$-2,P=g.top+2,L=Math.min(...h),D=Math.max(...h)-L||1,V=h.map((G,K)=>({x:T+(h.length>1?K/(h.length-1)*$:$/2),y:P+Q-(G-L)/D*Q,v:G,label:a[K]})),H=Math.max(0,Math.min(1,this.smooth));k+=`<rect data-composed-inset-bg x="${T-4}" y="${P-4}" width="${$+8}" height="${Q+8}" rx="${this.#l()}"/>`,k+=`<path data-composed-inset-line${this.#w(1,o)} d="${Ss(V,H)}"/>`;for(let G of V)k+=`<circle data-hit${at({label:G.label,value:G.v,series:o})} cx="${G.x}" cy="${G.y}" r="6" fill="transparent"/>`;k+=`<text data-composed-inset-label x="${T}" y="${P-6}" text-anchor="start" font-size="${t.valueSize}">${ct(o)}</text>`}else{let $=h.map((I,D)=>{let V=g.top+O-(d-f?(I-f)/(d-f)*O:0);return{x:g.left+x*D+x/2,y:this.#u(V,g.top,g.top+O),v:I,label:a[D]}}),Q=Math.max(0,Math.min(1,this.smooth)),T=i==="1:1",P=T?' data-slice="1" data-deemphasized-tint style="stroke: var(--md-sys-color-neutral-on-surface-variant)"':this.#w(1,o),L=T?' data-slice="1" data-deemphasized-tint style="fill: var(--md-sys-color-neutral-on-surface-variant)"':this.#x(1,o);k+=`<path data-line${P} d="${Ss($,Q)}"/>`,k+=this.#ht($,e,g.top+O,t,Q),$.forEach((I,D)=>{let V=this.#K(e[D]);k+=`<circle data-dot${L}${V} cx="${I.x}" cy="${I.y}" r="3"/>`,k+=`<circle data-hit${at({label:I.label,value:I.v,series:o})} cx="${I.x}" cy="${I.y}" r="10" fill="transparent"/>`})}let E=this.#V();return E>-1&&E<e.length&&(k+=this.#st(g.left+x*E+x/2,g.top+O,t)),this.#H=[{label:r,key:r,slot:0},{label:o,key:o,slot:1,deemphasized:i==="1:1"}],k+=b,{svg:k,viewBox:`0 0 ${p} ${m}`}}#At(){let t=this.#t,e=this.#W()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=i.reduce((g,O)=>g+O,0)||1,o=this.#O(),a=o.ratioResolved;if(a==="1:1"&&i.length>Jb&&({labels:n,vals:i}=Gb(n,i,Jb,!0)),this.#H=n.map((g,O)=>({label:g,value:i[O],pct:(i[O]/r*100).toFixed(1),slot:O%10})),a==="2:3")return this.#$t(o,n,i,r);let l=getComputedStyle(this),h=Math.max(40,this.clientWidth||200),c=24,u=Math.min(this.#l(),c/2),d=Math.max(0,parseFloat(l.getPropertyValue("--chart-segments-gap"))||2),f=[],p=0;for(let g=0;g<i.length;g++){let O=g===i.length-1?h:Math.round((p*r+i[g]*h)/r),w=g===i.length-1?h:i.slice(0,g+1).reduce((S,v)=>S+v,0)/r*h,x=g===0?0:i.slice(0,g).reduce((S,v)=>S+v,0)/r*h;f.push({x,w:Math.max(0,w-x)}),p=O}let m="";for(let g=0;g<f.length;g++){let{x:O,w}=f[g];if(w<=0)continue;let x=g===0,S=g===f.length-1,v=Math.max(0,w-(S?0:d)),k=(i[g]/r*100).toFixed(1),b=at({label:n[g],value:i[g],pct:k}),E=`<title>${ct(n[g])}: ${i[g]} (${k}%)</title>`;if(x&&S||!x&&!S||u===0)m+=`<rect data-slice="${g%10}"${b} x="${O}" y="0" width="${v}" height="${c}"${(x||S)&&u?` rx="${u}"`:""}>${E}</rect>`;else{let $=u,Q=O+v,T;x?T=`M ${O+$} 0 H ${Q} V ${c} H ${O+$} A ${$} ${$} 0 0 1 ${O} ${c-$} V ${$} A ${$} ${$} 0 0 1 ${O+$} 0 Z`:T=`M ${O} 0 H ${Q-$} A ${$} ${$} 0 0 1 ${Q} ${$} V ${c-$} A ${$} ${$} 0 0 1 ${Q-$} ${c} H ${O} Z`,m+=`<path data-slice="${g%10}"${b} d="${T}">${E}</path>`}}return{svg:m,viewBox:`0 0 ${h} ${c}`}}#$t(t,e,i,n){let o=Math.max(60,t.height),a=Math.min(this.#l(),24/2),l=getComputedStyle(this),h=Math.max(0,parseFloat(l.getPropertyValue("--chart-segments-gap"))||2),c=[];for(let d=0;d<i.length;d++){let f=d===i.length-1?o:i.slice(0,d+1).reduce((m,g)=>m+g,0)/n*o,p=d===0?0:i.slice(0,d).reduce((m,g)=>m+g,0)/n*o;c.push({y:p,h:Math.max(0,f-p)})}let u="";for(let d=0;d<c.length;d++){let{y:f,h:p}=c[d];if(p<=0)continue;let m=d===0,g=d===c.length-1,O=Math.max(0,p-(g?0:h)),w=(i[d]/n*100).toFixed(1),x=at({label:e[d],value:i[d],pct:w}),S=`<title>${ct(e[d])}: ${i[d]} (${w}%)</title>`;if(m&&g||!m&&!g||a===0)u+=`<rect data-slice="${d%10}"${x} x="0" y="${f}" width="24" height="${O}"${(m||g)&&a?` rx="${a}"`:""}>${S}</rect>`;else{let v=a,k=f+O,b;m?b=`M 0 ${f+v} A ${v} ${v} 0 0 1 ${v} ${f} H ${24-v} A ${v} ${v} 0 0 1 24 ${f+v} V ${k} H 0 Z`:b=`M 0 ${f} H 24 V ${k-v} A ${v} ${v} 0 0 1 ${24-v} ${k} H ${v} A ${v} ${v} 0 0 1 0 ${k-v} Z`,u+=`<path data-slice="${d%10}"${x} d="${b}">${S}</path>`}}return{svg:u,viewBox:`0 0 24 ${o}`}}#Ct(){let t=this.#t,e=this.#W(),i=t.map(b=>b[this.x]??""),n=t.map(b=>e.reduce((E,$)=>E+ +(b[$]??0),0)),r=Yi(...this.#c(n),5),o=r[r.length-1],a=r[0],l=this.#O(),h=l.ratioResolved;if(this.#H=e.map((b,E)=>({label:b,key:b,slot:E%10})),h==="2:3")return this.#Et(l,i,e,t,o,r);let{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/t.length,g=m*.6,O=(m-g)/2,{svg:w,chipSvg:x}=this.#tt(c,u,r,i,d,l,{abbreviateLabels:h==="1:1"}),S=o-a?f/(o-a):0,v=this.#u(d.top+f+a*S,d.top,d.top+f);for(let b=0;b<t.length;b++){let E=v,$=e.length;for(let Q=0;Q<$;Q++){if(this.#k(e[Q]))continue;let T=+(t[b][e[Q]]??0),P=T*S;if(P<=0){E=this.#u(E-P,d.top,d.top+f);continue}let L=Math.max(E-P,d.top),I=E-L,D=d.left+m*b+O,V=L;E=L;let H=Q===$-1,G=this.#l(),ot=`${this.#K(t[b])}${this.#x(Q%10,e[Q])}${at({label:i[b],value:T,series:e[Q]})}`;H?w+=`<path${ot} d="${mh(D,V,g,I,G)}"/>`:w+=`<rect${ot} x="${D}" y="${V}" width="${g}" height="${I}"/>`}}let k=this.#V();return k>-1&&k<t.length&&(w+=this.#st(d.left+m*k+m/2,d.top+f,l)),w+=x,{svg:w,viewBox:`0 0 ${c} ${u}`}}#Et(t,e,i,n,r,o){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce(($,Q)=>Math.max($,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,O=(l-p.top-p.bottom)/e.length,w=O*.6,x=(O-w)/2,S=o[0],v=r-S?m/(r-S):0,k=this.#u(p.left-S*v,p.left,p.left+m),b="";if(!u){let $=o[o.length-1]-o[0]||1;for(let Q of o){let T=p.left+m*((Q-o[0])/$);b+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,b+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#v(Q)}</text>`}}for(let $=0;$<e.length;$++){let Q=p.top+O*$+x;b+=`<text data-x-label x="${p.left-6}" y="${Q+w/2+h*.35}" text-anchor="end" font-size="${c}">${ct(e[$])}</text>`;let T=k,P=i.length;for(let L=0;L<P;L++){if(this.#k(i[L]))continue;let I=+(n[$][i[L]]??0),D=I*v;if(D<=0)continue;let V=T,H=Math.min(T+D,p.left+m),G=H-V;T=H;let K=L===P-1,pt=`${this.#K(n[$])}${this.#x(L%10,i[L])}${at({label:e[$],value:I,series:i[L]})}`;K?b+=`<path${pt} d="${Rd(V,Q,G,w,this.#l())}"/>`:b+=`<rect${pt} x="${V}" y="${Q}" width="${G}" height="${w}"/>`}}let E=this.#V();return E>-1&&E<e.length&&(b+=this.#lt(p.top+O*E+O/2,p.left,t)),{svg:b,viewBox:`0 0 ${a} ${l}`}}#Pt(){let t=this.#t,e=this.#W(),i=t.map(b=>b[this.x]??""),n=t.flatMap(b=>e.map(E=>+(b[E]??0))),r=Yi(...this.#c(n),5),o=r[r.length-1],a=r[0],l=this.#O(),h=l.ratioResolved;if(this.#H=e.map((b,E)=>({label:b,key:b,slot:E%10})),h==="2:3")return this.#Qt(l,i,e,t,o,r);let{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/t.length,g=3,O=m*.7,w=(O-g*(e.length-1))/e.length,x=(m-O)/2,{svg:S,chipSvg:v}=this.#tt(c,u,r,i,d,l,{abbreviateLabels:h==="1:1"});for(let b=0;b<t.length;b++){let E=this.#K(t[b]);for(let $=0;$<e.length;$++){if(this.#k(e[$]))continue;let Q=+(t[b][e[$]]??0),T=o-a?(Q-a)/(o-a)*f:0,P=this.#h(T,f),L=d.left+m*b+x+(w+g)*$,I=d.top+f-P;S+=`<path${E}${this.#x($%10,e[$])}${at({label:i[b],value:Q,series:e[$]})} d="${mh(L,I,w,P,this.#l())}"/>`,this.noValues||(S+=`<text data-value x="${L+w/2}" y="${I-4}" text-anchor="middle" font-size="${l.valueSize}">${this.#v(Q)}</text>`)}}let k=this.#V();return k>-1&&k<t.length&&(S+=this.#st(d.left+m*k+m/2,d.top+f,l)),S+=v,{svg:S,viewBox:`0 0 ${c} ${u}`}}#Qt(t,e,i,n,r,o){let{width:a,height:l}=t,h=t.fontSize,c=t.labelSize,u=this.noGrid,d=e.reduce(($,Q)=>Math.max($,String(Q).length),1),f=u?2:Math.min(a*.42,Math.max(h*3,d*c*.55+c)),p={top:h*.8,right:h*1.8,bottom:u?2:h*1.8,left:f},m=a-p.left-p.right,O=(l-p.top-p.bottom)/e.length,w=3,x=O*.7,S=(x-w*(i.length-1))/i.length,v=(O-x)/2,k=o[0],b="";if(!u){let $=o[o.length-1]-o[0]||1;for(let Q of o){let T=p.left+m*((Q-o[0])/$);b+=`<line data-chart-grid x1="${T}" y1="${p.top}" x2="${T}" y2="${l-p.bottom}"/>`,b+=`<text data-y-label x="${T}" y="${l-p.bottom+h*1.3}" text-anchor="middle" font-size="${h}">${this.#v(Q)}</text>`}}for(let $=0;$<e.length;$++){let Q=p.top+O*$,T=this.#K(n[$]);b+=`<text data-x-label x="${p.left-6}" y="${Q+O/2+h*.35}" text-anchor="end" font-size="${c}">${ct(e[$])}</text>`;for(let P=0;P<i.length;P++){if(this.#k(i[P]))continue;let L=+(n[$][i[P]]??0),I=r-k?(L-k)/(r-k)*m:0,D=this.#h(I,m),V=Q+v+(S+w)*P;b+=`<path${T}${this.#x(P%10,i[P])}${at({label:e[$],value:L,series:i[P]})} d="${Rd(p.left,V,D,S,this.#l())}"/>`,this.noValues||(b+=`<text data-value x="${p.left+D+4}" y="${V+S/2+h*.35}" text-anchor="start" font-size="${t.valueSize}">${this.#v(L)}</text>`)}}let E=this.#V();return E>-1&&E<e.length&&(b+=this.#lt(p.top+O*E+O/2,p.left,t)),{svg:b,viewBox:`0 0 ${a} ${l}`}}#Tt(){let t=this.#t,e=this.#W(),i=t.map(S=>S[this.x]??""),n=t.flatMap(S=>e.map(v=>+(S[v]??0))),r=Yi(...this.#c(n),5),o=r[r.length-1],a=r[0],l=this.#O(),h=l.ratioResolved,{width:c,height:u,pad:d}=l,f=u-d.top-d.bottom,m=(c-d.left-d.right)/Math.max(t.length-1,1),{svg:g,chipSvg:O}=this.#tt(c,u,r,i,d,l,{pointAligned:!0}),w=h==="3:2";for(let S=0;S<e.length;S++){if(this.#k(e[S]))continue;let k=t.map(P=>+(P[e[S]]??0)).map((P,L)=>{let I=d.left+m*L,D=d.top+f-(o-a?(P-a)/(o-a)*f:0),V=this.#u(D,d.top,d.top+f);return{x:I,y:V,v:P,label:i[L]}}),b=d.top+f,E=Math.max(0,Math.min(1,this.smooth)),$=this.seriesEmphasis,Q=!$||e[S]===$,T=Q?"":" data-deemphasized";if(Q&&(g+=`<path data-area${this.#x(S%10,e[S])} d="${Md(k,b,E)}"/>`),g+=`<path data-line${this.#w(S%10,e[S])}${T} d="${Ss(k,E)}"/>`,g+=this.#ht(k,t,b,l,E),k.forEach((P,L)=>{let I=this.#K(t[L]);this.#ot(L,k.length)&&(g+=`<circle data-dot${this.#x(S%10,e[S])}${T}${I} cx="${P.x}" cy="${P.y}" r="3"/>`),g+=`<circle data-hit${at({label:P.label,value:P.v,series:e[S]})} cx="${P.x}" cy="${P.y}" r="10" fill="transparent"/>`}),w&&k.length){let P=k[k.length-1];g+=`<text data-series-end-label${this.#x(S%10,e[S])} x="${P.x+6}" y="${P.y}" text-anchor="start" dominant-baseline="central" font-size="${l.labelSize}">${ct(e[S])}</text>`}}let x=this.#V();return x>-1&&x<t.length&&(g+=this.#st(d.left+m*x,d.top+f,l)),this.#H=e.map((S,v)=>({label:S,key:S,slot:v%10})),g+=O,{svg:g,viewBox:`0 0 ${c} ${u}`}}#H=null;get legendData(){return this.#H?this.#H.map(t=>({...t})):null}#Lt(){if(!this.#H||!this.#H.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#H){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.deemphasized?(n.setAttribute("data-deemphasized-tint",""),n.style.background="var(--md-sys-color-neutral-on-surface-variant)"):e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};M();A("chart-ui",Qr);X();var ey=new Set(["3:2","1:1","2:3"]),Tr=class s extends C{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},ratio:{type:String,default:"",reflect:!0},interactive:{type:Boolean,default:!0,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#a()}disconnected(){this.#n()}render(){this.#s(),this.#a()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#a(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(ey.has(this.ratio))return this.ratio;if(this.#t){let t=this.#t.getAttribute("data-ratio-resolved");if(ey.has(t))return t}return""}#o(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#a(){let t=this.#r();t?this.getAttribute("data-ratio-resolved")!==t&&this.setAttribute("data-ratio-resolved",t):this.hasAttribute("data-ratio-resolved")&&this.removeAttribute("data-ratio-resolved");let e=this.#o();if(this.innerHTML="",!!e.length)for(let i of e){let n=i.key??i.label??"",r=i.label??n,o=i.slot!=null?i.slot:0,a=!this.#i.has(n),l=document.createElement("badge-ui");l.setAttribute("data-row",""),l.setAttribute("role",this.interactive?"button":"listitem"),l.setAttribute("text",r),n&&l.setAttribute("data-key",n),a&&l.setAttribute("data-active",""),i.deemphasized&&l.setAttribute("data-deemphasized",""),this.interactive&&(l.setAttribute("tabindex","0"),l.setAttribute("aria-pressed",a?"true":"false"));let h=this.shape||"dot",c=document.createElement("swatch-ui");c.setAttribute("shape",h),c.setAttribute("size","sm");let u=i.deemphasized?"var(--md-sys-color-neutral-on-surface-variant)":n?`var(--color-${n}, var(--a-data-${o}))`:`var(--a-data-${o})`;c.style.setProperty("--swatch-color",u),l.appendChild(c),this.interactive&&(l.addEventListener("click",d=>this.#l(d,n)),l.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),this.#l(d,n))})),this.appendChild(l)}}#l(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};M();A("chart-legend-ui",Tr);X();var yC=120,Lr=class extends C{static properties={placement:{type:String,default:"bottom",reflect:!0},offset:{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;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#a),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#u),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#u))))}render(){this.open?this.#r():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=mt(t,e,{placement:this.placement,gap:this.offset,matchWidth:this.matchWidth}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#o(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#a=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#u=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},yC)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#o(),this.trigger==="click"&&this.removeEventListener("click",this.#a),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#u),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#u))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};M();A("popover-ui",Lr);X();var Mr=class extends C{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 n of i)n!==e&&n.open&&(n.open=!1)}},Rr=class extends C{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 n=document.createElement("icon-ui");n.setAttribute("name","caret-down"),n.setAttribute("slot","caret"),e.appendChild(n),this.prepend(e)}if(!this.querySelector('[slot="body"]')){let e=document.createElement("div");e.setAttribute("slot","body");let i=[...this.childNodes].filter(n=>n.nodeType===1?!n.hasAttribute("slot"):n.nodeType===3&&n.textContent.trim());for(let n of i)e.appendChild(n);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())}};M();A("accordion-ui",Mr),A("accordion-item-ui",Rr);X();var Ir=class extends C{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()}}};M();A("divider-ui",Ir);X();var Dr=class extends C{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()}};M();A("blockquote-ui",Dr);X();var Id=[{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}],Xr=class extends C{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),n=Id.find(o=>i<=o.limit)||Id[Id.length-1],r=Math.round(e/n.divisor);try{return new Intl.RelativeTimeFormat(this.#e(),{style:this.timeStyle,numeric:this.numeric}).format(r,n.unit)}catch{let o=e<0,a=Math.abs(r);return o?`${a} ${n.unit}${a===1?"":"s"} ago`:`in ${a} ${n.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.#n()}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.#n()}#n(){this.#r();let t=Number(this.updateInterval);!Number.isFinite(t)||t<=0||(this.#t=setInterval(()=>{this.textContent=this.#i()},t*1e3))}#r(){this.#t!=null&&(clearInterval(this.#t),this.#t=null)}disconnected(){super.disconnected(),this.#r()}};M();A("relative-time-ui",Xr);X();var qr=class extends C{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")}};M();A("number-format-ui",qr);X();var Dd=["Weak","Fair","Good","Strong"];function vC(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 Zr=class extends C{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=`
237
237
  <div slot="bar" aria-hidden="true">
238
238
  <div slot="segment" data-i="0"></div>
239
239
  <div slot="segment" data-i="1"></div>
@@ -247,9 +247,9 @@ Correct shape for <chart-ui x="label" y="value">:
247
247
  </svg>`}X();var zr=class extends C{static properties={value:{type:String,default:"",reflect:!0},matrix:{type:String,default:"",reflect:!0},size:{type:Number,default:200,reflect:!0},errorCorrection:{type:String,default:"M",reflect:!0,attribute:"error-correction"},quietZone:{type:Number,default:4,reflect:!0,attribute:"quiet-zone"},color:{type:String,default:"",reflect:!0},background:{type:String,default:"",reflect:!0},label:{type:String,default:"QR code",reflect:!0}};static template=()=>null;#t="";#e(t){if(!t)return null;try{let e=JSON.parse(t);return!Array.isArray(e)||e.length===0||!Array.isArray(e[0])?null:e.map(i=>i.map(n=>n?1:0))}catch(e){return console.warn("[qr-code-ui] invalid [matrix] JSON:",e.message),null}}#i(){let t=this.#e(this.matrix);if(t)return this.removeAttribute("error"),t;if(!this.value)return this.removeAttribute("error"),null;try{let e=hy(this.value,{errorCorrection:this.errorCorrection||"M"});return this.removeAttribute("error"),e.matrix}catch(e){return this.setAttribute("error",""),console.warn(`[qr-code-ui] encode failed for value (${this.value?.length||0} chars at ECC=${this.errorCorrection}): ${e.message}. Lower ECC, shorten input, or supply a precomputed [matrix].`),null}}connected(){super.connected(),this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.label||"QR code")}render(){let t=`${this.value}|${this.matrix}|${this.size}|${this.errorCorrection}|${this.quietZone}|${this.color}|${this.background}`;if(t===this.#t&&this.querySelector("svg"))return;this.#t=t,this.label&&this.setAttribute("aria-label",this.label);let e=this.#i();if(!e){this.innerHTML="";return}let i=cy(e,{cellSize:8,margin:Number.isFinite(this.quietZone)?this.quietZone:4,color:this.color||"#000000",background:this.background||"#ffffff"});this.innerHTML=i;let n=this.querySelector("svg");n&&Number.isFinite(this.size)&&(n.setAttribute("width",String(this.size)),n.setAttribute("height",String(this.size)))}};M();A("qr-code-ui",zr);X();ch();function xt(s,t,e){s.getAttribute(t)!==e&&s.setAttribute(t,e)}function Zd(s,t){s.hasAttribute(t)&&s.removeAttribute(t)}var Br=class extends C{static properties={page:{type:Number,default:1,reflect:!0},total:{type:Number,default:1,reflect:!0},siblings:{type:Number,default:1,reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0}};static requiredIcons=["caret-left","caret-right"];static template=()=>null;#t=null;#e=!1;connected(){this.#t||(this.#t=this.querySelector(':scope > nav[slot="nav"]'),this.#t?this.#s():(this.#t=document.createElement("nav"),this.#t.setAttribute("slot","nav"),this.#t.setAttribute("aria-label","Pagination"),this.appendChild(this.#t))),this.#e||(this.#e=!0,this.#t.addEventListener("press",this.#l))}disconnected(){this.#t?.removeEventListener("press",this.#l),this.#t=null,this.#e=!1}#i(t,e){return e.type==="ellipsis"?t.tagName==="SPAN"&&t.hasAttribute("data-ellipsis"):t.tagName!=="BUTTON-UI"?!1:e.type==="prev"?t.hasAttribute("data-prev"):e.type==="next"?t.hasAttribute("data-next"):t.hasAttribute("data-page")&&t.dataset.value===String(e.value)}#s(){let t=Math.max(1,Math.min(this.page,this.total)),e=Math.max(1,this.total),i=Math.max(0,this.siblings),n=this.#n(t,e,i),r=[...this.#t.children];if(!(r.length===n.length&&n.every((l,h)=>this.#i(r[h],l)))){this.#t.replaceChildren();return}let a=new Map;for(let l=0;l<n.length;l++)a.set(n[l].key,r[l]);this.#t[Fi]=a}render(){if(!this.#t)return;let t=Math.max(1,Math.min(this.page,this.total)),e=Math.max(1,this.total),i=Math.max(0,this.siblings),n=this.#n(t,e,i);this.reconcile(this.#t,n,r=>r.key,(r,o,a)=>a?(this.#a(a,r,t),a):this.#o(r,t))}#n(t,e,i){let n=[];n.push({key:"prev",type:"prev",value:t-1});let r=2*i+5;if(e<=r)for(let o=1;o<=e;o++)n.push({key:`page-${o}`,type:"page",value:o});else{let o=t<=i+3,a=t>=e-i-2;if(o){let l=r-2;for(let h=1;h<=l;h++)n.push({key:`page-${h}`,type:"page",value:h});n.push({key:"ellipsis-end",type:"ellipsis"}),n.push({key:`page-${e}`,type:"page",value:e})}else if(a){n.push({key:"page-1",type:"page",value:1}),n.push({key:"ellipsis-start",type:"ellipsis"});let l=e-r+3;for(let h=l;h<=e;h++)n.push({key:`page-${h}`,type:"page",value:h})}else{n.push({key:"page-1",type:"page",value:1}),n.push({key:"ellipsis-start",type:"ellipsis"});for(let l=t-i;l<=t+i;l++)n.push({key:`page-${l}`,type:"page",value:l});n.push({key:"ellipsis-end",type:"ellipsis"}),n.push({key:`page-${e}`,type:"page",value:e})}}return n.push({key:"next",type:"next",value:t+1}),n}#r(){return this.variant==="button"?"outline":"ghost"}#o(t,e){if(t.type==="ellipsis"){let n=document.createElement("span");return n.setAttribute("data-ellipsis",""),n.textContent="\u2026",n}let i=document.createElement("button-ui");return xt(i,"size",this.size),t.type==="prev"?(i.setAttribute("data-prev",""),xt(i,"icon","caret-left"),xt(i,"aria-label","Previous page")):t.type==="next"?(i.setAttribute("data-next",""),xt(i,"icon","caret-right"),xt(i,"aria-label","Next page")):(i.setAttribute("data-page",""),xt(i,"data-value",String(t.value)),xt(i,"text",String(t.value)),xt(i,"aria-label",`Page ${t.value}`)),this.#a(i,t,e),i}#a(t,e,i){e.type!=="ellipsis"&&(xt(t,"size",this.size),e.type==="prev"?(xt(t,"variant",this.#r()),i<=1?(xt(t,"disabled",""),xt(t,"tabindex","-1")):(Zd(t,"disabled"),xt(t,"tabindex","0"))):e.type==="next"?(xt(t,"variant",this.#r()),i>=this.total?(xt(t,"disabled",""),xt(t,"tabindex","-1")):(Zd(t,"disabled"),xt(t,"tabindex","0"))):(xt(t,"data-value",String(e.value)),xt(t,"text",String(e.value)),xt(t,"aria-label",`Page ${e.value}`),e.value===i?(xt(t,"variant","primary"),xt(t,"aria-current","page")):(xt(t,"variant",this.#r()),Zd(t,"aria-current"))))}#l=t=>{let e=t.target.closest("[data-prev], [data-next], [data-page]");if(!e||e.hasAttribute("disabled")||!this.#t.contains(e))return;let i;e.hasAttribute("data-prev")?i=this.page-1:e.hasAttribute("data-next")?i=this.page+1:e.hasAttribute("data-page")&&(i=Number(e.dataset.value)),!(i==null||i<1||i>this.total||i===this.page)&&(this.page=i,this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:this.page}})))}};M();A("pagination-ui",Br);X();var PI=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),QI={js:"javascript",md:"markdown",yml:"yaml"};function EO(s){if(!s)return"";let t=String(s).toLowerCase();return QI[t]??t}var Ao=class s extends C{static formAssociated=!0;static properties={language:{type:String,default:"",reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},text:{type:String,default:"",reflect:!0},lineNumbers:{type:Boolean,default:!1,reflect:!0,attribute:"line-numbers"},editable:{type:Boolean,default:!1,reflect:!0},bare:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=0;#n=!1;#r=null;#o="";#a=null;#l=()=>this.#S();connected(){this.#s+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#c(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#l);let t=EO(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(PI.has(t)||this.editable)&&this.#u()}disconnected(){this.#s+=1,this.#e!=null&&(clearTimeout(this.#e),this.#e=null),this.#t&&(this.#t.removeEventListener("click",this.#l),this.#t=null),this.#i&&(this.#i.destroy(),this.#i=null)}#c(){let t=this.querySelector(":scope > template"),e=this.text?this.text.trim():t?s.#h(t.innerHTML):(this.textContent||"").trim();if(this.textContent="",!this.bare){let l=document.createElement("header"),h=document.createElement("span");h.setAttribute("slot","label"),h.textContent=this.language||"code",l.appendChild(h);let c=document.createElement("div");c.setAttribute("role","button"),c.setAttribute("tabindex","0"),c.setAttribute("slot","copy"),c.textContent="Copy",l.appendChild(c),this.appendChild(l)}let i=document.createElement("pre"),n=document.createElement("code"),r=EO(this.language),o=this.getAttribute("data-line-states");if(o!=null||r==="diff"){n.setAttribute("data-line-state-mode",""),this.lineNumbers&&n.setAttribute("data-line-numbers","");let l=o?.split(",").map(c=>c.trim())??null;e.split(`
248
248
  `).forEach((c,u)=>{let d="unchanged";if(l&&l[u])d=l[u];else if(r==="diff"){let m=c.charAt(0);m==="+"?d="added":m==="-"&&(d="removed")}let f=document.createElement("span");if(f.setAttribute("data-line-state",d),this.lineNumbers){let m=document.createElement("span");m.setAttribute("data-line-num",""),m.textContent=String(u+1),f.appendChild(m)}let p=document.createElement("span");p.setAttribute("data-line-body",""),p.textContent=c,f.appendChild(p),n.appendChild(f)})}else n.textContent=e;i.appendChild(n),this.appendChild(i)}static#h(t){let e=t.replace(/^\n+|\n+$/g,"");if(!e)return"";let i=e.split(`
249
249
  `),n=i.filter(o=>o.trim().length>0).map(o=>o.match(/^[ \t]*/)[0].length),r=n.length?Math.min(...n):0;return r>0?i.map(o=>o.slice(r)).join(`
250
- `):e}async#u(){if(this.#n||this.#i)return;let t=this.#s,e=EO(this.language);this.#n=!0;try{let i=await Promise.resolve().then(()=>(CO(),$O)),n=null;try{n=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(r){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:r}}))}if(t!==this.#s||!this.isConnected)return;this.#d(i,n,e)}catch(i){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"core",error:i}})),console.warn("[code-ui] CodeMirror failed to load; staying on static fallback.",i)}finally{this.#n=!1}}#d(t,e,i){let{EditorState:n,EditorView:r,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:g,lintGutter:O,jsonLinter:w}=t,x=this.querySelector(":scope > pre"),S=x?x.querySelector("code")?.textContent??"":"",v=this.text||S||"";this.#o=v;let k=document.createElement("div");k.setAttribute("data-cm-mount",""),x?x.replaceWith(k):this.appendChild(k);let b=[m,h(g)];this.editable&&b.push(c(),p.of([{key:"Mod-s",run:E=>(this.#g(E),!0)},...d,...u,f]),r.updateListener.of(E=>{if(!E.docChanged)return;let $=E.state.doc.toString();this.#m($),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:$}}))}),r.domEventHandlers({focus:(E,$)=>(this.#r=$.state.doc.toString(),!1),blur:(E,$)=>{let Q=$.state.doc.toString();return this.#r!==null&&Q!==this.#r&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:Q}})),this.#r=null,!1}})),this.#a=new o,b.push(this.#a.of(this.#f(r,n))),e&&b.push(e),this.lineNumbers&&b.push(a()),this.placeholder&&b.push(l(this.placeholder)),this.editable&&i==="json"&&b.push(w,O()),this.#i=new r({parent:k,state:n.create({doc:v,extensions:b})}),this.editable&&this.#m(v)}#f(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#p(){if(!this.#i||!this.#a)return;let t=await Promise.resolve().then(()=>(CO(),$O));this.#i.dispatch({effects:this.#a.reconfigure(this.#f(t.EditorView,t.EditorState))})}get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}#m(t){this.editable&&(t=t??this.value??"",this.internals.setFormValue(t),this.#O(t))}#O(t){return t=t??"",this.required&&!t.trim()?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),this.setAttribute("aria-invalid","true"),!1):(this.internals.setValidity({}),this.removeAttribute("aria-invalid"),!0)}formResetCallback(){this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:this.#o}}):this.text=this.#o}formDisabledCallback(t){this.disabled=t}formStateRestoreCallback(t,e){typeof t=="string"&&(this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:t}}):this.text=t)}#g(t){this.dispatchEvent(new CustomEvent("save",{bubbles:!0,cancelable:!0,detail:{value:t.state.doc.toString()}}))}get value(){return this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??this.text??""}set value(t){this.text=String(t??"")}#S(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#p(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};M();A("code-ui",Ao);X();function Gk(s){let t=s.replace(/=""(?=[\s/>])/g,"").replace(/="([^"]*&quot;[^"]*)"/g,(o,a)=>{let l=a.replace(/&quot;/g,'"').replace(/&amp;/g,"&");return l.includes("'")?o:`='${l}'`}).replace(/\t/g," ").split(`
250
+ `):e}async#u(){if(this.#n||this.#i)return;let t=this.#s,e=EO(this.language);this.#n=!0;try{let i=await Promise.resolve().then(()=>(CO(),$O)),n=null;try{n=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(r){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:r}}))}if(t!==this.#s||!this.isConnected)return;this.#d(i,n,e)}catch(i){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"core",error:i}})),console.warn("[code-ui] CodeMirror failed to load; staying on static fallback.",i)}finally{this.#n=!1}}#d(t,e,i){let{EditorState:n,EditorView:r,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:g,lintGutter:O,jsonLinter:w}=t,x=this.querySelector(":scope > pre"),S=x?x.querySelector("code")?.textContent??"":"",v=this.text||S||"";this.#o=v;let k=document.createElement("div");k.setAttribute("data-cm-mount",""),x?x.replaceWith(k):this.appendChild(k);let b=[m,h(g)];this.editable&&b.push(c(),p.of([{key:"Mod-s",run:E=>(this.#O(E),!0)},...d,...u,f]),r.updateListener.of(E=>{if(!E.docChanged)return;let $=E.state.doc.toString();this.#m($),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:$}}))}),r.domEventHandlers({focus:(E,$)=>(this.#r=$.state.doc.toString(),!1),blur:(E,$)=>{let Q=$.state.doc.toString();return this.#r!==null&&Q!==this.#r&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:Q}})),this.#r=null,!1}})),this.#a=new o,b.push(this.#a.of(this.#f(r,n))),e&&b.push(e),this.lineNumbers&&b.push(a()),this.placeholder&&b.push(l(this.placeholder)),this.editable&&i==="json"&&b.push(w,O()),this.#i=new r({parent:k,state:n.create({doc:v,extensions:b})}),this.editable&&this.#m(v)}#f(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#p(){if(!this.#i||!this.#a)return;let t=await Promise.resolve().then(()=>(CO(),$O));this.#i.dispatch({effects:this.#a.reconfigure(this.#f(t.EditorView,t.EditorState))})}get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}#m(t){this.editable&&(t=t??this.value??"",this.internals.setFormValue(t),this.#g(t))}#g(t){return t=t??"",this.required&&!t.trim()?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),this.setAttribute("aria-invalid","true"),!1):(this.internals.setValidity({}),this.removeAttribute("aria-invalid"),!0)}formResetCallback(){this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:this.#o}}):this.text=this.#o}formDisabledCallback(t){this.disabled=t}formStateRestoreCallback(t,e){typeof t=="string"&&(this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:t}}):this.text=t)}#O(t){this.dispatchEvent(new CustomEvent("save",{bubbles:!0,cancelable:!0,detail:{value:t.state.doc.toString()}}))}get value(){return this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??this.text??""}set value(t){this.text=String(t??"")}#S(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#p(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};M();A("code-ui",Ao);X();function Gk(s){let t=s.replace(/=""(?=[\s/>])/g,"").replace(/="([^"]*&quot;[^"]*)"/g,(o,a)=>{let l=a.replace(/&quot;/g,'"').replace(/&amp;/g,"&");return l.includes("'")?o:`='${l}'`}).replace(/\t/g," ").split(`
251
251
  `);for(;t.length&&t[0].trim()==="";)t.shift();for(;t.length&&t[t.length-1].trim()==="";)t.pop();let e=o=>o.match(/^ */)[0].length,i=t.slice(1).filter(o=>o.trim()),n=(i.length?i:t.filter(o=>o.trim())).map(e),r=n.length?Math.min(...n):0;return t.map(o=>o.slice(Math.min(r,e(o)))).join(`
252
- `)}var $o=class extends C{static properties={layout:{type:String,default:"",reflect:!0},codeFirst:{type:Boolean,default:!1,reflect:!0,attribute:"code-first"},language:{type:String,default:"html",reflect:!0},rows:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e(t,e,i){let n=document.createElement("div");n.setAttribute("data-preview-render",""),n.innerHTML=t;let r=document.createElement("div");r.setAttribute("data-preview-code","");let o=document.createElement("code-ui");return o.setAttribute("language",e),o.textContent=t.replace(/\s+data-chunk(?:-[a-z]+)?="[^"]*"/g,""),r.appendChild(o),i?[r,n]:[n,r]}connected(){if(this.querySelector(":scope > [data-preview-render], :scope > [data-preview-row]"))return;!this.hasAttribute("rows")&&!this.hasAttribute("layout")&&this.setAttribute("layout","split");let t=this.getAttribute("language")||"html",e=this.hasAttribute("code-first");if(this.hasAttribute("rows")){let n=[...this.children],r=[];for(let o of n){let a=o.getAttribute("data-preview-label");a!=null&&o.removeAttribute("data-preview-label");let l=o.hasAttribute("data-preview-unwrap");l&&o.removeAttribute("data-preview-unwrap");let h=Gk(l?o.innerHTML:o.outerHTML),c=document.createElement("div");c.setAttribute("data-preview-row","");let u=this.#e(h,t,e);a&&u.find(f=>f.hasAttribute("data-preview-render"))?.setAttribute("data-preview-label",a),c.append(...u),r.push(c)}if(r.length){this.replaceChildren(...r),this.#n();return}}let i=Gk(this.innerHTML);this.replaceChildren(...this.#e(i,t,e)),this.#n()}#i=()=>{if(this.hasAttribute("rows"))for(let t of this.querySelectorAll(":scope > [data-preview-row]")){let e=t.querySelector(":scope > [data-preview-render]");e&&e.scrollWidth>e.clientWidth+4&&t.setAttribute("data-stack","")}else if(this.getAttribute("layout")==="split"){let t=this.querySelector(":scope > [data-preview-render]");t&&t.scrollWidth>t.clientWidth+4&&this.setAttribute("layout","stack")}};#s=()=>{typeof requestAnimationFrame=="function"&&requestAnimationFrame(this.#i)};#n(){this.#s(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(this.#s),this.#t.observe(this))}disconnected(){this.#t?.disconnect()}};M();A("preview-ui",$o);X();var Co=class extends C{static properties={divider:{type:Boolean,default:!1,reflect:!0},spacing:{type:String,default:"md",reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},selectedKey:{type:String,default:"",reflect:!0,attribute:"selected-key"}};static template=()=>null;#t=!1;#e=!1;connected(){this.hasAttribute("role")||this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#r),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#r),this.removeEventListener("keydown",this.#o),this.#t=!1}render(){if(!this.selectable){if(this.#e){for(let n of this.#i())n.removeAttribute("selected"),n.removeAttribute("aria-selected"),n.removeAttribute("tabindex");this.#e=!1}return}this.#e=!0;let t=this.selectedKey||"",e=this.#i(),i=null;for(let n of e){let r=this.#s(n),o=r&&r===t;o?n.setAttribute("selected",""):n.removeAttribute("selected"),n.setAttribute("aria-selected",o?"true":"false"),n.setAttribute("tabindex",o?"0":"-1"),o&&(i=n)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#i(){return[...this.children].filter(t=>t.tagName==="LIST-ITEM-UI"||t.getAttribute?.("role")==="listitem")}#s(t){return t.id||t.getAttribute("data-key")||""}#n(t,{focus:e=!1}={}){if(!this.selectable||!t)return;let i=this.selectedKey||"";t!==i&&(this.selectedKey=t,this.dispatchEvent(new CustomEvent("selection-change",{detail:{key:t,previousKey:i},bubbles:!0})),e&&[...this.#i()].find(r=>this.#s(r)===t)?.focus?.())}#r=t=>{if(!this.selectable)return;let e=t.target.closest?.('list-item-ui, [role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#s(e);i&&this.#n(i)};#o=t=>{if(!this.selectable)return;let e=this.#i();if(!e.length)return;let i=document.activeElement,n=e.indexOf(i);if(n<0)return;let r=n;switch(t.key){case"ArrowDown":r=Math.min(e.length-1,n+1);break;case"ArrowUp":r=Math.max(0,n-1);break;case"Home":r=0;break;case"End":r=e.length-1;break;case"Enter":case" ":{t.preventDefault();let o=this.#s(e[n]);o&&this.#n(o);return}default:return}r!==n&&(t.preventDefault(),e[r]?.focus?.())}},Eo=class extends C{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.#s()}#t(t){for(let e of this.children)if(e.matches(t))return e;return null}#e(t){return t.dataset.listStamped="1",t}#i(t){return t?.dataset?.listStamped==="1"}#s(){if(!this.#t('[slot="content"]')){if(this.icon){let t=this.#t('[slot="icon"]')||this.#t("icon-ui");t||(t=this.#e(document.createElement("icon-ui")),t.setAttribute("slot","icon"),this.prepend(t)),t.setAttribute("name",this.icon)}if(this.text){let t=this.#t('[slot="text"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","text"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.text)}if(this.description){let t=this.#t('[slot="description"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","description"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.description)}}}render(){if(this.#t('[slot="content"]'))return;let t=this.#t('[slot="icon"]');if(this.icon)if(t)this.#i(t)&&t.setAttribute("name",this.icon);else{let n=this.#e(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#i(t)&&t.remove();let e=this.#t('[slot="text"]');if(this.text)if(e)this.#i(e)&&(e.textContent=this.text);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","text"),n.textContent=this.text,this.appendChild(n)}else this.#i(e)&&e.remove();let i=this.#t('[slot="description"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","description"),n.textContent=this.description,this.appendChild(n)}else this.#i(i)&&i.remove()}};M();A("list-ui",Co),A("list-item-ui",Eo);X();Ge();var Po=class extends C{static properties={items:{type:Array,default:[],reflect:!1},itemSize:{type:Number,default:0,reflect:!0,attribute:"item-size"},itemSizeRem:{type:Number,default:0,reflect:!0,attribute:"item-size-rem"},estimatedSize:{type:Number,default:48,reflect:!0,attribute:"estimated-size"},overscan:{type:Number,default:3,reflect:!0},direction:{type:String,default:"vertical",reflect:!0},pinBottom:{type:Boolean,default:!1,reflect:!0,attribute:"pin-bottom"},startIndex:{type:Number,default:0,reflect:!1,attribute:"start-index"},loading:{type:Boolean,default:!1,reflect:!0}};static parts={phantom:"<div data-phantom></div>",window:"<div data-window></div>",sentinelTop:'<div data-sentinel="top"></div>',sentinelBottom:'<div data-sentinel="bottom"></div>'};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=(t,e)=>t&&typeof t=="object"&&"id"in t?t.id:e;#o=new Map;#a=new Map;#l=1e5;#c=-1;#h=-1;#u=0;#d=!0;#f=null;#p=null;#m=()=>{this.#E();let t=this.#P();this.#u=t,this.#d=this.#y()};#O=t=>{let e=t.target.closest?.("[data-row]");if(!e||e.parentElement!==this.#e)return;let i=Number(e.dataset.index);if(!Number.isInteger(i)||i<0)return;let n=this.items?.[i];n!=null&&this.dispatchEvent(new CustomEvent("item-click",{detail:{item:n,index:i},bubbles:!0}))};#g=t=>{if(t.target!==this)return;let e=this.#x()||this.estimatedSize||48,i=this.#C(),n=0;switch(t.key){case"ArrowDown":n=+e;break;case"ArrowUp":n=-e;break;case"PageDown":n=+i;break;case"PageUp":n=-i;break;case" ":n=+i;break;case"Home":t.preventDefault(),this.scrollToTop();return;case"End":t.preventDefault(),this.scrollToBottom();return;default:return}t.preventDefault();let r=this.#P();this.#k(r+n)};#S=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let n=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:n},bubbles:!0}))}else if(i==="bottom"){let n=this.items||[],r=this.#h>=0?this.#h:n.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:r},bubbles:!0}))}}};#v=t=>{if(this.itemSize>0)return;let e=!1;for(let i of t){let n=i.target;if(!n||n.parentElement!==this.#e)continue;let r=Number(n.dataset.index);if(!Number.isInteger(r))continue;let o=this.direction==="horizontal"?i.contentRect.width:i.contentRect.height,a=Math.max(1,Math.round(o));this.#a.get(r)!==a&&(this.#a.set(r,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:r,height:a},bubbles:!0})),e=!0)}e&&(this.#X(),this.#A(),this.#E())};connected(){this.setAttribute("role",this.getAttribute("role")||"list"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t=this.ensure("phantom"),this.#e=this.ensure("window"),this.#i=this.ensure("sentinelTop"),this.#s=this.ensure("sentinelBottom"),typeof IntersectionObserver<"u"&&(this.#p=new IntersectionObserver(this.#S,{root:this,rootMargin:"0px",threshold:0}),this.#p.observe(this.#i),this.#p.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#f=new ResizeObserver(this.#v)),this.addEventListener("scroll",this.#m,{passive:!0}),this.addEventListener("click",this.#O),this.addEventListener("keydown",this.#g),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#O),this.removeEventListener("keydown",this.#g),this.#p?.disconnect(),this.#p=null,this.#f?.disconnect(),this.#f=null,this.#o.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#d||this.#y());t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.setAttribute("aria-rowcount",String(t.length)),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.#A(),this.#E(),e&&this.scrollToBottom(),this.#d=this.#y()}set renderRow(t){this.#n=typeof t=="function"?t:null,this.#o.clear(),this.#E()}get renderRow(){return this.#n}set keyFn(t){this.#r=typeof t=="function"?t:((e,i)=>i),this.#o.clear(),this.#E()}get keyFn(){return this.#r}scrollToIndex(t,{behavior:e="auto",align:i="start"}={}){let n=this.items||[];if(!n.length)return;let r=Math.max(0,Math.min(n.length-1,t|0)),o=this.#b(r),a=this.#C(),l=this.#w(r),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#k(Math.max(0,h),e)}scrollToTop(){this.#k(0)}scrollToBottom(){let t=this.#$();this.#k(Math.max(0,t))}getVisibleRange(){return{startIndex:this.#c,endIndex:this.#h}}invalidateMeasurements(t=0){if(t<=0)this.#a.clear();else for(let e of[...this.#a.keys()])e>=t&&this.#a.delete(e);this.#A(),this.#E()}#x(){if(this.itemSize>0)return this.itemSize;if(this.itemSizeRem>0){let t=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return this.itemSizeRem*t}return 0}#w(t){let e=this.#x();if(e>0)return e;let i=this.#a.get(t);return i??(this.estimatedSize||48)}#b(t){let e=this.#x();if(e>0)return t*e;let i=0;for(let n=0;n<t;n++)i+=this.#w(n);return i}#$(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#x();if(i>0)return e*i;let n=0,r=this.estimatedSize||48;for(let o=0;o<e;o++)n+=this.#a.get(o)??r;return n}#C(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#P(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#k(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#y(){let t=this.#P(),e=this.#C(),i=this.#$();return t+e>=i-1}#A(){if(!this.#t)return;let t=this.#$();this.direction==="horizontal"?(this.#t.style.width=`${t}px`,this.#t.style.height="1px"):(this.#t.style.height=`${t}px`,this.#t.style.width="1px")}#T(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#C(),n=this.#P(),r=this.#x(),o,a;if(r>0)o=Math.floor(n/r),a=Math.ceil((n+i)/r);else{let h=this.estimatedSize||48,c=0;o=0;for(let d=0;d<e;d++){let f=this.#a.get(d)??h;if(c+f>n){o=d;break}c+=f}a=o;let u=0;for(let d=o;d<e;d++){let f=this.#a.get(d)??h;if(u+=f,a=d+1,u>=i)break}}let l=Math.max(0,this.overscan|0);return o=Math.max(0,o-l),a=Math.min(e,a+l),{start:o,end:a}}#E(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=t.length,{start:i,end:n}=this.#T(),r=this.#b(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${r}px)`:this.#e.style.transform=`translateY(${r}px)`,this.loading?this.#Q(n-i):this.#L(t,i,n),(i!==this.#c||n!==this.#h)&&(this.#c=i,this.#h=n,this.dispatchEvent(new CustomEvent("range-change",{detail:{startIndex:i,endIndex:n,items:t.slice(i,n)},bubbles:!0})))}#L(t,e,i){if(!this.#e)return;let n=new Set,r=this.#n??this.#I();for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l);n.add(c);let u=this.#o.get(c);u?(u.dataset.index=String(l),u.setAttribute("aria-rowindex",String(l+1))):(u=this.#M(h,l,r),this.#o.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l),u=this.#o.get(c);u&&o.push(u)}for(let[l,h]of this.#o)n.has(l)||(this.#f?.unobserve(h),h.parentElement===this.#e&&h.remove(),this.#o.delete(l));let a=this.#e.firstChild;for(let l of o)l!==a&&this.#e.insertBefore(l,a),a=l.nextSibling;for(;a;){let l=a.nextSibling;a.remove(),a=l}if(this.itemSize<=0&&this.itemSizeRem<=0&&this.#f)for(let l of o)this.#f.observe(l)}#Q(t){if(!this.#e)return;this.#e.replaceChildren(),this.#o.clear();let e=Math.max(1,Math.min(20,t|0||5)),i=this.querySelector(':scope > template[slot="loading"]');for(let n=0;n<e;n++){let r=document.createElement("div");if(r.setAttribute("data-row",""),r.setAttribute("data-skeleton-row",""),r.dataset.index=String(n),i?.content)r.appendChild(i.content.cloneNode(!0));else{let o=document.createElement("skeleton-ui");r.appendChild(o)}this.#e.appendChild(r)}}#M(t,e,i){let n=document.createElement("div");n.setAttribute("data-row",""),n.setAttribute("role","listitem"),n.dataset.index=String(e),n.setAttribute("aria-rowindex",String(e+1));let r=null;if(typeof i=="function")try{r=i(t,e)}catch(o){console.warn("[list-window-ui] render() threw:",o)}if(Wi(r))n.appendChild(r);else if(r!=null)n.textContent=String(r);else if(t!=null&&typeof t=="object"&&"text"in t){let o=document.createElement("list-item-ui");o.setAttribute("text",String(t.text)),"description"in t&&o.setAttribute("description",String(t.description)),"icon"in t&&o.setAttribute("icon",String(t.icon)),n.appendChild(o)}else t!=null&&(n.textContent=String(t));return n}#I(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#R==null&&(this.#R=t.innerHTML);let e=this.#R;return(i,n)=>{let r=e.replace(/\$\{item\.([a-zA-Z0-9_]+)\}/g,(a,l)=>{let h=i&&typeof i=="object"?i[l]:"";return h==null?"":TI(String(h))}),o=document.createElement("template");return o.innerHTML=r,o.content.cloneNode(!0)}}#R=null;#X(){if(this.#a.size<=this.#l)return;let t=this.#a.size-this.#l,e=0;for(let i of this.#a.keys())if(this.#a.delete(i),++e>=t)break}};function TI(s){return s.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}M();A("list-window-ui",Po);X();var Qo=class extends C{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},offset:{type:Number,default:4,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=null;#n=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#f))}render(){this.open?this.#o():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){if(this.#e)return this.#e;let t=document.createElement("div");return t.setAttribute("data-menu-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.addEventListener("toggle",this.#S),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#o(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#r(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui, menu-label-ui");for(let n of i)e.contains(n)||e.appendChild(n);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=mt(t,e,{placement:this.placement,gap:this.offset}),this.#u&&(this.#u=!1,this.#n=requestAnimationFrame(()=>{this.#n=null,this.#c(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#O),document.addEventListener("keydown",this.#g,!0)})}#a(){this.#t?.(),this.#t=null;let t=this.#e;if(t){t.matches(":popover-open")&&t.hidePopover?.();let e=t.querySelectorAll("menu-item-ui, menu-divider-ui, menu-label-ui");for(let i of e)this.insertBefore(i,t)}this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#O),document.removeEventListener("keydown",this.#g,!0)}#l(){return Array.from(this.#e?.querySelectorAll("menu-item-ui")??[]).filter(t=>!t.disabled)}#c(t){let e=this.#l();if(!e.length)return;let i=(t+e.length)%e.length,n=e[i];n.setAttribute("tabindex","-1"),n.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#u=!1;#d=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#u=!1,this.open=!this.open)};#f=t=>{let e=this.querySelector('[slot="trigger"]');!e||!(t.target===e||e.contains(t.target))||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#u=!0,this.open=!0)};#p=t=>{let e=t.target.closest("menu-item-ui");!e||e.disabled||(this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.value,text:e.text}})),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0}))};#m=t=>{let e=this.#l();if(!e.length)return;let i=this.#h();switch(t.key){case"ArrowDown":t.preventDefault(),this.#c(i+1);break;case"ArrowUp":t.preventDefault(),this.#c(i-1);break;case"Home":t.preventDefault(),this.#c(0);break;case"End":t.preventDefault(),this.#c(e.length-1);break;case"Enter":case" ":{t.preventDefault(),(e[i]??e[0])?.click();break}}};#O=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#g=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#S=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#a(),this.#e&&(this.#e.removeEventListener("toggle",this.#S),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},To=class extends C{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.hasAttribute("role")&&!this.#t||(this.closest('[role="menu"], [role="menubar"]')?(this.setAttribute("role","menuitem"),this.#t=!0,this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")):(this.removeAttribute("role"),this.removeAttribute("tabindex"),this.#t=!1)),this.#n(),this.#r()}#e(t){return t.dataset.menuItemStamped="1",t}#i(t){return t?.dataset?.menuItemStamped==="1"}#s(t){for(let e of this.children)if(e.matches(t))return e;return null}#n(){if(!this.#s('[slot="text"]')){if(this.icon&&!this.#s('[slot="icon"]')){let t=this.#e(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#e(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}if(this.description&&!this.#s('[slot="subtitle"]')){let t=this.#e(document.createElement("span"));t.setAttribute("slot","subtitle"),t.textContent=this.description,this.appendChild(t)}}}#r(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#s('[slot="icon"]');if(this.icon)if(t)this.#i(t)&&t.setAttribute("name",this.icon);else{let n=this.#e(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#i(t)&&t.remove();let e=this.#s('[slot="text"]');this.#i(e)&&(e.textContent=this.text);let i=this.#s('[slot="subtitle"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","subtitle"),n.textContent=this.description,this.appendChild(n)}else this.#i(i)&&i.remove();this.#r()}},Lo=class extends C{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}},Fl=class extends C{static properties={text:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation"),this.#t()}#t(){if(!this.querySelector(':scope > [slot="text"]')&&this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.dataset.menuLabelStamped="1",t.textContent=this.text,this.appendChild(t)}}render(){let t=this.querySelector(':scope > [slot="text"]');t?.dataset.menuLabelStamped==="1"&&(t.textContent=this.text)}};M();A("menu-ui",Qo),A("menu-item-ui",To),A("menu-divider-ui",Lo),A("menu-label-ui",Fl);X();var Kk=500,Jk=new WeakSet,Mo=class extends C{static properties={targetSelector:{type:String,default:"",reflect:!0,attribute:"target-selector"},for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:Kk,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#n=null;#r=null;#o=null;#a=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#w(),this.#t?.remove(),this.#t=null}openAt(t,e,i=null){if(i??=this.#s[0]??null,!!i){if(this.#r=i,t==null||e==null){let n=i.getBoundingClientRect();t=n.left+n.width/2,e=n.top+n.height/2}this.#v(t,e)}}close(t="manual"){this.#x(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#d),t.addEventListener("touchstart",this.#f,{passive:!0}),t.addEventListener("touchend",this.#p),t.addEventListener("touchcancel",this.#p),t.addEventListener("keydown",this.#m)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#d),t.removeEventListener("touchstart",this.#f),t.removeEventListener("touchend",this.#p),t.removeEventListener("touchcancel",this.#p),t.removeEventListener("keydown",this.#m);this.#s=[]}#h(){let t=this.targetSelector||this.#u();if(t)try{return[...document.querySelectorAll(t)]}catch(e){return console.warn(`[context-menu-ui] invalid [target-selector] selector: ${t}`,e),[]}for(let e of this.children){let i=e.tagName.toLowerCase();if(i!=="menu-item-ui"&&i!=="menu-divider-ui")return[e]}return[]}#u(){return this.for?(Jk.has(this)||(Jk.add(this),console.warn(`[context-menu-ui] [for="${this.for}"] is deprecated \u2014 use [target-selector="${this.for}"] instead. [for] now means an id-ref everywhere else in AdiaUI; context-menu-ui's own prior [for] carried a CSS-selector meaning (ADR-0079).`)),this.for):""}#d=t=>{t.defaultPrevented||this.#O()&&(t.preventDefault(),this.#r=t.currentTarget,this.#v(t.clientX,t.clientY))};#f=t=>{if(!this.#O())return;let e=t.touches[0];e&&(this.#n=setTimeout(()=>{this.#r=t.currentTarget,this.#v(e.clientX,e.clientY)},this.longPressMs??Kk))};#p=()=>{this.#n&&clearTimeout(this.#n),this.#n=null};#m=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#O())return;t.preventDefault(),this.#r=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#O(){return[...this.children].some(t=>t.tagName.toLowerCase()==="menu-item-ui")}#g(){if(this.#t)return this.#t;let t=document.createElement("div");return t.setAttribute("data-context-menu-surface",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.setAttribute("aria-label",this.getAttribute("aria-label")||"Context menu"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#C),document.body.appendChild(t),this.#t=t,t}#S(t,e){if(!this.#e){let i=document.createElement("div");i.setAttribute("data-context-menu-anchor",""),i.style.cssText="position:fixed;width:1px;height:1px;pointer-events:none;opacity:0;",document.body.appendChild(i),this.#e=i}return this.#e.style.left=`${t}px`,this.#e.style.top=`${e}px`,this.#e}#v(t,e){let i=this.#g();i.replaceChildren();for(let o of[...this.children]){let a=o.tagName.toLowerCase();(a==="menu-item-ui"||a==="menu-divider-ui")&&i.appendChild(o.cloneNode(!0))}try{i.showPopover()}catch{}let n=this.#S(t,e);this.#i?.(),this.#i=mt(n,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#b();let r=i.querySelector("menu-item-ui:not([disabled])");queueMicrotask(()=>r?.focus?.()),this.dispatchEvent(new CustomEvent("context-menu-open",{bubbles:!0,detail:{target:this.#r,x:t,y:e}}))}#x(t="manual"){if(this.open){this.open=!1,this.#w(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#r?.focus?.()}catch{}}}#w(){this.#$(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#b(){this.#o=t=>{this.#t?.contains(t.target)||this.#x("outside")},this.#a=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#x("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#o),document.addEventListener("keydown",this.#a)})}#$(){this.#o&&document.removeEventListener("pointerdown",this.#o),this.#a&&document.removeEventListener("keydown",this.#a),this.#o=null,this.#a=null}#C=t=>{let e=t.target.closest("menu-item-ui");if(!e||e.hasAttribute("disabled"))return;let i=e.getAttribute("value")||"",n=e.getAttribute("text")||e.textContent.trim();this.dispatchEvent(new CustomEvent("context-menu-select",{bubbles:!0,detail:{value:i,text:n}})),this.#x("select")}};M();A("context-menu-ui",Mo);X();var Ro=class extends C{static properties={};static template=()=>null};M();A("visually-hidden-ui",Ro);X();var Io=class extends C{static properties={target:{type:String,default:"#main",reflect:!0},text:{type:String,default:"Skip to main content",reflect:!0}};static template=({target:t,text:e})=>At`<a href="${t}" data-skip-link>${e}</a>`;connected(){super.connected(),this.addEventListener("click",this.#t)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t)}#t=t=>{if(!t.target.closest("[data-skip-link]"))return;let i=this.target.replace(/^#/,""),n=document.getElementById(i);n&&queueMicrotask(()=>{n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus({preventScroll:!1})})}};M();A("skip-nav-ui",Io);X();var Do=class extends C{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};M();A("mark-ui",Do);var Xo=class extends _{static properties={..._.properties,placeholder:{type:String,default:"Click to edit",reflect:!0},editing:{type:Boolean,default:!1,reflect:!0},commit:{type:String,default:"blur",reflect:!0}};static template=()=>null;#t="";#e=!1;#i=!1;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","textbox"),!this.hasAttribute("tabindex")&&!this.disabled&&this.setAttribute("tabindex","0"),this.value&&this.textContent.trim()===""?this.textContent=this.value:!this.value&&this.textContent.trim()&&(this.value=this.textContent.trim(),this.syncValue()),this.#e||(this.#e=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#n),this.addEventListener("focus",this.#r),this.addEventListener("blur",this.#o))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#n),this.removeEventListener("focus",this.#r),this.removeEventListener("blur",this.#o),this.#e=!1}startEdit(){this.editing||this.disabled||this.readonly||(this.#t=this.value||"",this.editing=!0,this.setAttribute("contenteditable","plaintext-only"),this.dispatchEvent(new CustomEvent("edit-start",{bubbles:!0})),queueMicrotask(()=>{this.focus(),this.#a()}))}commitEdit(){if(!this.editing)return;let t=(this.textContent||"").trim(),e=this.#t;this.editing=!1,this.removeAttribute("contenteditable"),this.textContent!==t&&(this.textContent=t),t!==e&&(this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,oldValue:e}}))),this.dispatchEvent(new CustomEvent("edit-end",{bubbles:!0,detail:{committed:!0}}))}cancelEdit(){this.editing&&(this.editing=!1,this.removeAttribute("contenteditable"),this.textContent=this.#t,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0})),this.dispatchEvent(new CustomEvent("edit-end",{bubbles:!0,detail:{committed:!1}})))}#s=t=>{this.disabled||this.readonly||this.editing||(t.preventDefault(),this.startEdit())};#n=t=>{if(this.editing)t.key==="Enter"?(t.preventDefault(),this.#i=!0,this.commitEdit(),this.blur()):t.key==="Escape"&&(t.preventDefault(),this.#i=!0,this.cancelEdit(),this.blur());else if(t.key==="Enter"||t.key===" "){if(this.disabled||this.readonly)return;t.preventDefault(),this.startEdit()}};#r=()=>{};#o=()=>{if(this.editing){if(this.#i){this.#i=!1;return}this.commit==="blur"?this.commitEdit():this.commit==="enter"&&this.cancelEdit()}};#a(){let t=document.createRange();t.selectNodeContents(this);let e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(t))}};M();A("inline-edit-ui",Xo);X();var qo=class extends C{static properties={active:{type:Boolean,default:!1,reflect:!0},step:{type:Number,default:0,reflect:!1},autoStart:{type:Boolean,default:!1,reflect:!0,attribute:"auto-start"},storageKey:{type:String,default:"",reflect:!0,attribute:"storage-key"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;connected(){super.connected(),this.autoStart&&!this.#a()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#o.length){console.warn("[tour-ui] start() called with no <tour-step> children \u2014 nothing to render.");return}this.step=0,this.active=!0,this.#c(),this.#u(),this.dispatchEvent(new CustomEvent("tour-start",{bubbles:!0,detail:{step:0}}))}}next(){if(!this.active)return;let t=this.#o.length;if(this.step>=t-1){this.finish();return}let e=this.step;this.step=e+1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:e,to:this.step,totalSteps:t}}))}previous(){if(!this.active||this.step<=0)return;let t=this.step;this.step=t-1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:t,to:this.step,totalSteps:this.#o.length}}))}skip(){if(!this.active)return;let t=this.#o.length,e=this.step;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-skip",{bubbles:!0,detail:{step:e,totalSteps:t}}))}finish(){if(!this.active)return;let t=this.#o.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#o(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#a(){if(!this.storageKey)return!1;try{return localStorage.getItem(this.storageKey)==="done"}catch{return!1}}#l(){if(this.storageKey)try{localStorage.setItem(this.storageKey,"done")}catch{}}#c(){if(!this.#t){let t=document.createElement("div");t.setAttribute("data-tour-spotlight",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t),this.#t=t}if(!this.#e){let t=document.createElement("div");t.setAttribute("data-tour-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#p),document.body.appendChild(t),this.#e=t}this.#s=()=>this.#f(),this.#n=()=>this.#f(),window.addEventListener("resize",this.#s),window.addEventListener("scroll",this.#n,!0),this.#r=t=>{this.active&&(t.key==="Escape"?(t.preventDefault(),this.skip()):t.key==="ArrowRight"?(t.preventDefault(),this.next()):t.key==="ArrowLeft"&&(t.preventDefault(),this.previous()))},document.addEventListener("keydown",this.#r)}#h(){this.#i?.(),this.#i=null,this.#s&&window.removeEventListener("resize",this.#s),this.#n&&window.removeEventListener("scroll",this.#n,!0),this.#r&&document.removeEventListener("keydown",this.#r),this.#s=this.#n=this.#r=null;try{this.#e?.hidePopover?.()}catch{}this.#e?.removeEventListener("click",this.#p),this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null}#u(){let t=this.#o[this.step];if(!t)return;let e=this.#o.length,i=this.step===e-1,n=this.step===0,r=t.getAttribute("title")||"",o=t.getAttribute("placement")||"bottom",a=t.getAttribute("target")||"",l=a?document.querySelector(a):null;this.#d=l,this.#f();let h=`${this.step+1} of ${e}`,c=t.innerHTML;this.#e.innerHTML=`
252
+ `)}var $o=class extends C{static properties={layout:{type:String,default:"",reflect:!0},codeFirst:{type:Boolean,default:!1,reflect:!0,attribute:"code-first"},language:{type:String,default:"html",reflect:!0},rows:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e(t,e,i){let n=document.createElement("div");n.setAttribute("data-preview-render",""),n.innerHTML=t;let r=document.createElement("div");r.setAttribute("data-preview-code","");let o=document.createElement("code-ui");return o.setAttribute("language",e),o.textContent=t.replace(/\s+data-chunk(?:-[a-z]+)?="[^"]*"/g,"").replace(/\s+data-a2ui-id="[^"]*"/g,""),r.appendChild(o),i?[r,n]:[n,r]}connected(){if(this.querySelector(":scope > [data-preview-render], :scope > [data-preview-row]"))return;!this.hasAttribute("rows")&&!this.hasAttribute("layout")&&this.setAttribute("layout","split");let t=this.getAttribute("language")||"html",e=this.hasAttribute("code-first");if(this.hasAttribute("rows")){let n=[...this.children],r=[];for(let o of n){let a=o.getAttribute("data-preview-label");a!=null&&o.removeAttribute("data-preview-label");let l=o.hasAttribute("data-preview-unwrap");l&&o.removeAttribute("data-preview-unwrap");let h=Gk(l?o.innerHTML:o.outerHTML),c=document.createElement("div");c.setAttribute("data-preview-row","");let u=this.#e(h,t,e);a&&u.find(f=>f.hasAttribute("data-preview-render"))?.setAttribute("data-preview-label",a),c.append(...u),r.push(c)}if(r.length){this.replaceChildren(...r),this.#n();return}}let i=Gk(this.innerHTML);this.replaceChildren(...this.#e(i,t,e)),this.#n()}#i=()=>{if(this.hasAttribute("rows"))for(let t of this.querySelectorAll(":scope > [data-preview-row]")){let e=t.querySelector(":scope > [data-preview-render]");e&&e.scrollWidth>e.clientWidth+4&&t.setAttribute("data-stack","")}else if(this.getAttribute("layout")==="split"){let t=this.querySelector(":scope > [data-preview-render]");t&&t.scrollWidth>t.clientWidth+4&&this.setAttribute("layout","stack")}};#s=()=>{typeof requestAnimationFrame=="function"&&requestAnimationFrame(this.#i)};#n(){this.#s(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(this.#s),this.#t.observe(this))}disconnected(){this.#t?.disconnect()}};M();A("preview-ui",$o);X();var Co=class extends C{static properties={divider:{type:Boolean,default:!1,reflect:!0},spacing:{type:String,default:"md",reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},selectedKey:{type:String,default:"",reflect:!0,attribute:"selected-key"}};static template=()=>null;#t=!1;#e=!1;connected(){this.hasAttribute("role")||this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#r),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#r),this.removeEventListener("keydown",this.#o),this.#t=!1}render(){if(!this.selectable){if(this.#e){for(let n of this.#i())n.removeAttribute("selected"),n.removeAttribute("aria-selected"),n.removeAttribute("tabindex");this.#e=!1}return}this.#e=!0;let t=this.selectedKey||"",e=this.#i(),i=null;for(let n of e){let r=this.#s(n),o=r&&r===t;o?n.setAttribute("selected",""):n.removeAttribute("selected"),n.setAttribute("aria-selected",o?"true":"false"),n.setAttribute("tabindex",o?"0":"-1"),o&&(i=n)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#i(){return[...this.children].filter(t=>t.tagName==="LIST-ITEM-UI"||t.getAttribute?.("role")==="listitem")}#s(t){return t.id||t.getAttribute("data-key")||""}#n(t,{focus:e=!1}={}){if(!this.selectable||!t)return;let i=this.selectedKey||"";t!==i&&(this.selectedKey=t,this.dispatchEvent(new CustomEvent("selection-change",{detail:{key:t,previousKey:i},bubbles:!0})),e&&[...this.#i()].find(r=>this.#s(r)===t)?.focus?.())}#r=t=>{if(!this.selectable)return;let e=t.target.closest?.('list-item-ui, [role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#s(e);i&&this.#n(i)};#o=t=>{if(!this.selectable)return;let e=this.#i();if(!e.length)return;let i=document.activeElement,n=e.indexOf(i);if(n<0)return;let r=n;switch(t.key){case"ArrowDown":r=Math.min(e.length-1,n+1);break;case"ArrowUp":r=Math.max(0,n-1);break;case"Home":r=0;break;case"End":r=e.length-1;break;case"Enter":case" ":{t.preventDefault();let o=this.#s(e[n]);o&&this.#n(o);return}default:return}r!==n&&(t.preventDefault(),e[r]?.focus?.())}},Eo=class extends C{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.#s()}#t(t){for(let e of this.children)if(e.matches(t))return e;return null}#e(t){return t.dataset.listStamped="1",t}#i(t){return t?.dataset?.listStamped==="1"}#s(){if(!this.#t('[slot="content"]')){if(this.icon){let t=this.#t('[slot="icon"]')||this.#t("icon-ui");t||(t=this.#e(document.createElement("icon-ui")),t.setAttribute("slot","icon"),this.prepend(t)),t.setAttribute("name",this.icon)}if(this.text){let t=this.#t('[slot="text"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","text"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.text)}if(this.description){let t=this.#t('[slot="description"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","description"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.description)}}}render(){if(this.#t('[slot="content"]'))return;let t=this.#t('[slot="icon"]');if(this.icon)if(t)this.#i(t)&&t.setAttribute("name",this.icon);else{let n=this.#e(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#i(t)&&t.remove();let e=this.#t('[slot="text"]');if(this.text)if(e)this.#i(e)&&(e.textContent=this.text);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","text"),n.textContent=this.text,this.appendChild(n)}else this.#i(e)&&e.remove();let i=this.#t('[slot="description"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","description"),n.textContent=this.description,this.appendChild(n)}else this.#i(i)&&i.remove()}};M();A("list-ui",Co),A("list-item-ui",Eo);X();Ge();var Po=class extends C{static properties={items:{type:Array,default:[],reflect:!1},itemSize:{type:Number,default:0,reflect:!0,attribute:"item-size"},itemSizeRem:{type:Number,default:0,reflect:!0,attribute:"item-size-rem"},estimatedSize:{type:Number,default:48,reflect:!0,attribute:"estimated-size"},overscan:{type:Number,default:3,reflect:!0},direction:{type:String,default:"vertical",reflect:!0},pinBottom:{type:Boolean,default:!1,reflect:!0,attribute:"pin-bottom"},startIndex:{type:Number,default:0,reflect:!1,attribute:"start-index"},loading:{type:Boolean,default:!1,reflect:!0}};static parts={phantom:"<div data-phantom></div>",window:"<div data-window></div>",sentinelTop:'<div data-sentinel="top"></div>',sentinelBottom:'<div data-sentinel="bottom"></div>'};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=(t,e)=>t&&typeof t=="object"&&"id"in t?t.id:e;#o=new Map;#a=new Map;#l=1e5;#c=-1;#h=-1;#u=0;#d=!0;#f=null;#p=null;#m=()=>{this.#C();let t=this.#P();this.#u=t,this.#d=this.#v()};#g=t=>{let e=t.target.closest?.("[data-row]");if(!e||e.parentElement!==this.#e)return;let i=Number(e.dataset.index);if(!Number.isInteger(i)||i<0)return;let n=this.items?.[i];n!=null&&this.dispatchEvent(new CustomEvent("item-click",{detail:{item:n,index:i},bubbles:!0}))};#O=t=>{if(t.target!==this)return;let e=this.#x()||this.estimatedSize||48,i=this.#E(),n=0;switch(t.key){case"ArrowDown":n=+e;break;case"ArrowUp":n=-e;break;case"PageDown":n=+i;break;case"PageUp":n=-i;break;case" ":n=+i;break;case"Home":t.preventDefault(),this.scrollToTop();return;case"End":t.preventDefault(),this.scrollToBottom();return;default:return}t.preventDefault();let r=this.#P();this.#k(r+n)};#S=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let n=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:n},bubbles:!0}))}else if(i==="bottom"){let n=this.items||[],r=this.#h>=0?this.#h:n.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:r},bubbles:!0}))}}};#b=t=>{if(this.itemSize>0)return;let e=!1;for(let i of t){let n=i.target;if(!n||n.parentElement!==this.#e)continue;let r=Number(n.dataset.index);if(!Number.isInteger(r))continue;let o=this.direction==="horizontal"?i.contentRect.width:i.contentRect.height,a=Math.max(1,Math.round(o));this.#a.get(r)!==a&&(this.#a.set(r,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:r,height:a},bubbles:!0})),e=!0)}e&&(this.#X(),this.#$(),this.#C())};connected(){this.setAttribute("role",this.getAttribute("role")||"list"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t=this.ensure("phantom"),this.#e=this.ensure("window"),this.#i=this.ensure("sentinelTop"),this.#s=this.ensure("sentinelBottom"),typeof IntersectionObserver<"u"&&(this.#p=new IntersectionObserver(this.#S,{root:this,rootMargin:"0px",threshold:0}),this.#p.observe(this.#i),this.#p.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#f=new ResizeObserver(this.#b)),this.addEventListener("scroll",this.#m,{passive:!0}),this.addEventListener("click",this.#g),this.addEventListener("keydown",this.#O),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#g),this.removeEventListener("keydown",this.#O),this.#p?.disconnect(),this.#p=null,this.#f?.disconnect(),this.#f=null,this.#o.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#d||this.#v());t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.setAttribute("aria-rowcount",String(t.length)),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.#$(),this.#C(),e&&this.scrollToBottom(),this.#d=this.#v()}set renderRow(t){this.#n=typeof t=="function"?t:null,this.#o.clear(),this.#C()}get renderRow(){return this.#n}set keyFn(t){this.#r=typeof t=="function"?t:((e,i)=>i),this.#o.clear(),this.#C()}get keyFn(){return this.#r}scrollToIndex(t,{behavior:e="auto",align:i="start"}={}){let n=this.items||[];if(!n.length)return;let r=Math.max(0,Math.min(n.length-1,t|0)),o=this.#y(r),a=this.#E(),l=this.#w(r),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#k(Math.max(0,h),e)}scrollToTop(){this.#k(0)}scrollToBottom(){let t=this.#A();this.#k(Math.max(0,t))}getVisibleRange(){return{startIndex:this.#c,endIndex:this.#h}}invalidateMeasurements(t=0){if(t<=0)this.#a.clear();else for(let e of[...this.#a.keys()])e>=t&&this.#a.delete(e);this.#$(),this.#C()}#x(){if(this.itemSize>0)return this.itemSize;if(this.itemSizeRem>0){let t=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return this.itemSizeRem*t}return 0}#w(t){let e=this.#x();if(e>0)return e;let i=this.#a.get(t);return i??(this.estimatedSize||48)}#y(t){let e=this.#x();if(e>0)return t*e;let i=0;for(let n=0;n<t;n++)i+=this.#w(n);return i}#A(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#x();if(i>0)return e*i;let n=0,r=this.estimatedSize||48;for(let o=0;o<e;o++)n+=this.#a.get(o)??r;return n}#E(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#P(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#k(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#v(){let t=this.#P(),e=this.#E(),i=this.#A();return t+e>=i-1}#$(){if(!this.#t)return;let t=this.#A();this.direction==="horizontal"?(this.#t.style.width=`${t}px`,this.#t.style.height="1px"):(this.#t.style.height=`${t}px`,this.#t.style.width="1px")}#T(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#E(),n=this.#P(),r=this.#x(),o,a;if(r>0)o=Math.floor(n/r),a=Math.ceil((n+i)/r);else{let h=this.estimatedSize||48,c=0;o=0;for(let d=0;d<e;d++){let f=this.#a.get(d)??h;if(c+f>n){o=d;break}c+=f}a=o;let u=0;for(let d=o;d<e;d++){let f=this.#a.get(d)??h;if(u+=f,a=d+1,u>=i)break}}let l=Math.max(0,this.overscan|0);return o=Math.max(0,o-l),a=Math.min(e,a+l),{start:o,end:a}}#C(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=t.length,{start:i,end:n}=this.#T(),r=this.#y(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${r}px)`:this.#e.style.transform=`translateY(${r}px)`,this.loading?this.#Q(n-i):this.#M(t,i,n),(i!==this.#c||n!==this.#h)&&(this.#c=i,this.#h=n,this.dispatchEvent(new CustomEvent("range-change",{detail:{startIndex:i,endIndex:n,items:t.slice(i,n)},bubbles:!0})))}#M(t,e,i){if(!this.#e)return;let n=new Set,r=this.#n??this.#I();for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l);n.add(c);let u=this.#o.get(c);u?(u.dataset.index=String(l),u.setAttribute("aria-rowindex",String(l+1))):(u=this.#R(h,l,r),this.#o.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l),u=this.#o.get(c);u&&o.push(u)}for(let[l,h]of this.#o)n.has(l)||(this.#f?.unobserve(h),h.parentElement===this.#e&&h.remove(),this.#o.delete(l));let a=this.#e.firstChild;for(let l of o)l!==a&&this.#e.insertBefore(l,a),a=l.nextSibling;for(;a;){let l=a.nextSibling;a.remove(),a=l}if(this.itemSize<=0&&this.itemSizeRem<=0&&this.#f)for(let l of o)this.#f.observe(l)}#Q(t){if(!this.#e)return;this.#e.replaceChildren(),this.#o.clear();let e=Math.max(1,Math.min(20,t|0||5)),i=this.querySelector(':scope > template[slot="loading"]');for(let n=0;n<e;n++){let r=document.createElement("div");if(r.setAttribute("data-row",""),r.setAttribute("data-skeleton-row",""),r.dataset.index=String(n),i?.content)r.appendChild(i.content.cloneNode(!0));else{let o=document.createElement("skeleton-ui");r.appendChild(o)}this.#e.appendChild(r)}}#R(t,e,i){let n=document.createElement("div");n.setAttribute("data-row",""),n.setAttribute("role","listitem"),n.dataset.index=String(e),n.setAttribute("aria-rowindex",String(e+1));let r=null;if(typeof i=="function")try{r=i(t,e)}catch(o){console.warn("[list-window-ui] render() threw:",o)}if(Wi(r))n.appendChild(r);else if(r!=null)n.textContent=String(r);else if(t!=null&&typeof t=="object"&&"text"in t){let o=document.createElement("list-item-ui");o.setAttribute("text",String(t.text)),"description"in t&&o.setAttribute("description",String(t.description)),"icon"in t&&o.setAttribute("icon",String(t.icon)),n.appendChild(o)}else t!=null&&(n.textContent=String(t));return n}#I(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#L==null&&(this.#L=t.innerHTML);let e=this.#L;return(i,n)=>{let r=e.replace(/\$\{item\.([a-zA-Z0-9_]+)\}/g,(a,l)=>{let h=i&&typeof i=="object"?i[l]:"";return h==null?"":TI(String(h))}),o=document.createElement("template");return o.innerHTML=r,o.content.cloneNode(!0)}}#L=null;#X(){if(this.#a.size<=this.#l)return;let t=this.#a.size-this.#l,e=0;for(let i of this.#a.keys())if(this.#a.delete(i),++e>=t)break}};function TI(s){return s.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}M();A("list-window-ui",Po);X();var Qo=class extends C{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},offset:{type:Number,default:4,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=null;#n=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#f))}render(){this.open?this.#o():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){if(this.#e)return this.#e;let t=document.createElement("div");return t.setAttribute("data-menu-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.addEventListener("toggle",this.#S),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#o(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#r(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui, menu-label-ui");for(let n of i)e.contains(n)||e.appendChild(n);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=mt(t,e,{placement:this.placement,gap:this.offset}),this.#u&&(this.#u=!1,this.#n=requestAnimationFrame(()=>{this.#n=null,this.#c(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#g),document.addEventListener("keydown",this.#O,!0)})}#a(){this.#t?.(),this.#t=null;let t=this.#e;if(t){t.matches(":popover-open")&&t.hidePopover?.();let e=t.querySelectorAll("menu-item-ui, menu-divider-ui, menu-label-ui");for(let i of e)this.insertBefore(i,t)}this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#g),document.removeEventListener("keydown",this.#O,!0)}#l(){return Array.from(this.#e?.querySelectorAll("menu-item-ui")??[]).filter(t=>!t.disabled)}#c(t){let e=this.#l();if(!e.length)return;let i=(t+e.length)%e.length,n=e[i];n.setAttribute("tabindex","-1"),n.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#u=!1;#d=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#u=!1,this.open=!this.open)};#f=t=>{let e=this.querySelector('[slot="trigger"]');!e||!(t.target===e||e.contains(t.target))||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#u=!0,this.open=!0)};#p=t=>{let e=t.target.closest("menu-item-ui");!e||e.disabled||(this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.value,text:e.text}})),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0}))};#m=t=>{let e=this.#l();if(!e.length)return;let i=this.#h();switch(t.key){case"ArrowDown":t.preventDefault(),this.#c(i+1);break;case"ArrowUp":t.preventDefault(),this.#c(i-1);break;case"Home":t.preventDefault(),this.#c(0);break;case"End":t.preventDefault(),this.#c(e.length-1);break;case"Enter":case" ":{t.preventDefault(),(e[i]??e[0])?.click();break}}};#g=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#O=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#S=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#a(),this.#e&&(this.#e.removeEventListener("toggle",this.#S),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},To=class extends C{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.hasAttribute("role")&&!this.#t||(this.closest('[role="menu"], [role="menubar"]')?(this.setAttribute("role","menuitem"),this.#t=!0,this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")):(this.removeAttribute("role"),this.removeAttribute("tabindex"),this.#t=!1)),this.#n(),this.#r()}#e(t){return t.dataset.menuItemStamped="1",t}#i(t){return t?.dataset?.menuItemStamped==="1"}#s(t){for(let e of this.children)if(e.matches(t))return e;return null}#n(){if(!this.#s('[slot="text"]')){if(this.icon&&!this.#s('[slot="icon"]')){let t=this.#e(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#e(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}if(this.description&&!this.#s('[slot="subtitle"]')){let t=this.#e(document.createElement("span"));t.setAttribute("slot","subtitle"),t.textContent=this.description,this.appendChild(t)}}}#r(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#s('[slot="icon"]');if(this.icon)if(t)this.#i(t)&&t.setAttribute("name",this.icon);else{let n=this.#e(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#i(t)&&t.remove();let e=this.#s('[slot="text"]');this.#i(e)&&(e.textContent=this.text);let i=this.#s('[slot="subtitle"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","subtitle"),n.textContent=this.description,this.appendChild(n)}else this.#i(i)&&i.remove();this.#r()}},Lo=class extends C{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}},Fl=class extends C{static properties={text:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation"),this.#t()}#t(){if(!this.querySelector(':scope > [slot="text"]')&&this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.dataset.menuLabelStamped="1",t.textContent=this.text,this.appendChild(t)}}render(){let t=this.querySelector(':scope > [slot="text"]');t?.dataset.menuLabelStamped==="1"&&(t.textContent=this.text)}};M();A("menu-ui",Qo),A("menu-item-ui",To),A("menu-divider-ui",Lo),A("menu-label-ui",Fl);X();var Kk=500,Jk=new WeakSet,Mo=class extends C{static properties={targetSelector:{type:String,default:"",reflect:!0,attribute:"target-selector"},for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:Kk,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#n=null;#r=null;#o=null;#a=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#w(),this.#t?.remove(),this.#t=null}openAt(t,e,i=null){if(i??=this.#s[0]??null,!!i){if(this.#r=i,t==null||e==null){let n=i.getBoundingClientRect();t=n.left+n.width/2,e=n.top+n.height/2}this.#b(t,e)}}close(t="manual"){this.#x(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#d),t.addEventListener("touchstart",this.#f,{passive:!0}),t.addEventListener("touchend",this.#p),t.addEventListener("touchcancel",this.#p),t.addEventListener("keydown",this.#m)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#d),t.removeEventListener("touchstart",this.#f),t.removeEventListener("touchend",this.#p),t.removeEventListener("touchcancel",this.#p),t.removeEventListener("keydown",this.#m);this.#s=[]}#h(){let t=this.targetSelector||this.#u();if(t)try{return[...document.querySelectorAll(t)]}catch(e){return console.warn(`[context-menu-ui] invalid [target-selector] selector: ${t}`,e),[]}for(let e of this.children){let i=e.tagName.toLowerCase();if(i!=="menu-item-ui"&&i!=="menu-divider-ui")return[e]}return[]}#u(){return this.for?(Jk.has(this)||(Jk.add(this),console.warn(`[context-menu-ui] [for="${this.for}"] is deprecated \u2014 use [target-selector="${this.for}"] instead. [for] now means an id-ref everywhere else in AdiaUI; context-menu-ui's own prior [for] carried a CSS-selector meaning (ADR-0079).`)),this.for):""}#d=t=>{t.defaultPrevented||this.#g()&&(t.preventDefault(),this.#r=t.currentTarget,this.#b(t.clientX,t.clientY))};#f=t=>{if(!this.#g())return;let e=t.touches[0];e&&(this.#n=setTimeout(()=>{this.#r=t.currentTarget,this.#b(e.clientX,e.clientY)},this.longPressMs??Kk))};#p=()=>{this.#n&&clearTimeout(this.#n),this.#n=null};#m=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#g())return;t.preventDefault(),this.#r=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#g(){return[...this.children].some(t=>t.tagName.toLowerCase()==="menu-item-ui")}#O(){if(this.#t)return this.#t;let t=document.createElement("div");return t.setAttribute("data-context-menu-surface",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.setAttribute("aria-label",this.getAttribute("aria-label")||"Context menu"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#E),document.body.appendChild(t),this.#t=t,t}#S(t,e){if(!this.#e){let i=document.createElement("div");i.setAttribute("data-context-menu-anchor",""),i.style.cssText="position:fixed;width:1px;height:1px;pointer-events:none;opacity:0;",document.body.appendChild(i),this.#e=i}return this.#e.style.left=`${t}px`,this.#e.style.top=`${e}px`,this.#e}#b(t,e){let i=this.#O();i.replaceChildren();for(let o of[...this.children]){let a=o.tagName.toLowerCase();(a==="menu-item-ui"||a==="menu-divider-ui")&&i.appendChild(o.cloneNode(!0))}try{i.showPopover()}catch{}let n=this.#S(t,e);this.#i?.(),this.#i=mt(n,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#y();let r=i.querySelector("menu-item-ui:not([disabled])");queueMicrotask(()=>r?.focus?.()),this.dispatchEvent(new CustomEvent("context-menu-open",{bubbles:!0,detail:{target:this.#r,x:t,y:e}}))}#x(t="manual"){if(this.open){this.open=!1,this.#w(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#r?.focus?.()}catch{}}}#w(){this.#A(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#y(){this.#o=t=>{this.#t?.contains(t.target)||this.#x("outside")},this.#a=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#x("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#o),document.addEventListener("keydown",this.#a)})}#A(){this.#o&&document.removeEventListener("pointerdown",this.#o),this.#a&&document.removeEventListener("keydown",this.#a),this.#o=null,this.#a=null}#E=t=>{let e=t.target.closest("menu-item-ui");if(!e||e.hasAttribute("disabled"))return;let i=e.getAttribute("value")||"",n=e.getAttribute("text")||e.textContent.trim();this.dispatchEvent(new CustomEvent("context-menu-select",{bubbles:!0,detail:{value:i,text:n}})),this.#x("select")}};M();A("context-menu-ui",Mo);X();var Ro=class extends C{static properties={};static template=()=>null};M();A("visually-hidden-ui",Ro);X();var Io=class extends C{static properties={target:{type:String,default:"#main",reflect:!0},text:{type:String,default:"Skip to main content",reflect:!0}};static template=({target:t,text:e})=>At`<a href="${t}" data-skip-link>${e}</a>`;connected(){super.connected(),this.addEventListener("click",this.#t)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t)}#t=t=>{if(!t.target.closest("[data-skip-link]"))return;let i=this.target.replace(/^#/,""),n=document.getElementById(i);n&&queueMicrotask(()=>{n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus({preventScroll:!1})})}};M();A("skip-nav-ui",Io);X();var Do=class extends C{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};M();A("mark-ui",Do);var Xo=class extends _{static properties={..._.properties,placeholder:{type:String,default:"Click to edit",reflect:!0},editing:{type:Boolean,default:!1,reflect:!0},commit:{type:String,default:"blur",reflect:!0}};static template=()=>null;#t="";#e=!1;#i=!1;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","textbox"),!this.hasAttribute("tabindex")&&!this.disabled&&this.setAttribute("tabindex","0"),this.value&&this.textContent.trim()===""?this.textContent=this.value:!this.value&&this.textContent.trim()&&(this.value=this.textContent.trim(),this.syncValue()),this.#e||(this.#e=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#n),this.addEventListener("focus",this.#r),this.addEventListener("blur",this.#o))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#n),this.removeEventListener("focus",this.#r),this.removeEventListener("blur",this.#o),this.#e=!1}startEdit(){this.editing||this.disabled||this.readonly||(this.#t=this.value||"",this.editing=!0,this.setAttribute("contenteditable","plaintext-only"),this.dispatchEvent(new CustomEvent("edit-start",{bubbles:!0})),queueMicrotask(()=>{this.focus(),this.#a()}))}commitEdit(){if(!this.editing)return;let t=(this.textContent||"").trim(),e=this.#t;this.editing=!1,this.removeAttribute("contenteditable"),this.textContent!==t&&(this.textContent=t),t!==e&&(this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,oldValue:e}}))),this.dispatchEvent(new CustomEvent("edit-end",{bubbles:!0,detail:{committed:!0}}))}cancelEdit(){this.editing&&(this.editing=!1,this.removeAttribute("contenteditable"),this.textContent=this.#t,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0})),this.dispatchEvent(new CustomEvent("edit-end",{bubbles:!0,detail:{committed:!1}})))}#s=t=>{this.disabled||this.readonly||this.editing||(t.preventDefault(),this.startEdit())};#n=t=>{if(this.editing)t.key==="Enter"?(t.preventDefault(),this.#i=!0,this.commitEdit(),this.blur()):t.key==="Escape"&&(t.preventDefault(),this.#i=!0,this.cancelEdit(),this.blur());else if(t.key==="Enter"||t.key===" "){if(this.disabled||this.readonly)return;t.preventDefault(),this.startEdit()}};#r=()=>{};#o=()=>{if(this.editing){if(this.#i){this.#i=!1;return}this.commit==="blur"?this.commitEdit():this.commit==="enter"&&this.cancelEdit()}};#a(){let t=document.createRange();t.selectNodeContents(this);let e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(t))}};M();A("inline-edit-ui",Xo);X();var qo=class extends C{static properties={active:{type:Boolean,default:!1,reflect:!0},step:{type:Number,default:0,reflect:!1},autoStart:{type:Boolean,default:!1,reflect:!0,attribute:"auto-start"},storageKey:{type:String,default:"",reflect:!0,attribute:"storage-key"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;connected(){super.connected(),this.autoStart&&!this.#a()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#o.length){console.warn("[tour-ui] start() called with no <tour-step> children \u2014 nothing to render.");return}this.step=0,this.active=!0,this.#c(),this.#u(),this.dispatchEvent(new CustomEvent("tour-start",{bubbles:!0,detail:{step:0}}))}}next(){if(!this.active)return;let t=this.#o.length;if(this.step>=t-1){this.finish();return}let e=this.step;this.step=e+1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:e,to:this.step,totalSteps:t}}))}previous(){if(!this.active||this.step<=0)return;let t=this.step;this.step=t-1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:t,to:this.step,totalSteps:this.#o.length}}))}skip(){if(!this.active)return;let t=this.#o.length,e=this.step;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-skip",{bubbles:!0,detail:{step:e,totalSteps:t}}))}finish(){if(!this.active)return;let t=this.#o.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#o(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#a(){if(!this.storageKey)return!1;try{return localStorage.getItem(this.storageKey)==="done"}catch{return!1}}#l(){if(this.storageKey)try{localStorage.setItem(this.storageKey,"done")}catch{}}#c(){if(!this.#t){let t=document.createElement("div");t.setAttribute("data-tour-spotlight",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t),this.#t=t}if(!this.#e){let t=document.createElement("div");t.setAttribute("data-tour-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#p),document.body.appendChild(t),this.#e=t}this.#s=()=>this.#f(),this.#n=()=>this.#f(),window.addEventListener("resize",this.#s),window.addEventListener("scroll",this.#n,!0),this.#r=t=>{this.active&&(t.key==="Escape"?(t.preventDefault(),this.skip()):t.key==="ArrowRight"?(t.preventDefault(),this.next()):t.key==="ArrowLeft"&&(t.preventDefault(),this.previous()))},document.addEventListener("keydown",this.#r)}#h(){this.#i?.(),this.#i=null,this.#s&&window.removeEventListener("resize",this.#s),this.#n&&window.removeEventListener("scroll",this.#n,!0),this.#r&&document.removeEventListener("keydown",this.#r),this.#s=this.#n=this.#r=null;try{this.#e?.hidePopover?.()}catch{}this.#e?.removeEventListener("click",this.#p),this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null}#u(){let t=this.#o[this.step];if(!t)return;let e=this.#o.length,i=this.step===e-1,n=this.step===0,r=t.getAttribute("title")||"",o=t.getAttribute("placement")||"bottom",a=t.getAttribute("target")||"",l=a?document.querySelector(a):null;this.#d=l,this.#f();let h=`${this.step+1} of ${e}`,c=t.innerHTML;this.#e.innerHTML=`
253
253
  <div data-tour-header>
254
254
  <span data-tour-indicator>${h}</span>
255
255
  <span></span>
@@ -263,7 +263,7 @@ Correct shape for <chart-ui x="label" y="value">:
263
263
  <button-ui data-tour-next variant="primary" size="sm" text="${i?"Done":"Next \u2192"}"></button-ui>
264
264
  </div>
265
265
  </div>
266
- `;try{this.#e.showPopover()}catch{}this.#i?.(),l?this.#i=mt(l,this.#e,{placement:o,gap:12}):(this.#e.style.position="fixed",this.#e.style.top="50%",this.#e.style.left="50%",this.#e.style.transform="translate(-50%, -50%)"),queueMicrotask(()=>this.#e?.focus?.())}#d=null;#f(){if(!this.#t)return;let t=this.#d;if(!t){this.#t.setAttribute("data-tour-no-target","");return}this.#t.removeAttribute("data-tour-no-target");let e=t.getBoundingClientRect(),i=getComputedStyle(this),n=parseFloat(i.getPropertyValue("--tour-spotlight-padding"))||8,r=Math.max(0,e.top-n),o=Math.max(0,e.left-n),a=e.width+n*2,l=e.height+n*2;this.#t.style.top=`${r}px`,this.#t.style.left=`${o}px`,this.#t.style.width=`${a}px`,this.#t.style.height=`${l}px`}#p=t=>{let e=t.target;if(!(!e||!e.closest)){if(e.closest("[data-tour-skip]")){this.skip();return}if(e.closest("[data-tour-previous]")){this.previous();return}if(e.closest("[data-tour-next]")){this.next();return}}}},Zo=class extends C{static properties={target:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null};function LI(s){return String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}M();A("tour-ui",qo),A("tour-step-ui",Zo);X();var tA="data-toolbar-spillover",MI="data-toolbar-spillover-menu",eA=8,Fu="data-toolbar-spillover-label";function iA(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function RI(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function II(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(Fu)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||RI(e.getAttribute("icon"));i&&(e.setAttribute(Fu,""),e.setAttribute("text",i))}}function DI(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(Fu)&&(e.removeAttribute(Fu),e.removeAttribute("text"))}function sA(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,n=parseFloat(e.marginRight)||0;return t.width+i+n}var No=class extends C{static requiredIcons=["dots-three"];static properties={gap:{type:String,default:"sm",reflect:!0},align:{type:String,default:"start",reflect:!0},overflow:{type:String,default:"menu",reflect:!0},bordered:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#o=!1;#a=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#c(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(()=>this.#g()),this.#t.observe(this)),typeof MutationObserver<"u"&&(this.#e=new MutationObserver(()=>{this.#r||this.#g()})),this.#S(),this.#g()}disconnected(){this.#a!=null&&(cancelAnimationFrame(this.#a),this.#a=null),this.#o=!1,this.#t?.disconnect(),this.#e?.disconnect(),this.#u(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}#c(){if(this.#i)return;let t=document.createElement("button-ui");t.setAttribute("icon","dots-three"),t.setAttribute("variant","ghost"),t.setAttribute("size","sm"),t.setAttribute(tA,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(MI,""),e.setAttribute("popover","manual"),e.setAttribute("role","menu"),t.addEventListener("click",this.#d),e.addEventListener("click",this.#f),e.addEventListener("toggle",this.#O),this.appendChild(t),this.appendChild(e),this.#i=t,this.#s=e}#h(){let t=this.#s;!t||t.matches(":popover-open")||(t.showPopover?.(),this.#n?.(),this.#n=mt(this.#i,t,{placement:"bottom-end",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#p,!0),document.addEventListener("keydown",this.#m,!0)}))}#u(){this.#n?.(),this.#n=null,this.#s?.matches(":popover-open")&&this.#s.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0)}#d=t=>{t.stopPropagation(),this.#s?.matches(":popover-open")?this.#u():this.#h()};#f=t=>{let e=t.target.closest("button-ui");e&&(e.matches(`[${tA}]`)||queueMicrotask(()=>this.#u()))};#p=t=>{if(this.#i?.contains(t.target)||this.#s?.contains(t.target))return;let e=t.composedPath?.()||[];for(let i of e){if(i===document)break;if(i?.nodeType===1&&i.hasAttribute?.("popover"))return}this.#u()};#m=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#u(),this.#i?.focus?.({preventScroll:!0}))};#O=t=>{t.newState==="closed"&&(this.#n?.(),this.#n=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0))};#g(){this.#o||typeof requestAnimationFrame=="function"&&(this.#o=!0,this.#a=requestAnimationFrame(()=>{this.#a=null,this.#o=!1,this.isConnected&&this.#x()}))}#S(){this.#e?.observe(this,{childList:!0})}#v(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#x(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#r=!0,this.#v();try{for(;e.firstChild;)DI(e.firstChild),this.insertBefore(e.firstChild,t);let i=0;for(let S of this.children)S===t||S===e||(S.dataset.toolbarOrder==null&&(S.dataset.toolbarOrder=String(i)),i+=1);let n=Array.from(this.children).filter(S=>S!==t&&S!==e).sort((S,v)=>Number(S.dataset.toolbarOrder)-Number(v.dataset.toolbarOrder));for(let S of n)this.insertBefore(S,t);let r=n;for(let S of r)S.hidden=!1;if(t.hidden=!0,this.clientWidth===0)return;let o=getComputedStyle(this),a=parseFloat(o.paddingLeft)||0,l=parseFloat(o.paddingRight)||0,h=parseFloat(o.columnGap||o.gap)||0,c=this.clientWidth-a-l,u=r.filter(S=>parseFloat(getComputedStyle(S).flexGrow)>0),d=u.map(S=>S.style.flexGrow);for(let S of u)S.style.flexGrow="0";let f=r.map(S=>sA(S));u.forEach((S,v)=>{S.style.flexGrow=d[v]});let p=f.reduce((S,v)=>S+v,0)+Math.max(0,r.length-1)*h,m=p<=c-eA;if(this.overflow==="none"||m)return;t.hidden=!1;let g=sA(t),O=r.length,w=p;for(;O>0&&!(w+h+g<=c-eA);)O-=1,w-=f[O],O>0&&(w-=h);for(;O>0&&iA(r[O-1]);)O-=1;let x=r.slice(O);for(let S of x){if(iA(S)){S.hidden=!0;continue}II(S),e.appendChild(S)}e.firstElementChild||(t.hidden=!0)}finally{this.#r=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#S()})}}}},zo=class extends C{static template=()=>null;connected(){this.setAttribute("role","group")}};M();A("toolbar-ui",No),A("toolbar-group-ui",zo);X();var Bo=class extends C{static properties={variant:{type:String,default:"primary",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},divider:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0},multiExpand:{type:Boolean,default:!1,reflect:!0,attribute:"multi-expand"}};static template=()=>null;#t=null;connected(){this.setAttribute("role","navigation"),this.heading&&this.setAttribute("aria-label",this.heading),this.addEventListener("click",this.#n),this.variant!=="section"&&typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(()=>this.#i()),this.#t.observe(this))}render(){this.heading?this.setAttribute("aria-label",this.heading):this.removeAttribute("aria-label"),this.variant!=="section"&&this.#i()}get#e(){return this.collapsed||typeof this.getBoundingClientRect=="function"&&this.getBoundingClientRect().width<=96}#i(){let t=this.#e;for(let e of this.querySelectorAll(":scope > nav-group-ui")){let i=e.querySelector(':scope > [slot="header"]');i&&(i.title=t?e.text:"")}for(let e of this.querySelectorAll(":scope > nav-item-ui"))e.title=t?e.text:""}get selectedItem(){return this.querySelector("nav-item-ui[selected]")}select(t){let e=this.selectedItem;e!==t&&(e&&e.removeAttribute("selected"),t&&(t.setAttribute("selected",""),this.#r(),this.#s(t),this.dispatchEvent(new CustomEvent("nav-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value}}))))}#s(t){if(this.multiExpand)return;let e=t.closest("nav-group-ui");for(let i of this.querySelectorAll(":scope > nav-group-ui"))i!==e&&(i.open=!1)}toggle(){this.variant!=="section"&&(this.collapsed=!this.collapsed)}#n=t=>{if(this.variant==="section")return;let e=t.target.closest("nav-group-ui");if(e&&this.contains(e))if(this.#e){if(t.target.closest("[popover]"))return;e.showPopover?.()}else{let i=e.querySelector(':scope > [slot="header"]');i&&(t.target===i||i.contains(t.target))&&(e.open=!e.open)}};#r(){this.style.pointerEvents="none",requestAnimationFrame(()=>{this.style.pointerEvents=""})}disconnected(){this.removeEventListener("click",this.#n),this.#t?.disconnect(),this.#t=null}};M();A("nav-ui",Bo);X();var Vo=class extends C{static requiredIcons=["caret-right"];static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},variant:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=()=>this.#o();#n=null;#r=t=>{this.collapsible&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!this.open,this.dispatchEvent(new CustomEvent("group-toggle",{bubbles:!0,detail:{text:this.text,open:this.open}})))};connected(){this.setAttribute("role","group"),lt(this,"header").length?this.#i=lt(this,"header")[0]:(this.#i=document.createElement("div"),this.#i.setAttribute("slot","header"),this.#i.setAttribute("tabindex","0"),this.#i.innerHTML=`
266
+ `;try{this.#e.showPopover()}catch{}this.#i?.(),l?this.#i=mt(l,this.#e,{placement:o,gap:12}):(this.#e.style.position="fixed",this.#e.style.top="50%",this.#e.style.left="50%",this.#e.style.transform="translate(-50%, -50%)"),queueMicrotask(()=>this.#e?.focus?.())}#d=null;#f(){if(!this.#t)return;let t=this.#d;if(!t){this.#t.setAttribute("data-tour-no-target","");return}this.#t.removeAttribute("data-tour-no-target");let e=t.getBoundingClientRect(),i=getComputedStyle(this),n=parseFloat(i.getPropertyValue("--tour-spotlight-padding"))||8,r=Math.max(0,e.top-n),o=Math.max(0,e.left-n),a=e.width+n*2,l=e.height+n*2;this.#t.style.top=`${r}px`,this.#t.style.left=`${o}px`,this.#t.style.width=`${a}px`,this.#t.style.height=`${l}px`}#p=t=>{let e=t.target;if(!(!e||!e.closest)){if(e.closest("[data-tour-skip]")){this.skip();return}if(e.closest("[data-tour-previous]")){this.previous();return}if(e.closest("[data-tour-next]")){this.next();return}}}},Zo=class extends C{static properties={target:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null};function LI(s){return String(s??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}M();A("tour-ui",qo),A("tour-step-ui",Zo);X();var tA="data-toolbar-spillover",MI="data-toolbar-spillover-menu",eA=8,Fu="data-toolbar-spillover-label";function iA(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function RI(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function II(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(Fu)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||RI(e.getAttribute("icon"));i&&(e.setAttribute(Fu,""),e.setAttribute("text",i))}}function DI(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(Fu)&&(e.removeAttribute(Fu),e.removeAttribute("text"))}function sA(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,n=parseFloat(e.marginRight)||0;return t.width+i+n}var No=class extends C{static requiredIcons=["dots-three"];static properties={gap:{type:String,default:"sm",reflect:!0},align:{type:String,default:"start",reflect:!0},overflow:{type:String,default:"menu",reflect:!0},bordered:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#o=!1;#a=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#c(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(()=>this.#O()),this.#t.observe(this)),typeof MutationObserver<"u"&&(this.#e=new MutationObserver(()=>{this.#r||this.#O()})),this.#S(),this.#O()}disconnected(){this.#a!=null&&(cancelAnimationFrame(this.#a),this.#a=null),this.#o=!1,this.#t?.disconnect(),this.#e?.disconnect(),this.#u(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}#c(){if(this.#i)return;let t=document.createElement("button-ui");t.setAttribute("icon","dots-three"),t.setAttribute("variant","ghost"),t.setAttribute("size","sm"),t.setAttribute(tA,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(MI,""),e.setAttribute("popover","manual"),e.setAttribute("role","menu"),t.addEventListener("click",this.#d),e.addEventListener("click",this.#f),e.addEventListener("toggle",this.#g),this.appendChild(t),this.appendChild(e),this.#i=t,this.#s=e}#h(){let t=this.#s;!t||t.matches(":popover-open")||(t.showPopover?.(),this.#n?.(),this.#n=mt(this.#i,t,{placement:"bottom-end",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#p,!0),document.addEventListener("keydown",this.#m,!0)}))}#u(){this.#n?.(),this.#n=null,this.#s?.matches(":popover-open")&&this.#s.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0)}#d=t=>{t.stopPropagation(),this.#s?.matches(":popover-open")?this.#u():this.#h()};#f=t=>{let e=t.target.closest("button-ui");e&&(e.matches(`[${tA}]`)||queueMicrotask(()=>this.#u()))};#p=t=>{if(this.#i?.contains(t.target)||this.#s?.contains(t.target))return;let e=t.composedPath?.()||[];for(let i of e){if(i===document)break;if(i?.nodeType===1&&i.hasAttribute?.("popover"))return}this.#u()};#m=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#u(),this.#i?.focus?.({preventScroll:!0}))};#g=t=>{t.newState==="closed"&&(this.#n?.(),this.#n=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#p,!0),document.removeEventListener("keydown",this.#m,!0))};#O(){this.#o||typeof requestAnimationFrame=="function"&&(this.#o=!0,this.#a=requestAnimationFrame(()=>{this.#a=null,this.#o=!1,this.isConnected&&this.#x()}))}#S(){this.#e?.observe(this,{childList:!0})}#b(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#x(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#r=!0,this.#b();try{for(;e.firstChild;)DI(e.firstChild),this.insertBefore(e.firstChild,t);let i=0;for(let S of this.children)S===t||S===e||(S.dataset.toolbarOrder==null&&(S.dataset.toolbarOrder=String(i)),i+=1);let n=Array.from(this.children).filter(S=>S!==t&&S!==e).sort((S,v)=>Number(S.dataset.toolbarOrder)-Number(v.dataset.toolbarOrder));for(let S of n)this.insertBefore(S,t);let r=n;for(let S of r)S.hidden=!1;if(t.hidden=!0,this.clientWidth===0)return;let o=getComputedStyle(this),a=parseFloat(o.paddingLeft)||0,l=parseFloat(o.paddingRight)||0,h=parseFloat(o.columnGap||o.gap)||0,c=this.clientWidth-a-l,u=r.filter(S=>parseFloat(getComputedStyle(S).flexGrow)>0),d=u.map(S=>S.style.flexGrow);for(let S of u)S.style.flexGrow="0";let f=r.map(S=>sA(S));u.forEach((S,v)=>{S.style.flexGrow=d[v]});let p=f.reduce((S,v)=>S+v,0)+Math.max(0,r.length-1)*h,m=p<=c-eA;if(this.overflow==="none"||m)return;t.hidden=!1;let g=sA(t),O=r.length,w=p;for(;O>0&&!(w+h+g<=c-eA);)O-=1,w-=f[O],O>0&&(w-=h);for(;O>0&&iA(r[O-1]);)O-=1;let x=r.slice(O);for(let S of x){if(iA(S)){S.hidden=!0;continue}II(S),e.appendChild(S)}e.firstElementChild||(t.hidden=!0)}finally{this.#r=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#S()})}}}},zo=class extends C{static template=()=>null;connected(){this.setAttribute("role","group")}};M();A("toolbar-ui",No),A("toolbar-group-ui",zo);X();var Bo=class extends C{static properties={variant:{type:String,default:"primary",reflect:!0},collapsed:{type:Boolean,default:!1,reflect:!0},divider:{type:Boolean,default:!1,reflect:!0},heading:{type:String,default:"",reflect:!0},multiExpand:{type:Boolean,default:!1,reflect:!0,attribute:"multi-expand"}};static template=()=>null;#t=null;connected(){this.setAttribute("role","navigation"),this.heading&&this.setAttribute("aria-label",this.heading),this.addEventListener("click",this.#n),this.variant!=="section"&&typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(()=>this.#i()),this.#t.observe(this))}render(){this.heading?this.setAttribute("aria-label",this.heading):this.removeAttribute("aria-label"),this.variant!=="section"&&this.#i()}get#e(){return this.collapsed||typeof this.getBoundingClientRect=="function"&&this.getBoundingClientRect().width<=96}#i(){let t=this.#e;for(let e of this.querySelectorAll(":scope > nav-group-ui")){let i=e.querySelector(':scope > [slot="header"]');i&&(i.title=t?e.text:"")}for(let e of this.querySelectorAll(":scope > nav-item-ui"))e.title=t?e.text:""}get selectedItem(){return this.querySelector("nav-item-ui[selected]")}select(t){let e=this.selectedItem;e!==t&&(e&&e.removeAttribute("selected"),t&&(t.setAttribute("selected",""),this.#r(),this.#s(t),this.dispatchEvent(new CustomEvent("nav-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value}}))))}#s(t){if(this.multiExpand)return;let e=t.closest("nav-group-ui");for(let i of this.querySelectorAll(":scope > nav-group-ui"))i!==e&&(i.open=!1)}toggle(){this.variant!=="section"&&(this.collapsed=!this.collapsed)}#n=t=>{if(this.variant==="section")return;let e=t.target.closest("nav-group-ui");if(e&&this.contains(e))if(this.#e){if(t.target.closest("[popover]"))return;e.showPopover?.()}else{let i=e.querySelector(':scope > [slot="header"]');i&&(t.target===i||i.contains(t.target))&&(e.open=!e.open)}};#r(){this.style.pointerEvents="none",requestAnimationFrame(()=>{this.style.pointerEvents=""})}disconnected(){this.removeEventListener("click",this.#n),this.#t?.disconnect(),this.#t=null}};M();A("nav-ui",Bo);X();var Vo=class extends C{static requiredIcons=["caret-right"];static properties={text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},collapsible:{type:Boolean,default:!0,reflect:!0},variant:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=()=>this.#o();#n=null;#r=t=>{this.collapsible&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!this.open,this.dispatchEvent(new CustomEvent("group-toggle",{bubbles:!0,detail:{text:this.text,open:this.open}})))};connected(){this.setAttribute("role","group"),lt(this,"header").length?this.#i=lt(this,"header")[0]:(this.#i=document.createElement("div"),this.#i.setAttribute("slot","header"),this.#i.setAttribute("tabindex","0"),this.#i.innerHTML=`
267
267
  <span slot="icon">${this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:""}</span>
268
268
  <span slot="text">${this.text}</span>
269
269
  ${this.badge?`<span slot="badge">${this.badge}</span>`:""}
@@ -278,7 +278,7 @@ Correct shape for <chart-ui x="label" y="value">:
278
278
  placeholder="${this.placeholder}"
279
279
  ${this.disabled?"disabled":""}
280
280
  ${t?`size="${t}"`:""}
281
- ></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#n),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#r)))}render(){this.#t&&(Uu(this.#t,"placeholder",this.placeholder),this.disabled?Uu(this.#t,"disabled",""):XI(this.#t,"disabled"),Uu(this,"value",this.value||""))}#s=()=>{this.value=this.#t.value,this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#n=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#r()};#r=()=>{clearTimeout(this.#i),this.value="",this.#t&&(this.#t.value=""),this.syncValue(""),this.setAttribute("value",""),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:""}})),this.#t?.focus()};focus(){this.#t?.focus()}clear(){this.#r()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#n)),this.#e&&this.#e.removeEventListener("click",this.#r),this.#t=null,this.#e=null}};M();A("search-ui",Fo);mi();function rn(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function qI(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ZI=0,Uo=class extends _{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle"];static properties={..._.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},creatable:{type:Boolean,default:!1,reflect:!0},clearable:{type:Boolean,default:!1,reflect:!0},filterMode:{type:String,default:"substring",reflect:!0,attribute:"filter-mode"},loading:{type:Boolean,default:!1,reflect:!0},maxOptions:{type:Number,default:100,reflect:!0,attribute:"max-options"},maxVisibleItems:{type:Number,default:10,reflect:!0,attribute:"max-visible-items"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#n=!1;#r=null;#o=null;#a=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=`combobox-${++ZI}`;#O=void 0;#g=()=>this.#Z();#S=t=>this.#B(t);#v=()=>this.#q();#x=t=>this.#F(t);#w=t=>this.#j(t);#b=t=>this.#U(t);#$=t=>this.#rt(t);#C=t=>this.#W(t);#P=t=>this.#ot(t);connected(){super.connected(),this.#t.length===0&&this.#E(),this.#e=this.value||"",this.#k(),this.#M(),this.#V()}disconnected(){super.disconnected(),this.#T(),this.#f?.(),this.#f=null,this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#P),this.#a?.hidePopover?.(),this.#a=null,this.#r=null,this.#o=null,this.#l=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null}render(){if(!this.#r)return;this.#r.setAttribute("aria-expanded",String(this.open)),this.disabled||this.readonly?this.#r.contentEditable="false":this.#r.contentEditable="plaintext-only",this.#o&&(this.#o.textContent=this.label||"",this.#o.style.display=this.label?"":"none");let t=this.label?"":this.placeholder||"";this.#O=Zt(this,this.#O,t),this.#u&&(this.#u.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#at():this.#it()}#k(){if(this.querySelector(":scope > [data-field]")){this.#y(),this.#A();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,n=lt(this,"prefix"),r=lt(this,"suffix"),o=lt(this,"empty"),a=lt(this,"loading"),l=lt(this,"footer");this.innerHTML=`
281
+ ></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#n),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#r)))}render(){this.#t&&(Uu(this.#t,"placeholder",this.placeholder),this.disabled?Uu(this.#t,"disabled",""):XI(this.#t,"disabled"),Uu(this,"value",this.value||""))}#s=()=>{this.value=this.#t.value,this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#n=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#r()};#r=()=>{clearTimeout(this.#i),this.value="",this.#t&&(this.#t.value=""),this.syncValue(""),this.setAttribute("value",""),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:""}})),this.#t?.focus()};focus(){this.#t?.focus()}clear(){this.#r()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#n)),this.#e&&this.#e.removeEventListener("click",this.#r),this.#t=null,this.#e=null}};M();A("search-ui",Fo);mi();function rn(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function qI(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ZI=0,Uo=class extends _{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle"];static properties={..._.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},creatable:{type:Boolean,default:!1,reflect:!0},clearable:{type:Boolean,default:!1,reflect:!0},filterMode:{type:String,default:"substring",reflect:!0,attribute:"filter-mode"},loading:{type:Boolean,default:!1,reflect:!0},maxOptions:{type:Number,default:100,reflect:!0,attribute:"max-options"},maxVisibleItems:{type:Number,default:10,reflect:!0,attribute:"max-visible-items"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#n=!1;#r=null;#o=null;#a=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=`combobox-${++ZI}`;#g=void 0;#O=()=>this.#Z();#S=t=>this.#B(t);#b=()=>this.#q();#x=t=>this.#F(t);#w=t=>this.#j(t);#y=t=>this.#U(t);#A=t=>this.#rt(t);#E=t=>this.#W(t);#P=t=>this.#ot(t);connected(){super.connected(),this.#t.length===0&&this.#C(),this.#e=this.value||"",this.#k(),this.#R(),this.#V()}disconnected(){super.disconnected(),this.#T(),this.#f?.(),this.#f=null,this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#P),this.#a?.hidePopover?.(),this.#a=null,this.#r=null,this.#o=null,this.#l=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null}render(){if(!this.#r)return;this.#r.setAttribute("aria-expanded",String(this.open)),this.disabled||this.readonly?this.#r.contentEditable="false":this.#r.contentEditable="plaintext-only",this.#o&&(this.#o.textContent=this.label||"",this.#o.style.display=this.label?"":"none");let t=this.label?"":this.placeholder||"";this.#g=Zt(this,this.#g,t),this.#u&&(this.#u.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#at():this.#it()}#k(){if(this.querySelector(":scope > [data-field]")){this.#v(),this.#$();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,n=lt(this,"prefix"),r=lt(this,"suffix"),o=lt(this,"empty"),a=lt(this,"loading"),l=lt(this,"footer");this.innerHTML=`
282
282
  <span data-label id="${t}"${this.label?"":' style="display:none"'}>${rn(this.label||"")}</span>
283
283
  <div data-field>
284
284
  <span data-prefix></span>
@@ -303,8 +303,8 @@ Correct shape for <chart-ui x="label" y="value">:
303
303
  <div data-empty>No matches</div>
304
304
  <div data-footer></div>
305
305
  </div>
306
- `,this.#y(),n.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...n),r.length&&this.#d.replaceChildren(...r),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#A()}#y(){this.#r=this.querySelector(":scope > [data-field] > [data-input]"),this.#o=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#a=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#A(){this.#r&&(this.#r.addEventListener("input",this.#g),this.#r.addEventListener("keydown",this.#S),this.#r.addEventListener("focus",this.#v),this.#r.addEventListener("blur",this.#x)),this.#u&&this.#u.addEventListener("click",this.#$),this.#d&&this.#d.addEventListener("click",this.#C)}#T(){this.#r&&(this.#r.removeEventListener("input",this.#g),this.#r.removeEventListener("keydown",this.#S),this.#r.removeEventListener("focus",this.#v),this.#r.removeEventListener("blur",this.#x)),this.#u&&this.#u.removeEventListener("click",this.#$),this.#d&&this.#d.removeEventListener("click",this.#C)}#E(){let t=[],e="";for(let i of Array.from(this.children))if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&!e&&(e=r.value);t.push(n)}else i.tagName==="OPTION"&&(t.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&!e&&(e=i.value));for(let i of[...this.querySelectorAll(":scope > option, :scope > optgroup")])i.remove();this.#t=t,!this.value&&e&&(this.value=e)}set options(t){Mt(()=>{this.#t=Array.isArray(t)?t:[],this.#a&&this.#M(),this.#V()})}get options(){return this.#t}#L(){let t=[];for(let e of this.#t)if(e&&Array.isArray(e.options))for(let i of e.options)t.push(i);else e&&t.push(e);return t}#Q(t){return this.#L().find(e=>e.value===t)||null}#M(){if(!this.#a)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#L(),i=this.#N(e).slice(0,Number(this.maxOptions)||100),n=0,r=a=>{n+=1;let l=document.createElement("div");return l.setAttribute("role","option"),l.setAttribute("id",`${this.#m}-opt-${n}`),l.dataset.value=a.value??"",a.disabled&&l.setAttribute("aria-disabled","true"),a.value===this.value&&l.setAttribute("aria-selected","true"),l.setAttribute("data-single-option",""),l.innerHTML=`<span data-radio aria-hidden="true"></span><span data-option-label>${this.#R(a.label??a.value)}</span>`,l.addEventListener("click",this.#w),l.addEventListener("mouseenter",this.#b),l};if(this.#t.some(a=>a&&Array.isArray(a.options)))for(let a of this.#t)if(a&&Array.isArray(a.options)){let l=this.#N(a.options);if(!l.length)continue;let h=document.createElement("div");h.setAttribute("role","group");let c=document.createElement("div");c.setAttribute("data-group-label",""),c.textContent=a.label||"",h.appendChild(c);for(let u of l)h.appendChild(r(u));t.appendChild(h)}else a&&this.#X(a)&&t.appendChild(r(a));else for(let a of i)t.appendChild(r(a));let o=t.querySelectorAll('[role="option"]').length;this.#l&&(this.#l.style.display=o||this.loading?"none":""),this.open&&this.#I(),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant")}#I(){if(!this.#a)return;let t=Number(this.maxVisibleItems),e=this.#a.querySelectorAll('[role="option"]');if(!Number.isFinite(t)||t<=0||e.length<=t){this.#a.style.removeProperty("--combobox-list-max-block");return}let i=e[0].getBoundingClientRect().height;if(!i)return;let n=getComputedStyle(this.#a),r=(parseFloat(n.paddingBlockStart)||0)+(parseFloat(n.paddingBlockEnd)||0)+(parseFloat(n.borderBlockStartWidth)||0)+(parseFloat(n.borderBlockEndWidth)||0);this.#a.style.setProperty("--combobox-list-max-block",`${Math.ceil(i*t+r)}px`)}#R(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return rn(e);let i=this.#i,n=new RegExp(qI(i),"i"),r=e.match(n);if(!r)return rn(e);let o=r.index??0,a=o+r[0].length;return rn(e.slice(0,o))+"<mark>"+rn(e.slice(o,a))+"</mark>"+rn(e.slice(a))}#X(t){if(!this.#i)return!0;let e=this.#i.toLowerCase(),i=String(t.label??t.value??"").toLowerCase();switch(this.filterMode){case"prefix":return i.startsWith(e);case"fuzzy":{let n=0;for(let r of e){if(n=i.indexOf(r,n),n===-1)return!1;n+=1}return!0}default:return i.includes(e)}}#N(t){return this.#i?t.filter(e=>this.#X(e)):t.slice()}#Z(){if(this.#n)return;let t=this.#r.textContent||"";this.#i=t.trim(),this.#r.toggleAttribute("data-empty",!t),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#M();let e=this.#D();this.#i&&e.length&&this.#_(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#B(t){let e=t.key;if(e==="ArrowDown"){t.preventDefault(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}))),this.#z(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#z(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#_(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#D();this.#_(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#et();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#tt("escape"));return}if(e==="Tab"){this.#G();return}if(e==="Backspace"){let i=!(this.#r.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#q(){}#F(t){!this.freeText&&this.#i&&!this.value&&(this.#V(),this.#i="")}#D(){return this.#a?Array.from(this.#a.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#z(t){let e=this.#D();if(!e.length)return;if(this.#s<0){this.#_(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#_(i)}#_(t){let e=this.#D();if(!e.length){this.#s=-1,this.#r?.removeAttribute("aria-activedescendant");return}for(let o of e)o.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),n=e[i];if(!n)return;n.setAttribute("data-active","");let r=this.#a;if(r){let o=n.offsetTop,a=o+n.offsetHeight;o<r.scrollTop?r.scrollTop=o:a>r.scrollTop+r.clientHeight&&(r.scrollTop=a-r.clientHeight)}this.#s=i,this.#r?.setAttribute("aria-activedescendant",n.id)}#j(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#Y(i,"click")}#U(t){let e=t.currentTarget,n=this.#D().indexOf(e);n>=0&&this.#_(n)}#et(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#D(),e=this.#s>=0?t[this.#s]:null;if(e){this.#Y(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(!i){this.#it("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#nt(i,"keyboard");return}if(this.freeText){this.#nt(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#V(),this.#i="",this.#M()}#G(){if(!this.open)return;let t=this.#D(),e=this.#s>=0?t[this.#s]:null;if(e){this.#Y(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#Q(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#nt(i,"keyboard");return}this.#V(),this.#i="",this.#it("blur")}#Y(t,e){if(this.readonly){this.#it("select");return}let i=this.#Q(t);Mt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#V(),this.#M(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:i,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#nt(t,e){if(this.readonly){this.#it("select");return}Mt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#V(),this.#M(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:null,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#rt(t){t.preventDefault(),t.stopPropagation(),this.#J("click"),this.#r?.focus()}#J(t){Mt(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#V(),this.#M(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#J("programmatic")}#W(t){t.preventDefault(),t.stopPropagation(),!this.disabled&&(this.open?(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}}))):(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"click"}})),this.#r?.focus()))}#ot(t){let e=this.contains(t.target),i=this.#a&&t.composedPath().includes(this.#a);!e&&!i&&(this.#i&&!this.freeText&&(this.#V(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#tt(t){this.#V(),this.#i="",this.#M(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#at(){if(!this.#a)return;this.#a.showPopover?.(),this.#I();let t=this.querySelector(":scope > [data-field]")||this;this.#a.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=mt(t,this.#a,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{this.#p=null,document.addEventListener("pointerdown",this.#P)});let e=this.#D();if(!e.length)return;let i=e.findIndex(n=>n.dataset.value===this.value);this.#_(i>=0?i:0)}#it(t){this.#a&&(this.#f?.(),this.#f=null,this.#a.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#P),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant"))}#V(){if(!this.#r)return;let t=this.#Q(this.value),e=t?t.label??t.value??"":this.value||"";(this.#r.textContent||"")!==e&&(this.#n=!0,this.#r.textContent=e,this.#n=!1),this.#r.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#r?.focus()}selectOption(t){return this.#Q(t)?(this.#Y(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};M();A("combobox-ui",Uo);mi();var NI=0;function zI(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Yo=class extends _{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=_.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
307
- `,reflect:!0,attribute:"paste-split"},max:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},minLength:{type:Number,default:1,reflect:!0,attribute:"min-length"},maxLength:{type:Number,default:0,reflect:!0,attribute:"max-length"},unique:{type:Boolean,default:!0,reflect:!0},normalize:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0}}}static get observedAttributes(){let t=super.observedAttributes;return t.includes("value")?t:[...t,"value"]}attributeChangedCallback(t,e,i){if(t==="value"){if(i!=null&&e!==i){let n=this.#j(i);n&&(this.value=n)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#n=!1;#r=0;#o=null;#a=null;#l=null;#c=null;#h=`tags-input-${++NI}`;#u=()=>this.#A();#d=t=>this.#T(t);#f=t=>this.#E(t);#p=t=>this.#L(t);#m=t=>this.#Q(t);#O=t=>this.#M(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#j(this.getAttribute("value"));t&&(this.#t=t)}this.#g(),this.#w(),this.#k(),this.#y()}disconnected(){super.disconnected(),this.#x(),this.#o=null,this.#a=null,this.#l=null,this.#c=null}render(){this.#a&&(this.disabled||this.readonly?this.#a.contentEditable="false":this.#a.contentEditable="plaintext-only",this.#a.setAttribute("data-placeholder",this.placeholder||""),this.#e.length?(this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","listbox"),this.setAttribute("aria-expanded",String(!!this.hasAttribute("suggesting")))):(this.setAttribute("role","group"),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded")),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.placeholder||"Tags"))}set value(t){Mt(()=>{let e=Array.isArray(t)?t.map(n=>String(n??"")):typeof t=="string"?this.#j(t)||[]:[],i=this.#t.slice();this.#t=e,this.#w(),this.#k(),this.#y(),this.#B(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){Mt(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#P(),this.render()})}get suggestions(){return this.#e.slice()}set validateFn(t){this.#i=typeof t=="function"?t:null}get validateFn(){return this.#i}addToken(t){return this.#R(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#Z(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#w(),this.#k(),this.#y(),this.#B(t,[],"programmatic")}focus(){this.#a?.focus()}#g(){if(this.querySelector(":scope > [data-chip-list]")){this.#S(),this.#v();return}let t=this.querySelector(':scope > template[slot="chip"]'),e=`${this.#h}-suggestions`,i=`${this.#h}-input`;this.innerHTML=`
306
+ `,this.#v(),n.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...n),r.length&&this.#d.replaceChildren(...r),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#$()}#v(){this.#r=this.querySelector(":scope > [data-field] > [data-input]"),this.#o=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#a=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#$(){this.#r&&(this.#r.addEventListener("input",this.#O),this.#r.addEventListener("keydown",this.#S),this.#r.addEventListener("focus",this.#b),this.#r.addEventListener("blur",this.#x)),this.#u&&this.#u.addEventListener("click",this.#A),this.#d&&this.#d.addEventListener("click",this.#E)}#T(){this.#r&&(this.#r.removeEventListener("input",this.#O),this.#r.removeEventListener("keydown",this.#S),this.#r.removeEventListener("focus",this.#b),this.#r.removeEventListener("blur",this.#x)),this.#u&&this.#u.removeEventListener("click",this.#A),this.#d&&this.#d.removeEventListener("click",this.#E)}#C(){let t=[],e="";for(let i of Array.from(this.children))if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&!e&&(e=r.value);t.push(n)}else i.tagName==="OPTION"&&(t.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&!e&&(e=i.value));for(let i of[...this.querySelectorAll(":scope > option, :scope > optgroup")])i.remove();this.#t=t,!this.value&&e&&(this.value=e)}set options(t){Mt(()=>{this.#t=Array.isArray(t)?t:[],this.#a&&this.#R(),this.#V()})}get options(){return this.#t}#M(){let t=[];for(let e of this.#t)if(e&&Array.isArray(e.options))for(let i of e.options)t.push(i);else e&&t.push(e);return t}#Q(t){return this.#M().find(e=>e.value===t)||null}#R(){if(!this.#a)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#M(),i=this.#N(e).slice(0,Number(this.maxOptions)||100),n=0,r=a=>{n+=1;let l=document.createElement("div");return l.setAttribute("role","option"),l.setAttribute("id",`${this.#m}-opt-${n}`),l.dataset.value=a.value??"",a.disabled&&l.setAttribute("aria-disabled","true"),a.value===this.value&&l.setAttribute("aria-selected","true"),l.setAttribute("data-single-option",""),l.innerHTML=`<span data-radio aria-hidden="true"></span><span data-option-label>${this.#L(a.label??a.value)}</span>`,l.addEventListener("click",this.#w),l.addEventListener("mouseenter",this.#y),l};if(this.#t.some(a=>a&&Array.isArray(a.options)))for(let a of this.#t)if(a&&Array.isArray(a.options)){let l=this.#N(a.options);if(!l.length)continue;let h=document.createElement("div");h.setAttribute("role","group");let c=document.createElement("div");c.setAttribute("data-group-label",""),c.textContent=a.label||"",h.appendChild(c);for(let u of l)h.appendChild(r(u));t.appendChild(h)}else a&&this.#X(a)&&t.appendChild(r(a));else for(let a of i)t.appendChild(r(a));let o=t.querySelectorAll('[role="option"]').length;this.#l&&(this.#l.style.display=o||this.loading?"none":""),this.open&&this.#I(),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant")}#I(){if(!this.#a)return;let t=Number(this.maxVisibleItems),e=this.#a.querySelectorAll('[role="option"]');if(!Number.isFinite(t)||t<=0||e.length<=t){this.#a.style.removeProperty("--combobox-list-max-block");return}let i=e[0].getBoundingClientRect().height;if(!i)return;let n=getComputedStyle(this.#a),r=(parseFloat(n.paddingBlockStart)||0)+(parseFloat(n.paddingBlockEnd)||0)+(parseFloat(n.borderBlockStartWidth)||0)+(parseFloat(n.borderBlockEndWidth)||0);this.#a.style.setProperty("--combobox-list-max-block",`${Math.ceil(i*t+r)}px`)}#L(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return rn(e);let i=this.#i,n=new RegExp(qI(i),"i"),r=e.match(n);if(!r)return rn(e);let o=r.index??0,a=o+r[0].length;return rn(e.slice(0,o))+"<mark>"+rn(e.slice(o,a))+"</mark>"+rn(e.slice(a))}#X(t){if(!this.#i)return!0;let e=this.#i.toLowerCase(),i=String(t.label??t.value??"").toLowerCase();switch(this.filterMode){case"prefix":return i.startsWith(e);case"fuzzy":{let n=0;for(let r of e){if(n=i.indexOf(r,n),n===-1)return!1;n+=1}return!0}default:return i.includes(e)}}#N(t){return this.#i?t.filter(e=>this.#X(e)):t.slice()}#Z(){if(this.#n)return;let t=this.#r.textContent||"";this.#i=t.trim(),this.#r.toggleAttribute("data-empty",!t),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#R();let e=this.#D();this.#i&&e.length&&this.#_(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#B(t){let e=t.key;if(e==="ArrowDown"){t.preventDefault(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}))),this.#z(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#z(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#_(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#D();this.#_(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#et();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#tt("escape"));return}if(e==="Tab"){this.#G();return}if(e==="Backspace"){let i=!(this.#r.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#q(){}#F(t){!this.freeText&&this.#i&&!this.value&&(this.#V(),this.#i="")}#D(){return this.#a?Array.from(this.#a.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#z(t){let e=this.#D();if(!e.length)return;if(this.#s<0){this.#_(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#_(i)}#_(t){let e=this.#D();if(!e.length){this.#s=-1,this.#r?.removeAttribute("aria-activedescendant");return}for(let o of e)o.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),n=e[i];if(!n)return;n.setAttribute("data-active","");let r=this.#a;if(r){let o=n.offsetTop,a=o+n.offsetHeight;o<r.scrollTop?r.scrollTop=o:a>r.scrollTop+r.clientHeight&&(r.scrollTop=a-r.clientHeight)}this.#s=i,this.#r?.setAttribute("aria-activedescendant",n.id)}#j(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#Y(i,"click")}#U(t){let e=t.currentTarget,n=this.#D().indexOf(e);n>=0&&this.#_(n)}#et(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#D(),e=this.#s>=0?t[this.#s]:null;if(e){this.#Y(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(!i){this.#it("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#nt(i,"keyboard");return}if(this.freeText){this.#nt(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#V(),this.#i="",this.#R()}#G(){if(!this.open)return;let t=this.#D(),e=this.#s>=0?t[this.#s]:null;if(e){this.#Y(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#Q(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#nt(i,"keyboard");return}this.#V(),this.#i="",this.#it("blur")}#Y(t,e){if(this.readonly){this.#it("select");return}let i=this.#Q(t);Mt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#V(),this.#R(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:i,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#nt(t,e){if(this.readonly){this.#it("select");return}Mt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#V(),this.#R(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:null,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#rt(t){t.preventDefault(),t.stopPropagation(),this.#J("click"),this.#r?.focus()}#J(t){Mt(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#V(),this.#R(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#J("programmatic")}#W(t){t.preventDefault(),t.stopPropagation(),!this.disabled&&(this.open?(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}}))):(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"click"}})),this.#r?.focus()))}#ot(t){let e=this.contains(t.target),i=this.#a&&t.composedPath().includes(this.#a);!e&&!i&&(this.#i&&!this.freeText&&(this.#V(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#tt(t){this.#V(),this.#i="",this.#R(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#at(){if(!this.#a)return;this.#a.showPopover?.(),this.#I();let t=this.querySelector(":scope > [data-field]")||this;this.#a.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=mt(t,this.#a,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{this.#p=null,document.addEventListener("pointerdown",this.#P)});let e=this.#D();if(!e.length)return;let i=e.findIndex(n=>n.dataset.value===this.value);this.#_(i>=0?i:0)}#it(t){this.#a&&(this.#f?.(),this.#f=null,this.#a.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#P),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant"))}#V(){if(!this.#r)return;let t=this.#Q(this.value),e=t?t.label??t.value??"":this.value||"";(this.#r.textContent||"")!==e&&(this.#n=!0,this.#r.textContent=e,this.#n=!1),this.#r.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#r?.focus()}selectOption(t){return this.#Q(t)?(this.#Y(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};M();A("combobox-ui",Uo);mi();var NI=0;function zI(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Yo=class extends _{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=_.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
307
+ `,reflect:!0,attribute:"paste-split"},max:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},minLength:{type:Number,default:1,reflect:!0,attribute:"min-length"},maxLength:{type:Number,default:0,reflect:!0,attribute:"max-length"},unique:{type:Boolean,default:!0,reflect:!0},normalize:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0}}}static get observedAttributes(){let t=super.observedAttributes;return t.includes("value")?t:[...t,"value"]}attributeChangedCallback(t,e,i){if(t==="value"){if(i!=null&&e!==i){let n=this.#j(i);n&&(this.value=n)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#n=!1;#r=0;#o=null;#a=null;#l=null;#c=null;#h=`tags-input-${++NI}`;#u=()=>this.#$();#d=t=>this.#T(t);#f=t=>this.#C(t);#p=t=>this.#M(t);#m=t=>this.#Q(t);#g=t=>this.#R(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#j(this.getAttribute("value"));t&&(this.#t=t)}this.#O(),this.#w(),this.#k(),this.#v()}disconnected(){super.disconnected(),this.#x(),this.#o=null,this.#a=null,this.#l=null,this.#c=null}render(){this.#a&&(this.disabled||this.readonly?this.#a.contentEditable="false":this.#a.contentEditable="plaintext-only",this.#a.setAttribute("data-placeholder",this.placeholder||""),this.#e.length?(this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","listbox"),this.setAttribute("aria-expanded",String(!!this.hasAttribute("suggesting")))):(this.setAttribute("role","group"),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded")),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.placeholder||"Tags"))}set value(t){Mt(()=>{let e=Array.isArray(t)?t.map(n=>String(n??"")):typeof t=="string"?this.#j(t)||[]:[],i=this.#t.slice();this.#t=e,this.#w(),this.#k(),this.#v(),this.#B(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){Mt(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#P(),this.render()})}get suggestions(){return this.#e.slice()}set validateFn(t){this.#i=typeof t=="function"?t:null}get validateFn(){return this.#i}addToken(t){return this.#L(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#Z(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#w(),this.#k(),this.#v(),this.#B(t,[],"programmatic")}focus(){this.#a?.focus()}#O(){if(this.querySelector(":scope > [data-chip-list]")){this.#S(),this.#b();return}let t=this.querySelector(':scope > template[slot="chip"]'),e=`${this.#h}-suggestions`,i=`${this.#h}-input`;this.innerHTML=`
308
308
  <div data-chip-list role="list" aria-label="Tags"></div>
309
309
  <span data-inline-input
310
310
  id="${i}"
@@ -319,20 +319,20 @@ Correct shape for <chart-ui x="label" y="value">:
319
319
  <icon-ui name="circle-notch"></icon-ui>
320
320
  </span>
321
321
  <div data-suggestions id="${e}" role="listbox" hidden></div>
322
- `,t&&this.appendChild(t),this.#S(),this.#v()}#S(){this.#o=this.querySelector(":scope > [data-chip-list]"),this.#a=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#v(){this.#a&&(this.#a.addEventListener("input",this.#u),this.#a.addEventListener("keydown",this.#d),this.#a.addEventListener("paste",this.#f)),this.#o&&this.#o.addEventListener("remove",this.#p),this.#l&&this.#l.addEventListener("click",this.#O),this.addEventListener("mousedown",this.#m)}#x(){this.#a&&(this.#a.removeEventListener("input",this.#u),this.#a.removeEventListener("keydown",this.#d),this.#a.removeEventListener("paste",this.#f)),this.#o&&this.#o.removeEventListener("remove",this.#p),this.#l&&this.#l.removeEventListener("click",this.#O),this.removeEventListener("mousedown",this.#m)}#w(){if(!this.#o)return;let t=this.querySelector(':scope > template[slot="chip"]'),e=t?"custom":"default",i=Array.from(this.#o.children);for(let n=0;n<this.#t.length;n++){let r=this.#t[n],o=i[n];if(o&&o.dataset.chipMode===e&&o.dataset.chipValue===r){o.setAttribute("data-index",String(n)),t||(this.readonly||this.disabled?o.removeAttribute("removable"):o.setAttribute("removable",""));continue}let l=t?this.#$(t,r,n):this.#b(r,n);o?this.#o.replaceChild(l,o):this.#o.appendChild(l),i[n]=l}for(let n=this.#t.length;n<i.length;n++)i[n].remove()}#b(t,e){let i=document.createElement("tag-ui");return i.setAttribute("role","listitem"),i.setAttribute("text",t),this.readonly||this.disabled||i.setAttribute("removable",""),i.setAttribute("data-index",String(e)),i.dataset.chipMode="default",i.dataset.chipValue=t,i}#$(t,e,i){let n=t.content.cloneNode(!0);this.#C(n,e,i);let r=n.firstElementChild;return r?(r.setAttribute("role","listitem"),r.setAttribute("data-index",String(i)),r.dataset.chipMode="custom",r.dataset.chipValue=e,r):this.#b(e,i)}#C(t,e,i){let n=String(i),r=l=>l.replace(/\{\{value\}\}|\{\{index\}\}/g,h=>h==="{{value}}"?e:n),o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),a;for(;a=o.nextNode();)if(a.nodeType===Node.TEXT_NODE)a.data.includes("{{")&&(a.data=r(a.data));else for(let l of a.attributes)l.value.includes("{{")&&(l.value=r(l.value))}#P(){if(!this.#l)return;let t=this.#a?(this.#a.textContent||"").trim().toLowerCase():"",e=this.#e.filter(n=>!this.#t.includes(n)).filter(n=>!t||n.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((n,r)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${r}`),o.dataset.value=n,o.textContent=n,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#a?.removeAttribute("aria-activedescendant");for(let n of this.#l.children)n.removeAttribute("data-active")}#k(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#a)return;let t=!(this.#a.textContent||"").length;this.toggleAttribute("editing",!t)}#y(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#n)return;let t=this.#a.textContent||"";if(this.delimiter&&this.delimiter!=="enter"&&t.includes(this.delimiter)){let e=t.split(this.delimiter),i=e.pop(),n=!1;for(let r of e)r.length&&this.#R(r,"delimiter")&&(n=!0);this.#n=!0,this.#a.textContent=i||"",this.#n=!1,this.#D(),this.#k(),this.#P(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#k(),this.#P(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#T(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#a&&this.#a.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let n=this.#l?.children[this.#s];if(n){this.#R(n.dataset.value||"","suggestion");return}}i&&this.#R(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#Z(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#z(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#z(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#_())}#E(t){if(this.disabled||this.readonly)return;let e=t.clipboardData?.getData("text/plain")||"";if(!e||!this.pasteSplit)return;t.preventDefault();let i=new RegExp(`[${zI(this.pasteSplit)}]+`),n=e.split(i).map(o=>o.trim()).filter(Boolean);if(n.length===0)return;if(n.length===1){document.execCommand("insertText",!1,n[0]),this.#k(),this.#P();return}let r="";for(let o=0;o<n.length;o++){let a=n[o];!this.#R(a,"paste")&&o===n.length-1&&(r=a)}r&&(this.#n=!0,this.#a.textContent=r,this.#n=!1,this.#D(),this.#k(),this.#P())}#L(t){let e=t.target.closest("[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#Z(i,"chip-click"))}#Q(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#a&&(t.preventDefault(),this.#a?.focus(),this.#D())}#M(t){let e=t.target.closest('[role="option"]');e&&this.#R(e.dataset.value||"","suggestion")}#I(t){let e=this.normalize;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#R(t,e){if(this.disabled||this.readonly)return!1;let i=this.#I(t.trim());if(!i)return this.#F(),!1;if(i.length<this.minLength)return this.#q(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#q(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#F(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#q(i,"max"),!1;let n=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(n))return this.#q(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#X(i,o,e),!1;if(o===!1)return this.#q(i,"validator"),!1}catch{return this.#q(i,"validator"),!1}return this.#N(i,e),!0}#X(t,e,i){let n=++this.#r;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(r=>{if(!(n!==this.#r||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),r===!1){this.#q(t,"validator");return}this.#N(t,i)}},()=>{n!==this.#r||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#q(t,"validator"))})}#N(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#w(),this.#F(),this.#k(),this.#y(),this.#B(i,this.#t,e),e!=="programmatic"&&this.#a?.focus()}#Z(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),n=i.slice();n.splice(t,1),this.#t=n,this.#w(),this.#k(),this.#y(),this.#B(i,n,e),e!=="programmatic"&&this.#a?.focus()}#B(t,e,i){let n=new Set(t),r=new Set(e),o=e.filter(l=>!n.has(l)),a=t.filter(l=>!r.has(l));o.length===0&&a.length===0||this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e.slice(),added:o,removed:a,source:i}}))}#q(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#F(){this.#a&&(this.#n=!0,this.#a.textContent="",this.#n=!1,this.removeAttribute("editing"),this.#P())}#D(){if(!(!this.#a||!this.#a.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#a),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#z(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let n of e)n.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#a?.setAttribute("aria-activedescendant",i.id)}#_(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#a?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#j(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(n=>String(n??""))}catch{}return e.includes(",")?(this.#q(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#j(t);if(e){this.value=e;return}}super.syncValue(t)}};M();A("tags-input-ui",Yo);M();X();var Ul=class extends C{static properties={value:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},change:{type:String,default:"",reflect:!0},trend:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},bleed:{type:Boolean,default:!1,reflect:!0},band:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;static requiredIcons=["arrow-up","arrow-down"];#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.#i.querySelector(":scope > icon-ui[data-trend-icon]"),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("data-trend-icon",""),this.#s.hidden=!0,this.#i.appendChild(this.#s)),this.#n=this.#i.querySelector(":scope > [data-trend-text]"),this.#n||(this.#n=document.createElement("span"),this.#n.setAttribute("data-trend-text",""),this.#i.appendChild(this.#n)),this.#r=this.querySelector(':scope > [slot="icon"]'),this.#r||(this.#r=document.createElement("icon-ui"),this.#r.setAttribute("slot","icon"),this.appendChild(this.#r))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" corner-radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" corner-radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#r.setAttribute("name",this.icon),this.#r.hidden=!1):this.#r.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.childNodes.length===2&&this.#i.firstChild===this.#s&&this.#i.lastChild===this.#n||(this.#i.textContent="",this.#i.appendChild(this.#s),this.#i.appendChild(this.#n)),this.#n.textContent=this.change,this.trend==="up"?(this.#s.setAttribute("name","arrow-up"),this.#s.hidden=!1):this.trend==="down"?(this.#s.setAttribute("name","arrow-down"),this.#s.hidden=!1):this.#s.hidden=!0,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#r.setAttribute("name",this.icon),this.#r.hidden=!1):this.#r.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=null}};A("stat-ui",Ul);X();var Ho=class extends C{static properties={};static template=()=>null;#t=!1;connected(){this.hasAttribute("role")||this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),n=i?e.indexOf(i):-1,r=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),r(n+1);break;case"ArrowUp":t.preventDefault(),r(n-1);break;case"Home":t.preventDefault(),r(0);break;case"End":t.preventDefault(),r(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},Go=class extends C{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t(t){return t.dataset.actionItemStamped="1",t}#e(t){return t?.dataset?.actionItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}connected(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#s(),this.#n()}#s(){if(!this.#i('[slot="text"]')){if(this.icon&&!this.#i('[slot="icon"]')){let t=this.#t(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#t(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}if(this.description&&!this.#i('[slot="subtitle"]')){let t=this.#t(document.createElement("span"));t.setAttribute("slot","subtitle"),t.textContent=this.description,this.appendChild(t)}}}#n(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let n=this.#t(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text);let i=this.#i('[slot="subtitle"]');if(this.description)if(i)this.#e(i)&&(i.textContent=this.description);else{let n=this.#t(document.createElement("span"));n.setAttribute("slot","subtitle"),n.textContent=this.description,this.appendChild(n)}else this.#e(i)&&i.remove();this.#n()}};M();A("action-list-ui",Ho),A("action-item-ui",Go);X();var Ko=class extends C{static properties={icon:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"",reflect:!0},minimal:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s(t){return t.dataset.emptyStateStamped="1",t}#n(t){return t?.dataset?.emptyStateStamped==="1"}connected(){this.#t=this.querySelector(':scope > [slot="icon"]'),this.#t||(this.#t=this.#s(document.createElement("icon-ui")),this.#t.setAttribute("slot","icon"),this.minimal||this.#t.setAttribute("size","lg"),this.insertBefore(this.#t,this.firstChild)),this.#e=this.querySelector(':scope > [slot="heading"]'),this.#e||(this.#e=this.#s(document.createElement("span")),this.#e.setAttribute("slot","heading"),this.insertBefore(this.#e,this.querySelector('[slot="action"]'))),this.#i=this.querySelector(':scope > [slot="description"]'),this.#i||(this.#i=this.#s(document.createElement("span")),this.#i.setAttribute("slot","description"),this.insertBefore(this.#i,this.querySelector('[slot="action"]')))}render(){this.#t&&(this.#n(this.#t)&&(this.icon?(this.#t.setAttribute("name",this.icon),this.#t.hidden=!1):this.#t.hidden=!0),this.#n(this.#e)&&(this.heading?(this.#e.textContent=this.heading,this.#e.hidden=!1):this.#e.hidden=!0),this.#n(this.#i)&&(this.description?(this.#i.textContent=this.description,this.#i.hidden=!1):this.#i.hidden=!0))}disconnected(){this.#t=null,this.#e=null,this.#i=null}};M();A("empty-state-ui",Ko);X();Ge();var BI=["S","M","T","W","T","F","S"],VI=["January","February","March","April","May","June","July","August","September","October","November","December"];function nA(s){return String(s).padStart(2,"0")}function PO(s,t,e){return`${s}-${nA(t+1)}-${nA(e)}`}function Ni(s){if(!s)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s).trim());return t?new Date(+t[1],+t[2]-1,+t[3]):null}function Yu(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Jo=class extends C{static requiredIcons=["caret-left","caret-right"];static properties={value:{type:String,default:"",reflect:!0},month:{type:String,default:"",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},rangeStart:{type:String,default:"",reflect:!0,attribute:"range-start"},rangeEnd:{type:String,default:"",reflect:!0,attribute:"range-end"}};static template=()=>null;#t=new Date().getFullYear();#e=new Date().getMonth();#i=null;#s=!1;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Calendar");let t=Ni(this.value);if(t)this.#t=t.getFullYear(),this.#e=t.getMonth();else{let e=/^(\d{4})-(\d{2})$/.exec(String(this.month||"").trim());e&&(this.#t=+e[1],this.#e=+e[2]-1)}this.#s||(this.#s=!0,this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#a))}disconnected(){this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#a),this.#s=!1}render(){let t=Ni(this.value);t&&(t.getFullYear()!==this.#t||t.getMonth()!==this.#e)&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#n()}navigate(t){for(this.#e+=t;this.#e>11;)this.#e-=12,this.#t++;for(;this.#e<0;)this.#e+=12,this.#t--;this.#i=null,this.#n()}focusDay(t){let e=new Date(this.#t,this.#e+1,0).getDate();t<1||t>e||(this.#i=t,this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.())}#n(){let t=this.#t,e=this.#e,i=new Date,n=Ni(this.value),r=Ni(this.min),o=Ni(this.max),a=Ni(this.rangeStart),l=Ni(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
322
+ `,t&&this.appendChild(t),this.#S(),this.#b()}#S(){this.#o=this.querySelector(":scope > [data-chip-list]"),this.#a=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#b(){this.#a&&(this.#a.addEventListener("input",this.#u),this.#a.addEventListener("keydown",this.#d),this.#a.addEventListener("paste",this.#f)),this.#o&&this.#o.addEventListener("remove",this.#p),this.#l&&this.#l.addEventListener("click",this.#g),this.addEventListener("mousedown",this.#m)}#x(){this.#a&&(this.#a.removeEventListener("input",this.#u),this.#a.removeEventListener("keydown",this.#d),this.#a.removeEventListener("paste",this.#f)),this.#o&&this.#o.removeEventListener("remove",this.#p),this.#l&&this.#l.removeEventListener("click",this.#g),this.removeEventListener("mousedown",this.#m)}#w(){if(!this.#o)return;let t=this.querySelector(':scope > template[slot="chip"]'),e=t?"custom":"default",i=Array.from(this.#o.children);for(let n=0;n<this.#t.length;n++){let r=this.#t[n],o=i[n];if(o&&o.dataset.chipMode===e&&o.dataset.chipValue===r){o.setAttribute("data-index",String(n)),t||(this.readonly||this.disabled?o.removeAttribute("removable"):o.setAttribute("removable",""));continue}let l=t?this.#A(t,r,n):this.#y(r,n);o?this.#o.replaceChild(l,o):this.#o.appendChild(l),i[n]=l}for(let n=this.#t.length;n<i.length;n++)i[n].remove()}#y(t,e){let i=document.createElement("tag-ui");return i.setAttribute("role","listitem"),i.setAttribute("text",t),this.readonly||this.disabled||i.setAttribute("removable",""),i.setAttribute("data-index",String(e)),i.dataset.chipMode="default",i.dataset.chipValue=t,i}#A(t,e,i){let n=t.content.cloneNode(!0);this.#E(n,e,i);let r=n.firstElementChild;return r?(r.setAttribute("role","listitem"),r.setAttribute("data-index",String(i)),r.dataset.chipMode="custom",r.dataset.chipValue=e,r):this.#y(e,i)}#E(t,e,i){let n=String(i),r=l=>l.replace(/\{\{value\}\}|\{\{index\}\}/g,h=>h==="{{value}}"?e:n),o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),a;for(;a=o.nextNode();)if(a.nodeType===Node.TEXT_NODE)a.data.includes("{{")&&(a.data=r(a.data));else for(let l of a.attributes)l.value.includes("{{")&&(l.value=r(l.value))}#P(){if(!this.#l)return;let t=this.#a?(this.#a.textContent||"").trim().toLowerCase():"",e=this.#e.filter(n=>!this.#t.includes(n)).filter(n=>!t||n.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((n,r)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${r}`),o.dataset.value=n,o.textContent=n,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#a?.removeAttribute("aria-activedescendant");for(let n of this.#l.children)n.removeAttribute("data-active")}#k(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#a)return;let t=!(this.#a.textContent||"").length;this.toggleAttribute("editing",!t)}#v(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#$(){if(this.#n)return;let t=this.#a.textContent||"";if(this.delimiter&&this.delimiter!=="enter"&&t.includes(this.delimiter)){let e=t.split(this.delimiter),i=e.pop(),n=!1;for(let r of e)r.length&&this.#L(r,"delimiter")&&(n=!0);this.#n=!0,this.#a.textContent=i||"",this.#n=!1,this.#D(),this.#k(),this.#P(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#k(),this.#P(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#T(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#a&&this.#a.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let n=this.#l?.children[this.#s];if(n){this.#L(n.dataset.value||"","suggestion");return}}i&&this.#L(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#Z(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#z(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#z(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#_())}#C(t){if(this.disabled||this.readonly)return;let e=t.clipboardData?.getData("text/plain")||"";if(!e||!this.pasteSplit)return;t.preventDefault();let i=new RegExp(`[${zI(this.pasteSplit)}]+`),n=e.split(i).map(o=>o.trim()).filter(Boolean);if(n.length===0)return;if(n.length===1){document.execCommand("insertText",!1,n[0]),this.#k(),this.#P();return}let r="";for(let o=0;o<n.length;o++){let a=n[o];!this.#L(a,"paste")&&o===n.length-1&&(r=a)}r&&(this.#n=!0,this.#a.textContent=r,this.#n=!1,this.#D(),this.#k(),this.#P())}#M(t){let e=t.target.closest("[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#Z(i,"chip-click"))}#Q(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#a&&(t.preventDefault(),this.#a?.focus(),this.#D())}#R(t){let e=t.target.closest('[role="option"]');e&&this.#L(e.dataset.value||"","suggestion")}#I(t){let e=this.normalize;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#L(t,e){if(this.disabled||this.readonly)return!1;let i=this.#I(t.trim());if(!i)return this.#F(),!1;if(i.length<this.minLength)return this.#q(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#q(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#F(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#q(i,"max"),!1;let n=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(n))return this.#q(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#X(i,o,e),!1;if(o===!1)return this.#q(i,"validator"),!1}catch{return this.#q(i,"validator"),!1}return this.#N(i,e),!0}#X(t,e,i){let n=++this.#r;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(r=>{if(!(n!==this.#r||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),r===!1){this.#q(t,"validator");return}this.#N(t,i)}},()=>{n!==this.#r||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#q(t,"validator"))})}#N(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#w(),this.#F(),this.#k(),this.#v(),this.#B(i,this.#t,e),e!=="programmatic"&&this.#a?.focus()}#Z(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),n=i.slice();n.splice(t,1),this.#t=n,this.#w(),this.#k(),this.#v(),this.#B(i,n,e),e!=="programmatic"&&this.#a?.focus()}#B(t,e,i){let n=new Set(t),r=new Set(e),o=e.filter(l=>!n.has(l)),a=t.filter(l=>!r.has(l));o.length===0&&a.length===0||this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e.slice(),added:o,removed:a,source:i}}))}#q(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#F(){this.#a&&(this.#n=!0,this.#a.textContent="",this.#n=!1,this.removeAttribute("editing"),this.#P())}#D(){if(!(!this.#a||!this.#a.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#a),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#z(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let n of e)n.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#a?.setAttribute("aria-activedescendant",i.id)}#_(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#a?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#j(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(n=>String(n??""))}catch{}return e.includes(",")?(this.#q(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#j(t);if(e){this.value=e;return}}super.syncValue(t)}};M();A("tags-input-ui",Yo);M();X();var Ul=class extends C{static properties={value:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},change:{type:String,default:"",reflect:!0},trend:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},bleed:{type:Boolean,default:!1,reflect:!0},band:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;static requiredIcons=["arrow-up","arrow-down"];#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.#i.querySelector(":scope > icon-ui[data-trend-icon]"),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("data-trend-icon",""),this.#s.hidden=!0,this.#i.appendChild(this.#s)),this.#n=this.#i.querySelector(":scope > [data-trend-text]"),this.#n||(this.#n=document.createElement("span"),this.#n.setAttribute("data-trend-text",""),this.#i.appendChild(this.#n)),this.#r=this.querySelector(':scope > [slot="icon"]'),this.#r||(this.#r=document.createElement("icon-ui"),this.#r.setAttribute("slot","icon"),this.appendChild(this.#r))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" corner-radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" corner-radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#r.setAttribute("name",this.icon),this.#r.hidden=!1):this.#r.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.childNodes.length===2&&this.#i.firstChild===this.#s&&this.#i.lastChild===this.#n||(this.#i.textContent="",this.#i.appendChild(this.#s),this.#i.appendChild(this.#n)),this.#n.textContent=this.change,this.trend==="up"?(this.#s.setAttribute("name","arrow-up"),this.#s.hidden=!1):this.trend==="down"?(this.#s.setAttribute("name","arrow-down"),this.#s.hidden=!1):this.#s.hidden=!0,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#r.setAttribute("name",this.icon),this.#r.hidden=!1):this.#r.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=null}};A("stat-ui",Ul);X();var Ho=class extends C{static properties={};static template=()=>null;#t=!1;connected(){this.hasAttribute("role")||this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),n=i?e.indexOf(i):-1,r=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),r(n+1);break;case"ArrowUp":t.preventDefault(),r(n-1);break;case"Home":t.preventDefault(),r(0);break;case"End":t.preventDefault(),r(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},Go=class extends C{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t(t){return t.dataset.actionItemStamped="1",t}#e(t){return t?.dataset?.actionItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}connected(){this.hasAttribute("role")||this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#s(),this.#n()}#s(){if(!this.#i('[slot="text"]')){if(this.icon&&!this.#i('[slot="icon"]')){let t=this.#t(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#t(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}if(this.description&&!this.#i('[slot="subtitle"]')){let t=this.#t(document.createElement("span"));t.setAttribute("slot","subtitle"),t.textContent=this.description,this.appendChild(t)}}}#n(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let n=this.#t(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text);let i=this.#i('[slot="subtitle"]');if(this.description)if(i)this.#e(i)&&(i.textContent=this.description);else{let n=this.#t(document.createElement("span"));n.setAttribute("slot","subtitle"),n.textContent=this.description,this.appendChild(n)}else this.#e(i)&&i.remove();this.#n()}};M();A("action-list-ui",Ho),A("action-item-ui",Go);X();var Ko=class extends C{static properties={icon:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"",reflect:!0},minimal:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s(t){return t.dataset.emptyStateStamped="1",t}#n(t){return t?.dataset?.emptyStateStamped==="1"}connected(){this.#t=this.querySelector(':scope > [slot="icon"]'),this.#t||(this.#t=this.#s(document.createElement("icon-ui")),this.#t.setAttribute("slot","icon"),this.minimal||this.#t.setAttribute("size","lg"),this.insertBefore(this.#t,this.firstChild)),this.#e=this.querySelector(':scope > [slot="heading"]'),this.#e||(this.#e=this.#s(document.createElement("span")),this.#e.setAttribute("slot","heading"),this.insertBefore(this.#e,this.querySelector('[slot="action"]'))),this.#i=this.querySelector(':scope > [slot="description"]'),this.#i||(this.#i=this.#s(document.createElement("span")),this.#i.setAttribute("slot","description"),this.insertBefore(this.#i,this.querySelector('[slot="action"]')))}render(){this.#t&&(this.#n(this.#t)&&(this.icon?(this.#t.setAttribute("name",this.icon),this.#t.hidden=!1):this.#t.hidden=!0),this.#n(this.#e)&&(this.heading?(this.#e.textContent=this.heading,this.#e.hidden=!1):this.#e.hidden=!0),this.#n(this.#i)&&(this.description?(this.#i.textContent=this.description,this.#i.hidden=!1):this.#i.hidden=!0))}disconnected(){this.#t=null,this.#e=null,this.#i=null}};M();A("empty-state-ui",Ko);X();Ge();var BI=["S","M","T","W","T","F","S"],VI=["January","February","March","April","May","June","July","August","September","October","November","December"];function nA(s){return String(s).padStart(2,"0")}function PO(s,t,e){return`${s}-${nA(t+1)}-${nA(e)}`}function Ni(s){if(!s)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s).trim());return t?new Date(+t[1],+t[2]-1,+t[3]):null}function Yu(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Jo=class extends C{static requiredIcons=["caret-left","caret-right"];static properties={value:{type:String,default:"",reflect:!0},month:{type:String,default:"",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},rangeStart:{type:String,default:"",reflect:!0,attribute:"range-start"},rangeEnd:{type:String,default:"",reflect:!0,attribute:"range-end"}};static template=()=>null;#t=new Date().getFullYear();#e=new Date().getMonth();#i=null;#s=!1;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Calendar");let t=Ni(this.value);if(t)this.#t=t.getFullYear(),this.#e=t.getMonth();else{let e=/^(\d{4})-(\d{2})$/.exec(String(this.month||"").trim());e&&(this.#t=+e[1],this.#e=+e[2]-1)}this.#s||(this.#s=!0,this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#a))}disconnected(){this.removeEventListener("click",this.#o),this.removeEventListener("keydown",this.#a),this.#s=!1}render(){let t=Ni(this.value);t&&(t.getFullYear()!==this.#t||t.getMonth()!==this.#e)&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#n()}navigate(t){for(this.#e+=t;this.#e>11;)this.#e-=12,this.#t++;for(;this.#e<0;)this.#e+=12,this.#t--;this.#i=null,this.#n()}focusDay(t){let e=new Date(this.#t,this.#e+1,0).getDate();t<1||t>e||(this.#i=t,this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.())}#n(){let t=this.#t,e=this.#e,i=new Date,n=Ni(this.value),r=Ni(this.min),o=Ni(this.max),a=Ni(this.rangeStart),l=Ni(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
323
323
  <button-ui variant="ghost" size="sm" icon="caret-left" data-cal-prev aria-label="Previous month" tabindex="-1"></button-ui>
324
324
  <span data-cal-title>${VI[e]} ${t}</span>
325
325
  <button-ui variant="ghost" size="sm" icon="caret-right" data-cal-next aria-label="Next month" tabindex="-1"></button-ui>
326
- </div>`;u+=`<div data-cal-weekdays>${BI.map(k=>`<span>${k}</span>`).join("")}</div>`;let d=new Date(t,e,1).getDay(),f=new Date(t,e+1,0).getDate(),p=new Date(t,e,0).getDate(),m=(k,b,E)=>{let $=PO(k.getFullYear(),k.getMonth(),k.getDate()),Q=Yu(k,i),T=!!(n&&Yu(k,n)),P=!!(h&&c&&k>h&&k<c),L=!!(h&&Yu(k,h)),I=!!(c&&Yu(k,c)),D=E||r&&k<r||o&&k>o,V=!E&&this.#i===b;return`<button-ui variant="ghost" ${["data-cal-day",E?"data-outside":`data-date="${$}"`,Q?"data-today":"",T?"data-selected":"",P?"data-in-range":"",L?"data-range-start":"",I?"data-range-end":"",D?"disabled":"",V?"data-focused":"",`tabindex="${V?"0":"-1"}"`].filter(Boolean).join(" ")} text="${b}"></button-ui>`};u+="<div data-cal-grid>";let g=e===0?11:e-1,O=e===0?t-1:t;for(let k=d-1;k>=0;k--){let b=p-k;u+=m(new Date(O,g,b),b,!0)}for(let k=1;k<=f;k++)u+=m(new Date(t,e,k),k,!1);let x=(7-(d+f)%7)%7,S=e===11?0:e+1,v=e===11?t+1:t;for(let k=1;k<=x;k++)u+=m(new Date(v,S,k),k,!0);u+="</div>",this.innerHTML=u}#r(t){this.disabled||this.readonly||(this.value=t,this.#n(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t}})))}#o=t=>{if(this.disabled)return;let e=te(t.target)?t.target:null;if(!e)return;if(e.closest("[data-cal-prev]")){t.stopPropagation(),this.navigate(-1);return}if(e.closest("[data-cal-next]")){t.stopPropagation(),this.navigate(1);return}let r=e.closest("[data-cal-day][data-date]:not([disabled])");r&&(t.stopPropagation(),this.#r(r.dataset.date))};#a=t=>{if(this.disabled)return;if(t.key==="Enter"||t.key===" "){if(this.#i){t.preventDefault();let i=PO(this.#t,this.#e,this.#i),n=new Date(this.#t,this.#e,this.#i),r=Ni(this.min),o=Ni(this.max);(!r||n>=r)&&(!o||n<=o)&&this.#r(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#t,this.#e+1,0).getDate(),n=(this.#i||1)+e[t.key];if(n<1){this.navigate(-1);let o=new Date(this.#t,this.#e+1,0).getDate();this.#i=o+n}else n>i?(this.navigate(1),this.#i=n-i):this.#i=n;this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{focusDate:PO(this.#t,this.#e,this.#i)}}));return}if(t.key==="PageUp"){t.preventDefault(),this.navigate(-1);return}if(t.key==="PageDown"){t.preventDefault(),this.navigate(1);return}if(t.key==="Home"){t.preventDefault(),this.#i=1,this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}if(t.key==="End"){t.preventDefault(),this.#i=new Date(this.#t,this.#e+1,0).getDate(),this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}}};M();A("calendar-grid-ui",Jo);var rA=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],oA=["January","February","March","April","May","June","July","August","September","October","November","December"];function QO(s){return String(s).padStart(2,"0")}function _I(s){if(!s)return null;let[t,e,i]=s.split("-").map(Number);return isNaN(t)||isNaN(e)||isNaN(i)?null:new Date(t,e-1,i)}function on(s){if(!s)return null;let t=String(s).trim(),e=/^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?)$/.exec(t);return e?{date:e[1],time:e[2]}:null}function TO(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let n=QO(Number(i[1])),r=i[2],o=i[3]||"00";return e==="second"?`${s}T${n}:${r}:${o}`:`${s}T${n}:${r}`}function jI(s,t){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s||"");if(!e)return"";let i=+e[1],n=+e[2]-1,r=+e[3];switch(t){case"long":return`${oA[n]} ${r}, ${i}`;case"iso":return s;default:return`${rA[n]} ${r}, ${i}`}}function WI(s,t,e){let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(s||"");if(!i)return"";let n=+i[1],r=i[2],o=i[3],a,l="";if(e==="h12"){let c=n>=12,u=n%12||12;a=QO(u),l=c?" PM":" AM"}else a=QO(n);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${r}${h}${l}`}var ta=class extends _{static labelDeprecated=!0;static requiredIcons=["calendar"];static properties={..._.properties,placeholder:{type:String,default:"Select date...",reflect:!0},format:{type:String,default:"short",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},precision:{type:String,default:"date",reflect:!0},step:{type:Number,default:60,reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},locale:{type:String,default:"",reflect:!1},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#n=null;#r=null;#o=!1;#a=null;#l=null;#c=!1;#h=null;#u="programmatic";#d="programmatic";get#f(){return this.precision==="minute"||this.precision==="second"}#p=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#i?.value||"";if(!e)return;if(!this.#f){this.value=e,this.syncValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}this.#h||(this.#h={date:"",time:""}),this.#h.date=e;let i=on(this.value),n=this.#h.time||i?.time||"",r=n?TO(e,n,this.precision):`${e}T`;this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:r}})),n?this.#S({date:e,time:n}):queueMicrotask(()=>{if(!this.open)return;this.#r?.querySelector?.('[data-segment="hour"]')?.focus?.()})};#m=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#r?.value||"";if(!e)return;this.#h||(this.#h={date:"",time:""}),this.#h.time=e;let i=on(this.value),n=this.#h.date||i?.date||"";n?this.#S({date:n,time:e}):this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:`T${e}`}}))};#O=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"",i=on(this.value),n=this.#h?.date||i?.date||"",r=n&&e?TO(n,e,this.precision):e?`T${e}`:"";this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:r}}))};#g=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:t.detail?.reason||"pane"}}))};#S(t){if(!t||!t.date||!t.time)return;let e=TO(t.date,t.time,this.precision);if(!e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"parse"}}));return}if(this.min&&e<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"below-min"}}));return}if(this.max&&e>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"above-max"}}));return}this.value=e,this.#h=null,this.syncValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e}}))}syncValue(t){let e=t??this.value??"";this.internals.setFormValue(e),this.#v(e)}#v(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||(this.#f?"Please select a date and time.":"Please select a date."),this),!1):t?this.#f&&!on(t)?(this.internals.setValidity({badInput:!0},"Invalid date or time format.",this),!1):this.min&&t<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable ${this.#f?"datetime":"date"} is ${this.min}.`,this),!1):this.max&&t>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable ${this.#f?"datetime":"date"} is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","group"),this.addEventListener("click",this.#w),this.addEventListener("keydown",this.#$)}render(){if(!this.querySelector('[slot="trigger"]'))this.innerHTML=`
326
+ </div>`;u+=`<div data-cal-weekdays>${BI.map(k=>`<span>${k}</span>`).join("")}</div>`;let d=new Date(t,e,1).getDay(),f=new Date(t,e+1,0).getDate(),p=new Date(t,e,0).getDate(),m=(k,b,E)=>{let $=PO(k.getFullYear(),k.getMonth(),k.getDate()),Q=Yu(k,i),T=!!(n&&Yu(k,n)),P=!!(h&&c&&k>h&&k<c),L=!!(h&&Yu(k,h)),I=!!(c&&Yu(k,c)),D=E||r&&k<r||o&&k>o,V=!E&&this.#i===b;return`<button-ui variant="ghost" ${["data-cal-day",E?"data-outside":`data-date="${$}"`,Q?"data-today":"",T?"data-selected":"",P?"data-in-range":"",L?"data-range-start":"",I?"data-range-end":"",D?"disabled":"",V?"data-focused":"",`tabindex="${V?"0":"-1"}"`].filter(Boolean).join(" ")} text="${b}"></button-ui>`};u+="<div data-cal-grid>";let g=e===0?11:e-1,O=e===0?t-1:t;for(let k=d-1;k>=0;k--){let b=p-k;u+=m(new Date(O,g,b),b,!0)}for(let k=1;k<=f;k++)u+=m(new Date(t,e,k),k,!1);let x=(7-(d+f)%7)%7,S=e===11?0:e+1,v=e===11?t+1:t;for(let k=1;k<=x;k++)u+=m(new Date(v,S,k),k,!0);u+="</div>",this.innerHTML=u}#r(t){this.disabled||this.readonly||(this.value=t,this.#n(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t}})))}#o=t=>{if(this.disabled)return;let e=te(t.target)?t.target:null;if(!e)return;if(e.closest("[data-cal-prev]")){t.stopPropagation(),this.navigate(-1);return}if(e.closest("[data-cal-next]")){t.stopPropagation(),this.navigate(1);return}let r=e.closest("[data-cal-day][data-date]:not([disabled])");r&&(t.stopPropagation(),this.#r(r.dataset.date))};#a=t=>{if(this.disabled)return;if(t.key==="Enter"||t.key===" "){if(this.#i){t.preventDefault();let i=PO(this.#t,this.#e,this.#i),n=new Date(this.#t,this.#e,this.#i),r=Ni(this.min),o=Ni(this.max);(!r||n>=r)&&(!o||n<=o)&&this.#r(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#t,this.#e+1,0).getDate(),n=(this.#i||1)+e[t.key];if(n<1){this.navigate(-1);let o=new Date(this.#t,this.#e+1,0).getDate();this.#i=o+n}else n>i?(this.navigate(1),this.#i=n-i):this.#i=n;this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{focusDate:PO(this.#t,this.#e,this.#i)}}));return}if(t.key==="PageUp"){t.preventDefault(),this.navigate(-1);return}if(t.key==="PageDown"){t.preventDefault(),this.navigate(1);return}if(t.key==="Home"){t.preventDefault(),this.#i=1,this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}if(t.key==="End"){t.preventDefault(),this.#i=new Date(this.#t,this.#e+1,0).getDate(),this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.();return}}};M();A("calendar-grid-ui",Jo);var rA=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],oA=["January","February","March","April","May","June","July","August","September","October","November","December"];function QO(s){return String(s).padStart(2,"0")}function _I(s){if(!s)return null;let[t,e,i]=s.split("-").map(Number);return isNaN(t)||isNaN(e)||isNaN(i)?null:new Date(t,e-1,i)}function on(s){if(!s)return null;let t=String(s).trim(),e=/^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?)$/.exec(t);return e?{date:e[1],time:e[2]}:null}function TO(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let n=QO(Number(i[1])),r=i[2],o=i[3]||"00";return e==="second"?`${s}T${n}:${r}:${o}`:`${s}T${n}:${r}`}function jI(s,t){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s||"");if(!e)return"";let i=+e[1],n=+e[2]-1,r=+e[3];switch(t){case"long":return`${oA[n]} ${r}, ${i}`;case"iso":return s;default:return`${rA[n]} ${r}, ${i}`}}function WI(s,t,e){let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(s||"");if(!i)return"";let n=+i[1],r=i[2],o=i[3],a,l="";if(e==="h12"){let c=n>=12,u=n%12||12;a=QO(u),l=c?" PM":" AM"}else a=QO(n);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${r}${h}${l}`}var ta=class extends _{static labelDeprecated=!0;static requiredIcons=["calendar"];static properties={..._.properties,placeholder:{type:String,default:"Select date...",reflect:!0},format:{type:String,default:"short",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},precision:{type:String,default:"date",reflect:!0},step:{type:Number,default:60,reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},locale:{type:String,default:"",reflect:!1},placement:{type:String,default:"bottom",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#n=null;#r=null;#o=!1;#a=null;#l=null;#c=!1;#h=null;#u="programmatic";#d="programmatic";get#f(){return this.precision==="minute"||this.precision==="second"}#p=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#i?.value||"";if(!e)return;if(!this.#f){this.value=e,this.syncValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}this.#h||(this.#h={date:"",time:""}),this.#h.date=e;let i=on(this.value),n=this.#h.time||i?.time||"",r=n?TO(e,n,this.precision):`${e}T`;this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:r}})),n?this.#S({date:e,time:n}):queueMicrotask(()=>{if(!this.open)return;this.#r?.querySelector?.('[data-segment="hour"]')?.focus?.()})};#m=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#r?.value||"";if(!e)return;this.#h||(this.#h={date:"",time:""}),this.#h.time=e;let i=on(this.value),n=this.#h.date||i?.date||"";n?this.#S({date:n,time:e}):this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:`T${e}`}}))};#g=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"",i=on(this.value),n=this.#h?.date||i?.date||"",r=n&&e?TO(n,e,this.precision):e?`T${e}`:"";this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:r}}))};#O=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:t.detail?.reason||"pane"}}))};#S(t){if(!t||!t.date||!t.time)return;let e=TO(t.date,t.time,this.precision);if(!e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"parse"}}));return}if(this.min&&e<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"below-min"}}));return}if(this.max&&e>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:e,reason:"above-max"}}));return}this.value=e,this.#h=null,this.syncValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e}}))}syncValue(t){let e=t??this.value??"";this.internals.setFormValue(e),this.#b(e)}#b(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||(this.#f?"Please select a date and time.":"Please select a date."),this),!1):t?this.#f&&!on(t)?(this.internals.setValidity({badInput:!0},"Invalid date or time format.",this),!1):this.min&&t<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable ${this.#f?"datetime":"date"} is ${this.min}.`,this),!1):this.max&&t>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable ${this.#f?"datetime":"date"} is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","group"),this.addEventListener("click",this.#w),this.addEventListener("keydown",this.#A)}render(){if(!this.querySelector('[slot="trigger"]'))this.innerHTML=`
327
327
  <span slot="trigger">
328
328
  <span slot="display">${this.#x()}</span>
329
329
  <icon-ui name="calendar" slot="caret"></icon-ui>
330
330
  </span>
331
- `,this.#e=this.querySelector('[slot="trigger"]'),this.#t=document.createElement("div"),this.#t.setAttribute("slot","popover"),this.#t.setAttribute("popover","manual"),this.appendChild(this.#t);else{let n=this.querySelector('[slot="display"]');n&&(n.textContent=this.#x())}if(this.#t||(this.#t=this.querySelector('[slot="popover"]')),this.#e||(this.#e=this.querySelector('[slot="trigger"]')),this.#t&&!this.#i&&(this.#i=this.#t.querySelector("calendar-grid-ui"),this.#i||(this.#i=document.createElement("calendar-grid-ui"),this.#t.appendChild(this.#i))),this.#i&&!this.#s&&(this.#i.addEventListener("change",this.#p),this.#s=!0),this.#t&&(this.#f?(this.#n||(this.#n=this.#t.querySelector("[data-pane-divider]"),this.#n||(this.#n=document.createElement("divider-ui"),this.#n.setAttribute("data-pane-divider",""),this.#n.setAttribute("vertical",""),this.#t.appendChild(this.#n))),this.#r||(this.#r=this.#t.querySelector("[data-time-pane]"),this.#r||(this.#r=document.createElement("time-picker-ui"),this.#r.setAttribute("data-time-pane",""),this.#t.appendChild(this.#r))),this.#o||(this.#r.addEventListener("change",this.#m),this.#r.addEventListener("input",this.#O),this.#r.addEventListener("invalid",this.#g),this.#o=!0)):(this.#r||this.#n)&&(this.#o&&(this.#r.removeEventListener("change",this.#m),this.#r.removeEventListener("input",this.#O),this.#r.removeEventListener("invalid",this.#g),this.#o=!1),this.#r?.remove(),this.#n?.remove(),this.#r=null,this.#n=null,this.#h=null)),this.#i){let n=this.#f?on(this.value):null,r=this.#f?this.#h?.date??n?.date??"":this.value||"";this.#i.value=r;let o=this.#f?this.min?this.min.slice(0,10):"":this.min,a=this.#f?this.max?this.max.slice(0,10):"":this.max;o?this.#i.setAttribute("min",o):this.#i.removeAttribute("min"),a?this.#i.setAttribute("max",a):this.#i.removeAttribute("max"),this.#i.toggleAttribute("disabled",!!this.disabled),this.#i.toggleAttribute("readonly",!!this.readonly)}if(this.#f&&this.#r){let n=on(this.value),r=this.#h?.time??n?.time??"";this.#r.setAttribute("precision",this.precision),this.#r.setAttribute("step",String(this.step)),this.hourcycle?this.#r.setAttribute("hour-cycle",this.hourcycle):this.#r.removeAttribute("hour-cycle"),this.locale?this.#r.setAttribute("locale",this.locale):this.#r.removeAttribute("locale");let o=this.#h?.date??n?.date??"",a=this.min?this.min.slice(11):"",l=this.max?this.max.slice(11):"";a&&o===this.min.slice(0,10)?this.#r.setAttribute("min",a):this.#r.removeAttribute("min"),l&&o===this.max.slice(0,10)?this.#r.setAttribute("max",l):this.#r.removeAttribute("max"),this.#r.value!==r&&(this.#r.value=r),this.#r.toggleAttribute("disabled",!!this.disabled),this.#r.toggleAttribute("readonly",!!this.readonly)}let t=this.querySelector(':scope > [slot="footer"]');t&&this.#t&&t.parentElement!==this.#t&&this.#t.appendChild(t),this.open&&(this.disabled||this.readonly)&&(this.open=!1);let e=this.open&&!this.#c,i=!this.open&&this.#c;this.open?(this.#t?.showPopover?.(),this.#a=mt(this.#e,this.#t,{placement:this.getAttribute("placement")||"bottom",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,!(!this.isConnected||!this.open)&&document.addEventListener("pointerdown",this.#b,{once:!0})}),e&&queueMicrotask(()=>{if(!this.open||!this.#i)return;let r=this.#i.querySelector("[data-cal-day][data-selected]:not([data-outside])")||this.#i.querySelector("[data-cal-day]:not([disabled]):not([data-outside])"),o=r&&Number(r.dataset.date?.split("-")[2]);o&&this.#i.focusDay(o)}),e&&this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:this.#u}}))):(this.#a?.(),this.#a=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.#t?.hidePopover?.(),document.removeEventListener("pointerdown",this.#b),i&&this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:this.#d}}))),this.#c=this.open}#x(){if(!this.value)return this.placeholder;if(this.#f){let e=on(this.value);if(!e)return this.value;let i=jI(e.date,this.format),n=WI(e.time,this.precision,this.hourcycle);return!i||!n?this.placeholder:`${i} ${n}`}let t=_I(this.value);if(!t)return this.value;switch(this.format){case"long":return`${oA[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`;case"iso":return this.value;default:return`${rA[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}}#w=t=>{if(!(this.disabled||this.readonly)){if(this.#t&&t.composedPath().includes(this.#t)){let e=t.target.closest?.("[data-action]");if(e&&this.contains(e)){let i=e.dataset.action;i==="apply"?(this.#S({date:this.#h?.date??this.#i?.value??"",time:this.#h?.time??this.#r?.value??""}),this.#d="apply",this.open=!1):i==="cancel"&&(this.#h=null,this.#d="cancel",this.open=!1)}return}this.open?(this.#d="outside",this.open=!1):(this.#u="click",this.open=!0)}};#b=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.#d="outside",this.open=!1)};#$=t=>{if(!(this.disabled||this.readonly)){if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#u="keyboard",this.open=!0);return}t.key==="Escape"&&(t.preventDefault(),this.#d="escape",this.open=!1)}};disconnected(){super.disconnected(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.removeEventListener("click",this.#w),this.removeEventListener("keydown",this.#$),document.removeEventListener("pointerdown",this.#b),this.#i&&this.#s&&this.#i.removeEventListener("change",this.#p),this.#r&&this.#o&&(this.#r.removeEventListener("change",this.#m),this.#r.removeEventListener("input",this.#O),this.#r.removeEventListener("invalid",this.#g)),this.#s=!1,this.#o=!1,this.#a?.(),this.#a=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null,this.#i=null,this.#n=null,this.#r=null,this.#h=null,this.#c=!1}};M();A("calendar-picker-ui",ta);mi();var FI=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],UI=["January","February","March","April","May","June","July","August","September","October","November","December"];function LO(s){return String(s).padStart(2,"0")}function He(s){return s?`${s.getFullYear()}-${LO(s.getMonth()+1)}-${LO(s.getDate())}`:""}function MO(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}function zi(s){if(s==null)return null;if(typeof s=="object")return!s.from||!s.to?null:{from:String(s.from),to:String(s.to)};if(typeof s!="string"||!s.trim())return null;try{let t=JSON.parse(s);if(t&&t.from&&t.to)return{from:String(t.from),to:String(t.to)}}catch{}return null}function aA(s){return s?s.from<=s.to:!1}function lA(s,t){let e=MO(s);if(!e)return"";switch(t){case"long":return`${UI[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${FI[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function YI(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=He(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),He(l)},n=He(new Date(t.getFullYear(),t.getMonth(),1)),r=He(new Date(t.getFullYear(),t.getMonth()+1,0)),o=He(new Date(t.getFullYear(),0,1));return[{label:"Today",range:{from:e,to:e}},{label:"Last 7 days",range:{from:i(6),to:e}},{label:"Last 30 days",range:{from:i(29),to:e}},{label:"This month",range:{from:n,to:r}},{label:"Year to date",range:{from:o,to:e}}]}function HI(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var ea=class extends _{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down"];static get properties(){return{..._.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" icon-trailing="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#n=!1;#r=null;#o=null;#a=null;#l=null;#c=null;#h=null;get rangeValue(){return zi(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return zi(this.compareValue)}set rangeCompareValue(t){t==null?this.compareValue="":this.compareValue=JSON.stringify({from:String(t.from),to:String(t.to)})}get presets(){return Array.isArray(this.#t)?this.#t:YI()}set presets(t){Mt(()=>{this.#t=Array.isArray(t)?t.slice():null,this.isConnected&&this.#p()})}open$(){this.open=!0}close$(){this.open=!1}openPopover(){this.disabled||this.readonly||this.open||(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.comparison&&(this.compareValue=""),this.#e=null,this.syncValue("")}applyPreset(t){let e=this.presets.find(i=>i.label===t);return!e||!e.range?!1:(this.#$(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=zi(e);if(this.comparison&&this.name){let n=new FormData;i&&n.append(this.name,e),zi(this.compareValue)&&n.append(`${this.name}-compare`,this.compareValue),this.internals.setFormValue(n)}else this.internals.setFormValue(i?e:"");this.#u(i)}#u(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date range.",this),!1):t&&!aA(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#d(),this.#r.addEventListener("click",this.#O),this.#r.addEventListener("keydown",this.#g,!0),this.#o.addEventListener("click",this.#S),this.#o.addEventListener("keydown",this.#v),this.#l.addEventListener("change",this.#w),this.#c.addEventListener("change",this.#w)),this.syncValue()}disconnected(){super.disconnected(),this.#r&&(this.#r.removeEventListener("click",this.#O),this.#r.removeEventListener("keydown",this.#g,!0)),this.#o&&(this.#o.removeEventListener("click",this.#S),this.#o.removeEventListener("keydown",this.#v),this.#o.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#w),this.#c&&this.#c.removeEventListener("change",this.#w),document.removeEventListener("pointerdown",this.#b),document.removeEventListener("keydown",this.#x),this.#h?.(),this.#h=null,this.#s=!1,this.#n=!1,this.#r=null,this.#o=null,this.#a=null,this.#l=null,this.#c=null}#d(){if(this.#r=this.ensure("trigger"),this.#o=this.ensure("popover"),this.id&&this.#o.setAttribute("aria-labelledby",this.id),!this.#o.querySelector(":scope > [data-calendar-area]")){let n=this.constructor._pp.calArea.cloneNode(!0);this.#o.appendChild(n)}let t=lt(this,"presets")[0];if(t&&t.parentElement!==this.#o)this.#o.appendChild(t),this.#a=t;else if(!this.noPresets&&!t){if(!this.#o.querySelector(":scope > [data-preset-rail]")){let n=this.constructor._pp.presets.cloneNode(!0);this.#o.insertBefore(n,this.#o.querySelector(":scope > [data-calendar-area]"))}this.#a=this.#o.querySelector(":scope > [data-preset-rail]")}let e=this.#o.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let n=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(n)}if(!e.querySelector(":scope > [data-cal-to]")){let n=this.constructor._pp.calTo.cloneNode(!0),r=zi(this.value)?.from,o,a;if(r){let[l,h]=r.split("-").map(Number);o=l,a=h-1}else{let l=new Date;o=l.getFullYear(),a=l.getMonth()}a+=1,a>11&&(a=0,o+=1),n.setAttribute("month",`${o}-${LO(a+1)}`),e.appendChild(n)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=lt(this,"footer")[0];i&&i.parentElement!==this.#o&&this.#o.appendChild(i)}render(){if(!this.#r)return;let t=this.#f();this.#r.setAttribute("text",t),this.#r.toggleAttribute("data-has-value",t!==this.placeholder),this.#r.toggleAttribute("disabled",this.disabled),this.#r.setAttribute("aria-haspopup","dialog"),this.#r.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let e=zi(this.value),i=this.#e,n=i?i.from:e?.from||"",r=i?i.to:e?.to||"",o=a=>{n?a.setAttribute("range-start",n):a.removeAttribute("range-start"),r?a.setAttribute("range-end",r):a.removeAttribute("range-end")};this.#l&&(this.min&&this.#l.setAttribute("min",this.min),this.max&&this.#l.setAttribute("max",this.max),this.#l.value=n,o(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=r,o(this.#c)),lt(this,"presets").length||(this.noPresets?(this.#a?.remove(),this.#a=null):(this.#a||this.#d(),this.#p())),this.#o&&(this.open&&!this.#n?!this.disabled&&!this.readonly?(this.#n=!0,this.#o.showPopover?.(),this.#h?.(),this.#h=mt(this.#r,this.#o,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#b),document.addEventListener("keydown",this.#x),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#n&&(this.#n=!1,this.#h?.(),this.#h=null,this.#o.hidePopover?.(),document.removeEventListener("pointerdown",this.#b),document.removeEventListener("keydown",this.#x),this.#r?.focus?.()))}#f(){let t=zi(this.value);if(!t)return this.placeholder;let e=lA(t.from,this.format),i=lA(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#p(){if(this.#a){this.#a.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#a.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#a.appendChild(t);for(let e of HI()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#a.appendChild(i)}}}}#m=!1;#O=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#g=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#S=t=>{if(this.readonly){let n=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),r=t.target.closest("[data-cal-day]");if(n||r){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let n=zi(this.value);if(!n)return;let r=this.#C(i.dataset.comparisonPresetLabel,n);r&&(this.rangeCompareValue=r);return}};#v=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#P();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#x=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#w=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"";if(!e)return;if(!this.#e?.from||this.#e.to||e<this.#e.from){this.#e={from:e,to:""},this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));return}this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from,to:e}}})),this.#$({from:this.#e.from,to:e})};#b=t=>{this.open&&(this.contains(t.target)||this.#o&&t.composedPath?.().includes(this.#o)||this.closePopover("outside"))};#$(t,e={}){if(!t||!t.from||!t.to)return;if(!aA(t)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"reversed"}}));return}if(this.min&&t.from<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"below-min"}}));return}if(this.max&&t.to>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"above-max"}}));return}let i=JSON.stringify({from:t.from,to:t.to});this.value=i,this.#e=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:{from:t.from,to:t.to},compareValue:zi(this.compareValue),presetLabel:e.presetLabel||null}}))}#C(t,e){let i=MO(e.from),n=MO(e.to);if(!i||!n)return null;let r=Math.round((n-i)/864e5)+1;switch(t){case"Previous period":{let o=new Date(i);o.setDate(o.getDate()-1);let a=new Date(o);return a.setDate(a.getDate()-(r-1)),{from:He(a),to:He(o)}}case"Same period last year":{let o=new Date(i);o.setFullYear(o.getFullYear()-1);let a=new Date(n);return a.setFullYear(a.getFullYear()-1),{from:He(o),to:He(a)}}case"Same period last month":{let o=new Date(i);o.setMonth(o.getMonth()-1);let a=new Date(n);return a.setMonth(a.getMonth()-1),{from:He(o),to:He(a)}}default:return null}}#P(){if(!this.#o)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#o.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};M();A("date-range-picker-ui",ea);Ge();var hA=23,cA=12,o7=1,uA=59,dA=59,GI=["hour","minute"];function Yl(s){if(!s)return null;let t=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(s).trim());if(!t)return null;let e=Number(t[1]),i=Number(t[2]),n=t[3]!=null?Number(t[3]):0;return!Number.isFinite(e)||e<0||e>23||!Number.isFinite(i)||i<0||i>59||!Number.isFinite(n)||n<0||n>59?null:{h:e,m:i,s:n}}function RO({h:s,m:t,s:e},i){let n=r=>String(r).padStart(2,"0");return i==="second"?`${n(s)}:${n(t)}:${n(e)}`:`${n(s)}:${n(t)}`}function ia({h:s,m:t,s:e}){return s*3600+t*60+e}function KI(s){try{let t=s||document?.documentElement?.lang||void 0,i=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions(),n=i.hourCycle||(i.hour12?"h12":"h23");return n==="h11"||n==="h12"?"h12":"h23"}catch{return"h23"}}var na=class extends _{static labelDeprecated=!1;static properties={..._.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#n(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:KI(this.locale)}get#r(){return this.#n==="h12"}get#o(){return this.precision==="second"}get#a(){return`${this.#n}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#g),this.addEventListener("focusin",this.#S),this.addEventListener("focusout",this.#v)}render(){this.#i&&this.#i!==this.#a&&this.#l(),this.#u(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#g),this.removeEventListener("focusin",this.#S),this.removeEventListener("focusout",this.#v),this.#t=null,this.#e=[],this.#s=null}clear(){this.value="",this.syncValue(""),this.#u()}stepUp(t,e=1){this.#f(t,1*(e|0||1))}stepDown(t,e=1){this.#f(t,-1*(e|0||1))}#l(){let t=this.#n,e=this.#o,i=this.#r,n=[...GI];e&&n.push("second"),i&&n.push("meridiem"),this.#e=n;let r=this.querySelector(':scope > [slot="prefix"]'),o=this.querySelector(':scope > [slot="suffix"]'),a=(c,u,d)=>`<span data-segment="${c}" role="spinbutton" tabindex="0"
331
+ `,this.#e=this.querySelector('[slot="trigger"]'),this.#t=document.createElement("div"),this.#t.setAttribute("slot","popover"),this.#t.setAttribute("popover","manual"),this.appendChild(this.#t);else{let n=this.querySelector('[slot="display"]');n&&(n.textContent=this.#x())}if(this.#t||(this.#t=this.querySelector('[slot="popover"]')),this.#e||(this.#e=this.querySelector('[slot="trigger"]')),this.#t&&!this.#i&&(this.#i=this.#t.querySelector("calendar-grid-ui"),this.#i||(this.#i=document.createElement("calendar-grid-ui"),this.#t.appendChild(this.#i))),this.#i&&!this.#s&&(this.#i.addEventListener("change",this.#p),this.#s=!0),this.#t&&(this.#f?(this.#n||(this.#n=this.#t.querySelector("[data-pane-divider]"),this.#n||(this.#n=document.createElement("divider-ui"),this.#n.setAttribute("data-pane-divider",""),this.#n.setAttribute("vertical",""),this.#t.appendChild(this.#n))),this.#r||(this.#r=this.#t.querySelector("[data-time-pane]"),this.#r||(this.#r=document.createElement("time-picker-ui"),this.#r.setAttribute("data-time-pane",""),this.#t.appendChild(this.#r))),this.#o||(this.#r.addEventListener("change",this.#m),this.#r.addEventListener("input",this.#g),this.#r.addEventListener("invalid",this.#O),this.#o=!0)):(this.#r||this.#n)&&(this.#o&&(this.#r.removeEventListener("change",this.#m),this.#r.removeEventListener("input",this.#g),this.#r.removeEventListener("invalid",this.#O),this.#o=!1),this.#r?.remove(),this.#n?.remove(),this.#r=null,this.#n=null,this.#h=null)),this.#i){let n=this.#f?on(this.value):null,r=this.#f?this.#h?.date??n?.date??"":this.value||"";this.#i.value=r;let o=this.#f?this.min?this.min.slice(0,10):"":this.min,a=this.#f?this.max?this.max.slice(0,10):"":this.max;o?this.#i.setAttribute("min",o):this.#i.removeAttribute("min"),a?this.#i.setAttribute("max",a):this.#i.removeAttribute("max"),this.#i.toggleAttribute("disabled",!!this.disabled),this.#i.toggleAttribute("readonly",!!this.readonly)}if(this.#f&&this.#r){let n=on(this.value),r=this.#h?.time??n?.time??"";this.#r.setAttribute("precision",this.precision),this.#r.setAttribute("step",String(this.step)),this.hourcycle?this.#r.setAttribute("hour-cycle",this.hourcycle):this.#r.removeAttribute("hour-cycle"),this.locale?this.#r.setAttribute("locale",this.locale):this.#r.removeAttribute("locale");let o=this.#h?.date??n?.date??"",a=this.min?this.min.slice(11):"",l=this.max?this.max.slice(11):"";a&&o===this.min.slice(0,10)?this.#r.setAttribute("min",a):this.#r.removeAttribute("min"),l&&o===this.max.slice(0,10)?this.#r.setAttribute("max",l):this.#r.removeAttribute("max"),this.#r.value!==r&&(this.#r.value=r),this.#r.toggleAttribute("disabled",!!this.disabled),this.#r.toggleAttribute("readonly",!!this.readonly)}let t=this.querySelector(':scope > [slot="footer"]');t&&this.#t&&t.parentElement!==this.#t&&this.#t.appendChild(t),this.open&&(this.disabled||this.readonly)&&(this.open=!1);let e=this.open&&!this.#c,i=!this.open&&this.#c;this.open?(this.#t?.showPopover?.(),this.#a=mt(this.#e,this.#t,{placement:this.getAttribute("placement")||"bottom",gap:4}),this.#l=requestAnimationFrame(()=>{this.#l=null,!(!this.isConnected||!this.open)&&document.addEventListener("pointerdown",this.#y,{once:!0})}),e&&queueMicrotask(()=>{if(!this.open||!this.#i)return;let r=this.#i.querySelector("[data-cal-day][data-selected]:not([data-outside])")||this.#i.querySelector("[data-cal-day]:not([disabled]):not([data-outside])"),o=r&&Number(r.dataset.date?.split("-")[2]);o&&this.#i.focusDay(o)}),e&&this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:this.#u}}))):(this.#a?.(),this.#a=null,this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.#t?.hidePopover?.(),document.removeEventListener("pointerdown",this.#y),i&&this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:this.#d}}))),this.#c=this.open}#x(){if(!this.value)return this.placeholder;if(this.#f){let e=on(this.value);if(!e)return this.value;let i=jI(e.date,this.format),n=WI(e.time,this.precision,this.hourcycle);return!i||!n?this.placeholder:`${i} ${n}`}let t=_I(this.value);if(!t)return this.value;switch(this.format){case"long":return`${oA[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`;case"iso":return this.value;default:return`${rA[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`}}#w=t=>{if(!(this.disabled||this.readonly)){if(this.#t&&t.composedPath().includes(this.#t)){let e=t.target.closest?.("[data-action]");if(e&&this.contains(e)){let i=e.dataset.action;i==="apply"?(this.#S({date:this.#h?.date??this.#i?.value??"",time:this.#h?.time??this.#r?.value??""}),this.#d="apply",this.open=!1):i==="cancel"&&(this.#h=null,this.#d="cancel",this.open=!1)}return}this.open?(this.#d="outside",this.open=!1):(this.#u="click",this.open=!0)}};#y=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.#d="outside",this.open=!1)};#A=t=>{if(!(this.disabled||this.readonly)){if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#u="keyboard",this.open=!0);return}t.key==="Escape"&&(t.preventDefault(),this.#d="escape",this.open=!1)}};disconnected(){super.disconnected(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),this.removeEventListener("click",this.#w),this.removeEventListener("keydown",this.#A),document.removeEventListener("pointerdown",this.#y),this.#i&&this.#s&&this.#i.removeEventListener("change",this.#p),this.#r&&this.#o&&(this.#r.removeEventListener("change",this.#m),this.#r.removeEventListener("input",this.#g),this.#r.removeEventListener("invalid",this.#O)),this.#s=!1,this.#o=!1,this.#a?.(),this.#a=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null,this.#i=null,this.#n=null,this.#r=null,this.#h=null,this.#c=!1}};M();A("calendar-picker-ui",ta);mi();var FI=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],UI=["January","February","March","April","May","June","July","August","September","October","November","December"];function LO(s){return String(s).padStart(2,"0")}function He(s){return s?`${s.getFullYear()}-${LO(s.getMonth()+1)}-${LO(s.getDate())}`:""}function MO(s){if(!s)return null;let t=String(s).match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return null;let e=new Date(+t[1],+t[2]-1,+t[3]);return Number.isNaN(e.getTime())?null:e}function zi(s){if(s==null)return null;if(typeof s=="object")return!s.from||!s.to?null:{from:String(s.from),to:String(s.to)};if(typeof s!="string"||!s.trim())return null;try{let t=JSON.parse(s);if(t&&t.from&&t.to)return{from:String(t.from),to:String(t.to)}}catch{}return null}function aA(s){return s?s.from<=s.to:!1}function lA(s,t){let e=MO(s);if(!e)return"";switch(t){case"long":return`${UI[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${FI[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function YI(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=He(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),He(l)},n=He(new Date(t.getFullYear(),t.getMonth(),1)),r=He(new Date(t.getFullYear(),t.getMonth()+1,0)),o=He(new Date(t.getFullYear(),0,1));return[{label:"Today",range:{from:e,to:e}},{label:"Last 7 days",range:{from:i(6),to:e}},{label:"Last 30 days",range:{from:i(29),to:e}},{label:"This month",range:{from:n,to:r}},{label:"Year to date",range:{from:o,to:e}}]}function HI(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var ea=class extends _{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down"];static get properties(){return{..._.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" icon-trailing="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#n=!1;#r=null;#o=null;#a=null;#l=null;#c=null;#h=null;get rangeValue(){return zi(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return zi(this.compareValue)}set rangeCompareValue(t){t==null?this.compareValue="":this.compareValue=JSON.stringify({from:String(t.from),to:String(t.to)})}get presets(){return Array.isArray(this.#t)?this.#t:YI()}set presets(t){Mt(()=>{this.#t=Array.isArray(t)?t.slice():null,this.isConnected&&this.#p()})}open$(){this.open=!0}close$(){this.open=!1}openPopover(){this.disabled||this.readonly||this.open||(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"programmatic"}})))}closePopover(t="programmatic"){this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}})))}clear(){this.value="",this.comparison&&(this.compareValue=""),this.#e=null,this.syncValue("")}applyPreset(t){let e=this.presets.find(i=>i.label===t);return!e||!e.range?!1:(this.#A(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=zi(e);if(this.comparison&&this.name){let n=new FormData;i&&n.append(this.name,e),zi(this.compareValue)&&n.append(`${this.name}-compare`,this.compareValue),this.internals.setFormValue(n)}else this.internals.setFormValue(i?e:"");this.#u(i)}#u(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date range.",this),!1):t&&!aA(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#d(),this.#r.addEventListener("click",this.#g),this.#r.addEventListener("keydown",this.#O,!0),this.#o.addEventListener("click",this.#S),this.#o.addEventListener("keydown",this.#b),this.#l.addEventListener("change",this.#w),this.#c.addEventListener("change",this.#w)),this.syncValue()}disconnected(){super.disconnected(),this.#r&&(this.#r.removeEventListener("click",this.#g),this.#r.removeEventListener("keydown",this.#O,!0)),this.#o&&(this.#o.removeEventListener("click",this.#S),this.#o.removeEventListener("keydown",this.#b),this.#o.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#w),this.#c&&this.#c.removeEventListener("change",this.#w),document.removeEventListener("pointerdown",this.#y),document.removeEventListener("keydown",this.#x),this.#h?.(),this.#h=null,this.#s=!1,this.#n=!1,this.#r=null,this.#o=null,this.#a=null,this.#l=null,this.#c=null}#d(){if(this.#r=this.ensure("trigger"),this.#o=this.ensure("popover"),this.id&&this.#o.setAttribute("aria-labelledby",this.id),!this.#o.querySelector(":scope > [data-calendar-area]")){let n=this.constructor._pp.calArea.cloneNode(!0);this.#o.appendChild(n)}let t=lt(this,"presets")[0];if(t&&t.parentElement!==this.#o)this.#o.appendChild(t),this.#a=t;else if(!this.noPresets&&!t){if(!this.#o.querySelector(":scope > [data-preset-rail]")){let n=this.constructor._pp.presets.cloneNode(!0);this.#o.insertBefore(n,this.#o.querySelector(":scope > [data-calendar-area]"))}this.#a=this.#o.querySelector(":scope > [data-preset-rail]")}let e=this.#o.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let n=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(n)}if(!e.querySelector(":scope > [data-cal-to]")){let n=this.constructor._pp.calTo.cloneNode(!0),r=zi(this.value)?.from,o,a;if(r){let[l,h]=r.split("-").map(Number);o=l,a=h-1}else{let l=new Date;o=l.getFullYear(),a=l.getMonth()}a+=1,a>11&&(a=0,o+=1),n.setAttribute("month",`${o}-${LO(a+1)}`),e.appendChild(n)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=lt(this,"footer")[0];i&&i.parentElement!==this.#o&&this.#o.appendChild(i)}render(){if(!this.#r)return;let t=this.#f();this.#r.setAttribute("text",t),this.#r.toggleAttribute("data-has-value",t!==this.placeholder),this.#r.toggleAttribute("disabled",this.disabled),this.#r.setAttribute("aria-haspopup","dialog"),this.#r.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let e=zi(this.value),i=this.#e,n=i?i.from:e?.from||"",r=i?i.to:e?.to||"",o=a=>{n?a.setAttribute("range-start",n):a.removeAttribute("range-start"),r?a.setAttribute("range-end",r):a.removeAttribute("range-end")};this.#l&&(this.min&&this.#l.setAttribute("min",this.min),this.max&&this.#l.setAttribute("max",this.max),this.#l.value=n,o(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=r,o(this.#c)),lt(this,"presets").length||(this.noPresets?(this.#a?.remove(),this.#a=null):(this.#a||this.#d(),this.#p())),this.#o&&(this.open&&!this.#n?!this.disabled&&!this.readonly?(this.#n=!0,this.#o.showPopover?.(),this.#h?.(),this.#h=mt(this.#r,this.#o,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#y),document.addEventListener("keydown",this.#x),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#n&&(this.#n=!1,this.#h?.(),this.#h=null,this.#o.hidePopover?.(),document.removeEventListener("pointerdown",this.#y),document.removeEventListener("keydown",this.#x),this.#r?.focus?.()))}#f(){let t=zi(this.value);if(!t)return this.placeholder;let e=lA(t.from,this.format),i=lA(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#p(){if(this.#a){this.#a.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#a.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#a.appendChild(t);for(let e of HI()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#a.appendChild(i)}}}}#m=!1;#g=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#O=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#S=t=>{if(this.readonly){let n=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),r=t.target.closest("[data-cal-day]");if(n||r){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let n=zi(this.value);if(!n)return;let r=this.#E(i.dataset.comparisonPresetLabel,n);r&&(this.rangeCompareValue=r);return}};#b=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#P();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#x=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#w=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"";if(!e)return;if(!this.#e?.from||this.#e.to||e<this.#e.from){this.#e={from:e,to:""},this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));return}this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from,to:e}}})),this.#A({from:this.#e.from,to:e})};#y=t=>{this.open&&(this.contains(t.target)||this.#o&&t.composedPath?.().includes(this.#o)||this.closePopover("outside"))};#A(t,e={}){if(!t||!t.from||!t.to)return;if(!aA(t)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"reversed"}}));return}if(this.min&&t.from<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"below-min"}}));return}if(this.max&&t.to>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:"above-max"}}));return}let i=JSON.stringify({from:t.from,to:t.to});this.value=i,this.#e=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:{from:t.from,to:t.to},compareValue:zi(this.compareValue),presetLabel:e.presetLabel||null}}))}#E(t,e){let i=MO(e.from),n=MO(e.to);if(!i||!n)return null;let r=Math.round((n-i)/864e5)+1;switch(t){case"Previous period":{let o=new Date(i);o.setDate(o.getDate()-1);let a=new Date(o);return a.setDate(a.getDate()-(r-1)),{from:He(a),to:He(o)}}case"Same period last year":{let o=new Date(i);o.setFullYear(o.getFullYear()-1);let a=new Date(n);return a.setFullYear(a.getFullYear()-1),{from:He(o),to:He(a)}}case"Same period last month":{let o=new Date(i);o.setMonth(o.getMonth()-1);let a=new Date(n);return a.setMonth(a.getMonth()-1),{from:He(o),to:He(a)}}default:return null}}#P(){if(!this.#o)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#o.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};M();A("date-range-picker-ui",ea);Ge();var hA=23,cA=12,o7=1,uA=59,dA=59,GI=["hour","minute"];function Yl(s){if(!s)return null;let t=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(String(s).trim());if(!t)return null;let e=Number(t[1]),i=Number(t[2]),n=t[3]!=null?Number(t[3]):0;return!Number.isFinite(e)||e<0||e>23||!Number.isFinite(i)||i<0||i>59||!Number.isFinite(n)||n<0||n>59?null:{h:e,m:i,s:n}}function RO({h:s,m:t,s:e},i){let n=r=>String(r).padStart(2,"0");return i==="second"?`${n(s)}:${n(t)}:${n(e)}`:`${n(s)}:${n(t)}`}function ia({h:s,m:t,s:e}){return s*3600+t*60+e}function KI(s){try{let t=s||document?.documentElement?.lang||void 0,i=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions(),n=i.hourCycle||(i.hour12?"h12":"h23");return n==="h11"||n==="h12"?"h12":"h23"}catch{return"h23"}}var na=class extends _{static labelDeprecated=!1;static properties={..._.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#n(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:KI(this.locale)}get#r(){return this.#n==="h12"}get#o(){return this.precision==="second"}get#a(){return`${this.#n}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#O),this.addEventListener("focusin",this.#S),this.addEventListener("focusout",this.#b)}render(){this.#i&&this.#i!==this.#a&&this.#l(),this.#u(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#O),this.removeEventListener("focusin",this.#S),this.removeEventListener("focusout",this.#b),this.#t=null,this.#e=[],this.#s=null}clear(){this.value="",this.syncValue(""),this.#u()}stepUp(t,e=1){this.#f(t,1*(e|0||1))}stepDown(t,e=1){this.#f(t,-1*(e|0||1))}#l(){let t=this.#n,e=this.#o,i=this.#r,n=[...GI];e&&n.push("second"),i&&n.push("meridiem"),this.#e=n;let r=this.querySelector(':scope > [slot="prefix"]'),o=this.querySelector(':scope > [slot="suffix"]'),a=(c,u,d)=>`<span data-segment="${c}" role="spinbutton" tabindex="0"
332
332
  aria-label="${u}" aria-valuemin="0" aria-valuemax="${d}"
333
333
  aria-valuenow=""></span>`,l='<span data-separator aria-hidden="true">:</span>',h="";h+=a("hour","Hours",i?cA:hA),h+=l,h+=a("minute","Minutes",uA),e&&(h+=l,h+=a("second","Seconds",dA)),i&&(h+=`<span data-segment="meridiem" role="spinbutton" tabindex="0"
334
334
  aria-label="AM/PM" aria-valuemin="0" aria-valuemax="1"
335
- aria-valuenow="" data-meridiem></span>`),this.innerHTML=h,r&&this.insertBefore(r,this.firstChild),o&&this.appendChild(o),this.#t={};for(let c of n){let u=this.querySelector(`[data-segment="${c}"]`);u&&(this.#t[c]=u)}for(let c of n){let u=this.#t[c];u&&(u.contentEditable="plaintext-only",u.addEventListener("beforeinput",this.#x),u.addEventListener("input",this.#w),u.addEventListener("blur",this.#b),u.addEventListener("focus",this.#$))}this.#i=this.#a}#c(){if(!this.#t)return;let t=!(this.disabled||this.readonly);for(let e of this.#e){let i=this.#t[e];i&&(i.contentEditable=t?"plaintext-only":"false")}}#h(){let t=Yl(this.value);return t||null}#u(){if(!this.#t)return;let t=this.#h(),e=this.#n;if(!t){for(let a of this.#e){let l=this.#t[a];l&&(document.activeElement===l&&l.textContent!==""||(l.textContent="",l.setAttribute("aria-valuenow",""),l.setAttribute("aria-valuetext",this.placeholder)))}return}let i=this.#r?t.h%12||12:t.h,n={hour:IO(i),minute:IO(t.m),second:IO(t.s),meridiem:e==="h12"?t.h>=12?"PM":"AM":""},r={hour:String(i),minute:String(t.m),second:String(t.s),meridiem:e==="h12"?t.h>=12?"1":"0":""},o={hour:`${i} hour${i===1?"":"s"}`,minute:`${t.m} minute${t.m===1?"":"s"}`,second:`${t.s} second${t.s===1?"":"s"}`,meridiem:e==="h12"?t.h>=12?"PM":"AM":""};for(let a of this.#e){let l=this.#t[a];l&&document.activeElement!==l&&(l.textContent=n[a],l.setAttribute("aria-valuenow",r[a]),l.setAttribute("aria-valuetext",o[a]))}}#d(t){if(!this.#t)return;let e=this.#n,i={};for(let d of this.#e)i[d]=(this.#t[d]?.textContent||"").trim();if(!i.hour&&!i.minute){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",segment:t||null}}));return}let n=DO(i.hour,0,e==="h12"?cA:hA),r=DO(i.minute,0,uA),o=this.#o?DO(i.second,0,dA):0;if(n==null||r==null||o==null){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"parse"}}));return}if(e==="h12"){let f=String(i.meridiem||"").trim().toUpperCase()==="PM";n===12?n=f?12:0:f&&(n+=12)}let a={h:n,m:r,s:o},l=ia(a),h=Yl(this.min),c=Yl(this.max);if(h&&l<ia(h)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(c&&l>ia(c)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let u=RO(a,this.precision);if(u===this.value){this.#u();return}this.value=u,this.syncValue(u),this.#u(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:u,segment:t||null}}))}#f(t,e){if(this.disabled||this.readonly||!this.#t?.[t])return;let i=this.#n,n=Math.max(1,this.step|0),r=this.#h();if(r||(r={h:0,m:0,s:0}),t==="hour")r.h=sa(r.h+e,0,24);else if(t==="minute"){let c=Math.max(1,Math.floor(n/60))*e;for(r.m=r.m+c;r.m<0;)r.m+=60,r.h=sa(r.h-1,0,24);for(;r.m>59;)r.m-=60,r.h=sa(r.h+1,0,24)}else if(t==="second"){let c=Math.max(1,n)*e;for(r.s=r.s+c;r.s<0;)r.s+=60,r.m-=1;for(;r.s>59;)r.s-=60,r.m+=1;for(;r.m<0;)r.m+=60,r.h=sa(r.h-1,0,24);for(;r.m>59;)r.m-=60,r.h=sa(r.h+1,0,24)}else t==="meridiem"&&(r.h=sa(r.h+12,0,24));let o=ia(r),a=Yl(this.min),l=Yl(this.max);if(a&&o<ia(a)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(l&&o>ia(l)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let h=RO(r,this.precision);this.value=h,this.syncValue(h),this.#u(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:h}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:h,segment:t}}))}#p(t,e){if(this.disabled||this.readonly)return;let i=this.#n,n=this.#h()||{h:0,m:0,s:0};t==="hour"?n.h=e==="min"?0:23:t==="minute"?n.m=e==="min"?0:59:t==="second"?n.s=e==="min"?0:59:t==="meridiem"&&(n.h=e==="min"?n.h%12:n.h%12+12);let r=RO(n,this.precision);this.value=r,this.syncValue(r),this.#u(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,segment:t}}))}#m(t,e){let i=this.#e.indexOf(t);if(i<0)return;let n=i+e;if(n<0||n>=this.#e.length)return;this.#t?.[this.#e[n]]?.focus()}#O(t){if(!te(t))return null;let e=t.closest("[data-segment]");return!e||!this.contains(e)?null:e.getAttribute("data-segment")}#g=t=>{if(this.disabled)return;let e=this.#O(t.target);if(e)switch(t.key){case"ArrowUp":t.preventDefault(),this.#f(e,1);return;case"ArrowDown":t.preventDefault(),this.#f(e,-1);return;case"PageUp":t.preventDefault(),this.#f(e,10);return;case"PageDown":t.preventDefault(),this.#f(e,-10);return;case"Home":t.preventDefault(),this.#p(e,"min");return;case"End":t.preventDefault(),this.#p(e,"max");return;case"ArrowLeft":t.preventDefault(),this.#m(e,-1);return;case"ArrowRight":t.preventDefault(),this.#m(e,1);return;case"Enter":t.preventDefault(),this.#d(e);return}};#S=t=>{let e=this.#O(t.target);e&&(this.#s=e,this.setAttribute("editing",""),this.setAttribute("segment",e))};#v=t=>{queueMicrotask(()=>{let e=document.activeElement;(!e||!this.contains(e))&&(this.removeAttribute("editing"),this.removeAttribute("segment"),this.#s=null)})};#x=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;if(this.#O(t.target)==="meridiem"){if(!/^[apmAPM]$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault();return}if(!/^\d$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault()};#w=t=>{let e=this.#O(t.target);if(!e)return;let i=(t.target.textContent||"").trim();if(this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),e==="meridiem"){let n=i.toUpperCase();(n==="AM"||n==="PM")&&(t.target.textContent=n,this.#d(e));return}if(i.length<2){let n=parseInt(t.target.getAttribute("aria-valuemax")||"0",10),r=parseInt(i,10);Number.isNaN(r)||r*10>n&&(this.#d(e),this.#m(e,1))}else this.#d(e),this.#m(e,1)};#b=t=>{let e=this.#O(t.target);e&&this.#d(e)};#$=t=>{let e=t.target;te(e)&&typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{if(document.activeElement!==e)return;let i=window.getSelection?.();if(!i)return;let n=document.createRange();n.selectNodeContents(e),i.removeAllRanges(),i.addRange(n)})};onFormReset(){this.value="",this.#u()}};function IO(s){return String(s).padStart(2,"0")}function DO(s,t,e){if(s===""||s==null)return null;let i=Number(s);return!Number.isFinite(i)||!Number.isInteger(i)||i<t||i>e?null:i}function sa(s,t,e){let i=s-t,n=e-t;return i=(i%n+n)%n,i+t}M();A("time-picker-ui",na);X();var ra=class extends C{static properties={src:{type:String,default:"",reflect:!0},height:{type:String,default:"400",reflect:!0},width:{type:String,default:"100%",reflect:!0},aspect:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;connected(){this.#t||(this.#t=document.createElement("iframe"),this.#t.setAttribute("sandbox","allow-scripts allow-same-origin"),this.#t.setAttribute("loading","lazy"),this.#t.setAttribute("allowfullscreen",""),this.appendChild(this.#t))}render(){this.#t&&(this.src&&(this.#t.src=this.src),this.aspect?(this.style.aspectRatio=this.aspect,this.#t.style.width="100%",this.#t.style.height="100%",this.style.width=this.width,this.style.height=""):(this.style.aspectRatio="",this.#t.style.width="100%",this.#t.style.height=this.height.match(/^\d+$/)?`${this.height}px`:this.height,this.style.width=this.width,this.style.height=""))}disconnected(){this.#t=null}};M();A("embed-ui",ra);X();var JI=new Set(["xs","sm","md","lg","xl"]);function fA(s,t){return s==null||s===""?"":s==="none"?"0":JI.has(s)?`var(--a-${t}-${s})`:/^\d+$/.test(s)?`var(--a-space-${s})`:s}var oa=class extends C{static properties={padding:{type:String,default:"md",reflect:!0},margin:{type:String,default:"none",reflect:!0}};static template=()=>null;render(){let t=this.padding,e=this.margin,n=t?.includes("@")||e?.includes("@")?Te.value:"";t?.includes("@")?this.style.setProperty("--block-padding",fA(Bt(t,n),"padding")):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",fA(Bt(e,n),"margin")):this.style.removeProperty("--block-margin")}};M();A("block-ui",oa);X();var t5={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function e5(s){return t5[s]??s}var aa=class extends C{static properties={variant:{type:String,default:"body",reflect:!0},strong:{type:Boolean,default:!1,reflect:!0},truncate:{type:Boolean,default:!1,reflect:!0},lines:{type:Number,default:0,reflect:!0},size:{type:String,default:"",reflect:!0},color:{type:String,default:"",reflect:!0},weight:{type:String,default:"",reflect:!0},"text-align":{type:String,default:"",reflect:!0}};static template=()=>null;render(){this.lines>0?this.style.setProperty("--_text-lines",String(this.lines)):this.style.removeProperty("--_text-lines");let t=this.size;if(t?.includes("@")){let e=Te.value;this.style.setProperty("--text-size",e5(Bt(t,e)))}else this.style.removeProperty("--text-size")}};M();A("text-ui",aa);X();var Bi="light",ze="dark",XO="auto",la=class extends C{static properties={scheme:{type:String,default:XO,reflect:!0},target:{type:String,default:":root",reflect:!0},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},iconLight:{type:String,default:"sun",reflect:!0,attribute:"icon-light"},iconDark:{type:String,default:"moon",reflect:!0,attribute:"icon-dark"},labelLight:{type:String,default:"Switch to dark mode",reflect:!0,attribute:"label-light"},labelDark:{type:String,default:"Switch to light mode",reflect:!0,attribute:"label-dark"},size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"ghost",reflect:!0},color:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=!1;#r=!1;connected(){this.#n||(this.#o(),this.#n=!0),this.#a()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="scheme"&&this.isConnected&&this.#n&&!this.#r&&e!==i&&this.#a()}disconnected(){this.#t&&this.#s&&this.#t.removeEventListener("press",this.#s),this.#O()}toggle(){this.#r=!0;let t=this.activeScheme===ze?Bi:ze;this.#l(t,"programmatic")}setScheme(t){if(this.#r=!0,t===XO){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Bi||t===ze)&&this.#l(t,"programmatic")}#o(){let t=document.createElement("button-ui");t.setAttribute("part","button"),t.setAttribute("variant",this.variant||"ghost"),t.setAttribute("size",this.size||"md"),this.color&&t.setAttribute("color",this.color),this.disabled&&t.setAttribute("disabled",""),this.appendChild(t),this.#t=t,this.#s=e=>{if(e.stopPropagation(),this.disabled)return;this.#r=!0;let i=this.activeScheme===ze?Bi:ze;this.#l(i,"press")},t.addEventListener("press",this.#s)}#a(){let t=null;if(this.persist)try{let e=localStorage.getItem(`${this.storagePrefix}scheme`);(e===Bi||e===ze)&&(t=e)}catch{}if(t===null){let e=this.scheme||XO;(e===Bi||e===ze)&&(t=e)}t===Bi||t===ze?(this.#d(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Bi&&t!==ze)){if(this.#d(t),this.activeScheme=t,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,t)}catch{}this.#O(),this.#c(),this.#h(e)}}#c(){if(!this.#t)return;let t=this.activeScheme===ze,e=t?this.iconDark:this.iconLight,i=t?this.labelDark:this.labelLight;this.#t.getAttribute("icon")!==e&&this.#t.setAttribute("icon",e),this.#t.setAttribute("aria-label",i),this.#t.setAttribute("title",i),this.#t.getAttribute("variant")!==this.variant&&this.#t.setAttribute("variant",this.variant||"ghost"),this.#t.getAttribute("size")!==this.size&&this.#t.setAttribute("size",this.size||"md"),this.color?this.#t.setAttribute("color",this.color):this.#t.removeAttribute("color"),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled")}render(){this.#c()}#h(t){this.dispatchEvent(new CustomEvent("scheme-change",{bubbles:!0,detail:{scheme:this.activeScheme,source:t}}))}#u(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#d(t){let e=this.#u();e.style.setProperty("color-scheme",t),e.setAttribute("data-scheme",t)}#f(){let t=this.#u();if(t.style.removeProperty("color-scheme"),t.removeAttribute("data-scheme"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}}#p(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return ze}catch{}return Bi}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?ze:Bi;t!==this.activeScheme&&(this.activeScheme=t,this.#c(),this.#h("media"))},this.#e.addEventListener("change",this.#i)}catch{}}#O(){if(this.#e&&this.#i)try{this.#e.removeEventListener("change",this.#i)}catch{}this.#e=null,this.#i=null}};M();A("toggle-scheme-ui",la);X();var ha=class extends C{static properties={labelOn:{type:String,default:"On",attribute:"label-on",reflect:!0},labelOff:{type:String,default:"Off",attribute:"label-off",reflect:!0},initial:{type:String,default:"off",reflect:!0},state:{type:String,default:"",reflect:!0}};static parts={bar:`
335
+ aria-valuenow="" data-meridiem></span>`),this.innerHTML=h,r&&this.insertBefore(r,this.firstChild),o&&this.appendChild(o),this.#t={};for(let c of n){let u=this.querySelector(`[data-segment="${c}"]`);u&&(this.#t[c]=u)}for(let c of n){let u=this.#t[c];u&&(u.contentEditable="plaintext-only",u.addEventListener("beforeinput",this.#x),u.addEventListener("input",this.#w),u.addEventListener("blur",this.#y),u.addEventListener("focus",this.#A))}this.#i=this.#a}#c(){if(!this.#t)return;let t=!(this.disabled||this.readonly);for(let e of this.#e){let i=this.#t[e];i&&(i.contentEditable=t?"plaintext-only":"false")}}#h(){let t=Yl(this.value);return t||null}#u(){if(!this.#t)return;let t=this.#h(),e=this.#n;if(!t){for(let a of this.#e){let l=this.#t[a];l&&(document.activeElement===l&&l.textContent!==""||(l.textContent="",l.setAttribute("aria-valuenow",""),l.setAttribute("aria-valuetext",this.placeholder)))}return}let i=this.#r?t.h%12||12:t.h,n={hour:IO(i),minute:IO(t.m),second:IO(t.s),meridiem:e==="h12"?t.h>=12?"PM":"AM":""},r={hour:String(i),minute:String(t.m),second:String(t.s),meridiem:e==="h12"?t.h>=12?"1":"0":""},o={hour:`${i} hour${i===1?"":"s"}`,minute:`${t.m} minute${t.m===1?"":"s"}`,second:`${t.s} second${t.s===1?"":"s"}`,meridiem:e==="h12"?t.h>=12?"PM":"AM":""};for(let a of this.#e){let l=this.#t[a];l&&document.activeElement!==l&&(l.textContent=n[a],l.setAttribute("aria-valuenow",r[a]),l.setAttribute("aria-valuetext",o[a]))}}#d(t){if(!this.#t)return;let e=this.#n,i={};for(let d of this.#e)i[d]=(this.#t[d]?.textContent||"").trim();if(!i.hour&&!i.minute){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",segment:t||null}}));return}let n=DO(i.hour,0,e==="h12"?cA:hA),r=DO(i.minute,0,uA),o=this.#o?DO(i.second,0,dA):0;if(n==null||r==null||o==null){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"parse"}}));return}if(e==="h12"){let f=String(i.meridiem||"").trim().toUpperCase()==="PM";n===12?n=f?12:0:f&&(n+=12)}let a={h:n,m:r,s:o},l=ia(a),h=Yl(this.min),c=Yl(this.max);if(h&&l<ia(h)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(c&&l>ia(c)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let u=RO(a,this.precision);if(u===this.value){this.#u();return}this.value=u,this.syncValue(u),this.#u(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:u,segment:t||null}}))}#f(t,e){if(this.disabled||this.readonly||!this.#t?.[t])return;let i=this.#n,n=Math.max(1,this.step|0),r=this.#h();if(r||(r={h:0,m:0,s:0}),t==="hour")r.h=sa(r.h+e,0,24);else if(t==="minute"){let c=Math.max(1,Math.floor(n/60))*e;for(r.m=r.m+c;r.m<0;)r.m+=60,r.h=sa(r.h-1,0,24);for(;r.m>59;)r.m-=60,r.h=sa(r.h+1,0,24)}else if(t==="second"){let c=Math.max(1,n)*e;for(r.s=r.s+c;r.s<0;)r.s+=60,r.m-=1;for(;r.s>59;)r.s-=60,r.m+=1;for(;r.m<0;)r.m+=60,r.h=sa(r.h-1,0,24);for(;r.m>59;)r.m-=60,r.h=sa(r.h+1,0,24)}else t==="meridiem"&&(r.h=sa(r.h+12,0,24));let o=ia(r),a=Yl(this.min),l=Yl(this.max);if(a&&o<ia(a)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(l&&o>ia(l)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let h=RO(r,this.precision);this.value=h,this.syncValue(h),this.#u(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:h}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:h,segment:t}}))}#p(t,e){if(this.disabled||this.readonly)return;let i=this.#n,n=this.#h()||{h:0,m:0,s:0};t==="hour"?n.h=e==="min"?0:23:t==="minute"?n.m=e==="min"?0:59:t==="second"?n.s=e==="min"?0:59:t==="meridiem"&&(n.h=e==="min"?n.h%12:n.h%12+12);let r=RO(n,this.precision);this.value=r,this.syncValue(r),this.#u(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:r,segment:t}}))}#m(t,e){let i=this.#e.indexOf(t);if(i<0)return;let n=i+e;if(n<0||n>=this.#e.length)return;this.#t?.[this.#e[n]]?.focus()}#g(t){if(!te(t))return null;let e=t.closest("[data-segment]");return!e||!this.contains(e)?null:e.getAttribute("data-segment")}#O=t=>{if(this.disabled)return;let e=this.#g(t.target);if(e)switch(t.key){case"ArrowUp":t.preventDefault(),this.#f(e,1);return;case"ArrowDown":t.preventDefault(),this.#f(e,-1);return;case"PageUp":t.preventDefault(),this.#f(e,10);return;case"PageDown":t.preventDefault(),this.#f(e,-10);return;case"Home":t.preventDefault(),this.#p(e,"min");return;case"End":t.preventDefault(),this.#p(e,"max");return;case"ArrowLeft":t.preventDefault(),this.#m(e,-1);return;case"ArrowRight":t.preventDefault(),this.#m(e,1);return;case"Enter":t.preventDefault(),this.#d(e);return}};#S=t=>{let e=this.#g(t.target);e&&(this.#s=e,this.setAttribute("editing",""),this.setAttribute("segment",e))};#b=t=>{queueMicrotask(()=>{let e=document.activeElement;(!e||!this.contains(e))&&(this.removeAttribute("editing"),this.removeAttribute("segment"),this.#s=null)})};#x=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;if(this.#g(t.target)==="meridiem"){if(!/^[apmAPM]$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault();return}if(!/^\d$/.test(i)){t.preventDefault();return}(t.target.textContent||"").length>=2&&t.preventDefault()};#w=t=>{let e=this.#g(t.target);if(!e)return;let i=(t.target.textContent||"").trim();if(this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),e==="meridiem"){let n=i.toUpperCase();(n==="AM"||n==="PM")&&(t.target.textContent=n,this.#d(e));return}if(i.length<2){let n=parseInt(t.target.getAttribute("aria-valuemax")||"0",10),r=parseInt(i,10);Number.isNaN(r)||r*10>n&&(this.#d(e),this.#m(e,1))}else this.#d(e),this.#m(e,1)};#y=t=>{let e=this.#g(t.target);e&&this.#d(e)};#A=t=>{let e=t.target;te(e)&&typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{if(document.activeElement!==e)return;let i=window.getSelection?.();if(!i)return;let n=document.createRange();n.selectNodeContents(e),i.removeAllRanges(),i.addRange(n)})};onFormReset(){this.value="",this.#u()}};function IO(s){return String(s).padStart(2,"0")}function DO(s,t,e){if(s===""||s==null)return null;let i=Number(s);return!Number.isFinite(i)||!Number.isInteger(i)||i<t||i>e?null:i}function sa(s,t,e){let i=s-t,n=e-t;return i=(i%n+n)%n,i+t}M();A("time-picker-ui",na);X();var ra=class extends C{static properties={src:{type:String,default:"",reflect:!0},height:{type:String,default:"400",reflect:!0},width:{type:String,default:"100%",reflect:!0},aspect:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;connected(){this.#t||(this.#t=document.createElement("iframe"),this.#t.setAttribute("sandbox","allow-scripts allow-same-origin"),this.#t.setAttribute("loading","lazy"),this.#t.setAttribute("allowfullscreen",""),this.appendChild(this.#t))}render(){this.#t&&(this.src&&(this.#t.src=this.src),this.aspect?(this.style.aspectRatio=this.aspect,this.#t.style.width="100%",this.#t.style.height="100%",this.style.width=this.width,this.style.height=""):(this.style.aspectRatio="",this.#t.style.width="100%",this.#t.style.height=this.height.match(/^\d+$/)?`${this.height}px`:this.height,this.style.width=this.width,this.style.height=""))}disconnected(){this.#t=null}};M();A("embed-ui",ra);X();var JI=new Set(["xs","sm","md","lg","xl"]);function fA(s,t){return s==null||s===""?"":s==="none"?"0":JI.has(s)?`var(--a-${t}-${s})`:/^\d+$/.test(s)?`var(--a-space-${s})`:s}var oa=class extends C{static properties={padding:{type:String,default:"md",reflect:!0},margin:{type:String,default:"none",reflect:!0}};static template=()=>null;render(){let t=this.padding,e=this.margin,n=t?.includes("@")||e?.includes("@")?Te.value:"";t?.includes("@")?this.style.setProperty("--block-padding",fA(Bt(t,n),"padding")):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",fA(Bt(e,n),"margin")):this.style.removeProperty("--block-margin")}};M();A("block-ui",oa);X();var t5={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function e5(s){return t5[s]??s}var aa=class extends C{static properties={variant:{type:String,default:"body",reflect:!0},strong:{type:Boolean,default:!1,reflect:!0},truncate:{type:Boolean,default:!1,reflect:!0},lines:{type:Number,default:0,reflect:!0},size:{type:String,default:"",reflect:!0},color:{type:String,default:"",reflect:!0},weight:{type:String,default:"",reflect:!0},"text-align":{type:String,default:"",reflect:!0}};static template=()=>null;render(){this.lines>0?this.style.setProperty("--_text-lines",String(this.lines)):this.style.removeProperty("--_text-lines");let t=this.size;if(t?.includes("@")){let e=Te.value;this.style.setProperty("--text-size",e5(Bt(t,e)))}else this.style.removeProperty("--text-size")}};M();A("text-ui",aa);X();var Bi="light",ze="dark",XO="auto",la=class extends C{static properties={scheme:{type:String,default:XO,reflect:!0},target:{type:String,default:":root",reflect:!0},persist:{type:Boolean,default:!1,reflect:!0},storagePrefix:{type:String,default:"adia-theme-",reflect:!0,attribute:"storage-prefix"},iconLight:{type:String,default:"sun",reflect:!0,attribute:"icon-light"},iconDark:{type:String,default:"moon",reflect:!0,attribute:"icon-dark"},labelLight:{type:String,default:"Switch to dark mode",reflect:!0,attribute:"label-light"},labelDark:{type:String,default:"Switch to light mode",reflect:!0,attribute:"label-dark"},size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"ghost",reflect:!0},color:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},activeScheme:{type:String,default:"",reflect:!0,attribute:"active-scheme"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=!1;#r=!1;connected(){this.#n||(this.#o(),this.#n=!0),this.#a()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="scheme"&&this.isConnected&&this.#n&&!this.#r&&e!==i&&this.#a()}disconnected(){this.#t&&this.#s&&this.#t.removeEventListener("press",this.#s),this.#g()}toggle(){this.#r=!0;let t=this.activeScheme===ze?Bi:ze;this.#l(t,"programmatic")}setScheme(t){if(this.#r=!0,t===XO){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Bi||t===ze)&&this.#l(t,"programmatic")}#o(){let t=document.createElement("button-ui");t.setAttribute("part","button"),t.setAttribute("variant",this.variant||"ghost"),t.setAttribute("size",this.size||"md"),this.color&&t.setAttribute("color",this.color),this.disabled&&t.setAttribute("disabled",""),this.appendChild(t),this.#t=t,this.#s=e=>{if(e.stopPropagation(),this.disabled)return;this.#r=!0;let i=this.activeScheme===ze?Bi:ze;this.#l(i,"press")},t.addEventListener("press",this.#s)}#a(){let t=null;if(this.persist)try{let e=localStorage.getItem(`${this.storagePrefix}scheme`);(e===Bi||e===ze)&&(t=e)}catch{}if(t===null){let e=this.scheme||XO;(e===Bi||e===ze)&&(t=e)}t===Bi||t===ze?(this.#d(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Bi&&t!==ze)){if(this.#d(t),this.activeScheme=t,this.persist)try{localStorage.setItem(`${this.storagePrefix}scheme`,t)}catch{}this.#g(),this.#c(),this.#h(e)}}#c(){if(!this.#t)return;let t=this.activeScheme===ze,e=t?this.iconDark:this.iconLight,i=t?this.labelDark:this.labelLight;this.#t.getAttribute("icon")!==e&&this.#t.setAttribute("icon",e),this.#t.setAttribute("aria-label",i),this.#t.setAttribute("title",i),this.#t.getAttribute("variant")!==this.variant&&this.#t.setAttribute("variant",this.variant||"ghost"),this.#t.getAttribute("size")!==this.size&&this.#t.setAttribute("size",this.size||"md"),this.color?this.#t.setAttribute("color",this.color):this.#t.removeAttribute("color"),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled")}render(){this.#c()}#h(t){this.dispatchEvent(new CustomEvent("scheme-change",{bubbles:!0,detail:{scheme:this.activeScheme,source:t}}))}#u(){let t=this.target||":root";if(t===":root")return document.documentElement;try{return document.querySelector(t)??document.documentElement}catch{return document.documentElement}}#d(t){let e=this.#u();e.style.setProperty("color-scheme",t),e.setAttribute("data-scheme",t)}#f(){let t=this.#u();if(t.style.removeProperty("color-scheme"),t.removeAttribute("data-scheme"),this.persist)try{localStorage.removeItem(`${this.storagePrefix}scheme`)}catch{}}#p(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return ze}catch{}return Bi}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?ze:Bi;t!==this.activeScheme&&(this.activeScheme=t,this.#c(),this.#h("media"))},this.#e.addEventListener("change",this.#i)}catch{}}#g(){if(this.#e&&this.#i)try{this.#e.removeEventListener("change",this.#i)}catch{}this.#e=null,this.#i=null}};M();A("toggle-scheme-ui",la);X();var ha=class extends C{static properties={labelOn:{type:String,default:"On",attribute:"label-on",reflect:!0},labelOff:{type:String,default:"Off",attribute:"label-off",reflect:!0},initial:{type:String,default:"off",reflect:!0},state:{type:String,default:"",reflect:!0}};static parts={bar:`
336
336
  <row-ui slot="bar" gap="3" align="center" data-demo-toggle-bar>
337
337
  <text-ui slot="label" data-demo-toggle-label></text-ui>
338
338
  <switch-ui slot="switch" data-demo-toggle-switch></switch-ui>
@@ -347,20 +347,20 @@ Correct shape for <chart-ui x="label" y="value">:
347
347
  `}).join("");this.innerHTML=i,this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(Number(this.value)||0)),this.setAttribute("aria-valuetext",`${Number(this.value)||0} out of ${t}`),this.readonly?this.setAttribute("aria-readonly","true"):this.removeAttribute("aria-readonly")}#e(t){let e=[...this.querySelectorAll("[data-rating-symbol]")],i=e.find(r=>r.contains(t.target));if(!i)return null;let n=e.indexOf(i);if(n===-1)return null;if(this.allowHalf){let r=i.getBoundingClientRect(),o=t.clientX-r.left<r.width/2;return n+(o?.5:1)}return n+1}#i=t=>{if(this.readonly||this.disabled)return;let e=this.#e(t);e!=null&&e!==this.#t&&(this.#t=e,this.render())};#s=()=>{this.#t!=null&&(this.#t=null,this.render())};#n=t=>{if(this.readonly||this.disabled)return;let e=this.#e(t);e!=null&&this.#o(e)};#r=t=>{if(this.readonly||this.disabled)return;let e=this.allowHalf?.5:1,i=Number(this.max)||5,n=Number(this.value)||0,r=n;if(t.key==="ArrowRight"||t.key==="ArrowUp")r=Math.min(i,n+e);else if(t.key==="ArrowLeft"||t.key==="ArrowDown")r=Math.max(0,n-e);else if(t.key==="Home")r=0;else if(t.key==="End")r=i;else return;t.preventDefault(),this.#o(r)};#o(t){this.value=t,this.#t=null,this.syncValue(String(t)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.render()}disconnected(){super.disconnected(),this.removeEventListener("pointermove",this.#i),this.removeEventListener("pointerleave",this.#s),this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#r)}};M();A("rating-ui",va);X();var xa=class extends C{static properties={layout:{type:String,default:"stacked",reflect:!0},align:{type:String,default:"start",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group")}render(){let t=this.#t();t.length&&(this.innerHTML=t.map(({term:e,description:i})=>`
348
348
  <dt data-dl-term>${this.#e(e)}</dt>
349
349
  <dd data-dl-desc>${this.#e(i)}</dd>
350
- `).join(""))}#t(){if(Array.isArray(this._items)&&this._items.length)return this._items;let t=this.getAttribute("items");if(t)try{let e=JSON.parse(t);if(Array.isArray(e))return e}catch{}return[]}set items(t){this._items=Array.isArray(t)?t:[],this.render()}get items(){return this._items||[]}#e(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}};M();A("description-list-ui",xa);X();var x5=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Sa=class extends C{static properties={type:{type:String,default:"matrix",reflect:!0},rows:{type:Number,default:7,reflect:!0},cols:{type:Number,default:12,reflect:!0},scale:{type:String,default:"linear",reflect:!0},noLegend:{type:Boolean,default:!1,reflect:!0,attribute:"no-legend"},colorScheme:{type:String,default:"data-ramp",reflect:!0,attribute:"color-scheme"},startDate:{type:String,default:"",reflect:!0,attribute:"start-date"},aspect:{type:String,default:"wide",reflect:!0}};static template=()=>null;#t=[];#e=!1;set data(t){if(typeof t=="string")try{t=JSON.parse(t)}catch{t=[]}this.#t=Array.isArray(t)?t:[],this.#s()}get data(){return this.#t}connected(){this.setAttribute("role","img");let t=this.getAttribute("data");if(t&&!this.#t.length)try{this.#t=JSON.parse(t)}catch{}this.#e||(this.#e=!0,this.addEventListener("pointerover",this.#l),this.addEventListener("pointermove",this.#c),this.addEventListener("pointerleave",this.#h),this.addEventListener("click",this.#u))}disconnected(){this.removeEventListener("pointerover",this.#l),this.removeEventListener("pointermove",this.#c),this.removeEventListener("pointerleave",this.#h),this.removeEventListener("click",this.#u),this.#e=!1,this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null)}#i=null;#s(){!this.isConnected||this.#i||(this.#i=requestAnimationFrame(()=>{this.#i=null,this.render()}))}#n(){let t=this.#t.map(r=>Number(r.v)||0);if(!t.length)return r=>0;let e=Math.min(...t),i=Math.max(...t);if(e===i)return r=>4;let n=this.scale;if(n==="log"){let r=Math.log(Math.max(1,e)),o=Math.log(Math.max(1,i));return a=>{let h=(Math.log(Math.max(1,Number(a)||0))-r)/(o-r);return Math.min(4,Math.max(0,Math.round(h*4)))}}if(n==="quantile"){let r=[...t].sort((l,h)=>l-h),o=l=>r[Math.floor(l*(r.length-1))],a=[o(.2),o(.4),o(.6),o(.8)];return l=>{let h=Number(l)||0;return h<=a[0]?0:h<=a[1]?1:h<=a[2]?2:h<=a[3]?3:4}}return r=>{let a=((Number(r)||0)-e)/(i-e);return Math.min(4,Math.max(0,Math.round(a*4)))}}render(){let t=Math.max(1,this.rows||7),e=Math.max(1,this.cols||12),i=new Map;for(let h of this.#t)h&&h.r!=null&&h.c!=null&&i.set(`${h.r},${h.c}`,h);let n=this.#n(),r=this.querySelector(':scope > [slot="title"]');if(this.replaceChildren(),r&&this.appendChild(r),this.type==="day-grid"&&this.startDate){let h=document.createElement("div");h.setAttribute("data-months","");let c=new Date(this.startDate);if(!Number.isNaN(c.getTime())){let u=[];for(let d=0;d<e;d++){let f=new Date(c);f.setDate(f.getDate()+d*7),(d===0||f.getDate()<=7)&&u.push({col:d,label:x5[f.getMonth()]})}for(let d of u){let f=document.createElement("span");f.setAttribute("data-month-label",""),f.style.gridColumn=String(d.col+1),f.textContent=d.label,h.appendChild(f)}}h.style.gridTemplateColumns=`repeat(${e}, var(--heatmap-cell-min-size, 0.75rem))`,this.appendChild(h)}let o=this.type==="day-grid",a=o?"var(--heatmap-cell-min-size, 0.75rem)":"minmax(0, 1fr)",l=document.createElement("div");l.setAttribute("data-heatmap-grid",""),l.style.gridTemplateColumns=`repeat(${e}, ${a})`,l.style.gridTemplateRows=`repeat(${t}, ${o?"var(--heatmap-cell-min-size, 0.75rem)":"1fr"})`;for(let h=0;h<t;h++)for(let c=0;c<e;c++){let u=i.get(`${h},${c}`),d=document.createElement("div");if(d.setAttribute("data-cell",""),d.setAttribute("role","gridcell"),d.dataset.r=String(h),d.dataset.c=String(c),u!=null){let f=Number(u.v)||0,p=n(f);d.dataset.bucket=String(p),d.dataset.v=String(f),u.label&&d.setAttribute("aria-label",u.label)}else d.dataset.empty="";l.appendChild(d)}if(this.appendChild(l),!this.noLegend){let h=document.createElement("div");h.setAttribute("data-legend","");let c=document.createElement("span");c.setAttribute("data-legend-label",""),c.textContent="Less",h.appendChild(c);for(let d=0;d<5;d++){let f=document.createElement("span");f.setAttribute("data-legend-swatch",""),f.dataset.bucket=String(d),h.appendChild(f)}let u=document.createElement("span");u.setAttribute("data-legend-label",""),u.textContent="More",h.appendChild(u),this.appendChild(h)}}#r(t){return t?.closest?.("[data-cell]")}#o(t,e){let i=Number(t.dataset.r),n=Number(t.dataset.c),r=Number(t.dataset.v),o=t.getAttribute("aria-label")||"";return{r:i,c:n,label:o,value:Number.isFinite(r)?r:null,pct:null,series:null,slot:0,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#a=null;#l=t=>{let e=this.#r(t.target);if(!e||!e.dataset.v)return;this.#a=e;let i=this.#o(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))};#c=t=>{let e=this.#r(t.target);if(!e||!e.dataset.v){this.#a&&(this.#a=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})));return}if(e!==this.#a){this.#a=e;let i=this.#o(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}else{let i=this.#o(e,t);this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}};#h=()=>{this.#a&&(this.#a=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})))};#u=t=>{let e=this.#r(t.target);if(!e||!e.dataset.v)return;let i=this.#o(e,t);this.dispatchEvent(new CustomEvent("cell-click",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-select",{detail:i,bubbles:!0}))}};M();A("heatmap-ui",Sa);X();var WA=new Set(["idle","active","done","error"]);function rb(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function S5(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var wa=class extends C{static requiredIcons=["check-circle","circle","warning","warning-circle"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},noAutocollapse:{type:Boolean,default:!1,reflect:!0,attribute:"no-autocollapse"},heading:{type:String,default:"",reflect:!0},status:{type:String,default:"active",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=Date.now();#s=null;#n=null;#r=null;#o=null;#a=!1;#l=null;#c=0;get entries(){return this.#t}connected(){this.#a||(this.#a=!0,this.#i=Date.now(),this.#s=setInterval(()=>this.#y(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#x()}))}),this.#l.observe(this)))}#h=t=>{let e=t.target.closest("timeline-item-ui[data-step-id]");!e||!this.#o?.contains(e)||this.dispatchEvent(new CustomEvent("reasoning-step-toggle",{bubbles:!0,detail:{stepId:e.dataset.stepId}}))};disconnected(){this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.#n!=null&&(clearTimeout(this.#n),this.#n=null),this.#c&&(cancelAnimationFrame(this.#c),this.#c=0),this.#l?.disconnect(),this.#l=null,this.#r?.removeEventListener("click",this.#f),this.#r?.removeEventListener("keydown",this.#p),this.#o?.removeEventListener("timeline-toggle",this.#h),this.#r=null,this.#o=null,this.#a=!1}addStep(t){let e={kind:"step",status:"active",duration:null,outcomes:[],children:[],...t};return this.#u(e),this.#v(),e}updateStep(t,e){let i=this.#d(t);i&&(Object.assign(i,e),this.#v())}completeStep(t,e){let i=this.#d(t);i&&(i.status="done",e!=null&&(i.duration=e),this.#v())}failStep(t,e){let i=this.#d(t);i&&(i.status="error",e&&(i.outcomes=[...i.outcomes||[],String(e)]),this.#v())}addThought(t,e=`thought-${this.#t.length}`){this.#u({kind:"thought",id:e,text:t}),this.#v()}setPlan(t,e="plan"){let i=this.#t.find(n=>n.kind==="plan"&&n.id===e);i?i.items=t.slice():this.#t.push({kind:"plan",id:e,items:t.slice()}),this.#v()}startIteration(t,e=`Attempt ${t}`,i=`iter-${t}`){let n={kind:"iteration",id:i,n:t,label:e,status:"active",summary:"",steps:[]};return this.#t.push(n),this.#e.push(i),this.#v(),n}endIteration(t,{status:e="done",summary:i=""}={}){let n=`iter-${t}`,r=this.#t.find(a=>a.kind==="iteration"&&a.id===n);if(!r)return;r.status=e,r.summary=i;let o=this.#e.lastIndexOf(n);o>=0&&this.#e.splice(o,1),this.#v()}finish(t,{status:e="done"}={}){let i=WA.has(e)?e:"done",n=i==="error";for(let r of this.#t)if(r.kind==="step"&&r.status==="active"&&(r.status=n?"error":"done"),r.kind==="iteration"){r.status==="active"&&(r.status=n?"error":"done");for(let o of r.steps||[])o.status==="active"&&(o.status=n?"error":"done")}this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.status=i,t&&(this.dataset.summary=t),this.#v(),this.dispatchEvent(new CustomEvent("reasoning-finish",{bubbles:!0,detail:{summary:t||"",status:i}})),this.#n!=null&&clearTimeout(this.#n),!this.noAutocollapse&&!n&&(this.#n=setTimeout(()=>{this.#n=null,this.collapsed=!0,this.#v()},1200))}fail(t){this.finish(t,{status:"error"})}#u(t){if(this.#e.length>0){let e=this.#e[this.#e.length-1],i=this.#t.find(n=>n.kind==="iteration"&&n.id===e);if(i){t.kind==="step"?i.steps.push(t):this.#t.push(t);return}}this.#t.push(t)}#d(t){for(let e of this.#t){if(e.kind==="step"&&e.id===t)return e;if(e.kind==="iteration"){for(let i of e.steps||[])if(i.id===t)return i}}return null}#f=()=>{this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("reasoning-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.#v()};#p=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#f())};#m(){this.innerHTML="",this.#r=document.createElement("div"),this.#r.setAttribute("data-reasoning-summary",""),this.#r.setAttribute("role","button"),this.#r.setAttribute("tabindex","0"),this.#r.setAttribute("aria-expanded",String(!this.collapsed)),this.#r.addEventListener("click",this.#f),this.#r.addEventListener("keydown",this.#p),this.appendChild(this.#r),this.#o=document.createElement("div"),this.#o.setAttribute("data-reasoning-body",""),this.#o.addEventListener("timeline-toggle",this.#h),this.appendChild(this.#o),this.#v()}#O(){for(let e=this.#t.length-1;e>=0;e--){let i=this.#t[e];if(i.kind==="step"&&i.status==="active")return i.label;if(i.kind==="iteration")for(let n=(i.steps||[]).length-1;n>=0;n--){let r=i.steps[n];if(r.status==="active")return r.label}if(i.kind==="thought")return i.text}return this.#t.findLast?.(e=>e.kind==="step")?.label||this.heading||"Thinking\u2026"}#g(t){switch(t){case"done":return'<icon-ui name="check-circle" color="success" data-reasoning-check></icon-ui>';case"error":return'<icon-ui name="warning-circle" color="danger" data-reasoning-check data-error></icon-ui>';case"idle":return'<icon-ui name="circle" color="muted" data-reasoning-check data-idle></icon-ui>';default:return"<span data-reasoning-spinner></span>"}}#S(){let t=0,e=0,i=n=>{t++,n.status==="done"&&e++};for(let n of this.#t)if(n.kind==="step"&&i(n),n.kind==="iteration")for(let r of n.steps||[])i(r);return{total:t,done:e}}#v(){if(!this.#r)return;let t=WA.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:n}=this.#S(),r=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#O();if(this.#r.innerHTML=`
351
- ${this.#g(t)}
350
+ `).join(""))}#t(){if(Array.isArray(this._items)&&this._items.length)return this._items;let t=this.getAttribute("items");if(t)try{let e=JSON.parse(t);if(Array.isArray(e))return e}catch{}return[]}set items(t){this._items=Array.isArray(t)?t:[],this.render()}get items(){return this._items||[]}#e(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}};M();A("description-list-ui",xa);X();var x5=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Sa=class extends C{static properties={type:{type:String,default:"matrix",reflect:!0},rows:{type:Number,default:7,reflect:!0},cols:{type:Number,default:12,reflect:!0},scale:{type:String,default:"linear",reflect:!0},noLegend:{type:Boolean,default:!1,reflect:!0,attribute:"no-legend"},colorScheme:{type:String,default:"data-ramp",reflect:!0,attribute:"color-scheme"},startDate:{type:String,default:"",reflect:!0,attribute:"start-date"},aspect:{type:String,default:"wide",reflect:!0}};static template=()=>null;#t=[];#e=!1;set data(t){if(typeof t=="string")try{t=JSON.parse(t)}catch{t=[]}this.#t=Array.isArray(t)?t:[],this.#s()}get data(){return this.#t}connected(){this.setAttribute("role","img");let t=this.getAttribute("data");if(t&&!this.#t.length)try{this.#t=JSON.parse(t)}catch{}this.#e||(this.#e=!0,this.addEventListener("pointerover",this.#l),this.addEventListener("pointermove",this.#c),this.addEventListener("pointerleave",this.#h),this.addEventListener("click",this.#u))}disconnected(){this.removeEventListener("pointerover",this.#l),this.removeEventListener("pointermove",this.#c),this.removeEventListener("pointerleave",this.#h),this.removeEventListener("click",this.#u),this.#e=!1,this.#i!=null&&(cancelAnimationFrame(this.#i),this.#i=null)}#i=null;#s(){!this.isConnected||this.#i||(this.#i=requestAnimationFrame(()=>{this.#i=null,this.render()}))}#n(){let t=this.#t.map(r=>Number(r.v)||0);if(!t.length)return r=>0;let e=Math.min(...t),i=Math.max(...t);if(e===i)return r=>4;let n=this.scale;if(n==="log"){let r=Math.log(Math.max(1,e)),o=Math.log(Math.max(1,i));return a=>{let h=(Math.log(Math.max(1,Number(a)||0))-r)/(o-r);return Math.min(4,Math.max(0,Math.round(h*4)))}}if(n==="quantile"){let r=[...t].sort((l,h)=>l-h),o=l=>r[Math.floor(l*(r.length-1))],a=[o(.2),o(.4),o(.6),o(.8)];return l=>{let h=Number(l)||0;return h<=a[0]?0:h<=a[1]?1:h<=a[2]?2:h<=a[3]?3:4}}return r=>{let a=((Number(r)||0)-e)/(i-e);return Math.min(4,Math.max(0,Math.round(a*4)))}}render(){let t=Math.max(1,this.rows||7),e=Math.max(1,this.cols||12),i=new Map;for(let h of this.#t)h&&h.r!=null&&h.c!=null&&i.set(`${h.r},${h.c}`,h);let n=this.#n(),r=this.querySelector(':scope > [slot="title"]');if(this.replaceChildren(),r&&this.appendChild(r),this.type==="day-grid"&&this.startDate){let h=document.createElement("div");h.setAttribute("data-months","");let c=new Date(this.startDate);if(!Number.isNaN(c.getTime())){let u=[];for(let d=0;d<e;d++){let f=new Date(c);f.setDate(f.getDate()+d*7),(d===0||f.getDate()<=7)&&u.push({col:d,label:x5[f.getMonth()]})}for(let d of u){let f=document.createElement("span");f.setAttribute("data-month-label",""),f.style.gridColumn=String(d.col+1),f.textContent=d.label,h.appendChild(f)}}h.style.gridTemplateColumns=`repeat(${e}, var(--heatmap-cell-min-size, 0.75rem))`,this.appendChild(h)}let o=this.type==="day-grid",a=o?"var(--heatmap-cell-min-size, 0.75rem)":"minmax(0, 1fr)",l=document.createElement("div");l.setAttribute("data-heatmap-grid",""),l.style.gridTemplateColumns=`repeat(${e}, ${a})`,l.style.gridTemplateRows=`repeat(${t}, ${o?"var(--heatmap-cell-min-size, 0.75rem)":"1fr"})`;for(let h=0;h<t;h++)for(let c=0;c<e;c++){let u=i.get(`${h},${c}`),d=document.createElement("div");if(d.setAttribute("data-cell",""),d.setAttribute("role","gridcell"),d.dataset.r=String(h),d.dataset.c=String(c),u!=null){let f=Number(u.v)||0,p=n(f);d.dataset.bucket=String(p),d.dataset.v=String(f),u.label&&d.setAttribute("aria-label",u.label)}else d.dataset.empty="";l.appendChild(d)}if(this.appendChild(l),!this.noLegend){let h=document.createElement("div");h.setAttribute("data-legend","");let c=document.createElement("span");c.setAttribute("data-legend-label",""),c.textContent="Less",h.appendChild(c);for(let d=0;d<5;d++){let f=document.createElement("span");f.setAttribute("data-legend-swatch",""),f.dataset.bucket=String(d),h.appendChild(f)}let u=document.createElement("span");u.setAttribute("data-legend-label",""),u.textContent="More",h.appendChild(u),this.appendChild(h)}}#r(t){return t?.closest?.("[data-cell]")}#o(t,e){let i=Number(t.dataset.r),n=Number(t.dataset.c),r=Number(t.dataset.v),o=t.getAttribute("aria-label")||"";return{r:i,c:n,label:o,value:Number.isFinite(r)?r:null,pct:null,series:null,slot:0,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#a=null;#l=t=>{let e=this.#r(t.target);if(!e||!e.dataset.v)return;this.#a=e;let i=this.#o(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))};#c=t=>{let e=this.#r(t.target);if(!e||!e.dataset.v){this.#a&&(this.#a=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})));return}if(e!==this.#a){this.#a=e;let i=this.#o(e,t);this.dispatchEvent(new CustomEvent("cell-hover",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}else{let i=this.#o(e,t);this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}};#h=()=>{this.#a&&(this.#a=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})))};#u=t=>{let e=this.#r(t.target);if(!e||!e.dataset.v)return;let i=this.#o(e,t);this.dispatchEvent(new CustomEvent("cell-click",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-select",{detail:i,bubbles:!0}))}};M();A("heatmap-ui",Sa);X();var WA=new Set(["idle","active","done","error"]);function rb(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function S5(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var wa=class extends C{static requiredIcons=["check-circle","circle","warning","warning-circle"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},noAutocollapse:{type:Boolean,default:!1,reflect:!0,attribute:"no-autocollapse"},heading:{type:String,default:"",reflect:!0},status:{type:String,default:"active",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=Date.now();#s=null;#n=null;#r=null;#o=null;#a=!1;#l=null;#c=0;get entries(){return this.#t}connected(){this.#a||(this.#a=!0,this.#i=Date.now(),this.#s=setInterval(()=>this.#v(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#x()}))}),this.#l.observe(this)))}#h=t=>{let e=t.target.closest("timeline-item-ui[data-step-id]");!e||!this.#o?.contains(e)||this.dispatchEvent(new CustomEvent("reasoning-step-toggle",{bubbles:!0,detail:{stepId:e.dataset.stepId}}))};disconnected(){this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.#n!=null&&(clearTimeout(this.#n),this.#n=null),this.#c&&(cancelAnimationFrame(this.#c),this.#c=0),this.#l?.disconnect(),this.#l=null,this.#r?.removeEventListener("click",this.#f),this.#r?.removeEventListener("keydown",this.#p),this.#o?.removeEventListener("timeline-toggle",this.#h),this.#r=null,this.#o=null,this.#a=!1}addStep(t){let e={kind:"step",status:"active",duration:null,outcomes:[],children:[],...t};return this.#u(e),this.#b(),e}updateStep(t,e){let i=this.#d(t);i&&(Object.assign(i,e),this.#b())}completeStep(t,e){let i=this.#d(t);i&&(i.status="done",e!=null&&(i.duration=e),this.#b())}failStep(t,e){let i=this.#d(t);i&&(i.status="error",e&&(i.outcomes=[...i.outcomes||[],String(e)]),this.#b())}addThought(t,e=`thought-${this.#t.length}`){this.#u({kind:"thought",id:e,text:t}),this.#b()}setPlan(t,e="plan"){let i=this.#t.find(n=>n.kind==="plan"&&n.id===e);i?i.items=t.slice():this.#t.push({kind:"plan",id:e,items:t.slice()}),this.#b()}startIteration(t,e=`Attempt ${t}`,i=`iter-${t}`){let n={kind:"iteration",id:i,n:t,label:e,status:"active",summary:"",steps:[]};return this.#t.push(n),this.#e.push(i),this.#b(),n}endIteration(t,{status:e="done",summary:i=""}={}){let n=`iter-${t}`,r=this.#t.find(a=>a.kind==="iteration"&&a.id===n);if(!r)return;r.status=e,r.summary=i;let o=this.#e.lastIndexOf(n);o>=0&&this.#e.splice(o,1),this.#b()}finish(t,{status:e="done"}={}){let i=WA.has(e)?e:"done",n=i==="error";for(let r of this.#t)if(r.kind==="step"&&r.status==="active"&&(r.status=n?"error":"done"),r.kind==="iteration"){r.status==="active"&&(r.status=n?"error":"done");for(let o of r.steps||[])o.status==="active"&&(o.status=n?"error":"done")}this.#s!=null&&(clearInterval(this.#s),this.#s=null),this.status=i,t&&(this.dataset.summary=t),this.#b(),this.dispatchEvent(new CustomEvent("reasoning-finish",{bubbles:!0,detail:{summary:t||"",status:i}})),this.#n!=null&&clearTimeout(this.#n),!this.noAutocollapse&&!n&&(this.#n=setTimeout(()=>{this.#n=null,this.collapsed=!0,this.#b()},1200))}fail(t){this.finish(t,{status:"error"})}#u(t){if(this.#e.length>0){let e=this.#e[this.#e.length-1],i=this.#t.find(n=>n.kind==="iteration"&&n.id===e);if(i){t.kind==="step"?i.steps.push(t):this.#t.push(t);return}}this.#t.push(t)}#d(t){for(let e of this.#t){if(e.kind==="step"&&e.id===t)return e;if(e.kind==="iteration"){for(let i of e.steps||[])if(i.id===t)return i}}return null}#f=()=>{this.collapsed=!this.collapsed,this.dispatchEvent(new CustomEvent("reasoning-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}})),this.#b()};#p=t=>{(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.#f())};#m(){this.innerHTML="",this.#r=document.createElement("div"),this.#r.setAttribute("data-reasoning-summary",""),this.#r.setAttribute("role","button"),this.#r.setAttribute("tabindex","0"),this.#r.setAttribute("aria-expanded",String(!this.collapsed)),this.#r.addEventListener("click",this.#f),this.#r.addEventListener("keydown",this.#p),this.appendChild(this.#r),this.#o=document.createElement("div"),this.#o.setAttribute("data-reasoning-body",""),this.#o.addEventListener("timeline-toggle",this.#h),this.appendChild(this.#o),this.#b()}#g(){for(let e=this.#t.length-1;e>=0;e--){let i=this.#t[e];if(i.kind==="step"&&i.status==="active")return i.label;if(i.kind==="iteration")for(let n=(i.steps||[]).length-1;n>=0;n--){let r=i.steps[n];if(r.status==="active")return r.label}if(i.kind==="thought")return i.text}return this.#t.findLast?.(e=>e.kind==="step")?.label||this.heading||"Thinking\u2026"}#O(t){switch(t){case"done":return'<icon-ui name="check-circle" color="success" data-reasoning-check></icon-ui>';case"error":return'<icon-ui name="warning-circle" color="danger" data-reasoning-check data-error></icon-ui>';case"idle":return'<icon-ui name="circle" color="muted" data-reasoning-check data-idle></icon-ui>';default:return"<span data-reasoning-spinner></span>"}}#S(){let t=0,e=0,i=n=>{t++,n.status==="done"&&e++};for(let n of this.#t)if(n.kind==="step"&&i(n),n.kind==="iteration")for(let r of n.steps||[])i(r);return{total:t,done:e}}#b(){if(!this.#r)return;let t=WA.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:n}=this.#S(),r=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#r.innerHTML=`
351
+ ${this.#O(t)}
352
352
  <span data-reasoning-label>${rb(o)}</span>
353
353
  <span data-reasoning-meta>
354
354
  ${i?`<span data-reasoning-counter>${n}/${i}</span>`:""}
355
355
  <span data-reasoning-time>${r}s</span>
356
356
  <icon-ui name="${this.collapsed?"caret-right":"caret-up"}" color="muted" data-reasoning-caret></icon-ui>
357
357
  </span>
358
- `,this.#o.hidden=this.collapsed,this.#r.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#o.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#w(),this.#o.appendChild(a)),a.appendChild(this.#b(l))):(a=null,this.#o.appendChild(this.#$(l)));this.#x()}#x(){let t=this.#o;if(!t)return;if(this.collapsed){t.removeAttribute("data-spine");return}let e=t.querySelectorAll("timeline-item-ui");if(e.length<2){t.removeAttribute("data-spine");return}let i=t.getBoundingClientRect().top,n=a=>{let l=a.getBoundingClientRect(),h=parseFloat(getComputedStyle(a).fontSize)||14;return l.top-i+.7*h+1},r=n(e[0]),o=Math.max(0,n(e[e.length-1])-r);t.style.setProperty("--reasoning-spine-top",`${Math.round(r)}px`),t.style.setProperty("--reasoning-spine-h",`${Math.round(o)}px`),t.setAttribute("data-spine","")}#w(){let t=document.createElement("timeline-ui");return t.setAttribute("size","sm"),t}#b(t){let e=document.createElement("timeline-item-ui");e.setAttribute("text",t.label||""),t.status==="done"&&e.setAttribute("status","completed"),t.status==="error"&&e.setAttribute("status","error"),t.status==="active"&&(e.setAttribute("status","active"),e.setAttribute("spinner",""));let i=t.durationLabel||(t.duration!=null?S5(t.duration):"");return i&&e.setAttribute("duration",i),t.outcomes?.length&&(e.outcomes=t.outcomes),e.dataset.stepId=t.id||"",e}#$(t){switch(t.kind){case"thought":return this.#C(t);case"plan":return this.#P(t);case"iteration":return this.#k(t);default:return document.createTextNode("")}}#C(t){let e=document.createElement("div");e.setAttribute("data-reasoning-thought","");let i=document.createElement("span");return i.setAttribute("data-reasoning-thought-text",""),i.textContent=t.text||"",e.appendChild(i),e}#P(t){let e=document.createElement("div");e.setAttribute("data-reasoning-plan","");let i=document.createElement("div");i.setAttribute("data-reasoning-plan-label",""),i.textContent="Plan",e.appendChild(i);let n=document.createElement("ol");n.setAttribute("data-reasoning-plan-list","");for(let r of t.items||[]){let o=document.createElement("li");o.textContent=r,n.appendChild(o)}return e.appendChild(n),e}#k(t){let e=document.createElement("div");e.setAttribute("data-reasoning-iteration",""),t.status==="active"&&e.setAttribute("data-active",""),t.status==="done"&&e.setAttribute("data-done",""),t.status==="error"&&e.setAttribute("data-error","");let i=document.createElement("div");i.setAttribute("data-reasoning-iter-header","");let n=t.status==="done"?'<icon-ui name="check-circle" color="success" size="sm"></icon-ui>':t.status==="error"?'<icon-ui name="warning" color="danger" size="sm"></icon-ui>':"<span data-reasoning-spinner data-small></span>";if(i.innerHTML=`
358
+ `,this.#o.hidden=this.collapsed,this.#r.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#o.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#w(),this.#o.appendChild(a)),a.appendChild(this.#y(l))):(a=null,this.#o.appendChild(this.#A(l)));this.#x()}#x(){let t=this.#o;if(!t)return;if(this.collapsed){t.removeAttribute("data-spine");return}let e=t.querySelectorAll("timeline-item-ui");if(e.length<2){t.removeAttribute("data-spine");return}let i=t.getBoundingClientRect().top,n=a=>{let l=a.getBoundingClientRect(),h=parseFloat(getComputedStyle(a).fontSize)||14;return l.top-i+.7*h+1},r=n(e[0]),o=Math.max(0,n(e[e.length-1])-r);t.style.setProperty("--reasoning-spine-top",`${Math.round(r)}px`),t.style.setProperty("--reasoning-spine-h",`${Math.round(o)}px`),t.setAttribute("data-spine","")}#w(){let t=document.createElement("timeline-ui");return t.setAttribute("size","sm"),t}#y(t){let e=document.createElement("timeline-item-ui");e.setAttribute("text",t.label||""),t.status==="done"&&e.setAttribute("status","completed"),t.status==="error"&&e.setAttribute("status","error"),t.status==="active"&&(e.setAttribute("status","active"),e.setAttribute("spinner",""));let i=t.durationLabel||(t.duration!=null?S5(t.duration):"");return i&&e.setAttribute("duration",i),t.outcomes?.length&&(e.outcomes=t.outcomes),e.dataset.stepId=t.id||"",e}#A(t){switch(t.kind){case"thought":return this.#E(t);case"plan":return this.#P(t);case"iteration":return this.#k(t);default:return document.createTextNode("")}}#E(t){let e=document.createElement("div");e.setAttribute("data-reasoning-thought","");let i=document.createElement("span");return i.setAttribute("data-reasoning-thought-text",""),i.textContent=t.text||"",e.appendChild(i),e}#P(t){let e=document.createElement("div");e.setAttribute("data-reasoning-plan","");let i=document.createElement("div");i.setAttribute("data-reasoning-plan-label",""),i.textContent="Plan",e.appendChild(i);let n=document.createElement("ol");n.setAttribute("data-reasoning-plan-list","");for(let r of t.items||[]){let o=document.createElement("li");o.textContent=r,n.appendChild(o)}return e.appendChild(n),e}#k(t){let e=document.createElement("div");e.setAttribute("data-reasoning-iteration",""),t.status==="active"&&e.setAttribute("data-active",""),t.status==="done"&&e.setAttribute("data-done",""),t.status==="error"&&e.setAttribute("data-error","");let i=document.createElement("div");i.setAttribute("data-reasoning-iter-header","");let n=t.status==="done"?'<icon-ui name="check-circle" color="success" size="sm"></icon-ui>':t.status==="error"?'<icon-ui name="warning" color="danger" size="sm"></icon-ui>':"<span data-reasoning-spinner data-small></span>";if(i.innerHTML=`
359
359
  ${n}
360
360
  <span data-reasoning-iter-n>#${t.n}</span>
361
361
  <span data-reasoning-iter-label>${rb(t.label||"")}</span>
362
362
  ${t.summary?`<span data-reasoning-iter-summary>${rb(t.summary)}</span>`:""}
363
- `,e.appendChild(i),t.steps?.length){let r=this.#w();for(let o of t.steps)r.appendChild(this.#b(o));e.appendChild(r)}return e}#y(){if(this.status==="done"||this.status==="error")return;let t=Math.round((Date.now()-this.#i)/1e3),e=this.#r?.querySelector("[data-reasoning-time]");e&&(e.textContent=t+"s");let i=t+"s";for(let n of this.querySelectorAll("timeline-item-ui[active]:not([completed])"))n.dataset._frozenDuration||n.setAttribute("duration",i)}};M();A("agent-reasoning-ui",wa);M();X();var Jl=class extends C{static requiredIcons=["caret-right","circle-fill"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=null;get pills(){return this.#t}set pills(t){this.#t=Array.isArray(t)?t.slice():[],this.#o()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#o()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#o()}connected(){this.#r()}disconnected(){this.#s?.removeEventListener("toggle",this.#n),this.#s=null}#n=()=>{this.collapsed=!this.#s.hasAttribute("open"),this.dispatchEvent(new CustomEvent("trace-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}}))};#r(){this.innerHTML="",this.#s=document.createElement("details"),this.#s.setAttribute("data-trace-root",""),this.collapsed||this.#s.setAttribute("open",""),this.#s.addEventListener("toggle",this.#n),this.appendChild(this.#s),this.#o()}#o(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${ms(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#a(a)),n=this.#e.length?`
363
+ `,e.appendChild(i),t.steps?.length){let r=this.#w();for(let o of t.steps)r.appendChild(this.#y(o));e.appendChild(r)}return e}#v(){if(this.status==="done"||this.status==="error")return;let t=Math.round((Date.now()-this.#i)/1e3),e=this.#r?.querySelector("[data-reasoning-time]");e&&(e.textContent=t+"s");let i=t+"s";for(let n of this.querySelectorAll("timeline-item-ui[active]:not([completed])"))n.dataset._frozenDuration||n.setAttribute("duration",i)}};M();A("agent-reasoning-ui",wa);M();X();var Jl=class extends C{static requiredIcons=["caret-right","circle-fill"];static properties={collapsed:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=null;get pills(){return this.#t}set pills(t){this.#t=Array.isArray(t)?t.slice():[],this.#o()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#o()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#o()}connected(){this.#r()}disconnected(){this.#s?.removeEventListener("toggle",this.#n),this.#s=null}#n=()=>{this.collapsed=!this.#s.hasAttribute("open"),this.dispatchEvent(new CustomEvent("trace-toggle",{bubbles:!0,detail:{collapsed:this.collapsed}}))};#r(){this.innerHTML="",this.#s=document.createElement("details"),this.#s.setAttribute("data-trace-root",""),this.collapsed||this.#s.setAttribute("open",""),this.#s.addEventListener("toggle",this.#n),this.appendChild(this.#s),this.#o()}#o(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${ms(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#a(a)),n=this.#e.length?`
364
364
  <div data-trace-headers>
365
365
  <span data-trace-header>Stage</span>
366
366
  <span data-trace-header>Score</span>