aktion-runtime 0.5.6 → 0.5.8
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/README.md +7 -1
- package/dist/aktion.iife.js +33 -33
- package/dist/aktion.iife.js.map +1 -1
- package/dist/aktion.js +23005 -22882
- package/dist/aktion.js.map +1 -1
- package/dist/aktion.umd.cjs +33 -33
- package/dist/aktion.umd.cjs.map +1 -1
- package/dist/testing.js +987 -10
- package/dist/testing.js.map +1 -1
- package/dist/types/element.d.ts +43 -0
- package/package.json +1 -1
package/dist/aktion.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(P,fe){typeof exports=="object"&&typeof module<"u"?fe(exports):typeof define=="function"&&define.amd?define(["exports"],fe):(P=typeof globalThis<"u"?globalThis:P||self,fe(P.Aktion={}))})(this,function(P){"use strict";var
|
|
1
|
+
(function(P,fe){typeof exports=="object"&&typeof module<"u"?fe(exports):typeof define=="function"&&define.amd?define(["exports"],fe):(P=typeof globalThis<"u"?globalThis:P||self,fe(P.Aktion={}))})(this,function(P){"use strict";var jg=Object.defineProperty;var Bg=(P,fe,Je)=>fe in P?jg(P,fe,{enumerable:!0,configurable:!0,writable:!0,value:Je}):P[fe]=Je;var z=(P,fe,Je)=>Bg(P,typeof fe!="symbol"?fe+"":fe,Je);const fe=new Set(["function","import","export","if","else","switch","case","break","continue","for","while","do","of","in","let","var","const","await","async","return","default","try","catch","finally","throw","new","typeof","instanceof","delete","void"]),Je=new Set(["(",")","[","]","{","}",",",":","?","."]),bo={true:"Boolean",false:"Boolean",null:"Null"};function ma(t){const e=[];let r=0,a=1,n=1;const i=(c=0)=>t[r+c],o=(c,u,p,d)=>{e.push({type:c,value:u,line:p,column:d})},s=()=>{const c=t[r];return r+=1,c===`
|
|
2
2
|
`?(a+=1,n=1):n+=1,c};for(;r<t.length;){const c=i();if(c===void 0)break;if(c===`
|
|
3
3
|
`){const b=a,h=n;s(),o("Newline",`
|
|
4
4
|
`,b,h);continue}if(c===" "||c===" "||c==="\r"){s();continue}if(c==="/"&&i(1)==="/"){for(;r<t.length&&i()!==`
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
`;break;case"t":y+=" ";break;case"r":y+="\r";break;case"\\":y+="\\";break;case'"':y+='"';break;case"'":y+="'";break;case"`":y+="`";break;default:y+=x??""}continue}if(i()===`
|
|
7
7
|
`)break;y+=s()}i()===b&&s(),o("String",y,h,v);continue}if(c==="`"){const b=a,h=n;s();const v=[];let y="",x=!1;for(;r<t.length&&i()!=="`";){if(i()==="\\"&&i(1)!==void 0){s();const w=s();switch(w){case"n":y+=`
|
|
8
8
|
`;break;case"t":y+=" ";break;case"r":y+="\r";break;case"\\":y+="\\";break;case'"':y+='"';break;case"'":y+="'";break;case"`":y+="`";break;case"$":y+="$";break;default:y+=w??""}continue}if(i()==="$"&&i(1)==="{"){v.push({kind:"str",text:y}),y="";const w=a,k=n;s(),s();let T=1,S="";for(;r<t.length&&T>0;){const C=i();if(C===void 0)break;if(C==="`"){for(S+=s();r<t.length&&i()!=="`";){if(i()==="\\"&&i(1)!==void 0){S+=s(),S+=s();continue}S+=s()}i()==="`"&&(S+=s());continue}if(C==='"'||C==="'"){const N=C;for(S+=s();r<t.length&&i()!==N;){if(i()==="\\"&&i(1)!==void 0){S+=s(),S+=s();continue}if(i()===`
|
|
9
|
-
`)break;S+=s()}i()===N&&(S+=s());continue}if(C==="{"){T+=1,S+=s();continue}if(C==="}"){if(T-=1,T===0){s();break}S+=s();continue}S+=s()}v.push({kind:"expr",source:S,line:w,column:k}),x=!0;continue}y+=s()}if(i()==="`"&&s(),v.push({kind:"str",text:y}),!x){o("String",y,b,h);continue}e.push({type:"TemplateString",value:"",line:b,column:h,parts:v});continue}const u=e[e.length-1],p=!u||u.type==="Newline"||u.type==="Semicolon"||u.type==="Operator"||u.type==="Punctuation"&&(u.value==="("||u.value==="["||u.value===","||u.value===":"||u.value==="?"||u.value==="{");if(Ie(c)||c==="-"&&Ie(i(1)??"")&&p||c==="."&&Ie(i(1)??"")&&p){const b=a,h=n;let v="";c==="-"&&(v+=s());const y=i(1);if(i()==="0"&&(y==="x"||y==="X"||y==="b"||y==="B"||y==="o"||y==="O")){for(v+=s(),v+=s();r<t.length;){const k=i()??"";if(fa(k)){v+=s();continue}if(k==="_"&&fa(i(1)??"")){v+=s();continue}break}o("Number",v,b,h);continue}let x=!1,w=!1;for(;r<t.length;){const k=i()??"";if(Ie(k)){v+=s();continue}if(k==="_"&&Ie(i(1)??"")){v+=s();continue}if(k==="."&&!x&&!w&&Ie(i(1)??"")){x=!0,v+=s();continue}if((k==="e"||k==="E")&&!w){const T=i(1)??"",S=T==="+"||T==="-"?i(2)??"":T;if(Ie(S)){w=!0,v+=s(),(i()==="+"||i()==="-")&&(v+=s());continue}}break}o("Number",v,b,h);continue}if(c==="$"){const b=a,h=n;s();let v="";for(;r<t.length&&ha(i()??"");)v+=s();o("StateIdentifier",v,b,h);continue}if(ga(c)){const b=a,h=n;let v="";for(;r<t.length&&ha(i()??"");)v+=s();const y=fo[v];y==="Boolean"?o("Boolean",v,b,h):y==="Null"?o("Null",v,b,h):fe.has(v)?o("Keyword",v,b,h):o("Identifier",v,b,h);continue}if(c==="."&&i(1)==="."&&i(2)==="."){const b=a,h=n;s(),s(),s(),o("Operator","...",b,h);continue}const d=c+(i(1)??""),m=d+(i(2)??""),g=m+(i(3)??"");if(g===">>>="){const b=a,h=n;s(),s(),s(),s(),o("Operator",g,b,h);continue}if(m==="==="||m==="!=="||m==="**="||m==="??="||m==="&&="||m==="||="||m===">>>"||m===">>="||m==="<<="){const b=a,h=n;s(),s(),s(),o("Operator",m,b,h);continue}if(d==="=="||d==="!="||d===">="||d==="<="||d==="&&"||d==="||"||d==="??"||d==="?."||d==="->"||d==="=>"||d==="**"||d==="%="||d==="+="||d==="-="||d==="*="||d==="/="||d==="++"||d==="--"||d==="<<"||d===">>"||d==="&="||d==="|="||d==="^="){const b=a,h=n;s(),s(),o("Operator",d,b,h);continue}if("+-*/%!=<>&|^~".includes(c)){const b=a,h=n;s(),o("Operator",c,b,h);continue}if(Je.has(c)){const b=a,h=n;s(),o("Punctuation",c,b,h);continue}s()}return e.push({type:"EOF",value:"",line:a,column:n}),e}function Ie(t){return t>="0"&&t<="9"}function fa(t){return t>="0"&&t<="9"||t>="a"&&t<="f"||t>="A"&&t<="F"}function ga(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function ha(t){return ga(t)||Ie(t)}function ge(t){const e=ma(t),r=new wo(e),a=[],n=[];for(;!r.isEnd();)if(!(r.match("Newline")||r.match("Semicolon")))try{const i=At(r,!0);i&&a.push(i)}catch(i){const o=i;n.push(o),r.recoverToNextLine()}return{statements:a,errors:n}}function At(t,e){const r=t.peek();if(r.type==="StateIdentifier"&&r.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="(")return ho(t);if(r.type==="Keyword")switch(r.value){case"function":return Tt(t);case"import":return ko(t);case"export":return So(t);case"await":return yo(t);case"async":{if(t.peek(1).type==="Keyword"&&t.peek(1).value==="function")return t.consume(),Tt(t);break}case"return":return xo(t);case"let":case"const":case"var":return ar(t);case"if":return La(t);case"switch":return Po(t);case"for":return Io(t);case"while":return Lo(t);case"do":return zo(t);case"break":return Ro(t);case"continue":return Do(t);case"throw":return jo(t);case"try":return Bo(t)}const a=t.snapshot();if(ba(t))try{return wa(t)}catch(n){if(n&&typeof n=="object"&&n.__definitive)throw n;t.restore(a)}return go(t)}function ba(t){const e=t.peek();if(e.type!=="Identifier"&&e.type!=="StateIdentifier")return!1;const r=t.peek(1);return r.type==="Operator"&&r.value==="="}function go(t){const e=t.peek();let r=F(t);const a=t.peek();if(a.type==="Operator"&&va(a.value)){if(ya(r)){t.consume();const n=F(t);r={kind:"BuiltinCall",name:"__rui_assign__",arguments:[r,n,{kind:"Literal",value:a.value}],loc:{line:a.line,column:a.column}}}}else a.type==="Operator"&&(a.value==="++"||a.value==="--")&&ya(r)&&(t.consume(),r={kind:"BuiltinCall",name:"__rui_postfix__",arguments:[r,{kind:"Literal",value:a.value}],loc:{line:a.line,column:a.column}});return ae(t),{kind:"ExpressionStatement",expression:r,loc:{line:e.line,column:e.column}}}function va(t){return t==="="||t==="+="||t==="-="||t==="*="||t==="/="||t==="%="||t==="**="||t==="??="||t==="&&="||t==="||="||t==="&="||t==="|="||t==="^="||t==="<<="||t===">>="||t===">>>="}function ya(t){return t.kind==="Member"||t.kind==="StateRef"||t.kind==="Identifier"}function Tt(t){const e=t.expect("Keyword","function"),r=t.peek().type==="StateIdentifier",a=r?t.consume():t.expect("Identifier"),n=xa(t),i=Fe(t);return ae(t),r?{kind:"HookDeclaration",name:a.value,params:n,body:i,loc:{line:e.line,column:e.column}}:a.value.length>0&&a.value[0]>="A"&&a.value[0]<="Z"?{kind:"ComponentDeclaration",name:a.value,params:n,slots:[],body:i,loc:{line:e.line,column:e.column}}:{kind:"ActionDeclaration",name:a.value,params:n,body:i,loc:{line:e.line,column:e.column}}}function xa(t){t.expect("Punctuation","(");const e=[];if(z(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){z(t);let r=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),r=!0);const a=t.peek();if(!r&&a.type==="Punctuation"&&(a.value==="{"||a.value==="[")){const n=nr(t);let i;t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=F(t));const o={name:"",pattern:n};i&&(o.defaultValue=i),e.push(o)}else if(a.type==="Identifier"||a.type==="Keyword"){const n=t.consume();let i;!r&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=F(t));const o={name:n.value};i&&(o.defaultValue=i),r&&(o.rest=!0),e.push(o)}else throw{message:`Expected parameter name, got ${a.type} "${a.value}"`,line:a.line,column:a.column};if(z(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(r)throw{message:"Rest parameter `...name` must be the final parameter.",line:t.peek().line,column:t.peek().column};if(t.consume(),z(t),t.peek().type==="Punctuation"&&t.peek().value===")")break;continue}break}return t.expect("Punctuation",")"),e}function ho(t){const e=t.consume();t.expect("Punctuation","("),z(t);const r=F(t);let a;r.kind==="Lambda"?a=r.body.kind==="Block"?r.body:{kind:"Block",body:[{kind:"ExpressionStatement",expression:r.body}]}:a={kind:"Block",body:[]};const n=[];let i;if(z(t),t.peek().type==="Punctuation"&&t.peek().value===",")if(t.consume(),z(t),t.peek().type==="Punctuation"&&t.peek().value==="["){for(t.consume(),z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");)bo(t,n,s=>{i=s}),z(t),t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),z(t));t.expect("Punctuation","]")}else F(t);z(t),t.expect("Punctuation",")"),ae(t);const o={kind:"EffectDeclaration",name:`__effect_L${e.line}_C${e.column}`,triggers:n,body:a,loc:{line:e.line,column:e.column}};return i&&(o.rateLimit=i),o}function bo(t,e,r){const a=t.peek();if(a.type==="StateIdentifier"){t.consume();let n=a.value;for(;t.peek().type==="Punctuation"&&t.peek().value===".";){const i=t.peek(1);if(i.type!=="Identifier"&&i.type!=="Keyword")break;t.consume(),t.consume(),n+="."+i.value}e.push({kind:"state",name:n});return}if(a.type==="String"){t.consume();const n=a.value;if(n==="mount"||n==="unmount"){e.push({kind:"lifecycle",name:n});return}const i=n.match(/^every\((\d+)\)$/);if(i){e.push({kind:"every",intervalMs:Number(i[1])});return}const o=n.match(/^debounce\((\d+)\)$/);if(o){r({kind:"debounce",ms:Number(o[1])});return}const s=n.match(/^throttle\((\d+)\)$/);if(s){r({kind:"throttle",ms:Number(s[1])});return}throw{message:`Unknown effect dependency string "${n}". Expected "mount", "unmount", "every(N)", "debounce(N)", or "throttle(N)".`,line:a.line,column:a.column}}throw{message:`Unexpected ${a.type} "${a.value}" inside effect dependency array. Expected $state or a string token ("mount", "unmount", "every(N)", etc.).`,line:a.line,column:a.column}}function ar(t){const e=t.consume(),r=t.peek();if(r.type==="Punctuation"&&(r.value==="["||r.value==="{"))return vo(t,e);let a="",n=!1;if(r.type==="StateIdentifier")a=t.consume().value,n=!0;else if(r.type==="Identifier")a=t.consume().value;else throw{message:`Expected identifier after "${e.value}", got ${r.type} "${r.value}"`,line:r.line,column:r.column};t.expect("Operator","=");const i=F(t);return ae(t),{kind:"Assignment",identifier:a,isState:n,expression:i,loc:{line:e.line,column:e.column}}}function vo(t,e){const r=nr(t);t.expect("Operator","=");const a=F(t);return ae(t),{kind:"DestructureStatement",patternKind:r.kind,bindings:r.bindings,expression:a,loc:{line:e.line,column:e.column}}}function nr(t){const r=t.consume().value==="["?"array":"object",a=[];if(r==="array"){for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");){if(t.peek().type==="Punctuation"&&t.peek().value===","){a.push({name:""}),t.consume(),z(t);continue}let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.expect("Identifier");let o;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),o=F(t));const s={name:i.value};if(n&&(s.rest=!0),o&&(s.defaultValue=o),a.push(s),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),z(t);continue}break}t.expect("Punctuation","]")}else{for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.expect("Identifier");let o=i.value,s;if(!n&&t.peek().type==="Punctuation"&&t.peek().value===":"){t.consume();const p=t.expect("Identifier");s=i.value,o=p.value}let c;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),c=F(t));const u={name:o};if(s&&(u.sourceKey=s),n&&(u.rest=!0),c&&(u.defaultValue=c),a.push(u),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),z(t);continue}break}t.expect("Punctuation","}")}return{kind:r,bindings:a}}function Fe(t){const e=t.expect("Punctuation","{"),r=[];for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const a=At(t);a&&r.push(a),z(t)}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function Ze(t){if(z(t),t.peek().type==="Punctuation"&&t.peek().value==="{")return Fe(t);const e=t.peek(),r=At(t);return{kind:"Block",body:r?[r]:[],loc:{line:e.line,column:e.column}}}function yo(t){const e=t.expect("Keyword","await"),r=F(t);return ae(t),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function xo(t){const e=t.expect("Keyword","return");let r;const a=t.peek();return a.type!=="Newline"&&a.type!=="Semicolon"&&!(a.type==="Punctuation"&&a.value==="}")&&(r=F(t)),ae(t),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class wo{constructor(e){D(this,"index",0);this.tokens=e}isEnd(){return this.peek().type==="EOF"}peek(e=0){return this.tokens[this.index+e]??{type:"EOF",value:"",line:0,column:0}}consume(){const e=this.tokens[this.index]??{type:"EOF",value:"",line:0,column:0};return this.index+=1,e}match(e,r){const a=this.peek();return a.type!==e||r!==void 0&&a.value!==r?!1:(this.consume(),!0)}expect(e,r){const a=this.peek();if(a.type!==e||r!==void 0&&a.value!==r)throw{message:`Expected ${e}${r!==void 0?` "${r}"`:""} but got ${a.type} "${a.value}"`,line:a.line,column:a.column};return this.consume()}recoverToNextLine(){for(;!this.isEnd()&&this.peek().type!=="Newline"&&this.peek().type!=="Semicolon";)this.consume();(this.peek().type==="Newline"||this.peek().type==="Semicolon")&&this.consume()}snapshot(){return this.index}restore(e){this.index=e}}function wa(t){const e=t.peek();let r="",a=!1;if(e.type==="Identifier")r=t.consume().value;else if(e.type==="StateIdentifier")r=t.consume().value,a=!0;else throw{message:`Expected identifier at start of statement, got ${e.type} "${e.value}"`,line:e.line,column:e.column};const n=t.expect("Operator","="),i=F(t);return ae(t),{kind:"Assignment",identifier:r,isState:a,expression:i,loc:{line:n.line,column:n.column}}}function ko(t){const e=t.expect("Keyword","import");t.expect("Punctuation","{");const r=[];for(;!t.isEnd()&&!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const i=t.peek();let o,s=!1;if(i.type==="StateIdentifier")o=t.consume().value,s=!0;else if(i.type==="Identifier")o=t.consume().value;else throw{message:`Expected an import name, got ${i.type} "${i.value}"`,line:i.line,column:i.column};let c=o;if(t.peek().type==="Identifier"&&t.peek().value==="as"){t.consume();const u=t.peek();let p=!1;if(u.type==="StateIdentifier")c=t.consume().value,p=!0;else if(u.type==="Identifier")c=t.consume().value;else throw{message:`Expected an alias after \`as\`, got ${u.type} "${u.value}"`,line:u.line,column:u.column};if(p!==s)throw{message:"A `$state` import must keep its `$` across `as` (e.g. `{ $x as $y }`); a non-state import must not gain one.",line:u.line,column:u.column}}if(r.push(s?{imported:o,local:c,isState:!0}:{imported:o,local:c}),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}t.expect("Punctuation","}");const a=t.peek();if(!(a.type==="Identifier"&&a.value==="from"))throw{message:`Expected \`from\` after import specifiers, got ${a.type} "${a.value}"`,line:a.line,column:a.column};t.consume();const n=t.expect("String");return ae(t),{kind:"Import",specifiers:r,source:n.value,loc:{line:e.line,column:e.column}}}function So(t){const e=t.expect("Keyword","export"),r=t.peek();if(r.type==="Punctuation"&&r.value==="{")throw{message:"`export { … }` lists are not supported yet — use inline `export <declaration>` (e.g. `export function Foo() {…}`, `export $count = 0`).",line:r.line,column:r.column};let a;if(r.type==="Keyword"&&r.value==="function")a=Tt(t);else if(r.type==="Keyword"&&r.value==="async"&&t.peek(1).type==="Keyword"&&t.peek(1).value==="function")t.consume(),a=Tt(t);else if(r.type==="Keyword"&&(r.value==="let"||r.value==="const"||r.value==="var")){if(a=ar(t),a&&a.kind==="DestructureStatement")throw{message:"`export` of a destructuring declaration is not supported — export named bindings individually.",line:r.line,column:r.column}}else if(ba(t))a=wa(t);else throw{message:"`export` must be followed by a declaration or assignment (`export function …`, `export let x = …`, `export $state = …`).",line:r.line,column:r.column};if(a&&(a.kind==="Assignment"||a.kind==="ComponentDeclaration"||a.kind==="ActionDeclaration"||a.kind==="HookDeclaration"))return a.exported=!0,a;throw{message:"`export` must be followed by a declaration or assignment.",line:e.line,column:e.column}}function F(t){return Co(t)}function $o(t){let e=0;for(;;){const r=t.peek(e);if(r.type==="Newline"){e+=1;continue}return{token:r,skipped:e}}}function de(t,e){const{token:r,skipped:a}=$o(t);if(!e(r))return!1;for(let n=0;n<a;n+=1)t.consume();return!0}function Co(t){const e=Ao(t);if(de(t,r=>r.type==="Punctuation"&&r.value==="?")){t.consume(),z(t);const r=F(t);z(t),t.expect("Punctuation",":"),z(t);const a=F(t);return{kind:"Ternary",test:e,consequent:r,alternate:a}}return e}function Ao(t){let e=ka(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="||"||r.value==="??"));){const r=t.consume().value;z(t);const a=ka(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ka(t){let e=Sa(t);for(;de(t,r=>r.type==="Operator"&&r.value==="&&");){t.consume(),z(t);const r=Sa(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function Sa(t){let e=$a(t);for(;de(t,r=>r.type==="Operator"&&r.value==="|");){t.consume(),z(t);const r=$a(t);e={kind:"Binary",operator:"|",left:e,right:r}}return e}function $a(t){let e=Ca(t);for(;de(t,r=>r.type==="Operator"&&r.value==="^");){t.consume(),z(t);const r=Ca(t);e={kind:"Binary",operator:"^",left:e,right:r}}return e}function Ca(t){let e=Aa(t);for(;de(t,r=>r.type==="Operator"&&r.value==="&");){t.consume(),z(t);const r=Aa(t);e={kind:"Binary",operator:"&",left:e,right:r}}return e}function Aa(t){let e=Ta(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="=="||r.value==="!="||r.value==="==="||r.value==="!=="));){const r=t.consume().value;z(t);const a=Ta(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Ta(t){let e=ir(t);for(;;){if(de(t,r=>r.type==="Operator"&&(r.value===">"||r.value==="<"||r.value===">="||r.value==="<="))){const r=t.consume().value;z(t);const a=ir(t);e={kind:"Binary",operator:r,left:e,right:a};continue}if(de(t,r=>r.type==="Keyword"&&(r.value==="instanceof"||r.value==="in"))){const r=t.consume().value;z(t);const a=ir(t);e={kind:"Binary",operator:r,left:e,right:a};continue}break}return e}function ir(t){let e=Ma(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="<<"||r.value===">>"||r.value===">>>"));){const r=t.consume().value;z(t);const a=Ma(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Ma(t){let e=Na(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="+"||r.value==="-"));){const r=t.consume().value;z(t);const a=Na(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Na(t){let e=or(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="*"||r.value==="/"||r.value==="%"));){const r=t.consume().value;z(t);const a=or(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function or(t){const e=ot(t);if(de(t,r=>r.type==="Operator"&&r.value==="**")){t.consume(),z(t);const r=or(t);return{kind:"Binary",operator:"**",left:e,right:r}}return e}function ot(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-"||e.value==="+"||e.value==="~")){t.consume();const r=ot(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="await")return t.consume(),{kind:"BuiltinCall",name:"__rui_await__",arguments:[ot(t)],loc:{line:e.line,column:e.column}};if(e.type==="Operator"&&(e.value==="++"||e.value==="--"))return t.consume(),{kind:"BuiltinCall",name:"__rui_prefix__",arguments:[ot(t),{kind:"Literal",value:e.value}],loc:{line:e.line,column:e.column}};if(e.type==="Keyword"&&(e.value==="typeof"||e.value==="void"||e.value==="delete")){t.consume();const r=ot(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="new"){t.consume();let r=Ia(t),a=[];if(r.kind==="Call")a=r.arguments,r={kind:"Identifier",name:r.callee,loc:r.loc};else{for(;;){const i=t.peek();if(i.type==="Punctuation"&&i.value==="."){t.consume();const o=t.consume();if(o.type!=="Identifier"&&o.type!=="Keyword")throw{message:`Expected Identifier but got ${o.type} "${o.value}"`,line:o.line,column:o.column};r={kind:"Member",object:r,property:o.value};continue}if(i.type==="Punctuation"&&i.value==="["){t.consume();const o=F(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:o};continue}break}t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),a=Me(t),t.expect("Punctuation",")"))}const n={kind:"New",callee:r,arguments:a,loc:{line:e.line,column:e.column}};return Pa(t,n)}return To(t)}function To(t){const e=Mo(t),r=t.peek();return r.type==="Operator"&&(r.value==="++"||r.value==="--")?(t.consume(),{kind:"BuiltinCall",name:"__rui_postfix__",arguments:[e,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}):e}function Mo(t){return Pa(t,Ia(t))}function Pa(t,e){let r=e;for(;;){de(t,n=>n.type==="Punctuation"&&n.value==="."||n.type==="Operator"&&n.value==="?.");const a=t.peek();if(a.type==="Punctuation"&&a.value==="."){t.consume();const n=t.consume();if(n.type!=="Identifier"&&n.type!=="Keyword")throw{message:`Expected Identifier but got ${n.type} "${n.value}"`,line:n.line,column:n.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Me(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:n.value,arguments:o,loc:{line:n.line,column:n.column}};continue}r={kind:"Member",object:r,property:n.value};continue}if(a.type==="Operator"&&a.value==="?."){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="["){t.consume();const n=F(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n,optional:!0}}else if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const n=Me(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,optional:!0,loc:{line:a.line,column:a.column}}}else{const n=t.consume();if(n.type!=="Identifier"&&n.type!=="Keyword")throw{message:`Expected Identifier but got ${n.type} "${n.value}"`,line:n.line,column:n.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Me(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:n.value,arguments:o,optional:!0,loc:{line:n.line,column:n.column}};continue}r={kind:"Member",object:r,property:n.value,optional:!0}}continue}if(a.type==="Punctuation"&&a.value==="["){t.consume();const n=F(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n};continue}if(a.type==="Punctuation"&&a.value==="("){t.consume();const n=Me(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,loc:{line:a.line,column:a.column}};continue}break}return r}function Ia(t){const e=t.peek();if(e.type==="Keyword"&&(e.value==="if"||e.value==="for"||e.value==="switch"||e.value==="while"||e.value==="try")){const r=e.value==="if"?"Use the ternary operator (`cond ? a : b`) when you need a value.":e.value==="for"?"Use `arr.map(x => …)` (or `.filter`, `.reduce`, …) to collect bodies into an array.":e.value==="switch"?"Use chained ternaries, an object lookup, or wrap the switch inside a `function`.":`Use the ${e.value} statement inside a function / effect body.`,a={message:`\`${e.value}\` is a statement, not an expression. ${r}`,line:e.line,column:e.column};throw a.__definitive=!0,a}if(e.type==="Keyword"){if(e.value==="function"){const r=t.peek(1),a=t.peek(2);if(r.type==="Punctuation"&&r.value==="("||r.type==="Identifier"&&a.type==="Punctuation"&&a.value==="("){const i=e;t.consume(),t.peek().type==="Identifier"&&t.consume();const o=xa(t),s=Fe(t);return{kind:"Lambda",params:o,body:s,loc:{line:i.line,column:i.column}}}}if(e.value==="function"||e.value==="let"||e.value==="const"||e.value==="var"||e.value==="of"||e.value==="in"||e.value==="case"||e.value==="break"||e.value==="continue"||e.value==="default"){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Me(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}return{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}}if(e.type==="Number")return t.consume(),{kind:"Literal",value:Fo(e.value)};if(e.type==="String")return t.consume(),{kind:"Literal",value:e.value};if(e.type==="TemplateString"){t.consume();const r=e.parts??[],a=[],n=[];let i="",o=!1;const s=()=>{a.push(i),i="",o=!1};for(const c of r){if(c.kind==="str"){i+=c.text,o=!0;continue}o?s():a.push("");const p=ge(`__rui_tmpl__ = ${c.source}`).statements[0];p&&p.kind==="Assignment"?n.push(p.expression):n.push({kind:"Literal",value:""})}for((o||a.length===0)&&a.push(i);a.length<=n.length;)a.push("");return{kind:"Template",quasis:a,expressions:n,loc:{line:e.line,column:e.column}}}if(e.type==="Boolean")return t.consume(),{kind:"Literal",value:e.value==="true"};if(e.type==="Null")return t.consume(),{kind:"Literal",value:null};if(e.type==="StateIdentifier")return e.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="("?(t.consume(),No(t,e)):(t.consume(),{kind:"StateRef",name:e.value});if(e.type==="Identifier"){if(t.consume(),t.peek().type==="Operator"&&t.peek().value==="=>"){t.consume();const r=za(t);return{kind:"Lambda",params:[{name:e.value}],body:r,loc:{line:e.line,column:e.column}}}if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Me(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}return{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}if(e.type==="Punctuation"&&e.value==="["){t.consume();const r=Me(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=_o(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),a=Oo(t);if(a)return a;t.restore(r),t.consume();const n=F(t);return t.expect("Punctuation",")"),n}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function No(t,e){t.consume();const r=Me(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}function Me(t){const e=[];if(z(t),t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return e;for(e.push(Ea(t)),z(t);t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),z(t),!(t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]")));)e.push(Ea(t)),z(t);return z(t),e}function Ea(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:F(t),loc:{line:e.line,column:e.column}}}return F(t)}function La(t){const e=t.expect("Keyword","if");t.expect("Punctuation","(");const r=F(t);t.expect("Punctuation",")");const a=Ze(t);let n;return z(t),t.peek().type==="Keyword"&&t.peek().value==="else"&&(t.consume(),z(t),t.peek().type==="Keyword"&&t.peek().value==="if"?n=La(t):n=Ze(t)),ae(t),{kind:"IfStatement",test:r,consequent:a,alternate:n,loc:{line:e.line,column:e.column}}}function Po(t){const e=t.expect("Keyword","switch");t.expect("Punctuation","(");const r=F(t);t.expect("Punctuation",")"),t.expect("Punctuation","{");const a=[];for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let n=null;if(t.peek().type==="Keyword"&&t.peek().value==="case")t.consume(),n=F(t);else if(t.peek().type==="Keyword"&&t.peek().value==="default")t.consume(),n=null;else throw{message:`Expected "case" or "default" in switch body, got ${t.peek().type} "${t.peek().value}"`,line:t.peek().line,column:t.peek().column};t.expect("Punctuation",":"),z(t);const i=[];for(;!t.isEnd()&&!(t.peek().type==="Keyword"&&(t.peek().value==="case"||t.peek().value==="default"))&&!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const o=At(t);o&&i.push(o),z(t)}a.push({test:n,body:i}),z(t)}return t.expect("Punctuation","}"),ae(t),{kind:"SwitchStatement",discriminant:r,cases:a,loc:{line:e.line,column:e.column}}}function Io(t){const e=t.expect("Keyword","for");t.expect("Punctuation","("),z(t);const r=t.snapshot();let a="for-of";{let u=1,p=0;for(;;){const d=t.peek(p);if(d.type==="EOF")break;if(d.type==="Punctuation"&&d.value==="(")u+=1;else if(d.type==="Punctuation"&&d.value===")"){if(u-=1,u===0)break}else if(u===1&&d.type==="Semicolon"){a="classic";break}else if(u===1&&d.type==="Keyword"&&d.value==="of"){a="for-of";break}else if(u===1&&d.type==="Keyword"&&d.value==="in"){a="for-in";break}p+=1}}if(t.restore(r),a==="classic")return Eo(t,e);t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")&&t.consume(),z(t);let n,i,o;if(t.peek().type==="Punctuation"&&t.peek().value==="[")t.consume(),n=t.expect("Identifier").value,t.expect("Punctuation",","),i=t.expect("Identifier").value,t.expect("Punctuation","]");else if(t.peek().type==="Punctuation"&&t.peek().value==="{"){t.consume();const u=[];for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");)u.push(t.expect("Identifier").value),t.peek().type==="Punctuation"&&t.peek().value===","&&t.consume();t.expect("Punctuation","}"),n="__row",o=u}else n=t.expect("Identifier").value;a==="for-in"?t.expect("Keyword","in"):t.expect("Keyword","of");const s=F(t);t.expect("Punctuation",")");const c=Ze(t);return ae(t),a==="for-in"?{kind:"ForInStatement",item:n,iterable:s,body:c,loc:{line:e.line,column:e.column}}:{kind:"ForOfStatement",item:n,index:i,destructure:o,iterable:s,body:c,loc:{line:e.line,column:e.column}}}function Eo(t,e){let r;if(t.peek().type!=="Semicolon")if(t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")){const o=ar(t);o.kind==="Assignment"&&(r=o),z(t)}else{const o=t.peek();r={kind:"ExpressionStatement",expression:F(t),loc:{line:o.line,column:o.column}},t.expect("Semicolon"),z(t)}else t.expect("Semicolon"),z(t);let a;t.peek().type!=="Semicolon"&&(a=F(t)),t.expect("Semicolon"),z(t);let n;t.peek().type==="Punctuation"&&t.peek().value===")"||(n=Ra(t)),t.expect("Punctuation",")");const i=Ze(t);return ae(t),{kind:"ForClassicStatement",init:r,test:a,update:n,body:i,loc:{line:e.line,column:e.column}}}function Lo(t){const e=t.expect("Keyword","while");t.expect("Punctuation","(");const r=F(t);t.expect("Punctuation",")");const a=Ze(t);return ae(t),{kind:"WhileStatement",test:r,body:a,loc:{line:e.line,column:e.column}}}function zo(t){const e=t.expect("Keyword","do"),r=Ze(t);z(t),t.expect("Keyword","while"),t.expect("Punctuation","(");const a=F(t);return t.expect("Punctuation",")"),ae(t),{kind:"DoWhileStatement",test:a,body:r,loc:{line:e.line,column:e.column}}}function Ro(t){const e=t.expect("Keyword","break");return ae(t),{kind:"BreakStatement",loc:{line:e.line,column:e.column}}}function Do(t){const e=t.expect("Keyword","continue");return ae(t),{kind:"ContinueStatement",loc:{line:e.line,column:e.column}}}function jo(t){const e=t.expect("Keyword","throw"),r=F(t);return ae(t),{kind:"ThrowStatement",argument:r,loc:{line:e.line,column:e.column}}}function Bo(t){const e=t.expect("Keyword","try"),r=Fe(t);let a,n,i;return z(t),t.peek().type==="Keyword"&&t.peek().value==="catch"&&(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),t.peek().type==="Identifier"&&(a=t.consume().value),t.expect("Punctuation",")")),n=Fe(t),z(t)),t.peek().type==="Keyword"&&t.peek().value==="finally"&&(t.consume(),i=Fe(t)),ae(t),{kind:"TryStatement",block:r,catchParam:a,catchBlock:n,finallyBlock:i,loc:{line:e.line,column:e.column}}}function Oo(t){const e=t.peek();if(e.type!=="Punctuation"||e.value!=="(")return null;t.consume();const r=[];if(z(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){z(t);let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.peek();if(!n&&i.type==="Punctuation"&&(i.value==="{"||i.value==="[")){let s;try{s=nr(t)}catch{return null}const c={name:"",pattern:s};if(t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{c.defaultValue=F(t)}catch{return null}}if(r.push(c),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}if(i.type!=="Identifier")return null;t.consume();const o={name:i.value};if(n&&(o.rest=!0),!n&&t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{o.defaultValue=F(t)}catch{return null}}if(r.push(o),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(n)return null;t.consume();continue}break}if(z(t),!(t.peek().type==="Punctuation"&&t.peek().value===")")||(t.consume(),!(t.peek().type==="Operator"&&t.peek().value==="=>")))return null;t.consume();const a=za(t);return{kind:"Lambda",params:r,body:a,loc:{line:e.line,column:e.column}}}function za(t){return z(t),t.peek().type==="Punctuation"&&t.peek().value==="{"?Fe(t):Ra(t)}function Ra(t){const e=F(t),r=t.peek();if(r.type==="Operator"){if(va(r.value)){t.consume();const a=F(t);return{kind:"BuiltinCall",name:"__rui_assign__",arguments:[e,a,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}}if(r.value==="++"||r.value==="--")return t.consume(),{kind:"BuiltinCall",name:"__rui_postfix__",arguments:[e,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}}return e}function _o(t){const e=[];if(z(t),t.peek().type==="Punctuation"&&t.peek().value==="}")return e;for(;;){z(t);const r=t.peek();if(r.type==="Operator"&&r.value==="..."){t.consume();const c=F(t);if(e.push({key:"",value:c,spread:!0}),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),z(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}let a,n;if(r.type==="Punctuation"&&r.value==="[")t.consume(),z(t),n=F(t),z(t),t.expect("Punctuation","]"),a="";else if(r.type==="Number")a=t.consume().value;else if(r.type==="Identifier"||r.type==="String"||r.type==="Keyword")a=t.consume().value;else throw{message:`Expected object key, got ${r.type} "${r.value}"`,line:r.line,column:r.column};const i=t.peek();let o;!n&&r.type==="Identifier"&&i.type==="Punctuation"&&(i.value===","||i.value==="}")?o={kind:"Identifier",name:a,loc:{line:r.line,column:r.column}}:(t.expect("Punctuation",":"),o=F(t));const s={key:a,value:o};if(n&&(s.computedKey=n),e.push(s),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),z(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}return z(t),e}function z(t){for(;t.match("Newline")||t.match("Semicolon"););}function ae(t){t.isEnd()||t.match("Newline")||t.match("Semicolon")}function Fo(t){let e=t.replace(/_/g,""),r=1;return e.startsWith("-")?(r=-1,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1)),r*Number(e)}function Uo(t){const e=ge(t);return Da(t,e)}function Da(t,e){const r=new Set(e.errors.map(s=>s.line)),a=[],n=[];for(const s of e.statements){const c=s.loc?.line??0;if(r.has(c)){n.push(s);continue}a.push(s)}let i=t,o="";if(e.errors.length>0){const s=Math.min(...e.errors.map(p=>p.line)),c=Vo(t,s);i=c.before,o=c.after;const u=a.findIndex(p=>(p.loc?.line??0)>=s);if(u>=0)for(const p of a.splice(u))n.push(p)}return{committedSource:i,draftingSource:o,committedBindings:a.map(ja).filter(s=>s!==null),uncommittedBindings:n.map(ja).filter(s=>s!==null),committedStatements:a,errors:e.errors}}function Ho(t,e){if(e.length===0)return!0;const r=new Set(t.committedBindings);for(const a of e)if(!r.has(a))return!1;return!0}function ja(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function Vo(t,e){if(e<=1)return{before:"",after:t};let r=0,a=1;for(;r<t.length&&a<e;)t[r]===`
|
|
10
|
-
`&&(a+=1),r+=1;return{before:t.slice(0,r),after:t.slice(r)}}const
|
|
9
|
+
`)break;S+=s()}i()===N&&(S+=s());continue}if(C==="{"){T+=1,S+=s();continue}if(C==="}"){if(T-=1,T===0){s();break}S+=s();continue}S+=s()}v.push({kind:"expr",source:S,line:w,column:k}),x=!0;continue}y+=s()}if(i()==="`"&&s(),v.push({kind:"str",text:y}),!x){o("String",y,b,h);continue}e.push({type:"TemplateString",value:"",line:b,column:h,parts:v});continue}const u=e[e.length-1],p=!u||u.type==="Newline"||u.type==="Semicolon"||u.type==="Operator"||u.type==="Punctuation"&&(u.value==="("||u.value==="["||u.value===","||u.value===":"||u.value==="?"||u.value==="{");if(Ie(c)||c==="-"&&Ie(i(1)??"")&&p||c==="."&&Ie(i(1)??"")&&p){const b=a,h=n;let v="";c==="-"&&(v+=s());const y=i(1);if(i()==="0"&&(y==="x"||y==="X"||y==="b"||y==="B"||y==="o"||y==="O")){for(v+=s(),v+=s();r<t.length;){const k=i()??"";if(fa(k)){v+=s();continue}if(k==="_"&&fa(i(1)??"")){v+=s();continue}break}o("Number",v,b,h);continue}let x=!1,w=!1;for(;r<t.length;){const k=i()??"";if(Ie(k)){v+=s();continue}if(k==="_"&&Ie(i(1)??"")){v+=s();continue}if(k==="."&&!x&&!w&&Ie(i(1)??"")){x=!0,v+=s();continue}if((k==="e"||k==="E")&&!w){const T=i(1)??"",S=T==="+"||T==="-"?i(2)??"":T;if(Ie(S)){w=!0,v+=s(),(i()==="+"||i()==="-")&&(v+=s());continue}}break}o("Number",v,b,h);continue}if(c==="$"){const b=a,h=n;s();let v="";for(;r<t.length&&ha(i()??"");)v+=s();o("StateIdentifier",v,b,h);continue}if(ga(c)){const b=a,h=n;let v="";for(;r<t.length&&ha(i()??"");)v+=s();const y=bo[v];y==="Boolean"?o("Boolean",v,b,h):y==="Null"?o("Null",v,b,h):fe.has(v)?o("Keyword",v,b,h):o("Identifier",v,b,h);continue}if(c==="."&&i(1)==="."&&i(2)==="."){const b=a,h=n;s(),s(),s(),o("Operator","...",b,h);continue}const d=c+(i(1)??""),m=d+(i(2)??""),g=m+(i(3)??"");if(g===">>>="){const b=a,h=n;s(),s(),s(),s(),o("Operator",g,b,h);continue}if(m==="==="||m==="!=="||m==="**="||m==="??="||m==="&&="||m==="||="||m===">>>"||m===">>="||m==="<<="){const b=a,h=n;s(),s(),s(),o("Operator",m,b,h);continue}if(d==="=="||d==="!="||d===">="||d==="<="||d==="&&"||d==="||"||d==="??"||d==="?."||d==="->"||d==="=>"||d==="**"||d==="%="||d==="+="||d==="-="||d==="*="||d==="/="||d==="++"||d==="--"||d==="<<"||d===">>"||d==="&="||d==="|="||d==="^="){const b=a,h=n;s(),s(),o("Operator",d,b,h);continue}if("+-*/%!=<>&|^~".includes(c)){const b=a,h=n;s(),o("Operator",c,b,h);continue}if(Je.has(c)){const b=a,h=n;s(),o("Punctuation",c,b,h);continue}s()}return e.push({type:"EOF",value:"",line:a,column:n}),e}function Ie(t){return t>="0"&&t<="9"}function fa(t){return t>="0"&&t<="9"||t>="a"&&t<="f"||t>="A"&&t<="F"}function ga(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function ha(t){return ga(t)||Ie(t)}function ge(t){const e=ma(t),r=new $o(e),a=[],n=[];for(;!r.isEnd();)if(!(r.match("Newline")||r.match("Semicolon")))try{const i=Tt(r,!0);i&&a.push(i)}catch(i){const o=i;n.push(o),r.recoverToNextLine()}return{statements:a,errors:n}}function Tt(t,e){const r=t.peek();if(r.type==="StateIdentifier"&&r.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="(")return yo(t);if(r.type==="Keyword")switch(r.value){case"function":return Mt(t);case"import":return Co(t);case"export":return Ao(t);case"await":return ko(t);case"async":{if(t.peek(1).type==="Keyword"&&t.peek(1).value==="function")return t.consume(),Mt(t);break}case"return":return So(t);case"let":case"const":case"var":return nr(t);case"if":return La(t);case"switch":return Lo(t);case"for":return Ro(t);case"while":return Do(t);case"do":return jo(t);case"break":return Bo(t);case"continue":return Oo(t);case"throw":return _o(t);case"try":return Fo(t)}const a=t.snapshot();if(ba(t))try{return wa(t)}catch(n){if(n&&typeof n=="object"&&n.__definitive)throw n;t.restore(a)}return vo(t)}function ba(t){const e=t.peek();if(e.type!=="Identifier"&&e.type!=="StateIdentifier")return!1;const r=t.peek(1);return r.type==="Operator"&&r.value==="="}function vo(t){const e=t.peek();let r=F(t);const a=t.peek();if(a.type==="Operator"&&va(a.value)){if(ya(r)){t.consume();const n=F(t);r={kind:"BuiltinCall",name:"__rui_assign__",arguments:[r,n,{kind:"Literal",value:a.value}],loc:{line:a.line,column:a.column}}}}else a.type==="Operator"&&(a.value==="++"||a.value==="--")&&ya(r)&&(t.consume(),r={kind:"BuiltinCall",name:"__rui_postfix__",arguments:[r,{kind:"Literal",value:a.value}],loc:{line:a.line,column:a.column}});return ae(t),{kind:"ExpressionStatement",expression:r,loc:{line:e.line,column:e.column}}}function va(t){return t==="="||t==="+="||t==="-="||t==="*="||t==="/="||t==="%="||t==="**="||t==="??="||t==="&&="||t==="||="||t==="&="||t==="|="||t==="^="||t==="<<="||t===">>="||t===">>>="}function ya(t){return t.kind==="Member"||t.kind==="StateRef"||t.kind==="Identifier"}function Mt(t){const e=t.expect("Keyword","function"),r=t.peek().type==="StateIdentifier",a=r?t.consume():t.expect("Identifier"),n=xa(t),i=Fe(t);return ae(t),r?{kind:"HookDeclaration",name:a.value,params:n,body:i,loc:{line:e.line,column:e.column}}:a.value.length>0&&a.value[0]>="A"&&a.value[0]<="Z"?{kind:"ComponentDeclaration",name:a.value,params:n,slots:[],body:i,loc:{line:e.line,column:e.column}}:{kind:"ActionDeclaration",name:a.value,params:n,body:i,loc:{line:e.line,column:e.column}}}function xa(t){t.expect("Punctuation","(");const e=[];if(R(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){R(t);let r=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),r=!0);const a=t.peek();if(!r&&a.type==="Punctuation"&&(a.value==="{"||a.value==="[")){const n=ir(t);let i;t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=F(t));const o={name:"",pattern:n};i&&(o.defaultValue=i),e.push(o)}else if(a.type==="Identifier"||a.type==="Keyword"){const n=t.consume();let i;!r&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=F(t));const o={name:n.value};i&&(o.defaultValue=i),r&&(o.rest=!0),e.push(o)}else throw{message:`Expected parameter name, got ${a.type} "${a.value}"`,line:a.line,column:a.column};if(R(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(r)throw{message:"Rest parameter `...name` must be the final parameter.",line:t.peek().line,column:t.peek().column};if(t.consume(),R(t),t.peek().type==="Punctuation"&&t.peek().value===")")break;continue}break}return t.expect("Punctuation",")"),e}function yo(t){const e=t.consume();t.expect("Punctuation","("),R(t);const r=F(t);let a;r.kind==="Lambda"?a=r.body.kind==="Block"?r.body:{kind:"Block",body:[{kind:"ExpressionStatement",expression:r.body}]}:a={kind:"Block",body:[]};const n=[];let i;if(R(t),t.peek().type==="Punctuation"&&t.peek().value===",")if(t.consume(),R(t),t.peek().type==="Punctuation"&&t.peek().value==="["){for(t.consume(),R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");)xo(t,n,s=>{i=s}),R(t),t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),R(t));t.expect("Punctuation","]")}else F(t);R(t),t.expect("Punctuation",")"),ae(t);const o={kind:"EffectDeclaration",name:`__effect_L${e.line}_C${e.column}`,triggers:n,body:a,loc:{line:e.line,column:e.column}};return i&&(o.rateLimit=i),o}function xo(t,e,r){const a=t.peek();if(a.type==="StateIdentifier"){t.consume();let n=a.value;for(;t.peek().type==="Punctuation"&&t.peek().value===".";){const i=t.peek(1);if(i.type!=="Identifier"&&i.type!=="Keyword")break;t.consume(),t.consume(),n+="."+i.value}e.push({kind:"state",name:n});return}if(a.type==="String"){t.consume();const n=a.value;if(n==="mount"||n==="unmount"){e.push({kind:"lifecycle",name:n});return}const i=n.match(/^every\((\d+)\)$/);if(i){e.push({kind:"every",intervalMs:Number(i[1])});return}const o=n.match(/^debounce\((\d+)\)$/);if(o){r({kind:"debounce",ms:Number(o[1])});return}const s=n.match(/^throttle\((\d+)\)$/);if(s){r({kind:"throttle",ms:Number(s[1])});return}throw{message:`Unknown effect dependency string "${n}". Expected "mount", "unmount", "every(N)", "debounce(N)", or "throttle(N)".`,line:a.line,column:a.column}}throw{message:`Unexpected ${a.type} "${a.value}" inside effect dependency array. Expected $state or a string token ("mount", "unmount", "every(N)", etc.).`,line:a.line,column:a.column}}function nr(t){const e=t.consume(),r=t.peek();if(r.type==="Punctuation"&&(r.value==="["||r.value==="{"))return wo(t,e);let a="",n=!1;if(r.type==="StateIdentifier")a=t.consume().value,n=!0;else if(r.type==="Identifier")a=t.consume().value;else throw{message:`Expected identifier after "${e.value}", got ${r.type} "${r.value}"`,line:r.line,column:r.column};t.expect("Operator","=");const i=F(t);return ae(t),{kind:"Assignment",identifier:a,isState:n,expression:i,loc:{line:e.line,column:e.column}}}function wo(t,e){const r=ir(t);t.expect("Operator","=");const a=F(t);return ae(t),{kind:"DestructureStatement",patternKind:r.kind,bindings:r.bindings,expression:a,loc:{line:e.line,column:e.column}}}function ir(t){const r=t.consume().value==="["?"array":"object",a=[];if(r==="array"){for(R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");){if(t.peek().type==="Punctuation"&&t.peek().value===","){a.push({name:""}),t.consume(),R(t);continue}let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.expect("Identifier");let o;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),o=F(t));const s={name:i.value};if(n&&(s.rest=!0),o&&(s.defaultValue=o),a.push(s),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),R(t);continue}break}t.expect("Punctuation","]")}else{for(R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.expect("Identifier");let o=i.value,s;if(!n&&t.peek().type==="Punctuation"&&t.peek().value===":"){t.consume();const p=t.expect("Identifier");s=i.value,o=p.value}let c;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),c=F(t));const u={name:o};if(s&&(u.sourceKey=s),n&&(u.rest=!0),c&&(u.defaultValue=c),a.push(u),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),R(t);continue}break}t.expect("Punctuation","}")}return{kind:r,bindings:a}}function Fe(t){const e=t.expect("Punctuation","{"),r=[];for(R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const a=Tt(t);a&&r.push(a),R(t)}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function Ze(t){if(R(t),t.peek().type==="Punctuation"&&t.peek().value==="{")return Fe(t);const e=t.peek(),r=Tt(t);return{kind:"Block",body:r?[r]:[],loc:{line:e.line,column:e.column}}}function ko(t){const e=t.expect("Keyword","await"),r=F(t);return ae(t),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function So(t){const e=t.expect("Keyword","return");let r;const a=t.peek();return a.type!=="Newline"&&a.type!=="Semicolon"&&!(a.type==="Punctuation"&&a.value==="}")&&(r=F(t)),ae(t),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class $o{constructor(e){z(this,"index",0);this.tokens=e}isEnd(){return this.peek().type==="EOF"}peek(e=0){return this.tokens[this.index+e]??{type:"EOF",value:"",line:0,column:0}}consume(){const e=this.tokens[this.index]??{type:"EOF",value:"",line:0,column:0};return this.index+=1,e}match(e,r){const a=this.peek();return a.type!==e||r!==void 0&&a.value!==r?!1:(this.consume(),!0)}expect(e,r){const a=this.peek();if(a.type!==e||r!==void 0&&a.value!==r)throw{message:`Expected ${e}${r!==void 0?` "${r}"`:""} but got ${a.type} "${a.value}"`,line:a.line,column:a.column};return this.consume()}recoverToNextLine(){for(;!this.isEnd()&&this.peek().type!=="Newline"&&this.peek().type!=="Semicolon";)this.consume();(this.peek().type==="Newline"||this.peek().type==="Semicolon")&&this.consume()}snapshot(){return this.index}restore(e){this.index=e}}function wa(t){const e=t.peek();let r="",a=!1;if(e.type==="Identifier")r=t.consume().value;else if(e.type==="StateIdentifier")r=t.consume().value,a=!0;else throw{message:`Expected identifier at start of statement, got ${e.type} "${e.value}"`,line:e.line,column:e.column};const n=t.expect("Operator","="),i=F(t);return ae(t),{kind:"Assignment",identifier:r,isState:a,expression:i,loc:{line:n.line,column:n.column}}}function Co(t){const e=t.expect("Keyword","import");t.expect("Punctuation","{");const r=[];for(;!t.isEnd()&&!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const i=t.peek();let o,s=!1;if(i.type==="StateIdentifier")o=t.consume().value,s=!0;else if(i.type==="Identifier")o=t.consume().value;else throw{message:`Expected an import name, got ${i.type} "${i.value}"`,line:i.line,column:i.column};let c=o;if(t.peek().type==="Identifier"&&t.peek().value==="as"){t.consume();const u=t.peek();let p=!1;if(u.type==="StateIdentifier")c=t.consume().value,p=!0;else if(u.type==="Identifier")c=t.consume().value;else throw{message:`Expected an alias after \`as\`, got ${u.type} "${u.value}"`,line:u.line,column:u.column};if(p!==s)throw{message:"A `$state` import must keep its `$` across `as` (e.g. `{ $x as $y }`); a non-state import must not gain one.",line:u.line,column:u.column}}if(r.push(s?{imported:o,local:c,isState:!0}:{imported:o,local:c}),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}t.expect("Punctuation","}");const a=t.peek();if(!(a.type==="Identifier"&&a.value==="from"))throw{message:`Expected \`from\` after import specifiers, got ${a.type} "${a.value}"`,line:a.line,column:a.column};t.consume();const n=t.expect("String");return ae(t),{kind:"Import",specifiers:r,source:n.value,loc:{line:e.line,column:e.column}}}function Ao(t){const e=t.expect("Keyword","export"),r=t.peek();if(r.type==="Punctuation"&&r.value==="{")throw{message:"`export { … }` lists are not supported yet — use inline `export <declaration>` (e.g. `export function Foo() {…}`, `export $count = 0`).",line:r.line,column:r.column};let a;if(r.type==="Keyword"&&r.value==="function")a=Mt(t);else if(r.type==="Keyword"&&r.value==="async"&&t.peek(1).type==="Keyword"&&t.peek(1).value==="function")t.consume(),a=Mt(t);else if(r.type==="Keyword"&&(r.value==="let"||r.value==="const"||r.value==="var")){if(a=nr(t),a&&a.kind==="DestructureStatement")throw{message:"`export` of a destructuring declaration is not supported — export named bindings individually.",line:r.line,column:r.column}}else if(ba(t))a=wa(t);else throw{message:"`export` must be followed by a declaration or assignment (`export function …`, `export let x = …`, `export $state = …`).",line:r.line,column:r.column};if(a&&(a.kind==="Assignment"||a.kind==="ComponentDeclaration"||a.kind==="ActionDeclaration"||a.kind==="HookDeclaration"))return a.exported=!0,a;throw{message:"`export` must be followed by a declaration or assignment.",line:e.line,column:e.column}}function F(t){return Mo(t)}function To(t){let e=0;for(;;){const r=t.peek(e);if(r.type==="Newline"){e+=1;continue}return{token:r,skipped:e}}}function de(t,e){const{token:r,skipped:a}=To(t);if(!e(r))return!1;for(let n=0;n<a;n+=1)t.consume();return!0}function Mo(t){const e=No(t);if(de(t,r=>r.type==="Punctuation"&&r.value==="?")){t.consume(),R(t);const r=F(t);R(t),t.expect("Punctuation",":"),R(t);const a=F(t);return{kind:"Ternary",test:e,consequent:r,alternate:a}}return e}function No(t){let e=ka(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="||"||r.value==="??"));){const r=t.consume().value;R(t);const a=ka(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ka(t){let e=Sa(t);for(;de(t,r=>r.type==="Operator"&&r.value==="&&");){t.consume(),R(t);const r=Sa(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function Sa(t){let e=$a(t);for(;de(t,r=>r.type==="Operator"&&r.value==="|");){t.consume(),R(t);const r=$a(t);e={kind:"Binary",operator:"|",left:e,right:r}}return e}function $a(t){let e=Ca(t);for(;de(t,r=>r.type==="Operator"&&r.value==="^");){t.consume(),R(t);const r=Ca(t);e={kind:"Binary",operator:"^",left:e,right:r}}return e}function Ca(t){let e=Aa(t);for(;de(t,r=>r.type==="Operator"&&r.value==="&");){t.consume(),R(t);const r=Aa(t);e={kind:"Binary",operator:"&",left:e,right:r}}return e}function Aa(t){let e=Ta(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="=="||r.value==="!="||r.value==="==="||r.value==="!=="));){const r=t.consume().value;R(t);const a=Ta(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Ta(t){let e=or(t);for(;;){if(de(t,r=>r.type==="Operator"&&(r.value===">"||r.value==="<"||r.value===">="||r.value==="<="))){const r=t.consume().value;R(t);const a=or(t);e={kind:"Binary",operator:r,left:e,right:a};continue}if(de(t,r=>r.type==="Keyword"&&(r.value==="instanceof"||r.value==="in"))){const r=t.consume().value;R(t);const a=or(t);e={kind:"Binary",operator:r,left:e,right:a};continue}break}return e}function or(t){let e=Ma(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="<<"||r.value===">>"||r.value===">>>"));){const r=t.consume().value;R(t);const a=Ma(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Ma(t){let e=Na(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="+"||r.value==="-"));){const r=t.consume().value;R(t);const a=Na(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Na(t){let e=sr(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="*"||r.value==="/"||r.value==="%"));){const r=t.consume().value;R(t);const a=sr(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function sr(t){const e=st(t);if(de(t,r=>r.type==="Operator"&&r.value==="**")){t.consume(),R(t);const r=sr(t);return{kind:"Binary",operator:"**",left:e,right:r}}return e}function st(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-"||e.value==="+"||e.value==="~")){t.consume();const r=st(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="await")return t.consume(),{kind:"BuiltinCall",name:"__rui_await__",arguments:[st(t)],loc:{line:e.line,column:e.column}};if(e.type==="Operator"&&(e.value==="++"||e.value==="--"))return t.consume(),{kind:"BuiltinCall",name:"__rui_prefix__",arguments:[st(t),{kind:"Literal",value:e.value}],loc:{line:e.line,column:e.column}};if(e.type==="Keyword"&&(e.value==="typeof"||e.value==="void"||e.value==="delete")){t.consume();const r=st(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="new"){t.consume();let r=Ia(t),a=[];if(r.kind==="Call")a=r.arguments,r={kind:"Identifier",name:r.callee,loc:r.loc};else{for(;;){const i=t.peek();if(i.type==="Punctuation"&&i.value==="."){t.consume();const o=t.consume();if(o.type!=="Identifier"&&o.type!=="Keyword")throw{message:`Expected Identifier but got ${o.type} "${o.value}"`,line:o.line,column:o.column};r={kind:"Member",object:r,property:o.value};continue}if(i.type==="Punctuation"&&i.value==="["){t.consume();const o=F(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:o};continue}break}t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),a=Me(t),t.expect("Punctuation",")"))}const n={kind:"New",callee:r,arguments:a,loc:{line:e.line,column:e.column}};return Pa(t,n)}return Po(t)}function Po(t){const e=Io(t),r=t.peek();return r.type==="Operator"&&(r.value==="++"||r.value==="--")?(t.consume(),{kind:"BuiltinCall",name:"__rui_postfix__",arguments:[e,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}):e}function Io(t){return Pa(t,Ia(t))}function Pa(t,e){let r=e;for(;;){de(t,n=>n.type==="Punctuation"&&n.value==="."||n.type==="Operator"&&n.value==="?.");const a=t.peek();if(a.type==="Punctuation"&&a.value==="."){t.consume();const n=t.consume();if(n.type!=="Identifier"&&n.type!=="Keyword")throw{message:`Expected Identifier but got ${n.type} "${n.value}"`,line:n.line,column:n.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Me(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:n.value,arguments:o,loc:{line:n.line,column:n.column}};continue}r={kind:"Member",object:r,property:n.value};continue}if(a.type==="Operator"&&a.value==="?."){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="["){t.consume();const n=F(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n,optional:!0}}else if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const n=Me(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,optional:!0,loc:{line:a.line,column:a.column}}}else{const n=t.consume();if(n.type!=="Identifier"&&n.type!=="Keyword")throw{message:`Expected Identifier but got ${n.type} "${n.value}"`,line:n.line,column:n.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Me(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:n.value,arguments:o,optional:!0,loc:{line:n.line,column:n.column}};continue}r={kind:"Member",object:r,property:n.value,optional:!0}}continue}if(a.type==="Punctuation"&&a.value==="["){t.consume();const n=F(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n};continue}if(a.type==="Punctuation"&&a.value==="("){t.consume();const n=Me(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,loc:{line:a.line,column:a.column}};continue}break}return r}function Ia(t){const e=t.peek();if(e.type==="Keyword"&&(e.value==="if"||e.value==="for"||e.value==="switch"||e.value==="while"||e.value==="try")){const r=e.value==="if"?"Use the ternary operator (`cond ? a : b`) when you need a value.":e.value==="for"?"Use `arr.map(x => …)` (or `.filter`, `.reduce`, …) to collect bodies into an array.":e.value==="switch"?"Use chained ternaries, an object lookup, or wrap the switch inside a `function`.":`Use the ${e.value} statement inside a function / effect body.`,a={message:`\`${e.value}\` is a statement, not an expression. ${r}`,line:e.line,column:e.column};throw a.__definitive=!0,a}if(e.type==="Keyword"){if(e.value==="function"){const r=t.peek(1),a=t.peek(2);if(r.type==="Punctuation"&&r.value==="("||r.type==="Identifier"&&a.type==="Punctuation"&&a.value==="("){const i=e;t.consume(),t.peek().type==="Identifier"&&t.consume();const o=xa(t),s=Fe(t);return{kind:"Lambda",params:o,body:s,loc:{line:i.line,column:i.column}}}}if(e.value==="function"||e.value==="let"||e.value==="const"||e.value==="var"||e.value==="of"||e.value==="in"||e.value==="case"||e.value==="break"||e.value==="continue"||e.value==="default"){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Me(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}return{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}}if(e.type==="Number")return t.consume(),{kind:"Literal",value:Vo(e.value)};if(e.type==="String")return t.consume(),{kind:"Literal",value:e.value};if(e.type==="TemplateString"){t.consume();const r=e.parts??[],a=[],n=[];let i="",o=!1;const s=()=>{a.push(i),i="",o=!1};for(const c of r){if(c.kind==="str"){i+=c.text,o=!0;continue}o?s():a.push("");const p=ge(`__rui_tmpl__ = ${c.source}`).statements[0];p&&p.kind==="Assignment"?n.push(p.expression):n.push({kind:"Literal",value:""})}for((o||a.length===0)&&a.push(i);a.length<=n.length;)a.push("");return{kind:"Template",quasis:a,expressions:n,loc:{line:e.line,column:e.column}}}if(e.type==="Boolean")return t.consume(),{kind:"Literal",value:e.value==="true"};if(e.type==="Null")return t.consume(),{kind:"Literal",value:null};if(e.type==="StateIdentifier")return e.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="("?(t.consume(),Eo(t,e)):(t.consume(),{kind:"StateRef",name:e.value});if(e.type==="Identifier"){if(t.consume(),t.peek().type==="Operator"&&t.peek().value==="=>"){t.consume();const r=Ra(t);return{kind:"Lambda",params:[{name:e.value}],body:r,loc:{line:e.line,column:e.column}}}if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Me(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}return{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}if(e.type==="Punctuation"&&e.value==="["){t.consume();const r=Me(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=Ho(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),a=Uo(t);if(a)return a;t.restore(r),t.consume();const n=F(t);return t.expect("Punctuation",")"),n}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function Eo(t,e){t.consume();const r=Me(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}function Me(t){const e=[];if(R(t),t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return e;for(e.push(Ea(t)),R(t);t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),R(t),!(t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]")));)e.push(Ea(t)),R(t);return R(t),e}function Ea(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:F(t),loc:{line:e.line,column:e.column}}}return F(t)}function La(t){const e=t.expect("Keyword","if");t.expect("Punctuation","(");const r=F(t);t.expect("Punctuation",")");const a=Ze(t);let n;return R(t),t.peek().type==="Keyword"&&t.peek().value==="else"&&(t.consume(),R(t),t.peek().type==="Keyword"&&t.peek().value==="if"?n=La(t):n=Ze(t)),ae(t),{kind:"IfStatement",test:r,consequent:a,alternate:n,loc:{line:e.line,column:e.column}}}function Lo(t){const e=t.expect("Keyword","switch");t.expect("Punctuation","(");const r=F(t);t.expect("Punctuation",")"),t.expect("Punctuation","{");const a=[];for(R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let n=null;if(t.peek().type==="Keyword"&&t.peek().value==="case")t.consume(),n=F(t);else if(t.peek().type==="Keyword"&&t.peek().value==="default")t.consume(),n=null;else throw{message:`Expected "case" or "default" in switch body, got ${t.peek().type} "${t.peek().value}"`,line:t.peek().line,column:t.peek().column};t.expect("Punctuation",":"),R(t);const i=[];for(;!t.isEnd()&&!(t.peek().type==="Keyword"&&(t.peek().value==="case"||t.peek().value==="default"))&&!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const o=Tt(t);o&&i.push(o),R(t)}a.push({test:n,body:i}),R(t)}return t.expect("Punctuation","}"),ae(t),{kind:"SwitchStatement",discriminant:r,cases:a,loc:{line:e.line,column:e.column}}}function Ro(t){const e=t.expect("Keyword","for");t.expect("Punctuation","("),R(t);const r=t.snapshot();let a="for-of";{let u=1,p=0;for(;;){const d=t.peek(p);if(d.type==="EOF")break;if(d.type==="Punctuation"&&d.value==="(")u+=1;else if(d.type==="Punctuation"&&d.value===")"){if(u-=1,u===0)break}else if(u===1&&d.type==="Semicolon"){a="classic";break}else if(u===1&&d.type==="Keyword"&&d.value==="of"){a="for-of";break}else if(u===1&&d.type==="Keyword"&&d.value==="in"){a="for-in";break}p+=1}}if(t.restore(r),a==="classic")return zo(t,e);t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")&&t.consume(),R(t);let n,i,o;if(t.peek().type==="Punctuation"&&t.peek().value==="[")t.consume(),n=t.expect("Identifier").value,t.expect("Punctuation",","),i=t.expect("Identifier").value,t.expect("Punctuation","]");else if(t.peek().type==="Punctuation"&&t.peek().value==="{"){t.consume();const u=[];for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");)u.push(t.expect("Identifier").value),t.peek().type==="Punctuation"&&t.peek().value===","&&t.consume();t.expect("Punctuation","}"),n="__row",o=u}else n=t.expect("Identifier").value;a==="for-in"?t.expect("Keyword","in"):t.expect("Keyword","of");const s=F(t);t.expect("Punctuation",")");const c=Ze(t);return ae(t),a==="for-in"?{kind:"ForInStatement",item:n,iterable:s,body:c,loc:{line:e.line,column:e.column}}:{kind:"ForOfStatement",item:n,index:i,destructure:o,iterable:s,body:c,loc:{line:e.line,column:e.column}}}function zo(t,e){let r;if(t.peek().type!=="Semicolon")if(t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")){const o=nr(t);o.kind==="Assignment"&&(r=o),R(t)}else{const o=t.peek();r={kind:"ExpressionStatement",expression:F(t),loc:{line:o.line,column:o.column}},t.expect("Semicolon"),R(t)}else t.expect("Semicolon"),R(t);let a;t.peek().type!=="Semicolon"&&(a=F(t)),t.expect("Semicolon"),R(t);let n;t.peek().type==="Punctuation"&&t.peek().value===")"||(n=za(t)),t.expect("Punctuation",")");const i=Ze(t);return ae(t),{kind:"ForClassicStatement",init:r,test:a,update:n,body:i,loc:{line:e.line,column:e.column}}}function Do(t){const e=t.expect("Keyword","while");t.expect("Punctuation","(");const r=F(t);t.expect("Punctuation",")");const a=Ze(t);return ae(t),{kind:"WhileStatement",test:r,body:a,loc:{line:e.line,column:e.column}}}function jo(t){const e=t.expect("Keyword","do"),r=Ze(t);R(t),t.expect("Keyword","while"),t.expect("Punctuation","(");const a=F(t);return t.expect("Punctuation",")"),ae(t),{kind:"DoWhileStatement",test:a,body:r,loc:{line:e.line,column:e.column}}}function Bo(t){const e=t.expect("Keyword","break");return ae(t),{kind:"BreakStatement",loc:{line:e.line,column:e.column}}}function Oo(t){const e=t.expect("Keyword","continue");return ae(t),{kind:"ContinueStatement",loc:{line:e.line,column:e.column}}}function _o(t){const e=t.expect("Keyword","throw"),r=F(t);return ae(t),{kind:"ThrowStatement",argument:r,loc:{line:e.line,column:e.column}}}function Fo(t){const e=t.expect("Keyword","try"),r=Fe(t);let a,n,i;return R(t),t.peek().type==="Keyword"&&t.peek().value==="catch"&&(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),t.peek().type==="Identifier"&&(a=t.consume().value),t.expect("Punctuation",")")),n=Fe(t),R(t)),t.peek().type==="Keyword"&&t.peek().value==="finally"&&(t.consume(),i=Fe(t)),ae(t),{kind:"TryStatement",block:r,catchParam:a,catchBlock:n,finallyBlock:i,loc:{line:e.line,column:e.column}}}function Uo(t){const e=t.peek();if(e.type!=="Punctuation"||e.value!=="(")return null;t.consume();const r=[];if(R(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){R(t);let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.peek();if(!n&&i.type==="Punctuation"&&(i.value==="{"||i.value==="[")){let s;try{s=ir(t)}catch{return null}const c={name:"",pattern:s};if(t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{c.defaultValue=F(t)}catch{return null}}if(r.push(c),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}if(i.type!=="Identifier")return null;t.consume();const o={name:i.value};if(n&&(o.rest=!0),!n&&t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{o.defaultValue=F(t)}catch{return null}}if(r.push(o),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(n)return null;t.consume();continue}break}if(R(t),!(t.peek().type==="Punctuation"&&t.peek().value===")")||(t.consume(),!(t.peek().type==="Operator"&&t.peek().value==="=>")))return null;t.consume();const a=Ra(t);return{kind:"Lambda",params:r,body:a,loc:{line:e.line,column:e.column}}}function Ra(t){return R(t),t.peek().type==="Punctuation"&&t.peek().value==="{"?Fe(t):za(t)}function za(t){const e=F(t),r=t.peek();if(r.type==="Operator"){if(va(r.value)){t.consume();const a=F(t);return{kind:"BuiltinCall",name:"__rui_assign__",arguments:[e,a,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}}if(r.value==="++"||r.value==="--")return t.consume(),{kind:"BuiltinCall",name:"__rui_postfix__",arguments:[e,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}}return e}function Ho(t){const e=[];if(R(t),t.peek().type==="Punctuation"&&t.peek().value==="}")return e;for(;;){R(t);const r=t.peek();if(r.type==="Operator"&&r.value==="..."){t.consume();const c=F(t);if(e.push({key:"",value:c,spread:!0}),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),R(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}let a,n;if(r.type==="Punctuation"&&r.value==="[")t.consume(),R(t),n=F(t),R(t),t.expect("Punctuation","]"),a="";else if(r.type==="Number")a=t.consume().value;else if(r.type==="Identifier"||r.type==="String"||r.type==="Keyword")a=t.consume().value;else throw{message:`Expected object key, got ${r.type} "${r.value}"`,line:r.line,column:r.column};const i=t.peek();let o;!n&&r.type==="Identifier"&&i.type==="Punctuation"&&(i.value===","||i.value==="}")?o={kind:"Identifier",name:a,loc:{line:r.line,column:r.column}}:(t.expect("Punctuation",":"),o=F(t));const s={key:a,value:o};if(n&&(s.computedKey=n),e.push(s),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),R(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}return R(t),e}function R(t){for(;t.match("Newline")||t.match("Semicolon"););}function ae(t){t.isEnd()||t.match("Newline")||t.match("Semicolon")}function Vo(t){let e=t.replace(/_/g,""),r=1;return e.startsWith("-")?(r=-1,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1)),r*Number(e)}function Wo(t){const e=ge(t);return Da(t,e)}function Da(t,e){const r=new Set(e.errors.map(s=>s.line)),a=[],n=[];for(const s of e.statements){const c=s.loc?.line??0;if(r.has(c)){n.push(s);continue}a.push(s)}let i=t,o="";if(e.errors.length>0){const s=Math.min(...e.errors.map(p=>p.line)),c=Ko(t,s);i=c.before,o=c.after;const u=a.findIndex(p=>(p.loc?.line??0)>=s);if(u>=0)for(const p of a.splice(u))n.push(p)}return{committedSource:i,draftingSource:o,committedBindings:a.map(ja).filter(s=>s!==null),uncommittedBindings:n.map(ja).filter(s=>s!==null),committedStatements:a,errors:e.errors}}function qo(t,e){if(e.length===0)return!0;const r=new Set(t.committedBindings);for(const a of e)if(!r.has(a))return!1;return!0}function ja(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function Ko(t,e){if(e<=1)return{before:"",after:t};let r=0,a=1;for(;r<t.length&&a<e;)t[r]===`
|
|
10
|
+
`&&(a+=1),r+=1;return{before:t.slice(0,r),after:t.slice(r)}}const Nt=1;function Ba(t){if(!t||typeof t!="object")return!1;const e=t;return e.__aktionCompiled===Nt&&typeof e.source=="string"&&typeof e.path=="string"&&!!e.program&&Array.isArray(e.program.statements)}function Go(t){return t}function Yo(t,e={}){const r=ge(t);return{__aktionCompiled:Nt,program:r,source:t,path:e.path??"<inline>"}}const Ce=" ",Oa=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Xo=/[\\"]/;function Jo(t){const e=[];let r=null;for(const a of t.statements)r&&Zo(r,a)&&e.push(""),e.push(Qe(a,0)),r=a;return e.join(`
|
|
11
11
|
`)+`
|
|
12
|
-
`}function
|
|
12
|
+
`}function Zo(t,e){const r=new Set(["ComponentDeclaration","EffectDeclaration","ActionDeclaration","HookDeclaration"]);return!!(r.has(t.kind)||r.has(e.kind))}function Qe(t,e){const r=Ce.repeat(e),a="exported"in t&&t.exported?"export ":"";switch(t.kind){case"Import":{const n=t.specifiers.map(i=>{const o=i.isState?`$${i.imported}`:i.imported;if(i.local===i.imported)return o;const s=i.isState?`$${i.local}`:i.local;return`${o} as ${s}`}).join(", ");return`${r}import { ${n} } from "${t.source}"`}case"Assignment":{const n=t.isState?`$${t.identifier}`:t.identifier,i=H(t.expression,e);return`${r}${a}${n} = ${i}`}case"ComponentDeclaration":{const n=t.params.map(lr).join(", "),i=`${r}${a}function ${t.name}(${n}) {`,o=ue(t.body.body,e+1);return o.length>0?`${i}
|
|
13
13
|
${o}
|
|
14
14
|
${r}}`:`${i}
|
|
15
|
-
${r}}`}case"EffectDeclaration":{const n=t.triggers.map(
|
|
15
|
+
${r}}`}case"EffectDeclaration":{const n=t.triggers.map(Qo).filter(s=>s.length>0);t.rateLimit&&n.push(`"${t.rateLimit.kind}(${t.rateLimit.ms})"`);const i=ue(t.body.body,e+1),o=`[${n.join(", ")}]`;return`${r}$effect(() => {
|
|
16
16
|
${i}
|
|
17
17
|
${r}}, ${o})`}case"ActionDeclaration":{const n=t.params.map(lr).join(", "),i=`${r}${a}function ${t.name}(${n}) {`,o=ue(t.body.body,e+1);return`${i}
|
|
18
18
|
${o}
|
|
@@ -22,7 +22,7 @@ ${r}}`}case"Await":return`${r}await ${H(t.argument,e)}`;case"Return":return t.ar
|
|
|
22
22
|
${ue(t.consequent.body,e+1)}
|
|
23
23
|
${r}}`;if(!t.alternate)return`${r}if (${n}) ${i}`;const o=t.alternate.kind==="IfStatement"?Qe(t.alternate,e).trimStart():`{
|
|
24
24
|
${ue(t.alternate.body,e+1)}
|
|
25
|
-
${r}}`;return`${r}if (${n}) ${i} else ${o}`}case"SwitchStatement":{const n=H(t.discriminant,e),i=t.cases.map(o=>
|
|
25
|
+
${r}}`;return`${r}if (${n}) ${i} else ${o}`}case"SwitchStatement":{const n=H(t.discriminant,e),i=t.cases.map(o=>es(o,e+1)).join(`
|
|
26
26
|
`);return`${r}switch (${n}) {
|
|
27
27
|
${i}
|
|
28
28
|
${r}}`}case"ForOfStatement":{const n=H(t.iterable,e),i=`{
|
|
@@ -41,33 +41,33 @@ ${r}}`;let i=`${r}try ${n}`;if(t.catchBlock){const o=t.catchParam?` (${t.catchPa
|
|
|
41
41
|
${ue(t.catchBlock.body,e+1)}
|
|
42
42
|
${r}}`;i+=` catch${o} ${s}`}if(t.finallyBlock){const o=`{
|
|
43
43
|
${ue(t.finallyBlock.body,e+1)}
|
|
44
|
-
${r}}`;i+=` finally ${o}`}return i}}}function lr(t){return t.defaultValue?`${t.name} = ${H(t.defaultValue,0)}`:t.name}function
|
|
45
|
-
`)}function H(t,e){switch(t.kind){case"Literal":return
|
|
44
|
+
${r}}`;i+=` finally ${o}`}return i}}}function lr(t){return t.defaultValue?`${t.name} = ${H(t.defaultValue,0)}`:t.name}function Qo(t){return t.kind==="lifecycle"?`"${t.name}"`:t.kind==="every"?`"every(${t.intervalMs})"`:t.kind==="state"?`$${t.name}`:""}function ue(t,e){return t.map(r=>Qe(r,e)).join(`
|
|
45
|
+
`)}function H(t,e){switch(t.kind){case"Literal":return rs(t.value);case"Identifier":return t.name;case"StateRef":return`$${t.name}`;case"Array":{if(t.elements.length===0)return"[]";const r=t.elements.map(i=>H(i,e)),a=`[${r.join(", ")}]`;if(a.length<=80&&!r.some(i=>i.includes(`
|
|
46
46
|
`)))return a;const n=Ce.repeat(e+1);return`[
|
|
47
47
|
${r.map(i=>`${n}${i}`).join(`,
|
|
48
48
|
`)}
|
|
49
|
-
${Ce.repeat(e)}]`}case"Object":{if(t.properties.length===0)return"{}";const r=t.properties.map(i=>
|
|
49
|
+
${Ce.repeat(e)}]`}case"Object":{if(t.properties.length===0)return"{}";const r=t.properties.map(i=>ts(i,e)),a=`{ ${r.join(", ")} }`;if(a.length<=80&&!r.some(i=>i.includes(`
|
|
50
50
|
`)))return a;const n=Ce.repeat(e+1);return`{
|
|
51
51
|
${r.map(i=>`${n}${i}`).join(`,
|
|
52
52
|
`)}
|
|
53
|
-
${Ce.repeat(e)}}`}case"Member":{const r=H(t.object,e),a=t.optional?"?.":".";if(t.property)return`${r}${a}${t.property}`;if(t.computed){const n=H(t.computed,e);return t.optional?`${r}?.[${n}]`:`${r}[${n}]`}return r}case"Unary":return`${t.operator}${H(t.argument,e)}`;case"Binary":return`${H(t.left,e)} ${t.operator} ${H(t.right,e)}`;case"Ternary":return`${H(t.test,e)} ? ${H(t.consequent,e)} : ${H(t.alternate,e)}`;case"Call":return
|
|
53
|
+
${Ce.repeat(e)}}`}case"Member":{const r=H(t.object,e),a=t.optional?"?.":".";if(t.property)return`${r}${a}${t.property}`;if(t.computed){const n=H(t.computed,e);return t.optional?`${r}?.[${n}]`:`${r}[${n}]`}return r}case"Unary":return`${t.operator}${H(t.argument,e)}`;case"Binary":return`${H(t.left,e)} ${t.operator} ${H(t.right,e)}`;case"Ternary":return`${H(t.test,e)} ? ${H(t.consequent,e)} : ${H(t.alternate,e)}`;case"Call":return lt(t.callee,t.arguments,e);case"MethodCall":{const r=H(t.object,e),a=t.optional?"?.":".";return lt(`${r}${a}${t.method}`,t.arguments,e)}case"Invoke":{const r=H(t.callee,e),a=t.optional?"?.":"";return lt(`${r}${a}`,t.arguments,e)}case"New":{const r=H(t.callee,e);return`new ${lt(r,t.arguments,e)}`}case"BuiltinCall":return lt(`@${t.name}`,t.arguments,e);case"Template":return as(t.quasis,t.expressions,e);case"Spread":return`...${H(t.argument,e)}`;case"Lambda":{const r=t.params.map(n=>{const i=n.rest?"...":"";return n.defaultValue?`${i}${n.name} = ${H(n.defaultValue,e)}`:`${i}${n.name}`}).join(", ");return`${t.params.length===1&&!t.params[0].defaultValue&&!t.params[0].rest?t.params[0].name:`(${r})`} => ${H(t.body,e)}`}case"Block":return`{
|
|
54
54
|
${ue(t.body,e+1)}
|
|
55
|
-
${Ce.repeat(e)}}`}}function
|
|
55
|
+
${Ce.repeat(e)}}`}}function lt(t,e,r){if(e.length===0)return`${t}()`;const a=e.map(o=>H(o,r)),n=`${t}(${a.join(", ")})`;if(n.length<=80&&!a.some(o=>o.includes(`
|
|
56
56
|
`)))return n;const i=Ce.repeat(r+1);return`${t}(
|
|
57
57
|
${a.map(o=>`${i}${o}`).join(`,
|
|
58
58
|
`)}
|
|
59
|
-
${Ce.repeat(r)})`}function
|
|
59
|
+
${Ce.repeat(r)})`}function es(t,e){const r=Ce.repeat(e),a=t.body.map(n=>Qe(n,e+1)).join(`
|
|
60
60
|
`);return t.test===null?`${r}default:
|
|
61
61
|
${a}
|
|
62
62
|
${Qe({kind:"ExpressionStatement",expression:{kind:"Identifier",name:"break"}},e+1)}`:`${r}case ${H(t.test,e)}:
|
|
63
63
|
${a}
|
|
64
|
-
${Ce.repeat(e+1)}break`}function
|
|
64
|
+
${Ce.repeat(e+1)}break`}function ts(t,e){if(t.spread)return`...${H(t.value,e)}`;const r=H(t.value,e);return t.value.kind==="Identifier"&&t.value.name===t.key&&Oa.test(t.key)?t.key:`${Oa.test(t.key)?t.key:_a(t.key)}: ${r}`}function rs(t){return t===null?"null":typeof t=="string"?_a(t):typeof t=="boolean"?t?"true":"false":String(t)}function _a(t){return Xo.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`"${t}"`}function as(t,e,r){const a=[];for(let n=0;n<t.length;n+=1)a.push(t[n]??""),n<e.length&&(a.push("${"),a.push(H(e[n],r)),a.push("}"));return`\`${a.join("")}\``}function Fa(t,e,r){const a=new Map,n=[],i=new Set,o=[];let s=0;const c=(m,g,b,h)=>{o.push({line:g,column:b,message:m===e?h:`${m}: ${h}`,severity:"error"})};function u(m,g){const b=a.get(m);if(b)return b;if(i.has(m))return;i.add(m);let h;if(g!==null)h=g;else try{h=r.load(m)}catch{i.delete(m),c(e,0,0,`Failed to load imported module "${m}".`);return}const v=ge(h),y={id:s++,path:m,program:v,edges:[],declaredPlain:new Set,declaredState:new Set,exportedPlain:new Set,exportedState:new Set,renamePlain:new Map,renameState:new Map};a.set(m,y),ns(y);for(const x of v.statements){if(x.kind!=="Import")continue;const w=r.resolve(x.source,m);if(y.edges.push({stmt:x,resolvedPath:w}),w===null){c(m,x.loc?.line??0,x.loc?.column??0,`Cannot resolve import "${x.source}".`);continue}u(w,null)}return i.delete(m),n.push(m),y}u(e,t);for(const m of a.values())if(m.path!==e){for(const g of m.declaredPlain)m.renamePlain.set(g,`__a${m.id}_${g}`);for(const g of m.declaredState)m.renameState.set(g,`__a${m.id}_${g}`)}for(const m of a.values())for(const{stmt:g,resolvedPath:b}of m.edges){if(b===null)continue;const h=a.get(b);if(h)for(const v of g.specifiers){const y=g.loc?.line??0,x=g.loc?.column??0;if(v.isState){if(!h.exportedState.has(v.imported)){c(m.path,y,x,`"${g.source}" does not export \`$${v.imported}\`.`);continue}m.renameState.set(v.local,h.renameState.get(v.imported)??`__a${h.id}_${v.imported}`)}else{if(!h.exportedPlain.has(v.imported)){c(m.path,y,x,`"${g.source}" does not export \`${v.imported}\`.`);continue}m.renamePlain.set(v.local,h.renamePlain.get(v.imported)??`__a${h.id}_${v.imported}`)}}}const p=[];for(const m of n){const g=a.get(m),b=os(g);for(const h of g.program.statements)h.kind!=="Import"&&(b.renameTopLevel(h),is(h),h.kind==="EffectDeclaration"&&g.path!==e&&(h.name=`__effect_a${g.id}_${h.name.replace(/^__effect_/,"")}`),p.push(h))}const d=a.get(e);return{program:{statements:p,errors:d?d.program.errors:[]},diagnostics:o,dependencies:n.filter(m=>m!==e)}}function ns(t){for(const e of t.program.statements)switch(e.kind){case"Assignment":e.isState?(t.declaredState.add(e.identifier),e.exported&&t.exportedState.add(e.identifier)):(t.declaredPlain.add(e.identifier),e.exported&&t.exportedPlain.add(e.identifier));break;case"ComponentDeclaration":case"ActionDeclaration":t.declaredPlain.add(e.name),e.exported&&t.exportedPlain.add(e.name);break;case"HookDeclaration":t.declaredState.add(e.name),e.exported&&t.exportedState.add(e.name);break;case"DestructureStatement":for(const r of e.bindings)r.name&&t.declaredPlain.add(r.name);break}}function is(t){(t.kind==="Assignment"||t.kind==="ComponentDeclaration"||t.kind==="ActionDeclaration"||t.kind==="HookDeclaration")&&delete t.exported}function os(t){const e=[],r=h=>{for(const v of e)if(v.has(h))return!0;return!1},a=h=>r(h)?h:t.renamePlain.get(h)??h,n=h=>t.renameState.get(h)??h,i=h=>{e.push(new Set(h))},o=()=>{e.pop()},s=h=>h.bindings.map(v=>v.name).filter(v=>!!v),c=h=>{const v=[];for(const y of h)y.name&&v.push(y.name),y.pattern&&v.push(...s(y.pattern));return v},u=h=>{for(const v of h)v.defaultValue&&p(v.defaultValue)};function p(h){switch(h.kind){case"Literal":return;case"Identifier":h.name=a(h.name);return;case"StateRef":h.name=n(h.name);return;case"Array":for(const v of h.elements)p(v);return;case"Object":for(const v of h.properties)v.computedKey&&p(v.computedKey),p(v.value);return;case"Member":p(h.object),h.computed&&p(h.computed);return;case"Unary":p(h.argument);return;case"Binary":p(h.left),p(h.right);return;case"Ternary":p(h.test),p(h.consequent),p(h.alternate);return;case"Call":h.callee=a(h.callee);for(const v of h.arguments)p(v);return;case"MethodCall":p(h.object);for(const v of h.arguments)p(v);return;case"Invoke":p(h.callee);for(const v of h.arguments)p(v);return;case"BuiltinCall":for(const v of h.arguments)p(v);return;case"New":p(h.callee);for(const v of h.arguments)p(v);return;case"Template":for(const v of h.expressions)p(v);return;case"Spread":p(h.argument);return;case"Lambda":i(c(h.params)),u(h.params),p(h.body),o();return;case"Block":d(h);return}}function d(h){i([]);const v=e[e.length-1];for(const y of h.body)b(y,!1),m(y,v);o()}function m(h,v){if(h.kind==="DestructureStatement")for(const y of h.bindings)y.name&&v.add(y.name);else(h.kind==="ComponentDeclaration"||h.kind==="ActionDeclaration")&&v.add(h.name)}function g(h){if(h.kind==="DestructureStatement"){p(h.expression);for(const v of h.bindings)v.defaultValue&&p(v.defaultValue),v.name=a(v.name);return}b(h,!0)}function b(h,v){switch(h.kind){case"Import":return;case"Assignment":h.identifier=h.isState?n(h.identifier):a(h.identifier),p(h.expression);return;case"ComponentDeclaration":case"ActionDeclaration":h.name=a(h.name),i(c(h.params)),u(h.params),d(h.body),o();return;case"HookDeclaration":h.name=n(h.name),i(c(h.params)),u(h.params),d(h.body),o();return;case"EffectDeclaration":for(const y of h.triggers)y.kind==="state"&&(y.name=n(y.name));d(h.body);return;case"Await":p(h.argument);return;case"Return":h.argument&&p(h.argument);return;case"ExpressionStatement":p(h.expression);return;case"IfStatement":p(h.test),d(h.consequent),h.alternate&&(h.alternate.kind==="IfStatement"?b(h.alternate,!1):d(h.alternate));return;case"SwitchStatement":p(h.discriminant);for(const y of h.cases){y.test&&p(y.test);for(const x of y.body)b(x,!1)}return;case"ForOfStatement":{p(h.iterable);const y=[h.item];h.index&&y.push(h.index),h.destructure&&y.push(...h.destructure),i(y),d(h.body),o();return}case"ForInStatement":p(h.iterable),i([h.item]),d(h.body),o();return;case"ForClassicStatement":{const y=[];h.init&&h.init.kind==="Assignment"&&h.init.identifier&&y.push(h.init.identifier),i(y),h.init&&b(h.init,!1),h.test&&p(h.test),h.update&&p(h.update),d(h.body),o();return}case"WhileStatement":case"DoWhileStatement":p(h.test),d(h.body);return;case"DestructureStatement":p(h.expression);for(const y of h.bindings)y.defaultValue&&p(y.defaultValue);if(v)for(const y of h.bindings)y.name=a(y.name);return;case"ThrowStatement":p(h.argument);return;case"TryStatement":d(h.block),h.catchBlock&&(i(h.catchParam?[h.catchParam]:[]),d(h.catchBlock),o()),h.finallyBlock&&d(h.finallyBlock);return;case"BreakStatement":case"ContinueStatement":return}}return{renameTopLevel:g}}function cr(t){return/^[a-z][a-z0-9+.-]*:\/\//i.test(t)}function Ua(t){const e=[];for(const r of t)r===""||r==="."||(r===".."?e.pop():e.push(r));return e.join("/")}function ss(t){const e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function ur(t,e){if(cr(t))try{return new URL(t).href}catch{return null}if(cr(e))try{return new URL(t,e).href}catch{return null}return t.startsWith("/")?Ua(t.split("/")):t.startsWith("./")||t.startsWith("../")?Ua(`${ss(e)}/${t}`.split("/")):null}function Ha(t){return{resolve:(e,r)=>ur(e,r),load:e=>{const r=t[e];if(r===void 0)throw new Error(`not found: ${e}`);return r}}}async function ls(t){if(typeof fetch!="function")throw new Error("global fetch is unavailable; cannot load URL imports");const e=await fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.text()}async function Va(t){const{entry:e,files:r}=t,a=t.fetch??ls,n=[],i={...r},o=new Set;async function s(p){if(o.has(p))return;if(o.add(p),i[p]===void 0)if(cr(p))try{i[p]=await a(p)}catch(g){n.push({line:0,column:0,message:`Failed to fetch module "${p}": ${g.message??g}`,severity:"error"});return}else return;let d;try{d=ge(i[p])}catch{return}const m=[];for(const g of d.statements){if(g.kind!=="Import")continue;const b=ur(g.source,p);b!==null&&m.push(s(b))}await Promise.all(m)}if(i[e]===void 0)return{program:{statements:[],errors:[]},source:"",diagnostics:[{line:0,column:0,message:`Entry module "${e}" was not found.`,severity:"error"}],dependencies:[]};await s(e);const c=Fa(i[e],e,Ha(i));let u;try{u=Jo(c.program)}catch{u=i[e]}return{program:c.program,source:u,diagnostics:[...n,...c.diagnostics],dependencies:c.dependencies}}function cs(t,e){const r=[],a={};let n=t;for(const i of e){if(i.kind==="patch"){a[i.target]=i.value;continue}const o=us(n,i);n=o.programText,o.warning&&r.push(o.warning)}return{programText:n,stateUpdates:a,warnings:r}}function us(t,e){const r=ge(t);if(r.errors.length>0)return{programText:t,warning:`delta(${e.kind}): source did not parse cleanly (${r.errors[0].message}); op skipped`};switch(e.kind){case"new":{const a=ge(e.source);if(a.errors.length>0||a.statements.length===0)return{programText:t,warning:`delta(new): could not parse "${Wa(e.source)}" — op skipped`};const n=t.endsWith(`
|
|
65
65
|
`)?"":`
|
|
66
66
|
`;return{programText:t+n+e.source.trim()+`
|
|
67
|
-
`}}case"delete":{const a=
|
|
67
|
+
`}}case"delete":{const a=dr(r,e.binding);return a<0?{programText:t,warning:`delta(delete): binding "${e.binding}" not found — op skipped`}:{programText:pr(t,r,a,null)}}case"replace":{const a=dr(r,e.binding);return a<0?{programText:t,warning:`delta(replace): binding "${e.binding}" not found — op skipped`}:ge(`${e.binding} = ${e.source}`).errors.length>0?{programText:t,warning:`delta(replace): could not parse new source for "${e.binding}" — op skipped`}:{programText:pr(t,r,a,`${e.binding} = ${e.source.trim()}`)}}case"append":{const a=dr(r,e.binding);if(a<0)return{programText:t,warning:`delta(append): binding "${e.binding}" not found — op skipped`};const n=r.statements[a];if(n.kind!=="Assignment"||n.expression.kind!=="Array")return{programText:t,warning:`delta(append): binding "${e.binding}" is not an array literal — op skipped`};const i=ge(`__rui_delta_item__ = ${e.item}`),o=i.statements[0];if(i.errors.length>0||!o||o.kind!=="Assignment")return{programText:t,warning:`delta(append): could not parse item "${Wa(e.item)}" — op skipped`};const s=n.expression.elements,c=`${e.binding} = [${[...s.map(he),e.item.trim()].join(", ")}]`;return{programText:pr(t,r,a,c)}}}}function dr(t,e){return t.statements.findIndex(r=>ds(r)===e)}function ds(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function pr(t,e,r,a){const n=t.split(`
|
|
68
68
|
`),i=e.statements[r],o=e.statements[r+1],s=(i.loc?.line??1)-1,c=o?(o.loc?.line??n.length+1)-1:n.length,u=n.slice(0,s),p=n.slice(c);return a===null?[...u,...p].join(`
|
|
69
69
|
`):[...u,a,...p].join(`
|
|
70
|
-
`)}function he(t){switch(t.kind){case"Literal":return typeof t.value=="string"?`"${t.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:String(t.value);case"Identifier":return t.name;case"StateRef":return`$${t.name}`;case"Call":return`${t.callee}(${t.arguments.map(he).join(", ")})`;case"MethodCall":return`${he(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(he).join(", ")})`;case"Array":return`[${t.elements.map(he).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${he(e.value)}`:`${e.key}: ${he(e.value)}`).join(", ")} }`;case"Member":{const e=he(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${he(t.computed)}]`:e}case"Binary":return`${he(t.left)} ${t.operator} ${he(t.right)}`;case"Template":{const e=[];for(let r=0;r<t.quasis.length;r+=1)e.push(t.quasis[r]??""),r<t.expressions.length&&(e.push("${"),e.push(he(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function
|
|
70
|
+
`)}function he(t){switch(t.kind){case"Literal":return typeof t.value=="string"?`"${t.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:String(t.value);case"Identifier":return t.name;case"StateRef":return`$${t.name}`;case"Call":return`${t.callee}(${t.arguments.map(he).join(", ")})`;case"MethodCall":return`${he(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(he).join(", ")})`;case"Array":return`[${t.elements.map(he).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${he(e.value)}`:`${e.key}: ${he(e.value)}`).join(", ")} }`;case"Member":{const e=he(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${he(t.computed)}]`:e}case"Binary":return`${he(t.left)} ${t.operator} ${he(t.right)}`;case"Template":{const e=[];for(let r=0;r<t.quasis.length;r+=1)e.push(t.quasis[r]??""),r<t.expressions.length&&(e.push("${"),e.push(he(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function Wa(t){return t.length>40?`${t.slice(0,37)}...`:t}const qa=new WeakMap;function ps(t){let e=qa.get(t.components);if(!e){e=new Map;for(const r of t.components)r?.name&&e.set(r.name,r);qa.set(t.components,e)}return e}function Ka(t,e){const r=new Map;for(const a of t.components)r.set(a.name,a);for(const a of e.components)r.set(a.name,a);return{root:e.root??t.root,components:[...r.values()],componentGroups:t.componentGroups}}function Ee(t,e){return ps(t).get(e)}function mr(t){const e=t.props.findIndex(r=>r.positional===!0);return e>=0?e:t.props.length>0?0:-1}function fr(t){const e=mr(t);return e>=0?t.props[e]:void 0}function Ga(t){for(const e of t){const r=e.props.filter(a=>a.positional===!0);if(r.length>1){const a=r.map(n=>n.name).join(", ");throw new SyntaxError(`Component "${e.name}" declares ${r.length} positional props (${a}). Aktion 0.5 §19.1 allows at most one.`)}}}function Ya(t,e){const r={};return t.props.forEach((a,n)=>{n<e.length&&(r[a.name]=e[n])}),r}function ms(t,e){const r=ge(t),a=gr(r,e);return a.length>0&&(r.errors=[...r.errors,...a]),r}function gr(t,e){const r=[];for(const a of t.statements)le(a,e,r);return r}function le(t,e,r){switch(t.kind){case"Assignment":V(t.expression,e,r);return;case"ExpressionStatement":V(t.expression,e,r);return;case"ComponentDeclaration":case"ActionDeclaration":case"EffectDeclaration":case"HookDeclaration":for(const a of t.body.body)le(a,e,r);return;case"Return":t.argument&&V(t.argument,e,r);return;case"Await":V(t.argument,e,r);return;case"IfStatement":V(t.test,e,r);for(const a of t.consequent.body)le(a,e,r);if(t.alternate)if(t.alternate.kind==="IfStatement")le(t.alternate,e,r);else for(const a of t.alternate.body)le(a,e,r);return;case"SwitchStatement":V(t.discriminant,e,r);for(const a of t.cases){a.test&&V(a.test,e,r);for(const n of a.body)le(n,e,r)}return;case"ForOfStatement":V(t.iterable,e,r);for(const a of t.body.body)le(a,e,r);return;case"ForClassicStatement":t.init&&le(t.init,e,r),t.test&&V(t.test,e,r),t.update&&V(t.update,e,r);for(const a of t.body.body)le(a,e,r);return;case"WhileStatement":case"DoWhileStatement":V(t.test,e,r);for(const a of t.body.body)le(a,e,r);return;case"ForInStatement":V(t.iterable,e,r);for(const a of t.body.body)le(a,e,r);return;case"DestructureStatement":V(t.expression,e,r);for(const a of t.bindings)a.defaultValue&&V(a.defaultValue,e,r);return;case"TryStatement":for(const a of t.block.body)le(a,e,r);if(t.catchBlock)for(const a of t.catchBlock.body)le(a,e,r);if(t.finallyBlock)for(const a of t.finallyBlock.body)le(a,e,r);return;case"ThrowStatement":V(t.argument,e,r);return;default:return}}function V(t,e,r){if(t)switch(t.kind){case"Call":{fs(t,e,r);for(const a of t.arguments)V(a,e,r);return}case"MethodCall":{V(t.object,e,r);for(const a of t.arguments)V(a,e,r);return}case"BuiltinCall":{for(const a of t.arguments)V(a,e,r);return}case"Array":for(const a of t.elements)V(a,e,r);return;case"Object":for(const a of t.properties)V(a.value,e,r);return;case"Template":for(const a of t.expressions)V(a,e,r);return;case"Binary":V(t.left,e,r),V(t.right,e,r);return;case"Unary":V(t.argument,e,r);return;case"Ternary":V(t.test,e,r),V(t.consequent,e,r),V(t.alternate,e,r);return;case"Member":V(t.object,e,r),t.computed&&V(t.computed,e,r);return;case"Spread":V(t.argument,e,r);return;case"Invoke":t.callee.kind==="StateRef"&&t.callee.name==="theme"&&vs(t,r),V(t.callee,e,r);for(const a of t.arguments)V(a,e,r);return;case"New":V(t.callee,e,r);for(const a of t.arguments)V(a,e,r);return;case"Lambda":if(t.body.kind==="Block")for(const a of t.body.body)le(a,e,r);else V(t.body,e,r);return;case"Block":for(const a of t.body)le(a,e,r);return;default:return}}function fs(t,e,r){const a=Ee(e,t.callee);if(!a)return;const n=new Set;for(const p of a.props)if(n.add(p.name),p.aliases)for(const d of p.aliases)n.add(d);n.add("key");const i=t.arguments;let o=-1;for(let p=i.length-1;p>=0;p-=1)if(i[p].kind==="Object"){o=p;break}const s=o>=0?i[o]:null,c=[];for(let p=0;p<i.length;p++)p!==o&&c.push(i[p]);if(c.length>1){const d=fr(a)?.name??"(none)",m=gs(i,s),g=a.props.filter(h=>h.name!==d&&!m.has(h.name)).slice(0,c.length-1).map(h=>h.name),b=g.length>0?g.map(h=>`${h}: …`).join(", "):"use a trailing { prop: value } object";r.push({message:`${t.callee}(...) — Aktion 0.5 §19.1 allows at most one positional argument (the "${d}" prop). The extra ${c.length-1} positional argument(s) must be passed inside a trailing object: ${b}. Multi-positional calls are removed.`,line:t.loc?.line??0,column:t.loc?.column??0})}const u=[];if(s)for(const p of s.properties)p.spread||u.push({name:p.key,value:p.value,loc:p.value.loc??s.loc});for(const p of u){if(!n.has(p.name)){r.push({message:`Unknown prop "${p.name}" on <${t.callee}>. Known props: ${a.props.map(m=>m.name).join(", ")}.`,line:p.loc?.line??t.loc?.line??0,column:p.loc?.column??t.loc?.column??0});continue}const d=a.props.find(m=>m.name===p.name||(m.aliases?.includes(p.name)??!1));if(d?.enum&&p.value.kind==="Literal"&&typeof p.value.value=="string"){const m=p.value.value;d.enum.includes(m)||r.push({message:`<${t.callee}> ${p.name}="${m}" — must be one of ${d.enum.map(g=>`"${g}"`).join(", ")}.`,line:p.loc?.line??t.loc?.line??0,column:p.loc?.column??t.loc?.column??0})}}}function gs(t,e){const r=new Set;if(e)for(const a of e.properties)a.spread||r.add(a.key);return r}const hs=new Set(["colors","radius","font"]),bs=new Set(["name","direction"]);function vs(t,e){const r=t.arguments[0];if(!(!r||r.kind!=="Object"))for(const a of r.properties){if(a.spread||hs.has(a.key)||bs.has(a.key))continue;const n=ys(a.key),i=a.key.startsWith("--")?`$theme({"${a.key}": ...}) — free-form CSS variable keys are removed in Aktion 0.5. Use the structured form: $theme({ colors: {...}, radius: {...}, font: {...} }).`:`$theme({${a.key}: ...}) — legacy flat-shape token is removed in Aktion 0.5. Use ${n}.`;e.push({message:i,line:t.loc?.line??0,column:t.loc?.column??0})}}function ys(t){const e=[{prefix:"color",group:"colors"},{prefix:"radius",group:"radius"},{prefix:"font",group:"font"}];for(const{prefix:r,group:a}of e)if(t!==r&&t.startsWith(r)&&t.length>r.length){const n=t.slice(r.length),i=n.charAt(0).toLowerCase()+n.slice(1);return`$theme({ ${a}: { ${i}: ... } })`}return"$theme({ colors: {...}, radius: {...}, font: {...} })"}const Pt={name:"aktion",atoms:["true","false","null","undefined"],keywords:["function","import","export","if","else","switch","case","break","continue","for","while","do","of","in","let","var","const","await","async","return","default","try","catch","finally","throw","new","typeof","instanceof","delete","void","aktion","route"],operators:["+","-","*","/","%","!","=","<",">","?",":",".",","],operatorsLong:["...","==","!=",">=","<=","&&","||","??","?."],brackets:[{open:"(",close:")"},{open:"[",close:"]"},{open:"{",close:"}"}],comments:{line:"//",blockStart:"/*",blockEnd:"*/"},strings:{singleLineQuotes:['"',"'"],multiLineQuote:"`"},identifier:{start:/[A-Za-z_]/,part:/[A-Za-z0-9_]/},sigils:{state:"$"}},Xa={aktion:{summary:"Legacy entry-point binding — prefer the `$app(...)` builtin to register the root of the rendered UI tree.",syntax:"$app(Component(...))",example:'$app(Stack([Heading("Hi"), Text("Welcome")]))'},route:{summary:"Reactive router handle — exposes path, params, query, and navigate().",syntax:"route.path · route.params · route.query · route.navigate(path)",example:'Button("Home", () => route.navigate("/"))'},$emit:{summary:"Dispatch a custom DOM event from the host element.",syntax:'$emit("event-name", detail)',example:'Button("Save", () => $emit("saved", { id: $id }))'},import:{summary:"Import named bindings (components, actions, hooks, `$state`) from another `.aktion` file. Multi-file projects are linked in the browser.",syntax:'import { Name, Other as Alias, $shared } from "./module.aktion"',example:`import { Button } from "./Button.aktion"
|
|
71
71
|
import { $count } from "./store.aktion"`},export:{summary:"Mark a top-level declaration importable from another file. Anything not exported is private to its file.",syntax:"export function Name(...) { ... } · export $state = ... · export name = ...",example:`export function Card2({ title }) {
|
|
72
72
|
return Card([CardHeader(title)])
|
|
73
73
|
}`},function:{summary:"Declare a component or action — first-letter case does not matter.",syntax:"function name(params) { ... }",example:"function Greeting(name) {\n return Text(`Hello ${name}`)\n}"},$effect:{summary:"Run a side-effect when dependencies change (timers, fetch, analytics).",syntax:"$effect(() => { ... }, [deps])",example:`$effect(() => {
|
|
@@ -93,19 +93,19 @@ import { $count } from "./store.aktion"`},export:{summary:"Mark a top-level decl
|
|
|
93
93
|
risky()
|
|
94
94
|
} catch (e) {
|
|
95
95
|
log(e)
|
|
96
|
-
}`},catch:{summary:"Handle an error thrown inside the preceding `try` block.",syntax:"catch (error) { ... }",example:"catch (e) { $error = e }"},finally:{summary:"Run cleanup after `try` / `catch`, regardless of outcome.",syntax:"finally { ... }",example:"finally { $loading = false }"},throw:{summary:"Raise an error — caught by an enclosing `try` / `catch`.",syntax:"throw value",example:'throw "invalid state"'},new:{summary:"Construct an instance of a host class (Date, Map, Set, …).",syntax:"new Constructor(args)",example:"let now = new Date()"},typeof:{summary:`Return a string naming a value's type ("number", "string", …).`,syntax:"typeof value",example:'if (typeof x === "number") { ... }'},instanceof:{summary:"Test whether a value is an instance of a constructor.",syntax:"value instanceof Constructor",example:"if (d instanceof Date) { ... }"},delete:{summary:"Remove a property from an object.",syntax:"delete obj.prop",example:"delete $form.draft"},void:{summary:"Evaluate an expression and yield `undefined`.",syntax:"void expression",example:"void sideEffect()"}};function Ka(t=Mt){const e=()=>({inBacktick:!1,inBlockComment:!1}),r=d=>({...d}),a=new Set(t.atoms),n=new Set(t.keywords),i=/^[A-Z][A-Za-z0-9_]*/,o=/^[a-z_][A-Za-z0-9_]*/,s=/^-?\d+(?:\.\d+)?/,c=new Set([...t.operators.join(""),..."=<>!&|"]),u=(d,m)=>{for(;!d.eol();){const g=d.next();if(!g)return;if(g==="\\"){d.next();continue}if(g===m)return}};return{startState:e,copyState:r,token:(d,m)=>{if(m.inBacktick){for(;!d.eol();){const b=d.next();if(b==="\\"){d.next();continue}if(b==="`")return m.inBacktick=!1,"string"}return"string"}if(m.inBlockComment){for(;!d.eol();){if(d.match(t.comments.blockEnd,!0))return m.inBlockComment=!1,"comment";d.next()}return"comment"}if(d.eatWhile(/[ \t]/))return null;if(d.match(t.comments.line,!0))return d.skipToEnd(),"comment";if(d.match(t.comments.blockStart,!0)){for(m.inBlockComment=!0;!d.eol();){if(d.match(t.comments.blockEnd,!0))return m.inBlockComment=!1,"comment";d.next()}return"comment"}const g=d.peek();if(g==null)return null;if(t.strings.singleLineQuotes.includes(g)){const b=g;return d.next(),u(d,b),"string"}if(g===t.strings.multiLineQuote){for(d.next();!d.eol();){const b=d.next();if(b==="\\"){d.next();continue}if(b==="`")return"string"}return m.inBacktick=!0,"string"}if(g>="0"&&g<="9"&&d.match(s,!0)||g==="-"&&d.match(/^-\d+(?:\.\d+)?/,!1)&&d.match(s,!0))return"number";if(g===t.sigils.state)return d.next(),d.peek()===t.sigils.state&&d.next(),d.eatWhile(t.identifier.part),"state";if(t.identifier.start.test(g)){if(d.match(i,!0))return"component";const h=d.match(o,!0);if(h){const v=h[0];return a.has(v)?"atom":n.has(v)?"keyword":d.peek()==="."?"loopvar":"identifier"}}for(const b of t.operatorsLong)if(d.match(b,!0))return"operator";return g==="."?(d.next(),d.peek()&&t.identifier.start.test(d.peek())?(d.eatWhile(t.identifier.part),"property"):"punctuation"):"()[]{},:?".includes(g)?(d.next(),"punctuation"):c.has(g)?(d.next(),"operator"):(d.next(),null)},languageData:{commentTokens:{line:t.comments.line,block:{open:t.comments.blockStart,close:t.comments.blockEnd}},closeBrackets:{brackets:["(","[","{",'"',"'","`"]},indentOnInput:/^\s*[)\]}]$/}}}const Ga={comment:"comment",string:"string",number:"number",atom:"atom",keyword:"keyword",state:"variableName.special",component:"typeName",identifier:"variableName",loopvar:"variableName.local",property:"propertyName",operator:"operator",punctuation:null},Nt=[{name:"state",sigil:"$state",category:"hook",signature:"$state(initial)",summary:"Hook: per-instance state → [value, setValue] (like React's useState)."},{name:"memo",sigil:"$memo",category:"hook",signature:"$memo(() => value, [deps])",summary:"Hook: value recomputed only when a dependency changes (like useMemo)."},{name:"ref",sigil:"$ref",category:"hook",signature:"$ref(initial)",summary:"Hook: stable { current } box; writing .current does not re-render (like useRef)."},{name:"reducer",sigil:"$reducer",category:"hook",signature:"$reducer((state, action) => next, initial)",summary:"Hook: [state, dispatch] (like useReducer)."},{name:"id",sigil:"$id",category:"hook",signature:"$id(prefix?)",summary:"Hook: stable unique id per component instance (like useId)."},{name:"effect",sigil:"$effect",category:"effect",signature:"$effect(() => { … }, [deps])",summary:'Declarative side effect; deps mix $state, "mount"/"unmount", "every(N)", "debounce(N)".'},{name:"optimistic",sigil:"$optimistic",category:"effect",signature:"$optimistic(() => { … })",summary:"Run optimistic writes; auto-rolls back state if the callback throws or rejects."},{name:"store",sigil:"$store",category:"effect",signature:"$store({ ...state, ...methods })",summary:"Global store: shared state + actions (like Zustand/Pinia)."},{name:"http",sigil:"$http",category:"data",signature:"$http({ url, method, … })",summary:"Reactive HTTP resource bag — { data, loading, error, refetch }."},{name:"query",sigil:"$query",category:"data",signature:"$query({ url, key, ttl })",summary:"Cached + deduplicated HTTP read."},{name:"mutation",sigil:"$mutation",category:"data",signature:"$mutation({ url, method })",summary:"Deferred write; fires on .mutate(overrides?)."},{name:"app",sigil:"$app",category:"app",signature:"$app(root)",summary:"Register the root of the rendered UI tree — every program needs one."},{name:"router",sigil:"$router",category:"routing",signature:"$router({ '/': Home(), default: NotFound() })",summary:"Outlet-first router: maps path patterns to component trees."},{name:"theme",sigil:"$theme",category:"theme",signature:"$theme({ colors, radius, font, … })",summary:"In-script theme override merged on top of the active base theme."},{name:"emit",sigil:"$emit",category:"event",signature:"$emit('name', detail)",summary:"Dispatch a CustomEvent from the host element."},{name:"util",sigil:"$util",category:"namespace",signature:"$util",summary:"Runtime helper namespace ($util.format, $util.sum, $util.range, …).",namespace:!0},{name:"storage",sigil:"$storage",category:"namespace",signature:"$storage",summary:"Persistent storage namespace ($storage.local, $storage.session, …).",namespace:!0},{name:"console",sigil:"$console",category:"namespace",signature:"$console",summary:"Console namespace ($console.log, $console.warn, …).",namespace:!0},{name:"toast",sigil:"$toast",category:"namespace",signature:"$toast",summary:"Imperative toasts: $toast.show/.success/.error/.dismiss; reactive .items.",namespace:!0},{name:"i18n",sigil:"$i18n",category:"data",signature:"$i18n({ translations, … })",summary:"Translation bundle → { t, setCurrentLanguage, getCurrentLanguage }."}],Ya=new Set(Nt.map(t=>t.name)),Xa=Object.freeze(Object.fromEntries(Nt.map(t=>[t.name,t])));function ps(t){return Xa[t]}function ms(t){return Ya.has(t)}const fs="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",Ja="6.7.2",Za="data-rui-font-awesome",gs=new Set(["solid","regular","brands"]),Qa="solid";function hs(t){typeof document<"u"&&en(document.head,document),en(t,t.ownerDocument??document)}function en(t,e){if(bs()||t.querySelector(`link[${Za}="${Ja}"]`))return;const a=e.createElement("link");a.rel="stylesheet",a.href=fs,a.setAttribute(Za,Ja);try{t.appendChild(a)}catch{}}function bs(){return typeof globalThis.happyDOM<"u"}function Pt(t){if(typeof t!="string")return[];const e=ys(t).trim();if(!e)return[];if(!ws(e))return[];const[r,a]=xs(e);return a?[`fa-${r}`,`fa-${a}`]:[]}const vs=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function ys(t){return t.replace(vs,"")}function xs(t){const e=t.indexOf(":");if(e===-1)return[Qa,t];const r=t.slice(0,e).trim().toLowerCase(),a=t.slice(e+1).trim();return gs.has(r)?[r,a]:[Qa,a||t]}function ws(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const ks=["xs","sm","md","lg","xl"];function l(t,e,r){const a=document.createElement(t);if(e)for(const[n,i]of Object.entries(e))i==null||i===!1||(n==="class"?a.setAttribute("class",String(i)):n==="html"?a.innerHTML=String(i):i===!0?a.setAttribute(n,""):a.setAttribute(n,String(i)));if(r)for(const n of r)n!=null&&a.append(typeof n=="string"?document.createTextNode(n):n);return a}function $(t){return Array.isArray(t)?t:t==null?[]:[t]}function f(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function A(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function E(t,e=0){if(typeof t=="number")return t;if(typeof t=="string"&&t.trim()!==""){const r=Number(t);if(!Number.isNaN(r))return r}return e}const et=["base","sm","md","lg","xl"];function be(t){if(t==null||typeof t!="object"||Array.isArray(t))return{kind:"single",value:t??null};const e=Object.entries(t),r={};let a=!1;for(const[n,i]of e)et.includes(n)&&(r[n]=i,a=!0);return a?{kind:"responsive",values:r}:{kind:"single",value:t}}const Ss=/["'\\\n\r<>;{}]/g;function $s(t){return t?t.replace(Ss,"").trim():""}const Cs=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function re(t,e){const r=(f(t)??"").trim();return!r||r.length>64||!Cs.test(r)?e:r}const As=/^[a-zA-Z0-9#%.,()\s+\-]+$/;function Ts(t){const e=f(t).trim();return!e||e.length>64||!As.test(e)||/\burl\s*\(|\bexpression\s*\(|javascript\s*:|@import\b/i.test(e)?"":e}const Ms=new Set(["http","https","mailto","tel"]);function tt(t,e="#"){const r=f(t).trim();if(!r)return e;const a=r.replace(/[\u0000-\u001F\u007F]/g,"");if(!a||a.startsWith("//"))return e;if(a.startsWith("#")||a.startsWith("/")||a.startsWith("?")||a.startsWith("."))return a;const n=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(a);if(!n)return a;const i=n[1].toLowerCase();return Ms.has(i)?a:e}const Ns=new Set(["http","https","data","blob"]);function ie(t){const e=f(t).trim();if(!e)return"";const r=e.replace(/[\u0000-\u001F\u007F]/g,"");if(!r||r.startsWith("//"))return"";if(r.startsWith("/")||r.startsWith(".")||r.startsWith("?")||r.startsWith("#"))return r;const a=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(r);if(!a)return r;const n=a[1].toLowerCase();return!Ns.has(n)||n==="data"&&!/^data:image\//i.test(r)?"":r}function Ps(t){if(t===null||typeof t!="object")return!1;const e=t.__kind;return e==="Component"||e==="UserComponent"}function fr(t,e,r,a,n,i){const o=e.format??"text";let s=r;if(typeof e.render=="function")try{s=e.render(r,a)}catch(u){console.error("[aktion] Col render() threw",u),s=null}const c=u=>{Ps(u)?t.append(n.renderNode(u)):u!=null&&t.append(document.createTextNode(i(u,o)))};if(Array.isArray(s))for(const u of s)c(u);else c(s);if(typeof e.onClick=="function"){t.setAttribute("data-clickable","true"),t.setAttribute("role","button"),t.tabIndex=0;const u=p=>p.target?.closest("input,button,a,label,select,textarea")?!1:(p.stopPropagation(),n.invoke(e.onClick,r,a),!0);t.onclick=p=>{u(p)},t.onkeydown=p=>{p.key!=="Enter"&&p.key!==" "||u(p)&&p.preventDefault()}}}function j(t,e={}){const r=f(t);if(!r)return null;const a=e.color?Ts(e.color):"",n=a?`color:${a};`:null,i=Pt(r),o=["rui-icon",e.className].filter(Boolean).join(" ");return i.length===0?l("span",{class:o,"data-icon-size":e.size??null,style:n},[r]):l("i",{class:`${o} ${i.join(" ")}`,"data-icon-size":e.size??null,style:n,"aria-hidden":"true"})}const lt=12,Is={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},Es={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function Ls(t){return Is[t]??"stretch"}function zs(t){return Es[t]??"flex-start"}function tn(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function Ue(t,e,r){for(const a of et){const n=e.values[a];n&&t.push(`${r}-${a}:var(--rui-spacing-${n}, ${n})`)}}function Rs(t,e,r,a){for(const n of et){const i=e.values[n];i&&t.push(`${r}-${n}:${a(String(i))}`)}}function rn(t,e,r,a){const n=be(t);if(n.kind==="single"){const i=n.value?String(n.value):a.defaultToken;r[a.attrName]=i;return}r[a.attrName]="responsive",r[a.responsiveFlag]="true",Rs(e,n,a.cssVarPrefix,a.mapper)}function Ds(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function js(t){const e=be(t.direction);return e.kind==="single"?e.value?String(e.value):"column":e.values.base?String(e.values.base):"column"}const Bs={name:"StackItem",description:"Per-child flex control inside a `Row`, `Column`, or `Stack`. Wraps one child so it can `grow` to fill leftover space, `shrink`, set a `basis`, override `alignSelf`, or change visual `order` — the building block for asymmetric rows like `Row([StackItem(searchInput, { grow: 1 }), saveButton])` (input expands, button hugs).",props:[{name:"child",type:"Node",description:"Child node to wrap"},{name:"grow",type:"number",optional:!0,description:"flex-grow (0 or 1 typical)"},{name:"shrink",type:"number",optional:!0,description:"flex-shrink (0 or 1 typical)"},{name:"basis",type:"string",optional:!0,description:"flex-basis (`auto`, `0`, or CSS length)"},{name:"alignSelf",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Per-item cross-axis alignment"},{name:"order",type:"number",optional:!0,description:"Visual order override"},{name:"minWidth",type:"string",optional:!0,description:"CSS min-width"},{name:"maxWidth",type:"string",optional:!0,description:"CSS max-width"}],render:(t,e,r)=>{const a={class:"rui-stack-item"},n=[];e.grow!==void 0&&e.grow!==null&&(a["data-grow"]=String(E(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(a["data-shrink"]=String(E(e.shrink,1)));const i=f(e.basis);i==="auto"||i==="0"?a["data-basis"]=i:i&&n.push(`flex-basis:${re(i,i)}`);const o=f(e.alignSelf);if(o&&(a["data-align-self"]=o),e.order!==void 0&&e.order!==null){const p=E(e.order,0);a["data-order"]=String(p),n.push(`order:${p}`)}const s=f(e.minWidth);s&&n.push(`min-width:${re(s,s)}`);const c=f(e.maxWidth);c&&n.push(`max-width:${re(c,c)}`),n.length>0&&(a.style=n.join(";"));const u=l("div",a);return u.append(r.renderNode(e.child)),u}};function gr(t,e,r,a,n){const i=be(t),o=be(a.gap),s=be(a.padding),c=A(a.reverse),u={class:"rui-stack","data-wrap":A(a.wrap)?"true":null,"data-reverse":c?"true":null,"data-uniform":e?"true":"false","data-inline":A(a.inline)?"true":null},p=[];if(i.kind==="single"){const g=i.value?String(i.value):"column";u["data-direction"]=tn(g,c)}else{u["data-direction"]="responsive",u["data-responsive-dir"]="true";for(const g of et){const b=i.values[g];b&&p.push(`--rui-stack-dir-${g}:${tn(String(b),c)}`)}}o.kind==="single"?u["data-gap"]=o.value?String(o.value):"m":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",Ue(p,o,"--rui-stack-gap")),rn(a.align,p,u,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:r,mapper:Ls}),rn(a.justify,p,u,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:zs});const d=f(a.alignContent);if(d&&(u["data-align-content"]=d),s.kind==="single"){const g=s.value?String(s.value):null;g&&(u["data-padding"]=g)}else u["data-padding"]="responsive",u["data-responsive-padding"]="true",Ue(p,s,"--rui-stack-padding");p.length>0&&(u.style=p.join(";"));const m=l("div",u);for(const g of $(a.children))m.append(n.renderNode(g));return m}const Os={name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between children. May be a responsive map."},hr={name:"justify",type:"string | object",optional:!0,enum:["start","center","end","between","around","evenly"],description:"Main-axis distribution. May be a responsive map."},br={name:"wrap",type:"boolean",optional:!0,description:"Wrap children onto multiple lines when they overflow"},vr={name:"reverse",type:"boolean",optional:!0,description:"Reverse the visual order of children"},yr={name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token. May be a responsive map."},xr={name:"inline",type:"boolean",optional:!0,description:"Use inline-flex (shrink-to-fit) instead of a full-width block"},an={name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Alignment of wrapped lines (only when `wrap` is on)"},_s={name:"Row",description:"Lay children out horizontally (left → right) with even spacing. The developer-friendly default: children keep their natural width and are vertically centered. Set `grow=true` to make children share the row equally (for equal-width columns prefer `Grid(columns: N)`); drop a `Spacer()` between children to push them apart; wrap a child in `StackItem` for per-child grow/shrink/alignment. Use `wrap=true` for chips/tags that should flow onto multiple lines.",props:[{name:"children",type:"Node[]",description:"Children laid out left → right"},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Horizontal spacing between children (default `m`). May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Vertical alignment of children (default `center`). May be a responsive map."},{...hr},{name:"grow",type:"boolean",optional:!0,description:"Children share the row width equally (replaces the old `uniform`)"},{...br},{...vr},{...yr},{...xr},{...an}],render:(t,e,r)=>gr("row",A(e.grow),"center",e,r)},Fs={name:"Column",description:"Lay children out vertically (top → bottom) with even spacing — the most common page/section layout. Children stretch to the full width by default; set `align` to `start`/`center`/`end` to change that. This is the recommended root container for a page or a card body.",props:[{name:"children",type:"Node[]",description:"Children laid out top → bottom"},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Vertical spacing between children (default `m`). May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Horizontal alignment of children (default `stretch`). May be a responsive map."},{...hr},{...br},{...vr},{...yr},{...xr}],render:(t,e,r)=>gr("column",!1,"stretch",e,r)},Us={name:"Stack",description:'Low-level flex container with a configurable, optionally responsive `direction`. Reach for `Row` or `Column` first — they are clearer for fixed-direction layouts. Use `Stack` when the direction itself must change across breakpoints, e.g. `direction: {base: "column", md: "row"}` for a sidebar that stacks on mobile. `gap`, `align`, `justify`, and `padding` also accept responsive maps. NOTE: a `row` Stack grows its children equally by default (`uniform=true`); set `uniform=false` for natural widths (this is `Row`\'s default).',props:[{name:"children",type:"Node[]",description:"Child components to stack"},{name:"direction",type:"string | object",optional:!0,enum:["column","row"],description:'Layout direction (default column). May be a responsive map like `{base: "column", md: "row"}`.'},{...Os},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment (default stretch). May be a responsive map."},{...hr},{...an},{...br},{...vr},{name:"uniform",type:"boolean",optional:!0,description:"Row children share space equally (default true for row stacks; use `Row` for natural widths)"},{...xr},{...yr}],render:(t,e,r)=>{const n=js(e)==="row",i=e.uniform===void 0?n:A(e.uniform,n);return gr(e.direction,i,"stretch",e,r)}},Hs={name:"Center",description:'Centers its children on both axes — the easy way to drop a spinner, an empty state, a hero call-to-action, or a modal body into the middle of a region. Give it `minHeight` (e.g. `"60vh"`) to center vertically inside a tall area, or `axis` to center on only one axis. Multiple children stack in a column and are centered as a group.',props:[{name:"children",type:"Node[]",description:"Content to center"},{name:"axis",type:"string",optional:!0,enum:["both","horizontal","vertical"],description:"Which axis to center on (default both)"},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height — set to center vertically inside a tall region (e.g. `60vh`, `400px`)"},{name:"gap",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between stacked children (default `m`)"},{name:"padding",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token"},{name:"inline",type:"boolean",optional:!0,description:"Shrink to fit content instead of filling the available width"}],render:(t,e,r)=>{const a={class:"rui-center","data-axis":f(e.axis,"both"),"data-gap":f(e.gap,"m"),"data-inline":A(e.inline)?"true":null},n=f(e.padding);n&&(a["data-padding"]=n);const i=[],o=f(e.minHeight);o&&i.push(`min-height:${re(o,o)}`),i.length>0&&(a.style=i.join(";"));const s=l("div",a);for(const c of $(e.children))s.append(r.renderNode(c));return s}},Vs={name:"Card",description:"Vertical card container.",props:[{name:"children",type:"Node[]",description:"Card contents"},{name:"variant",type:"string",optional:!0,enum:["default","outlined","elevated"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-card","data-variant":f(e.variant,"default")});for(const n of $(e.children))a.append(r.renderNode(n));return a}},Ws={name:"CardHeader",description:"Card header with title and optional subtitle.",props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0}],render:(t,e)=>{const r=l("header",{class:"rui-card-header"});r.append(l("h3",{class:"rui-card-title"},[f(e.title)]));const a=f(e.subtitle);return a&&r.append(l("p",{class:"rui-card-subtitle"},[a])),r}},qs={name:"CardFooter",description:"Card footer for actions.",props:[{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=l("footer",{class:"rui-card-footer"});for(const n of $(e.children))a.append(r.renderNode(n));return a}},Ks={name:"Separator",description:"Visual divider between content sections. Supports horizontal or vertical orientation, and an optional center `label` (lifted from the legacy `Divider`). Use `decorative=false` to expose the separator to assistive tech.",props:[{name:"orientation",type:"string",optional:!0,enum:["horizontal","vertical"]},{name:"label",type:"string",optional:!0,description:"Optional label rendered in the middle (horizontal only)"},{name:"decorative",type:"boolean",optional:!0,description:"Hides the separator from assistive tech when true (default)"}],render:(t,e)=>{const r=f(e.orientation,"horizontal"),a=A(e.decorative,!0),n=f(e.label);return n&&r==="horizontal"?l("div",{class:"rui-separator rui-separator-with-label","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r},[l("span",{class:"rui-separator-line"}),l("span",{class:"rui-separator-label"},[n]),l("span",{class:"rui-separator-line"})]):l("div",{class:"rui-separator","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r})}},nn=(t,e,r=!1)=>{const a=l("li",{class:"rui-steps-item","data-active":r?"true":"false"});return a.append(l("div",{class:"rui-steps-title"},[t])),e&&a.append(l("div",{class:"rui-steps-details"},[e])),a},Gs={name:"Steps",description:"Numbered step-by-step guide. Pass items as `{title, details?, active?}` objects. Use `active` to mark the current step in a multi-step flow.",props:[{name:"items",type:"object[]"}],render:(t,e,r)=>{const a=l("ol",{class:"rui-steps"});for(const n of $(e.items)){if(n&&typeof n=="object"&&n.__kind==="Component"){a.append(r.renderNode(n));continue}if(n&&typeof n=="object"){const i=n;a.append(nn(f(i.title),f(i.details),A(i.active)));continue}a.append(nn(f(n),""))}return a}},Ys={name:"TabItem",description:"Single tab definition (used inside Tabs). Add `badge` for a count chip in the tab trigger, and `icon` for a leading Font Awesome icon.",props:[{name:"value",type:"string",description:"Stable identifier for the tab"},{name:"label",type:"string",description:"Display label"},{name:"children",type:"Node[]",description:"Tab content"},{name:"badge",type:"string",optional:!0,description:"Trailing chip rendered in the tab trigger (count / status)"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown before the label"}],render:(t,e,r)=>{const a=l("div",{class:"rui-tab-content",role:"tabpanel","data-value":f(e.value),"data-active":"false"});for(const n of $(e.children))a.append(r.renderNode(n));return a}},Xs={name:"Tabs",description:'Tabbed container. Children must be TabItem components. Supports `orientation="vertical"` for sidebar-style tabs and built-in keyboard navigation (←/→ or ↑/↓, Home, End). Provide `onChange` to react when the user switches tabs (called with the new tab\'s value).',props:[{name:"items",type:"TabItem[]",description:"Tab definitions"},{name:"defaultValue",type:"string",optional:!0,description:"Initially active tab value"},{name:"orientation",type:"string",optional:!0,enum:["horizontal","vertical"],description:"Layout direction (default `horizontal`)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-activated tab value when the user switches tabs"}],render:(t,e,r)=>{const a=$(e.items),n=f(e.orientation,"horizontal"),i=l("div",{class:"rui-tabs","data-orientation":n}),o=l("div",{class:"rui-tab-list",role:"tablist","aria-orientation":n}),s=l("div",{class:"rui-tab-panels"});let c=f(e.defaultValue);if(!c&&a.length>0){const m=a[0];c=f(m?.args?.[0],"tab-0")}const u=r.useInstanceState("activeTab",c);f(e.defaultValue)&&f(e.defaultValue)!==c&&u.set(f(e.defaultValue)),new Set(a.map((m,g)=>f(m.args?.[0],`tab-${g}`))).has(u.get())||u.set(c);const d=(m,g)=>{const b=u.get();u.set(m);const h=g.closest(".rui-tabs");h&&(h.querySelectorAll(".rui-tab-trigger").forEach(v=>{const y=v.getAttribute("data-value")===m;v.setAttribute("aria-selected",y?"true":"false"),v.tabIndex=y?0:-1}),h.querySelectorAll(".rui-tab-content").forEach(v=>{v.setAttribute("data-active",v.getAttribute("data-value")===m?"true":"false")})),b!==m&&r.invoke(e.onChange,m)};return a.forEach((m,g)=>{const b=m,h=f(b.args?.[0],`tab-${g}`),v=f(b.args?.[1],`Tab ${g+1}`),y=f(b.args?.[3]),x=f(b.args?.[4]),w=h===u.get(),k=l("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":h,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),T=x?Js(x):null;T&&k.append(T),k.append(l("span",{class:"rui-tab-trigger-label"},[v])),y&&k.append(l("span",{class:"rui-tab-trigger-badge"},[y])),k.onclick=C=>{const N=C.currentTarget??C.target;d(h,N)},k.onkeydown=C=>{const N=C,I=n!=="vertical",L=I?N.key==="ArrowRight":N.key==="ArrowDown",R=I?N.key==="ArrowLeft":N.key==="ArrowUp";if(!L&&!R&&N.key!=="Home"&&N.key!=="End")return;N.preventDefault();const q=N.currentTarget??N.target,O=q.closest(".rui-tab-list");if(!O)return;const U=Array.from(O.querySelectorAll(".rui-tab-trigger"));if(U.length===0)return;const J=U.indexOf(q);let Z=J;N.key==="Home"?Z=0:N.key==="End"?Z=U.length-1:L?Z=(J+1)%U.length:R&&(Z=(J-1+U.length)%U.length);const me=U[Z];if(!me)return;me.focus();const $e=me.getAttribute("data-value")??"";$e&&d($e,me)},o.append(k);const S=r.renderNode(m);S.setAttribute("data-value",h),S.setAttribute("data-active",w?"true":"false"),s.append(S)}),i.append(o,s),i}};function Js(t){return j(t,{className:"rui-tab-trigger-icon"})}const Zs={name:"AccordionItem",description:"Single accordion section.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"open",type:"boolean",optional:!0},{name:"showArrow",type:"boolean",optional:!0,description:"Show a chevron icon on the right (default false). Inherits from parent Accordion when unset."}],render:(t,e,r)=>{const a=e.showArrow!==void 0&&e.showArrow!==null,n=l("details",{class:"rui-accordion-item","data-show-arrow":a?A(e.showArrow)?"true":"false":null});A(e.open)&&n.setAttribute("open","");const i=l("summary",{class:"rui-accordion-trigger"});i.append(l("span",{class:"rui-accordion-title"},[f(e.title)])),i.append(l("span",{class:"rui-accordion-chevron","aria-hidden":"true"})),n.append(i);const o=l("div",{class:"rui-accordion-body"});for(const s of $(e.children))o.append(r.renderNode(s));return n.append(o),n}},Qs={name:"Accordion",description:"Accordion container. Children must be AccordionItem components. Set `showArrow: true` to add a chevron indicator to every item; individual `AccordionItem`s can override via their own `showArrow` prop.",props:[{name:"items",type:"AccordionItem[]"},{name:"showArrow",type:"boolean",optional:!0,description:"Show chevron icon on every item (default false)."}],render:(t,e,r)=>{const a=l("div",{class:"rui-accordion","data-show-arrow":A(e.showArrow)?"true":"false"});for(const n of $(e.items))a.append(r.renderNode(n));return a}},It=t=>Math.max(1,Math.min(lt,Math.round(t)));function wr(t){if(t==null||t==="")return 12;const e=String(t).trim();if(e.includes("/")){const[r,a]=e.split("/"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return It(Math.round(lt*n/i))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:It(E(t,12))}function el(t){const e=f(t.minChildWidth)||f(t.minItemWidth);return re(e||"220px","220px")}const tl={name:"GridItem",description:'Wraps a child in a 12-column grid cell with `span`, `offset`, and responsive `spanAt` maps. Parent `Grid` auto-enables 12-column mode when any child is a `GridItem`. Fraction spans like `"1/3"` resolve against the 12-column track.',props:[{name:"child",type:"Node",description:"Child node to place in the grid"},{name:"span",type:"number | string",optional:!0,description:'Columns to span (1–12) or fraction like "1/2", "1/3"'},{name:"offset",type:"number",optional:!0,description:"Empty columns before this item (0–11)"},{name:"spanAt",type:"object",optional:!0,description:"Responsive span map `{sm: 12, md: 6, lg: 4}`"}],render:(t,e,r)=>{const a=wr(e.span??12),n=be(e.spanAt),i=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(lt-1,Math.round(E(e.offset,0)))),o={class:"rui-grid-item","data-span":String(a)},s=[`--rui-grid-item-span:${a}`];if(i>0&&(o["data-offset"]=String(i),s.push(`--rui-grid-item-offset:${i}`)),n.kind==="responsive"){o["data-responsive-span"]="true";for(const u of et){const p=n.values[u];if(p!==void 0){const d=wr(p);s.push(`--rui-grid-item-span-${u}:${d}`)}}}else if(n.kind==="single"&&n.value!=null){const u=wr(n.value);s.push(`--rui-grid-item-span:${u}`),o["data-span"]=String(u)}o.style=s.join(";");const c=l("div",o);return c.append(r.renderNode(e.child)),c}},rl={name:"Box",description:"Spacing and surface wrapper for padding, margin, borders, semantic backgrounds, and max-width constraints. Use when a `Card` is too heavy but the content needs a subtle surface or inset.",props:[{name:"children",type:"Node[]"},{name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding. May be a responsive map."},{name:"margin",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Outer margin. May be a responsive map."},{name:"border",type:"string",optional:!0,enum:["none","subtle","default"],description:"Border preset (default none)"},{name:"background",type:"string",optional:!0,enum:["none","surface","muted","primary","success","warning","danger","info"],description:"Semantic background token"},{name:"maxWidth",type:"string",optional:!0,description:"CSS max-width"}],render:(t,e,r)=>{const a=be(e.padding),n=be(e.margin),i={class:"rui-box","data-border":f(e.border,"none"),"data-background":f(e.background,"none")},o=[],s=f(e.maxWidth);if(s&&o.push(`max-width:${re(s,s)}`),a.kind==="single"){const u=a.value?String(a.value):null;u&&(i["data-padding"]=u)}else i["data-padding"]="responsive",i["data-responsive-padding"]="true",Ue(o,a,"--rui-box-padding");if(n.kind==="single"){const u=n.value?String(n.value):null;u&&(i["data-margin"]=u)}else i["data-margin"]="responsive",i["data-responsive-margin"]="true",Ue(o,n,"--rui-box-margin");o.length>0&&(i.style=o.join(";"));const c=l("div",i);for(const u of $(e.children))c.append(r.renderNode(u));return c}},on={name:"Grid",description:'Two-dimensional grid with three modes:\n 1. AUTO-FIT (default, no `columns`): wraps as many equal columns as fit, each at least `minChildWidth` wide (default 220px) — perfect for card/KPI grids that should reflow on their own.\n 2. FIXED (`columns: N`, 1–12): exactly N equal columns.\n 3. SPAN (`columns: 12` or any `GridItem` children): a 12-track grid where each `GridItem` sets its own `span` (a number 1–12 or a fraction like `"1/3"`) for dashboards and asymmetric layouts.\n`columns` and `gap` accept responsive maps like `{base: 1, md: 2, lg: 4}`.',props:[{name:"children",type:"Node[]"},{name:"columns",type:"number | object",optional:!0,description:"Fixed column count 1–12. Omit for auto-fit; `12` (or `GridItem` children) enables the 12-track span system. May be a responsive map like `{base: 1, md: 3}`."},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Gap on both axes (default `m`). May be a responsive map."},{name:"rowGap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Row gap override. May be a responsive map."},{name:"columnGap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Column gap override. May be a responsive map."},{name:"minChildWidth",type:"string",optional:!0,aliases:["minItemWidth"],description:'Minimum column width for AUTO-FIT mode, e.g. `"240px"` (default 220px). Also caps the floor in FIXED mode.'},{name:"alignItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Vertical alignment of items within their cells"},{name:"justifyItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Horizontal alignment of items within their cells"},{name:"dense",type:"boolean",optional:!0,description:"Dense auto-flow packing — let later items backfill earlier gaps"}],render:(t,e,r)=>{const a=$(e.children),n=a.some(v=>Ds(v,"GridItem")),i=be(e.columns),o=be(e.gap),s=be(e.rowGap),c=be(e.columnGap),u={class:"rui-grid"},p=[];let d=!1,m=!1;if(i.kind==="single"){const v=i.value===null?0:E(i.value,0),y=v>0?It(v):0;if(y===lt?d=!0:y>0&&(m=!0),y>0){u["data-columns"]=String(y);const x=f(e.minChildWidth)||f(e.minItemWidth);x&&(u["data-min-child-width"]="true",p.push(`--rui-grid-min-child:${re(x,"220px")}`))}else p.push(`--rui-grid-min-item:${el(e)}`)}else{u["data-responsive-cols"]="true";for(const v of et){const y=i.values[v];if(y===void 0)continue;const x=It(E(y,0));x===lt?d=!0:x>0&&(m=!0),p.push(`--rui-grid-cols-${v}:${x}`)}}n&&!m&&(d=!0),d&&(u["data-grid-mode"]="12"),o.kind==="single"?u["data-gap"]=o.value?String(o.value):"m":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",Ue(p,o,"--rui-grid-gap")),s.kind==="single"&&s.value?u["data-row-gap"]=String(s.value):s.kind==="responsive"&&(u["data-row-gap"]="responsive",u["data-responsive-row-gap"]="true",Ue(p,s,"--rui-grid-row-gap")),c.kind==="single"&&c.value?u["data-column-gap"]=String(c.value):c.kind==="responsive"&&(u["data-column-gap"]="responsive",u["data-responsive-column-gap"]="true",Ue(p,c,"--rui-grid-column-gap"));const g=f(e.alignItems);g&&(u["data-align-items"]=g);const b=f(e.justifyItems);b&&(u["data-justify-items"]=b),A(e.dense)&&(u["data-dense"]="true"),p.length>0&&(u.style=p.join(";"));const h=l("div",u);for(const v of a)h.append(r.renderNode(v));return h}},al={name:"AspectRatio",description:"Container that constrains its child to a fixed aspect ratio (e.g. 16:9 for video embeds, 1:1 for thumbnails). The child fills the box.",props:[{name:"ratio",type:"string",description:"`width:height` (e.g. `16:9`, `4:3`) or a decimal like `1.78`"},{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=nl(f(e.ratio,"16:9")),n=l("div",{class:"rui-aspect-ratio",style:`aspect-ratio:${a};`});for(const i of $(e.children))n.append(r.renderNode(i));return n}};function nl(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i!==0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const il={name:"ScrollArea",description:"Bounded scroll container. Use to clip long lists / logs / chat panels to a fixed max height with a clean scrollbar.",props:[{name:"children",type:"Node[]"},{name:"maxHeight",type:"string",optional:!0,aliases:["height"],description:"CSS height (default 320px)"},{name:"direction",type:"string",optional:!0,enum:["vertical","horizontal","both"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-scroll-area","data-direction":f(e.direction,"vertical"),style:`max-height:${re(e.maxHeight,"320px")};`});for(const n of $(e.children))a.append(r.renderNode(n));return a}},ol=["sm","md","lg","xl","full"],sn='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';let sl=0;function ln(t){return t.getRootNode().activeElement??null}const ll={name:"Modal",description:"Dialog overlay shown when `open` is true. Pass a `$variable` as `open` to control it. The header always renders a × close button (disable via `closable: false`); the optional `footer` slot is the canonical place for action buttons. `closeOnBackdrop=true` opts in to backdrop-click dismissal. `onClose` fires every time the modal closes (× button, backdrop, programmatic state write). Accessible by default: the dialog is labelled by its title, focus moves into it on open and is restored on close, Tab is trapped inside, and Escape closes it (unless `closable: false`).",props:[{name:"title",type:"string"},{name:"open",type:"boolean",description:"Open/closed state — usually a $variable"},{name:"children",type:"Node[]"},{name:"size",type:"string",optional:!0,enum:ol,description:"Width preset (default `md`)"},{name:"footer",type:"Node[]",optional:!0,description:"Footer slot — typically a row of action Buttons"},{name:"closable",type:"boolean",optional:!0,description:"Render the header × button (default true)"},{name:"closeOnBackdrop",type:"boolean",optional:!0,description:"Close when the overlay is clicked (default false)"},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"],description:"Callable invoked when the modal is closed (× button or backdrop)"}],render:(t,e,r)=>{const a=f(e.size,"md"),n=e.closable===void 0?!0:A(e.closable),i=l("div",{class:"rui-modal-overlay","data-open":A(e.open)?"true":"false"}),o=r.useInstanceState("rui-modal-title-id","");o.get()||o.set(`rui-modal-title-${sl+=1}`);const s=o.get(),c=l("div",{class:"rui-modal",role:"dialog","aria-modal":"true","aria-labelledby":s,tabindex:"-1","data-size":a}),u=l("header",{class:"rui-modal-header"});u.append(l("h3",{class:"rui-modal-title",id:s},[f(e.title)]));const p=t.argMeta?.[1]?.stateRef,d=()=>{p&&r.setState(p,!1),r.invoke(e.onClose)};if(n){const y=l("button",{type:"button",class:"rui-modal-close","aria-label":"Close dialog"},["×"]);y.onclick=x=>{x.stopPropagation(),d()},u.append(y)}c.append(u);const m=l("div",{class:"rui-modal-body"});for(const y of $(e.children))m.append(r.renderNode(y));c.append(m);const g=$(e.footer);if(g.length>0){const y=l("footer",{class:"rui-modal-footer"});for(const x of g)y.append(r.renderNode(x));c.append(y)}i.append(c),A(e.closeOnBackdrop)&&(i.onclick=y=>{y.target===i&&d()});const b=A(e.open);c.addEventListener("keydown",y=>{if(y.key==="Escape"&&n){y.stopPropagation(),d();return}if(y.key!=="Tab")return;const x=[...c.querySelectorAll(sn)];if(x.length===0){y.preventDefault(),c.focus();return}const w=x[0],k=x[x.length-1],T=ln(c);y.shiftKey&&T===w?(y.preventDefault(),k.focus()):!y.shiftKey&&T===k&&(y.preventDefault(),w.focus())});const h=r.useInstanceState("rui-modal-focus",{open:!1,prev:null}),v=h.get();if(b&&!v.open){const y=ln(c);h.set({open:!0,prev:y});const x=()=>{([...c.querySelectorAll(sn)][0]??c).focus()};typeof queueMicrotask=="function"?queueMicrotask(x):Promise.resolve().then(x)}else if(!b&&v.open){const y=v.prev;if(h.set({open:!1,prev:null}),y&&typeof y.focus=="function"){const x=()=>y.focus();typeof queueMicrotask=="function"?queueMicrotask(x):Promise.resolve().then(x)}}return i}},cl=["solid","regular","brands"],Et=["xs","sm","md","lg","xl"],ul=["default","neutral","primary","success","warning","danger","info"];function kr(t,e="md"){const r=f(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":Et.includes(r)?r:e:e}const dl={name:"Icon",description:'Single Font Awesome icon. `name` is the FA name without the `fa-` prefix (e.g. `"house"`, `"chart-line"`). Use `variant` for non-solid styles (`regular`/`brands`) or prefix the name (`"regular:star"`). `color` accepts any CSS colour (`"#00ff00"`, `"tomato"`, `"var(--rui-color-primary)"`).',props:[{name:"name",type:"string",description:"FA name without the fa- prefix"},{name:"variant",type:"string",optional:!0,enum:cl},{name:"size",type:"string",optional:!0,enum:ks},{name:"color",type:"string",optional:!0,description:"CSS colour applied to the glyph (hex, named, rgb()/hsl(), or var(--token))"}],render:(t,e)=>{const r=f(e.name),a=f(e.variant,""),n=f(e.size,"md"),i=f(e.color,""),o=a?`${a}:${r}`:r,s=j(o,{size:n,color:i});return s||l("span",{class:"rui-icon","data-icon-size":n},[r])}},pl=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function ml(t){const e=f(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const cn=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:pl},{name:"tone",type:"string",optional:!0,enum:["default","muted","primary","success","warning","danger"],description:"Visual accent"},{name:"style",type:"string",optional:!0,description:'Inline CSS declarations applied to the rendered element (e.g. "font-size: 16px; font-weight: bold; color: #000;").'}],un=(t,e)=>{const r=f(e.variant,"body"),a=f(e.tone,"default"),n=ml(e.style);return l("span",{class:"rui-text","data-variant":r,"data-color":a,style:n||null},[f(e.value)])},fl={name:"Text",description:'Renders plain text with a typographic variant. Optional `style` prop accepts a CSS declaration string (e.g. "font-size: 16px; color: #000;") applied directly to the rendered element.',props:cn,render:un},gl={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:cn,render:un},hl={name:"Image",description:"Inline image. `ratio` constrains the box to a fixed aspect ratio (e.g. `16:9`, `1:1`) so callers do not need an outer `AspectRatio`. `fit` controls how the image fills that box. When `src` is missing or unsafe the component renders a placeholder (or `fallback` text/icon).",props:[{name:"src",type:"string"},{name:"alt",type:"string",optional:!0},{name:"caption",type:"string",optional:!0},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio shorthand (e.g. `16:9`, `1:1`, `4:3`)"},{name:"fit",type:"string",optional:!0,enum:["cover","contain","fill","none","scale-down"],description:"object-fit value (default `cover`)"},{name:"fallback",type:"string",optional:!0,description:"Text label or Font Awesome icon shown when src is missing/unsafe"}],render:(t,e)=>{const r=l("figure",{class:"rui-image","data-fit":f(e.fit,"cover"),style:e.ratio?`aspect-ratio:${bl(f(e.ratio))};`:null}),a=ie(e.src);if(a)r.append(l("img",{src:a,alt:f(e.alt),loading:"lazy"}));else{const i=l("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),o=f(e.fallback);if(o){const s=j(o,{className:"rui-image-fallback-icon"});s?i.append(s):i.append(l("span",{class:"rui-image-fallback-text"},[o]))}r.append(i)}const n=f(e.caption);return n&&r.append(l("figcaption",{class:"rui-image-caption"},[n])),r}};function bl(t){if(!t)return"auto";if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"auto"}const dn=["neutral","primary","success","warning","danger","info"],vl={name:"Badge",description:"Small pill-style tag for status, counts, categories. Accepts an optional leading `icon` and a `size`.",props:[{name:"label",type:"string",positional:!0},{name:"tone",type:"string",optional:!0,enum:dn,aliases:["variant"],description:"Visual tone"},{name:"icon",type:"string",optional:!0,description:'Optional Font Awesome icon name (e.g. "star")'},{name:"size",type:"string",optional:!0,enum:Et}],render:(t,e)=>{const r=f(e.tone,"neutral"),a=kr(e.size,"md"),n=l("span",{class:"rui-badge","data-variant":r,"data-size":a}),i=j(e.icon,{className:"rui-badge-icon"});i&&n.append(i);const o=f(e.label);return o&&n.append(l("span",{class:"rui-badge-label"},[o])),n}},yl={name:"BadgeList",description:"Cluster of Badge pills rendered from an array of strings.",props:[{name:"labels",type:"string[]",positional:!0,description:"Array of badge labels"},{name:"tone",type:"string",optional:!0,enum:dn,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:Et}],render:(t,e)=>{const r=f(e.tone,"neutral"),a=kr(e.size,"md"),n=l("div",{class:"rui-badge-list"});for(const i of $(e.labels)){const o=f(i);if(!o)continue;const s=l("span",{class:"rui-badge","data-variant":r,"data-size":a});s.append(l("span",{class:"rui-badge-label"},[o])),n.append(s)}return n}},xl={name:"Callout",description:"Highlighted callout banner with variant, title, description, and leading icon. Pass `compact: true` for a one-line inline-note rendering.",props:[{name:"tone",type:"string",optional:!0,enum:["neutral","info","success","warning","danger","error"],aliases:["variant"]},{name:"title",type:"string",positional:!0,required:!0},{name:"description",type:"string",optional:!0,aliases:["text"],description:"Body text"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"},{name:"compact",type:"boolean",optional:!0,description:"Render with the dense, one-line note shape."}],render:(t,e)=>{const r=f(e.tone,"info"),a=A(e.compact),n=l("div",{class:"rui-callout","data-variant":r,"data-compact":a?"true":"false"}),i=f(e.icon)||Sl(r),o=j(i,{className:"rui-callout-icon"});o&&n.append(o);const s=l("div",{class:"rui-callout-body"});s.append(l("div",{class:"rui-callout-title"},[f(e.title)]));const c=f(e.description);return c&&s.append(l("div",{class:"rui-callout-description"},[c])),n.append(s),n}},wl={name:"CodeBlock",description:'Read-only code block with a language label and a copy-to-clipboard button. Pass `showLineNumbers=true` to render a gutter; `highlightLines` accepts a string like `"3-5,8"` to emphasise specific lines.',props:[{name:"language",type:"string",optional:!0,description:"Display label (e.g. ts, bash)"},{name:"codeString",type:"string",positional:!0,required:!0,aliases:["code"],description:"Raw source text"},{name:"showLineNumbers",type:"boolean",optional:!0,description:"Render a left-side line-number gutter"},{name:"highlightLines",type:"string",optional:!0,aliases:["highlight"],description:'Highlight ranges, e.g. "3-5,8"'},{name:"copy",type:"boolean",optional:!0,description:"Show the copy-to-clipboard button (default true)"}],render:(t,e)=>{const r=f(e.language),a=f(e.codeString),n=A(e.showLineNumbers),i=kl(f(e.highlightLines)),o=e.copy===void 0?!0:A(e.copy),s=l("div",{class:"rui-code-block"});if(r||o){const u=l("div",{class:"rui-code-block-head"});if(r&&u.append(l("span",{class:"rui-code-block-language"},[r])),o){const p=l("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),d=j("copy",{className:"rui-code-block-copy-icon"});d&&p.append(d),p.append(l("span",{class:"rui-code-block-copy-label"},["Copy"])),p.onclick=m=>{const g=m.currentTarget??m.target,h=g.closest(".rui-code-block")?.querySelector("code")?.textContent??a,y=(typeof navigator<"u"?navigator:null)?.clipboard;y?.writeText&&y.writeText(h).catch(()=>{});const x=g.querySelector(".rui-code-block-copy-label");if(x){const w=x.textContent??"Copy";x.textContent="Copied",setTimeout(()=>{x.textContent=w},1500)}},u.append(p)}s.append(u)}const c=l("pre",{class:"rui-code-block-pre","data-line-numbers":n?"true":"false"});if(n||i.size>0){const u=a.split(/\r?\n/),p=l("code",{});u.forEach((d,m)=>{const g=m+1,b=l("span",{class:"rui-code-block-line","data-line":String(g),"data-highlight":i.has(g)?"true":null});n&&b.append(l("span",{class:"rui-code-block-gutter"},[String(g)])),b.append(l("span",{class:"rui-code-block-code"},[d])),p.append(b)}),c.append(p)}else c.append(l("code",{},[a]));return s.append(c),s}};function kl(t){const e=new Set;if(!t)return e;for(const r of t.split(",")){const a=r.trim();if(a)if(a.includes("-")){const n=a.split("-").map(s=>Number(s.trim())),i=n[0]??NaN,o=n[1]??NaN;if(Number.isFinite(i)&&Number.isFinite(o)&&i<=o)for(let s=i;s<=o;s+=1)e.add(s)}else{const n=Number(a);Number.isFinite(n)&&e.add(n)}}return e}function Sl(t){switch(t){case"success":return"circle-check";case"warning":return"triangle-exclamation";case"danger":case"error":return"circle-xmark";case"info":return"circle-info";default:return"circle-info"}}const $l={name:"Skeleton",description:"Loading placeholder. Pass a `variant` for common shapes — `paragraph` (default), `card`, `table-row`, `avatar`, `image` — or use `shape` / `width` / `height` to build a custom one. All variants use a shimmer animation that respects `prefers-reduced-motion`.",props:[{name:"variant",type:"string",optional:!0,enum:["paragraph","card","table-row","avatar","image"]},{name:"lines",type:"number",optional:!0,aliases:["count"],description:"Lines for the `paragraph` variant (default 3)"},{name:"height",type:"number | string",optional:!0,description:"Line height in px (paragraph) or CSS height for custom shape"},{name:"shape",type:"string",optional:!0,enum:["rect","circle"],description:"Force a primitive shape (rect/circle)"},{name:"width",type:"string",optional:!0,description:"CSS width for shape-only skeletons"}],render:(t,e)=>{const r=f(e.variant),a=f(e.shape);if(a)return Cl(a,e);if(r&&r!=="paragraph")return Al(r,e);const n=Number(e.lines),i=Math.max(1,Math.min(50,Number.isFinite(n)?Math.floor(n):3)),o=Number(e.height),s=Number.isFinite(o)&&o>0?Math.min(200,Math.floor(o)):12,c=l("div",{class:"rui-skeleton","data-variant":"paragraph"});for(let u=0;u<i;u+=1)c.append(l("div",{class:"rui-skeleton-line",style:`height:${s}px`}));return c}};function Cl(t,e){const r=re(f(e.width),"100%"),a=f(e.height),n=a?re(a,"16px"):t==="circle"?r:"16px";return l("div",{class:"rui-skeleton","data-variant":"shape","data-shape":t==="circle"?"circle":"rect",style:`width:${r};height:${n};`})}function Al(t,e){const r=l("div",{class:"rui-skeleton","data-variant":t});switch(t){case"avatar":{const a=re(f(e.width),"40px");return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"circle",style:`width:${a};height:${a};`})),r}case"image":{const a=re(f(e.width),"100%"),n=re(f(e.height),"160px");return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"rect",style:`width:${a};height:${n};`})),r}case"card":return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"rect",style:"width:100%;height:120px;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:14px;width:70%;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:12px;width:90%;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:12px;width:60%;"})),r;case"table-row":{const a=Math.max(1,Math.min(8,Math.floor(Number(e.lines??4)))),n=l("div",{class:"rui-skeleton-row"});for(let i=0;i<a;i+=1)n.append(l("div",{class:"rui-skeleton-line",style:"height:12px;flex:1;"}));return r.append(n),r}default:return r}}const Tl={name:"Markdown",description:"Render markdown-flavoured text. Supports **bold**, *italic*, `code`, headings (`#`/`##`/`###`), blockquotes (`>`), bullet (`-`/`*`) and numbered (`1.`) lists, fenced code blocks (```), images (``), inline links, and auto-linked bare URLs. Multi-line paragraphs collapse into `<p>` blocks.",props:[{name:"content",type:"string"}],render:(t,e)=>{const r=f(e.content),a=El(r);return l("div",{class:"rui-markdown",html:a})}},Ml={name:"Container",description:"Centered, max-width content wrapper. Use when a page is wider than comfortable reading width — landing pages, marketing sections, long documents. Picks a sensible default max-width per size; pass `maxWidth` to override with any CSS value.",props:[{name:"children",type:"Node[]"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg","xl","full"],description:"sm=640 / md=820 / lg=1040 / xl=1280 / full=100% (default lg)"},{name:"maxWidth",type:"string",optional:!0,description:"Custom CSS max-width (overrides `size`)"},{name:"padding",type:"string",optional:!0,enum:["none","s","m","l"],description:"Horizontal padding (default m)"}],render:(t,e,r)=>{const a=l("div",{class:"rui-container","data-size":f(e.size,"lg"),"data-padding":f(e.padding,"m"),style:e.maxWidth?`max-width:${re(e.maxWidth,"auto")};`:null});for(const n of $(e.children))a.append(r.renderNode(n));return a}},Nl={name:"Spacer",description:'Explicit space element for fine layout control. By default acts as a flex spacer that pushes following content to the far edge (use inside `Stack(direction="row")`). Pass `size` to render a fixed vertical/horizontal gap instead.',props:[{name:"size",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Fixed gap; omit to flex-grow"},{name:"flex",type:"boolean",optional:!0,description:"Flex-grow even when size is set (default true when size omitted)"}],render:(t,e)=>{const r=f(e.size),a=e.flex===void 0?!r:A(e.flex);return l("span",{class:"rui-spacer","data-size":r||null,"data-flex":a?"true":"false","aria-hidden":"true"})}},Pl={name:"Spinner",description:"Indeterminate inline loader. Use for tiny loading states inside buttons, toolbars, table cells, or chat bubbles where `Skeleton` and `Progress(indeterminate=true)` are too heavy. Pass `label` to render an inline caption beside the spinner (also announced via `aria-label`).",props:[{name:"size",type:"string",optional:!0,enum:Et,description:"Default `md`"},{name:"label",type:"string",optional:!0,description:"Caption rendered beside the spinner (also announced)"},{name:"tone",type:"string",optional:!0,enum:ul,description:"Visual accent (default `primary`)"}],render:(t,e)=>{const r=kr(e.size,"md"),a=f(e.tone,"primary"),n=f(e.label),i=l("span",{class:"rui-spinner","data-size":r,"data-tone":a,role:"status","aria-live":"polite","aria-label":n||"Loading"});return i.append(l("span",{class:"rui-spinner-ring","aria-hidden":"true"})),n&&i.append(l("span",{class:"rui-spinner-label"},[n])),i}},Il={name:"Quote",description:"Inline pull-quote with optional citation. Lighter than `Testimonial` — use inside articles, blog posts, marketing sections, or anywhere you need to highlight a sentence without the full quote/author/role + rating shape.",props:[{name:"text",type:"string"},{name:"cite",type:"string",optional:!0,aliases:["attribution","author"],description:"Attribution text shown below the quote"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]}],render:(t,e)=>{const r=l("figure",{class:"rui-quote","data-tone":f(e.tone,"default")});r.append(l("blockquote",{class:"rui-quote-text"},[f(e.text)]));const a=f(e.cite);return a&&r.append(l("figcaption",{class:"rui-quote-cite"},[a])),r}};function El(t){const e=g=>g.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),r=t.split(/\r?\n/),a=[];let n=null,i=!1,o=!1,s="",c=[];const u=()=>{n&&(a.push(n==="ul"?"</ul>":"</ol>"),n=null)},p=()=>{i&&(a.push("</blockquote>"),i=!1)},d=()=>{const g=s?` data-language="${e(s)}"`:"";a.push(`<pre class="rui-markdown-code"${g}><code>${e(c.join(`
|
|
97
|
-
`))}</code></pre>`),c=[],s="",o=!1};for(const g of r){const b=/^```\s*(.*)$/.exec(g.trim());if(o){if(b){d();continue}c.push(g);continue}if(b){u(),p(),o=!0,s=b[1]??"";continue}const h=/^\s*(#{1,3})\s+(.+)$/.exec(g);if(h){u(),p();const w=h[1].length;a.push(`<h${w} class="rui-markdown-h${w}">${m(e(h[2]))}</h${w}>`);continue}const v=/^\s*>\s?(.*)$/.exec(g);if(v){u(),i||(a.push('<blockquote class="rui-markdown-quote">'),i=!0),a.push(`<p>${m(e(v[1]??""))}</p>`);continue}else i&&g.trim()!==""&&p();const y=/^\s*[-*]\s+(.*)$/.exec(g);if(y){p(),n!=="ul"&&(u(),a.push("<ul>"),n="ul"),a.push(`<li>${m(e(y[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(g);if(x){p(),n!=="ol"&&(u(),a.push("<ol>"),n="ol"),a.push(`<li>${m(e(x[1]??""))}</li>`);continue}if(g.trim()===""){u(),p();continue}u(),p(),a.push(`<p>${m(e(g))}</p>`)}return o&&d(),u(),p(),a.join("");function m(g){let b=g.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(h,v,y)=>{const x=ie(y);return x?`<img class="rui-markdown-image" src="${Lt(x)}" alt="${v}" loading="lazy">`:`<span class="rui-markdown-image-fallback">${v}</span>`}).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(h,v,y)=>`<a class="rui-link" href="${pn(y)}" target="_blank" rel="noopener noreferrer">${v}</a>`);return b=b.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,h=>`<a class="rui-link" href="${pn(h)}" target="_blank" rel="noopener noreferrer">${h}</a>`),b}}function pn(t){const e=t.trim();if(!e||e.startsWith("//"))return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("?"))return Lt(e);const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);if(!r)return Lt(e);const a=r[1].toLowerCase();return new Set(["http","https","mailto","tel"]).has(a)?Lt(e):"#"}function Lt(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function ct(t,e,r){const a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=ie(t);if(n){const i=l("img",{src:n,alt:e,loading:"lazy"});i.onerror=o=>{const s=o;(s.currentTarget??s.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[ut(e)]))},a.append(i)}else a.append(l("span",{class:"rui-avatar-fallback"},[ut(e)]));return a}function ut(t){const e=t.trim();return e?e.split(/\s+/).slice(0,2).map(a=>a.charAt(0).toUpperCase()).join("")||e.charAt(0).toUpperCase():"?"}const zt=new WeakMap;function rt(t){const{liveRoot:e,onDismiss:r}=t,a=zt.get(e);a&&a.dispose();const n=e.getRootNode();let i=!1;const o=d=>{const m=d.target;m&&e.contains(m)||(p.dispose(),r())},s=d=>{d.key==="Escape"&&(p.dispose(),r())},c=e.ownerDocument;let u=null;if(c&&typeof MutationObserver<"u"){u=new MutationObserver(()=>{e.isConnected||p.dispose()});const d=e.getRootNode();(d instanceof Element||d instanceof Document||d instanceof ShadowRoot)&&u.observe(d,{childList:!0,subtree:!0})}const p={dispose:()=>{i||(i=!0,n.removeEventListener("click",o,!0),n.removeEventListener("keydown",s,!0),u?.disconnect(),zt.delete(e))}};return setTimeout(()=>{i||(n.addEventListener("click",o,!0),n.addEventListener("keydown",s,!0))},0),zt.set(e,p),p}function Ne(t){if(!t)return;const e=zt.get(t);e&&e.dispose()}const Ll=[{match:/\b(revenue|sales|sale|income|payment|charges?|invoices?|billing)\b/i,icon:"sack-dollar"},{match:/\b(profit|earnings?|margin|roi)\b/i,icon:"chart-line"},{match:/\b(customers?|clients?|users?|members?|people|accounts?)\b/i,icon:"users"},{match:/\b(visitors?|sessions?|traffic|page-?views?|impressions?)\b/i,icon:"chart-line"},{match:/\b(orders?|carts?|purchases?|transactions?)\b/i,icon:"cart-shopping"},{match:/\b(products?|inventory|sku|stock|items?)\b/i,icon:"box"},{match:/\b(subscriptions?|plans?|tiers?|pricing)\b/i,icon:"credit-card"},{match:/\b(emails?|messages?|inbox|threads?|mail)\b/i,icon:"envelope"},{match:/\b(notifications?|alerts?|reminders?)\b/i,icon:"bell"},{match:/\b(growth|trend|increase|up)\b/i,icon:"arrow-trend-up"},{match:/\b(decline|drop|down|decrease|loss)\b/i,icon:"arrow-trend-down"},{match:/\b(reports?|analytics|insights?|dashboards?|metrics?|stats?|kpis?)\b/i,icon:"chart-pie"},{match:/\b(charts?|graphs?)\b/i,icon:"chart-column"},{match:/\b(tasks?|todos?|backlog|kanban|sprint)\b/i,icon:"list-check"},{match:/\b(projects?|workspaces?)\b/i,icon:"folder-open"},{match:/\b(files?|folders?|documents?|docs?|attachments?)\b/i,icon:"folder-open"},{match:/\b(images?|photos?|gallery|albums?)\b/i,icon:"image"},{match:/\b(videos?|clips?|recordings?)\b/i,icon:"video"},{match:/\b(audio|music|podcasts?|sounds?)\b/i,icon:"music"},{match:/\b(calendars?|schedule|events?|meetings?|appointments?)\b/i,icon:"calendar-days"},{match:/\b(comments?|replies|feedback|reviews?|ratings?)\b/i,icon:"comments"},{match:/\b(settings?|preferences?|config|configuration|options?)\b/i,icon:"gear"},{match:/\b(security|privacy|password|locks?|secure)\b/i,icon:"shield-halved"},{match:/\b(api|integrations?|webhooks?|connections?)\b/i,icon:"plug"},{match:/\b(database|storage|backups?|servers?)\b/i,icon:"database"},{match:/\b(speed|performance|latency|response\s?time)\b/i,icon:"gauge-high"},{match:/\b(uptime|availability|status|health)\b/i,icon:"heart-pulse"},{match:/\b(errors?|bugs?|failures?|exceptions?|incidents?)\b/i,icon:"circle-exclamation"},{match:/\b(success|complete|done|approved)\b/i,icon:"circle-check"},{match:/\b(warnings?|caution)\b/i,icon:"triangle-exclamation"},{match:/\b(search|results?|queries)\b/i,icon:"magnifying-glass"},{match:/\b(downloads?|exports?)\b/i,icon:"download"},{match:/\b(uploads?|imports?)\b/i,icon:"upload"},{match:/\b(time|hours?|duration|elapsed)\b/i,icon:"clock"},{match:/\b(locations?|maps?|addresses?|countries?|regions?)\b/i,icon:"location-dot"},{match:/\b(stars?|favourites?|favorites?|highlights?)\b/i,icon:"star"},{match:/\b(trophy|awards?|achievements?|badges?|gold)\b/i,icon:"trophy"},{match:/\b(targets?|goals?|objectives?|quotas?)\b/i,icon:"bullseye"},{match:/\b(teams?|departments?|orgs?|organisations?|organizations?)\b/i,icon:"people-group"},{match:/\b(tickets?|issues?|bugs?|requests?)\b/i,icon:"ticket"},{match:/\b(deploys?|builds?|releases?|versions?)\b/i,icon:"rocket"}];function mn(t){if(!t)return null;for(const e of Ll)if(e.match.test(t))return e.icon;return null}const zl={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function Rl(t){return t?zl[t.toLowerCase()]??null:null}function Dl(t,e="shapes"){const r=t.trim()||"anon";return`https://api.dicebear.com/9.x/${/^[a-z0-9-]+$/i.test(e)?e:"shapes"}/svg?seed=${encodeURIComponent(r)}`}function fn(t){return $(t).map(r=>{if(r&&typeof r=="object"){const n=r;if(n.__kind==="Component"&&Array.isArray(n.args)){const i=f(n.args[0]);return{value:i,label:f(n.args[1],i)}}if(n.value!==void 0||n.label!==void 0){const i=f(n.value);return{value:i,label:f(n.label,i)}}}const a=f(r);return{value:a,label:a}}).filter(r=>r.value!==""||r.label!=="")}function He(t,e){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const r=l("span",{class:"rui-wrapper-fragment"});for(const a of e)a!=null&&r.append(typeof a=="string"?document.createTextNode(a):t.renderNode(a));return r}return typeof e=="string"?document.createTextNode(e):t.renderNode(e)}function Rt(t,e){return l("span",{class:`rui-wrapper ${t}`,style:"display: contents;",...e??{}})}function jl(t){const e=f(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const Bl=/^[A-Za-z_][A-Za-z0-9_\-:/]*$/;function Ol(t){return(Array.isArray(t)?t.map(r=>f(r)):f(t).split(/\s+/)).map(r=>r.trim()).filter(r=>r.length>0&&r.length<=64&&Bl.test(r))}const _l={name:"OnClick",description:"Make any component clickable. Wraps the child in a transparent span and dispatches `onClick(event)` when the user clicks or taps anywhere inside it. Use to attach click behaviour to components that do not expose an `action` / `onClick` prop (cards, list rows, media tiles, custom layouts).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"],description:"Component (or array of components) to wrap"},{name:"onClick",type:"callable",required:!0,aliases:["action","onclick"],description:"Callable invoked on click / tap. Receives the native MouseEvent."},{name:"disabled",type:"boolean",optional:!0,description:"Skip firing the handler while truthy"},{name:"stopPropagation",type:"boolean",optional:!0,description:"Call event.stopPropagation() after invoking the handler (default false)"}],render:(t,e,r)=>{const a=Rt("rui-on-click",{role:"button",tabindex:"0"});a.append(He(r,e.child));const n=A(e.disabled),i=A(e.stopPropagation),o=s=>{n||(i&&s.stopPropagation(),r.invoke(e.onClick,s))};return a.addEventListener("click",o),a.addEventListener("keydown",s=>{const c=s;(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o(c))}),a}},Fl=[{prop:"enter",event:"mouseenter"},{prop:"leave",event:"mouseleave"},{prop:"hover",event:"mouseover"},{prop:"move",event:"mousemove"},{prop:"down",event:"mousedown"},{prop:"up",event:"mouseup"},{prop:"click",event:"click"},{prop:"doubleClick",event:"dblclick"},{prop:"contextMenu",event:"contextmenu"},{prop:"scroll",event:"scroll"},{prop:"wheel",event:"wheel"},{prop:"drag",event:"drag"},{prop:"drop",event:"drop"},{prop:"dragStart",event:"dragstart"},{prop:"dragEnd",event:"dragend"},{prop:"dragEnter",event:"dragenter"},{prop:"dragLeave",event:"dragleave"},{prop:"dragOver",event:"dragover"}],Ul={name:"OnMouse",description:"Attach any combination of mouse / pointer / drag listeners to a component. Pass only the props you need — unused events install no listener so the wrapper is essentially free. Each handler receives the native MouseEvent / DragEvent / WheelEvent. Use for hover tracking, custom drag-and-drop, context menus, scroll-aware UIs.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"],description:"Component to wrap"},{name:"enter",type:"callable",optional:!0,description:"Fired when the pointer enters the element (mouseenter)"},{name:"leave",type:"callable",optional:!0,description:"Fired when the pointer leaves the element (mouseleave)"},{name:"hover",type:"callable",optional:!0,description:"Fired on every mouseover inside the element"},{name:"move",type:"callable",optional:!0,description:"Fired on every mousemove inside the element"},{name:"down",type:"callable",optional:!0,description:"Fired on mousedown"},{name:"up",type:"callable",optional:!0,description:"Fired on mouseup"},{name:"click",type:"callable",optional:!0,description:"Fired on click / tap"},{name:"doubleClick",type:"callable",optional:!0,description:"Fired on double-click"},{name:"contextMenu",type:"callable",optional:!0,description:"Fired on right-click (contextmenu)"},{name:"scroll",type:"callable",optional:!0,description:"Fired when an inner element scrolls"},{name:"wheel",type:"callable",optional:!0,description:"Fired on mouse-wheel / trackpad scroll"},{name:"drag",type:"callable",optional:!0,description:"Fired while the element is being dragged"},{name:"drop",type:"callable",optional:!0,description:"Fired when something is dropped onto the element"},{name:"dragStart",type:"callable",optional:!0,description:"Fired when a drag begins"},{name:"dragEnd",type:"callable",optional:!0,description:"Fired when a drag ends"},{name:"dragEnter",type:"callable",optional:!0,description:"Fired when a drag enters the element"},{name:"dragLeave",type:"callable",optional:!0,description:"Fired when a drag leaves the element"},{name:"dragOver",type:"callable",optional:!0,description:"Fired while something is dragged over the element. Call `event.preventDefault()` to make the element a valid drop target."},{name:"draggable",type:"boolean",optional:!0,description:'Make the wrapper itself draggable (sets `draggable="true"`)'},{name:"passiveScroll",type:"boolean",optional:!0,description:"Register scroll/wheel listeners as passive (default true for better scroll performance)"}],render:(t,e,r)=>{const a=Rt("rui-on-mouse");A(e.draggable)&&a.setAttribute("draggable","true"),a.append(He(r,e.child));const n=e.passiveScroll===void 0?!0:A(e.passiveScroll);for(const{prop:i,event:o}of Fl){const s=e[i];if(s==null)continue;const u=o==="scroll"||o==="wheel"?{passive:n}:{};a.addEventListener(o,p=>{r.invoke(s,p)},u)}return a}},Hl=[{prop:"onKeyDown",event:"keydown"},{prop:"onKeyUp",event:"keyup"},{prop:"onKeyPress",event:"keypress"}],Vl={name:"OnKeyboard",description:'Attach keyboard listeners to a component. Pass any combination of `onKeyDown`, `onKeyUp`, and `onKeyPress`; each handler receives the native KeyboardEvent. Use for keyboard shortcuts, navigation, and custom focusable widgets. The wrapper is focusable by default (tabindex="0") so it can be reached via Tab; pass `focusable=false` to disable when the child is already focusable.',props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onKeyDown",type:"callable",optional:!0,aliases:["onkeydown"],description:"Fired on keydown"},{name:"onKeyUp",type:"callable",optional:!0,aliases:["onkeyup"],description:"Fired on keyup"},{name:"onKeyPress",type:"callable",optional:!0,aliases:["onkeypress"],description:"Fired on keypress"},{name:"focusable",type:"boolean",optional:!0,description:"Make the wrapper focusable via Tab (default true)"}],render:(t,e,r)=>{const a=e.focusable===void 0?!0:A(e.focusable),n=Rt("rui-on-keyboard",a?{tabindex:"0"}:{});n.append(He(r,e.child));for(const{prop:i,event:o}of Hl){const s=e[i];s!=null&&n.addEventListener(o,c=>{r.invoke(s,c)})}return n}},Wl={name:"OnFocus",description:"Attach focus / blur listeners to a component. Use to track input focus rings, custom focus indicators, or autosave-on-blur flows. Listens on the capture phase so blur from descendants is observed.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onFocus",type:"callable",optional:!0,aliases:["onfocus"],description:"Fired when focus enters the element or any descendant"},{name:"onBlur",type:"callable",optional:!0,aliases:["onblur"],description:"Fired when focus leaves the element and all descendants"}],render:(t,e,r)=>{const a=Rt("rui-on-focus");return a.append(He(r,e.child)),e.onFocus!=null&&a.addEventListener("focusin",n=>r.invoke(e.onFocus,n)),e.onBlur!=null&&a.addEventListener("focusout",n=>r.invoke(e.onBlur,n)),a}},ql={name:"OnIntersect",description:"Observe whether a component is visible in the viewport (or a scroll container) using IntersectionObserver. Fires `onEnter` the first time the wrapped element becomes visible, `onLeave` when it leaves, and `onChange({visible, ratio})` for every transition. Use for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onEnter",type:"callable",optional:!0,description:"Fired when the element enters the viewport"},{name:"onLeave",type:"callable",optional:!0,description:"Fired when the element leaves the viewport"},{name:"onChange",type:"callable",optional:!0,description:"Fired with `{visible, ratio}` on every transition"},{name:"threshold",type:"number",optional:!0,description:"Visible-ratio threshold 0–1 (default 0.05)"},{name:"rootMargin",type:"string",optional:!0,description:'CSS-length root margin (e.g. "0px 0px -64px 0px")'},{name:"once",type:"boolean",optional:!0,description:"Disconnect after the first entry (default false)"}],render:(t,e,r)=>{const a=l("span",{class:"rui-wrapper rui-on-intersect",style:"display: inline-block;"});a.append(He(r,e.child));const n=typeof IntersectionObserver<"u"?IntersectionObserver:void 0;if(!n)return a;const i=Math.max(0,Math.min(1,E(e.threshold,.05))),o=f(e.rootMargin),s=A(e.once);let c=null;const u=new n(p=>{for(const d of p){const m=d.isIntersecting;if(m!==c&&(m&&e.onEnter!=null&&r.invoke(e.onEnter,d),!m&&c===!0&&e.onLeave!=null&&r.invoke(e.onLeave,d),c=m),e.onChange!=null&&r.invoke(e.onChange,{visible:m,ratio:d.intersectionRatio}),s&&m){u.disconnect();return}}},{threshold:i,...o?{rootMargin:o}:{}});return u.observe(a),r.registerDisposer(()=>u.disconnect()),a}},Kl={name:"OnMount",description:"Run imperative code against the wrapped component's rendered DOM node. `onMount(node)` fires once, on a microtask after the child is attached to the DOM — the Aktion way to get a DOM ref (measure an element, focus it, or hand it to an imperative library such as a chart / map / editor). `onUnmount(node)` fires when the component leaves the tree. Pair with `$ref(...)` to stash the node across renders.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onMount",type:"callable",optional:!0,description:"`(node) => void` — fired once after the wrapped element is attached."},{name:"onUnmount",type:"callable",optional:!0,description:"`(node) => void` — fired when the wrapped element leaves the tree."}],render:(t,e,r)=>{const a=l("span",{class:"rui-wrapper rui-on-mount",style:"display: contents;"});a.append(He(r,e.child));const n=r.useInstanceState("rui-on-mount",!1);if(!n.get()){n.set(!0);const i=()=>{const o=a.firstElementChild??a;e.onMount!=null&&r.invoke(e.onMount,o),e.onUnmount!=null&&r.registerDisposer(()=>{const s=()=>r.invoke(e.onUnmount,o);typeof queueMicrotask=="function"?queueMicrotask(s):Promise.resolve().then(s)},"rui-on-mount-unmount")};typeof queueMicrotask=="function"?queueMicrotask(i):Promise.resolve().then(i)}return a}};function Gl(t,e){return e==null?[]:typeof e=="string"?[document.createTextNode(e)]:Array.isArray(e)?e.filter(r=>r!=null).map(r=>typeof r=="string"?document.createTextNode(r):t.renderNode(r)):[t.renderNode(e)]}const gn={name:"Link",description:'Anchor link. Accepts either a plain string label or a wrapped component as its positional child. Pass `to` for client-side router navigation (no page reload) or `href` for a regular anchor. `external: true` opens the link in a new tab with `rel="noopener noreferrer"`. Use to make any component clickable as a link — cards, icons, badges, list rows.',props:[{name:"label",type:"string | Node",positional:!0,required:!0,aliases:["child","children"],description:"Visible text OR a wrapped component"},{name:"to",type:"string",optional:!0,description:"Router path (preferred). Navigates via the runtime router on click."},{name:"href",type:"string",optional:!0,description:"Standard anchor href. Used when `to` is omitted."},{name:"external",type:"boolean",optional:!0,description:'Open in a new tab (`target="_blank"`, `rel="noopener noreferrer"`)'},{name:"variant",type:"string",optional:!0,enum:["default","subtle"]}],render:(t,e,r)=>{const a=f(e.to),n=A(e.external),i=a||f(e.href),o=a?i.startsWith("/")||i.startsWith("#")?i:tt(i,"#"):tt(e.href,"#"),s=f(e.variant,"default"),c=l("a",{class:"rui-link","data-variant":s,href:o,target:n?"_blank":null,rel:n?"noopener noreferrer":null});for(const u of Gl(r,e.label))c.append(u);return a&&!n&&c.addEventListener("click",u=>{u.defaultPrevented||u.button===0&&(u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||(u.preventDefault(),r.router.navigate(a)))}),c}},Yl={name:"Css",description:"Apply raw CSS class names and / or an inline style string to a wrapped component. The styling is merged onto the rendered child's DOM element — no extra wrapper element is added unless the child is plain text (in which case the styling lands on a wrapping span). Reach for `Css` only when the component's own props cannot express the styling (use `Box`/`Stack`/`Grid` props for layout, `Theme` for tokens, `Styles` + selector classes for sweeping changes).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"style",type:"string",optional:!0,description:'Inline CSS declarations (e.g. "padding: 16px; background: #eef;")'},{name:"class",type:"string | string[]",optional:!0,aliases:["className","classes"],description:"Class name (space-separated string or array). Tokens must match `[A-Za-z_][A-Za-z0-9_-:/]*`."}],render:(t,e,r)=>{const a=He(r,e.child),n=a instanceof HTMLElement?a:(()=>{const s=l("span",{class:"rui-css"});return s.append(a),s})(),i=Ol(e.class);for(const s of i)n.classList.add(s);const o=jl(e.style);if(o){const s=n.getAttribute("style");n.setAttribute("style",s?`${s};${o}`:o)}return n}};function oe(t,e,r,a){if(e==null)return;const n=a.event??"change";t.addEventListener(n,()=>{r.invoke(e,a.getValue(t))})}const Xl=["primary","secondary","ghost","danger"],Jl=["xs","sm","md","lg","xl"],Zl=["text","email","password","number","tel","url","date"];function Ql(t){const e=f(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="sm"?"sm":e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":"md"}const ec={name:"Button",description:"Clickable button. `onClick` (a callable) runs when the user presses the button. The legacy `action` prop is an alias and is still accepted.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable invoked when the button is clicked"},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:Xl},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:Jl,description:"Size token `xs|sm|md|lg|xl`"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"},{name:"iconPosition",type:"string",optional:!0,enum:["leading","trailing"],description:"Icon placement (default leading)"},{name:"iconOnly",type:"boolean",optional:!0,description:"Hide the label visually (keeps aria-label)"},{name:"loading",type:"boolean",optional:!0,description:"Show spinner and disable interaction"},{name:"fullWidth",type:"boolean",optional:!0},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=A(e.loading),n=A(e.iconOnly),i=f(e.iconPosition,"leading"),o=f(e.label),s=l("button",{class:"rui-button",type:f(e.type,"button"),"data-variant":f(e.variant,"primary"),"data-size":Ql(e.size),"data-icon-position":i,"data-icon-only":n?"true":null,"data-full-width":A(e.fullWidth)?"true":null,"data-loading":a?"true":null,"aria-label":n?o:null,disabled:A(e.disabled)||a?"":null}),c=l("span",{class:"rui-button-label"},[o]),u=j(e.icon,{className:"rui-button-icon"}),d=(a?j("spinner",{className:"rui-button-spinner"}):null)??u;return n?d&&s.append(d):i==="trailing"?(s.append(c),d&&s.append(d)):(d&&s.append(d),s.append(c)),s.onclick=()=>{a||r.invoke(e.onClick)},s}},tc={name:"Buttons",description:"Group of buttons laid out horizontally or vertically.",props:[{name:"items",type:"Button[]"},{name:"direction",type:"string",optional:!0,enum:["row","column"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-buttons","data-direction":f(e.direction,"row")});for(const n of $(e.items))a.append(r.renderNode(n));return a}},rc={name:"Input",description:"Text input field. Pass a $variable as `value` for two-way binding. `onChange(value)` fires on every keystroke with the current string.",props:[{name:"id",type:"string",description:"Input identifier"},{name:"placeholder",type:"string",optional:!0},{name:"type",type:"string",optional:!0,enum:Zl},{name:"validations",type:"any",optional:!0,description:"Array or object of validation hints"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=l("input",{class:"rui-input",id:f(e.id),name:f(e.id),type:f(e.type,"text"),placeholder:f(e.placeholder),value:f(e.value)});return Ve(a,t,4,r),oe(a,e.onChange,r,{event:"input",getValue:n=>n.value}),xc(a,e.validations),a}},ac={name:"TextArea",description:"Multi-line text input. `onChange(value)` fires on every keystroke with the current text.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0},{name:"value",type:"any",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=l("textarea",{class:"rui-textarea",id:f(e.id),name:f(e.id),placeholder:f(e.placeholder),rows:String(Number(e.rows??4)||4)});return a.value=f(e.value),Ve(a,t,3,r),oe(a,e.onChange,r,{event:"input",getValue:n=>n.value}),a}},nc={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>l("option",{value:f(e.value)},[f(e.label)])},ic={name:"Select",description:"Dropdown select. Pass a `$variable` as `value` for two-way binding. Set `searchable: true` for a combobox-style filter UI on long option lists. `onChange(value)` fires with the newly-selected value.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"label",type:"string",optional:!0},{name:"placeholder",type:"string",optional:!0},{name:"value",type:"any",optional:!0},{name:"searchable",type:"boolean",optional:!0,description:"Render as a filterable combobox"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{if(A(e.searchable))return yc(t,e,r);const a=l("select",{class:"rui-select",id:f(e.id),name:f(e.id)}),n=f(e.placeholder);n&&a.append(l("option",{value:"",disabled:"",selected:""},[n]));for(const i of $(e.items))a.append(r.renderNode(i));return a.value=f(e.value),Ve(a,t,4,r),oe(a,e.onChange,r,{event:"change",getValue:i=>i.value}),a}},oc={name:"Checkbox",description:"Boolean checkbox. `onChange(checked)` fires with the new boolean state.",props:[{name:"id",type:"string"},{name:"label",type:"string"},{name:"value",type:"boolean",optional:!0,aliases:["checked"]},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new boolean value"}],render:(t,e,r)=>{const a=l("label",{class:"rui-checkbox"}),n=A(e.value),i=l("input",{type:"checkbox",id:f(e.id),name:f(e.id),checked:n?"":null});return i.checked=n,Ve(i,t,2,r),oe(i,e.onChange,r,{event:"change",getValue:o=>o.checked}),a.append(i,l("span",{class:"rui-checkbox-label"},[f(e.label)])),a}},sc={name:"CheckBoxItem",description:"Single option inside a CheckBoxGroup.",props:[{name:"label",type:"string"},{name:"name",type:"string",description:"Key inside the group's value object"},{name:"description",type:"string",optional:!0},{name:"defaultChecked",type:"boolean",optional:!0,aliases:["checked"]}],render:(t,e)=>{const r=f(e.name),a=f(e.label),n=f(e.description),i=A(e.defaultChecked),o=l("label",{class:"rui-checkbox-item","data-name":r}),s=l("input",{type:"checkbox",name:r,checked:i?"":null});s.checked=i;const c=l("div",{class:"rui-checkbox-item-text"});return c.append(l("div",{class:"rui-checkbox-item-label"},[a])),n&&c.append(l("div",{class:"rui-checkbox-item-description"},[n])),o.append(s,c),o}},lc={name:"CheckBoxGroup",description:"Group of checkboxes. Value is an object keyed by item name. Pass a `$variable` for two-way binding. `onChange(value)` fires with the full updated object.",props:[{name:"name",type:"string",description:"Group identifier"},{name:"items",type:"CheckBoxItem[]"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated `{name: checked}` object when any item toggles"}],render:(t,e,r)=>{const a=f(e.name),n=l("div",{class:"rui-checkbox-group",role:"group","data-name":a}),i=$(e.items),o=e.value&&typeof e.value=="object"?e.value:{};i.forEach((u,p)=>{const d=f(u.args?.[0]),m=f(u.args?.[1],`${a}-${p}`),g=f(u.args?.[2]),b=A(u.args?.[3]),h=`${a}-${m}`,v=l("label",{class:"rui-checkbox-item",for:h}),y=m in o?!!o[m]:b,x=l("input",{type:"checkbox",id:h,name:m,checked:y?"":null}),w=l("div",{class:"rui-checkbox-item-text"});w.append(l("div",{class:"rui-checkbox-item-label"},[d])),g&&w.append(l("div",{class:"rui-checkbox-item-description"},[g])),v.append(x,w),n.append(v)});const s=t.argMeta?.[2]?.stateRef,c=u=>{const p={};return u.querySelectorAll('input[type="checkbox"]').forEach(d=>{p[d.name]=d.checked}),p};return s&&r.bindState(n,s,{event:"change",getValue:c}),oe(n,e.onChange,r,{event:"change",getValue:u=>c(u)}),n}},cc={name:"Radio",description:"Radio button group. `onChange(value)` fires with the newly-selected option value.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"value",type:"any",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected radio value"}],render:(t,e,r)=>{const a=f(e.id),n=l("div",{class:"rui-radio-group",role:"radiogroup"});for(const i of $(e.items)){const o=f(i.args?.[0]),s=f(i.args?.[1],o),c=`${a}-${o}`,u=l("label",{class:"rui-radio",for:c}),p=f(e.value)===o,d=l("input",{type:"radio",id:c,name:a,value:o,checked:p?"":null});d.checked=p,Ve(d,t,2,r),oe(d,e.onChange,r,{event:"change",getValue:m=>m.value}),u.append(d,l("span",{class:"rui-radio-label"},[s])),n.append(u)}return n}},uc={name:"FormControl",description:"Labeled wrapper around a single form field.",props:[{name:"label",type:"string"},{name:"field",type:"Node",aliases:["control"]},{name:"hint",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-form-control"});a.append(l("label",{class:"rui-form-label"},[f(e.label)]));const n=r.renderNode(e.field);a.append(n);const i=f(e.hint);return i&&a.append(l("p",{class:"rui-form-hint"},[i])),a}},hn={name:"SearchBar",description:"Pre-styled search input with a leading magnifying-glass icon, optional trailing submit button, and optional keyboard-shortcut hint. Pass a `$variable` as `value` for two-way binding. Use anywhere a user needs to filter content — toolbars, command bars, lists, headers.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"shortcut",type:"string",optional:!0,description:'Keyboard hint chip on the right (e.g. "/")'},{name:"onSubmit",type:"callable",optional:!0,aliases:["action","onClick"],description:"Optional submit callable; clicking the trailing button or pressing Enter invokes it"},{name:"submitLabel",type:"string",optional:!0,description:'Label for the trailing submit button (default "Search"). Omitted when no action is provided.'},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current query on every keystroke"}],render:(t,e,r)=>{const a=l("form",{class:"rui-search-bar",role:"search"});a.onsubmit=s=>{s.preventDefault(),r.invoke(e.onSubmit)};const n=j("magnifying-glass",{className:"rui-search-bar-icon"})??l("span",{class:"rui-search-bar-icon","aria-hidden":"true"});a.append(n);const i=l("input",{class:"rui-search-bar-input",id:f(e.id),name:f(e.id),type:"search",placeholder:f(e.placeholder,"Search…"),value:f(e.value),autocomplete:"off"});Ve(i,t,2,r),oe(i,e.onChange,r,{event:"input",getValue:s=>s.value}),a.append(i);const o=f(e.shortcut);if(o&&a.append(l("span",{class:"rui-search-bar-shortcut"},[o])),e.onSubmit!=null){const s=l("button",{type:"submit",class:"rui-search-bar-submit"},[f(e.submitLabel,"Search")]);a.append(s)}return a}},dc={name:"Form",description:'Form container. Children FormControls render in order; buttons render at the bottom. Provide `onSubmit` to handle form submission (invoked when the user presses Enter on a focused input or clicks a `type="submit"` Button inside the form).',props:[{name:"id",type:"string"},{name:"buttons",type:"Buttons | Button"},{name:"fields",type:"FormControl[]"},{name:"onSubmit",type:"callable",optional:!0,aliases:["onsubmit"],description:"Called when the form is submitted (Enter key or submit button)"}],render:(t,e,r)=>{const a=l("form",{class:"rui-form",id:f(e.id)});a.onsubmit=n=>{n.preventDefault(),r.invoke(e.onSubmit)};for(const n of $(e.fields))a.append(r.renderNode(n));if(e.buttons){const n=l("div",{class:"rui-form-actions"});n.append(r.renderNode(e.buttons)),a.append(n)}return a}},pc={name:"Slider",description:"Range slider for selecting a single numeric value between `min` and `max`. Pass a `$variable` as `value` for two-way binding. Useful for filters, settings (volume, brightness), and parameter tuning.",props:[{name:"id",type:"string"},{name:"min",type:"number",optional:!0,description:"Default 0"},{name:"max",type:"number",optional:!0,description:"Default 100"},{name:"step",type:"number",optional:!0,description:"Default 1"},{name:"value",type:"number",optional:!0,description:"Bound value (typically $variable)"},{name:"label",type:"string",optional:!0},{name:"showValue",type:"boolean",optional:!0,description:"Render the current numeric value beside the slider"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new number as the user drags"}],render:(t,e,r)=>{const a=f(e.id),n=E(e.min,0),i=E(e.max,100),o=E(e.step,1),s=E(e.value,n),c=l("div",{class:"rui-slider","data-disabled":A(e.disabled)?"true":"false"}),u=f(e.label),p=A(e.showValue);if(u||p){const g=l("div",{class:"rui-slider-head"});u&&g.append(l("label",{class:"rui-slider-label",for:a},[u])),p&&g.append(l("span",{class:"rui-slider-value"},[String(s)])),c.append(g)}const d=l("input",{type:"range",class:"rui-slider-input",id:a,name:a,min:String(n),max:String(i),step:String(o),value:String(s),disabled:A(e.disabled)?"":null});d.oninput=g=>{const b=g.currentTarget;if(!b)return;const v=b.closest(".rui-slider")?.querySelector(".rui-slider-value");v&&(v.textContent=b.value)};const m=t.argMeta?.[4]?.stateRef;return m&&r.bindState(d,m,{event:"input",getValue:g=>Number(g.value)}),oe(d,e.onChange,r,{event:"input",getValue:g=>Number(g.value)}),c.append(d),c}},mc={name:"NumberInput",description:'Numeric input with paired increment/decrement buttons. Use for quantity steppers, integer settings, and any field where a `<input type="number">` plus +/- controls is friendlier than the native spinner. Pass a `$variable` as `value` for two-way binding.',props:[{name:"id",type:"string"},{name:"value",type:"number",optional:!0,description:"Bound value (typically $variable)"},{name:"min",type:"number",optional:!0},{name:"max",type:"number",optional:!0},{name:"step",type:"number",optional:!0,description:"Default 1"},{name:"placeholder",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new number (or null when blank)"}],render:(t,e,r)=>{const a=f(e.id),n=E(e.step,1),i=e.min!==void 0&&e.min!==null,o=e.max!==void 0&&e.max!==null,s=i?E(e.min,0):Number.NEGATIVE_INFINITY,c=o?E(e.max,0):Number.POSITIVE_INFINITY,u=A(e.disabled),p=l("div",{class:"rui-number-input","data-disabled":u?"true":"false"}),d=l("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:u?"":null},["−"]),m=l("input",{type:"number",class:"rui-number-input-field",id:a,name:a,value:f(e.value),placeholder:f(e.placeholder),min:i?String(s):null,max:o?String(c):null,step:String(n),disabled:u?"":null}),g=l("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:u?"":null},["+"]),b=t.argMeta?.[1]?.stateRef,h=y=>{const x=y.value;if(x==="")return null;const w=Number(x);return Number.isFinite(w)?w:null};b&&r.bindState(m,b,{event:"input",getValue:h}),oe(m,e.onChange,r,{event:"input",getValue:h});const v=(y,x)=>{const k=y.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!k)return;const T=Number(k.value),S=Number.isFinite(T)?T:0,C=vc(S+x,s,c);k.value=String(C),k.dispatchEvent(new Event("input",{bubbles:!0}))};return d.onclick=y=>v(y.currentTarget??y.target,-n),g.onclick=y=>v(y.currentTarget??y.target,n),p.append(d,m,g),p}},fc={name:"DatePicker",description:'Date picker that wraps the native `<input type="date">` with consistent styling. Pass a `$variable` as `value` for two-way binding. Use `min`/`max` to bound the selectable range.',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"ISO date (YYYY-MM-DD); typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0,description:"Earliest ISO date"},{name:"max",type:"string",optional:!0,description:"Latest ISO date"},{name:"placeholder",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new ISO date string when the picker changes"}],render:(t,e,r)=>{const a=f(e.id),n=l("div",{class:"rui-date-picker"}),i=f(e.label);i&&n.append(l("label",{class:"rui-date-picker-label",for:a},[i]));const o=l("input",{type:"date",class:"rui-date-picker-input",id:a,name:a,value:f(e.value),min:f(e.min)||null,max:f(e.max)||null,placeholder:f(e.placeholder),disabled:A(e.disabled)?"":null});return Ve(o,t,1,r),oe(o,e.onChange,r,{event:"change",getValue:s=>s.value}),n.append(o),n}},gc={name:"FileUpload",description:'Styled file picker. Renders a click/drop area with a leading icon, label, and helper text. Files cannot round-trip through `$variables` (they are not serialisable), so pass a callable as `action` to handle the picked files via `ctx.query("#id").files`.',props:[{name:"id",type:"string"},{name:"label",type:"string",optional:!0,description:'Primary label (default "Choose a file")'},{name:"hint",type:"string",optional:!0,description:"Secondary helper text"},{name:"accept",type:"string",optional:!0,description:"Comma-separated MIME types or extensions"},{name:"multiple",type:"boolean",optional:!0},{name:"onSelect",type:"callable",optional:!0,aliases:["action","onChange"],description:"Callable fired with the FileList when files are picked"},{name:"icon",type:"string",optional:!0,description:'Font Awesome icon (default "cloud-arrow-up")'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=f(e.id),n=A(e.disabled),i=l("div",{class:"rui-file-upload","data-disabled":n?"true":"false"}),o=l("label",{class:"rui-file-upload-dropzone",for:a}),s=j(f(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});s&&o.append(s);const c=l("div",{class:"rui-file-upload-text"});c.append(l("div",{class:"rui-file-upload-label"},[f(e.label,"Choose a file")]));const u=f(e.hint);u&&c.append(l("div",{class:"rui-file-upload-hint"},[u])),o.append(c);const p=l("input",{type:"file",id:a,name:a,class:"rui-file-upload-input",accept:f(e.accept)||null,multiple:A(e.multiple)?"":null,disabled:n?"":null});o.append(p),i.append(o);const d=(m,g)=>g.includes("image")||m.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(m.name);return p.onchange=m=>{const g=m.currentTarget;r.invoke(e.onSelect,g.files);const b=g.closest(".rui-file-upload");if(!b)return;const h=g.files,v=b.querySelector(".rui-file-upload-preview");if(v&&v.remove(),!h||h.length===0)return;const y=f(e.accept),x=l("div",{class:"rui-file-upload-preview"});Array.from(h).forEach(w=>{const k=l("div",{class:"rui-file-upload-preview-item"});if(d(w,y)){const T=URL.createObjectURL(w),S=l("img",{src:T,alt:w.name,class:"rui-file-upload-thumbnail"});S.onload=()=>URL.revokeObjectURL(T),k.append(S)}k.append(l("span",{class:"rui-file-upload-filename"},[w.name])),x.append(k)}),b.append(x)},i}},bn={name:"Combobox",description:"Searchable single-select dropdown — type to filter, click an option to choose. Use instead of `Select` when the list is long enough that scanning is faster than scrolling (countries, currencies, repos, users). Pass a `$variable` as `value` for two-way binding; the selected option's `value` is written to state on pick.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]",description:"Options; SelectItem(value, label) or {value, label}"},{name:"value",type:"string",optional:!0,description:"Bound selected value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"emptyLabel",type:"string",optional:!0,description:'Text shown when no items match the filter (default "No matches")'},{name:"disabled",type:"boolean",optional:!0},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the dropdown"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{const a=f(e.id),n=fn(e.items),i=f(e.value),o=n.find(S=>S.value===i)?.label??i,s=f(e.placeholder,"Select…"),c=f(e.emptyLabel,"No matches"),u=A(e.disabled),p=A(e.open),d=r.useInstanceState("open",p),m=r.useInstanceState("filter",""),g=d.get(),b=l("div",{class:"rui-combobox","data-open":g?"true":"false","data-disabled":u?"true":"false"}),h=l("button",{type:"button",class:"rui-combobox-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":g?"true":"false",disabled:u?"":null});h.append(l("span",{class:"rui-combobox-value","data-placeholder":o?"false":"true"},[o||s]));const v=j("chevron-down",{className:"rui-combobox-chevron"});v&&h.append(v),b.append(h);const y=l("div",{class:"rui-combobox-panel",role:"listbox"}),x=l("input",{type:"text",class:"rui-combobox-filter",placeholder:"Filter…",autocomplete:"off",value:m.get()});y.append(x);const w=l("div",{class:"rui-combobox-list"});y.append(w);const k=(S,C)=>{S.replaceChildren();const N=C.trim().toLowerCase(),I=N===""?n:n.filter(L=>L.label.toLowerCase().includes(N)||L.value.toLowerCase().includes(N));if(I.length===0){S.append(l("div",{class:"rui-combobox-empty"},[c]));return}for(const L of I){const R=l("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":L.value,"aria-selected":L.value===i?"true":"false"},[L.label]);R.onclick=q=>{q.stopPropagation(),T(q.currentTarget,L.value)},S.append(R)}},T=(S,C)=>{const N=t.argMeta?.[2]?.stateRef;N&&r.setState(N,C),r.invoke(e.onChange,C),d.set(!1),m.set("");const I=S.closest(".rui-combobox");I?.setAttribute("data-open","false"),I?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false"),Ne(I)};return k(w,m.get()),x.oninput=S=>{const C=S.currentTarget;m.set(C.value);const N=C.closest(".rui-combobox-panel")?.querySelector(".rui-combobox-list");N&&k(N,C.value)},x.onkeydown=S=>{const C=S;if(C.key!=="Enter")return;C.preventDefault();const L=C.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),R=L?.getAttribute("data-value");R!=null&&L&&T(L,R)},h.onclick=S=>{if(u)return;S.stopPropagation();const C=!d.get();d.set(C);const N=S.currentTarget.closest(".rui-combobox");if(N?.setAttribute("data-open",C?"true":"false"),N?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded",C?"true":"false"),!!N){if(!C){Ne(N);return}setTimeout(()=>x.focus(),0),rt({liveRoot:N,onDismiss:()=>{d.set(!1),m.set(""),N.setAttribute("data-open","false"),N.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},b.append(y),b}},hc={name:"MultiSelect",description:"Multi-option searchable dropdown. Type to filter, click an option to add/remove it from the bound array. Renders the selected options as removable chips inside the trigger. Pass a `$variable` (array of values) as `value` for two-way binding.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]",description:"Options; SelectItem(value, label) or {value, label}"},{name:"value",type:"any[]",optional:!0,description:"Bound array of selected values (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when no items match the filter"},{name:"max",type:"number",optional:!0,description:"Maximum number of selections"},{name:"disabled",type:"boolean",optional:!0},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the dropdown"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated array of selected values"}],render:(t,e,r)=>{const a=f(e.id),n=fn(e.items),i=f(e.placeholder,"Select…"),o=f(e.emptyLabel,"No matches"),s=A(e.disabled),c=Math.max(0,Math.floor(Number(e.max??0))),u=Array.isArray(e.value)?e.value.map(I=>f(I)).filter(Boolean):[],p=new Set(u),d=t.argMeta?.[2]?.stateRef,m=A(e.open),g=r.useInstanceState("open",m),b=r.useInstanceState("filter",""),h=g.get(),v=l("div",{class:"rui-multiselect","data-open":h?"true":"false","data-disabled":s?"true":"false"}),y=l("button",{type:"button",class:"rui-multiselect-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":h?"true":"false",disabled:s?"":null}),x=l("span",{class:"rui-multiselect-chips"}),w=I=>{d&&r.setState(d,I),r.invoke(e.onChange,I)};if(u.length===0)x.append(l("span",{class:"rui-multiselect-placeholder"},[i]));else for(const I of u){const L=n.find(O=>O.value===I)?.label??I,R=l("span",{class:"rui-multiselect-chip","data-value":I});R.append(l("span",{class:"rui-multiselect-chip-label"},[L]));const q=l("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${L}`},["×"]);q.onclick=O=>{O.stopPropagation();const U=u.filter(J=>J!==I);w(U)},R.append(q),x.append(R)}y.append(x);const k=j("chevron-down",{className:"rui-multiselect-chevron"});k&&y.append(k),v.append(y);const T=l("div",{class:"rui-multiselect-panel",role:"listbox","aria-multiselectable":"true"}),S=l("input",{type:"text",class:"rui-multiselect-filter",placeholder:"Filter…",autocomplete:"off",value:b.get()});T.append(S);const C=l("div",{class:"rui-multiselect-list"});T.append(C);const N=(I,L)=>{I.replaceChildren();const R=L.trim().toLowerCase(),q=R===""?n:n.filter(O=>O.label.toLowerCase().includes(R)||O.value.toLowerCase().includes(R));if(q.length===0){I.append(l("div",{class:"rui-multiselect-empty"},[o]));return}for(const O of q){const U=p.has(O.value),J=!U&&c>0&&u.length>=c,Z=l("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":O.value,"data-selected":U?"true":"false","aria-selected":U?"true":"false",disabled:J?"":null}),me=l("span",{class:"rui-multiselect-option-check"}),$e=j(U?"check":"",{className:"rui-multiselect-option-check-icon"});$e&&me.append($e),Z.append(me),Z.append(l("span",{class:"rui-multiselect-option-label"},[O.label])),Z.onclick=$t=>{if($t.stopPropagation(),J)return;const Ye=U?u.filter(da=>da!==O.value):[...u,O.value];w(Ye)},I.append(Z)}};return N(C,b.get()),S.oninput=I=>{const L=I.currentTarget;b.set(L.value);const R=L.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");R&&N(R,L.value)},y.onclick=I=>{if(s)return;I.stopPropagation();const L=!g.get();g.set(L);const R=I.currentTarget.closest(".rui-multiselect");if(R?.setAttribute("data-open",L?"true":"false"),R?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",L?"true":"false"),!!R){if(!L){Ne(R);return}setTimeout(()=>S.focus(),0),rt({liveRoot:R,onDismiss:()=>{g.set(!1),b.set(""),R.setAttribute("data-open","false"),R.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},v.append(T),v}},bc={name:"DateRangePicker",description:"Paired date inputs with a single label, sharing the same min/max range. Pass `$variable` references for both `from` and `to` to two-way-bind a date range (ISO `YYYY-MM-DD` strings).",props:[{name:"id",type:"string"},{name:"from",type:"string",optional:!0,description:"ISO date start; typically $variable"},{name:"to",type:"string",optional:!0,description:"ISO date end; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0,description:"Earliest selectable ISO date"},{name:"max",type:"string",optional:!0,description:"Latest selectable ISO date"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with `{from, to}` whenever either endpoint changes"}],render:(t,e,r)=>{const a=f(e.id),n=`${a}-from`,i=`${a}-to`,o=f(e.min),s=f(e.max),c=A(e.disabled),u=l("div",{class:"rui-date-range-picker","data-disabled":c?"true":"false"}),p=f(e.label);p&&u.append(l("label",{class:"rui-date-range-picker-label",for:n},[p]));const d=l("div",{class:"rui-date-range-picker-row"}),m=l("input",{type:"date",class:"rui-date-range-picker-input",id:n,name:n,value:f(e.from),min:o||null,max:s||null,disabled:c?"":null,"data-role":"from"});d.append(m),d.append(l("span",{class:"rui-date-range-picker-separator","aria-hidden":"true"},["–"]));const g=l("input",{type:"date",class:"rui-date-range-picker-input",id:i,name:i,value:f(e.to),min:o||null,max:s||null,disabled:c?"":null,"data-role":"to"});d.append(g),u.append(d);const b=t.argMeta?.[1]?.stateRef,h=t.argMeta?.[2]?.stateRef;if(b&&r.bindState(m,b),h&&r.bindState(g,h),e.onChange!=null){const v=y=>{const x=y.closest(".rui-date-range-picker"),w=x?.querySelector('.rui-date-range-picker-input[data-role="from"]')?.value??"",k=x?.querySelector('.rui-date-range-picker-input[data-role="to"]')?.value??"";return{from:w,to:k}};m.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget))),g.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget)))}return u}};function vc(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function yc(t,e,r){const a=t.argMeta?[...t.argMeta]:[];for(;a.length<5;)a.push({});a[4]?.stateRef&&(a[2]=a[4]);const n=bn.render({...t,argMeta:a},{id:e.id,items:e.items,value:e.value,placeholder:e.placeholder,emptyLabel:"No matches",disabled:!1},r);return n.classList.add("rui-select-searchable"),n}function Ve(t,e,r,a){const n=e.argMeta?.[r]?.stateRef;if(n){if(t instanceof HTMLInputElement&&t.type==="checkbox"){a.bindState(t,n,{event:"change",getValue:i=>i.checked});return}a.bindState(t,n)}}function xc(t,e){if(!e)return;const r=Array.isArray(e)?e.map(a=>String(a)):typeof e=="object"?Object.entries(e).map(([a,n])=>n?`${a}:${n}`:a):[];for(const a of r)a==="required"?t.required=!0:a.startsWith("minLength:")?t.minLength=Number(a.slice(10))||0:a.startsWith("maxLength:")?t.maxLength=Number(a.slice(10))||0:a==="email"&&(t.type="email")}const Le=["default","primary","success","warning","danger","info"],We=(t,e)=>{const r=$(t);if(r.length===0)return null;const a=l("div",{class:"rui-pattern-actions"});for(const n of r)a.append(e.renderNode(n));return a},wc=[{match:/\bbeta\b/i,label:"Beta"},{match:/\b(early\s?access|preview)\b/i,label:"Preview"},{match:/\b(introduc(?:ing|e)|launch(?:ed|ing)?|announcing)\b/i,label:"Introducing"},{match:/\b(welcome\b|get(?:ting)?\s?started)/i,label:"Welcome"},{match:/\b(new\b|whats\s?new|now\b)/i,label:"What's new"},{match:/\bfree\b/i,label:"Free trial"},{match:/\bupgrade\b/i,label:"Upgrade"},{match:/\b(sale|discount|deal)\b/i,label:"Limited time"}];function kc(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const a of wc)if(a.match.test(r))return a.label;return""}const Sc={name:"Hero",description:'Eye-catching landing/marketing header with eyebrow tag, title, subtitle, optional bullet highlights, and primary/secondary CTA buttons. Use `layout="cover"` with `imageSrc` for an image-backed hero band (pass `height` and optional `caption`). Default layout shows an optional side illustration.',props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0},{name:"primary",type:"Button",optional:!0,description:"Primary CTA — pass a Button(...)"},{name:"secondary",type:"Button",optional:!0,description:"Secondary CTA — pass a Button(...)"},{name:"eyebrow",type:"string",optional:!0,description:"Short uppercase tag above the title"},{name:"highlights",type:"string[]",optional:!0,description:"Bullet items rendered as tag pills"},{name:"imageSrc",type:"string",optional:!0,description:"Illustration or cover background when layout=cover"},{name:"caption",type:"string",optional:!0,description:"Small caption above CTAs (cover layout)"},{name:"height",type:"string",optional:!0,description:"Min-height for cover layout (default 280px)"},{name:"actions",type:"Node[]",optional:!0,description:"CTA row (cover layout; alternative to primary/secondary)"},{name:"layout",type:"string",optional:!0,enum:["default","cover"],description:"default = text-first; cover = image-backed band"},{name:"tone",type:"string",optional:!0,enum:Le,description:"Accent tone"}],render:(t,e,r)=>{const a=f(e.layout,"default"),n=f(e.title),i=f(e.subtitle),s=f(e.eyebrow)||kc(n,i),c=f(e.tone,"primary");if(a==="cover"){const b=$s(f(e.imageSrc)),h=re(f(e.height),"280px"),v=l("section",{class:"rui-cover","data-tone":c,style:`background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url("${b}");min-height:${h};`}),y=l("div",{class:"rui-cover-body"});s&&y.append(l("span",{class:"rui-cover-eyebrow"},[s])),y.append(l("h1",{class:"rui-cover-title"},[n])),i&&y.append(l("p",{class:"rui-cover-subtitle"},[i]));const x=f(e.caption);x&&y.append(l("p",{class:"rui-cover-caption"},[x]));const w=We(e.actions,r);if(w)w.classList.add("rui-cover-actions"),y.append(w);else{const k=[e.primary,e.secondary].filter(Boolean);if(k.length>0){const T=l("div",{class:"rui-cover-actions rui-pattern-actions"});for(const S of k)T.append(r.renderNode(S));y.append(T)}}return v.append(y),v}const u=ie(e.imageSrc),p=l("section",{class:"rui-hero","data-tone":c,"data-has-image":u?"true":"false"}),d=l("div",{class:"rui-hero-body"});s&&d.append(l("span",{class:"rui-hero-eyebrow"},[s])),d.append(l("h1",{class:"rui-hero-title"},[n])),i&&d.append(l("p",{class:"rui-hero-subtitle"},[i]));const m=$(e.highlights);if(m.length>0){const b=l("div",{class:"rui-hero-highlights"});for(const h of m){const v=f(h);v&&b.append(l("span",{class:"rui-hero-highlight"},[v]))}d.append(b)}const g=[e.primary,e.secondary].filter(Boolean);if(g.length>0){const b=l("div",{class:"rui-hero-ctas"});for(const h of g)b.append(r.renderNode(h));d.append(b)}if(p.append(d),u){const b=l("div",{class:"rui-hero-media"});b.append(l("img",{src:u,alt:"",loading:"lazy"})),p.append(b)}return p}},$c={name:"PageHeader",description:'Page-level header with breadcrumbs, title, subtitle, status tag, and a right-aligned actions row. The canonical first child for any dashboard, settings, or detail page — replaces ad-hoc Stack+Header+Buttons stitching. If `breadcrumbs` is omitted the component auto-derives `["Home", title]` so the page never lacks a trail. Pass `breadcrumbs=false` to opt out.',props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0},{name:"breadcrumbs",type:"string[] | Breadcrumb | false",optional:!0,description:"Array of strings, a Breadcrumb(...) node, or `false` to suppress the auto-derived trail"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / NavLinks shown on the right"},{name:"status",type:"Badge",optional:!0,aliases:["badge"],description:"Optional Badge(...) rendered next to the title"}],render:(t,e,r)=>{const a=l("header",{class:"rui-page-header"}),n=f(e.title);let i=e.breadcrumbs;if(i==null?n&&(i=["Home",n]):(i===!1||i==="false")&&(i=null),i){const d=l("div",{class:"rui-page-header-breadcrumbs"});Array.isArray(i)?i.forEach((m,g)=>{g>0&&d.append(l("span",{class:"rui-page-header-crumb-sep"},["/"])),d.append(l("span",{class:"rui-page-header-crumb"},[f(m)]))}):d.append(r.renderNode(i)),a.append(d)}const o=l("div",{class:"rui-page-header-title-row"}),s=l("div",{class:"rui-page-header-title-block"}),c=l("div",{class:"rui-page-header-title-line"});c.append(l("h1",{class:"rui-page-header-title"},[n])),e.status&&c.append(r.renderNode(e.status)),s.append(c);const u=f(e.subtitle);u&&s.append(l("p",{class:"rui-page-header-subtitle"},[u])),o.append(s);const p=We(e.actions,r);return p&&(p.classList.add("rui-page-header-actions"),o.append(p)),a.append(o),a}},Cc={name:"EmptyState",description:"Zero-state placeholder for empty lists, searches, dashboards. Renders a centered icon (or illustration), title, description, and either a single `action` Button or an `actions` row (primary + secondary). Always preferable to an empty Card with raw text.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:'Font Awesome icon name (defaults to "inbox")'},{name:"illustration",type:"string",optional:!0,description:"Image URL — takes precedence over `icon` when provided"},{name:"action",type:"Button",optional:!0,description:"Single CTA (legacy slot)"},{name:"actions",type:"Node[]",optional:!0,description:"Row of CTA Buttons / Links — preferred over `action` for primary + secondary affordances"}],render:(t,e,r)=>{const a=l("div",{class:"rui-empty-state"}),n=ie(e.illustration);if(n)a.append(l("img",{class:"rui-empty-state-illustration",src:n,alt:"",loading:"lazy"}));else{const s=f(e.title),c=f(e.description),u=f(e.icon)||mn(`${s} ${c}`)||"inbox",p=j(u,{className:"rui-empty-state-icon"});p&&a.append(p)}a.append(l("h3",{class:"rui-empty-state-title"},[f(e.title)]));const i=f(e.description);i&&a.append(l("p",{class:"rui-empty-state-description"},[i]));const o=$(e.actions);if(o.length>0){const s=l("div",{class:"rui-empty-state-actions"});for(const c of o)s.append(r.renderNode(c));a.append(s)}else if(e.action){const s=l("div",{class:"rui-empty-state-action"});s.append(r.renderNode(e.action)),a.append(s)}return a}},Ac={name:"TimelineItem",description:"Single event on a Timeline.",props:[{name:"title",type:"string"},{name:"time",type:"string",optional:!0,description:"Display label (ISO, relative, etc.)"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name rendered inside the marker"},{name:"tone",type:"string",optional:!0,enum:Le}],render:(t,e)=>{const r=l("li",{class:"rui-timeline-item","data-tone":f(e.tone,"default")}),a=l("span",{class:"rui-timeline-marker"}),n=j(e.icon);n&&a.append(n),r.append(a);const i=l("div",{class:"rui-timeline-body"}),o=l("div",{class:"rui-timeline-head"});o.append(l("span",{class:"rui-timeline-title"},[f(e.title)]));const s=f(e.time);s&&o.append(l("span",{class:"rui-timeline-time"},[s])),i.append(o);const c=f(e.description);return c&&i.append(l("div",{class:"rui-timeline-description"},[c])),r.append(i),r}},Tc={name:"Timeline",description:"Vertical event timeline. Children must be TimelineItem entries. Ideal for activity feeds, changelogs, and process flows.",props:[{name:"items",type:"TimelineItem[]"}],render:(t,e,r)=>{const a=l("ol",{class:"rui-timeline"});for(const n of $(e.items))a.append(r.renderNode(n));return a}},Mc={name:"FeatureItem",description:"Single tile on a FeatureGrid.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"tone",type:"string",optional:!0,enum:Le}],render:(t,e)=>{const r=l("div",{class:"rui-feature-item","data-tone":f(e.tone,"primary")}),a=f(e.icon,"sparkles"),n=j(a,{className:"rui-feature-icon"});n&&r.append(n),r.append(l("h3",{class:"rui-feature-title"},[f(e.title)]));const i=f(e.description);return i&&r.append(l("p",{class:"rui-feature-description"},[i])),r}},Nc={name:"FeatureGrid",description:"Responsive grid of FeatureItem tiles (typically 2–3 columns). Use to highlight product capabilities or page categories.",props:[{name:"items",type:"FeatureItem[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(4,Number(e.columns??"auto"))),n=l("div",{class:"rui-feature-grid","data-columns":a>0?String(a):null});for(const i of $(e.items))n.append(r.renderNode(i));return n}},Pc={name:"Testimonial",description:"Quote card with author, role, and optional avatar.",props:[{name:"quote",type:"string"},{name:"author",type:"string",aliases:["name"]},{name:"role",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"rating",type:"number",optional:!0,description:"0–5 stars"}],render:(t,e)=>{const r=l("figure",{class:"rui-testimonial"}),a=Math.max(0,Math.min(5,Math.round(Number(e.rating??0))));if(a>0){const c=l("div",{class:"rui-testimonial-rating"});for(let u=0;u<5;u+=1){const p=u<a,d=j(p?"star":"regular:star",{className:"rui-testimonial-rating-star"});d&&c.append(d)}r.append(c)}r.append(l("blockquote",{class:"rui-testimonial-quote"},[f(e.quote)]));const n=l("figcaption",{class:"rui-testimonial-author"}),i=ie(e.avatarSrc);i&&n.append(l("img",{class:"rui-testimonial-avatar",src:i,alt:""}));const o=l("div",{class:"rui-testimonial-meta"});o.append(l("div",{class:"rui-testimonial-name"},[f(e.author)]));const s=f(e.role);return s&&o.append(l("div",{class:"rui-testimonial-role"},[s])),n.append(o),r.append(n),r}},Ic={name:"ProfileCard",description:"Compact profile/user card with avatar, name, role, optional bio, social tags, and a row of action buttons. Use for team rosters, contributor lists, and contact panels.",props:[{name:"name",type:"string"},{name:"role",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"],description:"Avatar image src; falls back to initials"},{name:"bio",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0},{name:"actions",type:"Node[]",optional:!0,description:"Buttons to render at the bottom"}],render:(t,e,r)=>{const a=l("div",{class:"rui-profile-card"}),n=l("div",{class:"rui-profile-card-header"});n.append(ct(f(e.avatarSrc),f(e.name),"lg"));const i=l("div",{class:"rui-profile-card-meta"});i.append(l("h3",{class:"rui-profile-card-name"},[f(e.name)]));const o=f(e.role);o&&i.append(l("p",{class:"rui-profile-card-role"},[o])),n.append(i),a.append(n);const s=f(e.bio);s&&a.append(l("p",{class:"rui-profile-card-bio"},[s]));const c=$(e.tags);if(c.length>0){const p=l("div",{class:"rui-profile-card-tags"});for(const d of c){const m=f(d);m&&p.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[m])]))}a.append(p)}const u=We(e.actions,r);return u&&(u.classList.add("rui-profile-card-actions"),a.append(u)),a}},Ec={name:"Comment",description:"Single comment / message bubble. Renders avatar, author, timestamp, body, and an optional row of toolbar buttons (reply, like, …).",props:[{name:"author",type:"string"},{name:"body",type:"string",aliases:["text","message"]},{name:"time",type:"string",optional:!0,description:"Relative or absolute timestamp"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=l("article",{class:"rui-comment"});a.append(ct(f(e.avatarSrc),f(e.author),"md"));const n=l("div",{class:"rui-comment-body"}),i=l("header",{class:"rui-comment-header"});i.append(l("span",{class:"rui-comment-author"},[f(e.author)]));const o=f(e.time);o&&i.append(l("span",{class:"rui-comment-time"},[o])),n.append(i),n.append(l("div",{class:"rui-comment-content"},[f(e.body)]));const s=We(e.actions,r);return s&&(s.classList.add("rui-comment-actions"),n.append(s)),a.append(n),a}},Lc={name:"Banner",description:"Full-width announcement banner. Use at the top of a page for promos, release notes, or downtime notices. For inline notices prefer Callout or Alert.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"action",type:"Button",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name"},{name:"tone",type:"string",optional:!0,enum:Le}],render:(t,e,r)=>{const a=f(e.tone,"primary"),n=l("aside",{class:"rui-banner","data-tone":a}),i=f(e.icon)||Rl(a)||"",o=j(i,{className:"rui-banner-icon"});o&&n.append(o);const s=l("div",{class:"rui-banner-body"});s.append(l("strong",{class:"rui-banner-title"},[f(e.title)]));const c=f(e.message);if(c&&s.append(l("span",{class:"rui-banner-message"},[c])),n.append(s),e.action){const u=l("div",{class:"rui-banner-action"});u.append(r.renderNode(e.action)),n.append(u)}return n}},zc={name:"KanbanCard",description:"Single card on a Kanban board.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0},{name:"assignee",type:"string",optional:!0,description:"Name shown next to avatar initials"},{name:"tone",type:"string",optional:!0,enum:Le},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown beside the title"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Optional callable fired when the card is clicked"}],render:(t,e,r)=>{const a=l("div",{class:"rui-kanban-card","data-tone":f(e.tone,"default")});typeof e.onClick=="function"&&(a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.onclick=()=>r.invoke(e.onClick),a.onkeydown=u=>{const p=u;(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r.invoke(e.onClick))});const n=l("div",{class:"rui-kanban-card-title"}),i=j(e.icon,{className:"rui-kanban-card-icon"});i&&n.append(i),n.append(document.createTextNode(f(e.title))),a.append(n);const o=f(e.description);o&&a.append(l("p",{class:"rui-kanban-card-description"},[o]));const s=$(e.tags);if(s.length>0){const u=l("div",{class:"rui-kanban-card-tags"});for(const p of s){const d=f(p);d&&u.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[d])]))}a.append(u)}const c=f(e.assignee);if(c){const u=l("footer",{class:"rui-kanban-card-footer"});u.append(ct("",c,"sm")),u.append(l("span",{class:"rui-kanban-card-assignee"},[c])),a.append(u)}return a}},Rc={name:"KanbanColumn",description:"Single column inside a KanbanBoard. Children must be KanbanCard entries.",props:[{name:"title",type:"string"},{name:"items",type:"KanbanCard[]",aliases:["cards"]},{name:"tone",type:"string",optional:!0,enum:Le,description:"Header accent tone"}],render:(t,e,r)=>{const a=$(e.items),n=l("section",{class:"rui-kanban-column","data-tone":f(e.tone,"default")}),i=l("header",{class:"rui-kanban-column-header"});i.append(l("span",{class:"rui-kanban-column-title"},[f(e.title)])),i.append(l("span",{class:"rui-kanban-column-count"},[String(a.length)])),n.append(i);const o=l("div",{class:"rui-kanban-column-body"});for(const s of a)o.append(r.renderNode(s));return a.length===0&&o.append(l("div",{class:"rui-kanban-column-empty"},["No items"])),n.append(o),n}},Dc={name:"KanbanBoard",description:"Horizontal Kanban board. Children must be KanbanColumn entries. The board scrolls horizontally on narrow viewports so columns stay readable.",props:[{name:"columns",type:"KanbanColumn[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-kanban-board"});for(const n of $(e.columns))a.append(r.renderNode(n));return a}},jc={name:"SectionHeader",description:"Compact section header for the top of a Card or panel. Renders a small eyebrow, a title, an optional subtitle, an optional status Tag/Badge, and a right-aligned actions row. Use this inside a Card to introduce a section instead of a bare `CardHeader`.",props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0,aliases:["description"]},{name:"eyebrow",type:"string",optional:!0,description:"Short uppercase label above the title"},{name:"status",type:"Badge | Tag",optional:!0,aliases:["badge"]},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / Links shown on the right"}],render:(t,e,r)=>{const a=l("header",{class:"rui-section-header"}),n=l("div",{class:"rui-section-header-left"}),i=f(e.eyebrow);i&&n.append(l("span",{class:"rui-section-header-eyebrow"},[i]));const o=l("div",{class:"rui-section-header-title-line"});o.append(l("h3",{class:"rui-section-header-title"},[f(e.title)])),e.status&&o.append(r.renderNode(e.status)),n.append(o);const s=f(e.subtitle);s&&n.append(l("p",{class:"rui-section-header-subtitle"},[s])),a.append(n);const c=We(e.actions,r);return c&&(c.classList.add("rui-section-header-actions"),a.append(c)),a}},Bc={name:"Toolbar",description:"Horizontal toolbar for filters, search, view modes, and primary actions. Left/center/right slots wrap onto separate rows on narrow viewports so the bar never overflows. Pass `searchable: true` to auto-mount a SearchBar in the left slot (bind `searchValue` to a `$variable`). Use ABOVE a Table, List, Grid, or Kanban view — never replace `PageHeader` with it.",props:[{name:"left",type:"Node[]",optional:!0,description:"Filters / search inputs / chips"},{name:"right",type:"Node[]",optional:!0,description:"Primary action buttons"},{name:"center",type:"Node[]",optional:!0,description:"Centered controls (e.g. SegmentedControl, search bar)"},{name:"searchable",type:"boolean",optional:!0,description:"Auto-mount a SearchBar at the start of the left slot"},{name:"searchPlaceholder",type:"string",optional:!0,description:"Placeholder for the auto-mounted SearchBar"},{name:"searchValue",type:"string",optional:!0,description:"$variable bound to the auto-mounted SearchBar"}],render:(t,e,r)=>{const a=$(e.center),n=l("div",{class:"rui-toolbar","data-has-center":a.length>0?"true":"false"}),i=l("div",{class:"rui-toolbar-side rui-toolbar-left"});A(e.searchable)&&i.append(hn.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:f(e.searchPlaceholder,"Search…"),value:e.searchValue},r));for(const s of $(e.left))i.append(r.renderNode(s));if(n.append(i),a.length>0){const s=l("div",{class:"rui-toolbar-side rui-toolbar-center"});for(const c of a)s.append(r.renderNode(c));n.append(s)}const o=l("div",{class:"rui-toolbar-side rui-toolbar-right"});for(const s of $(e.right))o.append(r.renderNode(s));return n.append(o),n}},Oc={name:"SidebarItem",description:"Single navigation item inside a Sidebar. Pass `active=true` to mark as the current page, a `to` path to navigate via the runtime router on click, an `onClick` callable for arbitrary click handling, or an optional `badge` (string/number) for a trailing chip. `to` and `onClick` can coexist — `onClick` is invoked AFTER the router navigates so authors can do extra work (analytics, side-effects).",props:[{name:"label",type:"string"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name rendered before the label"},{name:"active",type:"boolean",optional:!0,description:"Mark this item as the current page. When `to` is provided and `active` is omitted, the item auto-detects the active state from the current router path."},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"to",type:"string",optional:!0,description:'Router path to navigate to on click (e.g. "/", "/orders"). Uses the runtime router — no full page reload.'},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable invoked on click. Runs in addition to `to`-based navigation."}],render:(t,e,r)=>{const a=f(e.to),n=e.active!==void 0&&e.active!==null,i=a?r.router.getPath():"",o=a?a==="/"?i==="/":i===a?!0:i.startsWith(a+"/"):!1,s=n?A(e.active):o,c=l("button",{type:"button",class:"rui-sidebar-item","data-active":s?"true":"false","data-to":a||null}),u=j(e.icon,{className:"rui-sidebar-item-icon"});u&&c.append(u),c.append(l("span",{class:"rui-sidebar-item-label"},[f(e.label)]));const p=f(e.badge);return p&&c.append(l("span",{class:"rui-sidebar-item-badge"},[p])),(a||e.onClick!=null)&&(c.onclick=d=>{if(a){const m=d;if(m.metaKey||m.ctrlKey||m.shiftKey||m.altKey)return;r.router.navigate(a)}e.onClick!=null&&r.invoke(e.onClick)}),c}},_c={name:"SidebarSection",description:"Grouping inside a Sidebar — small uppercase label followed by SidebarItem entries. Use this to chunk a long sidebar into sections.",props:[{name:"label",type:"string"},{name:"items",type:"SidebarItem[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-sidebar-section"}),n=f(e.label);n&&a.append(l("div",{class:"rui-sidebar-section-label"},[n]));for(const i of $(e.items))a.append(r.renderNode(i));return a}},Fc={name:"Sidebar",description:"Vertical app navigation panel. Supports a brand header, navigation items (`SidebarItem` or `SidebarSection`), an optional footer, and a `collapsed` mode that hides labels to leave just an icon rail. Use inside `AppShell` for SaaS-style left navigation.",props:[{name:"items",type:"(SidebarItem | SidebarSection)[]"},{name:"brand",type:"string",optional:!0,description:"Product name / workspace label at the top"},{name:"tagline",type:"string",optional:!0},{name:"footer",type:"Node[]",optional:!0,description:"Footer block (Avatar + name, upgrade CTA, …)"},{name:"collapsed",type:"boolean",optional:!0,description:"Render as an icon-only rail (hides labels/badges)"}],render:(t,e,r)=>{const a=A(e.collapsed),n=l("aside",{class:"rui-sidebar"});a&&(n.dataset.collapsed="true");const i=f(e.brand),o=f(e.tagline);if(i||o){const u=l("div",{class:"rui-sidebar-header"});i&&u.append(l("div",{class:"rui-sidebar-brand"},[i])),o&&u.append(l("div",{class:"rui-sidebar-tagline"},[o])),n.append(u)}const s=l("nav",{class:"rui-sidebar-body"});for(const u of $(e.items))s.append(r.renderNode(u));n.append(s);const c=$(e.footer);if(c.length>0){const u=l("div",{class:"rui-sidebar-footer"});for(const p of c)u.append(r.renderNode(p));n.append(u)}return n}},Uc={name:"AppShell",description:"Canonical SaaS application shell: optional top bar, fixed left Sidebar, and scrollable main content. Reach for this whenever a response represents a full product surface (dashboard with nav, settings + sections, admin panels). Pass `collapsible=true` to render a hamburger that turns the sidebar into a slide-over drawer on narrow viewports.",props:[{name:"sidebar",type:"Sidebar",description:"Pass a Sidebar(...) node"},{name:"content",type:"Node[]",description:"Main content (typically starts with a PageHeader)"},{name:"topbar",type:"Node[]",optional:!0,description:"Optional thin top bar above the content"},{name:"collapsible",type:"boolean",optional:!0,description:"Show a hamburger that toggles the sidebar drawer on mobile"},{name:"sidebarOpen",type:"boolean",optional:!0,description:"$variable controlling whether the mobile drawer is open"}],render:(t,e,r)=>{const a=A(e.collapsible),n=A(e.sidebarOpen),i=l("div",{class:"rui-app-shell"});a&&(i.dataset.collapsible="true"),n&&(i.dataset.sidebarOpen="true");const o=l("div",{class:"rui-app-shell-sidebar"});if(o.append(r.renderNode(e.sidebar)),i.append(o),a){const p=l("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});p.addEventListener("click",()=>{delete i.dataset.sidebarOpen}),i.append(p)}const s=l("div",{class:"rui-app-shell-main"}),c=$(e.topbar);if(c.length>0||a){const p=l("div",{class:"rui-app-shell-topbar"});if(a){const d=l("button",{class:"rui-app-shell-toggle",type:"button","aria-label":"Toggle navigation"});d.append(j("bars",{size:"md"})??document.createTextNode("≡")),d.addEventListener("click",()=>{i.dataset.sidebarOpen?delete i.dataset.sidebarOpen:i.dataset.sidebarOpen="true"}),p.append(d)}for(const d of c)p.append(r.renderNode(d));s.append(p)}const u=l("div",{class:"rui-app-shell-content"});for(const p of $(e.content))u.append(r.renderNode(p));return s.append(u),i.append(s),i}},Hc={name:"SplitView",description:"Two-pane master/detail layout — a narrow primary pane on the left, wider detail pane on the right. Collapses to a single column on narrow viewports. Use for inboxes, file browsers, contact lists.",props:[{name:"primary",type:"Node[]",description:"Master pane content (list, filters)"},{name:"detail",type:"Node[]",aliases:["secondary"],description:"Detail pane content (selected item, empty state)"},{name:"primaryWidth",type:"string",optional:!0,aliases:["splitAt"],description:"CSS width for the primary pane (default 320px)"}],render:(t,e,r)=>{const a=re(f(e.primaryWidth),"320px"),n=l("div",{class:"rui-split-view",style:`--rui-split-primary:${a}`}),i=l("div",{class:"rui-split-view-primary"});for(const s of $(e.primary))i.append(r.renderNode(s));const o=l("div",{class:"rui-split-view-detail"});for(const s of $(e.detail))o.append(r.renderNode(s));return n.append(i,o),n}},Vc={name:"DescriptionItem",description:"Single row inside a DescriptionList. Renders a small uppercase label on the left and a value (string or arbitrary Node) on the right.",props:[{name:"label",type:"string"},{name:"value",type:"Node | string"},{name:"icon",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-description-item"}),n=l("dt",{class:"rui-description-label"}),i=j(e.icon,{className:"rui-description-icon"});i&&n.append(i),n.append(document.createTextNode(f(e.label)));const o=l("dd",{class:"rui-description-value"});return e.value&&typeof e.value=="object"&&e.value.__kind==="Component"?o.append(r.renderNode(e.value)):o.append(document.createTextNode(f(e.value))),a.append(n,o),a}},Wc={name:"DescriptionList",description:"Compact key/value summary for detail pages — replaces a row of `Text`s with a properly aligned `<dl>`. Children must be DescriptionItem entries. Two columns by default on wide viewports.",props:[{name:"items",type:"DescriptionItem[]"},{name:"columns",type:"number",optional:!0,description:"1 or 2 (default 2)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(2,Math.floor(Number(e.columns??2)))),n=l("dl",{class:"rui-description-list","data-columns":String(a)});for(const i of $(e.items))n.append(r.renderNode(i));return n}},qc={name:"StatusDot",description:"Inline status pip + label. Use for compact health/state indicators in toolbars, sidebars, lists, and table cells.",props:[{name:"label",type:"string"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]},{name:"pulse",type:"boolean",optional:!0,description:"Animate the dot for 'live' state"}],render:(t,e)=>{const r=l("span",{class:"rui-status-dot","data-tone":f(e.tone,"success"),"data-pulse":A(e.pulse)?"true":"false"});return r.append(l("span",{class:"rui-status-dot-marker"})),r.append(l("span",{class:"rui-status-dot-label"},[f(e.label)])),r}},Kc={name:"PricingCard",description:"Single pricing tier card with plan name, price, billing period, description, bullet features, and a CTA button. Mark one tier as `featured=true` to highlight it (raises the card, adds a ribbon).",props:[{name:"plan",type:"string",description:"Tier name (e.g. 'Pro')"},{name:"price",type:"string",description:"Display price (e.g. '$29')"},{name:"period",type:"string",optional:!0,description:"Billing period (e.g. '/mo')"},{name:"description",type:"string",optional:!0},{name:"features",type:"string[]",optional:!0,description:"Bullet list of included features"},{name:"action",type:"Button",optional:!0,aliases:["cta"],description:"Primary CTA — pass a Button(...)"},{name:"badge",type:"string",optional:!0,description:"Eyebrow / badge above the plan name"},{name:"featured",type:"boolean",optional:!0,aliases:["highlighted"]}],render:(t,e,r)=>{const a=A(e.featured),n=l("article",{class:"rui-pricing-card","data-featured":a?"true":"false"}),i=f(e.badge);i&&n.append(l("div",{class:"rui-pricing-card-badge"},[i])),n.append(l("h3",{class:"rui-pricing-card-plan"},[f(e.plan)]));const o=f(e.description);o&&n.append(l("p",{class:"rui-pricing-card-description"},[o]));const s=l("div",{class:"rui-pricing-card-price-row"});s.append(l("span",{class:"rui-pricing-card-price"},[f(e.price)]));const c=f(e.period);c&&s.append(l("span",{class:"rui-pricing-card-period"},[c])),n.append(s);const u=$(e.features);if(u.length>0){const p=l("ul",{class:"rui-pricing-card-features"});for(const d of u){const m=f(d);if(!m)continue;const g=j("circle-check",{className:"rui-pricing-card-check"})??l("span",{class:"rui-pricing-card-check"});p.append(l("li",{class:"rui-pricing-card-feature"},[g,document.createTextNode(m)]))}n.append(p)}if(e.action){const p=l("div",{class:"rui-pricing-card-action"});p.append(r.renderNode(e.action)),n.append(p)}return n}},Gc={name:"PricingTable",description:"Responsive grid of PricingCard tiers. Items size uniformly across a row and wrap onto multiple rows on narrow viewports. Use as the centerpiece of any pricing or upgrade page.",props:[{name:"tiers",type:"PricingCard[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(4,Math.floor(Number(e.columns??"auto")))),n=l("div",{class:"rui-pricing-table","data-columns":a>0?String(a):null});for(const i of $(e.tiers))n.append(r.renderNode(i));return n}},Yc={name:"MediaCard",description:'Card with a media (image) header followed by title, body, optional tags, footer meta, and an actions row. Use for article previews, product cards, project highlights, gallery items — anywhere a Card needs a leading image. Orient with `orientation="horizontal"` for side-by-side media + content on wide viewports.',props:[{name:"title",type:"string"},{name:"imageSrc",type:"string",optional:!0,aliases:["src","image"],description:"Image URL (omit to render a neutral placeholder)"},{name:"description",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0,description:"Tag pill labels"},{name:"meta",type:"string",optional:!0,description:"Footer meta line (author · date · category)"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / Links rendered at the bottom"},{name:"badge",type:"string | Badge",optional:!0,description:"Eyebrow string or Badge node shown over the image"},{name:"orientation",type:"string",optional:!0,enum:["vertical","horizontal"]},{name:"ratio",type:"string",optional:!0,description:"Media aspect ratio (default 16:9 vertical, 4:3 horizontal)"}],render:(t,e,r)=>{const a=f(e.orientation,"vertical"),n=l("article",{class:"rui-media-card","data-orientation":a}),i=Xc(f(e.ratio,a==="horizontal"?"4:3":"16:9")),o=l("div",{class:"rui-media-card-media",style:`aspect-ratio:${i};`}),s=ie(e.imageSrc);if(s)o.append(l("img",{src:s,alt:f(e.title),loading:"lazy"}));else{o.classList.add("rui-media-card-media-empty");const g=j("image",{className:"rui-media-card-placeholder"})??l("span",{class:"rui-media-card-placeholder"});o.append(g)}if(e.badge){const g=l("span",{class:"rui-media-card-badge"});typeof e.badge=="string"?g.append(document.createTextNode(f(e.badge))):g.append(r.renderNode(e.badge)),o.append(g)}n.append(o);const c=l("div",{class:"rui-media-card-body"});c.append(l("h3",{class:"rui-media-card-title"},[f(e.title)]));const u=f(e.description);u&&c.append(l("p",{class:"rui-media-card-description"},[u]));const p=$(e.tags);if(p.length>0){const g=l("div",{class:"rui-media-card-tags"});for(const b of p){const h=f(b);h&&g.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[h])]))}c.append(g)}const d=f(e.meta);d&&c.append(l("p",{class:"rui-media-card-meta"},[d]));const m=We(e.actions,r);return m&&(m.classList.add("rui-media-card-actions"),c.append(m)),n.append(c),n}};function Xc(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}function Sr(t,e="primary"){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg");if(i.setAttribute("class","rui-sparkline"),i.setAttribute("data-tone",e),i.setAttribute("viewBox","0 0 80 24"),i.setAttribute("width",String(80)),i.setAttribute("height",String(24)),i.setAttribute("aria-hidden","true"),t.length<2)return i;const o=Math.min(...t),s=Math.max(...t),c=s-o||1,u=80/(t.length-1),d=t.map((h,v)=>{const y=v*u,x=2+(s-h)/c*20;return[y,x]}).map(([h,v],y)=>`${y===0?"M":"L"}${h.toFixed(1)},${v.toFixed(1)}`).join(" "),m=`${d} L80,24 L0,24 Z`,g=document.createElementNS(n,"path");g.setAttribute("d",m),g.setAttribute("class","rui-sparkline-area"),i.appendChild(g);const b=document.createElementNS(n,"path");return b.setAttribute("d",d),b.setAttribute("class","rui-sparkline-line"),b.setAttribute("fill","none"),i.appendChild(b),i}const Jc={name:"Stats",description:'KPI strip or grid. Pass `items` as `{label, value, hint?, tone?, spark?}` objects for strip layout, or as `StatCard(...)` nodes when `layout="grid"`.',props:[{name:"items",type:"object[] | StatCard[]",description:"Stat objects or StatCard nodes when layout=grid"},{name:"layout",type:"string",optional:!0,enum:["strip","grid"],description:"strip = horizontal row; grid = responsive Grid"},{name:"columns",type:"number",optional:!0,description:"Preferred column count for grid layout (1–6)"},{name:"align",type:"string",optional:!0,enum:["start","center","end"],description:"Strip alignment (layout=strip only)"}],render:(t,e,r)=>{const a=$(e.items),n=a.some(c=>c&&typeof c=="object"&&c.__kind==="Component");if(f(e.layout,n?"grid":"strip")==="grid"){const c=e.columns?Math.max(1,Math.min(6,Math.floor(E(e.columns)))):0,u=on.render({__kind:"Component",name:"Grid",args:[],argMeta:[]},{children:a,columns:c>0?c:"auto",gap:"m"},r);return u.classList.add("rui-metric-grid"),u}const o=f(e.align,"start"),s=l("div",{class:"rui-stats","data-align":o});for(const c of a){const u=c??{},p=f(u.tone,"default"),d=l("div",{class:"rui-stats-item","data-tone":p});d.append(l("div",{class:"rui-stats-label"},[f(u.label)]));const m=l("div",{class:"rui-stats-value-row"});m.append(l("div",{class:"rui-stats-value"},[f(u.value)]));const g=$(u.spark).map(h=>Number(h)).filter(h=>Number.isFinite(h));g.length>1&&m.append(Sr(g,p)),d.append(m);const b=f(u.hint);b&&d.append(l("div",{class:"rui-stats-hint"},[b])),s.append(d)}return s}},Zc={name:"Tile",description:"Compact icon + label + optional value tile. Smaller and denser than `StatCard`, ideal for menu grids, quick-action panels, category directories, and category filters. Pair with `Grid` for uniform rows.",props:[{name:"label",type:"string"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"value",type:"string",optional:!0,description:"Secondary value rendered next to/under the label"},{name:"description",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:Le},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const a=typeof e.onClick=="function",i=l(a?"button":"div",{type:a?"button":null,class:"rui-tile","data-tone":f(e.tone,"default")}),o=j(e.icon,{className:"rui-tile-icon"});o&&i.append(o);const s=l("div",{class:"rui-tile-body"});s.append(l("div",{class:"rui-tile-label"},[f(e.label)]));const c=f(e.value);c&&s.append(l("div",{class:"rui-tile-value"},[c]));const u=f(e.description);return u&&s.append(l("div",{class:"rui-tile-description"},[u])),i.append(s),a&&(i.onclick=()=>r.invoke(e.onClick)),i}},vn={name:"Notification",description:"Inline notification card with title, message, time, optional avatar, and dismiss/action buttons. Use inside notification panels, inboxes, or activity drawers — for top-of-page announcements prefer `Banner`.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"time",type:"string",optional:!0,description:"Relative or absolute timestamp"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"],description:"Avatar URL (alternative to `icon`)"},{name:"tone",type:"string",optional:!0,enum:Le},{name:"unread",type:"boolean",optional:!0,description:"Highlights the card with an accent"},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=A(e.unread),n=l("article",{class:"rui-notification","data-tone":f(e.tone,"default"),"data-unread":a?"true":"false"}),i=f(e.avatarSrc),o=l("div",{class:"rui-notification-visual"});if(i)o.append(ct(i,f(e.title),"md"));else{const g=j(f(e.icon,"bell"),{className:"rui-notification-icon"});g&&o.append(g)}n.append(o);const s=l("div",{class:"rui-notification-body"}),c=l("header",{class:"rui-notification-head"}),u=l("span",{class:"rui-notification-title-wrap"});a&&u.append(l("span",{class:"rui-notification-unread-dot","aria-label":"Unread"})),u.append(l("span",{class:"rui-notification-title"},[f(e.title)])),c.append(u);const p=f(e.time);p&&c.append(l("span",{class:"rui-notification-time"},[p])),s.append(c);const d=f(e.message);d&&s.append(l("p",{class:"rui-notification-message"},[d]));const m=We(e.actions,r);return m&&(m.classList.add("rui-notification-actions"),s.append(m)),n.append(s),n}},Qc={name:"PersonChip",description:'Inline avatar + name + optional role/meta pill. Use anywhere a person needs to be referenced compactly: table cells, list rows, comments, kanban cards, sidebar footers. Pair multiple chips with `Stack(direction="row", wrap=true)` for assignee lists.',props:[{name:"name",type:"string"},{name:"role",type:"string",optional:!0,description:"Sub-line below the name (role, email, handle, …)"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const a=typeof e.onClick=="function",n=a?"button":"div",i=f(e.size,"md"),o=i==="lg"?"lg":i==="sm"?"sm":"md",s=l(n,{type:a?"button":null,class:"rui-person-chip","data-size":i}),c=l("span",{class:"rui-person-chip-avatar"});c.append(ct(f(e.avatarSrc),f(e.name),o));const u=f(e.status);u&&c.append(l("span",{class:"rui-person-chip-status","data-status":u})),s.append(c);const p=l("div",{class:"rui-person-chip-meta"});p.append(l("span",{class:"rui-person-chip-name"},[f(e.name)]));const d=f(e.role);return d&&p.append(l("span",{class:"rui-person-chip-role"},[d])),s.append(p),a&&(s.onclick=()=>r.invoke(e.onClick)),s}},yn=["left","center","right"],eu={name:"Col",description:'Single column inside a Table or DataGrid. Use `align` for per-column text alignment, `format` for cell rendering (`text|number|currency|date`). `values` may be plain values OR an array of component nodes — e.g. `Col("Status", rows.map(r => Badge(r.status)))` or `Col("Actions", rows.map(r => Button("Edit")))` — each component renders directly in its cell. Pass `render: (value, index) => …` for the same effect when you prefer to keep `values` as the raw row data (return a component, string, or array). Pass `onClick: (value, index) => …` to make the whole cell clickable (pointer + keyboard). `sortable` and `filterable` only take effect inside `DataGrid` (Table ignores them).',props:[{name:"header",type:"string"},{name:"values",type:"any[]",description:"Column values. Plain values are formatted as text; component nodes (e.g. `rows.map(r => Badge(r.status))`) render directly. You can also pass the full row array and map each cell with `render`."},{name:"format",type:"string",optional:!0,enum:["text","number","currency","date"]},{name:"align",type:"string",optional:!0,enum:yn,description:"Per-column horizontal alignment"},{name:"sortable",type:"boolean",optional:!0,description:"DataGrid: enable click-to-sort on this column"},{name:"filterable",type:"boolean",optional:!0,description:"DataGrid: enable a per-column filter chip"},{name:"render",type:"callable",optional:!0,aliases:["cell"],description:"`(value, index) => Component | string | array` — map each cell to arbitrary content (buttons, badges, links)."},{name:"onClick",type:"callable",optional:!0,aliases:["onclick","cellClick"],description:"`(value, index) => void` — fired when a cell in this column is clicked or activated via keyboard."}],render:(t,e)=>{const r=l("div",{class:"rui-col"});return r.append(l("strong",{},[f(e.header)])),r}},tu={name:"Table",description:'Tabular data view. Children must be Col components. `density="compact"` tightens row padding for dense data, `striped=true` zebra-stripes the rows, and `sticky=true` pins the header row when the table scrolls. The empty-state row uses `emptyLabel` when set.',props:[{name:"columns",type:"Col[]"},{name:"caption",type:"string",optional:!0,aliases:["title"]},{name:"density",type:"string",optional:!0,enum:["comfortable","compact"],description:"Row padding (default `comfortable`)"},{name:"striped",type:"boolean",optional:!0,description:"Zebra-stripe alternating rows"},{name:"sticky",type:"boolean",optional:!0,description:"Pin the header row when the table scrolls"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when the table has no rows (default `No data`)"}],render:(t,e,r)=>{const a=$(e.columns),n=f(e.density,"comfortable"),i=A(e.striped),o=A(e.sticky),s=l("div",{class:"rui-table-wrapper","data-density":n,"data-striped":i?"true":"false","data-sticky":o?"true":"false"}),c=l("table",{class:"rui-table"}),u=f(e.caption);u&&c.append(l("caption",{class:"rui-table-caption"},[u]));const p=a.map(w=>{const k=f(w.args?.[3],"");return yn.includes(k)?k:""}),d=l("thead"),m=l("tr");for(let w=0;w<a.length;w+=1){const k=a[w],T=l("th",{"data-align":p[w]||null},[f(k.args?.[0])]);m.append(T)}d.append(m),c.append(d);const g=l("tbody"),b=a.map(w=>$(w.args?.[1])),h=a.map(w=>f(w.args?.[2],"text")),v=a.map(w=>w.args?.[6]),y=a.map(w=>w.args?.[7]),x=Math.max(0,...b.map(w=>w.length));for(let w=0;w<x;w+=1){const k=l("tr");b.forEach((T,S)=>{const C=h[S]??"text",N=p[S],I=l("td",{"data-format":C,"data-align":N||null});fr(I,{format:C,render:v[S],onClick:y[S]},T[w],w,r,cu),k.append(I)}),g.append(k)}if(x===0){const w=l("tr"),k=f(e.emptyLabel,"No data");w.append(l("td",{colspan:String(a.length||1),class:"rui-table-empty"},[k])),g.append(w)}return c.append(g),s.append(c),s}},ru={name:"ListItem",description:"Single list item with optional title and description.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0,aliases:["meta"]},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name"}],render:(t,e)=>{const r=l("li",{class:"rui-list-item"}),a=j(e.icon,{className:"rui-list-icon"});a&&r.append(a);const n=l("div",{class:"rui-list-text"});n.append(l("div",{class:"rui-list-title"},[f(e.title)]));const i=f(e.description);return i&&n.append(l("div",{class:"rui-list-description"},[i])),r.append(n),r}},au={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=A(e.ordered)?"ol":"ul",n=l(a,{class:"rui-list"});for(const i of $(e.items))n.append(r.renderNode(i));return n}},nu={name:"StatCard",description:"Single KPI card with label, value, optional delta, optional icon, and optional inline sparkline (`spark=[…numbers]`). Use inside `Stats` for a uniform KPI strip.",props:[{name:"label",type:"string"},{name:"value",type:"string"},{name:"trend",type:"string",optional:!0,enum:["up","down","flat"]},{name:"delta",type:"string",optional:!0,description:"Change vs previous period"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a chip beside the label"},{name:"spark",type:"number[]",optional:!0,description:"Optional inline sparkline values"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]}],render:(t,e)=>{const r=f(e.tone,"default"),a=l("div",{class:"rui-stat-card","data-tone":r}),n=l("div",{class:"rui-stat-label-row"}),i=f(e.label),o=f(e.icon)||mn(i)||"",s=j(o,{className:"rui-stat-icon"});s&&n.append(s),n.append(l("div",{class:"rui-stat-label"},[i])),a.append(n),a.append(l("div",{class:"rui-stat-value"},[f(e.value)]));const c=f(e.delta),u=f(e.trend);(c||u)&&a.append(l("div",{class:"rui-stat-trend","data-trend":u||"flat"},[c||lu(u)]));const p=$(e.spark).map(d=>E(d));if(p.length>1){const d=l("div",{class:"rui-stat-spark"});d.append(Sr(p,r==="default"?"primary":r)),a.append(d)}return a}},iu={name:"Sparkline",description:"Tiny inline trend chart for KPIs, table cells, and dashboards. Renders an SVG line with a soft fill — use anywhere you would otherwise reach for `LineChart` but a single value series should stay inline with surrounding text.",props:[{name:"values",type:"number[]"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]}],render:(t,e)=>{const r=f(e.tone,"primary"),a=$(e.values).map(i=>E(i)),n=l("span",{class:"rui-sparkline-wrap"});return n.append(Sr(a,r)),n}},ou={name:"TreeNode",description:"Single node in a Tree view. When `children` is provided the node renders as an expandable branch with a chevron; otherwise it renders as a leaf. `onClick` fires on click. Use `active=true` to highlight the current selection.",props:[{name:"label",type:"string"},{name:"children",type:"TreeNode[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon shown before the label"},{name:"expanded",type:"boolean",optional:!0,description:"Whether the branch is open by default"},{name:"active",type:"boolean",optional:!0,aliases:["selected"],description:"Highlights the row as the current selection"},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable fired when the row is clicked"}],render:(t,e,r)=>{const a=$(e.children),n=a.length>0,i=A(e.expanded),o=A(e.active),s=typeof e.onClick=="function",c=l(s?"button":"div",{type:s?"button":null,class:"rui-tree-node-row",role:"treeitem","data-active":o?"true":"false","aria-expanded":n?i?"true":"false":null});if(n){const b=j("chevron-right",{className:"rui-tree-node-chevron"});b&&c.append(b)}else c.append(l("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const u=j(e.icon,{className:"rui-tree-node-icon"});u&&c.append(u),c.append(l("span",{class:"rui-tree-node-label"},[f(e.label)]));const p=f(e.badge);if(p&&c.append(l("span",{class:"rui-tree-node-badge"},[p])),s&&(c.onclick=()=>r.invoke(e.onClick)),!n)return c;const d=l("details",{class:"rui-tree-node"});i&&d.setAttribute("open","");const m=l("summary",{class:"rui-tree-node-summary"});m.append(c),s&&(m.onclick=b=>{b.target?.closest(".rui-tree-node-chevron")||b.preventDefault()}),d.append(m);const g=l("div",{class:"rui-tree-node-children",role:"group"});for(const b of a)g.append(r.renderNode(b));return d.append(g),d}},su={name:"Tree",description:"Hierarchical tree view. Children must be TreeNode entries. Use for file browsers, nested navigation, category pickers, and any parent/child structure with arbitrary depth.",props:[{name:"items",type:"TreeNode[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-tree",role:"tree"});for(const n of $(e.items))a.append(r.renderNode(n));return a}};function lu(t){return t==="up"?"▲":t==="down"?"▼":"—"}function cu(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():f(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):f(t);case"date":try{const r=new Date(f(t));return Number.isNaN(r.getTime())?f(t):r.toLocaleDateString()}catch{return f(t)}default:return f(t)}}const $r=["var(--rui-chart-1, #6366f1)","var(--rui-chart-2, #10b981)","var(--rui-chart-3, #f59e0b)","var(--rui-chart-4, #ef4444)","var(--rui-chart-5, #06b6d4)","var(--rui-chart-6, #8b5cf6)"],at=t=>$r[t%$r.length]??$r[0],uu={name:"Series",description:"Named data series for charts. Used inside BarChart, LineChart, PieChart.",props:[{name:"name",type:"string"},{name:"values",type:"number[]"}],render:(t,e)=>l("span",{class:"rui-series","data-name":f(e.name)})},xn=t=>t.map((e,r)=>{const a=e,n=f(a.args?.[0],`Series ${r+1}`),i=$(a.args?.[1]).map(o=>E(o));return{name:n,values:i}}),du={name:"BarChart",description:"Vertical bar chart. `labels` define the x-axis, `series` define grouped bars.",props:[{name:"labels",type:"string[]"},{name:"series",type:"Series[]"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=$(e.labels).map(y=>f(y)),a=xn($(e.series)),n=l("div",{class:"rui-chart rui-bar-chart"});f(e.title)&&n.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const i=Math.max(1,...a.flatMap(y=>y.values)),o=640,s=240,c=kn(r,o-40-12),u={left:40,right:12,top:12,bottom:c.bottomPadding},p=o-u.left-u.right,d=s-u.top-u.bottom,m=Cr(o,s);$n(m,u,p,d,i);const g=r.length,b=p/Math.max(g,1),h=a.length,v=b*.7/Math.max(h,1);return a.forEach((y,x)=>{y.values.forEach((w,k)=>{const T=w/i*d,S=u.left+k*b+b*.15+x*v,C=u.top+d-T,N=ve("rect",{x:String(S),y:String(C),width:String(Math.max(v-2,1)),height:String(T),fill:at(x),rx:"2"});N.append(ve("title",{},[`${y.name}: ${w}`])),m.append(N)})}),Sn(m,r,u,p,d,c,y=>u.left+(y+.5)*b),n.append(m),a.length>0&&n.append(Ar(a)),n}},pu={name:"LineChart",description:'Line chart. `labels` define the x-axis, each Series is a line. As a shortcut you can pass `data=[{x: "Jan", revenue: 12, signups: 4}, …]` and the labels + series will be derived automatically (one line per non-`x` key). Use `data` when the dataset is already row-shaped; use `series` when you have explicit Series objects.',props:[{name:"labels",type:"string[]",optional:!0},{name:"series",type:"Series[]",optional:!0},{name:"data",type:"{x: string, [key: string]: number}[]",optional:!0,description:"Row-shaped data — labels and series are auto-derived"},{name:"title",type:"string",optional:!0},{name:"filled",type:"boolean",optional:!0,description:"Fill the area beneath each line (area-chart style)"},{name:"stacked",type:"boolean",optional:!0,description:"Stack series when filled=true"}],render:(t,e)=>{let r=$(e.labels).map(C=>f(C)),a=xn($(e.series));const n=$(e.data);if(n.length>0&&(r.length===0||a.length===0)){const C=[],N=new Map;for(const I of n){const L=I;if(!(!L||typeof L!="object")){C.push(f(L.x??L.label??""));for(const[R,q]of Object.entries(L)){if(R==="x"||R==="label")continue;const O=E(q);Number.isNaN(O)||(N.has(R)||N.set(R,[]),N.get(R).push(O))}}}r.length===0&&(r=C),a.length===0&&(a=[...N.entries()].map(([I,L])=>({name:I,values:L})))}const i=e.filled===!0,o=e.stacked===!0,s=Math.max(r.length,...a.map(C=>C.values.length),1),c=a.map(()=>Array(s).fill(0));if(i&&o)for(let C=0;C<s;C+=1){let N=0;a.forEach((I,L)=>{N+=I.values[C]??0,c[L][C]=N})}const u=l("div",{class:"rui-chart rui-line-chart","data-filled":i?"true":"false"});f(e.title)&&u.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const p=i&&o?c.flat():a.flatMap(C=>C.values),d=Math.max(1,...p),m=i&&o?0:Math.min(0,...p),g=640,b=240,h=kn(r,g-40-12),v={left:40,right:12,top:12,bottom:h.bottomPadding},y=g-v.left-v.right,x=b-v.top-v.bottom,w=Cr(g,b);$n(w,v,y,x,d,m);const k=Math.max(r.length-1,1),T=y/k,S=C=>v.left+C*(y/Math.max(s-1,1));return a.forEach((C,N)=>{const I=i&&o?c[N]:C.values,L=i&&o&&N>0?c[N-1]:null,R=I.map((O,U)=>{const J=S(U),Z=v.top+x-(O-m)/(d-m||1)*x;return[J,Z]});if(i&&R.length>0){let O=R.map(([U,J],Z)=>`${Z===0?"M":"L"}${U.toFixed(1)},${J.toFixed(1)}`).join(" ");if(L){const U=L.map((J,Z)=>{const me=S(Z),$e=v.top+x-(J-m)/(d-m||1)*x;return[me,$e]});O+=" "+U.slice().reverse().map(([J,Z])=>`L${J.toFixed(1)},${Z.toFixed(1)}`).join(" ")+" Z"}else{const U=R[0],J=R[R.length-1];O+=` L${J[0].toFixed(1)},${(v.top+x).toFixed(1)} L${U[0].toFixed(1)},${(v.top+x).toFixed(1)} Z`}w.append(ve("path",{d:O,fill:at(N),"fill-opacity":"0.2",stroke:"none"}))}const q=R.map(([O,U],J)=>`${J===0?"M":"L"}${O.toFixed(1)},${U.toFixed(1)}`).join(" ");w.append(ve("path",{d:q,fill:"none",stroke:at(N),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),C.values.length<=30&&R.forEach(([O,U])=>{w.append(ve("circle",{cx:String(O),cy:String(U),r:"3",fill:at(N)}))})}),Sn(w,r,v,y,x,h,C=>v.left+C*T),u.append(w),a.length>0&&u.append(Ar(a)),u}},mu={name:"PieChart",description:'Pie / Donut chart. Each segment maps to a label/value pair. Numeric labels are rendered on every segment by default — set `showValues: false` to hide them, or `valueFormat: "percent"` to show the share instead of the raw value.',props:[{name:"labels",type:"string[]"},{name:"values",type:"number[]"},{name:"title",type:"string",optional:!0},{name:"showValues",type:"boolean",optional:!0,description:"Render numeric labels on each slice (default true)"},{name:"valueFormat",type:"string",optional:!0,enum:["value","percent","both"],description:'How to format the on-segment label (default "value")'}],render:(t,e)=>{const r=$(e.labels).map(h=>f(h)),a=$(e.values).map(h=>E(h)),n=e.showValues==null?!0:A(e.showValues),i=f(e.valueFormat,"value").toLowerCase(),o=i==="percent"?"percent":i==="both"?"both":"value",s=l("div",{class:"rui-chart rui-pie-chart"});f(e.title)&&s.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const c=a.reduce((h,v)=>h+(v>0?v:0),0)||1,u=Cr(240,240),p=120,d=120,m=90,g=.05;let b=-Math.PI/2;return a.forEach((h,v)=>{const y=h>0?h:0,x=y/c,w=x*Math.PI*2,k=b+w,T=w>Math.PI?1:0,S=p+m*Math.cos(b),C=d+m*Math.sin(b),N=p+m*Math.cos(k),I=d+m*Math.sin(k),L=`M${p},${d} L${S},${C} A${m},${m} 0 ${T} 1 ${N},${I} Z`,R=ve("path",{d:L,fill:at(v),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});if(R.append(ve("title",{},[`${r[v]??""}: ${h} (${(x*100).toFixed(1)}%)`])),u.append(R),n&&y>0&&x>=g){const q=b+w/2,O=m*.62,U=p+O*Math.cos(q),J=d+O*Math.sin(q),Z=fu(h,x,o),me=ve("text",{x:String(U),y:String(J),class:"rui-pie-chart-value","text-anchor":"middle","dominant-baseline":"central","paint-order":"stroke",stroke:"rgba(15, 23, 42, 0.55)","stroke-width":"3","stroke-linejoin":"round",fill:"#fff"},[Z]);u.append(me)}b=k}),s.append(u),s.append(Ar(r.map((h,v)=>({name:h,values:[a[v]??0]})))),s}};function fu(t,e,r){const a=`${Math.round(e*100)}%`,n=gu(t);return r==="percent"?a:r==="both"?`${n} (${a})`:n}function gu(t){if(!Number.isFinite(t))return String(t);const e=Math.abs(t);return e>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:e>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}k`:Number.isInteger(t)?String(t):t.toFixed(1)}const hu=7,wn=12;function kn(t,e){if(t.length===0)return{step:1,rotated:!1,maxChars:32,bottomPadding:32};const r=e/Math.max(t.length,1),a=t.reduce((o,s)=>Math.max(o,s.length),0);if(a*hu+4<=r)return{step:1,rotated:!1,maxChars:a,bottomPadding:32};const n=r<wn?Math.max(1,Math.ceil(wn/r)):1,i=Math.min(a,14);return{step:n,rotated:!0,maxChars:i,bottomPadding:60}}function bu(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function Sn(t,e,r,a,n,i,o){const s=r.top+n+(i.rotated?14:18);e.forEach((c,u)=>{if(u%i.step!==0)return;const p=o(u),d=bu(c,i.maxChars),m={x:String(p),y:String(s),class:"rui-chart-label","text-anchor":i.rotated?"end":"middle"};i.rotated&&(m.transform=`rotate(-45, ${p}, ${s})`);const g=ve("text",m,[d]);d!==c&&g.append(ve("title",{},[c])),t.append(g)})}function Cr(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("viewBox",`0 0 ${t} ${e}`),r.setAttribute("class","rui-chart-svg"),r.setAttribute("role","img"),r}function ve(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[n,i]of Object.entries(e))a.setAttribute(n,i);if(r)for(const n of r)a.append(typeof n=="string"?document.createTextNode(n):n);return a}function $n(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const c=s/4,u=e.top+a-c*a;t.append(ve("line",{x1:String(e.left),x2:String(e.left+r),y1:String(u),y2:String(u),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ve("text",{x:String(e.left-6),y:String(u+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((i+(n-i)*c)*10)/10)]))}}function Ar(t){const e=l("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const n=l("span",{class:"rui-chart-legend-item"});n.append(l("span",{class:"rui-chart-legend-swatch",style:`background:${at(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const vu={name:"SectionBlock",description:"Titled chat block with a description and child content.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"description",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("section",{class:"rui-section-block"});a.append(l("h3",{class:"rui-section-block-title"},[f(e.title)]));const n=f(e.description);n&&a.append(l("p",{class:"rui-section-block-description"},[n]));for(const i of $(e.children))a.append(r.renderNode(i));return a}},yu={name:"ListBlock",description:"Chat-styled list with bullets, useful for steps or summaries.",props:[{name:"items",type:"string[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e)=>{const r=A(e.ordered)?"ol":"ul",a=l(r,{class:"rui-list-block"});for(const n of $(e.items))a.append(l("li",{},[f(n)]));return a}},xu={name:"FollowUpBlock",description:'Suggested follow-up prompts shown as buttons. Each item dispatches its label as an assistant message (equivalent to `emit "assistant-message" { message }`).',props:[{name:"items",type:"FollowUpItem[]",description:"Array of FollowUpItem(label, message?), {label, message} objects, or plain strings"},{name:"title",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-follow-up"}),n=f(e.title,"You can also ask");n&&a.append(l("div",{class:"rui-follow-up-title"},[n]));const i=l("div",{class:"rui-follow-up-list"});for(const o of $(e.items))i.append(wu(o,r));return a.append(i),a}},wu=(t,e)=>{const{label:r,message:a}=ku(t),n=l("button",{class:"rui-follow-up-button",type:"button"},[r]);return n.onclick=()=>{e.sendToAssistant(a)},n},ku=t=>{if(typeof t=="string")return{label:t,message:t};if(t&&typeof t=="object"){const r=t;if(r.__kind==="Component"&&Array.isArray(r.args)){const i=f(r.args[0]),o=f(r.args[1],i);return{label:i,message:o}}const a=f(r.label),n=f(r.message,a);return{label:a,message:n}}const e=f(t);return{label:e,message:e}},Su={name:"FollowUpItem",description:"Single follow-up item.",props:[{name:"label",type:"string"},{name:"message",type:"string",optional:!0,description:"Defaults to label"}],render:(t,e,r)=>{const a=f(e.label),n=f(e.message,a),i=l("button",{class:"rui-follow-up-button",type:"button"},[a]);return i.onclick=()=>{r.sendToAssistant(n)},i}},$u={name:"ActionLink",description:"Inline link that runs an action when clicked instead of navigating.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",aliases:["action","onclick"]}],render:(t,e,r)=>{const a=l("a",{class:"rui-action-link",href:"#",role:"button"},[f(e.label)]);return a.onclick=n=>{n.preventDefault(),r.invoke(e.onClick)},a}},Cn=["xs","sm","md","lg","xl"],An={name:"Avatar",description:'User avatar. Shows the image at `src`. When `src` is missing, falls back to a deterministic DiceBear illustration seeded by `name` (pass `fallback="initials"` to render two-letter initials instead). If the image errors at runtime the avatar gracefully degrades to initials.',props:[{name:"name",type:"string",description:"Used for alt text + initials fallback"},{name:"src",type:"string",optional:!0,description:"Image URL"},{name:"size",type:"string",optional:!0,enum:Cn},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"fallback",type:"string",optional:!0,enum:["initials","dicebear"],description:"How to render when `src` is missing (default: dicebear illustration; pass `initials` for the two-letter pill)"}],render:(t,e)=>{const r=f(e.size,"md"),a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=f(e.name),i=f(e.fallback,"dicebear"),o=ie(e.src),s=!o&&i==="dicebear"&&n?ie(Dl(n)):"",c=o||s;if(c){const p=l("img",{src:c,alt:n,loading:"lazy"});p.onerror=d=>{const m=d;(m.currentTarget??m.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[ut(n)]))},a.append(p)}else a.append(l("span",{class:"rui-avatar-fallback"},[ut(n)]));const u=f(e.status);return u&&a.append(l("span",{class:"rui-avatar-status","data-status":u})),a}},Cu={name:"AvatarGroup",description:"Stack of overlapping avatars with a `+N` chip when the list overflows. Pass either Avatar(...) nodes or plain {name, src} objects.",props:[{name:"items",type:"Avatar[]",description:"Avatar(...) nodes or {name, src} objects"},{name:"max",type:"number",optional:!0,description:"Maximum avatars to show (default 4)"},{name:"size",type:"string",optional:!0,enum:Cn}],render:(t,e,r)=>{const a=$(e.items),n=Math.max(1,Math.floor(Number(e.max??4))),i=f(e.size,"md"),o=a.slice(0,n),s=a.length-o.length,c=l("div",{class:"rui-avatar-group","data-size":i});for(const u of o){if(u&&typeof u=="object"&&u.__kind==="Component"){c.append(r.renderNode(u));continue}const p=u,d=typeof p=="string"?p:f((p??{}).name),m=typeof p=="string"?"":f((p??{}).src);c.append(An.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:d,src:m,size:i},r))}return s>0&&c.append(l("span",{class:"rui-avatar rui-avatar-overflow","data-size":i},[l("span",{class:"rui-avatar-fallback"},[`+${s}`])])),c}},Au={name:"Progress",description:"Linear progress bar. `value` is clamped between 0 and `max` (default 100). `indeterminate=true` renders a looping animation when the total is unknown. Provide `segments` to render a segmented progress strip (steps in an onboarding flow), or `buffered` for a secondary buffer indicator (downloads, video buffering).",props:[{name:"value",type:"number",optional:!0,description:"Current progress; ignored when indeterminate"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"label",type:"string",optional:!0,description:"Shown above the bar"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"indeterminate",type:"boolean",optional:!0},{name:"showValue",type:"boolean",optional:!0,description:"Show the numeric value on the right"},{name:"segments",type:"number",optional:!0,description:"Render N equal segments (filled by current step)"},{name:"buffered",type:"number",optional:!0,description:"Secondary value (0..max) drawn behind the bar"}],render:(t,e)=>{const r=Math.max(1,E(e.max,100)),a=A(e.indeterminate),n=Math.max(0,Math.min(r,E(e.value,0))),i=Math.round(n/r*100),o=Math.max(0,Math.floor(E(e.segments,0))),s=e.buffered!=null?Math.max(0,Math.min(r,E(e.buffered,0))):null,c=l("div",{class:"rui-progress","data-tone":f(e.tone,"primary")}),u=f(e.label),p=A(e.showValue);if(u||p){const m=l("div",{class:"rui-progress-head"});if(m.append(l("span",{class:"rui-progress-label"},[u])),p&&!a){const g=o>0?`${Math.min(o,Math.round(n/r*o))} / ${o}`:`${i}%`;m.append(l("span",{class:"rui-progress-value"},[g]))}c.append(m)}if(o>0&&!a){const m=l("div",{class:"rui-progress-segments",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(o),"aria-valuenow":String(Math.min(o,Math.round(n/r*o)))}),g=Math.min(o,Math.round(n/r*o));for(let b=0;b<o;b+=1)m.append(l("span",{class:"rui-progress-segment","data-filled":b<g?"true":"false"}));return c.append(m),c}const d=l("div",{class:"rui-progress-track",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(r),"aria-valuenow":a?null:String(n),"data-indeterminate":a?"true":"false"});if(s!==null){const m=Math.round(s/r*100);d.append(l("div",{class:"rui-progress-buffer",style:`width:${m}%`,"aria-hidden":"true"}))}return d.append(l("div",{class:"rui-progress-bar",style:a?"":`width:${i}%`})),c.append(d),c}},Tu={name:"Switch",description:"Compact on/off toggle. Pass a `$variable` as `value` for two-way binding — prefer Switch over Checkbox when the control represents a setting. `onChange(checked)` fires with the new boolean.",props:[{name:"id",type:"string"},{name:"label",type:"string",optional:!0},{name:"value",type:"boolean",optional:!0,aliases:["checked"],description:"Bound value (typically $variable)"},{name:"description",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new boolean value"}],render:(t,e,r)=>{const a=f(e.id),n=l("label",{class:"rui-switch",for:a,"data-disabled":A(e.disabled)?"true":"false"}),i=A(e.value),o=l("input",{type:"checkbox",id:a,name:a,class:"rui-switch-input",role:"switch",checked:i?"":null,disabled:A(e.disabled)?"":null});o.checked=i;const s=l("span",{class:"rui-switch-track"},[l("span",{class:"rui-switch-thumb"})]),c=t.argMeta?.[2]?.stateRef;c&&r.bindState(o,c,{event:"change",getValue:d=>d.checked}),e.onChange!=null&&o.addEventListener("change",d=>{r.invoke(e.onChange,d.currentTarget.checked)});const u=f(e.label),p=f(e.description);if(n.append(o,s),u||p){const d=l("span",{class:"rui-switch-meta"});u&&d.append(l("span",{class:"rui-switch-label"},[u])),p&&d.append(l("span",{class:"rui-switch-description"},[p])),n.append(d)}return n}},Mu={name:"ToggleGroup",description:"Group of mutually-exclusive Toggle-style buttons (single-select). Items are `[value, label]` arrays, `{value, label, icon?}` objects, or plain strings (used for both value and label). Pass a `$variable` as `value` for two-way binding. `onChange(value)` fires with the newly-selected value.",props:[{name:"id",type:"string"},{name:"items",type:"any[]"},{name:"value",type:"any",optional:!0},{name:"variant",type:"string",optional:!0,enum:["default","outline"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{const a=f(e.value),n=f(e.variant,"outline"),i=f(e.size,"md"),o=l("div",{class:"rui-toggle-group",role:"radiogroup","data-variant":n,"data-size":i}),s=t.argMeta?.[2]?.stateRef;for(const c of $(e.items)){const{value:u,label:p,icon:d}=Nu(c),m=u===a,g=l("button",{type:"button",class:"rui-toggle",role:"radio","aria-checked":m?"true":"false","data-variant":n,"data-size":i,"data-state":m?"on":"off","data-value":u}),b=j(d,{className:"rui-toggle-icon"});b&&g.append(b),g.append(l("span",{class:"rui-toggle-label"},[p])),g.onclick=()=>{s&&r.setState(s,u),r.invoke(e.onChange,u)},o.append(g)}return o}};function Nu(t){if(typeof t=="string")return{value:t,label:t,icon:""};if(Array.isArray(t))return{value:f(t[0]),label:f(t[1],f(t[0])),icon:f(t[2])};if(t&&typeof t=="object"){const e=t,r=f(e.value);return{value:r,label:f(e.label,r),icon:f(e.icon)}}return{value:"",label:"",icon:""}}const Pu={name:"Tooltip",description:"Wraps a trigger node and shows `label` text when the user hovers or focuses it. Pure CSS — no JS needed. The tooltip hides on click/touch (so it does not stay stuck on touch devices) and supports `top|bottom|left|right` placement. Use for short hints (≤6 words); reach for HoverCard when you need rich content.",props:[{name:"label",type:"string"},{name:"trigger",type:"Node",aliases:["children"]},{name:"side",type:"string",optional:!0,enum:["top","bottom","left","right"],aliases:["placement"]}],render:(t,e,r)=>{const a=f(e.side,"top"),n=l("span",{class:"rui-tooltip","data-side":a,tabindex:"0"});n.append(l("span",{class:"rui-tooltip-trigger"},[r.renderNode(e.trigger)]));const i=l("span",{class:"rui-tooltip-content",role:"tooltip"},[f(e.label)]);return i.append(l("span",{class:"rui-tooltip-arrow","aria-hidden":"true"})),n.append(i),n.addEventListener("mousedown",()=>{requestAnimationFrame(()=>{(document.activeElement===n||n.contains(document.activeElement))&&document.activeElement?.blur?.()})}),n}},Iu={name:"HoverCard",description:"Wraps a trigger node and reveals a card with rich content on hover/focus. Use for previewing a referenced item (profile, link target, definition).",props:[{name:"trigger",type:"Node"},{name:"content",type:"Node[]",aliases:["children"]},{name:"side",type:"string",optional:!0,enum:["top","bottom","left","right"],aliases:["placement"]},{name:"open",type:"boolean",optional:!0,description:"Force the card open (otherwise reveal on hover/focus)"}],render:(t,e,r)=>{const a=l("span",{class:"rui-hover-card","data-side":f(e.side,"bottom"),"data-open":A(e.open)?"true":null,tabindex:"0"});a.append(l("span",{class:"rui-hover-card-trigger"},[r.renderNode(e.trigger)]));const n=l("span",{class:"rui-hover-card-content",role:"dialog"});for(const i of $(e.content))n.append(r.renderNode(i));return a.append(n),a}},Tr={star:{full:"star",half:"star-half-stroke",empty:"regular:star"},heart:{full:"heart",half:"heart",empty:"regular:heart"},thumb:{full:"thumbs-up",half:"thumbs-up",empty:"regular:thumbs-up"},fire:{full:"fire",half:"fire",empty:"regular:fire"},bolt:{full:"bolt",half:"bolt",empty:"regular:bolt"}},Eu={name:"Rating",description:"Compact 0–5 star rating with optional numeric badge and review count. Use in product cards, testimonials, reviews, and KPI rows. Pass `interactive: true` (or an `onChange` handler) to let users pick a rating; bind `value: $rating` for two-way binding, or read the new value from `onChange: (v) => …`. With `halfStep: true` clicking the left half of a star sets a fractional value. `icon` swaps the glyph family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any custom Font Awesome name.",props:[{name:"value",type:"number",description:"0–max; can be a $variable when interactive"},{name:"max",type:"number",optional:!0,description:"Maximum number of stars (default 5)"},{name:"label",type:"string",optional:!0,description:'Inline text shown after the stars (e.g. "4.2 of 5")'},{name:"count",type:"number",optional:!0,description:"Review/voter count rendered in parentheses"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"interactive",type:"boolean",optional:!0,description:"Allow clicking a star to set the value"},{name:"readonly",type:"boolean",optional:!0,description:"Force read-only (overrides `interactive`)"},{name:"halfStep",type:"boolean",optional:!0,description:"Allow half-star resolution when interactive"},{name:"icon",type:"string",optional:!0,description:"Icon family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any FA name"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new rating when the user clicks a star (interactive mode)"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(E(e.max,5))),n=f(e.size,"md"),i=A(e.halfStep),o=t.argMeta?.[0]?.stateRef,s=(A(e.interactive)||e.onChange!=null)&&!A(e.readonly),u=s&&!o?r.useInstanceState("rating-value",E(e.value,0)):null,p=E(u?u.get():e.value,0),d=Math.max(0,Math.min(a,p)),m=zu(f(e.icon)),g=l("div",{class:"rui-rating","data-size":n,"data-interactive":s?"true":"false","data-half-step":s&&i?"true":"false",role:"img","aria-label":`${d} of ${a}`}),b=l("span",{class:"rui-rating-stars"});for(let y=1;y<=a;y+=1){const x=Math.max(0,Math.min(1,d-(y-1))),w=x>=1?m.full:x>0?m.half:m.empty,k=Pt(w).join(" "),T=l(s?"button":"span",{class:`rui-rating-star ${k}`.trim(),type:s?"button":null,"data-fill":x>=1?"full":x>0?"half":"empty","aria-label":s?`Rate ${y}`:null,"aria-hidden":s?null:"true"});if(s){const S=y,C=y-.5;T.onclick=N=>{const I=N,L=I.currentTarget??I.target;let R=S;if(i){const q=L.getBoundingClientRect();q.width>0&&I.clientX-q.left<q.width/2&&(R=C)}o&&r.setState(o,R),u&&u.set(R),Lu(L.closest(".rui-rating"),R,a,m),r.invoke(e.onChange,R)}}b.append(T)}g.append(b);const h=f(e.label);h&&g.append(l("span",{class:"rui-rating-label"},[h]));const v=e.count!=null?E(e.count,0):null;return v!==null&&v>0&&g.append(l("span",{class:"rui-rating-count"},[`(${v.toLocaleString()})`])),g}};function Lu(t,e,r,a){if(!t)return;t.querySelectorAll(".rui-rating-star").forEach((i,o)=>{const s=Math.max(0,Math.min(1,e-o)),c=s>=1?a.full:s>0?a.half:a.empty;i.setAttribute("data-fill",s>=1?"full":s>0?"half":"empty"),i.className=`rui-rating-star ${Pt(c).join(" ")}`.trim()}),t.setAttribute("aria-label",`${Math.max(0,Math.min(r,e))} of ${r}`)}function zu(t){const e=t.trim().toLowerCase();return e?Tr[e]?Tr[e]:{full:e,half:e,empty:`regular:${e}`}:Tr.star}const Ru={name:"ProgressRing",description:"Circular progress indicator. Use for KPIs, quotas, completion rings, and any metric better shown as a circle than a bar. Renders the value (or a custom label) inside the ring.",props:[{name:"value",type:"number",optional:!0,description:"Current value (ignored when indeterminate)"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"label",type:"string",optional:!0,description:'Text shown inside the ring (default "{percent}%")'},{name:"caption",type:"string",optional:!0,aliases:["description"],description:"Small caption rendered under the ring"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"indeterminate",type:"boolean",optional:!0}],render:(t,e)=>{const r=Math.max(1,E(e.max,100)),a=A(e.indeterminate),n=Math.max(0,Math.min(r,E(e.value,0))),i=Math.round(n/r*100),o=f(e.size,"md"),s=o==="lg"?120:o==="sm"?72:96,c=o==="lg"?10:o==="sm"?6:8,u=(s-c)/2,p=2*Math.PI*u,d=a?p*.65:p*(1-i/100),m=l("div",{class:"rui-progress-ring","data-tone":f(e.tone,"primary"),"data-size":o,"data-indeterminate":a?"true":"false"}),g=l("div",{class:"rui-progress-ring-wrap"}),b="http://www.w3.org/2000/svg",h=document.createElementNS(b,"svg");h.setAttribute("width",String(s)),h.setAttribute("height",String(s)),h.setAttribute("viewBox",`0 0 ${s} ${s}`),h.setAttribute("class","rui-progress-ring-svg");const v=document.createElementNS(b,"circle");v.setAttribute("class","rui-progress-ring-track"),v.setAttribute("cx",String(s/2)),v.setAttribute("cy",String(s/2)),v.setAttribute("r",String(u)),v.setAttribute("stroke-width",String(c)),v.setAttribute("fill","none"),h.appendChild(v);const y=document.createElementNS(b,"circle");y.setAttribute("class","rui-progress-ring-bar"),y.setAttribute("cx",String(s/2)),y.setAttribute("cy",String(s/2)),y.setAttribute("r",String(u)),y.setAttribute("stroke-width",String(c)),y.setAttribute("fill","none"),y.setAttribute("stroke-linecap","round"),y.setAttribute("stroke-dasharray",String(p)),y.setAttribute("stroke-dashoffset",String(d)),h.appendChild(y),g.append(h);const x=f(e.label,a?"…":`${i}%`),w=l("span",{class:"rui-progress-ring-value"}),k=j(x,{className:"rui-progress-ring-icon"});k&&Pt(x).length>0?w.append(k):w.append(document.createTextNode(x)),g.append(w),m.append(g);const T=f(e.caption);return T&&m.append(l("span",{class:"rui-progress-ring-caption"},[T])),m}},Du={name:"ChatBubble",description:'Single chat-style message bubble with author, time, and body. Use for conversation threads, agent transcripts, support chats, and any message-style UI. Set `from="me"` (or any non-empty author) for the active speaker — the bubble aligns to the right with a primary tint. `from="agent"` (default) renders as the canonical incoming bubble on the left.',props:[{name:"author",type:"string"},{name:"body",type:"string",aliases:["text","message"]},{name:"time",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"from",type:"string",optional:!0,enum:["agent","me","system"],aliases:["role"],description:"Lane (default agent)"},{name:"status",type:"string",optional:!0,enum:["sending","sent","delivered","read","error"]}],render:(t,e)=>{const r=f(e.from,"agent"),a=l("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&a.append(Tn(f(e.avatarSrc),f(e.author)));const n=l("div",{class:"rui-chat-bubble-bubble"}),i=l("header",{class:"rui-chat-bubble-head"});i.append(l("span",{class:"rui-chat-bubble-author"},[f(e.author)]));const o=f(e.time);o&&i.append(l("span",{class:"rui-chat-bubble-time"},[o])),n.append(i),n.append(l("p",{class:"rui-chat-bubble-body"},[f(e.body)]));const s=f(e.status);return s&&n.append(l("span",{class:"rui-chat-bubble-status","data-status":s},[s])),a.append(n),r==="me"&&a.append(Tn(f(e.avatarSrc),f(e.author))),a}};function Tn(t,e){const r=l("span",{class:"rui-chat-bubble-avatar"}),a=ie(t);return a?r.append(l("img",{src:a,alt:e,loading:"lazy"})):r.append(l("span",{class:"rui-chat-bubble-fallback"},[ut(e)])),r}const ju={name:"Kbd",description:"Renders a keyboard shortcut chip (e.g. `Cmd+K`). Pass a single label, or multiple labels as an array to render a `key + key + …` combo.",props:[{name:"keys",type:"string | string[]"},{name:"size",type:"string",optional:!0,enum:["sm","md"]}],render:(t,e)=>{const r=f(e.size,"md"),a=l("span",{class:"rui-kbd-group","data-size":r});return(Array.isArray(e.keys)?e.keys:[e.keys]).forEach((i,o)=>{const s=f(i);s&&(o>0&&a.append(l("span",{class:"rui-kbd-sep"},["+"])),a.append(l("kbd",{class:"rui-kbd"},[s])))}),a}},Bu={name:"Popover",description:"Click-triggered popup with arbitrary rich content. Use when HoverCard's hover trigger is too eager and Modal/Sheet is too heavy — perfect for filter panels, color pickers, share menus, and small settings flyouts. The trigger stays visible while the popover is open — clicking it again, clicking outside, pressing Escape, or clicking the built-in × button all close it.",props:[{name:"trigger",type:"Node",description:"Clickable trigger element (Button, Avatar, IconButton, …). The trigger remains visible while the popover is open."},{name:"content",type:"Node[]",aliases:["children"],description:"Body rendered inside the popover"},{name:"title",type:"string",optional:!0,description:"Optional bold heading rendered above the content"},{name:"side",type:"string",optional:!0,enum:["bottom","top","left","right"],aliases:["placement"],description:'Where the popover opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:["start","center","end"],description:'Alignment along the trigger edge (default "start")'},{name:"width",type:"string",optional:!0,description:'CSS width for the popover panel (default "280px")'},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the popover"}],render:(t,e,r)=>{const a=A(e.open),n=r.useInstanceState("open",a),i=n.get(),o=re(e.width,""),s=l("div",{class:"rui-popover","data-open":i?"true":"false","data-side":f(e.side,"bottom"),"data-align":f(e.align,"start")}),c=l("span",{class:"rui-popover-trigger","data-state":i?"open":"closed","aria-haspopup":"dialog","aria-expanded":i?"true":"false"});c.append(r.renderNode(e.trigger)),s.append(c);const u=l("div",{class:"rui-popover-content",role:"dialog",style:o?`width: ${o};`:null}),p=l("div",{class:"rui-popover-header"}),d=f(e.title);p.append(d?l("div",{class:"rui-popover-title"},[d]):l("span",{class:"rui-popover-title-spacer"}));const m=l("button",{type:"button",class:"rui-popover-close","aria-label":"Close popover"},["×"]);m.onclick=g=>{g.stopPropagation(),Dt(m,!1,n)},p.append(m),u.append(p);for(const g of $(e.content))u.append(r.renderNode(g));return s.append(u),c.onclick=g=>{g.stopPropagation();const b=g.currentTarget??g.target,h=!n.get(),v=Dt(b,h,n);h&&v&&Mn(v,n)},c.onkeydown=g=>{const b=g,h=b.currentTarget??b.target;if(b.key==="Enter"||b.key===" "){b.preventDefault();const v=!n.get(),y=Dt(h,v,n);v&&y&&Mn(y,n)}else b.key==="Escape"&&n.get()&&(b.preventDefault(),Dt(h,!1,n))},s}},Dt=(t,e,r)=>{r.set(e);const a=t.closest(".rui-popover");if(!a)return null;a.setAttribute("data-open",e?"true":"false");const n=a.querySelector(".rui-popover-trigger");return n?.setAttribute("aria-expanded",e?"true":"false"),n?.setAttribute("data-state",e?"open":"closed"),e||Ne(a),a},Mn=(t,e)=>{rt({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false");const r=t.querySelector(".rui-popover-trigger");r?.setAttribute("aria-expanded","false"),r?.setAttribute("data-state","closed")}})},Ou={name:"Toast",description:"Single transient notification card. Always shows a close (×) button that removes the toast from the DOM (and fires `onClose` if set). Pass `duration` (ms) to auto-dismiss, or `position` for a standalone one-off toast (the renderer will pin it to the viewport corner so you do not have to wrap a single notification in `Stack(...)`). Use `Toasts` for grouped stacks; prefer `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"],description:'Visual accent (default "default")'},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name (default picked from tone)"},{name:"duration",type:"number",optional:!0,description:"Auto-dismiss after N milliseconds (e.g. 4000). Omit to keep the toast until the user closes it."},{name:"action",type:"Button",optional:!0,description:"Optional inline `Button` action shown above the message"},{name:"onClose",type:"callable",optional:!0,description:"Callable invoked when the toast is dismissed (× button, auto-dismiss, or programmatic)"},{name:"position",type:"string",optional:!0,enum:["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],description:"Pin a standalone Toast to a viewport corner without wrapping it in `Stack(...)`"}],render:(t,e,r)=>{const a=f(e.tone,"default"),n=f(e.position),i=l("div",{class:n?"rui-toast rui-toast-standalone":"rui-toast",role:a==="danger"?"alert":"status","aria-live":a==="danger"?"assertive":"polite","data-tone":a,"data-position":n||null}),o=f(e.icon)||_u(a),s=j(o,{className:"rui-toast-icon"});s&&i.append(s);const c=l("div",{class:"rui-toast-body"});c.append(l("div",{class:"rui-toast-title"},[f(e.title)]));const u=f(e.message);if(u&&c.append(l("div",{class:"rui-toast-message"},[u])),e.action){const x=l("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),c.append(x)}i.append(c);const p=r.useInstanceState("dismissed",!1),d=r.useInstanceState("timer",null),m=x=>{if(x){const w=x.closest(".rui-toast");if(w)return w}return i.isConnected?i:null},g=()=>{const x=d.get();x!==null&&(clearTimeout(x),d.set(null))},b=r.useInstanceState("removal-timer",null),h=x=>{if(p.get())return;p.set(!0),g();const w=m(x);if(!w)return;w.classList.add("is-dismissed");const k=setTimeout(()=>{b.set(null),w.remove()},180);b.set(k),r.registerDisposer(()=>{const T=b.get();T!==null&&(clearTimeout(T),b.set(null))},"exit-animation-timer"),r.invoke(e.onClose)},v=l("button",{type:"button",class:"rui-toast-close","aria-label":"Dismiss notification"},["×"]);v.onclick=x=>{x.stopPropagation(),h(x.currentTarget??x.target)},i.append(v);const y=E(e.duration,0);if(y>0&&d.get()===null&&!p.get()){const x=setTimeout(()=>{d.set(null),!p.get()&&i.isConnected&&h()},y);d.set(x),r.registerDisposer(()=>{const w=d.get();w!==null&&(clearTimeout(w),d.set(null))},"auto-dismiss-timer")}return p.get()?l("div",{class:"rui-toast-placeholder",hidden:""}):i}};function _u(t){switch(t){case"success":return"circle-check";case"warning":return"triangle-exclamation";case"danger":return"circle-xmark";case"primary":return"bell";case"info":return"circle-info";default:return"circle-info"}}const Nn={name:"BreadcrumbItem",description:"Single item inside a Breadcrumb trail. Provide `href` for a link, omit it for the current/leaf page (rendered with emphasis).",props:[{name:"label",type:"string"},{name:"href",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"}],render:(t,e)=>{const r=l("li",{class:"rui-breadcrumb-item"}),a=f(e.label),n=f(e.href),i=n?tt(n):"",o=[],s=j(e.icon,{className:"rui-breadcrumb-icon"});if(s&&o.push(s),o.push(l("span",{class:"rui-breadcrumb-label"},[a])),i)r.append(l("a",{class:"rui-breadcrumb-link",href:i},o));else{r.setAttribute("aria-current","page");const c=l("span",{class:"rui-breadcrumb-current"});for(const u of o)u&&c.append(typeof u=="string"?document.createTextNode(u):u);r.append(c)}return r}},Fu={name:"Breadcrumb",description:"Trail of links showing the user's location. Children may be BreadcrumbItem(label, href?) nodes OR plain strings (the last string is treated as the current page).",props:[{name:"items",type:"BreadcrumbItem[] | string[]"},{name:"separator",type:"string",optional:!0,description:"Default `/`"}],render:(t,e,r)=>{const a=$(e.items),n=f(e.separator,"/"),i=l("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),o=l("ol",{class:"rui-breadcrumb-list"});return a.forEach((s,c)=>{if(c>0&&o.append(l("li",{class:"rui-breadcrumb-separator","aria-hidden":"true"},[n])),s&&typeof s=="object"&&s.__kind==="Component"){o.append(r.renderNode(s));return}const u=f(s),p=c===a.length-1;o.append(Nn.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:u,href:p?"":"#"},r))}),i.append(o),i}},Uu=[10,20,50,100],Hu={name:"Pagination",description:'Page navigator with Prev/Next, page numbers, and ellipses. Pass a `$variable` as `page` for two-way binding — clicking a page button sets that state to the new (1-indexed) value. Add `total` to render a "Showing N–M of T" summary, pass `$variable` as `perPage` to expose a per-page selector, or set `compact: true` to drop the page-number row for tight toolbars.',props:[{name:"page",type:"number",description:"Current page (1-indexed); typically a $variable"},{name:"totalPages",type:"number",aliases:["pages"]},{name:"siblings",type:"number",optional:!0,description:"Number of page links shown around the current page (default 1)"},{name:"total",type:"number",optional:!0,description:'Total record count — enables the "Showing N–M of T" summary'},{name:"perPage",type:"number",optional:!0,description:"Bind a `$variable` to expose a per-page selector"},{name:"perPageOptions",type:"number[]",optional:!0,description:"Override the per-page choices (default 10/20/50/100)"},{name:"compact",type:"boolean",optional:!0,description:"Hide page numbers — keep Prev / Next only"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(E(e.totalPages,1))),n=Math.max(1,Math.min(a,Math.floor(E(e.page,1)))),i=Math.max(0,Math.floor(E(e.siblings,1))),o=A(e.compact),s=t.argMeta?.[0]?.stateRef,c=l("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":o?"true":"false"}),u=h=>{if(!s)return;const v=Math.max(1,Math.min(a,h));v!==n&&r.setState(s,v)},p=e.total!=null?Math.max(0,Math.floor(E(e.total,0))):null,d=e.perPage!=null?Math.max(1,Math.floor(E(e.perPage,0))):null;if(p!==null&&d&&d>0){const h=p===0?0:(n-1)*d+1,v=Math.min(p,n*d);c.append(l("span",{class:"rui-pagination-summary"},[p===0?"No results":`Showing ${h.toLocaleString()}–${v.toLocaleString()} of ${p.toLocaleString()}`]))}else p!==null&&c.append(l("span",{class:"rui-pagination-summary"},[`${p.toLocaleString()} result${p===1?"":"s"}`]));const m=l("div",{class:"rui-pagination-buttons"}),g=(h,v,y={})=>{if(y.ellipsis)return l("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[h]);const x=l("button",{type:"button",class:"rui-pagination-button","data-active":y.active?"true":"false","aria-current":y.active?"page":null,"aria-label":y.ariaLabel??null,disabled:y.disabled?"":null},[h]);return!y.disabled&&!y.active&&(x.onclick=()=>u(v)),x};if(m.append(g("‹",n-1,{disabled:n<=1,ariaLabel:"Previous page"})),o)m.append(l("span",{class:"rui-pagination-current"},[`${n} / ${a}`]));else{const h=Vu(n,a,i);for(const v of h)v==="…"?m.append(g("…",0,{ellipsis:!0})):m.append(g(String(v),v,{active:v===n}))}m.append(g("›",n+1,{disabled:n>=a,ariaLabel:"Next page"})),c.append(m);const b=t.argMeta?.[4]?.stateRef;if(d&&(b||$(e.perPageOptions).length>0)){const h=$(e.perPageOptions).length>0?$(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(Uu),v=l("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),y=l("select",{class:"rui-pagination-per-page-select"});for(const x of h){const w=l("option",{value:String(x),selected:x===d?"":null},[String(x)]);y.append(w)}b&&r.bindState(y,b,{event:"change",getValue:x=>Number(x.value)}),v.append(y),v.append(document.createTextNode(" per page")),c.append(v)}return c}};function Vu(t,e,r){const a=[],n=(c,u)=>{for(let p=c;p<=u;p+=1)a.push(p)},i=r*2+5;if(e<=i)return n(1,e),a;const o=Math.max(2,t-r),s=Math.min(e-1,t+r);return a.push(1),o>2&&a.push("…"),n(o,s),s<e-1&&a.push("…"),a.push(e),a}const Wu={name:"NavbarItem",description:"Single link inside a Navbar's main item slot. Renders as an inline anchor / button — pass `to` for a router-aware link, `href` for an external link, or `onClick` for a click handler. `active=true` highlights the current page.",props:[{name:"label",type:"string"},{name:"to",type:"string",optional:!0,description:"Internal route (consumes the built-in router)"},{name:"href",type:"string",optional:!0,description:"External href; opens in a new tab when set with `external=true`"},{name:"icon",type:"string",optional:!0},{name:"active",type:"boolean",optional:!0},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable fired on click (alternative to `to`/`href`)"},{name:"external",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=f(e.label),n=e.icon,i=A(e.active),o=f(e.to),s=tt(e.href,""),c=A(e.external),u=o||s?"a":"button",p=l(u,{class:"rui-navbar-item",type:u==="button"?"button":null,href:s||(o?`#${o.startsWith("/")?o:`/${o}`}`:null),target:c&&s?"_blank":null,rel:c&&s?"noopener noreferrer":null,"data-active":i?"true":"false"}),d=j(n,{className:"rui-navbar-item-icon"});return d&&p.append(d),p.append(l("span",{class:"rui-navbar-item-label"},[a])),o&&!s?p.onclick=m=>{if(m.defaultPrevented)return;const g=m;g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(m.preventDefault(),r.router.navigate(o))}:typeof e.onClick=="function"&&(p.onclick=m=>{m.preventDefault(),r.invoke(e.onClick)}),p}},qu={name:"Navbar",description:"Top navigation bar with a brand on the left, primary nav items in the middle, and a right-aligned actions slot (user avatar, DropdownMenu, CTA buttons, …). Use `sticky=true` to pin it to the top of the page. The canonical companion of `Sidebar` for product surfaces; prefer Navbar for marketing/docs pages without a sidebar.",props:[{name:"brand",type:"string | Node",optional:!0,description:"Workspace/product name (string) or a node (e.g. logo Image)"},{name:"items",type:"NavbarItem[]",optional:!0,description:"Center navigation items"},{name:"actions",type:"Node[]",optional:!0,description:"Right-side controls (Buttons, Avatar, DropdownMenu, …)"},{name:"sticky",type:"boolean",optional:!0,description:"Pin the bar to the top of the viewport"},{name:"variant",type:"string",optional:!0,enum:["default","transparent"],description:"Visual variant"}],render:(t,e,r)=>{const a=l("nav",{class:"rui-navbar","data-sticky":A(e.sticky)?"true":"false","data-variant":f(e.variant,"default"),"aria-label":"Primary"}),n=e.brand;if(n!=null&&n!==""){const s=l("div",{class:"rui-navbar-brand"});typeof n=="string"?s.append(document.createTextNode(n)):s.append(r.renderNode(n)),a.append(s)}const i=$(e.items);if(i.length>0){const s=l("div",{class:"rui-navbar-items"});for(const c of i)s.append(r.renderNode(c));a.append(s)}const o=$(e.actions);if(o.length>0){const s=l("div",{class:"rui-navbar-actions"});for(const c of o)s.append(r.renderNode(c));a.append(s)}return a}},Ku=["bottom","top","left","right"],Gu=["start","center","end"],Yu=["default","danger"],jt=(t,e,r)=>{r.set(e);const a=t.closest(".rui-dropdown-menu");return a?(a.setAttribute("data-open",e?"true":"false"),a.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded",e?"true":"false"),e||Ne(a),a):null},Pn=(t,e)=>{rt({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false"),t.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded","false")}})},Mr=(t,e)=>{if(!t||typeof t!="object")return!1;const r=t;return r.__kind==="Component"&&r.name===e},Xu={name:"DropdownMenu",description:"Click-triggered dropdown menu. Click the trigger to toggle, click a MenuItem to run its action and close, click outside or press Escape to close without acting. Children must be MenuItem, MenuSeparator, or MenuLabel entries.",props:[{name:"trigger",type:"Node",description:"Clickable trigger element (typically a Button or Avatar)"},{name:"items",type:"(MenuItem | MenuSeparator | MenuLabel)[]"},{name:"side",type:"string",optional:!0,enum:Ku,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:Gu,description:'How the menu aligns along the trigger edge (default "start")'},{name:"label",type:"string",optional:!0,description:"Optional ARIA label for the menu"},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the menu"}],render:(t,e,r)=>{const a=A(e.open),n=r.useInstanceState("open",a),i=n.get(),o=l("div",{class:"rui-dropdown-menu","data-open":i?"true":"false","data-side":f(e.side,"bottom"),"data-align":f(e.align,"start")}),s=l("span",{class:"rui-dropdown-menu-trigger","data-state":i?"open":"closed","aria-haspopup":"menu","aria-expanded":i?"true":"false",tabindex:"0"});s.append(r.renderNode(e.trigger)),s.onclick=u=>{u.stopPropagation();const p=u.currentTarget??u.target,d=!n.get(),m=jt(p,d,n);d&&m&&Pn(m,n)},s.onkeydown=u=>{const p=u,d=p.currentTarget??p.target;if(p.key==="Enter"||p.key===" "){p.preventDefault();const m=!n.get(),g=jt(d,m,n);m&&g&&Pn(g,n);return}p.key==="Escape"&&n.get()&&(p.preventDefault(),jt(d,!1,n))},o.append(s);const c=l("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":f(e.label)||null});for(const u of $(e.items)){if(Mr(u,"MenuItem")){const p=u.args??[],d=f(p[0]),m=p[1],g=p[2],b=f(p[3]),h=f(p[4],"default"),v=A(p[5]),y=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":h,disabled:v?"":null}),x=j(g,{className:"rui-menu-item-icon"});x&&y.append(x),y.append(l("span",{class:"rui-menu-item-label"},[d])),b&&y.append(l("span",{class:"rui-menu-item-shortcut"},[b])),v||(y.onclick=w=>{const k=w.currentTarget??w.target;jt(k,!1,n),r.invoke(m)}),c.append(y);continue}if(Mr(u,"MenuSeparator")){c.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}if(Mr(u,"MenuLabel")){const p=f((u.args??[])[0]);c.append(l("div",{class:"rui-menu-label"},[p]));continue}c.append(r.renderNode(u))}return o.append(c),o}},Ju={name:"MenuItem",description:"Single item inside a DropdownMenu. Renders a button-style row with an optional leading icon and trailing keyboard-shortcut hint. `onClick` (legacy: `action`) runs when clicked; the menu closes automatically afterwards.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable to execute on click"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown before the label"},{name:"shortcut",type:"string",optional:!0,description:'Trailing keyboard-shortcut hint (e.g. "⌘ K")'},{name:"variant",type:"string",optional:!0,enum:Yu,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=A(e.disabled),n=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":f(e.variant,"default"),disabled:a?"":null}),i=j(e.icon,{className:"rui-menu-item-icon"});i&&n.append(i),n.append(l("span",{class:"rui-menu-item-label"},[f(e.label)]));const o=f(e.shortcut);return o&&n.append(l("span",{class:"rui-menu-item-shortcut"},[o])),a||(n.onclick=()=>{r.invoke(e.onClick)}),n}},Zu={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>l("div",{class:"rui-menu-separator",role:"separator"})},Qu={name:"MenuLabel",description:'Small uppercase section header inside a DropdownMenu. Use to group related MenuItems (e.g. "Account", "Workspace", "Danger zone").',props:[{name:"label",type:"string"}],render:(t,e)=>l("div",{class:"rui-menu-label"},[f(e.label)])},ed=["left","center","right"];function td(t){return $(t).map((e,r)=>{const a=e.args??[],n=f(a[0]);return{header:n,values:$(a[1]),format:f(a[2],"text"),align:ed.includes(f(a[3]))?f(a[3]):"",sortable:A(a[4]),filterable:A(a[5]),render:a[6],onClick:a[7],key:n||`col-${r}`}})}function In(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return E(t,0)-E(e,0);if(r==="date"){const a=new Date(f(t)).getTime(),n=new Date(f(e)).getTime();if(Number.isFinite(a)&&Number.isFinite(n))return a-n}return f(t).localeCompare(f(e))}function Bt(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():f(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):f(t);case"date":try{const r=new Date(f(t));return Number.isNaN(r.getTime())?f(t):r.toLocaleDateString()}catch{return f(t)}default:return f(t)}}const rd={name:"DataGrid",description:"Advanced data table with sortable headers, per-column filter chips, row selection (checkboxes), sticky header / first column, optional pagination, an optional bulk-action toolbar slot, and click-to-act rows. Columns are Col(header, values, format?, align?, sortable?, filterable?) entries. Bind `$sort` (`{key, direction}` object), `$selectedIds` (string[]), and `$page` (number) for full reactivity. Use INSTEAD of `Table` when you need any of those interactions.",props:[{name:"columns",type:"Col[]",description:"Columns; pass sortable=true / filterable=true on each Col."},{name:"rowIds",type:"any[]",optional:!0,description:"Stable id per row (used by `selectedIds`); defaults to row index."},{name:"caption",type:"string",optional:!0},{name:"sort",type:"object",optional:!0,description:"`{key, direction}` — pass a $variable for two-way binding"},{name:"selectedIds",type:"any[]",optional:!0,description:"Array of selected row ids — bind a $variable"},{name:"selectable",type:"boolean",optional:!0,description:"Render leading selection checkboxes"},{name:"page",type:"number",optional:!0,description:"1-indexed current page — bind a $variable"},{name:"perPage",type:"number",optional:!0,description:"Page size (default 20)"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when no rows match (default `No results`)"},{name:"onRowClick",type:"callable",optional:!0,aliases:["rowAction"],description:"Callable fired when a row is clicked. Receives the row index."},{name:"toolbar",type:"Node[]",optional:!0,description:"Bulk-action toolbar shown above the table when any rows are selected"},{name:"density",type:"string",optional:!0,enum:["comfortable","compact"]},{name:"striped",type:"boolean",optional:!0},{name:"stickyHeader",type:"boolean",optional:!0,description:"Pin the header row (default true)"},{name:"stickyFirstColumn",type:"boolean",optional:!0,description:"Pin the first column horizontally"}],render:(t,e,r)=>{const a=td(e.columns),n=Math.max(0,...a.map(B=>B.values.length)),i=$(e.rowIds),o=B=>f(i[B]??B),s=e.sort&&typeof e.sort=="object"?e.sort:null,c=f(s?.key),u=f(s?.direction,"asc")==="desc"?"desc":"asc",p=$(e.selectedIds).map(B=>f(B)),d=new Set(p),m=A(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,g=e.stickyHeader===void 0?!0:A(e.stickyHeader),b=A(e.stickyFirstColumn),h=f(e.density,"comfortable"),v=A(e.striped),y=r.useInstanceState("filters",{}),x=y.get(),w=[];for(let B=0;B<n;B+=1){let K=!0;for(const Y of a){if(!Y.filterable)continue;const G=(x[Y.key]??"").trim().toLowerCase();if(!G)continue;const ne=Y.values[B];if(!Bt(ne,Y.format).toLowerCase().includes(G)){K=!1;break}}K&&w.push(B)}if(c){const B=a.find(K=>K.key===c);B&&B.sortable&&w.sort((K,Y)=>{const G=In(B.values[K],B.values[Y],B.format);return u==="desc"?-G:G})}const k=w.length,T=Math.max(1,Math.floor(E(e.perPage,20))),S=Math.max(1,Math.ceil(k/T)),C=Math.max(1,Math.floor(E(e.page,1))),N=Math.min(C,S),I=w.slice((N-1)*T,N*T),L=l("div",{class:"rui-data-grid","data-density":h,"data-striped":v?"true":"false","data-sticky-header":g?"true":"false","data-sticky-first":b?"true":"false"}),R=t.argMeta?.[3]?.stateRef,q=t.argMeta?.[4]?.stateRef,O=t.argMeta?.[6]?.stateRef,U=$(e.toolbar);if(p.length>0&&U.length>0){const B=l("div",{class:"rui-data-grid-bulk"});B.append(l("span",{class:"rui-data-grid-bulk-count"},[`${p.length} selected`]));const K=l("div",{class:"rui-data-grid-bulk-tools"});for(const Y of U)K.append(r.renderNode(Y));B.append(K),L.append(B)}const J=l("div",{class:"rui-data-grid-scroll"}),Z=l("table",{class:"rui-data-grid-table"}),me=f(e.caption);me&&Z.append(l("caption",{class:"rui-data-grid-caption"},[me]));const $e=l("thead"),$t=l("tr");if(m){const B=l("th",{class:"rui-data-grid-cell-select",scope:"col"}),K=I.length>0&&I.every(G=>d.has(o(G))),Y=l("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select all rows on this page",checked:K?"":null});q&&(Y.onclick=G=>{const ne=G.currentTarget,ee=new Set(p);for(const X of I){const Q=o(X);ne.checked?ee.add(Q):ee.delete(Q)}r.setState(q,Array.from(ee))}),B.append(Y),$t.append(B)}if(a.forEach((B,K)=>{const Y=l("th",{scope:"col","data-align":B.align||null,"data-sortable":B.sortable?"true":null,"data-active":B.sortable&&B.key===c?"true":null,"data-first":K===0?"true":null});if(B.sortable&&R){const G=l("button",{type:"button",class:"rui-data-grid-sort"});G.append(l("span",{},[B.header]));const ne=B.key===c?u==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",ee=j(ne,{className:"rui-data-grid-sort-icon"});ee&&G.append(ee),G.onclick=()=>{const X=B.key===c&&u==="asc"?"desc":"asc";r.setState(R,{key:B.key,direction:X})},Y.append(G)}else Y.append(document.createTextNode(B.header));$t.append(Y)}),$e.append($t),a.some(B=>B.filterable)){const B=l("tr",{class:"rui-data-grid-filter-row"});m&&B.append(l("td",{class:"rui-data-grid-cell-select"})),a.forEach(K=>{const Y=l("td");if(K.filterable){const G=l("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${K.header}`,value:x[K.key]??""});G.oninput=ne=>{const ee=ne.currentTarget,X={...y.get(),[K.key]:ee.value};y.set(X);const Q=ee.closest("table")?.querySelector("tbody");Lg(Q)},Y.append(G)}B.append(Y)}),$e.append(B)}Z.append($e);const Ye=l("tbody");Z.append(Ye);const da=B=>{if(Ye.replaceChildren(),B.length===0){const K=l("tr"),Y=(m?1:0)+Math.max(a.length,1);K.append(l("td",{colspan:String(Y),class:"rui-data-grid-empty"},[f(e.emptyLabel,"No results")])),Ye.append(K);return}for(const K of B){const Y=o(K),G=d.has(Y),ne=l("tr",{"data-selected":G?"true":null});if(m){const ee=l("td",{class:"rui-data-grid-cell-select"}),X=l("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select row",checked:G?"":null});q&&(X.onclick=Q=>{Q.stopPropagation();const xe=Q.currentTarget,we=new Set(p);xe.checked?we.add(Y):we.delete(Y),r.setState(q,Array.from(we))}),ee.append(X),ne.append(ee)}a.forEach((ee,X)=>{const Q=l("td",{"data-format":ee.format,"data-align":ee.align||null,"data-first":X===0?"true":null});fr(Q,ee,ee.values[K],K,r,Bt),ne.append(Q)}),typeof e.onRowClick=="function"&&(ne.setAttribute("data-clickable","true"),ne.onclick=ee=>{ee.target?.closest("input,button,a,label,select,textarea")||r.invoke(e.onRowClick,K)}),Ye.append(ne)}},Lg=B=>{const K=B??Ye,Y=y.get(),G=[];for(let X=0;X<n;X+=1){let Q=!0;for(const xe of a){if(!xe.filterable)continue;const we=(Y[xe.key]??"").trim().toLowerCase();if(!we)continue;const Ct=xe.values[X];if(!Bt(Ct,xe.format).toLowerCase().includes(we)){Q=!1;break}}Q&&G.push(X)}if(c){const X=a.find(Q=>Q.key===c);X&&X.sortable&&G.sort((Q,xe)=>{const we=In(X.values[Q],X.values[xe],X.format);return u==="desc"?-we:we})}const ne=G.slice((N-1)*T,N*T);(X=>{X.replaceChildren();for(const Q of ne){const xe=o(Q),we=d.has(xe),Ct=l("tr",{"data-selected":we?"true":null});if(m){const Xe=l("td",{class:"rui-data-grid-cell-select"}),pa=l("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:we?"":null});Xe.append(pa),Ct.append(Xe)}a.forEach((Xe,pa)=>{const mo=l("td",{"data-format":Xe.format,"data-align":Xe.align||null,"data-first":pa===0?"true":null});fr(mo,Xe,Xe.values[Q],Q,r,Bt),Ct.append(mo)}),X.append(Ct)}if(ne.length===0){const Q=l("tr"),xe=(m?1:0)+Math.max(a.length,1);Q.append(l("td",{colspan:String(xe),class:"rui-data-grid-empty"},[f(e.emptyLabel,"No results")])),X.append(Q)}})(K)};if(da(I),J.append(Z),L.append(J),k>T){const B=l("div",{class:"rui-data-grid-footer"}),K=k===0?0:(N-1)*T+1,Y=Math.min(k,N*T);B.append(l("span",{class:"rui-data-grid-footer-summary"},[k===0?"No results":`Showing ${K}–${Y} of ${k}`]));const G=l("div",{class:"rui-data-grid-footer-buttons"}),ne=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:N<=1?"":null},["‹ Prev"]),ee=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:N>=S?"":null},["Next ›"]);O&&(ne.onclick=()=>{N<=1||r.setState(O,N-1)},ee.onclick=()=>{N>=S||r.setState(O,N+1)}),G.append(ne),G.append(l("span",{class:"rui-data-grid-page-current"},[`${N} / ${S}`])),G.append(ee),B.append(G),L.append(B)}return L}};function ad(t){const e=[];for(const r of $(t)){if(!r||typeof r!="object")continue;const a=r,n=f(a.date);n&&e.push({date:n,title:f(a.title),tone:f(a.tone,"primary"),time:f(a.time)})}return e}function En(t,e){const r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=(r.getDay()-e+7)%7;return r.setDate(r.getDate()-n),r}function Ln(t){const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${a}`}const nd={name:"CalendarView",description:"Full-month or week calendar grid for scheduling apps — distinct from the form-input `DatePicker`. Pass events as an array of `{date: 'YYYY-MM-DD', title, tone?, time?}` objects. Bind `value` to a `$variable` for the selected date (ISO string). Use `view=\"week\"` for a single-week strip. `firstDay=1` (Monday) matches most business apps.",props:[{name:"value",type:"string",optional:!0,description:"Selected ISO date (YYYY-MM-DD); bind a $variable"},{name:"month",type:"string",optional:!0,description:"Reference month — ISO date or YYYY-MM (defaults to today)"},{name:"events",type:"object[]",optional:!0,description:"Array of {date, title, tone?, time?} objects"},{name:"view",type:"string",optional:!0,enum:["month","week"]},{name:"firstDay",type:"number",optional:!0,description:"0=Sunday, 1=Monday (default 1)"},{name:"onSelect",type:"callable",optional:!0,description:"Callable fired when a day is clicked; receives the ISO date string"}],render:(t,e,r)=>{const a=f(e.view,"month"),n=ad(e.events),i=f(e.value),o=f(e.month,i),s=new Date;let c=new Date(NaN);if(o){const T=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(o);if(T)c=new Date(Number(T[1]),Number(T[2])-1,T[3]?Number(T[3]):1);else{const S=new Date(o);Number.isNaN(S.getTime())||(c=S)}}Number.isNaN(c.getTime())&&(c=s);const u=(E(e.firstDay,1)%7+7)%7,p=i&&/^\d{4}-\d{2}-\d{2}$/.test(i)?i:"",d=new Map;for(const T of n){const S=T.date.slice(0,10),C=d.get(S)??[];C.push(T),d.set(S,C)}const m=t.argMeta?.[0]?.stateRef,g=l("div",{class:"rui-calendar","data-view":a}),b=l("div",{class:"rui-calendar-header"}),h=c.toLocaleDateString(void 0,{month:"long",year:"numeric"});b.append(l("div",{class:"rui-calendar-title"},[h])),g.append(b);const v=l("div",{class:"rui-calendar-weekrow"}),y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let T=0;T<7;T+=1){const S=y[(u+T)%7]??"";v.append(l("div",{class:"rui-calendar-weekday"},[S]))}g.append(v);const x=[];if(a==="week"){const T=p?new Date(p):c,S=En(T,u);for(let C=0;C<7;C+=1){const N=new Date(S);N.setDate(S.getDate()+C),x.push({date:N,inMonth:N.getMonth()===c.getMonth()})}}else{const T=new Date(c.getFullYear(),c.getMonth(),1),S=new Date(c.getFullYear(),c.getMonth()+1,0),C=En(T,u),N=Math.ceil((S.getDate()+(T.getDay()-u+7)%7)/7)*7;for(let I=0;I<N;I+=1){const L=new Date(C);L.setDate(C.getDate()+I),x.push({date:L,inMonth:L.getMonth()===c.getMonth()})}}const w=l("div",{class:"rui-calendar-grid","data-view":a}),k=Ln(s);for(const T of x){const S=Ln(T.date),C=S===k,N=S===p,I=d.get(S)??[],L=l("button",{type:"button",class:"rui-calendar-day","data-in-month":T.inMonth?"true":"false","data-today":C?"true":"false","data-selected":N?"true":"false","aria-label":T.date.toDateString()});if(L.append(l("span",{class:"rui-calendar-daynumber"},[String(T.date.getDate())])),I.length>0){const R=l("div",{class:"rui-calendar-day-events"}),q=I.slice(0,3);for(const O of q){const U=l("span",{class:"rui-calendar-event","data-tone":O.tone??"primary",title:O.time?`${O.time} — ${O.title}`:O.title},[O.title]);R.append(U)}I.length>3&&R.append(l("span",{class:"rui-calendar-event-more"},[`+${I.length-3} more`])),L.append(R)}L.onclick=()=>{m&&r.setState(m,S),r.invoke(e.onSelect,S)},w.append(L)}return g.append(w),g}};function id(t){const e=[];for(const r of $(t)){if(!r||typeof r!="object")continue;const a=r;e.push({title:f(a.title),description:f(a.description),actor:f(a.actor),avatarSrc:f(a.avatarSrc),time:f(a.time),icon:f(a.icon),tone:f(a.tone,"default"),meta:f(a.meta)})}return e}function od(t,e,r){const a=l("ol",{class:t,"data-variant":r});for(const n of e){const i=l("li",{class:`${t}-item`,"data-tone":n.tone}),o=l("span",{class:`${t}-marker`}),s=j(n.icon,{className:`${t}-icon`});s&&o.append(s),i.append(o);const c=l("div",{class:`${t}-body`}),u=l("div",{class:`${t}-head`});n.actor&&u.append(l("span",{class:`${t}-actor`},[n.actor])),u.append(l("span",{class:`${t}-title`},[n.title])),n.time&&u.append(l("span",{class:`${t}-time`},[n.time])),c.append(u),n.description&&c.append(l("p",{class:`${t}-description`},[n.description])),n.meta&&c.append(l("span",{class:`${t}-meta`},[n.meta])),i.append(c),a.append(i)}return a}const sd={name:"ActivityLog",description:'Purpose-built feed of user/system activity. Each entry has `actor`, `title`, `description?`, `time?`, `icon?`, `tone?`, and optional `meta` (IP, browser, request id). Use `variant="audit"` for monospace security/admin trails. Pass items as `{actor, title, description, time, icon, tone, avatarSrc, meta}` objects.',props:[{name:"items",type:"object[]"},{name:"variant",type:"string",optional:!0,enum:["default","audit"],description:"audit = monospace voice with meta column"}],render:(t,e)=>{const r=f(e.variant,"default");return od(r==="audit"?"rui-audit-trail":"rui-activity-log",id(e.items),r)}},ld={name:"ComparisonTable",description:"Feature/spec comparison table — generic counterpart of `PricingTable`. Pass `columns` (e.g. plan/product names) and `rows` of `{label, values}` where `values` aligns 1-to-1 with `columns`. Each value can be a boolean (✓/—), a string, or a node.",props:[{name:"columns",type:"string[]",description:"Column headers"},{name:"rows",type:"object[]",description:"Array of {label, values, hint?, group?} entries"},{name:"highlightColumn",type:"number",optional:!0,description:"0-indexed column to visually emphasise"}],render:(t,e,r)=>{const a=$(e.columns).map(m=>f(m)),n=$(e.rows).map(m=>{const g=m??{};return{label:f(g.label),values:$(g.values),hint:f(g.hint),group:f(g.group)}}),i=Math.floor(E(e.highlightColumn,-1)),o=l("div",{class:"rui-comparison-table"}),s=l("table"),c=l("thead"),u=l("tr");u.append(l("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),a.forEach((m,g)=>{u.append(l("th",{scope:"col","data-highlight":g===i?"true":null},[m]))}),c.append(u),s.append(c);const p=l("tbody");let d="";for(const m of n){if(m.group&&m.group!==d){d=m.group;const h=l("tr",{class:"rui-comparison-table-group"});h.append(l("td",{colspan:String(a.length+1)},[m.group])),p.append(h)}const g=l("tr"),b=l("td",{class:"rui-comparison-table-feature"});b.append(l("div",{class:"rui-comparison-table-feature-label"},[m.label])),m.hint&&b.append(l("div",{class:"rui-comparison-table-feature-hint"},[m.hint])),g.append(b);for(let h=0;h<a.length;h+=1){const v=m.values[h],y=l("td",{"data-highlight":h===i?"true":null});if(v===!0){const x=j("circle-check",{className:"rui-comparison-yes"});x?y.append(x):y.textContent="✓"}else v===!1||v===null||v===void 0?y.append(l("span",{class:"rui-comparison-no"},["—"])):v&&typeof v=="object"&&v.__kind==="Component"?y.append(r.renderNode(v)):y.textContent=f(v);g.append(y)}p.append(g)}return s.append(p),o.append(s),o}},cd={name:"InfiniteList",description:"Vertical list that fires `onLoadMore` when the user scrolls near the bottom. Pass already-rendered child nodes as `items`; wire `onLoadMore` to an `action` that awaits a `$mutation` or `$query` (e.g. `await loadMore.invoke()`) and appends to the bound state. Use `loading=true` to show the spinner row, `hasMore=false` to suppress further loads.",props:[{name:"items",type:"Node[]",description:"Already-rendered child nodes"},{name:"onLoadMore",type:"callable",optional:!0,description:"Callable fired when the sentinel scrolls into view"},{name:"loading",type:"boolean",optional:!0},{name:"hasMore",type:"boolean",optional:!0,description:"Default true — set false to hide the sentinel"},{name:"loaderLabel",type:"string",optional:!0,description:"Label rendered while loading (default `Loading…`)"}],render:(t,e,r)=>{const a=l("div",{class:"rui-infinite-list"}),n=l("div",{class:"rui-infinite-list-body"});for(const s of $(e.items))n.append(r.renderNode(s));a.append(n);const i=e.hasMore===void 0?!0:A(e.hasMore),o=A(e.loading);if(i){const s=l("div",{class:"rui-infinite-list-sentinel"});if(o){const c=j("spinner",{className:"rui-infinite-list-spin"});c&&s.append(c),s.append(l("span",{},[f(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const c=l("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);c.onclick=()=>r.invoke(e.onLoadMore),s.append(c)}if(a.append(s),!o&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const c=e.onLoadMore,u=new IntersectionObserver(p=>{for(const d of p)if(d.isIntersecting){r.invoke(c);break}});u.observe(s),r.registerDisposer(()=>u.disconnect(),"infinite-observer")}}return a}},ud=/^(https?:|blob:|data:(audio|video)\/)/i;function Ot(t){const e=f(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":ud.test(e)?e:"":""}const dd={name:"VideoPlayer",description:"Themed native `<video>` wrapper. Pass a `src` URL (or `sources` array for multi-codec fallback) and optional `poster`. Standard controls are visible by default; pass `autoplay`, `loop`, `muted`, or `controls=false` to override. Use for product demos, tutorials, and any inline video.",props:[{name:"src",type:"string",optional:!0,description:"Video URL (mp4 / webm / etc.)"},{name:"sources",type:"object[]",optional:!0,description:"Array of {src, type} entries for multi-codec fallback"},{name:"poster",type:"string",optional:!0,description:"Thumbnail image URL shown before playback"},{name:"caption",type:"string",optional:!0},{name:"controls",type:"boolean",optional:!0,description:"Show native controls (default true)"},{name:"autoplay",type:"boolean",optional:!0},{name:"loop",type:"boolean",optional:!0},{name:"muted",type:"boolean",optional:!0},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio (default 16:9)"}],render:(t,e)=>{const r=l("figure",{class:"rui-video-player"}),a=Nr(f(e.ratio,"16:9")),n=l("div",{class:"rui-video-player-frame",style:`aspect-ratio:${a};`}),i=e.controls===void 0?!0:A(e.controls),o=l("video",{class:"rui-video-player-video",controls:i?"":null,autoplay:A(e.autoplay)?"":null,loop:A(e.loop)?"":null,muted:A(e.muted)?"":null,poster:ie(e.poster)||null,playsinline:"",preload:"metadata"}),s=$(e.sources);if(s.length>0)for(const u of s){if(!u||typeof u!="object")continue;const p=u,d=Ot(p.src);d&&o.append(l("source",{src:d,type:f(p.type)||null}))}else{const u=Ot(e.src);u&&o.setAttribute("src",u)}n.append(o),r.append(n);const c=f(e.caption);return c&&r.append(l("figcaption",{class:"rui-video-player-caption"},[c])),r}},pd={name:"AudioPlayer",description:"Themed native `<audio>` wrapper with a title, optional artist, and standard transport controls. Pass `src` (or `sources`) plus a `title` so the bar still looks like a player when the controls bar is hidden. Use for podcasts, voice notes, and demo audio.",props:[{name:"src",type:"string",optional:!0,description:"Audio URL (mp3 / ogg / wav / etc.)"},{name:"sources",type:"object[]",optional:!0,description:"Array of {src, type} entries for multi-codec fallback"},{name:"title",type:"string",optional:!0},{name:"artist",type:"string",optional:!0},{name:"controls",type:"boolean",optional:!0,description:"Show native controls (default true)"},{name:"autoplay",type:"boolean",optional:!0},{name:"loop",type:"boolean",optional:!0},{name:"icon",type:"string",optional:!0,description:"Leading icon (default `music`)"}],render:(t,e)=>{const r=l("div",{class:"rui-audio-player"}),a=l("div",{class:"rui-audio-player-meta"}),n=j(f(e.icon,"music"),{className:"rui-audio-player-icon"});n&&a.append(n);const i=l("div",{class:"rui-audio-player-text"}),o=f(e.title);o&&i.append(l("div",{class:"rui-audio-player-title"},[o]));const s=f(e.artist);s&&i.append(l("div",{class:"rui-audio-player-artist"},[s])),a.append(i),r.append(a);const c=e.controls===void 0?!0:A(e.controls),u=l("audio",{class:"rui-audio-player-audio",controls:c?"":null,autoplay:A(e.autoplay)?"":null,loop:A(e.loop)?"":null,preload:"metadata"}),p=$(e.sources);if(p.length>0)for(const d of p){if(!d||typeof d!="object")continue;const m=d,g=Ot(m.src);g&&u.append(l("source",{src:g,type:f(m.type)||null}))}else{const d=Ot(e.src);d&&u.setAttribute("src",d)}return r.append(u),r}};function md(t,e){if(t==null)return null;if(typeof t=="object"&&t.__kind==="Component")return e.renderNode(t);if(typeof t=="string"){const r=ie(t);return r?l("img",{src:r,alt:"",loading:"lazy",class:"rui-carousel-image"}):null}if(typeof t=="object"){const r=t,a=ie(r.src);if(a){const n=l("figure",{class:"rui-carousel-figure"});n.append(l("img",{src:a,alt:f(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const i=f(r.caption??r.title);return i&&n.append(l("figcaption",{class:"rui-carousel-caption"},[i])),n}}return e.renderNode(t)}const fd={name:"Carousel",description:"Horizontal slider with prev/next buttons and dot navigation. Each child slide takes full width. Slides may be Component nodes (Image, Card, MediaCard, …), URL strings, or plain `{src, alt, caption?}` image objects — bare image objects are auto-wrapped into a captioned figure. Use for image galleries, onboarding carousels, hero banners, and product image strips. The active slide is preserved across re-renders via instance state.",props:[{name:"items",type:"Node[]",description:"Slide nodes, image URLs, or {src, alt, caption?} objects"},{name:"activeIndex",type:"number",optional:!0,description:"0-indexed initial slide (default 0)"},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio of the frame (default `16:9`)"},{name:"showDots",type:"boolean",optional:!0,description:"Show indicator dots (default true)"},{name:"showArrows",type:"boolean",optional:!0,description:"Show prev/next arrows (default true)"}],render:(t,e,r)=>{const a=$(e.items),n=a.length,i=Math.max(0,Math.min(Math.max(n-1,0),Math.floor(E(e.activeIndex,0)))),o=r.useInstanceState("active",i);let s=o.get();s>=n&&(s=0,o.set(s));const c=e.showDots===void 0?!0:A(e.showDots),u=e.showArrows===void 0?!0:A(e.showArrows),p=Nr(f(e.ratio,"16:9")),d=l("div",{class:"rui-carousel"}),m=l("div",{class:"rui-carousel-frame",style:`aspect-ratio:${p};`}),g=l("div",{class:"rui-carousel-track",style:`transform:translateX(${s*-100}%);`});a.forEach(h=>{const v=l("div",{class:"rui-carousel-slide"}),y=md(h,r);y&&v.append(y),g.append(v)}),m.append(g);const b=(h,v)=>{const y=(v%n+n)%n;o.set(y);const x=h.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${y*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((k,T)=>{k.setAttribute("data-active",T===y?"true":"false")})};if(u&&n>1){const h=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),v=j("chevron-left");v&&h.append(v);const y=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=j("chevron-right");x&&y.append(x),h.onclick=w=>b(w.currentTarget,o.get()-1),y.onclick=w=>b(w.currentTarget,o.get()+1),m.append(h,y)}if(d.append(m),c&&n>1){const h=l("div",{class:"rui-carousel-dots"});a.forEach((v,y)=>{const x=l("button",{type:"button",class:"rui-carousel-dot","data-active":y===s?"true":"false","aria-label":`Go to slide ${y+1}`});x.onclick=w=>b(w.currentTarget,y),h.append(x)}),d.append(h)}return d}},gd={name:"Gallery",description:"Responsive image grid. Pass items as plain URL strings, `{src, alt, caption?}` objects, or `Image(...)` nodes. When `onSelect` is provided each tile becomes a button; bind it through an Action that opens a `Lightbox`.",props:[{name:"items",type:"any[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"},{name:"ratio",type:"string",optional:!0,description:"Per-tile aspect ratio (default `1:1`)"},{name:"onSelect",type:"callable",optional:!0,description:"Callable fired when a tile is clicked"}],render:(t,e,r)=>{const a=$(e.items),n=Math.max(1,Math.min(6,Number(e.columns??"auto"))),i=Nr(f(e.ratio,"1:1")),o=l("div",{class:"rui-gallery","data-columns":n>0?String(n):null});return a.forEach((s,c)=>{const{src:u,alt:p,caption:d}=zn(s),m=ie(u),g=typeof e.onSelect=="function",b=l(g?"button":"figure",{type:g?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${i};`,"data-index":String(c)});if(m)b.append(l("img",{src:m,alt:p,loading:"lazy"}));else{const h=j("image",{className:"rui-gallery-placeholder"});h&&b.append(h)}d&&b.append(l("span",{class:"rui-gallery-caption"},[d])),g&&(b.onclick=()=>r.invoke(e.onSelect,c,s)),o.append(b)}),o}};function zn(t){if(typeof t=="string")return{src:t,alt:"",caption:""};if(t&&typeof t=="object"){const e=t;return e.__kind==="Component"&&Array.isArray(e.args)?{src:f(e.args[0]),alt:f(e.args[1]),caption:f(e.args[2])}:{src:f(e.src),alt:f(e.alt),caption:f(e.caption)}}return{src:"",alt:"",caption:""}}const hd={name:"Lightbox",description:"Image overlay. When you bind a `$variable` to `open` you control it explicitly; without one, Lightbox renders a clickable thumbnail of the current image that opens the overlay on click (and uses internal state for next/prev). Pass `items` (string URLs or `{src, alt, caption?}` objects). Clicking the backdrop or × closes; arrows step through the array.",props:[{name:"items",type:"any[]"},{name:"open",type:"boolean",optional:!0,description:"Open/closed; bind a $variable to control externally"},{name:"index",type:"number",optional:!0,description:"0-indexed current image; typically a $variable"}],render:(t,e,r)=>{const a=$(e.items).map(C=>zn(C)).filter(C=>ie(C.src)!==""),n=a.length,i=t.argMeta?.[2]?.stateRef,o=t.argMeta?.[1]?.stateRef,s=r.useInstanceState("open",!1),c=r.useInstanceState("index",0),u=o?A(e.open):s.get(),p=i?Math.floor(E(e.index,0)):c.get(),d=n===0?0:(p%n+n)%n,m=C=>{o?r.setState(o,C):s.set(C)},g=C=>{i?r.setState(i,C):c.set(C)},b=()=>m(!1),h=C=>{n!==0&&g(((d+C)%n+n)%n)},v=l("div",{class:"rui-lightbox-root"});if(!o&&n>0){const C=a[d],N=l("button",{type:"button",class:"rui-lightbox-thumb","aria-label":C?.alt||"Open image"});if(C){const I=ie(C.src);I&&N.append(l("img",{src:I,alt:C.alt,loading:"lazy"}))}N.onclick=I=>{I.stopPropagation(),m(!0)},v.append(N)}const y=l("div",{class:"rui-lightbox-overlay","data-open":u?"true":"false"});if(v.append(y),!u||n===0)return v;const x=a[d];if(!x)return v;const w=ie(x.src);y.onclick=C=>{C.target===y&&b()};const k=l("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),T=l("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(T.onclick=b,k.append(T),n>1){const C=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),N=j("chevron-left");N&&C.append(N),C.onclick=()=>h(-1);const I=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),L=j("chevron-right");L&&I.append(L),I.onclick=()=>h(1),k.append(C,I)}const S=l("div",{class:"rui-lightbox-image-wrap"});return w&&S.append(l("img",{src:w,alt:x.alt})),k.append(S),x.caption&&k.append(l("div",{class:"rui-lightbox-caption"},[x.caption])),n>1&&k.append(l("div",{class:"rui-lightbox-counter"},[`${d+1} / ${n}`])),y.append(k),v}};function bd(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){const e=t,r=E(e.lat??e.latitude,NaN),a=E(e.lng??e.longitude,NaN);if(Number.isFinite(r)&&Number.isFinite(a))return{lat:r,lng:a}}if(Array.isArray(t)&&t.length>=2){const e=E(t[0],NaN),r=E(t[1],NaN);if(Number.isFinite(e)&&Number.isFinite(r))return{lat:e,lng:r}}if(typeof t=="string"){const e=t.split(",").map(r=>Number(r.trim()));if(e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]))return{lat:e[0],lng:e[1]}}return null}const vd={name:"Map",description:"Static map view centered on a lat/lng coordinate. Renders an OpenStreetMap embed inside an `<iframe>` (no external JS, no API key). Pass `lat` and `lng` as bare numbers; `zoom` controls the level (1–18, default 13). Optional `markers` array adds map pins (rendered as a labelled list alongside the map). Use for store locators, address cards, itinerary previews.",props:[{name:"lat",type:"number",description:"Latitude of the map center"},{name:"lng",type:"number",description:"Longitude of the map center"},{name:"zoom",type:"number",optional:!0,description:"1–18 (default 13)"},{name:"markers",type:"object[]",optional:!0,description:"Array of {lat, lng, label?} markers (informational; rendered alongside the map)"},{name:"height",type:"string",optional:!0,description:"CSS height (default 320px)"},{name:"caption",type:"string",optional:!0}],render:(t,e)=>{const r=l("figure",{class:"rui-map"}),a=re(e.height,"320px"),n=l("div",{class:"rui-map-frame",style:`height:${a};`}),i=E(e.lat,NaN),o=E(e.lng,NaN),s=Number.isFinite(i)&&Number.isFinite(o)?{lat:i,lng:o}:null;if(!s){n.append(l("div",{class:"rui-map-empty"},["Pass lat & lng (numbers) to render the map."])),r.append(n);const h=f(e.caption);return h&&r.append(l("figcaption",{class:"rui-map-caption"},[h])),r}const c=Math.max(1,Math.min(18,Math.floor(E(e.zoom,13)))),u=1/Math.pow(2,c-8),d=`https://www.openstreetmap.org/export/embed.html?bbox=${[s.lng-u,s.lat-u/2,s.lng+u,s.lat+u/2].join(",")}&layer=mapnik&marker=${s.lat},${s.lng}`,m=l("iframe",{class:"rui-map-iframe",src:d,loading:"lazy",title:"Map view",referrerpolicy:"no-referrer"});n.append(m),r.append(n);const g=$(e.markers).map(h=>{const v=bd(h),y=h&&typeof h=="object"?f(h.label):"";return v?{...v,label:y}:null}).filter(h=>h!==null);if(g.length>0){const h=l("ul",{class:"rui-map-markers"});for(const v of g){const y=l("li",{class:"rui-map-marker"}),x=j("location-dot",{className:"rui-map-marker-icon"});x&&y.append(x),y.append(l("span",{class:"rui-map-marker-label"},[v.label||`${v.lat.toFixed(4)}, ${v.lng.toFixed(4)}`])),h.append(y)}r.append(h)}const b=f(e.caption);return b&&r.append(l("figcaption",{class:"rui-map-caption"},[b])),r}};function Nr(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const yd=[{command:"bold",icon:"bold",label:"Bold"},{command:"italic",icon:"italic",label:"Italic"},{command:"underline",icon:"underline",label:"Underline"},{command:"strikeThrough",icon:"strikethrough",label:"Strikethrough"},{command:"formatBlock",icon:"heading",label:"Heading",block:"h2"},{command:"formatBlock",icon:"quote-left",label:"Quote",block:"blockquote"},{command:"insertUnorderedList",icon:"list-ul",label:"Bullet list"},{command:"insertOrderedList",icon:"list-ol",label:"Numbered list"},{command:"createLink",icon:"link",label:"Link"}],xd={name:"RichTextEditor",description:"Rich-text WYSIWYG editor for CMS, email, and comment surfaces. Renders a small toolbar (bold / italic / underline / strikethrough / headings / lists / quote / link) above a `contenteditable` region. Pass `$variable` as `value` for two-way binding — the HTML body is written back to state on every edit. Provide `placeholder` for the empty-state prompt.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound HTML body (typically $variable)"},{name:"placeholder",type:"string",optional:!0,description:"Empty-state prompt"},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height for the editor area (default 160px)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current HTML on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=f(e.placeholder,"Start writing…"),i=A(e.disabled),o=l("div",{class:"rui-rich-text","data-disabled":i?"true":"false"}),s=l("div",{class:"rui-rich-text-toolbar",role:"toolbar"});for(const g of yd){const b=l("button",{type:"button",class:"rui-rich-text-tool","data-command":g.command,"data-block":g.block??null,"aria-label":g.label,title:g.label,disabled:i?"":null}),h=j(g.icon);h&&b.append(h),b.onmousedown=v=>v.preventDefault(),b.onclick=v=>{const x=v.currentTarget.closest(".rui-rich-text")?.querySelector(".rui-rich-text-content");if(x){x.focus();try{if(g.command==="createLink"){const w=window.prompt("URL");w&&document.execCommand("createLink",!1,w)}else g.command==="formatBlock"&&g.block?document.execCommand("formatBlock",!1,g.block):document.execCommand(g.command,!1)}catch{}x.dispatchEvent(new Event("input",{bubbles:!0}))}},s.append(b)}o.append(s);const c=f(e.value)||"",u=g=>g.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim().length===0,p=l("div",{class:"rui-rich-text-content",id:a,contenteditable:i?"false":"true",role:"textbox","aria-multiline":"true","aria-placeholder":n,"data-placeholder":n,"data-empty":u(c)?"true":"false",style:`min-height:${f(e.minHeight,"160px")};`,html:c}),d=g=>{g.setAttribute("data-empty",u(g.innerHTML)?"true":"false")},m=t.argMeta?.[1]?.stateRef;return m&&!i?r.bindState(p,m,{event:"input",getValue:g=>{const b=g;return d(b),b.innerHTML}}):p.oninput=g=>{const b=g.currentTarget??g.target;d(b)},p.onblur=g=>{const b=g.currentTarget??g.target;d(b)},oe(p,e.onChange,r,{event:"input",getValue:g=>g.innerHTML}),o.append(p),o}},wd={name:"CodeEditor",description:"Lightweight, dependency-free code editor. Pairs a styled textarea with a synchronised line-number gutter — no syntax highlighting, but the editor stays a single rendered node so it works inside Shadow DOM. Use for dev tooling, snippet editing, prompt playgrounds. Pass a `$variable` as `value` for two-way binding. For read-only rendering with highlights prefer `CodeBlock`.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound source text (typically $variable)"},{name:"language",type:"string",optional:!0,enum:["text","javascript","typescript","json","html","css","bash","python","sql","markdown"],description:"Language label shown on the header (default `text`)"},{name:"placeholder",type:"string",optional:!0},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height for the editor area (default 200px)"},{name:"tabSize",type:"number",optional:!0,description:"Spaces per Tab (default 2)"},{name:"showGutter",type:"boolean",optional:!0,description:"Show line-number gutter (default true)"},{name:"readonly",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current source on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=f(e.value),i=f(e.language,"text"),o=e.showGutter===void 0?!0:A(e.showGutter),s=Math.max(1,Math.min(8,Math.floor(E(e.tabSize,2)))),c=A(e.readonly),u=f(e.minHeight,"200px"),p=l("div",{class:"rui-code-editor","data-language":i,"data-gutter":o?"true":"false"}),d=l("div",{class:"rui-code-editor-head"});d.append(l("span",{class:"rui-code-editor-language"},[i])),p.append(d);const m=l("div",{class:"rui-code-editor-body",style:`min-height:${u};`}),g=l("div",{class:"rui-code-editor-gutter","aria-hidden":"true"});o&&((y=>{g.replaceChildren();const x=y.split(/\r?\n/),w=Math.max(1,x.length);for(let k=1;k<=w;k+=1)g.append(l("span",{class:"rui-code-editor-line"},[String(k)]))})(n),m.append(g));const h=l("textarea",{class:"rui-code-editor-textarea",id:a,name:a,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:f(e.placeholder),readonly:c?"":null,style:`tab-size:${s};-moz-tab-size:${s};`});h.value=n,h.oninput=y=>{const x=y.currentTarget;if(!o)return;const k=x.closest(".rui-code-editor")?.querySelector(".rui-code-editor-gutter");if(!k)return;k.replaceChildren();const T=x.value.split(/\r?\n/),S=Math.max(1,T.length);for(let C=1;C<=S;C+=1)k.append(l("span",{class:"rui-code-editor-line"},[String(C)]))},h.onkeydown=y=>{const x=y;if(x.key!=="Tab")return;x.preventDefault();const w=x.currentTarget,k=w.selectionStart,T=w.selectionEnd,S=" ".repeat(s);w.value=w.value.slice(0,k)+S+w.value.slice(T),w.selectionStart=w.selectionEnd=k+S.length,w.dispatchEvent(new Event("input",{bubbles:!0}))};const v=t.argMeta?.[1]?.stateRef;return v&&!c&&r.bindState(h,v,{event:"input",getValue:y=>y.value}),c||oe(h,e.onChange,r,{event:"input",getValue:y=>y.value}),m.append(h),p.append(m),p}};function kd(t){if(!t)return null;if(typeof t=="object"){const e=t;if(e.__kind==="Component"&&e.name==="MenuItem"&&Array.isArray(e.args)){const a=e.args;return{label:f(a[0]),action:a[1],icon:f(a[2]),shortcut:f(a[3]),variant:f(a[4],"default"),disabled:A(a[5]),separator:!1}}if(e.__kind==="Component"&&e.name==="MenuSeparator")return{label:"",action:null,icon:"",shortcut:"",variant:"default",disabled:!1,separator:!0};const r=t;return r.separator?{label:"",action:null,icon:"",shortcut:"",variant:"default",disabled:!1,separator:!0}:{label:f(r.label),action:r.action,icon:f(r.icon),shortcut:f(r.shortcut),variant:f(r.variant,"default"),disabled:A(r.disabled),separator:!1}}return null}const Sd={name:"ContextMenu",description:"Right-click (or long-press) menu that attaches to a child node. Wraps `target` and shows the menu at the pointer when the user right-clicks anywhere inside it. Items are `MenuItem(...)` nodes, `MenuSeparator()` entries, or `{label, action, icon?, shortcut?, variant?, disabled?, separator?}` objects. Use on table rows, tree nodes, kanban cards, file browser entries.",props:[{name:"target",type:"Node",description:"Child node the menu is bound to"},{name:"items",type:"any[]",description:"MenuItem nodes or {label, action} objects"},{name:"label",type:"string",optional:!0,description:"ARIA label for the menu"}],render:(t,e,r)=>{const a=l("div",{class:"rui-context-menu"}),n=l("div",{class:"rui-context-menu-target"});n.append(r.renderNode(e.target)),a.append(n);const i=l("div",{class:"rui-context-menu-pop",role:"menu","aria-label":f(e.label)||null,"data-open":"false"}),o=$(e.items).map(kd).filter(u=>u!==null);for(const u of o){if(u.separator){i.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}const p=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":u.variant,disabled:u.disabled?"":null}),d=j(u.icon,{className:"rui-menu-item-icon"});d&&p.append(d),p.append(l("span",{class:"rui-menu-item-label"},[u.label])),u.shortcut&&p.append(l("span",{class:"rui-menu-item-shortcut"},[u.shortcut])),u.disabled||(p.onclick=()=>{r.invoke(u.action),i.setAttribute("data-open","false")}),i.append(p)}a.append(i);const s=()=>i.setAttribute("data-open","false"),c=(u,p)=>{const d=n.isConnected?n.closest(".rui-context-menu"):null,m=d?.querySelector(".rui-context-menu-pop")??i,g=d?.getBoundingClientRect(),b=g?u-g.left:u,h=g?p-g.top:p;m.style.left=`${b}px`,m.style.top=`${h}px`,m.setAttribute("data-open","true");const v=y=>{y.target&&m.contains(y.target)||(m.setAttribute("data-open","false"),document.removeEventListener("click",v,!0),document.removeEventListener("contextmenu",v,!0))};setTimeout(()=>{document.addEventListener("click",v,!0),document.addEventListener("contextmenu",v,!0)},0)};return n.oncontextmenu=u=>{u.preventDefault(),c(u.clientX,u.clientY)},n.onkeydown=u=>{const p=u;if(p.key==="ContextMenu"||p.shiftKey&&p.key==="F10"){p.preventDefault();const m=p.currentTarget.getBoundingClientRect();c(m.left,m.top+m.height)}p.key==="Escape"&&s()},a}},$d=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function dt(t){const e=t.trim();if(!e)return"";let r=e.startsWith("#")?e.slice(1):e;return r.length===3&&(r=r.split("").map(a=>a+a).join("")),/^[0-9a-fA-F]{6,8}$/.test(r)?`#${r.toLowerCase().slice(0,6)}`:""}const Cd={name:"ColorPicker",description:'Hex / RGB color form control with preset swatches. Pairs a native `<input type="color">` chip with a hex text input and a row of preset swatches. Pass a `$variable` as `value` (hex string, e.g. `"#6366f1"`) for two-way binding. Use for theme builders, label color pickers, and any "pick a color" surface.',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound hex value (typically $variable)"},{name:"label",type:"string",optional:!0},{name:"swatches",type:"string[]",optional:!0,description:"Preset hex colors (default to a 12-color palette)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected hex string"}],render:(t,e,r)=>{const a=f(e.id),n=dt(f(e.value))||f(e.value,"#000000"),i=A(e.disabled),o=l("div",{class:"rui-color-picker","data-disabled":i?"true":"false"}),s=f(e.label);s&&o.append(l("label",{class:"rui-color-picker-label",for:a},[s]));const c=l("div",{class:"rui-color-picker-row"}),u=l("input",{type:"color",class:"rui-color-picker-color",id:a,name:a,value:dt(n)||"#000000",disabled:i?"":null}),p=l("input",{type:"text",class:"rui-color-picker-hex",value:n,placeholder:"#000000",disabled:i?"":null,autocomplete:"off"}),d=l("div",{class:"rui-color-picker-swatches"}),m=$(e.swatches).map(h=>f(h)).filter(Boolean),g=m.length>0?m:$d;for(const h of g){const v=dt(h)||h,y=l("button",{type:"button",class:"rui-color-picker-swatch",style:`background:${v}`,"aria-label":v,title:v,"data-active":v.toLowerCase()===n.toLowerCase()?"true":"false"});y.onclick=()=>{u.value=dt(v)||u.value,p.value=v,u.dispatchEvent(new Event("input",{bubbles:!0}))},d.append(y)}const b=t.argMeta?.[1]?.stateRef;return b&&!i&&(r.bindState(u,b,{event:"input",getValue:h=>h.value}),u.addEventListener("input",()=>{p.value=u.value}),p.oninput=()=>{const h=dt(p.value);h&&(u.value=h,u.dispatchEvent(new Event("input",{bubbles:!0})))}),i||oe(u,e.onChange,r,{event:"input",getValue:h=>h.value}),c.append(u,p),o.append(c,d),o}},Pr=["var(--rui-chart-1, #6366f1)","var(--rui-chart-2, #10b981)","var(--rui-chart-3, #f59e0b)","var(--rui-chart-4, #ef4444)","var(--rui-chart-5, #06b6d4)","var(--rui-chart-6, #8b5cf6)"],qe=t=>Pr[t%Pr.length]??Pr[0];function Ad(t){return t.map((e,r)=>{const a=e,n=f(a.args?.[0],`Series ${r+1}`),i=$(a.args?.[1]).map(o=>E(o));return{name:n,values:i}})}function _t(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("viewBox",`0 0 ${t} ${e}`),r.setAttribute("class","rui-chart-svg"),r.setAttribute("role","img"),r}function ce(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[n,i]of Object.entries(e))a.setAttribute(n,i);if(r)for(const n of r)a.append(typeof n=="string"?document.createTextNode(n):n);return a}function Rn(t){const e=l("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const n=l("span",{class:"rui-chart-legend-item"});n.append(l("span",{class:"rui-chart-legend-swatch",style:`background:${qe(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const Td={name:"Gauge",description:"Half-doughnut gauge indicator for a single value between `min` and `max`. The inner value is auto-formatted from the value (override via `label`). Pass `caption`, `tone`, and `size` for visual treatment. Use for KPI thresholds (uptime %, score, capacity, NPS, page-speed).",props:[{name:"value",type:"number"},{name:"min",type:"number",optional:!0,description:"Lower bound (default 0)"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"caption",type:"string",optional:!0,description:"Small caption below the gauge"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"label",type:"string",optional:!0,description:"Inner label override (defaults to auto-formatted value)"}],render:(t,e)=>{const r=E(e.min,0),a=Math.max(r+1,E(e.max,100)),n=Math.max(r,Math.min(a,E(e.value,r))),i=(n-r)/(a-r),o=f(e.tone,"primary"),s=f(e.size,"md"),c=s==="lg"?220:s==="sm"?140:180,u=c/2,p=s==="lg"?18:s==="sm"?10:14,d=u-p,m=l("div",{class:"rui-gauge","data-tone":o,"data-size":s}),g=_t(c,u+p+4),b=u,h=u,v=b-d,y=h,x=b+d,w=h;if(g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${x},${w}`,fill:"none",stroke:"var(--rui-color-border, #e2e8f0)","stroke-width":String(p),"stroke-linecap":"round"})),i>0){const C=Math.PI*i,N=b-d*Math.cos(C),I=h-d*Math.sin(C);g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${N.toFixed(2)},${I.toFixed(2)}`,fill:"none",stroke:`var(--rui-color-${o}, ${qe(0)})`,"stroke-width":String(p),"stroke-linecap":"round",class:"rui-gauge-arc"}))}m.append(g);const k=Md(n,r,a),T=f(e.label)||k;m.append(l("div",{class:"rui-gauge-value"},[T]));const S=f(e.caption);return S&&m.append(l("div",{class:"rui-gauge-caption"},[S])),m}};function Md(t,e,r){return e===0&&r===100?t%1===0?`${t}%`:`${t.toFixed(1)}%`:Math.abs(t)>=1e3?Math.round(t).toLocaleString():t%1===0?String(t):t.toFixed(t<10?2:1)}const Nd={name:"Heatmap",description:"Color-intensity matrix grid (calendar-style or correlation-style). Pass `xLabels`, `yLabels`, and a `values` array of arrays (rows × columns). Each cell's color intensity scales with the value relative to the global max. Use for activity heatmaps, schedule density, correlation matrices.",props:[{name:"xLabels",type:"string[]"},{name:"yLabels",type:"string[]"},{name:"values",type:"number[][]",description:"Matrix indexed by row (y), then column (x)"},{name:"title",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]}],render:(t,e)=>{const r=$(e.xLabels).map(p=>f(p)),a=$(e.yLabels).map(p=>f(p)),n=$(e.values).map(p=>$(p).map(d=>E(d,0))),i=f(e.tone,"primary"),o=Math.max(1,...n.flat()),s=l("div",{class:"rui-heatmap","data-tone":i});f(e.title)&&s.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const c=l("div",{class:"rui-heatmap-table"}),u=l("div",{class:"rui-heatmap-row rui-heatmap-row-header"});u.append(l("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const p of r)u.append(l("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[p]));return c.append(u),n.forEach((p,d)=>{const m=l("div",{class:"rui-heatmap-row"});m.append(l("div",{class:"rui-heatmap-cell rui-heatmap-ylabel"},[a[d]??String(d+1)])),p.forEach((g,b)=>{const h=o>0?g/o:0,v=l("div",{class:"rui-heatmap-cell rui-heatmap-value",style:`background:color-mix(in srgb, var(--rui-color-${i}, ${qe(0)}) ${Math.round(h*90+5)}%, transparent);`,title:`${r[b]??b+1} · ${a[d]??d+1}: ${g}`});v.append(l("span",{},[String(g)])),m.append(v)}),c.append(m)}),s.append(c),s}},Pd={name:"RadarChart",description:"Polygon chart with one axis per category. Use for skill maps, scorecards, capability comparisons, and any multi-dimensional snapshot. Each Series renders as a filled polygon — overlapping is expected for comparisons.",props:[{name:"axes",type:"string[]",description:"Category labels — one per radial axis"},{name:"series",type:"Series[]"},{name:"max",type:"number",optional:!0,description:"Outer ring value (default = max across series)"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=$(e.axes).map(g=>f(g)),a=Ad($(e.series)),n=Math.max(r.length,3),i=l("div",{class:"rui-chart rui-radar-chart"});f(e.title)&&i.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const o=Math.max(1,E(e.max,a.flatMap(g=>g.values).reduce((g,b)=>Math.max(g,b),1))),s=280,c=s/2,u=s/2,p=s/2-24,d=_t(s,s),m=4;for(let g=1;g<=m;g+=1){const b=p/m*g,h=[];for(let v=0;v<n;v+=1){const y=Math.PI*2*v/n-Math.PI/2;h.push(`${(c+b*Math.cos(y)).toFixed(1)},${(u+b*Math.sin(y)).toFixed(1)}`)}d.append(ce("polygon",{points:h.join(" "),fill:"none",stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}))}for(let g=0;g<n;g+=1){const b=Math.PI*2*g/n-Math.PI/2,h=c+p*Math.cos(b),v=u+p*Math.sin(b);d.append(ce("line",{x1:String(c),y1:String(u),x2:h.toFixed(1),y2:v.toFixed(1),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}));const y=c+(p+16)*Math.cos(b),x=u+(p+16)*Math.sin(b);d.append(ce("text",{x:y.toFixed(1),y:x.toFixed(1),"text-anchor":"middle","dominant-baseline":"middle",class:"rui-chart-label","font-size":"13","font-weight":"500"},[r[g]??""]))}return a.forEach((g,b)=>{const h=[];for(let v=0;v<n;v+=1){const y=g.values[v]??0,x=Math.max(0,Math.min(1,y/o)),w=Math.PI*2*v/n-Math.PI/2,k=c+p*x*Math.cos(w),T=u+p*x*Math.sin(w);h.push(`${k.toFixed(1)},${T.toFixed(1)}`)}d.append(ce("polygon",{points:h.join(" "),fill:qe(b),"fill-opacity":"0.2",stroke:qe(b),"stroke-width":"2","stroke-linejoin":"round"}))}),i.append(d),a.length>0&&i.append(Rn(a)),i}};function Id(t){return t.map((e,r)=>{const a=e,n=f(a.args?.[0],`Series ${r+1}`),i=$(a.args?.[1]).map(o=>{if(Array.isArray(o))return{x:E(o[0],0),y:E(o[1],0),label:f(o[2])};if(o&&typeof o=="object"){const s=o;return{x:E(s.x,0),y:E(s.y,0),label:f(s.label)}}return{x:0,y:0,label:""}});return{name:n,points:i}})}const Ed={name:"ScatterChart",description:'XY scatter plot — one dot per data point, optionally grouped by series. Pass each `Series(name, points)` with points as `{x, y, label?}` objects or `[x, y, label?]` tuples. Use for correlations, distributions, and "price vs. rating" style charts.',props:[{name:"series",type:"Series[]"},{name:"xLabel",type:"string",optional:!0},{name:"yLabel",type:"string",optional:!0},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=Id($(e.series)),a=l("div",{class:"rui-chart rui-scatter-chart"});f(e.title)&&a.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const n=640,i=280,o={left:50,right:16,top:16,bottom:40},s=n-o.left-o.right,c=i-o.top-o.bottom,u=r.flatMap(k=>k.points);if(u.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No points"])),a;const p=u.map(k=>k.x),d=u.map(k=>k.y),m=Math.min(...p),g=Math.max(...p),b=Math.min(...d),h=Math.max(...d),v=g-m||1,y=h-b||1,x=_t(n,i);if(jn(x,o,s,c,h,b),x.append(ce("line",{x1:String(o.left),y1:String(o.top+c),x2:String(o.left+s),y2:String(o.top+c),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((k,T)=>{k.points.forEach(S=>{const C=o.left+(S.x-m)/v*s,N=o.top+c-(S.y-b)/y*c,I=ce("circle",{cx:C.toFixed(1),cy:N.toFixed(1),r:"7",fill:qe(T),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});I.append(ce("title",{},[S.label||`${S.x}, ${S.y}`])),x.append(I)})}),f(e.xLabel)&&x.append(ce("text",{x:String(o.left+s/2),y:String(i-6),"text-anchor":"middle",class:"rui-chart-label","font-size":"14","font-weight":"500"},[f(e.xLabel)])),f(e.yLabel)){const T=o.top+c/2;x.append(ce("text",{x:String(14),y:String(T),"text-anchor":"middle",transform:`rotate(-90, 14, ${T})`,class:"rui-chart-label","font-size":"14","font-weight":"500"},[f(e.yLabel)]))}a.append(x);const w=r.map(k=>({name:k.name,values:k.points.map(T=>T.y)}));return w.length>0&&a.append(Rn(w)),a}},Ld={name:"Histogram",description:"Frequency distribution from raw numeric values. Pass `values` directly (the component bins them automatically) or pre-computed `bins` of `{label, count}` objects. Use for response-time histograms, score distributions, age buckets.",props:[{name:"values",type:"number[]",optional:!0,description:"Raw observations (binned automatically)"},{name:"bins",type:"object[]",optional:!0,description:"Pre-computed {label, count} entries (overrides `values`)"},{name:"binCount",type:"number",optional:!0,description:"Number of bins when computing from `values` (default 10)"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{let r=[];if(Array.isArray(e.bins)&&e.bins.length>0)r=e.bins.map(m=>{const g=m??{};return{label:f(g.label),count:E(g.count,0)}});else{const m=$(e.values).map(g=>E(g,NaN)).filter(g=>Number.isFinite(g));if(m.length>0){const g=Math.max(2,Math.min(50,Math.floor(E(e.binCount,10)))),b=Math.min(...m),y=(Math.max(...m)-b||1)/g,x=new Array(g).fill(0);for(const w of m){let k=Math.floor((w-b)/y);k>=g&&(k=g-1),k<0&&(k=0),x[k]+=1}r=x.map((w,k)=>{const T=b+k*y,S=T+y;return{label:`${Dn(T)}–${Dn(S)}`,count:w}})}}const a=l("div",{class:"rui-chart rui-histogram"});if(f(e.title)&&a.append(l("div",{class:"rui-chart-title"},[f(e.title)])),r.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No data"])),a;const n=640,i=240,o={left:40,right:12,top:16,bottom:50},s=n-o.left-o.right,c=i-o.top-o.bottom,u=Math.max(1,...r.map(m=>m.count)),p=s/r.length,d=_t(n,i);return jn(d,o,s,c,u),r.forEach((m,g)=>{const b=o.left+g*p+p*.1,h=p*.8,v=m.count/u*c,y=o.top+c-v,x=ce("rect",{x:b.toFixed(1),y:y.toFixed(1),width:h.toFixed(1),height:v.toFixed(1),fill:qe(0),rx:"2"});x.append(ce("title",{},[`${m.label}: ${m.count}`])),d.append(x),d.append(ce("text",{x:(b+h/2).toFixed(1),y:String(o.top+c+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[m.label]))}),a.append(d),a}};function Dn(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function jn(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const c=s/4,u=e.top+a-c*a;t.append(ce("line",{x1:String(e.left),x2:String(e.left+r),y1:String(u),y2:String(u),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ce("text",{x:String(e.left-8),y:String(u+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((i+(n-i)*c)*10)/10)]))}}const zd=["numeric","alphanumeric"];function Rd(t,e,r,a,n,i,o){const s=l("div",{class:"rui-pin-input","data-disabled":n?"true":"false"}),c=[];for(let d=0;d<e;d+=1){const m=l("input",{class:"rui-pin-input-slot",id:d===0?t:null,maxlength:"1",autocomplete:"one-time-code",inputmode:r==="numeric"?"numeric":"text",type:i?"password":"text","aria-label":`Digit ${d+1}`,value:a.charAt(d)||"",disabled:n?"":null});c.push(m),s.append(m)}const u=d=>{const m=d.closest(".rui-pin-input");return m?Array.from(m.querySelectorAll(".rui-pin-input-slot")):c},p=d=>u(d).map(m=>m.value).join("").slice(0,e);return c.forEach((d,m)=>{d.oninput=g=>{const b=g.currentTarget,h=u(b);let v=b.value;if(r==="numeric"?v=v.replace(/\D/g,""):v=v.replace(/[^A-Za-z0-9]/g,""),v.length>1){const y=v.split("");y.slice(0,e-m).forEach((w,k)=>{const T=h[m+k];T&&(T.value=w)});const x=Math.min(m+y.length,e-1);h[x]?.focus()}else b.value=v,v&&m<e-1&&h[m+1]?.focus();o?.(p(b))},d.onkeydown=g=>{const b=g,h=b.currentTarget,v=u(h);if(b.key==="Backspace"&&!h.value&&m>0){b.preventDefault(),v[m-1]?.focus();const y=v[m-1];y&&(y.value=""),o?.(p(h))}else b.key==="ArrowLeft"&&m>0?(b.preventDefault(),v[m-1]?.focus()):b.key==="ArrowRight"&&m<e-1&&(b.preventDefault(),v[m+1]?.focus())}}),s}const Dd={name:"PinInput",description:'Per-digit PIN entry. Auto-advances focus as the user types and supports paste. Pass a `$variable` as `value` for two-way binding (the bound value is the joined string). Use `type="numeric"` for PINs / 2FA codes, `"alphanumeric"` for invite codes.',props:[{name:"id",type:"string"},{name:"length",type:"number",optional:!0,description:"Number of slots (default 4)"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"type",type:"string",optional:!0,enum:zd},{name:"mask",type:"boolean",optional:!0,description:"Render slots as `<input type=password>`"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current joined string on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=Math.max(1,Math.min(12,Math.floor(E(e.length,4)))),i=f(e.type,"numeric"),o=f(e.value),s=A(e.disabled),c=A(e.mask),u=t.argMeta?.[2]?.stateRef;return Rd(a,n,i,o,s,c,p=>{u&&r.setState(u,p),r.invoke(e.onChange,p)})}};function jd(t){if(!t)return{score:0,label:""};let e=0;return t.length>=8&&(e+=1),t.length>=12&&(e+=1),/[A-Z]/.test(t)&&/[a-z]/.test(t)&&(e+=1),/[0-9]/.test(t)&&(e+=1),/[^A-Za-z0-9]/.test(t)&&(e+=1),e=Math.min(4,e),{score:e,label:["Too short","Weak","Fair","Good","Strong"][e]??""}}const Bd={name:"PasswordInput",description:"Password input with a show/hide toggle and an optional strength meter. Pass a `$variable` as `value` for two-way binding. Set `strengthMeter=true` to render a 4-step indicator and label.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"strengthMeter",type:"boolean",optional:!0,aliases:["showStrength"]},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=r.useInstanceState("visible",!1),i=n.get(),o=A(e.disabled),s=l("div",{class:"rui-password-input","data-disabled":o?"true":"false"}),c=f(e.label);c&&s.append(l("label",{class:"rui-password-input-label",for:a},[c]));const u=l("div",{class:"rui-password-input-row"}),p=l("input",{type:i?"text":"password",class:"rui-password-input-field",id:a,name:a,autocomplete:"current-password",placeholder:f(e.placeholder),value:f(e.value),disabled:o?"":null}),d=l("button",{type:"button",class:"rui-password-input-toggle","aria-label":i?"Hide password":"Show password"}),m=j(i?"eye-slash":"eye");m&&d.append(m),d.onclick=b=>{b.preventDefault();const h=!n.get();n.set(h);const x=b.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=h?"text":"password")};const g=t.argMeta?.[1]?.stateRef;if(g&&r.bindState(p,g,{event:"input",getValue:b=>b.value}),oe(p,e.onChange,r,{event:"input",getValue:b=>b.value}),u.append(p),u.append(d),s.append(u),A(e.strengthMeter)){const b=jd(f(e.value)),h=l("div",{class:"rui-password-input-strength","data-score":String(b.score)});for(let y=0;y<4;y+=1)h.append(l("span",{class:"rui-password-input-strength-bar","data-filled":y<b.score?"true":"false"}));const v=l("div",{class:"rui-password-input-strength-row"});v.append(h),b.label&&v.append(l("span",{class:"rui-password-input-strength-label"},[b.label])),s.append(v)}return s}},Od={name:"TagInput",description:"Tag/chip input — type a value, press Enter (or comma) to commit, click × on a chip to remove. Pass a `$variable` (array of strings) as `value` for two-way binding. Use for keywords, recipients, labels, skills, allowlists.",props:[{name:"id",type:"string"},{name:"value",type:"string[]",optional:!0,description:"Bound array of tag values"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"max",type:"number",optional:!0,description:"Maximum number of tags"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated array of tags whenever one is added or removed"}],render:(t,e,r)=>{const a=f(e.id),n=$(e.value).map(m=>f(m)).filter(Boolean),i=Math.max(0,Math.floor(E(e.max,0))),o=A(e.disabled),s=t.argMeta?.[1]?.stateRef,c=m=>{s&&r.setState(s,m),r.invoke(e.onChange,m)},u=f(e.label),p=l("div",{class:"rui-tag-input","data-disabled":o?"true":"false"});for(const m of n){const g=l("span",{class:"rui-tag-input-chip"});g.append(l("span",{},[m]));const b=l("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${m}`},["×"]);b.onclick=()=>c(n.filter(h=>h!==m)),g.append(b),p.append(g)}const d=l("input",{type:"text",class:"rui-tag-input-field",id:a,name:a,placeholder:f(e.placeholder,n.length===0?"Add tags…":""),disabled:o?"":null,autocomplete:"off"});if(d.onkeydown=m=>{const g=m,b=g.currentTarget;if(g.key==="Enter"||g.key===","){g.preventDefault();const h=b.value.trim();if(!h||i>0&&n.length>=i)return;if(n.includes(h)){b.value="";return}c([...n,h]),b.value=""}else g.key==="Backspace"&&b.value===""&&n.length>0&&(g.preventDefault(),c(n.slice(0,-1)))},p.append(d),u){const m=l("div",{class:"rui-tag-input-wrapper"});return m.append(l("label",{class:"rui-tag-input-label",for:a},[u])),m.append(p),m}return p}};function _d(t){return $(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,a=f(r.label??r.name??r.value??r.id);return{value:f(r.handle??r.value??r.id??r.name??r.label),label:a}}return{value:"",label:""}}).filter(e=>e.value||e.label)}const Fd={name:"MentionInput",description:"Multi-line input with inline @-mention suggestions. Typing `@` opens a popover listing the provided `people` (filtered by what follows). Selecting an option inserts `@label` into the text. Pass a `$variable` as `value` for two-way binding. Use for comments, task notes, chat composers.",props:[{name:"id",type:"string"},{name:"people",type:"any[]",description:"Available mentions: strings or {value, label} objects"},{name:"value",type:"string",optional:!0,description:"Bound text (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0,description:"TextArea rows (default 3)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current text on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=_d(e.people),i=A(e.disabled),o=l("div",{class:"rui-mention-input","data-disabled":i?"true":"false"}),s=l("textarea",{class:"rui-mention-input-field",id:a,name:a,rows:String(Math.max(2,Math.floor(E(e.rows,3)))),placeholder:f(e.placeholder,"Type @ to mention someone"),disabled:i?"":null});s.value=f(e.value);const c=l("div",{class:"rui-mention-input-suggestions","data-open":"false"}),u=r.useInstanceState("activeIndex",0),p=r.useInstanceState("matches",[]),d=r.useInstanceState("query",null),m=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-suggestions")??null,g=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-field")??null,b=(x,w)=>{const k=x.value,T=x.selectionStart??k.length,S=k.slice(0,T),C=S.lastIndexOf("@");if(C===-1)return;const N=k.slice(T),I=`@${w.value} `,L=S.slice(0,C)+I+N;x.value=L;const R=C+I.length;x.selectionStart=x.selectionEnd=R,x.dispatchEvent(new Event("input",{bubbles:!0})),x.focus()},h=(x,w)=>{if(x.replaceChildren(),w===null){x.setAttribute("data-open","false"),p.set([]);return}const k=w.toLowerCase(),S=n.filter(N=>N.label.toLowerCase().includes(k)||N.value.toLowerCase().includes(k)).slice(0,6);if(p.set(S),S.length===0){x.setAttribute("data-open","false");return}const C=Math.min(u.get(),S.length-1);u.set(C),x.setAttribute("data-open","true"),S.forEach((N,I)=>{const L=l("button",{type:"button",class:"rui-mention-input-option","data-value":N.value,"data-active":I===C?"true":"false"});L.append(l("span",{class:"rui-mention-input-option-label"},[N.label])),N.value&&N.value!==N.label&&L.append(l("span",{class:"rui-mention-input-option-handle"},[`@${N.value}`])),L.onmousedown=R=>R.preventDefault(),L.onclick=R=>{const q=R.currentTarget,O=g(q),U=m(q);O&&b(O,N),d.set(null),U&&h(U,null)},x.append(L)})},v=x=>{const w=m(x);if(!w)return;const k=x.selectionStart??x.value.length,T=x.value.slice(0,k),S=/@([\w-]*)$/.exec(T),C=S?S[1]??"":null;d.set(C),h(w,C)},y=t.argMeta?.[2]?.stateRef;return y?r.bindState(s,y,{event:"input",getValue:x=>{const w=x;return v(w),w.value}}):s.oninput=x=>{v(x.currentTarget)},oe(s,e.onChange,r,{event:"input",getValue:x=>x.value}),s.onkeydown=x=>{const w=x.currentTarget,k=m(w);if(!k||k.getAttribute("data-open")!=="true")return;const T=p.get();if(T.length!==0)if(x.key==="ArrowDown"){x.preventDefault();const S=(u.get()+1)%T.length;u.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((N,I)=>N.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="ArrowUp"){x.preventDefault();const S=(u.get()-1+T.length)%T.length;u.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((N,I)=>N.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="Enter"||x.key==="Tab"){x.preventDefault();const S=T[u.get()];S&&(b(w,S),d.set(null),h(k,null))}else x.key==="Escape"&&(d.set(null),h(k,null))},s.onblur=x=>{const w=x.currentTarget;setTimeout(()=>{const k=m(w);d.set(null),k&&h(k,null)},120)},o.append(s),o.append(c),h(c,d.get()),o}},Ud={name:"TimePicker",description:'Time-of-day picker that wraps `<input type="time">`. Pass a `$variable` as `value` for two-way binding (HH:MM 24-hour). Set `step` to constrain to specific increments (e.g. 900 for 15-minute buckets).',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"HH:MM value; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0},{name:"max",type:"string",optional:!0},{name:"step",type:"number",optional:!0,description:"Seconds between selectable times"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new HH:MM string when the user picks a time"}],render:(t,e,r)=>{const a=f(e.id),n=l("div",{class:"rui-time-picker"}),i=f(e.label);i&&n.append(l("label",{class:"rui-time-picker-label",for:a},[i]));const o=l("input",{type:"time",class:"rui-time-picker-input",id:a,name:a,value:f(e.value),min:f(e.min)||null,max:f(e.max)||null,step:e.step!=null?String(E(e.step,60)):null,disabled:A(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),oe(o,e.onChange,r,{event:"change",getValue:c=>c.value}),n.append(o),n}},Hd={name:"DateTimePicker",description:'Combined date + time picker — wraps `<input type="datetime-local">`. Pass a `$variable` as `value` for two-way binding (ISO `YYYY-MM-DDTHH:MM`).',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"ISO date-time value; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0},{name:"max",type:"string",optional:!0},{name:"step",type:"number",optional:!0,description:"Seconds between selectable times"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new ISO `YYYY-MM-DDTHH:MM` string"}],render:(t,e,r)=>{const a=f(e.id),n=l("div",{class:"rui-datetime-picker"}),i=f(e.label);i&&n.append(l("label",{class:"rui-datetime-picker-label",for:a},[i]));const o=l("input",{type:"datetime-local",class:"rui-datetime-picker-input",id:a,name:a,value:f(e.value),min:f(e.min)||null,max:f(e.max)||null,step:e.step!=null?String(E(e.step,60)):null,disabled:A(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),oe(o,e.onChange,r,{event:"change",getValue:c=>c.value}),n.append(o),n}};function Bn(t,e){if(!e)return t;let r="",a=0;const n=String(t??"");for(const i of e){if(a>=n.length)break;if(i==="9"){for(;a<n.length&&!/\d/.test(n[a]??"");)a+=1;if(a>=n.length)break;r+=n[a],a+=1}else if(i==="A"){for(;a<n.length&&!/[a-zA-Z]/.test(n[a]??"");)a+=1;if(a>=n.length)break;r+=n[a],a+=1}else i==="*"?(r+=n[a],a+=1):(r+=i,n[a]===i&&(a+=1))}return r}const Vd={name:"MaskedInput",description:'Text input with an inline mask — `9` matches a digit, `A` matches a letter, `*` matches any character, every other character is a fixed delimiter. Useful for phone numbers, postal codes, credit cards. Pass `mask` (e.g. `"(999) 999-9999"`) and a `$variable` as `value`.',props:[{name:"id",type:"string"},{name:"mask",type:"string",description:"Mask pattern"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the masked value on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=f(e.mask),i=A(e.disabled),o=Bn(f(e.value),n),s=f(e.label),c=l("input",{type:"text",class:"rui-masked-input",id:a,name:a,value:o,placeholder:f(e.placeholder,n),disabled:i?"":null,autocomplete:"off"});c.value=o;const u=t.argMeta?.[2]?.stateRef,p=d=>{const m=d.value,g=Bn(m,n);if(g===m)return g;const b=d.selectionStart??g.length;d.value=g;const h=Math.min(g.length,b);try{d.setSelectionRange(h,h)}catch{}return g};if(u?r.bindState(c,u,{event:"input",getValue:d=>p(d)}):c.oninput=d=>{p(d.currentTarget??d.target)},oe(c,e.onChange,r,{event:"input",getValue:d=>d.value}),s){const d=l("div",{class:"rui-masked-input-wrapper"});return d.append(l("label",{class:"rui-masked-input-label",for:a},[s])),d.append(c),d}return c}},Wd={name:"FormSection",description:"Semantic grouping for related form fields — renders a small heading (`label`), optional helper paragraph, and stacks the children with consistent spacing. Use INSTEAD of wrapping fields in `Card` + `SectionHeader` by hand. Pair with `FieldSet` when the group is a true `<fieldset>` (radio sets, checkbox groups).",props:[{name:"label",type:"string",aliases:["title"]},{name:"children",type:"Node[]",aliases:["fields"]},{name:"helper",type:"string",optional:!0,aliases:["description"],description:"Description rendered below the label"}],render:(t,e,r)=>{const a=l("section",{class:"rui-form-section"}),n=l("header",{class:"rui-form-section-header"});n.append(l("h3",{class:"rui-form-section-label"},[f(e.label)]));const i=f(e.helper);i&&n.append(l("p",{class:"rui-form-section-helper"},[i])),a.append(n);const o=l("div",{class:"rui-form-section-body"});for(const s of $(e.children))o.append(r.renderNode(s));return a.append(o),a}},qd={name:"FieldSet",description:"Native `<fieldset>`/`<legend>` wrapper for accessible grouping of related controls. Use when assistive tech should announce the wrapper (radio sets, checkbox groups). For purely visual grouping prefer `FormSection`.",props:[{name:"legend",type:"string",aliases:["title","label"]},{name:"children",type:"Node[]",aliases:["fields"]},{name:"helper",type:"string",optional:!0,aliases:["hint","description"]},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("fieldset",{class:"rui-fieldset",disabled:A(e.disabled)?"":null});a.append(l("legend",{class:"rui-fieldset-legend"},[f(e.legend)]));const n=f(e.helper);n&&a.append(l("p",{class:"rui-fieldset-helper"},[n]));for(const i of $(e.children))a.append(r.renderNode(i));return a}},Kd={name:"ValidationSummary",description:"Aggregate error list rendered at the top of a form. Pass `errors` as `{label?, message, field?}` objects or plain strings. Pair with individual field hints via `FormControl(hint=...)`.",props:[{name:"errors",type:"any[]"},{name:"title",type:"string",optional:!0,description:'Heading (default "Please fix the following:")'},{name:"tone",type:"string",optional:!0,enum:["danger","warning"]}],render:(t,e)=>{const r=$(e.errors).map(c=>{if(!c)return null;if(typeof c=="string")return{label:"",message:c,field:""};if(typeof c=="object"){const u=c;return{label:f(u.label),message:f(u.message??u.error),field:f(u.field)}}return null}).filter(c=>c!==null&&c.message!=="");if(r.length===0)return l("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const a=f(e.tone,"danger"),n=l("aside",{class:"rui-validation-summary","data-tone":a,role:"alert"}),i=l("div",{class:"rui-validation-summary-title"}),o=j(a==="warning"?"triangle-exclamation":"circle-xmark",{className:"rui-validation-summary-icon"});o&&i.append(o),i.append(document.createTextNode(f(e.title,"Please fix the following:"))),n.append(i);const s=l("ul",{class:"rui-validation-summary-list"});for(const c of r){const u=l("li",{class:"rui-validation-summary-item"});c.label&&u.append(l("strong",{},[`${c.label}: `])),u.append(document.createTextNode(c.message)),s.append(u)}return n.append(s),n}};function Gd(t){return $(t).map(e=>{if(!e||typeof e!="object")return{title:f(e),details:"",content:null};const r=e;return{title:f(r.title),details:f(r.details),content:r.content??null}})}const Yd={name:"MultiStepForm",description:'Multi-step / wizard form composite. Renders a `Steps` indicator, the active step\'s `content`, and Prev/Next buttons that drive a `$variable` for the current 0-indexed step. Use INSTEAD of hand-rolling `Steps` + content + manual prev/next wiring. The submit button is rendered on the final step (override via `submitLabel`). Step indicator direction defaults to `column` (stacked next to the content); set `stepsLayout: "row"` for a classic horizontal stepper.',props:[{name:"steps",type:"object[]",description:"Array of {title, details?, content} step objects"},{name:"current",type:"number",description:"0-indexed active step — bind a $variable"},{name:"onSubmit",type:"callable",optional:!0,description:"Callable fired when the user clicks Submit on the final step"},{name:"prevLabel",type:"string",optional:!0,description:'Default "Back"'},{name:"nextLabel",type:"string",optional:!0,description:'Default "Continue"'},{name:"submitLabel",type:"string",optional:!0,description:'Default "Submit" (final step)'},{name:"stepsLayout",type:"string",optional:!0,enum:["column","row"],aliases:["layout","stepsDirection"],description:'Direction of the steps indicator (default "column")'}],render:(t,e,r)=>{const a=Gd(e.steps),n=a.length,i=Math.max(0,Math.min(n-1,Math.floor(E(e.current,0)))),o=t.argMeta?.[1]?.stateRef,s=f(e.stepsLayout,"column").toLowerCase(),c=s==="row"||s==="horizontal"?"row":"column",u=l("div",{class:"rui-multi-step-form","data-layout":c}),p=l("ol",{class:"rui-steps rui-multi-step-form-steps","data-layout":c});a.forEach((x,w)=>{const k=l("li",{class:"rui-steps-item","data-active":w===i?"true":"false","data-complete":w<i?"true":"false"});k.append(l("div",{class:"rui-steps-title"},[x.title||`Step ${w+1}`])),x.details&&k.append(l("div",{class:"rui-steps-details"},[x.details])),p.append(k)}),u.append(p);const d=l("div",{class:"rui-multi-step-form-body"}),m=a[i];m&&m.content&&d.append(r.renderNode(m.content)),u.append(d);const g=l("div",{class:"rui-multi-step-form-footer"}),b=l("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:i<=0?"":null},[f(e.prevLabel,"Back")]);o&&i>0&&(b.onclick=()=>r.setState(o,i-1));const h=i>=n-1,v=h?f(e.submitLabel,"Submit"):f(e.nextLabel,"Continue"),y=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[v]);return y.onclick=()=>{h?r.invoke(e.onSubmit):o&&r.setState(o,i+1)},g.append(b),g.append(l("span",{class:"rui-multi-step-form-progress"},[`${i+1} / ${n}`])),g.append(y),u.append(g),u}};function Xd(t){return $(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:f(r.title),message:f(r.message),time:f(r.time),icon:f(r.icon),tone:f(r.tone,"default"),unread:A(r.unread),avatarSrc:f(r.avatarSrc),onClick:r.onClick??r.action}}).filter(e=>e!==null)}const Jd={name:"InboxPanel",description:"Grouped notification list — entries are grouped into Unread/Earlier sections, with a count chip on each group header. Pass `items` as `{title, message, time, icon?, tone?, unread?, avatarSrc?, onClick?}` objects (`action` is also accepted as an alias). Pair with a `SectionHeader` for the panel title (the component does not render its own title to avoid duplication). Use for top-bar notification trays, activity drawers, and alert center pages.",props:[{name:"items",type:"object[]"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when there are no notifications"},{name:"onMarkAllRead",type:"callable",optional:!0,description:'Callable fired by the "Mark all as read" button'}],render:(t,e,r)=>{const a=Xd(e.items),n=a.filter(c=>c.unread),i=a.filter(c=>!c.unread),o=l("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&n.length>0){const c=l("div",{class:"rui-inbox-panel-toolbar"}),u=l("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);u.onclick=()=>r.invoke(e.onMarkAllRead),c.append(u),o.append(c)}if(a.length===0)return o.append(l("div",{class:"rui-inbox-panel-empty"},[f(e.emptyLabel,"You're all caught up.")])),o;const s=(c,u)=>{if(u.length===0)return;const p=l("section",{class:"rui-inbox-panel-group"}),d=l("header",{class:"rui-inbox-panel-group-head"});d.append(l("span",{class:"rui-inbox-panel-group-label"},[c])),d.append(l("span",{class:"rui-inbox-panel-group-count"},[String(u.length)])),p.append(d);for(const m of u){const g=vn.render({__kind:"Component",name:"Notification",args:[],argMeta:[]},{title:m.title,message:m.message,time:m.time,icon:m.icon,tone:m.tone,avatarSrc:m.avatarSrc,unread:m.unread},r);typeof m.onClick=="function"&&(g.setAttribute("data-clickable","true"),g.onclick=()=>r.invoke(m.onClick)),p.append(g)}o.append(p)};return s(`Unread (${n.length})`,n),s("Earlier",i),o}};function Zd(t){return $(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:f(r.title),description:f(r.description),done:A(r.done),onClick:r.onClick??r.action,cta:f(r.cta,"Start")}}).filter(e=>e!==null)}const Qd={name:"OnboardingChecklist",description:'Step-by-step product checklist with completion progress at the top. Pass `items` as `{title, description?, done?, onClick?, cta?}` objects (`action` is also accepted as an alias). The progress percentage is computed automatically from `done`. Use on first-run dashboards, empty workspaces, and "complete your profile" surfaces.',props:[{name:"items",type:"object[]"},{name:"title",type:"string",optional:!0,description:'Heading (default "Getting started")'},{name:"subtitle",type:"string",optional:!0}],render:(t,e,r)=>{const a=Zd(e.items),n=a.filter(d=>d.done).length,i=Math.max(1,a.length),o=Math.round(n/i*100),s=l("div",{class:"rui-onboarding-checklist"}),c=l("header",{class:"rui-onboarding-checklist-header"});c.append(l("h3",{class:"rui-onboarding-checklist-title"},[f(e.title,"Getting started")]));const u=f(e.subtitle);u&&c.append(l("p",{class:"rui-onboarding-checklist-subtitle"},[u])),c.append(l("div",{class:"rui-onboarding-checklist-progress"},[l("div",{class:"rui-onboarding-checklist-bar"},[l("div",{class:"rui-onboarding-checklist-fill",style:`width:${o}%`})]),l("span",{class:"rui-onboarding-checklist-meta"},[`${n}/${a.length} complete`])])),s.append(c);const p=l("ol",{class:"rui-onboarding-checklist-list"});for(const d of a){const m=l("li",{class:"rui-onboarding-checklist-item","data-done":d.done?"true":"false"}),g=l("span",{class:"rui-onboarding-checklist-marker"}),b=j(d.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});b&&g.append(b),m.append(g);const h=l("div",{class:"rui-onboarding-checklist-body"});if(h.append(l("div",{class:"rui-onboarding-checklist-item-title"},[d.title])),d.description&&h.append(l("p",{class:"rui-onboarding-checklist-item-description"},[d.description])),m.append(h),!d.done&&typeof d.onClick=="function"){const v=l("button",{type:"button",class:"rui-button","data-variant":"secondary","data-size":"sm"},[d.cta]);v.onclick=()=>r.invoke(d.onClick),m.append(v)}p.append(m)}return s.append(p),s}};function On(t){const e=l("div",{class:`rui-${t.klass}`});if(t.iconName){const a=j(t.iconName,{className:t.iconClass});a&&e.append(a)}t.title&&e.append(l("h3",{class:`rui-${t.klass}-title`},[t.title])),t.description&&e.append(l("p",{class:`rui-${t.klass}-description`},[t.description]));const r=$(t.actions);if(r.length>0){const a=l("div",{class:`rui-${t.klass}-actions`});for(const n of r)a.append(t.helpers.renderNode(n));e.append(a)}return e}const ep={name:"LoadingState",description:"Full-card loading state — large spinner + title + description. Use while a query is in flight or while a long-running tool runs. For tiny inline loaders prefer `Spinner`; for skeleton placeholders prefer `Skeleton`.",props:[{name:"title",type:"string",optional:!0,description:'Default "Loading…"'},{name:"description",type:"string",optional:!0}],render:(t,e)=>{const r=l("div",{class:"rui-loading-state"}),a=l("span",{class:"rui-spinner","data-size":"lg","data-tone":"primary"});a.append(l("span",{class:"rui-spinner-ring","aria-hidden":"true"})),r.append(a),r.append(l("h3",{class:"rui-loading-state-title"},[f(e.title,"Loading…")]));const n=f(e.description);return n&&r.append(l("p",{class:"rui-loading-state-description"},[n])),r}},tp={name:"ErrorState",description:"Full-card error placeholder. Pairs a danger icon with title, description, and a row of recovery actions (Retry / Contact support / Go home). Pass `actions` as Button(...) entries.",props:[{name:"title",type:"string",optional:!0,description:'Default "Something went wrong"'},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon (default `circle-exclamation`)"}],render:(t,e,r)=>On({klass:"error-state",iconName:f(e.icon,"circle-exclamation"),iconClass:"rui-error-state-icon",title:f(e.title,"Something went wrong"),description:f(e.description),actions:e.actions,helpers:r})},rp={name:"SuccessState",description:'Full-card success placeholder. Use for confirmation screens ("Order placed", "Payment succeeded", "Account verified") at the end of a flow. Pass `actions` for follow-up CTAs.',props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Default `circle-check`"}],render:(t,e,r)=>On({klass:"success-state",iconName:f(e.icon,"circle-check"),iconClass:"rui-success-state-icon",title:f(e.title),description:f(e.description),actions:e.actions,helpers:r})},ap={name:"Tour",description:"Product-tour controller — renders the current step's title, description, and a Prev/Next/Skip row. Bind `current` to a `$variable` (0-indexed). Pass `steps` as `{title, description, target?}` objects; the optional `target` is a CSS selector that renders alongside the step for designers to reference.",props:[{name:"steps",type:"object[]"},{name:"current",type:"number",description:"0-indexed active step — bind a $variable"},{name:"open",type:"boolean",optional:!0,description:"Whether the tour is visible"},{name:"onComplete",type:"callable",optional:!0}],render:(t,e,r)=>{const a=$(e.steps).map(v=>{if(!v||typeof v!="object")return{title:f(v),description:"",target:""};const y=v;return{title:f(y.title),description:f(y.description),target:f(y.target)}}),n=e.open===void 0?!0:A(e.open),i=a.length,o=Math.max(0,Math.min(i-1,Math.floor(E(e.current,0)))),s=t.argMeta?.[1]?.stateRef,c=l("div",{class:"rui-tour","data-open":n?"true":"false"});if(!n||i===0)return c;const u=a[o];if(!u)return c;const p=l("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});p.append(l("div",{class:"rui-tour-step"},[`Step ${o+1} of ${i}`])),p.append(l("h3",{class:"rui-tour-title"},[u.title])),u.description&&p.append(l("p",{class:"rui-tour-description"},[u.description])),u.target&&p.append(l("div",{class:"rui-tour-target"},[`Target: ${u.target}`]));const d=l("div",{class:"rui-tour-footer"}),m=l("button",{type:"button",class:"rui-button","data-variant":"ghost"},["Skip"]);m.onclick=()=>r.invoke(e.onComplete);const g=l("button",{type:"button",class:"rui-button","data-variant":"secondary",disabled:o<=0?"":null},["Back"]);s&&o>0&&(g.onclick=()=>r.setState(s,o-1));const b=o>=i-1,h=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[b?"Finish":"Next"]);return h.onclick=()=>{b?r.invoke(e.onComplete):s&&r.setState(s,o+1)},d.append(m,g,h),p.append(d),c.append(p),c}},np={name:"Spotlight",description:'Single-step product highlight — a dimmed full-page overlay with a ring around the focused area and a small explainer card. Use for one-off feature reveals ("Try the new commands menu"). Bind `open` to a `$variable` to dismiss.',props:[{name:"title",type:"string"},{name:"open",type:"boolean",optional:!0,description:"Whether the spotlight is visible — typically a $variable (default true)"},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0,aliases:["action"]}],render:(t,e,r)=>{const a=e.open===void 0?!0:A(e.open),n=l("div",{class:"rui-spotlight","data-open":a?"true":"false"});if(!a)return n;const i=l("div",{class:"rui-spotlight-card"});i.append(l("h3",{class:"rui-spotlight-title"},[f(e.title)]));const o=f(e.description);o&&i.append(l("p",{class:"rui-spotlight-description"},[o]));const s=$(e.actions);if(s.length>0){const u=l("div",{class:"rui-spotlight-actions"});for(const p of s)u.append(r.renderNode(p));i.append(u)}const c=t.argMeta?.[1]?.stateRef;return c&&(n.onclick=u=>{u.target===n&&r.setState(c,!1)}),n.append(i),n}},ip={name:"Sticky",description:"Wraps content in a `position: sticky` container so it pins to the top (or bottom) of the nearest scrollable ancestor. Use for toolbar action rows above tables, in-page navs, status banners.",props:[{name:"children",type:"Node[]"},{name:"side",type:"string",optional:!0,enum:["top","bottom"]},{name:"offset",type:"string",optional:!0,description:"CSS offset (default 0)"},{name:"zIndex",type:"number",optional:!0,description:"Z-index (default 10)"}],render:(t,e,r)=>{const a=f(e.side,"top"),n=re(e.offset,"0"),i=Math.max(0,Math.floor(E(e.zIndex,10))),o=`position:sticky;${a}:${n};z-index:${i};`,s=l("div",{class:"rui-sticky",style:o});for(const c of $(e.children))s.append(r.renderNode(c));return s}},op={name:"ResizablePanels",description:"Two-pane horizontal split with a draggable divider. The user can drag the divider to resize the primary pane; defaults respect the starting width. Use for code editors, file browsers, master/detail layouts that need user-controllable proportions.",props:[{name:"primary",type:"Node[]"},{name:"secondary",type:"Node[]"},{name:"initialPrimaryWidth",type:"string",optional:!0,description:"CSS width for the primary pane (default 40%)"},{name:"minPrimaryWidth",type:"string",optional:!0,description:"Min width (default 240px)"}],render:(t,e,r)=>{const a=re(e.initialPrimaryWidth,"40%"),n=re(e.minPrimaryWidth,"240px"),i=l("div",{class:"rui-resizable-panels",style:`--rui-resizable-primary:${a};--rui-resizable-min:${n};`}),o=l("div",{class:"rui-resizable-panel rui-resizable-panel-primary"});for(const u of $(e.primary))o.append(r.renderNode(u));const s=l("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),c=l("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const u of $(e.secondary))c.append(r.renderNode(u));return i.append(o,s,c),s.onpointerdown=u=>{const p=u,d=p.currentTarget;d.setPointerCapture(p.pointerId);const m=d.closest(".rui-resizable-panels");if(!m)return;const g=m.getBoundingClientRect(),b=v=>{const y=(v.clientX-g.left)/g.width*100,x=Math.max(15,Math.min(85,y));m.style.setProperty("--rui-resizable-primary",`${x}%`)},h=v=>{d.releasePointerCapture(v.pointerId),d.removeEventListener("pointermove",b),d.removeEventListener("pointerup",h)};d.addEventListener("pointermove",b),d.addEventListener("pointerup",h)},i}},sp={name:"MasonryGrid",description:"Pinterest-style column grid. Children flow into columns that reflow on viewport changes. Use for galleries, social-style feeds, and mixed-height card walls. Prefer `Grid` when children should share the same height per row.",props:[{name:"items",type:"Node[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default 3)"},{name:"gap",type:"string",optional:!0,enum:["xs","s","m","l","xl"]}],render:(t,e,r)=>{const a=Math.max(1,Math.min(6,Math.floor(E(e.columns,3)))),n=f(e.gap,"m"),i=l("div",{class:"rui-masonry-grid","data-columns":String(a),"data-gap":n});for(const o of $(e.items))i.append(r.renderNode(o));return i}},lp={name:"Drawer",description:"Side drawer overlay shown when `open` is true. Pass a `$variable` as `open` to control it. Choose `side` for slide direction (default right). `onClose` fires whenever the drawer is dismissed (× button or backdrop click).",props:[{name:"title",type:"string"},{name:"open",type:"boolean",description:"Open/closed state — usually a $variable"},{name:"children",type:"Node[]"},{name:"side",type:"string",optional:!0,enum:["right","left","top","bottom"]},{name:"footer",type:"Node[]",optional:!0,description:"Optional footer actions row"},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"],description:"Callable invoked when the drawer is dismissed"}],render:(t,e,r)=>{const a=A(e.open),n=f(e.side,"right"),i=l("div",{class:"rui-sheet-overlay","data-open":a?"true":"false","data-side":n}),o=l("aside",{class:"rui-sheet",role:"dialog","aria-modal":"true","data-side":n}),s=l("header",{class:"rui-sheet-header"});s.append(l("h3",{class:"rui-sheet-title"},[f(e.title)]));const c=l("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),u=t.argMeta?.[1]?.stateRef,p=()=>{u&&r.setState(u,!1),r.invoke(e.onClose)};c.onclick=p,i.onclick=g=>{g.target===i&&p()},s.append(c),o.append(s);const d=l("div",{class:"rui-sheet-body"});for(const g of $(e.children))d.append(r.renderNode(g));o.append(d);const m=$(e.footer);if(m.length>0){const g=l("footer",{class:"rui-sheet-footer"});for(const b of m)g.append(r.renderNode(b));o.append(g)}return i.append(o),i}},cp={name:"TopBar",description:'Compact header strip that pairs a title (or breadcrumb) with search and action slots. Use INSTEAD of hand-rolling a `Stack(direction="row")` above a page. For full SaaS shells use `Navbar` (links) or `AppShell` (sidebar + topbar + content).',props:[{name:"title",type:"string",optional:!0},{name:"subtitle",type:"string",optional:!0},{name:"left",type:"Node[]",optional:!0,aliases:["badges"],description:"Leading slot (breadcrumbs, brand, status, badges)"},{name:"center",type:"Node[]",optional:!0,aliases:["search"],description:"Centered slot (search bar, segmented control)"},{name:"right",type:"Node[]",optional:!0,aliases:["actions"],description:"Trailing slot (actions, avatar)"},{name:"sticky",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("header",{class:"rui-topbar","data-sticky":A(e.sticky)?"true":"false"}),n=l("div",{class:"rui-topbar-side rui-topbar-left"}),i=f(e.title);if(i){const c=l("div",{class:"rui-topbar-title-block"});c.append(l("h2",{class:"rui-topbar-title"},[i]));const u=f(e.subtitle);u&&c.append(l("p",{class:"rui-topbar-subtitle"},[u])),n.append(c)}for(const c of $(e.left))n.append(r.renderNode(c));a.append(n);const o=$(e.center);if(o.length>0){const c=l("div",{class:"rui-topbar-side rui-topbar-center"});for(const u of o)c.append(r.renderNode(u));a.append(c)}const s=l("div",{class:"rui-topbar-side rui-topbar-right"});for(const c of $(e.right))s.append(r.renderNode(c));return a.append(s),a}},up={name:"NavLink",description:'Anchor that navigates to a route on click and stays in sync with the URL hash. Reflects `data-active="true"` (and `aria-current="page"` for assistive tech) when the current path matches `to` (set `exact=true` to require exact equality instead of prefix matching).',props:[{name:"label",type:"string",description:"Visible link text."},{name:"to",type:"string",description:'Target route path, e.g. "/about".'},{name:"variant",type:"string",optional:!0,enum:["default","primary","ghost","pill"],description:"Visual variant."},{name:"exact",type:"boolean",optional:!0,description:"Match the current path exactly (default: prefix match)."},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown before the label."}],render:(t,e,r)=>{const a=f(e.label,""),n=f(e.to,"/"),i=f(e.variant,"default"),o=A(e.exact,!1),s=r.router,c=s.getPath(),u=c?o?c===n:n==="/"?c==="/":c===n?!0:c.startsWith(n+"/"):!1,p=l("a",{class:"rui-nav-link","data-variant":i,"data-active":u?"true":"false","aria-current":u?"page":null,href:"#"+(n.startsWith("/")?n:"/"+n)}),d=j(e.icon,{className:"rui-nav-link-icon"});return d&&p.append(d),p.append(l("span",{class:"rui-nav-link-label"},[a])),p.onclick=m=>{m.defaultPrevented||m.button===0&&(m.metaKey||m.ctrlKey||m.shiftKey||m.altKey||(m.preventDefault(),s.navigate(n)))},p}},dp=["primary","secondary","ghost","danger"],pp=["xs","sm","md","lg","xl","small","normal","large"];function mp(t){const e=f(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="small"||e==="sm"?"sm":e==="large"||e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":e==="normal"||e==="md"||e===""?"md":e==="xs"||e==="sm"||e==="md"||e==="lg"||e==="xl"?e:"md"}function fp(t){return $(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=f(a.value??a.label);return{value:n,label:f(a.label,n)}}const r=f(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function Ft(t){return $(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function gp(t){return $(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=f(a.value??a.label);return{value:n,label:f(a.label,n),group:f(a.group)||void 0,shortcut:f(a.shortcut)||void 0,action:a.action}}const r=f(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function _n(t){return $(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=f(a.name??a.label);return{name:n,label:f(a.label,n),type:f(a.type,"text")||"text"}}const r=f(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function hp(t){return Ft(t).map((e,r)=>({id:f(e.id,`task-${r}`),label:f(e.label??e.name,`Task ${r+1}`),start:f(e.start),end:f(e.end),progress:e.progress!=null?E(e.progress,0):void 0}))}function Ke(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function bp(t,e){const r=t.split(`
|
|
96
|
+
}`},catch:{summary:"Handle an error thrown inside the preceding `try` block.",syntax:"catch (error) { ... }",example:"catch (e) { $error = e }"},finally:{summary:"Run cleanup after `try` / `catch`, regardless of outcome.",syntax:"finally { ... }",example:"finally { $loading = false }"},throw:{summary:"Raise an error — caught by an enclosing `try` / `catch`.",syntax:"throw value",example:'throw "invalid state"'},new:{summary:"Construct an instance of a host class (Date, Map, Set, …).",syntax:"new Constructor(args)",example:"let now = new Date()"},typeof:{summary:`Return a string naming a value's type ("number", "string", …).`,syntax:"typeof value",example:'if (typeof x === "number") { ... }'},instanceof:{summary:"Test whether a value is an instance of a constructor.",syntax:"value instanceof Constructor",example:"if (d instanceof Date) { ... }"},delete:{summary:"Remove a property from an object.",syntax:"delete obj.prop",example:"delete $form.draft"},void:{summary:"Evaluate an expression and yield `undefined`.",syntax:"void expression",example:"void sideEffect()"}};function Ja(t=Pt){const e=()=>({inBacktick:!1,inBlockComment:!1}),r=d=>({...d}),a=new Set(t.atoms),n=new Set(t.keywords),i=/^[A-Z][A-Za-z0-9_]*/,o=/^[a-z_][A-Za-z0-9_]*/,s=/^-?\d+(?:\.\d+)?/,c=new Set([...t.operators.join(""),..."=<>!&|"]),u=(d,m)=>{for(;!d.eol();){const g=d.next();if(!g)return;if(g==="\\"){d.next();continue}if(g===m)return}};return{startState:e,copyState:r,token:(d,m)=>{if(m.inBacktick){for(;!d.eol();){const b=d.next();if(b==="\\"){d.next();continue}if(b==="`")return m.inBacktick=!1,"string"}return"string"}if(m.inBlockComment){for(;!d.eol();){if(d.match(t.comments.blockEnd,!0))return m.inBlockComment=!1,"comment";d.next()}return"comment"}if(d.eatWhile(/[ \t]/))return null;if(d.match(t.comments.line,!0))return d.skipToEnd(),"comment";if(d.match(t.comments.blockStart,!0)){for(m.inBlockComment=!0;!d.eol();){if(d.match(t.comments.blockEnd,!0))return m.inBlockComment=!1,"comment";d.next()}return"comment"}const g=d.peek();if(g==null)return null;if(t.strings.singleLineQuotes.includes(g)){const b=g;return d.next(),u(d,b),"string"}if(g===t.strings.multiLineQuote){for(d.next();!d.eol();){const b=d.next();if(b==="\\"){d.next();continue}if(b==="`")return"string"}return m.inBacktick=!0,"string"}if(g>="0"&&g<="9"&&d.match(s,!0)||g==="-"&&d.match(/^-\d+(?:\.\d+)?/,!1)&&d.match(s,!0))return"number";if(g===t.sigils.state)return d.next(),d.peek()===t.sigils.state&&d.next(),d.eatWhile(t.identifier.part),"state";if(t.identifier.start.test(g)){if(d.match(i,!0))return"component";const h=d.match(o,!0);if(h){const v=h[0];return a.has(v)?"atom":n.has(v)?"keyword":d.peek()==="."?"loopvar":"identifier"}}for(const b of t.operatorsLong)if(d.match(b,!0))return"operator";return g==="."?(d.next(),d.peek()&&t.identifier.start.test(d.peek())?(d.eatWhile(t.identifier.part),"property"):"punctuation"):"()[]{},:?".includes(g)?(d.next(),"punctuation"):c.has(g)?(d.next(),"operator"):(d.next(),null)},languageData:{commentTokens:{line:t.comments.line,block:{open:t.comments.blockStart,close:t.comments.blockEnd}},closeBrackets:{brackets:["(","[","{",'"',"'","`"]},indentOnInput:/^\s*[)\]}]$/}}}const Za={comment:"comment",string:"string",number:"number",atom:"atom",keyword:"keyword",state:"variableName.special",component:"typeName",identifier:"variableName",loopvar:"variableName.local",property:"propertyName",operator:"operator",punctuation:null},It=[{name:"state",sigil:"$state",category:"hook",signature:"$state(initial)",summary:"Hook: per-instance state → [value, setValue] (like React's useState)."},{name:"memo",sigil:"$memo",category:"hook",signature:"$memo(() => value, [deps])",summary:"Hook: value recomputed only when a dependency changes (like useMemo)."},{name:"ref",sigil:"$ref",category:"hook",signature:"$ref(initial)",summary:"Hook: stable { current } box; writing .current does not re-render (like useRef)."},{name:"reducer",sigil:"$reducer",category:"hook",signature:"$reducer((state, action) => next, initial)",summary:"Hook: [state, dispatch] (like useReducer)."},{name:"id",sigil:"$id",category:"hook",signature:"$id(prefix?)",summary:"Hook: stable unique id per component instance (like useId)."},{name:"effect",sigil:"$effect",category:"effect",signature:"$effect(() => { … }, [deps])",summary:'Declarative side effect; deps mix $state, "mount"/"unmount", "every(N)", "debounce(N)".'},{name:"optimistic",sigil:"$optimistic",category:"effect",signature:"$optimistic(() => { … })",summary:"Run optimistic writes; auto-rolls back state if the callback throws or rejects."},{name:"store",sigil:"$store",category:"effect",signature:"$store({ ...state, ...methods })",summary:"Global store: shared state + actions (like Zustand/Pinia)."},{name:"http",sigil:"$http",category:"data",signature:"$http({ url, method, … })",summary:"Reactive HTTP resource bag — { data, loading, error, refetch }."},{name:"query",sigil:"$query",category:"data",signature:"$query({ url, key, ttl })",summary:"Cached + deduplicated HTTP read."},{name:"mutation",sigil:"$mutation",category:"data",signature:"$mutation({ url, method })",summary:"Deferred write; fires on .mutate(overrides?)."},{name:"app",sigil:"$app",category:"app",signature:"$app(root)",summary:"Register the root of the rendered UI tree — every program needs one."},{name:"router",sigil:"$router",category:"routing",signature:"$router({ '/': Home(), default: NotFound() })",summary:"Outlet-first router: maps path patterns to component trees."},{name:"theme",sigil:"$theme",category:"theme",signature:"$theme({ colors, radius, font, … })",summary:"In-script theme override merged on top of the active base theme."},{name:"emit",sigil:"$emit",category:"event",signature:"$emit('name', detail)",summary:"Dispatch a CustomEvent from the host element."},{name:"util",sigil:"$util",category:"namespace",signature:"$util",summary:"Runtime helper namespace ($util.format, $util.sum, $util.range, …).",namespace:!0},{name:"storage",sigil:"$storage",category:"namespace",signature:"$storage",summary:"Persistent storage namespace ($storage.local, $storage.session, …).",namespace:!0},{name:"console",sigil:"$console",category:"namespace",signature:"$console",summary:"Console namespace ($console.log, $console.warn, …).",namespace:!0},{name:"toast",sigil:"$toast",category:"namespace",signature:"$toast",summary:"Imperative toasts: $toast.show/.success/.error/.dismiss; reactive .items.",namespace:!0},{name:"i18n",sigil:"$i18n",category:"data",signature:"$i18n({ translations, … })",summary:"Translation bundle → { t, setCurrentLanguage, getCurrentLanguage }."}],Qa=new Set(It.map(t=>t.name)),en=Object.freeze(Object.fromEntries(It.map(t=>[t.name,t])));function xs(t){return en[t]}function ws(t){return Qa.has(t)}const ks="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",tn="6.7.2",rn="data-rui-font-awesome",Ss=new Set(["solid","regular","brands"]),an="solid";function $s(t){typeof document<"u"&&nn(document.head,document),nn(t,t.ownerDocument??document)}function nn(t,e){if(Cs()||t.querySelector(`link[${rn}="${tn}"]`))return;const a=e.createElement("link");a.rel="stylesheet",a.href=ks,a.setAttribute(rn,tn);try{t.appendChild(a)}catch{}}function Cs(){return typeof globalThis.happyDOM<"u"}function Et(t){if(typeof t!="string")return[];const e=Ts(t).trim();if(!e)return[];if(!Ns(e))return[];const[r,a]=Ms(e);return a?[`fa-${r}`,`fa-${a}`]:[]}const As=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function Ts(t){return t.replace(As,"")}function Ms(t){const e=t.indexOf(":");if(e===-1)return[an,t];const r=t.slice(0,e).trim().toLowerCase(),a=t.slice(e+1).trim();return Ss.has(r)?[r,a]:[an,a||t]}function Ns(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const Ps=["xs","sm","md","lg","xl"];function l(t,e,r){const a=document.createElement(t);if(e)for(const[n,i]of Object.entries(e))i==null||i===!1||(n==="class"?a.setAttribute("class",String(i)):n==="html"?a.innerHTML=String(i):i===!0?a.setAttribute(n,""):a.setAttribute(n,String(i)));if(r)for(const n of r)n!=null&&a.append(typeof n=="string"?document.createTextNode(n):n);return a}function $(t){return Array.isArray(t)?t:t==null?[]:[t]}function f(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function A(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function E(t,e=0){if(typeof t=="number")return t;if(typeof t=="string"&&t.trim()!==""){const r=Number(t);if(!Number.isNaN(r))return r}return e}const et=["base","sm","md","lg","xl"];function be(t){if(t==null||typeof t!="object"||Array.isArray(t))return{kind:"single",value:t??null};const e=Object.entries(t),r={};let a=!1;for(const[n,i]of e)et.includes(n)&&(r[n]=i,a=!0);return a?{kind:"responsive",values:r}:{kind:"single",value:t}}const Is=/["'\\\n\r<>;{}]/g;function Es(t){return t?t.replace(Is,"").trim():""}const Ls=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function re(t,e){const r=(f(t)??"").trim();return!r||r.length>64||!Ls.test(r)?e:r}const Rs=/^[a-zA-Z0-9#%.,()\s+\-]+$/;function zs(t){const e=f(t).trim();return!e||e.length>64||!Rs.test(e)||/\burl\s*\(|\bexpression\s*\(|javascript\s*:|@import\b/i.test(e)?"":e}const Ds=new Set(["http","https","mailto","tel"]);function tt(t,e="#"){const r=f(t).trim();if(!r)return e;const a=r.replace(/[\u0000-\u001F\u007F]/g,"");if(!a||a.startsWith("//"))return e;if(a.startsWith("#")||a.startsWith("/")||a.startsWith("?")||a.startsWith("."))return a;const n=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(a);if(!n)return a;const i=n[1].toLowerCase();return Ds.has(i)?a:e}const js=new Set(["http","https","data","blob"]);function ie(t){const e=f(t).trim();if(!e)return"";const r=e.replace(/[\u0000-\u001F\u007F]/g,"");if(!r||r.startsWith("//"))return"";if(r.startsWith("/")||r.startsWith(".")||r.startsWith("?")||r.startsWith("#"))return r;const a=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(r);if(!a)return r;const n=a[1].toLowerCase();return!js.has(n)||n==="data"&&!/^data:image\//i.test(r)?"":r}function Bs(t){if(t===null||typeof t!="object")return!1;const e=t.__kind;return e==="Component"||e==="UserComponent"}function hr(t,e,r,a,n,i){const o=e.format??"text";let s=r;if(typeof e.render=="function")try{s=e.render(r,a)}catch(u){console.error("[aktion] Col render() threw",u),s=null}const c=u=>{Bs(u)?t.append(n.renderNode(u)):u!=null&&t.append(document.createTextNode(i(u,o)))};if(Array.isArray(s))for(const u of s)c(u);else c(s);if(typeof e.onClick=="function"){t.setAttribute("data-clickable","true"),t.setAttribute("role","button"),t.tabIndex=0;const u=p=>p.target?.closest("input,button,a,label,select,textarea")?!1:(p.stopPropagation(),n.invoke(e.onClick,r,a),!0);t.onclick=p=>{u(p)},t.onkeydown=p=>{p.key!=="Enter"&&p.key!==" "||u(p)&&p.preventDefault()}}}function j(t,e={}){const r=f(t);if(!r)return null;const a=e.color?zs(e.color):"",n=a?`color:${a};`:null,i=Et(r),o=["rui-icon",e.className].filter(Boolean).join(" ");return i.length===0?l("span",{class:o,"data-icon-size":e.size??null,style:n},[r]):l("i",{class:`${o} ${i.join(" ")}`,"data-icon-size":e.size??null,style:n,"aria-hidden":"true"})}const ct=12,Os={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},_s={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function Fs(t){return Os[t]??"stretch"}function Us(t){return _s[t]??"flex-start"}function on(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function Ue(t,e,r){for(const a of et){const n=e.values[a];n&&t.push(`${r}-${a}:var(--rui-spacing-${n}, ${n})`)}}function Hs(t,e,r,a){for(const n of et){const i=e.values[n];i&&t.push(`${r}-${n}:${a(String(i))}`)}}function sn(t,e,r,a){const n=be(t);if(n.kind==="single"){const i=n.value?String(n.value):a.defaultToken;r[a.attrName]=i;return}r[a.attrName]="responsive",r[a.responsiveFlag]="true",Hs(e,n,a.cssVarPrefix,a.mapper)}function Vs(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function Ws(t){const e=be(t.direction);return e.kind==="single"?e.value?String(e.value):"column":e.values.base?String(e.values.base):"column"}const qs={name:"StackItem",description:"Per-child flex control inside a `Row`, `Column`, or `Stack`. Wraps one child so it can `grow` to fill leftover space, `shrink`, set a `basis`, override `alignSelf`, or change visual `order` — the building block for asymmetric rows like `Row([StackItem(searchInput, { grow: 1 }), saveButton])` (input expands, button hugs).",props:[{name:"child",type:"Node",description:"Child node to wrap"},{name:"grow",type:"number",optional:!0,description:"flex-grow (0 or 1 typical)"},{name:"shrink",type:"number",optional:!0,description:"flex-shrink (0 or 1 typical)"},{name:"basis",type:"string",optional:!0,description:"flex-basis (`auto`, `0`, or CSS length)"},{name:"alignSelf",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Per-item cross-axis alignment"},{name:"order",type:"number",optional:!0,description:"Visual order override"},{name:"minWidth",type:"string",optional:!0,description:"CSS min-width"},{name:"maxWidth",type:"string",optional:!0,description:"CSS max-width"}],render:(t,e,r)=>{const a={class:"rui-stack-item"},n=[];e.grow!==void 0&&e.grow!==null&&(a["data-grow"]=String(E(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(a["data-shrink"]=String(E(e.shrink,1)));const i=f(e.basis);i==="auto"||i==="0"?a["data-basis"]=i:i&&n.push(`flex-basis:${re(i,i)}`);const o=f(e.alignSelf);if(o&&(a["data-align-self"]=o),e.order!==void 0&&e.order!==null){const p=E(e.order,0);a["data-order"]=String(p),n.push(`order:${p}`)}const s=f(e.minWidth);s&&n.push(`min-width:${re(s,s)}`);const c=f(e.maxWidth);c&&n.push(`max-width:${re(c,c)}`),n.length>0&&(a.style=n.join(";"));const u=l("div",a);return u.append(r.renderNode(e.child)),u}};function br(t,e,r,a,n){const i=be(t),o=be(a.gap),s=be(a.padding),c=A(a.reverse),u={class:"rui-stack","data-wrap":A(a.wrap)?"true":null,"data-reverse":c?"true":null,"data-uniform":e?"true":"false","data-inline":A(a.inline)?"true":null},p=[];if(i.kind==="single"){const g=i.value?String(i.value):"column";u["data-direction"]=on(g,c)}else{u["data-direction"]="responsive",u["data-responsive-dir"]="true";for(const g of et){const b=i.values[g];b&&p.push(`--rui-stack-dir-${g}:${on(String(b),c)}`)}}o.kind==="single"?u["data-gap"]=o.value?String(o.value):"m":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",Ue(p,o,"--rui-stack-gap")),sn(a.align,p,u,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:r,mapper:Fs}),sn(a.justify,p,u,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:Us});const d=f(a.alignContent);if(d&&(u["data-align-content"]=d),s.kind==="single"){const g=s.value?String(s.value):null;g&&(u["data-padding"]=g)}else u["data-padding"]="responsive",u["data-responsive-padding"]="true",Ue(p,s,"--rui-stack-padding");p.length>0&&(u.style=p.join(";"));const m=l("div",u);for(const g of $(a.children))m.append(n.renderNode(g));return m}const Ks={name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between children. May be a responsive map."},vr={name:"justify",type:"string | object",optional:!0,enum:["start","center","end","between","around","evenly"],description:"Main-axis distribution. May be a responsive map."},yr={name:"wrap",type:"boolean",optional:!0,description:"Wrap children onto multiple lines when they overflow"},xr={name:"reverse",type:"boolean",optional:!0,description:"Reverse the visual order of children"},wr={name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token. May be a responsive map."},kr={name:"inline",type:"boolean",optional:!0,description:"Use inline-flex (shrink-to-fit) instead of a full-width block"},ln={name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Alignment of wrapped lines (only when `wrap` is on)"},Gs={name:"Row",description:"Lay children out horizontally (left → right) with even spacing. The developer-friendly default: children keep their natural width and are vertically centered. Set `grow=true` to make children share the row equally (for equal-width columns prefer `Grid(columns: N)`); drop a `Spacer()` between children to push them apart; wrap a child in `StackItem` for per-child grow/shrink/alignment. Use `wrap=true` for chips/tags that should flow onto multiple lines.",props:[{name:"children",type:"Node[]",description:"Children laid out left → right"},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Horizontal spacing between children (default `m`). May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Vertical alignment of children (default `center`). May be a responsive map."},{...vr},{name:"grow",type:"boolean",optional:!0,description:"Children share the row width equally (replaces the old `uniform`)"},{...yr},{...xr},{...wr},{...kr},{...ln}],render:(t,e,r)=>br("row",A(e.grow),"center",e,r)},Ys={name:"Column",description:"Lay children out vertically (top → bottom) with even spacing — the most common page/section layout. Children stretch to the full width by default; set `align` to `start`/`center`/`end` to change that. This is the recommended root container for a page or a card body.",props:[{name:"children",type:"Node[]",description:"Children laid out top → bottom"},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Vertical spacing between children (default `m`). May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Horizontal alignment of children (default `stretch`). May be a responsive map."},{...vr},{...yr},{...xr},{...wr},{...kr}],render:(t,e,r)=>br("column",!1,"stretch",e,r)},Xs={name:"Stack",description:'Low-level flex container with a configurable, optionally responsive `direction`. Reach for `Row` or `Column` first — they are clearer for fixed-direction layouts. Use `Stack` when the direction itself must change across breakpoints, e.g. `direction: {base: "column", md: "row"}` for a sidebar that stacks on mobile. `gap`, `align`, `justify`, and `padding` also accept responsive maps. NOTE: a `row` Stack grows its children equally by default (`uniform=true`); set `uniform=false` for natural widths (this is `Row`\'s default).',props:[{name:"children",type:"Node[]",description:"Child components to stack"},{name:"direction",type:"string | object",optional:!0,enum:["column","row"],description:'Layout direction (default column). May be a responsive map like `{base: "column", md: "row"}`.'},{...Ks},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment (default stretch). May be a responsive map."},{...vr},{...ln},{...yr},{...xr},{name:"uniform",type:"boolean",optional:!0,description:"Row children share space equally (default true for row stacks; use `Row` for natural widths)"},{...kr},{...wr}],render:(t,e,r)=>{const n=Ws(e)==="row",i=e.uniform===void 0?n:A(e.uniform,n);return br(e.direction,i,"stretch",e,r)}},Js={name:"Center",description:'Centers its children on both axes — the easy way to drop a spinner, an empty state, a hero call-to-action, or a modal body into the middle of a region. Give it `minHeight` (e.g. `"60vh"`) to center vertically inside a tall area, or `axis` to center on only one axis. Multiple children stack in a column and are centered as a group.',props:[{name:"children",type:"Node[]",description:"Content to center"},{name:"axis",type:"string",optional:!0,enum:["both","horizontal","vertical"],description:"Which axis to center on (default both)"},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height — set to center vertically inside a tall region (e.g. `60vh`, `400px`)"},{name:"gap",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between stacked children (default `m`)"},{name:"padding",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token"},{name:"inline",type:"boolean",optional:!0,description:"Shrink to fit content instead of filling the available width"}],render:(t,e,r)=>{const a={class:"rui-center","data-axis":f(e.axis,"both"),"data-gap":f(e.gap,"m"),"data-inline":A(e.inline)?"true":null},n=f(e.padding);n&&(a["data-padding"]=n);const i=[],o=f(e.minHeight);o&&i.push(`min-height:${re(o,o)}`),i.length>0&&(a.style=i.join(";"));const s=l("div",a);for(const c of $(e.children))s.append(r.renderNode(c));return s}},Zs={name:"Card",description:"Vertical card container.",props:[{name:"children",type:"Node[]",description:"Card contents"},{name:"variant",type:"string",optional:!0,enum:["default","outlined","elevated"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-card","data-variant":f(e.variant,"default")});for(const n of $(e.children))a.append(r.renderNode(n));return a}},Qs={name:"CardHeader",description:"Card header with title and optional subtitle.",props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0}],render:(t,e)=>{const r=l("header",{class:"rui-card-header"});r.append(l("h3",{class:"rui-card-title"},[f(e.title)]));const a=f(e.subtitle);return a&&r.append(l("p",{class:"rui-card-subtitle"},[a])),r}},el={name:"CardFooter",description:"Card footer for actions.",props:[{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=l("footer",{class:"rui-card-footer"});for(const n of $(e.children))a.append(r.renderNode(n));return a}},tl={name:"Separator",description:"Visual divider between content sections. Supports horizontal or vertical orientation, and an optional center `label` (lifted from the legacy `Divider`). Use `decorative=false` to expose the separator to assistive tech.",props:[{name:"orientation",type:"string",optional:!0,enum:["horizontal","vertical"]},{name:"label",type:"string",optional:!0,description:"Optional label rendered in the middle (horizontal only)"},{name:"decorative",type:"boolean",optional:!0,description:"Hides the separator from assistive tech when true (default)"}],render:(t,e)=>{const r=f(e.orientation,"horizontal"),a=A(e.decorative,!0),n=f(e.label);return n&&r==="horizontal"?l("div",{class:"rui-separator rui-separator-with-label","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r},[l("span",{class:"rui-separator-line"}),l("span",{class:"rui-separator-label"},[n]),l("span",{class:"rui-separator-line"})]):l("div",{class:"rui-separator","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r})}},cn=(t,e,r=!1)=>{const a=l("li",{class:"rui-steps-item","data-active":r?"true":"false"});return a.append(l("div",{class:"rui-steps-title"},[t])),e&&a.append(l("div",{class:"rui-steps-details"},[e])),a},rl={name:"Steps",description:"Numbered step-by-step guide. Pass items as `{title, details?, active?}` objects. Use `active` to mark the current step in a multi-step flow.",props:[{name:"items",type:"object[]"}],render:(t,e,r)=>{const a=l("ol",{class:"rui-steps"});for(const n of $(e.items)){if(n&&typeof n=="object"&&n.__kind==="Component"){a.append(r.renderNode(n));continue}if(n&&typeof n=="object"){const i=n;a.append(cn(f(i.title),f(i.details),A(i.active)));continue}a.append(cn(f(n),""))}return a}},al={name:"TabItem",description:"Single tab definition (used inside Tabs). Add `badge` for a count chip in the tab trigger, and `icon` for a leading Font Awesome icon.",props:[{name:"value",type:"string",description:"Stable identifier for the tab"},{name:"label",type:"string",description:"Display label"},{name:"children",type:"Node[]",description:"Tab content"},{name:"badge",type:"string",optional:!0,description:"Trailing chip rendered in the tab trigger (count / status)"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown before the label"}],render:(t,e,r)=>{const a=l("div",{class:"rui-tab-content",role:"tabpanel","data-value":f(e.value),"data-active":"false"});for(const n of $(e.children))a.append(r.renderNode(n));return a}},nl={name:"Tabs",description:'Tabbed container. Children must be TabItem components. Supports `orientation="vertical"` for sidebar-style tabs and built-in keyboard navigation (←/→ or ↑/↓, Home, End). Provide `onChange` to react when the user switches tabs (called with the new tab\'s value).',props:[{name:"items",type:"TabItem[]",description:"Tab definitions"},{name:"defaultValue",type:"string",optional:!0,description:"Initially active tab value"},{name:"orientation",type:"string",optional:!0,enum:["horizontal","vertical"],description:"Layout direction (default `horizontal`)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-activated tab value when the user switches tabs"}],render:(t,e,r)=>{const a=$(e.items),n=f(e.orientation,"horizontal"),i=l("div",{class:"rui-tabs","data-orientation":n}),o=l("div",{class:"rui-tab-list",role:"tablist","aria-orientation":n}),s=l("div",{class:"rui-tab-panels"});let c=f(e.defaultValue);if(!c&&a.length>0){const m=a[0];c=f(m?.args?.[0],"tab-0")}const u=r.useInstanceState("activeTab",c);f(e.defaultValue)&&f(e.defaultValue)!==c&&u.set(f(e.defaultValue)),new Set(a.map((m,g)=>f(m.args?.[0],`tab-${g}`))).has(u.get())||u.set(c);const d=(m,g)=>{const b=u.get();u.set(m);const h=g.closest(".rui-tabs");h&&(h.querySelectorAll(".rui-tab-trigger").forEach(v=>{const y=v.getAttribute("data-value")===m;v.setAttribute("aria-selected",y?"true":"false"),v.tabIndex=y?0:-1}),h.querySelectorAll(".rui-tab-content").forEach(v=>{v.setAttribute("data-active",v.getAttribute("data-value")===m?"true":"false")})),b!==m&&r.invoke(e.onChange,m)};return a.forEach((m,g)=>{const b=m,h=f(b.args?.[0],`tab-${g}`),v=f(b.args?.[1],`Tab ${g+1}`),y=f(b.args?.[3]),x=f(b.args?.[4]),w=h===u.get(),k=l("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":h,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),T=x?il(x):null;T&&k.append(T),k.append(l("span",{class:"rui-tab-trigger-label"},[v])),y&&k.append(l("span",{class:"rui-tab-trigger-badge"},[y])),k.onclick=C=>{const N=C.currentTarget??C.target;d(h,N)},k.onkeydown=C=>{const N=C,I=n!=="vertical",L=I?N.key==="ArrowRight":N.key==="ArrowDown",D=I?N.key==="ArrowLeft":N.key==="ArrowUp";if(!L&&!D&&N.key!=="Home"&&N.key!=="End")return;N.preventDefault();const q=N.currentTarget??N.target,O=q.closest(".rui-tab-list");if(!O)return;const U=Array.from(O.querySelectorAll(".rui-tab-trigger"));if(U.length===0)return;const J=U.indexOf(q);let Z=J;N.key==="Home"?Z=0:N.key==="End"?Z=U.length-1:L?Z=(J+1)%U.length:D&&(Z=(J-1+U.length)%U.length);const me=U[Z];if(!me)return;me.focus();const $e=me.getAttribute("data-value")??"";$e&&d($e,me)},o.append(k);const S=r.renderNode(m);S.setAttribute("data-value",h),S.setAttribute("data-active",w?"true":"false"),s.append(S)}),i.append(o,s),i}};function il(t){return j(t,{className:"rui-tab-trigger-icon"})}const ol={name:"AccordionItem",description:"Single accordion section.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"open",type:"boolean",optional:!0},{name:"showArrow",type:"boolean",optional:!0,description:"Show a chevron icon on the right (default false). Inherits from parent Accordion when unset."}],render:(t,e,r)=>{const a=e.showArrow!==void 0&&e.showArrow!==null,n=l("details",{class:"rui-accordion-item","data-show-arrow":a?A(e.showArrow)?"true":"false":null});A(e.open)&&n.setAttribute("open","");const i=l("summary",{class:"rui-accordion-trigger"});i.append(l("span",{class:"rui-accordion-title"},[f(e.title)])),i.append(l("span",{class:"rui-accordion-chevron","aria-hidden":"true"})),n.append(i);const o=l("div",{class:"rui-accordion-body"});for(const s of $(e.children))o.append(r.renderNode(s));return n.append(o),n}},sl={name:"Accordion",description:"Accordion container. Children must be AccordionItem components. Set `showArrow: true` to add a chevron indicator to every item; individual `AccordionItem`s can override via their own `showArrow` prop.",props:[{name:"items",type:"AccordionItem[]"},{name:"showArrow",type:"boolean",optional:!0,description:"Show chevron icon on every item (default false)."}],render:(t,e,r)=>{const a=l("div",{class:"rui-accordion","data-show-arrow":A(e.showArrow)?"true":"false"});for(const n of $(e.items))a.append(r.renderNode(n));return a}},Lt=t=>Math.max(1,Math.min(ct,Math.round(t)));function Sr(t){if(t==null||t==="")return 12;const e=String(t).trim();if(e.includes("/")){const[r,a]=e.split("/"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return Lt(Math.round(ct*n/i))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:Lt(E(t,12))}function ll(t){const e=f(t.minChildWidth)||f(t.minItemWidth);return re(e||"220px","220px")}const cl={name:"GridItem",description:'Wraps a child in a 12-column grid cell with `span`, `offset`, and responsive `spanAt` maps. Parent `Grid` auto-enables 12-column mode when any child is a `GridItem`. Fraction spans like `"1/3"` resolve against the 12-column track.',props:[{name:"child",type:"Node",description:"Child node to place in the grid"},{name:"span",type:"number | string",optional:!0,description:'Columns to span (1–12) or fraction like "1/2", "1/3"'},{name:"offset",type:"number",optional:!0,description:"Empty columns before this item (0–11)"},{name:"spanAt",type:"object",optional:!0,description:"Responsive span map `{sm: 12, md: 6, lg: 4}`"}],render:(t,e,r)=>{const a=Sr(e.span??12),n=be(e.spanAt),i=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(ct-1,Math.round(E(e.offset,0)))),o={class:"rui-grid-item","data-span":String(a)},s=[`--rui-grid-item-span:${a}`];if(i>0&&(o["data-offset"]=String(i),s.push(`--rui-grid-item-offset:${i}`)),n.kind==="responsive"){o["data-responsive-span"]="true";for(const u of et){const p=n.values[u];if(p!==void 0){const d=Sr(p);s.push(`--rui-grid-item-span-${u}:${d}`)}}}else if(n.kind==="single"&&n.value!=null){const u=Sr(n.value);s.push(`--rui-grid-item-span:${u}`),o["data-span"]=String(u)}o.style=s.join(";");const c=l("div",o);return c.append(r.renderNode(e.child)),c}},ul={name:"Box",description:"Spacing and surface wrapper for padding, margin, borders, semantic backgrounds, and max-width constraints. Use when a `Card` is too heavy but the content needs a subtle surface or inset.",props:[{name:"children",type:"Node[]"},{name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding. May be a responsive map."},{name:"margin",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Outer margin. May be a responsive map."},{name:"border",type:"string",optional:!0,enum:["none","subtle","default"],description:"Border preset (default none)"},{name:"background",type:"string",optional:!0,enum:["none","surface","muted","primary","success","warning","danger","info"],description:"Semantic background token"},{name:"maxWidth",type:"string",optional:!0,description:"CSS max-width"}],render:(t,e,r)=>{const a=be(e.padding),n=be(e.margin),i={class:"rui-box","data-border":f(e.border,"none"),"data-background":f(e.background,"none")},o=[],s=f(e.maxWidth);if(s&&o.push(`max-width:${re(s,s)}`),a.kind==="single"){const u=a.value?String(a.value):null;u&&(i["data-padding"]=u)}else i["data-padding"]="responsive",i["data-responsive-padding"]="true",Ue(o,a,"--rui-box-padding");if(n.kind==="single"){const u=n.value?String(n.value):null;u&&(i["data-margin"]=u)}else i["data-margin"]="responsive",i["data-responsive-margin"]="true",Ue(o,n,"--rui-box-margin");o.length>0&&(i.style=o.join(";"));const c=l("div",i);for(const u of $(e.children))c.append(r.renderNode(u));return c}},un={name:"Grid",description:'Two-dimensional grid with three modes:\n 1. AUTO-FIT (default, no `columns`): wraps as many equal columns as fit, each at least `minChildWidth` wide (default 220px) — perfect for card/KPI grids that should reflow on their own.\n 2. FIXED (`columns: N`, 1–12): exactly N equal columns.\n 3. SPAN (`columns: 12` or any `GridItem` children): a 12-track grid where each `GridItem` sets its own `span` (a number 1–12 or a fraction like `"1/3"`) for dashboards and asymmetric layouts.\n`columns` and `gap` accept responsive maps like `{base: 1, md: 2, lg: 4}`.',props:[{name:"children",type:"Node[]"},{name:"columns",type:"number | object",optional:!0,description:"Fixed column count 1–12. Omit for auto-fit; `12` (or `GridItem` children) enables the 12-track span system. May be a responsive map like `{base: 1, md: 3}`."},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Gap on both axes (default `m`). May be a responsive map."},{name:"rowGap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Row gap override. May be a responsive map."},{name:"columnGap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Column gap override. May be a responsive map."},{name:"minChildWidth",type:"string",optional:!0,aliases:["minItemWidth"],description:'Minimum column width for AUTO-FIT mode, e.g. `"240px"` (default 220px). Also caps the floor in FIXED mode.'},{name:"alignItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Vertical alignment of items within their cells"},{name:"justifyItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Horizontal alignment of items within their cells"},{name:"dense",type:"boolean",optional:!0,description:"Dense auto-flow packing — let later items backfill earlier gaps"}],render:(t,e,r)=>{const a=$(e.children),n=a.some(v=>Vs(v,"GridItem")),i=be(e.columns),o=be(e.gap),s=be(e.rowGap),c=be(e.columnGap),u={class:"rui-grid"},p=[];let d=!1,m=!1;if(i.kind==="single"){const v=i.value===null?0:E(i.value,0),y=v>0?Lt(v):0;if(y===ct?d=!0:y>0&&(m=!0),y>0){u["data-columns"]=String(y);const x=f(e.minChildWidth)||f(e.minItemWidth);x&&(u["data-min-child-width"]="true",p.push(`--rui-grid-min-child:${re(x,"220px")}`))}else p.push(`--rui-grid-min-item:${ll(e)}`)}else{u["data-responsive-cols"]="true";for(const v of et){const y=i.values[v];if(y===void 0)continue;const x=Lt(E(y,0));x===ct?d=!0:x>0&&(m=!0),p.push(`--rui-grid-cols-${v}:${x}`)}}n&&!m&&(d=!0),d&&(u["data-grid-mode"]="12"),o.kind==="single"?u["data-gap"]=o.value?String(o.value):"m":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",Ue(p,o,"--rui-grid-gap")),s.kind==="single"&&s.value?u["data-row-gap"]=String(s.value):s.kind==="responsive"&&(u["data-row-gap"]="responsive",u["data-responsive-row-gap"]="true",Ue(p,s,"--rui-grid-row-gap")),c.kind==="single"&&c.value?u["data-column-gap"]=String(c.value):c.kind==="responsive"&&(u["data-column-gap"]="responsive",u["data-responsive-column-gap"]="true",Ue(p,c,"--rui-grid-column-gap"));const g=f(e.alignItems);g&&(u["data-align-items"]=g);const b=f(e.justifyItems);b&&(u["data-justify-items"]=b),A(e.dense)&&(u["data-dense"]="true"),p.length>0&&(u.style=p.join(";"));const h=l("div",u);for(const v of a)h.append(r.renderNode(v));return h}},dl={name:"AspectRatio",description:"Container that constrains its child to a fixed aspect ratio (e.g. 16:9 for video embeds, 1:1 for thumbnails). The child fills the box.",props:[{name:"ratio",type:"string",description:"`width:height` (e.g. `16:9`, `4:3`) or a decimal like `1.78`"},{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=pl(f(e.ratio,"16:9")),n=l("div",{class:"rui-aspect-ratio",style:`aspect-ratio:${a};`});for(const i of $(e.children))n.append(r.renderNode(i));return n}};function pl(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i!==0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const ml={name:"ScrollArea",description:"Bounded scroll container. Use to clip long lists / logs / chat panels to a fixed max height with a clean scrollbar.",props:[{name:"children",type:"Node[]"},{name:"maxHeight",type:"string",optional:!0,aliases:["height"],description:"CSS height (default 320px)"},{name:"direction",type:"string",optional:!0,enum:["vertical","horizontal","both"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-scroll-area","data-direction":f(e.direction,"vertical"),style:`max-height:${re(e.maxHeight,"320px")};`});for(const n of $(e.children))a.append(r.renderNode(n));return a}},fl=["sm","md","lg","xl","full"],dn='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';let gl=0;function pn(t){return t.getRootNode().activeElement??null}const hl={name:"Modal",description:"Dialog overlay shown when `open` is true. Pass a `$variable` as `open` to control it. The header always renders a × close button (disable via `closable: false`); the optional `footer` slot is the canonical place for action buttons. `closeOnBackdrop=true` opts in to backdrop-click dismissal. `onClose` fires every time the modal closes (× button, backdrop, programmatic state write). Accessible by default: the dialog is labelled by its title, focus moves into it on open and is restored on close, Tab is trapped inside, and Escape closes it (unless `closable: false`).",props:[{name:"title",type:"string"},{name:"open",type:"boolean",description:"Open/closed state — usually a $variable"},{name:"children",type:"Node[]"},{name:"size",type:"string",optional:!0,enum:fl,description:"Width preset (default `md`)"},{name:"footer",type:"Node[]",optional:!0,description:"Footer slot — typically a row of action Buttons"},{name:"closable",type:"boolean",optional:!0,description:"Render the header × button (default true)"},{name:"closeOnBackdrop",type:"boolean",optional:!0,description:"Close when the overlay is clicked (default false)"},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"],description:"Callable invoked when the modal is closed (× button or backdrop)"}],render:(t,e,r)=>{const a=f(e.size,"md"),n=e.closable===void 0?!0:A(e.closable),i=l("div",{class:"rui-modal-overlay","data-open":A(e.open)?"true":"false"}),o=r.useInstanceState("rui-modal-title-id","");o.get()||o.set(`rui-modal-title-${gl+=1}`);const s=o.get(),c=l("div",{class:"rui-modal",role:"dialog","aria-modal":"true","aria-labelledby":s,tabindex:"-1","data-size":a}),u=l("header",{class:"rui-modal-header"});u.append(l("h3",{class:"rui-modal-title",id:s},[f(e.title)]));const p=t.argMeta?.[1]?.stateRef,d=()=>{p&&r.setState(p,!1),r.invoke(e.onClose)};if(n){const y=l("button",{type:"button",class:"rui-modal-close","aria-label":"Close dialog"},["×"]);y.onclick=x=>{x.stopPropagation(),d()},u.append(y)}c.append(u);const m=l("div",{class:"rui-modal-body"});for(const y of $(e.children))m.append(r.renderNode(y));c.append(m);const g=$(e.footer);if(g.length>0){const y=l("footer",{class:"rui-modal-footer"});for(const x of g)y.append(r.renderNode(x));c.append(y)}i.append(c),A(e.closeOnBackdrop)&&(i.onclick=y=>{y.target===i&&d()});const b=A(e.open);c.addEventListener("keydown",y=>{if(y.key==="Escape"&&n){y.stopPropagation(),d();return}if(y.key!=="Tab")return;const x=[...c.querySelectorAll(dn)];if(x.length===0){y.preventDefault(),c.focus();return}const w=x[0],k=x[x.length-1],T=pn(c);y.shiftKey&&T===w?(y.preventDefault(),k.focus()):!y.shiftKey&&T===k&&(y.preventDefault(),w.focus())});const h=r.useInstanceState("rui-modal-focus",{open:!1,prev:null}),v=h.get();if(b&&!v.open){const y=pn(c);h.set({open:!0,prev:y});const x=()=>{([...c.querySelectorAll(dn)][0]??c).focus()};typeof queueMicrotask=="function"?queueMicrotask(x):Promise.resolve().then(x)}else if(!b&&v.open){const y=v.prev;if(h.set({open:!1,prev:null}),y&&typeof y.focus=="function"){const x=()=>y.focus();typeof queueMicrotask=="function"?queueMicrotask(x):Promise.resolve().then(x)}}return i}},bl=["solid","regular","brands"],Rt=["xs","sm","md","lg","xl"],vl=["default","neutral","primary","success","warning","danger","info"];function $r(t,e="md"){const r=f(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":Rt.includes(r)?r:e:e}const yl={name:"Icon",description:'Single Font Awesome icon. `name` is the FA name without the `fa-` prefix (e.g. `"house"`, `"chart-line"`). Use `variant` for non-solid styles (`regular`/`brands`) or prefix the name (`"regular:star"`). `color` accepts any CSS colour (`"#00ff00"`, `"tomato"`, `"var(--rui-color-primary)"`).',props:[{name:"name",type:"string",description:"FA name without the fa- prefix"},{name:"variant",type:"string",optional:!0,enum:bl},{name:"size",type:"string",optional:!0,enum:Ps},{name:"color",type:"string",optional:!0,description:"CSS colour applied to the glyph (hex, named, rgb()/hsl(), or var(--token))"}],render:(t,e)=>{const r=f(e.name),a=f(e.variant,""),n=f(e.size,"md"),i=f(e.color,""),o=a?`${a}:${r}`:r,s=j(o,{size:n,color:i});return s||l("span",{class:"rui-icon","data-icon-size":n},[r])}},xl=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function wl(t){const e=f(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const mn=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:xl},{name:"tone",type:"string",optional:!0,enum:["default","muted","primary","success","warning","danger"],description:"Visual accent"},{name:"style",type:"string",optional:!0,description:'Inline CSS declarations applied to the rendered element (e.g. "font-size: 16px; font-weight: bold; color: #000;").'}],fn=(t,e)=>{const r=f(e.variant,"body"),a=f(e.tone,"default"),n=wl(e.style);return l("span",{class:"rui-text","data-variant":r,"data-color":a,style:n||null},[f(e.value)])},kl={name:"Text",description:'Renders plain text with a typographic variant. Optional `style` prop accepts a CSS declaration string (e.g. "font-size: 16px; color: #000;") applied directly to the rendered element.',props:mn,render:fn},Sl={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:mn,render:fn},$l={name:"Image",description:"Inline image. `ratio` constrains the box to a fixed aspect ratio (e.g. `16:9`, `1:1`) so callers do not need an outer `AspectRatio`. `fit` controls how the image fills that box. When `src` is missing or unsafe the component renders a placeholder (or `fallback` text/icon).",props:[{name:"src",type:"string"},{name:"alt",type:"string",optional:!0},{name:"caption",type:"string",optional:!0},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio shorthand (e.g. `16:9`, `1:1`, `4:3`)"},{name:"fit",type:"string",optional:!0,enum:["cover","contain","fill","none","scale-down"],description:"object-fit value (default `cover`)"},{name:"fallback",type:"string",optional:!0,description:"Text label or Font Awesome icon shown when src is missing/unsafe"}],render:(t,e)=>{const r=l("figure",{class:"rui-image","data-fit":f(e.fit,"cover"),style:e.ratio?`aspect-ratio:${Cl(f(e.ratio))};`:null}),a=ie(e.src);if(a)r.append(l("img",{src:a,alt:f(e.alt),loading:"lazy"}));else{const i=l("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),o=f(e.fallback);if(o){const s=j(o,{className:"rui-image-fallback-icon"});s?i.append(s):i.append(l("span",{class:"rui-image-fallback-text"},[o]))}r.append(i)}const n=f(e.caption);return n&&r.append(l("figcaption",{class:"rui-image-caption"},[n])),r}};function Cl(t){if(!t)return"auto";if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"auto"}const gn=["neutral","primary","success","warning","danger","info"],Al={name:"Badge",description:"Small pill-style tag for status, counts, categories. Accepts an optional leading `icon` and a `size`.",props:[{name:"label",type:"string",positional:!0},{name:"tone",type:"string",optional:!0,enum:gn,aliases:["variant"],description:"Visual tone"},{name:"icon",type:"string",optional:!0,description:'Optional Font Awesome icon name (e.g. "star")'},{name:"size",type:"string",optional:!0,enum:Rt}],render:(t,e)=>{const r=f(e.tone,"neutral"),a=$r(e.size,"md"),n=l("span",{class:"rui-badge","data-variant":r,"data-size":a}),i=j(e.icon,{className:"rui-badge-icon"});i&&n.append(i);const o=f(e.label);return o&&n.append(l("span",{class:"rui-badge-label"},[o])),n}},Tl={name:"BadgeList",description:"Cluster of Badge pills rendered from an array of strings.",props:[{name:"labels",type:"string[]",positional:!0,description:"Array of badge labels"},{name:"tone",type:"string",optional:!0,enum:gn,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:Rt}],render:(t,e)=>{const r=f(e.tone,"neutral"),a=$r(e.size,"md"),n=l("div",{class:"rui-badge-list"});for(const i of $(e.labels)){const o=f(i);if(!o)continue;const s=l("span",{class:"rui-badge","data-variant":r,"data-size":a});s.append(l("span",{class:"rui-badge-label"},[o])),n.append(s)}return n}},Ml={name:"Callout",description:"Highlighted callout banner with variant, title, description, and leading icon. Pass `compact: true` for a one-line inline-note rendering.",props:[{name:"tone",type:"string",optional:!0,enum:["neutral","info","success","warning","danger","error"],aliases:["variant"]},{name:"title",type:"string",positional:!0,required:!0},{name:"description",type:"string",optional:!0,aliases:["text"],description:"Body text"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"},{name:"compact",type:"boolean",optional:!0,description:"Render with the dense, one-line note shape."}],render:(t,e)=>{const r=f(e.tone,"info"),a=A(e.compact),n=l("div",{class:"rui-callout","data-variant":r,"data-compact":a?"true":"false"}),i=f(e.icon)||Il(r),o=j(i,{className:"rui-callout-icon"});o&&n.append(o);const s=l("div",{class:"rui-callout-body"});s.append(l("div",{class:"rui-callout-title"},[f(e.title)]));const c=f(e.description);return c&&s.append(l("div",{class:"rui-callout-description"},[c])),n.append(s),n}},Nl={name:"CodeBlock",description:'Read-only code block with a language label and a copy-to-clipboard button. Pass `showLineNumbers=true` to render a gutter; `highlightLines` accepts a string like `"3-5,8"` to emphasise specific lines.',props:[{name:"language",type:"string",optional:!0,description:"Display label (e.g. ts, bash)"},{name:"codeString",type:"string",positional:!0,required:!0,aliases:["code"],description:"Raw source text"},{name:"showLineNumbers",type:"boolean",optional:!0,description:"Render a left-side line-number gutter"},{name:"highlightLines",type:"string",optional:!0,aliases:["highlight"],description:'Highlight ranges, e.g. "3-5,8"'},{name:"copy",type:"boolean",optional:!0,description:"Show the copy-to-clipboard button (default true)"}],render:(t,e)=>{const r=f(e.language),a=f(e.codeString),n=A(e.showLineNumbers),i=Pl(f(e.highlightLines)),o=e.copy===void 0?!0:A(e.copy),s=l("div",{class:"rui-code-block"});if(r||o){const u=l("div",{class:"rui-code-block-head"});if(r&&u.append(l("span",{class:"rui-code-block-language"},[r])),o){const p=l("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),d=j("copy",{className:"rui-code-block-copy-icon"});d&&p.append(d),p.append(l("span",{class:"rui-code-block-copy-label"},["Copy"])),p.onclick=m=>{const g=m.currentTarget??m.target,h=g.closest(".rui-code-block")?.querySelector("code")?.textContent??a,y=(typeof navigator<"u"?navigator:null)?.clipboard;y?.writeText&&y.writeText(h).catch(()=>{});const x=g.querySelector(".rui-code-block-copy-label");if(x){const w=x.textContent??"Copy";x.textContent="Copied",setTimeout(()=>{x.textContent=w},1500)}},u.append(p)}s.append(u)}const c=l("pre",{class:"rui-code-block-pre","data-line-numbers":n?"true":"false"});if(n||i.size>0){const u=a.split(/\r?\n/),p=l("code",{});u.forEach((d,m)=>{const g=m+1,b=l("span",{class:"rui-code-block-line","data-line":String(g),"data-highlight":i.has(g)?"true":null});n&&b.append(l("span",{class:"rui-code-block-gutter"},[String(g)])),b.append(l("span",{class:"rui-code-block-code"},[d])),p.append(b)}),c.append(p)}else c.append(l("code",{},[a]));return s.append(c),s}};function Pl(t){const e=new Set;if(!t)return e;for(const r of t.split(",")){const a=r.trim();if(a)if(a.includes("-")){const n=a.split("-").map(s=>Number(s.trim())),i=n[0]??NaN,o=n[1]??NaN;if(Number.isFinite(i)&&Number.isFinite(o)&&i<=o)for(let s=i;s<=o;s+=1)e.add(s)}else{const n=Number(a);Number.isFinite(n)&&e.add(n)}}return e}function Il(t){switch(t){case"success":return"circle-check";case"warning":return"triangle-exclamation";case"danger":case"error":return"circle-xmark";case"info":return"circle-info";default:return"circle-info"}}const El={name:"Skeleton",description:"Loading placeholder. Pass a `variant` for common shapes — `paragraph` (default), `card`, `table-row`, `avatar`, `image` — or use `shape` / `width` / `height` to build a custom one. All variants use a shimmer animation that respects `prefers-reduced-motion`.",props:[{name:"variant",type:"string",optional:!0,enum:["paragraph","card","table-row","avatar","image"]},{name:"lines",type:"number",optional:!0,aliases:["count"],description:"Lines for the `paragraph` variant (default 3)"},{name:"height",type:"number | string",optional:!0,description:"Line height in px (paragraph) or CSS height for custom shape"},{name:"shape",type:"string",optional:!0,enum:["rect","circle"],description:"Force a primitive shape (rect/circle)"},{name:"width",type:"string",optional:!0,description:"CSS width for shape-only skeletons"}],render:(t,e)=>{const r=f(e.variant),a=f(e.shape);if(a)return Ll(a,e);if(r&&r!=="paragraph")return Rl(r,e);const n=Number(e.lines),i=Math.max(1,Math.min(50,Number.isFinite(n)?Math.floor(n):3)),o=Number(e.height),s=Number.isFinite(o)&&o>0?Math.min(200,Math.floor(o)):12,c=l("div",{class:"rui-skeleton","data-variant":"paragraph"});for(let u=0;u<i;u+=1)c.append(l("div",{class:"rui-skeleton-line",style:`height:${s}px`}));return c}};function Ll(t,e){const r=re(f(e.width),"100%"),a=f(e.height),n=a?re(a,"16px"):t==="circle"?r:"16px";return l("div",{class:"rui-skeleton","data-variant":"shape","data-shape":t==="circle"?"circle":"rect",style:`width:${r};height:${n};`})}function Rl(t,e){const r=l("div",{class:"rui-skeleton","data-variant":t});switch(t){case"avatar":{const a=re(f(e.width),"40px");return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"circle",style:`width:${a};height:${a};`})),r}case"image":{const a=re(f(e.width),"100%"),n=re(f(e.height),"160px");return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"rect",style:`width:${a};height:${n};`})),r}case"card":return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"rect",style:"width:100%;height:120px;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:14px;width:70%;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:12px;width:90%;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:12px;width:60%;"})),r;case"table-row":{const a=Math.max(1,Math.min(8,Math.floor(Number(e.lines??4)))),n=l("div",{class:"rui-skeleton-row"});for(let i=0;i<a;i+=1)n.append(l("div",{class:"rui-skeleton-line",style:"height:12px;flex:1;"}));return r.append(n),r}default:return r}}const zl={name:"Markdown",description:"Render markdown-flavoured text. Supports **bold**, *italic*, `code`, headings (`#`/`##`/`###`), blockquotes (`>`), bullet (`-`/`*`) and numbered (`1.`) lists, fenced code blocks (```), images (``), inline links, and auto-linked bare URLs. Multi-line paragraphs collapse into `<p>` blocks.",props:[{name:"content",type:"string"}],render:(t,e)=>{const r=f(e.content),a=_l(r);return l("div",{class:"rui-markdown",html:a})}},Dl={name:"Container",description:"Centered, max-width content wrapper. Use when a page is wider than comfortable reading width — landing pages, marketing sections, long documents. Picks a sensible default max-width per size; pass `maxWidth` to override with any CSS value.",props:[{name:"children",type:"Node[]"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg","xl","full"],description:"sm=640 / md=820 / lg=1040 / xl=1280 / full=100% (default lg)"},{name:"maxWidth",type:"string",optional:!0,description:"Custom CSS max-width (overrides `size`)"},{name:"padding",type:"string",optional:!0,enum:["none","s","m","l"],description:"Horizontal padding (default m)"}],render:(t,e,r)=>{const a=l("div",{class:"rui-container","data-size":f(e.size,"lg"),"data-padding":f(e.padding,"m"),style:e.maxWidth?`max-width:${re(e.maxWidth,"auto")};`:null});for(const n of $(e.children))a.append(r.renderNode(n));return a}},jl={name:"Spacer",description:'Explicit space element for fine layout control. By default acts as a flex spacer that pushes following content to the far edge (use inside `Stack(direction="row")`). Pass `size` to render a fixed vertical/horizontal gap instead.',props:[{name:"size",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Fixed gap; omit to flex-grow"},{name:"flex",type:"boolean",optional:!0,description:"Flex-grow even when size is set (default true when size omitted)"}],render:(t,e)=>{const r=f(e.size),a=e.flex===void 0?!r:A(e.flex);return l("span",{class:"rui-spacer","data-size":r||null,"data-flex":a?"true":"false","aria-hidden":"true"})}},Bl={name:"Spinner",description:"Indeterminate inline loader. Use for tiny loading states inside buttons, toolbars, table cells, or chat bubbles where `Skeleton` and `Progress(indeterminate=true)` are too heavy. Pass `label` to render an inline caption beside the spinner (also announced via `aria-label`).",props:[{name:"size",type:"string",optional:!0,enum:Rt,description:"Default `md`"},{name:"label",type:"string",optional:!0,description:"Caption rendered beside the spinner (also announced)"},{name:"tone",type:"string",optional:!0,enum:vl,description:"Visual accent (default `primary`)"}],render:(t,e)=>{const r=$r(e.size,"md"),a=f(e.tone,"primary"),n=f(e.label),i=l("span",{class:"rui-spinner","data-size":r,"data-tone":a,role:"status","aria-live":"polite","aria-label":n||"Loading"});return i.append(l("span",{class:"rui-spinner-ring","aria-hidden":"true"})),n&&i.append(l("span",{class:"rui-spinner-label"},[n])),i}},Ol={name:"Quote",description:"Inline pull-quote with optional citation. Lighter than `Testimonial` — use inside articles, blog posts, marketing sections, or anywhere you need to highlight a sentence without the full quote/author/role + rating shape.",props:[{name:"text",type:"string"},{name:"cite",type:"string",optional:!0,aliases:["attribution","author"],description:"Attribution text shown below the quote"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]}],render:(t,e)=>{const r=l("figure",{class:"rui-quote","data-tone":f(e.tone,"default")});r.append(l("blockquote",{class:"rui-quote-text"},[f(e.text)]));const a=f(e.cite);return a&&r.append(l("figcaption",{class:"rui-quote-cite"},[a])),r}};function _l(t){const e=g=>g.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),r=t.split(/\r?\n/),a=[];let n=null,i=!1,o=!1,s="",c=[];const u=()=>{n&&(a.push(n==="ul"?"</ul>":"</ol>"),n=null)},p=()=>{i&&(a.push("</blockquote>"),i=!1)},d=()=>{const g=s?` data-language="${e(s)}"`:"";a.push(`<pre class="rui-markdown-code"${g}><code>${e(c.join(`
|
|
97
|
+
`))}</code></pre>`),c=[],s="",o=!1};for(const g of r){const b=/^```\s*(.*)$/.exec(g.trim());if(o){if(b){d();continue}c.push(g);continue}if(b){u(),p(),o=!0,s=b[1]??"";continue}const h=/^\s*(#{1,3})\s+(.+)$/.exec(g);if(h){u(),p();const w=h[1].length;a.push(`<h${w} class="rui-markdown-h${w}">${m(e(h[2]))}</h${w}>`);continue}const v=/^\s*>\s?(.*)$/.exec(g);if(v){u(),i||(a.push('<blockquote class="rui-markdown-quote">'),i=!0),a.push(`<p>${m(e(v[1]??""))}</p>`);continue}else i&&g.trim()!==""&&p();const y=/^\s*[-*]\s+(.*)$/.exec(g);if(y){p(),n!=="ul"&&(u(),a.push("<ul>"),n="ul"),a.push(`<li>${m(e(y[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(g);if(x){p(),n!=="ol"&&(u(),a.push("<ol>"),n="ol"),a.push(`<li>${m(e(x[1]??""))}</li>`);continue}if(g.trim()===""){u(),p();continue}u(),p(),a.push(`<p>${m(e(g))}</p>`)}return o&&d(),u(),p(),a.join("");function m(g){let b=g.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(h,v,y)=>{const x=ie(y);return x?`<img class="rui-markdown-image" src="${zt(x)}" alt="${v}" loading="lazy">`:`<span class="rui-markdown-image-fallback">${v}</span>`}).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(h,v,y)=>`<a class="rui-link" href="${hn(y)}" target="_blank" rel="noopener noreferrer">${v}</a>`);return b=b.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,h=>`<a class="rui-link" href="${hn(h)}" target="_blank" rel="noopener noreferrer">${h}</a>`),b}}function hn(t){const e=t.trim();if(!e||e.startsWith("//"))return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("?"))return zt(e);const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);if(!r)return zt(e);const a=r[1].toLowerCase();return new Set(["http","https","mailto","tel"]).has(a)?zt(e):"#"}function zt(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function ut(t,e,r){const a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=ie(t);if(n){const i=l("img",{src:n,alt:e,loading:"lazy"});i.onerror=o=>{const s=o;(s.currentTarget??s.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[dt(e)]))},a.append(i)}else a.append(l("span",{class:"rui-avatar-fallback"},[dt(e)]));return a}function dt(t){const e=t.trim();return e?e.split(/\s+/).slice(0,2).map(a=>a.charAt(0).toUpperCase()).join("")||e.charAt(0).toUpperCase():"?"}const Dt=new WeakMap;function rt(t){const{liveRoot:e,onDismiss:r}=t,a=Dt.get(e);a&&a.dispose();const n=e.getRootNode();let i=!1;const o=d=>{const m=d.target;m&&e.contains(m)||(p.dispose(),r())},s=d=>{d.key==="Escape"&&(p.dispose(),r())},c=e.ownerDocument;let u=null;if(c&&typeof MutationObserver<"u"){u=new MutationObserver(()=>{e.isConnected||p.dispose()});const d=e.getRootNode();(d instanceof Element||d instanceof Document||d instanceof ShadowRoot)&&u.observe(d,{childList:!0,subtree:!0})}const p={dispose:()=>{i||(i=!0,n.removeEventListener("click",o,!0),n.removeEventListener("keydown",s,!0),u?.disconnect(),Dt.delete(e))}};return setTimeout(()=>{i||(n.addEventListener("click",o,!0),n.addEventListener("keydown",s,!0))},0),Dt.set(e,p),p}function Ne(t){if(!t)return;const e=Dt.get(t);e&&e.dispose()}const Fl=[{match:/\b(revenue|sales|sale|income|payment|charges?|invoices?|billing)\b/i,icon:"sack-dollar"},{match:/\b(profit|earnings?|margin|roi)\b/i,icon:"chart-line"},{match:/\b(customers?|clients?|users?|members?|people|accounts?)\b/i,icon:"users"},{match:/\b(visitors?|sessions?|traffic|page-?views?|impressions?)\b/i,icon:"chart-line"},{match:/\b(orders?|carts?|purchases?|transactions?)\b/i,icon:"cart-shopping"},{match:/\b(products?|inventory|sku|stock|items?)\b/i,icon:"box"},{match:/\b(subscriptions?|plans?|tiers?|pricing)\b/i,icon:"credit-card"},{match:/\b(emails?|messages?|inbox|threads?|mail)\b/i,icon:"envelope"},{match:/\b(notifications?|alerts?|reminders?)\b/i,icon:"bell"},{match:/\b(growth|trend|increase|up)\b/i,icon:"arrow-trend-up"},{match:/\b(decline|drop|down|decrease|loss)\b/i,icon:"arrow-trend-down"},{match:/\b(reports?|analytics|insights?|dashboards?|metrics?|stats?|kpis?)\b/i,icon:"chart-pie"},{match:/\b(charts?|graphs?)\b/i,icon:"chart-column"},{match:/\b(tasks?|todos?|backlog|kanban|sprint)\b/i,icon:"list-check"},{match:/\b(projects?|workspaces?)\b/i,icon:"folder-open"},{match:/\b(files?|folders?|documents?|docs?|attachments?)\b/i,icon:"folder-open"},{match:/\b(images?|photos?|gallery|albums?)\b/i,icon:"image"},{match:/\b(videos?|clips?|recordings?)\b/i,icon:"video"},{match:/\b(audio|music|podcasts?|sounds?)\b/i,icon:"music"},{match:/\b(calendars?|schedule|events?|meetings?|appointments?)\b/i,icon:"calendar-days"},{match:/\b(comments?|replies|feedback|reviews?|ratings?)\b/i,icon:"comments"},{match:/\b(settings?|preferences?|config|configuration|options?)\b/i,icon:"gear"},{match:/\b(security|privacy|password|locks?|secure)\b/i,icon:"shield-halved"},{match:/\b(api|integrations?|webhooks?|connections?)\b/i,icon:"plug"},{match:/\b(database|storage|backups?|servers?)\b/i,icon:"database"},{match:/\b(speed|performance|latency|response\s?time)\b/i,icon:"gauge-high"},{match:/\b(uptime|availability|status|health)\b/i,icon:"heart-pulse"},{match:/\b(errors?|bugs?|failures?|exceptions?|incidents?)\b/i,icon:"circle-exclamation"},{match:/\b(success|complete|done|approved)\b/i,icon:"circle-check"},{match:/\b(warnings?|caution)\b/i,icon:"triangle-exclamation"},{match:/\b(search|results?|queries)\b/i,icon:"magnifying-glass"},{match:/\b(downloads?|exports?)\b/i,icon:"download"},{match:/\b(uploads?|imports?)\b/i,icon:"upload"},{match:/\b(time|hours?|duration|elapsed)\b/i,icon:"clock"},{match:/\b(locations?|maps?|addresses?|countries?|regions?)\b/i,icon:"location-dot"},{match:/\b(stars?|favourites?|favorites?|highlights?)\b/i,icon:"star"},{match:/\b(trophy|awards?|achievements?|badges?|gold)\b/i,icon:"trophy"},{match:/\b(targets?|goals?|objectives?|quotas?)\b/i,icon:"bullseye"},{match:/\b(teams?|departments?|orgs?|organisations?|organizations?)\b/i,icon:"people-group"},{match:/\b(tickets?|issues?|bugs?|requests?)\b/i,icon:"ticket"},{match:/\b(deploys?|builds?|releases?|versions?)\b/i,icon:"rocket"}];function bn(t){if(!t)return null;for(const e of Fl)if(e.match.test(t))return e.icon;return null}const Ul={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function Hl(t){return t?Ul[t.toLowerCase()]??null:null}function Vl(t,e="shapes"){const r=t.trim()||"anon";return`https://api.dicebear.com/9.x/${/^[a-z0-9-]+$/i.test(e)?e:"shapes"}/svg?seed=${encodeURIComponent(r)}`}function vn(t){return $(t).map(r=>{if(r&&typeof r=="object"){const n=r;if(n.__kind==="Component"&&Array.isArray(n.args)){const i=f(n.args[0]);return{value:i,label:f(n.args[1],i)}}if(n.value!==void 0||n.label!==void 0){const i=f(n.value);return{value:i,label:f(n.label,i)}}}const a=f(r);return{value:a,label:a}}).filter(r=>r.value!==""||r.label!=="")}function He(t,e){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const r=l("span",{class:"rui-wrapper-fragment"});for(const a of e)a!=null&&r.append(typeof a=="string"?document.createTextNode(a):t.renderNode(a));return r}return typeof e=="string"?document.createTextNode(e):t.renderNode(e)}function jt(t,e){return l("span",{class:`rui-wrapper ${t}`,style:"display: contents;",...e??{}})}function Wl(t){const e=f(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const ql=/^[A-Za-z_][A-Za-z0-9_\-:/]*$/;function Kl(t){return(Array.isArray(t)?t.map(r=>f(r)):f(t).split(/\s+/)).map(r=>r.trim()).filter(r=>r.length>0&&r.length<=64&&ql.test(r))}const Gl={name:"OnClick",description:"Make any component clickable. Wraps the child in a transparent span and dispatches `onClick(event)` when the user clicks or taps anywhere inside it. Use to attach click behaviour to components that do not expose an `action` / `onClick` prop (cards, list rows, media tiles, custom layouts).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"],description:"Component (or array of components) to wrap"},{name:"onClick",type:"callable",required:!0,aliases:["action","onclick"],description:"Callable invoked on click / tap. Receives the native MouseEvent."},{name:"disabled",type:"boolean",optional:!0,description:"Skip firing the handler while truthy"},{name:"stopPropagation",type:"boolean",optional:!0,description:"Call event.stopPropagation() after invoking the handler (default false)"}],render:(t,e,r)=>{const a=jt("rui-on-click",{role:"button",tabindex:"0"});a.append(He(r,e.child));const n=A(e.disabled),i=A(e.stopPropagation),o=s=>{n||(i&&s.stopPropagation(),r.invoke(e.onClick,s))};return a.addEventListener("click",o),a.addEventListener("keydown",s=>{const c=s;(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o(c))}),a}},Yl=[{prop:"enter",event:"mouseenter"},{prop:"leave",event:"mouseleave"},{prop:"hover",event:"mouseover"},{prop:"move",event:"mousemove"},{prop:"down",event:"mousedown"},{prop:"up",event:"mouseup"},{prop:"click",event:"click"},{prop:"doubleClick",event:"dblclick"},{prop:"contextMenu",event:"contextmenu"},{prop:"scroll",event:"scroll"},{prop:"wheel",event:"wheel"},{prop:"drag",event:"drag"},{prop:"drop",event:"drop"},{prop:"dragStart",event:"dragstart"},{prop:"dragEnd",event:"dragend"},{prop:"dragEnter",event:"dragenter"},{prop:"dragLeave",event:"dragleave"},{prop:"dragOver",event:"dragover"}],Xl={name:"OnMouse",description:"Attach any combination of mouse / pointer / drag listeners to a component. Pass only the props you need — unused events install no listener so the wrapper is essentially free. Each handler receives the native MouseEvent / DragEvent / WheelEvent. Use for hover tracking, custom drag-and-drop, context menus, scroll-aware UIs.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"],description:"Component to wrap"},{name:"enter",type:"callable",optional:!0,description:"Fired when the pointer enters the element (mouseenter)"},{name:"leave",type:"callable",optional:!0,description:"Fired when the pointer leaves the element (mouseleave)"},{name:"hover",type:"callable",optional:!0,description:"Fired on every mouseover inside the element"},{name:"move",type:"callable",optional:!0,description:"Fired on every mousemove inside the element"},{name:"down",type:"callable",optional:!0,description:"Fired on mousedown"},{name:"up",type:"callable",optional:!0,description:"Fired on mouseup"},{name:"click",type:"callable",optional:!0,description:"Fired on click / tap"},{name:"doubleClick",type:"callable",optional:!0,description:"Fired on double-click"},{name:"contextMenu",type:"callable",optional:!0,description:"Fired on right-click (contextmenu)"},{name:"scroll",type:"callable",optional:!0,description:"Fired when an inner element scrolls"},{name:"wheel",type:"callable",optional:!0,description:"Fired on mouse-wheel / trackpad scroll"},{name:"drag",type:"callable",optional:!0,description:"Fired while the element is being dragged"},{name:"drop",type:"callable",optional:!0,description:"Fired when something is dropped onto the element"},{name:"dragStart",type:"callable",optional:!0,description:"Fired when a drag begins"},{name:"dragEnd",type:"callable",optional:!0,description:"Fired when a drag ends"},{name:"dragEnter",type:"callable",optional:!0,description:"Fired when a drag enters the element"},{name:"dragLeave",type:"callable",optional:!0,description:"Fired when a drag leaves the element"},{name:"dragOver",type:"callable",optional:!0,description:"Fired while something is dragged over the element. Call `event.preventDefault()` to make the element a valid drop target."},{name:"draggable",type:"boolean",optional:!0,description:'Make the wrapper itself draggable (sets `draggable="true"`)'},{name:"passiveScroll",type:"boolean",optional:!0,description:"Register scroll/wheel listeners as passive (default true for better scroll performance)"}],render:(t,e,r)=>{const a=jt("rui-on-mouse");A(e.draggable)&&a.setAttribute("draggable","true"),a.append(He(r,e.child));const n=e.passiveScroll===void 0?!0:A(e.passiveScroll);for(const{prop:i,event:o}of Yl){const s=e[i];if(s==null)continue;const u=o==="scroll"||o==="wheel"?{passive:n}:{};a.addEventListener(o,p=>{r.invoke(s,p)},u)}return a}},Jl=[{prop:"onKeyDown",event:"keydown"},{prop:"onKeyUp",event:"keyup"},{prop:"onKeyPress",event:"keypress"}],Zl={name:"OnKeyboard",description:'Attach keyboard listeners to a component. Pass any combination of `onKeyDown`, `onKeyUp`, and `onKeyPress`; each handler receives the native KeyboardEvent. Use for keyboard shortcuts, navigation, and custom focusable widgets. The wrapper is focusable by default (tabindex="0") so it can be reached via Tab; pass `focusable=false` to disable when the child is already focusable.',props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onKeyDown",type:"callable",optional:!0,aliases:["onkeydown"],description:"Fired on keydown"},{name:"onKeyUp",type:"callable",optional:!0,aliases:["onkeyup"],description:"Fired on keyup"},{name:"onKeyPress",type:"callable",optional:!0,aliases:["onkeypress"],description:"Fired on keypress"},{name:"focusable",type:"boolean",optional:!0,description:"Make the wrapper focusable via Tab (default true)"}],render:(t,e,r)=>{const a=e.focusable===void 0?!0:A(e.focusable),n=jt("rui-on-keyboard",a?{tabindex:"0"}:{});n.append(He(r,e.child));for(const{prop:i,event:o}of Jl){const s=e[i];s!=null&&n.addEventListener(o,c=>{r.invoke(s,c)})}return n}},Ql={name:"OnFocus",description:"Attach focus / blur listeners to a component. Use to track input focus rings, custom focus indicators, or autosave-on-blur flows. Listens on the capture phase so blur from descendants is observed.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onFocus",type:"callable",optional:!0,aliases:["onfocus"],description:"Fired when focus enters the element or any descendant"},{name:"onBlur",type:"callable",optional:!0,aliases:["onblur"],description:"Fired when focus leaves the element and all descendants"}],render:(t,e,r)=>{const a=jt("rui-on-focus");return a.append(He(r,e.child)),e.onFocus!=null&&a.addEventListener("focusin",n=>r.invoke(e.onFocus,n)),e.onBlur!=null&&a.addEventListener("focusout",n=>r.invoke(e.onBlur,n)),a}},ec={name:"OnIntersect",description:"Observe whether a component is visible in the viewport (or a scroll container) using IntersectionObserver. Fires `onEnter` the first time the wrapped element becomes visible, `onLeave` when it leaves, and `onChange({visible, ratio})` for every transition. Use for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onEnter",type:"callable",optional:!0,description:"Fired when the element enters the viewport"},{name:"onLeave",type:"callable",optional:!0,description:"Fired when the element leaves the viewport"},{name:"onChange",type:"callable",optional:!0,description:"Fired with `{visible, ratio}` on every transition"},{name:"threshold",type:"number",optional:!0,description:"Visible-ratio threshold 0–1 (default 0.05)"},{name:"rootMargin",type:"string",optional:!0,description:'CSS-length root margin (e.g. "0px 0px -64px 0px")'},{name:"once",type:"boolean",optional:!0,description:"Disconnect after the first entry (default false)"}],render:(t,e,r)=>{const a=l("span",{class:"rui-wrapper rui-on-intersect",style:"display: inline-block;"});a.append(He(r,e.child));const n=typeof IntersectionObserver<"u"?IntersectionObserver:void 0;if(!n)return a;const i=Math.max(0,Math.min(1,E(e.threshold,.05))),o=f(e.rootMargin),s=A(e.once);let c=null;const u=new n(p=>{for(const d of p){const m=d.isIntersecting;if(m!==c&&(m&&e.onEnter!=null&&r.invoke(e.onEnter,d),!m&&c===!0&&e.onLeave!=null&&r.invoke(e.onLeave,d),c=m),e.onChange!=null&&r.invoke(e.onChange,{visible:m,ratio:d.intersectionRatio}),s&&m){u.disconnect();return}}},{threshold:i,...o?{rootMargin:o}:{}});return u.observe(a),r.registerDisposer(()=>u.disconnect()),a}},tc={name:"OnMount",description:"Run imperative code against the wrapped component's rendered DOM node. `onMount(node)` fires once, on a microtask after the child is attached to the DOM — the Aktion way to get a DOM ref (measure an element, focus it, or hand it to an imperative library such as a chart / map / editor). `onUnmount(node)` fires when the component leaves the tree. Pair with `$ref(...)` to stash the node across renders.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onMount",type:"callable",optional:!0,description:"`(node) => void` — fired once after the wrapped element is attached."},{name:"onUnmount",type:"callable",optional:!0,description:"`(node) => void` — fired when the wrapped element leaves the tree."}],render:(t,e,r)=>{const a=l("span",{class:"rui-wrapper rui-on-mount",style:"display: contents;"});a.append(He(r,e.child));const n=r.useInstanceState("rui-on-mount",!1);if(!n.get()){n.set(!0);const i=()=>{const o=a.firstElementChild??a;e.onMount!=null&&r.invoke(e.onMount,o),e.onUnmount!=null&&r.registerDisposer(()=>{const s=()=>r.invoke(e.onUnmount,o);typeof queueMicrotask=="function"?queueMicrotask(s):Promise.resolve().then(s)},"rui-on-mount-unmount")};typeof queueMicrotask=="function"?queueMicrotask(i):Promise.resolve().then(i)}return a}};function rc(t,e){return e==null?[]:typeof e=="string"?[document.createTextNode(e)]:Array.isArray(e)?e.filter(r=>r!=null).map(r=>typeof r=="string"?document.createTextNode(r):t.renderNode(r)):[t.renderNode(e)]}const yn={name:"Link",description:'Anchor link. Accepts either a plain string label or a wrapped component as its positional child. Pass `to` for client-side router navigation (no page reload) or `href` for a regular anchor. `external: true` opens the link in a new tab with `rel="noopener noreferrer"`. Use to make any component clickable as a link — cards, icons, badges, list rows.',props:[{name:"label",type:"string | Node",positional:!0,required:!0,aliases:["child","children"],description:"Visible text OR a wrapped component"},{name:"to",type:"string",optional:!0,description:"Router path (preferred). Navigates via the runtime router on click."},{name:"href",type:"string",optional:!0,description:"Standard anchor href. Used when `to` is omitted."},{name:"external",type:"boolean",optional:!0,description:'Open in a new tab (`target="_blank"`, `rel="noopener noreferrer"`)'},{name:"variant",type:"string",optional:!0,enum:["default","subtle"]}],render:(t,e,r)=>{const a=f(e.to),n=A(e.external),i=a||f(e.href),o=a?i.startsWith("/")||i.startsWith("#")?i:tt(i,"#"):tt(e.href,"#"),s=f(e.variant,"default"),c=l("a",{class:"rui-link","data-variant":s,href:o,target:n?"_blank":null,rel:n?"noopener noreferrer":null});for(const u of rc(r,e.label))c.append(u);return a&&!n&&c.addEventListener("click",u=>{u.defaultPrevented||u.button===0&&(u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||(u.preventDefault(),r.router.navigate(a)))}),c}},ac={name:"Css",description:"Apply raw CSS class names and / or an inline style string to a wrapped component. The styling is merged onto the rendered child's DOM element — no extra wrapper element is added unless the child is plain text (in which case the styling lands on a wrapping span). Reach for `Css` only when the component's own props cannot express the styling (use `Box`/`Stack`/`Grid` props for layout, `Theme` for tokens, `Styles` + selector classes for sweeping changes).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"style",type:"string",optional:!0,description:'Inline CSS declarations (e.g. "padding: 16px; background: #eef;")'},{name:"class",type:"string | string[]",optional:!0,aliases:["className","classes"],description:"Class name (space-separated string or array). Tokens must match `[A-Za-z_][A-Za-z0-9_-:/]*`."}],render:(t,e,r)=>{const a=He(r,e.child),n=a instanceof HTMLElement?a:(()=>{const s=l("span",{class:"rui-css"});return s.append(a),s})(),i=Kl(e.class);for(const s of i)n.classList.add(s);const o=Wl(e.style);if(o){const s=n.getAttribute("style");n.setAttribute("style",s?`${s};${o}`:o)}return n}};function oe(t,e,r,a){if(e==null)return;const n=a.event??"change";t.addEventListener(n,()=>{r.invoke(e,a.getValue(t))})}const nc=["primary","secondary","ghost","danger"],ic=["xs","sm","md","lg","xl"],oc=["text","email","password","number","tel","url","date"];function sc(t){const e=f(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="sm"?"sm":e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":"md"}const lc={name:"Button",description:"Clickable button. `onClick` (a callable) runs when the user presses the button. The legacy `action` prop is an alias and is still accepted.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable invoked when the button is clicked"},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:nc},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:ic,description:"Size token `xs|sm|md|lg|xl`"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"},{name:"iconPosition",type:"string",optional:!0,enum:["leading","trailing"],description:"Icon placement (default leading)"},{name:"iconOnly",type:"boolean",optional:!0,description:"Hide the label visually (keeps aria-label)"},{name:"loading",type:"boolean",optional:!0,description:"Show spinner and disable interaction"},{name:"fullWidth",type:"boolean",optional:!0},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=A(e.loading),n=A(e.iconOnly),i=f(e.iconPosition,"leading"),o=f(e.label),s=l("button",{class:"rui-button",type:f(e.type,"button"),"data-variant":f(e.variant,"primary"),"data-size":sc(e.size),"data-icon-position":i,"data-icon-only":n?"true":null,"data-full-width":A(e.fullWidth)?"true":null,"data-loading":a?"true":null,"aria-label":n?o:null,disabled:A(e.disabled)||a?"":null}),c=l("span",{class:"rui-button-label"},[o]),u=j(e.icon,{className:"rui-button-icon"}),d=(a?j("spinner",{className:"rui-button-spinner"}):null)??u;return n?d&&s.append(d):i==="trailing"?(s.append(c),d&&s.append(d)):(d&&s.append(d),s.append(c)),s.onclick=()=>{a||r.invoke(e.onClick)},s}},cc={name:"Buttons",description:"Group of buttons laid out horizontally or vertically.",props:[{name:"items",type:"Button[]"},{name:"direction",type:"string",optional:!0,enum:["row","column"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-buttons","data-direction":f(e.direction,"row")});for(const n of $(e.items))a.append(r.renderNode(n));return a}},uc={name:"Input",description:"Text input field. Pass a $variable as `value` for two-way binding. `onChange(value)` fires on every keystroke with the current string.",props:[{name:"id",type:"string",description:"Input identifier"},{name:"placeholder",type:"string",optional:!0},{name:"type",type:"string",optional:!0,enum:oc},{name:"validations",type:"any",optional:!0,description:"Array or object of validation hints"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=l("input",{class:"rui-input",id:f(e.id),name:f(e.id),type:f(e.type,"text"),placeholder:f(e.placeholder),value:f(e.value)});return Ve(a,t,4,r),oe(a,e.onChange,r,{event:"input",getValue:n=>n.value}),Mc(a,e.validations),a}},dc={name:"TextArea",description:"Multi-line text input. `onChange(value)` fires on every keystroke with the current text.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0},{name:"value",type:"any",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=l("textarea",{class:"rui-textarea",id:f(e.id),name:f(e.id),placeholder:f(e.placeholder),rows:String(Number(e.rows??4)||4)});return a.value=f(e.value),Ve(a,t,3,r),oe(a,e.onChange,r,{event:"input",getValue:n=>n.value}),a}},pc={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>l("option",{value:f(e.value)},[f(e.label)])},mc={name:"Select",description:"Dropdown select. Pass a `$variable` as `value` for two-way binding. Set `searchable: true` for a combobox-style filter UI on long option lists. `onChange(value)` fires with the newly-selected value.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"label",type:"string",optional:!0},{name:"placeholder",type:"string",optional:!0},{name:"value",type:"any",optional:!0},{name:"searchable",type:"boolean",optional:!0,description:"Render as a filterable combobox"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{if(A(e.searchable))return Tc(t,e,r);const a=l("select",{class:"rui-select",id:f(e.id),name:f(e.id)}),n=f(e.placeholder);n&&a.append(l("option",{value:"",disabled:"",selected:""},[n]));for(const i of $(e.items))a.append(r.renderNode(i));return a.value=f(e.value),Ve(a,t,4,r),oe(a,e.onChange,r,{event:"change",getValue:i=>i.value}),a}},fc={name:"Checkbox",description:"Boolean checkbox. `onChange(checked)` fires with the new boolean state.",props:[{name:"id",type:"string"},{name:"label",type:"string"},{name:"value",type:"boolean",optional:!0,aliases:["checked"]},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new boolean value"}],render:(t,e,r)=>{const a=l("label",{class:"rui-checkbox"}),n=A(e.value),i=l("input",{type:"checkbox",id:f(e.id),name:f(e.id),checked:n?"":null});return i.checked=n,Ve(i,t,2,r),oe(i,e.onChange,r,{event:"change",getValue:o=>o.checked}),a.append(i,l("span",{class:"rui-checkbox-label"},[f(e.label)])),a}},gc={name:"CheckBoxItem",description:"Single option inside a CheckBoxGroup.",props:[{name:"label",type:"string"},{name:"name",type:"string",description:"Key inside the group's value object"},{name:"description",type:"string",optional:!0},{name:"defaultChecked",type:"boolean",optional:!0,aliases:["checked"]}],render:(t,e)=>{const r=f(e.name),a=f(e.label),n=f(e.description),i=A(e.defaultChecked),o=l("label",{class:"rui-checkbox-item","data-name":r}),s=l("input",{type:"checkbox",name:r,checked:i?"":null});s.checked=i;const c=l("div",{class:"rui-checkbox-item-text"});return c.append(l("div",{class:"rui-checkbox-item-label"},[a])),n&&c.append(l("div",{class:"rui-checkbox-item-description"},[n])),o.append(s,c),o}},hc={name:"CheckBoxGroup",description:"Group of checkboxes. Value is an object keyed by item name. Pass a `$variable` for two-way binding. `onChange(value)` fires with the full updated object.",props:[{name:"name",type:"string",description:"Group identifier"},{name:"items",type:"CheckBoxItem[]"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated `{name: checked}` object when any item toggles"}],render:(t,e,r)=>{const a=f(e.name),n=l("div",{class:"rui-checkbox-group",role:"group","data-name":a}),i=$(e.items),o=e.value&&typeof e.value=="object"?e.value:{};i.forEach((u,p)=>{const d=f(u.args?.[0]),m=f(u.args?.[1],`${a}-${p}`),g=f(u.args?.[2]),b=A(u.args?.[3]),h=`${a}-${m}`,v=l("label",{class:"rui-checkbox-item",for:h}),y=m in o?!!o[m]:b,x=l("input",{type:"checkbox",id:h,name:m,checked:y?"":null}),w=l("div",{class:"rui-checkbox-item-text"});w.append(l("div",{class:"rui-checkbox-item-label"},[d])),g&&w.append(l("div",{class:"rui-checkbox-item-description"},[g])),v.append(x,w),n.append(v)});const s=t.argMeta?.[2]?.stateRef,c=u=>{const p={};return u.querySelectorAll('input[type="checkbox"]').forEach(d=>{p[d.name]=d.checked}),p};return s&&r.bindState(n,s,{event:"change",getValue:c}),oe(n,e.onChange,r,{event:"change",getValue:u=>c(u)}),n}},bc={name:"Radio",description:"Radio button group. `onChange(value)` fires with the newly-selected option value.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"value",type:"any",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected radio value"}],render:(t,e,r)=>{const a=f(e.id),n=l("div",{class:"rui-radio-group",role:"radiogroup"});for(const i of $(e.items)){const o=f(i.args?.[0]),s=f(i.args?.[1],o),c=`${a}-${o}`,u=l("label",{class:"rui-radio",for:c}),p=f(e.value)===o,d=l("input",{type:"radio",id:c,name:a,value:o,checked:p?"":null});d.checked=p,Ve(d,t,2,r),oe(d,e.onChange,r,{event:"change",getValue:m=>m.value}),u.append(d,l("span",{class:"rui-radio-label"},[s])),n.append(u)}return n}},vc={name:"FormControl",description:"Labeled wrapper around a single form field.",props:[{name:"label",type:"string"},{name:"field",type:"Node",aliases:["control"]},{name:"hint",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-form-control"});a.append(l("label",{class:"rui-form-label"},[f(e.label)]));const n=r.renderNode(e.field);a.append(n);const i=f(e.hint);return i&&a.append(l("p",{class:"rui-form-hint"},[i])),a}},xn={name:"SearchBar",description:"Pre-styled search input with a leading magnifying-glass icon, optional trailing submit button, and optional keyboard-shortcut hint. Pass a `$variable` as `value` for two-way binding. Use anywhere a user needs to filter content — toolbars, command bars, lists, headers.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"shortcut",type:"string",optional:!0,description:'Keyboard hint chip on the right (e.g. "/")'},{name:"onSubmit",type:"callable",optional:!0,aliases:["action","onClick"],description:"Optional submit callable; clicking the trailing button or pressing Enter invokes it"},{name:"submitLabel",type:"string",optional:!0,description:'Label for the trailing submit button (default "Search"). Omitted when no action is provided.'},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current query on every keystroke"}],render:(t,e,r)=>{const a=l("form",{class:"rui-search-bar",role:"search"});a.onsubmit=s=>{s.preventDefault(),r.invoke(e.onSubmit)};const n=j("magnifying-glass",{className:"rui-search-bar-icon"})??l("span",{class:"rui-search-bar-icon","aria-hidden":"true"});a.append(n);const i=l("input",{class:"rui-search-bar-input",id:f(e.id),name:f(e.id),type:"search",placeholder:f(e.placeholder,"Search…"),value:f(e.value),autocomplete:"off"});Ve(i,t,2,r),oe(i,e.onChange,r,{event:"input",getValue:s=>s.value}),a.append(i);const o=f(e.shortcut);if(o&&a.append(l("span",{class:"rui-search-bar-shortcut"},[o])),e.onSubmit!=null){const s=l("button",{type:"submit",class:"rui-search-bar-submit"},[f(e.submitLabel,"Search")]);a.append(s)}return a}},yc={name:"Form",description:'Form container. Children FormControls render in order; buttons render at the bottom. Provide `onSubmit` to handle form submission (invoked when the user presses Enter on a focused input or clicks a `type="submit"` Button inside the form).',props:[{name:"id",type:"string"},{name:"buttons",type:"Buttons | Button"},{name:"fields",type:"FormControl[]"},{name:"onSubmit",type:"callable",optional:!0,aliases:["onsubmit"],description:"Called when the form is submitted (Enter key or submit button)"}],render:(t,e,r)=>{const a=l("form",{class:"rui-form",id:f(e.id)});a.onsubmit=n=>{n.preventDefault(),r.invoke(e.onSubmit)};for(const n of $(e.fields))a.append(r.renderNode(n));if(e.buttons){const n=l("div",{class:"rui-form-actions"});n.append(r.renderNode(e.buttons)),a.append(n)}return a}},xc={name:"Slider",description:"Range slider for selecting a single numeric value between `min` and `max`. Pass a `$variable` as `value` for two-way binding. Useful for filters, settings (volume, brightness), and parameter tuning.",props:[{name:"id",type:"string"},{name:"min",type:"number",optional:!0,description:"Default 0"},{name:"max",type:"number",optional:!0,description:"Default 100"},{name:"step",type:"number",optional:!0,description:"Default 1"},{name:"value",type:"number",optional:!0,description:"Bound value (typically $variable)"},{name:"label",type:"string",optional:!0},{name:"showValue",type:"boolean",optional:!0,description:"Render the current numeric value beside the slider"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new number as the user drags"}],render:(t,e,r)=>{const a=f(e.id),n=E(e.min,0),i=E(e.max,100),o=E(e.step,1),s=E(e.value,n),c=l("div",{class:"rui-slider","data-disabled":A(e.disabled)?"true":"false"}),u=f(e.label),p=A(e.showValue);if(u||p){const g=l("div",{class:"rui-slider-head"});u&&g.append(l("label",{class:"rui-slider-label",for:a},[u])),p&&g.append(l("span",{class:"rui-slider-value"},[String(s)])),c.append(g)}const d=l("input",{type:"range",class:"rui-slider-input",id:a,name:a,min:String(n),max:String(i),step:String(o),value:String(s),disabled:A(e.disabled)?"":null});d.oninput=g=>{const b=g.currentTarget;if(!b)return;const v=b.closest(".rui-slider")?.querySelector(".rui-slider-value");v&&(v.textContent=b.value)};const m=t.argMeta?.[4]?.stateRef;return m&&r.bindState(d,m,{event:"input",getValue:g=>Number(g.value)}),oe(d,e.onChange,r,{event:"input",getValue:g=>Number(g.value)}),c.append(d),c}},wc={name:"NumberInput",description:'Numeric input with paired increment/decrement buttons. Use for quantity steppers, integer settings, and any field where a `<input type="number">` plus +/- controls is friendlier than the native spinner. Pass a `$variable` as `value` for two-way binding.',props:[{name:"id",type:"string"},{name:"value",type:"number",optional:!0,description:"Bound value (typically $variable)"},{name:"min",type:"number",optional:!0},{name:"max",type:"number",optional:!0},{name:"step",type:"number",optional:!0,description:"Default 1"},{name:"placeholder",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new number (or null when blank)"}],render:(t,e,r)=>{const a=f(e.id),n=E(e.step,1),i=e.min!==void 0&&e.min!==null,o=e.max!==void 0&&e.max!==null,s=i?E(e.min,0):Number.NEGATIVE_INFINITY,c=o?E(e.max,0):Number.POSITIVE_INFINITY,u=A(e.disabled),p=l("div",{class:"rui-number-input","data-disabled":u?"true":"false"}),d=l("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:u?"":null},["−"]),m=l("input",{type:"number",class:"rui-number-input-field",id:a,name:a,value:f(e.value),placeholder:f(e.placeholder),min:i?String(s):null,max:o?String(c):null,step:String(n),disabled:u?"":null}),g=l("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:u?"":null},["+"]),b=t.argMeta?.[1]?.stateRef,h=y=>{const x=y.value;if(x==="")return null;const w=Number(x);return Number.isFinite(w)?w:null};b&&r.bindState(m,b,{event:"input",getValue:h}),oe(m,e.onChange,r,{event:"input",getValue:h});const v=(y,x)=>{const k=y.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!k)return;const T=Number(k.value),S=Number.isFinite(T)?T:0,C=Ac(S+x,s,c);k.value=String(C),k.dispatchEvent(new Event("input",{bubbles:!0}))};return d.onclick=y=>v(y.currentTarget??y.target,-n),g.onclick=y=>v(y.currentTarget??y.target,n),p.append(d,m,g),p}},kc={name:"DatePicker",description:'Date picker that wraps the native `<input type="date">` with consistent styling. Pass a `$variable` as `value` for two-way binding. Use `min`/`max` to bound the selectable range.',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"ISO date (YYYY-MM-DD); typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0,description:"Earliest ISO date"},{name:"max",type:"string",optional:!0,description:"Latest ISO date"},{name:"placeholder",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new ISO date string when the picker changes"}],render:(t,e,r)=>{const a=f(e.id),n=l("div",{class:"rui-date-picker"}),i=f(e.label);i&&n.append(l("label",{class:"rui-date-picker-label",for:a},[i]));const o=l("input",{type:"date",class:"rui-date-picker-input",id:a,name:a,value:f(e.value),min:f(e.min)||null,max:f(e.max)||null,placeholder:f(e.placeholder),disabled:A(e.disabled)?"":null});return Ve(o,t,1,r),oe(o,e.onChange,r,{event:"change",getValue:s=>s.value}),n.append(o),n}},Sc={name:"FileUpload",description:'Styled file picker. Renders a click/drop area with a leading icon, label, and helper text. Files cannot round-trip through `$variables` (they are not serialisable), so pass a callable as `action` to handle the picked files via `ctx.query("#id").files`.',props:[{name:"id",type:"string"},{name:"label",type:"string",optional:!0,description:'Primary label (default "Choose a file")'},{name:"hint",type:"string",optional:!0,description:"Secondary helper text"},{name:"accept",type:"string",optional:!0,description:"Comma-separated MIME types or extensions"},{name:"multiple",type:"boolean",optional:!0},{name:"onSelect",type:"callable",optional:!0,aliases:["action","onChange"],description:"Callable fired with the FileList when files are picked"},{name:"icon",type:"string",optional:!0,description:'Font Awesome icon (default "cloud-arrow-up")'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=f(e.id),n=A(e.disabled),i=l("div",{class:"rui-file-upload","data-disabled":n?"true":"false"}),o=l("label",{class:"rui-file-upload-dropzone",for:a}),s=j(f(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});s&&o.append(s);const c=l("div",{class:"rui-file-upload-text"});c.append(l("div",{class:"rui-file-upload-label"},[f(e.label,"Choose a file")]));const u=f(e.hint);u&&c.append(l("div",{class:"rui-file-upload-hint"},[u])),o.append(c);const p=l("input",{type:"file",id:a,name:a,class:"rui-file-upload-input",accept:f(e.accept)||null,multiple:A(e.multiple)?"":null,disabled:n?"":null});o.append(p),i.append(o);const d=(m,g)=>g.includes("image")||m.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(m.name);return p.onchange=m=>{const g=m.currentTarget;r.invoke(e.onSelect,g.files);const b=g.closest(".rui-file-upload");if(!b)return;const h=g.files,v=b.querySelector(".rui-file-upload-preview");if(v&&v.remove(),!h||h.length===0)return;const y=f(e.accept),x=l("div",{class:"rui-file-upload-preview"});Array.from(h).forEach(w=>{const k=l("div",{class:"rui-file-upload-preview-item"});if(d(w,y)){const T=URL.createObjectURL(w),S=l("img",{src:T,alt:w.name,class:"rui-file-upload-thumbnail"});S.onload=()=>URL.revokeObjectURL(T),k.append(S)}k.append(l("span",{class:"rui-file-upload-filename"},[w.name])),x.append(k)}),b.append(x)},i}},wn={name:"Combobox",description:"Searchable single-select dropdown — type to filter, click an option to choose. Use instead of `Select` when the list is long enough that scanning is faster than scrolling (countries, currencies, repos, users). Pass a `$variable` as `value` for two-way binding; the selected option's `value` is written to state on pick.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]",description:"Options; SelectItem(value, label) or {value, label}"},{name:"value",type:"string",optional:!0,description:"Bound selected value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"emptyLabel",type:"string",optional:!0,description:'Text shown when no items match the filter (default "No matches")'},{name:"disabled",type:"boolean",optional:!0},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the dropdown"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{const a=f(e.id),n=vn(e.items),i=f(e.value),o=n.find(S=>S.value===i)?.label??i,s=f(e.placeholder,"Select…"),c=f(e.emptyLabel,"No matches"),u=A(e.disabled),p=A(e.open),d=r.useInstanceState("open",p),m=r.useInstanceState("filter",""),g=d.get(),b=l("div",{class:"rui-combobox","data-open":g?"true":"false","data-disabled":u?"true":"false"}),h=l("button",{type:"button",class:"rui-combobox-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":g?"true":"false",disabled:u?"":null});h.append(l("span",{class:"rui-combobox-value","data-placeholder":o?"false":"true"},[o||s]));const v=j("chevron-down",{className:"rui-combobox-chevron"});v&&h.append(v),b.append(h);const y=l("div",{class:"rui-combobox-panel",role:"listbox"}),x=l("input",{type:"text",class:"rui-combobox-filter",placeholder:"Filter…",autocomplete:"off",value:m.get()});y.append(x);const w=l("div",{class:"rui-combobox-list"});y.append(w);const k=(S,C)=>{S.replaceChildren();const N=C.trim().toLowerCase(),I=N===""?n:n.filter(L=>L.label.toLowerCase().includes(N)||L.value.toLowerCase().includes(N));if(I.length===0){S.append(l("div",{class:"rui-combobox-empty"},[c]));return}for(const L of I){const D=l("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":L.value,"aria-selected":L.value===i?"true":"false"},[L.label]);D.onclick=q=>{q.stopPropagation(),T(q.currentTarget,L.value)},S.append(D)}},T=(S,C)=>{const N=t.argMeta?.[2]?.stateRef;N&&r.setState(N,C),r.invoke(e.onChange,C),d.set(!1),m.set("");const I=S.closest(".rui-combobox");I?.setAttribute("data-open","false"),I?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false"),Ne(I)};return k(w,m.get()),x.oninput=S=>{const C=S.currentTarget;m.set(C.value);const N=C.closest(".rui-combobox-panel")?.querySelector(".rui-combobox-list");N&&k(N,C.value)},x.onkeydown=S=>{const C=S;if(C.key!=="Enter")return;C.preventDefault();const L=C.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),D=L?.getAttribute("data-value");D!=null&&L&&T(L,D)},h.onclick=S=>{if(u)return;S.stopPropagation();const C=!d.get();d.set(C);const N=S.currentTarget.closest(".rui-combobox");if(N?.setAttribute("data-open",C?"true":"false"),N?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded",C?"true":"false"),!!N){if(!C){Ne(N);return}setTimeout(()=>x.focus(),0),rt({liveRoot:N,onDismiss:()=>{d.set(!1),m.set(""),N.setAttribute("data-open","false"),N.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},b.append(y),b}},$c={name:"MultiSelect",description:"Multi-option searchable dropdown. Type to filter, click an option to add/remove it from the bound array. Renders the selected options as removable chips inside the trigger. Pass a `$variable` (array of values) as `value` for two-way binding.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]",description:"Options; SelectItem(value, label) or {value, label}"},{name:"value",type:"any[]",optional:!0,description:"Bound array of selected values (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when no items match the filter"},{name:"max",type:"number",optional:!0,description:"Maximum number of selections"},{name:"disabled",type:"boolean",optional:!0},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the dropdown"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated array of selected values"}],render:(t,e,r)=>{const a=f(e.id),n=vn(e.items),i=f(e.placeholder,"Select…"),o=f(e.emptyLabel,"No matches"),s=A(e.disabled),c=Math.max(0,Math.floor(Number(e.max??0))),u=Array.isArray(e.value)?e.value.map(I=>f(I)).filter(Boolean):[],p=new Set(u),d=t.argMeta?.[2]?.stateRef,m=A(e.open),g=r.useInstanceState("open",m),b=r.useInstanceState("filter",""),h=g.get(),v=l("div",{class:"rui-multiselect","data-open":h?"true":"false","data-disabled":s?"true":"false"}),y=l("button",{type:"button",class:"rui-multiselect-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":h?"true":"false",disabled:s?"":null}),x=l("span",{class:"rui-multiselect-chips"}),w=I=>{d&&r.setState(d,I),r.invoke(e.onChange,I)};if(u.length===0)x.append(l("span",{class:"rui-multiselect-placeholder"},[i]));else for(const I of u){const L=n.find(O=>O.value===I)?.label??I,D=l("span",{class:"rui-multiselect-chip","data-value":I});D.append(l("span",{class:"rui-multiselect-chip-label"},[L]));const q=l("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${L}`},["×"]);q.onclick=O=>{O.stopPropagation();const U=u.filter(J=>J!==I);w(U)},D.append(q),x.append(D)}y.append(x);const k=j("chevron-down",{className:"rui-multiselect-chevron"});k&&y.append(k),v.append(y);const T=l("div",{class:"rui-multiselect-panel",role:"listbox","aria-multiselectable":"true"}),S=l("input",{type:"text",class:"rui-multiselect-filter",placeholder:"Filter…",autocomplete:"off",value:b.get()});T.append(S);const C=l("div",{class:"rui-multiselect-list"});T.append(C);const N=(I,L)=>{I.replaceChildren();const D=L.trim().toLowerCase(),q=D===""?n:n.filter(O=>O.label.toLowerCase().includes(D)||O.value.toLowerCase().includes(D));if(q.length===0){I.append(l("div",{class:"rui-multiselect-empty"},[o]));return}for(const O of q){const U=p.has(O.value),J=!U&&c>0&&u.length>=c,Z=l("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":O.value,"data-selected":U?"true":"false","aria-selected":U?"true":"false",disabled:J?"":null}),me=l("span",{class:"rui-multiselect-option-check"}),$e=j(U?"check":"",{className:"rui-multiselect-option-check-icon"});$e&&me.append($e),Z.append(me),Z.append(l("span",{class:"rui-multiselect-option-label"},[O.label])),Z.onclick=Ct=>{if(Ct.stopPropagation(),J)return;const Ye=U?u.filter(da=>da!==O.value):[...u,O.value];w(Ye)},I.append(Z)}};return N(C,b.get()),S.oninput=I=>{const L=I.currentTarget;b.set(L.value);const D=L.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");D&&N(D,L.value)},y.onclick=I=>{if(s)return;I.stopPropagation();const L=!g.get();g.set(L);const D=I.currentTarget.closest(".rui-multiselect");if(D?.setAttribute("data-open",L?"true":"false"),D?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",L?"true":"false"),!!D){if(!L){Ne(D);return}setTimeout(()=>S.focus(),0),rt({liveRoot:D,onDismiss:()=>{g.set(!1),b.set(""),D.setAttribute("data-open","false"),D.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},v.append(T),v}},Cc={name:"DateRangePicker",description:"Paired date inputs with a single label, sharing the same min/max range. Pass `$variable` references for both `from` and `to` to two-way-bind a date range (ISO `YYYY-MM-DD` strings).",props:[{name:"id",type:"string"},{name:"from",type:"string",optional:!0,description:"ISO date start; typically $variable"},{name:"to",type:"string",optional:!0,description:"ISO date end; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0,description:"Earliest selectable ISO date"},{name:"max",type:"string",optional:!0,description:"Latest selectable ISO date"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with `{from, to}` whenever either endpoint changes"}],render:(t,e,r)=>{const a=f(e.id),n=`${a}-from`,i=`${a}-to`,o=f(e.min),s=f(e.max),c=A(e.disabled),u=l("div",{class:"rui-date-range-picker","data-disabled":c?"true":"false"}),p=f(e.label);p&&u.append(l("label",{class:"rui-date-range-picker-label",for:n},[p]));const d=l("div",{class:"rui-date-range-picker-row"}),m=l("input",{type:"date",class:"rui-date-range-picker-input",id:n,name:n,value:f(e.from),min:o||null,max:s||null,disabled:c?"":null,"data-role":"from"});d.append(m),d.append(l("span",{class:"rui-date-range-picker-separator","aria-hidden":"true"},["–"]));const g=l("input",{type:"date",class:"rui-date-range-picker-input",id:i,name:i,value:f(e.to),min:o||null,max:s||null,disabled:c?"":null,"data-role":"to"});d.append(g),u.append(d);const b=t.argMeta?.[1]?.stateRef,h=t.argMeta?.[2]?.stateRef;if(b&&r.bindState(m,b),h&&r.bindState(g,h),e.onChange!=null){const v=y=>{const x=y.closest(".rui-date-range-picker"),w=x?.querySelector('.rui-date-range-picker-input[data-role="from"]')?.value??"",k=x?.querySelector('.rui-date-range-picker-input[data-role="to"]')?.value??"";return{from:w,to:k}};m.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget))),g.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget)))}return u}};function Ac(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function Tc(t,e,r){const a=t.argMeta?[...t.argMeta]:[];for(;a.length<5;)a.push({});a[4]?.stateRef&&(a[2]=a[4]);const n=wn.render({...t,argMeta:a},{id:e.id,items:e.items,value:e.value,placeholder:e.placeholder,emptyLabel:"No matches",disabled:!1},r);return n.classList.add("rui-select-searchable"),n}function Ve(t,e,r,a){const n=e.argMeta?.[r]?.stateRef;if(n){if(t instanceof HTMLInputElement&&t.type==="checkbox"){a.bindState(t,n,{event:"change",getValue:i=>i.checked});return}a.bindState(t,n)}}function Mc(t,e){if(!e)return;const r=Array.isArray(e)?e.map(a=>String(a)):typeof e=="object"?Object.entries(e).map(([a,n])=>n?`${a}:${n}`:a):[];for(const a of r)a==="required"?t.required=!0:a.startsWith("minLength:")?t.minLength=Number(a.slice(10))||0:a.startsWith("maxLength:")?t.maxLength=Number(a.slice(10))||0:a==="email"&&(t.type="email")}const Le=["default","primary","success","warning","danger","info"],We=(t,e)=>{const r=$(t);if(r.length===0)return null;const a=l("div",{class:"rui-pattern-actions"});for(const n of r)a.append(e.renderNode(n));return a},Nc=[{match:/\bbeta\b/i,label:"Beta"},{match:/\b(early\s?access|preview)\b/i,label:"Preview"},{match:/\b(introduc(?:ing|e)|launch(?:ed|ing)?|announcing)\b/i,label:"Introducing"},{match:/\b(welcome\b|get(?:ting)?\s?started)/i,label:"Welcome"},{match:/\b(new\b|whats\s?new|now\b)/i,label:"What's new"},{match:/\bfree\b/i,label:"Free trial"},{match:/\bupgrade\b/i,label:"Upgrade"},{match:/\b(sale|discount|deal)\b/i,label:"Limited time"}];function Pc(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const a of Nc)if(a.match.test(r))return a.label;return""}const Ic={name:"Hero",description:'Eye-catching landing/marketing header with eyebrow tag, title, subtitle, optional bullet highlights, and primary/secondary CTA buttons. Use `layout="cover"` with `imageSrc` for an image-backed hero band (pass `height` and optional `caption`). Default layout shows an optional side illustration.',props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0},{name:"primary",type:"Button",optional:!0,description:"Primary CTA — pass a Button(...)"},{name:"secondary",type:"Button",optional:!0,description:"Secondary CTA — pass a Button(...)"},{name:"eyebrow",type:"string",optional:!0,description:"Short uppercase tag above the title"},{name:"highlights",type:"string[]",optional:!0,description:"Bullet items rendered as tag pills"},{name:"imageSrc",type:"string",optional:!0,description:"Illustration or cover background when layout=cover"},{name:"caption",type:"string",optional:!0,description:"Small caption above CTAs (cover layout)"},{name:"height",type:"string",optional:!0,description:"Min-height for cover layout (default 280px)"},{name:"actions",type:"Node[]",optional:!0,description:"CTA row (cover layout; alternative to primary/secondary)"},{name:"layout",type:"string",optional:!0,enum:["default","cover"],description:"default = text-first; cover = image-backed band"},{name:"tone",type:"string",optional:!0,enum:Le,description:"Accent tone"}],render:(t,e,r)=>{const a=f(e.layout,"default"),n=f(e.title),i=f(e.subtitle),s=f(e.eyebrow)||Pc(n,i),c=f(e.tone,"primary");if(a==="cover"){const b=Es(f(e.imageSrc)),h=re(f(e.height),"280px"),v=l("section",{class:"rui-cover","data-tone":c,style:`background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url("${b}");min-height:${h};`}),y=l("div",{class:"rui-cover-body"});s&&y.append(l("span",{class:"rui-cover-eyebrow"},[s])),y.append(l("h1",{class:"rui-cover-title"},[n])),i&&y.append(l("p",{class:"rui-cover-subtitle"},[i]));const x=f(e.caption);x&&y.append(l("p",{class:"rui-cover-caption"},[x]));const w=We(e.actions,r);if(w)w.classList.add("rui-cover-actions"),y.append(w);else{const k=[e.primary,e.secondary].filter(Boolean);if(k.length>0){const T=l("div",{class:"rui-cover-actions rui-pattern-actions"});for(const S of k)T.append(r.renderNode(S));y.append(T)}}return v.append(y),v}const u=ie(e.imageSrc),p=l("section",{class:"rui-hero","data-tone":c,"data-has-image":u?"true":"false"}),d=l("div",{class:"rui-hero-body"});s&&d.append(l("span",{class:"rui-hero-eyebrow"},[s])),d.append(l("h1",{class:"rui-hero-title"},[n])),i&&d.append(l("p",{class:"rui-hero-subtitle"},[i]));const m=$(e.highlights);if(m.length>0){const b=l("div",{class:"rui-hero-highlights"});for(const h of m){const v=f(h);v&&b.append(l("span",{class:"rui-hero-highlight"},[v]))}d.append(b)}const g=[e.primary,e.secondary].filter(Boolean);if(g.length>0){const b=l("div",{class:"rui-hero-ctas"});for(const h of g)b.append(r.renderNode(h));d.append(b)}if(p.append(d),u){const b=l("div",{class:"rui-hero-media"});b.append(l("img",{src:u,alt:"",loading:"lazy"})),p.append(b)}return p}},Ec={name:"PageHeader",description:'Page-level header with breadcrumbs, title, subtitle, status tag, and a right-aligned actions row. The canonical first child for any dashboard, settings, or detail page — replaces ad-hoc Stack+Header+Buttons stitching. If `breadcrumbs` is omitted the component auto-derives `["Home", title]` so the page never lacks a trail. Pass `breadcrumbs=false` to opt out.',props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0},{name:"breadcrumbs",type:"string[] | Breadcrumb | false",optional:!0,description:"Array of strings, a Breadcrumb(...) node, or `false` to suppress the auto-derived trail"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / NavLinks shown on the right"},{name:"status",type:"Badge",optional:!0,aliases:["badge"],description:"Optional Badge(...) rendered next to the title"}],render:(t,e,r)=>{const a=l("header",{class:"rui-page-header"}),n=f(e.title);let i=e.breadcrumbs;if(i==null?n&&(i=["Home",n]):(i===!1||i==="false")&&(i=null),i){const d=l("div",{class:"rui-page-header-breadcrumbs"});Array.isArray(i)?i.forEach((m,g)=>{g>0&&d.append(l("span",{class:"rui-page-header-crumb-sep"},["/"])),d.append(l("span",{class:"rui-page-header-crumb"},[f(m)]))}):d.append(r.renderNode(i)),a.append(d)}const o=l("div",{class:"rui-page-header-title-row"}),s=l("div",{class:"rui-page-header-title-block"}),c=l("div",{class:"rui-page-header-title-line"});c.append(l("h1",{class:"rui-page-header-title"},[n])),e.status&&c.append(r.renderNode(e.status)),s.append(c);const u=f(e.subtitle);u&&s.append(l("p",{class:"rui-page-header-subtitle"},[u])),o.append(s);const p=We(e.actions,r);return p&&(p.classList.add("rui-page-header-actions"),o.append(p)),a.append(o),a}},Lc={name:"EmptyState",description:"Zero-state placeholder for empty lists, searches, dashboards. Renders a centered icon (or illustration), title, description, and either a single `action` Button or an `actions` row (primary + secondary). Always preferable to an empty Card with raw text.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:'Font Awesome icon name (defaults to "inbox")'},{name:"illustration",type:"string",optional:!0,description:"Image URL — takes precedence over `icon` when provided"},{name:"action",type:"Button",optional:!0,description:"Single CTA (legacy slot)"},{name:"actions",type:"Node[]",optional:!0,description:"Row of CTA Buttons / Links — preferred over `action` for primary + secondary affordances"}],render:(t,e,r)=>{const a=l("div",{class:"rui-empty-state"}),n=ie(e.illustration);if(n)a.append(l("img",{class:"rui-empty-state-illustration",src:n,alt:"",loading:"lazy"}));else{const s=f(e.title),c=f(e.description),u=f(e.icon)||bn(`${s} ${c}`)||"inbox",p=j(u,{className:"rui-empty-state-icon"});p&&a.append(p)}a.append(l("h3",{class:"rui-empty-state-title"},[f(e.title)]));const i=f(e.description);i&&a.append(l("p",{class:"rui-empty-state-description"},[i]));const o=$(e.actions);if(o.length>0){const s=l("div",{class:"rui-empty-state-actions"});for(const c of o)s.append(r.renderNode(c));a.append(s)}else if(e.action){const s=l("div",{class:"rui-empty-state-action"});s.append(r.renderNode(e.action)),a.append(s)}return a}},Rc={name:"TimelineItem",description:"Single event on a Timeline.",props:[{name:"title",type:"string"},{name:"time",type:"string",optional:!0,description:"Display label (ISO, relative, etc.)"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name rendered inside the marker"},{name:"tone",type:"string",optional:!0,enum:Le}],render:(t,e)=>{const r=l("li",{class:"rui-timeline-item","data-tone":f(e.tone,"default")}),a=l("span",{class:"rui-timeline-marker"}),n=j(e.icon);n&&a.append(n),r.append(a);const i=l("div",{class:"rui-timeline-body"}),o=l("div",{class:"rui-timeline-head"});o.append(l("span",{class:"rui-timeline-title"},[f(e.title)]));const s=f(e.time);s&&o.append(l("span",{class:"rui-timeline-time"},[s])),i.append(o);const c=f(e.description);return c&&i.append(l("div",{class:"rui-timeline-description"},[c])),r.append(i),r}},zc={name:"Timeline",description:"Vertical event timeline. Children must be TimelineItem entries. Ideal for activity feeds, changelogs, and process flows.",props:[{name:"items",type:"TimelineItem[]"}],render:(t,e,r)=>{const a=l("ol",{class:"rui-timeline"});for(const n of $(e.items))a.append(r.renderNode(n));return a}},Dc={name:"FeatureItem",description:"Single tile on a FeatureGrid.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"tone",type:"string",optional:!0,enum:Le}],render:(t,e)=>{const r=l("div",{class:"rui-feature-item","data-tone":f(e.tone,"primary")}),a=f(e.icon,"sparkles"),n=j(a,{className:"rui-feature-icon"});n&&r.append(n),r.append(l("h3",{class:"rui-feature-title"},[f(e.title)]));const i=f(e.description);return i&&r.append(l("p",{class:"rui-feature-description"},[i])),r}},jc={name:"FeatureGrid",description:"Responsive grid of FeatureItem tiles (typically 2–3 columns). Use to highlight product capabilities or page categories.",props:[{name:"items",type:"FeatureItem[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(4,Number(e.columns??"auto"))),n=l("div",{class:"rui-feature-grid","data-columns":a>0?String(a):null});for(const i of $(e.items))n.append(r.renderNode(i));return n}},Bc={name:"Testimonial",description:"Quote card with author, role, and optional avatar.",props:[{name:"quote",type:"string"},{name:"author",type:"string",aliases:["name"]},{name:"role",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"rating",type:"number",optional:!0,description:"0–5 stars"}],render:(t,e)=>{const r=l("figure",{class:"rui-testimonial"}),a=Math.max(0,Math.min(5,Math.round(Number(e.rating??0))));if(a>0){const c=l("div",{class:"rui-testimonial-rating"});for(let u=0;u<5;u+=1){const p=u<a,d=j(p?"star":"regular:star",{className:"rui-testimonial-rating-star"});d&&c.append(d)}r.append(c)}r.append(l("blockquote",{class:"rui-testimonial-quote"},[f(e.quote)]));const n=l("figcaption",{class:"rui-testimonial-author"}),i=ie(e.avatarSrc);i&&n.append(l("img",{class:"rui-testimonial-avatar",src:i,alt:""}));const o=l("div",{class:"rui-testimonial-meta"});o.append(l("div",{class:"rui-testimonial-name"},[f(e.author)]));const s=f(e.role);return s&&o.append(l("div",{class:"rui-testimonial-role"},[s])),n.append(o),r.append(n),r}},Oc={name:"ProfileCard",description:"Compact profile/user card with avatar, name, role, optional bio, social tags, and a row of action buttons. Use for team rosters, contributor lists, and contact panels.",props:[{name:"name",type:"string"},{name:"role",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"],description:"Avatar image src; falls back to initials"},{name:"bio",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0},{name:"actions",type:"Node[]",optional:!0,description:"Buttons to render at the bottom"}],render:(t,e,r)=>{const a=l("div",{class:"rui-profile-card"}),n=l("div",{class:"rui-profile-card-header"});n.append(ut(f(e.avatarSrc),f(e.name),"lg"));const i=l("div",{class:"rui-profile-card-meta"});i.append(l("h3",{class:"rui-profile-card-name"},[f(e.name)]));const o=f(e.role);o&&i.append(l("p",{class:"rui-profile-card-role"},[o])),n.append(i),a.append(n);const s=f(e.bio);s&&a.append(l("p",{class:"rui-profile-card-bio"},[s]));const c=$(e.tags);if(c.length>0){const p=l("div",{class:"rui-profile-card-tags"});for(const d of c){const m=f(d);m&&p.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[m])]))}a.append(p)}const u=We(e.actions,r);return u&&(u.classList.add("rui-profile-card-actions"),a.append(u)),a}},_c={name:"Comment",description:"Single comment / message bubble. Renders avatar, author, timestamp, body, and an optional row of toolbar buttons (reply, like, …).",props:[{name:"author",type:"string"},{name:"body",type:"string",aliases:["text","message"]},{name:"time",type:"string",optional:!0,description:"Relative or absolute timestamp"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=l("article",{class:"rui-comment"});a.append(ut(f(e.avatarSrc),f(e.author),"md"));const n=l("div",{class:"rui-comment-body"}),i=l("header",{class:"rui-comment-header"});i.append(l("span",{class:"rui-comment-author"},[f(e.author)]));const o=f(e.time);o&&i.append(l("span",{class:"rui-comment-time"},[o])),n.append(i),n.append(l("div",{class:"rui-comment-content"},[f(e.body)]));const s=We(e.actions,r);return s&&(s.classList.add("rui-comment-actions"),n.append(s)),a.append(n),a}},Fc={name:"Banner",description:"Full-width announcement banner. Use at the top of a page for promos, release notes, or downtime notices. For inline notices prefer Callout or Alert.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"action",type:"Button",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name"},{name:"tone",type:"string",optional:!0,enum:Le}],render:(t,e,r)=>{const a=f(e.tone,"primary"),n=l("aside",{class:"rui-banner","data-tone":a}),i=f(e.icon)||Hl(a)||"",o=j(i,{className:"rui-banner-icon"});o&&n.append(o);const s=l("div",{class:"rui-banner-body"});s.append(l("strong",{class:"rui-banner-title"},[f(e.title)]));const c=f(e.message);if(c&&s.append(l("span",{class:"rui-banner-message"},[c])),n.append(s),e.action){const u=l("div",{class:"rui-banner-action"});u.append(r.renderNode(e.action)),n.append(u)}return n}},Uc={name:"KanbanCard",description:"Single card on a Kanban board.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0},{name:"assignee",type:"string",optional:!0,description:"Name shown next to avatar initials"},{name:"tone",type:"string",optional:!0,enum:Le},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown beside the title"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Optional callable fired when the card is clicked"}],render:(t,e,r)=>{const a=l("div",{class:"rui-kanban-card","data-tone":f(e.tone,"default")});typeof e.onClick=="function"&&(a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.onclick=()=>r.invoke(e.onClick),a.onkeydown=u=>{const p=u;(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r.invoke(e.onClick))});const n=l("div",{class:"rui-kanban-card-title"}),i=j(e.icon,{className:"rui-kanban-card-icon"});i&&n.append(i),n.append(document.createTextNode(f(e.title))),a.append(n);const o=f(e.description);o&&a.append(l("p",{class:"rui-kanban-card-description"},[o]));const s=$(e.tags);if(s.length>0){const u=l("div",{class:"rui-kanban-card-tags"});for(const p of s){const d=f(p);d&&u.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[d])]))}a.append(u)}const c=f(e.assignee);if(c){const u=l("footer",{class:"rui-kanban-card-footer"});u.append(ut("",c,"sm")),u.append(l("span",{class:"rui-kanban-card-assignee"},[c])),a.append(u)}return a}},Hc={name:"KanbanColumn",description:"Single column inside a KanbanBoard. Children must be KanbanCard entries.",props:[{name:"title",type:"string"},{name:"items",type:"KanbanCard[]",aliases:["cards"]},{name:"tone",type:"string",optional:!0,enum:Le,description:"Header accent tone"}],render:(t,e,r)=>{const a=$(e.items),n=l("section",{class:"rui-kanban-column","data-tone":f(e.tone,"default")}),i=l("header",{class:"rui-kanban-column-header"});i.append(l("span",{class:"rui-kanban-column-title"},[f(e.title)])),i.append(l("span",{class:"rui-kanban-column-count"},[String(a.length)])),n.append(i);const o=l("div",{class:"rui-kanban-column-body"});for(const s of a)o.append(r.renderNode(s));return a.length===0&&o.append(l("div",{class:"rui-kanban-column-empty"},["No items"])),n.append(o),n}},Vc={name:"KanbanBoard",description:"Horizontal Kanban board. Children must be KanbanColumn entries. The board scrolls horizontally on narrow viewports so columns stay readable.",props:[{name:"columns",type:"KanbanColumn[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-kanban-board"});for(const n of $(e.columns))a.append(r.renderNode(n));return a}},Wc={name:"SectionHeader",description:"Compact section header for the top of a Card or panel. Renders a small eyebrow, a title, an optional subtitle, an optional status Tag/Badge, and a right-aligned actions row. Use this inside a Card to introduce a section instead of a bare `CardHeader`.",props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0,aliases:["description"]},{name:"eyebrow",type:"string",optional:!0,description:"Short uppercase label above the title"},{name:"status",type:"Badge | Tag",optional:!0,aliases:["badge"]},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / Links shown on the right"}],render:(t,e,r)=>{const a=l("header",{class:"rui-section-header"}),n=l("div",{class:"rui-section-header-left"}),i=f(e.eyebrow);i&&n.append(l("span",{class:"rui-section-header-eyebrow"},[i]));const o=l("div",{class:"rui-section-header-title-line"});o.append(l("h3",{class:"rui-section-header-title"},[f(e.title)])),e.status&&o.append(r.renderNode(e.status)),n.append(o);const s=f(e.subtitle);s&&n.append(l("p",{class:"rui-section-header-subtitle"},[s])),a.append(n);const c=We(e.actions,r);return c&&(c.classList.add("rui-section-header-actions"),a.append(c)),a}},qc={name:"Toolbar",description:"Horizontal toolbar for filters, search, view modes, and primary actions. Left/center/right slots wrap onto separate rows on narrow viewports so the bar never overflows. Pass `searchable: true` to auto-mount a SearchBar in the left slot (bind `searchValue` to a `$variable`). Use ABOVE a Table, List, Grid, or Kanban view — never replace `PageHeader` with it.",props:[{name:"left",type:"Node[]",optional:!0,description:"Filters / search inputs / chips"},{name:"right",type:"Node[]",optional:!0,description:"Primary action buttons"},{name:"center",type:"Node[]",optional:!0,description:"Centered controls (e.g. SegmentedControl, search bar)"},{name:"searchable",type:"boolean",optional:!0,description:"Auto-mount a SearchBar at the start of the left slot"},{name:"searchPlaceholder",type:"string",optional:!0,description:"Placeholder for the auto-mounted SearchBar"},{name:"searchValue",type:"string",optional:!0,description:"$variable bound to the auto-mounted SearchBar"}],render:(t,e,r)=>{const a=$(e.center),n=l("div",{class:"rui-toolbar","data-has-center":a.length>0?"true":"false"}),i=l("div",{class:"rui-toolbar-side rui-toolbar-left"});A(e.searchable)&&i.append(xn.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:f(e.searchPlaceholder,"Search…"),value:e.searchValue},r));for(const s of $(e.left))i.append(r.renderNode(s));if(n.append(i),a.length>0){const s=l("div",{class:"rui-toolbar-side rui-toolbar-center"});for(const c of a)s.append(r.renderNode(c));n.append(s)}const o=l("div",{class:"rui-toolbar-side rui-toolbar-right"});for(const s of $(e.right))o.append(r.renderNode(s));return n.append(o),n}},Kc={name:"SidebarItem",description:"Single navigation item inside a Sidebar. Pass `active=true` to mark as the current page, a `to` path to navigate via the runtime router on click, an `onClick` callable for arbitrary click handling, or an optional `badge` (string/number) for a trailing chip. `to` and `onClick` can coexist — `onClick` is invoked AFTER the router navigates so authors can do extra work (analytics, side-effects).",props:[{name:"label",type:"string"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name rendered before the label"},{name:"active",type:"boolean",optional:!0,description:"Mark this item as the current page. When `to` is provided and `active` is omitted, the item auto-detects the active state from the current router path."},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"to",type:"string",optional:!0,description:'Router path to navigate to on click (e.g. "/", "/orders"). Uses the runtime router — no full page reload.'},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable invoked on click. Runs in addition to `to`-based navigation."}],render:(t,e,r)=>{const a=f(e.to),n=e.active!==void 0&&e.active!==null,i=a?r.router.getPath():"",o=a?a==="/"?i==="/":i===a?!0:i.startsWith(a+"/"):!1,s=n?A(e.active):o,c=l("button",{type:"button",class:"rui-sidebar-item","data-active":s?"true":"false","data-to":a||null}),u=j(e.icon,{className:"rui-sidebar-item-icon"});u&&c.append(u),c.append(l("span",{class:"rui-sidebar-item-label"},[f(e.label)]));const p=f(e.badge);return p&&c.append(l("span",{class:"rui-sidebar-item-badge"},[p])),(a||e.onClick!=null)&&(c.onclick=d=>{if(a){const m=d;if(m.metaKey||m.ctrlKey||m.shiftKey||m.altKey)return;r.router.navigate(a)}e.onClick!=null&&r.invoke(e.onClick)}),c}},Gc={name:"SidebarSection",description:"Grouping inside a Sidebar — small uppercase label followed by SidebarItem entries. Use this to chunk a long sidebar into sections.",props:[{name:"label",type:"string"},{name:"items",type:"SidebarItem[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-sidebar-section"}),n=f(e.label);n&&a.append(l("div",{class:"rui-sidebar-section-label"},[n]));for(const i of $(e.items))a.append(r.renderNode(i));return a}},Yc={name:"Sidebar",description:"Vertical app navigation panel. Supports a brand header, navigation items (`SidebarItem` or `SidebarSection`), an optional footer, and a `collapsed` mode that hides labels to leave just an icon rail. Use inside `AppShell` for SaaS-style left navigation.",props:[{name:"items",type:"(SidebarItem | SidebarSection)[]"},{name:"brand",type:"string",optional:!0,description:"Product name / workspace label at the top"},{name:"tagline",type:"string",optional:!0},{name:"footer",type:"Node[]",optional:!0,description:"Footer block (Avatar + name, upgrade CTA, …)"},{name:"collapsed",type:"boolean",optional:!0,description:"Render as an icon-only rail (hides labels/badges)"}],render:(t,e,r)=>{const a=A(e.collapsed),n=l("aside",{class:"rui-sidebar"});a&&(n.dataset.collapsed="true");const i=f(e.brand),o=f(e.tagline);if(i||o){const u=l("div",{class:"rui-sidebar-header"});i&&u.append(l("div",{class:"rui-sidebar-brand"},[i])),o&&u.append(l("div",{class:"rui-sidebar-tagline"},[o])),n.append(u)}const s=l("nav",{class:"rui-sidebar-body"});for(const u of $(e.items))s.append(r.renderNode(u));n.append(s);const c=$(e.footer);if(c.length>0){const u=l("div",{class:"rui-sidebar-footer"});for(const p of c)u.append(r.renderNode(p));n.append(u)}return n}},Xc={name:"AppShell",description:"Canonical SaaS application shell: optional top bar, fixed left Sidebar, and scrollable main content. Reach for this whenever a response represents a full product surface (dashboard with nav, settings + sections, admin panels). Pass `collapsible=true` to render a hamburger that turns the sidebar into a slide-over drawer on narrow viewports.",props:[{name:"sidebar",type:"Sidebar",description:"Pass a Sidebar(...) node"},{name:"content",type:"Node[]",description:"Main content (typically starts with a PageHeader)"},{name:"topbar",type:"Node[]",optional:!0,description:"Optional thin top bar above the content"},{name:"collapsible",type:"boolean",optional:!0,description:"Show a hamburger that toggles the sidebar drawer on mobile"},{name:"sidebarOpen",type:"boolean",optional:!0,description:"$variable controlling whether the mobile drawer is open"}],render:(t,e,r)=>{const a=A(e.collapsible),n=A(e.sidebarOpen),i=l("div",{class:"rui-app-shell"});a&&(i.dataset.collapsible="true"),n&&(i.dataset.sidebarOpen="true");const o=l("div",{class:"rui-app-shell-sidebar"});if(o.append(r.renderNode(e.sidebar)),i.append(o),a){const p=l("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});p.addEventListener("click",()=>{delete i.dataset.sidebarOpen}),i.append(p)}const s=l("div",{class:"rui-app-shell-main"}),c=$(e.topbar);if(c.length>0||a){const p=l("div",{class:"rui-app-shell-topbar"});if(a){const d=l("button",{class:"rui-app-shell-toggle",type:"button","aria-label":"Toggle navigation"});d.append(j("bars",{size:"md"})??document.createTextNode("≡")),d.addEventListener("click",()=>{i.dataset.sidebarOpen?delete i.dataset.sidebarOpen:i.dataset.sidebarOpen="true"}),p.append(d)}for(const d of c)p.append(r.renderNode(d));s.append(p)}const u=l("div",{class:"rui-app-shell-content"});for(const p of $(e.content))u.append(r.renderNode(p));return s.append(u),i.append(s),i}},Jc={name:"SplitView",description:"Two-pane master/detail layout — a narrow primary pane on the left, wider detail pane on the right. Collapses to a single column on narrow viewports. Use for inboxes, file browsers, contact lists.",props:[{name:"primary",type:"Node[]",description:"Master pane content (list, filters)"},{name:"detail",type:"Node[]",aliases:["secondary"],description:"Detail pane content (selected item, empty state)"},{name:"primaryWidth",type:"string",optional:!0,aliases:["splitAt"],description:"CSS width for the primary pane (default 320px)"}],render:(t,e,r)=>{const a=re(f(e.primaryWidth),"320px"),n=l("div",{class:"rui-split-view",style:`--rui-split-primary:${a}`}),i=l("div",{class:"rui-split-view-primary"});for(const s of $(e.primary))i.append(r.renderNode(s));const o=l("div",{class:"rui-split-view-detail"});for(const s of $(e.detail))o.append(r.renderNode(s));return n.append(i,o),n}},Zc={name:"DescriptionItem",description:"Single row inside a DescriptionList. Renders a small uppercase label on the left and a value (string or arbitrary Node) on the right.",props:[{name:"label",type:"string"},{name:"value",type:"Node | string"},{name:"icon",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-description-item"}),n=l("dt",{class:"rui-description-label"}),i=j(e.icon,{className:"rui-description-icon"});i&&n.append(i),n.append(document.createTextNode(f(e.label)));const o=l("dd",{class:"rui-description-value"});return e.value&&typeof e.value=="object"&&e.value.__kind==="Component"?o.append(r.renderNode(e.value)):o.append(document.createTextNode(f(e.value))),a.append(n,o),a}},Qc={name:"DescriptionList",description:"Compact key/value summary for detail pages — replaces a row of `Text`s with a properly aligned `<dl>`. Children must be DescriptionItem entries. Two columns by default on wide viewports.",props:[{name:"items",type:"DescriptionItem[]"},{name:"columns",type:"number",optional:!0,description:"1 or 2 (default 2)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(2,Math.floor(Number(e.columns??2)))),n=l("dl",{class:"rui-description-list","data-columns":String(a)});for(const i of $(e.items))n.append(r.renderNode(i));return n}},eu={name:"StatusDot",description:"Inline status pip + label. Use for compact health/state indicators in toolbars, sidebars, lists, and table cells.",props:[{name:"label",type:"string"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]},{name:"pulse",type:"boolean",optional:!0,description:"Animate the dot for 'live' state"}],render:(t,e)=>{const r=l("span",{class:"rui-status-dot","data-tone":f(e.tone,"success"),"data-pulse":A(e.pulse)?"true":"false"});return r.append(l("span",{class:"rui-status-dot-marker"})),r.append(l("span",{class:"rui-status-dot-label"},[f(e.label)])),r}},tu={name:"PricingCard",description:"Single pricing tier card with plan name, price, billing period, description, bullet features, and a CTA button. Mark one tier as `featured=true` to highlight it (raises the card, adds a ribbon).",props:[{name:"plan",type:"string",description:"Tier name (e.g. 'Pro')"},{name:"price",type:"string",description:"Display price (e.g. '$29')"},{name:"period",type:"string",optional:!0,description:"Billing period (e.g. '/mo')"},{name:"description",type:"string",optional:!0},{name:"features",type:"string[]",optional:!0,description:"Bullet list of included features"},{name:"action",type:"Button",optional:!0,aliases:["cta"],description:"Primary CTA — pass a Button(...)"},{name:"badge",type:"string",optional:!0,description:"Eyebrow / badge above the plan name"},{name:"featured",type:"boolean",optional:!0,aliases:["highlighted"]}],render:(t,e,r)=>{const a=A(e.featured),n=l("article",{class:"rui-pricing-card","data-featured":a?"true":"false"}),i=f(e.badge);i&&n.append(l("div",{class:"rui-pricing-card-badge"},[i])),n.append(l("h3",{class:"rui-pricing-card-plan"},[f(e.plan)]));const o=f(e.description);o&&n.append(l("p",{class:"rui-pricing-card-description"},[o]));const s=l("div",{class:"rui-pricing-card-price-row"});s.append(l("span",{class:"rui-pricing-card-price"},[f(e.price)]));const c=f(e.period);c&&s.append(l("span",{class:"rui-pricing-card-period"},[c])),n.append(s);const u=$(e.features);if(u.length>0){const p=l("ul",{class:"rui-pricing-card-features"});for(const d of u){const m=f(d);if(!m)continue;const g=j("circle-check",{className:"rui-pricing-card-check"})??l("span",{class:"rui-pricing-card-check"});p.append(l("li",{class:"rui-pricing-card-feature"},[g,document.createTextNode(m)]))}n.append(p)}if(e.action){const p=l("div",{class:"rui-pricing-card-action"});p.append(r.renderNode(e.action)),n.append(p)}return n}},ru={name:"PricingTable",description:"Responsive grid of PricingCard tiers. Items size uniformly across a row and wrap onto multiple rows on narrow viewports. Use as the centerpiece of any pricing or upgrade page.",props:[{name:"tiers",type:"PricingCard[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(4,Math.floor(Number(e.columns??"auto")))),n=l("div",{class:"rui-pricing-table","data-columns":a>0?String(a):null});for(const i of $(e.tiers))n.append(r.renderNode(i));return n}},au={name:"MediaCard",description:'Card with a media (image) header followed by title, body, optional tags, footer meta, and an actions row. Use for article previews, product cards, project highlights, gallery items — anywhere a Card needs a leading image. Orient with `orientation="horizontal"` for side-by-side media + content on wide viewports.',props:[{name:"title",type:"string"},{name:"imageSrc",type:"string",optional:!0,aliases:["src","image"],description:"Image URL (omit to render a neutral placeholder)"},{name:"description",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0,description:"Tag pill labels"},{name:"meta",type:"string",optional:!0,description:"Footer meta line (author · date · category)"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / Links rendered at the bottom"},{name:"badge",type:"string | Badge",optional:!0,description:"Eyebrow string or Badge node shown over the image"},{name:"orientation",type:"string",optional:!0,enum:["vertical","horizontal"]},{name:"ratio",type:"string",optional:!0,description:"Media aspect ratio (default 16:9 vertical, 4:3 horizontal)"}],render:(t,e,r)=>{const a=f(e.orientation,"vertical"),n=l("article",{class:"rui-media-card","data-orientation":a}),i=nu(f(e.ratio,a==="horizontal"?"4:3":"16:9")),o=l("div",{class:"rui-media-card-media",style:`aspect-ratio:${i};`}),s=ie(e.imageSrc);if(s)o.append(l("img",{src:s,alt:f(e.title),loading:"lazy"}));else{o.classList.add("rui-media-card-media-empty");const g=j("image",{className:"rui-media-card-placeholder"})??l("span",{class:"rui-media-card-placeholder"});o.append(g)}if(e.badge){const g=l("span",{class:"rui-media-card-badge"});typeof e.badge=="string"?g.append(document.createTextNode(f(e.badge))):g.append(r.renderNode(e.badge)),o.append(g)}n.append(o);const c=l("div",{class:"rui-media-card-body"});c.append(l("h3",{class:"rui-media-card-title"},[f(e.title)]));const u=f(e.description);u&&c.append(l("p",{class:"rui-media-card-description"},[u]));const p=$(e.tags);if(p.length>0){const g=l("div",{class:"rui-media-card-tags"});for(const b of p){const h=f(b);h&&g.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[h])]))}c.append(g)}const d=f(e.meta);d&&c.append(l("p",{class:"rui-media-card-meta"},[d]));const m=We(e.actions,r);return m&&(m.classList.add("rui-media-card-actions"),c.append(m)),n.append(c),n}};function nu(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}function Cr(t,e="primary"){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg");if(i.setAttribute("class","rui-sparkline"),i.setAttribute("data-tone",e),i.setAttribute("viewBox","0 0 80 24"),i.setAttribute("width",String(80)),i.setAttribute("height",String(24)),i.setAttribute("aria-hidden","true"),t.length<2)return i;const o=Math.min(...t),s=Math.max(...t),c=s-o||1,u=80/(t.length-1),d=t.map((h,v)=>{const y=v*u,x=2+(s-h)/c*20;return[y,x]}).map(([h,v],y)=>`${y===0?"M":"L"}${h.toFixed(1)},${v.toFixed(1)}`).join(" "),m=`${d} L80,24 L0,24 Z`,g=document.createElementNS(n,"path");g.setAttribute("d",m),g.setAttribute("class","rui-sparkline-area"),i.appendChild(g);const b=document.createElementNS(n,"path");return b.setAttribute("d",d),b.setAttribute("class","rui-sparkline-line"),b.setAttribute("fill","none"),i.appendChild(b),i}const iu={name:"Stats",description:'KPI strip or grid. Pass `items` as `{label, value, hint?, tone?, spark?}` objects for strip layout, or as `StatCard(...)` nodes when `layout="grid"`.',props:[{name:"items",type:"object[] | StatCard[]",description:"Stat objects or StatCard nodes when layout=grid"},{name:"layout",type:"string",optional:!0,enum:["strip","grid"],description:"strip = horizontal row; grid = responsive Grid"},{name:"columns",type:"number",optional:!0,description:"Preferred column count for grid layout (1–6)"},{name:"align",type:"string",optional:!0,enum:["start","center","end"],description:"Strip alignment (layout=strip only)"}],render:(t,e,r)=>{const a=$(e.items),n=a.some(c=>c&&typeof c=="object"&&c.__kind==="Component");if(f(e.layout,n?"grid":"strip")==="grid"){const c=e.columns?Math.max(1,Math.min(6,Math.floor(E(e.columns)))):0,u=un.render({__kind:"Component",name:"Grid",args:[],argMeta:[]},{children:a,columns:c>0?c:"auto",gap:"m"},r);return u.classList.add("rui-metric-grid"),u}const o=f(e.align,"start"),s=l("div",{class:"rui-stats","data-align":o});for(const c of a){const u=c??{},p=f(u.tone,"default"),d=l("div",{class:"rui-stats-item","data-tone":p});d.append(l("div",{class:"rui-stats-label"},[f(u.label)]));const m=l("div",{class:"rui-stats-value-row"});m.append(l("div",{class:"rui-stats-value"},[f(u.value)]));const g=$(u.spark).map(h=>Number(h)).filter(h=>Number.isFinite(h));g.length>1&&m.append(Cr(g,p)),d.append(m);const b=f(u.hint);b&&d.append(l("div",{class:"rui-stats-hint"},[b])),s.append(d)}return s}},ou={name:"Tile",description:"Compact icon + label + optional value tile. Smaller and denser than `StatCard`, ideal for menu grids, quick-action panels, category directories, and category filters. Pair with `Grid` for uniform rows.",props:[{name:"label",type:"string"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"value",type:"string",optional:!0,description:"Secondary value rendered next to/under the label"},{name:"description",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:Le},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const a=typeof e.onClick=="function",i=l(a?"button":"div",{type:a?"button":null,class:"rui-tile","data-tone":f(e.tone,"default")}),o=j(e.icon,{className:"rui-tile-icon"});o&&i.append(o);const s=l("div",{class:"rui-tile-body"});s.append(l("div",{class:"rui-tile-label"},[f(e.label)]));const c=f(e.value);c&&s.append(l("div",{class:"rui-tile-value"},[c]));const u=f(e.description);return u&&s.append(l("div",{class:"rui-tile-description"},[u])),i.append(s),a&&(i.onclick=()=>r.invoke(e.onClick)),i}},kn={name:"Notification",description:"Inline notification card with title, message, time, optional avatar, and dismiss/action buttons. Use inside notification panels, inboxes, or activity drawers — for top-of-page announcements prefer `Banner`.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"time",type:"string",optional:!0,description:"Relative or absolute timestamp"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"],description:"Avatar URL (alternative to `icon`)"},{name:"tone",type:"string",optional:!0,enum:Le},{name:"unread",type:"boolean",optional:!0,description:"Highlights the card with an accent"},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=A(e.unread),n=l("article",{class:"rui-notification","data-tone":f(e.tone,"default"),"data-unread":a?"true":"false"}),i=f(e.avatarSrc),o=l("div",{class:"rui-notification-visual"});if(i)o.append(ut(i,f(e.title),"md"));else{const g=j(f(e.icon,"bell"),{className:"rui-notification-icon"});g&&o.append(g)}n.append(o);const s=l("div",{class:"rui-notification-body"}),c=l("header",{class:"rui-notification-head"}),u=l("span",{class:"rui-notification-title-wrap"});a&&u.append(l("span",{class:"rui-notification-unread-dot","aria-label":"Unread"})),u.append(l("span",{class:"rui-notification-title"},[f(e.title)])),c.append(u);const p=f(e.time);p&&c.append(l("span",{class:"rui-notification-time"},[p])),s.append(c);const d=f(e.message);d&&s.append(l("p",{class:"rui-notification-message"},[d]));const m=We(e.actions,r);return m&&(m.classList.add("rui-notification-actions"),s.append(m)),n.append(s),n}},su={name:"PersonChip",description:'Inline avatar + name + optional role/meta pill. Use anywhere a person needs to be referenced compactly: table cells, list rows, comments, kanban cards, sidebar footers. Pair multiple chips with `Stack(direction="row", wrap=true)` for assignee lists.',props:[{name:"name",type:"string"},{name:"role",type:"string",optional:!0,description:"Sub-line below the name (role, email, handle, …)"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const a=typeof e.onClick=="function",n=a?"button":"div",i=f(e.size,"md"),o=i==="lg"?"lg":i==="sm"?"sm":"md",s=l(n,{type:a?"button":null,class:"rui-person-chip","data-size":i}),c=l("span",{class:"rui-person-chip-avatar"});c.append(ut(f(e.avatarSrc),f(e.name),o));const u=f(e.status);u&&c.append(l("span",{class:"rui-person-chip-status","data-status":u})),s.append(c);const p=l("div",{class:"rui-person-chip-meta"});p.append(l("span",{class:"rui-person-chip-name"},[f(e.name)]));const d=f(e.role);return d&&p.append(l("span",{class:"rui-person-chip-role"},[d])),s.append(p),a&&(s.onclick=()=>r.invoke(e.onClick)),s}},Sn=["left","center","right"],lu={name:"Col",description:'Single column inside a Table or DataGrid. Use `align` for per-column text alignment, `format` for cell rendering (`text|number|currency|date`). `values` may be plain values OR an array of component nodes — e.g. `Col("Status", rows.map(r => Badge(r.status)))` or `Col("Actions", rows.map(r => Button("Edit")))` — each component renders directly in its cell. Pass `render: (value, index) => …` for the same effect when you prefer to keep `values` as the raw row data (return a component, string, or array). Pass `onClick: (value, index) => …` to make the whole cell clickable (pointer + keyboard). `sortable` and `filterable` only take effect inside `DataGrid` (Table ignores them).',props:[{name:"header",type:"string"},{name:"values",type:"any[]",description:"Column values. Plain values are formatted as text; component nodes (e.g. `rows.map(r => Badge(r.status))`) render directly. You can also pass the full row array and map each cell with `render`."},{name:"format",type:"string",optional:!0,enum:["text","number","currency","date"]},{name:"align",type:"string",optional:!0,enum:Sn,description:"Per-column horizontal alignment"},{name:"sortable",type:"boolean",optional:!0,description:"DataGrid: enable click-to-sort on this column"},{name:"filterable",type:"boolean",optional:!0,description:"DataGrid: enable a per-column filter chip"},{name:"render",type:"callable",optional:!0,aliases:["cell"],description:"`(value, index) => Component | string | array` — map each cell to arbitrary content (buttons, badges, links)."},{name:"onClick",type:"callable",optional:!0,aliases:["onclick","cellClick"],description:"`(value, index) => void` — fired when a cell in this column is clicked or activated via keyboard."}],render:(t,e)=>{const r=l("div",{class:"rui-col"});return r.append(l("strong",{},[f(e.header)])),r}},cu={name:"Table",description:'Tabular data view. Children must be Col components. `density="compact"` tightens row padding for dense data, `striped=true` zebra-stripes the rows, and `sticky=true` pins the header row when the table scrolls. The empty-state row uses `emptyLabel` when set.',props:[{name:"columns",type:"Col[]"},{name:"caption",type:"string",optional:!0,aliases:["title"]},{name:"density",type:"string",optional:!0,enum:["comfortable","compact"],description:"Row padding (default `comfortable`)"},{name:"striped",type:"boolean",optional:!0,description:"Zebra-stripe alternating rows"},{name:"sticky",type:"boolean",optional:!0,description:"Pin the header row when the table scrolls"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when the table has no rows (default `No data`)"}],render:(t,e,r)=>{const a=$(e.columns),n=f(e.density,"comfortable"),i=A(e.striped),o=A(e.sticky),s=l("div",{class:"rui-table-wrapper","data-density":n,"data-striped":i?"true":"false","data-sticky":o?"true":"false"}),c=l("table",{class:"rui-table"}),u=f(e.caption);u&&c.append(l("caption",{class:"rui-table-caption"},[u]));const p=a.map(w=>{const k=f(w.args?.[3],"");return Sn.includes(k)?k:""}),d=l("thead"),m=l("tr");for(let w=0;w<a.length;w+=1){const k=a[w],T=l("th",{"data-align":p[w]||null},[f(k.args?.[0])]);m.append(T)}d.append(m),c.append(d);const g=l("tbody"),b=a.map(w=>$(w.args?.[1])),h=a.map(w=>f(w.args?.[2],"text")),v=a.map(w=>w.args?.[6]),y=a.map(w=>w.args?.[7]),x=Math.max(0,...b.map(w=>w.length));for(let w=0;w<x;w+=1){const k=l("tr");b.forEach((T,S)=>{const C=h[S]??"text",N=p[S],I=l("td",{"data-format":C,"data-align":N||null});hr(I,{format:C,render:v[S],onClick:y[S]},T[w],w,r,bu),k.append(I)}),g.append(k)}if(x===0){const w=l("tr"),k=f(e.emptyLabel,"No data");w.append(l("td",{colspan:String(a.length||1),class:"rui-table-empty"},[k])),g.append(w)}return c.append(g),s.append(c),s}},uu={name:"ListItem",description:"Single list item with optional title and description.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0,aliases:["meta"]},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name"}],render:(t,e)=>{const r=l("li",{class:"rui-list-item"}),a=j(e.icon,{className:"rui-list-icon"});a&&r.append(a);const n=l("div",{class:"rui-list-text"});n.append(l("div",{class:"rui-list-title"},[f(e.title)]));const i=f(e.description);return i&&n.append(l("div",{class:"rui-list-description"},[i])),r.append(n),r}},du={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=A(e.ordered)?"ol":"ul",n=l(a,{class:"rui-list"});for(const i of $(e.items))n.append(r.renderNode(i));return n}},pu={name:"StatCard",description:"Single KPI card with label, value, optional delta, optional icon, and optional inline sparkline (`spark=[…numbers]`). Use inside `Stats` for a uniform KPI strip.",props:[{name:"label",type:"string"},{name:"value",type:"string"},{name:"trend",type:"string",optional:!0,enum:["up","down","flat"]},{name:"delta",type:"string",optional:!0,description:"Change vs previous period"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a chip beside the label"},{name:"spark",type:"number[]",optional:!0,description:"Optional inline sparkline values"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]}],render:(t,e)=>{const r=f(e.tone,"default"),a=l("div",{class:"rui-stat-card","data-tone":r}),n=l("div",{class:"rui-stat-label-row"}),i=f(e.label),o=f(e.icon)||bn(i)||"",s=j(o,{className:"rui-stat-icon"});s&&n.append(s),n.append(l("div",{class:"rui-stat-label"},[i])),a.append(n),a.append(l("div",{class:"rui-stat-value"},[f(e.value)]));const c=f(e.delta),u=f(e.trend);(c||u)&&a.append(l("div",{class:"rui-stat-trend","data-trend":u||"flat"},[c||hu(u)]));const p=$(e.spark).map(d=>E(d));if(p.length>1){const d=l("div",{class:"rui-stat-spark"});d.append(Cr(p,r==="default"?"primary":r)),a.append(d)}return a}},mu={name:"Sparkline",description:"Tiny inline trend chart for KPIs, table cells, and dashboards. Renders an SVG line with a soft fill — use anywhere you would otherwise reach for `LineChart` but a single value series should stay inline with surrounding text.",props:[{name:"values",type:"number[]"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]}],render:(t,e)=>{const r=f(e.tone,"primary"),a=$(e.values).map(i=>E(i)),n=l("span",{class:"rui-sparkline-wrap"});return n.append(Cr(a,r)),n}},fu={name:"TreeNode",description:"Single node in a Tree view. When `children` is provided the node renders as an expandable branch with a chevron; otherwise it renders as a leaf. `onClick` fires on click. Use `active=true` to highlight the current selection.",props:[{name:"label",type:"string"},{name:"children",type:"TreeNode[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon shown before the label"},{name:"expanded",type:"boolean",optional:!0,description:"Whether the branch is open by default"},{name:"active",type:"boolean",optional:!0,aliases:["selected"],description:"Highlights the row as the current selection"},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable fired when the row is clicked"}],render:(t,e,r)=>{const a=$(e.children),n=a.length>0,i=A(e.expanded),o=A(e.active),s=typeof e.onClick=="function",c=l(s?"button":"div",{type:s?"button":null,class:"rui-tree-node-row",role:"treeitem","data-active":o?"true":"false","aria-expanded":n?i?"true":"false":null});if(n){const b=j("chevron-right",{className:"rui-tree-node-chevron"});b&&c.append(b)}else c.append(l("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const u=j(e.icon,{className:"rui-tree-node-icon"});u&&c.append(u),c.append(l("span",{class:"rui-tree-node-label"},[f(e.label)]));const p=f(e.badge);if(p&&c.append(l("span",{class:"rui-tree-node-badge"},[p])),s&&(c.onclick=()=>r.invoke(e.onClick)),!n)return c;const d=l("details",{class:"rui-tree-node"});i&&d.setAttribute("open","");const m=l("summary",{class:"rui-tree-node-summary"});m.append(c),s&&(m.onclick=b=>{b.target?.closest(".rui-tree-node-chevron")||b.preventDefault()}),d.append(m);const g=l("div",{class:"rui-tree-node-children",role:"group"});for(const b of a)g.append(r.renderNode(b));return d.append(g),d}},gu={name:"Tree",description:"Hierarchical tree view. Children must be TreeNode entries. Use for file browsers, nested navigation, category pickers, and any parent/child structure with arbitrary depth.",props:[{name:"items",type:"TreeNode[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-tree",role:"tree"});for(const n of $(e.items))a.append(r.renderNode(n));return a}};function hu(t){return t==="up"?"▲":t==="down"?"▼":"—"}function bu(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():f(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):f(t);case"date":try{const r=new Date(f(t));return Number.isNaN(r.getTime())?f(t):r.toLocaleDateString()}catch{return f(t)}default:return f(t)}}const Ar=["var(--rui-chart-1, #6366f1)","var(--rui-chart-2, #10b981)","var(--rui-chart-3, #f59e0b)","var(--rui-chart-4, #ef4444)","var(--rui-chart-5, #06b6d4)","var(--rui-chart-6, #8b5cf6)"],at=t=>Ar[t%Ar.length]??Ar[0],vu={name:"Series",description:"Named data series for charts. Used inside BarChart, LineChart, PieChart.",props:[{name:"name",type:"string"},{name:"values",type:"number[]"}],render:(t,e)=>l("span",{class:"rui-series","data-name":f(e.name)})},$n=t=>t.map((e,r)=>{const a=e,n=f(a.args?.[0],`Series ${r+1}`),i=$(a.args?.[1]).map(o=>E(o));return{name:n,values:i}}),yu={name:"BarChart",description:"Vertical bar chart. `labels` define the x-axis, `series` define grouped bars.",props:[{name:"labels",type:"string[]"},{name:"series",type:"Series[]"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=$(e.labels).map(y=>f(y)),a=$n($(e.series)),n=l("div",{class:"rui-chart rui-bar-chart"});f(e.title)&&n.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const i=Math.max(1,...a.flatMap(y=>y.values)),o=640,s=240,c=An(r,o-40-12),u={left:40,right:12,top:12,bottom:c.bottomPadding},p=o-u.left-u.right,d=s-u.top-u.bottom,m=Tr(o,s);Mn(m,u,p,d,i);const g=r.length,b=p/Math.max(g,1),h=a.length,v=b*.7/Math.max(h,1);return a.forEach((y,x)=>{y.values.forEach((w,k)=>{const T=w/i*d,S=u.left+k*b+b*.15+x*v,C=u.top+d-T,N=ve("rect",{x:String(S),y:String(C),width:String(Math.max(v-2,1)),height:String(T),fill:at(x),rx:"2"});N.append(ve("title",{},[`${y.name}: ${w}`])),m.append(N)})}),Tn(m,r,u,p,d,c,y=>u.left+(y+.5)*b),n.append(m),a.length>0&&n.append(Mr(a)),n}},xu={name:"LineChart",description:'Line chart. `labels` define the x-axis, each Series is a line. As a shortcut you can pass `data=[{x: "Jan", revenue: 12, signups: 4}, …]` and the labels + series will be derived automatically (one line per non-`x` key). Use `data` when the dataset is already row-shaped; use `series` when you have explicit Series objects.',props:[{name:"labels",type:"string[]",optional:!0},{name:"series",type:"Series[]",optional:!0},{name:"data",type:"{x: string, [key: string]: number}[]",optional:!0,description:"Row-shaped data — labels and series are auto-derived"},{name:"title",type:"string",optional:!0},{name:"filled",type:"boolean",optional:!0,description:"Fill the area beneath each line (area-chart style)"},{name:"stacked",type:"boolean",optional:!0,description:"Stack series when filled=true"}],render:(t,e)=>{let r=$(e.labels).map(C=>f(C)),a=$n($(e.series));const n=$(e.data);if(n.length>0&&(r.length===0||a.length===0)){const C=[],N=new Map;for(const I of n){const L=I;if(!(!L||typeof L!="object")){C.push(f(L.x??L.label??""));for(const[D,q]of Object.entries(L)){if(D==="x"||D==="label")continue;const O=E(q);Number.isNaN(O)||(N.has(D)||N.set(D,[]),N.get(D).push(O))}}}r.length===0&&(r=C),a.length===0&&(a=[...N.entries()].map(([I,L])=>({name:I,values:L})))}const i=e.filled===!0,o=e.stacked===!0,s=Math.max(r.length,...a.map(C=>C.values.length),1),c=a.map(()=>Array(s).fill(0));if(i&&o)for(let C=0;C<s;C+=1){let N=0;a.forEach((I,L)=>{N+=I.values[C]??0,c[L][C]=N})}const u=l("div",{class:"rui-chart rui-line-chart","data-filled":i?"true":"false"});f(e.title)&&u.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const p=i&&o?c.flat():a.flatMap(C=>C.values),d=Math.max(1,...p),m=i&&o?0:Math.min(0,...p),g=640,b=240,h=An(r,g-40-12),v={left:40,right:12,top:12,bottom:h.bottomPadding},y=g-v.left-v.right,x=b-v.top-v.bottom,w=Tr(g,b);Mn(w,v,y,x,d,m);const k=Math.max(r.length-1,1),T=y/k,S=C=>v.left+C*(y/Math.max(s-1,1));return a.forEach((C,N)=>{const I=i&&o?c[N]:C.values,L=i&&o&&N>0?c[N-1]:null,D=I.map((O,U)=>{const J=S(U),Z=v.top+x-(O-m)/(d-m||1)*x;return[J,Z]});if(i&&D.length>0){let O=D.map(([U,J],Z)=>`${Z===0?"M":"L"}${U.toFixed(1)},${J.toFixed(1)}`).join(" ");if(L){const U=L.map((J,Z)=>{const me=S(Z),$e=v.top+x-(J-m)/(d-m||1)*x;return[me,$e]});O+=" "+U.slice().reverse().map(([J,Z])=>`L${J.toFixed(1)},${Z.toFixed(1)}`).join(" ")+" Z"}else{const U=D[0],J=D[D.length-1];O+=` L${J[0].toFixed(1)},${(v.top+x).toFixed(1)} L${U[0].toFixed(1)},${(v.top+x).toFixed(1)} Z`}w.append(ve("path",{d:O,fill:at(N),"fill-opacity":"0.2",stroke:"none"}))}const q=D.map(([O,U],J)=>`${J===0?"M":"L"}${O.toFixed(1)},${U.toFixed(1)}`).join(" ");w.append(ve("path",{d:q,fill:"none",stroke:at(N),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),C.values.length<=30&&D.forEach(([O,U])=>{w.append(ve("circle",{cx:String(O),cy:String(U),r:"3",fill:at(N)}))})}),Tn(w,r,v,y,x,h,C=>v.left+C*T),u.append(w),a.length>0&&u.append(Mr(a)),u}},wu={name:"PieChart",description:'Pie / Donut chart. Each segment maps to a label/value pair. Numeric labels are rendered on every segment by default — set `showValues: false` to hide them, or `valueFormat: "percent"` to show the share instead of the raw value.',props:[{name:"labels",type:"string[]"},{name:"values",type:"number[]"},{name:"title",type:"string",optional:!0},{name:"showValues",type:"boolean",optional:!0,description:"Render numeric labels on each slice (default true)"},{name:"valueFormat",type:"string",optional:!0,enum:["value","percent","both"],description:'How to format the on-segment label (default "value")'}],render:(t,e)=>{const r=$(e.labels).map(h=>f(h)),a=$(e.values).map(h=>E(h)),n=e.showValues==null?!0:A(e.showValues),i=f(e.valueFormat,"value").toLowerCase(),o=i==="percent"?"percent":i==="both"?"both":"value",s=l("div",{class:"rui-chart rui-pie-chart"});f(e.title)&&s.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const c=a.reduce((h,v)=>h+(v>0?v:0),0)||1,u=Tr(240,240),p=120,d=120,m=90,g=.05;let b=-Math.PI/2;return a.forEach((h,v)=>{const y=h>0?h:0,x=y/c,w=x*Math.PI*2,k=b+w,T=w>Math.PI?1:0,S=p+m*Math.cos(b),C=d+m*Math.sin(b),N=p+m*Math.cos(k),I=d+m*Math.sin(k),L=`M${p},${d} L${S},${C} A${m},${m} 0 ${T} 1 ${N},${I} Z`,D=ve("path",{d:L,fill:at(v),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});if(D.append(ve("title",{},[`${r[v]??""}: ${h} (${(x*100).toFixed(1)}%)`])),u.append(D),n&&y>0&&x>=g){const q=b+w/2,O=m*.62,U=p+O*Math.cos(q),J=d+O*Math.sin(q),Z=ku(h,x,o),me=ve("text",{x:String(U),y:String(J),class:"rui-pie-chart-value","text-anchor":"middle","dominant-baseline":"central","paint-order":"stroke",stroke:"rgba(15, 23, 42, 0.55)","stroke-width":"3","stroke-linejoin":"round",fill:"#fff"},[Z]);u.append(me)}b=k}),s.append(u),s.append(Mr(r.map((h,v)=>({name:h,values:[a[v]??0]})))),s}};function ku(t,e,r){const a=`${Math.round(e*100)}%`,n=Su(t);return r==="percent"?a:r==="both"?`${n} (${a})`:n}function Su(t){if(!Number.isFinite(t))return String(t);const e=Math.abs(t);return e>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:e>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}k`:Number.isInteger(t)?String(t):t.toFixed(1)}const $u=7,Cn=12;function An(t,e){if(t.length===0)return{step:1,rotated:!1,maxChars:32,bottomPadding:32};const r=e/Math.max(t.length,1),a=t.reduce((o,s)=>Math.max(o,s.length),0);if(a*$u+4<=r)return{step:1,rotated:!1,maxChars:a,bottomPadding:32};const n=r<Cn?Math.max(1,Math.ceil(Cn/r)):1,i=Math.min(a,14);return{step:n,rotated:!0,maxChars:i,bottomPadding:60}}function Cu(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function Tn(t,e,r,a,n,i,o){const s=r.top+n+(i.rotated?14:18);e.forEach((c,u)=>{if(u%i.step!==0)return;const p=o(u),d=Cu(c,i.maxChars),m={x:String(p),y:String(s),class:"rui-chart-label","text-anchor":i.rotated?"end":"middle"};i.rotated&&(m.transform=`rotate(-45, ${p}, ${s})`);const g=ve("text",m,[d]);d!==c&&g.append(ve("title",{},[c])),t.append(g)})}function Tr(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("viewBox",`0 0 ${t} ${e}`),r.setAttribute("class","rui-chart-svg"),r.setAttribute("role","img"),r}function ve(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[n,i]of Object.entries(e))a.setAttribute(n,i);if(r)for(const n of r)a.append(typeof n=="string"?document.createTextNode(n):n);return a}function Mn(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const c=s/4,u=e.top+a-c*a;t.append(ve("line",{x1:String(e.left),x2:String(e.left+r),y1:String(u),y2:String(u),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ve("text",{x:String(e.left-6),y:String(u+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((i+(n-i)*c)*10)/10)]))}}function Mr(t){const e=l("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const n=l("span",{class:"rui-chart-legend-item"});n.append(l("span",{class:"rui-chart-legend-swatch",style:`background:${at(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const Au={name:"SectionBlock",description:"Titled chat block with a description and child content.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"description",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("section",{class:"rui-section-block"});a.append(l("h3",{class:"rui-section-block-title"},[f(e.title)]));const n=f(e.description);n&&a.append(l("p",{class:"rui-section-block-description"},[n]));for(const i of $(e.children))a.append(r.renderNode(i));return a}},Tu={name:"ListBlock",description:"Chat-styled list with bullets, useful for steps or summaries.",props:[{name:"items",type:"string[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e)=>{const r=A(e.ordered)?"ol":"ul",a=l(r,{class:"rui-list-block"});for(const n of $(e.items))a.append(l("li",{},[f(n)]));return a}},Mu={name:"FollowUpBlock",description:'Suggested follow-up prompts shown as buttons. Each item dispatches its label as an assistant message (equivalent to `emit "assistant-message" { message }`).',props:[{name:"items",type:"FollowUpItem[]",description:"Array of FollowUpItem(label, message?), {label, message} objects, or plain strings"},{name:"title",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-follow-up"}),n=f(e.title,"You can also ask");n&&a.append(l("div",{class:"rui-follow-up-title"},[n]));const i=l("div",{class:"rui-follow-up-list"});for(const o of $(e.items))i.append(Nu(o,r));return a.append(i),a}},Nu=(t,e)=>{const{label:r,message:a}=Pu(t),n=l("button",{class:"rui-follow-up-button",type:"button"},[r]);return n.onclick=()=>{e.sendToAssistant(a)},n},Pu=t=>{if(typeof t=="string")return{label:t,message:t};if(t&&typeof t=="object"){const r=t;if(r.__kind==="Component"&&Array.isArray(r.args)){const i=f(r.args[0]),o=f(r.args[1],i);return{label:i,message:o}}const a=f(r.label),n=f(r.message,a);return{label:a,message:n}}const e=f(t);return{label:e,message:e}},Iu={name:"FollowUpItem",description:"Single follow-up item.",props:[{name:"label",type:"string"},{name:"message",type:"string",optional:!0,description:"Defaults to label"}],render:(t,e,r)=>{const a=f(e.label),n=f(e.message,a),i=l("button",{class:"rui-follow-up-button",type:"button"},[a]);return i.onclick=()=>{r.sendToAssistant(n)},i}},Eu={name:"ActionLink",description:"Inline link that runs an action when clicked instead of navigating.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",aliases:["action","onclick"]}],render:(t,e,r)=>{const a=l("a",{class:"rui-action-link",href:"#",role:"button"},[f(e.label)]);return a.onclick=n=>{n.preventDefault(),r.invoke(e.onClick)},a}},Nn=["xs","sm","md","lg","xl"],Pn={name:"Avatar",description:'User avatar. Shows the image at `src`. When `src` is missing, falls back to a deterministic DiceBear illustration seeded by `name` (pass `fallback="initials"` to render two-letter initials instead). If the image errors at runtime the avatar gracefully degrades to initials.',props:[{name:"name",type:"string",description:"Used for alt text + initials fallback"},{name:"src",type:"string",optional:!0,description:"Image URL"},{name:"size",type:"string",optional:!0,enum:Nn},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"fallback",type:"string",optional:!0,enum:["initials","dicebear"],description:"How to render when `src` is missing (default: dicebear illustration; pass `initials` for the two-letter pill)"}],render:(t,e)=>{const r=f(e.size,"md"),a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=f(e.name),i=f(e.fallback,"dicebear"),o=ie(e.src),s=!o&&i==="dicebear"&&n?ie(Vl(n)):"",c=o||s;if(c){const p=l("img",{src:c,alt:n,loading:"lazy"});p.onerror=d=>{const m=d;(m.currentTarget??m.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[dt(n)]))},a.append(p)}else a.append(l("span",{class:"rui-avatar-fallback"},[dt(n)]));const u=f(e.status);return u&&a.append(l("span",{class:"rui-avatar-status","data-status":u})),a}},Lu={name:"AvatarGroup",description:"Stack of overlapping avatars with a `+N` chip when the list overflows. Pass either Avatar(...) nodes or plain {name, src} objects.",props:[{name:"items",type:"Avatar[]",description:"Avatar(...) nodes or {name, src} objects"},{name:"max",type:"number",optional:!0,description:"Maximum avatars to show (default 4)"},{name:"size",type:"string",optional:!0,enum:Nn}],render:(t,e,r)=>{const a=$(e.items),n=Math.max(1,Math.floor(Number(e.max??4))),i=f(e.size,"md"),o=a.slice(0,n),s=a.length-o.length,c=l("div",{class:"rui-avatar-group","data-size":i});for(const u of o){if(u&&typeof u=="object"&&u.__kind==="Component"){c.append(r.renderNode(u));continue}const p=u,d=typeof p=="string"?p:f((p??{}).name),m=typeof p=="string"?"":f((p??{}).src);c.append(Pn.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:d,src:m,size:i},r))}return s>0&&c.append(l("span",{class:"rui-avatar rui-avatar-overflow","data-size":i},[l("span",{class:"rui-avatar-fallback"},[`+${s}`])])),c}},Ru={name:"Progress",description:"Linear progress bar. `value` is clamped between 0 and `max` (default 100). `indeterminate=true` renders a looping animation when the total is unknown. Provide `segments` to render a segmented progress strip (steps in an onboarding flow), or `buffered` for a secondary buffer indicator (downloads, video buffering).",props:[{name:"value",type:"number",optional:!0,description:"Current progress; ignored when indeterminate"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"label",type:"string",optional:!0,description:"Shown above the bar"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"indeterminate",type:"boolean",optional:!0},{name:"showValue",type:"boolean",optional:!0,description:"Show the numeric value on the right"},{name:"segments",type:"number",optional:!0,description:"Render N equal segments (filled by current step)"},{name:"buffered",type:"number",optional:!0,description:"Secondary value (0..max) drawn behind the bar"}],render:(t,e)=>{const r=Math.max(1,E(e.max,100)),a=A(e.indeterminate),n=Math.max(0,Math.min(r,E(e.value,0))),i=Math.round(n/r*100),o=Math.max(0,Math.floor(E(e.segments,0))),s=e.buffered!=null?Math.max(0,Math.min(r,E(e.buffered,0))):null,c=l("div",{class:"rui-progress","data-tone":f(e.tone,"primary")}),u=f(e.label),p=A(e.showValue);if(u||p){const m=l("div",{class:"rui-progress-head"});if(m.append(l("span",{class:"rui-progress-label"},[u])),p&&!a){const g=o>0?`${Math.min(o,Math.round(n/r*o))} / ${o}`:`${i}%`;m.append(l("span",{class:"rui-progress-value"},[g]))}c.append(m)}if(o>0&&!a){const m=l("div",{class:"rui-progress-segments",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(o),"aria-valuenow":String(Math.min(o,Math.round(n/r*o)))}),g=Math.min(o,Math.round(n/r*o));for(let b=0;b<o;b+=1)m.append(l("span",{class:"rui-progress-segment","data-filled":b<g?"true":"false"}));return c.append(m),c}const d=l("div",{class:"rui-progress-track",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(r),"aria-valuenow":a?null:String(n),"data-indeterminate":a?"true":"false"});if(s!==null){const m=Math.round(s/r*100);d.append(l("div",{class:"rui-progress-buffer",style:`width:${m}%`,"aria-hidden":"true"}))}return d.append(l("div",{class:"rui-progress-bar",style:a?"":`width:${i}%`})),c.append(d),c}},zu={name:"Switch",description:"Compact on/off toggle. Pass a `$variable` as `value` for two-way binding — prefer Switch over Checkbox when the control represents a setting. `onChange(checked)` fires with the new boolean.",props:[{name:"id",type:"string"},{name:"label",type:"string",optional:!0},{name:"value",type:"boolean",optional:!0,aliases:["checked"],description:"Bound value (typically $variable)"},{name:"description",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new boolean value"}],render:(t,e,r)=>{const a=f(e.id),n=l("label",{class:"rui-switch",for:a,"data-disabled":A(e.disabled)?"true":"false"}),i=A(e.value),o=l("input",{type:"checkbox",id:a,name:a,class:"rui-switch-input",role:"switch",checked:i?"":null,disabled:A(e.disabled)?"":null});o.checked=i;const s=l("span",{class:"rui-switch-track"},[l("span",{class:"rui-switch-thumb"})]),c=t.argMeta?.[2]?.stateRef;c&&r.bindState(o,c,{event:"change",getValue:d=>d.checked}),e.onChange!=null&&o.addEventListener("change",d=>{r.invoke(e.onChange,d.currentTarget.checked)});const u=f(e.label),p=f(e.description);if(n.append(o,s),u||p){const d=l("span",{class:"rui-switch-meta"});u&&d.append(l("span",{class:"rui-switch-label"},[u])),p&&d.append(l("span",{class:"rui-switch-description"},[p])),n.append(d)}return n}},Du={name:"ToggleGroup",description:"Group of mutually-exclusive Toggle-style buttons (single-select). Items are `[value, label]` arrays, `{value, label, icon?}` objects, or plain strings (used for both value and label). Pass a `$variable` as `value` for two-way binding. `onChange(value)` fires with the newly-selected value.",props:[{name:"id",type:"string"},{name:"items",type:"any[]"},{name:"value",type:"any",optional:!0},{name:"variant",type:"string",optional:!0,enum:["default","outline"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{const a=f(e.value),n=f(e.variant,"outline"),i=f(e.size,"md"),o=l("div",{class:"rui-toggle-group",role:"radiogroup","data-variant":n,"data-size":i}),s=t.argMeta?.[2]?.stateRef;for(const c of $(e.items)){const{value:u,label:p,icon:d}=ju(c),m=u===a,g=l("button",{type:"button",class:"rui-toggle",role:"radio","aria-checked":m?"true":"false","data-variant":n,"data-size":i,"data-state":m?"on":"off","data-value":u}),b=j(d,{className:"rui-toggle-icon"});b&&g.append(b),g.append(l("span",{class:"rui-toggle-label"},[p])),g.onclick=()=>{s&&r.setState(s,u),r.invoke(e.onChange,u)},o.append(g)}return o}};function ju(t){if(typeof t=="string")return{value:t,label:t,icon:""};if(Array.isArray(t))return{value:f(t[0]),label:f(t[1],f(t[0])),icon:f(t[2])};if(t&&typeof t=="object"){const e=t,r=f(e.value);return{value:r,label:f(e.label,r),icon:f(e.icon)}}return{value:"",label:"",icon:""}}const Bu={name:"Tooltip",description:"Wraps a trigger node and shows `label` text when the user hovers or focuses it. Pure CSS — no JS needed. The tooltip hides on click/touch (so it does not stay stuck on touch devices) and supports `top|bottom|left|right` placement. Use for short hints (≤6 words); reach for HoverCard when you need rich content.",props:[{name:"label",type:"string"},{name:"trigger",type:"Node",aliases:["children"]},{name:"side",type:"string",optional:!0,enum:["top","bottom","left","right"],aliases:["placement"]}],render:(t,e,r)=>{const a=f(e.side,"top"),n=l("span",{class:"rui-tooltip","data-side":a,tabindex:"0"});n.append(l("span",{class:"rui-tooltip-trigger"},[r.renderNode(e.trigger)]));const i=l("span",{class:"rui-tooltip-content",role:"tooltip"},[f(e.label)]);return i.append(l("span",{class:"rui-tooltip-arrow","aria-hidden":"true"})),n.append(i),n.addEventListener("mousedown",()=>{requestAnimationFrame(()=>{(document.activeElement===n||n.contains(document.activeElement))&&document.activeElement?.blur?.()})}),n}},Ou={name:"HoverCard",description:"Wraps a trigger node and reveals a card with rich content on hover/focus. Use for previewing a referenced item (profile, link target, definition).",props:[{name:"trigger",type:"Node"},{name:"content",type:"Node[]",aliases:["children"]},{name:"side",type:"string",optional:!0,enum:["top","bottom","left","right"],aliases:["placement"]},{name:"open",type:"boolean",optional:!0,description:"Force the card open (otherwise reveal on hover/focus)"}],render:(t,e,r)=>{const a=l("span",{class:"rui-hover-card","data-side":f(e.side,"bottom"),"data-open":A(e.open)?"true":null,tabindex:"0"});a.append(l("span",{class:"rui-hover-card-trigger"},[r.renderNode(e.trigger)]));const n=l("span",{class:"rui-hover-card-content",role:"dialog"});for(const i of $(e.content))n.append(r.renderNode(i));return a.append(n),a}},Nr={star:{full:"star",half:"star-half-stroke",empty:"regular:star"},heart:{full:"heart",half:"heart",empty:"regular:heart"},thumb:{full:"thumbs-up",half:"thumbs-up",empty:"regular:thumbs-up"},fire:{full:"fire",half:"fire",empty:"regular:fire"},bolt:{full:"bolt",half:"bolt",empty:"regular:bolt"}},_u={name:"Rating",description:"Compact 0–5 star rating with optional numeric badge and review count. Use in product cards, testimonials, reviews, and KPI rows. Pass `interactive: true` (or an `onChange` handler) to let users pick a rating; bind `value: $rating` for two-way binding, or read the new value from `onChange: (v) => …`. With `halfStep: true` clicking the left half of a star sets a fractional value. `icon` swaps the glyph family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any custom Font Awesome name.",props:[{name:"value",type:"number",description:"0–max; can be a $variable when interactive"},{name:"max",type:"number",optional:!0,description:"Maximum number of stars (default 5)"},{name:"label",type:"string",optional:!0,description:'Inline text shown after the stars (e.g. "4.2 of 5")'},{name:"count",type:"number",optional:!0,description:"Review/voter count rendered in parentheses"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"interactive",type:"boolean",optional:!0,description:"Allow clicking a star to set the value"},{name:"readonly",type:"boolean",optional:!0,description:"Force read-only (overrides `interactive`)"},{name:"halfStep",type:"boolean",optional:!0,description:"Allow half-star resolution when interactive"},{name:"icon",type:"string",optional:!0,description:"Icon family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any FA name"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new rating when the user clicks a star (interactive mode)"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(E(e.max,5))),n=f(e.size,"md"),i=A(e.halfStep),o=t.argMeta?.[0]?.stateRef,s=(A(e.interactive)||e.onChange!=null)&&!A(e.readonly),u=s&&!o?r.useInstanceState("rating-value",E(e.value,0)):null,p=E(u?u.get():e.value,0),d=Math.max(0,Math.min(a,p)),m=Uu(f(e.icon)),g=l("div",{class:"rui-rating","data-size":n,"data-interactive":s?"true":"false","data-half-step":s&&i?"true":"false",role:"img","aria-label":`${d} of ${a}`}),b=l("span",{class:"rui-rating-stars"});for(let y=1;y<=a;y+=1){const x=Math.max(0,Math.min(1,d-(y-1))),w=x>=1?m.full:x>0?m.half:m.empty,k=Et(w).join(" "),T=l(s?"button":"span",{class:`rui-rating-star ${k}`.trim(),type:s?"button":null,"data-fill":x>=1?"full":x>0?"half":"empty","aria-label":s?`Rate ${y}`:null,"aria-hidden":s?null:"true"});if(s){const S=y,C=y-.5;T.onclick=N=>{const I=N,L=I.currentTarget??I.target;let D=S;if(i){const q=L.getBoundingClientRect();q.width>0&&I.clientX-q.left<q.width/2&&(D=C)}o&&r.setState(o,D),u&&u.set(D),Fu(L.closest(".rui-rating"),D,a,m),r.invoke(e.onChange,D)}}b.append(T)}g.append(b);const h=f(e.label);h&&g.append(l("span",{class:"rui-rating-label"},[h]));const v=e.count!=null?E(e.count,0):null;return v!==null&&v>0&&g.append(l("span",{class:"rui-rating-count"},[`(${v.toLocaleString()})`])),g}};function Fu(t,e,r,a){if(!t)return;t.querySelectorAll(".rui-rating-star").forEach((i,o)=>{const s=Math.max(0,Math.min(1,e-o)),c=s>=1?a.full:s>0?a.half:a.empty;i.setAttribute("data-fill",s>=1?"full":s>0?"half":"empty"),i.className=`rui-rating-star ${Et(c).join(" ")}`.trim()}),t.setAttribute("aria-label",`${Math.max(0,Math.min(r,e))} of ${r}`)}function Uu(t){const e=t.trim().toLowerCase();return e?Nr[e]?Nr[e]:{full:e,half:e,empty:`regular:${e}`}:Nr.star}const Hu={name:"ProgressRing",description:"Circular progress indicator. Use for KPIs, quotas, completion rings, and any metric better shown as a circle than a bar. Renders the value (or a custom label) inside the ring.",props:[{name:"value",type:"number",optional:!0,description:"Current value (ignored when indeterminate)"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"label",type:"string",optional:!0,description:'Text shown inside the ring (default "{percent}%")'},{name:"caption",type:"string",optional:!0,aliases:["description"],description:"Small caption rendered under the ring"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"indeterminate",type:"boolean",optional:!0}],render:(t,e)=>{const r=Math.max(1,E(e.max,100)),a=A(e.indeterminate),n=Math.max(0,Math.min(r,E(e.value,0))),i=Math.round(n/r*100),o=f(e.size,"md"),s=o==="lg"?120:o==="sm"?72:96,c=o==="lg"?10:o==="sm"?6:8,u=(s-c)/2,p=2*Math.PI*u,d=a?p*.65:p*(1-i/100),m=l("div",{class:"rui-progress-ring","data-tone":f(e.tone,"primary"),"data-size":o,"data-indeterminate":a?"true":"false"}),g=l("div",{class:"rui-progress-ring-wrap"}),b="http://www.w3.org/2000/svg",h=document.createElementNS(b,"svg");h.setAttribute("width",String(s)),h.setAttribute("height",String(s)),h.setAttribute("viewBox",`0 0 ${s} ${s}`),h.setAttribute("class","rui-progress-ring-svg");const v=document.createElementNS(b,"circle");v.setAttribute("class","rui-progress-ring-track"),v.setAttribute("cx",String(s/2)),v.setAttribute("cy",String(s/2)),v.setAttribute("r",String(u)),v.setAttribute("stroke-width",String(c)),v.setAttribute("fill","none"),h.appendChild(v);const y=document.createElementNS(b,"circle");y.setAttribute("class","rui-progress-ring-bar"),y.setAttribute("cx",String(s/2)),y.setAttribute("cy",String(s/2)),y.setAttribute("r",String(u)),y.setAttribute("stroke-width",String(c)),y.setAttribute("fill","none"),y.setAttribute("stroke-linecap","round"),y.setAttribute("stroke-dasharray",String(p)),y.setAttribute("stroke-dashoffset",String(d)),h.appendChild(y),g.append(h);const x=f(e.label,a?"…":`${i}%`),w=l("span",{class:"rui-progress-ring-value"}),k=j(x,{className:"rui-progress-ring-icon"});k&&Et(x).length>0?w.append(k):w.append(document.createTextNode(x)),g.append(w),m.append(g);const T=f(e.caption);return T&&m.append(l("span",{class:"rui-progress-ring-caption"},[T])),m}},Vu={name:"ChatBubble",description:'Single chat-style message bubble with author, time, and body. Use for conversation threads, agent transcripts, support chats, and any message-style UI. Set `from="me"` (or any non-empty author) for the active speaker — the bubble aligns to the right with a primary tint. `from="agent"` (default) renders as the canonical incoming bubble on the left.',props:[{name:"author",type:"string"},{name:"body",type:"string",aliases:["text","message"]},{name:"time",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"from",type:"string",optional:!0,enum:["agent","me","system"],aliases:["role"],description:"Lane (default agent)"},{name:"status",type:"string",optional:!0,enum:["sending","sent","delivered","read","error"]}],render:(t,e)=>{const r=f(e.from,"agent"),a=l("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&a.append(In(f(e.avatarSrc),f(e.author)));const n=l("div",{class:"rui-chat-bubble-bubble"}),i=l("header",{class:"rui-chat-bubble-head"});i.append(l("span",{class:"rui-chat-bubble-author"},[f(e.author)]));const o=f(e.time);o&&i.append(l("span",{class:"rui-chat-bubble-time"},[o])),n.append(i),n.append(l("p",{class:"rui-chat-bubble-body"},[f(e.body)]));const s=f(e.status);return s&&n.append(l("span",{class:"rui-chat-bubble-status","data-status":s},[s])),a.append(n),r==="me"&&a.append(In(f(e.avatarSrc),f(e.author))),a}};function In(t,e){const r=l("span",{class:"rui-chat-bubble-avatar"}),a=ie(t);return a?r.append(l("img",{src:a,alt:e,loading:"lazy"})):r.append(l("span",{class:"rui-chat-bubble-fallback"},[dt(e)])),r}const Wu={name:"Kbd",description:"Renders a keyboard shortcut chip (e.g. `Cmd+K`). Pass a single label, or multiple labels as an array to render a `key + key + …` combo.",props:[{name:"keys",type:"string | string[]"},{name:"size",type:"string",optional:!0,enum:["sm","md"]}],render:(t,e)=>{const r=f(e.size,"md"),a=l("span",{class:"rui-kbd-group","data-size":r});return(Array.isArray(e.keys)?e.keys:[e.keys]).forEach((i,o)=>{const s=f(i);s&&(o>0&&a.append(l("span",{class:"rui-kbd-sep"},["+"])),a.append(l("kbd",{class:"rui-kbd"},[s])))}),a}},qu={name:"Popover",description:"Click-triggered popup with arbitrary rich content. Use when HoverCard's hover trigger is too eager and Modal/Sheet is too heavy — perfect for filter panels, color pickers, share menus, and small settings flyouts. The trigger stays visible while the popover is open — clicking it again, clicking outside, pressing Escape, or clicking the built-in × button all close it.",props:[{name:"trigger",type:"Node",description:"Clickable trigger element (Button, Avatar, IconButton, …). The trigger remains visible while the popover is open."},{name:"content",type:"Node[]",aliases:["children"],description:"Body rendered inside the popover"},{name:"title",type:"string",optional:!0,description:"Optional bold heading rendered above the content"},{name:"side",type:"string",optional:!0,enum:["bottom","top","left","right"],aliases:["placement"],description:'Where the popover opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:["start","center","end"],description:'Alignment along the trigger edge (default "start")'},{name:"width",type:"string",optional:!0,description:'CSS width for the popover panel (default "280px")'},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the popover"}],render:(t,e,r)=>{const a=A(e.open),n=r.useInstanceState("open",a),i=n.get(),o=re(e.width,""),s=l("div",{class:"rui-popover","data-open":i?"true":"false","data-side":f(e.side,"bottom"),"data-align":f(e.align,"start")}),c=l("span",{class:"rui-popover-trigger","data-state":i?"open":"closed","aria-haspopup":"dialog","aria-expanded":i?"true":"false"});c.append(r.renderNode(e.trigger)),s.append(c);const u=l("div",{class:"rui-popover-content",role:"dialog",style:o?`width: ${o};`:null}),p=l("div",{class:"rui-popover-header"}),d=f(e.title);p.append(d?l("div",{class:"rui-popover-title"},[d]):l("span",{class:"rui-popover-title-spacer"}));const m=l("button",{type:"button",class:"rui-popover-close","aria-label":"Close popover"},["×"]);m.onclick=g=>{g.stopPropagation(),Bt(m,!1,n)},p.append(m),u.append(p);for(const g of $(e.content))u.append(r.renderNode(g));return s.append(u),c.onclick=g=>{g.stopPropagation();const b=g.currentTarget??g.target,h=!n.get(),v=Bt(b,h,n);h&&v&&En(v,n)},c.onkeydown=g=>{const b=g,h=b.currentTarget??b.target;if(b.key==="Enter"||b.key===" "){b.preventDefault();const v=!n.get(),y=Bt(h,v,n);v&&y&&En(y,n)}else b.key==="Escape"&&n.get()&&(b.preventDefault(),Bt(h,!1,n))},s}},Bt=(t,e,r)=>{r.set(e);const a=t.closest(".rui-popover");if(!a)return null;a.setAttribute("data-open",e?"true":"false");const n=a.querySelector(".rui-popover-trigger");return n?.setAttribute("aria-expanded",e?"true":"false"),n?.setAttribute("data-state",e?"open":"closed"),e||Ne(a),a},En=(t,e)=>{rt({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false");const r=t.querySelector(".rui-popover-trigger");r?.setAttribute("aria-expanded","false"),r?.setAttribute("data-state","closed")}})},Ku={name:"Toast",description:"Single transient notification card. Always shows a close (×) button that removes the toast from the DOM (and fires `onClose` if set). Pass `duration` (ms) to auto-dismiss, or `position` for a standalone one-off toast (the renderer will pin it to the viewport corner so you do not have to wrap a single notification in `Stack(...)`). Use `Toasts` for grouped stacks; prefer `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"],description:'Visual accent (default "default")'},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name (default picked from tone)"},{name:"duration",type:"number",optional:!0,description:"Auto-dismiss after N milliseconds (e.g. 4000). Omit to keep the toast until the user closes it."},{name:"action",type:"Button",optional:!0,description:"Optional inline `Button` action shown above the message"},{name:"onClose",type:"callable",optional:!0,description:"Callable invoked when the toast is dismissed (× button, auto-dismiss, or programmatic)"},{name:"position",type:"string",optional:!0,enum:["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],description:"Pin a standalone Toast to a viewport corner without wrapping it in `Stack(...)`"}],render:(t,e,r)=>{const a=f(e.tone,"default"),n=f(e.position),i=l("div",{class:n?"rui-toast rui-toast-standalone":"rui-toast",role:a==="danger"?"alert":"status","aria-live":a==="danger"?"assertive":"polite","data-tone":a,"data-position":n||null}),o=f(e.icon)||Gu(a),s=j(o,{className:"rui-toast-icon"});s&&i.append(s);const c=l("div",{class:"rui-toast-body"});c.append(l("div",{class:"rui-toast-title"},[f(e.title)]));const u=f(e.message);if(u&&c.append(l("div",{class:"rui-toast-message"},[u])),e.action){const x=l("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),c.append(x)}i.append(c);const p=r.useInstanceState("dismissed",!1),d=r.useInstanceState("timer",null),m=x=>{if(x){const w=x.closest(".rui-toast");if(w)return w}return i.isConnected?i:null},g=()=>{const x=d.get();x!==null&&(clearTimeout(x),d.set(null))},b=r.useInstanceState("removal-timer",null),h=x=>{if(p.get())return;p.set(!0),g();const w=m(x);if(!w)return;w.classList.add("is-dismissed");const k=setTimeout(()=>{b.set(null),w.remove()},180);b.set(k),r.registerDisposer(()=>{const T=b.get();T!==null&&(clearTimeout(T),b.set(null))},"exit-animation-timer"),r.invoke(e.onClose)},v=l("button",{type:"button",class:"rui-toast-close","aria-label":"Dismiss notification"},["×"]);v.onclick=x=>{x.stopPropagation(),h(x.currentTarget??x.target)},i.append(v);const y=E(e.duration,0);if(y>0&&d.get()===null&&!p.get()){const x=setTimeout(()=>{d.set(null),!p.get()&&i.isConnected&&h()},y);d.set(x),r.registerDisposer(()=>{const w=d.get();w!==null&&(clearTimeout(w),d.set(null))},"auto-dismiss-timer")}return p.get()?l("div",{class:"rui-toast-placeholder",hidden:""}):i}};function Gu(t){switch(t){case"success":return"circle-check";case"warning":return"triangle-exclamation";case"danger":return"circle-xmark";case"primary":return"bell";case"info":return"circle-info";default:return"circle-info"}}const Ln={name:"BreadcrumbItem",description:"Single item inside a Breadcrumb trail. Provide `href` for a link, omit it for the current/leaf page (rendered with emphasis).",props:[{name:"label",type:"string"},{name:"href",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"}],render:(t,e)=>{const r=l("li",{class:"rui-breadcrumb-item"}),a=f(e.label),n=f(e.href),i=n?tt(n):"",o=[],s=j(e.icon,{className:"rui-breadcrumb-icon"});if(s&&o.push(s),o.push(l("span",{class:"rui-breadcrumb-label"},[a])),i)r.append(l("a",{class:"rui-breadcrumb-link",href:i},o));else{r.setAttribute("aria-current","page");const c=l("span",{class:"rui-breadcrumb-current"});for(const u of o)u&&c.append(typeof u=="string"?document.createTextNode(u):u);r.append(c)}return r}},Yu={name:"Breadcrumb",description:"Trail of links showing the user's location. Children may be BreadcrumbItem(label, href?) nodes OR plain strings (the last string is treated as the current page).",props:[{name:"items",type:"BreadcrumbItem[] | string[]"},{name:"separator",type:"string",optional:!0,description:"Default `/`"}],render:(t,e,r)=>{const a=$(e.items),n=f(e.separator,"/"),i=l("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),o=l("ol",{class:"rui-breadcrumb-list"});return a.forEach((s,c)=>{if(c>0&&o.append(l("li",{class:"rui-breadcrumb-separator","aria-hidden":"true"},[n])),s&&typeof s=="object"&&s.__kind==="Component"){o.append(r.renderNode(s));return}const u=f(s),p=c===a.length-1;o.append(Ln.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:u,href:p?"":"#"},r))}),i.append(o),i}},Xu=[10,20,50,100],Ju={name:"Pagination",description:'Page navigator with Prev/Next, page numbers, and ellipses. Pass a `$variable` as `page` for two-way binding — clicking a page button sets that state to the new (1-indexed) value. Add `total` to render a "Showing N–M of T" summary, pass `$variable` as `perPage` to expose a per-page selector, or set `compact: true` to drop the page-number row for tight toolbars.',props:[{name:"page",type:"number",description:"Current page (1-indexed); typically a $variable"},{name:"totalPages",type:"number",aliases:["pages"]},{name:"siblings",type:"number",optional:!0,description:"Number of page links shown around the current page (default 1)"},{name:"total",type:"number",optional:!0,description:'Total record count — enables the "Showing N–M of T" summary'},{name:"perPage",type:"number",optional:!0,description:"Bind a `$variable` to expose a per-page selector"},{name:"perPageOptions",type:"number[]",optional:!0,description:"Override the per-page choices (default 10/20/50/100)"},{name:"compact",type:"boolean",optional:!0,description:"Hide page numbers — keep Prev / Next only"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(E(e.totalPages,1))),n=Math.max(1,Math.min(a,Math.floor(E(e.page,1)))),i=Math.max(0,Math.floor(E(e.siblings,1))),o=A(e.compact),s=t.argMeta?.[0]?.stateRef,c=l("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":o?"true":"false"}),u=h=>{if(!s)return;const v=Math.max(1,Math.min(a,h));v!==n&&r.setState(s,v)},p=e.total!=null?Math.max(0,Math.floor(E(e.total,0))):null,d=e.perPage!=null?Math.max(1,Math.floor(E(e.perPage,0))):null;if(p!==null&&d&&d>0){const h=p===0?0:(n-1)*d+1,v=Math.min(p,n*d);c.append(l("span",{class:"rui-pagination-summary"},[p===0?"No results":`Showing ${h.toLocaleString()}–${v.toLocaleString()} of ${p.toLocaleString()}`]))}else p!==null&&c.append(l("span",{class:"rui-pagination-summary"},[`${p.toLocaleString()} result${p===1?"":"s"}`]));const m=l("div",{class:"rui-pagination-buttons"}),g=(h,v,y={})=>{if(y.ellipsis)return l("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[h]);const x=l("button",{type:"button",class:"rui-pagination-button","data-active":y.active?"true":"false","aria-current":y.active?"page":null,"aria-label":y.ariaLabel??null,disabled:y.disabled?"":null},[h]);return!y.disabled&&!y.active&&(x.onclick=()=>u(v)),x};if(m.append(g("‹",n-1,{disabled:n<=1,ariaLabel:"Previous page"})),o)m.append(l("span",{class:"rui-pagination-current"},[`${n} / ${a}`]));else{const h=Zu(n,a,i);for(const v of h)v==="…"?m.append(g("…",0,{ellipsis:!0})):m.append(g(String(v),v,{active:v===n}))}m.append(g("›",n+1,{disabled:n>=a,ariaLabel:"Next page"})),c.append(m);const b=t.argMeta?.[4]?.stateRef;if(d&&(b||$(e.perPageOptions).length>0)){const h=$(e.perPageOptions).length>0?$(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(Xu),v=l("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),y=l("select",{class:"rui-pagination-per-page-select"});for(const x of h){const w=l("option",{value:String(x),selected:x===d?"":null},[String(x)]);y.append(w)}b&&r.bindState(y,b,{event:"change",getValue:x=>Number(x.value)}),v.append(y),v.append(document.createTextNode(" per page")),c.append(v)}return c}};function Zu(t,e,r){const a=[],n=(c,u)=>{for(let p=c;p<=u;p+=1)a.push(p)},i=r*2+5;if(e<=i)return n(1,e),a;const o=Math.max(2,t-r),s=Math.min(e-1,t+r);return a.push(1),o>2&&a.push("…"),n(o,s),s<e-1&&a.push("…"),a.push(e),a}const Qu={name:"NavbarItem",description:"Single link inside a Navbar's main item slot. Renders as an inline anchor / button — pass `to` for a router-aware link, `href` for an external link, or `onClick` for a click handler. `active=true` highlights the current page.",props:[{name:"label",type:"string"},{name:"to",type:"string",optional:!0,description:"Internal route (consumes the built-in router)"},{name:"href",type:"string",optional:!0,description:"External href; opens in a new tab when set with `external=true`"},{name:"icon",type:"string",optional:!0},{name:"active",type:"boolean",optional:!0},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable fired on click (alternative to `to`/`href`)"},{name:"external",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=f(e.label),n=e.icon,i=A(e.active),o=f(e.to),s=tt(e.href,""),c=A(e.external),u=o||s?"a":"button",p=l(u,{class:"rui-navbar-item",type:u==="button"?"button":null,href:s||(o?`#${o.startsWith("/")?o:`/${o}`}`:null),target:c&&s?"_blank":null,rel:c&&s?"noopener noreferrer":null,"data-active":i?"true":"false"}),d=j(n,{className:"rui-navbar-item-icon"});return d&&p.append(d),p.append(l("span",{class:"rui-navbar-item-label"},[a])),o&&!s?p.onclick=m=>{if(m.defaultPrevented)return;const g=m;g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(m.preventDefault(),r.router.navigate(o))}:typeof e.onClick=="function"&&(p.onclick=m=>{m.preventDefault(),r.invoke(e.onClick)}),p}},ed={name:"Navbar",description:"Top navigation bar with a brand on the left, primary nav items in the middle, and a right-aligned actions slot (user avatar, DropdownMenu, CTA buttons, …). Use `sticky=true` to pin it to the top of the page. The canonical companion of `Sidebar` for product surfaces; prefer Navbar for marketing/docs pages without a sidebar.",props:[{name:"brand",type:"string | Node",optional:!0,description:"Workspace/product name (string) or a node (e.g. logo Image)"},{name:"items",type:"NavbarItem[]",optional:!0,description:"Center navigation items"},{name:"actions",type:"Node[]",optional:!0,description:"Right-side controls (Buttons, Avatar, DropdownMenu, …)"},{name:"sticky",type:"boolean",optional:!0,description:"Pin the bar to the top of the viewport"},{name:"variant",type:"string",optional:!0,enum:["default","transparent"],description:"Visual variant"}],render:(t,e,r)=>{const a=l("nav",{class:"rui-navbar","data-sticky":A(e.sticky)?"true":"false","data-variant":f(e.variant,"default"),"aria-label":"Primary"}),n=e.brand;if(n!=null&&n!==""){const s=l("div",{class:"rui-navbar-brand"});typeof n=="string"?s.append(document.createTextNode(n)):s.append(r.renderNode(n)),a.append(s)}const i=$(e.items);if(i.length>0){const s=l("div",{class:"rui-navbar-items"});for(const c of i)s.append(r.renderNode(c));a.append(s)}const o=$(e.actions);if(o.length>0){const s=l("div",{class:"rui-navbar-actions"});for(const c of o)s.append(r.renderNode(c));a.append(s)}return a}},td=["bottom","top","left","right"],rd=["start","center","end"],ad=["default","danger"],Ot=(t,e,r)=>{r.set(e);const a=t.closest(".rui-dropdown-menu");return a?(a.setAttribute("data-open",e?"true":"false"),a.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded",e?"true":"false"),e||Ne(a),a):null},Rn=(t,e)=>{rt({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false"),t.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded","false")}})},Pr=(t,e)=>{if(!t||typeof t!="object")return!1;const r=t;return r.__kind==="Component"&&r.name===e},nd={name:"DropdownMenu",description:"Click-triggered dropdown menu. Click the trigger to toggle, click a MenuItem to run its action and close, click outside or press Escape to close without acting. Children must be MenuItem, MenuSeparator, or MenuLabel entries.",props:[{name:"trigger",type:"Node",description:"Clickable trigger element (typically a Button or Avatar)"},{name:"items",type:"(MenuItem | MenuSeparator | MenuLabel)[]"},{name:"side",type:"string",optional:!0,enum:td,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:rd,description:'How the menu aligns along the trigger edge (default "start")'},{name:"label",type:"string",optional:!0,description:"Optional ARIA label for the menu"},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the menu"}],render:(t,e,r)=>{const a=A(e.open),n=r.useInstanceState("open",a),i=n.get(),o=l("div",{class:"rui-dropdown-menu","data-open":i?"true":"false","data-side":f(e.side,"bottom"),"data-align":f(e.align,"start")}),s=l("span",{class:"rui-dropdown-menu-trigger","data-state":i?"open":"closed","aria-haspopup":"menu","aria-expanded":i?"true":"false",tabindex:"0"});s.append(r.renderNode(e.trigger)),s.onclick=u=>{u.stopPropagation();const p=u.currentTarget??u.target,d=!n.get(),m=Ot(p,d,n);d&&m&&Rn(m,n)},s.onkeydown=u=>{const p=u,d=p.currentTarget??p.target;if(p.key==="Enter"||p.key===" "){p.preventDefault();const m=!n.get(),g=Ot(d,m,n);m&&g&&Rn(g,n);return}p.key==="Escape"&&n.get()&&(p.preventDefault(),Ot(d,!1,n))},o.append(s);const c=l("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":f(e.label)||null});for(const u of $(e.items)){if(Pr(u,"MenuItem")){const p=u.args??[],d=f(p[0]),m=p[1],g=p[2],b=f(p[3]),h=f(p[4],"default"),v=A(p[5]),y=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":h,disabled:v?"":null}),x=j(g,{className:"rui-menu-item-icon"});x&&y.append(x),y.append(l("span",{class:"rui-menu-item-label"},[d])),b&&y.append(l("span",{class:"rui-menu-item-shortcut"},[b])),v||(y.onclick=w=>{const k=w.currentTarget??w.target;Ot(k,!1,n),r.invoke(m)}),c.append(y);continue}if(Pr(u,"MenuSeparator")){c.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}if(Pr(u,"MenuLabel")){const p=f((u.args??[])[0]);c.append(l("div",{class:"rui-menu-label"},[p]));continue}c.append(r.renderNode(u))}return o.append(c),o}},id={name:"MenuItem",description:"Single item inside a DropdownMenu. Renders a button-style row with an optional leading icon and trailing keyboard-shortcut hint. `onClick` (legacy: `action`) runs when clicked; the menu closes automatically afterwards.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable to execute on click"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown before the label"},{name:"shortcut",type:"string",optional:!0,description:'Trailing keyboard-shortcut hint (e.g. "⌘ K")'},{name:"variant",type:"string",optional:!0,enum:ad,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=A(e.disabled),n=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":f(e.variant,"default"),disabled:a?"":null}),i=j(e.icon,{className:"rui-menu-item-icon"});i&&n.append(i),n.append(l("span",{class:"rui-menu-item-label"},[f(e.label)]));const o=f(e.shortcut);return o&&n.append(l("span",{class:"rui-menu-item-shortcut"},[o])),a||(n.onclick=()=>{r.invoke(e.onClick)}),n}},od={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>l("div",{class:"rui-menu-separator",role:"separator"})},sd={name:"MenuLabel",description:'Small uppercase section header inside a DropdownMenu. Use to group related MenuItems (e.g. "Account", "Workspace", "Danger zone").',props:[{name:"label",type:"string"}],render:(t,e)=>l("div",{class:"rui-menu-label"},[f(e.label)])},ld=["left","center","right"];function cd(t){return $(t).map((e,r)=>{const a=e.args??[],n=f(a[0]);return{header:n,values:$(a[1]),format:f(a[2],"text"),align:ld.includes(f(a[3]))?f(a[3]):"",sortable:A(a[4]),filterable:A(a[5]),render:a[6],onClick:a[7],key:n||`col-${r}`}})}function zn(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return E(t,0)-E(e,0);if(r==="date"){const a=new Date(f(t)).getTime(),n=new Date(f(e)).getTime();if(Number.isFinite(a)&&Number.isFinite(n))return a-n}return f(t).localeCompare(f(e))}function _t(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():f(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):f(t);case"date":try{const r=new Date(f(t));return Number.isNaN(r.getTime())?f(t):r.toLocaleDateString()}catch{return f(t)}default:return f(t)}}const ud={name:"DataGrid",description:"Advanced data table with sortable headers, per-column filter chips, row selection (checkboxes), sticky header / first column, optional pagination, an optional bulk-action toolbar slot, and click-to-act rows. Columns are Col(header, values, format?, align?, sortable?, filterable?) entries. Bind `$sort` (`{key, direction}` object), `$selectedIds` (string[]), and `$page` (number) for full reactivity. Use INSTEAD of `Table` when you need any of those interactions.",props:[{name:"columns",type:"Col[]",description:"Columns; pass sortable=true / filterable=true on each Col."},{name:"rowIds",type:"any[]",optional:!0,description:"Stable id per row (used by `selectedIds`); defaults to row index."},{name:"caption",type:"string",optional:!0},{name:"sort",type:"object",optional:!0,description:"`{key, direction}` — pass a $variable for two-way binding"},{name:"selectedIds",type:"any[]",optional:!0,description:"Array of selected row ids — bind a $variable"},{name:"selectable",type:"boolean",optional:!0,description:"Render leading selection checkboxes"},{name:"page",type:"number",optional:!0,description:"1-indexed current page — bind a $variable"},{name:"perPage",type:"number",optional:!0,description:"Page size (default 20)"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when no rows match (default `No results`)"},{name:"onRowClick",type:"callable",optional:!0,aliases:["rowAction"],description:"Callable fired when a row is clicked. Receives the row index."},{name:"toolbar",type:"Node[]",optional:!0,description:"Bulk-action toolbar shown above the table when any rows are selected"},{name:"density",type:"string",optional:!0,enum:["comfortable","compact"]},{name:"striped",type:"boolean",optional:!0},{name:"stickyHeader",type:"boolean",optional:!0,description:"Pin the header row (default true)"},{name:"stickyFirstColumn",type:"boolean",optional:!0,description:"Pin the first column horizontally"}],render:(t,e,r)=>{const a=cd(e.columns),n=Math.max(0,...a.map(B=>B.values.length)),i=$(e.rowIds),o=B=>f(i[B]??B),s=e.sort&&typeof e.sort=="object"?e.sort:null,c=f(s?.key),u=f(s?.direction,"asc")==="desc"?"desc":"asc",p=$(e.selectedIds).map(B=>f(B)),d=new Set(p),m=A(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,g=e.stickyHeader===void 0?!0:A(e.stickyHeader),b=A(e.stickyFirstColumn),h=f(e.density,"comfortable"),v=A(e.striped),y=r.useInstanceState("filters",{}),x=y.get(),w=[];for(let B=0;B<n;B+=1){let K=!0;for(const Y of a){if(!Y.filterable)continue;const G=(x[Y.key]??"").trim().toLowerCase();if(!G)continue;const ne=Y.values[B];if(!_t(ne,Y.format).toLowerCase().includes(G)){K=!1;break}}K&&w.push(B)}if(c){const B=a.find(K=>K.key===c);B&&B.sortable&&w.sort((K,Y)=>{const G=zn(B.values[K],B.values[Y],B.format);return u==="desc"?-G:G})}const k=w.length,T=Math.max(1,Math.floor(E(e.perPage,20))),S=Math.max(1,Math.ceil(k/T)),C=Math.max(1,Math.floor(E(e.page,1))),N=Math.min(C,S),I=w.slice((N-1)*T,N*T),L=l("div",{class:"rui-data-grid","data-density":h,"data-striped":v?"true":"false","data-sticky-header":g?"true":"false","data-sticky-first":b?"true":"false"}),D=t.argMeta?.[3]?.stateRef,q=t.argMeta?.[4]?.stateRef,O=t.argMeta?.[6]?.stateRef,U=$(e.toolbar);if(p.length>0&&U.length>0){const B=l("div",{class:"rui-data-grid-bulk"});B.append(l("span",{class:"rui-data-grid-bulk-count"},[`${p.length} selected`]));const K=l("div",{class:"rui-data-grid-bulk-tools"});for(const Y of U)K.append(r.renderNode(Y));B.append(K),L.append(B)}const J=l("div",{class:"rui-data-grid-scroll"}),Z=l("table",{class:"rui-data-grid-table"}),me=f(e.caption);me&&Z.append(l("caption",{class:"rui-data-grid-caption"},[me]));const $e=l("thead"),Ct=l("tr");if(m){const B=l("th",{class:"rui-data-grid-cell-select",scope:"col"}),K=I.length>0&&I.every(G=>d.has(o(G))),Y=l("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select all rows on this page",checked:K?"":null});q&&(Y.onclick=G=>{const ne=G.currentTarget,ee=new Set(p);for(const X of I){const Q=o(X);ne.checked?ee.add(Q):ee.delete(Q)}r.setState(q,Array.from(ee))}),B.append(Y),Ct.append(B)}if(a.forEach((B,K)=>{const Y=l("th",{scope:"col","data-align":B.align||null,"data-sortable":B.sortable?"true":null,"data-active":B.sortable&&B.key===c?"true":null,"data-first":K===0?"true":null});if(B.sortable&&D){const G=l("button",{type:"button",class:"rui-data-grid-sort"});G.append(l("span",{},[B.header]));const ne=B.key===c?u==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",ee=j(ne,{className:"rui-data-grid-sort-icon"});ee&&G.append(ee),G.onclick=()=>{const X=B.key===c&&u==="asc"?"desc":"asc";r.setState(D,{key:B.key,direction:X})},Y.append(G)}else Y.append(document.createTextNode(B.header));Ct.append(Y)}),$e.append(Ct),a.some(B=>B.filterable)){const B=l("tr",{class:"rui-data-grid-filter-row"});m&&B.append(l("td",{class:"rui-data-grid-cell-select"})),a.forEach(K=>{const Y=l("td");if(K.filterable){const G=l("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${K.header}`,value:x[K.key]??""});G.oninput=ne=>{const ee=ne.currentTarget,X={...y.get(),[K.key]:ee.value};y.set(X);const Q=ee.closest("table")?.querySelector("tbody");Dg(Q)},Y.append(G)}B.append(Y)}),$e.append(B)}Z.append($e);const Ye=l("tbody");Z.append(Ye);const da=B=>{if(Ye.replaceChildren(),B.length===0){const K=l("tr"),Y=(m?1:0)+Math.max(a.length,1);K.append(l("td",{colspan:String(Y),class:"rui-data-grid-empty"},[f(e.emptyLabel,"No results")])),Ye.append(K);return}for(const K of B){const Y=o(K),G=d.has(Y),ne=l("tr",{"data-selected":G?"true":null});if(m){const ee=l("td",{class:"rui-data-grid-cell-select"}),X=l("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select row",checked:G?"":null});q&&(X.onclick=Q=>{Q.stopPropagation();const xe=Q.currentTarget,we=new Set(p);xe.checked?we.add(Y):we.delete(Y),r.setState(q,Array.from(we))}),ee.append(X),ne.append(ee)}a.forEach((ee,X)=>{const Q=l("td",{"data-format":ee.format,"data-align":ee.align||null,"data-first":X===0?"true":null});hr(Q,ee,ee.values[K],K,r,_t),ne.append(Q)}),typeof e.onRowClick=="function"&&(ne.setAttribute("data-clickable","true"),ne.onclick=ee=>{ee.target?.closest("input,button,a,label,select,textarea")||r.invoke(e.onRowClick,K)}),Ye.append(ne)}},Dg=B=>{const K=B??Ye,Y=y.get(),G=[];for(let X=0;X<n;X+=1){let Q=!0;for(const xe of a){if(!xe.filterable)continue;const we=(Y[xe.key]??"").trim().toLowerCase();if(!we)continue;const At=xe.values[X];if(!_t(At,xe.format).toLowerCase().includes(we)){Q=!1;break}}Q&&G.push(X)}if(c){const X=a.find(Q=>Q.key===c);X&&X.sortable&&G.sort((Q,xe)=>{const we=zn(X.values[Q],X.values[xe],X.format);return u==="desc"?-we:we})}const ne=G.slice((N-1)*T,N*T);(X=>{X.replaceChildren();for(const Q of ne){const xe=o(Q),we=d.has(xe),At=l("tr",{"data-selected":we?"true":null});if(m){const Xe=l("td",{class:"rui-data-grid-cell-select"}),pa=l("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:we?"":null});Xe.append(pa),At.append(Xe)}a.forEach((Xe,pa)=>{const ho=l("td",{"data-format":Xe.format,"data-align":Xe.align||null,"data-first":pa===0?"true":null});hr(ho,Xe,Xe.values[Q],Q,r,_t),At.append(ho)}),X.append(At)}if(ne.length===0){const Q=l("tr"),xe=(m?1:0)+Math.max(a.length,1);Q.append(l("td",{colspan:String(xe),class:"rui-data-grid-empty"},[f(e.emptyLabel,"No results")])),X.append(Q)}})(K)};if(da(I),J.append(Z),L.append(J),k>T){const B=l("div",{class:"rui-data-grid-footer"}),K=k===0?0:(N-1)*T+1,Y=Math.min(k,N*T);B.append(l("span",{class:"rui-data-grid-footer-summary"},[k===0?"No results":`Showing ${K}–${Y} of ${k}`]));const G=l("div",{class:"rui-data-grid-footer-buttons"}),ne=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:N<=1?"":null},["‹ Prev"]),ee=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:N>=S?"":null},["Next ›"]);O&&(ne.onclick=()=>{N<=1||r.setState(O,N-1)},ee.onclick=()=>{N>=S||r.setState(O,N+1)}),G.append(ne),G.append(l("span",{class:"rui-data-grid-page-current"},[`${N} / ${S}`])),G.append(ee),B.append(G),L.append(B)}return L}};function dd(t){const e=[];for(const r of $(t)){if(!r||typeof r!="object")continue;const a=r,n=f(a.date);n&&e.push({date:n,title:f(a.title),tone:f(a.tone,"primary"),time:f(a.time)})}return e}function Dn(t,e){const r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=(r.getDay()-e+7)%7;return r.setDate(r.getDate()-n),r}function jn(t){const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${a}`}const pd={name:"CalendarView",description:"Full-month or week calendar grid for scheduling apps — distinct from the form-input `DatePicker`. Pass events as an array of `{date: 'YYYY-MM-DD', title, tone?, time?}` objects. Bind `value` to a `$variable` for the selected date (ISO string). Use `view=\"week\"` for a single-week strip. `firstDay=1` (Monday) matches most business apps.",props:[{name:"value",type:"string",optional:!0,description:"Selected ISO date (YYYY-MM-DD); bind a $variable"},{name:"month",type:"string",optional:!0,description:"Reference month — ISO date or YYYY-MM (defaults to today)"},{name:"events",type:"object[]",optional:!0,description:"Array of {date, title, tone?, time?} objects"},{name:"view",type:"string",optional:!0,enum:["month","week"]},{name:"firstDay",type:"number",optional:!0,description:"0=Sunday, 1=Monday (default 1)"},{name:"onSelect",type:"callable",optional:!0,description:"Callable fired when a day is clicked; receives the ISO date string"}],render:(t,e,r)=>{const a=f(e.view,"month"),n=dd(e.events),i=f(e.value),o=f(e.month,i),s=new Date;let c=new Date(NaN);if(o){const T=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(o);if(T)c=new Date(Number(T[1]),Number(T[2])-1,T[3]?Number(T[3]):1);else{const S=new Date(o);Number.isNaN(S.getTime())||(c=S)}}Number.isNaN(c.getTime())&&(c=s);const u=(E(e.firstDay,1)%7+7)%7,p=i&&/^\d{4}-\d{2}-\d{2}$/.test(i)?i:"",d=new Map;for(const T of n){const S=T.date.slice(0,10),C=d.get(S)??[];C.push(T),d.set(S,C)}const m=t.argMeta?.[0]?.stateRef,g=l("div",{class:"rui-calendar","data-view":a}),b=l("div",{class:"rui-calendar-header"}),h=c.toLocaleDateString(void 0,{month:"long",year:"numeric"});b.append(l("div",{class:"rui-calendar-title"},[h])),g.append(b);const v=l("div",{class:"rui-calendar-weekrow"}),y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let T=0;T<7;T+=1){const S=y[(u+T)%7]??"";v.append(l("div",{class:"rui-calendar-weekday"},[S]))}g.append(v);const x=[];if(a==="week"){const T=p?new Date(p):c,S=Dn(T,u);for(let C=0;C<7;C+=1){const N=new Date(S);N.setDate(S.getDate()+C),x.push({date:N,inMonth:N.getMonth()===c.getMonth()})}}else{const T=new Date(c.getFullYear(),c.getMonth(),1),S=new Date(c.getFullYear(),c.getMonth()+1,0),C=Dn(T,u),N=Math.ceil((S.getDate()+(T.getDay()-u+7)%7)/7)*7;for(let I=0;I<N;I+=1){const L=new Date(C);L.setDate(C.getDate()+I),x.push({date:L,inMonth:L.getMonth()===c.getMonth()})}}const w=l("div",{class:"rui-calendar-grid","data-view":a}),k=jn(s);for(const T of x){const S=jn(T.date),C=S===k,N=S===p,I=d.get(S)??[],L=l("button",{type:"button",class:"rui-calendar-day","data-in-month":T.inMonth?"true":"false","data-today":C?"true":"false","data-selected":N?"true":"false","aria-label":T.date.toDateString()});if(L.append(l("span",{class:"rui-calendar-daynumber"},[String(T.date.getDate())])),I.length>0){const D=l("div",{class:"rui-calendar-day-events"}),q=I.slice(0,3);for(const O of q){const U=l("span",{class:"rui-calendar-event","data-tone":O.tone??"primary",title:O.time?`${O.time} — ${O.title}`:O.title},[O.title]);D.append(U)}I.length>3&&D.append(l("span",{class:"rui-calendar-event-more"},[`+${I.length-3} more`])),L.append(D)}L.onclick=()=>{m&&r.setState(m,S),r.invoke(e.onSelect,S)},w.append(L)}return g.append(w),g}};function md(t){const e=[];for(const r of $(t)){if(!r||typeof r!="object")continue;const a=r;e.push({title:f(a.title),description:f(a.description),actor:f(a.actor),avatarSrc:f(a.avatarSrc),time:f(a.time),icon:f(a.icon),tone:f(a.tone,"default"),meta:f(a.meta)})}return e}function fd(t,e,r){const a=l("ol",{class:t,"data-variant":r});for(const n of e){const i=l("li",{class:`${t}-item`,"data-tone":n.tone}),o=l("span",{class:`${t}-marker`}),s=j(n.icon,{className:`${t}-icon`});s&&o.append(s),i.append(o);const c=l("div",{class:`${t}-body`}),u=l("div",{class:`${t}-head`});n.actor&&u.append(l("span",{class:`${t}-actor`},[n.actor])),u.append(l("span",{class:`${t}-title`},[n.title])),n.time&&u.append(l("span",{class:`${t}-time`},[n.time])),c.append(u),n.description&&c.append(l("p",{class:`${t}-description`},[n.description])),n.meta&&c.append(l("span",{class:`${t}-meta`},[n.meta])),i.append(c),a.append(i)}return a}const gd={name:"ActivityLog",description:'Purpose-built feed of user/system activity. Each entry has `actor`, `title`, `description?`, `time?`, `icon?`, `tone?`, and optional `meta` (IP, browser, request id). Use `variant="audit"` for monospace security/admin trails. Pass items as `{actor, title, description, time, icon, tone, avatarSrc, meta}` objects.',props:[{name:"items",type:"object[]"},{name:"variant",type:"string",optional:!0,enum:["default","audit"],description:"audit = monospace voice with meta column"}],render:(t,e)=>{const r=f(e.variant,"default");return fd(r==="audit"?"rui-audit-trail":"rui-activity-log",md(e.items),r)}},hd={name:"ComparisonTable",description:"Feature/spec comparison table — generic counterpart of `PricingTable`. Pass `columns` (e.g. plan/product names) and `rows` of `{label, values}` where `values` aligns 1-to-1 with `columns`. Each value can be a boolean (✓/—), a string, or a node.",props:[{name:"columns",type:"string[]",description:"Column headers"},{name:"rows",type:"object[]",description:"Array of {label, values, hint?, group?} entries"},{name:"highlightColumn",type:"number",optional:!0,description:"0-indexed column to visually emphasise"}],render:(t,e,r)=>{const a=$(e.columns).map(m=>f(m)),n=$(e.rows).map(m=>{const g=m??{};return{label:f(g.label),values:$(g.values),hint:f(g.hint),group:f(g.group)}}),i=Math.floor(E(e.highlightColumn,-1)),o=l("div",{class:"rui-comparison-table"}),s=l("table"),c=l("thead"),u=l("tr");u.append(l("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),a.forEach((m,g)=>{u.append(l("th",{scope:"col","data-highlight":g===i?"true":null},[m]))}),c.append(u),s.append(c);const p=l("tbody");let d="";for(const m of n){if(m.group&&m.group!==d){d=m.group;const h=l("tr",{class:"rui-comparison-table-group"});h.append(l("td",{colspan:String(a.length+1)},[m.group])),p.append(h)}const g=l("tr"),b=l("td",{class:"rui-comparison-table-feature"});b.append(l("div",{class:"rui-comparison-table-feature-label"},[m.label])),m.hint&&b.append(l("div",{class:"rui-comparison-table-feature-hint"},[m.hint])),g.append(b);for(let h=0;h<a.length;h+=1){const v=m.values[h],y=l("td",{"data-highlight":h===i?"true":null});if(v===!0){const x=j("circle-check",{className:"rui-comparison-yes"});x?y.append(x):y.textContent="✓"}else v===!1||v===null||v===void 0?y.append(l("span",{class:"rui-comparison-no"},["—"])):v&&typeof v=="object"&&v.__kind==="Component"?y.append(r.renderNode(v)):y.textContent=f(v);g.append(y)}p.append(g)}return s.append(p),o.append(s),o}},bd={name:"InfiniteList",description:"Vertical list that fires `onLoadMore` when the user scrolls near the bottom. Pass already-rendered child nodes as `items`; wire `onLoadMore` to an `action` that awaits a `$mutation` or `$query` (e.g. `await loadMore.invoke()`) and appends to the bound state. Use `loading=true` to show the spinner row, `hasMore=false` to suppress further loads.",props:[{name:"items",type:"Node[]",description:"Already-rendered child nodes"},{name:"onLoadMore",type:"callable",optional:!0,description:"Callable fired when the sentinel scrolls into view"},{name:"loading",type:"boolean",optional:!0},{name:"hasMore",type:"boolean",optional:!0,description:"Default true — set false to hide the sentinel"},{name:"loaderLabel",type:"string",optional:!0,description:"Label rendered while loading (default `Loading…`)"}],render:(t,e,r)=>{const a=l("div",{class:"rui-infinite-list"}),n=l("div",{class:"rui-infinite-list-body"});for(const s of $(e.items))n.append(r.renderNode(s));a.append(n);const i=e.hasMore===void 0?!0:A(e.hasMore),o=A(e.loading);if(i){const s=l("div",{class:"rui-infinite-list-sentinel"});if(o){const c=j("spinner",{className:"rui-infinite-list-spin"});c&&s.append(c),s.append(l("span",{},[f(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const c=l("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);c.onclick=()=>r.invoke(e.onLoadMore),s.append(c)}if(a.append(s),!o&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const c=e.onLoadMore,u=new IntersectionObserver(p=>{for(const d of p)if(d.isIntersecting){r.invoke(c);break}});u.observe(s),r.registerDisposer(()=>u.disconnect(),"infinite-observer")}}return a}},vd=/^(https?:|blob:|data:(audio|video)\/)/i;function Ft(t){const e=f(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":vd.test(e)?e:"":""}const yd={name:"VideoPlayer",description:"Themed native `<video>` wrapper. Pass a `src` URL (or `sources` array for multi-codec fallback) and optional `poster`. Standard controls are visible by default; pass `autoplay`, `loop`, `muted`, or `controls=false` to override. Use for product demos, tutorials, and any inline video.",props:[{name:"src",type:"string",optional:!0,description:"Video URL (mp4 / webm / etc.)"},{name:"sources",type:"object[]",optional:!0,description:"Array of {src, type} entries for multi-codec fallback"},{name:"poster",type:"string",optional:!0,description:"Thumbnail image URL shown before playback"},{name:"caption",type:"string",optional:!0},{name:"controls",type:"boolean",optional:!0,description:"Show native controls (default true)"},{name:"autoplay",type:"boolean",optional:!0},{name:"loop",type:"boolean",optional:!0},{name:"muted",type:"boolean",optional:!0},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio (default 16:9)"}],render:(t,e)=>{const r=l("figure",{class:"rui-video-player"}),a=Ir(f(e.ratio,"16:9")),n=l("div",{class:"rui-video-player-frame",style:`aspect-ratio:${a};`}),i=e.controls===void 0?!0:A(e.controls),o=l("video",{class:"rui-video-player-video",controls:i?"":null,autoplay:A(e.autoplay)?"":null,loop:A(e.loop)?"":null,muted:A(e.muted)?"":null,poster:ie(e.poster)||null,playsinline:"",preload:"metadata"}),s=$(e.sources);if(s.length>0)for(const u of s){if(!u||typeof u!="object")continue;const p=u,d=Ft(p.src);d&&o.append(l("source",{src:d,type:f(p.type)||null}))}else{const u=Ft(e.src);u&&o.setAttribute("src",u)}n.append(o),r.append(n);const c=f(e.caption);return c&&r.append(l("figcaption",{class:"rui-video-player-caption"},[c])),r}},xd={name:"AudioPlayer",description:"Themed native `<audio>` wrapper with a title, optional artist, and standard transport controls. Pass `src` (or `sources`) plus a `title` so the bar still looks like a player when the controls bar is hidden. Use for podcasts, voice notes, and demo audio.",props:[{name:"src",type:"string",optional:!0,description:"Audio URL (mp3 / ogg / wav / etc.)"},{name:"sources",type:"object[]",optional:!0,description:"Array of {src, type} entries for multi-codec fallback"},{name:"title",type:"string",optional:!0},{name:"artist",type:"string",optional:!0},{name:"controls",type:"boolean",optional:!0,description:"Show native controls (default true)"},{name:"autoplay",type:"boolean",optional:!0},{name:"loop",type:"boolean",optional:!0},{name:"icon",type:"string",optional:!0,description:"Leading icon (default `music`)"}],render:(t,e)=>{const r=l("div",{class:"rui-audio-player"}),a=l("div",{class:"rui-audio-player-meta"}),n=j(f(e.icon,"music"),{className:"rui-audio-player-icon"});n&&a.append(n);const i=l("div",{class:"rui-audio-player-text"}),o=f(e.title);o&&i.append(l("div",{class:"rui-audio-player-title"},[o]));const s=f(e.artist);s&&i.append(l("div",{class:"rui-audio-player-artist"},[s])),a.append(i),r.append(a);const c=e.controls===void 0?!0:A(e.controls),u=l("audio",{class:"rui-audio-player-audio",controls:c?"":null,autoplay:A(e.autoplay)?"":null,loop:A(e.loop)?"":null,preload:"metadata"}),p=$(e.sources);if(p.length>0)for(const d of p){if(!d||typeof d!="object")continue;const m=d,g=Ft(m.src);g&&u.append(l("source",{src:g,type:f(m.type)||null}))}else{const d=Ft(e.src);d&&u.setAttribute("src",d)}return r.append(u),r}};function wd(t,e){if(t==null)return null;if(typeof t=="object"&&t.__kind==="Component")return e.renderNode(t);if(typeof t=="string"){const r=ie(t);return r?l("img",{src:r,alt:"",loading:"lazy",class:"rui-carousel-image"}):null}if(typeof t=="object"){const r=t,a=ie(r.src);if(a){const n=l("figure",{class:"rui-carousel-figure"});n.append(l("img",{src:a,alt:f(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const i=f(r.caption??r.title);return i&&n.append(l("figcaption",{class:"rui-carousel-caption"},[i])),n}}return e.renderNode(t)}const kd={name:"Carousel",description:"Horizontal slider with prev/next buttons and dot navigation. Each child slide takes full width. Slides may be Component nodes (Image, Card, MediaCard, …), URL strings, or plain `{src, alt, caption?}` image objects — bare image objects are auto-wrapped into a captioned figure. Use for image galleries, onboarding carousels, hero banners, and product image strips. The active slide is preserved across re-renders via instance state.",props:[{name:"items",type:"Node[]",description:"Slide nodes, image URLs, or {src, alt, caption?} objects"},{name:"activeIndex",type:"number",optional:!0,description:"0-indexed initial slide (default 0)"},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio of the frame (default `16:9`)"},{name:"showDots",type:"boolean",optional:!0,description:"Show indicator dots (default true)"},{name:"showArrows",type:"boolean",optional:!0,description:"Show prev/next arrows (default true)"}],render:(t,e,r)=>{const a=$(e.items),n=a.length,i=Math.max(0,Math.min(Math.max(n-1,0),Math.floor(E(e.activeIndex,0)))),o=r.useInstanceState("active",i);let s=o.get();s>=n&&(s=0,o.set(s));const c=e.showDots===void 0?!0:A(e.showDots),u=e.showArrows===void 0?!0:A(e.showArrows),p=Ir(f(e.ratio,"16:9")),d=l("div",{class:"rui-carousel"}),m=l("div",{class:"rui-carousel-frame",style:`aspect-ratio:${p};`}),g=l("div",{class:"rui-carousel-track",style:`transform:translateX(${s*-100}%);`});a.forEach(h=>{const v=l("div",{class:"rui-carousel-slide"}),y=wd(h,r);y&&v.append(y),g.append(v)}),m.append(g);const b=(h,v)=>{const y=(v%n+n)%n;o.set(y);const x=h.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${y*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((k,T)=>{k.setAttribute("data-active",T===y?"true":"false")})};if(u&&n>1){const h=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),v=j("chevron-left");v&&h.append(v);const y=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=j("chevron-right");x&&y.append(x),h.onclick=w=>b(w.currentTarget,o.get()-1),y.onclick=w=>b(w.currentTarget,o.get()+1),m.append(h,y)}if(d.append(m),c&&n>1){const h=l("div",{class:"rui-carousel-dots"});a.forEach((v,y)=>{const x=l("button",{type:"button",class:"rui-carousel-dot","data-active":y===s?"true":"false","aria-label":`Go to slide ${y+1}`});x.onclick=w=>b(w.currentTarget,y),h.append(x)}),d.append(h)}return d}},Sd={name:"Gallery",description:"Responsive image grid. Pass items as plain URL strings, `{src, alt, caption?}` objects, or `Image(...)` nodes. When `onSelect` is provided each tile becomes a button; bind it through an Action that opens a `Lightbox`.",props:[{name:"items",type:"any[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"},{name:"ratio",type:"string",optional:!0,description:"Per-tile aspect ratio (default `1:1`)"},{name:"onSelect",type:"callable",optional:!0,description:"Callable fired when a tile is clicked"}],render:(t,e,r)=>{const a=$(e.items),n=Math.max(1,Math.min(6,Number(e.columns??"auto"))),i=Ir(f(e.ratio,"1:1")),o=l("div",{class:"rui-gallery","data-columns":n>0?String(n):null});return a.forEach((s,c)=>{const{src:u,alt:p,caption:d}=Bn(s),m=ie(u),g=typeof e.onSelect=="function",b=l(g?"button":"figure",{type:g?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${i};`,"data-index":String(c)});if(m)b.append(l("img",{src:m,alt:p,loading:"lazy"}));else{const h=j("image",{className:"rui-gallery-placeholder"});h&&b.append(h)}d&&b.append(l("span",{class:"rui-gallery-caption"},[d])),g&&(b.onclick=()=>r.invoke(e.onSelect,c,s)),o.append(b)}),o}};function Bn(t){if(typeof t=="string")return{src:t,alt:"",caption:""};if(t&&typeof t=="object"){const e=t;return e.__kind==="Component"&&Array.isArray(e.args)?{src:f(e.args[0]),alt:f(e.args[1]),caption:f(e.args[2])}:{src:f(e.src),alt:f(e.alt),caption:f(e.caption)}}return{src:"",alt:"",caption:""}}const $d={name:"Lightbox",description:"Image overlay. When you bind a `$variable` to `open` you control it explicitly; without one, Lightbox renders a clickable thumbnail of the current image that opens the overlay on click (and uses internal state for next/prev). Pass `items` (string URLs or `{src, alt, caption?}` objects). Clicking the backdrop or × closes; arrows step through the array.",props:[{name:"items",type:"any[]"},{name:"open",type:"boolean",optional:!0,description:"Open/closed; bind a $variable to control externally"},{name:"index",type:"number",optional:!0,description:"0-indexed current image; typically a $variable"}],render:(t,e,r)=>{const a=$(e.items).map(C=>Bn(C)).filter(C=>ie(C.src)!==""),n=a.length,i=t.argMeta?.[2]?.stateRef,o=t.argMeta?.[1]?.stateRef,s=r.useInstanceState("open",!1),c=r.useInstanceState("index",0),u=o?A(e.open):s.get(),p=i?Math.floor(E(e.index,0)):c.get(),d=n===0?0:(p%n+n)%n,m=C=>{o?r.setState(o,C):s.set(C)},g=C=>{i?r.setState(i,C):c.set(C)},b=()=>m(!1),h=C=>{n!==0&&g(((d+C)%n+n)%n)},v=l("div",{class:"rui-lightbox-root"});if(!o&&n>0){const C=a[d],N=l("button",{type:"button",class:"rui-lightbox-thumb","aria-label":C?.alt||"Open image"});if(C){const I=ie(C.src);I&&N.append(l("img",{src:I,alt:C.alt,loading:"lazy"}))}N.onclick=I=>{I.stopPropagation(),m(!0)},v.append(N)}const y=l("div",{class:"rui-lightbox-overlay","data-open":u?"true":"false"});if(v.append(y),!u||n===0)return v;const x=a[d];if(!x)return v;const w=ie(x.src);y.onclick=C=>{C.target===y&&b()};const k=l("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),T=l("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(T.onclick=b,k.append(T),n>1){const C=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),N=j("chevron-left");N&&C.append(N),C.onclick=()=>h(-1);const I=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),L=j("chevron-right");L&&I.append(L),I.onclick=()=>h(1),k.append(C,I)}const S=l("div",{class:"rui-lightbox-image-wrap"});return w&&S.append(l("img",{src:w,alt:x.alt})),k.append(S),x.caption&&k.append(l("div",{class:"rui-lightbox-caption"},[x.caption])),n>1&&k.append(l("div",{class:"rui-lightbox-counter"},[`${d+1} / ${n}`])),y.append(k),v}};function Cd(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){const e=t,r=E(e.lat??e.latitude,NaN),a=E(e.lng??e.longitude,NaN);if(Number.isFinite(r)&&Number.isFinite(a))return{lat:r,lng:a}}if(Array.isArray(t)&&t.length>=2){const e=E(t[0],NaN),r=E(t[1],NaN);if(Number.isFinite(e)&&Number.isFinite(r))return{lat:e,lng:r}}if(typeof t=="string"){const e=t.split(",").map(r=>Number(r.trim()));if(e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]))return{lat:e[0],lng:e[1]}}return null}const Ad={name:"Map",description:"Static map view centered on a lat/lng coordinate. Renders an OpenStreetMap embed inside an `<iframe>` (no external JS, no API key). Pass `lat` and `lng` as bare numbers; `zoom` controls the level (1–18, default 13). Optional `markers` array adds map pins (rendered as a labelled list alongside the map). Use for store locators, address cards, itinerary previews.",props:[{name:"lat",type:"number",description:"Latitude of the map center"},{name:"lng",type:"number",description:"Longitude of the map center"},{name:"zoom",type:"number",optional:!0,description:"1–18 (default 13)"},{name:"markers",type:"object[]",optional:!0,description:"Array of {lat, lng, label?} markers (informational; rendered alongside the map)"},{name:"height",type:"string",optional:!0,description:"CSS height (default 320px)"},{name:"caption",type:"string",optional:!0}],render:(t,e)=>{const r=l("figure",{class:"rui-map"}),a=re(e.height,"320px"),n=l("div",{class:"rui-map-frame",style:`height:${a};`}),i=E(e.lat,NaN),o=E(e.lng,NaN),s=Number.isFinite(i)&&Number.isFinite(o)?{lat:i,lng:o}:null;if(!s){n.append(l("div",{class:"rui-map-empty"},["Pass lat & lng (numbers) to render the map."])),r.append(n);const h=f(e.caption);return h&&r.append(l("figcaption",{class:"rui-map-caption"},[h])),r}const c=Math.max(1,Math.min(18,Math.floor(E(e.zoom,13)))),u=1/Math.pow(2,c-8),d=`https://www.openstreetmap.org/export/embed.html?bbox=${[s.lng-u,s.lat-u/2,s.lng+u,s.lat+u/2].join(",")}&layer=mapnik&marker=${s.lat},${s.lng}`,m=l("iframe",{class:"rui-map-iframe",src:d,loading:"lazy",title:"Map view",referrerpolicy:"no-referrer"});n.append(m),r.append(n);const g=$(e.markers).map(h=>{const v=Cd(h),y=h&&typeof h=="object"?f(h.label):"";return v?{...v,label:y}:null}).filter(h=>h!==null);if(g.length>0){const h=l("ul",{class:"rui-map-markers"});for(const v of g){const y=l("li",{class:"rui-map-marker"}),x=j("location-dot",{className:"rui-map-marker-icon"});x&&y.append(x),y.append(l("span",{class:"rui-map-marker-label"},[v.label||`${v.lat.toFixed(4)}, ${v.lng.toFixed(4)}`])),h.append(y)}r.append(h)}const b=f(e.caption);return b&&r.append(l("figcaption",{class:"rui-map-caption"},[b])),r}};function Ir(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const Td=[{command:"bold",icon:"bold",label:"Bold"},{command:"italic",icon:"italic",label:"Italic"},{command:"underline",icon:"underline",label:"Underline"},{command:"strikeThrough",icon:"strikethrough",label:"Strikethrough"},{command:"formatBlock",icon:"heading",label:"Heading",block:"h2"},{command:"formatBlock",icon:"quote-left",label:"Quote",block:"blockquote"},{command:"insertUnorderedList",icon:"list-ul",label:"Bullet list"},{command:"insertOrderedList",icon:"list-ol",label:"Numbered list"},{command:"createLink",icon:"link",label:"Link"}],Md={name:"RichTextEditor",description:"Rich-text WYSIWYG editor for CMS, email, and comment surfaces. Renders a small toolbar (bold / italic / underline / strikethrough / headings / lists / quote / link) above a `contenteditable` region. Pass `$variable` as `value` for two-way binding — the HTML body is written back to state on every edit. Provide `placeholder` for the empty-state prompt.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound HTML body (typically $variable)"},{name:"placeholder",type:"string",optional:!0,description:"Empty-state prompt"},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height for the editor area (default 160px)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current HTML on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=f(e.placeholder,"Start writing…"),i=A(e.disabled),o=l("div",{class:"rui-rich-text","data-disabled":i?"true":"false"}),s=l("div",{class:"rui-rich-text-toolbar",role:"toolbar"});for(const g of Td){const b=l("button",{type:"button",class:"rui-rich-text-tool","data-command":g.command,"data-block":g.block??null,"aria-label":g.label,title:g.label,disabled:i?"":null}),h=j(g.icon);h&&b.append(h),b.onmousedown=v=>v.preventDefault(),b.onclick=v=>{const x=v.currentTarget.closest(".rui-rich-text")?.querySelector(".rui-rich-text-content");if(x){x.focus();try{if(g.command==="createLink"){const w=window.prompt("URL");w&&document.execCommand("createLink",!1,w)}else g.command==="formatBlock"&&g.block?document.execCommand("formatBlock",!1,g.block):document.execCommand(g.command,!1)}catch{}x.dispatchEvent(new Event("input",{bubbles:!0}))}},s.append(b)}o.append(s);const c=f(e.value)||"",u=g=>g.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim().length===0,p=l("div",{class:"rui-rich-text-content",id:a,contenteditable:i?"false":"true",role:"textbox","aria-multiline":"true","aria-placeholder":n,"data-placeholder":n,"data-empty":u(c)?"true":"false",style:`min-height:${f(e.minHeight,"160px")};`,html:c}),d=g=>{g.setAttribute("data-empty",u(g.innerHTML)?"true":"false")},m=t.argMeta?.[1]?.stateRef;return m&&!i?r.bindState(p,m,{event:"input",getValue:g=>{const b=g;return d(b),b.innerHTML}}):p.oninput=g=>{const b=g.currentTarget??g.target;d(b)},p.onblur=g=>{const b=g.currentTarget??g.target;d(b)},oe(p,e.onChange,r,{event:"input",getValue:g=>g.innerHTML}),o.append(p),o}},Nd={name:"CodeEditor",description:"Lightweight, dependency-free code editor. Pairs a styled textarea with a synchronised line-number gutter — no syntax highlighting, but the editor stays a single rendered node so it works inside Shadow DOM. Use for dev tooling, snippet editing, prompt playgrounds. Pass a `$variable` as `value` for two-way binding. For read-only rendering with highlights prefer `CodeBlock`.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound source text (typically $variable)"},{name:"language",type:"string",optional:!0,enum:["text","javascript","typescript","json","html","css","bash","python","sql","markdown"],description:"Language label shown on the header (default `text`)"},{name:"placeholder",type:"string",optional:!0},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height for the editor area (default 200px)"},{name:"tabSize",type:"number",optional:!0,description:"Spaces per Tab (default 2)"},{name:"showGutter",type:"boolean",optional:!0,description:"Show line-number gutter (default true)"},{name:"readonly",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current source on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=f(e.value),i=f(e.language,"text"),o=e.showGutter===void 0?!0:A(e.showGutter),s=Math.max(1,Math.min(8,Math.floor(E(e.tabSize,2)))),c=A(e.readonly),u=f(e.minHeight,"200px"),p=l("div",{class:"rui-code-editor","data-language":i,"data-gutter":o?"true":"false"}),d=l("div",{class:"rui-code-editor-head"});d.append(l("span",{class:"rui-code-editor-language"},[i])),p.append(d);const m=l("div",{class:"rui-code-editor-body",style:`min-height:${u};`}),g=l("div",{class:"rui-code-editor-gutter","aria-hidden":"true"});o&&((y=>{g.replaceChildren();const x=y.split(/\r?\n/),w=Math.max(1,x.length);for(let k=1;k<=w;k+=1)g.append(l("span",{class:"rui-code-editor-line"},[String(k)]))})(n),m.append(g));const h=l("textarea",{class:"rui-code-editor-textarea",id:a,name:a,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:f(e.placeholder),readonly:c?"":null,style:`tab-size:${s};-moz-tab-size:${s};`});h.value=n,h.oninput=y=>{const x=y.currentTarget;if(!o)return;const k=x.closest(".rui-code-editor")?.querySelector(".rui-code-editor-gutter");if(!k)return;k.replaceChildren();const T=x.value.split(/\r?\n/),S=Math.max(1,T.length);for(let C=1;C<=S;C+=1)k.append(l("span",{class:"rui-code-editor-line"},[String(C)]))},h.onkeydown=y=>{const x=y;if(x.key!=="Tab")return;x.preventDefault();const w=x.currentTarget,k=w.selectionStart,T=w.selectionEnd,S=" ".repeat(s);w.value=w.value.slice(0,k)+S+w.value.slice(T),w.selectionStart=w.selectionEnd=k+S.length,w.dispatchEvent(new Event("input",{bubbles:!0}))};const v=t.argMeta?.[1]?.stateRef;return v&&!c&&r.bindState(h,v,{event:"input",getValue:y=>y.value}),c||oe(h,e.onChange,r,{event:"input",getValue:y=>y.value}),m.append(h),p.append(m),p}};function Pd(t){if(!t)return null;if(typeof t=="object"){const e=t;if(e.__kind==="Component"&&e.name==="MenuItem"&&Array.isArray(e.args)){const a=e.args;return{label:f(a[0]),action:a[1],icon:f(a[2]),shortcut:f(a[3]),variant:f(a[4],"default"),disabled:A(a[5]),separator:!1}}if(e.__kind==="Component"&&e.name==="MenuSeparator")return{label:"",action:null,icon:"",shortcut:"",variant:"default",disabled:!1,separator:!0};const r=t;return r.separator?{label:"",action:null,icon:"",shortcut:"",variant:"default",disabled:!1,separator:!0}:{label:f(r.label),action:r.action,icon:f(r.icon),shortcut:f(r.shortcut),variant:f(r.variant,"default"),disabled:A(r.disabled),separator:!1}}return null}const Id={name:"ContextMenu",description:"Right-click (or long-press) menu that attaches to a child node. Wraps `target` and shows the menu at the pointer when the user right-clicks anywhere inside it. Items are `MenuItem(...)` nodes, `MenuSeparator()` entries, or `{label, action, icon?, shortcut?, variant?, disabled?, separator?}` objects. Use on table rows, tree nodes, kanban cards, file browser entries.",props:[{name:"target",type:"Node",description:"Child node the menu is bound to"},{name:"items",type:"any[]",description:"MenuItem nodes or {label, action} objects"},{name:"label",type:"string",optional:!0,description:"ARIA label for the menu"}],render:(t,e,r)=>{const a=l("div",{class:"rui-context-menu"}),n=l("div",{class:"rui-context-menu-target"});n.append(r.renderNode(e.target)),a.append(n);const i=l("div",{class:"rui-context-menu-pop",role:"menu","aria-label":f(e.label)||null,"data-open":"false"}),o=$(e.items).map(Pd).filter(u=>u!==null);for(const u of o){if(u.separator){i.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}const p=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":u.variant,disabled:u.disabled?"":null}),d=j(u.icon,{className:"rui-menu-item-icon"});d&&p.append(d),p.append(l("span",{class:"rui-menu-item-label"},[u.label])),u.shortcut&&p.append(l("span",{class:"rui-menu-item-shortcut"},[u.shortcut])),u.disabled||(p.onclick=()=>{r.invoke(u.action),i.setAttribute("data-open","false")}),i.append(p)}a.append(i);const s=()=>i.setAttribute("data-open","false"),c=(u,p)=>{const d=n.isConnected?n.closest(".rui-context-menu"):null,m=d?.querySelector(".rui-context-menu-pop")??i,g=d?.getBoundingClientRect(),b=g?u-g.left:u,h=g?p-g.top:p;m.style.left=`${b}px`,m.style.top=`${h}px`,m.setAttribute("data-open","true");const v=y=>{y.target&&m.contains(y.target)||(m.setAttribute("data-open","false"),document.removeEventListener("click",v,!0),document.removeEventListener("contextmenu",v,!0))};setTimeout(()=>{document.addEventListener("click",v,!0),document.addEventListener("contextmenu",v,!0)},0)};return n.oncontextmenu=u=>{u.preventDefault(),c(u.clientX,u.clientY)},n.onkeydown=u=>{const p=u;if(p.key==="ContextMenu"||p.shiftKey&&p.key==="F10"){p.preventDefault();const m=p.currentTarget.getBoundingClientRect();c(m.left,m.top+m.height)}p.key==="Escape"&&s()},a}},Ed=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function pt(t){const e=t.trim();if(!e)return"";let r=e.startsWith("#")?e.slice(1):e;return r.length===3&&(r=r.split("").map(a=>a+a).join("")),/^[0-9a-fA-F]{6,8}$/.test(r)?`#${r.toLowerCase().slice(0,6)}`:""}const Ld={name:"ColorPicker",description:'Hex / RGB color form control with preset swatches. Pairs a native `<input type="color">` chip with a hex text input and a row of preset swatches. Pass a `$variable` as `value` (hex string, e.g. `"#6366f1"`) for two-way binding. Use for theme builders, label color pickers, and any "pick a color" surface.',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound hex value (typically $variable)"},{name:"label",type:"string",optional:!0},{name:"swatches",type:"string[]",optional:!0,description:"Preset hex colors (default to a 12-color palette)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected hex string"}],render:(t,e,r)=>{const a=f(e.id),n=pt(f(e.value))||f(e.value,"#000000"),i=A(e.disabled),o=l("div",{class:"rui-color-picker","data-disabled":i?"true":"false"}),s=f(e.label);s&&o.append(l("label",{class:"rui-color-picker-label",for:a},[s]));const c=l("div",{class:"rui-color-picker-row"}),u=l("input",{type:"color",class:"rui-color-picker-color",id:a,name:a,value:pt(n)||"#000000",disabled:i?"":null}),p=l("input",{type:"text",class:"rui-color-picker-hex",value:n,placeholder:"#000000",disabled:i?"":null,autocomplete:"off"}),d=l("div",{class:"rui-color-picker-swatches"}),m=$(e.swatches).map(h=>f(h)).filter(Boolean),g=m.length>0?m:Ed;for(const h of g){const v=pt(h)||h,y=l("button",{type:"button",class:"rui-color-picker-swatch",style:`background:${v}`,"aria-label":v,title:v,"data-active":v.toLowerCase()===n.toLowerCase()?"true":"false"});y.onclick=()=>{u.value=pt(v)||u.value,p.value=v,u.dispatchEvent(new Event("input",{bubbles:!0}))},d.append(y)}const b=t.argMeta?.[1]?.stateRef;return b&&!i&&(r.bindState(u,b,{event:"input",getValue:h=>h.value}),u.addEventListener("input",()=>{p.value=u.value}),p.oninput=()=>{const h=pt(p.value);h&&(u.value=h,u.dispatchEvent(new Event("input",{bubbles:!0})))}),i||oe(u,e.onChange,r,{event:"input",getValue:h=>h.value}),c.append(u,p),o.append(c,d),o}},Er=["var(--rui-chart-1, #6366f1)","var(--rui-chart-2, #10b981)","var(--rui-chart-3, #f59e0b)","var(--rui-chart-4, #ef4444)","var(--rui-chart-5, #06b6d4)","var(--rui-chart-6, #8b5cf6)"],qe=t=>Er[t%Er.length]??Er[0];function Rd(t){return t.map((e,r)=>{const a=e,n=f(a.args?.[0],`Series ${r+1}`),i=$(a.args?.[1]).map(o=>E(o));return{name:n,values:i}})}function Ut(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("viewBox",`0 0 ${t} ${e}`),r.setAttribute("class","rui-chart-svg"),r.setAttribute("role","img"),r}function ce(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[n,i]of Object.entries(e))a.setAttribute(n,i);if(r)for(const n of r)a.append(typeof n=="string"?document.createTextNode(n):n);return a}function On(t){const e=l("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const n=l("span",{class:"rui-chart-legend-item"});n.append(l("span",{class:"rui-chart-legend-swatch",style:`background:${qe(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const zd={name:"Gauge",description:"Half-doughnut gauge indicator for a single value between `min` and `max`. The inner value is auto-formatted from the value (override via `label`). Pass `caption`, `tone`, and `size` for visual treatment. Use for KPI thresholds (uptime %, score, capacity, NPS, page-speed).",props:[{name:"value",type:"number"},{name:"min",type:"number",optional:!0,description:"Lower bound (default 0)"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"caption",type:"string",optional:!0,description:"Small caption below the gauge"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"label",type:"string",optional:!0,description:"Inner label override (defaults to auto-formatted value)"}],render:(t,e)=>{const r=E(e.min,0),a=Math.max(r+1,E(e.max,100)),n=Math.max(r,Math.min(a,E(e.value,r))),i=(n-r)/(a-r),o=f(e.tone,"primary"),s=f(e.size,"md"),c=s==="lg"?220:s==="sm"?140:180,u=c/2,p=s==="lg"?18:s==="sm"?10:14,d=u-p,m=l("div",{class:"rui-gauge","data-tone":o,"data-size":s}),g=Ut(c,u+p+4),b=u,h=u,v=b-d,y=h,x=b+d,w=h;if(g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${x},${w}`,fill:"none",stroke:"var(--rui-color-border, #e2e8f0)","stroke-width":String(p),"stroke-linecap":"round"})),i>0){const C=Math.PI*i,N=b-d*Math.cos(C),I=h-d*Math.sin(C);g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${N.toFixed(2)},${I.toFixed(2)}`,fill:"none",stroke:`var(--rui-color-${o}, ${qe(0)})`,"stroke-width":String(p),"stroke-linecap":"round",class:"rui-gauge-arc"}))}m.append(g);const k=Dd(n,r,a),T=f(e.label)||k;m.append(l("div",{class:"rui-gauge-value"},[T]));const S=f(e.caption);return S&&m.append(l("div",{class:"rui-gauge-caption"},[S])),m}};function Dd(t,e,r){return e===0&&r===100?t%1===0?`${t}%`:`${t.toFixed(1)}%`:Math.abs(t)>=1e3?Math.round(t).toLocaleString():t%1===0?String(t):t.toFixed(t<10?2:1)}const jd={name:"Heatmap",description:"Color-intensity matrix grid (calendar-style or correlation-style). Pass `xLabels`, `yLabels`, and a `values` array of arrays (rows × columns). Each cell's color intensity scales with the value relative to the global max. Use for activity heatmaps, schedule density, correlation matrices.",props:[{name:"xLabels",type:"string[]"},{name:"yLabels",type:"string[]"},{name:"values",type:"number[][]",description:"Matrix indexed by row (y), then column (x)"},{name:"title",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]}],render:(t,e)=>{const r=$(e.xLabels).map(p=>f(p)),a=$(e.yLabels).map(p=>f(p)),n=$(e.values).map(p=>$(p).map(d=>E(d,0))),i=f(e.tone,"primary"),o=Math.max(1,...n.flat()),s=l("div",{class:"rui-heatmap","data-tone":i});f(e.title)&&s.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const c=l("div",{class:"rui-heatmap-table"}),u=l("div",{class:"rui-heatmap-row rui-heatmap-row-header"});u.append(l("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const p of r)u.append(l("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[p]));return c.append(u),n.forEach((p,d)=>{const m=l("div",{class:"rui-heatmap-row"});m.append(l("div",{class:"rui-heatmap-cell rui-heatmap-ylabel"},[a[d]??String(d+1)])),p.forEach((g,b)=>{const h=o>0?g/o:0,v=l("div",{class:"rui-heatmap-cell rui-heatmap-value",style:`background:color-mix(in srgb, var(--rui-color-${i}, ${qe(0)}) ${Math.round(h*90+5)}%, transparent);`,title:`${r[b]??b+1} · ${a[d]??d+1}: ${g}`});v.append(l("span",{},[String(g)])),m.append(v)}),c.append(m)}),s.append(c),s}},Bd={name:"RadarChart",description:"Polygon chart with one axis per category. Use for skill maps, scorecards, capability comparisons, and any multi-dimensional snapshot. Each Series renders as a filled polygon — overlapping is expected for comparisons.",props:[{name:"axes",type:"string[]",description:"Category labels — one per radial axis"},{name:"series",type:"Series[]"},{name:"max",type:"number",optional:!0,description:"Outer ring value (default = max across series)"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=$(e.axes).map(g=>f(g)),a=Rd($(e.series)),n=Math.max(r.length,3),i=l("div",{class:"rui-chart rui-radar-chart"});f(e.title)&&i.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const o=Math.max(1,E(e.max,a.flatMap(g=>g.values).reduce((g,b)=>Math.max(g,b),1))),s=280,c=s/2,u=s/2,p=s/2-24,d=Ut(s,s),m=4;for(let g=1;g<=m;g+=1){const b=p/m*g,h=[];for(let v=0;v<n;v+=1){const y=Math.PI*2*v/n-Math.PI/2;h.push(`${(c+b*Math.cos(y)).toFixed(1)},${(u+b*Math.sin(y)).toFixed(1)}`)}d.append(ce("polygon",{points:h.join(" "),fill:"none",stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}))}for(let g=0;g<n;g+=1){const b=Math.PI*2*g/n-Math.PI/2,h=c+p*Math.cos(b),v=u+p*Math.sin(b);d.append(ce("line",{x1:String(c),y1:String(u),x2:h.toFixed(1),y2:v.toFixed(1),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}));const y=c+(p+16)*Math.cos(b),x=u+(p+16)*Math.sin(b);d.append(ce("text",{x:y.toFixed(1),y:x.toFixed(1),"text-anchor":"middle","dominant-baseline":"middle",class:"rui-chart-label","font-size":"13","font-weight":"500"},[r[g]??""]))}return a.forEach((g,b)=>{const h=[];for(let v=0;v<n;v+=1){const y=g.values[v]??0,x=Math.max(0,Math.min(1,y/o)),w=Math.PI*2*v/n-Math.PI/2,k=c+p*x*Math.cos(w),T=u+p*x*Math.sin(w);h.push(`${k.toFixed(1)},${T.toFixed(1)}`)}d.append(ce("polygon",{points:h.join(" "),fill:qe(b),"fill-opacity":"0.2",stroke:qe(b),"stroke-width":"2","stroke-linejoin":"round"}))}),i.append(d),a.length>0&&i.append(On(a)),i}};function Od(t){return t.map((e,r)=>{const a=e,n=f(a.args?.[0],`Series ${r+1}`),i=$(a.args?.[1]).map(o=>{if(Array.isArray(o))return{x:E(o[0],0),y:E(o[1],0),label:f(o[2])};if(o&&typeof o=="object"){const s=o;return{x:E(s.x,0),y:E(s.y,0),label:f(s.label)}}return{x:0,y:0,label:""}});return{name:n,points:i}})}const _d={name:"ScatterChart",description:'XY scatter plot — one dot per data point, optionally grouped by series. Pass each `Series(name, points)` with points as `{x, y, label?}` objects or `[x, y, label?]` tuples. Use for correlations, distributions, and "price vs. rating" style charts.',props:[{name:"series",type:"Series[]"},{name:"xLabel",type:"string",optional:!0},{name:"yLabel",type:"string",optional:!0},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=Od($(e.series)),a=l("div",{class:"rui-chart rui-scatter-chart"});f(e.title)&&a.append(l("div",{class:"rui-chart-title"},[f(e.title)]));const n=640,i=280,o={left:50,right:16,top:16,bottom:40},s=n-o.left-o.right,c=i-o.top-o.bottom,u=r.flatMap(k=>k.points);if(u.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No points"])),a;const p=u.map(k=>k.x),d=u.map(k=>k.y),m=Math.min(...p),g=Math.max(...p),b=Math.min(...d),h=Math.max(...d),v=g-m||1,y=h-b||1,x=Ut(n,i);if(Fn(x,o,s,c,h,b),x.append(ce("line",{x1:String(o.left),y1:String(o.top+c),x2:String(o.left+s),y2:String(o.top+c),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((k,T)=>{k.points.forEach(S=>{const C=o.left+(S.x-m)/v*s,N=o.top+c-(S.y-b)/y*c,I=ce("circle",{cx:C.toFixed(1),cy:N.toFixed(1),r:"7",fill:qe(T),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});I.append(ce("title",{},[S.label||`${S.x}, ${S.y}`])),x.append(I)})}),f(e.xLabel)&&x.append(ce("text",{x:String(o.left+s/2),y:String(i-6),"text-anchor":"middle",class:"rui-chart-label","font-size":"14","font-weight":"500"},[f(e.xLabel)])),f(e.yLabel)){const T=o.top+c/2;x.append(ce("text",{x:String(14),y:String(T),"text-anchor":"middle",transform:`rotate(-90, 14, ${T})`,class:"rui-chart-label","font-size":"14","font-weight":"500"},[f(e.yLabel)]))}a.append(x);const w=r.map(k=>({name:k.name,values:k.points.map(T=>T.y)}));return w.length>0&&a.append(On(w)),a}},Fd={name:"Histogram",description:"Frequency distribution from raw numeric values. Pass `values` directly (the component bins them automatically) or pre-computed `bins` of `{label, count}` objects. Use for response-time histograms, score distributions, age buckets.",props:[{name:"values",type:"number[]",optional:!0,description:"Raw observations (binned automatically)"},{name:"bins",type:"object[]",optional:!0,description:"Pre-computed {label, count} entries (overrides `values`)"},{name:"binCount",type:"number",optional:!0,description:"Number of bins when computing from `values` (default 10)"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{let r=[];if(Array.isArray(e.bins)&&e.bins.length>0)r=e.bins.map(m=>{const g=m??{};return{label:f(g.label),count:E(g.count,0)}});else{const m=$(e.values).map(g=>E(g,NaN)).filter(g=>Number.isFinite(g));if(m.length>0){const g=Math.max(2,Math.min(50,Math.floor(E(e.binCount,10)))),b=Math.min(...m),y=(Math.max(...m)-b||1)/g,x=new Array(g).fill(0);for(const w of m){let k=Math.floor((w-b)/y);k>=g&&(k=g-1),k<0&&(k=0),x[k]+=1}r=x.map((w,k)=>{const T=b+k*y,S=T+y;return{label:`${_n(T)}–${_n(S)}`,count:w}})}}const a=l("div",{class:"rui-chart rui-histogram"});if(f(e.title)&&a.append(l("div",{class:"rui-chart-title"},[f(e.title)])),r.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No data"])),a;const n=640,i=240,o={left:40,right:12,top:16,bottom:50},s=n-o.left-o.right,c=i-o.top-o.bottom,u=Math.max(1,...r.map(m=>m.count)),p=s/r.length,d=Ut(n,i);return Fn(d,o,s,c,u),r.forEach((m,g)=>{const b=o.left+g*p+p*.1,h=p*.8,v=m.count/u*c,y=o.top+c-v,x=ce("rect",{x:b.toFixed(1),y:y.toFixed(1),width:h.toFixed(1),height:v.toFixed(1),fill:qe(0),rx:"2"});x.append(ce("title",{},[`${m.label}: ${m.count}`])),d.append(x),d.append(ce("text",{x:(b+h/2).toFixed(1),y:String(o.top+c+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[m.label]))}),a.append(d),a}};function _n(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function Fn(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const c=s/4,u=e.top+a-c*a;t.append(ce("line",{x1:String(e.left),x2:String(e.left+r),y1:String(u),y2:String(u),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ce("text",{x:String(e.left-8),y:String(u+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((i+(n-i)*c)*10)/10)]))}}const Ud=["numeric","alphanumeric"];function Hd(t,e,r,a,n,i,o){const s=l("div",{class:"rui-pin-input","data-disabled":n?"true":"false"}),c=[];for(let d=0;d<e;d+=1){const m=l("input",{class:"rui-pin-input-slot",id:d===0?t:null,maxlength:"1",autocomplete:"one-time-code",inputmode:r==="numeric"?"numeric":"text",type:i?"password":"text","aria-label":`Digit ${d+1}`,value:a.charAt(d)||"",disabled:n?"":null});c.push(m),s.append(m)}const u=d=>{const m=d.closest(".rui-pin-input");return m?Array.from(m.querySelectorAll(".rui-pin-input-slot")):c},p=d=>u(d).map(m=>m.value).join("").slice(0,e);return c.forEach((d,m)=>{d.oninput=g=>{const b=g.currentTarget,h=u(b);let v=b.value;if(r==="numeric"?v=v.replace(/\D/g,""):v=v.replace(/[^A-Za-z0-9]/g,""),v.length>1){const y=v.split("");y.slice(0,e-m).forEach((w,k)=>{const T=h[m+k];T&&(T.value=w)});const x=Math.min(m+y.length,e-1);h[x]?.focus()}else b.value=v,v&&m<e-1&&h[m+1]?.focus();o?.(p(b))},d.onkeydown=g=>{const b=g,h=b.currentTarget,v=u(h);if(b.key==="Backspace"&&!h.value&&m>0){b.preventDefault(),v[m-1]?.focus();const y=v[m-1];y&&(y.value=""),o?.(p(h))}else b.key==="ArrowLeft"&&m>0?(b.preventDefault(),v[m-1]?.focus()):b.key==="ArrowRight"&&m<e-1&&(b.preventDefault(),v[m+1]?.focus())}}),s}const Vd={name:"PinInput",description:'Per-digit PIN entry. Auto-advances focus as the user types and supports paste. Pass a `$variable` as `value` for two-way binding (the bound value is the joined string). Use `type="numeric"` for PINs / 2FA codes, `"alphanumeric"` for invite codes.',props:[{name:"id",type:"string"},{name:"length",type:"number",optional:!0,description:"Number of slots (default 4)"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"type",type:"string",optional:!0,enum:Ud},{name:"mask",type:"boolean",optional:!0,description:"Render slots as `<input type=password>`"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current joined string on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=Math.max(1,Math.min(12,Math.floor(E(e.length,4)))),i=f(e.type,"numeric"),o=f(e.value),s=A(e.disabled),c=A(e.mask),u=t.argMeta?.[2]?.stateRef;return Hd(a,n,i,o,s,c,p=>{u&&r.setState(u,p),r.invoke(e.onChange,p)})}};function Wd(t){if(!t)return{score:0,label:""};let e=0;return t.length>=8&&(e+=1),t.length>=12&&(e+=1),/[A-Z]/.test(t)&&/[a-z]/.test(t)&&(e+=1),/[0-9]/.test(t)&&(e+=1),/[^A-Za-z0-9]/.test(t)&&(e+=1),e=Math.min(4,e),{score:e,label:["Too short","Weak","Fair","Good","Strong"][e]??""}}const qd={name:"PasswordInput",description:"Password input with a show/hide toggle and an optional strength meter. Pass a `$variable` as `value` for two-way binding. Set `strengthMeter=true` to render a 4-step indicator and label.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"strengthMeter",type:"boolean",optional:!0,aliases:["showStrength"]},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=r.useInstanceState("visible",!1),i=n.get(),o=A(e.disabled),s=l("div",{class:"rui-password-input","data-disabled":o?"true":"false"}),c=f(e.label);c&&s.append(l("label",{class:"rui-password-input-label",for:a},[c]));const u=l("div",{class:"rui-password-input-row"}),p=l("input",{type:i?"text":"password",class:"rui-password-input-field",id:a,name:a,autocomplete:"current-password",placeholder:f(e.placeholder),value:f(e.value),disabled:o?"":null}),d=l("button",{type:"button",class:"rui-password-input-toggle","aria-label":i?"Hide password":"Show password"}),m=j(i?"eye-slash":"eye");m&&d.append(m),d.onclick=b=>{b.preventDefault();const h=!n.get();n.set(h);const x=b.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=h?"text":"password")};const g=t.argMeta?.[1]?.stateRef;if(g&&r.bindState(p,g,{event:"input",getValue:b=>b.value}),oe(p,e.onChange,r,{event:"input",getValue:b=>b.value}),u.append(p),u.append(d),s.append(u),A(e.strengthMeter)){const b=Wd(f(e.value)),h=l("div",{class:"rui-password-input-strength","data-score":String(b.score)});for(let y=0;y<4;y+=1)h.append(l("span",{class:"rui-password-input-strength-bar","data-filled":y<b.score?"true":"false"}));const v=l("div",{class:"rui-password-input-strength-row"});v.append(h),b.label&&v.append(l("span",{class:"rui-password-input-strength-label"},[b.label])),s.append(v)}return s}},Kd={name:"TagInput",description:"Tag/chip input — type a value, press Enter (or comma) to commit, click × on a chip to remove. Pass a `$variable` (array of strings) as `value` for two-way binding. Use for keywords, recipients, labels, skills, allowlists.",props:[{name:"id",type:"string"},{name:"value",type:"string[]",optional:!0,description:"Bound array of tag values"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"max",type:"number",optional:!0,description:"Maximum number of tags"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated array of tags whenever one is added or removed"}],render:(t,e,r)=>{const a=f(e.id),n=$(e.value).map(m=>f(m)).filter(Boolean),i=Math.max(0,Math.floor(E(e.max,0))),o=A(e.disabled),s=t.argMeta?.[1]?.stateRef,c=m=>{s&&r.setState(s,m),r.invoke(e.onChange,m)},u=f(e.label),p=l("div",{class:"rui-tag-input","data-disabled":o?"true":"false"});for(const m of n){const g=l("span",{class:"rui-tag-input-chip"});g.append(l("span",{},[m]));const b=l("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${m}`},["×"]);b.onclick=()=>c(n.filter(h=>h!==m)),g.append(b),p.append(g)}const d=l("input",{type:"text",class:"rui-tag-input-field",id:a,name:a,placeholder:f(e.placeholder,n.length===0?"Add tags…":""),disabled:o?"":null,autocomplete:"off"});if(d.onkeydown=m=>{const g=m,b=g.currentTarget;if(g.key==="Enter"||g.key===","){g.preventDefault();const h=b.value.trim();if(!h||i>0&&n.length>=i)return;if(n.includes(h)){b.value="";return}c([...n,h]),b.value=""}else g.key==="Backspace"&&b.value===""&&n.length>0&&(g.preventDefault(),c(n.slice(0,-1)))},p.append(d),u){const m=l("div",{class:"rui-tag-input-wrapper"});return m.append(l("label",{class:"rui-tag-input-label",for:a},[u])),m.append(p),m}return p}};function Gd(t){return $(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,a=f(r.label??r.name??r.value??r.id);return{value:f(r.handle??r.value??r.id??r.name??r.label),label:a}}return{value:"",label:""}}).filter(e=>e.value||e.label)}const Yd={name:"MentionInput",description:"Multi-line input with inline @-mention suggestions. Typing `@` opens a popover listing the provided `people` (filtered by what follows). Selecting an option inserts `@label` into the text. Pass a `$variable` as `value` for two-way binding. Use for comments, task notes, chat composers.",props:[{name:"id",type:"string"},{name:"people",type:"any[]",description:"Available mentions: strings or {value, label} objects"},{name:"value",type:"string",optional:!0,description:"Bound text (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0,description:"TextArea rows (default 3)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current text on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=Gd(e.people),i=A(e.disabled),o=l("div",{class:"rui-mention-input","data-disabled":i?"true":"false"}),s=l("textarea",{class:"rui-mention-input-field",id:a,name:a,rows:String(Math.max(2,Math.floor(E(e.rows,3)))),placeholder:f(e.placeholder,"Type @ to mention someone"),disabled:i?"":null});s.value=f(e.value);const c=l("div",{class:"rui-mention-input-suggestions","data-open":"false"}),u=r.useInstanceState("activeIndex",0),p=r.useInstanceState("matches",[]),d=r.useInstanceState("query",null),m=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-suggestions")??null,g=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-field")??null,b=(x,w)=>{const k=x.value,T=x.selectionStart??k.length,S=k.slice(0,T),C=S.lastIndexOf("@");if(C===-1)return;const N=k.slice(T),I=`@${w.value} `,L=S.slice(0,C)+I+N;x.value=L;const D=C+I.length;x.selectionStart=x.selectionEnd=D,x.dispatchEvent(new Event("input",{bubbles:!0})),x.focus()},h=(x,w)=>{if(x.replaceChildren(),w===null){x.setAttribute("data-open","false"),p.set([]);return}const k=w.toLowerCase(),S=n.filter(N=>N.label.toLowerCase().includes(k)||N.value.toLowerCase().includes(k)).slice(0,6);if(p.set(S),S.length===0){x.setAttribute("data-open","false");return}const C=Math.min(u.get(),S.length-1);u.set(C),x.setAttribute("data-open","true"),S.forEach((N,I)=>{const L=l("button",{type:"button",class:"rui-mention-input-option","data-value":N.value,"data-active":I===C?"true":"false"});L.append(l("span",{class:"rui-mention-input-option-label"},[N.label])),N.value&&N.value!==N.label&&L.append(l("span",{class:"rui-mention-input-option-handle"},[`@${N.value}`])),L.onmousedown=D=>D.preventDefault(),L.onclick=D=>{const q=D.currentTarget,O=g(q),U=m(q);O&&b(O,N),d.set(null),U&&h(U,null)},x.append(L)})},v=x=>{const w=m(x);if(!w)return;const k=x.selectionStart??x.value.length,T=x.value.slice(0,k),S=/@([\w-]*)$/.exec(T),C=S?S[1]??"":null;d.set(C),h(w,C)},y=t.argMeta?.[2]?.stateRef;return y?r.bindState(s,y,{event:"input",getValue:x=>{const w=x;return v(w),w.value}}):s.oninput=x=>{v(x.currentTarget)},oe(s,e.onChange,r,{event:"input",getValue:x=>x.value}),s.onkeydown=x=>{const w=x.currentTarget,k=m(w);if(!k||k.getAttribute("data-open")!=="true")return;const T=p.get();if(T.length!==0)if(x.key==="ArrowDown"){x.preventDefault();const S=(u.get()+1)%T.length;u.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((N,I)=>N.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="ArrowUp"){x.preventDefault();const S=(u.get()-1+T.length)%T.length;u.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((N,I)=>N.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="Enter"||x.key==="Tab"){x.preventDefault();const S=T[u.get()];S&&(b(w,S),d.set(null),h(k,null))}else x.key==="Escape"&&(d.set(null),h(k,null))},s.onblur=x=>{const w=x.currentTarget;setTimeout(()=>{const k=m(w);d.set(null),k&&h(k,null)},120)},o.append(s),o.append(c),h(c,d.get()),o}},Xd={name:"TimePicker",description:'Time-of-day picker that wraps `<input type="time">`. Pass a `$variable` as `value` for two-way binding (HH:MM 24-hour). Set `step` to constrain to specific increments (e.g. 900 for 15-minute buckets).',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"HH:MM value; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0},{name:"max",type:"string",optional:!0},{name:"step",type:"number",optional:!0,description:"Seconds between selectable times"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new HH:MM string when the user picks a time"}],render:(t,e,r)=>{const a=f(e.id),n=l("div",{class:"rui-time-picker"}),i=f(e.label);i&&n.append(l("label",{class:"rui-time-picker-label",for:a},[i]));const o=l("input",{type:"time",class:"rui-time-picker-input",id:a,name:a,value:f(e.value),min:f(e.min)||null,max:f(e.max)||null,step:e.step!=null?String(E(e.step,60)):null,disabled:A(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),oe(o,e.onChange,r,{event:"change",getValue:c=>c.value}),n.append(o),n}},Jd={name:"DateTimePicker",description:'Combined date + time picker — wraps `<input type="datetime-local">`. Pass a `$variable` as `value` for two-way binding (ISO `YYYY-MM-DDTHH:MM`).',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"ISO date-time value; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0},{name:"max",type:"string",optional:!0},{name:"step",type:"number",optional:!0,description:"Seconds between selectable times"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new ISO `YYYY-MM-DDTHH:MM` string"}],render:(t,e,r)=>{const a=f(e.id),n=l("div",{class:"rui-datetime-picker"}),i=f(e.label);i&&n.append(l("label",{class:"rui-datetime-picker-label",for:a},[i]));const o=l("input",{type:"datetime-local",class:"rui-datetime-picker-input",id:a,name:a,value:f(e.value),min:f(e.min)||null,max:f(e.max)||null,step:e.step!=null?String(E(e.step,60)):null,disabled:A(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),oe(o,e.onChange,r,{event:"change",getValue:c=>c.value}),n.append(o),n}};function Un(t,e){if(!e)return t;let r="",a=0;const n=String(t??"");for(const i of e){if(a>=n.length)break;if(i==="9"){for(;a<n.length&&!/\d/.test(n[a]??"");)a+=1;if(a>=n.length)break;r+=n[a],a+=1}else if(i==="A"){for(;a<n.length&&!/[a-zA-Z]/.test(n[a]??"");)a+=1;if(a>=n.length)break;r+=n[a],a+=1}else i==="*"?(r+=n[a],a+=1):(r+=i,n[a]===i&&(a+=1))}return r}const Zd={name:"MaskedInput",description:'Text input with an inline mask — `9` matches a digit, `A` matches a letter, `*` matches any character, every other character is a fixed delimiter. Useful for phone numbers, postal codes, credit cards. Pass `mask` (e.g. `"(999) 999-9999"`) and a `$variable` as `value`.',props:[{name:"id",type:"string"},{name:"mask",type:"string",description:"Mask pattern"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the masked value on every keystroke"}],render:(t,e,r)=>{const a=f(e.id),n=f(e.mask),i=A(e.disabled),o=Un(f(e.value),n),s=f(e.label),c=l("input",{type:"text",class:"rui-masked-input",id:a,name:a,value:o,placeholder:f(e.placeholder,n),disabled:i?"":null,autocomplete:"off"});c.value=o;const u=t.argMeta?.[2]?.stateRef,p=d=>{const m=d.value,g=Un(m,n);if(g===m)return g;const b=d.selectionStart??g.length;d.value=g;const h=Math.min(g.length,b);try{d.setSelectionRange(h,h)}catch{}return g};if(u?r.bindState(c,u,{event:"input",getValue:d=>p(d)}):c.oninput=d=>{p(d.currentTarget??d.target)},oe(c,e.onChange,r,{event:"input",getValue:d=>d.value}),s){const d=l("div",{class:"rui-masked-input-wrapper"});return d.append(l("label",{class:"rui-masked-input-label",for:a},[s])),d.append(c),d}return c}},Qd={name:"FormSection",description:"Semantic grouping for related form fields — renders a small heading (`label`), optional helper paragraph, and stacks the children with consistent spacing. Use INSTEAD of wrapping fields in `Card` + `SectionHeader` by hand. Pair with `FieldSet` when the group is a true `<fieldset>` (radio sets, checkbox groups).",props:[{name:"label",type:"string",aliases:["title"]},{name:"children",type:"Node[]",aliases:["fields"]},{name:"helper",type:"string",optional:!0,aliases:["description"],description:"Description rendered below the label"}],render:(t,e,r)=>{const a=l("section",{class:"rui-form-section"}),n=l("header",{class:"rui-form-section-header"});n.append(l("h3",{class:"rui-form-section-label"},[f(e.label)]));const i=f(e.helper);i&&n.append(l("p",{class:"rui-form-section-helper"},[i])),a.append(n);const o=l("div",{class:"rui-form-section-body"});for(const s of $(e.children))o.append(r.renderNode(s));return a.append(o),a}},ep={name:"FieldSet",description:"Native `<fieldset>`/`<legend>` wrapper for accessible grouping of related controls. Use when assistive tech should announce the wrapper (radio sets, checkbox groups). For purely visual grouping prefer `FormSection`.",props:[{name:"legend",type:"string",aliases:["title","label"]},{name:"children",type:"Node[]",aliases:["fields"]},{name:"helper",type:"string",optional:!0,aliases:["hint","description"]},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("fieldset",{class:"rui-fieldset",disabled:A(e.disabled)?"":null});a.append(l("legend",{class:"rui-fieldset-legend"},[f(e.legend)]));const n=f(e.helper);n&&a.append(l("p",{class:"rui-fieldset-helper"},[n]));for(const i of $(e.children))a.append(r.renderNode(i));return a}},tp={name:"ValidationSummary",description:"Aggregate error list rendered at the top of a form. Pass `errors` as `{label?, message, field?}` objects or plain strings. Pair with individual field hints via `FormControl(hint=...)`.",props:[{name:"errors",type:"any[]"},{name:"title",type:"string",optional:!0,description:'Heading (default "Please fix the following:")'},{name:"tone",type:"string",optional:!0,enum:["danger","warning"]}],render:(t,e)=>{const r=$(e.errors).map(c=>{if(!c)return null;if(typeof c=="string")return{label:"",message:c,field:""};if(typeof c=="object"){const u=c;return{label:f(u.label),message:f(u.message??u.error),field:f(u.field)}}return null}).filter(c=>c!==null&&c.message!=="");if(r.length===0)return l("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const a=f(e.tone,"danger"),n=l("aside",{class:"rui-validation-summary","data-tone":a,role:"alert"}),i=l("div",{class:"rui-validation-summary-title"}),o=j(a==="warning"?"triangle-exclamation":"circle-xmark",{className:"rui-validation-summary-icon"});o&&i.append(o),i.append(document.createTextNode(f(e.title,"Please fix the following:"))),n.append(i);const s=l("ul",{class:"rui-validation-summary-list"});for(const c of r){const u=l("li",{class:"rui-validation-summary-item"});c.label&&u.append(l("strong",{},[`${c.label}: `])),u.append(document.createTextNode(c.message)),s.append(u)}return n.append(s),n}};function rp(t){return $(t).map(e=>{if(!e||typeof e!="object")return{title:f(e),details:"",content:null};const r=e;return{title:f(r.title),details:f(r.details),content:r.content??null}})}const ap={name:"MultiStepForm",description:'Multi-step / wizard form composite. Renders a `Steps` indicator, the active step\'s `content`, and Prev/Next buttons that drive a `$variable` for the current 0-indexed step. Use INSTEAD of hand-rolling `Steps` + content + manual prev/next wiring. The submit button is rendered on the final step (override via `submitLabel`). Step indicator direction defaults to `column` (stacked next to the content); set `stepsLayout: "row"` for a classic horizontal stepper.',props:[{name:"steps",type:"object[]",description:"Array of {title, details?, content} step objects"},{name:"current",type:"number",description:"0-indexed active step — bind a $variable"},{name:"onSubmit",type:"callable",optional:!0,description:"Callable fired when the user clicks Submit on the final step"},{name:"prevLabel",type:"string",optional:!0,description:'Default "Back"'},{name:"nextLabel",type:"string",optional:!0,description:'Default "Continue"'},{name:"submitLabel",type:"string",optional:!0,description:'Default "Submit" (final step)'},{name:"stepsLayout",type:"string",optional:!0,enum:["column","row"],aliases:["layout","stepsDirection"],description:'Direction of the steps indicator (default "column")'}],render:(t,e,r)=>{const a=rp(e.steps),n=a.length,i=Math.max(0,Math.min(n-1,Math.floor(E(e.current,0)))),o=t.argMeta?.[1]?.stateRef,s=f(e.stepsLayout,"column").toLowerCase(),c=s==="row"||s==="horizontal"?"row":"column",u=l("div",{class:"rui-multi-step-form","data-layout":c}),p=l("ol",{class:"rui-steps rui-multi-step-form-steps","data-layout":c});a.forEach((x,w)=>{const k=l("li",{class:"rui-steps-item","data-active":w===i?"true":"false","data-complete":w<i?"true":"false"});k.append(l("div",{class:"rui-steps-title"},[x.title||`Step ${w+1}`])),x.details&&k.append(l("div",{class:"rui-steps-details"},[x.details])),p.append(k)}),u.append(p);const d=l("div",{class:"rui-multi-step-form-body"}),m=a[i];m&&m.content&&d.append(r.renderNode(m.content)),u.append(d);const g=l("div",{class:"rui-multi-step-form-footer"}),b=l("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:i<=0?"":null},[f(e.prevLabel,"Back")]);o&&i>0&&(b.onclick=()=>r.setState(o,i-1));const h=i>=n-1,v=h?f(e.submitLabel,"Submit"):f(e.nextLabel,"Continue"),y=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[v]);return y.onclick=()=>{h?r.invoke(e.onSubmit):o&&r.setState(o,i+1)},g.append(b),g.append(l("span",{class:"rui-multi-step-form-progress"},[`${i+1} / ${n}`])),g.append(y),u.append(g),u}};function np(t){return $(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:f(r.title),message:f(r.message),time:f(r.time),icon:f(r.icon),tone:f(r.tone,"default"),unread:A(r.unread),avatarSrc:f(r.avatarSrc),onClick:r.onClick??r.action}}).filter(e=>e!==null)}const ip={name:"InboxPanel",description:"Grouped notification list — entries are grouped into Unread/Earlier sections, with a count chip on each group header. Pass `items` as `{title, message, time, icon?, tone?, unread?, avatarSrc?, onClick?}` objects (`action` is also accepted as an alias). Pair with a `SectionHeader` for the panel title (the component does not render its own title to avoid duplication). Use for top-bar notification trays, activity drawers, and alert center pages.",props:[{name:"items",type:"object[]"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when there are no notifications"},{name:"onMarkAllRead",type:"callable",optional:!0,description:'Callable fired by the "Mark all as read" button'}],render:(t,e,r)=>{const a=np(e.items),n=a.filter(c=>c.unread),i=a.filter(c=>!c.unread),o=l("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&n.length>0){const c=l("div",{class:"rui-inbox-panel-toolbar"}),u=l("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);u.onclick=()=>r.invoke(e.onMarkAllRead),c.append(u),o.append(c)}if(a.length===0)return o.append(l("div",{class:"rui-inbox-panel-empty"},[f(e.emptyLabel,"You're all caught up.")])),o;const s=(c,u)=>{if(u.length===0)return;const p=l("section",{class:"rui-inbox-panel-group"}),d=l("header",{class:"rui-inbox-panel-group-head"});d.append(l("span",{class:"rui-inbox-panel-group-label"},[c])),d.append(l("span",{class:"rui-inbox-panel-group-count"},[String(u.length)])),p.append(d);for(const m of u){const g=kn.render({__kind:"Component",name:"Notification",args:[],argMeta:[]},{title:m.title,message:m.message,time:m.time,icon:m.icon,tone:m.tone,avatarSrc:m.avatarSrc,unread:m.unread},r);typeof m.onClick=="function"&&(g.setAttribute("data-clickable","true"),g.onclick=()=>r.invoke(m.onClick)),p.append(g)}o.append(p)};return s(`Unread (${n.length})`,n),s("Earlier",i),o}};function op(t){return $(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:f(r.title),description:f(r.description),done:A(r.done),onClick:r.onClick??r.action,cta:f(r.cta,"Start")}}).filter(e=>e!==null)}const sp={name:"OnboardingChecklist",description:'Step-by-step product checklist with completion progress at the top. Pass `items` as `{title, description?, done?, onClick?, cta?}` objects (`action` is also accepted as an alias). The progress percentage is computed automatically from `done`. Use on first-run dashboards, empty workspaces, and "complete your profile" surfaces.',props:[{name:"items",type:"object[]"},{name:"title",type:"string",optional:!0,description:'Heading (default "Getting started")'},{name:"subtitle",type:"string",optional:!0}],render:(t,e,r)=>{const a=op(e.items),n=a.filter(d=>d.done).length,i=Math.max(1,a.length),o=Math.round(n/i*100),s=l("div",{class:"rui-onboarding-checklist"}),c=l("header",{class:"rui-onboarding-checklist-header"});c.append(l("h3",{class:"rui-onboarding-checklist-title"},[f(e.title,"Getting started")]));const u=f(e.subtitle);u&&c.append(l("p",{class:"rui-onboarding-checklist-subtitle"},[u])),c.append(l("div",{class:"rui-onboarding-checklist-progress"},[l("div",{class:"rui-onboarding-checklist-bar"},[l("div",{class:"rui-onboarding-checklist-fill",style:`width:${o}%`})]),l("span",{class:"rui-onboarding-checklist-meta"},[`${n}/${a.length} complete`])])),s.append(c);const p=l("ol",{class:"rui-onboarding-checklist-list"});for(const d of a){const m=l("li",{class:"rui-onboarding-checklist-item","data-done":d.done?"true":"false"}),g=l("span",{class:"rui-onboarding-checklist-marker"}),b=j(d.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});b&&g.append(b),m.append(g);const h=l("div",{class:"rui-onboarding-checklist-body"});if(h.append(l("div",{class:"rui-onboarding-checklist-item-title"},[d.title])),d.description&&h.append(l("p",{class:"rui-onboarding-checklist-item-description"},[d.description])),m.append(h),!d.done&&typeof d.onClick=="function"){const v=l("button",{type:"button",class:"rui-button","data-variant":"secondary","data-size":"sm"},[d.cta]);v.onclick=()=>r.invoke(d.onClick),m.append(v)}p.append(m)}return s.append(p),s}};function Hn(t){const e=l("div",{class:`rui-${t.klass}`});if(t.iconName){const a=j(t.iconName,{className:t.iconClass});a&&e.append(a)}t.title&&e.append(l("h3",{class:`rui-${t.klass}-title`},[t.title])),t.description&&e.append(l("p",{class:`rui-${t.klass}-description`},[t.description]));const r=$(t.actions);if(r.length>0){const a=l("div",{class:`rui-${t.klass}-actions`});for(const n of r)a.append(t.helpers.renderNode(n));e.append(a)}return e}const lp={name:"LoadingState",description:"Full-card loading state — large spinner + title + description. Use while a query is in flight or while a long-running tool runs. For tiny inline loaders prefer `Spinner`; for skeleton placeholders prefer `Skeleton`.",props:[{name:"title",type:"string",optional:!0,description:'Default "Loading…"'},{name:"description",type:"string",optional:!0}],render:(t,e)=>{const r=l("div",{class:"rui-loading-state"}),a=l("span",{class:"rui-spinner","data-size":"lg","data-tone":"primary"});a.append(l("span",{class:"rui-spinner-ring","aria-hidden":"true"})),r.append(a),r.append(l("h3",{class:"rui-loading-state-title"},[f(e.title,"Loading…")]));const n=f(e.description);return n&&r.append(l("p",{class:"rui-loading-state-description"},[n])),r}},cp={name:"ErrorState",description:"Full-card error placeholder. Pairs a danger icon with title, description, and a row of recovery actions (Retry / Contact support / Go home). Pass `actions` as Button(...) entries.",props:[{name:"title",type:"string",optional:!0,description:'Default "Something went wrong"'},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon (default `circle-exclamation`)"}],render:(t,e,r)=>Hn({klass:"error-state",iconName:f(e.icon,"circle-exclamation"),iconClass:"rui-error-state-icon",title:f(e.title,"Something went wrong"),description:f(e.description),actions:e.actions,helpers:r})},up={name:"SuccessState",description:'Full-card success placeholder. Use for confirmation screens ("Order placed", "Payment succeeded", "Account verified") at the end of a flow. Pass `actions` for follow-up CTAs.',props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Default `circle-check`"}],render:(t,e,r)=>Hn({klass:"success-state",iconName:f(e.icon,"circle-check"),iconClass:"rui-success-state-icon",title:f(e.title),description:f(e.description),actions:e.actions,helpers:r})},dp={name:"Tour",description:"Product-tour controller — renders the current step's title, description, and a Prev/Next/Skip row. Bind `current` to a `$variable` (0-indexed). Pass `steps` as `{title, description, target?}` objects; the optional `target` is a CSS selector that renders alongside the step for designers to reference.",props:[{name:"steps",type:"object[]"},{name:"current",type:"number",description:"0-indexed active step — bind a $variable"},{name:"open",type:"boolean",optional:!0,description:"Whether the tour is visible"},{name:"onComplete",type:"callable",optional:!0}],render:(t,e,r)=>{const a=$(e.steps).map(v=>{if(!v||typeof v!="object")return{title:f(v),description:"",target:""};const y=v;return{title:f(y.title),description:f(y.description),target:f(y.target)}}),n=e.open===void 0?!0:A(e.open),i=a.length,o=Math.max(0,Math.min(i-1,Math.floor(E(e.current,0)))),s=t.argMeta?.[1]?.stateRef,c=l("div",{class:"rui-tour","data-open":n?"true":"false"});if(!n||i===0)return c;const u=a[o];if(!u)return c;const p=l("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});p.append(l("div",{class:"rui-tour-step"},[`Step ${o+1} of ${i}`])),p.append(l("h3",{class:"rui-tour-title"},[u.title])),u.description&&p.append(l("p",{class:"rui-tour-description"},[u.description])),u.target&&p.append(l("div",{class:"rui-tour-target"},[`Target: ${u.target}`]));const d=l("div",{class:"rui-tour-footer"}),m=l("button",{type:"button",class:"rui-button","data-variant":"ghost"},["Skip"]);m.onclick=()=>r.invoke(e.onComplete);const g=l("button",{type:"button",class:"rui-button","data-variant":"secondary",disabled:o<=0?"":null},["Back"]);s&&o>0&&(g.onclick=()=>r.setState(s,o-1));const b=o>=i-1,h=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[b?"Finish":"Next"]);return h.onclick=()=>{b?r.invoke(e.onComplete):s&&r.setState(s,o+1)},d.append(m,g,h),p.append(d),c.append(p),c}},pp={name:"Spotlight",description:'Single-step product highlight — a dimmed full-page overlay with a ring around the focused area and a small explainer card. Use for one-off feature reveals ("Try the new commands menu"). Bind `open` to a `$variable` to dismiss.',props:[{name:"title",type:"string"},{name:"open",type:"boolean",optional:!0,description:"Whether the spotlight is visible — typically a $variable (default true)"},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0,aliases:["action"]}],render:(t,e,r)=>{const a=e.open===void 0?!0:A(e.open),n=l("div",{class:"rui-spotlight","data-open":a?"true":"false"});if(!a)return n;const i=l("div",{class:"rui-spotlight-card"});i.append(l("h3",{class:"rui-spotlight-title"},[f(e.title)]));const o=f(e.description);o&&i.append(l("p",{class:"rui-spotlight-description"},[o]));const s=$(e.actions);if(s.length>0){const u=l("div",{class:"rui-spotlight-actions"});for(const p of s)u.append(r.renderNode(p));i.append(u)}const c=t.argMeta?.[1]?.stateRef;return c&&(n.onclick=u=>{u.target===n&&r.setState(c,!1)}),n.append(i),n}},mp={name:"Sticky",description:"Wraps content in a `position: sticky` container so it pins to the top (or bottom) of the nearest scrollable ancestor. Use for toolbar action rows above tables, in-page navs, status banners.",props:[{name:"children",type:"Node[]"},{name:"side",type:"string",optional:!0,enum:["top","bottom"]},{name:"offset",type:"string",optional:!0,description:"CSS offset (default 0)"},{name:"zIndex",type:"number",optional:!0,description:"Z-index (default 10)"}],render:(t,e,r)=>{const a=f(e.side,"top"),n=re(e.offset,"0"),i=Math.max(0,Math.floor(E(e.zIndex,10))),o=`position:sticky;${a}:${n};z-index:${i};`,s=l("div",{class:"rui-sticky",style:o});for(const c of $(e.children))s.append(r.renderNode(c));return s}},fp={name:"ResizablePanels",description:"Two-pane horizontal split with a draggable divider. The user can drag the divider to resize the primary pane; defaults respect the starting width. Use for code editors, file browsers, master/detail layouts that need user-controllable proportions.",props:[{name:"primary",type:"Node[]"},{name:"secondary",type:"Node[]"},{name:"initialPrimaryWidth",type:"string",optional:!0,description:"CSS width for the primary pane (default 40%)"},{name:"minPrimaryWidth",type:"string",optional:!0,description:"Min width (default 240px)"}],render:(t,e,r)=>{const a=re(e.initialPrimaryWidth,"40%"),n=re(e.minPrimaryWidth,"240px"),i=l("div",{class:"rui-resizable-panels",style:`--rui-resizable-primary:${a};--rui-resizable-min:${n};`}),o=l("div",{class:"rui-resizable-panel rui-resizable-panel-primary"});for(const u of $(e.primary))o.append(r.renderNode(u));const s=l("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),c=l("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const u of $(e.secondary))c.append(r.renderNode(u));return i.append(o,s,c),s.onpointerdown=u=>{const p=u,d=p.currentTarget;d.setPointerCapture(p.pointerId);const m=d.closest(".rui-resizable-panels");if(!m)return;const g=m.getBoundingClientRect(),b=v=>{const y=(v.clientX-g.left)/g.width*100,x=Math.max(15,Math.min(85,y));m.style.setProperty("--rui-resizable-primary",`${x}%`)},h=v=>{d.releasePointerCapture(v.pointerId),d.removeEventListener("pointermove",b),d.removeEventListener("pointerup",h)};d.addEventListener("pointermove",b),d.addEventListener("pointerup",h)},i}},gp={name:"MasonryGrid",description:"Pinterest-style column grid. Children flow into columns that reflow on viewport changes. Use for galleries, social-style feeds, and mixed-height card walls. Prefer `Grid` when children should share the same height per row.",props:[{name:"items",type:"Node[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default 3)"},{name:"gap",type:"string",optional:!0,enum:["xs","s","m","l","xl"]}],render:(t,e,r)=>{const a=Math.max(1,Math.min(6,Math.floor(E(e.columns,3)))),n=f(e.gap,"m"),i=l("div",{class:"rui-masonry-grid","data-columns":String(a),"data-gap":n});for(const o of $(e.items))i.append(r.renderNode(o));return i}},hp={name:"Drawer",description:"Side drawer overlay shown when `open` is true. Pass a `$variable` as `open` to control it. Choose `side` for slide direction (default right). `onClose` fires whenever the drawer is dismissed (× button or backdrop click).",props:[{name:"title",type:"string"},{name:"open",type:"boolean",description:"Open/closed state — usually a $variable"},{name:"children",type:"Node[]"},{name:"side",type:"string",optional:!0,enum:["right","left","top","bottom"]},{name:"footer",type:"Node[]",optional:!0,description:"Optional footer actions row"},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"],description:"Callable invoked when the drawer is dismissed"}],render:(t,e,r)=>{const a=A(e.open),n=f(e.side,"right"),i=l("div",{class:"rui-sheet-overlay","data-open":a?"true":"false","data-side":n}),o=l("aside",{class:"rui-sheet",role:"dialog","aria-modal":"true","data-side":n}),s=l("header",{class:"rui-sheet-header"});s.append(l("h3",{class:"rui-sheet-title"},[f(e.title)]));const c=l("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),u=t.argMeta?.[1]?.stateRef,p=()=>{u&&r.setState(u,!1),r.invoke(e.onClose)};c.onclick=p,i.onclick=g=>{g.target===i&&p()},s.append(c),o.append(s);const d=l("div",{class:"rui-sheet-body"});for(const g of $(e.children))d.append(r.renderNode(g));o.append(d);const m=$(e.footer);if(m.length>0){const g=l("footer",{class:"rui-sheet-footer"});for(const b of m)g.append(r.renderNode(b));o.append(g)}return i.append(o),i}},bp={name:"TopBar",description:'Compact header strip that pairs a title (or breadcrumb) with search and action slots. Use INSTEAD of hand-rolling a `Stack(direction="row")` above a page. For full SaaS shells use `Navbar` (links) or `AppShell` (sidebar + topbar + content).',props:[{name:"title",type:"string",optional:!0},{name:"subtitle",type:"string",optional:!0},{name:"left",type:"Node[]",optional:!0,aliases:["badges"],description:"Leading slot (breadcrumbs, brand, status, badges)"},{name:"center",type:"Node[]",optional:!0,aliases:["search"],description:"Centered slot (search bar, segmented control)"},{name:"right",type:"Node[]",optional:!0,aliases:["actions"],description:"Trailing slot (actions, avatar)"},{name:"sticky",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("header",{class:"rui-topbar","data-sticky":A(e.sticky)?"true":"false"}),n=l("div",{class:"rui-topbar-side rui-topbar-left"}),i=f(e.title);if(i){const c=l("div",{class:"rui-topbar-title-block"});c.append(l("h2",{class:"rui-topbar-title"},[i]));const u=f(e.subtitle);u&&c.append(l("p",{class:"rui-topbar-subtitle"},[u])),n.append(c)}for(const c of $(e.left))n.append(r.renderNode(c));a.append(n);const o=$(e.center);if(o.length>0){const c=l("div",{class:"rui-topbar-side rui-topbar-center"});for(const u of o)c.append(r.renderNode(u));a.append(c)}const s=l("div",{class:"rui-topbar-side rui-topbar-right"});for(const c of $(e.right))s.append(r.renderNode(c));return a.append(s),a}},vp={name:"NavLink",description:'Anchor that navigates to a route on click and stays in sync with the URL hash. Reflects `data-active="true"` (and `aria-current="page"` for assistive tech) when the current path matches `to` (set `exact=true` to require exact equality instead of prefix matching).',props:[{name:"label",type:"string",description:"Visible link text."},{name:"to",type:"string",description:'Target route path, e.g. "/about".'},{name:"variant",type:"string",optional:!0,enum:["default","primary","ghost","pill"],description:"Visual variant."},{name:"exact",type:"boolean",optional:!0,description:"Match the current path exactly (default: prefix match)."},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown before the label."}],render:(t,e,r)=>{const a=f(e.label,""),n=f(e.to,"/"),i=f(e.variant,"default"),o=A(e.exact,!1),s=r.router,c=s.getPath(),u=c?o?c===n:n==="/"?c==="/":c===n?!0:c.startsWith(n+"/"):!1,p=l("a",{class:"rui-nav-link","data-variant":i,"data-active":u?"true":"false","aria-current":u?"page":null,href:"#"+(n.startsWith("/")?n:"/"+n)}),d=j(e.icon,{className:"rui-nav-link-icon"});return d&&p.append(d),p.append(l("span",{class:"rui-nav-link-label"},[a])),p.onclick=m=>{m.defaultPrevented||m.button===0&&(m.metaKey||m.ctrlKey||m.shiftKey||m.altKey||(m.preventDefault(),s.navigate(n)))},p}},yp=["primary","secondary","ghost","danger"],xp=["xs","sm","md","lg","xl","small","normal","large"];function wp(t){const e=f(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="small"||e==="sm"?"sm":e==="large"||e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":e==="normal"||e==="md"||e===""?"md":e==="xs"||e==="sm"||e==="md"||e==="lg"||e==="xl"?e:"md"}function kp(t){return $(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=f(a.value??a.label);return{value:n,label:f(a.label,n)}}const r=f(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function Ht(t){return $(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function Sp(t){return $(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=f(a.value??a.label);return{value:n,label:f(a.label,n),group:f(a.group)||void 0,shortcut:f(a.shortcut)||void 0,action:a.action}}const r=f(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function Vn(t){return $(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=f(a.name??a.label);return{name:n,label:f(a.label,n),type:f(a.type,"text")||"text"}}const r=f(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function $p(t){return Ht(t).map((e,r)=>({id:f(e.id,`task-${r}`),label:f(e.label??e.name,`Task ${r+1}`),start:f(e.start),end:f(e.end),progress:e.progress!=null?E(e.progress,0):void 0}))}function Ke(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function Cp(t,e){const r=t.split(`
|
|
98
98
|
`),a=e.split(`
|
|
99
|
-
`),n=Math.max(r.length,a.length),i=[];for(let o=0;o<n;o++){const s=r[o],c=a[o];s===c?s!==void 0&&i.push({type:"same",text:s}):(s!==void 0&&i.push({type:"remove",text:s}),c!==void 0&&i.push({type:"add",text:c}))}return i}function Fn(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Un(t,e,r,a){for(const[n,i]of e){const o=l("div",{class:"rui-json-tree-row"});o.append(l("span",{class:"rui-json-tree-key"},[`${n}: `])),i!==null&&typeof i=="object"?o.append(Hn(i,r,a+1)):o.append(l("span",{class:"rui-json-tree-leaf"},[Fn(i)])),t.append(o)}}function Hn(t,e,r=0){const a=l("div",{class:"rui-json-tree-node","data-depth":String(r)});if(t===null||typeof t!="object")return a.append(l("span",{class:"rui-json-tree-leaf"},[Fn(t)])),a;const n=Array.isArray(t),i=n?t.map((u,p)=>[String(p),u]):Object.entries(t),o=e||r<1,s=l("button",{type:"button",class:"rui-json-tree-toggle","aria-expanded":o?"true":"false"},[o?"▼":"▶",n?` Array(${i.length})`:" Object"]),c=l("div",{class:"rui-json-tree-children","data-open":o?"true":"false"});return o&&Un(c,i,e,r),s.onclick=u=>{const p=u.currentTarget,d=p.nextElementSibling;if(!d)return;const m=d.getAttribute("data-open")!=="true";d.setAttribute("data-open",m?"true":"false"),p.setAttribute("aria-expanded",m?"true":"false"),p.firstChild&&(p.firstChild.textContent=m?"▼":"▶"),m&&d.childElementCount===0?Un(d,i,e,r):m||d.replaceChildren()},a.append(s,c),a}const vp={name:"IconButton",description:"Icon-only button with an accessible label. Use for toolbars, table row actions, and compact controls.",props:[{name:"icon",type:"string",description:"Font Awesome icon name"},{name:"label",type:"string",description:"Accessible label (visually hidden)"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:dp},{name:"size",type:"string",optional:!0,enum:pp},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("button",{class:"rui-icon-button",type:"button","data-variant":f(e.variant,"ghost"),"data-size":mp(e.size),"aria-label":f(e.label),title:f(e.label),disabled:A(e.disabled)?"":null}),n=j(e.icon,{className:"rui-icon-button-icon"});return n&&a.append(n),a.onclick=()=>r.invoke(e.onClick),a}},yp={name:"CommandPalette",description:"Cmd-K style searchable command list. Pass `items` as `{label, value, group?, shortcut?, action?}` objects.",props:[{name:"items",type:"any[]"},{name:"open",type:"boolean",optional:!0,description:"Whether the palette is visible (default true)"},{name:"placeholder",type:"string",optional:!0},{name:"shortcut",type:"string",optional:!0,description:"Hint label, e.g. Cmd+K"}],render:(t,e,r)=>{const a=gp(e.items),n=e.open!==void 0,i=n?A(e.open):!0,o=r.useInstanceState("open",i);n&&o.get()!==i&&o.set(i);const s=r.useInstanceState("filter",""),c=n?i:o.get(),u=l("div",{class:"rui-command-palette","data-open":c?"true":"false"});if(!c)return u;const p=l("div",{class:"rui-command-palette-backdrop"}),d=l("div",{class:"rui-command-palette-panel",role:"dialog","aria-modal":"true"}),m=l("div",{class:"rui-command-palette-header"}),g=l("input",{type:"text",class:"rui-command-palette-input",placeholder:f(e.placeholder,"Search commands…"),value:s.get(),autocomplete:"off"});m.append(g);const b=f(e.shortcut);b&&m.append(l("span",{class:"rui-command-palette-shortcut"},[b])),d.append(m);const h=l("div",{class:"rui-command-palette-list",role:"listbox"}),v=(y,x)=>{y.replaceChildren();const w=x.trim().toLowerCase(),k=w===""?a:a.filter(S=>S.label.toLowerCase().includes(w)||S.value.toLowerCase().includes(w)||(S.group??"").toLowerCase().includes(w));let T="";for(const S of k.slice(0,50)){S.group&&S.group!==T&&(T=S.group,y.append(l("div",{class:"rui-command-palette-group"},[T])));const C=l("button",{type:"button",class:"rui-command-palette-item",role:"option","data-value":S.value},[S.label]);S.shortcut&&C.append(l("span",{class:"rui-command-palette-item-kbd"},[S.shortcut])),C.onclick=N=>{N.stopPropagation(),r.invoke(S.action),o.set(!1),s.set("");const I=N.currentTarget.closest(".rui-command-palette"),L=I?.querySelector(".rui-command-palette-panel");I?.setAttribute("data-open","false"),Ne(L??null)},y.append(C)}k.length===0&&y.append(l("div",{class:"rui-command-palette-empty"},["No commands found"]))};return v(h,s.get()),d.append(h),p.onclick=y=>{const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ne(w??null)},u.append(p,d),g.oninput=y=>{const x=y.currentTarget,w=x.closest(".rui-command-palette-panel")?.querySelector(".rui-command-palette-list");s.set(x.value),w&&v(w,x.value)},g.onkeydown=y=>{if(y.key==="Escape"){const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ne(w??null)}},setTimeout(()=>g.focus(),0),rt({liveRoot:d,onDismiss:()=>{o.set(!1),u.setAttribute("data-open","false")}}),u}},xp={name:"FilterChips",description:"Removable filter chips with an optional clear-all control.",props:[{name:"chips",type:"any[]",description:"Array of strings or {label, value} objects"},{name:"onRemove",type:"callable",optional:!0,description:"Receives the removed chip value as an argument"},{name:"onClear",type:"callable",optional:!0}],render:(t,e,r)=>{const a=fp(e.chips),n=l("div",{class:"rui-filter-chips"}),i=l("div",{class:"rui-filter-chips-row"});for(const o of a){const s=l("span",{class:"rui-filter-chip","data-value":o.value});s.append(l("span",{class:"rui-filter-chip-label"},[o.label]));const c=l("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${o.label}`}),u=j("xmark",{className:"rui-filter-chip-remove-icon"});u&&c.append(u),c.onclick=()=>r.invoke(e.onRemove,o.value),s.append(c),i.append(s)}if(n.append(i),a.length>0&&typeof e.onClear=="function"){const o=l("button",{type:"button",class:"rui-filter-chips-clear"},["Clear all"]);o.onclick=()=>r.invoke(e.onClear),n.append(o)}return n}},wp={name:"FieldRepeater",description:"Dynamic list of field groups. Pass `items` as row objects and `fields` as `{name, label, type?}` definitions.",props:[{name:"items",type:"any[]"},{name:"fields",type:"any[]"},{name:"onAdd",type:"callable",optional:!0},{name:"onRemove",type:"callable",optional:!0,description:"Receives the removed row's 0-indexed position"},{name:"addLabel",type:"string",optional:!0}],render:(t,e,r)=>{const a=Ft(e.items),n=_n(e.fields),i=l("div",{class:"rui-field-repeater"});if(a.forEach((o,s)=>{const c=l("div",{class:"rui-field-repeater-row","data-index":String(s)}),u=l("div",{class:"rui-field-repeater-grid"});for(const p of n){const d=l("label",{class:"rui-field-repeater-field"});d.append(l("span",{class:"rui-field-repeater-label"},[p.label]));const m=l("input",{class:"rui-input",type:p.type==="number"?"number":"text",name:`${p.name}-${s}`,value:f(o[p.name]),readonly:""});d.append(m),u.append(d)}if(c.append(u),typeof e.onRemove=="function"){const p=l("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);p.onclick=()=>r.invoke(e.onRemove,s),c.append(p)}i.append(c)}),typeof e.onAdd=="function"){const o=l("button",{type:"button",class:"rui-field-repeater-add rui-button","data-variant":"secondary"},[f(e.addLabel,"Add row")]);o.onclick=()=>r.invoke(e.onAdd),i.append(o)}return i}},kp={name:"VirtualList",description:"Windowed vertical list for large datasets. Pass pre-rendered nodes as `items` or plain row objects plus a `renderItem` component node per row.",props:[{name:"items",type:"any[]"},{name:"itemHeight",type:"number",optional:!0,description:"Fixed row height in px (default 40)"},{name:"renderItem",type:"Node",optional:!0,description:"Template node rendered per data row"}],render:(t,e,r)=>{const a=Math.max(24,E(e.itemHeight,40)),n=$(e.items),i=l("div",{class:"rui-virtual-list"}),o=l("div",{class:"rui-virtual-list-scroller"}),s=l("div",{class:"rui-virtual-list-spacer"}),c=l("div",{class:"rui-virtual-list-window"}),u=n.length;s.style.height=`${u*a}px`,s.style.position="relative",c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.right="0",o.style.maxHeight=`${Math.min(Math.max(u,1),12)*a}px`,o.style.overflow="auto";const p=d=>{c.replaceChildren();const m=o.clientHeight||a*12,g=Math.ceil(m/a)+2,b=Math.max(0,d),h=Math.min(u,b+g);c.style.transform=`translateY(${b*a}px)`;for(let v=b;v<h;v++){const y=n[v];if(e.renderItem)c.append(r.renderNode(y??e.renderItem));else if(y&&typeof y=="object"&&y.__kind)c.append(r.renderNode(y));else{const x=l("div",{class:"rui-virtual-list-item",style:`height:${a}px`});x.append(l("span",{},[f(y)])),c.append(x)}}};return o.onscroll=()=>{const d=Math.floor(o.scrollTop/a);p(d)},p(0),o.append(s,c),i.append(o),i}},Sp={name:"QueryBuilder",description:"Visual filter builder. Pass `fields` as `{name, label, type?}` and bind `value` to a rule array.",props:[{name:"fields",type:"any[]"},{name:"value",type:"any[]",optional:!0},{name:"onChange",type:"callable",optional:!0,description:"Receives the next rule array"}],render:(t,e,r)=>{const a=_n(e.fields),n=Ft(e.value),i=t.argMeta?.[1]?.stateRef,o=l("div",{class:"rui-query-builder"}),s=c=>{o.replaceChildren(),c.forEach((p,d)=>{const m=l("div",{class:"rui-query-builder-row","data-index":String(d)}),g=l("select",{class:"rui-select rui-query-builder-field"});for(const y of a)g.append(l("option",{value:y.name},[y.label]));g.value=f(p.field??a[0]?.name);const b=l("select",{class:"rui-select rui-query-builder-op"},[]);for(const y of["equals","contains","gt","lt"])b.append(l("option",{value:y},[y]));b.value=f(p.op,"equals");const h=l("input",{class:"rui-input rui-query-builder-value",value:f(p.value)});m.append(g,b,h);const v=l("button",{type:"button",class:"rui-query-builder-remove"},["×"]);v.onclick=()=>{const y=c.filter((x,w)=>w!==d);i?r.setState(i,y):r.invoke(e.onChange,y),s(y)},m.append(v),o.append(m)});const u=l("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);u.onclick=()=>{const p=[...c,{field:a[0]?.name??"",op:"equals",value:""}];i?r.setState(i,p):r.invoke(e.onChange,p),s(p)},o.append(u)};return s(n.length>0?n:[{field:a[0]?.name??"",op:"equals",value:""}]),o}},$p={name:"DiffViewer",description:"Side-by-side or unified diff of two text blobs.",props:[{name:"left",type:"string"},{name:"right",type:"string"},{name:"mode",type:"string",optional:!0,enum:["split","unified"],description:"Default split"}],render:(t,e)=>{const r=f(e.left),a=f(e.right),n=f(e.mode,"split"),i=l("div",{class:"rui-diff-viewer","data-mode":n});if(n==="unified"){const u=l("pre",{class:"rui-diff-viewer-unified"});for(const p of bp(r,a))u.append(l("div",{class:`rui-diff-line rui-diff-line-${p.type}`},[(p.type==="add"?"+ ":p.type==="remove"?"- ":" ")+p.text]));return i.append(u),i}const o=l("div",{class:"rui-diff-viewer-panes"}),s=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),c=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[a]);return o.append(s,c),i.append(o),i}},Cp={name:"JsonTree",description:"Expandable JSON tree viewer for objects and arrays.",props:[{name:"data",type:"any"},{name:"expanded",type:"boolean",optional:!0,description:"Expand all nodes (default: first level only)"}],render:(t,e)=>{const r=l("div",{class:"rui-json-tree"});return r.append(Hn(e.data,A(e.expanded))),r}},Ap={name:"Gantt",description:"Simple Gantt chart. Pass `tasks` as `{id, label, start, end, progress?}` ISO date strings.",props:[{name:"tasks",type:"any[]"},{name:"startDate",type:"string",optional:!0},{name:"endDate",type:"string",optional:!0}],render:(t,e)=>{const r=hp(e.tasks),a=r.map(p=>Ke(p.start)),n=r.map(p=>Ke(p.end)),i=e.startDate?Ke(f(e.startDate)):a.length?Math.min(...a):Date.now(),o=e.endDate?Ke(f(e.endDate)):n.length?Math.max(...n):i+864e5,s=Math.max(o-i,1),c=l("div",{class:"rui-gantt"}),u=l("div",{class:"rui-gantt-track"});for(const p of r){const d=l("div",{class:"rui-gantt-row"});d.append(l("div",{class:"rui-gantt-label"},[p.label]));const m=l("div",{class:"rui-gantt-bars"}),g=(Ke(p.start)-i)/s*100,b=Math.max((Ke(p.end)-Ke(p.start))/s*100,2),h=l("div",{class:"rui-gantt-bar",style:`left:${g}%;width:${b}%`,title:`${p.start} → ${p.end}`});p.progress!=null&&h.append(l("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,p.progress))}%`})),m.append(h),d.append(m),u.append(d)}return c.append(u),c}},Tp={name:"Truncate",description:"Clamp long text with an expand control.",props:[{name:"text",type:"string"},{name:"maxLines",type:"number",optional:!0,description:"Lines before clamping (default 3)"},{name:"expandLabel",type:"string",optional:!0}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(E(e.maxLines,3))),n=r.useInstanceState("expanded",!1),i=`display:-webkit-box;-webkit-line-clamp:${a};-webkit-box-orient:vertical;overflow:hidden`,o=l("div",{class:"rui-truncate","data-expanded":n.get()?"true":"false"}),s=l("p",{class:"rui-truncate-text",style:n.get()?"":i},[f(e.text)]),c=l("button",{type:"button",class:"rui-truncate-toggle"},[n.get()?"Show less":f(e.expandLabel,"Show more")]);return c.onclick=u=>{const p=u.currentTarget,d=p.closest(".rui-truncate"),m=d?.querySelector(".rui-truncate-text");if(!d||!m)return;const g=!n.get();n.set(g),m.style.cssText=g?"":i,p.textContent=g?"Show less":f(e.expandLabel,"Show more"),d.setAttribute("data-expanded",g?"true":"false")},o.append(s,c),o}},Mp={name:"InlineEdit",description:"Click-to-edit inline field with save on Enter or blur.",props:[{name:"value",type:"string"},{name:"label",type:"string",optional:!0},{name:"onSave",type:"callable",optional:!0,description:"Receives the committed draft string"}],render:(t,e,r)=>{const a=r.useInstanceState("editing",!1),n=r.useInstanceState("draft",f(e.value)),i=t.argMeta?.[0]?.stateRef,o=l("div",{class:"rui-inline-edit","data-editing":a.get()?"true":"false"}),s=f(e.label);s&&o.append(l("span",{class:"rui-inline-edit-label"},[s]));const c=l("button",{type:"button",class:"rui-inline-edit-display"},[f(e.value)]),u=l("input",{class:"rui-inline-edit-input rui-input",value:n.get()}),p=m=>{const g=m.closest(".rui-inline-edit"),b=g?.querySelector(".rui-inline-edit-input");return!g||!b?null:{root:g,input:b}},d=m=>{const g=p(m);a.set(!1),g?.root.setAttribute("data-editing","false");const b=n.get();i&&r.setState(i,b),r.invoke(e.onSave,b)};return c.onclick=m=>{const g=p(m.currentTarget);n.set(f(e.value)),a.set(!0),g&&(g.root.setAttribute("data-editing","true"),g.input.value=n.get(),setTimeout(()=>g.input.focus(),0))},u.oninput=m=>n.set(m.currentTarget.value),u.onkeydown=m=>{const g=m;if(g.key==="Enter"&&d(m.currentTarget),g.key==="Escape"){const b=p(m.currentTarget);a.set(!1),b?.root.setAttribute("data-editing","false")}},u.onblur=m=>d(m.currentTarget),o.append(c,u),o}},Np={name:"NotificationBell",description:"Bell icon with unread count badge and dropdown notification list.",props:[{name:"count",type:"number",optional:!0},{name:"items",type:"any[]",optional:!0,description:"{title, message?, time?} objects"},{name:"onOpen",type:"callable",optional:!0}],render:(t,e,r)=>{const a=Math.max(0,Math.floor(E(e.count,0))),n=Ft(e.items),i=r.useInstanceState("open",!1),o=i.get(),s=l("div",{class:"rui-notification-bell","data-open":o?"true":"false"}),c=l("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":o?"true":"false","aria-haspopup":"true"}),u=j("bell",{className:"rui-notification-bell-icon"});u&&c.append(u),a>0&&c.append(l("span",{class:"rui-notification-bell-badge"},[a>99?"99+":String(a)])),s.append(c);const p=l("div",{class:"rui-notification-bell-panel",role:"menu"});if(n.length===0)p.append(l("div",{class:"rui-notification-bell-empty"},["No notifications"]));else for(const d of n){const m=l("div",{class:"rui-notification-bell-item"});m.append(l("div",{class:"rui-notification-bell-item-title"},[f(d.title)]));const g=f(d.message);g&&m.append(l("div",{class:"rui-notification-bell-item-message"},[g]));const b=f(d.time);b&&m.append(l("div",{class:"rui-notification-bell-item-time"},[b])),p.append(m)}return s.append(p),c.onclick=d=>{d.stopPropagation();const m=d.currentTarget,g=m.closest(".rui-notification-bell");if(!g)return;const b=!i.get();i.set(b),g.setAttribute("data-open",b?"true":"false"),m.setAttribute("aria-expanded",b?"true":"false"),b?(r.invoke(e.onOpen),rt({liveRoot:g,onDismiss:()=>{i.set(!1),g.setAttribute("data-open","false"),m.setAttribute("aria-expanded","false")}})):Ne(g)},s}},Pe=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),Pp=t=>!!(t&&typeof t=="object"),Ip={name:"Async",description:"Render `loading`, `error`, `empty`, or `data` slot based on an `$http({...})` resource's state.",props:[{name:"resource",type:"any",positional:!0,required:!0},{name:"loading",type:"Node",optional:!0},{name:"error",type:"Node",optional:!0},{name:"empty",type:"Node",optional:!0},{name:"data",type:"Node",optional:!0}],render:(t,e,r)=>{const a=e.resource,n={loading:e.loading,error:e.error,empty:e.empty,data:e.data};if(!Pp(a))return Pe(r,n.empty??n.data??null);const i=a.state;if(i==="loading"||a.loading)return Pe(r,n.loading??null);if(i==="error"||a.error)return Pe(r,n.error??null);const o=a.data;return o==null||Array.isArray(o)&&o.length===0?Pe(r,n.empty??n.data??null):Pe(r,n.data??null)}},Ep={name:"Show",description:"Conditional renderer. Sugar over `if expr { children } else { fallback }`.",props:[{name:"when",type:"any",positional:!0,required:!0},{name:"fallback",type:"Node",optional:!0},{name:"children",type:"Node[]",optional:!0}],render:(t,e,r)=>e.when?Pe(r,e.children??null):Pe(r,e.fallback??null)},Lp={name:"Portal",description:"Render children outside the parent subtree (e.g. into document.body).",props:[{name:"target",type:"string",optional:!0},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const a=f(e.target);let n=null;if(a)try{n=document.querySelector(a)}catch{n=null}n||(n=document.body);const i=l("div",{class:"rui-portal"});for(const o of $(e.children))i.append(r.renderNode(o));return n&&(n.append(i),r.registerDisposer(()=>{i.parentNode&&i.parentNode.removeChild(i)})),l("span",{class:"rui-portal-anchor","data-portal":a??"body"})}},zp={name:"Redirect",description:"Navigate to `path` and unmount the rest of the subtree.",props:[{name:"path",type:"string",positional:!0,required:!0}],render:(t,e,r)=>{const a=f(e.path);if(a)try{r.router.navigate(a)}catch{}return l("span",{class:"rui-redirect","data-path":a,hidden:"true"})}},Rp={name:"Lazy",description:"Defer rendering until an async `loader` resolves: show `fallback` while pending, then render the resolved value (or `children`). A synchronous loader value renders immediately.",props:[{name:"loader",type:"any",positional:!0,required:!0},{name:"fallback",type:"Node",optional:!0},{name:"children",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=e.loader,n=r.useInstanceState("rui-lazy",{status:"init"}),i=l("span",{class:"rui-lazy",style:"display: contents;"}),o=d=>{i.replaceChildren(Pe(r,d))},s=()=>e.fallback??null,c=d=>d??e.children??null,u=n.get();if(u.status==="resolved")return o(c(u.value)),i;if(u.status==="pending"||u.status==="error")return o(s()),i;let p;try{p=typeof a=="function"?a():a}catch{return n.set({status:"error"}),o(s()),i}if(p&&typeof p.then=="function"){n.set({status:"pending"}),o(s());let d=!1;return r.registerDisposer(()=>{d=!0},"rui-lazy-cancel"),p.then(m=>{d||(n.set({status:"resolved",value:m}),o(c(m)))},()=>{d||(n.set({status:"error"}),o(s()))}),i}return n.set({status:"resolved",value:p}),o(c(p)),i}},Dp={name:"ErrorBoundary",description:"Render a fallback subtree when rendering children throws.",props:[{name:"fallback",type:"Node",optional:!0},{name:"onError",type:"callable",optional:!0},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-error-boundary"});try{for(const n of $(e.children))a.append(r.renderNode(n));return a}catch(n){try{r.invoke(e.onError,n)}catch{}const i=Pe(r,e.fallback??null),o=l("div",{class:"rui-error-boundary rui-error-boundary--fallback"});return o.append(i),o.setAttribute("data-error",n instanceof Error?n.message:String(n)),o}}},jp=new Set(["div","span","p","section","article","header","footer","main","nav","aside","figure","figcaption","details","summary","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","table","thead","tbody","tfoot","tr","td","th","caption","colgroup","col","a","img","picture","source","video","audio","track","small","strong","em","b","i","u","s","mark","code","pre","kbd","samp","var","sub","sup","abbr","cite","blockquote","q","time","address","ins","del","ruby","rt","rp","bdi","bdo","br","hr","wbr","hgroup","label","fieldset","legend","progress","meter","output"]),Bp=/^[a-zA-Z][a-zA-Z0-9_:-]*$/,Op=new Set(["href","ping","action","formaction"]),_p=new Set(["src","poster"]);function Fp(t){const e=f(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}function Up(t){const e=f(t).trim().toLowerCase();return!e||!jp.has(e)?"div":e}function Hp(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t)){const n=r.trim();if(!n||!Bp.test(n))continue;const i=n.toLowerCase();if(!i.startsWith("on")&&!(a==null||a===!1)){if(i==="style"){const o=Fp(a);o&&(e.style=o);continue}if(Op.has(i)){const o=tt(a,"");o&&(e[n]=o);continue}if(_p.has(i)){const o=ie(a);o&&(e[n]=o);continue}e[n]=a===!0?"":f(a)}}return e}const Vp={name:"HTMLTag",description:"Escape-hatch primitive that renders an allow-listed HTML tag with the given attributes and children. Use ONLY when the standard component catalogue cannot express the markup (custom semantic elements, inline SVG, third-party widget mounts). Tag names outside the allow-list collapse to `div`. Attribute names matching `on*` (event handlers) are dropped, `href`/`src` are sanitised, and `style` is filtered for `expression()` / `javascript:` / `@import`. Pass children as an array of components — strings render as text nodes.",props:[{name:"tag",type:"string",positional:!0,required:!0,description:'HTML tag name (e.g. "div", "section", "svg"). Falls back to `div` when outside the allow-list.'},{name:"attributes",type:"object",optional:!0,aliases:["attrs","props"],description:'Plain object of attribute name → value pairs (e.g. `{ class: "hero", "data-id": 1 }`). `on*` handlers are dropped.'},{name:"children",type:"Node[]",optional:!0,description:"Child components or text nodes to render inside the tag."}],render:(t,e,r)=>{const a=Up(e.tag),n=Hp(e.attributes),i=l(a,n);for(const o of $(e.children))if(o!=null){if(typeof o=="string"){i.append(document.createTextNode(o));continue}if(typeof o=="number"||typeof o=="boolean"){i.append(document.createTextNode(String(o)));continue}i.append(r.renderNode(o))}return i}},Wp=/<\/style|<script|expression\s*\(|javascript\s*:|behavior\s*:|@import\b/i,qp=64*1024;function Kp(t){const e=f(t);return!e||e.length>qp||Wp.test(e)?"":e}const Vn=[_s,Fs,Hs,Us,Bs,on,tl,rl,Vs,Ws,qs,Ks,Xs,Ys,Qs,Zs,ll,Gs,al,il,Ml,Nl,fl,gl,hl,gn,vl,yl,xl,wl,$l,Tl,Il,dl,Pl,dc,uc,rc,ac,ic,nc,oc,lc,sc,cc,ec,tc,hn,pc,mc,fc,gc,bn,hc,bc,tu,eu,au,ru,nu,iu,su,ou,du,pu,mu,uu,vu,yu,xu,Su,$u,Du,An,Cu,Au,Ru,Tu,Mu,Pu,Iu,Bu,Ou,ju,Eu,Fu,Nn,Hu,qu,Wu,Xu,Ju,Zu,Qu,Sc,$c,Jc,Zc,Cc,Tc,Ac,Nc,Mc,Pc,Ic,Qc,Ec,Lc,vn,Yc,Dc,Rc,zc,jc,Bc,Fc,_c,Oc,Uc,Hc,Wc,Vc,qc,Gc,Kc,rd,nd,sd,ld,cd,dd,pd,fd,gd,hd,vd,xd,wd,Sd,Cd,Td,Nd,Pd,Ed,Ld,Dd,Bd,Od,Fd,Ud,Hd,Vd,Wd,qd,Kd,Yd,Jd,Qd,ep,tp,rp,ap,np,ip,op,sp,lp,cp,up,vp,yp,xp,wp,kp,Sp,$p,Cp,Ap,Tp,Mp,Np,Ip,Ep,Lp,zp,Rp,Dp,_l,Ul,Vl,Wl,ql,Kl,Yl,gn,Vp,{name:"Styles",description:"Escape-hatch primitive that injects a `<style>` block containing the given CSS rules. Use ONLY when a layout cannot be expressed via component props or the `$theme(...)` token map. The CSS is rendered verbatim into the document so authors can target their own `HTMLTag` markup or scope rules to a wrapper class. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped for safety.",props:[{name:"css",type:"string",positional:!0,required:!0,aliases:["content","rules"],description:'Raw CSS text (e.g. `".hero { color: red; }"`).'}],render:(t,e)=>{const r=Kp(e.css),a=document.createElement("style");return a.setAttribute("class","rui-styles"),r&&(a.textContent=r),a}}],Gp=[{name:"Layout",components:["Column","Row","Center","Stack","StackItem","Grid","GridItem","Box","Container","Spacer","Card","CardHeader","CardFooter","Separator","Tabs","TabItem","Accordion","AccordionItem","Modal","Drawer","Steps","AspectRatio","ScrollArea","Sticky","ResizablePanels","MasonryGrid"],notes:["- THREE primitives cover almost everything: `Column` (stack top→bottom), `Row` (left→right), and `Grid` (equal columns / card walls). Reach for these first.","- `root` is normally a `Column([...])` (or `Container([...])` for a centered page). A `Column` is the page body; put each major chunk in a `Card(...)`.","- `Row([...])` keeps children at their natural width and vertically centered — ideal for toolbars, button rows, label+value pairs, nav bars. Use `justify` to distribute (`between`, `center`, `end`) and `gap` for spacing.","- `Grid([...], { columns: N })` = N equal columns. Omit `columns` for auto-fit (wraps as many ≥`minChildWidth` columns as fit — best for KPI/card grids). Prefer `Grid` over a wrapping `Row` whenever cells should share a width.",'- For a 12-column dashboard / sidebar layout use `GridItem` spans: `Grid([GridItem(side, { span: "1/4" }), GridItem(main, { span: "3/4" })])`. Fractions `"1/2"`…`"1/12"` (or numbers 1–12) resolve on a 12-track grid; any `GridItem` child turns the grid on automatically.','- `Center([...], { minHeight })` centers content on both axes — spinners, empty states, hero CTAs, modal bodies. Add `minHeight: "60vh"` to center vertically in a region.','- `Stack` is the responsive escape hatch: use it ONLY when the direction itself must change across breakpoints, e.g. `Stack([...], { direction: {base: "column", md: "row"} })`.',"- Make one child in a `Row` expand with `StackItem(child, { grow: 1 })` (e.g. a search input beside a fixed button), or push items apart with a bare `Spacer()` between them.","- `Container([...], { size })` centers a wide page within a comfortable max-width (sm/md/lg/xl/full) — landing pages, articles, marketing sections.","- `Box([...], { padding?, margin?, border?, background?, maxWidth? })` is a plain spacing/surface wrapper for when a `Card` is too heavy.",'- `Separator(orientation?, label?)` adds a visual break between sections; pass a `label` for a centered "OR"-style divider.',"- `gap`/`padding` spacing tokens are `xs|s|m|l|xl`; `align`/`justify`/`columns`/`direction`/`gap` all accept responsive maps like `{base: …, md: …, lg: …}`.","- Use `Drawer` for side-panel detail views and `Modal` for centered dialogs. `Sticky(children, side?, offset?)` pins a toolbar/banner while content scrolls. `ResizablePanels(primary, secondary)` gives a user-resizable two-pane split. `MasonryGrid([...])` is for Pinterest-style mixed-height walls."]},{name:"Content",components:["Text","Image","Badge","BadgeList","Callout","Quote","CodeBlock","Skeleton","Spinner","Markdown","Kbd","Icon"],notes:["- Prefer `Markdown(...)` for rich paragraph text with inline formatting — the parser supports headings, blockquotes, fenced code, numbered/bullet lists, links, images, and bare-URL auto-linking.","- Use `Callout(variant, title, description, icon?, compact?)` for highlighted notices; pass `compact: true` for a one-line inline note.","- Use `Quote(text, cite?)` for inline pull-quotes inside articles and marketing sections (use `Testimonial` when you also have author/role/rating).","- Use `CodeBlock(language, codeString, showLineNumbers?, highlightLines?)` for read-only code snippets. The header always renders a copy-to-clipboard button.",'- Use `Badge(label, variant?, icon?, size?)` for a single pill and `BadgeList(["a","b","c"], variant?, size?)` to render an array of strings as Badge pills.',"- Use `Skeleton(variant?, lines?, height?, shape?, width?)` for loading placeholders; `variant` accepts `paragraph` (default), `card`, `table-row`, `avatar`, `image`.","- Use `Spinner(size?, label?, tone?)` for tiny inline loading indicators inside buttons, toolbars, or table cells.",'- Use `Image(src, alt?, caption?, ratio?, fit?, fallback?)` — `ratio` (e.g. `"16:9"`) makes the image self-constrain so you do not need an outer `AspectRatio`.','- Use `Kbd(["Cmd", "K"])` when referring to keyboard shortcuts.','- Use `Icon(name, variant?, size?)` to render a standalone Font Awesome icon (`name` is the FA name without the `fa-` prefix, e.g. `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`).','- For page-level titles reach for `PageHeader(...)` (top of dashboards/detail pages) or `SectionHeader(...)` (inside a Card). For tiny inline titles use `Text(value, variant="large-heavy")`.']},{name:"Forms",components:["Form","FormControl","FormSection","FieldSet","ValidationSummary","Input","TextArea","PasswordInput","MaskedInput","MentionInput","TagInput","Select","SelectItem","Combobox","MultiSelect","Checkbox","CheckBoxGroup","CheckBoxItem","Radio","Switch","ToggleGroup","Button","Buttons","SearchBar","Slider","NumberInput","ColorPicker","DatePicker","DateRangePicker","TimePicker","DateTimePicker","FileUpload","PinInput","MultiStepForm"],notes:["- Each FormControl should be a separate reference for progressive streaming.","- Pass a `$variable` as the last argument to `Input`, `Select`, `Checkbox`, `Switch`, `MultiSelect`, or `CheckBoxGroup` for two-way binding.","- Prefer `Switch` over `Checkbox` for settings; use `ToggleGroup` for view-mode pickers and mutually-exclusive filters.","- Reach for `SearchBar(id, placeholder?, value?, shortcut?)` instead of a raw `Input` whenever the field's purpose is to filter content. It ships with the magnifier icon and keyboard hint baked in.","- `Slider(id, min?, max?, step?, value?, label?, showValue?)` is the canonical control for numeric ranges (volume, brightness, filters); pass a `$variable` as `value` for two-way binding.",'- `NumberInput(id, value?, min?, max?, step?, placeholder?)` is friendlier than `Input(type="number")` for quantity steppers and integer settings — it ships with +/- buttons that respect `min`/`max`.',"- `DatePicker(id, value?, label?, min?, max?, placeholder?)` wraps the native date picker; pass `value` as a `$variable` for two-way binding (ISO `YYYY-MM-DD`).","- `DateRangePicker(id, from?, to?, label?, min?, max?)` is the paired-date variant — bind both `from` and `to` to `$variable`s for a single shared range.","- `Combobox(id, items, value?, placeholder?, emptyLabel?)` is the searchable single-select alternative to `Select` — type to filter long option lists (countries, currencies, users).","- `MultiSelect(id, items, value?, placeholder?, emptyLabel?, max?)` is the multi-select equivalent — bind a `$variable` array as `value` for two-way binding, the trigger renders the picks as removable chips.","- `FileUpload(id, { label?, hint?, accept?, multiple?, action? })` is the styled file picker; the picked files cannot pass through a `$variable`, so wire the `action` prop to a `function` declaration.",'- A submit button should call an `action` that awaits the relevant `$mutation` resource, optionally refetches a `$query`, and resets the form `$variable`s (e.g. `$title = ""`).',"- Button `size` accepts both `sm|md|lg` (canonical) and the legacy `small|normal|large`. Pass `icon` for an inline leading icon.","- `FormSection(label, children, helper?)` is the canonical wrapper for related fields. Reach for it INSTEAD of nesting fields in Card + SectionHeader by hand.","- `FieldSet(legend, children, helper?)` is the accessible `<fieldset>` for radio/checkbox groups; prefer `FormSection` for purely visual grouping.","- `ValidationSummary(errors, title?)` renders an aggregate error panel at the top of the form. Pass `errors` as `{label, message}` objects.",'- `PasswordInput(id, value?, placeholder?, strengthMeter?)` adds a show/hide toggle and an optional 4-step strength meter — prefer over `Input(type="password")` for sign-up flows.',"- `PinInput(id, length?, value?, type?)` renders per-digit code entry for 2FA / SMS verification (use `length=6` for OTP codes).","- `TagInput(id, value?, placeholder?)` lets the user add comma- or Enter-separated chips bound to a `$variable` array.","- `MentionInput(id, people, value?)` is a textarea with inline @-mention suggestions — use for comments, task notes, chat composers.","- `MaskedInput(id, mask, value?)` formats input against a mask string (`9` digit, `A` letter, `*` any). Use for phone numbers, postal codes.","- `TimePicker(id, value?)` and `DateTimePicker(id, value?)` wrap the corresponding native inputs with consistent styling.","- `ColorPicker(id, value?, label?, swatches?)` pairs a color chip with a hex input and preset swatches — bind a $variable holding a hex string.","- `MultiStepForm(steps, current, onSubmit?)` replaces ad-hoc `Steps` + content + manual prev/next wiring. Each step is `{title, details?, content}`."]},{name:"Data",components:["Table","Col","DataGrid","List","ListItem","StatCard","Stats","Sparkline","Tile","Progress","ProgressRing","Pagination","Tree","TreeNode","CalendarView","ComparisonTable","InfiniteList"],notes:['- Build columns using array pluck: `Col("Title", data.rows.title, format?, align?)`.',"- For per-row controls inside a Col, use `for (let row of data.rows) { ... }` and reference `row.field` inline.",'- `Table(cols, caption?, density?, striped?, sticky?, emptyLabel?)` — pass `density="compact"` for dense data, `sticky=true` to pin the header in a scrolling parent, and `emptyLabel` for the zero-state cell.',"- `DataGrid(cols, rowIds?, caption?, sort, selectedIds, selectable?, page, perPage?, …)` is the advanced Table — adds sortable headers (`sortable=true` on Col), per-column filter chips (`filterable=true`), checkbox row selection bound to `$selectedIds`, sticky header / first column, pagination, and an optional bulk-action toolbar. Reach for this whenever a user needs to sort, filter, or page through a list.","- `CalendarView(value?, month?, events?, view?, firstDay?, onSelect?)` renders a full-month (or week) calendar grid for scheduling apps — distinct from the `DatePicker` input. Bind `value` to a `$variable` for the selected ISO date.","- `ComparisonTable(columns, rows, highlightColumn?)` is the generic counterpart of `PricingTable` — pass rows of `{label, values, hint?, group?}`. Use for feature comparisons, spec sheets, plan grids.","- `InfiniteList(items, onLoadMore?, loading?, hasMore?)` is a scroll-to-load list; the action fires when the sentinel scrolls into view.","- Use `Progress(value, max?, label?, tone?, indeterminate?, segments?, buffered?)` for linear bars — `segments` renders an N-step strip (onboarding flows), `buffered` adds a secondary buffer indicator.","- `ProgressRing(value, max?, label?, tone?, size?)` is the circular variant for quotas/completion.",'- `Stats([{label, value, hint?, tone?, spark?}, …], layout?)` — `layout="strip"` (default) for inline KPIs; `layout="grid"` for a responsive StatCard grid. Pass `spark` for an inline trend line.',"- `StatCard(label, value, trend?, delta?, icon?, spark?, tone?)` gains an optional inline `Sparkline` via the `spark` prop. Use `Sparkline(values, tone?)` standalone for tiny trend chips in table cells.","- `Tile(label, icon?, value?, description?, tone?, action?)` is the dense icon tile for quick-action menus and category grids; pair with `Grid` for uniform rows.","- `Tree([TreeNode(label, children?, icon?, expanded?, active?, badge?, action?)])` renders a hierarchical tree (file browsers, nested navigation, category pickers); use `expanded=true` to open a branch by default.",'- `Pagination(page, totalPages, siblings?, total?, perPage?, perPageOptions?, compact?)` — bind `page` (and optionally `perPage`) to a `$variable`; pass `total` to render the "Showing N–M of T" summary. Reuse the same variable when slicing data with `arr.filter(...)` / `for`.']},{name:"Charts",components:["BarChart","LineChart","PieChart","RadarChart","ScatterChart","Histogram","Heatmap","Gauge","Series"],notes:["- Use `LineChart` for trends (pass `filled=true` for area-style charts), `BarChart` for comparisons, `PieChart` for proportions, `RadarChart` for multi-axis scorecards.","- `Heatmap(xLabels, yLabels, values)` renders a color-intensity matrix — perfect for calendar heatmaps, correlation grids, schedule density.","- `ScatterChart(series, xLabel?, yLabel?)` plots XY points; pass each Series as `Series(name, points)` where points are `{x, y, label?}`.","- `Histogram(values, binCount?)` bins raw numbers; pass pre-computed `bins=[{label, count}]` instead when you control the bucketing.","- `Gauge(value, min?, max?, label?, tone?, size?)` is the half-doughnut KPI indicator for thresholds (uptime %, score, NPS).",'- Pass series via `Series("Name", [...numbers])`.']},{name:"Feedback & Media",components:["Avatar","AvatarGroup","PersonChip","Tooltip","HoverCard","Popover","Rating","Toast","VideoPlayer","AudioPlayer","Carousel","Gallery","Lightbox","Map"],notes:["- `Avatar(name, src?, size?, status?)` falls back to initials when the image is missing.","- Use `AvatarGroup` to render contributor strips with a `+N` overflow chip.","- `PersonChip(name, role?, avatarSrc?, size?, status?, action?)` is the inline avatar + name + role pill — use everywhere a person is referenced (table cells, list rows, sidebar footers, kanban cards) instead of a raw `Avatar` next to `Text`.","- Wrap any node in `Tooltip(label, trigger)` for inline hints.","- Use `HoverCard(trigger, content)` when the popover needs rich content (profile preview, link target) and the trigger should open on hover.","- `Popover(trigger, content, title?, side?, align?, width?)` is the click-triggered counterpart of `HoverCard` — use for filter panels, color pickers, share menus, and small settings flyouts. Always renders an × close button in the header; clicking the trigger again, clicking outside, or pressing Escape also closes it.",'- `Rating(value, max?, label?, count?, size?, interactive?, halfStep?, icon?)` renders stars for product reviews, testimonials, and ranked lists. Pass a `$variable` as `value` with `interactive=true` to let users rate; add `halfStep=true` so clicking the left half of a star sets a half-value. Set `icon="heart"|"thumb"|"fire"|"bolt"` (or any FA name) to swap glyphs.',"- `Toast(title, message?, tone?, icon?, duration?, action?, onClose?, position?)` pins a transient notice; pass `duration` (ms) for auto-dismiss. Drive lists from an `action` body: `$toasts = [...$toasts, item]` to append and `$toasts = $toasts.filter((t) => t.id !== id)` to dismiss. Use `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.","- `NotificationBell(count?, items?, onOpen?)` — compact inbox trigger; `CommandPalette` for Cmd-K action search."]},{name:"Navigation",components:["Breadcrumb","BreadcrumbItem","Navbar","NavbarItem","DropdownMenu","MenuItem","MenuSeparator","MenuLabel"],notes:['- Use `Breadcrumb(["Workspace", "Reports", "Q3"])` at the top of every detail page so users see the path.',"- For per-item links, pass `BreadcrumbItem(label, href)` nodes instead of strings.","- `Navbar(brand?, items?, actions?, sticky?, variant?)` + `NavbarItem(label, to?, href?, icon?, active?, action?, external?)` produces a top navigation bar with brand on the left, links in the middle, and actions on the right — the canonical companion of `Sidebar` for marketing pages, docs, or any product surface without left-side nav.",'- `DropdownMenu(trigger, items, side?, align?, label?)` is the click-triggered dropdown menu — use it for user-profile menus, row "…" action menus, and any compact list of actions hanging off a single trigger. Children must be `MenuItem`, `MenuSeparator`, or `MenuLabel` entries.','- `MenuItem(label, action?, icon?, shortcut?, variant?, disabled?)` renders a single row inside a `DropdownMenu`; use `variant="danger"` for destructive actions and `MenuSeparator()`/`MenuLabel(label)` to group related items.']},{name:"Chat",components:["SectionBlock","ListBlock","FollowUpBlock","FollowUpItem","ActionLink","ChatBubble"],notes:["- End most responses with a `FollowUpBlock` of 2–4 short prompts to keep the conversation moving.",'- `ChatBubble(author, body, time?, avatarSrc?, from?)` renders a single message bubble; use `from="me"` for the active speaker and `from="agent"` for the assistant. Compose transcripts as `Stack([ChatBubble(...), ChatBubble(...), …])` inside a `Card`.']},{name:"Patterns",components:["Hero","PageHeader","EmptyState","Timeline","TimelineItem","ActivityLog","FeatureGrid","FeatureItem","Testimonial","ProfileCard","Comment","Banner","Notification","InboxPanel","OnboardingChecklist","MediaCard","TopBar","KanbanBoard","KanbanColumn","KanbanCard","SectionHeader","Toolbar","DescriptionList","DescriptionItem","StatusDot","PricingTable","PricingCard","LoadingState","ErrorState","SuccessState","Tour","Spotlight"],notes:["- Patterns are **opinionated composites** that pack an entire UI idiom into one component. Reach for them BEFORE composing equivalent layouts by hand with Card+Stack — the result will look more polished and require fewer tokens.",'- `Hero(title, subtitle, primary, secondary, eyebrow?, highlights?, tone?)` — landing-style text-first header. Use `layout="cover"` with `imageSrc`, `height`, and optional `caption` for image-backed hero bands.','- `PageHeader(title, subtitle?, breadcrumbs?, actions?, status?)` — the canonical first child for any dashboard or detail page. If you omit `breadcrumbs`, the component auto-derives `["Home", title]`.',"- `TopBar(title?, search?, actions?, sticky?)` — compact top strip for a content surface (panels, dialogs, embedded views). Use `AppShell` when you need a full sidebar; use `TopBar` for narrower headers above scrolling content.","- `SectionHeader(title, subtitle?, eyebrow?, status?, actions?)` — sub-header inside a Card or panel. Use instead of bare `CardHeader` when the section also needs eyebrow / actions / status.",'- `Stats(items, layout?)` — KPI strip (`layout="strip"`, default) or responsive grid (`layout="grid"` with StatCard children). Prefer over hand-rolled StatCard rows.',"- `Toolbar(left?, right?, center?, searchable?, searchPlaceholder?, searchValue?)` — filter/search/actions row above a list, table, or board. Pass `searchable: true` to auto-mount a `SearchBar` (use `searchValue` to bind it to a `$variable`).","- `EmptyState(title, description?, icon?, illustration?, actions?, action?)` — render this when a list is empty rather than an empty Card. The icon is auto-picked from the title keywords if you omit it (inbox/messages → `inbox`, charts/analytics → `chart-pie`, files/folders → `folder-open`, etc.).","- `Timeline([TimelineItem(...)])` — vertical event feed (audit log, changelog, activity).",'- `ActivityLog(entries, variant?)` — purpose-built feed of user actions. Pass `entries` of `{actor, title, description?, time?, icon?, tone?, meta?}`; use `variant="audit"` for security/admin trails with monospace meta.',"- `FeatureGrid([FeatureItem(...)])` — feature highlights with iconography.","- `MediaCard(title, imageSrc?, description?, tags?, meta?, actions?, badge?, orientation?, ratio?)` — image + content card. Use for article previews, product cards, project highlights. Pair with `Grid` for uniform card rows.",'- `KanbanBoard([KanbanColumn("To do", [KanbanCard(...), ...])])` — task boards.','- `DescriptionList([DescriptionItem("Status", Badge(...)), …])` — detail-page key/value summary. Always preferable to a Stack of Text rows on profile, billing, or metadata panels.',"- `StatusDot(label, tone?, pulse?)` — inline status pip. Use in toolbars, list rows, table cells, sidebars.","- `Notification(title, message?, time?, icon?, avatarSrc?, tone?, unread?, actions?)` — inline notification card for notification panels / inboxes (prefer `Banner` for top-of-page announcements).","- `InboxPanel(items, title?, onMarkAllRead?)` — `Notification` cards grouped into Unread / Earlier sections, with a shared mark-all-read action.","- `OnboardingChecklist(items, title?, description?)` — checklist of `{title, description?, done?, action?}` items with progress. Use for product onboarding, setup wizards, getting-started panels.","- `PricingTable([PricingCard(plan, price, period?, description?, features?, action?, badge?, featured?)])` — full pricing page block.","- `LoadingState(title?, description?, tone?, action?)`, `ErrorState(title, description?, action?, secondaryAction?, retryLabel?)`, `SuccessState(title, description?, action?, secondaryAction?)` — full-card empty-state alternatives for asynchronous content states.","- `Tour(steps, current, onFinish?)` and `Spotlight(title?, description?, action?)` are the product-tour primitives. `Spotlight` is a single highlighted call-out; `Tour` walks the user through multiple `{title, description, image?}` steps with Prev/Next/Skip controls and a progress dots indicator."]},{name:"Editors & overlays",components:["RichTextEditor","CodeEditor","ContextMenu"],notes:["- `RichTextEditor(id, value?, placeholder?, minHeight?)` is the contenteditable WYSIWYG editor — toolbar ships with bold/italic/underline/strike/heading/lists/link. Bind `value` to a `$variable` holding HTML.","- `CodeEditor(id, value?, language?, placeholder?, minHeight?)` is a lightweight `<textarea>` with a synced line-number gutter and tab indentation. Use for snippet editors, prompt sandboxes, settings JSON.","- `ContextMenu(target, items)` attaches a right-click menu to any node. `items` are `MenuItem` or `{label, action?, icon?, shortcut?, variant?, disabled?}` objects; pass a `MenuSeparator()` to split groups."]},{name:"App shell",components:["AppShell","Sidebar","SidebarSection","SidebarItem","SplitView"],notes:["- App shell components produce a **full SaaS-style layout in a single statement**. Use them whenever the response represents a complete product surface (dashboards with nav, settings sections, admin consoles, inboxes).","- `AppShell(sidebar, content, topbar?, collapsible?, sidebarOpen?)` — fixed-left navigation + scrollable main area. Pass `collapsible=true` to enable a hamburger that turns the sidebar into a slide-over drawer on mobile; bind `sidebarOpen` to a `$variable` if you want to drive that drawer programmatically.","- `Sidebar(items, brand?, tagline?, footer?, collapsed?)` + `SidebarItem(label, icon?, active?, badge?, action?)` + `SidebarSection(label, items)` — group nav links into sections, mark the current page with `active=true`, attach badges for counts. Pass `collapsed=true` (or bind to a `$variable`) to collapse it to an icon rail.","- `SplitView(primary, detail, primaryWidth?)` — master/detail layout (inboxes, file browsers, contact lists). Both panes are scrollable."]},{name:"Advanced UI",components:["IconButton","CommandPalette","FilterChips","FieldRepeater","VirtualList","QueryBuilder","DiffViewer","JsonTree","Gantt","Truncate","InlineEdit","NotificationBell"],notes:["- `IconButton(icon, label, action?, variant?, size?, disabled?)` — accessible icon-only control.","- `CommandPalette(items, open?, placeholder?, shortcut?)` — Cmd-K searchable actions.","- `FilterChips(chips, onRemove?, onClear?)` — applied filter pills with remove.","- `FieldRepeater(items, fields, onAdd?, onRemove?)` — dynamic form rows.","- `VirtualList(items, itemHeight?, renderItem)` — windowed long lists.","- `QueryBuilder(fields, value?)` — visual AND/OR filter builder.","- `DiffViewer(left, right, mode?)` — side-by-side or unified diff.","- `JsonTree(data)` — collapsible JSON inspector.","- `Gantt(tasks, startDate?, endDate?)` — horizontal schedule timeline.","- `Truncate(text, maxLines?)` / `InlineEdit(value, onSave?)` / `NotificationBell(count?, items?)`."]},{name:"Routing",components:["NavLink"],notes:['- Declare routes with the `$router({...})` call form: `pages = $router({ "/": Dashboard(), "/orders/:id": OrderDetail({ id: params.id }), default: NotFound() })`. The matched arm\'s `params` object is in scope on the right-hand side; nest `$router` inside components for layout-preserving sub-routes.',"- `Redirect(path)` is a router-aware component: returning it from a route's body navigates and unmounts the rest of the subtree.","- `NavLink(label, { to })` is a thin link wrapper that reads `route.path` and dispatches `route.navigate(to)` — use it for sidebars, navbars and breadcrumbs.","- Read URL params via `route.params.<name>` (e.g. `route.params.id` for `/users/:id`) and the current path via `route.path`."]},{name:"Helpers",components:["Async","Show","Portal","Redirect","Lazy","ErrorBoundary"],notes:["- `Async(resource, { loading:, error:, empty:, data: })` switches an `$http({...})` resource on its `state` field (`empty` shows for `null`/empty-array data).","- `Show(when, { fallback?, children })` is sugar over `if (expr) { children } else { fallback }`.","- `Portal(target?, children)` renders into a different DOM subtree (defaults to `document.body`).","- `Redirect(path)` is a router-aware component — see Routing.","- `Lazy(loader, fallback?)` defers rendering until the async `loader` resolves, showing `fallback` while pending (a synchronous loader value renders immediately).","- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants."]},{name:"Behaviour wrappers",components:["OnClick","OnMouse","OnKeyboard","OnFocus","OnIntersect","OnMount","Css","Link"],notes:["- Wrappers compose: any built-in component can be made clickable, hoverable, observable, or restyled by wrapping it in one of these primitives — no need for the underlying component to grow another prop.","- `OnClick(child, { onClick, disabled?, stopPropagation? })` makes any component clickable / tappable (touch devices fire `click` too). Use for clickable cards, list rows, media tiles, and any custom layout that needs a tap target without a `<button>` baseline.","- `OnMouse(child, { enter?, leave?, hover?, move?, down?, up?, click?, doubleClick?, contextMenu?, scroll?, wheel?, drag?, drop?, dragStart?, dragEnd?, dragEnter?, dragLeave?, dragOver?, draggable?, passiveScroll? })` attaches any combination of mouse / pointer / drag listeners. Pass `draggable: true` to make the wrapper itself draggable. Scroll / wheel listeners default to `{ passive: true }` for smooth scrolling.","- `OnKeyboard(child, { onKeyDown?, onKeyUp?, onKeyPress?, focusable? })` attaches keyboard listeners. The wrapper is focusable by default; pass `focusable: false` when the child is already focusable (input, button).","- `OnFocus(child, { onFocus?, onBlur? })` tracks focus moving into or out of a subtree (uses bubbling `focusin` / `focusout` so descendants count).","- `OnIntersect(child, { onEnter?, onLeave?, onChange?, threshold?, rootMargin?, once? })` is the IntersectionObserver wrapper — perfect for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.","- `OnMount(child, { onMount?, onUnmount? })` is the DOM-ref / lifecycle wrapper. `onMount(node)` fires once after the wrapped element attaches; `onUnmount(node)` fires when it leaves the tree. Use it to measure or focus an element, or to hand a node to an imperative library (chart / map / editor). Stash the node in a `$ref(...)`.","- `Css(child, { style?, class? })` merges raw class tokens and inline styles onto the wrapped child. Reach for it ONLY when the standard component props can't express the styling — prefer `Box`/`Stack`/`Grid` for layout and `$theme(...)` for tokens.","- `Link(label_or_child, { to?, href?, external?, variant? })` is the anchor primitive — accepts either a plain string label or a wrapped component. Use `to` for client-side router navigation and `href` (with `external: true`) for outbound links."]},{name:"Escape hatches",components:["HTMLTag","Styles"],notes:["- **Use only as a last resort.** Reach for these primitives when the standard catalogue cannot express the markup or styling you need; for everything else (typography, layout, surfaces, controls) the dedicated components produce a more consistent UI for fewer tokens.",'- `HTMLTag(tag, attributes?, children?)` renders an allow-listed HTML tag with the given attribute object and child nodes (e.g. `HTMLTag("section", attributes: {class: "hero", "data-id": 1}, children: [Text("Hello")])`). Tag names outside the allow-list collapse to `div`; `on*` attributes, `javascript:` URLs in `href`/`src`, and `expression()` / `@import` in inline `style` are stripped.',"- `Styles(css)` injects a `<style>` block containing the given CSS rules (e.g. `` Styles(`.hero { background: linear-gradient(...); }`) ``). Pair it with `HTMLTag` (or any built-in component's `class`-bearing wrapper) when scoping to a custom selector. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped."]}];Va(Vn);const pt={root:"Column",components:Vn,componentGroups:Gp},Yp=t=>{const e={name:t.name,type:t.type,required:!t.optional};return t.description&&(e.description=t.description),t.enum&&t.enum.length>0&&(e.enumValues=t.enum),e},Xp=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},Jp=t=>{const e=new Map;for(const r of t.componentGroups??[])for(const a of r.components)e.set(a,r.name);return e};function Wn(t=pt){const e=Jp(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(Yp),signature:Xp(r)}))}function qn(t){const e={};for(const r of t)e[r.name]=r;return e}const Kn=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");function Gn(t,e){return e.length===0?t:`${t}.${e.join(".")}`}function Yn(t,e){return!!(t===e||e.startsWith(t+".")||t.startsWith(e+"."))}function Ir(t,e){if(t.has(e))return!0;for(const r of t)if(Yn(r,e))return!0;return!1}function mt(t,e){for(const r of e)if(Ir(t,r))return!0;return!1}class Xn{constructor(){D(this,"values",new Map);D(this,"defaults",new Map);D(this,"subscribers",new Set);D(this,"pendingChanges",new Set);D(this,"flushScheduled",!1);D(this,"rendering",!1);D(this,"renderWriteOccurred",!1)}declare(e,r){this.defaults.set(e,r),this.values.has(e)||this.values.set(e,r)}has(e){return this.values.has(e)}get(e){return this.values.get(e)}set(e,r){this.values.get(e)!==r&&(this.values.set(e,r),this.enqueueChange(e))}enqueueChange(e){if(this.rendering){this.renderWriteOccurred=!0;return}this.pendingChanges.add(e),this.scheduleFlush()}beginRenderPass(){this.rendering=!0,this.renderWriteOccurred=!1}isRendering(){return this.rendering}endRenderPass(){this.rendering=!1;const e=this.renderWriteOccurred;return this.renderWriteOccurred=!1,e}setPath(e,r,a){if(r.length===0){this.set(e,a);return}const n=this.values.get(e),i=ft(n,r,0,a);this.values.set(e,i),this.enqueueChange(Gn(e,r))}entries(){return this.values.entries()}snapshot(){const e={};return this.values.forEach((r,a)=>{e[a]=r}),e}hydrate(e){for(const[r,a]of Object.entries(e))this.values.set(r,a)}reset(...e){for(const r of e){if(!this.defaults.has(r))continue;const a=this.defaults.get(r);this.values.get(r)!==a&&(this.values.set(r,a),this.enqueueChange(r))}}resetAll(){for(const[e,r]of this.defaults.entries())this.values.get(e)!==r&&(this.values.set(e,r),this.enqueueChange(e))}rebind(e){this.values.clear(),this.defaults.clear(),this.pendingChanges.clear();for(const[r,a]of e)this.defaults.set(r,a),this.values.set(r,a)}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flush()))}flush(){if(this.flushScheduled=!1,this.pendingChanges.size===0)return;const e=new Set(this.pendingChanges);this.pendingChanges.clear();for(const r of[...this.subscribers])r(e)}}function ft(t,e,r,a){if(r>=e.length)return a;const n=e[r],i=n!==""&&!Number.isNaN(Number(n))?Number(n):null;if(Array.isArray(t)&&i!==null){const s=t.slice();return s[i]=ft(t[i],e,r+1,a),s}if(t&&typeof t=="object"&&!Array.isArray(t)){const s={...t};return s[n]=ft(t[n],e,r+1,a),s}if(i!==null){const s=[];return s[i]=ft(void 0,e,r+1,a),s}const o={};return o[n]=ft(void 0,e,r+1,a),o}const Er=Symbol("aktion.httpResource");function Jn(t){return typeof t=="object"&&t!==null&&t[Er]===!0}class Zn{constructor(){D(this,"interceptors",{})}registerInterceptors(e){this.interceptors={...this.interceptors,...e}}resolveUrl(e){return e}async request(e){let r={...e,headers:{...e.headers}};if(this.interceptors.onRequest)try{r=await this.interceptors.onRequest(r)}catch(n){throw this.interceptors.onError?.(n,r),n}const a=async()=>{const n=new AbortController,i=typeof fetch=="function"?fetch:null;if(!i)throw new Error("`fetch` is not available in this environment");const o={...r.init,method:r.method,headers:r.headers,signal:r.signal??n.signal};r.body!==void 0&&r.method!=="GET"&&r.method!=="HEAD"&&(o.body=Zp(r.body,r.headers));const s=await i(r.url,o),c={};s.headers.forEach((d,m)=>{c[m]=d});const u=c["content-type"]??"";let p;return s.status===204||r.method==="HEAD"?p=null:u.includes("application/json")?p=await s.json().catch(()=>null):p=await s.text().catch(()=>""),{status:s.status,headers:c,body:p}};try{let n=await a();if(this.interceptors.onResponse){let i=!1;const o=async()=>i?n:(i=!0,a());n=await this.interceptors.onResponse(n,o)}return n}catch(n){throw this.interceptors.onError?.(n,r),n}}}function Zp(t,e){if(t==null)return"";if(typeof t=="string"||t instanceof Blob||t instanceof ArrayBuffer||typeof FormData<"u"&&t instanceof FormData||typeof URLSearchParams<"u"&&t instanceof URLSearchParams)return t;!e["content-type"]&&!e["Content-Type"]&&(e["Content-Type"]="application/json");try{return JSON.stringify(t)}catch{return String(t)}}const Qp=new Set(["url","method","headers","body","query","signal"]);function Qn(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=typeof e.url=="string"?e.url:"",a=typeof e.method=="string"?e.method.toUpperCase():"GET",n={};if(e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(const[c,u]of Object.entries(e.headers))u!=null&&(n[c]=String(u));let i=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const c=new URLSearchParams;for(const[p,d]of Object.entries(e.query))d!=null&&c.append(p,String(d));const u=c.toString();u&&(i+=(i.includes("?")?"&":"?")+u)}const o={};for(const[c,u]of Object.entries(e))Qp.has(c)||(o[c]=u);const s={url:i,method:a,headers:n,body:e.body};return Object.keys(o).length>0&&(s.init=o),e.signal instanceof AbortSignal&&(s.signal=e.signal),s}function Lr(t,e){const r={state:"loading",data:void 0,error:void 0,loading:!0,refetch:async()=>{await o()},cancel:()=>{n+=1,a&&a.abort(),a=null,r.loading&&(r.loading=!1,r.state=r.data===void 0?"idle":"data",i())}};Object.defineProperty(r,Er,{value:!0,enumerable:!1,writable:!1});let a=null,n=0;const i=()=>e.notify?.(),o=async()=>{const s=n+=1;a&&a.abort(),a=new AbortController;const c=a;if(r.state=r.data===void 0?"loading":"stale",r.loading=!0,i(),!e.http){r.error={message:"http runtime not available"},r.state="error",r.loading=!1,i();return}try{const u=Qn(t);u.url=e.http.resolveUrl(u.url),u.signal=c.signal;const p=await e.http.request(u);if(s!==n)return;p.status>=200&&p.status<300?(r.data=p.body,r.state="data",r.error=void 0):(r.error={status:p.status,body:p.body},r.state="error"),r.status=p.status,r.headers=p.headers,r.lastUpdated=Date.now()}catch(u){if(s!==n||u?.name==="AbortError")return;r.error=u,r.state="error"}finally{if(s===n&&(r.loading=!1,i(),typeof r.onDone=="function"))try{r.onDone(r)}catch(u){console.error("[aktion] Http onDone callback threw",u)}}};return o(),r}function zr(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function em(t){const e=typeof t.method=="string"?t.method.toUpperCase():"GET",r=typeof t.url=="string"?t.url:"";let a="null",n="null";try{a=JSON.stringify(t.query??null)}catch{}try{n=JSON.stringify(t.body??null)}catch{}return`${e} ${r} ${a} ${n}`}function ei(t,e){const r=zr(t),a=typeof r.ttl=="number"?r.ttl:0,n=r.key!=null?String(r.key):em(r),i=e.queryCache,o=i.get(n);if(o)return a>0&&o.lastUpdated!=null&&Date.now()-o.lastUpdated>a&&!o.loading&&o.refetch(),o;const s={};for(const[u,p]of Object.entries(r))u==="key"||u==="ttl"||(s[u]=p);const c=Lr(s,e);return i.set(n,c),c}function ti(t,e){const r=zr(t);let a=0,n=null;const i=()=>e.notify?.(),o={data:void 0,error:void 0,loading:!1,reset:()=>{a+=1,n&&n.abort(),n=null,o.data=void 0,o.error=void 0,o.status=void 0,o.loading=!1,i()},mutate:async s=>{const c=a+=1;n&&n.abort(),n=new AbortController;const u=n;if(o.loading=!0,o.error=void 0,i(),!e.http){o.error={message:"http runtime not available"},o.loading=!1,i();return}try{const p={method:"POST",...r,...zr(s)},d=Qn(p);d.url=e.http.resolveUrl(d.url),d.signal=u.signal;const m=await e.http.request(d);if(c!==a)return;const g=m.status>=200&&m.status<300;return g?(o.data=m.body,o.error=void 0):o.error={status:m.status,body:m.body},o.status=m.status,g?m.body:void 0}catch(p){if(c!==a||p?.name==="AbortError")return;o.error=p;return}finally{if(c===a&&(o.loading=!1,i(),typeof o.onDone=="function"))try{o.onDone(o)}catch(p){console.error("[aktion] $mutation onDone callback threw",p)}}}};return Object.defineProperty(o,Er,{value:!0,enumerable:!1,writable:!1}),o}function ri(t={}){const e=tm(t.translations),r=typeof t.defaultLanguage=="string"?t.defaultLanguage:"";let a=typeof t.currentLanguage=="string"&&t.currentLanguage?t.currentLanguage:r;function n(s,c){if(typeof s!="string"||!s)return"";const u=e[s];let p;return u&&(a&&typeof u[a]=="string"?p=u[a]:r&&typeof u[r]=="string"&&(p=u[r])),p===void 0?s:rm(p,c)}function i(s){typeof s!="string"||!s||(a=s)}function o(){return a}return{t:n,setCurrentLanguage:i,getCurrentLanguage:o}}function tm(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t)){if(!a||typeof a!="object"||Array.isArray(a))continue;const n={};for(const[i,o]of Object.entries(a))typeof o=="string"&&(n[i]=o);e[r]=n}return e}function rm(t,e){return e?t.replace(/\{([^}]+)\}/g,(r,a)=>{const n=e[a.trim()];return n==null?"":String(n)}):t}const W=t=>typeof t=="number"?t:typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):0,te=t=>Array.isArray(t)?t:[],ze=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Rr=(t,e,r)=>{switch(t){case"==":return e===r;case"!=":return e!==r;case">":return W(e)>W(r);case"<":return W(e)<W(r);case">=":return W(e)>=W(r);case"<=":return W(e)<=W(r);case"contains":{const a=String(e??"").toLowerCase(),n=String(r??"").toLowerCase();return a.includes(n)}case"startsWith":return String(e??"").toLowerCase().startsWith(String(r??"").toLowerCase());case"endsWith":return String(e??"").toLowerCase().endsWith(String(r??"").toLowerCase());default:return!1}},gt=t=>{if(Array.isArray(t))return t.map(e=>gt(e));if(t instanceof Date)return new Date(t.getTime());if(t&&typeof t=="object"){const e={};for(const r of Object.keys(t))e[r]=gt(t[r]);return e}return t},Re=(t,e)=>{if(e==="")return t;if(t&&typeof t=="object"){if(e.includes(".")){let r=t;for(const a of e.split("."))if(r&&typeof r=="object")r=r[a];else return;return r}return t[e]}},Ge=t=>{if(t instanceof Date)return t;if(typeof t=="number")return new Date(t);if(typeof t=="string"&&t.trim()!==""){if(!Number.isNaN(Number(t))&&/^-?\d+$/.test(t.trim()))return new Date(Number(t));const e=new Date(t);if(!Number.isNaN(e.getTime()))return e}return new Date},am=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],nm=["January","February","March","April","May","June","July","August","September","October","November","December"],im=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],om=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],sm=(t,e)=>{const r=(s,c=2)=>String(s).padStart(c,"0"),a=t.getHours(),n=(a+11)%12+1,i=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,nm[t.getMonth()]],[/MMM/g,am[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,om[t.getDay()]],[/ddd/g,im[t.getDay()]],[/DD/g,r(t.getDate())],[/HH/g,r(a)],[/hh/g,r(n)],[/mm/g,r(t.getMinutes())],[/ss/g,r(t.getSeconds())],[/\bM\b/g,String(t.getMonth()+1)],[/\bD\b/g,String(t.getDate())],[/\bH\b/g,String(a)],[/\bh\b/g,String(n)],[/\bm\b/g,String(t.getMinutes())],[/\bs\b/g,String(t.getSeconds())],[/A/g,a>=12?"PM":"AM"],[/a/g,a>=12?"pm":"am"]];let o=e;for(const[s,c]of i)o=o.replace(s,c);return o},lm=(t,e=Date.now())=>{const r=e-t.getTime(),a=Math.abs(r),n=r<0,i=6e4,o=60*i,s=24*o,c=7*s,u=30*s,p=365*s;let d,m;return a<i?n?"in a moment":"just now":(a<o?(d=Math.round(a/i),m="m"):a<s?(d=Math.round(a/o),m="h"):a<c?(d=Math.round(a/s),m="d"):a<u?(d=Math.round(a/c),m="w"):a<p?(d=Math.round(a/u),m="mo"):(d=Math.round(a/p),m="y"),n?`in ${d}${m}`:`${d}${m} ago`)},cm=(t,e,r)=>{if(ze(e)){const n={};return typeof e.currency=="string"&&(n.currency=e.currency),typeof e.locale=="string"&&(n.locale=e.locale),typeof e.decimals=="number"&&(n.decimals=e.decimals),n}const a={};return t==="currency"?(typeof e=="string"&&e.length>0&&(a.currency=e),typeof r=="string"&&r.length>0&&(a.locale=r)):typeof e=="string"&&e.length>0&&(a.locale=e),a},um=(t,e)=>{const a=String(t??"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(i=>i.toLowerCase());if(a.length===0)return"";if(e==="snake")return a.join("_");if(e==="kebab")return a.join("-");const n=i=>i.charAt(0).toUpperCase()+i.slice(1);return e==="pascal"?a.map(n).join(""):a[0]+a.slice(1).map(n).join("")},ai={count:t=>te(t).length,sum:t=>te(t).reduce((e,r)=>e+W(r),0),avg:t=>{const e=te(t);return e.length===0?0:e.reduce((r,a)=>r+W(a),0)/e.length},min:t=>{const e=te(t).map(W);return e.length===0?0:Math.min(...e)},max:t=>{const e=te(t).map(W);return e.length===0?0:Math.max(...e)},first:t=>te(t)[0]??null,last:t=>{const e=te(t);return e.length===0?null:e[e.length-1]},filter:(t,e="",r="==",a)=>te(t).filter(n=>Rr(r,Re(n,String(e)),a)),find:(t,e="",r="==",a)=>te(t).find(n=>Rr(r,Re(n,String(e)),a))??null,sort:(t,e="",r="asc")=>{const a=[...te(t)],n=String(r).toLowerCase()==="desc"?-1:1;return a.sort((i,o)=>{const s=Re(i,String(e)),c=Re(o,String(e));return typeof s=="number"&&typeof c=="number"?(s-c)*n:String(s??"").localeCompare(String(c??""))*n}),a},groupBy:(t,e="")=>{const r={};for(const a of te(t)){const n=String(Re(a,String(e))??"");(r[n]??(r[n]=[])).push(a)}return r},slice:(t,e,r)=>{const a=te(t);return a.slice(e??0,r??a.length)},unique:(t,e)=>{const r=te(t);if(!e)return Array.from(new Set(r));const a=new Set,n=[];for(const i of r){const o=Re(i,e);a.has(o)||(a.add(o),n.push(i))}return n},reverse:t=>[...te(t)].reverse(),range:(t,e,r)=>{const a=W(t),n=W(e),i=r===void 0?n>=a?1:-1:W(r);if(i===0)return[a];const o=Math.abs(n-a),s=Math.floor(o/Math.abs(i))+1;if(s>Ut)throw new RangeError(`$util.range refusing to allocate ${s} entries (limit ${Ut}).`);const c=[];if(i>0)for(let u=a;u<=n;u+=i)c.push(u);else for(let u=a;u>=n;u+=i)c.push(u);return c},repeat:(t,e)=>{const r=Math.max(0,W(e));if(r>Ut)throw new RangeError(`$util.repeat refusing to allocate ${r} entries (limit ${Ut}).`);return Array.from({length:r},()=>t)},pick:(t,e)=>{if(!ze(t))return{};const r=te(e).map(n=>String(n??"")),a={};for(const n of r)n in t&&(a[n]=t[n]);return a},omit:(t,e)=>{if(!ze(t))return{};const r=new Set(te(e).map(n=>String(n??""))),a={};for(const n of Object.keys(t))r.has(n)||(a[n]=t[n]);return a},chunk:(t,e)=>{const r=te(t),a=Math.max(1,Math.floor(W(e))),n=[];for(let i=0;i<r.length;i+=a)n.push(r.slice(i,i+a));return n},flatten:(t,e=1)=>{const r=(a,n)=>n<=0?a.slice():a.reduce((i,o)=>(Array.isArray(o)?i.push(...r(o,n-1)):i.push(o),i),[]);return r(te(t),Math.max(0,Math.floor(W(e))))},zip:(...t)=>{const e=t.map(te),r=e.reduce((n,i)=>Math.max(n,i.length),0),a=[];for(let n=0;n<r;n+=1)a.push(e.map(i=>i[n]??null));return a},partition:(t,e="",r="==",a)=>{const n=[],i=[];for(const o of te(t))(Rr(r,Re(o,String(e)),a)?n:i).push(o);return[n,i]},keyBy:(t,e="")=>{const r={};for(const a of te(t))r[String(Re(a,String(e))??"")]=a;return r},cloneDeep:t=>gt(t),merge:(t,...e)=>{const r=ze(t)?gt(t):{};for(const a of e)if(ze(a))for(const n of Object.keys(a)){const i=a[n],o=r[n];r[n]=ze(o)&&ze(i)?ai.merge(o,i):ze(i)||Array.isArray(i)?gt(i):i}return r},format:(t,e="number",r,a)=>{const n=W(t),i=String(e),o=cm(i,r,a),s={};i==="currency"?(s.style="currency",s.currency=o.currency||"USD"):i==="percent"?(s.style="percent",o.decimals===void 0&&(s.maximumFractionDigits=2)):i==="compact"?s.notation="compact":s.style="decimal",o.decimals!==void 0&&(s.minimumFractionDigits=o.decimals,s.maximumFractionDigits=o.decimals);try{return new Intl.NumberFormat(o.locale||void 0,s).format(n)}catch{return i==="currency"?n.toFixed(o.decimals??2):String(n)}},formatDate:(t,e="MMM D")=>{const r=Ge(t),a=String(e);switch(a){case"relative":return lm(r);case"date":return r.toLocaleDateString();case"time":return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});case"datetime":return r.toLocaleString();case"iso":return r.toISOString();default:return sm(r,a)}},plural:(t,e,r)=>{const a=W(t),n=String(e??""),i=r===void 0?n+"s":String(r??"");return`${a} ${a===1?n:i}`},capitalize:t=>{const e=String(t??"");return e.length===0?"":e.charAt(0).toUpperCase()+e.slice(1)},lowercase:t=>String(t??"").toLowerCase(),uppercase:t=>String(t??"").toUpperCase(),titlecase:t=>String(t??"").split(/\s+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),case:(t,e="camel")=>{const r=String(e).toLowerCase();return um(t,r==="snake"||r==="kebab"||r==="pascal"||r==="camel"?r:"camel")},now:()=>Date.now(),today:()=>{const t=new Date;return t.setHours(0,0,0,0),t.toISOString()},addDays:(t,e)=>{const r=Ge(t),a=new Date(r.getTime());return a.setDate(a.getDate()+W(e)),a.toISOString()},addHours:(t,e)=>{const r=Ge(t);return new Date(r.getTime()+W(e)*36e5).toISOString()},diffDays:(t,e)=>{const r=Ge(t),a=Ge(e);return Math.round((a.getTime()-r.getTime())/864e5)},startOfWeek:t=>{const e=Ge(t),r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));return r.setUTCDate(r.getUTCDate()-r.getUTCDay()),r.toISOString()},endOfMonth:t=>{const e=Ge(t);return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999).toISOString()},join:(t,e=",")=>te(t).map(r=>r==null?"":String(r)).join(String(e)),split:(t,e=",")=>String(t??"").split(String(e)),trim:t=>String(t??"").trim(),replace:(t,e,r="")=>String(t??"").split(String(e??"")).join(String(r??"")),substring:(t,e,r)=>{const a=String(t??"");return a.substring(W(e),r===void 0?a.length:W(r))},startsWith:(t,e)=>String(t??"").startsWith(String(e??"")),endsWith:(t,e)=>String(t??"").endsWith(String(e??"")),contains:(t,e)=>String(t??"").includes(String(e??"")),match:(t,e)=>{try{return new RegExp(String(e??"")).test(String(t??""))}catch{return!1}},round:(t,e=0)=>{const r=Math.pow(10,W(e));return Math.round(W(t)*r)/r},floor:t=>Math.floor(W(t)),ceil:t=>Math.ceil(W(t)),abs:t=>Math.abs(W(t)),clamp:(t,e,r)=>Math.min(Math.max(W(t),W(e)),W(r)),pow:(t,e)=>Math.pow(W(t),W(e)),sqrt:t=>Math.sqrt(W(t)),random:()=>Math.random(),log:t=>Math.log(W(t))},Ut=1e5;function De(t){if(!t)return"/";let e=String(t);e.startsWith("#")&&(e=e.slice(1));const r=e.indexOf("?");return r>=0&&(e=e.slice(0,r)),e=e.replace(/\/{2,}/g,"/"),!e||e==="/"?"/":(e.startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e)}function ni(t,e){if(!t)return{matched:!1,params:{}};if(t==="*")return{matched:!0,params:{},wildcard:!0};const r=De(t),a=De(e),n=r==="/"?[]:r.slice(1).split("/"),i=a==="/"?[]:a.slice(1).split("/"),o={};let s=!1;for(let c=0;c<n.length;c+=1){const u=n[c];if(u==="*"){s=!0;const d=i.slice(c).join("/");return o._=d,{matched:!0,params:o,wildcard:s}}const p=i[c];if(p===void 0)return{matched:!1,params:{}};if(u.startsWith(":")){const d=u.slice(1);if(!d)return{matched:!1,params:{}};o[d]=decodeURIComponent(p);continue}if(u!==p)return{matched:!1,params:{}}}return!s&&i.length>n.length?{matched:!1,params:{}}:s?{matched:!0,params:o,wildcard:!0}:{matched:!0,params:o}}class ii{constructor(e={}){D(this,"currentPath");D(this,"currentParams",{});D(this,"currentPattern",null);D(this,"enabled",!1);D(this,"hashListener",null);D(this,"listeners",new Set);D(this,"defaultPath");D(this,"mode");D(this,"basePath");D(this,"settingHash",!1);this.defaultPath=De(e.defaultPath??"/"),this.currentPath=this.defaultPath,this.mode=e.mode==="history"?"history":"hash",this.basePath=oi(e.basePath)}configure(e){this.enabled||(e.mode&&(this.mode=e.mode==="history"?"history":"hash"),e.basePath!==void 0&&(this.basePath=oi(e.basePath)))}getMode(){return this.mode}start(){if(this.enabled||(this.enabled=!0,typeof window>"u"))return;const e=r=>{this.settingHash||this.setPath(this.readLocation(),r)};if(this.mode==="history"){const r=()=>e("hashchange");window.addEventListener("popstate",r),this.hashListener=r}else{const r=()=>e("hashchange");window.addEventListener("hashchange",r),this.hashListener=r}e("init")}readLocation(){if(typeof window>"u")return this.currentPath;if(this.mode==="history"){let e=window.location.pathname||"/";return this.basePath&&e.startsWith(this.basePath)&&(e=e.slice(this.basePath.length)||"/"),De(e)}return De(window.location.hash)}stop(){this.enabled&&(this.enabled=!1,typeof window<"u"&&this.hashListener&&(window.removeEventListener("hashchange",this.hashListener),window.removeEventListener("popstate",this.hashListener)),this.hashListener=null)}getPath(){return this.currentPath}getParams(){return this.currentParams}getActivePattern(){return this.currentPattern}setActiveMatch(e,r){this.currentPattern=e,dm(this.currentParams,r)||(this.currentParams=r)}navigate(e){const r=De(e);if(r!==this.currentPath){if(this.enabled&&typeof window<"u"){this.settingHash=!0;try{this.mode==="history"&&typeof window.history?.pushState=="function"?window.history.pushState({},"",(this.basePath||"")+r):window.location.hash="#"+r}finally{queueMicrotask(()=>{this.settingHash=!1})}this.setPath(r,"navigate");return}this.setPath(r,"navigate")}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setPath(e,r){const a=De(e);if(a===this.currentPath)return;const n=this.currentPath;this.currentPath=a,this.currentParams={},this.currentPattern=null;for(const i of[...this.listeners])try{i({path:a,previousPath:n,source:r})}catch(o){console.error("[aktion] router listener failed",o)}}}function oi(t){if(!t)return"";let e=String(t).trim();return e===""||e==="/"?"":(e.startsWith("/")||(e="/"+e),e.endsWith("/")&&(e=e.slice(0,-1)),e)}function dm(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(t[n]!==e[n])return!1;return!0}const je=(t,e)=>{try{return t()}catch{return e}},si=t=>{if(typeof t=="string")return t;if(t===null)return"null";if(t===void 0)return"";try{return JSON.stringify(t)}catch{return String(t)}},li=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},ci=t=>({set:(e,r)=>je(()=>{const a=t();return a?(a.setItem(String(e),si(r)),!0):!1},!1),get:e=>je(()=>{const r=t();return r?li(r.getItem(String(e))):null},null),remove:e=>je(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>je(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),pm=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,mm=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,Ht=()=>typeof globalThis>"u"?null:globalThis.document??null,fm=t=>{if(t==null)return null;if(t instanceof Date)return t.toUTCString();if(typeof t=="string"){const e=new Date(t);return Number.isNaN(e.getTime())?null:e.toUTCString()}if(typeof t=="number"&&Number.isFinite(t)){const e=new Date;return e.setTime(e.getTime()+t*864e5),e.toUTCString()}return null},Dr=(t={})=>{const e=[],r=fm(t.expires);if(r&&e.push(`expires=${r}`),typeof t.maxAge=="number"&&Number.isFinite(t.maxAge)&&e.push(`max-age=${Math.floor(t.maxAge)}`),e.push(`path=${t.path??"/"}`),t.domain&&e.push(`domain=${t.domain}`),t.secure&&e.push("secure"),t.sameSite){const a=t.sameSite.charAt(0).toUpperCase()+t.sameSite.slice(1).toLowerCase();e.push(`samesite=${a}`)}return e.length===0?"":`; ${e.join("; ")}`},ui=()=>{const t=Ht();if(!t)return{};const e={},r=t.cookie??"";if(!r)return e;for(const a of r.split(";")){const n=a.trim();if(!n)continue;const i=n.indexOf("=");if(i<0){e[decodeURIComponent(n)]="";continue}const o=decodeURIComponent(n.slice(0,i)),s=decodeURIComponent(n.slice(i+1));e[o]=s}return e},gm={set:(t,e,r)=>je(()=>{const a=Ht();if(!a)return!1;const n=encodeURIComponent(String(t)),i=encodeURIComponent(si(e));return a.cookie=`${n}=${i}${Dr(r)}`,!0},!1),get:t=>je(()=>{const r=ui()[String(t)];return r===void 0?null:li(r)},null),remove:(t,e)=>je(()=>{const r=Ht();if(!r)return!1;const a=encodeURIComponent(String(t)),n={...e,expires:new Date(0),maxAge:0};return r.cookie=`${a}=${Dr(n)}`,!0},!1),clear:()=>je(()=>{const t=Ht();if(!t)return!1;const e=ui();for(const r of Object.keys(e)){const a=encodeURIComponent(r);t.cookie=`${a}=${Dr({expires:new Date(0),maxAge:0})}`}return!0},!1)},ht=ci(pm),hm=ci(mm),jr={set:ht.set,get:ht.get,remove:ht.remove,clear:ht.clear,local:ht,session:hm,cookies:gm},bm=["log","error","warn","info","debug"],vm=()=>typeof globalThis>"u"?null:globalThis.console??null,ym=t=>(...e)=>{const r=vm();if(!r)return;const a=r[t]??r.log;if(typeof a=="function")try{a(...e)}catch{}},di=bm.reduce((t,e)=>(t[e]=ym(e),t),{}),xm=4e3;function Br(t){return t==null?"":typeof t=="string"?t:String(t)}function pi(t){let e=[];const r=new Map;let a=0;const n=()=>t.notify?.(),i=d=>{const m=r.get(d);m!==void 0&&(clearTimeout(m),r.delete(d))},o=d=>{i(d);const m=e.filter(g=>g.id!==d);m.length!==e.length&&(e=m,p.items=e,n())},s=()=>{if(e.length!==0){for(const d of[...r.keys()])i(d);e=[],p.items=e,n()}},c=(d,m={})=>{const g=`toast-${a+=1}`,b=typeof m.duration=="number"?m.duration:xm,h={id:g,message:Br(d),title:m.title!=null?Br(m.title):void 0,tone:m.tone!=null?Br(m.tone):"default",duration:b,createdAt:Date.now()};return e=[...e,h],p.items=e,b>0&&r.set(g,setTimeout(()=>{r.delete(g),o(g)},b)),n(),g},u=d=>(m,g={})=>c(m,{...g,tone:d}),p={items:e,show:c,success:u("success"),error:u("danger"),info:u("info"),warning:u("warning"),dismiss:o,clear:s};return t.disposers.push(()=>{for(const d of r.values())clearTimeout(d);r.clear(),e=[],p.items=e}),p}const bt={Math,JSON,Object,Array,Number,String,Boolean,Date,Map,Set,WeakMap,WeakSet,RegExp,Symbol,Promise,Error,TypeError,RangeError,Infinity:1/0,NaN:NaN,undefined:void 0,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,encodeURI,decodeURI,structuredClone:typeof structuredClone=="function"?structuredClone:void 0},Or={util:ai,console:di,storage:jr},mi=new Set(["toast"]);function wm(t){return t.toastManager||(t.toastManager=pi(t)),t.toastManager}function fi(t){if(typeof globalThis>"u")return{found:!1,value:void 0};if(t in Object.prototype)return{found:!1,value:void 0};const e=globalThis;return t in e?{found:!0,value:e[t]}:{found:!1,value:void 0}}const Vt={componentDepthLimit:150,iterationLimit:25e4,arrayLengthLimit:1e5};class Be extends Error{constructor(r,a,n){super(km(r,a,n));D(this,"kind");D(this,"limit");D(this,"source");this.name="RuntimeBudgetError",this.kind=r,this.limit=a,this.source=n}}function km(t,e,r){switch(t){case"component-depth":return`[aktion] runtime aborted at ${r}: component recursion exceeded ${e} levels — check for a component that calls itself directly or transitively.`;case"iterations":return`[aktion] runtime aborted at ${r}: exceeded ${e} total loop iterations in a single render — narrow the iterable or split the loop.`;case"array-length":return`[aktion] runtime aborted at ${r}: array length would exceed ${e} elements.`}}function gi(t={}){return{componentDepthLimit:t.componentDepthLimit??Vt.componentDepthLimit,iterationLimit:t.iterationLimit??Vt.iterationLimit,arrayLengthLimit:t.arrayLengthLimit??Vt.arrayLengthLimit,componentDepth:0,iterations:0}}function _r(t){t.iterations=0,t.componentDepth=0}function vt(t,e,r){if(t&&(t.iterations+=e,t.iterations>t.iterationLimit))throw new Be("iterations",t.iterationLimit,r)}function Fr(t,e){const r=t.budget;if(r&&(r.componentDepth+=1,r.componentDepth>r.componentDepthLimit))throw r.componentDepth-=1,new Be("component-depth",r.componentDepthLimit,`component "${e}"`)}function Ur(t){const e=t.budget;e&&e.componentDepth>0&&(e.componentDepth-=1)}const hi=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),bi=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent"),Wt=t=>!!(t&&typeof t=="object"&&t.__kind==="Store");function Hr(t,e={}){const r={state:t,bindings:new Map,expressions:new Map,trackedState:new Set,loopVars:new Map,mutableBindings:new Map,stateAliases:[],router:e.router,library:e.library,componentDecls:new Map,effectDecls:new Map,componentEffectStack:[],actionDecls:new Map,hookDecls:new Map,hookScope:null,hookStore:new Map,stores:new Map,http:e.http,queryCache:new Map,notify:e.notify,onEmit:e.onEmit,strict:e.strict,strictWarned:new Set,disposers:[],timers:{timeouts:new Set,intervals:new Set},budget:e.budget===null?void 0:e.budget??gi()};return r.disposers.push(()=>{for(const a of r.timers.timeouts)clearTimeout(a);for(const a of r.timers.intervals)clearInterval(a);r.timers.timeouts.clear(),r.timers.intervals.clear()}),r}function Vr(t){const e=t.disposers;t.disposers=[];for(const r of e)try{r()}catch(a){console.error("[aktion] context disposer threw",a)}}function vi(t){t.mutableBindings.clear()}function Ae(t,e){for(let r=t.stateAliases.length-1;r>=0;r-=1){const n=t.stateAliases[r].get(e);if(n!==void 0)return n}return e}function qt(t,e){const r=[];let a=t;for(;a.kind==="Member";){if(a.computed){if(a.computed.kind!=="Literal")return null;const n=a.computed.value;if(typeof n!="string"&&typeof n!="number")return null;r.unshift(String(n))}else if(a.property)r.unshift(a.property);else return null;a=a.object}return a.kind!=="StateRef"?null:{name:Ae(e,a.name),path:r}}function Kt(t,e){if(t.kind==="StateRef")return Ae(e,t.name);if(t.kind==="Member"){const r=qt(t,e);if(r)return r.path.length===0?r.name:`${r.name}.${r.path.join(".")}`;const a=Mi(t,e);if(a)return a.path.length===0?a.atom:`${a.atom}.${a.path.join(".")}`}return null}function yi(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const a=Yt(r.expression);e.state.declare(r.identifier,a)}for(const r of t.statements)Wr(r,e);for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||!xi(r.expression))continue;const a=M(r.expression,e);e.state.set(r.identifier,a)}Cm(t,e),$m(t,e)}const Sm=8;function $m(t,e){const r=[],a=o=>{const s=new Set,c=e.trackedState;e.trackedState=s;try{const u=M(o.expr,e);e.state.set(o.name,u)}finally{e.trackedState=c}o.deps=s};for(const o of t.statements){if(o.kind!=="Assignment"||!o.isState||Gt(o.expression)||xi(o.expression))continue;const s={name:o.identifier,expr:o.expression,deps:new Set};r.push(s),a(s)}if(r.length===0)return;let n=!1;const i=e.state.subscribe(o=>{if(!n){n=!0;try{const s=new Set(o);for(let c=0;c<Sm;c+=1){let u=!1;for(const p of r){if(!mt(s,p.deps))continue;const m=e.state.get(p.name);a(p),e.state.get(p.name)!==m&&(s.add(p.name),u=!0)}if(!u)break}}finally{n=!1}}});e.disposers.push(i)}function Gt(t){switch(t.kind){case"Literal":return!0;case"Array":return t.elements.every(e=>e.kind!=="Spread"&&Gt(e));case"Object":return t.properties.every(e=>!e.spread&&!e.computedKey&&Gt(e.value));case"Template":return t.expressions.length===0;default:return!1}}function xi(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="http"}function wi(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="theme"}function ki(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="app"}function Wr(t,e){switch(t.kind){case"ComponentDeclaration":{e.componentDecls.set(t.name,t),e.actionDecls.set(t.name,{kind:"ActionDeclaration",name:t.name,params:t.params,body:t.body,loc:t.loc});return}case"EffectDeclaration":e.effectDecls.set(t.name,t);return;case"ActionDeclaration":e.actionDecls.set(t.name,t);return;case"HookDeclaration":e.hookDecls.set(t.name,t);return;case"Await":case"Return":return;case"Import":return;case"ExpressionStatement":{const r=t.expression;ki(r)?e.bindings.set("aktion",()=>M(r,e)):wi(r)&&e.bindings.set("theme",()=>M(r,e));return}case"Assignment":{if(t.isState)return;e.expressions.set(t.identifier,t.expression);const r=t.expression;e.bindings.set(t.identifier,()=>M(r,e));return}}}function Si(t){switch(t.kind){case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"DestructureStatement":case"ThrowStatement":return!0;case"ExpressionStatement":return!ki(t.expression)&&!wi(t.expression);default:return!1}}function Cm(t,e){let r=!1;for(const a of t.statements)if(Si(a)){r=!0;break}if(r){for(const a of t.statements)a.kind==="Assignment"&&a.isState&&Gt(a.expression)&&e.state.set(a.identifier,Yt(a.expression));for(const a of t.statements)if(Si(a))try{qr(a,e)}catch(n){if(n instanceof ke||n instanceof Te||n instanceof nt)continue;if(n instanceof Be)throw n;console.error("[aktion] top-level statement threw",n)}}}function Am(t,e,r){const a=t[0];if(!a||a.kind!=="Object")return console.error('[aktion] $router expects an object literal of route arms (e.g. `$router({ "/": Home(), default: NotFound() })`).',r),e.router?.setActiveMatch(null,{}),null;const n=df(e);let i=null;for(const o of a.properties){if(o.spread)continue;const s=o.key;if(s==="default"||s==="*"){i=o;continue}const c=ni(s,n);if(c.matched)return $i(s,o.value,c.params,e)}return i?$i(null,i.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function $i(t,e,r,a){const n=a.loopVars.get("params"),i=a.loopVars.has("params");a.loopVars.set("params",r);try{const o=M(e,a);return a.router?.setActiveMatch(t,r),o}finally{i?a.loopVars.set("params",n):a.loopVars.delete("params")}}function Yt(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(Yt(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=Yt(r.value));return e}case"Template":return t.expressions.length===0?t.quasis[0]??"":null;default:return null}}function M(t,e){switch(t.kind){case"Literal":return t.value;case"Identifier":{if(e.loopVars.has(t.name))return e.loopVars.get(t.name);if(e.mutableBindings.has(t.name))return e.mutableBindings.get(t.name);if(t.name==="route")return e.trackedState.add("route"),e.router?pf(e.router):{path:"/",params:{},pattern:null,query:{},navigate(){},toString(){return"/"}};const r=e.bindings.get(t.name);if(r){const o=r();return e.mutableBindings.set(t.name,o),o}const a=e.actionDecls.get(t.name);if(a)return rf(a,e);const n=e.componentDecls.get(t.name);if(n)return af(n);if(Object.prototype.hasOwnProperty.call(bt,t.name))return bt[t.name];if(e.library&&Ee(e.library,t.name))return nf(t.name);if(t.name==="cleanup"&&e.cleanupSink){const o=e.cleanupSink;return s=>{typeof s=="function"&&o(s)}}const i=fi(t.name);if(i.found)return i.value;if(e.strict&&!e.strictWarned.has(t.name)){e.strictWarned.add(t.name);const o=t.loc?` (line ${t.loc.line}, col ${t.loc.column})`:"";console.warn(`[aktion] strict: unknown identifier "${t.name}" resolved to null${o}. Did you misspell a state atom, action, or component name?`)}return null}case"StateRef":{if(Object.prototype.hasOwnProperty.call(Or,t.name))return Or[t.name];if(mi.has(t.name)&&t.name==="toast")return wm(e);if(t.name==="emit"&&e.onEmit){const a=e.onEmit;return(n,i)=>{a(n==null?"":String(n),i)}}const r=Ae(e,t.name);return e.trackedState.add(r),e.state.get(r)}case"Array":{const r=[];for(const a of t.elements){if(a.kind==="Spread"){const n=M(a.argument,e);if(Array.isArray(n))for(const i of n)r.push(i);else if(n!=null&&typeof n=="string")for(const i of n)r.push(i);continue}r.push(M(a,e))}return r}case"Object":{const r={};for(const a of t.properties){if(a.spread){const i=M(a.value,e);if(i&&typeof i=="object"&&!Array.isArray(i))for(const[o,s]of Object.entries(i))r[o]=s;continue}const n=a.computedKey?String(M(a.computedKey,e)??""):a.key;r[n]=M(a.value,e)}return r}case"Member":{if(Rm(t))return Dm(t,e);const r=jm(t,e);if(r)return Bm(t,e,r);const a=M(t.object,e);if(t.optional&&a==null)return;if(t.computed){const n=M(t.computed,e);return Yr(a,n)}return Xr(a,t.property??"")}case"Unary":{if(t.operator==="delete"){const a=t.argument;if(a.kind==="Member"&&a.property){const n=M(a.object,e);if(n&&typeof n=="object")try{return delete n[a.property],!0}catch{return!1}}return!1}const r=M(t.argument,e);switch(t.operator){case"!":return!r;case"-":return-_(r);case"+":return+_(r);case"~":return~se(r);case"typeof":return typeof r;case"void":return;default:return r}}case"Binary":return Hm(t.operator,t.left,t.right,e);case"Ternary":{const r=M(t.test,e);return M(r?t.consequent:t.alternate,e)}case"Call":return Wm(t.callee,t.arguments,e,t.loc);case"MethodCall":return Vm(t,e);case"Invoke":return _m(t,e);case"New":return Fm(t,e);case"BuiltinCall":return of(t.name,t.arguments,e);case"Template":return Um(t.quasis,t.expressions,e);case"Spread":return M(t.argument,e);case"Block":return Kr(t,e,{});case"Lambda":{const r=t.params,a=t.body,n=e.stateAliases.map(o=>new Map(o)),i=new Map(e.loopVars);return(...o)=>{const s=new Map(e.loopVars),c=e.stateAliases.slice();e.loopVars.clear();for(const[d,m]of i)e.loopVars.set(d,m);e.stateAliases.length=0;for(const d of n)e.stateAliases.push(d);const u=[],p=(d,m)=>{u.push({name:d,had:e.loopVars.has(d),prev:e.loopVars.get(d)}),e.loopVars.set(d,m)};for(let d=0;d<r.length;d+=1){const m=r[d];let g=o[d];if(g===void 0&&m.defaultValue&&(g=M(m.defaultValue,e)),m.pattern){for(const b of yt(m.pattern,g,e))p(b.name,b.value);continue}p(m.name,g)}try{return M(a,e)}finally{for(const d of u)d.had?e.loopVars.set(d.name,d.prev):e.loopVars.delete(d.name);e.loopVars.clear();for(const[d,m]of s)e.loopVars.set(d,m);e.stateAliases.length=0;for(const d of c)e.stateAliases.push(d)}}}default:return null}}class ke{constructor(){D(this,"kind","break")}}class Te{constructor(){D(this,"kind","continue")}}class nt{constructor(e){D(this,"kind","return");this.value=e}}function Ci(t,e){if(M(t.test,e)){Se(t.consequent.body,e);return}if(t.alternate){if(t.alternate.kind==="IfStatement"){Ci(t.alternate,e);return}t.alternate.kind==="Block"&&Se(t.alternate.body,e)}}function Tm(t,e){const r=M(t.discriminant,e);let a=!1;try{for(const n of t.cases)a||(n.test===null||M(n.test,e)===r)&&(a=!0),a&&Se(n.body,e)}catch(n){if(n instanceof ke)return;throw n}}function Mm(t,e){const r=M(t.iterable,e);if(!Array.isArray(r)&&(r==null||typeof r!="object"||!(Symbol.iterator in r)))return;const a=e.loopVars.has(t.item),n=e.loopVars.get(t.item),i=t.index,o=i?e.loopVars.has(i):!1,s=i?e.loopVars.get(i):void 0,c=t.destructure??[],u=c.map(p=>({name:p,had:e.loopVars.has(p),value:e.loopVars.get(p)}));try{let p=0;const d=(Array.isArray(r),r);for(const m of d){vt(e.budget,1,"`for…of` loop"),e.loopVars.set(t.item,m),i&&e.loopVars.set(i,p);for(const g of c){const b=m&&typeof m=="object"?m[g]:void 0;e.loopVars.set(g,b)}try{Se(t.body.body,e)}catch(g){if(g instanceof Te){p+=1;continue}if(g instanceof ke)return;throw g}p+=1}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item),i&&(o?e.loopVars.set(i,s):e.loopVars.delete(i));for(const p of u)p.had?e.loopVars.set(p.name,p.value):e.loopVars.delete(p.name)}}function Nm(t,e){for(t.init&&Xt(t.init,e);!(t.test&&!M(t.test,e));){vt(e.budget,1,"`for` loop");try{Se(t.body.body,e)}catch(r){if(!(r instanceof Te)){if(r instanceof ke)return;throw r}}t.update&&M(t.update,e)}}function Pm(t,e){for(;M(t.test,e);){vt(e.budget,1,"`while` loop");try{Se(t.body.body,e)}catch(r){if(r instanceof Te)continue;if(r instanceof ke)return;throw r}}}function Im(t,e){for(;;){vt(e.budget,1,"`do…while` loop");try{Se(t.body.body,e)}catch(r){if(!(r instanceof Te)){if(r instanceof ke)return;throw r}}if(!M(t.test,e))break}}function Em(t,e){const r=M(t.expression,e),a=yt({kind:t.patternKind,bindings:t.bindings},r,e);for(const{name:n,value:i}of a)e.loopVars.set(n,i)}function yt(t,e,r){const a=[];if(t.kind==="array"){const o=Array.isArray(e)?e:[];let s=0;for(const c of t.bindings){if(c.rest){a.push({name:c.name,value:o.slice(s)}),s=o.length;continue}let u=o[s];u===void 0&&c.defaultValue&&(u=M(c.defaultValue,r)),c.name!==""&&a.push({name:c.name,value:u}),s+=1}return a}const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},i=new Set;for(const o of t.bindings){if(o.rest){const u={};for(const[p,d]of Object.entries(n))i.has(p)||(u[p]=d);a.push({name:o.name,value:u});continue}const s=o.sourceKey??o.name;i.add(s);let c=n[s];c===void 0&&o.defaultValue&&(c=M(o.defaultValue,r)),a.push({name:o.name,value:c})}return a}function Lm(t,e){const r=M(t.iterable,e);if(r==null||typeof r!="object")return;const a=e.loopVars.has(t.item),n=e.loopVars.get(t.item);try{for(const i in r){vt(e.budget,1,"`for…in` loop"),e.loopVars.set(t.item,i);try{Se(t.body.body,e)}catch(o){if(o instanceof Te)continue;if(o instanceof ke)return;throw o}}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item)}}function zm(t,e){try{Se(t.block.body,e)}catch(r){if(r instanceof ke||r instanceof Te||r instanceof nt)throw r;if(t.catchBlock){const a=t.catchParam,n=a?e.loopVars.has(a):!1,i=a?e.loopVars.get(a):void 0;a&&e.loopVars.set(a,r);try{Se(t.catchBlock.body,e)}finally{a&&(n?e.loopVars.set(a,i):e.loopVars.delete(a))}}}finally{t.finallyBlock&&Se(t.finallyBlock.body,e)}}function Se(t,e){for(const r of t)Xt(r,e)}function qr(t,e){Xt(t,e)}function Xt(t,e){switch(t.kind){case"ExpressionStatement":M(t.expression,e);return;case"Assignment":{const r=M(t.expression,e);if(t.identifier)if(t.isState){const a=Ae(e,t.identifier);e.state.set(a,r)}else e.bindings.has(t.identifier)&&!e.loopVars.has(t.identifier)?e.mutableBindings.set(t.identifier,r):e.loopVars.set(t.identifier,r);return}case"IfStatement":Ci(t,e);return;case"SwitchStatement":Tm(t,e);return;case"ForOfStatement":Mm(t,e);return;case"ForClassicStatement":Nm(t,e);return;case"ForInStatement":Lm(t,e);return;case"WhileStatement":Pm(t,e);return;case"DoWhileStatement":Im(t,e);return;case"DestructureStatement":Em(t,e);return;case"TryStatement":zm(t,e);return;case"BreakStatement":throw new ke;case"ContinueStatement":throw new Te;case"ThrowStatement":throw M(t.argument,e);case"Return":{const r=t.argument?M(t.argument,e):void 0;throw new nt(r)}case"Await":M(t.argument,e);return;default:return}}function Rm(t){let e=t;for(;e.kind==="Member";)e=e.object;return e.kind==="StateRef"&&(Object.prototype.hasOwnProperty.call(Or,e.name)||mi.has(e.name))?!1:e.kind==="StateRef"}function Dm(t,e){const r=Ai(t);let a=t;for(;a.kind==="Member";)a=a.object;const n=Ae(e,a.name);return Ti(r,n,e)}function Ai(t){const e=[];let r=t;for(;r.kind==="Member";)e.unshift({property:r.property,computed:r.computed}),r=r.object;return e}function Ti(t,e,r){let a=r.state.get(e);const n=[e];let i=!0;for(const o of t){let s,c=null;o.computed?o.computed.kind==="Literal"?(s=o.computed.value,(typeof s=="string"||typeof s=="number")&&(c=String(s))):s=M(o.computed,r):(s=o.property??"",c=o.property??"");const u=a!=null&&typeof a=="object"&&!Array.isArray(a);i&&c!==null&&u?n.push(c):i=!1,a=o.computed?Yr(a,s):Xr(a,o.property??"")}return r.trackedState.add(n.join(".")),a}function jm(t,e){let r=t;for(;r.kind==="Member";)r=r.object;if(r.kind!=="Identifier")return null;const a=M(r,e);return Wt(a)?a:null}function Bm(t,e,r){const a=Ai(t),n=a[0];if(n&&n.computed===void 0&&n.property!==void 0&&Object.prototype.hasOwnProperty.call(r.__methods,n.property)){let i=r.__methods[n.property];for(let o=1;o<a.length;o+=1){const s=a[o];s.computed?i=Yr(i,M(s.computed,e)):i=Xr(i,s.property??"")}return i}return Ti(a,r.__atom,e)}function Om(t,e,r){const a=r?`${r.line}:${r.column}`:`anon:${e.stores.size}`,n=e.stores.get(a);if(n)return n;const i=t[0]?M(t[0],e):{},o={},s={};if(i&&typeof i=="object"&&!Array.isArray(i))for(const[d,m]of Object.entries(i))typeof m=="function"?s[d]=m:o[d]=m;const c=r?`__store_${r.line}_${r.column}`:`__store_anon_${e.stores.size}`;e.state.declare(c,o);const u={},p={__kind:"Store",__atom:c,__methods:u};for(const[d,m]of Object.entries(s))u[d]=(...g)=>m(p,...g);return e.stores.set(a,p),p}function Mi(t,e){const r=[];let a=t;for(;a.kind==="Member";){if(a.computed){if(a.computed.kind!=="Literal")return null;const i=a.computed.value;if(typeof i!="string"&&typeof i!="number")return null;r.unshift(String(i))}else if(a.property)r.unshift(a.property);else return null;a=a.object}if(a.kind!=="Identifier")return null;const n=M(a,e);return Wt(n)?{atom:n.__atom,path:r}:null}function _m(t,e){if(t.callee.kind==="StateRef"){const n=t.callee.name;if(n==="state")return Xm(t.arguments,e,t.loc);if(n==="memo")return Jm(t.arguments,e,t.loc);if(n==="ref")return Zm(t.arguments,e,t.loc);if(n==="reducer")return Qm(t.arguments,e,t.loc);if(n==="id")return ef(t.arguments,e,t.loc);switch(n){case"store":return Om(t.arguments,e,t.loc);case"router":return Am(t.arguments,e,t.loc);case"http":{const o=t.arguments[0];return Lr(o?M(o,e):{},e)}case"query":{const o=t.arguments[0];return ei(o?M(o,e):{},e)}case"mutation":{const o=t.arguments[0];return ti(o?M(o,e):{},e)}case"theme":{const o=t.arguments[0];return{kind:"Theme",tokens:gf(o?M(o,e):null)}}case"app":{const o=t.arguments;return o.length===1?M(o[0],e):o.map(s=>M(s,e))}case"i18n":{const o=t.arguments[0],s=o?M(o,e):null,c=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return ri(c)}case"emit":{const o=t.arguments[0]?String(M(t.arguments[0],e)):"",s=t.arguments[1]?M(t.arguments[1],e):void 0;e.onEmit?.(o,s);return}case"storage":return t.arguments[0]&&M(t.arguments[0],e),jr;case"optimistic":return Gm(t.arguments[0],e)}const i=e.hookDecls.get(n);if(i)return tf(i,t.arguments,e)}const r=M(t.callee,e);if(r==null)return t.optional?void 0:null;if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=M(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(M(n,e))}try{return r.apply(void 0,a)}catch(n){return console.error("[aktion] call expression threw",n),null}}function Fm(t,e){const r=M(t.callee,e);if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=M(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(M(n,e))}try{return Reflect.construct(r,a)}catch(n){return console.error("[aktion] `new` threw",n),null}}function Kr(t,e,r){let a=null;const n=[];try{for(const i of t.body)switch(i.kind){case"ExpressionStatement":a=M(i.expression,e);continue;case"Assignment":{if(i.isState&&i.identifier){const s=Ae(e,i.identifier);if(r.stateAsDeclaration){if(e.state.has(s)){a=e.state.get(s);continue}const u=M(i.expression,e);e.state.declare(s,u),a=u;continue}const c=M(i.expression,e);e.state.set(s,c),a=c;continue}const o=M(i.expression,e);e.bindings.has(i.identifier)&&!e.loopVars.has(i.identifier)?e.mutableBindings.set(i.identifier,o):(e.loopVars.has(i.identifier)||n.push(i.identifier),e.loopVars.set(i.identifier,o)),a=o;continue}case"Return":return a=i.argument?M(i.argument,e):void 0,a;case"ThrowStatement":throw M(i.argument,e);case"EffectDeclaration":{const o=e.componentEffectStack[e.componentEffectStack.length-1];o?o.push({decl:i,capturedAliases:e.stateAliases.map(s=>new Map(s)),capturedLoopVars:new Map(e.loopVars)}):Wr(i,e);continue}case"ComponentDeclaration":case"ActionDeclaration":case"HookDeclaration":Wr(i,e);continue;case"Await":continue;case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"DestructureStatement":Xt(i,e);continue}}catch(i){if(i instanceof nt)return i.value;throw i}finally{for(const i of n)e.loopVars.delete(i)}return a}function Um(t,e,r){let a=t[0]??"";for(let n=0;n<e.length;n+=1)a+=Jr(M(e[n],r)),a+=t[n+1]??"";return a}function Hm(t,e,r,a){if(t==="&&"){const o=M(e,a);return o&&M(r,a)}if(t==="||"){const o=M(e,a);return o||M(r,a)}if(t==="??"){const o=M(e,a);return o??M(r,a)}const n=M(e,a),i=M(r,a);switch(t){case"+":return typeof n=="string"||typeof i=="string"?Jr(n)+Jr(i):_(n)+_(i);case"-":return _(n)-_(i);case"*":return _(n)*_(i);case"/":{const o=_(i);return o===0?0:_(n)/o}case"%":{const o=_(i);return o===0?0:_(n)%o}case"**":return _(n)**_(i);case"==":case"===":return n===i;case"!=":case"!==":return n!==i;case">":return _(n)>_(i);case"<":return _(n)<_(i);case">=":return _(n)>=_(i);case"<=":return _(n)<=_(i);case"&":return se(n)&se(i);case"|":return se(n)|se(i);case"^":return se(n)^se(i);case"<<":return se(n)<<(Oe(i)&31);case">>":return se(n)>>(Oe(i)&31);case">>>":return Oe(n)>>>(Oe(i)&31);case"instanceof":{if(typeof i!="function")return!1;try{return n instanceof i}catch{return!1}}case"in":{if(i==null||typeof i!="object"&&typeof i!="function")return!1;try{return String(n)in i}catch{return!1}}default:return null}}function se(t){return _(t)|0}function Oe(t){return _(t)>>>0}function Vm(t,e){const r=M(t.object,e);if(r==null)return t.optional?void 0:null;const a=Wt(r)?r.__methods[t.method]:r[t.method];if(typeof a!="function")return null;const n=[];for(const o of t.arguments){if(o.kind==="Spread"){const s=M(o.argument,e);if(Array.isArray(s))for(const c of s)n.push(c);continue}n.push(M(o,e))}const i=n;try{return a.apply(r,i)}catch(o){if(o instanceof RangeError||o instanceof Be)throw o;return console.error(`[aktion] method "${t.method}" threw`,o),null}}function Wm(t,e,r,a){const n=r.componentDecls.get(t);if(n)return Km(n,e,r,a);const i=r.actionDecls.get(t);if(i){const g=e.map(b=>M(b,r));return Pi(i,g,r)}if(t==="cleanup"&&r.cleanupSink){const g=e[0]?M(e[0],r):void 0;typeof g=="function"&&r.cleanupSink(g);return}if(t==="setTimeout"||t==="setInterval")return sf(t,e,r);if(t==="clearTimeout"||t==="clearInterval"){const g=e[0]?M(e[0],r):void 0;g!=null&&(t==="clearTimeout"?(clearTimeout(g),r.timers.timeouts.delete(g)):(clearInterval(g),r.timers.intervals.delete(g)));return}const o=r.loopVars.get(t);if(typeof o=="function"){const g=e.map(b=>M(b,r));return o(...g)}const s=r.bindings.get(t);if(s){const g=s();if(typeof g=="function"){const b=e.map(h=>M(h,r));return g(...b)}}if(Object.prototype.hasOwnProperty.call(bt,t)&&typeof bt[t]=="function"&&!r.componentDecls.has(t)&&!(r.library&&Ee(r.library,t))){const g=bt[t],b=[];for(const h of e){if(h.kind==="Spread"){const v=M(h.argument,r);if(Array.isArray(v))for(const y of v)b.push(y);continue}b.push(M(h,r))}try{return g(...b)}catch(h){return console.error(`[aktion] global "${t}" threw`,h),null}}if(r.library&&!Ee(r.library,t)){const g=fi(t);if(g.found&&typeof g.value=="function"){const b=g.value,h=[];for(const v of e){if(v.kind==="Spread"){const y=M(v.argument,r);if(Array.isArray(y))for(const x of y)h.push(x);continue}h.push(M(v,r))}try{return b(...h)}catch(v){return console.error(`[aktion] global "${t}" threw`,v),null}}return Ee(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:a}:null}let c;const u=[...e];if(u.length>0){const g=u[u.length-1];if(g.kind==="Object"){const b=g.properties.find(h=>!h.spread&&h.key==="key");if(b){c=M(b.value,r);const h=g.properties.filter(v=>v!==b);h.length>0?u[u.length-1]={...g,properties:h}:u.pop()}}}const{args:p,argMeta:d}=qm(r,t,u);return{__kind:"Component",name:t,args:p,argMeta:d,explicitKey:c,source:a}}function qm(t,e,r){const a=t.library?Ee(t.library,e):void 0;if(!a){const m=r.map(b=>M(b,t)),g=r.map(b=>{const h=Kt(b,t);return h!==null?{stateRef:h}:{}});return{args:m,argMeta:g}}const n=new Map;a.props.forEach((m,g)=>{if(n.set(m.name,g),m.aliases)for(const b of m.aliases)n.has(b)||n.set(b,g)});const i=dr(a),o=a.props.map(()=>({value:void 0,meta:{},filled:!1})),s=[];let c=-1;for(let m=r.length-1;m>=0;m-=1)if(r[m].kind==="Object"){c=m;break}for(let m=0;m<r.length;m+=1){if(m===c)continue;const g=r[m];s.push({expr:g,value:M(g,t)})}if(c>=0){const m=r[c];if(m.kind==="Object")for(const g of m.properties){if(g.spread)continue;const b=n.get(g.key);if(b===void 0)continue;const h=M(g.value,t);o[b].value=h,o[b].filled=!0;const v=Kt(g.value,t);v!==null&&(o[b].meta={stateRef:v})}}if(s.length>0&&i>=0&&!o[i].filled){const{expr:m,value:g}=s.shift();o[i].value=g,o[i].filled=!0;const b=Kt(m,t);b!==null&&(o[i].meta={stateRef:b})}let u=0;for(const{expr:m,value:g}of s){for(;u<a.props.length&&o[u].filled;)u+=1;if(u>=a.props.length)break;o[u].value=g,o[u].filled=!0;const b=Kt(m,t);b!==null&&(o[u].meta={stateRef:b}),u+=1}const p=o.map(m=>m.value),d=o.map(m=>m.meta);for(;p.length>0&&p[p.length-1]===void 0;)p.pop(),d.pop();return{args:p,argMeta:d}}function Km(t,e,r,a){const n=[],i={};let o,s=-1;for(let b=e.length-1;b>=0;b-=1)if(e[b].kind==="Object"){s=b;break}let c=s>=0?e[s]:null,u=!1;if(c&&c.kind==="Object"){const b=new Set(t.params.map(v=>v.name)),h=[];for(const v of c.properties)v.spread||(h.push(v.key),(v.key==="key"||b.has(v.key))&&(u=!0));if(!u&&r.strict&&h.length>0&&t.params.length>0){const v=`trailing:${t.name}:${h.slice().sort().join(",")}`;if(!r.strictWarned.has(v)){r.strictWarned.add(v);const y=a?` (line ${a.line}, col ${a.column})`:"";console.warn(`[aktion] strict: object { ${h.join(", ")} } passed to <${t.name}>${y} is being forwarded as a positional argument because none of its keys match a parameter (${t.params.map(x=>x.name).join(", ")||"none"}). If you meant named props, check for a renamed/misspelled parameter.`)}}}u||(s=-1,c=null);for(let b=0;b<e.length;b+=1)b!==s&&n.push(e[b]);if(c&&c.kind==="Object")for(const b of c.properties)b.spread||(b.key==="key"?o=b.value:i[b.key]=b.value);const p=n.map(b=>b.kind==="Spread"?M(b.argument,r):M(b,r)),d=[];for(let b=0;b<n.length;b+=1){const h=n[b],v=p[b];if(h.kind==="Spread"&&Array.isArray(v))for(const y of v)d.push(y);else d.push(v)}const m={};for(const[b,h]of Object.entries(i))m[b]=M(h,r);const g=o?M(o,r):void 0;return{__kind:"UserComponent",decl:t,positional:d,named:m,explicitKey:g,source:a}}function Ni(t,e,r){const{decl:a,positional:n,named:i}=t,o=[],s=(m,g)=>{o.push({name:m,had:e.loopVars.has(m),prev:e.loopVars.get(m)}),e.loopVars.set(m,g)};for(let m=0;m<a.params.length;m+=1){const g=a.params[m];if(g.pattern){let h=n[m];h===void 0&&g.defaultValue&&(h=M(g.defaultValue,e));for(const v of yt(g.pattern,h,e))s(v.name,v.value);continue}let b;i[g.name]!==void 0?b=i[g.name]:n[m]!==void 0?b=n[m]:g.defaultValue?b=M(g.defaultValue,e):b=void 0,s(g.name,b)}if(n.length>a.params.length){const m=n.slice(a.params.length),g=m.length===1?m[0]:m;o.push({name:"children",had:e.loopVars.has("children"),prev:e.loopVars.get("children")}),e.loopVars.set("children",g)}if(a.slots.length>0){const m={};for(const g of a.slots)i[g]!==void 0&&(m[g]=i[g]);o.push({name:"slots",had:e.loopVars.has("slots"),prev:e.loopVars.get("slots")}),e.loopVars.set("slots",m)}const c=new Map;for(const m of a.body.body)if(m.kind==="Assignment"&&m.isState){const g=`${r}:${m.identifier}`;c.set(m.identifier,g)}e.stateAliases.push(c);const u=[];e.componentEffectStack.push(u);const p=e.hookScope,d={instanceKey:r,cursor:0};e.hookScope=d;try{return{value:Kr(a.body,e,{stateAsDeclaration:!0}),effects:u,hooks:d.cursor}}finally{e.hookScope=p,e.componentEffectStack.pop(),e.stateAliases.pop();for(const m of o)m.had?e.loopVars.set(m.name,m.prev):e.loopVars.delete(m.name)}}function Pi(t,e,r){return Ii(t.params,t.body,e,r)}function Gm(t,e){const r=t?M(t,e):void 0;if(typeof r!="function")return;const a=new Map;for(const[i,o]of e.state.entries())a.set(i,o);const n=()=>{for(const i of[...e.state.entries()].map(([o])=>o))a.has(i)||e.state.set(i,void 0);for(const[i,o]of a)e.state.set(i,o);e.notify?.()};try{const i=r();return i&&typeof i.then=="function"?i.catch(o=>{throw n(),o}):i}catch(i){throw i instanceof nt||i instanceof ke||i instanceof Te||n(),i}}function Ii(t,e,r,a){const n=[],i=(o,s)=>{n.push({name:o,had:a.loopVars.has(o),prev:a.loopVars.get(o)}),a.loopVars.set(o,s)};for(let o=0;o<t.length;o+=1){const s=t[o];let c=r[o];if(c===void 0&&s.defaultValue&&(c=M(s.defaultValue,a)),s.pattern){for(const u of yt(s.pattern,c,a))i(u.name,u.value);continue}i(s.name,c)}try{return Kr(e,a,{stateAsDeclaration:a.state.isRendering()})}finally{for(const o of n)o.had?a.loopVars.set(o.name,o.prev):a.loopVars.delete(o.name)}}function xt(t){const e=t.hookScope;if(!e)return null;let r=t.hookStore.get(e.instanceKey);return r||(r=[],t.hookStore.set(e.instanceKey,r)),r}function Ym(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Object.is(t[r],e[r]))return!1;return!0}function Xm(t,e,r){const a=xt(e);if(!a)return wt("state",r),[t[0]?M(t[0],e):void 0,()=>{}];const n=e.hookScope.cursor++;let i=a[n];(!i||i.kind!=="state")&&(i={kind:"state",value:t[0]?M(t[0],e):void 0},a[n]=i);const o=i,s=c=>{const u=typeof c=="function"?c(o.value):c;Object.is(u,o.value)||(o.value=u,e.notify?.())};return[o.value,s]}function Jm(t,e,r){const a=t[0],n=t[1],i=()=>{const m=a?M(a,e):void 0;return typeof m=="function"?m():m},o=xt(e);if(!o)return wt("memo",r),i();const s=e.hookScope.cursor++,c=n?M(n,e):void 0,u=Array.isArray(c)?c:void 0,p=o[s];if(p&&p.kind==="memo"&&u&&p.deps&&Ym(p.deps,u))return p.value;const d=i();return o[s]={kind:"memo",deps:u,value:d},d}function Zm(t,e,r){const a=xt(e);if(!a)return wt("ref",r),{current:t[0]?M(t[0],e):void 0};const n=e.hookScope.cursor++;let i=a[n];return(!i||i.kind!=="ref")&&(i={kind:"ref",box:{current:t[0]?M(t[0],e):void 0}},a[n]=i),i.box}function Qm(t,e,r){const a=t[0]?M(t[0],e):void 0,n=xt(e),i=t[1]?M(t[1],e):void 0;if(!n)return wt("reducer",r),[i,()=>{}];const o=e.hookScope.cursor++;let s=n[o];(!s||s.kind!=="reducer")&&(s={kind:"reducer",value:i},n[o]=s);const c=s,u=p=>{if(typeof a!="function")return;const d=a(c.value,p);Object.is(d,c.value)||(c.value=d,e.notify?.())};return[c.value,u]}let Ei=0;function ef(t,e,r){const a=t[0]?String(M(t[0],e)):"rui",n=xt(e);if(!n)return wt("id",r),`${a}-${Ei+=1}`;const i=e.hookScope.cursor++;let o=n[i];return(!o||o.kind!=="id")&&(o={kind:"id",value:`${a}-${Ei+=1}`},n[i]=o),o.value}function tf(t,e,r){const a=[];for(const n of e){if(n.kind==="Spread"){const i=M(n.argument,r);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(M(n,r))}return Ii(t.params,t.body,a,r)}let Li=!1;function wt(t,e){Li||(Li=!0,console.error(`[aktion] $${t}(...) was called outside a component render. Hooks may only be called at the top level of a component body or another $hook.`,e))}function zi(t,e){t.hookStore.delete(e)}function rf(t,e){const r=e.stateAliases.map(n=>new Map(n)),a=new Map(e.loopVars);return(...n)=>{const i=new Map(e.loopVars),o=e.stateAliases.slice();e.loopVars.clear();for(const[s,c]of a)e.loopVars.set(s,c);e.stateAliases.length=0;for(const s of r)e.stateAliases.push(s);try{return Pi(t,n,e)}finally{e.loopVars.clear();for(const[s,c]of i)e.loopVars.set(s,c);e.stateAliases.length=0;for(const s of o)e.stateAliases.push(s)}}}function af(t,e){return(...r)=>({__kind:"UserComponent",decl:t,positional:r,named:{},explicitKey:void 0,source:t.loc})}function nf(t,e){return(...r)=>({__kind:"Component",name:t,args:r,argMeta:r.map(()=>({})),source:void 0})}function of(t,e,r){return t==="__rui_assign__"?lf(e,r):t==="__rui_postfix__"?cf(e,r):t==="__rui_prefix__"?uf(e,r):t==="__rui_await__"?e[0]?M(e[0],r):void 0:null}function _e(t,e,r){switch(t){case"=":return r;case"+=":return typeof e=="string"||typeof r=="string"?`${e??""}${r??""}`:_(e)+_(r);case"-=":return _(e)-_(r);case"*=":return _(e)*_(r);case"/=":{const a=_(r);return a===0?0:_(e)/a}case"%=":{const a=_(r);return a===0?0:_(e)%a}case"**=":return _(e)**_(r);case"&&=":return e&&r;case"||=":return e||r;case"??=":return e??r;case"&=":return se(e)&se(r);case"|=":return se(e)|se(r);case"^=":return se(e)^se(r);case"<<=":return se(e)<<(Oe(r)&31);case">>=":return se(e)>>(Oe(r)&31);case">>>=":return Oe(e)>>>(Oe(r)&31);default:return r}}function sf(t,e,r){const a=e[0]?M(e[0],r):null;if(typeof a!="function")return null;const n=a,i=e[1]?_(M(e[1],r)):0,o=[];for(let u=2;u<e.length;u+=1)o.push(M(e[u],r));const s=()=>{try{n(...o)}catch(u){console.error(`[aktion] ${t} callback threw`,u)}finally{r.notify?.()}};if(t==="setTimeout"){const u=setTimeout(()=>{r.timers.timeouts.delete(u),s()},i);return r.timers.timeouts.add(u),u}const c=setInterval(s,i);return r.timers.intervals.add(c),c}function lf(t,e){const[r,a,n]=t;if(!r||!a)return null;const i=n&&n.kind==="Literal"?String(n.value??"="):"=",o=M(a,e);if(r.kind==="StateRef"){const s=Ae(e,r.name),c=e.state.get(s),u=_e(i,c,o);return e.state.set(s,u),u}if(r.kind==="Member"){const s=qt(r,e);if(s){const d=e.state.get(s.name);if(s.path.length>=1&&Jn(d)){let b=d;for(let h=0;h<s.path.length-1;h+=1)b=b?.[s.path[h]];if(b&&typeof b=="object"){const h=s.path[s.path.length-1],v=b[h],y=_e(i,v,o);return b[h]=y,e.notify?.(),y}}const m=Gr(d,s.path),g=_e(i,m,o);return e.state.setPath(s.name,s.path,g),g}const c=Mi(r,e);if(c){const d=Gr(e.state.get(c.atom),c.path),m=_e(i,d,o);return e.state.setPath(c.atom,c.path,m),m}const u=M(r.object,e),p=r.computed?r.computed.kind==="Literal"?r.computed.value:null:r.property;if(u&&typeof u=="object"&&p!=null){const d=u[String(p)],m=_e(i,d,o);return u[String(p)]=m,m}return o}if(r.kind==="Identifier"){const s=r.name;if(e.loopVars.has(s)){const p=e.loopVars.get(s),d=_e(i,p,o);return e.loopVars.set(s,d),d}if(e.bindings.has(s)||e.mutableBindings.has(s)){const p=e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)(),d=_e(i,p,o);return e.mutableBindings.set(s,d),d}const c=e.loopVars.get(s),u=_e(i,c,o);return e.loopVars.set(s,u),u}return o}function Gr(t,e){let r=t;for(const a of e){if(r==null)return;if(Array.isArray(r)){const n=Number(a);r=Number.isNaN(n)?void 0:r[n];continue}if(typeof r=="object"){r=r[a];continue}return}return r}function Ri(t,e,r){const[a,n]=t;if(!a)return null;const o=(n&&n.kind==="Literal"?String(n.value??"++"):"++")==="--"?-1:1;if(a.kind==="StateRef"){const s=Ae(e,a.name),c=_(e.state.get(s)),u=c+o;return e.state.set(s,u),r==="prefix"?u:c}if(a.kind==="Member"){const s=qt(a,e);if(s){const c=_(Gr(e.state.get(s.name),s.path)),u=c+o;return e.state.setPath(s.name,s.path,u),r==="prefix"?u:c}}if(a.kind==="Identifier"){const s=a.name;if(e.loopVars.has(s)){const p=_(e.loopVars.get(s)),d=p+o;return e.loopVars.set(s,d),r==="prefix"?d:p}if(e.bindings.has(s)||e.mutableBindings.has(s)){const p=_(e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)()),d=p+o;return e.mutableBindings.set(s,d),r==="prefix"?d:p}const c=_(e.loopVars.get(s)),u=c+o;return e.loopVars.set(s,u),r==="prefix"?u:c}return null}function cf(t,e){return Ri(t,e,"postfix")}function uf(t,e){return Ri(t,e,"prefix")}function df(t){if(t.trackedState.add("route"),t.router)return t.router.getPath();if(t.state.has("route")){const e=t.state.get("route");if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"&&"path"in e){const r=e.path;if(typeof r=="string"&&r)return r}}return"/"}function pf(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),n={};if(typeof globalThis<"u"&&globalThis.location){const i=globalThis.location?.search??"";if(i){const o=new URLSearchParams(i.startsWith("?")?i.slice(1):i);for(const[s,c]of o)n[s]=c}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function Yr(t,e){if(t!=null){if(Array.isArray(t)){const r=Di(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=Di(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function Di(t,e){let r;if(typeof t=="number")r=t;else if(typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t)))r=Number(t);else return null;return r<0&&(r=e+r),r<0||r>=e?null:r}function Xr(t,e){if(t!=null){if(Array.isArray(t)){switch(e){case"length":return t.length;case"first":return t[0]??null;case"last":return t.length===0?null:t[t.length-1]}return t.map(r=>{if(r&&typeof r=="object")return r[e]})}if(typeof t=="string"&&e==="length")return t.length;if(typeof t=="object")return t[e]}}function _(t){if(typeof t=="number")return t;if(typeof t=="string"){if(t.trim()==="")return 0;const e=Number(t);return Number.isNaN(e)?0:e}return typeof t=="boolean"&&t?1:0}const mf=new Set(["colors","radius","font"]),ff=new Set(["name","direction"]);function gf(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const r=t;for(const[a,n]of Object.entries(r))if(n!=null&&!ff.has(a)&&mf.has(a)&&n&&typeof n=="object"&&!Array.isArray(n)){const i=a==="colors"?"color":a;for(const[o,s]of Object.entries(n)){if(s==null)continue;const c=i+hf(o);e[c]=bf(s)}}return e}function hf(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function bf(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function Jr(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(typeof t=="object"&&t!==null){const e=t.toString;if(typeof e=="function"&&e!==Object.prototype.toString){const r=e.call(t);if(typeof r=="string")return r}}try{return JSON.stringify(t)}catch{return String(t)}}const vf="__AKTION_DEVTOOLS_HOOK__";function yf(){return globalThis}function Jt(){return yf()[vf]}function Zr(){const t=Jt();return t!==void 0&&t.active}function Qr(t){Jt()?.emit(t)}function xf(t){Jt()?.unregisterApp(t)}function pe(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function wf(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="emit"}const Zt="::",kf=new Map;class ji{constructor(e){D(this,"mounted",new Map);D(this,"errors",[]);this.options=e}getErrors(){return this.errors}syncEffects(e,r){this.errors=[];const a=new Set(e.map(n=>n.name));for(const n of[...this.mounted.keys()])n.includes(Zt)||a.has(n)||this.unmount(n);for(const n of e)this.mounted.has(n.name)||this.mount(n.name,n,r,[],kf)}syncInstanceEffects(e,r,a){const n=`${e}${Zt}`,i=new Set(r.map(o=>`${n}${o.decl.name}`));for(const o of[...this.mounted.keys()])o.startsWith(n)&&(i.has(o)||this.unmount(o));for(const o of r){const s=`${n}${o.decl.name}`,c=this.mounted.get(s);if(c){c.capturedLoopVars=o.capturedLoopVars;continue}this.mount(s,o.decl,a,o.capturedAliases,o.capturedLoopVars)}}unmountInstance(e){const r=`${e}${Zt}`;for(const a of[...this.mounted.keys()])a.startsWith(r)&&this.unmount(a)}reset(){for(const e of[...this.mounted.keys()])this.unmount(e);this.errors=[]}mount(e,r,a,n,i){const o={decl:r,cleanups:[],intervals:[],unsubscribers:[],ctxRef:a,capturedAliases:n,capturedLoopVars:i};this.mounted.set(e,o),this.emitEffect(e,r,"mount","mount");const c=Sf(m=>{const g=o.cleanups.splice(0);if(g.length>0){for(const h of g)try{h()}catch(v){Oi(e,v)}this.emitEffect(e,r,"cleanup",m,{cleanups:g.length})}const b=pe();try{Bi(r,a(),o,this.options),this.emitEffect(e,r,"run",m,{duration:pe()-b})}catch(h){this.emitEffect(e,r,"error",m,{duration:pe()-b,error:h instanceof Error?h.message:String(h)}),console.error(`[aktion] effect "${e}" failed`,h)}finally{this.options.notify()}},r.rateLimit,o);let u=!1,p=!1,d=!1;for(const m of r.triggers)switch(m.kind){case"lifecycle":m.name==="mount"&&(u=!0),m.name==="unmount"&&(p=!0);break;case"every":{d=!0;const g=`every(${m.intervalMs})`,b=setInterval(()=>c(g),m.intervalMs);o.intervals.push(b);break}case"state":{const g=Tf(m.name,n),b=`state:${m.name}`,h=this.options.state.subscribe(v=>{Ir(v,g)&&c(b)});o.unsubscribers.push(h);break}}(r.triggers.length===0||u||!d&&!p&&r.triggers.every(m=>m.kind==="state"))&&c("mount")}emitEffect(e,r,a,n,i={}){const o=this.options.onEffectEvent;if(!o||!Zr())return;const s=e.lastIndexOf(Zt);o({effectKey:e,label:Cf(r.name),instanceKey:s>=0?e.slice(0,s):null,phase:a,reason:n,triggers:Af(r),...i})}unmount(e){const r=this.mounted.get(e);if(!r)return;this.mounted.delete(e);for(const n of r.intervals)clearInterval(n);for(const n of r.unsubscribers)try{n()}catch{}if(r.cleanups.length>0){const n=r.cleanups.length;for(const i of r.cleanups)try{i()}catch(o){Oi(e,o)}this.emitEffect(e,r.decl,"cleanup","unmount",{cleanups:n})}if(r.decl.triggers.some(n=>n.kind==="lifecycle"&&n.name==="unmount")){const n=pe();try{Bi(r.decl,r.ctxRef(),r,this.options),this.emitEffect(e,r.decl,"run","unmount",{duration:pe()-n})}catch(i){this.emitEffect(e,r.decl,"error","unmount",{error:i instanceof Error?i.message:String(i)}),console.error(`[aktion] effect "${e}" unmount body threw`,i)}}this.emitEffect(e,r.decl,"unmount","unmount")}}function Sf(t,e,r){if(!e||e.ms<=0)return t;if(e.kind==="debounce"){let o=null;const s=()=>{o&&(clearTimeout(o),o=null)};return r.cleanups.push(s),c=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(c)},e.ms)}}let a=0,n=null,i="";return r.cleanups.push(()=>{n&&(clearTimeout(n),n=null)}),o=>{const s=Date.now(),c=s-a;c>=e.ms?(a=s,t(o)):n?i=o:(i=o,n=setTimeout(()=>{n=null,a=Date.now(),t(i)},e.ms-c))}}function Bi(t,e,r,a){const n=r.capturedAliases.length>0?e.stateAliases.slice():null;if(n){e.stateAliases.length=0;for(const s of r.capturedAliases)e.stateAliases.push(new Map(s))}const i=r.capturedLoopVars.size>0?new Map(e.loopVars):null;if(i){e.loopVars.clear();for(const[s,c]of r.capturedLoopVars)e.loopVars.set(s,c)}const o=e.cleanupSink;e.cleanupSink=s=>{r.cleanups.push(s)};try{for(const s of t.body.body)$f(s,e,r,a)}finally{if(e.cleanupSink=o,n){e.stateAliases.length=0;for(const s of n)e.stateAliases.push(s)}if(i){e.loopVars.clear();for(const[s,c]of i)e.loopVars.set(s,c)}}}function $f(t,e,r,a){switch(t.kind){case"ExpressionStatement":{const n=t.expression;if(n.kind==="Call"&&n.callee==="cleanup"){const i=n.arguments[0]?M(n.arguments[0],e):null;typeof i=="function"&&r.cleanups.push(i);return}if(wf(n)){const i=n.arguments,o=i[0]?String(M(i[0],e)):"",s=i[1]?M(i[1],e):void 0;a.onEmit?.(o,s);return}return M(n,e)}case"Assignment":{const n=M(t.expression,e);if(t.identifier&&t.identifier!==""){const i=Ae(e,t.identifier);e.state.set(i,n)}return n}case"IfStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"SwitchStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"ThrowStatement":case"DestructureStatement":qr(t,e);return;default:return}}function Oi(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function Cf(t){const e=/^__effect_L(\d+)_C(\d+)$/.exec(t);return e?`effect @ L${e[1]}:C${e[2]}`:t}function Af(t){const e=t.triggers.map(r=>r.kind==="lifecycle"?`"${r.name}"`:r.kind==="every"?`every(${r.intervalMs})`:`$${r.name}`);return t.rateLimit&&e.push(`${t.rateLimit.kind}(${t.rateLimit.ms})`),e.length>0?`[${e.join(", ")}]`:"[mount]"}function Tf(t,e){const r=t.indexOf("."),a=r<0?t:t.slice(0,r),n=r<0?"":t.slice(r);for(let i=e.length-1;i>=0;i-=1){const o=e[i].get(a);if(o!==void 0)return o+n}return t}const Mf="$";function _i(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Object.is(t[r],e[r]))return!1;return!0}function Fi(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(e,n)||!Object.is(t[n],e[n]))return!1;return!0}class Ui{constructor(e){D(this,"instanceStates",new Map);D(this,"instanceDisposers",new Map);D(this,"aliveInstances",new Set);D(this,"instancesWithEffects",new Set);D(this,"instancesWithHooks",new Set);D(this,"memoCache",new Map);D(this,"changedPaths",new Set);D(this,"memoEnabled",!1);D(this,"profiling",!1);D(this,"profilerRecords",[]);D(this,"profiledInstances",new Set);this.options=e}setProfiling(e){this.profiling=e,e||(this.profilerRecords=[],this.profiledInstances.clear())}drainProfilerRecords(){const e=this.profilerRecords;return this.profilerRecords=[],e}depthOf(e){let r=0;for(let a=0;a<e.length;a+=1)e[a]==="#"&&(r+=1);return r}setLibrary(e){this.options={...this.options,library:e}}reset(){for(const e of this.instanceDisposers.values())for(const r of e.values())this.safeDispose(r);if(this.instanceDisposers.clear(),this.instanceStates.clear(),this.memoCache.clear(),this.options.unmountInstanceEffects)for(const e of this.instancesWithEffects)try{this.options.unmountInstanceEffects(e)}catch(r){console.error(`[aktion] unmountInstanceEffects threw for ${e}`,r)}if(this.instancesWithEffects.clear(),this.options.unmountInstanceHooks)for(const e of this.instancesWithHooks)try{this.options.unmountInstanceHooks(e)}catch(r){console.error(`[aktion] unmountInstanceHooks threw for ${e}`,r)}this.instancesWithHooks.clear(),this.aliveInstances=new Set,this.profilerRecords=[],this.profiledInstances.clear()}beginRender(e={}){this.aliveInstances=new Set,this.changedPaths=e.changedPaths??new Set,this.memoEnabled=e.memoize??!1,this.profiling&&(this.profilerRecords=[])}endRender(){const e=this.aliveInstances;for(const r of[...this.instanceStates.keys()]){const a=r.lastIndexOf("::"),n=a===-1?r:r.slice(0,a);e.has(n)||this.instanceStates.delete(r)}for(const[r,a]of[...this.instanceDisposers.entries()])if(!e.has(r)){for(const n of a.values())this.safeDispose(n);this.instanceDisposers.delete(r)}if(this.options.unmountInstanceEffects){for(const r of[...this.instancesWithEffects])if(!e.has(r)){try{this.options.unmountInstanceEffects(r)}catch(a){console.error(`[aktion] unmountInstanceEffects threw for ${r}`,a)}this.instancesWithEffects.delete(r)}}if(this.options.unmountInstanceHooks){for(const r of[...this.instancesWithHooks])if(!e.has(r)){try{this.options.unmountInstanceHooks(r)}catch(a){console.error(`[aktion] unmountInstanceHooks threw for ${r}`,a)}this.instancesWithHooks.delete(r)}}for(const r of[...this.memoCache.keys()])e.has(r)||this.memoCache.delete(r);if(this.profiling)for(const r of[...this.profiledInstances])e.has(r)||this.profiledInstances.delete(r)}profile(e,r,a,n,i,o,s){this.profilerRecords.push({instanceKey:e,name:r,kind:a,phase:n,selfTime:i,depth:this.depthOf(e),reason:o,deps:s?[...s]:void 0}),this.profiledInstances.add(e)}safeDispose(e){try{e()}catch(r){console.error("[aktion] disposer threw",r)}}writeState(e,r){const a=e.indexOf(".");if(a<0){this.options.state.set(e,r);return}const n=e.slice(0,a),i=e.slice(a+1).split(".");this.options.state.setPath(n,i,r)}render(e){return this.renderAt(e,Mf)}renderAt(e,r){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const a=document.createDocumentFragment();return e.forEach((n,i)=>{a.append(this.renderAt(n,`${r}/${i}`))}),a}return bi(e)?this.renderUserComponent(e,r):hi(e)?this.renderComponent(e,r):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?document.createTextNode(String(e)):document.createTextNode("")}renderUserComponent(e,r){const a=this.options.evaluationContext;if(!a){const d=document.createElement("div");return d.className="rui-unknown-component",d.textContent=`[unknown component: ${e.decl.name}]`,d}const n=a(),i=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,o=`${r}#${e.decl.name}${i}`;this.aliveInstances.add(o);const s=this.memoCache.get(o);if(this.memoEnabled&&s&&_i(e.positional,s.positional)&&Fi(e.named,s.named)&&!mt(this.changedPaths,s.deps)){const d=n.trackedState;for(const m of s.deps)d.add(m);this.profiling&&this.profile(o,e.decl.name,"user","memo",0,"memoized (args + deps unchanged)",s.deps),Fr(n,e.decl.name);try{return this.renderAt(s.value,o)}finally{Ur(n)}}const c=this.profiledInstances.has(o)?"update":"mount",u=s?_i(e.positional,s.positional)?Fi(e.named,s.named)?mt(this.changedPaths,s.deps)?"state dependency changed":"full render":"named args changed":"positional args changed":c==="mount"?"initial mount":"no memo (full render)",p=this.profiling?pe():0;Fr(n,e.decl.name);try{const d=n.trackedState,m=new Set;n.trackedState=m;let g;try{g=Ni(e,n,o)}finally{n.trackedState=d;for(const y of m)d.add(y)}const{value:b,effects:h,hooks:v}=g;return this.profiling&&this.profile(o,e.decl.name,"user",c,pe()-p,u,m),this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(o,h,a),h.length>0&&this.instancesWithEffects.add(o)),v>0&&this.instancesWithHooks.add(o),this.memoCache.set(o,{positional:e.positional,named:e.named,deps:m,value:b}),this.renderAt(b,o)}finally{Ur(n)}}renderComponent(e,r){const a=Ee(this.options.library,e.name);if(!a){const d=document.createElement("div");return d.className="rui-unknown-component",d.textContent=`[unknown component: ${e.name}]`,d}const n=Wa(a,e.args),i=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,o=`${r}#${e.name}${i}`;this.aliveInstances.add(o);let s=0;const c={renderNode:d=>this.renderAt(d,`${o}>${s++}`),invoke:(d,...m)=>{if(typeof d=="function")try{const g=d(...m);g&&typeof g.then=="function"&&g.catch(b=>{console.error("[aktion] handler rejected",b)})}catch(g){console.error("[aktion] handler threw",g)}},setState:(d,m)=>{this.writeState(d,m)},resetState:(...d)=>{this.options.state.reset(...d)},sendToAssistant:d=>{this.options.onAssistantMessage?.(d)},openUrl:d=>{const m=tt(d,"#"),g=this.options.onOpenUrl;g?g(m):m!=="#"&&typeof window<"u"&&window.open(m,"_blank","noopener,noreferrer")},bindState:(d,m,g)=>{const h=`on${g?.event??this.eventFor(d)}`,v=g?.getValue??this.defaultValueGetter(d);d[h]=y=>{const x=y.currentTarget??y.target??d;this.writeState(m,v(x))}},useInstanceState:(d,m)=>{const g=`${o}::${d}`;return this.instanceStates.has(g)||this.instanceStates.set(g,m),{get:()=>this.instanceStates.get(g),set:b=>{this.instanceStates.set(g,b)}}},registerDisposer:(d,m)=>{let g=this.instanceDisposers.get(o);g||(g=new Map,this.instanceDisposers.set(o,g));const b=m??`__anon::${g.size}`,h=g.get(b);h&&h!==d&&this.safeDispose(h),g.set(b,d)},router:this.options.router},u=this.profiledInstances.has(o)?"update":"mount",p=this.profiling?pe():0;try{const d=a.render(e,n,c);return this.profiling&&this.profile(o,e.name,"library",u,pe()-p,u==="mount"?"mounted":"re-rendered"),d}catch(d){this.profiling&&this.profile(o,e.name,"library",u,pe()-p,"render threw"),console.error(`[aktion] failed to render ${a.name}`,d);const m=document.createElement("div");return m.className="rui-render-error",m.textContent=`[render error in ${a.name}]`,m}}eventFor(e){return e instanceof HTMLSelectElement||e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?"change":"input"}defaultValueGetter(e){return e instanceof HTMLInputElement&&e.type==="checkbox"?r=>r.checked:e instanceof HTMLInputElement&&e.type==="radio"?r=>r.value:e instanceof HTMLInputElement&&e.type==="number"?r=>{const a=r.value;if(a==="")return null;const n=Number(a);return Number.isFinite(n)?n:null}:e instanceof HTMLInputElement&&e.type==="range"?r=>Number(r.value):r=>r.value}}const Nf=["onclick","ondblclick","oncontextmenu","onmousedown","onmouseup","onmousemove","onmouseenter","onmouseleave","onmouseover","onmouseout","onpointerdown","onpointerup","onpointermove","onpointerenter","onpointerleave","onpointercancel","onscroll","onwheel","ondrag","ondragstart","ondragend","ondragenter","ondragleave","ondragover","ondrop","ontouchstart","ontouchmove","ontouchend","ontouchcancel","oninput","onchange","onsubmit","onreset","oninvalid","ontoggle","onkeydown","onkeyup","onkeypress","onfocus","onblur","onerror"];function Pf(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];Wi(t,r)}function Hi(t,e){if(t===e)return t;if(t.nodeType!==e.nodeType)return Vi(t,e);if(t.nodeType===Node.TEXT_NODE)return t.textContent!==e.textContent&&(t.textContent=e.textContent),t;if(t.nodeType!==Node.ELEMENT_NODE)return t;const r=t,a=e;return r.tagName!==a.tagName?Vi(r,a):(If(r,a),r)}function Vi(t,e){return t.parentNode?.replaceChild(e,t),e}function If(t,e){Ef(t,e),Lf(t,e),Wi(t,Array.from(e.childNodes)),zf(t,e)}function Ef(t,e){const r=t.attributes;for(let n=r.length-1;n>=0;n-=1){const i=r[n];e.hasAttribute(i.name)||i.name==="open"&&t.tagName==="DETAILS"||t.removeAttribute(i.name)}const a=e.attributes;for(let n=0;n<a.length;n+=1){const i=a[n];t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}}function Lf(t,e){for(const r of Nf){const a=e[r],n=t[r];a!==n&&(t[r]=a??null)}}function zf(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){Rf(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){Df(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){!Qt(t)&&t.value!==e.value&&(t.value=e.value);return}}function Rf(t,e){if(t.type==="checkbox"||t.type==="radio"){const a=e.hasAttribute("checked")||e.checked;t.checked!==a&&!Qt(t)&&(t.checked=a);return}const r=e.getAttribute("value")??e.value??"";!Qt(t)&&t.value!==r&&(t.value=r)}function Df(t,e){const r=e.value??e.textContent??"";!Qt(t)&&t.value!==r&&(t.value=r)}function Qt(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function Wi(t,e){const r=new Map;for(const n of Array.from(t.childNodes)){const i=ea(n);i&&r.set(i,n)}let a=0;for(const n of e){const i=t.childNodes[a]??null,o=ea(n);if(o&&r.has(o)){const c=r.get(o);r.delete(o),c!==i&&t.insertBefore(c,i),Hi(c,n),a+=1;continue}if(!i){t.appendChild(n),a+=1;continue}const s=ea(i);if(s&&(!o||s!==o)){t.insertBefore(n,i),a+=1;continue}Hi(i,n),a+=1}for(;t.childNodes.length>e.length;){const n=t.childNodes[t.childNodes.length-1];t.removeChild(n)}}function ea(t){if(t.nodeType!==Node.ELEMENT_NODE)return null;const e=t;if(e.id)return`#${e.id}`;const r=e.getAttribute("data-rui-key");return r?`@${r}`:null}function ta(t,e={}){return e.mode==="chat"?Of(t,e):Bf(t,e)}function jf(t){return er(t)}function Bf(t,e){const r=e.bindings??!0,a=e.toolCalls??!0,n=[];n.push(_f(e.preamble)),n.push(Ff()),n.push(Uf()),r&&n.push(Hf()),n.push(Vf()),n.push(Wf()),a&&n.push(qf()),n.push(Kf()),n.push(Gf()),n.push(Yf()),n.push(Xf()),n.push(Jf()),n.push(Zf()),n.push(Qf()),n.push(eg(t)),e.inlineMode&&n.push(tg()),e.editMode&&n.push(rg()),e.tools&&e.tools.length>0&&n.push(gg(e.tools)),e.toolExamples&&e.toolExamples.length>0&&n.push(ra("Endpoint examples",e.toolExamples));const i=e.examples??ng();return i.length>0&&n.push(ra("Examples",i)),e.additionalRules&&e.additionalRules.length>0&&n.push(qi(e.additionalRules)),n.push(ag()),n.join(`
|
|
99
|
+
`),n=Math.max(r.length,a.length),i=[];for(let o=0;o<n;o++){const s=r[o],c=a[o];s===c?s!==void 0&&i.push({type:"same",text:s}):(s!==void 0&&i.push({type:"remove",text:s}),c!==void 0&&i.push({type:"add",text:c}))}return i}function Wn(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function qn(t,e,r,a){for(const[n,i]of e){const o=l("div",{class:"rui-json-tree-row"});o.append(l("span",{class:"rui-json-tree-key"},[`${n}: `])),i!==null&&typeof i=="object"?o.append(Kn(i,r,a+1)):o.append(l("span",{class:"rui-json-tree-leaf"},[Wn(i)])),t.append(o)}}function Kn(t,e,r=0){const a=l("div",{class:"rui-json-tree-node","data-depth":String(r)});if(t===null||typeof t!="object")return a.append(l("span",{class:"rui-json-tree-leaf"},[Wn(t)])),a;const n=Array.isArray(t),i=n?t.map((u,p)=>[String(p),u]):Object.entries(t),o=e||r<1,s=l("button",{type:"button",class:"rui-json-tree-toggle","aria-expanded":o?"true":"false"},[o?"▼":"▶",n?` Array(${i.length})`:" Object"]),c=l("div",{class:"rui-json-tree-children","data-open":o?"true":"false"});return o&&qn(c,i,e,r),s.onclick=u=>{const p=u.currentTarget,d=p.nextElementSibling;if(!d)return;const m=d.getAttribute("data-open")!=="true";d.setAttribute("data-open",m?"true":"false"),p.setAttribute("aria-expanded",m?"true":"false"),p.firstChild&&(p.firstChild.textContent=m?"▼":"▶"),m&&d.childElementCount===0?qn(d,i,e,r):m||d.replaceChildren()},a.append(s,c),a}const Ap={name:"IconButton",description:"Icon-only button with an accessible label. Use for toolbars, table row actions, and compact controls.",props:[{name:"icon",type:"string",description:"Font Awesome icon name"},{name:"label",type:"string",description:"Accessible label (visually hidden)"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:yp},{name:"size",type:"string",optional:!0,enum:xp},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("button",{class:"rui-icon-button",type:"button","data-variant":f(e.variant,"ghost"),"data-size":wp(e.size),"aria-label":f(e.label),title:f(e.label),disabled:A(e.disabled)?"":null}),n=j(e.icon,{className:"rui-icon-button-icon"});return n&&a.append(n),a.onclick=()=>r.invoke(e.onClick),a}},Tp={name:"CommandPalette",description:"Cmd-K style searchable command list. Pass `items` as `{label, value, group?, shortcut?, action?}` objects.",props:[{name:"items",type:"any[]"},{name:"open",type:"boolean",optional:!0,description:"Whether the palette is visible (default true)"},{name:"placeholder",type:"string",optional:!0},{name:"shortcut",type:"string",optional:!0,description:"Hint label, e.g. Cmd+K"}],render:(t,e,r)=>{const a=Sp(e.items),n=e.open!==void 0,i=n?A(e.open):!0,o=r.useInstanceState("open",i);n&&o.get()!==i&&o.set(i);const s=r.useInstanceState("filter",""),c=n?i:o.get(),u=l("div",{class:"rui-command-palette","data-open":c?"true":"false"});if(!c)return u;const p=l("div",{class:"rui-command-palette-backdrop"}),d=l("div",{class:"rui-command-palette-panel",role:"dialog","aria-modal":"true"}),m=l("div",{class:"rui-command-palette-header"}),g=l("input",{type:"text",class:"rui-command-palette-input",placeholder:f(e.placeholder,"Search commands…"),value:s.get(),autocomplete:"off"});m.append(g);const b=f(e.shortcut);b&&m.append(l("span",{class:"rui-command-palette-shortcut"},[b])),d.append(m);const h=l("div",{class:"rui-command-palette-list",role:"listbox"}),v=(y,x)=>{y.replaceChildren();const w=x.trim().toLowerCase(),k=w===""?a:a.filter(S=>S.label.toLowerCase().includes(w)||S.value.toLowerCase().includes(w)||(S.group??"").toLowerCase().includes(w));let T="";for(const S of k.slice(0,50)){S.group&&S.group!==T&&(T=S.group,y.append(l("div",{class:"rui-command-palette-group"},[T])));const C=l("button",{type:"button",class:"rui-command-palette-item",role:"option","data-value":S.value},[S.label]);S.shortcut&&C.append(l("span",{class:"rui-command-palette-item-kbd"},[S.shortcut])),C.onclick=N=>{N.stopPropagation(),r.invoke(S.action),o.set(!1),s.set("");const I=N.currentTarget.closest(".rui-command-palette"),L=I?.querySelector(".rui-command-palette-panel");I?.setAttribute("data-open","false"),Ne(L??null)},y.append(C)}k.length===0&&y.append(l("div",{class:"rui-command-palette-empty"},["No commands found"]))};return v(h,s.get()),d.append(h),p.onclick=y=>{const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ne(w??null)},u.append(p,d),g.oninput=y=>{const x=y.currentTarget,w=x.closest(".rui-command-palette-panel")?.querySelector(".rui-command-palette-list");s.set(x.value),w&&v(w,x.value)},g.onkeydown=y=>{if(y.key==="Escape"){const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ne(w??null)}},setTimeout(()=>g.focus(),0),rt({liveRoot:d,onDismiss:()=>{o.set(!1),u.setAttribute("data-open","false")}}),u}},Mp={name:"FilterChips",description:"Removable filter chips with an optional clear-all control.",props:[{name:"chips",type:"any[]",description:"Array of strings or {label, value} objects"},{name:"onRemove",type:"callable",optional:!0,description:"Receives the removed chip value as an argument"},{name:"onClear",type:"callable",optional:!0}],render:(t,e,r)=>{const a=kp(e.chips),n=l("div",{class:"rui-filter-chips"}),i=l("div",{class:"rui-filter-chips-row"});for(const o of a){const s=l("span",{class:"rui-filter-chip","data-value":o.value});s.append(l("span",{class:"rui-filter-chip-label"},[o.label]));const c=l("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${o.label}`}),u=j("xmark",{className:"rui-filter-chip-remove-icon"});u&&c.append(u),c.onclick=()=>r.invoke(e.onRemove,o.value),s.append(c),i.append(s)}if(n.append(i),a.length>0&&typeof e.onClear=="function"){const o=l("button",{type:"button",class:"rui-filter-chips-clear"},["Clear all"]);o.onclick=()=>r.invoke(e.onClear),n.append(o)}return n}},Np={name:"FieldRepeater",description:"Dynamic list of field groups. Pass `items` as row objects and `fields` as `{name, label, type?}` definitions.",props:[{name:"items",type:"any[]"},{name:"fields",type:"any[]"},{name:"onAdd",type:"callable",optional:!0},{name:"onRemove",type:"callable",optional:!0,description:"Receives the removed row's 0-indexed position"},{name:"addLabel",type:"string",optional:!0}],render:(t,e,r)=>{const a=Ht(e.items),n=Vn(e.fields),i=l("div",{class:"rui-field-repeater"});if(a.forEach((o,s)=>{const c=l("div",{class:"rui-field-repeater-row","data-index":String(s)}),u=l("div",{class:"rui-field-repeater-grid"});for(const p of n){const d=l("label",{class:"rui-field-repeater-field"});d.append(l("span",{class:"rui-field-repeater-label"},[p.label]));const m=l("input",{class:"rui-input",type:p.type==="number"?"number":"text",name:`${p.name}-${s}`,value:f(o[p.name]),readonly:""});d.append(m),u.append(d)}if(c.append(u),typeof e.onRemove=="function"){const p=l("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);p.onclick=()=>r.invoke(e.onRemove,s),c.append(p)}i.append(c)}),typeof e.onAdd=="function"){const o=l("button",{type:"button",class:"rui-field-repeater-add rui-button","data-variant":"secondary"},[f(e.addLabel,"Add row")]);o.onclick=()=>r.invoke(e.onAdd),i.append(o)}return i}},Pp={name:"VirtualList",description:"Windowed vertical list for large datasets. Pass pre-rendered nodes as `items` or plain row objects plus a `renderItem` component node per row.",props:[{name:"items",type:"any[]"},{name:"itemHeight",type:"number",optional:!0,description:"Fixed row height in px (default 40)"},{name:"renderItem",type:"Node",optional:!0,description:"Template node rendered per data row"}],render:(t,e,r)=>{const a=Math.max(24,E(e.itemHeight,40)),n=$(e.items),i=l("div",{class:"rui-virtual-list"}),o=l("div",{class:"rui-virtual-list-scroller"}),s=l("div",{class:"rui-virtual-list-spacer"}),c=l("div",{class:"rui-virtual-list-window"}),u=n.length;s.style.height=`${u*a}px`,s.style.position="relative",c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.right="0",o.style.maxHeight=`${Math.min(Math.max(u,1),12)*a}px`,o.style.overflow="auto";const p=d=>{c.replaceChildren();const m=o.clientHeight||a*12,g=Math.ceil(m/a)+2,b=Math.max(0,d),h=Math.min(u,b+g);c.style.transform=`translateY(${b*a}px)`;for(let v=b;v<h;v++){const y=n[v];if(e.renderItem)c.append(r.renderNode(y??e.renderItem));else if(y&&typeof y=="object"&&y.__kind)c.append(r.renderNode(y));else{const x=l("div",{class:"rui-virtual-list-item",style:`height:${a}px`});x.append(l("span",{},[f(y)])),c.append(x)}}};return o.onscroll=()=>{const d=Math.floor(o.scrollTop/a);p(d)},p(0),o.append(s,c),i.append(o),i}},Ip={name:"QueryBuilder",description:"Visual filter builder. Pass `fields` as `{name, label, type?}` and bind `value` to a rule array.",props:[{name:"fields",type:"any[]"},{name:"value",type:"any[]",optional:!0},{name:"onChange",type:"callable",optional:!0,description:"Receives the next rule array"}],render:(t,e,r)=>{const a=Vn(e.fields),n=Ht(e.value),i=t.argMeta?.[1]?.stateRef,o=l("div",{class:"rui-query-builder"}),s=c=>{o.replaceChildren(),c.forEach((p,d)=>{const m=l("div",{class:"rui-query-builder-row","data-index":String(d)}),g=l("select",{class:"rui-select rui-query-builder-field"});for(const y of a)g.append(l("option",{value:y.name},[y.label]));g.value=f(p.field??a[0]?.name);const b=l("select",{class:"rui-select rui-query-builder-op"},[]);for(const y of["equals","contains","gt","lt"])b.append(l("option",{value:y},[y]));b.value=f(p.op,"equals");const h=l("input",{class:"rui-input rui-query-builder-value",value:f(p.value)});m.append(g,b,h);const v=l("button",{type:"button",class:"rui-query-builder-remove"},["×"]);v.onclick=()=>{const y=c.filter((x,w)=>w!==d);i?r.setState(i,y):r.invoke(e.onChange,y),s(y)},m.append(v),o.append(m)});const u=l("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);u.onclick=()=>{const p=[...c,{field:a[0]?.name??"",op:"equals",value:""}];i?r.setState(i,p):r.invoke(e.onChange,p),s(p)},o.append(u)};return s(n.length>0?n:[{field:a[0]?.name??"",op:"equals",value:""}]),o}},Ep={name:"DiffViewer",description:"Side-by-side or unified diff of two text blobs.",props:[{name:"left",type:"string"},{name:"right",type:"string"},{name:"mode",type:"string",optional:!0,enum:["split","unified"],description:"Default split"}],render:(t,e)=>{const r=f(e.left),a=f(e.right),n=f(e.mode,"split"),i=l("div",{class:"rui-diff-viewer","data-mode":n});if(n==="unified"){const u=l("pre",{class:"rui-diff-viewer-unified"});for(const p of Cp(r,a))u.append(l("div",{class:`rui-diff-line rui-diff-line-${p.type}`},[(p.type==="add"?"+ ":p.type==="remove"?"- ":" ")+p.text]));return i.append(u),i}const o=l("div",{class:"rui-diff-viewer-panes"}),s=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),c=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[a]);return o.append(s,c),i.append(o),i}},Lp={name:"JsonTree",description:"Expandable JSON tree viewer for objects and arrays.",props:[{name:"data",type:"any"},{name:"expanded",type:"boolean",optional:!0,description:"Expand all nodes (default: first level only)"}],render:(t,e)=>{const r=l("div",{class:"rui-json-tree"});return r.append(Kn(e.data,A(e.expanded))),r}},Rp={name:"Gantt",description:"Simple Gantt chart. Pass `tasks` as `{id, label, start, end, progress?}` ISO date strings.",props:[{name:"tasks",type:"any[]"},{name:"startDate",type:"string",optional:!0},{name:"endDate",type:"string",optional:!0}],render:(t,e)=>{const r=$p(e.tasks),a=r.map(p=>Ke(p.start)),n=r.map(p=>Ke(p.end)),i=e.startDate?Ke(f(e.startDate)):a.length?Math.min(...a):Date.now(),o=e.endDate?Ke(f(e.endDate)):n.length?Math.max(...n):i+864e5,s=Math.max(o-i,1),c=l("div",{class:"rui-gantt"}),u=l("div",{class:"rui-gantt-track"});for(const p of r){const d=l("div",{class:"rui-gantt-row"});d.append(l("div",{class:"rui-gantt-label"},[p.label]));const m=l("div",{class:"rui-gantt-bars"}),g=(Ke(p.start)-i)/s*100,b=Math.max((Ke(p.end)-Ke(p.start))/s*100,2),h=l("div",{class:"rui-gantt-bar",style:`left:${g}%;width:${b}%`,title:`${p.start} → ${p.end}`});p.progress!=null&&h.append(l("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,p.progress))}%`})),m.append(h),d.append(m),u.append(d)}return c.append(u),c}},zp={name:"Truncate",description:"Clamp long text with an expand control.",props:[{name:"text",type:"string"},{name:"maxLines",type:"number",optional:!0,description:"Lines before clamping (default 3)"},{name:"expandLabel",type:"string",optional:!0}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(E(e.maxLines,3))),n=r.useInstanceState("expanded",!1),i=`display:-webkit-box;-webkit-line-clamp:${a};-webkit-box-orient:vertical;overflow:hidden`,o=l("div",{class:"rui-truncate","data-expanded":n.get()?"true":"false"}),s=l("p",{class:"rui-truncate-text",style:n.get()?"":i},[f(e.text)]),c=l("button",{type:"button",class:"rui-truncate-toggle"},[n.get()?"Show less":f(e.expandLabel,"Show more")]);return c.onclick=u=>{const p=u.currentTarget,d=p.closest(".rui-truncate"),m=d?.querySelector(".rui-truncate-text");if(!d||!m)return;const g=!n.get();n.set(g),m.style.cssText=g?"":i,p.textContent=g?"Show less":f(e.expandLabel,"Show more"),d.setAttribute("data-expanded",g?"true":"false")},o.append(s,c),o}},Dp={name:"InlineEdit",description:"Click-to-edit inline field with save on Enter or blur.",props:[{name:"value",type:"string"},{name:"label",type:"string",optional:!0},{name:"onSave",type:"callable",optional:!0,description:"Receives the committed draft string"}],render:(t,e,r)=>{const a=r.useInstanceState("editing",!1),n=r.useInstanceState("draft",f(e.value)),i=t.argMeta?.[0]?.stateRef,o=l("div",{class:"rui-inline-edit","data-editing":a.get()?"true":"false"}),s=f(e.label);s&&o.append(l("span",{class:"rui-inline-edit-label"},[s]));const c=l("button",{type:"button",class:"rui-inline-edit-display"},[f(e.value)]),u=l("input",{class:"rui-inline-edit-input rui-input",value:n.get()}),p=m=>{const g=m.closest(".rui-inline-edit"),b=g?.querySelector(".rui-inline-edit-input");return!g||!b?null:{root:g,input:b}},d=m=>{const g=p(m);a.set(!1),g?.root.setAttribute("data-editing","false");const b=n.get();i&&r.setState(i,b),r.invoke(e.onSave,b)};return c.onclick=m=>{const g=p(m.currentTarget);n.set(f(e.value)),a.set(!0),g&&(g.root.setAttribute("data-editing","true"),g.input.value=n.get(),setTimeout(()=>g.input.focus(),0))},u.oninput=m=>n.set(m.currentTarget.value),u.onkeydown=m=>{const g=m;if(g.key==="Enter"&&d(m.currentTarget),g.key==="Escape"){const b=p(m.currentTarget);a.set(!1),b?.root.setAttribute("data-editing","false")}},u.onblur=m=>d(m.currentTarget),o.append(c,u),o}},jp={name:"NotificationBell",description:"Bell icon with unread count badge and dropdown notification list.",props:[{name:"count",type:"number",optional:!0},{name:"items",type:"any[]",optional:!0,description:"{title, message?, time?} objects"},{name:"onOpen",type:"callable",optional:!0}],render:(t,e,r)=>{const a=Math.max(0,Math.floor(E(e.count,0))),n=Ht(e.items),i=r.useInstanceState("open",!1),o=i.get(),s=l("div",{class:"rui-notification-bell","data-open":o?"true":"false"}),c=l("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":o?"true":"false","aria-haspopup":"true"}),u=j("bell",{className:"rui-notification-bell-icon"});u&&c.append(u),a>0&&c.append(l("span",{class:"rui-notification-bell-badge"},[a>99?"99+":String(a)])),s.append(c);const p=l("div",{class:"rui-notification-bell-panel",role:"menu"});if(n.length===0)p.append(l("div",{class:"rui-notification-bell-empty"},["No notifications"]));else for(const d of n){const m=l("div",{class:"rui-notification-bell-item"});m.append(l("div",{class:"rui-notification-bell-item-title"},[f(d.title)]));const g=f(d.message);g&&m.append(l("div",{class:"rui-notification-bell-item-message"},[g]));const b=f(d.time);b&&m.append(l("div",{class:"rui-notification-bell-item-time"},[b])),p.append(m)}return s.append(p),c.onclick=d=>{d.stopPropagation();const m=d.currentTarget,g=m.closest(".rui-notification-bell");if(!g)return;const b=!i.get();i.set(b),g.setAttribute("data-open",b?"true":"false"),m.setAttribute("aria-expanded",b?"true":"false"),b?(r.invoke(e.onOpen),rt({liveRoot:g,onDismiss:()=>{i.set(!1),g.setAttribute("data-open","false"),m.setAttribute("aria-expanded","false")}})):Ne(g)},s}},Pe=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),Bp=t=>!!(t&&typeof t=="object"),Op={name:"Async",description:"Render `loading`, `error`, `empty`, or `data` slot based on an `$http({...})` resource's state.",props:[{name:"resource",type:"any",positional:!0,required:!0},{name:"loading",type:"Node",optional:!0},{name:"error",type:"Node",optional:!0},{name:"empty",type:"Node",optional:!0},{name:"data",type:"Node",optional:!0}],render:(t,e,r)=>{const a=e.resource,n={loading:e.loading,error:e.error,empty:e.empty,data:e.data};if(!Bp(a))return Pe(r,n.empty??n.data??null);const i=a.state;if(i==="loading"||a.loading)return Pe(r,n.loading??null);if(i==="error"||a.error)return Pe(r,n.error??null);const o=a.data;return o==null||Array.isArray(o)&&o.length===0?Pe(r,n.empty??n.data??null):Pe(r,n.data??null)}},_p={name:"Show",description:"Conditional renderer. Sugar over `if expr { children } else { fallback }`.",props:[{name:"when",type:"any",positional:!0,required:!0},{name:"fallback",type:"Node",optional:!0},{name:"children",type:"Node[]",optional:!0}],render:(t,e,r)=>e.when?Pe(r,e.children??null):Pe(r,e.fallback??null)},Fp={name:"Portal",description:"Render children outside the parent subtree (e.g. into document.body).",props:[{name:"target",type:"string",optional:!0},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const a=f(e.target);let n=null;if(a)try{n=document.querySelector(a)}catch{n=null}n||(n=document.body);const i=l("div",{class:"rui-portal"});for(const o of $(e.children))i.append(r.renderNode(o));return n&&(n.append(i),r.registerDisposer(()=>{i.parentNode&&i.parentNode.removeChild(i)})),l("span",{class:"rui-portal-anchor","data-portal":a??"body"})}},Up={name:"Redirect",description:"Navigate to `path` and unmount the rest of the subtree.",props:[{name:"path",type:"string",positional:!0,required:!0}],render:(t,e,r)=>{const a=f(e.path);if(a)try{r.router.navigate(a)}catch{}return l("span",{class:"rui-redirect","data-path":a,hidden:"true"})}},Hp={name:"Lazy",description:"Defer rendering until an async `loader` resolves: show `fallback` while pending, then render the resolved value (or `children`). A synchronous loader value renders immediately.",props:[{name:"loader",type:"any",positional:!0,required:!0},{name:"fallback",type:"Node",optional:!0},{name:"children",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=e.loader,n=r.useInstanceState("rui-lazy",{status:"init"}),i=l("span",{class:"rui-lazy",style:"display: contents;"}),o=d=>{i.replaceChildren(Pe(r,d))},s=()=>e.fallback??null,c=d=>d??e.children??null,u=n.get();if(u.status==="resolved")return o(c(u.value)),i;if(u.status==="pending"||u.status==="error")return o(s()),i;let p;try{p=typeof a=="function"?a():a}catch{return n.set({status:"error"}),o(s()),i}if(p&&typeof p.then=="function"){n.set({status:"pending"}),o(s());let d=!1;return r.registerDisposer(()=>{d=!0},"rui-lazy-cancel"),p.then(m=>{d||(n.set({status:"resolved",value:m}),o(c(m)))},()=>{d||(n.set({status:"error"}),o(s()))}),i}return n.set({status:"resolved",value:p}),o(c(p)),i}},Vp={name:"ErrorBoundary",description:"Render a fallback subtree when rendering children throws.",props:[{name:"fallback",type:"Node",optional:!0},{name:"onError",type:"callable",optional:!0},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-error-boundary"});try{for(const n of $(e.children))a.append(r.renderNode(n));return a}catch(n){try{r.invoke(e.onError,n)}catch{}const i=Pe(r,e.fallback??null),o=l("div",{class:"rui-error-boundary rui-error-boundary--fallback"});return o.append(i),o.setAttribute("data-error",n instanceof Error?n.message:String(n)),o}}},Wp=new Set(["div","span","p","section","article","header","footer","main","nav","aside","figure","figcaption","details","summary","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","table","thead","tbody","tfoot","tr","td","th","caption","colgroup","col","a","img","picture","source","video","audio","track","small","strong","em","b","i","u","s","mark","code","pre","kbd","samp","var","sub","sup","abbr","cite","blockquote","q","time","address","ins","del","ruby","rt","rp","bdi","bdo","br","hr","wbr","hgroup","label","fieldset","legend","progress","meter","output"]),qp=/^[a-zA-Z][a-zA-Z0-9_:-]*$/,Kp=new Set(["href","ping","action","formaction"]),Gp=new Set(["src","poster"]);function Yp(t){const e=f(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}function Xp(t){const e=f(t).trim().toLowerCase();return!e||!Wp.has(e)?"div":e}function Jp(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t)){const n=r.trim();if(!n||!qp.test(n))continue;const i=n.toLowerCase();if(!i.startsWith("on")&&!(a==null||a===!1)){if(i==="style"){const o=Yp(a);o&&(e.style=o);continue}if(Kp.has(i)){const o=tt(a,"");o&&(e[n]=o);continue}if(Gp.has(i)){const o=ie(a);o&&(e[n]=o);continue}e[n]=a===!0?"":f(a)}}return e}const Zp={name:"HTMLTag",description:"Escape-hatch primitive that renders an allow-listed HTML tag with the given attributes and children. Use ONLY when the standard component catalogue cannot express the markup (custom semantic elements, inline SVG, third-party widget mounts). Tag names outside the allow-list collapse to `div`. Attribute names matching `on*` (event handlers) are dropped, `href`/`src` are sanitised, and `style` is filtered for `expression()` / `javascript:` / `@import`. Pass children as an array of components — strings render as text nodes.",props:[{name:"tag",type:"string",positional:!0,required:!0,description:'HTML tag name (e.g. "div", "section", "svg"). Falls back to `div` when outside the allow-list.'},{name:"attributes",type:"object",optional:!0,aliases:["attrs","props"],description:'Plain object of attribute name → value pairs (e.g. `{ class: "hero", "data-id": 1 }`). `on*` handlers are dropped.'},{name:"children",type:"Node[]",optional:!0,description:"Child components or text nodes to render inside the tag."}],render:(t,e,r)=>{const a=Xp(e.tag),n=Jp(e.attributes),i=l(a,n);for(const o of $(e.children))if(o!=null){if(typeof o=="string"){i.append(document.createTextNode(o));continue}if(typeof o=="number"||typeof o=="boolean"){i.append(document.createTextNode(String(o)));continue}i.append(r.renderNode(o))}return i}},Qp=/<\/style|<script|expression\s*\(|javascript\s*:|behavior\s*:|@import\b/i,em=64*1024;function tm(t){const e=f(t);return!e||e.length>em||Qp.test(e)?"":e}const Gn=[Gs,Ys,Js,Xs,qs,un,cl,ul,Zs,Qs,el,tl,nl,al,sl,ol,hl,rl,dl,ml,Dl,jl,kl,Sl,$l,yn,Al,Tl,Ml,Nl,El,zl,Ol,yl,Bl,yc,vc,uc,dc,mc,pc,fc,hc,gc,bc,lc,cc,xn,xc,wc,kc,Sc,wn,$c,Cc,cu,lu,du,uu,pu,mu,gu,fu,yu,xu,wu,vu,Au,Tu,Mu,Iu,Eu,Vu,Pn,Lu,Ru,Hu,zu,Du,Bu,Ou,qu,Ku,Wu,_u,Yu,Ln,Ju,ed,Qu,nd,id,od,sd,Ic,Ec,iu,ou,Lc,zc,Rc,jc,Dc,Bc,Oc,su,_c,Fc,kn,au,Vc,Hc,Uc,Wc,qc,Yc,Gc,Kc,Xc,Jc,Qc,Zc,eu,ru,tu,ud,pd,gd,hd,bd,yd,xd,kd,Sd,$d,Ad,Md,Nd,Id,Ld,zd,jd,Bd,_d,Fd,Vd,qd,Kd,Yd,Xd,Jd,Zd,Qd,ep,tp,ap,ip,sp,lp,cp,up,dp,pp,mp,fp,gp,hp,bp,vp,Ap,Tp,Mp,Np,Pp,Ip,Ep,Lp,Rp,zp,Dp,jp,Op,_p,Fp,Up,Hp,Vp,Gl,Xl,Zl,Ql,ec,tc,ac,yn,Zp,{name:"Styles",description:"Escape-hatch primitive that injects a `<style>` block containing the given CSS rules. Use ONLY when a layout cannot be expressed via component props or the `$theme(...)` token map. The CSS is rendered verbatim into the document so authors can target their own `HTMLTag` markup or scope rules to a wrapper class. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped for safety.",props:[{name:"css",type:"string",positional:!0,required:!0,aliases:["content","rules"],description:'Raw CSS text (e.g. `".hero { color: red; }"`).'}],render:(t,e)=>{const r=tm(e.css),a=document.createElement("style");return a.setAttribute("class","rui-styles"),r&&(a.textContent=r),a}}],rm=[{name:"Layout",components:["Column","Row","Center","Stack","StackItem","Grid","GridItem","Box","Container","Spacer","Card","CardHeader","CardFooter","Separator","Tabs","TabItem","Accordion","AccordionItem","Modal","Drawer","Steps","AspectRatio","ScrollArea","Sticky","ResizablePanels","MasonryGrid"],notes:["- THREE primitives cover almost everything: `Column` (stack top→bottom), `Row` (left→right), and `Grid` (equal columns / card walls). Reach for these first.","- `root` is normally a `Column([...])` (or `Container([...])` for a centered page). A `Column` is the page body; put each major chunk in a `Card(...)`.","- `Row([...])` keeps children at their natural width and vertically centered — ideal for toolbars, button rows, label+value pairs, nav bars. Use `justify` to distribute (`between`, `center`, `end`) and `gap` for spacing.","- `Grid([...], { columns: N })` = N equal columns. Omit `columns` for auto-fit (wraps as many ≥`minChildWidth` columns as fit — best for KPI/card grids). Prefer `Grid` over a wrapping `Row` whenever cells should share a width.",'- For a 12-column dashboard / sidebar layout use `GridItem` spans: `Grid([GridItem(side, { span: "1/4" }), GridItem(main, { span: "3/4" })])`. Fractions `"1/2"`…`"1/12"` (or numbers 1–12) resolve on a 12-track grid; any `GridItem` child turns the grid on automatically.','- `Center([...], { minHeight })` centers content on both axes — spinners, empty states, hero CTAs, modal bodies. Add `minHeight: "60vh"` to center vertically in a region.','- `Stack` is the responsive escape hatch: use it ONLY when the direction itself must change across breakpoints, e.g. `Stack([...], { direction: {base: "column", md: "row"} })`.',"- Make one child in a `Row` expand with `StackItem(child, { grow: 1 })` (e.g. a search input beside a fixed button), or push items apart with a bare `Spacer()` between them.","- `Container([...], { size })` centers a wide page within a comfortable max-width (sm/md/lg/xl/full) — landing pages, articles, marketing sections.","- `Box([...], { padding?, margin?, border?, background?, maxWidth? })` is a plain spacing/surface wrapper for when a `Card` is too heavy.",'- `Separator(orientation?, label?)` adds a visual break between sections; pass a `label` for a centered "OR"-style divider.',"- `gap`/`padding` spacing tokens are `xs|s|m|l|xl`; `align`/`justify`/`columns`/`direction`/`gap` all accept responsive maps like `{base: …, md: …, lg: …}`.","- Use `Drawer` for side-panel detail views and `Modal` for centered dialogs. `Sticky(children, side?, offset?)` pins a toolbar/banner while content scrolls. `ResizablePanels(primary, secondary)` gives a user-resizable two-pane split. `MasonryGrid([...])` is for Pinterest-style mixed-height walls."]},{name:"Content",components:["Text","Image","Badge","BadgeList","Callout","Quote","CodeBlock","Skeleton","Spinner","Markdown","Kbd","Icon"],notes:["- Prefer `Markdown(...)` for rich paragraph text with inline formatting — the parser supports headings, blockquotes, fenced code, numbered/bullet lists, links, images, and bare-URL auto-linking.","- Use `Callout(variant, title, description, icon?, compact?)` for highlighted notices; pass `compact: true` for a one-line inline note.","- Use `Quote(text, cite?)` for inline pull-quotes inside articles and marketing sections (use `Testimonial` when you also have author/role/rating).","- Use `CodeBlock(language, codeString, showLineNumbers?, highlightLines?)` for read-only code snippets. The header always renders a copy-to-clipboard button.",'- Use `Badge(label, variant?, icon?, size?)` for a single pill and `BadgeList(["a","b","c"], variant?, size?)` to render an array of strings as Badge pills.',"- Use `Skeleton(variant?, lines?, height?, shape?, width?)` for loading placeholders; `variant` accepts `paragraph` (default), `card`, `table-row`, `avatar`, `image`.","- Use `Spinner(size?, label?, tone?)` for tiny inline loading indicators inside buttons, toolbars, or table cells.",'- Use `Image(src, alt?, caption?, ratio?, fit?, fallback?)` — `ratio` (e.g. `"16:9"`) makes the image self-constrain so you do not need an outer `AspectRatio`.','- Use `Kbd(["Cmd", "K"])` when referring to keyboard shortcuts.','- Use `Icon(name, variant?, size?)` to render a standalone Font Awesome icon (`name` is the FA name without the `fa-` prefix, e.g. `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`).','- For page-level titles reach for `PageHeader(...)` (top of dashboards/detail pages) or `SectionHeader(...)` (inside a Card). For tiny inline titles use `Text(value, variant="large-heavy")`.']},{name:"Forms",components:["Form","FormControl","FormSection","FieldSet","ValidationSummary","Input","TextArea","PasswordInput","MaskedInput","MentionInput","TagInput","Select","SelectItem","Combobox","MultiSelect","Checkbox","CheckBoxGroup","CheckBoxItem","Radio","Switch","ToggleGroup","Button","Buttons","SearchBar","Slider","NumberInput","ColorPicker","DatePicker","DateRangePicker","TimePicker","DateTimePicker","FileUpload","PinInput","MultiStepForm"],notes:["- Each FormControl should be a separate reference for progressive streaming.","- Pass a `$variable` as the last argument to `Input`, `Select`, `Checkbox`, `Switch`, `MultiSelect`, or `CheckBoxGroup` for two-way binding.","- Prefer `Switch` over `Checkbox` for settings; use `ToggleGroup` for view-mode pickers and mutually-exclusive filters.","- Reach for `SearchBar(id, placeholder?, value?, shortcut?)` instead of a raw `Input` whenever the field's purpose is to filter content. It ships with the magnifier icon and keyboard hint baked in.","- `Slider(id, min?, max?, step?, value?, label?, showValue?)` is the canonical control for numeric ranges (volume, brightness, filters); pass a `$variable` as `value` for two-way binding.",'- `NumberInput(id, value?, min?, max?, step?, placeholder?)` is friendlier than `Input(type="number")` for quantity steppers and integer settings — it ships with +/- buttons that respect `min`/`max`.',"- `DatePicker(id, value?, label?, min?, max?, placeholder?)` wraps the native date picker; pass `value` as a `$variable` for two-way binding (ISO `YYYY-MM-DD`).","- `DateRangePicker(id, from?, to?, label?, min?, max?)` is the paired-date variant — bind both `from` and `to` to `$variable`s for a single shared range.","- `Combobox(id, items, value?, placeholder?, emptyLabel?)` is the searchable single-select alternative to `Select` — type to filter long option lists (countries, currencies, users).","- `MultiSelect(id, items, value?, placeholder?, emptyLabel?, max?)` is the multi-select equivalent — bind a `$variable` array as `value` for two-way binding, the trigger renders the picks as removable chips.","- `FileUpload(id, { label?, hint?, accept?, multiple?, action? })` is the styled file picker; the picked files cannot pass through a `$variable`, so wire the `action` prop to a `function` declaration.",'- A submit button should call an `action` that awaits the relevant `$mutation` resource, optionally refetches a `$query`, and resets the form `$variable`s (e.g. `$title = ""`).',"- Button `size` accepts both `sm|md|lg` (canonical) and the legacy `small|normal|large`. Pass `icon` for an inline leading icon.","- `FormSection(label, children, helper?)` is the canonical wrapper for related fields. Reach for it INSTEAD of nesting fields in Card + SectionHeader by hand.","- `FieldSet(legend, children, helper?)` is the accessible `<fieldset>` for radio/checkbox groups; prefer `FormSection` for purely visual grouping.","- `ValidationSummary(errors, title?)` renders an aggregate error panel at the top of the form. Pass `errors` as `{label, message}` objects.",'- `PasswordInput(id, value?, placeholder?, strengthMeter?)` adds a show/hide toggle and an optional 4-step strength meter — prefer over `Input(type="password")` for sign-up flows.',"- `PinInput(id, length?, value?, type?)` renders per-digit code entry for 2FA / SMS verification (use `length=6` for OTP codes).","- `TagInput(id, value?, placeholder?)` lets the user add comma- or Enter-separated chips bound to a `$variable` array.","- `MentionInput(id, people, value?)` is a textarea with inline @-mention suggestions — use for comments, task notes, chat composers.","- `MaskedInput(id, mask, value?)` formats input against a mask string (`9` digit, `A` letter, `*` any). Use for phone numbers, postal codes.","- `TimePicker(id, value?)` and `DateTimePicker(id, value?)` wrap the corresponding native inputs with consistent styling.","- `ColorPicker(id, value?, label?, swatches?)` pairs a color chip with a hex input and preset swatches — bind a $variable holding a hex string.","- `MultiStepForm(steps, current, onSubmit?)` replaces ad-hoc `Steps` + content + manual prev/next wiring. Each step is `{title, details?, content}`."]},{name:"Data",components:["Table","Col","DataGrid","List","ListItem","StatCard","Stats","Sparkline","Tile","Progress","ProgressRing","Pagination","Tree","TreeNode","CalendarView","ComparisonTable","InfiniteList"],notes:['- Build columns using array pluck: `Col("Title", data.rows.title, format?, align?)`.',"- For per-row controls inside a Col, use `for (let row of data.rows) { ... }` and reference `row.field` inline.",'- `Table(cols, caption?, density?, striped?, sticky?, emptyLabel?)` — pass `density="compact"` for dense data, `sticky=true` to pin the header in a scrolling parent, and `emptyLabel` for the zero-state cell.',"- `DataGrid(cols, rowIds?, caption?, sort, selectedIds, selectable?, page, perPage?, …)` is the advanced Table — adds sortable headers (`sortable=true` on Col), per-column filter chips (`filterable=true`), checkbox row selection bound to `$selectedIds`, sticky header / first column, pagination, and an optional bulk-action toolbar. Reach for this whenever a user needs to sort, filter, or page through a list.","- `CalendarView(value?, month?, events?, view?, firstDay?, onSelect?)` renders a full-month (or week) calendar grid for scheduling apps — distinct from the `DatePicker` input. Bind `value` to a `$variable` for the selected ISO date.","- `ComparisonTable(columns, rows, highlightColumn?)` is the generic counterpart of `PricingTable` — pass rows of `{label, values, hint?, group?}`. Use for feature comparisons, spec sheets, plan grids.","- `InfiniteList(items, onLoadMore?, loading?, hasMore?)` is a scroll-to-load list; the action fires when the sentinel scrolls into view.","- Use `Progress(value, max?, label?, tone?, indeterminate?, segments?, buffered?)` for linear bars — `segments` renders an N-step strip (onboarding flows), `buffered` adds a secondary buffer indicator.","- `ProgressRing(value, max?, label?, tone?, size?)` is the circular variant for quotas/completion.",'- `Stats([{label, value, hint?, tone?, spark?}, …], layout?)` — `layout="strip"` (default) for inline KPIs; `layout="grid"` for a responsive StatCard grid. Pass `spark` for an inline trend line.',"- `StatCard(label, value, trend?, delta?, icon?, spark?, tone?)` gains an optional inline `Sparkline` via the `spark` prop. Use `Sparkline(values, tone?)` standalone for tiny trend chips in table cells.","- `Tile(label, icon?, value?, description?, tone?, action?)` is the dense icon tile for quick-action menus and category grids; pair with `Grid` for uniform rows.","- `Tree([TreeNode(label, children?, icon?, expanded?, active?, badge?, action?)])` renders a hierarchical tree (file browsers, nested navigation, category pickers); use `expanded=true` to open a branch by default.",'- `Pagination(page, totalPages, siblings?, total?, perPage?, perPageOptions?, compact?)` — bind `page` (and optionally `perPage`) to a `$variable`; pass `total` to render the "Showing N–M of T" summary. Reuse the same variable when slicing data with `arr.filter(...)` / `for`.']},{name:"Charts",components:["BarChart","LineChart","PieChart","RadarChart","ScatterChart","Histogram","Heatmap","Gauge","Series"],notes:["- Use `LineChart` for trends (pass `filled=true` for area-style charts), `BarChart` for comparisons, `PieChart` for proportions, `RadarChart` for multi-axis scorecards.","- `Heatmap(xLabels, yLabels, values)` renders a color-intensity matrix — perfect for calendar heatmaps, correlation grids, schedule density.","- `ScatterChart(series, xLabel?, yLabel?)` plots XY points; pass each Series as `Series(name, points)` where points are `{x, y, label?}`.","- `Histogram(values, binCount?)` bins raw numbers; pass pre-computed `bins=[{label, count}]` instead when you control the bucketing.","- `Gauge(value, min?, max?, label?, tone?, size?)` is the half-doughnut KPI indicator for thresholds (uptime %, score, NPS).",'- Pass series via `Series("Name", [...numbers])`.']},{name:"Feedback & Media",components:["Avatar","AvatarGroup","PersonChip","Tooltip","HoverCard","Popover","Rating","Toast","VideoPlayer","AudioPlayer","Carousel","Gallery","Lightbox","Map"],notes:["- `Avatar(name, src?, size?, status?)` falls back to initials when the image is missing.","- Use `AvatarGroup` to render contributor strips with a `+N` overflow chip.","- `PersonChip(name, role?, avatarSrc?, size?, status?, action?)` is the inline avatar + name + role pill — use everywhere a person is referenced (table cells, list rows, sidebar footers, kanban cards) instead of a raw `Avatar` next to `Text`.","- Wrap any node in `Tooltip(label, trigger)` for inline hints.","- Use `HoverCard(trigger, content)` when the popover needs rich content (profile preview, link target) and the trigger should open on hover.","- `Popover(trigger, content, title?, side?, align?, width?)` is the click-triggered counterpart of `HoverCard` — use for filter panels, color pickers, share menus, and small settings flyouts. Always renders an × close button in the header; clicking the trigger again, clicking outside, or pressing Escape also closes it.",'- `Rating(value, max?, label?, count?, size?, interactive?, halfStep?, icon?)` renders stars for product reviews, testimonials, and ranked lists. Pass a `$variable` as `value` with `interactive=true` to let users rate; add `halfStep=true` so clicking the left half of a star sets a half-value. Set `icon="heart"|"thumb"|"fire"|"bolt"` (or any FA name) to swap glyphs.',"- `Toast(title, message?, tone?, icon?, duration?, action?, onClose?, position?)` pins a transient notice; pass `duration` (ms) for auto-dismiss. Drive lists from an `action` body: `$toasts = [...$toasts, item]` to append and `$toasts = $toasts.filter((t) => t.id !== id)` to dismiss. Use `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.","- `NotificationBell(count?, items?, onOpen?)` — compact inbox trigger; `CommandPalette` for Cmd-K action search."]},{name:"Navigation",components:["Breadcrumb","BreadcrumbItem","Navbar","NavbarItem","DropdownMenu","MenuItem","MenuSeparator","MenuLabel"],notes:['- Use `Breadcrumb(["Workspace", "Reports", "Q3"])` at the top of every detail page so users see the path.',"- For per-item links, pass `BreadcrumbItem(label, href)` nodes instead of strings.","- `Navbar(brand?, items?, actions?, sticky?, variant?)` + `NavbarItem(label, to?, href?, icon?, active?, action?, external?)` produces a top navigation bar with brand on the left, links in the middle, and actions on the right — the canonical companion of `Sidebar` for marketing pages, docs, or any product surface without left-side nav.",'- `DropdownMenu(trigger, items, side?, align?, label?)` is the click-triggered dropdown menu — use it for user-profile menus, row "…" action menus, and any compact list of actions hanging off a single trigger. Children must be `MenuItem`, `MenuSeparator`, or `MenuLabel` entries.','- `MenuItem(label, action?, icon?, shortcut?, variant?, disabled?)` renders a single row inside a `DropdownMenu`; use `variant="danger"` for destructive actions and `MenuSeparator()`/`MenuLabel(label)` to group related items.']},{name:"Chat",components:["SectionBlock","ListBlock","FollowUpBlock","FollowUpItem","ActionLink","ChatBubble"],notes:["- End most responses with a `FollowUpBlock` of 2–4 short prompts to keep the conversation moving.",'- `ChatBubble(author, body, time?, avatarSrc?, from?)` renders a single message bubble; use `from="me"` for the active speaker and `from="agent"` for the assistant. Compose transcripts as `Stack([ChatBubble(...), ChatBubble(...), …])` inside a `Card`.']},{name:"Patterns",components:["Hero","PageHeader","EmptyState","Timeline","TimelineItem","ActivityLog","FeatureGrid","FeatureItem","Testimonial","ProfileCard","Comment","Banner","Notification","InboxPanel","OnboardingChecklist","MediaCard","TopBar","KanbanBoard","KanbanColumn","KanbanCard","SectionHeader","Toolbar","DescriptionList","DescriptionItem","StatusDot","PricingTable","PricingCard","LoadingState","ErrorState","SuccessState","Tour","Spotlight"],notes:["- Patterns are **opinionated composites** that pack an entire UI idiom into one component. Reach for them BEFORE composing equivalent layouts by hand with Card+Stack — the result will look more polished and require fewer tokens.",'- `Hero(title, subtitle, primary, secondary, eyebrow?, highlights?, tone?)` — landing-style text-first header. Use `layout="cover"` with `imageSrc`, `height`, and optional `caption` for image-backed hero bands.','- `PageHeader(title, subtitle?, breadcrumbs?, actions?, status?)` — the canonical first child for any dashboard or detail page. If you omit `breadcrumbs`, the component auto-derives `["Home", title]`.',"- `TopBar(title?, search?, actions?, sticky?)` — compact top strip for a content surface (panels, dialogs, embedded views). Use `AppShell` when you need a full sidebar; use `TopBar` for narrower headers above scrolling content.","- `SectionHeader(title, subtitle?, eyebrow?, status?, actions?)` — sub-header inside a Card or panel. Use instead of bare `CardHeader` when the section also needs eyebrow / actions / status.",'- `Stats(items, layout?)` — KPI strip (`layout="strip"`, default) or responsive grid (`layout="grid"` with StatCard children). Prefer over hand-rolled StatCard rows.',"- `Toolbar(left?, right?, center?, searchable?, searchPlaceholder?, searchValue?)` — filter/search/actions row above a list, table, or board. Pass `searchable: true` to auto-mount a `SearchBar` (use `searchValue` to bind it to a `$variable`).","- `EmptyState(title, description?, icon?, illustration?, actions?, action?)` — render this when a list is empty rather than an empty Card. The icon is auto-picked from the title keywords if you omit it (inbox/messages → `inbox`, charts/analytics → `chart-pie`, files/folders → `folder-open`, etc.).","- `Timeline([TimelineItem(...)])` — vertical event feed (audit log, changelog, activity).",'- `ActivityLog(entries, variant?)` — purpose-built feed of user actions. Pass `entries` of `{actor, title, description?, time?, icon?, tone?, meta?}`; use `variant="audit"` for security/admin trails with monospace meta.',"- `FeatureGrid([FeatureItem(...)])` — feature highlights with iconography.","- `MediaCard(title, imageSrc?, description?, tags?, meta?, actions?, badge?, orientation?, ratio?)` — image + content card. Use for article previews, product cards, project highlights. Pair with `Grid` for uniform card rows.",'- `KanbanBoard([KanbanColumn("To do", [KanbanCard(...), ...])])` — task boards.','- `DescriptionList([DescriptionItem("Status", Badge(...)), …])` — detail-page key/value summary. Always preferable to a Stack of Text rows on profile, billing, or metadata panels.',"- `StatusDot(label, tone?, pulse?)` — inline status pip. Use in toolbars, list rows, table cells, sidebars.","- `Notification(title, message?, time?, icon?, avatarSrc?, tone?, unread?, actions?)` — inline notification card for notification panels / inboxes (prefer `Banner` for top-of-page announcements).","- `InboxPanel(items, title?, onMarkAllRead?)` — `Notification` cards grouped into Unread / Earlier sections, with a shared mark-all-read action.","- `OnboardingChecklist(items, title?, description?)` — checklist of `{title, description?, done?, action?}` items with progress. Use for product onboarding, setup wizards, getting-started panels.","- `PricingTable([PricingCard(plan, price, period?, description?, features?, action?, badge?, featured?)])` — full pricing page block.","- `LoadingState(title?, description?, tone?, action?)`, `ErrorState(title, description?, action?, secondaryAction?, retryLabel?)`, `SuccessState(title, description?, action?, secondaryAction?)` — full-card empty-state alternatives for asynchronous content states.","- `Tour(steps, current, onFinish?)` and `Spotlight(title?, description?, action?)` are the product-tour primitives. `Spotlight` is a single highlighted call-out; `Tour` walks the user through multiple `{title, description, image?}` steps with Prev/Next/Skip controls and a progress dots indicator."]},{name:"Editors & overlays",components:["RichTextEditor","CodeEditor","ContextMenu"],notes:["- `RichTextEditor(id, value?, placeholder?, minHeight?)` is the contenteditable WYSIWYG editor — toolbar ships with bold/italic/underline/strike/heading/lists/link. Bind `value` to a `$variable` holding HTML.","- `CodeEditor(id, value?, language?, placeholder?, minHeight?)` is a lightweight `<textarea>` with a synced line-number gutter and tab indentation. Use for snippet editors, prompt sandboxes, settings JSON.","- `ContextMenu(target, items)` attaches a right-click menu to any node. `items` are `MenuItem` or `{label, action?, icon?, shortcut?, variant?, disabled?}` objects; pass a `MenuSeparator()` to split groups."]},{name:"App shell",components:["AppShell","Sidebar","SidebarSection","SidebarItem","SplitView"],notes:["- App shell components produce a **full SaaS-style layout in a single statement**. Use them whenever the response represents a complete product surface (dashboards with nav, settings sections, admin consoles, inboxes).","- `AppShell(sidebar, content, topbar?, collapsible?, sidebarOpen?)` — fixed-left navigation + scrollable main area. Pass `collapsible=true` to enable a hamburger that turns the sidebar into a slide-over drawer on mobile; bind `sidebarOpen` to a `$variable` if you want to drive that drawer programmatically.","- `Sidebar(items, brand?, tagline?, footer?, collapsed?)` + `SidebarItem(label, icon?, active?, badge?, action?)` + `SidebarSection(label, items)` — group nav links into sections, mark the current page with `active=true`, attach badges for counts. Pass `collapsed=true` (or bind to a `$variable`) to collapse it to an icon rail.","- `SplitView(primary, detail, primaryWidth?)` — master/detail layout (inboxes, file browsers, contact lists). Both panes are scrollable."]},{name:"Advanced UI",components:["IconButton","CommandPalette","FilterChips","FieldRepeater","VirtualList","QueryBuilder","DiffViewer","JsonTree","Gantt","Truncate","InlineEdit","NotificationBell"],notes:["- `IconButton(icon, label, action?, variant?, size?, disabled?)` — accessible icon-only control.","- `CommandPalette(items, open?, placeholder?, shortcut?)` — Cmd-K searchable actions.","- `FilterChips(chips, onRemove?, onClear?)` — applied filter pills with remove.","- `FieldRepeater(items, fields, onAdd?, onRemove?)` — dynamic form rows.","- `VirtualList(items, itemHeight?, renderItem)` — windowed long lists.","- `QueryBuilder(fields, value?)` — visual AND/OR filter builder.","- `DiffViewer(left, right, mode?)` — side-by-side or unified diff.","- `JsonTree(data)` — collapsible JSON inspector.","- `Gantt(tasks, startDate?, endDate?)` — horizontal schedule timeline.","- `Truncate(text, maxLines?)` / `InlineEdit(value, onSave?)` / `NotificationBell(count?, items?)`."]},{name:"Routing",components:["NavLink"],notes:['- Declare routes with the `$router({...})` call form: `pages = $router({ "/": Dashboard(), "/orders/:id": OrderDetail({ id: params.id }), default: NotFound() })`. The matched arm\'s `params` object is in scope on the right-hand side; nest `$router` inside components for layout-preserving sub-routes.',"- `Redirect(path)` is a router-aware component: returning it from a route's body navigates and unmounts the rest of the subtree.","- `NavLink(label, { to })` is a thin link wrapper that reads `route.path` and dispatches `route.navigate(to)` — use it for sidebars, navbars and breadcrumbs.","- Read URL params via `route.params.<name>` (e.g. `route.params.id` for `/users/:id`) and the current path via `route.path`."]},{name:"Helpers",components:["Async","Show","Portal","Redirect","Lazy","ErrorBoundary"],notes:["- `Async(resource, { loading:, error:, empty:, data: })` switches an `$http({...})` resource on its `state` field (`empty` shows for `null`/empty-array data).","- `Show(when, { fallback?, children })` is sugar over `if (expr) { children } else { fallback }`.","- `Portal(target?, children)` renders into a different DOM subtree (defaults to `document.body`).","- `Redirect(path)` is a router-aware component — see Routing.","- `Lazy(loader, fallback?)` defers rendering until the async `loader` resolves, showing `fallback` while pending (a synchronous loader value renders immediately).","- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants."]},{name:"Behaviour wrappers",components:["OnClick","OnMouse","OnKeyboard","OnFocus","OnIntersect","OnMount","Css","Link"],notes:["- Wrappers compose: any built-in component can be made clickable, hoverable, observable, or restyled by wrapping it in one of these primitives — no need for the underlying component to grow another prop.","- `OnClick(child, { onClick, disabled?, stopPropagation? })` makes any component clickable / tappable (touch devices fire `click` too). Use for clickable cards, list rows, media tiles, and any custom layout that needs a tap target without a `<button>` baseline.","- `OnMouse(child, { enter?, leave?, hover?, move?, down?, up?, click?, doubleClick?, contextMenu?, scroll?, wheel?, drag?, drop?, dragStart?, dragEnd?, dragEnter?, dragLeave?, dragOver?, draggable?, passiveScroll? })` attaches any combination of mouse / pointer / drag listeners. Pass `draggable: true` to make the wrapper itself draggable. Scroll / wheel listeners default to `{ passive: true }` for smooth scrolling.","- `OnKeyboard(child, { onKeyDown?, onKeyUp?, onKeyPress?, focusable? })` attaches keyboard listeners. The wrapper is focusable by default; pass `focusable: false` when the child is already focusable (input, button).","- `OnFocus(child, { onFocus?, onBlur? })` tracks focus moving into or out of a subtree (uses bubbling `focusin` / `focusout` so descendants count).","- `OnIntersect(child, { onEnter?, onLeave?, onChange?, threshold?, rootMargin?, once? })` is the IntersectionObserver wrapper — perfect for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.","- `OnMount(child, { onMount?, onUnmount? })` is the DOM-ref / lifecycle wrapper. `onMount(node)` fires once after the wrapped element attaches; `onUnmount(node)` fires when it leaves the tree. Use it to measure or focus an element, or to hand a node to an imperative library (chart / map / editor). Stash the node in a `$ref(...)`.","- `Css(child, { style?, class? })` merges raw class tokens and inline styles onto the wrapped child. Reach for it ONLY when the standard component props can't express the styling — prefer `Box`/`Stack`/`Grid` for layout and `$theme(...)` for tokens.","- `Link(label_or_child, { to?, href?, external?, variant? })` is the anchor primitive — accepts either a plain string label or a wrapped component. Use `to` for client-side router navigation and `href` (with `external: true`) for outbound links."]},{name:"Escape hatches",components:["HTMLTag","Styles"],notes:["- **Use only as a last resort.** Reach for these primitives when the standard catalogue cannot express the markup or styling you need; for everything else (typography, layout, surfaces, controls) the dedicated components produce a more consistent UI for fewer tokens.",'- `HTMLTag(tag, attributes?, children?)` renders an allow-listed HTML tag with the given attribute object and child nodes (e.g. `HTMLTag("section", attributes: {class: "hero", "data-id": 1}, children: [Text("Hello")])`). Tag names outside the allow-list collapse to `div`; `on*` attributes, `javascript:` URLs in `href`/`src`, and `expression()` / `@import` in inline `style` are stripped.',"- `Styles(css)` injects a `<style>` block containing the given CSS rules (e.g. `` Styles(`.hero { background: linear-gradient(...); }`) ``). Pair it with `HTMLTag` (or any built-in component's `class`-bearing wrapper) when scoping to a custom selector. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped."]}];Ga(Gn);const mt={root:"Column",components:Gn,componentGroups:rm},am=t=>{const e={name:t.name,type:t.type,required:!t.optional};return t.description&&(e.description=t.description),t.enum&&t.enum.length>0&&(e.enumValues=t.enum),e},nm=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},im=t=>{const e=new Map;for(const r of t.componentGroups??[])for(const a of r.components)e.set(a,r.name);return e};function Yn(t=mt){const e=im(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(am),signature:nm(r)}))}function Xn(t){const e={};for(const r of t)e[r.name]=r;return e}const Jn=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");function Zn(t,e){return e.length===0?t:`${t}.${e.join(".")}`}function Qn(t,e){return!!(t===e||e.startsWith(t+".")||t.startsWith(e+"."))}function Lr(t,e){if(t.has(e))return!0;for(const r of t)if(Qn(r,e))return!0;return!1}function ft(t,e){for(const r of e)if(Lr(t,r))return!0;return!1}class ei{constructor(){z(this,"values",new Map);z(this,"defaults",new Map);z(this,"subscribers",new Set);z(this,"pendingChanges",new Set);z(this,"flushScheduled",!1);z(this,"rendering",!1);z(this,"renderWriteOccurred",!1)}declare(e,r){this.defaults.set(e,r),this.values.has(e)||this.values.set(e,r)}has(e){return this.values.has(e)}get(e){return this.values.get(e)}set(e,r){this.values.get(e)!==r&&(this.values.set(e,r),this.enqueueChange(e))}enqueueChange(e){if(this.rendering){this.renderWriteOccurred=!0;return}this.pendingChanges.add(e),this.scheduleFlush()}beginRenderPass(){this.rendering=!0,this.renderWriteOccurred=!1}isRendering(){return this.rendering}endRenderPass(){this.rendering=!1;const e=this.renderWriteOccurred;return this.renderWriteOccurred=!1,e}setPath(e,r,a){if(r.length===0){this.set(e,a);return}const n=this.values.get(e),i=gt(n,r,0,a);this.values.set(e,i),this.enqueueChange(Zn(e,r))}entries(){return this.values.entries()}snapshot(){const e={};return this.values.forEach((r,a)=>{e[a]=r}),e}hydrate(e){for(const[r,a]of Object.entries(e))this.values.set(r,a)}reset(...e){for(const r of e){if(!this.defaults.has(r))continue;const a=this.defaults.get(r);this.values.get(r)!==a&&(this.values.set(r,a),this.enqueueChange(r))}}resetAll(){for(const[e,r]of this.defaults.entries())this.values.get(e)!==r&&(this.values.set(e,r),this.enqueueChange(e))}rebind(e){this.values.clear(),this.defaults.clear(),this.pendingChanges.clear();for(const[r,a]of e)this.defaults.set(r,a),this.values.set(r,a)}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flush()))}flush(){if(this.flushScheduled=!1,this.pendingChanges.size===0)return;const e=new Set(this.pendingChanges);this.pendingChanges.clear();for(const r of[...this.subscribers])r(e)}}function gt(t,e,r,a){if(r>=e.length)return a;const n=e[r],i=n!==""&&!Number.isNaN(Number(n))?Number(n):null;if(Array.isArray(t)&&i!==null){const s=t.slice();return s[i]=gt(t[i],e,r+1,a),s}if(t&&typeof t=="object"&&!Array.isArray(t)){const s={...t};return s[n]=gt(t[n],e,r+1,a),s}if(i!==null){const s=[];return s[i]=gt(void 0,e,r+1,a),s}const o={};return o[n]=gt(void 0,e,r+1,a),o}const Rr=Symbol("aktion.httpResource");function ti(t){return typeof t=="object"&&t!==null&&t[Rr]===!0}class ri{constructor(){z(this,"interceptors",{})}registerInterceptors(e){this.interceptors={...this.interceptors,...e}}resolveUrl(e){return e}async request(e){let r={...e,headers:{...e.headers}};if(this.interceptors.onRequest)try{r=await this.interceptors.onRequest(r)}catch(n){throw this.interceptors.onError?.(n,r),n}const a=async()=>{const n=new AbortController,i=typeof fetch=="function"?fetch:null;if(!i)throw new Error("`fetch` is not available in this environment");const o={...r.init,method:r.method,headers:r.headers,signal:r.signal??n.signal};r.body!==void 0&&r.method!=="GET"&&r.method!=="HEAD"&&(o.body=om(r.body,r.headers));const s=await i(r.url,o),c={};s.headers.forEach((d,m)=>{c[m]=d});const u=c["content-type"]??"";let p;return s.status===204||r.method==="HEAD"?p=null:u.includes("application/json")?p=await s.json().catch(()=>null):p=await s.text().catch(()=>""),{status:s.status,headers:c,body:p}};try{let n=await a();if(this.interceptors.onResponse){let i=!1;const o=async()=>i?n:(i=!0,a());n=await this.interceptors.onResponse(n,o)}return n}catch(n){throw this.interceptors.onError?.(n,r),n}}}function om(t,e){if(t==null)return"";if(typeof t=="string"||t instanceof Blob||t instanceof ArrayBuffer||typeof FormData<"u"&&t instanceof FormData||typeof URLSearchParams<"u"&&t instanceof URLSearchParams)return t;!e["content-type"]&&!e["Content-Type"]&&(e["Content-Type"]="application/json");try{return JSON.stringify(t)}catch{return String(t)}}const sm=new Set(["url","method","headers","body","query","signal"]);function ai(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=typeof e.url=="string"?e.url:"",a=typeof e.method=="string"?e.method.toUpperCase():"GET",n={};if(e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(const[c,u]of Object.entries(e.headers))u!=null&&(n[c]=String(u));let i=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const c=new URLSearchParams;for(const[p,d]of Object.entries(e.query))d!=null&&c.append(p,String(d));const u=c.toString();u&&(i+=(i.includes("?")?"&":"?")+u)}const o={};for(const[c,u]of Object.entries(e))sm.has(c)||(o[c]=u);const s={url:i,method:a,headers:n,body:e.body};return Object.keys(o).length>0&&(s.init=o),e.signal instanceof AbortSignal&&(s.signal=e.signal),s}function zr(t,e){const r={state:"loading",data:void 0,error:void 0,loading:!0,refetch:async()=>{await o()},cancel:()=>{n+=1,a&&a.abort(),a=null,r.loading&&(r.loading=!1,r.state=r.data===void 0?"idle":"data",i())}};Object.defineProperty(r,Rr,{value:!0,enumerable:!1,writable:!1});let a=null,n=0;const i=()=>e.notify?.(),o=async()=>{const s=n+=1;a&&a.abort(),a=new AbortController;const c=a;if(r.state=r.data===void 0?"loading":"stale",r.loading=!0,i(),!e.http){r.error={message:"http runtime not available"},r.state="error",r.loading=!1,i();return}try{const u=ai(t);u.url=e.http.resolveUrl(u.url),u.signal=c.signal;const p=await e.http.request(u);if(s!==n)return;p.status>=200&&p.status<300?(r.data=p.body,r.state="data",r.error=void 0):(r.error={status:p.status,body:p.body},r.state="error"),r.status=p.status,r.headers=p.headers,r.lastUpdated=Date.now()}catch(u){if(s!==n||u?.name==="AbortError")return;r.error=u,r.state="error"}finally{if(s===n&&(r.loading=!1,i(),typeof r.onDone=="function"))try{r.onDone(r)}catch(u){console.error("[aktion] Http onDone callback threw",u)}}};return o(),r}function Dr(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function lm(t){const e=typeof t.method=="string"?t.method.toUpperCase():"GET",r=typeof t.url=="string"?t.url:"";let a="null",n="null";try{a=JSON.stringify(t.query??null)}catch{}try{n=JSON.stringify(t.body??null)}catch{}return`${e} ${r} ${a} ${n}`}function ni(t,e){const r=Dr(t),a=typeof r.ttl=="number"?r.ttl:0,n=r.key!=null?String(r.key):lm(r),i=e.queryCache,o=i.get(n);if(o)return a>0&&o.lastUpdated!=null&&Date.now()-o.lastUpdated>a&&!o.loading&&o.refetch(),o;const s={};for(const[u,p]of Object.entries(r))u==="key"||u==="ttl"||(s[u]=p);const c=zr(s,e);return i.set(n,c),c}function ii(t,e){const r=Dr(t);let a=0,n=null;const i=()=>e.notify?.(),o={data:void 0,error:void 0,loading:!1,reset:()=>{a+=1,n&&n.abort(),n=null,o.data=void 0,o.error=void 0,o.status=void 0,o.loading=!1,i()},mutate:async s=>{const c=a+=1;n&&n.abort(),n=new AbortController;const u=n;if(o.loading=!0,o.error=void 0,i(),!e.http){o.error={message:"http runtime not available"},o.loading=!1,i();return}try{const p={method:"POST",...r,...Dr(s)},d=ai(p);d.url=e.http.resolveUrl(d.url),d.signal=u.signal;const m=await e.http.request(d);if(c!==a)return;const g=m.status>=200&&m.status<300;return g?(o.data=m.body,o.error=void 0):o.error={status:m.status,body:m.body},o.status=m.status,g?m.body:void 0}catch(p){if(c!==a||p?.name==="AbortError")return;o.error=p;return}finally{if(c===a&&(o.loading=!1,i(),typeof o.onDone=="function"))try{o.onDone(o)}catch(p){console.error("[aktion] $mutation onDone callback threw",p)}}}};return Object.defineProperty(o,Rr,{value:!0,enumerable:!1,writable:!1}),o}function oi(t={}){const e=cm(t.translations),r=typeof t.defaultLanguage=="string"?t.defaultLanguage:"";let a=typeof t.currentLanguage=="string"&&t.currentLanguage?t.currentLanguage:r;function n(s,c){if(typeof s!="string"||!s)return"";const u=e[s];let p;return u&&(a&&typeof u[a]=="string"?p=u[a]:r&&typeof u[r]=="string"&&(p=u[r])),p===void 0?s:um(p,c)}function i(s){typeof s!="string"||!s||(a=s)}function o(){return a}return{t:n,setCurrentLanguage:i,getCurrentLanguage:o}}function cm(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t)){if(!a||typeof a!="object"||Array.isArray(a))continue;const n={};for(const[i,o]of Object.entries(a))typeof o=="string"&&(n[i]=o);e[r]=n}return e}function um(t,e){return e?t.replace(/\{([^}]+)\}/g,(r,a)=>{const n=e[a.trim()];return n==null?"":String(n)}):t}const W=t=>typeof t=="number"?t:typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):0,te=t=>Array.isArray(t)?t:[],Re=t=>!!t&&typeof t=="object"&&!Array.isArray(t),jr=(t,e,r)=>{switch(t){case"==":return e===r;case"!=":return e!==r;case">":return W(e)>W(r);case"<":return W(e)<W(r);case">=":return W(e)>=W(r);case"<=":return W(e)<=W(r);case"contains":{const a=String(e??"").toLowerCase(),n=String(r??"").toLowerCase();return a.includes(n)}case"startsWith":return String(e??"").toLowerCase().startsWith(String(r??"").toLowerCase());case"endsWith":return String(e??"").toLowerCase().endsWith(String(r??"").toLowerCase());default:return!1}},ht=t=>{if(Array.isArray(t))return t.map(e=>ht(e));if(t instanceof Date)return new Date(t.getTime());if(t&&typeof t=="object"){const e={};for(const r of Object.keys(t))e[r]=ht(t[r]);return e}return t},ze=(t,e)=>{if(e==="")return t;if(t&&typeof t=="object"){if(e.includes(".")){let r=t;for(const a of e.split("."))if(r&&typeof r=="object")r=r[a];else return;return r}return t[e]}},Ge=t=>{if(t instanceof Date)return t;if(typeof t=="number")return new Date(t);if(typeof t=="string"&&t.trim()!==""){if(!Number.isNaN(Number(t))&&/^-?\d+$/.test(t.trim()))return new Date(Number(t));const e=new Date(t);if(!Number.isNaN(e.getTime()))return e}return new Date},dm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],pm=["January","February","March","April","May","June","July","August","September","October","November","December"],mm=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],fm=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],gm=(t,e)=>{const r=(s,c=2)=>String(s).padStart(c,"0"),a=t.getHours(),n=(a+11)%12+1,i=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,pm[t.getMonth()]],[/MMM/g,dm[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,fm[t.getDay()]],[/ddd/g,mm[t.getDay()]],[/DD/g,r(t.getDate())],[/HH/g,r(a)],[/hh/g,r(n)],[/mm/g,r(t.getMinutes())],[/ss/g,r(t.getSeconds())],[/\bM\b/g,String(t.getMonth()+1)],[/\bD\b/g,String(t.getDate())],[/\bH\b/g,String(a)],[/\bh\b/g,String(n)],[/\bm\b/g,String(t.getMinutes())],[/\bs\b/g,String(t.getSeconds())],[/A/g,a>=12?"PM":"AM"],[/a/g,a>=12?"pm":"am"]];let o=e;for(const[s,c]of i)o=o.replace(s,c);return o},hm=(t,e=Date.now())=>{const r=e-t.getTime(),a=Math.abs(r),n=r<0,i=6e4,o=60*i,s=24*o,c=7*s,u=30*s,p=365*s;let d,m;return a<i?n?"in a moment":"just now":(a<o?(d=Math.round(a/i),m="m"):a<s?(d=Math.round(a/o),m="h"):a<c?(d=Math.round(a/s),m="d"):a<u?(d=Math.round(a/c),m="w"):a<p?(d=Math.round(a/u),m="mo"):(d=Math.round(a/p),m="y"),n?`in ${d}${m}`:`${d}${m} ago`)},bm=(t,e,r)=>{if(Re(e)){const n={};return typeof e.currency=="string"&&(n.currency=e.currency),typeof e.locale=="string"&&(n.locale=e.locale),typeof e.decimals=="number"&&(n.decimals=e.decimals),n}const a={};return t==="currency"?(typeof e=="string"&&e.length>0&&(a.currency=e),typeof r=="string"&&r.length>0&&(a.locale=r)):typeof e=="string"&&e.length>0&&(a.locale=e),a},vm=(t,e)=>{const a=String(t??"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(i=>i.toLowerCase());if(a.length===0)return"";if(e==="snake")return a.join("_");if(e==="kebab")return a.join("-");const n=i=>i.charAt(0).toUpperCase()+i.slice(1);return e==="pascal"?a.map(n).join(""):a[0]+a.slice(1).map(n).join("")},si={count:t=>te(t).length,sum:t=>te(t).reduce((e,r)=>e+W(r),0),avg:t=>{const e=te(t);return e.length===0?0:e.reduce((r,a)=>r+W(a),0)/e.length},min:t=>{const e=te(t).map(W);return e.length===0?0:Math.min(...e)},max:t=>{const e=te(t).map(W);return e.length===0?0:Math.max(...e)},first:t=>te(t)[0]??null,last:t=>{const e=te(t);return e.length===0?null:e[e.length-1]},filter:(t,e="",r="==",a)=>te(t).filter(n=>jr(r,ze(n,String(e)),a)),find:(t,e="",r="==",a)=>te(t).find(n=>jr(r,ze(n,String(e)),a))??null,sort:(t,e="",r="asc")=>{const a=[...te(t)],n=String(r).toLowerCase()==="desc"?-1:1;return a.sort((i,o)=>{const s=ze(i,String(e)),c=ze(o,String(e));return typeof s=="number"&&typeof c=="number"?(s-c)*n:String(s??"").localeCompare(String(c??""))*n}),a},groupBy:(t,e="")=>{const r={};for(const a of te(t)){const n=String(ze(a,String(e))??"");(r[n]??(r[n]=[])).push(a)}return r},slice:(t,e,r)=>{const a=te(t);return a.slice(e??0,r??a.length)},unique:(t,e)=>{const r=te(t);if(!e)return Array.from(new Set(r));const a=new Set,n=[];for(const i of r){const o=ze(i,e);a.has(o)||(a.add(o),n.push(i))}return n},reverse:t=>[...te(t)].reverse(),range:(t,e,r)=>{const a=W(t),n=W(e),i=r===void 0?n>=a?1:-1:W(r);if(i===0)return[a];const o=Math.abs(n-a),s=Math.floor(o/Math.abs(i))+1;if(s>Vt)throw new RangeError(`$util.range refusing to allocate ${s} entries (limit ${Vt}).`);const c=[];if(i>0)for(let u=a;u<=n;u+=i)c.push(u);else for(let u=a;u>=n;u+=i)c.push(u);return c},repeat:(t,e)=>{const r=Math.max(0,W(e));if(r>Vt)throw new RangeError(`$util.repeat refusing to allocate ${r} entries (limit ${Vt}).`);return Array.from({length:r},()=>t)},pick:(t,e)=>{if(!Re(t))return{};const r=te(e).map(n=>String(n??"")),a={};for(const n of r)n in t&&(a[n]=t[n]);return a},omit:(t,e)=>{if(!Re(t))return{};const r=new Set(te(e).map(n=>String(n??""))),a={};for(const n of Object.keys(t))r.has(n)||(a[n]=t[n]);return a},chunk:(t,e)=>{const r=te(t),a=Math.max(1,Math.floor(W(e))),n=[];for(let i=0;i<r.length;i+=a)n.push(r.slice(i,i+a));return n},flatten:(t,e=1)=>{const r=(a,n)=>n<=0?a.slice():a.reduce((i,o)=>(Array.isArray(o)?i.push(...r(o,n-1)):i.push(o),i),[]);return r(te(t),Math.max(0,Math.floor(W(e))))},zip:(...t)=>{const e=t.map(te),r=e.reduce((n,i)=>Math.max(n,i.length),0),a=[];for(let n=0;n<r;n+=1)a.push(e.map(i=>i[n]??null));return a},partition:(t,e="",r="==",a)=>{const n=[],i=[];for(const o of te(t))(jr(r,ze(o,String(e)),a)?n:i).push(o);return[n,i]},keyBy:(t,e="")=>{const r={};for(const a of te(t))r[String(ze(a,String(e))??"")]=a;return r},cloneDeep:t=>ht(t),merge:(t,...e)=>{const r=Re(t)?ht(t):{};for(const a of e)if(Re(a))for(const n of Object.keys(a)){const i=a[n],o=r[n];r[n]=Re(o)&&Re(i)?si.merge(o,i):Re(i)||Array.isArray(i)?ht(i):i}return r},format:(t,e="number",r,a)=>{const n=W(t),i=String(e),o=bm(i,r,a),s={};i==="currency"?(s.style="currency",s.currency=o.currency||"USD"):i==="percent"?(s.style="percent",o.decimals===void 0&&(s.maximumFractionDigits=2)):i==="compact"?s.notation="compact":s.style="decimal",o.decimals!==void 0&&(s.minimumFractionDigits=o.decimals,s.maximumFractionDigits=o.decimals);try{return new Intl.NumberFormat(o.locale||void 0,s).format(n)}catch{return i==="currency"?n.toFixed(o.decimals??2):String(n)}},formatDate:(t,e="MMM D")=>{const r=Ge(t),a=String(e);switch(a){case"relative":return hm(r);case"date":return r.toLocaleDateString();case"time":return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});case"datetime":return r.toLocaleString();case"iso":return r.toISOString();default:return gm(r,a)}},plural:(t,e,r)=>{const a=W(t),n=String(e??""),i=r===void 0?n+"s":String(r??"");return`${a} ${a===1?n:i}`},capitalize:t=>{const e=String(t??"");return e.length===0?"":e.charAt(0).toUpperCase()+e.slice(1)},lowercase:t=>String(t??"").toLowerCase(),uppercase:t=>String(t??"").toUpperCase(),titlecase:t=>String(t??"").split(/\s+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),case:(t,e="camel")=>{const r=String(e).toLowerCase();return vm(t,r==="snake"||r==="kebab"||r==="pascal"||r==="camel"?r:"camel")},now:()=>Date.now(),today:()=>{const t=new Date;return t.setHours(0,0,0,0),t.toISOString()},addDays:(t,e)=>{const r=Ge(t),a=new Date(r.getTime());return a.setDate(a.getDate()+W(e)),a.toISOString()},addHours:(t,e)=>{const r=Ge(t);return new Date(r.getTime()+W(e)*36e5).toISOString()},diffDays:(t,e)=>{const r=Ge(t),a=Ge(e);return Math.round((a.getTime()-r.getTime())/864e5)},startOfWeek:t=>{const e=Ge(t),r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));return r.setUTCDate(r.getUTCDate()-r.getUTCDay()),r.toISOString()},endOfMonth:t=>{const e=Ge(t);return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999).toISOString()},join:(t,e=",")=>te(t).map(r=>r==null?"":String(r)).join(String(e)),split:(t,e=",")=>String(t??"").split(String(e)),trim:t=>String(t??"").trim(),replace:(t,e,r="")=>String(t??"").split(String(e??"")).join(String(r??"")),substring:(t,e,r)=>{const a=String(t??"");return a.substring(W(e),r===void 0?a.length:W(r))},startsWith:(t,e)=>String(t??"").startsWith(String(e??"")),endsWith:(t,e)=>String(t??"").endsWith(String(e??"")),contains:(t,e)=>String(t??"").includes(String(e??"")),match:(t,e)=>{try{return new RegExp(String(e??"")).test(String(t??""))}catch{return!1}},round:(t,e=0)=>{const r=Math.pow(10,W(e));return Math.round(W(t)*r)/r},floor:t=>Math.floor(W(t)),ceil:t=>Math.ceil(W(t)),abs:t=>Math.abs(W(t)),clamp:(t,e,r)=>Math.min(Math.max(W(t),W(e)),W(r)),pow:(t,e)=>Math.pow(W(t),W(e)),sqrt:t=>Math.sqrt(W(t)),random:()=>Math.random(),log:t=>Math.log(W(t))},Vt=1e5;function De(t){if(!t)return"/";let e=String(t);e.startsWith("#")&&(e=e.slice(1));const r=e.indexOf("?");return r>=0&&(e=e.slice(0,r)),e=e.replace(/\/{2,}/g,"/"),!e||e==="/"?"/":(e.startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e)}function li(t,e){if(!t)return{matched:!1,params:{}};if(t==="*")return{matched:!0,params:{},wildcard:!0};const r=De(t),a=De(e),n=r==="/"?[]:r.slice(1).split("/"),i=a==="/"?[]:a.slice(1).split("/"),o={};let s=!1;for(let c=0;c<n.length;c+=1){const u=n[c];if(u==="*"){s=!0;const d=i.slice(c).join("/");return o._=d,{matched:!0,params:o,wildcard:s}}const p=i[c];if(p===void 0)return{matched:!1,params:{}};if(u.startsWith(":")){const d=u.slice(1);if(!d)return{matched:!1,params:{}};o[d]=decodeURIComponent(p);continue}if(u!==p)return{matched:!1,params:{}}}return!s&&i.length>n.length?{matched:!1,params:{}}:s?{matched:!0,params:o,wildcard:!0}:{matched:!0,params:o}}class ci{constructor(e={}){z(this,"currentPath");z(this,"currentParams",{});z(this,"currentPattern",null);z(this,"enabled",!1);z(this,"hashListener",null);z(this,"listeners",new Set);z(this,"defaultPath");z(this,"mode");z(this,"basePath");z(this,"settingHash",!1);this.defaultPath=De(e.defaultPath??"/"),this.currentPath=this.defaultPath,this.mode=e.mode==="history"?"history":"hash",this.basePath=ui(e.basePath)}configure(e){this.enabled||(e.mode&&(this.mode=e.mode==="history"?"history":"hash"),e.basePath!==void 0&&(this.basePath=ui(e.basePath)))}getMode(){return this.mode}start(){if(this.enabled||(this.enabled=!0,typeof window>"u"))return;const e=r=>{this.settingHash||this.setPath(this.readLocation(),r)};if(this.mode==="history"){const r=()=>e("hashchange");window.addEventListener("popstate",r),this.hashListener=r}else{const r=()=>e("hashchange");window.addEventListener("hashchange",r),this.hashListener=r}e("init")}readLocation(){if(typeof window>"u")return this.currentPath;if(this.mode==="history"){let e=window.location.pathname||"/";return this.basePath&&e.startsWith(this.basePath)&&(e=e.slice(this.basePath.length)||"/"),De(e)}return De(window.location.hash)}stop(){this.enabled&&(this.enabled=!1,typeof window<"u"&&this.hashListener&&(window.removeEventListener("hashchange",this.hashListener),window.removeEventListener("popstate",this.hashListener)),this.hashListener=null)}getPath(){return this.currentPath}getParams(){return this.currentParams}getActivePattern(){return this.currentPattern}setActiveMatch(e,r){this.currentPattern=e,ym(this.currentParams,r)||(this.currentParams=r)}navigate(e){const r=De(e);if(r!==this.currentPath){if(this.enabled&&typeof window<"u"){this.settingHash=!0;try{this.mode==="history"&&typeof window.history?.pushState=="function"?window.history.pushState({},"",(this.basePath||"")+r):window.location.hash="#"+r}finally{queueMicrotask(()=>{this.settingHash=!1})}this.setPath(r,"navigate");return}this.setPath(r,"navigate")}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setPath(e,r){const a=De(e);if(a===this.currentPath)return;const n=this.currentPath;this.currentPath=a,this.currentParams={},this.currentPattern=null;for(const i of[...this.listeners])try{i({path:a,previousPath:n,source:r})}catch(o){console.error("[aktion] router listener failed",o)}}}function ui(t){if(!t)return"";let e=String(t).trim();return e===""||e==="/"?"":(e.startsWith("/")||(e="/"+e),e.endsWith("/")&&(e=e.slice(0,-1)),e)}function ym(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(t[n]!==e[n])return!1;return!0}const je=(t,e)=>{try{return t()}catch{return e}},di=t=>{if(typeof t=="string")return t;if(t===null)return"null";if(t===void 0)return"";try{return JSON.stringify(t)}catch{return String(t)}},pi=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},mi=t=>({set:(e,r)=>je(()=>{const a=t();return a?(a.setItem(String(e),di(r)),!0):!1},!1),get:e=>je(()=>{const r=t();return r?pi(r.getItem(String(e))):null},null),remove:e=>je(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>je(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),xm=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,wm=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,Wt=()=>typeof globalThis>"u"?null:globalThis.document??null,km=t=>{if(t==null)return null;if(t instanceof Date)return t.toUTCString();if(typeof t=="string"){const e=new Date(t);return Number.isNaN(e.getTime())?null:e.toUTCString()}if(typeof t=="number"&&Number.isFinite(t)){const e=new Date;return e.setTime(e.getTime()+t*864e5),e.toUTCString()}return null},Br=(t={})=>{const e=[],r=km(t.expires);if(r&&e.push(`expires=${r}`),typeof t.maxAge=="number"&&Number.isFinite(t.maxAge)&&e.push(`max-age=${Math.floor(t.maxAge)}`),e.push(`path=${t.path??"/"}`),t.domain&&e.push(`domain=${t.domain}`),t.secure&&e.push("secure"),t.sameSite){const a=t.sameSite.charAt(0).toUpperCase()+t.sameSite.slice(1).toLowerCase();e.push(`samesite=${a}`)}return e.length===0?"":`; ${e.join("; ")}`},fi=()=>{const t=Wt();if(!t)return{};const e={},r=t.cookie??"";if(!r)return e;for(const a of r.split(";")){const n=a.trim();if(!n)continue;const i=n.indexOf("=");if(i<0){e[decodeURIComponent(n)]="";continue}const o=decodeURIComponent(n.slice(0,i)),s=decodeURIComponent(n.slice(i+1));e[o]=s}return e},Sm={set:(t,e,r)=>je(()=>{const a=Wt();if(!a)return!1;const n=encodeURIComponent(String(t)),i=encodeURIComponent(di(e));return a.cookie=`${n}=${i}${Br(r)}`,!0},!1),get:t=>je(()=>{const r=fi()[String(t)];return r===void 0?null:pi(r)},null),remove:(t,e)=>je(()=>{const r=Wt();if(!r)return!1;const a=encodeURIComponent(String(t)),n={...e,expires:new Date(0),maxAge:0};return r.cookie=`${a}=${Br(n)}`,!0},!1),clear:()=>je(()=>{const t=Wt();if(!t)return!1;const e=fi();for(const r of Object.keys(e)){const a=encodeURIComponent(r);t.cookie=`${a}=${Br({expires:new Date(0),maxAge:0})}`}return!0},!1)},bt=mi(xm),$m=mi(wm),Or={set:bt.set,get:bt.get,remove:bt.remove,clear:bt.clear,local:bt,session:$m,cookies:Sm},Cm=["log","error","warn","info","debug"],Am=()=>typeof globalThis>"u"?null:globalThis.console??null,Tm=t=>(...e)=>{const r=Am();if(!r)return;const a=r[t]??r.log;if(typeof a=="function")try{a(...e)}catch{}},gi=Cm.reduce((t,e)=>(t[e]=Tm(e),t),{}),Mm=4e3;function _r(t){return t==null?"":typeof t=="string"?t:String(t)}function hi(t){let e=[];const r=new Map;let a=0;const n=()=>t.notify?.(),i=d=>{const m=r.get(d);m!==void 0&&(clearTimeout(m),r.delete(d))},o=d=>{i(d);const m=e.filter(g=>g.id!==d);m.length!==e.length&&(e=m,p.items=e,n())},s=()=>{if(e.length!==0){for(const d of[...r.keys()])i(d);e=[],p.items=e,n()}},c=(d,m={})=>{const g=`toast-${a+=1}`,b=typeof m.duration=="number"?m.duration:Mm,h={id:g,message:_r(d),title:m.title!=null?_r(m.title):void 0,tone:m.tone!=null?_r(m.tone):"default",duration:b,createdAt:Date.now()};return e=[...e,h],p.items=e,b>0&&r.set(g,setTimeout(()=>{r.delete(g),o(g)},b)),n(),g},u=d=>(m,g={})=>c(m,{...g,tone:d}),p={items:e,show:c,success:u("success"),error:u("danger"),info:u("info"),warning:u("warning"),dismiss:o,clear:s};return t.disposers.push(()=>{for(const d of r.values())clearTimeout(d);r.clear(),e=[],p.items=e}),p}const vt={Math,JSON,Object,Array,Number,String,Boolean,Date,Map,Set,WeakMap,WeakSet,RegExp,Symbol,Promise,Error,TypeError,RangeError,Infinity:1/0,NaN:NaN,undefined:void 0,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,encodeURI,decodeURI,structuredClone:typeof structuredClone=="function"?structuredClone:void 0},Fr={util:si,console:gi,storage:Or},bi=new Set(["toast"]);function Nm(t){return t.toastManager||(t.toastManager=hi(t)),t.toastManager}function vi(t){if(typeof globalThis>"u")return{found:!1,value:void 0};if(t in Object.prototype)return{found:!1,value:void 0};const e=globalThis;return t in e?{found:!0,value:e[t]}:{found:!1,value:void 0}}const qt={componentDepthLimit:150,iterationLimit:25e4,arrayLengthLimit:1e5};class Be extends Error{constructor(r,a,n){super(Pm(r,a,n));z(this,"kind");z(this,"limit");z(this,"source");this.name="RuntimeBudgetError",this.kind=r,this.limit=a,this.source=n}}function Pm(t,e,r){switch(t){case"component-depth":return`[aktion] runtime aborted at ${r}: component recursion exceeded ${e} levels — check for a component that calls itself directly or transitively.`;case"iterations":return`[aktion] runtime aborted at ${r}: exceeded ${e} total loop iterations in a single render — narrow the iterable or split the loop.`;case"array-length":return`[aktion] runtime aborted at ${r}: array length would exceed ${e} elements.`}}function yi(t={}){return{componentDepthLimit:t.componentDepthLimit??qt.componentDepthLimit,iterationLimit:t.iterationLimit??qt.iterationLimit,arrayLengthLimit:t.arrayLengthLimit??qt.arrayLengthLimit,componentDepth:0,iterations:0}}function Ur(t){t.iterations=0,t.componentDepth=0}function yt(t,e,r){if(t&&(t.iterations+=e,t.iterations>t.iterationLimit))throw new Be("iterations",t.iterationLimit,r)}function Hr(t,e){const r=t.budget;if(r&&(r.componentDepth+=1,r.componentDepth>r.componentDepthLimit))throw r.componentDepth-=1,new Be("component-depth",r.componentDepthLimit,`component "${e}"`)}function Vr(t){const e=t.budget;e&&e.componentDepth>0&&(e.componentDepth-=1)}const xi=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),wi=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent"),Kt=t=>!!(t&&typeof t=="object"&&t.__kind==="Store");function Wr(t,e={}){const r={state:t,bindings:new Map,expressions:new Map,trackedState:new Set,loopVars:new Map,mutableBindings:new Map,stateAliases:[],router:e.router,library:e.library,componentDecls:new Map,effectDecls:new Map,componentEffectStack:[],actionDecls:new Map,hookDecls:new Map,hookScope:null,hookStore:new Map,stores:new Map,http:e.http,queryCache:new Map,notify:e.notify,onEmit:e.onEmit,strict:e.strict,strictWarned:new Set,disposers:[],timers:{timeouts:new Set,intervals:new Set},budget:e.budget===null?void 0:e.budget??yi()};return r.disposers.push(()=>{for(const a of r.timers.timeouts)clearTimeout(a);for(const a of r.timers.intervals)clearInterval(a);r.timers.timeouts.clear(),r.timers.intervals.clear()}),r}function qr(t){const e=t.disposers;t.disposers=[];for(const r of e)try{r()}catch(a){console.error("[aktion] context disposer threw",a)}}function ki(t){t.mutableBindings.clear()}function Ae(t,e){for(let r=t.stateAliases.length-1;r>=0;r-=1){const n=t.stateAliases[r].get(e);if(n!==void 0)return n}return e}function Gt(t,e){const r=[];let a=t;for(;a.kind==="Member";){if(a.computed){if(a.computed.kind!=="Literal")return null;const n=a.computed.value;if(typeof n!="string"&&typeof n!="number")return null;r.unshift(String(n))}else if(a.property)r.unshift(a.property);else return null;a=a.object}return a.kind!=="StateRef"?null:{name:Ae(e,a.name),path:r}}function Yt(t,e){if(t.kind==="StateRef")return Ae(e,t.name);if(t.kind==="Member"){const r=Gt(t,e);if(r)return r.path.length===0?r.name:`${r.name}.${r.path.join(".")}`;const a=Ei(t,e);if(a)return a.path.length===0?a.atom:`${a.atom}.${a.path.join(".")}`}return null}function Si(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const a=Jt(r.expression);e.state.declare(r.identifier,a)}for(const r of t.statements)Kr(r,e);for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||!$i(r.expression))continue;const a=M(r.expression,e);e.state.set(r.identifier,a)}Lm(t,e),Em(t,e)}const Im=8;function Em(t,e){const r=[],a=o=>{const s=new Set,c=e.trackedState;e.trackedState=s;try{const u=M(o.expr,e);e.state.set(o.name,u)}finally{e.trackedState=c}o.deps=s};for(const o of t.statements){if(o.kind!=="Assignment"||!o.isState||Xt(o.expression)||$i(o.expression))continue;const s={name:o.identifier,expr:o.expression,deps:new Set};r.push(s),a(s)}if(r.length===0)return;let n=!1;const i=e.state.subscribe(o=>{if(!n){n=!0;try{const s=new Set(o);for(let c=0;c<Im;c+=1){let u=!1;for(const p of r){if(!ft(s,p.deps))continue;const m=e.state.get(p.name);a(p),e.state.get(p.name)!==m&&(s.add(p.name),u=!0)}if(!u)break}}finally{n=!1}}});e.disposers.push(i)}function Xt(t){switch(t.kind){case"Literal":return!0;case"Array":return t.elements.every(e=>e.kind!=="Spread"&&Xt(e));case"Object":return t.properties.every(e=>!e.spread&&!e.computedKey&&Xt(e.value));case"Template":return t.expressions.length===0;default:return!1}}function $i(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="http"}function Ci(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="theme"}function Ai(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="app"}function Kr(t,e){switch(t.kind){case"ComponentDeclaration":{e.componentDecls.set(t.name,t),e.actionDecls.set(t.name,{kind:"ActionDeclaration",name:t.name,params:t.params,body:t.body,loc:t.loc});return}case"EffectDeclaration":e.effectDecls.set(t.name,t);return;case"ActionDeclaration":e.actionDecls.set(t.name,t);return;case"HookDeclaration":e.hookDecls.set(t.name,t);return;case"Await":case"Return":return;case"Import":return;case"ExpressionStatement":{const r=t.expression;Ai(r)?e.bindings.set("aktion",()=>M(r,e)):Ci(r)&&e.bindings.set("theme",()=>M(r,e));return}case"Assignment":{if(t.isState)return;e.expressions.set(t.identifier,t.expression);const r=t.expression;e.bindings.set(t.identifier,()=>M(r,e));return}}}function Ti(t){switch(t.kind){case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"DestructureStatement":case"ThrowStatement":return!0;case"ExpressionStatement":return!Ai(t.expression)&&!Ci(t.expression);default:return!1}}function Lm(t,e){let r=!1;for(const a of t.statements)if(Ti(a)){r=!0;break}if(r){for(const a of t.statements)a.kind==="Assignment"&&a.isState&&Xt(a.expression)&&e.state.set(a.identifier,Jt(a.expression));for(const a of t.statements)if(Ti(a))try{Gr(a,e)}catch(n){if(n instanceof ke||n instanceof Te||n instanceof nt)continue;if(n instanceof Be)throw n;console.error("[aktion] top-level statement threw",n)}}}function Rm(t,e,r){const a=t[0];if(!a||a.kind!=="Object")return console.error('[aktion] $router expects an object literal of route arms (e.g. `$router({ "/": Home(), default: NotFound() })`).',r),e.router?.setActiveMatch(null,{}),null;const n=yf(e);let i=null;for(const o of a.properties){if(o.spread)continue;const s=o.key;if(s==="default"||s==="*"){i=o;continue}const c=li(s,n);if(c.matched)return Mi(s,o.value,c.params,e)}return i?Mi(null,i.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function Mi(t,e,r,a){const n=a.loopVars.get("params"),i=a.loopVars.has("params");a.loopVars.set("params",r);try{const o=M(e,a);return a.router?.setActiveMatch(t,r),o}finally{i?a.loopVars.set("params",n):a.loopVars.delete("params")}}function Jt(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(Jt(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=Jt(r.value));return e}case"Template":return t.expressions.length===0?t.quasis[0]??"":null;default:return null}}function M(t,e){switch(t.kind){case"Literal":return t.value;case"Identifier":{if(e.loopVars.has(t.name))return e.loopVars.get(t.name);if(e.mutableBindings.has(t.name))return e.mutableBindings.get(t.name);if(t.name==="route")return e.trackedState.add("route"),e.router?xf(e.router):{path:"/",params:{},pattern:null,query:{},navigate(){},toString(){return"/"}};const r=e.bindings.get(t.name);if(r){const o=r();return e.mutableBindings.set(t.name,o),o}const a=e.actionDecls.get(t.name);if(a)return df(a,e);const n=e.componentDecls.get(t.name);if(n)return pf(n);if(Object.prototype.hasOwnProperty.call(vt,t.name))return vt[t.name];if(e.library&&Ee(e.library,t.name))return mf(t.name);if(t.name==="cleanup"&&e.cleanupSink){const o=e.cleanupSink;return s=>{typeof s=="function"&&o(s)}}const i=vi(t.name);if(i.found)return i.value;if(e.strict&&!e.strictWarned.has(t.name)){e.strictWarned.add(t.name);const o=t.loc?` (line ${t.loc.line}, col ${t.loc.column})`:"";console.warn(`[aktion] strict: unknown identifier "${t.name}" resolved to null${o}. Did you misspell a state atom, action, or component name?`)}return null}case"StateRef":{if(Object.prototype.hasOwnProperty.call(Fr,t.name))return Fr[t.name];if(bi.has(t.name)&&t.name==="toast")return Nm(e);if(t.name==="emit"&&e.onEmit){const a=e.onEmit;return(n,i)=>{a(n==null?"":String(n),i)}}const r=Ae(e,t.name);return e.trackedState.add(r),e.state.get(r)}case"Array":{const r=[];for(const a of t.elements){if(a.kind==="Spread"){const n=M(a.argument,e);if(Array.isArray(n))for(const i of n)r.push(i);else if(n!=null&&typeof n=="string")for(const i of n)r.push(i);continue}r.push(M(a,e))}return r}case"Object":{const r={};for(const a of t.properties){if(a.spread){const i=M(a.value,e);if(i&&typeof i=="object"&&!Array.isArray(i))for(const[o,s]of Object.entries(i))r[o]=s;continue}const n=a.computedKey?String(M(a.computedKey,e)??""):a.key;r[n]=M(a.value,e)}return r}case"Member":{if(Hm(t))return Vm(t,e);const r=Wm(t,e);if(r)return qm(t,e,r);const a=M(t.object,e);if(t.optional&&a==null)return;if(t.computed){const n=M(t.computed,e);return Jr(a,n)}return Zr(a,t.property??"")}case"Unary":{if(t.operator==="delete"){const a=t.argument;if(a.kind==="Member"&&a.property){const n=M(a.object,e);if(n&&typeof n=="object")try{return delete n[a.property],!0}catch{return!1}}return!1}const r=M(t.argument,e);switch(t.operator){case"!":return!r;case"-":return-_(r);case"+":return+_(r);case"~":return~se(r);case"typeof":return typeof r;case"void":return;default:return r}}case"Binary":return Jm(t.operator,t.left,t.right,e);case"Ternary":{const r=M(t.test,e);return M(r?t.consequent:t.alternate,e)}case"Call":return Qm(t.callee,t.arguments,e,t.loc);case"MethodCall":return Zm(t,e);case"Invoke":return Gm(t,e);case"New":return Ym(t,e);case"BuiltinCall":return ff(t.name,t.arguments,e);case"Template":return Xm(t.quasis,t.expressions,e);case"Spread":return M(t.argument,e);case"Block":return Yr(t,e,{});case"Lambda":{const r=t.params,a=t.body,n=e.stateAliases.map(o=>new Map(o)),i=new Map(e.loopVars);return(...o)=>{const s=new Map(e.loopVars),c=e.stateAliases.slice();e.loopVars.clear();for(const[d,m]of i)e.loopVars.set(d,m);e.stateAliases.length=0;for(const d of n)e.stateAliases.push(d);const u=[],p=(d,m)=>{u.push({name:d,had:e.loopVars.has(d),prev:e.loopVars.get(d)}),e.loopVars.set(d,m)};for(let d=0;d<r.length;d+=1){const m=r[d];let g=o[d];if(g===void 0&&m.defaultValue&&(g=M(m.defaultValue,e)),m.pattern){for(const b of xt(m.pattern,g,e))p(b.name,b.value);continue}p(m.name,g)}try{return M(a,e)}finally{for(const d of u)d.had?e.loopVars.set(d.name,d.prev):e.loopVars.delete(d.name);e.loopVars.clear();for(const[d,m]of s)e.loopVars.set(d,m);e.stateAliases.length=0;for(const d of c)e.stateAliases.push(d)}}}default:return null}}class ke{constructor(){z(this,"kind","break")}}class Te{constructor(){z(this,"kind","continue")}}class nt{constructor(e){z(this,"kind","return");this.value=e}}function Ni(t,e){if(M(t.test,e)){Se(t.consequent.body,e);return}if(t.alternate){if(t.alternate.kind==="IfStatement"){Ni(t.alternate,e);return}t.alternate.kind==="Block"&&Se(t.alternate.body,e)}}function zm(t,e){const r=M(t.discriminant,e);let a=!1;try{for(const n of t.cases)a||(n.test===null||M(n.test,e)===r)&&(a=!0),a&&Se(n.body,e)}catch(n){if(n instanceof ke)return;throw n}}function Dm(t,e){const r=M(t.iterable,e);if(!Array.isArray(r)&&(r==null||typeof r!="object"||!(Symbol.iterator in r)))return;const a=e.loopVars.has(t.item),n=e.loopVars.get(t.item),i=t.index,o=i?e.loopVars.has(i):!1,s=i?e.loopVars.get(i):void 0,c=t.destructure??[],u=c.map(p=>({name:p,had:e.loopVars.has(p),value:e.loopVars.get(p)}));try{let p=0;const d=(Array.isArray(r),r);for(const m of d){yt(e.budget,1,"`for…of` loop"),e.loopVars.set(t.item,m),i&&e.loopVars.set(i,p);for(const g of c){const b=m&&typeof m=="object"?m[g]:void 0;e.loopVars.set(g,b)}try{Se(t.body.body,e)}catch(g){if(g instanceof Te){p+=1;continue}if(g instanceof ke)return;throw g}p+=1}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item),i&&(o?e.loopVars.set(i,s):e.loopVars.delete(i));for(const p of u)p.had?e.loopVars.set(p.name,p.value):e.loopVars.delete(p.name)}}function jm(t,e){for(t.init&&Zt(t.init,e);!(t.test&&!M(t.test,e));){yt(e.budget,1,"`for` loop");try{Se(t.body.body,e)}catch(r){if(!(r instanceof Te)){if(r instanceof ke)return;throw r}}t.update&&M(t.update,e)}}function Bm(t,e){for(;M(t.test,e);){yt(e.budget,1,"`while` loop");try{Se(t.body.body,e)}catch(r){if(r instanceof Te)continue;if(r instanceof ke)return;throw r}}}function Om(t,e){for(;;){yt(e.budget,1,"`do…while` loop");try{Se(t.body.body,e)}catch(r){if(!(r instanceof Te)){if(r instanceof ke)return;throw r}}if(!M(t.test,e))break}}function _m(t,e){const r=M(t.expression,e),a=xt({kind:t.patternKind,bindings:t.bindings},r,e);for(const{name:n,value:i}of a)e.loopVars.set(n,i)}function xt(t,e,r){const a=[];if(t.kind==="array"){const o=Array.isArray(e)?e:[];let s=0;for(const c of t.bindings){if(c.rest){a.push({name:c.name,value:o.slice(s)}),s=o.length;continue}let u=o[s];u===void 0&&c.defaultValue&&(u=M(c.defaultValue,r)),c.name!==""&&a.push({name:c.name,value:u}),s+=1}return a}const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},i=new Set;for(const o of t.bindings){if(o.rest){const u={};for(const[p,d]of Object.entries(n))i.has(p)||(u[p]=d);a.push({name:o.name,value:u});continue}const s=o.sourceKey??o.name;i.add(s);let c=n[s];c===void 0&&o.defaultValue&&(c=M(o.defaultValue,r)),a.push({name:o.name,value:c})}return a}function Fm(t,e){const r=M(t.iterable,e);if(r==null||typeof r!="object")return;const a=e.loopVars.has(t.item),n=e.loopVars.get(t.item);try{for(const i in r){yt(e.budget,1,"`for…in` loop"),e.loopVars.set(t.item,i);try{Se(t.body.body,e)}catch(o){if(o instanceof Te)continue;if(o instanceof ke)return;throw o}}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item)}}function Um(t,e){try{Se(t.block.body,e)}catch(r){if(r instanceof ke||r instanceof Te||r instanceof nt)throw r;if(t.catchBlock){const a=t.catchParam,n=a?e.loopVars.has(a):!1,i=a?e.loopVars.get(a):void 0;a&&e.loopVars.set(a,r);try{Se(t.catchBlock.body,e)}finally{a&&(n?e.loopVars.set(a,i):e.loopVars.delete(a))}}}finally{t.finallyBlock&&Se(t.finallyBlock.body,e)}}function Se(t,e){for(const r of t)Zt(r,e)}function Gr(t,e){Zt(t,e)}function Zt(t,e){switch(t.kind){case"ExpressionStatement":M(t.expression,e);return;case"Assignment":{const r=M(t.expression,e);if(t.identifier)if(t.isState){const a=Ae(e,t.identifier);e.state.set(a,r)}else e.bindings.has(t.identifier)&&!e.loopVars.has(t.identifier)?e.mutableBindings.set(t.identifier,r):e.loopVars.set(t.identifier,r);return}case"IfStatement":Ni(t,e);return;case"SwitchStatement":zm(t,e);return;case"ForOfStatement":Dm(t,e);return;case"ForClassicStatement":jm(t,e);return;case"ForInStatement":Fm(t,e);return;case"WhileStatement":Bm(t,e);return;case"DoWhileStatement":Om(t,e);return;case"DestructureStatement":_m(t,e);return;case"TryStatement":Um(t,e);return;case"BreakStatement":throw new ke;case"ContinueStatement":throw new Te;case"ThrowStatement":throw M(t.argument,e);case"Return":{const r=t.argument?M(t.argument,e):void 0;throw new nt(r)}case"Await":M(t.argument,e);return;default:return}}function Hm(t){let e=t;for(;e.kind==="Member";)e=e.object;return e.kind==="StateRef"&&(Object.prototype.hasOwnProperty.call(Fr,e.name)||bi.has(e.name))?!1:e.kind==="StateRef"}function Vm(t,e){const r=Pi(t);let a=t;for(;a.kind==="Member";)a=a.object;const n=Ae(e,a.name);return Ii(r,n,e)}function Pi(t){const e=[];let r=t;for(;r.kind==="Member";)e.unshift({property:r.property,computed:r.computed}),r=r.object;return e}function Ii(t,e,r){let a=r.state.get(e);const n=[e];let i=!0;for(const o of t){let s,c=null;o.computed?o.computed.kind==="Literal"?(s=o.computed.value,(typeof s=="string"||typeof s=="number")&&(c=String(s))):s=M(o.computed,r):(s=o.property??"",c=o.property??"");const u=a!=null&&typeof a=="object"&&!Array.isArray(a);i&&c!==null&&u?n.push(c):i=!1,a=o.computed?Jr(a,s):Zr(a,o.property??"")}return r.trackedState.add(n.join(".")),a}function Wm(t,e){let r=t;for(;r.kind==="Member";)r=r.object;if(r.kind!=="Identifier")return null;const a=M(r,e);return Kt(a)?a:null}function qm(t,e,r){const a=Pi(t),n=a[0];if(n&&n.computed===void 0&&n.property!==void 0&&Object.prototype.hasOwnProperty.call(r.__methods,n.property)){let i=r.__methods[n.property];for(let o=1;o<a.length;o+=1){const s=a[o];s.computed?i=Jr(i,M(s.computed,e)):i=Zr(i,s.property??"")}return i}return Ii(a,r.__atom,e)}function Km(t,e,r){const a=r?`${r.line}:${r.column}`:`anon:${e.stores.size}`,n=e.stores.get(a);if(n)return n;const i=t[0]?M(t[0],e):{},o={},s={};if(i&&typeof i=="object"&&!Array.isArray(i))for(const[d,m]of Object.entries(i))typeof m=="function"?s[d]=m:o[d]=m;const c=r?`__store_${r.line}_${r.column}`:`__store_anon_${e.stores.size}`;e.state.declare(c,o);const u={},p={__kind:"Store",__atom:c,__methods:u};for(const[d,m]of Object.entries(s))u[d]=(...g)=>m(p,...g);return e.stores.set(a,p),p}function Ei(t,e){const r=[];let a=t;for(;a.kind==="Member";){if(a.computed){if(a.computed.kind!=="Literal")return null;const i=a.computed.value;if(typeof i!="string"&&typeof i!="number")return null;r.unshift(String(i))}else if(a.property)r.unshift(a.property);else return null;a=a.object}if(a.kind!=="Identifier")return null;const n=M(a,e);return Kt(n)?{atom:n.__atom,path:r}:null}function Gm(t,e){if(t.callee.kind==="StateRef"){const n=t.callee.name;if(n==="state")return nf(t.arguments,e,t.loc);if(n==="memo")return of(t.arguments,e,t.loc);if(n==="ref")return sf(t.arguments,e,t.loc);if(n==="reducer")return lf(t.arguments,e,t.loc);if(n==="id")return cf(t.arguments,e,t.loc);switch(n){case"store":return Km(t.arguments,e,t.loc);case"router":return Rm(t.arguments,e,t.loc);case"http":{const o=t.arguments[0];return zr(o?M(o,e):{},e)}case"query":{const o=t.arguments[0];return ni(o?M(o,e):{},e)}case"mutation":{const o=t.arguments[0];return ii(o?M(o,e):{},e)}case"theme":{const o=t.arguments[0];return{kind:"Theme",tokens:Sf(o?M(o,e):null)}}case"app":{const o=t.arguments;return o.length===1?M(o[0],e):o.map(s=>M(s,e))}case"i18n":{const o=t.arguments[0],s=o?M(o,e):null,c=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return oi(c)}case"emit":{const o=t.arguments[0]?String(M(t.arguments[0],e)):"",s=t.arguments[1]?M(t.arguments[1],e):void 0;e.onEmit?.(o,s);return}case"storage":return t.arguments[0]&&M(t.arguments[0],e),Or;case"optimistic":return rf(t.arguments[0],e)}const i=e.hookDecls.get(n);if(i)return uf(i,t.arguments,e)}const r=M(t.callee,e);if(r==null)return t.optional?void 0:null;if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=M(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(M(n,e))}try{return r.apply(void 0,a)}catch(n){return console.error("[aktion] call expression threw",n),null}}function Ym(t,e){const r=M(t.callee,e);if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=M(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(M(n,e))}try{return Reflect.construct(r,a)}catch(n){return console.error("[aktion] `new` threw",n),null}}function Yr(t,e,r){let a=null;const n=[];try{for(const i of t.body)switch(i.kind){case"ExpressionStatement":a=M(i.expression,e);continue;case"Assignment":{if(i.isState&&i.identifier){const s=Ae(e,i.identifier);if(r.stateAsDeclaration){if(e.state.has(s)){a=e.state.get(s);continue}const u=M(i.expression,e);e.state.declare(s,u),a=u;continue}const c=M(i.expression,e);e.state.set(s,c),a=c;continue}const o=M(i.expression,e);e.bindings.has(i.identifier)&&!e.loopVars.has(i.identifier)?e.mutableBindings.set(i.identifier,o):(e.loopVars.has(i.identifier)||n.push(i.identifier),e.loopVars.set(i.identifier,o)),a=o;continue}case"Return":return a=i.argument?M(i.argument,e):void 0,a;case"ThrowStatement":throw M(i.argument,e);case"EffectDeclaration":{const o=e.componentEffectStack[e.componentEffectStack.length-1];o?o.push({decl:i,capturedAliases:e.stateAliases.map(s=>new Map(s)),capturedLoopVars:new Map(e.loopVars)}):Kr(i,e);continue}case"ComponentDeclaration":case"ActionDeclaration":case"HookDeclaration":Kr(i,e);continue;case"Await":continue;case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"DestructureStatement":Zt(i,e);continue}}catch(i){if(i instanceof nt)return i.value;throw i}finally{for(const i of n)e.loopVars.delete(i)}return a}function Xm(t,e,r){let a=t[0]??"";for(let n=0;n<e.length;n+=1)a+=Qr(M(e[n],r)),a+=t[n+1]??"";return a}function Jm(t,e,r,a){if(t==="&&"){const o=M(e,a);return o&&M(r,a)}if(t==="||"){const o=M(e,a);return o||M(r,a)}if(t==="??"){const o=M(e,a);return o??M(r,a)}const n=M(e,a),i=M(r,a);switch(t){case"+":return typeof n=="string"||typeof i=="string"?Qr(n)+Qr(i):_(n)+_(i);case"-":return _(n)-_(i);case"*":return _(n)*_(i);case"/":{const o=_(i);return o===0?0:_(n)/o}case"%":{const o=_(i);return o===0?0:_(n)%o}case"**":return _(n)**_(i);case"==":case"===":return n===i;case"!=":case"!==":return n!==i;case">":return _(n)>_(i);case"<":return _(n)<_(i);case">=":return _(n)>=_(i);case"<=":return _(n)<=_(i);case"&":return se(n)&se(i);case"|":return se(n)|se(i);case"^":return se(n)^se(i);case"<<":return se(n)<<(Oe(i)&31);case">>":return se(n)>>(Oe(i)&31);case">>>":return Oe(n)>>>(Oe(i)&31);case"instanceof":{if(typeof i!="function")return!1;try{return n instanceof i}catch{return!1}}case"in":{if(i==null||typeof i!="object"&&typeof i!="function")return!1;try{return String(n)in i}catch{return!1}}default:return null}}function se(t){return _(t)|0}function Oe(t){return _(t)>>>0}function Zm(t,e){const r=M(t.object,e);if(r==null)return t.optional?void 0:null;const a=Kt(r)?r.__methods[t.method]:r[t.method];if(typeof a!="function")return null;const n=[];for(const o of t.arguments){if(o.kind==="Spread"){const s=M(o.argument,e);if(Array.isArray(s))for(const c of s)n.push(c);continue}n.push(M(o,e))}const i=n;try{return a.apply(r,i)}catch(o){if(o instanceof RangeError||o instanceof Be)throw o;return console.error(`[aktion] method "${t.method}" threw`,o),null}}function Qm(t,e,r,a){const n=r.componentDecls.get(t);if(n)return tf(n,e,r,a);const i=r.actionDecls.get(t);if(i){const g=e.map(b=>M(b,r));return Ri(i,g,r)}if(t==="cleanup"&&r.cleanupSink){const g=e[0]?M(e[0],r):void 0;typeof g=="function"&&r.cleanupSink(g);return}if(t==="setTimeout"||t==="setInterval")return gf(t,e,r);if(t==="clearTimeout"||t==="clearInterval"){const g=e[0]?M(e[0],r):void 0;g!=null&&(t==="clearTimeout"?(clearTimeout(g),r.timers.timeouts.delete(g)):(clearInterval(g),r.timers.intervals.delete(g)));return}const o=r.loopVars.get(t);if(typeof o=="function"){const g=e.map(b=>M(b,r));return o(...g)}const s=r.bindings.get(t);if(s){const g=s();if(typeof g=="function"){const b=e.map(h=>M(h,r));return g(...b)}}if(Object.prototype.hasOwnProperty.call(vt,t)&&typeof vt[t]=="function"&&!r.componentDecls.has(t)&&!(r.library&&Ee(r.library,t))){const g=vt[t],b=[];for(const h of e){if(h.kind==="Spread"){const v=M(h.argument,r);if(Array.isArray(v))for(const y of v)b.push(y);continue}b.push(M(h,r))}try{return g(...b)}catch(h){return console.error(`[aktion] global "${t}" threw`,h),null}}if(r.library&&!Ee(r.library,t)){const g=vi(t);if(g.found&&typeof g.value=="function"){const b=g.value,h=[];for(const v of e){if(v.kind==="Spread"){const y=M(v.argument,r);if(Array.isArray(y))for(const x of y)h.push(x);continue}h.push(M(v,r))}try{return b(...h)}catch(v){return console.error(`[aktion] global "${t}" threw`,v),null}}return Ee(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:a}:null}let c;const u=[...e];if(u.length>0){const g=u[u.length-1];if(g.kind==="Object"){const b=g.properties.find(h=>!h.spread&&h.key==="key");if(b){c=M(b.value,r);const h=g.properties.filter(v=>v!==b);h.length>0?u[u.length-1]={...g,properties:h}:u.pop()}}}const{args:p,argMeta:d}=ef(r,t,u);return{__kind:"Component",name:t,args:p,argMeta:d,explicitKey:c,source:a}}function ef(t,e,r){const a=t.library?Ee(t.library,e):void 0;if(!a){const m=r.map(b=>M(b,t)),g=r.map(b=>{const h=Yt(b,t);return h!==null?{stateRef:h}:{}});return{args:m,argMeta:g}}const n=new Map;a.props.forEach((m,g)=>{if(n.set(m.name,g),m.aliases)for(const b of m.aliases)n.has(b)||n.set(b,g)});const i=mr(a),o=a.props.map(()=>({value:void 0,meta:{},filled:!1})),s=[];let c=-1;for(let m=r.length-1;m>=0;m-=1)if(r[m].kind==="Object"){c=m;break}for(let m=0;m<r.length;m+=1){if(m===c)continue;const g=r[m];s.push({expr:g,value:M(g,t)})}if(c>=0){const m=r[c];if(m.kind==="Object")for(const g of m.properties){if(g.spread)continue;const b=n.get(g.key);if(b===void 0)continue;const h=M(g.value,t);o[b].value=h,o[b].filled=!0;const v=Yt(g.value,t);v!==null&&(o[b].meta={stateRef:v})}}if(s.length>0&&i>=0&&!o[i].filled){const{expr:m,value:g}=s.shift();o[i].value=g,o[i].filled=!0;const b=Yt(m,t);b!==null&&(o[i].meta={stateRef:b})}let u=0;for(const{expr:m,value:g}of s){for(;u<a.props.length&&o[u].filled;)u+=1;if(u>=a.props.length)break;o[u].value=g,o[u].filled=!0;const b=Yt(m,t);b!==null&&(o[u].meta={stateRef:b}),u+=1}const p=o.map(m=>m.value),d=o.map(m=>m.meta);for(;p.length>0&&p[p.length-1]===void 0;)p.pop(),d.pop();return{args:p,argMeta:d}}function tf(t,e,r,a){const n=[],i={};let o,s=-1;for(let b=e.length-1;b>=0;b-=1)if(e[b].kind==="Object"){s=b;break}let c=s>=0?e[s]:null,u=!1;if(c&&c.kind==="Object"){const b=new Set(t.params.map(v=>v.name)),h=[];for(const v of c.properties)v.spread||(h.push(v.key),(v.key==="key"||b.has(v.key))&&(u=!0));if(!u&&r.strict&&h.length>0&&t.params.length>0){const v=`trailing:${t.name}:${h.slice().sort().join(",")}`;if(!r.strictWarned.has(v)){r.strictWarned.add(v);const y=a?` (line ${a.line}, col ${a.column})`:"";console.warn(`[aktion] strict: object { ${h.join(", ")} } passed to <${t.name}>${y} is being forwarded as a positional argument because none of its keys match a parameter (${t.params.map(x=>x.name).join(", ")||"none"}). If you meant named props, check for a renamed/misspelled parameter.`)}}}u||(s=-1,c=null);for(let b=0;b<e.length;b+=1)b!==s&&n.push(e[b]);if(c&&c.kind==="Object")for(const b of c.properties)b.spread||(b.key==="key"?o=b.value:i[b.key]=b.value);const p=n.map(b=>b.kind==="Spread"?M(b.argument,r):M(b,r)),d=[];for(let b=0;b<n.length;b+=1){const h=n[b],v=p[b];if(h.kind==="Spread"&&Array.isArray(v))for(const y of v)d.push(y);else d.push(v)}const m={};for(const[b,h]of Object.entries(i))m[b]=M(h,r);const g=o?M(o,r):void 0;return{__kind:"UserComponent",decl:t,positional:d,named:m,explicitKey:g,source:a}}function Li(t,e,r){const{decl:a,positional:n,named:i}=t,o=[],s=(m,g)=>{o.push({name:m,had:e.loopVars.has(m),prev:e.loopVars.get(m)}),e.loopVars.set(m,g)};for(let m=0;m<a.params.length;m+=1){const g=a.params[m];if(g.pattern){let h=n[m];h===void 0&&g.defaultValue&&(h=M(g.defaultValue,e));for(const v of xt(g.pattern,h,e))s(v.name,v.value);continue}let b;i[g.name]!==void 0?b=i[g.name]:n[m]!==void 0?b=n[m]:g.defaultValue?b=M(g.defaultValue,e):b=void 0,s(g.name,b)}if(n.length>a.params.length){const m=n.slice(a.params.length),g=m.length===1?m[0]:m;o.push({name:"children",had:e.loopVars.has("children"),prev:e.loopVars.get("children")}),e.loopVars.set("children",g)}if(a.slots.length>0){const m={};for(const g of a.slots)i[g]!==void 0&&(m[g]=i[g]);o.push({name:"slots",had:e.loopVars.has("slots"),prev:e.loopVars.get("slots")}),e.loopVars.set("slots",m)}const c=new Map;for(const m of a.body.body)if(m.kind==="Assignment"&&m.isState){const g=`${r}:${m.identifier}`;c.set(m.identifier,g)}e.stateAliases.push(c);const u=[];e.componentEffectStack.push(u);const p=e.hookScope,d={instanceKey:r,cursor:0};e.hookScope=d;try{return{value:Yr(a.body,e,{stateAsDeclaration:!0}),effects:u,hooks:d.cursor}}finally{e.hookScope=p,e.componentEffectStack.pop(),e.stateAliases.pop();for(const m of o)m.had?e.loopVars.set(m.name,m.prev):e.loopVars.delete(m.name)}}function Ri(t,e,r){return zi(t.params,t.body,e,r)}function rf(t,e){const r=t?M(t,e):void 0;if(typeof r!="function")return;const a=new Map;for(const[i,o]of e.state.entries())a.set(i,o);const n=()=>{for(const i of[...e.state.entries()].map(([o])=>o))a.has(i)||e.state.set(i,void 0);for(const[i,o]of a)e.state.set(i,o);e.notify?.()};try{const i=r();return i&&typeof i.then=="function"?i.catch(o=>{throw n(),o}):i}catch(i){throw i instanceof nt||i instanceof ke||i instanceof Te||n(),i}}function zi(t,e,r,a){const n=[],i=(o,s)=>{n.push({name:o,had:a.loopVars.has(o),prev:a.loopVars.get(o)}),a.loopVars.set(o,s)};for(let o=0;o<t.length;o+=1){const s=t[o];let c=r[o];if(c===void 0&&s.defaultValue&&(c=M(s.defaultValue,a)),s.pattern){for(const u of xt(s.pattern,c,a))i(u.name,u.value);continue}i(s.name,c)}try{return Yr(e,a,{stateAsDeclaration:a.state.isRendering()})}finally{for(const o of n)o.had?a.loopVars.set(o.name,o.prev):a.loopVars.delete(o.name)}}function wt(t){const e=t.hookScope;if(!e)return null;let r=t.hookStore.get(e.instanceKey);return r||(r=[],t.hookStore.set(e.instanceKey,r)),r}function af(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Object.is(t[r],e[r]))return!1;return!0}function nf(t,e,r){const a=wt(e);if(!a)return kt("state",r),[t[0]?M(t[0],e):void 0,()=>{}];const n=e.hookScope.cursor++;let i=a[n];(!i||i.kind!=="state")&&(i={kind:"state",value:t[0]?M(t[0],e):void 0},a[n]=i);const o=i,s=c=>{const u=typeof c=="function"?c(o.value):c;Object.is(u,o.value)||(o.value=u,e.notify?.())};return[o.value,s]}function of(t,e,r){const a=t[0],n=t[1],i=()=>{const m=a?M(a,e):void 0;return typeof m=="function"?m():m},o=wt(e);if(!o)return kt("memo",r),i();const s=e.hookScope.cursor++,c=n?M(n,e):void 0,u=Array.isArray(c)?c:void 0,p=o[s];if(p&&p.kind==="memo"&&u&&p.deps&&af(p.deps,u))return p.value;const d=i();return o[s]={kind:"memo",deps:u,value:d},d}function sf(t,e,r){const a=wt(e);if(!a)return kt("ref",r),{current:t[0]?M(t[0],e):void 0};const n=e.hookScope.cursor++;let i=a[n];return(!i||i.kind!=="ref")&&(i={kind:"ref",box:{current:t[0]?M(t[0],e):void 0}},a[n]=i),i.box}function lf(t,e,r){const a=t[0]?M(t[0],e):void 0,n=wt(e),i=t[1]?M(t[1],e):void 0;if(!n)return kt("reducer",r),[i,()=>{}];const o=e.hookScope.cursor++;let s=n[o];(!s||s.kind!=="reducer")&&(s={kind:"reducer",value:i},n[o]=s);const c=s,u=p=>{if(typeof a!="function")return;const d=a(c.value,p);Object.is(d,c.value)||(c.value=d,e.notify?.())};return[c.value,u]}let Di=0;function cf(t,e,r){const a=t[0]?String(M(t[0],e)):"rui",n=wt(e);if(!n)return kt("id",r),`${a}-${Di+=1}`;const i=e.hookScope.cursor++;let o=n[i];return(!o||o.kind!=="id")&&(o={kind:"id",value:`${a}-${Di+=1}`},n[i]=o),o.value}function uf(t,e,r){const a=[];for(const n of e){if(n.kind==="Spread"){const i=M(n.argument,r);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(M(n,r))}return zi(t.params,t.body,a,r)}let ji=!1;function kt(t,e){ji||(ji=!0,console.error(`[aktion] $${t}(...) was called outside a component render. Hooks may only be called at the top level of a component body or another $hook.`,e))}function Bi(t,e){t.hookStore.delete(e)}function df(t,e){const r=e.stateAliases.map(n=>new Map(n)),a=new Map(e.loopVars);return(...n)=>{const i=new Map(e.loopVars),o=e.stateAliases.slice();e.loopVars.clear();for(const[s,c]of a)e.loopVars.set(s,c);e.stateAliases.length=0;for(const s of r)e.stateAliases.push(s);try{return Ri(t,n,e)}finally{e.loopVars.clear();for(const[s,c]of i)e.loopVars.set(s,c);e.stateAliases.length=0;for(const s of o)e.stateAliases.push(s)}}}function pf(t,e){return(...r)=>({__kind:"UserComponent",decl:t,positional:r,named:{},explicitKey:void 0,source:t.loc})}function mf(t,e){return(...r)=>({__kind:"Component",name:t,args:r,argMeta:r.map(()=>({})),source:void 0})}function ff(t,e,r){return t==="__rui_assign__"?hf(e,r):t==="__rui_postfix__"?bf(e,r):t==="__rui_prefix__"?vf(e,r):t==="__rui_await__"?e[0]?M(e[0],r):void 0:null}function _e(t,e,r){switch(t){case"=":return r;case"+=":return typeof e=="string"||typeof r=="string"?`${e??""}${r??""}`:_(e)+_(r);case"-=":return _(e)-_(r);case"*=":return _(e)*_(r);case"/=":{const a=_(r);return a===0?0:_(e)/a}case"%=":{const a=_(r);return a===0?0:_(e)%a}case"**=":return _(e)**_(r);case"&&=":return e&&r;case"||=":return e||r;case"??=":return e??r;case"&=":return se(e)&se(r);case"|=":return se(e)|se(r);case"^=":return se(e)^se(r);case"<<=":return se(e)<<(Oe(r)&31);case">>=":return se(e)>>(Oe(r)&31);case">>>=":return Oe(e)>>>(Oe(r)&31);default:return r}}function gf(t,e,r){const a=e[0]?M(e[0],r):null;if(typeof a!="function")return null;const n=a,i=e[1]?_(M(e[1],r)):0,o=[];for(let u=2;u<e.length;u+=1)o.push(M(e[u],r));const s=()=>{try{n(...o)}catch(u){console.error(`[aktion] ${t} callback threw`,u)}finally{r.notify?.()}};if(t==="setTimeout"){const u=setTimeout(()=>{r.timers.timeouts.delete(u),s()},i);return r.timers.timeouts.add(u),u}const c=setInterval(s,i);return r.timers.intervals.add(c),c}function hf(t,e){const[r,a,n]=t;if(!r||!a)return null;const i=n&&n.kind==="Literal"?String(n.value??"="):"=",o=M(a,e);if(r.kind==="StateRef"){const s=Ae(e,r.name),c=e.state.get(s),u=_e(i,c,o);return e.state.set(s,u),u}if(r.kind==="Member"){const s=Gt(r,e);if(s){const d=e.state.get(s.name);if(s.path.length>=1&&ti(d)){let b=d;for(let h=0;h<s.path.length-1;h+=1)b=b?.[s.path[h]];if(b&&typeof b=="object"){const h=s.path[s.path.length-1],v=b[h],y=_e(i,v,o);return b[h]=y,e.notify?.(),y}}const m=Xr(d,s.path),g=_e(i,m,o);return e.state.setPath(s.name,s.path,g),g}const c=Ei(r,e);if(c){const d=Xr(e.state.get(c.atom),c.path),m=_e(i,d,o);return e.state.setPath(c.atom,c.path,m),m}const u=M(r.object,e),p=r.computed?r.computed.kind==="Literal"?r.computed.value:null:r.property;if(u&&typeof u=="object"&&p!=null){const d=u[String(p)],m=_e(i,d,o);return u[String(p)]=m,m}return o}if(r.kind==="Identifier"){const s=r.name;if(e.loopVars.has(s)){const p=e.loopVars.get(s),d=_e(i,p,o);return e.loopVars.set(s,d),d}if(e.bindings.has(s)||e.mutableBindings.has(s)){const p=e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)(),d=_e(i,p,o);return e.mutableBindings.set(s,d),d}const c=e.loopVars.get(s),u=_e(i,c,o);return e.loopVars.set(s,u),u}return o}function Xr(t,e){let r=t;for(const a of e){if(r==null)return;if(Array.isArray(r)){const n=Number(a);r=Number.isNaN(n)?void 0:r[n];continue}if(typeof r=="object"){r=r[a];continue}return}return r}function Oi(t,e,r){const[a,n]=t;if(!a)return null;const o=(n&&n.kind==="Literal"?String(n.value??"++"):"++")==="--"?-1:1;if(a.kind==="StateRef"){const s=Ae(e,a.name),c=_(e.state.get(s)),u=c+o;return e.state.set(s,u),r==="prefix"?u:c}if(a.kind==="Member"){const s=Gt(a,e);if(s){const c=_(Xr(e.state.get(s.name),s.path)),u=c+o;return e.state.setPath(s.name,s.path,u),r==="prefix"?u:c}}if(a.kind==="Identifier"){const s=a.name;if(e.loopVars.has(s)){const p=_(e.loopVars.get(s)),d=p+o;return e.loopVars.set(s,d),r==="prefix"?d:p}if(e.bindings.has(s)||e.mutableBindings.has(s)){const p=_(e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)()),d=p+o;return e.mutableBindings.set(s,d),r==="prefix"?d:p}const c=_(e.loopVars.get(s)),u=c+o;return e.loopVars.set(s,u),r==="prefix"?u:c}return null}function bf(t,e){return Oi(t,e,"postfix")}function vf(t,e){return Oi(t,e,"prefix")}function yf(t){if(t.trackedState.add("route"),t.router)return t.router.getPath();if(t.state.has("route")){const e=t.state.get("route");if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"&&"path"in e){const r=e.path;if(typeof r=="string"&&r)return r}}return"/"}function xf(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),n={};if(typeof globalThis<"u"&&globalThis.location){const i=globalThis.location?.search??"";if(i){const o=new URLSearchParams(i.startsWith("?")?i.slice(1):i);for(const[s,c]of o)n[s]=c}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function Jr(t,e){if(t!=null){if(Array.isArray(t)){const r=_i(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=_i(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function _i(t,e){let r;if(typeof t=="number")r=t;else if(typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t)))r=Number(t);else return null;return r<0&&(r=e+r),r<0||r>=e?null:r}function Zr(t,e){if(t!=null){if(Array.isArray(t)){switch(e){case"length":return t.length;case"first":return t[0]??null;case"last":return t.length===0?null:t[t.length-1]}return t.map(r=>{if(r&&typeof r=="object")return r[e]})}if(typeof t=="string"&&e==="length")return t.length;if(typeof t=="object")return t[e]}}function _(t){if(typeof t=="number")return t;if(typeof t=="string"){if(t.trim()==="")return 0;const e=Number(t);return Number.isNaN(e)?0:e}return typeof t=="boolean"&&t?1:0}const wf=new Set(["colors","radius","font"]),kf=new Set(["name","direction"]);function Sf(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const r=t;for(const[a,n]of Object.entries(r))if(n!=null&&!kf.has(a)&&wf.has(a)&&n&&typeof n=="object"&&!Array.isArray(n)){const i=a==="colors"?"color":a;for(const[o,s]of Object.entries(n)){if(s==null)continue;const c=i+$f(o);e[c]=Cf(s)}}return e}function $f(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function Cf(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function Qr(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(typeof t=="object"&&t!==null){const e=t.toString;if(typeof e=="function"&&e!==Object.prototype.toString){const r=e.call(t);if(typeof r=="string")return r}}try{return JSON.stringify(t)}catch{return String(t)}}const Af="__AKTION_DEVTOOLS_HOOK__";function Tf(){return globalThis}function Qt(){return Tf()[Af]}function ea(){const t=Qt();return t!==void 0&&t.active}function ta(t){Qt()?.emit(t)}function Mf(t){Qt()?.unregisterApp(t)}function pe(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Nf(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="emit"}const er="::",Pf=new Map;class Fi{constructor(e){z(this,"mounted",new Map);z(this,"errors",[]);this.options=e}getErrors(){return this.errors}syncEffects(e,r){this.errors=[];const a=new Set(e.map(n=>n.name));for(const n of[...this.mounted.keys()])n.includes(er)||a.has(n)||this.unmount(n);for(const n of e)this.mounted.has(n.name)||this.mount(n.name,n,r,[],Pf)}syncInstanceEffects(e,r,a){const n=`${e}${er}`,i=new Set(r.map(o=>`${n}${o.decl.name}`));for(const o of[...this.mounted.keys()])o.startsWith(n)&&(i.has(o)||this.unmount(o));for(const o of r){const s=`${n}${o.decl.name}`,c=this.mounted.get(s);if(c){c.capturedLoopVars=o.capturedLoopVars;continue}this.mount(s,o.decl,a,o.capturedAliases,o.capturedLoopVars)}}unmountInstance(e){const r=`${e}${er}`;for(const a of[...this.mounted.keys()])a.startsWith(r)&&this.unmount(a)}reset(){for(const e of[...this.mounted.keys()])this.unmount(e);this.errors=[]}mount(e,r,a,n,i){const o={decl:r,cleanups:[],intervals:[],unsubscribers:[],ctxRef:a,capturedAliases:n,capturedLoopVars:i};this.mounted.set(e,o),this.emitEffect(e,r,"mount","mount");const c=If(m=>{const g=o.cleanups.splice(0);if(g.length>0){for(const h of g)try{h()}catch(v){Hi(e,v)}this.emitEffect(e,r,"cleanup",m,{cleanups:g.length})}const b=pe();try{Ui(r,a(),o,this.options),this.emitEffect(e,r,"run",m,{duration:pe()-b})}catch(h){this.emitEffect(e,r,"error",m,{duration:pe()-b,error:h instanceof Error?h.message:String(h)}),console.error(`[aktion] effect "${e}" failed`,h)}finally{this.options.notify()}},r.rateLimit,o);let u=!1,p=!1,d=!1;for(const m of r.triggers)switch(m.kind){case"lifecycle":m.name==="mount"&&(u=!0),m.name==="unmount"&&(p=!0);break;case"every":{d=!0;const g=`every(${m.intervalMs})`,b=setInterval(()=>c(g),m.intervalMs);o.intervals.push(b);break}case"state":{const g=zf(m.name,n),b=`state:${m.name}`,h=this.options.state.subscribe(v=>{Lr(v,g)&&c(b)});o.unsubscribers.push(h);break}}(r.triggers.length===0||u||!d&&!p&&r.triggers.every(m=>m.kind==="state"))&&c("mount")}emitEffect(e,r,a,n,i={}){const o=this.options.onEffectEvent;if(!o||!ea())return;const s=e.lastIndexOf(er);o({effectKey:e,label:Lf(r.name),instanceKey:s>=0?e.slice(0,s):null,phase:a,reason:n,triggers:Rf(r),...i})}unmount(e){const r=this.mounted.get(e);if(!r)return;this.mounted.delete(e);for(const n of r.intervals)clearInterval(n);for(const n of r.unsubscribers)try{n()}catch{}if(r.cleanups.length>0){const n=r.cleanups.length;for(const i of r.cleanups)try{i()}catch(o){Hi(e,o)}this.emitEffect(e,r.decl,"cleanup","unmount",{cleanups:n})}if(r.decl.triggers.some(n=>n.kind==="lifecycle"&&n.name==="unmount")){const n=pe();try{Ui(r.decl,r.ctxRef(),r,this.options),this.emitEffect(e,r.decl,"run","unmount",{duration:pe()-n})}catch(i){this.emitEffect(e,r.decl,"error","unmount",{error:i instanceof Error?i.message:String(i)}),console.error(`[aktion] effect "${e}" unmount body threw`,i)}}this.emitEffect(e,r.decl,"unmount","unmount")}}function If(t,e,r){if(!e||e.ms<=0)return t;if(e.kind==="debounce"){let o=null;const s=()=>{o&&(clearTimeout(o),o=null)};return r.cleanups.push(s),c=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(c)},e.ms)}}let a=0,n=null,i="";return r.cleanups.push(()=>{n&&(clearTimeout(n),n=null)}),o=>{const s=Date.now(),c=s-a;c>=e.ms?(a=s,t(o)):n?i=o:(i=o,n=setTimeout(()=>{n=null,a=Date.now(),t(i)},e.ms-c))}}function Ui(t,e,r,a){const n=r.capturedAliases.length>0?e.stateAliases.slice():null;if(n){e.stateAliases.length=0;for(const s of r.capturedAliases)e.stateAliases.push(new Map(s))}const i=r.capturedLoopVars.size>0?new Map(e.loopVars):null;if(i){e.loopVars.clear();for(const[s,c]of r.capturedLoopVars)e.loopVars.set(s,c)}const o=e.cleanupSink;e.cleanupSink=s=>{r.cleanups.push(s)};try{for(const s of t.body.body)Ef(s,e,r,a)}finally{if(e.cleanupSink=o,n){e.stateAliases.length=0;for(const s of n)e.stateAliases.push(s)}if(i){e.loopVars.clear();for(const[s,c]of i)e.loopVars.set(s,c)}}}function Ef(t,e,r,a){switch(t.kind){case"ExpressionStatement":{const n=t.expression;if(n.kind==="Call"&&n.callee==="cleanup"){const i=n.arguments[0]?M(n.arguments[0],e):null;typeof i=="function"&&r.cleanups.push(i);return}if(Nf(n)){const i=n.arguments,o=i[0]?String(M(i[0],e)):"",s=i[1]?M(i[1],e):void 0;a.onEmit?.(o,s);return}return M(n,e)}case"Assignment":{const n=M(t.expression,e);if(t.identifier&&t.identifier!==""){const i=Ae(e,t.identifier);e.state.set(i,n)}return n}case"IfStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"SwitchStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"ThrowStatement":case"DestructureStatement":Gr(t,e);return;default:return}}function Hi(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function Lf(t){const e=/^__effect_L(\d+)_C(\d+)$/.exec(t);return e?`effect @ L${e[1]}:C${e[2]}`:t}function Rf(t){const e=t.triggers.map(r=>r.kind==="lifecycle"?`"${r.name}"`:r.kind==="every"?`every(${r.intervalMs})`:`$${r.name}`);return t.rateLimit&&e.push(`${t.rateLimit.kind}(${t.rateLimit.ms})`),e.length>0?`[${e.join(", ")}]`:"[mount]"}function zf(t,e){const r=t.indexOf("."),a=r<0?t:t.slice(0,r),n=r<0?"":t.slice(r);for(let i=e.length-1;i>=0;i-=1){const o=e[i].get(a);if(o!==void 0)return o+n}return t}const Df="$";function Vi(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Object.is(t[r],e[r]))return!1;return!0}function Wi(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(e,n)||!Object.is(t[n],e[n]))return!1;return!0}class qi{constructor(e){z(this,"instanceStates",new Map);z(this,"instanceDisposers",new Map);z(this,"aliveInstances",new Set);z(this,"instancesWithEffects",new Set);z(this,"instancesWithHooks",new Set);z(this,"memoCache",new Map);z(this,"changedPaths",new Set);z(this,"memoEnabled",!1);z(this,"profiling",!1);z(this,"profilerRecords",[]);z(this,"profiledInstances",new Set);this.options=e}setProfiling(e){this.profiling=e,e||(this.profilerRecords=[],this.profiledInstances.clear())}drainProfilerRecords(){const e=this.profilerRecords;return this.profilerRecords=[],e}depthOf(e){let r=0;for(let a=0;a<e.length;a+=1)e[a]==="#"&&(r+=1);return r}setLibrary(e){this.options={...this.options,library:e}}reset(){for(const e of this.instanceDisposers.values())for(const r of e.values())this.safeDispose(r);if(this.instanceDisposers.clear(),this.instanceStates.clear(),this.memoCache.clear(),this.options.unmountInstanceEffects)for(const e of this.instancesWithEffects)try{this.options.unmountInstanceEffects(e)}catch(r){console.error(`[aktion] unmountInstanceEffects threw for ${e}`,r)}if(this.instancesWithEffects.clear(),this.options.unmountInstanceHooks)for(const e of this.instancesWithHooks)try{this.options.unmountInstanceHooks(e)}catch(r){console.error(`[aktion] unmountInstanceHooks threw for ${e}`,r)}this.instancesWithHooks.clear(),this.aliveInstances=new Set,this.profilerRecords=[],this.profiledInstances.clear()}beginRender(e={}){this.aliveInstances=new Set,this.changedPaths=e.changedPaths??new Set,this.memoEnabled=e.memoize??!1,this.profiling&&(this.profilerRecords=[])}endRender(){const e=this.aliveInstances;for(const r of[...this.instanceStates.keys()]){const a=r.lastIndexOf("::"),n=a===-1?r:r.slice(0,a);e.has(n)||this.instanceStates.delete(r)}for(const[r,a]of[...this.instanceDisposers.entries()])if(!e.has(r)){for(const n of a.values())this.safeDispose(n);this.instanceDisposers.delete(r)}if(this.options.unmountInstanceEffects){for(const r of[...this.instancesWithEffects])if(!e.has(r)){try{this.options.unmountInstanceEffects(r)}catch(a){console.error(`[aktion] unmountInstanceEffects threw for ${r}`,a)}this.instancesWithEffects.delete(r)}}if(this.options.unmountInstanceHooks){for(const r of[...this.instancesWithHooks])if(!e.has(r)){try{this.options.unmountInstanceHooks(r)}catch(a){console.error(`[aktion] unmountInstanceHooks threw for ${r}`,a)}this.instancesWithHooks.delete(r)}}for(const r of[...this.memoCache.keys()])e.has(r)||this.memoCache.delete(r);if(this.profiling)for(const r of[...this.profiledInstances])e.has(r)||this.profiledInstances.delete(r)}profile(e,r,a,n,i,o,s){this.profilerRecords.push({instanceKey:e,name:r,kind:a,phase:n,selfTime:i,depth:this.depthOf(e),reason:o,deps:s?[...s]:void 0}),this.profiledInstances.add(e)}safeDispose(e){try{e()}catch(r){console.error("[aktion] disposer threw",r)}}writeState(e,r){const a=e.indexOf(".");if(a<0){this.options.state.set(e,r);return}const n=e.slice(0,a),i=e.slice(a+1).split(".");this.options.state.setPath(n,i,r)}render(e){return this.renderAt(e,Df)}renderAt(e,r){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const a=document.createDocumentFragment();return e.forEach((n,i)=>{a.append(this.renderAt(n,`${r}/${i}`))}),a}return wi(e)?this.renderUserComponent(e,r):xi(e)?this.renderComponent(e,r):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?document.createTextNode(String(e)):document.createTextNode("")}renderUserComponent(e,r){const a=this.options.evaluationContext;if(!a){const d=document.createElement("div");return d.className="rui-unknown-component",d.textContent=`[unknown component: ${e.decl.name}]`,d}const n=a(),i=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,o=`${r}#${e.decl.name}${i}`;this.aliveInstances.add(o);const s=this.memoCache.get(o);if(this.memoEnabled&&s&&Vi(e.positional,s.positional)&&Wi(e.named,s.named)&&!ft(this.changedPaths,s.deps)){const d=n.trackedState;for(const m of s.deps)d.add(m);this.profiling&&this.profile(o,e.decl.name,"user","memo",0,"memoized (args + deps unchanged)",s.deps),Hr(n,e.decl.name);try{return this.renderAt(s.value,o)}finally{Vr(n)}}const c=this.profiledInstances.has(o)?"update":"mount",u=s?Vi(e.positional,s.positional)?Wi(e.named,s.named)?ft(this.changedPaths,s.deps)?"state dependency changed":"full render":"named args changed":"positional args changed":c==="mount"?"initial mount":"no memo (full render)",p=this.profiling?pe():0;Hr(n,e.decl.name);try{const d=n.trackedState,m=new Set;n.trackedState=m;let g;try{g=Li(e,n,o)}finally{n.trackedState=d;for(const y of m)d.add(y)}const{value:b,effects:h,hooks:v}=g;return this.profiling&&this.profile(o,e.decl.name,"user",c,pe()-p,u,m),this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(o,h,a),h.length>0&&this.instancesWithEffects.add(o)),v>0&&this.instancesWithHooks.add(o),this.memoCache.set(o,{positional:e.positional,named:e.named,deps:m,value:b}),this.renderAt(b,o)}finally{Vr(n)}}renderComponent(e,r){const a=Ee(this.options.library,e.name);if(!a){const d=document.createElement("div");return d.className="rui-unknown-component",d.textContent=`[unknown component: ${e.name}]`,d}const n=Ya(a,e.args),i=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,o=`${r}#${e.name}${i}`;this.aliveInstances.add(o);let s=0;const c={renderNode:d=>this.renderAt(d,`${o}>${s++}`),invoke:(d,...m)=>{if(typeof d=="function")try{const g=d(...m);g&&typeof g.then=="function"&&g.catch(b=>{console.error("[aktion] handler rejected",b)})}catch(g){console.error("[aktion] handler threw",g)}},setState:(d,m)=>{this.writeState(d,m)},resetState:(...d)=>{this.options.state.reset(...d)},sendToAssistant:d=>{this.options.onAssistantMessage?.(d)},openUrl:d=>{const m=tt(d,"#"),g=this.options.onOpenUrl;g?g(m):m!=="#"&&typeof window<"u"&&window.open(m,"_blank","noopener,noreferrer")},bindState:(d,m,g)=>{const h=`on${g?.event??this.eventFor(d)}`,v=g?.getValue??this.defaultValueGetter(d);d[h]=y=>{const x=y.currentTarget??y.target??d;this.writeState(m,v(x))}},useInstanceState:(d,m)=>{const g=`${o}::${d}`;return this.instanceStates.has(g)||this.instanceStates.set(g,m),{get:()=>this.instanceStates.get(g),set:b=>{this.instanceStates.set(g,b)}}},registerDisposer:(d,m)=>{let g=this.instanceDisposers.get(o);g||(g=new Map,this.instanceDisposers.set(o,g));const b=m??`__anon::${g.size}`,h=g.get(b);h&&h!==d&&this.safeDispose(h),g.set(b,d)},router:this.options.router},u=this.profiledInstances.has(o)?"update":"mount",p=this.profiling?pe():0;try{const d=a.render(e,n,c);return this.profiling&&this.profile(o,e.name,"library",u,pe()-p,u==="mount"?"mounted":"re-rendered"),d}catch(d){this.profiling&&this.profile(o,e.name,"library",u,pe()-p,"render threw"),console.error(`[aktion] failed to render ${a.name}`,d);const m=document.createElement("div");return m.className="rui-render-error",m.textContent=`[render error in ${a.name}]`,m}}eventFor(e){return e instanceof HTMLSelectElement||e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?"change":"input"}defaultValueGetter(e){return e instanceof HTMLInputElement&&e.type==="checkbox"?r=>r.checked:e instanceof HTMLInputElement&&e.type==="radio"?r=>r.value:e instanceof HTMLInputElement&&e.type==="number"?r=>{const a=r.value;if(a==="")return null;const n=Number(a);return Number.isFinite(n)?n:null}:e instanceof HTMLInputElement&&e.type==="range"?r=>Number(r.value):r=>r.value}}const jf=["onclick","ondblclick","oncontextmenu","onmousedown","onmouseup","onmousemove","onmouseenter","onmouseleave","onmouseover","onmouseout","onpointerdown","onpointerup","onpointermove","onpointerenter","onpointerleave","onpointercancel","onscroll","onwheel","ondrag","ondragstart","ondragend","ondragenter","ondragleave","ondragover","ondrop","ontouchstart","ontouchmove","ontouchend","ontouchcancel","oninput","onchange","onsubmit","onreset","oninvalid","ontoggle","onkeydown","onkeyup","onkeypress","onfocus","onblur","onerror"];function Bf(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];Xi(t,r)}function Ki(t,e){if(t===e)return t;if(t.nodeType!==e.nodeType)return Gi(t,e);if(t.nodeType===Node.TEXT_NODE)return t.textContent!==e.textContent&&(t.textContent=e.textContent),t;if(t.nodeType!==Node.ELEMENT_NODE)return t;const r=t,a=e;return r.tagName!==a.tagName?Gi(r,a):(Of(r,a),r)}function Gi(t,e){return t.parentNode?.replaceChild(e,t),e}function Of(t,e){_f(t,e),Ff(t,e),Xi(t,Array.from(e.childNodes)),Uf(t,e)}function _f(t,e){const r=t.attributes;for(let n=r.length-1;n>=0;n-=1){const i=r[n];e.hasAttribute(i.name)||i.name==="open"&&t.tagName==="DETAILS"||t.removeAttribute(i.name)}const a=e.attributes;for(let n=0;n<a.length;n+=1){const i=a[n];t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}}function Ff(t,e){for(const r of jf){const a=e[r],n=t[r];a!==n&&(t[r]=a??null)}}function Uf(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){Hf(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){Vf(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){t.value!==e.value&&(t.value=e.value);return}}function Hf(t,e){if(t.type==="checkbox"||t.type==="radio"){const a=e.hasAttribute("checked")||e.checked;t.checked!==a&&(t.checked=a);return}const r=e.getAttribute("value")??e.value??"";t.value!==r&&Yi(t,r)}function Vf(t,e){const r=e.value??e.textContent??"";t.value!==r&&Yi(t,r)}function Yi(t,e){if(!Wf(t)){t.value=e;return}let r=null,a=null;try{r=t.selectionStart,a=t.selectionEnd}catch{}const n=t.value.length;if(t.value=e,r==null||a==null)return;const i=r>=n&&a>=n,o=i?e.length:Math.min(r,e.length),s=i?e.length:Math.min(a,e.length);try{t.setSelectionRange(o,s)}catch{}}function Wf(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function Xi(t,e){const r=new Map;for(const n of Array.from(t.childNodes)){const i=ra(n);i&&r.set(i,n)}let a=0;for(const n of e){const i=t.childNodes[a]??null,o=ra(n);if(o&&r.has(o)){const c=r.get(o);r.delete(o),c!==i&&t.insertBefore(c,i),Ki(c,n),a+=1;continue}if(!i){t.appendChild(n),a+=1;continue}const s=ra(i);if(s&&(!o||s!==o)){t.insertBefore(n,i),a+=1;continue}Ki(i,n),a+=1}for(;t.childNodes.length>e.length;){const n=t.childNodes[t.childNodes.length-1];t.removeChild(n)}}function ra(t){if(t.nodeType!==Node.ELEMENT_NODE)return null;const e=t;if(e.id)return`#${e.id}`;const r=e.getAttribute("data-rui-key");return r?`@${r}`:null}function aa(t,e={}){return e.mode==="chat"?Gf(t,e):Kf(t,e)}function qf(t){return tr(t)}function Kf(t,e){const r=e.bindings??!0,a=e.toolCalls??!0,n=[];n.push(Yf(e.preamble)),n.push(Xf()),n.push(Jf()),r&&n.push(Zf()),n.push(Qf()),n.push(eg()),a&&n.push(tg()),n.push(rg()),n.push(ag()),n.push(ng()),n.push(ig()),n.push(og()),n.push(sg()),n.push(lg()),n.push(cg(t)),e.inlineMode&&n.push(ug()),e.editMode&&n.push(dg()),e.tools&&e.tools.length>0&&n.push($g(e.tools)),e.toolExamples&&e.toolExamples.length>0&&n.push(na("Endpoint examples",e.toolExamples));const i=e.examples??mg();return i.length>0&&n.push(na("Examples",i)),e.additionalRules&&e.additionalRules.length>0&&n.push(Ji(e.additionalRules)),n.push(pg()),n.join(`
|
|
100
100
|
|
|
101
101
|
`).trim()+`
|
|
102
|
-
`}function
|
|
102
|
+
`}function Gf(t,e){const r=[];r.push(gg(e.preamble)),r.push(hg()),r.push(bg(t)),r.push(vg()),e.tools&&e.tools.length>0&&r.push(xg(e.tools));const a=e.examples??wg();return a.length>0&&r.push(na("Examples",a)),e.additionalRules&&e.additionalRules.length>0&&r.push(Ji(e.additionalRules)),r.push(yg()),r.push(kg()),r.push(Sg()),r.join(`
|
|
103
103
|
|
|
104
104
|
`).trim()+`
|
|
105
|
-
`}function
|
|
105
|
+
`}function Yf(t){return`${t?.trim()||"You are a UI engineer building complete, working apps in Aktion — a declarative language that is a strict subset of JavaScript: every program is valid JS, and the runtime adds reactivity on top. Respond ONLY in Aktion — no prose, JSON, markdown, or HTML."}
|
|
106
106
|
|
|
107
|
-
Register the UI root with \`$app(...)\` on the first line. Pass it one node (\`$app(Component())\`), an array (\`$app([Component1(), Component2()])\`), or variadic nodes (\`$app(Component1(), Component2())\`). Wrap a dashboard/app in \`AppShell\` (left sidebar + topbar); build a website or marketing page from a top \`Navbar\` + stacked sections — never an \`AppShell\`. References resolve across the whole program, so call \`$app(...)\` first and let the rest stream in below it. There should be only one \`$app(...)\` in the program, as the runtime treats it as the UI root.`}function Ff(){return'## Core syntax\n\nA program is a flat list of `name = expression` statements, one per line (newlines end statements; semicolons optional).\n\n```\n$app(Column([header, kpis, table])) // UI root — always first\nheader = PageHeader("Sales", { subtitle: "Q4 2026" })\n$count = 0 // reactive atom — the \'$\' prefix is the contract\nfunction Counter(label) { return Text(`${label}: ${$count}`) } // component (returns a tree)\nfunction inc() { $count += 1 } // action (no return — runs for side effects)\n$effect(() => $console.log($count), [$count]) // declarative side effect\n```\n\n### Three kinds of name\n- `name = value` — plain binding, captured once (not reactive).\n- `$name = value` — reactive atom: reading subscribes, writing notifies.\n- `function name(...)` — declares a component AND an action of that name. First-letter case is NOT significant (`Card`/`card`, `SaveOrder`/`saveOrder`); same for arrow bindings (`row = item => Row(...)`).\n\n### Two rules, broken constantly — always check\n1. **Invoke components with parentheses.** A component is a function; the bare name is just its value. Render it by calling it, even with no args: `$app(MyApp())` not `$app(MyApp)`; `Column([Header(), Body()])` not `Column([Header, Body])`. (Exception: passing a component as a callback, e.g. `render: UserCard`.)\n2. **One positional argument max** (the trailing-object rule): each call takes at most one bare positional arg; all other props go in a trailing `{ }` object.\n\n```\nButton("Save", { variant: "primary", loading: $isSaving })\nStatCard("Revenue", { value: "$48k", trend: "up", delta: "+12%" })\nRow([Card1(), Card2()], { gap: "m" })\n```\n\n`Button("Save", "primary")` is a schema error — use the named-prop form. Any call also accepts `{ key: ... }` to pin per-instance state across reorders.\n\n### Reserved top-level names\n- `$app(...)` — registers the UI root (REQUIRED).\n- `$theme({...})` — optional brand override (written as a bare statement).\n- `route` — the reactive router handle (`route.path`, `route.params`, `route.navigate("/x")`); never declare it yourself.'}function Uf(){return'## JavaScript is fully supported\n\nAktion *is* JavaScript — every standard feature works inside expressions, action bodies, effect callbacks, and lambdas. Use whatever is clearest.\n\n### Ways to produce the UI\nThere is no single required shape — compose however the content suggests, and mix these freely:\n- **Inline in `$app(...)`** — `$app(Column([Hero(), Features(), Footer()]))` for a self-contained tree.\n- **Named statements** — pull pieces into `name = ...` bindings and reference them; they hoist and stream in independently.\n- **`.map` / `.filter` over data** — turn arrays into nodes: `rows = $items.map(i => Row(i))`.\n- **`function` components** — factor reusable or parameterised UI into components; invoke them with `()`.\n- **`$router({...})` pages** — split a multi-page app into route arms.\n\n### In expressions (right of `=`) — value-producing JS only\n```\nbanner = $error ? Banner($error, { tone: "danger" }) : null // ternary\nrows = $todos.filter(t => !t.done).map(t => TodoRow(t)) // map / filter / reduce\ntotal = $cart.reduce((sum, i) => sum + i.price, 0)\nmerged = { ...$base, status: "done" } // spread / destructuring\nname = $user?.profile?.name ?? "Guest" // optional chain / nullish\ntitle = `${rows.length} ${$util.plural(rows.length, "result", "results")}` // template literal\n```\n`if` / `switch` / `for` / `while` / `try` are statements — they can\'t sit on the right of `=`. Use a ternary, an array method, or wrap them in a function and call it.\n\n### In action / effect / lambda bodies — full statement surface\n`if`/`else`, `switch`, every `for` and `while`, `try`/`catch`/`finally`, `throw`, `return`, plus all assignment operators (`= += -= *= /= ??= ++ --`) against `$atoms` and member chains (`$user.name = "Alex"`).\n\n```\nfunction submit(payload) {\n if (!payload.email) return\n for (let tag of payload.tags) $tags = [...$tags, tag]\n $emit("submitted", { id: payload.id })\n}\n```\n\n### Lambdas, continuations, comments, timers\n- Arrow functions in every form: `() => expr`, `x => expr`, `(a, b = 0) => { ...; return ... }`, `(...args) => ...`.\n- A leading operator (`.`, `?.`, `&&`, `??`, `?`/`:`, arithmetic) continues an expression onto the next line.\n- Comments: `// line` and `/* block */` only.\n- `setTimeout` / `setInterval` / `clearTimeout` / `clearInterval` work and are torn down on re-plan — create them in an `$effect` and clear them in its `cleanup`, or prefer `$effect(..., ["every(1000)"])` for simple repeats.\n- Every JavaScript global resolves by name (see *Built-in globals*).'}function Hf(){return'## Reactive State\n\nThe `$` sigil is the only thing that makes a binding reactive; `let`/`const`/`var` are optional and don\'t affect reactivity.\n\n```\n$count = 0\n$user = { name: "Ada", role: "Engineer" }\n```\n\n- **Read** `$name` anywhere — it auto-subscribes whoever reads it (component, derived value, effect).\n- **Write** `$name = ...` (and `+= -= ??= ++ --`) only from event handlers, effects, and lambdas — never while building the UI. Member writes (`$user.name = "Alex"`) update immutably so subscribers see a fresh reference.\n- **Never write reactive state in render position.** A write that runs while the UI is built loops; the runtime applies it but skips the re-render and warns. Hold component-local state by declaring it at the top of a component body (set-once per instance) or with the `$state` hook.\n\n### Fine-grained reactivity (path-level)\nSubscriptions track the exact **path** you read. Reading `$user.name` subscribes to `user.name` alone — writing `$user.role` won\'t recompute it, but replacing `$user` will; effect deps work the same (`$effect(..., [$user.name])`). Prefer reading the precise field for the tightest updates. A component re-executes only when its own inputs change — its args or a `$` path its body read — like `React.memo`, but automatic. Args compare shallowly, so hoist inline-lambda props to a stable binding to avoid needless child re-renders.\n\n### Per-instance state\n`$name = value` inside a function body is per-instance when the function renders as a component — two `Counter()`s each own their `$count`. Add `{ key: id }` to keep state attached when siblings reorder.\n\n### Hooks\nFor composable local state, use hooks — a function whose name starts with `$`, called only at the top level of a component (or another hook) in a stable order:\n- `$state(initial)` → `[value, setValue]` (like `useState`; `setValue(prev => next)` supported, `initial` runs once).\n- `$memo(() => value, [deps])` → a cached value (like `useMemo`).\n- `$ref(initial)` → a stable `{ current }` box (like `useRef`; writing `.current` does NOT re-render — for DOM nodes, timer ids, previous values).\n- `$reducer((state, action) => next, initial)` → `[state, dispatch]` (like `useReducer`; the clean way to manage many related transitions).\n- `$id(prefix?)` → a stable unique id per instance (like `useId`; for `for`/`aria-*` wiring).\n- `function $name(...)` declares a custom hook composing the built-ins.\n\n```\nfunction Counter() {\n const [count, setCount] = $state(0)\n const label = $memo(() => `Count: ${count}`, [count])\n return Stack([Text(label), Button("+1", { onClick: () => setCount(c => c + 1) })])\n}\n```\n\n### Two-way binding\nPass a `$variable` (or member chain — `value: $form.email`) as the value prop of any input/select/checkbox/switch/slider and the runtime wires the change handler automatically; add `onChange: v => ...` for an extra side effect.\n\n```\n$draft = ""\nfield = Input("draft", { value: $draft })\n```\n\n### Computed values\nNo separate "computed" tier — just compute. Every `$` reference in an expression auto-tracks: `$open = $todos.filter(t => !t.done)`.\n\n### Global stores — `$store({...})`\nFor app-wide state without prop-drilling, declare a store. Non-function entries are reactive state; function entries are methods that receive the store handle `s` first. Read `store.field` (fine-grained) and call `store.method(args)`.\n\n```\ncart = $store({\n items: [],\n total: (s) => $util.sum(s.items.map(i => i.price)), // → cart.total()\n add: (s, item) => { s.items = [...s.items, item] }, // → cart.add(item)\n})\nfunction CartBadge() { return Badge(`${cart.items.length} items`) }\n```\n\nUse a store for shared state; use a component\'s local `$state` / `$name` for state one component owns.'}function Vf(){return'## Components & Actions\n\nA `function` declaration is both a **component** (call it in render position → its return value renders) and an **action** (call it from an event handler → its body runs). Name case is not significant, and a function with no `return` renders nothing.\n\n### Components\n```\nfunction UserCard(user, { tone = "default" } = {}) {\n return Card([\n Avatar(user.name, { size: "md" }),\n Text(user.name, { variant: "large-heavy" }),\n Badge(tone, { tone })\n ])\n}\n$app(Column([UserCard($currentUser), UserCard($other, { tone: "primary" })]))\n```\n\n- The positional argument lands in the component\'s first parameter (the `children` slot for container-style components).\n- User components shadow built-ins of the same name — wrap a library component to add telemetry or styling.\n- Use a lambda (`row = item => Row(item)`) for one-off helpers that don\'t need a named component.\n\n### Actions\nA `function` whose body runs for side effects is an action — use it as a handler (`onClick: save`) or call it for its result. `return` is optional; the full JS statement surface applies. Wrap optimistic writes in `$optimistic(() => { … })` to snapshot state and auto-roll-back if the callback throws (or its promise rejects).\n\n```\nfunction save(item) {\n $items = [...$items, item]\n $save = $http({ url: "https://api.example.com/save", method: "POST", body: { item } })\n $emit("saved", { id: item.id })\n}\nfunction addTodo(text) {\n $optimistic(() => {\n $todos = [...$todos, { id: $todos.length + 1, text }] // optimistic write\n if (text == "") throw new Error("empty") // → rolls $todos back\n })\n}\nsaveBtn = Button("Save", { onClick: save })\nresetBtn = Button("Reset", { onClick: () => { $count = 0; $message = "" } })\n```\n\n### `$emit("name", { detail })`\nFrom any action / effect / lambda, `$emit` dispatches a `CustomEvent` on the host `<aktion-app>` (listen with `el.addEventListener`). Reserved names: `assistant-message`, `error`, `route-change`.'}function Wf(){return'## Effects — Declarative side effects\n\n`$effect(() => { ... }, [...deps])` runs side effects. Dep entries: `$atom` (re-run on change), `"mount"` / `"unmount"` (once), `"every(N)"` (every N ms), `"debounce(N)"` / `"throttle(N)"` (trailing-edge rate limit). No second argument ≡ `["mount"]`.\n\nTop-level effects mount on parse and tear down on the next response; effects inside a component mount per-instance and tear down — running their `cleanup(fn)` — when the instance leaves the tree.\n\n```\n$effect(() => {\n $results = $http({ url: "https://api.example.com/search", query: { q: $term } })\n}, [$term, "debounce(250)"])\n\n$effect(() => {\n const onKey = e => { if (e.key == "/") $palette = true }\n document.addEventListener("keydown", onKey)\n cleanup(() => document.removeEventListener("keydown", onKey))\n}, ["mount"])\n```'}function qf(){return'## Data — `$http({...})`\n\n`$http({ ... })` is the only HTTP primitive. Each call is self-contained: pass an absolute `url`, optional `method` (default `GET`), `query` (serialised into the URL), `headers`, `body` (JSON-encoded automatically), and any `fetch` option. No host-wide defaults.\n\n```\n$orders = $http({ url: `https://api.example.com/users/${$userId}/orders`, query: { limit: 5 } })\n```\n\nIt fires once when the binding mounts and exposes a reactive bag:\n```\n$orders.data $orders.error $orders.status $orders.loading\n$orders.headers $orders.lastUpdated\n$orders.refetch() $orders.cancel() $orders.onDone = fn\n```\n\nRe-run with `.refetch()`, or wrap the call in `$effect(..., [$dep])` to re-issue when a dep changes. After a write, refresh a list from the write\'s `onDone` (fires on every settle — the initial load and each refetch):\n\n```\nfunction saveOrder(payload) {\n $save = $http({ url: "https://api.example.com/orders", method: "POST", body: payload })\n $save.onDone = () => $orders.refetch()\n}\n```\n\nBranch on resource state with `Async`:\n```\nview = Async($orders, {\n loading: LoadingState("Loading orders…"),\n error: ErrorState("Couldn\'t fetch orders"),\n empty: EmptyState("No orders yet"),\n data: Table([Col("Item", $orders.data.title), Col("Total", $orders.data.total, { format: "currency" })])\n})\n```\n\n### `$query({...})` and `$mutation({...})`\nSame config shape as `$http`, for two common needs:\n- `$query({ url, key?, ttl? })` — a **cached, deduplicated** read. Identical queries (same `key`, or same method+url+query+body) share one in-flight request and one cached bag, so calling it from several components fetches once. Pass `ttl` (ms) to auto-refetch stale data. Same bag as `$http` (`.data`/`.loading`/`.error`/`.refetch()`).\n- `$mutation({ url, method? })` — a **deferred** write that fires only when you call `.mutate(overrides?)`, not on render (method defaults to `POST`). Assign it to an atom, then trigger it from a handler:\n```\n$save = $mutation({ url: "https://api.example.com/orders" })\n$save.onDone = () => $orders.refetch()\n...\nButton("Save", { onClick: () => $save.mutate({ body: { item: $item } }) })\n```\n`.mutate()` resolves with the response body; the bag exposes `.loading`/`.error`/`.data` plus `.reset()`.'}function Kf(){return'## Routing\n\n`$router({ ... })` is a plain function call — assign it and drop the result into your page shell.\n\n```\npages = $router({\n "/": Dashboard(),\n "/orders/:id": OrderDetail({ id: params.id }),\n "/docs/*": Docs({ rest: params._ }),\n default: NotFound()\n})\n$app(AppShell(MainSidebar(), pages)) // app/dashboard shell\n```\n\n- **Pick the shell for the surface.** `AppShell(Sidebar(...), pages)` for an app/dashboard (left sidebar + optional topbar); a top `Navbar(...)` above the pages inside a `Column` for a website / marketing / docs layout (no sidebar) — never wrap a website in `AppShell`. The router result is just a node, so it drops into either.\n- Patterns: literal, `:param` (read `params.id`), trailing `*` (read `params._`), and `default:` for the catch-all (unknown paths render `null` without it).\n- The read-only `route` handle: `route.path`, `route.params.x`, `route.query.tab`; navigate with `route.navigate("/path")` from an action/effect.\n- `NavLink(label, { to, exact?, icon? })` and `SidebarItem(label, { to, icon?, badge? })` derive active state from `route.path`. Never declare `route` yourself.'}function Gf(){return'## Built-in globals — `storage`, `console` & `$toast`\n\nAlways in scope, lowercase, no imports.\n\n```\n$storage.set("name", "John"); $name = $storage.get("name"); $storage.remove("name")\n$storage.session.set("draft", $draft)\n$storage.cookies.set("user", "John", { expires: 7, path: "/" })\n$console.log("Hello", $user)\n```\n\nNon-string values JSON-roundtrip; missing keys return `null`. Beyond these, every JavaScript global resolves by name — `Math`, `JSON`, `Date`, `crypto`, `fetch`, `URL`, `navigator`, `window`, `document`, dialogs like `confirm`, … — and your declarations and components shadow same-named globals. Prefer reactive `$http({...})` over raw `fetch` for UI data, and keep timers/listeners inside `$effect` so they\'re cleaned up.\n\n```\nfunction copyLink() { navigator.clipboard.writeText(window.location.href); $toast.show("Copied", { tone: "success" }) }\nid = crypto.randomUUID()\n```\n\n### `$toast` — imperative notifications\nInstead of hand-managing a `$toasts = [...]` array, use the reserved `$toast` namespace. `$toast.show(message, { tone?, title?, duration? })` appends a toast (auto-dismisses after `duration` ms, default 4000; pass `0` to keep it). Shortcuts: `$toast.success/.error/.info/.warning`. Remove with `$toast.dismiss(id)` / `$toast.clear()`. Render the reactive `$toast.items` list:\n\n```\nfunction save() { $save = $http({ url, method: "POST", body }); $save.onDone = () => $toast.success("Saved") }\ntoaster = Toasts(map($toast.items, t => Toast({ title: t.title, message: t.message, tone: t.tone, onClose: () => $toast.dismiss(t.id) })))\n```'}function Yf(){return'## Behaviour wrappers\n\nThese attach behaviour or styling to ANY node via `display: contents` (the visual tree is unchanged):\n- `OnClick(child, { onClick, disabled?, stopPropagation? })` — pointer + keyboard activatable. (Don\'t wrap `Button` — it already has `onClick`; use this for clickable cards / list rows.)\n- `OnMouse(child, { enter?, leave?, move?, down?, up?, drag?, drop?, dragOver?, ... })` — pass only the events you need.\n- `OnKeyboard(child, { onKeyDown?, onKeyUp?, focusable? })` and `OnFocus(child, { onFocus?, onBlur? })`.\n- `OnIntersect(child, { onEnter?, onLeave?, threshold?, once? })` — IntersectionObserver (lazy-load, infinite scroll).\n- `OnMount(child, { onMount?, onUnmount? })` — DOM-ref / lifecycle. `onMount(node)` fires once after attach (grab a node, focus it, hand it to a chart/map/editor); `onUnmount(node)` on teardown. Stash the node in a `$ref(...)`.\n- `Css(child, { class?, style? })` — last-resort class/style merge.\n- `Link(childOrLabel, { to?, href?, external?, variant? })` — anchor; `to` for router nav, `href`+`external: true` for outbound links.\n\n```\nOnClick(Card([Text("View order")]), { onClick: () => route.navigate("/orders/4821") })\nOnIntersect(Skeleton({ variant: "card" }), { onEnter: $items.refetch, once: true })\n```'}function Xf(){return'## Escape hatches — `HTMLTag` & `Styles`\n\nOnly when the catalogue can\'t express the markup/styling you need:\n- `HTMLTag(tag, { attributes?, children? })` — an allow-listed HTML tag (`on*` attributes, `javascript:` URLs, and unsafe `style` are stripped; unknown tags become `div`).\n- `Styles(css)` — inject a `<style>` block (`</style>`, `<script>`, `@import`, `javascript:` are dropped).\n\n```\n$app(Column([\n Styles(`.hero { background: linear-gradient(135deg, #6366f1, #10b981); padding: 24px; border-radius: 12px; }`),\n HTMLTag("div", { attributes: { class: "hero" }, children: [Text("Custom block")] })\n]))\n```'}function Jf(){return'## Theming, i18n & icons\n\n### `$theme({ ... })`\nA bare `$theme({...})` statement (near the top) brands the response. Structured groups: `colors`, `radius`, `font` (plus metadata `name`, `direction`). Omit it to inherit the host theme.\n\n```\n$theme({\n colors: { primary: "#635bff", bg: "#0a0a23", surface: "#10103a", text: "#fff" },\n radius: { md: "0.5rem", button: "999px" },\n font: { family: "Inter, sans-serif", familyHeading: "Inter, sans-serif" }\n})\n```\n\nThe host picks one of seven base themes (`light`, `dark`, `neon`, `pastel`, `glass`, `brutalist`, `skyline`) — author theme-neutral UI (use `tone:` / `variant:`, not hard-coded colours).\n\n### i18n\n```\nconst { t, setCurrentLanguage } = $i18n({\n defaultLanguage: "en", currentLanguage: $lang,\n translations: { greeting: { en: "Hello, {name}!", fr: "Bonjour, {name}!" } }\n})\nwelcome = Text(t("greeting", { name: $user.name }))\n```\n`t(key, vars?)` resolves `translations[key][currentLanguage]`, falling back to the default language then the bare key; `{name}` placeholders interpolate. Drive `currentLanguage` from a reactive atom for live switching.\n\n### Icons\nIcon props take a Font Awesome name (no `fa-` prefix, never an emoji): `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`. `Icon(name, { variant?, size? })` renders a standalone glyph.'}function Zf(){return'## `$util` — runtime helper namespace\n\nPure helpers (no side effects), available in every expression, action, effect, and lambda. Reach for `$util` when plain JS would be verbose (formatting, dates, grouping); use plain JS when it\'s just as clear (`arr.length`, `arr.slice(0, 5)`).\n\n- **Collections**: `$util.sort(arr, field, dir?)`, `$util.groupBy(arr, field)`, `$util.unique(arr, field?)`, `$util.sum / .avg / .min / .max / .count`, `.first / .last`, `.filter(arr, field, op, value)`, `.find`, `.partition(arr, field, op, value)`, `.keyBy(arr, field)`, `.chunk(arr, size)`, `.flatten(arr, depth?)`, `.zip(...arrays)`, `.range(start, end, step?)`.\n- **Objects**: `$util.pick(obj, keys)`, `.omit(obj, keys)`, `.merge(target, ...sources)` (deep), `.cloneDeep(value)`.\n- **Strings**: `$util.capitalize / .titlecase / .uppercase / .lowercase`, `.plural(n, singular, plural)`, `.trim / .replace / .split / .match`.\n- **Formatting**: `$util.format(value, mode, opts?)` (number, currency, percent, compact) and `$util.formatDate(value, mode)` (`"short" | "long" | "time" | "relative"` or a token string).\n- **Dates / math**: `.now / .today / .addDays / .diffDays / .startOfWeek`; `.round / .floor / .ceil / .abs / .clamp(v, min, max) / .random`.\n\n```\nsorted = $util.sort($users.filter(u => u.team === $team), "joinedAt", "desc")\nsummary = `${rows.length} ${$util.plural(rows.length, "order", "orders")} · ${$util.format($util.sum(rows.amount), "currency")}`\n```'}function Qf(){return"## Standard helper components\n\n| Component | Purpose |\n|---|---|\n| `Async(resource, { loading, error, empty, data })` | Branch on an `$http({...})` resource state. |\n| `Show(when, { fallback?, children })` | Sugar for `when ? children : fallback`. |\n| `Portal(children, { target? })` | Render outside the parent subtree. |\n| `Redirect(path)` | Navigate and unmount the rest of the subtree. |\n| `Lazy(loader, { fallback?, children })` | Defer rendering until the async `loader` resolves; show `fallback` while pending. |\n| `ErrorBoundary(children, { fallback?, onError? })` | Catch render errors thrown by descendants. |\n| `VirtualList(items, { key, render })` | Virtualised list — preferred for >100 rows. |"}function eg(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(o=>o.name)}],r=new Map(t.components.map(o=>[o.name,o])),a=[];a.push("## Component library"),a.push("Use only these components. Each signature lists props in declaration order; optional props end with `?`. The prop tagged `(positional)` is the canonical positional slot — pass it bare; every other prop goes in a trailing `{ prop: value }` object."),a.push("");for(const o of e){a.push(`### ${o.name}`);for(const s of o.components){const c=r.get(s);c&&a.push(er(c))}a.push("")}const n=new Set(e.flatMap(o=>o.components)),i=t.components.filter(o=>!n.has(o.name));if(i.length>0){a.push("### Other");for(const o of i)a.push(er(o))}return a.join(`
|
|
108
|
-
`).trim()}function
|
|
107
|
+
Register the UI root with \`$app(...)\` on the first line. Pass it one node (\`$app(Component())\`), an array (\`$app([Component1(), Component2()])\`), or variadic nodes (\`$app(Component1(), Component2())\`). Wrap a dashboard/app in \`AppShell\` (left sidebar + topbar); build a website or marketing page from a top \`Navbar\` + stacked sections — never an \`AppShell\`. References resolve across the whole program, so call \`$app(...)\` first and let the rest stream in below it. There should be only one \`$app(...)\` in the program, as the runtime treats it as the UI root.`}function Xf(){return'## Core syntax\n\nA program is a flat list of `name = expression` statements, one per line (newlines end statements; semicolons optional).\n\n```\n$app(Column([header, kpis, table])) // UI root — always first\nheader = PageHeader("Sales", { subtitle: "Q4 2026" })\n$count = 0 // reactive atom — the \'$\' prefix is the contract\nfunction Counter(label) { return Text(`${label}: ${$count}`) } // component (returns a tree)\nfunction inc() { $count += 1 } // action (no return — runs for side effects)\n$effect(() => $console.log($count), [$count]) // declarative side effect\n```\n\n### Three kinds of name\n- `name = value` — plain binding, captured once (not reactive).\n- `$name = value` — reactive atom: reading subscribes, writing notifies.\n- `function name(...)` — declares a component AND an action of that name. First-letter case is NOT significant (`Card`/`card`, `SaveOrder`/`saveOrder`); same for arrow bindings (`row = item => Row(...)`).\n\n### Two rules, broken constantly — always check\n1. **Invoke components with parentheses.** A component is a function; the bare name is just its value. Render it by calling it, even with no args: `$app(MyApp())` not `$app(MyApp)`; `Column([Header(), Body()])` not `Column([Header, Body])`. (Exception: passing a component as a callback, e.g. `render: UserCard`.)\n2. **One positional argument max** (the trailing-object rule): each call takes at most one bare positional arg; all other props go in a trailing `{ }` object.\n\n```\nButton("Save", { variant: "primary", loading: $isSaving })\nStatCard("Revenue", { value: "$48k", trend: "up", delta: "+12%" })\nRow([Card1(), Card2()], { gap: "m" })\n```\n\n`Button("Save", "primary")` is a schema error — use the named-prop form. Any call also accepts `{ key: ... }` to pin per-instance state across reorders.\n\n### Reserved top-level names\n- `$app(...)` — registers the UI root (REQUIRED).\n- `$theme({...})` — optional brand override (written as a bare statement).\n- `route` — the reactive router handle (`route.path`, `route.params`, `route.navigate("/x")`); never declare it yourself.'}function Jf(){return'## JavaScript is fully supported\n\nAktion *is* JavaScript — every standard feature works inside expressions, action bodies, effect callbacks, and lambdas. Use whatever is clearest.\n\n### Ways to produce the UI\nThere is no single required shape — compose however the content suggests, and mix these freely:\n- **Inline in `$app(...)`** — `$app(Column([Hero(), Features(), Footer()]))` for a self-contained tree.\n- **Named statements** — pull pieces into `name = ...` bindings and reference them; they hoist and stream in independently.\n- **`.map` / `.filter` over data** — turn arrays into nodes: `rows = $items.map(i => Row(i))`.\n- **`function` components** — factor reusable or parameterised UI into components; invoke them with `()`.\n- **`$router({...})` pages** — split a multi-page app into route arms.\n\n### In expressions (right of `=`) — value-producing JS only\n```\nbanner = $error ? Banner($error, { tone: "danger" }) : null // ternary\nrows = $todos.filter(t => !t.done).map(t => TodoRow(t)) // map / filter / reduce\ntotal = $cart.reduce((sum, i) => sum + i.price, 0)\nmerged = { ...$base, status: "done" } // spread / destructuring\nname = $user?.profile?.name ?? "Guest" // optional chain / nullish\ntitle = `${rows.length} ${$util.plural(rows.length, "result", "results")}` // template literal\n```\n`if` / `switch` / `for` / `while` / `try` are statements — they can\'t sit on the right of `=`. Use a ternary, an array method, or wrap them in a function and call it.\n\n### In action / effect / lambda bodies — full statement surface\n`if`/`else`, `switch`, every `for` and `while`, `try`/`catch`/`finally`, `throw`, `return`, plus all assignment operators (`= += -= *= /= ??= ++ --`) against `$atoms` and member chains (`$user.name = "Alex"`).\n\n```\nfunction submit(payload) {\n if (!payload.email) return\n for (let tag of payload.tags) $tags = [...$tags, tag]\n $emit("submitted", { id: payload.id })\n}\n```\n\n### Lambdas, continuations, comments, timers\n- Arrow functions in every form: `() => expr`, `x => expr`, `(a, b = 0) => { ...; return ... }`, `(...args) => ...`.\n- A leading operator (`.`, `?.`, `&&`, `??`, `?`/`:`, arithmetic) continues an expression onto the next line.\n- Comments: `// line` and `/* block */` only.\n- `setTimeout` / `setInterval` / `clearTimeout` / `clearInterval` work and are torn down on re-plan — create them in an `$effect` and clear them in its `cleanup`, or prefer `$effect(..., ["every(1000)"])` for simple repeats.\n- Every JavaScript global resolves by name (see *Built-in globals*).'}function Zf(){return'## Reactive State\n\nThe `$` sigil is the only thing that makes a binding reactive; `let`/`const`/`var` are optional and don\'t affect reactivity.\n\n```\n$count = 0\n$user = { name: "Ada", role: "Engineer" }\n```\n\n- **Read** `$name` anywhere — it auto-subscribes whoever reads it (component, derived value, effect).\n- **Write** `$name = ...` (and `+= -= ??= ++ --`) only from event handlers, effects, and lambdas — never while building the UI. Member writes (`$user.name = "Alex"`) update immutably so subscribers see a fresh reference.\n- **Never write reactive state in render position.** A write that runs while the UI is built loops; the runtime applies it but skips the re-render and warns. Hold component-local state by declaring it at the top of a component body (set-once per instance) or with the `$state` hook.\n\n### Fine-grained reactivity (path-level)\nSubscriptions track the exact **path** you read. Reading `$user.name` subscribes to `user.name` alone — writing `$user.role` won\'t recompute it, but replacing `$user` will; effect deps work the same (`$effect(..., [$user.name])`). Prefer reading the precise field for the tightest updates. A component re-executes only when its own inputs change — its args or a `$` path its body read — like `React.memo`, but automatic. Args compare shallowly, so hoist inline-lambda props to a stable binding to avoid needless child re-renders.\n\n### Per-instance state\n`$name = value` inside a function body is per-instance when the function renders as a component — two `Counter()`s each own their `$count`. Add `{ key: id }` to keep state attached when siblings reorder.\n\n### Hooks\nFor composable local state, use hooks — a function whose name starts with `$`, called only at the top level of a component (or another hook) in a stable order:\n- `$state(initial)` → `[value, setValue]` (like `useState`; `setValue(prev => next)` supported, `initial` runs once).\n- `$memo(() => value, [deps])` → a cached value (like `useMemo`).\n- `$ref(initial)` → a stable `{ current }` box (like `useRef`; writing `.current` does NOT re-render — for DOM nodes, timer ids, previous values).\n- `$reducer((state, action) => next, initial)` → `[state, dispatch]` (like `useReducer`; the clean way to manage many related transitions).\n- `$id(prefix?)` → a stable unique id per instance (like `useId`; for `for`/`aria-*` wiring).\n- `function $name(...)` declares a custom hook composing the built-ins.\n\n```\nfunction Counter() {\n const [count, setCount] = $state(0)\n const label = $memo(() => `Count: ${count}`, [count])\n return Stack([Text(label), Button("+1", { onClick: () => setCount(c => c + 1) })])\n}\n```\n\n### Two-way binding\nPass a `$variable` (or member chain — `value: $form.email`) as the value prop of any input/select/checkbox/switch/slider and the runtime wires the change handler automatically; add `onChange: v => ...` for an extra side effect.\n\n```\n$draft = ""\nfield = Input("draft", { value: $draft })\n```\n\n### Computed values\nNo separate "computed" tier — just compute. Every `$` reference in an expression auto-tracks: `$open = $todos.filter(t => !t.done)`.\n\n### Global stores — `$store({...})`\nFor app-wide state without prop-drilling, declare a store. Non-function entries are reactive state; function entries are methods that receive the store handle `s` first. Read `store.field` (fine-grained) and call `store.method(args)`.\n\n```\ncart = $store({\n items: [],\n total: (s) => $util.sum(s.items.map(i => i.price)), // → cart.total()\n add: (s, item) => { s.items = [...s.items, item] }, // → cart.add(item)\n})\nfunction CartBadge() { return Badge(`${cart.items.length} items`) }\n```\n\nUse a store for shared state; use a component\'s local `$state` / `$name` for state one component owns.'}function Qf(){return'## Components & Actions\n\nA `function` declaration is both a **component** (call it in render position → its return value renders) and an **action** (call it from an event handler → its body runs). Name case is not significant, and a function with no `return` renders nothing.\n\n### Components\n```\nfunction UserCard(user, { tone = "default" } = {}) {\n return Card([\n Avatar(user.name, { size: "md" }),\n Text(user.name, { variant: "large-heavy" }),\n Badge(tone, { tone })\n ])\n}\n$app(Column([UserCard($currentUser), UserCard($other, { tone: "primary" })]))\n```\n\n- The positional argument lands in the component\'s first parameter (the `children` slot for container-style components).\n- User components shadow built-ins of the same name — wrap a library component to add telemetry or styling.\n- Use a lambda (`row = item => Row(item)`) for one-off helpers that don\'t need a named component.\n\n### Actions\nA `function` whose body runs for side effects is an action — use it as a handler (`onClick: save`) or call it for its result. `return` is optional; the full JS statement surface applies. Wrap optimistic writes in `$optimistic(() => { … })` to snapshot state and auto-roll-back if the callback throws (or its promise rejects).\n\n```\nfunction save(item) {\n $items = [...$items, item]\n $save = $http({ url: "https://api.example.com/save", method: "POST", body: { item } })\n $emit("saved", { id: item.id })\n}\nfunction addTodo(text) {\n $optimistic(() => {\n $todos = [...$todos, { id: $todos.length + 1, text }] // optimistic write\n if (text == "") throw new Error("empty") // → rolls $todos back\n })\n}\nsaveBtn = Button("Save", { onClick: save })\nresetBtn = Button("Reset", { onClick: () => { $count = 0; $message = "" } })\n```\n\n### `$emit("name", { detail })`\nFrom any action / effect / lambda, `$emit` dispatches a `CustomEvent` on the host `<aktion-app>` (listen with `el.addEventListener`). Reserved names: `assistant-message`, `error`, `route-change`.'}function eg(){return'## Effects — Declarative side effects\n\n`$effect(() => { ... }, [...deps])` runs side effects. Dep entries: `$atom` (re-run on change), `"mount"` / `"unmount"` (once), `"every(N)"` (every N ms), `"debounce(N)"` / `"throttle(N)"` (trailing-edge rate limit). No second argument ≡ `["mount"]`.\n\nTop-level effects mount on parse and tear down on the next response; effects inside a component mount per-instance and tear down — running their `cleanup(fn)` — when the instance leaves the tree.\n\n```\n$effect(() => {\n $results = $http({ url: "https://api.example.com/search", query: { q: $term } })\n}, [$term, "debounce(250)"])\n\n$effect(() => {\n const onKey = e => { if (e.key == "/") $palette = true }\n document.addEventListener("keydown", onKey)\n cleanup(() => document.removeEventListener("keydown", onKey))\n}, ["mount"])\n```'}function tg(){return'## Data — `$http({...})`\n\n`$http({ ... })` is the only HTTP primitive. Each call is self-contained: pass an absolute `url`, optional `method` (default `GET`), `query` (serialised into the URL), `headers`, `body` (JSON-encoded automatically), and any `fetch` option. No host-wide defaults.\n\n```\n$orders = $http({ url: `https://api.example.com/users/${$userId}/orders`, query: { limit: 5 } })\n```\n\nIt fires once when the binding mounts and exposes a reactive bag:\n```\n$orders.data $orders.error $orders.status $orders.loading\n$orders.headers $orders.lastUpdated\n$orders.refetch() $orders.cancel() $orders.onDone = fn\n```\n\nRe-run with `.refetch()`, or wrap the call in `$effect(..., [$dep])` to re-issue when a dep changes. After a write, refresh a list from the write\'s `onDone` (fires on every settle — the initial load and each refetch):\n\n```\nfunction saveOrder(payload) {\n $save = $http({ url: "https://api.example.com/orders", method: "POST", body: payload })\n $save.onDone = () => $orders.refetch()\n}\n```\n\nBranch on resource state with `Async`:\n```\nview = Async($orders, {\n loading: LoadingState("Loading orders…"),\n error: ErrorState("Couldn\'t fetch orders"),\n empty: EmptyState("No orders yet"),\n data: Table([Col("Item", $orders.data.title), Col("Total", $orders.data.total, { format: "currency" })])\n})\n```\n\n### `$query({...})` and `$mutation({...})`\nSame config shape as `$http`, for two common needs:\n- `$query({ url, key?, ttl? })` — a **cached, deduplicated** read. Identical queries (same `key`, or same method+url+query+body) share one in-flight request and one cached bag, so calling it from several components fetches once. Pass `ttl` (ms) to auto-refetch stale data. Same bag as `$http` (`.data`/`.loading`/`.error`/`.refetch()`).\n- `$mutation({ url, method? })` — a **deferred** write that fires only when you call `.mutate(overrides?)`, not on render (method defaults to `POST`). Assign it to an atom, then trigger it from a handler:\n```\n$save = $mutation({ url: "https://api.example.com/orders" })\n$save.onDone = () => $orders.refetch()\n...\nButton("Save", { onClick: () => $save.mutate({ body: { item: $item } }) })\n```\n`.mutate()` resolves with the response body; the bag exposes `.loading`/`.error`/`.data` plus `.reset()`.'}function rg(){return'## Routing\n\n`$router({ ... })` is a plain function call — assign it and drop the result into your page shell.\n\n```\npages = $router({\n "/": Dashboard(),\n "/orders/:id": OrderDetail({ id: params.id }),\n "/docs/*": Docs({ rest: params._ }),\n default: NotFound()\n})\n$app(AppShell(MainSidebar(), pages)) // app/dashboard shell\n```\n\n- **Pick the shell for the surface.** `AppShell(Sidebar(...), pages)` for an app/dashboard (left sidebar + optional topbar); a top `Navbar(...)` above the pages inside a `Column` for a website / marketing / docs layout (no sidebar) — never wrap a website in `AppShell`. The router result is just a node, so it drops into either.\n- Patterns: literal, `:param` (read `params.id`), trailing `*` (read `params._`), and `default:` for the catch-all (unknown paths render `null` without it).\n- The read-only `route` handle: `route.path`, `route.params.x`, `route.query.tab`; navigate with `route.navigate("/path")` from an action/effect.\n- `NavLink(label, { to, exact?, icon? })` and `SidebarItem(label, { to, icon?, badge? })` derive active state from `route.path`. Never declare `route` yourself.'}function ag(){return'## Built-in globals — `storage`, `console` & `$toast`\n\nAlways in scope, lowercase, no imports.\n\n```\n$storage.set("name", "John"); $name = $storage.get("name"); $storage.remove("name")\n$storage.session.set("draft", $draft)\n$storage.cookies.set("user", "John", { expires: 7, path: "/" })\n$console.log("Hello", $user)\n```\n\nNon-string values JSON-roundtrip; missing keys return `null`. Beyond these, every JavaScript global resolves by name — `Math`, `JSON`, `Date`, `crypto`, `fetch`, `URL`, `navigator`, `window`, `document`, dialogs like `confirm`, … — and your declarations and components shadow same-named globals. Prefer reactive `$http({...})` over raw `fetch` for UI data, and keep timers/listeners inside `$effect` so they\'re cleaned up.\n\n```\nfunction copyLink() { navigator.clipboard.writeText(window.location.href); $toast.show("Copied", { tone: "success" }) }\nid = crypto.randomUUID()\n```\n\n### `$toast` — imperative notifications\nInstead of hand-managing a `$toasts = [...]` array, use the reserved `$toast` namespace. `$toast.show(message, { tone?, title?, duration? })` appends a toast (auto-dismisses after `duration` ms, default 4000; pass `0` to keep it). Shortcuts: `$toast.success/.error/.info/.warning`. Remove with `$toast.dismiss(id)` / `$toast.clear()`. Render the reactive `$toast.items` list:\n\n```\nfunction save() { $save = $http({ url, method: "POST", body }); $save.onDone = () => $toast.success("Saved") }\ntoaster = Toasts(map($toast.items, t => Toast({ title: t.title, message: t.message, tone: t.tone, onClose: () => $toast.dismiss(t.id) })))\n```'}function ng(){return'## Behaviour wrappers\n\nThese attach behaviour or styling to ANY node via `display: contents` (the visual tree is unchanged):\n- `OnClick(child, { onClick, disabled?, stopPropagation? })` — pointer + keyboard activatable. (Don\'t wrap `Button` — it already has `onClick`; use this for clickable cards / list rows.)\n- `OnMouse(child, { enter?, leave?, move?, down?, up?, drag?, drop?, dragOver?, ... })` — pass only the events you need.\n- `OnKeyboard(child, { onKeyDown?, onKeyUp?, focusable? })` and `OnFocus(child, { onFocus?, onBlur? })`.\n- `OnIntersect(child, { onEnter?, onLeave?, threshold?, once? })` — IntersectionObserver (lazy-load, infinite scroll).\n- `OnMount(child, { onMount?, onUnmount? })` — DOM-ref / lifecycle. `onMount(node)` fires once after attach (grab a node, focus it, hand it to a chart/map/editor); `onUnmount(node)` on teardown. Stash the node in a `$ref(...)`.\n- `Css(child, { class?, style? })` — last-resort class/style merge.\n- `Link(childOrLabel, { to?, href?, external?, variant? })` — anchor; `to` for router nav, `href`+`external: true` for outbound links.\n\n```\nOnClick(Card([Text("View order")]), { onClick: () => route.navigate("/orders/4821") })\nOnIntersect(Skeleton({ variant: "card" }), { onEnter: $items.refetch, once: true })\n```'}function ig(){return'## Escape hatches — `HTMLTag` & `Styles`\n\nOnly when the catalogue can\'t express the markup/styling you need:\n- `HTMLTag(tag, { attributes?, children? })` — an allow-listed HTML tag (`on*` attributes, `javascript:` URLs, and unsafe `style` are stripped; unknown tags become `div`).\n- `Styles(css)` — inject a `<style>` block (`</style>`, `<script>`, `@import`, `javascript:` are dropped).\n\n```\n$app(Column([\n Styles(`.hero { background: linear-gradient(135deg, #6366f1, #10b981); padding: 24px; border-radius: 12px; }`),\n HTMLTag("div", { attributes: { class: "hero" }, children: [Text("Custom block")] })\n]))\n```'}function og(){return'## Theming, i18n & icons\n\n### `$theme({ ... })`\nA bare `$theme({...})` statement (near the top) brands the response. Structured groups: `colors`, `radius`, `font` (plus metadata `name`, `direction`). Omit it to inherit the host theme.\n\n```\n$theme({\n colors: { primary: "#635bff", bg: "#0a0a23", surface: "#10103a", text: "#fff" },\n radius: { md: "0.5rem", button: "999px" },\n font: { family: "Inter, sans-serif", familyHeading: "Inter, sans-serif" }\n})\n```\n\nThe host picks one of seven base themes (`light`, `dark`, `neon`, `pastel`, `glass`, `brutalist`, `skyline`) — author theme-neutral UI (use `tone:` / `variant:`, not hard-coded colours).\n\n### i18n\n```\nconst { t, setCurrentLanguage } = $i18n({\n defaultLanguage: "en", currentLanguage: $lang,\n translations: { greeting: { en: "Hello, {name}!", fr: "Bonjour, {name}!" } }\n})\nwelcome = Text(t("greeting", { name: $user.name }))\n```\n`t(key, vars?)` resolves `translations[key][currentLanguage]`, falling back to the default language then the bare key; `{name}` placeholders interpolate. Drive `currentLanguage` from a reactive atom for live switching.\n\n### Icons\nIcon props take a Font Awesome name (no `fa-` prefix, never an emoji): `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`. `Icon(name, { variant?, size? })` renders a standalone glyph.'}function sg(){return'## `$util` — runtime helper namespace\n\nPure helpers (no side effects), available in every expression, action, effect, and lambda. Reach for `$util` when plain JS would be verbose (formatting, dates, grouping); use plain JS when it\'s just as clear (`arr.length`, `arr.slice(0, 5)`).\n\n- **Collections**: `$util.sort(arr, field, dir?)`, `$util.groupBy(arr, field)`, `$util.unique(arr, field?)`, `$util.sum / .avg / .min / .max / .count`, `.first / .last`, `.filter(arr, field, op, value)`, `.find`, `.partition(arr, field, op, value)`, `.keyBy(arr, field)`, `.chunk(arr, size)`, `.flatten(arr, depth?)`, `.zip(...arrays)`, `.range(start, end, step?)`.\n- **Objects**: `$util.pick(obj, keys)`, `.omit(obj, keys)`, `.merge(target, ...sources)` (deep), `.cloneDeep(value)`.\n- **Strings**: `$util.capitalize / .titlecase / .uppercase / .lowercase`, `.plural(n, singular, plural)`, `.trim / .replace / .split / .match`.\n- **Formatting**: `$util.format(value, mode, opts?)` (number, currency, percent, compact) and `$util.formatDate(value, mode)` (`"short" | "long" | "time" | "relative"` or a token string).\n- **Dates / math**: `.now / .today / .addDays / .diffDays / .startOfWeek`; `.round / .floor / .ceil / .abs / .clamp(v, min, max) / .random`.\n\n```\nsorted = $util.sort($users.filter(u => u.team === $team), "joinedAt", "desc")\nsummary = `${rows.length} ${$util.plural(rows.length, "order", "orders")} · ${$util.format($util.sum(rows.amount), "currency")}`\n```'}function lg(){return"## Standard helper components\n\n| Component | Purpose |\n|---|---|\n| `Async(resource, { loading, error, empty, data })` | Branch on an `$http({...})` resource state. |\n| `Show(when, { fallback?, children })` | Sugar for `when ? children : fallback`. |\n| `Portal(children, { target? })` | Render outside the parent subtree. |\n| `Redirect(path)` | Navigate and unmount the rest of the subtree. |\n| `Lazy(loader, { fallback?, children })` | Defer rendering until the async `loader` resolves; show `fallback` while pending. |\n| `ErrorBoundary(children, { fallback?, onError? })` | Catch render errors thrown by descendants. |\n| `VirtualList(items, { key, render })` | Virtualised list — preferred for >100 rows. |"}function cg(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(o=>o.name)}],r=new Map(t.components.map(o=>[o.name,o])),a=[];a.push("## Component library"),a.push("Use only these components. Each signature lists props in declaration order; optional props end with `?`. The prop tagged `(positional)` is the canonical positional slot — pass it bare; every other prop goes in a trailing `{ prop: value }` object."),a.push("");for(const o of e){a.push(`### ${o.name}`);for(const s of o.components){const c=r.get(s);c&&a.push(tr(c))}a.push("")}const n=new Set(e.flatMap(o=>o.components)),i=t.components.filter(o=>!n.has(o.name));if(i.length>0){a.push("### Other");for(const o of i)a.push(tr(o))}return a.join(`
|
|
108
|
+
`).trim()}function ug(){return"## Inline mode\n\nYou may answer questions in plain text. When you do, wrap any UI you produce in a fenced ```aktion``` block. Otherwise output Aktion directly with no surrounding prose."}function dg(){return"## Edit mode\n\nWhen the user asks for an incremental change to a prior response, output ONLY the statements that need to change (additions, replacements, removals). Do NOT re-emit the whole UI. To remove a statement, write `name = null`."}function pg(){return'## Streaming & verification\n\n### Hoisting & streaming (CRITICAL)\nReferences resolve across the whole top-level scope, not source order — undefined refs render empty until they arrive, giving a smooth top-down reveal. Emit in this order: (1) `$app(...)` first; (2) `function` declarations and `$effect(...)`; (3) leaf data (arrays, objects, strings) last. Give each `Col` / `TabItem` / `Series` its own named binding so it streams independently. Never split a statement across lines unless it sits inside an unmatched `[`, `(`, or `{`.\n\n### Before finishing, check\n1. `$app(...)` is first; every name it reaches is defined below, and every defined name is reachable from it.\n2. Every component reference is invoked with `()` — scan the root, array elements, and prop values for bare identifiers (callback props like `render: UserCard` are the one exception).\n3. State uses `$name = ...`; writes happen only in handlers/effects, never in render position.\n4. `$http({...})` uses an absolute URL and exposes `.data` / `.error` / `.loading` / `.refetch()`; `$router({...})` arms use `:` and `default`; effects are `$effect(() => {...}, [deps])`.\n5. Build a complete surface — `PageHeader`, multi-section layout, wired buttons, 5–20 rows of realistic seed data — not a lone Card. Lay out with `Column` / `Row` / `Grid`; use responsive maps (`{ base: 1, md: 2 }`) where they help.\n6. Tables are column-oriented (`Table([Col("Label", arr)])`, cells may be components via `rows.map(r => Badge(r.status))`); charts take numeric arrays (`PieChart(rows.label, rows.value)`); icons are Font Awesome names; `storage` / `console` are lowercase; `route` is reserved.'}function mg(){return[`// Tasks dashboard — $http, Async, an action, multi-section layout
|
|
109
109
|
$tasks = $http({ url: "https://api.example.com/tasks" })
|
|
110
110
|
|
|
111
111
|
function toggle(task) {
|
|
@@ -127,12 +127,12 @@ $app(Column([
|
|
|
127
127
|
empty: EmptyState("No tasks yet"),
|
|
128
128
|
data: Column($tasks.data.map(t => row(t)), { gap: "s" })
|
|
129
129
|
})
|
|
130
|
-
], { gap: "l" }))`]}const
|
|
130
|
+
], { gap: "l" }))`]}const fg=["Column","Row","Center","Stack","StackItem","Grid","GridItem","Box","Container","Spacer","Card","CardHeader","CardFooter","Separator","Tabs","TabItem","Accordion","AccordionItem","Steps","AspectRatio","Text","Markdown","Quote","Callout","CodeBlock","Image","Link","Badge","BadgeList","Icon","Kbd","Spinner","Skeleton","Table","Col","List","ListItem","StatCard","Stats","Sparkline","Tile","Progress","ProgressRing","DescriptionList","DescriptionItem","StatusDot","Tree","TreeNode","BarChart","LineChart","PieChart","RadarChart","ScatterChart","Histogram","Heatmap","Gauge","Series","Avatar","AvatarGroup","PersonChip","Rating","ChatBubble","Banner","Notification","Hero","PageHeader","SectionHeader","EmptyState","Timeline","TimelineItem","ActivityLog","FeatureGrid","FeatureItem","Testimonial","ProfileCard","Comment","MediaCard","LoadingState","ErrorState","SuccessState","DiffViewer","JsonTree","SectionBlock","ListBlock","FollowUpBlock","FollowUpItem"];function gg(t){return`${t?.trim()||"You respond in Aktion — a declarative language that is a strict subset of JavaScript. The host renders your reply as a rich, read-only UI. Output ONLY Aktion: no markdown, prose, or JSON."}
|
|
131
131
|
|
|
132
|
-
Register the UI root with \`$app(...)\` on the first line (typically \`$app(Column([...]))\`). This is read-only display mode — use only the layout, content, data, chart, and feedback components listed below. Do NOT emit state writes, actions, effects, HTTP, routing, form controls, or clickable buttons. The single exception is \`FollowUpBlock\`, which the host renders as suggested follow-up prompts.`}function
|
|
133
|
-
### ${n.name}`);for(const o of i){const s=r.get(o);s&&a.push(
|
|
134
|
-
`)}function
|
|
135
|
-
`)}function
|
|
132
|
+
Register the UI root with \`$app(...)\` on the first line (typically \`$app(Column([...]))\`). This is read-only display mode — use only the layout, content, data, chart, and feedback components listed below. Do NOT emit state writes, actions, effects, HTTP, routing, form controls, or clickable buttons. The single exception is \`FollowUpBlock\`, which the host renders as suggested follow-up prompts.`}function hg(){return'## Syntax (read-only subset)\n\nA program is a flat list of `name = expression` statements in standard JavaScript. `$app(...)` registers the entry point (always first); every other binding hoists, so order is free — emit `$app(...)`, then containers, then leaf data last for a smooth streaming reveal.\n\n- Strings, numbers, booleans, `null`, arrays, objects; template literals `Found ${rows.length}` over `+` concatenation.\n- Operators `+ - * / %`, comparisons, `&& || !`, ternary `cond ? a : b`, nullish `a ?? b`, spread, member `obj.field`, optional chaining `obj?.field`.\n\n### Component calls\n- **Case doesn\'t matter** — `Card` and `card` are equivalent.\n- **Always invoke with parentheses** — `Column([Header(), Body()])`, never `Column([Header, Body])`; write `Hero()` even with no args.\n- **One positional arg, the rest in a trailing object** — `Callout("info", { title: "Heads up", icon: "circle-info" })`, `Badge("Live", { tone: "success" })`.\n\n### Build UI from data — JS is fully supported\n`.map` / `.filter` arrays into nodes (`rows.map(r => ListItem(r.title))`), ternaries for branching, and the array-pluck shortcut `rows.title` → `[each row.title]` to feed columns (`Col("Title", rows.title)`) and chart series (`PieChart(rows.label, rows.value)`). `if` / `for` are statements — not usable on the right of `=`.\n\n```\n$app(Column([title, table, follow]))\ntitle = Text("Q4 results", { variant: "large-heavy" })\ntable = Table([Col("Region", rows.region), Col("Revenue", rows.revenue, { format: "currency" })])\nfollow = FollowUpBlock(["Break down by region", "Compare to Q3"])\nrows = [{ region: "NA", revenue: 184000 }, { region: "EU", revenue: 122000 }]\n```'}function bg(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(n=>n.name)}],r=new Map(t.components.map(n=>[n.name,n])),a=["## Component library (read-only)","Use only these components. Each signature lists props in declaration order; optional props end with `?`. Pass the positional prop bare, then all other props in a trailing `{ prop: value }` object."];for(const n of e){const i=n.components.filter(o=>fg.includes(o));if(i.length!==0){a.push(`
|
|
133
|
+
### ${n.name}`);for(const o of i){const s=r.get(o);s&&a.push(tr(s))}}}return a.join(`
|
|
134
|
+
`)}function vg(){return'## `$util` — runtime helper namespace\n\nPure helpers — no side effects. Use `$util` anywhere in expressions for data shaping, formatting, math, and strings. Prefer plain JavaScript where it is just as clear (`arr.length`, `arr.slice(0, 5)`, `s.toUpperCase()`).\n\n### Most useful helpers\n- Collections: `$util.sum / .avg / .min / .max / .sort(arr, field, dir?) / .groupBy(arr, field) / .unique(arr, field?) / .chunk / .partition / .keyBy`.\n- Objects: `$util.pick / .omit / .merge / .cloneDeep`.\n- Strings: `$util.capitalize / .titlecase / .plural(n, singular, plural)`.\n- Formatting: `$util.format(value, mode, opts?)` (numbers, currency, percent, compact) and `$util.formatDate(value, mode)` (`"short"` | `"long"` | `"time"` | `"relative"`).\n\nIcons are Font Awesome names — `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`. Never use `fa-` prefixes or emoji characters.'}function yg(){return"## Hoisting & streaming (CRITICAL)\n\nReferences resolve from the whole scope, not source order — undefined refs render empty until they arrive, producing a smooth top-down reveal. Order: (1) `$app(...)` first; (2) container statements; (3) leaf data (arrays, objects, strings) last. Give each `Col` / `TabItem` / `Series` / `FollowUpItem` its own binding so it streams independently. Never split a statement across lines unless it sits inside an unmatched `[`, `(`, or `{`."}function xg(t){const e=["## Available data sources (context only)","These endpoints are available to the host. You cannot call them from read-only mode, but you may incorporate the data they describe when composing the UI:"];for(const r of t)e.push(`- **${r.name}** — ${r.description}`);return e.join(`
|
|
135
|
+
`)}function wg(){return[`// Comparison table with a template-literal summary and follow-ups
|
|
136
136
|
$app(Column([title, tbl, totals, follow]))
|
|
137
137
|
title = Text("Top languages by users", { variant: "large-heavy" })
|
|
138
138
|
tbl = Table([
|
|
@@ -147,11 +147,11 @@ langs = [
|
|
|
147
147
|
{ name: "Python", users: 15.7, year: 1991 },
|
|
148
148
|
{ name: "JavaScript", users: 14.2, year: 1995 },
|
|
149
149
|
{ name: "TypeScript", users: 8.5, year: 2012 }
|
|
150
|
-
]`]}function
|
|
151
|
-
`)}function
|
|
152
|
-
`)}function
|
|
150
|
+
]`]}function kg(){return"## Important rules\n\n- **Match the component to the content** — tables for comparisons, charts for trends, `Callout`/`Banner` for highlights, `Markdown` for paragraph prose, `Text` for short labels, `Hero`/`PageHeader` for titles, `Stats` for KPI strips.\n- **Lead with a clear title**, and use **realistic data** — believable names, numbers, dates; never Lorem Ipsum.\n- **Template literals** for any string mixing copy with values.\n- **End conversational replies with `FollowUpBlock([...])`** — 2–4 short next-prompt suggestions.\n- **Compose freely** — vary the structure and component mix to fit each request rather than reaching for the same template every time."}function Sg(){return'## Final verification\n\n1. `$app(...)` is first; every referenced name is defined below and reachable from the root.\n2. Every component is invoked with `()` — `Hero()`, never bare `Hero`.\n3. Only the read-only display components above — no forms, clickable buttons, state writes, actions, effects, HTTP, or routing.\n4. Tables are column-oriented (`Table([Col("Label", arr)])`, cells may be components via `rows.map(r => Badge(r.status))`); charts take numeric arrays (array-pluck `rows.value`).\n5. One positional arg per call, everything else in a trailing `{ }` object; no statement split across lines outside an unmatched bracket.'}function tr(t){const e=fr(t),r=t.props.map(a=>{const n=a.enum?a.enum.map(o=>`"${o}"`).join("|"):a.type,i=a===e&&a.positional===!0?" (positional)":"";return`${a.name}${a.optional?"?":""}: ${n}${i}`}).join(", ");return`- ${t.name}(${r}) — ${t.description}`}function na(t,e){const r=[`## ${t}`];for(const a of e)r.push("```"),r.push(a.trim()),r.push("```");return r.join(`
|
|
151
|
+
`)}function Ji(t){const e=["## Additional rules"];for(const r of t)e.push(`- ${r}`);return e.join(`
|
|
152
|
+
`)}function $g(t){const e=["## Available endpoints","These endpoints are provided by the host. Fire requests with `$http({ url, method, body, headers, ... })` and observe the reactive bag (`.data`, `.error`, `.loading`, `.status`, `.refetch()`)."];for(const r of t){const a=r.kind==="Mutation"?"POST/PUT/PATCH/DELETE":"GET",n=r.argsExample?` example body: ${JSON.stringify(r.argsExample)}`:" example body: {}";e.push(`- ${r.name} (${a}) — ${r.description}
|
|
153
153
|
${n}`)}return e.join(`
|
|
154
|
-
`)}const ye={colorBg:"#ffffff",colorBgSubtle:"#f8fafc",colorSurface:"#ffffff",colorSurfaceMuted:"#f1f5f9",colorBorder:"#e2e8f0",colorBorderSubtle:"rgba(15, 23, 42, 0.08)",colorText:"#0f172a",colorTextMuted:"#475569",colorPrimary:"#6366f1",colorPrimaryHover:"#4f46e5",colorPrimaryText:"#ffffff",colorAccent:"#6366f1",colorAccentHover:"#4f46e5",colorAccentText:"#ffffff",colorFocusRing:"#6366f1",colorSuccess:"#10b981",colorWarning:"#f59e0b",colorDanger:"#ef4444",colorInfo:"#06b6d4",shadowSm:"0 1px 2px rgba(15, 23, 42, 0.06)",shadowMd:"0 6px 24px rgba(15, 23, 42, 0.08)",shadowLg:"0 18px 60px rgba(15, 23, 42, 0.12)",borderWidth:"1px",chart1:"#6366f1",chart2:"#10b981",chart3:"#f59e0b",chart4:"#ef4444",chart5:"#06b6d4",chart6:"#8b5cf6",...{fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyHeading:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},...{fontSizeBase:"14px",fontSizeSm:"12px",fontSizeLg:"16px",fontSizeHeading:"16px",fontSizeTitle:"22px",fontWeightBody:"400",fontWeightHeading:"700",lineHeightBody:"1.5",lineHeightHeading:"1.2",letterSpacingHeading:"0",headingTextTransform:"none"},...{spacingXs:"4px",spacingS:"8px",spacingM:"12px",spacingL:"20px",spacingXl:"32px"},...{radiusXs:"4px",radiusSm:"6px",radiusMd:"10px",radiusLg:"16px",radiusPill:"999px",radiusButton:"6px",radiusInput:"6px"},...{buttonFontWeight:"600",buttonTextTransform:"none",buttonLetterSpacing:"0",buttonPaddingY:"8px",buttonPaddingX:"14px"},...{transitionDuration:"120ms"}},Ki={...ye,colorBg:"#0b1220",colorBgSubtle:"#0f172a",colorSurface:"#111827",colorSurfaceMuted:"#1e293b",colorBorder:"#1f2937",colorBorderSubtle:"rgba(248, 250, 252, 0.08)",colorText:"#f8fafc",colorTextMuted:"#94a3b8",colorPrimary:"#818cf8",colorPrimaryHover:"#6366f1",colorPrimaryText:"#0b1220",colorAccent:"#818cf8",colorAccentHover:"#6366f1",colorAccentText:"#0b1220",colorFocusRing:"#818cf8",shadowSm:"0 1px 2px rgba(0, 0, 0, 0.4)",shadowMd:"0 8px 24px rgba(0, 0, 0, 0.4)",shadowLg:"0 22px 60px rgba(0, 0, 0, 0.55)"},Gi={...ye,colorBg:"#05060f",colorBgSubtle:"#0a0c1c",colorSurface:"#0d1024",colorSurfaceMuted:"#161a36",colorBorder:"#2a2f6b",colorBorderSubtle:"rgba(236, 72, 153, 0.18)",colorText:"#f5f3ff",colorTextMuted:"#a5b4fc",colorPrimary:"#ec4899",colorPrimaryHover:"#f472b6",colorPrimaryText:"#05060f",colorAccent:"#22d3ee",colorAccentHover:"#67e8f9",colorAccentText:"#05060f",colorFocusRing:"#ec4899",colorSuccess:"#34d399",colorWarning:"#fbbf24",colorDanger:"#f87171",colorInfo:"#22d3ee",fontFamily:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontFamilyHeading:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontFamilyMono:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",letterSpacingHeading:"0.02em",radiusXs:"2px",radiusSm:"2px",radiusMd:"4px",radiusLg:"6px",radiusButton:"2px",radiusInput:"2px",shadowSm:"0 0 0 1px rgba(236, 72, 153, 0.25), 0 0 12px rgba(34, 211, 238, 0.18)",shadowMd:"0 0 0 1px rgba(236, 72, 153, 0.35), 0 0 28px rgba(34, 211, 238, 0.22)",shadowLg:"0 0 0 1px rgba(236, 72, 153, 0.45), 0 0 48px rgba(34, 211, 238, 0.35)",spacingXs:"4px",spacingS:"8px",spacingM:"14px",spacingL:"22px",spacingXl:"36px",chart1:"#ec4899",chart2:"#22d3ee",chart3:"#fbbf24",chart4:"#a78bfa",chart5:"#34d399",chart6:"#f472b6"},Yi={...ye,colorBg:"#fdf6ff",colorBgSubtle:"#fbf2ff",colorSurface:"#ffffff",colorSurfaceMuted:"#f4ecff",colorBorder:"#ead8ff",colorBorderSubtle:"rgba(168, 132, 232, 0.18)",colorText:"#3b1f56",colorTextMuted:"#7d6193",colorPrimary:"#a78bfa",colorPrimaryHover:"#8b5cf6",colorPrimaryText:"#ffffff",colorAccent:"#5eead4",colorAccentHover:"#2dd4bf",colorAccentText:"#0f3a35",colorFocusRing:"#a78bfa",colorSuccess:"#5eead4",colorWarning:"#fcd34d",colorDanger:"#fda4af",colorInfo:"#93c5fd",fontFamily:"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"8px",radiusSm:"12px",radiusMd:"20px",radiusLg:"28px",radiusButton:"16px",radiusInput:"16px",shadowSm:"0 4px 14px rgba(168, 132, 232, 0.12)",shadowMd:"0 18px 40px rgba(168, 132, 232, 0.18)",shadowLg:"0 28px 70px rgba(168, 132, 232, 0.22)",spacingXs:"6px",spacingS:"12px",spacingM:"18px",spacingL:"28px",spacingXl:"44px",chart1:"#a78bfa",chart2:"#5eead4",chart3:"#fcd34d",chart4:"#fda4af",chart5:"#93c5fd",chart6:"#f9a8d4"},Xi={...ye,colorBg:"#0f1730",colorBgSubtle:"#13204a",colorSurface:"rgba(255, 255, 255, 0.08)",colorSurfaceMuted:"rgba(255, 255, 255, 0.04)",colorBorder:"rgba(255, 255, 255, 0.18)",colorBorderSubtle:"rgba(255, 255, 255, 0.10)",colorText:"#f1f5ff",colorTextMuted:"#b6c3e6",colorPrimary:"#60a5fa",colorPrimaryHover:"#3b82f6",colorPrimaryText:"#0b132b",colorAccent:"#22d3ee",colorAccentHover:"#67e8f9",colorAccentText:"#0b132b",colorFocusRing:"#60a5fa",colorSuccess:"#34d399",colorWarning:"#fbbf24",colorDanger:"#fb7185",colorInfo:"#22d3ee",fontFamily:"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"6px",radiusSm:"10px",radiusMd:"16px",radiusLg:"24px",radiusButton:"12px",radiusInput:"12px",shadowSm:"0 1px 2px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.08)",shadowMd:"0 18px 50px rgba(7, 14, 33, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.10)",shadowLg:"0 28px 80px rgba(7, 14, 33, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12)",spacingXs:"4px",spacingS:"10px",spacingM:"16px",spacingL:"24px",spacingXl:"40px",chart1:"#60a5fa",chart2:"#22d3ee",chart3:"#a78bfa",chart4:"#f472b6",chart5:"#34d399",chart6:"#fbbf24"},Ji={...ye,colorBg:"#fef9c3",colorBgSubtle:"#fde68a",colorSurface:"#ffffff",colorSurfaceMuted:"#fef3c7",colorBorder:"#0a0a0a",colorBorderSubtle:"#0a0a0a",colorText:"#0a0a0a",colorTextMuted:"#3f3f46",colorPrimary:"#1d4ed8",colorPrimaryHover:"#1e40af",colorPrimaryText:"#ffffff",colorAccent:"#dc2626",colorAccentHover:"#b91c1c",colorAccentText:"#ffffff",colorFocusRing:"#0a0a0a",colorSuccess:"#16a34a",colorWarning:"#ea580c",colorDanger:"#dc2626",colorInfo:"#0891b2",fontFamily:"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",fontFamilyHeading:"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",fontFamilyMono:"'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontWeightHeading:"800",letterSpacingHeading:"-0.01em",headingTextTransform:"uppercase",radiusXs:"0px",radiusSm:"0px",radiusMd:"0px",radiusLg:"0px",radiusPill:"0px",radiusButton:"0px",radiusInput:"0px",borderWidth:"2px",shadowSm:"3px 3px 0 0 #0a0a0a",shadowMd:"6px 6px 0 0 #0a0a0a",shadowLg:"10px 10px 0 0 #0a0a0a",spacingXs:"4px",spacingS:"10px",spacingM:"16px",spacingL:"22px",spacingXl:"36px",buttonFontWeight:"800",buttonTextTransform:"uppercase",buttonLetterSpacing:"0.02em",chart1:"#dc2626",chart2:"#1d4ed8",chart3:"#16a34a",chart4:"#ea580c",chart5:"#7c3aed",chart6:"#0a0a0a"},Zi={...ye,colorBg:"#eff2f7",colorBgSubtle:"#e6ecf3",colorSurface:"#ffffff",colorSurfaceMuted:"#f4f7fb",colorBorder:"#d6deea",colorBorderSubtle:"rgba(13, 27, 58, 0.08)",colorText:"#0d1b3a",colorTextMuted:"#5a6a85",colorPrimary:"#003580",colorPrimaryHover:"#002a66",colorPrimaryText:"#ffffff",colorAccent:"#0095d6",colorAccentHover:"#0078ad",colorAccentText:"#ffffff",colorFocusRing:"#0095d6",colorSuccess:"#1b8f4f",colorWarning:"#c47e00",colorDanger:"#c8362b",colorInfo:"#0095d6",fontFamily:"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"3px",radiusSm:"4px",radiusMd:"6px",radiusLg:"10px",radiusButton:"4px",radiusInput:"4px",shadowSm:"0 1px 0 rgba(13, 27, 58, 0.04), 0 1px 3px rgba(13, 27, 58, 0.06)",shadowMd:"0 4px 16px rgba(13, 27, 58, 0.08), 0 1px 3px rgba(13, 27, 58, 0.04)",shadowLg:"0 16px 40px rgba(13, 27, 58, 0.12), 0 2px 6px rgba(13, 27, 58, 0.06)",spacingXs:"4px",spacingS:"8px",spacingM:"14px",spacingL:"20px",spacingXl:"32px",chart1:"#003580",chart2:"#0095d6",chart3:"#1b8f4f",chart4:"#c47e00",chart5:"#d43594",chart6:"#5a6a85"},aa={light:ye,dark:Ki,neon:Gi,pastel:Yi,glass:Xi,brutalist:Ji,skyline:Zi},tr={colorBg:"--rui-color-bg",colorBgSubtle:"--rui-color-bg-subtle",colorSurface:"--rui-color-surface",colorSurfaceMuted:"--rui-color-surface-muted",colorBorder:"--rui-color-border",colorBorderSubtle:"--rui-color-border-subtle",colorText:"--rui-color-text",colorTextMuted:"--rui-color-text-muted",colorPrimary:"--rui-color-primary",colorPrimaryHover:"--rui-color-primary-hover",colorPrimaryText:"--rui-color-primary-text",colorAccent:"--rui-color-accent",colorAccentHover:"--rui-color-accent-hover",colorAccentText:"--rui-color-accent-text",colorFocusRing:"--rui-color-focus-ring",colorSuccess:"--rui-color-success",colorWarning:"--rui-color-warning",colorDanger:"--rui-color-danger",colorInfo:"--rui-color-info",fontFamily:"--rui-font-family",fontFamilyHeading:"--rui-font-family-heading",fontFamilyMono:"--rui-font-family-mono",fontSizeBase:"--rui-font-size-base",fontSizeSm:"--rui-font-size-sm",fontSizeLg:"--rui-font-size-lg",fontSizeHeading:"--rui-font-size-heading",fontSizeTitle:"--rui-font-size-title",fontWeightBody:"--rui-font-weight-body",fontWeightHeading:"--rui-font-weight-heading",lineHeightBody:"--rui-line-height-body",lineHeightHeading:"--rui-line-height-heading",letterSpacingHeading:"--rui-letter-spacing-heading",headingTextTransform:"--rui-heading-text-transform",radiusXs:"--rui-radius-xs",radiusSm:"--rui-radius-sm",radiusMd:"--rui-radius-md",radiusLg:"--rui-radius-lg",radiusPill:"--rui-radius-pill",radiusButton:"--rui-radius-button",radiusInput:"--rui-radius-input",borderWidth:"--rui-border-width",shadowSm:"--rui-shadow-sm",shadowMd:"--rui-shadow-md",shadowLg:"--rui-shadow-lg",spacingXs:"--rui-spacing-xs",spacingS:"--rui-spacing-s",spacingM:"--rui-spacing-m",spacingL:"--rui-spacing-l",spacingXl:"--rui-spacing-xl",buttonFontWeight:"--rui-button-font-weight",buttonTextTransform:"--rui-button-text-transform",buttonLetterSpacing:"--rui-button-letter-spacing",buttonPaddingY:"--rui-button-padding-y",buttonPaddingX:"--rui-button-padding-x",transitionDuration:"--rui-transition-duration",chart1:"--rui-chart-1",chart2:"--rui-chart-2",chart3:"--rui-chart-3",chart4:"--rui-chart-4",chart5:"--rui-chart-5",chart6:"--rui-chart-6"};function na(t){if(!t)return{name:"light",tokens:ye};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:ro(JSON.parse(t))}}catch{return{name:"light",tokens:ye}}const r=aa[e];return r?{name:e,tokens:r}:{name:"light",tokens:ye}}return{name:"custom",tokens:ro(t)}}function ia(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[a,n]of Object.entries(tr))t.style.setProperty(n,r.tokens[a]);t.setAttribute("data-rui-theme",r.name)}function Qi(t,e){const r=[];for(const a of Object.keys(e)){const n=tr[a];if(!n)continue;const i=e[a];typeof i!="string"||i===""||(t.style.setProperty(n,i),r.push(a))}return r}function eo(t,e){for(const r of e){const a=tr[r];a&&t.style.removeProperty(a)}}function to(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t))if(r in tr&&a!=null)if(typeof a=="string"){if(a.trim()==="")continue;e[r]=a}else typeof a=="number"&&(e[r]=String(a));return e}function ro(t){return{...ye,...t}}const ao=`
|
|
154
|
+
`)}const ye={colorBg:"#ffffff",colorBgSubtle:"#f8fafc",colorSurface:"#ffffff",colorSurfaceMuted:"#f1f5f9",colorBorder:"#e2e8f0",colorBorderSubtle:"rgba(15, 23, 42, 0.08)",colorText:"#0f172a",colorTextMuted:"#475569",colorPrimary:"#6366f1",colorPrimaryHover:"#4f46e5",colorPrimaryText:"#ffffff",colorAccent:"#6366f1",colorAccentHover:"#4f46e5",colorAccentText:"#ffffff",colorFocusRing:"#6366f1",colorSuccess:"#10b981",colorWarning:"#f59e0b",colorDanger:"#ef4444",colorInfo:"#06b6d4",shadowSm:"0 1px 2px rgba(15, 23, 42, 0.06)",shadowMd:"0 6px 24px rgba(15, 23, 42, 0.08)",shadowLg:"0 18px 60px rgba(15, 23, 42, 0.12)",borderWidth:"1px",chart1:"#6366f1",chart2:"#10b981",chart3:"#f59e0b",chart4:"#ef4444",chart5:"#06b6d4",chart6:"#8b5cf6",...{fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyHeading:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},...{fontSizeBase:"14px",fontSizeSm:"12px",fontSizeLg:"16px",fontSizeHeading:"16px",fontSizeTitle:"22px",fontWeightBody:"400",fontWeightHeading:"700",lineHeightBody:"1.5",lineHeightHeading:"1.2",letterSpacingHeading:"0",headingTextTransform:"none"},...{spacingXs:"4px",spacingS:"8px",spacingM:"12px",spacingL:"20px",spacingXl:"32px"},...{radiusXs:"4px",radiusSm:"6px",radiusMd:"10px",radiusLg:"16px",radiusPill:"999px",radiusButton:"6px",radiusInput:"6px"},...{buttonFontWeight:"600",buttonTextTransform:"none",buttonLetterSpacing:"0",buttonPaddingY:"8px",buttonPaddingX:"14px"},...{transitionDuration:"120ms"}},Zi={...ye,colorBg:"#0b1220",colorBgSubtle:"#0f172a",colorSurface:"#111827",colorSurfaceMuted:"#1e293b",colorBorder:"#1f2937",colorBorderSubtle:"rgba(248, 250, 252, 0.08)",colorText:"#f8fafc",colorTextMuted:"#94a3b8",colorPrimary:"#818cf8",colorPrimaryHover:"#6366f1",colorPrimaryText:"#0b1220",colorAccent:"#818cf8",colorAccentHover:"#6366f1",colorAccentText:"#0b1220",colorFocusRing:"#818cf8",shadowSm:"0 1px 2px rgba(0, 0, 0, 0.4)",shadowMd:"0 8px 24px rgba(0, 0, 0, 0.4)",shadowLg:"0 22px 60px rgba(0, 0, 0, 0.55)"},Qi={...ye,colorBg:"#05060f",colorBgSubtle:"#0a0c1c",colorSurface:"#0d1024",colorSurfaceMuted:"#161a36",colorBorder:"#2a2f6b",colorBorderSubtle:"rgba(236, 72, 153, 0.18)",colorText:"#f5f3ff",colorTextMuted:"#a5b4fc",colorPrimary:"#ec4899",colorPrimaryHover:"#f472b6",colorPrimaryText:"#05060f",colorAccent:"#22d3ee",colorAccentHover:"#67e8f9",colorAccentText:"#05060f",colorFocusRing:"#ec4899",colorSuccess:"#34d399",colorWarning:"#fbbf24",colorDanger:"#f87171",colorInfo:"#22d3ee",fontFamily:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontFamilyHeading:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontFamilyMono:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",letterSpacingHeading:"0.02em",radiusXs:"2px",radiusSm:"2px",radiusMd:"4px",radiusLg:"6px",radiusButton:"2px",radiusInput:"2px",shadowSm:"0 0 0 1px rgba(236, 72, 153, 0.25), 0 0 12px rgba(34, 211, 238, 0.18)",shadowMd:"0 0 0 1px rgba(236, 72, 153, 0.35), 0 0 28px rgba(34, 211, 238, 0.22)",shadowLg:"0 0 0 1px rgba(236, 72, 153, 0.45), 0 0 48px rgba(34, 211, 238, 0.35)",spacingXs:"4px",spacingS:"8px",spacingM:"14px",spacingL:"22px",spacingXl:"36px",chart1:"#ec4899",chart2:"#22d3ee",chart3:"#fbbf24",chart4:"#a78bfa",chart5:"#34d399",chart6:"#f472b6"},eo={...ye,colorBg:"#fdf6ff",colorBgSubtle:"#fbf2ff",colorSurface:"#ffffff",colorSurfaceMuted:"#f4ecff",colorBorder:"#ead8ff",colorBorderSubtle:"rgba(168, 132, 232, 0.18)",colorText:"#3b1f56",colorTextMuted:"#7d6193",colorPrimary:"#a78bfa",colorPrimaryHover:"#8b5cf6",colorPrimaryText:"#ffffff",colorAccent:"#5eead4",colorAccentHover:"#2dd4bf",colorAccentText:"#0f3a35",colorFocusRing:"#a78bfa",colorSuccess:"#5eead4",colorWarning:"#fcd34d",colorDanger:"#fda4af",colorInfo:"#93c5fd",fontFamily:"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"8px",radiusSm:"12px",radiusMd:"20px",radiusLg:"28px",radiusButton:"16px",radiusInput:"16px",shadowSm:"0 4px 14px rgba(168, 132, 232, 0.12)",shadowMd:"0 18px 40px rgba(168, 132, 232, 0.18)",shadowLg:"0 28px 70px rgba(168, 132, 232, 0.22)",spacingXs:"6px",spacingS:"12px",spacingM:"18px",spacingL:"28px",spacingXl:"44px",chart1:"#a78bfa",chart2:"#5eead4",chart3:"#fcd34d",chart4:"#fda4af",chart5:"#93c5fd",chart6:"#f9a8d4"},to={...ye,colorBg:"#0f1730",colorBgSubtle:"#13204a",colorSurface:"rgba(255, 255, 255, 0.08)",colorSurfaceMuted:"rgba(255, 255, 255, 0.04)",colorBorder:"rgba(255, 255, 255, 0.18)",colorBorderSubtle:"rgba(255, 255, 255, 0.10)",colorText:"#f1f5ff",colorTextMuted:"#b6c3e6",colorPrimary:"#60a5fa",colorPrimaryHover:"#3b82f6",colorPrimaryText:"#0b132b",colorAccent:"#22d3ee",colorAccentHover:"#67e8f9",colorAccentText:"#0b132b",colorFocusRing:"#60a5fa",colorSuccess:"#34d399",colorWarning:"#fbbf24",colorDanger:"#fb7185",colorInfo:"#22d3ee",fontFamily:"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"6px",radiusSm:"10px",radiusMd:"16px",radiusLg:"24px",radiusButton:"12px",radiusInput:"12px",shadowSm:"0 1px 2px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.08)",shadowMd:"0 18px 50px rgba(7, 14, 33, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.10)",shadowLg:"0 28px 80px rgba(7, 14, 33, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12)",spacingXs:"4px",spacingS:"10px",spacingM:"16px",spacingL:"24px",spacingXl:"40px",chart1:"#60a5fa",chart2:"#22d3ee",chart3:"#a78bfa",chart4:"#f472b6",chart5:"#34d399",chart6:"#fbbf24"},ro={...ye,colorBg:"#fef9c3",colorBgSubtle:"#fde68a",colorSurface:"#ffffff",colorSurfaceMuted:"#fef3c7",colorBorder:"#0a0a0a",colorBorderSubtle:"#0a0a0a",colorText:"#0a0a0a",colorTextMuted:"#3f3f46",colorPrimary:"#1d4ed8",colorPrimaryHover:"#1e40af",colorPrimaryText:"#ffffff",colorAccent:"#dc2626",colorAccentHover:"#b91c1c",colorAccentText:"#ffffff",colorFocusRing:"#0a0a0a",colorSuccess:"#16a34a",colorWarning:"#ea580c",colorDanger:"#dc2626",colorInfo:"#0891b2",fontFamily:"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",fontFamilyHeading:"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",fontFamilyMono:"'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontWeightHeading:"800",letterSpacingHeading:"-0.01em",headingTextTransform:"uppercase",radiusXs:"0px",radiusSm:"0px",radiusMd:"0px",radiusLg:"0px",radiusPill:"0px",radiusButton:"0px",radiusInput:"0px",borderWidth:"2px",shadowSm:"3px 3px 0 0 #0a0a0a",shadowMd:"6px 6px 0 0 #0a0a0a",shadowLg:"10px 10px 0 0 #0a0a0a",spacingXs:"4px",spacingS:"10px",spacingM:"16px",spacingL:"22px",spacingXl:"36px",buttonFontWeight:"800",buttonTextTransform:"uppercase",buttonLetterSpacing:"0.02em",chart1:"#dc2626",chart2:"#1d4ed8",chart3:"#16a34a",chart4:"#ea580c",chart5:"#7c3aed",chart6:"#0a0a0a"},ao={...ye,colorBg:"#eff2f7",colorBgSubtle:"#e6ecf3",colorSurface:"#ffffff",colorSurfaceMuted:"#f4f7fb",colorBorder:"#d6deea",colorBorderSubtle:"rgba(13, 27, 58, 0.08)",colorText:"#0d1b3a",colorTextMuted:"#5a6a85",colorPrimary:"#003580",colorPrimaryHover:"#002a66",colorPrimaryText:"#ffffff",colorAccent:"#0095d6",colorAccentHover:"#0078ad",colorAccentText:"#ffffff",colorFocusRing:"#0095d6",colorSuccess:"#1b8f4f",colorWarning:"#c47e00",colorDanger:"#c8362b",colorInfo:"#0095d6",fontFamily:"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"3px",radiusSm:"4px",radiusMd:"6px",radiusLg:"10px",radiusButton:"4px",radiusInput:"4px",shadowSm:"0 1px 0 rgba(13, 27, 58, 0.04), 0 1px 3px rgba(13, 27, 58, 0.06)",shadowMd:"0 4px 16px rgba(13, 27, 58, 0.08), 0 1px 3px rgba(13, 27, 58, 0.04)",shadowLg:"0 16px 40px rgba(13, 27, 58, 0.12), 0 2px 6px rgba(13, 27, 58, 0.06)",spacingXs:"4px",spacingS:"8px",spacingM:"14px",spacingL:"20px",spacingXl:"32px",chart1:"#003580",chart2:"#0095d6",chart3:"#1b8f4f",chart4:"#c47e00",chart5:"#d43594",chart6:"#5a6a85"},ia={light:ye,dark:Zi,neon:Qi,pastel:eo,glass:to,brutalist:ro,skyline:ao},rr={colorBg:"--rui-color-bg",colorBgSubtle:"--rui-color-bg-subtle",colorSurface:"--rui-color-surface",colorSurfaceMuted:"--rui-color-surface-muted",colorBorder:"--rui-color-border",colorBorderSubtle:"--rui-color-border-subtle",colorText:"--rui-color-text",colorTextMuted:"--rui-color-text-muted",colorPrimary:"--rui-color-primary",colorPrimaryHover:"--rui-color-primary-hover",colorPrimaryText:"--rui-color-primary-text",colorAccent:"--rui-color-accent",colorAccentHover:"--rui-color-accent-hover",colorAccentText:"--rui-color-accent-text",colorFocusRing:"--rui-color-focus-ring",colorSuccess:"--rui-color-success",colorWarning:"--rui-color-warning",colorDanger:"--rui-color-danger",colorInfo:"--rui-color-info",fontFamily:"--rui-font-family",fontFamilyHeading:"--rui-font-family-heading",fontFamilyMono:"--rui-font-family-mono",fontSizeBase:"--rui-font-size-base",fontSizeSm:"--rui-font-size-sm",fontSizeLg:"--rui-font-size-lg",fontSizeHeading:"--rui-font-size-heading",fontSizeTitle:"--rui-font-size-title",fontWeightBody:"--rui-font-weight-body",fontWeightHeading:"--rui-font-weight-heading",lineHeightBody:"--rui-line-height-body",lineHeightHeading:"--rui-line-height-heading",letterSpacingHeading:"--rui-letter-spacing-heading",headingTextTransform:"--rui-heading-text-transform",radiusXs:"--rui-radius-xs",radiusSm:"--rui-radius-sm",radiusMd:"--rui-radius-md",radiusLg:"--rui-radius-lg",radiusPill:"--rui-radius-pill",radiusButton:"--rui-radius-button",radiusInput:"--rui-radius-input",borderWidth:"--rui-border-width",shadowSm:"--rui-shadow-sm",shadowMd:"--rui-shadow-md",shadowLg:"--rui-shadow-lg",spacingXs:"--rui-spacing-xs",spacingS:"--rui-spacing-s",spacingM:"--rui-spacing-m",spacingL:"--rui-spacing-l",spacingXl:"--rui-spacing-xl",buttonFontWeight:"--rui-button-font-weight",buttonTextTransform:"--rui-button-text-transform",buttonLetterSpacing:"--rui-button-letter-spacing",buttonPaddingY:"--rui-button-padding-y",buttonPaddingX:"--rui-button-padding-x",transitionDuration:"--rui-transition-duration",chart1:"--rui-chart-1",chart2:"--rui-chart-2",chart3:"--rui-chart-3",chart4:"--rui-chart-4",chart5:"--rui-chart-5",chart6:"--rui-chart-6"};function oa(t){if(!t)return{name:"light",tokens:ye};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:so(JSON.parse(t))}}catch{return{name:"light",tokens:ye}}const r=ia[e];return r?{name:e,tokens:r}:{name:"light",tokens:ye}}return{name:"custom",tokens:so(t)}}function sa(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[a,n]of Object.entries(rr))t.style.setProperty(n,r.tokens[a]);t.setAttribute("data-rui-theme",r.name)}function no(t,e){const r=[];for(const a of Object.keys(e)){const n=rr[a];if(!n)continue;const i=e[a];typeof i!="string"||i===""||(t.style.setProperty(n,i),r.push(a))}return r}function io(t,e){for(const r of e){const a=rr[r];a&&t.style.removeProperty(a)}}function oo(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t))if(r in rr&&a!=null)if(typeof a=="string"){if(a.trim()==="")continue;e[r]=a}else typeof a=="number"&&(e[r]=String(a));return e}function so(t){return{...ye,...t}}const lo=`
|
|
155
155
|
:host {
|
|
156
156
|
display: block;
|
|
157
157
|
box-sizing: border-box;
|
|
@@ -8032,7 +8032,7 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
|
|
|
8032
8032
|
}
|
|
8033
8033
|
.rui-lightbox-thumb img { display: block; width: 100%; height: auto; }
|
|
8034
8034
|
.rui-lightbox-thumb:hover { border-color: var(--rui-color-primary); }
|
|
8035
|
-
`,oa="theme",kt="streaming",sa="response",it="showerrors",no="route";function hg(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),n={};if(typeof window<"u"&&window.location){const i=window.location.search||"";if(i){const o=new URLSearchParams(i.startsWith("?")?i.slice(1):i);for(const[s,c]of o)n[s]=c}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function bg(t,e){if(!t||!e||typeof t!="object"||typeof e!="object")return!1;const r=t,a=e;return r.path!==a.path||r.pattern!==a.pattern?!1:io(r.params??{},a.params??{})&&io(r.query??{},a.query??{})}function io(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(t[n]!==e[n])return!1;return!0}let la=null,rr=null,vg=0;function yg(){if(rr===!1)return null;if(la)return la;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return rr=!1,null;const t=new CSSStyleSheet;return t.replaceSync(ao),la=t,rr=!0,t}catch{return rr=!1,null}}class St extends HTMLElement{constructor(){super();D(this,"state",new Xn);D(this,"router",new ii);D(this,"library",pt);D(this,"http",new Zn);D(this,"effectRunner");D(this,"renderer");D(this,"context");D(this,"root");D(this,"rootEl");D(this,"errorEl");D(this,"currentResponse","");D(this,"pendingCompiled",null);D(this,"compiledSourceId",null);D(this,"renderScheduled",!1);D(this,"programDirty",!0);D(this,"lastRenderDeps",null);D(this,"pendingChangedPaths",new Set);D(this,"forceFullRender",!1);D(this,"parseErrors",[]);D(this,"scriptThemeKeys",[]);D(this,"devtoolsId",`aktion-app-${vg+=1}`);D(this,"devtoolsCommitId",0);D(this,"devtoolsRegistered",!1);D(this,"warnedStateWriteDuringRender",!1);this.root=this.attachShadow({mode:"open"}),this.errorEl=document.createElement("div"),this.errorEl.className="rui-error-banner",this.errorEl.hidden=!0,this.rootEl=document.createElement("div"),this.rootEl.className="rui-root";const r=yg();if(r)try{this.root.adoptedStyleSheets=[r],this.root.append(this.errorEl,this.rootEl)}catch{this.root.append(this.buildInlineStyle(),this.errorEl,this.rootEl)}else this.root.append(this.buildInlineStyle(),this.errorEl,this.rootEl);const a=n=>{this.dispatchEvent(new CustomEvent("assistant-message",{detail:{message:n},bubbles:!0,composed:!0}))};this.effectRunner=new ji({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i),onEffectEvent:n=>this.emitDevtoolsEffect(n)}),this.context=Hr(this.state,{router:this.router,library:this.library,http:this.http,strict:this.hasAttribute("strict"),notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i)}),this.renderer=new Ui({library:this.library,state:this.state,router:this.router,onAssistantMessage:a,evaluationContext:()=>this.context,mountInstanceEffects:(n,i,o)=>this.effectRunner.syncInstanceEffects(n,i,o),unmountInstanceEffects:n=>this.effectRunner.unmountInstance(n),unmountInstanceHooks:n=>zi(this.context,n)}),this.state.subscribe(n=>{for(const i of n)this.pendingChangedPaths.add(i);Zr()&&Qr({kind:"state",appId:this.devtoolsId,snapshot:this.state.snapshot(),changedPaths:[...n],time:pe()}),(this.lastRenderDeps===null||mt(n,this.lastRenderDeps))&&this.scheduleRender()}),this.router.subscribe(n=>this.handleRouteChange(n))}static get observedAttributes(){return[oa,kt,sa,it]}connectedCallback(){hs(this.root),this.registerWithDevtools(),this.applyThemeFromAttribute(),this.startRouter();const r=this.getAttribute(sa);if(r!==null&&r!==""&&r!==this.currentResponse){this.setResponse(r);return}if(!this.currentResponse){const a=(this.textContent??"").trim();if(a){this.setResponse(a);return}}this.currentResponse&&(this.programDirty=!0,this.scheduleRender())}disconnectedCallback(){this.effectRunner.reset(),this.context&&Vr(this.context),this.router.stop(),this.devtoolsRegistered&&(xf(this.devtoolsId),this.devtoolsRegistered=!1)}attributeChangedCallback(r,a,n){if(r===oa&&this.applyThemeFromAttribute(),r===kt&&(this.updateErrorBanner(),this.scheduleRender()),r===it&&this.updateErrorBanner(),r===sa){const i=n??"";i!==this.currentResponse&&this.setResponse(i)}}registerHttpInterceptors(r){this.http.registerInterceptors(r)}setResponse(r){r!==this.currentResponse&&(this.currentResponse=r,this.pendingCompiled=null,this.compiledSourceId=null,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.scheduleRender())}serializeState(){return this.state.snapshot()}hydrateState(r){this.state.hydrate(r),this.scheduleRender()}applyDelta(r){const a=this.state.snapshot(),n=ts(this.currentResponse,r);return Object.assign(a,n.stateUpdates),this.loadSnapshot({programText:n.programText,state:a}),n.warnings}loadSnapshot(r){this.currentResponse=r.programText,this.pendingCompiled=null,this.compiledSourceId=null,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.state.hydrate(r.state),this.scheduleRender()}mountCompiled(r,a){if(!Ba(r)){console.error("[aktion] mountCompiled() expected a CompiledProgram (from linkProject() or compileLite()); ignoring the call.");return}this.currentResponse=r.source,this.compiledSourceId=r.path,this.pendingCompiled={...r.program,errors:[...r.program.errors]},this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],a&&this.state.hydrate(a),this.scheduleRender()}get sourceId(){return this.compiledSourceId}appendChunk(r){if(r==null)return;const a=typeof r=="string"?r:String(r);a!==""&&(this.currentResponse+=a,this.programDirty=!0,this.scheduleRender())}setTheme(r){ia(this,na(r)),this.scriptThemeKeys=[],this.scheduleRender()}registerComponents(r,a){this.library=Ha(this.library,{components:r,root:a}),this.renderer.setLibrary(this.library),this.scheduleRender()}getSystemPrompt(r){return ta(this.library,r??{})}navigate(r){this.router.navigate(r)}get route(){return this.router.getPath()}clear(){this.currentResponse="",this.pendingCompiled=null,this.compiledSourceId=null,this.state.rebind([]),this.effectRunner.reset(),this.renderer.reset(),this.programDirty=!0,this.parseErrors=[],this.errorEl.hidden=!0,this.errorEl.replaceChildren(),this.rootEl.replaceChildren(),this.router.setActiveMatch(null,{})}get response(){return this.currentResponse}set response(r){this.setResponse(r)}get streaming(){return oo(this.getAttribute(kt))}set streaming(r){r?this.setAttribute(kt,"true"):this.removeAttribute(kt)}get showErrors(){return oo(this.getAttribute(it))}set showErrors(r){r?this.setAttribute(it,"true"):this.removeAttribute(it)}emitCustomEvent(r,a){this.dispatchEvent(new CustomEvent(r,{detail:a,bubbles:!0,composed:!0}))}registerWithDevtools(){if(this.devtoolsRegistered)return;const r=Jt();if(!r)return;const a={id:this.devtoolsId,label:this.getAttribute("data-devtools-label")||this.id||this.devtoolsId,element:this,getState:()=>this.state.snapshot(),setState:(n,i)=>this.applyDevtoolsStateEdit(n,i),getProgram:()=>this.currentResponse,forceRender:()=>this.requestFullRender()};r.registerApp(a),this.devtoolsRegistered=!0}connectDevtools(){this.registerWithDevtools(),this.devtoolsRegistered&&this.requestFullRender()}applyDevtoolsStateEdit(r,a){const n=r.indexOf(".");if(n<0){this.state.set(r,a);return}const i=r.slice(0,n),o=r.slice(n+1).split(".");this.state.setPath(i,o,a)}emitDevtoolsEffect(r){Qr({kind:"effect",appId:this.devtoolsId,time:pe(),...r})}buildInlineStyle(){const r=document.createElement("style");return r.textContent=ao,r}startRouter(){const r=this.getAttribute("router-mode"),a=this.getAttribute("router-base");(r||a)&&this.router.configure({mode:r==="history"?"history":r==="hash"?"hash":void 0,...a!==null?{basePath:a}:{}}),this.router.start(),this.writeRouteState()}writeRouteState(){const r=hg(this.router);bg(this.state.get(no),r)||this.state.set(no,r)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender()}applyThemeFromAttribute(){const r=this.getAttribute(oa);ia(this,na(r)),this.scriptThemeKeys=[]}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(eo(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let a;try{a=r()}catch{return}if(!Kn(a))return;const n=to(a.tokens);Object.keys(n).length!==0&&(this.scriptThemeKeys=Qi(this,n))}scheduleRender(){this.renderScheduled||(this.renderScheduled=!0,queueMicrotask(()=>this.renderNow()))}requestFullRender(){this.forceFullRender=!0,this.scheduleRender()}renderNow(){if(this.renderScheduled=!1,!this.isConnected)return;this.programDirty&&(this.replan(),this.programDirty=!1),this.context.budget&&_r(this.context.budget),this.devtoolsRegistered||this.registerWithDevtools();const r=Zr();this.renderer.setProfiling(r);const a=r?pe():0,n=new Set,i=this.context.trackedState;this.context.trackedState=n;let o=!1;this.state.beginRenderPass();try{this.applyScriptThemeOverrides(),vi(this.context);const s=this.context.bindings.get("aktion");let c=null;if(s)try{c=s()}catch(g){if(g instanceof Be){this.handleRuntimeBudgetError(g);return}console.error("[aktion] entry point evaluation error",g)}const u=this.pendingChangedPaths;this.pendingChangedPaths=new Set;const p=!this.forceFullRender&&this.lastRenderDeps!==null;this.forceFullRender=!1,this.renderer.beginRender({changedPaths:u,memoize:p});const d=this.captureFocus();let m;try{m=this.renderer.render(c)}catch(g){if(this.renderer.endRender(),g instanceof Be){this.handleRuntimeBudgetError(g);return}throw g}if(Pf(this.rootEl,m),this.renderer.endRender(),this.restoreFocus(d),o=!0,r){const g=this.renderer.drainProfilerRecords();let b=0,h=0;for(const v of g)v.phase==="memo"?h+=1:b+=1;Qr({kind:"commit",appId:this.devtoolsId,commitId:this.devtoolsCommitId,startTime:a,duration:pe()-a,changedPaths:[...u],fullRender:!p,initial:this.devtoolsCommitId===0,components:g,rendered:b,memoized:h}),this.devtoolsCommitId+=1}}finally{this.context.trackedState=i,this.lastRenderDeps=o?n:null,this.state.endRenderPass()&&this.warnStateWriteDuringRender()}}warnStateWriteDuringRender(){this.warnedStateWriteDuringRender||(this.warnedStateWriteDuringRender=!0,console.warn("[aktion] A reactive `$state` write happened during render and was applied WITHOUT scheduling a re-render, to prevent an infinite render loop. This usually means a `$name = …` assignment is running in render position — e.g. `$user = {…}` at the top of a lowercase `function` that's invoked to build the UI (`$app(page())`), where the function runs as an action and re-writes the atom every render. Seed component-local state with a PascalCase component (so `$name = …` becomes a set-once per-instance declaration) or the `$state` hook, and only write state from event handlers / effects."))}handleRuntimeBudgetError(r){const a=`Runtime aborted (${r.kind}): ${r.message}`;this.parseErrors.includes(a)||(this.parseErrors=[...this.parseErrors,a]),this.updateErrorBanner(),this.streaming||this.dispatchEvent(new CustomEvent("error",{detail:{errors:[{line:0,column:0,message:r.message}]},bubbles:!0,composed:!0}))}captureFocus(){const r=this.root.activeElement;if(!r||!this.rootEl.contains(r))return null;const a=r.id||null;if(!a)return null;const n={id:a,tagName:r.tagName};return(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(n.selectionStart=r.selectionStart,n.selectionEnd=r.selectionEnd,n.selectionDirection=r.selectionDirection??null),n}restoreFocus(r){if(!r)return;const a=this.rootEl.querySelector(`#${xg(r.id)}`);!a||a.tagName!==r.tagName||this.root.activeElement===a||(a.focus(),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&r.selectionStart!=null&&r.selectionEnd!=null&&kg(a,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.lastRenderDeps=null,this.warnedStateWriteDuringRender=!1,this.context&&Vr(this.context),this.context=Hr(this.state,{router:this.router,library:this.library,http:this.http,strict:this.hasAttribute("strict"),notify:()=>this.requestFullRender(),onEmit:(i,o)=>this.emitCustomEvent(i,o)});const r=this.pendingCompiled??ge(this.currentResponse);this.pendingCompiled=null;const a=mr(r,this.library);a.length>0&&(r.errors=[...r.errors,...a]),this.context.budget&&_r(this.context.budget);try{yi(r,this.context)}catch(i){if(i instanceof Be)r.errors=[...r.errors,{line:0,column:0,message:i.message}];else throw i}const n=[...this.context.effectDecls.values()];n.length>0&&this.effectRunner.syncEffects(n,()=>this.context),this.writeRouteState(),this.parseErrors=[...r.errors.map(i=>`Line ${i.line}: ${i.message}`),...this.effectRunner.getErrors()],this.updateErrorBanner(),r.errors.length>0&&!this.streaming&&this.dispatchEvent(new CustomEvent("error",{detail:{errors:r.errors},bubbles:!0,composed:!0}))}updateErrorBanner(){if(!this.showErrors||this.streaming||this.parseErrors.length===0){this.errorEl.hidden=!0,this.errorEl.replaceChildren();return}this.errorEl.hidden=!1;const r=document.createElement("div");r.textContent=`${this.parseErrors.length} parse issue${this.parseErrors.length===1?"":"s"} (rendered partial UI):`;const a=document.createElement("ul");for(const n of this.parseErrors.slice(0,5)){const i=document.createElement("li");i.textContent=n,a.append(i)}this.errorEl.replaceChildren(r,a)}}D(St,"tagName","aktion-app");function xg(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const wg=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function kg(t,e,r,a){if(t instanceof HTMLInputElement&&wg.has(t.type)){const n=t.type;try{t.type="text",t.setSelectionRange(e,r,a)}catch{}finally{t.type=n}return}try{t.setSelectionRange(e,r,a)}catch{}}function oo(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===it}function so(){customElements.get(St.tagName)||customElements.define(St.tagName,St)}const Sg=[{name:"App",description:"Top-level `$app(...)` root — every program needs one.",template:'$app(Column([\n ${1:Card([CardHeader("${2:Hello}")])}\n]))'},{name:"Card",description:"Card with header + body block.",template:`card\${1} = Card([
|
|
8035
|
+
`,la="theme",St="streaming",ca="response",it="showerrors",ot="src",co="route";function Cg(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),n={};if(typeof window<"u"&&window.location){const i=window.location.search||"";if(i){const o=new URLSearchParams(i.startsWith("?")?i.slice(1):i);for(const[s,c]of o)n[s]=c}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function Ag(t,e){if(!t||!e||typeof t!="object"||typeof e!="object")return!1;const r=t,a=e;return r.path!==a.path||r.pattern!==a.pattern?!1:uo(r.params??{},a.params??{})&&uo(r.query??{},a.query??{})}function uo(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(t[n]!==e[n])return!1;return!0}let ua=null,ar=null,Tg=0;function Mg(){if(ar===!1)return null;if(ua)return ua;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return ar=!1,null;const t=new CSSStyleSheet;return t.replaceSync(lo),ua=t,ar=!0,t}catch{return ar=!1,null}}class $t extends HTMLElement{constructor(){super();z(this,"state",new ei);z(this,"router",new ci);z(this,"library",mt);z(this,"http",new ri);z(this,"effectRunner");z(this,"renderer");z(this,"context");z(this,"root");z(this,"rootEl");z(this,"errorEl");z(this,"currentResponse","");z(this,"pendingCompiled",null);z(this,"compiledSourceId",null);z(this,"renderScheduled",!1);z(this,"programDirty",!0);z(this,"lastRenderDeps",null);z(this,"pendingChangedPaths",new Set);z(this,"forceFullRender",!1);z(this,"parseErrors",[]);z(this,"srcDiagnostics",[]);z(this,"srcLoadToken",0);z(this,"hasConnected",!1);z(this,"scriptThemeKeys",[]);z(this,"devtoolsId",`aktion-app-${Tg+=1}`);z(this,"devtoolsCommitId",0);z(this,"devtoolsRegistered",!1);z(this,"warnedStateWriteDuringRender",!1);this.root=this.attachShadow({mode:"open"}),this.errorEl=document.createElement("div"),this.errorEl.className="rui-error-banner",this.errorEl.hidden=!0,this.rootEl=document.createElement("div"),this.rootEl.className="rui-root";const r=Mg();if(r)try{this.root.adoptedStyleSheets=[r],this.root.append(this.errorEl,this.rootEl)}catch{this.root.append(this.buildInlineStyle(),this.errorEl,this.rootEl)}else this.root.append(this.buildInlineStyle(),this.errorEl,this.rootEl);const a=n=>{this.dispatchEvent(new CustomEvent("assistant-message",{detail:{message:n},bubbles:!0,composed:!0}))};this.effectRunner=new Fi({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i),onEffectEvent:n=>this.emitDevtoolsEffect(n)}),this.context=Wr(this.state,{router:this.router,library:this.library,http:this.http,strict:this.hasAttribute("strict"),notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i)}),this.renderer=new qi({library:this.library,state:this.state,router:this.router,onAssistantMessage:a,evaluationContext:()=>this.context,mountInstanceEffects:(n,i,o)=>this.effectRunner.syncInstanceEffects(n,i,o),unmountInstanceEffects:n=>this.effectRunner.unmountInstance(n),unmountInstanceHooks:n=>Bi(this.context,n)}),this.state.subscribe(n=>{for(const i of n)this.pendingChangedPaths.add(i);ea()&&ta({kind:"state",appId:this.devtoolsId,snapshot:this.state.snapshot(),changedPaths:[...n],time:pe()}),(this.lastRenderDeps===null||ft(n,this.lastRenderDeps))&&this.scheduleRender()}),this.router.subscribe(n=>this.handleRouteChange(n))}static get observedAttributes(){return[la,St,ca,it,ot]}connectedCallback(){this.hasConnected=!0,$s(this.root),this.registerWithDevtools(),this.applyThemeFromAttribute(),this.startRouter();const r=this.getAttribute(ca);if(r!==null&&r!==""&&r!==this.currentResponse){this.setResponse(r);return}const a=this.getAttribute(ot);if(a&&!this.currentResponse){this.loadFromSrc(a);return}if(!this.currentResponse){const n=(this.textContent??"").trim();if(n){this.setResponse(n);return}}this.currentResponse&&(this.programDirty=!0,this.scheduleRender())}disconnectedCallback(){this.effectRunner.reset(),this.context&&qr(this.context),this.router.stop(),this.devtoolsRegistered&&(Mf(this.devtoolsId),this.devtoolsRegistered=!1)}attributeChangedCallback(r,a,n){if(r===la&&this.applyThemeFromAttribute(),r===St&&(this.updateErrorBanner(),this.scheduleRender()),r===it&&this.updateErrorBanner(),r===ca){const i=n??"";i!==this.currentResponse&&this.setResponse(i)}r===ot&&this.hasConnected&&n&&this.loadFromSrc(n)}registerHttpInterceptors(r){this.http.registerInterceptors(r)}setResponse(r){r!==this.currentResponse&&(this.currentResponse=r,this.pendingCompiled=null,this.compiledSourceId=null,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.srcDiagnostics=[],this.scheduleRender())}serializeState(){return this.state.snapshot()}hydrateState(r){this.state.hydrate(r),this.scheduleRender()}applyDelta(r){const a=this.state.snapshot(),n=cs(this.currentResponse,r);return Object.assign(a,n.stateUpdates),this.loadSnapshot({programText:n.programText,state:a}),n.warnings}loadSnapshot(r){this.currentResponse=r.programText,this.pendingCompiled=null,this.compiledSourceId=null,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.srcDiagnostics=[],this.state.hydrate(r.state),this.scheduleRender()}mountCompiled(r,a){if(!Ba(r)){console.error("[aktion] mountCompiled() expected a CompiledProgram (from linkProject() or compileLite()); ignoring the call.");return}this.currentResponse=r.source,this.compiledSourceId=r.path,this.pendingCompiled={...r.program,errors:[...r.program.errors]},this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.srcDiagnostics=[],a&&this.state.hydrate(a),this.scheduleRender()}get sourceId(){return this.compiledSourceId}get src(){return this.getAttribute(ot)}set src(r){r===null?this.removeAttribute(ot):this.setAttribute(ot,r)}async loadFromSrc(r){const a=this.srcLoadToken+=1;this.srcDiagnostics=[];let n;try{const s=typeof document<"u"?document.baseURI:void 0;n=new URL(r,s).href}catch{this.reportSrcError(`Invalid src "${r}".`);return}let i;try{if(typeof fetch!="function")throw new Error("global fetch is unavailable");const s=await fetch(n);if(!s.ok)throw new Error(`HTTP ${s.status}`);i=await s.text()}catch(s){if(this.isStaleSrcLoad(a))return;this.reportSrcError(`Failed to load "${r}": ${mo(s)}`);return}if(this.isStaleSrcLoad(a))return;let o;try{o=await Va({entry:n,files:{[n]:i}})}catch(s){if(this.isStaleSrcLoad(a))return;this.reportSrcError(`Failed to link "${r}": ${mo(s)}`);return}this.isStaleSrcLoad(a)||(this.mountCompiled({__aktionCompiled:Nt,program:o.program,source:o.source,path:n}),this.srcDiagnostics=o.diagnostics.filter(s=>s.severity!=="warning").map(s=>s.line>0?`Line ${s.line}: ${s.message}`:s.message))}isStaleSrcLoad(r){return r!==this.srcLoadToken||!this.isConnected}reportSrcError(r){this.srcDiagnostics.includes(r)||(this.srcDiagnostics=[...this.srcDiagnostics,r]),this.updateErrorBanner(),this.dispatchEvent(new CustomEvent("error",{detail:{errors:[{line:0,column:0,message:r}]},bubbles:!0,composed:!0}))}appendChunk(r){if(r==null)return;const a=typeof r=="string"?r:String(r);a!==""&&(this.currentResponse+=a,this.programDirty=!0,this.scheduleRender())}setTheme(r){sa(this,oa(r)),this.scriptThemeKeys=[],this.scheduleRender()}registerComponents(r,a){this.library=Ka(this.library,{components:r,root:a}),this.renderer.setLibrary(this.library),this.scheduleRender()}getSystemPrompt(r){return aa(this.library,r??{})}navigate(r){this.router.navigate(r)}get route(){return this.router.getPath()}clear(){this.currentResponse="",this.pendingCompiled=null,this.compiledSourceId=null,this.state.rebind([]),this.effectRunner.reset(),this.renderer.reset(),this.programDirty=!0,this.parseErrors=[],this.srcDiagnostics=[],this.errorEl.hidden=!0,this.errorEl.replaceChildren(),this.rootEl.replaceChildren(),this.router.setActiveMatch(null,{})}get response(){return this.currentResponse}set response(r){this.setResponse(r)}get streaming(){return po(this.getAttribute(St))}set streaming(r){r?this.setAttribute(St,"true"):this.removeAttribute(St)}get showErrors(){return po(this.getAttribute(it))}set showErrors(r){r?this.setAttribute(it,"true"):this.removeAttribute(it)}emitCustomEvent(r,a){this.dispatchEvent(new CustomEvent(r,{detail:a,bubbles:!0,composed:!0}))}registerWithDevtools(){if(this.devtoolsRegistered)return;const r=Qt();if(!r)return;const a={id:this.devtoolsId,label:this.getAttribute("data-devtools-label")||this.id||this.devtoolsId,element:this,getState:()=>this.state.snapshot(),setState:(n,i)=>this.applyDevtoolsStateEdit(n,i),getProgram:()=>this.currentResponse,forceRender:()=>this.requestFullRender()};r.registerApp(a),this.devtoolsRegistered=!0}connectDevtools(){this.registerWithDevtools(),this.devtoolsRegistered&&this.requestFullRender()}applyDevtoolsStateEdit(r,a){const n=r.indexOf(".");if(n<0){this.state.set(r,a);return}const i=r.slice(0,n),o=r.slice(n+1).split(".");this.state.setPath(i,o,a)}emitDevtoolsEffect(r){ta({kind:"effect",appId:this.devtoolsId,time:pe(),...r})}buildInlineStyle(){const r=document.createElement("style");return r.textContent=lo,r}startRouter(){const r=this.getAttribute("router-mode"),a=this.getAttribute("router-base");(r||a)&&this.router.configure({mode:r==="history"?"history":r==="hash"?"hash":void 0,...a!==null?{basePath:a}:{}}),this.router.start(),this.writeRouteState()}writeRouteState(){const r=Cg(this.router);Ag(this.state.get(co),r)||this.state.set(co,r)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender()}applyThemeFromAttribute(){const r=this.getAttribute(la);sa(this,oa(r)),this.scriptThemeKeys=[]}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(io(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let a;try{a=r()}catch{return}if(!Jn(a))return;const n=oo(a.tokens);Object.keys(n).length!==0&&(this.scriptThemeKeys=no(this,n))}scheduleRender(){this.renderScheduled||(this.renderScheduled=!0,queueMicrotask(()=>this.renderNow()))}requestFullRender(){this.forceFullRender=!0,this.scheduleRender()}renderNow(){if(this.renderScheduled=!1,!this.isConnected)return;this.programDirty&&(this.replan(),this.programDirty=!1),this.context.budget&&Ur(this.context.budget),this.devtoolsRegistered||this.registerWithDevtools();const r=ea();this.renderer.setProfiling(r);const a=r?pe():0,n=new Set,i=this.context.trackedState;this.context.trackedState=n;let o=!1;this.state.beginRenderPass();try{this.applyScriptThemeOverrides(),ki(this.context);const s=this.context.bindings.get("aktion");let c=null;if(s)try{c=s()}catch(g){if(g instanceof Be){this.handleRuntimeBudgetError(g);return}console.error("[aktion] entry point evaluation error",g)}const u=this.pendingChangedPaths;this.pendingChangedPaths=new Set;const p=!this.forceFullRender&&this.lastRenderDeps!==null;this.forceFullRender=!1,this.renderer.beginRender({changedPaths:u,memoize:p});const d=this.captureFocus();let m;try{m=this.renderer.render(c)}catch(g){if(this.renderer.endRender(),g instanceof Be){this.handleRuntimeBudgetError(g);return}throw g}if(Bf(this.rootEl,m),this.renderer.endRender(),this.restoreFocus(d),o=!0,r){const g=this.renderer.drainProfilerRecords();let b=0,h=0;for(const v of g)v.phase==="memo"?h+=1:b+=1;ta({kind:"commit",appId:this.devtoolsId,commitId:this.devtoolsCommitId,startTime:a,duration:pe()-a,changedPaths:[...u],fullRender:!p,initial:this.devtoolsCommitId===0,components:g,rendered:b,memoized:h}),this.devtoolsCommitId+=1}}finally{this.context.trackedState=i,this.lastRenderDeps=o?n:null,this.state.endRenderPass()&&this.warnStateWriteDuringRender()}}warnStateWriteDuringRender(){this.warnedStateWriteDuringRender||(this.warnedStateWriteDuringRender=!0,console.warn("[aktion] A reactive `$state` write happened during render and was applied WITHOUT scheduling a re-render, to prevent an infinite render loop. This usually means a `$name = …` assignment is running in render position — e.g. `$user = {…}` at the top of a lowercase `function` that's invoked to build the UI (`$app(page())`), where the function runs as an action and re-writes the atom every render. Seed component-local state with a PascalCase component (so `$name = …` becomes a set-once per-instance declaration) or the `$state` hook, and only write state from event handlers / effects."))}handleRuntimeBudgetError(r){const a=`Runtime aborted (${r.kind}): ${r.message}`;this.parseErrors.includes(a)||(this.parseErrors=[...this.parseErrors,a]),this.updateErrorBanner(),this.streaming||this.dispatchEvent(new CustomEvent("error",{detail:{errors:[{line:0,column:0,message:r.message}]},bubbles:!0,composed:!0}))}captureFocus(){const r=this.root.activeElement;if(!r||!this.rootEl.contains(r))return null;const a=r.id||null;if(!a)return null;const n={id:a,tagName:r.tagName};return(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(n.selectionStart=r.selectionStart,n.selectionEnd=r.selectionEnd,n.selectionDirection=r.selectionDirection??null),n}restoreFocus(r){if(!r)return;const a=this.rootEl.querySelector(`#${Ng(r.id)}`);!a||a.tagName!==r.tagName||this.root.activeElement===a||(a.focus(),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&r.selectionStart!=null&&r.selectionEnd!=null&&Ig(a,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.lastRenderDeps=null,this.warnedStateWriteDuringRender=!1,this.context&&qr(this.context),this.context=Wr(this.state,{router:this.router,library:this.library,http:this.http,strict:this.hasAttribute("strict"),notify:()=>this.requestFullRender(),onEmit:(i,o)=>this.emitCustomEvent(i,o)});const r=this.pendingCompiled??ge(this.currentResponse);this.pendingCompiled=null;const a=gr(r,this.library);a.length>0&&(r.errors=[...r.errors,...a]),this.context.budget&&Ur(this.context.budget);try{Si(r,this.context)}catch(i){if(i instanceof Be)r.errors=[...r.errors,{line:0,column:0,message:i.message}];else throw i}const n=[...this.context.effectDecls.values()];n.length>0&&this.effectRunner.syncEffects(n,()=>this.context),this.writeRouteState(),this.parseErrors=[...r.errors.map(i=>`Line ${i.line}: ${i.message}`),...this.effectRunner.getErrors()],this.updateErrorBanner(),r.errors.length>0&&!this.streaming&&this.dispatchEvent(new CustomEvent("error",{detail:{errors:r.errors},bubbles:!0,composed:!0}))}updateErrorBanner(){const r=[...this.parseErrors,...this.srcDiagnostics];if(!this.showErrors||this.streaming||r.length===0){this.errorEl.hidden=!0,this.errorEl.replaceChildren();return}this.errorEl.hidden=!1;const a=document.createElement("div");a.textContent=`${r.length} parse issue${r.length===1?"":"s"} (rendered partial UI):`;const n=document.createElement("ul");for(const i of r.slice(0,5)){const o=document.createElement("li");o.textContent=i,n.append(o)}this.errorEl.replaceChildren(a,n)}}z($t,"tagName","aktion-app");function Ng(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const Pg=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function Ig(t,e,r,a){if(t instanceof HTMLInputElement&&Pg.has(t.type)){const n=t.type;try{t.type="text",t.setSelectionRange(e,r,a)}catch{}finally{t.type=n}return}try{t.setSelectionRange(e,r,a)}catch{}}function po(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===it}function mo(t){return t instanceof Error&&t.message?t.message:String(t)}function fo(){customElements.get($t.tagName)||customElements.define($t.tagName,$t)}const Eg=[{name:"App",description:"Top-level `$app(...)` root — every program needs one.",template:'$app(Column([\n ${1:Card([CardHeader("${2:Hello}")])}\n]))'},{name:"Card",description:"Card with header + body block.",template:`card\${1} = Card([
|
|
8036
8036
|
CardHeader("\${2:Title}", { subtitle: "\${3:Subtitle}" }),
|
|
8037
8037
|
Column([
|
|
8038
8038
|
Text("\${4:Body copy goes here.}")
|
|
@@ -8123,5 +8123,5 @@ list = $users.map(u => \${1:UserCard}(u))`},{name:"Ternary",description:"Pick be
|
|
|
8123
8123
|
url: "\${2:https://api.example.com/items}",
|
|
8124
8124
|
method: "\${3:GET}",
|
|
8125
8125
|
headers: { "Content-Type": "application/json" }
|
|
8126
|
-
})`},{name:"State",description:"Reactive state atom — declared with `$name = value`.",template:'$${1:name} = ${2:"default"}'},{name:"Store",description:"Global store — colocated state + actions shared across components (like Zustand/Pinia).",template:"${1:cart} = $store({\n ${2:items}: [],\n ${3:count}: (s) => s.${2:items}.length,\n ${4:add}: (s, item) => { s.${2:items} = [...s.${2:items}, item] },\n})"},{name:"useState",description:"`$state` hook — per-instance state with a [value, setValue] pair (like React's useState).",template:'const [${1:value}, set${2:Value}] = $state(${3:"default"})'},{name:"useMemo",description:"`$memo` hook — value recomputed only when a dependency changes (like React's useMemo).",template:"const ${1:memoized} = $memo(() => ${2:compute}, [${3:deps}])"},{name:"Hook",description:"Custom hook declaration — a `$`-prefixed function that composes $state / $memo.",template:"function $use${1:Counter}(${2:start}) {\n const [${3:count}, set${4:Count}] = $state(${2:start})\n return { ${3:count}: ${3:count}, increment: () => set${4:Count}(v => v + 1) }\n}"},{name:"ResponsiveGrid",description:"Grid with a responsive column map per breakpoint.",template:'cards${1} = Grid(${2:items}, { columns: {sm: 1, md: 2, lg: 4}, gap: "${3:l}" })'}];function lo(){return Sg}function $g(t=pt){const e=Wn(t);return{grammar:Mt,tokenizer:Ka(Mt),tagMap:Ga,components:e,componentsByName:qn(e),builtins:Nt,snippets:lo(),keywordDocs:qa,themeNames:Object.keys(aa),severityTokenMap:{"parse-error":"error"},iconAliases:Cg}}const Cg=["house","user","users","gear","bell","envelope","magnifying-glass","plus","minus","pen","trash","check","xmark","arrow-right","arrow-left","arrow-up","arrow-down","chevron-right","chevron-left","chevron-down","chevron-up","ellipsis","ellipsis-vertical","star","heart","bookmark","calendar","clock","file","folder","image","video","music","chart-line","chart-bar","chart-pie","gauge","table","circle-info","circle-check","circle-exclamation","circle-question","triangle-exclamation","shield","lock","unlock","key","rocket","bolt","fire","snowflake","sun","moon","cloud","code","terminal","database","server","globe","link","share","download","upload","filter","sort","list","grid","columns","sidebar","bars","tag","tags","flag","trophy","medal","gift","cart-shopping","credit-card","money-bill","receipt","wallet","comment","comments","paper-plane","inbox","paper-clip","phone","video-camera","play","pause","stop","forward","backward","expand","compress","eye","eye-slash","thumbs-up","thumbs-down","thumbtack"];function co(t,e,r){const a=new Map,n=[],i=new Set,o=[];let s=0;const c=(m,g,b,h)=>{o.push({line:g,column:b,message:m===e?h:`${m}: ${h}`,severity:"error"})};function u(m,g){const b=a.get(m);if(b)return b;if(i.has(m))return;i.add(m);let h;if(g!==null)h=g;else try{h=r.load(m)}catch{i.delete(m),c(e,0,0,`Failed to load imported module "${m}".`);return}const v=ge(h),y={id:s++,path:m,program:v,edges:[],declaredPlain:new Set,declaredState:new Set,exportedPlain:new Set,exportedState:new Set,renamePlain:new Map,renameState:new Map};a.set(m,y),Ag(y);for(const x of v.statements){if(x.kind!=="Import")continue;const w=r.resolve(x.source,m);if(y.edges.push({stmt:x,resolvedPath:w}),w===null){c(m,x.loc?.line??0,x.loc?.column??0,`Cannot resolve import "${x.source}".`);continue}u(w,null)}return i.delete(m),n.push(m),y}u(e,t);for(const m of a.values())if(m.path!==e){for(const g of m.declaredPlain)m.renamePlain.set(g,`__a${m.id}_${g}`);for(const g of m.declaredState)m.renameState.set(g,`__a${m.id}_${g}`)}for(const m of a.values())for(const{stmt:g,resolvedPath:b}of m.edges){if(b===null)continue;const h=a.get(b);if(h)for(const v of g.specifiers){const y=g.loc?.line??0,x=g.loc?.column??0;if(v.isState){if(!h.exportedState.has(v.imported)){c(m.path,y,x,`"${g.source}" does not export \`$${v.imported}\`.`);continue}m.renameState.set(v.local,h.renameState.get(v.imported)??`__a${h.id}_${v.imported}`)}else{if(!h.exportedPlain.has(v.imported)){c(m.path,y,x,`"${g.source}" does not export \`${v.imported}\`.`);continue}m.renamePlain.set(v.local,h.renamePlain.get(v.imported)??`__a${h.id}_${v.imported}`)}}}const p=[];for(const m of n){const g=a.get(m),b=Mg(g);for(const h of g.program.statements)h.kind!=="Import"&&(b.renameTopLevel(h),Tg(h),h.kind==="EffectDeclaration"&&g.path!==e&&(h.name=`__effect_a${g.id}_${h.name.replace(/^__effect_/,"")}`),p.push(h))}const d=a.get(e);return{program:{statements:p,errors:d?d.program.errors:[]},diagnostics:o,dependencies:n.filter(m=>m!==e)}}function Ag(t){for(const e of t.program.statements)switch(e.kind){case"Assignment":e.isState?(t.declaredState.add(e.identifier),e.exported&&t.exportedState.add(e.identifier)):(t.declaredPlain.add(e.identifier),e.exported&&t.exportedPlain.add(e.identifier));break;case"ComponentDeclaration":case"ActionDeclaration":t.declaredPlain.add(e.name),e.exported&&t.exportedPlain.add(e.name);break;case"HookDeclaration":t.declaredState.add(e.name),e.exported&&t.exportedState.add(e.name);break;case"DestructureStatement":for(const r of e.bindings)r.name&&t.declaredPlain.add(r.name);break}}function Tg(t){(t.kind==="Assignment"||t.kind==="ComponentDeclaration"||t.kind==="ActionDeclaration"||t.kind==="HookDeclaration")&&delete t.exported}function Mg(t){const e=[],r=h=>{for(const v of e)if(v.has(h))return!0;return!1},a=h=>r(h)?h:t.renamePlain.get(h)??h,n=h=>t.renameState.get(h)??h,i=h=>{e.push(new Set(h))},o=()=>{e.pop()},s=h=>h.bindings.map(v=>v.name).filter(v=>!!v),c=h=>{const v=[];for(const y of h)y.name&&v.push(y.name),y.pattern&&v.push(...s(y.pattern));return v},u=h=>{for(const v of h)v.defaultValue&&p(v.defaultValue)};function p(h){switch(h.kind){case"Literal":return;case"Identifier":h.name=a(h.name);return;case"StateRef":h.name=n(h.name);return;case"Array":for(const v of h.elements)p(v);return;case"Object":for(const v of h.properties)v.computedKey&&p(v.computedKey),p(v.value);return;case"Member":p(h.object),h.computed&&p(h.computed);return;case"Unary":p(h.argument);return;case"Binary":p(h.left),p(h.right);return;case"Ternary":p(h.test),p(h.consequent),p(h.alternate);return;case"Call":h.callee=a(h.callee);for(const v of h.arguments)p(v);return;case"MethodCall":p(h.object);for(const v of h.arguments)p(v);return;case"Invoke":p(h.callee);for(const v of h.arguments)p(v);return;case"BuiltinCall":for(const v of h.arguments)p(v);return;case"New":p(h.callee);for(const v of h.arguments)p(v);return;case"Template":for(const v of h.expressions)p(v);return;case"Spread":p(h.argument);return;case"Lambda":i(c(h.params)),u(h.params),p(h.body),o();return;case"Block":d(h);return}}function d(h){i([]);const v=e[e.length-1];for(const y of h.body)b(y,!1),m(y,v);o()}function m(h,v){if(h.kind==="DestructureStatement")for(const y of h.bindings)y.name&&v.add(y.name);else(h.kind==="ComponentDeclaration"||h.kind==="ActionDeclaration")&&v.add(h.name)}function g(h){if(h.kind==="DestructureStatement"){p(h.expression);for(const v of h.bindings)v.defaultValue&&p(v.defaultValue),v.name=a(v.name);return}b(h,!0)}function b(h,v){switch(h.kind){case"Import":return;case"Assignment":h.identifier=h.isState?n(h.identifier):a(h.identifier),p(h.expression);return;case"ComponentDeclaration":case"ActionDeclaration":h.name=a(h.name),i(c(h.params)),u(h.params),d(h.body),o();return;case"HookDeclaration":h.name=n(h.name),i(c(h.params)),u(h.params),d(h.body),o();return;case"EffectDeclaration":for(const y of h.triggers)y.kind==="state"&&(y.name=n(y.name));d(h.body);return;case"Await":p(h.argument);return;case"Return":h.argument&&p(h.argument);return;case"ExpressionStatement":p(h.expression);return;case"IfStatement":p(h.test),d(h.consequent),h.alternate&&(h.alternate.kind==="IfStatement"?b(h.alternate,!1):d(h.alternate));return;case"SwitchStatement":p(h.discriminant);for(const y of h.cases){y.test&&p(y.test);for(const x of y.body)b(x,!1)}return;case"ForOfStatement":{p(h.iterable);const y=[h.item];h.index&&y.push(h.index),h.destructure&&y.push(...h.destructure),i(y),d(h.body),o();return}case"ForInStatement":p(h.iterable),i([h.item]),d(h.body),o();return;case"ForClassicStatement":{const y=[];h.init&&h.init.kind==="Assignment"&&h.init.identifier&&y.push(h.init.identifier),i(y),h.init&&b(h.init,!1),h.test&&p(h.test),h.update&&p(h.update),d(h.body),o();return}case"WhileStatement":case"DoWhileStatement":p(h.test),d(h.body);return;case"DestructureStatement":p(h.expression);for(const y of h.bindings)y.defaultValue&&p(y.defaultValue);if(v)for(const y of h.bindings)y.name=a(y.name);return;case"ThrowStatement":p(h.argument);return;case"TryStatement":d(h.block),h.catchBlock&&(i(h.catchParam?[h.catchParam]:[]),d(h.catchBlock),o()),h.finallyBlock&&d(h.finallyBlock);return;case"BreakStatement":case"ContinueStatement":return}}return{renameTopLevel:g}}function ca(t){return/^[a-z][a-z0-9+.-]*:\/\//i.test(t)}function uo(t){const e=[];for(const r of t)r===""||r==="."||(r===".."?e.pop():e.push(r));return e.join("/")}function Ng(t){const e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function ua(t,e){if(ca(t))try{return new URL(t).href}catch{return null}if(ca(e))try{return new URL(t,e).href}catch{return null}return t.startsWith("/")?uo(t.split("/")):t.startsWith("./")||t.startsWith("../")?uo(`${Ng(e)}/${t}`.split("/")):null}function po(t){return{resolve:(e,r)=>ua(e,r),load:e=>{const r=t[e];if(r===void 0)throw new Error(`not found: ${e}`);return r}}}async function Pg(t){if(typeof fetch!="function")throw new Error("global fetch is unavailable; cannot load URL imports");const e=await fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.text()}async function Ig(t){const{entry:e,files:r}=t,a=t.fetch??Pg,n=[],i={...r},o=new Set;async function s(p){if(o.has(p))return;if(o.add(p),i[p]===void 0)if(ca(p))try{i[p]=await a(p)}catch(g){n.push({line:0,column:0,message:`Failed to fetch module "${p}": ${g.message??g}`,severity:"error"});return}else return;let d;try{d=ge(i[p])}catch{return}const m=[];for(const g of d.statements){if(g.kind!=="Import")continue;const b=ua(g.source,p);b!==null&&m.push(s(b))}await Promise.all(m)}if(i[e]===void 0)return{program:{statements:[],errors:[]},source:"",diagnostics:[{line:0,column:0,message:`Entry module "${e}" was not found.`,severity:"error"}],dependencies:[]};await s(e);const c=co(i[e],e,po(i));let u;try{u=Go(c.program)}catch{u=i[e]}return{program:c.program,source:u,diagnostics:[...n,...c.diagnostics],dependencies:c.dependencies}}so();const Eg=ta(pt);P.AktionElement=St,P.BreakSignal=ke,P.COMPILED_PROGRAM_VERSION=sr,P.ContinueSignal=Te,P.DEFAULT_RUNTIME_BUDGET=Vt,P.EffectRunner=ji,P.HttpRuntime=Zn,P.Renderer=Ui,P.ReturnSignal=nt,P.Router=ii,P.RuntimeBudgetError=Be,P.SYSTEM_PROMPT_TEXT=Eg,P.StateStore=Xn,P.anyPathAffects=Ir,P.applyPartialTheme=Qi,P.applyTheme=ia,P.assertOnePositionalMax=Va,P.brutalistTheme=Ji,P.buildFrontier=Da,P.builtInThemes=aa,P.builtinCatalog=Nt,P.builtinNames=Ya,P.builtinsByName=Xa,P.clearInstanceHooks=zi,P.clearTokenOverrides=eo,P.compileLite=qo,P.computeFrontier=Uo,P.consoleNs=di,P.createContext=Hr,P.createHttpResource=Lr,P.createI18n=ri,P.createMemoryResolver=po,P.createMutationResource=ti,P.createQueryResource=ei,P.createRuntimeBudget=gi,P.createStreamTokenizer=Ka,P.createToastManager=pi,P.darkTheme=Ki,P.defaultLibrary=pt,P.defaultTagMap=Ga,P.defineCompiledProgram=Wo,P.defineElement=so,P.describeComponentSpec=jf,P.disposeContext=Vr,P.enterUserComponent=Fr,P.evaluate=M,P.evaluateUserComponent=Ni,P.extractStatePath=qt,P.findBuiltin=ps,P.findComponent=Ee,P.findPositionalIndex=dr,P.findPositionalProp=pr,P.generatePrompt=ta,P.getComponentCatalog=Wn,P.getLanguageSpec=$g,P.getSnippets=lo,P.glassTheme=Xi,P.grammarSpec=Mt,P.indexCatalog=qn,P.isBuiltinName=ms,P.isCompiledProgram=Ba,P.isComponentNode=hi,P.isEndpointResource=Jn,P.isQuiescent=Ho,P.isStoreHandle=Wt,P.isThemeNode=Kn,P.isUserComponentNode=bi,P.joinStatePath=Gn,P.keywordDocs=qa,P.leaveUserComponent=Ur,P.lightTheme=ye,P.linkProgram=co,P.linkProject=Ig,P.mapPositionalArgs=Wa,P.matchRoute=ni,P.mergeLibraries=Ha,P.neonTheme=Gi,P.normalisePath=De,P.parse=ge,P.pastelTheme=Yi,P.pathAffects=Yn,P.pathsOverlap=mt,P.planProgram=yi,P.resetMutableBindings=vi,P.resetRuntimeBudget=_r,P.resolvePatternBindings=yt,P.resolveSpecifier=ua,P.resolveStateAlias=Ae,P.resolveTheme=na,P.runControlFlowStatement=qr,P.sanitiseThemeTokens=to,P.skylineTheme=Zi,P.storage=jr,P.tokenize=ma,P.validateProgram=is,P.validateProgramSchema=mr,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
|
|
8126
|
+
})`},{name:"State",description:"Reactive state atom — declared with `$name = value`.",template:'$${1:name} = ${2:"default"}'},{name:"Store",description:"Global store — colocated state + actions shared across components (like Zustand/Pinia).",template:"${1:cart} = $store({\n ${2:items}: [],\n ${3:count}: (s) => s.${2:items}.length,\n ${4:add}: (s, item) => { s.${2:items} = [...s.${2:items}, item] },\n})"},{name:"useState",description:"`$state` hook — per-instance state with a [value, setValue] pair (like React's useState).",template:'const [${1:value}, set${2:Value}] = $state(${3:"default"})'},{name:"useMemo",description:"`$memo` hook — value recomputed only when a dependency changes (like React's useMemo).",template:"const ${1:memoized} = $memo(() => ${2:compute}, [${3:deps}])"},{name:"Hook",description:"Custom hook declaration — a `$`-prefixed function that composes $state / $memo.",template:"function $use${1:Counter}(${2:start}) {\n const [${3:count}, set${4:Count}] = $state(${2:start})\n return { ${3:count}: ${3:count}, increment: () => set${4:Count}(v => v + 1) }\n}"},{name:"ResponsiveGrid",description:"Grid with a responsive column map per breakpoint.",template:'cards${1} = Grid(${2:items}, { columns: {sm: 1, md: 2, lg: 4}, gap: "${3:l}" })'}];function go(){return Eg}function Lg(t=mt){const e=Yn(t);return{grammar:Pt,tokenizer:Ja(Pt),tagMap:Za,components:e,componentsByName:Xn(e),builtins:It,snippets:go(),keywordDocs:Xa,themeNames:Object.keys(ia),severityTokenMap:{"parse-error":"error"},iconAliases:Rg}}const Rg=["house","user","users","gear","bell","envelope","magnifying-glass","plus","minus","pen","trash","check","xmark","arrow-right","arrow-left","arrow-up","arrow-down","chevron-right","chevron-left","chevron-down","chevron-up","ellipsis","ellipsis-vertical","star","heart","bookmark","calendar","clock","file","folder","image","video","music","chart-line","chart-bar","chart-pie","gauge","table","circle-info","circle-check","circle-exclamation","circle-question","triangle-exclamation","shield","lock","unlock","key","rocket","bolt","fire","snowflake","sun","moon","cloud","code","terminal","database","server","globe","link","share","download","upload","filter","sort","list","grid","columns","sidebar","bars","tag","tags","flag","trophy","medal","gift","cart-shopping","credit-card","money-bill","receipt","wallet","comment","comments","paper-plane","inbox","paper-clip","phone","video-camera","play","pause","stop","forward","backward","expand","compress","eye","eye-slash","thumbs-up","thumbs-down","thumbtack"];fo();const zg=aa(mt);P.AktionElement=$t,P.BreakSignal=ke,P.COMPILED_PROGRAM_VERSION=Nt,P.ContinueSignal=Te,P.DEFAULT_RUNTIME_BUDGET=qt,P.EffectRunner=Fi,P.HttpRuntime=ri,P.Renderer=qi,P.ReturnSignal=nt,P.Router=ci,P.RuntimeBudgetError=Be,P.SYSTEM_PROMPT_TEXT=zg,P.StateStore=ei,P.anyPathAffects=Lr,P.applyPartialTheme=no,P.applyTheme=sa,P.assertOnePositionalMax=Ga,P.brutalistTheme=ro,P.buildFrontier=Da,P.builtInThemes=ia,P.builtinCatalog=It,P.builtinNames=Qa,P.builtinsByName=en,P.clearInstanceHooks=Bi,P.clearTokenOverrides=io,P.compileLite=Yo,P.computeFrontier=Wo,P.consoleNs=gi,P.createContext=Wr,P.createHttpResource=zr,P.createI18n=oi,P.createMemoryResolver=Ha,P.createMutationResource=ii,P.createQueryResource=ni,P.createRuntimeBudget=yi,P.createStreamTokenizer=Ja,P.createToastManager=hi,P.darkTheme=Zi,P.defaultLibrary=mt,P.defaultTagMap=Za,P.defineCompiledProgram=Go,P.defineElement=fo,P.describeComponentSpec=qf,P.disposeContext=qr,P.enterUserComponent=Hr,P.evaluate=M,P.evaluateUserComponent=Li,P.extractStatePath=Gt,P.findBuiltin=xs,P.findComponent=Ee,P.findPositionalIndex=mr,P.findPositionalProp=fr,P.generatePrompt=aa,P.getComponentCatalog=Yn,P.getLanguageSpec=Lg,P.getSnippets=go,P.glassTheme=to,P.grammarSpec=Pt,P.indexCatalog=Xn,P.isBuiltinName=ws,P.isCompiledProgram=Ba,P.isComponentNode=xi,P.isEndpointResource=ti,P.isQuiescent=qo,P.isStoreHandle=Kt,P.isThemeNode=Jn,P.isUserComponentNode=wi,P.joinStatePath=Zn,P.keywordDocs=Xa,P.leaveUserComponent=Vr,P.lightTheme=ye,P.linkProgram=Fa,P.linkProject=Va,P.mapPositionalArgs=Ya,P.matchRoute=li,P.mergeLibraries=Ka,P.neonTheme=Qi,P.normalisePath=De,P.parse=ge,P.pastelTheme=eo,P.pathAffects=Qn,P.pathsOverlap=ft,P.planProgram=Si,P.resetMutableBindings=ki,P.resetRuntimeBudget=Ur,P.resolvePatternBindings=xt,P.resolveSpecifier=ur,P.resolveStateAlias=Ae,P.resolveTheme=oa,P.runControlFlowStatement=Gr,P.sanitiseThemeTokens=oo,P.skylineTheme=ao,P.storage=Or,P.tokenize=ma,P.validateProgram=ms,P.validateProgramSchema=gr,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
|
|
8127
8127
|
//# sourceMappingURL=aktion.umd.cjs.map
|