@adia-ai/web-components 0.7.4 → 0.7.6
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.
- package/CHANGELOG.md +30 -0
- package/components/action-list/action-list.a2ui.json +2 -2
- package/components/action-list/action-list.yaml +2 -2
- package/components/badge/badge.yaml +1 -0
- package/components/block/block.class.js +20 -4
- package/components/block/block.css +18 -13
- package/components/button/button.a2ui.json +1 -2
- package/components/button/button.css +44 -10
- package/components/button/button.yaml +1 -0
- package/components/card/card.yaml +1 -0
- package/components/chart/chart.a2ui.json +1 -2
- package/components/chart/chart.d.ts +1 -1
- package/components/chart/chart.yaml +1 -0
- package/components/check/check.a2ui.json +0 -3
- package/components/check/check.yaml +0 -2
- package/components/combobox/combobox.a2ui.json +1 -2
- package/components/combobox/combobox.yaml +1 -0
- package/components/command/command.a2ui.json +0 -3
- package/components/command/command.class.js +19 -1
- package/components/command/command.yaml +0 -2
- package/components/context-menu/context-menu.class.js +1 -0
- package/components/description-list/description-list.a2ui.json +1 -2
- package/components/description-list/description-list.d.ts +1 -1
- package/components/description-list/description-list.yaml +1 -0
- package/components/field/field.class.js +1 -0
- package/components/fields/fields.class.js +1 -0
- package/components/grid/grid.yaml +2 -0
- package/components/input/input.a2ui.json +2 -14
- package/components/input/input.yaml +2 -0
- package/components/integration-card/integration-card.class.js +1 -0
- package/components/list/list.class.js +1 -0
- package/components/list/list.yaml +1 -0
- package/components/menu/menu.class.js +1 -0
- package/components/menu/menu.css +14 -2
- package/components/pipeline-status/pipeline-status.yaml +1 -0
- package/components/radio/radio.a2ui.json +0 -3
- package/components/radio/radio.yaml +0 -2
- package/components/rating/rating.yaml +1 -0
- package/components/search/search.a2ui.json +1 -8
- package/components/search/search.yaml +1 -5
- package/components/select/select.a2ui.json +1 -2
- package/components/select/select.class.js +46 -1
- package/components/select/select.test.js +33 -0
- package/components/select/select.yaml +2 -0
- package/components/slider/slider.a2ui.json +0 -3
- package/components/slider/slider.yaml +0 -2
- package/components/swatch/swatch.class.js +1 -0
- package/components/table/table.a2ui.json +2 -4
- package/components/table/table.d.ts +2 -2
- package/components/table/table.yaml +2 -0
- package/components/tabs/tabs.yaml +1 -0
- package/components/tag/tag.yaml +1 -0
- package/components/toggle-group/toggle-group.yaml +1 -0
- package/components/toolbar/toolbar.class.js +1 -0
- package/components/tree/tree.a2ui.json +2 -2
- package/components/tree/tree.yaml +2 -2
- package/dist/host.min.css +1 -1
- package/dist/web-components.min.css +1 -1
- package/dist/web-components.min.js +28 -28
- package/index.css +11 -17
- package/package.json +1 -1
- package/styles/api/sizing.css +18 -6
- package/styles/api/text.css +9 -2
- package/styles/foundation/space.css +33 -0
- package/styles/host.css +20 -22
- package/styles/index.css +14 -17
- package/styles/verse.css +14 -0
|
@@ -38,7 +38,7 @@ var tA=Object.defineProperty;var V=(s,t)=>()=>(s&&(t=s(s=0)),t);var Yt=(s,t)=>{f
|
|
|
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=qc.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 F(this.parser.nodeSet.types[t],Hr,Hr,(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(Nm(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?TS(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=Nm(this.parser.parseInline(t.content,t.start),t.marks);this.addNode(this.buffer.writeElements(e,-t.start).finish(T.Paragraph,t.content.length),t.start)}elt(t,e,i,n){return typeof t=="string"?J(this.parser.getNodeType(t),e,i,n):new Wc(t,e)}get buffer(){return new _c(this.parser.nodeSet)}};Jr=class s extends Fe{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 Vc(this,t,e,i);for(let r of this.wrappers)n=r(n,t,e,i);return n}configure(t){let e=Zm(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(bl(e.defineNodes)){n=Object.assign({},n);let d=i.types.slice(),f;for(let p of e.defineNodes){let{name:m,block:O,composite:g,style:y}=typeof p=="string"?{name:p}:p;if(d.some(w=>w.name==m))continue;g&&(n[d.length]=(w,$,A)=>g($,A,w.value));let v=d.length,S=g?["Block","BlockContext"]:O?v>=T.ATXHeading1&&v<=T.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;d.push(lt.define({id:v,name:m,props:S&&[[B.group,S]]})),y&&(f||(f={}),Array.isArray(y)||y instanceof ae?f[m]=y:Object.assign(f,y))}i=new Ye(d),f&&(i=i.extend(Ct(f)))}if(bl(e.props)&&(i=i.extend(...e.props)),bl(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(bl(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?jc(a,d.before):d.after?jc(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(bl(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?jc(h,d.before):d.after?jc(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 Kr(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)}};LS=[lt.none];for(let s=1,t;t=T[s];s++)LS[s]=lt.define({id:s,name:t,props:s>=T.Escape?[]:[[B.group,s in yS?["Block","BlockContext"]:["Block","LeafBlock"]]],top:t=="Document"});Hr=[],_c=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 F.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:t,length:e})}},Gi=class{constructor(t,e,i,n=Hr){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 _c(t).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},Wc=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 Hr}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}};MS={resolve:"Emphasis",mark:"EmphasisMark"},RS={resolve:"Emphasis",mark:"EmphasisMark"},Zs={},Yc={},ee=class{constructor(t,e,i,n){this.type=t,this.from=e,this.to=i,this.side=n}},IS="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",yl=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{yl=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}qm={Escape(s,t,e){if(t!=92||e==s.end-1)return-1;let i=s.char(e+1);for(let n=0;n<IS.length;n++)if(IS.charCodeAt(n)==i)return s.append(J(T.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(J(T.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(J(T.InlineCode,e,i+1,[J(T.CodeMark,e,e+n),J(T.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(J(T.Autolink,e,e+1+n[0].length,[J(T.LinkMark,e,e+1),J(T.URL,e+1,e+n[0].length),J(T.LinkMark,e+n[0].length,e+1+n[0].length)]));let r=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);if(r)return s.append(J(T.Comment,e,e+1+r[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return s.append(J(T.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(J(T.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=yl.test(n),a=yl.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 ee(t==95?MS:RS,e,i,(d?1:0)|(f?2:0)))},HardBreak(s,t,e){if(t==92&&s.char(e+1)==10)return s.append(J(T.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(J(T.HardBreak,e,i+1))}return-1},Link(s,t,e){return t==91?s.append(new ee(Zs,e,e+1,1)):-1},Image(s,t,e){return t==33&&s.char(e+1)==91?s.append(new ee(Yc,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 ee&&(n.type==Zs||n.type==Yc)){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]=uM(s,r,n.type==Zs?T.Link:T.Image,n.from,e+1);if(n.type==Zs)for(let a=0;a<i;a++){let l=s.parts[a];l instanceof ee&&l.type==Zs&&(l.side=0)}return o.to}}return-1}};Kr=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 ee(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 ee&&(e.type==Zs||e.type==Yc))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 ee&&n.type.resolve&&n.side&2))continue;let r=n.type==MS||n.type==RS,o=n.to-n.from,a,l=i-1;for(;l>=t;l--){let m=this.parts[l];if(m instanceof ee&&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 Gi&&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 ee(a.type,a.from,u,a.side):null,(this.parts[i]=r&&n.to!=d?new ee(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 Gi&&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 ee&&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 ee?e:null}skipSpace(t){return Ol(this.text,t-this.offset)+this.offset}elt(t,e,i,n){return typeof t=="string"?J(this.parser.getNodeType(t),e,i,n):new Wc(t,e)}};Kr.linkStart=Zs,Kr.imageStart=Yc;dM=[T.CodeBlock,T.ListItem,T.OrderedList,T.BulletList],Bm=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(B.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=qS(e.from-i,t.ranges);if(e.to-i<=t.ranges[t.rangeI].to)t.addNode(e.tree,c);else{let u=new F(t.parser.nodeSet.types[T.Paragraph],[],[],0,t.block.hashProp);t.reusePlaceholders.set(u,e.tree),t.addNode(u,c)}if(e.type.is("Block")&&(dM.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}};fM=Ct({"Blockquote/...":b.quote,HorizontalRule:b.contentSeparator,"ATXHeading1/... SetextHeading1/...":b.heading1,"ATXHeading2/... SetextHeading2/...":b.heading2,"ATXHeading3/...":b.heading3,"ATXHeading4/...":b.heading4,"ATXHeading5/...":b.heading5,"ATXHeading6/...":b.heading6,"Comment CommentBlock":b.comment,Escape:b.escape,Entity:b.character,"Emphasis/...":b.emphasis,"StrongEmphasis/...":b.strong,"Link/... Image/...":b.link,"OrderedList/... BulletList/...":b.list,"BlockQuote/...":b.quote,"InlineCode CodeText":b.monospace,"URL Autolink":b.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":b.processingInstruction,"CodeInfo LinkLabel":b.labelName,LinkTitle:b.string,Paragraph:b.content}),Vm=new Jr(new Ye(LS).extend(fM),Object.keys(zc).map(s=>zc[s]),Object.keys(zc).map(s=>QS[s]),Object.keys(zc),hM,yS,Object.keys(qm).map(s=>qm[s]),Object.keys(qm),[]);mM={resolve:"Strikethrough",mark:"StrikethroughMark"},NS={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":b.strikethrough}},{name:"StrikethroughMark",style:b.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=yl.test(i),l=yl.test(n);return s.addDelimiter(mM,e,e+2,!o&&(!l||r||a),!r&&(!a||o||l))},after:"Emphasis"}]};zS=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,Fc=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)&&zS.test(n=e.text.slice(e.pos))){let r=[];vl(t,i.content,0,r,i.start)==vl(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=[];vl(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}},VS={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":b.heading}},"TableRow",{name:"TableCell",style:b.content},{name:"TableDelimiter",style:b.processingInstruction}],parseBlock:[{name:"Table",leaf(s,t){return BS(t.content,0)?new Fc:null},endLeaf(s,t,e){if(e.parsers.some(n=>n instanceof Fc)||!BS(t.text,t.basePos))return!1;let i=s.peekLine();return zS.test(i)&&vl(s,t.text,t.basePos)==vl(s,i,t.basePos)},before:"SetextHeading"}]},zm=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}},jS={defineNodes:[{name:"Task",block:!0,style:b.list},{name:"TaskMarker",style:b.atom}],parseBlock:[{name:"TaskList",leaf(s,t){return/^\[[ xX]\][ \t]/.test(t.content)&&s.parentType().name=="ListItem"?new zm:null},after:"SetextHeading"}]},_S=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,WS=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,gM=/[\w-]+\.[\w-]+($|\/)/,YS=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,FS=/\/[a-zA-Z\d@.]+/gy;HS={parseInline:[{name:"Autolink",parse(s,t,e){let i=e-s.offset;if(i&&/\w/.test(s.text[i-1]))return-1;_S.lastIndex=i;let n=_S.exec(s.text),r=-1;if(!n)return-1;if(n[1]||n[2]){if(r=OM(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=GS(s.text,i):(r=GS(s.text,i+n[0].length),r>-1&&n[0]=="xmpp:"&&(FS.lastIndex=r,n=FS.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)}}]},_m=[VS,jS,NS,HS];Wm={defineNodes:[{name:"Superscript",style:b.special(b.content)},{name:"SuperscriptMark",style:b.processingInstruction}],parseInline:[{name:"Superscript",parse:KS(94,"Superscript","SuperscriptMark")}]},Ym={defineNodes:[{name:"Subscript",style:b.special(b.content)},{name:"SubscriptMark",style:b.processingInstruction}],parseInline:[{name:"Subscript",parse:KS(126,"Subscript","SubscriptMark")}]},Fm={defineNodes:[{name:"Emoji",style:b.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 hw={};Yt(hw,{commonmarkLanguage:()=>tg,deleteMarkupBackward:()=>sg,insertNewlineContinueMarkup:()=>ig,insertNewlineContinueMarkupCommand:()=>eg,markdown:()=>lw,markdownKeymap:()=>ng,markdownLanguage:()=>to,pasteURLAsLink:()=>rg});function Um(s){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return t?+t[1]:void 0}function bM(s){return s.name=="OrderedList"||s.name=="BulletList"}function yM(s,t){let e=s;for(;;){let i=e.nextSibling,n;if(!i||(n=Um(i.type))!=null&&n<=t)break;e=i}return e.to}function Gm(s){return new At(tw,s,[],"markdown")}function SM(s,t){return e=>{if(e&&s){let i=null;if(e=/\S*/.exec(e)[0],typeof s=="function"?i=s(e):i=jr.matchLanguageName(s,e,!0),i instanceof jr)return i.support?i.support.language.parser:Yi.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}function sw(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 xl(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 xl(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 xl(r.parent,l,l+c,o[1],h,u,r))}}return i}function nw(s,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(s.from,s.from+10))}function Hm(s,t,e,i=0){for(let n=-1,r=s;;){if(r.name=="ListItem"){let a=nw(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 Km(s,t){let e=/^[ \t]*/.exec(s)[0].length;if(!e||t.facet(Ai)!=" ")return s;let i=Nt(s,4,e),n="";for(let r=i;r>0;)r>=4?(n+=" ",r-=4):(n+=" ",r--);return n+s.slice(e)}function rw(s){return s.name=="QuoteMark"||s.name=="ListMark"}function wM(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 ow(s,t,e){let i="";for(let n=0,r=s.length-2;n<=r;n++)i+=s[n].blank(n<r?Nt(e.text,4,s[n+1].from)-i.length:null,n<r);return Km(i,t)}function kM(s,t){let e=s.resolveInner(t,-1),i=t;rw(e)&&(i=e.from,e=e.parent);for(let n;n=e.childBefore(i);)if(rw(n))i=n.from;else if(n.name=="OrderedList"||n.name=="BulletList")e=n.lastChild,i=e.to;else break;return e}function lw(s={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:i=!0,base:{parser:n}=tg,completeHTMLTags:r=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=aw}=s;if(!(n instanceof Jr))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],h=[a.support,vM],c;o&&h.push(rg),e instanceof mt?(h.push(e.support),c=e.language):e&&(c=e);let u=t||c?SM(t,c):void 0;l.push(jm({codeParser:u,htmlParser:a.language.parser})),i&&h.push(le.high(si.of(ng)));let d=Gm(n.configure(l));return r&&h.push(d.data.of({autocomplete:AM})),new mt(d,h)}function AM(s){let{state:t,pos:e}=s,i=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(e-25,e));if(!i)return null;let n=G(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:$M(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}function $M(){if(Jm)return Jm;let s=Xc(new Ds(it.create({extensions:aw}),0,!0));return Jm=s?s.options:[]}var tw,ew,iw,vM,tg,xM,to,xl,eg,ig,sg,ng,aw,Jm,CM,rg,cw=V(()=>{ti();yi();oi();mm();JS();Pm();Ze();tw=Ts({commentTokens:{block:{open:"<!--",close:"-->"}}}),ew=new B,iw=Vm.configure({props:[te.add(s=>!s.is("Block")||s.is("Document")||Um(s)!=null||bM(s)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),ew.add(Um),Jt.add({Document:()=>null}),ni.add({Document:tw})]});vM=bc.of((s,t,e)=>{for(let i=G(s).resolveInner(e,-1);i&&!(i.from<t);i=i.parent){let n=i.type.prop(ew);if(n==null)continue;let r=yM(i,n);if(r>e)return{from:e,to:r}}return null});tg=Gm(iw),xM=iw.configure([_m,Ym,Wm,Fm,{props:[te.add({Table:(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}]),to=Gm(xM);xl=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(+nw(this.item,t)[2]+e):"";return this.spaceBefore+i+this.type+this.spaceAfter}};eg=(s={})=>({state:t,dispatch:e})=>{let i=G(t),{doc:n}=t,r=null,o=t.changeByRange(a=>{if(!a.empty||!to.isActiveAt(t,a.from,-1)&&!to.isActiveAt(t,a.from,1))return r={range:a};let l=a.from,h=n.lineAt(l),c=sw(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){let g=u.node.firstChild,y=u.node.getChild("ListItem","ListItem");if(g.to>=l||y&&y.to<l||h.from>0&&!/[^\s>]/.test(n.lineAt(h.from-1).text)||s.nonTightLists===!1){let v=c.length>1?c[c.length-2]:null,S,w="";v&&v.item?(S=h.from+v.from,w=v.marker(n,1)):S=h.from+(v?v.to:0);let $=[{from:S,to:l,insert:w}];return u.node.name=="OrderedList"&&Hm(u.item,n,$,-2),v&&v.node.name=="OrderedList"&&Hm(v.item,n,$),{range:C.cursor(S+w.length),changes:$}}else{let v=ow(c,t,h);return{range:C.cursor(l+v.length+1),changes:{from:h.from,insert:v+t.lineBreak}}}}if(u.node.name=="Blockquote"&&d&&h.from){let g=n.lineAt(h.from-1),y=/>\s*$/.exec(g.text);if(y&&y.index==u.from){let v=t.changes([{from:g.from+y.index,to:g.to},{from:h.from+u.from,to:h.to}]);return{range:a.map(v),changes:v}}}let f=[];u.node.name=="OrderedList"&&Hm(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 g=0,y=c.length-1;g<=y;g++)m+=g==y&&!p?c[g].marker(n,1):c[g].blank(g<y?Nt(h.text,4,c[g+1].from)-m.length:null);let O=l;for(;O>h.from&&/\s/.test(h.text.charAt(O-h.from-1));)O--;return m=Km(m,t),wM(u.node,t.doc)&&(m=ow(c,t,h)+t.lineBreak+m),f.push({from:O,to:l,insert:t.lineBreak+m}),{range:C.cursor(O+m.length+1),changes:f}});return r?!1:(e(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},ig=eg();sg=({state:s,dispatch:t})=>{let e=G(s),i=null,n=s.changeByRange(r=>{let o=r.from,{doc:a}=s;if(r.empty&&to.isActiveAt(s,r.from)){let l=a.lineAt(o),h=sw(kM(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:C.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(Nt(l.text,4,c.to)-Nt(l.text,4,c.from));return d==l.from&&(f=Km(f,s)),{range:C.cursor(d+f.length),changes:{from:d,to:l.from+c.to,insert:f}}}if(d<o)return{range:C.cursor(d),changes:{from:d,to:o}}}}}return i={range:r}});return i?!1:(t(s.update(n,{scrollIntoView:!0,userEvent:"delete"})),!0)},ng=[{key:"Enter",run:ig},{key:"Backspace",run:sg}],aw=Zc({matchClosingTags:!1});Jm=null;CM=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,rg=M.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),!to.isActiveAt(t.state,i.from,1)))return!1;let r=G(t.state),o=!1;return r.iterate({from:i.from,to:i.to,enter:a=>{(a.from>i.from||CM.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 wl(s,t){for(let e=0,i=t-s.pos-1;;i--,e++){let n=s.peek(i);if(Qi(n)||n==-1)return e}}function hg(s){return s==32||s==9}function Qi(s){return s==10||s==13}function gw(s){return hg(s)||Qi(s)}function qs(s){return s<0||gw(s)}function io(s,t,e=0){return s.peek(e)==t&&s.peek(e+1)==t&&s.peek(e+2)==t&&qs(s.peek(e+3))}function UM(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 Ow(s){return s>=48&&s<=57||s>=97&&s<=102||s>=65&&s<=70}function bw(s,t){return s.next==37?(s.advance(),Ow(s.next)&&s.advance(),Ow(s.next)&&s.advance(),!0):UM(s.next)||t&&s.next==44?(s.advance(),!0):!1}function yw(s){if(s.advance(),s.next==60){for(s.advance();;)if(!bw(s,!0)){s.next==62&&s.advance();break}}else for(;bw(s,!1););}function cg(s){for(s.advance();!qs(s.next)&&Uc(s.next)!="f";)s.advance()}function ug(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(Qi(r)){if(t)return!1;i=!0}else if(t&&s.pos>=n+1024)return!1}return!i}function GM(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(!ug(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||Qi(s.next))return!1;s.advance()}}function Uc(s){return s<33?"u":s>125?"s":HM[s-33]}function dg(s,t){let e=Uc(s);return e!="u"&&!(t&&e=="f")}function vw(s,t,e,i){if(Uc(s.next)=="s"||(s.next==63||s.next==58||s.next==45)&&dg(s.peek(1),e))s.advance();else return!1;let n=s.pos;for(;;){let r=s.next,o=0,a=i+1;for(;gw(r);){if(Qi(r)){if(t)return!1;a=0}else a++;r=s.peek(++o)}if(!(r>=0&&(r==58?dg(s.peek(o+1),e):r==35?s.peek(o-1)!=32:dg(r,e)))||!e&&a<=i||a==0&&!e&&(io(s,45,o)||io(s,46,o)))break;if(t&&Uc(r)=="f")return!1;for(let h=o;h>=0;h--)s.advance();if(t&&s.pos>n+1024)return!1}return!0}var eo,uw,EM,PM,dw,QM,fw,TM,LM,pw,MM,RM,IM,DM,XM,ZM,mw,qM,NM,BM,zM,VM,jM,_M,og,ag,Sl,lg,Pi,WM,YM,FM,HM,KM,JM,t2,fg,xw=V(()=>{ps();Ke();eo=63,uw=64,EM=1,PM=2,dw=3,QM=4,fw=5,TM=6,LM=7,pw=65,MM=66,RM=8,IM=9,DM=10,XM=11,ZM=12,mw=13,qM=19,NM=20,BM=29,zM=33,VM=34,jM=47,_M=0,og=1,ag=2,Sl=3,lg=4,Pi=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}};Pi.top=new Pi(null,-1,_M);WM=new pi({start:Pi.top,reduce(s,t){return s.type==Sl&&(t==NM||t==VM)?s.parent:s},shift(s,t,e,i){if(t==dw)return new Pi(s,wl(i,i.pos),og);if(t==pw||t==fw)return new Pi(s,wl(i,i.pos),ag);if(t==eo)return s.parent;if(t==qM||t==zM)return new Pi(s,0,Sl);if(t==mw&&s.type==lg)return s.parent;if(t==jM){let n=/[1-9]/.exec(i.read(i.pos,e.pos));if(n)return new Pi(s,s.depth+ +n[0],lg)}return s},hash(s){return s.hash}});YM=new ht((s,t)=>{if(s.next==-1&&t.canShift(uw))return s.acceptToken(uw);let e=s.peek(-1);if((Qi(e)||e<0)&&t.context.type!=Sl){if(io(s,45))if(t.canShift(eo))s.acceptToken(eo);else return s.acceptToken(EM,3);if(io(s,46))if(t.canShift(eo))s.acceptToken(eo);else return s.acceptToken(PM,3);let i=0;for(;s.next==32;)i++,s.advance();(i<t.context.depth||i==t.context.depth&&t.context.type==og&&(s.next!=45||!qs(s.peek(1))))&&s.next!=-1&&!Qi(s.next)&&s.next!=35&&s.acceptToken(eo,-i)}},{contextual:!0}),FM=new ht((s,t)=>{if(t.context.type==Sl){s.next==63&&(s.advance(),qs(s.next)&&s.acceptToken(LM));return}if(s.next==45)s.advance(),qs(s.next)&&s.acceptToken(t.context.type==og&&t.context.depth==wl(s,s.pos-1)?QM:dw);else if(s.next==63)s.advance(),qs(s.next)&&s.acceptToken(t.context.type==ag&&t.context.depth==wl(s,s.pos-1)?TM:fw);else{let e=s.pos;for(;;)if(hg(s.next)){if(s.pos==e)return;s.advance()}else if(s.next==33)yw(s);else if(s.next==38)cg(s);else if(s.next==42){cg(s);break}else if(s.next==39||s.next==34){if(ug(s,!0))break;return}else if(s.next==91||s.next==123){if(!GM(s))return;break}else{vw(s,!0,!1,0);break}for(;hg(s.next);)s.advance();if(s.next==58){if(s.pos==e&&t.canShift(BM))return;let i=s.peek(1);qs(i)&&s.acceptTokenTo(t.context.type==ag&&t.context.depth==wl(s,e)?MM:pw,e)}}},{contextual:!0});HM="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";KM=new ht((s,t)=>{if(s.next==33)yw(s),s.acceptToken(ZM);else if(s.next==38||s.next==42){let e=s.next==38?DM:XM;cg(s),s.acceptToken(e)}else s.next==39||s.next==34?(ug(s,!1),s.acceptToken(IM)):vw(s,!1,t.context.type==Sl,t.context.depth)&&s.acceptToken(RM)}),JM=new ht((s,t)=>{let e=t.context.type==lg?t.context.depth:-1,i=s.pos;t:for(;;){let n=0,r=s.next;for(;r==32;)r=s.peek(++n);if(!n&&(io(s,45,n)||io(s,46,n))||!Qi(r)&&(e<0&&(e=Math.max(t.context.depth+1,n)),n<e))break;for(;;){if(s.next<0)break t;let o=Qi(s.next);if(s.advance(),o)continue t;i=s.pos}}s.acceptTokenTo(mw,i)}),t2=Ct({DirectiveName:b.keyword,DirectiveContent:b.attributeValue,"DirectiveEnd DocEnd":b.meta,QuotedLiteral:b.string,BlockLiteralHeader:b.special(b.string),BlockLiteralContent:b.content,Literal:b.content,"Key/Literal Key/QuotedLiteral":b.definition(b.propertyName),"Anchor Alias":b.labelName,Tag:b.typeName,Comment:b.lineComment,": , -":b.separator,"?":b.punctuation,"[ ]":b.squareBracket,"{ }":b.brace}),fg=Ft.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:WM,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[t2],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:[YM,FM,KM,JM,0,1],topRules:{Stream:[0,15]},tokenPrec:0})});var kw={};Yt(kw,{yaml:()=>Sw,yamlFrontmatter:()=>ww,yamlLanguage:()=>Gc});function Sw(){return new mt(Gc)}function ww(s){let{language:t,support:e}=s.content instanceof mt?s.content:{language:s.content,support:[]};return new mt(i2.configure({wrap:fs(i=>i.name=="FrontmatterContent"?{parser:Gc.parser}:i.name=="Body"?{parser:t.parser}:null)}),e)}var e2,Gc,i2,Aw=V(()=>{xw();oi();Ze();Ke();ps();e2=Ft.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}),Gc=de.define({name:"yaml",parser:fg.configure({props:[Jt.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:Wr({closing:"}"}),FlowSequence:Wr({closing:"]"})}),te.add({"FlowMapping FlowSequence":$i,"Item Pair BlockLiteral":(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});i2=de.define({name:"yaml-frontmatter",parser:e2.configure({props:[Ct({DashLine:b.meta})]})})});function Ns(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 pg(s,t){let e=s.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}function a2(s,{open:t,close:e},i,n){let r=s.sliceDoc(i-kl,i),o=s.sliceDoc(n,n+kl),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*kl?c=u=s.sliceDoc(i,n):(c=s.sliceDoc(i,i+kl),u=s.sliceDoc(n-kl,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 l2(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 Hc(s,t,e=t.selection.ranges){let i=e.map(r=>pg(t,r.from).block);if(!i.every(r=>r))return null;let n=e.map((r,o)=>a2(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 mg(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=pg(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[Kc,Lw.of(s),M.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?Og:t.inputType=="historyRedo"?tu:null;return i?(t.preventDefault(),i(e)):!1}})]}function Jc(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let n=e.field(Kc,!1);if(!n)return!1;let r=n.pop(s,e,t);return r?(i(r),!0):!1}}function Iw(s){return function(t){let e=t.field(Kc,!1);if(!e)return 0;let i=s==0?e.done:e.undone;return i.length-(i.length&&!i[0].changes?1:0)}}function eu(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 d2(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 f2(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function Dw(s,t){return s.length?t.length?s.concat(t):s:t}function Xw(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-p2));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),eu(s,s.length-1,1e9,e.setSelAfter(i)))}else return[Ne.selection([t])]}function m2(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 bg(s,t){if(!s.length)return s;let e=s.length,i=Re;for(;e;){let n=g2(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?[Ne.selection(i)]:Re}function g2(s,t,e){let i=Dw(s.selectionsAfter.length?s.selectionsAfter.map(a=>a.map(t)):Re,e);if(!s.changes)return Ne.selection(i);let n=s.changes.map(t),r=t.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(r):r;return new Ne(n,j.mapEffects(s.effects,t),o,s.startSelection.map(r),i)}function so(s,t){return C.create(s.ranges.map(t),s.mainIndex)}function Be(s,t){return s.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function pe({state:s,dispatch:t},e){let i=so(s.selection,e);return i.eq(s.selection,!0)?!1:(t(Be(s,i)),!0)}function zs(s,t){return C.cursor(t?s.to:s.from)}function iu(s,t){return pe(s,e=>e.empty?s.moveByChar(e,t):zs(e,t))}function zt(s){return s.textDirectionAt(s.state.selection.main.head)==tt.LTR}function xg(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+yt(n.text,i-n.from,e),C.cursor(i,e?-1:1)}function Zw(s,t){return pe(s,e=>e.empty?xg(s.state,e,t):zs(e,t))}function su(s,t){return pe(s,e=>e.empty?s.moveByGroup(e,t):zs(e,t))}function Sg(s,t,e){let i=s.state.charCategorizer(t),n=i(e),r=n!=ct.Space;return o=>{let a=i(o);return a!=ct.Space?r&&a==n:(r=!1,!0)}}function zw(s,t,e){let i=s.state.charCategorizer(t.from),n=ct.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==ct.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(f=-1),n==ct.Space&&(n=f),n!=f)return!1;if(n==ct.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))==ct.Word&&p.toLowerCase()==p)return!1;l=!0}return o++,!0},u=s.moveByChar(t,e,d=>(c(d),c));if(Bw&&n==ct.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(Bw.segment(p));if(m.length>1)return e?C.cursor(t.head+m[1].index,-1):C.cursor(u.head+m[m.length-1].index,1)}}return u}function Vw(s,t){return pe(s,e=>e.empty?zw(s,e,t):zs(e,t))}function C2(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 nu(s,t,e){let i=G(s).resolveInner(t.head),n=e?B.closedBy:B.openedBy;for(let l=t.head;;){let h=e?i.childAfter(l):i.childBefore(l);if(!h)break;C2(s,h,n)?i=h:l=e?h.to:h.from}let r=i.type.prop(n),o,a;return r&&(o=e?Le(s,i.from,1):Le(s,i.to,-1))&&o.matched?a=e?o.end.to:o.end.from:a=e?i.to:i.from,C.cursor(a,e?-1:1)}function Ww(s,t){return pe(s,e=>{if(!e.empty)return zs(e,t);let i=s.moveVertically(e,t);return i.head!=e.head?i:s.moveToLineBoundary(e,t)})}function Yw(s){let t=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,e=0,i=0,n;if(t){for(let r of s.state.facet(M.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 Fw(s,t){let e=Yw(s),{state:i}=s,n=so(i.selection,o=>o.empty?s.moveVertically(o,t,e.height):zs(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=M.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-l}))}return s.dispatch(Be(i,n),{effects:r}),!0}function Hi(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=C.cursor(i.from+r))}return n}function ek(s,t,e){let i=!1,n=so(s.selection,r=>{let o=Le(s,r.head,-1)||Le(s,r.head,1)||r.head>0&&Le(s,r.head-1,1)||r.head<s.doc.length&&Le(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?C.range(r.anchor,a):C.cursor(a)});return i?(t(Be(s,n)),!0):!1}function Vt(s,t){let e=so(s.state.selection,i=>{let n=t(i);return C.range(i.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return e.eq(s.state.selection)?!1:(s.dispatch(Be(s.state,e)),!0)}function ou(s,t){return Vt(s,e=>s.moveByChar(e,t))}function au(s,t){return Vt(s,e=>s.moveByGroup(e,t))}function rk(s,t){return Vt(s,e=>zw(s,e,t))}function lk(s,t){return Vt(s,e=>s.moveVertically(e,t))}function hk(s,t){return Vt(s,e=>s.moveVertically(e,t,Yw(s).height))}function yk(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(Be(e,C.create(n,n.length-1))),!0)}function Vs(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:C.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"?M.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function lu(s,t,e){if(s instanceof M)for(let i of s.state.facet(M.atomicRanges).map(n=>n(s)))i.between(t,t,(n,r)=>{n<t&&r>t&&(t=e?r:n)});return t}function cu(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 Qk(s,t,e){if(s.readOnly)return!1;let i=[],n=[];for(let r of cu(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(C.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(C.range(l.anchor-a,l.head-a))}}return i.length?(t(s.update({changes:i,scrollIntoView:!0,selection:C.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}function Mk(s,t,e){if(s.readOnly)return!1;let i=[];for(let r of cu(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 j2(s,t){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=G(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(B.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 Zk(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&&j2(t,r);s&&(r=o=(o<=a.to?a:t.doc.lineAt(o)).to);let h=new Si(t,{simulateBreak:r,simulateDoubleBreak:!!l}),c=_r(h,r);for(c==null&&(c=Nt(/^\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=["",Fi(t,c)];return l&&u.push(Fi(t,h.lineIndent(a.from,-1))),{changes:{from:r,to:o,insert:H.of(u)},range:C.cursor(r+1+u[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ng(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:C.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}var $w,Cw,s2,n2,Ew,r2,o2,Pw,kl,gg,Qw,Tw,Lw,Kc,h2,Og,tu,Mw,Rw,c2,u2,Ne,Re,p2,O2,Bs,fu,yg,vg,b2,y2,v2,x2,qw,Nw,S2,w2,k2,Bw,A2,$2,jw,_w,wg,kg,Ag,ru,Uw,Gw,Hw,Kw,Jw,tk,ik,E2,$g,Cg,P2,Q2,T2,L2,sk,nk,M2,R2,I2,D2,X2,ok,ak,Eg,Pg,Qg,Tg,ck,uk,dk,fk,pk,mk,Lg,Mg,Rg,Ig,gk,Ok,bk,vk,xk,Sk,Dg,hu,Z2,Xg,wk,Zg,kk,q2,Ak,N2,$k,Ck,B2,Ek,Pk,Tk,Lk,Rk,Ik,Dk,z2,V2,qg,Xk,qk,uu,Bg,Nk,_2,W2,Bk,zk,pu,mu,Vk=V(()=>{ti();yi();oi();Ze();$w=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.from),i=pg(s.state,e.from);return i.line?Cw(s):i.block?Pw(s):!1};Cw=Ns(mg,0),s2=Ns(mg,1),n2=Ns(mg,2),Ew=Ns(Hc,0),r2=Ns(Hc,1),o2=Ns(Hc,2),Pw=Ns((s,t)=>Hc(s,t,l2(t)),0);kl=50;gg=Ut.define(),Qw=Ut.define(),Tw=I.define(),Lw=I.define({combine(s){return Gt(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)})}}),Kc=ut.define({create(){return Bs.empty},update(s,t){let e=t.state.facet(Lw),i=t.annotation(gg);if(i){let l=Ne.fromTransaction(t,i.selection),h=i.side,c=h==0?s.undone:s.done;return l?c=eu(c,c.length,e.minDepth,l):c=Xw(c,t.startState.selection),new Bs(h==0?i.rest:c,h==0?c:i.rest)}let n=t.annotation(Qw);if((n=="full"||n=="before")&&(s=s.isolate()),t.annotation(pt.addToHistory)===!1)return t.changes.empty?s:s.addMapping(t.changes.desc);let r=Ne.fromTransaction(t),o=t.annotation(pt.time),a=t.annotation(pt.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 Bs(s.done.map(Ne.fromJSON),s.undone.map(Ne.fromJSON))}});h2=Kc;Og=Jc(0,!1),tu=Jc(1,!1),Mw=Jc(0,!0),Rw=Jc(1,!0);c2=Iw(0),u2=Iw(1),Ne=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&&Zt.fromJSON(t.changes),[],t.mapped&&Je.fromJSON(t.mapped),t.startSelection&&C.fromJSON(t.startSelection),t.selectionsAfter.map(C.fromJSON))}static fromTransaction(t,e){let i=Re;for(let n of t.startState.facet(Tw)){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,Re)}static selection(t){return new s(void 0,Re,void 0,void 0,t)}};Re=[],p2=200;O2=/^(input\.type|delete)($|\.)/,Bs=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||O2.test(i))&&(!a.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,d2(a.changes,t.changes))||i=="input.type.compose")?o=eu(o,o.length-1,n.minDepth,new Ne(t.changes.compose(a.changes),Dw(j.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,Re)):o=eu(o,o.length,n.minDepth,t),new s(o,Re,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Re;return r.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&f2(r[r.length-1],t)?this:new s(Xw(this.done,t),this.undone,e,i)}addMapping(t){return new s(bg(this.done,t),bg(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:gg.of({side:t,rest:m2(n),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let a=n.length==1?Re:n.slice(0,n.length-1);return r.mapped&&(a=bg(a,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:gg.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};Bs.empty=new Bs(Re,Re);fu=[{key:"Mod-z",run:Og,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:tu,preventDefault:!0},{linux:"Ctrl-Shift-z",run:tu,preventDefault:!0},{key:"Mod-u",run:Mw,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Rw,preventDefault:!0}];yg=s=>iu(s,!zt(s)),vg=s=>iu(s,zt(s)),b2=s=>iu(s,!0),y2=s=>iu(s,!1);v2=s=>Zw(s,!0),x2=s=>Zw(s,!1);qw=s=>su(s,!zt(s)),Nw=s=>su(s,zt(s)),S2=s=>su(s,!0),w2=s=>su(s,!1);k2=s=>pe(s,t=>t.empty?s.moveByChar(t,!0,e=>Sg(s,t.head,e)):zs(t,!0)),Bw=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;A2=s=>Vw(s,!0),$2=s=>Vw(s,!1);jw=s=>pe(s,t=>nu(s.state,t,!zt(s))),_w=s=>pe(s,t=>nu(s.state,t,zt(s)));wg=s=>Ww(s,!1),kg=s=>Ww(s,!0);Ag=s=>Fw(s,!1),ru=s=>Fw(s,!0);Uw=s=>pe(s,t=>Hi(s,t,!0)),Gw=s=>pe(s,t=>Hi(s,t,!1)),Hw=s=>pe(s,t=>Hi(s,t,!zt(s))),Kw=s=>pe(s,t=>Hi(s,t,zt(s))),Jw=s=>pe(s,t=>C.cursor(s.lineBlockAt(t.head).from,1)),tk=s=>pe(s,t=>C.cursor(s.lineBlockAt(t.head).to,-1));ik=({state:s,dispatch:t})=>ek(s,t,!1),E2=({state:s,dispatch:t})=>ek(s,t,!0);$g=s=>ou(s,!zt(s)),Cg=s=>ou(s,zt(s)),P2=s=>ou(s,!0),Q2=s=>ou(s,!1),T2=s=>Vt(s,t=>xg(s.state,t,!0)),L2=s=>Vt(s,t=>xg(s.state,t,!1));sk=s=>au(s,!zt(s)),nk=s=>au(s,zt(s)),M2=s=>au(s,!0),R2=s=>au(s,!1),I2=s=>Vt(s,t=>s.moveByChar(t,!0,e=>Sg(s,t.head,e)));D2=s=>rk(s,!0),X2=s=>rk(s,!1),ok=s=>Vt(s,t=>nu(s.state,t,!zt(s))),ak=s=>Vt(s,t=>nu(s.state,t,zt(s)));Eg=s=>lk(s,!1),Pg=s=>lk(s,!0);Qg=s=>hk(s,!1),Tg=s=>hk(s,!0),ck=s=>Vt(s,t=>Hi(s,t,!0)),uk=s=>Vt(s,t=>Hi(s,t,!1)),dk=s=>Vt(s,t=>Hi(s,t,!zt(s))),fk=s=>Vt(s,t=>Hi(s,t,zt(s))),pk=s=>Vt(s,t=>C.cursor(s.lineBlockAt(t.head).from)),mk=s=>Vt(s,t=>C.cursor(s.lineBlockAt(t.head).to)),Lg=({state:s,dispatch:t})=>(t(Be(s,{anchor:0})),!0),Mg=({state:s,dispatch:t})=>(t(Be(s,{anchor:s.doc.length})),!0),Rg=({state:s,dispatch:t})=>(t(Be(s,{anchor:s.selection.main.anchor,head:0})),!0),Ig=({state:s,dispatch:t})=>(t(Be(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),gk=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),Ok=({state:s,dispatch:t})=>{let e=cu(s).map(({from:i,to:n})=>C.range(i,Math.min(n+1,s.doc.length)));return t(s.update({selection:C.create(e),userEvent:"select"})),!0},bk=({state:s,dispatch:t})=>{let e=so(s.selection,i=>{let n=G(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 C.range(a.to,a.from)}return i});return e.eq(s.selection)?!1:(t(Be(s,e)),!0)};vk=s=>yk(s,!1),xk=s=>yk(s,!0),Sk=({state:s,dispatch:t})=>{let e=s.selection,i=null;return e.ranges.length>1?i=C.create([e.main]):e.main.empty||(i=C.create([C.cursor(e.main.head)])),i?(t(Be(s,i)),!0):!1};Dg=(s,t,e)=>Vs(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=Nt(a,r.tabSize),c=h%wi(r)||wi(r);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)n--;l=n}else l=yt(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=yt(o.text,l-o.from,!1,!1)+o.from);return l}),hu=s=>Dg(s,!1,!0),Z2=s=>Dg(s,!1,!1),Xg=s=>Dg(s,!0,!1),wk=(s,t)=>Vs(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=yt(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}),Zg=s=>wk(s,!1),kk=s=>wk(s,!0),q2=s=>Vs(s,t=>s.moveByChar(t,!0,e=>Sg(s,t.head,e)).head),Ak=s=>Vs(s,t=>{let e=s.lineBlockAt(t.head).to;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),N2=s=>Vs(s,t=>{let e=s.lineBlockAt(t.head).from;return t.head>e?e:Math.max(0,t.head-1)}),$k=s=>Vs(s,t=>{let e=s.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),Ck=s=>Vs(s,t=>{let e=s.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),B2=({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},Ek=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:H.of(["",""])},range:C.cursor(i.from)}));return t(s.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},Pk=({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:yt(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:yt(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:C.cursor(a)}});return e.changes.empty?!1:(t(s.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};Tk=({state:s,dispatch:t})=>Qk(s,t,!1),Lk=({state:s,dispatch:t})=>Qk(s,t,!0);Rk=({state:s,dispatch:t})=>Mk(s,t,!1),Ik=({state:s,dispatch:t})=>Mk(s,t,!0),Dk=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(cu(t).map(({from:n,to:r})=>(n>0?n--:r<t.doc.length&&r++,{from:n,to:r}))),i=so(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},z2=({state:s,dispatch:t})=>(t(s.update(s.replaceSelection(s.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),V2=({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:C.cursor(e.from+i.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);qg=Zk(!1),Xk=Zk(!0);qk=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=Object.create(null),i=new Si(s,{overrideIndentation:r=>{let o=e[r];return o??-1}}),n=Ng(s,(r,o,a)=>{let l=_r(i,r.from);if(l==null)return;/\S/.test(r.text)||(l=0);let h=/^\s*/.exec(r.text)[0],c=Fi(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},uu=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Ng(s,(e,i)=>{i.push({from:e.from,insert:s.facet(Ai)})}),{userEvent:"input.indent"})),!0),Bg=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Ng(s,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=Nt(n,s.tabSize),o=0,a=Fi(s,Math.max(0,r-wi(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),Nk=s=>(s.setTabFocusMode(),!0),_2=s=>(s.setTabFocusMode(2e3),!0),W2=({state:s,dispatch:t})=>s.selection.ranges.some(e=>!e.empty)?uu({state:s,dispatch:t}):(t(s.update(s.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),Bk=[{key:"Ctrl-b",run:yg,shift:$g,preventDefault:!0},{key:"Ctrl-f",run:vg,shift:Cg},{key:"Ctrl-p",run:wg,shift:Eg},{key:"Ctrl-n",run:kg,shift:Pg},{key:"Ctrl-a",run:Jw,shift:pk},{key:"Ctrl-e",run:tk,shift:mk},{key:"Ctrl-d",run:Xg},{key:"Ctrl-h",run:hu},{key:"Ctrl-k",run:Ak},{key:"Ctrl-Alt-h",run:Zg},{key:"Ctrl-o",run:Ek},{key:"Ctrl-t",run:Pk},{key:"Ctrl-v",run:ru}],zk=[{key:"ArrowLeft",run:yg,shift:$g,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:qw,shift:sk,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Hw,shift:dk,preventDefault:!0},{key:"ArrowRight",run:vg,shift:Cg,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Nw,shift:nk,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Kw,shift:fk,preventDefault:!0},{key:"ArrowUp",run:wg,shift:Eg,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Lg,shift:Rg},{mac:"Ctrl-ArrowUp",run:Ag,shift:Qg},{key:"ArrowDown",run:kg,shift:Pg,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Mg,shift:Ig},{mac:"Ctrl-ArrowDown",run:ru,shift:Tg},{key:"PageUp",run:Ag,shift:Qg},{key:"PageDown",run:ru,shift:Tg},{key:"Home",run:Gw,shift:uk,preventDefault:!0},{key:"Mod-Home",run:Lg,shift:Rg},{key:"End",run:Uw,shift:ck,preventDefault:!0},{key:"Mod-End",run:Mg,shift:Ig},{key:"Enter",run:qg,shift:qg},{key:"Mod-a",run:gk},{key:"Backspace",run:hu,shift:hu,preventDefault:!0},{key:"Delete",run:Xg,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Zg,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:kk,preventDefault:!0},{mac:"Mod-Backspace",run:$k,preventDefault:!0},{mac:"Mod-Delete",run:Ck,preventDefault:!0}].concat(Bk.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),pu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:jw,shift:ok},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:_w,shift:ak},{key:"Alt-ArrowUp",run:Tk},{key:"Shift-Alt-ArrowUp",run:Rk},{key:"Alt-ArrowDown",run:Lk},{key:"Shift-Alt-ArrowDown",run:Ik},{key:"Mod-Alt-ArrowUp",run:vk},{key:"Mod-Alt-ArrowDown",run:xk},{key:"Escape",run:Sk},{key:"Mod-Enter",run:Xk},{key:"Alt-l",mac:"Ctrl-l",run:Ok},{key:"Mod-i",run:bk,preventDefault:!0},{key:"Mod-[",run:Bg},{key:"Mod-]",run:uu},{key:"Mod-Alt-\\",run:qk},{key:"Shift-Mod-k",run:Dk},{key:"Shift-Mod-\\",run:ik},{key:"Mod-/",run:$w},{key:"Alt-A",run:Ew},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Nk}].concat(zk),mu={key:"Tab",run:uu,shift:Bg}});function Ki(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 gu(n,r,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new gu(i.from,r,i.diagnostic)}}),i}function jk(s,t){let e=t.pos,i=t.end||e,n=s.state.facet(ai).hideOn(s,e,i);if(n!=null)return n;let r=s.startState.doc.lineAt(t.pos);return!!(s.effects.some(o=>o.is(Al))||s.changes.touchesRange(r.from,Math.max(r.to,i)))}function _k(s,t){return s.field(jt,!1)?t:t.concat(j.appendConfig.of(s1))}function Wk(s,t){return{effects:_k(s,[Al.of(t)])}}function Y2(s){let t=s.field(jt,!1);return t?t.diagnostics.size:0}function U2(s,t,e){let{diagnostics:i}=s.state.field(jt),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(ai).tooltipFilter;return n&&a&&(n=a(n,s.state)),n?{pos:r,end:o,above:s.state.doc.lineAt(r).to<o,create(){return{dom:Fk(s,n)}}}:null}function Fk(s,t){return wt("ul",{class:"cm-tooltip-lint"},t.map(e=>t1(s,e,!1)))}function K2(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 Kk(s,t){return s?t?(e,i)=>t(s(e,i),i):s:t}function Cl(s,t={}){return[ai.of({source:s,config:t}),Hk,s1]}function J2(s){let t=s.plugin(Hk);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 t1(s,t,e){var i;let n=e?Jk(t.actions):[];return wt("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},wt("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=Ki(s.state.field(jt).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),wt("u",h.slice(c,c+1)),h.slice(c+1)],d=r.markClass?" "+r.markClass:"";return wt("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[o]})"`}.`},u)}),t.source&&wt("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 yu(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 eR(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function e1(s){let t="hint",e=1;for(let i of s){let n=eR(i.severity);n>e&&(e=n,t=i.severity)}return t}function iR(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(i1)&&s.dispatch({effects:Wg.of(null)})}};window.addEventListener("mousemove",e)}function sR(s,t,e){function i(){let o=s.elementAtHeight(t.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:Wg.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Fk(s,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,iR(s,t)}let{hoverTime:n}=s.state.facet(xu),r=setTimeout(i,n);t.onmouseout=()=>{clearTimeout(r),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,n)}}function nR(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 vu(e[n]).range(+n));return U.of(i,!0)}function Su(s={}){return[xu.of(s),_g,rR,oR,i1]}function aR(s,t){let e=s.field(jt,!1);if(e&&e.diagnostics.size){let i=[],n=[],r=-1;for(let o=U.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 gu,js,Al,zg,Yk,jt,F2,Uk,Vg,Gk,G2,H2,Hk,ai,jg,Ou,$l,tR,vu,rR,_g,Wg,i1,oR,s1,xu,n1=V(()=>{yi();ti();Jd();gu=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},js=class s{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=i.facet(ai).markerFilter;n&&(t=n(t,i));let r=t.slice().sort((f,p)=>f.from-p.from||f.to-p.to),o=new Se,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,O;if(a.length)m=l,O=a.reduce((v,S)=>Math.min(v,S.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;O=p.to,a.push(p),f++}for(;f<r.length;){let v=r[f];if(v.from==m&&(v.to>v.from||v.to==m))a.push(v),f++,O=Math.min(v.to,O);else{O=Math.min(v.from,O);break}}O=Math.min(O,u);let g=!1;if(a.some(v=>v.from==m&&(v.to==O||O==u))&&(g=m==O,!g&&O-m<10)){let v=m-(c+h.value.length);v>0&&(h.next(v),c=m);for(let S=m;;){if(S>=O){g=!0;break}if(!h.lineBreak&&c+h.value.length>S)break;S=c+h.value.length,c+=h.value.length,h.next()}}let y=e1(a);if(g)o.add(m,m,z.widget({widget:new jg(y),diagnostics:a.slice()}));else{let v=a.reduce((S,w)=>w.markClass?S+" "+w.markClass:S,"");o.add(m,O,z.mark({class:"cm-lintRange cm-lintRange-"+y+v,diagnostics:a.slice(),inclusiveEnd:a.some(S=>S.to>O)}))}if(l=O,l==u)break;for(let v=0;v<a.length;v++)a[v].to<=l&&a.splice(v--,1)}let d=o.finish();return new s(d,e,Ki(d))}};Al=j.define(),zg=j.define(),Yk=j.define(),jt=ut.define({create(){return new js(z.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=Ki(e,s.selected.diagnostic,r)||Ki(e,null,r)}!e.size&&n&&t.state.facet(ai).autoPanel&&(n=null),s=new js(e,n,i)}for(let e of t.effects)if(e.is(Al)){let i=t.state.facet(ai).autoPanel?e.value.length?$l.open:null:s.panel;s=js.init(e.value,i,t.state)}else e.is(zg)?s=new js(s.diagnostics,e.value?$l.open:null,s.selected):e.is(Yk)&&(s=new js(s.diagnostics,s.panel,e.value));return s},provide:s=>[Br.from(s,t=>t.panel),M.decorations.from(s,t=>t.diagnostics)]});F2=z.mark({class:"cm-lintRange cm-lintRange-active"});Uk=s=>{let t=s.state.field(jt,!1);(!t||!t.panel)&&s.dispatch({effects:_k(s.state,[zg.of(!0)])});let e=oc(s,$l.open);return e&&e.dom.querySelector(".cm-panel-lint ul").focus(),!0},Vg=s=>{let t=s.state.field(jt,!1);return!t||!t.panel?!1:(s.dispatch({effects:zg.of(!1)}),!0)},Gk=s=>{let t=s.state.field(jt,!1);if(!t)return!1;let e=s.state.selection.main,i=Ki(t.diagnostics,null,e.to+1);return!i&&(i=Ki(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}),!0)},G2=s=>{let{state:t}=s,e=t.field(jt,!1);if(!e)return!1;let i=t.selection.main,n,r,o,a;return e.diagnostics.between(0,t.doc.length,(l,h)=>{h<i.to&&(n==null||n<l)&&(n=l,r=h),(o==null||l>o)&&(o=l,a=h)}),o==null||n==null&&o==i.from?!1:(s.dispatch({selection:{anchor:n??o,head:r??a},scrollIntoView:!0}),!0)},H2=[{key:"Mod-Shift-m",run:Uk,preventDefault:!0},{key:"F8",run:Gk}],Hk=rt.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:t}=s.state.facet(ai);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(ai);e.length&&K2(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(Wk(this.view.state,i.reduce((n,r)=>n.concat(r))))},i=>{kt(this.view.state,i)})}}update(s){let t=s.state.facet(ai);(s.docChanged||t!=s.startState.facet(ai)||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)}});ai=I.define({combine(s){return{sources:s.map(t=>t.source).filter(t=>t!=null),...Gt(s.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Kk,tooltipFilter:Kk,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})}}});jg=class extends Mt{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return wt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Ou=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=t1(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},$l=class s{constructor(t){this.view=t,this.items=[];let e=n=>{if(!(n.ctrlKey||n.altKey||n.metaKey)){if(n.keyCode==27)Vg(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=Ki(this.view.state.field(jt).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=wt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=wt("div",{class:"cm-panel-lint"},this.list,wt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Vg(this.view)},"\xD7")),this.update()}get selectedIndex(){let t=this.view.state.field(jt).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(jt),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 Ou(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 Ou(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(jt),i=Ki(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Yk.of(i)})}static open(t){return new s(t)}};tR=M.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:yu("#d11")},".cm-lintRange-warning":{backgroundImage:yu("orange")},".cm-lintRange-info":{backgroundImage:yu("#999")},".cm-lintRange-hint":{backgroundImage:yu("#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"}}});vu=class extends Kt{constructor(t){super(),this.diagnostics=t,this.severity=e1(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(xu).tooltipFilter;return n&&(i=n(i,t.state)),i.length&&(e.onmouseover=()=>sR(t,e,i)),e}};rR=Ja({class:"cm-gutter-lint",markers:s=>s.state.field(_g),widgetMarker:(s,t,e)=>{let i=[];return s.state.field(_g).between(e.from,e.to,(n,r,o)=>{n>e.from&&n<e.to&&i.push(...o.diagnostics)}),i.length?new vu(i):null}}),_g=ut.define({create(){return U.empty},update(s,t){s=s.map(t.changes);let e=t.state.facet(xu).markerFilter;for(let i of t.effects)if(i.is(Al)){let n=i.value;e&&(n=e(n||[],t.state)),s=nR(t.state.doc,n.slice(0))}return s}}),Wg=j.define(),i1=ut.define({create(){return null},update(s,t){return s&&t.docChanged&&(s=jk(t,s)?null:{...s,pos:t.changes.mapPos(s.pos)}),t.effects.reduce((e,i)=>i.is(Wg)?i.value:e,s)},provide:s=>Ps.from(s)}),oR=M.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"/>')}}),s1=[jt,M.decorations.compute([jt],s=>{let{selected:t,panel:e}=s.field(jt);return!t||!e||t.from==t.to?z.none:z.set([F2.range(t.from,t.to)])}),fp(U2,{hideOn:jk}),tR],xu=I.define({combine(s){return Gt(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}})});var Fg={};Yt(Fg,{Compartment:()=>Bi,EditorSelection:()=>C,EditorState:()=>it,EditorView:()=>M,HighlightStyle:()=>ki,LOAD_TIMEOUT_MS:()=>Yg,LanguageSupport:()=>mt,StateEffect:()=>j,adiaBaseTheme:()=>lR,adiaHighlightStyle:()=>hR,defaultHighlightStyle:()=>xc,defaultKeymap:()=>pu,drawSelection:()=>ac,highlightActiveLine:()=>lc,highlightActiveLineGutter:()=>dc,history:()=>du,historyKeymap:()=>fu,importWithTimeout:()=>uR,indentWithTab:()=>mu,jsonLinter:()=>dR,keymap:()=>si,languages:()=>cR,lineNumbers:()=>uc,lintGutter:()=>Su,linter:()=>Cl,placeholder:()=>hc,syntaxHighlighting:()=>vc});function uR(s,t){return Promise.race([s(),new Promise((e,i)=>setTimeout(()=>i(new Error(`code-editor: ${t} load timed out after ${Yg}ms`)),Yg))])}function fR(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 lR,hR,cR,Yg,dR,Ug=V(()=>{"use strict";ti();yi();Vk();oi();n1();Ke();lR=M.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{padding:"0",caretColor:"inherit"},".cm-focused":{outline:"none"}}),hR=ki.define([{tag:[b.comment,b.lineComment,b.blockComment,b.docComment],class:"tok-comment"},{tag:[b.keyword,b.controlKeyword,b.modifier,b.operatorKeyword],class:"tok-keyword"},{tag:[b.string,b.character,b.regexp,b.escape,b.special(b.string)],class:"tok-string"},{tag:[b.number,b.integer,b.float],class:"tok-number"},{tag:[b.bool,b.null,b.atom],class:"tok-boolean"},{tag:[b.operator,b.logicOperator,b.arithmeticOperator,b.compareOperator,b.updateOperator,b.definitionOperator],class:"tok-operator"},{tag:[b.punctuation,b.bracket,b.paren,b.brace,b.squareBracket,b.angleBracket,b.separator],class:"tok-punctuation"},{tag:[b.function(b.variableName),b.function(b.propertyName),b.macroName],class:"tok-function"},{tag:[b.variableName,b.local(b.variableName),b.self],class:"tok-variable"},{tag:[b.typeName,b.className,b.namespace],class:"tok-type"},{tag:[b.propertyName,b.labelName,b.definition(b.variableName)],class:"tok-property"},{tag:[b.tagName,b.heading,b.contentSeparator],class:"tok-tag"},{tag:[b.attributeName,b.attributeValue],class:"tok-attribute"},{tag:[b.url,b.link],class:"tok-url"},{tag:[b.invalid,b.deleted],class:"tok-invalid"}]),cR={json:()=>Promise.resolve().then(()=>(q0(),Z0)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(Pm(),OS)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(Sm(),rS)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Yp(),mx)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(cw(),hw)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Aw(),kw)).then(s=>({extension:s.yaml()}))},Yg=1e4;dR=Cl(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}=fR(i,t);return[{from:n,to:r,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function $u(s){return Rt.get(s)||null}function S1(s,t){Rt.set(s,t)}var Rt,rO=V(()=>{"use strict";Rt=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"],["ProgressRow","progress-row-ui"],["DateRangePicker","date-range-picker-ui"],["DatetimePicker","datetime-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"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorPicker","color-picker-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"],["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"],["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"],["ToggleGroup","toggle-group-ui"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-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-picker-ui","color-picker-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"],["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"]])});function w1(s,t){if(!t||t==="/")return s;let e=t.replace(/^\//,"").split("/"),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function VR(s,t,e){if(!t||t==="/")return;let i=t.replace(/^\//,"").split("/"),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}var Cu,Go,oO=V(()=>{"use strict";Cu={provider:0,controller:1,source:2,action:3,lifecycle:4},Go=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?w1(this.#e,t):this.#e,setModel:(t,e)=>this.#a(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.#o(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)=>(Cu[i.kind]??9)-(Cu[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)=>(Cu[i[1].dockable.kind]??9)-(Cu[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}#a(t,e){VR(this.#e,t,e);for(let[i,n]of this.#s)if(t===i||t.startsWith(i+"/"))for(let r of n)r(w1(this.#e,i))}#o(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 me,Ys=V(()=>{"use strict";me=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 Ho,aO=V(()=>{"use strict";Ys();Ho=class extends me{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 Ko,lO=V(()=>{"use strict";Ys();Ko=class extends me{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 Eu,Jo,hO=V(()=>{"use strict";Ys();Eu={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"},Jo=class extends me{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=Eu[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 ta,cO=V(()=>{"use strict";Ys();ta=class extends me{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 ea,uO=V(()=>{"use strict";Ys();ea=class extends me{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 k1,ge,Fs=V(()=>{"use strict";k1=new WeakSet,ge=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!k1.has(e)&&e!==s&&(k1.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 A1={};Yt(A1,{FormController:()=>dO});var dO,$1=V(()=>{"use strict";Fs();dO=class extends ge{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 C1={};Yt(C1,{DataStreamController:()=>fO});var fO,E1=V(()=>{"use strict";Fs();fO=class extends ge{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;#a=1;#o=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:n=[]}={}){super(),this.#e=t,this.#r=e,this.#a=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.#a>1&&this.#l%this.#a!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u())}#h(t){if(this.#a>1){let e=[];for(let i of t)this.#l++,this.#l%this.#a===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.#o===null&&(this.#o=setTimeout(()=>{this.#o=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.#o!==null&&(clearTimeout(this.#o),this.#o=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 P1={};Yt(P1,{SelectionController:()=>pO});var pO,Q1=V(()=>{"use strict";Fs();pO=class extends ge{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 T1={};Yt(T1,{ToggleController:()=>mO});var mO,L1=V(()=>{"use strict";Fs();mO=class extends ge{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 M1={};Yt(M1,{AccordionController:()=>gO});var gO,R1=V(()=>{"use strict";Fs();gO=class extends ge{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 I1={};Yt(I1,{StateMachineController:()=>OO});var OO,D1=V(()=>{"use strict";Fs();OO=class extends ge{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 X1(s,t){Mi.controllers.set(s,t)}function Z1(s,t){Mi.handlers.set(s,t)}function q1(s,t){Mi.resolvers.set(s,t)}async function Pu(s){let t=Mi.controllers.get(s);return t?t():null}function Qu(s){return Mi.handlers.get(s)||null}async function Ql(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=Mi.resolvers.get(n);if(!r)throw new Error(`No resolver for scheme "${n}"`);return r(e,t)}async function jR(s){let{action:t,params:e}=s,i=bO(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=Mi.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 _R(s){let{action:t}=s,e=bO(t.value,s);s.updateModel(t.path,e)}async function WR(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 YR(){history.back()}async function FR(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 UR(s){let{action:t,source:e}=s,i=bO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function GR(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function HR(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 bO(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 KR(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}function KR(s,t){if(!t||!s)return;let e=t.split("/").filter(Boolean),i=s;for(let n of e){if(i==null||typeof i!="object")return;i=i[n]}return i}async function JR(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 tI(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 eI(s,t){return{_source:s,_mock:!0}}var Mi,yO=V(()=>{"use strict";Mi={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>($1(),A1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(E1(),C1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(Q1(),P1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(L1(),T1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(R1(),M1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(D1(),I1))).StateMachineController]]),handlers:new Map([["submit-resource",jR],["update-model",_R],["navigate",WR],["navigate-back",YR],["controller-command",FR],["emit-event",UR],["refresh-source",GR],["notify",HR]]),resolvers:new Map([["resource",JR],["api",tI],["mock",eI]])}});function iI(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:Ql};return s(n)}}function sI(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=Qu(t);if(!e)return null;let i=iI(e);return s.set(t,i),i}}function nI(){return async s=>Pu(s)}function rI(){return async(s,t)=>Ql(s,{})}function Tu(s){let t=[],e=sI(),i=nI(),n=rI();if(s.data?.sources)for(let o of s.data.sources)t.push(new Ko(o,n));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new Ho(o,i));if(s.actions)for(let o of s.actions)t.push(new Jo(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new ta(a))}s.lifecycle&&t.push(new ea(s.lifecycle,e));let r=s.state?.model||null;return{dockables:t,initialModel:r}}var vO=V(()=>{"use strict";aO();lO();hO();cO();uO();yO()});var N1={};Yt(N1,{WiringEngine:()=>Tl});var Tl,xO=V(()=>{"use strict";oO();vO();Tl=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}=Tu(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))}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 Go(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}}});var ts,B1=V(()=>{"use strict";rO();ts=class s{#t;#e;#i=new Map;#s=new Map;#n=new Map;#r=[];#a=null;#o=!1;constructor(t,e=Rt,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#o=i}process(t){t&&(this.#o?(this.#r.push(t),this.#a===null&&(this.#a=requestAnimationFrame(()=>this.#l()))):this.#c(t))}#l(){this.#a=null;let t=this.#r.splice(0);for(let e of t)this.#c(e)}#c(t){switch(t.type||t.messageType){case"createSurface":this.#d(t);break;case"updateComponents":this.#f(t);break;case"updateDataModel":this.#M(t);break;case"wireComponents":this.#u(t);break;case"deleteSurface":this.#Q(t);break;case"updateStyles":this.#R(t);break;case"removeStyles":this.#C(t);break;case"meta":break;default:console.warn("A2UI: unknown message type",t.type)}}#h=null;async#u(t){if(!this.#h){let{WiringEngine:e}=await Promise.resolve().then(()=>(xO(),N1));this.#h=new e({updateDataModel:(i,n,r)=>{this.#M({surfaceId:i,path:n,value:r})},getElement:(i,n)=>this.#i.get(i)?.elements.get(n)||null})}await this.#h.process(t)}async processStream(t){for await(let e of t)this.process(e)}#d({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t))return;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})}#f({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},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.#S(l.variant,l):$u(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-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),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),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.#w(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#y(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#p=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#m=new Set(["Header","Section","Footer"]);static#O=new Set(["header","body","footer"]);#g=new Set;#y(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.#m:s.#p,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.#O.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#g.has(u)||(this.#g.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=new Set(["data","columns","options","itemRenderer","textContent"]);static#k=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui"]);static#v={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};static#x=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"]);#S(t,e){return!e?.slot&&s.#v[t]?s.#v[t]:"text-ui"}#w(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#v[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);if(r[o]=h,!(n&&Object.is(n[o],h))){if(o==="style"&&typeof h=="string"){t.style.cssText=h;continue}if(s.#b.has(o)&&h!=null){if(o==="textContent"&&!s.#k.has(t.localName)){t.setAttribute("text",String(h));continue}let c=h;if(typeof c=="string"&&(c.startsWith("[")||c.startsWith("{")))try{c=JSON.parse(c)}catch{}t[o]=c;continue}typeof h=="boolean"?h?t.setAttribute(o,""):t.removeAttribute(o):h!=null?t.setAttribute(this.#A(o),String(h)):l&&t.removeAttribute(this.#A(o))}}if(n)for(let o of Object.keys(n))!(o in r)&&!i.has(o)&&t.removeAttribute(this.#A(o));this.#n.set(e.id,r)}#A(t){return s.#x.has(t.toLowerCase())?t.toLowerCase():t.replace(/([A-Z])/g,"-$1").toLowerCase()}#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?this.#$(i.dataModel,t.path):t.path}return t}#$(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,n)=>i?.[n],t)}#M({surfaceId:t,path:e,value:i}){let n=this.#i.get(t);if(n){if(!e||e==="/")n.dataModel=i??{};else{let r=e.split("/").filter(Boolean),o=n.dataModel;for(let a=0;a<r.length-1;a++)o[r[a]]==null&&(o[r[a]]={}),o=o[r[a]];o[r[r.length-1]]=i}for(let[r,o]of n.bindings){let a=n.elements.get(r);a&&this.#w(a,o)}}}#Q({surfaceId:t}){let e=this.#i.get(t);if(e){this.#h?.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)}}static#E=new Set(["root","html","body"]);#R({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#q(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#q(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.#q(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let r=this.#L(i,t);if(r.rejected){this.#q(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.#q(n.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:r.sheet.cssRules.length,validationWarnings:r.warnings})}#C({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.#q(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#L(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.#T(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.#Z(n,e),o=this.#I(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}}#T(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.#D(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.#E.has(a))return`forbidden-${a}-selector`}}return null}#D(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}#Z(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}#I(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 lR,hR,cR,Yg,dR,Ug=V(()=>{"use strict";ti();yi();Vk();oi();n1();Ke();lR=M.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{padding:"0",caretColor:"inherit"},".cm-focused":{outline:"none"}}),hR=ki.define([{tag:[b.comment,b.lineComment,b.blockComment,b.docComment],class:"tok-comment"},{tag:[b.keyword,b.controlKeyword,b.modifier,b.operatorKeyword],class:"tok-keyword"},{tag:[b.string,b.character,b.regexp,b.escape,b.special(b.string)],class:"tok-string"},{tag:[b.number,b.integer,b.float],class:"tok-number"},{tag:[b.bool,b.null,b.atom],class:"tok-boolean"},{tag:[b.operator,b.logicOperator,b.arithmeticOperator,b.compareOperator,b.updateOperator,b.definitionOperator],class:"tok-operator"},{tag:[b.punctuation,b.bracket,b.paren,b.brace,b.squareBracket,b.angleBracket,b.separator],class:"tok-punctuation"},{tag:[b.function(b.variableName),b.function(b.propertyName),b.macroName],class:"tok-function"},{tag:[b.variableName,b.local(b.variableName),b.self],class:"tok-variable"},{tag:[b.typeName,b.className,b.namespace],class:"tok-type"},{tag:[b.propertyName,b.labelName,b.definition(b.variableName)],class:"tok-property"},{tag:[b.tagName,b.heading,b.contentSeparator],class:"tok-tag"},{tag:[b.attributeName,b.attributeValue],class:"tok-attribute"},{tag:[b.url,b.link],class:"tok-url"},{tag:[b.invalid,b.deleted],class:"tok-invalid"}]),cR={json:()=>Promise.resolve().then(()=>(q0(),Z0)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(Pm(),OS)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(Sm(),rS)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Yp(),mx)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(cw(),hw)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Aw(),kw)).then(s=>({extension:s.yaml()}))},Yg=1e4;dR=Cl(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}=fR(i,t);return[{from:n,to:r,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function $u(s){return Rt.get(s)||null}function S1(s,t){Rt.set(s,t)}var Rt,rO=V(()=>{"use strict";Rt=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"],["ProgressRow","progress-row-ui"],["DateRangePicker","date-range-picker-ui"],["DatetimePicker","datetime-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"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorPicker","color-picker-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"],["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"],["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"],["ToggleGroup","toggle-group-ui"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-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-picker-ui","color-picker-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"],["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"]])});function w1(s,t){if(!t||t==="/")return s;let e=t.replace(/^\//,"").split("/"),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function VR(s,t,e){if(!t||t==="/")return;let i=t.replace(/^\//,"").split("/"),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}var Cu,Go,oO=V(()=>{"use strict";Cu={provider:0,controller:1,source:2,action:3,lifecycle:4},Go=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?w1(this.#e,t):this.#e,setModel:(t,e)=>this.#a(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.#o(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)=>(Cu[i.kind]??9)-(Cu[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)=>(Cu[i[1].dockable.kind]??9)-(Cu[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}#a(t,e){VR(this.#e,t,e);for(let[i,n]of this.#s)if(t===i||t.startsWith(i+"/"))for(let r of n)r(w1(this.#e,i))}#o(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 me,Ys=V(()=>{"use strict";me=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 Ho,aO=V(()=>{"use strict";Ys();Ho=class extends me{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 Ko,lO=V(()=>{"use strict";Ys();Ko=class extends me{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 Eu,Jo,hO=V(()=>{"use strict";Ys();Eu={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"},Jo=class extends me{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=Eu[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 ta,cO=V(()=>{"use strict";Ys();ta=class extends me{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 ea,uO=V(()=>{"use strict";Ys();ea=class extends me{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 k1,ge,Fs=V(()=>{"use strict";k1=new WeakSet,ge=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!k1.has(e)&&e!==s&&(k1.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 A1={};Yt(A1,{FormController:()=>dO});var dO,$1=V(()=>{"use strict";Fs();dO=class extends ge{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 C1={};Yt(C1,{DataStreamController:()=>fO});var fO,E1=V(()=>{"use strict";Fs();fO=class extends ge{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;#a=1;#o=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:n=[]}={}){super(),this.#e=t,this.#r=e,this.#a=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.#a>1&&this.#l%this.#a!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u())}#h(t){if(this.#a>1){let e=[];for(let i of t)this.#l++,this.#l%this.#a===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.#o===null&&(this.#o=setTimeout(()=>{this.#o=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.#o!==null&&(clearTimeout(this.#o),this.#o=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 P1={};Yt(P1,{SelectionController:()=>pO});var pO,Q1=V(()=>{"use strict";Fs();pO=class extends ge{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 T1={};Yt(T1,{ToggleController:()=>mO});var mO,L1=V(()=>{"use strict";Fs();mO=class extends ge{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 M1={};Yt(M1,{AccordionController:()=>gO});var gO,R1=V(()=>{"use strict";Fs();gO=class extends ge{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 I1={};Yt(I1,{StateMachineController:()=>OO});var OO,D1=V(()=>{"use strict";Fs();OO=class extends ge{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 X1(s,t){Mi.controllers.set(s,t)}function Z1(s,t){Mi.handlers.set(s,t)}function q1(s,t){Mi.resolvers.set(s,t)}async function Pu(s){let t=Mi.controllers.get(s);return t?t():null}function Qu(s){return Mi.handlers.get(s)||null}async function Ql(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=Mi.resolvers.get(n);if(!r)throw new Error(`No resolver for scheme "${n}"`);return r(e,t)}async function jR(s){let{action:t,params:e}=s,i=bO(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=Mi.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 _R(s){let{action:t}=s,e=bO(t.value,s);s.updateModel(t.path,e)}async function WR(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 YR(){history.back()}async function FR(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 UR(s){let{action:t,source:e}=s,i=bO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function GR(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function HR(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 bO(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 KR(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}function KR(s,t){if(!t||!s)return;let e=t.split("/").filter(Boolean),i=s;for(let n of e){if(i==null||typeof i!="object")return;i=i[n]}return i}async function JR(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 tI(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 eI(s,t){return{_source:s,_mock:!0}}var Mi,yO=V(()=>{"use strict";Mi={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>($1(),A1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(E1(),C1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(Q1(),P1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(L1(),T1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(R1(),M1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(D1(),I1))).StateMachineController]]),handlers:new Map([["submit-resource",jR],["update-model",_R],["navigate",WR],["navigate-back",YR],["controller-command",FR],["emit-event",UR],["refresh-source",GR],["notify",HR]]),resolvers:new Map([["resource",JR],["api",tI],["mock",eI]])}});function iI(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:Ql};return s(n)}}function sI(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=Qu(t);if(!e)return null;let i=iI(e);return s.set(t,i),i}}function nI(){return async s=>Pu(s)}function rI(){return async(s,t)=>Ql(s,{})}function Tu(s){let t=[],e=sI(),i=nI(),n=rI();if(s.data?.sources)for(let o of s.data.sources)t.push(new Ko(o,n));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new Ho(o,i));if(s.actions)for(let o of s.actions)t.push(new Jo(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new ta(a))}s.lifecycle&&t.push(new ea(s.lifecycle,e));let r=s.state?.model||null;return{dockables:t,initialModel:r}}var vO=V(()=>{"use strict";aO();lO();hO();cO();uO();yO()});var N1={};Yt(N1,{WiringEngine:()=>Tl});var Tl,xO=V(()=>{"use strict";oO();vO();Tl=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}=Tu(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))}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 Go(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}}});var ts,B1=V(()=>{"use strict";rO();ts=class s{#t;#e;#i=new Map;#s=new Map;#n=new Map;#r=[];#a=null;#o=!1;constructor(t,e=Rt,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#o=i}process(t){t&&(this.#o?(this.#r.push(t),this.#a===null&&(this.#a=requestAnimationFrame(()=>this.#l()))):this.#c(t))}#l(){this.#a=null;let t=this.#r.splice(0);for(let e of t)this.#c(e)}#c(t){switch(t.type||t.messageType){case"createSurface":this.#d(t);break;case"updateComponents":this.#f(t);break;case"updateDataModel":this.#M(t);break;case"wireComponents":this.#u(t);break;case"deleteSurface":this.#C(t);break;case"updateStyles":this.#R(t);break;case"removeStyles":this.#P(t);break;case"meta":break;default:console.warn("A2UI: unknown message type",t.type)}}#h=null;async#u(t){if(!this.#h){let{WiringEngine:e}=await Promise.resolve().then(()=>(xO(),N1));this.#h=new e({updateDataModel:(i,n,r)=>{this.#M({surfaceId:i,path:n,value:r})},getElement:(i,n)=>this.#i.get(i)?.elements.get(n)||null})}await this.#h.process(t)}async processStream(t){for await(let e of t)this.process(e)}#d({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t))return;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})}#f({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},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.#S(l.variant,l):$u(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-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),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),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.#k(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#y(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#p=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#m=new Set(["Header","Section","Footer"]);static#g=new Set(["header","body","footer"]);#O=new Set;#y(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.#m:s.#p,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.#g.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#O.has(u)||(this.#O.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=new Set(["data","columns","options","itemRenderer","textContent"]);static#w=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui"]);static#v={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};static#x=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"]);#S(t,e){return!e?.slot&&s.#v[t]?s.#v[t]:"text-ui"}#k(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#v[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.#$(a,e._surfaceId);if(r[o]=h,!(n&&Object.is(n[o],h))){if(o==="style"&&typeof h=="string"){t.style.cssText=h;continue}if(s.#b.has(o)&&h!=null){if(o==="textContent"&&!s.#w.has(t.localName)){t.setAttribute("text",String(h));continue}let c=h;if(typeof c=="string"&&(c.startsWith("[")||c.startsWith("{")))try{c=JSON.parse(c)}catch{}t[o]=c;continue}typeof h=="boolean"?h?t.setAttribute(o,""):t.removeAttribute(o):h!=null?t.setAttribute(this.#A(o),String(h)):l&&t.removeAttribute(this.#A(o))}}if(n)for(let o of Object.keys(n))!(o in r)&&!i.has(o)&&t.removeAttribute(this.#A(o));this.#n.set(e.id,r)}#A(t){return s.#x.has(t.toLowerCase())?t.toLowerCase():t.replace(/([A-Z])/g,"-$1").toLowerCase()}#$(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?this.#T(i.dataModel,t.path):t.path}return t}#T(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,n)=>i?.[n],t)}#M({surfaceId:t,path:e,value:i}){let n=this.#i.get(t);if(n){if(!e||e==="/")n.dataModel=i??{};else{let r=e.split("/").filter(Boolean),o=n.dataModel;for(let a=0;a<r.length-1;a++)o[r[a]]==null&&(o[r[a]]={}),o=o[r[a]];o[r[r.length-1]]=i}for(let[r,o]of n.bindings){let a=n.elements.get(r);a&&this.#k(a,o)}}}#C({surfaceId:t}){let e=this.#i.get(t);if(e){this.#h?.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)}}static#E=new Set(["root","html","body"]);#R({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#q(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#q(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.#q(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let r=this.#L(i,t);if(r.rejected){this.#q(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.#q(n.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:r.sheet.cssRules.length,validationWarnings:r.warnings})}#P({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.#q(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#L(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.#Q(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.#Z(n,e),o=this.#D(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}}#Q(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.#I(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.#E.has(a))return`forbidden-${a}-selector`}}return null}#I(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}#Z(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}#D(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
|
}`}#q(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.#a!==null&&(cancelAnimationFrame(this.#a),this.#a=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.#o=!!t}get batching(){return this.#o}}});function Lu(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 Mu(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 j1(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function Ru(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?oI(s,t):V1(s,t)}function z1(s,t){if(s.result?.content){for(let e of s.result.content)if(e.type==="resource"&&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 oI(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);z1(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 V1(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=[],o=null,a=!1,l=g=>{if(o){let y=o;o=null,y({value:g,done:!1})}else r.push(g)},h=()=>{if(a=!0,o){let g=o;o=null,g({value:void 0,done:!0})}},c={jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:"a2ui-runtime",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(g){console.warn("A2UI MCP HTTP: initialize failed",g);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 y=u.body.getReader(),v=new TextDecoder,S="";for(;;){let{done:w,value:$}=await y.read();if(w||(S+=v.decode($,{stream:!0}),S.includes(`
|
|
@@ -62,7 +62,7 @@ ${i.join(`
|
|
|
62
62
|
aria-label="Undo" \u2190 explicit accessible name
|
|
63
63
|
title="Undo" \u2190 auto-mirrored to aria-label + tooltip
|
|
64
64
|
aria-labelledby="..." \u2190 reference an existing label element
|
|
65
|
-
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)}};x("button-ui",tn);Q();var en=class extends k{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)}};x("link-ui",en);Q();var Z=class s extends k{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()};#a=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#n),this.addEventListener("input",this.#r),this.addEventListener("blur",this.#a,!0),this.#o()}#o(){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.#a,!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 KO=s=>Zl(s)?`<icon-ui name="${s}"></icon-ui>`:s,sn=class s extends Z{static labelDeprecated=!1;static properties={...Z.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;#a=null;#o=".";#l="";#c=null;static#h=0;static#u=400;static#d=60;get#f(){return this.type==="password"}get#p(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#
|
|
65
|
+
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)}};x("button-ui",tn);Q();var en=class extends k{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)}};x("link-ui",en);Q();var Z=class s extends k{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()};#a=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#n),this.addEventListener("input",this.#r),this.addEventListener("blur",this.#a,!0),this.#o()}#o(){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.#a,!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 KO=s=>Zl(s)?`<icon-ui name="${s}"></icon-ui>`:s,sn=class s extends Z{static labelDeprecated=!1;static properties={...Z.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;#a=null;#o=".";#l="";#c=null;static#h=0;static#u=400;static#d=60;get#f(){return this.type==="password"}get#p(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#k(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.#p?"spinbutton":"textbox");let t=Array.from(this.querySelectorAll(':scope > [slot="leading"]')),e=Array.from(this.querySelectorAll(':scope > [slot="trailing"]'));if(!this.querySelector('[slot="text"]')){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#m(i),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.#f&&this.value&&(this.#t.textContent=this.#p?this.#T(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#E),this.#t.addEventListener("keydown",this.#Z),this.#t.addEventListener("blur",this.#q),this.#t.addEventListener("focus",this.#D),this.#t.addEventListener("paste",this.#j),this.#p&&this.#t.addEventListener("beforeinput",this.#R)),this.#i?.addEventListener("pointerdown",this.#B),this.#s?.addEventListener("pointerdown",this.#G),(this.prefix||this.suffix)&&IO.then(()=>this.#O())}#m(t){let e=this.prefix?`<span slot="prefix">${KO(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",n=this.suffix?`<span slot="suffix">${KO(this.suffix)}</span>`:"",r=t?`aria-labelledby="${t}"`:"";if(this.#f)return`
|
|
66
66
|
<div slot="field">
|
|
67
67
|
${e}${i}
|
|
68
68
|
<input slot="text" type="password" tabindex="0"
|
|
@@ -86,12 +86,12 @@ ${i.join(`
|
|
|
86
86
|
<div slot="field"${this.#p?" data-number":""}>
|
|
87
87
|
${e}${i}${o}${n}${a}
|
|
88
88
|
</div>
|
|
89
|
-
`}#O(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)}}}#g(){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")&&Zl(e)){i.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",e),i.appendChild(n)}}}#y(){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&&Zl(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;let t=this.value??"";if(this.#f)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 e=this.#p&&document.activeElement!==this.#t?this.#$(t):String(t);this.#t.textContent!==e&&(this.#t.textContent=e,this.#t.toggleAttribute("data-empty",!e))}if(this.#e&&(this.#e.textContent=this.label||""),this.#y(),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#p){let e=this.valueAsNumber;Number.isFinite(e)?(this.setAttribute("aria-valuenow",String(e)),this.setAttribute("aria-valuetext",`${this.#A(e)}${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 i=this.disabled||this.readonly||this.max!=null&&Number.isFinite(e)&&e>=this.max,n=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!n)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#p&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#p)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.#w(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)}#k(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#v(){return this.locale?this.#c===this.locale?this.#o:(this.#S(),this.#o):"."}#x(){return this.locale?this.#c===this.locale?this.#l:(this.#S(),this.#l):""}#S(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#o=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#o=".",this.#l=""}this.#c=this.locale}#w(t){let e=this.#v(),i=this.#x(),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.#k();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))}#P(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#A(t);let e=this.#k();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#A(t)}}#$(t){let e=String(t??"");if(!e)return"";let i=Number(this.#w(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#A(i):this.#P(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.#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}})))}#E=()=>{let t;if(this.#f)t=this.#t.value||"";else if(this.#p){let e=this.#t.textContent||"";t=this.#L(e),t!==e&&(this.#t.textContent=t,this.#D())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#R=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.#T(h.startContainer,h.startOffset),a=this.#T(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=n.slice(0,o)+i+n.slice(a);this.#C(l)||t.preventDefault()};#C(t){let e=this.#w(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)}#L(t){let e=this.#v(),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}#T(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}#D(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#Z=t=>{if(this.#p){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.#N(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#N(this.max));return;case"Escape":t.preventDefault(),this.value=this.#n,this.#t.textContent=this.#$(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#V(),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})))};#I=()=>{if(this.#n=this.value??"",this.#p&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#w(t));if(!Number.isFinite(e))return;let i=this.#A(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#q=()=>{this.#p&&this.#V(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#V(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#w(t));if(!Number.isFinite(e))return;let i=this.#M(e),n=this.#A(i),r=this.#P(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))}#N(t){let e=this.#M(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}})))}#j=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#L(e):e;document.execCommand("insertText",!1,i)};#B=t=>this.#F(t,1);#G=t=>this.#F(t,-1);#F(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#Q(e),this.#X(),document.addEventListener("pointerup",this.#_,{once:!0}),document.addEventListener("pointercancel",this.#_,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#r=window.setInterval(()=>{let i=this.valueAsNumber;this.#Q(e),this.valueAsNumber===i&&this.#X()},s.#d)},s.#u))}#_=()=>this.#X();#X(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#r!=null&&(window.clearInterval(this.#r),this.#r=null),document.removeEventListener("pointerup",this.#_),document.removeEventListener("pointercancel",this.#_)}focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#f?this.#t.value="":(this.#t.textContent="",this.#t.setAttribute("data-empty",""))),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#E),this.#t.removeEventListener("keydown",this.#Z),this.#t.removeEventListener("blur",this.#q),this.#t.removeEventListener("focus",this.#I),this.#t.removeEventListener("paste",this.#j),this.#t.removeEventListener("beforeinput",this.#R)),this.#i?.removeEventListener("pointerdown",this.#B),this.#s?.removeEventListener("pointerdown",this.#G),this.#X(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};x("input-ui",sn);var nn=class extends Z{static labelDeprecated=!1;static properties={...Z.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;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
|
|
89
|
+
`}#g(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)}}}#O(){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")&&Zl(e)){i.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",e),i.appendChild(n)}}}#y(){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&&Zl(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;let t=this.value??"";if(this.#f)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 e=this.#p&&document.activeElement!==this.#t?this.#T(t):String(t);this.#t.textContent!==e&&(this.#t.textContent=e,this.#t.toggleAttribute("data-empty",!e))}if(this.#e&&(this.#e.textContent=this.label||""),this.#y(),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#p){let e=this.valueAsNumber;Number.isFinite(e)?(this.setAttribute("aria-valuenow",String(e)),this.setAttribute("aria-valuetext",`${this.#A(e)}${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 i=this.disabled||this.readonly||this.max!=null&&Number.isFinite(e)&&e>=this.max,n=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!n)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#p&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#p)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.#k(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)}#w(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#v(){return this.locale?this.#c===this.locale?this.#o:(this.#S(),this.#o):"."}#x(){return this.locale?this.#c===this.locale?this.#l:(this.#S(),this.#l):""}#S(){try{let t=new Intl.NumberFormat(this.locale).formatToParts(123456789e-2);this.#o=t.find(e=>e.type==="decimal")?.value||".",this.#l=t.find(e=>e.type==="group")?.value||""}catch{this.#o=".",this.#l=""}this.#c=this.locale}#k(t){let e=this.#v(),i=this.#x(),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.#w();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){if(!Number.isFinite(t))return"";if(!this.locale)return this.#A(t);let e=this.#w();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#A(t)}}#T(t){let e=String(t??"");if(!e)return"";let i=Number(this.#k(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#A(i):this.#$(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))}#C(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.#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}})))}#E=()=>{let t;if(this.#f)t=this.#t.value||"";else if(this.#p){let e=this.#t.textContent||"";t=this.#L(e),t!==e&&(this.#t.textContent=t,this.#I())}else t=this.#t.textContent||"";this.value=t,this.#f||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#R=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.#Q(h.startContainer,h.startOffset),a=this.#Q(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=n.slice(0,o)+i+n.slice(a);this.#P(l)||t.preventDefault()};#P(t){let e=this.#k(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)}#L(t){let e=this.#v(),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}#Q(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}#I(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#Z=t=>{if(this.#p){switch(t.key){case"ArrowUp":t.preventDefault(),this.#C(1);return;case"ArrowDown":t.preventDefault(),this.#C(-1);return;case"PageUp":t.preventDefault(),this.#C(10);return;case"PageDown":t.preventDefault(),this.#C(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#N(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#N(this.max));return;case"Escape":t.preventDefault(),this.value=this.#n,this.#t.textContent=this.#T(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#V(),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})))};#D=()=>{if(this.#n=this.value??"",this.#p&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#A(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#q=()=>{this.#p&&this.#V(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#V(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#k(t));if(!Number.isFinite(e))return;let i=this.#M(e),n=this.#A(i),r=this.#$(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))}#N(t){let e=this.#M(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}})))}#j=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#p?this.#L(e):e;document.execCommand("insertText",!1,i)};#B=t=>this.#F(t,1);#G=t=>this.#F(t,-1);#F(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#C(e),this.#X(),document.addEventListener("pointerup",this.#_,{once:!0}),document.addEventListener("pointercancel",this.#_,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#r=window.setInterval(()=>{let i=this.valueAsNumber;this.#C(e),this.valueAsNumber===i&&this.#X()},s.#d)},s.#u))}#_=()=>this.#X();#X(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#r!=null&&(window.clearInterval(this.#r),this.#r=null),document.removeEventListener("pointerup",this.#_),document.removeEventListener("pointercancel",this.#_)}focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#f?this.#t.value="":(this.#t.textContent="",this.#t.setAttribute("data-empty",""))),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#E),this.#t.removeEventListener("keydown",this.#Z),this.#t.removeEventListener("blur",this.#q),this.#t.removeEventListener("focus",this.#D),this.#t.removeEventListener("paste",this.#j),this.#t.removeEventListener("beforeinput",this.#R)),this.#i?.removeEventListener("pointerdown",this.#B),this.#s?.removeEventListener("pointerdown",this.#G),this.#X(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};x("input-ui",sn);var nn=class extends Z{static labelDeprecated=!1;static properties={...Z.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;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
|
|
90
90
|
${this.label?`<label slot="label" label="${this.label}"></label>`:""}
|
|
91
91
|
<div slot="text" contenteditable="plaintext-only" tabindex="0"
|
|
92
92
|
${this.value?"":'data-empty=""'}
|
|
93
93
|
data-placeholder="${this.placeholder}"></div>
|
|
94
|
-
`),this.#t=this.querySelector('[slot="text"]'),this.value&&(this.#t.textContent=this.value),this.#t&&(this.#t.addEventListener("input",this.#e),this.#t.addEventListener("keydown",this.#i),this.#t.addEventListener("blur",this.#s),this.#t.addEventListener("paste",this.#n))}render(){if(!this.#t)return;this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let t=this.value||"";this.#t.textContent!==t&&(this.#t.textContent=t,this.#t.toggleAttribute("data-empty",!t));let e=this.querySelector('[slot="label"]');e&&this.label&&e.setAttribute("label",this.label),this.setAttribute("aria-label",this.label||this.placeholder||"")}#e=()=>{let t=this.#t.textContent||"";this.value=t,this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#i=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.flushPendingInput(),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#s=()=>{this.flushPendingInput(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#n=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,e)};focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#t.textContent="",this.#t.setAttribute("data-empty","")),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#e),this.#t.removeEventListener("keydown",this.#i),this.#t.removeEventListener("blur",this.#s),this.#t.removeEventListener("paste",this.#n)),this.#t=null}};x("textarea-ui",nn);Q();var rn=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,checked:{type:Boolean,default:!1,reflect:!0},indeterminate:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>It`<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)}};x("check-ui",rn);Q();var on=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>It`<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)}};x("radio-ui",on);var an=class extends Z{static properties={...Z.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&&!this.querySelector(':scope > [slot="heading"]')){let t=document.createElement("span");t.setAttribute("slot","heading"),t.dataset.fromAttr="true",t.textContent=this.heading,this.appendChild(t)}if(this.description&&!this.querySelector(':scope > [slot="description"]')){let t=document.createElement("span");t.setAttribute("slot","description"),t.dataset.fromAttr="true",t.textContent=this.description,this.appendChild(t)}if(this.icon&&!this.querySelector(':scope > [slot="icon"]')){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}};x("option-card-ui",an);Q();var _e=Object.freeze({AVAILABLE:"available",CONNECTED:"connected",ERROR:"error",PENDING:"pending",COMING_SOON:"coming-soon"}),JO=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:""}}),vA=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":{variant:"muted",text:"Coming soon",icon:""}}),xA=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"}),SA="plug",ln=class extends k{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;#a=null;#o=null;#l=null;connected(){this.setAttribute("role","group"),this.#e=this.ensure("body"),this.#i=this.ensure("logo"),this.#s=this.ensure("heading"),this.#n=this.ensure("desc"),this.#a=this.ensure("status"),this.#o=this.ensure("footer"),this.#i.parentElement!==this.#e&&this.#e.appendChild(this.#i),this.#s.parentElement!==this.#e&&this.#e.appendChild(this.#s),this.#a.parentElement!==this.#e&&this.#e.appendChild(this.#a),this.#s.id?this.#t=this.#s.id:(this.#t=`integration-card-heading-${Math.random().toString(36).slice(2,9)}`,this.#s.id=this.#t),this.setAttribute("aria-labelledby",this.#t),this.addEventListener("press",this.#m),this.addEventListener("action",this.#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.#a=null,this.#o=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()||_e.AVAILABLE;return Object.values(_e).includes(t)?t:_e.AVAILABLE}#h(){for(let t of this.children)if(t!==this.#e&&t!==this.#n&&t!==this.#r&&t!==this.#o&&!(t.getAttribute&&t.getAttribute("slot")==="actions")&&!(t.dataset&&(t.dataset.integrationCardBody!==void 0||t.dataset.integrationCardDescription!==void 0||t.dataset.integrationCardError!==void 0||t.dataset.integrationCardFooter!==void 0)))return!0;return!1}#u(){if(!this.#i)return;let t=(this.logo||"").trim();if(t.startsWith("{{p:"))return;let e=(this.provider||"").trim().toLowerCase(),i=t||xA[e]||(e?SA:"");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.#a)return;let e=vA[t];if(!e){this.#a.hidden=!0,this.#a.removeAttribute("aria-label");return}this.#a.hidden=!1,this.#a.setAttribute("variant",e.variant),this.#a.setAttribute("text",e.text),this.#a.setAttribute("size","sm"),e.icon?this.#a.setAttribute("icon",e.icon):this.#a.removeAttribute("icon"),this.#a.setAttribute("aria-label",e.text)}#f(t){let e=(this["error-message"]||this.getAttribute("error-message")||"").trim();t===_e.ERROR&&e?(this.#r||(this.#r=this.ensure("error")),this.#r.parentElement||(this.#n?.parentElement===this?this.#n.after(this.#r):this.#o?.parentElement===this?this.insertBefore(this.#r,this.#o):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===_e.COMING_SOON){this.drop("button"),this.#l=null;return}let e=JO[t];if(!e){this.drop("button"),this.#l=null;return}this.#l||(this.#l=this.ensure("button")),this.#l.parentElement!==this.#o&&this.#o.insertBefore(this.#l,this.#o.firstChild),this.#l.setAttribute("text",e.label),this.#l.setAttribute("variant",e.variant),this.#l.setAttribute("size","sm"),e.icon?this.#l.setAttribute("icon",e.icon):this.#l.removeAttribute("icon"),t===_e.CONNECTED?this.#l.setAttribute("aria-pressed","true"):t===_e.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===_e.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===_e.PENDING||e===_e.COMING_SOON){t.stopPropagation();return}let i=JO[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}}))}}};x("integration-card-ui",ln);Q();var hn=class s extends Z{static labelDeprecated=!1;static properties={...Z.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"),It`
|
|
94
|
+
`),this.#t=this.querySelector('[slot="text"]'),this.value&&(this.#t.textContent=this.value),this.#t&&(this.#t.addEventListener("input",this.#e),this.#t.addEventListener("keydown",this.#i),this.#t.addEventListener("blur",this.#s),this.#t.addEventListener("paste",this.#n))}render(){if(!this.#t)return;this.#t.setAttribute("data-placeholder",this.placeholder),this.disabled||this.readonly?this.#t.contentEditable="false":this.#t.contentEditable="plaintext-only";let t=this.value||"";this.#t.textContent!==t&&(this.#t.textContent=t,this.#t.toggleAttribute("data-empty",!t));let e=this.querySelector('[slot="label"]');e&&this.label&&e.setAttribute("label",this.label),this.setAttribute("aria-label",this.label||this.placeholder||"")}#e=()=>{let t=this.#t.textContent||"";this.value=t,this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#i=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.flushPendingInput(),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#s=()=>{this.flushPendingInput(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#n=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,e)};focus(){this.#t?.focus()}clear(){this.value="",this.#t&&(this.#t.textContent="",this.#t.setAttribute("data-empty","")),this.syncValue("")}disconnected(){super.disconnected(),this.#t&&(this.#t.removeEventListener("input",this.#e),this.#t.removeEventListener("keydown",this.#i),this.#t.removeEventListener("blur",this.#s),this.#t.removeEventListener("paste",this.#n)),this.#t=null}};x("textarea-ui",nn);Q();var rn=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,checked:{type:Boolean,default:!1,reflect:!0},indeterminate:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>It`<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)}};x("check-ui",rn);Q();var on=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,checked:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0}};static template=()=>It`<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)}};x("radio-ui",on);var an=class extends Z{static properties={...Z.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&&!this.querySelector(':scope > [slot="heading"]')){let t=document.createElement("span");t.setAttribute("slot","heading"),t.dataset.fromAttr="true",t.textContent=this.heading,this.appendChild(t)}if(this.description&&!this.querySelector(':scope > [slot="description"]')){let t=document.createElement("span");t.setAttribute("slot","description"),t.dataset.fromAttr="true",t.textContent=this.description,this.appendChild(t)}if(this.icon&&!this.querySelector(':scope > [slot="icon"]')){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}};x("option-card-ui",an);Q();var _e=Object.freeze({AVAILABLE:"available",CONNECTED:"connected",ERROR:"error",PENDING:"pending",COMING_SOON:"coming-soon"}),JO=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:""}}),vA=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":{variant:"muted",text:"Coming soon",icon:""}}),xA=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"}),SA="plug",ln=class extends k{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;#a=null;#o=null;#l=null;connected(){this.setAttribute("role","group"),this.#e=this.ensure("body"),this.#i=this.ensure("logo"),this.#s=this.ensure("heading"),this.#n=this.ensure("desc"),this.#a=this.ensure("status"),this.#o=this.ensure("footer"),this.#i.parentElement!==this.#e&&this.#e.appendChild(this.#i),this.#s.parentElement!==this.#e&&this.#e.appendChild(this.#s),this.#a.parentElement!==this.#e&&this.#e.appendChild(this.#a),this.#s.id?this.#t=this.#s.id:(this.#t=`integration-card-heading-${Math.random().toString(36).slice(2,9)}`,this.#s.id=this.#t),this.setAttribute("aria-labelledby",this.#t),this.addEventListener("press",this.#m),this.addEventListener("action",this.#g)}disconnected(){this.removeEventListener("press",this.#m),this.removeEventListener("action",this.#g),this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=null,this.#a=null,this.#o=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()||_e.AVAILABLE;return Object.values(_e).includes(t)?t:_e.AVAILABLE}#h(){for(let t of this.children)if(t!==this.#e&&t!==this.#n&&t!==this.#r&&t!==this.#o&&!(t.getAttribute&&t.getAttribute("slot")==="actions")&&!(t.dataset&&(t.dataset.integrationCardBody!==void 0||t.dataset.integrationCardDescription!==void 0||t.dataset.integrationCardError!==void 0||t.dataset.integrationCardFooter!==void 0)))return!0;return!1}#u(){if(!this.#i)return;let t=(this.logo||"").trim();if(t.startsWith("{{p:"))return;let e=(this.provider||"").trim().toLowerCase(),i=t||xA[e]||(e?SA:"");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.#a)return;let e=vA[t];if(!e){this.#a.hidden=!0,this.#a.removeAttribute("aria-label");return}this.#a.hidden=!1,this.#a.setAttribute("variant",e.variant),this.#a.setAttribute("text",e.text),this.#a.setAttribute("size","sm"),e.icon?this.#a.setAttribute("icon",e.icon):this.#a.removeAttribute("icon"),this.#a.setAttribute("aria-label",e.text)}#f(t){let e=(this["error-message"]||this.getAttribute("error-message")||"").trim();t===_e.ERROR&&e?(this.#r||(this.#r=this.ensure("error")),this.#r.parentElement||(this.#n?.parentElement===this?this.#n.after(this.#r):this.#o?.parentElement===this?this.insertBefore(this.#r,this.#o):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===_e.COMING_SOON){this.drop("button"),this.#l=null;return}let e=JO[t];if(!e){this.drop("button"),this.#l=null;return}this.#l||(this.#l=this.ensure("button")),this.#l.parentElement!==this.#o&&this.#o.insertBefore(this.#l,this.#o.firstChild),this.#l.setAttribute("text",e.label),this.#l.setAttribute("variant",e.variant),this.#l.setAttribute("size","sm"),e.icon?this.#l.setAttribute("icon",e.icon):this.#l.removeAttribute("icon"),t===_e.CONNECTED?this.#l.setAttribute("aria-pressed","true"):t===_e.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===_e.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===_e.PENDING||e===_e.COMING_SOON){t.stopPropagation();return}let i=JO[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}}))}}};x("integration-card-ui",ln);Q();var hn=class s extends Z{static labelDeprecated=!1;static properties={...Z.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"),It`
|
|
95
95
|
<span slot="track"><span slot="thumb"></span></span>
|
|
96
96
|
${t.label?It`<span slot="label">${t.label}</span>`:null}
|
|
97
97
|
${t.hint?It`<span slot="hint" id=${e}>${t.hint}</span>`:null}
|
|
@@ -113,7 +113,7 @@ ${i.join(`
|
|
|
113
113
|
.value=\${signal.value} \u2190 read the signal's current value
|
|
114
114
|
Functions are not auto-invoked at render time; the slider reads
|
|
115
115
|
.value synchronously. See USAGE.md "Reactive binding" for the
|
|
116
|
-
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())}#y(){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("data-dragging","");let e;if(this.dual){let i=t.currentTarget?.dataset?.thumb;this.#a=i==="upper"?"upper":"lower",e=this.#a==="lower"?this.#s:this.#n,e?.setAttribute("data-active","")}else e=this.#i;if(this.#e&&e){let i=this.dual?this.#a:null;this.#o=t.clientX-this.#f(i)}else this.#o=0;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.#k),e.addEventListener("pointerup",this.#v)};#k=t=>{if(!this.#r)return;let e=t.clientX-this.#o;if(this.dual){let i=this.#d(e,this.#a);this.#a==="lower"?this.#O(i):this.#g(i)}else this.#m(this.#d(e))};#v=t=>{this.#r=!1,this.#o=0,this.removeAttribute("data-dragging");let e=this.dual?this.#a==="lower"?this.#s:this.#n:this.#i;e?.releasePointerCapture(t.pointerId),e?.removeEventListener("pointermove",this.#k),e?.removeEventListener("pointerup",this.#v),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#y(),this.#a=null};#x=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.#y()}};#S=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.#y()};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.#x),this.removeEventListener("keydown",this.#S),this.#e=null,this.#i=null,this.#s=null,this.#n=null}};x("slider-ui",cn);var wA=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,kA=0;function at(s,t,e={}){let{placement:i="bottom-start",gap:n=4,matchWidth:r=!1}=e;return wA?AA(s,t,{placement:i,gap:n,matchWidth:r}):EA(s,t,{placement:i,gap:n,matchWidth:r})}function AA(s,t,{placement:e,gap:i,matchWidth:n}){let r=`--a-anchor-${++kA}`,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};return s.style.anchorName=r,t.style.position="fixed",t.style.positionAnchor=r,t.style.positionArea=CA(e),t.style.margin=$A(e,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))",t.style.maxHeight="calc(100vh - 3rem)",t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[l,h]of Object.entries(a))t.style[l]=h}}function $A(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 CA(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 EA(s,t,{placement:e,gap:i,matchWidth:n}){function r(){if(!s||!t)return;let a=s.getBoundingClientRect(),l=t.getBoundingClientRect(),h=window.innerWidth,c=window.innerHeight,u=e;u.startsWith("bottom")&&a.bottom+i+l.height>c&&a.top-i-l.height>0?u=u.replace("bottom","top"):u.startsWith("top")&&a.top-i-l.height<0&&a.bottom+i+l.height<c&&(u=u.replace("top","bottom"));let d,f;u.startsWith("top")?d=a.top-l.height-i:u.startsWith("bottom")?d=a.bottom+i:u.startsWith("left")?(f=a.left-l.width-i,u==="left-start"?d=a.top:u==="left-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2):u.startsWith("right")&&(f=a.right+i,u==="right-start"?d=a.top:u==="right-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2),f===void 0&&(u.endsWith("-start")?f=a.left:u.endsWith("-end")?f=a.right-l.width:f=a.left+(a.width-l.width)/2),f+l.width>h-i&&(f=a.right-l.width),f<i&&(f=a.left),d=Math.max(i,Math.min(d,c-l.height-i)),f=Math.max(i,Math.min(f,h-l.width-i)),t.style.position="fixed",t.style.top=`${d}px`,t.style.left=`${f}px`,n&&(t.style.width=`${a.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{r(),t.style.opacity=""});let o=PA(s);for(let a of o)a.addEventListener("scroll",r,{passive:!0});return window.addEventListener("resize",r,{passive:!0}),()=>{for(let a of o)a.removeEventListener("scroll",r);window.removeEventListener("resize",r)}}function PA(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}je();function Lt(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var un=class s extends Z{static labelDeprecated=!1;static requiredIcons=["caret-up-down","check","x","magnifying-glass"];static#t=new WeakSet;static properties={...Z.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},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",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},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},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;#a="";#o=null;#l=null;#c=()=>{this.disabled||(this.open=!0)};#h=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#u=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.#a="",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({})}#d(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#f(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.#d(),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.#f(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.#f(t.map(o=>o.value));if(e===this.value)return;let i=this.#d();this.value=e,this.syncValue(e),this.render();let n=this.#d(),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.#d();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#p(){let t=this.#d();if(t.length===0)return;let e=t.pop(),i=this.#f(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#m=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.#d().filter(o=>o!==i),r=this.#f(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)};#g=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#y=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.#d());i.length>0&&i.every(o=>n.has(o))?this.clear():this.selectAllOptions()};#b=!1;#k(){let t="Select...",e=this.hasAttribute("aria-label")&&!this.#b,i=!!this.label||this.hasAttribute("aria-labelledby");!e&&!i&&this.placeholder&&this.placeholder!==t?(this.setAttribute("aria-label",this.placeholder),this.#b=!0):this.#b&&(this.removeAttribute("aria-label"),this.#b=!1)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#M),this.addEventListener("keydown",this.#E),this.addEventListener("remove",this.#m),this.#i.length===0&&this.#v()}render(){if(this.multiple?this.setAttribute("data-multi-chips",""):this.removeAttribute("data-multi-chips"),this.#k(),this.querySelector('[slot="trigger"]')){let e=this.querySelector('[slot="display"]');if(e&&!this.multiple)e.tagName==="INPUT"?this.#a||(e.value=this.#$()===this.placeholder?"":this.#$()):e.textContent=this.#$();else if(e&&this.multiple){let i=this.#d().length>0;e.tagName==="INPUT"?(e.placeholder=i?"":this.placeholder||"",this.#a||(e.value="")):e.textContent=i?"":this.placeholder||""}}else{this.#s=!0;let e=this.#n;e?.parentNode===this&&this.removeChild(e);let i=this.avatar?`<img slot="leading" data-select-leading src="${Lt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${Lt(this.icon)}"></icon-ui>`:"",n=this.searchable?`<input slot="display" type="text" role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="${Lt(this.placeholder||"")}" value="${Lt(this.#$()===this.placeholder?"":this.#$())}" />`:`<span slot="display">${Lt(this.#$())}</span>`,r=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${r}">${Lt(this.hint)}</span>`:"";this.innerHTML=`
|
|
116
|
+
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())}#y(){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("data-dragging","");let e;if(this.dual){let i=t.currentTarget?.dataset?.thumb;this.#a=i==="upper"?"upper":"lower",e=this.#a==="lower"?this.#s:this.#n,e?.setAttribute("data-active","")}else e=this.#i;if(this.#e&&e){let i=this.dual?this.#a:null;this.#o=t.clientX-this.#f(i)}else this.#o=0;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.#w),e.addEventListener("pointerup",this.#v)};#w=t=>{if(!this.#r)return;let e=t.clientX-this.#o;if(this.dual){let i=this.#d(e,this.#a);this.#a==="lower"?this.#g(i):this.#O(i)}else this.#m(this.#d(e))};#v=t=>{this.#r=!1,this.#o=0,this.removeAttribute("data-dragging");let e=this.dual?this.#a==="lower"?this.#s:this.#n:this.#i;e?.releasePointerCapture(t.pointerId),e?.removeEventListener("pointermove",this.#w),e?.removeEventListener("pointerup",this.#v),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#y(),this.#a=null};#x=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.#y()}};#S=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.#y()};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.#x),this.removeEventListener("keydown",this.#S),this.#e=null,this.#i=null,this.#s=null,this.#n=null}};x("slider-ui",cn);var wA=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,kA=0;function at(s,t,e={}){let{placement:i="bottom-start",gap:n=4,matchWidth:r=!1}=e;return wA?AA(s,t,{placement:i,gap:n,matchWidth:r}):EA(s,t,{placement:i,gap:n,matchWidth:r})}function AA(s,t,{placement:e,gap:i,matchWidth:n}){let r=`--a-anchor-${++kA}`,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};return s.style.anchorName=r,t.style.position="fixed",t.style.positionAnchor=r,t.style.positionArea=CA(e),t.style.margin=$A(e,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))",t.style.maxHeight="calc(100vh - 3rem)",t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[l,h]of Object.entries(a))t.style[l]=h}}function $A(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 CA(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 EA(s,t,{placement:e,gap:i,matchWidth:n}){function r(){if(!s||!t)return;let a=s.getBoundingClientRect(),l=t.getBoundingClientRect(),h=window.innerWidth,c=window.innerHeight,u=e;u.startsWith("bottom")&&a.bottom+i+l.height>c&&a.top-i-l.height>0?u=u.replace("bottom","top"):u.startsWith("top")&&a.top-i-l.height<0&&a.bottom+i+l.height<c&&(u=u.replace("top","bottom"));let d,f;u.startsWith("top")?d=a.top-l.height-i:u.startsWith("bottom")?d=a.bottom+i:u.startsWith("left")?(f=a.left-l.width-i,u==="left-start"?d=a.top:u==="left-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2):u.startsWith("right")&&(f=a.right+i,u==="right-start"?d=a.top:u==="right-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2),f===void 0&&(u.endsWith("-start")?f=a.left:u.endsWith("-end")?f=a.right-l.width:f=a.left+(a.width-l.width)/2),f+l.width>h-i&&(f=a.right-l.width),f<i&&(f=a.left),d=Math.max(i,Math.min(d,c-l.height-i)),f=Math.max(i,Math.min(f,h-l.width-i)),t.style.position="fixed",t.style.top=`${d}px`,t.style.left=`${f}px`,n&&(t.style.width=`${a.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{r(),t.style.opacity=""});let o=PA(s);for(let a of o)a.addEventListener("scroll",r,{passive:!0});return window.addEventListener("resize",r,{passive:!0}),()=>{for(let a of o)a.removeEventListener("scroll",r);window.removeEventListener("resize",r)}}function PA(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}je();function Lt(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var un=class s extends Z{static labelDeprecated=!1;static requiredIcons=["caret-up-down","check","x","magnifying-glass"];static#t=new WeakSet;static properties={...Z.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},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",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},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},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;#a="";#o=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.#a="",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)};#y=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()};#w=!1;#v(){let t="Select...",e=this.hasAttribute("aria-label")&&!this.#w,i=!!this.label||this.hasAttribute("aria-labelledby");!e&&!i&&this.placeholder&&this.placeholder!==t?(this.setAttribute("aria-label",this.placeholder),this.#w=!0):this.#w&&(this.removeAttribute("aria-label"),this.#w=!1)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#E),this.addEventListener("keydown",this.#P),this.addEventListener("remove",this.#g),this.#i.length===0&&this.#S(),this.#c||(this.#c=new MutationObserver(()=>{if(!(this.#i.length||!this.#x().some(e=>e.tagName==="OPTION"||e.tagName==="OPTGROUP"))&&(this.#S(),this.#i.length)){this.#$();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#C())}})),this.#c.observe(this,{childList:!0,subtree:!0})}render(){if(this.multiple?this.setAttribute("data-multi-chips",""):this.removeAttribute("data-multi-chips"),this.#v(),this.querySelector('[slot="trigger"]')){let e=this.querySelector('[slot="display"]');if(e&&!this.multiple)e.tagName==="INPUT"?this.#a||(e.value=this.#C()===this.placeholder?"":this.#C()):e.textContent=this.#C();else if(e&&this.multiple){let i=this.#f().length>0;e.tagName==="INPUT"?(e.placeholder=i?"":this.placeholder||"",this.#a||(e.value="")):e.textContent=i?"":this.placeholder||""}}else{this.#s=!0;let e=this.#n;e?.parentNode===this&&this.removeChild(e);let i=this.avatar?`<img slot="leading" data-select-leading src="${Lt(this.avatar)}" alt="" />`:this.icon?`<icon-ui slot="leading" data-select-leading name="${Lt(this.icon)}"></icon-ui>`:"",n=this.searchable?`<input slot="display" type="text" role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="${Lt(this.placeholder||"")}" value="${Lt(this.#C()===this.placeholder?"":this.#C())}" />`:`<span slot="display">${Lt(this.#C())}</span>`,r=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${r}">${Lt(this.hint)}</span>`:"";this.innerHTML=`
|
|
117
117
|
<span slot="trigger">
|
|
118
118
|
${i}
|
|
119
119
|
<span data-chips></span>
|
|
@@ -124,7 +124,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
124
124
|
<icon-ui name="caret-up-down" slot="caret"></icon-ui>
|
|
125
125
|
</span>
|
|
126
126
|
${o}
|
|
127
|
-
`,this.hint&&this.setAttribute("aria-describedby",r);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#g),a.addEventListener("click",this.#g)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#R),this.#o.removeEventListener("focus",this.#c),this.#o.removeEventListener("click",this.#h)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#R),this.#o.addEventListener("focus",this.#c),this.#o.addEventListener("click",this.#h))),e&&this.appendChild(e)}this.#S(),this.multiple&&this.#P();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#d().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.#w()),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");(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=at(e,this.#n,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#Q,{once:!0})})}else this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q)}#v(){this.#i=[];let t=new Set,e=[];for(let i of 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,icon:r.getAttribute("icon")||"",avatar:r.getAttribute("avatar")||""}),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")||""}),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){Tt(()=>{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.#w();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#$())})}get options(){return this.#i}static#x(t){return t?t.avatar?`<img data-option-avatar src="${Lt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Lt(t.icon)}"></icon-ui>`:"":""}#S(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(c=>c.options||[c]).find(c=>!c.header&&!c.separator&&c.value===this.value),n=i&&i.avatar||this.avatar||"",r=i&&i.icon||this.icon||"",o=t.querySelector(":scope > [data-select-leading]"),a="";if(n?a=`<img slot="leading" data-select-leading src="${Lt(n)}" alt="" />`:r&&(a=`<icon-ui slot="leading" data-select-leading name="${Lt(r)}"></icon-ui>`),!a){o?.remove();return}let l=document.createElement("template");l.innerHTML=a;let h=l.content.firstElementChild;o?o.tagName===h.tagName?h.tagName==="IMG"?o.getAttribute("src")!==h.getAttribute("src")&&o.setAttribute("src",h.getAttribute("src")):o.getAttribute("name")!==h.getAttribute("name")&&o.setAttribute("name",h.getAttribute("name")):o.replaceWith(h):t.insertBefore(h,t.firstChild)}#w(){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");i.type="button",i.dataset.selectAllBtn="",i.textContent=this.#A()?"Clear":"Select all",i.addEventListener("click",this.#y),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"),i.setAttribute("data-value",e.value||"");let n=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,r=n?n.has(e.value):e.value===this.value,o=s.#x(e);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}${Lt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else o?i.innerHTML=`${o}${Lt(e.label)}`:i.textContent=e.label;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.#u),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>${Lt(e.label)}</strong><span>${Lt(e.description||"")}</span></div>`:`<div><strong>${Lt(e.label)}</strong><span>${Lt(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">${Lt(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.#a&&this.#C()}#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.#d());return t.every(i=>e.has(String(i.value)))}#P(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;let e=this.#d(),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=this.#i.flatMap(l=>l.options||[l]).filter(l=>!l.separator&&!l.header&&l.value!=null),a=l=>{let h=o.find(c=>String(c.value)===String(l));return h?h.label:String(l)};for(;t.firstChild;)t.removeChild(t.firstChild);for(let l of n){let h=document.createElement("tag-ui");h.setAttribute("size","sm"),!this.disabled&&!this.readonly&&h.setAttribute("removable",""),h.dataset.chipValue=String(l),h.setAttribute("text",a(l)),t.appendChild(h)}if(r>0){let l=document.createElement("button");l.type="button",l.dataset.more="",l.textContent=`+${r} more`,l.addEventListener("click",this.#O),t.appendChild(l)}}#$(){return this.multiple?this.value?"":this.placeholder:this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#M=t=>{this.disabled||this.#n&&t.composedPath().includes(this.#n)||(this.open=!this.open)};#Q=t=>{!this.contains(t.target)&&!(this.#n&&t.composedPath().includes(this.#n))&&(this.open=!1)};#E=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.tagName==="INPUT"&&e.getAttribute("slot")==="display",n=!this.#a||this.#a.length===0;if((!i||n)&&this.#d().length>0){t.preventDefault(),this.#p();return}}if(t.key==="Escape"){if(this.searchable&&this.#a){this.#a="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#C();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.#a){let i=this.#a;this.value=i,this.#a="",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.#L(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#L(-1))};#R=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#C()};#C(){if(!this.#n)return;let t=this.#a.toLowerCase(),e=this.#n.querySelectorAll('[role="option"]'),i=!1;for(let r of e){let o=(r.textContent||"").toLowerCase();!t||o.includes(t)?(r.removeAttribute("data-filtered-out"),r.style.display="",i=!0):(r.setAttribute("data-filtered-out",""),r.style.display="none")}for(let r of this.#n.querySelectorAll('[role="group"]')){let o=r.querySelectorAll('[role="option"]:not([data-filtered-out])').length;r.style.display=o?"":"none"}let n=this.#n.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#L(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.#M),this.removeEventListener("keydown",this.#E),this.removeEventListener("remove",this.#m),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q),this.#o&&(this.#o.removeEventListener("input",this.#R),this.#o.removeEventListener("focus",this.#c),this.#o.removeEventListener("click",this.#h),this.#o=null),this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#n=null}};x("select-ui",un);Q();var dn=class extends k{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()}};x("segment-ui",dn);var fn=class s extends Z{static properties={...Z.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#u)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#l(this.#a)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#l(this.#a)}))}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.#h),this.removeEventListener("keydown",this.#u),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator")&&!(i.tagName==="SPAN"&&i.style.display==="contents"));e&&(s.#t.add(this),console.warn(`[segmented-ui] child <${e.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.#a;if(t.length){for(let e of t){let n=(e.value||e.getAttribute("value")||"")===this.value;n?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",n?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){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",""))}#c(t){t.disabled||(this.value=t.value,this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#c(e)};#u=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#o,n=i.indexOf(e);if(n<0)return;let r;switch(t.key){case"ArrowRight":case"ArrowDown":r=n<i.length-1?n+1:0;break;case"ArrowLeft":case"ArrowUp":r=n>0?n-1:i.length-1;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}t.preventDefault(),i[r].focus(),this.#c(i[r])}};x("segmented-ui",fn);var pn=class extends Z{static labelDeprecated=!1;static properties={...Z.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;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
|
|
127
|
+
`,this.hint&&this.setAttribute("aria-describedby",r);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#y),a.addEventListener("click",this.#y)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#L),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#L),this.#o.addEventListener("focus",this.#h),this.#o.addEventListener("click",this.#u))),e&&this.appendChild(e)}this.#A(),this.multiple&&this.#M();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.#$()),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");(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=at(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)}#x(){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}#S(){this.#i=[];let t=new Set,e=[];for(let i of this.#x())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")||""}),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")||""}),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){Tt(()=>{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.#$();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#C())})}get options(){return this.#i}static#k(t){return t?t.avatar?`<img data-option-avatar src="${Lt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Lt(t.icon)}"></icon-ui>`:"":""}#A(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(c=>c.options||[c]).find(c=>!c.header&&!c.separator&&c.value===this.value),n=i&&i.avatar||this.avatar||"",r=i&&i.icon||this.icon||"",o=t.querySelector(":scope > [data-select-leading]"),a="";if(n?a=`<img slot="leading" data-select-leading src="${Lt(n)}" alt="" />`:r&&(a=`<icon-ui slot="leading" data-select-leading name="${Lt(r)}"></icon-ui>`),!a){o?.remove();return}let l=document.createElement("template");l.innerHTML=a;let h=l.content.firstElementChild;o?o.tagName===h.tagName?h.tagName==="IMG"?o.getAttribute("src")!==h.getAttribute("src")&&o.setAttribute("src",h.getAttribute("src")):o.getAttribute("name")!==h.getAttribute("name")&&o.setAttribute("name",h.getAttribute("name")):o.replaceWith(h):t.insertBefore(h,t.firstChild)}#$(){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");i.type="button",i.dataset.selectAllBtn="",i.textContent=this.#T()?"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"),i.setAttribute("data-value",e.value||"");let n=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,r=n?n.has(e.value):e.value===this.value,o=s.#k(e);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}${Lt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else o?i.innerHTML=`${o}${Lt(e.label)}`:i.textContent=e.label;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>${Lt(e.label)}</strong><span>${Lt(e.description||"")}</span></div>`:`<div><strong>${Lt(e.label)}</strong><span>${Lt(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">${Lt(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.#a&&this.#Q()}#T(){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)))}#M(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)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=this.#i.flatMap(l=>l.options||[l]).filter(l=>!l.separator&&!l.header&&l.value!=null),a=l=>{let h=o.find(c=>String(c.value)===String(l));return h?h.label:String(l)};for(;t.firstChild;)t.removeChild(t.firstChild);for(let l of n){let h=document.createElement("tag-ui");h.setAttribute("size","sm"),!this.disabled&&!this.readonly&&h.setAttribute("removable",""),h.dataset.chipValue=String(l),h.setAttribute("text",a(l)),t.appendChild(h)}if(r>0){let l=document.createElement("button");l.type="button",l.dataset.more="",l.textContent=`+${r} more`,l.addEventListener("click",this.#O),t.appendChild(l)}}#C(){return this.multiple?this.value?"":this.placeholder:this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#E=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)};#P=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.tagName==="INPUT"&&e.getAttribute("slot")==="display",n=!this.#a||this.#a.length===0;if((!i||n)&&this.#f().length>0){t.preventDefault(),this.#m();return}}if(t.key==="Escape"){if(this.searchable&&this.#a){this.#a="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#Q();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.#a){let i=this.#a;this.value=i,this.#a="",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.#I(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#I(-1))};#L=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#Q()};#Q(){if(!this.#n)return;let t=this.#a.toLowerCase(),e=this.#n.querySelectorAll('[role="option"]'),i=!1;for(let r of e){let o=(r.textContent||"").toLowerCase();!t||o.includes(t)?(r.removeAttribute("data-filtered-out"),r.style.display="",i=!0):(r.setAttribute("data-filtered-out",""),r.style.display="none")}for(let r of this.#n.querySelectorAll('[role="group"]')){let o=r.querySelectorAll('[role="option"]:not([data-filtered-out])').length;r.style.display=o?"":"none"}let n=this.#n.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#I(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.#E),this.removeEventListener("keydown",this.#P),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#R),this.#o&&(this.#o.removeEventListener("input",this.#L),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u),this.#o=null),this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#n=null}};x("select-ui",un);Q();var dn=class extends k{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()}};x("segment-ui",dn);var fn=class s extends Z{static properties={...Z.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#u)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#l(this.#a)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#l(this.#a)}))}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.#h),this.removeEventListener("keydown",this.#u),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator")&&!(i.tagName==="SPAN"&&i.style.display==="contents"));e&&(s.#t.add(this),console.warn(`[segmented-ui] child <${e.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.#a;if(t.length){for(let e of t){let n=(e.value||e.getAttribute("value")||"")===this.value;n?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",n?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){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",""))}#c(t){t.disabled||(this.value=t.value,this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#c(e)};#u=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#o,n=i.indexOf(e);if(n<0)return;let r;switch(t.key){case"ArrowRight":case"ArrowDown":r=n<i.length-1?n+1:0;break;case"ArrowLeft":case"ArrowUp":r=n>0?n-1:i.length-1;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}t.preventDefault(),i[r].focus(),this.#c(i[r])}};x("segmented-ui",fn);var pn=class extends Z{static labelDeprecated=!1;static properties={...Z.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;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
|
|
128
128
|
<span slot="label">${this.label}</span>
|
|
129
129
|
<span slot="value">${this.#r(this.value)}</span>
|
|
130
130
|
${this.suffix?`<span slot="suffix">${this.suffix}</span>`:""}
|
|
@@ -139,7 +139,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
139
139
|
<select-ui slot="model" placeholder="Model" aria-label="Select model" divider></select-ui>
|
|
140
140
|
<button-ui icon="paper-plane-right" variant="ghost" slot="send" aria-label="Send message"></button-ui>
|
|
141
141
|
</div>
|
|
142
|
-
`),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.#o=document.createElement("input"),this.#o.type="file",this.#o.accept="image/*",this.#o.multiple=!0,this.#o.style.display="none",this.appendChild(this.#o),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.#o.addEventListener("change",this.#h)}this.#a=document.createElement("div"),this.#a.setAttribute("slot","preview"),this.#a.hidden=!0,this.insertBefore(this.#a,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=()=>{if(this.disabled||this.loading)return;let t=this.value;!t&&!this.#r.length||this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:t,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.#
|
|
142
|
+
`),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.#o=document.createElement("input"),this.#o.type="file",this.#o.accept="image/*",this.#o.multiple=!0,this.#o.style.display="none",this.appendChild(this.#o),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.#o.addEventListener("change",this.#h)}this.#a=document.createElement("div"),this.#a.setAttribute("slot","preview"),this.#a.hidden=!0,this.insertBefore(this.#a,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=()=>{if(this.disabled||this.loading)return;let t=this.value;!t&&!this.#r.length||this.dispatchEvent(new CustomEvent("submit",{bubbles:!0,detail:{text:t,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.#a&&(this.#a.innerHTML="",this.#a.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");r.textContent="\xD7",r.setAttribute("data-preview-remove",""),r.addEventListener("click",()=>this.#g(e)),i.appendChild(n),i.appendChild(r),this.#a.appendChild(i)}))}clear(){this.#t?.clear(),this.#r=[],this.#a&&(this.#a.innerHTML="",this.#a.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.#o?.removeEventListener("change",this.#h),this.removeEventListener("pointerdown",this.#u),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#a=null,this.#o=null}};customElements.define("chat-input-ui",ma);var QA={"&":"&","<":"<",">":">",'"':"""},tb=s=>s.replace(/[&<>"]/g,t=>QA[t]);function yn(s){let t=s.split(`
|
|
143
143
|
`),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(tb(t[i])),i++;i++;let c=h.join(`
|
|
144
144
|
`);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}>${jl(o[2])}</h${l}>`),i++;continue}if(/^[-*]\s/.test(n)){let l=[];for(;i<t.length&&/^[-*]\s/.test(t[i]);)l.push(`<li>${jl(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>${jl(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>${jl(a.join(" "))}</p>`)}return e.join(`
|
|
145
145
|
`)}function jl(s){return tb(s).replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/_(.+?)_/g,"<em>$1</em>").replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>')}Q();function TA(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var vn=class extends k{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=`
|
|
@@ -154,7 +154,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
154
154
|
`),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(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?yn(e):TA(e);if(t==="user")n.innerHTML=`<div slot="bubble">${r}</div>`;else{let o=i?"":'<span slot="cursor"></span>';n.innerHTML=`
|
|
155
155
|
<span slot="avatar">${t==="assistant"?"AI":t[0].toUpperCase()}</span>
|
|
156
156
|
<div slot="bubble">${r}${o}</div>
|
|
157
|
-
`}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=yn(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)}))}};x("chat-thread-ui",vn);Q();var xn=class extends k{#t=!1;#e=!1;#i=null;#s=null;#n=null;#r=null;#a="programmatic";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})}}#o=t=>{t.target.closest('[slot="close"]')&&(this.#a="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#a="escape",this.permanent||(this.open=!1)};#c=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#a;this.#a="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#r&&!this.permanent&&(this.#a="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#o);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.#o),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}};x("drawer-ui",xn);Q();var Sn=class extends k{#t=!1;#e=!1;#i=null;#s=null;#n=null;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>'};#r=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#a=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#o=()=>{this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0}))};#l=t=>{t.target===this.#n&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#r);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#a),t.addEventListener("close",this.#o),t.addEventListener("click",this.#l))}disconnected(){this.removeEventListener("press",this.#r),this.#n&&(this.#n.removeEventListener("cancel",this.#a),this.#n.removeEventListener("close",this.#o),this.#n.removeEventListener("click",this.#l)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#t=!1,this.#n=null}#c(){let e=getComputedStyle(this).getPropertyValue("--modal-duration").trim();return parseFloat(e)||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.ensure("header");if(i.parentElement!==e&&e.prepend(i),this.text?i.setAttribute("text",this.text):i.removeAttribute("text"),this.permanent)this.drop("close");else{let l=this.ensure("close");l.parentElement!==i&&i.appendChild(l)}let n=[...this.children].find(l=>l.getAttribute("slot")==="body"||!l.getAttribute("slot")&&l.localName==="section"),r=[...this.children].filter(l=>!l.getAttribute("slot")&&l.localName!=="section"&&l.localName!=="dialog"&&l.localName!=="footer"),o;n?(n.getAttribute("slot")!=="body"&&n.setAttribute("slot","body"),n.parentElement!==e&&e.appendChild(n),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),o=n):(o=this.ensure("body"),o.setAttribute("data-stamped",""),o.parentElement!==e&&e.appendChild(o));for(let l of r)l!==o&&o.appendChild(l);let a=[...this.children].find(l=>l.getAttribute("slot")==="footer"||!l.getAttribute("slot")&&l.localName==="footer");if(a)a.getAttribute("slot")!=="footer"&&a.setAttribute("slot","footer"),a.parentElement!==e&&e.appendChild(a),e.querySelector(':scope > [slot="footer"][data-stamped]')?.remove();else{let l=this.ensure("footer");l.setAttribute("data-stamped",""),l.parentElement!==e&&e.appendChild(l)}this.open&&!t.open?(this.#e=!1,this.#i=document.activeElement,t.showModal(),t.offsetHeight,t.setAttribute("data-open","")):!this.open&&t.open&&!this.#e&&this.#h(t)}#h(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.#c())}show(){this.open=!0}hide(){this.open=!1}};x("modal-ui",Sn);Q();var wn=class extends k{static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>It``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},kn=class s extends k{#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=()=>It``;#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;#a=null;#o=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("data-open")&&!this.#e&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("data-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("data-open"),this.setAttribute("data-closing",""),this.#i=setTimeout(()=>{this.#i=null;let t=this.parentElement;this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove(),t?.matches?.("feed-ui")&&Xe.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.#o)return;this.#a=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.#o=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.#o,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#u(){if(this.#o){this.removeEventListener("keydown",this.#o,!0),this.#o=null;try{this.#a?.focus?.()}catch{}this.#a=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()}},Xe=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(y=>y.tagName==="FEED-ITEM-UI"&&!y.hasAttribute("data-queued")).length,O=document.createElement("feed-item-ui");h&&O.setAttribute("data-id",h),O.text=e,O.heading=i,O.icon=n,O.variant=d;let g="duration"in t;return O.duration=c&&!g?0:o,l!=null&&(O.dismissible=!!l),c&&(O.action=c),m>=p&&O.setAttribute("data-queued",""),f.appendChild(O),typeof u=="function"&&O.update({onAction:u}),{id:h??null,dismiss:()=>O.dismiss(),update:y=>O.update(y)}}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[data-queued]");if(e&&e.removeAttribute("data-queued"),!(t.children.length>0)){try{t.hidePopover?.()}catch{}t.remove();for(let[i,n]of s.#t)n===t&&s.#t.delete(i)}}};x("feed-ui",wn),x("feed-item-ui",kn),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&Xe.post(s.detail)}));Q();var os=class extends k{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=()=>It``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,Xe.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=Xe.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),Xe.post(l)}};x("toast-ui",os),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&os.show(s.detail)}));Q();var ga=class extends k{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}};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")}};customElements.define("tab-ui",ga);Q();var An=class extends k{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.#o),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.#o),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.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):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()}#a(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#o=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#a(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.#a(i[l].dataset.value)}};x("tabs-ui",An);Q();var $n=class s extends k{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.#a),this.addEventListener("focusout",this.#a))}disconnected(){this.removeEventListener("mouseenter",this.#r),this.removeEventListener("focusin",this.#r),this.removeEventListener("mouseleave",this.#a),this.removeEventListener("focusout",this.#a),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.#o(),this.delay))};#a=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#o(){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=at(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=this.#s.style;for(let i=0;i<t.length;i++){let n=t[i];n.startsWith("--color-")&&this.#t.style.setProperty(n,t.getPropertyValue(n))}let e=getComputedStyle(this.#s);for(let i=0;i<10;i++){let n=e.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,O=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let g=f!=null?this.#g(String(f)):"",y=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",v=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${O}"></span>`:"",S=d?`<span data-tip-role="name">${this.#g(d)}</span>`:"",w=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${w}>${v}${S}<span data-tip-role="value">${g}${y}</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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}};x("tooltip-ui",$n);Q();var LA={new:{variant:"success",text:"New"},updated:{variant:"info",text:"Updated"},deprecated:{variant:"warning",text:"Deprecated"},removed:{variant:"danger",text:"Removed"},beta:{variant:"accent",text:"Beta"}},Cn=class extends k{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=LA[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()}};x("badge-ui",Cn);Q();var En=class extends k{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}};x("breadcrumb-ui",En);Q();var Pn=class s extends k{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;#a=null;#o=!1;#l=new WeakMap;static#c=3;#h=t=>{let e=t.target instanceof Element?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=this.#l.get(e);i&&this.#v(i)};#u=t=>{let e=t.target instanceof Element?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.#b(i)};connected(){this.#o||(this.#o=!0,this.addEventListener("keydown",this.#w))}render(){this.#s||(this.#d(),this.innerHTML=`
|
|
157
|
+
`}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=yn(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)}))}};x("chat-thread-ui",vn);Q();var xn=class extends k{#t=!1;#e=!1;#i=null;#s=null;#n=null;#r=null;#a="programmatic";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})}}#o=t=>{t.target.closest('[slot="close"]')&&(this.#a="close-button",this.open=!1)};#l=t=>{t.preventDefault(),this.#a="escape",this.permanent||(this.open=!1)};#c=()=>{this.open=!1,this.#i?.focus(),this.#i=null;let t=this.#a;this.#a="programmatic",this.dispatchEvent(new CustomEvent("close",{detail:{reason:t},bubbles:!0}))};#h=t=>{t.target===this.#r&&!this.permanent&&(this.#a="backdrop",this.open=!1)};connected(){this.addEventListener("press",this.#o);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.#o),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}};x("drawer-ui",xn);Q();var Sn=class extends k{#t=!1;#e=!1;#i=null;#s=null;#n=null;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>'};#r=t=>{t.target.closest('[slot="close"]')&&(this.open=!1)};#a=t=>{t.preventDefault(),this.permanent||(this.open=!1)};#o=()=>{this.open=!1,this.#i?.focus(),this.#i=null,this.dispatchEvent(new Event("close",{bubbles:!0}))};#l=t=>{t.target===this.#n&&!this.permanent&&(this.open=!1)};connected(){this.addEventListener("press",this.#r);let t=this.ensure("dialog");t&&!this.#t&&(this.#t=!0,this.#n=t,t.addEventListener("cancel",this.#a),t.addEventListener("close",this.#o),t.addEventListener("click",this.#l))}disconnected(){this.removeEventListener("press",this.#r),this.#n&&(this.#n.removeEventListener("cancel",this.#a),this.#n.removeEventListener("close",this.#o),this.#n.removeEventListener("click",this.#l)),this.#s!=null&&(clearTimeout(this.#s),this.#s=null),this.#t=!1,this.#n=null}#c(){let e=getComputedStyle(this).getPropertyValue("--modal-duration").trim();return parseFloat(e)||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.ensure("header");if(i.parentElement!==e&&e.prepend(i),this.text?i.setAttribute("text",this.text):i.removeAttribute("text"),this.permanent)this.drop("close");else{let l=this.ensure("close");l.parentElement!==i&&i.appendChild(l)}let n=[...this.children].find(l=>l.getAttribute("slot")==="body"||!l.getAttribute("slot")&&l.localName==="section"),r=[...this.children].filter(l=>!l.getAttribute("slot")&&l.localName!=="section"&&l.localName!=="dialog"&&l.localName!=="footer"),o;n?(n.getAttribute("slot")!=="body"&&n.setAttribute("slot","body"),n.parentElement!==e&&e.appendChild(n),e.querySelector(':scope > [slot="body"][data-stamped]')?.remove(),o=n):(o=this.ensure("body"),o.setAttribute("data-stamped",""),o.parentElement!==e&&e.appendChild(o));for(let l of r)l!==o&&o.appendChild(l);let a=[...this.children].find(l=>l.getAttribute("slot")==="footer"||!l.getAttribute("slot")&&l.localName==="footer");if(a)a.getAttribute("slot")!=="footer"&&a.setAttribute("slot","footer"),a.parentElement!==e&&e.appendChild(a),e.querySelector(':scope > [slot="footer"][data-stamped]')?.remove();else{let l=this.ensure("footer");l.setAttribute("data-stamped",""),l.parentElement!==e&&e.appendChild(l)}this.open&&!t.open?(this.#e=!1,this.#i=document.activeElement,t.showModal(),t.offsetHeight,t.setAttribute("data-open","")):!this.open&&t.open&&!this.#e&&this.#h(t)}#h(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.#c())}show(){this.open=!0}hide(){this.open=!1}};x("modal-ui",Sn);Q();var wn=class extends k{static properties={position:{type:String,default:"bottom-right",reflect:!0},max:{type:Number,default:5,reflect:!0}};static template=()=>It``;connected(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Feed")}},kn=class s extends k{#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=()=>It``;#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;#a=null;#o=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("data-open")&&!this.#e&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.setAttribute("data-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("data-open"),this.setAttribute("data-closing",""),this.#i=setTimeout(()=>{this.#i=null;let t=this.parentElement;this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove(),t?.matches?.("feed-ui")&&Xe.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.#o)return;this.#a=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.#o=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.#o,!0),queueMicrotask(()=>{let e=t();(this.querySelector("[data-feed-action]")||e[0])?.focus?.()})}#u(){if(this.#o){this.removeEventListener("keydown",this.#o,!0),this.#o=null;try{this.#a?.focus?.()}catch{}this.#a=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()}},Xe=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(y=>y.tagName==="FEED-ITEM-UI"&&!y.hasAttribute("data-queued")).length,O=document.createElement("feed-item-ui");h&&O.setAttribute("data-id",h),O.text=e,O.heading=i,O.icon=n,O.variant=d;let g="duration"in t;return O.duration=c&&!g?0:o,l!=null&&(O.dismissible=!!l),c&&(O.action=c),m>=p&&O.setAttribute("data-queued",""),f.appendChild(O),typeof u=="function"&&O.update({onAction:u}),{id:h??null,dismiss:()=>O.dismiss(),update:y=>O.update(y)}}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[data-queued]");if(e&&e.removeAttribute("data-queued"),!(t.children.length>0)){try{t.hidePopover?.()}catch{}t.remove();for(let[i,n]of s.#t)n===t&&s.#t.delete(i)}}};x("feed-ui",wn),x("feed-item-ui",kn),typeof window<"u"&&!window.__adiaFeedListenerInstalled&&(window.__adiaFeedListenerInstalled=!0,window.addEventListener("feed",s=>{s?.detail&&typeof s.detail=="object"&&Xe.post(s.detail)}));Q();var os=class extends k{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=()=>It``;connected(){this.__routedToFeed||(this.__routedToFeed=!0,Xe.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=Xe.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),Xe.post(l)}};x("toast-ui",os),typeof window<"u"&&!window.__adiaToastListenerInstalled&&(window.__adiaToastListenerInstalled=!0,window.addEventListener("toast",s=>{s?.detail&&typeof s.detail=="object"&&os.show(s.detail)}));Q();var ga=class extends k{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}};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")}};customElements.define("tab-ui",ga);Q();var An=class extends k{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.#o),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.#o),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.removeAttribute("hidden"),e.setAttribute("role","tabpanel")):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()}#a(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#o=t=>{let e=t.target.closest('[slot="tab-button"]');!e||!this.contains(e)||e.hasAttribute("disabled")||this.#a(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.#a(i[l].dataset.value)}};x("tabs-ui",An);Q();var $n=class s extends k{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.#a),this.addEventListener("focusout",this.#a))}disconnected(){this.removeEventListener("mouseenter",this.#r),this.removeEventListener("focusin",this.#r),this.removeEventListener("mouseleave",this.#a),this.removeEventListener("focusout",this.#a),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.#o(),this.delay))};#a=()=>{this.#e&&(clearTimeout(this.#e),this.#e=null),this.#l()};#o(){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=at(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=this.#s.style;for(let i=0;i<t.length;i++){let n=t[i];n.startsWith("--color-")&&this.#t.style.setProperty(n,t.getPropertyValue(n))}let e=getComputedStyle(this.#s);for(let i=0;i<10;i++){let n=e.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,O=d?`var(--color-${d}, var(--chart-${m}))`:`var(--chart-${m})`;if(f==null&&p==null)continue;let g=f!=null?this.#O(String(f)):"",y=p!=null?`<span data-tip-role="pct"> (${p}%)</span>`:"",v=l!=="none"?`<span data-indicator style="--tooltip-indicator-color: ${O}"></span>`:"",S=d?`<span data-tip-role="name">${this.#O(d)}</span>`:"",w=u.hovered?" data-hovered":"";c.push(`<span data-tip-row${w}>${v}${S}<span data-tip-role="value">${g}${y}</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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}};x("tooltip-ui",$n);Q();var LA={new:{variant:"success",text:"New"},updated:{variant:"info",text:"Updated"},deprecated:{variant:"warning",text:"Deprecated"},removed:{variant:"danger",text:"Removed"},beta:{variant:"accent",text:"Beta"}},Cn=class extends k{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=LA[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()}};x("badge-ui",Cn);Q();var En=class extends k{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}};x("breadcrumb-ui",En);Q();var Pn=class s extends k{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;#a=null;#o=!1;#l=new WeakMap;static#c=3;#h=t=>{let e=t.target instanceof Element?t.target.closest('[role="option"]:not([aria-disabled])'):null;if(!e)return;let i=this.#l.get(e);i&&this.#x(i)};#u=t=>{let e=t.target instanceof Element?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.#w(i)};connected(){this.#o||(this.#o=!0,this.addEventListener("keydown",this.#A))}render(){this.#s||(this.#f(),this.innerHTML=`
|
|
158
158
|
<header>
|
|
159
159
|
<icon-ui name="magnifying-glass" slot="icon"></icon-ui>
|
|
160
160
|
<input type="text" placeholder="${this.placeholder}" slot="input" />
|
|
@@ -165,26 +165,26 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
165
165
|
<span data-hint><kbd>\u21B5</kbd> Select</span>
|
|
166
166
|
<span data-hint><kbd>\u238B</kbd> Close</span>
|
|
167
167
|
</footer>
|
|
168
|
-
`,this.#s=this.querySelector("input"),this.#n=this.querySelector('[slot="list"]'),this.#a=this.querySelector("footer"),this.#s.addEventListener("input",this.#
|
|
168
|
+
`,this.#s=this.querySelector("input"),this.#n=this.querySelector('[slot="list"]'),this.#a=this.querySelector("footer"),this.#s.addEventListener("input",this.#k),this.#n.addEventListener("click",this.#h),this.#n.addEventListener("pointerover",this.#u),this.#m()),this.open&&(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#s?.focus()}))}get value(){return this.#s?.value||""}set value(t){if(!this.#s)return;let e=t??"";this.#s.value=e,this.#m(e)}focus(){this.#s?.focus()}setItems(t){this.#t=t,this.#m()}#d(){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}#f(){let t=[];for(let e of this.#d())if(e.tagName==="OPTGROUP"){let i=e.label,n={label:i,items:[]};for(let r of e.querySelectorAll("option"))n.items.push(this.#p(r,i));t.push(n)}else e.tagName==="OPTION"&&t.push(this.#p(e,""));this.#t=t}#p(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}}#m(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.#g(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.#b(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.#b(r,e))continue;this.#n.appendChild(this.#y(r,n)),n++}if(!n){let r=document.createElement("div");r.setAttribute("data-empty",""),r.textContent="No results found.",this.#n.appendChild(r)}n>0&&this.#w(0)}#g(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}#O(t){t&&(this.#e=[t,...this.#e.filter(e=>e!==t)].slice(0,s.#c))}#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=`
|
|
169
169
|
${t.icon?`<icon-ui name="${t.icon}"></icon-ui>`:""}
|
|
170
170
|
<span data-text>${t.label}</span>
|
|
171
171
|
${t.shortcut?`<span data-shortcut>${t.shortcut}</span>`:""}
|
|
172
|
-
`,this.#l.set(i,t),i}#y(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#b(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#k(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#b(parseInt(e[r].dataset.idx))}#v(t){this.#O(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#x(){let t=this.#n.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",r=(this.#l.get(t)||this.#m(e))?.category||"";this.#O(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#S=()=>{this.#p(this.#s.value)};#w=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#k(1);break;case"ArrowUp":t.preventDefault(),this.#k(-1);break;case"Enter":t.preventDefault(),this.#x();break;case"Tab":t.preventDefault(),this.#x();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),this.removeEventListener("keydown",this.#w),this.#s?.removeEventListener("input",this.#S),this.#n?.removeEventListener("click",this.#h),this.#n?.removeEventListener("pointerover",this.#u),this.#s=null,this.#n=null,this.#a=null,this.#o=!1}};x("command-ui",Pn);var Oa=.4;function Gu(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Hu(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 li(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function Ku(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function eb(s,t,e){let{a:i,b:n}=Gu(s,t,e),[r,o,a]=Hu(s,i,n);return[Math.max(0,Math.min(1,li(r))),Math.max(0,Math.min(1,li(o))),Math.max(0,Math.min(1,li(a)))]}function MA(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Qn(s,t,e){let[i,n,r]=eb(s,t,e);return MA(i,n,r)}function RA(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=Ku(parseInt(s.slice(0,2),16)/255),e=Ku(parseInt(s.slice(2,4),16)/255),i=Ku(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 ib(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function ba(s,t,e){let{a:i,b:n}=Gu(s,t,e),[r,o,a]=Hu(s,i,n);if(ib(li(r),li(o),li(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=Gu(s,u,e),[p,m,O]=Hu(s,d,f);ib(li(p),li(m),li(O))?l=u:h=u}return l}var Tn=class s extends Z{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...Z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=null;#O=null;#g=null;#y=null;#b=null;#k=[];#v=null;static template=()=>null;#x=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#T("input")};#S=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#R(t))};#w=t=>{this.#a==="area"&&this.#R(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#T("change"))};#P=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#C(t))};#$=t=>{this.#a==="hue"&&this.#C(t)};#M=()=>{this.#a==="hue"&&(this.#a=null,this.#T("change"))};#Q=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(Oa,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.#T("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.#T("change")};connected(){if(super.connected(),this.#L(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#x),t.appendChild(c),c};this.#g=e("H","hue",0,360,1),this.#y=e("C","chroma",0,Oa,.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.#Z(r,l);return l.addEventListener("click",h),this.#k.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#p=n("oklch"),this.#m=n("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#S),this.#h.addEventListener("pointermove",this.#w),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#P),this.#d.addEventListener("pointermove",this.#$),this.#d.addEventListener("pointerup",this.#M),this.#h.addEventListener("keydown",this.#Q),this.#d.addEventListener("keydown",this.#E),this.#O=new ResizeObserver(()=>this.#I()),this.#O.observe(this.#h)}disconnected(){super.disconnected(),this.#v!=null&&(clearTimeout(this.#v),this.#v=null),this.#O&&(this.#O.disconnect(),this.#O=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#S),this.#h.removeEventListener("pointermove",this.#w),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#Q)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#P),this.#d.removeEventListener("pointermove",this.#$),this.#d.removeEventListener("pointerup",this.#M),this.#d.removeEventListener("keydown",this.#E)),this.#g?.removeEventListener("input",this.#x),this.#y?.removeEventListener("input",this.#x),this.#b?.removeEventListener("input",this.#x);for(let{el:t,handler:e}of this.#k)t.removeEventListener("click",e);this.#k=[],this.#r=!1}#R(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*Oa,this.#e=1-n,this.#T("input")}#C(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#T("input")}#L(t){if(t){if(t.startsWith("#")){let e=RA(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-picker-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#T(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=ba(this.#e,this.#i,this.#s),n=Qn(this.#e,i,this.#s),r=this.#D();this.#o=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#D(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#Z(t,e){let i=t==="oklch"?this.#D():Qn(this.#e,ba(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#v!=null&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#I(){if(!this.#l||!this.#c||!this.#h)return;let t=Math.min(window.devicePixelRatio||1,2)*.5,e=Math.round(this.#h.clientWidth*t),i=Math.round(this.#h.clientHeight*t);if(e<=0||i<=0)return;this.#l.width=e,this.#l.height=i;let n=this.#c.createImageData(e,i),r=n.data,o=this.#s;for(let a=0;a<i;a++){let l=1-a/(i-1);for(let h=0;h<e;h++){let c=h/(e-1)*Oa,u=ba(l,c,o),[d,f,p]=eb(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#c.putImageData(n,0,0)}render(){if(this.#o?this.#o=!1:this.#L(this.value),this.#I(),this.#u){let r=this.#i/Oa*100,o=(1-this.#e)*100;this.#u.style.left=`${r}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Qn(this.#e,ba(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(Qn(.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=Qn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#D());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=Qn(this.#e,ba(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#D()),this.#m&&(this.#m.textContent=n)}onFormReset(){this.value="#3b82f6"}};x("color-picker-ui",Tn);var Ln=class extends Z{static get properties(){return{...Z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",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;#a=null;connected(){this.#o(),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}#o(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-picker-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-picker-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#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),this.#a=new MutationObserver(t),this.#a.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.#a?.disconnect(),this.#a=null,this.#r=!1}};x("color-input-ui",Ln);Q();var Ju=0,Mn=class extends k{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#a=!1;#o=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++Ju}`,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-${++Ju}`,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),this.#s=new ResizeObserver(()=>this.#h()),this.#n=new MutationObserver(()=>{this.#x(),this.#h()}),this.#s.observe(this),this.#u();for(let t of this.#m())this.#s.observe(t);this.#x(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#c?.(),this.#s?.disconnect(),this.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#S(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#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.#w();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.#o&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#u()}#p(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#O(t,e){let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),r=this.offsetWidth&&n.width?n.width/this.offsetWidth:1,o=(i.left-n.left)/r,a=(i.top-n.top)/r,l=i.width/r,h=i.height/r;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#g(t,e,i,n){switch(this.curve){case"step":return this.#k(t,e);case"straight":return this.#v(t,e);default:return this.#y(t,e,i,n)}}#y(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#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}}}#k(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#v(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#x(){this.#d(),this.#S();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#P(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#w(),this.#u()}#S(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#w(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#O(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#A(t,e){return t._noodleId||(t._noodleId=`_n${++Ju}`),`${t._noodleId}:${e}`}#P=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#O(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#g(r,{x:c,y:u},i,this.#$(r,{x:c,y:u})),this.#h(),this.#M(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.#Q(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#E(),this.#o=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#o=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#E(),this.#l=null,this.#c=null},this.#o={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#$(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"}#M(t,e,i){this.#E();let n=this.#Q(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#Q(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#m().find(O=>O._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#E(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};x("noodles-ui",Mn);var Di={};function be(s,t){Di[s]=t}function Rn(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 td={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()};be("text",{render(s,t,e){Rn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),be("number",{render(s,t,e){Rn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),be("currency",{render(s,t,e,i){Rn(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"}),be("percent",{render(s,t,e){Rn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var sb={year:"numeric",month:"short",day:"numeric"};be("date",{render(s,t,e){Rn(e,s?new Intl.DateTimeFormat("en-US",sb).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",sb).format(new Date(s)):""},align:"left",sortFn:"datetime"});var nb={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};be("datetime",{render(s,t,e){Rn(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"}),be("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"}),be("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let r=i?.variants||{};n.setAttribute("variant",r[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),be("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"}),be("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--a-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),be("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),be("actions",{render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});Q();function IA(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 hi(s,t){return typeof t.accessor=="function"?t.accessor(s):IA(s,t.key)}function _l(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
173
|
-
`)?'"'+t.replace(/"/g,'""')+'"':t}var In=class extends k{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},density:{type:String,default:"standard",reflect:!0},paginate:{type:Number,default:0,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#u=-1;#d=null;#f=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#y()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#a=0,this.#y()}get data(){return this.#e}get selected(){return[...this.#o].sort((t,e)=>t-e)}set selected(t){if(this.#o.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#o.add(e);this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#a=0,this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#a=0,this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#y()}get expanded(){return[...this.#n]}expandRenderer=null;getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#a,density:this.density}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#a=t.page),t.density&&(this.density=t.density),this.#y()}}#p(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#m(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#O(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#m(),this.#h||(this.#h=!0,this.addEventListener("click",this.#L),this.addEventListener("keydown",this.#V),this.addEventListener("pointerdown",this.#C))}disconnected(){this.removeEventListener("click",this.#L),this.removeEventListener("keydown",this.#V),this.removeEventListener("pointerdown",this.#C),this.#h=!1,this.#q(),this.#g&&(cancelAnimationFrame(this.#g),this.#g=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}#O(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l)),e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#g=null;#y(){!this.isConnected||this.#g||(this.#g=requestAnimationFrame(()=>{this.#g=null,this.render(),this.#p()}))}get#b(){return this.#t.filter(t=>!t.hidden)}#k(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#b)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#v(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#b.some(r=>{let o=hi(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=hi(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=hi(this.#e[e],o||{key:n}),l=hi(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Di[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=td[d]||td.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#x(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#S(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#v().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#b;this.style.gridTemplateColumns=this.#k();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#w(e,t),this.#R();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let n=this.#v(),r=this.#x(n),o=[];for(let c of r){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#A(c,t);if(u&&this.#P(u,c,t),this.expandable&&(this.#n.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#n.has(c)){let f=i.querySelector(`:scope > [data-detail-row][data-for="${c}"]`);if(!f&&(f=document.createElement("div"),f.setAttribute("data-detail-row",""),f.dataset.for=c,this.expandRenderer)){let p=this.expandRenderer(this.#e[c],c);p instanceof Node?f.appendChild(p):f.textContent=String(p)}o.push(f)}}let a=[...i.children];for(let c of a)o.includes(c)||c.remove();for(let c=0;c<o.length;c++)i.children[c]!==o[c]&&(i.children[c]?i.insertBefore(o[c],i.children[c]):i.appendChild(o[c]));this.#$(i),this.#M(i,n,t);let l=this.paginate>0&&this.#e.length>0,h=this.querySelector(":scope > [data-footer]");l?(h||(h=document.createElement("div"),h.setAttribute("data-footer",""),this.appendChild(h)),this.#Q(h,n.length)):h&&h.remove()}#w(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,n=[];if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#E(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}for(;t.children.length>n.length;)t.lastChild.remove();for(let r=0;r<n.length;r++)t.children[r]?t.replaceChild(n[r],t.children[r]):t.appendChild(n[r])}#A(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#P(i,t,e),i}#P(t,e,i){let n=this.#e[e],r=this.#o.has(e);t.dataset.index=e,r?(t.setAttribute("data-selected",""),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.removeAttribute("aria-selected"));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col","");let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=hi(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);u instanceof Node?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Di[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Di[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}for(;t.children.length>o.length;)t.lastChild.remove();for(let a=0;a<o.length;a++)t.children[a]?t.replaceChild(o[a],t.children[a]):t.appendChild(o[a])}#$(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.#b,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#M(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=hi(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=Di[a.type||"text"];typeof c=="number"&&u?.render?u.render(c,{},l,a.meta):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}for(;r.children.length>o.length;)r.lastChild.remove();for(let a=0;a<o.length;a++)r.children[a]?r.replaceChild(o[a],r.children[a]):r.appendChild(o[a])}#Q(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",r=>{this.#a=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))}),t.appendChild(i));let n=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#a+1)),i.setAttribute("total",String(n))}#E(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=hi(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}#R(){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)}#C=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#D(t,e))};#L=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#d=this.#d===c?null:c,this.#y();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#y());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-resize-handle]");if(r&&this.contains(r)){this.#D(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#o.add(u);else this.#o.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#u>=0){let f=Math.min(this.#u,u),p=Math.max(this.#u,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#u=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(O=>O.key===d),m=p?hi(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}}))}}};#T=null;#D(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#T={key:i,col:n,startX:a,startWidth:o},document.addEventListener("pointermove",this.#Z),document.addEventListener("pointerup",this.#I)}#Z=t=>{if(!this.#T)return;let{key:e,col:i,startX:n,startWidth:r}=this.#T,o=t.clientX-n,a=r+o,l=i.minWidth||48,h=i.maxWidth||1/0;a=Math.max(l,Math.min(h,a)),this.#l.set(e,Math.round(a)),this.style.gridTemplateColumns=this.#k()};#I=t=>{if(!this.#T)return;let{key:e}=this.#T;document.removeEventListener("pointermove",this.#Z),document.removeEventListener("pointerup",this.#I),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#T=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#q(){document.removeEventListener("pointermove",this.#Z),document.removeEventListener("pointerup",this.#I),this.#T=null}#V=t=>{let i=this.#b.length+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.children.length:0;this.#c||(this.#c={row:0,col:0});let{row:o,col:a}=this.#c,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#c={row:o,col:a},this.#N())};#N(){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.#b,i=this.#v(),n=e.map(c=>_l(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=hi(u,d);if(typeof d.format=="function")return _l(d.format(f,u));let p=Di[d.type||"text"];return p?.format?_l(p.format(f,u,d.meta)):_l(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
|
|
174
|
-
`),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)}};x("table-ui",In);Q();var DA=200;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 id(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}var XA=50,rb=500;function ob(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 ZA(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 qA(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(ZA(s?.key))return"text";let e=[],i=Math.min(t?.length??0,rb),n=new Set;for(let r=0;r<i;r++){let o=ob(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>XA))return"text"}return e.length?"select":"text"}function NA(s,t){let e=new Set,i=Math.min(t?.length??0,rb);for(let n=0;n<i;n++){let r=ob(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var Dn=class s extends k{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){this.setAttribute("role","toolbar"),this.#a(),this.#h(),this.#o(),this.#O()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#y(),this.#c()}render(){this.#o(),this.#O(),this.#f()}#a(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#o(){let t=this.#l();if(t===this.#t||(this.#c(),!t))return;this.#t=t;let e=()=>this.#w(),i=()=>this.#x();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#l(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#c(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#h(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-title","");let i=document.createElement("span");i.setAttribute("data-heading",""),e.appendChild(i);let n=document.createElement("badge-ui");n.setAttribute("data-count-badge",""),n.setAttribute("size","sm"),n.setAttribute("variant","muted"),n.hidden=!0,e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-controls",""),r.appendChild(this.#d("filter","Filter","funnel-simple")),r.appendChild(this.#d("sort","Sort","arrows-down-up")),r.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("size","sm"),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(DA)),o.addEventListener("search",this.#m);let a=document.createElement("div");a.setAttribute("data-actions","");for(let l of[...this.children])l!==t&&l.getAttribute?.("slot")==="actions"&&a.appendChild(l);t.appendChild(e),t.appendChild(r),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#f(),this.#p()}#u(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#d(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("size","sm"),n.setAttribute("aria-haspopup","menu"),n.addEventListener("click",r=>{r.stopPropagation(),this.#g(t,n)}),n}#f(){let t=this.querySelector(":scope [data-heading]");if(!t)return;this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0;let e=this.querySelector(":scope [data-count-badge]");if(!e)return;let i=this.count?.toString().trim(),n=this.#t?.data?.length,r=i||(Number.isFinite(n)?String(n):"");r?(e.setAttribute("text",r),e.hidden=!1):e.hidden=!0}#p(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,n)=>{let r=t.querySelector(i);r&&(r.hidden=n)};e('[data-toolbar-btn="filter"]',this.noFilter),e('[data-toolbar-btn="sort"]',this.noSort),e('[data-toolbar-btn="columns"]',this.noColumns),e("[data-search]",this.noSearch)}attributeChanged(t){["no-filter","no-sort","no-columns","no-search"].includes(t)&&this.#p(),t==="placeholder"&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}#m=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#O(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#f()}#g(t,e){if(this.#i?.kind===t){this.#y();return}this.#y();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#v(i),t==="sort"&&this.#S(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=at(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.#b,!0),document.addEventListener("keydown",this.#k,!0))}))}#y(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#b,!0),document.removeEventListener("keydown",this.#k,!0))}}#b=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#y())};#k=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(ed("No filterable columns"));return}let i=e.filters||{};t.appendChild(id("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",o.label||o.key);let l=qA(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=NA(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";d?e.setFilter(o.key,d,"select"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;u?e.setFilter(o.key,u,"contains"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#u("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#x()});t.appendChild(o)}}#x(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#S(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(ed("No sortable columns"));return}t.appendChild(id("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",o.label||o.key),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#w()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#u("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#w()});t.appendChild(o)}}#w(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#S(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(ed("No columns"));return}t.appendChild(id("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",n.label||n.key);let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.columns=a,this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};x("table-toolbar-ui",Dn);Q();var Xn=class extends k{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","")}},Zn=class extends k{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}connected(){this.querySelector(':scope > [slot="label"]')||(this.innerHTML=`
|
|
172
|
+
`,this.#l.set(i,t),i}#b(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#w(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#v(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#w(parseInt(e[r].dataset.idx))}#x(t){this.#O(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#S(){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.#g(e))?.category||"";this.#O(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#k=()=>{this.#m(this.#s.value)};#A=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#v(1);break;case"ArrowUp":t.preventDefault(),this.#v(-1);break;case"Enter":t.preventDefault(),this.#S();break;case"Tab":t.preventDefault(),this.#S();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.#A),this.#s?.removeEventListener("input",this.#k),this.#n?.removeEventListener("click",this.#h),this.#n?.removeEventListener("pointerover",this.#u),this.#s=null,this.#n=null,this.#a=null,this.#o=!1}};x("command-ui",Pn);var Oa=.4;function Gu(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function Hu(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 li(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function Ku(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function eb(s,t,e){let{a:i,b:n}=Gu(s,t,e),[r,o,a]=Hu(s,i,n);return[Math.max(0,Math.min(1,li(r))),Math.max(0,Math.min(1,li(o))),Math.max(0,Math.min(1,li(a)))]}function MA(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Qn(s,t,e){let[i,n,r]=eb(s,t,e);return MA(i,n,r)}function RA(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=Ku(parseInt(s.slice(0,2),16)/255),e=Ku(parseInt(s.slice(2,4),16)/255),i=Ku(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 ib(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function ba(s,t,e){let{a:i,b:n}=Gu(s,t,e),[r,o,a]=Hu(s,i,n);if(ib(li(r),li(o),li(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=Gu(s,u,e),[p,m,O]=Hu(s,d,f);ib(li(p),li(m),li(O))?l=u:h=u}return l}var Tn=class s extends Z{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...Z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=null;#g=null;#O=null;#y=null;#b=null;#w=[];#v=null;static template=()=>null;#x=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#Q("input")};#S=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#R(t))};#k=t=>{this.#a==="area"&&this.#R(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#Q("change"))};#$=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#P(t))};#T=t=>{this.#a==="hue"&&this.#P(t)};#M=()=>{this.#a==="hue"&&(this.#a=null,this.#Q("change"))};#C=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(Oa,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.#Q("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.#Q("change")};connected(){if(super.connected(),this.#L(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#x),t.appendChild(c),c};this.#O=e("H","hue",0,360,1),this.#y=e("C","chroma",0,Oa,.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.#Z(r,l);return l.addEventListener("click",h),this.#w.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.#S),this.#h.addEventListener("pointermove",this.#k),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#$),this.#d.addEventListener("pointermove",this.#T),this.#d.addEventListener("pointerup",this.#M),this.#h.addEventListener("keydown",this.#C),this.#d.addEventListener("keydown",this.#E),this.#g=new ResizeObserver(()=>this.#D()),this.#g.observe(this.#h)}disconnected(){super.disconnected(),this.#v!=null&&(clearTimeout(this.#v),this.#v=null),this.#g&&(this.#g.disconnect(),this.#g=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#S),this.#h.removeEventListener("pointermove",this.#k),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#C)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#$),this.#d.removeEventListener("pointermove",this.#T),this.#d.removeEventListener("pointerup",this.#M),this.#d.removeEventListener("keydown",this.#E)),this.#O?.removeEventListener("input",this.#x),this.#y?.removeEventListener("input",this.#x),this.#b?.removeEventListener("input",this.#x);for(let{el:t,handler:e}of this.#w)t.removeEventListener("click",e);this.#w=[],this.#r=!1}#R(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*Oa,this.#e=1-n,this.#Q("input")}#P(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#Q("input")}#L(t){if(t){if(t.startsWith("#")){let e=RA(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-picker-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#Q(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=ba(this.#e,this.#i,this.#s),n=Qn(this.#e,i,this.#s),r=this.#I();this.#o=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#I(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#Z(t,e){let i=t==="oklch"?this.#I():Qn(this.#e,ba(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#v!=null&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#D(){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)*Oa,u=ba(l,c,o),[d,f,p]=eb(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#c.putImageData(n,0,0)}render(){if(this.#o?this.#o=!1:this.#L(this.value),this.#D(),this.#u){let r=this.#i/Oa*100,o=(1-this.#e)*100;this.#u.style.left=`${r}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Qn(this.#e,ba(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(Qn(.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=Qn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#I());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=Qn(this.#e,ba(this.#e,this.#i,this.#s),this.#s);this.#p&&(this.#p.textContent=this.#I()),this.#m&&(this.#m.textContent=n)}onFormReset(){this.value="#3b82f6"}};x("color-picker-ui",Tn);var Ln=class extends Z{static get properties(){return{...Z.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",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;#a=null;connected(){this.#o(),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}#o(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-picker-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-picker-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#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),this.#a=new MutationObserver(t),this.#a.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.#a?.disconnect(),this.#a=null,this.#r=!1}};x("color-input-ui",Ln);Q();var Ju=0,Mn=class extends k{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#a=!1;#o=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++Ju}`,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-${++Ju}`,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),this.#s=new ResizeObserver(()=>this.#h()),this.#n=new MutationObserver(()=>{this.#x(),this.#h()}),this.#s.observe(this),this.#u();for(let t of this.#m())this.#s.observe(t);this.#x(),this.#h()}render(){this.#t&&(this.color?this.#t.style.setProperty("--noodles-stroke",this.color):this.#t.style.removeProperty("--noodles-stroke"))}disconnected(){this.#c?.(),this.#s?.disconnect(),this.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#S(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#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.#k();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.#o&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#u()}#p(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#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.#w(t,e);case"straight":return this.#v(t,e);default:return this.#y(t,e,i,n)}}#y(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#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}}}#w(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#v(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#x(){this.#d(),this.#S();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#$(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#k(),this.#u()}#S(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#k(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#g(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#A(t,e){return t._noodleId||(t._noodleId=`_n${++Ju}`),`${t._noodleId}:${e}`}#$=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#g(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#O(r,{x:c,y:u},i,this.#T(r,{x:c,y:u})),this.#h(),this.#M(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.#C(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#E(),this.#o=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#o=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#E(),this.#l=null,this.#c=null},this.#o={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#T(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"}#M(t,e,i){this.#E();let n=this.#C(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#C(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#m().find(O=>O._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#E(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};x("noodles-ui",Mn);var Di={};function be(s,t){Di[s]=t}function Rn(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 td={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()};be("text",{render(s,t,e){Rn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),be("number",{render(s,t,e){Rn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),be("currency",{render(s,t,e,i){Rn(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"}),be("percent",{render(s,t,e){Rn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var sb={year:"numeric",month:"short",day:"numeric"};be("date",{render(s,t,e){Rn(e,s?new Intl.DateTimeFormat("en-US",sb).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",sb).format(new Date(s)):""},align:"left",sortFn:"datetime"});var nb={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};be("datetime",{render(s,t,e){Rn(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"}),be("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"}),be("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let r=i?.variants||{};n.setAttribute("variant",r[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),be("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"}),be("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--a-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),be("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),be("actions",{render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});Q();function IA(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 hi(s,t){return typeof t.accessor=="function"?t.accessor(s):IA(s,t.key)}function _l(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
173
|
+
`)?'"'+t.replace(/"/g,'""')+'"':t}var In=class extends k{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},density:{type:String,default:"standard",reflect:!0},paginate:{type:Number,default:0,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#u=-1;#d=null;#f=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#y()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#a=0,this.#y()}get data(){return this.#e}get selected(){return[...this.#o].sort((t,e)=>t-e)}set selected(t){if(this.#o.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#o.add(e);this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#y(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#a=0,this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#a=0,this.#y(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#y()}get expanded(){return[...this.#n]}expandRenderer=null;getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#a,density:this.density}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#a=t.page),t.density&&(this.density=t.density),this.#y()}}#p(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#m(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#g(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#m(),this.#h||(this.#h=!0,this.addEventListener("click",this.#L),this.addEventListener("keydown",this.#V),this.addEventListener("pointerdown",this.#P))}disconnected(){this.removeEventListener("click",this.#L),this.removeEventListener("keydown",this.#V),this.removeEventListener("pointerdown",this.#P),this.#h=!1,this.#q(),this.#O&&(cancelAnimationFrame(this.#O),this.#O=null),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null)}#g(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l)),e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#O=null;#y(){!this.isConnected||this.#O||(this.#O=requestAnimationFrame(()=>{this.#O=null,this.render(),this.#p()}))}get#b(){return this.#t.filter(t=>!t.hidden)}#w(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#b)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#v(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#b.some(r=>{let o=hi(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=hi(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=hi(this.#e[e],o||{key:n}),l=hi(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Di[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=td[d]||td.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#x(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#S(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#v().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#b;this.style.gridTemplateColumns=this.#w();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#k(e,t),this.#R();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let n=this.#v(),r=this.#x(n),o=[];for(let c of r){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#A(c,t);if(u&&this.#$(u,c,t),this.expandable&&(this.#n.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#n.has(c)){let f=i.querySelector(`:scope > [data-detail-row][data-for="${c}"]`);if(!f&&(f=document.createElement("div"),f.setAttribute("data-detail-row",""),f.dataset.for=c,this.expandRenderer)){let p=this.expandRenderer(this.#e[c],c);p instanceof Node?f.appendChild(p):f.textContent=String(p)}o.push(f)}}let a=[...i.children];for(let c of a)o.includes(c)||c.remove();for(let c=0;c<o.length;c++)i.children[c]!==o[c]&&(i.children[c]?i.insertBefore(o[c],i.children[c]):i.appendChild(o[c]));this.#T(i),this.#M(i,n,t);let l=this.paginate>0&&this.#e.length>0,h=this.querySelector(":scope > [data-footer]");l?(h||(h=document.createElement("div"),h.setAttribute("data-footer",""),this.appendChild(h)),this.#C(h,n.length)):h&&h.remove()}#k(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,n=[];if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#E(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}for(;t.children.length>n.length;)t.lastChild.remove();for(let r=0;r<n.length;r++)t.children[r]?t.replaceChild(n[r],t.children[r]):t.appendChild(n[r])}#A(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#$(i,t,e),i}#$(t,e,i){let n=this.#e[e],r=this.#o.has(e);t.dataset.index=e,r?(t.setAttribute("data-selected",""),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.removeAttribute("aria-selected"));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col","");let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=hi(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);u instanceof Node?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Di[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Di[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}for(;t.children.length>o.length;)t.lastChild.remove();for(let a=0;a<o.length;a++)t.children[a]?t.replaceChild(o[a],t.children[a]):t.appendChild(o[a])}#T(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.#b,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#M(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=hi(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=Di[a.type||"text"];typeof c=="number"&&u?.render?u.render(c,{},l,a.meta):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}for(;r.children.length>o.length;)r.lastChild.remove();for(let a=0;a<o.length;a++)r.children[a]?r.replaceChild(o[a],r.children[a]):r.appendChild(o[a])}#C(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",r=>{this.#a=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))}),t.appendChild(i));let n=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#a+1)),i.setAttribute("total",String(n))}#E(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=hi(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}#R(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:n,value:r}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=n==="select"?`${r.split(",").length} selected`:r;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#P=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#I(t,e))};#L=t=>{let e=t.target,i=e.closest("[data-filter-btn]");if(i&&this.contains(i)){let c=i.dataset.filterKey;this.#d=this.#d===c?null:c,this.#y();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#y());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-resize-handle]");if(r&&this.contains(r)){this.#I(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#o.add(u);else this.#o.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#u>=0){let f=Math.min(this.#u,u),p=Math.max(this.#u,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#u=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(O=>O.key===d),m=p?hi(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}}))}}};#Q=null;#I(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#Q={key:i,col:n,startX:a,startWidth:o},document.addEventListener("pointermove",this.#Z),document.addEventListener("pointerup",this.#D)}#Z=t=>{if(!this.#Q)return;let{key:e,col:i,startX:n,startWidth:r}=this.#Q,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.#w()};#D=t=>{if(!this.#Q)return;let{key:e}=this.#Q;document.removeEventListener("pointermove",this.#Z),document.removeEventListener("pointerup",this.#D),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#Q=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#q(){document.removeEventListener("pointermove",this.#Z),document.removeEventListener("pointerup",this.#D),this.#Q=null}#V=t=>{let i=this.#b.length+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.children.length:0;this.#c||(this.#c={row:0,col:0});let{row:o,col:a}=this.#c,l=!0;switch(t.key){case"ArrowDown":o=Math.min(o+1,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#c={row:o,col:a},this.#N())};#N(){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.#b,i=this.#v(),n=e.map(c=>_l(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=hi(u,d);if(typeof d.format=="function")return _l(d.format(f,u));let p=Di[d.type||"text"];return p?.format?_l(p.format(f,u,d.meta)):_l(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
|
|
174
|
+
`),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)}};x("table-ui",In);Q();var DA=200;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 id(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}var XA=50,rb=500;function ob(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 ZA(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 qA(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(ZA(s?.key))return"text";let e=[],i=Math.min(t?.length??0,rb),n=new Set;for(let r=0;r<i;r++){let o=ob(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>XA))return"text"}return e.length?"select":"text"}function NA(s,t){let e=new Set,i=Math.min(t?.length??0,rb);for(let n=0;n<i;n++){let r=ob(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var Dn=class s extends k{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){this.setAttribute("role","toolbar"),this.#a(),this.#h(),this.#o(),this.#g()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#y(),this.#c()}render(){this.#o(),this.#g(),this.#f()}#a(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#o(){let t=this.#l();if(t===this.#t||(this.#c(),!t))return;this.#t=t;let e=()=>this.#k(),i=()=>this.#x();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#l(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#c(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#h(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-title","");let i=document.createElement("span");i.setAttribute("data-heading",""),e.appendChild(i);let n=document.createElement("badge-ui");n.setAttribute("data-count-badge",""),n.setAttribute("size","sm"),n.setAttribute("variant","muted"),n.hidden=!0,e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-controls",""),r.appendChild(this.#d("filter","Filter","funnel-simple")),r.appendChild(this.#d("sort","Sort","arrows-down-up")),r.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("size","sm"),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(DA)),o.addEventListener("search",this.#m);let a=document.createElement("div");a.setAttribute("data-actions","");for(let l of[...this.children])l!==t&&l.getAttribute?.("slot")==="actions"&&a.appendChild(l);t.appendChild(e),t.appendChild(r),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#f(),this.#p()}#u(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#d(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("size","sm"),n.setAttribute("aria-haspopup","menu"),n.addEventListener("click",r=>{r.stopPropagation(),this.#O(t,n)}),n}#f(){let t=this.querySelector(":scope [data-heading]");if(!t)return;this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0;let e=this.querySelector(":scope [data-count-badge]");if(!e)return;let i=this.count?.toString().trim(),n=this.#t?.data?.length,r=i||(Number.isFinite(n)?String(n):"");r?(e.setAttribute("text",r),e.hidden=!1):e.hidden=!0}#p(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,n)=>{let r=t.querySelector(i);r&&(r.hidden=n)};e('[data-toolbar-btn="filter"]',this.noFilter),e('[data-toolbar-btn="sort"]',this.noSort),e('[data-toolbar-btn="columns"]',this.noColumns),e("[data-search]",this.noSearch)}attributeChanged(t){["no-filter","no-sort","no-columns","no-search"].includes(t)&&this.#p(),t==="placeholder"&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}#m=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#g(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#f()}#O(t,e){if(this.#i?.kind===t){this.#y();return}this.#y();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#v(i),t==="sort"&&this.#S(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=at(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.#b,!0),document.addEventListener("keydown",this.#w,!0))}))}#y(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#b,!0),document.removeEventListener("keydown",this.#w,!0))}}#b=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#y())};#w=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(ed("No filterable columns"));return}let i=e.filters||{};t.appendChild(id("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",o.label||o.key);let l=qA(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=NA(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";d?e.setFilter(o.key,d,"select"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;u?e.setFilter(o.key,u,"contains"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#u("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#x()});t.appendChild(o)}}#x(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#S(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(ed("No sortable columns"));return}t.appendChild(id("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",o.label||o.key),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#k()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#u("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#k()});t.appendChild(o)}}#k(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#S(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(ed("No columns"));return}t.appendChild(id("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",n.label||n.key);let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.columns=a,this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};x("table-toolbar-ui",Dn);Q();var Xn=class extends k{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","")}},Zn=class extends k{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}connected(){this.querySelector(':scope > [slot="label"]')||(this.innerHTML=`
|
|
175
175
|
<span slot="label"></span>
|
|
176
176
|
<span slot="description"></span>
|
|
177
177
|
<span slot="time"></span>
|
|
178
178
|
`)}render(){let t=this.querySelector(':scope > [slot="label"]'),e=this.querySelector(':scope > [slot="description"]'),i=this.querySelector(':scope > [slot="time"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),i&&(i.textContent=this.duration||this.time),this.icon){let r=this.querySelector(':scope > [slot="icon"]');r||(r=document.createElement("icon-ui"),r.setAttribute("slot","icon"),this.prepend(r)),r.setAttribute("name",this.icon)}else this.querySelector(':scope > [slot="icon"]')?.remove();let n=this.querySelector(':scope > [slot="outcomes"]');if(this.#t.length>0){n||(n=document.createElement("ul"),n.setAttribute("slot","outcomes"),this.appendChild(n)),n.innerHTML="";for(let a of this.#t){let l=document.createElement("li");l.textContent=a,n.appendChild(l)}n.hidden=!this.#e;let r=this.querySelector(":scope > [data-timeline-toggle]");r||(r=document.createElement("button"),r.type="button",r.setAttribute("data-timeline-toggle",""),r.setAttribute("aria-label","Toggle details"),r.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(r)),r.innerHTML="";let o=document.createElement("icon-ui");o.setAttribute("name",this.#e?"caret-down":"caret-right"),o.setAttribute("color","muted"),o.setAttribute("size","sm"),r.appendChild(o)}else this.querySelector(":scope > [data-timeline-toggle]")?.remove(),n?.remove()}};x("timeline-ui",Xn),x("timeline-item-ui",Zn);Q();var qn=class extends k{static properties={step:{type:Number,default:0,reflect:!0},orientation:{type:String,default:"horizontal",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll("stepper-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];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")})}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))}},Nn=class extends k{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}};static template=()=>null;connected(){this.querySelector('[slot="label"]')||(this.innerHTML=`
|
|
179
179
|
<span slot="label"></span>
|
|
180
180
|
<span slot="description"></span>
|
|
181
|
-
`)}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),this.icon){let i=this.querySelector('[slot="icon"]');i||(i=document.createElement("icon-ui"),i.setAttribute("slot","icon"),this.prepend(i)),i.setAttribute("name",this.icon)}else this.querySelector('[slot="icon"]')?.remove()}};x("stepper-ui",qn),x("stepper-item-ui",Nn);Q();var Bn=class extends k{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;#a=!1;#o=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.#
|
|
181
|
+
`)}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),this.icon){let i=this.querySelector('[slot="icon"]');i||(i=document.createElement("icon-ui"),i.setAttribute("slot","icon"),this.prepend(i)),i.setAttribute("name",this.icon)}else this.querySelector('[slot="icon"]')?.remove()}};x("stepper-ui",qn),x("stepper-item-ui",Nn);Q();var Bn=class extends k{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;#a=!1;#o=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.#x),this.addEventListener("pointerleave",this.#S),this.addEventListener("focusin",this.#k),this.addEventListener("focusout",this.#A)),this.addEventListener("keydown",this.#$),this.#t.addEventListener("pointerdown",this.#M),this.#t.addEventListener("pointermove",this.#C),this.#t.addEventListener("pointerup",this.#E),this.#t.addEventListener("pointercancel",this.#E),this.#t.addEventListener("click",this.#R,!0),this.#t.addEventListener("dragstart",this.#P)),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.#x),this.removeEventListener("pointerleave",this.#S),this.removeEventListener("focusin",this.#k),this.removeEventListener("focusout",this.#A),this.removeEventListener("keydown",this.#$),this.#t&&(this.#t.removeEventListener("pointerdown",this.#M),this.#t.removeEventListener("pointermove",this.#C),this.#t.removeEventListener("pointerup",this.#E),this.#t.removeEventListener("pointercancel",this.#E),this.#t.removeEventListener("click",this.#R,!0),this.#t.removeEventListener("dragstart",this.#P)),this.#o=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(),!window.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.#v(),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.#a||(this.#a=!0,this.chrome==="toolbar"?this.#y():this.#O(),this.#w(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#w()),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)}#y(){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}`}#w(){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");n.setAttribute("role","tab"),n.setAttribute("aria-label",`Page ${i+1}`),n.addEventListener("click",()=>this.goTo(this.#p(i))),t.appendChild(n)}}this.#v()}#v(){if(!this.#a)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()}#x=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#S=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#k=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#A=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#$=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#T=5;#M=t=>{t.pointerType!=="touch"&&t.button===0&&(t.target.closest("button, button-ui, a, input, select, textarea")||(this.#o={pointerId:t.pointerId,startX:t.clientX,startScrollLeft:this.#t.scrollLeft,hasMoved:!1},this.#t.style.scrollBehavior="auto",this.#t.setAttribute("data-dragging","")))};#C=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#T){if(!this.#o.hasMoved){this.#o.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#o.startScrollLeft-e,t.preventDefault()}};#E=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=this.#o.hasMoved;if(e)try{this.#t.releasePointerCapture(t.pointerId)}catch{}this.#o=null,this.#t.style.scrollBehavior="",this.#t.removeAttribute("data-dragging"),e&&(this.#t.setAttribute("data-just-dragged",""),requestAnimationFrame(()=>this.#t?.removeAttribute("data-just-dragged")))};#R=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#P=t=>{this.#o&&t.preventDefault()}};x("swiper-ui",Bn);var zn=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,label:{type:String,default:"",reflect:!0},accept:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;connected(){super.connected(),this.querySelector("[data-dropzone]")||(this.innerHTML=`
|
|
182
182
|
<div data-dropzone tabindex="0" role="button">Drop files here or click to browse</div>
|
|
183
183
|
<span hint="${this.hint||""}"></span>
|
|
184
184
|
<div data-filelist></div>
|
|
185
|
-
`),this.#e=this.querySelector("[data-dropzone]"),this.#e&&(this.#e.addEventListener("click",this.#i),this.#e.addEventListener("keydown",this.#s),this.#e.addEventListener("dragover",this.#o),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#c))}render(){let t=this.querySelector("[data-filelist]");if(!this.#e||!t)return;let e=this.querySelector("span[hint]");e&&this.hint&&e.setAttribute("hint",this.hint),t.innerHTML="";for(let i of this.#t){let n=document.createElement("span");n.textContent=i.name,t.appendChild(n)}}get files(){return this.#t}#i=()=>{this.disabled||this.#n()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#n())};async#n(){try{if(window.showOpenFilePicker){let t=this.#a(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let n=await Promise.all(i.map(r=>r.getFile()));if(!this.isConnected)return;this.#h(n)}else this.#r()}catch(t){if(t.name!=="AbortError")throw t}}#r(){let t=document.createElement("input");t.type="file",this.accept&&(t.accept=this.accept),this.multiple&&(t.multiple=!0),t.style.display="none",document.body.appendChild(t),t.addEventListener("change",()=>{t.files?.length&&this.#h([...t.files]),t.remove()},{once:!0}),t.addEventListener("cancel",()=>t.remove(),{once:!0}),t.click()}#a(){if(!this.accept)return[];let t={};for(let e of this.accept.split(",")){let i=e.trim();i&&(i.startsWith(".")?(t["application/octet-stream"]=t["application/octet-stream"]||[],t["application/octet-stream"].push(i)):t[i]=t[i]||[])}return Object.keys(t).length?[{accept:t}]:[]}#o=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#c=t=>{if(t.preventDefault(),this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover"),this.disabled)return;let e=t.dataTransfer;e?.files?.length&&this.#h([...e.files])};#h(t){this.#t=t;let e=new FormData;for(let i of this.#t)e.append(this.name||"file",i);this.internals.setFormValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,files:this.files}})),this.render()}disconnected(){super.disconnected(),this.#e&&(this.#e.removeEventListener("click",this.#i),this.#e.removeEventListener("keydown",this.#s),this.#e.removeEventListener("dragover",this.#o),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#c)),this.#e=null}};x("upload-ui",zn);_u();var Vn=YO({name:"draggable",category:"motion-positioning",description:"Pointer drag to reposition",attributes:["data-draggable-dragging"],events:["drag-end"],config:[],setup({host:s}){let t=!1,e=0,i=0,n=0,r=0;function o(){return s.hasAttribute("disabled")}function a(c){if(o())return;t=!0,e=c.clientX,i=c.clientY;let u=getComputedStyle(s),d=u.translate;if(d&&d!=="none"){let f=d.split(/\s+/).map(parseFloat);n=f[0]||0,r=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);n=f.m41,r=f.m42}s.setPointerCapture(c.pointerId),s.setAttribute("data-draggable-dragging",""),s.style.touchAction="none"}function l(c){if(!t)return;let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.style.translate=`${f}px ${p}px`}function h(c){if(!t)return;t=!1,s.removeAttribute("data-draggable-dragging");let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.dispatchEvent(new CustomEvent("drag-end",{bubbles:!0,detail:{x:f,y:p}}))}return s.addEventListener("pointerdown",a),s.addEventListener("pointermove",l),s.addEventListener("pointerup",h),()=>{s.removeEventListener("pointerdown",a),s.removeEventListener("pointermove",l),s.removeEventListener("pointerup",h),s.removeAttribute("data-draggable-dragging"),s.style.touchAction=""}}});Q();var jn=class extends k{static properties={variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"",reflect:!0},elevation:{type:Number,default:1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Vn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Vn),this.#t=!0)}};x("card-ui",jn);Q();var _n=class extends k{static properties={src:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},shape:{type:String,default:"circle",reflect:!0}};get displayName(){return this.text}static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","img")}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#t||(this.#t=document.createElement("img"),this.#t.setAttribute("slot","img"),this.#t.onerror=()=>{this.#t.remove(),this.#t=null,this.#s()}),this.#t.src=this.src,this.#t.alt=this.displayName||"",this.#t.parentElement||this.appendChild(this.#t),this.#e&&(this.#e.remove(),this.#e=null)):this.icon?(this.#t&&(this.#t.remove(),this.#t=null),this.#e&&(this.#e.remove(),this.#e=null),this.#i||(this.#i=document.createElement("icon-ui"),this.#i.setAttribute("slot","icon"),this.appendChild(this.#i)),this.#i.setAttribute("name",this.icon)):(this.#t&&(this.#t.remove(),this.#t=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#s(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","initials"),this.appendChild(this.#e)),this.#e.textContent=t}},Wn=class extends k{static properties={max:{type:Number,default:5,reflect:!0},size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Avatar group")}render(){let t=[...this.querySelectorAll("avatar-ui")],e=this.max,i=t.length-e;if(this.size)for(let r of t)r.setAttribute("size",this.size);t.forEach((r,o)=>{r.style.display=o<e?"":"none",r.style.zIndex=String(t.length-o)});let n=this.querySelector('[slot="overflow"]');i>0?(n||(n=document.createElement("span"),n.setAttribute("slot","overflow"),this.appendChild(n)),n.textContent=`+${i}`,n.setAttribute("aria-label",`${i} more`),n.style.zIndex="0"):n&&n.remove()}};x("avatar-ui",_n),x("avatar-group-ui",Wn);Q();var Yn=class extends k{static properties={value:{type:Number,default:null,reflect:!0},variant:{type:String,default:"bar",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.variant==="bar"&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","track"),this.#e=document.createElement("div"),this.#e.setAttribute("slot","fill"),this.#t.appendChild(this.#e),this.appendChild(this.#t))}render(){let t=this.value==null||this.value<0,e=Math.max(0,Math.min(100,this.value));this.setAttribute("aria-busy",String(t)),t?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",String(e)),this.#e&&(this.#e.style.width=t?"100%":`${e}%`)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null}};x("progress-ui",Yn);Q();var Fn=class extends k{static properties={value:{type:Number,default:0,reflect:!0},total:{type:Number,default:0,reflect:!0},caption:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),!this.querySelector(':scope > [slot="caption"]')&&!this.querySelector(':scope > [slot="track"]')?(this.#t=document.createElement("span"),this.#t.setAttribute("slot","caption"),this.appendChild(this.#t),this.#e=document.createElement("div"),this.#e.setAttribute("slot","track"),this.appendChild(this.#e)):(this.#t=this.querySelector(':scope > [slot="caption"]'),this.#e=this.querySelector(':scope > [slot="track"]'))}render(){let t=Math.max(0,this.total|0),e=Math.max(0,Math.min(t,this.value|0));if(this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(e)),this.#t&&!this.#t.dataset.custom&&(this.#t.textContent=this.caption||"",this.#t.toggleAttribute("hidden",!this.caption)),this.#e){let i=this.#e.children.length;for(;this.#e.children.length<t;)this.#e.appendChild(document.createElement("span"));for(;this.#e.children.length>t;)this.#e.lastElementChild.remove();for(let n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};x("step-progress-ui",Fn);Q();var Un=class extends k{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},radius:{type:String,default:"sm",reflect:!0},static:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("aria-hidden","true"),this.#t()}render(){this.#t()}#t(){this.style.width=this.width,this.style.height=this.height}};x("skeleton-ui",Un);Q();var Gn=class extends k{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())}};x("spinner-ui",Gn);Q();var Hn=class extends k{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let n=!!t.get.call(this);e.call(this,i),!!i!==n&&this.#s(!!i)},configurable:!0})}}connected(){this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.setAttribute("aria-label",this.label||"Loading"),this.#t=this.parentElement,this.active&&this.#s(!0)}disconnected(){this.#a(),this.#i&&this.#r(),this.#t=null}render(){let t=this.label||"Loading";this.setAttribute("aria-label",t);let e=this.querySelector(":scope > spinner-ui[data-loading-overlay-auto]");e&&e.getAttribute("label")!==t&&e.setAttribute("label",t),this.children.length===0&&this.#o()}#s(t){if(this.#a(),t){let e=Math.max(0,Number(this.delay)||0);e===0?this.#n():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#n()},e)}else this.#i&&this.#r()}#n(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#r(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#a(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#o(){let t=document.createElement("spinner-ui");t.setAttribute("size","lg"),t.setAttribute("tone","subtle"),t.setAttribute("label",this.label||"Loading"),t.setAttribute("data-loading-overlay-auto",""),this.appendChild(t)}};x("loading-overlay-ui",Hn);Q();var ab=new Set;function lb(s,t){ab.has(s)||(ab.add(s),console.warn(`[alert-ui] ${t}`))}var Kn=class s extends k{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"&&(lb("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger, muted, neutral]. Mapping to "danger". Fix the source (LLM prompt / corpus pattern) to emit "danger" directly.'),this.setAttribute("variant","danger")),this.hasAttribute("closeable")&&!this.hasAttribute("closable")&&!this.hasAttribute("dismissible")&&(lb("alias-closeable","attribute [closeable] is a misspelled alias of canonical [closable]. Mapping. Fix the source to use [closable] or [dismissible]."),this.setAttribute("closable",""),this.removeAttribute("closeable")),this.hasAttribute("dismissible")&&!this.hasAttribute("closable")&&this.setAttribute("closable","")}#i=t=>{if(t.target.closest('[slot="close"]')){this.#h();return}if(this.pattern==="dunning"){let e=t.target.closest("[data-dunning-action]");if(e&&this.contains(e)){let i=e.getAttribute("data-dunning-action")||"";this.dispatchEvent(new CustomEvent("dunning-action",{bubbles:!0,composed:!0,detail:{action:i,amount:this.amount,currency:this.currency,dueAt:this.dueAt}}))}}};connected(){this.#e(),this.#c(),(this.icon||this.pattern==="dunning"&&this.reason)&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#i)}disconnected(){this.removeEventListener("press",this.#i)}render(){if(this.pattern==="dunning"){this.#s(),this.#c();return}if(this.icon){let e=this.ensure("leading");e&&e.setAttribute("name",this.icon)}else this.drop("leading");let t=this.ensure("content");if(t){let e=t.hasAttribute("data-alert-auto"),i=t.childNodes.length>0;if(!e&&i){if(this.title||this.description){let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#c()}#s(){let t=this.icon||s.#t[this.reason]||"x-circle",e=this.ensure("leading");e&&e.setAttribute("name",t);let i=this.ensure("content");if(!i)return;i.setAttribute("data-alert-auto","dunning"),i.replaceChildren();let n=this.title||this.#n();if(n){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=n,i.appendChild(l)}let r=this.#r(),o=this.#o();if(r||o){if(i.appendChild(document.createTextNode(" ")),r){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=r,i.appendChild(l)}if(r&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[n,r,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#n(){switch(this.reason){case"expired":return"Card expired";case"insufficient":return"Insufficient funds";case"network":return"Network error";case"declined":return"Payment failed";default:return this.variant==="warning"?"Payment due soon":"Payment failed"}}#r(){if(!this.amount&&this.amount!==0||this.amount===0)return"";try{let t=this.getAttribute("lang")||this.lang||void 0;return new Intl.NumberFormat(t,{style:"currency",currency:this.currency||"USD"}).format(this.amount)}catch{return`${this.currency||""} ${this.amount}`.trim()}}#a(){if(!this.dueAt)return"";let t=/^\d{4}-\d{2}-\d{2}$/.test(this.dueAt)?new Date(`${this.dueAt}T00:00:00`):new Date(this.dueAt);if(Number.isNaN(t.getTime()))return"";try{let e=this.getAttribute("lang")||this.lang||void 0;return new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}).format(t)}catch{return t.toDateString()}}#o(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#a();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#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()}};x("alert-ui",Kn);Q();var BA={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},Jn=class extends k{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||BA[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()}};x("inline-message-ui",Jn);Q();var tr=class extends k{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};x("kbd-ui",tr);Q();var er=class extends k{static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},removable:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={dismiss:'<button slot="dismiss" type="button" aria-label="Remove"><icon-ui name="x" weight="bold"></icon-ui></button>'};static template=()=>null;#t=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#e=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};connected(){this.setAttribute("role","status"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")),this.removable&&!this.disabled){let t=this.ensure("dismiss");t&&t.parentElement!==this&&this.appendChild(t)}else this.drop("dismiss")}};x("tag-ui",er);Q();var zA=new Set(["block","dot","square","line","dashed"]),VA=new Set(["sm","md","lg"]),jA=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),_A={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},WA={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function YA(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&jA.has(t)):[]}var as=null;function FA(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!as){let u=document.createElement("canvas");u.width=1,u.height=1,as=u.getContext("2d")}as.fillStyle="#000",as.clearRect(0,0,1,1),as.fillStyle=s,as.fillRect(0,0,1,1);let[t,e,i]=as.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 ir=class extends k{static properties={shape:{type:String,default:"square",reflect:!0},size:{type:String,default:"md",reflect:!0},color:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},detail:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},copyable:{type:Boolean,default:!1,reflect:!0},copyValue:{type:String,default:""},selectable:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},autoContrast:{type:Boolean,default:!1,reflect:!0},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;connected(){this.#d(),this.#k(),this.#u=new MutationObserver(t=>{let e=!1;for(let i of t){for(let n of i.addedNodes)if(n.nodeType===1){if(n.getAttribute?.("slot")==="chrome"){e=!0;break}if(n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#f(),this.#u.takeRecords())}),this.#u.observe(this,{childList:!0})}render(){this.#d(),this.#p(),this.#m(),this.#g(),this.#y(),this.#b(),this.#O()}#d(){if(this.#r)return;let t=Array.from(this.children).filter(r=>r.getAttribute&&r.getAttribute("slot")==="chrome");for(let r of t)r.remove();let e=Array.from(this.children).filter(r=>r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]'));for(let r of e)r.remove();let i=[];for(let r of Array.from(this.childNodes))(r.nodeType===3&&!r.data||r.nodeType===8)&&i.push(r);for(let r of i)r.remove();let n=Array.from(this.childNodes).filter(r=>!(r.nodeType===1&&r.dataset&&(r.dataset.tile!==void 0||r.dataset.label!==void 0||r.dataset.detail!==void 0||r.dataset.badge!==void 0||r.dataset.copy!==void 0))&&!(r.nodeType===3&&!r.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let r of t)this.appendChild(r);for(let r of e)this.appendChild(r);for(let r of i)this.appendChild(r);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),n.length)for(let r of n)this.#e.appendChild(r);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#n=document.createElement("button"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("type","button"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.textContent="\u29C9",this.appendChild(this.#n),this.#r=!0}#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=zA.has(this.shape)?this.shape:"square",e=VA.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=YA(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",WA[r]),o.textContent=_A[r],n.appendChild(o)}this.#s.replaceChildren(n)}#O(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#a=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#a)return;this.#a=t;let e=FA(t);if(e==null){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark");return}let i=e<.62;this.#e.toggleAttribute("data-on-dark",i),this.#e.toggleAttribute("data-on-light",!i)}#g(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#y(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#x();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#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"))}#k(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#v()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#n&&(t.preventDefault(),this.#v()))},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#x();e&&this.#S(e)},this.#n.addEventListener("click",this.#c)}#v(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#x(){return this.copyValue?this.copyValue:this.color?this.color:""}async#S(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#w(e)}#w(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#u&&(this.#u.disconnect(),this.#u=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#c&&this.#n.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};x("swatch-ui",ir);je();var hb={xs:0,sm:480,md:768,lg:1024,xl:1280},ls=Object.keys(hb),sd=Object.values(hb);function cb(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=ls.length-1;t>=0;t--)if(s>=sd[t])return ls[t];return"xs"}var Ae=Ii(cb());if(typeof window<"u")for(let s=1;s<sd.length;s++)window.matchMedia(`(min-width: ${sd[s]}px)`).addEventListener("change",()=>{Ae.value=cb()});function Dt(s,t=Ae.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=ls.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=ls.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}Q();var sr=class extends k{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("@")?Ae.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",HA(Dt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Dt(e,r);this.style.setProperty("--col-align",KA(o)),this.style.textAlign=JA(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",t$(Dt(i,r))):this.style.removeProperty("--col-justify")}},UA={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},GA={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function HA(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function KA(s){return UA[s]??s}function JA(s){return{start:"start",center:"center",end:"end"}[s]??""}function t$(s){return GA[s]??s}x("col-ui",sr);Q();var nr=class s extends k{static properties={label:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},align:{type:String,default:"start",reflect:!0}};get error(){return this.#O()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=t=>{let e=this.#O();if(!e)return;let i=this.#g(e);i&&(t.preventDefault(),i.focus())};connected(){this.#u(),this.#d(),this.#f(),this.#p(),this.#c(),this.#t?.addEventListener("click",this.#r),this.#n=new MutationObserver(()=>{this.#p(),this.#c(),this.#m(),this.#a()}),this.#n.observe(this,{childList:!0}),this.#a()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#a(),this.#m()}#a(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#o=()=>{this.#a(),this.#m()};#l=null;#c(){let t=this.#O();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#u(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#v("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#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.#v("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.#b()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#O();if(!t)return;let e=new Set;this.#i&&!this.#i.hidden&&e.add(this.#i.id),this.#s&&!this.#s.hidden&&e.add(this.#s.id);let n=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(r=>r&&!r.startsWith("field-hint-")&&!r.startsWith("field-err-")),...e].join(" ").trim();n?t.setAttribute("aria-describedby",n):t.removeAttribute("aria-describedby")}#O(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#g(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#y=0;static#b(){return`field-ctl-${++s.#y}`}static#k=0;static#v(t){return`field-${t}-${++s.#k}`}};x("field-ui",nr);Q();var rr=class extends k{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),this.#t=new MutationObserver(t=>{for(let e of t)if(e.type==="childList"&&(this.#i(e.addedNodes)||this.#i(e.removedNodes))){this.#e();return}}),this.#t.observe(this,{childList:!0})}disconnected(){this.#t?.disconnect(),this.#t=null}render(){this.#e()}#e(){let t=this.hasAttribute("inline");for(let e of this.children)e.localName==="field-ui"&&(t?e.hasAttribute("inline")||e.setAttribute("inline",""):e.hasAttribute("inline")&&e.removeAttribute("inline"))}#i(t){for(let e of t)if(e.nodeType===1&&e.localName==="field-ui")return!0;return!1}};x("fields-ui",rr);Q();var or=class extends k{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(Vn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Vn),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?Ae.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",s$(Dt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",n$(Dt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",r$(Dt(i,o))):this.style.removeProperty("--row-justify"),n){let a=ls.indexOf(o),l=ls.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},e$={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},i$={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function s$(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function n$(s){return e$[s]??s}function r$(s){return i$[s]??s}x("row-ui",or);Q();var ar=class extends k{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=Ae.value,e=this.columns;if(e?.includes("@")){let n=Dt(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=Dt(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})`}};x("grid-ui",ar);Q();var lr=class extends k{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};x("stack-ui",lr);Q();function hs(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 ub(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 ie(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ot({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${ie(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${ie(String(i))}"`),n}function se(s,t,e){return s+t*Math.cos(e)}function ne(s,t,e){return s+t*Math.sin(e)}function o$(s,t,e,i,n){let r=se(s,e,i),o=ne(t,e,i),a=se(s,e,n),l=ne(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 nd(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 gt=se(s,e,n),ft=ne(t,e,n),xt=se(s,e,r),$t=ne(t,e,r),St=se(s,i,r),_t=ne(t,i,r),Wt=se(s,i,n),Ri=ne(t,i,n),is=l>Math.PI?1:0;return`M ${gt} ${ft} A ${e} ${e} 0 ${is} 1 ${xt} ${$t} L ${St} ${_t} A ${i} ${i} 0 ${is} 0 ${Wt} ${Ri} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,O=r-d,g=p-f>Math.PI?1:0,y=se(s,e,f),v=ne(t,e,f),S=se(s,e,p),w=ne(t,e,p),$=se(s,i,O),A=ne(t,i,O),E=se(s,i,m),L=ne(t,i,m),P=se(s,e-h,n),X=ne(t,e-h,n),D=se(s,i+h,n),_=ne(t,i+h,n),W=se(s,e-h,r),Y=ne(t,e-h,r),et=se(s,i+h,r),ot=ne(t,i+h,r);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${S} ${w} A ${h} ${h} 0 0 1 ${W} ${Y} L ${et} ${ot} A ${h} ${h} 0 0 1 ${$} ${A} A ${i} ${i} 0 ${g} 0 ${E} ${L} A ${h} ${h} 0 0 1 ${D} ${_} L ${P} ${X} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function ya(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 rd(s,t,e=.4){let i=ya(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function Wl(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}var a$={std:{ratio:4/3}},hr=class extends k{static properties={type:{type:String,default:"bar",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},hideAverage:{type:Boolean,default:!1,reflect:!0,attribute:"hide-average"},color:{type:String,default:"",reflect:!0},hideGrid:{type:Boolean,default:!1,reflect:!0,attribute:"hide-grid"},hideValues:{type:Boolean,default:!1,reflect:!0,attribute:"hide-values"},radius:{type:Number,default:null,reflect:!0},smooth:{type:Number,default:.4,reflect:!0},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#a=new Set;#o(){if(this.radius!=null)return this.radius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}set data(t){!Array.isArray(t)&&!this.#e&&(this.#e=!0,console.warn(`[chart-ui] .data must be an array of plain objects \u2014 received ${t===null?"null":typeof t}. The {labels, datasets} envelope is the Chart.js API, not the chart-ui API.
|
|
185
|
+
`),this.#e=this.querySelector("[data-dropzone]"),this.#e&&(this.#e.addEventListener("click",this.#i),this.#e.addEventListener("keydown",this.#s),this.#e.addEventListener("dragover",this.#o),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#c))}render(){let t=this.querySelector("[data-filelist]");if(!this.#e||!t)return;let e=this.querySelector("span[hint]");e&&this.hint&&e.setAttribute("hint",this.hint),t.innerHTML="";for(let i of this.#t){let n=document.createElement("span");n.textContent=i.name,t.appendChild(n)}}get files(){return this.#t}#i=()=>{this.disabled||this.#n()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#n())};async#n(){try{if(window.showOpenFilePicker){let t=this.#a(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let n=await Promise.all(i.map(r=>r.getFile()));if(!this.isConnected)return;this.#h(n)}else this.#r()}catch(t){if(t.name!=="AbortError")throw t}}#r(){let t=document.createElement("input");t.type="file",this.accept&&(t.accept=this.accept),this.multiple&&(t.multiple=!0),t.style.display="none",document.body.appendChild(t),t.addEventListener("change",()=>{t.files?.length&&this.#h([...t.files]),t.remove()},{once:!0}),t.addEventListener("cancel",()=>t.remove(),{once:!0}),t.click()}#a(){if(!this.accept)return[];let t={};for(let e of this.accept.split(",")){let i=e.trim();i&&(i.startsWith(".")?(t["application/octet-stream"]=t["application/octet-stream"]||[],t["application/octet-stream"].push(i)):t[i]=t[i]||[])}return Object.keys(t).length?[{accept:t}]:[]}#o=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#c=t=>{if(t.preventDefault(),this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover"),this.disabled)return;let e=t.dataTransfer;e?.files?.length&&this.#h([...e.files])};#h(t){this.#t=t;let e=new FormData;for(let i of this.#t)e.append(this.name||"file",i);this.internals.setFormValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,files:this.files}})),this.render()}disconnected(){super.disconnected(),this.#e&&(this.#e.removeEventListener("click",this.#i),this.#e.removeEventListener("keydown",this.#s),this.#e.removeEventListener("dragover",this.#o),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#c)),this.#e=null}};x("upload-ui",zn);_u();var Vn=YO({name:"draggable",category:"motion-positioning",description:"Pointer drag to reposition",attributes:["data-draggable-dragging"],events:["drag-end"],config:[],setup({host:s}){let t=!1,e=0,i=0,n=0,r=0;function o(){return s.hasAttribute("disabled")}function a(c){if(o())return;t=!0,e=c.clientX,i=c.clientY;let u=getComputedStyle(s),d=u.translate;if(d&&d!=="none"){let f=d.split(/\s+/).map(parseFloat);n=f[0]||0,r=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);n=f.m41,r=f.m42}s.setPointerCapture(c.pointerId),s.setAttribute("data-draggable-dragging",""),s.style.touchAction="none"}function l(c){if(!t)return;let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.style.translate=`${f}px ${p}px`}function h(c){if(!t)return;t=!1,s.removeAttribute("data-draggable-dragging");let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.dispatchEvent(new CustomEvent("drag-end",{bubbles:!0,detail:{x:f,y:p}}))}return s.addEventListener("pointerdown",a),s.addEventListener("pointermove",l),s.addEventListener("pointerup",h),()=>{s.removeEventListener("pointerdown",a),s.removeEventListener("pointermove",l),s.removeEventListener("pointerup",h),s.removeAttribute("data-draggable-dragging"),s.style.touchAction=""}}});Q();var jn=class extends k{static properties={variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"",reflect:!0},elevation:{type:Number,default:1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Vn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Vn),this.#t=!0)}};x("card-ui",jn);Q();var _n=class extends k{static properties={src:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},shape:{type:String,default:"circle",reflect:!0}};get displayName(){return this.text}static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","img")}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#t||(this.#t=document.createElement("img"),this.#t.setAttribute("slot","img"),this.#t.onerror=()=>{this.#t.remove(),this.#t=null,this.#s()}),this.#t.src=this.src,this.#t.alt=this.displayName||"",this.#t.parentElement||this.appendChild(this.#t),this.#e&&(this.#e.remove(),this.#e=null)):this.icon?(this.#t&&(this.#t.remove(),this.#t=null),this.#e&&(this.#e.remove(),this.#e=null),this.#i||(this.#i=document.createElement("icon-ui"),this.#i.setAttribute("slot","icon"),this.appendChild(this.#i)),this.#i.setAttribute("name",this.icon)):(this.#t&&(this.#t.remove(),this.#t=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#s(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","initials"),this.appendChild(this.#e)),this.#e.textContent=t}},Wn=class extends k{static properties={max:{type:Number,default:5,reflect:!0},size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Avatar group")}render(){let t=[...this.querySelectorAll("avatar-ui")],e=this.max,i=t.length-e;if(this.size)for(let r of t)r.setAttribute("size",this.size);t.forEach((r,o)=>{r.style.display=o<e?"":"none",r.style.zIndex=String(t.length-o)});let n=this.querySelector('[slot="overflow"]');i>0?(n||(n=document.createElement("span"),n.setAttribute("slot","overflow"),this.appendChild(n)),n.textContent=`+${i}`,n.setAttribute("aria-label",`${i} more`),n.style.zIndex="0"):n&&n.remove()}};x("avatar-ui",_n),x("avatar-group-ui",Wn);Q();var Yn=class extends k{static properties={value:{type:Number,default:null,reflect:!0},variant:{type:String,default:"bar",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.variant==="bar"&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","track"),this.#e=document.createElement("div"),this.#e.setAttribute("slot","fill"),this.#t.appendChild(this.#e),this.appendChild(this.#t))}render(){let t=this.value==null||this.value<0,e=Math.max(0,Math.min(100,this.value));this.setAttribute("aria-busy",String(t)),t?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",String(e)),this.#e&&(this.#e.style.width=t?"100%":`${e}%`)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null}};x("progress-ui",Yn);Q();var Fn=class extends k{static properties={value:{type:Number,default:0,reflect:!0},total:{type:Number,default:0,reflect:!0},caption:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),!this.querySelector(':scope > [slot="caption"]')&&!this.querySelector(':scope > [slot="track"]')?(this.#t=document.createElement("span"),this.#t.setAttribute("slot","caption"),this.appendChild(this.#t),this.#e=document.createElement("div"),this.#e.setAttribute("slot","track"),this.appendChild(this.#e)):(this.#t=this.querySelector(':scope > [slot="caption"]'),this.#e=this.querySelector(':scope > [slot="track"]'))}render(){let t=Math.max(0,this.total|0),e=Math.max(0,Math.min(t,this.value|0));if(this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(e)),this.#t&&!this.#t.dataset.custom&&(this.#t.textContent=this.caption||"",this.#t.toggleAttribute("hidden",!this.caption)),this.#e){let i=this.#e.children.length;for(;this.#e.children.length<t;)this.#e.appendChild(document.createElement("span"));for(;this.#e.children.length>t;)this.#e.lastElementChild.remove();for(let n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};x("step-progress-ui",Fn);Q();var Un=class extends k{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},radius:{type:String,default:"sm",reflect:!0},static:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("aria-hidden","true"),this.#t()}render(){this.#t()}#t(){this.style.width=this.width,this.style.height=this.height}};x("skeleton-ui",Un);Q();var Gn=class extends k{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())}};x("spinner-ui",Gn);Q();var Hn=class extends k{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let n=!!t.get.call(this);e.call(this,i),!!i!==n&&this.#s(!!i)},configurable:!0})}}connected(){this.hasAttribute("role")||this.setAttribute("role","status"),this.hasAttribute("aria-live")||this.setAttribute("aria-live","polite"),this.setAttribute("aria-label",this.label||"Loading"),this.#t=this.parentElement,this.active&&this.#s(!0)}disconnected(){this.#a(),this.#i&&this.#r(),this.#t=null}render(){let t=this.label||"Loading";this.setAttribute("aria-label",t);let e=this.querySelector(":scope > spinner-ui[data-loading-overlay-auto]");e&&e.getAttribute("label")!==t&&e.setAttribute("label",t),this.children.length===0&&this.#o()}#s(t){if(this.#a(),t){let e=Math.max(0,Number(this.delay)||0);e===0?this.#n():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#n()},e)}else this.#i&&this.#r()}#n(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#r(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#a(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#o(){let t=document.createElement("spinner-ui");t.setAttribute("size","lg"),t.setAttribute("tone","subtle"),t.setAttribute("label",this.label||"Loading"),t.setAttribute("data-loading-overlay-auto",""),this.appendChild(t)}};x("loading-overlay-ui",Hn);Q();var ab=new Set;function lb(s,t){ab.has(s)||(ab.add(s),console.warn(`[alert-ui] ${t}`))}var Kn=class s extends k{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"&&(lb("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger, muted, neutral]. Mapping to "danger". Fix the source (LLM prompt / corpus pattern) to emit "danger" directly.'),this.setAttribute("variant","danger")),this.hasAttribute("closeable")&&!this.hasAttribute("closable")&&!this.hasAttribute("dismissible")&&(lb("alias-closeable","attribute [closeable] is a misspelled alias of canonical [closable]. Mapping. Fix the source to use [closable] or [dismissible]."),this.setAttribute("closable",""),this.removeAttribute("closeable")),this.hasAttribute("dismissible")&&!this.hasAttribute("closable")&&this.setAttribute("closable","")}#i=t=>{if(t.target.closest('[slot="close"]')){this.#h();return}if(this.pattern==="dunning"){let e=t.target.closest("[data-dunning-action]");if(e&&this.contains(e)){let i=e.getAttribute("data-dunning-action")||"";this.dispatchEvent(new CustomEvent("dunning-action",{bubbles:!0,composed:!0,detail:{action:i,amount:this.amount,currency:this.currency,dueAt:this.dueAt}}))}}};connected(){this.#e(),this.#c(),(this.icon||this.pattern==="dunning"&&this.reason)&&this.ensure("leading"),this.ensure("content"),this.closable&&this.ensure("close"),this.addEventListener("press",this.#i)}disconnected(){this.removeEventListener("press",this.#i)}render(){if(this.pattern==="dunning"){this.#s(),this.#c();return}if(this.icon){let e=this.ensure("leading");e&&e.setAttribute("name",this.icon)}else this.drop("leading");let t=this.ensure("content");if(t){let e=t.hasAttribute("data-alert-auto"),i=t.childNodes.length>0;if(!e&&i){if(this.title||this.description){let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#c()}#s(){let t=this.icon||s.#t[this.reason]||"x-circle",e=this.ensure("leading");e&&e.setAttribute("name",t);let i=this.ensure("content");if(!i)return;i.setAttribute("data-alert-auto","dunning"),i.replaceChildren();let n=this.title||this.#n();if(n){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=n,i.appendChild(l)}let r=this.#r(),o=this.#o();if(r||o){if(i.appendChild(document.createTextNode(" ")),r){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=r,i.appendChild(l)}if(r&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[n,r,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#n(){switch(this.reason){case"expired":return"Card expired";case"insufficient":return"Insufficient funds";case"network":return"Network error";case"declined":return"Payment failed";default:return this.variant==="warning"?"Payment due soon":"Payment failed"}}#r(){if(!this.amount&&this.amount!==0||this.amount===0)return"";try{let t=this.getAttribute("lang")||this.lang||void 0;return new Intl.NumberFormat(t,{style:"currency",currency:this.currency||"USD"}).format(this.amount)}catch{return`${this.currency||""} ${this.amount}`.trim()}}#a(){if(!this.dueAt)return"";let t=/^\d{4}-\d{2}-\d{2}$/.test(this.dueAt)?new Date(`${this.dueAt}T00:00:00`):new Date(this.dueAt);if(Number.isNaN(t.getTime()))return"";try{let e=this.getAttribute("lang")||this.lang||void 0;return new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}).format(t)}catch{return t.toDateString()}}#o(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#a();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#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()}};x("alert-ui",Kn);Q();var BA={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},Jn=class extends k{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||BA[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()}};x("inline-message-ui",Jn);Q();var tr=class extends k{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};x("kbd-ui",tr);Q();var er=class extends k{static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},removable:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={dismiss:'<button slot="dismiss" type="button" aria-label="Remove"><icon-ui name="x" weight="bold"></icon-ui></button>'};static template=()=>null;#t=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#e=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};connected(){this.setAttribute("role","status"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")),this.removable&&!this.disabled){let t=this.ensure("dismiss");t&&t.parentElement!==this&&this.appendChild(t)}else this.drop("dismiss")}};x("tag-ui",er);Q();var zA=new Set(["block","dot","square","line","dashed"]),VA=new Set(["sm","md","lg"]),jA=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),_A={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},WA={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function YA(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&jA.has(t)):[]}var as=null;function FA(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!as){let u=document.createElement("canvas");u.width=1,u.height=1,as=u.getContext("2d")}as.fillStyle="#000",as.clearRect(0,0,1,1),as.fillStyle=s,as.fillRect(0,0,1,1);let[t,e,i]=as.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 ir=class extends k{static properties={shape:{type:String,default:"square",reflect:!0},size:{type:String,default:"md",reflect:!0},color:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},detail:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},copyable:{type:Boolean,default:!1,reflect:!0},copyValue:{type:String,default:""},selectable:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},autoContrast:{type:Boolean,default:!1,reflect:!0},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;connected(){this.#d(),this.#w(),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.#y(),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"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("type","button"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.textContent="\u29C9",this.appendChild(this.#n),this.#r=!0}#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=zA.has(this.shape)?this.shape:"square",e=VA.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=YA(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",WA[r]),o.textContent=_A[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.#a=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#a)return;this.#a=t;let e=FA(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)}#y(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#x();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#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"))}#w(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#v()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#n&&(t.preventDefault(),this.#v()))},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#x();e&&this.#S(e)},this.#n.addEventListener("click",this.#c)}#v(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#x(){return this.copyValue?this.copyValue:this.color?this.color:""}async#S(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#k(e)}#k(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#u&&(this.#u.disconnect(),this.#u=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#c&&this.#n.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};x("swatch-ui",ir);je();var hb={xs:0,sm:480,md:768,lg:1024,xl:1280},ls=Object.keys(hb),sd=Object.values(hb);function cb(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=ls.length-1;t>=0;t--)if(s>=sd[t])return ls[t];return"xs"}var Ae=Ii(cb());if(typeof window<"u")for(let s=1;s<sd.length;s++)window.matchMedia(`(min-width: ${sd[s]}px)`).addEventListener("change",()=>{Ae.value=cb()});function Dt(s,t=Ae.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=ls.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=ls.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}Q();var sr=class extends k{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("@")?Ae.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",HA(Dt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Dt(e,r);this.style.setProperty("--col-align",KA(o)),this.style.textAlign=JA(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",t$(Dt(i,r))):this.style.removeProperty("--col-justify")}},UA={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},GA={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function HA(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function KA(s){return UA[s]??s}function JA(s){return{start:"start",center:"center",end:"end"}[s]??""}function t$(s){return GA[s]??s}x("col-ui",sr);Q();var nr=class s extends k{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.#O(e);i&&(t.preventDefault(),i.focus())};connected(){this.#u(),this.#d(),this.#f(),this.#p(),this.#c(),this.#t?.addEventListener("click",this.#r),this.#n=new MutationObserver(()=>{this.#p(),this.#c(),this.#m(),this.#a()}),this.#n.observe(this,{childList:!0}),this.#a()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#a(),this.#m()}#a(){if(!this.#s)return;let t=this.error;this.#s.textContent=t||"",this.#s.hidden=!t}#o=()=>{this.#a(),this.#m()};#l=null;#c(){let t=this.#g();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#u(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#v("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#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.#v("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.#b()),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(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#O(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#y=0;static#b(){return`field-ctl-${++s.#y}`}static#w=0;static#v(t){return`field-${t}-${++s.#w}`}};x("field-ui",nr);Q();var rr=class extends k{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),this.#t=new MutationObserver(t=>{for(let e of t)if(e.type==="childList"&&(this.#i(e.addedNodes)||this.#i(e.removedNodes))){this.#e();return}}),this.#t.observe(this,{childList:!0})}disconnected(){this.#t?.disconnect(),this.#t=null}render(){this.#e()}#e(){let t=this.hasAttribute("inline");for(let e of this.children)e.localName==="field-ui"&&(t?e.hasAttribute("inline")||e.setAttribute("inline",""):e.hasAttribute("inline")&&e.removeAttribute("inline"))}#i(t){for(let e of t)if(e.nodeType===1&&e.localName==="field-ui")return!0;return!1}};x("fields-ui",rr);Q();var or=class extends k{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(Vn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Vn),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?Ae.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",s$(Dt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",n$(Dt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",r$(Dt(i,o))):this.style.removeProperty("--row-justify"),n){let a=ls.indexOf(o),l=ls.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},e$={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},i$={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function s$(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function n$(s){return e$[s]??s}function r$(s){return i$[s]??s}x("row-ui",or);Q();var ar=class extends k{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=Ae.value,e=this.columns;if(e?.includes("@")){let n=Dt(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=Dt(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})`}};x("grid-ui",ar);Q();var lr=class extends k{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};x("stack-ui",lr);Q();function hs(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 ub(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 ie(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ot({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${ie(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${ie(String(i))}"`),n}function se(s,t,e){return s+t*Math.cos(e)}function ne(s,t,e){return s+t*Math.sin(e)}function o$(s,t,e,i,n){let r=se(s,e,i),o=ne(t,e,i),a=se(s,e,n),l=ne(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 nd(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 gt=se(s,e,n),ft=ne(t,e,n),xt=se(s,e,r),$t=ne(t,e,r),St=se(s,i,r),_t=ne(t,i,r),Wt=se(s,i,n),Ri=ne(t,i,n),is=l>Math.PI?1:0;return`M ${gt} ${ft} A ${e} ${e} 0 ${is} 1 ${xt} ${$t} L ${St} ${_t} A ${i} ${i} 0 ${is} 0 ${Wt} ${Ri} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,O=r-d,g=p-f>Math.PI?1:0,y=se(s,e,f),v=ne(t,e,f),S=se(s,e,p),w=ne(t,e,p),$=se(s,i,O),A=ne(t,i,O),E=se(s,i,m),L=ne(t,i,m),P=se(s,e-h,n),X=ne(t,e-h,n),D=se(s,i+h,n),_=ne(t,i+h,n),W=se(s,e-h,r),Y=ne(t,e-h,r),et=se(s,i+h,r),ot=ne(t,i+h,r);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${S} ${w} A ${h} ${h} 0 0 1 ${W} ${Y} L ${et} ${ot} A ${h} ${h} 0 0 1 ${$} ${A} A ${i} ${i} 0 ${g} 0 ${E} ${L} A ${h} ${h} 0 0 1 ${D} ${_} L ${P} ${X} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function ya(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 rd(s,t,e=.4){let i=ya(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function Wl(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}var a$={std:{ratio:4/3}},hr=class extends k{static properties={type:{type:String,default:"bar",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},hideAverage:{type:Boolean,default:!1,reflect:!0,attribute:"hide-average"},color:{type:String,default:"",reflect:!0},hideGrid:{type:Boolean,default:!1,reflect:!0,attribute:"hide-grid"},hideValues:{type:Boolean,default:!1,reflect:!0,attribute:"hide-values"},radius:{type:Number,default:null,reflect:!0},smooth:{type:Number,default:.4,reflect:!0},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#a=new Set;#o(){if(this.radius!=null)return this.radius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}set data(t){!Array.isArray(t)&&!this.#e&&(this.#e=!0,console.warn(`[chart-ui] .data must be an array of plain objects \u2014 received ${t===null?"null":typeof t}. The {labels, datasets} envelope is the Chart.js API, not the chart-ui API.
|
|
186
186
|
Correct shape for <chart-ui x="label" y="value">:
|
|
187
|
-
[{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#c(),this.#f()}get data(){return this.#t}#l=!1;#c(){if(this.#l)return;let t=this.#h();this.#t.length>t&&(console.warn(`[chart-ui] .data has ${this.#t.length} rows which exceeds the recommended perf budget of ${t}. Consider downsampling at the data layer (e.g., LTTB, bucket aggregation). Override the budget via CSS: chart-ui { --chart-perf-budget: 10000 }.`),this.#l=!0)}#h(){let t=getComputedStyle(this).getPropertyValue("--chart-perf-budget").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:5e3}connected(){if(this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",`${this.type} chart`),this.#t.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}document.addEventListener("toggle",this.#k),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#C),this.addEventListener("focus",this.#E),this.addEventListener("blur",this.#R),this.addEventListener("pointerover",this.#T),this.addEventListener("pointermove",this.#D),this.addEventListener("pointerleave",this.#Z),this.addEventListener("pointerdown",this.#I),this.addEventListener("click",this.#V),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.#f()})))}),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.#f()}#u(){let t=this.clientWidth||300,e=this.clientHeight||0,i=a$.std,n=this.#t.length||1,r=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(r/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(r,a),c=this.size||(h<150?"sm":h<300?"md":"lg"),u=c==="sm"?9:c==="md"?10:11,d=u,f=c==="sm"?8:c==="md"?9:10,p=this.hideGrid,m=p?0:u*3.2,O=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!O||p?2:u*2.2,left:m},y=r-g.left-g.right,v=Math.max(4,y/n*.6);return{width:r,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n,sizeClass:c}}#d=null;#f(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#d&&(this.#d=t.cloneNode(!0)),this.innerHTML="",this.#d&&this.appendChild(this.#d.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}this.setAttribute("data-has-data",""),this.#p();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.#H());break;case"line":({svg:n,viewBox:r}=this.#J());break;case"pie":({svg:n,viewBox:r}=this.#K());break;case"donut":({svg:n,viewBox:r}=this.#tt());break;case"radar":({svg:n,viewBox:r}=this.#et());break;case"sparkline":({svg:n,viewBox:r}=this.#it());break;case"segments":({svg:n,viewBox:r}=this.#ht());break;case"area":({svg:n,viewBox:r}=this.#st());break;case"scatter":({svg:n,viewBox:r}=this.#U());break;case"radial-bar":({svg:n,viewBox:r}=this.#Y());break;case"gauge":({svg:n,viewBox:r}=this.#nt());break;case"funnel":({svg:n,viewBox:r}=this.#rt());break;case"treemap":({svg:n,viewBox:r}=this.#ot());break;case"sankey":({svg:n,viewBox:r}=this.#at());break;case"composed":({svg:n,viewBox:r}=this.#lt());break;case"stacked-bar":({svg:n,viewBox:r}=this.#ct());break;case"grouped-bar":({svg:n,viewBox:r}=this.#ut());break;case"multi-line":({svg:n,viewBox:r}=this.#dt());break;default:({svg:n,viewBox:r}=this.#H());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#y()){let o=this.#ft();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#p(){let t=this.#X();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#m(t,e){return e?` data-slice="${t}" data-series-key="${ie(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#O(t,e){return e?` data-slice="${t}" data-series-key="${ie(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#k),document.removeEventListener("pointerdown",this.#q),this.removeEventListener("keydown",this.#C),this.removeEventListener("focus",this.#E),this.removeEventListener("blur",this.#R),this.removeEventListener("pointerover",this.#T),this.removeEventListener("pointermove",this.#D),this.removeEventListener("pointerleave",this.#Z),this.removeEventListener("pointerdown",this.#I),this.removeEventListener("click",this.#V),this.#_()}#y(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#b(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#k=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#a.delete(i):this.#a.add(i),this.#f())};#v(t){return!!t&&this.#a.has(t)}#x(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${ub(e)}`}default:return ub(e)}}#S=-1;#w(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#A(t){let e=this.#w();if(!e.length){this.#$();return}this.#S=Math.max(0,Math.min(t,e.length-1)),this.#P(),this.#M()}#P(){let t=this.#w();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#S];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#$(){this.#S=-1;for(let t of this.#w())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#M(){let t=this.#w()[this.#S];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#N(t,i)}#Q(){let t=this.#w()[this.#S];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.#B(t,i)}))}#E=()=>{this.#S===-1&&this.#A(0)};#R=()=>{this.#$(),this.#L&&this.#j()};#C=t=>{let e=this.#w();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#A(this.#S+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#A(Math.max(0,this.#S-1));break;case"Home":t.preventDefault(),this.#A(0);break;case"End":t.preventDefault(),this.#A(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#Q();break;case"Escape":t.preventDefault(),this.#$(),this.#L&&this.#j();break}};#L=null;#T=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#F(e,t),this.#N(e,t))};#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#L&&this.#j(),this.#_();this.#F(e,t),e!==this.#L&&this.#N(e,t)};#Z=t=>{t&&t.pointerType==="touch"||(this.#_(),this.#L&&this.#j())};#I=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#L&&this.#j(),this.#_();this.#F(e,t),e!==this.#L&&this.#N(e,t),document.addEventListener("pointerdown",this.#q)};#q=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#_(),this.#L&&this.#j(),document.removeEventListener("pointerdown",this.#q)))};#V=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#B(e,t)}))};#N(t,e){this.#L=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#B(t,e)}))}#j(){this.#L=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#B(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#G(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#G(t,e){if(t==null)return null;let i=this.x,n=this.#X();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#F(t,e){if(this.#b())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#g){let O=document.createElement("div");O.setAttribute("popover","manual"),O.setAttribute("role","tooltip"),O.classList.add("chart-tooltip-popup"),document.body.appendChild(O),this.#g=O}let a=[];if(o&&a.push(`<span data-tip-role="series">${ie(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ie(i)}</span>`),n!==void 0){let O=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#x(n)}${O}</span>`)}this.#g.innerHTML=a.join("");try{this.#g.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#g.offsetWidth||0,f=this.#g.offsetHeight||0,p=c-d/2,m=u-f-l;p<h&&(p=h),p+d>window.innerWidth-h&&(p=window.innerWidth-d-h),m<h&&(m=u+l),this.#g.style.left=`${p}px`,this.#g.style.top=`${m}px`}#_(){if(this.#g){try{this.#g.hidePopover()}catch{}this.#g.remove(),this.#g=null}}#X(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#W(t,e,i,n,r,o){let a=r,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#x(p)}</text>`}if(n){let m=(t-a.left-a.right)/n.length,g=n.reduce((S,w)=>Math.max(S,String(w).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=n.length-1;for(let S=0;S<n.length;S++){if(S%y!==0&&S!==v||S!==v&&v-S<y)continue;let w=a.left+m*S+m/2;c+=`<text data-x-label x="${w}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${ie(n[S])}</text>`}}}return c}#H(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(v=>+(v[i]??0)),r=e.map(v=>v[this.x]??""),o=hs(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/e.length,p=f*.6,m=(f-p)/2,O=this.#W(l,h,o,r,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&n.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let S=n[v],w=a?S/a*u:0,$=c.left+f*v+m,A=c.top+u-w;O+=`<path data-bar${Ot({label:r[v],value:S})} d="${Wl($,A,p,w,this.#o())}"/>`,g&&(O+=`<text data-value x="${$+p/2}" y="${A-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(S)}</text>`)}if(y){let v=n.reduce((w,$)=>w+$,0)/n.length,S=c.top+u-(a?v/a*u:0);O+=`<line data-avg x1="${c.left}" y1="${S}" x2="${l-c.right}" y2="${S}"/>`,O+=`<text data-avg-label x="${l-c.right+2}" y="${S+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(v)}</text>`,O+=`<line data-hit${Ot({label:"Average",value:v})} x1="${c.left}" y1="${S}" x2="${l-c.right}" y2="${S}" stroke="transparent" stroke-width="12"/>`}return{svg:O,viewBox:`0 0 ${l} ${h}`}}#J(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(A=>+(A[i]??0)),r=e.map(A=>A[this.x]??""),o=hs(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#W(l,h,o,r,c,t),m=n.map((A,E)=>{let L=c.left+f*E,P=c.top+u-(a?A/a*u:0);return{x:L,y:P,v:A,label:r[E]}}),O=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${rd(m,O,g)}"/>`,p+=`<path data-line d="${ya(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,S=Math.max(v,10),w=!this.hideValues&&!y,$=!this.hideAverage&&n.length>1&&!y&&!this.hideGrid;for(let A of m)p+=`<circle data-dot cx="${A.x}" cy="${A.y}" r="${v}"/>`,p+=`<circle data-hit${Ot({label:A.label,value:A.v})} cx="${A.x}" cy="${A.y}" r="${S}" fill="transparent"/>`,w&&(p+=`<text data-value x="${A.x}" y="${A.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(A.v)}</text>`);if($){let A=n.reduce((L,P)=>L+P,0)/n.length,E=c.top+u-(a?A/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${E}" x2="${l-c.right}" y2="${E}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${E+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(A)}</text>`,p+=`<line data-hit${Ot({label:"Average",value:A})} x1="${c.left}" y1="${E}" x2="${l-c.right}" y2="${E}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#K(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d="",f=-Math.PI/2;for(let p=0;p<i.length;p++){let m=i[p]/n*Math.PI*2;if(m===0)continue;let O=f+m,g=(i[p]/n*100).toFixed(1),y=` data-slice="${p%10}"${Ot({label:r[p],value:i[p],pct:g})}`;Math.abs(m-Math.PI*2)<.001?d+=`<circle${y} cx="${h}" cy="${c}" r="${u}"/>`:d+=`<path${y} d="${o$(h,c,u,f,O)}"/>`,f=O}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#tt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=i.reduce((g,y)=>g+y,0)||1,r=t.map(g=>g[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d=u*.72,f="",p=-Math.PI/2;for(let g=0;g<i.length;g++){let y=i[g]/n*Math.PI*2;if(y===0)continue;let v=p+y,S=(i[g]/n*100).toFixed(1),w=` data-slice="${g%10}"${Ot({label:r[g],value:i[g],pct:S})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${w} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${w} d="M ${h-u} ${c} A ${u} ${u} 0 1 1 ${h+u} ${c} A ${u} ${u} 0 1 1 ${h-u} ${c} Z M ${h-d} ${c} A ${d} ${d} 0 1 0 ${h+d} ${c} A ${d} ${d} 0 1 0 ${h-d} ${c} Z" fill-rule="evenodd"/>`):f+=`<path${w} d="${nd(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),O=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#x(n)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${O}">Total</text>`,this.#z=t.map((g,y)=>({label:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#et(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(w=>+(w[e]??0)),n=t.map(w=>w[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#u(),{width:l,height:h,fontSize:c}=a,u=l/2,d=h/2,f=c*3.5,p=Math.max(40,Math.min(l,h)/2-f),m="",O=Math.PI*2/o;for(let w=1;w<=3;w++){let $=p*w/3,A="";for(let E=0;E<o;E++){let L=-Math.PI/2+O*E,P=u+$*Math.cos(L),X=d+$*Math.sin(L);A+=(E===0?"M":"L")+` ${P} ${X}`}A+=" Z",m+=`<path data-grid d="${A}"/>`}for(let w=0;w<o;w++){let $=-Math.PI/2+O*w,A=u+p*Math.cos($),E=d+p*Math.sin($);m+=`<line data-grid x1="${u}" y1="${d}" x2="${A}" y2="${E}"/>`}let g="",y=[];for(let w=0;w<o;w++){let $=-Math.PI/2+O*w,A=i[w]/r*p,E=u+A*Math.cos($),L=d+A*Math.sin($);g+=(w===0?"M":"L")+` ${E} ${L}`,y.push({px:E,py:L})}g+=" Z",m+=`<path data-radar-fill d="${g}"/>`,m+=`<path data-radar-line d="${g}"/>`;let v=Math.max(c,10);for(let w=0;w<o;w++){let{px:$,py:A}=y[w];m+=`<circle data-hit${Ot({label:n[w],value:i[w]})} cx="${$}" cy="${A}" r="${v}" fill="transparent"/>`}let S=c*1.3;for(let w=0;w<o;w++){let $=-Math.PI/2+O*w,A=u+(p+S)*Math.cos($),E=d+(p+S)*Math.sin($),L=Math.abs(Math.cos($))<.1?"middle":Math.cos($)>0?"start":"end";m+=`<text data-x-label x="${A}" y="${E}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${ie(n[w])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#it(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(y=>+(y[e]??0)),n=Math.max(...i)||1,r=Math.min(...i),o=n-r||1,a=this.clientWidth||120,l=this.clientHeight||32,h=Math.max(40,a),c=Math.max(16,l),u=h/Math.max(i.length-1,1),d=Math.max(2,Math.min(6,c*.1)),f=t.map(y=>y[this.x]??""),p=i.map((y,v)=>({x:u*v,y:c-(y-r)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),O="";O+=`<path data-area d="${rd(p,c,m)}"/>`,O+=`<path data-line d="${ya(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)O+=`<circle data-hit${Ot({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:O,viewBox:`0 0 ${h} ${c}`}}#st(){return this.#J()}#U(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(g=>+(g[i]??0)),r=e.map(g=>g[this.x]??""),o=hs(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#W(l,h,o,r,c,t),m=t.sizeClass==="sm"?2.5:4,O=Math.max(m*2,10);for(let g=0;g<n.length;g++){let y=c.left+f*g,v=c.top+u-(a?n[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${Ot({label:r[g],value:n[g]})} cx="${y}" cy="${v}" r="${O}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#Y(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=Math.max(...i)||1,o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.45),d=u*.3,f=i.length||1,p=(u-d)/f,m=Math.min(2,p*.15),O="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,S=(y+v)/2,w=v-y,$=2*Math.PI*S,A=Math.max(0,Math.min(1,i[g]/r))*$;if(O+=`<circle data-radial-track cx="${h}" cy="${c}" r="${S}" fill="none" stroke-width="${w}"/>`,A<=0)continue;let E=(i[g]/r*100).toFixed(1),L=Ot({label:n[g],value:i[g],pct:E}),P=Math.abs(A-$)<.5,X=P?"butt":"round",D=P?`${$} 0`:`${A} ${$-A}`;O+=`<circle data-slice="${g%10}"${L} data-radial-bar cx="${h}" cy="${c}" r="${S}" fill="none" stroke-width="${w}" stroke-linecap="${X}" stroke-dasharray="${D}" transform="rotate(-90 ${h} ${c})"/>`}return this.#z=t.map((g,y)=>({label:n[y],key:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:O,viewBox:`0 0 ${a} ${l}`}}#nt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(S=>+(S[e]??0)),n=i.reduce((S,w)=>S+w,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#u(),{width:h,height:c}=l,u=h/2,d=c*.68,f=Math.max(40,Math.min(h*.45,c*.6)),p=f*.72,m=(f-p)/2,O="";if(O+=`<path data-radial-track d="${nd(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let S=Math.PI+Math.PI*a,w=Ot({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});O+=`<path data-slice="0"${w} data-gauge-fill d="${nd(u,d,f,p,Math.PI,S,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return O+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#x(r)}</text>`,o!==r&&(O+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#x(o)}</text>`),{svg:O,viewBox:`0 0 ${h} ${c}`}}#rt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#u(),{width:l,height:h}=a,c=a.fontSize,u=Math.max(l*.18,80),d=c*.8,f=l-u*2,m=(h-d*2)/r,O=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<r;v++){let S=i[v],w=v<r-1?i[v+1]:i[v],$=S/o*(f/2),A=w/o*(f/2),E=d+m*v+O/2,L=d+m*(v+1)-O/2,P=(S/o*100).toFixed(1),X=Ot({label:n[v],value:S,pct:P}),D=`M ${g-$} ${E} L ${g+$} ${E} L ${g+A} ${L} L ${g-A} ${L} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${X} d="${D}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${E+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ie(n[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${E+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#x(S)}</text>`,v>0){let _=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${E+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${_}%</text>`}}return this.#z=t.map((v,S)=>({label:n[S],value:i[S],pct:(i[S]/o*100).toFixed(1),slot:S%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#ot(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(P=>+(P[e]??0)),n=t.map(P=>P[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#u(),{width:a,height:l,fontSize:h}=o,c=i.reduce((P,X)=>P+X,0)||1,u=Array.from({length:r},(P,X)=>X).sort((P,X)=>i[X]-i[P]),d=[],f=a*l,p=u.map(P=>i[P]/c*f),m=0,O=0,g=a,y=l,v=[],S=0,w=(P,X)=>{if(P.length===0)return 1/0;let D=P.reduce((ot,gt)=>ot+gt,0),_=Math.max(...P),W=Math.min(...P),Y=X*X,et=D*D;return Math.max(Y*_/et,et/(Y*W))},$=(P,X,D,_,W,Y)=>{let et=P.reduce(($t,St)=>$t+St,0),ot=W>=Y,gt=ot?et/W:Y,ft=ot?W:et/Y,xt=0;for(let $t=0;$t<P.length;$t++){let St=P[$t]/et,_t=u[X+$t];if(ot){let Wt=St*W;d.push({i:_t,x:D+xt,y:_,w:Wt,h:gt}),xt+=Wt}else{let Wt=St*Y;d.push({i:_t,x:D,y:_+xt,w:ft,h:Wt}),xt+=Wt}}return ot?{x:D,y:_+gt,w:W,h:Y-gt}:{x:D+ft,y:_,w:W-ft,h:Y}},A=p.slice();for(;A.length>0;){v=[A[0]],S=p.length-A.length;let P=Math.min(g,y),X=1;for(;X<A.length;){let _=v.concat(A[X]);if(w(_,P)>w(v,P))break;v=_,X++}let D=$(v,S,m,O,g,y);m=D.x,O=D.y,g=D.w,y=D.h,A=A.slice(v.length)}let E="",L=2;for(let P of d){let X=(i[P.i]/c*100).toFixed(1),D=Ot({label:n[P.i],value:i[P.i],pct:X});E+=`<rect data-slice="${P.i%10}" data-treemap-tile${D} x="${P.x+L}" y="${P.y+L}" width="${Math.max(0,P.w-L*2)}" height="${Math.max(0,P.h-L*2)}" rx="${this.#o()}"/>`;let _=P.x+8,W=P.w>h*4,Y=W&&P.h>h*2.5,et=W&&!Y&&P.h>h*1.2;if(Y)E+=`<text data-treemap-label x="${_}" y="${P.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ie(n[P.i])}</text>`,E+=`<text data-treemap-value x="${_}" y="${P.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#x(i[P.i])}</text>`;else if(et){let ot=P.y+P.h/2;E+=`<text data-treemap-label x="${_}" y="${ot}" font-size="${h}" dominant-baseline="central">${ie(n[P.i])}</text>`}}return this.#z=t.map((P,X)=>({label:n[X],value:i[X],pct:(i[X]/c*100).toFixed(1),slot:X%10})),{svg:E,viewBox:`0 0 ${a} ${l}`}}#at(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let S of t){let w=S.source??S.from??"",$=S.target??S.to??"",A=+(S.value??S.v??0);e.has(w)||e.set(w,{name:w,flow:0}),i.has($)||i.set($,{name:$,flow:0}),e.get(w).flow+=A,i.get($).flow+=A}let n=this.#u(),{width:r,height:o,fontSize:a}=n,l=Math.max(8,r*.03),h=l+a*5,c=[...e.values()].reduce((S,w)=>S+w.flow,0)||1,u=[...i.values()].reduce((S,w)=>S+w.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),O=o-d*(p.length-1),g=0;for(let S of f){let w=S.flow/c*m;S.y0=g,S.y1=g+w,S.cursor=g,g+=w+d}g=0;for(let S of p){let w=S.flow/u*O;S.y0=g,S.y1=g+w,S.cursor=g,g+=w+d}let y="",v=Math.min(this.#o(),l/2);f.forEach((S,w)=>{y+=`<rect data-sankey-node data-slice="${w%10}" x="${h-l}" y="${S.y0}" width="${l}" height="${S.y1-S.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(S.y0+S.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${ie(S.name)}</text>`}),p.forEach((S,w)=>{y+=`<rect data-sankey-node data-slice="${(f.length+w)%10}" x="${r-h}" y="${S.y0}" width="${l}" height="${S.y1-S.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${r-h+l+6}" y="${(S.y0+S.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${ie(S.name)}</text>`});for(let S of t){let w=e.get(S.source??S.from??""),$=i.get(S.target??S.to??"");if(!w||!$)continue;let A=+(S.value??S.v??0);if(A<=0)continue;let E=A/c*m,L=A/u*O,P=w.cursor,X=P+E,D=$.cursor,_=D+L;w.cursor+=E,$.cursor+=L;let W=h,Y=r-h,et=(W+Y)/2,ot=Ot({label:`${w.name} \u2192 ${$.name}`,value:A}),gt=`M ${W} ${P} C ${et} ${P}, ${et} ${D}, ${Y} ${D} L ${Y} ${_} C ${et} ${_}, ${et} ${X}, ${W} ${X} Z`;y+=`<path data-sankey-link${ot} d="${gt}"/>`}return{svg:y,viewBox:`0 0 ${r} ${o}`}}#lt(){let t=this.#u(),e=this.#t,i=this.#X(),n=i[0]||"bar",r=i[1]||"line",o=e.map($=>$[this.x]??""),a=e.map($=>+($[n]??0)),l=e.map($=>+($[r]??0)),h=[...a,...l],c=hs(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,O=d-p.left-p.right,g=O/e.length,y=g*.6,v=(g-y)/2,S=O/Math.max(e.length-1,1),w=this.#W(d,f,c,o,p,t);if(!this.#v(n))for(let $=0;$<e.length;$++){let A=a[$],E=u?A/u*m:0,L=p.left+g*$+v,P=p.top+m-E;w+=`<path${this.#m(0,n)}${Ot({label:o[$],value:A,series:n})} d="${Wl(L,P,y,E,this.#o())}"/>`}if(!this.#v(r)){let $=l.map((E,L)=>({x:p.left+g*L+g/2,y:p.top+m-(u?E/u*m:0),v:E,label:o[L]})),A=Math.max(0,Math.min(1,this.smooth));w+=`<path data-line${this.#O(1,r)} d="${ya($,A)}"/>`;for(let E of $)w+=`<circle data-dot${this.#m(1,r)} cx="${E.x}" cy="${E.y}" r="3"/>`,w+=`<circle data-hit${Ot({label:E.label,value:E.v,series:r})} cx="${E.x}" cy="${E.y}" r="10" fill="transparent"/>`}return this.#z=[{label:n,key:n,slot:0},{label:r,key:r,slot:1}],{svg:w,viewBox:`0 0 ${d} ${f}`}}#ht(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#o(),l/2),c=Math.max(0,parseFloat(o.getPropertyValue("--chart-segments-gap"))||2),u=[],d=0;for(let p=0;p<i.length;p++){let m=p===i.length-1?a:Math.round((d*n+i[p]*a)/n),O=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/n*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/n*a;u.push({x:g,w:Math.max(0,O-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:O}=u[p];if(O<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,O-(y?0:c)),S=(i[p]/n*100).toFixed(1),w=Ot({label:r[p],value:i[p],pct:S}),$=`<title>${ie(r[p])}: ${i[p]} (${S}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${w} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${$}</rect>`;else{let A=h,E=m+v,L;g?L=`M ${m+A} 0 H ${E} V ${l} H ${m+A} A ${A} ${A} 0 0 1 ${m} ${l-A} V ${A} A ${A} ${A} 0 0 1 ${m+A} 0 Z`:L=`M ${m} 0 H ${E-A} A ${A} ${A} 0 0 1 ${E} ${A} V ${l-A} A ${A} ${A} 0 0 1 ${E-A} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${w} d="${L}">${$}</path>`}}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#ct(){let t=this.#t,e=this.#X(),i=t.map(g=>g[this.x]??""),n=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),r=hs(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=f*.6,m=(f-p)/2,O=this.#W(l,h,r,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let S=0;S<v;S++){if(this.#v(e[S]))continue;let w=+(t[g][e[S]]??0),$=o?w/o*u:0;if($<=0){y-=$;continue}y-=$;let A=c.left+f*g+m,E=y,L=$,P=S===v-1,X=this.#o(),D=`${this.#m(S%10,e[S])}${Ot({label:i[g],value:w,series:e[S]})}`;P?O+=`<path${D} d="${Wl(A,E,p,L,X)}"/>`:O+=`<rect${D} x="${A}" y="${E}" width="${p}" height="${L}"/>`}}return this.#z=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:O,viewBox:`0 0 ${l} ${h}`}}#ut(){let t=this.#t,e=this.#X(),i=t.map(v=>v[this.x]??""),n=t.flatMap(v=>e.map(S=>+(v[S]??0))),r=hs(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=3,m=f*.7,O=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#W(l,h,r,i,c,a);for(let v=0;v<t.length;v++)for(let S=0;S<e.length;S++){if(this.#v(e[S]))continue;let w=+(t[v][e[S]]??0),$=o?w/o*u:0,A=c.left+f*v+g+(O+p)*S,E=c.top+u-$;y+=`<path${this.#m(S%10,e[S])}${Ot({label:i[v],value:w,series:e[S]})} d="${Wl(A,E,O,$,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${A+O/2}" y="${E-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#x(w)}</text>`)}return this.#z=e.map((v,S)=>({label:v,key:v,slot:S%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#dt(){let t=this.#t,e=this.#X(),i=t.map(m=>m[this.x]??""),n=t.flatMap(m=>e.map(O=>+(m[O]??0))),r=hs(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(t.length-1,1),p=this.#W(l,h,r,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(S=>+(S[e[m]]??0)).map((S,w)=>{let $=c.left+f*w,A=c.top+u-(o?S/o*u:0);return{x:$,y:A,v:S,label:i[w]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#m(m%10,e[m])} d="${rd(g,y,v)}"/>`,p+=`<path data-line${this.#O(m%10,e[m])} d="${ya(g,v)}"/>`;for(let S of g)p+=`<circle data-dot${this.#m(m%10,e[m])} cx="${S.x}" cy="${S.y}" r="3"/>`,p+=`<circle data-hit${Ot({label:S.label,value:S.v,series:e[m]})} cx="${S.x}" cy="${S.y}" r="10" fill="transparent"/>`}return this.#z=e.map((m,O)=>({label:m,key:m,slot:O%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#z=null;get legendData(){return this.#z?this.#z.map(t=>({...t})):null}#ft(){if(!this.#z||!this.#z.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#z){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};x("chart-ui",hr);Q();var cr=class s extends k{static properties={for:{type:String,default:"",reflect:!0},items:{type:String,default:"",reflect:!1},shape:{type:String,default:"dot",reflect:!0},position:{type:String,default:"bottom",reflect:!0},static:{type:Boolean,default:!1,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#a()}disconnected(){this.#n()}render(){this.#s(),this.#a()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#a(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#a(){let t=this.#r();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",n=e.label??i,r=e.slot!=null?e.slot:0,o=!this.#i.has(i),a=document.createElement("badge-ui");a.setAttribute("data-row",""),a.setAttribute("role",this.static?"listitem":"button"),a.setAttribute("text",n),i&&a.setAttribute("data-key",i),o&&a.setAttribute("data-active",""),this.static||(a.setAttribute("tabindex","0"),a.setAttribute("aria-pressed",o?"true":"false"));let l=this.shape||"dot",h=document.createElement("swatch-ui");h.setAttribute("shape",l),h.setAttribute("size","sm");let c=i?`var(--color-${i}, var(--a-data-${r}))`:`var(--a-data-${r})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#o(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#o(u,i))})),this.appendChild(a)}}#o(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};x("chart-legend-ui",cr);Q();var l$=120,ur=class extends k{static properties={placement:{type:String,default:"bottom",reflect:!0},gap:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#u),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#u))))}render(){this.open?this.#r():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=at(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#a(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#u=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},l$)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#u),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#u))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};x("popover-ui",ur);Q();var dr=class extends k{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.addEventListener("toggle",this.#t)}disconnected(){this.removeEventListener("toggle",this.#t)}#t=t=>{if(this.multiple)return;let e=t.target;if(!e.open)return;let i=this.querySelectorAll("accordion-item-ui");for(let n of i)n!==e&&n.open&&(n.open=!1)}},fr=class extends k{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){if(!this.querySelector('[slot="header"]')){let t=document.createElement("div");t.setAttribute("slot","header");let e=document.createElement("span");e.setAttribute("slot","header-text"),t.appendChild(e);let i=document.createElement("icon-ui");i.setAttribute("name","caret-down"),i.setAttribute("slot","caret"),t.appendChild(i),this.prepend(t)}if(!this.querySelector('[slot="body"]')){let t=document.createElement("div");t.setAttribute("slot","body");let e=[...this.childNodes].filter(i=>i.nodeType===1?!i.hasAttribute("slot"):i.nodeType===3&&i.textContent.trim());for(let i of e)t.appendChild(i);this.appendChild(t)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e))}disconnected(){this.removeEventListener("click",this.#e),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"]');t&&(t.textContent=this.text)}#e=t=>{let e=this.querySelector('[slot="header"]');!e||!e.contains(t.target)||t.target.closest('[slot="action"], [slot="actions"], [data-no-toggle]')||(this.open=!this.open,this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{open:this.open}})))}};x("accordion-ui",dr),x("accordion-item-ui",fr);Q();var pr=class extends k{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()}}};x("divider-ui",pr);Q();var mr=class extends k{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()}};x("blockquote-ui",mr);Q();var od=[{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}],gr=class extends k{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=od.find(o=>i<=o.limit)||od[od.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()}};x("relative-time-ui",gr);Q();var Or=class extends k{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")}};x("number-format-ui",Or);Q();var ad=["Weak","Fair","Good","Strong"];function h$(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 br=class extends k{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=`
|
|
187
|
+
[{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#c(),this.#f()}get data(){return this.#t}#l=!1;#c(){if(this.#l)return;let t=this.#h();this.#t.length>t&&(console.warn(`[chart-ui] .data has ${this.#t.length} rows which exceeds the recommended perf budget of ${t}. Consider downsampling at the data layer (e.g., LTTB, bucket aggregation). Override the budget via CSS: chart-ui { --chart-perf-budget: 10000 }.`),this.#l=!0)}#h(){let t=getComputedStyle(this).getPropertyValue("--chart-perf-budget").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:5e3}connected(){if(this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",`${this.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.#w),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#P),this.addEventListener("focus",this.#E),this.addEventListener("blur",this.#R),this.addEventListener("pointerover",this.#Q),this.addEventListener("pointermove",this.#I),this.addEventListener("pointerleave",this.#Z),this.addEventListener("pointerdown",this.#D),this.addEventListener("click",this.#V),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.#f()})))}),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.#f()}#u(){let t=this.clientWidth||300,e=this.clientHeight||0,i=a$.std,n=this.#t.length||1,r=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(r/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(r,a),c=this.size||(h<150?"sm":h<300?"md":"lg"),u=c==="sm"?9:c==="md"?10:11,d=u,f=c==="sm"?8:c==="md"?9:10,p=this.hideGrid,m=p?0:u*3.2,O=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!O||p?2:u*2.2,left:m},y=r-g.left-g.right,v=Math.max(4,y/n*.6);return{width:r,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n,sizeClass:c}}#d=null;#f(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#d&&(this.#d=t.cloneNode(!0)),this.innerHTML="",this.#d&&this.appendChild(this.#d.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}this.setAttribute("data-has-data",""),this.#p();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.#H());break;case"line":({svg:n,viewBox:r}=this.#J());break;case"pie":({svg:n,viewBox:r}=this.#K());break;case"donut":({svg:n,viewBox:r}=this.#tt());break;case"radar":({svg:n,viewBox:r}=this.#et());break;case"sparkline":({svg:n,viewBox:r}=this.#it());break;case"segments":({svg:n,viewBox:r}=this.#ht());break;case"area":({svg:n,viewBox:r}=this.#st());break;case"scatter":({svg:n,viewBox:r}=this.#U());break;case"radial-bar":({svg:n,viewBox:r}=this.#Y());break;case"gauge":({svg:n,viewBox:r}=this.#nt());break;case"funnel":({svg:n,viewBox:r}=this.#rt());break;case"treemap":({svg:n,viewBox:r}=this.#ot());break;case"sankey":({svg:n,viewBox:r}=this.#at());break;case"composed":({svg:n,viewBox:r}=this.#lt());break;case"stacked-bar":({svg:n,viewBox:r}=this.#ct());break;case"grouped-bar":({svg:n,viewBox:r}=this.#ut());break;case"multi-line":({svg:n,viewBox:r}=this.#dt());break;default:({svg:n,viewBox:r}=this.#H());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#y()){let o=this.#ft();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#p(){let t=this.#X();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#m(t,e){return e?` data-slice="${t}" data-series-key="${ie(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g(t,e){return e?` data-slice="${t}" data-series-key="${ie(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#O=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#w),document.removeEventListener("pointerdown",this.#q),this.removeEventListener("keydown",this.#P),this.removeEventListener("focus",this.#E),this.removeEventListener("blur",this.#R),this.removeEventListener("pointerover",this.#Q),this.removeEventListener("pointermove",this.#I),this.removeEventListener("pointerleave",this.#Z),this.removeEventListener("pointerdown",this.#D),this.removeEventListener("click",this.#V),this.#_()}#y(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#b(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#w=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#a.delete(i):this.#a.add(i),this.#f())};#v(t){return!!t&&this.#a.has(t)}#x(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${ub(e)}`}default:return ub(e)}}#S=-1;#k(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#A(t){let e=this.#k();if(!e.length){this.#T();return}this.#S=Math.max(0,Math.min(t,e.length-1)),this.#$(),this.#M()}#$(){let t=this.#k();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#S];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#T(){this.#S=-1;for(let t of this.#k())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#M(){let t=this.#k()[this.#S];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#N(t,i)}#C(){let t=this.#k()[this.#S];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.#B(t,i)}))}#E=()=>{this.#S===-1&&this.#A(0)};#R=()=>{this.#T(),this.#L&&this.#j()};#P=t=>{let e=this.#k();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#A(this.#S+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#A(Math.max(0,this.#S-1));break;case"Home":t.preventDefault(),this.#A(0);break;case"End":t.preventDefault(),this.#A(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#C();break;case"Escape":t.preventDefault(),this.#T(),this.#L&&this.#j();break}};#L=null;#Q=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#F(e,t),this.#N(e,t))};#I=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#L&&this.#j(),this.#_();this.#F(e,t),e!==this.#L&&this.#N(e,t)};#Z=t=>{t&&t.pointerType==="touch"||(this.#_(),this.#L&&this.#j())};#D=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#L&&this.#j(),this.#_();this.#F(e,t),e!==this.#L&&this.#N(e,t),document.addEventListener("pointerdown",this.#q)};#q=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#_(),this.#L&&this.#j(),document.removeEventListener("pointerdown",this.#q)))};#V=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#B(e,t)}))};#N(t,e){this.#L=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#B(t,e)}))}#j(){this.#L=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#B(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#G(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#G(t,e){if(t==null)return null;let i=this.x,n=this.#X();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#F(t,e){if(this.#b())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#O){let O=document.createElement("div");O.setAttribute("popover","manual"),O.setAttribute("role","tooltip"),O.classList.add("chart-tooltip-popup"),document.body.appendChild(O),this.#O=O}let a=[];if(o&&a.push(`<span data-tip-role="series">${ie(o)}</span>`),i&&a.push(`<span data-tip-role="label">${ie(i)}</span>`),n!==void 0){let O=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#x(n)}${O}</span>`)}this.#O.innerHTML=a.join("");try{this.#O.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#O.offsetWidth||0,f=this.#O.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.#O.style.left=`${p}px`,this.#O.style.top=`${m}px`}#_(){if(this.#O){try{this.#O.hidePopover()}catch{}this.#O.remove(),this.#O=null}}#X(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#W(t,e,i,n,r,o){let a=r,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#x(p)}</text>`}if(n){let m=(t-a.left-a.right)/n.length,g=n.reduce((S,w)=>Math.max(S,String(w).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=n.length-1;for(let S=0;S<n.length;S++){if(S%y!==0&&S!==v||S!==v&&v-S<y)continue;let w=a.left+m*S+m/2;c+=`<text data-x-label x="${w}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${ie(n[S])}</text>`}}}return c}#H(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(v=>+(v[i]??0)),r=e.map(v=>v[this.x]??""),o=hs(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/e.length,p=f*.6,m=(f-p)/2,O=this.#W(l,h,o,r,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&n.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let S=n[v],w=a?S/a*u:0,$=c.left+f*v+m,A=c.top+u-w;O+=`<path data-bar${Ot({label:r[v],value:S})} d="${Wl($,A,p,w,this.#o())}"/>`,g&&(O+=`<text data-value x="${$+p/2}" y="${A-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(S)}</text>`)}if(y){let v=n.reduce((w,$)=>w+$,0)/n.length,S=c.top+u-(a?v/a*u:0);O+=`<line data-avg x1="${c.left}" y1="${S}" x2="${l-c.right}" y2="${S}"/>`,O+=`<text data-avg-label x="${l-c.right+2}" y="${S+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(v)}</text>`,O+=`<line data-hit${Ot({label:"Average",value:v})} x1="${c.left}" y1="${S}" x2="${l-c.right}" y2="${S}" stroke="transparent" stroke-width="12"/>`}return{svg:O,viewBox:`0 0 ${l} ${h}`}}#J(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(A=>+(A[i]??0)),r=e.map(A=>A[this.x]??""),o=hs(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#W(l,h,o,r,c,t),m=n.map((A,E)=>{let L=c.left+f*E,P=c.top+u-(a?A/a*u:0);return{x:L,y:P,v:A,label:r[E]}}),O=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${rd(m,O,g)}"/>`,p+=`<path data-line d="${ya(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,S=Math.max(v,10),w=!this.hideValues&&!y,$=!this.hideAverage&&n.length>1&&!y&&!this.hideGrid;for(let A of m)p+=`<circle data-dot cx="${A.x}" cy="${A.y}" r="${v}"/>`,p+=`<circle data-hit${Ot({label:A.label,value:A.v})} cx="${A.x}" cy="${A.y}" r="${S}" fill="transparent"/>`,w&&(p+=`<text data-value x="${A.x}" y="${A.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(A.v)}</text>`);if($){let A=n.reduce((L,P)=>L+P,0)/n.length,E=c.top+u-(a?A/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${E}" x2="${l-c.right}" y2="${E}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${E+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(A)}</text>`,p+=`<line data-hit${Ot({label:"Average",value:A})} x1="${c.left}" y1="${E}" x2="${l-c.right}" y2="${E}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#K(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d="",f=-Math.PI/2;for(let p=0;p<i.length;p++){let m=i[p]/n*Math.PI*2;if(m===0)continue;let O=f+m,g=(i[p]/n*100).toFixed(1),y=` data-slice="${p%10}"${Ot({label:r[p],value:i[p],pct:g})}`;Math.abs(m-Math.PI*2)<.001?d+=`<circle${y} cx="${h}" cy="${c}" r="${u}"/>`:d+=`<path${y} d="${o$(h,c,u,f,O)}"/>`,f=O}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#tt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=i.reduce((g,y)=>g+y,0)||1,r=t.map(g=>g[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d=u*.72,f="",p=-Math.PI/2;for(let g=0;g<i.length;g++){let y=i[g]/n*Math.PI*2;if(y===0)continue;let v=p+y,S=(i[g]/n*100).toFixed(1),w=` data-slice="${g%10}"${Ot({label:r[g],value:i[g],pct:S})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${w} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${w} d="M ${h-u} ${c} A ${u} ${u} 0 1 1 ${h+u} ${c} A ${u} ${u} 0 1 1 ${h-u} ${c} Z M ${h-d} ${c} A ${d} ${d} 0 1 0 ${h+d} ${c} A ${d} ${d} 0 1 0 ${h-d} ${c} Z" fill-rule="evenodd"/>`):f+=`<path${w} d="${nd(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),O=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#x(n)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${O}">Total</text>`,this.#z=t.map((g,y)=>({label:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#et(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(w=>+(w[e]??0)),n=t.map(w=>w[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#u(),{width:l,height:h,fontSize:c}=a,u=l/2,d=h/2,f=c*3.5,p=Math.max(40,Math.min(l,h)/2-f),m="",O=Math.PI*2/o;for(let w=1;w<=3;w++){let $=p*w/3,A="";for(let E=0;E<o;E++){let L=-Math.PI/2+O*E,P=u+$*Math.cos(L),X=d+$*Math.sin(L);A+=(E===0?"M":"L")+` ${P} ${X}`}A+=" Z",m+=`<path data-grid d="${A}"/>`}for(let w=0;w<o;w++){let $=-Math.PI/2+O*w,A=u+p*Math.cos($),E=d+p*Math.sin($);m+=`<line data-grid x1="${u}" y1="${d}" x2="${A}" y2="${E}"/>`}let g="",y=[];for(let w=0;w<o;w++){let $=-Math.PI/2+O*w,A=i[w]/r*p,E=u+A*Math.cos($),L=d+A*Math.sin($);g+=(w===0?"M":"L")+` ${E} ${L}`,y.push({px:E,py:L})}g+=" Z",m+=`<path data-radar-fill d="${g}"/>`,m+=`<path data-radar-line d="${g}"/>`;let v=Math.max(c,10);for(let w=0;w<o;w++){let{px:$,py:A}=y[w];m+=`<circle data-hit${Ot({label:n[w],value:i[w]})} cx="${$}" cy="${A}" r="${v}" fill="transparent"/>`}let S=c*1.3;for(let w=0;w<o;w++){let $=-Math.PI/2+O*w,A=u+(p+S)*Math.cos($),E=d+(p+S)*Math.sin($),L=Math.abs(Math.cos($))<.1?"middle":Math.cos($)>0?"start":"end";m+=`<text data-x-label x="${A}" y="${E}" text-anchor="${L}" dominant-baseline="central" font-size="${c}">${ie(n[w])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#it(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(y=>+(y[e]??0)),n=Math.max(...i)||1,r=Math.min(...i),o=n-r||1,a=this.clientWidth||120,l=this.clientHeight||32,h=Math.max(40,a),c=Math.max(16,l),u=h/Math.max(i.length-1,1),d=Math.max(2,Math.min(6,c*.1)),f=t.map(y=>y[this.x]??""),p=i.map((y,v)=>({x:u*v,y:c-(y-r)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),O="";O+=`<path data-area d="${rd(p,c,m)}"/>`,O+=`<path data-line d="${ya(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)O+=`<circle data-hit${Ot({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:O,viewBox:`0 0 ${h} ${c}`}}#st(){return this.#J()}#U(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(g=>+(g[i]??0)),r=e.map(g=>g[this.x]??""),o=hs(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#W(l,h,o,r,c,t),m=t.sizeClass==="sm"?2.5:4,O=Math.max(m*2,10);for(let g=0;g<n.length;g++){let y=c.left+f*g,v=c.top+u-(a?n[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${Ot({label:r[g],value:n[g]})} cx="${y}" cy="${v}" r="${O}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#Y(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=Math.max(...i)||1,o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.45),d=u*.3,f=i.length||1,p=(u-d)/f,m=Math.min(2,p*.15),O="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,S=(y+v)/2,w=v-y,$=2*Math.PI*S,A=Math.max(0,Math.min(1,i[g]/r))*$;if(O+=`<circle data-radial-track cx="${h}" cy="${c}" r="${S}" fill="none" stroke-width="${w}"/>`,A<=0)continue;let E=(i[g]/r*100).toFixed(1),L=Ot({label:n[g],value:i[g],pct:E}),P=Math.abs(A-$)<.5,X=P?"butt":"round",D=P?`${$} 0`:`${A} ${$-A}`;O+=`<circle data-slice="${g%10}"${L} data-radial-bar cx="${h}" cy="${c}" r="${S}" fill="none" stroke-width="${w}" stroke-linecap="${X}" stroke-dasharray="${D}" transform="rotate(-90 ${h} ${c})"/>`}return this.#z=t.map((g,y)=>({label:n[y],key:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:O,viewBox:`0 0 ${a} ${l}`}}#nt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(S=>+(S[e]??0)),n=i.reduce((S,w)=>S+w,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#u(),{width:h,height:c}=l,u=h/2,d=c*.68,f=Math.max(40,Math.min(h*.45,c*.6)),p=f*.72,m=(f-p)/2,O="";if(O+=`<path data-radial-track d="${nd(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let S=Math.PI+Math.PI*a,w=Ot({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});O+=`<path data-slice="0"${w} data-gauge-fill d="${nd(u,d,f,p,Math.PI,S,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return O+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#x(r)}</text>`,o!==r&&(O+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#x(o)}</text>`),{svg:O,viewBox:`0 0 ${h} ${c}`}}#rt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#u(),{width:l,height:h}=a,c=a.fontSize,u=Math.max(l*.18,80),d=c*.8,f=l-u*2,m=(h-d*2)/r,O=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<r;v++){let S=i[v],w=v<r-1?i[v+1]:i[v],$=S/o*(f/2),A=w/o*(f/2),E=d+m*v+O/2,L=d+m*(v+1)-O/2,P=(S/o*100).toFixed(1),X=Ot({label:n[v],value:S,pct:P}),D=`M ${g-$} ${E} L ${g+$} ${E} L ${g+A} ${L} L ${g-A} ${L} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${X} d="${D}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${E+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${ie(n[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${E+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#x(S)}</text>`,v>0){let _=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${E+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${_}%</text>`}}return this.#z=t.map((v,S)=>({label:n[S],value:i[S],pct:(i[S]/o*100).toFixed(1),slot:S%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#ot(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(P=>+(P[e]??0)),n=t.map(P=>P[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#u(),{width:a,height:l,fontSize:h}=o,c=i.reduce((P,X)=>P+X,0)||1,u=Array.from({length:r},(P,X)=>X).sort((P,X)=>i[X]-i[P]),d=[],f=a*l,p=u.map(P=>i[P]/c*f),m=0,O=0,g=a,y=l,v=[],S=0,w=(P,X)=>{if(P.length===0)return 1/0;let D=P.reduce((ot,gt)=>ot+gt,0),_=Math.max(...P),W=Math.min(...P),Y=X*X,et=D*D;return Math.max(Y*_/et,et/(Y*W))},$=(P,X,D,_,W,Y)=>{let et=P.reduce(($t,St)=>$t+St,0),ot=W>=Y,gt=ot?et/W:Y,ft=ot?W:et/Y,xt=0;for(let $t=0;$t<P.length;$t++){let St=P[$t]/et,_t=u[X+$t];if(ot){let Wt=St*W;d.push({i:_t,x:D+xt,y:_,w:Wt,h:gt}),xt+=Wt}else{let Wt=St*Y;d.push({i:_t,x:D,y:_+xt,w:ft,h:Wt}),xt+=Wt}}return ot?{x:D,y:_+gt,w:W,h:Y-gt}:{x:D+ft,y:_,w:W-ft,h:Y}},A=p.slice();for(;A.length>0;){v=[A[0]],S=p.length-A.length;let P=Math.min(g,y),X=1;for(;X<A.length;){let _=v.concat(A[X]);if(w(_,P)>w(v,P))break;v=_,X++}let D=$(v,S,m,O,g,y);m=D.x,O=D.y,g=D.w,y=D.h,A=A.slice(v.length)}let E="",L=2;for(let P of d){let X=(i[P.i]/c*100).toFixed(1),D=Ot({label:n[P.i],value:i[P.i],pct:X});E+=`<rect data-slice="${P.i%10}" data-treemap-tile${D} x="${P.x+L}" y="${P.y+L}" width="${Math.max(0,P.w-L*2)}" height="${Math.max(0,P.h-L*2)}" rx="${this.#o()}"/>`;let _=P.x+8,W=P.w>h*4,Y=W&&P.h>h*2.5,et=W&&!Y&&P.h>h*1.2;if(Y)E+=`<text data-treemap-label x="${_}" y="${P.y+h+4}" font-size="${h}" dominant-baseline="hanging">${ie(n[P.i])}</text>`,E+=`<text data-treemap-value x="${_}" y="${P.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#x(i[P.i])}</text>`;else if(et){let ot=P.y+P.h/2;E+=`<text data-treemap-label x="${_}" y="${ot}" font-size="${h}" dominant-baseline="central">${ie(n[P.i])}</text>`}}return this.#z=t.map((P,X)=>({label:n[X],value:i[X],pct:(i[X]/c*100).toFixed(1),slot:X%10})),{svg:E,viewBox:`0 0 ${a} ${l}`}}#at(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let S of t){let w=S.source??S.from??"",$=S.target??S.to??"",A=+(S.value??S.v??0);e.has(w)||e.set(w,{name:w,flow:0}),i.has($)||i.set($,{name:$,flow:0}),e.get(w).flow+=A,i.get($).flow+=A}let n=this.#u(),{width:r,height:o,fontSize:a}=n,l=Math.max(8,r*.03),h=l+a*5,c=[...e.values()].reduce((S,w)=>S+w.flow,0)||1,u=[...i.values()].reduce((S,w)=>S+w.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),O=o-d*(p.length-1),g=0;for(let S of f){let w=S.flow/c*m;S.y0=g,S.y1=g+w,S.cursor=g,g+=w+d}g=0;for(let S of p){let w=S.flow/u*O;S.y0=g,S.y1=g+w,S.cursor=g,g+=w+d}let y="",v=Math.min(this.#o(),l/2);f.forEach((S,w)=>{y+=`<rect data-sankey-node data-slice="${w%10}" x="${h-l}" y="${S.y0}" width="${l}" height="${S.y1-S.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(S.y0+S.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${ie(S.name)}</text>`}),p.forEach((S,w)=>{y+=`<rect data-sankey-node data-slice="${(f.length+w)%10}" x="${r-h}" y="${S.y0}" width="${l}" height="${S.y1-S.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${r-h+l+6}" y="${(S.y0+S.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${ie(S.name)}</text>`});for(let S of t){let w=e.get(S.source??S.from??""),$=i.get(S.target??S.to??"");if(!w||!$)continue;let A=+(S.value??S.v??0);if(A<=0)continue;let E=A/c*m,L=A/u*O,P=w.cursor,X=P+E,D=$.cursor,_=D+L;w.cursor+=E,$.cursor+=L;let W=h,Y=r-h,et=(W+Y)/2,ot=Ot({label:`${w.name} \u2192 ${$.name}`,value:A}),gt=`M ${W} ${P} C ${et} ${P}, ${et} ${D}, ${Y} ${D} L ${Y} ${_} C ${et} ${_}, ${et} ${X}, ${W} ${X} Z`;y+=`<path data-sankey-link${ot} d="${gt}"/>`}return{svg:y,viewBox:`0 0 ${r} ${o}`}}#lt(){let t=this.#u(),e=this.#t,i=this.#X(),n=i[0]||"bar",r=i[1]||"line",o=e.map($=>$[this.x]??""),a=e.map($=>+($[n]??0)),l=e.map($=>+($[r]??0)),h=[...a,...l],c=hs(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,O=d-p.left-p.right,g=O/e.length,y=g*.6,v=(g-y)/2,S=O/Math.max(e.length-1,1),w=this.#W(d,f,c,o,p,t);if(!this.#v(n))for(let $=0;$<e.length;$++){let A=a[$],E=u?A/u*m:0,L=p.left+g*$+v,P=p.top+m-E;w+=`<path${this.#m(0,n)}${Ot({label:o[$],value:A,series:n})} d="${Wl(L,P,y,E,this.#o())}"/>`}if(!this.#v(r)){let $=l.map((E,L)=>({x:p.left+g*L+g/2,y:p.top+m-(u?E/u*m:0),v:E,label:o[L]})),A=Math.max(0,Math.min(1,this.smooth));w+=`<path data-line${this.#g(1,r)} d="${ya($,A)}"/>`;for(let E of $)w+=`<circle data-dot${this.#m(1,r)} cx="${E.x}" cy="${E.y}" r="3"/>`,w+=`<circle data-hit${Ot({label:E.label,value:E.v,series:r})} cx="${E.x}" cy="${E.y}" r="10" fill="transparent"/>`}return this.#z=[{label:n,key:n,slot:0},{label:r,key:r,slot:1}],{svg:w,viewBox:`0 0 ${d} ${f}`}}#ht(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#o(),l/2),c=Math.max(0,parseFloat(o.getPropertyValue("--chart-segments-gap"))||2),u=[],d=0;for(let p=0;p<i.length;p++){let m=p===i.length-1?a:Math.round((d*n+i[p]*a)/n),O=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/n*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/n*a;u.push({x:g,w:Math.max(0,O-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:O}=u[p];if(O<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,O-(y?0:c)),S=(i[p]/n*100).toFixed(1),w=Ot({label:r[p],value:i[p],pct:S}),$=`<title>${ie(r[p])}: ${i[p]} (${S}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${w} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${$}</rect>`;else{let A=h,E=m+v,L;g?L=`M ${m+A} 0 H ${E} V ${l} H ${m+A} A ${A} ${A} 0 0 1 ${m} ${l-A} V ${A} A ${A} ${A} 0 0 1 ${m+A} 0 Z`:L=`M ${m} 0 H ${E-A} A ${A} ${A} 0 0 1 ${E} ${A} V ${l-A} A ${A} ${A} 0 0 1 ${E-A} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${w} d="${L}">${$}</path>`}}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#ct(){let t=this.#t,e=this.#X(),i=t.map(g=>g[this.x]??""),n=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),r=hs(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=f*.6,m=(f-p)/2,O=this.#W(l,h,r,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let S=0;S<v;S++){if(this.#v(e[S]))continue;let w=+(t[g][e[S]]??0),$=o?w/o*u:0;if($<=0){y-=$;continue}y-=$;let A=c.left+f*g+m,E=y,L=$,P=S===v-1,X=this.#o(),D=`${this.#m(S%10,e[S])}${Ot({label:i[g],value:w,series:e[S]})}`;P?O+=`<path${D} d="${Wl(A,E,p,L,X)}"/>`:O+=`<rect${D} x="${A}" y="${E}" width="${p}" height="${L}"/>`}}return this.#z=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:O,viewBox:`0 0 ${l} ${h}`}}#ut(){let t=this.#t,e=this.#X(),i=t.map(v=>v[this.x]??""),n=t.flatMap(v=>e.map(S=>+(v[S]??0))),r=hs(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=3,m=f*.7,O=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#W(l,h,r,i,c,a);for(let v=0;v<t.length;v++)for(let S=0;S<e.length;S++){if(this.#v(e[S]))continue;let w=+(t[v][e[S]]??0),$=o?w/o*u:0,A=c.left+f*v+g+(O+p)*S,E=c.top+u-$;y+=`<path${this.#m(S%10,e[S])}${Ot({label:i[v],value:w,series:e[S]})} d="${Wl(A,E,O,$,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${A+O/2}" y="${E-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#x(w)}</text>`)}return this.#z=e.map((v,S)=>({label:v,key:v,slot:S%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#dt(){let t=this.#t,e=this.#X(),i=t.map(m=>m[this.x]??""),n=t.flatMap(m=>e.map(O=>+(m[O]??0))),r=hs(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(t.length-1,1),p=this.#W(l,h,r,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(S=>+(S[e[m]]??0)).map((S,w)=>{let $=c.left+f*w,A=c.top+u-(o?S/o*u:0);return{x:$,y:A,v:S,label:i[w]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#m(m%10,e[m])} d="${rd(g,y,v)}"/>`,p+=`<path data-line${this.#g(m%10,e[m])} d="${ya(g,v)}"/>`;for(let S of g)p+=`<circle data-dot${this.#m(m%10,e[m])} cx="${S.x}" cy="${S.y}" r="3"/>`,p+=`<circle data-hit${Ot({label:S.label,value:S.v,series:e[m]})} cx="${S.x}" cy="${S.y}" r="10" fill="transparent"/>`}return this.#z=e.map((m,O)=>({label:m,key:m,slot:O%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#z=null;get legendData(){return this.#z?this.#z.map(t=>({...t})):null}#ft(){if(!this.#z||!this.#z.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#z){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};x("chart-ui",hr);Q();var cr=class s extends k{static properties={for:{type:String,default:"",reflect:!0},items:{type:String,default:"",reflect:!1},shape:{type:String,default:"dot",reflect:!0},position:{type:String,default:"bottom",reflect:!0},static:{type:Boolean,default:!1,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#a()}disconnected(){this.#n()}render(){this.#s(),this.#a()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#a(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#a(){let t=this.#r();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",n=e.label??i,r=e.slot!=null?e.slot:0,o=!this.#i.has(i),a=document.createElement("badge-ui");a.setAttribute("data-row",""),a.setAttribute("role",this.static?"listitem":"button"),a.setAttribute("text",n),i&&a.setAttribute("data-key",i),o&&a.setAttribute("data-active",""),this.static||(a.setAttribute("tabindex","0"),a.setAttribute("aria-pressed",o?"true":"false"));let l=this.shape||"dot",h=document.createElement("swatch-ui");h.setAttribute("shape",l),h.setAttribute("size","sm");let c=i?`var(--color-${i}, var(--a-data-${r}))`:`var(--a-data-${r})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#o(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#o(u,i))})),this.appendChild(a)}}#o(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};x("chart-legend-ui",cr);Q();var l$=120,ur=class extends k{static properties={placement:{type:String,default:"bottom",reflect:!0},gap:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#u),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#u))))}render(){this.open?this.#r():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=at(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#c)}))}}#a(){this.#t?.(),this.#t=null;let t=this.#s??this.querySelector('[slot="content"]');if(t?.matches(":popover-open"))try{t.hidePopover()}catch{}this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#u=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},l$)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#u),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#u))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};x("popover-ui",ur);Q();var dr=class extends k{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.addEventListener("toggle",this.#t)}disconnected(){this.removeEventListener("toggle",this.#t)}#t=t=>{if(this.multiple)return;let e=t.target;if(!e.open)return;let i=this.querySelectorAll("accordion-item-ui");for(let n of i)n!==e&&n.open&&(n.open=!1)}},fr=class extends k{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){if(!this.querySelector('[slot="header"]')){let t=document.createElement("div");t.setAttribute("slot","header");let e=document.createElement("span");e.setAttribute("slot","header-text"),t.appendChild(e);let i=document.createElement("icon-ui");i.setAttribute("name","caret-down"),i.setAttribute("slot","caret"),t.appendChild(i),this.prepend(t)}if(!this.querySelector('[slot="body"]')){let t=document.createElement("div");t.setAttribute("slot","body");let e=[...this.childNodes].filter(i=>i.nodeType===1?!i.hasAttribute("slot"):i.nodeType===3&&i.textContent.trim());for(let i of e)t.appendChild(i);this.appendChild(t)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e))}disconnected(){this.removeEventListener("click",this.#e),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"]');t&&(t.textContent=this.text)}#e=t=>{let e=this.querySelector('[slot="header"]');!e||!e.contains(t.target)||t.target.closest('[slot="action"], [slot="actions"], [data-no-toggle]')||(this.open=!this.open,this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{open:this.open}})))}};x("accordion-ui",dr),x("accordion-item-ui",fr);Q();var pr=class extends k{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()}}};x("divider-ui",pr);Q();var mr=class extends k{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()}};x("blockquote-ui",mr);Q();var od=[{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}],gr=class extends k{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=od.find(o=>i<=o.limit)||od[od.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()}};x("relative-time-ui",gr);Q();var Or=class extends k{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")}};x("number-format-ui",Or);Q();var ad=["Weak","Fair","Good","Strong"];function h$(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 br=class extends k{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=`
|
|
188
188
|
<div slot="bar" aria-hidden="true">
|
|
189
189
|
<div slot="segment" data-i="0"></div>
|
|
190
190
|
<div slot="segment" data-i="1"></div>
|
|
@@ -198,9 +198,9 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
198
198
|
</svg>`}Q();var vr=class extends k{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"},margin:{type:Number,default:4,reflect:!0},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("data-error"),t;if(!this.value)return this.removeAttribute("data-error"),null;try{let e=yb(this.value,{errorCorrection:this.errorCorrection||"M"});return this.removeAttribute("data-error"),e.matrix}catch(e){return this.setAttribute("data-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.margin}|${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=vb(e,{cellSize:8,margin:Number.isFinite(this.margin)?this.margin: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)))}};x("qr-code-ui",vr);Q();var xr=class extends k{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=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.#a))}disconnected(){this.#t?.removeEventListener("press",this.#a),this.#t=null,this.#e=!1}render(){if(!this.#t)return;let t=Math.max(1,Math.min(this.page,this.total)),e=Math.max(1,this.total),i=Math.max(0,this.siblings),n=this.#i(t,e,i);this.reconcile(this.#t,n,r=>r.key,(r,o,a)=>a?(this.#r(a,r,t),a):this.#n(r,t))}#i(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}#s(){return this.variant==="button"?"outline":"ghost"}#n(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 i.setAttribute("size",this.size),t.type==="prev"?(i.setAttribute("data-prev",""),i.setAttribute("icon","caret-left"),i.setAttribute("aria-label","Previous page")):t.type==="next"?(i.setAttribute("data-next",""),i.setAttribute("icon","caret-right"),i.setAttribute("aria-label","Next page")):(i.setAttribute("data-page",""),i.dataset.value=String(t.value),i.setAttribute("text",String(t.value)),i.setAttribute("aria-label",`Page ${t.value}`)),this.#r(i,t,e),i}#r(t,e,i){e.type!=="ellipsis"&&(t.setAttribute("size",this.size),e.type==="prev"?(t.setAttribute("variant",this.#s()),i<=1?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0"))):e.type==="next"?(t.setAttribute("variant",this.#s()),i>=this.total?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0"))):(t.dataset.value=String(e.value),t.setAttribute("text",String(e.value)),t.setAttribute("aria-label",`Page ${e.value}`),e.value===i?(t.setAttribute("variant","primary"),t.setAttribute("data-active",""),t.setAttribute("aria-current","page")):(t.setAttribute("variant",this.#s()),t.removeAttribute("data-active"),t.removeAttribute("aria-current"))))}#a=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}})))}};x("pagination-ui",xr);Q();var pR=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),mR={js:"javascript",md:"markdown",yml:"yaml"};function Gg(s){if(!s)return"";let t=String(s).toLowerCase();return mR[t]??t}var no=class s extends k{static formAssociated=!0;static properties={language:{type:String,default:"",reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},text:{type:String,default:"",reflect:!0},lineNumbers:{type:Boolean,default:!1,reflect:!0,attribute:"line-numbers"},editable:{type:Boolean,default:!1,reflect:!0},bare:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=0;#n=!1;#r=null;#a="";#o=null;#l=()=>this.#y();connected(){this.#s+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#c(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#l);let t=Gg(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(pR.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=Gg(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(`
|
|
199
199
|
`).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(`
|
|
200
200
|
`),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(`
|
|
201
|
-
`):e}async#u(){if(this.#n||this.#i)return;let t=this.#s,e=Gg(this.language);this.#n=!0;try{let i=await Promise.resolve().then(()=>(Ug(),Fg)),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:O,lintGutter:g,jsonLinter:y}=t,v=this.querySelector(":scope > pre"),S=v?v.querySelector("code")?.textContent??"":"",w=this.text||S||"";this.#a=w;let $=document.createElement("div");$.setAttribute("data-cm-mount",""),v?v.replaceWith($):this.appendChild($);let A=[m,h(O)];this.editable&&A.push(c(),p.of([{key:"Mod-s",run:E=>(this.#
|
|
201
|
+
`):e}async#u(){if(this.#n||this.#i)return;let t=this.#s,e=Gg(this.language);this.#n=!0;try{let i=await Promise.resolve().then(()=>(Ug(),Fg)),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:O,lintGutter:g,jsonLinter:y}=t,v=this.querySelector(":scope > pre"),S=v?v.querySelector("code")?.textContent??"":"",w=this.text||S||"";this.#a=w;let $=document.createElement("div");$.setAttribute("data-cm-mount",""),v?v.replaceWith($):this.appendChild($);let A=[m,h(O)];this.editable&&A.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 L=E.state.doc.toString();this.#m(L),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:L}}))}),r.domEventHandlers({focus:(E,L)=>(this.#r=L.state.doc.toString(),!1),blur:(E,L)=>{let P=L.state.doc.toString();return this.#r!==null&&P!==this.#r&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:P}})),this.#r=null,!1}})),this.#o=new o,A.push(this.#o.of(this.#f(r,n))),e&&A.push(e),this.lineNumbers&&A.push(a()),this.placeholder&&A.push(l(this.placeholder)),this.editable&&i==="json"&&A.push(y,g()),this.#i=new r({parent:$,state:n.create({doc:w,extensions:A})}),this.editable&&this.#m(w)}#f(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#p(){if(!this.#i||!this.#o)return;let t=await Promise.resolve().then(()=>(Ug(),Fg));this.#i.dispatch({effects:this.#o.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.#a}}):this.text=this.#a}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??"")}#y(){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)}}};x("code-ui",no);Q();function r1(s){let t=s.replace(/=""(?=[\s/>])/g,"").replace(/\t/g," ").split(`
|
|
202
202
|
`);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(`
|
|
203
|
-
`)}var ro=class extends k{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=r1(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=r1(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=()=>requestAnimationFrame(this.#i);#n(){this.#s(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(this.#s),this.#t.observe(this))}disconnected(){this.#t?.disconnect()}};x("preview-ui",ro);Q();var oo=class extends k{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;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#r),this.#t=!1}render(){if(!this.selectable){for(let n of this.#e())n.removeAttribute("aria-selected"),n.removeAttribute("tabindex");return}let t=this.selectedKey||"",e=this.#e(),i=null;for(let n of e){let r=this.#i(n),o=r&&r===t;n.setAttribute("aria-selected",o?"true":"false"),n.setAttribute("tabindex",o?"0":"-1"),o&&(i=n)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#e(){return[...this.children].filter(t=>t.tagName==="LIST-ITEM-UI"||t.getAttribute?.("role")==="listitem")}#i(t){return t.id||t.getAttribute("data-key")||""}#s(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.#e()].find(r=>this.#i(r)===t)?.focus?.())}#n=t=>{if(!this.selectable)return;let e=t.target.closest?.('[role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#i(e);i&&this.#s(i)};#r=t=>{if(!this.selectable)return;let e=this.#e();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.#i(e[n]);o&&this.#s(o);return}default:return}r!==n&&(t.preventDefault(),e[r]?.focus?.())}},ao=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){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(){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()}};x("list-ui",oo),x("list-item-ui",ao);Q();var lo=class extends k{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;#a=new Map;#o=new Map;#l=1e5;#c=-1;#h=-1;#u=0;#d=!0;#f=null;#p=null;#m=()=>{this.#E();let t=this.#A();this.#u=t,this.#d=this.#$()};#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.#k()||this.estimatedSize||48,i=this.#w(),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.#A();this.#P(r+n)};#y=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.#o.get(r)!==a&&(this.#o.set(r,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:r,height:a},bubbles:!0})),e=!0)}e&&(this.#Z(),this.#M(),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.#y,{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.#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.#a.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#d||this.#$());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.#M(),this.#E(),e&&this.scrollToBottom(),this.#d=this.#$()}set renderRow(t){this.#n=typeof t=="function"?t:null,this.#a.clear(),this.#E()}get renderRow(){return this.#n}set keyFn(t){this.#r=typeof t=="function"?t:((e,i)=>i),this.#a.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.#x(r),a=this.#w(),l=this.#v(r),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#P(Math.max(0,h),e)}scrollToTop(){this.#P(0)}scrollToBottom(){let t=this.#S();this.#P(Math.max(0,t))}getVisibleRange(){return{startIndex:this.#c,endIndex:this.#h}}invalidateMeasurements(t=0){if(t<=0)this.#o.clear();else for(let e of[...this.#o.keys()])e>=t&&this.#o.delete(e);this.#M(),this.#E()}#k(){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}#v(t){let e=this.#k();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#x(t){let e=this.#k();if(e>0)return t*e;let i=0;for(let n=0;n<t;n++)i+=this.#v(n);return i}#S(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#k();if(i>0)return e*i;let n=0,r=this.estimatedSize||48;for(let o=0;o<e;o++)n+=this.#o.get(o)??r;return n}#w(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#A(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#P(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#$(){let t=this.#A(),e=this.#w(),i=this.#S();return t+e>=i-1}#M(){if(!this.#t)return;let t=this.#S();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")}#Q(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#w(),n=this.#A(),r=this.#k(),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.#o.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.#o.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.#Q(),r=this.#x(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${r}px)`:this.#e.style.transform=`translateY(${r}px)`,this.loading?this.#C(n-i):this.#R(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})))}#R(t,e,i){if(!this.#e)return;let n=new Set,r=this.#n??this.#T();for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l);n.add(c);let u=this.#a.get(c);u?(u.dataset.index=String(l),u.setAttribute("aria-rowindex",String(l+1))):(u=this.#L(h,l,r),this.#a.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l),u=this.#a.get(c);u&&o.push(u)}for(let[l,h]of this.#a)n.has(l)||(this.#f?.unobserve(h),h.parentElement===this.#e&&h.remove(),this.#a.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)}#C(t){if(!this.#e)return;this.#e.replaceChildren(),this.#a.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)}}#L(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(r instanceof Node)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}#T(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#D==null&&(this.#D=t.innerHTML);let e=this.#D;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?"":gR(String(h))}),o=document.createElement("template");return o.innerHTML=r,o.content.cloneNode(!0)}}#D=null;#Z(){if(this.#o.size<=this.#l)return;let t=this.#o.size-this.#l,e=0;for(let i of this.#o.keys())if(this.#o.delete(i),++e>=t)break}};function gR(s){return s.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}x("list-window-ui",lo);Q();var ho=class extends k{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},gap:{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.#a():this.#o()}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.#y),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#a(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#r(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui");for(let n of i)e.contains(n)||e.appendChild(n);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=at(t,e,{placement:this.placement,gap:this.gap}),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)})}#o(){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");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)};#y=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#y),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},co=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.closest('[role="menu"], [role="menubar"]')?(this.setAttribute("role","menuitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")):(this.removeAttribute("role"),this.removeAttribute("tabindex")),this.#s(),this.#n()}#t(t){return t.dataset.menuItemStamped="1",t}#e(t){return t?.dataset?.menuItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}#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)}}}#n(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let i=this.#t(document.createElement("icon-ui"));i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text),this.#n()}},uo=class extends k{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}};x("menu-ui",ho),x("menu-item-ui",co),x("menu-divider-ui",uo);Q();var o1=500,fo=class extends k{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:o1,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#n=null;#r=null;#a=null;#o=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#k(),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.#y(t,e)}}close(t="manual"){this.#b(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#u),t.addEventListener("touchstart",this.#d,{passive:!0}),t.addEventListener("touchend",this.#f),t.addEventListener("touchcancel",this.#f),t.addEventListener("keydown",this.#p)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#u),t.removeEventListener("touchstart",this.#d),t.removeEventListener("touchend",this.#f),t.removeEventListener("touchcancel",this.#f),t.removeEventListener("keydown",this.#p);this.#s=[]}#h(){if(this.for)try{return[...document.querySelectorAll(this.for)]}catch(t){return console.warn(`[context-menu-ui] invalid [for] selector: ${this.for}`,t),[]}for(let t of this.children){let e=t.tagName.toLowerCase();if(e!=="menu-item-ui"&&e!=="menu-divider-ui")return[t]}return[]}#u=t=>{t.defaultPrevented||this.#m()&&(t.preventDefault(),this.#r=t.currentTarget,this.#y(t.clientX,t.clientY))};#d=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#n=setTimeout(()=>{this.#r=t.currentTarget,this.#y(e.clientX,e.clientY)},this.longPressMs??o1))};#f=()=>{this.#n&&clearTimeout(this.#n),this.#n=null};#p=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#m())return;t.preventDefault(),this.#r=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#m(){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.#S),document.body.appendChild(t),this.#t=t,t}#g(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}#y(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.#g(t,e);this.#i?.(),this.#i=at(n,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#v();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}}))}#b(t="manual"){if(this.open){this.open=!1,this.#k(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#r?.focus?.()}catch{}}}#k(){this.#x(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#v(){this.#a=t=>{this.#t?.contains(t.target)||this.#b("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#b("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#x(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#S=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.#b("select")}};x("context-menu-ui",fo);Q();var po=class extends k{static properties={};static template=()=>null};x("visually-hidden-ui",po);Q();var mo=class extends k{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})=>It`<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})})}};x("skip-nav-ui",mo);Q();var go=class extends k{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};x("mark-ui",go);var Oo=class extends Z{static properties={...Z.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.#a))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#n),this.removeEventListener("focus",this.#r),this.removeEventListener("blur",this.#a),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.#o()}))}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=()=>{};#a=()=>{if(this.editing){if(this.#i){this.#i=!1;return}this.commit==="blur"?this.commitEdit():this.commit==="enter"&&this.cancelEdit()}};#o(){let t=document.createRange();t.selectNodeContents(this);let e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(t))}};x("inline-edit-ui",Oo);Q();var bo=class extends k{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.#o()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#a.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.#a.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.#a.length}}))}skip(){if(!this.active)return;let t=this.#a.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.#a.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#a(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#o(){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.#a[this.step];if(!t)return;let e=this.#a.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=`
|
|
203
|
+
`)}var ro=class extends k{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=r1(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=r1(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=()=>requestAnimationFrame(this.#i);#n(){this.#s(),typeof ResizeObserver<"u"&&(this.#t=new ResizeObserver(this.#s),this.#t.observe(this))}disconnected(){this.#t?.disconnect()}};x("preview-ui",ro);Q();var oo=class extends k{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;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#r),this.#t=!1}render(){if(!this.selectable){for(let n of this.#e())n.removeAttribute("aria-selected"),n.removeAttribute("tabindex");return}let t=this.selectedKey||"",e=this.#e(),i=null;for(let n of e){let r=this.#i(n),o=r&&r===t;n.setAttribute("aria-selected",o?"true":"false"),n.setAttribute("tabindex",o?"0":"-1"),o&&(i=n)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#e(){return[...this.children].filter(t=>t.tagName==="LIST-ITEM-UI"||t.getAttribute?.("role")==="listitem")}#i(t){return t.id||t.getAttribute("data-key")||""}#s(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.#e()].find(r=>this.#i(r)===t)?.focus?.())}#n=t=>{if(!this.selectable)return;let e=t.target.closest?.('[role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#i(e);i&&this.#s(i)};#r=t=>{if(!this.selectable)return;let e=this.#e();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.#i(e[n]);o&&this.#s(o);return}default:return}r!==n&&(t.preventDefault(),e[r]?.focus?.())}},ao=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){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(){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()}};x("list-ui",oo),x("list-item-ui",ao);Q();var lo=class extends k{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;#a=new Map;#o=new Map;#l=1e5;#c=-1;#h=-1;#u=0;#d=!0;#f=null;#p=null;#m=()=>{this.#E();let t=this.#A();this.#u=t,this.#d=this.#T()};#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.#w()||this.estimatedSize||48,i=this.#k(),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.#A();this.#$(r+n)};#y=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.#o.get(r)!==a&&(this.#o.set(r,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:r,height:a},bubbles:!0})),e=!0)}e&&(this.#Z(),this.#M(),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.#y,{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.#a.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#d||this.#T());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.#M(),this.#E(),e&&this.scrollToBottom(),this.#d=this.#T()}set renderRow(t){this.#n=typeof t=="function"?t:null,this.#a.clear(),this.#E()}get renderRow(){return this.#n}set keyFn(t){this.#r=typeof t=="function"?t:((e,i)=>i),this.#a.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.#x(r),a=this.#k(),l=this.#v(r),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#$(Math.max(0,h),e)}scrollToTop(){this.#$(0)}scrollToBottom(){let t=this.#S();this.#$(Math.max(0,t))}getVisibleRange(){return{startIndex:this.#c,endIndex:this.#h}}invalidateMeasurements(t=0){if(t<=0)this.#o.clear();else for(let e of[...this.#o.keys()])e>=t&&this.#o.delete(e);this.#M(),this.#E()}#w(){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}#v(t){let e=this.#w();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#x(t){let e=this.#w();if(e>0)return t*e;let i=0;for(let n=0;n<t;n++)i+=this.#v(n);return i}#S(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#w();if(i>0)return e*i;let n=0,r=this.estimatedSize||48;for(let o=0;o<e;o++)n+=this.#o.get(o)??r;return n}#k(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#A(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#$(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#T(){let t=this.#A(),e=this.#k(),i=this.#S();return t+e>=i-1}#M(){if(!this.#t)return;let t=this.#S();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")}#C(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#k(),n=this.#A(),r=this.#w(),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.#o.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.#o.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.#C(),r=this.#x(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${r}px)`:this.#e.style.transform=`translateY(${r}px)`,this.loading?this.#P(n-i):this.#R(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})))}#R(t,e,i){if(!this.#e)return;let n=new Set,r=this.#n??this.#Q();for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l);n.add(c);let u=this.#a.get(c);u?(u.dataset.index=String(l),u.setAttribute("aria-rowindex",String(l+1))):(u=this.#L(h,l,r),this.#a.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l),u=this.#a.get(c);u&&o.push(u)}for(let[l,h]of this.#a)n.has(l)||(this.#f?.unobserve(h),h.parentElement===this.#e&&h.remove(),this.#a.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)}#P(t){if(!this.#e)return;this.#e.replaceChildren(),this.#a.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)}}#L(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(r instanceof Node)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}#Q(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#I==null&&(this.#I=t.innerHTML);let e=this.#I;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?"":gR(String(h))}),o=document.createElement("template");return o.innerHTML=r,o.content.cloneNode(!0)}}#I=null;#Z(){if(this.#o.size<=this.#l)return;let t=this.#o.size-this.#l,e=0;for(let i of this.#o.keys())if(this.#o.delete(i),++e>=t)break}};function gR(s){return s.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}x("list-window-ui",lo);Q();var ho=class extends k{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},gap:{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.#a():this.#o()}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.#y),t.addEventListener("click",this.#p),t.addEventListener("keydown",this.#m),this.appendChild(t),this.#e=t,t}#a(){let t=this.querySelector('[slot="trigger"]');if(!t)return;let e=this.#r(),i=this.querySelectorAll("menu-item-ui, menu-divider-ui");for(let n of i)e.contains(n)||e.appendChild(n);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=at(t,e,{placement:this.placement,gap:this.gap}),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)})}#o(){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");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)};#y=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#y),this.#e.removeEventListener("click",this.#p),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},co=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.closest('[role="menu"], [role="menubar"]')?(this.setAttribute("role","menuitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")):(this.removeAttribute("role"),this.removeAttribute("tabindex")),this.#s(),this.#n()}#t(t){return t.dataset.menuItemStamped="1",t}#e(t){return t?.dataset?.menuItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}#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)}}}#n(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let i=this.#t(document.createElement("icon-ui"));i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text),this.#n()}},uo=class extends k{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}};x("menu-ui",ho),x("menu-item-ui",co),x("menu-divider-ui",uo);Q();var o1=500,fo=class extends k{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:o1,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#n=null;#r=null;#a=null;#o=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.#y(t,e)}}close(t="manual"){this.#b(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#u),t.addEventListener("touchstart",this.#d,{passive:!0}),t.addEventListener("touchend",this.#f),t.addEventListener("touchcancel",this.#f),t.addEventListener("keydown",this.#p)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#u),t.removeEventListener("touchstart",this.#d),t.removeEventListener("touchend",this.#f),t.removeEventListener("touchcancel",this.#f),t.removeEventListener("keydown",this.#p);this.#s=[]}#h(){if(this.for)try{return[...document.querySelectorAll(this.for)]}catch(t){return console.warn(`[context-menu-ui] invalid [for] selector: ${this.for}`,t),[]}for(let t of this.children){let e=t.tagName.toLowerCase();if(e!=="menu-item-ui"&&e!=="menu-divider-ui")return[t]}return[]}#u=t=>{t.defaultPrevented||this.#m()&&(t.preventDefault(),this.#r=t.currentTarget,this.#y(t.clientX,t.clientY))};#d=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#n=setTimeout(()=>{this.#r=t.currentTarget,this.#y(e.clientX,e.clientY)},this.longPressMs??o1))};#f=()=>{this.#n&&clearTimeout(this.#n),this.#n=null};#p=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#m())return;t.preventDefault(),this.#r=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#m(){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.#S),document.body.appendChild(t),this.#t=t,t}#O(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}#y(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.#O(t,e);this.#i?.(),this.#i=at(n,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#v();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}}))}#b(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.#x(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#v(){this.#a=t=>{this.#t?.contains(t.target)||this.#b("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#b("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#x(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#S=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.#b("select")}};x("context-menu-ui",fo);Q();var po=class extends k{static properties={};static template=()=>null};x("visually-hidden-ui",po);Q();var mo=class extends k{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})=>It`<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})})}};x("skip-nav-ui",mo);Q();var go=class extends k{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};x("mark-ui",go);var Oo=class extends Z{static properties={...Z.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.#a))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#n),this.removeEventListener("focus",this.#r),this.removeEventListener("blur",this.#a),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.#o()}))}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=()=>{};#a=()=>{if(this.editing){if(this.#i){this.#i=!1;return}this.commit==="blur"?this.commitEdit():this.commit==="enter"&&this.cancelEdit()}};#o(){let t=document.createRange();t.selectNodeContents(this);let e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(t))}};x("inline-edit-ui",Oo);Q();var bo=class extends k{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.#o()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#a.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.#a.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.#a.length}}))}skip(){if(!this.active)return;let t=this.#a.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.#a.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#a(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#o(){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.#a[this.step];if(!t)return;let e=this.#a.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=`
|
|
204
204
|
<div data-tour-header>
|
|
205
205
|
<span data-tour-indicator>${h}</span>
|
|
206
206
|
<span></span>
|
|
@@ -214,7 +214,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
214
214
|
<button-ui data-tour-next variant="primary" size="sm" text="${i?"Done":"Next \u2192"}"></button-ui>
|
|
215
215
|
</div>
|
|
216
216
|
</div>
|
|
217
|
-
`;try{this.#e.showPopover()}catch{}this.#i?.(),l?this.#i=at(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}}}},yo=class extends k{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 OR(s){return String(s??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}x("tour-ui",bo),x("tour-step-ui",yo);Q();var a1="data-toolbar-spillover",bR="data-toolbar-spillover-menu",l1=8,wu="data-toolbar-spillover-label";function h1(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function yR(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function vR(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(wu)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||yR(e.getAttribute("icon"));i&&(e.setAttribute(wu,""),e.setAttribute("text",i))}}function xR(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(wu)&&(e.removeAttribute(wu),e.removeAttribute("text"))}function c1(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,n=parseFloat(e.marginRight)||0;return t.width+i+n}var vo=class extends k{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;#a=!1;#o=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#c(),this.#t=new ResizeObserver(()=>this.#
|
|
217
|
+
`;try{this.#e.showPopover()}catch{}this.#i?.(),l?this.#i=at(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}}}},yo=class extends k{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 OR(s){return String(s??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}x("tour-ui",bo),x("tour-step-ui",yo);Q();var a1="data-toolbar-spillover",bR="data-toolbar-spillover-menu",l1=8,wu="data-toolbar-spillover-label";function h1(s){return s?.tagName&&s.tagName.toLowerCase()==="divider-ui"}function yR(s){return s?s.split("-").filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(" "):""}function vR(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t){if(e.hasAttribute(wu)||e.getAttribute("text"))continue;let i=e.getAttribute("aria-label")||yR(e.getAttribute("icon"));i&&(e.setAttribute(wu,""),e.setAttribute("text",i))}}function xR(s){let t=s.matches?.("button-ui")?[s]:Array.from(s.querySelectorAll?.("button-ui")||[]);for(let e of t)e.hasAttribute(wu)&&(e.removeAttribute(wu),e.removeAttribute("text"))}function c1(s){let t=s.getBoundingClientRect(),e=getComputedStyle(s),i=parseFloat(e.marginLeft)||0,n=parseFloat(e.marginRight)||0;return t.width+i+n}var vo=class extends k{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;#a=!1;#o=null;#l=null;connected(){this.setAttribute("role","toolbar"),this.#c(),this.#t=new ResizeObserver(()=>this.#O()),this.#t.observe(this),this.#e=new MutationObserver(()=>{this.#r||this.#O()}),this.#y(),this.#O()}disconnected(){this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.#a=!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(a1,""),t.setAttribute("aria-label","More actions"),t.setAttribute("aria-haspopup","menu"),t.hidden=!0;let e=document.createElement("div");e.setAttribute(bR,""),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=at(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(`[${a1}]`)||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.#a||(this.#a=!0,this.#o=requestAnimationFrame(()=>{this.#o=null,this.#a=!1,this.isConnected&&this.#w()}))}#y(){this.#e?.observe(this,{childList:!0})}#b(){this.#e&&(this.#e.disconnect(),this.#e.takeRecords())}#w(){if(!this.isConnected)return;let t=this.#i,e=this.#s;if(!(!t||!e)){this.#r=!0,this.#b();try{for(;e.firstChild;)xR(e.firstChild),this.insertBefore(e.firstChild,t);let i=0;for(let y of this.children)y===t||y===e||(y.dataset.toolbarOrder==null&&(y.dataset.toolbarOrder=String(i)),i+=1);let n=Array.from(this.children).filter(y=>y!==t&&y!==e).sort((y,v)=>Number(y.dataset.toolbarOrder)-Number(v.dataset.toolbarOrder));for(let y of n)this.insertBefore(y,t);let r=n;for(let y of r)y.hidden=!1;t.hidden=!0;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.map(y=>c1(y)),d=u.reduce((y,v)=>y+v,0)+Math.max(0,r.length-1)*h,f=d<=c-l1;if(this.overflow==="none"||f)return;t.hidden=!1;let p=c1(t),m=r.length,O=d;for(;m>0&&!(O+h+p<=c-l1);)m-=1,O-=u[m],m>0&&(O-=h);for(;m>0&&h1(r[m-1]);)m-=1;let g=r.slice(m);for(let y of g){if(h1(y)){y.hidden=!0;continue}vR(y),e.appendChild(y)}e.firstElementChild||(t.hidden=!0)}finally{this.#r=!1,queueMicrotask(()=>{this.#e?.takeRecords(),this.#y()})}}}},xo=class extends k{static template=()=>null;connected(){this.setAttribute("role","group")}};x("toolbar-ui",vo),x("toolbar-group-ui",xo);Q();var So=class extends k{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}};static template=()=>null;#t=null;connected(){this.setAttribute("role","navigation"),this.heading&&this.setAttribute("aria-label",this.heading),this.addEventListener("click",this.#i),this.variant!=="section"&&(this.#t=new ResizeObserver(()=>this.#e()),this.#t.observe(this))}render(){this.heading?this.setAttribute("aria-label",this.heading):this.removeAttribute("aria-label"),this.variant!=="section"&&this.#e()}#e(){let t=this.collapsed||this.getBoundingClientRect().width<=96;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&&e!==t&&e.removeAttribute("selected"),t&&(t.setAttribute("selected",""),this.dispatchEvent(new CustomEvent("nav-select",{bubbles:!0,detail:{item:t,text:t.text,value:t.value}})))}toggle(){this.variant!=="section"&&(this.collapsed=!this.collapsed)}#i=t=>{let e=t.target.closest("nav-item-ui");if(e&&this.contains(e)){if(e.disabled)return;this.select(e),this.#s();return}if(this.variant==="section")return;let i=t.target.closest("nav-group-ui");if(i&&this.contains(i))if(this.collapsed||this.getBoundingClientRect().width<=96)i.showPopover?.();else{let r=i.querySelector(':scope > [slot="header"]');r&&(t.target===r||r.contains(t.target))&&(i.open=!i.open)}};#s(){this.style.pointerEvents="none",requestAnimationFrame(()=>{this.style.pointerEvents=""})}disconnected(){this.removeEventListener("click",this.#i),this.#t?.disconnect(),this.#t=null}};x("nav-ui",So);Q();var wo=class extends k{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},collapsible:{type:Boolean,default:!0,reflect:!0},variant:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=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"),this.querySelector(':scope > [slot="header"]')?this.#i=this.querySelector(':scope > [slot="header"]'):(this.#i=document.createElement("div"),this.#i.setAttribute("slot","header"),this.#i.setAttribute("tabindex","0"),this.#i.innerHTML=`
|
|
218
218
|
<span slot="icon">${this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:""}</span>
|
|
219
219
|
<span slot="text">${this.text}</span>
|
|
220
220
|
${this.badge?`<span slot="badge">${this.badge}</span>`:""}
|
|
@@ -230,7 +230,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
230
230
|
placeholder="${this.placeholder}"
|
|
231
231
|
${this.disabled?"disabled":""}
|
|
232
232
|
${t?`size="${t}"`:""}
|
|
233
|
-
></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#n),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#r)))}render(){this.#t&&(this.#t.setAttribute("placeholder",this.placeholder),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"),this.setAttribute("value",this.value||""))}#s=()=>{this.value=this.#t.value,this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#n=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#r()};#r=()=>{clearTimeout(this.#i),this.value="",this.#t&&(this.#t.value=""),this.syncValue(""),this.setAttribute("value",""),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:""}})),this.#t?.focus()};focus(){this.#t?.focus()}clear(){this.#r()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#n)),this.#e&&this.#e.removeEventListener("click",this.#r),this.#t=null,this.#e=null}};x("search-ui",Co);je();function _s(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function SR(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var wR=0,Eo=class extends Z{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle","check"];static properties={...Z.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},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"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=`combobox-${++wR}`;#
|
|
233
|
+
></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#n),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#r)))}render(){this.#t&&(this.#t.setAttribute("placeholder",this.placeholder),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"),this.setAttribute("value",this.value||""))}#s=()=>{this.value=this.#t.value,this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#n=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#r()};#r=()=>{clearTimeout(this.#i),this.value="",this.#t&&(this.#t.value=""),this.syncValue(""),this.setAttribute("value",""),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:""}})),this.#t?.focus()};focus(){this.#t?.focus()}clear(){this.#r()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#n)),this.#e&&this.#e.removeEventListener("click",this.#r),this.#t=null,this.#e=null}};x("search-ui",Co);je();function _s(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function SR(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var wR=0,Eo=class extends Z{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle","check"];static properties={...Z.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},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"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#f=null;#p=null;#m=`combobox-${++wR}`;#g=()=>this.#Z();#O=t=>this.#D(t);#y=()=>this.#q();#b=t=>this.#V(t);#w=t=>this.#G(t);#v=t=>this.#F(t);#x=t=>this.#J(t);#S=t=>this.#tt(t);#k=t=>this.#et(t);connected(){super.connected(),this.#t.length===0&&this.#C(),this.#e=this.value||"",this.#A(),this.#P(),this.#Y()}disconnected(){super.disconnected(),this.#M(),this.#f?.(),this.#f=null,this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#k),this.#o?.hidePopover?.(),this.#o=null,this.#r=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null}render(){this.#r&&(this.#r.setAttribute("aria-expanded",String(this.open)),this.disabled||this.readonly?this.#r.contentEditable="false":this.#r.contentEditable="plaintext-only",this.#a&&(this.#a.textContent=this.label||"",this.#a.style.display=this.label?"":"none"),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#u&&(this.#u.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#st():this.#U())}#A(){if(this.querySelector(":scope > [data-field]")){this.#$(),this.#T();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,n=Array.from(this.querySelectorAll(':scope > [slot="prefix"]')),r=Array.from(this.querySelectorAll(':scope > [slot="suffix"]')),o=Array.from(this.querySelectorAll(':scope > [slot="empty"]')),a=Array.from(this.querySelectorAll(':scope > [slot="loading"]')),l=Array.from(this.querySelectorAll(':scope > [slot="footer"]'));this.innerHTML=`
|
|
234
234
|
<span data-label id="${t}"${this.label?"":' style="display:none"'}>${_s(this.label||"")}</span>
|
|
235
235
|
<div data-field>
|
|
236
236
|
<span data-prefix></span>
|
|
@@ -257,8 +257,8 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
257
257
|
<div data-empty>No matches</div>
|
|
258
258
|
<div data-footer></div>
|
|
259
259
|
</div>
|
|
260
|
-
`,this.#P(),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.#$()}#P(){this.#r=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=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.#g),this.#r.addEventListener("focus",this.#y),this.#r.addEventListener("blur",this.#b)),this.#u&&this.#u.addEventListener("click",this.#x),this.#d&&this.#d.addEventListener("click",this.#S)}#M(){this.#r&&(this.#r.removeEventListener("input",this.#O),this.#r.removeEventListener("keydown",this.#g),this.#r.removeEventListener("focus",this.#y),this.#r.removeEventListener("blur",this.#b)),this.#u&&this.#u.removeEventListener("click",this.#x),this.#d&&this.#d.removeEventListener("click",this.#S)}#Q(){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){Tt(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#C(),this.#Y()})}get options(){return this.#t}#E(){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}#R(t){return this.#E().find(e=>e.value===t)||null}#C(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#E(),i=this.#D(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.innerHTML=this.#L(a.label??a.value),l.addEventListener("click",this.#k),l.addEventListener("mouseenter",this.#v),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.#D(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.#T(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.#s=-1,this.#r?.removeAttribute("aria-activedescendant")}#L(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return _s(e);let i=this.#i,n=new RegExp(SR(i),"i"),r=e.match(n);if(!r)return _s(e);let o=r.index??0,a=o+r[0].length;return _s(e.slice(0,o))+"<mark>"+_s(e.slice(o,a))+"</mark>"+_s(e.slice(a))}#T(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)}}#D(t){return this.#i?t.filter(e=>this.#T(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.#C();let e=this.#N();this.#i&&e.length&&this.#B(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#I(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.#j(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#j(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#B(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#N();this.#B(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#_();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#it("escape"));return}if(e==="Tab"){this.#X();return}if(e==="Backspace"){let i=!(this.#r.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#K("keyboard"));return}}#q(){}#V(t){!this.freeText&&this.#i&&!this.value&&(this.#Y(),this.#i="")}#N(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#j(t){let e=this.#N();if(!e.length)return;if(this.#s<0){this.#B(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#B(i)}#B(t){let e=this.#N();if(!e.length){this.#s=-1,this.#r?.removeAttribute("aria-activedescendant");return}for(let r of e)r.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),n=e[i];n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#s=i,this.#r?.setAttribute("aria-activedescendant",n.id))}#G(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#W(i,"click")}#F(t){let e=t.currentTarget,n=this.#N().indexOf(e);n>=0&&this.#B(n)}#_(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#N(),e=this.#s>=0?t[this.#s]:null;if(e){this.#W(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(!i){this.#U("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#H(i,"keyboard");return}if(this.freeText){this.#H(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#Y(),this.#i="",this.#C()}#X(){if(!this.open)return;let t=this.#N(),e=this.#s>=0?t[this.#s]:null;if(e){this.#W(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#R(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#H(i,"keyboard");return}this.#Y(),this.#i="",this.#U("blur")}#W(t,e){if(this.readonly){this.#U("select");return}let i=this.#R(t);Tt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#Y(),this.#C(),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"}}))}#H(t,e){if(this.readonly){this.#U("select");return}Tt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#Y(),this.#C(),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"}}))}#J(t){t.preventDefault(),t.stopPropagation(),this.#K("click"),this.#r?.focus()}#K(t){Tt(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#Y(),this.#C(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#K("programmatic")}#tt(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()))}#et(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#Y(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#it(t){this.#Y(),this.#i="",this.#C(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#st(){if(!this.#o)return;this.#o.showPopover?.();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=at(t,this.#o,{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.#w)});let e=this.#N();if(!e.length)return;let i=e.findIndex(n=>n.dataset.value===this.value);this.#B(i>=0?i:0)}#U(t){this.#o&&(this.#f?.(),this.#f=null,this.#o.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#w),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant"))}#Y(){if(!this.#r)return;let t=this.#R(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.#R(t)?(this.#W(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};x("combobox-ui",Eo);je();var kR=0;function AR(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Po=class extends Z{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=Z.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
|
|
261
|
-
`,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},transform:{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.#B(i);n&&(this.value=n)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#n=!1;#r=0;#a=null;#o=null;#l=null;#c=null;#h=`tags-input-${++kR}`;#u=()=>this.#A();#d=t=>this
|
|
260
|
+
`,this.#$(),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.#T()}#$(){this.#r=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=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]")}#T(){this.#r&&(this.#r.addEventListener("input",this.#g),this.#r.addEventListener("keydown",this.#O),this.#r.addEventListener("focus",this.#y),this.#r.addEventListener("blur",this.#b)),this.#u&&this.#u.addEventListener("click",this.#x),this.#d&&this.#d.addEventListener("click",this.#S)}#M(){this.#r&&(this.#r.removeEventListener("input",this.#g),this.#r.removeEventListener("keydown",this.#O),this.#r.removeEventListener("focus",this.#y),this.#r.removeEventListener("blur",this.#b)),this.#u&&this.#u.removeEventListener("click",this.#x),this.#d&&this.#d.removeEventListener("click",this.#S)}#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){Tt(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#P(),this.#Y()})}get options(){return this.#t}#E(){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}#R(t){return this.#E().find(e=>e.value===t)||null}#P(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#E(),i=this.#I(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.innerHTML=this.#L(a.label??a.value),l.addEventListener("click",this.#w),l.addEventListener("mouseenter",this.#v),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.#I(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.#Q(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.#s=-1,this.#r?.removeAttribute("aria-activedescendant")}#L(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return _s(e);let i=this.#i,n=new RegExp(SR(i),"i"),r=e.match(n);if(!r)return _s(e);let o=r.index??0,a=o+r[0].length;return _s(e.slice(0,o))+"<mark>"+_s(e.slice(o,a))+"</mark>"+_s(e.slice(a))}#Q(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)}}#I(t){return this.#i?t.filter(e=>this.#Q(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.#P();let e=this.#N();this.#i&&e.length&&this.#B(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#D(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.#j(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#j(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#B(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#N();this.#B(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#_();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#it("escape"));return}if(e==="Tab"){this.#X();return}if(e==="Backspace"){let i=!(this.#r.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#K("keyboard"));return}}#q(){}#V(t){!this.freeText&&this.#i&&!this.value&&(this.#Y(),this.#i="")}#N(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#j(t){let e=this.#N();if(!e.length)return;if(this.#s<0){this.#B(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#B(i)}#B(t){let e=this.#N();if(!e.length){this.#s=-1,this.#r?.removeAttribute("aria-activedescendant");return}for(let r of e)r.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),n=e[i];n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#s=i,this.#r?.setAttribute("aria-activedescendant",n.id))}#G(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#W(i,"click")}#F(t){let e=t.currentTarget,n=this.#N().indexOf(e);n>=0&&this.#B(n)}#_(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#N(),e=this.#s>=0?t[this.#s]:null;if(e){this.#W(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(!i){this.#U("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#H(i,"keyboard");return}if(this.freeText){this.#H(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#Y(),this.#i="",this.#P()}#X(){if(!this.open)return;let t=this.#N(),e=this.#s>=0?t[this.#s]:null;if(e){this.#W(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#R(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#H(i,"keyboard");return}this.#Y(),this.#i="",this.#U("blur")}#W(t,e){if(this.readonly){this.#U("select");return}let i=this.#R(t);Tt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#Y(),this.#P(),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"}}))}#H(t,e){if(this.readonly){this.#U("select");return}Tt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#Y(),this.#P(),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"}}))}#J(t){t.preventDefault(),t.stopPropagation(),this.#K("click"),this.#r?.focus()}#K(t){Tt(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#Y(),this.#P(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#K("programmatic")}#tt(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()))}#et(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#Y(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#it(t){this.#Y(),this.#i="",this.#P(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#st(){if(!this.#o)return;this.#o.showPopover?.();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=at(t,this.#o,{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.#k)});let e=this.#N();if(!e.length)return;let i=e.findIndex(n=>n.dataset.value===this.value);this.#B(i>=0?i:0)}#U(t){this.#o&&(this.#f?.(),this.#f=null,this.#o.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#k),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant"))}#Y(){if(!this.#r)return;let t=this.#R(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.#R(t)?(this.#W(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};x("combobox-ui",Eo);je();var kR=0;function AR(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Po=class extends Z{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=Z.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
|
|
261
|
+
`,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},transform:{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.#B(i);n&&(this.value=n)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#n=!1;#r=0;#a=null;#o=null;#l=null;#c=null;#h=`tags-input-${++kR}`;#u=()=>this.#A();#d=t=>this.#$(t);#f=t=>this.#T(t);#p=t=>this.#M(t);#m=t=>this.#C(t);#g=t=>this.#E(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#B(this.getAttribute("value"));t&&(this.#t=t)}this.#O(),this.#v(),this.#S(),this.#k()}disconnected(){super.disconnected(),this.#w(),this.#a=null,this.#o=null,this.#l=null,this.#c=null}render(){this.#o&&(this.disabled||this.readonly?this.#o.contentEditable="false":this.#o.contentEditable="plaintext-only",this.#o.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){Tt(()=>{let e=Array.isArray(t)?t.map(n=>String(n??"")):typeof t=="string"?this.#B(t)||[]:[],i=this.#t.slice();this.#t=e,this.#v(),this.#S(),this.#k(),this.#Z(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){Tt(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#x(),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.#P(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#I(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#v(),this.#S(),this.#k(),this.#Z(t,[],"programmatic")}focus(){this.#o?.focus()}#O(){if(this.querySelector(":scope > [data-chip-list]")){this.#y(),this.#b();return}let t=`${this.#h}-suggestions`,e=`${this.#h}-input`;this.innerHTML=`
|
|
262
262
|
<div data-chip-list role="list" aria-label="Tags"></div>
|
|
263
263
|
<span data-inline-input
|
|
264
264
|
id="${e}"
|
|
@@ -274,7 +274,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
274
274
|
<icon-ui name="circle-notch"></icon-ui>
|
|
275
275
|
</span>
|
|
276
276
|
<div data-suggestions id="${t}" role="listbox" hidden></div>
|
|
277
|
-
`,this.#y(),this.#b()}#y(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#b(){this.#o&&(this.#o.addEventListener("input",this.#u),this.#o.addEventListener("keydown",this.#d),this.#o.addEventListener("paste",this.#f)),this.#a&&this.#a.addEventListener("remove",this.#p),this.#l&&this.#l.addEventListener("click",this.#O),this.addEventListener("mousedown",this.#m)}#k(){this.#o&&(this.#o.removeEventListener("input",this.#u),this.#o.removeEventListener("keydown",this.#d),this.#o.removeEventListener("paste",this.#f)),this.#a&&this.#a.removeEventListener("remove",this.#p),this.#l&&this.#l.removeEventListener("click",this.#O),this.removeEventListener("mousedown",this.#m)}#v(){if(!this.#a)return;let t=Array.from(this.#a.querySelectorAll(":scope > tag-ui"));for(let e=0;e<this.#t.length;e++){let i=this.#t[e],n=t[e];n||(n=document.createElement("tag-ui"),n.setAttribute("role","listitem"),this.#a.appendChild(n)),n.setAttribute("text",i),this.readonly||this.disabled?n.removeAttribute("removable"):n.setAttribute("removable",""),n.setAttribute("data-index",String(e))}for(let e=this.#t.length;e<t.length;e++)t[e].remove()}#x(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(n=>!this.#t.includes(n)).filter(n=>!t||n.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((n,r)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${r}`),o.dataset.value=n,o.textContent=n,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant");for(let n of this.#l.children)n.removeAttribute("data-active")}#S(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.#o.toggleAttribute("data-empty",t),this.toggleAttribute("editing",!t)}#w(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#n)return;let t=this.#o.textContent||"";if(this.delimiter&&this.delimiter!=="enter"&&t.includes(this.delimiter)){let e=t.split(this.delimiter),i=e.pop(),n=!1;for(let r of e)r.length&&this.#C(r,"delimiter")&&(n=!0);this.#n=!0,this.#o.textContent=i||"",this.#n=!1,this.#V(),this.#S(),this.#x(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#S(),this.#x(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#P(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#o&&this.#o.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let n=this.#l?.children[this.#s];if(n){this.#C(n.dataset.value||"","suggestion");return}}i&&this.#C(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#D(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#N(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#N(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#j())}#$(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(`[${AR(this.pasteSplit)}]+`),n=e.split(i).map(o=>o.trim()).filter(Boolean);if(n.length===0)return;if(n.length===1){document.execCommand("insertText",!1,n[0]),this.#S(),this.#x();return}let r="";for(let o=0;o<n.length;o++){let a=n[o];!this.#C(a,"paste")&&o===n.length-1&&(r=a)}r&&(this.#n=!0,this.#o.textContent=r,this.#n=!1,this.#V(),this.#S(),this.#x())}#M(t){let e=t.target.closest("tag-ui[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#D(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.#o&&(t.preventDefault(),this.#o?.focus(),this.#V())}#E(t){let e=t.target.closest('[role="option"]');e&&this.#C(e.dataset.value||"","suggestion")}#R(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#C(t,e){if(this.disabled||this.readonly)return!1;let i=this.#R(t.trim());if(!i)return this.#q(),!1;if(i.length<this.minLength)return this.#I(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#I(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#q(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#I(i,"max"),!1;let n=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(n))return this.#I(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#L(i,o,e),!1;if(o===!1)return this.#I(i,"validator"),!1}catch{return this.#I(i,"validator"),!1}return this.#T(i,e),!0}#L(t,e,i){let n=++this.#r;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(r=>{if(!(n!==this.#r||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),r===!1){this.#I(t,"validator");return}this.#T(t,i)}},()=>{n!==this.#r||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#I(t,"validator"))})}#T(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#q(),this.#S(),this.#w(),this.#Z(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#D(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),n=i.slice();n.splice(t,1),this.#t=n,this.#v(),this.#S(),this.#w(),this.#Z(i,n,e),e!=="programmatic"&&this.#o?.focus()}#Z(t,e,i){let n=new Set(t),r=new Set(e),o=e.filter(l=>!n.has(l)),a=t.filter(l=>!r.has(l));o.length===0&&a.length===0||this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e.slice(),added:o,removed:a,source:i}}))}#I(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#q(){this.#o&&(this.#n=!0,this.#o.textContent="",this.#n=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#x())}#V(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#N(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let n of e)n.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#j(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#B(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(n=>String(n??""))}catch{}return e.includes(",")?(this.#I(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#B(t);if(e){this.value=e;return}}super.syncValue(t)}};x("tags-input-ui",Po);Q();var El=class extends k{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}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="icon"]'),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.textContent=this.change,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};customElements.define("stat-ui",El);Q();var Qo=class extends k{static properties={label:{type:String,default:"",reflect:!0},value:{type:Number,default:null,reflect:!0},meta:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","group"),this.#t=this.querySelector(':scope > [slot="label"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","label"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="meta"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","meta"),this.appendChild(this.#e)),this.#i=this.querySelector(":scope > progress-ui"),this.#i||(this.#i=document.createElement("progress-ui"),this.value!=null&&this.value>=0&&this.#i.setAttribute("value",String(this.value)),this.appendChild(this.#i))}disconnected(){this.#t=null,this.#e=null,this.#i=null}render(){this.#t&&(this.#t.textContent=this.label,this.#t.hidden=!this.label,this.#e.textContent=this.meta,this.#e.hidden=!this.meta,this.value!=null&&this.value>=0?this.#i.setAttribute("value",String(this.value)):this.#i.removeAttribute("value"),this.label?this.setAttribute("aria-label",this.meta?`${this.label}, ${this.meta}`:this.label):this.removeAttribute("aria-label"))}};x("progress-row-ui",Qo);Q();var To=class extends k{static properties={};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),n=i?e.indexOf(i):-1,r=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),r(n+1);break;case"ArrowUp":t.preventDefault(),r(n-1);break;case"Home":t.preventDefault(),r(0);break;case"End":t.preventDefault(),r(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},Lo=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t(),this.#e()}#t(){if(!this.querySelector('[slot="text"]')){if(this.icon){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#e(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.querySelector('[slot="icon"]');if(this.icon)if(t)t.setAttribute("name",this.icon);else{let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else t&&t.remove();let e=this.querySelector('[slot="text"]');e&&(e.textContent=this.text),this.#e()}};x("action-list-ui",To),x("action-item-ui",Lo);Q();var Mo=class extends k{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}};x("empty-state-ui",Mo);Q();var $R=["S","M","T","W","T","F","S"],CR=["January","February","March","April","May","June","July","August","September","October","November","December"];function u1(s){return String(s).padStart(2,"0")}function Hg(s,t,e){return`${s}-${u1(t+1)}-${u1(e)}`}function Ti(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 ku(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Ro=class extends k{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=Ti(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.#a),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#o),this.#s=!1}render(){let t=Ti(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=Ti(this.value),r=Ti(this.min),o=Ti(this.max),a=Ti(this.rangeStart),l=Ti(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
|
|
277
|
+
`,this.#y(),this.#b()}#y(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#b(){this.#o&&(this.#o.addEventListener("input",this.#u),this.#o.addEventListener("keydown",this.#d),this.#o.addEventListener("paste",this.#f)),this.#a&&this.#a.addEventListener("remove",this.#p),this.#l&&this.#l.addEventListener("click",this.#g),this.addEventListener("mousedown",this.#m)}#w(){this.#o&&(this.#o.removeEventListener("input",this.#u),this.#o.removeEventListener("keydown",this.#d),this.#o.removeEventListener("paste",this.#f)),this.#a&&this.#a.removeEventListener("remove",this.#p),this.#l&&this.#l.removeEventListener("click",this.#g),this.removeEventListener("mousedown",this.#m)}#v(){if(!this.#a)return;let t=Array.from(this.#a.querySelectorAll(":scope > tag-ui"));for(let e=0;e<this.#t.length;e++){let i=this.#t[e],n=t[e];n||(n=document.createElement("tag-ui"),n.setAttribute("role","listitem"),this.#a.appendChild(n)),n.setAttribute("text",i),this.readonly||this.disabled?n.removeAttribute("removable"):n.setAttribute("removable",""),n.setAttribute("data-index",String(e))}for(let e=this.#t.length;e<t.length;e++)t[e].remove()}#x(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(n=>!this.#t.includes(n)).filter(n=>!t||n.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((n,r)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${r}`),o.dataset.value=n,o.textContent=n,this.#l.appendChild(o)});let i=this.#e.length>0&&e.length>0&&this.hasAttribute("editing");this.#l.hidden=!i,this.toggleAttribute("suggesting",i),i?this.setAttribute("aria-expanded","true"):this.removeAttribute("aria-expanded"),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant");for(let n of this.#l.children)n.removeAttribute("data-active")}#S(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.#o.toggleAttribute("data-empty",t),this.toggleAttribute("editing",!t)}#k(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#n)return;let t=this.#o.textContent||"";if(this.delimiter&&this.delimiter!=="enter"&&t.includes(this.delimiter)){let e=t.split(this.delimiter),i=e.pop(),n=!1;for(let r of e)r.length&&this.#P(r,"delimiter")&&(n=!0);this.#n=!0,this.#o.textContent=i||"",this.#n=!1,this.#V(),this.#S(),this.#x(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#S(),this.#x(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#$(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#o&&this.#o.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let n=this.#l?.children[this.#s];if(n){this.#P(n.dataset.value||"","suggestion");return}}i&&this.#P(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#I(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#N(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#N(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#j())}#T(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(`[${AR(this.pasteSplit)}]+`),n=e.split(i).map(o=>o.trim()).filter(Boolean);if(n.length===0)return;if(n.length===1){document.execCommand("insertText",!1,n[0]),this.#S(),this.#x();return}let r="";for(let o=0;o<n.length;o++){let a=n[o];!this.#P(a,"paste")&&o===n.length-1&&(r=a)}r&&(this.#n=!0,this.#o.textContent=r,this.#n=!1,this.#V(),this.#S(),this.#x())}#M(t){let e=t.target.closest("tag-ui[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#I(i,"chip-click"))}#C(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#o&&(t.preventDefault(),this.#o?.focus(),this.#V())}#E(t){let e=t.target.closest('[role="option"]');e&&this.#P(e.dataset.value||"","suggestion")}#R(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#P(t,e){if(this.disabled||this.readonly)return!1;let i=this.#R(t.trim());if(!i)return this.#q(),!1;if(i.length<this.minLength)return this.#D(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#D(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#q(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#D(i,"max"),!1;let n=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(n))return this.#D(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#L(i,o,e),!1;if(o===!1)return this.#D(i,"validator"),!1}catch{return this.#D(i,"validator"),!1}return this.#Q(i,e),!0}#L(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.#D(t,"validator");return}this.#Q(t,i)}},()=>{n!==this.#r||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#D(t,"validator"))})}#Q(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#q(),this.#S(),this.#k(),this.#Z(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#I(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),n=i.slice();n.splice(t,1),this.#t=n,this.#v(),this.#S(),this.#k(),this.#Z(i,n,e),e!=="programmatic"&&this.#o?.focus()}#Z(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}}))}#D(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#q(){this.#o&&(this.#n=!0,this.#o.textContent="",this.#n=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#x())}#V(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#N(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let n of e)n.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#j(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#B(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(n=>String(n??""))}catch{}return e.includes(",")?(this.#D(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#B(t);if(e){this.value=e;return}}super.syncValue(t)}};x("tags-input-ui",Po);Q();var El=class extends k{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}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="icon"]'),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.textContent=this.change,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};customElements.define("stat-ui",El);Q();var Qo=class extends k{static properties={label:{type:String,default:"",reflect:!0},value:{type:Number,default:null,reflect:!0},meta:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","group"),this.#t=this.querySelector(':scope > [slot="label"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","label"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="meta"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","meta"),this.appendChild(this.#e)),this.#i=this.querySelector(":scope > progress-ui"),this.#i||(this.#i=document.createElement("progress-ui"),this.value!=null&&this.value>=0&&this.#i.setAttribute("value",String(this.value)),this.appendChild(this.#i))}disconnected(){this.#t=null,this.#e=null,this.#i=null}render(){this.#t&&(this.#t.textContent=this.label,this.#t.hidden=!this.label,this.#e.textContent=this.meta,this.#e.hidden=!this.meta,this.value!=null&&this.value>=0?this.#i.setAttribute("value",String(this.value)):this.#i.removeAttribute("value"),this.label?this.setAttribute("aria-label",this.meta?`${this.label}, ${this.meta}`:this.label):this.removeAttribute("aria-label"))}};x("progress-row-ui",Qo);Q();var To=class extends k{static properties={};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),n=i?e.indexOf(i):-1,r=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),r(n+1);break;case"ArrowUp":t.preventDefault(),r(n-1);break;case"Home":t.preventDefault(),r(0);break;case"End":t.preventDefault(),r(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},Lo=class extends k{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t(),this.#e()}#t(){if(!this.querySelector('[slot="text"]')){if(this.icon){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#e(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.querySelector('[slot="icon"]');if(this.icon)if(t)t.setAttribute("name",this.icon);else{let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else t&&t.remove();let e=this.querySelector('[slot="text"]');e&&(e.textContent=this.text),this.#e()}};x("action-list-ui",To),x("action-item-ui",Lo);Q();var Mo=class extends k{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}};x("empty-state-ui",Mo);Q();var $R=["S","M","T","W","T","F","S"],CR=["January","February","March","April","May","June","July","August","September","October","November","December"];function u1(s){return String(s).padStart(2,"0")}function Hg(s,t,e){return`${s}-${u1(t+1)}-${u1(e)}`}function Ti(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 ku(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Ro=class extends k{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=Ti(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.#a),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#o),this.#s=!1}render(){let t=Ti(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=Ti(this.value),r=Ti(this.min),o=Ti(this.max),a=Ti(this.rangeStart),l=Ti(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
|
|
278
278
|
<button data-cal-prev type="button" aria-label="Previous month" tabindex="-1"><icon-ui name="caret-left"></icon-ui></button>
|
|
279
279
|
<span data-cal-title>${CR[e]} ${t}</span>
|
|
280
280
|
<button data-cal-next type="button" aria-label="Next month" tabindex="-1"><icon-ui name="caret-right"></icon-ui></button>
|
|
@@ -287,11 +287,11 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
287
287
|
<button data-cal-prev type="button" aria-label="Previous month"><icon-ui name="caret-left"></icon-ui></button>
|
|
288
288
|
<span data-cal-title>${d1[e]} ${t}</span>
|
|
289
289
|
<button data-cal-next type="button" aria-label="Next month"><icon-ui name="caret-right"></icon-ui></button>
|
|
290
|
-
</div>`;a+=`<div data-cal-weekdays>${ER.map(f=>`<span>${f}</span>`).join("")}</div>`;let l=new Date(t,e,1).getDay(),h=new Date(t,e+1,0).getDate(),c=new Date(t,e,0).getDate();a+="<div data-cal-grid>";for(let f=l-1;f>=0;f--){let p=c-f;a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${p}</button>`}for(let f=1;f<=h;f++){let p=new Date(t,e,f),m=f1(t,e,f),O=p1(p,i),g=n&&p1(p,n),y=r&&p<r||o&&p>o,v=this.#r===f,S=['type="button"',"data-cal-day",`data-date="${m}"`,O?"data-today":"",g?"data-selected":"",y?"disabled":"",v?"data-focused":"",`tabindex="${v?"0":"-1"}"`].filter(Boolean).join(" ");a+=`<button ${S}>${f}</button>`}let d=(7-(l+h)%7)%7;for(let f=1;f<=d;f++)a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${f}</button>`;a+="</div>",this.#t.innerHTML=a}#u(t){this.#n+=t,this.#n>11&&(this.#n=0,this.#s++),this.#n<0&&(this.#n=11,this.#s--),this.#r=null,this.#h()}#d(t){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.open&&this.#h()}#f=t=>{if(!this.disabled&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!this.open,this.open)){let e=Ji(this.value);if(e)this.#s=e.getFullYear(),this.#n=e.getMonth(),this.#r=e.getDate();else{let i=new Date;this.#s=i.getFullYear(),this.#n=i.getMonth(),this.#r=i.getDate()}}};#p=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!1)};#m=t=>{if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!0);return}if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.#r){let i=f1(this.#s,this.#n,this.#r),n=new Date(this.#s,this.#n,this.#r),r=Ji(this.min),o=Ji(this.max);(!r||n>=r)&&(!o||n<=o)&&this.#d(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#s,this.#n+1,0).getDate(),n=(this.#r||1)+e[t.key];if(n<1){this.#u(-1);let o=new Date(this.#s,this.#n+1,0).getDate();this.#r=o+n}else n>i?(this.#u(1),this.#r=n-i):this.#r=n;this.#h(),this.#t?.querySelector("[data-focused]")?.focus()}};disconnected(){super.disconnected(),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.removeEventListener("click",this.#f),this.removeEventListener("keydown",this.#m),document.removeEventListener("pointerdown",this.#p),this.#t&&this.#a&&this.#t.removeEventListener("click",this.#l),this.#a=!1,this.#i?.(),this.#i=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null}};x("calendar-picker-ui",Io);je();var QR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],TR=["January","February","March","April","May","June","July","August","September","October","November","December"];function Kg(s){return String(s).padStart(2,"0")}function ze(s){return s?`${s.getFullYear()}-${Kg(s.getMonth()+1)}-${Kg(s.getDate())}`:""}function Jg(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 Ve(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 m1(s){return s?s.from<=s.to:!1}function g1(s,t){let e=Jg(s);if(!e)return"";switch(t){case"long":return`${TR[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${QR[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function LR(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=ze(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),ze(l)},n=ze(new Date(t.getFullYear(),t.getMonth(),1)),r=ze(new Date(t.getFullYear(),t.getMonth()+1,0)),o=ze(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 MR(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var Do=class extends Z{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down","arrow-right"];static get properties(){return{...Z.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;get rangeValue(){return Ve(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return Ve(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:LR()}set presets(t){Tt(()=>{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.#w(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=Ve(e);if(this.comparison&&this.name){let n=new FormData;i&&n.append(this.name,e),Ve(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&&!m1(t)?(this.internals.setValidity({rangeUnderflow:!0},"End date must be on or after start date.",this),!1):t&&this.min&&t.from<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable date is ${this.min}.`,this),!1):t&&this.max&&t.to>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable date is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","dialog"),this.setAttribute("aria-expanded",this.open?"true":"false"),this.#s||(this.#s=!0,this.#d(),this.#r.addEventListener("click",this.#O),this.#r.addEventListener("keydown",this.#g,!0),this.#a.addEventListener("click",this.#y),this.#a.addEventListener("keydown",this.#b),this.#l.addEventListener("change",this.#v),this.#c.addEventListener("change",this.#x)),this.syncValue()}disconnected(){super.disconnected(),this.#r&&(this.#r.removeEventListener("click",this.#O),this.#r.removeEventListener("keydown",this.#g,!0)),this.#a&&(this.#a.removeEventListener("click",this.#y),this.#a.removeEventListener("keydown",this.#b),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#v),this.#c&&this.#c.removeEventListener("change",this.#x),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#k),this.#h?.(),this.#h=null,this.#s=!1,this.#n=!1,this.#r=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null}#d(){if(this.#r=this.ensure("trigger"),this.#a=this.ensure("popover"),this.id&&this.#a.setAttribute("aria-labelledby",this.id),!this.#a.querySelector(":scope > [data-calendar-area]")){let n=this.constructor._pp.calArea.cloneNode(!0);this.#a.appendChild(n)}let t=this.querySelector(':scope > [slot="presets"]');if(t&&t.parentElement!==this.#a)this.#a.appendChild(t),this.#o=t;else if(!this.noPresets&&!t){if(!this.#a.querySelector(":scope > [data-preset-rail]")){let n=this.constructor._pp.presets.cloneNode(!0);this.#a.insertBefore(n,this.#a.querySelector(":scope > [data-calendar-area]"))}this.#o=this.#a.querySelector(":scope > [data-preset-rail]")}let e=this.#a.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let n=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(n)}if(!e.querySelector(":scope > [data-cal-to]")){let n=this.constructor._pp.calTo.cloneNode(!0),r=Ve(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}-${Kg(a+1)}`),e.appendChild(n)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=this.querySelector(':scope > [slot="footer"]');i&&i.parentElement!==this.#a&&this.#a.appendChild(i)}render(){if(!this.#r)return;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=Ve(this.value),i=this.#e,n=i?.from||e?.from||"",r=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=i?.from||e?.from||"",o(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=i?.to||e?.to||"",o(this.#c)),this.querySelector(':scope > [slot="presets"]')||(this.noPresets?(this.#o?.remove(),this.#o=null):(this.#o||this.#d(),this.#p())),this.#a&&(this.open&&!this.#n?!this.disabled&&!this.readonly?(this.#n=!0,this.#a.showPopover?.(),this.#h?.(),this.#h=at(this.#r,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#k),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#n&&(this.#n=!1,this.#h?.(),this.#h=null,this.#a.hidePopover?.(),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#k),this.#r?.focus?.()))}#f(){let t=Ve(this.value);if(!t)return this.placeholder;let e=g1(t.from,this.format),i=g1(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#p(){if(this.#o){this.#o.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#o.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#o.appendChild(t);for(let e of MR()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#o.appendChild(i)}}}}#m=!1;#O=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#m;this.#m=!1,this.open?this.closePopover("outside"):(this.#i=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#g=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#m=!0}};#y=t=>{if(this.readonly){let n=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),r=t.target.closest("[data-cal-day]");if(n||r){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let n=Ve(this.value);if(!n)return;let r=this.#A(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())}};#k=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#l?.value||"";if(!e)return;let i=Ve(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.from=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));let n=this.#e.to||i?.to||null;n&&this.#w({from:e,to:n})};#x=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#c?.value||"";if(!e)return;let i=Ve(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from||i?.from||null,to:e}}}));let n=this.#e.from||i?.from||null;n&&this.#w({from:n,to:e})};#S=t=>{this.open&&(this.contains(t.target)||this.#a&&t.composedPath?.().includes(this.#a)||this.closePopover("outside"))};#w(t,e={}){if(!t||!t.from||!t.to)return;if(!m1(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:Ve(this.compareValue),presetLabel:e.presetLabel||null}}))}#A(t,e){let i=Jg(e.from),n=Jg(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:ze(a),to:ze(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:ze(o),to:ze(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:ze(o),to:ze(a)}}default:return null}}#P(){if(!this.#a)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#a.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};x("date-range-picker-ui",Do);var O1=23,b1=12,CW=1,y1=59,v1=59,RR=["hour","minute"];function Pl(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 tO({h:s,m:t,s:e},i){let n=r=>String(r).padStart(2,"0");return i==="second"?`${n(s)}:${n(t)}:${n(e)}`:`${n(s)}:${n(t)}`}function Xo({h:s,m:t,s:e}){return s*3600+t*60+e}function IR(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 qo=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#n(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:IR(this.locale)}get#r(){return this.#n==="h12"}get#a(){return this.precision==="second"}get#o(){return`${this.#n}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#g),this.addEventListener("focusin",this.#y),this.addEventListener("focusout",this.#b)}render(){this.#i&&this.#i!==this.#o&&this.#l(),this.#u(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#g),this.removeEventListener("focusin",this.#y),this.removeEventListener("focusout",this.#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.#a,i=this.#r,n=[...RR];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"
|
|
290
|
+
</div>`;a+=`<div data-cal-weekdays>${ER.map(f=>`<span>${f}</span>`).join("")}</div>`;let l=new Date(t,e,1).getDay(),h=new Date(t,e+1,0).getDate(),c=new Date(t,e,0).getDate();a+="<div data-cal-grid>";for(let f=l-1;f>=0;f--){let p=c-f;a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${p}</button>`}for(let f=1;f<=h;f++){let p=new Date(t,e,f),m=f1(t,e,f),O=p1(p,i),g=n&&p1(p,n),y=r&&p<r||o&&p>o,v=this.#r===f,S=['type="button"',"data-cal-day",`data-date="${m}"`,O?"data-today":"",g?"data-selected":"",y?"disabled":"",v?"data-focused":"",`tabindex="${v?"0":"-1"}"`].filter(Boolean).join(" ");a+=`<button ${S}>${f}</button>`}let d=(7-(l+h)%7)%7;for(let f=1;f<=d;f++)a+=`<button type="button" data-cal-day data-outside disabled tabindex="-1">${f}</button>`;a+="</div>",this.#t.innerHTML=a}#u(t){this.#n+=t,this.#n>11&&(this.#n=0,this.#s++),this.#n<0&&(this.#n=11,this.#s--),this.#r=null,this.#h()}#d(t){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.open&&this.#h()}#f=t=>{if(!this.disabled&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!this.open,this.open)){let e=Ji(this.value);if(e)this.#s=e.getFullYear(),this.#n=e.getMonth(),this.#r=e.getDate();else{let i=new Date;this.#s=i.getFullYear(),this.#n=i.getMonth(),this.#r=i.getDate()}}};#p=t=>{!this.contains(t.target)&&!(this.#t&&t.composedPath().includes(this.#t))&&(this.open=!1)};#m=t=>{if(!this.open){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!0);return}if(t.key==="Escape"){t.preventDefault(),this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.#r){let i=f1(this.#s,this.#n,this.#r),n=new Date(this.#s,this.#n,this.#r),r=Ji(this.min),o=Ji(this.max);(!r||n>=r)&&(!o||n<=o)&&this.#d(i)}return}let e={ArrowUp:-7,ArrowDown:7,ArrowLeft:-1,ArrowRight:1};if(e[t.key]!==void 0){t.preventDefault();let i=new Date(this.#s,this.#n+1,0).getDate(),n=(this.#r||1)+e[t.key];if(n<1){this.#u(-1);let o=new Date(this.#s,this.#n+1,0).getDate();this.#r=o+n}else n>i?(this.#u(1),this.#r=n-i):this.#r=n;this.#h(),this.#t?.querySelector("[data-focused]")?.focus()}};disconnected(){super.disconnected(),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),this.removeEventListener("click",this.#f),this.removeEventListener("keydown",this.#m),document.removeEventListener("pointerdown",this.#p),this.#t&&this.#a&&this.#t.removeEventListener("click",this.#l),this.#a=!1,this.#i?.(),this.#i=null,this.#t?.hidePopover?.(),this.#t=null,this.#e=null}};x("calendar-picker-ui",Io);je();var QR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],TR=["January","February","March","April","May","June","July","August","September","October","November","December"];function Kg(s){return String(s).padStart(2,"0")}function ze(s){return s?`${s.getFullYear()}-${Kg(s.getMonth()+1)}-${Kg(s.getDate())}`:""}function Jg(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 Ve(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 m1(s){return s?s.from<=s.to:!1}function g1(s,t){let e=Jg(s);if(!e)return"";switch(t){case"long":return`${TR[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;case"iso":return s;default:return`${QR[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}}function LR(s=new Date){let t=new Date(s.getFullYear(),s.getMonth(),s.getDate()),e=ze(t),i=a=>{let l=new Date(t);return l.setDate(l.getDate()-a),ze(l)},n=ze(new Date(t.getFullYear(),t.getMonth(),1)),r=ze(new Date(t.getFullYear(),t.getMonth()+1,0)),o=ze(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 MR(){return[{label:"Previous period"},{label:"Same period last year"},{label:"Same period last month"}]}var Do=class extends Z{static labelDeprecated=!0;static requiredIcons=["calendar","caret-down","arrow-right"];static get properties(){return{...Z.properties,compareValue:{type:String,default:"",attribute:"compare-value"},comparison:{type:Boolean,default:!1,reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select range",reflect:!0},format:{type:String,default:"short",reflect:!0},noPresets:{type:Boolean,default:!1,attribute:"no-presets",reflect:!0},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date range picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date range picker"></div>',presets:'<div data-preset-rail role="group" aria-label="Date range presets"></div>',calArea:"<div data-calendar-area></div>",calFrom:'<calendar-grid-ui data-cal-from aria-label="Start date"></calendar-grid-ui>',calTo:'<calendar-grid-ui data-cal-to aria-label="End date"></calendar-grid-ui>'};static template=()=>null;#t=null;#e=null;#i=null;#s=!1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;get rangeValue(){return Ve(this.value)}set rangeValue(t){t==null?this.value="":this.value=JSON.stringify({from:String(t.from),to:String(t.to)})}get rangeCompareValue(){return Ve(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:LR()}set presets(t){Tt(()=>{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.#k(e.range,{presetLabel:e.label}),!0)}syncValue(t){let e=t??this.value??"",i=Ve(e);if(this.comparison&&this.name){let n=new FormData;i&&n.append(this.name,e),Ve(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&&!m1(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.#a.addEventListener("click",this.#y),this.#a.addEventListener("keydown",this.#b),this.#l.addEventListener("change",this.#v),this.#c.addEventListener("change",this.#x)),this.syncValue()}disconnected(){super.disconnected(),this.#r&&(this.#r.removeEventListener("click",this.#g),this.#r.removeEventListener("keydown",this.#O,!0)),this.#a&&(this.#a.removeEventListener("click",this.#y),this.#a.removeEventListener("keydown",this.#b),this.#a.hidePopover?.()),this.#l&&this.#l.removeEventListener("change",this.#v),this.#c&&this.#c.removeEventListener("change",this.#x),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#w),this.#h?.(),this.#h=null,this.#s=!1,this.#n=!1,this.#r=null,this.#a=null,this.#o=null,this.#l=null,this.#c=null}#d(){if(this.#r=this.ensure("trigger"),this.#a=this.ensure("popover"),this.id&&this.#a.setAttribute("aria-labelledby",this.id),!this.#a.querySelector(":scope > [data-calendar-area]")){let n=this.constructor._pp.calArea.cloneNode(!0);this.#a.appendChild(n)}let t=this.querySelector(':scope > [slot="presets"]');if(t&&t.parentElement!==this.#a)this.#a.appendChild(t),this.#o=t;else if(!this.noPresets&&!t){if(!this.#a.querySelector(":scope > [data-preset-rail]")){let n=this.constructor._pp.presets.cloneNode(!0);this.#a.insertBefore(n,this.#a.querySelector(":scope > [data-calendar-area]"))}this.#o=this.#a.querySelector(":scope > [data-preset-rail]")}let e=this.#a.querySelector(":scope > [data-calendar-area]");if(!e.querySelector(":scope > [data-cal-from]")){let n=this.constructor._pp.calFrom.cloneNode(!0);e.appendChild(n)}if(!e.querySelector(":scope > [data-cal-to]")){let n=this.constructor._pp.calTo.cloneNode(!0),r=Ve(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}-${Kg(a+1)}`),e.appendChild(n)}this.#l=e.querySelector(":scope > [data-cal-from]"),this.#c=e.querySelector(":scope > [data-cal-to]");let i=this.querySelector(':scope > [slot="footer"]');i&&i.parentElement!==this.#a&&this.#a.appendChild(i)}render(){if(!this.#r)return;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=Ve(this.value),i=this.#e,n=i?.from||e?.from||"",r=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=i?.from||e?.from||"",o(this.#l)),this.#c&&(this.min&&this.#c.setAttribute("min",this.min),this.max&&this.#c.setAttribute("max",this.max),this.#c.value=i?.to||e?.to||"",o(this.#c)),this.querySelector(':scope > [slot="presets"]')||(this.noPresets?(this.#o?.remove(),this.#o=null):(this.#o||this.#d(),this.#p())),this.#a&&(this.open&&!this.#n?!this.disabled&&!this.readonly?(this.#n=!0,this.#a.showPopover?.(),this.#h?.(),this.#h=at(this.#r,this.#a,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#w),queueMicrotask(()=>{if(!this.open)return;this.#l?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#n&&(this.#n=!1,this.#h?.(),this.#h=null,this.#a.hidePopover?.(),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#w),this.#r?.focus?.()))}#f(){let t=Ve(this.value);if(!t)return this.placeholder;let e=g1(t.from,this.format),i=g1(t.to,this.format);return!e||!i?this.placeholder:`${e} \u2192 ${i}`}#p(){if(this.#o){this.#o.replaceChildren();for(let t of this.presets){let e=document.createElement("button-ui");e.setAttribute("variant","ghost"),e.setAttribute("type","button"),e.setAttribute("text",t.label),e.setAttribute("size","sm"),e.dataset.presetLabel=t.label,this.#o.appendChild(e)}if(this.comparison){let t=document.createElement("divider-ui");t.dataset.presetDivider="",this.#o.appendChild(t);for(let e of MR()){let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("type","button"),i.setAttribute("text",e.label),i.setAttribute("size","sm"),i.dataset.comparisonPresetLabel=e.label,this.#o.appendChild(i)}}}}#m=!1;#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}};#y=t=>{if(this.readonly){let n=t.target.closest("[data-preset-label],[data-comparison-preset-label]"),r=t.target.closest("[data-cal-day]");if(n||r){t.stopPropagation(),t.preventDefault();return}}let e=t.target.closest("[data-preset-label]");if(e){t.stopPropagation(),this.applyPreset(e.dataset.presetLabel),this.closePopover("apply");return}let i=t.target.closest("[data-comparison-preset-label]");if(i){t.stopPropagation();let n=Ve(this.value);if(!n)return;let r=this.#A(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.#$();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())}};#w=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#l?.value||"";if(!e)return;let i=Ve(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.from=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:e,to:null}}}));let n=this.#e.to||i?.to||null;n&&this.#k({from:e,to:n})};#x=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#c?.value||"";if(!e)return;let i=Ve(this.value);this.#e||(this.#e={from:"",to:""}),this.#e.to=e,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:{from:this.#e.from||i?.from||null,to:e}}}));let n=this.#e.from||i?.from||null;n&&this.#k({from:n,to:e})};#S=t=>{this.open&&(this.contains(t.target)||this.#a&&t.composedPath?.().includes(this.#a)||this.closePopover("outside"))};#k(t,e={}){if(!t||!t.from||!t.to)return;if(!m1(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:Ve(this.compareValue),presetLabel:e.presetLabel||null}}))}#A(t,e){let i=Jg(e.from),n=Jg(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:ze(a),to:ze(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:ze(o),to:ze(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:ze(o),to:ze(a)}}default:return null}}#$(){if(!this.#a)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])",'[tabindex="0"]'].join(",");return Array.from(this.#a.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};x("date-range-picker-ui",Do);var O1=23,b1=12,CW=1,y1=59,v1=59,RR=["hour","minute"];function Pl(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 tO({h:s,m:t,s:e},i){let n=r=>String(r).padStart(2,"0");return i==="second"?`${n(s)}:${n(t)}:${n(e)}`:`${n(s)}:${n(t)}`}function Xo({h:s,m:t,s:e}){return s*3600+t*60+e}function IR(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 qo=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},placeholder:{type:String,default:"--",reflect:!1},locale:{type:String,default:"",reflect:!1}};static template=()=>null;#t=null;#e=[];#i="";#s=null;get#n(){return this.hourcycle==="h12"||this.hourcycle==="h23"?this.hourcycle:IR(this.locale)}get#r(){return this.#n==="h12"}get#a(){return this.precision==="second"}get#o(){return`${this.#n}|${this.precision}`}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Time"),this.required&&this.setAttribute("aria-required","true"),this.#l(),this.addEventListener("keydown",this.#O),this.addEventListener("focusin",this.#y),this.addEventListener("focusout",this.#b)}render(){this.#i&&this.#i!==this.#o&&this.#l(),this.#u(),this.#c()}disconnected(){super.disconnected(),this.removeEventListener("keydown",this.#O),this.removeEventListener("focusin",this.#y),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.#a,i=this.#r,n=[...RR];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"
|
|
291
291
|
aria-label="${u}" aria-valuemin="0" aria-valuemax="${d}"
|
|
292
292
|
aria-valuenow=""></span>`,l='<span data-separator aria-hidden="true">:</span>',h="";h+=a("hour","Hours",i?b1:O1),h+=l,h+=a("minute","Minutes",y1),e&&(h+=l,h+=a("second","Seconds",v1)),i&&(h+=`<span data-segment="meridiem" role="spinbutton" tabindex="0"
|
|
293
293
|
aria-label="AM/PM" aria-valuemin="0" aria-valuemax="1"
|
|
294
|
-
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.#k),u.addEventListener("input",this.#v),u.addEventListener("blur",this.#x),u.addEventListener("focus",this.#S))}this.#i=this.#o}#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=Pl(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:eO(i),minute:eO(t.m),second:eO(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=iO(i.hour,0,e==="h12"?b1:O1),r=iO(i.minute,0,y1),o=this.#a?iO(i.second,0,v1):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=Xo(a),h=Pl(this.min),c=Pl(this.max);if(h&&l<Xo(h)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(c&&l>Xo(c)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let u=tO(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=Zo(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=Zo(r.h-1,0,24);for(;r.m>59;)r.m-=60,r.h=Zo(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=Zo(r.h-1,0,24);for(;r.m>59;)r.m-=60,r.h=Zo(r.h+1,0,24)}else t==="meridiem"&&(r.h=Zo(r.h+12,0,24));let o=Xo(r),a=Pl(this.min),l=Pl(this.max);if(a&&o<Xo(a)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(l&&o>Xo(l)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let h=tO(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=tO(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(!(t instanceof Element))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}};#y=t=>{let e=this.#O(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)})};#k=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()};#v=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)};#x=t=>{let e=this.#O(t.target);e&&this.#d(e)};#S=t=>{let e=t.target;e instanceof HTMLElement&&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 eO(s){return String(s).padStart(2,"0")}function iO(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 Zo(s,t,e){let i=s-t,n=e-t;return i=(i%n+n)%n,i+t}x("time-picker-ui",qo);je();var DR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],XR=["January","February","March","April","May","June","July","August","September","October","November","December"];function sO(s){return String(s).padStart(2,"0")}function Ws(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 Au(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let n=sO(Number(i[1])),r=i[2],o=i[3]||"00";return e==="second"?`${s}T${n}:${r}:${o}`:`${s}T${n}:${r}`}function ZR(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`${XR[n]} ${r}, ${i}`;case"iso":return s;default:return`${DR[n]} ${r}, ${i}`}}function qR(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=sO(u),l=c?" PM":" AM"}else a=sO(n);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${r}${h}${l}`}var No=class extends Z{static labelDeprecated=!0;static requiredIcons=["calendar","clock","caret-down"];static get properties(){return{...Z.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select date and time",reflect:!1},format:{type:String,default:"short",reflect:!0},locale:{type:String,default:"",reflect:!1},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date and time picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date and time picker"></div>',calPane:'<calendar-grid-ui data-cal-pane aria-label="Date"></calendar-grid-ui>',divider:"<divider-ui data-pane-divider vertical></divider-ui>",timePane:"<time-picker-ui data-time-pane></time-picker-ui>"};static template=()=>null;#t=null;#e=null;#i=!1;#s=!1;#n=null;#r=null;#a=null;#o=null;#l=null;#c=null;#h=!1;get datetimeValue(){return Ws(this.value)}set datetimeValue(t){Tt(()=>{t==null?this.value="":typeof t=="string"?this.value=t:t.date&&t.time?this.value=Au(t.date,t.time,this.precision):this.value=""})}openPopover(){this.disabled||this.readonly||this.open||(this.#e=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.#t=null,this.syncValue("")}syncValue(t){let e=t??this.value??"";this.internals.setFormValue(e),this.#u(e)}#u(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date and time.",this),!1):t?Ws(t)?this.min&&t<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable datetime is ${this.min}.`,this),!1):this.max&&t>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable datetime is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0):(this.internals.setValidity({badInput:!0},"Invalid date or time format.",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.#i||(this.#i=!0,this.#d(),this.#n.addEventListener("click",this.#p),this.#n.addEventListener("keydown",this.#m,!0),this.#r.addEventListener("click",this.#O),this.#r.addEventListener("keydown",this.#g),this.#a.addEventListener("change",this.#b),this.#o.addEventListener("change",this.#k),this.#o.addEventListener("input",this.#v),this.#o.addEventListener("invalid",this.#x)),this.syncValue()}disconnected(){super.disconnected(),this.#n&&(this.#n.removeEventListener("click",this.#p),this.#n.removeEventListener("keydown",this.#m,!0)),this.#r&&(this.#r.removeEventListener("click",this.#O),this.#r.removeEventListener("keydown",this.#g),this.#r.hidePopover?.()),this.#a&&this.#a.removeEventListener("change",this.#b),this.#o&&(this.#o.removeEventListener("change",this.#k),this.#o.removeEventListener("input",this.#v),this.#o.removeEventListener("invalid",this.#x)),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#y),this.#c?.(),this.#c=null,this.#i=!1,this.#s=!1,this.#n=null,this.#r=null,this.#a=null,this.#o=null,this.#l=null,this.#t=null}#d(){if(this.#n=this.ensure("trigger"),this.#r=this.ensure("popover"),this.id&&this.#r.setAttribute("aria-labelledby",this.id),!this.#r.querySelector(":scope > [data-cal-pane]")){let e=this.constructor._pp.calPane.cloneNode(!0);this.#r.appendChild(e)}if(!this.#r.querySelector(":scope > [data-pane-divider]")){let e=this.constructor._pp.divider.cloneNode(!0);this.#r.appendChild(e)}if(!this.#r.querySelector(":scope > [data-time-pane]")){let e=this.constructor._pp.timePane.cloneNode(!0);this.#r.appendChild(e)}this.#a=this.#r.querySelector(":scope > [data-cal-pane]"),this.#l=this.#r.querySelector(":scope > [data-pane-divider]"),this.#o=this.#r.querySelector(":scope > [data-time-pane]");let t=this.querySelector(':scope > [slot="footer"]');t&&t.parentElement!==this.#r&&this.#r.appendChild(t)}render(){if(!this.#n)return;(!this.#a||!this.#o||!this.#a.isConnected)&&this.#d(),this.#n.setAttribute("text",this.#f()),this.#n.toggleAttribute("data-has-value",this.#f()!==this.placeholder),this.#n.toggleAttribute("disabled",this.disabled),this.#n.setAttribute("aria-haspopup","dialog"),this.#n.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let t=Ws(this.value),e=this.#t,i=e?.date??t?.date??"",n=e?.time??t?.time??"";if(this.#a){let r=this.min?this.min.slice(0,10):"",o=this.max?this.max.slice(0,10):"";r?this.#a.setAttribute("min",r):this.#a.removeAttribute("min"),o?this.#a.setAttribute("max",o):this.#a.removeAttribute("max"),this.#a.value!==i&&(this.#a.value=i),this.#a.toggleAttribute("disabled",!!this.disabled),this.#a.toggleAttribute("readonly",!!this.readonly)}if(this.#o){this.#o.setAttribute("precision",this.precision),this.#o.setAttribute("step",String(this.step)),this.hourcycle?this.#o.setAttribute("hour-cycle",this.hourcycle):this.#o.removeAttribute("hour-cycle"),this.locale?this.#o.setAttribute("locale",this.locale):this.#o.removeAttribute("locale");let r=this.min?this.min.slice(11):"",o=this.max?this.max.slice(11):"";r&&i===this.min.slice(0,10)?this.#o.setAttribute("min",r):this.#o.removeAttribute("min"),o&&i===this.max.slice(0,10)?this.#o.setAttribute("max",o):this.#o.removeAttribute("max"),this.#o.value!==n&&(this.#o.value=n),this.#o.toggleAttribute("disabled",!!this.disabled),this.#o.toggleAttribute("readonly",!!this.readonly)}this.#r&&(this.open&&!this.#s?!this.disabled&&!this.readonly?(this.#s=!0,this.#r.showPopover?.(),this.#c?.(),this.#c=at(this.#n,this.#r,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#y),queueMicrotask(()=>{if(!this.open)return;this.#a?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#s&&(this.#s=!1,this.#c?.(),this.#c=null,this.#r.hidePopover?.(),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#y),this.#n?.focus?.()))}#f(){let t=Ws(this.value);if(!t)return this.placeholder;let e=ZR(t.date,this.format),i=qR(t.time,this.precision,this.hourcycle);return!e||!i?this.placeholder:`${e} ${i}`}#p=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#h;this.#h=!1,this.open?this.closePopover("outside"):(this.#e=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#m=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#h=!0}};#O=t=>{let e=t.target.closest("[data-action]");if(e&&this.contains(e)){let i=e.dataset.action;i==="apply"?(this.#A("click"),this.closePopover("apply")):i==="cancel"&&(this.#t=null,this.closePopover("cancel"))}};#g=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())}};#y=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#b=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#a?.value||"";if(!e)return;this.#t||(this.#t={date:"",time:""}),this.#t.date=e;let i=Ws(this.value),n=this.#t.time||i?.time||"",r=n?Au(e,n,this.precision):`${e}T`;this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:r}})),n?this.#w({date:e,time:n}):queueMicrotask(()=>{if(!this.open)return;this.#o?.querySelector?.('[data-segment="hour"]')?.focus?.()})};#k=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#o?.value||"";if(!e)return;this.#t||(this.#t={date:"",time:""}),this.#t.time=e;let i=Ws(this.value),n=this.#t.date||i?.date||"";n?this.#w({date:n,time:e}):this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:`T${e}`}}))};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"",i=Ws(this.value),n=this.#t?.date||i?.date||"",r=n&&e?Au(n,e,this.precision):e?`T${e}`:"";this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:r}}))};#x=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:t.detail?.reason||"pane"}}))};#S=t=>{this.open&&(this.contains(t.target)||this.#r&&t.composedPath?.().includes(this.#r)||this.closePopover("outside"))};#w(t,e="click"){if(!t||!t.date||!t.time)return;let i=Au(t.date,t.time,this.precision);if(!i){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"parse"}}));return}if(this.min&&i<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"below-min"}}));return}if(this.max&&i>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"above-max"}}));return}this.value=i,this.#t=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:i,source:e}}))}#A(t="click"){let e=this.#a?.value||"",i=this.#o?.value||"";!e||!i||this.#w({date:e,time:i},t)}#P(){if(!this.#r)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","time-picker-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])","[data-segment]",'[tabindex="0"]'].join(",");return Array.from(this.#r.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};x("datetime-picker-ui",No);Q();var Bo=class extends k{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}};x("embed-ui",Bo);Q();var NR={none:"0",xs:"var(--a-space-1)",sm:"var(--a-space-2)",md:"var(--a-space-4)",lg:"var(--a-space-6)",xl:"var(--a-space-10)"};function x1(s){return NR[s]??(/^\d+$/.test(s??"")?`var(--a-space-${s})`:s??"")}var zo=class extends k{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("@")?Ae.value:"";t?.includes("@")?this.style.setProperty("--block-padding",x1(Dt(t,n))):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",x1(Dt(e,n))):this.style.removeProperty("--block-margin")}};x("block-ui",zo);Q();var BR={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function zR(s){return BR[s]??s}var Vo=class extends k{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=Ae.value;this.style.setProperty("--text-size",zR(Dt(t,e)))}else this.style.removeProperty("--text-size")}};x("text-ui",Vo);Q();var jo=class extends k{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}};static template=()=>null;#t=!1;connected(){this.setAttribute("role","button"),this.setAttribute("tabindex","0")}render(){this.#t||(this.#t=!0,this.#e()),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}#e(){let t="";this.icon&&(t+=`<icon-ui name="${this.icon}"></icon-ui>`),this.text&&(t+=`<span data-text>${this.text}</span>`),this.innerHTML=t}disconnected(){this.#t=!1}},_o=class extends k{static properties={value:{type:String,default:"",reflect:!0},single:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;get#e(){return new Set(this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[])}connected(){this.#t||(this.#t=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#n)),this.setAttribute("role","group")}render(){let t=this.#e;for(let e of this.querySelectorAll("toggle-option-ui")){let i=e.value||e.getAttribute("value")||"";t.has(i)?(e.setAttribute("data-selected",""),e.setAttribute("aria-pressed","true")):(e.removeAttribute("data-selected"),e.setAttribute("aria-pressed","false"))}}#i(t){if(t.disabled)return;let e=t.value||t.getAttribute("value")||"";if(!e)return;let i=this.#e;this.single?i.has(e)?i.clear():(i.clear(),i.add(e)):i.has(e)?i.delete(e):i.add(e),this.value=[...i].join(","),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}#s=t=>{let e=t.target.closest("toggle-option-ui");e&&this.contains(e)&&this.#i(e)};#n=t=>{if(t.key==="Enter"||t.key===" "){t.preventDefault();let e=t.target.closest("toggle-option-ui");e&&this.contains(e)&&this.#i(e)}};disconnected(){this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#n),this.#t=!1}};x("toggle-option-ui",jo),x("toggle-group-ui",_o);Q();var Li="light",Ie="dark",nO="auto",Wo=class extends k{static properties={scheme:{type:String,default:nO,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.#a(),this.#n=!0),this.#o()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="scheme"&&this.isConnected&&this.#n&&!this.#r&&e!==i&&this.#o()}disconnected(){this.#t&&this.#s&&this.#t.removeEventListener("press",this.#s),this.#O()}toggle(){this.#r=!0;let t=this.activeScheme===Ie?Li:Ie;this.#l(t,"programmatic")}setScheme(t){if(this.#r=!0,t===nO){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Li||t===Ie)&&this.#l(t,"programmatic")}#a(){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===Ie?Li:Ie;this.#l(i,"press")},t.addEventListener("press",this.#s)}#o(){let t=null;if(this.persist)try{let e=localStorage.getItem(`${this.storagePrefix}scheme`);(e===Li||e===Ie)&&(t=e)}catch{}if(t===null){let e=this.scheme||nO;(e===Li||e===Ie)&&(t=e)}t===Li||t===Ie?(this.#d(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Li&&t!==Ie)){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===Ie,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 Ie}catch{}return Li}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?Ie:Li;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}};x("toggle-scheme-ui",Wo);Q();var Yo=class extends k{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:`
|
|
294
|
+
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.#w),u.addEventListener("input",this.#v),u.addEventListener("blur",this.#x),u.addEventListener("focus",this.#S))}this.#i=this.#o}#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=Pl(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:eO(i),minute:eO(t.m),second:eO(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=iO(i.hour,0,e==="h12"?b1:O1),r=iO(i.minute,0,y1),o=this.#a?iO(i.second,0,v1):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=Xo(a),h=Pl(this.min),c=Pl(this.max);if(h&&l<Xo(h)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(c&&l>Xo(c)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let u=tO(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=Zo(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=Zo(r.h-1,0,24);for(;r.m>59;)r.m-=60,r.h=Zo(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=Zo(r.h-1,0,24);for(;r.m>59;)r.m-=60,r.h=Zo(r.h+1,0,24)}else t==="meridiem"&&(r.h=Zo(r.h+12,0,24));let o=Xo(r),a=Pl(this.min),l=Pl(this.max);if(a&&o<Xo(a)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"min"}}));return}if(l&&o>Xo(l)){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:"max"}}));return}let h=tO(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=tO(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(!(t instanceof Element))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}};#y=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)})};#w=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()};#v=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)};#x=t=>{let e=this.#g(t.target);e&&this.#d(e)};#S=t=>{let e=t.target;e instanceof HTMLElement&&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 eO(s){return String(s).padStart(2,"0")}function iO(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 Zo(s,t,e){let i=s-t,n=e-t;return i=(i%n+n)%n,i+t}x("time-picker-ui",qo);je();var DR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],XR=["January","February","March","April","May","June","July","August","September","October","November","December"];function sO(s){return String(s).padStart(2,"0")}function Ws(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 Au(s,t,e){if(!s||!t)return"";let i=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(t);if(!i)return"";let n=sO(Number(i[1])),r=i[2],o=i[3]||"00";return e==="second"?`${s}T${n}:${r}:${o}`:`${s}T${n}:${r}`}function ZR(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`${XR[n]} ${r}, ${i}`;case"iso":return s;default:return`${DR[n]} ${r}, ${i}`}}function qR(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=sO(u),l=c?" PM":" AM"}else a=sO(n);let h=t==="second"&&o!=null?`:${o}`:"";return`${a}:${r}${h}${l}`}var No=class extends Z{static labelDeprecated=!0;static requiredIcons=["calendar","clock","caret-down"];static get properties(){return{...Z.properties,min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},step:{type:Number,default:60,reflect:!0},precision:{type:String,default:"minute",reflect:!0},hourcycle:{type:String,default:"",reflect:!0,attribute:"hour-cycle"},open:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"Select date and time",reflect:!1},format:{type:String,default:"short",reflect:!0},locale:{type:String,default:"",reflect:!1},placement:{type:String,default:"bottom",reflect:!0}}}static parts={trigger:'<button-ui slot="trigger" variant="outline" type="button" icon="calendar" trailing-icon="caret-down" aria-label="Open date and time picker"></button-ui>',popover:'<div slot="popover" popover="manual" role="dialog" aria-label="Date and time picker"></div>',calPane:'<calendar-grid-ui data-cal-pane aria-label="Date"></calendar-grid-ui>',divider:"<divider-ui data-pane-divider vertical></divider-ui>",timePane:"<time-picker-ui data-time-pane></time-picker-ui>"};static template=()=>null;#t=null;#e=null;#i=!1;#s=!1;#n=null;#r=null;#a=null;#o=null;#l=null;#c=null;#h=!1;get datetimeValue(){return Ws(this.value)}set datetimeValue(t){Tt(()=>{t==null?this.value="":typeof t=="string"?this.value=t:t.date&&t.time?this.value=Au(t.date,t.time,this.precision):this.value=""})}openPopover(){this.disabled||this.readonly||this.open||(this.#e=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.#t=null,this.syncValue("")}syncValue(t){let e=t??this.value??"";this.internals.setFormValue(e),this.#u(e)}#u(t){return this.required&&!t?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please select a date and time.",this),!1):t?Ws(t)?this.min&&t<this.min?(this.internals.setValidity({rangeUnderflow:!0},`Earliest selectable datetime is ${this.min}.`,this),!1):this.max&&t>this.max?(this.internals.setValidity({rangeOverflow:!0},`Latest selectable datetime is ${this.max}.`,this),!1):(this.internals.setValidity({}),!0):(this.internals.setValidity({badInput:!0},"Invalid date or time format.",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.#i||(this.#i=!0,this.#d(),this.#n.addEventListener("click",this.#p),this.#n.addEventListener("keydown",this.#m,!0),this.#r.addEventListener("click",this.#g),this.#r.addEventListener("keydown",this.#O),this.#a.addEventListener("change",this.#b),this.#o.addEventListener("change",this.#w),this.#o.addEventListener("input",this.#v),this.#o.addEventListener("invalid",this.#x)),this.syncValue()}disconnected(){super.disconnected(),this.#n&&(this.#n.removeEventListener("click",this.#p),this.#n.removeEventListener("keydown",this.#m,!0)),this.#r&&(this.#r.removeEventListener("click",this.#g),this.#r.removeEventListener("keydown",this.#O),this.#r.hidePopover?.()),this.#a&&this.#a.removeEventListener("change",this.#b),this.#o&&(this.#o.removeEventListener("change",this.#w),this.#o.removeEventListener("input",this.#v),this.#o.removeEventListener("invalid",this.#x)),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#y),this.#c?.(),this.#c=null,this.#i=!1,this.#s=!1,this.#n=null,this.#r=null,this.#a=null,this.#o=null,this.#l=null,this.#t=null}#d(){if(this.#n=this.ensure("trigger"),this.#r=this.ensure("popover"),this.id&&this.#r.setAttribute("aria-labelledby",this.id),!this.#r.querySelector(":scope > [data-cal-pane]")){let e=this.constructor._pp.calPane.cloneNode(!0);this.#r.appendChild(e)}if(!this.#r.querySelector(":scope > [data-pane-divider]")){let e=this.constructor._pp.divider.cloneNode(!0);this.#r.appendChild(e)}if(!this.#r.querySelector(":scope > [data-time-pane]")){let e=this.constructor._pp.timePane.cloneNode(!0);this.#r.appendChild(e)}this.#a=this.#r.querySelector(":scope > [data-cal-pane]"),this.#l=this.#r.querySelector(":scope > [data-pane-divider]"),this.#o=this.#r.querySelector(":scope > [data-time-pane]");let t=this.querySelector(':scope > [slot="footer"]');t&&t.parentElement!==this.#r&&this.#r.appendChild(t)}render(){if(!this.#n)return;(!this.#a||!this.#o||!this.#a.isConnected)&&this.#d(),this.#n.setAttribute("text",this.#f()),this.#n.toggleAttribute("data-has-value",this.#f()!==this.placeholder),this.#n.toggleAttribute("disabled",this.disabled),this.#n.setAttribute("aria-haspopup","dialog"),this.#n.setAttribute("aria-expanded",this.open?"true":"false"),this.setAttribute("aria-expanded",this.open?"true":"false");let t=Ws(this.value),e=this.#t,i=e?.date??t?.date??"",n=e?.time??t?.time??"";if(this.#a){let r=this.min?this.min.slice(0,10):"",o=this.max?this.max.slice(0,10):"";r?this.#a.setAttribute("min",r):this.#a.removeAttribute("min"),o?this.#a.setAttribute("max",o):this.#a.removeAttribute("max"),this.#a.value!==i&&(this.#a.value=i),this.#a.toggleAttribute("disabled",!!this.disabled),this.#a.toggleAttribute("readonly",!!this.readonly)}if(this.#o){this.#o.setAttribute("precision",this.precision),this.#o.setAttribute("step",String(this.step)),this.hourcycle?this.#o.setAttribute("hour-cycle",this.hourcycle):this.#o.removeAttribute("hour-cycle"),this.locale?this.#o.setAttribute("locale",this.locale):this.#o.removeAttribute("locale");let r=this.min?this.min.slice(11):"",o=this.max?this.max.slice(11):"";r&&i===this.min.slice(0,10)?this.#o.setAttribute("min",r):this.#o.removeAttribute("min"),o&&i===this.max.slice(0,10)?this.#o.setAttribute("max",o):this.#o.removeAttribute("max"),this.#o.value!==n&&(this.#o.value=n),this.#o.toggleAttribute("disabled",!!this.disabled),this.#o.toggleAttribute("readonly",!!this.readonly)}this.#r&&(this.open&&!this.#s?!this.disabled&&!this.readonly?(this.#s=!0,this.#r.showPopover?.(),this.#c?.(),this.#c=at(this.#n,this.#r,{placement:this.getAttribute("placement")||"bottom",gap:4}),document.addEventListener("pointerdown",this.#S),document.addEventListener("keydown",this.#y),queueMicrotask(()=>{if(!this.open)return;this.#a?.querySelector?.("[data-cal-day]:not([disabled]):not([data-outside])")?.focus?.()})):this.open=!1:!this.open&&this.#s&&(this.#s=!1,this.#c?.(),this.#c=null,this.#r.hidePopover?.(),document.removeEventListener("pointerdown",this.#S),document.removeEventListener("keydown",this.#y),this.#n?.focus?.()))}#f(){let t=Ws(this.value);if(!t)return this.placeholder;let e=ZR(t.date,this.format),i=qR(t.time,this.precision,this.hourcycle);return!e||!i?this.placeholder:`${e} ${i}`}#p=t=>{if(this.disabled||this.readonly)return;t.stopPropagation();let e=this.#h;this.#h=!1,this.open?this.closePopover("outside"):(this.#e=document.activeElement,this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:e?"keyboard":"click"}})))};#m=t=>{if(!this.disabled&&(t.key==="Enter"||t.key===" ")){if(this.readonly){t.preventDefault();return}this.#h=!0}};#g=t=>{let e=t.target.closest("[data-action]");if(e&&this.contains(e)){let i=e.dataset.action;i==="apply"?(this.#A("click"),this.closePopover("apply")):i==="cancel"&&(this.#t=null,this.closePopover("cancel"))}};#O=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),this.closePopover("escape");return}if(t.key==="Tab"){let e=this.#$();if(e.length===0)return;let i=e.indexOf(document.activeElement);t.shiftKey?i<=0&&(t.preventDefault(),e[e.length-1].focus()):(i===-1||i===e.length-1)&&(t.preventDefault(),e[0].focus())}};#y=t=>{t.key==="Escape"&&this.open&&this.closePopover("escape")};#b=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#a?.value||"";if(!e)return;this.#t||(this.#t={date:"",time:""}),this.#t.date=e;let i=Ws(this.value),n=this.#t.time||i?.time||"",r=n?Au(e,n,this.precision):`${e}T`;this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:r}})),n?this.#k({date:e,time:n}):queueMicrotask(()=>{if(!this.open)return;this.#o?.querySelector?.('[data-segment="hour"]')?.focus?.()})};#w=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||this.#o?.value||"";if(!e)return;this.#t||(this.#t={date:"",time:""}),this.#t.time=e;let i=Ws(this.value),n=this.#t.date||i?.date||"";n?this.#k({date:n,time:e}):this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:`T${e}`}}))};#v=t=>{if(this.readonly)return;t.stopPropagation();let e=t.detail?.value||"",i=Ws(this.value),n=this.#t?.date||i?.date||"",r=n&&e?Au(n,e,this.precision):e?`T${e}`:"";this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:r}}))};#x=t=>{t.stopPropagation(),this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:this.value,reason:t.detail?.reason||"pane"}}))};#S=t=>{this.open&&(this.contains(t.target)||this.#r&&t.composedPath?.().includes(this.#r)||this.closePopover("outside"))};#k(t,e="click"){if(!t||!t.date||!t.time)return;let i=Au(t.date,t.time,this.precision);if(!i){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"parse"}}));return}if(this.min&&i<this.min){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"below-min"}}));return}if(this.max&&i>this.max){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:i,reason:"above-max"}}));return}this.value=i,this.#t=null,this.syncValue(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:i,source:e}}))}#A(t="click"){let e=this.#a?.value||"",i=this.#o?.value||"";!e||!i||this.#k({date:e,time:i},t)}#$(){if(!this.#r)return[];let t=["button-ui:not([disabled])","button:not([disabled])","calendar-grid-ui:not([disabled])","time-picker-ui:not([disabled])","[data-cal-day]:not([disabled]):not([data-outside])","[data-segment]",'[tabindex="0"]'].join(",");return Array.from(this.#r.querySelectorAll(t)).filter(e=>e.offsetParent!==null||e.matches(":popover-open *"))}};x("datetime-picker-ui",No);Q();var Bo=class extends k{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}};x("embed-ui",Bo);Q();var NR=new Set(["xs","sm","md","lg","xl"]);function x1(s,t){return s==null||s===""?"":s==="none"?"0":NR.has(s)?`var(--a-${t}-${s})`:/^\d+$/.test(s)?`var(--a-space-${s})`:s}var zo=class extends k{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("@")?Ae.value:"";t?.includes("@")?this.style.setProperty("--block-padding",x1(Dt(t,n),"padding")):this.style.removeProperty("--block-padding"),e?.includes("@")?this.style.setProperty("--block-margin",x1(Dt(e,n),"margin")):this.style.removeProperty("--block-margin")}};x("block-ui",zo);Q();var BR={sm:"var(--a-body-sm)",md:"var(--a-body-md)",lg:"var(--a-body-lg)"};function zR(s){return BR[s]??s}var Vo=class extends k{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=Ae.value;this.style.setProperty("--text-size",zR(Dt(t,e)))}else this.style.removeProperty("--text-size")}};x("text-ui",Vo);Q();var jo=class extends k{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}};static template=()=>null;#t=!1;connected(){this.setAttribute("role","button"),this.setAttribute("tabindex","0")}render(){this.#t||(this.#t=!0,this.#e()),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}#e(){let t="";this.icon&&(t+=`<icon-ui name="${this.icon}"></icon-ui>`),this.text&&(t+=`<span data-text>${this.text}</span>`),this.innerHTML=t}disconnected(){this.#t=!1}},_o=class extends k{static properties={value:{type:String,default:"",reflect:!0},single:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;get#e(){return new Set(this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[])}connected(){this.#t||(this.#t=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#n)),this.setAttribute("role","group")}render(){let t=this.#e;for(let e of this.querySelectorAll("toggle-option-ui")){let i=e.value||e.getAttribute("value")||"";t.has(i)?(e.setAttribute("data-selected",""),e.setAttribute("aria-pressed","true")):(e.removeAttribute("data-selected"),e.setAttribute("aria-pressed","false"))}}#i(t){if(t.disabled)return;let e=t.value||t.getAttribute("value")||"";if(!e)return;let i=this.#e;this.single?i.has(e)?i.clear():(i.clear(),i.add(e)):i.has(e)?i.delete(e):i.add(e),this.value=[...i].join(","),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}#s=t=>{let e=t.target.closest("toggle-option-ui");e&&this.contains(e)&&this.#i(e)};#n=t=>{if(t.key==="Enter"||t.key===" "){t.preventDefault();let e=t.target.closest("toggle-option-ui");e&&this.contains(e)&&this.#i(e)}};disconnected(){this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#n),this.#t=!1}};x("toggle-option-ui",jo),x("toggle-group-ui",_o);Q();var Li="light",Ie="dark",nO="auto",Wo=class extends k{static properties={scheme:{type:String,default:nO,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.#a(),this.#n=!0),this.#o()}attributeChangedCallback(t,e,i){super.attributeChangedCallback(t,e,i),t==="scheme"&&this.isConnected&&this.#n&&!this.#r&&e!==i&&this.#o()}disconnected(){this.#t&&this.#s&&this.#t.removeEventListener("press",this.#s),this.#g()}toggle(){this.#r=!0;let t=this.activeScheme===Ie?Li:Ie;this.#l(t,"programmatic")}setScheme(t){if(this.#r=!0,t===nO){this.#f();let e=this.#p();this.activeScheme=e,this.#c(),this.#m(),this.#h("programmatic")}else(t===Li||t===Ie)&&this.#l(t,"programmatic")}#a(){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===Ie?Li:Ie;this.#l(i,"press")},t.addEventListener("press",this.#s)}#o(){let t=null;if(this.persist)try{let e=localStorage.getItem(`${this.storagePrefix}scheme`);(e===Li||e===Ie)&&(t=e)}catch{}if(t===null){let e=this.scheme||nO;(e===Li||e===Ie)&&(t=e)}t===Li||t===Ie?(this.#d(t),this.activeScheme=t):(this.activeScheme=this.#p(),this.#m()),this.#c()}#l(t,e){if(!(t!==Li&&t!==Ie)){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===Ie,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 Ie}catch{}return Li}#m(){if(!(this.#e||typeof matchMedia!="function"))try{this.#e=matchMedia("(prefers-color-scheme: dark)"),this.#i=()=>{let t=this.#e.matches?Ie:Li;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}};x("toggle-scheme-ui",Wo);Q();var Yo=class extends k{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:`
|
|
295
295
|
<row-ui slot="bar" gap="3" align="center" data-demo-toggle-bar>
|
|
296
296
|
<text-ui slot="label" data-demo-toggle-label></text-ui>
|
|
297
297
|
<switch-ui slot="switch" data-demo-toggle-switch></switch-ui>
|
|
@@ -306,20 +306,20 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
306
306
|
`}).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.#a(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.#a(r)};#a(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)}};x("rating-ui",na);Q();var ra=class extends k{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})=>`
|
|
307
307
|
<dt data-dl-term>${this.#e(e)}</dt>
|
|
308
308
|
<dd data-dl-desc>${this.#e(i)}</dd>
|
|
309
|
-
`).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,"&").replace(/</g,"<").replace(/>/g,">")}};x("description-list-ui",ra);Q();var aI=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],oa=class extends k{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:aI[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-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]")}#a(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}}#o=null;#l=t=>{let e=this.#r(t.target);if(!e||!e.dataset.v)return;this.#o=e;let i=this.#a(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.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})));return}if(e!==this.#o){this.#o=e;let i=this.#a(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.#a(e,t);this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}};#h=()=>{this.#o&&(this.#o=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.#a(e,t);this.dispatchEvent(new CustomEvent("cell-click",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-select",{detail:i,bubbles:!0}))}};x("heatmap-ui",oa);Q();var G1=new Set(["idle","active","done","error"]);function wO(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function lI(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var aa=class extends k{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;#a=null;#o=!1;#l=null;#c=0;get entries(){return this.#t}connected(){this.#o||(this.#o=!0,this.#i=Date.now(),this.#s=setInterval(()=>this.#$(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#k()}))}),this.#l.observe(this)))}#h=t=>{let e=t.target.closest("timeline-item-ui[data-step-id]");!e||!this.#a?.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.#a?.removeEventListener("timeline-toggle",this.#h),this.#r=null,this.#a=null,this.#o=!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=G1.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.#a=document.createElement("div"),this.#a.setAttribute("data-reasoning-body",""),this.#a.addEventListener("timeline-toggle",this.#h),this.appendChild(this.#a),this.#b()}#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>"}}#y(){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=G1.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:n}=this.#y(),r=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#O();if(this.#r.innerHTML=`
|
|
310
|
-
${this.#
|
|
309
|
+
`).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,"&").replace(/</g,"<").replace(/>/g,">")}};x("description-list-ui",ra);Q();var aI=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],oa=class extends k{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:aI[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-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]")}#a(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}}#o=null;#l=t=>{let e=this.#r(t.target);if(!e||!e.dataset.v)return;this.#o=e;let i=this.#a(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.#o&&(this.#o=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0})));return}if(e!==this.#o){this.#o=e;let i=this.#a(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.#a(e,t);this.dispatchEvent(new CustomEvent("chart-hover",{detail:i,bubbles:!0}))}};#h=()=>{this.#o&&(this.#o=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.#a(e,t);this.dispatchEvent(new CustomEvent("cell-click",{detail:i,bubbles:!0})),this.dispatchEvent(new CustomEvent("chart-select",{detail:i,bubbles:!0}))}};x("heatmap-ui",oa);Q();var G1=new Set(["idle","active","done","error"]);function wO(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function lI(s){return s<1e3?s+"ms":Math.round(s/1e3)+"s"}var aa=class extends k{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;#a=null;#o=!1;#l=null;#c=0;get entries(){return this.#t}connected(){this.#o||(this.#o=!0,this.#i=Date.now(),this.#s=setInterval(()=>this.#T(),1e3),this.#m(),typeof ResizeObserver<"u"&&(this.#l=new ResizeObserver(()=>{this.#c||(this.#c=requestAnimationFrame(()=>{this.#c=0,this.#w()}))}),this.#l.observe(this)))}#h=t=>{let e=t.target.closest("timeline-item-ui[data-step-id]");!e||!this.#a?.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.#a?.removeEventListener("timeline-toggle",this.#h),this.#r=null,this.#a=null,this.#o=!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=G1.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.#a=document.createElement("div"),this.#a.setAttribute("data-reasoning-body",""),this.#a.addEventListener("timeline-toggle",this.#h),this.appendChild(this.#a),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>"}}#y(){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=G1.has(this.status)?this.status:"active",e=t==="done"||t==="error",{total:i,done:n}=this.#y(),r=Math.round((Date.now()-this.#i)/1e3),o=e&&this.dataset.summary?this.dataset.summary:this.#g();if(this.#r.innerHTML=`
|
|
310
|
+
${this.#O(t)}
|
|
311
311
|
<span data-reasoning-label>${wO(o)}</span>
|
|
312
312
|
<span data-reasoning-meta>
|
|
313
313
|
${i?`<span data-reasoning-counter>${n}/${i}</span>`:""}
|
|
314
314
|
<span data-reasoning-time>${r}s</span>
|
|
315
315
|
<icon-ui name="${this.collapsed?"caret-right":"caret-up"}" color="muted" data-reasoning-caret></icon-ui>
|
|
316
316
|
</span>
|
|
317
|
-
`,this.#a.hidden=this.collapsed,this.#r.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#a.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#v(),this.#a.appendChild(a)),a.appendChild(this.#x(l))):(a=null,this.#a.appendChild(this.#S(l)));this.#
|
|
317
|
+
`,this.#a.hidden=this.collapsed,this.#r.setAttribute("aria-expanded",String(!this.collapsed)),this.collapsed)return;this.#a.innerHTML="";let a=null;for(let l of this.#t)l.kind==="step"?(a||(a=this.#v(),this.#a.appendChild(a)),a.appendChild(this.#x(l))):(a=null,this.#a.appendChild(this.#S(l)));this.#w()}#w(){let t=this.#a;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","")}#v(){let t=document.createElement("timeline-ui");return t.setAttribute("size","sm"),t}#x(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?lI(t.duration):"");return i&&e.setAttribute("duration",i),t.outcomes?.length&&(e.outcomes=t.outcomes),e.dataset.stepId=t.id||"",e}#S(t){switch(t.kind){case"thought":return this.#k(t);case"plan":return this.#A(t);case"iteration":return this.#$(t);default:return document.createTextNode("")}}#k(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}#A(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}#$(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=`
|
|
318
318
|
${n}
|
|
319
319
|
<span data-reasoning-iter-n>#${t.n}</span>
|
|
320
320
|
<span data-reasoning-iter-label>${wO(t.label||"")}</span>
|
|
321
321
|
${t.summary?`<span data-reasoning-iter-summary>${wO(t.summary)}</span>`:""}
|
|
322
|
-
`,e.appendChild(i),t.steps?.length){let r=this.#v();for(let o of t.steps)r.appendChild(this.#x(o));e.appendChild(r)}return e}
|
|
322
|
+
`,e.appendChild(i),t.steps?.length){let r=this.#v();for(let o of t.steps)r.appendChild(this.#x(o));e.appendChild(r)}return e}#T(){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)}};x("agent-reasoning-ui",aa);Q();var Ml=class extends k{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.#a()}get metrics(){return this.#e}set metrics(t){this.#e=Array.isArray(t)?t.slice():[],this.#a()}get feedback(){return this.#i}set feedback(t){this.#i=Array.isArray(t)?t.slice():[],this.#a()}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.#a()}#a(){if(!this.#s)return;let t=this.#t.length?this.#t.map(a=>this.#h(a)).join("<span data-trace-sep>\xB7</span>"):`<span>${es(this.label||"Trace")}</span>`,e=this.#e.some(a=>a.aux!=null&&String(a.aux).trim()!==""),i=this.#e.some(a=>this.#o(a)),n=this.#e.length?`
|
|
323
323
|
<div data-trace-headers>
|
|
324
324
|
<span data-trace-header>Stage</span>
|
|
325
325
|
<span data-trace-header>Score</span>
|