@maxhealth.tech/prefab 0.3.18 → 0.3.19

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 (140) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/a2ui/browser.js +1 -2
  3. package/dist/a2ui/browser.js.map +1 -1
  4. package/dist/a2ui/expr.d.ts +7 -54
  5. package/dist/a2ui/expr.d.ts.map +1 -1
  6. package/dist/a2ui/expr.js +13 -90
  7. package/dist/a2ui/expr.js.map +1 -1
  8. package/dist/a2ui/icons.d.ts +3 -25
  9. package/dist/a2ui/icons.d.ts.map +1 -1
  10. package/dist/a2ui/icons.js +4 -33
  11. package/dist/a2ui/icons.js.map +1 -1
  12. package/dist/a2ui/types.d.ts +7 -54
  13. package/dist/a2ui/types.d.ts.map +1 -1
  14. package/dist/a2ui/types.js +2 -21
  15. package/dist/a2ui/types.js.map +1 -1
  16. package/dist/a2ui.min.js +1 -1
  17. package/dist/actions/subscribe.d.ts +3 -18
  18. package/dist/actions/subscribe.d.ts.map +1 -1
  19. package/dist/actions/subscribe.js +2 -17
  20. package/dist/actions/subscribe.js.map +1 -1
  21. package/dist/components/pdf/index.d.ts +3 -9
  22. package/dist/components/pdf/index.d.ts.map +1 -1
  23. package/dist/components/pdf/index.js +2 -8
  24. package/dist/components/pdf/index.js.map +1 -1
  25. package/dist/core/escape.d.ts +1 -19
  26. package/dist/core/escape.d.ts.map +1 -1
  27. package/dist/core/escape.js +1 -19
  28. package/dist/core/escape.js.map +1 -1
  29. package/dist/core/humanize.d.ts +2 -17
  30. package/dist/core/humanize.d.ts.map +1 -1
  31. package/dist/core/humanize.js +8 -20
  32. package/dist/core/humanize.js.map +1 -1
  33. package/dist/core/logger.d.ts +1 -9
  34. package/dist/core/logger.d.ts.map +1 -1
  35. package/dist/core/logger.js +1 -9
  36. package/dist/core/logger.js.map +1 -1
  37. package/dist/core/stringify.d.ts +2 -19
  38. package/dist/core/stringify.d.ts.map +1 -1
  39. package/dist/core/stringify.js +3 -21
  40. package/dist/core/stringify.js.map +1 -1
  41. package/dist/core/validate.d.ts.map +1 -1
  42. package/dist/core/validate.js +23 -26
  43. package/dist/core/validate.js.map +1 -1
  44. package/dist/core/version.d.ts +3 -22
  45. package/dist/core/version.d.ts.map +1 -1
  46. package/dist/core/version.js +3 -22
  47. package/dist/core/version.js.map +1 -1
  48. package/dist/mcp/a2ui.d.ts +6 -36
  49. package/dist/mcp/a2ui.d.ts.map +1 -1
  50. package/dist/mcp/a2ui.js +6 -36
  51. package/dist/mcp/a2ui.js.map +1 -1
  52. package/dist/mcp/input-required.d.ts.map +1 -1
  53. package/dist/mcp/input-required.js +2 -8
  54. package/dist/mcp/input-required.js.map +1 -1
  55. package/dist/mcp/resource.d.ts +12 -88
  56. package/dist/mcp/resource.d.ts.map +1 -1
  57. package/dist/mcp/resource.js +18 -85
  58. package/dist/mcp/resource.js.map +1 -1
  59. package/dist/mcp/result.d.ts +2 -27
  60. package/dist/mcp/result.d.ts.map +1 -1
  61. package/dist/mcp/result.js +2 -27
  62. package/dist/mcp/result.js.map +1 -1
  63. package/dist/mcp/theme-bridge.d.ts +5 -36
  64. package/dist/mcp/theme-bridge.d.ts.map +1 -1
  65. package/dist/mcp/theme-bridge.js +6 -43
  66. package/dist/mcp/theme-bridge.js.map +1 -1
  67. package/dist/mcp/types.d.ts +11 -106
  68. package/dist/mcp/types.d.ts.map +1 -1
  69. package/dist/mcp/types.js +2 -22
  70. package/dist/mcp/types.js.map +1 -1
  71. package/dist/renderer/actions.d.ts +2 -2
  72. package/dist/renderer/actions.d.ts.map +1 -1
  73. package/dist/renderer/actions.js +6 -2
  74. package/dist/renderer/actions.js.map +1 -1
  75. package/dist/renderer/app.d.ts.map +1 -1
  76. package/dist/renderer/app.js +3 -2
  77. package/dist/renderer/app.js.map +1 -1
  78. package/dist/renderer/auto.js +9 -4
  79. package/dist/renderer/auto.js.map +1 -1
  80. package/dist/renderer/bridge.d.ts +3 -7
  81. package/dist/renderer/bridge.d.ts.map +1 -1
  82. package/dist/renderer/bridge.js +38 -64
  83. package/dist/renderer/bridge.js.map +1 -1
  84. package/dist/renderer/components/alert.d.ts.map +1 -1
  85. package/dist/renderer/components/alert.js +4 -2
  86. package/dist/renderer/components/alert.js.map +1 -1
  87. package/dist/renderer/components/choice.d.ts.map +1 -1
  88. package/dist/renderer/components/choice.js +5 -4
  89. package/dist/renderer/components/choice.js.map +1 -1
  90. package/dist/renderer/components/control.d.ts.map +1 -1
  91. package/dist/renderer/components/control.js +16 -9
  92. package/dist/renderer/components/control.js.map +1 -1
  93. package/dist/renderer/components/data.d.ts.map +1 -1
  94. package/dist/renderer/components/data.js +17 -15
  95. package/dist/renderer/components/data.js.map +1 -1
  96. package/dist/renderer/components/form.d.ts.map +1 -1
  97. package/dist/renderer/components/form.js +18 -17
  98. package/dist/renderer/components/form.js.map +1 -1
  99. package/dist/renderer/components/interactive.d.ts.map +1 -1
  100. package/dist/renderer/components/interactive.js +3 -2
  101. package/dist/renderer/components/interactive.js.map +1 -1
  102. package/dist/renderer/components/media.d.ts.map +1 -1
  103. package/dist/renderer/components/media.js +13 -10
  104. package/dist/renderer/components/media.js.map +1 -1
  105. package/dist/renderer/components/pdf.d.ts +1 -10
  106. package/dist/renderer/components/pdf.d.ts.map +1 -1
  107. package/dist/renderer/components/pdf.js +19 -14
  108. package/dist/renderer/components/pdf.js.map +1 -1
  109. package/dist/renderer/components/table.js +2 -2
  110. package/dist/renderer/components/table.js.map +1 -1
  111. package/dist/renderer/components/typography.d.ts.map +1 -1
  112. package/dist/renderer/components/typography.js +4 -2
  113. package/dist/renderer/components/typography.js.map +1 -1
  114. package/dist/renderer/engine.d.ts.map +1 -1
  115. package/dist/renderer/engine.js +5 -6
  116. package/dist/renderer/engine.js.map +1 -1
  117. package/dist/renderer/host-context.d.ts +8 -0
  118. package/dist/renderer/host-context.d.ts.map +1 -0
  119. package/dist/renderer/host-context.js +62 -0
  120. package/dist/renderer/host-context.js.map +1 -0
  121. package/dist/renderer/index.d.ts.map +1 -1
  122. package/dist/renderer/index.js +20 -20
  123. package/dist/renderer/index.js.map +1 -1
  124. package/dist/renderer/rx.d.ts.map +1 -1
  125. package/dist/renderer/rx.js +17 -24
  126. package/dist/renderer/rx.js.map +1 -1
  127. package/dist/renderer/state.d.ts.map +1 -1
  128. package/dist/renderer/state.js +10 -4
  129. package/dist/renderer/state.js.map +1 -1
  130. package/dist/renderer.auto.min.js +10 -10
  131. package/dist/renderer.min.js +10 -10
  132. package/dist/rx/pipes.d.ts +3 -19
  133. package/dist/rx/pipes.d.ts.map +1 -1
  134. package/dist/rx/pipes.js +3 -19
  135. package/dist/rx/pipes.js.map +1 -1
  136. package/dist/rx/signal.d.ts +3 -13
  137. package/dist/rx/signal.d.ts.map +1 -1
  138. package/dist/rx/signal.js +2 -9
  139. package/dist/rx/signal.js.map +1 -1
  140. package/package.json +1 -1
@@ -1,16 +1,16 @@
1
- (()=>{var{defineProperty:lt,getOwnPropertyNames:mr,getOwnPropertyDescriptor:gr}=Object,hr=Object.prototype.hasOwnProperty;function br(e){return this[e]}var yr=(e)=>{var t=(Wt??=new WeakMap).get(e),n;if(t)return t;if(t=lt({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var r of mr(e))if(!hr.call(t,r))lt(t,r,{get:br.bind(e,r),enumerable:!(n=gr(e,r))||n.enumerable})}return Wt.set(e,t),t},Wt;var Cr=(e)=>e;function xr(e,t){this[e]=Cr.bind(null,t)}var wr=(e,t)=>{for(var n in t)lt(e,n,{get:t[n],enumerable:!0,configurable:!0,set:xr.bind(t,n)})};var us={};wr(us,{Bridge:()=>ge,DestroyRegistry:()=>Le,PrefabRenderer:()=>U,app:()=>st,applyHostTheme:()=>De,createLogger:()=>ct,createThemeToggle:()=>Oe,getLogLevel:()=>Jt,isIframe:()=>ve,isValidWireFormat:()=>ar,listPipes:()=>je,log:()=>T,registerComponent:()=>p,registerPipe:()=>Ee,setLogLevel:()=>Ie,unregisterPipe:()=>Re,validateWireFormat:()=>ke});var Kt={silent:0,error:1,warn:2,info:3,debug:4},dt="warn";function Ie(e){dt=e}function Jt(){return dt}function ct(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,i)=>{if(Kt[r]>Kt[dt])return;console[r](`${t} ${o}`,...i)};return{error:(r,...o)=>n("error",r,o),warn:(r,...o)=>n("warn",r,o),info:(r,...o)=>n("info",r,o),debug:(r,...o)=>n("debug",r,o)}}var T=ct();class Se{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return vr(this.data,e)}getAll(){return this.data}set(e,t){Gt(this.data,e,t),this.notify(e)}toggle(e){let t=this.get(e),n=t==null||t===!1||t===0||t==="";this.set(e,n)}append(e,t,n){let r=this.get(e);if(!Array.isArray(r)){this.set(e,[t]);return}if(n!==void 0)r.splice(n,0,t);else r.push(t);this.notify(e)}pop(e,t){let n=this.get(e);if(!Array.isArray(n))return;if(typeof t==="number")n.splice(t,1);else{let r=n.indexOf(t);if(r>=0)n.splice(r,1)}this.notify(e)}merge(e){for(let[t,n]of Object.entries(e))Gt(this.data,t,n);for(let t of Object.keys(e))this.notify(t)}subscribe(e,t){if(!this.subscribers.has(e))this.subscribers.set(e,new Set);return this.subscribers.get(e)?.add(t),()=>this.subscribers.get(e)?.delete(t)}subscribeAll(e){return this.globalSubscribers.add(e),()=>this.globalSubscribers.delete(e)}notify(e){this.generation++;let t=e.split(".");for(let n=1;n<=t.length;n++){let r=t.slice(0,n).join("."),o=this.subscribers.get(r);if(o)o.forEach((i)=>i())}this.globalSubscribers.forEach((n)=>n())}}function vr(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=r[o]}return r}var kr=new Set(["__proto__","constructor","prototype"]);function Gt(e,t,n){let r=t.split(".");if(r.some((i)=>kr.has(i))){T.warn(`Blocked prototype pollution attempt: ${t}`);return}let o=e;for(let i=0;i<r.length-1;i++){let s=r[i];if(o[s]==null||typeof o[s]!=="object")o[s]={};o=o[s]}o[r[r.length-1]]=n}var he=new Map;function Ee(e,t){if(he.has(e)&&he.get(e)!==t)T.warn(`pipe "${e}" re-registered`);he.set(e,t)}function Re(e){return he.delete(e)}function je(){return[...he.keys()]}function Fe(e){return he.get(e)}function E(e){if(e==null)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"||typeof e==="bigint")return String(e);if(typeof e==="symbol")return e.description??"";if(typeof e==="function")return e.name;if(e instanceof Date)return Number.isNaN(e.getTime())?"":e.toISOString();if(Array.isArray(e))return e.map(E).join(", ");try{return JSON.stringify(e)??""}catch{return""}}var qt=-1,pt=new Map,Sr=/\{\{\s*(.+?)\s*\}\}/g;function K(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function J(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&Nr(r,"{{")===1){let o=r.slice(2,-2).trim();return Ut(o,t,n)}return e.replace(Sr,(o,i)=>{let s=Ut(i.trim(),t,n);return E(s)})}function Ut(e,t,n){let[r,...o]=Lr(e),i=W(r.trim(),t,n);for(let s of o)i=Er(s.trim(),i,t,n);return i}function W(e,t,n){let r=Ar(e);if(r>=0){let s=e.slice(0,r).trim(),a=e.slice(r+1),l=Mr(a);if(l>=0){let d=a.slice(0,l).trim(),u=a.slice(l+1).trim(),c=W(s,t,n);return c!==null&&c!==void 0&&c!==!1&&c!==0&&c!==""?W(d,t,n):W(u,t,n)}}let o=Be(e,"||");if(o>=0){let s=W(e.slice(0,o).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:W(e.slice(o+2).trim(),t,n)}let i=Be(e,"&&");if(i>=0){let s=W(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return W(e.slice(i+2).trim(),t,n)}for(let[s,a]of Rr){let l=Be(e,s);if(l>=0){let d=W(e.slice(0,l).trim(),t,n),u=W(e.slice(l+s.length).trim(),t,n);return a(d,u)}}if(e.startsWith("!")){let s=W(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of Tr){let l=Be(e,s);if(l>=0){let d=W(e.slice(0,l).trim(),t,n),u=W(e.slice(l+s.length).trim(),t,n);return a(Number(d),Number(u))}}if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);if(n&&e.startsWith("$")){let s=e.indexOf(".");if(s>=0){let a=e.slice(0,s),l=e.slice(s+1),d=n[a];return Ve(d,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return Ve(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}var Yt=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function Er(e,t,n,r){let o=e.indexOf(":"),i=o>=0?e.slice(0,o).trim():e,s=o>=0?e.slice(o+1).trim():void 0,a=s?ut(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=Xt(s);if(l.length<2)return;let d=ut(l[0]),u=l[1].trim(),c;if(u.startsWith("'")&&u.endsWith("'")||u.startsWith('"')&&u.endsWith('"'))c=u.slice(1,-1);else if(n){if(r&&u.startsWith("$")){let m=u.indexOf(".");if(m>=0){let b=u.slice(0,m);if(b in r)c=Ve(r[b],u.slice(m+1))}else if(u in r)c=r[u]}if(c===void 0&&!(r&&u.startsWith("$")))if(r){let m=u.split(".")[0];c=m in r?Ve(r[m],u.includes(".")?u.slice(m.length+1):""):n.get(u)}else c=n.get(u)}else c=u;if(c==null)return;let f=n?.generation??0;if(f!==qt)pt=new Map,qt=f;let h=pt.get(t);if(!h)h=new Map,pt.set(t,h);let y=h.get(d);if(!y){y=new Map;for(let m of t)if(m!=null&&typeof m==="object"){let b=m[d];if(b!=null)y.set(E(b),m)}h.set(d,y)}return y.get(E(c))}case"dot":{if(t==null||typeof t!=="object"||typeof a!=="string")return;return t[a]}case"length":return Array.isArray(t)?t.length:typeof t==="string"?t.length:0;case"upper":return typeof t==="string"?t.toUpperCase():t;case"lower":return typeof t==="string"?t.toLowerCase():t;case"truncate":if(typeof t==="string"&&typeof a==="number")return t.slice(0,a);return t;case"join":return Array.isArray(t)?t.join(typeof a==="string"?a:", "):t;case"first":return Array.isArray(t)?t[0]:t;case"last":return Array.isArray(t)?t[t.length-1]:t;case"abs":return Math.abs(Number(t));case"round":return typeof a==="number"?Number(Number(t).toFixed(a)):Math.round(Number(t));case"number":return typeof a==="number"?Number(Number(t).toFixed(a)):Number(t);case"currency":{let l=typeof a==="string"?a:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:l}).format(Number(t))}catch{return t}}case"percent":return typeof a==="number"?`${(Number(t)*100).toFixed(a)}%`:`${Math.round(Number(t)*100)}%`;case"compact":{let l=typeof a==="number"?a:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:l}).format(Number(t))}catch{return t}}case"date":try{return new Date(t).toLocaleDateString()}catch{return t}case"time":try{return new Date(t).toLocaleTimeString()}catch{return t}case"datetime":try{return new Date(t).toLocaleString()}catch{return t}case"pluralize":{let l=Number(t),d=typeof a==="string"?a:"";return l===1?d:`${d}s`}case"default":return t==null||t===""?a:t;case"selectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>l!=null&&typeof l==="object"&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(l==null||typeof l!=="object")return!1;let d=l[a];return d==null||d===!1||d===0||d===""}):t;default:{let l=Fe(i);if(l){let d=s?Xt(s).map(ut):[];return l(t,...d)}return t}}}var Rr=[["!==",(e,t)=>e!==t],["===",(e,t)=>e===t],["!=",(e,t)=>e!=t],["==",(e,t)=>e==t],[">=",(e,t)=>Number(e)>=Number(t)],["<=",(e,t)=>Number(e)<=Number(t)],[">",(e,t)=>Number(e)>Number(t)],["<",(e,t)=>Number(e)<Number(t)]],Tr=[[" + ",(e,t)=>e+t],[" - ",(e,t)=>e-t],[" * ",(e,t)=>e*t],[" / ",(e,t)=>t!==0?e/t:0],[" % ",(e,t)=>t!==0?e%t:0]];function Be(e,t){let n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n&&e.slice(r,r+t.length)===t)return r}return-1}function Ar(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="(")t++;else if(o===")")t--;else if(o==="?"&&t===0)return r}}return-1}function Mr(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="?"||o==="(")t++;else if(o===")")t--;else if(o===":"&&t===0)return r}}return-1}function Lr(e){let t=[],n="",r=null;for(let o=0;o<e.length;o++){let i=e[o];if(i==="'"||i==='"')r=r===i?null:r??i;if(i==="|"&&!r)if(e[o+1]==="|")n+="||",o++;else t.push(n),n="";else n+=i}return t.push(n),t}function ut(e){let t=e.replace(/^['"]|['"]$/g,"");if(t==="true")return!0;if(t==="false")return!1;let n=Number(t);return isNaN(n)?t:n}function Xt(e){let t=[],n="",r=null;for(let o of e){if(o==="'"||o==='"')r=r===o?null:r??o;if(o===","&&!r)t.push(n),n="";else n+=o}return t.push(n),t}function Ve(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=r[o]}return r}function Nr(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function _e(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function B(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function S(e){return typeof e==="string"?e:void 0}function V(e){return typeof e==="number"?e:void 0}function Te(e){return B(e)?e:void 0}function Ae(e){return Array.isArray(e)?e.filter(B):[]}function ft(e){return B(e)?[e]:Ae(e)}function Zt(e){let t={};if(!B(e))return t;for(let[n,r]of Object.entries(e))if(typeof r==="string"||typeof r==="number"||typeof r==="boolean")t[n]=String(r);return t}function mt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:_e(n);if(Array.isArray(r))t[o]=r.map((i)=>B(i)?mt(i):i);else if(B(r))t[o]=mt(r);else t[o]=r}return t}async function H(e,t){for(let n of ft(e))await Hr(n,t)}function P(e,t){e.catch((n)=>T.error(`${t} failed:`,n))}async function ht(e,t,n,r){if(n!=null)T.debug(`${e} failed:`,t),await Me(n,r,{$error:t});else T.warn(`${e} failed:`,t)}async function Hr(e,t){let n=mt(e);switch(S(n.action)){case"setState":{Pr(n,t);return}case"toggleState":{$r(n,t);return}case"appendState":{Or(n,t);return}case"popState":{Dr(n,t);return}case"showToast":{Ir(n,t);return}case"closeOverlay":{jr(n,t);return}case"openLink":{Fr(n);return}case"setInterval":{Vr(n,t);return}case"toolCall":case"callTool":return _r(n,t);case"sendMessage":return zr(n,t);case"updateContext":{Wr(n,t);return}case"fetch":return Kr(n,t);case"openFilePicker":{Jr(n,t);return}case"callHandler":return Gr(n,t);case"requestDisplayMode":{qr(n,t);return}case"subscribe":{Yr(n,t);return}case"unsubscribe":{Zr(n);return}default:T.warn(`Unknown action: ${E(n.action)}`)}}function Ke(e,t){let n=S(e.key);if(n===void 0)T.warn(`${t}: missing key`);return n}function Pr(e,t){let n=Ke(e,"setState");if(n===void 0)return;let r=e.value;if(K(r))r=J(r,t.store,t.scope);t.store.set(n,r),t.rerender(),Me(e.onSuccess,t)}function $r(e,t){let n=Ke(e,"toggleState");if(n===void 0)return;t.store.toggle(n),t.rerender()}function Or(e,t){let n=Ke(e,"appendState");if(n===void 0)return;let r=e.value??e.item;if(K(r))r=J(r,t.store,t.scope);t.store.append(n,r,V(e.index)),t.rerender()}function Dr(e,t){let n=Ke(e,"popState");if(n===void 0)return;let r=e.index;if(typeof r!=="number"&&typeof r!=="string"){T.warn("popState: missing index");return}t.store.pop(n,r),t.rerender()}function Ir(e,t){t.onToast?.({message:We(e.message,t),description:e.description!=null?We(e.description,t):void 0,variant:S(e.variant),duration:V(e.duration)})}function jr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function Fr(e){if(typeof window<"u"){let t=S(e.url);if(!t){T.warn("openLink: missing url");return}if(!an(t)){T.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,S(e.target)??"_blank")}}var ze=new Set,Br=20,gt=100;function Vr(e,t){let n=Math.max(V(e.intervalMs)??gt,gt),r=ft(e.onTick);if(typeof globalThis.setInterval!=="function")return;if(r.length===0){T.warn("setInterval: missing onTick");return}if(ze.size>=Br){T.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>P(H(r,t),"interval action"),n);ze.add(o)}function Qt(){for(let e of ze)globalThis.clearInterval(e);ze.clear()}async function en(e,t,n){let r=S(e.resultKey);if(r!==void 0)n.store.set(r,t);let o=on(t);if(o&&n.remount)n.remount(o);else sn(t,n),n.rerender();await Me(e.onSuccess,n,{$result:t})}async function tn(e,t,n,r,o){let i=ln(Te(n.arguments),r);try{if(t===void 0)throw Error(`${e}: missing tool name`);let s=await o.callTool(t,i);await en(n,s,r)}catch(s){await ht(e,s,n.onError,r)}}async function _r(e,t){if(!t.transport){T.warn("No MCP transport configured for toolCall");return}await tn("toolCall",S(e.tool),e,t,t.transport)}async function zr(e,t){if(!t.transport){T.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(We(e.message,t))}function Wr(e,t){let n=Te(e.context);if(n!=null)t.store.merge(n),t.rerender()}async function Kr(e,t){let n=We(e.url,t);if(!an(n)){T.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=S(e.method)??"GET",o=Zt(e.headers),i=e.body!==void 0?JSON.stringify(e.body):void 0;try{let s=await globalThis.fetch(n,{method:r,headers:{"Content-Type":"application/json",...o},...i&&{body:i}}),a=await s.json().catch(()=>s.text());await en(e,a,t)}catch(s){await ht("fetch",s,e.onError,t)}}function Jr(e,t){if(typeof document>"u")return;let n=document.createElement("input");n.type="file";let r=S(e.accept);if(r!==void 0)n.accept=r;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let o=Array.from(n.files??[]),i=S(e.resultKey);if(i!==void 0)t.store.set(i,o);t.rerender(),Me(e.onSuccess,t,{$result:o})}),n.click()}async function Gr(e,t){let n=S(e.handler);if(!t.transport){T.warn(`No transport configured for callHandler: ${n??""}`);return}await tn("callHandler",n,e,t,t.transport)}function qr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var re=new Map,Ur=50,Xr=2000;function Yr(e,t){let n=S(e.uri),r=S(e.stateKey);if(!n||!r){T.warn("subscribe: missing uri or stateKey");return}if(re.has(n))return;if(re.size>=Ur){T.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(c)=>{let f=on(c);if(f&&t.remount)t.remount(f);else{if(!sn(c,t))t.store.set(r,c);t.rerender()}Me(e.onData,t,{$data:c})};if(e.push!==!1&&t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let c=t.transport.subscribe(n,o);re.set(n,c);return}let i=S(e.fallbackTool),s=V(e.fallbackInterval)??Xr;if(!i){T.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){T.warn("No MCP transport configured for subscribe fallback");return}let a=Te(e.fallbackArgs)??{},l=Math.max(s,gt),d=t.transport,u=globalThis.setInterval(()=>{(async()=>{try{let c=ln(a,t),f=await d.callTool(i,c);o(f)}catch(c){ht("subscribe",c,e.onError,t)}})()},l);re.set(n,()=>globalThis.clearInterval(u))}function Zr(e){let t=S(e.uri);if(!t){T.warn("unsubscribe: missing uri");return}let n=re.get(t);if(n)n(),re.delete(t)}function nn(){for(let[e,t]of re)try{t()}catch(n){T.warn(`Error cleaning up subscription '${e}':`,n)}re.clear()}function Qr(e){try{return JSON.parse(e)}catch{return}}function rn(e,t){if(!B(e))return null;if(t(e))return e;let n=e.structuredContent;if(B(n)&&t(n))return n;for(let r of Ae(e.content)){if(r.type!=="text"||typeof r.text!=="string")continue;let o=Qr(r.text);if(B(o)&&t(o))return o}return null}function eo(e){return"$prefab"in e&&"view"in e}function to(e){return"$prefab"in e&&B(e.update)&&"state"in e.update}function on(e){return rn(e,eo)}function sn(e,t){let n=rn(e,to);if(!n)return!1;let{update:r}=n,o=Te(r.state);if(o)t.store.merge(o);if(r.actions!=null)P(H(r.actions,t),"update action");return!0}var no=/^\s*(javascript|vbscript|data):/i;function an(e){return!no.test(e)}function We(e,t){if(K(e)){let n=J(e,t.store,t.scope);return E(n)}return E(e)}function ln(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=K(o)?J(o,t.store,t.scope):o;return n}async function Me(e,t,n){if(e==null)return;let r={...t.scope,...n};await H(e,{...t,scope:r})}function yt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:_e(n);if(Array.isArray(r))t[o]=r.map((i)=>i!=null&&typeof i==="object"&&!Array.isArray(i)?yt(i):i);else if(r!=null&&typeof r==="object"&&!Array.isArray(r))t[o]=yt(r);else t[o]=r}return t}class Le{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){T.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function ro(e){return typeof e==="object"&&"element"in e}var Je=new Map;function p(e,t){if(Je.has(e))T.warn(`overriding existing renderer for "${e}"`);Je.set(e,t)}function Ct(){return[...Je.keys()].sort()}var dn=new Set;function pn(e){dn.clear();for(let t of e)dn.add(t)}function O(e,t){let n=yt(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return O(i,t)}let r=Je.get(n.type),o;if(r){let i=r(n,t);if(ro(i))o=i.element,t.destroyRegistry?.track(i.destroy);else o=i}else if(o=document.createElement("div"),o.setAttribute("data-prefab-type",n.type),n.children)for(let i of n.children)o.appendChild(O(i,t));if(o instanceof HTMLElement){if(n.id)o.id=n.id;if(n.cssClass){let i=C(n.cssClass,t);if(i)o.className=(o.className?o.className+" ":"")+i}if(n.onClick!=null){if(o.addEventListener("click",()=>{P(H(n.onClick,j(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(i)=>{let s=i.key;if(s==="Enter"||s===" ")i.preventDefault(),P(H(n.onClick,j(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=j(t);queueMicrotask(()=>P(H(i,s),"onMount"))}return o}function M(e,t,n){if(!e.children)return;oe(e.children,t,n)}function oe(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=oo(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(O(o,n)),r++}}function oo(e,t,n,r){let o=!1,i=t,s=e[i];if(cn(s.condition,r))bt(s,n,r),o=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!o&&cn(a.condition,r))bt(a,n,r),o=!0;i++}else if(a.type==="Else"){if(!o)bt(a,n,r);i++;break}else break}return i}function cn(e,t){if(!e)return!1;if(K(e))return Boolean(J(e,t.store,t.scope));return Boolean(t.store.get(e))}function bt(e,t,n){if(!e.children)return;oe(e.children,t,n)}function C(e,t){if(K(e)){let n=J(e,t.store,t.scope);return E(n)}return E(e)}function z(e,t){if(K(e))return J(e,t.store,t.scope);return e}function j(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function g(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function xt(e,t){return e.textContent=t,e}function Ge(e,t){return e===void 0||t(e)}function io(e){return B(e)||Array.isArray(e)&&e.every(B)}function wt(e){return B(e)&&typeof e.type==="string"&&Ge(e.id,(t)=>typeof t==="string")&&Ge(e.cssClass,(t)=>typeof t==="string")&&Ge(e.onMount,io)&&Ge(e.children,(t)=>Array.isArray(t)&&t.every(wt))}function hn(){p("Column",so),p("Row",ao),p("Grid",un),p("GridItem",fn),p("Container",lo),p("Div",mn),p("Span",co),p("Dashboard",un),p("DashboardItem",fn),p("Pages",po),p("Page",mn),p("Detail",uo),p("MasterDetail",fo)}function so(e,t){let n=g("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let r=qe(e);if(r!=null)n.style.gap=`${r*4}px`;return bn(n,e),M(e,n,t),n}function ao(e,t){let n=g("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let r=qe(e);if(r!=null)n.style.gap=`${r*4}px`;if(bn(n,e),e.wrap===!0)n.style.flexWrap="wrap";return M(e,n,t),n}function un(e,t){let n=g("div","pf-grid");n.style.display="grid",n.style.gridTemplateColumns=`repeat(${ho(e.columns)}, 1fr)`;let r=qe(e);if(r!=null)n.style.gap=`${r*4}px`;return M(e,n,t),n}function fn(e,t){let n=g("div","pf-grid-item"),r=V(e.colSpan),o=V(e.rowSpan);if(r!=null)n.style.gridColumn=`span ${r}`;if(o!=null)n.style.gridRow=`span ${o}`;return M(e,n,t),n}function lo(e,t){let n=g("div","pf-container");n.style.maxWidth=S(e.maxWidth)??"1200px",n.style.margin="0 auto";let r=V(e.padding);if(r!=null)n.style.padding=`${r*4}px`;return M(e,n,t),n}function mn(e,t){let n=g("div","pf-div");return M(e,n,t),n}function co(e,t){let n=g("span","pf-span");return M(e,n,t),n}function po(e,t){let n=g("div","pf-pages");return M(e,n,t),n}function uo(e,t){let n=g("div","pf-detail"),r=e.of!=null?z(e.of,t):void 0;if(r!=null&&r!==""&&r!==!1&&r!==0)M(e,n,t);else if(wt(e.empty))n.appendChild(O(e.empty,t));return n}function fo(e,t){let n=g("div","pf-master-detail");n.style.display="flex",n.style.flexDirection="row";let r=qe(e);if(r!=null)n.style.gap=`${r*4}px`;let o=S(e.masterWidth)??"33%",i=e.children??[];if(i.length>0){let s=g("div","pf-master-detail-master");s.style.width=o,s.style.flexShrink="0",s.style.overflow="auto",s.appendChild(O(i[0],t)),n.appendChild(s)}if(i.length>1){let s=g("div","pf-master-detail-detail");s.style.flex="1",s.style.overflow="auto",s.appendChild(O(i[1],t)),n.appendChild(s)}return n}var mo=/\bgap-(\d+)\b/;function qe(e){let t=V(e.gap);if(t!=null)return t;if(typeof e.cssClass==="string"){let n=mo.exec(e.cssClass);if(n)return Number(n[1])}return null}var go=["default","base","xs","sm","md","lg","xl","2xl"],gn=3;function ho(e){if(typeof e==="number")return e;if(!B(e))return gn;let t=go.map((n)=>e[n]).filter((n)=>typeof n==="number");return t.length>0?t[t.length-1]:gn}function bn(e,t){let n=S(t.align),r=S(t.justify);if(n!=null)e.style.alignItems=bo(n);if(r!=null)e.style.justifyContent=yo(r)}function bo(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function yo(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var Co={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function Ne(e){return e.replace(/[&<>"']/g,(t)=>Co[t]??t)}function Cn(){p("Heading",xo),p("H1",(e,t)=>Ue(e,t,"h1")),p("H2",(e,t)=>Ue(e,t,"h2")),p("H3",(e,t)=>Ue(e,t,"h3")),p("H4",(e,t)=>Ue(e,t,"h4")),p("Text",wo),p("P",vo),p("Lead",(e,t)=>be(e,t,"p","pf-lead")),p("Large",(e,t)=>be(e,t,"span","pf-large")),p("Small",(e,t)=>be(e,t,"small","pf-small")),p("Muted",(e,t)=>be(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>be(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>be(e,t,"label","pf-label")),p("Link",So),p("Code",Eo),p("Markdown",Ro),p("Kbd",To)}function xo(e,t){let n=e.level??2,r=`h${Math.min(Math.max(n,1),6)}`,o=document.createElement(r);return o.className=`pf-heading pf-${r}`,o.textContent=C(e.content,t),o}function Ue(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=C(e.content,t),r}function wo(e,t){return xt(g("span","pf-text"),C(e.content,t))}function vo(e,t){return xt(g("p","pf-p"),C(e.content,t))}function be(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=C(e.content,t),o}var ko=/^\s*(javascript|vbscript|data):/i;function So(e,t){let n=document.createElement("a");if(n.className="pf-link",n.textContent=C(e.content,t),e.href!=null){let r=C(e.href,t);if(!ko.test(r))n.href=r}if(e.target!=null)n.target=C(e.target,t);return n}function Eo(e,t){let n=g("pre","pf-code"),r=g("code");if(r.textContent=C(e.content,t),e.language!=null)r.setAttribute("data-language",e.language);return n.appendChild(r),n}function Ro(e,t){let n=g("div","pf-markdown"),r=C(e.content,t);return n.innerHTML=xn(r),n.setAttribute("data-markdown","true"),n}var yn=/^\s*(javascript|vbscript|data):/i;function Xe(e){let t=Ne(e),n=[];return t=t.replace(/`([^`]+)`/g,(r,o)=>(n.push(`<code>${o}</code>`),`﷐CODE${n.length-1}﷐`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(r,o,i)=>{if(yn.test(i))return Ne(o);return`<img src="${i}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,i)=>{if(yn.test(i))return o;return`<a href="${i}">${o}</a>`}),t=t.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),t=t.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/\uFDD0CODE(\d+)\uFDD0/g,(r,o)=>n[parseInt(o)]),t}function xn(e){let t=e.replace(/\r\n?/g,`
1
+ (()=>{var{defineProperty:ut,getOwnPropertyNames:vr,getOwnPropertyDescriptor:kr}=Object,Sr=Object.prototype.hasOwnProperty;function Er(e){return this[e]}var Rr=(e)=>{var t=(Ut??=new WeakMap).get(e),n;if(t)return t;if(t=ut({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var r of vr(e))if(!Sr.call(t,r))ut(t,r,{get:Er.bind(e,r),enumerable:!(n=kr(e,r))||n.enumerable})}return Ut.set(e,t),t},Ut;var Tr=(e)=>e;function Ar(e,t){this[e]=Tr.bind(null,t)}var Mr=(e,t)=>{for(var n in t)ut(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Ar.bind(t,n)})};var Es={};Mr(Es,{Bridge:()=>he,DestroyRegistry:()=>Ne,PrefabRenderer:()=>q,app:()=>dt,applyHostTheme:()=>Ie,createLogger:()=>mt,createThemeToggle:()=>De,getLogLevel:()=>Yt,isIframe:()=>ke,isValidWireFormat:()=>gr,listPipes:()=>Fe,log:()=>M,registerComponent:()=>p,registerPipe:()=>Te,setLogLevel:()=>je,unregisterPipe:()=>Ae,validateWireFormat:()=>Se});var Xt={silent:0,error:1,warn:2,info:3,debug:4},ft="warn";function je(e){ft=e}function Yt(){return ft}function mt(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,i)=>{if(Xt[r]>Xt[ft])return;console[r](`${t} ${o}`,...i)};return{error:(r,...o)=>n("error",r,o),warn:(r,...o)=>n("warn",r,o),info:(r,...o)=>n("info",r,o),debug:(r,...o)=>n("debug",r,o)}}var M=mt();function S(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function b(e){return typeof e==="string"?e:void 0}function D(e){return typeof e==="number"?e:void 0}function I(e){return S(e)?e:void 0}function Ee(e){return Array.isArray(e)?e.filter(S):[]}function gt(e){return S(e)?[e]:Ee(e)}function Zt(e){let t={};if(!S(e))return t;for(let[n,r]of Object.entries(e))if(typeof r==="string"||typeof r==="number"||typeof r==="boolean")t[n]=String(r);return t}class Re{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return Nr(this.data,e)}getAll(){return this.data}set(e,t){Qt(this.data,e,t),this.notify(e)}toggle(e){let t=this.get(e),n=t==null||t===!1||t===0||t==="";this.set(e,n)}append(e,t,n){let r=this.get(e);if(!Array.isArray(r)){this.set(e,[t]);return}if(n!==void 0)r.splice(n,0,t);else r.push(t);this.notify(e)}pop(e,t){let n=this.get(e);if(!Array.isArray(n))return;if(typeof t==="number")n.splice(t,1);else{let r=n.indexOf(t);if(r>=0)n.splice(r,1)}this.notify(e)}merge(e){for(let[t,n]of Object.entries(e))Qt(this.data,t,n);for(let t of Object.keys(e))this.notify(t)}subscribe(e,t){if(!this.subscribers.has(e))this.subscribers.set(e,new Set);return this.subscribers.get(e)?.add(t),()=>this.subscribers.get(e)?.delete(t)}subscribeAll(e){return this.globalSubscribers.add(e),()=>this.globalSubscribers.delete(e)}notify(e){this.generation++;let t=e.split(".");for(let n=1;n<=t.length;n++){let r=t.slice(0,n).join("."),o=this.subscribers.get(r);if(o)o.forEach((i)=>i())}this.globalSubscribers.forEach((n)=>n())}}function Nr(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=Reflect.get(r,o)}return r}var Lr=new Set(["__proto__","constructor","prototype"]);function Qt(e,t,n){let r=t.split(".");if(r.some((i)=>Lr.has(i))){M.warn(`Blocked prototype pollution attempt: ${t}`);return}let o=e;for(let i=0;i<r.length-1;i++){let s=r[i],a=o[s];if(S(a))o=a;else{let l={};o[s]=l,o=l}}o[r[r.length-1]]=n}var be=new Map;function Te(e,t){if(be.has(e)&&be.get(e)!==t)M.warn(`pipe "${e}" re-registered`);be.set(e,t)}function Ae(e){return be.delete(e)}function Fe(){return[...be.keys()]}function Be(e){return be.get(e)}function k(e){if(e==null)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"||typeof e==="bigint")return String(e);if(typeof e==="symbol")return e.description??"";if(typeof e==="function")return e.name;if(e instanceof Date)return Number.isNaN(e.getTime())?"":e.toISOString();if(Array.isArray(e))return e.map(k).join(", ");try{return JSON.stringify(e)??""}catch{return""}}function ht(e,t){let n=e instanceof Date?e:typeof e==="string"||typeof e==="number"?new Date(e):void 0;return n&&!Number.isNaN(n.getTime())?t(n):e}var en=-1,bt=new Map,Hr=/\{\{\s*(.+?)\s*\}\}/g;function J(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function G(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&Fr(r,"{{")===1){let o=r.slice(2,-2).trim();return tn(o,t,n)}return e.replace(Hr,(o,i)=>{let s=tn(i.trim(),t,n);return k(s)})}function tn(e,t,n){let[r,...o]=jr(e),i=K(r.trim(),t,n);for(let s of o)i=Pr(s.trim(),i,t,n);return i}function K(e,t,n){let r=Dr(e);if(r>=0){let s=e.slice(0,r).trim(),a=e.slice(r+1),l=Ir(a);if(l>=0){let c=a.slice(0,l).trim(),u=a.slice(l+1).trim(),d=K(s,t,n);return d!==null&&d!==void 0&&d!==!1&&d!==0&&d!==""?K(c,t,n):K(u,t,n)}}let o=Ve(e,"||");if(o>=0){let s=K(e.slice(0,o).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:K(e.slice(o+2).trim(),t,n)}let i=Ve(e,"&&");if(i>=0){let s=K(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return K(e.slice(i+2).trim(),t,n)}for(let[s,a]of $r){let l=Ve(e,s);if(l>=0){let c=K(e.slice(0,l).trim(),t,n),u=K(e.slice(l+s.length).trim(),t,n);return a(c,u)}}if(e.startsWith("!")){let s=K(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of Or){let l=Ve(e,s);if(l>=0){let c=K(e.slice(0,l).trim(),t,n),u=K(e.slice(l+s.length).trim(),t,n);return a(Number(c),Number(u))}}if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);if(n&&e.startsWith("$")){let s=e.indexOf(".");if(s>=0){let a=e.slice(0,s),l=e.slice(s+1),c=n[a];return _e(c,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return _e(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}var rn=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function Pr(e,t,n,r){let o=e.indexOf(":"),i=o>=0?e.slice(0,o).trim():e,s=o>=0?e.slice(o+1).trim():void 0,a=s?yt(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=nn(s);if(l.length<2)return;let c=yt(l[0]),u=l[1].trim(),d;if(u.startsWith("'")&&u.endsWith("'")||u.startsWith('"')&&u.endsWith('"'))d=u.slice(1,-1);else if(n){if(r&&u.startsWith("$")){let f=u.indexOf(".");if(f>=0){let y=u.slice(0,f);if(y in r)d=_e(r[y],u.slice(f+1))}else if(u in r)d=r[u]}if(d===void 0&&!(r&&u.startsWith("$")))if(r){let f=u.split(".")[0];d=f in r?_e(r[f],u.includes(".")?u.slice(f.length+1):""):n.get(u)}else d=n.get(u)}else d=u;if(d==null)return;let m=n?.generation??0;if(m!==en)bt=new Map,en=m;let h=bt.get(t);if(!h)h=new Map,bt.set(t,h);let C=h.get(c);if(!C){C=new Map;for(let f of t)if(S(f)){let y=f[c];if(y!=null)C.set(k(y),f)}h.set(c,C)}return C.get(k(d))}case"dot":{if(t==null||typeof t!=="object"||typeof a!=="string")return;return Reflect.get(t,a)}case"length":return Array.isArray(t)?t.length:typeof t==="string"?t.length:0;case"upper":return typeof t==="string"?t.toUpperCase():t;case"lower":return typeof t==="string"?t.toLowerCase():t;case"truncate":if(typeof t==="string"&&typeof a==="number")return t.slice(0,a);return t;case"join":return Array.isArray(t)?t.join(typeof a==="string"?a:", "):t;case"first":return Array.isArray(t)?t[0]:t;case"last":return Array.isArray(t)?t[t.length-1]:t;case"abs":return Math.abs(Number(t));case"round":return typeof a==="number"?Number(Number(t).toFixed(a)):Math.round(Number(t));case"number":return typeof a==="number"?Number(Number(t).toFixed(a)):Number(t);case"currency":{let l=typeof a==="string"?a:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:l}).format(Number(t))}catch{return t}}case"percent":return typeof a==="number"?`${(Number(t)*100).toFixed(a)}%`:`${Math.round(Number(t)*100)}%`;case"compact":{let l=typeof a==="number"?a:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:l}).format(Number(t))}catch{return t}}case"date":return ht(t,(l)=>l.toLocaleDateString());case"time":return ht(t,(l)=>l.toLocaleTimeString());case"datetime":return ht(t,(l)=>l.toLocaleString());case"pluralize":{let l=Number(t),c=typeof a==="string"?a:"";return l===1?c:`${c}s`}case"default":return t==null||t===""?a:t;case"selectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>S(l)&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(!S(l))return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=Be(i);if(l){let c=s?nn(s).map(yt):[];return l(t,...c)}return t}}}var $r=[["!==",(e,t)=>e!==t],["===",(e,t)=>e===t],["!=",(e,t)=>e!=t],["==",(e,t)=>e==t],[">=",(e,t)=>Number(e)>=Number(t)],["<=",(e,t)=>Number(e)<=Number(t)],[">",(e,t)=>Number(e)>Number(t)],["<",(e,t)=>Number(e)<Number(t)]],Or=[[" + ",(e,t)=>e+t],[" - ",(e,t)=>e-t],[" * ",(e,t)=>e*t],[" / ",(e,t)=>t!==0?e/t:0],[" % ",(e,t)=>t!==0?e%t:0]];function Ve(e,t){let n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n&&e.slice(r,r+t.length)===t)return r}return-1}function Dr(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="(")t++;else if(o===")")t--;else if(o==="?"&&t===0)return r}}return-1}function Ir(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="?"||o==="(")t++;else if(o===")")t--;else if(o===":"&&t===0)return r}}return-1}function jr(e){let t=[],n="",r=null;for(let o=0;o<e.length;o++){let i=e[o];if(i==="'"||i==='"')r=r===i?null:r??i;if(i==="|"&&!r)if(e[o+1]==="|")n+="||",o++;else t.push(n),n="";else n+=i}return t.push(n),t}function yt(e){let t=e.replace(/^['"]|['"]$/g,"");if(t==="true")return!0;if(t==="false")return!1;let n=Number(t);return isNaN(n)?t:n}function nn(e){let t=[],n="",r=null;for(let o of e){if(o==="'"||o==='"')r=r===o?null:r??o;if(o===","&&!r)t.push(n),n="";else n+=o}return t.push(n),t}function _e(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(!S(r)&&!Array.isArray(r))return;r=Reflect.get(r,o)}return r}function Fr(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function ze(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function Ct(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:ze(n);if(Array.isArray(r))t[o]=r.map((i)=>S(i)?Ct(i):i);else if(S(r))t[o]=Ct(r);else t[o]=r}return t}async function P(e,t){for(let n of gt(e))await Br(n,t)}function O(e,t){e.catch((n)=>M.error(`${t} failed:`,n))}async function We(e,t,n,r){if(n!=null)M.debug(`${e} failed:`,t),await Me(n,r,{$error:t});else M.warn(`${e} failed:`,t)}async function Br(e,t){let n=Ct(e);switch(b(n.action)){case"setState":{Vr(n,t);return}case"toggleState":{_r(n,t);return}case"appendState":{zr(n,t);return}case"popState":{Wr(n,t);return}case"showToast":{Kr(n,t);return}case"closeOverlay":{Jr(n,t);return}case"openLink":{Gr(n);return}case"setInterval":{Ur(n,t);return}case"toolCall":case"callTool":return Xr(n,t);case"sendMessage":return Yr(n,t);case"updateContext":{Zr(n,t);return}case"fetch":return Qr(n,t);case"openFilePicker":{eo(n,t);return}case"callHandler":return to(n,t);case"requestDisplayMode":{no(n,t);return}case"subscribe":{io(n,t);return}case"unsubscribe":{so(n);return}default:M.warn(`Unknown action: ${k(n.action)}`)}}function Ge(e,t){let n=b(e.key);if(n===void 0)M.warn(`${t}: missing key`);return n}function Vr(e,t){let n=Ge(e,"setState");if(n===void 0)return;let r=e.value;if(J(r))r=G(r,t.store,t.scope);t.store.set(n,r),t.rerender(),Me(e.onSuccess,t)}function _r(e,t){let n=Ge(e,"toggleState");if(n===void 0)return;t.store.toggle(n),t.rerender()}function zr(e,t){let n=Ge(e,"appendState");if(n===void 0)return;let r=e.value??e.item;if(J(r))r=G(r,t.store,t.scope);t.store.append(n,r,D(e.index)),t.rerender()}function Wr(e,t){let n=Ge(e,"popState");if(n===void 0)return;let r=J(e.index)?G(e.index,t.store,t.scope):e.index;if(typeof r!=="number"&&typeof r!=="string"){M.warn("popState: missing index");return}t.store.pop(n,r),t.rerender()}function Kr(e,t){t.onToast?.({message:Je(e.message,t),description:e.description!=null?Je(e.description,t):void 0,variant:b(e.variant),duration:D(e.duration)})}function Jr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function Gr(e){if(typeof window<"u"){let t=b(e.url);if(!t){M.warn("openLink: missing url");return}if(!un(t)){M.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,b(e.target)??"_blank")}}var Ke=new Set,qr=20,xt=100;function Ur(e,t){let n=Math.max(D(e.intervalMs)??xt,xt),r=gt(e.onTick);if(typeof globalThis.setInterval!=="function")return;if(r.length===0){M.warn("setInterval: missing onTick");return}if(Ke.size>=qr){M.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>O(P(r,t),"interval action"),n);Ke.add(o)}function on(){for(let e of Ke)globalThis.clearInterval(e);Ke.clear()}async function sn(e,t,n){let r=b(e.resultKey);if(r!==void 0)n.store.set(r,t);let o=dn(t);if(o&&n.remount)n.remount(o);else pn(t,n),n.rerender();await Me(e.onSuccess,n,{$result:t})}async function an(e,t,n,r,o){let i=fn(I(n.arguments),r);try{if(t===void 0)throw Error(`${e}: missing tool name`);let s=await o.callTool(t,i);await sn(n,s,r)}catch(s){await We(e,s,n.onError,r)}}async function Xr(e,t){if(!t.transport){M.warn("No MCP transport configured for toolCall");return}await an("toolCall",b(e.tool),e,t,t.transport)}async function Yr(e,t){if(!t.transport){M.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(Je(e.message,t))}function Zr(e,t){let n=I(e.context);if(n!=null)t.store.merge(n),t.rerender()}async function Qr(e,t){let n=Je(e.url,t);if(!un(n)){M.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=b(e.method)??"GET",o=Zt(e.headers),i=e.body!==void 0?JSON.stringify(e.body):void 0;try{let s=await globalThis.fetch(n,{method:r,headers:{"Content-Type":"application/json",...o},...i&&{body:i}}),a=await s.json().catch(()=>s.text());await sn(e,a,t)}catch(s){await We("fetch",s,e.onError,t)}}function eo(e,t){if(typeof document>"u")return;let n=document.createElement("input");n.type="file";let r=b(e.accept);if(r!==void 0)n.accept=r;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let o=Array.from(n.files??[]),i=b(e.resultKey);if(i!==void 0)t.store.set(i,o);t.rerender(),Me(e.onSuccess,t,{$result:o})}),n.click()}async function to(e,t){let n=b(e.handler);if(!t.transport){M.warn(`No transport configured for callHandler: ${n??""}`);return}await an("callHandler",n,e,t,t.transport)}function no(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var ee=new Map,ro=50,oo=2000;function io(e,t){let n=b(e.uri),r=b(e.stateKey);if(!n||!r){M.warn("subscribe: missing uri or stateKey");return}if(ee.has(n))return;if(ee.size>=ro){M.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(d)=>{let m=dn(d);if(m&&t.remount)t.remount(m);else{if(!pn(d,t))t.store.set(r,d);t.rerender()}Me(e.onData,t,{$data:d})};if(e.push!==!1&&t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let d=t.transport.subscribe(n,o,(m)=>{if(ee.get(n)===d)ee.delete(n);We("subscribe",m,e.onError,t)});ee.set(n,d);return}let i=b(e.fallbackTool),s=D(e.fallbackInterval)??oo;if(!i){M.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){M.warn("No MCP transport configured for subscribe fallback");return}let a=I(e.fallbackArgs)??{},l=Math.max(s,xt),c=t.transport,u=globalThis.setInterval(()=>{(async()=>{try{let d=fn(a,t),m=await c.callTool(i,d);o(m)}catch(d){We("subscribe",d,e.onError,t)}})()},l);ee.set(n,()=>globalThis.clearInterval(u))}function so(e){let t=b(e.uri);if(!t){M.warn("unsubscribe: missing uri");return}let n=ee.get(t);if(n)n(),ee.delete(t)}function ln(){for(let[e,t]of ee)try{t()}catch(n){M.warn(`Error cleaning up subscription '${e}':`,n)}ee.clear()}function ao(e){try{return JSON.parse(e)}catch{return}}function cn(e,t){if(!S(e))return null;if(t(e))return e;let n=e.structuredContent;if(S(n)&&t(n))return n;for(let r of Ee(e.content)){if(r.type!=="text"||typeof r.text!=="string")continue;let o=ao(r.text);if(S(o)&&t(o))return o}return null}function lo(e){return"$prefab"in e&&"view"in e}function co(e){return"$prefab"in e&&S(e.update)&&"state"in e.update}function dn(e){return cn(e,lo)}function pn(e,t){let n=cn(e,co);if(!n)return!1;let{update:r}=n,o=I(r.state);if(o)t.store.merge(o);if(r.actions!=null)O(P(r.actions,t),"update action");return!0}var po=/^\s*(javascript|vbscript|data):/i;function un(e){return!po.test(e)}function Je(e,t){if(J(e)){let n=G(e,t.store,t.scope);return k(n)}return k(e)}function fn(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=J(o)?G(o,t.store,t.scope):o;return n}async function Me(e,t,n){if(e==null)return;let r={...t.scope,...n};await P(e,{...t,scope:r})}function vt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:ze(n);if(Array.isArray(r))t[o]=r.map((i)=>S(i)?vt(i):i);else if(S(r))t[o]=vt(r);else t[o]=r}return t}class Ne{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){M.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function uo(e){return typeof e==="object"&&"element"in e}var qe=new Map;function p(e,t){if(qe.has(e))M.warn(`overriding existing renderer for "${e}"`);qe.set(e,t)}function kt(){return[...qe.keys()].sort()}var mn=new Set;function hn(e){mn.clear();for(let t of e)mn.add(t)}function j(e,t){let n=vt(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return j(i,t)}let r=qe.get(n.type),o;if(r){let i=r(n,t);if(uo(i))o=i.element,t.destroyRegistry?.track(i.destroy);else o=i}else if(o=document.createElement("div"),o.setAttribute("data-prefab-type",n.type),n.children)for(let i of n.children)o.appendChild(j(i,t));if(o instanceof HTMLElement){if(n.id)o.id=n.id;if(n.cssClass){let i=w(n.cssClass,t);if(i)o.className=(o.className?o.className+" ":"")+i}if(n.onClick!=null){if(o.addEventListener("click",()=>{O(P(n.onClick,V(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(i)=>{let s=i.key;if(s==="Enter"||s===" ")i.preventDefault(),O(P(n.onClick,V(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=V(t);queueMicrotask(()=>O(P(i,s),"onMount"))}return o}function N(e,t,n){if(!e.children)return;ie(e.children,t,n)}function ie(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=fo(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(j(o,n)),r++}}function fo(e,t,n,r){let o=!1,i=t,s=e[i];if(gn(b(s.condition)??"",r))wt(s,n,r),o=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!o&&gn(b(a.condition)??"",r))wt(a,n,r),o=!0;i++}else if(a.type==="Else"){if(!o)wt(a,n,r);i++;break}else break}return i}function gn(e,t){if(!e)return!1;if(J(e))return Boolean(G(e,t.store,t.scope));return Boolean(t.store.get(e))}function wt(e,t,n){if(!e.children)return;ie(e.children,t,n)}function w(e,t){if(J(e)){let n=G(e,t.store,t.scope);return k(n)}return k(e)}function W(e,t){if(J(e))return G(e,t.store,t.scope);return e}function V(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function g(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function St(e,t){return e.textContent=t,e}function Ue(e,t){return e===void 0||t(e)}function mo(e){return S(e)||Array.isArray(e)&&e.every(S)}function Le(e){return S(e)&&typeof e.type==="string"&&Ue(e.id,(t)=>typeof t==="string")&&Ue(e.cssClass,(t)=>typeof t==="string")&&Ue(e.onMount,mo)&&Ue(e.children,(t)=>Array.isArray(t)&&t.every(Le))}function wn(){p("Column",go),p("Row",ho),p("Grid",bn),p("GridItem",yn),p("Container",bo),p("Div",Cn),p("Span",yo),p("Dashboard",bn),p("DashboardItem",yn),p("Pages",Co),p("Page",Cn),p("Detail",xo),p("MasterDetail",wo)}function go(e,t){let n=g("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let r=Xe(e);if(r!=null)n.style.gap=`${r*4}px`;return vn(n,e),N(e,n,t),n}function ho(e,t){let n=g("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let r=Xe(e);if(r!=null)n.style.gap=`${r*4}px`;if(vn(n,e),e.wrap===!0)n.style.flexWrap="wrap";return N(e,n,t),n}function bn(e,t){let n=g("div","pf-grid");n.style.display="grid",n.style.gridTemplateColumns=`repeat(${So(e.columns)}, 1fr)`;let r=Xe(e);if(r!=null)n.style.gap=`${r*4}px`;return N(e,n,t),n}function yn(e,t){let n=g("div","pf-grid-item"),r=D(e.colSpan),o=D(e.rowSpan);if(r!=null)n.style.gridColumn=`span ${r}`;if(o!=null)n.style.gridRow=`span ${o}`;return N(e,n,t),n}function bo(e,t){let n=g("div","pf-container");n.style.maxWidth=b(e.maxWidth)??"1200px",n.style.margin="0 auto";let r=D(e.padding);if(r!=null)n.style.padding=`${r*4}px`;return N(e,n,t),n}function Cn(e,t){let n=g("div","pf-div");return N(e,n,t),n}function yo(e,t){let n=g("span","pf-span");return N(e,n,t),n}function Co(e,t){let n=g("div","pf-pages");return N(e,n,t),n}function xo(e,t){let n=g("div","pf-detail"),r=e.of!=null?W(e.of,t):void 0;if(r!=null&&r!==""&&r!==!1&&r!==0)N(e,n,t);else if(Le(e.empty))n.appendChild(j(e.empty,t));return n}function wo(e,t){let n=g("div","pf-master-detail");n.style.display="flex",n.style.flexDirection="row";let r=Xe(e);if(r!=null)n.style.gap=`${r*4}px`;let o=b(e.masterWidth)??"33%",i=e.children??[];if(i.length>0){let s=g("div","pf-master-detail-master");s.style.width=o,s.style.flexShrink="0",s.style.overflow="auto",s.appendChild(j(i[0],t)),n.appendChild(s)}if(i.length>1){let s=g("div","pf-master-detail-detail");s.style.flex="1",s.style.overflow="auto",s.appendChild(j(i[1],t)),n.appendChild(s)}return n}var vo=/\bgap-(\d+)\b/;function Xe(e){let t=D(e.gap);if(t!=null)return t;if(typeof e.cssClass==="string"){let n=vo.exec(e.cssClass);if(n)return Number(n[1])}return null}var ko=["default","base","xs","sm","md","lg","xl","2xl"],xn=3;function So(e){if(typeof e==="number")return e;if(!S(e))return xn;let t=ko.map((n)=>e[n]).filter((n)=>typeof n==="number");return t.length>0?t[t.length-1]:xn}function vn(e,t){let n=b(t.align),r=b(t.justify);if(n!=null)e.style.alignItems=Eo(n);if(r!=null)e.style.justifyContent=Ro(r)}function Eo(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Ro(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var To={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function He(e){return e.replace(/[&<>"']/g,(t)=>To[t]??t)}function Sn(){p("Heading",Ao),p("H1",(e,t)=>Ye(e,t,"h1")),p("H2",(e,t)=>Ye(e,t,"h2")),p("H3",(e,t)=>Ye(e,t,"h3")),p("H4",(e,t)=>Ye(e,t,"h4")),p("Text",Mo),p("P",No),p("Lead",(e,t)=>ye(e,t,"p","pf-lead")),p("Large",(e,t)=>ye(e,t,"span","pf-large")),p("Small",(e,t)=>ye(e,t,"small","pf-small")),p("Muted",(e,t)=>ye(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>ye(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>ye(e,t,"label","pf-label")),p("Link",Ho),p("Code",Po),p("Markdown",$o),p("Kbd",Oo)}function Ao(e,t){let n=D(e.level)??2,r=`h${Math.min(Math.max(n,1),6)}`,o=document.createElement(r);return o.className=`pf-heading pf-${r}`,o.textContent=w(e.content,t),o}function Ye(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=w(e.content,t),r}function Mo(e,t){return St(g("span","pf-text"),w(e.content,t))}function No(e,t){return St(g("p","pf-p"),w(e.content,t))}function ye(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=w(e.content,t),o}var Lo=/^\s*(javascript|vbscript|data):/i;function Ho(e,t){let n=document.createElement("a");if(n.className="pf-link",n.textContent=w(e.content,t),e.href!=null){let r=w(e.href,t);if(!Lo.test(r))n.href=r}if(e.target!=null)n.target=w(e.target,t);return n}function Po(e,t){let n=g("pre","pf-code"),r=g("code");if(r.textContent=w(e.content,t),e.language!=null)r.setAttribute("data-language",k(e.language));return n.appendChild(r),n}function $o(e,t){let n=g("div","pf-markdown"),r=w(e.content,t);return n.innerHTML=En(r),n.setAttribute("data-markdown","true"),n}var kn=/^\s*(javascript|vbscript|data):/i;function Ze(e){let t=He(e),n=[];return t=t.replace(/`([^`]+)`/g,(r,o)=>(n.push(`<code>${o}</code>`),`﷐CODE${n.length-1}﷐`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(r,o,i)=>{if(kn.test(i))return He(o);return`<img src="${i}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,i)=>{if(kn.test(i))return o;return`<a href="${i}">${o}</a>`}),t=t.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),t=t.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/\uFDD0CODE(\d+)\uFDD0/g,(r,o)=>n[parseInt(o)]),t}function En(e){let t=e.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `),n=[],r=0;while(r<t.length){let o=t[r];if(o.trimStart().startsWith("```")){let a=o.trimStart().slice(3).trim(),l=[];r++;while(r<t.length&&!t[r].trimStart().startsWith("```"))l.push(Ne(t[r])),r++;r++;let d=a?` data-language="${Ne(a)}"`:"";n.push(`<pre class="pf-code"><code${d}>${l.join(`
4
- `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(o)){n.push("<hr />"),r++;continue}let i=/^(#{1,6})\s+(.+)$/.exec(o);if(i){let a=i[1].length;n.push(`<h${a}>${Xe(i[2])}</h${a}>`),r++;continue}if(o.startsWith("> ")||o===">"){let a=[];while(r<t.length&&(t[r].startsWith("> ")||t[r]===">"))a.push(t[r].replace(/^>\s?/,"")),r++;n.push(`<blockquote>${xn(a.join(`
5
- `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(o)){n.push("<ul>");while(r<t.length&&/^[\s]*[-*+]\s+/.test(t[r]))n.push(`<li>${Xe(t[r].replace(/^[\s]*[-*+]\s+/,""))}</li>`),r++;n.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(o)){n.push("<ol>");while(r<t.length&&/^[\s]*\d+\.\s+/.test(t[r]))n.push(`<li>${Xe(t[r].replace(/^[\s]*\d+\.\s+/,""))}</li>`),r++;n.push("</ol>");continue}if(o.trim()===""){r++;continue}let s=[];while(r<t.length&&t[r].trim()!==""&&!/^#{1,6}\s/.test(t[r])&&!/^[-*+]\s/.test(t[r])&&!/^\d+\.\s/.test(t[r])&&!t[r].startsWith("> ")&&!t[r].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(t[r]))s.push(t[r]),r++;n.push(`<p>${s.map(Xe).join("<br />")}</p>`)}return n.join(`
6
- `)}function To(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=C(e.content,t),n}function vn(){p("Card",Ao),p("CardHeader",vt("pf-card-header")),p("CardTitle",wn("pf-card-title","h3")),p("CardDescription",wn("pf-card-description","p")),p("CardContent",vt("pf-card-content")),p("CardFooter",vt("pf-card-footer"))}function Ao(e,t){let n=g("div","pf-card");return n.style.overflow="hidden",M(e,n,t),n}function vt(e){return(t,n)=>{let r=g("div",e);return r.style.padding="16px 24px",M(t,r,n),r}}function wn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=C(n.content,r),o}}function kn(){p("DataTable",Mo),p("Badge",Lo),p("Dot",No),p("Metric",Ho),p("Ring",Po),p("Progress",$o),p("Separator",Oo),p("Loader",Do),p("Icon",Io),p("Sparkline",jo)}function Mo(e,t){let n=g("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable",r.style.width="100%",r.style.borderCollapse="collapse";let o=e.columns??[],i=z(e.rows,t),{rowKey:s,selected:a}=e,l=document.createElement("thead"),d=document.createElement("tr");for(let c of o){let f=document.createElement("th");f.className="pf-datatable-th",f.textContent=c.header??c.key,f.style.padding="8px 12px",f.style.textAlign="left",d.appendChild(f)}l.appendChild(d),r.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(i)){let c=a!=null?z(a,t):void 0;for(let f of i){let h=document.createElement("tr");h.className="pf-datatable-row";let y=f,m=f===null||typeof f!=="object";if(s&&c!=null&&y[s]!=null&&E(y[s])===E(c))h.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)h.style.cursor="pointer",h.addEventListener("click",()=>{let b={...t.scope,$item:y,$index:i.indexOf(f)},x=j({...t,scope:b});P(H(e.onRowClick,x),"onRowClick")});for(let b of o){let x=document.createElement("td");x.className="pf-datatable-td";let w;if(b.accessor)w=z(`{{ $item.${b.accessor} }}`,{...t,scope:{...t.scope,$item:y}});else if(w=m?f:y[b.key],b.format&&w!=null)w=z(`{{ __fmtVal | ${b.format} }}`,{...t,scope:{...t.scope,__fmtVal:w}});x.textContent=E(w),x.style.padding="8px 12px",h.appendChild(x)}u.appendChild(h)}}if(r.appendChild(u),e.search===!0){let c=document.createElement("input");c.type="text",c.placeholder="Search...",c.className="pf-datatable-search",c.style.marginBottom="8px",c.style.padding="6px 12px",c.style.width="100%",c.style.boxSizing="border-box",c.addEventListener("input",()=>{let f=c.value.toLowerCase(),h=Array.from(u.querySelectorAll("tr"));for(let y of h){let m=(y.textContent??"").toLowerCase();y.style.display=m.includes(f)?"":"none"}}),n.appendChild(c)}return n.appendChild(r),n}function Lo(e,t){let n=g("span","pf-badge"),r=e.variant??"default";return n.setAttribute("data-variant",r),n.style.alignItems="center",n.style.padding="2px 10px",n.style.borderRadius="9999px",n.style.fontSize="12px",n.style.fontWeight="500",n.textContent=C(e.label??e.content,t),Fo(n,r),n}function No(e,t){let n=g("span","pf-dot"),r=e.color??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=r,n}function Ho(e,t){let n=g("div","pf-metric"),r=g("div","pf-metric-label");r.textContent=C(e.label,t),r.style.fontSize="14px",n.appendChild(r);let o=g("div","pf-metric-value");if(o.textContent=C(e.value,t),o.style.fontSize="28px",o.style.fontWeight="700",n.appendChild(o),e.delta!=null){let i=g("span","pf-metric-delta");i.textContent=C(e.delta,t);let s=e.trend??"",a=e.trendSentiment??"neutral";if(i.style.fontSize="14px",i.style.color=a==="positive"?"green":a==="negative"?"red":"inherit",s==="up")i.textContent="↑ "+i.textContent;else if(s==="down")i.textContent="↓ "+i.textContent;n.appendChild(i)}if(e.description!=null){let i=g("div","pf-metric-desc");i.textContent=C(e.description,t),i.style.fontSize="12px",n.appendChild(i)}return n}function Po(e,t){let n=g("div","pf-ring"),r=e.size??80,o=e.thickness??8,i=Number(z(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(r-o)/2,l=2*Math.PI*a,d=l*(1-s/100),u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(r)),u.setAttribute("height",String(r)),u.setAttribute("viewBox",`0 0 ${r} ${r}`);let c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.setAttribute("cx",String(r/2)),c.setAttribute("cy",String(r/2)),c.setAttribute("r",String(a)),c.setAttribute("fill","none"),c.setAttribute("stroke","var(--muted, #e5e7eb)"),c.setAttribute("stroke-width",String(o));let f=document.createElementNS("http://www.w3.org/2000/svg","circle");if(f.setAttribute("cx",String(r/2)),f.setAttribute("cy",String(r/2)),f.setAttribute("r",String(a)),f.setAttribute("fill","none"),f.setAttribute("stroke","var(--primary, #3b82f6)"),f.setAttribute("stroke-width",String(o)),f.setAttribute("stroke-dasharray",String(l)),f.setAttribute("stroke-dashoffset",String(d)),f.setAttribute("stroke-linecap","round"),f.style.transform="rotate(-90deg)",f.style.transformOrigin="center",u.appendChild(c),u.appendChild(f),n.appendChild(u),e.label!=null){let h=g("div","pf-ring-label");h.textContent=C(e.label,t),h.style.textAlign="center",h.style.fontSize="12px",n.appendChild(h)}return n}function $o(e,t){let n=g("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(z(e.value,t)??0),o=e.max??100,i=o>0?Math.max(0,Math.min(100,r/o*100)):0;n.setAttribute("aria-valuenow",String(r)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(o)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let s=g("div","pf-progress-fill");return s.style.height="100%",s.style.width=`${i}%`,s.style.borderRadius="4px",s.style.transition="width 0.3s ease",n.appendChild(s),n}function Oo(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Do(e,t){let n=g("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function Io(e,t){let n=g("span","pf-icon");return n.setAttribute("data-icon",C(e.name??e.content,t)),n}function jo(e,t){let n=g("div","pf-sparkline"),r=e.data??[];if(r.length===0)return n;let o=e.width??120,i=e.height??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("width",String(o)),d.setAttribute("height",String(i)),d.setAttribute("viewBox",`0 0 ${o} ${i}`);let u=r.length>1?r.length-1:1,c=r.map((h,y)=>{let m=y/u*o,b=i-(h-a)/l*(i-4)-2;return`${m},${b}`}).join(" "),f=document.createElementNS("http://www.w3.org/2000/svg","polyline");return f.setAttribute("points",c),f.setAttribute("fill","none"),f.setAttribute("stroke","var(--primary, #3b82f6)"),f.setAttribute("stroke-width","1.5"),d.appendChild(f),n.appendChild(d),n}function Fo(e,t){let r={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(r)e.style.backgroundColor=r.bg,e.style.color=r.fg}function Sn(){p("Form",Bo),p("Input",Vo),p("Textarea",ye(_o)),p("Button",zo),p("ButtonGroup",Wo),p("Checkbox",Ko),p("Switch",Jo),p("Slider",ye(Go)),p("Calendar",Uo),p("DatePicker",ye(Xo)),p("Field",He("pf-field")),p("FieldTitle",Ce("pf-field-title")),p("FieldDescription",Ce("pf-field-description")),p("FieldContent",He("pf-field-content")),p("FieldError",Ce("pf-field-error"))}function Bo(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(r)=>{r.preventDefault();let o=new FormData(n),i={};for(let s of new Set(o.keys())){let a=o.getAll(s),l=n.elements.namedItem(s),d=l instanceof HTMLSelectElement&&l.multiple||a.length>1;i[s]=d?a:a[0]}if(t.store.merge(i),e.onSubmit!=null){let s=j(t);s.scope={...t.scope,...i},P(H(e.onSubmit,s),"onSubmit")}}),M(e,n,t),n}function En(e,t,n){if(t.label==null)return;let r=document.createElement("label");if(r.className="pf-input-label",r.textContent=C(t.label,n),t.name!=null)r.htmlFor=t.name;r.style.fontSize="14px",r.style.fontWeight="500",e.insertBefore(r,e.firstChild)}function ye(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",En(r,t,n),r}}function ie(e,t){if(t.required!==!0)return;if("required"in e)e.required=!0;e.setAttribute("aria-required","true")}function Vo(e,t){let n=g("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",En(n,e,t);let r=document.createElement("input");if(r.className="pf-input",r.type=e.inputType??"text",e.name!=null)r.name=e.name;if(e.name!=null)r.id=`pf-input-${e.name}`;if(e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(ie(r,e),e.error!=null)r.setAttribute("aria-invalid","true");let o=e.name;if(o){let i=t.store.get(o);if(i!=null)r.value=E(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)P(H(e.onChange,{...j(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Ye(r),n.appendChild(r),n}function _o(e,t){let n=g("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=e.name;if(e.name!=null)r.id=`pf-textarea-${e.name}`;if(e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.rows!=null)r.rows=e.rows;ie(r,e);let o=e.name;if(o!=null){let i=t.store.get(o);if(i!=null)r.value=E(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)P(H(e.onChange,{...j(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Ye(r),n.appendChild(r),n}function zo(e,t){let n=document.createElement("button");n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=C(e.label,t);let r=e.variant??"default";if(n.setAttribute("data-variant",r),qo(n,r),e.size!=null)n.setAttribute("data-size",e.size);if(e.disabled===!0)n.disabled=!0;return n}function Wo(e,t){let n=g("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",M(e,n,t),n}function Ko(e,t){let n=g("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-checkbox",e.name!=null)r.name=e.name;if(e.checked===!0)r.checked=!0;let o=e.name;if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)P(H(e.onChange,{...j(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=C(e.label,t),n.appendChild(i)}return n}function Jo(e,t){let n=g("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-switch",r.setAttribute("role","switch"),e.name!=null)r.name=e.name;let o=e.name;if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)P(H(e.onChange,{...j(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=C(e.label,t),n.appendChild(i)}return n}function Go(e,t){let n=g("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=e.name;if(e.min!=null)r.min=E(e.min);if(e.max!=null)r.max=E(e.max);if(e.step!=null)r.step=E(e.step);let o=e.name;if(o){let i=t.store.get(o);if(i!=null)r.value=E(i);r.addEventListener("input",()=>{if(t.store.set(o,Number(r.value)),e.onChange!=null)P(H(e.onChange,{...j(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function Ye(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function qo(e,t){if(e.style.padding="8px 16px",e.style.fontSize="14px",e.style.fontWeight="500",e.style.cursor="pointer",e.style.border="none",t==="ghost")e.style.backgroundColor="transparent",e.style.color="inherit"}function He(e){return(t,n)=>{let r=g("div",e);return M(t,r,n),r}}function Ce(e){return(t,n)=>{let r=g("span",e);return r.textContent=C(t.content,n),r}}function kt(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function Uo(e,t){let n=g("div","pf-calendar"),r=document.createElement("input");if(r.type="date",r.name=C(e.name,t),ie(r,e),e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=E(i);if(e.minDate!=null)r.min=C(e.minDate,t);if(e.maxDate!=null)r.max=C(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)P(H(e.onChange,j(t)),"onChange")}),n.appendChild(r),n}function Xo(e,t){let n=g("div","pf-datepicker"),r=document.createElement("input");if(r.type="date",r.name=C(e.name,t),ie(r,e),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=E(i);if(e.minDate!=null)r.min=C(e.minDate,t);if(e.maxDate!=null)r.max=C(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)P(H(e.onChange,j(t)),"onChange")}),n.appendChild(r),n}function Rn(){p("Select",ye(Yo)),p("SelectOption",ei),p("SelectGroup",He("pf-select-group")),p("SelectLabel",Ce("pf-select-label")),p("SelectSeparator",kt),p("Radio",ti),p("RadioGroup",ni),p("Combobox",ye(ri)),p("ComboboxOption",oi),p("ComboboxGroup",He("pf-combobox-group")),p("ComboboxLabel",Ce("pf-combobox-label")),p("ComboboxSeparator",kt),p("ChoiceCard",ii)}function Yo(e,t){let n=g("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=e.name;if(e.multiple===!0)r.multiple=!0;if(ie(r,e),Ye(r),e.placeholder!=null){let s=document.createElement("option");s.value="",s.textContent=C(e.placeholder,t),s.disabled=!0,s.selected=!0,s.hidden=!0,r.appendChild(s)}let o=e.options;if(Array.isArray(o))for(let s of o){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}if(e.children)for(let s of e.children)if(s.type==="SelectOption"){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}else r.appendChild(O(s,t));let i=e.name;if(i){let s=t.store.get(i);if(s!=null)Qo(r,s);r.addEventListener("change",()=>{let a=Zo(r);if(t.store.set(i,a),e.onChange!=null)P(H(e.onChange,{...j(t),scope:{...t.scope,$event:a}}),"onChange")})}return n.appendChild(r),n}function Zo(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function Qo(e,t){if(!e.multiple){e.value=E(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>E(r)));for(let r of e.options)r.selected=n.has(r.value)}function ei(e,t){return g("span")}function ti(e,t){let n=g("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="radio",r.value=C(e.value,t),n.appendChild(r),e.label!=null){let o=g("span","pf-radio-label");o.textContent=C(e.label,t),n.appendChild(o)}return n}function ni(e,t){let n=g("fieldset","pf-radio-group");if(ie(n,e),n.style.border="none",n.style.padding="0",n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",e.label!=null){let i=document.createElement("legend");i.textContent=C(e.label,t),i.style.fontWeight="500",i.style.marginBottom="4px",n.appendChild(i)}M(e,n,t);let r=C(e.name,t),o=t.store.get(r);for(let i of Array.from(n.querySelectorAll('input[type="radio"]')))if(i.name=r,o!=null&&i.value===E(o))i.checked=!0;return n.addEventListener("change",(i)=>{let s=i.target;if(s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)P(H(e.onChange,j(t)),"onChange")}}),n}function ri(e,t){let n=g("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=C(e.name,t),ie(r,e),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=E(i);r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box";let s=g("div","pf-combobox-dropdown");if(s.style.display="none",s.style.position="absolute",s.style.borderRadius="6px",s.style.maxHeight="200px",s.style.overflowY="auto",s.style.zIndex="50",M(e,s,t),r.addEventListener("focus",()=>{s.style.display="block"}),r.addEventListener("blur",()=>{setTimeout(()=>{s.style.display="none"},150)}),e.searchable!==!1)r.addEventListener("input",()=>{let a=r.value.toLowerCase();for(let l of Array.from(s.querySelectorAll(".pf-combobox-option"))){let d=(l.textContent??"").toLowerCase();l.style.display=d.includes(a)?"":"none"}});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{P(H(e.onChange,{...j(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function oi(e,t){let n=g("div","pf-combobox-option");return n.style.padding="6px 12px",n.style.cursor="pointer",n.textContent=C(e.label??e.value,t),n.dataset.value=C(e.value,t),n.addEventListener("mousedown",()=>{let r=n.closest(".pf-combobox"),o=r?.querySelector("input");if(o)o.value=n.dataset.value??"",t.store.set(o.name,o.value),r?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function ii(e,t){let n=g("div","pf-choice-card");if(n.style.padding="16px",n.style.cursor="pointer",n.style.transition="border-color 0.2s",n.dataset.value=C(e.value,t),e.selected===!0)n.dataset.selected="true";if(e.label!=null){let r=g("div","pf-choice-card-label");r.textContent=C(e.label,t),r.style.fontWeight="600",n.appendChild(r)}if(e.description!=null){let r=g("div","pf-choice-card-description");r.textContent=C(e.description,t),r.style.fontSize="14px",n.appendChild(r)}return M(e,n,t),n}function Tn(){p("Tabs",si),p("Tab",ai),p("Accordion",li),p("AccordionItem",di),p("Dialog",ci),p("Popover",pi),p("Tooltip",ui),p("HoverCard",fi),p("Carousel",mi)}function si(e,t){let n=g("div","pf-tabs"),r=g("div","pf-tabs-bar");r.setAttribute("role","tablist"),r.style.display="flex",r.style.gap="4px",r.style.marginBottom="12px";let o=[],i=[],s=e.children??[],a=(()=>{let d=e.defaultTab;if(typeof d==="number")return d>=0&&d<s.length?d:0;if(typeof d==="string"){let u=s.findIndex((c)=>c.title===d);return u>=0?u:0}return 0})();if(e.children)for(let d=0;d<e.children.length;d++){let u=e.children[d],c=`pf-tab-${Math.random().toString(36).slice(2,8)}`,f=`pf-panel-${Math.random().toString(36).slice(2,8)}`,h=document.createElement("button");h.type="button",h.className="pf-tab-trigger",h.textContent=u.title??`Tab ${d+1}`,h.setAttribute("role","tab"),h.setAttribute("aria-selected",d===a?"true":"false"),h.setAttribute("aria-controls",f),h.id=c,h.tabIndex=d===a?0:-1,h.style.padding="8px 16px",h.style.border="none",h.style.background="none",h.style.cursor="pointer",h.style.borderBottom="2px solid transparent",h.style.marginBottom="-2px",h.style.fontSize="14px";let y=g("div","pf-tab-panel");if(y.style.display=d===a?"block":"none",y.setAttribute("role","tabpanel"),y.setAttribute("aria-labelledby",c),y.id=f,y.tabIndex=0,M(u,y,t),h.addEventListener("click",()=>{l(d)}),d===a)h.classList.add("pf-tab-active"),h.style.fontWeight="600";i.push(h),o.push(y),r.appendChild(h)}function l(d){o.forEach((u)=>u.style.display="none"),i.forEach((u)=>{u.style.borderBottomColor="transparent",u.style.fontWeight="normal",u.classList.remove("pf-tab-active"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}),o[d].style.display="block",i[d].classList.add("pf-tab-active"),i[d].style.fontWeight="600",i[d].setAttribute("aria-selected","true"),i[d].tabIndex=0,i[d].focus()}r.addEventListener("keydown",(d)=>{let u=i.indexOf(d.target);if(u<0)return;let c;if(d.key==="ArrowRight")c=(u+1)%i.length;else if(d.key==="ArrowLeft")c=(u-1+i.length)%i.length;else if(d.key==="Home")c=0;else if(d.key==="End")c=i.length-1;else return;d.preventDefault(),l(c)}),n.appendChild(r);for(let d of o)n.appendChild(d);return n}function ai(e,t){let n=g("div","pf-tab");return M(e,n,t),n}function li(e,t){let n=g("div","pf-accordion");return M(e,n,t),n}function di(e,t){let n=g("div","pf-accordion-item"),r=`pf-acc-${Math.random().toString(36).slice(2,8)}`,o=document.createElement("button");o.type="button",o.className="pf-accordion-trigger",o.textContent=e.title??"",o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",r),o.style.width="100%",o.style.textAlign="left",o.style.padding="12px 0",o.style.border="none",o.style.background="none",o.style.cursor="pointer",o.style.fontSize="14px",o.style.fontWeight="500";let i=g("div","pf-accordion-content");return i.id=r,i.setAttribute("role","region"),i.setAttribute("aria-labelledby",o.id),i.style.display="none",i.style.paddingBottom="12px",M(e,i,t),o.addEventListener("click",()=>{let s=i.style.display!=="none";i.style.display=s?"none":"block",o.setAttribute("aria-expanded",s?"false":"true")}),n.appendChild(o),n.appendChild(i),n}function ci(e,t){let n=g("div","pf-dialog-wrapper");if(e.trigger!=null){let i=O(e.trigger,t);i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i)}let r=document.createElement("dialog");if(r.className="pf-dialog",r.setAttribute("aria-modal","true"),r.style.maxWidth="500px",r.style.width="100%",r.style.padding="24px",e.title!=null){let i=g("h2","pf-dialog-title");i.textContent=C(e.title,t),i.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",i.id),r.appendChild(i)}if(e.description!=null){let i=g("p","pf-dialog-desc");i.textContent=C(e.description,t),r.appendChild(i)}let o=g("div","pf-dialog-body");if(M(e,o,t),r.appendChild(o),e.dismissible!==!1)r.addEventListener("click",(i)=>{if(i.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function pi(e,t){let n=g("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-popover-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="12px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let i=g("div","pf-popover-title");i.textContent=C(e.title,t),i.style.fontWeight="600",i.style.marginBottom="4px",r.appendChild(i)}M(e,r,t);let o=()=>{r.style.display=r.style.display==="none"?"block":"none"};if(e.trigger!=null){let i=O(e.trigger,t);i.addEventListener("click",(s)=>{s.stopPropagation(),o()}),n.appendChild(i)}else n.addEventListener("click",(i)=>{if(r.contains(i.target)&&r.style.display!=="none")return;o()});return n.appendChild(r),n}function ui(e,t){let n=g("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let r=`pf-tip-${Math.random().toString(36).slice(2,8)}`,o=g("div","pf-tooltip-content");return o.id=r,o.setAttribute("role","tooltip"),o.textContent=C(e.content??"",t),o.style.display="none",o.style.position="absolute",o.style.bottom="100%",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.padding="4px 8px",o.style.borderRadius="4px",o.style.color="#fff",o.style.fontSize="12px",o.style.whiteSpace="nowrap",o.style.zIndex="50",M(e,n,t),n.setAttribute("aria-describedby",r),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.addEventListener("focus",()=>{o.style.display="block"},!0),n.addEventListener("blur",()=>{o.style.display="none"},!0),n.appendChild(o),n}function fi(e,t){let n=g("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-hover-card-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="16px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",r.style.minWidth="200px",e.trigger!=null)n.appendChild(O(e.trigger,t));return M(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function mi(e,t){let n=g("div","pf-carousel");n.style.position="relative",n.style.overflow="hidden",n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",C(e.label??"Carousel",t));let r=g("div","pf-carousel-track");r.style.display="flex",r.style.transition="transform 0.3s ease",M(e,r,t);let o=0,i=e.children?.length??0,s=document.createElement("button");s.type="button",s.textContent="‹",s.className="pf-carousel-prev",s.setAttribute("aria-label","Previous slide"),s.style.position="absolute",s.style.left="4px",s.style.top="50%",s.style.transform="translateY(-50%)",s.style.zIndex="10";let a=document.createElement("button");a.type="button",a.textContent="›",a.className="pf-carousel-next",a.setAttribute("aria-label","Next slide"),a.style.position="absolute",a.style.right="4px",a.style.top="50%",a.style.transform="translateY(-50%)",a.style.zIndex="10";let l=()=>{r.style.transform=`translateX(-${o*100}%)`};return s.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),l()}),a.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),l()}),n.appendChild(r),n.appendChild(s),n.appendChild(a),n}function An(){p("ForEach",gi),p("If",Mn),p("Elif",hi),p("Else",bi),p("Condition",yi),p("Define",Ci),p("Use",xi),p("Slot",wi)}function gi(e,t){let n=document.createDocumentFragment(),r=e.expression;if(!r)return n;let o;if(K(r)){let s=J(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=e.let??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},d={...t,scope:l};if(e.children)oe(e.children,n,d)}return n}function Mn(e,t){if(Ln(e.condition,t)){let r=document.createDocumentFragment();if(e.children)oe(e.children,r,t);return r}return document.createDocumentFragment()}function hi(e,t){return Mn(e,t)}function bi(e,t){let n=document.createDocumentFragment();if(e.children)oe(e.children,n,t);return n}function Ln(e,t){if(!e)return!1;if(K(e))return Boolean(J(e,t.store,t.scope));return Boolean(t.store.get(e))}function yi(e,t){let n=document.createDocumentFragment(),{cases:r,else:o}=e;if(r){for(let i of r)if(Ln(i.when,t)){if(i.children)oe(i.children,n,t);return n}}if(o)oe(o,n,t);return n}function Ci(e,t){let n=e.name;if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function xi(e,t){let n=document.createDocumentFragment(),r=e.def??e.name,o=t.templates?.[r];if(!o)return n;let i=e.overrides??{},s={...t.scope,...i},a={...t.slots??{},...e.slots??{}};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let d of o)n.appendChild(O(d,l));return n}function wi(e,t){let n=document.createDocumentFragment(),r=e.name??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(O(s,t));return n}function Nn(){p("Alert",vi),p("AlertTitle",ki),p("AlertDescription",Si)}function vi(e,t){let n=g("div","pf-alert");n.setAttribute("role","alert");let r=e.variant??"default";if(n.setAttribute("data-variant",r),n.style.padding="12px 16px",e.icon!=null){let o=g("span","pf-alert-icon");o.setAttribute("data-icon",e.icon),o.style.marginRight="8px",n.appendChild(o)}return M(e,n,t),n}function ki(e,t){let n=g("h5","pf-alert-title");return n.textContent=C(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function Si(e,t){let n=g("p","pf-alert-description");return n.textContent=C(e.content,t),n.style.fontSize="14px",n}function Hn(){p("Image",Ei),p("Audio",Ri),p("Video",Ti),p("Embed",Ai),p("Svg",Li),p("DropZone",Hi),p("Mermaid",Pi)}function Ei(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=C(e.src,t),e.alt!=null)n.alt=C(e.alt,t);if(e.width!=null)n.width=e.width;if(e.height!=null)n.height=e.height;return n.style.maxWidth="100%",n}function Ri(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=C(e.src,t),n.controls=!0,n}function Ti(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=C(e.src,t),n.controls=!0,e.width!=null)n.width=e.width;if(e.height!=null)n.height=e.height;return n.style.maxWidth="100%",n}function Ai(e,t){let n=g("div","pf-embed"),r=document.createElement("iframe");return r.src=C(e.src,t),r.style.width="100%",r.style.height=e.height!=null?`${e.height}px`:"400px",r.style.border="none",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var Mi=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","defs","use","symbol","clippath","mask","pattern","lineargradient","radialgradient","stop","filter","fegaussianblur","feoffset","femerge","femergenode","fecolormatrix","feblend","title","desc"]);function Li(e,t){let n=g("div","pf-svg"),r=C(e.content,t);if(!r.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(r))r=r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let i=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!i)return n;return Pn(i),n.appendChild(document.importNode(i,!0)),n}function Pn(e){let t=Array.from(e.children);for(let n of t){if(!Mi.has(n.tagName.toLowerCase())){n.remove();continue}for(let r of Array.from(n.attributes)){let o=r.name.toLowerCase();if(o.startsWith("on")||o==="href"&&r.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(r.name)}Pn(n)}}function Ni(e,t){let n=(t??"").split(",").map((i)=>i.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let r=e.name.toLowerCase(),o=e.type.toLowerCase();return n.some((i)=>{if(i.startsWith("."))return r.endsWith(i);if(i.endsWith("/*"))return o.startsWith(i.slice(0,-1));return o===i})}function Hi(e,t){let n=g("div","pf-dropzone");n.style.padding="32px",n.style.textAlign="center",n.style.cursor="pointer",n.textContent=C(e.label??"Drop files here",t);let r=document.createElement("input");if(r.type="file",r.style.display="none",e.accept!=null)r.accept=e.accept;if(e.multiple===!0)r.multiple=!0;n.appendChild(r),n.setAttribute("role","button"),n.tabIndex=0;function o(s){let a=Array.from(s??[]).filter((l)=>Ni(l,e.accept));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;if(e.resultKey!=null)t.store.set(e.resultKey,s),t.rerender();if(e.onDrop!=null)P(H(e.onDrop,{...j(t),scope:{...t.scope,$result:s}}),"onDrop")}return r.addEventListener("change",()=>{i(o(r.files)),r.value=""}),n.addEventListener("click",()=>r.click()),n.addEventListener("keydown",(s)=>{if(s.key==="Enter"||s.key===" ")s.preventDefault(),r.click()}),n.addEventListener("dragover",(s)=>{s.preventDefault(),n.classList.add("pf-dropzone-active")}),n.addEventListener("dragleave",()=>{n.classList.remove("pf-dropzone-active")}),n.addEventListener("drop",(s)=>{s.preventDefault(),n.classList.remove("pf-dropzone-active"),i(o(s.dataTransfer?.files??null))}),n}function Pi(e,t){let n=g("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=C(e.content,t);if(n.textContent=r,typeof globalThis.mermaid<"u")n.classList.add("mermaid"),n.textContent=r;return n}var $i="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Oi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",St=null,Ze=null;async function Di(){if(St)return St;if(Ze)return Ze;return Ze=import($i).then((e)=>{let t=e;return t.GlobalWorkerOptions.workerSrc=Oi,St=t,t}),Ze}function On(){p("PdfViewer",Ii)}function Ii(e,t){let n=g("div","pf-pdf-viewer"),r=e.src!=null?C(e.src,t):void 0,o=e.data,i=e.page!=null?e.page:1,s=e.zoom!=null?e.zoom:"fit-width",a=e.toolbar!==!1,l=e.height!=null?e.height:600;n.style.height=`${l}px`,n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",n.style.border="1px solid var(--color-border-primary, #e5e7eb)",n.style.borderRadius="var(--border-radius-md, 0.375rem)",n.style.background="var(--color-background-secondary, #f9fafb)";let d=g("div","pf-pdf-loading");return d.textContent="Loading PDF…",d.style.display="flex",d.style.alignItems="center",d.style.justifyContent="center",d.style.flex="1",d.style.color="var(--color-text-secondary, #6b7280)",n.appendChild(d),ji(n,d,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function ji(e,t,n){try{let r=await Di(),o;if(n.src)o={url:n.src};else if(n.data){let f=atob(n.data),h=new Uint8Array(f.length);for(let y=0;y<f.length;y++)h[y]=f.charCodeAt(y);o={data:h}}else{t.textContent="Error: No PDF source provided";return}let i=await r.getDocument(o).promise;t.remove();let s=Math.max(1,Math.min(n.initialPage,i.numPages)),a=null,l=null;if(n.showToolbar){let f=Fi(i.numPages,s,{onPrev:()=>{if(s>1)s--,c()},onNext:()=>{if(s<i.numPages)s++,c()},onPageChange:(h)=>{let y=Math.max(1,Math.min(h,i.numPages));if(y!==s)s=y,c()}});a=f.pageInput,l=f.pageCount,e.insertBefore(f.el,e.firstChild)}let d=g("div","pf-pdf-canvas-container");d.style.flex="1",d.style.overflow="auto",d.style.display="flex",d.style.justifyContent="center",d.style.padding="8px",e.appendChild(d);let u=document.createElement("canvas");u.style.display="block",u.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",d.appendChild(u);async function c(){let f=await i.getPage(s),h=d.clientWidth-16,y,m=f.getViewport({scale:1});if(n.zoom==="fit-width")y=h/m.width;else if(n.zoom==="fit-page"){let w=d.clientHeight-16,A=h/m.width,k=w/m.height;y=Math.min(A,k)}else y=typeof n.zoom==="number"?n.zoom:1;let b=f.getViewport({scale:y});u.width=b.width,u.height=b.height,u.style.width=`${b.width}px`,u.style.height=`${b.height}px`;let x=u.getContext("2d");if(!x)return;if(await f.render({canvasContext:x,viewport:b}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await c()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function Fi(e,t,n){let r=g("div","pf-pdf-toolbar");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.padding="6px 12px",r.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",r.style.background="var(--color-background-primary, #fff)",r.style.flexShrink="0",r.style.fontSize="13px";let o=document.createElement("button");o.textContent="‹",o.title="Previous page",o.className="pf-pdf-btn",$n(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",$n(i),i.addEventListener("click",n.onNext);let s=document.createElement("input");s.type="number",s.min="1",s.max=String(e),s.value=String(t),s.style.width="48px",s.style.textAlign="center",s.style.border="1px solid var(--color-border-primary, #e5e7eb)",s.style.borderRadius="4px",s.style.padding="2px 4px",s.style.fontSize="13px",s.addEventListener("change",()=>{let l=parseInt(s.value,10);if(!isNaN(l))n.onPageChange(l)});let a=document.createElement("span");return a.textContent=`/ ${e}`,a.style.color="var(--color-text-secondary, #6b7280)",r.appendChild(o),r.appendChild(s),r.appendChild(a),r.appendChild(i),{el:r,pageInput:s,pageCount:a}}function $n(e){e.style.border="1px solid var(--color-border-primary, #e5e7eb)",e.style.borderRadius="4px",e.style.background="var(--color-background-primary, #fff)",e.style.cursor="pointer",e.style.padding="2px 8px",e.style.fontSize="16px",e.style.lineHeight="1"}var D=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],q="var(--muted-foreground, #6b7280)",pe="var(--border, #e5e7eb)",se="10";function Qe(e,t,n,r=!1){let o=n?44:0,i=e-(r?44:0),s=10,a=t-24;return{plotLeft:o,plotRight:i,plotTop:10,plotBottom:a,plotWidth:i-o,plotHeight:a-10}}function Dn(e,t=5){if(e<=0)return[0];let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,i=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r,s=[];for(let a=0;a<=e+i*0.01;a+=i)s.push(Math.round(a*1000)/1000);return s}function In(e,t,n,r,o){let i=Dn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=_("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":se,fill:q});if(l.textContent=Rt(s,o),e.appendChild(l),r&&s>0)e.appendChild(_("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:pe,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function jn(e,t,n,r){let o=Dn(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=_("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":se,fill:q});a.textContent=Rt(i,r),e.appendChild(a)}}function Et(e,t,n,r,o,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=_("text",{x:r(s),y:o+14,"text-anchor":"middle","font-size":se,fill:q});l.textContent=a==null?"":i?i(a):E(a),e.appendChild(l)}}function et(e,t){e.appendChild(_("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:q,"stroke-width":1}))}function ae(e,t,n){if(e==null)return"";let r=z(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return E(r??e)}function Rt(e,t){if(t==="currency")return`$${e.toLocaleString()}`;if(t==="percent")return`${e}%`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1000)return`${(e/1000).toFixed(1)}K`;return String(e)}function le(e){let t=S(e.yAxisFormat)??S(e.valueFormat);return t&&t!=="auto"?t:void 0}function Tt(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return ae(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return Rt(Number(r),i)}}function Q(e,t,n){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r.setAttribute("width","100%"),r.setAttribute("height",String(t)),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("role","img"),n)r.setAttribute("aria-label",`${n} chart`);return r.style.overflow="visible",r}function _(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function Pe(e,t){let n=_("text",e);return n.textContent=t,n}function ue(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function At(e,t,n,r,o){let i=Math.max(2,Math.ceil(Math.abs(o-r)/4)),s=[];for(let a=0;a<=i;a++){let l=ue(e,t,n,r+(o-r)*a/i);s.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return s.join(" ")}function ee(e,t,n){if(!n||t.length<=1)return;let r=g("div","pf-chart-legend");r.style.display="flex",r.style.gap="12px",r.style.fontSize="12px",r.style.marginBottom="8px";for(let o=0;o<t.length;o++){let i=g("div","pf-chart-legend-item");i.style.display="flex",i.style.alignItems="center",i.style.gap="4px";let s=g("span");s.style.width="8px",s.style.height="8px",s.style.borderRadius="50%",s.style.backgroundColor=t[o].color??D[o%D.length];let a=g("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}function te(e,t){let n=document.createElement("div");return n.className="pf-chart-tooltip",e.appendChild(n),e.addEventListener("mouseleave",()=>{n.classList.remove("pf-visible")}),{wrapper:e,tooltip:n,svgEl:t}}function Mt(e,t,n,r,o){let{tooltip:i,svgEl:s,wrapper:a}=e;if(o.length===0)return;let l="";if(r)l+=`<div class="pf-chart-tooltip-label">${tt(r)}</div>`;for(let b of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${tt(b.color)}"></span>`,l+=`<span>${tt(b.label)}:</span> <strong>${tt(String(b.value))}</strong>`,l+="</div>";i.innerHTML=l;let d=s.getBoundingClientRect(),u=a.getBoundingClientRect(),c=s.viewBox.baseVal,f=d.width/(c.width||1),h=d.left-u.left+t*f,y=i.offsetWidth||100,m=h+12;if(m+y>u.width)m=h-y-12;i.style.left=`${Math.max(0,m)}px`,i.style.top="4px",i.classList.add("pf-visible")}function tt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xe(e,t,n,r,o,i){let s=()=>{Mt(t,n,r,o,i)},a=()=>{t.tooltip.classList.remove("pf-visible")};e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",a),e.addEventListener("touchstart",s,{passive:!0}),e.addEventListener("touchend",a,{passive:!0})}function Fn(e,t,n,r,o,i,s,a){let l=o.plotWidth/n.length;for(let d=0;d<n.length;d++){let u=o.plotLeft+d*l,c=document.createElementNS("http://www.w3.org/2000/svg","rect");c.setAttribute("x",String(u)),c.setAttribute("y",String(o.plotTop)),c.setAttribute("width",String(l)),c.setAttribute("height",String(o.plotHeight)),c.setAttribute("fill","transparent"),c.style.cursor="default";let f=i?n[d][i]:void 0,h=f!=null?a?a(f):E(f):void 0,y=r.map((w,A)=>({label:w.label??w.dataKey,value:s(n[d][w.dataKey],w,A),color:w.color??D[A%D.length]})),m=u+l/2,b=()=>Mt(e,m,o.plotTop,h,y),x=()=>e.tooltip.classList.remove("pf-visible");c.addEventListener("mouseenter",b),c.addEventListener("mouseleave",x),c.addEventListener("touchstart",b,{passive:!0}),c.addEventListener("touchend",x,{passive:!0}),t.appendChild(c)}}function Bn(e,t,n,r,o,i,s,a,l,d){let u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let c=0;c<n.length;c++){let f=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+c/(n.length-1)*o.plotWidth,h=n.length===1?o.plotLeft:f-u/2,y=n.length===1?o.plotWidth:u,m=document.createElementNS("http://www.w3.org/2000/svg","rect");m.setAttribute("x",String(Math.max(o.plotLeft,h))),m.setAttribute("y",String(o.plotTop)),m.setAttribute("width",String(Math.min(y,o.plotRight-Math.max(o.plotLeft,h)))),m.setAttribute("height",String(o.plotHeight)),m.setAttribute("fill","transparent"),m.style.cursor="default";let b=i?n[c][i]:void 0,x=b!=null?d?d(b):E(b):void 0,w=r.map((v,R)=>({label:v.label??v.dataKey,value:s(n[c][v.dataKey],v,R),color:v.color??D[R%D.length]})),A=()=>{if(Mt(e,f,o.plotTop,x,w),a)a.setAttribute("x1",String(f)),a.setAttribute("x2",String(f)),a.setAttribute("opacity","1");if(l)for(let v of l){for(let R of v)R.setAttribute("data-visible","false");v[c]?.setAttribute("data-visible","true")}},k=()=>{if(e.tooltip.classList.remove("pf-visible"),a)a.setAttribute("opacity","0");if(l)for(let v of l)for(let R of v)R.setAttribute("data-visible","false")};m.addEventListener("mouseenter",A),m.addEventListener("mouseleave",k),m.addEventListener("touchstart",A,{passive:!0}),m.addEventListener("touchend",k,{passive:!0}),t.appendChild(m)}}function fe(e,t){return Ae(z(e.data,t))}function Vn(e,t){let n=z(e.data,t);if(!Array.isArray(n)||n.length===0)return;return n.filter((r)=>typeof r==="number"&&Number.isFinite(r))}function Bi(e){return e==="left"||e==="right"?e:void 0}function Vi(e){if(!B(e)||typeof e.dataKey!=="string")return;let t=S(e.label),n=S(e.color),r=Bi(e.yAxisId),o=S(e.tooltipFormat);return{dataKey:e.dataKey,...t!==void 0&&{label:t},...n!==void 0&&{color:n},...r!==void 0&&{yAxisId:r},...o!==void 0&&{tooltipFormat:o}}}function me(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=Vi(t);return n?[n]:[]})}function de(e,t){return V(e.height)??t}function $e(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function Lt(e,t){return{valueKey:S(e.dataKey)??t[0]?.dataKey,nameKey:S(e.nameKey)??S(e.tooltipXKey)??S(e.xAxis)}}function Nt(e,t){return{rows:fe(e,t),series:me(e),height:de(e,300),showYAxis:e.showYAxis!==!1,showGrid:e.showGrid===!0,showYAxisRight:e.showYAxisRight===!0,showTooltip:e.showTooltip!==!1,showLegend:e.showLegend!==!1,xAxisKey:S(e.xAxis),tooltipXKey:S(e.tooltipXKey),xAxisFormat:S(e.xAxisFormat),tooltipXFormat:S(e.tooltipXFormat),yAxisRightFormat:S(e.yAxisRightFormat)}}function _n(e,t,n){let r=t.series.filter((c)=>c.yAxisId!=="right"),o=t.series.filter((c)=>c.yAxisId==="right"),i=t.showYAxisRight&&o.length>0,s=r.length>0?$e(t.rows,r):1,a=i?$e(t.rows,o):1,l=400,d=Qe(400,t.height,t.showYAxis,i),u=Q(400,t.height,n);if(t.showYAxis)In(u,d,s,t.showGrid,le(e));if(i)jn(u,d,a,t.yAxisRightFormat);return et(u,d),{layout:d,svg:u,leftMax:s,rightMax:a}}function nt(e,t){return e?(n)=>ae(n,e,t):void 0}function zn(e,t){let n=g("div","pf-chart pf-bar-chart"),r=Nt(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let{layout:s,svg:a,leftMax:l,rightMax:d}=_n(e,r,"Bar"),u=s.plotWidth/o.length,c=u/(i.length+1);for(let f=0;f<o.length;f++)for(let h=0;h<i.length;h++){let y=i[h],m=o[f][y.dataKey];if(m===null||m===void 0)continue;let b=y.yAxisId==="right"?d:l,x=Math.max(0,Number(m)/b*s.plotHeight),w=s.plotLeft+f*u+h*c+c/2,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(w)),A.setAttribute("y",String(s.plotBottom-x)),A.setAttribute("width",String(c*0.8)),A.setAttribute("height",String(x)),A.setAttribute("fill",y.color??D[h%D.length]),A.setAttribute("rx","2"),a.appendChild(A)}if(r.xAxisKey)Et(a,o,r.xAxisKey,(f)=>s.plotLeft+f*u+u/2,s.plotBottom,nt(r.xAxisFormat,t));if(r.showTooltip){let f=te(n,a),h=Tt(t,le(e),r.yAxisRightFormat);Fn(f,a,o,i,s,r.tooltipXKey??r.xAxisKey,h,nt(r.tooltipXFormat,t))}return ee(n,i,r.showLegend),n.appendChild(a),n}function _i(e,t,n,r){let o=[],i=()=>{if(o.length<2){o=[];return}let s=`M ${o[0].x},${n} `+o.map((l)=>`L ${l.x},${l.y}`).join(" ")+` L ${o[o.length-1].x},${n} Z`,a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",s),a.setAttribute("fill",r),a.setAttribute("opacity","0.15"),e.appendChild(a),o=[]};for(let s of t){if(s.isNull){i();continue}o.push(s)}i()}function zi(e,t,n,r){let o="";for(let s of t){if(s.isNull)continue;let a=t.indexOf(s),l=a===0||t[a-1].isNull;o+=`${l?"M":"L"} ${s.x},${s.y} `}if(!o)return;let i=document.createElementNS("http://www.w3.org/2000/svg","path");if(i.setAttribute("d",o.trim()),i.setAttribute("fill","none"),i.setAttribute("stroke",n),i.setAttribute("stroke-width","2"),r)i.setAttribute("stroke-dasharray","6 3");e.appendChild(i)}function Wi(e,t,n){let r=[];for(let o of t){let i=document.createElementNS("http://www.w3.org/2000/svg","circle");if(i.setAttribute("cx",String(o.x)),i.setAttribute("cy",String(o.y)),i.setAttribute("r","4"),i.setAttribute("fill",n),i.setAttribute("class","pf-data-dot"),i.setAttribute("data-visible","false"),i.style.pointerEvents="none",o.isNull)i.style.display="none";e.appendChild(i),r.push(i)}return r}function Ki(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg","line");return n.setAttribute("class","pf-crosshair"),n.setAttribute("x1",String(t.plotLeft)),n.setAttribute("x2",String(t.plotLeft)),n.setAttribute("y1",String(t.plotTop)),n.setAttribute("y2",String(t.plotBottom)),n.setAttribute("stroke",q),n.setAttribute("stroke-width","1"),n.setAttribute("stroke-dasharray","3 3"),n.setAttribute("opacity","0"),e.appendChild(n),n}function Ht(e,t){let n=g("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=Nt(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let s=e.type==="AreaChart",{layout:a,svg:l,leftMax:d,rightMax:u}=_n(e,r,s?"Area":"Line"),c=(y)=>o.length===1?(a.plotLeft+a.plotRight)/2:a.plotLeft+y/(o.length-1)*a.plotWidth,f=[];for(let y=0;y<i.length;y++){let m=i[y],b=m.yAxisId==="right",x=b?u:d,w=m.color??D[y%D.length],A=o.map((k,v)=>{let R=k[m.dataKey],I=R===null||R===void 0,N=I?a.plotBottom:a.plotBottom-Number(R)/x*a.plotHeight;return{x:c(v),y:N,isNull:I}});if(s)_i(l,A,a.plotBottom,w);zi(l,A,w,b),f.push(Wi(l,A,w))}let h=Ki(l,a);if(r.xAxisKey)Et(l,o,r.xAxisKey,c,a.plotBottom,nt(r.xAxisFormat,t));if(r.showTooltip){let y=te(n,l),m=Tt(t,le(e),r.yAxisRightFormat);Bn(y,l,o,i,a,r.tooltipXKey??r.xAxisKey,m,h,f,nt(r.tooltipXFormat,t))}return ee(n,i,r.showLegend),n.appendChild(l),n}function Pt(e,t){let n=le(e);return(r)=>n?ae(r,n,t):String(r)}function Wn(e,t){let n=g("div","pf-chart pf-pie-chart"),r=fe(e,t),o=me(e),i=Math.min(de(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=Lt(e,o),d=o.length>0?o:a?[{dataKey:a,label:a}]:[];if(r.length===0||!a)return n.textContent="No chart data",n;let u=Q(i,i,"Pie"),c=i/2,f=i/2,h=i/2-10,y=S(e.tooltipXFormat),m=Pt(e,t),b=r.map((k)=>Number(k[a]??0)),x=b.reduce((k,v)=>k+v,0);if(x===0)return n.textContent="No chart data",n.appendChild(u),n;let w=s?te(n,u):void 0,A=-Math.PI/2;for(let k=0;k<b.length;k++){let v=b[k]/x*2*Math.PI,R=A+v,I=v>Math.PI?1:0,N=c+h*Math.cos(A),F=f+h*Math.sin(A),X=c+h*Math.cos(R),Y=f+h*Math.sin(R),Z=D[k%D.length],G=document.createElementNS("http://www.w3.org/2000/svg","path");if(G.setAttribute("d",`M ${c},${f} L ${N},${F} A ${h},${h} 0 ${I} 1 ${X},${Y} Z`),G.setAttribute("fill",Z),G.style.cursor="default",w){let L=l?r[k][l]:void 0,ce=L!=null?y?ae(L,y,t):E(L):`Slice ${k+1}`,ne=`${(b[k]/x*100).toFixed(1)}%`,at=c+h*0.6*Math.cos(A+v/2);xe(G,w,at,f,ce,[{label:d[0].label??a,value:`${m(b[k])} (${ne})`,color:Z}])}u.appendChild(G),A=R}return ee(n,d,e.showLegend!==!1),n.appendChild(u),n}function Kn(e,t){let n=g("div","pf-chart pf-radial-chart"),r=fe(e,t),o=me(e),{valueKey:i,nameKey:s}=Lt(e,o);if(r.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(de(e,300),300),l=a/2,d=a/2,u=a/2-10,c=Math.max(0,Math.min(V(e.innerRadius)??30,u-10)),f=V(e.startAngle)??180,h=V(e.endAngle)??0,y=r.map((R)=>Number(R[i]??0)),m=Math.max(...y,1),b=Q(a,a,"Radial"),x=(u-c)/r.length,w=Math.max(2,x*0.7),A=Pt(e,t),k=e.showTooltip!==!1?te(n,b):void 0,v=[];for(let R=0;R<r.length;R++){let I=u-x*R-x/2,N=o[R]?.color??D[R%D.length],F=f+y[R]/m*(h-f),X=s?r[R][s]:null,Y=X!=null?E(X):o[R]?.label??i;v.push({dataKey:Y||i,label:Y||i,color:N}),b.appendChild(_("path",{d:At(l,d,I,f,h),fill:"none",stroke:pe,"stroke-width":w,"stroke-linecap":"round"}));let Z=_("path",{d:At(l,d,I,f,F),fill:"none",stroke:N,"stroke-width":w,"stroke-linecap":"round"});if(k){let G=ue(l,d,I,(f+F)/2);xe(Z,k,G.x,G.y,Y||i,[{label:i,value:A(y[R]),color:N}])}b.appendChild(Z)}return ee(n,v,e.showLegend!==!1),n.appendChild(b),n}function Jn(e,t){let n=g("div","pf-chart pf-radar-chart"),r=fe(e,t),o=me(e),i=S(e.axisKey)??S(e.xAxis);if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.filled!==!1,a=e.showDots===!0,l=e.showGrid!==!1,d=Math.min(de(e,300),320),u=d/2,c=d/2,f=d/2-24,h=r.length,y=$e(r,o),m=(k)=>90-360*k/h,b=(k)=>k.map((v)=>`${v.x.toFixed(1)},${v.y.toFixed(1)}`).join(" "),x=Q(d,d,"Radar");if(l){for(let v=1;v<=4;v++){let R=f*v/4,I=Array.from({length:h},(N,F)=>ue(u,c,R,m(F)));x.appendChild(_("polygon",{points:b(I),fill:"none",stroke:pe,"stroke-width":1}))}for(let v=0;v<h;v++){let R=ue(u,c,f,m(v));x.appendChild(_("line",{x1:u,y1:c,x2:R.x,y2:R.y,stroke:pe,"stroke-width":1}))}}for(let k=0;k<h;k++){let v=ue(u,c,f+12,m(k)),R=i?r[k][i]:null;x.appendChild(Pe({x:v.x,y:v.y+3,"text-anchor":"middle","font-size":se,fill:q},E(R)))}let w=e.showTooltip!==!1?te(n,x):void 0,A=Pt(e,t);for(let k=0;k<o.length;k++){let v=o[k],R=v.color??D[k%D.length],I=r.map((N,F)=>ue(u,c,Number(N[v.dataKey]??0)/y*f,m(F)));if(x.appendChild(_("polygon",{points:b(I),fill:s?R:"none","fill-opacity":s?0.2:0,stroke:R,"stroke-width":2})),!a&&!w)continue;for(let N=0;N<I.length;N++){let F=_("circle",{cx:I[N].x,cy:I[N].y,r:a?3:6,fill:a?R:"transparent","fill-opacity":a?1:0});if(w){let X=i?r[N][i]:null,Y=X!=null?E(X):v.label??v.dataKey,Z=[{label:v.label??v.dataKey,value:A(Number(r[N][v.dataKey]??0)),color:R}];xe(F,w,I[N].x,I[N].y,Y,Z)}x.appendChild(F)}}return ee(n,o,e.showLegend!==!1),n.appendChild(x),n}function Gn(e,t){let n=g("div","pf-chart pf-scatter-chart"),r=fe(e,t),o=S(e.xAxis),i=S(e.yAxis),s=S(e.zAxis),a=me(e),l=de(e,300);if(r.length===0||!o||!i)return n.textContent="No chart data",n;let d=e.showGrid!==!1,u=a[0]?.color??D[0],c=le(e),f=(L)=>c?ae(L,c,t):String(Math.round(L*100)/100),h=r.map((L)=>Number(L[o]??0)),y=r.map((L)=>Number(L[i]??0)),m=Math.min(...h),b=Math.max(...h),x=Math.min(...y),w=Math.max(...y),A=b-m||1,k=w-x||1,v=s?r.map((L)=>Number(L[s]??0)):[],R=s?Math.max(...v,1):1,I=400,N=Qe(I,l,!0),F=Q(I,l,"Scatter"),X=(L)=>N.plotLeft+(L-m)/A*N.plotWidth,Y=(L)=>N.plotBottom-(L-x)/k*N.plotHeight,Z=4;for(let L=0;L<=Z;L++){let ce=x+k*L/Z,ne=Y(ce);if(F.appendChild(Pe({x:N.plotLeft-6,y:ne+3,"text-anchor":"end","font-size":se,fill:q},f(ce))),d&&L>0)F.appendChild(_("line",{x1:N.plotLeft,y1:ne,x2:N.plotRight,y2:ne,stroke:pe,"stroke-width":1,"stroke-dasharray":"4 3"}))}et(F,N);for(let L of[m,(m+b)/2,b])F.appendChild(Pe({x:X(L),y:N.plotBottom+14,"text-anchor":"middle","font-size":se,fill:q},String(Math.round(L*100)/100)));let G=e.showTooltip!==!1?te(n,F):void 0;for(let L=0;L<r.length;L++){let ce=X(h[L]),ne=Y(y[L]),at=s?4+Math.sqrt(v[L]/R)*14:4,zt=_("circle",{cx:ce,cy:ne,r:at,fill:u,"fill-opacity":s?0.6:0.85});if(G){let ur=[{label:o,value:f(h[L]),color:u},{label:i,value:f(y[L]),color:u},...s?[{label:s,value:f(v[L]),color:u}]:[]],fr=a[0]?.label??"Point";xe(zt,G,ce,ne,fr,ur)}F.appendChild(zt)}return ee(n,a,e.showLegend!==!1),n.appendChild(F),n}function qn(e,t){let n=g("div","pf-chart pf-histogram"),r=Vn(e,t);if(!r)return n.textContent="No data",n;let o=V(e.bins)??10,i=de(e,200),s=S(e.color)??D[0],a=Math.min(...r),d=(Math.max(...r)-a)/o||1,u=Array(o).fill(0);for(let m of r){let b=Math.min(Math.floor((m-a)/d),o-1);u[b]++}let c=Math.max(...u),f=300,h=f/o,y=Q(f,i,"Histogram");for(let m=0;m<o;m++){let b=c>0?u[m]/c*i:0,x=document.createElementNS("http://www.w3.org/2000/svg","rect");x.setAttribute("x",String(m*h)),x.setAttribute("y",String(i-b)),x.setAttribute("width",String(h-1)),x.setAttribute("height",String(b)),x.setAttribute("fill",s),y.appendChild(x)}return n.appendChild(y),n}function Un(){p("BarChart",zn),p("LineChart",Ht),p("AreaChart",Ht),p("PieChart",Wn),p("RadarChart",Jn),p("ScatterChart",Gn),p("RadialChart",Kn),p("Histogram",qn)}function Xn(){p("Table",Ji),p("TableHead",$t("thead")),p("TableBody",$t("tbody")),p("TableFooter",$t("tfoot")),p("TableRow",Gi),p("TableHeader",qi),p("TableCell",Ui),p("TableCaption",Xi),p("ExpandableRow",Yi)}function Ji(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",M(e,n,t),n}function $t(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,M(t,r,n),r}}function Gi(e,t){let n=document.createElement("tr");return n.className="pf-table-row",M(e,n,t),n}function qi(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.style.textAlign="left",n.style.padding="8px 12px",n.style.fontWeight="600",n.textContent=C(e.content,t),n}function Ui(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=e.colSpan;if(e.rowSpan!=null)n.rowSpan=e.rowSpan;return M(e,n,t),n}function Xi(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.style.padding="8px",n.style.fontSize="14px",n.textContent=C(e.content,t),n}function Yi(e,t){let n=g("div","pf-expandable-row"),r=g("div","pf-expandable-row-summary");r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.gap="8px";let o=g("span","pf-expandable-arrow");o.textContent="▶",o.style.transition="transform 0.2s",o.style.fontSize="10px",r.appendChild(o);let i=e.summary;if(i)for(let l of i)r.appendChild(O(l,t));let s=g("div","pf-expandable-row-detail");s.style.display="none",s.style.paddingLeft="24px",M(e,s,t);let a=!1;return r.addEventListener("click",()=>{a=!a,s.style.display=a?"block":"none",o.style.transform=a?"rotate(90deg)":""}),n.appendChild(r),n.appendChild(s),n}var Yn=!1;function rt(){if(Yn)return;Yn=!0;let e=new Set(Ct());hn(),Cn(),vn(),kn(),Sn(),Rn(),Tn(),An(),Nn(),Hn(),On(),Un(),Xn(),pn(Ct().filter((t)=>!e.has(t)))}function Dt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function It(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Ot(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Dt(n)}: ${It(r)};`).join(`
7
- `)}function Zn(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
8
- ${Ot(e.light)}
9
- }`);if(e.dark&&Object.keys(e.dark).length>0){let n=Ot(e.dark);t.push(`.dark, [data-theme="dark"] {
3
+ `),n=[],r=0;while(r<t.length){let o=t[r];if(o.trimStart().startsWith("```")){let a=o.trimStart().slice(3).trim(),l=[];r++;while(r<t.length&&!t[r].trimStart().startsWith("```"))l.push(He(t[r])),r++;r++;let c=a?` data-language="${He(a)}"`:"";n.push(`<pre class="pf-code"><code${c}>${l.join(`
4
+ `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(o)){n.push("<hr />"),r++;continue}let i=/^(#{1,6})\s+(.+)$/.exec(o);if(i){let a=i[1].length;n.push(`<h${a}>${Ze(i[2])}</h${a}>`),r++;continue}if(o.startsWith("> ")||o===">"){let a=[];while(r<t.length&&(t[r].startsWith("> ")||t[r]===">"))a.push(t[r].replace(/^>\s?/,"")),r++;n.push(`<blockquote>${En(a.join(`
5
+ `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(o)){n.push("<ul>");while(r<t.length&&/^[\s]*[-*+]\s+/.test(t[r]))n.push(`<li>${Ze(t[r].replace(/^[\s]*[-*+]\s+/,""))}</li>`),r++;n.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(o)){n.push("<ol>");while(r<t.length&&/^[\s]*\d+\.\s+/.test(t[r]))n.push(`<li>${Ze(t[r].replace(/^[\s]*\d+\.\s+/,""))}</li>`),r++;n.push("</ol>");continue}if(o.trim()===""){r++;continue}let s=[];while(r<t.length&&t[r].trim()!==""&&!/^#{1,6}\s/.test(t[r])&&!/^[-*+]\s/.test(t[r])&&!/^\d+\.\s/.test(t[r])&&!t[r].startsWith("> ")&&!t[r].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(t[r]))s.push(t[r]),r++;n.push(`<p>${s.map(Ze).join("<br />")}</p>`)}return n.join(`
6
+ `)}function Oo(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=w(e.content,t),n}function Tn(){p("Card",Do),p("CardHeader",Et("pf-card-header")),p("CardTitle",Rn("pf-card-title","h3")),p("CardDescription",Rn("pf-card-description","p")),p("CardContent",Et("pf-card-content")),p("CardFooter",Et("pf-card-footer"))}function Do(e,t){let n=g("div","pf-card");return n.style.overflow="hidden",N(e,n,t),n}function Et(e){return(t,n)=>{let r=g("div",e);return r.style.padding="16px 24px",N(t,r,n),r}}function Rn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=w(n.content,r),o}}function An(){p("DataTable",Io),p("Badge",jo),p("Dot",Fo),p("Metric",Bo),p("Ring",Vo),p("Progress",_o),p("Separator",zo),p("Loader",Wo),p("Icon",Ko),p("Sparkline",Jo)}function Io(e,t){let n=g("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable",r.style.width="100%",r.style.borderCollapse="collapse";let o=e.columns??[],i=W(e.rows,t),s=b(e.rowKey),a=b(e.selected),l=document.createElement("thead"),c=document.createElement("tr");for(let d of o){let m=document.createElement("th");m.className="pf-datatable-th",m.textContent=d.header??d.key,m.style.padding="8px 12px",m.style.textAlign="left",c.appendChild(m)}l.appendChild(c),r.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(i)){let d=a!=null?W(a,t):void 0;for(let m of i){let h=document.createElement("tr");h.className="pf-datatable-row";let C=m,f=S(C)?C:{},y=m===null||typeof m!=="object";if(s&&d!=null&&f[s]!=null&&k(f[s])===k(d))h.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)h.style.cursor="pointer",h.addEventListener("click",()=>{let x={...t.scope,$item:C,$index:i.indexOf(m)},v=V({...t,scope:x});O(P(e.onRowClick,v),"onRowClick")});for(let x of o){let v=document.createElement("td");v.className="pf-datatable-td";let R;if(x.accessor)R=W(`{{ $item.${x.accessor} }}`,{...t,scope:{...t.scope,$item:C}});else if(R=y?m:f[x.key],x.format&&R!=null)R=W(`{{ __fmtVal | ${x.format} }}`,{...t,scope:{...t.scope,__fmtVal:R}});v.textContent=k(R),v.style.padding="8px 12px",h.appendChild(v)}u.appendChild(h)}}if(r.appendChild(u),e.search===!0){let d=document.createElement("input");d.type="text",d.placeholder="Search...",d.className="pf-datatable-search",d.style.marginBottom="8px",d.style.padding="6px 12px",d.style.width="100%",d.style.boxSizing="border-box",d.addEventListener("input",()=>{let m=d.value.toLowerCase(),h=Array.from(u.querySelectorAll("tr"));for(let C of h){let f=(C.textContent??"").toLowerCase();C.style.display=f.includes(m)?"":"none"}}),n.appendChild(d)}return n.appendChild(r),n}function jo(e,t){let n=g("span","pf-badge"),r=b(e.variant)??"default";return n.setAttribute("data-variant",r),n.style.alignItems="center",n.style.padding="2px 10px",n.style.borderRadius="9999px",n.style.fontSize="12px",n.style.fontWeight="500",n.textContent=w(e.label??e.content,t),Go(n,r),n}function Fo(e,t){let n=g("span","pf-dot"),r=b(e.color)??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=r,n}function Bo(e,t){let n=g("div","pf-metric"),r=g("div","pf-metric-label");r.textContent=w(e.label,t),r.style.fontSize="14px",n.appendChild(r);let o=g("div","pf-metric-value");if(o.textContent=w(e.value,t),o.style.fontSize="28px",o.style.fontWeight="700",n.appendChild(o),e.delta!=null){let i=g("span","pf-metric-delta");i.textContent=w(e.delta,t);let s=b(e.trend)??"",a=b(e.trendSentiment)??"neutral";if(i.style.fontSize="14px",i.style.color=a==="positive"?"green":a==="negative"?"red":"inherit",s==="up")i.textContent="↑ "+i.textContent;else if(s==="down")i.textContent="↓ "+i.textContent;n.appendChild(i)}if(e.description!=null){let i=g("div","pf-metric-desc");i.textContent=w(e.description,t),i.style.fontSize="12px",n.appendChild(i)}return n}function Vo(e,t){let n=g("div","pf-ring"),r=D(e.size)??80,o=D(e.thickness)??8,i=Number(W(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(r-o)/2,l=2*Math.PI*a,c=l*(1-s/100),u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(r)),u.setAttribute("height",String(r)),u.setAttribute("viewBox",`0 0 ${r} ${r}`);let d=document.createElementNS("http://www.w3.org/2000/svg","circle");d.setAttribute("cx",String(r/2)),d.setAttribute("cy",String(r/2)),d.setAttribute("r",String(a)),d.setAttribute("fill","none"),d.setAttribute("stroke","var(--muted, #e5e7eb)"),d.setAttribute("stroke-width",String(o));let m=document.createElementNS("http://www.w3.org/2000/svg","circle");if(m.setAttribute("cx",String(r/2)),m.setAttribute("cy",String(r/2)),m.setAttribute("r",String(a)),m.setAttribute("fill","none"),m.setAttribute("stroke","var(--primary, #3b82f6)"),m.setAttribute("stroke-width",String(o)),m.setAttribute("stroke-dasharray",String(l)),m.setAttribute("stroke-dashoffset",String(c)),m.setAttribute("stroke-linecap","round"),m.style.transform="rotate(-90deg)",m.style.transformOrigin="center",u.appendChild(d),u.appendChild(m),n.appendChild(u),e.label!=null){let h=g("div","pf-ring-label");h.textContent=w(e.label,t),h.style.textAlign="center",h.style.fontSize="12px",n.appendChild(h)}return n}function _o(e,t){let n=g("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(W(e.value,t)??0),o=D(e.max)??100,i=o>0?Math.max(0,Math.min(100,r/o*100)):0;n.setAttribute("aria-valuenow",String(r)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(o)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let s=g("div","pf-progress-fill");return s.style.height="100%",s.style.width=`${i}%`,s.style.borderRadius="4px",s.style.transition="width 0.3s ease",n.appendChild(s),n}function zo(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Wo(e,t){let n=g("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function Ko(e,t){let n=g("span","pf-icon");return n.setAttribute("data-icon",w(e.name??e.content,t)),n}function Jo(e,t){let n=g("div","pf-sparkline"),r=Array.isArray(e.data)?e.data.filter((h)=>typeof h==="number"&&Number.isFinite(h)):[];if(r.length===0)return n;let o=D(e.width)??120,i=D(e.height)??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("width",String(o)),c.setAttribute("height",String(i)),c.setAttribute("viewBox",`0 0 ${o} ${i}`);let u=r.length>1?r.length-1:1,d=r.map((h,C)=>{let f=C/u*o,y=i-(h-a)/l*(i-4)-2;return`${f},${y}`}).join(" "),m=document.createElementNS("http://www.w3.org/2000/svg","polyline");return m.setAttribute("points",d),m.setAttribute("fill","none"),m.setAttribute("stroke","var(--primary, #3b82f6)"),m.setAttribute("stroke-width","1.5"),c.appendChild(m),n.appendChild(c),n}function Go(e,t){let r={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(r)e.style.backgroundColor=r.bg,e.style.color=r.fg}function Mn(){p("Form",qo),p("Input",Uo),p("Textarea",Ce(Xo)),p("Button",Yo),p("ButtonGroup",Zo),p("Checkbox",Qo),p("Switch",ei),p("Slider",Ce(ti)),p("Calendar",ri),p("DatePicker",Ce(oi)),p("Field",Pe("pf-field")),p("FieldTitle",xe("pf-field-title")),p("FieldDescription",xe("pf-field-description")),p("FieldContent",Pe("pf-field-content")),p("FieldError",xe("pf-field-error"))}function qo(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(r)=>{r.preventDefault();let o=new FormData(n),i={};for(let s of new Set(o.keys())){let a=o.getAll(s),l=n.elements.namedItem(s),c=l instanceof HTMLSelectElement&&l.multiple||a.length>1;i[s]=c?a:a[0]}if(t.store.merge(i),e.onSubmit!=null){let s=V(t);s.scope={...t.scope,...i},O(P(e.onSubmit,s),"onSubmit")}}),N(e,n,t),n}function Nn(e,t,n){if(t.label==null)return;let r=document.createElement("label");if(r.className="pf-input-label",r.textContent=w(t.label,n),t.name!=null)r.htmlFor=k(t.name);r.style.fontSize="14px",r.style.fontWeight="500",e.insertBefore(r,e.firstChild)}function Ce(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",Nn(r,t,n),r}}function se(e,t){if(t.required!==!0)return;if("required"in e)e.required=!0;e.setAttribute("aria-required","true")}function Uo(e,t){let n=g("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",Nn(n,e,t);let r=document.createElement("input");if(r.className="pf-input",r.type=b(e.inputType)??"text",e.name!=null)r.name=k(e.name);if(e.name!=null)r.id=`pf-input-${k(e.name)}`;if(e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(se(r,e),e.error!=null)r.setAttribute("aria-invalid","true");let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Qe(r),n.appendChild(r),n}function Xo(e,t){let n=g("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=k(e.name);if(e.name!=null)r.id=`pf-textarea-${k(e.name)}`;if(e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.rows!=null)r.rows=Number(e.rows);se(r,e);let o=b(e.name);if(o!=null){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Qe(r),n.appendChild(r),n}function Yo(e,t){let n=document.createElement("button");n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=w(e.label,t);let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),ni(n,r),e.size!=null)n.setAttribute("data-size",k(e.size));if(e.disabled===!0)n.disabled=!0;return n}function Zo(e,t){let n=g("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",N(e,n,t),n}function Qo(e,t){let n=g("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-checkbox",e.name!=null)r.name=k(e.name);if(e.checked===!0)r.checked=!0;let o=b(e.name);if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=w(e.label,t),n.appendChild(i)}return n}function ei(e,t){let n=g("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-switch",r.setAttribute("role","switch"),e.name!=null)r.name=k(e.name);let o=b(e.name);if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=w(e.label,t),n.appendChild(i)}return n}function ti(e,t){let n=g("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=k(e.name);if(e.min!=null)r.min=k(e.min);if(e.max!=null)r.max=k(e.max);if(e.step!=null)r.step=k(e.step);let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,Number(r.value)),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function Qe(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function ni(e,t){if(e.style.padding="8px 16px",e.style.fontSize="14px",e.style.fontWeight="500",e.style.cursor="pointer",e.style.border="none",t==="ghost")e.style.backgroundColor="transparent",e.style.color="inherit"}function Pe(e){return(t,n)=>{let r=g("div",e);return N(t,r,n),r}}function xe(e){return(t,n)=>{let r=g("span",e);return r.textContent=w(t.content,n),r}}function Rt(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function ri(e,t){let n=g("div","pf-calendar"),r=document.createElement("input");if(r.type="date",r.name=w(e.name,t),se(r,e),e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);if(e.minDate!=null)r.min=w(e.minDate,t);if(e.maxDate!=null)r.max=w(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)O(P(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function oi(e,t){let n=g("div","pf-datepicker"),r=document.createElement("input");if(r.type="date",r.name=w(e.name,t),se(r,e),e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);if(e.minDate!=null)r.min=w(e.minDate,t);if(e.maxDate!=null)r.max=w(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)O(P(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function Ln(){p("Select",Ce(ii)),p("SelectOption",li),p("SelectGroup",Pe("pf-select-group")),p("SelectLabel",xe("pf-select-label")),p("SelectSeparator",Rt),p("Radio",ci),p("RadioGroup",di),p("Combobox",Ce(pi)),p("ComboboxOption",ui),p("ComboboxGroup",Pe("pf-combobox-group")),p("ComboboxLabel",xe("pf-combobox-label")),p("ComboboxSeparator",Rt),p("ChoiceCard",fi)}function ii(e,t){let n=g("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=k(e.name);if(e.multiple===!0)r.multiple=!0;if(se(r,e),Qe(r),e.placeholder!=null){let s=document.createElement("option");s.value="",s.textContent=w(e.placeholder,t),s.disabled=!0,s.selected=!0,s.hidden=!0,r.appendChild(s)}let o=e.options;if(Array.isArray(o))for(let s of o){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}if(e.children)for(let s of e.children)if(s.type==="SelectOption"){let a=document.createElement("option");a.value=b(s.value)??"",a.textContent=b(s.label)??a.value,r.appendChild(a)}else r.appendChild(j(s,t));let i=b(e.name);if(i){let s=t.store.get(i);if(s!=null)ai(r,s);r.addEventListener("change",()=>{let a=si(r);if(t.store.set(i,a),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:a}}),"onChange")})}return n.appendChild(r),n}function si(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function ai(e,t){if(!e.multiple){e.value=k(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>k(r)));for(let r of e.options)r.selected=n.has(r.value)}function li(e,t){return g("span")}function ci(e,t){let n=g("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="radio",r.value=w(e.value,t),n.appendChild(r),e.label!=null){let o=g("span","pf-radio-label");o.textContent=w(e.label,t),n.appendChild(o)}return n}function di(e,t){let n=g("fieldset","pf-radio-group");if(se(n,e),n.style.border="none",n.style.padding="0",n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",e.label!=null){let i=document.createElement("legend");i.textContent=w(e.label,t),i.style.fontWeight="500",i.style.marginBottom="4px",n.appendChild(i)}N(e,n,t);let r=w(e.name,t),o=t.store.get(r);for(let i of Array.from(n.querySelectorAll('input[type="radio"]')))if(i.name=r,o!=null&&i.value===k(o))i.checked=!0;return n.addEventListener("change",(i)=>{let s=i.target;if(s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)O(P(e.onChange,V(t)),"onChange")}}),n}function pi(e,t){let n=g("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=w(e.name,t),se(r,e),e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box";let s=g("div","pf-combobox-dropdown");if(s.style.display="none",s.style.position="absolute",s.style.borderRadius="6px",s.style.maxHeight="200px",s.style.overflowY="auto",s.style.zIndex="50",N(e,s,t),r.addEventListener("focus",()=>{s.style.display="block"}),r.addEventListener("blur",()=>{setTimeout(()=>{s.style.display="none"},150)}),e.searchable!==!1)r.addEventListener("input",()=>{let a=r.value.toLowerCase();for(let l of Array.from(s.querySelectorAll(".pf-combobox-option"))){let c=(l.textContent??"").toLowerCase();l.style.display=c.includes(a)?"":"none"}});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function ui(e,t){let n=g("div","pf-combobox-option");return n.style.padding="6px 12px",n.style.cursor="pointer",n.textContent=w(e.label??e.value,t),n.dataset.value=w(e.value,t),n.addEventListener("mousedown",()=>{let r=n.closest(".pf-combobox"),o=r?.querySelector("input");if(o)o.value=n.dataset.value??"",t.store.set(o.name,o.value),r?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function fi(e,t){let n=g("div","pf-choice-card");if(n.style.padding="16px",n.style.cursor="pointer",n.style.transition="border-color 0.2s",n.dataset.value=w(e.value,t),e.selected===!0)n.dataset.selected="true";if(e.label!=null){let r=g("div","pf-choice-card-label");r.textContent=w(e.label,t),r.style.fontWeight="600",n.appendChild(r)}if(e.description!=null){let r=g("div","pf-choice-card-description");r.textContent=w(e.description,t),r.style.fontSize="14px",n.appendChild(r)}return N(e,n,t),n}function Hn(){p("Tabs",mi),p("Tab",gi),p("Accordion",hi),p("AccordionItem",bi),p("Dialog",yi),p("Popover",Ci),p("Tooltip",xi),p("HoverCard",wi),p("Carousel",vi)}function mi(e,t){let n=g("div","pf-tabs"),r=g("div","pf-tabs-bar");r.setAttribute("role","tablist"),r.style.display="flex",r.style.gap="4px",r.style.marginBottom="12px";let o=[],i=[],s=e.children??[],a=(()=>{let c=e.defaultTab;if(typeof c==="number")return c>=0&&c<s.length?c:0;if(typeof c==="string"){let u=s.findIndex((d)=>d.title===c);return u>=0?u:0}return 0})();if(e.children)for(let c=0;c<e.children.length;c++){let u=e.children[c],d=`pf-tab-${Math.random().toString(36).slice(2,8)}`,m=`pf-panel-${Math.random().toString(36).slice(2,8)}`,h=document.createElement("button");h.type="button",h.className="pf-tab-trigger",h.textContent=b(u.title)??`Tab ${String(c+1)}`,h.setAttribute("role","tab"),h.setAttribute("aria-selected",c===a?"true":"false"),h.setAttribute("aria-controls",m),h.id=d,h.tabIndex=c===a?0:-1,h.style.padding="8px 16px",h.style.border="none",h.style.background="none",h.style.cursor="pointer",h.style.borderBottom="2px solid transparent",h.style.marginBottom="-2px",h.style.fontSize="14px";let C=g("div","pf-tab-panel");if(C.style.display=c===a?"block":"none",C.setAttribute("role","tabpanel"),C.setAttribute("aria-labelledby",d),C.id=m,C.tabIndex=0,N(u,C,t),h.addEventListener("click",()=>{l(c)}),c===a)h.classList.add("pf-tab-active"),h.style.fontWeight="600";i.push(h),o.push(C),r.appendChild(h)}function l(c){o.forEach((u)=>u.style.display="none"),i.forEach((u)=>{u.style.borderBottomColor="transparent",u.style.fontWeight="normal",u.classList.remove("pf-tab-active"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}),o[c].style.display="block",i[c].classList.add("pf-tab-active"),i[c].style.fontWeight="600",i[c].setAttribute("aria-selected","true"),i[c].tabIndex=0,i[c].focus()}r.addEventListener("keydown",(c)=>{let u=i.indexOf(c.target);if(u<0)return;let d;if(c.key==="ArrowRight")d=(u+1)%i.length;else if(c.key==="ArrowLeft")d=(u-1+i.length)%i.length;else if(c.key==="Home")d=0;else if(c.key==="End")d=i.length-1;else return;c.preventDefault(),l(d)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function gi(e,t){let n=g("div","pf-tab");return N(e,n,t),n}function hi(e,t){let n=g("div","pf-accordion");return N(e,n,t),n}function bi(e,t){let n=g("div","pf-accordion-item"),r=`pf-acc-${Math.random().toString(36).slice(2,8)}`,o=document.createElement("button");o.type="button",o.className="pf-accordion-trigger",o.textContent=b(e.title)??"",o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",r),o.style.width="100%",o.style.textAlign="left",o.style.padding="12px 0",o.style.border="none",o.style.background="none",o.style.cursor="pointer",o.style.fontSize="14px",o.style.fontWeight="500";let i=g("div","pf-accordion-content");return i.id=r,i.setAttribute("role","region"),i.setAttribute("aria-labelledby",o.id),i.style.display="none",i.style.paddingBottom="12px",N(e,i,t),o.addEventListener("click",()=>{let s=i.style.display!=="none";i.style.display=s?"none":"block",o.setAttribute("aria-expanded",s?"false":"true")}),n.appendChild(o),n.appendChild(i),n}function yi(e,t){let n=g("div","pf-dialog-wrapper");if(e.trigger!=null){let i=j(e.trigger,t);i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i)}let r=document.createElement("dialog");if(r.className="pf-dialog",r.setAttribute("aria-modal","true"),r.style.maxWidth="500px",r.style.width="100%",r.style.padding="24px",e.title!=null){let i=g("h2","pf-dialog-title");i.textContent=w(e.title,t),i.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",i.id),r.appendChild(i)}if(e.description!=null){let i=g("p","pf-dialog-desc");i.textContent=w(e.description,t),r.appendChild(i)}let o=g("div","pf-dialog-body");if(N(e,o,t),r.appendChild(o),e.dismissible!==!1)r.addEventListener("click",(i)=>{if(i.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function Ci(e,t){let n=g("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-popover-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="12px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let i=g("div","pf-popover-title");i.textContent=w(e.title,t),i.style.fontWeight="600",i.style.marginBottom="4px",r.appendChild(i)}N(e,r,t);let o=()=>{r.style.display=r.style.display==="none"?"block":"none"};if(e.trigger!=null){let i=j(e.trigger,t);i.addEventListener("click",(s)=>{s.stopPropagation(),o()}),n.appendChild(i)}else n.addEventListener("click",(i)=>{if(r.contains(i.target)&&r.style.display!=="none")return;o()});return n.appendChild(r),n}function xi(e,t){let n=g("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let r=`pf-tip-${Math.random().toString(36).slice(2,8)}`,o=g("div","pf-tooltip-content");return o.id=r,o.setAttribute("role","tooltip"),o.textContent=w(e.content??"",t),o.style.display="none",o.style.position="absolute",o.style.bottom="100%",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.padding="4px 8px",o.style.borderRadius="4px",o.style.color="#fff",o.style.fontSize="12px",o.style.whiteSpace="nowrap",o.style.zIndex="50",N(e,n,t),n.setAttribute("aria-describedby",r),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.addEventListener("focus",()=>{o.style.display="block"},!0),n.addEventListener("blur",()=>{o.style.display="none"},!0),n.appendChild(o),n}function wi(e,t){let n=g("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-hover-card-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="16px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",r.style.minWidth="200px",e.trigger!=null)n.appendChild(j(e.trigger,t));return N(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function vi(e,t){let n=g("div","pf-carousel");n.style.position="relative",n.style.overflow="hidden",n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",w(e.label??"Carousel",t));let r=g("div","pf-carousel-track");r.style.display="flex",r.style.transition="transform 0.3s ease",N(e,r,t);let o=0,i=e.children?.length??0,s=document.createElement("button");s.type="button",s.textContent="‹",s.className="pf-carousel-prev",s.setAttribute("aria-label","Previous slide"),s.style.position="absolute",s.style.left="4px",s.style.top="50%",s.style.transform="translateY(-50%)",s.style.zIndex="10";let a=document.createElement("button");a.type="button",a.textContent="›",a.className="pf-carousel-next",a.setAttribute("aria-label","Next slide"),a.style.position="absolute",a.style.right="4px",a.style.top="50%",a.style.transform="translateY(-50%)",a.style.zIndex="10";let l=()=>{r.style.transform=`translateX(-${o*100}%)`};return s.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),l()}),a.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),l()}),n.appendChild(r),n.appendChild(s),n.appendChild(a),n}function ki(e){if(!S(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Array.isArray(n)?n.filter(Le):[]]))}function Pn(){p("ForEach",Si),p("If",$n),p("Elif",Ei),p("Else",Ri),p("Condition",Ti),p("Define",Ai),p("Use",Mi),p("Slot",Ni)}function Si(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(J(r)){let s=G(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=I(e.let)??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},c={...t,scope:l};if(e.children)ie(e.children,n,c)}return n}function $n(e,t){if(On(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)ie(e.children,r,t);return r}return document.createDocumentFragment()}function Ei(e,t){return $n(e,t)}function Ri(e,t){let n=document.createDocumentFragment();if(e.children)ie(e.children,n,t);return n}function On(e,t){if(!e)return!1;if(J(e))return Boolean(G(e,t.store,t.scope));return Boolean(t.store.get(e))}function Ti(e,t){let n=document.createDocumentFragment(),{cases:r,else:o}=e;if(r){for(let i of r)if(On(i.when,t)){if(i.children)ie(i.children,n,t);return n}}if(o)ie(o,n,t);return n}function Ai(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Mi(e,t){let n=document.createDocumentFragment(),r=b(e.def??e.name),o=r!=null?t.templates?.[r]:void 0;if(!o)return n;let i=I(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...ki(e.slots)};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let c of o)n.appendChild(j(c,l));return n}function Ni(e,t){let n=document.createDocumentFragment(),r=b(e.name)??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(j(s,t));return n}function Dn(){p("Alert",Li),p("AlertTitle",Hi),p("AlertDescription",Pi)}function Li(e,t){let n=g("div","pf-alert");n.setAttribute("role","alert");let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),n.style.padding="12px 16px",e.icon!=null){let o=g("span","pf-alert-icon");o.setAttribute("data-icon",k(e.icon)),o.style.marginRight="8px",n.appendChild(o)}return N(e,n,t),n}function Hi(e,t){let n=g("h5","pf-alert-title");return n.textContent=w(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function Pi(e,t){let n=g("p","pf-alert-description");return n.textContent=w(e.content,t),n.style.fontSize="14px",n}function In(){p("Image",$i),p("Audio",Oi),p("Video",Di),p("Embed",Ii),p("Svg",Fi),p("DropZone",Vi),p("Mermaid",_i)}function $i(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=w(e.src,t),e.alt!=null)n.alt=w(e.alt,t);if(e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Oi(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=w(e.src,t),n.controls=!0,n}function Di(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=w(e.src,t),n.controls=!0,e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Ii(e,t){let n=g("div","pf-embed"),r=document.createElement("iframe");return r.src=w(e.src,t),r.style.width="100%",r.style.height=e.height!=null?`${String(Number(e.height))}px`:"400px",r.style.border="none",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var ji=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","defs","use","symbol","clippath","mask","pattern","lineargradient","radialgradient","stop","filter","fegaussianblur","feoffset","femerge","femergenode","fecolormatrix","feblend","title","desc"]);function Fi(e,t){let n=g("div","pf-svg"),r=w(e.content,t);if(!r.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(r))r=r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let i=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!i)return n;return jn(i),n.appendChild(document.importNode(i,!0)),n}function jn(e){let t=Array.from(e.children);for(let n of t){if(!ji.has(n.tagName.toLowerCase())){n.remove();continue}for(let r of Array.from(n.attributes)){let o=r.name.toLowerCase();if(o.startsWith("on")||o==="href"&&r.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(r.name)}jn(n)}}function Bi(e,t){let n=(t??"").split(",").map((i)=>i.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let r=e.name.toLowerCase(),o=e.type.toLowerCase();return n.some((i)=>{if(i.startsWith("."))return r.endsWith(i);if(i.endsWith("/*"))return o.startsWith(i.slice(0,-1));return o===i})}function Vi(e,t){let n=g("div","pf-dropzone");n.style.padding="32px",n.style.textAlign="center",n.style.cursor="pointer",n.textContent=w(e.label??"Drop files here",t);let r=document.createElement("input");if(r.type="file",r.style.display="none",e.accept!=null)r.accept=k(e.accept);if(e.multiple===!0)r.multiple=!0;n.appendChild(r),n.setAttribute("role","button"),n.tabIndex=0;function o(s){let a=Array.from(s??[]).filter((l)=>Bi(l,b(e.accept)));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;let a=b(e.resultKey);if(a!=null)t.store.set(a,s),t.rerender();if(e.onDrop!=null)O(P(e.onDrop,{...V(t),scope:{...t.scope,$result:s}}),"onDrop")}return r.addEventListener("change",()=>{i(o(r.files)),r.value=""}),n.addEventListener("click",()=>r.click()),n.addEventListener("keydown",(s)=>{if(s.key==="Enter"||s.key===" ")s.preventDefault(),r.click()}),n.addEventListener("dragover",(s)=>{s.preventDefault(),n.classList.add("pf-dropzone-active")}),n.addEventListener("dragleave",()=>{n.classList.remove("pf-dropzone-active")}),n.addEventListener("drop",(s)=>{s.preventDefault(),n.classList.remove("pf-dropzone-active"),i(o(s.dataTransfer?.files??null))}),n}function _i(e,t){let n=g("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=w(e.content,t);if(n.textContent=r,"mermaid"in globalThis)n.classList.add("mermaid"),n.textContent=r;return n}var zi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Wi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",Tt=null,et=null;function Ki(e){return S(e)&&typeof e.getDocument==="function"&&S(e.GlobalWorkerOptions)}function At(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function Ji(e){return e==="fit-page"||e==="fit-width"?e:At(e,0)||"fit-width"}async function Gi(){if(Tt)return Tt;if(et)return et;return et=import(zi).then((e)=>{if(!Ki(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=Wi,Tt=t,t}),et}function Bn(){p("PdfViewer",qi)}function qi(e,t){let n=g("div","pf-pdf-viewer"),r=e.src!=null?w(e.src,t):void 0,o=b(e.data),i=At(e.page,1),s=Ji(e.zoom),a=e.toolbar!==!1,l=At(e.height,600);n.style.height=`${l}px`,n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",n.style.border="1px solid var(--color-border-primary, #e5e7eb)",n.style.borderRadius="var(--border-radius-md, 0.375rem)",n.style.background="var(--color-background-secondary, #f9fafb)";let c=g("div","pf-pdf-loading");return c.textContent="Loading PDF…",c.style.display="flex",c.style.alignItems="center",c.style.justifyContent="center",c.style.flex="1",c.style.color="var(--color-text-secondary, #6b7280)",n.appendChild(c),Ui(n,c,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function Ui(e,t,n){try{let r=await Gi(),o;if(n.src)o={url:n.src};else if(n.data){let m=atob(n.data),h=new Uint8Array(m.length);for(let C=0;C<m.length;C++)h[C]=m.charCodeAt(C);o={data:h}}else{t.textContent="Error: No PDF source provided";return}let i=await r.getDocument(o).promise;t.remove();let s=Math.max(1,Math.min(n.initialPage,i.numPages)),a=null,l=null;if(n.showToolbar){let m=Xi(i.numPages,s,{onPrev:()=>{if(s>1)s--,d()},onNext:()=>{if(s<i.numPages)s++,d()},onPageChange:(h)=>{let C=Math.max(1,Math.min(h,i.numPages));if(C!==s)s=C,d()}});a=m.pageInput,l=m.pageCount,e.insertBefore(m.el,e.firstChild)}let c=g("div","pf-pdf-canvas-container");c.style.flex="1",c.style.overflow="auto",c.style.display="flex",c.style.justifyContent="center",c.style.padding="8px",e.appendChild(c);let u=document.createElement("canvas");u.style.display="block",u.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",c.appendChild(u);async function d(){let m=await i.getPage(s),h=c.clientWidth-16,C,f=m.getViewport({scale:1});if(n.zoom==="fit-width")C=h/f.width;else if(n.zoom==="fit-page"){let v=c.clientHeight-16,R=h/f.width,T=v/f.height;C=Math.min(R,T)}else C=typeof n.zoom==="number"?n.zoom:1;let y=m.getViewport({scale:C});u.width=y.width,u.height=y.height,u.style.width=`${y.width}px`,u.style.height=`${y.height}px`;let x=u.getContext("2d");if(!x)return;if(await m.render({canvasContext:x,viewport:y}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await d()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function Xi(e,t,n){let r=g("div","pf-pdf-toolbar");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.padding="6px 12px",r.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",r.style.background="var(--color-background-primary, #fff)",r.style.flexShrink="0",r.style.fontSize="13px";let o=document.createElement("button");o.textContent="‹",o.title="Previous page",o.className="pf-pdf-btn",Fn(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",Fn(i),i.addEventListener("click",n.onNext);let s=document.createElement("input");s.type="number",s.min="1",s.max=String(e),s.value=String(t),s.style.width="48px",s.style.textAlign="center",s.style.border="1px solid var(--color-border-primary, #e5e7eb)",s.style.borderRadius="4px",s.style.padding="2px 4px",s.style.fontSize="13px",s.addEventListener("change",()=>{let l=parseInt(s.value,10);if(!isNaN(l))n.onPageChange(l)});let a=document.createElement("span");return a.textContent=`/ ${e}`,a.style.color="var(--color-text-secondary, #6b7280)",r.appendChild(o),r.appendChild(s),r.appendChild(a),r.appendChild(i),{el:r,pageInput:s,pageCount:a}}function Fn(e){e.style.border="1px solid var(--color-border-primary, #e5e7eb)",e.style.borderRadius="4px",e.style.background="var(--color-background-primary, #fff)",e.style.cursor="pointer",e.style.padding="2px 8px",e.style.fontSize="16px",e.style.lineHeight="1"}var F=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],X="var(--muted-foreground, #6b7280)",ue="var(--border, #e5e7eb)",ae="10";function tt(e,t,n,r=!1){let o=n?44:0,i=e-(r?44:0),s=10,a=t-24;return{plotLeft:o,plotRight:i,plotTop:10,plotBottom:a,plotWidth:i-o,plotHeight:a-10}}function Vn(e,t=5){if(e<=0)return[0];let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,i=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r,s=[];for(let a=0;a<=e+i*0.01;a+=i)s.push(Math.round(a*1000)/1000);return s}function _n(e,t,n,r,o){let i=Vn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=z("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":ae,fill:X});if(l.textContent=Nt(s,o),e.appendChild(l),r&&s>0)e.appendChild(z("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function zn(e,t,n,r){let o=Vn(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=z("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":ae,fill:X});a.textContent=Nt(i,r),e.appendChild(a)}}function Mt(e,t,n,r,o,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=z("text",{x:r(s),y:o+14,"text-anchor":"middle","font-size":ae,fill:X});l.textContent=a==null?"":i?i(a):k(a),e.appendChild(l)}}function nt(e,t){e.appendChild(z("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function le(e,t,n){if(e==null)return"";let r=W(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return k(r??e)}function Nt(e,t){if(t==="currency")return`$${e.toLocaleString()}`;if(t==="percent")return`${e}%`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1000)return`${(e/1000).toFixed(1)}K`;return String(e)}function ce(e){let t=b(e.yAxisFormat)??b(e.valueFormat);return t&&t!=="auto"?t:void 0}function Lt(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return le(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return Nt(Number(r),i)}}function te(e,t,n){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r.setAttribute("width","100%"),r.setAttribute("height",String(t)),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("role","img"),n)r.setAttribute("aria-label",`${n} chart`);return r.style.overflow="visible",r}function z(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function $e(e,t){let n=z("text",e);return n.textContent=t,n}function fe(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function Ht(e,t,n,r,o){let i=Math.max(2,Math.ceil(Math.abs(o-r)/4)),s=[];for(let a=0;a<=i;a++){let l=fe(e,t,n,r+(o-r)*a/i);s.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return s.join(" ")}function ne(e,t,n){if(!n||t.length<=1)return;let r=g("div","pf-chart-legend");r.style.display="flex",r.style.gap="12px",r.style.fontSize="12px",r.style.marginBottom="8px";for(let o=0;o<t.length;o++){let i=g("div","pf-chart-legend-item");i.style.display="flex",i.style.alignItems="center",i.style.gap="4px";let s=g("span");s.style.width="8px",s.style.height="8px",s.style.borderRadius="50%",s.style.backgroundColor=t[o].color??F[o%F.length];let a=g("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}function re(e,t){let n=document.createElement("div");return n.className="pf-chart-tooltip",e.appendChild(n),e.addEventListener("mouseleave",()=>{n.classList.remove("pf-visible")}),{wrapper:e,tooltip:n,svgEl:t}}function Pt(e,t,n,r,o){let{tooltip:i,svgEl:s,wrapper:a}=e;if(o.length===0)return;let l="";if(r)l+=`<div class="pf-chart-tooltip-label">${rt(r)}</div>`;for(let y of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${rt(y.color)}"></span>`,l+=`<span>${rt(y.label)}:</span> <strong>${rt(String(y.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),u=a.getBoundingClientRect(),d=s.viewBox.baseVal,m=c.width/(d.width||1),h=c.left-u.left+t*m,C=i.offsetWidth||100,f=h+12;if(f+C>u.width)f=h-C-12;i.style.left=`${Math.max(0,f)}px`,i.style.top="4px",i.classList.add("pf-visible")}function rt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function we(e,t,n,r,o,i){let s=()=>{Pt(t,n,r,o,i)},a=()=>{t.tooltip.classList.remove("pf-visible")};e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",a),e.addEventListener("touchstart",s,{passive:!0}),e.addEventListener("touchend",a,{passive:!0})}function Wn(e,t,n,r,o,i,s,a){let l=o.plotWidth/n.length;for(let c=0;c<n.length;c++){let u=o.plotLeft+c*l,d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("x",String(u)),d.setAttribute("y",String(o.plotTop)),d.setAttribute("width",String(l)),d.setAttribute("height",String(o.plotHeight)),d.setAttribute("fill","transparent"),d.style.cursor="default";let m=i?n[c][i]:void 0,h=m!=null?a?a(m):k(m):void 0,C=r.map((v,R)=>({label:v.label??v.dataKey,value:s(n[c][v.dataKey],v,R),color:v.color??F[R%F.length]})),f=u+l/2,y=()=>Pt(e,f,o.plotTop,h,C),x=()=>e.tooltip.classList.remove("pf-visible");d.addEventListener("mouseenter",y),d.addEventListener("mouseleave",x),d.addEventListener("touchstart",y,{passive:!0}),d.addEventListener("touchend",x,{passive:!0}),t.appendChild(d)}}function Kn(e,t,n,r,o,i,s,a,l,c){let u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let d=0;d<n.length;d++){let m=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+d/(n.length-1)*o.plotWidth,h=n.length===1?o.plotLeft:m-u/2,C=n.length===1?o.plotWidth:u,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Math.max(o.plotLeft,h))),f.setAttribute("y",String(o.plotTop)),f.setAttribute("width",String(Math.min(C,o.plotRight-Math.max(o.plotLeft,h)))),f.setAttribute("height",String(o.plotHeight)),f.setAttribute("fill","transparent"),f.style.cursor="default";let y=i?n[d][i]:void 0,x=y!=null?c?c(y):k(y):void 0,v=r.map((E,A)=>({label:E.label??E.dataKey,value:s(n[d][E.dataKey],E,A),color:E.color??F[A%F.length]})),R=()=>{if(Pt(e,m,o.plotTop,x,v),a)a.setAttribute("x1",String(m)),a.setAttribute("x2",String(m)),a.setAttribute("opacity","1");if(l)for(let E of l){for(let A of E)A.setAttribute("data-visible","false");E[d]?.setAttribute("data-visible","true")}},T=()=>{if(e.tooltip.classList.remove("pf-visible"),a)a.setAttribute("opacity","0");if(l)for(let E of l)for(let A of E)A.setAttribute("data-visible","false")};f.addEventListener("mouseenter",R),f.addEventListener("mouseleave",T),f.addEventListener("touchstart",R,{passive:!0}),f.addEventListener("touchend",T,{passive:!0}),t.appendChild(f)}}function me(e,t){return Ee(W(e.data,t))}function Jn(e,t){let n=W(e.data,t);if(!Array.isArray(n)||n.length===0)return;return n.filter((r)=>typeof r==="number"&&Number.isFinite(r))}function Yi(e){return e==="left"||e==="right"?e:void 0}function Zi(e){if(!S(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=Yi(e.yAxisId),o=b(e.tooltipFormat);return{dataKey:e.dataKey,...t!==void 0&&{label:t},...n!==void 0&&{color:n},...r!==void 0&&{yAxisId:r},...o!==void 0&&{tooltipFormat:o}}}function ge(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=Zi(t);return n?[n]:[]})}function de(e,t){return D(e.height)??t}function Oe(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function $t(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function Ot(e,t){return{rows:me(e,t),series:ge(e),height:de(e,300),showYAxis:e.showYAxis!==!1,showGrid:e.showGrid===!0,showYAxisRight:e.showYAxisRight===!0,showTooltip:e.showTooltip!==!1,showLegend:e.showLegend!==!1,xAxisKey:b(e.xAxis),tooltipXKey:b(e.tooltipXKey),xAxisFormat:b(e.xAxisFormat),tooltipXFormat:b(e.tooltipXFormat),yAxisRightFormat:b(e.yAxisRightFormat)}}function Gn(e,t,n){let r=t.series.filter((d)=>d.yAxisId!=="right"),o=t.series.filter((d)=>d.yAxisId==="right"),i=t.showYAxisRight&&o.length>0,s=r.length>0?Oe(t.rows,r):1,a=i?Oe(t.rows,o):1,l=400,c=tt(400,t.height,t.showYAxis,i),u=te(400,t.height,n);if(t.showYAxis)_n(u,c,s,t.showGrid,ce(e));if(i)zn(u,c,a,t.yAxisRightFormat);return nt(u,c),{layout:c,svg:u,leftMax:s,rightMax:a}}function ot(e,t){return e?(n)=>le(n,e,t):void 0}function qn(e,t){let n=g("div","pf-chart pf-bar-chart"),r=Ot(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let{layout:s,svg:a,leftMax:l,rightMax:c}=Gn(e,r,"Bar"),u=s.plotWidth/o.length,d=u/(i.length+1);for(let m=0;m<o.length;m++)for(let h=0;h<i.length;h++){let C=i[h],f=o[m][C.dataKey];if(f===null||f===void 0)continue;let y=C.yAxisId==="right"?c:l,x=Math.max(0,Number(f)/y*s.plotHeight),v=s.plotLeft+m*u+h*d+d/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(v)),R.setAttribute("y",String(s.plotBottom-x)),R.setAttribute("width",String(d*0.8)),R.setAttribute("height",String(x)),R.setAttribute("fill",C.color??F[h%F.length]),R.setAttribute("rx","2"),a.appendChild(R)}if(r.xAxisKey)Mt(a,o,r.xAxisKey,(m)=>s.plotLeft+m*u+u/2,s.plotBottom,ot(r.xAxisFormat,t));if(r.showTooltip){let m=re(n,a),h=Lt(t,ce(e),r.yAxisRightFormat);Wn(m,a,o,i,s,r.tooltipXKey??r.xAxisKey,h,ot(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(a),n}function Qi(e,t,n,r){let o=[],i=()=>{if(o.length<2){o=[];return}let s=`M ${o[0].x},${n} `+o.map((l)=>`L ${l.x},${l.y}`).join(" ")+` L ${o[o.length-1].x},${n} Z`,a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",s),a.setAttribute("fill",r),a.setAttribute("opacity","0.15"),e.appendChild(a),o=[]};for(let s of t){if(s.isNull){i();continue}o.push(s)}i()}function es(e,t,n,r){let o="";for(let s of t){if(s.isNull)continue;let a=t.indexOf(s),l=a===0||t[a-1].isNull;o+=`${l?"M":"L"} ${s.x},${s.y} `}if(!o)return;let i=document.createElementNS("http://www.w3.org/2000/svg","path");if(i.setAttribute("d",o.trim()),i.setAttribute("fill","none"),i.setAttribute("stroke",n),i.setAttribute("stroke-width","2"),r)i.setAttribute("stroke-dasharray","6 3");e.appendChild(i)}function ts(e,t,n){let r=[];for(let o of t){let i=document.createElementNS("http://www.w3.org/2000/svg","circle");if(i.setAttribute("cx",String(o.x)),i.setAttribute("cy",String(o.y)),i.setAttribute("r","4"),i.setAttribute("fill",n),i.setAttribute("class","pf-data-dot"),i.setAttribute("data-visible","false"),i.style.pointerEvents="none",o.isNull)i.style.display="none";e.appendChild(i),r.push(i)}return r}function ns(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg","line");return n.setAttribute("class","pf-crosshair"),n.setAttribute("x1",String(t.plotLeft)),n.setAttribute("x2",String(t.plotLeft)),n.setAttribute("y1",String(t.plotTop)),n.setAttribute("y2",String(t.plotBottom)),n.setAttribute("stroke",X),n.setAttribute("stroke-width","1"),n.setAttribute("stroke-dasharray","3 3"),n.setAttribute("opacity","0"),e.appendChild(n),n}function Dt(e,t){let n=g("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=Ot(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let s=e.type==="AreaChart",{layout:a,svg:l,leftMax:c,rightMax:u}=Gn(e,r,s?"Area":"Line"),d=(C)=>o.length===1?(a.plotLeft+a.plotRight)/2:a.plotLeft+C/(o.length-1)*a.plotWidth,m=[];for(let C=0;C<i.length;C++){let f=i[C],y=f.yAxisId==="right",x=y?u:c,v=f.color??F[C%F.length],R=o.map((T,E)=>{let A=T[f.dataKey],B=A===null||A===void 0,H=B?a.plotBottom:a.plotBottom-Number(A)/x*a.plotHeight;return{x:d(E),y:H,isNull:B}});if(s)Qi(l,R,a.plotBottom,v);es(l,R,v,y),m.push(ts(l,R,v))}let h=ns(l,a);if(r.xAxisKey)Mt(l,o,r.xAxisKey,d,a.plotBottom,ot(r.xAxisFormat,t));if(r.showTooltip){let C=re(n,l),f=Lt(t,ce(e),r.yAxisRightFormat);Kn(C,l,o,i,a,r.tooltipXKey??r.xAxisKey,f,h,m,ot(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(l),n}function It(e,t){let n=ce(e);return(r)=>n?le(r,n,t):String(r)}function Un(e,t){let n=g("div","pf-chart pf-pie-chart"),r=me(e,t),o=ge(e),i=Math.min(de(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=$t(e,o),c=o.length>0?o:a?[{dataKey:a,label:a}]:[];if(r.length===0||!a)return n.textContent="No chart data",n;let u=te(i,i,"Pie"),d=i/2,m=i/2,h=i/2-10,C=b(e.tooltipXFormat),f=It(e,t),y=r.map((T)=>Number(T[a]??0)),x=y.reduce((T,E)=>T+E,0);if(x===0)return n.textContent="No chart data",n.appendChild(u),n;let v=s?re(n,u):void 0,R=-Math.PI/2;for(let T=0;T<y.length;T++){let E=y[T]/x*2*Math.PI,A=R+E,B=E>Math.PI?1:0,H=d+h*Math.cos(R),_=m+h*Math.sin(R),Y=d+h*Math.cos(A),Z=m+h*Math.sin(A),Q=F[T%F.length],U=document.createElementNS("http://www.w3.org/2000/svg","path");if(U.setAttribute("d",`M ${d},${m} L ${H},${_} A ${h},${h} 0 ${B} 1 ${Y},${Z} Z`),U.setAttribute("fill",Q),U.style.cursor="default",v){let L=l?r[T][l]:void 0,pe=L!=null?C?le(L,C,t):k(L):`Slice ${T+1}`,oe=`${(y[T]/x*100).toFixed(1)}%`,pt=d+h*0.6*Math.cos(R+E/2);we(U,v,pt,m,pe,[{label:c[0].label??a,value:`${f(y[T])} (${oe})`,color:Q}])}u.appendChild(U),R=A}return ne(n,c,e.showLegend!==!1),n.appendChild(u),n}function Xn(e,t){let n=g("div","pf-chart pf-radial-chart"),r=me(e,t),o=ge(e),{valueKey:i,nameKey:s}=$t(e,o);if(r.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(de(e,300),300),l=a/2,c=a/2,u=a/2-10,d=Math.max(0,Math.min(D(e.innerRadius)??30,u-10)),m=D(e.startAngle)??180,h=D(e.endAngle)??0,C=r.map((A)=>Number(A[i]??0)),f=Math.max(...C,1),y=te(a,a,"Radial"),x=(u-d)/r.length,v=Math.max(2,x*0.7),R=It(e,t),T=e.showTooltip!==!1?re(n,y):void 0,E=[];for(let A=0;A<r.length;A++){let B=u-x*A-x/2,H=o[A]?.color??F[A%F.length],_=m+C[A]/f*(h-m),Y=s?r[A][s]:null,Z=Y!=null?k(Y):o[A]?.label??i;E.push({dataKey:Z||i,label:Z||i,color:H}),y.appendChild(z("path",{d:Ht(l,c,B,m,h),fill:"none",stroke:ue,"stroke-width":v,"stroke-linecap":"round"}));let Q=z("path",{d:Ht(l,c,B,m,_),fill:"none",stroke:H,"stroke-width":v,"stroke-linecap":"round"});if(T){let U=fe(l,c,B,(m+_)/2);we(Q,T,U.x,U.y,Z||i,[{label:i,value:R(C[A]),color:H}])}y.appendChild(Q)}return ne(n,E,e.showLegend!==!1),n.appendChild(y),n}function Yn(e,t){let n=g("div","pf-chart pf-radar-chart"),r=me(e,t),o=ge(e),i=b(e.axisKey)??b(e.xAxis);if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.filled!==!1,a=e.showDots===!0,l=e.showGrid!==!1,c=Math.min(de(e,300),320),u=c/2,d=c/2,m=c/2-24,h=r.length,C=Oe(r,o),f=(T)=>90-360*T/h,y=(T)=>T.map((E)=>`${E.x.toFixed(1)},${E.y.toFixed(1)}`).join(" "),x=te(c,c,"Radar");if(l){for(let E=1;E<=4;E++){let A=m*E/4,B=Array.from({length:h},(H,_)=>fe(u,d,A,f(_)));x.appendChild(z("polygon",{points:y(B),fill:"none",stroke:ue,"stroke-width":1}))}for(let E=0;E<h;E++){let A=fe(u,d,m,f(E));x.appendChild(z("line",{x1:u,y1:d,x2:A.x,y2:A.y,stroke:ue,"stroke-width":1}))}}for(let T=0;T<h;T++){let E=fe(u,d,m+12,f(T)),A=i?r[T][i]:null;x.appendChild($e({x:E.x,y:E.y+3,"text-anchor":"middle","font-size":ae,fill:X},k(A)))}let v=e.showTooltip!==!1?re(n,x):void 0,R=It(e,t);for(let T=0;T<o.length;T++){let E=o[T],A=E.color??F[T%F.length],B=r.map((H,_)=>fe(u,d,Number(H[E.dataKey]??0)/C*m,f(_)));if(x.appendChild(z("polygon",{points:y(B),fill:s?A:"none","fill-opacity":s?0.2:0,stroke:A,"stroke-width":2})),!a&&!v)continue;for(let H=0;H<B.length;H++){let _=z("circle",{cx:B[H].x,cy:B[H].y,r:a?3:6,fill:a?A:"transparent","fill-opacity":a?1:0});if(v){let Y=i?r[H][i]:null,Z=Y!=null?k(Y):E.label??E.dataKey,Q=[{label:E.label??E.dataKey,value:R(Number(r[H][E.dataKey]??0)),color:A}];we(_,v,B[H].x,B[H].y,Z,Q)}x.appendChild(_)}}return ne(n,o,e.showLegend!==!1),n.appendChild(x),n}function Zn(e,t){let n=g("div","pf-chart pf-scatter-chart"),r=me(e,t),o=b(e.xAxis),i=b(e.yAxis),s=b(e.zAxis),a=ge(e),l=de(e,300);if(r.length===0||!o||!i)return n.textContent="No chart data",n;let c=e.showGrid!==!1,u=a[0]?.color??F[0],d=ce(e),m=(L)=>d?le(L,d,t):String(Math.round(L*100)/100),h=r.map((L)=>Number(L[o]??0)),C=r.map((L)=>Number(L[i]??0)),f=Math.min(...h),y=Math.max(...h),x=Math.min(...C),v=Math.max(...C),R=y-f||1,T=v-x||1,E=s?r.map((L)=>Number(L[s]??0)):[],A=s?Math.max(...E,1):1,B=400,H=tt(B,l,!0),_=te(B,l,"Scatter"),Y=(L)=>H.plotLeft+(L-f)/R*H.plotWidth,Z=(L)=>H.plotBottom-(L-x)/T*H.plotHeight,Q=4;for(let L=0;L<=Q;L++){let pe=x+T*L/Q,oe=Z(pe);if(_.appendChild($e({x:H.plotLeft-6,y:oe+3,"text-anchor":"end","font-size":ae,fill:X},m(pe))),c&&L>0)_.appendChild(z("line",{x1:H.plotLeft,y1:oe,x2:H.plotRight,y2:oe,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}nt(_,H);for(let L of[f,(f+y)/2,y])_.appendChild($e({x:Y(L),y:H.plotBottom+14,"text-anchor":"middle","font-size":ae,fill:X},String(Math.round(L*100)/100)));let U=e.showTooltip!==!1?re(n,_):void 0;for(let L=0;L<r.length;L++){let pe=Y(h[L]),oe=Z(C[L]),pt=s?4+Math.sqrt(E[L]/A)*14:4,qt=z("circle",{cx:pe,cy:oe,r:pt,fill:u,"fill-opacity":s?0.6:0.85});if(U){let xr=[{label:o,value:m(h[L]),color:u},{label:i,value:m(C[L]),color:u},...s?[{label:s,value:m(E[L]),color:u}]:[]],wr=a[0]?.label??"Point";we(qt,U,pe,oe,wr,xr)}_.appendChild(qt)}return ne(n,a,e.showLegend!==!1),n.appendChild(_),n}function Qn(e,t){let n=g("div","pf-chart pf-histogram"),r=Jn(e,t);if(!r)return n.textContent="No data",n;let o=D(e.bins)??10,i=de(e,200),s=b(e.color)??F[0],a=Math.min(...r),c=(Math.max(...r)-a)/o||1,u=Array(o).fill(0);for(let f of r){let y=Math.min(Math.floor((f-a)/c),o-1);u[y]++}let d=Math.max(...u),m=300,h=m/o,C=te(m,i,"Histogram");for(let f=0;f<o;f++){let y=d>0?u[f]/d*i:0,x=document.createElementNS("http://www.w3.org/2000/svg","rect");x.setAttribute("x",String(f*h)),x.setAttribute("y",String(i-y)),x.setAttribute("width",String(h-1)),x.setAttribute("height",String(y)),x.setAttribute("fill",s),C.appendChild(x)}return n.appendChild(C),n}function er(){p("BarChart",qn),p("LineChart",Dt),p("AreaChart",Dt),p("PieChart",Un),p("RadarChart",Yn),p("ScatterChart",Zn),p("RadialChart",Xn),p("Histogram",Qn)}function tr(){p("Table",rs),p("TableHead",jt("thead")),p("TableBody",jt("tbody")),p("TableFooter",jt("tfoot")),p("TableRow",os),p("TableHeader",is),p("TableCell",ss),p("TableCaption",as),p("ExpandableRow",ls)}function rs(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",N(e,n,t),n}function jt(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,N(t,r,n),r}}function os(e,t){let n=document.createElement("tr");return n.className="pf-table-row",N(e,n,t),n}function is(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.style.textAlign="left",n.style.padding="8px 12px",n.style.fontWeight="600",n.textContent=w(e.content,t),n}function ss(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=Number(e.colSpan);if(e.rowSpan!=null)n.rowSpan=Number(e.rowSpan);return N(e,n,t),n}function as(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.style.padding="8px",n.style.fontSize="14px",n.textContent=w(e.content,t),n}function ls(e,t){let n=g("div","pf-expandable-row"),r=g("div","pf-expandable-row-summary");r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.gap="8px";let o=g("span","pf-expandable-arrow");o.textContent="▶",o.style.transition="transform 0.2s",o.style.fontSize="10px",r.appendChild(o);let i=e.summary;if(i)for(let l of i)r.appendChild(j(l,t));let s=g("div","pf-expandable-row-detail");s.style.display="none",s.style.paddingLeft="24px",N(e,s,t);let a=!1;return r.addEventListener("click",()=>{a=!a,s.style.display=a?"block":"none",o.style.transform=a?"rotate(90deg)":""}),n.appendChild(r),n.appendChild(s),n}var nr=!1;function it(){if(nr)return;nr=!0;let e=new Set(kt());wn(),Sn(),Tn(),An(),Mn(),Ln(),Hn(),Pn(),Dn(),In(),Bn(),er(),tr(),hn(kt().filter((t)=>!e.has(t)))}function Bt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Vt(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Ft(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Bt(n)}: ${Vt(r)};`).join(`
7
+ `)}function rr(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
8
+ ${Ft(e.light)}
9
+ }`);if(e.dark&&Object.keys(e.dark).length>0){let n=Ft(e.dark);t.push(`.dark, [data-theme="dark"] {
10
10
  ${n}
11
11
  }`),t.push(`@media (prefers-color-scheme: dark) {
12
12
  :root:not([data-theme="light"]):not(.light) {
13
- ${Ot(e.dark," ")}
13
+ ${Ft(e.dark," ")}
14
14
  }
15
15
  }`)}return t.join(`
16
- `)}function we(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function jt(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Dt(n)}`,It(r));if(t.dark){let r=document.getElementById("prefab-dark-theme");if(!r)r=document.createElement("style"),r.id="prefab-dark-theme",document.head.appendChild(r);r.textContent=Zn({dark:t.dark})}}function Ft(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(Zi(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function Zi(e,t){let n=e.toLowerCase().split("+").map((i)=>i.trim()),r=n[n.length-1],o=new Set(n.slice(0,-1));if(o.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(o.has("shift")!==t.shiftKey)return!1;if(o.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===r}var Qn='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',er='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',tr={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function Qi(e,t){try{let r=localStorage.getItem(t);if(r==="light"||r==="dark")return r}catch{}let n=e.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(n==="light"||n==="dark")return n;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function Oe(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",r=t?.storageKey??"prefab-theme",o=t?.syncDocument??!0,i=getComputedStyle(e).position;if(i==="static"||i==="")e.style.position="relative";let s=document.createElement("button");s.className="pf-theme-toggle",s.setAttribute("aria-label","Toggle theme"),s.setAttribute("title","Toggle light/dark"),Object.assign(s.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let a=tr[n]??tr["top-right"];for(let c of a.split(";")){let[f,h]=c.split(":").map((y)=>y.trim());if(f&&h)s.style.setProperty(f,h)}s.addEventListener("mouseenter",()=>{s.style.opacity="1"}),s.addEventListener("mouseleave",()=>{s.style.opacity="0.7"});function l(c){if(we(e,c),o)we(document.documentElement,c);s.innerHTML=c==="dark"?er:Qn;try{localStorage.setItem(r,c)}catch{}}let d=Qi(e,r);l(d),s.addEventListener("click",()=>{let c=e.getAttribute("data-theme")??"dark";l(c==="dark"?"light":"dark")}),e.appendChild(s);let u;if(o)u=new MutationObserver((c)=>{for(let f of c)if(f.type==="attributes"&&f.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){we(e,h),s.innerHTML=h==="dark"?er:Qn;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function ot(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},r=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(o,i){let s=await r(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:o,arguments:i}})});if(!s.ok)throw Error(`MCP tool call failed: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw Error(a.error.message??"MCP tool call returned error");let l=a.result?.content??a.content??[];for(let d of l)if(d.type==="text"&&d.text!==void 0){try{let u=JSON.parse(d.text);if(typeof u==="object"&&u!==null&&"$prefab"in u)return u;return u}catch{}return d.text}return a.result??a},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function it(){return{callTool(e){return T.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return T.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var nr="0.3.18";function es(e){return e!==null&&typeof e==="object"&&e.jsonrpc==="2.0"}class ge{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=rs();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(es(r)){this.handleJsonRpc(r);return}let o=r;if(!o?.type.startsWith("prefab:"))return;if(o.type==="prefab:tool-call-response"&&o.id){let s=this.pending.get(o.id);if(s){if(this.pending.delete(o.id),o.payload?.error!=null)s.reject(Error(o.payload.error));else s.resolve(o.payload?.result);return}}let i=this.listeners.get(o.type);if(i)for(let s of i)s(o.payload??{})};window.addEventListener("message",t),this.cleanup=()=>window.removeEventListener("message",t)}async initialize(e){try{return await Promise.any([this.initPrefab(e),this.initJsonRpc(e)])}catch(t){let n=t instanceof AggregateError?t.errors.map((r)=>r.message).join("; "):String(t);throw Error(`Bridge init failed — no host responded. Tried: ${n}`,{cause:t})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:e});else this.sendPrefab("prefab:request-mode",{mode:e})}openLink(e,t){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:e,target:t});else this.sendPrefab("prefab:open-link",{url:e,target:t})}updateContext(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:e});else this.sendPrefab("prefab:update-context",{context:e})}setupAutoResize(e){if(typeof ResizeObserver>"u")return ts;let t=-1,n=-1,r=(s,a)=>{if(s===t&&a===n)return;if(t=s,n=a,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:s,height:a});else this.sendPrefab("prefab:size-changed",{width:s,height:a})},o=new ResizeObserver((s)=>{for(let a of s)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];r(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();r(Math.ceil(l.width),Math.ceil(l.height))}});o.observe(e);let i=e.getBoundingClientRect();return r(Math.ceil(i.width),Math.ceil(i.height)),()=>o.disconnect()}notifyPreferredSize(e){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",e);else this.sendPrefab("prefab:preferred-size",e)}subscribe(e,t){let n=(r)=>{if(r.uri!==e)return;t(r.contents??r.data??r)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",n),this.sendRpcRequest("resources/subscribe",{uri:e});else this.on("prefab:resource-updated",n),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",n),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e});else this.sendPrefab("prefab:unsubscribe",{uri:e})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);let n=this.listeners.get(e);if(n)n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,e]of this.pending)e.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,e]of this.rpcPending)e.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab(e){return new Promise((t,n)=>{let r=!1,o=(i)=>{if(r)return;r=!0,this.off("prefab:init-response",o),this.protocol="prefab";let s=i.capabilities;this._hostSupportsSubscriptions=s?.subscriptions===!0,t(i)};this.on("prefab:init-response",o),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!r)r=!0,this.off("prefab:init-response",o),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((r,o)=>{this.pending.set(n,{resolve:r,reject:o}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),o(Error(`Tool call '${e}' timed out`))},30000)})},sendMessage:(e)=>(this.sendPrefab("prefab:send-message",{message:e}),Promise.resolve()),updateModelContext:(e)=>(this.sendPrefab("prefab:update-context",{context:e.structuredContent,content:e.content}),Promise.resolve()),subscribe:(e,t)=>this.subscribe(e,t),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab(e,t,n){if(typeof window>"u")return;let r=window.parent!==window?window.parent:window,o={type:e,payload:t,id:n};r.postMessage(o,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let r=this.rpcPending.get(e.id);if(r)if(this.rpcPending.delete(e.id),e.error)r.reject(Error(e.error.message));else r.resolve(e.result);return}let t=e.method,n=e.params??{};if(e.id!=null&&this.sentRpcIds.delete(e.id))return;if(e.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:e.id,result:{}});switch(t){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:n.arguments??n});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:n.arguments??n});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:n});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",n);break;case"ui/notifications/host-context-changed":{let r={};if(typeof n.theme==="string")r.colorScheme=n.theme;if(typeof n.styles==="object"&&n.styles!==null){let o=n.styles;if(o.variables)r.variables=o.variables;if(typeof o.css?.fonts==="string")r.fontCss=o.css.fonts}this.dispatch("prefab:theme-update",r),this.dispatch("prefab:host-context-changed",n);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",n);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",n);break}}initJsonRpc(e){return new Promise((t,n)=>{let r=++this.rpcIdCounter,o=!1;this.rpcPending.set(r,{resolve:(i)=>{if(o)return;o=!0,this.protocol="jsonrpc";let s=i??{},a=s.hostInfo??{},l=s.hostContext??{},d=s.hostCapabilities??{},u;if(typeof l.theme==="string"||typeof l.styles==="object"){if(u={},typeof l.theme==="string")u.colorScheme=l.theme;if(typeof l.styles==="object"&&l.styles!==null){let f=l.styles;if(f.variables)u.variables=f.variables;if(typeof f.css?.fonts==="string")u.fontCss=f.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let c=d.resources;this._hostSupportsSubscriptions=d.subscriptions===!0||c?.subscribe===!0,t({hostName:a.name,hostVersion:a.version,capabilities:{toast:!0,navigation:d.openLinks!=null,messaging:!0,displayModes:l.availableDisplayModes??[]},theme:u,toolInput:void 0,meta:l})},reject:(i)=>{if(o)return;o=!0,n(i)}}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:nr},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!o)o=!0,this.rpcPending.delete(r),n(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:(e,t)=>this.sendRpcRequest("tools/call",{name:e,arguments:t}),sendMessage:async(e)=>{await this.sendRpcRequest("ui/message",{role:"user",content:[{type:"text",text:e}]})},updateModelContext:async(e)=>{await this.sendRpcRequest("ui/update-model-context",{...e})},subscribe:(e,t)=>this.subscribe(e,t),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest(e,t){let n=++this.rpcIdCounter;return new Promise((r,o)=>{this.rpcPending.set(n,{resolve:r,reject:o}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),o(Error(`JSON-RPC '${e}' timed out`))},30000)})}sendRpcNotification(e,t){this.postJsonRpc({jsonrpc:"2.0",method:e,params:t})}postJsonRpc(e){if(typeof window>"u")return;if(e.id!=null&&typeof e.method==="string")this.sentRpcIds.add(e.id);if(this.postFn)this.postFn(e);else(window.parent!==window?window.parent:window).postMessage(e,this.hostOrigin)}dispatch(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r(t)}}var ts=()=>{};function De(e,t){if(t.variables)for(let[n,r]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,r);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)ns(t.fontCss)}function ns(e){if(document.getElementById("__prefab-host-fonts"))return;let n=document.createElement("style");n.id="__prefab-host-fonts",n.textContent=e,document.head.appendChild(n)}function ve(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function rs(){if(typeof window>"u")return;let e=window;if(typeof e.acquireVsCodeApi==="function")try{let t=e.acquireVsCodeApi();if(t!==null&&typeof t==="object"&&"postMessage"in t)return t}catch{return}return}async function st(e){rt();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&ve(),r,o,i={capabilities:{}};if(n)o=new ge(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=ot(e.transport);else r=it();if(i.theme&&typeof document<"u")De(document.documentElement,i.theme);if(typeof document<"u"&&!o)is();let s,a,l,d,u,c=i.toolInput,f;if(o)o.on("prefab:tool-input",(m)=>{let b=m.args??m;if(s)s(b);else c=b}),o.on("prefab:tool-result",(m)=>{let b=m.result??m;if(a)a(b);else f=b}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(m)=>{d?.(m.args??m)}),o.on("prefab:theme-update",(m)=>{if(typeof document<"u")De(document.documentElement,m)}),o.on("prefab:host-context-changed",(m)=>{u?.(m)});function h(m,...b){let x=Bt(m),w=new Se,A={store:w,scope:{},transport:r,rerender:()=>k(),onToast:void 0};function k(){x.innerHTML="";for(let v of b)x.appendChild(O(v,A))}return k(),{rerender:k,store:w,destroy:()=>{x.innerHTML=""}}}return{callTool:(m,b={})=>r.callTool(m,b),sendMessage:(m)=>r.sendMessage(m),onToolInput:(m)=>{if(s=m,c){let b=c;c=void 0,queueMicrotask(()=>m(b))}},onToolResult:(m)=>{if(a=m,f!==void 0){let b=f;f=void 0,queueMicrotask(()=>m(b))}},onToolCancelled:(m)=>{l=m},onToolInputPartial:(m)=>{d=m},onHostContextChanged:(m)=>{u=m},render:h,mount:(m,b,x)=>{let w=Bt(m);return U.mount(w,b,{transport:r,...x})},requestMode:(m)=>o?.requestMode(m),openLink:(m,b)=>{if(o)o.openLink(m,b);else if(typeof window<"u")window.open(m,b??"_blank")},updateContext:(m)=>{if(o)o.updateContext(m)},setupAutoResize:(m)=>{if(!o)return os;let b=typeof m==="string"?Bt(m):m;return o.setupAutoResize(b)},notifyPreferredSize:(m)=>{if(o)o.notifyPreferredSize(m)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var os=()=>{};function Bt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}return e}function is(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let r=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",r)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var rr=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var sr=new Set(rr);function ke(e,t={}){let n=[],r=t.strict??!1;if(e==null||typeof e!=="object")return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e;if(o.$prefab==null||typeof o.$prefab!=="object")n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof o.$prefab.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(o.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Vt(o.view,"$.view",n,r);if(o.state!==void 0){if(o.state===null||typeof o.state!=="object"||Array.isArray(o.state))n.push({path:"$.state",message:"state must be a plain object"})}if(o.theme!==void 0)as(o.theme,n);if(o.css!==void 0)ir(o.css,"$.css",n);if(o.stylesheets!==void 0)ir(o.stylesheets,"$.stylesheets",n);if(o.mode!==void 0&&o.mode!=="light"&&o.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(o.defs!==void 0)if(o.defs===null||typeof o.defs!=="object"||Array.isArray(o.defs))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[i,s]of Object.entries(o.defs))Vt(s,`$.defs.${i}`,n,r);if(o.keyBindings!==void 0)if(o.keyBindings===null||typeof o.keyBindings!=="object"||Array.isArray(o.keyBindings))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[i,s]of Object.entries(o.keyBindings))_t(s,`$.keyBindings.${i}`,n);return{valid:n.length===0,errors:n}}function ar(e){return ke(e).valid}function Vt(e,t,n,r){if(e==null||typeof e!=="object"||Array.isArray(e)){n.push({path:t,message:"Component must be a plain object"});return}let o=e;if(typeof o.type!=="string"||o.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(r&&!sr.has(o.type))n.push({path:`${t}.type`,message:`Unknown component type: "${o.type}"`});if(o.children!==void 0)if(!Array.isArray(o.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let s=0;s<o.children.length;s++)Vt(o.children[s],`${t}.children[${s}]`,n,r);let i=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let s of i)if(o[s]!==void 0)_t(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||ss.has(s)||i.includes(s))continue;if(or(a)||Array.isArray(a)&&a.some(or))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var ss=new Set(["children","fallback","trigger","empty","else","summary"]);function or(e){if(e==null||typeof e!=="object"||Array.isArray(e))return!1;let t=e.type;return typeof t==="string"&&sr.has(t)}function _t(e,t,n){if(Array.isArray(e)){for(let a=0;a<e.length;a++)_t(e[a],`${t}[${a}]`,n);return}if(e==null||typeof e!=="object"){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.type==="string"&&r.type.length>0,i=typeof r.action==="string"&&r.action.length>0;if(!o&&!i){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((i?r.action:r.type).toLowerCase()==="showtoast"){if(typeof r.message!=="string"||r.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function ir(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let r=0;r<e.length;r++)if(typeof e[r]!=="string")n.push({path:`${t}[${r}]`,message:"must be a string"})}function as(e,t){if(e===null||typeof e!=="object"||Array.isArray(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}let n=e;for(let r of["light","dark"])if(n[r]!==void 0){if(n[r]===null||typeof n[r]!=="object"||Array.isArray(n[r]))t.push({path:`$.theme.${r}`,message:`theme.${r} must be a plain object`})}}var U={mount(e,t,n){if(rt(),n?.validate!==!1)for(let x of ke(t).errors)T.warn(`wire validation ${x.path}: ${x.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[x,w]of Object.entries(r.pipes))lr(x,w,o);let i=new Se(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=ot(n.transport);else s=it();let a=n?.onToast??ds,l=new Le;function d(x){let w=x;if(r=w,w.state)i.merge(w.state);if(w.defs)c.defs=w.defs;if(w.theme)jt(e,w.theme);if(w.mode)dr(e,w.mode);if(w.pipes)for(let[A,k]of Object.entries(w.pipes))lr(A,k,o);for(let A of f)A.remove();if(f.length=0,f.push(...cr(w.css,w.stylesheets)),pr(e,w.layout),h?.(),h=void 0,w.keyBindings)h=Ft(w.keyBindings,(A)=>{P(H(A,{store:i,transport:s,scope:{},rerender:()=>b(),remount:d,onToast:a}),"keyBinding")});b(),u(w)}function u(x){if(x.onMount!=null)P(H(x.onMount,c),"onMount")}let c={store:i,scope:{},transport:s,rerender:()=>b(),remount:d,onToast:a,defs:r.defs,destroyRegistry:l};if(jt(e,r.theme),r.mode)dr(e,r.mode);pr(e,r.layout);let f=cr(r.css,r.stylesheets),h;if(r.keyBindings)h=Ft(r.keyBindings,(x)=>{P(H(x,{store:i,transport:s,scope:{},rerender:()=>b(),remount:d,onToast:a}),"keyBinding")});let y,m=n?.themeToggle??!0;if(m!==!1)y=Oe(e,typeof m==="object"?m:void 0);function b(){l.flush();let x=e.querySelector(".pf-theme-toggle");e.innerHTML="";let w=O(r.view,c);if(e.appendChild(w),x)e.appendChild(x)}return b(),u(r),{rerender:()=>b(),update(x){if(i.merge(x.update.state),b(),x.update.actions!=null)P(H(x.update.actions,c),"update action")},store:i,destroy(){l.flush(),y?.(),h?.(),Qt(),nn();for(let x of f)x.remove();for(let x of o.tracked)Re(x);e.innerHTML=""}}},isPrefabData(e){return e!=null&&typeof e==="object"&&"$prefab"in e},isPrefabUpdate(e){return e!=null&&typeof e==="object"&&"$prefab"in e&&"update"in e}};function ls(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function lr(e,t,n){if(Yt.has(e)){T.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(Fe(e)!=null){T.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){T.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}Ee(e,r),n.tracked.push(e)}catch(r){if(ls(r)){n.evalBlocked=!0,T.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}T.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function ds(e){if(typeof document>"u")return;let t=ps(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let o=document.createElement("div");if(o.textContent=e.message,o.style.fontWeight="500",n.appendChild(o),e.description){let s=document.createElement("div");s.textContent=e.description,s.style.fontSize="14px",s.style.color="var(--muted-foreground, #6b7280)",n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.style.opacity="0",setTimeout(()=>n.remove(),300)},i)}function dr(e,t){if(we(e,t),typeof document<"u")we(document.documentElement,t)}function cs(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function cr(e,t){let n=[];if(typeof document>"u")return n;for(let r of e??[]){let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}for(let r of t??[])if(cs(r)){let o=document.createElement("link");o.rel="stylesheet",o.href=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}else{let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}return n}function pr(e,t){if(e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="",!t)return;if(t.preferredHeight!=null)e.style.height=`${t.preferredHeight}px`;if(t.minHeight!=null)e.style.minHeight=`${t.minHeight}px`;if(t.maxHeight!=null)e.style.maxHeight=`${t.maxHeight}px`,e.style.overflow="auto"}function ps(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.style.position="fixed",t.style.bottom="16px",t.style.right="16px",t.style.zIndex="9999",t.style.maxWidth="400px",document.body.appendChild(t);return t}if(typeof window<"u"){let e=window;e.PrefabRenderer=U,e.prefab={app:st,mount:U.mount.bind(U),isPrefabData:U.isPrefabData.bind(U),isPrefabUpdate:U.isPrefabUpdate.bind(U),Bridge:ge,isIframe:ve,registerPipe:Ee,unregisterPipe:Re,listPipes:je,registerComponent:p,createThemeToggle:Oe,validateWireFormat:ke,setLogLevel:Ie};let t=e.__PREFAB_DATA__;if(t!=null){let n=document.getElementById("prefab-root");if(n)U.mount(n,t)}}})();
16
+ `)}function ve(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function _t(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Bt(n)}`,Vt(r));if(t.dark){let r=document.getElementById("prefab-dark-theme");if(!r)r=document.createElement("style"),r.id="prefab-dark-theme",document.head.appendChild(r);r.textContent=rr({dark:t.dark})}}function zt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(cs(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function cs(e,t){let n=e.toLowerCase().split("+").map((i)=>i.trim()),r=n[n.length-1],o=new Set(n.slice(0,-1));if(o.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(o.has("shift")!==t.shiftKey)return!1;if(o.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===r}var or='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',ir='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',sr={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function ds(e,t){try{let r=localStorage.getItem(t);if(r==="light"||r==="dark")return r}catch{}let n=e.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(n==="light"||n==="dark")return n;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function De(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",r=t?.storageKey??"prefab-theme",o=t?.syncDocument??!0,i=getComputedStyle(e).position;if(i==="static"||i==="")e.style.position="relative";let s=document.createElement("button");s.className="pf-theme-toggle",s.setAttribute("aria-label","Toggle theme"),s.setAttribute("title","Toggle light/dark"),Object.assign(s.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let a=sr[n]??sr["top-right"];for(let d of a.split(";")){let[m,h]=d.split(":").map((C)=>C.trim());if(m&&h)s.style.setProperty(m,h)}s.addEventListener("mouseenter",()=>{s.style.opacity="1"}),s.addEventListener("mouseleave",()=>{s.style.opacity="0.7"});function l(d){if(ve(e,d),o)ve(document.documentElement,d);s.innerHTML=d==="dark"?ir:or;try{localStorage.setItem(r,d)}catch{}}let c=ds(e,r);l(c),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";l(d==="dark"?"light":"dark")}),e.appendChild(s);let u;if(o)u=new MutationObserver((d)=>{for(let m of d)if(m.type==="attributes"&&m.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){ve(e,h),s.innerHTML=h==="dark"?ir:or;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function st(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},r=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(o,i){let s=await r(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:o,arguments:i}})});if(!s.ok)throw Error(`MCP tool call failed: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw Error(a.error.message??"MCP tool call returned error");let l=a.result?.content??a.content??[];for(let c of l)if(c.type==="text"&&c.text!==void 0){try{let u=JSON.parse(c.text);if(typeof u==="object"&&u!==null&&"$prefab"in u)return u;return u}catch{}return c.text}return a.result??a},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function at(){return{callTool(e){return M.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return M.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var ar="0.3.19";var ps=["light","dark","auto"],us=["inline","fullscreen","pip"];function lr(e){return S(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||S(e.payload))}function lt(e){return typeof e==="boolean"?e:void 0}function cr(e){let t=I(e.capabilities)??{},n=I(e.theme),r=I(e.toolInput),o=I(e.meta);return{hostName:b(e.hostName),hostVersion:b(e.hostVersion),capabilities:{toast:lt(t.toast),clipboard:lt(t.clipboard),navigation:lt(t.navigation),messaging:lt(t.messaging),displayModes:Wt(t.displayModes)},...n&&{theme:fs(n)},...r&&{toolInput:r},...o&&{meta:o}}}function fs(e){let t=b(e.fontCss);return{...ct({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Wt(e){let t=Array.isArray(e)?e:[];return us.filter((n)=>t.includes(n))}function ct(e){let t={},n=ps.find((s)=>s===e.theme);if(n)t.colorScheme=n;let r=I(e.styles),o=I(r?.variables);if(o)t.variables=Object.fromEntries(Object.entries(o).filter((s)=>typeof s[1]==="string"));let i=b(I(r?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function ms(e){return S(e)&&e.jsonrpc==="2.0"}class he{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=hs();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(ms(r)){this.handleJsonRpc(r);return}if(!lr(r)||!r.type.startsWith("prefab:"))return;let o=r;if(o.type==="prefab:tool-call-response"&&o.id){let s=this.pending.get(o.id);if(s){if(this.pending.delete(o.id),o.payload?.error!=null)s.reject(Error(k(o.payload.error)));else s.resolve(o.payload?.result);return}}let i=this.listeners.get(o.type);if(i)for(let s of i)s(o.payload??{})};window.addEventListener("message",t),this.cleanup=()=>window.removeEventListener("message",t)}async initialize(e){try{return await Promise.any([this.initPrefab(e),this.initJsonRpc(e)])}catch(t){let n=t instanceof AggregateError?t.errors.map((r)=>r.message).join("; "):String(t);throw Error(`Bridge init failed — no host responded. Tried: ${n}`,{cause:t})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:e});else this.sendPrefab("prefab:request-mode",{mode:e})}openLink(e,t){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:e,target:t});else this.sendPrefab("prefab:open-link",{url:e,target:t})}updateContext(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:e});else this.sendPrefab("prefab:update-context",{context:e})}setupAutoResize(e){if(typeof ResizeObserver>"u")return dr;let t=-1,n=-1,r=(s,a)=>{if(s===t&&a===n)return;if(t=s,n=a,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:s,height:a});else this.sendPrefab("prefab:size-changed",{width:s,height:a})},o=new ResizeObserver((s)=>{for(let a of s)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];r(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();r(Math.ceil(l.width),Math.ceil(l.height))}});o.observe(e);let i=e.getBoundingClientRect();return r(Math.ceil(i.width),Math.ceil(i.height)),()=>o.disconnect()}notifyPreferredSize(e){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",e);else this.sendPrefab("prefab:preferred-size",e)}subscribe(e,t,n){let r=(o)=>{if(o.uri!==e)return;t(o.contents??o.data??o)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",r),this.sendRpcRequest("resources/subscribe",{uri:e}).catch((o)=>{this.off("prefab:resource-updated",r),n?.(o)});else this.on("prefab:resource-updated",r),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",r),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e}).catch(dr);else this.sendPrefab("prefab:unsubscribe",{uri:e})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);let n=this.listeners.get(e);if(n)n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,e]of this.pending)e.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,e]of this.rpcPending)e.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab(e){return new Promise((t,n)=>{let r=!1,o=(i)=>{if(r)return;r=!0,this.off("prefab:init-response",o),this.protocol="prefab",this._hostSupportsSubscriptions=I(i.capabilities)?.subscriptions===!0,t(cr(i))};this.on("prefab:init-response",o),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!r)r=!0,this.off("prefab:init-response",o),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((r,o)=>{this.pending.set(n,{resolve:r,reject:o}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),o(Error(`Tool call '${e}' timed out`))},30000)})},sendMessage:(e)=>(this.sendPrefab("prefab:send-message",{message:e}),Promise.resolve()),updateModelContext:(e)=>(this.sendPrefab("prefab:update-context",{context:e.structuredContent,content:e.content}),Promise.resolve()),subscribe:(e,t,n)=>this.subscribe(e,t,n),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab(e,t,n){if(typeof window>"u")return;let r=window.parent!==window?window.parent:window,o={type:e,payload:t,id:n};r.postMessage(o,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let r=this.rpcPending.get(e.id);if(r)if(this.rpcPending.delete(e.id),e.error)r.reject(Error(e.error.message));else r.resolve(e.result);return}let t=e.method,n=e.params??{};if(e.id!=null&&this.sentRpcIds.delete(e.id))return;if(e.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:e.id,result:{}});switch(t){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:n.arguments??n});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:n.arguments??n});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:n});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",n);break;case"ui/notifications/host-context-changed":{this.dispatch("prefab:theme-update",{...ct(n)}),this.dispatch("prefab:host-context-changed",n);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",n);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",n);break}}initJsonRpc(e){return new Promise((t,n)=>{let r=++this.rpcIdCounter,o=!1;this.rpcPending.set(r,{resolve:(i)=>{if(o)return;o=!0,this.protocol="jsonrpc";let s=I(i)??{},a=I(s.hostInfo)??{},l=I(s.hostContext)??{},c=I(s.hostCapabilities)??{},u=typeof l.theme==="string"||S(l.styles)?ct(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let d=I(c.resources);this._hostSupportsSubscriptions=c.subscriptions===!0||d?.subscribe===!0,t({hostName:b(a.name),hostVersion:b(a.version),capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:Wt(l.availableDisplayModes)},theme:u,toolInput:void 0,meta:l})},reject:(i)=>{if(o)return;o=!0,n(i)}}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:ar},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!o)o=!0,this.rpcPending.delete(r),n(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:(e,t)=>this.sendRpcRequest("tools/call",{name:e,arguments:t}),sendMessage:async(e)=>{await this.sendRpcRequest("ui/message",{role:"user",content:[{type:"text",text:e}]})},updateModelContext:async(e)=>{await this.sendRpcRequest("ui/update-model-context",{...e})},subscribe:(e,t,n)=>this.subscribe(e,t,n),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest(e,t){let n=++this.rpcIdCounter;return new Promise((r,o)=>{this.rpcPending.set(n,{resolve:r,reject:o}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),o(Error(`JSON-RPC '${e}' timed out`))},30000)})}sendRpcNotification(e,t){this.postJsonRpc({jsonrpc:"2.0",method:e,params:t})}postJsonRpc(e){if(typeof window>"u")return;if((typeof e.id==="number"||typeof e.id==="string")&&typeof e.method==="string")this.sentRpcIds.add(e.id);if(this.postFn)this.postFn(e);else(window.parent!==window?window.parent:window).postMessage(e,this.hostOrigin)}dispatch(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r(t)}}var dr=()=>{};function Ie(e,t){if(t.variables)for(let[n,r]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,r);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)gs(t.fontCss)}function gs(e){if(document.getElementById("__prefab-host-fonts"))return;let n=document.createElement("style");n.id="__prefab-host-fonts",n.textContent=e,document.head.appendChild(n)}function ke(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function hs(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(S(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(r)=>{Reflect.apply(n,t,[r])}}}}catch{return}return}async function dt(e){it();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&ke(),r,o,i={capabilities:{}};if(n)o=new he(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=st(e.transport);else r=at();if(i.theme&&typeof document<"u")Ie(document.documentElement,i.theme);if(typeof document<"u"&&!o)ys();let s,a,l,c,u,d=i.toolInput,m;if(o)o.on("prefab:tool-input",(f)=>{let y=I(f.args)??f;if(s)s(y);else d=y}),o.on("prefab:tool-result",(f)=>{let y=f.result??f;if(a)a(y);else m=y}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(f)=>{c?.(I(f.args)??f)}),o.on("prefab:theme-update",(f)=>{if(typeof document<"u")Ie(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...y){let x=Kt(f),v=new Re,R={store:v,scope:{},transport:r,rerender:()=>T(),onToast:void 0};function T(){x.innerHTML="";for(let E of y)x.appendChild(j(E,R))}return T(),{rerender:T,store:v,destroy:()=>{x.innerHTML=""}}}return{callTool:(f,y={})=>r.callTool(f,y),sendMessage:(f)=>r.sendMessage(f),onToolInput:(f)=>{if(s=f,d){let y=d;d=void 0,queueMicrotask(()=>f(y))}},onToolResult:(f)=>{if(a=f,m!==void 0){let y=m;m=void 0,queueMicrotask(()=>f(y))}},onToolCancelled:(f)=>{l=f},onToolInputPartial:(f)=>{c=f},onHostContextChanged:(f)=>{u=f},render:h,mount:(f,y,x)=>{let v=Kt(f);return q.mount(v,y,{transport:r,...x})},requestMode:(f)=>o?.requestMode(f),openLink:(f,y)=>{if(o)o.openLink(f,y);else if(typeof window<"u")window.open(f,y??"_blank")},updateContext:(f)=>{if(o)o.updateContext(f)},setupAutoResize:(f)=>{if(!o)return bs;let y=typeof f==="string"?Kt(f):f;return o.setupAutoResize(y)},notifyPreferredSize:(f)=>{if(o)o.notifyPreferredSize(f)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var bs=()=>{};function Kt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}return e}function ys(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let r=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",r)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var pr=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var mr=new Set(pr);function Se(e,t={}){let n=[],r=t.strict??!1;if(!S(e))return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e,i=o.$prefab;if(!S(i))n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof i.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(o.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Jt(o.view,"$.view",n,r);if(o.state!==void 0){if(o.state===null||typeof o.state!=="object"||Array.isArray(o.state))n.push({path:"$.state",message:"state must be a plain object"})}if(o.theme!==void 0)xs(o.theme,n);if(o.css!==void 0)fr(o.css,"$.css",n);if(o.stylesheets!==void 0)fr(o.stylesheets,"$.stylesheets",n);if(o.mode!==void 0&&o.mode!=="light"&&o.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});let s=o.defs;if(s!==void 0)if(!S(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Jt(c,`$.defs.${l}`,n,r);let a=o.keyBindings;if(a!==void 0)if(!S(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))Gt(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function gr(e){return Se(e).valid}function Jt(e,t,n,r){if(!S(e)){n.push({path:t,message:"Component must be a plain object"});return}let o=e;if(typeof o.type!=="string"||o.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(r&&!mr.has(o.type))n.push({path:`${t}.type`,message:`Unknown component type: "${o.type}"`});if(o.children!==void 0)if(!Array.isArray(o.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let s=0;s<o.children.length;s++)Jt(o.children[s],`${t}.children[${s}]`,n,r);let i=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let s of i)if(o[s]!==void 0)Gt(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||Cs.has(s)||i.includes(s))continue;if(ur(a)||Array.isArray(a)&&a.some(ur))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var Cs=new Set(["children","fallback","trigger","empty","else","summary"]);function ur(e){return S(e)&&typeof e.type==="string"&&mr.has(e.type)}function Gt(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)Gt(e[i],`${t}[${i}]`,n);return}if(!S(e)){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.action==="string"&&r.action.length>0?r.action:typeof r.type==="string"&&r.type.length>0?r.type:void 0;if(o===void 0){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if(o.toLowerCase()==="showtoast"){if(typeof r.message!=="string"||r.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function fr(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let r=0;r<e.length;r++)if(typeof e[r]!=="string")n.push({path:`${t}[${r}]`,message:"must be a string"})}function xs(e,t){if(!S(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}for(let n of["light","dark"])if(e[n]!==void 0){if(!S(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var q={mount(e,t,n){if(it(),n?.validate!==!1)for(let x of Se(t).errors)M.warn(`wire validation ${x.path}: ${x.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[x,v]of Object.entries(r.pipes))hr(x,v,o);let i=new Re(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=st(n.transport);else s=at();let a=n?.onToast??vs,l=new Ne;function c(x){if(!q.isPrefabData(x))return;let v=x;if(r=v,v.state)i.merge(v.state);if(v.defs)d.defs=v.defs;if(v.theme)_t(e,v.theme);if(v.mode)br(e,v.mode);if(v.pipes)for(let[R,T]of Object.entries(v.pipes))hr(R,T,o);for(let R of m)R.remove();if(m.length=0,m.push(...yr(v.css,v.stylesheets)),Cr(e,v.layout),h?.(),h=void 0,v.keyBindings)h=zt(v.keyBindings,(R)=>{O(P(R,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});y(),u(v)}function u(x){if(x.onMount!=null)O(P(x.onMount,d),"onMount")}let d={store:i,scope:{},transport:s,rerender:()=>y(),remount:c,onToast:a,defs:r.defs,destroyRegistry:l};if(_t(e,r.theme),r.mode)br(e,r.mode);Cr(e,r.layout);let m=yr(r.css,r.stylesheets),h;if(r.keyBindings)h=zt(r.keyBindings,(x)=>{O(P(x,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});let C,f=n?.themeToggle??!0;if(f!==!1)C=De(e,typeof f==="object"?f:void 0);function y(){l.flush();let x=e.querySelector(".pf-theme-toggle");e.innerHTML="";let v=j(r.view,d);if(e.appendChild(v),x)e.appendChild(x)}return y(),u(r),{rerender:()=>y(),update(x){if(i.merge(x.update.state),y(),x.update.actions!=null)O(P(x.update.actions,d),"update action")},store:i,destroy(){l.flush(),C?.(),h?.(),on(),ln();for(let x of m)x.remove();for(let x of o.tracked)Ae(x);e.innerHTML=""}}},isPrefabData(e){return e!=null&&typeof e==="object"&&"$prefab"in e},isPrefabUpdate(e){return e!=null&&typeof e==="object"&&"$prefab"in e&&"update"in e}};function ws(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function hr(e,t,n){if(rn.has(e)){M.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(Be(e)!=null){M.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){M.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}Te(e,r),n.tracked.push(e)}catch(r){if(ws(r)){n.evalBlocked=!0,M.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}M.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function vs(e){if(typeof document>"u")return;let t=Ss(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let o=document.createElement("div");if(o.textContent=e.message,o.style.fontWeight="500",n.appendChild(o),e.description){let s=document.createElement("div");s.textContent=e.description,s.style.fontSize="14px",s.style.color="var(--muted-foreground, #6b7280)",n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.style.opacity="0",setTimeout(()=>n.remove(),300)},i)}function br(e,t){if(ve(e,t),typeof document<"u")ve(document.documentElement,t)}function ks(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function yr(e,t){let n=[];if(typeof document>"u")return n;for(let r of e??[]){let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}for(let r of t??[])if(ks(r)){let o=document.createElement("link");o.rel="stylesheet",o.href=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}else{let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}return n}function Cr(e,t){if(e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="",!t)return;if(t.preferredHeight!=null)e.style.height=`${t.preferredHeight}px`;if(t.minHeight!=null)e.style.minHeight=`${t.minHeight}px`;if(t.maxHeight!=null)e.style.maxHeight=`${t.maxHeight}px`,e.style.overflow="auto"}function Ss(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.style.position="fixed",t.style.bottom="16px",t.style.right="16px",t.style.zIndex="9999",t.style.maxWidth="400px",document.body.appendChild(t);return t}if(typeof window<"u"){Object.assign(window,{PrefabRenderer:q}),Object.assign(window,{prefab:{app:dt,mount:q.mount.bind(q),isPrefabData:q.isPrefabData.bind(q),isPrefabUpdate:q.isPrefabUpdate.bind(q),Bridge:he,isIframe:ke,registerPipe:Te,unregisterPipe:Ae,listPipes:Fe,registerComponent:p,createThemeToggle:De,validateWireFormat:Se,setLogLevel:je}});let e=Reflect.get(window,"__PREFAB_DATA__");if(q.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)q.mount(t,e)}}})();