aktion-runtime 0.5.1 → 0.5.3

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.
Files changed (35) hide show
  1. package/README.md +654 -373
  2. package/dist/aktion.iife.js +798 -790
  3. package/dist/aktion.iife.js.map +1 -1
  4. package/dist/aktion.js +10059 -7997
  5. package/dist/aktion.js.map +1 -1
  6. package/dist/aktion.umd.cjs +798 -790
  7. package/dist/aktion.umd.cjs.map +1 -1
  8. package/dist/system_prompt.txt +595 -829
  9. package/dist/system_prompt_chat.txt +98 -263
  10. package/dist/types/element.d.ts +46 -26
  11. package/dist/types/language/grammar.d.ts +25 -9
  12. package/dist/types/language/index.d.ts +8 -6
  13. package/dist/types/library/components/content.d.ts +0 -1
  14. package/dist/types/library/components/escape-hatch.d.ts +3 -0
  15. package/dist/types/library/components/layout.d.ts +3 -0
  16. package/dist/types/library/components/wrappers.d.ts +12 -0
  17. package/dist/types/library/utils.d.ts +42 -0
  18. package/dist/types/parser/frontier.d.ts +3 -3
  19. package/dist/types/parser/lexer.d.ts +7 -17
  20. package/dist/types/parser/types.d.ts +239 -113
  21. package/dist/types/prompt/generator.d.ts +0 -11
  22. package/dist/types/renderer/renderer.d.ts +60 -7
  23. package/dist/types/runtime/builtins.d.ts +10 -6
  24. package/dist/types/runtime/effects.d.ts +5 -30
  25. package/dist/types/runtime/evaluator.d.ts +356 -25
  26. package/dist/types/runtime/http.d.ts +35 -30
  27. package/dist/types/runtime/i18n.d.ts +23 -32
  28. package/dist/types/runtime/router.d.ts +5 -6
  29. package/dist/types/runtime/state.d.ts +77 -33
  30. package/dist/types/runtime/util.d.ts +88 -0
  31. package/dist/types/theme/styles.d.ts +1 -1
  32. package/dist/types/tooling/delta.d.ts +1 -1
  33. package/dist/types/tooling/inspector.d.ts +1 -1
  34. package/package.json +2 -2
  35. package/dist/types/language/builtins.d.ts +0 -33
@@ -1,856 +1,507 @@
1
- (function(I,oe){typeof exports=="object"&&typeof module<"u"?oe(exports):typeof define=="function"&&define.amd?define(["exports"],oe):(I=typeof globalThis<"u"?globalThis:I||self,oe(I.Aktion={}))})(this,function(I){"use strict";var lp=Object.defineProperty;var cp=(I,oe,Pe)=>oe in I?lp(I,oe,{enumerable:!0,configurable:!0,writable:!0,value:Pe}):I[oe]=Pe;var j=(I,oe,Pe)=>cp(I,typeof oe!="symbol"?oe+"":oe,Pe);const oe=new Set(["component","effect","action","if","else","match","for","in","await","return","cleanup","optimistic","on","emit","bind","default"]),Pe=new Set(["(",")","[","]","{","}",",",":","?","."]),ki={true:"Boolean",false:"Boolean",null:"Null"};function ir(t){const e=[];let r=0,a=1,i=1;const n=(c=0)=>t[r+c],s=(c,u,p,m)=>{e.push({type:c,value:u,line:p,column:m})},l=()=>{const c=t[r];return r+=1,c===`
2
- `?(a+=1,i=1):i+=1,c};for(;r<t.length;){const c=n();if(c===void 0)break;if(c===`
3
- `){const f=a,h=i;l(),s("Newline",`
4
- `,f,h);continue}if(c===" "||c===" "||c==="\r"){l();continue}if(c==="/"&&n(1)==="/"){for(;r<t.length&&n()!==`
5
- `;)l();continue}if(c==="#"){for(;r<t.length&&n()!==`
6
- `;)l();continue}if(c==="/"&&n(1)==="*"){for(l(),l();r<t.length&&!(n()==="*"&&n(1)==="/");)l();r<t.length&&(l(),l());continue}if(c==='"'||c==="'"){const f=c,h=a,b=i;l();let v="";for(;r<t.length&&n()!==f;){if(n()==="\\"&&n(1)!==void 0){l();const y=l();switch(y){case"n":v+=`
7
- `;break;case"t":v+=" ";break;case"r":v+="\r";break;case"\\":v+="\\";break;case'"':v+='"';break;case"'":v+="'";break;case"`":v+="`";break;default:v+=y??""}continue}if(n()===`
8
- `)break;v+=l()}n()===f&&l(),s("String",v,h,b);continue}if(c==="`"){const f=a,h=i;l();const b=[];let v="",y=!1;for(;r<t.length&&n()!=="`";){if(n()==="\\"&&n(1)!==void 0){l();const x=l();switch(x){case"n":v+=`
9
- `;break;case"t":v+=" ";break;case"r":v+="\r";break;case"\\":v+="\\";break;case'"':v+='"';break;case"'":v+="'";break;case"`":v+="`";break;case"$":v+="$";break;default:v+=x??""}continue}if(n()==="$"&&n(1)==="{"){b.push({kind:"str",text:v}),v="";const x=a,w=i;l(),l();let T=1,S="";for(;r<t.length&&T>0;){const N=n();if(N===void 0)break;if(N==="`"){for(S+=l();r<t.length&&n()!=="`";){if(n()==="\\"&&n(1)!==void 0){S+=l(),S+=l();continue}S+=l()}n()==="`"&&(S+=l());continue}if(N==='"'||N==="'"){const $=N;for(S+=l();r<t.length&&n()!==$;){if(n()==="\\"&&n(1)!==void 0){S+=l(),S+=l();continue}if(n()===`
10
- `)break;S+=l()}n()===$&&(S+=l());continue}if(N==="{"){T+=1,S+=l();continue}if(N==="}"){if(T-=1,T===0){l();break}S+=l();continue}S+=l()}b.push({kind:"expr",source:S,line:x,column:w}),y=!0;continue}v+=l()}if(n()==="`"&&l(),b.push({kind:"str",text:v}),!y){s("String",v,f,h);continue}e.push({type:"TemplateString",value:"",line:f,column:h,parts:b});continue}const u=e[e.length-1],p=!u||u.type==="Newline"||u.type==="Operator"||u.type==="Punctuation"&&(u.value==="("||u.value==="["||u.value===","||u.value===":"||u.value==="?"||u.value==="{");if(De(c)||c==="-"&&De(n(1)??"")&&p){const f=a,h=i;let b="";c==="-"&&(b+=l());let v=!1;for(;r<t.length;){const y=n()??"";if(De(y)){b+=l();continue}if(y==="."&&!v&&De(n(1)??"")){v=!0,b+=l();continue}break}s("Number",b,f,h);continue}if(c==="@"){const f=a,h=i;l();let b="";for(;r<t.length&&wt(n()??"");)b+=l();s("BuiltinIdentifier",b,f,h);continue}if(c==="$"){const f=a,h=i;if(l(),n()==="$"){const v=new Error('Legacy "$$x" persistent reference is removed. Reactive state is declared with "$x = value" and referenced as "$x".');throw v.line=f,v.column=h,v}let b="";for(;r<t.length&&wt(n()??"");)b+=l();s("StateIdentifier",b,f,h);continue}if(nr(c)){const f=a,h=i;let b="";for(;r<t.length&&wt(n()??"");)b+=l();if(b==="js"){let y=0;for(;n(y)===" "||n(y)===" ";)y+=1;if(n(y)==="{")for(let x=0;x<y;x+=1)l()}if(b==="js"&&n()==="{"){l();let y="",x=1;for(;r<t.length&&x>0;){const w=n();if(w===void 0)break;if(w==="\\"&&n(1)!==void 0){y+=l(),y+=l();continue}if(w==='"'||w==="'"){const T=w;for(y+=l();r<t.length&&n()!==T;){if(n()==="\\"&&n(1)!==void 0){y+=l(),y+=l();continue}if(n()===`
11
- `)break;y+=l()}n()===T&&(y+=l());continue}if(w==="`"){for(y+=l();r<t.length&&n()!=="`";){if(n()==="\\"&&n(1)!==void 0){y+=l(),y+=l();continue}y+=l()}n()==="`"&&(y+=l());continue}if(w==="{"){x+=1,y+=l();continue}if(w==="}"){if(x-=1,x===0){l();break}y+=l();continue}y+=l()}s("JsBlock",y,f,h);continue}const v=ki[b];v==="Boolean"?s("Boolean",b,f,h):v==="Null"?s("Null",b,f,h):oe.has(b)?s("Keyword",b,f,h):s("Identifier",b,f,h);continue}if(c==="."&&n(1)==="."&&n(2)==="."){const f=a,h=i;l(),l(),l(),s("Operator","...",f,h);continue}const m=c+(n(1)??"");if(m+(n(2)??"")==="??="){const f=a,h=i;l(),l(),l(),s("Operator","??=",f,h);continue}if(m==="=="||m==="!="||m===">="||m==="<="||m==="&&"||m==="||"||m==="??"||m==="?."||m==="->"||m==="=>"||m==="+="||m==="-="||m==="*="||m==="/="||m==="++"||m==="--"){const f=a,h=i;l(),l(),s("Operator",m,f,h);continue}if("+-*/%!=<>".includes(c)){const f=a,h=i;l(),s("Operator",c,f,h);continue}if(Pe.has(c)){const f=a,h=i;l(),s("Punctuation",c,f,h);continue}l()}return e.push({type:"EOF",value:"",line:a,column:i}),e}function De(t){return t>="0"&&t<="9"}function nr(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function wt(t){return nr(t)||De(t)}function fe(t){const e=ir(t),r=new Li(e),a=[],i=[];for(;!r.isEnd();)if(!r.match("Newline"))try{const n=or(r,!0);n&&a.push(n)}catch(n){const s=n;i.push(s),r.recoverToNextLine()}return{statements:a,errors:i}}function or(t,e){const r=t.peek();if(r.type==="Keyword")switch(r.value){case"component":return Ti(t);case"effect":return $i(t);case"action":return Ai(t);case"emit":return Pi(t);case"cleanup":return Ii(t);case"await":return zi(t);case"return":return Ri(t)}const a=t.snapshot();if(Si(t))try{return Ei(t)}catch(i){if(i&&typeof i=="object"&&i.__definitive)throw i;t.restore(a)}return Ci(t)}function Si(t){const e=t.peek();if(e.type==="StateIdentifier"){const a=t.peek(1);return a.type==="Operator"&&a.value==="="}if(e.type!=="Identifier")return!1;const r=t.peek(1);return r.type==="Operator"&&r.value==="="||r.type==="Punctuation"&&r.value==="("}function Ci(t){const e=t.peek(),r=W(t);return t.isEnd()||t.match("Newline"),{kind:"ExpressionStatement",expression:r,loc:{line:e.line,column:e.column}}}function Ti(t){const e=t.expect("Keyword","component"),r=t.expect("Identifier"),{params:a,slots:i}=sr(t),n=ye(t);if(t.isEnd()||t.match("Newline"),!n.body.some(l=>l.kind==="Return")){const l={message:`component "${r.value}" must end with an explicit \`return\` statement.`,line:e.line,column:e.column};throw l.__definitive=!0,l}return{kind:"ComponentDeclaration",name:r.value,params:a,slots:i,body:n,loc:{line:e.line,column:e.column}}}function sr(t){t.expect("Punctuation","(");const e=[],r=[];for(;t.match("Newline"););if(!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){for(;t.match("Newline"););const a=t.peek();if(a.type==="Identifier"&&a.value==="slots"){for(t.consume(),t.expect("Punctuation",":"),t.expect("Punctuation","{");t.match("Newline"););for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const i=t.expect("Identifier");for(r.push(i.value),t.peek().type==="Punctuation"&&t.peek().value==="?"&&t.consume();t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===",")for(t.consume();t.match("Newline"););}t.expect("Punctuation","}")}else if(a.type==="Identifier"||a.type==="Keyword"){const i=t.consume();let n;t.peek().type==="Punctuation"&&t.peek().value===":"&&(t.consume(),n=W(t)),e.push({name:i.value,defaultValue:n})}else throw{message:`Expected parameter name, got ${a.type} "${a.value}"`,line:a.line,column:a.column};for(;t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}return t.expect("Punctuation",")"),{params:e,slots:r}}function $i(t){const e=t.expect("Keyword","effect"),r=[];let a;if(t.peek().type==="Punctuation"&&t.peek().value==="["){for(t.consume();t.match("Newline"););for(;!(t.peek().type==="Punctuation"&&t.peek().value==="]");){for(Ni(t,r,s=>{a=s});t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===",")for(t.consume();t.match("Newline"););}t.expect("Punctuation","]")}const i=ye(t);t.isEnd()||t.match("Newline");const n={kind:"EffectDeclaration",name:`__effect_L${e.line}_C${e.column}`,triggers:r,body:i,loc:{line:e.line,column:e.column}};return a&&(n.rateLimit=a),n}function Ni(t,e,r){const a=t.peek();if(a.type==="StateIdentifier"){t.consume(),e.push({kind:"state",name:a.value});return}if(a.type==="Keyword"&&a.value==="on"){t.consume(),t.expect("Punctuation",":");const i=t.expect("Identifier").value;if(i==="mount"||i==="unmount"){e.push({kind:"lifecycle",name:i});return}if(i==="every"){t.expect("Punctuation","(");const n=t.expect("Number");t.expect("Punctuation",")"),e.push({kind:"every",intervalMs:Number(n.value)});return}throw{message:`Unknown lifecycle trigger "on:${i}" inside effect dependency list`,line:a.line,column:a.column}}if(a.type==="Identifier"&&(a.value==="debounce"||a.value==="throttle")){const i=t.consume().value;t.expect("Punctuation","(");const n=t.expect("Number");t.expect("Punctuation",")"),r({kind:i,ms:Number(n.value)});return}throw{message:`Unexpected ${a.type} "${a.value}" inside effect dependency list. Expected $state, on:mount, on:unmount, on:every(N), debounce(N), or throttle(N).`,line:a.line,column:a.column}}function Ai(t){const e=t.expect("Keyword","action"),r=t.expect("Identifier");let a=[];t.peek().type==="Punctuation"&&t.peek().value==="("&&(a=sr(t).params),Mi(t);let i=!1;t.peek().type==="Keyword"&&t.peek().value==="optimistic"&&(t.consume(),i=!0);const n=ye(t);return t.isEnd()||t.match("Newline"),{kind:"ActionDeclaration",name:r.value,params:a,optimistic:i,body:n,loc:{line:e.line,column:e.column}}}function Mi(t){const e=t.peek();if(e.type!=="Identifier"||e.value!=="uses")return;t.consume(),t.expect("Punctuation","{");let r;for(;t.match("Newline"););for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const a=t.peek();if(a.type!=="Identifier"&&a.type!=="Keyword")throw{message:`Expected capability name inside legacy "uses { … }" clause, got ${a.type} "${a.value}"`,line:a.line,column:a.column};let i=t.consume().value;for(;t.peek().type==="Punctuation"&&t.peek().value===".";)t.consume(),i+=`.${t.expect("Identifier").value}`;let n;if(t.peek().type==="Punctuation"&&t.peek().value==="(")if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value===")")t.expect("Punctuation",")");else{const s=t.peek();s.type==="Number"&&(n=Number(s.value));let l=1;for(;!t.isEnd()&&l>0;){const c=t.consume();c.type==="Punctuation"&&c.value==="("?l+=1:c.type==="Punctuation"&&c.value===")"&&(l-=1)}}for((i==="debounce"||i==="throttle")&&n!==void 0&&(r={kind:i,ms:n});t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===",")for(t.consume();t.match("Newline"););}return t.expect("Punctuation","}"),r}function ye(t){const e=t.expect("Punctuation","{"),r=[];for(;t.match("Newline"););for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const a=or(t);for(a&&r.push(a);t.match("Newline"););}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function Pi(t){const e=t.expect("Keyword","emit"),r=t.expect("String");let a={kind:"Object",properties:[]};if(t.peek().type==="Punctuation"&&t.peek().value==="{"){t.consume();const i=hr(t);t.expect("Punctuation","}"),a={kind:"Object",properties:i}}return t.isEnd()||t.match("Newline"),{kind:"Emit",eventName:r.value,detail:a,loc:{line:e.line,column:e.column}}}function Ii(t){const e=t.expect("Keyword","cleanup");t.expect("Punctuation","(");const r=W(t);return t.expect("Punctuation",")"),t.isEnd()||t.match("Newline"),{kind:"Cleanup",callback:r,loc:{line:e.line,column:e.column}}}function zi(t){const e=t.expect("Keyword","await"),r=W(t);return t.isEnd()||t.match("Newline"),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function Ri(t){const e=t.expect("Keyword","return");let r;const a=t.peek();return a.type!=="Newline"&&!(a.type==="Punctuation"&&a.value==="}")&&(r=W(t)),t.isEnd()||t.match("Newline"),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class Li{constructor(e){j(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.consume();this.peek().type==="Newline"&&this.consume()}snapshot(){return this.index}restore(e){this.index=e}}function Ei(t){const e=t.peek();let r="",a=!1;if(e.type==="Identifier"){if(r=t.consume().value,t.peek().type==="Punctuation"&&t.peek().value==="("){const s=t.snapshot();t.consume();const l=[];let c=!0;for(;t.match("Newline"););if(!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){for(;t.match("Newline"););if(t.peek().type!=="Identifier"){c=!1;break}for(l.push(t.consume().value);t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}if(c&&t.peek().type==="Punctuation"&&t.peek().value===")"){if(t.consume(),t.peek().type==="Operator"&&t.peek().value==="="){const u={message:`Legacy "${r}(...) = expr" macro shorthand is removed in Aktion 0.5. Use "component ${r}(${l.join(", ")}) { ... }" for reusables, or "${r} = (${l.join(", ")}) => ..." for local helpers.`,line:e.line,column:e.column};throw u.__definitive=!0,u}t.restore(s)}else t.restore(s)}}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 i=t.expect("Operator","="),n=W(t);return t.isEnd()||t.match("Newline"),{kind:"Assignment",identifier:r,isState:a,expression:n,loc:{line:i.line,column:i.column}}}function W(t){return _i(t)}function _i(t){const e=ji(t);if(t.peek().type==="Punctuation"&&t.peek().value==="?"){t.consume();const r=W(t);t.expect("Punctuation",":");const a=W(t);return{kind:"Ternary",test:e,consequent:r,alternate:a}}return e}function ji(t){let e=lr(t);for(;t.peek().type==="Operator"&&(t.peek().value==="||"||t.peek().value==="??");){const r=t.consume().value,a=lr(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function lr(t){let e=cr(t);for(;t.peek().type==="Operator"&&t.peek().value==="&&";){t.consume();const r=cr(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function cr(t){let e=ur(t);for(;t.peek().type==="Operator"&&(t.peek().value==="=="||t.peek().value==="!=");){const r=t.consume().value,a=ur(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ur(t){let e=dr(t);for(;t.peek().type==="Operator"&&[">","<",">=","<="].includes(t.peek().value);){const r=t.consume().value,a=dr(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function dr(t){let e=pr(t);for(;t.peek().type==="Operator"&&(t.peek().value==="+"||t.peek().value==="-");){const r=t.consume().value,a=pr(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function pr(t){let e=kt(t);for(;t.peek().type==="Operator"&&(t.peek().value==="*"||t.peek().value==="/"||t.peek().value==="%");){const r=t.consume().value,a=kt(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function kt(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-")){t.consume();const r=kt(t);return{kind:"Unary",operator:e.value,argument:r}}return Bi(t)}function Bi(t){let e=Di(t);for(;;){const r=t.peek();if(r.type==="Punctuation"&&r.value==="."){t.consume();const a=t.consume();if(a.type!=="Identifier"&&a.type!=="Keyword")throw{message:`Expected Identifier but got ${a.type} "${a.value}"`,line:a.line,column:a.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const n=Fe(t,{named:!0});t.expect("Punctuation",")"),e={kind:"MethodCall",object:e,method:a.value,arguments:n,loc:{line:a.line,column:a.column}};continue}e={kind:"Member",object:e,property:a.value};continue}if(r.type==="Operator"&&r.value==="?."){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="["){t.consume();const a=W(t);t.expect("Punctuation","]"),e={kind:"Member",object:e,computed:a,optional:!0}}else{const a=t.consume();if(a.type!=="Identifier"&&a.type!=="Keyword")throw{message:`Expected Identifier but got ${a.type} "${a.value}"`,line:a.line,column:a.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const n=Fe(t,{named:!0});t.expect("Punctuation",")"),e={kind:"MethodCall",object:e,method:a.value,arguments:n,optional:!0,loc:{line:a.line,column:a.column}};continue}e={kind:"Member",object:e,property:a.value,optional:!0}}continue}if(r.type==="Punctuation"&&r.value==="["){t.consume();const a=W(t);t.expect("Punctuation","]"),e={kind:"Member",object:e,computed:a};continue}break}return e}function Di(t){const e=t.peek();if(e.type==="Keyword"){if(e.value==="if")return fr(t);if(e.value==="match")return Fi(t);if(e.value==="for")return Oi(t);if(e.value==="action"||e.value==="effect"){const r=t.peek(1);if(!(r&&r.type==="Identifier"))return t.consume(),{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}}if(e.type==="JsBlock")return t.consume(),{kind:"JsBlock",body:e.value,loc:{line:e.line,column:e.column}};if(e.type==="Number")return t.consume(),{kind:"Literal",value:Number(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=[],i=[];let n="",s=!1;const l=()=>{a.push(n),n="",s=!1};for(const c of r){if(c.kind==="str"){n+=c.text,s=!0;continue}s?l():a.push("");const p=fe(`__rui_tmpl__ = ${c.source}`).statements[0];p&&p.kind==="Assignment"?i.push(p.expression):i.push({kind:"Literal",value:""})}for((s||a.length===0)&&a.push(n);a.length<=i.length;)a.push("");return{kind:"Template",quasis:a,expressions:i,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 t.consume(),{kind:"StateRef",name:e.value};if(e.type==="BuiltinIdentifier"){t.consume(),t.expect("Punctuation","(");const r=Fe(t,{named:!0});return t.expect("Punctuation",")"),{kind:"BuiltinCall",name:e.value,arguments:r,loc:{line:e.line,column:e.column}}}if(e.type==="Identifier"){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Fe(t,{named:!0});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=Fe(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=hr(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),a=Ui(t);if(a)return a;t.restore(r),t.consume();const i=W(t);return t.expect("Punctuation",")"),i}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function Fe(t,e){const r=[],a=e?.named===!0;for(;t.match("Newline"););if(t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return r;for(r.push(a?gr(t):mr(t));t.match("Newline"););for(;t.peek().type==="Punctuation"&&t.peek().value===",";){for(t.consume();t.match("Newline"););if(t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))break;for(r.push(a?gr(t):mr(t));t.match("Newline"););}for(;t.match("Newline"););return r}function mr(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:W(t),loc:{line:e.line,column:e.column}}}return W(t)}function gr(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const r=t.consume();return{kind:"Spread",argument:W(t),loc:{line:r.line,column:r.column}}}if(t.peek().type==="Keyword"&&t.peek().value==="bind"){const r=t.consume();t.expect("Punctuation",":");const a=t.expect("Identifier");t.expect("Punctuation",":");const i=W(t);return{kind:"Bind",prop:a.value,target:i,loc:{line:r.line,column:r.column}}}if(t.peek().type==="Identifier"&&t.peek(1).type==="Operator"&&t.peek(1).value==="="){const r=t.peek(),a={message:`Legacy "name=value" named-arg form is removed in Aktion 0.5. Use "${r.value}: value" instead.`,line:r.line,column:r.column};throw a.__definitive=!0,a}const e=t.peek();if((e.type==="Identifier"||e.type==="Keyword")&&t.peek(1).type==="Punctuation"&&t.peek(1).value===":"){const r=t.consume();t.consume();const a=W(t);return{kind:"NamedArg",name:r.value,value:a,loc:{line:r.line,column:r.column}}}return W(t)}function fr(t){const e=t.expect("Keyword","if"),r=W(t),a=ye(t);let i;for(;t.match("Newline"););return t.peek().type==="Keyword"&&t.peek().value==="else"&&(t.consume(),t.peek().type==="Keyword"&&t.peek().value==="if"?i=fr(t):i=ye(t)),{kind:"If",test:r,consequent:a,alternate:i,loc:{line:e.line,column:e.column}}}function Fi(t){const e=t.expect("Keyword","match"),r=W(t);t.expect("Punctuation","{");const a=[];for(;t.match("Newline"););for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let i;const n=t.peek();n.type==="Keyword"&&n.value==="default"?(t.consume(),i="_"):i=W(t),t.expect("Punctuation",":");const s=W(t);for(a.push({pattern:i,body:s});t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===",")for(t.consume();t.match("Newline"););}return t.expect("Punctuation","}"),{kind:"Match",discriminant:r,arms:a,loc:{line:e.line,column:e.column}}}function Oi(t){const e=t.expect("Keyword","for");let r,a,i;if(t.peek().type==="Punctuation"&&t.peek().value==="(")t.consume(),r=t.expect("Identifier").value,t.expect("Punctuation",","),a=t.expect("Identifier").value,t.expect("Punctuation",")");else if(t.peek().type==="Punctuation"&&t.peek().value==="{"){t.consume();const l=[];for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");)l.push(t.expect("Identifier").value),t.peek().type==="Punctuation"&&t.peek().value===","&&t.consume();t.expect("Punctuation","}"),r="__row",i=l}else r=t.expect("Identifier").value;t.expect("Keyword","in");const n=W(t),s=ye(t);return{kind:"For",item:r,index:a,destructure:i,iterable:n,body:s,loc:{line:e.line,column:e.column}}}function Ui(t){const e=t.peek();if(e.type!=="Punctuation"||e.value!=="(")return null;t.consume();const r=[];for(;t.match("Newline"););if(!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){for(;t.match("Newline"););const i=t.peek();if(i.type!=="Identifier")return null;t.consume();const n={name:i.value};if(t.peek().type==="Punctuation"&&t.peek().value===":"){t.consume();try{n.defaultValue=W(t)}catch{return null}}for(r.push(n);t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}for(;t.match("Newline"););if(!(t.peek().type==="Punctuation"&&t.peek().value===")")||(t.consume(),!(t.peek().type==="Operator"&&t.peek().value==="=>")))return null;t.consume();let a;if(t.peek().type==="JsBlock"){const i=t.consume();a={kind:"JsBlock",body:i.value,loc:{line:i.line,column:i.column}}}else t.peek().type==="Punctuation"&&t.peek().value==="{"?a=ye(t):a=qi(t);return{kind:"Lambda",params:r,body:a,loc:{line:e.line,column:e.column}}}function qi(t){const e=W(t),r=t.peek();if(r.type==="Operator"){if(["=","+=","-=","*=","/=","??="].includes(r.value)){t.consume();const i=W(t);return{kind:"BuiltinCall",name:"__rui_assign__",arguments:[e,i,{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 hr(t){const e=[];for(;t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value==="}")return e;for(;;){for(;t.match("Newline"););const r=t.peek();if(r.type==="Operator"&&r.value==="..."){t.consume();const s=W(t);for(e.push({key:"",value:s,spread:!0});t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===","){for(t.consume();t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}let a;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 n;for(r.type==="Identifier"&&i.type==="Punctuation"&&(i.value===","||i.value==="}")?n={kind:"Identifier",name:a,loc:{line:r.line,column:r.column}}:(t.expect("Punctuation",":"),n=W(t)),e.push({key:a,value:n});t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value===","){for(t.consume();t.match("Newline"););if(t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}for(;t.match("Newline"););return e}function Hi(t){const e=fe(t);return br(t,e)}function br(t,e){const r=new Set(e.errors.map(l=>l.line)),a=[],i=[];for(const l of e.statements){const c=l.loc?.line??0;if(r.has(c)){i.push(l);continue}a.push(l)}let n=t,s="";if(e.errors.length>0){const l=Math.min(...e.errors.map(p=>p.line)),c=Wi(t,l);n=c.before,s=c.after;const u=a.findIndex(p=>(p.loc?.line??0)>=l);if(u>=0)for(const p of a.splice(u))i.push(p)}return{committedSource:n,draftingSource:s,committedBindings:a.map(vr).filter(l=>l!==null),uncommittedBindings:i.map(vr).filter(l=>l!==null),committedStatements:a,errors:e.errors}}function Vi(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 vr(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":return t.name;default:return null}}function Wi(t,e){if(e<=1)return{before:"",after:t};let r=0,a=1;for(;r<t.length&&a<e;)t[r]===`
12
- `&&(a+=1),r+=1;return{before:t.slice(0,r),after:t.slice(r)}}function Gi(t,e){const r=[],a={};let i=t;for(const n of e){if(n.kind==="patch"){a[n.target]=n.value;continue}const s=Ki(i,n);i=s.programText,s.warning&&r.push(s.warning)}return{programText:i,stateUpdates:a,warnings:r}}function Ki(t,e){const r=fe(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=fe(e.source);if(a.errors.length>0||a.statements.length===0)return{programText:t,warning:`delta(new): could not parse "${yr(e.source)}" — op skipped`};const i=t.endsWith(`
1
+ (function(P,pe){typeof exports=="object"&&typeof module<"u"?pe(exports):typeof define=="function"&&define.amd?define(["exports"],pe):(P=typeof globalThis<"u"?globalThis:P||self,pe(P.Aktion={}))})(this,function(P){"use strict";var kf=Object.defineProperty;var Sf=(P,pe,We)=>pe in P?kf(P,pe,{enumerable:!0,configurable:!0,writable:!0,value:We}):P[pe]=We;var D=(P,pe,We)=>Sf(P,typeof pe!="symbol"?pe+"":pe,We);const pe=new Set(["function","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"]),We=new Set(["(",")","[","]","{","}",",",":","?","."]),Ii={true:"Boolean",false:"Boolean",null:"Null"};function Vr(t){const e=[];let r=0,a=1,n=1;const i=(u=0)=>t[r+u],o=(u,c,m,d)=>{e.push({type:u,value:c,line:m,column:d})},s=()=>{const u=t[r];return r+=1,u===`
2
+ `?(a+=1,n=1):n+=1,u};for(;r<t.length;){const u=i();if(u===void 0)break;if(u===`
3
+ `){const h=a,b=n;s(),o("Newline",`
4
+ `,h,b);continue}if(u===" "||u===" "||u==="\r"){s();continue}if(u==="/"&&i(1)==="/"){for(;r<t.length&&i()!==`
5
+ `;)s();continue}if(u==="/"&&i(1)==="*"){for(s(),s();r<t.length&&!(i()==="*"&&i(1)==="/");)s();r<t.length&&(s(),s());continue}if(u===";"){const h=a,b=n;s(),o("Semicolon",";",h,b);continue}if(u==='"'||u==="'"){const h=u,b=a,v=n;s();let y="";for(;r<t.length&&i()!==h;){if(i()==="\\"&&i(1)!==void 0){s();const x=s();switch(x){case"n":y+=`
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
+ `)break;y+=s()}i()===h&&s(),o("String",y,b,v);continue}if(u==="`"){const h=a,b=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
+ `;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 A=1,S="";for(;r<t.length&&A>0;){const $=i();if($===void 0)break;if($==="`"){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($==='"'||$==="'"){const M=$;for(S+=s();r<t.length&&i()!==M;){if(i()==="\\"&&i(1)!==void 0){S+=s(),S+=s();continue}if(i()===`
9
+ `)break;S+=s()}i()===M&&(S+=s());continue}if($==="{"){A+=1,S+=s();continue}if($==="}"){if(A-=1,A===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,h,b);continue}e.push({type:"TemplateString",value:"",line:h,column:b,parts:v});continue}const c=e[e.length-1],m=!c||c.type==="Newline"||c.type==="Semicolon"||c.type==="Operator"||c.type==="Punctuation"&&(c.value==="("||c.value==="["||c.value===","||c.value===":"||c.value==="?"||c.value==="{");if(et(u)||u==="-"&&et(i(1)??"")&&m){const h=a,b=n;let v="";u==="-"&&(v+=s());let y=!1;for(;r<t.length;){const x=i()??"";if(et(x)){v+=s();continue}if(x==="."&&!y&&et(i(1)??"")){y=!0,v+=s();continue}break}o("Number",v,h,b);continue}if(u==="@"){const h=new Error("Legacy `@name(...)` builtins are removed. Use `$util.<name>(...)` or the equivalent native JavaScript instead (e.g. `arr.length` for `$util.count(arr)`).");throw h.line=a,h.column=n,h}if(u==="$"){const h=a,b=n;if(s(),i()==="$"){const y=new Error('Legacy "$$x" persistent reference is removed. Reactive state is declared with "$x = value" and referenced as "$x".');throw y.line=h,y.column=b,y}let v="";for(;r<t.length&&qr(i()??"");)v+=s();o("StateIdentifier",v,h,b);continue}if(Wr(u)){const h=a,b=n;let v="";for(;r<t.length&&qr(i()??"");)v+=s();const y=Ii[v];y==="Boolean"?o("Boolean",v,h,b):y==="Null"?o("Null",v,h,b):pe.has(v)?o("Keyword",v,h,b):o("Identifier",v,h,b);continue}if(u==="."&&i(1)==="."&&i(2)==="."){const h=a,b=n;s(),s(),s(),o("Operator","...",h,b);continue}const d=u+(i(1)??""),f=d+(i(2)??""),g=f+(i(3)??"");if(g===">>>="){const h=a,b=n;s(),s(),s(),s(),o("Operator",g,h,b);continue}if(f==="==="||f==="!=="||f==="**="||f==="??="||f==="&&="||f==="||="||f===">>>"||f===">>="||f==="<<="){const h=a,b=n;s(),s(),s(),o("Operator",f,h,b);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 h=a,b=n;s(),s(),o("Operator",d,h,b);continue}if("+-*/%!=<>&|^~".includes(u)){const h=a,b=n;s(),o("Operator",u,h,b);continue}if(We.has(u)){const h=a,b=n;s(),o("Punctuation",u,h,b);continue}s()}return e.push({type:"EOF",value:"",line:a,column:n}),e}function et(t){return t>="0"&&t<="9"}function Wr(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function qr(t){return Wr(t)||et(t)}function $e(t){const e=Vr(t),r=new Fi(e),a=[],n=[];for(;!r.isEnd();)if(!(r.match("Newline")||r.match("Semicolon")))try{const i=ht(r,!0);i&&a.push(i)}catch(i){const o=i;n.push(o),r.recoverToNextLine()}return{statements:a,errors:n}}function ht(t,e){const r=t.peek();if(r.type==="StateIdentifier"&&r.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="(")return Ri(t);if(r.type==="Keyword")switch(r.value){case"function":return Yr(t);case"await":return Di(t);case"async":{if(t.peek(1).type==="Keyword"&&t.peek(1).value==="function")return t.consume(),Yr(t);break}case"return":return Bi(t);case"let":case"const":case"var":return Jr(t);case"if":return ca(t);case"switch":return Gi(t);case"for":return Ki(t);case"while":return Xi(t);case"do":return Ji(t);case"break":return Zi(t);case"continue":return Qi(t);case"throw":return eo(t);case"try":return to(t)}const a=t.snapshot();if(Li(t))try{return Oi(t)}catch(n){if(n&&typeof n=="object"&&n.__definitive)throw n;t.restore(a)}return zi(t)}function Li(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 zi(t){const e=t.peek();let r=_(t);const a=t.peek();if(a.type==="Operator"&&Gr(a.value)){if(Kr(r)){t.consume();const n=_(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==="--")&&Kr(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 Gr(t){return t==="="||t==="+="||t==="-="||t==="*="||t==="/="||t==="%="||t==="**="||t==="??="||t==="&&="||t==="||="||t==="&="||t==="|="||t==="^="||t==="<<="||t===">>="||t===">>>="}function Kr(t){return t.kind==="Member"||t.kind==="StateRef"||t.kind==="Identifier"}function Yr(t){const e=t.expect("Keyword","function"),r=t.peek().type==="StateIdentifier",a=r?t.consume():t.expect("Identifier"),n=Xr(t),i=Ee(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,optimistic:!1,body:i,loc:{line:e.line,column:e.column}}}function Xr(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=Wt(t);let i;t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=_(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=_(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 Ri(t){const e=t.consume();t.expect("Punctuation","("),z(t);const r=_(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==="]");)Ei(t,n,s=>{i=s}),z(t),t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),z(t));t.expect("Punctuation","]")}else _(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 Ei(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 Jr(t){const e=t.consume(),r=t.peek();if(r.type==="Punctuation"&&(r.value==="["||r.value==="{"))return ji(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=_(t);return ae(t),{kind:"Assignment",identifier:a,isState:n,expression:i,loc:{line:e.line,column:e.column}}}function ji(t,e){const r=Wt(t);t.expect("Operator","=");const a=_(t);return ae(t),{kind:"DestructureStatement",patternKind:r.kind,bindings:r.bindings,expression:a,loc:{line:e.line,column:e.column}}}function Wt(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=_(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 m=t.expect("Identifier");s=i.value,o=m.value}let u;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),u=_(t));const c={name:o};if(s&&(c.sourceKey=s),n&&(c.rest=!0),u&&(c.defaultValue=u),a.push(c),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),z(t);continue}break}t.expect("Punctuation","}")}return{kind:r,bindings:a}}function Ee(t){const e=t.expect("Punctuation","{"),r=[];for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const a=ht(t);a&&r.push(a),z(t)}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function qe(t){if(z(t),t.peek().type==="Punctuation"&&t.peek().value==="{")return Ee(t);const e=t.peek(),r=ht(t);return{kind:"Block",body:r?[r]:[],loc:{line:e.line,column:e.column}}}function Di(t){const e=t.expect("Keyword","await"),r=_(t);return ae(t),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function Bi(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=_(t)),ae(t),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class Fi{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 Oi(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=_(t);return ae(t),{kind:"Assignment",identifier:r,isState:a,expression:i,loc:{line:n.line,column:n.column}}}function _(t){return Ui(t)}function _i(t){let e=0;for(;;){const r=t.peek(e);if(r.type==="Newline"){e+=1;continue}return{token:r,skipped:e}}}function ue(t,e){const{token:r,skipped:a}=_i(t);if(!e(r))return!1;for(let n=0;n<a;n+=1)t.consume();return!0}function Ui(t){const e=Hi(t);if(ue(t,r=>r.type==="Punctuation"&&r.value==="?")){t.consume(),z(t);const r=_(t);z(t),t.expect("Punctuation",":"),z(t);const a=_(t);return{kind:"Ternary",test:e,consequent:r,alternate:a}}return e}function Hi(t){let e=Zr(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="||"||r.value==="??"));){const r=t.consume().value;z(t);const a=Zr(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Zr(t){let e=Qr(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="&&");){t.consume(),z(t);const r=Qr(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function Qr(t){let e=ea(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="|");){t.consume(),z(t);const r=ea(t);e={kind:"Binary",operator:"|",left:e,right:r}}return e}function ea(t){let e=ta(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="^");){t.consume(),z(t);const r=ta(t);e={kind:"Binary",operator:"^",left:e,right:r}}return e}function ta(t){let e=ra(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="&");){t.consume(),z(t);const r=ra(t);e={kind:"Binary",operator:"&",left:e,right:r}}return e}function ra(t){let e=aa(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="=="||r.value==="!="||r.value==="==="||r.value==="!=="));){const r=t.consume().value;z(t);const a=aa(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function aa(t){let e=qt(t);for(;;){if(ue(t,r=>r.type==="Operator"&&(r.value===">"||r.value==="<"||r.value===">="||r.value==="<="))){const r=t.consume().value;z(t);const a=qt(t);e={kind:"Binary",operator:r,left:e,right:a};continue}if(ue(t,r=>r.type==="Keyword"&&(r.value==="instanceof"||r.value==="in"))){const r=t.consume().value;z(t);const a=qt(t);e={kind:"Binary",operator:r,left:e,right:a};continue}break}return e}function qt(t){let e=na(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="<<"||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=ia(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="+"||r.value==="-"));){const r=t.consume().value;z(t);const a=ia(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ia(t){let e=Gt(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="*"||r.value==="/"||r.value==="%"));){const r=t.consume().value;z(t);const a=Gt(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Gt(t){const e=tt(t);if(ue(t,r=>r.type==="Operator"&&r.value==="**")){t.consume(),z(t);const r=Gt(t);return{kind:"Binary",operator:"**",left:e,right:r}}return e}function tt(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-"||e.value==="+"||e.value==="~")){t.consume();const r=tt(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:[tt(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:[tt(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=tt(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="new"){t.consume();let r=sa(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=_(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:o};continue}break}t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),a=Te(t),t.expect("Punctuation",")"))}const n={kind:"New",callee:r,arguments:a,loc:{line:e.line,column:e.column}};return oa(t,n)}return Vi(t)}function Vi(t){const e=Wi(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 Wi(t){return oa(t,sa(t))}function oa(t,e){let r=e;for(;;){ue(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=Te(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=_(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=Te(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=Te(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=_(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n};continue}if(a.type==="Punctuation"&&a.value==="("){t.consume();const n=Te(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,loc:{line:a.line,column:a.column}};continue}break}return r}function sa(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=Xr(t),s=Ee(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=Te(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:Number(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 u of r){if(u.kind==="str"){i+=u.text,o=!0;continue}o?s():a.push("");const m=$e(`__rui_tmpl__ = ${u.source}`).statements[0];m&&m.kind==="Assignment"?n.push(m.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(),qi(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=ua(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=Te(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=Te(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=ao(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),a=ro(t);if(a)return a;t.restore(r),t.consume();const n=_(t);return t.expect("Punctuation",")"),n}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function qi(t,e){t.consume();const r=Te(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}function Te(t){const e=[];if(z(t),t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return e;for(e.push(la(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(la(t)),z(t);return z(t),e}function la(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:_(t),loc:{line:e.line,column:e.column}}}return _(t)}function ca(t){const e=t.expect("Keyword","if");t.expect("Punctuation","(");const r=_(t);t.expect("Punctuation",")");const a=qe(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=ca(t):n=qe(t)),ae(t),{kind:"IfStatement",test:r,consequent:a,alternate:n,loc:{line:e.line,column:e.column}}}function Gi(t){const e=t.expect("Keyword","switch");t.expect("Punctuation","(");const r=_(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=_(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=ht(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 Ki(t){const e=t.expect("Keyword","for");t.expect("Punctuation","("),z(t);const r=t.snapshot();let a="for-of";{let c=1,m=0;for(;;){const d=t.peek(m);if(d.type==="EOF")break;if(d.type==="Punctuation"&&d.value==="(")c+=1;else if(d.type==="Punctuation"&&d.value===")"){if(c-=1,c===0)break}else if(c===1&&d.type==="Semicolon"){a="classic";break}else if(c===1&&d.type==="Keyword"&&d.value==="of"){a="for-of";break}else if(c===1&&d.type==="Keyword"&&d.value==="in"){a="for-in";break}m+=1}}if(t.restore(r),a==="classic")return Yi(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 c=[];for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");)c.push(t.expect("Identifier").value),t.peek().type==="Punctuation"&&t.peek().value===","&&t.consume();t.expect("Punctuation","}"),n="__row",o=c}else n=t.expect("Identifier").value;a==="for-in"?t.expect("Keyword","in"):t.expect("Keyword","of");const s=_(t);t.expect("Punctuation",")");const u=qe(t);return ae(t),a==="for-in"?{kind:"ForInStatement",item:n,iterable:s,body:u,loc:{line:e.line,column:e.column}}:{kind:"ForOfStatement",item:n,index:i,destructure:o,iterable:s,body:u,loc:{line:e.line,column:e.column}}}function Yi(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=Jr(t);o.kind==="Assignment"&&(r=o),z(t)}else{const o=t.peek();r={kind:"ExpressionStatement",expression:_(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=_(t)),t.expect("Semicolon"),z(t);let n;t.peek().type==="Punctuation"&&t.peek().value===")"||(n=da(t)),t.expect("Punctuation",")");const i=qe(t);return ae(t),{kind:"ForClassicStatement",init:r,test:a,update:n,body:i,loc:{line:e.line,column:e.column}}}function Xi(t){const e=t.expect("Keyword","while");t.expect("Punctuation","(");const r=_(t);t.expect("Punctuation",")");const a=qe(t);return ae(t),{kind:"WhileStatement",test:r,body:a,loc:{line:e.line,column:e.column}}}function Ji(t){const e=t.expect("Keyword","do"),r=qe(t);z(t),t.expect("Keyword","while"),t.expect("Punctuation","(");const a=_(t);return t.expect("Punctuation",")"),ae(t),{kind:"DoWhileStatement",test:a,body:r,loc:{line:e.line,column:e.column}}}function Zi(t){const e=t.expect("Keyword","break");return ae(t),{kind:"BreakStatement",loc:{line:e.line,column:e.column}}}function Qi(t){const e=t.expect("Keyword","continue");return ae(t),{kind:"ContinueStatement",loc:{line:e.line,column:e.column}}}function eo(t){const e=t.expect("Keyword","throw"),r=_(t);return ae(t),{kind:"ThrowStatement",argument:r,loc:{line:e.line,column:e.column}}}function to(t){const e=t.expect("Keyword","try"),r=Ee(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=Ee(t),z(t)),t.peek().type==="Keyword"&&t.peek().value==="finally"&&(t.consume(),i=Ee(t)),ae(t),{kind:"TryStatement",block:r,catchParam:a,catchBlock:n,finallyBlock:i,loc:{line:e.line,column:e.column}}}function ro(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=Wt(t)}catch{return null}const u={name:"",pattern:s};if(t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{u.defaultValue=_(t)}catch{return null}}if(r.push(u),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=_(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=ua(t);return{kind:"Lambda",params:r,body:a,loc:{line:e.line,column:e.column}}}function ua(t){return z(t),t.peek().type==="Punctuation"&&t.peek().value==="{"?Ee(t):da(t)}function da(t){const e=_(t),r=t.peek();if(r.type==="Operator"){if(Gr(r.value)){t.consume();const a=_(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 ao(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 u=_(t);if(e.push({key:"",value:u,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=_(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=_(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 no(t){const e=$e(t);return pa(t,e)}function pa(t,e){const r=new Set(e.errors.map(s=>s.line)),a=[],n=[];for(const s of e.statements){const u=s.loc?.line??0;if(r.has(u)){n.push(s);continue}a.push(s)}let i=t,o="";if(e.errors.length>0){const s=Math.min(...e.errors.map(m=>m.line)),u=oo(t,s);i=u.before,o=u.after;const c=a.findIndex(m=>(m.loc?.line??0)>=s);if(c>=0)for(const m of a.splice(c))n.push(m)}return{committedSource:i,draftingSource:o,committedBindings:a.map(ma).filter(s=>s!==null),uncommittedBindings:n.map(ma).filter(s=>s!==null),committedStatements:a,errors:e.errors}}function io(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 ma(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function oo(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)}}function so(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=lo(n,i);n=o.programText,o.warning&&r.push(o.warning)}return{programText:n,stateUpdates:a,warnings:r}}function lo(t,e){const r=$e(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=$e(e.source);if(a.errors.length>0||a.statements.length===0)return{programText:t,warning:`delta(new): could not parse "${fa(e.source)}" — op skipped`};const n=t.endsWith(`
13
11
  `)?"":`
14
- `;return{programText:t+i+e.source.trim()+`
15
- `}}case"delete":{const a=St(r,e.binding);return a<0?{programText:t,warning:`delta(delete): binding "${e.binding}" not found — op skipped`}:{programText:Ct(t,r,a,null)}}case"replace":{const a=St(r,e.binding);return a<0?{programText:t,warning:`delta(replace): binding "${e.binding}" not found — op skipped`}:fe(`${e.binding} = ${e.source}`).errors.length>0?{programText:t,warning:`delta(replace): could not parse new source for "${e.binding}" — op skipped`}:{programText:Ct(t,r,a,`${e.binding} = ${e.source.trim()}`)}}case"append":{const a=St(r,e.binding);if(a<0)return{programText:t,warning:`delta(append): binding "${e.binding}" not found — op skipped`};const i=r.statements[a];if(i.kind!=="Assignment"||i.expression.kind!=="Array")return{programText:t,warning:`delta(append): binding "${e.binding}" is not an array literal — op skipped`};const n=fe(`__rui_delta_item__ = ${e.item}`),s=n.statements[0];if(n.errors.length>0||!s||s.kind!=="Assignment")return{programText:t,warning:`delta(append): could not parse item "${yr(e.item)}" — op skipped`};const l=i.expression.elements,c=`${e.binding} = [${[...l.map(se),e.item.trim()].join(", ")}]`;return{programText:Ct(t,r,a,c)}}}}function St(t,e){return t.statements.findIndex(r=>Yi(r)===e)}function Yi(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":return t.name;default:return null}}function Ct(t,e,r,a){const i=t.split(`
16
- `),n=e.statements[r],s=e.statements[r+1],l=(n.loc?.line??1)-1,c=s?(s.loc?.line??i.length+1)-1:i.length,u=i.slice(0,l),p=i.slice(c);return a===null?[...u,...p].join(`
17
- `):[...u,a,...p].join(`
18
- `)}function se(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(se).join(", ")})`;case"MethodCall":return`${se(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(se).join(", ")})`;case"NamedArg":return`${t.name}: ${se(t.value)}`;case"Array":return`[${t.elements.map(se).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${se(e.value)}`:`${e.key}: ${se(e.value)}`).join(", ")} }`;case"Member":{const e=se(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${se(t.computed)}]`:e}case"Binary":return`${se(t.left)} ${t.operator} ${se(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(se(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function yr(t){return t.length>40?`${t.slice(0,37)}...`:t}const xr=new WeakMap;function Ji(t){let e=xr.get(t.components);if(!e){e=new Map;for(const r of t.components)r?.name&&e.set(r.name,r);xr.set(t.components,e)}return e}function wr(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 Ie(t,e){return Ji(t).get(e)}function Tt(t){const e=t.props.findIndex(r=>r.positional===!0);return e>=0?e:t.props.length>0?0:-1}function $t(t){const e=Tt(t);return e>=0?t.props[e]:void 0}function kr(t){for(const e of t){const r=e.props.filter(a=>a.positional===!0);if(r.length>1){const a=r.map(i=>i.name).join(", ");throw new SyntaxError(`Component "${e.name}" declares ${r.length} positional props (${a}). Aktion 0.5 §19.1 allows at most one.`)}}}function Sr(t,e){const r={};return t.props.forEach((a,i)=>{i<e.length&&(r[a.name]=e[i])}),r}function Xi(t,e){const r=fe(t),a=Nt(r,e);return a.length>0&&(r.errors=[...r.errors,...a]),r}function Nt(t,e){const r=[];for(const a of t.statements)Oe(a,e,r);return r}function Oe(t,e,r){switch(t.kind){case"Assignment":G(t.expression,e,r);return;case"ExpressionStatement":G(t.expression,e,r);return;case"ComponentDeclaration":case"ActionDeclaration":case"EffectDeclaration":for(const a of t.body.body)Oe(a,e,r);return;case"Return":t.argument&&G(t.argument,e,r);return;default:return}}function G(t,e,r){if(t)switch(t.kind){case"Call":{Qi(t,e,r);for(const a of t.arguments)G(a,e,r);return}case"MethodCall":{G(t.object,e,r);for(const a of t.arguments)G(a,e,r);return}case"BuiltinCall":{nn(t,r);for(const a of t.arguments)G(a,e,r);return}case"Array":for(const a of t.elements)G(a,e,r);return;case"Object":for(const a of t.properties)G(a.value,e,r);return;case"Template":for(const a of t.expressions)G(a,e,r);return;case"Binary":G(t.left,e,r),G(t.right,e,r);return;case"Unary":G(t.argument,e,r);return;case"Ternary":G(t.test,e,r),G(t.consequent,e,r),G(t.alternate,e,r);return;case"Member":G(t.object,e,r),t.computed&&G(t.computed,e,r);return;case"Spread":G(t.argument,e,r);return;case"NamedArg":G(t.value,e,r);return;case"If":G(t.test,e,r);for(const a of t.consequent.body)Oe(a,e,r);if(t.alternate)if(t.alternate.kind==="If")G(t.alternate,e,r);else for(const a of t.alternate.body)Oe(a,e,r);return;case"Match":G(t.discriminant,e,r);for(const a of t.arms)G(a.body,e,r);return;case"For":G(t.iterable,e,r);for(const a of t.body.body)Oe(a,e,r);return;case"Lambda":t.body.kind!=="JsBlock"&&G(t.body,e,r);return;case"Bind":G(t.target,e,r);return;default:return}}const Zi={Script:'Script("id", body, deps?) is not supported. Use an `effect [$deps] { js{ … } }` block (see §9 — effect declarations).',Action:'Action([@Set, @Run, …]) payloads are removed in 0.5. Use `action <Name>() { … }` declarations and reference them by name (e.g. `Button("Save", action: save)`) — see §10.',Routes:'Routes(items, default?) is removed in 0.5. Use `pages = _router_({ "/": Home(), default: NotFound() })` (see §12 — outlet-first router).',Route:'Route(path, content) is only valid inside a v1 `Routes(...)` outlet, which has been removed. Use `"/path": content` arms inside a `_router_({ … })` call (see §12).',Query:'Query("name", args, placeholder, refreshSec?) is removed in 0.5. Declare a top-level `query <Name>(args) { url, method, … }` block and bind it with `$query foo = <Name>(args)` (see §11.2).',Mutation:'Mutation("name", args) is removed in 0.5. Declare a top-level `mutation <Name>(args) { url, method, body, … }` block and bind it with `$mutation save = <Name>` (see §11.3).',NavLinkRoute:'NavLinkRoute is removed in 0.5. Use `NavLink(label, to: "/path")` (see §12 — Outlet-first router).',useInstanceState:"useInstanceState(...) is removed in 0.5. Declare per-instance state inside the component body with `$state name = init` — identity is content-addressed (§13)."};function Qi(t,e,r){const a=Zi[t.callee];if(a){r.push({message:`${t.callee}(...) — ${a}`,line:t.loc?.line??0,column:t.loc?.column??0});return}if(t.callee==="Theme"){rn(t,r);return}const i=Ie(e,t.callee);if(!i)return;const n=new Set;for(const l of i.props)if(n.add(l.name),l.aliases)for(const c of l.aliases)n.add(c);n.add("key");const s=[];for(const l of t.arguments)l.kind!=="NamedArg"&&s.push(l);if(s.length>1){const c=$t(i)?.name??"(none)",u=new Set(t.arguments.filter(g=>g.kind==="NamedArg").map(g=>g.name)),p=i.props.filter(g=>g.name!==c&&!u.has(g.name)).slice(0,s.length-1).map(g=>g.name),m=p.length>0?p.map(g=>`${g}: …`).join(", "):"use named arguments";r.push({message:`${t.callee}(...) — Aktion 0.5 §19.1 allows at most one positional argument (the "${c}" prop). The extra ${s.length-1} positional argument(s) must be passed as named arguments: ${m}. Multi-positional calls are removed.`,line:t.loc?.line??0,column:t.loc?.column??0})}for(const l of t.arguments){if(l.kind!=="NamedArg")continue;if(!n.has(l.name)){r.push({message:`Unknown prop "${l.name}" on <${t.callee}>. Known props: ${i.props.map(u=>u.name).join(", ")}.`,line:l.loc?.line??t.loc?.line??0,column:l.loc?.column??t.loc?.column??0});continue}const c=i.props.find(u=>u.name===l.name||(u.aliases?.includes(l.name)??!1));if(c?.enum&&l.value.kind==="Literal"&&typeof l.value.value=="string"){const u=l.value.value;c.enum.includes(u)||r.push({message:`<${t.callee}> ${l.name}="${u}" — must be one of ${c.enum.map(p=>`"${p}"`).join(", ")}.`,line:l.loc?.line??t.loc?.line??0,column:l.loc?.column??t.loc?.column??0})}}}const en=new Set(["colors","radius","font","motion","elevation"]),tn=new Set(["name","direction"]);function rn(t,e){const r=t.arguments[0];if(!(!r||r.kind!=="Object"))for(const a of r.properties){if(a.spread||en.has(a.key)||tn.has(a.key))continue;const i=on(a.key),n=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 ${i}.`;e.push({message:n,line:t.loc?.line??0,column:t.loc?.column??0})}}const an={Set:"@Set($x, value) is removed in 0.5. Inside an `action Name() { … }` body, assign directly: `$x = value`.",Reset:"@Reset($x) is removed in 0.5. Inside an `action Name() { … }` body, assign the default explicitly: `$x = defaultValue`.",Run:"@Run(name) is removed in 0.5. Inside an `action Name() { … }` body, call the mutation: `await $mutation.foo.call(args)` (see §11.3).",ToAssistant:'@ToAssistant("text") is removed in 0.5. Use `emit "assistant-message" { message: "..." }` inside an `action Name() { … }` body (see §22.2).',OpenUrl:'@OpenUrl("https://…") is removed in 0.5. Inside an `action Name() { js{ … } }` body, call `window.open(url, "_blank", "noopener,noreferrer")`.',Navigate:'@Navigate("/path") is removed in 0.5. Use `pages = _router_({ … })` (see §12) and navigate via the host (`el.navigate("/path")`), `_route_.navigate("/path")` from inside an action, or by linking to the path with `NavLink(label, "/path")`.',Js:"@Js(body, args?) is removed in 0.5. Use `effect <id> on $deps { js{ … } }` or `action Name() { js{ … } }` (see §9, §10).",Const:"@Const(expr) is removed in 0.5. Use `$computed name = expr` (see §4 — state tiers).",Memo:"@Memo(expr) is removed in 0.5. Use `$computed name = expr` (see §4 — state tiers).",Push:"@Push(arr, value) is removed in 0.5. Use spread: `[...arr, value]`.",Concat:"@Concat(a, b) is removed in 0.5. Use spread: `[...a, ...b]`.",Map:'@Map(arr, "field") is removed in 0.5. Use array pluck shorthand: `arr.field` (yields `[arr[0].field, arr[1].field, …]`).',Take:"@Take(arr, n) is removed in 0.5. Use @Slice(arr, 0, n) or array shortcuts like `arr.first` / `arr.last`.",FormatCurrency:'@FormatCurrency(value, opts?) is removed in 0.5. Use `@Format(value, "currency", opts?)`.',FormatNumber:'@FormatNumber(value, opts?) is removed in 0.5. Use `@Format(value, "number", opts?)`.',Each:'@Each(items, "x", template) is removed in 0.5. Use the expression-form loop: `for x in items { template }` (see §8.3).',If:"@If(cond, then, else?) is removed in 0.5. Use the expression-form conditional: `if cond { then } else { else }` (see §8.1).",Switch:'@Switch(value, cases, default?) is removed in 0.5. Use the expression-form match: `match value { "a" -> A() _ -> Default() }` (see §8.2).'};function nn(t,e){const r=an[t.name];r&&e.push({message:`@${t.name}(...) — ${r}`,line:t.loc?.line??0,column:t.loc?.column??0})}function on(t){const e=[{prefix:"color",group:"colors"},{prefix:"radius",group:"radius"},{prefix:"font",group:"font"},{prefix:"motion",group:"motion"},{prefix:"elevation",group:"elevation"}];for(const{prefix:r,group:a}of e)if(t!==r&&t.startsWith(r)&&t.length>r.length){const i=t.slice(r.length),n=i.charAt(0).toLowerCase()+i.slice(1);return`Theme({ ${a}: { ${n}: ... } })`}return"Theme({ colors: {...}, radius: {...}, font: {...}, motion: {...}, elevation: {...} })"}const F=t=>typeof t=="number"?t:typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):0,ae=t=>Array.isArray(t)?t:[],Cr=(t,e,r)=>{switch(t){case"==":return e===r;case"!=":return e!==r;case">":return F(e)>F(r);case"<":return F(e)<F(r);case">=":return F(e)>=F(r);case"<=":return F(e)<=F(r);case"contains":{const a=String(e??"").toLowerCase(),i=String(r??"").toLowerCase();return a.includes(i)}default:return!1}},ze=(t,e)=>{if(e==="")return t;if(t&&typeof t=="object"){if(e.includes(".")){const r=e.split(".");let a=t;for(const i of r)if(a&&typeof a=="object")a=a[i];else return;return a}return t[e]}},Tr=t=>{const e=ae(t[0]),r=String(t[1]??""),a=String(t[2]??"=="),i=t[3];return e.filter(n=>Cr(a,ze(n,r),i))},sn=t=>!!t&&typeof t=="object"&&!Array.isArray(t),xe=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},ln=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],cn=["January","February","March","April","May","June","July","August","September","October","November","December"],un=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dn=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pn=(t,e)=>{const r=(l,c=2)=>String(l).padStart(c,"0"),a=t.getHours(),i=(a+11)%12+1,n=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,cn[t.getMonth()]],[/MMM/g,ln[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,dn[t.getDay()]],[/ddd/g,un[t.getDay()]],[/DD/g,r(t.getDate())],[/HH/g,r(a)],[/hh/g,r(i)],[/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(i)],[/\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 s=e;for(const[l,c]of n)s=s.replace(l,c);return s},mn=(t,e=Date.now())=>{const r=e-t.getTime(),a=Math.abs(r),i=r<0,n=6e4,s=60*n,l=24*s,c=7*l,u=30*l,p=365*l;let m,g;return a<n?i?"in a moment":"just now":(a<s?(m=Math.round(a/n),g="m"):a<l?(m=Math.round(a/s),g="h"):a<c?(m=Math.round(a/l),g="d"):a<u?(m=Math.round(a/c),g="w"):a<p?(m=Math.round(a/u),g="mo"):(m=Math.round(a/p),g="y"),i?`in ${m}${g}`:`${m}${g} ago`)},$r=(t,e)=>{const a=String(t??"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(n=>n.toLowerCase());if(a.length===0)return"";if(e==="snake")return a.join("_");if(e==="kebab")return a.join("-");const i=n=>n.charAt(0).toUpperCase()+n.slice(1);return e==="pascal"?a.map(i).join(""):a[0]+a.slice(1).map(i).join("")},At={Count:t=>ae(t[0]).length,Sum:t=>ae(t[0]).reduce((e,r)=>e+F(r),0),Avg:t=>{const e=ae(t[0]);return e.length===0?0:e.reduce((r,a)=>r+F(a),0)/e.length},Min:t=>{const e=ae(t[0]).map(F);return e.length===0?0:Math.min(...e)},Max:t=>{const e=ae(t[0]).map(F);return e.length===0?0:Math.max(...e)},First:t=>ae(t[0])[0]??null,Last:t=>{const e=ae(t[0]);return e.length===0?null:e[e.length-1]},Filter:Tr,FilterBy:Tr,Sort:t=>{const e=[...ae(t[0])],r=String(t[1]??""),a=String(t[2]??"asc").toLowerCase()==="desc"?-1:1;return e.sort((i,n)=>{const s=ze(i,r),l=ze(n,r);return typeof s=="number"&&typeof l=="number"?(s-l)*a:String(s??"").localeCompare(String(l??""))*a}),e},Round:t=>{const e=F(t[0]),r=t[1]===void 0?0:F(t[1]),a=Math.pow(10,r);return Math.round(e*a)/a},Abs:t=>Math.abs(F(t[0])),Floor:t=>Math.floor(F(t[0])),Ceil:t=>Math.ceil(F(t[0])),Find:t=>{const e=ae(t[0]),r=String(t[1]??""),a=String(t[2]??"=="),i=t[3];return e.find(n=>Cr(a,ze(n,r),i))??null},GroupBy:t=>{const e=ae(t[0]),r=String(t[1]??""),a={};for(const i of e){const n=String(ze(i,r)??"");(a[n]??(a[n]=[])).push(i)}return a},Slice:t=>{const e=ae(t[0]),r=t[1]===void 0?0:F(t[1]),a=t[2]===void 0?e.length:F(t[2]);return e.slice(r,a)},Unique:t=>{const e=ae(t[0]),r=t[1]===void 0?"":String(t[1]??"");if(!r)return Array.from(new Set(e));const a=new Set,i=[];for(const n of e){const s=ze(n,r);a.has(s)||(a.add(s),i.push(n))}return i},Reverse:t=>[...ae(t[0])].reverse(),Range:t=>{const e=F(t[0]),r=F(t[1]),a=t[2]===void 0?r>=e?1:-1:F(t[2]);if(a===0)return[e];const i=[];if(a>0)for(let n=e;n<=r;n+=a)i.push(n);else for(let n=e;n>=r;n+=a)i.push(n);return i},Repeat:t=>{const e=Math.max(0,F(t[1]));return Array.from({length:e},()=>t[0])},Pick:t=>{const e=t[0];if(!sn(e))return{};const r=ae(t[1]).map(i=>String(i??"")),a={};for(const i of r)i in e&&(a[i]=e[i]);return a},Format:t=>{const e=F(t[0]),r=String(t[1]??"number"),a=t[2];if(r==="currency"){const n=String(a??"USD")||"USD",s=t[3]===void 0?void 0:String(t[3]??"");try{return new Intl.NumberFormat(s||void 0,{style:"currency",currency:n}).format(e)}catch{return e.toFixed(2)}}if(r==="percent"){const n=t[2]===void 0?void 0:String(t[2]??"");return new Intl.NumberFormat(n||void 0,{style:"percent",maximumFractionDigits:2}).format(e)}const i=t[2]===void 0?void 0:String(t[2]??"");return new Intl.NumberFormat(i||void 0).format(e)},FormatDate:t=>{const e=xe(t[0]),r=String(t[1]??"MMM D");switch(r){case"relative":return mn(e);case"date":return e.toLocaleDateString();case"time":return e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});case"datetime":return e.toLocaleString();case"iso":return e.toISOString();default:return pn(e,r)}},Now:()=>Date.now(),Today:()=>{const t=new Date;return t.setHours(0,0,0,0),t.toISOString()},AddDays:t=>{const e=xe(t[0]),r=F(t[1]),a=new Date(e.getTime());return a.setDate(a.getDate()+r),a.toISOString()},AddHours:t=>{const e=xe(t[0]),r=F(t[1]),a=new Date(e.getTime());return a.setTime(a.getTime()+r*36e5),a.toISOString()},DiffDays:t=>{const e=xe(t[0]),r=xe(t[1]);return Math.round((r.getTime()-e.getTime())/864e5)},StartOfWeek:t=>{const e=xe(t[0]),r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));return r.setUTCDate(r.getUTCDate()-r.getUTCDay()),r.toISOString()},EndOfMonth:t=>{const e=xe(t[0]);return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999).toISOString()},Plural:t=>{const e=F(t[0]),r=String(t[1]??""),a=t[2]===void 0?r+"s":String(t[2]??"");return`${e} ${e===1?r:a}`},Capitalize:t=>{const e=String(t[0]??"");return e.length===0?"":e.charAt(0).toUpperCase()+e.slice(1)},Lowercase:t=>String(t[0]??"").toLowerCase(),Uppercase:t=>String(t[0]??"").toUpperCase(),Titlecase:t=>String(t[0]??"").split(/\s+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),Case:t=>{const e=String(t[1]??"camel").toLowerCase();return e==="snake"||e==="kebab"||e==="pascal"||e==="camel"?$r(t[0],e):$r(t[0],"camel")},Join:t=>{const e=ae(t[0]),r=t[1]===void 0?",":String(t[1]??"");return e.map(a=>a==null?"":String(a)).join(r)},Split:t=>{const e=String(t[0]??""),r=t[1]===void 0?",":String(t[1]??"");return e.split(r)},Trim:t=>String(t[0]??"").trim(),Replace:t=>{const e=String(t[0]??""),r=String(t[1]??""),a=t[2]===void 0?"":String(t[2]??"");return e.split(r).join(a)},Substring:t=>{const e=String(t[0]??""),r=F(t[1]),a=t[2]===void 0?e.length:F(t[2]);return e.substring(r,a)},StartsWith:t=>String(t[0]??"").startsWith(String(t[1]??"")),EndsWith:t=>String(t[0]??"").endsWith(String(t[1]??"")),Contains:t=>String(t[0]??"").includes(String(t[1]??"")),Match:t=>{const e=String(t[0]??""),r=String(t[1]??"");try{return new RegExp(r).test(e)}catch{return!1}},Clamp:t=>{const e=F(t[0]),r=F(t[1]),a=F(t[2]);return Math.min(Math.max(e,r),a)},Pow:t=>Math.pow(F(t[0]),F(t[1])),Sqrt:t=>Math.sqrt(F(t[0])),Random:()=>Math.random(),Log:t=>Math.log(F(t[0]))},Nr=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");class Ar{constructor(){j(this,"values",new Map);j(this,"defaults",new Map);j(this,"persistent",new Set);j(this,"persistenceAdapter",null);j(this,"subscribers",new Set);j(this,"pendingChanges",new Set);j(this,"flushScheduled",!1)}setPersistenceAdapter(e){this.persistenceAdapter=e}declare(e,r){this.defaults.set(e,r),this.values.has(e)||this.values.set(e,r)}declarePersistent(e,r){this.persistent.add(e),this.defaults.set(e,r);const a=this.persistenceAdapter;let i=r;if(a){const n=a.load(e);n!==void 0&&(i=n)}this.values.set(e,i)}isPersistent(e){return this.persistent.has(e)}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.pendingChanges.add(e),this.persistent.has(e)&&this.persistenceAdapter?.save(e,r),this.scheduleFlush())}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){let r=!1;for(const a of e){if(!this.defaults.has(a))continue;const i=this.defaults.get(a);this.values.get(a)!==i&&(this.values.set(a,i),this.pendingChanges.add(a),this.persistent.has(a)&&this.persistenceAdapter?.save(a,i),r=!0)}r&&this.scheduleFlush()}resetAll(){let e=!1;for(const[r,a]of this.defaults.entries())this.values.get(r)!==a&&(this.values.set(r,a),this.pendingChanges.add(r),e=!0);e&&this.scheduleFlush()}rebind(e){this.values.clear(),this.defaults.clear(),this.persistent.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 Mr(t,e){if(!e)return null;const r=a=>`${t}::${a}`;return{load(a){try{const i=e.getItem(r(a));return i===null?void 0:JSON.parse(i)}catch{return}},save(a,i){try{e.setItem(r(a),JSON.stringify(i))}catch{}},remove(a){try{e.removeItem(r(a))}catch{}}}}class Pr{constructor(){j(this,"interceptors",{});j(this,"defaults",{})}setDefaults(e){this.defaults={...e}}registerInterceptors(e){this.interceptors={...this.interceptors,...e}}resolveUrl(e){const r=this.defaults.baseUrl;return!r||/^https?:\/\//i.test(e)||/^wss?:\/\//i.test(e)?e:e.startsWith("/")?r.replace(/\/$/,"")+e:r.replace(/\/$/,"")+"/"+e}async request(e){let r={...e,headers:{...this.defaults.headers,...e.headers}};if(this.interceptors.onRequest)try{r=await this.interceptors.onRequest(r)}catch(c){throw this.interceptors.onError?.(c,r),c}const a=async()=>{const c=new AbortController,u=this.defaults.timeoutMs??0;let p=null;u>0&&(p=setTimeout(()=>c.abort(),u));try{const m=typeof fetch=="function"?fetch:null;if(!m)throw new Error("`fetch` is not available in this environment");const g={method:r.method,headers:r.headers,signal:r.signal??c.signal};r.body!==void 0&&r.method!=="GET"&&r.method!=="HEAD"&&(g.body=gn(r.body,r.headers)),this.defaults.credentials&&(g.credentials=this.defaults.credentials);const f=await m(r.url,g),h={};f.headers.forEach((y,x)=>{h[x]=y});const b=h["content-type"]??"";let v;return f.status===204||r.method==="HEAD"?v=null:b.includes("application/json")?v=await f.json().catch(()=>null):v=await f.text().catch(()=>""),{status:f.status,headers:h,body:v}}finally{p&&clearTimeout(p)}},i=this.defaults.retry,n=Math.max(0,i?.count??0),s=i?.backoff??"exponential",l=async()=>{let c=null;for(let u=0;u<=n;u+=1)try{const p=await a();if(p.status>=500&&p.status<=599&&u<n){await zr(Ir(s,u));continue}return p}catch(p){if(c=p,u<n){await zr(Ir(s,u));continue}throw p}throw c??new Error("retry loop exhausted")};try{let c=await l();if(this.interceptors.onResponse){let u=!1;const p=async()=>u?c:(u=!0,l());c=await this.interceptors.onResponse(c,p)}return c}catch(c){throw this.interceptors.onError?.(c,r),c}}}function Ir(t,e){return t==="linear"?1e3*(e+1):Math.min(3e4,500*2**e)}function zr(t){return new Promise(e=>setTimeout(e,t))}function gn(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)}}function fn(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",i={};if(e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(const[l,c]of Object.entries(e.headers))c!=null&&(i[l]=String(c));let n=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const l=new URLSearchParams;for(const[u,p]of Object.entries(e.query))p!=null&&l.append(u,String(p));const c=l.toString();c&&(n+=(n.includes("?")?"&":"?")+c)}const s={url:n,method:a,headers:i,body:e.body};return e.signal instanceof AbortSignal&&(s.signal=e.signal),s}function Rr(t,e){const r={state:"loading",data:void 0,error:void 0,loading:!0,refetch:async()=>{await s()},cancel:()=>{a&&a.abort()}};let a=null,i=!1;const n=()=>e.notify?.(),s=async()=>{if(i&&a&&a.abort(),i=!0,a=new AbortController,r.state=r.data===void 0?"loading":"stale",r.loading=!0,n(),!e.http){r.error={message:"http runtime not available"},r.state="error",r.loading=!1,i=!1,n();return}try{const l=fn(t);l.url=e.http.resolveUrl(l.url),l.signal=a.signal;const c=await e.http.request(l);c.status>=200&&c.status<300?(r.data=c.body,r.state="data",r.error=void 0):(r.error={status:c.status,body:c.body},r.state="error"),r.status=c.status,r.headers=c.headers,r.lastUpdated=Date.now()}catch(l){if(l?.name==="AbortError")return;r.error=l,r.state="error"}finally{i=!1,r.loading=!1,n()}};return s(),r}function we(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 Lr(t,e){if(!t)return{matched:!1,params:{}};if(t==="*")return{matched:!0,params:{},wildcard:!0};const r=we(t),a=we(e),i=r==="/"?[]:r.slice(1).split("/"),n=a==="/"?[]:a.slice(1).split("/"),s={};let l=!1;for(let c=0;c<i.length;c+=1){const u=i[c];if(u==="*"){l=!0;const m=n.slice(c).join("/");return s._=m,{matched:!0,params:s,wildcard:l}}const p=n[c];if(p===void 0)return{matched:!1,params:{}};if(u.startsWith(":")){const m=u.slice(1);if(!m)return{matched:!1,params:{}};s[m]=decodeURIComponent(p);continue}if(u!==p)return{matched:!1,params:{}}}return!l&&n.length>i.length?{matched:!1,params:{}}:l?{matched:!0,params:s,wildcard:!0}:{matched:!0,params:s}}class Er{constructor(e={}){j(this,"currentPath");j(this,"currentParams",{});j(this,"currentPattern",null);j(this,"enabled",!1);j(this,"hashListener",null);j(this,"listeners",new Set);j(this,"defaultPath");j(this,"settingHash",!1);this.defaultPath=we(e.defaultPath??"/"),this.currentPath=this.defaultPath}start(){if(this.enabled||(this.enabled=!0,typeof window>"u"))return;const e=a=>{if(this.settingHash)return;const i=we(window.location.hash);this.setPath(i,a)},r=()=>e("hashchange");window.addEventListener("hashchange",r),this.hashListener=r,e("init")}stop(){this.enabled&&(this.enabled=!1,typeof window<"u"&&this.hashListener&&window.removeEventListener("hashchange",this.hashListener),this.hashListener=null)}getPath(){return this.currentPath}getParams(){return this.currentParams}getActivePattern(){return this.currentPattern}setActiveMatch(e,r){this.currentPattern=e,hn(this.currentParams,r)||(this.currentParams=r)}navigate(e){const r=we(e);if(r!==this.currentPath){if(this.enabled&&typeof window<"u"){this.settingHash=!0;try{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=we(e);if(a===this.currentPath)return;const i=this.currentPath;this.currentPath=a,this.currentParams={},this.currentPattern=null;for(const n of[...this.listeners])try{n({path:a,previousPath:i,source:r})}catch(s){console.error("[aktion] router listener failed",s)}}}function hn(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const i of r)if(t[i]!==e[i])return!1;return!0}const be=(t,e)=>{try{return t()}catch{return e}},_r=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)}},jr=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},Br=t=>({set:(e,r)=>be(()=>{const a=t();return a?(a.setItem(String(e),_r(r)),!0):!1},!1),get:e=>be(()=>{const r=t();return r?jr(r.getItem(String(e))):null},null),remove:e=>be(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>be(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),bn=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,vn=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,Qe=()=>typeof globalThis>"u"?null:globalThis.document??null,yn=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},Mt=(t={})=>{const e=[],r=yn(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("; ")}`},Dr=()=>{const t=Qe();if(!t)return{};const e={},r=t.cookie??"";if(!r)return e;for(const a of r.split(";")){const i=a.trim();if(!i)continue;const n=i.indexOf("=");if(n<0){e[decodeURIComponent(i)]="";continue}const s=decodeURIComponent(i.slice(0,n)),l=decodeURIComponent(i.slice(n+1));e[s]=l}return e},xn={set:(t,e,r)=>be(()=>{const a=Qe();if(!a)return!1;const i=encodeURIComponent(String(t)),n=encodeURIComponent(_r(e));return a.cookie=`${i}=${n}${Mt(r)}`,!0},!1),get:t=>be(()=>{const r=Dr()[String(t)];return r===void 0?null:jr(r)},null),remove:(t,e)=>be(()=>{const r=Qe();if(!r)return!1;const a=encodeURIComponent(String(t)),i={...e,expires:new Date(0),maxAge:0};return r.cookie=`${a}=${Mt(i)}`,!0},!1),clear:()=>be(()=>{const t=Qe();if(!t)return!1;const e=Dr();for(const r of Object.keys(e)){const a=encodeURIComponent(r);t.cookie=`${a}=${Mt({expires:new Date(0),maxAge:0})}`}return!0},!1)},Ue=Br(bn),wn=Br(vn),Fr={set:Ue.set,get:Ue.get,remove:Ue.remove,clear:Ue.clear,local:Ue,session:wn,cookies:xn},kn=["log","error","warn","info","debug"],Sn=()=>typeof globalThis>"u"?null:globalThis.console??null,Cn=t=>(...e)=>{const r=Sn();if(!r)return;const a=r[t]??r.log;if(typeof a=="function")try{a(...e)}catch{}},Or=kn.reduce((t,e)=>(t[e]=Cn(e),t),{}),Ur={storage:Fr,console:Or},qr=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),Hr=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent");function Pt(t,e={}){return{state:t,bindings:new Map,expressions:new Map,trackedState:new Set,loopVars:new Map,stateAliases:[],router:e.router,library:e.library,componentDecls:new Map,effectDecls:new Map,componentEffectStack:[],actionDecls:new Map,http:e.http,i18n:e.i18n,actionRunner:e.actionRunner,notify:e.notify,jsBlockExecutor:e.jsBlockExecutor}}function Vr(t,e){const r={};for(let a=0;a<t.length;a+=1)r[t[a].name]=e[a];return r}function ke(t,e){for(let r=t.stateAliases.length-1;r>=0;r-=1){const i=t.stateAliases[r].get(e);if(i!==void 0)return i}return e}function Wr(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const a=et(r.expression);e.state.declare(r.identifier,a)}for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||r.expression.kind!=="Call"||r.expression.callee!=="http")continue;const a=M(r.expression,e);e.state.set(r.identifier,a)}for(const r of t.statements){if(r.kind!=="Assignment")continue;const a=r.expression;if(a.kind==="Call"){if((r.identifier==="http"||r.identifier==="$http")&&a.callee==="Http"){M(a,e);continue}if((r.identifier==="i18n"||r.identifier==="$i18n")&&a.callee==="i18n"){M(a,e);continue}}}for(const r of t.statements)It(r,e)}function It(t,e){switch(t.kind){case"ComponentDeclaration":e.componentDecls.set(t.name,t);return;case"EffectDeclaration":e.effectDecls.set(t.name,t);return;case"ActionDeclaration":e.actionDecls.set(t.name,t);return;case"Emit":case"Cleanup":case"Await":case"Return":case"ExpressionStatement":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 Tn(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 i=Dn(e);let n=null;for(const s of a.properties){if(s.spread)continue;const l=s.key;if(l==="default"||l==="*"){n=s;continue}const c=Lr(l,i);if(c.matched)return Gr(l,s.value,c.params,e)}return n?Gr(null,n.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function Gr(t,e,r,a){const i=a.loopVars.get("params"),n=a.loopVars.has("params");a.loopVars.set("params",r);try{const s=M(e,a);return a.router?.setActiveMatch(t,r),s}finally{n?a.loopVars.set("params",i):a.loopVars.delete("params")}}function et(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(et(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=et(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(t.name==="_route_")return e.trackedState.add("route"),e.router?Fn(e.router):{path:"/",params:{},pattern:null,query:{},navigate(){},toString(){return"/"}};const r=e.bindings.get(t.name);if(r)return r();const a=e.actionDecls.get(t.name);return a?Yr(a,e):Object.prototype.hasOwnProperty.call(Ur,t.name)?Ur[t.name]:null}case"StateRef":{const r=ke(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 i=M(a.argument,e);if(Array.isArray(i))for(const n of i)r.push(n);else if(i!=null&&typeof i=="string")for(const n of i)r.push(n);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[n,s]of Object.entries(i))r[n]=s;continue}r[a.key]=M(a.value,e)}return r}case"Member":{const r=M(t.object,e);if(t.optional&&r==null)return;if(t.computed){const a=M(t.computed,e);return On(r,a)}return Un(r,t.property??"")}case"Unary":{const r=M(t.argument,e);return t.operator==="!"?!r:-U(r)}case"Binary":return Pn(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 zn(t.callee,t.arguments,e,t.loc);case"MethodCall":return In(t,e);case"BuiltinCall":return En(t.name,t.arguments,e);case"Template":return Mn(t.quasis,t.expressions,e);case"Spread":return M(t.argument,e);case"If":return $n(t,e);case"Match":return Nn(t,e);case"For":return An(t,e);case"Block":return Re(t,e);case"Lambda":{const r=t.params,a=t.body,i=e.stateAliases.map(s=>new Map(s)),n=new Map(e.loopVars);return(...s)=>{const l=new Map(e.loopVars),c=e.stateAliases.slice();e.loopVars.clear();for(const[p,m]of n)e.loopVars.set(p,m);e.stateAliases.length=0;for(const p of i)e.stateAliases.push(p);const u=[];for(let p=0;p<r.length;p+=1){const m=r[p];let g=s[p];g===void 0&&m.defaultValue&&(g=M(m.defaultValue,e)),u.push({name:m.name,had:e.loopVars.has(m.name),prev:e.loopVars.get(m.name)}),e.loopVars.set(m.name,g)}try{if(a.kind==="JsBlock"){const m=a.body;return e.jsBlockExecutor?e.jsBlockExecutor(m,Vr(r,s)):{__kind:"JsBlock",body:m}}const p=M(a,e);if(e.jsBlockExecutor&&p&&typeof p=="object"&&p.__kind==="JsBlock"){const m=p.body;return e.jsBlockExecutor(m,Vr(r,s))}return p}finally{for(const p of u)p.had?e.loopVars.set(p.name,p.prev):e.loopVars.delete(p.name);e.loopVars.clear();for(const[p,m]of l)e.loopVars.set(p,m);e.stateAliases.length=0;for(const p of c)e.stateAliases.push(p)}}}case"JsBlock":return{__kind:"JsBlock",body:t.body};case"Bind":return{__kind:"Bind",prop:t.prop,target:M(t.target,e),targetExpr:t.target};case"NamedArg":return M(t.value,e);default:return null}}function $n(t,e){return M(t.test,e)?Re(t.consequent,e):t.alternate?t.alternate.kind==="Block"?Re(t.alternate,e):M(t.alternate,e):null}function Nn(t,e){const r=M(t.discriminant,e);for(const a of t.arms)if(a.pattern==="_"||M(a.pattern,e)===r)return M(a.body,e);return null}function An(t,e){const r=M(t.iterable,e);if(!Array.isArray(r))return[];const a=[],i=e.loopVars.has(t.item),n=e.loopVars.get(t.item),s=t.index,l=s?e.loopVars.has(s):!1,c=s?e.loopVars.get(s):void 0,u=t.destructure??[],p=u.map(m=>({name:m,had:e.loopVars.has(m),value:e.loopVars.get(m)}));try{for(let m=0;m<r.length;m+=1){const g=r[m];e.loopVars.set(t.item,g),s&&e.loopVars.set(s,m);for(const f of u){const h=g&&typeof g=="object"?g[f]:void 0;e.loopVars.set(f,h)}a.push(Re(t.body,e))}}finally{i?e.loopVars.set(t.item,n):e.loopVars.delete(t.item),s&&(l?e.loopVars.set(s,c):e.loopVars.delete(s));for(const m of p)m.had?e.loopVars.set(m.name,m.value):e.loopVars.delete(m.name)}return a}function Re(t,e){let r=null;const a=[];for(const i of t.body)switch(i.kind){case"ExpressionStatement":r=M(i.expression,e);continue;case"Assignment":{const n=M(i.expression,e);if(i.isState&&i.identifier){const s=ke(e,i.identifier);e.state.set(s,n)}else e.loopVars.has(i.identifier)||a.push(i.identifier),e.loopVars.set(i.identifier,n);r=n;continue}case"Return":return r=i.argument?M(i.argument,e):void 0,r;case"EffectDeclaration":{const n=e.componentEffectStack[e.componentEffectStack.length-1];n?n.push(i):It(i,e);continue}case"ComponentDeclaration":case"ActionDeclaration":It(i,e);continue;case"Emit":case"Cleanup":case"Await":continue}for(const i of a)e.loopVars.delete(i);return r}function Mn(t,e,r){let a=t[0]??"";for(let i=0;i<e.length;i+=1)a+=tt(M(e[i],r)),a+=t[i+1]??"";return a}function Pn(t,e,r,a){if(t==="&&"){const s=M(e,a);return s&&M(r,a)}if(t==="||"){const s=M(e,a);return s||M(r,a)}if(t==="??"){const s=M(e,a);return s??M(r,a)}const i=M(e,a),n=M(r,a);switch(t){case"+":return typeof i=="string"||typeof n=="string"?tt(i)+tt(n):U(i)+U(n);case"-":return U(i)-U(n);case"*":return U(i)*U(n);case"/":{const s=U(n);return s===0?0:U(i)/s}case"%":{const s=U(n);return s===0?0:U(i)%s}case"==":return i===n;case"!=":return i!==n;case">":return U(i)>U(n);case"<":return U(i)<U(n);case">=":return U(i)>=U(n);case"<=":return U(i)<=U(n);default:return null}}function In(t,e){const r=M(t.object,e);if(r==null)return t.optional?void 0:null;const a=r[t.method];if(typeof a!="function")return null;const i=[],n={};let s=!1;for(const c of t.arguments){if(c.kind==="NamedArg"){n[c.name]=M(c.value,e),s=!0;continue}if(c.kind==="Spread"){const u=M(c.argument,e);if(Array.isArray(u))for(const p of u)i.push(p);continue}i.push(M(c,e))}const l=s?[...i,n]:i;try{return a.apply(r,l)}catch(c){return console.error(`[aktion] method "${t.method}" threw`,c),null}}function zn(t,e,r,a){if(t==="_router_")return Tn(e,r,a);const i=r.componentDecls.get(t);if(i)return Ln(i,e,r,a);const n=r.actionDecls.get(t);if(n){if(e.length===0)return Yr(n,r);const f=e.map(h=>h.kind==="NamedArg"?M(h.value,r):M(h,r));return Jr(n,f,r)}if(t==="http"){const f=e[0],h=f?f.kind==="NamedArg"?M(f.value,r):M(f,r):{};return Rr(h,r)}const s=r.loopVars.get(t);if(typeof s=="function"){const f=e.map(h=>M(h,r));return s(...f)}const l=r.bindings.get(t);if(l){const f=l();if(typeof f=="function"){const h=e.map(b=>b.kind==="NamedArg"?M(b.value,r):M(b,r));return f(...h)}}if(t==="Theme"){const f=e[0];return{kind:"Theme",tokens:Vn(f?M(f,r):null)}}if(t==="Http"){const f=e[0],h=f?M(f,r):null;if(h&&typeof h=="object"&&!Array.isArray(h)&&r.http){const b=h;r.http.setDefaults({baseUrl:typeof b.baseUrl=="string"?b.baseUrl:void 0,headers:b.headers&&typeof b.headers=="object"&&!Array.isArray(b.headers)?Object.fromEntries(Object.entries(b.headers).map(([v,y])=>[v,String(y??"")])):void 0,timeoutMs:typeof b.timeout=="number"?b.timeout:void 0,retry:b.retry&&typeof b.retry=="object"&&!Array.isArray(b.retry)?{count:Number(b.retry.count??0)||0,backoff:b.retry.backoff==="linear"?"linear":"exponential"}:void 0,credentials:b.credentials==="omit"||b.credentials==="same-origin"||b.credentials==="include"?b.credentials:void 0})}return{__kind:"Http",config:h}}if(t==="i18n"){const f=e[0],h=f?M(f,r):null;if(h&&typeof h=="object"&&!Array.isArray(h)&&r.i18n){const b=h;r.i18n.configure({locale:typeof b.locale=="string"?b.locale:"en",messages:b.messages&&typeof b.messages=="object"&&!Array.isArray(b.messages)?b.messages:{},fallback:typeof b.fallback=="string"?b.fallback:"en",fallbackMessages:b.fallbackMessages&&typeof b.fallbackMessages=="object"&&!Array.isArray(b.fallbackMessages)?b.fallbackMessages:void 0})}return{__kind:"I18n",config:h}}if(r.library&&!Ie(r.library,t))return Ie(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:a}:null;let c;const u=[];for(const f of e){if(f.kind==="NamedArg"&&f.name==="key"){c=M(f.value,r);continue}u.push(f)}const{args:p,argMeta:m}=Rn(r,t,u);return{__kind:"Component",name:t,args:p,argMeta:m,explicitKey:c,source:a}}function Rn(t,e,r){const a=t.library?Ie(t.library,e):void 0;if(!a){const m=r.map(f=>f.kind==="NamedArg"?M(f.value,t):f.kind==="Bind"?M(f.target,t):M(f,t)),g=r.map(f=>f.kind==="StateRef"?{stateRef:f.name}:f.kind==="Bind"&&f.target.kind==="StateRef"?{stateRef:f.target.name}:f.kind==="NamedArg"&&f.value.kind==="StateRef"?{stateRef:f.value.name}:{});return{args:m,argMeta:g}}const i=new Map;a.props.forEach((m,g)=>{if(i.set(m.name,g),m.aliases)for(const f of m.aliases)i.has(f)||i.set(f,g)});const n=Tt(a),s=a.props.map(()=>({value:void 0,meta:{},filled:!1})),l=[];for(const m of r){if(m.kind==="NamedArg"){const g=i.get(m.name);if(g===void 0)continue;const f=M(m.value,t);s[g].value=f,s[g].filled=!0,m.value.kind==="StateRef"&&(s[g].meta={stateRef:m.value.name});continue}if(m.kind==="Bind"){const g=i.get(m.prop);if(g===void 0)continue;const f=M(m.target,t);s[g].value=f,s[g].filled=!0,m.target.kind==="StateRef"&&(s[g].meta={stateRef:m.target.name});continue}l.push({expr:m,value:M(m,t)})}if(l.length>0&&n>=0&&!s[n].filled){const{expr:m,value:g}=l.shift();s[n].value=g,s[n].filled=!0,m.kind==="StateRef"&&(s[n].meta={stateRef:m.name})}let c=0;for(const{expr:m,value:g}of l){for(;c<a.props.length&&s[c].filled;)c+=1;if(c>=a.props.length)break;s[c].value=g,s[c].filled=!0,m.kind==="StateRef"&&(s[c].meta={stateRef:m.name}),c+=1}const u=s.map(m=>m.value),p=s.map(m=>m.meta);for(;u.length>0&&u[u.length-1]===void 0;)u.pop(),p.pop();return{args:u,argMeta:p}}function Ln(t,e,r,a){const i=[],n={};let s;for(const m of e)m.kind==="NamedArg"?m.name==="key"?s=m.value:n[m.name]=m.value:i.push(m);const l=i.map(m=>m.kind==="Spread"?M(m.argument,r):M(m,r)),c=[];for(let m=0;m<i.length;m+=1){const g=i[m],f=l[m];if(g.kind==="Spread"&&Array.isArray(f))for(const h of f)c.push(h);else c.push(f)}const u={};for(const[m,g]of Object.entries(n))u[m]=M(g,r);const p=s?M(s,r):void 0;return{__kind:"UserComponent",decl:t,positional:c,named:u,explicitKey:p,source:a}}function Kr(t,e,r){const{decl:a,positional:i,named:n}=t,s=[];for(let u=0;u<a.params.length;u+=1){const p=a.params[u];let m;n[p.name]!==void 0?m=n[p.name]:i[u]!==void 0?m=i[u]:p.defaultValue?m=M(p.defaultValue,e):m=void 0,s.push({name:p.name,had:e.loopVars.has(p.name),prev:e.loopVars.get(p.name)}),e.loopVars.set(p.name,m)}if(i.length>a.params.length){const u=i.slice(a.params.length),p=u.length===1?u[0]:u;s.push({name:"children",had:e.loopVars.has("children"),prev:e.loopVars.get("children")}),e.loopVars.set("children",p)}if(a.slots.length>0){const u={};for(const p of a.slots)n[p]!==void 0&&(u[p]=n[p]);s.push({name:"slots",had:e.loopVars.has("slots"),prev:e.loopVars.get("slots")}),e.loopVars.set("slots",u)}const l=new Map;for(const u of a.body.body)if(u.kind==="Assignment"&&u.isState){const p=`${r}:${u.identifier}`;l.set(u.identifier,p),e.state.declare(p,et(u.expression))}e.stateAliases.push(l);const c=[];e.componentEffectStack.push(c);try{return{value:Re(a.body,e),effects:c}}finally{e.componentEffectStack.pop(),e.stateAliases.pop();for(const u of s)u.had?e.loopVars.set(u.name,u.prev):e.loopVars.delete(u.name)}}function Yr(t,e){const r=e.stateAliases.map(a=>new Map(a));return async(...a)=>{const i=e.stateAliases.slice();e.stateAliases.length=0;for(const n of r)e.stateAliases.push(n);try{return await Jr(t,a,e)}finally{e.stateAliases.length=0;for(const n of i)e.stateAliases.push(n)}}}function Jr(t,e,r){if(!r.actionRunner){const a=[];for(let i=0;i<t.params.length;i+=1){const n=t.params[i];a.push({name:n.name,had:r.loopVars.has(n.name),prev:r.loopVars.get(n.name)}),r.loopVars.set(n.name,e[i])}try{return Re(t.body,r)}finally{for(const i of a)i.had?r.loopVars.set(i.name,i.prev):r.loopVars.delete(i.name)}}return r.actionRunner.run(t,e,r)}function En(t,e,r){if(t==="__rui_assign__")return _n(e,r);if(t==="__rui_postfix__")return jn(e,r);if(t==="Each"){const n=e[0],s=e[1],l=e[2];if(!n||!s||!l)return[];const c=M(n,r),u=Array.isArray(c)?c:[],p=s.kind==="Literal"?String(s.value??""):"",m=Bn(p),g=[],f=m.bindings.map(h=>({name:h,had:r.loopVars.has(h),prev:r.loopVars.get(h)}));try{for(const h of u){m.scalarName&&r.loopVars.set(m.scalarName,h);for(const b of m.fields)h&&typeof h=="object"?r.loopVars.set(b,h[b]):r.loopVars.set(b,void 0);g.push(M(l,r))}}finally{for(const h of f)h.had?r.loopVars.set(h.name,h.prev):r.loopVars.delete(h.name)}return g}if(t==="If"){const n=e[0],s=e[1],l=e[2];return n?M(n,r)?s?M(s,r):null:l?M(l,r):null:null}if(t==="Switch"){const n=e[0],s=e[1],l=e[2];if(!n||!s)return null;const c=M(n,r),u=tt(c);if(s.kind==="Object"){for(const p of s.properties)if(!p.spread&&p.key===u)return M(p.value,r)}return l?M(l,r):null}if(t==="T"||t==="t"){const n=e[0],s=e[1],l=n?String(M(n,r)??""):"";if(!r.i18n)return l;let c;if(s){const u=M(s,r);u&&typeof u=="object"&&!Array.isArray(u)&&(c=u)}return r.i18n.t(l,c)}if(t==="Locale")return r.i18n?.getLocale()??"";const a=At[t];if(!a)return null;const i=e.map(n=>M(n,r));return a(i)}function Xr(t,e,r){switch(t){case"=":return r;case"+=":return typeof e=="string"||typeof r=="string"?`${e??""}${r??""}`:U(e)+U(r);case"-=":return U(e)-U(r);case"*=":return U(e)*U(r);case"/=":{const a=U(r);return a===0?0:U(e)/a}case"??=":return e??r;default:return r}}function _n(t,e){const[r,a,i]=t;if(!r||!a)return null;const n=i&&i.kind==="Literal"?String(i.value??"="):"=",s=M(a,e);if(r.kind==="StateRef"){const l=ke(e,r.name),c=e.state.get(l),u=Xr(n,c,s);return e.state.set(l,u),u}if(r.kind==="Identifier"){const l=e.loopVars.get(r.name),c=Xr(n,l,s);return e.loopVars.set(r.name,c),c}return s}function jn(t,e){const[r,a]=t;if(!r)return null;const n=(a&&a.kind==="Literal"?String(a.value??"++"):"++")==="--"?-1:1;if(r.kind==="StateRef"){const s=ke(e,r.name),l=U(e.state.get(s))+n;return e.state.set(s,l),l}if(r.kind==="Identifier"){const s=U(e.loopVars.get(r.name))+n;return e.loopVars.set(r.name,s),s}return null}function Bn(t){const e=t.trim();if(!e)return{scalarName:"",fields:[],bindings:[]};if(e.startsWith("{")&&e.endsWith("}")){const a=e.slice(1,-1).split(",").map(i=>i.trim()).filter(Boolean);return{scalarName:"",fields:a,bindings:a}}const r=e.indexOf("{");if(r>0){const i=e.slice(0,r).trim().replace(/,\s*$/,"").trim(),n=e.indexOf("}",r),s=n>r?e.slice(r+1,n).split(",").map(l=>l.trim()).filter(Boolean):[];return{scalarName:i,fields:s,bindings:i?[i,...s]:s}}return{scalarName:e,fields:[],bindings:[e]}}function Dn(t){if(t.router)return t.router.getPath();if(t.state.has("route")){t.trackedState.add("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 Fn(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),i={};if(typeof globalThis<"u"&&globalThis.location){const n=globalThis.location?.search??"";if(n){const s=new URLSearchParams(n.startsWith("?")?n.slice(1):n);for(const[l,c]of s)i[l]=c}}return{path:e,params:r,pattern:a,query:i,navigate(n){typeof n!="string"||!n||t.navigate(n)},toString(){return e}}}function On(t,e){if(t!=null){if(Array.isArray(t)){const r=Zr(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=Zr(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function Zr(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 Un(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 U(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 qn=new Set(["colors","radius","font","motion","elevation"]),Hn=new Set(["name","direction"]);function Vn(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const r=t;for(const[a,i]of Object.entries(r))if(i!=null&&!Hn.has(a)&&qn.has(a)&&i&&typeof i=="object"&&!Array.isArray(i)){const n=a==="colors"?"color":a;for(const[s,l]of Object.entries(i)){if(l==null)continue;const c=n+Wn(s);e[c]=Gn(l)}}return e}function Wn(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function Gn(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function tt(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)}}class Qr{constructor(){j(this,"locale","en");j(this,"fallback","en");j(this,"messages",{});j(this,"fallbackMessages",{})}configure(e){this.locale=e.locale||"en",this.fallback=e.fallback??"en",this.messages=ea(e.messages),this.fallbackMessages=ea(e.fallbackMessages??{})}getLocale(){return this.locale}getFallback(){return this.fallback}t(e,r){const a=ta(this.messages,e)??ta(this.fallbackMessages,e)??e;return typeof a!="string"?e:Kn(a,r)}}function ea(t){return!t||typeof t!="object"||Array.isArray(t)?{}:t}function ta(t,e){if(!e)return;if(e.indexOf(".")===-1)return t[e];let r=t;for(const a of e.split(".")){if(!r||typeof r!="object")return;r=r[a]}return r}function Kn(t,e){return e?t.replace(/\$\{([^}]+)\}/g,(r,a)=>{const i=e[a.trim()];return i==null?"":String(i)}):t}const zt="::";class ra{constructor(e){j(this,"mounted",new Map);j(this,"errors",[]);this.options=e}getErrors(){return this.errors}syncEffects(e,r){this.errors=[];const a=new Set(e.map(i=>i.name));for(const i of[...this.mounted.keys()])i.includes(zt)||a.has(i)||this.unmount(i);for(const i of e)this.mounted.has(i.name)||this.mount(i.name,i,r)}syncInstanceEffects(e,r,a){const i=`${e}${zt}`,n=new Set(r.map(s=>`${i}${s.name}`));for(const s of[...this.mounted.keys()])s.startsWith(i)&&(n.has(s)||this.unmount(s));for(const s of r){const l=`${i}${s.name}`;this.mounted.has(l)||this.mount(l,s,a)}}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){const i={decl:r,cleanups:[],intervals:[],unsubscribers:[],ctxRef:a};this.mounted.set(e,i);const s=Yn(()=>{for(const p of i.cleanups.splice(0))try{p()}catch(m){ia(e,m)}try{aa(r,a(),i,this.options)}catch(p){console.error(`[aktion] effect "${e}" failed`,p)}finally{this.options.notify()}},r.rateLimit,i);let l=!1,c=!1,u=!1;for(const p of r.triggers)switch(p.kind){case"lifecycle":p.name==="mount"&&(l=!0),p.name==="unmount"&&(c=!0);break;case"every":{u=!0;const m=setInterval(s,p.intervalMs);i.intervals.push(m);break}case"state":{const m=p.name,g=this.options.state.subscribe(f=>{f.has(m)&&s()});i.unsubscribers.push(g);break}}(r.triggers.length===0||l||!u&&!c&&r.triggers.every(p=>p.kind==="state"))&&s()}unmount(e){const r=this.mounted.get(e);if(!r)return;this.mounted.delete(e);for(const i of r.intervals)clearInterval(i);for(const i of r.unsubscribers)try{i()}catch{}for(const i of r.cleanups)try{i()}catch(n){ia(e,n)}if(r.decl.triggers.some(i=>i.kind==="lifecycle"&&i.name==="unmount"))try{aa(r.decl,r.ctxRef(),r,this.options)}catch(i){console.error(`[aktion] effect "${e}" unmount body threw`,i)}}}function Yn(t,e,r){if(!e||e.ms<=0)return t;if(e.kind==="debounce"){let n=null;const s=()=>{n&&(clearTimeout(n),n=null)};return r.cleanups.push(s),()=>{n&&clearTimeout(n),n=setTimeout(()=>{n=null,t()},e.ms)}}let a=0,i=null;return r.cleanups.push(()=>{i&&(clearTimeout(i),i=null)}),()=>{const n=Date.now(),s=n-a;s>=e.ms?(a=n,t()):i||(i=setTimeout(()=>{i=null,a=Date.now(),t()},e.ms-s))}}function aa(t,e,r,a){for(const i of t.body.body)Jn(i,e,r,a)}function Jn(t,e,r,a){switch(t.kind){case"ExpressionStatement":{const i=t.expression;if(i.kind==="Call"&&i.callee==="cleanup"){const n=i.arguments[0]?M(i.arguments[0],e):null;typeof n=="function"&&r.cleanups.push(n);return}return i.kind==="JsBlock"?Rt(i.body,r.decl.name,e,a,r):M(i,e)}case"Assignment":{const i=M(t.expression,e);if(t.identifier&&t.identifier!==""){const n=ke(e,t.identifier);e.state.set(n,i)}return i}case"Cleanup":{const i=t.callback?M(t.callback,e):null;typeof i=="function"&&r.cleanups.push(i);return}case"Emit":{const i=M(t.detail,e);a.onEmit?.(t.eventName,i);return}default:return}}function ia(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function na(t){return(e,r={})=>Rt(e,"<inline>",void 0,t,void 0,r)}function Rt(t,e,r,a,i,n={}){const s={state:{get:l=>a.state.get(l),set:(l,c)=>a.state.set(l,c)},cleanup:l=>{typeof l=="function"&&i&&i.cleanups.push(l)},host:a.host,tools:a.tools??{},args:n};try{const c=new Function("ctx",`return (async () => { ${t}
19
- })()`)(s);return c&&typeof c.then=="function"&&c.catch(u=>{console.error(`[aktion] js{} body in "${e}" rejected`,u)}),c}catch(l){console.error(`[aktion] js{} body in "${e}" threw`,l);return}}class oa{constructor(e){this.options=e}async run(e,r,a){const i=[],n={};for(let l=0;l<e.params.length;l+=1){const c=e.params[l],u=r[l];i.push({name:c.name,had:a.loopVars.has(c.name),prev:a.loopVars.get(c.name)}),a.loopVars.set(c.name,u),n[c.name]=u}const s=e.optimistic?Xn(this.options.state):null;try{let l;for(const c of e.body.body)l=await this.runStatement(c,a,e,n);return this.options.notify(),l}catch(l){throw s&&(Zn(this.options.state,s),this.options.notify()),console.error(`[aktion] action "${e.name}" failed`,l),l}finally{for(const l of i)l.had?a.loopVars.set(l.name,l.prev):a.loopVars.delete(l.name)}}async runStatement(e,r,a,i){switch(e.kind){case"ExpressionStatement":{const n=e.expression;if(n.kind==="JsBlock"){const l=Rt(n.body,a.name,r,this.options,void 0,i);return await qe(l)}const s=M(n,r);return await qe(s)}case"Await":{const n=M(e.argument,r);return await qe(n)}case"Assignment":{const n=await qe(M(e.expression,r));if(e.identifier){const s=ke(r,e.identifier);this.options.state.set(s,n)}return n}case"Return":return e.argument?await qe(M(e.argument,r)):void 0;case"Emit":{const n=M(e.detail,r);this.options.onEmit?.(e.eventName,n);return}default:return}}}async function qe(t){return t&&typeof t.then=="function"?await t:t}function Xn(t){const e=new Map;for(const[r,a]of t.entries())e.set(r,a);return e}function Zn(t,e){for(const[r,a]of e)t.set(r,a)}const Qn="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",sa="6.7.2",la="data-rui-font-awesome",eo=new Set(["solid","regular","brands"]),ca="solid";function to(t){typeof document<"u"&&ua(document.head,document),ua(t,t.ownerDocument??document)}function ua(t,e){if(ro()||t.querySelector(`link[${la}="${sa}"]`))return;const a=e.createElement("link");a.rel="stylesheet",a.href=Qn,a.setAttribute(la,sa);try{t.appendChild(a)}catch{}}function ro(){return typeof globalThis.happyDOM<"u"}function Lt(t){if(typeof t!="string")return[];const e=io(t).trim();if(!e)return[];if(!oo(e))return[];const[r,a]=no(e);return a?[`fa-${r}`,`fa-${a}`]:[]}const ao=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function io(t){return t.replace(ao,"")}function no(t){const e=t.indexOf(":");if(e===-1)return[ca,t];const r=t.slice(0,e).trim().toLowerCase(),a=t.slice(e+1).trim();return eo.has(r)?[r,a]:[ca,a||t]}function oo(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const so=["xs","sm","md","lg","xl"];function o(t,e,r){const a=document.createElement(t);if(e)for(const[i,n]of Object.entries(e))n==null||n===!1||(i==="class"?a.setAttribute("class",String(n)):i==="html"?a.innerHTML=String(n):n===!0?a.setAttribute(i,""):a.setAttribute(i,String(n)));if(r)for(const i of r)i!=null&&a.append(typeof i=="string"?document.createTextNode(i):i);return a}function k(t){return Array.isArray(t)?t:t==null?[]:[t]}function d(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function C(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function P(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 Le=["base","sm","md","lg","xl"];function le(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[i,n]of e)Le.includes(i)&&(r[i]=n,a=!0);return a?{kind:"responsive",values:r}:{kind:"single",value:t}}const lo=/["'\\\n\r<>;{}]/g;function co(t){return t?t.replace(lo,"").trim():""}const uo=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function ee(t,e){const r=(d(t)??"").trim();return!r||r.length>64||!uo.test(r)?e:r}const po=new Set(["http","https","mailto","tel"]);function rt(t,e="#"){const r=d(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 i=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(a);if(!i)return a;const n=i[1].toLowerCase();return po.has(n)?a:e}const mo=new Set(["http","https","data","blob"]);function re(t){const e=d(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 i=a[1].toLowerCase();return!mo.has(i)||i==="data"&&!/^data:image\//i.test(r)?"":r}function L(t,e={}){const r=d(t);if(!r)return null;const a=Lt(r),i=["rui-icon",e.className].filter(Boolean).join(" ");return a.length===0?o("span",{class:i,"data-icon-size":e.size??null},[r]):o("i",{class:`${i} ${a.join(" ")}`,"data-icon-size":e.size??null,"aria-hidden":"true"})}const He=12,go={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},fo={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function ho(t){return go[t]??"stretch"}function bo(t){return fo[t]??"flex-start"}function da(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function Se(t,e,r){for(const a of Le){const i=e.values[a];i&&t.push(`${r}-${a}:var(--rui-spacing-${i}, ${i})`)}}function vo(t,e,r,a){for(const i of Le){const n=e.values[i];n&&t.push(`${r}-${i}:${a(String(n))}`)}}function pa(t,e,r,a){const i=le(t);if(i.kind==="single"){const n=i.value?String(i.value):a.defaultToken;r[a.attrName]=n;return}r[a.attrName]="responsive",r[a.responsiveFlag]="true",vo(e,i,a.cssVarPrefix,a.mapper)}function yo(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function xo(t){const e=le(t.direction);return e.kind==="single"?e.value?String(e.value):"column":e.values.base?String(e.values.base):"column"}const wo={name:"StackItem",description:"Wraps a single child in a flex item with explicit grow/shrink/basis, alignment, and order. Use inside `Stack` when the default row flex growth would stretch toolbars, chips, or asymmetric layouts.",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"},i=[];e.grow!==void 0&&e.grow!==null&&(a["data-grow"]=String(P(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(a["data-shrink"]=String(P(e.shrink,1)));const n=d(e.basis);n==="auto"||n==="0"?a["data-basis"]=n:n&&i.push(`flex-basis:${ee(n,n)}`);const s=d(e.alignSelf);if(s&&(a["data-align-self"]=s),e.order!==void 0&&e.order!==null){const p=P(e.order,0);a["data-order"]=String(p),i.push(`order:${p}`)}const l=d(e.minWidth);l&&i.push(`min-width:${ee(l,l)}`);const c=d(e.maxWidth);c&&i.push(`max-width:${ee(c,c)}`),i.length>0&&(a.style=i.join(";"));const u=o("div",a);return u.append(r.renderNode(e.child)),u}},ko={name:"Stack",description:'Flex container that arranges children in a row or column. `direction`, `gap`, `align`, `justify`, and `padding` accept either a single value OR a responsive map like `{sm: "column", md: "row"}`. Row stacks grow children uniformly by default (`uniform=true`); set `uniform=false` or wrap children in `StackItem` for toolbars and asymmetric rows. Use `reverse` for chat-style column-reverse timelines.',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."},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between children. May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment. May be a responsive map."},{name:"justify",type:"string | object",optional:!0,enum:["start","center","end","between","around","evenly"],description:"Main-axis alignment. May be a responsive map."},{name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Multi-line wrap alignment"},{name:"wrap",type:"boolean",optional:!0,description:"Allow wrapping"},{name:"reverse",type:"boolean",optional:!0,description:"Reverse main-axis order (column-reverse / row-reverse)"},{name:"uniform",type:"boolean",optional:!0,description:"Row children share space equally (default true for row stacks)"},{name:"inline",type:"boolean",optional:!0,description:"Use inline-flex instead of flex"},{name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token. May be a responsive map."}],render:(t,e,r)=>{const a=le(e.direction),i=le(e.gap),n=le(e.padding),s=C(e.reverse),c=xo(e)==="row",u=e.uniform===void 0?c:C(e.uniform,c),p={class:"rui-stack","data-wrap":C(e.wrap)?"true":null,"data-reverse":s?"true":null,"data-uniform":u?"true":"false","data-inline":C(e.inline)?"true":null},m=[];if(a.kind==="single"){const h=a.value?String(a.value):"column";p["data-direction"]=da(h,s)}else{p["data-direction"]="responsive",p["data-responsive-dir"]="true";for(const h of Le){const b=a.values[h];b&&m.push(`--rui-stack-dir-${h}:${da(String(b),s)}`)}}i.kind==="single"?p["data-gap"]=i.value?String(i.value):"m":(p["data-gap"]="responsive",p["data-responsive-gap"]="true",Se(m,i,"--rui-stack-gap")),pa(e.align,m,p,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:"stretch",mapper:ho}),pa(e.justify,m,p,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:bo});const g=d(e.alignContent);if(g&&(p["data-align-content"]=g),n.kind==="single"){const h=n.value?String(n.value):null;h&&(p["data-padding"]=h)}else p["data-padding"]="responsive",p["data-responsive-padding"]="true",Se(m,n,"--rui-stack-padding");m.length>0&&(p.style=m.join(";"));const f=o("div",p);for(const h of k(e.children))f.append(r.renderNode(h));return f}},So={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=o("div",{class:"rui-card","data-variant":d(e.variant,"default")});for(const i of k(e.children))a.append(r.renderNode(i));return a}},Co={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=o("header",{class:"rui-card-header"});r.append(o("h3",{class:"rui-card-title"},[d(e.title)]));const a=d(e.subtitle);return a&&r.append(o("p",{class:"rui-card-subtitle"},[a])),r}},To={name:"CardFooter",description:"Card footer for actions.",props:[{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=o("footer",{class:"rui-card-footer"});for(const i of k(e.children))a.append(r.renderNode(i));return a}},$o={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=d(e.orientation,"horizontal"),a=C(e.decorative,!0),i=d(e.label);return i&&r==="horizontal"?o("div",{class:"rui-separator rui-separator-with-label","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r},[o("span",{class:"rui-separator-line"}),o("span",{class:"rui-separator-label"},[i]),o("span",{class:"rui-separator-line"})]):o("div",{class:"rui-separator","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r})}},ma=(t,e,r=!1)=>{const a=o("li",{class:"rui-steps-item","data-active":r?"true":"false"});return a.append(o("div",{class:"rui-steps-title"},[t])),e&&a.append(o("div",{class:"rui-steps-details"},[e])),a},No={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=o("ol",{class:"rui-steps"});for(const i of k(e.items)){if(i&&typeof i=="object"&&i.__kind==="Component"){a.append(r.renderNode(i));continue}if(i&&typeof i=="object"){const n=i;a.append(ma(d(n.title),d(n.details),C(n.active)));continue}a.append(ma(d(i),""))}return a}},Ao={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=o("div",{class:"rui-tab-content",role:"tabpanel","data-value":d(e.value),"data-active":"false"});for(const i of k(e.children))a.append(r.renderNode(i));return a}},Mo={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).',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`)"}],render:(t,e,r)=>{const a=k(e.items),i=d(e.orientation,"horizontal"),n=o("div",{class:"rui-tabs","data-orientation":i}),s=o("div",{class:"rui-tab-list",role:"tablist","aria-orientation":i}),l=o("div",{class:"rui-tab-panels"});let c=d(e.defaultValue);if(!c&&a.length>0){const g=a[0];c=d(g?.args?.[0],"tab-0")}const u=r.useInstanceState("activeTab",c);d(e.defaultValue)&&d(e.defaultValue)!==c&&u.set(d(e.defaultValue)),new Set(a.map((g,f)=>d(g.args?.[0],`tab-${f}`))).has(u.get())||u.set(c);const m=(g,f)=>{u.set(g);const h=f.closest(".rui-tabs");h&&(h.querySelectorAll(".rui-tab-trigger").forEach(b=>{const v=b.getAttribute("data-value")===g;b.setAttribute("aria-selected",v?"true":"false"),b.tabIndex=v?0:-1}),h.querySelectorAll(".rui-tab-content").forEach(b=>{b.setAttribute("data-active",b.getAttribute("data-value")===g?"true":"false")}))};return a.forEach((g,f)=>{const h=g,b=d(h.args?.[0],`tab-${f}`),v=d(h.args?.[1],`Tab ${f+1}`),y=d(h.args?.[3]),x=d(h.args?.[4]),w=b===u.get(),T=o("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":b,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),S=x?Po(x):null;S&&T.append(S),T.append(o("span",{class:"rui-tab-trigger-label"},[v])),y&&T.append(o("span",{class:"rui-tab-trigger-badge"},[y])),T.onclick=$=>{const A=$.currentTarget??$.target;m(b,A)},T.onkeydown=$=>{const A=$,z=i!=="vertical",R=z?A.key==="ArrowRight":A.key==="ArrowDown",_=z?A.key==="ArrowLeft":A.key==="ArrowUp";if(!R&&!_&&A.key!=="Home"&&A.key!=="End")return;A.preventDefault();const Q=A.currentTarget??A.target,B=Q.closest(".rui-tab-list");if(!B)return;const O=Array.from(B.querySelectorAll(".rui-tab-trigger"));if(O.length===0)return;const J=O.indexOf(Q);let X=J;A.key==="Home"?X=0:A.key==="End"?X=O.length-1:R?X=(J+1)%O.length:_&&(X=(J-1+O.length)%O.length);const de=O[X];if(!de)return;de.focus();const ge=de.getAttribute("data-value")??"";ge&&m(ge,de)},s.append(T);const N=r.renderNode(g);N.setAttribute("data-value",b),N.setAttribute("data-active",w?"true":"false"),l.append(N)}),n.append(s,l),n}};function Po(t){return L(t,{className:"rui-tab-trigger-icon"})}const Io={name:"AccordionItem",description:"Single accordion section.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"open",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=o("details",{class:"rui-accordion-item"});C(e.open)&&a.setAttribute("open","");const i=o("summary",{class:"rui-accordion-trigger"},[d(e.title)]);a.append(i);const n=o("div",{class:"rui-accordion-body"});for(const s of k(e.children))n.append(r.renderNode(s));return a.append(n),a}},zo={name:"Accordion",description:"Accordion container. Children must be AccordionItem components.",props:[{name:"items",type:"AccordionItem[]"}],render:(t,e,r)=>{const a=o("div",{class:"rui-accordion"});for(const i of k(e.items))a.append(r.renderNode(i));return a}},at=t=>Math.max(1,Math.min(He,Math.round(t)));function Et(t){if(t==null||t==="")return 12;const e=String(t).trim();if(e.includes("/")){const[r,a]=e.split("/"),i=Number(r),n=Number(a);if(Number.isFinite(i)&&Number.isFinite(n)&&n>0)return at(Math.round(He*i/n))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:at(P(t,12))}function Ro(t){const e=d(t.minChildWidth)||d(t.minItemWidth);return ee(e||"220px","220px")}const Lo={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=Et(e.span??12),i=le(e.spanAt),n=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(He-1,Math.round(P(e.offset,0)))),s={class:"rui-grid-item","data-span":String(a)},l=[`--rui-grid-item-span:${a}`];if(n>0&&(s["data-offset"]=String(n),l.push(`--rui-grid-item-offset:${n}`)),i.kind==="responsive"){s["data-responsive-span"]="true";for(const u of Le){const p=i.values[u];if(p!==void 0){const m=Et(p);l.push(`--rui-grid-item-span-${u}:${m}`)}}}else if(i.kind==="single"&&i.value!=null){const u=Et(i.value);l.push(`--rui-grid-item-span:${u}`),s["data-span"]=String(u)}s.style=l.join(";");const c=o("div",s);return c.append(r.renderNode(e.child)),c}},Eo={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=le(e.padding),i=le(e.margin),n={class:"rui-box","data-border":d(e.border,"none"),"data-background":d(e.background,"none")},s=[],l=d(e.maxWidth);if(l&&s.push(`max-width:${ee(l,l)}`),a.kind==="single"){const u=a.value?String(a.value):null;u&&(n["data-padding"]=u)}else n["data-padding"]="responsive",n["data-responsive-padding"]="true",Se(s,a,"--rui-box-padding");if(i.kind==="single"){const u=i.value?String(i.value):null;u&&(n["data-margin"]=u)}else n["data-margin"]="responsive",n["data-responsive-margin"]="true",Se(s,i,"--rui-box-margin");s.length>0&&(n.style=s.join(";"));const c=o("div",n);for(const u of k(e.children))c.append(r.renderNode(u));return c}},ga={name:"Grid",description:'Responsive CSS grid. Use for KPI strips, feature blocks, card grids, and asymmetric layouts with `GridItem` spans. Set `columns: 12` (or include `GridItem` children) for a 12-column track system with fractional spans like `"1/3"`. `columns` and `gap` accept responsive maps like `{sm: 1, md: 2, lg: 4}`.',props:[{name:"children",type:"Node[]"},{name:"columns",type:"number | object",optional:!0,description:"Target column count 1–12 (default auto-fit). `12` enables 12-column mode. May be a responsive map."},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Gap size (both axes). 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:"minItemWidth",type:"string",optional:!0,description:"CSS min width for auto-fit fallback (alias: minChildWidth)"},{name:"minChildWidth",type:"string",optional:!0,description:"CSS min child width; also applies when `columns` is set"},{name:"alignItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Align items inside grid cells"},{name:"justifyItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Justify items inside grid cells"},{name:"dense",type:"boolean",optional:!0,description:"Use dense auto-flow packing"}],render:(t,e,r)=>{const a=k(e.children),i=a.some(v=>yo(v,"GridItem")),n=le(e.columns),s=le(e.gap),l=le(e.rowGap),c=le(e.columnGap),u={class:"rui-grid"},p=[];let m=!1,g=!1;if(n.kind==="single"){const v=n.value===null?0:P(n.value,0),y=v>0?at(v):0;if(y===He?m=!0:y>0&&(g=!0),y>0){u["data-columns"]=String(y);const x=d(e.minChildWidth)||d(e.minItemWidth);x&&(u["data-min-child-width"]="true",p.push(`--rui-grid-min-child:${ee(x,"220px")}`))}else p.push(`--rui-grid-min-item:${Ro(e)}`)}else{u["data-responsive-cols"]="true";for(const v of Le){const y=n.values[v];if(y===void 0)continue;const x=at(P(y,0));x===He?m=!0:x>0&&(g=!0),p.push(`--rui-grid-cols-${v}:${x}`)}}i&&!g&&(m=!0),m&&(u["data-grid-mode"]="12"),s.kind==="single"?u["data-gap"]=s.value?String(s.value):"m":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",Se(p,s,"--rui-grid-gap")),l.kind==="single"&&l.value?u["data-row-gap"]=String(l.value):l.kind==="responsive"&&(u["data-row-gap"]="responsive",u["data-responsive-row-gap"]="true",Se(p,l,"--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",Se(p,c,"--rui-grid-column-gap"));const f=d(e.alignItems);f&&(u["data-align-items"]=f);const h=d(e.justifyItems);h&&(u["data-justify-items"]=h),C(e.dense)&&(u["data-dense"]="true"),p.length>0&&(u.style=p.join(";"));const b=o("div",u);for(const v of a)b.append(r.renderNode(v));return b}},_o={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=jo(d(e.ratio,"16:9")),i=o("div",{class:"rui-aspect-ratio",style:`aspect-ratio:${a};`});for(const n of k(e.children))i.append(r.renderNode(n));return i}};function jo(t){if(t.includes(":")){const[r,a]=t.split(":"),i=Number(r),n=Number(a);if(Number.isFinite(i)&&Number.isFinite(n)&&n!==0)return`${i} / ${n}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const Bo={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=o("div",{class:"rui-scroll-area","data-direction":d(e.direction,"vertical"),style:`max-height:${ee(e.maxHeight,"320px")};`});for(const i of k(e.children))a.append(r.renderNode(i));return a}},Do={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.",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:["sm","md","lg","xl","full"],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)"}],render:(t,e,r)=>{const a=d(e.size,"md"),i=e.closable===void 0?!0:C(e.closable),n=o("div",{class:"rui-modal-overlay","data-open":C(e.open)?"true":"false"}),s=o("div",{class:"rui-modal",role:"dialog","aria-modal":"true","data-size":a}),l=o("header",{class:"rui-modal-header"});l.append(o("h3",{class:"rui-modal-title"},[d(e.title)]));const c=t.argMeta?.[1]?.stateRef,u=()=>{c&&r.setState(c,!1)};if(i){const g=o("button",{type:"button",class:"rui-modal-close","aria-label":"Close dialog"},["×"]);g.onclick=f=>{f.stopPropagation(),u()},l.append(g)}s.append(l);const p=o("div",{class:"rui-modal-body"});for(const g of k(e.children))p.append(r.renderNode(g));s.append(p);const m=k(e.footer);if(m.length>0){const g=o("footer",{class:"rui-modal-footer"});for(const f of m)g.append(r.renderNode(f));s.append(g)}return n.append(s),C(e.closeOnBackdrop)&&c&&(n.onclick=g=>{g.target===n&&u()}),n}},Fo=["solid","regular","brands"],it=["xs","sm","md","lg","xl"],Oo=["default","neutral","primary","success","warning","danger","info"];function _t(t,e="md"){const r=d(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":it.includes(r)?r:e:e}const Uo={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"`).',props:[{name:"name",type:"string",description:"FA name without the fa- prefix"},{name:"variant",type:"string",optional:!0,enum:Fo},{name:"size",type:"string",optional:!0,enum:so}],render:(t,e)=>{const r=d(e.name),a=d(e.variant,""),i=d(e.size,"md"),n=a?`${a}:${r}`:r,s=L(n,{size:i});return s||o("span",{class:"rui-icon","data-icon-size":i},[r])}},qo=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function Ho(t){const e=d(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const fa=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:qo},{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;").'}],ha=(t,e)=>{const r=d(e.variant,"body"),a=d(e.tone,"default"),i=Ho(e.style);return o("span",{class:"rui-text","data-variant":r,"data-color":a,style:i||null},[d(e.value)])},Vo={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:fa,render:ha},Wo={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:fa,render:ha},Go={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=o("figure",{class:"rui-image","data-fit":d(e.fit,"cover"),style:e.ratio?`aspect-ratio:${Ko(d(e.ratio))};`:null}),a=re(e.src);if(a)r.append(o("img",{src:a,alt:d(e.alt),loading:"lazy"}));else{const n=o("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),s=d(e.fallback);if(s){const l=L(s,{className:"rui-image-fallback-icon"});l?n.append(l):n.append(o("span",{class:"rui-image-fallback-text"},[s]))}r.append(n)}const i=d(e.caption);return i&&r.append(o("figcaption",{class:"rui-image-caption"},[i])),r}};function Ko(t){if(!t)return"auto";if(t.includes(":")){const[r,a]=t.split(":"),i=Number(r),n=Number(a);if(Number.isFinite(i)&&Number.isFinite(n)&&n>0)return`${i} / ${n}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"auto"}const Yo={name:"Link",description:"Anchor link.",props:[{name:"label",type:"string"},{name:"href",type:"string"},{name:"external",type:"boolean",optional:!0}],render:(t,e)=>{const r=C(e.external),a=rt(e.href,"#");return o("a",{class:"rui-link",href:a,target:r?"_blank":null,rel:r?"noopener noreferrer":null},[d(e.label)])}},ba=["neutral","primary","success","warning","danger","info"],Jo={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:ba,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:it}],render:(t,e)=>{const r=d(e.tone,"neutral"),a=_t(e.size,"md"),i=o("span",{class:"rui-badge","data-variant":r,"data-size":a}),n=L(e.icon,{className:"rui-badge-icon"});n&&i.append(n);const s=d(e.label);return s&&i.append(o("span",{class:"rui-badge-label"},[s])),i}},Xo={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:ba,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:it}],render:(t,e)=>{const r=d(e.tone,"neutral"),a=_t(e.size,"md"),i=o("div",{class:"rui-badge-list"});for(const n of k(e.labels)){const s=d(n);if(!s)continue;const l=o("span",{class:"rui-badge","data-variant":r,"data-size":a});l.append(o("span",{class:"rui-badge-label"},[s])),i.append(l)}return i}},Zo={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=d(e.tone,"info"),a=C(e.compact),i=o("div",{class:"rui-callout","data-variant":r,"data-compact":a?"true":"false"}),n=d(e.icon)||ts(r),s=L(n,{className:"rui-callout-icon"});s&&i.append(s);const l=o("div",{class:"rui-callout-body"});l.append(o("div",{class:"rui-callout-title"},[d(e.title)]));const c=d(e.description);return c&&l.append(o("div",{class:"rui-callout-description"},[c])),i.append(l),i}},Qo={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=d(e.language),a=d(e.codeString),i=C(e.showLineNumbers),n=es(d(e.highlightLines)),s=e.copy===void 0?!0:C(e.copy),l=o("div",{class:"rui-code-block"});if(r||s){const u=o("div",{class:"rui-code-block-head"});if(r&&u.append(o("span",{class:"rui-code-block-language"},[r])),s){const p=o("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),m=L("copy",{className:"rui-code-block-copy-icon"});m&&p.append(m),p.append(o("span",{class:"rui-code-block-copy-label"},["Copy"])),p.onclick=g=>{const f=g.currentTarget??g.target,b=f.closest(".rui-code-block")?.querySelector("code")?.textContent??a,y=(typeof navigator<"u"?navigator:null)?.clipboard;y?.writeText&&y.writeText(b).catch(()=>{});const x=f.querySelector(".rui-code-block-copy-label");if(x){const w=x.textContent??"Copy";x.textContent="Copied",setTimeout(()=>{x.textContent=w},1500)}},u.append(p)}l.append(u)}const c=o("pre",{class:"rui-code-block-pre","data-line-numbers":i?"true":"false"});if(i||n.size>0){const u=a.split(/\r?\n/),p=o("code",{});u.forEach((m,g)=>{const f=g+1,h=o("span",{class:"rui-code-block-line","data-line":String(f),"data-highlight":n.has(f)?"true":null});i&&h.append(o("span",{class:"rui-code-block-gutter"},[String(f)])),h.append(o("span",{class:"rui-code-block-code"},[m])),p.append(h)}),c.append(p)}else c.append(o("code",{},[a]));return l.append(c),l}};function es(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 i=a.split("-").map(l=>Number(l.trim())),n=i[0]??NaN,s=i[1]??NaN;if(Number.isFinite(n)&&Number.isFinite(s)&&n<=s)for(let l=n;l<=s;l+=1)e.add(l)}else{const i=Number(a);Number.isFinite(i)&&e.add(i)}}return e}function ts(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 rs={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=d(e.variant),a=d(e.shape);if(a)return as(a,e);if(r&&r!=="paragraph")return is(r,e);const i=Number(e.lines),n=Math.max(1,Math.min(50,Number.isFinite(i)?Math.floor(i):3)),s=Number(e.height),l=Number.isFinite(s)&&s>0?Math.min(200,Math.floor(s)):12,c=o("div",{class:"rui-skeleton","data-variant":"paragraph"});for(let u=0;u<n;u+=1)c.append(o("div",{class:"rui-skeleton-line",style:`height:${l}px`}));return c}};function as(t,e){const r=ee(d(e.width),"100%"),a=d(e.height),i=a?ee(a,"16px"):t==="circle"?r:"16px";return o("div",{class:"rui-skeleton","data-variant":"shape","data-shape":t==="circle"?"circle":"rect",style:`width:${r};height:${i};`})}function is(t,e){const r=o("div",{class:"rui-skeleton","data-variant":t});switch(t){case"avatar":{const a=ee(d(e.width),"40px");return r.append(o("div",{class:"rui-skeleton-shape","data-shape":"circle",style:`width:${a};height:${a};`})),r}case"image":{const a=ee(d(e.width),"100%"),i=ee(d(e.height),"160px");return r.append(o("div",{class:"rui-skeleton-shape","data-shape":"rect",style:`width:${a};height:${i};`})),r}case"card":return r.append(o("div",{class:"rui-skeleton-shape","data-shape":"rect",style:"width:100%;height:120px;"})),r.append(o("div",{class:"rui-skeleton-line",style:"height:14px;width:70%;"})),r.append(o("div",{class:"rui-skeleton-line",style:"height:12px;width:90%;"})),r.append(o("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)))),i=o("div",{class:"rui-skeleton-row"});for(let n=0;n<a;n+=1)i.append(o("div",{class:"rui-skeleton-line",style:"height:12px;flex:1;"}));return r.append(i),r}default:return r}}const ns={name:"Markdown",description:"Render markdown-flavoured text. Supports **bold**, *italic*, `code`, headings (`#`/`##`/`###`), blockquotes (`>`), bullet (`-`/`*`) and numbered (`1.`) lists, fenced code blocks (```), images (`![alt](src)`), inline links, and auto-linked bare URLs. Multi-line paragraphs collapse into `<p>` blocks.",props:[{name:"content",type:"string"}],render:(t,e)=>{const r=d(e.content),a=us(r);return o("div",{class:"rui-markdown",html:a})}},os={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=o("div",{class:"rui-container","data-size":d(e.size,"lg"),"data-padding":d(e.padding,"m"),style:e.maxWidth?`max-width:${ee(e.maxWidth,"auto")};`:null});for(const i of k(e.children))a.append(r.renderNode(i));return a}},ss={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=d(e.size),a=e.flex===void 0?!r:C(e.flex);return o("span",{class:"rui-spacer","data-size":r||null,"data-flex":a?"true":"false","aria-hidden":"true"})}},ls={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:it,description:"Default `md`"},{name:"label",type:"string",optional:!0,description:"Caption rendered beside the spinner (also announced)"},{name:"tone",type:"string",optional:!0,enum:Oo,description:"Visual accent (default `primary`)"}],render:(t,e)=>{const r=_t(e.size,"md"),a=d(e.tone,"primary"),i=d(e.label),n=o("span",{class:"rui-spinner","data-size":r,"data-tone":a,role:"status","aria-live":"polite","aria-label":i||"Loading"});return n.append(o("span",{class:"rui-spinner-ring","aria-hidden":"true"})),i&&n.append(o("span",{class:"rui-spinner-label"},[i])),n}},cs={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=o("figure",{class:"rui-quote","data-tone":d(e.tone,"default")});r.append(o("blockquote",{class:"rui-quote-text"},[d(e.text)]));const a=d(e.cite);return a&&r.append(o("figcaption",{class:"rui-quote-cite"},[a])),r}};function us(t){const e=f=>f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),r=t.split(/\r?\n/),a=[];let i=null,n=!1,s=!1,l="",c=[];const u=()=>{i&&(a.push(i==="ul"?"</ul>":"</ol>"),i=null)},p=()=>{n&&(a.push("</blockquote>"),n=!1)},m=()=>{const f=l?` data-language="${e(l)}"`:"";a.push(`<pre class="rui-markdown-code"${f}><code>${e(c.join(`
20
- `))}</code></pre>`),c=[],l="",s=!1};for(const f of r){const h=/^```\s*(.*)$/.exec(f.trim());if(s){if(h){m();continue}c.push(f);continue}if(h){u(),p(),s=!0,l=h[1]??"";continue}const b=/^\s*(#{1,3})\s+(.+)$/.exec(f);if(b){u(),p();const w=b[1].length;a.push(`<h${w} class="rui-markdown-h${w}">${g(e(b[2]))}</h${w}>`);continue}const v=/^\s*>\s?(.*)$/.exec(f);if(v){u(),n||(a.push('<blockquote class="rui-markdown-quote">'),n=!0),a.push(`<p>${g(e(v[1]??""))}</p>`);continue}else n&&f.trim()!==""&&p();const y=/^\s*[-*]\s+(.*)$/.exec(f);if(y){p(),i!=="ul"&&(u(),a.push("<ul>"),i="ul"),a.push(`<li>${g(e(y[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(f);if(x){p(),i!=="ol"&&(u(),a.push("<ol>"),i="ol"),a.push(`<li>${g(e(x[1]??""))}</li>`);continue}if(f.trim()===""){u(),p();continue}u(),p(),a.push(`<p>${g(e(f))}</p>`)}return s&&m(),u(),p(),a.join("");function g(f){let h=f.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(b,v,y)=>{const x=re(y);return x?`<img class="rui-markdown-image" src="${nt(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,(b,v,y)=>`<a class="rui-link" href="${va(y)}" target="_blank" rel="noopener noreferrer">${v}</a>`);return h=h.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,b=>`<a class="rui-link" href="${va(b)}" target="_blank" rel="noopener noreferrer">${b}</a>`),h}}function va(t){const e=t.trim();if(!e||e.startsWith("//"))return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("?"))return nt(e);const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);if(!r)return nt(e);const a=r[1].toLowerCase();return new Set(["http","https","mailto","tel"]).has(a)?nt(e):"#"}function nt(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ve(t,e,r){const a=o("span",{class:"rui-avatar","data-size":r,role:"img"}),i=re(t);if(i){const n=o("img",{src:i,alt:e,loading:"lazy"});n.onerror=s=>{const l=s;(l.currentTarget??l.target).replaceWith(o("span",{class:"rui-avatar-fallback"},[We(e)]))},a.append(n)}else a.append(o("span",{class:"rui-avatar-fallback"},[We(e)]));return a}function We(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 ot=new WeakMap;function Ee(t){const{liveRoot:e,onDismiss:r}=t,a=ot.get(e);a&&a.dispose();const i=e.getRootNode();let n=!1;const s=m=>{const g=m.target;g&&e.contains(g)||(p.dispose(),r())},l=m=>{m.key==="Escape"&&(p.dispose(),r())},c=e.ownerDocument;let u=null;if(c&&typeof MutationObserver<"u"){u=new MutationObserver(()=>{e.isConnected||p.dispose()});const m=e.getRootNode();(m instanceof Element||m instanceof Document||m instanceof ShadowRoot)&&u.observe(m,{childList:!0,subtree:!0})}const p={dispose:()=>{n||(n=!0,i.removeEventListener("click",s,!0),i.removeEventListener("keydown",l,!0),u?.disconnect(),ot.delete(e))}};return setTimeout(()=>{n||(i.addEventListener("click",s,!0),i.addEventListener("keydown",l,!0))},0),ot.set(e,p),p}function he(t){if(!t)return;const e=ot.get(t);e&&e.dispose()}const ds=[{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 ya(t){if(!t)return null;for(const e of ds)if(e.match.test(t))return e.icon;return null}const ps={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function ms(t){return t?ps[t.toLowerCase()]??null:null}function gs(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 xa(t){return k(t).map(r=>{if(r&&typeof r=="object"){const i=r;if(i.__kind==="Component"&&Array.isArray(i.args)){const n=d(i.args[0]);return{value:n,label:d(i.args[1],n)}}if(i.value!==void 0||i.label!==void 0){const n=d(i.value);return{value:n,label:d(i.label,n)}}}const a=d(r);return{value:a,label:a}}).filter(r=>r.value!==""||r.label!=="")}const fs=["primary","secondary","ghost","danger"],hs=["xs","sm","md","lg","xl","small","normal","large"],bs=["text","email","password","number","tel","url","date"];function vs(t){const e=d(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"}const ys={name:"Button",description:"Clickable button. The action argument runs when clicked.",props:[{name:"label",type:"string"},{name:"action",type:"callable",optional:!0,aliases:["onClick","onclick"],description:"Callable invoked when clicked"},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:fs},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:hs,description:"Canonical `xs|sm|md|lg|xl` (legacy `small|normal|large` still accepted)"},{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=C(e.loading),i=C(e.iconOnly),n=d(e.iconPosition,"leading"),s=d(e.label),l=o("button",{class:"rui-button",type:d(e.type,"button"),"data-variant":d(e.variant,"primary"),"data-size":vs(e.size),"data-icon-position":n,"data-icon-only":i?"true":null,"data-full-width":C(e.fullWidth)?"true":null,"data-loading":a?"true":null,"aria-label":i?s:null,disabled:C(e.disabled)||a?"":null}),c=o("span",{class:"rui-button-label"},[s]),u=L(e.icon,{className:"rui-button-icon"}),m=(a?L("spinner",{className:"rui-button-spinner"}):null)??u;return i?m&&l.append(m):n==="trailing"?(l.append(c),m&&l.append(m)):(m&&l.append(m),l.append(c)),l.onclick=()=>{a||r.invoke(e.action)},l}},xs={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=o("div",{class:"rui-buttons","data-direction":d(e.direction,"row")});for(const i of k(e.items))a.append(r.renderNode(i));return a}},ws={name:"Input",description:"Text input field. Pass a $variable as `value` for two-way binding.",props:[{name:"id",type:"string",description:"Input identifier"},{name:"placeholder",type:"string",optional:!0},{name:"type",type:"string",optional:!0,enum:bs},{name:"validations",type:"any",optional:!0,description:"Array or object of validation hints"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"}],render:(t,e,r)=>{const a=o("input",{class:"rui-input",id:d(e.id),name:d(e.id),type:d(e.type,"text"),placeholder:d(e.placeholder),value:d(e.value)});return Ce(a,t,4,r),Ds(a,e.validations),a}},ks={name:"TextArea",description:"Multi-line text input.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0},{name:"value",type:"any",optional:!0}],render:(t,e,r)=>{const a=o("textarea",{class:"rui-textarea",id:d(e.id),name:d(e.id),placeholder:d(e.placeholder),rows:String(Number(e.rows??4)||4)});return a.value=d(e.value),Ce(a,t,3,r),a}},Ss={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>o("option",{value:d(e.value)},[d(e.label)])},Cs={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.",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"}],render:(t,e,r)=>{if(C(e.searchable))return Bs(t,e,r);const a=o("select",{class:"rui-select",id:d(e.id),name:d(e.id)}),i=d(e.placeholder);i&&a.append(o("option",{value:"",disabled:"",selected:""},[i]));for(const n of k(e.items))a.append(r.renderNode(n));return a.value=d(e.value),Ce(a,t,4,r),a}},Ts={name:"Checkbox",description:"Boolean checkbox.",props:[{name:"id",type:"string"},{name:"label",type:"string"},{name:"value",type:"boolean",optional:!0,aliases:["checked"]}],render:(t,e,r)=>{const a=o("label",{class:"rui-checkbox"}),i=C(e.value),n=o("input",{type:"checkbox",id:d(e.id),name:d(e.id),checked:i?"":null});return n.checked=i,Ce(n,t,2,r),a.append(n,o("span",{class:"rui-checkbox-label"},[d(e.label)])),a}},$s={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=d(e.name),a=d(e.label),i=d(e.description),n=C(e.defaultChecked),s=o("label",{class:"rui-checkbox-item","data-name":r}),l=o("input",{type:"checkbox",name:r,checked:n?"":null});l.checked=n;const c=o("div",{class:"rui-checkbox-item-text"});return c.append(o("div",{class:"rui-checkbox-item-label"},[a])),i&&c.append(o("div",{class:"rui-checkbox-item-description"},[i])),s.append(l,c),s}},Ns={name:"CheckBoxGroup",description:"Group of checkboxes. Value is an object keyed by item name. Pass a `$variable` for two-way binding.",props:[{name:"name",type:"string",description:"Group identifier"},{name:"items",type:"CheckBoxItem[]"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"}],render:(t,e,r)=>{const a=d(e.name),i=o("div",{class:"rui-checkbox-group",role:"group","data-name":a}),n=k(e.items),s=e.value&&typeof e.value=="object"?e.value:{};n.forEach((c,u)=>{const p=d(c.args?.[0]),m=d(c.args?.[1],`${a}-${u}`),g=d(c.args?.[2]),f=C(c.args?.[3]),h=`${a}-${m}`,b=o("label",{class:"rui-checkbox-item",for:h}),v=m in s?!!s[m]:f,y=o("input",{type:"checkbox",id:h,name:m,checked:v?"":null}),x=o("div",{class:"rui-checkbox-item-text"});x.append(o("div",{class:"rui-checkbox-item-label"},[p])),g&&x.append(o("div",{class:"rui-checkbox-item-description"},[g])),b.append(y,x),i.append(b)});const l=t.argMeta?.[2]?.stateRef;return l&&r.bindState(i,l,{event:"change",getValue:c=>{const u={};return c.querySelectorAll('input[type="checkbox"]').forEach(p=>{u[p.name]=p.checked}),u}}),i}},As={name:"Radio",description:"Radio button group.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"value",type:"any",optional:!0}],render:(t,e,r)=>{const a=d(e.id),i=o("div",{class:"rui-radio-group",role:"radiogroup"});for(const n of k(e.items)){const s=d(n.args?.[0]),l=d(n.args?.[1],s),c=`${a}-${s}`,u=o("label",{class:"rui-radio",for:c}),p=d(e.value)===s,m=o("input",{type:"radio",id:c,name:a,value:s,checked:p?"":null});m.checked=p,Ce(m,t,2,r),u.append(m,o("span",{class:"rui-radio-label"},[l])),i.append(u)}return i}},Ms={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=o("div",{class:"rui-form-control"});a.append(o("label",{class:"rui-form-label"},[d(e.label)]));const i=r.renderNode(e.field);a.append(i);const n=d(e.hint);return n&&a.append(o("p",{class:"rui-form-hint"},[n])),a}},wa={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:"action",type:"callable",optional:!0,aliases:["onClick","onSubmit"],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.'}],render:(t,e,r)=>{const a=o("form",{class:"rui-search-bar",role:"search"});a.onsubmit=l=>{l.preventDefault(),r.invoke(e.action)};const i=L("magnifying-glass",{className:"rui-search-bar-icon"})??o("span",{class:"rui-search-bar-icon","aria-hidden":"true"});a.append(i);const n=o("input",{class:"rui-search-bar-input",id:d(e.id),name:d(e.id),type:"search",placeholder:d(e.placeholder,"Search…"),value:d(e.value),autocomplete:"off"});Ce(n,t,2,r),a.append(n);const s=d(e.shortcut);if(s&&a.append(o("span",{class:"rui-search-bar-shortcut"},[s])),e.action!=null){const l=o("button",{type:"submit",class:"rui-search-bar-submit"},[d(e.submitLabel,"Search")]);a.append(l)}return a}},Ps={name:"Form",description:"Form container. Children FormControls render in order; buttons render at the bottom.",props:[{name:"id",type:"string"},{name:"buttons",type:"Buttons | Button"},{name:"fields",type:"FormControl[]"}],render:(t,e,r)=>{const a=o("form",{class:"rui-form",id:d(e.id)});a.onsubmit=i=>i.preventDefault();for(const i of k(e.fields))a.append(r.renderNode(i));if(e.buttons){const i=o("div",{class:"rui-form-actions"});i.append(r.renderNode(e.buttons)),a.append(i)}return a}},Is={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}],render:(t,e,r)=>{const a=d(e.id),i=P(e.min,0),n=P(e.max,100),s=P(e.step,1),l=P(e.value,i),c=o("div",{class:"rui-slider","data-disabled":C(e.disabled)?"true":"false"}),u=d(e.label),p=C(e.showValue);if(u||p){const f=o("div",{class:"rui-slider-head"});u&&f.append(o("label",{class:"rui-slider-label",for:a},[u])),p&&f.append(o("span",{class:"rui-slider-value"},[String(l)])),c.append(f)}const m=o("input",{type:"range",class:"rui-slider-input",id:a,name:a,min:String(i),max:String(n),step:String(s),value:String(l),disabled:C(e.disabled)?"":null});m.oninput=f=>{const h=f.currentTarget;if(!h)return;const v=h.closest(".rui-slider")?.querySelector(".rui-slider-value");v&&(v.textContent=h.value)};const g=t.argMeta?.[4]?.stateRef;return g&&r.bindState(m,g,{event:"input",getValue:f=>Number(f.value)}),c.append(m),c}},zs={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}],render:(t,e,r)=>{const a=d(e.id),i=P(e.step,1),n=e.min!==void 0&&e.min!==null,s=e.max!==void 0&&e.max!==null,l=n?P(e.min,0):Number.NEGATIVE_INFINITY,c=s?P(e.max,0):Number.POSITIVE_INFINITY,u=C(e.disabled),p=o("div",{class:"rui-number-input","data-disabled":u?"true":"false"}),m=o("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:u?"":null},["−"]),g=o("input",{type:"number",class:"rui-number-input-field",id:a,name:a,value:d(e.value),placeholder:d(e.placeholder),min:n?String(l):null,max:s?String(c):null,step:String(i),disabled:u?"":null}),f=o("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:u?"":null},["+"]),h=t.argMeta?.[1]?.stateRef;h&&r.bindState(g,h,{event:"input",getValue:v=>{const y=v.value;if(y==="")return null;const x=Number(y);return Number.isFinite(x)?x:null}});const b=(v,y)=>{const w=v.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!w)return;const T=Number(w.value),S=Number.isFinite(T)?T:0,N=js(S+y,l,c);w.value=String(N),w.dispatchEvent(new Event("input",{bubbles:!0}))};return m.onclick=v=>b(v.currentTarget??v.target,-i),f.onclick=v=>b(v.currentTarget??v.target,i),p.append(m,g,f),p}},Rs={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}],render:(t,e,r)=>{const a=d(e.id),i=o("div",{class:"rui-date-picker"}),n=d(e.label);n&&i.append(o("label",{class:"rui-date-picker-label",for:a},[n]));const s=o("input",{type:"date",class:"rui-date-picker-input",id:a,name:a,value:d(e.value),min:d(e.min)||null,max:d(e.max)||null,placeholder:d(e.placeholder),disabled:C(e.disabled)?"":null});return Ce(s,t,1,r),i.append(s),i}},Ls={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:"action",type:"callable",optional:!0,aliases:["onChange","onSelect"],description:"Callable fired 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=d(e.id),i=C(e.disabled),n=o("div",{class:"rui-file-upload","data-disabled":i?"true":"false"}),s=o("label",{class:"rui-file-upload-dropzone",for:a}),l=L(d(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});l&&s.append(l);const c=o("div",{class:"rui-file-upload-text"});c.append(o("div",{class:"rui-file-upload-label"},[d(e.label,"Choose a file")]));const u=d(e.hint);u&&c.append(o("div",{class:"rui-file-upload-hint"},[u])),s.append(c);const p=o("input",{type:"file",id:a,name:a,class:"rui-file-upload-input",accept:d(e.accept)||null,multiple:C(e.multiple)?"":null,disabled:i?"":null});s.append(p),n.append(s);const m=(g,f)=>f.includes("image")||g.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(g.name);return p.onchange=g=>{r.invoke(e.action);const f=g.currentTarget,h=f.closest(".rui-file-upload");if(!h)return;const b=f.files,v=h.querySelector(".rui-file-upload-preview");if(v&&v.remove(),!b||b.length===0)return;const y=d(e.accept),x=o("div",{class:"rui-file-upload-preview"});Array.from(b).forEach(w=>{const T=o("div",{class:"rui-file-upload-preview-item"});if(m(w,y)){const S=URL.createObjectURL(w),N=o("img",{src:S,alt:w.name,class:"rui-file-upload-thumbnail"});N.onload=()=>URL.revokeObjectURL(S),T.append(N)}T.append(o("span",{class:"rui-file-upload-filename"},[w.name])),x.append(T)}),h.append(x)},n}},ka={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"}],render:(t,e,r)=>{const a=d(e.id),i=xa(e.items),n=d(e.value),s=i.find(N=>N.value===n)?.label??n,l=d(e.placeholder,"Select…"),c=d(e.emptyLabel,"No matches"),u=C(e.disabled),p=C(e.open),m=r.useInstanceState("open",p),g=r.useInstanceState("filter",""),f=m.get(),h=o("div",{class:"rui-combobox","data-open":f?"true":"false","data-disabled":u?"true":"false"}),b=o("button",{type:"button",class:"rui-combobox-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":f?"true":"false",disabled:u?"":null});b.append(o("span",{class:"rui-combobox-value","data-placeholder":s?"false":"true"},[s||l]));const v=L("chevron-down",{className:"rui-combobox-chevron"});v&&b.append(v),h.append(b);const y=o("div",{class:"rui-combobox-panel",role:"listbox"}),x=o("input",{type:"text",class:"rui-combobox-filter",placeholder:"Filter…",autocomplete:"off",value:g.get()});y.append(x);const w=o("div",{class:"rui-combobox-list"});y.append(w);const T=(N,$)=>{N.replaceChildren();const A=$.trim().toLowerCase(),z=A===""?i:i.filter(R=>R.label.toLowerCase().includes(A)||R.value.toLowerCase().includes(A));if(z.length===0){N.append(o("div",{class:"rui-combobox-empty"},[c]));return}for(const R of z){const _=o("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":R.value,"aria-selected":R.value===n?"true":"false"},[R.label]);_.onclick=Q=>{Q.stopPropagation(),S(Q.currentTarget,R.value)},N.append(_)}},S=(N,$)=>{const A=t.argMeta?.[2]?.stateRef;A&&r.setState(A,$),m.set(!1),g.set("");const z=N.closest(".rui-combobox");z?.setAttribute("data-open","false"),z?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false"),he(z)};return T(w,g.get()),x.oninput=N=>{const $=N.currentTarget;g.set($.value);const A=$.closest(".rui-combobox-panel")?.querySelector(".rui-combobox-list");A&&T(A,$.value)},x.onkeydown=N=>{const $=N;if($.key!=="Enter")return;$.preventDefault();const R=$.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),_=R?.getAttribute("data-value");_!=null&&R&&S(R,_)},b.onclick=N=>{if(u)return;N.stopPropagation();const $=!m.get();m.set($);const A=N.currentTarget.closest(".rui-combobox");if(A?.setAttribute("data-open",$?"true":"false"),A?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded",$?"true":"false"),!!A){if(!$){he(A);return}setTimeout(()=>x.focus(),0),Ee({liveRoot:A,onDismiss:()=>{m.set(!1),g.set(""),A.setAttribute("data-open","false"),A.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},h.append(y),h}},Es={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"}],render:(t,e,r)=>{const a=d(e.id),i=xa(e.items),n=d(e.placeholder,"Select…"),s=d(e.emptyLabel,"No matches"),l=C(e.disabled),c=Math.max(0,Math.floor(Number(e.max??0))),u=Array.isArray(e.value)?e.value.map(z=>d(z)).filter(Boolean):[],p=new Set(u),m=t.argMeta?.[2]?.stateRef,g=C(e.open),f=r.useInstanceState("open",g),h=r.useInstanceState("filter",""),b=f.get(),v=o("div",{class:"rui-multiselect","data-open":b?"true":"false","data-disabled":l?"true":"false"}),y=o("button",{type:"button",class:"rui-multiselect-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":b?"true":"false",disabled:l?"":null}),x=o("span",{class:"rui-multiselect-chips"}),w=z=>{m&&r.setState(m,z)};if(u.length===0)x.append(o("span",{class:"rui-multiselect-placeholder"},[n]));else for(const z of u){const R=i.find(B=>B.value===z)?.label??z,_=o("span",{class:"rui-multiselect-chip","data-value":z});_.append(o("span",{class:"rui-multiselect-chip-label"},[R]));const Q=o("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${R}`},["×"]);Q.onclick=B=>{B.stopPropagation();const O=u.filter(J=>J!==z);w(O)},_.append(Q),x.append(_)}y.append(x);const T=L("chevron-down",{className:"rui-multiselect-chevron"});T&&y.append(T),v.append(y);const S=o("div",{class:"rui-multiselect-panel",role:"listbox","aria-multiselectable":"true"}),N=o("input",{type:"text",class:"rui-multiselect-filter",placeholder:"Filter…",autocomplete:"off",value:h.get()});S.append(N);const $=o("div",{class:"rui-multiselect-list"});S.append($);const A=(z,R)=>{z.replaceChildren();const _=R.trim().toLowerCase(),Q=_===""?i:i.filter(B=>B.label.toLowerCase().includes(_)||B.value.toLowerCase().includes(_));if(Q.length===0){z.append(o("div",{class:"rui-multiselect-empty"},[s]));return}for(const B of Q){const O=p.has(B.value),J=!O&&c>0&&u.length>=c,X=o("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":B.value,"data-selected":O?"true":"false","aria-selected":O?"true":"false",disabled:J?"":null}),de=o("span",{class:"rui-multiselect-option-check"}),ge=L(O?"check":"",{className:"rui-multiselect-option-check-icon"});ge&&de.append(ge),X.append(de),X.append(o("span",{class:"rui-multiselect-option-label"},[B.label])),X.onclick=Je=>{if(Je.stopPropagation(),J)return;const Ae=O?u.filter(tr=>tr!==B.value):[...u,B.value];w(Ae)},z.append(X)}};return A($,h.get()),N.oninput=z=>{const R=z.currentTarget;h.set(R.value);const _=R.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");_&&A(_,R.value)},y.onclick=z=>{if(l)return;z.stopPropagation();const R=!f.get();f.set(R);const _=z.currentTarget.closest(".rui-multiselect");if(_?.setAttribute("data-open",R?"true":"false"),_?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",R?"true":"false"),!!_){if(!R){he(_);return}setTimeout(()=>N.focus(),0),Ee({liveRoot:_,onDismiss:()=>{f.set(!1),h.set(""),_.setAttribute("data-open","false"),_.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},v.append(S),v}},_s={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}],render:(t,e,r)=>{const a=d(e.id),i=`${a}-from`,n=`${a}-to`,s=d(e.min),l=d(e.max),c=C(e.disabled),u=o("div",{class:"rui-date-range-picker","data-disabled":c?"true":"false"}),p=d(e.label);p&&u.append(o("label",{class:"rui-date-range-picker-label",for:i},[p]));const m=o("div",{class:"rui-date-range-picker-row"}),g=o("input",{type:"date",class:"rui-date-range-picker-input",id:i,name:i,value:d(e.from),min:s||null,max:l||null,disabled:c?"":null,"data-role":"from"});m.append(g),m.append(o("span",{class:"rui-date-range-picker-separator","aria-hidden":"true"},["–"]));const f=o("input",{type:"date",class:"rui-date-range-picker-input",id:n,name:n,value:d(e.to),min:s||null,max:l||null,disabled:c?"":null,"data-role":"to"});m.append(f),u.append(m);const h=t.argMeta?.[1]?.stateRef,b=t.argMeta?.[2]?.stateRef;return h&&r.bindState(g,h),b&&r.bindState(f,b),u}};function js(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function Bs(t,e,r){const a=t.argMeta?[...t.argMeta]:[];for(;a.length<5;)a.push({});a[4]?.stateRef&&(a[2]=a[4]);const i=ka.render({...t,argMeta:a},{id:e.id,items:e.items,value:e.value,placeholder:e.placeholder,emptyLabel:"No matches",disabled:!1},r);return i.classList.add("rui-select-searchable"),i}function Ce(t,e,r,a){const i=e.argMeta?.[r]?.stateRef;if(i){if(t instanceof HTMLInputElement&&t.type==="checkbox"){a.bindState(t,i,{event:"change",getValue:n=>n.checked});return}a.bindState(t,i)}}function Ds(t,e){if(!e)return;const r=Array.isArray(e)?e.map(a=>String(a)):typeof e=="object"?Object.entries(e).map(([a,i])=>i?`${a}:${i}`: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 ve=["default","primary","success","warning","danger","info"],Te=(t,e)=>{const r=k(t);if(r.length===0)return null;const a=o("div",{class:"rui-pattern-actions"});for(const i of r)a.append(e.renderNode(i));return a},Fs=[{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 Os(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const a of Fs)if(a.match.test(r))return a.label;return""}const Us={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:ve,description:"Accent tone"}],render:(t,e,r)=>{const a=d(e.layout,"default"),i=d(e.title),n=d(e.subtitle),l=d(e.eyebrow)||Os(i,n),c=d(e.tone,"primary");if(a==="cover"){const h=co(d(e.imageSrc)),b=ee(d(e.height),"280px"),v=o("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("${h}");min-height:${b};`}),y=o("div",{class:"rui-cover-body"});l&&y.append(o("span",{class:"rui-cover-eyebrow"},[l])),y.append(o("h1",{class:"rui-cover-title"},[i])),n&&y.append(o("p",{class:"rui-cover-subtitle"},[n]));const x=d(e.caption);x&&y.append(o("p",{class:"rui-cover-caption"},[x]));const w=Te(e.actions,r);if(w)w.classList.add("rui-cover-actions"),y.append(w);else{const T=[e.primary,e.secondary].filter(Boolean);if(T.length>0){const S=o("div",{class:"rui-cover-actions rui-pattern-actions"});for(const N of T)S.append(r.renderNode(N));y.append(S)}}return v.append(y),v}const u=re(e.imageSrc),p=o("section",{class:"rui-hero","data-tone":c,"data-has-image":u?"true":"false"}),m=o("div",{class:"rui-hero-body"});l&&m.append(o("span",{class:"rui-hero-eyebrow"},[l])),m.append(o("h1",{class:"rui-hero-title"},[i])),n&&m.append(o("p",{class:"rui-hero-subtitle"},[n]));const g=k(e.highlights);if(g.length>0){const h=o("div",{class:"rui-hero-highlights"});for(const b of g){const v=d(b);v&&h.append(o("span",{class:"rui-hero-highlight"},[v]))}m.append(h)}const f=[e.primary,e.secondary].filter(Boolean);if(f.length>0){const h=o("div",{class:"rui-hero-ctas"});for(const b of f)h.append(r.renderNode(b));m.append(h)}if(p.append(m),u){const h=o("div",{class:"rui-hero-media"});h.append(o("img",{src:u,alt:"",loading:"lazy"})),p.append(h)}return p}},qs={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=o("header",{class:"rui-page-header"}),i=d(e.title);let n=e.breadcrumbs;if(n==null?i&&(n=["Home",i]):(n===!1||n==="false")&&(n=null),n){const m=o("div",{class:"rui-page-header-breadcrumbs"});Array.isArray(n)?n.forEach((g,f)=>{f>0&&m.append(o("span",{class:"rui-page-header-crumb-sep"},["/"])),m.append(o("span",{class:"rui-page-header-crumb"},[d(g)]))}):m.append(r.renderNode(n)),a.append(m)}const s=o("div",{class:"rui-page-header-title-row"}),l=o("div",{class:"rui-page-header-title-block"}),c=o("div",{class:"rui-page-header-title-line"});c.append(o("h1",{class:"rui-page-header-title"},[i])),e.status&&c.append(r.renderNode(e.status)),l.append(c);const u=d(e.subtitle);u&&l.append(o("p",{class:"rui-page-header-subtitle"},[u])),s.append(l);const p=Te(e.actions,r);return p&&(p.classList.add("rui-page-header-actions"),s.append(p)),a.append(s),a}},Hs={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=o("div",{class:"rui-empty-state"}),i=re(e.illustration);if(i)a.append(o("img",{class:"rui-empty-state-illustration",src:i,alt:"",loading:"lazy"}));else{const l=d(e.title),c=d(e.description),u=d(e.icon)||ya(`${l} ${c}`)||"inbox",p=L(u,{className:"rui-empty-state-icon"});p&&a.append(p)}a.append(o("h3",{class:"rui-empty-state-title"},[d(e.title)]));const n=d(e.description);n&&a.append(o("p",{class:"rui-empty-state-description"},[n]));const s=k(e.actions);if(s.length>0){const l=o("div",{class:"rui-empty-state-actions"});for(const c of s)l.append(r.renderNode(c));a.append(l)}else if(e.action){const l=o("div",{class:"rui-empty-state-action"});l.append(r.renderNode(e.action)),a.append(l)}return a}},Vs={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:ve}],render:(t,e)=>{const r=o("li",{class:"rui-timeline-item","data-tone":d(e.tone,"default")}),a=o("span",{class:"rui-timeline-marker"}),i=L(e.icon);i&&a.append(i),r.append(a);const n=o("div",{class:"rui-timeline-body"}),s=o("div",{class:"rui-timeline-head"});s.append(o("span",{class:"rui-timeline-title"},[d(e.title)]));const l=d(e.time);l&&s.append(o("span",{class:"rui-timeline-time"},[l])),n.append(s);const c=d(e.description);return c&&n.append(o("div",{class:"rui-timeline-description"},[c])),r.append(n),r}},Ws={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=o("ol",{class:"rui-timeline"});for(const i of k(e.items))a.append(r.renderNode(i));return a}},Gs={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:ve}],render:(t,e)=>{const r=o("div",{class:"rui-feature-item","data-tone":d(e.tone,"primary")}),a=d(e.icon,"sparkles"),i=L(a,{className:"rui-feature-icon"});i&&r.append(i),r.append(o("h3",{class:"rui-feature-title"},[d(e.title)]));const n=d(e.description);return n&&r.append(o("p",{class:"rui-feature-description"},[n])),r}},Ks={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"))),i=o("div",{class:"rui-feature-grid","data-columns":a>0?String(a):null});for(const n of k(e.items))i.append(r.renderNode(n));return i}},Ys={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=o("figure",{class:"rui-testimonial"}),a=Math.max(0,Math.min(5,Math.round(Number(e.rating??0))));if(a>0){const c=o("div",{class:"rui-testimonial-rating"});for(let u=0;u<5;u+=1){const p=u<a,m=L(p?"star":"regular:star",{className:"rui-testimonial-rating-star"});m&&c.append(m)}r.append(c)}r.append(o("blockquote",{class:"rui-testimonial-quote"},[d(e.quote)]));const i=o("figcaption",{class:"rui-testimonial-author"}),n=re(e.avatarSrc);n&&i.append(o("img",{class:"rui-testimonial-avatar",src:n,alt:""}));const s=o("div",{class:"rui-testimonial-meta"});s.append(o("div",{class:"rui-testimonial-name"},[d(e.author)]));const l=d(e.role);return l&&s.append(o("div",{class:"rui-testimonial-role"},[l])),i.append(s),r.append(i),r}},Js={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=o("div",{class:"rui-profile-card"}),i=o("div",{class:"rui-profile-card-header"});i.append(Ve(d(e.avatarSrc),d(e.name),"lg"));const n=o("div",{class:"rui-profile-card-meta"});n.append(o("h3",{class:"rui-profile-card-name"},[d(e.name)]));const s=d(e.role);s&&n.append(o("p",{class:"rui-profile-card-role"},[s])),i.append(n),a.append(i);const l=d(e.bio);l&&a.append(o("p",{class:"rui-profile-card-bio"},[l]));const c=k(e.tags);if(c.length>0){const p=o("div",{class:"rui-profile-card-tags"});for(const m of c){const g=d(m);g&&p.append(o("span",{class:"rui-tag","data-size":"sm"},[o("span",{class:"rui-tag-label"},[g])]))}a.append(p)}const u=Te(e.actions,r);return u&&(u.classList.add("rui-profile-card-actions"),a.append(u)),a}},Xs={name:"Comment",description:"Single comment / message bubble. Renders avatar, author, timestamp, body, and an optional row of action 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=o("article",{class:"rui-comment"});a.append(Ve(d(e.avatarSrc),d(e.author),"md"));const i=o("div",{class:"rui-comment-body"}),n=o("header",{class:"rui-comment-header"});n.append(o("span",{class:"rui-comment-author"},[d(e.author)]));const s=d(e.time);s&&n.append(o("span",{class:"rui-comment-time"},[s])),i.append(n),i.append(o("div",{class:"rui-comment-content"},[d(e.body)]));const l=Te(e.actions,r);return l&&(l.classList.add("rui-comment-actions"),i.append(l)),a.append(i),a}},Zs={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:ve}],render:(t,e,r)=>{const a=d(e.tone,"primary"),i=o("aside",{class:"rui-banner","data-tone":a}),n=d(e.icon)||ms(a)||"",s=L(n,{className:"rui-banner-icon"});s&&i.append(s);const l=o("div",{class:"rui-banner-body"});l.append(o("strong",{class:"rui-banner-title"},[d(e.title)]));const c=d(e.message);if(c&&l.append(o("span",{class:"rui-banner-message"},[c])),i.append(l),e.action){const u=o("div",{class:"rui-banner-action"});u.append(r.renderNode(e.action)),i.append(u)}return i}},Qs={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:ve},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown beside the title"},{name:"action",type:"callable",optional:!0,aliases:["onClick","onclick"],description:"Optional callable fired when the card is clicked"}],render:(t,e,r)=>{const a=o("div",{class:"rui-kanban-card","data-tone":d(e.tone,"default")});typeof e.action=="function"&&(a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.onclick=()=>r.invoke(e.action),a.onkeydown=u=>{const p=u;(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r.invoke(e.action))});const i=o("div",{class:"rui-kanban-card-title"}),n=L(e.icon,{className:"rui-kanban-card-icon"});n&&i.append(n),i.append(document.createTextNode(d(e.title))),a.append(i);const s=d(e.description);s&&a.append(o("p",{class:"rui-kanban-card-description"},[s]));const l=k(e.tags);if(l.length>0){const u=o("div",{class:"rui-kanban-card-tags"});for(const p of l){const m=d(p);m&&u.append(o("span",{class:"rui-tag","data-size":"sm"},[o("span",{class:"rui-tag-label"},[m])]))}a.append(u)}const c=d(e.assignee);if(c){const u=o("footer",{class:"rui-kanban-card-footer"});u.append(Ve("",c,"sm")),u.append(o("span",{class:"rui-kanban-card-assignee"},[c])),a.append(u)}return a}},el={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:ve,description:"Header accent tone"}],render:(t,e,r)=>{const a=k(e.items),i=o("section",{class:"rui-kanban-column","data-tone":d(e.tone,"default")}),n=o("header",{class:"rui-kanban-column-header"});n.append(o("span",{class:"rui-kanban-column-title"},[d(e.title)])),n.append(o("span",{class:"rui-kanban-column-count"},[String(a.length)])),i.append(n);const s=o("div",{class:"rui-kanban-column-body"});for(const l of a)s.append(r.renderNode(l));return a.length===0&&s.append(o("div",{class:"rui-kanban-column-empty"},["No items"])),i.append(s),i}},tl={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=o("div",{class:"rui-kanban-board"});for(const i of k(e.columns))a.append(r.renderNode(i));return a}},rl={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=o("header",{class:"rui-section-header"}),i=o("div",{class:"rui-section-header-left"}),n=d(e.eyebrow);n&&i.append(o("span",{class:"rui-section-header-eyebrow"},[n]));const s=o("div",{class:"rui-section-header-title-line"});s.append(o("h3",{class:"rui-section-header-title"},[d(e.title)])),e.status&&s.append(r.renderNode(e.status)),i.append(s);const l=d(e.subtitle);l&&i.append(o("p",{class:"rui-section-header-subtitle"},[l])),a.append(i);const c=Te(e.actions,r);return c&&(c.classList.add("rui-section-header-actions"),a.append(c)),a}},al={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=k(e.center),i=o("div",{class:"rui-toolbar","data-has-center":a.length>0?"true":"false"}),n=o("div",{class:"rui-toolbar-side rui-toolbar-left"});C(e.searchable)&&n.append(wa.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:d(e.searchPlaceholder,"Search…"),value:e.searchValue},r));for(const l of k(e.left))n.append(r.renderNode(l));if(i.append(n),a.length>0){const l=o("div",{class:"rui-toolbar-side rui-toolbar-center"});for(const c of a)l.append(r.renderNode(c));i.append(l)}const s=o("div",{class:"rui-toolbar-side rui-toolbar-right"});for(const l of k(e.right))s.append(r.renderNode(l));return i.append(s),i}},il={name:"SidebarItem",description:"Single navigation item inside a Sidebar. Pass `active=true` to mark as the current page, an `action` Action for click handling, or an optional `badge` (string/number) for a trailing chip.",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},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"action",type:"callable",optional:!0,aliases:["onClick","onclick"]}],render:(t,e,r)=>{const a=o("button",{type:"button",class:"rui-sidebar-item","data-active":C(e.active)?"true":"false"}),i=L(e.icon,{className:"rui-sidebar-item-icon"});i&&a.append(i),a.append(o("span",{class:"rui-sidebar-item-label"},[d(e.label)]));const n=d(e.badge);return n&&a.append(o("span",{class:"rui-sidebar-item-badge"},[n])),typeof e.action=="function"&&(a.onclick=()=>r.invoke(e.action)),a}},nl={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=o("div",{class:"rui-sidebar-section"}),i=d(e.label);i&&a.append(o("div",{class:"rui-sidebar-section-label"},[i]));for(const n of k(e.items))a.append(r.renderNode(n));return a}},ol={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=C(e.collapsed),i=o("aside",{class:"rui-sidebar"});a&&(i.dataset.collapsed="true");const n=d(e.brand),s=d(e.tagline);if(n||s){const u=o("div",{class:"rui-sidebar-header"});n&&u.append(o("div",{class:"rui-sidebar-brand"},[n])),s&&u.append(o("div",{class:"rui-sidebar-tagline"},[s])),i.append(u)}const l=o("nav",{class:"rui-sidebar-body"});for(const u of k(e.items))l.append(r.renderNode(u));i.append(l);const c=k(e.footer);if(c.length>0){const u=o("div",{class:"rui-sidebar-footer"});for(const p of c)u.append(r.renderNode(p));i.append(u)}return i}},sl={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=C(e.collapsible),i=C(e.sidebarOpen),n=o("div",{class:"rui-app-shell"});a&&(n.dataset.collapsible="true"),i&&(n.dataset.sidebarOpen="true");const s=o("div",{class:"rui-app-shell-sidebar"});if(s.append(r.renderNode(e.sidebar)),n.append(s),a){const p=o("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});p.addEventListener("click",()=>{delete n.dataset.sidebarOpen}),n.append(p)}const l=o("div",{class:"rui-app-shell-main"}),c=k(e.topbar);if(c.length>0||a){const p=o("div",{class:"rui-app-shell-topbar"});if(a){const m=o("button",{class:"rui-app-shell-toggle",type:"button","aria-label":"Toggle navigation"});m.append(L("bars",{size:"md"})??document.createTextNode("≡")),m.addEventListener("click",()=>{n.dataset.sidebarOpen?delete n.dataset.sidebarOpen:n.dataset.sidebarOpen="true"}),p.append(m)}for(const m of c)p.append(r.renderNode(m));l.append(p)}const u=o("div",{class:"rui-app-shell-content"});for(const p of k(e.content))u.append(r.renderNode(p));return l.append(u),n.append(l),n}},ll={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=ee(d(e.primaryWidth),"320px"),i=o("div",{class:"rui-split-view",style:`--rui-split-primary:${a}`}),n=o("div",{class:"rui-split-view-primary"});for(const l of k(e.primary))n.append(r.renderNode(l));const s=o("div",{class:"rui-split-view-detail"});for(const l of k(e.detail))s.append(r.renderNode(l));return i.append(n,s),i}},cl={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=o("div",{class:"rui-description-item"}),i=o("dt",{class:"rui-description-label"}),n=L(e.icon,{className:"rui-description-icon"});n&&i.append(n),i.append(document.createTextNode(d(e.label)));const s=o("dd",{class:"rui-description-value"});return e.value&&typeof e.value=="object"&&e.value.__kind==="Component"?s.append(r.renderNode(e.value)):s.append(document.createTextNode(d(e.value))),a.append(i,s),a}},ul={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)))),i=o("dl",{class:"rui-description-list","data-columns":String(a)});for(const n of k(e.items))i.append(r.renderNode(n));return i}},dl={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=o("span",{class:"rui-status-dot","data-tone":d(e.tone,"success"),"data-pulse":C(e.pulse)?"true":"false"});return r.append(o("span",{class:"rui-status-dot-marker"})),r.append(o("span",{class:"rui-status-dot-label"},[d(e.label)])),r}},pl={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=C(e.featured),i=o("article",{class:"rui-pricing-card","data-featured":a?"true":"false"}),n=d(e.badge);n&&i.append(o("div",{class:"rui-pricing-card-badge"},[n])),i.append(o("h3",{class:"rui-pricing-card-plan"},[d(e.plan)]));const s=d(e.description);s&&i.append(o("p",{class:"rui-pricing-card-description"},[s]));const l=o("div",{class:"rui-pricing-card-price-row"});l.append(o("span",{class:"rui-pricing-card-price"},[d(e.price)]));const c=d(e.period);c&&l.append(o("span",{class:"rui-pricing-card-period"},[c])),i.append(l);const u=k(e.features);if(u.length>0){const p=o("ul",{class:"rui-pricing-card-features"});for(const m of u){const g=d(m);if(!g)continue;const f=L("circle-check",{className:"rui-pricing-card-check"})??o("span",{class:"rui-pricing-card-check"});p.append(o("li",{class:"rui-pricing-card-feature"},[f,document.createTextNode(g)]))}i.append(p)}if(e.action){const p=o("div",{class:"rui-pricing-card-action"});p.append(r.renderNode(e.action)),i.append(p)}return i}},ml={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")))),i=o("div",{class:"rui-pricing-table","data-columns":a>0?String(a):null});for(const n of k(e.tiers))i.append(r.renderNode(n));return i}},gl={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=d(e.orientation,"vertical"),i=o("article",{class:"rui-media-card","data-orientation":a}),n=fl(d(e.ratio,a==="horizontal"?"4:3":"16:9")),s=o("div",{class:"rui-media-card-media",style:`aspect-ratio:${n};`}),l=re(e.imageSrc);if(l)s.append(o("img",{src:l,alt:d(e.title),loading:"lazy"}));else{s.classList.add("rui-media-card-media-empty");const f=L("image",{className:"rui-media-card-placeholder"})??o("span",{class:"rui-media-card-placeholder"});s.append(f)}if(e.badge){const f=o("span",{class:"rui-media-card-badge"});typeof e.badge=="string"?f.append(document.createTextNode(d(e.badge))):f.append(r.renderNode(e.badge)),s.append(f)}i.append(s);const c=o("div",{class:"rui-media-card-body"});c.append(o("h3",{class:"rui-media-card-title"},[d(e.title)]));const u=d(e.description);u&&c.append(o("p",{class:"rui-media-card-description"},[u]));const p=k(e.tags);if(p.length>0){const f=o("div",{class:"rui-media-card-tags"});for(const h of p){const b=d(h);b&&f.append(o("span",{class:"rui-tag","data-size":"sm"},[o("span",{class:"rui-tag-label"},[b])]))}c.append(f)}const m=d(e.meta);m&&c.append(o("p",{class:"rui-media-card-meta"},[m]));const g=Te(e.actions,r);return g&&(g.classList.add("rui-media-card-actions"),c.append(g)),i.append(c),i}};function fl(t){if(t.includes(":")){const[r,a]=t.split(":"),i=Number(r),n=Number(a);if(Number.isFinite(i)&&Number.isFinite(n)&&n>0)return`${i} / ${n}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}function jt(t,e="primary"){const i="http://www.w3.org/2000/svg",n=document.createElementNS(i,"svg");if(n.setAttribute("class","rui-sparkline"),n.setAttribute("data-tone",e),n.setAttribute("viewBox","0 0 80 24"),n.setAttribute("width",String(80)),n.setAttribute("height",String(24)),n.setAttribute("aria-hidden","true"),t.length<2)return n;const s=Math.min(...t),l=Math.max(...t),c=l-s||1,u=80/(t.length-1),m=t.map((b,v)=>{const y=v*u,x=2+(l-b)/c*20;return[y,x]}).map(([b,v],y)=>`${y===0?"M":"L"}${b.toFixed(1)},${v.toFixed(1)}`).join(" "),g=`${m} L80,24 L0,24 Z`,f=document.createElementNS(i,"path");f.setAttribute("d",g),f.setAttribute("class","rui-sparkline-area"),n.appendChild(f);const h=document.createElementNS(i,"path");return h.setAttribute("d",m),h.setAttribute("class","rui-sparkline-line"),h.setAttribute("fill","none"),n.appendChild(h),n}const hl={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=k(e.items),i=a.some(c=>c&&typeof c=="object"&&c.__kind==="Component");if(d(e.layout,i?"grid":"strip")==="grid"){const c=e.columns?Math.max(1,Math.min(6,Math.floor(P(e.columns)))):0,u=ga.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 s=d(e.align,"start"),l=o("div",{class:"rui-stats","data-align":s});for(const c of a){const u=c??{},p=d(u.tone,"default"),m=o("div",{class:"rui-stats-item","data-tone":p});m.append(o("div",{class:"rui-stats-label"},[d(u.label)]));const g=o("div",{class:"rui-stats-value-row"});g.append(o("div",{class:"rui-stats-value"},[d(u.value)]));const f=k(u.spark).map(b=>Number(b)).filter(b=>Number.isFinite(b));f.length>1&&g.append(jt(f,p)),m.append(g);const h=d(u.hint);h&&m.append(o("div",{class:"rui-stats-hint"},[h])),l.append(m)}return l}},bl={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:ve},{name:"action",type:"callable",optional:!0,aliases:["onClick","onclick"]}],render:(t,e,r)=>{const a=typeof e.action=="function",n=o(a?"button":"div",{type:a?"button":null,class:"rui-tile","data-tone":d(e.tone,"default")}),s=L(e.icon,{className:"rui-tile-icon"});s&&n.append(s);const l=o("div",{class:"rui-tile-body"});l.append(o("div",{class:"rui-tile-label"},[d(e.label)]));const c=d(e.value);c&&l.append(o("div",{class:"rui-tile-value"},[c]));const u=d(e.description);return u&&l.append(o("div",{class:"rui-tile-description"},[u])),n.append(l),a&&(n.onclick=()=>r.invoke(e.action)),n}},Sa={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:ve},{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=o("article",{class:"rui-notification","data-tone":d(e.tone,"default"),"data-unread":C(e.unread)?"true":"false"}),i=d(e.avatarSrc);if(i)a.append(Ve(i,d(e.title),"md"));else{const p=L(d(e.icon,"bell"),{className:"rui-notification-icon"});p&&a.append(p)}const n=o("div",{class:"rui-notification-body"}),s=o("header",{class:"rui-notification-head"});s.append(o("span",{class:"rui-notification-title"},[d(e.title)]));const l=d(e.time);l&&s.append(o("span",{class:"rui-notification-time"},[l])),n.append(s);const c=d(e.message);c&&n.append(o("p",{class:"rui-notification-message"},[c]));const u=Te(e.actions,r);return u&&(u.classList.add("rui-notification-actions"),n.append(u)),a.append(n),a}},vl={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:"action",type:"callable",optional:!0,aliases:["onClick","onclick"]}],render:(t,e,r)=>{const a=typeof e.action=="function",i=a?"button":"div",n=d(e.size,"md"),s=n==="lg"?"lg":n==="sm"?"sm":"md",l=o(i,{type:a?"button":null,class:"rui-person-chip","data-size":n}),c=o("span",{class:"rui-person-chip-avatar"});c.append(Ve(d(e.avatarSrc),d(e.name),s));const u=d(e.status);u&&c.append(o("span",{class:"rui-person-chip-status","data-status":u})),l.append(c);const p=o("div",{class:"rui-person-chip-meta"});p.append(o("span",{class:"rui-person-chip-name"},[d(e.name)]));const m=d(e.role);return m&&p.append(o("span",{class:"rui-person-chip-role"},[m])),l.append(p),a&&(l.onclick=()=>r.invoke(e.action)),l}},Ca=["left","center","right"],yl={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`). `sortable` and `filterable` only take effect inside `DataGrid` (Table ignores them).",props:[{name:"header",type:"string"},{name:"values",type:"any[]",description:"Column values (use array pluck like data.rows.title)"},{name:"format",type:"string",optional:!0,enum:["text","number","currency","date"]},{name:"align",type:"string",optional:!0,enum:Ca,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"}],render:(t,e)=>{const r=o("div",{class:"rui-col"});return r.append(o("strong",{},[d(e.header)])),r}},xl={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=k(e.columns),i=d(e.density,"comfortable"),n=C(e.striped),s=C(e.sticky),l=o("div",{class:"rui-table-wrapper","data-density":i,"data-striped":n?"true":"false","data-sticky":s?"true":"false"}),c=o("table",{class:"rui-table"}),u=d(e.caption);u&&c.append(o("caption",{class:"rui-table-caption"},[u]));const p=a.map(y=>{const x=d(y.args?.[3],"");return Ca.includes(x)?x:""}),m=o("thead"),g=o("tr");for(let y=0;y<a.length;y+=1){const x=a[y],w=o("th",{"data-align":p[y]||null},[d(x.args?.[0])]);g.append(w)}m.append(g),c.append(m);const f=o("tbody"),h=a.map(y=>k(y.args?.[1])),b=a.map(y=>d(y.args?.[2],"text")),v=Math.max(0,...h.map(y=>y.length));for(let y=0;y<v;y+=1){const x=o("tr");h.forEach((w,T)=>{const S=w[y],N=b[T]??"text",$=p[T],A=o("td",{"data-format":N,"data-align":$||null});S!==null&&typeof S=="object"&&S.__kind==="Component"?A.append(r.renderNode(S)):A.textContent=Al(S,N),x.append(A)}),f.append(x)}if(v===0){const y=o("tr"),x=d(e.emptyLabel,"No data");y.append(o("td",{colspan:String(a.length||1),class:"rui-table-empty"},[x])),f.append(y)}return c.append(f),l.append(c),l}},wl={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=o("li",{class:"rui-list-item"}),a=L(e.icon,{className:"rui-list-icon"});a&&r.append(a);const i=o("div",{class:"rui-list-text"});i.append(o("div",{class:"rui-list-title"},[d(e.title)]));const n=d(e.description);return n&&i.append(o("div",{class:"rui-list-description"},[n])),r.append(i),r}},kl={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=C(e.ordered)?"ol":"ul",i=o(a,{class:"rui-list"});for(const n of k(e.items))i.append(r.renderNode(n));return i}},Sl={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=d(e.tone,"default"),a=o("div",{class:"rui-stat-card","data-tone":r}),i=o("div",{class:"rui-stat-label-row"}),n=d(e.label),s=d(e.icon)||ya(n)||"",l=L(s,{className:"rui-stat-icon"});l&&i.append(l),i.append(o("div",{class:"rui-stat-label"},[n])),a.append(i),a.append(o("div",{class:"rui-stat-value"},[d(e.value)]));const c=d(e.delta),u=d(e.trend);(c||u)&&a.append(o("div",{class:"rui-stat-trend","data-trend":u||"flat"},[c||Nl(u)]));const p=k(e.spark).map(m=>P(m));if(p.length>1){const m=o("div",{class:"rui-stat-spark"});m.append(jt(p,r==="default"?"primary":r)),a.append(m)}return a}},Cl={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=d(e.tone,"primary"),a=k(e.values).map(n=>P(n)),i=o("span",{class:"rui-sparkline-wrap"});return i.append(jt(a,r)),i}},Tl={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. `action` 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:"action",type:"callable",optional:!0,aliases:["onClick","onclick"],description:"Callable fired when the row is clicked"}],render:(t,e,r)=>{const a=k(e.children),i=a.length>0,n=C(e.expanded),s=C(e.active),l=typeof e.action=="function",c=o(l?"button":"div",{type:l?"button":null,class:"rui-tree-node-row",role:"treeitem","data-active":s?"true":"false","aria-expanded":i?n?"true":"false":null});if(i){const h=L("chevron-right",{className:"rui-tree-node-chevron"});h&&c.append(h)}else c.append(o("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const u=L(e.icon,{className:"rui-tree-node-icon"});u&&c.append(u),c.append(o("span",{class:"rui-tree-node-label"},[d(e.label)]));const p=d(e.badge);if(p&&c.append(o("span",{class:"rui-tree-node-badge"},[p])),l&&(c.onclick=()=>r.invoke(e.action)),!i)return c;const m=o("details",{class:"rui-tree-node"});n&&m.setAttribute("open","");const g=o("summary",{class:"rui-tree-node-summary"});g.append(c),l&&(g.onclick=h=>{h.target?.closest(".rui-tree-node-chevron")||h.preventDefault()}),m.append(g);const f=o("div",{class:"rui-tree-node-children",role:"group"});for(const h of a)f.append(r.renderNode(h));return m.append(f),m}},$l={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=o("div",{class:"rui-tree",role:"tree"});for(const i of k(e.items))a.append(r.renderNode(i));return a}};function Nl(t){return t==="up"?"▲":t==="down"?"▼":"—"}function Al(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():d(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):d(t);case"date":try{const r=new Date(d(t));return Number.isNaN(r.getTime())?d(t):r.toLocaleDateString()}catch{return d(t)}default:return d(t)}}const Bt=["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)"],_e=t=>Bt[t%Bt.length]??Bt[0],Ml={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)=>o("span",{class:"rui-series","data-name":d(e.name)})},Ta=t=>t.map((e,r)=>{const a=e,i=d(a.args?.[0],`Series ${r+1}`),n=k(a.args?.[1]).map(s=>P(s));return{name:i,values:n}}),Pl={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=k(e.labels).map(y=>d(y)),a=Ta(k(e.series)),i=o("div",{class:"rui-chart rui-bar-chart"});d(e.title)&&i.append(o("div",{class:"rui-chart-title"},[d(e.title)]));const n=Math.max(1,...a.flatMap(y=>y.values)),s=640,l=240,c=Na(r,s-40-12),u={left:40,right:12,top:12,bottom:c.bottomPadding},p=s-u.left-u.right,m=l-u.top-u.bottom,g=Dt(s,l);Ma(g,u,p,m,n);const f=r.length,h=p/Math.max(f,1),b=a.length,v=h*.7/Math.max(b,1);return a.forEach((y,x)=>{y.values.forEach((w,T)=>{const S=w/n*m,N=u.left+T*h+h*.15+x*v,$=u.top+m-S,A=me("rect",{x:String(N),y:String($),width:String(Math.max(v-2,1)),height:String(S),fill:_e(x),rx:"2"});A.append(me("title",{},[`${y.name}: ${w}`])),g.append(A)})}),Aa(g,r,u,p,m,c,y=>u.left+(y+.5)*h),i.append(g),a.length>0&&i.append(Ft(a)),i}},Il={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=k(e.labels).map($=>d($)),a=Ta(k(e.series));const i=k(e.data);if(i.length>0&&(r.length===0||a.length===0)){const $=[],A=new Map;for(const z of i){const R=z;if(!(!R||typeof R!="object")){$.push(d(R.x??R.label??""));for(const[_,Q]of Object.entries(R)){if(_==="x"||_==="label")continue;const B=P(Q);Number.isNaN(B)||(A.has(_)||A.set(_,[]),A.get(_).push(B))}}}r.length===0&&(r=$),a.length===0&&(a=[...A.entries()].map(([z,R])=>({name:z,values:R})))}const n=e.filled===!0,s=e.stacked===!0,l=Math.max(r.length,...a.map($=>$.values.length),1),c=a.map(()=>Array(l).fill(0));if(n&&s)for(let $=0;$<l;$+=1){let A=0;a.forEach((z,R)=>{A+=z.values[$]??0,c[R][$]=A})}const u=o("div",{class:"rui-chart rui-line-chart","data-filled":n?"true":"false"});d(e.title)&&u.append(o("div",{class:"rui-chart-title"},[d(e.title)]));const p=n&&s?c.flat():a.flatMap($=>$.values),m=Math.max(1,...p),g=n&&s?0:Math.min(0,...p),f=640,h=240,b=Na(r,f-40-12),v={left:40,right:12,top:12,bottom:b.bottomPadding},y=f-v.left-v.right,x=h-v.top-v.bottom,w=Dt(f,h);Ma(w,v,y,x,m,g);const T=Math.max(r.length-1,1),S=y/T,N=$=>v.left+$*(y/Math.max(l-1,1));return a.forEach(($,A)=>{const z=n&&s?c[A]:$.values,R=n&&s&&A>0?c[A-1]:null,_=z.map((B,O)=>{const J=N(O),X=v.top+x-(B-g)/(m-g||1)*x;return[J,X]});if(n&&_.length>0){let B=_.map(([O,J],X)=>`${X===0?"M":"L"}${O.toFixed(1)},${J.toFixed(1)}`).join(" ");if(R){const O=R.map((J,X)=>{const de=N(X),ge=v.top+x-(J-g)/(m-g||1)*x;return[de,ge]});B+=" "+O.slice().reverse().map(([J,X])=>`L${J.toFixed(1)},${X.toFixed(1)}`).join(" ")+" Z"}else{const O=_[0],J=_[_.length-1];B+=` L${J[0].toFixed(1)},${(v.top+x).toFixed(1)} L${O[0].toFixed(1)},${(v.top+x).toFixed(1)} Z`}w.append(me("path",{d:B,fill:_e(A),"fill-opacity":"0.2",stroke:"none"}))}const Q=_.map(([B,O],J)=>`${J===0?"M":"L"}${B.toFixed(1)},${O.toFixed(1)}`).join(" ");w.append(me("path",{d:Q,fill:"none",stroke:_e(A),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),$.values.length<=30&&_.forEach(([B,O])=>{w.append(me("circle",{cx:String(B),cy:String(O),r:"3",fill:_e(A)}))})}),Aa(w,r,v,y,x,b,$=>v.left+$*S),u.append(w),a.length>0&&u.append(Ft(a)),u}},zl={name:"PieChart",description:"Pie/Donut chart. Each segment maps to a label/value pair.",props:[{name:"labels",type:"string[]"},{name:"values",type:"number[]"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=k(e.labels).map(m=>d(m)),a=k(e.values).map(m=>P(m)),i=o("div",{class:"rui-chart rui-pie-chart"});d(e.title)&&i.append(o("div",{class:"rui-chart-title"},[d(e.title)]));const n=a.reduce((m,g)=>m+g,0)||1,s=Dt(240,240),l=120,c=120,u=90;let p=-Math.PI/2;return a.forEach((m,g)=>{const f=m/n*Math.PI*2,h=p+f,b=f>Math.PI?1:0,v=l+u*Math.cos(p),y=c+u*Math.sin(p),x=l+u*Math.cos(h),w=c+u*Math.sin(h),T=`M${l},${c} L${v},${y} A${u},${u} 0 ${b} 1 ${x},${w} Z`,S=me("path",{d:T,fill:_e(g),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});S.append(me("title",{},[`${r[g]??""}: ${m}`])),s.append(S),p=h}),i.append(s),i.append(Ft(r.map((m,g)=>({name:m,values:[a[g]??0]})))),i}},Rl=7,$a=12;function Na(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((s,l)=>Math.max(s,l.length),0);if(a*Rl+4<=r)return{step:1,rotated:!1,maxChars:a,bottomPadding:32};const i=r<$a?Math.max(1,Math.ceil($a/r)):1,n=Math.min(a,14);return{step:i,rotated:!0,maxChars:n,bottomPadding:60}}function Ll(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function Aa(t,e,r,a,i,n,s){const l=r.top+i+(n.rotated?14:18);e.forEach((c,u)=>{if(u%n.step!==0)return;const p=s(u),m=Ll(c,n.maxChars),g={x:String(p),y:String(l),class:"rui-chart-label","text-anchor":n.rotated?"end":"middle"};n.rotated&&(g.transform=`rotate(-45, ${p}, ${l})`);const f=me("text",g,[m]);m!==c&&f.append(me("title",{},[c])),t.append(f)})}function Dt(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 me(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[i,n]of Object.entries(e))a.setAttribute(i,n);if(r)for(const i of r)a.append(typeof i=="string"?document.createTextNode(i):i);return a}function Ma(t,e,r,a,i,n=0){for(let l=0;l<=4;l+=1){const c=l/4,u=e.top+a-c*a;t.append(me("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(me("text",{x:String(e.left-6),y:String(u+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((n+(i-n)*c)*10)/10)]))}}function Ft(t){const e=o("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const i=o("span",{class:"rui-chart-legend-item"});i.append(o("span",{class:"rui-chart-legend-swatch",style:`background:${_e(a)}`})),i.append(o("span",{},[r.name])),e.append(i)}),e}const El={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=o("section",{class:"rui-section-block"});a.append(o("h3",{class:"rui-section-block-title"},[d(e.title)]));const i=d(e.description);i&&a.append(o("p",{class:"rui-section-block-description"},[i]));for(const n of k(e.children))a.append(r.renderNode(n));return a}},_l={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=C(e.ordered)?"ol":"ul",a=o(r,{class:"rui-list-block"});for(const i of k(e.items))a.append(o("li",{},[d(i)]));return a}},jl={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=o("div",{class:"rui-follow-up"}),i=d(e.title,"You can also ask");i&&a.append(o("div",{class:"rui-follow-up-title"},[i]));const n=o("div",{class:"rui-follow-up-list"});for(const s of k(e.items))n.append(Bl(s,r));return a.append(n),a}},Bl=(t,e)=>{const{label:r,message:a}=Dl(t),i=o("button",{class:"rui-follow-up-button",type:"button"},[r]);return i.onclick=()=>{e.sendToAssistant(a)},i},Dl=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 n=d(r.args[0]),s=d(r.args[1],n);return{label:n,message:s}}const a=d(r.label),i=d(r.message,a);return{label:a,message:i}}const e=d(t);return{label:e,message:e}},Fl={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=d(e.label),i=d(e.message,a),n=o("button",{class:"rui-follow-up-button",type:"button"},[a]);return n.onclick=()=>{r.sendToAssistant(i)},n}},Ol={name:"ActionLink",description:"Inline link that runs an Action when clicked instead of navigating.",props:[{name:"label",type:"string"},{name:"action",type:"callable",aliases:["onClick","onclick"]}],render:(t,e,r)=>{const a=o("a",{class:"rui-action-link",href:"#",role:"button"},[d(e.label)]);return a.onclick=i=>{i.preventDefault(),r.invoke(e.action)},a}},Pa=["sm","md","lg","xl"],Ia={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:Pa},{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=d(e.size,"md"),a=o("span",{class:"rui-avatar","data-size":r,role:"img"}),i=d(e.name),n=d(e.fallback,"dicebear"),s=re(e.src),l=!s&&n==="dicebear"&&i?re(gs(i)):"",c=s||l;if(c){const p=o("img",{src:c,alt:i,loading:"lazy"});p.onerror=m=>{const g=m;(g.currentTarget??g.target).replaceWith(o("span",{class:"rui-avatar-fallback"},[We(i)]))},a.append(p)}else a.append(o("span",{class:"rui-avatar-fallback"},[We(i)]));const u=d(e.status);return u&&a.append(o("span",{class:"rui-avatar-status","data-status":u})),a}},Ul={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:Pa}],render:(t,e,r)=>{const a=k(e.items),i=Math.max(1,Math.floor(Number(e.max??4))),n=d(e.size,"md"),s=a.slice(0,i),l=a.length-s.length,c=o("div",{class:"rui-avatar-group","data-size":n});for(const u of s){if(u&&typeof u=="object"&&u.__kind==="Component"){c.append(r.renderNode(u));continue}const p=u,m=typeof p=="string"?p:d((p??{}).name),g=typeof p=="string"?"":d((p??{}).src);c.append(Ia.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:m,src:g,size:n},r))}return l>0&&c.append(o("span",{class:"rui-avatar rui-avatar-overflow","data-size":n},[o("span",{class:"rui-avatar-fallback"},[`+${l}`])])),c}},ql={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,P(e.max,100)),a=C(e.indeterminate),i=Math.max(0,Math.min(r,P(e.value,0))),n=Math.round(i/r*100),s=Math.max(0,Math.floor(P(e.segments,0))),l=e.buffered!=null?Math.max(0,Math.min(r,P(e.buffered,0))):null,c=o("div",{class:"rui-progress","data-tone":d(e.tone,"primary")}),u=d(e.label),p=C(e.showValue);if(u||p){const g=o("div",{class:"rui-progress-head"});if(g.append(o("span",{class:"rui-progress-label"},[u])),p&&!a){const f=s>0?`${Math.min(s,Math.round(i/r*s))} / ${s}`:`${n}%`;g.append(o("span",{class:"rui-progress-value"},[f]))}c.append(g)}if(s>0&&!a){const g=o("div",{class:"rui-progress-segments",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(s),"aria-valuenow":String(Math.min(s,Math.round(i/r*s)))}),f=Math.min(s,Math.round(i/r*s));for(let h=0;h<s;h+=1)g.append(o("span",{class:"rui-progress-segment","data-filled":h<f?"true":"false"}));return c.append(g),c}const m=o("div",{class:"rui-progress-track",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(r),"aria-valuenow":a?null:String(i),"data-indeterminate":a?"true":"false"});if(l!==null){const g=Math.round(l/r*100);m.append(o("div",{class:"rui-progress-buffer",style:`width:${g}%`,"aria-hidden":"true"}))}return m.append(o("div",{class:"rui-progress-bar",style:a?"":`width:${n}%`})),c.append(m),c}},Hl={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.",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}],render:(t,e,r)=>{const a=d(e.id),i=o("label",{class:"rui-switch",for:a,"data-disabled":C(e.disabled)?"true":"false"}),n=C(e.value),s=o("input",{type:"checkbox",id:a,name:a,class:"rui-switch-input",role:"switch",checked:n?"":null,disabled:C(e.disabled)?"":null});s.checked=n;const l=o("span",{class:"rui-switch-track"},[o("span",{class:"rui-switch-thumb"})]),c=t.argMeta?.[2]?.stateRef;c&&r.bindState(s,c,{event:"change",getValue:m=>m.checked});const u=d(e.label),p=d(e.description);if(i.append(s,l),u||p){const m=o("span",{class:"rui-switch-meta"});u&&m.append(o("span",{class:"rui-switch-label"},[u])),p&&m.append(o("span",{class:"rui-switch-description"},[p])),i.append(m)}return i}},Vl={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.",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"]}],render:(t,e,r)=>{const a=d(e.value),i=d(e.variant,"outline"),n=d(e.size,"md"),s=o("div",{class:"rui-toggle-group",role:"radiogroup","data-variant":i,"data-size":n}),l=t.argMeta?.[2]?.stateRef;for(const c of k(e.items)){const{value:u,label:p,icon:m}=Wl(c),g=u===a,f=o("button",{type:"button",class:"rui-toggle",role:"radio","aria-checked":g?"true":"false","data-variant":i,"data-size":n,"data-state":g?"on":"off","data-value":u}),h=L(m,{className:"rui-toggle-icon"});h&&f.append(h),f.append(o("span",{class:"rui-toggle-label"},[p])),l&&(f.onclick=()=>{r.setState(l,u)}),s.append(f)}return s}};function Wl(t){if(typeof t=="string")return{value:t,label:t,icon:""};if(Array.isArray(t))return{value:d(t[0]),label:d(t[1],d(t[0])),icon:d(t[2])};if(t&&typeof t=="object"){const e=t,r=d(e.value);return{value:r,label:d(e.label,r),icon:d(e.icon)}}return{value:"",label:"",icon:""}}const Gl={name:"Tooltip",description:"Wraps a trigger node and shows `label` text when the user hovers or focuses it. Pure CSS — no JS needed. 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=o("span",{class:"rui-tooltip","data-side":d(e.side,"top"),tabindex:"0"});return a.append(o("span",{class:"rui-tooltip-trigger"},[r.renderNode(e.trigger)])),a.append(o("span",{class:"rui-tooltip-content",role:"tooltip"},[d(e.label)])),a}},Kl={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=o("span",{class:"rui-hover-card","data-side":d(e.side,"bottom"),"data-open":C(e.open)?"true":null,tabindex:"0"});a.append(o("span",{class:"rui-hover-card-trigger"},[r.renderNode(e.trigger)]));const i=o("span",{class:"rui-hover-card-content",role:"dialog"});for(const n of k(e.content))i.append(r.renderNode(n));return a.append(i),a}},Ot={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"}},Yl={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` and a `$variable` as `value` to let users rate something; 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"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(P(e.max,5))),i=Math.max(0,Math.min(a,P(e.value,0))),n=d(e.size,"md"),s=C(e.interactive)&&!C(e.readonly),l=C(e.halfStep),c=t.argMeta?.[0]?.stateRef,u=Jl(d(e.icon)),p=o("div",{class:"rui-rating","data-size":n,"data-interactive":s&&c?"true":"false","data-half-step":s&&c&&l?"true":"false",role:"img","aria-label":`${i} of ${a}`}),m=o("span",{class:"rui-rating-stars"});for(let h=1;h<=a;h+=1){const b=Math.max(0,Math.min(1,i-(h-1))),v=b>=1?u.full:b>0?u.half:u.empty,y=Lt(v).join(" "),x=o(s&&c?"button":"span",{class:`rui-rating-star ${y}`.trim(),type:s&&c?"button":null,"data-fill":b>=1?"full":b>0?"half":"empty","aria-label":s&&c?`Rate ${h}`:null,"aria-hidden":s&&c?null:"true"});if(s&&c){const w=h,T=h-.5;x.onclick=S=>{let N=w;if(l){const $=S,z=($.currentTarget??$.target).getBoundingClientRect();z.width>0&&$.clientX-z.left<z.width/2&&(N=T)}r.setState(c,N)}}m.append(x)}p.append(m);const g=d(e.label);g&&p.append(o("span",{class:"rui-rating-label"},[g]));const f=e.count!=null?P(e.count,0):null;return f!==null&&f>0&&p.append(o("span",{class:"rui-rating-count"},[`(${f.toLocaleString()})`])),p}};function Jl(t){const e=t.trim().toLowerCase();return e?Ot[e]?Ot[e]:{full:e,half:e,empty:`regular:${e}`}:Ot.star}const Xl={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,P(e.max,100)),a=C(e.indeterminate),i=Math.max(0,Math.min(r,P(e.value,0))),n=Math.round(i/r*100),s=d(e.size,"md"),l=s==="lg"?120:s==="sm"?72:96,c=s==="lg"?10:s==="sm"?6:8,u=(l-c)/2,p=2*Math.PI*u,m=a?p*.65:p*(1-n/100),g=o("div",{class:"rui-progress-ring","data-tone":d(e.tone,"primary"),"data-size":s,"data-indeterminate":a?"true":"false"}),f=o("div",{class:"rui-progress-ring-wrap"}),h="http://www.w3.org/2000/svg",b=document.createElementNS(h,"svg");b.setAttribute("width",String(l)),b.setAttribute("height",String(l)),b.setAttribute("viewBox",`0 0 ${l} ${l}`),b.setAttribute("class","rui-progress-ring-svg");const v=document.createElementNS(h,"circle");v.setAttribute("class","rui-progress-ring-track"),v.setAttribute("cx",String(l/2)),v.setAttribute("cy",String(l/2)),v.setAttribute("r",String(u)),v.setAttribute("stroke-width",String(c)),v.setAttribute("fill","none"),b.appendChild(v);const y=document.createElementNS(h,"circle");y.setAttribute("class","rui-progress-ring-bar"),y.setAttribute("cx",String(l/2)),y.setAttribute("cy",String(l/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(m)),b.appendChild(y),f.append(b);const x=d(e.label,a?"…":`${n}%`),w=o("span",{class:"rui-progress-ring-value"}),T=L(x,{className:"rui-progress-ring-icon"});T&&Lt(x).length>0?w.append(T):w.append(document.createTextNode(x)),f.append(w),g.append(f);const S=d(e.caption);return S&&g.append(o("span",{class:"rui-progress-ring-caption"},[S])),g}},Zl={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=d(e.from,"agent"),a=o("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&a.append(za(d(e.avatarSrc),d(e.author)));const i=o("div",{class:"rui-chat-bubble-bubble"}),n=o("header",{class:"rui-chat-bubble-head"});n.append(o("span",{class:"rui-chat-bubble-author"},[d(e.author)]));const s=d(e.time);s&&n.append(o("span",{class:"rui-chat-bubble-time"},[s])),i.append(n),i.append(o("p",{class:"rui-chat-bubble-body"},[d(e.body)]));const l=d(e.status);return l&&i.append(o("span",{class:"rui-chat-bubble-status","data-status":l},[l])),a.append(i),r==="me"&&a.append(za(d(e.avatarSrc),d(e.author))),a}};function za(t,e){const r=o("span",{class:"rui-chat-bubble-avatar"}),a=re(t);return a?r.append(o("img",{src:a,alt:e,loading:"lazy"})):r.append(o("span",{class:"rui-chat-bubble-fallback"},[We(e)])),r}const Ql={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=d(e.size,"md"),a=o("span",{class:"rui-kbd-group","data-size":r});return(Array.isArray(e.keys)?e.keys:[e.keys]).forEach((n,s)=>{const l=d(n);l&&(s>0&&a.append(o("span",{class:"rui-kbd-sep"},["+"])),a.append(o("kbd",{class:"rui-kbd"},[l])))}),a}},ec={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=C(e.open),i=r.useInstanceState("open",a),n=i.get(),s=ee(e.width,""),l=o("div",{class:"rui-popover","data-open":n?"true":"false","data-side":d(e.side,"bottom"),"data-align":d(e.align,"start")}),c=o("span",{class:"rui-popover-trigger","data-state":n?"open":"closed","aria-haspopup":"dialog","aria-expanded":n?"true":"false"});c.append(r.renderNode(e.trigger)),l.append(c);const u=o("div",{class:"rui-popover-content",role:"dialog",style:s?`width: ${s};`:null}),p=o("div",{class:"rui-popover-header"}),m=d(e.title);p.append(m?o("div",{class:"rui-popover-title"},[m]):o("span",{class:"rui-popover-title-spacer"}));const g=o("button",{type:"button",class:"rui-popover-close","aria-label":"Close popover"},["×"]);g.onclick=f=>{f.stopPropagation(),st(g,!1,i)},p.append(g),u.append(p);for(const f of k(e.content))u.append(r.renderNode(f));return l.append(u),c.onclick=f=>{f.stopPropagation();const h=f.currentTarget??f.target,b=!i.get(),v=st(h,b,i);b&&v&&Ra(v,i)},c.onkeydown=f=>{const h=f,b=h.currentTarget??h.target;if(h.key==="Enter"||h.key===" "){h.preventDefault();const v=!i.get(),y=st(b,v,i);v&&y&&Ra(y,i)}else h.key==="Escape"&&i.get()&&(h.preventDefault(),st(b,!1,i))},l}},st=(t,e,r)=>{r.set(e);const a=t.closest(".rui-popover");if(!a)return null;a.setAttribute("data-open",e?"true":"false");const i=a.querySelector(".rui-popover-trigger");return i?.setAttribute("aria-expanded",e?"true":"false"),i?.setAttribute("data-state",e?"open":"closed"),e||he(a),a},Ra=(t,e)=>{Ee({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")}})},tc={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 action Button(...) 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=d(e.tone,"default"),i=d(e.position),n=o("div",{class:i?"rui-toast rui-toast-standalone":"rui-toast",role:"status","aria-live":a==="danger"?"assertive":"polite","data-tone":a,"data-position":i||null}),s=d(e.icon)||rc(a),l=L(s,{className:"rui-toast-icon"});l&&n.append(l);const c=o("div",{class:"rui-toast-body"});c.append(o("div",{class:"rui-toast-title"},[d(e.title)]));const u=d(e.message);if(u&&c.append(o("div",{class:"rui-toast-message"},[u])),e.action){const x=o("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),c.append(x)}n.append(c);const p=r.useInstanceState("dismissed",!1),m=r.useInstanceState("timer",null),g=x=>{if(x){const w=x.closest(".rui-toast");if(w)return w}return n.isConnected?n:null},f=()=>{const x=m.get();x!==null&&(clearTimeout(x),m.set(null))},h=r.useInstanceState("removal-timer",null),b=x=>{if(p.get())return;p.set(!0),f();const w=g(x);if(!w)return;w.classList.add("is-dismissed");const T=setTimeout(()=>{h.set(null),w.remove()},180);h.set(T),r.registerDisposer(()=>{const S=h.get();S!==null&&(clearTimeout(S),h.set(null))},"exit-animation-timer"),r.invoke(e.onClose)},v=o("button",{type:"button",class:"rui-toast-close","aria-label":"Dismiss notification"},["×"]);v.onclick=x=>{x.stopPropagation(),b(x.currentTarget??x.target)},n.append(v);const y=P(e.duration,0);if(y>0&&m.get()===null&&!p.get()){const x=setTimeout(()=>{m.set(null),!p.get()&&n.isConnected&&b()},y);m.set(x),r.registerDisposer(()=>{const w=m.get();w!==null&&(clearTimeout(w),m.set(null))},"auto-dismiss-timer")}return p.get()?o("div",{class:"rui-toast-placeholder",hidden:""}):n}};function rc(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 La={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=o("li",{class:"rui-breadcrumb-item"}),a=d(e.label),i=d(e.href),n=i?rt(i):"",s=[],l=L(e.icon,{className:"rui-breadcrumb-icon"});if(l&&s.push(l),s.push(o("span",{class:"rui-breadcrumb-label"},[a])),n)r.append(o("a",{class:"rui-breadcrumb-link",href:n},s));else{r.setAttribute("aria-current","page");const c=o("span",{class:"rui-breadcrumb-current"});for(const u of s)u&&c.append(typeof u=="string"?document.createTextNode(u):u);r.append(c)}return r}},ac={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=k(e.items),i=d(e.separator,"/"),n=o("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),s=o("ol",{class:"rui-breadcrumb-list"});return a.forEach((l,c)=>{if(c>0&&s.append(o("li",{class:"rui-breadcrumb-separator","aria-hidden":"true"},[i])),l&&typeof l=="object"&&l.__kind==="Component"){s.append(r.renderNode(l));return}const u=d(l),p=c===a.length-1;s.append(La.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:u,href:p?"":"#"},r))}),n.append(s),n}},ic=[10,20,50,100],nc={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(P(e.totalPages,1))),i=Math.max(1,Math.min(a,Math.floor(P(e.page,1)))),n=Math.max(0,Math.floor(P(e.siblings,1))),s=C(e.compact),l=t.argMeta?.[0]?.stateRef,c=o("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":s?"true":"false"}),u=b=>{if(!l)return;const v=Math.max(1,Math.min(a,b));v!==i&&r.setState(l,v)},p=e.total!=null?Math.max(0,Math.floor(P(e.total,0))):null,m=e.perPage!=null?Math.max(1,Math.floor(P(e.perPage,0))):null;if(p!==null&&m&&m>0){const b=p===0?0:(i-1)*m+1,v=Math.min(p,i*m);c.append(o("span",{class:"rui-pagination-summary"},[p===0?"No results":`Showing ${b.toLocaleString()}–${v.toLocaleString()} of ${p.toLocaleString()}`]))}else p!==null&&c.append(o("span",{class:"rui-pagination-summary"},[`${p.toLocaleString()} result${p===1?"":"s"}`]));const g=o("div",{class:"rui-pagination-buttons"}),f=(b,v,y={})=>{if(y.ellipsis)return o("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[b]);const x=o("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},[b]);return!y.disabled&&!y.active&&(x.onclick=()=>u(v)),x};if(g.append(f("‹",i-1,{disabled:i<=1,ariaLabel:"Previous page"})),s)g.append(o("span",{class:"rui-pagination-current"},[`${i} / ${a}`]));else{const b=oc(i,a,n);for(const v of b)v==="…"?g.append(f("…",0,{ellipsis:!0})):g.append(f(String(v),v,{active:v===i}))}g.append(f("›",i+1,{disabled:i>=a,ariaLabel:"Next page"})),c.append(g);const h=t.argMeta?.[4]?.stateRef;if(m&&(h||k(e.perPageOptions).length>0)){const b=k(e.perPageOptions).length>0?k(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(ic),v=o("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),y=o("select",{class:"rui-pagination-per-page-select"});for(const x of b){const w=o("option",{value:String(x),selected:x===m?"":null},[String(x)]);y.append(w)}h&&r.bindState(y,h,{event:"change",getValue:x=>Number(x.value)}),v.append(y),v.append(document.createTextNode(" per page")),c.append(v)}return c}};function oc(t,e,r){const a=[],i=(c,u)=>{for(let p=c;p<=u;p+=1)a.push(p)},n=r*2+5;if(e<=n)return i(1,e),a;const s=Math.max(2,t-r),l=Math.min(e-1,t+r);return a.push(1),s>2&&a.push("…"),i(s,l),l<e-1&&a.push("…"),a.push(e),a}const sc={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 `action` 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:"action",type:"callable",optional:!0,aliases:["onClick","onclick"],description:"Callable fired on click (alternative to `to`/`href`)"},{name:"external",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=d(e.label),i=e.icon,n=C(e.active),s=d(e.to),l=rt(e.href,""),c=C(e.external),u=s||l?"a":"button",p=o(u,{class:"rui-navbar-item",type:u==="button"?"button":null,href:l||(s?`#${s.startsWith("/")?s:`/${s}`}`:null),target:c&&l?"_blank":null,rel:c&&l?"noopener noreferrer":null,"data-active":n?"true":"false"}),m=L(i,{className:"rui-navbar-item-icon"});return m&&p.append(m),p.append(o("span",{class:"rui-navbar-item-label"},[a])),s&&!l?p.onclick=g=>{if(g.defaultPrevented)return;const f=g;f.button!==0||f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(g.preventDefault(),r.router.navigate(s))}:typeof e.action=="function"&&(p.onclick=g=>{g.preventDefault(),r.invoke(e.action)}),p}},lc={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=o("nav",{class:"rui-navbar","data-sticky":C(e.sticky)?"true":"false","data-variant":d(e.variant,"default"),"aria-label":"Primary"}),i=e.brand;if(i!=null&&i!==""){const l=o("div",{class:"rui-navbar-brand"});typeof i=="string"?l.append(document.createTextNode(i)):l.append(r.renderNode(i)),a.append(l)}const n=k(e.items);if(n.length>0){const l=o("div",{class:"rui-navbar-items"});for(const c of n)l.append(r.renderNode(c));a.append(l)}const s=k(e.actions);if(s.length>0){const l=o("div",{class:"rui-navbar-actions"});for(const c of s)l.append(r.renderNode(c));a.append(l)}return a}},cc=["bottom","top","left","right"],uc=["start","center","end"],dc=["default","danger"],lt=(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||he(a),a):null},Ea=(t,e)=>{Ee({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false"),t.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded","false")}})},Ut=(t,e)=>{if(!t||typeof t!="object")return!1;const r=t;return r.__kind==="Component"&&r.name===e},pc={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:cc,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:uc,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=C(e.open),i=r.useInstanceState("open",a),n=i.get(),s=o("div",{class:"rui-dropdown-menu","data-open":n?"true":"false","data-side":d(e.side,"bottom"),"data-align":d(e.align,"start")}),l=o("span",{class:"rui-dropdown-menu-trigger","data-state":n?"open":"closed","aria-haspopup":"menu","aria-expanded":n?"true":"false",tabindex:"0"});l.append(r.renderNode(e.trigger)),l.onclick=u=>{u.stopPropagation();const p=u.currentTarget??u.target,m=!i.get(),g=lt(p,m,i);m&&g&&Ea(g,i)},l.onkeydown=u=>{const p=u,m=p.currentTarget??p.target;if(p.key==="Enter"||p.key===" "){p.preventDefault();const g=!i.get(),f=lt(m,g,i);g&&f&&Ea(f,i);return}p.key==="Escape"&&i.get()&&(p.preventDefault(),lt(m,!1,i))},s.append(l);const c=o("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":d(e.label)||null});for(const u of k(e.items)){if(Ut(u,"MenuItem")){const p=u.args??[],m=d(p[0]),g=p[1],f=p[2],h=d(p[3]),b=d(p[4],"default"),v=C(p[5]),y=o("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":b,disabled:v?"":null}),x=L(f,{className:"rui-menu-item-icon"});x&&y.append(x),y.append(o("span",{class:"rui-menu-item-label"},[m])),h&&y.append(o("span",{class:"rui-menu-item-shortcut"},[h])),v||(y.onclick=w=>{const T=w.currentTarget??w.target;lt(T,!1,i),r.invoke(g)}),c.append(y);continue}if(Ut(u,"MenuSeparator")){c.append(o("div",{class:"rui-menu-separator",role:"separator"}));continue}if(Ut(u,"MenuLabel")){const p=d((u.args??[])[0]);c.append(o("div",{class:"rui-menu-label"},[p]));continue}c.append(r.renderNode(u))}return s.append(c),s}},mc={name:"MenuItem",description:"Single item inside a DropdownMenu. Renders a button-style row with an optional leading icon and trailing keyboard-shortcut hint. The action argument runs when clicked; the menu closes automatically afterwards.",props:[{name:"label",type:"string"},{name:"action",type:"callable",optional:!0,aliases:["onClick","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:dc,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=C(e.disabled),i=o("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":d(e.variant,"default"),disabled:a?"":null}),n=L(e.icon,{className:"rui-menu-item-icon"});n&&i.append(n),i.append(o("span",{class:"rui-menu-item-label"},[d(e.label)]));const s=d(e.shortcut);return s&&i.append(o("span",{class:"rui-menu-item-shortcut"},[s])),a||(i.onclick=()=>{r.invoke(e.action)}),i}},gc={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>o("div",{class:"rui-menu-separator",role:"separator"})},fc={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)=>o("div",{class:"rui-menu-label"},[d(e.label)])},hc=["left","center","right"];function bc(t){return k(t).map((e,r)=>{const a=e.args??[],i=d(a[0]);return{header:i,values:k(a[1]),format:d(a[2],"text"),align:hc.includes(d(a[3]))?d(a[3]):"",sortable:C(a[4]),filterable:C(a[5]),key:i||`col-${r}`}})}function _a(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return P(t,0)-P(e,0);if(r==="date"){const a=new Date(d(t)).getTime(),i=new Date(d(e)).getTime();if(Number.isFinite(a)&&Number.isFinite(i))return a-i}return d(t).localeCompare(d(e))}function ct(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():d(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):d(t);case"date":try{const r=new Date(d(t));return Number.isNaN(r.getTime())?d(t):r.toLocaleDateString()}catch{return d(t)}default:return d(t)}}const vc={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:"rowAction",type:"callable",optional:!0,description:"Callable fired when a row is clicked"},{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=bc(e.columns),i=Math.max(0,...a.map(E=>E.values.length)),n=k(e.rowIds),s=E=>d(n[E]??E),l=e.sort&&typeof e.sort=="object"?e.sort:null,c=d(l?.key),u=d(l?.direction,"asc")==="desc"?"desc":"asc",p=k(e.selectedIds).map(E=>d(E)),m=new Set(p),g=C(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,f=e.stickyHeader===void 0?!0:C(e.stickyHeader),h=C(e.stickyFirstColumn),b=d(e.density,"comfortable"),v=C(e.striped),y=r.useInstanceState("filters",{}),x=y.get(),w=[];for(let E=0;E<i;E+=1){let H=!0;for(const V of a){if(!V.filterable)continue;const q=(x[V.key]??"").trim().toLowerCase();if(!q)continue;const te=V.values[E];if(!ct(te,V.format).toLowerCase().includes(q)){H=!1;break}}H&&w.push(E)}if(c){const E=a.find(H=>H.key===c);E&&E.sortable&&w.sort((H,V)=>{const q=_a(E.values[H],E.values[V],E.format);return u==="desc"?-q:q})}const T=w.length,S=Math.max(1,Math.floor(P(e.perPage,20))),N=Math.max(1,Math.ceil(T/S)),$=Math.max(1,Math.floor(P(e.page,1))),A=Math.min($,N),z=w.slice((A-1)*S,A*S),R=o("div",{class:"rui-data-grid","data-density":b,"data-striped":v?"true":"false","data-sticky-header":f?"true":"false","data-sticky-first":h?"true":"false"}),_=t.argMeta?.[3]?.stateRef,Q=t.argMeta?.[4]?.stateRef,B=t.argMeta?.[6]?.stateRef,O=k(e.toolbar);if(p.length>0&&O.length>0){const E=o("div",{class:"rui-data-grid-bulk"});E.append(o("span",{class:"rui-data-grid-bulk-count"},[`${p.length} selected`]));const H=o("div",{class:"rui-data-grid-bulk-tools"});for(const V of O)H.append(r.renderNode(V));E.append(H),R.append(E)}const J=o("div",{class:"rui-data-grid-scroll"}),X=o("table",{class:"rui-data-grid-table"}),de=d(e.caption);de&&X.append(o("caption",{class:"rui-data-grid-caption"},[de]));const ge=o("thead"),Je=o("tr");if(g){const E=o("th",{class:"rui-data-grid-cell-select",scope:"col"}),H=z.length>0&&z.every(q=>m.has(s(q))),V=o("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select all rows on this page",checked:H?"":null});Q&&(V.onclick=q=>{const te=q.currentTarget,Z=new Set(p);for(const K of z){const Y=s(K);te.checked?Z.add(Y):Z.delete(Y)}r.setState(Q,Array.from(Z))}),E.append(V),Je.append(E)}if(a.forEach((E,H)=>{const V=o("th",{scope:"col","data-align":E.align||null,"data-sortable":E.sortable?"true":null,"data-active":E.sortable&&E.key===c?"true":null,"data-first":H===0?"true":null});if(E.sortable&&_){const q=o("button",{type:"button",class:"rui-data-grid-sort"});q.append(o("span",{},[E.header]));const te=E.key===c?u==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",Z=L(te,{className:"rui-data-grid-sort-icon"});Z&&q.append(Z),q.onclick=()=>{const K=E.key===c&&u==="asc"?"desc":"asc";r.setState(_,{key:E.key,direction:K})},V.append(q)}else V.append(document.createTextNode(E.header));Je.append(V)}),ge.append(Je),a.some(E=>E.filterable)){const E=o("tr",{class:"rui-data-grid-filter-row"});g&&E.append(o("td",{class:"rui-data-grid-cell-select"})),a.forEach(H=>{const V=o("td");if(H.filterable){const q=o("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${H.header}`,value:x[H.key]??""});q.oninput=te=>{const Z=te.currentTarget,K={...y.get(),[H.key]:Z.value};y.set(K);const Y=Z.closest("table")?.querySelector("tbody");sp(Y)},V.append(q)}E.append(V)}),ge.append(E)}X.append(ge);const Ae=o("tbody");X.append(Ae);const tr=E=>{if(Ae.replaceChildren(),E.length===0){const H=o("tr"),V=(g?1:0)+Math.max(a.length,1);H.append(o("td",{colspan:String(V),class:"rui-data-grid-empty"},[d(e.emptyLabel,"No results")])),Ae.append(H);return}for(const H of E){const V=s(H),q=m.has(V),te=o("tr",{"data-selected":q?"true":null});if(g){const Z=o("td",{class:"rui-data-grid-cell-select"}),K=o("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select row",checked:q?"":null});Q&&(K.onclick=Y=>{Y.stopPropagation();const ne=Y.currentTarget,pe=new Set(p);ne.checked?pe.add(V):pe.delete(V),r.setState(Q,Array.from(pe))}),Z.append(K),te.append(Z)}a.forEach((Z,K)=>{const Y=Z.values[H],ne=o("td",{"data-format":Z.format,"data-align":Z.align||null,"data-first":K===0?"true":null});Y!==null&&typeof Y=="object"&&Y.__kind==="Component"?ne.append(r.renderNode(Y)):ne.textContent=ct(Y,Z.format),te.append(ne)}),typeof e.rowAction=="function"&&(te.setAttribute("data-clickable","true"),te.onclick=Z=>{Z.target?.closest("input,button,a,label,select,textarea")||r.invoke(e.rowAction)}),Ae.append(te)}},sp=E=>{const H=E??Ae,V=y.get(),q=[];for(let K=0;K<i;K+=1){let Y=!0;for(const ne of a){if(!ne.filterable)continue;const pe=(V[ne.key]??"").trim().toLowerCase();if(!pe)continue;const Xe=ne.values[K];if(!ct(Xe,ne.format).toLowerCase().includes(pe)){Y=!1;break}}Y&&q.push(K)}if(c){const K=a.find(Y=>Y.key===c);K&&K.sortable&&q.sort((Y,ne)=>{const pe=_a(K.values[Y],K.values[ne],K.format);return u==="desc"?-pe:pe})}const te=q.slice((A-1)*S,A*S);(K=>{K.replaceChildren();for(const Y of te){const ne=s(Y),pe=m.has(ne),Xe=o("tr",{"data-selected":pe?"true":null});if(g){const Me=o("td",{class:"rui-data-grid-cell-select"}),rr=o("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:pe?"":null});Me.append(rr),Xe.append(Me)}a.forEach((Me,rr)=>{const Ze=Me.values[Y],ar=o("td",{"data-format":Me.format,"data-align":Me.align||null,"data-first":rr===0?"true":null});Ze!==null&&typeof Ze=="object"&&Ze.__kind==="Component"?ar.append(r.renderNode(Ze)):ar.textContent=ct(Ze,Me.format),Xe.append(ar)}),K.append(Xe)}if(te.length===0){const Y=o("tr"),ne=(g?1:0)+Math.max(a.length,1);Y.append(o("td",{colspan:String(ne),class:"rui-data-grid-empty"},[d(e.emptyLabel,"No results")])),K.append(Y)}})(H)};if(tr(z),J.append(X),R.append(J),T>S){const E=o("div",{class:"rui-data-grid-footer"}),H=T===0?0:(A-1)*S+1,V=Math.min(T,A*S);E.append(o("span",{class:"rui-data-grid-footer-summary"},[T===0?"No results":`Showing ${H}–${V} of ${T}`]));const q=o("div",{class:"rui-data-grid-footer-buttons"}),te=o("button",{type:"button",class:"rui-data-grid-page-button",disabled:A<=1?"":null},["‹ Prev"]),Z=o("button",{type:"button",class:"rui-data-grid-page-button",disabled:A>=N?"":null},["Next ›"]);B&&(te.onclick=()=>{A<=1||r.setState(B,A-1)},Z.onclick=()=>{A>=N||r.setState(B,A+1)}),q.append(te),q.append(o("span",{class:"rui-data-grid-page-current"},[`${A} / ${N}`])),q.append(Z),E.append(q),R.append(E)}return R}};function yc(t){const e=[];for(const r of k(t)){if(!r||typeof r!="object")continue;const a=r,i=d(a.date);i&&e.push({date:i,title:d(a.title),tone:d(a.tone,"primary"),time:d(a.time)})}return e}function ja(t,e){const r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=(r.getDay()-e+7)%7;return r.setDate(r.getDate()-i),r}function Ba(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 xc={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=d(e.view,"month"),i=yc(e.events),n=d(e.value),s=d(e.month,n),l=new Date;let c=new Date(NaN);if(s){const S=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(s);if(S)c=new Date(Number(S[1]),Number(S[2])-1,S[3]?Number(S[3]):1);else{const N=new Date(s);Number.isNaN(N.getTime())||(c=N)}}Number.isNaN(c.getTime())&&(c=l);const u=(P(e.firstDay,1)%7+7)%7,p=n&&/^\d{4}-\d{2}-\d{2}$/.test(n)?n:"",m=new Map;for(const S of i){const N=S.date.slice(0,10),$=m.get(N)??[];$.push(S),m.set(N,$)}const g=t.argMeta?.[0]?.stateRef,f=o("div",{class:"rui-calendar","data-view":a}),h=o("div",{class:"rui-calendar-header"}),b=c.toLocaleDateString(void 0,{month:"long",year:"numeric"});h.append(o("div",{class:"rui-calendar-title"},[b])),f.append(h);const v=o("div",{class:"rui-calendar-weekrow"}),y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let S=0;S<7;S+=1){const N=y[(u+S)%7]??"";v.append(o("div",{class:"rui-calendar-weekday"},[N]))}f.append(v);const x=[];if(a==="week"){const S=p?new Date(p):c,N=ja(S,u);for(let $=0;$<7;$+=1){const A=new Date(N);A.setDate(N.getDate()+$),x.push({date:A,inMonth:A.getMonth()===c.getMonth()})}}else{const S=new Date(c.getFullYear(),c.getMonth(),1),N=new Date(c.getFullYear(),c.getMonth()+1,0),$=ja(S,u),A=Math.ceil((N.getDate()+(S.getDay()-u+7)%7)/7)*7;for(let z=0;z<A;z+=1){const R=new Date($);R.setDate($.getDate()+z),x.push({date:R,inMonth:R.getMonth()===c.getMonth()})}}const w=o("div",{class:"rui-calendar-grid","data-view":a}),T=Ba(l);for(const S of x){const N=Ba(S.date),$=N===T,A=N===p,z=m.get(N)??[],R=o("button",{type:"button",class:"rui-calendar-day","data-in-month":S.inMonth?"true":"false","data-today":$?"true":"false","data-selected":A?"true":"false","aria-label":S.date.toDateString()});if(R.append(o("span",{class:"rui-calendar-daynumber"},[String(S.date.getDate())])),z.length>0){const _=o("div",{class:"rui-calendar-day-events"}),Q=z.slice(0,3);for(const B of Q){const O=o("span",{class:"rui-calendar-event","data-tone":B.tone??"primary",title:B.time?`${B.time} — ${B.title}`:B.title},[B.title]);_.append(O)}z.length>3&&_.append(o("span",{class:"rui-calendar-event-more"},[`+${z.length-3} more`])),R.append(_)}R.onclick=()=>{g&&r.setState(g,N),r.invoke(e.onSelect,N)},w.append(R)}return f.append(w),f}};function wc(t){const e=[];for(const r of k(t)){if(!r||typeof r!="object")continue;const a=r;e.push({title:d(a.title),description:d(a.description),actor:d(a.actor),avatarSrc:d(a.avatarSrc),time:d(a.time),icon:d(a.icon),tone:d(a.tone,"default"),meta:d(a.meta)})}return e}function kc(t,e,r){const a=o("ol",{class:t,"data-variant":r});for(const i of e){const n=o("li",{class:`${t}-item`,"data-tone":i.tone}),s=o("span",{class:`${t}-marker`}),l=L(i.icon,{className:`${t}-icon`});l&&s.append(l),n.append(s);const c=o("div",{class:`${t}-body`}),u=o("div",{class:`${t}-head`});i.actor&&u.append(o("span",{class:`${t}-actor`},[i.actor])),u.append(o("span",{class:`${t}-title`},[i.title])),i.time&&u.append(o("span",{class:`${t}-time`},[i.time])),c.append(u),i.description&&c.append(o("p",{class:`${t}-description`},[i.description])),i.meta&&c.append(o("span",{class:`${t}-meta`},[i.meta])),n.append(c),a.append(n)}return a}const Sc={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=d(e.variant,"default");return kc(r==="audit"?"rui-audit-trail":"rui-activity-log",wc(e.items),r)}},Cc={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=k(e.columns).map(g=>d(g)),i=k(e.rows).map(g=>{const f=g??{};return{label:d(f.label),values:k(f.values),hint:d(f.hint),group:d(f.group)}}),n=Math.floor(P(e.highlightColumn,-1)),s=o("div",{class:"rui-comparison-table"}),l=o("table"),c=o("thead"),u=o("tr");u.append(o("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),a.forEach((g,f)=>{u.append(o("th",{scope:"col","data-highlight":f===n?"true":null},[g]))}),c.append(u),l.append(c);const p=o("tbody");let m="";for(const g of i){if(g.group&&g.group!==m){m=g.group;const b=o("tr",{class:"rui-comparison-table-group"});b.append(o("td",{colspan:String(a.length+1)},[g.group])),p.append(b)}const f=o("tr"),h=o("td",{class:"rui-comparison-table-feature"});h.append(o("div",{class:"rui-comparison-table-feature-label"},[g.label])),g.hint&&h.append(o("div",{class:"rui-comparison-table-feature-hint"},[g.hint])),f.append(h);for(let b=0;b<a.length;b+=1){const v=g.values[b],y=o("td",{"data-highlight":b===n?"true":null});if(v===!0){const x=L("circle-check",{className:"rui-comparison-yes"});x?y.append(x):y.textContent="✓"}else v===!1||v===null||v===void 0?y.append(o("span",{class:"rui-comparison-no"},["—"])):v&&typeof v=="object"&&v.__kind==="Component"?y.append(r.renderNode(v)):y.textContent=d(v);f.append(y)}p.append(f)}return l.append(p),s.append(l),s}},Tc={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=o("div",{class:"rui-infinite-list"}),i=o("div",{class:"rui-infinite-list-body"});for(const l of k(e.items))i.append(r.renderNode(l));a.append(i);const n=e.hasMore===void 0?!0:C(e.hasMore),s=C(e.loading);if(n){const l=o("div",{class:"rui-infinite-list-sentinel"});if(s){const c=L("spinner",{className:"rui-infinite-list-spin"});c&&l.append(c),l.append(o("span",{},[d(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const c=o("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);c.onclick=()=>r.invoke(e.onLoadMore),l.append(c)}if(a.append(l),!s&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const c=e.onLoadMore,u=new IntersectionObserver(p=>{for(const m of p)if(m.isIntersecting){r.invoke(c);break}});u.observe(l),r.registerDisposer(()=>u.disconnect(),"infinite-observer")}}return a}},$c=/^(https?:|blob:|data:(audio|video)\/)/i;function ut(t){const e=d(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":$c.test(e)?e:"":""}const Nc={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=o("figure",{class:"rui-video-player"}),a=qt(d(e.ratio,"16:9")),i=o("div",{class:"rui-video-player-frame",style:`aspect-ratio:${a};`}),n=e.controls===void 0?!0:C(e.controls),s=o("video",{class:"rui-video-player-video",controls:n?"":null,autoplay:C(e.autoplay)?"":null,loop:C(e.loop)?"":null,muted:C(e.muted)?"":null,poster:re(e.poster)||null,playsinline:"",preload:"metadata"}),l=k(e.sources);if(l.length>0)for(const u of l){if(!u||typeof u!="object")continue;const p=u,m=ut(p.src);m&&s.append(o("source",{src:m,type:d(p.type)||null}))}else{const u=ut(e.src);u&&s.setAttribute("src",u)}i.append(s),r.append(i);const c=d(e.caption);return c&&r.append(o("figcaption",{class:"rui-video-player-caption"},[c])),r}},Ac={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=o("div",{class:"rui-audio-player"}),a=o("div",{class:"rui-audio-player-meta"}),i=L(d(e.icon,"music"),{className:"rui-audio-player-icon"});i&&a.append(i);const n=o("div",{class:"rui-audio-player-text"}),s=d(e.title);s&&n.append(o("div",{class:"rui-audio-player-title"},[s]));const l=d(e.artist);l&&n.append(o("div",{class:"rui-audio-player-artist"},[l])),a.append(n),r.append(a);const c=e.controls===void 0?!0:C(e.controls),u=o("audio",{class:"rui-audio-player-audio",controls:c?"":null,autoplay:C(e.autoplay)?"":null,loop:C(e.loop)?"":null,preload:"metadata"}),p=k(e.sources);if(p.length>0)for(const m of p){if(!m||typeof m!="object")continue;const g=m,f=ut(g.src);f&&u.append(o("source",{src:f,type:d(g.type)||null}))}else{const m=ut(e.src);m&&u.setAttribute("src",m)}return r.append(u),r}};function Mc(t,e){if(t==null)return null;if(typeof t=="object"&&t.__kind==="Component")return e.renderNode(t);if(typeof t=="string"){const r=re(t);return r?o("img",{src:r,alt:"",loading:"lazy",class:"rui-carousel-image"}):null}if(typeof t=="object"){const r=t,a=re(r.src);if(a){const i=o("figure",{class:"rui-carousel-figure"});i.append(o("img",{src:a,alt:d(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const n=d(r.caption??r.title);return n&&i.append(o("figcaption",{class:"rui-carousel-caption"},[n])),i}}return e.renderNode(t)}const Pc={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=k(e.items),i=a.length,n=Math.max(0,Math.min(Math.max(i-1,0),Math.floor(P(e.activeIndex,0)))),s=r.useInstanceState("active",n);let l=s.get();l>=i&&(l=0,s.set(l));const c=e.showDots===void 0?!0:C(e.showDots),u=e.showArrows===void 0?!0:C(e.showArrows),p=qt(d(e.ratio,"16:9")),m=o("div",{class:"rui-carousel"}),g=o("div",{class:"rui-carousel-frame",style:`aspect-ratio:${p};`}),f=o("div",{class:"rui-carousel-track",style:`transform:translateX(${l*-100}%);`});a.forEach(b=>{const v=o("div",{class:"rui-carousel-slide"}),y=Mc(b,r);y&&v.append(y),f.append(v)}),g.append(f);const h=(b,v)=>{const y=(v%i+i)%i;s.set(y);const x=b.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${y*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((T,S)=>{T.setAttribute("data-active",S===y?"true":"false")})};if(u&&i>1){const b=o("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),v=L("chevron-left");v&&b.append(v);const y=o("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=L("chevron-right");x&&y.append(x),b.onclick=w=>h(w.currentTarget,s.get()-1),y.onclick=w=>h(w.currentTarget,s.get()+1),g.append(b,y)}if(m.append(g),c&&i>1){const b=o("div",{class:"rui-carousel-dots"});a.forEach((v,y)=>{const x=o("button",{type:"button",class:"rui-carousel-dot","data-active":y===l?"true":"false","aria-label":`Go to slide ${y+1}`});x.onclick=w=>h(w.currentTarget,y),b.append(x)}),m.append(b)}return m}},Ic={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=k(e.items),i=Math.max(1,Math.min(6,Number(e.columns??"auto"))),n=qt(d(e.ratio,"1:1")),s=o("div",{class:"rui-gallery","data-columns":i>0?String(i):null});return a.forEach((l,c)=>{const{src:u,alt:p,caption:m}=Da(l),g=re(u),f=typeof e.onSelect=="function",h=o(f?"button":"figure",{type:f?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${n};`,"data-index":String(c)});if(g)h.append(o("img",{src:g,alt:p,loading:"lazy"}));else{const b=L("image",{className:"rui-gallery-placeholder"});b&&h.append(b)}m&&h.append(o("span",{class:"rui-gallery-caption"},[m])),f&&(h.onclick=()=>r.invoke(e.onSelect,c,l)),s.append(h)}),s}};function Da(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:d(e.args[0]),alt:d(e.args[1]),caption:d(e.args[2])}:{src:d(e.src),alt:d(e.alt),caption:d(e.caption)}}return{src:"",alt:"",caption:""}}const zc={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=k(e.items).map($=>Da($)).filter($=>re($.src)!==""),i=a.length,n=t.argMeta?.[2]?.stateRef,s=t.argMeta?.[1]?.stateRef,l=r.useInstanceState("open",!1),c=r.useInstanceState("index",0),u=s?C(e.open):l.get(),p=n?Math.floor(P(e.index,0)):c.get(),m=i===0?0:(p%i+i)%i,g=$=>{s?r.setState(s,$):l.set($)},f=$=>{n?r.setState(n,$):c.set($)},h=()=>g(!1),b=$=>{i!==0&&f(((m+$)%i+i)%i)},v=o("div",{class:"rui-lightbox-root"});if(!s&&i>0){const $=a[m],A=o("button",{type:"button",class:"rui-lightbox-thumb","aria-label":$?.alt||"Open image"});if($){const z=re($.src);z&&A.append(o("img",{src:z,alt:$.alt,loading:"lazy"}))}A.onclick=z=>{z.stopPropagation(),g(!0)},v.append(A)}const y=o("div",{class:"rui-lightbox-overlay","data-open":u?"true":"false"});if(v.append(y),!u||i===0)return v;const x=a[m];if(!x)return v;const w=re(x.src);y.onclick=$=>{$.target===y&&h()};const T=o("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),S=o("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(S.onclick=h,T.append(S),i>1){const $=o("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),A=L("chevron-left");A&&$.append(A),$.onclick=()=>b(-1);const z=o("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),R=L("chevron-right");R&&z.append(R),z.onclick=()=>b(1),T.append($,z)}const N=o("div",{class:"rui-lightbox-image-wrap"});return w&&N.append(o("img",{src:w,alt:x.alt})),T.append(N),x.caption&&T.append(o("div",{class:"rui-lightbox-caption"},[x.caption])),i>1&&T.append(o("div",{class:"rui-lightbox-counter"},[`${m+1} / ${i}`])),y.append(T),v}};function Rc(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){const e=t,r=P(e.lat??e.latitude,NaN),a=P(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=P(t[0],NaN),r=P(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 Lc={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=o("figure",{class:"rui-map"}),a=ee(e.height,"320px"),i=o("div",{class:"rui-map-frame",style:`height:${a};`}),n=P(e.lat,NaN),s=P(e.lng,NaN),l=Number.isFinite(n)&&Number.isFinite(s)?{lat:n,lng:s}:null;if(!l){i.append(o("div",{class:"rui-map-empty"},["Pass lat & lng (numbers) to render the map."])),r.append(i);const b=d(e.caption);return b&&r.append(o("figcaption",{class:"rui-map-caption"},[b])),r}const c=Math.max(1,Math.min(18,Math.floor(P(e.zoom,13)))),u=1/Math.pow(2,c-8),m=`https://www.openstreetmap.org/export/embed.html?bbox=${[l.lng-u,l.lat-u/2,l.lng+u,l.lat+u/2].join(",")}&layer=mapnik&marker=${l.lat},${l.lng}`,g=o("iframe",{class:"rui-map-iframe",src:m,loading:"lazy",title:"Map view",referrerpolicy:"no-referrer"});i.append(g),r.append(i);const f=k(e.markers).map(b=>{const v=Rc(b),y=b&&typeof b=="object"?d(b.label):"";return v?{...v,label:y}:null}).filter(b=>b!==null);if(f.length>0){const b=o("ul",{class:"rui-map-markers"});for(const v of f){const y=o("li",{class:"rui-map-marker"}),x=L("location-dot",{className:"rui-map-marker-icon"});x&&y.append(x),y.append(o("span",{class:"rui-map-marker-label"},[v.label||`${v.lat.toFixed(4)}, ${v.lng.toFixed(4)}`])),b.append(y)}r.append(b)}const h=d(e.caption);return h&&r.append(o("figcaption",{class:"rui-map-caption"},[h])),r}};function qt(t){if(t.includes(":")){const[r,a]=t.split(":"),i=Number(r),n=Number(a);if(Number.isFinite(i)&&Number.isFinite(n)&&n>0)return`${i} / ${n}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const Ec=[{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"}],_c={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}],render:(t,e,r)=>{const a=d(e.id),i=d(e.placeholder,"Start writing…"),n=C(e.disabled),s=o("div",{class:"rui-rich-text","data-disabled":n?"true":"false"}),l=o("div",{class:"rui-rich-text-toolbar",role:"toolbar"});for(const f of Ec){const h=o("button",{type:"button",class:"rui-rich-text-tool","data-command":f.command,"data-block":f.block??null,"aria-label":f.label,title:f.label,disabled:n?"":null}),b=L(f.icon);b&&h.append(b),h.onmousedown=v=>v.preventDefault(),h.onclick=v=>{const x=v.currentTarget.closest(".rui-rich-text")?.querySelector(".rui-rich-text-content");if(x){x.focus();try{if(f.command==="createLink"){const w=window.prompt("URL");w&&document.execCommand("createLink",!1,w)}else f.command==="formatBlock"&&f.block?document.execCommand("formatBlock",!1,f.block):document.execCommand(f.command,!1)}catch{}x.dispatchEvent(new Event("input",{bubbles:!0}))}},l.append(h)}s.append(l);const c=d(e.value)||"",u=f=>f.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").trim().length===0,p=o("div",{class:"rui-rich-text-content",id:a,contenteditable:n?"false":"true",role:"textbox","aria-multiline":"true","aria-placeholder":i,"data-placeholder":i,"data-empty":u(c)?"true":"false",style:`min-height:${d(e.minHeight,"160px")};`,html:c}),m=f=>{f.setAttribute("data-empty",u(f.innerHTML)?"true":"false")},g=t.argMeta?.[1]?.stateRef;return g&&!n?r.bindState(p,g,{event:"input",getValue:f=>{const h=f;return m(h),h.innerHTML}}):p.oninput=f=>{const h=f.currentTarget??f.target;m(h)},p.onblur=f=>{const h=f.currentTarget??f.target;m(h)},s.append(p),s}},jc={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}],render:(t,e,r)=>{const a=d(e.id),i=d(e.value),n=d(e.language,"text"),s=e.showGutter===void 0?!0:C(e.showGutter),l=Math.max(1,Math.min(8,Math.floor(P(e.tabSize,2)))),c=C(e.readonly),u=d(e.minHeight,"200px"),p=o("div",{class:"rui-code-editor","data-language":n,"data-gutter":s?"true":"false"}),m=o("div",{class:"rui-code-editor-head"});m.append(o("span",{class:"rui-code-editor-language"},[n])),p.append(m);const g=o("div",{class:"rui-code-editor-body",style:`min-height:${u};`}),f=o("div",{class:"rui-code-editor-gutter","aria-hidden":"true"});s&&((y=>{f.replaceChildren();const x=y.split(/\r?\n/),w=Math.max(1,x.length);for(let T=1;T<=w;T+=1)f.append(o("span",{class:"rui-code-editor-line"},[String(T)]))})(i),g.append(f));const b=o("textarea",{class:"rui-code-editor-textarea",id:a,name:a,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:d(e.placeholder),readonly:c?"":null,style:`tab-size:${l};-moz-tab-size:${l};`});b.value=i,b.oninput=y=>{const x=y.currentTarget;if(!s)return;const T=x.closest(".rui-code-editor")?.querySelector(".rui-code-editor-gutter");if(!T)return;T.replaceChildren();const S=x.value.split(/\r?\n/),N=Math.max(1,S.length);for(let $=1;$<=N;$+=1)T.append(o("span",{class:"rui-code-editor-line"},[String($)]))},b.onkeydown=y=>{const x=y;if(x.key!=="Tab")return;x.preventDefault();const w=x.currentTarget,T=w.selectionStart,S=w.selectionEnd,N=" ".repeat(l);w.value=w.value.slice(0,T)+N+w.value.slice(S),w.selectionStart=w.selectionEnd=T+N.length,w.dispatchEvent(new Event("input",{bubbles:!0}))};const v=t.argMeta?.[1]?.stateRef;return v&&!c&&r.bindState(b,v,{event:"input",getValue:y=>y.value}),g.append(b),p.append(g),p}};function Bc(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:d(a[0]),action:a[1],icon:d(a[2]),shortcut:d(a[3]),variant:d(a[4],"default"),disabled:C(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:d(r.label),action:r.action,icon:d(r.icon),shortcut:d(r.shortcut),variant:d(r.variant,"default"),disabled:C(r.disabled),separator:!1}}return null}const Dc={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=o("div",{class:"rui-context-menu"}),i=o("div",{class:"rui-context-menu-target"});i.append(r.renderNode(e.target)),a.append(i);const n=o("div",{class:"rui-context-menu-pop",role:"menu","aria-label":d(e.label)||null,"data-open":"false"}),s=k(e.items).map(Bc).filter(u=>u!==null);for(const u of s){if(u.separator){n.append(o("div",{class:"rui-menu-separator",role:"separator"}));continue}const p=o("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":u.variant,disabled:u.disabled?"":null}),m=L(u.icon,{className:"rui-menu-item-icon"});m&&p.append(m),p.append(o("span",{class:"rui-menu-item-label"},[u.label])),u.shortcut&&p.append(o("span",{class:"rui-menu-item-shortcut"},[u.shortcut])),u.disabled||(p.onclick=()=>{r.invoke(u.action),n.setAttribute("data-open","false")}),n.append(p)}a.append(n);const l=()=>n.setAttribute("data-open","false"),c=(u,p)=>{const m=i.isConnected?i.closest(".rui-context-menu"):null,g=m?.querySelector(".rui-context-menu-pop")??n,f=m?.getBoundingClientRect(),h=f?u-f.left:u,b=f?p-f.top:p;g.style.left=`${h}px`,g.style.top=`${b}px`,g.setAttribute("data-open","true");const v=y=>{y.target&&g.contains(y.target)||(g.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 i.oncontextmenu=u=>{u.preventDefault(),c(u.clientX,u.clientY)},i.onkeydown=u=>{const p=u;if(p.key==="ContextMenu"||p.shiftKey&&p.key==="F10"){p.preventDefault();const g=p.currentTarget.getBoundingClientRect();c(g.left,g.top+g.height)}p.key==="Escape"&&l()},a}},Fc=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function Ge(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 Oc={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}],render:(t,e,r)=>{const a=d(e.id),i=Ge(d(e.value))||d(e.value,"#000000"),n=C(e.disabled),s=o("div",{class:"rui-color-picker","data-disabled":n?"true":"false"}),l=d(e.label);l&&s.append(o("label",{class:"rui-color-picker-label",for:a},[l]));const c=o("div",{class:"rui-color-picker-row"}),u=o("input",{type:"color",class:"rui-color-picker-color",id:a,name:a,value:Ge(i)||"#000000",disabled:n?"":null}),p=o("input",{type:"text",class:"rui-color-picker-hex",value:i,placeholder:"#000000",disabled:n?"":null,autocomplete:"off"}),m=o("div",{class:"rui-color-picker-swatches"}),g=k(e.swatches).map(b=>d(b)).filter(Boolean),f=g.length>0?g:Fc;for(const b of f){const v=Ge(b)||b,y=o("button",{type:"button",class:"rui-color-picker-swatch",style:`background:${v}`,"aria-label":v,title:v,"data-active":v.toLowerCase()===i.toLowerCase()?"true":"false"});y.onclick=()=>{u.value=Ge(v)||u.value,p.value=v,u.dispatchEvent(new Event("input",{bubbles:!0}))},m.append(y)}const h=t.argMeta?.[1]?.stateRef;return h&&!n&&(r.bindState(u,h,{event:"input",getValue:b=>b.value}),u.addEventListener("input",()=>{p.value=u.value}),p.oninput=()=>{const b=Ge(p.value);b&&(u.value=b,u.dispatchEvent(new Event("input",{bubbles:!0})))}),c.append(u,p),s.append(c,m),s}},Ht=["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)"],$e=t=>Ht[t%Ht.length]??Ht[0];function Uc(t){return t.map((e,r)=>{const a=e,i=d(a.args?.[0],`Series ${r+1}`),n=k(a.args?.[1]).map(s=>P(s));return{name:i,values:n}})}function dt(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 ie(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[i,n]of Object.entries(e))a.setAttribute(i,n);if(r)for(const i of r)a.append(typeof i=="string"?document.createTextNode(i):i);return a}function Fa(t){const e=o("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const i=o("span",{class:"rui-chart-legend-item"});i.append(o("span",{class:"rui-chart-legend-swatch",style:`background:${$e(a)}`})),i.append(o("span",{},[r.name])),e.append(i)}),e}const qc={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=P(e.min,0),a=Math.max(r+1,P(e.max,100)),i=Math.max(r,Math.min(a,P(e.value,r))),n=(i-r)/(a-r),s=d(e.tone,"primary"),l=d(e.size,"md"),c=l==="lg"?220:l==="sm"?140:180,u=c/2,p=l==="lg"?18:l==="sm"?10:14,m=u-p,g=o("div",{class:"rui-gauge","data-tone":s,"data-size":l}),f=dt(c,u+p+4),h=u,b=u,v=h-m,y=b,x=h+m,w=b;if(f.append(ie("path",{d:`M${v},${y} A${m},${m} 0 0 1 ${x},${w}`,fill:"none",stroke:"var(--rui-color-border, #e2e8f0)","stroke-width":String(p),"stroke-linecap":"round"})),n>0){const $=Math.PI*n,A=h-m*Math.cos($),z=b-m*Math.sin($);f.append(ie("path",{d:`M${v},${y} A${m},${m} 0 0 1 ${A.toFixed(2)},${z.toFixed(2)}`,fill:"none",stroke:`var(--rui-color-${s}, ${$e(0)})`,"stroke-width":String(p),"stroke-linecap":"round",class:"rui-gauge-arc"}))}g.append(f);const T=Hc(i,r,a),S=d(e.label)||T;g.append(o("div",{class:"rui-gauge-value"},[S]));const N=d(e.caption);return N&&g.append(o("div",{class:"rui-gauge-caption"},[N])),g}};function Hc(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 Vc={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=k(e.xLabels).map(p=>d(p)),a=k(e.yLabels).map(p=>d(p)),i=k(e.values).map(p=>k(p).map(m=>P(m,0))),n=d(e.tone,"primary"),s=Math.max(1,...i.flat()),l=o("div",{class:"rui-heatmap","data-tone":n});d(e.title)&&l.append(o("div",{class:"rui-chart-title"},[d(e.title)]));const c=o("div",{class:"rui-heatmap-table"}),u=o("div",{class:"rui-heatmap-row rui-heatmap-row-header"});u.append(o("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const p of r)u.append(o("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[p]));return c.append(u),i.forEach((p,m)=>{const g=o("div",{class:"rui-heatmap-row"});g.append(o("div",{class:"rui-heatmap-cell rui-heatmap-ylabel"},[a[m]??String(m+1)])),p.forEach((f,h)=>{const b=s>0?f/s:0,v=o("div",{class:"rui-heatmap-cell rui-heatmap-value",style:`background:color-mix(in srgb, var(--rui-color-${n}, ${$e(0)}) ${Math.round(b*90+5)}%, transparent);`,title:`${r[h]??h+1} · ${a[m]??m+1}: ${f}`});v.append(o("span",{},[String(f)])),g.append(v)}),c.append(g)}),l.append(c),l}},Wc={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=k(e.axes).map(f=>d(f)),a=Uc(k(e.series)),i=Math.max(r.length,3),n=o("div",{class:"rui-chart rui-radar-chart"});d(e.title)&&n.append(o("div",{class:"rui-chart-title"},[d(e.title)]));const s=Math.max(1,P(e.max,a.flatMap(f=>f.values).reduce((f,h)=>Math.max(f,h),1))),l=280,c=l/2,u=l/2,p=l/2-24,m=dt(l,l),g=4;for(let f=1;f<=g;f+=1){const h=p/g*f,b=[];for(let v=0;v<i;v+=1){const y=Math.PI*2*v/i-Math.PI/2;b.push(`${(c+h*Math.cos(y)).toFixed(1)},${(u+h*Math.sin(y)).toFixed(1)}`)}m.append(ie("polygon",{points:b.join(" "),fill:"none",stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}))}for(let f=0;f<i;f+=1){const h=Math.PI*2*f/i-Math.PI/2,b=c+p*Math.cos(h),v=u+p*Math.sin(h);m.append(ie("line",{x1:String(c),y1:String(u),x2:b.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(h),x=u+(p+16)*Math.sin(h);m.append(ie("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[f]??""]))}return a.forEach((f,h)=>{const b=[];for(let v=0;v<i;v+=1){const y=f.values[v]??0,x=Math.max(0,Math.min(1,y/s)),w=Math.PI*2*v/i-Math.PI/2,T=c+p*x*Math.cos(w),S=u+p*x*Math.sin(w);b.push(`${T.toFixed(1)},${S.toFixed(1)}`)}m.append(ie("polygon",{points:b.join(" "),fill:$e(h),"fill-opacity":"0.2",stroke:$e(h),"stroke-width":"2","stroke-linejoin":"round"}))}),n.append(m),a.length>0&&n.append(Fa(a)),n}};function Gc(t){return t.map((e,r)=>{const a=e,i=d(a.args?.[0],`Series ${r+1}`),n=k(a.args?.[1]).map(s=>{if(Array.isArray(s))return{x:P(s[0],0),y:P(s[1],0),label:d(s[2])};if(s&&typeof s=="object"){const l=s;return{x:P(l.x,0),y:P(l.y,0),label:d(l.label)}}return{x:0,y:0,label:""}});return{name:i,points:n}})}const Kc={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=Gc(k(e.series)),a=o("div",{class:"rui-chart rui-scatter-chart"});d(e.title)&&a.append(o("div",{class:"rui-chart-title"},[d(e.title)]));const i=640,n=280,s={left:50,right:16,top:16,bottom:40},l=i-s.left-s.right,c=n-s.top-s.bottom,u=r.flatMap(T=>T.points);if(u.length===0)return a.append(o("div",{class:"rui-chart-empty"},["No points"])),a;const p=u.map(T=>T.x),m=u.map(T=>T.y),g=Math.min(...p),f=Math.max(...p),h=Math.min(...m),b=Math.max(...m),v=f-g||1,y=b-h||1,x=dt(i,n);if(Ua(x,s,l,c,b,h),x.append(ie("line",{x1:String(s.left),y1:String(s.top+c),x2:String(s.left+l),y2:String(s.top+c),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((T,S)=>{T.points.forEach(N=>{const $=s.left+(N.x-g)/v*l,A=s.top+c-(N.y-h)/y*c,z=ie("circle",{cx:$.toFixed(1),cy:A.toFixed(1),r:"7",fill:$e(S),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});z.append(ie("title",{},[N.label||`${N.x}, ${N.y}`])),x.append(z)})}),d(e.xLabel)&&x.append(ie("text",{x:String(s.left+l/2),y:String(n-6),"text-anchor":"middle",class:"rui-chart-label","font-size":"14","font-weight":"500"},[d(e.xLabel)])),d(e.yLabel)){const S=s.top+c/2;x.append(ie("text",{x:String(14),y:String(S),"text-anchor":"middle",transform:`rotate(-90, 14, ${S})`,class:"rui-chart-label","font-size":"14","font-weight":"500"},[d(e.yLabel)]))}a.append(x);const w=r.map(T=>({name:T.name,values:T.points.map(S=>S.y)}));return w.length>0&&a.append(Fa(w)),a}},Yc={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(g=>{const f=g??{};return{label:d(f.label),count:P(f.count,0)}});else{const g=k(e.values).map(f=>P(f,NaN)).filter(f=>Number.isFinite(f));if(g.length>0){const f=Math.max(2,Math.min(50,Math.floor(P(e.binCount,10)))),h=Math.min(...g),y=(Math.max(...g)-h||1)/f,x=new Array(f).fill(0);for(const w of g){let T=Math.floor((w-h)/y);T>=f&&(T=f-1),T<0&&(T=0),x[T]+=1}r=x.map((w,T)=>{const S=h+T*y,N=S+y;return{label:`${Oa(S)}–${Oa(N)}`,count:w}})}}const a=o("div",{class:"rui-chart rui-histogram"});if(d(e.title)&&a.append(o("div",{class:"rui-chart-title"},[d(e.title)])),r.length===0)return a.append(o("div",{class:"rui-chart-empty"},["No data"])),a;const i=640,n=240,s={left:40,right:12,top:16,bottom:50},l=i-s.left-s.right,c=n-s.top-s.bottom,u=Math.max(1,...r.map(g=>g.count)),p=l/r.length,m=dt(i,n);return Ua(m,s,l,c,u),r.forEach((g,f)=>{const h=s.left+f*p+p*.1,b=p*.8,v=g.count/u*c,y=s.top+c-v,x=ie("rect",{x:h.toFixed(1),y:y.toFixed(1),width:b.toFixed(1),height:v.toFixed(1),fill:$e(0),rx:"2"});x.append(ie("title",{},[`${g.label}: ${g.count}`])),m.append(x),m.append(ie("text",{x:(h+b/2).toFixed(1),y:String(s.top+c+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[g.label]))}),a.append(m),a}};function Oa(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function Ua(t,e,r,a,i,n=0){for(let l=0;l<=4;l+=1){const c=l/4,u=e.top+a-c*a;t.append(ie("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(ie("text",{x:String(e.left-8),y:String(u+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((n+(i-n)*c)*10)/10)]))}}const Jc=["numeric","alphanumeric"];function Xc(t,e,r,a,i,n,s){const l=o("div",{class:"rui-pin-input","data-disabled":i?"true":"false"}),c=[];for(let m=0;m<e;m+=1){const g=o("input",{class:"rui-pin-input-slot",id:m===0?t:null,maxlength:"1",autocomplete:"one-time-code",inputmode:r==="numeric"?"numeric":"text",type:n?"password":"text","aria-label":`Digit ${m+1}`,value:a.charAt(m)||"",disabled:i?"":null});c.push(g),l.append(g)}const u=m=>{const g=m.closest(".rui-pin-input");return g?Array.from(g.querySelectorAll(".rui-pin-input-slot")):c},p=m=>u(m).map(g=>g.value).join("").slice(0,e);return c.forEach((m,g)=>{m.oninput=f=>{const h=f.currentTarget,b=u(h);let v=h.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-g).forEach((w,T)=>{const S=b[g+T];S&&(S.value=w)});const x=Math.min(g+y.length,e-1);b[x]?.focus()}else h.value=v,v&&g<e-1&&b[g+1]?.focus();s?.(p(h))},m.onkeydown=f=>{const h=f,b=h.currentTarget,v=u(b);if(h.key==="Backspace"&&!b.value&&g>0){h.preventDefault(),v[g-1]?.focus();const y=v[g-1];y&&(y.value=""),s?.(p(b))}else h.key==="ArrowLeft"&&g>0?(h.preventDefault(),v[g-1]?.focus()):h.key==="ArrowRight"&&g<e-1&&(h.preventDefault(),v[g+1]?.focus())}}),l}const Zc={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:Jc},{name:"mask",type:"boolean",optional:!0,description:"Render slots as `<input type=password>`"},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=d(e.id),i=Math.max(1,Math.min(12,Math.floor(P(e.length,4)))),n=d(e.type,"numeric"),s=d(e.value),l=C(e.disabled),c=C(e.mask),u=t.argMeta?.[2]?.stateRef;return Xc(a,i,n,s,l,c,p=>{u&&r.setState(u,p)})}};function Qc(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 eu={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}],render:(t,e,r)=>{const a=d(e.id),i=r.useInstanceState("visible",!1),n=i.get(),s=C(e.disabled),l=o("div",{class:"rui-password-input","data-disabled":s?"true":"false"}),c=d(e.label);c&&l.append(o("label",{class:"rui-password-input-label",for:a},[c]));const u=o("div",{class:"rui-password-input-row"}),p=o("input",{type:n?"text":"password",class:"rui-password-input-field",id:a,name:a,autocomplete:"current-password",placeholder:d(e.placeholder),value:d(e.value),disabled:s?"":null}),m=o("button",{type:"button",class:"rui-password-input-toggle","aria-label":n?"Hide password":"Show password"}),g=L(n?"eye-slash":"eye");g&&m.append(g),m.onclick=h=>{h.preventDefault();const b=!i.get();i.set(b);const x=h.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=b?"text":"password")};const f=t.argMeta?.[1]?.stateRef;if(f&&r.bindState(p,f,{event:"input",getValue:h=>h.value}),u.append(p),u.append(m),l.append(u),C(e.strengthMeter)){const h=Qc(d(e.value)),b=o("div",{class:"rui-password-input-strength","data-score":String(h.score)});for(let y=0;y<4;y+=1)b.append(o("span",{class:"rui-password-input-strength-bar","data-filled":y<h.score?"true":"false"}));const v=o("div",{class:"rui-password-input-strength-row"});v.append(b),h.label&&v.append(o("span",{class:"rui-password-input-strength-label"},[h.label])),l.append(v)}return l}},tu={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}],render:(t,e,r)=>{const a=d(e.id),i=k(e.value).map(g=>d(g)).filter(Boolean),n=Math.max(0,Math.floor(P(e.max,0))),s=C(e.disabled),l=t.argMeta?.[1]?.stateRef,c=g=>{l&&r.setState(l,g)},u=d(e.label),p=o("div",{class:"rui-tag-input","data-disabled":s?"true":"false"});for(const g of i){const f=o("span",{class:"rui-tag-input-chip"});f.append(o("span",{},[g]));const h=o("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${g}`},["×"]);h.onclick=()=>c(i.filter(b=>b!==g)),f.append(h),p.append(f)}const m=o("input",{type:"text",class:"rui-tag-input-field",id:a,name:a,placeholder:d(e.placeholder,i.length===0?"Add tags…":""),disabled:s?"":null,autocomplete:"off"});if(m.onkeydown=g=>{const f=g,h=f.currentTarget;if(f.key==="Enter"||f.key===","){f.preventDefault();const b=h.value.trim();if(!b||n>0&&i.length>=n)return;if(i.includes(b)){h.value="";return}c([...i,b]),h.value=""}else f.key==="Backspace"&&h.value===""&&i.length>0&&(f.preventDefault(),c(i.slice(0,-1)))},p.append(m),u){const g=o("div",{class:"rui-tag-input-wrapper"});return g.append(o("label",{class:"rui-tag-input-label",for:a},[u])),g.append(p),g}return p}};function ru(t){return k(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,a=d(r.value??r.id??r.name),i=d(r.label,a);return{value:a,label:i}}return{value:"",label:""}}).filter(e=>e.value)}const au={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}],render:(t,e,r)=>{const a=d(e.id),i=ru(e.people),n=C(e.disabled),s=o("div",{class:"rui-mention-input","data-disabled":n?"true":"false"}),l=o("textarea",{class:"rui-mention-input-field",id:a,name:a,rows:String(Math.max(2,Math.floor(P(e.rows,3)))),placeholder:d(e.placeholder,"Type @ to mention someone"),disabled:n?"":null});l.value=d(e.value);const c=t.argMeta?.[2]?.stateRef;c&&r.bindState(l,c,{event:"input",getValue:g=>g.value});const u=o("div",{class:"rui-mention-input-suggestions","data-open":"false"}),p=g=>{u.replaceChildren();const h=i.filter(b=>b.label.toLowerCase().includes(g.toLowerCase())).slice(0,6);if(h.length===0){u.setAttribute("data-open","false");return}u.setAttribute("data-open","true");for(const b of h){const v=o("button",{type:"button",class:"rui-mention-input-option","data-value":b.value},[b.label]);v.onmousedown=y=>y.preventDefault(),v.onclick=()=>{m(b),u.setAttribute("data-open","false")},u.append(v)}},m=g=>{const f=l.value,h=l.selectionStart,b=f.slice(0,h),v=b.lastIndexOf("@");if(v===-1)return;const y=f.slice(h),x=`@${g.label} `,w=b.slice(0,v)+x+y;l.value=w;const T=v+x.length;l.selectionStart=l.selectionEnd=T,l.dispatchEvent(new Event("input",{bubbles:!0})),l.focus()};return l.oninput=()=>{const g=l.selectionStart,f=l.value.slice(0,g),h=/@([\w-]*)$/.exec(f);h?p(h[1]??""):u.setAttribute("data-open","false")},l.onblur=()=>setTimeout(()=>u.setAttribute("data-open","false"),80),s.append(l),s.append(u),s}},iu={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}],render:(t,e,r)=>{const a=d(e.id),i=o("div",{class:"rui-time-picker"}),n=d(e.label);n&&i.append(o("label",{class:"rui-time-picker-label",for:a},[n]));const s=o("input",{type:"time",class:"rui-time-picker-input",id:a,name:a,value:d(e.value),min:d(e.min)||null,max:d(e.max)||null,step:e.step!=null?String(P(e.step,60)):null,disabled:C(e.disabled)?"":null}),l=t.argMeta?.[1]?.stateRef;return l&&r.bindState(s,l),i.append(s),i}},nu={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}],render:(t,e,r)=>{const a=d(e.id),i=o("div",{class:"rui-datetime-picker"}),n=d(e.label);n&&i.append(o("label",{class:"rui-datetime-picker-label",for:a},[n]));const s=o("input",{type:"datetime-local",class:"rui-datetime-picker-input",id:a,name:a,value:d(e.value),min:d(e.min)||null,max:d(e.max)||null,step:e.step!=null?String(P(e.step,60)):null,disabled:C(e.disabled)?"":null}),l=t.argMeta?.[1]?.stateRef;return l&&r.bindState(s,l),i.append(s),i}};function qa(t,e){let r="",a=t;for(const i of e){if(!a)break;if(i==="9"){const n=/\d/.exec(a);if(!n)break;r+=n[0],a=a.slice(a.indexOf(n[0])+1)}else if(i==="A"){const n=/[a-zA-Z]/.exec(a);if(!n)break;r+=n[0],a=a.slice(a.indexOf(n[0])+1)}else i==="*"?(r+=a.charAt(0),a=a.slice(1)):(r+=i,a.startsWith(i)&&(a=a.slice(1)))}return r}const ou={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}],render:(t,e,r)=>{const a=d(e.id),i=d(e.mask),n=C(e.disabled),s=qa(d(e.value),i),l=d(e.label),c=o("input",{type:"text",class:"rui-masked-input",id:a,name:a,value:s,placeholder:d(e.placeholder,i),disabled:n?"":null,autocomplete:"off"}),u=t.argMeta?.[2]?.stateRef;if(c.oninput=()=>{c.value=qa(c.value,i)},u&&r.bindState(c,u,{event:"input",getValue:p=>p.value}),l){const p=o("div",{class:"rui-masked-input-wrapper"});return p.append(o("label",{class:"rui-masked-input-label",for:a},[l])),p.append(c),p}return c}},su={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=o("section",{class:"rui-form-section"}),i=o("header",{class:"rui-form-section-header"});i.append(o("h3",{class:"rui-form-section-label"},[d(e.label)]));const n=d(e.helper);n&&i.append(o("p",{class:"rui-form-section-helper"},[n])),a.append(i);const s=o("div",{class:"rui-form-section-body"});for(const l of k(e.children))s.append(r.renderNode(l));return a.append(s),a}},lu={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=o("fieldset",{class:"rui-fieldset",disabled:C(e.disabled)?"":null});a.append(o("legend",{class:"rui-fieldset-legend"},[d(e.legend)]));const i=d(e.helper);i&&a.append(o("p",{class:"rui-fieldset-helper"},[i]));for(const n of k(e.children))a.append(r.renderNode(n));return a}},cu={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=k(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:d(u.label),message:d(u.message??u.error),field:d(u.field)}}return null}).filter(c=>c!==null&&c.message!=="");if(r.length===0)return o("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const a=d(e.tone,"danger"),i=o("aside",{class:"rui-validation-summary","data-tone":a,role:"alert"}),n=o("div",{class:"rui-validation-summary-title"}),s=L(a==="warning"?"triangle-exclamation":"circle-xmark",{className:"rui-validation-summary-icon"});s&&n.append(s),n.append(document.createTextNode(d(e.title,"Please fix the following:"))),i.append(n);const l=o("ul",{class:"rui-validation-summary-list"});for(const c of r){const u=o("li",{class:"rui-validation-summary-item"});c.label&&u.append(o("strong",{},[`${c.label}: `])),u.append(document.createTextNode(c.message)),l.append(u)}return i.append(l),i}};function uu(t){return k(t).map(e=>{if(!e||typeof e!="object")return{title:d(e),details:"",content:null};const r=e;return{title:d(r.title),details:d(r.details),content:r.content??null}})}const du={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`).",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)'}],render:(t,e,r)=>{const a=uu(e.steps),i=a.length,n=Math.max(0,Math.min(i-1,Math.floor(P(e.current,0)))),s=t.argMeta?.[1]?.stateRef,l=o("div",{class:"rui-multi-step-form"}),c=o("ol",{class:"rui-steps rui-multi-step-form-steps"});a.forEach((v,y)=>{const x=o("li",{class:"rui-steps-item","data-active":y===n?"true":"false","data-complete":y<n?"true":"false"});x.append(o("div",{class:"rui-steps-title"},[v.title||`Step ${y+1}`])),v.details&&x.append(o("div",{class:"rui-steps-details"},[v.details])),c.append(x)}),l.append(c);const u=o("div",{class:"rui-multi-step-form-body"}),p=a[n];p&&p.content&&u.append(r.renderNode(p.content)),l.append(u);const m=o("div",{class:"rui-multi-step-form-footer"}),g=o("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:n<=0?"":null},[d(e.prevLabel,"Back")]);s&&n>0&&(g.onclick=()=>r.setState(s,n-1));const f=n>=i-1,h=f?d(e.submitLabel,"Submit"):d(e.nextLabel,"Continue"),b=o("button",{type:"button",class:"rui-button","data-variant":"primary"},[h]);return b.onclick=()=>{f?r.invoke(e.onSubmit):s&&r.setState(s,n+1)},m.append(g),m.append(o("span",{class:"rui-multi-step-form-progress"},[`${n+1} / ${i}`])),m.append(b),l.append(m),l}};function pu(t){return k(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:d(r.title),message:d(r.message),time:d(r.time),icon:d(r.icon),tone:d(r.tone,"default"),unread:C(r.unread),avatarSrc:d(r.avatarSrc),action:r.action}}).filter(e=>e!==null)}const mu={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?, action?}` objects. 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=pu(e.items),i=a.filter(c=>c.unread),n=a.filter(c=>!c.unread),s=o("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&i.length>0){const c=o("div",{class:"rui-inbox-panel-toolbar"}),u=o("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);u.onclick=()=>r.invoke(e.onMarkAllRead),c.append(u),s.append(c)}if(a.length===0)return s.append(o("div",{class:"rui-inbox-panel-empty"},[d(e.emptyLabel,"You're all caught up.")])),s;const l=(c,u)=>{if(u.length===0)return;const p=o("section",{class:"rui-inbox-panel-group"}),m=o("header",{class:"rui-inbox-panel-group-head"});m.append(o("span",{class:"rui-inbox-panel-group-label"},[c])),m.append(o("span",{class:"rui-inbox-panel-group-count"},[String(u.length)])),p.append(m);for(const g of u){const f=Sa.render({__kind:"Component",name:"Notification",args:[],argMeta:[]},{title:g.title,message:g.message,time:g.time,icon:g.icon,tone:g.tone,avatarSrc:g.avatarSrc,unread:g.unread},r);typeof g.action=="function"&&(f.setAttribute("data-clickable","true"),f.onclick=()=>r.invoke(g.action)),p.append(f)}s.append(p)};return l(`Unread (${i.length})`,i),l("Earlier",n),s}};function gu(t){return k(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:d(r.title),description:d(r.description),done:C(r.done),action:r.action,cta:d(r.cta,"Start")}}).filter(e=>e!==null)}const fu={name:"OnboardingChecklist",description:'Step-by-step product checklist with completion progress at the top. Pass `items` as `{title, description?, done?, action?, cta?}` objects. 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=gu(e.items),i=a.filter(m=>m.done).length,n=Math.max(1,a.length),s=Math.round(i/n*100),l=o("div",{class:"rui-onboarding-checklist"}),c=o("header",{class:"rui-onboarding-checklist-header"});c.append(o("h3",{class:"rui-onboarding-checklist-title"},[d(e.title,"Getting started")]));const u=d(e.subtitle);u&&c.append(o("p",{class:"rui-onboarding-checklist-subtitle"},[u])),c.append(o("div",{class:"rui-onboarding-checklist-progress"},[o("div",{class:"rui-onboarding-checklist-bar"},[o("div",{class:"rui-onboarding-checklist-fill",style:`width:${s}%`})]),o("span",{class:"rui-onboarding-checklist-meta"},[`${i}/${a.length} complete`])])),l.append(c);const p=o("ol",{class:"rui-onboarding-checklist-list"});for(const m of a){const g=o("li",{class:"rui-onboarding-checklist-item","data-done":m.done?"true":"false"}),f=o("span",{class:"rui-onboarding-checklist-marker"}),h=L(m.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});h&&f.append(h),g.append(f);const b=o("div",{class:"rui-onboarding-checklist-body"});if(b.append(o("div",{class:"rui-onboarding-checklist-item-title"},[m.title])),m.description&&b.append(o("p",{class:"rui-onboarding-checklist-item-description"},[m.description])),g.append(b),!m.done&&typeof m.action=="function"){const v=o("button",{type:"button",class:"rui-button","data-variant":"secondary","data-size":"sm"},[m.cta]);v.onclick=()=>r.invoke(m.action),g.append(v)}p.append(g)}return l.append(p),l}};function Ha(t){const e=o("div",{class:`rui-${t.klass}`});if(t.iconName){const a=L(t.iconName,{className:t.iconClass});a&&e.append(a)}t.title&&e.append(o("h3",{class:`rui-${t.klass}-title`},[t.title])),t.description&&e.append(o("p",{class:`rui-${t.klass}-description`},[t.description]));const r=k(t.actions);if(r.length>0){const a=o("div",{class:`rui-${t.klass}-actions`});for(const i of r)a.append(t.helpers.renderNode(i));e.append(a)}return e}const hu={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=o("div",{class:"rui-loading-state"}),a=o("span",{class:"rui-spinner","data-size":"lg","data-tone":"primary"});a.append(o("span",{class:"rui-spinner-ring","aria-hidden":"true"})),r.append(a),r.append(o("h3",{class:"rui-loading-state-title"},[d(e.title,"Loading…")]));const i=d(e.description);return i&&r.append(o("p",{class:"rui-loading-state-description"},[i])),r}},bu={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)=>Ha({klass:"error-state",iconName:d(e.icon,"circle-exclamation"),iconClass:"rui-error-state-icon",title:d(e.title,"Something went wrong"),description:d(e.description),actions:e.actions,helpers:r})},vu={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)=>Ha({klass:"success-state",iconName:d(e.icon,"circle-check"),iconClass:"rui-success-state-icon",title:d(e.title),description:d(e.description),actions:e.actions,helpers:r})},yu={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=k(e.steps).map(v=>{if(!v||typeof v!="object")return{title:d(v),description:"",target:""};const y=v;return{title:d(y.title),description:d(y.description),target:d(y.target)}}),i=e.open===void 0?!0:C(e.open),n=a.length,s=Math.max(0,Math.min(n-1,Math.floor(P(e.current,0)))),l=t.argMeta?.[1]?.stateRef,c=o("div",{class:"rui-tour","data-open":i?"true":"false"});if(!i||n===0)return c;const u=a[s];if(!u)return c;const p=o("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});p.append(o("div",{class:"rui-tour-step"},[`Step ${s+1} of ${n}`])),p.append(o("h3",{class:"rui-tour-title"},[u.title])),u.description&&p.append(o("p",{class:"rui-tour-description"},[u.description])),u.target&&p.append(o("div",{class:"rui-tour-target"},[`Target: ${u.target}`]));const m=o("div",{class:"rui-tour-footer"}),g=o("button",{type:"button",class:"rui-button","data-variant":"ghost"},["Skip"]);g.onclick=()=>r.invoke(e.onComplete);const f=o("button",{type:"button",class:"rui-button","data-variant":"secondary",disabled:s<=0?"":null},["Back"]);l&&s>0&&(f.onclick=()=>r.setState(l,s-1));const h=s>=n-1,b=o("button",{type:"button",class:"rui-button","data-variant":"primary"},[h?"Finish":"Next"]);return b.onclick=()=>{h?r.invoke(e.onComplete):l&&r.setState(l,s+1)},m.append(g,f,b),p.append(m),c.append(p),c}},xu={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:C(e.open),i=o("div",{class:"rui-spotlight","data-open":a?"true":"false"});if(!a)return i;const n=o("div",{class:"rui-spotlight-card"});n.append(o("h3",{class:"rui-spotlight-title"},[d(e.title)]));const s=d(e.description);s&&n.append(o("p",{class:"rui-spotlight-description"},[s]));const l=k(e.actions);if(l.length>0){const u=o("div",{class:"rui-spotlight-actions"});for(const p of l)u.append(r.renderNode(p));n.append(u)}const c=t.argMeta?.[1]?.stateRef;return c&&(i.onclick=u=>{u.target===i&&r.setState(c,!1)}),i.append(n),i}},wu={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=d(e.side,"top"),i=ee(e.offset,"0"),n=Math.max(0,Math.floor(P(e.zIndex,10))),s=`position:sticky;${a}:${i};z-index:${n};`,l=o("div",{class:"rui-sticky",style:s});for(const c of k(e.children))l.append(r.renderNode(c));return l}},ku={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=ee(e.initialPrimaryWidth,"40%"),i=ee(e.minPrimaryWidth,"240px"),n=o("div",{class:"rui-resizable-panels",style:`--rui-resizable-primary:${a};--rui-resizable-min:${i};`}),s=o("div",{class:"rui-resizable-panel rui-resizable-panel-primary"});for(const u of k(e.primary))s.append(r.renderNode(u));const l=o("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),c=o("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const u of k(e.secondary))c.append(r.renderNode(u));return n.append(s,l,c),l.onpointerdown=u=>{const p=u,m=p.currentTarget;m.setPointerCapture(p.pointerId);const g=m.closest(".rui-resizable-panels");if(!g)return;const f=g.getBoundingClientRect(),h=v=>{const y=(v.clientX-f.left)/f.width*100,x=Math.max(15,Math.min(85,y));g.style.setProperty("--rui-resizable-primary",`${x}%`)},b=v=>{m.releasePointerCapture(v.pointerId),m.removeEventListener("pointermove",h),m.removeEventListener("pointerup",b)};m.addEventListener("pointermove",h),m.addEventListener("pointerup",b)},n}},Su={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(P(e.columns,3)))),i=d(e.gap,"m"),n=o("div",{class:"rui-masonry-grid","data-columns":String(a),"data-gap":i});for(const s of k(e.items))n.append(r.renderNode(s));return n}},Cu={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).",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"}],render:(t,e,r)=>{const a=C(e.open),i=d(e.side,"right"),n=o("div",{class:"rui-sheet-overlay","data-open":a?"true":"false","data-side":i}),s=o("aside",{class:"rui-sheet",role:"dialog","aria-modal":"true","data-side":i}),l=o("header",{class:"rui-sheet-header"});l.append(o("h3",{class:"rui-sheet-title"},[d(e.title)]));const c=o("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),u=t.argMeta?.[1]?.stateRef;u&&(c.onclick=()=>r.setState(u,!1),n.onclick=g=>{g.target===n&&r.setState(u,!1)}),l.append(c),s.append(l);const p=o("div",{class:"rui-sheet-body"});for(const g of k(e.children))p.append(r.renderNode(g));s.append(p);const m=k(e.footer);if(m.length>0){const g=o("footer",{class:"rui-sheet-footer"});for(const f of m)g.append(r.renderNode(f));s.append(g)}return n.append(s),n}},Tu={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=o("header",{class:"rui-topbar","data-sticky":C(e.sticky)?"true":"false"}),i=o("div",{class:"rui-topbar-side rui-topbar-left"}),n=d(e.title);if(n){const c=o("div",{class:"rui-topbar-title-block"});c.append(o("h2",{class:"rui-topbar-title"},[n]));const u=d(e.subtitle);u&&c.append(o("p",{class:"rui-topbar-subtitle"},[u])),i.append(c)}for(const c of k(e.left))i.append(r.renderNode(c));a.append(i);const s=k(e.center);if(s.length>0){const c=o("div",{class:"rui-topbar-side rui-topbar-center"});for(const u of s)c.append(r.renderNode(u));a.append(c)}const l=o("div",{class:"rui-topbar-side rui-topbar-right"});for(const c of k(e.right))l.append(r.renderNode(c));return a.append(l),a}},$u={name:"Theme",description:"Apply a partial theme on top of the base theme. Pass an object of token → value pairs (colors, fonts, radii, spacing, button styling). Assigning the result to a top-level binding (conventionally `theme`) lets the runtime detect it and write the tokens to the host as CSS custom properties — the rest of the rendered UI picks them up instantly.",props:[{name:"tokens",type:"any",description:"Object literal of theme tokens. Keys must match `ThemeTokens` (e.g. colorPrimary, colorBg, fontFamily, fontFamilyHeading, fontSizeBase, radiusMd, radiusButton, borderWidth, shadowMd, buttonFontWeight, …). Unknown keys are ignored."}],render:()=>document.createDocumentFragment()},Nu={name:"NavLink",description:'Anchor that navigates to a route on click and stays in sync with the URL hash. Reflects `data-active="true"` 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=d(e.label,""),i=d(e.to,"/"),n=d(e.variant,"default"),s=C(e.exact,!1),l=r.router,c=l.getPath(),u=c?s?c===i:i==="/"?c==="/":c===i?!0:c.startsWith(i+"/"):!1,p=o("a",{class:"rui-nav-link","data-variant":n,"data-active":u?"true":"false",href:"#"+(i.startsWith("/")?i:"/"+i)}),m=L(e.icon,{className:"rui-nav-link-icon"});return m&&p.append(m),p.append(o("span",{class:"rui-nav-link-label"},[a])),p.onclick=g=>{g.defaultPrevented||g.button===0&&(g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(g.preventDefault(),l.navigate(i)))},p}},Au=["primary","secondary","ghost","danger"],Mu=["xs","sm","md","lg","xl","small","normal","large"];function Pu(t){const e=d(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 Iu(t){return k(t).map(e=>{if(e&&typeof e=="object"){const a=e,i=d(a.value??a.label);return{value:i,label:d(a.label,i)}}const r=d(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function pt(t){return k(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function zu(t){return k(t).map(e=>{if(e&&typeof e=="object"){const a=e,i=d(a.value??a.label);return{value:i,label:d(a.label,i),group:d(a.group)||void 0,shortcut:d(a.shortcut)||void 0,action:a.action}}const r=d(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function Va(t){return k(t).map(e=>{if(e&&typeof e=="object"){const a=e,i=d(a.name??a.label);return{name:i,label:d(a.label,i),type:d(a.type,"text")||"text"}}const r=d(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function Ru(t){return pt(t).map((e,r)=>({id:d(e.id,`task-${r}`),label:d(e.label??e.name,`Task ${r+1}`),start:d(e.start),end:d(e.end),progress:e.progress!=null?P(e.progress,0):void 0}))}function Ne(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function Lu(t,e){const r=t.split(`
12
+ `;return{programText:t+n+e.source.trim()+`
13
+ `}}case"delete":{const a=Kt(r,e.binding);return a<0?{programText:t,warning:`delta(delete): binding "${e.binding}" not found — op skipped`}:{programText:Yt(t,r,a,null)}}case"replace":{const a=Kt(r,e.binding);return a<0?{programText:t,warning:`delta(replace): binding "${e.binding}" not found — op skipped`}:$e(`${e.binding} = ${e.source}`).errors.length>0?{programText:t,warning:`delta(replace): could not parse new source for "${e.binding}" — op skipped`}:{programText:Yt(t,r,a,`${e.binding} = ${e.source.trim()}`)}}case"append":{const a=Kt(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=$e(`__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 "${fa(e.item)}" — op skipped`};const s=n.expression.elements,u=`${e.binding} = [${[...s.map(me),e.item.trim()].join(", ")}]`;return{programText:Yt(t,r,a,u)}}}}function Kt(t,e){return t.statements.findIndex(r=>co(r)===e)}function co(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function Yt(t,e,r,a){const n=t.split(`
14
+ `),i=e.statements[r],o=e.statements[r+1],s=(i.loc?.line??1)-1,u=o?(o.loc?.line??n.length+1)-1:n.length,c=n.slice(0,s),m=n.slice(u);return a===null?[...c,...m].join(`
15
+ `):[...c,a,...m].join(`
16
+ `)}function me(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(me).join(", ")})`;case"MethodCall":return`${me(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(me).join(", ")})`;case"Array":return`[${t.elements.map(me).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${me(e.value)}`:`${e.key}: ${me(e.value)}`).join(", ")} }`;case"Member":{const e=me(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${me(t.computed)}]`:e}case"Binary":return`${me(t.left)} ${t.operator} ${me(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(me(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function fa(t){return t.length>40?`${t.slice(0,37)}...`:t}const ga=new WeakMap;function uo(t){let e=ga.get(t.components);if(!e){e=new Map;for(const r of t.components)r?.name&&e.set(r.name,r);ga.set(t.components,e)}return e}function ha(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 Ne(t,e){return uo(t).get(e)}function Xt(t){const e=t.props.findIndex(r=>r.positional===!0);return e>=0?e:t.props.length>0?0:-1}function Jt(t){const e=Xt(t);return e>=0?t.props[e]:void 0}function ba(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 va(t,e){const r={};return t.props.forEach((a,n)=>{n<e.length&&(r[a.name]=e[n])}),r}function po(t,e){const r=$e(t),a=Zt(r,e);return a.length>0&&(r.errors=[...r.errors,...a]),r}function Zt(t,e){const r=[];for(const a of t.statements)se(a,e,r);return r}function se(t,e,r){switch(t.kind){case"Assignment":H(t.expression,e,r);return;case"ExpressionStatement":H(t.expression,e,r);return;case"ComponentDeclaration":case"ActionDeclaration":case"EffectDeclaration":case"HookDeclaration":for(const a of t.body.body)se(a,e,r);return;case"Return":t.argument&&H(t.argument,e,r);return;case"Await":H(t.argument,e,r);return;case"IfStatement":H(t.test,e,r);for(const a of t.consequent.body)se(a,e,r);if(t.alternate)if(t.alternate.kind==="IfStatement")se(t.alternate,e,r);else for(const a of t.alternate.body)se(a,e,r);return;case"SwitchStatement":H(t.discriminant,e,r);for(const a of t.cases){a.test&&H(a.test,e,r);for(const n of a.body)se(n,e,r)}return;case"ForOfStatement":H(t.iterable,e,r);for(const a of t.body.body)se(a,e,r);return;case"ForClassicStatement":t.init&&se(t.init,e,r),t.test&&H(t.test,e,r),t.update&&H(t.update,e,r);for(const a of t.body.body)se(a,e,r);return;case"WhileStatement":case"DoWhileStatement":H(t.test,e,r);for(const a of t.body.body)se(a,e,r);return;case"ForInStatement":H(t.iterable,e,r);for(const a of t.body.body)se(a,e,r);return;case"DestructureStatement":H(t.expression,e,r);for(const a of t.bindings)a.defaultValue&&H(a.defaultValue,e,r);return;case"TryStatement":for(const a of t.block.body)se(a,e,r);if(t.catchBlock)for(const a of t.catchBlock.body)se(a,e,r);if(t.finallyBlock)for(const a of t.finallyBlock.body)se(a,e,r);return;case"ThrowStatement":H(t.argument,e,r);return;default:return}}function H(t,e,r){if(t)switch(t.kind){case"Call":{fo(t,e,r);for(const a of t.arguments)H(a,e,r);return}case"MethodCall":{H(t.object,e,r);for(const a of t.arguments)H(a,e,r);return}case"BuiltinCall":{for(const a of t.arguments)H(a,e,r);return}case"Array":for(const a of t.elements)H(a,e,r);return;case"Object":for(const a of t.properties)H(a.value,e,r);return;case"Template":for(const a of t.expressions)H(a,e,r);return;case"Binary":H(t.left,e,r),H(t.right,e,r);return;case"Unary":H(t.argument,e,r);return;case"Ternary":H(t.test,e,r),H(t.consequent,e,r),H(t.alternate,e,r);return;case"Member":H(t.object,e,r),t.computed&&H(t.computed,e,r);return;case"Spread":H(t.argument,e,r);return;case"Invoke":t.callee.kind==="StateRef"&&t.callee.name==="theme"&&ya(t,r),H(t.callee,e,r);for(const a of t.arguments)H(a,e,r);return;case"New":H(t.callee,e,r);for(const a of t.arguments)H(a,e,r);return;case"Lambda":if(t.body.kind==="Block")for(const a of t.body.body)se(a,e,r);else H(t.body,e,r);return;case"Block":for(const a of t.body)se(a,e,r);return;default:return}}const mo={Script:'Script("id", body, deps?) is not supported. Use `$effect(() => { … }, [deps])` (see §9 — effect declarations).',Action:'Action([@Set, @Run, …]) payloads are removed in 0.5. Use `function name() { … }` declarations and reference them by name (e.g. `Button("Save", { action: save })`) — see §10.',Routes:'Routes(items, default?) is removed in 0.5. Use `pages = $router({ "/": Home(), default: NotFound() })` (see §12 — outlet-first router).',Route:'Route(path, content) is only valid inside a v1 `Routes(...)` outlet, which has been removed. Use `"/path": content` arms inside a `$router({ … })` call (see §12).',Query:'Query("name", args, placeholder, refreshSec?) is removed in 0.5. Declare a top-level `query <Name>(args) { url, method, … }` block and bind it with `$query foo = <Name>(args)` (see §11.2).',Mutation:'Mutation("name", args) is removed in 0.5. Declare a top-level `mutation <Name>(args) { url, method, body, … }` block and bind it with `$mutation save = <Name>` (see §11.3).',NavLinkRoute:'NavLinkRoute is removed in 0.5. Use `NavLink(label, { to: "/path" })` (see §12 — Outlet-first router).',useInstanceState:"useInstanceState(...) is removed in 0.5. Declare per-instance state inside the component body with `$state name = init` — identity is content-addressed (§13)."};function fo(t,e,r){const a=mo[t.callee];if(a){r.push({message:`${t.callee}(...) — ${a}`,line:t.loc?.line??0,column:t.loc?.column??0});return}if(t.callee==="Theme"){ya(t,r);return}const n=Ne(e,t.callee);if(!n)return;const i=new Set;for(const d of n.props)if(i.add(d.name),d.aliases)for(const f of d.aliases)i.add(f);i.add("key");const o=t.arguments;let s=-1;for(let d=o.length-1;d>=0;d-=1)if(o[d].kind==="Object"){s=d;break}const u=s>=0?o[s]:null,c=[];for(let d=0;d<o.length;d++)d!==s&&c.push(o[d]);if(c.length>1){const f=Jt(n)?.name??"(none)",g=go(o,u),h=n.props.filter(v=>v.name!==f&&!g.has(v.name)).slice(0,c.length-1).map(v=>v.name),b=h.length>0?h.map(v=>`${v}: …`).join(", "):"use a trailing { prop: value } object";r.push({message:`${t.callee}(...) — Aktion 0.5 §19.1 allows at most one positional argument (the "${f}" 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 m=[];if(u)for(const d of u.properties)d.spread||m.push({name:d.key,value:d.value,loc:d.value.loc??u.loc});for(const d of m){if(!i.has(d.name)){r.push({message:`Unknown prop "${d.name}" on <${t.callee}>. Known props: ${n.props.map(g=>g.name).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0});continue}const f=n.props.find(g=>g.name===d.name||(g.aliases?.includes(d.name)??!1));if(f?.enum&&d.value.kind==="Literal"&&typeof d.value.value=="string"){const g=d.value.value;f.enum.includes(g)||r.push({message:`<${t.callee}> ${d.name}="${g}" — must be one of ${f.enum.map(h=>`"${h}"`).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0})}}}function go(t,e){const r=new Set;if(e)for(const a of e.properties)a.spread||r.add(a.key);return r}const ho=new Set(["colors","radius","font","motion","elevation"]),bo=new Set(["name","direction"]);function ya(t,e){const r=t.arguments[0];if(!(!r||r.kind!=="Object"))for(const a of r.properties){if(a.spread||ho.has(a.key)||bo.has(a.key))continue;const n=vo(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 vo(t){const e=[{prefix:"color",group:"colors"},{prefix:"radius",group:"radius"},{prefix:"font",group:"font"},{prefix:"motion",group:"motion"},{prefix:"elevation",group:"elevation"}];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: {...}, motion: {...}, elevation: {...} })"}const bt={name:"aktion",atoms:["true","false","null","undefined"],keywords:["function","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:"Reserved entry-point binding — the root of the rendered UI tree.",syntax:"aktion = Component(...)",example:'aktion = 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 }))'},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(() => {
17
+ $now = $util.now()
18
+ }, ["every(1000)"])`},if:{summary:"Conditional statement — run a block when a condition is truthy.",syntax:"if (condition) { ... } else { ... }",example:`if (!$user) {
19
+ return Spinner()
20
+ }`},else:{summary:"Fallback branch executed when the matching `if` condition is falsy.",syntax:"if (condition) { ... } else { ... }",example:"if ($ok) { return Done() } else { return Retry() }"},switch:{summary:"Multi-way branch on a value — pair each arm with `case` / `default`.",syntax:"switch (value) { case x: ...; default: ... }",example:`switch (tab) {
21
+ case "list": return List()
22
+ default: return Empty()
23
+ }`},case:{summary:"A labelled arm inside a `switch` statement.",syntax:"case value: statements; break",example:'case "grid": return Grid($items)'},break:{summary:"Exit the nearest enclosing loop or `switch` immediately.",syntax:"break",example:`for (let i = 0; i < n; i++) {
24
+ if (done) break
25
+ }`},continue:{summary:"Skip to the next iteration of the nearest enclosing loop.",syntax:"continue",example:`for (let x of items) {
26
+ if (!x.ok) continue
27
+ }`},for:{summary:"Loop — classic `for`, `for…of` (values), or `for…in` (keys).",syntax:"for (let i = 0; i < n; i++) { ... }",example:`for (let item of $items) {
28
+ log(item)
29
+ }`},while:{summary:"Loop while a condition stays truthy (checked before each pass).",syntax:"while (condition) { ... }",example:`while (i > 0) {
30
+ i = i - 1
31
+ }`},do:{summary:"Run a block once, then repeat while a condition holds.",syntax:"do { ... } while (condition)",example:`do {
32
+ step()
33
+ } while (hasMore)`},of:{summary:"Iterate the VALUES of an array/iterable in a `for…of` loop.",syntax:"for (let item of iterable) { ... }",example:"for (let row of $rows) { render(row) }"},in:{summary:"Iterate the KEYS of an object (`for…in`) or test key membership.",syntax:'for (let key in obj) { ... } · "key" in obj',example:"for (let k in $config) { use(k) }"},let:{summary:"Declare a block-scoped mutable variable (supports destructuring).",syntax:"let name = value · let [a, b] = arr · let { x } = obj",example:"let { name, age = 0 } = $user"},var:{summary:"Declare a variable (function-scoped) — `let` is preferred.",syntax:"var name = value",example:"var total = 0"},const:{summary:"Declare a block-scoped constant binding (supports destructuring).",syntax:"const name = value",example:"const [first, ...rest] = $items"},await:{summary:"Await a promise inside an action/effect body (or expression).",syntax:"await expression",example:'let res = await $http({ url: "https://api.example.com" })'},async:{summary:"Marks a function as async — accepted as a no-op modifier.",syntax:"async function name() { ... }",example:`async function load() {
34
+ let data = await fetch()
35
+ }`},return:{summary:"Return a value from a component / action / helper body.",syntax:"return expression",example:'return Card({ title: "Done" })'},default:{summary:"The fallback arm of a `switch` (or wildcard route in Router).",syntax:"default: statements",example:"default: return NotFound()"},try:{summary:"Run code that may throw, handling errors in a `catch` block.",syntax:"try { ... } catch (e) { ... } finally { ... }",example:`try {
36
+ risky()
37
+ } catch (e) {
38
+ log(e)
39
+ }`},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 wa(t=bt){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+)?/,u=new Set([...t.operators.join(""),..."=<>!&|"]),c=(d,f)=>{for(;!d.eol();){const g=d.next();if(!g)return;if(g==="\\"){d.next();continue}if(g===f)return}};return{startState:e,copyState:r,token:(d,f)=>{if(f.inBacktick){for(;!d.eol();){const h=d.next();if(h==="\\"){d.next();continue}if(h==="`")return f.inBacktick=!1,"string"}return"string"}if(f.inBlockComment){for(;!d.eol();){if(d.match(t.comments.blockEnd,!0))return f.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(f.inBlockComment=!0;!d.eol();){if(d.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";d.next()}return"comment"}const g=d.peek();if(g==null)return null;if(t.strings.singleLineQuotes.includes(g)){const h=g;return d.next(),c(d,h),"string"}if(g===t.strings.multiLineQuote){for(d.next();!d.eol();){const h=d.next();if(h==="\\"){d.next();continue}if(h==="`")return"string"}return f.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 b=d.match(o,!0);if(b){const v=b[0];return a.has(v)?"atom":n.has(v)?"keyword":d.peek()==="."?"loopvar":"identifier"}}for(const h of t.operatorsLong)if(d.match(h,!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"):u.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 ka={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},Sa={},Ca=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");function $a(t,e){return e.length===0?t:`${t}.${e.join(".")}`}function Ta(t,e){return!!(t===e||e.startsWith(t+".")||t.startsWith(e+"."))}function Qt(t,e){if(t.has(e))return!0;for(const r of t)if(Ta(r,e))return!0;return!1}function vt(t,e){for(const r of e)if(Qt(t,r))return!0;return!1}class Aa{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=rt(n,r,0,a);this.values.set(e,i),this.enqueueChange($a(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 rt(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]=rt(t[i],e,r+1,a),s}if(t&&typeof t=="object"&&!Array.isArray(t)){const s={...t};return s[n]=rt(t[n],e,r+1,a),s}if(i!==null){const s=[];return s[i]=rt(void 0,e,r+1,a),s}const o={};return o[n]=rt(void 0,e,r+1,a),o}const Na=Symbol("aktion.httpResource");function Ma(t){return typeof t=="object"&&t!==null&&t[Na]===!0}class Pa{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=yo(r.body,r.headers));const s=await i(r.url,o),u={};s.headers.forEach((d,f)=>{u[f]=d});const c=u["content-type"]??"";let m;return s.status===204||r.method==="HEAD"?m=null:c.includes("application/json")?m=await s.json().catch(()=>null):m=await s.text().catch(()=>""),{status:s.status,headers:u,body:m}};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 yo(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 xo=new Set(["url","method","headers","body","query","signal"]);function wo(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[u,c]of Object.entries(e.headers))c!=null&&(n[u]=String(c));let i=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const u=new URLSearchParams;for(const[m,d]of Object.entries(e.query))d!=null&&u.append(m,String(d));const c=u.toString();c&&(i+=(i.includes("?")?"&":"?")+c)}const o={};for(const[u,c]of Object.entries(e))xo.has(u)||(o[u]=c);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 Ia(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,Na,{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 u=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 c=wo(t);c.url=e.http.resolveUrl(c.url),c.signal=u.signal;const m=await e.http.request(c);if(s!==n)return;m.status>=200&&m.status<300?(r.data=m.body,r.state="data",r.error=void 0):(r.error={status:m.status,body:m.body},r.state="error"),r.status=m.status,r.headers=m.headers,r.lastUpdated=Date.now()}catch(c){if(s!==n||c?.name==="AbortError")return;r.error=c,r.state="error"}finally{if(s===n&&(r.loading=!1,i(),typeof r.onDone=="function"))try{r.onDone(r)}catch(c){console.error("[aktion] Http onDone callback threw",c)}}};return o(),r}function La(t={}){const e=ko(t.translations),r=typeof t.defaultLanguage=="string"?t.defaultLanguage:"";let a=typeof t.currentLanguage=="string"&&t.currentLanguage?t.currentLanguage:r;function n(s,u){if(typeof s!="string"||!s)return"";const c=e[s];let m;return c&&(a&&typeof c[a]=="string"?m=c[a]:r&&typeof c[r]=="string"&&(m=c[r])),m===void 0?s:So(m,u)}function i(s){typeof s!="string"||!s||(a=s)}function o(){return a}return{t:n,setCurrentLanguage:i,getCurrentLanguage:o}}function ko(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 So(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,le=t=>Array.isArray(t)?t:[],za=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Ra=(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)}default:return!1}},Ge=(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]}},je=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},Co=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],$o=["January","February","March","April","May","June","July","August","September","October","November","December"],To=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ao=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],No=(t,e)=>{const r=(s,u=2)=>String(s).padStart(u,"0"),a=t.getHours(),n=(a+11)%12+1,i=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,$o[t.getMonth()]],[/MMM/g,Co[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,Ao[t.getDay()]],[/ddd/g,To[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,u]of i)o=o.replace(s,u);return o},Mo=(t,e=Date.now())=>{const r=e-t.getTime(),a=Math.abs(r),n=r<0,i=6e4,o=60*i,s=24*o,u=7*s,c=30*s,m=365*s;let d,f;return a<i?n?"in a moment":"just now":(a<o?(d=Math.round(a/i),f="m"):a<s?(d=Math.round(a/o),f="h"):a<u?(d=Math.round(a/s),f="d"):a<c?(d=Math.round(a/u),f="w"):a<m?(d=Math.round(a/c),f="mo"):(d=Math.round(a/m),f="y"),n?`in ${d}${f}`:`${d}${f} ago`)},Po=(t,e,r)=>{if(za(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},Io=(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("")},Lo={count:t=>le(t).length,sum:t=>le(t).reduce((e,r)=>e+W(r),0),avg:t=>{const e=le(t);return e.length===0?0:e.reduce((r,a)=>r+W(a),0)/e.length},min:t=>{const e=le(t).map(W);return e.length===0?0:Math.min(...e)},max:t=>{const e=le(t).map(W);return e.length===0?0:Math.max(...e)},first:t=>le(t)[0]??null,last:t=>{const e=le(t);return e.length===0?null:e[e.length-1]},filter:(t,e="",r="==",a)=>le(t).filter(n=>Ra(r,Ge(n,String(e)),a)),find:(t,e="",r="==",a)=>le(t).find(n=>Ra(r,Ge(n,String(e)),a))??null,sort:(t,e="",r="asc")=>{const a=[...le(t)],n=String(r).toLowerCase()==="desc"?-1:1;return a.sort((i,o)=>{const s=Ge(i,String(e)),u=Ge(o,String(e));return typeof s=="number"&&typeof u=="number"?(s-u)*n:String(s??"").localeCompare(String(u??""))*n}),a},groupBy:(t,e="")=>{const r={};for(const a of le(t)){const n=String(Ge(a,String(e))??"");(r[n]??(r[n]=[])).push(a)}return r},slice:(t,e,r)=>{const a=le(t);return a.slice(e??0,r??a.length)},unique:(t,e)=>{const r=le(t);if(!e)return Array.from(new Set(r));const a=new Set,n=[];for(const i of r){const o=Ge(i,e);a.has(o)||(a.add(o),n.push(i))}return n},reverse:t=>[...le(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>yt)throw new RangeError(`$util.range refusing to allocate ${s} entries (limit ${yt}).`);const u=[];if(i>0)for(let c=a;c<=n;c+=i)u.push(c);else for(let c=a;c>=n;c+=i)u.push(c);return u},repeat:(t,e)=>{const r=Math.max(0,W(e));if(r>yt)throw new RangeError(`$util.repeat refusing to allocate ${r} entries (limit ${yt}).`);return Array.from({length:r},()=>t)},pick:(t,e)=>{if(!za(t))return{};const r=le(e).map(n=>String(n??"")),a={};for(const n of r)n in t&&(a[n]=t[n]);return a},format:(t,e="number",r,a)=>{const n=W(t),i=String(e),o=Po(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=je(t),a=String(e);switch(a){case"relative":return Mo(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 No(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 Io(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=je(t),a=new Date(r.getTime());return a.setDate(a.getDate()+W(e)),a.toISOString()},addHours:(t,e)=>{const r=je(t);return new Date(r.getTime()+W(e)*36e5).toISOString()},diffDays:(t,e)=>{const r=je(t),a=je(e);return Math.round((a.getTime()-r.getTime())/864e5)},startOfWeek:t=>{const e=je(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=je(t);return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999).toISOString()},join:(t,e=",")=>le(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))},yt=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 Ea(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 u=0;u<n.length;u+=1){const c=n[u];if(c==="*"){s=!0;const d=i.slice(u).join("/");return o._=d,{matched:!0,params:o,wildcard:s}}const m=i[u];if(m===void 0)return{matched:!1,params:{}};if(c.startsWith(":")){const d=c.slice(1);if(!d)return{matched:!1,params:{}};o[d]=decodeURIComponent(m);continue}if(c!==m)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 ja{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,"settingHash",!1);this.defaultPath=De(e.defaultPath??"/"),this.currentPath=this.defaultPath}start(){if(this.enabled||(this.enabled=!0,typeof window>"u"))return;const e=a=>{if(this.settingHash)return;const n=De(window.location.hash);this.setPath(n,a)},r=()=>e("hashchange");window.addEventListener("hashchange",r),this.hashListener=r,e("init")}stop(){this.enabled&&(this.enabled=!1,typeof window<"u"&&this.hashListener&&window.removeEventListener("hashchange",this.hashListener),this.hashListener=null)}getPath(){return this.currentPath}getParams(){return this.currentParams}getActivePattern(){return this.currentPattern}setActiveMatch(e,r){this.currentPattern=e,zo(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{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 zo(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 Me=(t,e)=>{try{return t()}catch{return e}},Da=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)}},Ba=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},Fa=t=>({set:(e,r)=>Me(()=>{const a=t();return a?(a.setItem(String(e),Da(r)),!0):!1},!1),get:e=>Me(()=>{const r=t();return r?Ba(r.getItem(String(e))):null},null),remove:e=>Me(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>Me(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),Ro=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,Eo=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,xt=()=>typeof globalThis>"u"?null:globalThis.document??null,jo=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},er=(t={})=>{const e=[],r=jo(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("; ")}`},Oa=()=>{const t=xt();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},Do={set:(t,e,r)=>Me(()=>{const a=xt();if(!a)return!1;const n=encodeURIComponent(String(t)),i=encodeURIComponent(Da(e));return a.cookie=`${n}=${i}${er(r)}`,!0},!1),get:t=>Me(()=>{const r=Oa()[String(t)];return r===void 0?null:Ba(r)},null),remove:(t,e)=>Me(()=>{const r=xt();if(!r)return!1;const a=encodeURIComponent(String(t)),n={...e,expires:new Date(0),maxAge:0};return r.cookie=`${a}=${er(n)}`,!0},!1),clear:()=>Me(()=>{const t=xt();if(!t)return!1;const e=Oa();for(const r of Object.keys(e)){const a=encodeURIComponent(r);t.cookie=`${a}=${er({expires:new Date(0),maxAge:0})}`}return!0},!1)},at=Fa(Ro),Bo=Fa(Eo),tr={set:at.set,get:at.get,remove:at.remove,clear:at.clear,local:at,session:Bo,cookies:Do},Fo=["log","error","warn","info","debug"],Oo=()=>typeof globalThis>"u"?null:globalThis.console??null,_o=t=>(...e)=>{const r=Oo();if(!r)return;const a=r[t]??r.log;if(typeof a=="function")try{a(...e)}catch{}},_a=Fo.reduce((t,e)=>(t[e]=_o(e),t),{}),nt={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},rr={util:Lo,console:_a,storage:tr};function Ua(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 wt={componentDepthLimit:150,iterationLimit:25e4,arrayLengthLimit:1e5};class Pe extends Error{constructor(r,a,n){super(Uo(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 Uo(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 Ha(t={}){return{componentDepthLimit:t.componentDepthLimit??wt.componentDepthLimit,iterationLimit:t.iterationLimit??wt.iterationLimit,arrayLengthLimit:t.arrayLengthLimit??wt.arrayLengthLimit,componentDepth:0,iterations:0}}function ar(t){t.iterations=0,t.componentDepth=0}function it(t,e,r){if(t&&(t.iterations+=e,t.iterations>t.iterationLimit))throw new Pe("iterations",t.iterationLimit,r)}function nr(t,e){const r=t.budget;if(r&&(r.componentDepth+=1,r.componentDepth>r.componentDepthLimit))throw r.componentDepth-=1,new Pe("component-depth",r.componentDepthLimit,`component "${e}"`)}function ir(t){const e=t.budget;e&&e.componentDepth>0&&(e.componentDepth-=1)}const Va=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),Wa=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent"),kt=t=>!!(t&&typeof t=="object"&&t.__kind==="Store");function or(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,actionRunner:e.actionRunner,notify:e.notify,onEmit:e.onEmit,disposers:[],timers:{timeouts:new Set,intervals:new Set},budget:e.budget===null?void 0:e.budget??Ha()};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 sr(t){const e=t.disposers;t.disposers=[];for(const r of e)try{r()}catch(a){console.error("[aktion] context disposer threw",a)}}function qa(t){t.mutableBindings.clear()}function xe(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 St(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:xe(e,a.name),path:r}}function Ct(t,e){if(t.kind==="StateRef")return xe(e,t.name);if(t.kind==="Member"){const r=St(t,e);if(r)return r.path.length===0?r.name:`${r.name}.${r.path.join(".")}`;const a=en(t,e);if(a)return a.path.length===0?a.atom:`${a.atom}.${a.path.join(".")}`}return null}function Ga(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const a=Tt(r.expression);e.state.declare(r.identifier,a)}for(const r of t.statements)lr(r,e);for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||!Ka(r.expression))continue;const a=N(r.expression,e);e.state.set(r.identifier,a)}Wo(t,e),Vo(t,e)}const Ho=8;function Vo(t,e){const r=[],a=o=>{const s=new Set,u=e.trackedState;e.trackedState=s;try{const c=N(o.expr,e);e.state.set(o.name,c)}finally{e.trackedState=u}o.deps=s};for(const o of t.statements){if(o.kind!=="Assignment"||!o.isState||$t(o.expression)||Ka(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 u=0;u<Ho;u+=1){let c=!1;for(const m of r){if(!vt(s,m.deps))continue;const f=e.state.get(m.name);a(m),e.state.get(m.name)!==f&&(s.add(m.name),c=!0)}if(!c)break}}finally{n=!1}}});e.disposers.push(i)}function $t(t){switch(t.kind){case"Literal":return!0;case"Array":return t.elements.every(e=>e.kind!=="Spread"&&$t(e));case"Object":return t.properties.every(e=>!e.spread&&!e.computedKey&&$t(e.value));case"Template":return t.expressions.length===0;default:return!1}}function Ka(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="http"}function lr(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,optimistic:!1,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":case"ExpressionStatement":return;case"Assignment":{if(t.isState)return;e.expressions.set(t.identifier,t.expression);const r=t.expression;e.bindings.set(t.identifier,()=>N(r,e));return}}}function Ya(t){switch(t.kind){case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"DestructureStatement":case"ExpressionStatement":case"ThrowStatement":return!0;default:return!1}}function Wo(t,e){let r=!1;for(const a of t.statements)if(Ya(a)){r=!0;break}if(r){for(const a of t.statements)a.kind==="Assignment"&&a.isState&&$t(a.expression)&&e.state.set(a.identifier,Tt(a.expression));for(const a of t.statements)if(Ya(a))try{At(a,e)}catch(n){if(n instanceof we||n instanceof Ce||n instanceof Ie)continue;if(n instanceof Pe)throw n;console.error("[aktion] top-level statement threw",n)}}}function qo(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=Ts(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 u=Ea(s,n);if(u.matched)return Xa(s,o.value,u.params,e)}return i?Xa(null,i.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function Xa(t,e,r,a){const n=a.loopVars.get("params"),i=a.loopVars.has("params");a.loopVars.set("params",r);try{const o=N(e,a);return a.router?.setActiveMatch(t,r),o}finally{i?a.loopVars.set("params",n):a.loopVars.delete("params")}}function Tt(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(Tt(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=Tt(r.value));return e}case"Template":return t.expressions.length===0?t.quasis[0]??"":null;default:return null}}function N(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?As(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 vs(a,e);const n=e.componentDecls.get(t.name);if(n)return ys(n);if(Object.prototype.hasOwnProperty.call(nt,t.name))return nt[t.name];if(e.library&&Ne(e.library,t.name))return xs(t.name);const i=Ua(t.name);return i.found?i.value:null}case"StateRef":{if(Object.prototype.hasOwnProperty.call(rr,t.name))return rr[t.name];const r=xe(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=N(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(N(a,e))}return r}case"Object":{const r={};for(const a of t.properties){if(a.spread){const i=N(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(N(a.computedKey,e)??""):a.key;r[n]=N(a.value,e)}return r}case"Member":{if(ts(t))return rs(t,e);const r=as(t,e);if(r)return ns(t,e,r);const a=N(t.object,e);if(t.optional&&a==null)return;if(t.computed){const n=N(t.computed,e);return dr(a,n)}return pr(a,t.property??"")}case"Unary":{if(t.operator==="delete"){const a=t.argument;if(a.kind==="Member"&&a.property){const n=N(a.object,e);if(n&&typeof n=="object")try{return delete n[a.property],!0}catch{return!1}}return!1}const r=N(t.argument,e);switch(t.operator){case"!":return!r;case"-":return-O(r);case"+":return+O(r);case"~":return~oe(r);case"typeof":return typeof r;case"void":return;default:return r}}case"Binary":return cs(t.operator,t.left,t.right,e);case"Ternary":{const r=N(t.test,e);return N(r?t.consequent:t.alternate,e)}case"Call":return ds(t.callee,t.arguments,e,t.loc);case"MethodCall":return us(t,e);case"Invoke":return os(t,e);case"New":return ss(t,e);case"BuiltinCall":return ws(t.name,t.arguments,e);case"Template":return ls(t.quasis,t.expressions,e);case"Spread":return N(t.argument,e);case"Block":return cr(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),u=e.stateAliases.slice();e.loopVars.clear();for(const[d,f]of i)e.loopVars.set(d,f);e.stateAliases.length=0;for(const d of n)e.stateAliases.push(d);const c=[],m=(d,f)=>{c.push({name:d,had:e.loopVars.has(d),prev:e.loopVars.get(d)}),e.loopVars.set(d,f)};for(let d=0;d<r.length;d+=1){const f=r[d];let g=o[d];if(g===void 0&&f.defaultValue&&(g=N(f.defaultValue,e)),f.pattern){for(const h of ot(f.pattern,g,e))m(h.name,h.value);continue}m(f.name,g)}try{return N(a,e)}finally{for(const d of c)d.had?e.loopVars.set(d.name,d.prev):e.loopVars.delete(d.name);e.loopVars.clear();for(const[d,f]of s)e.loopVars.set(d,f);e.stateAliases.length=0;for(const d of u)e.stateAliases.push(d)}}}default:return null}}class we{constructor(){D(this,"kind","break")}}class Ce{constructor(){D(this,"kind","continue")}}class Ie{constructor(e){D(this,"kind","return");this.value=e}}function Ja(t,e){if(N(t.test,e)){ke(t.consequent.body,e);return}if(t.alternate){if(t.alternate.kind==="IfStatement"){Ja(t.alternate,e);return}t.alternate.kind==="Block"&&ke(t.alternate.body,e)}}function Go(t,e){const r=N(t.discriminant,e);let a=!1;try{for(const n of t.cases)a||(n.test===null||N(n.test,e)===r)&&(a=!0),a&&ke(n.body,e)}catch(n){if(n instanceof we)return;throw n}}function Ko(t,e){const r=N(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,u=t.destructure??[],c=u.map(m=>({name:m,had:e.loopVars.has(m),value:e.loopVars.get(m)}));try{let m=0;const d=(Array.isArray(r),r);for(const f of d){it(e.budget,1,"`for…of` loop"),e.loopVars.set(t.item,f),i&&e.loopVars.set(i,m);for(const g of u){const h=f&&typeof f=="object"?f[g]:void 0;e.loopVars.set(g,h)}try{ke(t.body.body,e)}catch(g){if(g instanceof Ce){m+=1;continue}if(g instanceof we)return;throw g}m+=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 m of c)m.had?e.loopVars.set(m.name,m.value):e.loopVars.delete(m.name)}}function Yo(t,e){for(t.init&&Nt(t.init,e);!(t.test&&!N(t.test,e));){it(e.budget,1,"`for` loop");try{ke(t.body.body,e)}catch(r){if(!(r instanceof Ce)){if(r instanceof we)return;throw r}}t.update&&N(t.update,e)}}function Xo(t,e){for(;N(t.test,e);){it(e.budget,1,"`while` loop");try{ke(t.body.body,e)}catch(r){if(r instanceof Ce)continue;if(r instanceof we)return;throw r}}}function Jo(t,e){for(;;){it(e.budget,1,"`do…while` loop");try{ke(t.body.body,e)}catch(r){if(!(r instanceof Ce)){if(r instanceof we)return;throw r}}if(!N(t.test,e))break}}function Zo(t,e){const r=N(t.expression,e),a=ot({kind:t.patternKind,bindings:t.bindings},r,e);for(const{name:n,value:i}of a)e.loopVars.set(n,i)}function ot(t,e,r){const a=[];if(t.kind==="array"){const o=Array.isArray(e)?e:[];let s=0;for(const u of t.bindings){if(u.rest){a.push({name:u.name,value:o.slice(s)}),s=o.length;continue}let c=o[s];c===void 0&&u.defaultValue&&(c=N(u.defaultValue,r)),u.name!==""&&a.push({name:u.name,value:c}),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 c={};for(const[m,d]of Object.entries(n))i.has(m)||(c[m]=d);a.push({name:o.name,value:c});continue}const s=o.sourceKey??o.name;i.add(s);let u=n[s];u===void 0&&o.defaultValue&&(u=N(o.defaultValue,r)),a.push({name:o.name,value:u})}return a}function Qo(t,e){const r=N(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){it(e.budget,1,"`for…in` loop"),e.loopVars.set(t.item,i);try{ke(t.body.body,e)}catch(o){if(o instanceof Ce)continue;if(o instanceof we)return;throw o}}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item)}}function es(t,e){try{ke(t.block.body,e)}catch(r){if(r instanceof we||r instanceof Ce||r instanceof Ie)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{ke(t.catchBlock.body,e)}finally{a&&(n?e.loopVars.set(a,i):e.loopVars.delete(a))}}}finally{t.finallyBlock&&ke(t.finallyBlock.body,e)}}function ke(t,e){for(const r of t)Nt(r,e)}function At(t,e){Nt(t,e)}function Nt(t,e){switch(t.kind){case"ExpressionStatement":N(t.expression,e);return;case"Assignment":{const r=N(t.expression,e);if(t.identifier)if(t.isState){const a=xe(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":Ja(t,e);return;case"SwitchStatement":Go(t,e);return;case"ForOfStatement":Ko(t,e);return;case"ForClassicStatement":Yo(t,e);return;case"ForInStatement":Qo(t,e);return;case"WhileStatement":Xo(t,e);return;case"DoWhileStatement":Jo(t,e);return;case"DestructureStatement":Zo(t,e);return;case"TryStatement":es(t,e);return;case"BreakStatement":throw new we;case"ContinueStatement":throw new Ce;case"ThrowStatement":throw N(t.argument,e);case"Return":{const r=t.argument?N(t.argument,e):void 0;throw new Ie(r)}case"Await":N(t.argument,e);return;default:return}}function ts(t){let e=t;for(;e.kind==="Member";)e=e.object;return e.kind==="StateRef"&&Object.prototype.hasOwnProperty.call(rr,e.name)?!1:e.kind==="StateRef"}function rs(t,e){const r=Za(t);let a=t;for(;a.kind==="Member";)a=a.object;const n=xe(e,a.name);return Qa(r,n,e)}function Za(t){const e=[];let r=t;for(;r.kind==="Member";)e.unshift({property:r.property,computed:r.computed}),r=r.object;return e}function Qa(t,e,r){let a=r.state.get(e);const n=[e];let i=!0;for(const o of t){let s,u=null;o.computed?o.computed.kind==="Literal"?(s=o.computed.value,(typeof s=="string"||typeof s=="number")&&(u=String(s))):s=N(o.computed,r):(s=o.property??"",u=o.property??"");const c=a!=null&&typeof a=="object"&&!Array.isArray(a);i&&u!==null&&c?n.push(u):i=!1,a=o.computed?dr(a,s):pr(a,o.property??"")}return r.trackedState.add(n.join(".")),a}function as(t,e){let r=t;for(;r.kind==="Member";)r=r.object;if(r.kind!=="Identifier")return null;const a=N(r,e);return kt(a)?a:null}function ns(t,e,r){const a=Za(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=dr(i,N(s.computed,e)):i=pr(i,s.property??"")}return i}return Qa(a,r.__atom,e)}function is(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]?N(t[0],e):{},o={},s={};if(i&&typeof i=="object"&&!Array.isArray(i))for(const[d,f]of Object.entries(i))typeof f=="function"?s[d]=f:o[d]=f;const u=r?`__store_${r.line}_${r.column}`:`__store_anon_${e.stores.size}`;e.state.declare(u,o);const c={},m={__kind:"Store",__atom:u,__methods:c};for(const[d,f]of Object.entries(s))c[d]=(...g)=>f(m,...g);return e.stores.set(a,m),m}function en(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=N(a,e);return kt(n)?{atom:n.__atom,path:r}:null}function os(t,e){if(t.callee.kind==="StateRef"){const n=t.callee.name;if(n==="state")return gs(t.arguments,e,t.loc);if(n==="memo")return hs(t.arguments,e,t.loc);switch(n){case"store":return is(t.arguments,e,t.loc);case"router":return qo(t.arguments,e,t.loc);case"http":{const o=t.arguments[0];return Ia(o?N(o,e):{},e)}case"theme":{const o=t.arguments[0];return{kind:"Theme",tokens:Ps(o?N(o,e):null)}}case"i18n":{const o=t.arguments[0],s=o?N(o,e):null,u=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return La(u)}case"emit":{const o=t.arguments[0]?String(N(t.arguments[0],e)):"",s=t.arguments[1]?N(t.arguments[1],e):void 0;e.onEmit?.(o,s);return}case"storage":return t.arguments[0]&&N(t.arguments[0],e),tr}const i=e.hookDecls.get(n);if(i)return bs(i,t.arguments,e)}const r=N(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=N(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,e))}try{return r.apply(void 0,a)}catch(n){return console.error("[aktion] call expression threw",n),null}}function ss(t,e){const r=N(t.callee,e);if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=N(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,e))}try{return Reflect.construct(r,a)}catch(n){return console.error("[aktion] `new` threw",n),null}}function cr(t,e,r){let a=null;const n=[];try{for(const i of t.body)switch(i.kind){case"ExpressionStatement":a=N(i.expression,e);continue;case"Assignment":{if(i.isState&&i.identifier){const s=xe(e,i.identifier);if(r.stateAsDeclaration){if(e.state.has(s)){a=e.state.get(s);continue}const c=N(i.expression,e);e.state.declare(s,c),a=c;continue}const u=N(i.expression,e);e.state.set(s,u),a=u;continue}const o=N(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?N(i.argument,e):void 0,a;case"ThrowStatement":throw N(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)}):lr(i,e);continue}case"ComponentDeclaration":case"ActionDeclaration":case"HookDeclaration":lr(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":Nt(i,e);continue}}catch(i){if(i instanceof Ie)return i.value;throw i}finally{for(const i of n)e.loopVars.delete(i)}return a}function ls(t,e,r){let a=t[0]??"";for(let n=0;n<e.length;n+=1)a+=mr(N(e[n],r)),a+=t[n+1]??"";return a}function cs(t,e,r,a){if(t==="&&"){const o=N(e,a);return o&&N(r,a)}if(t==="||"){const o=N(e,a);return o||N(r,a)}if(t==="??"){const o=N(e,a);return o??N(r,a)}const n=N(e,a),i=N(r,a);switch(t){case"+":return typeof n=="string"||typeof i=="string"?mr(n)+mr(i):O(n)+O(i);case"-":return O(n)-O(i);case"*":return O(n)*O(i);case"/":{const o=O(i);return o===0?0:O(n)/o}case"%":{const o=O(i);return o===0?0:O(n)%o}case"**":return O(n)**O(i);case"==":case"===":return n===i;case"!=":case"!==":return n!==i;case">":return O(n)>O(i);case"<":return O(n)<O(i);case">=":return O(n)>=O(i);case"<=":return O(n)<=O(i);case"&":return oe(n)&oe(i);case"|":return oe(n)|oe(i);case"^":return oe(n)^oe(i);case"<<":return oe(n)<<(Le(i)&31);case">>":return oe(n)>>(Le(i)&31);case">>>":return Le(n)>>>(Le(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 oe(t){return O(t)|0}function Le(t){return O(t)>>>0}function us(t,e){const r=N(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=N(o.argument,e);if(Array.isArray(s))for(const u of s)n.push(u);continue}n.push(N(o,e))}const i=n;try{return a.apply(r,i)}catch(o){if(o instanceof RangeError||o instanceof Pe)throw o;return console.error(`[aktion] method "${t.method}" threw`,o),null}}function ds(t,e,r,a){const n=r.componentDecls.get(t);if(n)return ms(n,e,r,a);const i=r.actionDecls.get(t);if(i){const g=e.map(h=>N(h,r));return rn(i,g,r)}if(t==="setTimeout"||t==="setInterval")return ks(t,e,r);if(t==="clearTimeout"||t==="clearInterval"){const g=e[0]?N(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(h=>N(h,r));return o(...g)}const s=r.bindings.get(t);if(s){const g=s();if(typeof g=="function"){const h=e.map(b=>N(b,r));return g(...h)}}if(Object.prototype.hasOwnProperty.call(nt,t)&&typeof nt[t]=="function"&&!r.componentDecls.has(t)&&!(r.library&&Ne(r.library,t))){const g=nt[t],h=[];for(const b of e){if(b.kind==="Spread"){const v=N(b.argument,r);if(Array.isArray(v))for(const y of v)h.push(y);continue}h.push(N(b,r))}try{return g(...h)}catch(b){return console.error(`[aktion] global "${t}" threw`,b),null}}if(r.library&&!Ne(r.library,t)){const g=Ua(t);if(g.found&&typeof g.value=="function"){const h=g.value,b=[];for(const v of e){if(v.kind==="Spread"){const y=N(v.argument,r);if(Array.isArray(y))for(const x of y)b.push(x);continue}b.push(N(v,r))}try{return h(...b)}catch(v){return console.error(`[aktion] global "${t}" threw`,v),null}}return Ne(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:a}:null}let u;const c=[...e];if(c.length>0){const g=c[c.length-1];if(g.kind==="Object"){const h=g.properties.find(b=>!b.spread&&b.key==="key");if(h){u=N(h.value,r);const b=g.properties.filter(v=>v!==h);b.length>0?c[c.length-1]={...g,properties:b}:c.pop()}}}const{args:m,argMeta:d}=ps(r,t,c);return{__kind:"Component",name:t,args:m,argMeta:d,explicitKey:u,source:a}}function ps(t,e,r){const a=t.library?Ne(t.library,e):void 0;if(!a){const f=r.map(h=>N(h,t)),g=r.map(h=>{const b=Ct(h,t);return b!==null?{stateRef:b}:{}});return{args:f,argMeta:g}}const n=new Map;a.props.forEach((f,g)=>{if(n.set(f.name,g),f.aliases)for(const h of f.aliases)n.has(h)||n.set(h,g)});const i=Xt(a),o=a.props.map(()=>({value:void 0,meta:{},filled:!1})),s=[];let u=-1;for(let f=r.length-1;f>=0;f-=1)if(r[f].kind==="Object"){u=f;break}for(let f=0;f<r.length;f+=1){if(f===u)continue;const g=r[f];s.push({expr:g,value:N(g,t)})}if(u>=0){const f=r[u];if(f.kind==="Object")for(const g of f.properties){if(g.spread)continue;const h=n.get(g.key);if(h===void 0)continue;const b=N(g.value,t);o[h].value=b,o[h].filled=!0;const v=Ct(g.value,t);v!==null&&(o[h].meta={stateRef:v})}}if(s.length>0&&i>=0&&!o[i].filled){const{expr:f,value:g}=s.shift();o[i].value=g,o[i].filled=!0;const h=Ct(f,t);h!==null&&(o[i].meta={stateRef:h})}let c=0;for(const{expr:f,value:g}of s){for(;c<a.props.length&&o[c].filled;)c+=1;if(c>=a.props.length)break;o[c].value=g,o[c].filled=!0;const h=Ct(f,t);h!==null&&(o[c].meta={stateRef:h}),c+=1}const m=o.map(f=>f.value),d=o.map(f=>f.meta);for(;m.length>0&&m[m.length-1]===void 0;)m.pop(),d.pop();return{args:m,argMeta:d}}function ms(t,e,r,a){const n=[],i={};let o,s=-1;for(let h=e.length-1;h>=0;h-=1)if(e[h].kind==="Object"){s=h;break}let u=s>=0?e[s]:null,c=!1;if(u&&u.kind==="Object"){const h=new Set(t.params.map(b=>b.name));for(const b of u.properties)if(!b.spread&&(b.key==="key"||h.has(b.key))){c=!0;break}}c||(s=-1,u=null);for(let h=0;h<e.length;h+=1)h!==s&&n.push(e[h]);if(u&&u.kind==="Object")for(const h of u.properties)h.spread||(h.key==="key"?o=h.value:i[h.key]=h.value);const m=n.map(h=>h.kind==="Spread"?N(h.argument,r):N(h,r)),d=[];for(let h=0;h<n.length;h+=1){const b=n[h],v=m[h];if(b.kind==="Spread"&&Array.isArray(v))for(const y of v)d.push(y);else d.push(v)}const f={};for(const[h,b]of Object.entries(i))f[h]=N(b,r);const g=o?N(o,r):void 0;return{__kind:"UserComponent",decl:t,positional:d,named:f,explicitKey:g,source:a}}function tn(t,e,r){const{decl:a,positional:n,named:i}=t,o=[],s=(f,g)=>{o.push({name:f,had:e.loopVars.has(f),prev:e.loopVars.get(f)}),e.loopVars.set(f,g)};for(let f=0;f<a.params.length;f+=1){const g=a.params[f];if(g.pattern){let b=n[f];b===void 0&&g.defaultValue&&(b=N(g.defaultValue,e));for(const v of ot(g.pattern,b,e))s(v.name,v.value);continue}let h;i[g.name]!==void 0?h=i[g.name]:n[f]!==void 0?h=n[f]:g.defaultValue?h=N(g.defaultValue,e):h=void 0,s(g.name,h)}if(n.length>a.params.length){const f=n.slice(a.params.length),g=f.length===1?f[0]:f;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 f={};for(const g of a.slots)i[g]!==void 0&&(f[g]=i[g]);o.push({name:"slots",had:e.loopVars.has("slots"),prev:e.loopVars.get("slots")}),e.loopVars.set("slots",f)}const u=new Map;for(const f of a.body.body)if(f.kind==="Assignment"&&f.isState){const g=`${r}:${f.identifier}`;u.set(f.identifier,g)}e.stateAliases.push(u);const c=[];e.componentEffectStack.push(c);const m=e.hookScope,d={instanceKey:r,cursor:0};e.hookScope=d;try{return{value:cr(a.body,e,{stateAsDeclaration:!0}),effects:c,hooks:d.cursor}}finally{e.hookScope=m,e.componentEffectStack.pop(),e.stateAliases.pop();for(const f of o)f.had?e.loopVars.set(f.name,f.prev):e.loopVars.delete(f.name)}}function rn(t,e,r){return an(t.params,t.body,e,r)}function an(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 u=r[o];if(u===void 0&&s.defaultValue&&(u=N(s.defaultValue,a)),s.pattern){for(const c of ot(s.pattern,u,a))i(c.name,c.value);continue}i(s.name,u)}try{return cr(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 nn(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 fs(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 gs(t,e,r){const a=nn(e);if(!a)return sn("state",r),[t[0]?N(t[0],e):void 0,()=>{}];const n=e.hookScope.cursor++;let i=a[n];(!i||i.kind!=="state")&&(i={kind:"state",value:t[0]?N(t[0],e):void 0},a[n]=i);const o=i,s=u=>{const c=typeof u=="function"?u(o.value):u;Object.is(c,o.value)||(o.value=c,e.notify?.())};return[o.value,s]}function hs(t,e,r){const a=t[0],n=t[1],i=()=>{const f=a?N(a,e):void 0;return typeof f=="function"?f():f},o=nn(e);if(!o)return sn("memo",r),i();const s=e.hookScope.cursor++,u=n?N(n,e):void 0,c=Array.isArray(u)?u:void 0,m=o[s];if(m&&m.kind==="memo"&&c&&m.deps&&fs(m.deps,c))return m.value;const d=i();return o[s]={kind:"memo",deps:c,value:d},d}function bs(t,e,r){const a=[];for(const n of e){if(n.kind==="Spread"){const i=N(n.argument,r);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,r))}return an(t.params,t.body,a,r)}let on=!1;function sn(t,e){on||(on=!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 ln(t,e){t.hookStore.delete(e)}function vs(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,u]of a)e.loopVars.set(s,u);e.stateAliases.length=0;for(const s of r)e.stateAliases.push(s);try{return rn(t,n,e)}finally{e.loopVars.clear();for(const[s,u]of i)e.loopVars.set(s,u);e.stateAliases.length=0;for(const s of o)e.stateAliases.push(s)}}}function ys(t,e){return(...r)=>({__kind:"UserComponent",decl:t,positional:r,named:{},explicitKey:void 0,source:t.loc})}function xs(t,e){return(...r)=>({__kind:"Component",name:t,args:r,argMeta:r.map(()=>({})),source:void 0})}function ws(t,e,r){if(t==="__rui_assign__")return Ss(e,r);if(t==="__rui_postfix__")return Cs(e,r);if(t==="__rui_prefix__")return $s(e,r);if(t==="__rui_await__")return e[0]?N(e[0],r):void 0;const a=Sa[t];if(!a)return null;const n=e.map(i=>N(i,r));return a(n)}function ze(t,e,r){switch(t){case"=":return r;case"+=":return typeof e=="string"||typeof r=="string"?`${e??""}${r??""}`:O(e)+O(r);case"-=":return O(e)-O(r);case"*=":return O(e)*O(r);case"/=":{const a=O(r);return a===0?0:O(e)/a}case"%=":{const a=O(r);return a===0?0:O(e)%a}case"**=":return O(e)**O(r);case"&&=":return e&&r;case"||=":return e||r;case"??=":return e??r;case"&=":return oe(e)&oe(r);case"|=":return oe(e)|oe(r);case"^=":return oe(e)^oe(r);case"<<=":return oe(e)<<(Le(r)&31);case">>=":return oe(e)>>(Le(r)&31);case">>>=":return Le(e)>>>(Le(r)&31);default:return r}}function ks(t,e,r){const a=e[0]?N(e[0],r):null;if(typeof a!="function")return null;const n=a,i=e[1]?O(N(e[1],r)):0,o=[];for(let c=2;c<e.length;c+=1)o.push(N(e[c],r));const s=()=>{try{n(...o)}catch(c){console.error(`[aktion] ${t} callback threw`,c)}finally{r.notify?.()}};if(t==="setTimeout"){const c=setTimeout(()=>{r.timers.timeouts.delete(c),s()},i);return r.timers.timeouts.add(c),c}const u=setInterval(s,i);return r.timers.intervals.add(u),u}function Ss(t,e){const[r,a,n]=t;if(!r||!a)return null;const i=n&&n.kind==="Literal"?String(n.value??"="):"=",o=N(a,e);if(r.kind==="StateRef"){const s=xe(e,r.name),u=e.state.get(s),c=ze(i,u,o);return e.state.set(s,c),c}if(r.kind==="Member"){const s=St(r,e);if(s){const d=e.state.get(s.name);if(s.path.length>=1&&Ma(d)){let h=d;for(let b=0;b<s.path.length-1;b+=1)h=h?.[s.path[b]];if(h&&typeof h=="object"){const b=s.path[s.path.length-1],v=h[b],y=ze(i,v,o);return h[b]=y,e.notify?.(),y}}const f=ur(d,s.path),g=ze(i,f,o);return e.state.setPath(s.name,s.path,g),g}const u=en(r,e);if(u){const d=ur(e.state.get(u.atom),u.path),f=ze(i,d,o);return e.state.setPath(u.atom,u.path,f),f}const c=N(r.object,e),m=r.computed?r.computed.kind==="Literal"?r.computed.value:null:r.property;if(c&&typeof c=="object"&&m!=null){const d=c[String(m)],f=ze(i,d,o);return c[String(m)]=f,f}return o}if(r.kind==="Identifier"){const s=r.name;if(e.loopVars.has(s)){const m=e.loopVars.get(s),d=ze(i,m,o);return e.loopVars.set(s,d),d}if(e.bindings.has(s)||e.mutableBindings.has(s)){const m=e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)(),d=ze(i,m,o);return e.mutableBindings.set(s,d),d}const u=e.loopVars.get(s),c=ze(i,u,o);return e.loopVars.set(s,c),c}return o}function ur(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 cn(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=xe(e,a.name),u=O(e.state.get(s)),c=u+o;return e.state.set(s,c),r==="prefix"?c:u}if(a.kind==="Member"){const s=St(a,e);if(s){const u=O(ur(e.state.get(s.name),s.path)),c=u+o;return e.state.setPath(s.name,s.path,c),r==="prefix"?c:u}}if(a.kind==="Identifier"){const s=a.name;if(e.loopVars.has(s)){const m=O(e.loopVars.get(s)),d=m+o;return e.loopVars.set(s,d),r==="prefix"?d:m}if(e.bindings.has(s)||e.mutableBindings.has(s)){const m=O(e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)()),d=m+o;return e.mutableBindings.set(s,d),r==="prefix"?d:m}const u=O(e.loopVars.get(s)),c=u+o;return e.loopVars.set(s,c),r==="prefix"?c:u}return null}function Cs(t,e){return cn(t,e,"postfix")}function $s(t,e){return cn(t,e,"prefix")}function Ts(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 As(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,u]of o)n[s]=u}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function dr(t,e){if(t!=null){if(Array.isArray(t)){const r=un(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=un(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function un(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 pr(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 O(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 Ns=new Set(["colors","radius","font","motion","elevation"]),Ms=new Set(["name","direction"]);function Ps(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&&!Ms.has(a)&&Ns.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 u=i+Is(o);e[u]=Ls(s)}}return e}function Is(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function Ls(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function mr(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)}}function dn(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="emit"}const fr="::",zs=new Map;class pn{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(fr)||a.has(n)||this.unmount(n);for(const n of e)this.mounted.has(n.name)||this.mount(n.name,n,r,[],zs)}syncInstanceEffects(e,r,a){const n=`${e}${fr}`,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}`,u=this.mounted.get(s);if(u){u.capturedLoopVars=o.capturedLoopVars;continue}this.mount(s,o.decl,a,o.capturedAliases,o.capturedLoopVars)}}unmountInstance(e){const r=`${e}${fr}`;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);const u=Rs(()=>{for(const f of o.cleanups.splice(0))try{f()}catch(g){fn(e,g)}try{mn(r,a(),o,this.options)}catch(f){console.error(`[aktion] effect "${e}" failed`,f)}finally{this.options.notify()}},r.rateLimit,o);let c=!1,m=!1,d=!1;for(const f of r.triggers)switch(f.kind){case"lifecycle":f.name==="mount"&&(c=!0),f.name==="unmount"&&(m=!0);break;case"every":{d=!0;const g=setInterval(u,f.intervalMs);o.intervals.push(g);break}case"state":{const g=js(f.name,n),h=this.options.state.subscribe(b=>{Qt(b,g)&&u()});o.unsubscribers.push(h);break}}(r.triggers.length===0||c||!d&&!m&&r.triggers.every(f=>f.kind==="state"))&&u()}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{}for(const n of r.cleanups)try{n()}catch(i){fn(e,i)}if(r.decl.triggers.some(n=>n.kind==="lifecycle"&&n.name==="unmount"))try{mn(r.decl,r.ctxRef(),r,this.options)}catch(n){console.error(`[aktion] effect "${e}" unmount body threw`,n)}}}function Rs(t,e,r){if(!e||e.ms<=0)return t;if(e.kind==="debounce"){let i=null;const o=()=>{i&&(clearTimeout(i),i=null)};return r.cleanups.push(o),()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,t()},e.ms)}}let a=0,n=null;return r.cleanups.push(()=>{n&&(clearTimeout(n),n=null)}),()=>{const i=Date.now(),o=i-a;o>=e.ms?(a=i,t()):n||(n=setTimeout(()=>{n=null,a=Date.now(),t()},e.ms-o))}}function mn(t,e,r,a){const n=r.capturedAliases.length>0?e.stateAliases.slice():null;if(n){e.stateAliases.length=0;for(const o of r.capturedAliases)e.stateAliases.push(new Map(o))}const i=r.capturedLoopVars.size>0?new Map(e.loopVars):null;if(i){e.loopVars.clear();for(const[o,s]of r.capturedLoopVars)e.loopVars.set(o,s)}try{for(const o of t.body.body)Es(o,e,r,a)}finally{if(n){e.stateAliases.length=0;for(const o of n)e.stateAliases.push(o)}if(i){e.loopVars.clear();for(const[o,s]of i)e.loopVars.set(o,s)}}}function Es(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]?N(n.arguments[0],e):null;typeof i=="function"&&r.cleanups.push(i);return}if(dn(n)){const i=n.arguments,o=i[0]?String(N(i[0],e)):"",s=i[1]?N(i[1],e):void 0;a.onEmit?.(o,s);return}return N(n,e)}case"Assignment":{const n=N(t.expression,e);if(t.identifier&&t.identifier!==""){const i=xe(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":At(t,e);return;default:return}}function fn(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function js(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}class gn{constructor(e){this.options=e}async run(e,r,a){const n=[];for(let o=0;o<e.params.length;o+=1){const s=e.params[o],u=r[o];n.push({name:s.name,had:a.loopVars.has(s.name),prev:a.loopVars.get(s.name)}),a.loopVars.set(s.name,u)}const i=e.optimistic?Ds(this.options.state):null;try{let o;try{for(const s of e.body.body)o=await this.runStatement(s,a)}catch(s){if(s instanceof Ie)return this.options.notify(),s.value;throw s}return this.options.notify(),o}catch(o){if(o instanceof we||o instanceof Ce){console.error(`[aktion] action "${e.name}" — \`${o.kind}\` outside a loop.`);return}throw i&&(Bs(this.options.state,i),this.options.notify()),console.error(`[aktion] action "${e.name}" failed`,o),o}finally{for(const o of n)o.had?a.loopVars.set(o.name,o.prev):a.loopVars.delete(o.name)}}async runStatement(e,r){switch(e.kind){case"ExpressionStatement":{const a=e.expression;if(dn(a)){const i=a.arguments,o=i[0]?String(N(i[0],r)):"",s=i[1]?N(i[1],r):void 0;this.options.onEmit?.(o,s);return}const n=N(a,r);return await Mt(n)}case"Await":{const a=N(e.argument,r);return await Mt(a)}case"Assignment":{const a=await Mt(N(e.expression,r));if(e.identifier)if(e.isState){const n=xe(r,e.identifier);this.options.state.set(n,a)}else r.loopVars.set(e.identifier,a);return a}case"Return":{if(!e.argument)throw new Ie(void 0);const a=await Mt(N(e.argument,r));throw new Ie(a)}case"IfStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"SwitchStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"ThrowStatement":case"DestructureStatement":At(e,r);return;default:return}}}async function Mt(t){return t&&typeof t.then=="function"?await t:t}function Ds(t){const e=new Map;for(const[r,a]of t.entries())e.set(r,a);return e}function Bs(t,e){for(const[r,a]of e)t.set(r,a)}const Fs="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",hn="6.7.2",bn="data-rui-font-awesome",Os=new Set(["solid","regular","brands"]),vn="solid";function _s(t){typeof document<"u"&&yn(document.head,document),yn(t,t.ownerDocument??document)}function yn(t,e){if(Us()||t.querySelector(`link[${bn}="${hn}"]`))return;const a=e.createElement("link");a.rel="stylesheet",a.href=Fs,a.setAttribute(bn,hn);try{t.appendChild(a)}catch{}}function Us(){return typeof globalThis.happyDOM<"u"}function gr(t){if(typeof t!="string")return[];const e=Vs(t).trim();if(!e)return[];if(!qs(e))return[];const[r,a]=Ws(e);return a?[`fa-${r}`,`fa-${a}`]:[]}const Hs=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function Vs(t){return t.replace(Hs,"")}function Ws(t){const e=t.indexOf(":");if(e===-1)return[vn,t];const r=t.slice(0,e).trim().toLowerCase(),a=t.slice(e+1).trim();return Os.has(r)?[r,a]:[vn,a||t]}function qs(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const Gs=["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 C(t){return Array.isArray(t)?t:t==null?[]:[t]}function p(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function T(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function L(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 Ke=["base","sm","md","lg","xl"];function fe(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)Ke.includes(n)&&(r[n]=i,a=!0);return a?{kind:"responsive",values:r}:{kind:"single",value:t}}const Ks=/["'\\\n\r<>;{}]/g;function Ys(t){return t?t.replace(Ks,"").trim():""}const Xs=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function te(t,e){const r=(p(t)??"").trim();return!r||r.length>64||!Xs.test(r)?e:r}const Js=/^[a-zA-Z0-9#%.,()\s+\-]+$/;function Zs(t){const e=p(t).trim();return!e||e.length>64||!Js.test(e)||/\burl\s*\(|\bexpression\s*\(|javascript\s*:|@import\b/i.test(e)?"":e}const Qs=new Set(["http","https","mailto","tel"]);function Ye(t,e="#"){const r=p(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 Qs.has(i)?a:e}const el=new Set(["http","https","data","blob"]);function ne(t){const e=p(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!el.has(n)||n==="data"&&!/^data:image\//i.test(r)?"":r}function tl(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(c){console.error("[aktion] Col render() threw",c),s=null}const u=c=>{tl(c)?t.append(n.renderNode(c)):c!=null&&t.append(document.createTextNode(i(c,o)))};if(Array.isArray(s))for(const c of s)u(c);else u(s);if(typeof e.onClick=="function"){t.setAttribute("data-clickable","true"),t.setAttribute("role","button"),t.tabIndex=0;const c=m=>m.target?.closest("input,button,a,label,select,textarea")?!1:(m.stopPropagation(),n.invoke(e.onClick,r,a),!0);t.onclick=m=>{c(m)},t.onkeydown=m=>{m.key!=="Enter"&&m.key!==" "||c(m)&&m.preventDefault()}}}function E(t,e={}){const r=p(t);if(!r)return null;const a=e.color?Zs(e.color):"",n=a?`color:${a};`:null,i=gr(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 st=12,rl={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},al={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function nl(t){return rl[t]??"stretch"}function il(t){return al[t]??"flex-start"}function xn(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function Be(t,e,r){for(const a of Ke){const n=e.values[a];n&&t.push(`${r}-${a}:var(--rui-spacing-${n}, ${n})`)}}function ol(t,e,r,a){for(const n of Ke){const i=e.values[n];i&&t.push(`${r}-${n}:${a(String(i))}`)}}function wn(t,e,r,a){const n=fe(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",ol(e,n,a.cssVarPrefix,a.mapper)}function sl(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function ll(t){const e=fe(t.direction);return e.kind==="single"?e.value?String(e.value):"column":e.values.base?String(e.values.base):"column"}const cl={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(L(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(a["data-shrink"]=String(L(e.shrink,1)));const i=p(e.basis);i==="auto"||i==="0"?a["data-basis"]=i:i&&n.push(`flex-basis:${te(i,i)}`);const o=p(e.alignSelf);if(o&&(a["data-align-self"]=o),e.order!==void 0&&e.order!==null){const m=L(e.order,0);a["data-order"]=String(m),n.push(`order:${m}`)}const s=p(e.minWidth);s&&n.push(`min-width:${te(s,s)}`);const u=p(e.maxWidth);u&&n.push(`max-width:${te(u,u)}`),n.length>0&&(a.style=n.join(";"));const c=l("div",a);return c.append(r.renderNode(e.child)),c}};function br(t,e,r,a,n){const i=fe(t),o=fe(a.gap),s=fe(a.padding),u=T(a.reverse),c={class:"rui-stack","data-wrap":T(a.wrap)?"true":null,"data-reverse":u?"true":null,"data-uniform":e?"true":"false","data-inline":T(a.inline)?"true":null},m=[];if(i.kind==="single"){const g=i.value?String(i.value):"column";c["data-direction"]=xn(g,u)}else{c["data-direction"]="responsive",c["data-responsive-dir"]="true";for(const g of Ke){const h=i.values[g];h&&m.push(`--rui-stack-dir-${g}:${xn(String(h),u)}`)}}o.kind==="single"?c["data-gap"]=o.value?String(o.value):"m":(c["data-gap"]="responsive",c["data-responsive-gap"]="true",Be(m,o,"--rui-stack-gap")),wn(a.align,m,c,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:r,mapper:nl}),wn(a.justify,m,c,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:il});const d=p(a.alignContent);if(d&&(c["data-align-content"]=d),s.kind==="single"){const g=s.value?String(s.value):null;g&&(c["data-padding"]=g)}else c["data-padding"]="responsive",c["data-responsive-padding"]="true",Be(m,s,"--rui-stack-padding");m.length>0&&(c.style=m.join(";"));const f=l("div",c);for(const g of C(a.children))f.append(n.renderNode(g));return f}const ul={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"},kn={name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Alignment of wrapped lines (only when `wrap` is on)"},dl={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},{...kn}],render:(t,e,r)=>br("row",T(e.grow),"center",e,r)},pl={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)},ml={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"}`.'},{...ul},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment (default stretch). May be a responsive map."},{...vr},{...kn},{...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=ll(e)==="row",i=e.uniform===void 0?n:T(e.uniform,n);return br(e.direction,i,"stretch",e,r)}},fl={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":p(e.axis,"both"),"data-gap":p(e.gap,"m"),"data-inline":T(e.inline)?"true":null},n=p(e.padding);n&&(a["data-padding"]=n);const i=[],o=p(e.minHeight);o&&i.push(`min-height:${te(o,o)}`),i.length>0&&(a.style=i.join(";"));const s=l("div",a);for(const u of C(e.children))s.append(r.renderNode(u));return s}},gl={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":p(e.variant,"default")});for(const n of C(e.children))a.append(r.renderNode(n));return a}},hl={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"},[p(e.title)]));const a=p(e.subtitle);return a&&r.append(l("p",{class:"rui-card-subtitle"},[a])),r}},bl={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 C(e.children))a.append(r.renderNode(n));return a}},vl={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=p(e.orientation,"horizontal"),a=T(e.decorative,!0),n=p(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})}},Sn=(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},yl={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 C(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(Sn(p(i.title),p(i.details),T(i.active)));continue}a.append(Sn(p(n),""))}return a}},xl={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":p(e.value),"data-active":"false"});for(const n of C(e.children))a.append(r.renderNode(n));return a}},wl={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=C(e.items),n=p(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 u=p(e.defaultValue);if(!u&&a.length>0){const f=a[0];u=p(f?.args?.[0],"tab-0")}const c=r.useInstanceState("activeTab",u);p(e.defaultValue)&&p(e.defaultValue)!==u&&c.set(p(e.defaultValue)),new Set(a.map((f,g)=>p(f.args?.[0],`tab-${g}`))).has(c.get())||c.set(u);const d=(f,g)=>{const h=c.get();c.set(f);const b=g.closest(".rui-tabs");b&&(b.querySelectorAll(".rui-tab-trigger").forEach(v=>{const y=v.getAttribute("data-value")===f;v.setAttribute("aria-selected",y?"true":"false"),v.tabIndex=y?0:-1}),b.querySelectorAll(".rui-tab-content").forEach(v=>{v.setAttribute("data-active",v.getAttribute("data-value")===f?"true":"false")})),h!==f&&r.invoke(e.onChange,f)};return a.forEach((f,g)=>{const h=f,b=p(h.args?.[0],`tab-${g}`),v=p(h.args?.[1],`Tab ${g+1}`),y=p(h.args?.[3]),x=p(h.args?.[4]),w=b===c.get(),k=l("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":b,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),A=x?kl(x):null;A&&k.append(A),k.append(l("span",{class:"rui-tab-trigger-label"},[v])),y&&k.append(l("span",{class:"rui-tab-trigger-badge"},[y])),k.onclick=$=>{const M=$.currentTarget??$.target;d(b,M)},k.onkeydown=$=>{const M=$,I=n!=="vertical",R=I?M.key==="ArrowRight":M.key==="ArrowDown",j=I?M.key==="ArrowLeft":M.key==="ArrowUp";if(!R&&!j&&M.key!=="Home"&&M.key!=="End")return;M.preventDefault();const K=M.currentTarget??M.target,F=K.closest(".rui-tab-list");if(!F)return;const U=Array.from(F.querySelectorAll(".rui-tab-trigger"));if(U.length===0)return;const J=U.indexOf(K);let Z=J;M.key==="Home"?Z=0:M.key==="End"?Z=U.length-1:R?Z=(J+1)%U.length:j&&(Z=(J-1+U.length)%U.length);const de=U[Z];if(!de)return;de.focus();const Se=de.getAttribute("data-value")??"";Se&&d(Se,de)},o.append(k);const S=r.renderNode(f);S.setAttribute("data-value",b),S.setAttribute("data-active",w?"true":"false"),s.append(S)}),i.append(o,s),i}};function kl(t){return E(t,{className:"rui-tab-trigger-icon"})}const Sl={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?T(e.showArrow)?"true":"false":null});T(e.open)&&n.setAttribute("open","");const i=l("summary",{class:"rui-accordion-trigger"});i.append(l("span",{class:"rui-accordion-title"},[p(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 C(e.children))o.append(r.renderNode(s));return n.append(o),n}},Cl={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":T(e.showArrow)?"true":"false"});for(const n of C(e.items))a.append(r.renderNode(n));return a}},Pt=t=>Math.max(1,Math.min(st,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 Pt(Math.round(st*n/i))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:Pt(L(t,12))}function $l(t){const e=p(t.minChildWidth)||p(t.minItemWidth);return te(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=Sr(e.span??12),n=fe(e.spanAt),i=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(st-1,Math.round(L(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 c of Ke){const m=n.values[c];if(m!==void 0){const d=Sr(m);s.push(`--rui-grid-item-span-${c}:${d}`)}}}else if(n.kind==="single"&&n.value!=null){const c=Sr(n.value);s.push(`--rui-grid-item-span:${c}`),o["data-span"]=String(c)}o.style=s.join(";");const u=l("div",o);return u.append(r.renderNode(e.child)),u}},Al={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=fe(e.padding),n=fe(e.margin),i={class:"rui-box","data-border":p(e.border,"none"),"data-background":p(e.background,"none")},o=[],s=p(e.maxWidth);if(s&&o.push(`max-width:${te(s,s)}`),a.kind==="single"){const c=a.value?String(a.value):null;c&&(i["data-padding"]=c)}else i["data-padding"]="responsive",i["data-responsive-padding"]="true",Be(o,a,"--rui-box-padding");if(n.kind==="single"){const c=n.value?String(n.value):null;c&&(i["data-margin"]=c)}else i["data-margin"]="responsive",i["data-responsive-margin"]="true",Be(o,n,"--rui-box-margin");o.length>0&&(i.style=o.join(";"));const u=l("div",i);for(const c of C(e.children))u.append(r.renderNode(c));return u}},Cn={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=C(e.children),n=a.some(v=>sl(v,"GridItem")),i=fe(e.columns),o=fe(e.gap),s=fe(e.rowGap),u=fe(e.columnGap),c={class:"rui-grid"},m=[];let d=!1,f=!1;if(i.kind==="single"){const v=i.value===null?0:L(i.value,0),y=v>0?Pt(v):0;if(y===st?d=!0:y>0&&(f=!0),y>0){c["data-columns"]=String(y);const x=p(e.minChildWidth)||p(e.minItemWidth);x&&(c["data-min-child-width"]="true",m.push(`--rui-grid-min-child:${te(x,"220px")}`))}else m.push(`--rui-grid-min-item:${$l(e)}`)}else{c["data-responsive-cols"]="true";for(const v of Ke){const y=i.values[v];if(y===void 0)continue;const x=Pt(L(y,0));x===st?d=!0:x>0&&(f=!0),m.push(`--rui-grid-cols-${v}:${x}`)}}n&&!f&&(d=!0),d&&(c["data-grid-mode"]="12"),o.kind==="single"?c["data-gap"]=o.value?String(o.value):"m":(c["data-gap"]="responsive",c["data-responsive-gap"]="true",Be(m,o,"--rui-grid-gap")),s.kind==="single"&&s.value?c["data-row-gap"]=String(s.value):s.kind==="responsive"&&(c["data-row-gap"]="responsive",c["data-responsive-row-gap"]="true",Be(m,s,"--rui-grid-row-gap")),u.kind==="single"&&u.value?c["data-column-gap"]=String(u.value):u.kind==="responsive"&&(c["data-column-gap"]="responsive",c["data-responsive-column-gap"]="true",Be(m,u,"--rui-grid-column-gap"));const g=p(e.alignItems);g&&(c["data-align-items"]=g);const h=p(e.justifyItems);h&&(c["data-justify-items"]=h),T(e.dense)&&(c["data-dense"]="true"),m.length>0&&(c.style=m.join(";"));const b=l("div",c);for(const v of a)b.append(r.renderNode(v));return b}},Nl={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=Ml(p(e.ratio,"16:9")),n=l("div",{class:"rui-aspect-ratio",style:`aspect-ratio:${a};`});for(const i of C(e.children))n.append(r.renderNode(i));return n}};function Ml(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 Pl={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":p(e.direction,"vertical"),style:`max-height:${te(e.maxHeight,"320px")};`});for(const n of C(e.children))a.append(r.renderNode(n));return a}},Il={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).",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:["sm","md","lg","xl","full"],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=p(e.size,"md"),n=e.closable===void 0?!0:T(e.closable),i=l("div",{class:"rui-modal-overlay","data-open":T(e.open)?"true":"false"}),o=l("div",{class:"rui-modal",role:"dialog","aria-modal":"true","data-size":a}),s=l("header",{class:"rui-modal-header"});s.append(l("h3",{class:"rui-modal-title"},[p(e.title)]));const u=t.argMeta?.[1]?.stateRef,c=()=>{u&&r.setState(u,!1),r.invoke(e.onClose)};if(n){const f=l("button",{type:"button",class:"rui-modal-close","aria-label":"Close dialog"},["×"]);f.onclick=g=>{g.stopPropagation(),c()},s.append(f)}o.append(s);const m=l("div",{class:"rui-modal-body"});for(const f of C(e.children))m.append(r.renderNode(f));o.append(m);const d=C(e.footer);if(d.length>0){const f=l("footer",{class:"rui-modal-footer"});for(const g of d)f.append(r.renderNode(g));o.append(f)}return i.append(o),T(e.closeOnBackdrop)&&(i.onclick=f=>{f.target===i&&c()}),i}},Ll=["solid","regular","brands"],It=["xs","sm","md","lg","xl"],zl=["default","neutral","primary","success","warning","danger","info"];function Cr(t,e="md"){const r=p(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":It.includes(r)?r:e:e}const Rl={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:Ll},{name:"size",type:"string",optional:!0,enum:Gs},{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=p(e.name),a=p(e.variant,""),n=p(e.size,"md"),i=p(e.color,""),o=a?`${a}:${r}`:r,s=E(o,{size:n,color:i});return s||l("span",{class:"rui-icon","data-icon-size":n},[r])}},El=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function jl(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const $n=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:El},{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;").'}],Tn=(t,e)=>{const r=p(e.variant,"body"),a=p(e.tone,"default"),n=jl(e.style);return l("span",{class:"rui-text","data-variant":r,"data-color":a,style:n||null},[p(e.value)])},Dl={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:$n,render:Tn},Bl={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:$n,render:Tn},Fl={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":p(e.fit,"cover"),style:e.ratio?`aspect-ratio:${Ol(p(e.ratio))};`:null}),a=ne(e.src);if(a)r.append(l("img",{src:a,alt:p(e.alt),loading:"lazy"}));else{const i=l("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),o=p(e.fallback);if(o){const s=E(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=p(e.caption);return n&&r.append(l("figcaption",{class:"rui-image-caption"},[n])),r}};function Ol(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 An=["neutral","primary","success","warning","danger","info"],_l={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:An,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:It}],render:(t,e)=>{const r=p(e.tone,"neutral"),a=Cr(e.size,"md"),n=l("span",{class:"rui-badge","data-variant":r,"data-size":a}),i=E(e.icon,{className:"rui-badge-icon"});i&&n.append(i);const o=p(e.label);return o&&n.append(l("span",{class:"rui-badge-label"},[o])),n}},Ul={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:An,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:It}],render:(t,e)=>{const r=p(e.tone,"neutral"),a=Cr(e.size,"md"),n=l("div",{class:"rui-badge-list"});for(const i of C(e.labels)){const o=p(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}},Hl={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=p(e.tone,"info"),a=T(e.compact),n=l("div",{class:"rui-callout","data-variant":r,"data-compact":a?"true":"false"}),i=p(e.icon)||ql(r),o=E(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"},[p(e.title)]));const u=p(e.description);return u&&s.append(l("div",{class:"rui-callout-description"},[u])),n.append(s),n}},Vl={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=p(e.language),a=p(e.codeString),n=T(e.showLineNumbers),i=Wl(p(e.highlightLines)),o=e.copy===void 0?!0:T(e.copy),s=l("div",{class:"rui-code-block"});if(r||o){const c=l("div",{class:"rui-code-block-head"});if(r&&c.append(l("span",{class:"rui-code-block-language"},[r])),o){const m=l("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),d=E("copy",{className:"rui-code-block-copy-icon"});d&&m.append(d),m.append(l("span",{class:"rui-code-block-copy-label"},["Copy"])),m.onclick=f=>{const g=f.currentTarget??f.target,b=g.closest(".rui-code-block")?.querySelector("code")?.textContent??a,y=(typeof navigator<"u"?navigator:null)?.clipboard;y?.writeText&&y.writeText(b).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)}},c.append(m)}s.append(c)}const u=l("pre",{class:"rui-code-block-pre","data-line-numbers":n?"true":"false"});if(n||i.size>0){const c=a.split(/\r?\n/),m=l("code",{});c.forEach((d,f)=>{const g=f+1,h=l("span",{class:"rui-code-block-line","data-line":String(g),"data-highlight":i.has(g)?"true":null});n&&h.append(l("span",{class:"rui-code-block-gutter"},[String(g)])),h.append(l("span",{class:"rui-code-block-code"},[d])),m.append(h)}),u.append(m)}else u.append(l("code",{},[a]));return s.append(u),s}};function Wl(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 ql(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 Gl={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=p(e.variant),a=p(e.shape);if(a)return Kl(a,e);if(r&&r!=="paragraph")return Yl(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,u=l("div",{class:"rui-skeleton","data-variant":"paragraph"});for(let c=0;c<i;c+=1)u.append(l("div",{class:"rui-skeleton-line",style:`height:${s}px`}));return u}};function Kl(t,e){const r=te(p(e.width),"100%"),a=p(e.height),n=a?te(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 Yl(t,e){const r=l("div",{class:"rui-skeleton","data-variant":t});switch(t){case"avatar":{const a=te(p(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=te(p(e.width),"100%"),n=te(p(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 Xl={name:"Markdown",description:"Render markdown-flavoured text. Supports **bold**, *italic*, `code`, headings (`#`/`##`/`###`), blockquotes (`>`), bullet (`-`/`*`) and numbered (`1.`) lists, fenced code blocks (```), images (`![alt](src)`), inline links, and auto-linked bare URLs. Multi-line paragraphs collapse into `<p>` blocks.",props:[{name:"content",type:"string"}],render:(t,e)=>{const r=p(e.content),a=tc(r);return l("div",{class:"rui-markdown",html:a})}},Jl={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":p(e.size,"lg"),"data-padding":p(e.padding,"m"),style:e.maxWidth?`max-width:${te(e.maxWidth,"auto")};`:null});for(const n of C(e.children))a.append(r.renderNode(n));return a}},Zl={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=p(e.size),a=e.flex===void 0?!r:T(e.flex);return l("span",{class:"rui-spacer","data-size":r||null,"data-flex":a?"true":"false","aria-hidden":"true"})}},Ql={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:It,description:"Default `md`"},{name:"label",type:"string",optional:!0,description:"Caption rendered beside the spinner (also announced)"},{name:"tone",type:"string",optional:!0,enum:zl,description:"Visual accent (default `primary`)"}],render:(t,e)=>{const r=Cr(e.size,"md"),a=p(e.tone,"primary"),n=p(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}},ec={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":p(e.tone,"default")});r.append(l("blockquote",{class:"rui-quote-text"},[p(e.text)]));const a=p(e.cite);return a&&r.append(l("figcaption",{class:"rui-quote-cite"},[a])),r}};function tc(t){const e=g=>g.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),r=t.split(/\r?\n/),a=[];let n=null,i=!1,o=!1,s="",u=[];const c=()=>{n&&(a.push(n==="ul"?"</ul>":"</ol>"),n=null)},m=()=>{i&&(a.push("</blockquote>"),i=!1)},d=()=>{const g=s?` data-language="${e(s)}"`:"";a.push(`<pre class="rui-markdown-code"${g}><code>${e(u.join(`
40
+ `))}</code></pre>`),u=[],s="",o=!1};for(const g of r){const h=/^```\s*(.*)$/.exec(g.trim());if(o){if(h){d();continue}u.push(g);continue}if(h){c(),m(),o=!0,s=h[1]??"";continue}const b=/^\s*(#{1,3})\s+(.+)$/.exec(g);if(b){c(),m();const w=b[1].length;a.push(`<h${w} class="rui-markdown-h${w}">${f(e(b[2]))}</h${w}>`);continue}const v=/^\s*>\s?(.*)$/.exec(g);if(v){c(),i||(a.push('<blockquote class="rui-markdown-quote">'),i=!0),a.push(`<p>${f(e(v[1]??""))}</p>`);continue}else i&&g.trim()!==""&&m();const y=/^\s*[-*]\s+(.*)$/.exec(g);if(y){m(),n!=="ul"&&(c(),a.push("<ul>"),n="ul"),a.push(`<li>${f(e(y[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(g);if(x){m(),n!=="ol"&&(c(),a.push("<ol>"),n="ol"),a.push(`<li>${f(e(x[1]??""))}</li>`);continue}if(g.trim()===""){c(),m();continue}c(),m(),a.push(`<p>${f(e(g))}</p>`)}return o&&d(),c(),m(),a.join("");function f(g){let h=g.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(b,v,y)=>{const x=ne(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,(b,v,y)=>`<a class="rui-link" href="${Nn(y)}" target="_blank" rel="noopener noreferrer">${v}</a>`);return h=h.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,b=>`<a class="rui-link" href="${Nn(b)}" target="_blank" rel="noopener noreferrer">${b}</a>`),h}}function Nn(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,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function lt(t,e,r){const a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=ne(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"},[ct(e)]))},a.append(i)}else a.append(l("span",{class:"rui-avatar-fallback"},[ct(e)]));return a}function ct(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 Xe(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 f=d.target;f&&e.contains(f)||(m.dispose(),r())},s=d=>{d.key==="Escape"&&(m.dispose(),r())},u=e.ownerDocument;let c=null;if(u&&typeof MutationObserver<"u"){c=new MutationObserver(()=>{e.isConnected||m.dispose()});const d=e.getRootNode();(d instanceof Element||d instanceof Document||d instanceof ShadowRoot)&&c.observe(d,{childList:!0,subtree:!0})}const m={dispose:()=>{i||(i=!0,n.removeEventListener("click",o,!0),n.removeEventListener("keydown",s,!0),c?.disconnect(),zt.delete(e))}};return setTimeout(()=>{i||(n.addEventListener("click",o,!0),n.addEventListener("keydown",s,!0))},0),zt.set(e,m),m}function Ae(t){if(!t)return;const e=zt.get(t);e&&e.dispose()}const rc=[{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 rc)if(e.match.test(t))return e.icon;return null}const ac={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function nc(t){return t?ac[t.toLowerCase()]??null:null}function ic(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 Pn(t){return C(t).map(r=>{if(r&&typeof r=="object"){const n=r;if(n.__kind==="Component"&&Array.isArray(n.args)){const i=p(n.args[0]);return{value:i,label:p(n.args[1],i)}}if(n.value!==void 0||n.label!==void 0){const i=p(n.value);return{value:i,label:p(n.label,i)}}}const a=p(r);return{value:a,label:a}}).filter(r=>r.value!==""||r.label!=="")}function Je(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 oc(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const sc=/^[A-Za-z_][A-Za-z0-9_\-:/]*$/;function lc(t){return(Array.isArray(t)?t.map(r=>p(r)):p(t).split(/\s+/)).map(r=>r.trim()).filter(r=>r.length>0&&r.length<=64&&sc.test(r))}const cc={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(Je(r,e.child));const n=T(e.disabled),i=T(e.stopPropagation),o=s=>{n||(i&&s.stopPropagation(),r.invoke(e.onClick,s))};return a.addEventListener("click",o),a.addEventListener("keydown",s=>{const u=s;(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),o(u))}),a}},uc=[{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"}],dc={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");T(e.draggable)&&a.setAttribute("draggable","true"),a.append(Je(r,e.child));const n=e.passiveScroll===void 0?!0:T(e.passiveScroll);for(const{prop:i,event:o}of uc){const s=e[i];if(s==null)continue;const c=o==="scroll"||o==="wheel"?{passive:n}:{};a.addEventListener(o,m=>{r.invoke(s,m)},c)}return a}},pc=[{prop:"onKeyDown",event:"keydown"},{prop:"onKeyUp",event:"keyup"},{prop:"onKeyPress",event:"keypress"}],mc={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:T(e.focusable),n=Rt("rui-on-keyboard",a?{tabindex:"0"}:{});n.append(Je(r,e.child));for(const{prop:i,event:o}of pc){const s=e[i];s!=null&&n.addEventListener(o,u=>{r.invoke(s,u)})}return n}},fc={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(Je(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}},gc={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(Je(r,e.child));const n=typeof IntersectionObserver<"u"?IntersectionObserver:void 0;if(!n)return a;const i=Math.max(0,Math.min(1,L(e.threshold,.05))),o=p(e.rootMargin),s=T(e.once);let u=null;const c=new n(m=>{for(const d of m){const f=d.isIntersecting;if(f!==u&&(f&&e.onEnter!=null&&r.invoke(e.onEnter,d),!f&&u===!0&&e.onLeave!=null&&r.invoke(e.onLeave,d),u=f),e.onChange!=null&&r.invoke(e.onChange,{visible:f,ratio:d.intersectionRatio}),s&&f){c.disconnect();return}}},{threshold:i,...o?{rootMargin:o}:{}});return c.observe(a),r.registerDisposer(()=>c.disconnect()),a}};function hc(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 In={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=p(e.to),n=T(e.external),i=a||p(e.href),o=a?i.startsWith("/")||i.startsWith("#")?i:Ye(i,"#"):Ye(e.href,"#"),s=p(e.variant,"default"),u=l("a",{class:"rui-link","data-variant":s,href:o,target:n?"_blank":null,rel:n?"noopener noreferrer":null});for(const c of hc(r,e.label))u.append(c);return a&&!n&&u.addEventListener("click",c=>{c.defaultPrevented||c.button===0&&(c.metaKey||c.ctrlKey||c.shiftKey||c.altKey||(c.preventDefault(),r.router.navigate(a)))}),u}},bc={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=Je(r,e.child),n=a instanceof HTMLElement?a:(()=>{const s=l("span",{class:"rui-css"});return s.append(a),s})(),i=lc(e.class);for(const s of i)n.classList.add(s);const o=oc(e.style);if(o){const s=n.getAttribute("style");n.setAttribute("style",s?`${s};${o}`:o)}return n}};function ie(t,e,r,a){if(e==null)return;const n=a.event??"change";t.addEventListener(n,()=>{r.invoke(e,a.getValue(t))})}const vc=["primary","secondary","ghost","danger"],yc=["xs","sm","md","lg","xl","small","normal","large"],xc=["text","email","password","number","tel","url","date"];function wc(t){const e=p(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"}const kc={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:vc},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:yc,description:"Canonical `xs|sm|md|lg|xl` (legacy `small|normal|large` still accepted)"},{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=T(e.loading),n=T(e.iconOnly),i=p(e.iconPosition,"leading"),o=p(e.label),s=l("button",{class:"rui-button",type:p(e.type,"button"),"data-variant":p(e.variant,"primary"),"data-size":wc(e.size),"data-icon-position":i,"data-icon-only":n?"true":null,"data-full-width":T(e.fullWidth)?"true":null,"data-loading":a?"true":null,"aria-label":n?o:null,disabled:T(e.disabled)||a?"":null}),u=l("span",{class:"rui-button-label"},[o]),c=E(e.icon,{className:"rui-button-icon"}),d=(a?E("spinner",{className:"rui-button-spinner"}):null)??c;return n?d&&s.append(d):i==="trailing"?(s.append(u),d&&s.append(d)):(d&&s.append(d),s.append(u)),s.onclick=()=>{a||r.invoke(e.onClick)},s}},Sc={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":p(e.direction,"row")});for(const n of C(e.items))a.append(r.renderNode(n));return a}},Cc={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:xc},{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:p(e.id),name:p(e.id),type:p(e.type,"text"),placeholder:p(e.placeholder),value:p(e.value)});return Fe(a,t,4,r),ie(a,e.onChange,r,{event:"input",getValue:n=>n.value}),Uc(a,e.validations),a}},$c={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:p(e.id),name:p(e.id),placeholder:p(e.placeholder),rows:String(Number(e.rows??4)||4)});return a.value=p(e.value),Fe(a,t,3,r),ie(a,e.onChange,r,{event:"input",getValue:n=>n.value}),a}},Tc={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>l("option",{value:p(e.value)},[p(e.label)])},Ac={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(T(e.searchable))return _c(t,e,r);const a=l("select",{class:"rui-select",id:p(e.id),name:p(e.id)}),n=p(e.placeholder);n&&a.append(l("option",{value:"",disabled:"",selected:""},[n]));for(const i of C(e.items))a.append(r.renderNode(i));return a.value=p(e.value),Fe(a,t,4,r),ie(a,e.onChange,r,{event:"change",getValue:i=>i.value}),a}},Nc={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=T(e.value),i=l("input",{type:"checkbox",id:p(e.id),name:p(e.id),checked:n?"":null});return i.checked=n,Fe(i,t,2,r),ie(i,e.onChange,r,{event:"change",getValue:o=>o.checked}),a.append(i,l("span",{class:"rui-checkbox-label"},[p(e.label)])),a}},Mc={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=p(e.name),a=p(e.label),n=p(e.description),i=T(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 u=l("div",{class:"rui-checkbox-item-text"});return u.append(l("div",{class:"rui-checkbox-item-label"},[a])),n&&u.append(l("div",{class:"rui-checkbox-item-description"},[n])),o.append(s,u),o}},Pc={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=p(e.name),n=l("div",{class:"rui-checkbox-group",role:"group","data-name":a}),i=C(e.items),o=e.value&&typeof e.value=="object"?e.value:{};i.forEach((c,m)=>{const d=p(c.args?.[0]),f=p(c.args?.[1],`${a}-${m}`),g=p(c.args?.[2]),h=T(c.args?.[3]),b=`${a}-${f}`,v=l("label",{class:"rui-checkbox-item",for:b}),y=f in o?!!o[f]:h,x=l("input",{type:"checkbox",id:b,name:f,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,u=c=>{const m={};return c.querySelectorAll('input[type="checkbox"]').forEach(d=>{m[d.name]=d.checked}),m};return s&&r.bindState(n,s,{event:"change",getValue:u}),ie(n,e.onChange,r,{event:"change",getValue:c=>u(c)}),n}},Ic={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=p(e.id),n=l("div",{class:"rui-radio-group",role:"radiogroup"});for(const i of C(e.items)){const o=p(i.args?.[0]),s=p(i.args?.[1],o),u=`${a}-${o}`,c=l("label",{class:"rui-radio",for:u}),m=p(e.value)===o,d=l("input",{type:"radio",id:u,name:a,value:o,checked:m?"":null});d.checked=m,Fe(d,t,2,r),ie(d,e.onChange,r,{event:"change",getValue:f=>f.value}),c.append(d,l("span",{class:"rui-radio-label"},[s])),n.append(c)}return n}},Lc={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"},[p(e.label)]));const n=r.renderNode(e.field);a.append(n);const i=p(e.hint);return i&&a.append(l("p",{class:"rui-form-hint"},[i])),a}},Ln={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=E("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:p(e.id),name:p(e.id),type:"search",placeholder:p(e.placeholder,"Search…"),value:p(e.value),autocomplete:"off"});Fe(i,t,2,r),ie(i,e.onChange,r,{event:"input",getValue:s=>s.value}),a.append(i);const o=p(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"},[p(e.submitLabel,"Search")]);a.append(s)}return a}},zc={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:p(e.id)});a.onsubmit=n=>{n.preventDefault(),r.invoke(e.onSubmit)};for(const n of C(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}},Rc={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=p(e.id),n=L(e.min,0),i=L(e.max,100),o=L(e.step,1),s=L(e.value,n),u=l("div",{class:"rui-slider","data-disabled":T(e.disabled)?"true":"false"}),c=p(e.label),m=T(e.showValue);if(c||m){const g=l("div",{class:"rui-slider-head"});c&&g.append(l("label",{class:"rui-slider-label",for:a},[c])),m&&g.append(l("span",{class:"rui-slider-value"},[String(s)])),u.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:T(e.disabled)?"":null});d.oninput=g=>{const h=g.currentTarget;if(!h)return;const v=h.closest(".rui-slider")?.querySelector(".rui-slider-value");v&&(v.textContent=h.value)};const f=t.argMeta?.[4]?.stateRef;return f&&r.bindState(d,f,{event:"input",getValue:g=>Number(g.value)}),ie(d,e.onChange,r,{event:"input",getValue:g=>Number(g.value)}),u.append(d),u}},Ec={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=p(e.id),n=L(e.step,1),i=e.min!==void 0&&e.min!==null,o=e.max!==void 0&&e.max!==null,s=i?L(e.min,0):Number.NEGATIVE_INFINITY,u=o?L(e.max,0):Number.POSITIVE_INFINITY,c=T(e.disabled),m=l("div",{class:"rui-number-input","data-disabled":c?"true":"false"}),d=l("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:c?"":null},["−"]),f=l("input",{type:"number",class:"rui-number-input-field",id:a,name:a,value:p(e.value),placeholder:p(e.placeholder),min:i?String(s):null,max:o?String(u):null,step:String(n),disabled:c?"":null}),g=l("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:c?"":null},["+"]),h=t.argMeta?.[1]?.stateRef,b=y=>{const x=y.value;if(x==="")return null;const w=Number(x);return Number.isFinite(w)?w:null};h&&r.bindState(f,h,{event:"input",getValue:b}),ie(f,e.onChange,r,{event:"input",getValue:b});const v=(y,x)=>{const k=y.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!k)return;const A=Number(k.value),S=Number.isFinite(A)?A:0,$=Oc(S+x,s,u);k.value=String($),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),m.append(d,f,g),m}},jc={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=p(e.id),n=l("div",{class:"rui-date-picker"}),i=p(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:p(e.value),min:p(e.min)||null,max:p(e.max)||null,placeholder:p(e.placeholder),disabled:T(e.disabled)?"":null});return Fe(o,t,1,r),ie(o,e.onChange,r,{event:"change",getValue:s=>s.value}),n.append(o),n}},Dc={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=p(e.id),n=T(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=E(p(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});s&&o.append(s);const u=l("div",{class:"rui-file-upload-text"});u.append(l("div",{class:"rui-file-upload-label"},[p(e.label,"Choose a file")]));const c=p(e.hint);c&&u.append(l("div",{class:"rui-file-upload-hint"},[c])),o.append(u);const m=l("input",{type:"file",id:a,name:a,class:"rui-file-upload-input",accept:p(e.accept)||null,multiple:T(e.multiple)?"":null,disabled:n?"":null});o.append(m),i.append(o);const d=(f,g)=>g.includes("image")||f.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(f.name);return m.onchange=f=>{const g=f.currentTarget;r.invoke(e.onSelect,g.files);const h=g.closest(".rui-file-upload");if(!h)return;const b=g.files,v=h.querySelector(".rui-file-upload-preview");if(v&&v.remove(),!b||b.length===0)return;const y=p(e.accept),x=l("div",{class:"rui-file-upload-preview"});Array.from(b).forEach(w=>{const k=l("div",{class:"rui-file-upload-preview-item"});if(d(w,y)){const A=URL.createObjectURL(w),S=l("img",{src:A,alt:w.name,class:"rui-file-upload-thumbnail"});S.onload=()=>URL.revokeObjectURL(A),k.append(S)}k.append(l("span",{class:"rui-file-upload-filename"},[w.name])),x.append(k)}),h.append(x)},i}},zn={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=p(e.id),n=Pn(e.items),i=p(e.value),o=n.find(S=>S.value===i)?.label??i,s=p(e.placeholder,"Select…"),u=p(e.emptyLabel,"No matches"),c=T(e.disabled),m=T(e.open),d=r.useInstanceState("open",m),f=r.useInstanceState("filter",""),g=d.get(),h=l("div",{class:"rui-combobox","data-open":g?"true":"false","data-disabled":c?"true":"false"}),b=l("button",{type:"button",class:"rui-combobox-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":g?"true":"false",disabled:c?"":null});b.append(l("span",{class:"rui-combobox-value","data-placeholder":o?"false":"true"},[o||s]));const v=E("chevron-down",{className:"rui-combobox-chevron"});v&&b.append(v),h.append(b);const y=l("div",{class:"rui-combobox-panel",role:"listbox"}),x=l("input",{type:"text",class:"rui-combobox-filter",placeholder:"Filter…",autocomplete:"off",value:f.get()});y.append(x);const w=l("div",{class:"rui-combobox-list"});y.append(w);const k=(S,$)=>{S.replaceChildren();const M=$.trim().toLowerCase(),I=M===""?n:n.filter(R=>R.label.toLowerCase().includes(M)||R.value.toLowerCase().includes(M));if(I.length===0){S.append(l("div",{class:"rui-combobox-empty"},[u]));return}for(const R of I){const j=l("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":R.value,"aria-selected":R.value===i?"true":"false"},[R.label]);j.onclick=K=>{K.stopPropagation(),A(K.currentTarget,R.value)},S.append(j)}},A=(S,$)=>{const M=t.argMeta?.[2]?.stateRef;M&&r.setState(M,$),r.invoke(e.onChange,$),d.set(!1),f.set("");const I=S.closest(".rui-combobox");I?.setAttribute("data-open","false"),I?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false"),Ae(I)};return k(w,f.get()),x.oninput=S=>{const $=S.currentTarget;f.set($.value);const M=$.closest(".rui-combobox-panel")?.querySelector(".rui-combobox-list");M&&k(M,$.value)},x.onkeydown=S=>{const $=S;if($.key!=="Enter")return;$.preventDefault();const R=$.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),j=R?.getAttribute("data-value");j!=null&&R&&A(R,j)},b.onclick=S=>{if(c)return;S.stopPropagation();const $=!d.get();d.set($);const M=S.currentTarget.closest(".rui-combobox");if(M?.setAttribute("data-open",$?"true":"false"),M?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded",$?"true":"false"),!!M){if(!$){Ae(M);return}setTimeout(()=>x.focus(),0),Xe({liveRoot:M,onDismiss:()=>{d.set(!1),f.set(""),M.setAttribute("data-open","false"),M.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},h.append(y),h}},Bc={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=p(e.id),n=Pn(e.items),i=p(e.placeholder,"Select…"),o=p(e.emptyLabel,"No matches"),s=T(e.disabled),u=Math.max(0,Math.floor(Number(e.max??0))),c=Array.isArray(e.value)?e.value.map(I=>p(I)).filter(Boolean):[],m=new Set(c),d=t.argMeta?.[2]?.stateRef,f=T(e.open),g=r.useInstanceState("open",f),h=r.useInstanceState("filter",""),b=g.get(),v=l("div",{class:"rui-multiselect","data-open":b?"true":"false","data-disabled":s?"true":"false"}),y=l("button",{type:"button",class:"rui-multiselect-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":b?"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(c.length===0)x.append(l("span",{class:"rui-multiselect-placeholder"},[i]));else for(const I of c){const R=n.find(F=>F.value===I)?.label??I,j=l("span",{class:"rui-multiselect-chip","data-value":I});j.append(l("span",{class:"rui-multiselect-chip-label"},[R]));const K=l("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${R}`},["×"]);K.onclick=F=>{F.stopPropagation();const U=c.filter(J=>J!==I);w(U)},j.append(K),x.append(j)}y.append(x);const k=E("chevron-down",{className:"rui-multiselect-chevron"});k&&y.append(k),v.append(y);const A=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:h.get()});A.append(S);const $=l("div",{class:"rui-multiselect-list"});A.append($);const M=(I,R)=>{I.replaceChildren();const j=R.trim().toLowerCase(),K=j===""?n:n.filter(F=>F.label.toLowerCase().includes(j)||F.value.toLowerCase().includes(j));if(K.length===0){I.append(l("div",{class:"rui-multiselect-empty"},[o]));return}for(const F of K){const U=m.has(F.value),J=!U&&u>0&&c.length>=u,Z=l("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":F.value,"data-selected":U?"true":"false","aria-selected":U?"true":"false",disabled:J?"":null}),de=l("span",{class:"rui-multiselect-option-check"}),Se=E(U?"check":"",{className:"rui-multiselect-option-check-icon"});Se&&de.append(Se),Z.append(de),Z.append(l("span",{class:"rui-multiselect-option-label"},[F.label])),Z.onclick=ft=>{if(ft.stopPropagation(),J)return;const He=U?c.filter(Ur=>Ur!==F.value):[...c,F.value];w(He)},I.append(Z)}};return M($,h.get()),S.oninput=I=>{const R=I.currentTarget;h.set(R.value);const j=R.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");j&&M(j,R.value)},y.onclick=I=>{if(s)return;I.stopPropagation();const R=!g.get();g.set(R);const j=I.currentTarget.closest(".rui-multiselect");if(j?.setAttribute("data-open",R?"true":"false"),j?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",R?"true":"false"),!!j){if(!R){Ae(j);return}setTimeout(()=>S.focus(),0),Xe({liveRoot:j,onDismiss:()=>{g.set(!1),h.set(""),j.setAttribute("data-open","false"),j.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},v.append(A),v}},Fc={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=p(e.id),n=`${a}-from`,i=`${a}-to`,o=p(e.min),s=p(e.max),u=T(e.disabled),c=l("div",{class:"rui-date-range-picker","data-disabled":u?"true":"false"}),m=p(e.label);m&&c.append(l("label",{class:"rui-date-range-picker-label",for:n},[m]));const d=l("div",{class:"rui-date-range-picker-row"}),f=l("input",{type:"date",class:"rui-date-range-picker-input",id:n,name:n,value:p(e.from),min:o||null,max:s||null,disabled:u?"":null,"data-role":"from"});d.append(f),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:p(e.to),min:o||null,max:s||null,disabled:u?"":null,"data-role":"to"});d.append(g),c.append(d);const h=t.argMeta?.[1]?.stateRef,b=t.argMeta?.[2]?.stateRef;if(h&&r.bindState(f,h),b&&r.bindState(g,b),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}};f.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget))),g.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget)))}return c}};function Oc(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function _c(t,e,r){const a=t.argMeta?[...t.argMeta]:[];for(;a.length<5;)a.push({});a[4]?.stateRef&&(a[2]=a[4]);const n=zn.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 Fe(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 Uc(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 Re=["default","primary","success","warning","danger","info"],Oe=(t,e)=>{const r=C(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},Hc=[{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 Vc(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const a of Hc)if(a.match.test(r))return a.label;return""}const Wc={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:Re,description:"Accent tone"}],render:(t,e,r)=>{const a=p(e.layout,"default"),n=p(e.title),i=p(e.subtitle),s=p(e.eyebrow)||Vc(n,i),u=p(e.tone,"primary");if(a==="cover"){const h=Ys(p(e.imageSrc)),b=te(p(e.height),"280px"),v=l("section",{class:"rui-cover","data-tone":u,style:`background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url("${h}");min-height:${b};`}),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=p(e.caption);x&&y.append(l("p",{class:"rui-cover-caption"},[x]));const w=Oe(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 A=l("div",{class:"rui-cover-actions rui-pattern-actions"});for(const S of k)A.append(r.renderNode(S));y.append(A)}}return v.append(y),v}const c=ne(e.imageSrc),m=l("section",{class:"rui-hero","data-tone":u,"data-has-image":c?"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 f=C(e.highlights);if(f.length>0){const h=l("div",{class:"rui-hero-highlights"});for(const b of f){const v=p(b);v&&h.append(l("span",{class:"rui-hero-highlight"},[v]))}d.append(h)}const g=[e.primary,e.secondary].filter(Boolean);if(g.length>0){const h=l("div",{class:"rui-hero-ctas"});for(const b of g)h.append(r.renderNode(b));d.append(h)}if(m.append(d),c){const h=l("div",{class:"rui-hero-media"});h.append(l("img",{src:c,alt:"",loading:"lazy"})),m.append(h)}return m}},qc={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=p(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((f,g)=>{g>0&&d.append(l("span",{class:"rui-page-header-crumb-sep"},["/"])),d.append(l("span",{class:"rui-page-header-crumb"},[p(f)]))}):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"}),u=l("div",{class:"rui-page-header-title-line"});u.append(l("h1",{class:"rui-page-header-title"},[n])),e.status&&u.append(r.renderNode(e.status)),s.append(u);const c=p(e.subtitle);c&&s.append(l("p",{class:"rui-page-header-subtitle"},[c])),o.append(s);const m=Oe(e.actions,r);return m&&(m.classList.add("rui-page-header-actions"),o.append(m)),a.append(o),a}},Gc={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=ne(e.illustration);if(n)a.append(l("img",{class:"rui-empty-state-illustration",src:n,alt:"",loading:"lazy"}));else{const s=p(e.title),u=p(e.description),c=p(e.icon)||Mn(`${s} ${u}`)||"inbox",m=E(c,{className:"rui-empty-state-icon"});m&&a.append(m)}a.append(l("h3",{class:"rui-empty-state-title"},[p(e.title)]));const i=p(e.description);i&&a.append(l("p",{class:"rui-empty-state-description"},[i]));const o=C(e.actions);if(o.length>0){const s=l("div",{class:"rui-empty-state-actions"});for(const u of o)s.append(r.renderNode(u));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}},Kc={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:Re}],render:(t,e)=>{const r=l("li",{class:"rui-timeline-item","data-tone":p(e.tone,"default")}),a=l("span",{class:"rui-timeline-marker"}),n=E(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"},[p(e.title)]));const s=p(e.time);s&&o.append(l("span",{class:"rui-timeline-time"},[s])),i.append(o);const u=p(e.description);return u&&i.append(l("div",{class:"rui-timeline-description"},[u])),r.append(i),r}},Yc={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 C(e.items))a.append(r.renderNode(n));return a}},Xc={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:Re}],render:(t,e)=>{const r=l("div",{class:"rui-feature-item","data-tone":p(e.tone,"primary")}),a=p(e.icon,"sparkles"),n=E(a,{className:"rui-feature-icon"});n&&r.append(n),r.append(l("h3",{class:"rui-feature-title"},[p(e.title)]));const i=p(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 C(e.items))n.append(r.renderNode(i));return n}},Zc={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 u=l("div",{class:"rui-testimonial-rating"});for(let c=0;c<5;c+=1){const m=c<a,d=E(m?"star":"regular:star",{className:"rui-testimonial-rating-star"});d&&u.append(d)}r.append(u)}r.append(l("blockquote",{class:"rui-testimonial-quote"},[p(e.quote)]));const n=l("figcaption",{class:"rui-testimonial-author"}),i=ne(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"},[p(e.author)]));const s=p(e.role);return s&&o.append(l("div",{class:"rui-testimonial-role"},[s])),n.append(o),r.append(n),r}},Qc={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(lt(p(e.avatarSrc),p(e.name),"lg"));const i=l("div",{class:"rui-profile-card-meta"});i.append(l("h3",{class:"rui-profile-card-name"},[p(e.name)]));const o=p(e.role);o&&i.append(l("p",{class:"rui-profile-card-role"},[o])),n.append(i),a.append(n);const s=p(e.bio);s&&a.append(l("p",{class:"rui-profile-card-bio"},[s]));const u=C(e.tags);if(u.length>0){const m=l("div",{class:"rui-profile-card-tags"});for(const d of u){const f=p(d);f&&m.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[f])]))}a.append(m)}const c=Oe(e.actions,r);return c&&(c.classList.add("rui-profile-card-actions"),a.append(c)),a}},eu={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(lt(p(e.avatarSrc),p(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"},[p(e.author)]));const o=p(e.time);o&&i.append(l("span",{class:"rui-comment-time"},[o])),n.append(i),n.append(l("div",{class:"rui-comment-content"},[p(e.body)]));const s=Oe(e.actions,r);return s&&(s.classList.add("rui-comment-actions"),n.append(s)),a.append(n),a}},tu={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:Re}],render:(t,e,r)=>{const a=p(e.tone,"primary"),n=l("aside",{class:"rui-banner","data-tone":a}),i=p(e.icon)||nc(a)||"",o=E(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"},[p(e.title)]));const u=p(e.message);if(u&&s.append(l("span",{class:"rui-banner-message"},[u])),n.append(s),e.action){const c=l("div",{class:"rui-banner-action"});c.append(r.renderNode(e.action)),n.append(c)}return n}},ru={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:Re},{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":p(e.tone,"default")});typeof e.onClick=="function"&&(a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.onclick=()=>r.invoke(e.onClick),a.onkeydown=c=>{const m=c;(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),r.invoke(e.onClick))});const n=l("div",{class:"rui-kanban-card-title"}),i=E(e.icon,{className:"rui-kanban-card-icon"});i&&n.append(i),n.append(document.createTextNode(p(e.title))),a.append(n);const o=p(e.description);o&&a.append(l("p",{class:"rui-kanban-card-description"},[o]));const s=C(e.tags);if(s.length>0){const c=l("div",{class:"rui-kanban-card-tags"});for(const m of s){const d=p(m);d&&c.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[d])]))}a.append(c)}const u=p(e.assignee);if(u){const c=l("footer",{class:"rui-kanban-card-footer"});c.append(lt("",u,"sm")),c.append(l("span",{class:"rui-kanban-card-assignee"},[u])),a.append(c)}return a}},au={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:Re,description:"Header accent tone"}],render:(t,e,r)=>{const a=C(e.items),n=l("section",{class:"rui-kanban-column","data-tone":p(e.tone,"default")}),i=l("header",{class:"rui-kanban-column-header"});i.append(l("span",{class:"rui-kanban-column-title"},[p(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}},nu={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 C(e.columns))a.append(r.renderNode(n));return a}},iu={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=p(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"},[p(e.title)])),e.status&&o.append(r.renderNode(e.status)),n.append(o);const s=p(e.subtitle);s&&n.append(l("p",{class:"rui-section-header-subtitle"},[s])),a.append(n);const u=Oe(e.actions,r);return u&&(u.classList.add("rui-section-header-actions"),a.append(u)),a}},ou={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=C(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"});T(e.searchable)&&i.append(Ln.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:p(e.searchPlaceholder,"Search…"),value:e.searchValue},r));for(const s of C(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 u of a)s.append(r.renderNode(u));n.append(s)}const o=l("div",{class:"rui-toolbar-side rui-toolbar-right"});for(const s of C(e.right))o.append(r.renderNode(s));return n.append(o),n}},su={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=p(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?T(e.active):o,u=l("button",{type:"button",class:"rui-sidebar-item","data-active":s?"true":"false","data-to":a||null}),c=E(e.icon,{className:"rui-sidebar-item-icon"});c&&u.append(c),u.append(l("span",{class:"rui-sidebar-item-label"},[p(e.label)]));const m=p(e.badge);return m&&u.append(l("span",{class:"rui-sidebar-item-badge"},[m])),(a||e.onClick!=null)&&(u.onclick=d=>{if(a){const f=d;if(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey)return;r.router.navigate(a)}e.onClick!=null&&r.invoke(e.onClick)}),u}},lu={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=p(e.label);n&&a.append(l("div",{class:"rui-sidebar-section-label"},[n]));for(const i of C(e.items))a.append(r.renderNode(i));return a}},cu={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=T(e.collapsed),n=l("aside",{class:"rui-sidebar"});a&&(n.dataset.collapsed="true");const i=p(e.brand),o=p(e.tagline);if(i||o){const c=l("div",{class:"rui-sidebar-header"});i&&c.append(l("div",{class:"rui-sidebar-brand"},[i])),o&&c.append(l("div",{class:"rui-sidebar-tagline"},[o])),n.append(c)}const s=l("nav",{class:"rui-sidebar-body"});for(const c of C(e.items))s.append(r.renderNode(c));n.append(s);const u=C(e.footer);if(u.length>0){const c=l("div",{class:"rui-sidebar-footer"});for(const m of u)c.append(r.renderNode(m));n.append(c)}return n}},uu={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=T(e.collapsible),n=T(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 m=l("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});m.addEventListener("click",()=>{delete i.dataset.sidebarOpen}),i.append(m)}const s=l("div",{class:"rui-app-shell-main"}),u=C(e.topbar);if(u.length>0||a){const m=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(E("bars",{size:"md"})??document.createTextNode("≡")),d.addEventListener("click",()=>{i.dataset.sidebarOpen?delete i.dataset.sidebarOpen:i.dataset.sidebarOpen="true"}),m.append(d)}for(const d of u)m.append(r.renderNode(d));s.append(m)}const c=l("div",{class:"rui-app-shell-content"});for(const m of C(e.content))c.append(r.renderNode(m));return s.append(c),i.append(s),i}},du={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=te(p(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 C(e.primary))i.append(r.renderNode(s));const o=l("div",{class:"rui-split-view-detail"});for(const s of C(e.detail))o.append(r.renderNode(s));return n.append(i,o),n}},pu={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=E(e.icon,{className:"rui-description-icon"});i&&n.append(i),n.append(document.createTextNode(p(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(p(e.value))),a.append(n,o),a}},mu={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 C(e.items))n.append(r.renderNode(i));return n}},fu={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":p(e.tone,"success"),"data-pulse":T(e.pulse)?"true":"false"});return r.append(l("span",{class:"rui-status-dot-marker"})),r.append(l("span",{class:"rui-status-dot-label"},[p(e.label)])),r}},gu={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=T(e.featured),n=l("article",{class:"rui-pricing-card","data-featured":a?"true":"false"}),i=p(e.badge);i&&n.append(l("div",{class:"rui-pricing-card-badge"},[i])),n.append(l("h3",{class:"rui-pricing-card-plan"},[p(e.plan)]));const o=p(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"},[p(e.price)]));const u=p(e.period);u&&s.append(l("span",{class:"rui-pricing-card-period"},[u])),n.append(s);const c=C(e.features);if(c.length>0){const m=l("ul",{class:"rui-pricing-card-features"});for(const d of c){const f=p(d);if(!f)continue;const g=E("circle-check",{className:"rui-pricing-card-check"})??l("span",{class:"rui-pricing-card-check"});m.append(l("li",{class:"rui-pricing-card-feature"},[g,document.createTextNode(f)]))}n.append(m)}if(e.action){const m=l("div",{class:"rui-pricing-card-action"});m.append(r.renderNode(e.action)),n.append(m)}return n}},hu={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 C(e.tiers))n.append(r.renderNode(i));return n}},bu={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=p(e.orientation,"vertical"),n=l("article",{class:"rui-media-card","data-orientation":a}),i=vu(p(e.ratio,a==="horizontal"?"4:3":"16:9")),o=l("div",{class:"rui-media-card-media",style:`aspect-ratio:${i};`}),s=ne(e.imageSrc);if(s)o.append(l("img",{src:s,alt:p(e.title),loading:"lazy"}));else{o.classList.add("rui-media-card-media-empty");const g=E("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(p(e.badge))):g.append(r.renderNode(e.badge)),o.append(g)}n.append(o);const u=l("div",{class:"rui-media-card-body"});u.append(l("h3",{class:"rui-media-card-title"},[p(e.title)]));const c=p(e.description);c&&u.append(l("p",{class:"rui-media-card-description"},[c]));const m=C(e.tags);if(m.length>0){const g=l("div",{class:"rui-media-card-tags"});for(const h of m){const b=p(h);b&&g.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[b])]))}u.append(g)}const d=p(e.meta);d&&u.append(l("p",{class:"rui-media-card-meta"},[d]));const f=Oe(e.actions,r);return f&&(f.classList.add("rui-media-card-actions"),u.append(f)),n.append(u),n}};function vu(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 $r(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),u=s-o||1,c=80/(t.length-1),d=t.map((b,v)=>{const y=v*c,x=2+(s-b)/u*20;return[y,x]}).map(([b,v],y)=>`${y===0?"M":"L"}${b.toFixed(1)},${v.toFixed(1)}`).join(" "),f=`${d} L80,24 L0,24 Z`,g=document.createElementNS(n,"path");g.setAttribute("d",f),g.setAttribute("class","rui-sparkline-area"),i.appendChild(g);const h=document.createElementNS(n,"path");return h.setAttribute("d",d),h.setAttribute("class","rui-sparkline-line"),h.setAttribute("fill","none"),i.appendChild(h),i}const yu={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=C(e.items),n=a.some(u=>u&&typeof u=="object"&&u.__kind==="Component");if(p(e.layout,n?"grid":"strip")==="grid"){const u=e.columns?Math.max(1,Math.min(6,Math.floor(L(e.columns)))):0,c=Cn.render({__kind:"Component",name:"Grid",args:[],argMeta:[]},{children:a,columns:u>0?u:"auto",gap:"m"},r);return c.classList.add("rui-metric-grid"),c}const o=p(e.align,"start"),s=l("div",{class:"rui-stats","data-align":o});for(const u of a){const c=u??{},m=p(c.tone,"default"),d=l("div",{class:"rui-stats-item","data-tone":m});d.append(l("div",{class:"rui-stats-label"},[p(c.label)]));const f=l("div",{class:"rui-stats-value-row"});f.append(l("div",{class:"rui-stats-value"},[p(c.value)]));const g=C(c.spark).map(b=>Number(b)).filter(b=>Number.isFinite(b));g.length>1&&f.append($r(g,m)),d.append(f);const h=p(c.hint);h&&d.append(l("div",{class:"rui-stats-hint"},[h])),s.append(d)}return s}},xu={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:Re},{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":p(e.tone,"default")}),o=E(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"},[p(e.label)]));const u=p(e.value);u&&s.append(l("div",{class:"rui-tile-value"},[u]));const c=p(e.description);return c&&s.append(l("div",{class:"rui-tile-description"},[c])),i.append(s),a&&(i.onclick=()=>r.invoke(e.onClick)),i}},Rn={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:Re},{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=T(e.unread),n=l("article",{class:"rui-notification","data-tone":p(e.tone,"default"),"data-unread":a?"true":"false"}),i=p(e.avatarSrc),o=l("div",{class:"rui-notification-visual"});if(i)o.append(lt(i,p(e.title),"md"));else{const g=E(p(e.icon,"bell"),{className:"rui-notification-icon"});g&&o.append(g)}n.append(o);const s=l("div",{class:"rui-notification-body"}),u=l("header",{class:"rui-notification-head"}),c=l("span",{class:"rui-notification-title-wrap"});a&&c.append(l("span",{class:"rui-notification-unread-dot","aria-label":"Unread"})),c.append(l("span",{class:"rui-notification-title"},[p(e.title)])),u.append(c);const m=p(e.time);m&&u.append(l("span",{class:"rui-notification-time"},[m])),s.append(u);const d=p(e.message);d&&s.append(l("p",{class:"rui-notification-message"},[d]));const f=Oe(e.actions,r);return f&&(f.classList.add("rui-notification-actions"),s.append(f)),n.append(s),n}},wu={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=p(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}),u=l("span",{class:"rui-person-chip-avatar"});u.append(lt(p(e.avatarSrc),p(e.name),o));const c=p(e.status);c&&u.append(l("span",{class:"rui-person-chip-status","data-status":c})),s.append(u);const m=l("div",{class:"rui-person-chip-meta"});m.append(l("span",{class:"rui-person-chip-name"},[p(e.name)]));const d=p(e.role);return d&&m.append(l("span",{class:"rui-person-chip-role"},[d])),s.append(m),a&&(s.onclick=()=>r.invoke(e.onClick)),s}},En=["left","center","right"],ku={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:En,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",{},[p(e.header)])),r}},Su={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=C(e.columns),n=p(e.density,"comfortable"),i=T(e.striped),o=T(e.sticky),s=l("div",{class:"rui-table-wrapper","data-density":n,"data-striped":i?"true":"false","data-sticky":o?"true":"false"}),u=l("table",{class:"rui-table"}),c=p(e.caption);c&&u.append(l("caption",{class:"rui-table-caption"},[c]));const m=a.map(w=>{const k=p(w.args?.[3],"");return En.includes(k)?k:""}),d=l("thead"),f=l("tr");for(let w=0;w<a.length;w+=1){const k=a[w],A=l("th",{"data-align":m[w]||null},[p(k.args?.[0])]);f.append(A)}d.append(f),u.append(d);const g=l("tbody"),h=a.map(w=>C(w.args?.[1])),b=a.map(w=>p(w.args?.[2],"text")),v=a.map(w=>w.args?.[6]),y=a.map(w=>w.args?.[7]),x=Math.max(0,...h.map(w=>w.length));for(let w=0;w<x;w+=1){const k=l("tr");h.forEach((A,S)=>{const $=b[S]??"text",M=m[S],I=l("td",{"data-format":$,"data-align":M||null});hr(I,{format:$,render:v[S],onClick:y[S]},A[w],w,r,Iu),k.append(I)}),g.append(k)}if(x===0){const w=l("tr"),k=p(e.emptyLabel,"No data");w.append(l("td",{colspan:String(a.length||1),class:"rui-table-empty"},[k])),g.append(w)}return u.append(g),s.append(u),s}},Cu={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=E(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"},[p(e.title)]));const i=p(e.description);return i&&n.append(l("div",{class:"rui-list-description"},[i])),r.append(n),r}},$u={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=T(e.ordered)?"ol":"ul",n=l(a,{class:"rui-list"});for(const i of C(e.items))n.append(r.renderNode(i));return n}},Tu={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=p(e.tone,"default"),a=l("div",{class:"rui-stat-card","data-tone":r}),n=l("div",{class:"rui-stat-label-row"}),i=p(e.label),o=p(e.icon)||Mn(i)||"",s=E(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"},[p(e.value)]));const u=p(e.delta),c=p(e.trend);(u||c)&&a.append(l("div",{class:"rui-stat-trend","data-trend":c||"flat"},[u||Pu(c)]));const m=C(e.spark).map(d=>L(d));if(m.length>1){const d=l("div",{class:"rui-stat-spark"});d.append($r(m,r==="default"?"primary":r)),a.append(d)}return a}},Au={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=p(e.tone,"primary"),a=C(e.values).map(i=>L(i)),n=l("span",{class:"rui-sparkline-wrap"});return n.append($r(a,r)),n}},Nu={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=C(e.children),n=a.length>0,i=T(e.expanded),o=T(e.active),s=typeof e.onClick=="function",u=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 h=E("chevron-right",{className:"rui-tree-node-chevron"});h&&u.append(h)}else u.append(l("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const c=E(e.icon,{className:"rui-tree-node-icon"});c&&u.append(c),u.append(l("span",{class:"rui-tree-node-label"},[p(e.label)]));const m=p(e.badge);if(m&&u.append(l("span",{class:"rui-tree-node-badge"},[m])),s&&(u.onclick=()=>r.invoke(e.onClick)),!n)return u;const d=l("details",{class:"rui-tree-node"});i&&d.setAttribute("open","");const f=l("summary",{class:"rui-tree-node-summary"});f.append(u),s&&(f.onclick=h=>{h.target?.closest(".rui-tree-node-chevron")||h.preventDefault()}),d.append(f);const g=l("div",{class:"rui-tree-node-children",role:"group"});for(const h of a)g.append(r.renderNode(h));return d.append(g),d}},Mu={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 C(e.items))a.append(r.renderNode(n));return a}};function Pu(t){return t==="up"?"▲":t==="down"?"▼":"—"}function Iu(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():p(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):p(t);case"date":try{const r=new Date(p(t));return Number.isNaN(r.getTime())?p(t):r.toLocaleDateString()}catch{return p(t)}default:return p(t)}}const Tr=["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)"],Ze=t=>Tr[t%Tr.length]??Tr[0],Lu={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":p(e.name)})},jn=t=>t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>L(o));return{name:n,values:i}}),zu={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=C(e.labels).map(y=>p(y)),a=jn(C(e.series)),n=l("div",{class:"rui-chart rui-bar-chart"});p(e.title)&&n.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const i=Math.max(1,...a.flatMap(y=>y.values)),o=640,s=240,u=Bn(r,o-40-12),c={left:40,right:12,top:12,bottom:u.bottomPadding},m=o-c.left-c.right,d=s-c.top-c.bottom,f=Ar(o,s);On(f,c,m,d,i);const g=r.length,h=m/Math.max(g,1),b=a.length,v=h*.7/Math.max(b,1);return a.forEach((y,x)=>{y.values.forEach((w,k)=>{const A=w/i*d,S=c.left+k*h+h*.15+x*v,$=c.top+d-A,M=ge("rect",{x:String(S),y:String($),width:String(Math.max(v-2,1)),height:String(A),fill:Ze(x),rx:"2"});M.append(ge("title",{},[`${y.name}: ${w}`])),f.append(M)})}),Fn(f,r,c,m,d,u,y=>c.left+(y+.5)*h),n.append(f),a.length>0&&n.append(Nr(a)),n}},Ru={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=C(e.labels).map($=>p($)),a=jn(C(e.series));const n=C(e.data);if(n.length>0&&(r.length===0||a.length===0)){const $=[],M=new Map;for(const I of n){const R=I;if(!(!R||typeof R!="object")){$.push(p(R.x??R.label??""));for(const[j,K]of Object.entries(R)){if(j==="x"||j==="label")continue;const F=L(K);Number.isNaN(F)||(M.has(j)||M.set(j,[]),M.get(j).push(F))}}}r.length===0&&(r=$),a.length===0&&(a=[...M.entries()].map(([I,R])=>({name:I,values:R})))}const i=e.filled===!0,o=e.stacked===!0,s=Math.max(r.length,...a.map($=>$.values.length),1),u=a.map(()=>Array(s).fill(0));if(i&&o)for(let $=0;$<s;$+=1){let M=0;a.forEach((I,R)=>{M+=I.values[$]??0,u[R][$]=M})}const c=l("div",{class:"rui-chart rui-line-chart","data-filled":i?"true":"false"});p(e.title)&&c.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const m=i&&o?u.flat():a.flatMap($=>$.values),d=Math.max(1,...m),f=i&&o?0:Math.min(0,...m),g=640,h=240,b=Bn(r,g-40-12),v={left:40,right:12,top:12,bottom:b.bottomPadding},y=g-v.left-v.right,x=h-v.top-v.bottom,w=Ar(g,h);On(w,v,y,x,d,f);const k=Math.max(r.length-1,1),A=y/k,S=$=>v.left+$*(y/Math.max(s-1,1));return a.forEach(($,M)=>{const I=i&&o?u[M]:$.values,R=i&&o&&M>0?u[M-1]:null,j=I.map((F,U)=>{const J=S(U),Z=v.top+x-(F-f)/(d-f||1)*x;return[J,Z]});if(i&&j.length>0){let F=j.map(([U,J],Z)=>`${Z===0?"M":"L"}${U.toFixed(1)},${J.toFixed(1)}`).join(" ");if(R){const U=R.map((J,Z)=>{const de=S(Z),Se=v.top+x-(J-f)/(d-f||1)*x;return[de,Se]});F+=" "+U.slice().reverse().map(([J,Z])=>`L${J.toFixed(1)},${Z.toFixed(1)}`).join(" ")+" Z"}else{const U=j[0],J=j[j.length-1];F+=` L${J[0].toFixed(1)},${(v.top+x).toFixed(1)} L${U[0].toFixed(1)},${(v.top+x).toFixed(1)} Z`}w.append(ge("path",{d:F,fill:Ze(M),"fill-opacity":"0.2",stroke:"none"}))}const K=j.map(([F,U],J)=>`${J===0?"M":"L"}${F.toFixed(1)},${U.toFixed(1)}`).join(" ");w.append(ge("path",{d:K,fill:"none",stroke:Ze(M),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),$.values.length<=30&&j.forEach(([F,U])=>{w.append(ge("circle",{cx:String(F),cy:String(U),r:"3",fill:Ze(M)}))})}),Fn(w,r,v,y,x,b,$=>v.left+$*A),c.append(w),a.length>0&&c.append(Nr(a)),c}},Eu={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=C(e.labels).map(b=>p(b)),a=C(e.values).map(b=>L(b)),n=e.showValues==null?!0:T(e.showValues),i=p(e.valueFormat,"value").toLowerCase(),o=i==="percent"?"percent":i==="both"?"both":"value",s=l("div",{class:"rui-chart rui-pie-chart"});p(e.title)&&s.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const u=a.reduce((b,v)=>b+(v>0?v:0),0)||1,c=Ar(240,240),m=120,d=120,f=90,g=.05;let h=-Math.PI/2;return a.forEach((b,v)=>{const y=b>0?b:0,x=y/u,w=x*Math.PI*2,k=h+w,A=w>Math.PI?1:0,S=m+f*Math.cos(h),$=d+f*Math.sin(h),M=m+f*Math.cos(k),I=d+f*Math.sin(k),R=`M${m},${d} L${S},${$} A${f},${f} 0 ${A} 1 ${M},${I} Z`,j=ge("path",{d:R,fill:Ze(v),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});if(j.append(ge("title",{},[`${r[v]??""}: ${b} (${(x*100).toFixed(1)}%)`])),c.append(j),n&&y>0&&x>=g){const K=h+w/2,F=f*.62,U=m+F*Math.cos(K),J=d+F*Math.sin(K),Z=ju(b,x,o),de=ge("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]);c.append(de)}h=k}),s.append(c),s.append(Nr(r.map((b,v)=>({name:b,values:[a[v]??0]})))),s}};function ju(t,e,r){const a=`${Math.round(e*100)}%`,n=Du(t);return r==="percent"?a:r==="both"?`${n} (${a})`:n}function Du(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 Bu=7,Dn=12;function Bn(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*Bu+4<=r)return{step:1,rotated:!1,maxChars:a,bottomPadding:32};const n=r<Dn?Math.max(1,Math.ceil(Dn/r)):1,i=Math.min(a,14);return{step:n,rotated:!0,maxChars:i,bottomPadding:60}}function Fu(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function Fn(t,e,r,a,n,i,o){const s=r.top+n+(i.rotated?14:18);e.forEach((u,c)=>{if(c%i.step!==0)return;const m=o(c),d=Fu(u,i.maxChars),f={x:String(m),y:String(s),class:"rui-chart-label","text-anchor":i.rotated?"end":"middle"};i.rotated&&(f.transform=`rotate(-45, ${m}, ${s})`);const g=ge("text",f,[d]);d!==u&&g.append(ge("title",{},[u])),t.append(g)})}function Ar(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 ge(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,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const u=s/4,c=e.top+a-u*a;t.append(ge("line",{x1:String(e.left),x2:String(e.left+r),y1:String(c),y2:String(c),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ge("text",{x:String(e.left-6),y:String(c+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((i+(n-i)*u)*10)/10)]))}}function Nr(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:${Ze(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const Ou={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"},[p(e.title)]));const n=p(e.description);n&&a.append(l("p",{class:"rui-section-block-description"},[n]));for(const i of C(e.children))a.append(r.renderNode(i));return a}},_u={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=T(e.ordered)?"ol":"ul",a=l(r,{class:"rui-list-block"});for(const n of C(e.items))a.append(l("li",{},[p(n)]));return a}},Uu={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=p(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 C(e.items))i.append(Hu(o,r));return a.append(i),a}},Hu=(t,e)=>{const{label:r,message:a}=Vu(t),n=l("button",{class:"rui-follow-up-button",type:"button"},[r]);return n.onclick=()=>{e.sendToAssistant(a)},n},Vu=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=p(r.args[0]),o=p(r.args[1],i);return{label:i,message:o}}const a=p(r.label),n=p(r.message,a);return{label:a,message:n}}const e=p(t);return{label:e,message:e}},Wu={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=p(e.label),n=p(e.message,a),i=l("button",{class:"rui-follow-up-button",type:"button"},[a]);return i.onclick=()=>{r.sendToAssistant(n)},i}},qu={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"},[p(e.label)]);return a.onclick=n=>{n.preventDefault(),r.invoke(e.onClick)},a}},_n=["sm","md","lg","xl"],Un={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:_n},{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=p(e.size,"md"),a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=p(e.name),i=p(e.fallback,"dicebear"),o=ne(e.src),s=!o&&i==="dicebear"&&n?ne(ic(n)):"",u=o||s;if(u){const m=l("img",{src:u,alt:n,loading:"lazy"});m.onerror=d=>{const f=d;(f.currentTarget??f.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[ct(n)]))},a.append(m)}else a.append(l("span",{class:"rui-avatar-fallback"},[ct(n)]));const c=p(e.status);return c&&a.append(l("span",{class:"rui-avatar-status","data-status":c})),a}},Gu={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:_n}],render:(t,e,r)=>{const a=C(e.items),n=Math.max(1,Math.floor(Number(e.max??4))),i=p(e.size,"md"),o=a.slice(0,n),s=a.length-o.length,u=l("div",{class:"rui-avatar-group","data-size":i});for(const c of o){if(c&&typeof c=="object"&&c.__kind==="Component"){u.append(r.renderNode(c));continue}const m=c,d=typeof m=="string"?m:p((m??{}).name),f=typeof m=="string"?"":p((m??{}).src);u.append(Un.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:d,src:f,size:i},r))}return s>0&&u.append(l("span",{class:"rui-avatar rui-avatar-overflow","data-size":i},[l("span",{class:"rui-avatar-fallback"},[`+${s}`])])),u}},Ku={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,L(e.max,100)),a=T(e.indeterminate),n=Math.max(0,Math.min(r,L(e.value,0))),i=Math.round(n/r*100),o=Math.max(0,Math.floor(L(e.segments,0))),s=e.buffered!=null?Math.max(0,Math.min(r,L(e.buffered,0))):null,u=l("div",{class:"rui-progress","data-tone":p(e.tone,"primary")}),c=p(e.label),m=T(e.showValue);if(c||m){const f=l("div",{class:"rui-progress-head"});if(f.append(l("span",{class:"rui-progress-label"},[c])),m&&!a){const g=o>0?`${Math.min(o,Math.round(n/r*o))} / ${o}`:`${i}%`;f.append(l("span",{class:"rui-progress-value"},[g]))}u.append(f)}if(o>0&&!a){const f=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 h=0;h<o;h+=1)f.append(l("span",{class:"rui-progress-segment","data-filled":h<g?"true":"false"}));return u.append(f),u}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 f=Math.round(s/r*100);d.append(l("div",{class:"rui-progress-buffer",style:`width:${f}%`,"aria-hidden":"true"}))}return d.append(l("div",{class:"rui-progress-bar",style:a?"":`width:${i}%`})),u.append(d),u}},Yu={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=p(e.id),n=l("label",{class:"rui-switch",for:a,"data-disabled":T(e.disabled)?"true":"false"}),i=T(e.value),o=l("input",{type:"checkbox",id:a,name:a,class:"rui-switch-input",role:"switch",checked:i?"":null,disabled:T(e.disabled)?"":null});o.checked=i;const s=l("span",{class:"rui-switch-track"},[l("span",{class:"rui-switch-thumb"})]),u=t.argMeta?.[2]?.stateRef;u&&r.bindState(o,u,{event:"change",getValue:d=>d.checked}),e.onChange!=null&&o.addEventListener("change",d=>{r.invoke(e.onChange,d.currentTarget.checked)});const c=p(e.label),m=p(e.description);if(n.append(o,s),c||m){const d=l("span",{class:"rui-switch-meta"});c&&d.append(l("span",{class:"rui-switch-label"},[c])),m&&d.append(l("span",{class:"rui-switch-description"},[m])),n.append(d)}return n}},Xu={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=p(e.value),n=p(e.variant,"outline"),i=p(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 u of C(e.items)){const{value:c,label:m,icon:d}=Ju(u),f=c===a,g=l("button",{type:"button",class:"rui-toggle",role:"radio","aria-checked":f?"true":"false","data-variant":n,"data-size":i,"data-state":f?"on":"off","data-value":c}),h=E(d,{className:"rui-toggle-icon"});h&&g.append(h),g.append(l("span",{class:"rui-toggle-label"},[m])),g.onclick=()=>{s&&r.setState(s,c),r.invoke(e.onChange,c)},o.append(g)}return o}};function Ju(t){if(typeof t=="string")return{value:t,label:t,icon:""};if(Array.isArray(t))return{value:p(t[0]),label:p(t[1],p(t[0])),icon:p(t[2])};if(t&&typeof t=="object"){const e=t,r=p(e.value);return{value:r,label:p(e.label,r),icon:p(e.icon)}}return{value:"",label:"",icon:""}}const Zu={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=p(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"},[p(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}},Qu={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":p(e.side,"bottom"),"data-open":T(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 C(e.content))n.append(r.renderNode(i));return a.append(n),a}},Mr={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"}},ed={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` and a `$variable` as `value` to let users rate something; 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(L(e.max,5))),n=Math.max(0,Math.min(a,L(e.value,0))),i=p(e.size,"md"),o=T(e.interactive)&&!T(e.readonly),s=T(e.halfStep),u=t.argMeta?.[0]?.stateRef,c=td(p(e.icon)),m=l("div",{class:"rui-rating","data-size":i,"data-interactive":o&&u?"true":"false","data-half-step":o&&u&&s?"true":"false",role:"img","aria-label":`${n} of ${a}`}),d=l("span",{class:"rui-rating-stars"});for(let h=1;h<=a;h+=1){const b=Math.max(0,Math.min(1,n-(h-1))),v=b>=1?c.full:b>0?c.half:c.empty,y=gr(v).join(" "),x=l(o&&u?"button":"span",{class:`rui-rating-star ${y}`.trim(),type:o&&u?"button":null,"data-fill":b>=1?"full":b>0?"half":"empty","aria-label":o&&u?`Rate ${h}`:null,"aria-hidden":o&&u?null:"true"});if(o&&u){const w=h,k=h-.5;x.onclick=A=>{let S=w;if(s){const $=A,I=($.currentTarget??$.target).getBoundingClientRect();I.width>0&&$.clientX-I.left<I.width/2&&(S=k)}r.setState(u,S),r.invoke(e.onChange,S)}}d.append(x)}m.append(d);const f=p(e.label);f&&m.append(l("span",{class:"rui-rating-label"},[f]));const g=e.count!=null?L(e.count,0):null;return g!==null&&g>0&&m.append(l("span",{class:"rui-rating-count"},[`(${g.toLocaleString()})`])),m}};function td(t){const e=t.trim().toLowerCase();return e?Mr[e]?Mr[e]:{full:e,half:e,empty:`regular:${e}`}:Mr.star}const rd={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,L(e.max,100)),a=T(e.indeterminate),n=Math.max(0,Math.min(r,L(e.value,0))),i=Math.round(n/r*100),o=p(e.size,"md"),s=o==="lg"?120:o==="sm"?72:96,u=o==="lg"?10:o==="sm"?6:8,c=(s-u)/2,m=2*Math.PI*c,d=a?m*.65:m*(1-i/100),f=l("div",{class:"rui-progress-ring","data-tone":p(e.tone,"primary"),"data-size":o,"data-indeterminate":a?"true":"false"}),g=l("div",{class:"rui-progress-ring-wrap"}),h="http://www.w3.org/2000/svg",b=document.createElementNS(h,"svg");b.setAttribute("width",String(s)),b.setAttribute("height",String(s)),b.setAttribute("viewBox",`0 0 ${s} ${s}`),b.setAttribute("class","rui-progress-ring-svg");const v=document.createElementNS(h,"circle");v.setAttribute("class","rui-progress-ring-track"),v.setAttribute("cx",String(s/2)),v.setAttribute("cy",String(s/2)),v.setAttribute("r",String(c)),v.setAttribute("stroke-width",String(u)),v.setAttribute("fill","none"),b.appendChild(v);const y=document.createElementNS(h,"circle");y.setAttribute("class","rui-progress-ring-bar"),y.setAttribute("cx",String(s/2)),y.setAttribute("cy",String(s/2)),y.setAttribute("r",String(c)),y.setAttribute("stroke-width",String(u)),y.setAttribute("fill","none"),y.setAttribute("stroke-linecap","round"),y.setAttribute("stroke-dasharray",String(m)),y.setAttribute("stroke-dashoffset",String(d)),b.appendChild(y),g.append(b);const x=p(e.label,a?"…":`${i}%`),w=l("span",{class:"rui-progress-ring-value"}),k=E(x,{className:"rui-progress-ring-icon"});k&&gr(x).length>0?w.append(k):w.append(document.createTextNode(x)),g.append(w),f.append(g);const A=p(e.caption);return A&&f.append(l("span",{class:"rui-progress-ring-caption"},[A])),f}},ad={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=p(e.from,"agent"),a=l("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&a.append(Hn(p(e.avatarSrc),p(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"},[p(e.author)]));const o=p(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"},[p(e.body)]));const s=p(e.status);return s&&n.append(l("span",{class:"rui-chat-bubble-status","data-status":s},[s])),a.append(n),r==="me"&&a.append(Hn(p(e.avatarSrc),p(e.author))),a}};function Hn(t,e){const r=l("span",{class:"rui-chat-bubble-avatar"}),a=ne(t);return a?r.append(l("img",{src:a,alt:e,loading:"lazy"})):r.append(l("span",{class:"rui-chat-bubble-fallback"},[ct(e)])),r}const nd={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=p(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=p(i);s&&(o>0&&a.append(l("span",{class:"rui-kbd-sep"},["+"])),a.append(l("kbd",{class:"rui-kbd"},[s])))}),a}},id={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=T(e.open),n=r.useInstanceState("open",a),i=n.get(),o=te(e.width,""),s=l("div",{class:"rui-popover","data-open":i?"true":"false","data-side":p(e.side,"bottom"),"data-align":p(e.align,"start")}),u=l("span",{class:"rui-popover-trigger","data-state":i?"open":"closed","aria-haspopup":"dialog","aria-expanded":i?"true":"false"});u.append(r.renderNode(e.trigger)),s.append(u);const c=l("div",{class:"rui-popover-content",role:"dialog",style:o?`width: ${o};`:null}),m=l("div",{class:"rui-popover-header"}),d=p(e.title);m.append(d?l("div",{class:"rui-popover-title"},[d]):l("span",{class:"rui-popover-title-spacer"}));const f=l("button",{type:"button",class:"rui-popover-close","aria-label":"Close popover"},["×"]);f.onclick=g=>{g.stopPropagation(),Et(f,!1,n)},m.append(f),c.append(m);for(const g of C(e.content))c.append(r.renderNode(g));return s.append(c),u.onclick=g=>{g.stopPropagation();const h=g.currentTarget??g.target,b=!n.get(),v=Et(h,b,n);b&&v&&Vn(v,n)},u.onkeydown=g=>{const h=g,b=h.currentTarget??h.target;if(h.key==="Enter"||h.key===" "){h.preventDefault();const v=!n.get(),y=Et(b,v,n);v&&y&&Vn(y,n)}else h.key==="Escape"&&n.get()&&(h.preventDefault(),Et(b,!1,n))},s}},Et=(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||Ae(a),a},Vn=(t,e)=>{Xe({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")}})},od={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=p(e.tone,"default"),n=p(e.position),i=l("div",{class:n?"rui-toast rui-toast-standalone":"rui-toast",role:"status","aria-live":a==="danger"?"assertive":"polite","data-tone":a,"data-position":n||null}),o=p(e.icon)||sd(a),s=E(o,{className:"rui-toast-icon"});s&&i.append(s);const u=l("div",{class:"rui-toast-body"});u.append(l("div",{class:"rui-toast-title"},[p(e.title)]));const c=p(e.message);if(c&&u.append(l("div",{class:"rui-toast-message"},[c])),e.action){const x=l("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),u.append(x)}i.append(u);const m=r.useInstanceState("dismissed",!1),d=r.useInstanceState("timer",null),f=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))},h=r.useInstanceState("removal-timer",null),b=x=>{if(m.get())return;m.set(!0),g();const w=f(x);if(!w)return;w.classList.add("is-dismissed");const k=setTimeout(()=>{h.set(null),w.remove()},180);h.set(k),r.registerDisposer(()=>{const A=h.get();A!==null&&(clearTimeout(A),h.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(),b(x.currentTarget??x.target)},i.append(v);const y=L(e.duration,0);if(y>0&&d.get()===null&&!m.get()){const x=setTimeout(()=>{d.set(null),!m.get()&&i.isConnected&&b()},y);d.set(x),r.registerDisposer(()=>{const w=d.get();w!==null&&(clearTimeout(w),d.set(null))},"auto-dismiss-timer")}return m.get()?l("div",{class:"rui-toast-placeholder",hidden:""}):i}};function sd(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 Wn={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=p(e.label),n=p(e.href),i=n?Ye(n):"",o=[],s=E(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 u=l("span",{class:"rui-breadcrumb-current"});for(const c of o)c&&u.append(typeof c=="string"?document.createTextNode(c):c);r.append(u)}return r}},ld={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=C(e.items),n=p(e.separator,"/"),i=l("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),o=l("ol",{class:"rui-breadcrumb-list"});return a.forEach((s,u)=>{if(u>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 c=p(s),m=u===a.length-1;o.append(Wn.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:c,href:m?"":"#"},r))}),i.append(o),i}},cd=[10,20,50,100],ud={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(L(e.totalPages,1))),n=Math.max(1,Math.min(a,Math.floor(L(e.page,1)))),i=Math.max(0,Math.floor(L(e.siblings,1))),o=T(e.compact),s=t.argMeta?.[0]?.stateRef,u=l("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":o?"true":"false"}),c=b=>{if(!s)return;const v=Math.max(1,Math.min(a,b));v!==n&&r.setState(s,v)},m=e.total!=null?Math.max(0,Math.floor(L(e.total,0))):null,d=e.perPage!=null?Math.max(1,Math.floor(L(e.perPage,0))):null;if(m!==null&&d&&d>0){const b=m===0?0:(n-1)*d+1,v=Math.min(m,n*d);u.append(l("span",{class:"rui-pagination-summary"},[m===0?"No results":`Showing ${b.toLocaleString()}–${v.toLocaleString()} of ${m.toLocaleString()}`]))}else m!==null&&u.append(l("span",{class:"rui-pagination-summary"},[`${m.toLocaleString()} result${m===1?"":"s"}`]));const f=l("div",{class:"rui-pagination-buttons"}),g=(b,v,y={})=>{if(y.ellipsis)return l("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[b]);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},[b]);return!y.disabled&&!y.active&&(x.onclick=()=>c(v)),x};if(f.append(g("‹",n-1,{disabled:n<=1,ariaLabel:"Previous page"})),o)f.append(l("span",{class:"rui-pagination-current"},[`${n} / ${a}`]));else{const b=dd(n,a,i);for(const v of b)v==="…"?f.append(g("…",0,{ellipsis:!0})):f.append(g(String(v),v,{active:v===n}))}f.append(g("›",n+1,{disabled:n>=a,ariaLabel:"Next page"})),u.append(f);const h=t.argMeta?.[4]?.stateRef;if(d&&(h||C(e.perPageOptions).length>0)){const b=C(e.perPageOptions).length>0?C(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(cd),v=l("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),y=l("select",{class:"rui-pagination-per-page-select"});for(const x of b){const w=l("option",{value:String(x),selected:x===d?"":null},[String(x)]);y.append(w)}h&&r.bindState(y,h,{event:"change",getValue:x=>Number(x.value)}),v.append(y),v.append(document.createTextNode(" per page")),u.append(v)}return u}};function dd(t,e,r){const a=[],n=(u,c)=>{for(let m=u;m<=c;m+=1)a.push(m)},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 pd={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=p(e.label),n=e.icon,i=T(e.active),o=p(e.to),s=Ye(e.href,""),u=T(e.external),c=o||s?"a":"button",m=l(c,{class:"rui-navbar-item",type:c==="button"?"button":null,href:s||(o?`#${o.startsWith("/")?o:`/${o}`}`:null),target:u&&s?"_blank":null,rel:u&&s?"noopener noreferrer":null,"data-active":i?"true":"false"}),d=E(n,{className:"rui-navbar-item-icon"});return d&&m.append(d),m.append(l("span",{class:"rui-navbar-item-label"},[a])),o&&!s?m.onclick=f=>{if(f.defaultPrevented)return;const g=f;g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(f.preventDefault(),r.router.navigate(o))}:typeof e.onClick=="function"&&(m.onclick=f=>{f.preventDefault(),r.invoke(e.onClick)}),m}},md={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":T(e.sticky)?"true":"false","data-variant":p(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=C(e.items);if(i.length>0){const s=l("div",{class:"rui-navbar-items"});for(const u of i)s.append(r.renderNode(u));a.append(s)}const o=C(e.actions);if(o.length>0){const s=l("div",{class:"rui-navbar-actions"});for(const u of o)s.append(r.renderNode(u));a.append(s)}return a}},fd=["bottom","top","left","right"],gd=["start","center","end"],hd=["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||Ae(a),a):null},qn=(t,e)=>{Xe({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},bd={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:fd,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:gd,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=T(e.open),n=r.useInstanceState("open",a),i=n.get(),o=l("div",{class:"rui-dropdown-menu","data-open":i?"true":"false","data-side":p(e.side,"bottom"),"data-align":p(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=c=>{c.stopPropagation();const m=c.currentTarget??c.target,d=!n.get(),f=jt(m,d,n);d&&f&&qn(f,n)},s.onkeydown=c=>{const m=c,d=m.currentTarget??m.target;if(m.key==="Enter"||m.key===" "){m.preventDefault();const f=!n.get(),g=jt(d,f,n);f&&g&&qn(g,n);return}m.key==="Escape"&&n.get()&&(m.preventDefault(),jt(d,!1,n))},o.append(s);const u=l("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":p(e.label)||null});for(const c of C(e.items)){if(Pr(c,"MenuItem")){const m=c.args??[],d=p(m[0]),f=m[1],g=m[2],h=p(m[3]),b=p(m[4],"default"),v=T(m[5]),y=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":b,disabled:v?"":null}),x=E(g,{className:"rui-menu-item-icon"});x&&y.append(x),y.append(l("span",{class:"rui-menu-item-label"},[d])),h&&y.append(l("span",{class:"rui-menu-item-shortcut"},[h])),v||(y.onclick=w=>{const k=w.currentTarget??w.target;jt(k,!1,n),r.invoke(f)}),u.append(y);continue}if(Pr(c,"MenuSeparator")){u.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}if(Pr(c,"MenuLabel")){const m=p((c.args??[])[0]);u.append(l("div",{class:"rui-menu-label"},[m]));continue}u.append(r.renderNode(c))}return o.append(u),o}},vd={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:hd,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=T(e.disabled),n=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":p(e.variant,"default"),disabled:a?"":null}),i=E(e.icon,{className:"rui-menu-item-icon"});i&&n.append(i),n.append(l("span",{class:"rui-menu-item-label"},[p(e.label)]));const o=p(e.shortcut);return o&&n.append(l("span",{class:"rui-menu-item-shortcut"},[o])),a||(n.onclick=()=>{r.invoke(e.onClick)}),n}},yd={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>l("div",{class:"rui-menu-separator",role:"separator"})},xd={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"},[p(e.label)])},wd=["left","center","right"];function kd(t){return C(t).map((e,r)=>{const a=e.args??[],n=p(a[0]);return{header:n,values:C(a[1]),format:p(a[2],"text"),align:wd.includes(p(a[3]))?p(a[3]):"",sortable:T(a[4]),filterable:T(a[5]),render:a[6],onClick:a[7],key:n||`col-${r}`}})}function Gn(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return L(t,0)-L(e,0);if(r==="date"){const a=new Date(p(t)).getTime(),n=new Date(p(e)).getTime();if(Number.isFinite(a)&&Number.isFinite(n))return a-n}return p(t).localeCompare(p(e))}function Dt(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():p(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):p(t);case"date":try{const r=new Date(p(t));return Number.isNaN(r.getTime())?p(t):r.toLocaleDateString()}catch{return p(t)}default:return p(t)}}const Sd={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=kd(e.columns),n=Math.max(0,...a.map(B=>B.values.length)),i=C(e.rowIds),o=B=>p(i[B]??B),s=e.sort&&typeof e.sort=="object"?e.sort:null,u=p(s?.key),c=p(s?.direction,"asc")==="desc"?"desc":"asc",m=C(e.selectedIds).map(B=>p(B)),d=new Set(m),f=T(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,g=e.stickyHeader===void 0?!0:T(e.stickyHeader),h=T(e.stickyFirstColumn),b=p(e.density,"comfortable"),v=T(e.striped),y=r.useInstanceState("filters",{}),x=y.get(),w=[];for(let B=0;B<n;B+=1){let q=!0;for(const Y of a){if(!Y.filterable)continue;const G=(x[Y.key]??"").trim().toLowerCase();if(!G)continue;const re=Y.values[B];if(!Dt(re,Y.format).toLowerCase().includes(G)){q=!1;break}}q&&w.push(B)}if(u){const B=a.find(q=>q.key===u);B&&B.sortable&&w.sort((q,Y)=>{const G=Gn(B.values[q],B.values[Y],B.format);return c==="desc"?-G:G})}const k=w.length,A=Math.max(1,Math.floor(L(e.perPage,20))),S=Math.max(1,Math.ceil(k/A)),$=Math.max(1,Math.floor(L(e.page,1))),M=Math.min($,S),I=w.slice((M-1)*A,M*A),R=l("div",{class:"rui-data-grid","data-density":b,"data-striped":v?"true":"false","data-sticky-header":g?"true":"false","data-sticky-first":h?"true":"false"}),j=t.argMeta?.[3]?.stateRef,K=t.argMeta?.[4]?.stateRef,F=t.argMeta?.[6]?.stateRef,U=C(e.toolbar);if(m.length>0&&U.length>0){const B=l("div",{class:"rui-data-grid-bulk"});B.append(l("span",{class:"rui-data-grid-bulk-count"},[`${m.length} selected`]));const q=l("div",{class:"rui-data-grid-bulk-tools"});for(const Y of U)q.append(r.renderNode(Y));B.append(q),R.append(B)}const J=l("div",{class:"rui-data-grid-scroll"}),Z=l("table",{class:"rui-data-grid-table"}),de=p(e.caption);de&&Z.append(l("caption",{class:"rui-data-grid-caption"},[de]));const Se=l("thead"),ft=l("tr");if(f){const B=l("th",{class:"rui-data-grid-cell-select",scope:"col"}),q=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:q?"":null});K&&(Y.onclick=G=>{const re=G.currentTarget,ee=new Set(m);for(const X of I){const Q=o(X);re.checked?ee.add(Q):ee.delete(Q)}r.setState(K,Array.from(ee))}),B.append(Y),ft.append(B)}if(a.forEach((B,q)=>{const Y=l("th",{scope:"col","data-align":B.align||null,"data-sortable":B.sortable?"true":null,"data-active":B.sortable&&B.key===u?"true":null,"data-first":q===0?"true":null});if(B.sortable&&j){const G=l("button",{type:"button",class:"rui-data-grid-sort"});G.append(l("span",{},[B.header]));const re=B.key===u?c==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",ee=E(re,{className:"rui-data-grid-sort-icon"});ee&&G.append(ee),G.onclick=()=>{const X=B.key===u&&c==="asc"?"desc":"asc";r.setState(j,{key:B.key,direction:X})},Y.append(G)}else Y.append(document.createTextNode(B.header));ft.append(Y)}),Se.append(ft),a.some(B=>B.filterable)){const B=l("tr",{class:"rui-data-grid-filter-row"});f&&B.append(l("td",{class:"rui-data-grid-cell-select"})),a.forEach(q=>{const Y=l("td");if(q.filterable){const G=l("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${q.header}`,value:x[q.key]??""});G.oninput=re=>{const ee=re.currentTarget,X={...y.get(),[q.key]:ee.value};y.set(X);const Q=ee.closest("table")?.querySelector("tbody");wf(Q)},Y.append(G)}B.append(Y)}),Se.append(B)}Z.append(Se);const He=l("tbody");Z.append(He);const Ur=B=>{if(He.replaceChildren(),B.length===0){const q=l("tr"),Y=(f?1:0)+Math.max(a.length,1);q.append(l("td",{colspan:String(Y),class:"rui-data-grid-empty"},[p(e.emptyLabel,"No results")])),He.append(q);return}for(const q of B){const Y=o(q),G=d.has(Y),re=l("tr",{"data-selected":G?"true":null});if(f){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});K&&(X.onclick=Q=>{Q.stopPropagation();const ve=Q.currentTarget,ye=new Set(m);ve.checked?ye.add(Y):ye.delete(Y),r.setState(K,Array.from(ye))}),ee.append(X),re.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[q],q,r,Dt),re.append(Q)}),typeof e.onRowClick=="function"&&(re.setAttribute("data-clickable","true"),re.onclick=ee=>{ee.target?.closest("input,button,a,label,select,textarea")||r.invoke(e.onRowClick,q)}),He.append(re)}},wf=B=>{const q=B??He,Y=y.get(),G=[];for(let X=0;X<n;X+=1){let Q=!0;for(const ve of a){if(!ve.filterable)continue;const ye=(Y[ve.key]??"").trim().toLowerCase();if(!ye)continue;const gt=ve.values[X];if(!Dt(gt,ve.format).toLowerCase().includes(ye)){Q=!1;break}}Q&&G.push(X)}if(u){const X=a.find(Q=>Q.key===u);X&&X.sortable&&G.sort((Q,ve)=>{const ye=Gn(X.values[Q],X.values[ve],X.format);return c==="desc"?-ye:ye})}const re=G.slice((M-1)*A,M*A);(X=>{X.replaceChildren();for(const Q of re){const ve=o(Q),ye=d.has(ve),gt=l("tr",{"data-selected":ye?"true":null});if(f){const Ve=l("td",{class:"rui-data-grid-cell-select"}),Hr=l("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:ye?"":null});Ve.append(Hr),gt.append(Ve)}a.forEach((Ve,Hr)=>{const Pi=l("td",{"data-format":Ve.format,"data-align":Ve.align||null,"data-first":Hr===0?"true":null});hr(Pi,Ve,Ve.values[Q],Q,r,Dt),gt.append(Pi)}),X.append(gt)}if(re.length===0){const Q=l("tr"),ve=(f?1:0)+Math.max(a.length,1);Q.append(l("td",{colspan:String(ve),class:"rui-data-grid-empty"},[p(e.emptyLabel,"No results")])),X.append(Q)}})(q)};if(Ur(I),J.append(Z),R.append(J),k>A){const B=l("div",{class:"rui-data-grid-footer"}),q=k===0?0:(M-1)*A+1,Y=Math.min(k,M*A);B.append(l("span",{class:"rui-data-grid-footer-summary"},[k===0?"No results":`Showing ${q}–${Y} of ${k}`]));const G=l("div",{class:"rui-data-grid-footer-buttons"}),re=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:M<=1?"":null},["‹ Prev"]),ee=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:M>=S?"":null},["Next ›"]);F&&(re.onclick=()=>{M<=1||r.setState(F,M-1)},ee.onclick=()=>{M>=S||r.setState(F,M+1)}),G.append(re),G.append(l("span",{class:"rui-data-grid-page-current"},[`${M} / ${S}`])),G.append(ee),B.append(G),R.append(B)}return R}};function Cd(t){const e=[];for(const r of C(t)){if(!r||typeof r!="object")continue;const a=r,n=p(a.date);n&&e.push({date:n,title:p(a.title),tone:p(a.tone,"primary"),time:p(a.time)})}return e}function Kn(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 Yn(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 $d={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=p(e.view,"month"),n=Cd(e.events),i=p(e.value),o=p(e.month,i),s=new Date;let u=new Date(NaN);if(o){const A=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(o);if(A)u=new Date(Number(A[1]),Number(A[2])-1,A[3]?Number(A[3]):1);else{const S=new Date(o);Number.isNaN(S.getTime())||(u=S)}}Number.isNaN(u.getTime())&&(u=s);const c=(L(e.firstDay,1)%7+7)%7,m=i&&/^\d{4}-\d{2}-\d{2}$/.test(i)?i:"",d=new Map;for(const A of n){const S=A.date.slice(0,10),$=d.get(S)??[];$.push(A),d.set(S,$)}const f=t.argMeta?.[0]?.stateRef,g=l("div",{class:"rui-calendar","data-view":a}),h=l("div",{class:"rui-calendar-header"}),b=u.toLocaleDateString(void 0,{month:"long",year:"numeric"});h.append(l("div",{class:"rui-calendar-title"},[b])),g.append(h);const v=l("div",{class:"rui-calendar-weekrow"}),y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let A=0;A<7;A+=1){const S=y[(c+A)%7]??"";v.append(l("div",{class:"rui-calendar-weekday"},[S]))}g.append(v);const x=[];if(a==="week"){const A=m?new Date(m):u,S=Kn(A,c);for(let $=0;$<7;$+=1){const M=new Date(S);M.setDate(S.getDate()+$),x.push({date:M,inMonth:M.getMonth()===u.getMonth()})}}else{const A=new Date(u.getFullYear(),u.getMonth(),1),S=new Date(u.getFullYear(),u.getMonth()+1,0),$=Kn(A,c),M=Math.ceil((S.getDate()+(A.getDay()-c+7)%7)/7)*7;for(let I=0;I<M;I+=1){const R=new Date($);R.setDate($.getDate()+I),x.push({date:R,inMonth:R.getMonth()===u.getMonth()})}}const w=l("div",{class:"rui-calendar-grid","data-view":a}),k=Yn(s);for(const A of x){const S=Yn(A.date),$=S===k,M=S===m,I=d.get(S)??[],R=l("button",{type:"button",class:"rui-calendar-day","data-in-month":A.inMonth?"true":"false","data-today":$?"true":"false","data-selected":M?"true":"false","aria-label":A.date.toDateString()});if(R.append(l("span",{class:"rui-calendar-daynumber"},[String(A.date.getDate())])),I.length>0){const j=l("div",{class:"rui-calendar-day-events"}),K=I.slice(0,3);for(const F of K){const U=l("span",{class:"rui-calendar-event","data-tone":F.tone??"primary",title:F.time?`${F.time} — ${F.title}`:F.title},[F.title]);j.append(U)}I.length>3&&j.append(l("span",{class:"rui-calendar-event-more"},[`+${I.length-3} more`])),R.append(j)}R.onclick=()=>{f&&r.setState(f,S),r.invoke(e.onSelect,S)},w.append(R)}return g.append(w),g}};function Td(t){const e=[];for(const r of C(t)){if(!r||typeof r!="object")continue;const a=r;e.push({title:p(a.title),description:p(a.description),actor:p(a.actor),avatarSrc:p(a.avatarSrc),time:p(a.time),icon:p(a.icon),tone:p(a.tone,"default"),meta:p(a.meta)})}return e}function Ad(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=E(n.icon,{className:`${t}-icon`});s&&o.append(s),i.append(o);const u=l("div",{class:`${t}-body`}),c=l("div",{class:`${t}-head`});n.actor&&c.append(l("span",{class:`${t}-actor`},[n.actor])),c.append(l("span",{class:`${t}-title`},[n.title])),n.time&&c.append(l("span",{class:`${t}-time`},[n.time])),u.append(c),n.description&&u.append(l("p",{class:`${t}-description`},[n.description])),n.meta&&u.append(l("span",{class:`${t}-meta`},[n.meta])),i.append(u),a.append(i)}return a}const Nd={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=p(e.variant,"default");return Ad(r==="audit"?"rui-audit-trail":"rui-activity-log",Td(e.items),r)}},Md={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=C(e.columns).map(f=>p(f)),n=C(e.rows).map(f=>{const g=f??{};return{label:p(g.label),values:C(g.values),hint:p(g.hint),group:p(g.group)}}),i=Math.floor(L(e.highlightColumn,-1)),o=l("div",{class:"rui-comparison-table"}),s=l("table"),u=l("thead"),c=l("tr");c.append(l("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),a.forEach((f,g)=>{c.append(l("th",{scope:"col","data-highlight":g===i?"true":null},[f]))}),u.append(c),s.append(u);const m=l("tbody");let d="";for(const f of n){if(f.group&&f.group!==d){d=f.group;const b=l("tr",{class:"rui-comparison-table-group"});b.append(l("td",{colspan:String(a.length+1)},[f.group])),m.append(b)}const g=l("tr"),h=l("td",{class:"rui-comparison-table-feature"});h.append(l("div",{class:"rui-comparison-table-feature-label"},[f.label])),f.hint&&h.append(l("div",{class:"rui-comparison-table-feature-hint"},[f.hint])),g.append(h);for(let b=0;b<a.length;b+=1){const v=f.values[b],y=l("td",{"data-highlight":b===i?"true":null});if(v===!0){const x=E("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=p(v);g.append(y)}m.append(g)}return s.append(m),o.append(s),o}},Pd={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 C(e.items))n.append(r.renderNode(s));a.append(n);const i=e.hasMore===void 0?!0:T(e.hasMore),o=T(e.loading);if(i){const s=l("div",{class:"rui-infinite-list-sentinel"});if(o){const u=E("spinner",{className:"rui-infinite-list-spin"});u&&s.append(u),s.append(l("span",{},[p(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const u=l("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);u.onclick=()=>r.invoke(e.onLoadMore),s.append(u)}if(a.append(s),!o&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const u=e.onLoadMore,c=new IntersectionObserver(m=>{for(const d of m)if(d.isIntersecting){r.invoke(u);break}});c.observe(s),r.registerDisposer(()=>c.disconnect(),"infinite-observer")}}return a}},Id=/^(https?:|blob:|data:(audio|video)\/)/i;function Bt(t){const e=p(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":Id.test(e)?e:"":""}const Ld={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(p(e.ratio,"16:9")),n=l("div",{class:"rui-video-player-frame",style:`aspect-ratio:${a};`}),i=e.controls===void 0?!0:T(e.controls),o=l("video",{class:"rui-video-player-video",controls:i?"":null,autoplay:T(e.autoplay)?"":null,loop:T(e.loop)?"":null,muted:T(e.muted)?"":null,poster:ne(e.poster)||null,playsinline:"",preload:"metadata"}),s=C(e.sources);if(s.length>0)for(const c of s){if(!c||typeof c!="object")continue;const m=c,d=Bt(m.src);d&&o.append(l("source",{src:d,type:p(m.type)||null}))}else{const c=Bt(e.src);c&&o.setAttribute("src",c)}n.append(o),r.append(n);const u=p(e.caption);return u&&r.append(l("figcaption",{class:"rui-video-player-caption"},[u])),r}},zd={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=E(p(e.icon,"music"),{className:"rui-audio-player-icon"});n&&a.append(n);const i=l("div",{class:"rui-audio-player-text"}),o=p(e.title);o&&i.append(l("div",{class:"rui-audio-player-title"},[o]));const s=p(e.artist);s&&i.append(l("div",{class:"rui-audio-player-artist"},[s])),a.append(i),r.append(a);const u=e.controls===void 0?!0:T(e.controls),c=l("audio",{class:"rui-audio-player-audio",controls:u?"":null,autoplay:T(e.autoplay)?"":null,loop:T(e.loop)?"":null,preload:"metadata"}),m=C(e.sources);if(m.length>0)for(const d of m){if(!d||typeof d!="object")continue;const f=d,g=Bt(f.src);g&&c.append(l("source",{src:g,type:p(f.type)||null}))}else{const d=Bt(e.src);d&&c.setAttribute("src",d)}return r.append(c),r}};function Rd(t,e){if(t==null)return null;if(typeof t=="object"&&t.__kind==="Component")return e.renderNode(t);if(typeof t=="string"){const r=ne(t);return r?l("img",{src:r,alt:"",loading:"lazy",class:"rui-carousel-image"}):null}if(typeof t=="object"){const r=t,a=ne(r.src);if(a){const n=l("figure",{class:"rui-carousel-figure"});n.append(l("img",{src:a,alt:p(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const i=p(r.caption??r.title);return i&&n.append(l("figcaption",{class:"rui-carousel-caption"},[i])),n}}return e.renderNode(t)}const Ed={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=C(e.items),n=a.length,i=Math.max(0,Math.min(Math.max(n-1,0),Math.floor(L(e.activeIndex,0)))),o=r.useInstanceState("active",i);let s=o.get();s>=n&&(s=0,o.set(s));const u=e.showDots===void 0?!0:T(e.showDots),c=e.showArrows===void 0?!0:T(e.showArrows),m=Ir(p(e.ratio,"16:9")),d=l("div",{class:"rui-carousel"}),f=l("div",{class:"rui-carousel-frame",style:`aspect-ratio:${m};`}),g=l("div",{class:"rui-carousel-track",style:`transform:translateX(${s*-100}%);`});a.forEach(b=>{const v=l("div",{class:"rui-carousel-slide"}),y=Rd(b,r);y&&v.append(y),g.append(v)}),f.append(g);const h=(b,v)=>{const y=(v%n+n)%n;o.set(y);const x=b.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${y*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((k,A)=>{k.setAttribute("data-active",A===y?"true":"false")})};if(c&&n>1){const b=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),v=E("chevron-left");v&&b.append(v);const y=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=E("chevron-right");x&&y.append(x),b.onclick=w=>h(w.currentTarget,o.get()-1),y.onclick=w=>h(w.currentTarget,o.get()+1),f.append(b,y)}if(d.append(f),u&&n>1){const b=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=>h(w.currentTarget,y),b.append(x)}),d.append(b)}return d}},jd={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=C(e.items),n=Math.max(1,Math.min(6,Number(e.columns??"auto"))),i=Ir(p(e.ratio,"1:1")),o=l("div",{class:"rui-gallery","data-columns":n>0?String(n):null});return a.forEach((s,u)=>{const{src:c,alt:m,caption:d}=Xn(s),f=ne(c),g=typeof e.onSelect=="function",h=l(g?"button":"figure",{type:g?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${i};`,"data-index":String(u)});if(f)h.append(l("img",{src:f,alt:m,loading:"lazy"}));else{const b=E("image",{className:"rui-gallery-placeholder"});b&&h.append(b)}d&&h.append(l("span",{class:"rui-gallery-caption"},[d])),g&&(h.onclick=()=>r.invoke(e.onSelect,u,s)),o.append(h)}),o}};function Xn(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:p(e.args[0]),alt:p(e.args[1]),caption:p(e.args[2])}:{src:p(e.src),alt:p(e.alt),caption:p(e.caption)}}return{src:"",alt:"",caption:""}}const Dd={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=C(e.items).map($=>Xn($)).filter($=>ne($.src)!==""),n=a.length,i=t.argMeta?.[2]?.stateRef,o=t.argMeta?.[1]?.stateRef,s=r.useInstanceState("open",!1),u=r.useInstanceState("index",0),c=o?T(e.open):s.get(),m=i?Math.floor(L(e.index,0)):u.get(),d=n===0?0:(m%n+n)%n,f=$=>{o?r.setState(o,$):s.set($)},g=$=>{i?r.setState(i,$):u.set($)},h=()=>f(!1),b=$=>{n!==0&&g(((d+$)%n+n)%n)},v=l("div",{class:"rui-lightbox-root"});if(!o&&n>0){const $=a[d],M=l("button",{type:"button",class:"rui-lightbox-thumb","aria-label":$?.alt||"Open image"});if($){const I=ne($.src);I&&M.append(l("img",{src:I,alt:$.alt,loading:"lazy"}))}M.onclick=I=>{I.stopPropagation(),f(!0)},v.append(M)}const y=l("div",{class:"rui-lightbox-overlay","data-open":c?"true":"false"});if(v.append(y),!c||n===0)return v;const x=a[d];if(!x)return v;const w=ne(x.src);y.onclick=$=>{$.target===y&&h()};const k=l("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),A=l("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(A.onclick=h,k.append(A),n>1){const $=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),M=E("chevron-left");M&&$.append(M),$.onclick=()=>b(-1);const I=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),R=E("chevron-right");R&&I.append(R),I.onclick=()=>b(1),k.append($,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=L(e.lat??e.latitude,NaN),a=L(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=L(t[0],NaN),r=L(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 Fd={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=te(e.height,"320px"),n=l("div",{class:"rui-map-frame",style:`height:${a};`}),i=L(e.lat,NaN),o=L(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 b=p(e.caption);return b&&r.append(l("figcaption",{class:"rui-map-caption"},[b])),r}const u=Math.max(1,Math.min(18,Math.floor(L(e.zoom,13)))),c=1/Math.pow(2,u-8),d=`https://www.openstreetmap.org/export/embed.html?bbox=${[s.lng-c,s.lat-c/2,s.lng+c,s.lat+c/2].join(",")}&layer=mapnik&marker=${s.lat},${s.lng}`,f=l("iframe",{class:"rui-map-iframe",src:d,loading:"lazy",title:"Map view",referrerpolicy:"no-referrer"});n.append(f),r.append(n);const g=C(e.markers).map(b=>{const v=Bd(b),y=b&&typeof b=="object"?p(b.label):"";return v?{...v,label:y}:null}).filter(b=>b!==null);if(g.length>0){const b=l("ul",{class:"rui-map-markers"});for(const v of g){const y=l("li",{class:"rui-map-marker"}),x=E("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)}`])),b.append(y)}r.append(b)}const h=p(e.caption);return h&&r.append(l("figcaption",{class:"rui-map-caption"},[h])),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 Od=[{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"}],_d={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=p(e.id),n=p(e.placeholder,"Start writing…"),i=T(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 Od){const h=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}),b=E(g.icon);b&&h.append(b),h.onmousedown=v=>v.preventDefault(),h.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(h)}o.append(s);const u=p(e.value)||"",c=g=>g.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").trim().length===0,m=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":c(u)?"true":"false",style:`min-height:${p(e.minHeight,"160px")};`,html:u}),d=g=>{g.setAttribute("data-empty",c(g.innerHTML)?"true":"false")},f=t.argMeta?.[1]?.stateRef;return f&&!i?r.bindState(m,f,{event:"input",getValue:g=>{const h=g;return d(h),h.innerHTML}}):m.oninput=g=>{const h=g.currentTarget??g.target;d(h)},m.onblur=g=>{const h=g.currentTarget??g.target;d(h)},ie(m,e.onChange,r,{event:"input",getValue:g=>g.innerHTML}),o.append(m),o}},Ud={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=p(e.id),n=p(e.value),i=p(e.language,"text"),o=e.showGutter===void 0?!0:T(e.showGutter),s=Math.max(1,Math.min(8,Math.floor(L(e.tabSize,2)))),u=T(e.readonly),c=p(e.minHeight,"200px"),m=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])),m.append(d);const f=l("div",{class:"rui-code-editor-body",style:`min-height:${c};`}),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),f.append(g));const b=l("textarea",{class:"rui-code-editor-textarea",id:a,name:a,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:p(e.placeholder),readonly:u?"":null,style:`tab-size:${s};-moz-tab-size:${s};`});b.value=n,b.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 A=x.value.split(/\r?\n/),S=Math.max(1,A.length);for(let $=1;$<=S;$+=1)k.append(l("span",{class:"rui-code-editor-line"},[String($)]))},b.onkeydown=y=>{const x=y;if(x.key!=="Tab")return;x.preventDefault();const w=x.currentTarget,k=w.selectionStart,A=w.selectionEnd,S=" ".repeat(s);w.value=w.value.slice(0,k)+S+w.value.slice(A),w.selectionStart=w.selectionEnd=k+S.length,w.dispatchEvent(new Event("input",{bubbles:!0}))};const v=t.argMeta?.[1]?.stateRef;return v&&!u&&r.bindState(b,v,{event:"input",getValue:y=>y.value}),u||ie(b,e.onChange,r,{event:"input",getValue:y=>y.value}),f.append(b),m.append(f),m}};function Hd(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:p(a[0]),action:a[1],icon:p(a[2]),shortcut:p(a[3]),variant:p(a[4],"default"),disabled:T(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:p(r.label),action:r.action,icon:p(r.icon),shortcut:p(r.shortcut),variant:p(r.variant,"default"),disabled:T(r.disabled),separator:!1}}return null}const Vd={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":p(e.label)||null,"data-open":"false"}),o=C(e.items).map(Hd).filter(c=>c!==null);for(const c of o){if(c.separator){i.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}const m=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":c.variant,disabled:c.disabled?"":null}),d=E(c.icon,{className:"rui-menu-item-icon"});d&&m.append(d),m.append(l("span",{class:"rui-menu-item-label"},[c.label])),c.shortcut&&m.append(l("span",{class:"rui-menu-item-shortcut"},[c.shortcut])),c.disabled||(m.onclick=()=>{r.invoke(c.action),i.setAttribute("data-open","false")}),i.append(m)}a.append(i);const s=()=>i.setAttribute("data-open","false"),u=(c,m)=>{const d=n.isConnected?n.closest(".rui-context-menu"):null,f=d?.querySelector(".rui-context-menu-pop")??i,g=d?.getBoundingClientRect(),h=g?c-g.left:c,b=g?m-g.top:m;f.style.left=`${h}px`,f.style.top=`${b}px`,f.setAttribute("data-open","true");const v=y=>{y.target&&f.contains(y.target)||(f.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=c=>{c.preventDefault(),u(c.clientX,c.clientY)},n.onkeydown=c=>{const m=c;if(m.key==="ContextMenu"||m.shiftKey&&m.key==="F10"){m.preventDefault();const f=m.currentTarget.getBoundingClientRect();u(f.left,f.top+f.height)}m.key==="Escape"&&s()},a}},Wd=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function ut(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 qd={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=p(e.id),n=ut(p(e.value))||p(e.value,"#000000"),i=T(e.disabled),o=l("div",{class:"rui-color-picker","data-disabled":i?"true":"false"}),s=p(e.label);s&&o.append(l("label",{class:"rui-color-picker-label",for:a},[s]));const u=l("div",{class:"rui-color-picker-row"}),c=l("input",{type:"color",class:"rui-color-picker-color",id:a,name:a,value:ut(n)||"#000000",disabled:i?"":null}),m=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"}),f=C(e.swatches).map(b=>p(b)).filter(Boolean),g=f.length>0?f:Wd;for(const b of g){const v=ut(b)||b,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=()=>{c.value=ut(v)||c.value,m.value=v,c.dispatchEvent(new Event("input",{bubbles:!0}))},d.append(y)}const h=t.argMeta?.[1]?.stateRef;return h&&!i&&(r.bindState(c,h,{event:"input",getValue:b=>b.value}),c.addEventListener("input",()=>{m.value=c.value}),m.oninput=()=>{const b=ut(m.value);b&&(c.value=b,c.dispatchEvent(new Event("input",{bubbles:!0})))}),i||ie(c,e.onChange,r,{event:"input",getValue:b=>b.value}),u.append(c,m),o.append(u,d),o}},Lr=["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)"],_e=t=>Lr[t%Lr.length]??Lr[0];function Gd(t){return t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>L(o));return{name:n,values:i}})}function Ft(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 Jn(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:${_e(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const Kd={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=L(e.min,0),a=Math.max(r+1,L(e.max,100)),n=Math.max(r,Math.min(a,L(e.value,r))),i=(n-r)/(a-r),o=p(e.tone,"primary"),s=p(e.size,"md"),u=s==="lg"?220:s==="sm"?140:180,c=u/2,m=s==="lg"?18:s==="sm"?10:14,d=c-m,f=l("div",{class:"rui-gauge","data-tone":o,"data-size":s}),g=Ft(u,c+m+4),h=c,b=c,v=h-d,y=b,x=h+d,w=b;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(m),"stroke-linecap":"round"})),i>0){const $=Math.PI*i,M=h-d*Math.cos($),I=b-d*Math.sin($);g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${M.toFixed(2)},${I.toFixed(2)}`,fill:"none",stroke:`var(--rui-color-${o}, ${_e(0)})`,"stroke-width":String(m),"stroke-linecap":"round",class:"rui-gauge-arc"}))}f.append(g);const k=Yd(n,r,a),A=p(e.label)||k;f.append(l("div",{class:"rui-gauge-value"},[A]));const S=p(e.caption);return S&&f.append(l("div",{class:"rui-gauge-caption"},[S])),f}};function Yd(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 Xd={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=C(e.xLabels).map(m=>p(m)),a=C(e.yLabels).map(m=>p(m)),n=C(e.values).map(m=>C(m).map(d=>L(d,0))),i=p(e.tone,"primary"),o=Math.max(1,...n.flat()),s=l("div",{class:"rui-heatmap","data-tone":i});p(e.title)&&s.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const u=l("div",{class:"rui-heatmap-table"}),c=l("div",{class:"rui-heatmap-row rui-heatmap-row-header"});c.append(l("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const m of r)c.append(l("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[m]));return u.append(c),n.forEach((m,d)=>{const f=l("div",{class:"rui-heatmap-row"});f.append(l("div",{class:"rui-heatmap-cell rui-heatmap-ylabel"},[a[d]??String(d+1)])),m.forEach((g,h)=>{const b=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}, ${_e(0)}) ${Math.round(b*90+5)}%, transparent);`,title:`${r[h]??h+1} · ${a[d]??d+1}: ${g}`});v.append(l("span",{},[String(g)])),f.append(v)}),u.append(f)}),s.append(u),s}},Jd={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=C(e.axes).map(g=>p(g)),a=Gd(C(e.series)),n=Math.max(r.length,3),i=l("div",{class:"rui-chart rui-radar-chart"});p(e.title)&&i.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const o=Math.max(1,L(e.max,a.flatMap(g=>g.values).reduce((g,h)=>Math.max(g,h),1))),s=280,u=s/2,c=s/2,m=s/2-24,d=Ft(s,s),f=4;for(let g=1;g<=f;g+=1){const h=m/f*g,b=[];for(let v=0;v<n;v+=1){const y=Math.PI*2*v/n-Math.PI/2;b.push(`${(u+h*Math.cos(y)).toFixed(1)},${(c+h*Math.sin(y)).toFixed(1)}`)}d.append(ce("polygon",{points:b.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 h=Math.PI*2*g/n-Math.PI/2,b=u+m*Math.cos(h),v=c+m*Math.sin(h);d.append(ce("line",{x1:String(u),y1:String(c),x2:b.toFixed(1),y2:v.toFixed(1),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}));const y=u+(m+16)*Math.cos(h),x=c+(m+16)*Math.sin(h);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,h)=>{const b=[];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=u+m*x*Math.cos(w),A=c+m*x*Math.sin(w);b.push(`${k.toFixed(1)},${A.toFixed(1)}`)}d.append(ce("polygon",{points:b.join(" "),fill:_e(h),"fill-opacity":"0.2",stroke:_e(h),"stroke-width":"2","stroke-linejoin":"round"}))}),i.append(d),a.length>0&&i.append(Jn(a)),i}};function Zd(t){return t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>{if(Array.isArray(o))return{x:L(o[0],0),y:L(o[1],0),label:p(o[2])};if(o&&typeof o=="object"){const s=o;return{x:L(s.x,0),y:L(s.y,0),label:p(s.label)}}return{x:0,y:0,label:""}});return{name:n,points:i}})}const Qd={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=Zd(C(e.series)),a=l("div",{class:"rui-chart rui-scatter-chart"});p(e.title)&&a.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const n=640,i=280,o={left:50,right:16,top:16,bottom:40},s=n-o.left-o.right,u=i-o.top-o.bottom,c=r.flatMap(k=>k.points);if(c.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No points"])),a;const m=c.map(k=>k.x),d=c.map(k=>k.y),f=Math.min(...m),g=Math.max(...m),h=Math.min(...d),b=Math.max(...d),v=g-f||1,y=b-h||1,x=Ft(n,i);if(Qn(x,o,s,u,b,h),x.append(ce("line",{x1:String(o.left),y1:String(o.top+u),x2:String(o.left+s),y2:String(o.top+u),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((k,A)=>{k.points.forEach(S=>{const $=o.left+(S.x-f)/v*s,M=o.top+u-(S.y-h)/y*u,I=ce("circle",{cx:$.toFixed(1),cy:M.toFixed(1),r:"7",fill:_e(A),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});I.append(ce("title",{},[S.label||`${S.x}, ${S.y}`])),x.append(I)})}),p(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"},[p(e.xLabel)])),p(e.yLabel)){const A=o.top+u/2;x.append(ce("text",{x:String(14),y:String(A),"text-anchor":"middle",transform:`rotate(-90, 14, ${A})`,class:"rui-chart-label","font-size":"14","font-weight":"500"},[p(e.yLabel)]))}a.append(x);const w=r.map(k=>({name:k.name,values:k.points.map(A=>A.y)}));return w.length>0&&a.append(Jn(w)),a}},ep={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(f=>{const g=f??{};return{label:p(g.label),count:L(g.count,0)}});else{const f=C(e.values).map(g=>L(g,NaN)).filter(g=>Number.isFinite(g));if(f.length>0){const g=Math.max(2,Math.min(50,Math.floor(L(e.binCount,10)))),h=Math.min(...f),y=(Math.max(...f)-h||1)/g,x=new Array(g).fill(0);for(const w of f){let k=Math.floor((w-h)/y);k>=g&&(k=g-1),k<0&&(k=0),x[k]+=1}r=x.map((w,k)=>{const A=h+k*y,S=A+y;return{label:`${Zn(A)}–${Zn(S)}`,count:w}})}}const a=l("div",{class:"rui-chart rui-histogram"});if(p(e.title)&&a.append(l("div",{class:"rui-chart-title"},[p(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,u=i-o.top-o.bottom,c=Math.max(1,...r.map(f=>f.count)),m=s/r.length,d=Ft(n,i);return Qn(d,o,s,u,c),r.forEach((f,g)=>{const h=o.left+g*m+m*.1,b=m*.8,v=f.count/c*u,y=o.top+u-v,x=ce("rect",{x:h.toFixed(1),y:y.toFixed(1),width:b.toFixed(1),height:v.toFixed(1),fill:_e(0),rx:"2"});x.append(ce("title",{},[`${f.label}: ${f.count}`])),d.append(x),d.append(ce("text",{x:(h+b/2).toFixed(1),y:String(o.top+u+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[f.label]))}),a.append(d),a}};function Zn(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function Qn(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const u=s/4,c=e.top+a-u*a;t.append(ce("line",{x1:String(e.left),x2:String(e.left+r),y1:String(c),y2:String(c),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ce("text",{x:String(e.left-8),y:String(c+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((i+(n-i)*u)*10)/10)]))}}const tp=["numeric","alphanumeric"];function rp(t,e,r,a,n,i,o){const s=l("div",{class:"rui-pin-input","data-disabled":n?"true":"false"}),u=[];for(let d=0;d<e;d+=1){const f=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});u.push(f),s.append(f)}const c=d=>{const f=d.closest(".rui-pin-input");return f?Array.from(f.querySelectorAll(".rui-pin-input-slot")):u},m=d=>c(d).map(f=>f.value).join("").slice(0,e);return u.forEach((d,f)=>{d.oninput=g=>{const h=g.currentTarget,b=c(h);let v=h.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-f).forEach((w,k)=>{const A=b[f+k];A&&(A.value=w)});const x=Math.min(f+y.length,e-1);b[x]?.focus()}else h.value=v,v&&f<e-1&&b[f+1]?.focus();o?.(m(h))},d.onkeydown=g=>{const h=g,b=h.currentTarget,v=c(b);if(h.key==="Backspace"&&!b.value&&f>0){h.preventDefault(),v[f-1]?.focus();const y=v[f-1];y&&(y.value=""),o?.(m(b))}else h.key==="ArrowLeft"&&f>0?(h.preventDefault(),v[f-1]?.focus()):h.key==="ArrowRight"&&f<e-1&&(h.preventDefault(),v[f+1]?.focus())}}),s}const ap={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:tp},{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=p(e.id),n=Math.max(1,Math.min(12,Math.floor(L(e.length,4)))),i=p(e.type,"numeric"),o=p(e.value),s=T(e.disabled),u=T(e.mask),c=t.argMeta?.[2]?.stateRef;return rp(a,n,i,o,s,u,m=>{c&&r.setState(c,m),r.invoke(e.onChange,m)})}};function np(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 ip={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=p(e.id),n=r.useInstanceState("visible",!1),i=n.get(),o=T(e.disabled),s=l("div",{class:"rui-password-input","data-disabled":o?"true":"false"}),u=p(e.label);u&&s.append(l("label",{class:"rui-password-input-label",for:a},[u]));const c=l("div",{class:"rui-password-input-row"}),m=l("input",{type:i?"text":"password",class:"rui-password-input-field",id:a,name:a,autocomplete:"current-password",placeholder:p(e.placeholder),value:p(e.value),disabled:o?"":null}),d=l("button",{type:"button",class:"rui-password-input-toggle","aria-label":i?"Hide password":"Show password"}),f=E(i?"eye-slash":"eye");f&&d.append(f),d.onclick=h=>{h.preventDefault();const b=!n.get();n.set(b);const x=h.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=b?"text":"password")};const g=t.argMeta?.[1]?.stateRef;if(g&&r.bindState(m,g,{event:"input",getValue:h=>h.value}),ie(m,e.onChange,r,{event:"input",getValue:h=>h.value}),c.append(m),c.append(d),s.append(c),T(e.strengthMeter)){const h=np(p(e.value)),b=l("div",{class:"rui-password-input-strength","data-score":String(h.score)});for(let y=0;y<4;y+=1)b.append(l("span",{class:"rui-password-input-strength-bar","data-filled":y<h.score?"true":"false"}));const v=l("div",{class:"rui-password-input-strength-row"});v.append(b),h.label&&v.append(l("span",{class:"rui-password-input-strength-label"},[h.label])),s.append(v)}return s}},op={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=p(e.id),n=C(e.value).map(f=>p(f)).filter(Boolean),i=Math.max(0,Math.floor(L(e.max,0))),o=T(e.disabled),s=t.argMeta?.[1]?.stateRef,u=f=>{s&&r.setState(s,f),r.invoke(e.onChange,f)},c=p(e.label),m=l("div",{class:"rui-tag-input","data-disabled":o?"true":"false"});for(const f of n){const g=l("span",{class:"rui-tag-input-chip"});g.append(l("span",{},[f]));const h=l("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${f}`},["×"]);h.onclick=()=>u(n.filter(b=>b!==f)),g.append(h),m.append(g)}const d=l("input",{type:"text",class:"rui-tag-input-field",id:a,name:a,placeholder:p(e.placeholder,n.length===0?"Add tags…":""),disabled:o?"":null,autocomplete:"off"});if(d.onkeydown=f=>{const g=f,h=g.currentTarget;if(g.key==="Enter"||g.key===","){g.preventDefault();const b=h.value.trim();if(!b||i>0&&n.length>=i)return;if(n.includes(b)){h.value="";return}u([...n,b]),h.value=""}else g.key==="Backspace"&&h.value===""&&n.length>0&&(g.preventDefault(),u(n.slice(0,-1)))},m.append(d),c){const f=l("div",{class:"rui-tag-input-wrapper"});return f.append(l("label",{class:"rui-tag-input-label",for:a},[c])),f.append(m),f}return m}};function sp(t){return C(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,a=p(r.label??r.name??r.value??r.id);return{value:p(r.handle??r.value??r.id??r.name??r.label),label:a}}return{value:"",label:""}}).filter(e=>e.value||e.label)}const lp={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=p(e.id),n=sp(e.people),i=T(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(L(e.rows,3)))),placeholder:p(e.placeholder,"Type @ to mention someone"),disabled:i?"":null});s.value=p(e.value);const u=l("div",{class:"rui-mention-input-suggestions","data-open":"false"}),c=r.useInstanceState("activeIndex",0),m=r.useInstanceState("matches",[]),d=r.useInstanceState("query",null),f=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,h=(x,w)=>{const k=x.value,A=x.selectionStart??k.length,S=k.slice(0,A),$=S.lastIndexOf("@");if($===-1)return;const M=k.slice(A),I=`@${w.value} `,R=S.slice(0,$)+I+M;x.value=R;const j=$+I.length;x.selectionStart=x.selectionEnd=j,x.dispatchEvent(new Event("input",{bubbles:!0})),x.focus()},b=(x,w)=>{if(x.replaceChildren(),w===null){x.setAttribute("data-open","false"),m.set([]);return}const k=w.toLowerCase(),S=n.filter(M=>M.label.toLowerCase().includes(k)||M.value.toLowerCase().includes(k)).slice(0,6);if(m.set(S),S.length===0){x.setAttribute("data-open","false");return}const $=Math.min(c.get(),S.length-1);c.set($),x.setAttribute("data-open","true"),S.forEach((M,I)=>{const R=l("button",{type:"button",class:"rui-mention-input-option","data-value":M.value,"data-active":I===$?"true":"false"});R.append(l("span",{class:"rui-mention-input-option-label"},[M.label])),M.value&&M.value!==M.label&&R.append(l("span",{class:"rui-mention-input-option-handle"},[`@${M.value}`])),R.onmousedown=j=>j.preventDefault(),R.onclick=j=>{const K=j.currentTarget,F=g(K),U=f(K);F&&h(F,M),d.set(null),U&&b(U,null)},x.append(R)})},v=x=>{const w=f(x);if(!w)return;const k=x.selectionStart??x.value.length,A=x.value.slice(0,k),S=/@([\w-]*)$/.exec(A),$=S?S[1]??"":null;d.set($),b(w,$)},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)},ie(s,e.onChange,r,{event:"input",getValue:x=>x.value}),s.onkeydown=x=>{const w=x.currentTarget,k=f(w);if(!k||k.getAttribute("data-open")!=="true")return;const A=m.get();if(A.length!==0)if(x.key==="ArrowDown"){x.preventDefault();const S=(c.get()+1)%A.length;c.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((M,I)=>M.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="ArrowUp"){x.preventDefault();const S=(c.get()-1+A.length)%A.length;c.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((M,I)=>M.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="Enter"||x.key==="Tab"){x.preventDefault();const S=A[c.get()];S&&(h(w,S),d.set(null),b(k,null))}else x.key==="Escape"&&(d.set(null),b(k,null))},s.onblur=x=>{const w=x.currentTarget;setTimeout(()=>{const k=f(w);d.set(null),k&&b(k,null)},120)},o.append(s),o.append(u),b(u,d.get()),o}},cp={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=p(e.id),n=l("div",{class:"rui-time-picker"}),i=p(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:p(e.value),min:p(e.min)||null,max:p(e.max)||null,step:e.step!=null?String(L(e.step,60)):null,disabled:T(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ie(o,e.onChange,r,{event:"change",getValue:u=>u.value}),n.append(o),n}},up={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=p(e.id),n=l("div",{class:"rui-datetime-picker"}),i=p(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:p(e.value),min:p(e.min)||null,max:p(e.max)||null,step:e.step!=null?String(L(e.step,60)):null,disabled:T(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ie(o,e.onChange,r,{event:"change",getValue:u=>u.value}),n.append(o),n}};function ei(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 dp={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=p(e.id),n=p(e.mask),i=T(e.disabled),o=ei(p(e.value),n),s=p(e.label),u=l("input",{type:"text",class:"rui-masked-input",id:a,name:a,value:o,placeholder:p(e.placeholder,n),disabled:i?"":null,autocomplete:"off"});u.value=o;const c=t.argMeta?.[2]?.stateRef,m=d=>{const f=d.value,g=ei(f,n);if(g===f)return g;const h=d.selectionStart??g.length;d.value=g;const b=Math.min(g.length,h);try{d.setSelectionRange(b,b)}catch{}return g};if(c?r.bindState(u,c,{event:"input",getValue:d=>m(d)}):u.oninput=d=>{m(d.currentTarget??d.target)},ie(u,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(u),d}return u}},pp={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"},[p(e.label)]));const i=p(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 C(e.children))o.append(r.renderNode(s));return a.append(o),a}},mp={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:T(e.disabled)?"":null});a.append(l("legend",{class:"rui-fieldset-legend"},[p(e.legend)]));const n=p(e.helper);n&&a.append(l("p",{class:"rui-fieldset-helper"},[n]));for(const i of C(e.children))a.append(r.renderNode(i));return a}},fp={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=C(e.errors).map(u=>{if(!u)return null;if(typeof u=="string")return{label:"",message:u,field:""};if(typeof u=="object"){const c=u;return{label:p(c.label),message:p(c.message??c.error),field:p(c.field)}}return null}).filter(u=>u!==null&&u.message!=="");if(r.length===0)return l("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const a=p(e.tone,"danger"),n=l("aside",{class:"rui-validation-summary","data-tone":a,role:"alert"}),i=l("div",{class:"rui-validation-summary-title"}),o=E(a==="warning"?"triangle-exclamation":"circle-xmark",{className:"rui-validation-summary-icon"});o&&i.append(o),i.append(document.createTextNode(p(e.title,"Please fix the following:"))),n.append(i);const s=l("ul",{class:"rui-validation-summary-list"});for(const u of r){const c=l("li",{class:"rui-validation-summary-item"});u.label&&c.append(l("strong",{},[`${u.label}: `])),c.append(document.createTextNode(u.message)),s.append(c)}return n.append(s),n}};function gp(t){return C(t).map(e=>{if(!e||typeof e!="object")return{title:p(e),details:"",content:null};const r=e;return{title:p(r.title),details:p(r.details),content:r.content??null}})}const hp={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=gp(e.steps),n=a.length,i=Math.max(0,Math.min(n-1,Math.floor(L(e.current,0)))),o=t.argMeta?.[1]?.stateRef,s=p(e.stepsLayout,"column").toLowerCase(),u=s==="row"||s==="horizontal"?"row":"column",c=l("div",{class:"rui-multi-step-form","data-layout":u}),m=l("ol",{class:"rui-steps rui-multi-step-form-steps","data-layout":u});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])),m.append(k)}),c.append(m);const d=l("div",{class:"rui-multi-step-form-body"}),f=a[i];f&&f.content&&d.append(r.renderNode(f.content)),c.append(d);const g=l("div",{class:"rui-multi-step-form-footer"}),h=l("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:i<=0?"":null},[p(e.prevLabel,"Back")]);o&&i>0&&(h.onclick=()=>r.setState(o,i-1));const b=i>=n-1,v=b?p(e.submitLabel,"Submit"):p(e.nextLabel,"Continue"),y=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[v]);return y.onclick=()=>{b?r.invoke(e.onSubmit):o&&r.setState(o,i+1)},g.append(h),g.append(l("span",{class:"rui-multi-step-form-progress"},[`${i+1} / ${n}`])),g.append(y),c.append(g),c}};function bp(t){return C(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:p(r.title),message:p(r.message),time:p(r.time),icon:p(r.icon),tone:p(r.tone,"default"),unread:T(r.unread),avatarSrc:p(r.avatarSrc),onClick:r.onClick??r.action}}).filter(e=>e!==null)}const vp={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=bp(e.items),n=a.filter(u=>u.unread),i=a.filter(u=>!u.unread),o=l("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&n.length>0){const u=l("div",{class:"rui-inbox-panel-toolbar"}),c=l("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);c.onclick=()=>r.invoke(e.onMarkAllRead),u.append(c),o.append(u)}if(a.length===0)return o.append(l("div",{class:"rui-inbox-panel-empty"},[p(e.emptyLabel,"You're all caught up.")])),o;const s=(u,c)=>{if(c.length===0)return;const m=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"},[u])),d.append(l("span",{class:"rui-inbox-panel-group-count"},[String(c.length)])),m.append(d);for(const f of c){const g=Rn.render({__kind:"Component",name:"Notification",args:[],argMeta:[]},{title:f.title,message:f.message,time:f.time,icon:f.icon,tone:f.tone,avatarSrc:f.avatarSrc,unread:f.unread},r);typeof f.onClick=="function"&&(g.setAttribute("data-clickable","true"),g.onclick=()=>r.invoke(f.onClick)),m.append(g)}o.append(m)};return s(`Unread (${n.length})`,n),s("Earlier",i),o}};function yp(t){return C(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:p(r.title),description:p(r.description),done:T(r.done),onClick:r.onClick??r.action,cta:p(r.cta,"Start")}}).filter(e=>e!==null)}const xp={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=yp(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"}),u=l("header",{class:"rui-onboarding-checklist-header"});u.append(l("h3",{class:"rui-onboarding-checklist-title"},[p(e.title,"Getting started")]));const c=p(e.subtitle);c&&u.append(l("p",{class:"rui-onboarding-checklist-subtitle"},[c])),u.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(u);const m=l("ol",{class:"rui-onboarding-checklist-list"});for(const d of a){const f=l("li",{class:"rui-onboarding-checklist-item","data-done":d.done?"true":"false"}),g=l("span",{class:"rui-onboarding-checklist-marker"}),h=E(d.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});h&&g.append(h),f.append(g);const b=l("div",{class:"rui-onboarding-checklist-body"});if(b.append(l("div",{class:"rui-onboarding-checklist-item-title"},[d.title])),d.description&&b.append(l("p",{class:"rui-onboarding-checklist-item-description"},[d.description])),f.append(b),!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),f.append(v)}m.append(f)}return s.append(m),s}};function ti(t){const e=l("div",{class:`rui-${t.klass}`});if(t.iconName){const a=E(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=C(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 wp={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"},[p(e.title,"Loading…")]));const n=p(e.description);return n&&r.append(l("p",{class:"rui-loading-state-description"},[n])),r}},kp={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)=>ti({klass:"error-state",iconName:p(e.icon,"circle-exclamation"),iconClass:"rui-error-state-icon",title:p(e.title,"Something went wrong"),description:p(e.description),actions:e.actions,helpers:r})},Sp={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)=>ti({klass:"success-state",iconName:p(e.icon,"circle-check"),iconClass:"rui-success-state-icon",title:p(e.title),description:p(e.description),actions:e.actions,helpers:r})},Cp={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=C(e.steps).map(v=>{if(!v||typeof v!="object")return{title:p(v),description:"",target:""};const y=v;return{title:p(y.title),description:p(y.description),target:p(y.target)}}),n=e.open===void 0?!0:T(e.open),i=a.length,o=Math.max(0,Math.min(i-1,Math.floor(L(e.current,0)))),s=t.argMeta?.[1]?.stateRef,u=l("div",{class:"rui-tour","data-open":n?"true":"false"});if(!n||i===0)return u;const c=a[o];if(!c)return u;const m=l("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});m.append(l("div",{class:"rui-tour-step"},[`Step ${o+1} of ${i}`])),m.append(l("h3",{class:"rui-tour-title"},[c.title])),c.description&&m.append(l("p",{class:"rui-tour-description"},[c.description])),c.target&&m.append(l("div",{class:"rui-tour-target"},[`Target: ${c.target}`]));const d=l("div",{class:"rui-tour-footer"}),f=l("button",{type:"button",class:"rui-button","data-variant":"ghost"},["Skip"]);f.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 h=o>=i-1,b=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[h?"Finish":"Next"]);return b.onclick=()=>{h?r.invoke(e.onComplete):s&&r.setState(s,o+1)},d.append(f,g,b),m.append(d),u.append(m),u}},$p={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:T(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"},[p(e.title)]));const o=p(e.description);o&&i.append(l("p",{class:"rui-spotlight-description"},[o]));const s=C(e.actions);if(s.length>0){const c=l("div",{class:"rui-spotlight-actions"});for(const m of s)c.append(r.renderNode(m));i.append(c)}const u=t.argMeta?.[1]?.stateRef;return u&&(n.onclick=c=>{c.target===n&&r.setState(u,!1)}),n.append(i),n}},Tp={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=p(e.side,"top"),n=te(e.offset,"0"),i=Math.max(0,Math.floor(L(e.zIndex,10))),o=`position:sticky;${a}:${n};z-index:${i};`,s=l("div",{class:"rui-sticky",style:o});for(const u of C(e.children))s.append(r.renderNode(u));return s}},Ap={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=te(e.initialPrimaryWidth,"40%"),n=te(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 c of C(e.primary))o.append(r.renderNode(c));const s=l("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),u=l("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const c of C(e.secondary))u.append(r.renderNode(c));return i.append(o,s,u),s.onpointerdown=c=>{const m=c,d=m.currentTarget;d.setPointerCapture(m.pointerId);const f=d.closest(".rui-resizable-panels");if(!f)return;const g=f.getBoundingClientRect(),h=v=>{const y=(v.clientX-g.left)/g.width*100,x=Math.max(15,Math.min(85,y));f.style.setProperty("--rui-resizable-primary",`${x}%`)},b=v=>{d.releasePointerCapture(v.pointerId),d.removeEventListener("pointermove",h),d.removeEventListener("pointerup",b)};d.addEventListener("pointermove",h),d.addEventListener("pointerup",b)},i}},Np={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(L(e.columns,3)))),n=p(e.gap,"m"),i=l("div",{class:"rui-masonry-grid","data-columns":String(a),"data-gap":n});for(const o of C(e.items))i.append(r.renderNode(o));return i}},Mp={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=T(e.open),n=p(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"},[p(e.title)]));const u=l("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),c=t.argMeta?.[1]?.stateRef,m=()=>{c&&r.setState(c,!1),r.invoke(e.onClose)};u.onclick=m,i.onclick=g=>{g.target===i&&m()},s.append(u),o.append(s);const d=l("div",{class:"rui-sheet-body"});for(const g of C(e.children))d.append(r.renderNode(g));o.append(d);const f=C(e.footer);if(f.length>0){const g=l("footer",{class:"rui-sheet-footer"});for(const h of f)g.append(r.renderNode(h));o.append(g)}return i.append(o),i}},Pp={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":T(e.sticky)?"true":"false"}),n=l("div",{class:"rui-topbar-side rui-topbar-left"}),i=p(e.title);if(i){const u=l("div",{class:"rui-topbar-title-block"});u.append(l("h2",{class:"rui-topbar-title"},[i]));const c=p(e.subtitle);c&&u.append(l("p",{class:"rui-topbar-subtitle"},[c])),n.append(u)}for(const u of C(e.left))n.append(r.renderNode(u));a.append(n);const o=C(e.center);if(o.length>0){const u=l("div",{class:"rui-topbar-side rui-topbar-center"});for(const c of o)u.append(r.renderNode(c));a.append(u)}const s=l("div",{class:"rui-topbar-side rui-topbar-right"});for(const u of C(e.right))s.append(r.renderNode(u));return a.append(s),a}},Ip={name:"Theme",description:"Apply a partial theme on top of the base theme. Pass an object of token → value pairs (colors, fonts, radii, spacing, button styling). Assigning the result to a top-level binding (conventionally `theme`) lets the runtime detect it and write the tokens to the host as CSS custom properties — the rest of the rendered UI picks them up instantly.",props:[{name:"tokens",type:"any",description:"Object literal of theme tokens. Keys must match `ThemeTokens` (e.g. colorPrimary, colorBg, fontFamily, fontFamilyHeading, fontSizeBase, radiusMd, radiusButton, borderWidth, shadowMd, buttonFontWeight, …). Unknown keys are ignored."}],render:()=>document.createDocumentFragment()},Lp={name:"NavLink",description:'Anchor that navigates to a route on click and stays in sync with the URL hash. Reflects `data-active="true"` 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=p(e.label,""),n=p(e.to,"/"),i=p(e.variant,"default"),o=T(e.exact,!1),s=r.router,u=s.getPath(),c=u?o?u===n:n==="/"?u==="/":u===n?!0:u.startsWith(n+"/"):!1,m=l("a",{class:"rui-nav-link","data-variant":i,"data-active":c?"true":"false",href:"#"+(n.startsWith("/")?n:"/"+n)}),d=E(e.icon,{className:"rui-nav-link-icon"});return d&&m.append(d),m.append(l("span",{class:"rui-nav-link-label"},[a])),m.onclick=f=>{f.defaultPrevented||f.button===0&&(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(f.preventDefault(),s.navigate(n)))},m}},zp=["primary","secondary","ghost","danger"],Rp=["xs","sm","md","lg","xl","small","normal","large"];function Ep(t){const e=p(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 jp(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.value??a.label);return{value:n,label:p(a.label,n)}}const r=p(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function Ot(t){return C(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function Dp(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.value??a.label);return{value:n,label:p(a.label,n),group:p(a.group)||void 0,shortcut:p(a.shortcut)||void 0,action:a.action}}const r=p(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function ri(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.name??a.label);return{name:n,label:p(a.label,n),type:p(a.type,"text")||"text"}}const r=p(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function Bp(t){return Ot(t).map((e,r)=>({id:p(e.id,`task-${r}`),label:p(e.label??e.name,`Task ${r+1}`),start:p(e.start),end:p(e.end),progress:e.progress!=null?L(e.progress,0):void 0}))}function Ue(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function Fp(t,e){const r=t.split(`
21
41
  `),a=e.split(`
22
- `),i=Math.max(r.length,a.length),n=[];for(let s=0;s<i;s++){const l=r[s],c=a[s];l===c?l!==void 0&&n.push({type:"same",text:l}):(l!==void 0&&n.push({type:"remove",text:l}),c!==void 0&&n.push({type:"add",text:c}))}return n}function Wa(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ga(t,e,r,a){for(const[i,n]of e){const s=o("div",{class:"rui-json-tree-row"});s.append(o("span",{class:"rui-json-tree-key"},[`${i}: `])),n!==null&&typeof n=="object"?s.append(Ka(n,r,a+1)):s.append(o("span",{class:"rui-json-tree-leaf"},[Wa(n)])),t.append(s)}}function Ka(t,e,r=0){const a=o("div",{class:"rui-json-tree-node","data-depth":String(r)});if(t===null||typeof t!="object")return a.append(o("span",{class:"rui-json-tree-leaf"},[Wa(t)])),a;const i=Array.isArray(t),n=i?t.map((u,p)=>[String(p),u]):Object.entries(t),s=e||r<1,l=o("button",{type:"button",class:"rui-json-tree-toggle","aria-expanded":s?"true":"false"},[s?"▼":"▶",i?` Array(${n.length})`:" Object"]),c=o("div",{class:"rui-json-tree-children","data-open":s?"true":"false"});return s&&Ga(c,n,e,r),l.onclick=u=>{const p=u.currentTarget,m=p.nextElementSibling;if(!m)return;const g=m.getAttribute("data-open")!=="true";m.setAttribute("data-open",g?"true":"false"),p.setAttribute("aria-expanded",g?"true":"false"),p.firstChild&&(p.firstChild.textContent=g?"▼":"▶"),g&&m.childElementCount===0?Ga(m,n,e,r):g||m.replaceChildren()},a.append(l,c),a}const Eu={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:"action",type:"callable",optional:!0,aliases:["onClick","onclick"]},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:Au},{name:"size",type:"string",optional:!0,enum:Mu},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=o("button",{class:"rui-icon-button",type:"button","data-variant":d(e.variant,"ghost"),"data-size":Pu(e.size),"aria-label":d(e.label),title:d(e.label),disabled:C(e.disabled)?"":null}),i=L(e.icon,{className:"rui-icon-button-icon"});return i&&a.append(i),a.onclick=()=>r.invoke(e.action),a}},_u={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=zu(e.items),i=e.open!==void 0,n=i?C(e.open):!0,s=r.useInstanceState("open",n);i&&s.get()!==n&&s.set(n);const l=r.useInstanceState("filter",""),c=i?n:s.get(),u=o("div",{class:"rui-command-palette","data-open":c?"true":"false"});if(!c)return u;const p=o("div",{class:"rui-command-palette-backdrop"}),m=o("div",{class:"rui-command-palette-panel",role:"dialog","aria-modal":"true"}),g=o("div",{class:"rui-command-palette-header"}),f=o("input",{type:"text",class:"rui-command-palette-input",placeholder:d(e.placeholder,"Search commands…"),value:l.get(),autocomplete:"off"});g.append(f);const h=d(e.shortcut);h&&g.append(o("span",{class:"rui-command-palette-shortcut"},[h])),m.append(g);const b=o("div",{class:"rui-command-palette-list",role:"listbox"}),v=(y,x)=>{y.replaceChildren();const w=x.trim().toLowerCase(),T=w===""?a:a.filter(N=>N.label.toLowerCase().includes(w)||N.value.toLowerCase().includes(w)||(N.group??"").toLowerCase().includes(w));let S="";for(const N of T.slice(0,50)){N.group&&N.group!==S&&(S=N.group,y.append(o("div",{class:"rui-command-palette-group"},[S])));const $=o("button",{type:"button",class:"rui-command-palette-item",role:"option","data-value":N.value},[N.label]);N.shortcut&&$.append(o("span",{class:"rui-command-palette-item-kbd"},[N.shortcut])),$.onclick=A=>{A.stopPropagation(),r.invoke(N.action),s.set(!1),l.set("");const z=A.currentTarget.closest(".rui-command-palette"),R=z?.querySelector(".rui-command-palette-panel");z?.setAttribute("data-open","false"),he(R??null)},y.append($)}T.length===0&&y.append(o("div",{class:"rui-command-palette-empty"},["No commands found"]))};return v(b,l.get()),m.append(b),p.onclick=y=>{const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");s.set(!1),x?.setAttribute("data-open","false"),he(w??null)},u.append(p,m),f.oninput=y=>{const x=y.currentTarget,w=x.closest(".rui-command-palette-panel")?.querySelector(".rui-command-palette-list");l.set(x.value),w&&v(w,x.value)},f.onkeydown=y=>{if(y.key==="Escape"){const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");s.set(!1),x?.setAttribute("data-open","false"),he(w??null)}},setTimeout(()=>f.focus(),0),Ee({liveRoot:m,onDismiss:()=>{s.set(!1),u.setAttribute("data-open","false")}}),u}},ju={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=Iu(e.chips),i=o("div",{class:"rui-filter-chips"}),n=o("div",{class:"rui-filter-chips-row"});for(const s of a){const l=o("span",{class:"rui-filter-chip","data-value":s.value});l.append(o("span",{class:"rui-filter-chip-label"},[s.label]));const c=o("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${s.label}`}),u=L("xmark",{className:"rui-filter-chip-remove-icon"});u&&c.append(u),c.onclick=()=>r.invoke(e.onRemove,s.value),l.append(c),n.append(l)}if(i.append(n),a.length>0&&typeof e.onClear=="function"){const s=o("button",{type:"button",class:"rui-filter-chips-clear"},["Clear all"]);s.onclick=()=>r.invoke(e.onClear),i.append(s)}return i}},Bu={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=pt(e.items),i=Va(e.fields),n=o("div",{class:"rui-field-repeater"});if(a.forEach((s,l)=>{const c=o("div",{class:"rui-field-repeater-row","data-index":String(l)}),u=o("div",{class:"rui-field-repeater-grid"});for(const p of i){const m=o("label",{class:"rui-field-repeater-field"});m.append(o("span",{class:"rui-field-repeater-label"},[p.label]));const g=o("input",{class:"rui-input",type:p.type==="number"?"number":"text",name:`${p.name}-${l}`,value:d(s[p.name]),readonly:""});m.append(g),u.append(m)}if(c.append(u),typeof e.onRemove=="function"){const p=o("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);p.onclick=()=>r.invoke(e.onRemove,l),c.append(p)}n.append(c)}),typeof e.onAdd=="function"){const s=o("button",{type:"button",class:"rui-field-repeater-add rui-button","data-variant":"secondary"},[d(e.addLabel,"Add row")]);s.onclick=()=>r.invoke(e.onAdd),n.append(s)}return n}},Du={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,P(e.itemHeight,40)),i=k(e.items),n=o("div",{class:"rui-virtual-list"}),s=o("div",{class:"rui-virtual-list-scroller"}),l=o("div",{class:"rui-virtual-list-spacer"}),c=o("div",{class:"rui-virtual-list-window"}),u=i.length;l.style.height=`${u*a}px`,l.style.position="relative",c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.right="0",s.style.maxHeight=`${Math.min(Math.max(u,1),12)*a}px`,s.style.overflow="auto";const p=m=>{c.replaceChildren();const g=s.clientHeight||a*12,f=Math.ceil(g/a)+2,h=Math.max(0,m),b=Math.min(u,h+f);c.style.transform=`translateY(${h*a}px)`;for(let v=h;v<b;v++){const y=i[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=o("div",{class:"rui-virtual-list-item",style:`height:${a}px`});x.append(o("span",{},[d(y)])),c.append(x)}}};return s.onscroll=()=>{const m=Math.floor(s.scrollTop/a);p(m)},p(0),s.append(l,c),n.append(s),n}},Fu={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=Va(e.fields),i=pt(e.value),n=t.argMeta?.[1]?.stateRef,s=o("div",{class:"rui-query-builder"}),l=c=>{s.replaceChildren(),c.forEach((p,m)=>{const g=o("div",{class:"rui-query-builder-row","data-index":String(m)}),f=o("select",{class:"rui-select rui-query-builder-field"});for(const y of a)f.append(o("option",{value:y.name},[y.label]));f.value=d(p.field??a[0]?.name);const h=o("select",{class:"rui-select rui-query-builder-op"},[]);for(const y of["equals","contains","gt","lt"])h.append(o("option",{value:y},[y]));h.value=d(p.op,"equals");const b=o("input",{class:"rui-input rui-query-builder-value",value:d(p.value)});g.append(f,h,b);const v=o("button",{type:"button",class:"rui-query-builder-remove"},["×"]);v.onclick=()=>{const y=c.filter((x,w)=>w!==m);n?r.setState(n,y):r.invoke(e.onChange,y),l(y)},g.append(v),s.append(g)});const u=o("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);u.onclick=()=>{const p=[...c,{field:a[0]?.name??"",op:"equals",value:""}];n?r.setState(n,p):r.invoke(e.onChange,p),l(p)},s.append(u)};return l(i.length>0?i:[{field:a[0]?.name??"",op:"equals",value:""}]),s}},Ou={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=d(e.left),a=d(e.right),i=d(e.mode,"split"),n=o("div",{class:"rui-diff-viewer","data-mode":i});if(i==="unified"){const u=o("pre",{class:"rui-diff-viewer-unified"});for(const p of Lu(r,a))u.append(o("div",{class:`rui-diff-line rui-diff-line-${p.type}`},[(p.type==="add"?"+ ":p.type==="remove"?"- ":" ")+p.text]));return n.append(u),n}const s=o("div",{class:"rui-diff-viewer-panes"}),l=o("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),c=o("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[a]);return s.append(l,c),n.append(s),n}},Uu={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=o("div",{class:"rui-json-tree"});return r.append(Ka(e.data,C(e.expanded))),r}},qu={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=Ru(e.tasks),a=r.map(p=>Ne(p.start)),i=r.map(p=>Ne(p.end)),n=e.startDate?Ne(d(e.startDate)):a.length?Math.min(...a):Date.now(),s=e.endDate?Ne(d(e.endDate)):i.length?Math.max(...i):n+864e5,l=Math.max(s-n,1),c=o("div",{class:"rui-gantt"}),u=o("div",{class:"rui-gantt-track"});for(const p of r){const m=o("div",{class:"rui-gantt-row"});m.append(o("div",{class:"rui-gantt-label"},[p.label]));const g=o("div",{class:"rui-gantt-bars"}),f=(Ne(p.start)-n)/l*100,h=Math.max((Ne(p.end)-Ne(p.start))/l*100,2),b=o("div",{class:"rui-gantt-bar",style:`left:${f}%;width:${h}%`,title:`${p.start} → ${p.end}`});p.progress!=null&&b.append(o("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,p.progress))}%`})),g.append(b),m.append(g),u.append(m)}return c.append(u),c}},Hu={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(P(e.maxLines,3))),i=r.useInstanceState("expanded",!1),n=`display:-webkit-box;-webkit-line-clamp:${a};-webkit-box-orient:vertical;overflow:hidden`,s=o("div",{class:"rui-truncate","data-expanded":i.get()?"true":"false"}),l=o("p",{class:"rui-truncate-text",style:i.get()?"":n},[d(e.text)]),c=o("button",{type:"button",class:"rui-truncate-toggle"},[i.get()?"Show less":d(e.expandLabel,"Show more")]);return c.onclick=u=>{const p=u.currentTarget,m=p.closest(".rui-truncate"),g=m?.querySelector(".rui-truncate-text");if(!m||!g)return;const f=!i.get();i.set(f),g.style.cssText=f?"":n,p.textContent=f?"Show less":d(e.expandLabel,"Show more"),m.setAttribute("data-expanded",f?"true":"false")},s.append(l,c),s}},Vu={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),i=r.useInstanceState("draft",d(e.value)),n=t.argMeta?.[0]?.stateRef,s=o("div",{class:"rui-inline-edit","data-editing":a.get()?"true":"false"}),l=d(e.label);l&&s.append(o("span",{class:"rui-inline-edit-label"},[l]));const c=o("button",{type:"button",class:"rui-inline-edit-display"},[d(e.value)]),u=o("input",{class:"rui-inline-edit-input rui-input",value:i.get()}),p=g=>{const f=g.closest(".rui-inline-edit"),h=f?.querySelector(".rui-inline-edit-input");return!f||!h?null:{root:f,input:h}},m=g=>{const f=p(g);a.set(!1),f?.root.setAttribute("data-editing","false");const h=i.get();n&&r.setState(n,h),r.invoke(e.onSave,h)};return c.onclick=g=>{const f=p(g.currentTarget);i.set(d(e.value)),a.set(!0),f&&(f.root.setAttribute("data-editing","true"),f.input.value=i.get(),setTimeout(()=>f.input.focus(),0))},u.oninput=g=>i.set(g.currentTarget.value),u.onkeydown=g=>{const f=g;if(f.key==="Enter"&&m(g.currentTarget),f.key==="Escape"){const h=p(g.currentTarget);a.set(!1),h?.root.setAttribute("data-editing","false")}},u.onblur=g=>m(g.currentTarget),s.append(c,u),s}},Wu={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(P(e.count,0))),i=pt(e.items),n=r.useInstanceState("open",!1),s=n.get(),l=o("div",{class:"rui-notification-bell","data-open":s?"true":"false"}),c=o("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":s?"true":"false","aria-haspopup":"true"}),u=L("bell",{className:"rui-notification-bell-icon"});u&&c.append(u),a>0&&c.append(o("span",{class:"rui-notification-bell-badge"},[a>99?"99+":String(a)])),l.append(c);const p=o("div",{class:"rui-notification-bell-panel",role:"menu"});if(i.length===0)p.append(o("div",{class:"rui-notification-bell-empty"},["No notifications"]));else for(const m of i){const g=o("div",{class:"rui-notification-bell-item"});g.append(o("div",{class:"rui-notification-bell-item-title"},[d(m.title)]));const f=d(m.message);f&&g.append(o("div",{class:"rui-notification-bell-item-message"},[f]));const h=d(m.time);h&&g.append(o("div",{class:"rui-notification-bell-item-time"},[h])),p.append(g)}return l.append(p),c.onclick=m=>{m.stopPropagation();const g=m.currentTarget,f=g.closest(".rui-notification-bell");if(!f)return;const h=!n.get();n.set(h),f.setAttribute("data-open",h?"true":"false"),g.setAttribute("aria-expanded",h?"true":"false"),h?(r.invoke(e.onOpen),Ee({liveRoot:f,onDismiss:()=>{n.set(!1),f.setAttribute("data-open","false"),g.setAttribute("aria-expanded","false")}})):he(f)},l}},ce=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),Gu=t=>!!(t&&typeof t=="object"),Ya=[ko,wo,ga,Lo,Eo,So,Co,To,$o,Mo,Ao,zo,Io,Do,No,_o,Bo,os,ss,Vo,Wo,Go,Yo,Jo,Xo,Zo,Qo,rs,ns,cs,Uo,ls,Ps,Ms,ws,ks,Cs,Ss,Ts,Ns,$s,As,ys,xs,wa,Is,zs,Rs,Ls,ka,Es,_s,xl,yl,kl,wl,Sl,Cl,$l,Tl,Pl,Il,zl,Ml,El,_l,jl,Fl,Ol,Zl,Ia,Ul,ql,Xl,Hl,Vl,Gl,Kl,ec,tc,Ql,Yl,ac,La,nc,lc,sc,pc,mc,gc,fc,Us,qs,hl,bl,Hs,Ws,Vs,Ks,Gs,Ys,Js,vl,Xs,Zs,Sa,gl,tl,el,Qs,rl,al,ol,nl,il,sl,ll,ul,cl,dl,ml,pl,vc,xc,Sc,Cc,Tc,Nc,Ac,Pc,Ic,zc,Lc,_c,jc,Dc,Oc,qc,Vc,Wc,Kc,Yc,Zc,eu,tu,au,iu,nu,ou,su,lu,cu,du,mu,fu,hu,bu,vu,yu,xu,wu,ku,Su,Cu,Tu,$u,Nu,Eu,_u,ju,Bu,Du,Fu,Ou,Uu,qu,Hu,Vu,Wu,{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,i={loading:e.loading,error:e.error,empty:e.empty,data:e.data};if(!Gu(a))return ce(r,i.empty??i.data??null);const n=a.state;if(n==="loading"||a.loading)return ce(r,i.loading??null);if(n==="error"||a.error)return ce(r,i.error??null);const s=a.data;return s==null||Array.isArray(s)&&s.length===0?ce(r,i.empty??i.data??null):ce(r,i.data??null)}},{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?ce(r,e.children??null):ce(r,e.fallback??null)},{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=d(e.target);let i=null;if(a)try{i=document.querySelector(a)}catch{i=null}i||(i=document.body);const n=o("div",{class:"rui-portal"});for(const s of k(e.children))n.append(r.renderNode(s));return i&&(i.append(n),r.registerDisposer(()=>{n.parentNode&&n.parentNode.removeChild(n)})),o("span",{class:"rui-portal-anchor","data-portal":a??"body"})}},{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=d(e.path);if(a)try{r.router.navigate(a)}catch{}return o("span",{class:"rui-redirect","data-path":a,hidden:"true"})}},{name:"Lazy",description:"Defer rendering `children` until `loader` resolves.",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;if(typeof a=="function")try{const i=a();return i&&typeof i.then=="function"?ce(r,e.fallback??null):ce(r,i??e.children??null)}catch{return ce(r,e.fallback??null)}return ce(r,e.children??null)}},{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=o("div",{class:"rui-error-boundary"});try{for(const i of k(e.children))a.append(r.renderNode(i));return a}catch(i){try{r.invoke(e.onError,i)}catch{}const n=ce(r,e.fallback??null),s=o("div",{class:"rui-error-boundary rui-error-boundary--fallback"});return s.append(n),s.setAttribute("data-error",i instanceof Error?i.message:String(i)),s}}}],Ku=[{name:"Layout",components:["Stack","StackItem","Grid","GridItem","Box","Container","Spacer","Card","CardHeader","CardFooter","Separator","Tabs","TabItem","Accordion","AccordionItem","Modal","Drawer","Steps","AspectRatio","ScrollArea","Sticky","ResizablePanels","MasonryGrid"],notes:["- `root` MUST be `Stack(...)` and contain at least one child.","- Wrap each major chunk of content in a `Card(...)` for visual grouping.",'- Prefer `Grid(...)` over `Stack` with `direction="row" wrap=true` when children should size uniformly (KPIs, feature tiles, card grids).',"- Use `Container(children, size?)` to centre a wide page within a comfortable max-width (landing pages, articles, marketing sections).",'- Use `Spacer()` inside `Stack(direction="row")` to push the next item to the far edge; pass a `size` for an explicit fixed gap.','- Use `Separator(orientation?, label?)` between sections to add visual breaks. Pass a `label` for a centered "OR"-style separator.',"- Use `Drawer` for side-panel detail views, `Modal` for centered dialogs.","- Use `Sticky(children, side?, offset?)` to pin a toolbar/banner while the surrounding content scrolls.","- Use `ResizablePanels(primary, secondary, initialPrimaryWidth?)` for user-resizable two-pane layouts (code editors, file browsers).","- Use `MasonryGrid([...])` for Pinterest-style mixed-height card walls — prefer `Grid` when rows should share a height.",'- Use `StackItem(child, grow?, shrink?, basis?, alignSelf?)` inside `Stack(direction="row", uniform=false)` for toolbars.','- Use `Grid(columns: 12, [GridItem(child, span: "1/4"), GridItem(main, span: "3/4")])` for sidebar layouts; fractional spans `"1/2"`…`"1/12"` resolve on a 12-column track.',"- Use `Box(children, padding?, margin?, border?, background?)` for spacing and surfaces without raw CSS."]},{name:"Content",components:["Text","Image","Link","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 an `action` block (use a `js{ … }` body if you need to read file contents directly).",'- 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 `@Each(data.rows, "row", ...)` 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 `@Filter` / `@Each`.']},{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 = @Filter($toasts, "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:"Theming",components:["Theme"],notes:["- `Theme({...})` applies a partial token override **on top of** the base theme set by the host (attribute / `setTheme()`). Use it to brand a single response without changing host configuration.","- Assign the result to a top-level binding called `theme` so the runtime picks it up:",' `theme = Theme({ colors: { primary: "#0969da" }, radius: { button: "6px" } })`',"- Tokens MUST use the structured form. Top-level groups: `colors`, `radius`, `font`, `motion`, `elevation` (plus metadata: `name`, `direction`).","- Common tokens (each lives inside its group): `colors.primary`, `colors.primaryHover`, `colors.primaryText`, `colors.accent`, `colors.bg`, `colors.surface`, `colors.text`, `colors.textMuted`, `colors.border`, `colors.focusRing`; `radius.md`, `radius.button`, `radius.input`; `font.family`, `font.familyHeading`, `font.sizeBase`, `font.weightHeading`; `motion.transitionDuration`; `elevation.md`.","- The legacy flat-shape form (`Theme({colorPrimary: ...})`) and free-form `--css-vars` are removed in Aktion 0.5 — the runtime drops them and the schema validator surfaces a migration warning.",'- Tokens are CSS values (`"#0969da"`, `"\'Inter\', sans-serif"`, `"6px"`, `"600"`). The runtime ignores unknown keys inside a group, so typos fail silent.',"- Removing the `Theme(...)` line snaps the UI back to the base theme without a reload."]},{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 a `$query` / `$mutation` / `$subscription` resource on its `state` field.","- `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 children until `loader` resolves.","- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants."]}];kr(Ya);const Ke={root:"Stack",components:Ya,componentGroups:Ku},Yu="$";class Ja{constructor(e){j(this,"instanceStates",new Map);j(this,"instanceDisposers",new Map);j(this,"aliveInstances",new Set);j(this,"instancesWithEffects",new Set);this.options=e}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.options.unmountInstanceEffects)for(const e of this.instancesWithEffects)try{this.options.unmountInstanceEffects(e)}catch(r){console.error(`[aktion] unmountInstanceEffects threw for ${e}`,r)}this.instancesWithEffects.clear(),this.aliveInstances=new Set}beginRender(){this.aliveInstances=new Set}endRender(){const e=this.aliveInstances;for(const r of[...this.instanceStates.keys()]){const a=r.lastIndexOf("::"),i=a===-1?r:r.slice(0,a);e.has(i)||this.instanceStates.delete(r)}for(const[r,a]of[...this.instanceDisposers.entries()])if(!e.has(r)){for(const i of a.values())this.safeDispose(i);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)}}}safeDispose(e){try{e()}catch(r){console.error("[aktion] disposer threw",r)}}render(e){return this.renderAt(e,Yu)}renderAt(e,r){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const a=document.createDocumentFragment();return e.forEach((i,n)=>{a.append(this.renderAt(i,`${r}/${n}`))}),a}return Hr(e)?this.renderUserComponent(e,r):qr(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 u=document.createElement("div");return u.className="rui-unknown-component",u.textContent=`[unknown component: ${e.decl.name}]`,u}const i=a(),n=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,s=`${r}#${e.decl.name}${n}`;this.aliveInstances.add(s);const{value:l,effects:c}=Kr(e,i,s);return this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(s,c,a),c.length>0&&this.instancesWithEffects.add(s)),this.renderAt(l,s)}renderComponent(e,r){const a=Ie(this.options.library,e.name);if(!a){const u=document.createElement("div");return u.className="rui-unknown-component",u.textContent=`[unknown component: ${e.name}]`,u}const i=Sr(a,e.args),n=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,s=`${r}#${e.name}${n}`;this.aliveInstances.add(s);let l=0;const c={renderNode:u=>this.renderAt(u,`${s}>${l++}`),invoke:(u,...p)=>{if(typeof u=="function")try{const m=u(...p);m&&typeof m.then=="function"&&m.catch(g=>{console.error("[aktion] handler rejected",g)})}catch(m){console.error("[aktion] handler threw",m)}},setState:(u,p)=>{this.options.state.set(u,p)},resetState:(...u)=>{this.options.state.reset(...u)},sendToAssistant:u=>{this.options.onAssistantMessage?.(u)},openUrl:u=>{const p=rt(u,"#"),m=this.options.onOpenUrl;m?m(p):p!=="#"&&typeof window<"u"&&window.open(p,"_blank","noopener,noreferrer")},bindState:(u,p,m)=>{const f=`on${m?.event??this.eventFor(u)}`,h=m?.getValue??this.defaultValueGetter(u);u[f]=b=>{const v=b.currentTarget??b.target??u;this.options.state.set(p,h(v))}},useInstanceState:(u,p)=>{const m=`${s}::${u}`;return this.instanceStates.has(m)||this.instanceStates.set(m,p),{get:()=>this.instanceStates.get(m),set:g=>{this.instanceStates.set(m,g)}}},registerDisposer:(u,p)=>{let m=this.instanceDisposers.get(s);m||(m=new Map,this.instanceDisposers.set(s,m));const g=p??`__anon::${m.size}`,f=m.get(g);f&&f!==u&&this.safeDispose(f),m.set(g,u)},router:this.options.router};try{return a.render(e,i,c)}catch(u){console.error(`[aktion] failed to render ${a.name}`,u);const p=document.createElement("div");return p.className="rui-render-error",p.textContent=`[render error in ${a.name}]`,p}}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 i=Number(a);return Number.isFinite(i)?i:null}:e instanceof HTMLInputElement&&e.type==="range"?r=>Number(r.value):r=>r.value}}const Ju=["onclick","oninput","onchange","onsubmit","onfocus","onblur","onkeydown","onkeyup","onkeypress","onerror","onmouseenter","onmouseleave","onmousedown","onmouseup","onpointerdown","onpointerup"];function Xu(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];Qa(t,r)}function Xa(t,e){if(t===e)return t;if(t.nodeType!==e.nodeType)return Za(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?Za(r,a):(Zu(r,a),r)}function Za(t,e){return t.parentNode?.replaceChild(e,t),e}function Zu(t,e){Qu(t,e),ed(t,e),Qa(t,Array.from(e.childNodes)),td(t,e)}function Qu(t,e){const r=t.attributes;for(let i=r.length-1;i>=0;i-=1){const n=r[i];e.hasAttribute(n.name)||n.name==="open"&&t.tagName==="DETAILS"||t.removeAttribute(n.name)}const a=e.attributes;for(let i=0;i<a.length;i+=1){const n=a[i];t.getAttribute(n.name)!==n.value&&t.setAttribute(n.name,n.value)}}function ed(t,e){for(const r of Ju){const a=e[r],i=t[r];a!==i&&(t[r]=a??null)}}function td(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){rd(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){ad(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){!mt(t)&&t.value!==e.value&&(t.value=e.value);return}}function rd(t,e){if(t.type==="checkbox"||t.type==="radio"){const a=e.hasAttribute("checked")||e.checked;t.checked!==a&&!mt(t)&&(t.checked=a);return}const r=e.getAttribute("value")??e.value??"";!mt(t)&&t.value!==r&&(t.value=r)}function ad(t,e){const r=e.value??e.textContent??"";!mt(t)&&t.value!==r&&(t.value=r)}function mt(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function Qa(t,e){const r=new Map;for(const i of Array.from(t.childNodes)){const n=Vt(i);n&&r.set(n,i)}let a=0;for(const i of e){const n=t.childNodes[a]??null,s=Vt(i);if(s&&r.has(s)){const c=r.get(s);r.delete(s),c!==n&&t.insertBefore(c,n),Xa(c,i),a+=1;continue}if(!n){t.appendChild(i),a+=1;continue}const l=Vt(n);if(l&&(!s||l!==s)){t.insertBefore(i,n),a+=1;continue}Xa(n,i),a+=1}for(;t.childNodes.length>e.length;){const i=t.childNodes[t.childNodes.length-1];t.removeChild(i)}}function Vt(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}const id={Count:{description:"Number of items in an array.",params:[{name:"array",type:"any[]",required:!0}]},Sum:{description:"Sum of numeric values in an array.",params:[{name:"array",type:"number[]",required:!0}]},Avg:{description:"Average of numeric values in an array.",params:[{name:"array",type:"number[]",required:!0}]},Min:{description:"Minimum of numeric values in an array.",params:[{name:"array",type:"number[]",required:!0}]},Max:{description:"Maximum of numeric values in an array.",params:[{name:"array",type:"number[]",required:!0}]},First:{description:"First element of an array, or null.",params:[{name:"array",type:"any[]",required:!0}]},Last:{description:"Last element of an array, or null.",params:[{name:"array",type:"any[]",required:!0}]},Filter:{description:"Filter an array by a field/operator/value comparison.",params:[{name:"array",type:"any[]",required:!0},{name:"field",type:"string",required:!0},{name:"op",type:"'=='|'!='|'>'|'<'|'>='|'<='|'contains'",required:!0},{name:"value",type:"any",required:!0}]},FilterBy:{description:"Alias for `@Filter` — filter an array by a field/operator/value comparison.",params:[{name:"array",type:"any[]",required:!0},{name:"field",type:"string",required:!0},{name:"op",type:"'=='|'!='|'>'|'<'|'>='|'<='|'contains'",required:!0},{name:"value",type:"any",required:!0}]},Sort:{description:"Sort an array by a field, ascending or descending.",params:[{name:"array",type:"any[]",required:!0},{name:"field",type:"string",required:!0},{name:"direction",type:"'asc'|'desc'",required:!1}]},Round:{description:"Round a number to N decimals (default 0).",params:[{name:"value",type:"number",required:!0},{name:"decimals",type:"number",required:!1}]},Abs:{description:"Absolute value of a number.",params:[{name:"value",type:"number",required:!0}]},Floor:{description:"Round a number down to the nearest integer.",params:[{name:"value",type:"number",required:!0}]},Ceil:{description:"Round a number up to the nearest integer.",params:[{name:"value",type:"number",required:!0}]},Find:{description:"Find the first item matching a field/op/value comparator.",params:[{name:"array",type:"any[]",required:!0},{name:"field",type:"string",required:!0},{name:"op",type:"'=='|'!='|'>'|'<'|'>='|'<='|'contains'",required:!0},{name:"value",type:"any",required:!0}]},GroupBy:{description:"Group items into `{groupKey: [items…]}` by a field value.",params:[{name:"array",type:"any[]",required:!0},{name:"field",type:"string",required:!0}]},Slice:{description:"Slice an array by `[start, end)` — both indices optional.",params:[{name:"array",type:"any[]",required:!0},{name:"start",type:"number",required:!1},{name:"end",type:"number",required:!1}]},Unique:{description:"Deduplicate. With a `field`, dedupes by that field (first wins).",params:[{name:"array",type:"any[]",required:!0},{name:"field",type:"string",required:!1}]},Reverse:{description:"Return a reversed copy of the array (non-mutating).",params:[{name:"array",type:"any[]",required:!0}]},Range:{description:"Inclusive integer range. Third arg is the step (default 1 / -1).",params:[{name:"start",type:"number",required:!0},{name:"end",type:"number",required:!0},{name:"step",type:"number",required:!1}]},Repeat:{description:"Repeat a value N times. Useful for skeleton/placeholder grids.",params:[{name:"value",type:"any",required:!0},{name:"count",type:"number",required:!0}]},Pick:{description:'Keep only the listed keys from an object — `@Pick(obj, ["a","b"])`.',params:[{name:"object",type:"object",required:!0},{name:"keys",type:"string[]",required:!0}]},Format:{description:"Locale-aware number formatter. Modes: 'currency', 'percent', 'number'.",params:[{name:"value",type:"number",required:!0},{name:"mode",type:"'currency'|'percent'|'number'",required:!1},{name:"currencyOrLocale",type:"string",required:!1},{name:"locale",type:"string",required:!1}]},FormatDate:{description:"Format a date. Pattern tokens (MMM D, YYYY-MM-DD) or named: 'relative', 'date', 'time', 'datetime', 'iso'.",params:[{name:"value",type:"Date|number|string",required:!0},{name:"format",type:"string",required:!1}]},Now:{description:"Current moment as epoch ms — pair with `@FormatDate`.",params:[]},Today:{description:"Today's date at midnight, as an ISO string.",params:[]},AddDays:{description:"Shift a date by N days (negative N moves backward).",params:[{name:"date",type:"Date|number|string",required:!0},{name:"days",type:"number",required:!0}]},AddHours:{description:"Shift a date by N hours (negative N moves backward).",params:[{name:"date",type:"Date|number|string",required:!0},{name:"hours",type:"number",required:!0}]},DiffDays:{description:"Whole-day difference from start to end (end − start).",params:[{name:"start",type:"Date|number|string",required:!0},{name:"end",type:"Date|number|string",required:!0}]},StartOfWeek:{description:"Local Sunday 00:00:00 for the week containing the date.",params:[{name:"date",type:"Date|number|string",required:!0}]},EndOfMonth:{description:"Last moment of the calendar month containing the date.",params:[{name:"date",type:"Date|number|string",required:!0}]},Plural:{description:'Pluralisation: `@Plural(n, "order", "orders")` → "1 order" / "2 orders".',params:[{name:"count",type:"number",required:!0},{name:"singular",type:"string",required:!0},{name:"plural",type:"string",required:!1}]},Capitalize:{description:"Uppercase the first character.",params:[{name:"value",type:"string",required:!0}]},Lowercase:{description:"Lowercase every character.",params:[{name:"value",type:"string",required:!0}]},Uppercase:{description:"Uppercase every character.",params:[{name:"value",type:"string",required:!0}]},Titlecase:{description:"Capitalise the first letter of each word.",params:[{name:"value",type:"string",required:!0}]},Case:{description:'Convert casing — mode: "camel", "snake", "kebab", or "pascal".',params:[{name:"value",type:"string",required:!0},{name:"mode",type:"'camel'|'snake'|'kebab'|'pascal'",required:!0}]},Join:{description:'Join array values into a string (default separator ",").',params:[{name:"array",type:"any[]",required:!0},{name:"separator",type:"string",required:!1}]},Split:{description:'Split a string by a separator (default ",").',params:[{name:"value",type:"string",required:!0},{name:"separator",type:"string",required:!1}]},Trim:{description:"Trim leading and trailing whitespace.",params:[{name:"value",type:"string",required:!0}]},Replace:{description:"Replace all occurrences of search with replacement.",params:[{name:"value",type:"string",required:!0},{name:"search",type:"string",required:!0},{name:"replacement",type:"string",required:!1}]},Substring:{description:"Extract a substring — `start`, optional `end`.",params:[{name:"value",type:"string",required:!0},{name:"start",type:"number",required:!0},{name:"end",type:"number",required:!1}]},StartsWith:{description:"True when the string starts with the given prefix.",params:[{name:"value",type:"string",required:!0},{name:"prefix",type:"string",required:!0}]},EndsWith:{description:"True when the string ends with the given suffix.",params:[{name:"value",type:"string",required:!0},{name:"suffix",type:"string",required:!0}]},Contains:{description:"True when the string contains the given substring.",params:[{name:"value",type:"string",required:!0},{name:"needle",type:"string",required:!0}]},Match:{description:"Test a string against a RegExp pattern (invalid patterns return false).",params:[{name:"value",type:"string",required:!0},{name:"pattern",type:"string",required:!0}]},Clamp:{description:"Clamp a number into `[min, max]`.",params:[{name:"value",type:"number",required:!0},{name:"min",type:"number",required:!0},{name:"max",type:"number",required:!0}]},Pow:{description:"Raise a number to a power — `Math.pow(base, exp)`.",params:[{name:"base",type:"number",required:!0},{name:"exp",type:"number",required:!0}]},Sqrt:{description:"Square root of a number.",params:[{name:"value",type:"number",required:!0}]},Random:{description:"Pseudo-random number in [0, 1) — `Math.random()`.",params:[]},Log:{description:"Natural logarithm — `Math.log(value)`.",params:[{name:"value",type:"number",required:!0}]}},nd=[{name:"Each",category:"iteration",description:'Iterate over an array. The loop variable is scoped to the template. Supports destructuring: "{id, name}" binds those fields per row.',params:[{name:"array",type:"any[]",required:!0},{name:"varName",type:"string",required:!0},{name:"template",type:"Node",required:!0}]},{name:"If",category:"iteration",description:"Lazy conditional renderer — only the selected branch is evaluated. Useful when an unused branch would otherwise read missing loop variables.",params:[{name:"condition",type:"any",required:!0},{name:"trueBranch",type:"Node",required:!0},{name:"falseBranch",type:"Node",required:!1}]},{name:"Switch",category:"iteration",description:"Key-based branch selector. Stringifies `value` and renders the matching property of `cases` (or `default` when no key matches).",params:[{name:"value",type:"any",required:!0},{name:"cases",type:"{key: Node | string, ...}, i.e. {overview: Node, billing: 'Invoice', security: Node}",required:!0},{name:"default",type:"Node",required:!1}]}],od=t=>{const e=t.params.map(r=>r.required?r.name:`${r.name}?`);return`@${t.name}(${e.join(", ")})`},Wt=t=>({...t,signature:od(t)});function gt(){return[...Object.keys(At).map(e=>{const r=id[e];return Wt(r?{name:e,category:"data",...r}:{name:e,category:"data",description:`Data helper: @${e}`,params:[{name:"value",type:"any",required:!0}]})}),...nd.map(Wt)]}function ei(t){const e={};for(const r of t)e[r.name]=r;return e}const D="_app_";function Gt(t,e={}){return e.mode==="chat"?cd(t,e):ld(t,e)}function sd(t){return ft(t)}function ld(t,e){const r=(e.tools?.length??0)>0,a={toolCalls:e.toolCalls??r,bindings:e.bindings??e.toolCalls??r,inlineMode:e.inlineMode??!1,editMode:e.editMode??!1},i=[];i.push(ud(e.preamble)),i.push(dd()),i.push(pd()),a.bindings&&i.push(md()),i.push(gd()),i.push(fd()),i.push(hd()),a.toolCalls&&i.push(bd()),i.push(vd()),i.push(yd()),i.push(xd()),i.push(wd()),(a.toolCalls||a.bindings)&&i.push(kd()),i.push(Sd()),i.push(Cd()),i.push(Td()),i.push($d()),i.push(Nd()),i.push(Ad(t)),a.inlineMode&&i.push(Md()),a.editMode&&i.push(Pd()),e.tools&&e.tools.length>0&&i.push(Gd(e.tools)),e.toolExamples&&e.toolExamples.length>0&&i.push(Kt("Endpoint examples",e.toolExamples));const n=e.examples??Ld();return n.length>0&&i.push(Kt("Examples",n)),e.additionalRules&&e.additionalRules.length>0&&i.push(ti(e.additionalRules)),i.push(Id()),i.push(zd()),i.push(Rd()),i.join(`
42
+ `),n=Math.max(r.length,a.length),i=[];for(let o=0;o<n;o++){const s=r[o],u=a[o];s===u?s!==void 0&&i.push({type:"same",text:s}):(s!==void 0&&i.push({type:"remove",text:s}),u!==void 0&&i.push({type:"add",text:u}))}return i}function ai(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function ni(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(ii(i,r,a+1)):o.append(l("span",{class:"rui-json-tree-leaf"},[ai(i)])),t.append(o)}}function ii(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"},[ai(t)])),a;const n=Array.isArray(t),i=n?t.map((c,m)=>[String(m),c]):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"]),u=l("div",{class:"rui-json-tree-children","data-open":o?"true":"false"});return o&&ni(u,i,e,r),s.onclick=c=>{const m=c.currentTarget,d=m.nextElementSibling;if(!d)return;const f=d.getAttribute("data-open")!=="true";d.setAttribute("data-open",f?"true":"false"),m.setAttribute("aria-expanded",f?"true":"false"),m.firstChild&&(m.firstChild.textContent=f?"▼":"▶"),f&&d.childElementCount===0?ni(d,i,e,r):f||d.replaceChildren()},a.append(s,u),a}const Op={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:zp},{name:"size",type:"string",optional:!0,enum:Rp},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("button",{class:"rui-icon-button",type:"button","data-variant":p(e.variant,"ghost"),"data-size":Ep(e.size),"aria-label":p(e.label),title:p(e.label),disabled:T(e.disabled)?"":null}),n=E(e.icon,{className:"rui-icon-button-icon"});return n&&a.append(n),a.onclick=()=>r.invoke(e.onClick),a}},_p={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=Dp(e.items),n=e.open!==void 0,i=n?T(e.open):!0,o=r.useInstanceState("open",i);n&&o.get()!==i&&o.set(i);const s=r.useInstanceState("filter",""),u=n?i:o.get(),c=l("div",{class:"rui-command-palette","data-open":u?"true":"false"});if(!u)return c;const m=l("div",{class:"rui-command-palette-backdrop"}),d=l("div",{class:"rui-command-palette-panel",role:"dialog","aria-modal":"true"}),f=l("div",{class:"rui-command-palette-header"}),g=l("input",{type:"text",class:"rui-command-palette-input",placeholder:p(e.placeholder,"Search commands…"),value:s.get(),autocomplete:"off"});f.append(g);const h=p(e.shortcut);h&&f.append(l("span",{class:"rui-command-palette-shortcut"},[h])),d.append(f);const b=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 A="";for(const S of k.slice(0,50)){S.group&&S.group!==A&&(A=S.group,y.append(l("div",{class:"rui-command-palette-group"},[A])));const $=l("button",{type:"button",class:"rui-command-palette-item",role:"option","data-value":S.value},[S.label]);S.shortcut&&$.append(l("span",{class:"rui-command-palette-item-kbd"},[S.shortcut])),$.onclick=M=>{M.stopPropagation(),r.invoke(S.action),o.set(!1),s.set("");const I=M.currentTarget.closest(".rui-command-palette"),R=I?.querySelector(".rui-command-palette-panel");I?.setAttribute("data-open","false"),Ae(R??null)},y.append($)}k.length===0&&y.append(l("div",{class:"rui-command-palette-empty"},["No commands found"]))};return v(b,s.get()),d.append(b),m.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"),Ae(w??null)},c.append(m,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"),Ae(w??null)}},setTimeout(()=>g.focus(),0),Xe({liveRoot:d,onDismiss:()=>{o.set(!1),c.setAttribute("data-open","false")}}),c}},Up={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=jp(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 u=l("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${o.label}`}),c=E("xmark",{className:"rui-filter-chip-remove-icon"});c&&u.append(c),u.onclick=()=>r.invoke(e.onRemove,o.value),s.append(u),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}},Hp={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=Ot(e.items),n=ri(e.fields),i=l("div",{class:"rui-field-repeater"});if(a.forEach((o,s)=>{const u=l("div",{class:"rui-field-repeater-row","data-index":String(s)}),c=l("div",{class:"rui-field-repeater-grid"});for(const m of n){const d=l("label",{class:"rui-field-repeater-field"});d.append(l("span",{class:"rui-field-repeater-label"},[m.label]));const f=l("input",{class:"rui-input",type:m.type==="number"?"number":"text",name:`${m.name}-${s}`,value:p(o[m.name]),readonly:""});d.append(f),c.append(d)}if(u.append(c),typeof e.onRemove=="function"){const m=l("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);m.onclick=()=>r.invoke(e.onRemove,s),u.append(m)}i.append(u)}),typeof e.onAdd=="function"){const o=l("button",{type:"button",class:"rui-field-repeater-add rui-button","data-variant":"secondary"},[p(e.addLabel,"Add row")]);o.onclick=()=>r.invoke(e.onAdd),i.append(o)}return i}},Vp={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,L(e.itemHeight,40)),n=C(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"}),u=l("div",{class:"rui-virtual-list-window"}),c=n.length;s.style.height=`${c*a}px`,s.style.position="relative",u.style.position="absolute",u.style.top="0",u.style.left="0",u.style.right="0",o.style.maxHeight=`${Math.min(Math.max(c,1),12)*a}px`,o.style.overflow="auto";const m=d=>{u.replaceChildren();const f=o.clientHeight||a*12,g=Math.ceil(f/a)+2,h=Math.max(0,d),b=Math.min(c,h+g);u.style.transform=`translateY(${h*a}px)`;for(let v=h;v<b;v++){const y=n[v];if(e.renderItem)u.append(r.renderNode(y??e.renderItem));else if(y&&typeof y=="object"&&y.__kind)u.append(r.renderNode(y));else{const x=l("div",{class:"rui-virtual-list-item",style:`height:${a}px`});x.append(l("span",{},[p(y)])),u.append(x)}}};return o.onscroll=()=>{const d=Math.floor(o.scrollTop/a);m(d)},m(0),o.append(s,u),i.append(o),i}},Wp={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=ri(e.fields),n=Ot(e.value),i=t.argMeta?.[1]?.stateRef,o=l("div",{class:"rui-query-builder"}),s=u=>{o.replaceChildren(),u.forEach((m,d)=>{const f=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=p(m.field??a[0]?.name);const h=l("select",{class:"rui-select rui-query-builder-op"},[]);for(const y of["equals","contains","gt","lt"])h.append(l("option",{value:y},[y]));h.value=p(m.op,"equals");const b=l("input",{class:"rui-input rui-query-builder-value",value:p(m.value)});f.append(g,h,b);const v=l("button",{type:"button",class:"rui-query-builder-remove"},["×"]);v.onclick=()=>{const y=u.filter((x,w)=>w!==d);i?r.setState(i,y):r.invoke(e.onChange,y),s(y)},f.append(v),o.append(f)});const c=l("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);c.onclick=()=>{const m=[...u,{field:a[0]?.name??"",op:"equals",value:""}];i?r.setState(i,m):r.invoke(e.onChange,m),s(m)},o.append(c)};return s(n.length>0?n:[{field:a[0]?.name??"",op:"equals",value:""}]),o}},qp={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=p(e.left),a=p(e.right),n=p(e.mode,"split"),i=l("div",{class:"rui-diff-viewer","data-mode":n});if(n==="unified"){const c=l("pre",{class:"rui-diff-viewer-unified"});for(const m of Fp(r,a))c.append(l("div",{class:`rui-diff-line rui-diff-line-${m.type}`},[(m.type==="add"?"+ ":m.type==="remove"?"- ":" ")+m.text]));return i.append(c),i}const o=l("div",{class:"rui-diff-viewer-panes"}),s=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),u=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[a]);return o.append(s,u),i.append(o),i}},Gp={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(ii(e.data,T(e.expanded))),r}},Kp={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=Bp(e.tasks),a=r.map(m=>Ue(m.start)),n=r.map(m=>Ue(m.end)),i=e.startDate?Ue(p(e.startDate)):a.length?Math.min(...a):Date.now(),o=e.endDate?Ue(p(e.endDate)):n.length?Math.max(...n):i+864e5,s=Math.max(o-i,1),u=l("div",{class:"rui-gantt"}),c=l("div",{class:"rui-gantt-track"});for(const m of r){const d=l("div",{class:"rui-gantt-row"});d.append(l("div",{class:"rui-gantt-label"},[m.label]));const f=l("div",{class:"rui-gantt-bars"}),g=(Ue(m.start)-i)/s*100,h=Math.max((Ue(m.end)-Ue(m.start))/s*100,2),b=l("div",{class:"rui-gantt-bar",style:`left:${g}%;width:${h}%`,title:`${m.start} → ${m.end}`});m.progress!=null&&b.append(l("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,m.progress))}%`})),f.append(b),d.append(f),c.append(d)}return u.append(c),u}},Yp={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(L(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},[p(e.text)]),u=l("button",{type:"button",class:"rui-truncate-toggle"},[n.get()?"Show less":p(e.expandLabel,"Show more")]);return u.onclick=c=>{const m=c.currentTarget,d=m.closest(".rui-truncate"),f=d?.querySelector(".rui-truncate-text");if(!d||!f)return;const g=!n.get();n.set(g),f.style.cssText=g?"":i,m.textContent=g?"Show less":p(e.expandLabel,"Show more"),d.setAttribute("data-expanded",g?"true":"false")},o.append(s,u),o}},Xp={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",p(e.value)),i=t.argMeta?.[0]?.stateRef,o=l("div",{class:"rui-inline-edit","data-editing":a.get()?"true":"false"}),s=p(e.label);s&&o.append(l("span",{class:"rui-inline-edit-label"},[s]));const u=l("button",{type:"button",class:"rui-inline-edit-display"},[p(e.value)]),c=l("input",{class:"rui-inline-edit-input rui-input",value:n.get()}),m=f=>{const g=f.closest(".rui-inline-edit"),h=g?.querySelector(".rui-inline-edit-input");return!g||!h?null:{root:g,input:h}},d=f=>{const g=m(f);a.set(!1),g?.root.setAttribute("data-editing","false");const h=n.get();i&&r.setState(i,h),r.invoke(e.onSave,h)};return u.onclick=f=>{const g=m(f.currentTarget);n.set(p(e.value)),a.set(!0),g&&(g.root.setAttribute("data-editing","true"),g.input.value=n.get(),setTimeout(()=>g.input.focus(),0))},c.oninput=f=>n.set(f.currentTarget.value),c.onkeydown=f=>{const g=f;if(g.key==="Enter"&&d(f.currentTarget),g.key==="Escape"){const h=m(f.currentTarget);a.set(!1),h?.root.setAttribute("data-editing","false")}},c.onblur=f=>d(f.currentTarget),o.append(u,c),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(L(e.count,0))),n=Ot(e.items),i=r.useInstanceState("open",!1),o=i.get(),s=l("div",{class:"rui-notification-bell","data-open":o?"true":"false"}),u=l("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":o?"true":"false","aria-haspopup":"true"}),c=E("bell",{className:"rui-notification-bell-icon"});c&&u.append(c),a>0&&u.append(l("span",{class:"rui-notification-bell-badge"},[a>99?"99+":String(a)])),s.append(u);const m=l("div",{class:"rui-notification-bell-panel",role:"menu"});if(n.length===0)m.append(l("div",{class:"rui-notification-bell-empty"},["No notifications"]));else for(const d of n){const f=l("div",{class:"rui-notification-bell-item"});f.append(l("div",{class:"rui-notification-bell-item-title"},[p(d.title)]));const g=p(d.message);g&&f.append(l("div",{class:"rui-notification-bell-item-message"},[g]));const h=p(d.time);h&&f.append(l("div",{class:"rui-notification-bell-item-time"},[h])),m.append(f)}return s.append(m),u.onclick=d=>{d.stopPropagation();const f=d.currentTarget,g=f.closest(".rui-notification-bell");if(!g)return;const h=!i.get();i.set(h),g.setAttribute("data-open",h?"true":"false"),f.setAttribute("aria-expanded",h?"true":"false"),h?(r.invoke(e.onOpen),Xe({liveRoot:g,onDismiss:()=>{i.set(!1),g.setAttribute("data-open","false"),f.setAttribute("aria-expanded","false")}})):Ae(g)},s}},he=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),Zp=t=>!!(t&&typeof t=="object"),Qp={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(!Zp(a))return he(r,n.empty??n.data??null);const i=a.state;if(i==="loading"||a.loading)return he(r,n.loading??null);if(i==="error"||a.error)return he(r,n.error??null);const o=a.data;return o==null||Array.isArray(o)&&o.length===0?he(r,n.empty??n.data??null):he(r,n.data??null)}},em={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?he(r,e.children??null):he(r,e.fallback??null)},tm={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=p(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 C(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"})}},rm={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=p(e.path);if(a)try{r.router.navigate(a)}catch{}return l("span",{class:"rui-redirect","data-path":a,hidden:"true"})}},am={name:"Lazy",description:"Defer rendering `children` until `loader` resolves.",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;if(typeof a=="function")try{const n=a();return n&&typeof n.then=="function"?he(r,e.fallback??null):he(r,n??e.children??null)}catch{return he(r,e.fallback??null)}return he(r,e.children??null)}},nm={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 C(e.children))a.append(r.renderNode(n));return a}catch(n){try{r.invoke(e.onError,n)}catch{}const i=he(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}}},im=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"]),om=/^[a-zA-Z][a-zA-Z0-9_:-]*$/,sm=new Set(["href","ping","action","formaction"]),lm=new Set(["src","poster"]);function cm(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}function um(t){const e=p(t).trim().toLowerCase();return!e||!im.has(e)?"div":e}function dm(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||!om.test(n))continue;const i=n.toLowerCase();if(!i.startsWith("on")&&!(a==null||a===!1)){if(i==="style"){const o=cm(a);o&&(e.style=o);continue}if(sm.has(i)){const o=Ye(a,"");o&&(e[n]=o);continue}if(lm.has(i)){const o=ne(a);o&&(e[n]=o);continue}e[n]=a===!0?"":p(a)}}return e}const pm={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=um(e.tag),n=dm(e.attributes),i=l(a,n);for(const o of C(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}},mm=/<\/style|<script|expression\s*\(|javascript\s*:|behavior\s*:|@import\b/i,fm=64*1024;function gm(t){const e=p(t);return!e||e.length>fm||mm.test(e)?"":e}const oi=[dl,pl,fl,ml,cl,Cn,Tl,Al,gl,hl,bl,vl,wl,xl,Cl,Sl,Il,yl,Nl,Pl,Jl,Zl,Dl,Bl,Fl,In,_l,Ul,Hl,Vl,Gl,Xl,ec,Rl,Ql,zc,Lc,Cc,$c,Ac,Tc,Nc,Pc,Mc,Ic,kc,Sc,Ln,Rc,Ec,jc,Dc,zn,Bc,Fc,Su,ku,$u,Cu,Tu,Au,Mu,Nu,zu,Ru,Eu,Lu,Ou,_u,Uu,Wu,qu,ad,Un,Gu,Ku,rd,Yu,Xu,Zu,Qu,id,od,nd,ed,ld,Wn,ud,md,pd,bd,vd,yd,xd,Wc,qc,yu,xu,Gc,Yc,Kc,Jc,Xc,Zc,Qc,wu,eu,tu,Rn,bu,nu,au,ru,iu,ou,cu,lu,su,uu,du,mu,pu,fu,hu,gu,Sd,$d,Nd,Md,Pd,Ld,zd,Ed,jd,Dd,Fd,_d,Ud,Vd,qd,Kd,Xd,Jd,Qd,ep,ap,ip,op,lp,cp,up,dp,pp,mp,fp,hp,vp,xp,wp,kp,Sp,Cp,$p,Tp,Ap,Np,Mp,Pp,Ip,Lp,Op,_p,Up,Hp,Vp,Wp,qp,Gp,Kp,Yp,Xp,Jp,Qp,em,tm,rm,am,nm,cc,dc,mc,fc,gc,bc,In,pm,{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=gm(e.css),a=document.createElement("style");return a.setAttribute("class","rui-styles"),r&&(a.textContent=r),a}}],hm=[{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:"Theming",components:["Theme"],notes:["- `$theme({...})` applies a partial token override **on top of** the base theme set by the host (attribute / `setTheme()`). Use it to brand a single response without changing host configuration.","- Assign to `aktion.theme` so the runtime picks it up:",' `theme = $theme({ colors: { primary: "#0969da" }, radius: { button: "6px" } })`',"- Tokens MUST use the structured form. Top-level groups: `colors`, `radius`, `font`, `motion`, `elevation` (plus metadata: `name`, `direction`).","- Common tokens (each lives inside its group): `colors.primary`, `colors.primaryHover`, `colors.primaryText`, `colors.accent`, `colors.bg`, `colors.surface`, `colors.text`, `colors.textMuted`, `colors.border`, `colors.focusRing`; `radius.md`, `radius.button`, `radius.input`; `font.family`, `font.familyHeading`, `font.sizeBase`, `font.weightHeading`; `motion.transitionDuration`; `elevation.md`.","- The legacy flat-shape form (`$theme({colorPrimary: ...})`) and free-form `--css-vars` are removed in Aktion 0.5 — the runtime drops them and the schema validator surfaces a migration warning.",'- Tokens are CSS values (`"#0969da"`, `"\'Inter\', sans-serif"`, `"6px"`, `"600"`). The runtime ignores unknown keys inside a group, so typos fail silent.',"- Removing the `theme = $theme(...)` line snaps the UI back to the base theme without a reload."]},{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 children until `loader` resolves.","- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants."]},{name:"Behaviour wrappers",components:["OnClick","OnMouse","OnKeyboard","OnFocus","OnIntersect","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.","- `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."]}];ba(oi);const dt={root:"Column",components:oi,componentGroups:hm},bm="$";function vm(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 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(!Object.prototype.hasOwnProperty.call(e,n)||!Object.is(t[n],e[n]))return!1;return!0}class si{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);this.options=e}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}beginRender(e={}){this.aliveInstances=new Set,this.changedPaths=e.changedPaths??new Set,this.memoEnabled=e.memoize??!1}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)}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,bm)}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 Wa(e)?this.renderUserComponent(e,r):Va(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 u=document.createElement("div");return u.className="rui-unknown-component",u.textContent=`[unknown component: ${e.decl.name}]`,u}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&&vm(e.positional,s.positional)&&ym(e.named,s.named)&&!vt(this.changedPaths,s.deps)){const u=n.trackedState;for(const c of s.deps)u.add(c);nr(n,e.decl.name);try{return this.renderAt(s.value,o)}finally{ir(n)}}nr(n,e.decl.name);try{const u=n.trackedState,c=new Set;n.trackedState=c;let m;try{m=tn(e,n,o)}finally{n.trackedState=u;for(const h of c)u.add(h)}const{value:d,effects:f,hooks:g}=m;return this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(o,f,a),f.length>0&&this.instancesWithEffects.add(o)),g>0&&this.instancesWithHooks.add(o),this.memoCache.set(o,{positional:e.positional,named:e.named,deps:c,value:d}),this.renderAt(d,o)}finally{ir(n)}}renderComponent(e,r){const a=Ne(this.options.library,e.name);if(!a){const c=document.createElement("div");return c.className="rui-unknown-component",c.textContent=`[unknown component: ${e.name}]`,c}const n=va(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 u={renderNode:c=>this.renderAt(c,`${o}>${s++}`),invoke:(c,...m)=>{if(typeof c=="function")try{const d=c(...m);d&&typeof d.then=="function"&&d.catch(f=>{console.error("[aktion] handler rejected",f)})}catch(d){console.error("[aktion] handler threw",d)}},setState:(c,m)=>{this.writeState(c,m)},resetState:(...c)=>{this.options.state.reset(...c)},sendToAssistant:c=>{this.options.onAssistantMessage?.(c)},openUrl:c=>{const m=Ye(c,"#"),d=this.options.onOpenUrl;d?d(m):m!=="#"&&typeof window<"u"&&window.open(m,"_blank","noopener,noreferrer")},bindState:(c,m,d)=>{const g=`on${d?.event??this.eventFor(c)}`,h=d?.getValue??this.defaultValueGetter(c);c[g]=b=>{const v=b.currentTarget??b.target??c;this.writeState(m,h(v))}},useInstanceState:(c,m)=>{const d=`${o}::${c}`;return this.instanceStates.has(d)||this.instanceStates.set(d,m),{get:()=>this.instanceStates.get(d),set:f=>{this.instanceStates.set(d,f)}}},registerDisposer:(c,m)=>{let d=this.instanceDisposers.get(o);d||(d=new Map,this.instanceDisposers.set(o,d));const f=m??`__anon::${d.size}`,g=d.get(f);g&&g!==c&&this.safeDispose(g),d.set(f,c)},router:this.options.router};try{return a.render(e,n,u)}catch(c){console.error(`[aktion] failed to render ${a.name}`,c);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 xm=["onclick","oninput","onchange","onsubmit","onfocus","onblur","onkeydown","onkeyup","onkeypress","onerror","onmouseenter","onmouseleave","onmousedown","onmouseup","onpointerdown","onpointerup"];function wm(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];ui(t,r)}function li(t,e){if(t===e)return t;if(t.nodeType!==e.nodeType)return ci(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?ci(r,a):(km(r,a),r)}function ci(t,e){return t.parentNode?.replaceChild(e,t),e}function km(t,e){Sm(t,e),Cm(t,e),ui(t,Array.from(e.childNodes)),$m(t,e)}function Sm(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 Cm(t,e){for(const r of xm){const a=e[r],n=t[r];a!==n&&(t[r]=a??null)}}function $m(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){Tm(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){Am(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){!_t(t)&&t.value!==e.value&&(t.value=e.value);return}}function Tm(t,e){if(t.type==="checkbox"||t.type==="radio"){const a=e.hasAttribute("checked")||e.checked;t.checked!==a&&!_t(t)&&(t.checked=a);return}const r=e.getAttribute("value")??e.value??"";!_t(t)&&t.value!==r&&(t.value=r)}function Am(t,e){const r=e.value??e.textContent??"";!_t(t)&&t.value!==r&&(t.value=r)}function _t(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function ui(t,e){const r=new Map;for(const n of Array.from(t.childNodes)){const i=zr(n);i&&r.set(i,n)}let a=0;for(const n of e){const i=t.childNodes[a]??null,o=zr(n);if(o&&r.has(o)){const u=r.get(o);r.delete(o),u!==i&&t.insertBefore(u,i),li(u,n),a+=1;continue}if(!i){t.appendChild(n),a+=1;continue}const s=zr(i);if(s&&(!o||s!==o)){t.insertBefore(n,i),a+=1;continue}li(i,n),a+=1}for(;t.childNodes.length>e.length;){const n=t.childNodes[t.childNodes.length-1];t.removeChild(n)}}function zr(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}const V="aktion";function Rr(t,e={}){return e.mode==="chat"?Pm(t,e):Mm(t,e)}function Nm(t){return Ut(t)}function Mm(t,e){const r=e.bindings??!0,a=e.toolCalls??!0,n=[];n.push(Im(e.preamble)),n.push(Lm()),n.push(zm()),r&&n.push(Rm()),n.push(Em()),n.push(jm()),a&&n.push(Dm()),n.push(Bm()),n.push(Fm()),n.push(Om()),n.push(_m()),n.push(Um()),n.push(Hm()),n.push(Vm()),n.push(Wm(t)),e.inlineMode&&n.push(qm()),e.editMode&&n.push(Gm()),e.tools&&e.tools.length>0&&n.push(sf(e.tools)),e.toolExamples&&e.toolExamples.length>0&&n.push(Er("Endpoint examples",e.toolExamples));const i=e.examples??Ym();return i.length>0&&n.push(Er("Examples",i)),e.additionalRules&&e.additionalRules.length>0&&n.push(di(e.additionalRules)),n.push(Km()),n.join(`
23
43
 
24
44
  `).trim()+`
25
- `}function cd(t,e){const r=[];r.push(_d(e.preamble)),r.push(jd()),r.push(Bd(t)),r.push(Dd()),r.push(Fd()),r.push(Od()),e.tools&&e.tools.length>0&&r.push(Ud(e.tools));const a=e.examples??qd();return a.length>0&&r.push(Kt("Examples",a)),e.additionalRules&&e.additionalRules.length>0&&r.push(ti(e.additionalRules)),r.push(Hd()),r.push(Vd()),r.join(`
45
+ `}function Pm(t,e){const r=[];r.push(Jm(e.preamble)),r.push(Zm()),r.push(Qm(t)),r.push(ef()),e.tools&&e.tools.length>0&&r.push(rf(e.tools));const a=e.examples??af();return a.length>0&&r.push(Er("Examples",a)),e.additionalRules&&e.additionalRules.length>0&&r.push(di(e.additionalRules)),r.push(tf()),r.push(nf()),r.push(of()),r.join(`
26
46
 
27
47
  `).trim()+`
28
- `}function ud(t){return`${t?.trim()||"You are a full-stack UI engineer building **complete, working applications** in Aktion — a compact, declarative DSL for reactive, streaming-first user interfaces. Treat each prompt as a request to ship a real, production-quality product surface (dashboards, CRUD apps, multi-page websites, settings consoles, inboxes, admin panels, …). Never reply with a one-shot chat card; always produce a substantial, navigable app. Respond ONLY in Aktion — no prose, no JSON, no markdown, no HTML."}
29
-
30
- Every response MUST begin with \`${D} = ...\` on the very first line. Use a top-level container (\`${D} = AppShell(...)\` for full apps, \`${D} = Stack(...)\` for landing pages, etc.) or a user-declared component (\`${D} = App()\`). For multi-page apps wrap the main area in \`pages = _router_({ ... })\` and reference \`pages\` from \`${D}\`. Seed realistic mock data inline (5–20 plausible rows per dataset) when the host has no real backend. Wire every visible button to an \`action\`. Use \`$name = value\` for reactive state, \`http({ ... })\` for any data fetch, \`effect [ ...deps ] { … }\` for lifecycle work, \`_router_({ … })\` for navigation. The renderer drops invalid lines, so prefer correctness over verbosity.`}function dd(){return`## Mental model
31
-
32
- Aktion is a streaming-first, declarative DSL. A program is a flat
33
- list of \`name = expression\` statements. The renderer evaluates them lazily,
34
- re-parses the stream on every chunk, and silently treats undefined references
35
- as empty — so a partially-streamed program renders progressively from the top.
36
-
37
- Three identifier conventions cooperate:
38
-
39
- - **Plain bindings**: \`name = expression\` — a non-reactive alias. Reading
40
- it never subscribes; the value is captured once when the statement runs.
41
- - **Reactive atoms**: \`$name = value\` — a single tracked cell. Reading
42
- \`$name\` subscribes the surrounding component / effect; writing inside
43
- an \`action\` / \`effect\` / lambda body notifies subscribers.
44
- - **Reserved built-ins**: \`${D}\` (the UI root, required first
45
- line), \`theme\` (optional brand override), \`_route_\` (router-owned
46
- reactive surface — read \`_route_.path\` / \`_route_.params\` and call
47
- \`_route_.navigate("/path")\` to navigate), \`$i18n\` (i18n bundle handle).
48
-
49
- Three declaration keywords are reserved at the top level:
50
-
51
- - \`component Name(args) { … return Expression }\` — first-class UI
52
- primitive with optional defaults and per-instance state.
53
- - \`action Name(args) { … }\` — imperative side-effect block triggered by
54
- events. MAY \`return\` a value.
55
- - \`effect [ ...deps ] { … }\` — declarative, anonymous background work
56
- tied to a component / top-level binding. Dependencies (\`$atom\`,
57
- \`on:mount\`, \`on:unmount\`, \`on:every(N)\`, \`debounce(N)\`,
58
- \`throttle(N)\`) live in the bracketed list.
59
-
60
- Everything else (\`http({...})\`, \`_router_({...})\`, \`Theme({...})\`,
61
- \`i18n({...})\`, \`Toast(...)\`, \`Stack(...)\`) is a regular function /
62
- component call.`}function pd(){return`## Syntax
63
-
64
- Source is line-oriented; **newline terminates a statement**. Never use
65
- semicolons or statement-level commas. \`{ … }\` braces open blocks (component
66
- bodies, action bodies, effect bodies, control-flow arms, object literals).
67
- Indentation is purely cosmetic.
68
-
69
- ### Literals
70
- - Strings: \`"double"\` or \`'single'\`. Standard newline / tab / quote
71
- escape sequences are supported inside string bodies.
72
- - Template literals: backticks with \`\${expr}\` interpolation —
73
- \`\`\`Hi \${$user.name}, you have \${@Count($todos)} todos\`\`\`. Embed any
74
- expression; mix freely with state refs and \`@\`-builtins.
75
- - Numbers: \`42\`, \`-3.14\`, \`1_000_000\` (underscores allowed).
76
- - Booleans: \`true\`, \`false\`. Null: \`null\`.
77
- - Arrays: \`[1, 2, 3]\`, \`[Card1(), Card2()]\` — heterogeneous, multi-line OK.
78
- - Objects: \`{ name: "Ada", role: "Engineer" }\` — keys are bare identifiers
79
- or quoted strings; commas optional between rows on separate lines.
80
-
81
- ### Operators
82
- - Arithmetic: \`+ - * / %\`, unary \`-\`.
83
- - Comparison: \`== != > < >= <=\`.
84
- - Logical: \`&& || !\`. Nullish coalescing: \`??\`.
85
- - Ternary: \`cond ? a : b\`.
86
- - Spread \`...\` in arrays and objects: \`[...$a, ...$b]\`,
87
- \`{ ...$cur, status: "done" }\`.
88
- - Member access: \`obj.field\`, \`obj["field"]\` (bracket form), optional
89
- \`obj?.field\` to short-circuit on null/undefined.
90
-
91
- ### Array shortcuts
92
- - \`$rows.length\` / \`"hi".length\` — element / character count.
93
- - \`$rows.first\` / \`$rows.last\` — first or last element (\`null\` if empty).
94
- - **Array pluck**: \`$rows.title\` returns \`[row.title for each row]\` —
95
- the idiomatic projection. Composes with charts
96
- (\`PieChart(rows.label, rows.value)\`) and tables
97
- (\`Col("Title", rows.title)\`).
98
-
99
- ### Statements
100
- - \`name = expression\` — plain binding (top-level or block-local).
101
- - \`$name = expression\` — declare or write a reactive atom.
102
- - \`component Name(args) { … }\` — component declaration.
103
- - \`action Name(args) { … }\` — action declaration.
104
- - \`effect [ ...deps ] { … }\` — anonymous effect declaration.
105
- - \`return expression\` — only valid inside \`component\` / \`action\` /
106
- lambda bodies.
107
-
108
- ### Function calls and named arguments
109
- \`TypeName(arg1, prop: value, …)\` — arguments are matched against the
110
- spec's prop list in declaration order. Named arguments (\`prop: value\`)
111
- may appear at any position and override positional matching. Optional props
112
- can be omitted from the end.
113
-
114
- **One positional argument max** is the canonical 0.5 style — every
115
- component declares **at most one** canonical positional slot (its primary
116
- label / content / children). Pass that slot bare; every other argument is
117
- best supplied as a named argument:
48
+ `}function Im(t){return`${t?.trim()||"You are a UI engineer authoring complete, working applications in Aktion — a declarative language whose surface syntax is a strict subset of JavaScript. Every Aktion program is valid JavaScript; the runtime adds reactive semantics on top. Respond ONLY in Aktion: no prose, JSON, markdown, or HTML."}
49
+
50
+ Every response MUST start with \`${V} = ...\` on the first line. Forward references are allowed — declare the shell first (\`${V} = AppShell(...)\` for apps, \`${V} = Column(...)\` or \`${V} = Container(...)\` for pages, \`${V} = MyApp()\` when you wrap a user component) and let children stream in below it.`}function Lm(){return`## Core syntax
51
+
52
+ A program is a flat list of \`name = expression\` statements, one per line. Newlines terminate statements; semicolons are optional.
118
53
 
119
54
  \`\`\`
120
- Button("Save", variant: "primary", loading: $isSaving) // canonical
121
- StatCard("Revenue", value: "$48k", trend: "up", delta: "+12%") // canonical
122
- Stack([Card1(), Card2()], direction: "row", gap: "md") // canonical
123
- Callout("info", title: "Heads up", description: "Action required", icon: "circle-info", compact: true)
55
+ ${V} = Column([header, kpis, table]) // root assignment (always first)
56
+ header = PageHeader("Sales", { subtitle: "Q4 2026" })
57
+ $count = 0 // reactive atom — '$' prefix is the contract
58
+ function Counter(label) { return Text(\`\${label}: \${$count}\`) } // component (returns a render tree)
59
+ function inc() { $count = $count + 1 } // action (no return — runs for side effects)
60
+ $effect(() => { $console.log($count) }, [$count]) // declarative side effect
124
61
  \`\`\`
125
62
 
126
- The component reference below tags the canonical positional with
127
- \`(positional)\`. For backwards-compatibility, additional positional
128
- arguments are still accepted in declaration order — but the named form is
129
- preferred because it survives prop renames and reorderings.
130
-
131
- ### Lambdas
132
- \`(arg) => expression\` for one-liners; \`(arg) => { … }\` for multi-statement
133
- bodies. A lambda body has the same imperative surface as an \`action\` body
134
- (assignments to \`$atoms\`, \`http(...)\`, \`emit\`, etc.).
63
+ ### Three name conventions
64
+ - \`name = value\` — plain binding (not reactive). Captured once.
65
+ - \`$name = value\` — reactive atom. Reading subscribes; writing notifies.
66
+ - \`function name(...)\` — declares a component AND an action with that name. The same declaration works in both render position (its return value renders) and event-handler position (its body runs). First-letter case is NOT significant: \`function Card(...)\`, \`function card(...)\`, \`function SaveOrder(...)\`, and \`function saveOrder(...)\` are all valid.
135
67
 
136
- ### Forward references
137
- Statements may **reference names defined later in the program**. The parser
138
- resolves them once the full stream lands. This is what makes streaming work:
139
- emit the shell (\`${D} = Stack([hero, body])\`) on the first line,
140
- then fill in \`hero\` and \`body\` later.`}function md(){return'## Reactive State\n\nAktion has **one reactive atom kind**. Every reactive cell is declared\nand read with the same surface:\n\n```\n$count = 0\n$user = { name: "Ada", role: "Engineer" }\n$todos = []\n$theme = "dark"\n```\n\n### Sigil contract\n- `count` (no sigil) is a plain binding — NOT tracked, NOT reactive.\n- `$count` (with sigil) is a tracked atom — reading subscribes the\n surrounding component / effect; writing notifies subscribers.\n\n### Assignment rules\n- **Render position** (top-level bindings, component body output, prop values):\n assignment is forbidden. Use `$name = …` declarations to seed.\n- **Inside `action` / `effect` / lambda bodies**: `= += -= *= /= ??= ++ --`\n are allowed against any `$name` atom.\n- **Nested writes require whole-object replacement.** Direct\n `$user.name = "Alex"` is rejected — spread instead:\n `$user = { ...$user, name: "Alex" }`. Arrays follow the same rule:\n `$todos = [...$todos, item]`, `$todos = @Filter($todos, "id", "!=", id)`.\n\n### Component-scoped state\nA `$name = value` declared **inside** a `component` body is per-instance.\nTwo `<Counter/>` siblings each have their own `count`. Top-level\n`$name` declarations live for the lifetime of the response.\n\n### Computed values\nJust compute — every reference to a `$` atom inside an expression auto-tracks:\n\n```\n$cart = []\n$total = @Sum($cart.price) // re-derives when $cart changes\n$open = @Filter($todos, "done", "==", false)\n```\n\n### URL-synced state\nURL state lives on the router, not as a separate tier:\n- `_route_.path` — current path (read-only).\n- `_route_.params.id` — path parameter; reactive.\n- `_route_.query.tab` — query string; **writable** (assigning updates the URL).\n- `_route_.navigate("/path")` — imperative navigation; only valid inside\n `action` / `effect` bodies.'}function gd(){return`## Components and lambdas
68
+ ### One hard rule — broken constantly, ALWAYS check
69
+ 1. **Always invoke components with parentheses.** A component is a function — to render it you MUST call it. The bare identifier \`MyApp\` is a *reference to the function*; the rendered element is \`MyApp()\`. Even with no arguments, write \`MyApp()\`. So \`${V} = MyApp\` is wrong — write \`${V} = MyApp()\`. Inside arrays the same applies: \`Column([Header(), Body(), Footer()])\`, never \`Column([Header, Body, Footer])\`. The only exception is passing a component as a callback (e.g. \`render: UserCard\`) where the caller invokes it.
141
70
 
142
- ### Component declarations
143
- \`\`\`
144
- component UserCard(user, tone: "default") {
145
- $hover = false
146
- return Card([
147
- Avatar(user.name, size: "md"),
148
- Text(user.name, variant: "large-heavy"),
149
- Text(user.role, tone: "muted"),
150
- Badge(tone, tone: tone)
151
- ])
152
- }
153
- \`\`\`
71
+ ### Reserved top-level names
72
+ - \`${V}\` — the UI root (REQUIRED, first line).
73
+ - \`theme\` — optional brand override (\`theme = $theme({...})\`).
74
+ - \`route\` — reactive router handle (\`route.path\`, \`route.params\`, \`route.navigate("/x")\`). NEVER declare \`route\` yourself.
154
75
 
155
- - Components **must** end with an explicit \`return <expression>\`.
156
- - Defaults use \`= expression\` (literal or computed in the component's scope).
157
- - \`children\` is the implicit named slot — the trailing positional argument
158
- at the call site is delivered as \`children\` inside the body.
159
- - Per-instance state: any \`$name = value\` declared inside the body is
160
- private to that instance.
76
+ ### Component-call shape — One positional argument max (TRAILING-OBJECT RULE)
77
+ Every call takes **at most one positional argument**; every other argument lives in a trailing \`{ }\` object literal:
161
78
 
162
- ### Call sites
163
79
  \`\`\`
164
- ${D} = Stack([
165
- UserCard($alice), // positional arg
166
- UserCard($bob, tone: "primary"), // named arg
167
- UserCard(user: $carol, tone: "warning") // both named
168
- ])
80
+ Button("Save", { variant: "primary", loading: $isSaving })
81
+ StatCard("Revenue", { value: "$48k", trend: "up", delta: "+12%" })
82
+ Row([Card1(), Card2()], { gap: "m" })
169
83
  \`\`\`
170
84
 
171
- ### Local helpers — lambda form
172
- Use a lambda binding for one-off helpers that don't need their own component:
173
- \`\`\`
174
- priorityTone = (p) => match p { "high": "danger" "med": "warning" default: "muted" }
175
- rowFor = (item) => Stack([Badge(item.label, tone: priorityTone(item.priority)), Text(item.title)])
176
- list = for item in $items { rowFor(item) }
177
- \`\`\``}function fd(){return'## Actions — callable side effects\n\nAn `action` is a callable block of imperative statements. Declare at the\ntop level (or inside a component body); invoke from any event-handler prop\n(`onClick`, `onChange`, `onSubmit`) or as an expression.\n\n```\naction save(item) {\n $items = [...$items, item]\n $save = http({ url: "/api/save", method: "POST", body: { item: item } })\n emit "saved" { id: item.id }\n}\n\nsubmitBtn = Button("Save", onClick: save)\n```\n\n### Body grammar\nInside an action body the imperative surface is small:\n- Assignments: `$x = newValue`, `$x += 1`, `$x = { ...$x, field: v }`.\n- `http({ ... })` — fire a request; the result is a reactive resource bag.\n- `emit "event-name" { detail }` — dispatch a `CustomEvent` on the host element.\n- `_route_.navigate("/path")` — programmatic navigation.\n- Statement-form `if` / `match` / `for` — same keywords as the expression\n forms (covered below).\n- `return` — optionally yields a value to the caller.\n- `js{ /* opaque JS */ }` — escape hatch for browser APIs not exposed\n natively (see § JS escape hatch).\n\n### Optional `return`\nActions MAY include a `return` statement. When omitted the action runs for\nits side effects and yields `undefined`. When present the result is\nobservable from `$x = myAction(...)` expressions:\n\n```\naction greet(name) {\n return "Hello, " + name\n}\n$hello = greet("Ada") // re-runs whenever the action call\'s args change\n```\n\n### Inline lambdas — the short form\nFor trivial handlers, skip the `action` declaration entirely:\n\n```\nincBtn = Button("+", onClick: () => $count = $count + 1)\nresetBtn = Button("Reset", onClick: () => { $count = 0 $message = "" })\ncopyBtn = Button("Copy", onClick: () => { js{ navigator.clipboard.writeText("hi") } })\n```'}function hd(){return`## Effects — Declarative side effects
85
+ \`Button("Save", "primary", true)\` is a schema error — write the named-prop form instead. Every call site also accepts \`{ key: ... }\` to pin per-instance state across reorders.`}function zm(){return'## JavaScript is fully supported\n\nAktion is a strict subset of JavaScript — every standard JS feature works inside expressions, action bodies, effect callbacks, and lambdas. Use whichever style is clearest for the value you need to compute.\n\n### In expressions (right-hand side of `=`)\nUse **value-producing** JS — no `if`/`switch`/`for` statements here.\n\n```\n// Ternary for branching\nbanner = $error ? Banner($error, { tone: "danger" }) : null\ntone = $value > 0 ? "success" : ($value < 0 ? "danger" : "muted")\n\n// .map / .filter / .reduce for iteration\nrows = $todos.map(t => TodoRow(t))\nvisible = $todos.filter(t => !t.done).map(t => TodoRow(t))\ntotal = $cart.reduce((sum, item) => sum + item.price, 0)\n\n// Object/array spread, destructuring, optional chaining, nullish coalescing\nmerged = { ...$base, status: "done" }\n[a, b] = $points\nname = $user?.profile?.name ?? "Guest"\n\n// Template literals — preferred over string concatenation\ntitle = `Found ${rows.length} ${$util.plural(rows.length, "result", "results")}`\n\n// Wrap a switch/match in a function and call it\nfunction panelFor(tab) {\n switch (tab) {\n case "overview": return Overview()\n case "billing": return Billing()\n default: return Empty()\n }\n}\npanel = panelFor($tab)\n```\n\n### In action / effect / lambda bodies\nThe full **statement** surface is available — `if`, `else`, `switch`, `for...of`, `for...in`, classic `for`, `while`, `do…while`, `break`, `continue`, `try`/`catch`/`finally`, `throw`, `return`. Plus all assignment operators (`= += -= *= /= ??= ++ --`) against `$atoms` and member chains rooted at one (`$user.name = "Alex"`).\n\n```\nfunction submit(payload) {\n if (!payload.email) return\n for (let tag of payload.tags) $tags = [...$tags, tag]\n switch (payload.kind) {\n case "draft": $drafts = [...$drafts, payload]; break\n default: $records = [...$records, payload]\n }\n $emit("submitted", { id: payload.id })\n}\n```\n\n### Timers — `setTimeout` / `setInterval`\n`setTimeout(fn, ms)`, `setInterval(fn, ms)`, `clearTimeout(id)`, and `clearInterval(id)` are available and behave like their JS counterparts. They return a handle you can later clear. Timers are tracked by the runtime and torn down automatically when the program re-plans, so they never outlive the program — but you should still clear a `setInterval` you no longer need. Create them inside an `effect` (not at the top level, which would re-create them on every render) and clear them in the effect\'s `cleanup`.\n\n```\n// Debounced search — restart a 300ms timer on every keystroke\nfunction onType(q) {\n clearTimeout($searchTimer)\n $searchTimer = setTimeout(() => { $results = $http({ url: `/search?q=${q}` }) }, 300)\n}\n\n// A ticking clock — start on mount, clear on unmount\n$effect(() => {\n let id = setInterval(() => { $now = $util.now() }, 1000)\n cleanup(() => clearInterval(id))\n}, ["mount"])\n```\n\nPrefer `$effect(..., ["every(1000)"])` for a simple repeating effect; reach for `setInterval`/`setTimeout` when you need an imperative handle to clear, a one-shot delay, or a debounce/restart.\n\n### Lambdas (arrow functions) — every JS form works\n`() => expr`, `x => expr`, `(x, y) => expr`, `(x = 0) => x`, `(...args) => sum(args)`, and the multi-statement `(x) => { ...; return ... }` form. Long lambdas may continue onto the next line.\n\n### Line continuations (matches JS ASI)\nAny expression operator (`.`, `?.`, `?`, `:`, `&&`, `||`, `??`, comparison, arithmetic) at the **start** of the next line keeps building the same expression.\n\n```\nfilteredTodos = $todos\n .filter(t => t.category == $filter)\n .filter(t => t.title.includes($searchQuery))\n```\n\n### Comments\nOnly `// line` and `/* block */` comments. No `#` shebangs.\n\n### Forbidden in expression position\n`if`, `switch`, `for`, `while`, `try` are statements — they cannot be assigned to a binding directly. Use a ternary, `.map`/`.filter`, or wrap them in a function.'}function Rm(){return`## Reactive State
178
86
 
179
- \`effect\` blocks attach side effects to a component or top-level binding.
180
- They are **anonymous** — there is no name, no \`on\` keyword. Every
181
- dependency lives inside a single bracketed list right after the keyword:
87
+ The \`$\` sigil is the only thing that makes a binding reactive. \`let\`/\`const\`/\`var\` keywords are optional and have no effect on reactivity.
182
88
 
183
89
  \`\`\`
184
- effect [ ...dependencies ] {
185
- // body
186
- }
90
+ $count = 0
91
+ $user = { name: "Ada", role: "Engineer" }
92
+ $todos = []
187
93
  \`\`\`
188
94
 
189
- A dependency entry is one of:
190
- - \`$atom\` — re-run when the named reactive atom changes.
191
- - \`on:mount\` — run once when the surrounding scope mounts.
192
- - \`on:unmount\` — run once when it unmounts.
193
- - \`on:every(N)\` — re-run every N milliseconds.
194
- - \`debounce(N)\` / \`throttle(N)\` — wrap the body with a trailing-edge rate limit.
95
+ ### Read & write
96
+ - Read \`$name\` anywhere — auto-subscribes whoever reads it (component, derived value, effect).
97
+ - Write \`$name = ...\` from event handlers, effect callbacks, and lambda bodies — i.e. in response to an event, never while building the UI. \`+=\`, \`-=\`, \`*=\`, \`/=\`, \`??=\`, \`++\`, \`--\` work too. Member writes (\`$user.name = "Alex"\`) rebuild the root immutably so subscribers see a fresh reference.
98
+ - **Never write \`$state\` in render position.** A \`$name = ...\` that runs while the UI is being built schedules a re-render that re-runs the write — an infinite loop. This bites when a \`function\` that *declares* state is invoked to render (\`aktion = app()\` where \`app\` does \`$user = {...}\`): a lowercase \`function\` called that way runs as an action, so the assignment is a per-render write. To hold component-local state, make it a **PascalCase component** (then top-of-body \`$count = 0\` is a set-once per-instance declaration) or use the \`$state\` hook — both seed once and persist. (The runtime defends against the loop — it applies the write but skips the re-render and warns — but the pattern is still wrong.)
195
99
 
196
- Dependencies may be combined freely (e.g.
197
- \`effect [$query, $page, debounce(250)] { … }\`). The order inside the
198
- brackets doesn't matter.
100
+ ### Fine-grained reactivity (path-level)
101
+ Subscriptions are tracked at the **path** you read, not the whole atom. Reading \`$user.name\` subscribes to \`user.name\` alone: a write to a sibling field (\`$user.role = ...\`) won't re-render or recompute it, while replacing the whole atom (\`$user = ...\`) or writing a descendant still does. The same rule drives computed values and effect deps (\`$effect(..., [$user.name])\` fires only on \`name\` changes). Reading a whole object (\`$user\`) or indexing into an array (\`$rows[i]\`, the \`$rows.field\` pluck) subscribes at that object/array — so prefer reading the exact field you need (\`$user.name\`) to get the tightest updates. No selectors or special syntax — just read the path.
199
102
 
200
- \`effect { ... }\` (no brackets) is equivalent to \`effect [on:mount] { ... }\` —
201
- both run the body once on mount.
103
+ A component re-executes only when **its own inputs change** — its args (props) or a \`$state\` path its body read — like \`React.memo\` / Solid, but automatic. So \`ShowName($user.name)\` and \`ShowAge($user.age)\` are independent: changing \`$user.age\` re-runs only \`ShowAge\`. Args are compared shallowly, so (as in React) a fresh inline lambda prop each render makes the child re-render — hoist the handler to a stable binding to skip it.
202
104
 
203
- ### Scope — top-level vs. component-local
204
- An effect can live at the program top level OR inside a
205
- \`component Name() { … }\` body. The syntax is identical; only the
206
- lifecycle differs:
207
-
208
- - **Top-level** — mounted once when the program parses, torn down on
209
- \`setResponse\` / \`clear()\`. Use for global concerns (analytics,
210
- app-wide shortcuts, hydration of shared atoms).
211
- - **Component-local** — mounted once per component instance on its
212
- first render, torn down when the instance disappears from the tree.
213
- Each instance gets its own timers, watched-atom subscriptions, and
214
- \`cleanup(fn)\` registrations. Use for per-instance work (per-row
215
- polling, modal focus management, observers attached to a widget).
105
+ ### Per-instance state
106
+ \`$name = value\` inside a function body is per-instance when the function is used as a component. Two \`Counter()\` siblings each hold their own \`$count\`. Add \`{ key: id }\` at the call site to keep state attached when siblings reorder.
216
107
 
217
- \`\`\`
218
- _app_ = App()
219
- $value = 10
108
+ ### Hooks — composable per-instance state
109
+ A function whose name starts with \`$\` is a **hook** (mirroring React's \`use*\` convention). Call hooks only at the top level of a component body (or another hook), in a stable order — never inside an \`if\`, loop, or callback. Hook state is per-instance and resets when the instance leaves the tree.
110
+
111
+ - \`$state(initial)\` → \`[value, setValue]\`, like React's \`useState\`. \`setValue(next)\` replaces the value; \`setValue(prev => next)\` derives it from the previous value. \`initial\` is evaluated once, on first render.
112
+ - \`$memo(() => compute, [deps])\` → a cached value, like React's \`useMemo\`. Recomputes only when a dependency changes (shallow \`Object.is\` compare); omit the deps array to recompute every render.
113
+ - \`function $name(...) { ... }\` declares a custom hook that composes the built-ins. Its \`$state\` / \`$memo\` calls attach to the component that called it.
220
114
 
221
- # Top-level — one shared interval for the whole program.
222
- effect [on:every(1000)] {
223
- $value = $value + 1
115
+ \`\`\`
116
+ function $useCounter(start) {
117
+ const [count, setCount] = $state(start)
118
+ return { count: count, increment: () => setCount(c => c + 1) }
224
119
  }
225
120
 
226
- component App() {
227
- return Box([Text("Value: " + $value)])
121
+ function Counter() {
122
+ const c = $useCounter(0)
123
+ const label = $memo(() => \`Count: \${c.count}\`, [c.count])
124
+ return Stack([Text(label), Button("+1", { onClick: c.increment })])
228
125
  }
126
+ ${V} = Counter()
229
127
  \`\`\`
230
128
 
129
+ Reach for \`$state(...)\` when a component owns local state with explicit setters; the bare \`$name = value\` per-instance form above is the lighter option when an atom is written directly by the component's actions. \`$state\` and \`$memo\` are reserved hook names.
130
+
131
+ ### Two-way binding (implicit)
132
+ Pass a \`$variable\` (or a member chain rooted at one — \`value: $form.email\`) as a value prop on any input/select/checkbox/switch/slider/picker and the runtime wires the change handler automatically. Add \`onChange: v => ...\` when you also need a side effect (debounced search, persistence, etc.).
133
+
231
134
  \`\`\`
232
- _app_ = App()
233
- $value = 10
234
-
235
- component App() {
236
- # Component-local — interval starts on first render and is cleared
237
- # automatically when the App instance leaves the tree.
238
- effect [on:every(1000)] {
239
- $value = $value + 1
240
- }
241
- return Box([Text("Value: " + $value)])
242
- }
135
+ $draft = ""
136
+ $theme = "light"
137
+
138
+ field = Input("draft", { value: $draft })
139
+ darkMode = Switch("dark", { value: $theme == "dark", onChange: on => $theme = on ? "dark" : "light" })
140
+ search = Input("query", { onChange: q => $results = $http({ url: \`https://api.example.com/search?q=\${q}\` }) })
243
141
  \`\`\`
244
142
 
245
- ### Examples
143
+ ### Computed values
144
+ There is no separate "computed" tier — just compute. Every \`$\` reference inside an expression auto-tracks.
246
145
 
247
146
  \`\`\`
248
- component LiveClock() {
249
- $now = @Now()
250
- effect [on:every(1000)] { $now = @Now() }
251
- return Text(@FormatDate($now, "time"))
252
- }
147
+ $open = $todos.filter((t) => !t.done)
148
+ $total = $util.sum($cart.price)
149
+ \`\`\`
253
150
 
254
- effect [$query, $page, debounce(250)] {
255
- $results = http({ url: "/api/search", query: { q: $query, page: $page } })
256
- }
151
+ ### Global stores — \`$store({...})\`
152
+ For app-wide state shared across many components (no prop drilling), declare a **store** at the top level. Non-function entries are reactive **state**; function entries are **methods** that receive the store handle \`s\` as their first argument. Read state as \`store.field\` (fine-grained — subscribes to that slice) and call methods as \`store.method(args)\`. Mutate inside a method with \`s.field = …\`. The handle is an app-global singleton with reference-stable methods.
257
153
 
258
- effect [$draft, debounce(500)] {
259
- $save = http({ url: "/api/draft", method: "PUT", body: $draft })
260
- }
154
+ \`\`\`
155
+ cart = $store({
156
+ items: [], // state
157
+ count: (s) => s.items.length, // getter-method → cart.count()
158
+ total: (s) => $util.sum(s.items.map(i => i.price)), // getter-method → cart.total()
159
+ add: (s, item) => { s.items = [...s.items, item] }, // action → cart.add(item)
160
+ clear: (s) => { s.items = [] },
161
+ })
261
162
 
262
- effect [on:mount] {
263
- js{
264
- const onKey = (e) => { if (e.key === "k" && e.metaKey) ctx.host.emit("toggle-palette", {}) }
265
- document.addEventListener("keydown", onKey)
266
- ctx.cleanup(() => document.removeEventListener("keydown", onKey))
267
- }
268
- }
163
+ function CartBadge() { return Badge(\`\${cart.count()} items\`) } // reads the store
164
+ function AddButton(item) { return Button("Add", { onClick: () => cart.add(item) }) } // calls a method
269
165
  \`\`\`
270
166
 
271
- ### Cleanup
272
- Use \`cleanup(fn)\` to register teardown for intervals, listeners, observers.
273
- Cleanup fires before the next re-run AND on unmount.`}function bd(){return`## Data — \`http({...})\`
167
+ Reads are fine-grained and per-component: changing \`cart.items\` re-renders only components that read \`items\`. Two-way binding works against a store field (\`Input(value: form.draft)\`). Use a \`Store\` for shared/global state; use a component's local \`$state\` / \`$name = …\` for state only one component owns.`}function Em(){return`## Components & Actions
168
+
169
+ A \`function\` declaration creates BOTH a component (callable in render position; its return value is rendered) and an action (callable from an event handler; its body runs for side effects). The first-letter case of the name is NOT significant — \`function Card(...)\`, \`function card(...)\`, \`function SaveOrder(...)\`, and \`function saveOrder(...)\` are all valid. A function with no \`return\` simply renders nothing when invoked in a render position. The same applies to arrow-function bindings (\`Display = () => Card(...)\` and \`display = () => Card(...)\` both work).
274
170
 
275
- There is exactly one HTTP primitive: the \`http({ ... })\` function. Pass any
276
- \`fetch\`-compatible option (\`url\`, \`method\`, \`headers\`, \`body\`,
277
- \`signal\`, \`credentials\`, …) plus a convenience \`query\` object that is
278
- serialised into the URL.
171
+ ### Components
172
+ A function used as a component returns a render tree. Parameters use standard JS defaults; destructured options are canonical. To render a component you MUST call it with parentheses — even when it takes no arguments. The bare identifier is just the function value.
279
173
 
280
- ### Reads (GET / HEAD / OPTIONS)
281
174
  \`\`\`
282
- $orders = http({
283
- url: "/api/users/" + $userId + "/orders",
284
- method: "GET",
285
- query: { limit: 5, status: "open" },
286
- headers:{ "X-Tenant": $tenant }
287
- })
175
+ // Both forms work — case is not significant
176
+ function UserCard(user) { return Card([Text(user.name)]) }
177
+ function userCard(user) { return Card([Text(user.name)]) }
178
+ Display = () => ["apple", "banana"].map(function (e) { return Button(e) })
179
+ ${V} = Column([UserCard($currentUser), userCard($otherUser), Display()])
288
180
  \`\`\`
289
181
 
290
- ### Writes (POST / PUT / PATCH / DELETE)
291
- Fire writes from inside an \`action\` body and observe the resulting resource:
292
182
  \`\`\`
293
- action saveOrder(payload) {
294
- $save = http({ url: "/api/orders", method: "POST", body: payload })
295
- emit "assistant-message" { message: "Saved." }
183
+ function UserCard(user, { tone = "default" } = {}) {
184
+ $hover = false
185
+ return Card([
186
+ Avatar(user.name, { size: "md" }),
187
+ Text(user.name, { variant: "large-heavy" }),
188
+ Text(user.role, { tone: "muted" }),
189
+ Badge(tone, { tone: tone })
190
+ ])
296
191
  }
297
192
  \`\`\`
298
193
 
299
- ### Reactive resource shape
300
- Every \`http({ ... })\` call returns a reactive bag with:
301
- \`\`\`
302
- $orders.data // parsed response body (null until resolved)
303
- $orders.error // null on success
304
- $orders.status // HTTP status code, e.g. 200
305
- $orders.loading // true while the request is in-flight
306
- $orders.headers // response headers as a plain object
307
- $orders.lastUpdated // ms-epoch of the last successful response
308
- $orders.refetch() // re-issue the request
309
- $orders.cancel() // abort the in-flight request (no-op when idle)
310
- \`\`\`
194
+ - \`children\` parameter is the implicit slot — the call site's positional argument is delivered into it.
195
+ - User-declared components shadow built-ins by name, so you can wrap library components with telemetry / per-app styling.
196
+ - Lambdas (\`row = item => Row(item)\`) are the right tool for one-off helpers that don't need their own component.
197
+ - A function that does not \`return\` anything simply renders nothing when called in a render position — the runtime treats the missing/undefined value as an empty fragment.
311
198
 
312
- ### \`Async(resource, …)\` wrapper
313
- The standard library component \`Async(resource, loading:, error:, empty:, data:)\`
314
- covers the loading / error / empty / data branches uniformly. Prefer it over
315
- hand-rolled \`if\` chains:
199
+ ### Actions
200
+ A \`function\` whose body runs for side effects (rather than returning a render tree) acts as an action. Use as event handler (\`onClick: save\`) or as a value-producing expression (\`$result = greet("Ada")\`). The first-letter case of the name does not matter — \`save\` and \`Save\` are both valid.
316
201
 
317
202
  \`\`\`
318
- view = Async($orders,
319
- loading: LoadingState("Loading orders…"),
320
- error: ErrorState("Couldn't fetch orders", description: "Try again in a moment."),
321
- empty: EmptyState("No orders yet", description: "Place your first order."),
322
- data: Table([Col("Item", $orders.data.title), Col("Total", $orders.data.total, format: "currency")])
323
- )
203
+ function save(item) {
204
+ $items = [...$items, item]
205
+ $save = $http({ url: "https://api.example.com/save", method: "POST", body: { item } })
206
+ $emit("saved", { id: item.id })
207
+ }
208
+
209
+ submitBtn = Button("Save", { onClick: save })
210
+ resetBtn = Button("Reset", { onClick: () => { $count = 0; $message = "" } }) // inline lambda
324
211
  \`\`\`
325
212
 
326
- ### Optional \`Http({ ... })\` defaults
327
- Configure host-wide defaults once at the top of the response:
213
+ \`return\` is optional. Inside the body, the full JS statement surface is available (see *JavaScript is fully supported*).
214
+
215
+ ### \`$emit("name", { detail })\`
216
+ Inside any action / effect / lambda, \`$emit("name", { detail })\` dispatches an outbound \`CustomEvent\` on the host \`<aktion-app>\` element. Reserved names: \`assistant-message\` (chat follow-up), \`error\`, \`route-change\`. Pick stable names; the host listens with \`el.addEventListener("name", ...)\`.`}function jm(){return`## Effects — Declarative side effects
217
+
218
+ \`$effect(() => { ... }, [...deps])\` runs declarative side effects. Dependency entries:
219
+
220
+ - \`$atom\` — re-run when this reactive atom changes.
221
+ - \`"mount"\` — run once when the surrounding scope mounts.
222
+ - \`"unmount"\` — run once when it unmounts.
223
+ - \`"every(N)"\` — re-run every N milliseconds.
224
+ - \`"debounce(N)"\` / \`"throttle(N)"\` — wrap the body with a trailing-edge rate limit.
225
+
226
+ \`$effect(() => { ... })\` (no second argument) is shorthand for \`["mount"]\`.
227
+
228
+ ### Scope — top-level vs. component-local
229
+ Top-level effects mount on parse, tear down on \`setResponse\` / \`clear()\`. Effects inside a component body mount per-instance and tear down when the instance leaves the tree (clearing intervals, watched-atom subscriptions, and \`cleanup(fn)\` registrations).
230
+
328
231
  \`\`\`
329
- $http = Http({
330
- baseUrl: "https://api.example.com",
331
- headers: { "Accept": "application/json" },
332
- timeout: 10000,
333
- retry: { count: 2, backoff: "exponential" }
334
- })
335
- \`\`\``}function vd(){return'## Control flow\n\nAll three control-flow keywords are **expressions** — they yield a node (or\narray of nodes) that can be assigned, passed as a prop, or returned from a\ncomponent / action body.\n\n### `if` / `else`\n```\nbanner = if $hasError { Banner("Something went wrong", tone: "danger") } else { null }\nactive = if $tab == "billing" { billingPanel } else { overviewPanel }\n```\nA trailing `else` is optional — without it an unmatched `if` evaluates to\n`null` (renders nothing).\n\n### `match`\n```\npanel = match $stage {\n "draft": DraftView()\n "review": ReviewView()\n "shipped": ShippedView()\n default: EmptyState("Pick a stage")\n}\n```\n- Arms use `: value` like object properties (the arrow form `->` is\n not valid).\n- `default:` is the wildcard.\n- Arms can return arbitrary expressions, not just strings.\n\n### `for`\n```\nrows = for item in $todos { TaskRow(item) }\nrowsWithIndex = for (item, idx) in $todos { TaskRow(item, index: idx) }\n```\n`for` produces an array of nodes — assign it and reference the binding\nfrom a container (`Stack(rows)`, `Table([Col("Task", rows)])`). The loop\nvariable is **block-scoped**, so a stale closure can never see the wrong row.\n\n### Statement form inside action / effect bodies\nThe same three keywords also work as statements:\n```\naction submit(payload) {\n if !payload.email { return }\n for tag in payload.tags { $tags = [...$tags, tag] }\n match payload.kind {\n "draft": { $drafts = [...$drafts, payload] }\n default: { $records = [...$records, payload] }\n }\n}\n```'}function yd(){return`## Routing — \`_router_({ … })\`
232
+ function LiveClock() {
233
+ $now = $util.now()
234
+ $effect(() => { $now = $util.now() }, ["every(1000)"])
235
+ return Text($util.formatDate($now, "time"))
236
+ }
336
237
 
337
- The router is a plain function call. It returns the matched arm's evaluated
338
- value — assign the result to any binding and reference that binding inside
339
- your shell.
238
+ // Debounced search — re-issue the request when inputs change
239
+ $effect(() => {
240
+ $results = $http({ url: "https://api.example.com/search", query: { q: $query, page: $page } })
241
+ }, [$query, $page, "debounce(250)"])
242
+
243
+ // Cleanup
244
+ $effect(() => {
245
+ const onKey = e => { if (e.key == "/") $palette = true }
246
+ document.addEventListener("keydown", onKey)
247
+ cleanup(() => document.removeEventListener("keydown", onKey))
248
+ }, ["mount"])
249
+ \`\`\``}function Dm(){return'## Data — `$http({...})`\n\n`$http({ ... })` is the only HTTP primitive. Every call is self-contained — pass a full absolute `url`, an optional `method` (`GET` is the default), a convenience `query` object serialised into the URL, `headers`, `body`, and any other `fetch`-compatible option. There are NO host-wide defaults.\n\n```\n$orders = $http({\n url: `https://api.example.com/users/${$userId}/orders`,\n method: "GET",\n query: { limit: 5, status: "open" }, // → ?limit=5&status=open\n headers:{ "X-Tenant": $tenant }\n})\n```\n\nThe request fires once when the binding mounts. To re-run it call `$orders.refetch()`, or wrap it in an `$effect(..., [$dep])` so it re-issues when a dependency changes.\n\n### Reactive resource shape\n```\n$orders.data // parsed body (null until resolved)\n$orders.error // null on success\n$orders.status // HTTP status code, e.g. 200\n$orders.loading // true while in-flight\n$orders.headers // response headers as a plain object\n$orders.lastUpdated // ms-epoch of last successful response\n$orders.refetch() // re-issue the request\n$orders.cancel() // abort the in-flight request\n$orders.onDone = fn // callback fired each time the request settles\n```\n\n### `onDone` — run something when the request settles\nAssign `onDone` after creating the resource. It fires once every time the request completes — the initial load and every `refetch()`, on both success and error — and receives the resource bag as its argument. It does NOT fire for a request that was superseded or `cancel()`led. This is the idiomatic way to refresh a list after a mutation:\n\n```\n$patch = $http({\n url: endpoint + "/" + todo.id,\n method: "PATCH",\n body: { isCompleted: !todo.isCompleted }\n})\n\n$patch.onDone = () => {\n $todos.refetch()\n}\n```\n\n### Writes — fire from an action\n```\nfunction saveOrder(payload) {\n $save = $http({ url: "https://api.example.com/orders", method: "POST", body: payload })\n $save.onDone = () => { $orders.refetch() }\n $emit("assistant-message", { message: "Saved." })\n}\n```\n\n`body` objects are JSON-encoded automatically (a `Content-Type: application/json` header is added unless you set one). After a write, call `.refetch()` on the list resource to refresh it — either directly or from the write resource\'s `onDone`.\n\n### `Async` wrapper — branch on resource state\n```\nview = Async($orders, {\n loading: LoadingState("Loading orders…"),\n error: ErrorState("Couldn\'t fetch orders"),\n empty: EmptyState("No orders yet"), // shown when data is null or an empty array\n data: Table([Col("Item", $orders.data.title), Col("Total", $orders.data.total, { format: "currency" })])\n})\n```'}function Bm(){return`## Routing
250
+
251
+ The router is a plain function call. Assign \`$router({ ... })\` to a binding and reference that binding from your shell.
340
252
 
341
253
  \`\`\`
342
- pages = _router_({
254
+ pages = $router({
343
255
  "/": Dashboard(),
344
256
  "/orders": OrdersPage(),
345
- "/orders/:id": OrderDetail(id: params.id),
346
- "/settings/*": SettingsArea(rest: params._),
257
+ "/orders/:id": OrderDetail({ id: params.id }),
258
+ "/settings/*": SettingsArea({ rest: params._ }),
347
259
  default: NotFound()
348
260
  })
349
261
 
350
- ${D} = AppShell(MainSidebar(), pages, TopBar())
262
+ ${V} = AppShell(MainSidebar(), pages, TopBar())
351
263
  \`\`\`
352
264
 
353
- ### Path patterns
354
- - Literal segments: \`"/"\`, \`"/about"\`, \`"/settings/profile"\`.
355
- - Parameter segments: \`"/users/:id"\`. Read inside the arm body with
356
- \`params.id\` (or \`_route_.params.id\` from elsewhere).
357
- - Trailing wildcard: \`"/docs/*"\`. Remainder lands in \`params._\`.
358
- - Default arm: \`default: NotFound()\` is the catch-all (synonym: \`"*"\`).
359
-
360
- ### Inside an arm body
361
- - \`params\` is bound to the matched route's path captures. It is scoped to
362
- the arm — the value is **not** available outside \`_router_({…})\`.
363
- - Use \`_route_\` for cross-cutting reactive reads (current path, query
364
- string) that don't depend on which arm matched.
365
-
366
- ### Reactive surface
367
- - \`_route_.path\` — current path (read-only).
368
- - \`_route_.params.id\` — path parameter; reactive.
369
- - \`_route_.query.tab\` — query string; **writable** (assigning updates the URL).
370
- - \`_route_.navigate("/path")\` — imperative navigation. Use inside any action
371
- or effect body.
372
-
373
- ### \`NavLink\` companion
374
- \`NavLink(label, to)\` reads \`_route_.path\` and dispatches
375
- \`_route_.navigate(to)\` on click — use for sidebars, navbars and breadcrumbs.
376
-
377
- ### Common mistakes
378
- - \`_route_\` is read-only (apart from \`_route_.navigate(...)\`). Assigning
379
- to \`_route_\` or to a state slot named \`route\` is ignored.
380
- - Forgetting the \`default:\` arm. Without it, unknown paths render \`null\`
381
- and the outlet collapses.
382
- - Using \`->\` instead of \`:\` for arm bodies. Inside \`_router_({…})\` the
383
- arms are ordinary object properties — separate with \`:\` and commas.`}function xd(){return'## Two-way binding — `bind:`\n\n`bind:value: $name` desugars to `value: $name, onValueChange: (v) => $name = v`.\nThe right-hand side must be a state ref (`$x`), member access\n(`$user.name`), or a form field — never a computed expression.\n\n```\n$search = ""\nbar = SearchBar("q", placeholder: "Search…", bind:value: $search)\nlist = for row in @Filter($rows, "title", "contains", $search) { ListItem(row.title) }\n\n$tags = []\nchips = TagInput("tags", bind:value: $tags)\n```\n\n`bind:` works on any form control whose spec declares a primary value prop:\n`Input`, `TextArea`, `Select`, `Combobox`, `MultiSelect`,\n`Checkbox`, `CheckBoxGroup`, `Switch`, `ToggleGroup`, `Slider`,\n`NumberInput`, `DatePicker`, `DateRangePicker`, `TimePicker`,\n`DateTimePicker`, `SearchBar`, `PinInput`, `PasswordInput`,\n`TagInput`, `MentionInput`, `MaskedInput`, `RichTextEditor`,\n`CodeEditor`, `ColorPicker`, `Rating` (when `interactive: true`),\n`Pagination` (binds `page`).'}function wd(){return'## JS escape hatch — `js{ … }`\n\n`js{ /* opaque JS body */ }` runs raw JavaScript inside an `effect`,\n`action`, or lambda body. Use sparingly — every other surface is preferred —\nbut it is always available for browser APIs not exposed natively (clipboard,\nkeyboard listeners, IntersectionObserver, audio, custom DOM work).\n\nThe body receives a single `ctx` bridge:\n- `ctx.host` — the `<aktion-app>` host element (for `dispatchEvent`).\n- `ctx.state` — `{ get(name), set(name, value) }` for reactive atoms.\n- `ctx.cleanup(fn)` — register teardown (same semantics as `effect` cleanup).\n- `ctx.tools` — host-registered endpoint catalog (rarely needed; prefer `http()`).\n- `ctx.args` — when invoked from an `action` or lambda, the call\'s arguments.\n\n```\neffect [on:mount] {\n js{\n const id = setInterval(() => ctx.state.set("now", Date.now()), 1000)\n ctx.cleanup(() => clearInterval(id))\n }\n}\n\naction copyShareLink() {\n js{ navigator.clipboard.writeText(window.location.href) }\n emit "assistant-message" { message: "Link copied" }\n}\n```'}function kd(){return`## Built-in \`@\`-functions
384
-
385
- All built-ins use the \`@\` prefix and may appear anywhere in an expression.
386
- They are **pure** — no side effects, no I/O. Use them for data shaping,
387
- formatting, and inline iteration.
388
-
389
- ${Wd(gt())}
390
-
391
- ### Control flow — expression form
392
- Use the expression-form \`if\` / \`match\` / \`for\` covered above —
393
- they return values that can be assigned, passed as props, or composed:
265
+ - Path patterns: literal \`"/about"\`, parameter \`"/users/:id"\` (read \`params.id\`), trailing wildcard \`"/docs/*"\` (read \`params._\`), \`default:\` for the catch-all.
266
+ - \`route\` handle (read-only): \`route.path\`, \`route.params.x\`, \`route.query.tab\`, \`route.pattern\`.
267
+ - \`route.navigate("/path")\` inside an action / effect changes the URL.
268
+ - \`NavLink(label, { to, exact?, icon? })\` and \`SidebarItem(label, { to, icon?, badge? })\` are router-aware anchors that auto-derive their active state from \`route.path\`.
394
269
 
395
- \`\`\`
396
- active = if $tab == "billing" { billingPanel } else { overviewPanel }
397
- list = for item in $todos { TaskRow(item) }
398
- panel = match $stage { "done": Done() "ready": Ready() default: Pending() }
399
- \`\`\`
270
+ NEVER declare a state slot named \`route\` yourself. Forget the \`default:\` arm and unknown paths render \`null\`.`}function Fm(){return'## Built-in globals — `storage` & `console`\n\nBoth are always in scope, lowercase. No imports.\n\n```\n// localStorage (default); \'$storage.local\' is its alias\n$storage.set("name", "John")\n$name = $storage.get("name")\n$storage.remove("name")\n\n// sessionStorage (per-tab)\n$storage.session.set("draft", $draft)\n\n// Cookies — options as an object literal\n$storage.cookies.set("user", "John", { expires: 7, path: "/", sameSite: "Lax" })\n$storage.cookies.remove("user", { path: "/" })\n\n// Console — forwards to host console\n$console.log("Hello", $user)\n$console.error("Failed", $error)\n```\n\nNon-string values JSON-roundtrip; missing keys return `null`. Cookie options: `expires` (days/Date/ISO), `maxAge` (seconds), `path`, `domain`, `secure`, `sameSite`. Failures (quota, disabled storage) are swallowed silently.\n\n### The full JavaScript global surface\nBeyond `storage` and `console`, **every** JavaScript global resolves by name — the standard library (`Math`, `JSON`, `Object`, `Date`, `Map`, …), browser dialogs (`alert`, `confirm`, `prompt`), and Web APIs (`fetch`, `URL`, `URLSearchParams`, `Blob`, `FormData`, `crypto`, `navigator`, `localStorage`, `atob`/`btoa`, `Intl`, `BigInt`, …), plus `window` / `document`.\n\n```\nfunction copyLink() {\n navigator.clipboard.writeText(window.location.href)\n $toast = "Link copied"\n}\nfunction remove(id) {\n if (confirm("Delete this item?")) { $items = $items.filter(x => x.id != id) }\n}\nid = crypto.randomUUID()\n```\n\nAuthor declarations and built-in components always win over a same-named global, so the passthrough only fills in names you haven\'t defined. Prefer the reactive `$http({...})` over raw `fetch` for data that drives the UI, and keep timers/listeners inside `$effect(...)` so they\'re cleaned up.'}function Om(){return'## Behaviour wrappers\n\nSix tiny wrappers attach behaviour or styling to ANY component without forcing every primitive to grow another prop. They render the child via `display: contents`, so the visual tree is unchanged — only the event / styling layer changes.\n\n```\n// Clickable card\nOnClick(Card([Text("View order")]), { onClick: () => route.navigate("/orders/4821") })\n\n// Lazy-load sentinel — fires once when scrolled into view\nOnIntersect(Skeleton({ variant: "card" }), { onEnter: $items.refetch, once: true })\n\n// Drop zone using HTML5 drag-and-drop\nOnMouse(Card([Text("Drop files here")]), {\n dragOver: e => e.preventDefault(),\n drop: e => { e.preventDefault(); $files = e.dataTransfer.files }\n})\n\n// Apply a class / inline style without breaking out of the component\nCss(Card([Text("Highlighted")]), { class: "highlight", style: "border-color: #f59e0b;" })\n\n// Router-aware anchor wrapping any node\nLink(PersonChip("Ada Lovelace"), { to: "/people/ada" })\n```\n\n- `OnClick(child, { onClick, disabled?, stopPropagation? })` — touch + mouse + keyboard (Enter/Space) activatable.\n- `OnMouse(child, { enter?, leave?, hover?, move?, down?, up?, click?, doubleClick?, contextMenu?, scroll?, wheel?, drag?, drop?, dragStart?, dragEnd?, dragEnter?, dragLeave?, dragOver?, draggable?, passiveScroll? })` — pass only the events you need.\n- `OnKeyboard(child, { onKeyDown?, onKeyUp?, onKeyPress?, focusable? })`.\n- `OnFocus(child, { onFocus?, onBlur? })` — uses bubbling `focusin`/`focusout`.\n- `OnIntersect(child, { onEnter?, onLeave?, onChange?, threshold?, rootMargin?, once? })` — IntersectionObserver wrapper.\n- `Css(child, { style?, class? })` — last-resort raw CSS class/style merge.\n- `Link(child_or_label, { to?, href?, external?, variant? })` — anchor primitive; `to` for router nav, `href`+`external: true` for outbound links.\n\nDon\'t wrap a `Button` in `OnClick` — `Button` already exposes `onClick`. Use `OnClick` for clickable cards / list rows / custom layouts.'}function _m(){return`## Escape hatches — \`HTMLTag\` & \`Styles\`
400
271
 
401
- ### Responsive prop maps
402
- \`Grid(items, columns: {sm: 1, md: 2, lg: 4}, gap: "l")\` — 1 column on mobile,
403
- 2 on tablet, 4 on desktop. \`Stack(children, direction: {sm: "column", md: "row"})\`
404
- — stack on mobile, row on desktop. Both \`columns\` and \`gap\` accept either
405
- a single value or a responsive map.`}function Sd(){return'## Standard helper components\n\nAktion keeps the language core small by exposing "frameworky"\nfeatures as library components rather than language keywords:\n\n| Component | Purpose |\n|---|---|\n| `Async(resource, loading:, error:, empty:, data:)` | Branch on an `http({...})` resource\'s state. |\n| `Show(when, fallback?, children)` | Sugar over `if when { children } else { fallback }`. |\n| `Portal(children, target?)` | Render children outside the parent subtree. |\n| `Redirect(path)` | Navigate to `path` and unmount the rest of the subtree. |\n| `Lazy(loader, fallback?, children)` | Defer rendering children until `loader` resolves. |\n| `ErrorBoundary(children, fallback?, onError?)` | Catch render errors thrown by descendants. |\n| `VirtualList(items, key:, render:)` | Virtualised list — preferred for >100 rows. |'}function Cd(){return`## Built-in globals
272
+ Use only when the standard catalogue cannot express the markup or styling you need.
406
273
 
407
- Two namespace globals are always in scope — no import, no declaration.
408
- Invoke them through the standard \`obj.method(args)\` syntax. Named-arg
409
- options collapse into a single trailing options object on the method's
410
- arg list (same rule as component named args).
274
+ - \`HTMLTag(tag, { attributes?, children? })\` — render an allow-listed HTML tag. \`on*\` attributes, \`javascript:\` URLs, and unsafe \`style\` patterns are stripped; tag names outside the allow-list collapse to \`div\`.
275
+ - \`Styles(css)\` — inject a \`<style>\` block. Payloads containing \`</style>\`, \`<script>\`, \`expression(\`, \`javascript:\`, \`behavior:\`, or \`@import\` are dropped.
411
276
 
412
- \`storage\` — browser storage (localStorage by default):
413
277
  \`\`\`
414
- storage.set("name", "John") // alias of storage.local.set
415
- $name = storage.get("name")
416
- storage.remove("name")
417
- storage.clear()
418
-
419
- storage.session.set("draft", $draft) // per-tab sessionStorage
420
- $draft = storage.session.get("draft")
421
-
422
- storage.cookies.set("user", "John", expires: 7, path: "/", sameSite: "Lax")
423
- $user = storage.cookies.get("user")
424
- storage.cookies.remove("user", path: "/")
425
- storage.cookies.clear()
426
- \`\`\`
427
- - Values that aren't strings round-trip through JSON; missing keys return \`null\`.
428
- - Cookie options: \`expires\` (days, Date, or ISO string), \`maxAge\`
429
- (seconds), \`path\`, \`domain\`, \`secure\`, \`sameSite\`.
430
-
431
- \`console\` — host console forwarder:
432
- \`\`\`
433
- console.log("Hello", $user)
434
- console.error("Failed", $error)
435
- console.warn("Deprecated path")
436
- console.info("Route changed", _route_.path)
437
- console.debug({ days: $days, count: $count })
438
- \`\`\``}function Td(){return'## Internationalisation\n\n```\n$locale = "en"\n$bundle = http({ url: "/i18n/" + $locale + ".json", method: "GET" })\n$i18n = i18n({\n locale: $locale,\n messages: $bundle.data ?? {},\n fallback: "en"\n})\n\nText(t("orders.title")) // "Orders"\nText(t("orders.greeting", { name: $userName })) // "Welcome back, Alex"\n```\n\n- `t(key, vars?)` looks up the translation by dot-pathed key with\n `${name}` interpolation.\n- `Locale()` returns the active locale tag.\n- Formatting builtins (`@Format`, `@FormatDate`) consult `Locale()`\n automatically.'}function $d(){return`## In-script theming
278
+ ${V} = Column([
279
+ Styles(\`.hero-callout { background: linear-gradient(135deg, #6366f1, #10b981); color: white; padding: 24px; border-radius: 12px; }\`),
280
+ HTMLTag("div", { attributes: { class: "hero-callout" }, children: [
281
+ HTMLTag("h2", { children: [Text("Custom block")] }),
282
+ Text("Use these only when the standard library cannot capture the design.")
283
+ ]})
284
+ ])
285
+ \`\`\``}function Um(){return`## Theming, i18n & icons
439
286
 
440
- Assign a \`Theme({ … })\` call to a top-level binding named \`theme\` (the
441
- runtime looks for that exact name) **before** defining \`${D}\`. The
442
- runtime writes the theme tokens to the host element as CSS custom properties.
287
+ ### \`theme = $theme({ ... })\`
288
+ Assign before \`${V}\` to brand the response. Tokens use the structured form — top-level groups \`colors\`, \`radius\`, \`font\`, \`motion\`, \`elevation\` (plus metadata: \`name\`, \`direction\`). Removing the line snaps the UI back to the host theme.
443
289
 
444
290
  \`\`\`
445
- theme = Theme({
446
- colors: {
447
- primary: "#635bff",
448
- bg: "#0a0a23",
449
- surface: "#10103a",
450
- text: "#ffffff"
451
- },
291
+ theme = $theme({
292
+ colors: { primary: "#635bff", bg: "#0a0a23", surface: "#10103a", text: "#fff" },
452
293
  radius: { md: "0.5rem", button: "999px" },
453
294
  font: { family: "Inter, sans-serif", familyHeading: "Inter, sans-serif" }
454
295
  })
455
- ${D} = AppShell(...)
456
296
  \`\`\`
457
297
 
458
- Top-level token groups: \`colors\`, \`radius\`, \`font\`, \`motion\`,
459
- \`elevation\`. Unknown keys inside a group are silently ignored, so typos
460
- fail silent — verify token names against the \`Themes\` reference.`}function Nd(){return'## Icons (Font Awesome)\n\nIcon-typed props accept a Font Awesome name as a string. The host element\nauto-loads the Font Awesome stylesheet — no setup needed.\n\n- Format: `"name"` (defaults to the solid set), e.g. `"house"`,\n `"chart-line"`, `"star"`, `"circle-check"`.\n- Variants: prefix with `"regular:name"` (outline set) or `"brands:name"`\n (brand logos).\n- **Never emit emoji characters in `icon` props.**\n- Use the `Icon(name, variant?, size?)` component to render an icon inline\n anywhere a Node is expected.'}function Ad(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(s=>s.name)}],r=new Map(t.components.map(s=>[s.name,s])),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 is best supplied as a named argument (`prop: value`)."),a.push("");for(const s of e){a.push(`### ${s.name}`);for(const l of s.components){const c=r.get(l);c&&a.push(ft(c))}if(s.notes&&s.notes.length>0){a.push("");for(const l of s.notes)a.push(l)}a.push("")}const i=new Set(e.flatMap(s=>s.components)),n=t.components.filter(s=>!i.has(s.name));if(n.length>0){a.push("### Other");for(const s of n)a.push(ft(s))}return a.join(`
461
- `).trim()}function Md(){return`## Inline mode
462
-
463
- You may answer questions in plain text when appropriate. When you do, wrap
464
- any UI you produce in a fenced \`\`\`aktion block. Otherwise
465
- output Aktion directly with no surrounding prose.`}function Pd(){return`## Edit mode
466
-
467
- When the user asks for an incremental change to a prior response, output
468
- ONLY the statements that need to change (additions, replacements, removals).
469
- Do NOT re-emit the whole UI. To remove a statement, write \`name = null\`.`}function Id(){return`## Hoisting & streaming (CRITICAL)
470
-
471
- Aktion supports hoisting: a reference can be used BEFORE it is
472
- defined. The renderer re-parses the program on every streamed chunk and
473
- silently treats unresolved references as empty, so a partially-streamed
474
- response renders progressively without flashing errors.
475
-
476
- **Required statement order for streaming-friendly output:**
477
- 1. \`${D} = ...\` — emit this FIRST so the UI shell appears immediately.
478
- 2. \`component\` / \`action\` / \`effect\` declarations — fill in layout & behaviour.
479
- 3. Leaf data values — strings, numbers, arrays, objects — last.
480
-
481
- **Streaming rules — follow strictly:**
482
- - Always reference children by name from the root (\`${D} = Stack([hero, body, footer])\`).
483
- - Define one reference per FormControl, TabItem, AccordionItem, Series, Col —
484
- so each one streams in independently.
485
- - Place large data values on their own trailing lines.
486
- - Never split a single statement across multiple lines unless it sits inside
487
- an unmatched bracket (\`[\`, \`(\`, \`{\`).
488
- - Do not introduce trailing commas, dangling operators, or open brackets you
489
- don't close on the same line.`}function zd(){return`## Output rules
490
-
491
- - **Build a complete application.** Reply with a substantive, navigable
492
- product surface — page headers, sidebars, multiple pages, data views,
493
- KPIs, toolbars, working actions. Never reply with a single Card or a
494
- chat-style bubble.
495
- - Output ONLY Aktion (or a fenced \`\`\`aktion
496
- block when inline mode is enabled).
497
- - Always start with \`${D} = ...\` on the very first line.
498
- - Prefer many small, named statements over deeply nested inline expressions —
499
- this is what makes streaming work.
500
- - Order statements top-down: \`${D}\` first, then components /
501
- actions / effects, then leaf data.
502
- - **Seed realistic mock data inline.** When no backend is available, write
503
- 5–20 believable rows per dataset (real names, dates, numbers, statuses)
504
- inside \`$state\` declarations. Pages read from these atoms so changes
505
- propagate live.
506
- - **Wire every visible button.** Declare \`action Name() { … }\` blocks and
507
- reference them via \`Button("Label", onClick: name)\`. No dead buttons —
508
- forms submit by dispatching an action that writes to \`$state\`.
509
- - **Use \`_router_({...})\` for multi-page apps.** Declare \`pages = _router_({ "/": Home(), … })\` once,
510
- reference \`pages\` from \`${D}\`, link routes from the sidebar /
511
- navbar with \`NavLink(label, to)\`. Each route must be a substantive
512
- page (PageHeader + at least one data view + at least one action).
513
- - **Match real-product polish.** Use \`Stats\`, \`PageHeader\`, \`Toolbar\`,
514
- \`Badge\` / \`StatusDot\` for state, \`PersonChip\` / \`Avatar\` where
515
- people appear, \`EmptyState\` for empty lists. Pair text-heavy sections
516
- with plausible \`Image\` URLs.
517
- - **Use responsive prop maps** (\`{sm: 1, md: 2, lg: 4}\`) for \`Grid\` and
518
- \`Stack\` so the app works on phone AND desktop.
519
- - **Use template literals** for any string mixing copy with values:
520
- \`\`\`\${@Count(rows)} \${@Plural(@Count(rows), "order", "orders")}\`\`\`
521
- reads much better than \`+\` concatenation.
522
- - Icons are Font Awesome names without the \`fa-\` prefix — never emoji.
523
- - Do not invent component names that are not in the library above.
524
- - Use expression-form \`if\` / \`match\` / \`for\` for control flow.
525
- - Use \`http({ ... })\` for every HTTP request; observe \`.data\`,
526
- \`.error\`, \`.loading\`, \`.status\`, \`.refetch()\`.
527
- - Never declare a state slot named \`route\` yourself. The router exposes
528
- its reactive surface through the reserved \`_route_\` handle — read
529
- \`_route_.path\` / \`_route_.params\` and call
530
- \`_route_.navigate("/path")\` to navigate.`}function Rd(){return`## Final verification
298
+ The host page picks one of seven base themes (\`light\`, \`dark\`, \`neon\`, \`pastel\`, \`glass\`, \`brutalist\`, \`skyline\`) via the \`theme\` attribute. Authored programs should be theme-neutral by default — pass \`tone:\` / \`variant:\` instead of hard-coded colours.
531
299
 
532
- Before finishing, walk your output and verify:
533
- 1. \`${D} = ...\` is the FIRST line.
300
+ ### i18n
301
+ \`\`\`
302
+ const { t, setCurrentLanguage, getCurrentLanguage } = $i18n({
303
+ defaultLanguage: "en",
304
+ currentLanguage: "fr",
305
+ translations: {
306
+ greeting: { en: "Hello, {name}!", fr: "Bonjour, {name}!" },
307
+ items_count: { en: "{count} items", fr: "{count} objets" }
308
+ }
309
+ })
310
+ welcome = Text(t("greeting", { name: $user.name }))
311
+ \`\`\`
312
+ \`t(key, vars?)\` looks up \`translations[key][currentLanguage]\`, falls back to \`translations[key][defaultLanguage]\`, then to the bare key. Placeholders use \`{name}\` syntax. Drive \`currentLanguage\` from a \`$state\` atom (e.g. \`currentLanguage: $lang\`) for reactive language switching, or call \`setCurrentLanguage(next)\` on the bundle.
313
+
314
+ ### Icons
315
+ Icon-typed props expect a Font Awesome name as a string — no \`fa-\` prefix, NEVER an emoji character.
316
+
317
+ - \`"name"\` defaults to the solid set: \`"house"\`, \`"chart-line"\`, \`"star"\`.
318
+ - \`"regular:name"\` for the outline set; \`"brands:name"\` for brand logos.
319
+ - \`Icon(name, { variant?, size? })\` renders a standalone glyph (\`size\` ∈ \`xs|sm|md|lg|xl\`).`}function Hm(){return'## `$util` — runtime helper namespace\n\nPure helpers — no side effects. `$util` is a global available inside every Aktion expression, action body, effect, and lambda. Library consumers can call the same methods from JavaScript (`import { Util } from "aktion"`).\n\nReach for `$util` when native JavaScript would be verbose (formatting, date math, grouping). Prefer plain JS where it is just as clear: `arr.length` over `$util.count(arr)`, `a.filter(x => x.done)` over `$util.filter(a, "done", "==", true)`.\n\n### Collections\n- `$util.count(arr)` — length / object key count.\n- `$util.sum(arr)` / `$util.avg(arr)` / `$util.min(arr)` / `$util.max(arr)` — numeric reductions.\n- `$util.first(arr)` / `$util.last(arr)` — endpoints (safe on empty arrays).\n- `$util.filter(arr, field, op, value)` — declarative filter (`op` ∈ `==`, `!=`, `<`, `<=`, `>`, `>=`, `contains`, `startsWith`, `endsWith`).\n- `$util.find(arr, field, op, value)` — first match.\n- `$util.sort(arr, field, dir?)` — stable sort (`dir` ∈ `"asc"` | `"desc"`).\n- `$util.groupBy(arr, field)` — `{ [key]: items[] }`.\n- `$util.unique(arr, field?)` / `$util.reverse(arr)` / `$util.slice(arr, start, end?)` / `$util.pick(obj, ["a", "b"])`.\n- `$util.range(start, end, step?)` — inclusive numeric range.\n- `$util.repeat(value, count)` — fixed-length array.\n- `$util.join(arr, sep?)` — string join.\n\n### Strings\n- `$util.capitalize(s)` / `$util.lowercase(s)` / `$util.uppercase(s)` / `$util.titlecase(s)` / `$util.case(s, mode)`.\n- `$util.split / .trim / .replace / .substring / .startsWith / .endsWith / .contains / .match`.\n- `$util.plural(n, singular, plural)` — picks the right word for a count.\n\n### Formatting\n- `$util.format(value, mode, opts?)` — numbers, currency, percent, compact (`{ currency, locale, decimals }`).\n- `$util.formatDate(value, mode, opts?)` — `"short"` | `"long"` | `"time"` | `"relative"` | token strings (`"YYYY-MM-DD"`).\n\n### Dates\n- `$util.now()` / `$util.today()` / `$util.addDays(date, n)` / `$util.addHours(date, n)` / `$util.diffDays(a, b)` / `$util.startOfWeek(date)` / `$util.endOfMonth(date)`.\n\n### Math\n- `$util.round / .floor / .ceil / .abs / .clamp(v, min, max) / .pow / .sqrt / .random / .log`.\n\nThe namespace is open for extension — new helpers may be added over time.\n\n```\nfiltered = $users.filter((u) => u.team === $team)\nsorted = $util.sort(filtered, "joinedAt", "desc")\nfirstFive = sorted.slice(0, 5)\nsummary = `${rows.length} ${$util.plural(rows.length, "order", "orders")}: ${$util.format($util.sum(rows.amount), "currency")}`\n```'}function Vm(){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 `loader` resolves. |\n| `ErrorBoundary(children, { fallback?, onError? })` | Catch render errors thrown by descendants. |\n| `VirtualList(items, { key, render })` | Virtualised list — preferred for >100 rows. |"}function Wm(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 u=r.get(s);u&&a.push(Ut(u))}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(Ut(o))}return a.join(`
320
+ `).trim()}function qm(){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 Gm(){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 Km(){return`## Streaming, output rules & verification
321
+
322
+ ### Hoisting & streaming (CRITICAL)
323
+ References resolve from the entire top-level scope, not source order. Emit the shell first so the renderer has somewhere to attach streamed leaves. Required statement order:
324
+
325
+ 1. \`${V} = ...\` — first line, always.
326
+ 2. Function declarations (components & actions) and \`$effect(...)\` calls.
327
+ 3. Leaf data values (strings, numbers, arrays, objects) — last.
328
+
329
+ Define one named reference per FormControl, TabItem, AccordionItem, Series, Col, etc. so each one streams independently. Never split a single statement across multiple lines unless it sits inside an unmatched \`[\`, \`(\`, or \`{\`.
330
+
331
+ ### Output rules
332
+ - Output ONLY Aktion (or a fenced \`\`\`aktion\`\`\` block when inline mode is enabled).
333
+ - Build a complete, navigable surface — \`PageHeader\`, multi-section layouts, working buttons. Don't reply with a single Card.
334
+ - Wire every visible button. Declare \`function name() { ... }\` blocks (any case for the name); reference via \`Button("Label", { onClick: name })\`.
335
+ - Use \`$router({...})\` for multi-page apps; reach \`pages\` from \`${V}\`; link from sidebar/navbar with \`NavLink\`/\`SidebarItem\` (\`to: "/path"\`).
336
+ - Seed realistic mock data inline when no backend is available (5–20 plausible rows).
337
+ - Lay out with three primitives: \`Column([...])\` (vertical, the usual page/section), \`Row([...])\` (horizontal toolbars/rows), and \`Grid([...], { columns })\` (equal columns / card walls). \`Center([...], { minHeight })\` centers content. Use responsive prop maps (\`{ base: 1, md: 2, lg: 4 }\`) on \`Grid\` columns or \`Stack\` direction so the app works on phone and desktop.
338
+ - Use template literals for any string mixing copy with values.
339
+ - Tables are column-oriented: \`Table([Col("Label", arr1), Col("Count", arr2, { format: "number" })])\`. A column cell can be any component — the simplest form just maps each row to a component: \`Col("Status", rows.map(r => Badge(r.status)))\`, \`Col("Actions", rows.map(r => Button("Edit", { onClick: () => edit(r.id) })))\`. You can also keep \`values\` as the raw rows and pass \`render: (value, index) => Component\`. Make a column clickable with \`onClick: (value, index) => …\`. Both work in \`Table\` and \`DataGrid\`.
340
+ - Charts need numeric arrays. Use array pluck: \`PieChart(rows.label, rows.value)\`.
341
+ - Icons are Font Awesome names (no \`fa-\` prefix, no emoji).
342
+ - Named arguments use a trailing \`{ prop: value }\` object — never bare \`prop: value\` in a call.
343
+
344
+ ### Final verification
345
+ Before finishing, walk your output and check:
346
+ 1. \`${V} = ...\` is the FIRST line.
534
347
  2. Every referenced name is defined somewhere below.
535
- 3. Every defined name (other than \`${D}\`, \`theme\`, \`$http\`,
536
- \`$i18n\`) is reachable from \`${D}\`.
537
- 4. Containers reference their children by name; large data arrays live on
538
- their own trailing lines.
539
- 5. No statement is split across multiple lines unless it sits inside an
540
- unmatched \`[\`, \`(\`, or \`{\`.
541
- 6. Components end with an explicit \`return\` statement.
348
+ 3. Every defined name (other than \`${V}\`, \`theme\`) is reachable from \`${V}\`.
349
+ 4. **Function name case is NOT significant.** \`function Card(...)\` and \`function card(...)\` both declare a component-and-action; the same applies to arrow bindings.
350
+ 5. **Every component reference is invoked with parentheses.** Scan for bare component identifiers used as values (root assignment, array elements, prop values) — wrap each in \`()\`. \`${V} = MyApp\` → \`${V} = MyApp()\`; \`Column([Hero, Body])\` → \`Column([Hero(), Body()])\`. The only exception is passing a component as a callback (e.g. \`render: UserCard\`) where the caller invokes it.
351
+ 6. A function with no \`return\` simply renders nothing when called in a render position.
542
352
  7. State uses the single-sigil \`$name = value\` form.
543
- 8. HTTP uses \`http({ url, method, ... })\`; the reactive bag exposes
544
- \`.data\` / \`.error\` / \`.loading\` / \`.status\` / \`.refetch()\` / \`.cancel()\`.
545
- 9. Router and \`match\` arms use \`:\` (not \`->\`) and \`default\` (not
546
- \`_\`) as the wildcard.`}function Ld(){return[`# Tasks dashboard backed by http()
547
- $tasks = http({ url: "/api/tasks", method: "GET" })
548
-
549
- action toggle(task) {
550
- $update = http({
551
- url: "/api/tasks/" + task.id,
552
- method: "PATCH",
553
- body: { done: !task.done }
554
- })
353
+ 8. \`$http({...})\` uses an absolute \`url\` and exposes \`.data\`, \`.error\`, \`.loading\`, \`.status\`, \`.refetch()\`, \`.cancel()\`.
354
+ 9. \`$router({...})\` arms use \`:\` (not \`->\`) and \`default\` (not \`_\`) for the wildcard.
355
+ 10. Effects use \`$effect(() => {...}, [deps])\` — never the legacy bracket form.
356
+ 11. \`storage\` / \`console\` are lowercase; \`route\` is reserved (never declare it).`}function Ym(){return[`// Tasks dashboard — $http(), Async, action, multi-section layout
357
+ $tasks = $http({ url: "https://api.example.com/tasks", method: "GET" })
358
+
359
+ function toggle(task) {
360
+ $update = $http({ url: \`https://api.example.com/tasks/\${task.id}\`, method: "PATCH", body: { done: !task.done } })
555
361
  $tasks.refetch()
556
362
  }
557
363
 
558
- action removeTask(task) {
559
- $delete = http({ url: "/api/tasks/" + task.id, method: "DELETE" })
560
- $tasks.refetch()
561
- }
364
+ renderRow = task => Card([Row([
365
+ Badge(task.done ? "done" : "open", { tone: task.done ? "success" : "neutral" }),
366
+ StackItem(Text(task.title, { tone: task.done ? "muted" : "default" }), { grow: 1 }),
367
+ Buttons([Button(task.done ? "Reopen" : "Done", { onClick: () => toggle(task), variant: "primary", size: "sm" })])
368
+ ], { gap: "m" })])
562
369
 
563
- renderRow = (task) => Card([Stack([
564
- Badge(task.done ? "done" : "open", tone: task.done ? "success" : "neutral"),
565
- Text(task.title, tone: task.done ? "muted" : "default"),
566
- Buttons([
567
- Button(task.done ? "Reopen" : "Done", onClick: () => toggle(task), variant: "primary", size: "sm"),
568
- Button("Delete", onClick: () => removeTask(task), variant: "ghost", size: "sm")
569
- ])
570
- ])])
571
-
572
- component TasksPage() {
573
- return Stack([
574
- PageHeader("Tasks", subtitle: \`\${@Count($tasks.data)} items\`, actions: [Button("Refresh", onClick: $tasks.refetch, variant: "ghost")]),
575
- Async($tasks,
576
- loading: LoadingState("Loading tasks…"),
577
- error: ErrorState("We couldn't fetch tasks", description: "Try again in a moment.", action: Button("Retry", onClick: $tasks.refetch, variant: "primary")),
578
- empty: EmptyState("No tasks yet", description: "Create your first task to get started.", icon: "list-check"),
579
- data: Stack(for t in $tasks.data { renderRow(t) }, direction: "column", gap: "s")
580
- )
581
- ], direction: "column", gap: "l")
582
- }
583
-
584
- ${D} = TasksPage()`,`# App shell with router
585
- action selectNav(label, path) { _route_.navigate(path) }
586
-
587
- pages = _router_({
588
- "/": Overview(),
589
- "/projects": Projects(),
590
- "/calendar": Calendar(),
591
- default: NotFound()
370
+ ${V} = Column([
371
+ PageHeader("Tasks", { subtitle: \`\${$tasks.data.length} items\`, actions: [Button("Refresh", { onClick: $tasks.refetch, variant: "ghost" })] }),
372
+ Async($tasks, {
373
+ loading: LoadingState("Loading tasks…"),
374
+ error: ErrorState("Couldn't fetch tasks", { description: "Try again in a moment." }),
375
+ empty: EmptyState("No tasks yet", { description: "Create your first task." }),
376
+ data: Column($tasks.data.map(t => renderRow(t)), { gap: "s" })
377
+ })
378
+ ], { gap: "l" })`,`// Multi-page app shell with router and sidebar
379
+ pages = $router({
380
+ "/": Overview(),
381
+ "/projects": Projects(),
382
+ "/calendar": Calendar(),
383
+ default: NotFound()
592
384
  })
593
385
 
594
- renderNav = (label, icon, path) => SidebarItem(label, icon: icon, active: _route_.path == path, action: () => selectNav(label, path))
595
-
596
- nav = Sidebar([
597
- SidebarSection("Workspace", [
598
- renderNav("Overview", "house", "/"),
599
- renderNav("Projects", "folder", "/projects"),
600
- renderNav("Calendar", "calendar", "/calendar")
601
- ])
602
- ])
386
+ nav = Sidebar([SidebarSection("Workspace", [
387
+ SidebarItem("Overview", { icon: "house", to: "/" }),
388
+ SidebarItem("Projects", { icon: "folder", to: "/projects" }),
389
+ SidebarItem("Calendar", { icon: "calendar", to: "/calendar" })
390
+ ])])
603
391
 
604
- ${D} = AppShell(nav, pages)
392
+ ${V} = AppShell(nav, pages)
605
393
 
606
- component Overview() {
607
- return Stack([
608
- PageHeader("Overview", subtitle: "Everything happening across your workspace"),
394
+ function Overview() {
395
+ return Column([
396
+ PageHeader("Overview", { subtitle: "Everything across your workspace" }),
609
397
  Stats([
610
- StatCard("MRR", value: "$48.2k", trend: "up", delta: "+12% vs last month", icon: "sack-dollar"),
611
- StatCard("Active users", value: "2,184", trend: "up", delta: "+184", icon: "users"),
612
- StatCard("Open tickets", value: "23", trend: "down", delta: "-9", icon: "ticket")
398
+ StatCard("MRR", { value: "$48.2k", trend: "up", delta: "+12%", icon: "sack-dollar" }),
399
+ StatCard("Active users", { value: "2,184", trend: "up", delta: "+184", icon: "users" }),
400
+ StatCard("Open tickets", { value: "23", trend: "down", delta: "-9", icon: "ticket" })
613
401
  ])
614
- ], direction: "column", gap: "l")
615
- }
616
-
617
- component Projects() { return Stack([PageHeader("Projects")], direction: "column", gap: "l") }
618
- component Calendar() { return Stack([PageHeader("Calendar")], direction: "column", gap: "l") }
619
- component NotFound() { return Stack([PageHeader("Not found")], direction: "column", gap: "l") }`,`# Contact form with two-way binding and validation
620
- $name = ""
621
- $email = ""
622
- $message = ""
623
- $sent = false
624
-
625
- action submit() {
626
- if !$name || !$email { return }
627
- $post = http({ url: "/api/contact", method: "POST", body: { name: $name, email: $email, message: $message } })
628
- $sent = true
402
+ ], { gap: "l" })
629
403
  }
630
404
 
631
- action reset() { $name = "" $email = "" $message = "" $sent = false }
632
-
633
- formCard = Card([
634
- CardHeader("Get in touch", subtitle: "We typically reply within one business day."),
635
- Form("contact", btns, [
636
- FormControl("Name", Input("name", placeholder: "Your name", bind:value: $name)),
637
- FormControl("Email", Input("email", placeholder: "you@example.com", type: "email", bind:value: $email)),
638
- FormControl("Message", TextArea("message", placeholder: "Tell us more…", rows: 4, bind:value: $message))
639
- ])
640
- ])
641
-
642
- btns = Buttons([
643
- Button("Send", onClick: submit, variant: "primary", icon: "paper-plane"),
644
- Button("Reset", onClick: reset, variant: "ghost")
645
- ])
646
-
647
- resultCard = if $sent {
648
- Card([Callout("success", "Message sent", description: \`Thanks \${$name}, we'll be in touch at \${$email}.\`, icon: "envelope-circle-check")])
649
- } else { null }
650
-
651
- ${D} = Stack([formCard, resultCard], direction: "column", gap: "l")`]}const Ed=["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 _d(t){return`${t?.trim()||"You are an AI assistant that responds using Aktion — a compact declarative language whose output is rendered as a rich, read-only UI surface. Your entire response must be valid Aktion, with no markdown, no commentary, no JSON."}
652
- Every response MUST start with \`${D} = ...\` on the very first line.
653
-
654
- You are operating in **read-only UI mode**. Use ONLY the layout, content,
655
- data-presentation, and feedback components listed below. Do NOT emit any
656
- of the following — they are interactive surfaces reserved for full-app
657
- mode and will not function here:
405
+ function Projects() { return PageHeader("Projects") }
406
+ function Calendar() { return PageHeader("Calendar") }
407
+ function NotFound() { return PageHeader("Not found") }`]}const Xm=["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 Jm(t){return`${t?.trim()||"You are an assistant that responds in Aktion — a declarative language whose surface syntax is a strict subset of JavaScript. The host renders your reply as a rich, read-only UI surface. Output ONLY Aktion: no markdown, prose, or JSON."}
658
408
 
659
- - Reactive-state writes, \`action\` blocks, \`effect\` blocks, raw \`js\`
660
- escape hatches, HTTP calls, or routing primitives.
661
- - Form controls and clickable buttons (text inputs, dropdowns, submit
662
- controls, file pickers, etc.).
663
- - App shells, sidebars, split views, and kanban-style boards.
664
- - Floating overlays and menus (modals, drawers, popovers, hover-cards,
665
- tooltips, dropdown menus, command palettes, context menus).
409
+ Every response MUST start with \`${V} = ...\` on the first line. You are in read-only UI mode — use only the layout, content, data-presentation, chart, and feedback components listed below. Do NOT emit reactive-state writes, action functions, \`effect\` calls, HTTP calls, routing primitives, form controls, clickable buttons, app shells, sidebars, kanban boards, modals, drawers, popovers, hover-cards, tooltips, or dropdown menus. The single exception is \`FollowUpBlock\`, which the host renders as plain follow-up prompt buttons.`}function Zm(){return`## Syntax (read-only subset)
666
410
 
667
- The single exception is \`FollowUpBlock\` — it is a read-only block of
668
- suggested follow-up prompts which the host renders as plain buttons.`}function jd(){return`## Syntax (read-only subset)
669
-
670
- A program is a flat list of \`name = expression\` statements terminated by
671
- newlines. \`${D}\` is the entry point — every program MUST begin
672
- with \`${D} = ...\` (typically \`${D} = Stack([...])\`).
411
+ A program is a flat list of \`name = expression\` statements, written in standard JavaScript. \`${V}\` is the entry point — every program MUST begin with \`${V} = ...\` (typically \`${V} = Column([...])\`).
673
412
 
674
413
  ### Expressions
675
- - Strings: \`"hello"\` or \`'hello'\`. Both forms support escapes.
676
- - Template literals: backticks with \`\${expr}\` interpolation —
677
- \`\`\`\${@Count(rows)} results\`\`\`. Mix copy with values without manual \`+\` concatenation.
678
- - Numbers (\`42\`, \`-3.14\`), booleans (\`true\`, \`false\`), \`null\`.
679
- - Arrays: \`[1, 2, 3]\`, \`[Card1(), Card2()]\` — multi-line OK.
680
- - Objects: \`{ key: value, "quoted-key": value }\`.
681
- - Operators: \`+ - * / %\`, \`== != > < >= <=\`, \`&& || !\`, ternary
682
- \`cond ? a : b\`, nullish coalescing \`a ?? b\`, spread \`[...a, ...b]\`,
683
- member access \`obj.field\`, optional chaining \`obj?.field\`.
684
-
685
- ### Component calls
686
- \`TypeName(arg1, arg2, prop: value, …)\`. Arguments are matched against the
687
- spec's prop list in declaration order; named arguments (\`prop: value\`) may
688
- appear at any position and override positional matching. Optional props can
689
- be omitted from the end.
414
+ - Strings \`"hello"\` / \`'hello'\`. Template literals: \`\` \`\${rows.length} results\` \`\` — preferred over \`+\` concatenation.
415
+ - Numbers, booleans, \`null\`, arrays \`[1, 2, 3]\`, objects \`{ key: value }\`.
416
+ - Operators: \`+ - * / %\`, \`== != > < >= <=\`, \`&& || !\`, ternary \`cond ? a : b\`, nullish \`a ?? b\`, spread \`[...a, ...b]\`, member access \`obj.field\`, optional chaining \`obj?.field\`.
690
417
 
691
- \`\`\`
692
- Callout("info", "Heads up", description: "Action required", icon: "circle-info", compact: true)
693
- Stack([card1, card2], direction: "row", gap: "m")
694
- Badge("Live", tone: "success", icon: "circle-dot")
695
- \`\`\`
418
+ ### Component calls — two hard rules
419
+ 1. **Any case works.** Component names may start with either an uppercase or lowercase letter — \`Card\`, \`card\`, \`Hero\`, \`hero\` are all valid declarations.
420
+ 2. **Always invoke with parentheses.** A bare identifier (\`Hero\`) is a function reference; the rendered element is \`Hero()\`. Even with no arguments, write \`Hero()\`. In arrays: \`Column([Header(), Body(), Footer()])\`, never \`Column([Header, Body, Footer])\`.
696
421
 
697
- ### Repeating UI from data
698
- Use the expression-form \`for\` loop to render an array of items into
699
- multiple nodes:
422
+ ### Trailing-object rule
423
+ \`TypeName(positionalArg, { prop: value, ... })\`. The first argument is the canonical positional slot; every other argument lives in a trailing \`{ }\` object.
700
424
 
701
425
  \`\`\`
702
- rows = for item in items { ListItem(item.title, description: item.desc) }
703
- list = List(rows)
426
+ Callout("info", { title: "Heads up", description: "Action required", icon: "circle-info", compact: true })
427
+ Row([card1, card2], { gap: "m" })
428
+ Badge("Live", { tone: "success", icon: "circle-dot" })
704
429
  \`\`\`
705
430
 
706
- ### Branching (optional)
707
- Use \`if\` / \`match\` when the UI depends on a literal you computed:
431
+ ### Building UI from data — JS is fully supported
432
+ - \`.map(...)\` / \`.filter().map()\` to render arrays into nodes (same as React).
433
+ - Ternary for branching: \`tone = status == "ok" ? "success" : "warning"\`.
434
+ - Array pluck: \`rows.title\` returns \`[row.title for each row]\` — feed columns (\`Col("Title", rows.title)\`) and chart series (\`PieChart(rows.label, rows.value)\`).
435
+ - \`rows.length\`, \`rows.first\`, \`rows.last\` shortcuts.
708
436
 
709
- \`\`\`
710
- greeting = if isMorning { "Good morning" } else { "Hello" }
711
- tone = match status { "ok": "success" "warn": "warning" default: "neutral" }
712
- \`\`\`
437
+ \`if\` / \`switch\` / \`for\` are statement-only — they cannot appear on the right-hand side of an assignment in chat mode.
713
438
 
714
- ### Array helpers
715
- - \`rows.length\` — element count.
716
- - \`rows.first\` / \`rows.last\` — first / last element (\`null\` if empty).
717
- - **Array pluck**: \`rows.title\` returns \`[row.title for each row]\` —
718
- the idiomatic way to feed per-column arrays (\`Col("Title", rows.title)\`)
719
- or per-segment number arrays (\`PieChart(rows.label, rows.value)\`).
439
+ ### Streaming order
440
+ Always declare \`${V}\` FIRST. Then container/composition statements. Then leaf data arrays last.
720
441
 
721
- ### Statement ordering — required for streaming
722
442
  \`\`\`
723
- ${D} = Stack([heroCard, statsRow, table, follow])
443
+ ${V} = Column([heroCard, statsRow, table, follow])
724
444
 
725
- heroCard = Card([CardHeader("Q4 results", subtitle: "Across all teams")])
445
+ heroCard = Card([CardHeader("Q4 results", { subtitle: "Across all teams" })])
726
446
  statsRow = Stats(stats)
727
- table = Table([Col("Region", rows.region), Col("Revenue", rows.revenue, format: "currency")])
447
+ table = Table([Col("Region", rows.region), Col("Revenue", rows.revenue, { format: "currency" })])
728
448
  follow = FollowUpBlock(["Break down by region", "Compare to Q3"])
729
449
 
730
- stats = [
731
- { label: "MRR", value: "$48.2k", hint: "+12% vs Q3" },
732
- { label: "Active users", value: "2,184", hint: "+184" }
733
- ]
734
- rows = [
735
- { region: "North America", revenue: 184000 },
736
- { region: "Europe", revenue: 122000 },
737
- { region: "APAC", revenue: 89000 }
738
- ]
739
- \`\`\`
740
-
741
- Always declare \`${D}\` FIRST. Then container/composition statements
742
- (\`heroCard\`, \`statsRow\`, …). Then leaf data arrays last. This produces a
743
- clean top-down reveal as the response streams in.`}function Bd(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(i=>i.name)}],r=new Map(t.components.map(i=>[i.name,i])),a=["## Component library (read-only)","Use only these components. Each signature lists props in declaration order; optional props end with `?`. Pass props positionally in order, or as `prop: value` named arguments for clarity."];for(const i of e){const n=i.components.filter(s=>Ed.includes(s));if(n.length!==0){a.push(`
744
- ### ${i.name}`);for(const s of n){const l=r.get(s);l&&a.push(ft(l))}}}return a.join(`
745
- `)}function Dd(){return'## Icons (Font Awesome)\n\nIcon-typed props (`icon`, `avatarSrc`, etc.) expect a Font Awesome name\nas a string — no `fa-` prefix, no emoji characters.\n\n- Format: `"name"` (defaults to the solid set), e.g. `"house"`,\n `"chart-line"`, `"star"`, `"circle-check"`.\n- Variants: prefix with `"regular:name"` (outline set) or\n `"brands:name"` (brand logos).\n- Render an icon inline anywhere a Node is expected with\n `Icon(name, variant?, size?)`.'}function Fd(){const t=gt(),e=t.filter(n=>n.category==="data"),r=t.filter(n=>n.category==="iteration"),a=e.map(ht).join(`
746
- `),i=r.map(ht).join(`
747
- `);return`## Built-in \`@\`-functions
748
-
749
- \`@\`-prefixed functions are **pure helpers** — no side effects. Use them
750
- for data shaping, counts, sums, formatting, and inline iteration when the
751
- expression-form \`for\` / \`if\` / \`match\` would be awkward.
450
+ stats = [{ label: "MRR", value: "$48.2k", hint: "+12% vs Q3" }]
451
+ rows = [{ region: "NA", revenue: 184000 }, { region: "EU", revenue: 122000 }]
452
+ \`\`\``}function Qm(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=>Xm.includes(o));if(i.length!==0){a.push(`
453
+ ### ${n.name}`);for(const o of i){const s=r.get(o);s&&a.push(Ut(s))}}}return a.join(`
454
+ `)}function ef(){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?)`.\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 tf(){return`## Hoisting & streaming (CRITICAL)
752
455
 
753
- ### Data helpers
754
- ${a}
456
+ References resolve from the entire scope, not source order — undefined references render as empty until their definitions arrive. This produces a smooth top-down reveal as the response streams.
755
457
 
756
- ### Iteration helpers
757
- ${i}
758
-
759
- Template literals (\`backticks with \${expr}\`) compose naturally with these
760
- helpers — \`\`\`Found \${@Count(rows)} \${@Plural(@Count(rows), "result", "results")} (\${@Format(@Sum(rows.amount), "currency", "USD")} total)\`\`\``}function Od(){return`## Hoisting & streaming (CRITICAL)
761
-
762
- Aktion supports hoisting: a reference can be used BEFORE it is
763
- defined. The output is re-parsed on every streamed chunk, so undefined
764
- references render as empty until their definitions arrive. This produces a
765
- smooth top-down reveal.
766
-
767
- **Required statement order:**
768
- 1. \`${D} = ...\` — emit FIRST so the UI shell appears immediately.
769
- 2. Container statements (\`heroCard\`, \`tableBlock\`, \`statsRow\`, …) — next.
458
+ Required statement order:
459
+ 1. \`${V} = ...\` — emit FIRST so the shell appears immediately.
460
+ 2. Container statements (\`heroCard\`, \`tableBlock\`, \`statsRow\`, ...).
770
461
  3. Leaf data values (arrays, objects, strings) — last.
771
462
 
772
- **Streaming rules:**
773
- - Always reference children by name from the root
774
- (\`${D} = Stack([hero, body, footer])\`).
775
- - Define one reference per \`Col\`, \`TabItem\`, \`AccordionItem\`,
776
- \`Series\`, \`FollowUpItem\`, etc. — each one streams in independently.
777
- - Place large data values on their own trailing lines.
778
- - Never split a single statement across multiple lines unless it sits
779
- inside an unmatched \`[\`, \`(\`, or \`{\`.`}function Ud(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(`
780
- `)}function qd(){return[`# Comparison table reply with template literal summary
781
- ${D} = Stack([title, tbl, totals, follow])
782
- title = Text("Top languages by users", variant: "large-heavy")
463
+ Define one named reference per \`Col\`, \`TabItem\`, \`AccordionItem\`, \`Series\`, \`FollowUpItem\` so each one streams independently. Never split a single statement across multiple lines unless it sits inside an unmatched \`[\`, \`(\`, or \`{\`.`}function rf(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(`
464
+ `)}function af(){return[`// Comparison table reply with a template-literal summary
465
+ ${V} = Column([title, tbl, totals, follow])
466
+ title = Text("Top languages by users", { variant: "large-heavy" })
783
467
  tbl = Table([
784
468
  Col("Language", langs.name),
785
- Col("Users (M)", langs.users, format: "number"),
786
- Col("First seen", langs.year, format: "number")
469
+ Col("Users (M)", langs.users, { format: "number" }),
470
+ Col("First seen", langs.year, { format: "number" })
787
471
  ])
788
- totals = Callout("info", \`Tracking \${@Count(langs)} languages · \${@Sum(langs.users)}M users combined\`, icon: "chart-line", compact: true)
789
- follow = FollowUpBlock(["Sort by users", "Show this as a chart", "Tell me about TypeScript"])
472
+ totals = Callout("info", { title: \`Tracking \${langs.length} languages · \${$util.sum(langs.users)}M users combined\`, icon: "chart-line", compact: true })
473
+ follow = FollowUpBlock(["Sort by users", "Show as a chart"])
790
474
 
791
475
  langs = [
792
476
  { name: "Python", users: 15.7, year: 1991 },
793
477
  { name: "JavaScript", users: 14.2, year: 1995 },
794
- { name: "Java", users: 12.1, year: 1995 },
795
478
  { name: "TypeScript", users: 8.5, year: 2012 },
796
479
  { name: "Go", users: 5.2, year: 2009 }
797
- ]`,`# Bar chart reply with a summary callout
798
- ${D} = Stack([title, chart, summary, follow])
799
- title = Text("Q4 revenue by product", variant: "large-heavy")
800
- chart = BarChart(labels, [Series("Product A", a), Series("Product B", b)])
801
- summary = Callout("info", \`Q4 total: \${@Format(@Sum(a) + @Sum(b), "currency", "USD")} across \${@Count(labels)} months\`, icon: "chart-column", compact: true)
802
- follow = FollowUpBlock(["Compare to Q3", "Break down by region", "Show as a line chart"])
803
-
804
- labels = ["Oct", "Nov", "Dec"]
805
- a = [120, 150, 180]
806
- b = [90, 110, 140]`,`# Article-style reply with Markdown body and a KPI strip
807
- ${D} = Stack([header, body, kpis, related])
808
- header = Hero(
809
- "The fastest open-source UI runtime",
810
- subtitle: "Three releases in, the renderer parses and paints 38,000 LLM responses per second.",
811
- eyebrow: "Engineering update"
812
- )
813
- body = Markdown(article)
814
- kpis = Stats([
480
+ ]`,`// Article-style reply with Markdown body and KPI strip
481
+ ${V} = Column([header, body, kpis])
482
+ header = Hero("The fastest open-source UI runtime", { subtitle: "38,000 LLM responses per second.", eyebrow: "Engineering update" })
483
+ body = Markdown(article)
484
+ kpis = Stats([
815
485
  { label: "Open issues", value: "184", hint: "-23 vs last week" },
816
486
  { label: "PRs merged", value: "1,204", hint: "this quarter" },
817
487
  { label: "Avg latency", value: "84ms", hint: "p99" }
818
488
  ])
819
- related = SectionBlock("Related reads", [
820
- ListBlock([
821
- "How streaming UI got 2× faster",
822
- "The case for a single reactive sigil",
823
- "Lazy hydration in practice"
824
- ])
825
- ])
826
-
827
- article = "The renderer started as a hack to display LLM responses without a framework. Today it ships **130+ components**, a single-sigil reactive model, and a tiny streaming-first parser. Read on for the architecture deep-dive."`,`# Code-snippet reply — title + Markdown + summary callout
828
- ${D} = Stack([header, answer, hint, follow])
829
- header = Text("Recommended Postgres index", variant: "large-heavy")
830
- answer = CodeBlock("sql", indexSql, showLineNumbers: true)
831
- hint = Callout("success", "Composite index cuts query time ~12×", description: "Postgres reads index entries already in the requested order, so the planner skips the sort step entirely.", icon: "lightbulb")
832
- follow = FollowUpBlock(["Show EXPLAIN ANALYZE output", "How big is the index?", "Compare to a partial index"])
833
489
 
834
- indexSql = "CREATE INDEX idx_orders_user_status_created\\n ON orders (user_id, status, created_at DESC);"`]}function Hd(){return'## Important rules\n\n- **Choose components that best represent the content.** Tables for\n comparisons, charts for trends, `Callout` / `Banner` for highlights,\n `Markdown` for paragraph prose with inline formatting, `Hero` /\n `PageHeader` for top-of-reply titles, `Stats` for KPI strips.\n- **Lead with a clear title.** Use `Text(text, variant: "large-heavy")`,\n `SectionHeader(...)`, `PageHeader(...)`, or `Hero(...)` so the user sees\n what the reply is about at a glance.\n- **Generate realistic data.** When asked about data, write believable\n names, numbers, and dates. Never write Lorem Ipsum.\n- **Tables are column-oriented**: `Table([Col("Label", arr1), Col("Count", arr2, format: "number")])`.\n- **Charts need numeric arrays**, not arrays of objects. Use array pluck:\n `PieChart(rows.label, rows.value)` instead of passing `rows` directly.\n- **End conversational replies with `FollowUpBlock([...])`** — 2–4 short\n next-prompt suggestions keep the conversation flowing.\n- **Use `Markdown`** for rich paragraph prose with bold, lists, code\n fences, links, and headings. Use `Text` for short labelled lines.\n- **Icons are Font Awesome names** (no `fa-` prefix, no emoji). Example\n values: `"house"`, `"chart-line"`, `"star"`, `"circle-check"`.\n- **Use template literals** for any string that mixes copy with values:\n ```${@Count(rows)} results``` instead of `"..." + ... + "..."` concatenation.'}function Vd(){return`## Final verification
490
+ article = "The renderer ships **130+ components**, a single reactive sigil, and a streaming-first parser."`]}function nf(){return'## Important rules\n\n- **Pick the right component for the content.** Tables for comparisons, charts for trends, `Callout`/`Banner` for highlights, `Markdown` for paragraph prose, `Hero`/`PageHeader` for top titles, `Stats` for KPI strips.\n- **Lead with a clear title.** `Text(text, { variant: "large-heavy" })`, `SectionHeader(...)`, `PageHeader(...)`, or `Hero(...)`.\n- **Realistic data** — believable names, numbers, and dates. Never Lorem Ipsum.\n- **Tables are column-oriented:** `Table([Col("Label", arr1), Col("Count", arr2, { format: "number" })])`. Columns can hold components in two equivalent ways: map values to components directly — `Col("Status", rows.map(r => Badge(r.status)))`, `Col("Actions", rows.map(r => Button("Edit")))` — or keep rows as values and use `render: (r) => Component`. A whole column can be clickable with `onClick: (value, index) => …`.\n- **Charts need numeric arrays** — use array pluck (`PieChart(rows.label, rows.value)`).\n- **End conversational replies with `FollowUpBlock([...])`** — 2–4 short next-prompt suggestions.\n- **`Markdown`** for rich paragraph prose; **`Text`** for short labels.\n- **Template literals** for any string mixing copy with values.\n- **Trailing-object form** — `Button("Save", { variant: "primary" })`, never bare `Button("Save", variant: "primary")`.'}function of(){return`## Final verification
835
491
 
836
492
  Before finishing, walk your output and verify:
837
- 1. \`${D} = ...\` is the FIRST line.
493
+ 1. \`${V} = ...\` is the FIRST line.
838
494
  2. Every referenced name is defined somewhere below.
839
- 3. Every defined name (other than \`${D}\`) is reachable from
840
- \`${D}\` (directly or transitively).
841
- 4. Only the read-only components listed above are used — no forms,
842
- clickable buttons, modal overlays, app shells, reactive-state writes,
843
- action blocks, effect blocks, HTTP calls, routing primitives, or raw
844
- \`js\` escape hatches.
845
- 5. No statement is split across multiple lines unless it sits inside an
846
- unmatched \`[\`, \`(\`, or \`{\`.
847
- 6. Tables are column-oriented; charts use numeric arrays (use array pluck
848
- like \`rows.value\` when needed).`}function ft(t){const e=$t(t),r=t.props.map(a=>{const i=a.enum?a.enum.map(s=>`"${s}"`).join("|"):a.type,n=a===e&&a.positional===!0?" (positional)":"";return`${a.name}${a.optional?"?":""}: ${i}${n}`}).join(", ");return`- ${t.name}(${r}) — ${t.description}`}function Wd(t){const e=t.filter(i=>i.category==="data"),r=t.filter(i=>i.category==="iteration"),a=[];if(e.length>0){a.push("### Data helpers");for(const i of e)a.push(ht(i));a.push("")}if(r.length>0){a.push("### Iteration helpers");for(const i of r)a.push(ht(i))}return a.join(`
849
- `)}function ht(t){return`- \`${t.signature}\` — ${t.description}`}function Kt(t,e){const r=[`## ${t}`];for(const a of e)r.push("```"),r.push(a.trim()),r.push("```");return r.join(`
850
- `)}function ti(t){const e=["## Additional rules"];for(const r of t)e.push(`- ${r}`);return e.join(`
851
- `)}function Gd(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",i=r.argsExample?` example body: ${JSON.stringify(r.argsExample)}`:" example body: {}";e.push(`- ${r.name} (${a}) — ${r.description}
852
- ${i}`)}return e.join(`
853
- `)}const ue={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"}},ri={...ue,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)"},ai={...ue,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"},ii={...ue,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"},ni={...ue,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"},oi={...ue,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"},si={...ue,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"},Yt={light:ue,dark:ri,neon:ai,pastel:ii,glass:ni,brutalist:oi,skyline:si},bt={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 Jt(t){if(!t)return{name:"light",tokens:ue};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:di(JSON.parse(t))}}catch{return{name:"light",tokens:ue}}const r=Yt[e];return r?{name:e,tokens:r}:{name:"light",tokens:ue}}return{name:"custom",tokens:di(t)}}function Xt(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[a,i]of Object.entries(bt))t.style.setProperty(i,r.tokens[a]);t.setAttribute("data-rui-theme",r.name)}function li(t,e){const r=[];for(const a of Object.keys(e)){const i=bt[a];if(!i)continue;const n=e[a];typeof n!="string"||n===""||(t.style.setProperty(i,n),r.push(a))}return r}function ci(t,e){for(const r of e){const a=bt[r];a&&t.style.removeProperty(a)}}function ui(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t))if(r in bt&&a!=null)if(typeof a=="string"){if(a.trim()==="")continue;e[r]=a}else typeof a=="number"&&(e[r]=String(a));return e}function di(t){return{...ue,...t}}const pi=`
495
+ 3. Every defined name (other than \`${V}\`) is reachable from \`${V}\`.
496
+ 4. Component name case is not significant, but every component reference is invoked with parentheses — \`Hero()\`, never bare \`Hero\`.
497
+ 5. Only the read-only components above are used — no forms, clickable buttons, modals, app shells, reactive-state writes, action functions, effect calls, HTTP calls, or routing primitives.
498
+ 6. No statement is split across multiple lines unless it sits inside an unmatched \`[\`, \`(\`, or \`{\`.
499
+ 7. Tables are column-oriented; charts use numeric arrays (use array pluck like \`rows.value\` when needed).
500
+ 8. Named arguments use a trailing \`{ prop: value }\` object — not bare \`prop: value\` syntax.`}function Ut(t){const e=Jt(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 Er(t,e){const r=[`## ${t}`];for(const a of e)r.push("```"),r.push(a.trim()),r.push("```");return r.join(`
501
+ `)}function di(t){const e=["## Additional rules"];for(const r of t)e.push(`- ${r}`);return e.join(`
502
+ `)}function sf(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}
503
+ ${n}`)}return e.join(`
504
+ `)}const be={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"}},pi={...be,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)"},mi={...be,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"},fi={...be,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"},gi={...be,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"},hi={...be,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"},bi={...be,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"},jr={light:be,dark:pi,neon:mi,pastel:fi,glass:gi,brutalist:hi,skyline:bi},Ht={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 Dr(t){if(!t)return{name:"light",tokens:be};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:wi(JSON.parse(t))}}catch{return{name:"light",tokens:be}}const r=jr[e];return r?{name:e,tokens:r}:{name:"light",tokens:be}}return{name:"custom",tokens:wi(t)}}function Br(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[a,n]of Object.entries(Ht))t.style.setProperty(n,r.tokens[a]);t.setAttribute("data-rui-theme",r.name)}function vi(t,e){const r=[];for(const a of Object.keys(e)){const n=Ht[a];if(!n)continue;const i=e[a];typeof i!="string"||i===""||(t.style.setProperty(n,i),r.push(a))}return r}function yi(t,e){for(const r of e){const a=Ht[r];a&&t.style.removeProperty(a)}}function xi(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t))if(r in Ht&&a!=null)if(typeof a=="string"){if(a.trim()==="")continue;e[r]=a}else typeof a=="number"&&(e[r]=String(a));return e}function wi(t){return{...be,...t}}const ki=`
854
505
  :host {
855
506
  display: block;
856
507
  box-sizing: border-box;
@@ -956,6 +607,7 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
956
607
  display: flex;
957
608
  flex-direction: column;
958
609
  gap: var(--rui-spacing-m);
610
+ padding: 20px;
959
611
  }
960
612
 
961
613
  .rui-error-banner {
@@ -1041,6 +693,32 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
1041
693
  .rui-stack-item[data-align-self="end"] { align-self: flex-end; }
1042
694
  .rui-stack-item[data-align-self="stretch"] { align-self: stretch; }
1043
695
 
696
+ /* Center — center children on both axes (or one, via data-axis). Pair with
697
+ a minHeight to center vertically inside a tall region. */
698
+ .rui-center {
699
+ display: flex;
700
+ flex-direction: column;
701
+ align-items: center;
702
+ justify-content: center;
703
+ gap: var(--rui-spacing-m);
704
+ width: 100%;
705
+ box-sizing: border-box;
706
+ text-align: center;
707
+ }
708
+ .rui-center[data-inline="true"] { display: inline-flex; width: auto; }
709
+ .rui-center[data-axis="horizontal"] { justify-content: flex-start; }
710
+ .rui-center[data-axis="vertical"] { align-items: stretch; text-align: left; }
711
+ .rui-center[data-gap="xs"] { gap: var(--rui-spacing-xs); }
712
+ .rui-center[data-gap="s"] { gap: var(--rui-spacing-s); }
713
+ .rui-center[data-gap="m"] { gap: var(--rui-spacing-m); }
714
+ .rui-center[data-gap="l"] { gap: var(--rui-spacing-l); }
715
+ .rui-center[data-gap="xl"] { gap: var(--rui-spacing-xl); }
716
+ .rui-center[data-padding="xs"] { padding: var(--rui-spacing-xs); }
717
+ .rui-center[data-padding="s"] { padding: var(--rui-spacing-s); }
718
+ .rui-center[data-padding="m"] { padding: var(--rui-spacing-m); }
719
+ .rui-center[data-padding="l"] { padding: var(--rui-spacing-l); }
720
+ .rui-center[data-padding="xl"] { padding: var(--rui-spacing-xl); }
721
+
1044
722
  /* Section */
1045
723
  .rui-section { display: flex; flex-direction: column; gap: var(--rui-spacing-s); }
1046
724
  .rui-section-title {
@@ -1500,6 +1178,37 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
1500
1178
  padding: var(--rui-spacing-s) var(--rui-spacing-m);
1501
1179
  font-weight: 600;
1502
1180
  list-style: none;
1181
+ display: flex;
1182
+ align-items: center;
1183
+ justify-content: space-between;
1184
+ gap: var(--rui-spacing-s);
1185
+ }
1186
+ .rui-accordion-trigger::-webkit-details-marker { display: none; }
1187
+ .rui-accordion-title { flex: 1; min-width: 0; }
1188
+ /* Chevron: hidden by default; revealed when wrapper or item opts in via data-show-arrow="true". */
1189
+ .rui-accordion-chevron {
1190
+ display: none;
1191
+ width: 8px;
1192
+ height: 8px;
1193
+ flex-shrink: 0;
1194
+ border-right: 2px solid currentColor;
1195
+ border-bottom: 2px solid currentColor;
1196
+ transform: rotate(45deg) translate(-2px, -2px);
1197
+ transform-origin: center;
1198
+ transition: transform 180ms ease;
1199
+ color: var(--rui-color-text-muted);
1200
+ opacity: 0.8;
1201
+ }
1202
+ .rui-accordion[data-show-arrow="true"] .rui-accordion-item:not([data-show-arrow="false"]) .rui-accordion-chevron,
1203
+ .rui-accordion-item[data-show-arrow="true"] .rui-accordion-chevron {
1204
+ display: inline-block;
1205
+ }
1206
+ .rui-accordion[data-show-arrow="true"] .rui-accordion-item[data-show-arrow="false"] .rui-accordion-chevron {
1207
+ display: none;
1208
+ }
1209
+ .rui-accordion-item[open] > .rui-accordion-trigger .rui-accordion-chevron {
1210
+ transform: rotate(225deg) translate(-2px, -2px);
1211
+ color: var(--rui-color-primary);
1503
1212
  }
1504
1213
  .rui-accordion-body { padding: 0 var(--rui-spacing-m) var(--rui-spacing-m); }
1505
1214
 
@@ -1568,9 +1277,88 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
1568
1277
  gap: var(--rui-spacing-s);
1569
1278
  cursor: pointer;
1570
1279
  font-size: 14px;
1280
+ user-select: none;
1281
+ line-height: 1.4;
1571
1282
  }
1572
1283
  .rui-radio-group { display: flex; flex-direction: column; gap: var(--rui-spacing-xs); }
1573
1284
 
1285
+ /* Custom Checkbox & Radio control styling.
1286
+ * Hides the native input visually but keeps it focusable; renders the
1287
+ * checked state via a CSS-painted indicator so the appearance is
1288
+ * consistent across themes and platforms. */
1289
+ .rui-checkbox input[type="checkbox"],
1290
+ .rui-checkbox-item input[type="checkbox"],
1291
+ .rui-radio input[type="radio"] {
1292
+ appearance: none;
1293
+ -webkit-appearance: none;
1294
+ margin: 0;
1295
+ flex-shrink: 0;
1296
+ display: inline-block;
1297
+ width: 20px;
1298
+ height: 20px;
1299
+ transform: scale(0.8);
1300
+ background: var(--rui-color-surface);
1301
+ border: 1.5px solid var(--rui-color-border);
1302
+ cursor: pointer;
1303
+ position: relative;
1304
+ transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
1305
+ }
1306
+ .rui-checkbox input[type="checkbox"],
1307
+ .rui-checkbox-item input[type="checkbox"] {
1308
+ border-radius: 5px;
1309
+ }
1310
+ .rui-radio input[type="radio"] {
1311
+ border-radius: 999px;
1312
+ }
1313
+ .rui-checkbox input[type="checkbox"]:hover,
1314
+ .rui-checkbox-item input[type="checkbox"]:hover,
1315
+ .rui-radio input[type="radio"]:hover {
1316
+ border-color: var(--rui-color-primary);
1317
+ }
1318
+ .rui-checkbox input[type="checkbox"]:focus-visible,
1319
+ .rui-checkbox-item input[type="checkbox"]:focus-visible,
1320
+ .rui-radio input[type="radio"]:focus-visible {
1321
+ outline: none;
1322
+ border-color: var(--rui-color-focus-ring);
1323
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--rui-color-focus-ring) 22%, transparent);
1324
+ }
1325
+ .rui-checkbox input[type="checkbox"]:checked,
1326
+ .rui-checkbox-item input[type="checkbox"]:checked,
1327
+ .rui-radio input[type="radio"]:checked {
1328
+ background: var(--rui-color-primary);
1329
+ border-color: var(--rui-color-primary);
1330
+ }
1331
+ .rui-checkbox input[type="checkbox"]:checked::after,
1332
+ .rui-checkbox-item input[type="checkbox"]:checked::after {
1333
+ content: "";
1334
+ position: absolute;
1335
+ left: 5px;
1336
+ top: 1px;
1337
+ width: 5px;
1338
+ height: 10px;
1339
+ border: solid var(--rui-color-primary-text, #fff);
1340
+ border-width: 0 2px 2px 0;
1341
+ transform: rotate(45deg);
1342
+ }
1343
+ .rui-radio input[type="radio"]:checked::after {
1344
+ content: "";
1345
+ position: absolute;
1346
+ left: 50%;
1347
+ top: 50%;
1348
+ width: 8px;
1349
+ height: 8px;
1350
+ border-radius: 999px;
1351
+ background: var(--rui-color-primary-text, #fff);
1352
+ transform: translate(-50%, -50%);
1353
+ }
1354
+ .rui-checkbox input[type="checkbox"]:disabled,
1355
+ .rui-checkbox-item input[type="checkbox"]:disabled,
1356
+ .rui-radio input[type="radio"]:disabled {
1357
+ opacity: 0.55;
1358
+ cursor: not-allowed;
1359
+ }
1360
+ .rui-checkbox-label, .rui-radio-label { color: var(--rui-color-text); }
1361
+
1574
1362
  .rui-button {
1575
1363
  border: var(--rui-border-width) solid transparent;
1576
1364
  border-radius: var(--rui-radius-button);
@@ -1605,10 +1393,10 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
1605
1393
  .rui-button[data-size="xl"] { padding: calc(var(--rui-button-padding-y) * 1.6) calc(var(--rui-button-padding-x) * 1.5); font-size: var(--rui-font-size-lg); }
1606
1394
  .rui-button[data-full-width="true"] { width: 100%; }
1607
1395
  .rui-button[data-icon-only="true"] .rui-button-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
1608
- .rui-button[data-icon-position="trailing"] .rui-button-icon { margin-right: 0; margin-left: 4px; order: 2; }
1396
+ .rui-button[data-icon-position="trailing"] .rui-button-icon { margin-right: 0; margin-left: 10px; order: 2; }
1609
1397
  .rui-button[data-loading="true"] { pointer-events: none; }
1610
1398
  .rui-button-spinner { margin-right: 4px; }
1611
- .rui-button[data-icon-position="trailing"] .rui-button-spinner { margin-right: 0; margin-left: 4px; }
1399
+ .rui-button[data-icon-position="trailing"] .rui-button-spinner { margin-right: 0; margin-left: 10px; }
1612
1400
 
1613
1401
  .rui-buttons {
1614
1402
  display: flex;
@@ -1737,6 +1525,18 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
1737
1525
  }
1738
1526
  .rui-chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
1739
1527
  .rui-chart-legend-swatch { width: 10px; height: 10px; border-radius: 999px; }
1528
+ /* Pie chart inline value labels: bold, centered, painted with a soft
1529
+ * stroke (set inline) so they remain legible on any slice color. The
1530
+ * specificity here is higher than the generic '.rui-chart-svg text'
1531
+ * fill, so the white fill wins. */
1532
+ .rui-chart-svg .rui-pie-chart-value,
1533
+ .rui-pie-chart .rui-pie-chart-value {
1534
+ font-size: 12px;
1535
+ font-weight: 700;
1536
+ pointer-events: none;
1537
+ font-variant-numeric: tabular-nums;
1538
+ fill: #ffffff;
1539
+ }
1740
1540
 
1741
1541
  /* Chat blocks */
1742
1542
  .rui-section-block {
@@ -2089,10 +1889,10 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
2089
1889
  color-mix(in srgb, var(--rui-color-primary) 30%, var(--rui-color-surface-muted)));
2090
1890
  color: color-mix(in srgb, var(--rui-color-primary) 90%, var(--rui-color-text));
2091
1891
  }
2092
- .rui-avatar[data-size="sm"] { width: 24px; height: 24px; font-size: 10px; }
2093
- .rui-avatar[data-size="md"] { width: 36px; height: 36px; font-size: 13px; }
2094
- .rui-avatar[data-size="lg"] { width: 52px; height: 52px; font-size: 18px; }
2095
- .rui-avatar[data-size="xl"] { width: 72px; height: 72px; font-size: 22px; }
1892
+ .rui-avatar[data-size="sm"] { width: 24px; height: 24px; font-size: 10px; max-width: 24px; max-height: 24px; }
1893
+ .rui-avatar[data-size="md"] { width: 36px; height: 36px; font-size: 13px; max-width: 36px; max-height: 36px; }
1894
+ .rui-avatar[data-size="lg"] { width: 52px; height: 52px; font-size: 18px; max-width: 52px; max-height: 52px; }
1895
+ .rui-avatar[data-size="xl"] { width: 72px; height: 72px; font-size: 22px; max-width: 72px; max-height: 72px; }
2096
1896
  .rui-avatar-status {
2097
1897
  position: absolute;
2098
1898
  right: 2px;
@@ -2265,7 +2065,7 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
2265
2065
  color: var(--rui-color-primary);
2266
2066
  }
2267
2067
 
2268
- /* Tooltip — CSS-only hover/focus reveal. */
2068
+ /* Tooltip — CSS-only hover/focus reveal with arrow and accurate placement. */
2269
2069
  .rui-tooltip {
2270
2070
  position: relative;
2271
2071
  display: inline-flex;
@@ -2275,7 +2075,7 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
2275
2075
  .rui-tooltip-trigger { display: contents; }
2276
2076
  .rui-tooltip-content {
2277
2077
  position: absolute;
2278
- padding: 4px 8px;
2078
+ padding: 5px 9px;
2279
2079
  border-radius: var(--rui-radius-sm);
2280
2080
  background: var(--rui-color-text);
2281
2081
  color: var(--rui-color-bg);
@@ -2289,21 +2089,82 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
2289
2089
  transition: opacity 140ms ease, transform 140ms ease;
2290
2090
  z-index: 30;
2291
2091
  box-shadow: var(--rui-shadow-sm);
2092
+ /* Default origin — overridden per side below. */
2093
+ --rui-tooltip-x: -50%;
2094
+ --rui-tooltip-y: 0;
2095
+ --rui-tooltip-offset-x: 0;
2096
+ --rui-tooltip-offset-y: 4px;
2097
+ }
2098
+ /* Arrow pointing back at the trigger. */
2099
+ .rui-tooltip-arrow {
2100
+ position: absolute;
2101
+ width: 8px;
2102
+ height: 8px;
2103
+ background: inherit;
2104
+ transform: rotate(45deg);
2105
+ }
2106
+ .rui-tooltip[data-side="top"] .rui-tooltip-content {
2107
+ bottom: calc(100% + 6px);
2108
+ left: 50%;
2109
+ --rui-tooltip-x: -50%;
2110
+ --rui-tooltip-y: 0;
2111
+ --rui-tooltip-offset-y: 4px;
2112
+ }
2113
+ .rui-tooltip[data-side="top"] .rui-tooltip-arrow {
2114
+ bottom: -4px;
2115
+ left: calc(50% - 4px);
2116
+ }
2117
+ .rui-tooltip[data-side="bottom"] .rui-tooltip-content {
2118
+ top: calc(100% + 6px);
2119
+ left: 50%;
2120
+ --rui-tooltip-x: -50%;
2121
+ --rui-tooltip-y: 0;
2122
+ --rui-tooltip-offset-y: -4px;
2123
+ }
2124
+ .rui-tooltip[data-side="bottom"] .rui-tooltip-arrow {
2125
+ top: -4px;
2126
+ left: calc(50% - 4px);
2127
+ }
2128
+ .rui-tooltip[data-side="left"] .rui-tooltip-content {
2129
+ right: calc(100% + 6px);
2130
+ top: 50%;
2131
+ --rui-tooltip-x: 0;
2132
+ --rui-tooltip-y: -50%;
2133
+ --rui-tooltip-offset-x: 4px;
2134
+ --rui-tooltip-offset-y: 0;
2135
+ }
2136
+ .rui-tooltip[data-side="left"] .rui-tooltip-arrow {
2137
+ right: -4px;
2138
+ top: calc(50% - 4px);
2139
+ }
2140
+ .rui-tooltip[data-side="right"] .rui-tooltip-content {
2141
+ left: calc(100% + 6px);
2142
+ top: 50%;
2143
+ --rui-tooltip-x: 0;
2144
+ --rui-tooltip-y: -50%;
2145
+ --rui-tooltip-offset-x: -4px;
2146
+ --rui-tooltip-offset-y: 0;
2147
+ }
2148
+ .rui-tooltip[data-side="right"] .rui-tooltip-arrow {
2149
+ left: -4px;
2150
+ top: calc(50% - 4px);
2151
+ }
2152
+ .rui-tooltip-content {
2153
+ transform: translate(calc(var(--rui-tooltip-x) + var(--rui-tooltip-offset-x)), calc(var(--rui-tooltip-y) + var(--rui-tooltip-offset-y)));
2292
2154
  }
2293
- .rui-tooltip[data-side="top"] .rui-tooltip-content { bottom: calc(100% + 6px); left: 50%; transform: translate(-50%, 4px); }
2294
- .rui-tooltip[data-side="bottom"] .rui-tooltip-content { top: calc(100% + 6px); left: 50%; transform: translate(-50%, -4px); }
2295
- .rui-tooltip[data-side="left"] .rui-tooltip-content { right: calc(100% + 6px); top: 50%; transform: translate(4px, -50%); }
2296
- .rui-tooltip[data-side="right"] .rui-tooltip-content { left: calc(100% + 6px); top: 50%; transform: translate(-4px, -50%); }
2297
2155
  .rui-tooltip:hover .rui-tooltip-content,
2298
2156
  .rui-tooltip:focus-visible .rui-tooltip-content,
2299
- .rui-tooltip:focus-within .rui-tooltip-content {
2157
+ .rui-tooltip:focus-within:not(:active) .rui-tooltip-content {
2300
2158
  opacity: 1;
2301
- transform: translate(0, 0);
2159
+ transform: translate(var(--rui-tooltip-x), var(--rui-tooltip-y));
2160
+ }
2161
+ /* When the wrapper (or any descendant) is being pressed, suppress the
2162
+ * tooltip immediately so clicking the trigger doesn't leave it visible. */
2163
+ .rui-tooltip:active .rui-tooltip-content,
2164
+ .rui-tooltip:has(:active) .rui-tooltip-content {
2165
+ opacity: 0;
2166
+ transition-duration: 0ms;
2302
2167
  }
2303
- .rui-tooltip[data-side="top"]:hover .rui-tooltip-content { transform: translate(-50%, 0); }
2304
- .rui-tooltip[data-side="bottom"]:hover .rui-tooltip-content { transform: translate(-50%, 0); }
2305
- .rui-tooltip[data-side="left"]:hover .rui-tooltip-content { transform: translate(0, -50%); }
2306
- .rui-tooltip[data-side="right"]:hover .rui-tooltip-content { transform: translate(0, -50%); }
2307
2168
 
2308
2169
  /* HoverCard */
2309
2170
  .rui-hover-card {
@@ -3137,7 +2998,6 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
3137
2998
  gap: var(--rui-spacing-l);
3138
2999
  }
3139
3000
  .rui-app-shell-topbar {
3140
- display: flex;
3141
3001
  align-items: center;
3142
3002
  justify-content: space-between;
3143
3003
  gap: var(--rui-spacing-m);
@@ -3638,21 +3498,48 @@ button.rui-tile:hover,
3638
3498
  border: 1px solid var(--rui-color-border);
3639
3499
  border-radius: var(--rui-radius-md);
3640
3500
  position: relative;
3501
+ transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
3502
+ }
3503
+ .rui-notification[data-unread="true"] {
3504
+ background: color-mix(in srgb, var(--rui-color-primary) 5%, var(--rui-color-surface));
3505
+ border-color: color-mix(in srgb, var(--rui-color-primary) 28%, var(--rui-color-border));
3506
+ box-shadow: 0 1px 2px color-mix(in srgb, var(--rui-color-primary) 16%, transparent);
3641
3507
  }
3642
3508
  .rui-notification[data-unread="true"]::before {
3643
3509
  content: "";
3644
3510
  position: absolute;
3645
- top: var(--rui-spacing-m);
3646
- left: -1px;
3647
- width: 3px;
3648
- height: 24px;
3511
+ top: 0;
3512
+ bottom: 0;
3513
+ left: 0;
3514
+ width: 4px;
3649
3515
  background: var(--rui-color-primary);
3650
- border-radius: 999px;
3516
+ border-radius: var(--rui-radius-md) 0 0 var(--rui-radius-md);
3517
+ }
3518
+ .rui-notification[data-tone="success"][data-unread="true"] {
3519
+ background: color-mix(in srgb, var(--rui-color-success) 6%, var(--rui-color-surface));
3520
+ border-color: color-mix(in srgb, var(--rui-color-success) 28%, var(--rui-color-border));
3521
+ box-shadow: 0 1px 2px color-mix(in srgb, var(--rui-color-success) 16%, transparent);
3651
3522
  }
3652
3523
  .rui-notification[data-tone="success"][data-unread="true"]::before { background: var(--rui-color-success); }
3524
+ .rui-notification[data-tone="warning"][data-unread="true"] {
3525
+ background: color-mix(in srgb, var(--rui-color-warning) 6%, var(--rui-color-surface));
3526
+ border-color: color-mix(in srgb, var(--rui-color-warning) 28%, var(--rui-color-border));
3527
+ box-shadow: 0 1px 2px color-mix(in srgb, var(--rui-color-warning) 16%, transparent);
3528
+ }
3653
3529
  .rui-notification[data-tone="warning"][data-unread="true"]::before { background: var(--rui-color-warning); }
3530
+ .rui-notification[data-tone="danger"][data-unread="true"] {
3531
+ background: color-mix(in srgb, var(--rui-color-danger) 6%, var(--rui-color-surface));
3532
+ border-color: color-mix(in srgb, var(--rui-color-danger) 28%, var(--rui-color-border));
3533
+ box-shadow: 0 1px 2px color-mix(in srgb, var(--rui-color-danger) 16%, transparent);
3534
+ }
3654
3535
  .rui-notification[data-tone="danger"][data-unread="true"]::before { background: var(--rui-color-danger); }
3536
+ .rui-notification[data-tone="info"][data-unread="true"] {
3537
+ background: color-mix(in srgb, var(--rui-color-info) 6%, var(--rui-color-surface));
3538
+ border-color: color-mix(in srgb, var(--rui-color-info) 28%, var(--rui-color-border));
3539
+ box-shadow: 0 1px 2px color-mix(in srgb, var(--rui-color-info) 16%, transparent);
3540
+ }
3655
3541
  .rui-notification[data-tone="info"][data-unread="true"]::before { background: var(--rui-color-info); }
3542
+ .rui-notification-visual { flex-shrink: 0; display: flex; }
3656
3543
  .rui-notification-icon {
3657
3544
  display: inline-flex !important;
3658
3545
  align-items: center;
@@ -3664,6 +3551,10 @@ button.rui-tile:hover,
3664
3551
  font-size: 16px;
3665
3552
  flex-shrink: 0;
3666
3553
  }
3554
+ .rui-notification[data-unread="true"] .rui-notification-icon {
3555
+ background: color-mix(in srgb, var(--rui-color-primary) 18%, var(--rui-color-surface));
3556
+ color: var(--rui-color-primary);
3557
+ }
3667
3558
  .rui-notification[data-tone="success"] .rui-notification-icon { background: color-mix(in srgb, var(--rui-color-success) 18%, transparent); color: var(--rui-color-success); }
3668
3559
  .rui-notification[data-tone="warning"] .rui-notification-icon { background: color-mix(in srgb, var(--rui-color-warning) 18%, transparent); color: var(--rui-color-warning); }
3669
3560
  .rui-notification[data-tone="danger"] .rui-notification-icon { background: color-mix(in srgb, var(--rui-color-danger) 18%, transparent); color: var(--rui-color-danger); }
@@ -3681,16 +3572,57 @@ button.rui-tile:hover,
3681
3572
  gap: var(--rui-spacing-s);
3682
3573
  align-items: baseline;
3683
3574
  }
3575
+ .rui-notification-title-wrap {
3576
+ display: inline-flex;
3577
+ align-items: center;
3578
+ gap: 6px;
3579
+ min-width: 0;
3580
+ }
3581
+ .rui-notification-unread-dot {
3582
+ width: 8px;
3583
+ height: 8px;
3584
+ border-radius: 999px;
3585
+ background: var(--rui-color-primary);
3586
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--rui-color-primary) 25%, transparent);
3587
+ flex-shrink: 0;
3588
+ }
3589
+ .rui-notification[data-tone="success"] .rui-notification-unread-dot {
3590
+ background: var(--rui-color-success);
3591
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--rui-color-success) 25%, transparent);
3592
+ }
3593
+ .rui-notification[data-tone="warning"] .rui-notification-unread-dot {
3594
+ background: var(--rui-color-warning);
3595
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--rui-color-warning) 25%, transparent);
3596
+ }
3597
+ .rui-notification[data-tone="danger"] .rui-notification-unread-dot {
3598
+ background: var(--rui-color-danger);
3599
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--rui-color-danger) 25%, transparent);
3600
+ }
3601
+ .rui-notification[data-tone="info"] .rui-notification-unread-dot {
3602
+ background: var(--rui-color-info);
3603
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--rui-color-info) 25%, transparent);
3604
+ }
3684
3605
  .rui-notification-title {
3685
3606
  font-size: 14px;
3686
3607
  font-weight: 600;
3687
3608
  color: var(--rui-color-text);
3688
3609
  }
3610
+ .rui-notification[data-unread="true"] .rui-notification-title {
3611
+ font-weight: 700;
3612
+ }
3689
3613
  .rui-notification-time {
3690
3614
  font-size: 12px;
3691
3615
  color: var(--rui-color-text-muted);
3692
3616
  flex-shrink: 0;
3693
3617
  }
3618
+ .rui-notification[data-unread="true"] .rui-notification-time {
3619
+ color: var(--rui-color-primary);
3620
+ font-weight: 600;
3621
+ }
3622
+ .rui-notification[data-tone="success"][data-unread="true"] .rui-notification-time { color: var(--rui-color-success); }
3623
+ .rui-notification[data-tone="warning"][data-unread="true"] .rui-notification-time { color: var(--rui-color-warning); }
3624
+ .rui-notification[data-tone="danger"][data-unread="true"] .rui-notification-time { color: var(--rui-color-danger); }
3625
+ .rui-notification[data-tone="info"][data-unread="true"] .rui-notification-time { color: var(--rui-color-info); }
3694
3626
  .rui-notification-message {
3695
3627
  margin: 0;
3696
3628
  font-size: 13px;
@@ -6055,6 +5987,22 @@ button.rui-person-chip:hover { background: color-mix(in srgb, var(--rui-color-pr
6055
5987
  .rui-table td[data-align="right"], .rui-table th[data-align="right"] { text-align: right; }
6056
5988
  .rui-table td[data-align="left"], .rui-table th[data-align="left"] { text-align: left; }
6057
5989
 
5990
+ /* Clickable cells (Col onClick) — both Table and DataGrid. The whole cell
5991
+ is an accessible button; show affordance + a keyboard focus ring. */
5992
+ .rui-table td[data-clickable="true"],
5993
+ .rui-data-grid-table td[data-clickable="true"] {
5994
+ cursor: pointer;
5995
+ }
5996
+ .rui-table td[data-clickable="true"]:hover,
5997
+ .rui-data-grid-table td[data-clickable="true"]:hover {
5998
+ background: var(--rui-color-surface-hover, rgba(0, 0, 0, 0.04));
5999
+ }
6000
+ .rui-table td[data-clickable="true"]:focus-visible,
6001
+ .rui-data-grid-table td[data-clickable="true"]:focus-visible {
6002
+ outline: 2px solid var(--rui-color-primary, #6366f1);
6003
+ outline-offset: -2px;
6004
+ }
6005
+
6058
6006
  /* Pagination summary + per-page selector ------------------------------ */
6059
6007
  .rui-pagination {
6060
6008
  display: flex;
@@ -7430,8 +7378,22 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
7430
7378
  color: inherit;
7431
7379
  font: inherit;
7432
7380
  font-size: 13px;
7381
+ display: flex;
7382
+ align-items: center;
7383
+ justify-content: space-between;
7384
+ gap: 8px;
7385
+ }
7386
+ .rui-mention-input-option:hover,
7387
+ .rui-mention-input-option[data-active="true"] {
7388
+ background: color-mix(in srgb, var(--rui-color-primary) 14%, transparent);
7389
+ color: var(--rui-color-text);
7390
+ }
7391
+ .rui-mention-input-option-label { font-weight: 500; }
7392
+ .rui-mention-input-option-handle {
7393
+ color: var(--rui-color-text-muted);
7394
+ font-size: 12px;
7395
+ font-family: var(--rui-font-family-mono);
7433
7396
  }
7434
- .rui-mention-input-option:hover { background: color-mix(in srgb, var(--rui-color-text) 6%, transparent); }
7435
7397
 
7436
7398
  /* Time / DateTime / Masked input ---------------------------------- */
7437
7399
  .rui-time-picker,
@@ -7546,10 +7508,26 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
7546
7508
 
7547
7509
  /* MultiStepForm ------------------------------------------------ */
7548
7510
  .rui-multi-step-form {
7549
- display: flex;
7550
- flex-direction: column;
7511
+ display: grid;
7551
7512
  gap: 16px;
7552
7513
  }
7514
+ .rui-multi-step-form[data-layout="row"] {
7515
+ grid-template-columns: 1fr;
7516
+ grid-template-areas:
7517
+ "steps"
7518
+ "body"
7519
+ "footer";
7520
+ }
7521
+ .rui-multi-step-form[data-layout="column"] {
7522
+ grid-template-columns: 240px 1fr;
7523
+ grid-template-areas:
7524
+ "steps body"
7525
+ "steps footer";
7526
+ align-items: start;
7527
+ }
7528
+ .rui-multi-step-form > .rui-multi-step-form-steps { grid-area: steps; }
7529
+ .rui-multi-step-form > .rui-multi-step-form-body { grid-area: body; }
7530
+ .rui-multi-step-form > .rui-multi-step-form-footer { grid-area: footer; }
7553
7531
  .rui-multi-step-form-steps {
7554
7532
  display: flex;
7555
7533
  gap: 0;
@@ -7561,15 +7539,23 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
7561
7539
  border-radius: var(--rui-radius-md, 8px);
7562
7540
  overflow: hidden;
7563
7541
  }
7542
+ .rui-multi-step-form-steps[data-layout="row"] { flex-direction: row; }
7543
+ .rui-multi-step-form-steps[data-layout="column"] { flex-direction: column; }
7564
7544
  .rui-multi-step-form-steps .rui-steps-item {
7565
7545
  flex: 1;
7566
7546
  padding: 12px 16px 12px 52px;
7567
- border-right: 1px solid var(--rui-color-border);
7568
7547
  position: relative;
7569
7548
  color: var(--rui-color-text-muted);
7570
7549
  font-size: 13px;
7571
7550
  }
7572
- .rui-multi-step-form-steps .rui-steps-item:last-child { border-right: none; }
7551
+ .rui-multi-step-form-steps[data-layout="row"] .rui-steps-item {
7552
+ border-right: 1px solid var(--rui-color-border);
7553
+ }
7554
+ .rui-multi-step-form-steps[data-layout="row"] .rui-steps-item:last-child { border-right: none; }
7555
+ .rui-multi-step-form-steps[data-layout="column"] .rui-steps-item {
7556
+ border-bottom: 1px solid var(--rui-color-border);
7557
+ }
7558
+ .rui-multi-step-form-steps[data-layout="column"] .rui-steps-item:last-child { border-bottom: none; }
7573
7559
  .rui-multi-step-form-steps .rui-steps-item::before {
7574
7560
  left: 12px;
7575
7561
  top: 50%;
@@ -7579,6 +7565,10 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
7579
7565
  background: color-mix(in srgb, var(--rui-color-text) 12%, transparent);
7580
7566
  color: var(--rui-color-text-muted);
7581
7567
  }
7568
+ .rui-multi-step-form-steps[data-layout="column"] .rui-steps-item::before {
7569
+ top: 6px;
7570
+ transform: none;
7571
+ }
7582
7572
  .rui-multi-step-form-steps .rui-steps-item[data-active="true"]::before {
7583
7573
  background: var(--rui-color-primary);
7584
7574
  color: var(--rui-color-primary-text, #fff);
@@ -7627,6 +7617,15 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
7627
7617
  font-size: 13px;
7628
7618
  font-variant-numeric: tabular-nums;
7629
7619
  }
7620
+ @media (max-width: 720px) {
7621
+ .rui-multi-step-form[data-layout="column"] {
7622
+ grid-template-columns: 1fr;
7623
+ grid-template-areas:
7624
+ "steps"
7625
+ "body"
7626
+ "footer";
7627
+ }
7628
+ }
7630
7629
 
7631
7630
  /* Advanced charts (Area/Gauge/Heatmap/Radar/Scatter/Histogram) -- */
7632
7631
  .rui-chart { display: flex; flex-direction: column; gap: 10px; width: 100%; }
@@ -8384,63 +8383,73 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
8384
8383
  }
8385
8384
  .rui-lightbox-thumb img { display: block; width: 100%; height: auto; }
8386
8385
  .rui-lightbox-thumb:hover { border-color: var(--rui-color-primary); }
8387
- `,Zt="theme",Ye="streaming",Qt="response",je="showerrors",mi="route";function Kd(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),i={};if(typeof window<"u"&&window.location){const n=window.location.search||"";if(n){const s=new URLSearchParams(n.startsWith("?")?n.slice(1):n);for(const[l,c]of s)i[l]=c}}return{path:e,params:r,pattern:a,query:i,navigate(n){typeof n!="string"||!n||t.navigate(n)},toString(){return e}}}function Yd(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:gi(r.params??{},a.params??{})&&gi(r.query??{},a.query??{})}function gi(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const i of r)if(t[i]!==e[i])return!1;return!0}let er=null,vt=null;function Jd(){if(vt===!1)return null;if(er)return er;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return vt=!1,null;const t=new CSSStyleSheet;return t.replaceSync(pi),er=t,vt=!0,t}catch{return vt=!1,null}}const xt=class xt extends HTMLElement{constructor(){super();j(this,"state",new Ar);j(this,"router",new Er);j(this,"library",Ke);j(this,"http",new Pr);j(this,"i18n",new Qr);j(this,"effectRunner");j(this,"actionDeclRunner");j(this,"tools",{});j(this,"renderer");j(this,"context");j(this,"root");j(this,"rootEl");j(this,"errorEl");j(this,"currentResponse","");j(this,"renderScheduled",!1);j(this,"programDirty",!0);j(this,"parseErrors",[]);j(this,"scriptThemeKeys",[]);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=Jd();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}))},i=(n,s)=>{this.dispatchEvent(new CustomEvent(n,{detail:s,bubbles:!0,composed:!0}))};this.effectRunner=new ra({state:this.state,notify:()=>this.scheduleRender(),onEmit:i,host:this,tools:this.tools}),this.actionDeclRunner=new oa({state:this.state,notify:()=>this.scheduleRender(),onEmit:i,onAssistantMessage:a,host:this,tools:this.tools}),this.context=Pt(this.state,{router:this.router,library:this.library,http:this.http,i18n:this.i18n,actionRunner:this.actionDeclRunner,notify:()=>this.scheduleRender(),jsBlockExecutor:na({state:this.state,host:this,tools:this.tools})}),this.renderer=new Ja({library:this.library,state:this.state,router:this.router,onAssistantMessage:a,evaluationContext:()=>this.context,mountInstanceEffects:(n,s,l)=>this.effectRunner.syncInstanceEffects(n,s,l),unmountInstanceEffects:n=>this.effectRunner.unmountInstance(n)}),this.state.subscribe(()=>this.scheduleRender()),this.router.subscribe(n=>this.handleRouteChange(n))}static get observedAttributes(){return[Zt,Ye,Qt,je]}connectedCallback(){to(this.root),this.applyThemeFromAttribute(),this.startRouter(),this.attachPersistenceAdapter();const r=this.getAttribute(Qt);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.router.stop()}attributeChangedCallback(r,a,i){if(r===Zt&&this.applyThemeFromAttribute(),r===Ye&&(this.updateErrorBanner(),this.scheduleRender()),r===je&&this.updateErrorBanner(),r===Qt){const n=i??"";n!==this.currentResponse&&this.setResponse(n)}}registerHttpInterceptors(r){this.http.registerInterceptors(r)}setResponse(r){r!==this.currentResponse&&(this.currentResponse=r,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(),i=Gi(this.currentResponse,r);return Object.assign(a,i.stateUpdates),this.loadSnapshot({programText:i.programText,state:a}),i.warnings}loadSnapshot(r){this.currentResponse=r.programText,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.state.hydrate(r.state),this.scheduleRender()}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){Xt(this,Jt(r)),this.scriptThemeKeys=[],this.scheduleRender()}registerComponents(r,a){this.library=wr(this.library,{components:r,root:a}),this.renderer.setLibrary(this.library),this.scheduleRender()}getSystemPrompt(r){return Gt(this.library,r??{})}navigate(r){this.router.navigate(r)}setTools(r){for(const a of Object.keys(this.tools))delete this.tools[a];for(const[a,i]of Object.entries(r??{}))typeof i=="function"&&(this.tools[a]=i)}get route(){return this.router.getPath()}clear(){this.currentResponse="",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 fi(this.getAttribute(Ye))}set streaming(r){r?this.setAttribute(Ye,"true"):this.removeAttribute(Ye)}get showErrors(){return fi(this.getAttribute(je))}set showErrors(r){r?this.setAttribute(je,"true"):this.removeAttribute(je)}buildInlineStyle(){const r=document.createElement("style");return r.textContent=pi,r}startRouter(){this.router.start(),this.writeRouteState()}writeRouteState(){const r=Kd(this.router);Yd(this.state.get(mi),r)||this.state.set(mi,r)}attachPersistenceAdapter(){const r=typeof window<"u"?window.localStorage:null,a=`rui:${xt.tagName}:${this.id||"default"}`,i=Mr(a,r??null);this.state.setPersistenceAdapter(i)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender()}applyThemeFromAttribute(){const r=this.getAttribute(Zt);Xt(this,Jt(r)),this.scriptThemeKeys=[]}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(ci(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let a;try{a=r()}catch{return}if(!Nr(a))return;const i=ui(a.tokens);Object.keys(i).length!==0&&(this.scriptThemeKeys=li(this,i))}scheduleRender(){this.renderScheduled||(this.renderScheduled=!0,queueMicrotask(()=>this.renderNow()))}renderNow(){if(this.renderScheduled=!1,!this.isConnected)return;this.programDirty&&(this.replan(),this.programDirty=!1),this.applyScriptThemeOverrides();const r=this.context.bindings.get("_app_")??this.context.bindings.get("root");let a=null;if(r)try{a=r()}catch(s){console.error("[aktion] _app_ evaluation error",s)}this.renderer.beginRender();const i=this.captureFocus(),n=this.renderer.render(a);Xu(this.rootEl,n),this.renderer.endRender(),this.restoreFocus(i)}captureFocus(){const r=this.root.activeElement;if(!r||!this.rootEl.contains(r))return null;const a=r.id||null;if(!a)return null;const i={id:a,tagName:r.tagName};return(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(i.selectionStart=r.selectionStart,i.selectionEnd=r.selectionEnd,i.selectionDirection=r.selectionDirection??null),i}restoreFocus(r){if(!r)return;const a=this.rootEl.querySelector(`#${Xd(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&&Qd(a,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.context=Pt(this.state,{router:this.router,library:this.library,http:this.http,i18n:this.i18n,actionRunner:this.actionDeclRunner,notify:()=>this.scheduleRender(),jsBlockExecutor:na({state:this.state,host:this,tools:this.tools})});const r=fe(this.currentResponse),a=Nt(r,this.library);a.length>0&&(r.errors=[...r.errors,...a]),Wr(r,this.context);const i=[...this.context.effectDecls.values()];i.length>0&&this.effectRunner.syncEffects(i,()=>this.context),this.writeRouteState(),this.parseErrors=[...r.errors.map(n=>`Line ${n.line}: ${n.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 i of this.parseErrors.slice(0,5)){const n=document.createElement("li");n.textContent=i,a.append(n)}this.errorEl.replaceChildren(r,a)}};j(xt,"tagName","aktion-app");let Be=xt;function Xd(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const Zd=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function Qd(t,e,r,a){if(t instanceof HTMLInputElement&&Zd.has(t.type)){const i=t.type;try{t.type="text",t.setSelectionRange(e,r,a)}catch{}finally{t.type=i}return}try{t.setSelectionRange(e,r,a)}catch{}}function fi(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===je}function hi(){customElements.get(Be.tagName)||customElements.define(Be.tagName,Be)}const yt={name:"aktion",atoms:["true","false","null"],operators:["+","-","*","/","%","!","=","<",">","?",":",".",","],operatorsLong:["...","==","!=",">=","<=","&&","||","??","?."],brackets:[{open:"(",close:")"},{open:"[",close:"]"},{open:"{",close:"}"}],comments:{line:"//",extraLine:["#"],blockStart:"/*",blockEnd:"*/"},strings:{singleLineQuotes:['"',"'"],multiLineQuote:"`"},identifier:{start:/[A-Za-z_]/,part:/[A-Za-z0-9_]/},sigils:{builtin:"@",state:"$"}};function bi(t=yt){const e=()=>({inBacktick:!1,inBlockComment:!1}),r=p=>({...p}),a=new Set(t.atoms),i=/^[A-Z][A-Za-z0-9_]*/,n=/^[a-z_][A-Za-z0-9_]*/,s=/^-?\d+(?:\.\d+)?/,l=new Set([...t.operators.join(""),..."=<>!&|"]),c=(p,m)=>{for(;!p.eol();){const g=p.next();if(!g)return;if(g==="\\"){p.next();continue}if(g===m)return}};return{startState:e,copyState:r,token:(p,m)=>{if(m.inBacktick){for(;!p.eol();){const f=p.next();if(f==="\\"){p.next();continue}if(f==="`")return m.inBacktick=!1,"string"}return"string"}if(m.inBlockComment){for(;!p.eol();){if(p.match(t.comments.blockEnd,!0))return m.inBlockComment=!1,"comment";p.next()}return"comment"}if(p.eatWhile(/[ \t]/))return null;if(p.match(t.comments.line,!0))return p.skipToEnd(),"comment";for(const f of t.comments.extraLine)if(p.match(f,!0))return p.skipToEnd(),"comment";if(p.match(t.comments.blockStart,!0)){for(m.inBlockComment=!0;!p.eol();){if(p.match(t.comments.blockEnd,!0))return m.inBlockComment=!1,"comment";p.next()}return"comment"}const g=p.peek();if(g==null)return null;if(t.strings.singleLineQuotes.includes(g)){const f=g;return p.next(),c(p,f),"string"}if(g===t.strings.multiLineQuote){for(p.next();!p.eol();){const f=p.next();if(f==="\\"){p.next();continue}if(f==="`")return"string"}return m.inBacktick=!0,"string"}if(g>="0"&&g<="9"&&p.match(s,!0)||g==="-"&&p.match(/^-\d+(?:\.\d+)?/,!1)&&p.match(s,!0))return"number";if(g===t.sigils.builtin)return p.next(),p.eatWhile(t.identifier.part),"builtin";if(g===t.sigils.state)return p.next(),p.peek()===t.sigils.state&&p.next(),p.eatWhile(t.identifier.part),"state";if(t.identifier.start.test(g)){if(p.match(i,!0))return"component";const h=p.match(n,!0);if(h){const b=h[0];return a.has(b)?"atom":p.peek()==="."?"loopvar":"identifier"}}for(const f of t.operatorsLong)if(p.match(f,!0))return"operator";return g==="."?(p.next(),p.peek()&&t.identifier.start.test(p.peek())?(p.eatWhile(t.identifier.part),"property"):"punctuation"):"()[]{},:?".includes(g)?(p.next(),"punctuation"):l.has(g)?(p.next(),"operator"):(p.next(),null)},languageData:{commentTokens:{line:t.comments.line,block:{open:t.comments.blockStart,close:t.comments.blockEnd}},closeBrackets:{brackets:["(","[","{",'"',"'","`"]},indentOnInput:/^\s*[)\]}]$/}}}const vi={comment:"comment",string:"string",number:"number",atom:"atom",builtin:"keyword",state:"variableName.special",component:"typeName",identifier:"variableName",loopvar:"variableName.local",property:"propertyName",operator:"operator",punctuation:null},ep=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},tp=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},rp=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 yi(t=Ke){const e=rp(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(ep),signature:tp(r)}))}function xi(t){const e={};for(const r of t)e[r.name]=r;return e}const ap=[{name:"App",description:"Top-level `_app_` binding — every program needs one.",template:'_app_ = Stack([\n ${1:Card([CardHeader("${2:Hello}")])}\n])'},{name:"Card",description:"Card with header + body block.",template:`card\${1} = Card([
8388
- CardHeader("\${2:Title}", subtitle: "\${3:Subtitle}"),
8389
- Stack([
8386
+ `,Fr="theme",pt="streaming",Or="response",Qe="showerrors",Si="route";function lf(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,u]of o)n[s]=u}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function cf(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:Ci(r.params??{},a.params??{})&&Ci(r.query??{},a.query??{})}function Ci(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 _r=null,Vt=null;function uf(){if(Vt===!1)return null;if(_r)return _r;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return Vt=!1,null;const t=new CSSStyleSheet;return t.replaceSync(ki),_r=t,Vt=!0,t}catch{return Vt=!1,null}}class mt extends HTMLElement{constructor(){super();D(this,"state",new Aa);D(this,"router",new ja);D(this,"library",dt);D(this,"http",new Pa);D(this,"effectRunner");D(this,"actionDeclRunner");D(this,"renderer");D(this,"context");D(this,"root");D(this,"rootEl");D(this,"errorEl");D(this,"currentResponse","");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,"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=uf();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 pn({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i)}),this.actionDeclRunner=new gn({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i),onAssistantMessage:a}),this.context=or(this.state,{router:this.router,library:this.library,http:this.http,actionRunner:this.actionDeclRunner,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i)}),this.renderer=new si({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=>ln(this.context,n)}),this.state.subscribe(n=>{for(const i of n)this.pendingChangedPaths.add(i);(this.lastRenderDeps===null||vt(n,this.lastRenderDeps))&&this.scheduleRender()}),this.router.subscribe(n=>this.handleRouteChange(n))}static get observedAttributes(){return[Fr,pt,Or,Qe]}connectedCallback(){_s(this.root),this.applyThemeFromAttribute(),this.startRouter();const r=this.getAttribute(Or);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&&sr(this.context),this.router.stop()}attributeChangedCallback(r,a,n){if(r===Fr&&this.applyThemeFromAttribute(),r===pt&&(this.updateErrorBanner(),this.scheduleRender()),r===Qe&&this.updateErrorBanner(),r===Or){const i=n??"";i!==this.currentResponse&&this.setResponse(i)}}registerHttpInterceptors(r){this.http.registerInterceptors(r)}setResponse(r){r!==this.currentResponse&&(this.currentResponse=r,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=so(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.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.state.hydrate(r.state),this.scheduleRender()}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){Br(this,Dr(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 Rr(this.library,r??{})}navigate(r){this.router.navigate(r)}get route(){return this.router.getPath()}clear(){this.currentResponse="",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 $i(this.getAttribute(pt))}set streaming(r){r?this.setAttribute(pt,"true"):this.removeAttribute(pt)}get showErrors(){return $i(this.getAttribute(Qe))}set showErrors(r){r?this.setAttribute(Qe,"true"):this.removeAttribute(Qe)}emitCustomEvent(r,a){this.dispatchEvent(new CustomEvent(r,{detail:a,bubbles:!0,composed:!0}))}buildInlineStyle(){const r=document.createElement("style");return r.textContent=ki,r}startRouter(){this.router.start(),this.writeRouteState()}writeRouteState(){const r=lf(this.router);cf(this.state.get(Si),r)||this.state.set(Si,r)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender()}applyThemeFromAttribute(){const r=this.getAttribute(Fr);Br(this,Dr(r)),this.scriptThemeKeys=[]}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(yi(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let a;try{a=r()}catch{return}if(!Ca(a))return;const n=xi(a.tokens);Object.keys(n).length!==0&&(this.scriptThemeKeys=vi(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&&ar(this.context.budget);const r=new Set,a=this.context.trackedState;this.context.trackedState=r;let n=!1;this.state.beginRenderPass();try{this.applyScriptThemeOverrides(),qa(this.context);const i=this.context.bindings.get("aktion");let o=null;if(i)try{o=i()}catch(d){if(d instanceof Pe){this.handleRuntimeBudgetError(d);return}console.error("[aktion] entry point evaluation error",d)}const s=this.pendingChangedPaths;this.pendingChangedPaths=new Set;const u=!this.forceFullRender&&this.lastRenderDeps!==null;this.forceFullRender=!1,this.renderer.beginRender({changedPaths:s,memoize:u});const c=this.captureFocus();let m;try{m=this.renderer.render(o)}catch(d){if(this.renderer.endRender(),d instanceof Pe){this.handleRuntimeBudgetError(d);return}throw d}wm(this.rootEl,m),this.renderer.endRender(),this.restoreFocus(c),n=!0}finally{this.context.trackedState=a,this.lastRenderDeps=n?r: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 (`aktion = app()`), 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(`#${df(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&&mf(a,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.lastRenderDeps=null,this.warnedStateWriteDuringRender=!1,this.context&&sr(this.context),this.context=or(this.state,{router:this.router,library:this.library,http:this.http,actionRunner:this.actionDeclRunner,notify:()=>this.requestFullRender(),onEmit:(i,o)=>this.emitCustomEvent(i,o)});const r=$e(this.currentResponse),a=Zt(r,this.library);a.length>0&&(r.errors=[...r.errors,...a]),this.context.budget&&ar(this.context.budget);try{Ga(r,this.context)}catch(i){if(i instanceof Pe)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(mt,"tagName","aktion-app");function df(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const pf=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function mf(t,e,r,a){if(t instanceof HTMLInputElement&&pf.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 $i(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===Qe}function Ti(){customElements.get(mt.tagName)||customElements.define(mt.tagName,mt)}const ff=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},gf=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},hf=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 Ai(t=dt){const e=hf(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(ff),signature:gf(r)}))}function Ni(t){const e={};for(const r of t)e[r.name]=r;return e}const bf=[{name:"App",description:"Top-level `aktion` binding — every program needs one.",template:'aktion = Column([\n ${1:Card([CardHeader("${2:Hello}")])}\n])'},{name:"Card",description:"Card with header + body block.",template:`card\${1} = Card([
8387
+ CardHeader("\${2:Title}", { subtitle: "\${3:Subtitle}" }),
8388
+ Column([
8390
8389
  Text("\${4:Body copy goes here.}")
8391
8390
  ])
8392
- ])`},{name:"Hero",description:"Landing-page hero with eyebrow, title, subtitle, and a CTA.",template:'action ${4:Start}() { _route_.navigate("/start") }\naction ${5:OpenDemo}() { _route_.navigate("/demo") }\nhero${1} = Hero(\n "${2:Ship faster}",\n subtitle: "${3:From idea to production in minutes.}",\n primary: Button("${6:Get started}", action: ${4:Start}, variant: "primary"),\n secondary: Button("${7:Live demo}", action: ${5:OpenDemo}, variant: "ghost"),\n eyebrow: "${8:v2 launch}"\n)'},{name:"PageHeader",description:"Dashboard page header with breadcrumbs and actions.",template:'action ${6:RunAction}() { /* TODO: implement */ }\nheader${1} = PageHeader(\n "${2:Page title}",\n subtitle: "${3:Subtitle / meta line}",\n breadcrumbs: ["${4:Workspace}", "${5:Section}"],\n actions: [Button("${7:Action}", action: ${6:RunAction}, variant: "primary")],\n status: Badge("${8:On track}", variant: "success")\n)'},{name:"Stats",description:"Responsive KPI strip with four StatCards.",template:'metrics${1} = Stats([\n StatCard("${2:Active}", value: "${3:12}", trend: "flat"),\n StatCard("${4:At risk}", value: "${5:4}", trend: "up", delta: "+2"),\n StatCard("${6:Shipped}", value: "${7:8}", trend: "up", delta: "+3"),\n StatCard("${8:On-time}", value: "${9:87%}", trend: "down", delta: "-3%")\n])'},{name:"GridLayout",description:"12-column sidebar layout with named GridItem spans.",template:'sidebar${1} = Card([CardHeader("${2:Sidebar}")])\nmain${1} = Card([CardHeader("${3:Main}")])\n_app_ = Grid([\n GridItem(sidebar${1}, span: "1/4"),\n GridItem(main${1}, span: "3/4")\n], columns: 12, gap: "l")'},{name:"KanbanBoard",description:"Three-column kanban board with sample cards.",template:'board${1} = KanbanBoard([\n KanbanColumn("To do", items: [\n KanbanCard("${2:Migrate auth}", description: "${3:Roll out the new SDK.}", tags: ["auth"], assignee: "${4:Asha}")\n ]),\n KanbanColumn("Doing", items: [\n KanbanCard("${5:Streaming UI v2}", description: "${6:Ship 20 new components.}", tags: ["frontend"], assignee: "${7:Alex}", tone: "primary")\n ]),\n KanbanColumn("Done", items: [\n KanbanCard("${8:Activity timeline}", description: "${9:Shipped to 100%.}", tags: ["shipped"], assignee: "${10:Mira}", tone: "success")\n ])\n])'},{name:"FollowUpBlock",description:"Chat follow-up prompts.",template:'follow${1} = FollowUpBlock([\n FollowUpItem("${2:Show me a chart}"),\n FollowUpItem("${3:Add a filter}"),\n FollowUpItem("${4:Export as CSV}")\n])'},{name:"Router",description:"Multi-page router via _router_({…}) with NavLink sidebar.",template:`pages = _router_({
8393
- "/": homePage(),
8394
- "/dashboard": dashboardPage(),
8395
- "/users/:id": userPage(id: params.id),
8396
- "/docs/*": docsPage(rest: params._),
8397
- default: notFoundPage()
8391
+ ])`},{name:"Row",description:"Horizontal toolbar — label on the left, actions pushed to the right.",template:`toolbar\${1} = Row([
8392
+ Text("\${2:Section title}", { variant: "large-heavy" }),
8393
+ Spacer(),
8394
+ Button("\${3:Action}", { variant: "primary" })
8395
+ ], { gap: "m" })`},{name:"Center",description:"Center content on both axes inside a tall region.",template:'empty${1} = Center([\n EmptyState("${2:Nothing here yet}", { description: "${3:Create your first item to get started.}" })\n], { minHeight: "${4:50vh}" })'},{name:"Hero",description:"Landing-page hero with eyebrow, title, subtitle, and a CTA.",template:'function ${4:start}() { route.navigate("/start") }\nfunction ${5:openDemo}() { route.navigate("/demo") }\nhero${1} = Hero(\n "${2:Ship faster}",\n { subtitle: "${3:From idea to production in minutes.}",\n primary: Button("${6:Get started}", { action: ${4:start}, variant: "primary" }),\n secondary: Button("${7:Live demo}", { action: ${5:openDemo}, variant: "ghost" }),\n eyebrow: "${8:v2 launch}" }\n)'},{name:"PageHeader",description:"Dashboard page header with breadcrumbs and actions.",template:'function ${6:runAction}() { /* TODO: implement */ }\nheader${1} = PageHeader(\n "${2:Page title}",\n { subtitle: "${3:Subtitle / meta line}",\n breadcrumbs: ["${4:Workspace}", "${5:Section}"],\n actions: [Button("${7:Action}", { action: ${6:runAction}, variant: "primary" })],\n status: Badge("${8:On track}", { variant: "success" }) }\n)'},{name:"Stats",description:"Responsive KPI strip with four StatCards.",template:'metrics${1} = Stats([\n StatCard("${2:Active}", { value: "${3:12}", trend: "flat" }),\n StatCard("${4:At risk}", { value: "${5:4}", trend: "up", delta: "+2" }),\n StatCard("${6:Shipped}", { value: "${7:8}", trend: "up", delta: "+3" }),\n StatCard("${8:On-time}", { value: "${9:87%}", trend: "down", delta: "-3%" })\n])'},{name:"GridLayout",description:"12-column sidebar layout with named GridItem spans.",template:'sidebar${1} = Card([CardHeader("${2:Sidebar}")])\nmain${1} = Card([CardHeader("${3:Main}")])\naktion = Grid([\n GridItem(sidebar${1}, { span: "1/4" }),\n GridItem(main${1}, { span: "3/4" })\n], { columns: 12, gap: "l" })'},{name:"KanbanBoard",description:"Three-column kanban board with sample cards.",template:'board${1} = KanbanBoard([\n KanbanColumn("To do", { items: [\n KanbanCard("${2:Migrate auth}", { description: "${3:Roll out the new SDK.}", tags: ["auth"], assignee: "${4:Asha}" })\n ] }),\n KanbanColumn("Doing", { items: [\n KanbanCard("${5:Streaming UI v2}", { description: "${6:Ship 20 new components.}", tags: ["frontend"], assignee: "${7:Alex}", tone: "primary" })\n ] }),\n KanbanColumn("Done", { items: [\n KanbanCard("${8:Activity timeline}", { description: "${9:Shipped to 100%.}", tags: ["shipped"], assignee: "${10:Mira}", tone: "success" })\n ] })\n])'},{name:"FollowUpBlock",description:"Chat follow-up prompts.",template:'follow${1} = FollowUpBlock([\n FollowUpItem("${2:Show me a chart}"),\n FollowUpItem("${3:Add a filter}"),\n FollowUpItem("${4:Export as CSV}")\n])'},{name:"Router",description:"Multi-page router via $router({…}) with NavLink sidebar.",template:`pages = $router({
8396
+ "/": HomePage(),
8397
+ "/dashboard": DashboardPage(),
8398
+ "/users/:id": UserPage(params.id),
8399
+ "/docs/*": DocsPage(params._),
8400
+ default: NotFoundPage()
8398
8401
  })
8399
8402
 
8400
- component homePage() {
8403
+ function HomePage() {
8401
8404
  return Card([CardHeader("Welcome")])
8402
8405
  }
8403
- component dashboardPage() {
8406
+ function DashboardPage() {
8404
8407
  return Card([CardHeader("Dashboard")])
8405
8408
  }
8406
- component userPage(id) {
8409
+ function UserPage(id) {
8407
8410
  return Card([CardHeader(\`User \${id}\`)])
8408
8411
  }
8409
- component docsPage(rest) {
8412
+ function DocsPage(rest) {
8410
8413
  return Card([CardHeader(\`Docs · \${rest}\`)])
8411
8414
  }
8412
- component notFoundPage() {
8413
- return Callout("Not found", variant: "warning", description: \`We couldn't find \${_route_.path}.\`)
8415
+ function NotFoundPage() {
8416
+ return Callout("Not found", { variant: "warning", description: \`We couldn't find \${route.path}.\` })
8414
8417
  }
8415
8418
 
8416
- nav\${1} = Stack([
8417
- NavLink("Home", to: "/", variant: "ghost", exact: true),
8418
- NavLink("Dashboard", to: "/dashboard", variant: "ghost"),
8419
- NavLink("Users", to: "/users", variant: "ghost")
8420
- ], direction: "row", gap: "s")`},{name:"Effect",description:"Lifecycle-managed effect (clock/interval) with cleanup.",template:`$\${3:now} = ""
8419
+ nav\${1} = Row([
8420
+ NavLink("Home", { to: "/", variant: "ghost", exact: true }),
8421
+ NavLink("Dashboard", { to: "/dashboard", variant: "ghost" }),
8422
+ NavLink("Users", { to: "/users", variant: "ghost" })
8423
+ ], { gap: "s" })`},{name:"Effect",description:"Lifecycle-managed effect (clock/interval) with cleanup.",template:`$\${3:now} = ""
8421
8424
 
8422
- effect [on:mount] {
8423
- let id = js{ setInterval(() => helpers.setState("\${3:now}", new Date().toISOString()), 1000) }
8424
- cleanup { js{ clearInterval(id) } }
8425
- }
8425
+ $effect(() => {
8426
+ let id = setInterval(() => { $\${3:now} = new Date().toISOString() }, 1000)
8427
+ cleanup(() => clearInterval(id))
8428
+ }, ["mount"])
8426
8429
 
8427
- body = Text($\${3:now})`},{name:"Action",description:"Action declaration that POSTs through the http() builtin.",template:`$\${1:items} = []
8430
+ body = Text($\${3:now})`},{name:"Action",description:"Action declaration that POSTs through the $http() builtin.",template:`$\${1:items} = []
8428
8431
 
8429
- action Add(text) {
8432
+ function add(text) {
8430
8433
  $\${1:items} = [...$\${1:items}, { id: $\${1:items}.length + 1, text: text }]
8431
- $response = http({ url: "/api/save", method: "POST", body: { item: { text: text } } })
8432
- }`},{name:"Each",description:"Iterate over an array using the expression-form `for` loop.",template:"list${1} = for item in $items {\n Card([Text(item.${2:name})])\n}"},{name:"FormReactive",description:"Two-way bound input with submit action.",template:`$draft = ""
8434
+ $response = $http({ url: "https://api.example.com/save", method: "POST", body: { item: { text: text } } })
8435
+ }`},{name:"MapList",description:"Map an array of items into a list of components using `.map`.",template:"list${1} = $items.map(item => Card([Text(item.${2:name})]))"},{name:"ForLoop",description:"Iterate over an array statement-style — usable in a function body.",template:`function build\${1:List}() {
8436
+ let out = []
8437
+ for (let item of $items) {
8438
+ out.push(Card([Text(item.\${2:name})]))
8439
+ }
8440
+ return Column(out)
8441
+ }`},{name:"FormReactive",description:"Two-way bound input with submit action.",template:`$draft = ""
8433
8442
  $items = []
8434
8443
 
8435
- action Add() {
8444
+ function add() {
8436
8445
  $items = [...$items, { id: $items.length + 1, text: $draft }]
8437
8446
  $draft = ""
8438
8447
  }
8439
8448
 
8440
- form\${1} = Stack([
8441
- Input("\${2:draft}", placeholder: "What needs doing?", type: "text", bind:value: $draft),
8442
- Button("Add", action: Add, variant: "primary")
8443
- ])`},{name:"Theme",description:"Brand-style theme override applied on top of the base theme.",template:`theme = Theme({
8449
+ form\${1} = Column([
8450
+ Input("\${2:draft}", { placeholder: "What needs doing?", type: "text", value: $draft }),
8451
+ Button("Add", { action: add, variant: "primary" })
8452
+ ])`},{name:"Theme",description:"Brand-style theme override applied on top of the base theme.",template:`theme = $theme({
8444
8453
  name: "\${1:brand}",
8445
8454
  colors: {
8446
8455
  primary: "\${2:#0969da}",
@@ -8453,21 +8462,20 @@ form\${1} = Stack([
8453
8462
  family: "\${8:-apple-system, BlinkMacSystemFont, sans-serif}",
8454
8463
  heading: "\${9:-apple-system, BlinkMacSystemFont, sans-serif}"
8455
8464
  }
8456
- })`},{name:"Component",description:"Reusable component declaration — components MUST `return`.",template:`component \${1:UserCard}(\${2:user}) {
8465
+ })`},{name:"Component",description:"Reusable component declaration — first-letter case is not significant; a function with no `return` simply renders nothing.",template:`function \${1:UserCard}(\${2:user}) {
8457
8466
  return Card([
8458
8467
  Avatar(\${2:user}.name),
8459
8468
  Text(\${2:user}.role)
8460
8469
  ])
8461
8470
  }
8462
8471
 
8463
- list = for u in $users { \${1:UserCard}(u) }`},{name:"If",description:"Expression-form `if`.",template:"body${1} = if ${2:condition} {\n ${3:trueBranch}\n} else {\n ${4:falseBranch}\n}"},{name:"Match",description:"Pattern match on a value with arms.",template:`panel\${1} = match \${2:$tab} {
8464
- "overview" : overviewPanel
8465
- "billing" : billingPanel
8466
- "security" : securityPanel
8467
- default : overviewPanel
8468
- }`},{name:"TemplateLiteral",description:"Template literal with `${}` interpolation.",template:"greeting${1} = `Hello ${${2:$user.name}}, you have ${${3:$messages.length}} messages`"},{name:"Http",description:"Fire an http() request and bind the reactive resource bag.",template:`$\${1:response} = http({
8469
- url: "\${2:/api/items}",
8472
+ list = $users.map(u => \${1:UserCard}(u))`},{name:"Ternary",description:"Pick between two expressions — the JS way to express a value-producing if.",template:"body${1} = ${2:condition} ? ${3:trueBranch} : ${4:falseBranch}"},{name:"IfStatement",description:"Imperative `if (cond) { … } else { … }` — usable inside function / effect bodies.",template:`if (\${1:condition}) {
8473
+ \${2:// then branch}
8474
+ } else {
8475
+ \${3:// else branch}
8476
+ }`},{name:"SwitchStatement",description:"Switch on a value with case/default/break — statement form.",template:'switch (${1:$tab}) {\n case "overview": ${2:// …}; break\n case "billing": ${3:// …}; break\n case "security": ${4:// …}; break\n default: ${5:// …}\n}'},{name:"TemplateLiteral",description:"Template literal with `${}` interpolation.",template:"greeting${1} = `Hello ${${2:$user.name}}, you have ${${3:$messages.length}} messages`"},{name:"Http",description:"Fire an $http() request and bind the reactive resource bag.",template:`$\${1:response} = $http({
8477
+ url: "\${2:https://api.example.com/items}",
8470
8478
  method: "\${3:GET}",
8471
8479
  headers: { "Content-Type": "application/json" }
8472
- })`},{name:"State",description:"Reactive state atom — declared with `$name = value`.",template:'$${1:name} = ${2:"default"}'},{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 wi(){return ap}function ip(t=Ke){const e=yi(t),r=gt();return{grammar:yt,tokenizer:bi(yt),tagMap:vi,components:e,componentsByName:xi(e),builtins:r,builtinsByName:ei(r),snippets:wi(),themeNames:Object.keys(Yt),severityTokenMap:{"parse-error":"error"},iconAliases:np}}const np=["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"];hi();const op=Gt(Ke);I.ActionDeclRunner=oa,I.AktionElement=Be,I.EffectRunner=ra,I.HttpRuntime=Pr,I.I18nRuntime=Qr,I.Renderer=Ja,I.Router=Er,I.SYSTEM_PROMPT_TEXT=op,I.StateStore=Ar,I.applyPartialTheme=li,I.applyTheme=Xt,I.assertOnePositionalMax=kr,I.brutalistTheme=oi,I.buildFrontier=br,I.builtInThemes=Yt,I.clearTokenOverrides=ci,I.computeFrontier=Hi,I.consoleNs=Or,I.createContext=Pt,I.createHttpResource=Rr,I.createLocalStorageAdapter=Mr,I.createStreamTokenizer=bi,I.darkTheme=ri,I.dataBuiltins=At,I.defaultLibrary=Ke,I.defaultTagMap=vi,I.defineElement=hi,I.describeComponentSpec=sd,I.evaluate=M,I.evaluateUserComponent=Kr,I.findComponent=Ie,I.findPositionalIndex=Tt,I.findPositionalProp=$t,I.generatePrompt=Gt,I.getBuiltinCatalog=gt,I.getComponentCatalog=yi,I.getLanguageSpec=ip,I.getSnippets=wi,I.glassTheme=ni,I.grammarSpec=yt,I.indexBuiltins=ei,I.indexCatalog=xi,I.isComponentNode=qr,I.isQuiescent=Vi,I.isThemeNode=Nr,I.isUserComponentNode=Hr,I.lightTheme=ue,I.mapPositionalArgs=Sr,I.matchRoute=Lr,I.mergeLibraries=wr,I.neonTheme=ai,I.normalisePath=we,I.parse=fe,I.pastelTheme=ii,I.planProgram=Wr,I.resolveStateAlias=ke,I.resolveTheme=Jt,I.sanitiseThemeTokens=ui,I.skylineTheme=si,I.storage=Fr,I.tokenize=ir,I.validateProgram=Xi,I.validateProgramSchema=Nt,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
8480
+ })`},{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 Mi(){return bf}function vf(t=dt){const e=Ai(t);return{grammar:bt,tokenizer:wa(bt),tagMap:ka,components:e,componentsByName:Ni(e),snippets:Mi(),keywordDocs:xa,themeNames:Object.keys(jr),severityTokenMap:{"parse-error":"error"},iconAliases:yf}}const yf=["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"];Ti();const xf=Rr(dt);P.ActionDeclRunner=gn,P.AktionElement=mt,P.BreakSignal=we,P.ContinueSignal=Ce,P.DEFAULT_RUNTIME_BUDGET=wt,P.EffectRunner=pn,P.HttpRuntime=Pa,P.Renderer=si,P.ReturnSignal=Ie,P.Router=ja,P.RuntimeBudgetError=Pe,P.SYSTEM_PROMPT_TEXT=xf,P.StateStore=Aa,P.anyPathAffects=Qt,P.applyPartialTheme=vi,P.applyTheme=Br,P.assertOnePositionalMax=ba,P.brutalistTheme=hi,P.buildFrontier=pa,P.builtInThemes=jr,P.clearInstanceHooks=ln,P.clearTokenOverrides=yi,P.computeFrontier=no,P.consoleNs=_a,P.createContext=or,P.createHttpResource=Ia,P.createI18n=La,P.createRuntimeBudget=Ha,P.createStreamTokenizer=wa,P.darkTheme=pi,P.dataBuiltins=Sa,P.defaultLibrary=dt,P.defaultTagMap=ka,P.defineElement=Ti,P.describeComponentSpec=Nm,P.disposeContext=sr,P.enterUserComponent=nr,P.evaluate=N,P.evaluateUserComponent=tn,P.extractStatePath=St,P.findComponent=Ne,P.findPositionalIndex=Xt,P.findPositionalProp=Jt,P.generatePrompt=Rr,P.getComponentCatalog=Ai,P.getLanguageSpec=vf,P.getSnippets=Mi,P.glassTheme=gi,P.grammarSpec=bt,P.indexCatalog=Ni,P.isComponentNode=Va,P.isEndpointResource=Ma,P.isQuiescent=io,P.isStoreHandle=kt,P.isThemeNode=Ca,P.isUserComponentNode=Wa,P.joinStatePath=$a,P.keywordDocs=xa,P.leaveUserComponent=ir,P.lightTheme=be,P.mapPositionalArgs=va,P.matchRoute=Ea,P.mergeLibraries=ha,P.neonTheme=mi,P.normalisePath=De,P.parse=$e,P.pastelTheme=fi,P.pathAffects=Ta,P.pathsOverlap=vt,P.planProgram=Ga,P.resetMutableBindings=qa,P.resetRuntimeBudget=ar,P.resolvePatternBindings=ot,P.resolveStateAlias=xe,P.resolveTheme=Dr,P.runControlFlowStatement=At,P.sanitiseThemeTokens=xi,P.skylineTheme=bi,P.storage=tr,P.tokenize=Vr,P.validateProgram=po,P.validateProgramSchema=Zt,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
8473
8481
  //# sourceMappingURL=aktion.umd.cjs.map