@maxhealth.tech/prefab 0.3.22 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/README.md +8 -0
- package/dist/a2ui/catalog.d.ts.map +1 -1
- package/dist/a2ui/catalog.js +1 -10
- package/dist/a2ui/catalog.js.map +1 -1
- package/dist/a2ui/control.d.ts.map +1 -1
- package/dist/a2ui/control.js +1 -10
- package/dist/a2ui/control.js.map +1 -1
- package/dist/a2ui.min.js +1 -1
- package/dist/auto/chart.js +1 -1
- package/dist/auto/chart.js.map +1 -1
- package/dist/auto/comparison.js +1 -1
- package/dist/auto/comparison.js.map +1 -1
- package/dist/auto/form.d.ts +1 -1
- package/dist/auto/form.d.ts.map +1 -1
- package/dist/auto/form.js +15 -2
- package/dist/auto/form.js.map +1 -1
- package/dist/auto/index.d.ts +2 -10
- package/dist/auto/index.d.ts.map +1 -1
- package/dist/auto/index.js +5 -61
- package/dist/auto/index.js.map +1 -1
- package/dist/auto/metrics.js +1 -1
- package/dist/auto/metrics.js.map +1 -1
- package/dist/auto/progress.d.ts.map +1 -1
- package/dist/auto/progress.js +8 -7
- package/dist/auto/progress.js.map +1 -1
- package/dist/auto/status.d.ts +17 -0
- package/dist/auto/status.d.ts.map +1 -0
- package/dist/auto/status.js +79 -0
- package/dist/auto/status.js.map +1 -0
- package/dist/auto/timeline.d.ts.map +1 -1
- package/dist/auto/timeline.js +3 -14
- package/dist/auto/timeline.js.map +1 -1
- package/dist/components/form/index.d.ts +3 -2
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +8 -2
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/layout/index.d.ts +7 -1
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/layout/index.js +6 -2
- package/dist/components/layout/index.js.map +1 -1
- package/dist/core/guards.d.ts +2 -0
- package/dist/core/guards.d.ts.map +1 -1
- package/dist/core/guards.js +13 -1
- package/dist/core/guards.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/prefab.css +742 -427
- package/dist/renderer/cdn.d.ts +5 -0
- package/dist/renderer/cdn.d.ts.map +1 -0
- package/dist/renderer/cdn.js +19 -0
- package/dist/renderer/cdn.js.map +1 -0
- package/dist/renderer/components/alert.d.ts.map +1 -1
- package/dist/renderer/components/alert.js +2 -6
- package/dist/renderer/components/alert.js.map +1 -1
- package/dist/renderer/components/card.js +0 -2
- package/dist/renderer/components/card.js.map +1 -1
- package/dist/renderer/components/charts/cartesian.d.ts +2 -2
- package/dist/renderer/components/charts/cartesian.d.ts.map +1 -1
- package/dist/renderer/components/charts/cartesian.js +6 -7
- package/dist/renderer/components/charts/cartesian.js.map +1 -1
- package/dist/renderer/components/charts/helpers.d.ts +12 -2
- package/dist/renderer/components/charts/helpers.d.ts.map +1 -1
- package/dist/renderer/components/charts/helpers.js +64 -26
- package/dist/renderer/components/charts/helpers.js.map +1 -1
- package/dist/renderer/components/charts/index.d.ts.map +1 -1
- package/dist/renderer/components/charts/index.js +6 -5
- package/dist/renderer/components/charts/index.js.map +1 -1
- package/dist/renderer/components/charts/scatter.d.ts +2 -2
- package/dist/renderer/components/charts/scatter.d.ts.map +1 -1
- package/dist/renderer/components/charts/scatter.js +39 -20
- package/dist/renderer/components/charts/scatter.js.map +1 -1
- package/dist/renderer/components/choice.js +67 -39
- package/dist/renderer/components/choice.js.map +1 -1
- package/dist/renderer/components/data.d.ts.map +1 -1
- package/dist/renderer/components/data.js +42 -74
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.d.ts +8 -10
- package/dist/renderer/components/form.d.ts.map +1 -1
- package/dist/renderer/components/form.js +147 -238
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/interactive.d.ts.map +1 -1
- package/dist/renderer/components/interactive.js +115 -158
- package/dist/renderer/components/interactive.js.map +1 -1
- package/dist/renderer/components/layout.js +29 -14
- package/dist/renderer/components/layout.js.map +1 -1
- package/dist/renderer/components/media.d.ts.map +1 -1
- package/dist/renderer/components/media.js +24 -15
- package/dist/renderer/components/media.js.map +1 -1
- package/dist/renderer/components/pdf.d.ts +38 -0
- package/dist/renderer/components/pdf.d.ts.map +1 -1
- package/dist/renderer/components/pdf.js +152 -174
- package/dist/renderer/components/pdf.js.map +1 -1
- package/dist/renderer/components/table.d.ts +4 -0
- package/dist/renderer/components/table.d.ts.map +1 -1
- package/dist/renderer/components/table.js +47 -35
- package/dist/renderer/components/table.js.map +1 -1
- package/dist/renderer/icons.d.ts +5 -0
- package/dist/renderer/icons.d.ts.map +1 -0
- package/dist/renderer/icons.generated.d.ts +3 -0
- package/dist/renderer/icons.generated.d.ts.map +1 -0
- package/dist/renderer/icons.generated.js +64 -0
- package/dist/renderer/icons.generated.js.map +1 -0
- package/dist/renderer/icons.js +23 -0
- package/dist/renderer/icons.js.map +1 -0
- package/dist/renderer/index.js +7 -12
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/theme.d.ts.map +1 -1
- package/dist/renderer/theme.js +3 -32
- package/dist/renderer/theme.js.map +1 -1
- package/dist/renderer.auto.min.js +10 -10
- package/dist/renderer.min.js +10 -10
- package/package.json +3 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(()=>{var Gt={silent:0,error:1,warn:2,info:3,debug:4},Ut="warn";function qt(e){Ut=e}function it(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(o,r,i)=>{if(Gt[o]>Gt[Ut])return;console[o](`${t} ${r}`,...i)};return{error:(o,...r)=>n("error",o,r),warn:(o,...r)=>n("warn",o,r),info:(o,...r)=>n("info",o,r),debug:(o,...r)=>n("debug",o,r)}}var N=it();function k(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function y(e){return typeof e==="string"?e:void 0}function F(e){return typeof e==="number"?e:void 0}function H(e){return k(e)?e:void 0}function K(e){return Array.isArray(e)?e.filter(k):[]}function st(e){return k(e)?[e]:K(e)}function Xt(e){let t={};if(!k(e))return t;for(let[n,o]of Object.entries(e))if(typeof o==="string"||typeof o==="number"||typeof o==="boolean")t[n]=String(o);return t}class Re{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return Po(this.data,e)}getAll(){return this.data}set(e,t){Yt(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 o=this.get(e);if(!Array.isArray(o)){this.set(e,[t]);return}if(n!==void 0)o.splice(n,0,t);else o.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 o=n.indexOf(t);if(o>=0)n.splice(o,1)}this.notify(e)}merge(e){for(let[t,n]of Object.entries(e))Yt(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 o=t.slice(0,n).join("."),r=this.subscribers.get(o);if(r)r.forEach((i)=>i())}this.globalSubscribers.forEach((n)=>n())}}function Po(e,t){let n=t.split("."),o=e;for(let r of n){if(o==null||typeof o!=="object")return;o=Reflect.get(o,r)}return o}var Ho=new Set(["__proto__","constructor","prototype"]);function Yt(e,t,n){let o=t.split(".");if(o.some((i)=>Ho.has(i))){N.warn(`Blocked prototype pollution attempt: ${t}`);return}let r=e;for(let i=0;i<o.length-1;i++){let s=o[i],a=r[s];if(k(a))r=a;else{let l={};r[s]=l,r=l}}r[o[o.length-1]]=n}function Zt(e){return typeof e==="function"}var ye=new Map;function at(e,t){if(ye.has(e)&&ye.get(e)!==t)N.warn(`pipe "${e}" re-registered`);ye.set(e,t)}function lt(e){return ye.delete(e)}function Qt(){return[...ye.keys()]}function He(e){return ye.get(e)}function v(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(v).join(", ");try{return JSON.stringify(e)??""}catch{return""}}function ct(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,dt=new Map,Oo=/\{\{\s*(.+?)\s*\}\}/g;function U(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function q(e,t,n){let o=e.trim();if(o.startsWith("{{")&&o.endsWith("}}")&&Vo(o,"{{")===1){let r=o.slice(2,-2).trim();return tn(r,t,n)}return e.replace(Oo,(r,i)=>{let s=tn(i.trim(),t,n);return v(s)})}function tn(e,t,n){let[o,...r]=Bo(e),i=G(o.trim(),t,n);for(let s of r)i=$o(s.trim(),i,t,n);return i}function G(e,t,n){let o=jo(e);if(o>=0){let s=e.slice(0,o).trim(),a=e.slice(o+1),l=Fo(a);if(l>=0){let c=a.slice(0,l).trim(),u=a.slice(l+1).trim(),d=G(s,t,n);return d!==null&&d!==void 0&&d!==!1&&d!==0&&d!==""?G(c,t,n):G(u,t,n)}}let r=Oe(e,"||");if(r>=0){let s=G(e.slice(0,r).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:G(e.slice(r+2).trim(),t,n)}let i=Oe(e,"&&");if(i>=0){let s=G(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return G(e.slice(i+2).trim(),t,n)}for(let[s,a]of Do){let l=Oe(e,s);if(l>=0){let c=G(e.slice(0,l).trim(),t,n),u=G(e.slice(l+s.length).trim(),t,n);return a(c,u)}}if(e.startsWith("!")){let s=G(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of Io){let l=Oe(e,s);if(l>=0){let c=G(e.slice(0,l).trim(),t,n),u=G(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 on=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 $o(e,t,n,o){let r=e.indexOf(":"),i=r>=0?e.slice(0,r).trim():e,s=r>=0?e.slice(r+1).trim():void 0,a=s?pt(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=nn(s);if(l.length<2)return;let c=String(pt(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(o&&u.startsWith("$")){let h=u.indexOf(".");if(h>=0){let x=u.slice(0,h);if(x in o)d=$e(o[x],u.slice(h+1))}else if(u in o)d=o[u]}if(d===void 0&&!(o&&u.startsWith("$")))if(o){let h=u.split(".")[0];d=h in o?$e(o[h],u.includes(".")?u.slice(h.length+1):""):n.get(u)}else d=n.get(u)}else d=u;if(d==null)return;let g=n?.generation??0;if(g!==en)dt=new Map,en=g;let m=dt.get(t);if(!m)m=new Map,dt.set(t,m);let b=m.get(c);if(!b){b=new Map;for(let h of t)if(k(h)){let x=h[c];if(x!=null)b.set(v(x),h)}m.set(c,b)}return b.get(v(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 ct(t,(l)=>l.toLocaleDateString());case"time":return ct(t,(l)=>l.toLocaleTimeString());case"datetime":return ct(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)=>k(l)&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(!k(l))return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=He(i);if(l){let c=s?nn(s).map(pt):[];return l(t,...c)}return t}}}var Do=[["!==",(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)]],Io=[[" + ",(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 Oe(e,t){let n=null;for(let o=0;o<e.length;o++){let r=e[o];if(r==="'"||r==='"')n=n===r?null:n??r;if(!n&&e.slice(o,o+t.length)===t)return o}return-1}function jo(e){let t=0,n=null;for(let o=0;o<e.length;o++){let r=e[o];if(r==="'"||r==='"')n=n===r?null:n??r;if(!n){if(r==="(")t++;else if(r===")")t--;else if(r==="?"&&t===0)return o}}return-1}function Fo(e){let t=0,n=null;for(let o=0;o<e.length;o++){let r=e[o];if(r==="'"||r==='"')n=n===r?null:n??r;if(!n){if(r==="?"||r==="(")t++;else if(r===")")t--;else if(r===":"&&t===0)return o}}return-1}function Bo(e){let t=[],n="",o=null;for(let r=0;r<e.length;r++){let i=e[r];if(i==="'"||i==='"')o=o===i?null:o??i;if(i==="|"&&!o)if(e[r+1]==="|")n+="||",r++;else t.push(n),n="";else n+=i}return t.push(n),t}function pt(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="",o=null;for(let r of e){if(r==="'"||r==='"')o=o===r?null:o??r;if(r===","&&!o)t.push(n),n="";else n+=r}return t.push(n),t}function $e(e,t){if(!t)return e;let n=t.split("."),o=e;for(let r of n){if(!k(o)&&!Array.isArray(o))return;o=Reflect.get(o,r)}return o}function Vo(e,t){let n=0,o=0;while((o=e.indexOf(t,o))!==-1)n++,o+=t.length;return n}function De(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function ut(e){let t={};for(let[n,o]of Object.entries(e)){let r=n.startsWith("$")?n:De(n);if(Array.isArray(o))t[r]=o.map((i)=>k(i)?ut(i):i);else if(k(o))t[r]=ut(o);else t[r]=o}return t}async function O(e,t){for(let n of st(e))await _o(n,t)}function D(e,t){e.catch((n)=>N.error(`${t} failed:`,n))}async function Ie(e,t,n,o){if(n!=null)N.debug(`${e} failed:`,t),await Ee(n,o,{$error:t});else N.warn(`${e} failed:`,t)}async function _o(e,t){let n=ut(e);switch(y(n.action)){case"setState":{zo(n,t);return}case"toggleState":{Wo(n,t);return}case"appendState":{Jo(n,t);return}case"popState":{Ko(n,t);return}case"showToast":{Go(n,t);return}case"closeOverlay":{Uo(n,t);return}case"openLink":{qo(n);return}case"setInterval":{Yo(n,t);return}case"toolCall":case"callTool":return Zo(n,t);case"sendMessage":return Qo(n,t);case"updateContext":{er(n,t);return}case"fetch":return tr(n,t);case"openFilePicker":{nr(n,t);return}case"callHandler":return or(n,t);case"requestDisplayMode":{rr(n,t);return}case"subscribe":{ar(n,t);return}case"unsubscribe":{lr(n);return}default:N.warn(`Unknown action: ${v(n.action)}`)}}function Be(e,t){let n=y(e.key);if(n===void 0)N.warn(`${t}: missing key`);return n}function zo(e,t){let n=Be(e,"setState");if(n===void 0)return;let o=e.value;if(U(o))o=q(o,t.store,t.scope);t.store.set(n,o),t.rerender(),Ee(e.onSuccess,t)}function Wo(e,t){let n=Be(e,"toggleState");if(n===void 0)return;t.store.toggle(n),t.rerender()}function Jo(e,t){let n=Be(e,"appendState");if(n===void 0)return;let o=e.value??e.item;if(U(o))o=q(o,t.store,t.scope);t.store.append(n,o,F(e.index)),t.rerender()}function Ko(e,t){let n=Be(e,"popState");if(n===void 0)return;let o=U(e.index)?q(e.index,t.store,t.scope):e.index;if(typeof o!=="number"&&typeof o!=="string"){N.warn("popState: missing index");return}t.store.pop(n,o),t.rerender()}function Go(e,t){t.onToast?.({message:Fe(e.message,t),description:e.description!=null?Fe(e.description,t):void 0,variant:y(e.variant),duration:F(e.duration)})}function Uo(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function qo(e){if(typeof window<"u"){let t=y(e.url);if(!t){N.warn("openLink: missing url");return}if(!un(t)){N.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,y(e.target)??"_blank")}}var je=new Set,Xo=20,ft=100;function Yo(e,t){let n=Math.max(F(e.intervalMs)??ft,ft),o=st(e.onTick);if(typeof globalThis.setInterval!=="function")return;if(o.length===0){N.warn("setInterval: missing onTick");return}if(je.size>=Xo){N.warn("Max intervals reached, ignoring new setInterval");return}let r=globalThis.setInterval(()=>D(O(o,t),"interval action"),n);je.add(r)}function rn(){for(let e of je)globalThis.clearInterval(e);je.clear()}async function sn(e,t,n){let o=y(e.resultKey);if(o!==void 0)n.store.set(o,t);let r=dn(t);if(r&&n.remount)n.remount(r);else pn(t,n),n.rerender();await Ee(e.onSuccess,n,{$result:t})}async function an(e,t,n,o,r){let i=fn(H(n.arguments),o);try{if(t===void 0)throw Error(`${e}: missing tool name`);let s=await r.callTool(t,i);await sn(n,s,o)}catch(s){await Ie(e,s,n.onError,o)}}async function Zo(e,t){if(!t.transport){N.warn("No MCP transport configured for toolCall");return}await an("toolCall",y(e.tool),e,t,t.transport)}async function Qo(e,t){if(!t.transport){N.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(Fe(e.message,t))}function er(e,t){let n=H(e.context);if(n!=null)t.store.merge(n),t.rerender()}async function tr(e,t){let n=Fe(e.url,t);if(!un(n)){N.warn(`Blocked unsafe URL in fetch: ${n}`);return}let o=y(e.method)??"GET",r=Xt(e.headers),i=e.body!==void 0?JSON.stringify(e.body):void 0;try{let s=await globalThis.fetch(n,{method:o,headers:{"Content-Type":"application/json",...r},...i&&{body:i}}),a=await s.json().catch(()=>s.text());await sn(e,a,t)}catch(s){await Ie("fetch",s,e.onError,t)}}function nr(e,t){if(typeof document>"u")return;let n=document.createElement("input");n.type="file";let o=y(e.accept);if(o!==void 0)n.accept=o;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let r=Array.from(n.files??[]),i=y(e.resultKey);if(i!==void 0)t.store.set(i,r);t.rerender(),Ee(e.onSuccess,t,{$result:r})}),n.click()}async function or(e,t){let n=y(e.handler);if(!t.transport){N.warn(`No transport configured for callHandler: ${n??""}`);return}await an("callHandler",n,e,t,t.transport)}function rr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var ee=new Map,ir=50,sr=2000;function ar(e,t){let n=y(e.uri),o=y(e.stateKey);if(!n||!o){N.warn("subscribe: missing uri or stateKey");return}if(ee.has(n))return;if(ee.size>=ir){N.warn("Max subscriptions reached, ignoring new subscribe");return}let r=(d)=>{let g=dn(d);if(g&&t.remount)t.remount(g);else{if(!pn(d,t))t.store.set(o,d);t.rerender()}Ee(e.onData,t,{$data:d})};if(e.push!==!1&&t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let d=t.transport.subscribe(n,r,(g)=>{if(ee.get(n)===d)ee.delete(n);Ie("subscribe",g,e.onError,t)});ee.set(n,d);return}let i=y(e.fallbackTool),s=F(e.fallbackInterval)??sr;if(!i){N.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){N.warn("No MCP transport configured for subscribe fallback");return}let a=H(e.fallbackArgs)??{},l=Math.max(s,ft),c=t.transport,u=globalThis.setInterval(()=>{(async()=>{try{let d=fn(a,t),g=await c.callTool(i,d);r(g)}catch(d){Ie("subscribe",d,e.onError,t)}})()},l);ee.set(n,()=>globalThis.clearInterval(u))}function lr(e){let t=y(e.uri);if(!t){N.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){N.warn(`Error cleaning up subscription '${e}':`,n)}ee.clear()}function cr(e){try{return JSON.parse(e)}catch{return}}function cn(e,t){if(!k(e))return null;if(t(e))return e;let n=e.structuredContent;if(k(n)&&t(n))return n;for(let o of K(e.content)){if(o.type!=="text"||typeof o.text!=="string")continue;let r=cr(o.text);if(k(r)&&t(r))return r}return null}function dr(e){return"$prefab"in e&&"view"in e}function pr(e){return"$prefab"in e&&k(e.update)&&"state"in e.update}function dn(e){return cn(e,dr)}function pn(e,t){let n=cn(e,pr);if(!n)return!1;let{update:o}=n,r=H(o.state);if(r)t.store.merge(r);if(o.actions!=null)D(O(o.actions,t),"update action");return!0}var ur=/^\s*(javascript|vbscript|data):/i;function un(e){return!ur.test(e)}function Fe(e,t){if(U(e)){let n=q(e,t.store,t.scope);return v(n)}return v(e)}function fn(e,t){if(!e)return{};let n={};for(let[o,r]of Object.entries(e))n[o]=U(r)?q(r,t.store,t.scope):r;return n}async function Ee(e,t,n){if(e==null)return;let o={...t.scope,...n};await O(e,{...t,scope:o})}function Ve(e,t){return e===void 0||t(e)}function mt(e){return k(e)||Array.isArray(e)&&e.every(k)}function be(e){return k(e)&&typeof e.type==="string"&&Ve(e.id,(t)=>typeof t==="string")&&Ve(e.cssClass,(t)=>typeof t==="string")&&Ve(e.onMount,mt)&&Ve(e.children,(t)=>Array.isArray(t)&&t.every(be))}function de(e){return Array.isArray(e)?e.filter(be):[]}function ht(e){let t={};for(let[n,o]of Object.entries(e)){let r=n.startsWith("$")?n:De(n);if(Array.isArray(o))t[r]=o.map((i)=>k(i)?ht(i):i);else if(k(o))t[r]=ht(o);else t[r]=o}return t}function fr(e){let{id:t,cssClass:n,onMount:o,children:r,...i}=ht(e),s={...i,type:e.type};if(typeof t==="string")s.id=t;if(typeof n==="string")s.cssClass=n;if(mt(o))s.onMount=o;if(Array.isArray(r))s.children=de(r);return s}class yt{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){N.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function mr(e){return typeof e==="object"&&"element"in e}var _e=new Map;function p(e,t){if(_e.has(e))N.warn(`overriding existing renderer for "${e}"`);_e.set(e,t)}function bt(){return[..._e.keys()].sort()}var mn=new Set;function hn(e){mn.clear();for(let t of e)mn.add(t)}function V(e,t){let n=fr(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return V(i,t)}let o=_e.get(n.type),r;if(o){let i=o(n,t);if(mr(i))r=i.element,t.destroyRegistry?.track(i.destroy);else r=i}else if(r=document.createElement("div"),r.setAttribute("data-prefab-type",n.type),n.children)for(let i of n.children)r.appendChild(V(i,t));if(r instanceof HTMLElement){if(n.id)r.id=n.id;if(n.cssClass){let i=C(n.cssClass,t);if(i)r.className=(r.className?r.className+" ":"")+i}if(n.onClick!=null){if(r.addEventListener("click",()=>{D(O(n.onClick,B(t)),"onClick")}),r.tagName!=="BUTTON"&&r.tagName!=="A")r.setAttribute("role","button"),r.setAttribute("tabindex","0"),r.addEventListener("keydown",(i)=>{if(i.key==="Enter"||i.key===" ")i.preventDefault(),D(O(n.onClick,B(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=B(t);queueMicrotask(()=>D(O(i,s),"onMount"))}return r}function M(e,t,n){if(!e.children)return;pe(e.children,t,n)}function pe(e,t,n){let o=0;while(o<e.length){let r=e[o];if(r.type==="If")o=gr(e,o,t,n);else if(r.type==="Elif"||r.type==="Else")o++;else t.appendChild(V(r,n)),o++}}function gr(e,t,n,o){let r=!1,i=t,s=e[i];if(gn(y(s.condition)??"",o))gt(s,n,o),r=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!r&&gn(y(a.condition)??"",o))gt(a,n,o),r=!0;i++}else if(a.type==="Else"){if(!r)gt(a,n,o);i++;break}else break}return i}function gn(e,t){if(!e)return!1;if(U(e))return Boolean(q(e,t.store,t.scope));return Boolean(t.store.get(e))}function gt(e,t,n){if(!e.children)return;pe(e.children,t,n)}function C(e,t){if(U(e)){let n=q(e,t.store,t.scope);return v(n)}return v(e)}function J(e,t){if(U(e))return q(e,t.store,t.scope);return e}function B(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function f(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function Ct(e,t){return e.textContent=t,e}function vn(){p("Column",hr),p("Row",yr),p("Grid",yn),p("GridItem",bn),p("Container",br),p("Div",Cn),p("Span",Cr),p("Dashboard",yn),p("DashboardItem",bn),p("Pages",xr),p("Page",Cn),p("Detail",vr),p("MasterDetail",wr)}function hr(e,t){let n=f("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let o=ze(e);if(o!=null)n.style.gap=`${o*4}px`;return wn(n,e),M(e,n,t),n}function yr(e,t){let n=f("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let o=ze(e);if(o!=null)n.style.gap=`${o*4}px`;if(wn(n,e),e.wrap===!0)n.style.flexWrap="wrap";return M(e,n,t),n}function yn(e,t){let n=f("div","pf-grid");n.style.display="grid",n.style.gridTemplateColumns=`repeat(${Rr(e.columns)}, 1fr)`;let o=ze(e);if(o!=null)n.style.gap=`${o*4}px`;return M(e,n,t),n}function bn(e,t){let n=f("div","pf-grid-item"),o=F(e.colSpan),r=F(e.rowSpan);if(o!=null)n.style.gridColumn=`span ${o}`;if(r!=null)n.style.gridRow=`span ${r}`;return M(e,n,t),n}function br(e,t){let n=f("div","pf-container");n.style.maxWidth=y(e.maxWidth)??"1200px",n.style.margin="0 auto";let o=F(e.padding);if(o!=null)n.style.padding=`${o*4}px`;return M(e,n,t),n}function Cn(e,t){let n=f("div","pf-div");return M(e,n,t),n}function Cr(e,t){let n=f("span","pf-span");return M(e,n,t),n}function xr(e,t){let n=f("div","pf-pages");return M(e,n,t),n}function vr(e,t){let n=f("div","pf-detail"),o=e.of!=null?J(e.of,t):void 0;if(o!=null&&o!==""&&o!==!1&&o!==0)M(e,n,t);else if(be(e.empty))n.appendChild(V(e.empty,t));return n}function wr(e,t){let n=f("div","pf-master-detail");n.style.display="flex",n.style.flexDirection="row";let o=ze(e);if(o!=null)n.style.gap=`${o*4}px`;let r=y(e.masterWidth)??"33%",i=e.children??[];if(i.length>0){let s=f("div","pf-master-detail-master");s.style.width=r,s.style.flexShrink="0",s.style.overflow="auto",s.appendChild(V(i[0],t)),n.appendChild(s)}if(i.length>1){let s=f("div","pf-master-detail-detail");s.style.flex="1",s.style.overflow="auto",s.appendChild(V(i[1],t)),n.appendChild(s)}return n}var kr=/\bgap-(\d+)\b/;function ze(e){let t=F(e.gap);if(t!=null)return t;if(typeof e.cssClass==="string"){let n=kr.exec(e.cssClass);if(n)return Number(n[1])}return null}var Sr=["default","base","xs","sm","md","lg","xl","2xl"],xn=3;function Rr(e){if(typeof e==="number")return e;if(!k(e))return xn;let t=Sr.map((n)=>e[n]).filter((n)=>typeof n==="number");return t.length>0?t[t.length-1]:xn}function wn(e,t){let n=y(t.align),o=y(t.justify);if(n!=null)e.style.alignItems=Er(n);if(o!=null)e.style.justifyContent=Tr(o)}function Er(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Tr(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var Mr={"&":"&","<":"<",">":">",'"':""","'":"'"};function te(e){return e.replace(/[&<>"']/g,(t)=>Mr[t]??t)}function Sn(){p("Heading",Nr),p("H1",(e,t)=>We(e,t,"h1")),p("H2",(e,t)=>We(e,t,"h2")),p("H3",(e,t)=>We(e,t,"h3")),p("H4",(e,t)=>We(e,t,"h4")),p("Text",Lr),p("P",Ar),p("Lead",(e,t)=>Ce(e,t,"p","pf-lead")),p("Large",(e,t)=>Ce(e,t,"span","pf-large")),p("Small",(e,t)=>Ce(e,t,"small","pf-small")),p("Muted",(e,t)=>Ce(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>Ce(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>Ce(e,t,"label","pf-label")),p("Link",Hr),p("Code",Or),p("Markdown",$r),p("Kbd",Dr)}function Nr(e,t){let n=F(e.level)??2,o=`h${Math.min(Math.max(n,1),6)}`,r=document.createElement(o);return r.className=`pf-heading pf-${o}`,r.textContent=C(e.content,t),r}function We(e,t,n){let o=document.createElement(n);return o.className=`pf-heading pf-${n}`,o.textContent=C(e.content,t),o}function Lr(e,t){return Ct(f("span","pf-text"),C(e.content,t))}function Ar(e,t){return Ct(f("p","pf-p"),C(e.content,t))}function Ce(e,t,n,o){let r=document.createElement(n);return r.className=o,r.textContent=C(e.content,t),r}var Pr=/^\s*(javascript|vbscript|data):/i;function Hr(e,t){let n=document.createElement("a");if(n.className="pf-link",n.textContent=C(e.content,t),e.href!=null){let o=C(e.href,t);if(!Pr.test(o))n.href=o}if(e.target!=null)n.target=C(e.target,t);return n}function Or(e,t){let n=f("pre","pf-code"),o=f("code");if(o.textContent=C(e.content,t),e.language!=null)o.setAttribute("data-language",v(e.language));return n.appendChild(o),n}function $r(e,t){let n=f("div","pf-markdown"),o=C(e.content,t);return n.innerHTML=Rn(o),n.setAttribute("data-markdown","true"),n}var kn=/^\s*(javascript|vbscript|data):/i;function Je(e){let t=te(e),n=[];return t=t.replace(/`([^`]+)`/g,(o,r)=>(n.push(`<code>${r}</code>`),`CODE${n.length-1}`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(o,r,i)=>{if(kn.test(i))return te(r);return`<img src="${i}" alt="${r}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(o,r,i)=>{if(kn.test(i))return r;return`<a href="${i}">${r}</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,(o,r)=>n[parseInt(r)]),t}function Rn(e){let t=e.replace(/\r\n?/g,`
|
|
1
|
+
(()=>{var sn={silent:0,error:1,warn:2,info:3,debug:4},an="warn";function ln(e){an=e}function mt(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,i)=>{if(sn[r]>sn[an])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 S=mt();function M(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function b(e){return typeof e==="string"?e:void 0}function O(e){return typeof e==="number"?e:void 0}function P(e){return M(e)?e:void 0}function W(e){return Array.isArray(e)?e.filter(M):[]}function ht(e){return M(e)?[e]:W(e)}function no(e){return typeof e==="string"||typeof e==="number"||typeof e==="boolean"}function cn(e){let t={};if(!M(e))return t;for(let[n,r]of Object.entries(e))if(no(r))t[n]=String(r);return t}class Pe{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return ro(this.data,e)}getAll(){return this.data}set(e,t){dn(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))dn(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 ro(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 oo=new Set(["__proto__","constructor","prototype"]);function dn(e,t,n){let r=t.split(".");if(r.some((i)=>oo.has(i))){S.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(M(a))o=a;else{let l={};o[s]=l,o=l}}o[r[r.length-1]]=n}function pn(e){return typeof e==="function"}var ke=new Map;function gt(e,t){if(ke.has(e)&&ke.get(e)!==t)S.warn(`pipe "${e}" re-registered`);ke.set(e,t)}function bt(e){return ke.delete(e)}function un(){return[...ke.keys()]}function ze(e){return ke.get(e)}function T(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(T).join(", ");try{return JSON.stringify(e)??""}catch{return""}}function yt(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 fn=-1,Ct=new Map,io=/\{\{\s*(.+?)\s*\}\}/g;function q(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function U(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&fo(r,"{{")===1){let o=r.slice(2,-2).trim();return mn(o,t,n)}return e.replace(io,(o,i)=>{let s=mn(i.trim(),t,n);return T(s)})}function mn(e,t,n){let[r,...o]=uo(e),i=G(r.trim(),t,n);for(let s of o)i=so(s.trim(),i,t,n);return i}function G(e,t,n){let r=co(e);if(r>=0){let s=e.slice(0,r).trim(),a=e.slice(r+1),l=po(a);if(l>=0){let c=a.slice(0,l).trim(),d=a.slice(l+1).trim(),u=G(s,t,n);return u!==null&&u!==void 0&&u!==!1&&u!==0&&u!==""?G(c,t,n):G(d,t,n)}}let o=Je(e,"||");if(o>=0){let s=G(e.slice(0,o).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:G(e.slice(o+2).trim(),t,n)}let i=Je(e,"&&");if(i>=0){let s=G(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return G(e.slice(i+2).trim(),t,n)}for(let[s,a]of ao){let l=Je(e,s);if(l>=0){let c=G(e.slice(0,l).trim(),t,n),d=G(e.slice(l+s.length).trim(),t,n);return a(c,d)}}if(e.startsWith("!")){let s=G(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of lo){let l=Je(e,s);if(l>=0){let c=G(e.slice(0,l).trim(),t,n),d=G(e.slice(l+s.length).trim(),t,n);return a(Number(c),Number(d))}}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 Ke(c,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return Ke(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}var gn=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 so(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?vt(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=hn(s);if(l.length<2)return;let c=String(vt(l[0])),d=l[1].trim(),u;if(d.startsWith("'")&&d.endsWith("'")||d.startsWith('"')&&d.endsWith('"'))u=d.slice(1,-1);else if(n){if(r&&d.startsWith("$")){let g=d.indexOf(".");if(g>=0){let y=d.slice(0,g);if(y in r)u=Ke(r[y],d.slice(g+1))}else if(d in r)u=r[d]}if(u===void 0&&!(r&&d.startsWith("$")))if(r){let g=d.split(".")[0];u=g in r?Ke(r[g],d.includes(".")?d.slice(g.length+1):""):n.get(d)}else u=n.get(d)}else u=d;if(u==null)return;let h=n?.generation??0;if(h!==fn)Ct=new Map,fn=h;let m=Ct.get(t);if(!m)m=new Map,Ct.set(t,m);let v=m.get(c);if(!v){v=new Map;for(let g of t)if(M(g)){let y=g[c];if(y!=null)v.set(T(y),g)}m.set(c,v)}return v.get(T(u))}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 yt(t,(l)=>l.toLocaleDateString());case"time":return yt(t,(l)=>l.toLocaleTimeString());case"datetime":return yt(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)=>M(l)&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(!M(l))return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=ze(i);if(l){let c=s?hn(s).map(vt):[];return l(t,...c)}return t}}}var ao=[["!==",(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)]],lo=[[" + ",(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 Je(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 co(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 po(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 uo(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 vt(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 hn(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 Ke(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(!M(r)&&!Array.isArray(r))return;r=Reflect.get(r,o)}return r}function fo(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function We(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function xt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:We(n);if(Array.isArray(r))t[o]=r.map((i)=>M(i)?xt(i):i);else if(M(r))t[o]=xt(r);else t[o]=r}return t}async function I(e,t){for(let n of ht(e))await mo(n,t)}function j(e,t){e.catch((n)=>S.error(`${t} failed:`,n))}async function Ge(e,t,n,r){if(n!=null)S.debug(`${e} failed:`,t),await Oe(n,r,{$error:t});else S.warn(`${e} failed:`,t)}async function mo(e,t){let n=xt(e);switch(b(n.action)){case"setState":{ho(n,t);return}case"toggleState":{go(n,t);return}case"appendState":{bo(n,t);return}case"popState":{yo(n,t);return}case"showToast":{Co(n,t);return}case"closeOverlay":{vo(n,t);return}case"openLink":{xo(n);return}case"setInterval":{ko(n,t);return}case"toolCall":case"callTool":return Mo(n,t);case"sendMessage":return Ro(n,t);case"updateContext":{Eo(n,t);return}case"fetch":return To(n,t);case"openFilePicker":{Ao(n,t);return}case"callHandler":return So(n,t);case"requestDisplayMode":{Lo(n,t);return}case"subscribe":{Po(n,t);return}case"unsubscribe":{Oo(n);return}default:S.warn(`Unknown action: ${T(n.action)}`)}}function Xe(e,t){let n=b(e.key);if(n===void 0)S.warn(`${t}: missing key`);return n}function ho(e,t){let n=Xe(e,"setState");if(n===void 0)return;let r=e.value;if(q(r))r=U(r,t.store,t.scope);t.store.set(n,r),t.rerender(),Oe(e.onSuccess,t)}function go(e,t){let n=Xe(e,"toggleState");if(n===void 0)return;t.store.toggle(n),t.rerender()}function bo(e,t){let n=Xe(e,"appendState");if(n===void 0)return;let r=e.value??e.item;if(q(r))r=U(r,t.store,t.scope);t.store.append(n,r,O(e.index)),t.rerender()}function yo(e,t){let n=Xe(e,"popState");if(n===void 0)return;let r=q(e.index)?U(e.index,t.store,t.scope):e.index;if(typeof r!=="number"&&typeof r!=="string"){S.warn("popState: missing index");return}t.store.pop(n,r),t.rerender()}function Co(e,t){t.onToast?.({message:Ue(e.message,t),description:e.description!=null?Ue(e.description,t):void 0,variant:b(e.variant),duration:O(e.duration)})}function vo(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function xo(e){if(typeof window<"u"){let t=b(e.url);if(!t){S.warn("openLink: missing url");return}if(!Mn(t)){S.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,b(e.target)??"_blank")}}var qe=new Set,wo=20,wt=100;function ko(e,t){let n=Math.max(O(e.intervalMs)??wt,wt),r=ht(e.onTick);if(typeof globalThis.setInterval!=="function")return;if(r.length===0){S.warn("setInterval: missing onTick");return}if(qe.size>=wo){S.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>j(I(r,t),"interval action"),n);qe.add(o)}function bn(){for(let e of qe)globalThis.clearInterval(e);qe.clear()}async function yn(e,t,n){let r=b(e.resultKey);if(r!==void 0)n.store.set(r,t);let o=wn(t);if(o&&n.remount)n.remount(o);else kn(t,n),n.rerender();await Oe(e.onSuccess,n,{$result:t})}async function Cn(e,t,n,r,o){let i=Rn(P(n.arguments),r);try{if(t===void 0)throw Error(`${e}: missing tool name`);let s=await o.callTool(t,i);await yn(n,s,r)}catch(s){await Ge(e,s,n.onError,r)}}async function Mo(e,t){if(!t.transport){S.warn("No MCP transport configured for toolCall");return}await Cn("toolCall",b(e.tool),e,t,t.transport)}async function Ro(e,t){if(!t.transport){S.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(Ue(e.message,t))}function Eo(e,t){let n=P(e.context);if(n!=null)t.store.merge(n),t.rerender()}async function To(e,t){let n=Ue(e.url,t);if(!Mn(n)){S.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=b(e.method)??"GET",o=cn(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 yn(e,a,t)}catch(s){await Ge("fetch",s,e.onError,t)}}function Ao(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(),Oe(e.onSuccess,t,{$result:o})}),n.click()}async function So(e,t){let n=b(e.handler);if(!t.transport){S.warn(`No transport configured for callHandler: ${n??""}`);return}await Cn("callHandler",n,e,t,t.transport)}function Lo(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var Y=new Map,No=50,Ho=2000;function Po(e,t){let n=b(e.uri),r=b(e.stateKey);if(!n||!r){S.warn("subscribe: missing uri or stateKey");return}if(Y.has(n))return;if(Y.size>=No){S.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(u)=>{let h=wn(u);if(h&&t.remount)t.remount(h);else{if(!kn(u,t))t.store.set(r,u);t.rerender()}Oe(e.onData,t,{$data:u})};if(e.push!==!1&&t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let u=t.transport.subscribe(n,o,(h)=>{if(Y.get(n)===u)Y.delete(n);Ge("subscribe",h,e.onError,t)});Y.set(n,u);return}let i=b(e.fallbackTool),s=O(e.fallbackInterval)??Ho;if(!i){S.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){S.warn("No MCP transport configured for subscribe fallback");return}let a=P(e.fallbackArgs)??{},l=Math.max(s,wt),c=t.transport,d=globalThis.setInterval(()=>{(async()=>{try{let u=Rn(a,t),h=await c.callTool(i,u);o(h)}catch(u){Ge("subscribe",u,e.onError,t)}})()},l);Y.set(n,()=>globalThis.clearInterval(d))}function Oo(e){let t=b(e.uri);if(!t){S.warn("unsubscribe: missing uri");return}let n=Y.get(t);if(n)n(),Y.delete(t)}function vn(){for(let[e,t]of Y)try{t()}catch(n){S.warn(`Error cleaning up subscription '${e}':`,n)}Y.clear()}function Do(e){try{return JSON.parse(e)}catch{return}}function xn(e,t){if(!M(e))return null;if(t(e))return e;let n=e.structuredContent;if(M(n)&&t(n))return n;for(let r of W(e.content)){if(r.type!=="text"||typeof r.text!=="string")continue;let o=Do(r.text);if(M(o)&&t(o))return o}return null}function $o(e){return"$prefab"in e&&"view"in e}function Fo(e){return"$prefab"in e&&M(e.update)&&"state"in e.update}function wn(e){return xn(e,$o)}function kn(e,t){let n=xn(e,Fo);if(!n)return!1;let{update:r}=n,o=P(r.state);if(o)t.store.merge(o);if(r.actions!=null)j(I(r.actions,t),"update action");return!0}var Io=/^\s*(javascript|vbscript|data):/i;function Mn(e){return!Io.test(e)}function Ue(e,t){if(q(e)){let n=U(e,t.store,t.scope);return T(n)}return T(e)}function Rn(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=q(o)?U(o,t.store,t.scope):o;return n}async function Oe(e,t,n){if(e==null)return;let r={...t.scope,...n};await I(e,{...t,scope:r})}function Ze(e,t){return e===void 0||t(e)}function kt(e){return M(e)||Array.isArray(e)&&e.every(M)}function Me(e){return M(e)&&typeof e.type==="string"&&Ze(e.id,(t)=>typeof t==="string")&&Ze(e.cssClass,(t)=>typeof t==="string")&&Ze(e.onMount,kt)&&Ze(e.children,(t)=>Array.isArray(t)&&t.every(Me))}function me(e){return Array.isArray(e)?e.filter(Me):[]}function Rt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:We(n);if(Array.isArray(r))t[o]=r.map((i)=>M(i)?Rt(i):i);else if(M(r))t[o]=Rt(r);else t[o]=r}return t}function jo(e){let{id:t,cssClass:n,onMount:r,children:o,...i}=Rt(e),s={...i,type:e.type};if(typeof t==="string")s.id=t;if(typeof n==="string")s.cssClass=n;if(kt(r))s.onMount=r;if(Array.isArray(o))s.children=me(o);return s}class Et{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){S.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function Vo(e){return typeof e==="object"&&"element"in e}var Ye=new Map;function p(e,t){if(Ye.has(e))S.warn(`overriding existing renderer for "${e}"`);Ye.set(e,t)}function Tt(){return[...Ye.keys()].sort()}var En=new Set;function An(e){En.clear();for(let t of e)En.add(t)}function B(e,t){let n=jo(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return B(i,t)}let r=Ye.get(n.type),o;if(r){let i=r(n,t);if(Vo(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(B(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",()=>{j(I(n.onClick,z(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(i)=>{if(i.key==="Enter"||i.key===" ")i.preventDefault(),j(I(n.onClick,z(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=z(t);queueMicrotask(()=>j(I(i,s),"onMount"))}return o}function L(e,t,n){if(!e.children)return;he(e.children,t,n)}function he(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=Bo(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(B(o,n)),r++}}function Bo(e,t,n,r){let o=!1,i=t,s=e[i];if(Tn(b(s.condition)??"",r))Mt(s,n,r),o=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!o&&Tn(b(a.condition)??"",r))Mt(a,n,r),o=!0;i++}else if(a.type==="Else"){if(!o)Mt(a,n,r);i++;break}else break}return i}function Tn(e,t){if(!e)return!1;if(q(e))return Boolean(U(e,t.store,t.scope));return Boolean(t.store.get(e))}function Mt(e,t,n){if(!e.children)return;he(e.children,t,n)}function C(e,t){if(q(e)){let n=U(e,t.store,t.scope);return T(n)}return T(e)}function J(e,t){if(q(e))return U(e,t.store,t.scope);return e}function z(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function f(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function At(e,t){return e.textContent=t,e}function Dn(){p("Column",_o),p("Row",zo),p("Grid",Sn),p("GridItem",Nn),p("Container",Jo),p("Div",Hn),p("Span",Ko),p("Dashboard",Sn),p("DashboardItem",Nn),p("Pages",Wo),p("Page",Hn),p("Detail",Go),p("MasterDetail",qo)}function _o(e,t){let n=f("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 $n(n,e),L(e,n,t),n}function zo(e,t){let n=f("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($n(n,e),e.wrap===!0)n.style.flexWrap="wrap";return L(e,n,t),n}function Sn(e,t){let n=f("div","pf-grid");n.style.display="grid",n.style.gridTemplateColumns=`repeat(${Zo(e.columns)}, minmax(0, 1fr))`;let r=Qe(e);if(r!=null)n.style.gap=`${r*4}px`;let o=O(e.rowHeight);if(o!=null)n.style.gridAutoRows=`minmax(${o}px, auto)`;return L(e,n,t),n}function Ln(e,t){if(e!=null)return t!=null?`${e} / span ${t}`:String(e);return t!=null?`span ${t}`:void 0}function Nn(e,t){let n=f("div","pf-grid-item"),r=Ln(O(e.col),O(e.colSpan)),o=Ln(O(e.row),O(e.rowSpan));if(r!=null)n.style.gridColumn=r;if(o!=null)n.style.gridRow=o;return L(e,n,t),n}function Jo(e,t){let n=f("div","pf-container");n.style.maxWidth=b(e.maxWidth)??"1200px",n.style.margin="0 auto";let r=O(e.padding);if(r!=null)n.style.padding=`${r*4}px`;return L(e,n,t),n}function Hn(e,t){let n=f("div","pf-div");return L(e,n,t),n}function Ko(e,t){let n=f("span","pf-span");return L(e,n,t),n}function Pn(e){return b(e.name)??b(e.value)??b(e.title)}function Wo(e,t){let n=f("div","pf-pages"),r=e.children??[],o=b(e.name),i=o!=null?t.store.get(o):void 0,s=typeof i==="string"?i:b(e.value),a=r.find((l)=>s!=null&&Pn(l)===s)??r.at(0);if(a!=null)n.setAttribute("data-page",Pn(a)??""),n.appendChild(B(a,t));return n}function Go(e,t){let n=f("div","pf-detail"),r=e.of!=null?J(e.of,t):void 0;if(r!=null&&r!==""&&r!==!1&&r!==0)L(e,n,t);else if(Me(e.empty))n.appendChild(B(e.empty,t));return n}function qo(e,t){let n=f("div","pf-master-detail"),r=Qe(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=f("div","pf-master-detail-master");s.style.width=o,s.appendChild(B(i[0],t)),n.appendChild(s)}if(i.length>1){let s=f("div","pf-master-detail-detail");s.appendChild(B(i[1],t)),n.appendChild(s)}return n}var Uo=/\bgap-(\d+)\b/;function Qe(e){let t=O(e.gap);if(t!=null)return t;if(typeof e.cssClass==="string"){let n=Uo.exec(e.cssClass);if(n)return Number(n[1])}return null}var Xo=["default","base","xs","sm","md","lg","xl","2xl"],On=3;function Zo(e){if(typeof e==="number")return e;if(!M(e))return On;let t=Xo.map((n)=>e[n]).filter((n)=>typeof n==="number");return t.length>0?t[t.length-1]:On}function $n(e,t){let n=b(t.align),r=b(t.justify);if(n!=null)e.style.alignItems=Yo(n);if(r!=null)e.style.justifyContent=Qo(r)}function Yo(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Qo(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var ei={"&":"&","<":"<",">":">",'"':""","'":"'"};function Q(e){return e.replace(/[&<>"']/g,(t)=>ei[t]??t)}function In(){p("Heading",ti),p("H1",(e,t)=>et(e,t,"h1")),p("H2",(e,t)=>et(e,t,"h2")),p("H3",(e,t)=>et(e,t,"h3")),p("H4",(e,t)=>et(e,t,"h4")),p("Text",ni),p("P",ri),p("Lead",(e,t)=>Re(e,t,"p","pf-lead")),p("Large",(e,t)=>Re(e,t,"span","pf-large")),p("Small",(e,t)=>Re(e,t,"small","pf-small")),p("Muted",(e,t)=>Re(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>Re(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>Re(e,t,"label","pf-label")),p("Link",ii),p("Code",si),p("Markdown",ai),p("Kbd",li)}function ti(e,t){let n=O(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 et(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=C(e.content,t),r}function ni(e,t){return At(f("span","pf-text"),C(e.content,t))}function ri(e,t){return At(f("p","pf-p"),C(e.content,t))}function Re(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=C(e.content,t),o}var oi=/^\s*(javascript|vbscript|data):/i;function ii(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(!oi.test(r))n.href=r}if(e.target!=null)n.target=C(e.target,t);return n}function si(e,t){let n=f("pre","pf-code"),r=f("code");if(r.textContent=C(e.content,t),e.language!=null)r.setAttribute("data-language",T(e.language));return n.appendChild(r),n}function ai(e,t){let n=f("div","pf-markdown"),r=C(e.content,t);return n.innerHTML=jn(r),n.setAttribute("data-markdown","true"),n}var Fn=/^\s*(javascript|vbscript|data):/i;function tt(e){let t=Q(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(Fn.test(i))return Q(o);return`<img src="${i}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,i)=>{if(Fn.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 jn(e){let t=e.replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`),n=[],
|
|
4
|
-
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(
|
|
5
|
-
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(
|
|
6
|
-
`)}function Dr(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=C(e.content,t),n}function Tn(){p("Card",Ir),p("CardHeader",xt("pf-card-header")),p("CardTitle",En("pf-card-title","h3")),p("CardDescription",En("pf-card-description","p")),p("CardContent",xt("pf-card-content")),p("CardFooter",xt("pf-card-footer"))}function Ir(e,t){let n=f("div","pf-card");return n.style.overflow="hidden",M(e,n,t),n}function xt(e){return(t,n)=>{let o=f("div",e);return o.style.padding="16px 24px",M(t,o,n),o}}function En(e,t){return(n,o)=>{let r=document.createElement(t);return r.className=e,r.textContent=C(n.content,o),r}}var _=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],X="var(--muted-foreground, #6b7280)",ue="var(--border, #e5e7eb)",ae="10";function Ke(e,t,n,o=!1){let r=n?44:0,i=e-(o?44:0),s=10,a=t-24;return{plotLeft:r,plotRight:i,plotTop:10,plotBottom:a,plotWidth:i-r,plotHeight:a-10}}function Mn(e,t=5){if(e<=0)return[0];let n=e/t,o=Math.pow(10,Math.floor(Math.log10(n))),r=n/o,i=r<=1.5?o:r<=3?2*o:r<=7?5*o:10*o,s=[];for(let a=0;a<=e+i*0.01;a+=i)s.push(Math.round(a*1000)/1000);return s}function Nn(e,t,n,o,r){let i=Mn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=P("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":ae,fill:X});if(l.textContent=wt(s,r),e.appendChild(l),o&&s>0)e.appendChild(P("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function Ln(e,t,n,o){let r=Mn(n);for(let i of r){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=P("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":ae,fill:X});a.textContent=wt(i,o),e.appendChild(a)}}function vt(e,t,n,o,r,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=P("text",{x:o(s),y:r+14,"text-anchor":"middle","font-size":ae,fill:X});l.textContent=a==null?"":i?i(a):v(a),e.appendChild(l)}}function Ge(e,t){e.appendChild(P("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function xe(e,t,n){if(e==null)return"";let o=J(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return v(o??e)}function wt(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 Te(e){let t=y(e.yAxisFormat)??y(e.valueFormat);return t&&t!=="auto"?t:void 0}function ve(e,t,n=String){let o=Te(e);return(r)=>o?xe(r,o,t):n(r)}function kt(e,t,n){return(o,r)=>{if(o===null||o===void 0)return"—";if(r.tooltipFormat)return xe(o,r.tooltipFormat,e);let i=r.yAxisId==="right"?n:t;return wt(Number(o),i)}}function oe(e,t,n){let o=P("svg",{width:"100%",height:t,viewBox:`0 0 ${e} ${t}`,role:"img",...n?{"aria-label":`${n} chart`}:{}});return o.style.overflow="visible",o}function P(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[o,r]of Object.entries(t))n.setAttribute(o,String(r));return n}function Me(e,t){let n=P("text",e);return n.textContent=t,n}function fe(e,t,n,o){let r=o*Math.PI/180;return{x:e+n*Math.cos(r),y:t-n*Math.sin(r)}}function St(e,t,n,o,r){let i=Math.max(2,Math.ceil(Math.abs(r-o)/4)),s=[];for(let a=0;a<=i;a++){let l=fe(e,t,n,o+(r-o)*a/i);s.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return s.join(" ")}function re(e,t,n){if(!n||t.length<=1)return;let o=f("div","pf-chart-legend");o.style.display="flex",o.style.gap="12px",o.style.fontSize="12px",o.style.marginBottom="8px";for(let r=0;r<t.length;r++){let i=f("div","pf-chart-legend-item");i.style.display="flex",i.style.alignItems="center",i.style.gap="4px";let s=f("span");s.style.width="8px",s.style.height="8px",s.style.borderRadius="50%",s.style.backgroundColor=t[r].color??_[r%_.length];let a=f("span");a.textContent=t[r].label??t[r].dataKey,i.appendChild(s),i.appendChild(a),o.appendChild(i)}e.appendChild(o)}function An(){p("DataTable",jr),p("Badge",Fr),p("Dot",Br),p("Metric",Vr),p("Ring",_r),p("Progress",zr),p("Separator",Wr),p("Loader",Jr),p("Icon",Kr),p("Sparkline",Gr)}function jr(e,t){let n=f("div","pf-datatable-wrapper"),o=document.createElement("table");o.className="pf-datatable",o.style.width="100%",o.style.borderCollapse="collapse";let r=K(e.columns).map((d)=>({key:v(d.key),header:d.header!=null?v(d.header):void 0,format:y(d.format),accessor:y(d.accessor)})),i=J(e.rows,t),s=y(e.rowKey),a=y(e.selected),l=document.createElement("thead"),c=document.createElement("tr");for(let d of r){let g=document.createElement("th");g.className="pf-datatable-th",g.textContent=d.header??d.key,g.style.padding="8px 12px",g.style.textAlign="left",c.appendChild(g)}l.appendChild(c),o.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(i)){let d=a!=null?J(a,t):void 0;for(let g of i){let m=document.createElement("tr");m.className="pf-datatable-row";let b=g,h=k(b)?b:{},x=g===null||typeof g!=="object";if(s&&d!=null&&h[s]!=null&&v(h[s])===v(d))m.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)m.style.cursor="pointer",m.addEventListener("click",()=>{let E={...t.scope,$item:b,$index:i.indexOf(g)},w=B({...t,scope:E});D(O(e.onRowClick,w),"onRowClick")});for(let E of r){let w=document.createElement("td");w.className="pf-datatable-td";let R;if(E.accessor)R=J(`{{ $item.${E.accessor} }}`,{...t,scope:{...t.scope,$item:b}});else if(R=x?g:h[E.key],E.format&&R!=null)R=J(`{{ __fmtVal | ${E.format} }}`,{...t,scope:{...t.scope,__fmtVal:R}});w.textContent=v(R),w.style.padding="8px 12px",m.appendChild(w)}u.appendChild(m)}}if(o.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 g=d.value.toLowerCase();for(let m of u.querySelectorAll("tr"))m.style.display=m.textContent.toLowerCase().includes(g)?"":"none"}),n.appendChild(d)}return n.appendChild(o),n}function Fr(e,t){let n=f("span","pf-badge"),o=y(e.variant)??"default";return n.setAttribute("data-variant",o),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),Ur(n,o),n}function Br(e,t){let n=f("span","pf-dot"),o=y(e.color)??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=o,n}function Vr(e,t){let n=f("div","pf-metric"),o=f("div","pf-metric-label");o.textContent=C(e.label,t),o.style.fontSize="14px",n.appendChild(o);let r=f("div","pf-metric-value");if(r.textContent=C(e.value,t),r.style.fontSize="28px",r.style.fontWeight="700",n.appendChild(r),e.delta!=null){let i=f("span","pf-metric-delta");i.textContent=C(e.delta,t);let s=y(e.trend)??"",a=y(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=f("div","pf-metric-desc");i.textContent=C(e.description,t),i.style.fontSize="12px",n.appendChild(i)}return n}function _r(e,t){let n=f("div","pf-ring"),o=F(e.size)??80,r=F(e.thickness)??8,i=Number(J(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(o-r)/2,l=2*Math.PI*a,c=l*(1-s/100),u=P("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`}),d={cx:o/2,cy:o/2,r:a,fill:"none","stroke-width":r},g=P("circle",{...d,stroke:"var(--muted, #e5e7eb)"}),m=P("circle",{...d,stroke:"var(--primary, #3b82f6)","stroke-dasharray":l,"stroke-dashoffset":c,"stroke-linecap":"round"});if(m.style.transform="rotate(-90deg)",m.style.transformOrigin="center",u.appendChild(g),u.appendChild(m),n.appendChild(u),e.label!=null){let b=f("div","pf-ring-label");b.textContent=C(e.label,t),b.style.textAlign="center",b.style.fontSize="12px",n.appendChild(b)}return n}function zr(e,t){let n=f("div","pf-progress");n.setAttribute("role","progressbar");let o=Number(J(e.value,t)??0),r=F(e.max)??100,i=r>0?Math.max(0,Math.min(100,o/r*100)):0;n.setAttribute("aria-valuenow",String(o)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(r)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let s=f("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 Wr(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Jr(e,t){let n=f("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function Kr(e,t){let n=f("span","pf-icon");return n.setAttribute("data-icon",C(e.name??e.content,t)),n}function Gr(e,t){let n=f("div","pf-sparkline"),o=Array.isArray(e.data)?e.data.filter((g)=>typeof g==="number"&&Number.isFinite(g)):[];if(o.length===0)return n;let r=F(e.width)??120,i=F(e.height)??32,s=Math.max(...o),a=Math.min(...o),l=s-a||1,c=P("svg",{width:r,height:i,viewBox:`0 0 ${r} ${i}`}),u=o.length>1?o.length-1:1,d=o.map((g,m)=>{let b=m/u*r,h=i-(g-a)/l*(i-4)-2;return`${b},${h}`}).join(" ");return c.appendChild(P("polyline",{points:d,fill:"none",stroke:"var(--primary, #3b82f6)","stroke-width":1.5})),n.appendChild(c),n}function Ur(e,t){let o={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(o)e.style.backgroundColor=o.bg,e.style.color=o.fg}function Pn(){p("Form",qr),p("Input",Xr),p("Textarea",we(Yr)),p("Button",Zr),p("ButtonGroup",Qr),p("Checkbox",ei),p("Switch",ti),p("Slider",we(ni)),p("Calendar",ri),p("DatePicker",we(ii)),p("Field",Ne("pf-field")),p("FieldTitle",ke("pf-field-title")),p("FieldDescription",ke("pf-field-description")),p("FieldContent",Ne("pf-field-content")),p("FieldError",ke("pf-field-error"))}function qr(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(o)=>{o.preventDefault();let r=new FormData(n),i={};for(let s of new Set(r.keys())){let a=r.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=B(t);s.scope={...t.scope,...i},D(O(e.onSubmit,s),"onSubmit")}}),M(e,n,t),n}function Hn(e,t,n){if(t.label==null)return;let o=document.createElement("label");if(o.className="pf-input-label",o.textContent=C(t.label,n),t.name!=null)o.htmlFor=v(t.name);o.style.fontSize="14px",o.style.fontWeight="500",e.insertBefore(o,e.firstChild)}function we(e){return(t,n)=>{let o=e(t,n);return o.style.display="flex",o.style.flexDirection="column",o.style.gap="4px",Hn(o,t,n),o}}function le(e,t){if(t.required!==!0)return;if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)e.required=!0;e.setAttribute("aria-required","true")}function Xr(e,t){let n=f("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",Hn(n,e,t);let o=document.createElement("input");if(o.className="pf-input",o.type=y(e.inputType)??"text",e.name!=null)o.name=v(e.name);if(e.name!=null)o.id=`pf-input-${v(e.name)}`;if(e.placeholder!=null)o.placeholder=C(e.placeholder,t);if(le(o,e),e.error!=null)o.setAttribute("aria-invalid","true");let r=y(e.name);if(r){let i=t.store.get(r);if(i!=null)o.value=v(i);o.addEventListener("input",()=>{if(t.store.set(r,o.value),e.onChange!=null)D(O(e.onChange,{...B(t),scope:{...t.scope,$event:o.value}}),"onChange")})}return Ue(o),n.appendChild(o),n}function Yr(e,t){let n=f("div","pf-textarea-wrapper"),o=document.createElement("textarea");if(o.className="pf-textarea",e.name!=null)o.name=v(e.name);if(e.name!=null)o.id=`pf-textarea-${v(e.name)}`;if(e.placeholder!=null)o.placeholder=C(e.placeholder,t);if(e.rows!=null)o.rows=Number(e.rows);le(o,e);let r=y(e.name);if(r!=null){let i=t.store.get(r);if(i!=null)o.value=v(i);o.addEventListener("input",()=>{if(t.store.set(r,o.value),e.onChange!=null)D(O(e.onChange,{...B(t),scope:{...t.scope,$event:o.value}}),"onChange")})}return Ue(o),n.appendChild(o),n}function Zr(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 o=y(e.variant)??"default";if(n.setAttribute("data-variant",o),oi(n,o),e.size!=null)n.setAttribute("data-size",v(e.size));if(e.disabled===!0)n.disabled=!0;return n}function Qr(e,t){let n=f("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",M(e,n,t),n}function ei(e,t){let n=f("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let o=document.createElement("input");if(o.type="checkbox",o.className="pf-checkbox",e.name!=null)o.name=v(e.name);if(e.checked===!0)o.checked=!0;let r=y(e.name);if(r){let i=t.store.get(r);if(typeof i==="boolean")o.checked=i;o.addEventListener("change",()=>{if(t.store.set(r,o.checked),e.onChange!=null)D(O(e.onChange,{...B(t),scope:{...t.scope,$event:o.checked}}),"onChange")})}if(n.appendChild(o),e.label!=null){let i=f("span");i.textContent=C(e.label,t),n.appendChild(i)}return n}function ti(e,t){let n=f("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let o=document.createElement("input");if(o.type="checkbox",o.className="pf-switch",o.setAttribute("role","switch"),e.name!=null)o.name=v(e.name);let r=y(e.name);if(r){let i=t.store.get(r);if(typeof i==="boolean")o.checked=i;o.addEventListener("change",()=>{if(t.store.set(r,o.checked),e.onChange!=null)D(O(e.onChange,{...B(t),scope:{...t.scope,$event:o.checked}}),"onChange")})}if(n.appendChild(o),e.label!=null){let i=f("span");i.textContent=C(e.label,t),n.appendChild(i)}return n}function ni(e,t){let n=f("div","pf-slider-wrapper"),o=document.createElement("input");if(o.type="range",o.className="pf-slider",e.name!=null)o.name=v(e.name);if(e.min!=null)o.min=v(e.min);if(e.max!=null)o.max=v(e.max);if(e.step!=null)o.step=v(e.step);let r=y(e.name);if(r){let i=t.store.get(r);if(i!=null)o.value=v(i);o.addEventListener("input",()=>{if(t.store.set(r,Number(o.value)),e.onChange!=null)D(O(e.onChange,{...B(t),scope:{...t.scope,$event:Number(o.value)}}),"onChange")})}return n.appendChild(o),n}function Ue(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function oi(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 Ne(e){return(t,n)=>{let o=f("div",e);return M(t,o,n),o}}function ke(e){return(t,n)=>{let o=f("span",e);return o.textContent=C(t.content,n),o}}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=f("div","pf-calendar"),o=document.createElement("input");if(o.type="date",o.name=C(e.name,t),le(o,e),e.value!==void 0)o.value=C(e.value,t);let r=o.name,i=t.store.get(r);if(i!=null)o.value=v(i);if(e.minDate!=null)o.min=C(e.minDate,t);if(e.maxDate!=null)o.max=C(e.maxDate,t);return o.style.padding="6px 12px",o.style.borderRadius="6px",o.addEventListener("change",()=>{if(t.store.set(o.name,o.value),e.onChange!=null)D(O(e.onChange,B(t)),"onChange")}),n.appendChild(o),n}function ii(e,t){let n=f("div","pf-datepicker"),o=document.createElement("input");if(o.type="date",o.name=C(e.name,t),le(o,e),e.placeholder!=null)o.placeholder=C(e.placeholder,t);if(e.value!==void 0)o.value=C(e.value,t);let r=o.name,i=t.store.get(r);if(i!=null)o.value=v(i);if(e.minDate!=null)o.min=C(e.minDate,t);if(e.maxDate!=null)o.max=C(e.maxDate,t);return o.style.padding="6px 12px",o.style.borderRadius="6px",o.style.width="100%",o.style.boxSizing="border-box",o.addEventListener("change",()=>{if(t.store.set(o.name,o.value),e.onChange!=null)D(O(e.onChange,B(t)),"onChange")}),n.appendChild(o),n}function On(){p("Select",we(si)),p("SelectOption",ci),p("SelectGroup",Ne("pf-select-group")),p("SelectLabel",ke("pf-select-label")),p("SelectSeparator",Rt),p("Radio",di),p("RadioGroup",pi),p("Combobox",we(ui)),p("ComboboxOption",fi),p("ComboboxGroup",Ne("pf-combobox-group")),p("ComboboxLabel",ke("pf-combobox-label")),p("ComboboxSeparator",Rt),p("ChoiceCard",mi)}function si(e,t){let n=f("div","pf-select-wrapper"),o=document.createElement("select");if(o.className="pf-select",e.name!=null)o.name=v(e.name);if(e.multiple===!0)o.multiple=!0;if(le(o,e),Ue(o),e.placeholder!=null){let i=document.createElement("option");i.value="",i.textContent=C(e.placeholder,t),i.disabled=!0,i.selected=!0,i.hidden=!0,o.appendChild(i)}for(let i of K(e.options)){let s=document.createElement("option");s.value=v(i.value),s.textContent=i.label!=null?v(i.label):s.value,o.appendChild(s)}if(e.children)for(let i of e.children)if(i.type==="SelectOption"){let s=document.createElement("option");s.value=y(i.value)??"",s.textContent=y(i.label)??s.value,o.appendChild(s)}else o.appendChild(V(i,t));let r=y(e.name);if(r){let i=t.store.get(r);if(i!=null)li(o,i);o.addEventListener("change",()=>{let s=ai(o);if(t.store.set(r,s),e.onChange!=null)D(O(e.onChange,{...B(t),scope:{...t.scope,$event:s}}),"onChange")})}return n.appendChild(o),n}function ai(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function li(e,t){if(!e.multiple){e.value=v(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((o)=>v(o)));for(let o of e.options)o.selected=n.has(o.value)}function ci(e,t){return f("span")}function di(e,t){let n=f("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let o=document.createElement("input");if(o.type="radio",o.value=C(e.value,t),n.appendChild(o),e.label!=null){let r=f("span","pf-radio-label");r.textContent=C(e.label,t),n.appendChild(r)}return n}function pi(e,t){let n=f("fieldset","pf-radio-group");if(le(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 o=C(e.name,t),r=t.store.get(o);for(let i of n.querySelectorAll('input[type="radio"]')){if(!(i instanceof HTMLInputElement))continue;if(i.name=o,r!=null&&i.value===v(r))i.checked=!0}return n.addEventListener("change",(i)=>{let s=i.target;if(s instanceof HTMLInputElement&&s.type==="radio"){if(t.store.set(o,s.value),e.onChange!=null)D(O(e.onChange,B(t)),"onChange")}}),n}function ui(e,t){let n=f("div","pf-combobox"),o=document.createElement("input");if(o.className="pf-combobox-input",o.type="text",o.name=C(e.name,t),le(o,e),e.placeholder!=null)o.placeholder=C(e.placeholder,t);if(e.value!==void 0)o.value=C(e.value,t);let r=o.name,i=t.store.get(r);if(i!=null)o.value=v(i);o.style.padding="6px 12px",o.style.borderRadius="6px",o.style.width="100%",o.style.boxSizing="border-box";let s=f("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),o.addEventListener("focus",()=>{s.style.display="block"}),o.addEventListener("blur",()=>{setTimeout(()=>{s.style.display="none"},150)}),e.searchable!==!1)o.addEventListener("input",()=>{let a=o.value.toLowerCase();for(let l of s.querySelectorAll(".pf-combobox-option"))if(l instanceof HTMLElement)l.style.display=l.textContent.toLowerCase().includes(a)?"":"none"});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{D(O(e.onChange,{...B(t),scope:{...t.scope,$event:o.value}}),"onChange")});return n.style.position="relative",n.appendChild(o),n.appendChild(s),n}function fi(e,t){let n=f("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 o=n.closest(".pf-combobox"),r=o?.querySelector("input");if(r)r.value=n.dataset.value??"",t.store.set(r.name,r.value),o?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function mi(e,t){let n=f("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 o=f("div","pf-choice-card-label");o.textContent=C(e.label,t),o.style.fontWeight="600",n.appendChild(o)}if(e.description!=null){let o=f("div","pf-choice-card-description");o.textContent=C(e.description,t),o.style.fontSize="14px",n.appendChild(o)}return M(e,n,t),n}function Et(e,t){if(!be(e))return;let n=V(e,t);if(n instanceof HTMLElement)return n;let o=f("span","pf-trigger");return o.style.display="contents",o.appendChild(n),o}function $n(){p("Tabs",gi),p("Tab",hi),p("Accordion",yi),p("AccordionItem",bi),p("Dialog",Ci),p("Popover",xi),p("Tooltip",vi),p("HoverCard",wi),p("Carousel",ki)}function gi(e,t){let n=f("div","pf-tabs"),o=f("div","pf-tabs-bar");o.setAttribute("role","tablist"),o.style.display="flex",o.style.gap="4px",o.style.marginBottom="12px";let r=[],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)}`,g=`pf-panel-${Math.random().toString(36).slice(2,8)}`,m=document.createElement("button");m.type="button",m.className="pf-tab-trigger",m.textContent=y(u.title)??`Tab ${String(c+1)}`,m.setAttribute("role","tab"),m.setAttribute("aria-selected",c===a?"true":"false"),m.setAttribute("aria-controls",g),m.id=d,m.tabIndex=c===a?0:-1,m.style.padding="8px 16px",m.style.border="none",m.style.background="none",m.style.cursor="pointer",m.style.borderBottom="2px solid transparent",m.style.marginBottom="-2px",m.style.fontSize="14px";let b=f("div","pf-tab-panel");if(b.style.display=c===a?"block":"none",b.setAttribute("role","tabpanel"),b.setAttribute("aria-labelledby",d),b.id=g,b.tabIndex=0,M(u,b,t),m.addEventListener("click",()=>{l(c)}),c===a)m.classList.add("pf-tab-active"),m.style.fontWeight="600";i.push(m),r.push(b),o.appendChild(m)}function l(c){r.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}),r[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()}o.addEventListener("keydown",(c)=>{let u=i.findIndex((g)=>g===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(o);for(let c of r)n.appendChild(c);return n}function hi(e,t){let n=f("div","pf-tab");return M(e,n,t),n}function yi(e,t){let n=f("div","pf-accordion");return M(e,n,t),n}function bi(e,t){let n=f("div","pf-accordion-item"),o=`pf-acc-${Math.random().toString(36).slice(2,8)}`,r=document.createElement("button");r.type="button",r.className="pf-accordion-trigger",r.textContent=y(e.title)??"",r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",o),r.style.width="100%",r.style.textAlign="left",r.style.padding="12px 0",r.style.border="none",r.style.background="none",r.style.cursor="pointer",r.style.fontSize="14px",r.style.fontWeight="500";let i=f("div","pf-accordion-content");return i.id=o,i.setAttribute("role","region"),i.setAttribute("aria-labelledby",r.id),i.style.display="none",i.style.paddingBottom="12px",M(e,i,t),r.addEventListener("click",()=>{let s=i.style.display!=="none";i.style.display=s?"none":"block",r.setAttribute("aria-expanded",s?"false":"true")}),n.appendChild(r),n.appendChild(i),n}function Ci(e,t){let n=f("div","pf-dialog-wrapper"),o=Et(e.trigger,t);if(o)o.addEventListener("click",()=>{r.showModal()}),n.appendChild(o);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 s=f("h2","pf-dialog-title");s.textContent=C(e.title,t),s.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",s.id),r.appendChild(s)}if(e.description!=null){let s=f("p","pf-dialog-desc");s.textContent=C(e.description,t),r.appendChild(s)}let i=f("div","pf-dialog-body");if(M(e,i,t),r.appendChild(i),e.dismissible!==!1)r.addEventListener("click",(s)=>{if(s.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function xi(e,t){let n=f("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let o=f("div","pf-popover-content");if(o.style.display="none",o.style.position="absolute",o.style.zIndex="50",o.style.padding="12px",o.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let s=f("div","pf-popover-title");s.textContent=C(e.title,t),s.style.fontWeight="600",s.style.marginBottom="4px",o.appendChild(s)}M(e,o,t);let r=()=>{o.style.display=o.style.display==="none"?"block":"none"},i=Et(e.trigger,t);if(i)i.addEventListener("click",(s)=>{s.stopPropagation(),r()}),n.appendChild(i);else n.addEventListener("click",(s)=>{if(s.target instanceof Node&&o.contains(s.target)&&o.style.display!=="none")return;r()});return n.appendChild(o),n}function vi(e,t){let n=f("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let o=`pf-tip-${Math.random().toString(36).slice(2,8)}`,r=f("div","pf-tooltip-content");return r.id=o,r.setAttribute("role","tooltip"),r.textContent=C(e.content??"",t),r.style.display="none",r.style.position="absolute",r.style.bottom="100%",r.style.left="50%",r.style.transform="translateX(-50%)",r.style.padding="4px 8px",r.style.borderRadius="4px",r.style.color="#fff",r.style.fontSize="12px",r.style.whiteSpace="nowrap",r.style.zIndex="50",M(e,n,t),n.setAttribute("aria-describedby",o),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.addEventListener("focus",()=>{r.style.display="block"},!0),n.addEventListener("blur",()=>{r.style.display="none"},!0),n.appendChild(r),n}function wi(e,t){let n=f("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let o=f("div","pf-hover-card-content");o.style.display="none",o.style.position="absolute",o.style.zIndex="50",o.style.padding="16px",o.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",o.style.minWidth="200px";let r=Et(e.trigger,t);if(r)n.appendChild(r);return M(e,o,t),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.appendChild(o),n}function ki(e,t){let n=f("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 o=f("div","pf-carousel-track");o.style.display="flex",o.style.transition="transform 0.3s ease",M(e,o,t);let r=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=()=>{o.style.transform=`translateX(-${r*100}%)`};return s.addEventListener("click",()=>{if(i===0)return;r=Math.max(0,r-1),l()}),a.addEventListener("click",()=>{if(i===0)return;r=Math.min(i-1,r+1),l()}),n.appendChild(o),n.appendChild(s),n.appendChild(a),n}function Si(e){if(!k(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,de(n)]))}function Dn(){p("ForEach",Ri),p("If",In),p("Elif",Ei),p("Else",Ti),p("Condition",Mi),p("Define",Ni),p("Use",Li),p("Slot",Ai)}function Ri(e,t){let n=document.createDocumentFragment(),o=y(e.expression);if(!o)return n;let r;if(U(o)){let s=q(o,t.store,t.scope);r=Array.isArray(s)?s:[]}else{let s=t.store.get(o);r=Array.isArray(s)?s:[]}let i=H(e.let)??{};for(let s=0;s<r.length;s++){let a=r[s],l={...t.scope,$item:a,$index:s,...i},c={...t,scope:l};if(e.children)pe(e.children,n,c)}return n}function In(e,t){if(jn(y(e.condition)??"",t)){let o=document.createDocumentFragment();if(e.children)pe(e.children,o,t);return o}return document.createDocumentFragment()}function Ei(e,t){return In(e,t)}function Ti(e,t){let n=document.createDocumentFragment();if(e.children)pe(e.children,n,t);return n}function jn(e,t){if(!e)return!1;if(U(e))return Boolean(q(e,t.store,t.scope));return Boolean(t.store.get(e))}function Mi(e,t){let n=document.createDocumentFragment(),o=K(e.cases).find((r)=>jn(y(r.when)??"",t));return pe(de(o?o.children:e.else),n,t),n}function Ni(e,t){let n=y(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Li(e,t){let n=document.createDocumentFragment(),o=y(e.def??e.name),r=o!=null?t.templates?.[o]:void 0;if(!r)return n;let i=H(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...Si(e.slots)};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let c of r)n.appendChild(V(c,l));return n}function Ai(e,t){let n=document.createDocumentFragment(),o=y(e.name)??"default",i=t.slots?.[o]??e.children;if(i)for(let s of i)n.appendChild(V(s,t));return n}function Fn(){p("Alert",Pi),p("AlertTitle",Hi),p("AlertDescription",Oi)}function Pi(e,t){let n=f("div","pf-alert");n.setAttribute("role","alert");let o=y(e.variant)??"default";if(n.setAttribute("data-variant",o),n.style.padding="12px 16px",e.icon!=null){let r=f("span","pf-alert-icon");r.setAttribute("data-icon",v(e.icon)),r.style.marginRight="8px",n.appendChild(r)}return M(e,n,t),n}function Hi(e,t){let n=f("h5","pf-alert-title");return n.textContent=C(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function Oi(e,t){let n=f("p","pf-alert-description");return n.textContent=C(e.content,t),n.style.fontSize="14px",n}function Bn(){p("Image",$i),p("Audio",Di),p("Video",Ii),p("Embed",ji),p("Svg",Bi),p("DropZone",_i),p("Mermaid",zi)}function $i(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=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Di(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=C(e.src,t),n.controls=!0,n}function Ii(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=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function ji(e,t){let n=f("div","pf-embed"),o=document.createElement("iframe");return o.src=C(e.src,t),o.style.width="100%",o.style.height=e.height!=null?`${String(Number(e.height))}px`:"400px",o.style.border="none",o.setAttribute("sandbox","allow-scripts"),n.appendChild(o),n}var Fi=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 Bi(e,t){let n=f("div","pf-svg"),o=C(e.content,t);if(!o.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(o))o=o.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let i=new DOMParser().parseFromString(o,"image/svg+xml").querySelector("svg");if(!i)return n;return Vn(i),n.appendChild(document.importNode(i,!0)),n}function Vn(e){let t=Array.from(e.children);for(let n of t){if(!Fi.has(n.tagName.toLowerCase())){n.remove();continue}for(let o of Array.from(n.attributes)){let r=o.name.toLowerCase();if(r.startsWith("on")||r==="href"&&o.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(o.name)}Vn(n)}}function Vi(e,t){let n=(t??"").split(",").map((i)=>i.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let o=e.name.toLowerCase(),r=e.type.toLowerCase();return n.some((i)=>{if(i.startsWith("."))return o.endsWith(i);if(i.endsWith("/*"))return r.startsWith(i.slice(0,-1));return r===i})}function _i(e,t){let n=f("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 o=document.createElement("input");if(o.type="file",o.style.display="none",e.accept!=null)o.accept=v(e.accept);if(e.multiple===!0)o.multiple=!0;n.appendChild(o),n.setAttribute("role","button"),n.tabIndex=0;function r(s){let a=Array.from(s??[]).filter((l)=>Vi(l,y(e.accept)));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;let a=y(e.resultKey);if(a!=null)t.store.set(a,s),t.rerender();if(e.onDrop!=null)D(O(e.onDrop,{...B(t),scope:{...t.scope,$result:s}}),"onDrop")}return o.addEventListener("change",()=>{i(r(o.files)),o.value=""}),n.addEventListener("click",()=>o.click()),n.addEventListener("keydown",(s)=>{if(s.key==="Enter"||s.key===" ")s.preventDefault(),o.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(r(s.dataTransfer?.files??null))}),n}function zi(e,t){let n=f("div","pf-mermaid");n.setAttribute("data-mermaid","true");let o=C(e.content,t);if(n.textContent=o,"mermaid"in globalThis)n.classList.add("mermaid"),n.textContent=o;return n}var Wi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Ji="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",Tt=null,qe=null;function Ki(e){return k(e)&&typeof e.getDocument==="function"&&k(e.GlobalWorkerOptions)}function Mt(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function Gi(e){return e==="fit-page"||e==="fit-width"?e:Mt(e,0)||"fit-width"}async function Ui(){if(Tt)return Tt;if(qe)return qe;return qe=import(Wi).then((e)=>{if(!Ki(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=Ji,Tt=t,t}),qe}function zn(){p("PdfViewer",qi)}function qi(e,t){let n=f("div","pf-pdf-viewer"),o=e.src!=null?C(e.src,t):void 0,r=y(e.data),i=Mt(e.page,1),s=Gi(e.zoom),a=e.toolbar!==!1,l=Mt(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=f("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),Xi(n,c,{src:o,data:r,initialPage:i,zoom:s,showToolbar:a}),n}async function Xi(e,t,n){try{let o=await Ui(),r;if(n.src)r={url:n.src};else if(n.data){let g=atob(n.data),m=new Uint8Array(g.length);for(let b=0;b<g.length;b++)m[b]=g.charCodeAt(b);r={data:m}}else{t.textContent="Error: No PDF source provided";return}let i=await o.getDocument(r).promise;t.remove();let s=Math.max(1,Math.min(n.initialPage,i.numPages)),a=null,l=null;if(n.showToolbar){let g=Yi(i.numPages,s,{onPrev:()=>{if(s>1)s--,d()},onNext:()=>{if(s<i.numPages)s++,d()},onPageChange:(m)=>{let b=Math.max(1,Math.min(m,i.numPages));if(b!==s)s=b,d()}});a=g.pageInput,l=g.pageCount,e.insertBefore(g.el,e.firstChild)}let c=f("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 g=await i.getPage(s),m=c.clientWidth-16,b,h=g.getViewport({scale:1});if(n.zoom==="fit-width")b=m/h.width;else if(n.zoom==="fit-page"){let w=c.clientHeight-16,R=m/h.width,S=w/h.height;b=Math.min(R,S)}else b=typeof n.zoom==="number"?n.zoom:1;let x=g.getViewport({scale:b});u.width=x.width,u.height=x.height,u.style.width=`${x.width}px`,u.style.height=`${x.height}px`;let E=u.getContext("2d");if(!E)return;if(await g.render({canvasContext:E,viewport:x}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await d()}catch(o){t.textContent=`PDF Error: ${o instanceof Error?o.message:String(o)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function Yi(e,t,n){let o=f("div","pf-pdf-toolbar");o.style.display="flex",o.style.alignItems="center",o.style.gap="8px",o.style.padding="6px 12px",o.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",o.style.background="var(--color-background-primary, #fff)",o.style.flexShrink="0",o.style.fontSize="13px";let r=document.createElement("button");r.textContent="‹",r.title="Previous page",r.className="pf-pdf-btn",_n(r),r.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)",o.appendChild(r),o.appendChild(s),o.appendChild(a),o.appendChild(i),{el:o,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"}function ie(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 Wn(e,t,n,o,r){let{tooltip:i,svgEl:s,wrapper:a}=e;if(r.length===0)return;let l="";if(o)l+=`<div class="pf-chart-tooltip-label">${te(o)}</div>`;for(let x of r)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${te(x.color)}"></span>`,l+=`<span>${te(x.label)}:</span> <strong>${te(String(x.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),u=a.getBoundingClientRect(),d=s.viewBox.baseVal,g=c.width/(d.width||1),m=c.left-u.left+t*g,b=i.offsetWidth||100,h=m+12;if(h+b>u.width)h=m-b-12;i.style.left=`${Math.max(0,h)}px`,i.style.top="4px",i.classList.add("pf-visible")}function Jn(e){e.tooltip.classList.remove("pf-visible")}function Kn(e,t,n){e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",n),e.addEventListener("touchstart",t,{passive:!0}),e.addEventListener("touchend",n,{passive:!0})}function me(e,t,n,o,r,i){Kn(e,()=>{Wn(t,n,o,r,i)},()=>{Jn(t)})}function Gn(e,t){let{data:n,series:o,xAxisKey:r,formatValue:i,formatLabel:s}=e,a=r?n[t][r]:void 0,l=a!=null?s?s(a):v(a):void 0,c=o.map((u,d)=>({label:u.label??u.dataKey,value:i(n[t][u.dataKey],u,d),color:u.color??_[d%_.length]}));return{label:l,entries:c}}function Un(e,t,n){let o=P("rect",{x:e,y:n.plotTop,width:t,height:n.plotHeight,fill:"transparent"});return o.style.cursor="default",o}function qn(e,t,n,o,r,i,s,a){let l={data:n,series:o,xAxisKey:i,formatValue:s,formatLabel:a},c=r.plotWidth/n.length;for(let u=0;u<n.length;u++){let d=r.plotLeft+u*c,g=Un(d,c,r),{label:m,entries:b}=Gn(l,u);me(g,e,d+c/2,r.plotTop,m,b),t.appendChild(g)}}function Xn(e,t,n,o,r,i,s,a,l,c){let u={data:n,series:o,xAxisKey:i,formatValue:s,formatLabel:c},d=n.length===1?r.plotWidth:r.plotWidth/(n.length-1);for(let g=0;g<n.length;g++){let m=n.length===1?(r.plotLeft+r.plotRight)/2:r.plotLeft+g/(n.length-1)*r.plotWidth,b=Math.max(r.plotLeft,n.length===1?r.plotLeft:m-d/2),h=Un(b,Math.min(d,r.plotRight-b),r),{label:x,entries:E}=Gn(u,g);Kn(h,()=>{if(Wn(e,m,r.plotTop,x,E),a)a.setAttribute("x1",String(m)),a.setAttribute("x2",String(m)),a.setAttribute("opacity","1");if(l)for(let S of l){for(let T of S)T.setAttribute("data-visible","false");S[g]?.setAttribute("data-visible","true")}},()=>{if(Jn(e),a)a.setAttribute("opacity","0");if(l)for(let S of l)for(let T of S)T.setAttribute("data-visible","false")}),t.appendChild(h)}}function ge(e,t){return K(J(e.data,t))}function Yn(e,t){let n=J(e.data,t);if(!Array.isArray(n))return;let o=n.filter((r)=>typeof r==="number"&&Number.isFinite(r));return o.length>0?o:void 0}function Zi(e){return e==="left"||e==="right"?e:void 0}function Qi(e){if(!k(e)||typeof e.dataKey!=="string")return;let t=y(e.label),n=y(e.color),o=Zi(e.yAxisId),r=y(e.tooltipFormat);return{dataKey:e.dataKey,...t!==void 0&&{label:t},...n!==void 0&&{color:n},...o!==void 0&&{yAxisId:o},...r!==void 0&&{tooltipFormat:r}}}function he(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=Qi(t);return n?[n]:[]})}function ce(e,t){return F(e.height)??t}function Le(e,t){return Math.max(...e.flatMap((n)=>t.map((o)=>Number(n[o.dataKey]??0))),1)}function Nt(e,t){return{valueKey:y(e.dataKey)??t[0]?.dataKey,nameKey:y(e.nameKey)??y(e.tooltipXKey)??y(e.xAxis)}}function Lt(e,t){return{rows:ge(e,t),series:he(e),height:ce(e,300),showYAxis:e.showYAxis!==!1,showGrid:e.showGrid===!0,showYAxisRight:e.showYAxisRight===!0,showTooltip:e.showTooltip!==!1,showLegend:e.showLegend!==!1,xAxisKey:y(e.xAxis),tooltipXKey:y(e.tooltipXKey),xAxisFormat:y(e.xAxisFormat),tooltipXFormat:y(e.tooltipXFormat),yAxisRightFormat:y(e.yAxisRightFormat)}}function Zn(e,t,n){let o=t.series.filter((d)=>d.yAxisId!=="right"),r=t.series.filter((d)=>d.yAxisId==="right"),i=t.showYAxisRight&&r.length>0,s=o.length>0?Le(t.rows,o):1,a=i?Le(t.rows,r):1,l=400,c=Ke(400,t.height,t.showYAxis,i),u=oe(400,t.height,n);if(t.showYAxis)Nn(u,c,s,t.showGrid,Te(e));if(i)Ln(u,c,a,t.yAxisRightFormat);return Ge(u,c),{layout:c,svg:u,leftMax:s,rightMax:a}}function Xe(e,t){return e?(n)=>xe(n,e,t):void 0}function Qn(e,t){let n=f("div","pf-chart pf-bar-chart"),o=Lt(e,t),{rows:r,series:i}=o;if(r.length===0||i.length===0)return n.textContent="No chart data",n;let{layout:s,svg:a,leftMax:l,rightMax:c}=Zn(e,o,"Bar"),u=s.plotWidth/r.length,d=u/(i.length+1);for(let g=0;g<r.length;g++)for(let m=0;m<i.length;m++){let b=i[m],h=r[g][b.dataKey];if(h===null||h===void 0)continue;let x=b.yAxisId==="right"?c:l,E=Math.max(0,Number(h)/x*s.plotHeight),w=s.plotLeft+g*u+m*d+d/2;a.appendChild(P("rect",{x:w,y:s.plotBottom-E,width:d*0.8,height:E,fill:b.color??_[m%_.length],rx:2}))}if(o.xAxisKey)vt(a,r,o.xAxisKey,(g)=>s.plotLeft+g*u+u/2,s.plotBottom,Xe(o.xAxisFormat,t));if(o.showTooltip){let g=ie(n,a),m=kt(t,Te(e),o.yAxisRightFormat);qn(g,a,r,i,s,o.tooltipXKey??o.xAxisKey,m,Xe(o.tooltipXFormat,t))}return re(n,i,o.showLegend),n.appendChild(a),n}function es(e,t,n,o){let r=[],i=()=>{if(r.length<2){r=[];return}let s=`M ${r[0].x},${n} `+r.map((a)=>`L ${a.x},${a.y}`).join(" ")+` L ${r[r.length-1].x},${n} Z`;e.appendChild(P("path",{d:s,fill:o,opacity:0.15})),r=[]};for(let s of t){if(s.isNull){i();continue}r.push(s)}i()}function ts(e,t,n,o){let r="";for(let i of t){if(i.isNull)continue;let s=t.indexOf(i),a=s===0||t[s-1].isNull;r+=`${a?"M":"L"} ${i.x},${i.y} `}if(!r)return;e.appendChild(P("path",{d:r.trim(),fill:"none",stroke:n,"stroke-width":2,...o?{"stroke-dasharray":"6 3"}:{}}))}function ns(e,t,n){let o=[];for(let r of t){let i=P("circle",{cx:r.x,cy:r.y,r:4,fill:n,class:"pf-data-dot","data-visible":"false"});if(i.style.pointerEvents="none",r.isNull)i.style.display="none";e.appendChild(i),o.push(i)}return o}function os(e,t){let n=P("line",{class:"pf-crosshair",x1:t.plotLeft,x2:t.plotLeft,y1:t.plotTop,y2:t.plotBottom,stroke:X,"stroke-width":1,"stroke-dasharray":"3 3",opacity:0});return e.appendChild(n),n}function At(e,t){let n=f("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),o=Lt(e,t),{rows:r,series:i}=o;if(r.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}=Zn(e,o,s?"Area":"Line"),d=(b)=>r.length===1?(a.plotLeft+a.plotRight)/2:a.plotLeft+b/(r.length-1)*a.plotWidth,g=[];for(let b=0;b<i.length;b++){let h=i[b],x=h.yAxisId==="right",E=x?u:c,w=h.color??_[b%_.length],R=r.map((S,T)=>{let L=S[h.dataKey],I=L===null||L===void 0,j=I?a.plotBottom:a.plotBottom-Number(L)/E*a.plotHeight;return{x:d(T),y:j,isNull:I}});if(s)es(l,R,a.plotBottom,w);ts(l,R,w,x),g.push(ns(l,R,w))}let m=os(l,a);if(o.xAxisKey)vt(l,r,o.xAxisKey,d,a.plotBottom,Xe(o.xAxisFormat,t));if(o.showTooltip){let b=ie(n,l),h=kt(t,Te(e),o.yAxisRightFormat);Xn(b,l,r,i,a,o.tooltipXKey??o.xAxisKey,h,m,g,Xe(o.tooltipXFormat,t))}return re(n,i,o.showLegend),n.appendChild(l),n}function eo(e,t){let n=f("div","pf-chart pf-pie-chart"),o=ge(e,t),r=he(e),i=Math.min(ce(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=Nt(e,r),c=r.length>0?r:a?[{dataKey:a,label:a}]:[];if(o.length===0||!a)return n.textContent="No chart data",n;let u=oe(i,i,"Pie"),d=i/2,g=i/2,m=i/2-10,b=y(e.tooltipXFormat),h=ve(e,t),x=o.map((S)=>Number(S[a]??0)),E=x.reduce((S,T)=>S+T,0);if(E===0)return n.textContent="No chart data",n.appendChild(u),n;let w=s?ie(n,u):void 0,R=-Math.PI/2;for(let S=0;S<x.length;S++){let T=x[S]/E*2*Math.PI,L=R+T,I=T>Math.PI?1:0,j=d+m*Math.cos(R),W=g+m*Math.sin(R),Y=d+m*Math.cos(L),Z=g+m*Math.sin(L),Q=_[S%_.length],A=P("path",{d:`M ${d},${g} L ${j},${W} A ${m},${m} 0 ${I} 1 ${Y},${Z} Z`,fill:Q});if(A.style.cursor="default",w){let ne=l?o[S][l]:void 0,se=ne!=null?b?xe(ne,b,t):v(ne):`Slice ${S+1}`,rt=`${(x[S]/E*100).toFixed(1)}%`,Pe=d+m*0.6*Math.cos(R+T/2);me(A,w,Pe,g,se,[{label:c[0].label??a,value:`${h(x[S])} (${rt})`,color:Q}])}u.appendChild(A),R=L}return re(n,c,e.showLegend!==!1),n.appendChild(u),n}function to(e,t){let n=f("div","pf-chart pf-radial-chart"),o=ge(e,t),r=he(e),{valueKey:i,nameKey:s}=Nt(e,r);if(o.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(ce(e,300),300),l=a/2,c=a/2,u=a/2-10,d=Math.max(0,Math.min(F(e.innerRadius)??30,u-10)),g=F(e.startAngle)??180,m=F(e.endAngle)??0,b=o.map((L)=>Number(L[i]??0)),h=Math.max(...b,1),x=oe(a,a,"Radial"),E=(u-d)/o.length,w=Math.max(2,E*0.7),R=ve(e,t),S=e.showTooltip!==!1?ie(n,x):void 0,T=[];for(let L=0;L<o.length;L++){let I=u-E*L-E/2,j=r[L]?.color??_[L%_.length],W=g+b[L]/h*(m-g),Y=s?o[L][s]:null,Z=Y!=null?v(Y):r[L]?.label??i;T.push({dataKey:Z||i,label:Z||i,color:j}),x.appendChild(P("path",{d:St(l,c,I,g,m),fill:"none",stroke:ue,"stroke-width":w,"stroke-linecap":"round"}));let Q=P("path",{d:St(l,c,I,g,W),fill:"none",stroke:j,"stroke-width":w,"stroke-linecap":"round"});if(S){let A=fe(l,c,I,(g+W)/2);me(Q,S,A.x,A.y,Z||i,[{label:i,value:R(b[L]),color:j}])}x.appendChild(Q)}return re(n,T,e.showLegend!==!1),n.appendChild(x),n}function no(e,t){let n=f("div","pf-chart pf-radar-chart"),o=ge(e,t),r=he(e),i=y(e.axisKey)??y(e.xAxis);if(o.length===0||r.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(ce(e,300),320),u=c/2,d=c/2,g=c/2-24,m=o.length,b=Le(o,r),h=(S)=>90-360*S/m,x=(S)=>S.map((T)=>`${T.x.toFixed(1)},${T.y.toFixed(1)}`).join(" "),E=oe(c,c,"Radar");if(l){for(let T=1;T<=4;T++){let L=g*T/4,I=Array.from({length:m},(j,W)=>fe(u,d,L,h(W)));E.appendChild(P("polygon",{points:x(I),fill:"none",stroke:ue,"stroke-width":1}))}for(let T=0;T<m;T++){let L=fe(u,d,g,h(T));E.appendChild(P("line",{x1:u,y1:d,x2:L.x,y2:L.y,stroke:ue,"stroke-width":1}))}}for(let S=0;S<m;S++){let T=fe(u,d,g+12,h(S)),L=i?o[S][i]:null;E.appendChild(Me({x:T.x,y:T.y+3,"text-anchor":"middle","font-size":ae,fill:X},v(L)))}let w=e.showTooltip!==!1?ie(n,E):void 0,R=ve(e,t);for(let S=0;S<r.length;S++){let T=r[S],L=T.color??_[S%_.length],I=o.map((j,W)=>fe(u,d,Number(j[T.dataKey]??0)/b*g,h(W)));if(E.appendChild(P("polygon",{points:x(I),fill:s?L:"none","fill-opacity":s?0.2:0,stroke:L,"stroke-width":2})),!a&&!w)continue;for(let j=0;j<I.length;j++){let W=P("circle",{cx:I[j].x,cy:I[j].y,r:a?3:6,fill:a?L:"transparent","fill-opacity":a?1:0});if(w){let Y=i?o[j][i]:null,Z=Y!=null?v(Y):T.label??T.dataKey,Q=[{label:T.label??T.dataKey,value:R(Number(o[j][T.dataKey]??0)),color:L}];me(W,w,I[j].x,I[j].y,Z,Q)}E.appendChild(W)}}return re(n,r,e.showLegend!==!1),n.appendChild(E),n}var oo=(e)=>String(Math.round(e*100)/100);function ro(e,t){let n=f("div","pf-chart pf-scatter-chart"),o=ge(e,t),r=y(e.xAxis),i=y(e.yAxis),s=y(e.zAxis),a=he(e),l=ce(e,300);if(o.length===0||!r||!i)return n.textContent="No chart data",n;let c=e.showGrid!==!1,u=a[0]?.color??_[0],d=ve(e,t,oo),g=o.map((A)=>Number(A[r]??0)),m=o.map((A)=>Number(A[i]??0)),b=Math.min(...g),h=Math.max(...g),x=Math.min(...m),E=Math.max(...m),w=h-b||1,R=E-x||1,S=s?o.map((A)=>Number(A[s]??0)):[],T=s?Math.max(...S,1):1,L=400,I=Ke(L,l,!0),j=oe(L,l,"Scatter"),W=(A)=>I.plotLeft+(A-b)/w*I.plotWidth,Y=(A)=>I.plotBottom-(A-x)/R*I.plotHeight,Z=4;for(let A=0;A<=Z;A++){let ne=x+R*A/Z,se=Y(ne);if(j.appendChild(Me({x:I.plotLeft-6,y:se+3,"text-anchor":"end","font-size":ae,fill:X},d(ne))),c&&A>0)j.appendChild(P("line",{x1:I.plotLeft,y1:se,x2:I.plotRight,y2:se,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}Ge(j,I);for(let A of[b,(b+h)/2,h])j.appendChild(Me({x:W(A),y:I.plotBottom+14,"text-anchor":"middle","font-size":ae,fill:X},oo(A)));let Q=e.showTooltip!==!1?ie(n,j):void 0;for(let A=0;A<o.length;A++){let ne=W(g[A]),se=Y(m[A]),rt=s?4+Math.sqrt(S[A]/T)*14:4,Pe=P("circle",{cx:ne,cy:se,r:rt,fill:u,"fill-opacity":s?0.6:0.85});if(Q){let Lo=[{label:r,value:d(g[A]),color:u},{label:i,value:d(m[A]),color:u},...s?[{label:s,value:d(S[A]),color:u}]:[]],Ao=a[0]?.label??"Point";me(Pe,Q,ne,se,Ao,Lo)}j.appendChild(Pe)}return re(n,a,e.showLegend!==!1),n.appendChild(j),n}function io(e,t){let n=f("div","pf-chart pf-histogram"),o=Yn(e,t);if(!o)return n.textContent="No data",n;let r=F(e.bins)??10,i=ce(e,200),s=y(e.color)??_[0],a=Math.min(...o),c=(Math.max(...o)-a)/r||1,u=Array(r).fill(0);for(let h of o){let x=Math.min(Math.floor((h-a)/c),r-1);u[x]++}let d=Math.max(...u),g=300,m=g/r,b=oe(g,i,"Histogram");for(let h=0;h<r;h++){let x=d>0?u[h]/d*i:0;b.appendChild(P("rect",{x:h*m,y:i-x,width:m-1,height:x,fill:s}))}return n.appendChild(b),n}function so(){p("BarChart",Qn),p("LineChart",At),p("AreaChart",At),p("PieChart",eo),p("RadarChart",no),p("ScatterChart",ro),p("RadialChart",to),p("Histogram",io)}function ao(){p("Table",rs),p("TableHead",Pt("thead")),p("TableBody",Pt("tbody")),p("TableFooter",Pt("tfoot")),p("TableRow",is),p("TableHeader",ss),p("TableCell",as),p("TableCaption",ls),p("ExpandableRow",cs)}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",M(e,n,t),n}function Pt(e){return(t,n)=>{let o=document.createElement(e);return o.className=`pf-${e}`,M(t,o,n),o}}function is(e,t){let n=document.createElement("tr");return n.className="pf-table-row",M(e,n,t),n}function ss(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 as(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 M(e,n,t),n}function ls(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 cs(e,t){let n=f("div","pf-expandable-row"),o=f("div","pf-expandable-row-summary");o.style.cursor="pointer",o.style.display="flex",o.style.alignItems="center",o.style.gap="8px";let r=f("span","pf-expandable-arrow");r.textContent="▶",r.style.transition="transform 0.2s",r.style.fontSize="10px",o.appendChild(r);for(let a of de(e.summary))o.appendChild(V(a,t));let i=f("div","pf-expandable-row-detail");i.style.display="none",i.style.paddingLeft="24px",M(e,i,t);let s=!1;return o.addEventListener("click",()=>{s=!s,i.style.display=s?"block":"none",r.style.transform=s?"rotate(90deg)":""}),n.appendChild(o),n.appendChild(i),n}var lo=!1;function Ye(){if(lo)return;lo=!0;let e=new Set(bt());vn(),Sn(),Tn(),An(),Pn(),On(),$n(),Dn(),Fn(),Bn(),zn(),so(),ao(),hn(bt().filter((t)=>!e.has(t)))}function Ot(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function $t(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Ht(e,t=" "){return Object.entries(e).map(([n,o])=>`${t}--${Ot(n)}: ${$t(o)};`).join(`
|
|
7
|
-
`)}function
|
|
8
|
-
${
|
|
9
|
-
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=
|
|
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(Q(t[r])),r++;r++;let c=a?` data-language="${Q(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}>${tt(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>${jn(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>${tt(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>${tt(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(tt).join("<br />")}</p>`)}return n.join(`
|
|
6
|
+
`)}function li(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=C(e.content,t),n}function Bn(){p("Card",ci),p("CardHeader",St("pf-card-header")),p("CardTitle",Vn("pf-card-title","h3")),p("CardDescription",Vn("pf-card-description","p")),p("CardContent",St("pf-card-content")),p("CardFooter",St("pf-card-footer"))}function ci(e,t){let n=f("div","pf-card");return L(e,n,t),n}function St(e){return(t,n)=>{let r=f("div",e);return L(t,r,n),r}}function Vn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=C(n.content,r),o}}var _=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],X="var(--muted-foreground, #6b7280)",ge="var(--border, #e5e7eb)",ee="11";function De(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 di(e,t){let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r;return(o<=1.5?1:o<=3?2:o<=7?5:10)*r}function _n(e,t=5){if(e<=0)return[0];return $e(0,e,t)}function $e(e,t,n=4){let r=t>e?t:e+1,o=di(r-e,n),i=Math.floor(e/o)*o,s=[];for(let a=i;a<=r+o*0.01||s.length<2;a+=o)s.push(Math.round(a*1000)/1000);return s}function nt(e,t,n,r,o){let i=_n(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=H("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":ee,fill:X});if(l.textContent=Nt(s,o),e.appendChild(l),r&&s>0)e.appendChild(H("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ge,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function zn(e,t,n,r){let o=_n(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=H("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":ee,fill:X});a.textContent=Nt(i,r),e.appendChild(a)}}function Lt(e,t,n,r,o,i){let s=t.map((d)=>{let u=d[n];return u==null?"":i?i(u):T(u)}),a=t.length>1?Math.abs(r(t.length-1)-r(0))/(t.length-1):1/0,l=Math.max(1,...s.map((d)=>d.length))*Number(ee)*0.6+8,c=Math.max(1,Math.ceil(l/a));for(let d=0;d<t.length;d++){if(d%c!==0)continue;let u=H("text",{x:r(d),y:o+14,"text-anchor":"middle","font-size":ee,fill:X});u.textContent=s[d],e.appendChild(u)}}function Fe(e,t){e.appendChild(H("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function Ee(e,t,n){if(e==null)return"";let r=J(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return T(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 Ie(e){let t=b(e.yAxisFormat)??b(e.valueFormat);return t&&t!=="auto"?t:void 0}function Te(e,t,n=String){let r=Ie(e);return(o)=>r?Ee(o,r,t):n(o)}function Ht(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return Ee(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return Nt(Number(r),i)}}function ie(e,t,n){return H("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,role:"img",...n?{"aria-label":`${n} chart`}:{}})}var le=400,pi=160;function Ae(e){return(t,n)=>{let r=e(t,n,le);if(typeof ResizeObserver>"u")return r;let o=le,i=0,s=(l)=>{if(!r.isConnected)return;o=l;let c=e(t,n,l);a.unobserve(r),r.replaceWith(c),r=c,a.observe(r)},a=new ResizeObserver((l)=>{let c=Math.floor(l[0]?.contentRect.width??0);if(c<pi||Math.abs(c-o)<1)return;cancelAnimationFrame(i),i=requestAnimationFrame(()=>{s(c)})});return a.observe(r),{element:r,destroy:()=>{cancelAnimationFrame(i),a.disconnect()}}}}function H(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 Se(e,t){let n=H("text",e);return n.textContent=t,n}function be(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function Pt(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=be(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 se(e,t,n){if(!n||t.length<=1)return;let r=f("div","pf-chart-legend");for(let o=0;o<t.length;o++){let i=f("div","pf-chart-legend-item"),s=f("span","pf-chart-legend-dot");s.style.backgroundColor=t[o].color??_[o%_.length];let a=f("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}var ui=["accountCircle","add","arrowBack","arrowForward","attachFile","calendarToday","call","camera","check","close","delete","download","edit","event","error","fastForward","favorite","favoriteOff","folder","help","home","info","locationOn","lock","lockOpen","mail","menu","moreVert","moreHoriz","notificationsOff","notifications","pause","payment","person","phone","photo","play","print","refresh","rewind","search","send","settings","share","shoppingCart","skipNext","skipPrevious","star","starHalf","starOff","stop","upload","visibility","visibilityOff","volumeDown","volumeMute","volumeOff","volumeUp","warning"],fi=new Map(ui.map((e)=>[Jn(e),e])),mi={alertcircle:"error",alerttriangle:"warning",alertoctagon:"error",xcircle:"error",circlex:"error",circlealert:"error",checkcircle:"check",circlecheck:"check",checkcircle2:"check",infocircle:"info",circleinfo:"info",helpcircle:"help",circlehelp:"help",bell:"notifications",belloff:"notificationsOff",arrowleft:"arrowBack",arrowright:"arrowForward",chevronleft:"arrowBack",chevronright:"arrowForward",x:"close",plus:"add",trash:"delete",trash2:"delete",ellipsisvertical:"moreVert",ellipsis:"moreHoriz",morehorizontal:"moreHoriz",morevertical:"moreVert",pencil:"edit",pen:"edit",squarepen:"edit",user:"person",usercircle:"accountCircle",circleuser:"accountCircle",eye:"visibility",eyeoff:"visibilityOff",mappin:"locationOn",map:"locationOn",image:"photo",images:"photo",file:"folder",files:"folder",calendar:"calendarToday",calendardays:"calendarToday",clock:"event",creditcard:"payment",cart:"shoppingCart",shoppingbag:"shoppingCart",phonecall:"call",mailopen:"mail",inbox:"mail",cog:"settings",gear:"settings",sliders:"settings",rotatecw:"refresh",rotateccw:"refresh",refreshcw:"refresh",heart:"favorite",heartoff:"favoriteOff",volume:"volumeUp",volume1:"volumeDown",volume2:"volumeUp",volumex:"volumeOff",skipforward:"skipNext",skipback:"skipPrevious",paperclip:"attachFile",link:"share",share2:"share",magnifyingglass:"search",searchicon:"search"};function Jn(e){return e.replace(/[\s._-]/g,"").toLowerCase()}function Kn(e){let t=Jn(e);return fi.get(t)??mi[t]}var Ot={accountCircle:'<path d="M18 20a6 6 0 0 0-12 0"/><circle cx="12" cy="10" r="4"/><circle cx="12" cy="12" r="10"/>',add:'<path d="M5 12h14"/><path d="M12 5v14"/>',arrowBack:'<path d="m12 19-7-7 7-7"/><path d="M19 12H5"/>',arrowForward:'<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',attachFile:'<path d="M13.234 20.252 21 12.3"/><path d="m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486"/>',calendarToday:'<path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/>',call:'<path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/>',camera:'<path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/>',check:'<path d="M20 6 9 17l-5-5"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',delete:'<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>',edit:'<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>',event:'<path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/><path d="M8 14h.01"/><path d="M12 14h.01"/><path d="M16 14h.01"/><path d="M8 18h.01"/><path d="M12 18h.01"/><path d="M16 18h.01"/>',error:'<circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/>',fastForward:'<polygon points="13 19 22 12 13 5 13 19"/><polygon points="2 19 11 12 2 5 2 19"/>',favorite:'<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"/>',favoriteOff:'<line x1="2" y1="2" x2="22" y2="22"/><path d="M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35"/><path d="M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17"/>',folder:'<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',help:'<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',home:'<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',info:'<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>',locationOn:'<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>',lock:'<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',lockOpen:'<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/>',mail:'<rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>',menu:'<line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/>',moreVert:'<circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/>',moreHoriz:'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',notificationsOff:'<path d="M10.268 21a2 2 0 0 0 3.464 0"/><path d="M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742"/><path d="m2 2 20 20"/><path d="M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05"/>',notifications:'<path d="M10.268 21a2 2 0 0 0 3.464 0"/><path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"/>',pause:'<rect x="14" y="4" width="4" height="16" rx="1"/><rect x="6" y="4" width="4" height="16" rx="1"/>',payment:'<rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/>',person:'<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',phone:'<rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/>',photo:'<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>',play:'<polygon points="6 3 20 12 6 21 6 3"/>',print:'<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6"/><rect x="6" y="14" width="12" height="8" rx="1"/>',refresh:'<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',rewind:'<polygon points="11 19 2 12 11 5 11 19"/><polygon points="22 19 13 12 22 5 22 19"/>',search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',send:'<path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"/><path d="m21.854 2.147-10.94 10.939"/>',settings:'<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',share:'<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" x2="15.42" y1="13.51" y2="17.49"/><line x1="15.41" x2="8.59" y1="6.51" y2="10.49"/>',shoppingCart:'<circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>',skipNext:'<polygon points="5 4 15 12 5 20 5 4"/><line x1="19" x2="19" y1="5" y2="19"/>',skipPrevious:'<polygon points="19 20 9 12 19 4 19 20"/><line x1="5" x2="5" y1="19" y2="5"/>',star:'<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"/>',starHalf:'<path d="M12 18.338a2.1 2.1 0 0 0-.987.244L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16l2.309-4.679A.53.53 0 0 1 12 2"/>',starOff:'<path d="M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43"/><path d="M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91"/><line x1="2" x2="22" y1="2" y2="22"/>',stop:'<rect width="18" height="18" x="3" y="3" rx="2"/>',upload:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>',visibility:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>',visibilityOff:'<path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"/><path d="M14.084 14.158a3 3 0 0 1-4.242-4.242"/><path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"/><path d="m2 2 20 20"/>',volumeDown:'<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/>',volumeMute:'<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/>',volumeOff:'<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><line x1="22" x2="16" y1="9" y2="15"/><line x1="16" x2="22" y1="9" y2="15"/>',volumeUp:'<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/>',warning:'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>'};var hi='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">';function gi(e){let t=Kn(e);if(t==null||!(t in Ot))return;return`${hi}${Ot[t]}</svg>`}function rt(e,t){e.setAttribute("data-icon",t);let n=gi(t);if(n===void 0){if(t!=="")S.warn(`icon "${t}" has no glyph`);return}e.innerHTML=n}function Wn(){p("DataTable",bi),p("Badge",yi),p("Dot",Ci),p("Metric",vi),p("Ring",xi),p("Progress",wi),p("Separator",ki),p("Loader",Mi),p("Icon",Ri),p("Sparkline",Ei)}function bi(e,t){let n=f("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable";let o=W(e.columns).map((h)=>({key:T(h.key),header:h.header!=null?T(h.header):void 0,format:b(h.format),accessor:b(h.accessor)})),i=J(e.rows,t),s=b(e.rowKey),a=b(e.selected),l=document.createElement("thead"),c=document.createElement("tr");for(let h of o){let m=document.createElement("th");m.className="pf-datatable-th",m.setAttribute("scope","col"),m.textContent=h.header??h.key,c.appendChild(m)}l.appendChild(c),r.appendChild(l);let d=document.createElement("tbody");if(Array.isArray(i)){let h=a!=null?J(a,t):void 0;for(let m of i){let v=document.createElement("tr");v.className="pf-datatable-row";let g=m,y=M(g)?g:{},R=m===null||typeof m!=="object";if(s&&h!=null&&y[s]!=null&&T(y[s])===T(h))v.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)v.classList.add("pf-datatable-row-clickable"),v.addEventListener("click",()=>{let w={...t.scope,$item:g,$index:i.indexOf(m)},k=z({...t,scope:w});j(I(e.onRowClick,k),"onRowClick")});for(let w of o){let k=document.createElement("td");k.className="pf-datatable-td";let x;if(w.accessor)x=J(`{{ $item.${w.accessor} }}`,{...t,scope:{...t.scope,$item:g}});else if(x=R?m:y[w.key],w.format&&x!=null)x=J(`{{ __fmtVal | ${w.format} }}`,{...t,scope:{...t.scope,__fmtVal:x}});k.textContent=T(x),v.appendChild(k)}d.appendChild(v)}}if(!Array.isArray(i)||i.length===0){let h=document.createElement("tr"),m=document.createElement("td");m.className="pf-datatable-empty",m.colSpan=Math.max(1,o.length),m.textContent="No results",h.appendChild(m),d.appendChild(h)}if(r.appendChild(d),e.search===!0){let h=document.createElement("input");h.type="text",h.placeholder="Search...",h.className="pf-datatable-search",h.setAttribute("aria-label","Search table"),h.addEventListener("input",()=>{let m=h.value.toLowerCase();for(let v of d.querySelectorAll("tr.pf-datatable-row"))v.style.display=v.textContent.toLowerCase().includes(m)?"":"none"}),n.appendChild(h)}let u=f("div","pf-datatable-scroll");return u.appendChild(r),n.appendChild(u),n}function yi(e,t){let n=f("span","pf-badge"),r=b(e.variant)??"default";return n.setAttribute("data-variant",r),n.textContent=C(e.label??e.content,t),n}function Ci(e,t){let n=f("span","pf-dot"),r=b(e.color);if(r!=null)n.style.backgroundColor=r;return n}function vi(e,t){let n=f("div","pf-metric"),r=f("div","pf-metric-label");r.textContent=C(e.label,t),n.appendChild(r);let o=f("div","pf-metric-row"),i=f("div","pf-metric-value");if(i.textContent=C(e.value,t),o.appendChild(i),e.delta!=null){let s=f("span","pf-metric-delta"),a=b(e.trend),l=a==="up"?"↑ ":a==="down"?"↓ ":"";s.textContent=l+C(e.delta,t),s.setAttribute("data-sentiment",b(e.trendSentiment)??"neutral"),o.appendChild(s)}if(n.appendChild(o),e.description!=null){let s=f("div","pf-metric-desc");s.textContent=C(e.description,t),n.appendChild(s)}return n}function xi(e,t){let n=f("div","pf-ring");n.setAttribute("data-variant",b(e.variant)??"default");let r=O(e.size)??80,o=O(e.thickness)??8,i=Number(J(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),d=H("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`}),u={cx:r/2,cy:r/2,r:a,fill:"none","stroke-width":o},h=H("circle",{...u,class:"pf-ring-track",stroke:"var(--muted, #e5e7eb)"}),m=H("circle",{...u,class:"pf-ring-fill",stroke:"var(--primary, #3b82f6)","stroke-dasharray":l,"stroke-dashoffset":c,"stroke-linecap":"round"});if(d.appendChild(h),d.appendChild(m),n.appendChild(d),n.setAttribute("role","img"),n.setAttribute("aria-label",`${String(s)}%`),e.label!=null){let v=f("div","pf-ring-label");v.textContent=C(e.label,t),n.appendChild(v)}return n}function wi(e,t){let n=f("div","pf-progress");n.setAttribute("role","progressbar"),n.setAttribute("data-variant",b(e.variant)??"default");let r=Number(J(e.value,t)??0),o=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));let s=f("div","pf-progress-fill");return s.style.width=`${i}%`,n.appendChild(s),n}function ki(e,t){let n=document.createElement("hr");if(n.className="pf-separator",e.orientation==="vertical")n.setAttribute("data-orientation","vertical"),n.setAttribute("aria-orientation","vertical");return n}function Mi(e,t){let n=f("div","pf-loader");return n.setAttribute("role","status"),n.setAttribute("aria-label","Loading"),n}function Ri(e,t){let n=f("span","pf-icon");return rt(n,C(e.name??e.content,t)),n}function Ei(e,t){let n=f("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=O(e.width)??120,i=O(e.height)??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,c=H("svg",{width:o,height:i,viewBox:`0 0 ${o} ${i}`}),d=r.length>1?r.length-1:1,u=r.map((h,m)=>{let v=m/d*o,g=i-(h-a)/l*(i-4)-2;return`${v},${g}`}).join(" ");return c.appendChild(H("polyline",{points:u,fill:"none",stroke:"var(--primary, #3b82f6)","stroke-width":1.5})),n.appendChild(c),n}function Zn(){p("Form",Ti),p("Input",Ai),p("Textarea",ye(Si)),p("Button",Li),p("ButtonGroup",Le("pf-button-group")),p("Checkbox",qn("pf-checkbox")),p("Switch",qn("pf-switch")),p("Slider",ye(Ni)),p("Calendar",ye(Xn("pf-calendar"))),p("DatePicker",ye(Xn("pf-datepicker"))),p("Field",Le("pf-field")),p("FieldTitle",Ne("pf-field-title")),p("FieldDescription",Ne("pf-field-description")),p("FieldContent",Le("pf-field-content")),p("FieldError",Ne("pf-field-error"))}function Ti(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]}for(let s of n.querySelectorAll('input[type="checkbox"][name]'))i[s.name]=s.checked;if(t.store.merge(i),e.onSubmit!=null){let s=z(t);s.scope={...t.scope,...i},j(I(e.onSubmit,s),"onSubmit")}}),L(e,n,t),n}var Gn=0;function ce(e,t){return Gn+=1,`pf-${e}-${t??"field"}-${String(Gn)}`}function Yn(e,t,n){if(t.label==null)return;let r=document.createElement("label");r.className="pf-input-label",r.textContent=C(t.label,n);let o=e.querySelector("input, select, textarea");if(o){if(!o.id)o.id=ce("control",b(t.name));r.htmlFor=o.id}if(t.required===!0)r.setAttribute("data-required","");e.insertBefore(r,e.firstChild)}function Qn(e,t,n){if(t.error==null||t.error===!1||t.error==="")return;let r=e.querySelector("input, select, textarea");if(r?.setAttribute("aria-invalid","true"),t.error===!0)return;let o=f("p","pf-field-error");o.id=ce("error",b(t.name)),o.textContent=C(t.error,n),r?.setAttribute("aria-describedby",o.id),e.appendChild(o)}function ye(e){return(t,n)=>{let r=e(t,n);return r.classList.add("pf-labeled"),Yn(r,t,n),Qn(r,t,n),r}}function Ce(e,t){if(t.required!==!0)return;if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)e.required=!0;e.setAttribute("aria-required","true")}function Dt(e,t,n,r="input",o=()=>e.value){let i=b(t.name)??(e.name||void 0);if(!i)return;let s=n.store.get(i);if(s!=null)e.value=T(s);e.addEventListener(r,()=>{let a=o();if(n.store.set(i,a),t.onChange!=null)j(I(t.onChange,{...z(n),scope:{...n.scope,$event:a}}),"onChange")})}function Ai(e,t){let n=f("div","pf-input-wrapper"),r=document.createElement("input");if(r.className="pf-input",r.type=b(e.inputType)??"text",e.name!=null)r.name=T(e.name);if(r.id=ce("input",b(e.name)),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.disabled===!0)r.disabled=!0;return Ce(r,e),Dt(r,e,t),n.appendChild(r),Yn(n,e,t),Qn(n,e,t),n}function Si(e,t){let n=f("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=T(e.name);if(r.id=ce("textarea",b(e.name)),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.rows!=null)r.rows=Number(e.rows);if(e.disabled===!0)r.disabled=!0;return Ce(r,e),Dt(r,e,t),n.appendChild(r),n}function Li(e,t){let n=document.createElement("button");if(n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=C(e.label,t),n.setAttribute("data-variant",b(e.variant)??"default"),e.size!=null)n.setAttribute("data-size",T(e.size));if(e.disabled===!0)n.disabled=!0;return n}function qn(e){return(t,n)=>{let r=f("label",`${e}-wrapper`),o=document.createElement("input");if(o.type="checkbox",o.className=e,e==="pf-switch")o.setAttribute("role","switch");if(t.name!=null)o.name=T(t.name);if(t.checked===!0)o.checked=!0;if(t.disabled===!0)o.disabled=!0;let i=b(t.name);if(i){let s=n.store.get(i);if(typeof s==="boolean")o.checked=s;o.addEventListener("change",()=>{if(n.store.set(i,o.checked),t.onChange!=null)j(I(t.onChange,{...z(n),scope:{...n.scope,$event:o.checked}}),"onChange")})}if(r.appendChild(o),t.label!=null){let s=f("span");s.textContent=C(t.label,n),r.appendChild(s)}return r}}function Un(e){let t=Number(e.min||0),n=Number(e.max||100),r=n>t?(Number(e.value)-t)/(n-t)*100:0;e.style.setProperty("--pf-fill",`${String(Math.round(Math.max(0,Math.min(100,r))*100)/100)}%`)}function Ni(e,t){let n=f("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=T(e.name);if(e.min!=null)r.min=T(e.min);if(e.max!=null)r.max=T(e.max);if(e.step!=null)r.step=T(e.step);if(e.disabled===!0)r.disabled=!0;return Dt(r,e,t,"input",()=>Number(r.value)),Un(r),r.addEventListener("input",()=>{Un(r)}),n.appendChild(r),n}function Le(e){return(t,n)=>{let r=f("div",e);return L(t,r,n),r}}function Ne(e){return(t,n)=>{let r=f("span",e);return r.textContent=C(t.content,n),r}}function $t(){let e=document.createElement("hr");return e.className="pf-separator",e}function Xn(e){return(t,n)=>{let r=f("div",e),o=document.createElement("input");if(o.type="date",o.className="pf-input",o.name=C(t.name,n),o.id=ce("date",o.name||void 0),Ce(o,t),t.placeholder!=null)o.placeholder=C(t.placeholder,n);if(t.value!==void 0)o.value=C(t.value,n);if(t.minDate!=null)o.min=C(t.minDate,n);if(t.maxDate!=null)o.max=C(t.maxDate,n);if(t.disabled===!0)o.disabled=!0;let i=n.store.get(o.name);if(i!=null)o.value=T(i);return o.addEventListener("change",()=>{if(n.store.set(o.name,o.value),t.onChange!=null)j(I(t.onChange,z(n)),"onChange")}),r.appendChild(o),r}}function er(){p("Select",ye(Hi)),p("SelectOption",Di),p("SelectGroup",Le("pf-select-group")),p("SelectLabel",Ne("pf-select-label")),p("SelectSeparator",$t),p("Radio",$i),p("RadioGroup",Fi),p("Combobox",ye(Ii)),p("ComboboxOption",ji),p("ComboboxGroup",Le("pf-combobox-group")),p("ComboboxLabel",Ne("pf-combobox-label")),p("ComboboxSeparator",$t),p("ChoiceCard",Vi)}function Hi(e,t){let n=f("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=T(e.name);if(r.id=ce("select",b(e.name)),e.multiple===!0)r.multiple=!0;if(e.disabled===!0)r.disabled=!0;if(Ce(r,e),e.placeholder!=null){let i=document.createElement("option");i.value="",i.textContent=C(e.placeholder,t),i.disabled=!0,i.selected=!0,i.hidden=!0,r.appendChild(i)}for(let i of W(e.options)){let s=document.createElement("option");s.value=T(i.value),s.textContent=i.label!=null?T(i.label):s.value,r.appendChild(s)}if(e.children)for(let i of e.children)if(i.type==="SelectOption"){let s=document.createElement("option");s.value=b(i.value)??"",s.textContent=b(i.label)??s.value,r.appendChild(s)}else r.appendChild(B(i,t));let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)Oi(r,i);r.addEventListener("change",()=>{let s=Pi(r);if(t.store.set(o,s),e.onChange!=null)j(I(e.onChange,{...z(t),scope:{...t.scope,$event:s}}),"onChange")})}return n.appendChild(r),n}function Pi(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function Oi(e,t){if(!e.multiple){e.value=T(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>T(r)));for(let r of e.options)r.selected=n.has(r.value)}function Di(e,t){return f("span")}function $i(e,t){let n=f("label","pf-radio"),r=document.createElement("input");if(r.type="radio",r.className="pf-radio-input",e.disabled===!0)r.disabled=!0;if(r.value=C(e.value,t),n.appendChild(r),e.label!=null){let o=f("span","pf-radio-label");o.textContent=C(e.label,t),n.appendChild(o)}return n}function Fi(e,t){let n=f("fieldset","pf-radio-group");if(Ce(n,e),e.label!=null){let i=document.createElement("legend");if(i.className="pf-radio-legend",i.textContent=C(e.label,t),e.required===!0)i.setAttribute("data-required","");n.appendChild(i)}L(e,n,t);let r=C(e.name,t),o=t.store.get(r);for(let i of n.querySelectorAll('input[type="radio"]')){if(!(i instanceof HTMLInputElement))continue;if(i.name=r,o!=null&&i.value===T(o))i.checked=!0}return n.addEventListener("change",(i)=>{let s=i.target;if(s instanceof HTMLInputElement&&s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)j(I(e.onChange,z(t)),"onChange")}}),n}function Ii(e,t){let n=f("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=C(e.name,t),r.id=ce("combobox",r.name||void 0),r.autocomplete="off",r.setAttribute("role","combobox"),r.setAttribute("aria-autocomplete","list"),r.setAttribute("aria-expanded","false"),Ce(r,e),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);if(e.disabled===!0)r.disabled=!0;let o=t.store.get(r.name);if(o!=null)r.value=T(o);let i=f("div","pf-combobox-dropdown");i.id=`${r.id}-list`,i.setAttribute("role","listbox"),i.style.display="none",r.setAttribute("aria-controls",i.id),L(e,i,t);let s=()=>Array.from(i.querySelectorAll(".pf-combobox-option")).filter((c)=>c.style.display!=="none"),a=(c)=>{if(i.style.display=c?"block":"none",r.setAttribute("aria-expanded",c?"true":"false"),!c)for(let d of s())d.setAttribute("aria-selected","false")},l=(c)=>{let d=s();if(d.length===0)return;let u=d.findIndex((m)=>m.getAttribute("aria-selected")==="true"),h=d[(u+c+d.length)%d.length];for(let m of d)m.setAttribute("aria-selected",m===h?"true":"false");h.scrollIntoView({block:"nearest"})};if(r.addEventListener("focus",()=>{a(!0)}),r.addEventListener("blur",()=>{setTimeout(()=>{a(!1)},150)}),r.addEventListener("keydown",(c)=>{if(c.key==="ArrowDown"||c.key==="ArrowUp")c.preventDefault(),a(!0),l(c.key==="ArrowDown"?1:-1);else if(c.key==="Enter"){let d=s().find((u)=>u.getAttribute("aria-selected")==="true");if(d)c.preventDefault(),d.dispatchEvent(new MouseEvent("mousedown")),a(!1)}else if(c.key==="Escape")a(!1)}),e.searchable!==!1)r.addEventListener("input",()=>{let c=r.value.toLowerCase();for(let d of i.querySelectorAll(".pf-combobox-option"))if(d instanceof HTMLElement)d.style.display=d.textContent.toLowerCase().includes(c)?"":"none";a(!0)});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{j(I(e.onChange,{...z(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.appendChild(r),n.appendChild(i),n}function ji(e,t){let n=f("div","pf-combobox-option");return n.setAttribute("role","option"),n.setAttribute("aria-selected","false"),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 Vi(e,t){let n=f("div","pf-choice-card");n.dataset.value=C(e.value,t);let r=typeof e.selected==="string"?J(e.selected,t):e.selected;if(r===!0||r==="true")n.dataset.selected="true";if(e.onClick!=null)n.setAttribute("aria-pressed",n.dataset.selected==="true"?"true":"false");if(e.label!=null){let o=f("div","pf-choice-card-label");o.textContent=C(e.label,t),n.appendChild(o)}if(e.description!=null){let o=f("div","pf-choice-card-description");o.textContent=C(e.description,t),n.appendChild(o)}return L(e,n,t),n}var de=(e)=>`${e}-${Math.random().toString(36).slice(2,8)}`;function Ft(e,t){if(!Me(e))return;let n=B(e,t);if(n instanceof HTMLElement)return n;let r=f("span","pf-trigger");return r.style.display="contents",r.appendChild(n),r}function tr(){p("Tabs",Bi),p("Tab",_i),p("Accordion",zi),p("AccordionItem",Ji),p("Dialog",Ki),p("Popover",Wi),p("Tooltip",Gi),p("HoverCard",qi),p("Carousel",Ui)}function Bi(e,t){let n=f("div","pf-tabs"),r=f("div","pf-tabs-bar");r.setAttribute("role","tablist");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 d=s.findIndex((u)=>u.title===c);return d>=0?d:0}return 0})();s.forEach((c,d)=>{let u=de("pf-tab"),h=de("pf-panel"),m=document.createElement("button");m.type="button",m.className="pf-tab-trigger",m.textContent=b(c.title)??`Tab ${String(d+1)}`,m.setAttribute("role","tab"),m.setAttribute("aria-controls",h),m.id=u,m.addEventListener("click",()=>{l(d,!0)});let v=f("div","pf-tab-panel");v.setAttribute("role","tabpanel"),v.setAttribute("aria-labelledby",u),v.id=h,v.tabIndex=0,L(c,v,t),i.push(m),o.push(v),r.appendChild(m)});function l(c,d){if(i.forEach((u,h)=>{let m=h===c;u.classList.toggle("pf-tab-active",m),u.setAttribute("aria-selected",m?"true":"false"),u.tabIndex=m?0:-1,o[h].style.display=m?"block":"none"}),d)i[c]?.focus()}if(i.length>0)l(a,!1);r.addEventListener("keydown",(c)=>{let d=i.findIndex((h)=>h===c.target);if(d<0)return;let u;if(c.key==="ArrowRight")u=(d+1)%i.length;else if(c.key==="ArrowLeft")u=(d-1+i.length)%i.length;else if(c.key==="Home")u=0;else if(c.key==="End")u=i.length-1;else return;c.preventDefault(),l(u,!0)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function _i(e,t){let n=f("div","pf-tab");return L(e,n,t),n}function zi(e,t){let n=f("div","pf-accordion");return L(e,n,t),n}function Ji(e,t){let n=f("div","pf-accordion-item"),r=document.createElement("button");r.type="button",r.className="pf-accordion-trigger",r.id=de("pf-acc-trigger"),r.textContent=b(e.title)??"",r.setAttribute("aria-expanded","false");let o=f("div","pf-accordion-content");return o.id=de("pf-acc"),o.setAttribute("role","region"),o.setAttribute("aria-labelledby",r.id),o.style.display="none",r.setAttribute("aria-controls",o.id),L(e,o,t),r.addEventListener("click",()=>{let i=o.style.display!=="none";o.style.display=i?"none":"block",r.setAttribute("aria-expanded",i?"false":"true")}),n.appendChild(r),n.appendChild(o),n}function Ki(e,t){let n=f("div","pf-dialog-wrapper"),r=document.createElement("dialog");r.className="pf-dialog",r.setAttribute("aria-modal","true");let o=e.dismissible!==!1,i=Ft(e.trigger,t);if(i)i.setAttribute("aria-haspopup","dialog"),i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i);if(e.title!=null){let l=f("h2","pf-dialog-title");l.textContent=C(e.title,t),l.id=de("pf-dialog-title"),r.setAttribute("aria-labelledby",l.id),r.appendChild(l)}if(e.description!=null){let l=f("p","pf-dialog-desc");l.textContent=C(e.description,t),l.id=de("pf-dialog-desc"),r.setAttribute("aria-describedby",l.id),r.appendChild(l)}let s=f("div","pf-dialog-body");if(L(e,s,t),r.appendChild(s),o){let l=document.createElement("button");l.type="button",l.className="pf-dialog-close",l.setAttribute("aria-label","Close"),l.textContent="×",l.addEventListener("click",()=>{r.close()}),r.appendChild(l),r.addEventListener("click",(c)=>{if(c.target===r)r.close()})}else r.addEventListener("cancel",(l)=>{l.preventDefault()});let a=()=>{r.close()};return document.addEventListener("prefab:close-overlay",a),n.appendChild(r),{element:n,destroy:()=>{document.removeEventListener("prefab:close-overlay",a)}}}function Wi(e,t){let n=f("div","pf-popover"),r=f("div","pf-popover-content");if(r.id=de("pf-popover"),r.setAttribute("role","dialog"),r.style.display="none",e.title!=null){let c=f("div","pf-popover-title");c.textContent=C(e.title,t),r.appendChild(c)}L(e,r,t);let o=Ft(e.trigger,t),i=()=>r.style.display!=="none",s=(c)=>{r.style.display=c?"block":"none",o?.setAttribute("aria-expanded",c?"true":"false")};if(o)o.setAttribute("aria-haspopup","dialog"),o.setAttribute("aria-controls",r.id),o.setAttribute("aria-expanded","false"),o.addEventListener("click",(c)=>{c.stopPropagation(),s(!i())}),n.appendChild(o);else n.addEventListener("click",(c)=>{if(c.target instanceof Node&&r.contains(c.target)&&i())return;s(!i())});let a=(c)=>{if(i()&&c.target instanceof Node&&!n.contains(c.target))s(!1)},l=(c)=>{if(c.key==="Escape"&&i())s(!1)};return document.addEventListener("click",a),document.addEventListener("keydown",l),n.appendChild(r),{element:n,destroy:()=>{document.removeEventListener("click",a),document.removeEventListener("keydown",l)}}}function Gi(e,t){let n=f("div","pf-tooltip"),r=f("div","pf-tooltip-content");r.id=de("pf-tip"),r.setAttribute("role","tooltip"),r.textContent=C(e.content??"",t),r.style.display="none",L(e,n,t),n.setAttribute("aria-describedby",r.id);let o=()=>{r.style.display="block"},i=()=>{r.style.display="none"};return n.addEventListener("mouseenter",o),n.addEventListener("mouseleave",i),n.addEventListener("focus",o,!0),n.addEventListener("blur",i,!0),n.appendChild(r),n}function qi(e,t){let n=f("div","pf-hover-card"),r=f("div","pf-hover-card-content");r.style.display="none";let o=Ft(e.trigger,t);if(o)n.appendChild(o);return L(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.addEventListener("focusin",()=>{r.style.display="block"}),n.addEventListener("focusout",()=>{r.style.display="none"}),n.appendChild(r),n}function Ui(e,t){let n=f("div","pf-carousel");n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",C(e.label??"Carousel",t));let r=f("div","pf-carousel-track");L(e,r,t);let o=0,i=e.children?.length??0,s=(d,u,h)=>{let m=document.createElement("button");return m.type="button",m.className=d,m.textContent=u,m.setAttribute("aria-label",h),m},a=s("pf-carousel-prev","‹","Previous slide"),l=s("pf-carousel-next","›","Next slide"),c=()=>{r.style.transform=`translateX(-${String(o*100)}%)`,a.disabled=o<=0,l.disabled=o>=i-1};return a.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),c()}),l.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),c()}),c(),n.appendChild(r),n.appendChild(a),n.appendChild(l),n}function Xi(e){if(!M(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,me(n)]))}function nr(){p("ForEach",Zi),p("If",rr),p("Elif",Yi),p("Else",Qi),p("Condition",es),p("Define",ts),p("Use",ns),p("Slot",rs)}function Zi(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(q(r)){let s=U(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=P(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)he(e.children,n,c)}return n}function rr(e,t){if(or(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)he(e.children,r,t);return r}return document.createDocumentFragment()}function Yi(e,t){return rr(e,t)}function Qi(e,t){let n=document.createDocumentFragment();if(e.children)he(e.children,n,t);return n}function or(e,t){if(!e)return!1;if(q(e))return Boolean(U(e,t.store,t.scope));return Boolean(t.store.get(e))}function es(e,t){let n=document.createDocumentFragment(),r=W(e.cases).find((o)=>or(b(o.when)??"",t));return he(me(r?r.children:e.else),n,t),n}function ts(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function ns(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=P(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...Xi(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(B(c,l));return n}function rs(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(B(s,t));return n}function ir(){p("Alert",os),p("AlertTitle",is),p("AlertDescription",ss)}function os(e,t){let n=f("div","pf-alert");n.setAttribute("role","alert");let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),e.icon!=null){let o=f("span","pf-alert-icon");rt(o,T(e.icon)),n.appendChild(o)}return L(e,n,t),n}function is(e,t){let n=f("h5","pf-alert-title");return n.textContent=C(e.content,t),n}function ss(e,t){let n=f("p","pf-alert-description");return n.textContent=C(e.content,t),n}var It=new Map;function ot(e){let t=It.get(e);if(t)return t;let n=import(e);return It.set(e,n),n.catch(()=>{It.delete(e)}),n}function sr(e){let t=e.closest("[data-theme], .dark, .light");if(t)return t.getAttribute("data-theme")==="dark"||t.classList.contains("dark");return typeof matchMedia==="function"&&matchMedia("(prefers-color-scheme: dark)").matches}function lr(){p("Image",as),p("Audio",ls),p("Video",cs),p("Embed",ds),p("Svg",us),p("DropZone",ms),p("Mermaid",bs)}function as(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=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.loading="lazy",n}function ls(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=C(e.src,t),n.controls=!0,n}function cs(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=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n}function ds(e,t){let n=f("div","pf-embed"),r=document.createElement("iframe");return r.src=C(e.src,t),r.style.height=e.height!=null?`${String(Number(e.height))}px`:"400px",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var ps=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 us(e,t){let n=f("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 cr(i),n.appendChild(document.importNode(i,!0)),n}function cr(e){let t=Array.from(e.children);for(let n of t){if(!ps.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)}cr(n)}}function fs(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 ms(e,t){let n=f("div","pf-dropzone");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=T(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)=>fs(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)j(I(e.onDrop,{...z(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}var hs="https://cdn.jsdelivr.net/npm/mermaid@11.4.1/dist/mermaid.esm.min.mjs",ar=0;function gs(e){return M(e)&&typeof e.initialize==="function"&&typeof e.render==="function"}function bs(e,t){let n=f("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=C(e.content,t),o=f("pre","pf-mermaid-source");if(o.textContent=r,n.appendChild(o),r.trim()==="")return n;return ot(hs).then(async(i)=>{let s=M(i)?i.default:void 0;if(!gs(s))return;s.initialize({startOnLoad:!1,securityLevel:"strict",theme:sr(n)?"dark":"neutral",fontFamily:"inherit"}),ar+=1;let{svg:a}=await s.render(`pf-mermaid-${String(ar)}`,r);n.innerHTML=a,n.setAttribute("data-state","rendered")}).catch(()=>{n.setAttribute("data-state","source")}),n}var ys="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Cs="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",dr=1.25,ur=0.25,fr=5,pr=32;function vs(e){if(!M(e)||typeof e.getDocument!=="function")return!1;let t=e.GlobalWorkerOptions;return typeof t==="function"||M(t)}function jt(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function xs(e){return e==="fit-page"||e==="fit-width"?e:jt(e,0)||"fit-width"}async function ws(){let e=await ot(ys);if(!vs(e))throw Error("PDF.js did not load");return e.GlobalWorkerOptions.workerSrc=Cs,e}function mr(){p("PdfViewer",ks)}function ks(e,t){let n=f("div","pf-pdf-viewer");n.style.height=`${jt(e.height,600)}px`;let r=f("div","pf-pdf-message");r.setAttribute("role","status"),r.textContent="Loading PDF…",n.appendChild(r);let o={destroyed:!1,cleanup:()=>{return}};return Rs(n,r,o,{src:e.src!=null?C(e.src,t):void 0,data:b(e.data),initialPage:jt(e.page,1),zoom:xs(e.zoom),showToolbar:e.toolbar!==!1}),{element:n,destroy:()=>{o.destroyed=!0,o.cleanup()}}}function Ms(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function Rs(e,t,n,r){try{let v=function(y){let R=Math.max(1,Math.min(y,i.numPages));if(R!==s)s=R,g()};if(!r.src&&!r.data)throw Error("No PDF source provided");let i=await(await ws()).getDocument(r.src?{url:r.src}:{data:Ms(r.data??"")}).promise;if(n.destroyed)return;t.remove();let s=Math.max(1,Math.min(r.initialPage,i.numPages)),a=r.zoom,l=1,c,d=0,u=r.showToolbar?Ts(i.numPages,{onPage:(y)=>{v(y)},onZoom:(y)=>{a=Es(l*y),g()},onFit:()=>{a=a==="fit-page"?"fit-width":"fit-page",g()}}):void 0;if(u)e.appendChild(u.el);let h=f("div","pf-pdf-canvas-container"),m=document.createElement("canvas");m.className="pf-pdf-canvas",h.appendChild(m),e.appendChild(h);async function g(){d+=1;let y=d;c?.cancel();let R=await i.getPage(s);if(n.destroyed||y!==d)return;let w=R.getViewport({scale:1}),k=Math.max(1,h.clientWidth-pr),x=Math.max(1,h.clientHeight-pr);l=a==="fit-width"?k/w.width:a==="fit-page"?Math.min(k/w.width,x/w.height):a;let E=R.getViewport({scale:l}),A=window.devicePixelRatio||1;m.width=Math.floor(E.width*A),m.height=Math.floor(E.height*A),m.style.width=`${Math.floor(E.width)}px`,m.style.height=`${Math.floor(E.height)}px`;let F=m.getContext("2d");if(!F)return;let N=R.render({canvasContext:F,viewport:E,transform:A!==1?[A,0,0,A,0,0]:void 0});c=N;try{await N.promise}catch(V){if(y!==d)return;throw V}u?.update(s,l,a)}if(typeof ResizeObserver<"u"){let y=0,R=new ResizeObserver((w)=>{let k=Math.round(w[0]?.contentRect.width??0);if(typeof a==="number"||k===y)return;y=k,g()});R.observe(h),n.cleanup=()=>{R.disconnect()}}await g()}catch(o){t.textContent=`Could not load PDF: ${o instanceof Error?o.message:String(o)}`,t.setAttribute("data-state","error")}}function Es(e){return Math.min(fr,Math.max(ur,e))}function je(e,t,n){let r=document.createElement("button");return r.type="button",r.className="pf-pdf-btn",r.textContent=e,r.title=t,r.setAttribute("aria-label",t),r.addEventListener("click",n),r}function Ts(e,t){let n=f("div","pf-pdf-toolbar"),r=1,o=je("‹","Previous page",()=>{t.onPage(r-1)}),i=je("›","Next page",()=>{t.onPage(r+1)}),s=document.createElement("input");s.type="text",s.inputMode="numeric",s.className="pf-pdf-page-input",s.setAttribute("aria-label","Page number"),s.addEventListener("change",()=>{let m=parseInt(s.value,10);if(isNaN(m))s.value=String(r);else t.onPage(m)});let a=f("span","pf-pdf-page-count");a.textContent=`/ ${String(e)}`;let l=f("span","pf-pdf-spacer"),c=je("−","Zoom out",()=>{t.onZoom(1/dr)}),d=f("span","pf-pdf-zoom-label"),u=je("+","Zoom in",()=>{t.onZoom(dr)}),h=je("⤢","Fit page / fit width",t.onFit);return n.append(o,s,a,i,l,c,d,u,h),{el:n,update(m,v,g){r=m,s.value=String(m),o.disabled=m<=1,i.disabled=m>=e,d.textContent=`${String(Math.round(v*100))}%`,c.disabled=v<=ur,u.disabled=v>=fr,h.setAttribute("aria-pressed",typeof g==="number"?"false":"true")}}}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 hr(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">${Q(r)}</div>`;for(let y of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${Q(y.color)}"></span>`,l+=`<span>${Q(y.label)}:</span> <strong>${Q(String(y.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),d=a.getBoundingClientRect(),u=s.viewBox.baseVal,h=c.width/(u.width||1),m=c.left-d.left+t*h,v=i.offsetWidth||100,g=m+12;if(g+v>d.width)g=m-v-12;i.style.left=`${Math.max(0,g)}px`,i.style.top="4px",i.classList.add("pf-visible")}function gr(e){e.tooltip.classList.remove("pf-visible")}function br(e,t,n){e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",n),e.addEventListener("touchstart",t,{passive:!0}),e.addEventListener("touchend",n,{passive:!0})}function pe(e,t,n,r,o,i){br(e,()=>{hr(t,n,r,o,i)},()=>{gr(t)})}function yr(e,t){let{data:n,series:r,xAxisKey:o,formatValue:i,formatLabel:s}=e,a=o?n[t][o]:void 0,l=a!=null?s?s(a):T(a):void 0,c=r.map((d,u)=>({label:d.label??d.dataKey,value:i(n[t][d.dataKey],d,u),color:d.color??_[u%_.length]}));return{label:l,entries:c}}function Cr(e,t,n){let r=H("rect",{x:e,y:n.plotTop,width:t,height:n.plotHeight,fill:"transparent"});return r.style.cursor="default",r}function vr(e,t,n,r,o,i,s,a){let l={data:n,series:r,xAxisKey:i,formatValue:s,formatLabel:a},c=o.plotWidth/n.length;for(let d=0;d<n.length;d++){let u=o.plotLeft+d*c,h=Cr(u,c,o),{label:m,entries:v}=yr(l,d);pe(h,e,u+c/2,o.plotTop,m,v),t.appendChild(h)}}function xr(e,t,n,r,o,i,s,a,l,c){let d={data:n,series:r,xAxisKey:i,formatValue:s,formatLabel:c},u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let h=0;h<n.length;h++){let m=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+h/(n.length-1)*o.plotWidth,v=Math.max(o.plotLeft,n.length===1?o.plotLeft:m-u/2),g=Cr(v,Math.min(u,o.plotRight-v),o),{label:y,entries:R}=yr(d,h);br(g,()=>{if(hr(e,m,o.plotTop,y,R),a)a.setAttribute("x1",String(m)),a.setAttribute("x2",String(m)),a.setAttribute("opacity","1");if(l)for(let x of l){for(let E of x)E.setAttribute("data-visible","false");x[h]?.setAttribute("data-visible","true")}},()=>{if(gr(e),a)a.setAttribute("opacity","0");if(l)for(let x of l)for(let E of x)E.setAttribute("data-visible","false")}),t.appendChild(g)}}function ve(e,t){return W(J(e.data,t))}function wr(e,t){let n=J(e.data,t);if(!Array.isArray(n))return;let r=n.filter((o)=>typeof o==="number"&&Number.isFinite(o));return r.length>0?r:void 0}function As(e){return e==="left"||e==="right"?e:void 0}function Ss(e){if(!M(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=As(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 xe(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=Ss(t);return n?[n]:[]})}function ue(e,t){return O(e.height)??t}function Ve(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function Vt(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function Bt(e,t){return{rows:ve(e,t),series:xe(e),height:ue(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 kr(e,t,n,r){let o=t.series.filter((u)=>u.yAxisId!=="right"),i=t.series.filter((u)=>u.yAxisId==="right"),s=t.showYAxisRight&&i.length>0,a=o.length>0?Ve(t.rows,o):1,l=s?Ve(t.rows,i):1,c=De(r,t.height,t.showYAxis,s),d=ie(r,t.height,n);if(t.showYAxis)nt(d,c,a,t.showGrid,Ie(e));if(s)zn(d,c,l,t.yAxisRightFormat);return Fe(d,c),{layout:c,svg:d,leftMax:a,rightMax:l}}function it(e,t){return e?(n)=>Ee(n,e,t):void 0}function Mr(e,t,n=le){let r=f("div","pf-chart pf-bar-chart"),o=Bt(e,t),{rows:i,series:s}=o;if(i.length===0||s.length===0)return r.textContent="No chart data",r;let{layout:a,svg:l,leftMax:c,rightMax:d}=kr(e,o,"Bar",n),u=a.plotWidth/i.length,h=u/(s.length+1);for(let m=0;m<i.length;m++)for(let v=0;v<s.length;v++){let g=s[v],y=i[m][g.dataKey];if(y===null||y===void 0)continue;let R=g.yAxisId==="right"?d:c,w=Math.max(0,Number(y)/R*a.plotHeight),k=a.plotLeft+m*u+v*h+h/2;l.appendChild(H("rect",{x:k,y:a.plotBottom-w,width:h*0.8,height:w,fill:g.color??_[v%_.length],rx:2}))}if(o.xAxisKey)Lt(l,i,o.xAxisKey,(m)=>a.plotLeft+m*u+u/2,a.plotBottom,it(o.xAxisFormat,t));if(o.showTooltip){let m=te(r,l),v=Ht(t,Ie(e),o.yAxisRightFormat);vr(m,l,i,s,a,o.tooltipXKey??o.xAxisKey,v,it(o.tooltipXFormat,t))}return se(r,s,o.showLegend),r.appendChild(l),r}function Ls(e,t,n,r){let o=[],i=()=>{if(o.length<2){o=[];return}let s=`M ${o[0].x},${n} `+o.map((a)=>`L ${a.x},${a.y}`).join(" ")+` L ${o[o.length-1].x},${n} Z`;e.appendChild(H("path",{d:s,fill:r,opacity:0.15})),o=[]};for(let s of t){if(s.isNull){i();continue}o.push(s)}i()}function Ns(e,t,n,r){let o="";for(let i of t){if(i.isNull)continue;let s=t.indexOf(i),a=s===0||t[s-1].isNull;o+=`${a?"M":"L"} ${i.x},${i.y} `}if(!o)return;e.appendChild(H("path",{d:o.trim(),fill:"none",stroke:n,"stroke-width":2,...r?{"stroke-dasharray":"6 3"}:{}}))}function Hs(e,t,n){let r=[];for(let o of t){let i=H("circle",{cx:o.x,cy:o.y,r:4,fill:n,class:"pf-data-dot","data-visible":"false"});if(i.style.pointerEvents="none",o.isNull)i.style.display="none";e.appendChild(i),r.push(i)}return r}function Ps(e,t){let n=H("line",{class:"pf-crosshair",x1:t.plotLeft,x2:t.plotLeft,y1:t.plotTop,y2:t.plotBottom,stroke:X,"stroke-width":1,"stroke-dasharray":"3 3",opacity:0});return e.appendChild(n),n}function _t(e,t,n=le){let r=f("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),o=Bt(e,t),{rows:i,series:s}=o;if(i.length===0||s.length===0)return r.textContent="No chart data",r;let a=e.type==="AreaChart",{layout:l,svg:c,leftMax:d,rightMax:u}=kr(e,o,a?"Area":"Line",n),h=(g)=>i.length===1?(l.plotLeft+l.plotRight)/2:l.plotLeft+g/(i.length-1)*l.plotWidth,m=[];for(let g=0;g<s.length;g++){let y=s[g],R=y.yAxisId==="right",w=R?u:d,k=y.color??_[g%_.length],x=i.map((E,A)=>{let F=E[y.dataKey],N=F===null||F===void 0,V=N?l.plotBottom:l.plotBottom-Number(F)/w*l.plotHeight;return{x:h(A),y:V,isNull:N}});if(a)Ls(c,x,l.plotBottom,k);Ns(c,x,k,R),m.push(Hs(c,x,k))}let v=Ps(c,l);if(o.xAxisKey)Lt(c,i,o.xAxisKey,h,l.plotBottom,it(o.xAxisFormat,t));if(o.showTooltip){let g=te(r,c),y=Ht(t,Ie(e),o.yAxisRightFormat);xr(g,c,i,s,l,o.tooltipXKey??o.xAxisKey,y,v,m,it(o.tooltipXFormat,t))}return se(r,s,o.showLegend),r.appendChild(c),r}function Rr(e,t){let n=f("div","pf-chart pf-pie-chart"),r=ve(e,t),o=xe(e),i=Math.min(ue(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=Vt(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 d=ie(i,i,"Pie"),u=i/2,h=i/2,m=i/2-10,v=b(e.tooltipXFormat),g=Te(e,t),y=r.map((x)=>Number(x[a]??0)),R=y.reduce((x,E)=>x+E,0);if(R===0)return n.textContent="No chart data",n.appendChild(d),n;let w=s?te(n,d):void 0,k=-Math.PI/2;for(let x=0;x<y.length;x++){let E=y[x]/R*2*Math.PI,A=k+E,F=E>Math.PI?1:0,N=u+m*Math.cos(k),V=h+m*Math.sin(k),ne=u+m*Math.cos(A),re=h+m*Math.sin(A),Z=_[x%_.length],oe=H("path",{d:`M ${u},${h} L ${N},${V} A ${m},${m} 0 ${F} 1 ${ne},${re} Z`,fill:Z});if(oe.style.cursor="default",w){let we=l?r[x][l]:void 0,D=we!=null?v?Ee(we,v,t):T(we):`Slice ${x+1}`,fe=`${(y[x]/R*100).toFixed(1)}%`,ae=u+m*0.6*Math.cos(k+E/2);pe(oe,w,ae,h,D,[{label:c[0].label??a,value:`${g(y[x])} (${fe})`,color:Z}])}d.appendChild(oe),k=A}return se(n,c,e.showLegend!==!1),n.appendChild(d),n}function Er(e,t){let n=f("div","pf-chart pf-radial-chart"),r=ve(e,t),o=xe(e),{valueKey:i,nameKey:s}=Vt(e,o);if(r.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(ue(e,300),300),l=a/2,c=a/2,d=a/2-10,u=Math.max(0,Math.min(O(e.innerRadius)??30,d-10)),h=O(e.startAngle)??180,m=O(e.endAngle)??0,v=r.map((A)=>Number(A[i]??0)),g=Math.max(...v,1),y=ie(a,a,"Radial"),R=(d-u)/r.length,w=Math.max(2,R*0.7),k=Te(e,t),x=e.showTooltip!==!1?te(n,y):void 0,E=[];for(let A=0;A<r.length;A++){let F=d-R*A-R/2,N=o[A]?.color??_[A%_.length],V=h+v[A]/g*(m-h),ne=s?r[A][s]:null,re=ne!=null?T(ne):o[A]?.label??i;E.push({dataKey:re||i,label:re||i,color:N}),y.appendChild(H("path",{d:Pt(l,c,F,h,m),fill:"none",stroke:ge,"stroke-width":w,"stroke-linecap":"round"}));let Z=H("path",{d:Pt(l,c,F,h,V),fill:"none",stroke:N,"stroke-width":w,"stroke-linecap":"round"});if(x){let oe=be(l,c,F,(h+V)/2);pe(Z,x,oe.x,oe.y,re||i,[{label:i,value:k(v[A]),color:N}])}y.appendChild(Z)}return se(n,E,e.showLegend!==!1),n.appendChild(y),n}function Tr(e,t){let n=f("div","pf-chart pf-radar-chart"),r=ve(e,t),o=xe(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(ue(e,300),320),d=c/2,u=c/2,h=c/2-24,m=r.length,v=Ve(r,o),g=(x)=>90-360*x/m,y=(x)=>x.map((E)=>`${E.x.toFixed(1)},${E.y.toFixed(1)}`).join(" "),R=ie(c,c,"Radar");if(l){for(let E=1;E<=4;E++){let A=h*E/4,F=Array.from({length:m},(N,V)=>be(d,u,A,g(V)));R.appendChild(H("polygon",{points:y(F),fill:"none",stroke:ge,"stroke-width":1}))}for(let E=0;E<m;E++){let A=be(d,u,h,g(E));R.appendChild(H("line",{x1:d,y1:u,x2:A.x,y2:A.y,stroke:ge,"stroke-width":1}))}}for(let x=0;x<m;x++){let E=be(d,u,h+12,g(x)),A=i?r[x][i]:null;R.appendChild(Se({x:E.x,y:E.y+3,"text-anchor":"middle","font-size":ee,fill:X},T(A)))}let w=e.showTooltip!==!1?te(n,R):void 0,k=Te(e,t);for(let x=0;x<o.length;x++){let E=o[x],A=E.color??_[x%_.length],F=r.map((N,V)=>be(d,u,Number(N[E.dataKey]??0)/v*h,g(V)));if(R.appendChild(H("polygon",{points:y(F),fill:s?A:"none","fill-opacity":s?0.2:0,stroke:A,"stroke-width":2})),!a&&!w)continue;for(let N=0;N<F.length;N++){let V=H("circle",{cx:F[N].x,cy:F[N].y,r:a?3:6,fill:a?A:"transparent","fill-opacity":a?1:0});if(w){let ne=i?r[N][i]:null,re=ne!=null?T(ne):E.label??E.dataKey,Z=[{label:E.label??E.dataKey,value:k(Number(r[N][E.dataKey]??0)),color:A}];pe(V,w,F[N].x,F[N].y,re,Z)}R.appendChild(V)}}return se(n,o,e.showLegend!==!1),n.appendChild(R),n}var Be=(e)=>String(Math.round(e*100)/100);function Ar(e,t,n=le){let r=f("div","pf-chart pf-scatter-chart"),o=ve(e,t),i=b(e.xAxis),s=b(e.yAxis),a=b(e.zAxis),l=xe(e),c=ue(e,300);if(o.length===0||!i||!s)return r.textContent="No chart data",r;let d=e.showGrid!==!1,u=l[0]?.color??_[0],h=Te(e,t,Be),m=o.map((D)=>Number(D[i]??0)),v=o.map((D)=>Number(D[s]??0)),g=$e(Math.min(...m),Math.max(...m),5),y=$e(Math.min(...v),Math.max(...v),4),R=g[0],w=g[g.length-1]-R||1,k=y[0],x=y[y.length-1]-k||1,E=a?o.map((D)=>Number(D[a]??0)):[],A=a?Math.max(...E,1):1,F=a?18:4,N=De(n,c,!0),V=ie(n,c,"Scatter"),ne=N.plotLeft+F,re=Math.max(1,N.plotWidth-F*2),Z=(D)=>ne+(D-R)/w*re,oe=(D)=>N.plotBottom-(D-k)/x*N.plotHeight;for(let D=0;D<y.length;D++){let fe=y[D],ae=oe(fe);if(V.appendChild(Se({x:N.plotLeft-6,y:ae+3,"text-anchor":"end","font-size":ee,fill:X},h(fe))),d&&D>0)V.appendChild(H("line",{x1:N.plotLeft,y1:ae,x2:N.plotRight,y2:ae,stroke:ge,"stroke-width":1,"stroke-dasharray":"4 3"}))}Fe(V,N);for(let D of g)V.appendChild(Se({x:Z(D),y:N.plotBottom+14,"text-anchor":"middle","font-size":ee,fill:X},Be(D)));let we=e.showTooltip!==!1?te(r,V):void 0;for(let D=0;D<o.length;D++){let fe=Z(m[D]),ae=oe(v[D]),Qr=a?4+Math.sqrt(E[D]/A)*14:4,on=H("circle",{cx:fe,cy:ae,r:Qr,fill:u,"fill-opacity":a?0.6:0.85});if(we){let eo=[{label:i,value:h(m[D]),color:u},{label:s,value:h(v[D]),color:u},...a?[{label:a,value:h(E[D]),color:u}]:[]],to=l[0]?.label??"Point";pe(on,we,fe,ae,to,eo)}V.appendChild(on)}return se(r,l,e.showLegend!==!1),r.appendChild(V),r}function Sr(e,t,n=le){let r=f("div","pf-chart pf-histogram"),o=wr(e,t);if(!o)return r.textContent="No data",r;let i=O(e.bins)??10,s=ue(e,200),a=b(e.color)??_[0],l=Math.min(...o),d=(Math.max(...o)-l)/i||1,u=Array(i).fill(0);for(let x of o){let E=Math.min(Math.floor((x-l)/d),i-1);u[E]++}let h=Math.max(...u),m=e.showYAxis!==!1,v=e.showXAxis!==!1,g=$e(0,Math.max(1,h)).at(-1)??h,y=De(n,s,m),R=ie(n,s,"Histogram");if(m)nt(R,y,g,e.showGrid!==!1);Fe(R,y);let w=e.showTooltip!==!1?te(r,R):void 0,k=y.plotWidth/i;for(let x=0;x<i;x++){let E=g>0?u[x]/g*y.plotHeight:0,A=y.plotLeft+x*k,F=H("rect",{x:A+1,y:y.plotBottom-E,width:Math.max(1,k-2),height:E,fill:a,rx:2});if(w){let N=`${Be(l+x*d)} – ${Be(l+(x+1)*d)}`;pe(F,w,A+k/2,y.plotBottom-E,N,[{label:"Count",value:u[x],color:a}])}R.appendChild(F)}if(v)for(let[x,E]of[[0,l],[i/2,l+i/2*d],[i,l+i*d]])R.appendChild(Se({x:y.plotLeft+x*k,y:y.plotBottom+14,"text-anchor":x===0?"start":x===i?"end":"middle","font-size":ee,fill:X},Be(E)));return r.appendChild(R),r}function Lr(){p("BarChart",Ae(Mr)),p("LineChart",Ae(_t)),p("AreaChart",Ae(_t)),p("PieChart",Rr),p("RadarChart",Tr),p("ScatterChart",Ae(Ar)),p("RadialChart",Er),p("Histogram",Ae(Sr))}function Hr(){p("Table",Os),p("TableHead",(e,t)=>zt(e)?st("thead",e,t):Nr(e,t)),p("TableHeader",(e,t)=>zt(e)?st("thead",e,t):Nr(e,t)),p("TableBody",(e,t)=>st("tbody",e,t)),p("TableFooter",(e,t)=>st("tfoot",e,t)),p("TableRow",Ds),p("TableCell",$s),p("TableCaption",Fs),p("ExpandableRow",Is)}function zt(e){return(e.children?.length??0)>0}function Os(e,t){let n=document.createElement("table");n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",L(e,n,t);let r=Array.from(n.children).find((o)=>o.tagName==="CAPTION");if(r&&r!==n.firstChild)n.insertBefore(r,n.firstChild);return n}function st(e,t,n){let r=document.createElement(e);return r.className=`pf-${e}`,L(t,r,n),r}function Ds(e,t){let n=document.createElement("tr");return n.className="pf-table-row",L(e,n,t),n}function Nr(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.setAttribute("scope","col"),n.textContent=C(e.content,t),n}function $s(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",e.colSpan!=null)n.colSpan=Number(e.colSpan);if(e.rowSpan!=null)n.rowSpan=Number(e.rowSpan);if(e.content!=null&&!zt(e))n.textContent=C(e.content,t);else L(e,n,t);return n}function Fs(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.textContent=C(e.content,t),n}function Is(e,t){let n=f("div","pf-expandable-row"),r=f("div","pf-expandable-row-summary");if(r.setAttribute("role","button"),r.setAttribute("aria-expanded","false"),r.tabIndex=0,r.appendChild(f("span","pf-expandable-arrow")),typeof e.summary==="string"){let a=f("span");a.textContent=C(e.summary,t),r.appendChild(a)}else for(let a of me(e.summary))r.appendChild(B(a,t));let o=f("div","pf-expandable-row-detail");o.style.display="none",L(e,o,t);let i=!1,s=()=>{i=!i,o.style.display=i?"block":"none",r.setAttribute("aria-expanded",i?"true":"false")};return r.addEventListener("click",s),r.addEventListener("keydown",(a)=>{if(a.key==="Enter"||a.key===" ")a.preventDefault(),s()}),n.appendChild(r),n.appendChild(o),n}var Pr=!1;function at(){if(Pr)return;Pr=!0;let e=new Set(Tt());Dn(),In(),Bn(),Wn(),Zn(),er(),tr(),nr(),ir(),lr(),mr(),Lr(),Hr(),An(Tt().filter((t)=>!e.has(t)))}function Kt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Wt(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Jt(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Kt(n)}: ${Wt(r)};`).join(`
|
|
7
|
+
`)}function Or(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
|
|
8
|
+
${Jt(e.light)}
|
|
9
|
+
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=Jt(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
|
-
${
|
|
13
|
+
${Jt(e.dark," ")}
|
|
14
14
|
}
|
|
15
15
|
}`)}return t.join(`
|
|
16
|
-
`)}function Se(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function Dt(e,t){if(!t)return;if(t.light)for(let[n,o]of Object.entries(t.light))e.style.setProperty(`--${Ot(n)}`,$t(o));if(t.dark){let o=document.getElementById("prefab-dark-theme");if(!o)o=document.createElement("style"),o.id="prefab-dark-theme",document.head.appendChild(o);o.textContent=co({dark:t.dark})}}function It(e,t){if(!e||typeof document>"u")return;let n=(o)=>{for(let[r,i]of Object.entries(e))if(ds(r,o))o.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function ds(e,t){let n=e.toLowerCase().split("+").map((i)=>i.trim()),o=n[n.length-1],r=new Set(n.slice(0,-1));if(r.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(r.has("shift")!==t.shiftKey)return!1;if(r.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===o}var po='<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>',uo='<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>',fo={"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 ps(e,t){try{let o=localStorage.getItem(t);if(o==="light"||o==="dark")return o}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 jt(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",o=t?.storageKey??"prefab-theme",r=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=fo[n]??fo["top-right"];for(let d of a.split(";")){let[g,m]=d.split(":").map((b)=>b.trim());if(g&&m)s.style.setProperty(g,m)}s.addEventListener("mouseenter",()=>{s.style.opacity="1"}),s.addEventListener("mouseleave",()=>{s.style.opacity="0.7"});function l(d){if(Se(e,d),r)Se(document.documentElement,d);s.innerHTML=d==="dark"?uo:po;try{localStorage.setItem(o,d)}catch{}}let c=ps(e,o);l(c),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";l(d==="dark"?"light":"dark")}),e.appendChild(s);let u;if(r)u=new MutationObserver((d)=>{for(let g of d)if(g.type==="attributes"&&g.attributeName==="data-theme"){let m=document.documentElement.getAttribute("data-theme");if((m==="light"||m==="dark")&&m!==e.getAttribute("data-theme")){Se(e,m),s.innerHTML=m==="dark"?uo:po;try{localStorage.setItem(o,m)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function Ze(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},o=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(r,i){let s=await o(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:r,arguments:i}})});if(!s.ok)throw Error(`MCP tool call failed: ${s.status} ${s.statusText}`);let a=await s.json(),l=H(a);if(!l)return a;if(Boolean(l.error))throw Error(y(H(l.error)?.message)??"MCP tool call returned error");let u=K(H(l.result)?.content??l.content);for(let d of u)if(d.type==="text"&&typeof d.text==="string"){try{return JSON.parse(d.text)}catch{}return d.text}return l.result??l},async sendMessage(r){await o(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:r})})}}}function Qe(){return{callTool(e){return N.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return N.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var mo="0.3.22";var us=["light","dark","auto"],fs=["inline","fullscreen","pip"];function go(e){return k(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||k(e.payload))}function et(e){return typeof e==="boolean"?e:void 0}function ho(e){let t=H(e.capabilities)??{},n=H(e.theme),o=H(e.toolInput),r=H(e.meta);return{hostName:y(e.hostName),hostVersion:y(e.hostVersion),capabilities:{toast:et(t.toast),clipboard:et(t.clipboard),navigation:et(t.navigation),messaging:et(t.messaging),displayModes:Ft(t.displayModes)},...n&&{theme:ms(n)},...o&&{toolInput:o},...r&&{meta:r}}}function ms(e){let t=y(e.fontCss);return{...tt({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Ft(e){let t=Array.isArray(e)?e:[];return fs.filter((n)=>t.includes(n))}function tt(e){let t={},n=us.find((s)=>s===e.theme);if(n)t.colorScheme=n;let o=H(e.styles),r=H(o?.variables);if(r)t.variables=Object.fromEntries(Object.entries(r).filter((s)=>typeof s[1]==="string"));let i=y(H(o?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function gs(e){return k(e)&&e.jsonrpc==="2.0"}class Ae{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=ys();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let o=n.data;if(gs(o)){this.handleJsonRpc(o);return}if(!go(o)||!o.type.startsWith("prefab:"))return;let r=o;if(r.type==="prefab:tool-call-response"&&r.id){let s=this.pending.get(r.id);if(s){if(this.pending.delete(r.id),r.payload?.error!=null)s.reject(Error(v(r.payload.error)));else s.resolve(r.payload?.result);return}}let i=this.listeners.get(r.type);if(i)for(let s of i)s(r.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((o)=>o.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 yo;let t=-1,n=-1,o=(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})},r=new ResizeObserver((s)=>{for(let a of s)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];o(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();o(Math.ceil(l.width),Math.ceil(l.height))}});r.observe(e);let i=e.getBoundingClientRect();return o(Math.ceil(i.width),Math.ceil(i.height)),()=>r.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 o=(r)=>{if(r.uri!==e)return;t(r.contents??r.data??r)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",o),this.sendRpcRequest("resources/subscribe",{uri:e}).catch((r)=>{this.off("prefab:resource-updated",o),n?.(r)});else this.on("prefab:resource-updated",o),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",o),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e}).catch(yo);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 o=!1,r=(i)=>{if(o)return;o=!0,this.off("prefab:init-response",r),this.protocol="prefab",this._hostSupportsSubscriptions=H(i.capabilities)?.subscriptions===!0,t(ho(i))};this.on("prefab:init-response",r),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!o)o=!0,this.off("prefab:init-response",r),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((o,r)=>{this.pending.set(n,{resolve:o,reject:r}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),r(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 o=window.parent!==window?window.parent:window,r={type:e,payload:t,id:n};o.postMessage(r,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let o=this.rpcPending.get(e.id);if(o)if(this.rpcPending.delete(e.id),e.error)o.reject(Error(e.error.message));else o.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",{...tt(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 o=++this.rpcIdCounter,r=!1;this.rpcPending.set(o,{resolve:(i)=>{if(r)return;r=!0,this.protocol="jsonrpc";let s=H(i)??{},a=H(s.hostInfo)??{},l=H(s.hostContext)??{},c=H(s.hostCapabilities)??{},u=typeof l.theme==="string"||k(l.styles)?tt(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let d=H(c.resources);this._hostSupportsSubscriptions=c.subscriptions===!0||d?.subscribe===!0,t({hostName:y(a.name),hostVersion:y(a.version),capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:Ft(l.availableDisplayModes)},theme:u,toolInput:void 0,meta:l})},reject:(i)=>{if(r)return;r=!0,n(i)}}),this.postJsonRpc({jsonrpc:"2.0",id:o,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:mo},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!r)r=!0,this.rpcPending.delete(o),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((o,r)=>{this.rpcPending.set(n,{resolve:o,reject:r}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),r(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 o of n)o(t)}}var yo=()=>{};function Bt(e,t){if(t.variables)for(let[n,o]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,o);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)hs(t.fontCss)}function hs(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 nt(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function ys(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(k(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(o)=>{Reflect.apply(n,t,[o])}}}}catch{return}return}var bo=["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 vo=new Set(bo);function _t(e,t={}){let n=[],o=t.strict??!1;if(!k(e))return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let r=e,i=r.$prefab;if(!k(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(r.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Vt(r.view,"$.view",n,o);if(r.state!==void 0){if(r.state===null||typeof r.state!=="object"||Array.isArray(r.state))n.push({path:"$.state",message:"state must be a plain object"})}if(r.theme!==void 0)Cs(r.theme,n);if(r.css!==void 0)xo(r.css,"$.css",n);if(r.stylesheets!==void 0)xo(r.stylesheets,"$.stylesheets",n);if(r.mode!==void 0&&r.mode!=="light"&&r.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});let s=r.defs;if(s!==void 0)if(!k(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Vt(c,`$.defs.${l}`,n,o);let a=r.keyBindings;if(a!==void 0)if(!k(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))zt(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function Vt(e,t,n,o){if(!k(e)){n.push({path:t,message:"Component must be a plain object"});return}let r=e;if(typeof r.type!=="string"||r.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(o&&!vo.has(r.type))n.push({path:`${t}.type`,message:`Unknown component type: "${r.type}"`});if(r.children!==void 0)if(!Array.isArray(r.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let s=0;s<r.children.length;s++)Vt(r.children[s],`${t}.children[${s}]`,n,o);let i=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let s of i)if(r[s]!==void 0)zt(r[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(r)){if(s==="type"||bs.has(s)||i.includes(s))continue;if(Co(a)||Array.isArray(a)&&a.some(Co))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var bs=new Set(["children","fallback","trigger","empty","else","summary"]);function Co(e){return k(e)&&typeof e.type==="string"&&vo.has(e.type)}function zt(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)zt(e[i],`${t}[${i}]`,n);return}if(!k(e)){n.push({path:t,message:"Action must be an object or array of objects"});return}let o=e,r=typeof o.action==="string"&&o.action.length>0?o.action:typeof o.type==="string"&&o.type.length>0?o.type:void 0;if(r===void 0){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if(r.toLowerCase()==="showtoast"){if(typeof o.message!=="string"||o.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function xo(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let o=0;o<e.length;o++)if(typeof e[o]!=="string")n.push({path:`${t}[${o}]`,message:"must be a string"})}function Cs(e,t){if(!k(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(!k(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var z={mount(e,t,n){if(Ye(),n?.validate!==!1)for(let w of _t(t).errors)N.warn(`wire validation ${w.path}: ${w.message}`);let o=t,r={tracked:[],evalBlocked:!1};if(o.pipes)for(let[w,R]of Object.entries(o.pipes))wo(w,R,r);let i=new Re(o.state),s=n?.transport,a;if(!s)a=Qe();else if("callTool"in s)a=s;else a=Ze(s);let l=n?.onToast??vs,c=new yt;function u(w){if(!z.isPrefabData(w))return;let R=w;if(o=R,R.state)i.merge(R.state);if(R.defs)g.defs=R.defs;if(R.theme)Dt(e,R.theme);if(R.mode)ko(e,R.mode);if(R.pipes)for(let[S,T]of Object.entries(R.pipes))wo(S,T,r);for(let S of m)S.remove();if(m.length=0,m.push(...So(R.css,R.stylesheets)),Ro(e,R.layout),b?.(),b=void 0,R.keyBindings)b=It(R.keyBindings,(S)=>{D(O(S,{store:i,transport:a,scope:{},rerender:()=>E(),remount:u,onToast:l}),"keyBinding")});E(),d(R)}function d(w){if(w.onMount!=null)D(O(w.onMount,g),"onMount")}let g={store:i,scope:{},transport:a,rerender:()=>E(),remount:u,onToast:l,defs:o.defs,destroyRegistry:c};if(Dt(e,o.theme),o.mode)ko(e,o.mode);Ro(e,o.layout);let m=So(o.css,o.stylesheets),b;if(o.keyBindings)b=It(o.keyBindings,(w)=>{D(O(w,{store:i,transport:a,scope:{},rerender:()=>E(),remount:u,onToast:l}),"keyBinding")});let h,x=n?.themeToggle??!0;if(x!==!1)h=jt(e,typeof x==="object"?x:void 0);function E(){c.flush();let w=e.querySelector(".pf-theme-toggle");e.innerHTML="";let R=V(o.view,g);if(e.appendChild(R),w)e.appendChild(w)}return E(),d(o),{rerender:()=>E(),update(w){if(i.merge(w.update.state),E(),w.update.actions!=null)D(O(w.update.actions,g),"update action")},store:i,destroy(){c.flush(),h?.(),b?.(),rn(),ln();for(let w of m)w.remove();for(let w of r.tracked)lt(w);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 xs(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function wo(e,t,n){if(on.has(e)){N.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(He(e)!=null){N.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let o=Function("return ("+t+")")();if(!Zt(o)){N.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}at(e,o),n.tracked.push(e)}catch(o){if(xs(o)){n.evalBlocked=!0,N.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}N.warn(`wire pipe "${e}" — failed to hydrate:`,o)}}function vs(e){if(typeof document>"u")return;let t=ks(),n=document.createElement("div"),o=e.variant??"default";n.className=`pf-toast${o!=="default"?` pf-toast--${o}`:""}`,n.setAttribute("data-variant",o),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let r=document.createElement("div");if(r.textContent=e.message,r.style.fontWeight="500",n.appendChild(r),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 ko(e,t){if(Se(e,t),typeof document<"u")Se(document.documentElement,t)}function ws(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function So(e,t){let n=[];if(typeof document>"u")return n;for(let o of e??[]){let r=document.createElement("style");r.textContent=o,r.dataset.prefab="injected",document.head.appendChild(r),n.push(r)}for(let o of t??[])if(ws(o)){let r=document.createElement("link");r.rel="stylesheet",r.href=o,r.dataset.prefab="injected",document.head.appendChild(r),n.push(r)}else{let r=document.createElement("style");r.textContent=o,r.dataset.prefab="injected",document.head.appendChild(r),n.push(r)}return n}function Ro(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 ks(){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:z}),Object.assign(window,{prefab:{app:ot,mount:z.mount.bind(z),isPrefabData:z.isPrefabData.bind(z),isPrefabUpdate:z.isPrefabUpdate.bind(z),Bridge:Ae,isIframe:nt,registerPipe:at,unregisterPipe:lt,listPipes:Qt,registerComponent:p,createThemeToggle:jt,validateWireFormat:_t,setLogLevel:qt}});let e=Reflect.get(window,"__PREFAB_DATA__");if(z.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)z.mount(t,e)}}async function ot(e){Ye();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&nt(),o,r,i={capabilities:{}};if(n)r=new Ae(e?.hostOrigin),r.connect(),i=await r.initialize(e?.capabilities??{toolInput:!0}),o=r.createTransport();else if(e?.transport)o=Ze(e.transport);else o=Qe();if(i.theme&&typeof document<"u")Bt(document.documentElement,i.theme);if(typeof document<"u"&&!r)Rs();let s,a,l,c,u,d=i.toolInput,g;if(r)r.on("prefab:tool-input",(h)=>{let x=H(h.args)??h;if(s)s(x);else d=x}),r.on("prefab:tool-result",(h)=>{let x=h.result??h;if(a)a(x);else g=x}),r.on("prefab:tool-cancelled",()=>{l?.()}),r.on("prefab:tool-input-partial",(h)=>{c?.(H(h.args)??h)}),r.on("prefab:theme-update",(h)=>{if(typeof document<"u")Bt(document.documentElement,h)}),r.on("prefab:host-context-changed",(h)=>{u?.(h)});function m(h,...x){let E=Wt(h),w=new Re,R={store:w,scope:{},transport:o,rerender:()=>S(),onToast:void 0};function S(){E.innerHTML="";for(let T of x)E.appendChild(V(T,R))}return S(),{rerender:S,store:w,destroy:()=>{E.innerHTML=""}}}return{callTool:(h,x={})=>o.callTool(h,x),sendMessage:(h)=>o.sendMessage(h),onToolInput:(h)=>{if(s=h,d){let x=d;d=void 0,queueMicrotask(()=>h(x))}},onToolResult:(h)=>{if(a=h,g!==void 0){let x=g;g=void 0,queueMicrotask(()=>h(x))}},onToolCancelled:(h)=>{l=h},onToolInputPartial:(h)=>{c=h},onHostContextChanged:(h)=>{u=h},render:m,mount:(h,x,E)=>{let w=Wt(h);return z.mount(w,x,{transport:o,...E})},requestMode:(h)=>r?.requestMode(h),openLink:(h,x)=>{if(r)r.openLink(h,x);else if(typeof window<"u")window.open(h,x??"_blank")},updateContext:(h)=>{if(r)r.updateContext(h)},setupAutoResize:(h)=>{if(!r)return Ss;let x=typeof h==="string"?Wt(h):h;return r.setupAutoResize(x)},notifyPreferredSize:(h)=>{if(r)r.notifyPreferredSize(h)},host:i,capabilities:i.capabilities,theme:i.theme,transport:o,destroy:()=>r?.disconnect()}}var Ss=()=>{};function Wt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`Element not found: ${e}`);return t}return e}function Rs(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let o=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",o)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var Kt=it("auto"),Eo="#root";function Jt(e){return z.isPrefabData(e)}function To(e){return z.isPrefabUpdate(e)}function Mo(e){if(Jt(e))return e;if(k(e)){let t=e;if(Jt(t.structuredContent))return t.structuredContent;if(Array.isArray(t.content)){for(let n of t.content)if(k(n)&&n.type==="text"&&typeof n.text==="string")try{let o=JSON.parse(n.text);if(Jt(o))return o}catch{}}}return null}async function No(){let e=document.querySelector(Eo);if(!e){Kt.error(`Mount target "${Eo}" not found`);return}let t=e,n=await ot();n.setupAutoResize(t);let o;function r(i){if(o)o.destroy();if(o=n.mount(t,i),i.layout)n.notifyPreferredSize(i.layout)}n.onToolResult((i)=>{let s=Mo(i);if(s)r(s);else if(To(i)&&o)o.update(i)}),n.onToolInput((i)=>{let s=Mo(i);if(s)r(s);else if(To(i)&&o)o.update(i)})}function Es(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{No().catch((e)=>{Kt.error("Boot failed:",e)})},{once:!0});else queueMicrotask(()=>{No().catch((e)=>{Kt.error("Boot failed:",e)})})}Es();})();
|
|
16
|
+
`)}function He(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function Gt(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Kt(n)}`,Wt(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=Or({dark:t.dark})}}function qt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(js(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function js(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 Dr='<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>',$r='<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>',Vs=new Set(["top-right","top-left","bottom-right","bottom-left"]);function Bs(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 Ut(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"),s.type="button",s.setAttribute("data-position",Vs.has(n)?n:"top-right");function a(d){if(He(e,d),o)He(document.documentElement,d);s.innerHTML=d==="dark"?$r:Dr;try{localStorage.setItem(r,d)}catch{}}let l=Bs(e,r);a(l),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";a(d==="dark"?"light":"dark")}),e.appendChild(s);let c;if(o)c=new MutationObserver((d)=>{for(let u of d)if(u.type==="attributes"&&u.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){He(e,h),s.innerHTML=h==="dark"?$r:Dr;try{localStorage.setItem(r,h)}catch{}}}}),c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{c?.disconnect(),s.remove()}}function lt(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(),l=P(a);if(!l)return a;if(Boolean(l.error))throw Error(b(P(l.error)?.message)??"MCP tool call returned error");let d=W(P(l.result)?.content??l.content);for(let u of d)if(u.type==="text"&&typeof u.text==="string"){try{return JSON.parse(u.text)}catch{}return u.text}return l.result??l},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function ct(){return{callTool(e){return S.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return S.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var Fr="0.3.24";var _s=["light","dark","auto"],zs=["inline","fullscreen","pip"];function Ir(e){return M(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||M(e.payload))}function dt(e){return typeof e==="boolean"?e:void 0}function jr(e){let t=P(e.capabilities)??{},n=P(e.theme),r=P(e.toolInput),o=P(e.meta);return{hostName:b(e.hostName),hostVersion:b(e.hostVersion),capabilities:{toast:dt(t.toast),clipboard:dt(t.clipboard),navigation:dt(t.navigation),messaging:dt(t.messaging),displayModes:Xt(t.displayModes)},...n&&{theme:Js(n)},...r&&{toolInput:r},...o&&{meta:o}}}function Js(e){let t=b(e.fontCss);return{...pt({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Xt(e){let t=Array.isArray(e)?e:[];return zs.filter((n)=>t.includes(n))}function pt(e){let t={},n=_s.find((s)=>s===e.theme);if(n)t.colorScheme=n;let r=P(e.styles),o=P(r?.variables);if(o)t.variables=Object.fromEntries(Object.entries(o).filter((s)=>typeof s[1]==="string"));let i=b(P(r?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function Ks(e){return M(e)&&e.jsonrpc==="2.0"}class _e{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=Gs();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(Ks(r)){this.handleJsonRpc(r);return}if(!Ir(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(T(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 Vr;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(Vr);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=P(i.capabilities)?.subscriptions===!0,t(jr(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",{...pt(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=P(i)??{},a=P(s.hostInfo)??{},l=P(s.hostContext)??{},c=P(s.hostCapabilities)??{},d=typeof l.theme==="string"||M(l.styles)?pt(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let u=P(c.resources);this._hostSupportsSubscriptions=c.subscriptions===!0||u?.subscribe===!0,t({hostName:b(a.name),hostVersion:b(a.version),capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:Xt(l.availableDisplayModes)},theme:d,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:Fr},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 Vr=()=>{};function Zt(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)Ws(t.fontCss)}function Ws(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 ut(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Gs(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(M(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(r)=>{Reflect.apply(n,t,[r])}}}}catch{return}return}var Br=["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 Jr=new Set(Br);function Qt(e,t={}){let n=[],r=t.strict??!1;if(!M(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(!M(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 Yt(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)Us(o.theme,n);if(o.css!==void 0)zr(o.css,"$.css",n);if(o.stylesheets!==void 0)zr(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(!M(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Yt(c,`$.defs.${l}`,n,r);let a=o.keyBindings;if(a!==void 0)if(!M(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))en(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function Yt(e,t,n,r){if(!M(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&&!Jr.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++)Yt(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)en(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||qs.has(s)||i.includes(s))continue;if(_r(a)||Array.isArray(a)&&a.some(_r))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var qs=new Set(["children","fallback","trigger","empty","else","summary"]);function _r(e){return M(e)&&typeof e.type==="string"&&Jr.has(e.type)}function en(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)en(e[i],`${t}[${i}]`,n);return}if(!M(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 zr(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 Us(e,t){if(!M(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(!M(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var K={mount(e,t,n){if(at(),e.classList.add("pf-app-root"),n?.validate!==!1)for(let w of Qt(t).errors)S.warn(`wire validation ${w.path}: ${w.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[w,k]of Object.entries(r.pipes))Kr(w,k,o);let i=new Pe(r.state),s=n?.transport,a;if(!s)a=ct();else if("callTool"in s)a=s;else a=lt(s);let l=n?.onToast??Zs,c=new Et;function d(w){if(!K.isPrefabData(w))return;let k=w;if(r=k,k.state)i.merge(k.state);if(k.defs)h.defs=k.defs;if(k.theme)Gt(e,k.theme);if(k.mode)Wr(e,k.mode);if(k.pipes)for(let[x,E]of Object.entries(k.pipes))Kr(x,E,o);for(let x of m)x.remove();if(m.length=0,m.push(...Gr(k.css,k.stylesheets)),qr(e,k.layout),v?.(),v=void 0,k.keyBindings)v=qt(k.keyBindings,(x)=>{j(I(x,{store:i,transport:a,scope:{},rerender:()=>R(),remount:d,onToast:l}),"keyBinding")});R(),u(k)}function u(w){if(w.onMount!=null)j(I(w.onMount,h),"onMount")}let h={store:i,scope:{},transport:a,rerender:()=>R(),remount:d,onToast:l,defs:r.defs,destroyRegistry:c};if(Gt(e,r.theme),r.mode)Wr(e,r.mode);qr(e,r.layout);let m=Gr(r.css,r.stylesheets),v;if(r.keyBindings)v=qt(r.keyBindings,(w)=>{j(I(w,{store:i,transport:a,scope:{},rerender:()=>R(),remount:d,onToast:l}),"keyBinding")});let g,y=n?.themeToggle??!0;if(y!==!1)g=Ut(e,typeof y==="object"?y:void 0);function R(){c.flush();let w=e.querySelector(".pf-theme-toggle");e.innerHTML="";let k=B(r.view,h);if(e.appendChild(k),w)e.appendChild(w)}return R(),u(r),{rerender:()=>R(),update(w){if(i.merge(w.update.state),R(),w.update.actions!=null)j(I(w.update.actions,h),"update action")},store:i,destroy(){c.flush(),g?.(),v?.(),bn(),vn();for(let w of m)w.remove();for(let w of o.tracked)bt(w);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 Xs(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function Kr(e,t,n){if(gn.has(e)){S.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(ze(e)!=null){S.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(!pn(r)){S.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}gt(e,r),n.tracked.push(e)}catch(r){if(Xs(r)){n.evalBlocked=!0,S.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}S.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function Zs(e){if(typeof document>"u")return;let t=Qs(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.setAttribute("role",r==="error"?"alert":"status");let o=document.createElement("div");if(o.className="pf-toast-title",o.textContent=e.message,n.appendChild(o),e.description){let s=document.createElement("div");s.className="pf-toast-description",s.textContent=e.description,n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.classList.add("pf-toast--leaving"),setTimeout(()=>n.remove(),300)},i)}function Wr(e,t){if(He(e,t),typeof document<"u")He(document.documentElement,t)}function Ys(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function Gr(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(Ys(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 qr(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 Qs(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.className="pf-toast-region",t.setAttribute("aria-live","polite"),document.body.appendChild(t);return t}if(typeof window<"u"){Object.assign(window,{PrefabRenderer:K}),Object.assign(window,{prefab:{app:ft,mount:K.mount.bind(K),isPrefabData:K.isPrefabData.bind(K),isPrefabUpdate:K.isPrefabUpdate.bind(K),Bridge:_e,isIframe:ut,registerPipe:gt,unregisterPipe:bt,listPipes:un,registerComponent:p,createThemeToggle:Ut,validateWireFormat:Qt,setLogLevel:ln}});let e=Reflect.get(window,"__PREFAB_DATA__");if(K.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)K.mount(t,e)}}async function ft(e){at();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&ut(),r,o,i={capabilities:{}};if(n)o=new _e(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=lt(e.transport);else r=ct();if(i.theme&&typeof document<"u")Zt(document.documentElement,i.theme);if(typeof document<"u"&&!o)ta();let s,a,l,c,d,u=i.toolInput,h;if(o)o.on("prefab:tool-input",(g)=>{let y=P(g.args)??g;if(s)s(y);else u=y}),o.on("prefab:tool-result",(g)=>{let y=g.result??g;if(a)a(y);else h=y}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(g)=>{c?.(P(g.args)??g)}),o.on("prefab:theme-update",(g)=>{if(typeof document<"u")Zt(document.documentElement,g)}),o.on("prefab:host-context-changed",(g)=>{d?.(g)});function m(g,...y){let R=tn(g),w=new Pe,k={store:w,scope:{},transport:r,rerender:()=>x(),onToast:void 0};function x(){R.innerHTML="";for(let E of y)R.appendChild(B(E,k))}return x(),{rerender:x,store:w,destroy:()=>{R.innerHTML=""}}}return{callTool:(g,y={})=>r.callTool(g,y),sendMessage:(g)=>r.sendMessage(g),onToolInput:(g)=>{if(s=g,u){let y=u;u=void 0,queueMicrotask(()=>g(y))}},onToolResult:(g)=>{if(a=g,h!==void 0){let y=h;h=void 0,queueMicrotask(()=>g(y))}},onToolCancelled:(g)=>{l=g},onToolInputPartial:(g)=>{c=g},onHostContextChanged:(g)=>{d=g},render:m,mount:(g,y,R)=>{let w=tn(g);return K.mount(w,y,{transport:r,...R})},requestMode:(g)=>o?.requestMode(g),openLink:(g,y)=>{if(o)o.openLink(g,y);else if(typeof window<"u")window.open(g,y??"_blank")},updateContext:(g)=>{if(o)o.updateContext(g)},setupAutoResize:(g)=>{if(!o)return ea;let y=typeof g==="string"?tn(g):g;return o.setupAutoResize(y)},notifyPreferredSize:(g)=>{if(o)o.notifyPreferredSize(g)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var ea=()=>{};function tn(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`Element not found: ${e}`);return t}return e}function ta(){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 rn=mt("auto"),Ur="#root";function nn(e){return K.isPrefabData(e)}function Xr(e){return K.isPrefabUpdate(e)}function Zr(e){if(nn(e))return e;if(M(e)){let t=e;if(nn(t.structuredContent))return t.structuredContent;if(Array.isArray(t.content)){for(let n of t.content)if(M(n)&&n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(nn(r))return r}catch{}}}return null}async function Yr(){let e=document.querySelector(Ur);if(!e){rn.error(`Mount target "${Ur}" not found`);return}let t=e,n=await ft();n.setupAutoResize(t);let r;function o(i){if(r)r.destroy();if(r=n.mount(t,i),i.layout)n.notifyPreferredSize(i.layout)}n.onToolResult((i)=>{let s=Zr(i);if(s)o(s);else if(Xr(i)&&r)r.update(i)}),n.onToolInput((i)=>{let s=Zr(i);if(s)o(s);else if(Xr(i)&&r)r.update(i)})}function na(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{Yr().catch((e)=>{rn.error("Boot failed:",e)})},{once:!0});else queueMicrotask(()=>{Yr().catch((e)=>{rn.error("Boot failed:",e)})})}na();})();
|