@maxhealth.tech/prefab 0.3.20 → 0.3.22
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 +24 -0
- package/dist/a2ui/browser.d.ts.map +1 -1
- package/dist/a2ui/browser.js +15 -2
- package/dist/a2ui/browser.js.map +1 -1
- package/dist/a2ui/catalog.d.ts.map +1 -1
- package/dist/a2ui/catalog.js +2 -1
- package/dist/a2ui/catalog.js.map +1 -1
- package/dist/a2ui/control.d.ts.map +1 -1
- package/dist/a2ui/control.js +6 -4
- package/dist/a2ui/control.js.map +1 -1
- package/dist/a2ui/emit.d.ts +3 -1
- package/dist/a2ui/emit.d.ts.map +1 -1
- package/dist/a2ui/emit.js +4 -7
- package/dist/a2ui/emit.js.map +1 -1
- package/dist/a2ui/index.d.ts +1 -1
- package/dist/a2ui/index.d.ts.map +1 -1
- package/dist/a2ui/table.d.ts.map +1 -1
- package/dist/a2ui/table.js +4 -8
- package/dist/a2ui/table.js.map +1 -1
- package/dist/a2ui.min.js +1 -1
- package/dist/auto/index.d.ts.map +1 -1
- package/dist/auto/index.js +7 -10
- package/dist/auto/index.js.map +1 -1
- package/dist/components/form/index.js.map +1 -1
- package/dist/core/component.d.ts.map +1 -1
- package/dist/core/component.js +5 -3
- package/dist/core/component.js.map +1 -1
- package/dist/core/guards.d.ts +4 -0
- package/dist/core/guards.d.ts.map +1 -1
- package/dist/core/guards.js +38 -0
- 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/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/resource.d.ts +9 -3
- package/dist/mcp/resource.d.ts.map +1 -1
- package/dist/mcp/resource.js +7 -3
- package/dist/mcp/resource.js.map +1 -1
- package/dist/renderer/app.js +1 -1
- package/dist/renderer/app.js.map +1 -1
- package/dist/renderer/components/charts/cartesian.d.ts.map +1 -1
- package/dist/renderer/components/charts/cartesian.js +16 -39
- package/dist/renderer/components/charts/cartesian.js.map +1 -1
- package/dist/renderer/components/charts/helpers.d.ts +2 -0
- package/dist/renderer/components/charts/helpers.d.ts.map +1 -1
- package/dist/renderer/components/charts/helpers.js +9 -8
- package/dist/renderer/components/charts/helpers.js.map +1 -1
- package/dist/renderer/components/charts/polar.d.ts.map +1 -1
- package/dist/renderer/components/charts/polar.js +2 -8
- package/dist/renderer/components/charts/polar.js.map +1 -1
- package/dist/renderer/components/charts/scatter.d.ts.map +1 -1
- package/dist/renderer/components/charts/scatter.js +5 -11
- package/dist/renderer/components/charts/scatter.js.map +1 -1
- package/dist/renderer/components/charts/tooltip.d.ts +1 -1
- package/dist/renderer/components/charts/tooltip.d.ts.map +1 -1
- package/dist/renderer/components/charts/tooltip.js +39 -55
- package/dist/renderer/components/charts/tooltip.js.map +1 -1
- package/dist/renderer/components/choice.js +14 -20
- package/dist/renderer/components/choice.js.map +1 -1
- package/dist/renderer/components/control.js +5 -19
- package/dist/renderer/components/control.js.map +1 -1
- package/dist/renderer/components/data.d.ts.map +1 -1
- package/dist/renderer/components/data.js +22 -38
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.d.ts.map +1 -1
- package/dist/renderer/components/form.js +2 -1
- 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 +21 -11
- package/dist/renderer/components/interactive.js.map +1 -1
- package/dist/renderer/components/table.d.ts.map +1 -1
- package/dist/renderer/components/table.js +3 -6
- package/dist/renderer/components/table.js.map +1 -1
- package/dist/renderer/engine.d.ts +1 -1
- package/dist/renderer/engine.d.ts.map +1 -1
- package/dist/renderer/engine.js +16 -3
- package/dist/renderer/engine.js.map +1 -1
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/renderer/index.js +9 -10
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/node-guard.d.ts +3 -0
- package/dist/renderer/node-guard.d.ts.map +1 -1
- package/dist/renderer/node-guard.js +4 -1
- package/dist/renderer/node-guard.js.map +1 -1
- package/dist/renderer/rx.js +1 -1
- package/dist/renderer/rx.js.map +1 -1
- package/dist/renderer/theme.js.map +1 -1
- package/dist/renderer/transport.d.ts.map +1 -1
- package/dist/renderer/transport.js +10 -10
- package/dist/renderer/transport.js.map +1 -1
- package/dist/renderer.auto.min.js +10 -10
- package/dist/renderer.min.js +10 -10
- package/dist/rx/pipes.d.ts +1 -0
- package/dist/rx/pipes.d.ts.map +1 -1
- package/dist/rx/pipes.js +3 -0
- package/dist/rx/pipes.js.map +1 -1
- package/package.json +5 -5
package/dist/renderer.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(()=>{var{defineProperty:ut,getOwnPropertyNames:vr,getOwnPropertyDescriptor:kr}=Object,Sr=Object.prototype.hasOwnProperty;function Er(e){return this[e]}var Rr=(e)=>{var t=(Ut??=new WeakMap).get(e),n;if(t)return t;if(t=ut({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var r of vr(e))if(!Sr.call(t,r))ut(t,r,{get:Er.bind(e,r),enumerable:!(n=kr(e,r))||n.enumerable})}return Ut.set(e,t),t},Ut;var Tr=(e)=>e;function Ar(e,t){this[e]=Tr.bind(null,t)}var Mr=(e,t)=>{for(var n in t)ut(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Ar.bind(t,n)})};var Es={};Mr(Es,{Bridge:()=>he,DestroyRegistry:()=>Ne,PrefabRenderer:()=>q,app:()=>dt,applyHostTheme:()=>Ie,createLogger:()=>mt,createThemeToggle:()=>De,getLogLevel:()=>Yt,isIframe:()=>ke,isValidWireFormat:()=>gr,listPipes:()=>Fe,log:()=>M,registerComponent:()=>p,registerPipe:()=>Te,setLogLevel:()=>je,unregisterPipe:()=>Ae,validateWireFormat:()=>Se});var Xt={silent:0,error:1,warn:2,info:3,debug:4},ft="warn";function je(e){ft=e}function Yt(){return ft}function mt(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,i)=>{if(Xt[r]>Xt[ft])return;console[r](`${t} ${o}`,...i)};return{error:(r,...o)=>n("error",r,o),warn:(r,...o)=>n("warn",r,o),info:(r,...o)=>n("info",r,o),debug:(r,...o)=>n("debug",r,o)}}var M=mt();function S(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function b(e){return typeof e==="string"?e:void 0}function D(e){return typeof e==="number"?e:void 0}function I(e){return S(e)?e:void 0}function Ee(e){return Array.isArray(e)?e.filter(S):[]}function gt(e){return S(e)?[e]:Ee(e)}function Zt(e){let t={};if(!S(e))return t;for(let[n,r]of Object.entries(e))if(typeof r==="string"||typeof r==="number"||typeof r==="boolean")t[n]=String(r);return t}class Re{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return Nr(this.data,e)}getAll(){return this.data}set(e,t){Qt(this.data,e,t),this.notify(e)}toggle(e){let t=this.get(e),n=t==null||t===!1||t===0||t==="";this.set(e,n)}append(e,t,n){let r=this.get(e);if(!Array.isArray(r)){this.set(e,[t]);return}if(n!==void 0)r.splice(n,0,t);else r.push(t);this.notify(e)}pop(e,t){let n=this.get(e);if(!Array.isArray(n))return;if(typeof t==="number")n.splice(t,1);else{let r=n.indexOf(t);if(r>=0)n.splice(r,1)}this.notify(e)}merge(e){for(let[t,n]of Object.entries(e))Qt(this.data,t,n);for(let t of Object.keys(e))this.notify(t)}subscribe(e,t){if(!this.subscribers.has(e))this.subscribers.set(e,new Set);return this.subscribers.get(e)?.add(t),()=>this.subscribers.get(e)?.delete(t)}subscribeAll(e){return this.globalSubscribers.add(e),()=>this.globalSubscribers.delete(e)}notify(e){this.generation++;let t=e.split(".");for(let n=1;n<=t.length;n++){let r=t.slice(0,n).join("."),o=this.subscribers.get(r);if(o)o.forEach((i)=>i())}this.globalSubscribers.forEach((n)=>n())}}function Nr(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=Reflect.get(r,o)}return r}var Lr=new Set(["__proto__","constructor","prototype"]);function Qt(e,t,n){let r=t.split(".");if(r.some((i)=>Lr.has(i))){M.warn(`Blocked prototype pollution attempt: ${t}`);return}let o=e;for(let i=0;i<r.length-1;i++){let s=r[i],a=o[s];if(S(a))o=a;else{let l={};o[s]=l,o=l}}o[r[r.length-1]]=n}var be=new Map;function Te(e,t){if(be.has(e)&&be.get(e)!==t)M.warn(`pipe "${e}" re-registered`);be.set(e,t)}function Ae(e){return be.delete(e)}function Fe(){return[...be.keys()]}function Be(e){return be.get(e)}function k(e){if(e==null)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"||typeof e==="bigint")return String(e);if(typeof e==="symbol")return e.description??"";if(typeof e==="function")return e.name;if(e instanceof Date)return Number.isNaN(e.getTime())?"":e.toISOString();if(Array.isArray(e))return e.map(k).join(", ");try{return JSON.stringify(e)??""}catch{return""}}function ht(e,t){let n=e instanceof Date?e:typeof e==="string"||typeof e==="number"?new Date(e):void 0;return n&&!Number.isNaN(n.getTime())?t(n):e}var en=-1,bt=new Map,Hr=/\{\{\s*(.+?)\s*\}\}/g;function J(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function G(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&Fr(r,"{{")===1){let o=r.slice(2,-2).trim();return tn(o,t,n)}return e.replace(Hr,(o,i)=>{let s=tn(i.trim(),t,n);return k(s)})}function tn(e,t,n){let[r,...o]=jr(e),i=K(r.trim(),t,n);for(let s of o)i=Pr(s.trim(),i,t,n);return i}function K(e,t,n){let r=Dr(e);if(r>=0){let s=e.slice(0,r).trim(),a=e.slice(r+1),l=Ir(a);if(l>=0){let c=a.slice(0,l).trim(),u=a.slice(l+1).trim(),d=K(s,t,n);return d!==null&&d!==void 0&&d!==!1&&d!==0&&d!==""?K(c,t,n):K(u,t,n)}}let o=Ve(e,"||");if(o>=0){let s=K(e.slice(0,o).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:K(e.slice(o+2).trim(),t,n)}let i=Ve(e,"&&");if(i>=0){let s=K(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return K(e.slice(i+2).trim(),t,n)}for(let[s,a]of $r){let l=Ve(e,s);if(l>=0){let c=K(e.slice(0,l).trim(),t,n),u=K(e.slice(l+s.length).trim(),t,n);return a(c,u)}}if(e.startsWith("!")){let s=K(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of Or){let l=Ve(e,s);if(l>=0){let c=K(e.slice(0,l).trim(),t,n),u=K(e.slice(l+s.length).trim(),t,n);return a(Number(c),Number(u))}}if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);if(n&&e.startsWith("$")){let s=e.indexOf(".");if(s>=0){let a=e.slice(0,s),l=e.slice(s+1),c=n[a];return _e(c,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return _e(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}var rn=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function Pr(e,t,n,r){let o=e.indexOf(":"),i=o>=0?e.slice(0,o).trim():e,s=o>=0?e.slice(o+1).trim():void 0,a=s?yt(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=nn(s);if(l.length<2)return;let c=yt(l[0]),u=l[1].trim(),d;if(u.startsWith("'")&&u.endsWith("'")||u.startsWith('"')&&u.endsWith('"'))d=u.slice(1,-1);else if(n){if(r&&u.startsWith("$")){let f=u.indexOf(".");if(f>=0){let y=u.slice(0,f);if(y in r)d=_e(r[y],u.slice(f+1))}else if(u in r)d=r[u]}if(d===void 0&&!(r&&u.startsWith("$")))if(r){let f=u.split(".")[0];d=f in r?_e(r[f],u.includes(".")?u.slice(f.length+1):""):n.get(u)}else d=n.get(u)}else d=u;if(d==null)return;let m=n?.generation??0;if(m!==en)bt=new Map,en=m;let h=bt.get(t);if(!h)h=new Map,bt.set(t,h);let C=h.get(c);if(!C){C=new Map;for(let f of t)if(S(f)){let y=f[c];if(y!=null)C.set(k(y),f)}h.set(c,C)}return C.get(k(d))}case"dot":{if(t==null||typeof t!=="object"||typeof a!=="string")return;return Reflect.get(t,a)}case"length":return Array.isArray(t)?t.length:typeof t==="string"?t.length:0;case"upper":return typeof t==="string"?t.toUpperCase():t;case"lower":return typeof t==="string"?t.toLowerCase():t;case"truncate":if(typeof t==="string"&&typeof a==="number")return t.slice(0,a);return t;case"join":return Array.isArray(t)?t.join(typeof a==="string"?a:", "):t;case"first":return Array.isArray(t)?t[0]:t;case"last":return Array.isArray(t)?t[t.length-1]:t;case"abs":return Math.abs(Number(t));case"round":return typeof a==="number"?Number(Number(t).toFixed(a)):Math.round(Number(t));case"number":return typeof a==="number"?Number(Number(t).toFixed(a)):Number(t);case"currency":{let l=typeof a==="string"?a:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:l}).format(Number(t))}catch{return t}}case"percent":return typeof a==="number"?`${(Number(t)*100).toFixed(a)}%`:`${Math.round(Number(t)*100)}%`;case"compact":{let l=typeof a==="number"?a:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:l}).format(Number(t))}catch{return t}}case"date":return ht(t,(l)=>l.toLocaleDateString());case"time":return ht(t,(l)=>l.toLocaleTimeString());case"datetime":return ht(t,(l)=>l.toLocaleString());case"pluralize":{let l=Number(t),c=typeof a==="string"?a:"";return l===1?c:`${c}s`}case"default":return t==null||t===""?a:t;case"selectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>S(l)&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(!S(l))return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=Be(i);if(l){let c=s?nn(s).map(yt):[];return l(t,...c)}return t}}}var $r=[["!==",(e,t)=>e!==t],["===",(e,t)=>e===t],["!=",(e,t)=>e!=t],["==",(e,t)=>e==t],[">=",(e,t)=>Number(e)>=Number(t)],["<=",(e,t)=>Number(e)<=Number(t)],[">",(e,t)=>Number(e)>Number(t)],["<",(e,t)=>Number(e)<Number(t)]],Or=[[" + ",(e,t)=>e+t],[" - ",(e,t)=>e-t],[" * ",(e,t)=>e*t],[" / ",(e,t)=>t!==0?e/t:0],[" % ",(e,t)=>t!==0?e%t:0]];function Ve(e,t){let n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n&&e.slice(r,r+t.length)===t)return r}return-1}function Dr(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="(")t++;else if(o===")")t--;else if(o==="?"&&t===0)return r}}return-1}function Ir(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="?"||o==="(")t++;else if(o===")")t--;else if(o===":"&&t===0)return r}}return-1}function jr(e){let t=[],n="",r=null;for(let o=0;o<e.length;o++){let i=e[o];if(i==="'"||i==='"')r=r===i?null:r??i;if(i==="|"&&!r)if(e[o+1]==="|")n+="||",o++;else t.push(n),n="";else n+=i}return t.push(n),t}function yt(e){let t=e.replace(/^['"]|['"]$/g,"");if(t==="true")return!0;if(t==="false")return!1;let n=Number(t);return isNaN(n)?t:n}function nn(e){let t=[],n="",r=null;for(let o of e){if(o==="'"||o==='"')r=r===o?null:r??o;if(o===","&&!r)t.push(n),n="";else n+=o}return t.push(n),t}function _e(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(!S(r)&&!Array.isArray(r))return;r=Reflect.get(r,o)}return r}function Fr(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function ze(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function Ct(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:ze(n);if(Array.isArray(r))t[o]=r.map((i)=>S(i)?Ct(i):i);else if(S(r))t[o]=Ct(r);else t[o]=r}return t}async function P(e,t){for(let n of gt(e))await Br(n,t)}function O(e,t){e.catch((n)=>M.error(`${t} failed:`,n))}async function We(e,t,n,r){if(n!=null)M.debug(`${e} failed:`,t),await Me(n,r,{$error:t});else M.warn(`${e} failed:`,t)}async function Br(e,t){let n=Ct(e);switch(b(n.action)){case"setState":{Vr(n,t);return}case"toggleState":{_r(n,t);return}case"appendState":{zr(n,t);return}case"popState":{Wr(n,t);return}case"showToast":{Kr(n,t);return}case"closeOverlay":{Jr(n,t);return}case"openLink":{Gr(n);return}case"setInterval":{Ur(n,t);return}case"toolCall":case"callTool":return Xr(n,t);case"sendMessage":return Yr(n,t);case"updateContext":{Zr(n,t);return}case"fetch":return Qr(n,t);case"openFilePicker":{eo(n,t);return}case"callHandler":return to(n,t);case"requestDisplayMode":{no(n,t);return}case"subscribe":{io(n,t);return}case"unsubscribe":{so(n);return}default:M.warn(`Unknown action: ${k(n.action)}`)}}function Ge(e,t){let n=b(e.key);if(n===void 0)M.warn(`${t}: missing key`);return n}function Vr(e,t){let n=Ge(e,"setState");if(n===void 0)return;let r=e.value;if(J(r))r=G(r,t.store,t.scope);t.store.set(n,r),t.rerender(),Me(e.onSuccess,t)}function _r(e,t){let n=Ge(e,"toggleState");if(n===void 0)return;t.store.toggle(n),t.rerender()}function zr(e,t){let n=Ge(e,"appendState");if(n===void 0)return;let r=e.value??e.item;if(J(r))r=G(r,t.store,t.scope);t.store.append(n,r,D(e.index)),t.rerender()}function Wr(e,t){let n=Ge(e,"popState");if(n===void 0)return;let r=J(e.index)?G(e.index,t.store,t.scope):e.index;if(typeof r!=="number"&&typeof r!=="string"){M.warn("popState: missing index");return}t.store.pop(n,r),t.rerender()}function Kr(e,t){t.onToast?.({message:Je(e.message,t),description:e.description!=null?Je(e.description,t):void 0,variant:b(e.variant),duration:D(e.duration)})}function Jr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function Gr(e){if(typeof window<"u"){let t=b(e.url);if(!t){M.warn("openLink: missing url");return}if(!un(t)){M.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,b(e.target)??"_blank")}}var Ke=new Set,qr=20,xt=100;function Ur(e,t){let n=Math.max(D(e.intervalMs)??xt,xt),r=gt(e.onTick);if(typeof globalThis.setInterval!=="function")return;if(r.length===0){M.warn("setInterval: missing onTick");return}if(Ke.size>=qr){M.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>O(P(r,t),"interval action"),n);Ke.add(o)}function on(){for(let e of Ke)globalThis.clearInterval(e);Ke.clear()}async function sn(e,t,n){let r=b(e.resultKey);if(r!==void 0)n.store.set(r,t);let o=dn(t);if(o&&n.remount)n.remount(o);else pn(t,n),n.rerender();await Me(e.onSuccess,n,{$result:t})}async function an(e,t,n,r,o){let i=fn(I(n.arguments),r);try{if(t===void 0)throw Error(`${e}: missing tool name`);let s=await o.callTool(t,i);await sn(n,s,r)}catch(s){await We(e,s,n.onError,r)}}async function Xr(e,t){if(!t.transport){M.warn("No MCP transport configured for toolCall");return}await an("toolCall",b(e.tool),e,t,t.transport)}async function Yr(e,t){if(!t.transport){M.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(Je(e.message,t))}function Zr(e,t){let n=I(e.context);if(n!=null)t.store.merge(n),t.rerender()}async function Qr(e,t){let n=Je(e.url,t);if(!un(n)){M.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=b(e.method)??"GET",o=Zt(e.headers),i=e.body!==void 0?JSON.stringify(e.body):void 0;try{let s=await globalThis.fetch(n,{method:r,headers:{"Content-Type":"application/json",...o},...i&&{body:i}}),a=await s.json().catch(()=>s.text());await sn(e,a,t)}catch(s){await We("fetch",s,e.onError,t)}}function eo(e,t){if(typeof document>"u")return;let n=document.createElement("input");n.type="file";let r=b(e.accept);if(r!==void 0)n.accept=r;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let o=Array.from(n.files??[]),i=b(e.resultKey);if(i!==void 0)t.store.set(i,o);t.rerender(),Me(e.onSuccess,t,{$result:o})}),n.click()}async function to(e,t){let n=b(e.handler);if(!t.transport){M.warn(`No transport configured for callHandler: ${n??""}`);return}await an("callHandler",n,e,t,t.transport)}function no(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var ee=new Map,ro=50,oo=2000;function io(e,t){let n=b(e.uri),r=b(e.stateKey);if(!n||!r){M.warn("subscribe: missing uri or stateKey");return}if(ee.has(n))return;if(ee.size>=ro){M.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(d)=>{let m=dn(d);if(m&&t.remount)t.remount(m);else{if(!pn(d,t))t.store.set(r,d);t.rerender()}Me(e.onData,t,{$data:d})};if(e.push!==!1&&t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let d=t.transport.subscribe(n,o,(m)=>{if(ee.get(n)===d)ee.delete(n);We("subscribe",m,e.onError,t)});ee.set(n,d);return}let i=b(e.fallbackTool),s=D(e.fallbackInterval)??oo;if(!i){M.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){M.warn("No MCP transport configured for subscribe fallback");return}let a=I(e.fallbackArgs)??{},l=Math.max(s,xt),c=t.transport,u=globalThis.setInterval(()=>{(async()=>{try{let d=fn(a,t),m=await c.callTool(i,d);o(m)}catch(d){We("subscribe",d,e.onError,t)}})()},l);ee.set(n,()=>globalThis.clearInterval(u))}function so(e){let t=b(e.uri);if(!t){M.warn("unsubscribe: missing uri");return}let n=ee.get(t);if(n)n(),ee.delete(t)}function ln(){for(let[e,t]of ee)try{t()}catch(n){M.warn(`Error cleaning up subscription '${e}':`,n)}ee.clear()}function ao(e){try{return JSON.parse(e)}catch{return}}function cn(e,t){if(!S(e))return null;if(t(e))return e;let n=e.structuredContent;if(S(n)&&t(n))return n;for(let r of Ee(e.content)){if(r.type!=="text"||typeof r.text!=="string")continue;let o=ao(r.text);if(S(o)&&t(o))return o}return null}function lo(e){return"$prefab"in e&&"view"in e}function co(e){return"$prefab"in e&&S(e.update)&&"state"in e.update}function dn(e){return cn(e,lo)}function pn(e,t){let n=cn(e,co);if(!n)return!1;let{update:r}=n,o=I(r.state);if(o)t.store.merge(o);if(r.actions!=null)O(P(r.actions,t),"update action");return!0}var po=/^\s*(javascript|vbscript|data):/i;function un(e){return!po.test(e)}function Je(e,t){if(J(e)){let n=G(e,t.store,t.scope);return k(n)}return k(e)}function fn(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=J(o)?G(o,t.store,t.scope):o;return n}async function Me(e,t,n){if(e==null)return;let r={...t.scope,...n};await P(e,{...t,scope:r})}function vt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:ze(n);if(Array.isArray(r))t[o]=r.map((i)=>S(i)?vt(i):i);else if(S(r))t[o]=vt(r);else t[o]=r}return t}class Ne{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){M.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function uo(e){return typeof e==="object"&&"element"in e}var qe=new Map;function p(e,t){if(qe.has(e))M.warn(`overriding existing renderer for "${e}"`);qe.set(e,t)}function kt(){return[...qe.keys()].sort()}var mn=new Set;function hn(e){mn.clear();for(let t of e)mn.add(t)}function j(e,t){let n=vt(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return j(i,t)}let r=qe.get(n.type),o;if(r){let i=r(n,t);if(uo(i))o=i.element,t.destroyRegistry?.track(i.destroy);else o=i}else if(o=document.createElement("div"),o.setAttribute("data-prefab-type",n.type),n.children)for(let i of n.children)o.appendChild(j(i,t));if(o instanceof HTMLElement){if(n.id)o.id=n.id;if(n.cssClass){let i=w(n.cssClass,t);if(i)o.className=(o.className?o.className+" ":"")+i}if(n.onClick!=null){if(o.addEventListener("click",()=>{O(P(n.onClick,V(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(i)=>{let s=i.key;if(s==="Enter"||s===" ")i.preventDefault(),O(P(n.onClick,V(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=V(t);queueMicrotask(()=>O(P(i,s),"onMount"))}return o}function N(e,t,n){if(!e.children)return;ie(e.children,t,n)}function ie(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=fo(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(j(o,n)),r++}}function fo(e,t,n,r){let o=!1,i=t,s=e[i];if(gn(b(s.condition)??"",r))wt(s,n,r),o=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!o&&gn(b(a.condition)??"",r))wt(a,n,r),o=!0;i++}else if(a.type==="Else"){if(!o)wt(a,n,r);i++;break}else break}return i}function gn(e,t){if(!e)return!1;if(J(e))return Boolean(G(e,t.store,t.scope));return Boolean(t.store.get(e))}function wt(e,t,n){if(!e.children)return;ie(e.children,t,n)}function w(e,t){if(J(e)){let n=G(e,t.store,t.scope);return k(n)}return k(e)}function W(e,t){if(J(e))return G(e,t.store,t.scope);return e}function V(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function g(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function St(e,t){return e.textContent=t,e}function Ue(e,t){return e===void 0||t(e)}function mo(e){return S(e)||Array.isArray(e)&&e.every(S)}function Le(e){return S(e)&&typeof e.type==="string"&&Ue(e.id,(t)=>typeof t==="string")&&Ue(e.cssClass,(t)=>typeof t==="string")&&Ue(e.onMount,mo)&&Ue(e.children,(t)=>Array.isArray(t)&&t.every(Le))}function wn(){p("Column",go),p("Row",ho),p("Grid",bn),p("GridItem",yn),p("Container",bo),p("Div",Cn),p("Span",yo),p("Dashboard",bn),p("DashboardItem",yn),p("Pages",Co),p("Page",Cn),p("Detail",xo),p("MasterDetail",wo)}function go(e,t){let n=g("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let r=Xe(e);if(r!=null)n.style.gap=`${r*4}px`;return vn(n,e),N(e,n,t),n}function ho(e,t){let n=g("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let r=Xe(e);if(r!=null)n.style.gap=`${r*4}px`;if(vn(n,e),e.wrap===!0)n.style.flexWrap="wrap";return N(e,n,t),n}function bn(e,t){let n=g("div","pf-grid");n.style.display="grid",n.style.gridTemplateColumns=`repeat(${So(e.columns)}, 1fr)`;let r=Xe(e);if(r!=null)n.style.gap=`${r*4}px`;return N(e,n,t),n}function yn(e,t){let n=g("div","pf-grid-item"),r=D(e.colSpan),o=D(e.rowSpan);if(r!=null)n.style.gridColumn=`span ${r}`;if(o!=null)n.style.gridRow=`span ${o}`;return N(e,n,t),n}function bo(e,t){let n=g("div","pf-container");n.style.maxWidth=b(e.maxWidth)??"1200px",n.style.margin="0 auto";let r=D(e.padding);if(r!=null)n.style.padding=`${r*4}px`;return N(e,n,t),n}function Cn(e,t){let n=g("div","pf-div");return N(e,n,t),n}function yo(e,t){let n=g("span","pf-span");return N(e,n,t),n}function Co(e,t){let n=g("div","pf-pages");return N(e,n,t),n}function xo(e,t){let n=g("div","pf-detail"),r=e.of!=null?W(e.of,t):void 0;if(r!=null&&r!==""&&r!==!1&&r!==0)N(e,n,t);else if(Le(e.empty))n.appendChild(j(e.empty,t));return n}function wo(e,t){let n=g("div","pf-master-detail");n.style.display="flex",n.style.flexDirection="row";let r=Xe(e);if(r!=null)n.style.gap=`${r*4}px`;let o=b(e.masterWidth)??"33%",i=e.children??[];if(i.length>0){let s=g("div","pf-master-detail-master");s.style.width=o,s.style.flexShrink="0",s.style.overflow="auto",s.appendChild(j(i[0],t)),n.appendChild(s)}if(i.length>1){let s=g("div","pf-master-detail-detail");s.style.flex="1",s.style.overflow="auto",s.appendChild(j(i[1],t)),n.appendChild(s)}return n}var vo=/\bgap-(\d+)\b/;function Xe(e){let t=D(e.gap);if(t!=null)return t;if(typeof e.cssClass==="string"){let n=vo.exec(e.cssClass);if(n)return Number(n[1])}return null}var ko=["default","base","xs","sm","md","lg","xl","2xl"],xn=3;function So(e){if(typeof e==="number")return e;if(!S(e))return xn;let t=ko.map((n)=>e[n]).filter((n)=>typeof n==="number");return t.length>0?t[t.length-1]:xn}function vn(e,t){let n=b(t.align),r=b(t.justify);if(n!=null)e.style.alignItems=Eo(n);if(r!=null)e.style.justifyContent=Ro(r)}function Eo(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Ro(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var To={"&":"&","<":"<",">":">",'"':""","'":"'"};function He(e){return e.replace(/[&<>"']/g,(t)=>To[t]??t)}function Sn(){p("Heading",Ao),p("H1",(e,t)=>Ye(e,t,"h1")),p("H2",(e,t)=>Ye(e,t,"h2")),p("H3",(e,t)=>Ye(e,t,"h3")),p("H4",(e,t)=>Ye(e,t,"h4")),p("Text",Mo),p("P",No),p("Lead",(e,t)=>ye(e,t,"p","pf-lead")),p("Large",(e,t)=>ye(e,t,"span","pf-large")),p("Small",(e,t)=>ye(e,t,"small","pf-small")),p("Muted",(e,t)=>ye(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>ye(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>ye(e,t,"label","pf-label")),p("Link",Ho),p("Code",Po),p("Markdown",$o),p("Kbd",Oo)}function Ao(e,t){let n=D(e.level)??2,r=`h${Math.min(Math.max(n,1),6)}`,o=document.createElement(r);return o.className=`pf-heading pf-${r}`,o.textContent=w(e.content,t),o}function Ye(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=w(e.content,t),r}function Mo(e,t){return St(g("span","pf-text"),w(e.content,t))}function No(e,t){return St(g("p","pf-p"),w(e.content,t))}function ye(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=w(e.content,t),o}var Lo=/^\s*(javascript|vbscript|data):/i;function Ho(e,t){let n=document.createElement("a");if(n.className="pf-link",n.textContent=w(e.content,t),e.href!=null){let r=w(e.href,t);if(!Lo.test(r))n.href=r}if(e.target!=null)n.target=w(e.target,t);return n}function Po(e,t){let n=g("pre","pf-code"),r=g("code");if(r.textContent=w(e.content,t),e.language!=null)r.setAttribute("data-language",k(e.language));return n.appendChild(r),n}function $o(e,t){let n=g("div","pf-markdown"),r=w(e.content,t);return n.innerHTML=En(r),n.setAttribute("data-markdown","true"),n}var kn=/^\s*(javascript|vbscript|data):/i;function Ze(e){let t=He(e),n=[];return t=t.replace(/`([^`]+)`/g,(r,o)=>(n.push(`<code>${o}</code>`),`CODE${n.length-1}`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(r,o,i)=>{if(kn.test(i))return He(o);return`<img src="${i}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,i)=>{if(kn.test(i))return o;return`<a href="${i}">${o}</a>`}),t=t.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),t=t.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/\uFDD0CODE(\d+)\uFDD0/g,(r,o)=>n[parseInt(o)]),t}function En(e){let t=e.replace(/\r\n?/g,`
|
|
1
|
+
(()=>{var{defineProperty:ft,getOwnPropertyNames:Lo,getOwnPropertyDescriptor:Ao}=Object,Ho=Object.prototype.hasOwnProperty;function Po(e){return this[e]}var $o=(e)=>{var t=(Ut??=new WeakMap).get(e),n;if(t)return t;if(t=ft({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var o of Lo(e))if(!Ho.call(t,o))ft(t,o,{get:Po.bind(e,o),enumerable:!(n=Ao(e,o))||n.enumerable})}return Ut.set(e,t),t},Ut;var Oo=(e)=>e;function Do(e,t){this[e]=Oo.bind(null,t)}var Io=(e,t)=>{for(var n in t)ft(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Do.bind(t,n)})};var Hs={};Io(Hs,{Bridge:()=>ye,DestroyRegistry:()=>He,PrefabRenderer:()=>U,app:()=>pt,applyHostTheme:()=>je,createLogger:()=>gt,createThemeToggle:()=>Ie,getLogLevel:()=>Yt,isIframe:()=>Ee,isValidWireFormat:()=>ko,listPipes:()=>Ve,log:()=>M,registerComponent:()=>p,registerPipe:()=>Ne,setLogLevel:()=>Be,unregisterPipe:()=>Le,validateWireFormat:()=>Te});var Xt={silent:0,error:1,warn:2,info:3,debug:4},mt="warn";function Be(e){mt=e}function Yt(){return mt}function gt(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(o,r,i)=>{if(Xt[o]>Xt[mt])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 M=gt();function S(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 P(e){return S(e)?e:void 0}function W(e){return Array.isArray(e)?e.filter(S):[]}function ht(e){return S(e)?[e]:W(e)}function Zt(e){let t={};if(!S(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 Me{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return jo(this.data,e)}getAll(){return this.data}set(e,t){Qt(this.data,e,t),this.notify(e)}toggle(e){let t=this.get(e),n=t==null||t===!1||t===0||t==="";this.set(e,n)}append(e,t,n){let 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))Qt(this.data,t,n);for(let t of Object.keys(e))this.notify(t)}subscribe(e,t){if(!this.subscribers.has(e))this.subscribers.set(e,new Set);return this.subscribers.get(e)?.add(t),()=>this.subscribers.get(e)?.delete(t)}subscribeAll(e){return this.globalSubscribers.add(e),()=>this.globalSubscribers.delete(e)}notify(e){this.generation++;let t=e.split(".");for(let n=1;n<=t.length;n++){let o=t.slice(0,n).join("."),r=this.subscribers.get(o);if(r)r.forEach((i)=>i())}this.globalSubscribers.forEach((n)=>n())}}function jo(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 Fo=new Set(["__proto__","constructor","prototype"]);function Qt(e,t,n){let o=t.split(".");if(o.some((i)=>Fo.has(i))){M.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(S(a))r=a;else{let l={};r[s]=l,r=l}}r[o[o.length-1]]=n}function en(e){return typeof e==="function"}var be=new Map;function Ne(e,t){if(be.has(e)&&be.get(e)!==t)M.warn(`pipe "${e}" re-registered`);be.set(e,t)}function Le(e){return be.delete(e)}function Ve(){return[...be.keys()]}function _e(e){return be.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 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 tn=-1,bt=new Map,Bo=/\{\{\s*(.+?)\s*\}\}/g;function G(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function q(e,t,n){let o=e.trim();if(o.startsWith("{{")&&o.endsWith("}}")&&Go(o,"{{")===1){let r=o.slice(2,-2).trim();return nn(r,t,n)}return e.replace(Bo,(r,i)=>{let s=nn(i.trim(),t,n);return v(s)})}function nn(e,t,n){let[o,...r]=Ko(e),i=K(o.trim(),t,n);for(let s of r)i=Vo(s.trim(),i,t,n);return i}function K(e,t,n){let o=Jo(e);if(o>=0){let s=e.slice(0,o).trim(),a=e.slice(o+1),l=Wo(a);if(l>=0){let c=a.slice(0,l).trim(),u=a.slice(l+1).trim(),d=K(s,t,n);return d!==null&&d!==void 0&&d!==!1&&d!==0&&d!==""?K(c,t,n):K(u,t,n)}}let r=ze(e,"||");if(r>=0){let s=K(e.slice(0,r).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:K(e.slice(r+2).trim(),t,n)}let i=ze(e,"&&");if(i>=0){let s=K(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return K(e.slice(i+2).trim(),t,n)}for(let[s,a]of _o){let l=ze(e,s);if(l>=0){let c=K(e.slice(0,l).trim(),t,n),u=K(e.slice(l+s.length).trim(),t,n);return a(c,u)}}if(e.startsWith("!")){let s=K(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of zo){let l=ze(e,s);if(l>=0){let c=K(e.slice(0,l).trim(),t,n),u=K(e.slice(l+s.length).trim(),t,n);return a(Number(c),Number(u))}}if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);if(n&&e.startsWith("$")){let s=e.indexOf(".");if(s>=0){let a=e.slice(0,s),l=e.slice(s+1),c=n[a];return Je(c,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return Je(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}var rn=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function Vo(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?Ct(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=on(s);if(l.length<2)return;let c=String(Ct(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=Je(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?Je(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!==tn)bt=new Map,tn=g;let m=bt.get(t);if(!m)m=new Map,bt.set(t,m);let b=m.get(c);if(!b){b=new Map;for(let h of t)if(S(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 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)=>S(l)&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(!S(l))return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=_e(i);if(l){let c=s?on(s).map(Ct):[];return l(t,...c)}return t}}}var _o=[["!==",(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)]],zo=[[" + ",(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 ze(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 Wo(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 Ko(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 Ct(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 on(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 Je(e,t){if(!t)return e;let n=t.split("."),o=e;for(let r of n){if(!S(o)&&!Array.isArray(o))return;o=Reflect.get(o,r)}return o}function Go(e,t){let n=0,o=0;while((o=e.indexOf(t,o))!==-1)n++,o+=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,o]of Object.entries(e)){let r=n.startsWith("$")?n:We(n);if(Array.isArray(o))t[r]=o.map((i)=>S(i)?xt(i):i);else if(S(o))t[r]=xt(o);else t[r]=o}return t}async function O(e,t){for(let n of ht(e))await qo(n,t)}function D(e,t){e.catch((n)=>M.error(`${t} failed:`,n))}async function Ke(e,t,n,o){if(n!=null)M.debug(`${e} failed:`,t),await Ae(n,o,{$error:t});else M.warn(`${e} failed:`,t)}async function qo(e,t){let n=xt(e);switch(y(n.action)){case"setState":{Uo(n,t);return}case"toggleState":{Xo(n,t);return}case"appendState":{Yo(n,t);return}case"popState":{Zo(n,t);return}case"showToast":{Qo(n,t);return}case"closeOverlay":{er(n,t);return}case"openLink":{tr(n);return}case"setInterval":{or(n,t);return}case"toolCall":case"callTool":return rr(n,t);case"sendMessage":return ir(n,t);case"updateContext":{sr(n,t);return}case"fetch":return ar(n,t);case"openFilePicker":{lr(n,t);return}case"callHandler":return cr(n,t);case"requestDisplayMode":{dr(n,t);return}case"subscribe":{fr(n,t);return}case"unsubscribe":{mr(n);return}default:M.warn(`Unknown action: ${v(n.action)}`)}}function Ue(e,t){let n=y(e.key);if(n===void 0)M.warn(`${t}: missing key`);return n}function Uo(e,t){let n=Ue(e,"setState");if(n===void 0)return;let o=e.value;if(G(o))o=q(o,t.store,t.scope);t.store.set(n,o),t.rerender(),Ae(e.onSuccess,t)}function Xo(e,t){let n=Ue(e,"toggleState");if(n===void 0)return;t.store.toggle(n),t.rerender()}function Yo(e,t){let n=Ue(e,"appendState");if(n===void 0)return;let o=e.value??e.item;if(G(o))o=q(o,t.store,t.scope);t.store.append(n,o,F(e.index)),t.rerender()}function Zo(e,t){let n=Ue(e,"popState");if(n===void 0)return;let o=G(e.index)?q(e.index,t.store,t.scope):e.index;if(typeof o!=="number"&&typeof o!=="string"){M.warn("popState: missing index");return}t.store.pop(n,o),t.rerender()}function Qo(e,t){t.onToast?.({message:qe(e.message,t),description:e.description!=null?qe(e.description,t):void 0,variant:y(e.variant),duration:F(e.duration)})}function er(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function tr(e){if(typeof window<"u"){let t=y(e.url);if(!t){M.warn("openLink: missing url");return}if(!fn(t)){M.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,y(e.target)??"_blank")}}var Ge=new Set,nr=20,vt=100;function or(e,t){let n=Math.max(F(e.intervalMs)??vt,vt),o=ht(e.onTick);if(typeof globalThis.setInterval!=="function")return;if(o.length===0){M.warn("setInterval: missing onTick");return}if(Ge.size>=nr){M.warn("Max intervals reached, ignoring new setInterval");return}let r=globalThis.setInterval(()=>D(O(o,t),"interval action"),n);Ge.add(r)}function sn(){for(let e of Ge)globalThis.clearInterval(e);Ge.clear()}async function an(e,t,n){let o=y(e.resultKey);if(o!==void 0)n.store.set(o,t);let r=pn(t);if(r&&n.remount)n.remount(r);else un(t,n),n.rerender();await Ae(e.onSuccess,n,{$result:t})}async function ln(e,t,n,o,r){let i=mn(P(n.arguments),o);try{if(t===void 0)throw Error(`${e}: missing tool name`);let s=await r.callTool(t,i);await an(n,s,o)}catch(s){await Ke(e,s,n.onError,o)}}async function rr(e,t){if(!t.transport){M.warn("No MCP transport configured for toolCall");return}await ln("toolCall",y(e.tool),e,t,t.transport)}async function ir(e,t){if(!t.transport){M.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(qe(e.message,t))}function sr(e,t){let n=P(e.context);if(n!=null)t.store.merge(n),t.rerender()}async function ar(e,t){let n=qe(e.url,t);if(!fn(n)){M.warn(`Blocked unsafe URL in fetch: ${n}`);return}let o=y(e.method)??"GET",r=Zt(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 an(e,a,t)}catch(s){await Ke("fetch",s,e.onError,t)}}function lr(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(),Ae(e.onSuccess,t,{$result:r})}),n.click()}async function cr(e,t){let n=y(e.handler);if(!t.transport){M.warn(`No transport configured for callHandler: ${n??""}`);return}await ln("callHandler",n,e,t,t.transport)}function dr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var ee=new Map,pr=50,ur=2000;function fr(e,t){let n=y(e.uri),o=y(e.stateKey);if(!n||!o){M.warn("subscribe: missing uri or stateKey");return}if(ee.has(n))return;if(ee.size>=pr){M.warn("Max subscriptions reached, ignoring new subscribe");return}let r=(d)=>{let g=pn(d);if(g&&t.remount)t.remount(g);else{if(!un(d,t))t.store.set(o,d);t.rerender()}Ae(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);Ke("subscribe",g,e.onError,t)});ee.set(n,d);return}let i=y(e.fallbackTool),s=F(e.fallbackInterval)??ur;if(!i){M.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){M.warn("No MCP transport configured for subscribe fallback");return}let a=P(e.fallbackArgs)??{},l=Math.max(s,vt),c=t.transport,u=globalThis.setInterval(()=>{(async()=>{try{let d=mn(a,t),g=await c.callTool(i,d);r(g)}catch(d){Ke("subscribe",d,e.onError,t)}})()},l);ee.set(n,()=>globalThis.clearInterval(u))}function mr(e){let t=y(e.uri);if(!t){M.warn("unsubscribe: missing uri");return}let n=ee.get(t);if(n)n(),ee.delete(t)}function cn(){for(let[e,t]of ee)try{t()}catch(n){M.warn(`Error cleaning up subscription '${e}':`,n)}ee.clear()}function gr(e){try{return JSON.parse(e)}catch{return}}function dn(e,t){if(!S(e))return null;if(t(e))return e;let n=e.structuredContent;if(S(n)&&t(n))return n;for(let o of W(e.content)){if(o.type!=="text"||typeof o.text!=="string")continue;let r=gr(o.text);if(S(r)&&t(r))return r}return null}function hr(e){return"$prefab"in e&&"view"in e}function yr(e){return"$prefab"in e&&S(e.update)&&"state"in e.update}function pn(e){return dn(e,hr)}function un(e,t){let n=dn(e,yr);if(!n)return!1;let{update:o}=n,r=P(o.state);if(r)t.store.merge(r);if(o.actions!=null)D(O(o.actions,t),"update action");return!0}var br=/^\s*(javascript|vbscript|data):/i;function fn(e){return!br.test(e)}function qe(e,t){if(G(e)){let n=q(e,t.store,t.scope);return v(n)}return v(e)}function mn(e,t){if(!e)return{};let n={};for(let[o,r]of Object.entries(e))n[o]=G(r)?q(r,t.store,t.scope):r;return n}async function Ae(e,t,n){if(e==null)return;let o={...t.scope,...n};await O(e,{...t,scope:o})}function Xe(e,t){return e===void 0||t(e)}function wt(e){return S(e)||Array.isArray(e)&&e.every(S)}function Ce(e){return S(e)&&typeof e.type==="string"&&Xe(e.id,(t)=>typeof t==="string")&&Xe(e.cssClass,(t)=>typeof t==="string")&&Xe(e.onMount,wt)&&Xe(e.children,(t)=>Array.isArray(t)&&t.every(Ce))}function de(e){return Array.isArray(e)?e.filter(Ce):[]}function St(e){let t={};for(let[n,o]of Object.entries(e)){let r=n.startsWith("$")?n:We(n);if(Array.isArray(o))t[r]=o.map((i)=>S(i)?St(i):i);else if(S(o))t[r]=St(o);else t[r]=o}return t}function Cr(e){let{id:t,cssClass:n,onMount:o,children:r,...i}=St(e),s={...i,type:e.type};if(typeof t==="string")s.id=t;if(typeof n==="string")s.cssClass=n;if(wt(o))s.onMount=o;if(Array.isArray(r))s.children=de(r);return s}class He{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){M.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function xr(e){return typeof e==="object"&&"element"in e}var Ye=new Map;function p(e,t){if(Ye.has(e))M.warn(`overriding existing renderer for "${e}"`);Ye.set(e,t)}function Rt(){return[...Ye.keys()].sort()}var gn=new Set;function yn(e){gn.clear();for(let t of e)gn.add(t)}function V(e,t){let n=Cr(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=Ye.get(n.type),r;if(o){let i=o(n,t);if(xr(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 N(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=vr(e,o,t,n);else if(r.type==="Elif"||r.type==="Else")o++;else t.appendChild(V(r,n)),o++}}function vr(e,t,n,o){let r=!1,i=t,s=e[i];if(hn(y(s.condition)??"",o))kt(s,n,o),r=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!r&&hn(y(a.condition)??"",o))kt(a,n,o),r=!0;i++}else if(a.type==="Else"){if(!r)kt(a,n,o);i++;break}else break}return i}function hn(e,t){if(!e)return!1;if(G(e))return Boolean(q(e,t.store,t.scope));return Boolean(t.store.get(e))}function kt(e,t,n){if(!e.children)return;pe(e.children,t,n)}function C(e,t){if(G(e)){let n=q(e,t.store,t.scope);return v(n)}return v(e)}function J(e,t){if(G(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 Et(e,t){return e.textContent=t,e}function wn(){p("Column",wr),p("Row",kr),p("Grid",bn),p("GridItem",Cn),p("Container",Sr),p("Div",xn),p("Span",Rr),p("Dashboard",bn),p("DashboardItem",Cn),p("Pages",Er),p("Page",xn),p("Detail",Tr),p("MasterDetail",Mr)}function wr(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 kn(n,e),N(e,n,t),n}function kr(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(kn(n,e),e.wrap===!0)n.style.flexWrap="wrap";return N(e,n,t),n}function bn(e,t){let n=f("div","pf-grid");n.style.display="grid",n.style.gridTemplateColumns=`repeat(${Ar(e.columns)}, 1fr)`;let o=Ze(e);if(o!=null)n.style.gap=`${o*4}px`;return N(e,n,t),n}function Cn(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 N(e,n,t),n}function Sr(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 N(e,n,t),n}function xn(e,t){let n=f("div","pf-div");return N(e,n,t),n}function Rr(e,t){let n=f("span","pf-span");return N(e,n,t),n}function Er(e,t){let n=f("div","pf-pages");return N(e,n,t),n}function Tr(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)N(e,n,t);else if(Ce(e.empty))n.appendChild(V(e.empty,t));return n}function Mr(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 Nr=/\bgap-(\d+)\b/;function Ze(e){let t=F(e.gap);if(t!=null)return t;if(typeof e.cssClass==="string"){let n=Nr.exec(e.cssClass);if(n)return Number(n[1])}return null}var Lr=["default","base","xs","sm","md","lg","xl","2xl"],vn=3;function Ar(e){if(typeof e==="number")return e;if(!S(e))return vn;let t=Lr.map((n)=>e[n]).filter((n)=>typeof n==="number");return t.length>0?t[t.length-1]:vn}function kn(e,t){let n=y(t.align),o=y(t.justify);if(n!=null)e.style.alignItems=Hr(n);if(o!=null)e.style.justifyContent=Pr(o)}function Hr(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Pr(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var $r={"&":"&","<":"<",">":">",'"':""","'":"'"};function te(e){return e.replace(/[&<>"']/g,(t)=>$r[t]??t)}function Rn(){p("Heading",Or),p("H1",(e,t)=>Qe(e,t,"h1")),p("H2",(e,t)=>Qe(e,t,"h2")),p("H3",(e,t)=>Qe(e,t,"h3")),p("H4",(e,t)=>Qe(e,t,"h4")),p("Text",Dr),p("P",Ir),p("Lead",(e,t)=>xe(e,t,"p","pf-lead")),p("Large",(e,t)=>xe(e,t,"span","pf-large")),p("Small",(e,t)=>xe(e,t,"small","pf-small")),p("Muted",(e,t)=>xe(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>xe(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>xe(e,t,"label","pf-label")),p("Link",Fr),p("Code",Br),p("Markdown",Vr),p("Kbd",_r)}function Or(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 Qe(e,t,n){let o=document.createElement(n);return o.className=`pf-heading pf-${n}`,o.textContent=C(e.content,t),o}function Dr(e,t){return Et(f("span","pf-text"),C(e.content,t))}function Ir(e,t){return Et(f("p","pf-p"),C(e.content,t))}function xe(e,t,n,o){let r=document.createElement(n);return r.className=o,r.textContent=C(e.content,t),r}var jr=/^\s*(javascript|vbscript|data):/i;function Fr(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(!jr.test(o))n.href=o}if(e.target!=null)n.target=C(e.target,t);return n}function Br(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 Vr(e,t){let n=f("div","pf-markdown"),o=C(e.content,t);return n.innerHTML=En(o),n.setAttribute("data-markdown","true"),n}var Sn=/^\s*(javascript|vbscript|data):/i;function et(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(Sn.test(i))return te(r);return`<img src="${i}" alt="${r}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(o,r,i)=>{if(Sn.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 En(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 Oo(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=w(e.content,t),n}function Tn(){p("Card",Do),p("CardHeader",Et("pf-card-header")),p("CardTitle",Rn("pf-card-title","h3")),p("CardDescription",Rn("pf-card-description","p")),p("CardContent",Et("pf-card-content")),p("CardFooter",Et("pf-card-footer"))}function Do(e,t){let n=g("div","pf-card");return n.style.overflow="hidden",N(e,n,t),n}function Et(e){return(t,n)=>{let r=g("div",e);return r.style.padding="16px 24px",N(t,r,n),r}}function Rn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=w(n.content,r),o}}function An(){p("DataTable",Io),p("Badge",jo),p("Dot",Fo),p("Metric",Bo),p("Ring",Vo),p("Progress",_o),p("Separator",zo),p("Loader",Wo),p("Icon",Ko),p("Sparkline",Jo)}function Io(e,t){let n=g("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable",r.style.width="100%",r.style.borderCollapse="collapse";let o=e.columns??[],i=W(e.rows,t),s=b(e.rowKey),a=b(e.selected),l=document.createElement("thead"),c=document.createElement("tr");for(let d of o){let m=document.createElement("th");m.className="pf-datatable-th",m.textContent=d.header??d.key,m.style.padding="8px 12px",m.style.textAlign="left",c.appendChild(m)}l.appendChild(c),r.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(i)){let d=a!=null?W(a,t):void 0;for(let m of i){let h=document.createElement("tr");h.className="pf-datatable-row";let C=m,f=S(C)?C:{},y=m===null||typeof m!=="object";if(s&&d!=null&&f[s]!=null&&k(f[s])===k(d))h.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)h.style.cursor="pointer",h.addEventListener("click",()=>{let x={...t.scope,$item:C,$index:i.indexOf(m)},v=V({...t,scope:x});O(P(e.onRowClick,v),"onRowClick")});for(let x of o){let v=document.createElement("td");v.className="pf-datatable-td";let R;if(x.accessor)R=W(`{{ $item.${x.accessor} }}`,{...t,scope:{...t.scope,$item:C}});else if(R=y?m:f[x.key],x.format&&R!=null)R=W(`{{ __fmtVal | ${x.format} }}`,{...t,scope:{...t.scope,__fmtVal:R}});v.textContent=k(R),v.style.padding="8px 12px",h.appendChild(v)}u.appendChild(h)}}if(r.appendChild(u),e.search===!0){let d=document.createElement("input");d.type="text",d.placeholder="Search...",d.className="pf-datatable-search",d.style.marginBottom="8px",d.style.padding="6px 12px",d.style.width="100%",d.style.boxSizing="border-box",d.addEventListener("input",()=>{let m=d.value.toLowerCase(),h=Array.from(u.querySelectorAll("tr"));for(let C of h){let f=(C.textContent??"").toLowerCase();C.style.display=f.includes(m)?"":"none"}}),n.appendChild(d)}return n.appendChild(r),n}function jo(e,t){let n=g("span","pf-badge"),r=b(e.variant)??"default";return n.setAttribute("data-variant",r),n.style.alignItems="center",n.style.padding="2px 10px",n.style.borderRadius="9999px",n.style.fontSize="12px",n.style.fontWeight="500",n.textContent=w(e.label??e.content,t),Go(n,r),n}function Fo(e,t){let n=g("span","pf-dot"),r=b(e.color)??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=r,n}function Bo(e,t){let n=g("div","pf-metric"),r=g("div","pf-metric-label");r.textContent=w(e.label,t),r.style.fontSize="14px",n.appendChild(r);let o=g("div","pf-metric-value");if(o.textContent=w(e.value,t),o.style.fontSize="28px",o.style.fontWeight="700",n.appendChild(o),e.delta!=null){let i=g("span","pf-metric-delta");i.textContent=w(e.delta,t);let s=b(e.trend)??"",a=b(e.trendSentiment)??"neutral";if(i.style.fontSize="14px",i.style.color=a==="positive"?"green":a==="negative"?"red":"inherit",s==="up")i.textContent="↑ "+i.textContent;else if(s==="down")i.textContent="↓ "+i.textContent;n.appendChild(i)}if(e.description!=null){let i=g("div","pf-metric-desc");i.textContent=w(e.description,t),i.style.fontSize="12px",n.appendChild(i)}return n}function Vo(e,t){let n=g("div","pf-ring"),r=D(e.size)??80,o=D(e.thickness)??8,i=Number(W(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(r-o)/2,l=2*Math.PI*a,c=l*(1-s/100),u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(r)),u.setAttribute("height",String(r)),u.setAttribute("viewBox",`0 0 ${r} ${r}`);let d=document.createElementNS("http://www.w3.org/2000/svg","circle");d.setAttribute("cx",String(r/2)),d.setAttribute("cy",String(r/2)),d.setAttribute("r",String(a)),d.setAttribute("fill","none"),d.setAttribute("stroke","var(--muted, #e5e7eb)"),d.setAttribute("stroke-width",String(o));let m=document.createElementNS("http://www.w3.org/2000/svg","circle");if(m.setAttribute("cx",String(r/2)),m.setAttribute("cy",String(r/2)),m.setAttribute("r",String(a)),m.setAttribute("fill","none"),m.setAttribute("stroke","var(--primary, #3b82f6)"),m.setAttribute("stroke-width",String(o)),m.setAttribute("stroke-dasharray",String(l)),m.setAttribute("stroke-dashoffset",String(c)),m.setAttribute("stroke-linecap","round"),m.style.transform="rotate(-90deg)",m.style.transformOrigin="center",u.appendChild(d),u.appendChild(m),n.appendChild(u),e.label!=null){let h=g("div","pf-ring-label");h.textContent=w(e.label,t),h.style.textAlign="center",h.style.fontSize="12px",n.appendChild(h)}return n}function _o(e,t){let n=g("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(W(e.value,t)??0),o=D(e.max)??100,i=o>0?Math.max(0,Math.min(100,r/o*100)):0;n.setAttribute("aria-valuenow",String(r)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(o)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let s=g("div","pf-progress-fill");return s.style.height="100%",s.style.width=`${i}%`,s.style.borderRadius="4px",s.style.transition="width 0.3s ease",n.appendChild(s),n}function zo(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Wo(e,t){let n=g("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function Ko(e,t){let n=g("span","pf-icon");return n.setAttribute("data-icon",w(e.name??e.content,t)),n}function Jo(e,t){let n=g("div","pf-sparkline"),r=Array.isArray(e.data)?e.data.filter((h)=>typeof h==="number"&&Number.isFinite(h)):[];if(r.length===0)return n;let o=D(e.width)??120,i=D(e.height)??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("width",String(o)),c.setAttribute("height",String(i)),c.setAttribute("viewBox",`0 0 ${o} ${i}`);let u=r.length>1?r.length-1:1,d=r.map((h,C)=>{let f=C/u*o,y=i-(h-a)/l*(i-4)-2;return`${f},${y}`}).join(" "),m=document.createElementNS("http://www.w3.org/2000/svg","polyline");return m.setAttribute("points",d),m.setAttribute("fill","none"),m.setAttribute("stroke","var(--primary, #3b82f6)"),m.setAttribute("stroke-width","1.5"),c.appendChild(m),n.appendChild(c),n}function Go(e,t){let r={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(r)e.style.backgroundColor=r.bg,e.style.color=r.fg}function Mn(){p("Form",qo),p("Input",Uo),p("Textarea",Ce(Xo)),p("Button",Yo),p("ButtonGroup",Zo),p("Checkbox",Qo),p("Switch",ei),p("Slider",Ce(ti)),p("Calendar",ri),p("DatePicker",Ce(oi)),p("Field",Pe("pf-field")),p("FieldTitle",xe("pf-field-title")),p("FieldDescription",xe("pf-field-description")),p("FieldContent",Pe("pf-field-content")),p("FieldError",xe("pf-field-error"))}function qo(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(r)=>{r.preventDefault();let o=new FormData(n),i={};for(let s of new Set(o.keys())){let a=o.getAll(s),l=n.elements.namedItem(s),c=l instanceof HTMLSelectElement&&l.multiple||a.length>1;i[s]=c?a:a[0]}if(t.store.merge(i),e.onSubmit!=null){let s=V(t);s.scope={...t.scope,...i},O(P(e.onSubmit,s),"onSubmit")}}),N(e,n,t),n}function Nn(e,t,n){if(t.label==null)return;let r=document.createElement("label");if(r.className="pf-input-label",r.textContent=w(t.label,n),t.name!=null)r.htmlFor=k(t.name);r.style.fontSize="14px",r.style.fontWeight="500",e.insertBefore(r,e.firstChild)}function Ce(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",Nn(r,t,n),r}}function se(e,t){if(t.required!==!0)return;if("required"in e)e.required=!0;e.setAttribute("aria-required","true")}function Uo(e,t){let n=g("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",Nn(n,e,t);let r=document.createElement("input");if(r.className="pf-input",r.type=b(e.inputType)??"text",e.name!=null)r.name=k(e.name);if(e.name!=null)r.id=`pf-input-${k(e.name)}`;if(e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(se(r,e),e.error!=null)r.setAttribute("aria-invalid","true");let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Qe(r),n.appendChild(r),n}function Xo(e,t){let n=g("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=k(e.name);if(e.name!=null)r.id=`pf-textarea-${k(e.name)}`;if(e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.rows!=null)r.rows=Number(e.rows);se(r,e);let o=b(e.name);if(o!=null){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Qe(r),n.appendChild(r),n}function Yo(e,t){let n=document.createElement("button");n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=w(e.label,t);let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),ni(n,r),e.size!=null)n.setAttribute("data-size",k(e.size));if(e.disabled===!0)n.disabled=!0;return n}function Zo(e,t){let n=g("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",N(e,n,t),n}function Qo(e,t){let n=g("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-checkbox",e.name!=null)r.name=k(e.name);if(e.checked===!0)r.checked=!0;let o=b(e.name);if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=w(e.label,t),n.appendChild(i)}return n}function ei(e,t){let n=g("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-switch",r.setAttribute("role","switch"),e.name!=null)r.name=k(e.name);let o=b(e.name);if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=g("span");i.textContent=w(e.label,t),n.appendChild(i)}return n}function ti(e,t){let n=g("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=k(e.name);if(e.min!=null)r.min=k(e.min);if(e.max!=null)r.max=k(e.max);if(e.step!=null)r.step=k(e.step);let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)r.value=k(i);r.addEventListener("input",()=>{if(t.store.set(o,Number(r.value)),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function Qe(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function ni(e,t){if(e.style.padding="8px 16px",e.style.fontSize="14px",e.style.fontWeight="500",e.style.cursor="pointer",e.style.border="none",t==="ghost")e.style.backgroundColor="transparent",e.style.color="inherit"}function Pe(e){return(t,n)=>{let r=g("div",e);return N(t,r,n),r}}function xe(e){return(t,n)=>{let r=g("span",e);return r.textContent=w(t.content,n),r}}function Rt(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function ri(e,t){let n=g("div","pf-calendar"),r=document.createElement("input");if(r.type="date",r.name=w(e.name,t),se(r,e),e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);if(e.minDate!=null)r.min=w(e.minDate,t);if(e.maxDate!=null)r.max=w(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)O(P(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function oi(e,t){let n=g("div","pf-datepicker"),r=document.createElement("input");if(r.type="date",r.name=w(e.name,t),se(r,e),e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);if(e.minDate!=null)r.min=w(e.minDate,t);if(e.maxDate!=null)r.max=w(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)O(P(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function Ln(){p("Select",Ce(ii)),p("SelectOption",li),p("SelectGroup",Pe("pf-select-group")),p("SelectLabel",xe("pf-select-label")),p("SelectSeparator",Rt),p("Radio",ci),p("RadioGroup",di),p("Combobox",Ce(pi)),p("ComboboxOption",ui),p("ComboboxGroup",Pe("pf-combobox-group")),p("ComboboxLabel",xe("pf-combobox-label")),p("ComboboxSeparator",Rt),p("ChoiceCard",fi)}function ii(e,t){let n=g("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=k(e.name);if(e.multiple===!0)r.multiple=!0;if(se(r,e),Qe(r),e.placeholder!=null){let s=document.createElement("option");s.value="",s.textContent=w(e.placeholder,t),s.disabled=!0,s.selected=!0,s.hidden=!0,r.appendChild(s)}let o=e.options;if(Array.isArray(o))for(let s of o){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}if(e.children)for(let s of e.children)if(s.type==="SelectOption"){let a=document.createElement("option");a.value=b(s.value)??"",a.textContent=b(s.label)??a.value,r.appendChild(a)}else r.appendChild(j(s,t));let i=b(e.name);if(i){let s=t.store.get(i);if(s!=null)ai(r,s);r.addEventListener("change",()=>{let a=si(r);if(t.store.set(i,a),e.onChange!=null)O(P(e.onChange,{...V(t),scope:{...t.scope,$event:a}}),"onChange")})}return n.appendChild(r),n}function si(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function ai(e,t){if(!e.multiple){e.value=k(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>k(r)));for(let r of e.options)r.selected=n.has(r.value)}function li(e,t){return g("span")}function ci(e,t){let n=g("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="radio",r.value=w(e.value,t),n.appendChild(r),e.label!=null){let o=g("span","pf-radio-label");o.textContent=w(e.label,t),n.appendChild(o)}return n}function di(e,t){let n=g("fieldset","pf-radio-group");if(se(n,e),n.style.border="none",n.style.padding="0",n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",e.label!=null){let i=document.createElement("legend");i.textContent=w(e.label,t),i.style.fontWeight="500",i.style.marginBottom="4px",n.appendChild(i)}N(e,n,t);let r=w(e.name,t),o=t.store.get(r);for(let i of Array.from(n.querySelectorAll('input[type="radio"]')))if(i.name=r,o!=null&&i.value===k(o))i.checked=!0;return n.addEventListener("change",(i)=>{let s=i.target;if(s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)O(P(e.onChange,V(t)),"onChange")}}),n}function pi(e,t){let n=g("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=w(e.name,t),se(r,e),e.placeholder!=null)r.placeholder=w(e.placeholder,t);if(e.value!==void 0)r.value=w(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=k(i);r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box";let s=g("div","pf-combobox-dropdown");if(s.style.display="none",s.style.position="absolute",s.style.borderRadius="6px",s.style.maxHeight="200px",s.style.overflowY="auto",s.style.zIndex="50",N(e,s,t),r.addEventListener("focus",()=>{s.style.display="block"}),r.addEventListener("blur",()=>{setTimeout(()=>{s.style.display="none"},150)}),e.searchable!==!1)r.addEventListener("input",()=>{let a=r.value.toLowerCase();for(let l of Array.from(s.querySelectorAll(".pf-combobox-option"))){let c=(l.textContent??"").toLowerCase();l.style.display=c.includes(a)?"":"none"}});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{O(P(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function ui(e,t){let n=g("div","pf-combobox-option");return n.style.padding="6px 12px",n.style.cursor="pointer",n.textContent=w(e.label??e.value,t),n.dataset.value=w(e.value,t),n.addEventListener("mousedown",()=>{let r=n.closest(".pf-combobox"),o=r?.querySelector("input");if(o)o.value=n.dataset.value??"",t.store.set(o.name,o.value),r?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function fi(e,t){let n=g("div","pf-choice-card");if(n.style.padding="16px",n.style.cursor="pointer",n.style.transition="border-color 0.2s",n.dataset.value=w(e.value,t),e.selected===!0)n.dataset.selected="true";if(e.label!=null){let r=g("div","pf-choice-card-label");r.textContent=w(e.label,t),r.style.fontWeight="600",n.appendChild(r)}if(e.description!=null){let r=g("div","pf-choice-card-description");r.textContent=w(e.description,t),r.style.fontSize="14px",n.appendChild(r)}return N(e,n,t),n}function Hn(){p("Tabs",mi),p("Tab",gi),p("Accordion",hi),p("AccordionItem",bi),p("Dialog",yi),p("Popover",Ci),p("Tooltip",xi),p("HoverCard",wi),p("Carousel",vi)}function mi(e,t){let n=g("div","pf-tabs"),r=g("div","pf-tabs-bar");r.setAttribute("role","tablist"),r.style.display="flex",r.style.gap="4px",r.style.marginBottom="12px";let o=[],i=[],s=e.children??[],a=(()=>{let c=e.defaultTab;if(typeof c==="number")return c>=0&&c<s.length?c:0;if(typeof c==="string"){let u=s.findIndex((d)=>d.title===c);return u>=0?u:0}return 0})();if(e.children)for(let c=0;c<e.children.length;c++){let u=e.children[c],d=`pf-tab-${Math.random().toString(36).slice(2,8)}`,m=`pf-panel-${Math.random().toString(36).slice(2,8)}`,h=document.createElement("button");h.type="button",h.className="pf-tab-trigger",h.textContent=b(u.title)??`Tab ${String(c+1)}`,h.setAttribute("role","tab"),h.setAttribute("aria-selected",c===a?"true":"false"),h.setAttribute("aria-controls",m),h.id=d,h.tabIndex=c===a?0:-1,h.style.padding="8px 16px",h.style.border="none",h.style.background="none",h.style.cursor="pointer",h.style.borderBottom="2px solid transparent",h.style.marginBottom="-2px",h.style.fontSize="14px";let C=g("div","pf-tab-panel");if(C.style.display=c===a?"block":"none",C.setAttribute("role","tabpanel"),C.setAttribute("aria-labelledby",d),C.id=m,C.tabIndex=0,N(u,C,t),h.addEventListener("click",()=>{l(c)}),c===a)h.classList.add("pf-tab-active"),h.style.fontWeight="600";i.push(h),o.push(C),r.appendChild(h)}function l(c){o.forEach((u)=>u.style.display="none"),i.forEach((u)=>{u.style.borderBottomColor="transparent",u.style.fontWeight="normal",u.classList.remove("pf-tab-active"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}),o[c].style.display="block",i[c].classList.add("pf-tab-active"),i[c].style.fontWeight="600",i[c].setAttribute("aria-selected","true"),i[c].tabIndex=0,i[c].focus()}r.addEventListener("keydown",(c)=>{let u=i.indexOf(c.target);if(u<0)return;let d;if(c.key==="ArrowRight")d=(u+1)%i.length;else if(c.key==="ArrowLeft")d=(u-1+i.length)%i.length;else if(c.key==="Home")d=0;else if(c.key==="End")d=i.length-1;else return;c.preventDefault(),l(d)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function gi(e,t){let n=g("div","pf-tab");return N(e,n,t),n}function hi(e,t){let n=g("div","pf-accordion");return N(e,n,t),n}function bi(e,t){let n=g("div","pf-accordion-item"),r=`pf-acc-${Math.random().toString(36).slice(2,8)}`,o=document.createElement("button");o.type="button",o.className="pf-accordion-trigger",o.textContent=b(e.title)??"",o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",r),o.style.width="100%",o.style.textAlign="left",o.style.padding="12px 0",o.style.border="none",o.style.background="none",o.style.cursor="pointer",o.style.fontSize="14px",o.style.fontWeight="500";let i=g("div","pf-accordion-content");return i.id=r,i.setAttribute("role","region"),i.setAttribute("aria-labelledby",o.id),i.style.display="none",i.style.paddingBottom="12px",N(e,i,t),o.addEventListener("click",()=>{let s=i.style.display!=="none";i.style.display=s?"none":"block",o.setAttribute("aria-expanded",s?"false":"true")}),n.appendChild(o),n.appendChild(i),n}function yi(e,t){let n=g("div","pf-dialog-wrapper");if(e.trigger!=null){let i=j(e.trigger,t);i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i)}let r=document.createElement("dialog");if(r.className="pf-dialog",r.setAttribute("aria-modal","true"),r.style.maxWidth="500px",r.style.width="100%",r.style.padding="24px",e.title!=null){let i=g("h2","pf-dialog-title");i.textContent=w(e.title,t),i.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",i.id),r.appendChild(i)}if(e.description!=null){let i=g("p","pf-dialog-desc");i.textContent=w(e.description,t),r.appendChild(i)}let o=g("div","pf-dialog-body");if(N(e,o,t),r.appendChild(o),e.dismissible!==!1)r.addEventListener("click",(i)=>{if(i.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function Ci(e,t){let n=g("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-popover-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="12px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let i=g("div","pf-popover-title");i.textContent=w(e.title,t),i.style.fontWeight="600",i.style.marginBottom="4px",r.appendChild(i)}N(e,r,t);let o=()=>{r.style.display=r.style.display==="none"?"block":"none"};if(e.trigger!=null){let i=j(e.trigger,t);i.addEventListener("click",(s)=>{s.stopPropagation(),o()}),n.appendChild(i)}else n.addEventListener("click",(i)=>{if(r.contains(i.target)&&r.style.display!=="none")return;o()});return n.appendChild(r),n}function xi(e,t){let n=g("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let r=`pf-tip-${Math.random().toString(36).slice(2,8)}`,o=g("div","pf-tooltip-content");return o.id=r,o.setAttribute("role","tooltip"),o.textContent=w(e.content??"",t),o.style.display="none",o.style.position="absolute",o.style.bottom="100%",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.padding="4px 8px",o.style.borderRadius="4px",o.style.color="#fff",o.style.fontSize="12px",o.style.whiteSpace="nowrap",o.style.zIndex="50",N(e,n,t),n.setAttribute("aria-describedby",r),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.addEventListener("focus",()=>{o.style.display="block"},!0),n.addEventListener("blur",()=>{o.style.display="none"},!0),n.appendChild(o),n}function wi(e,t){let n=g("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let r=g("div","pf-hover-card-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="16px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",r.style.minWidth="200px",e.trigger!=null)n.appendChild(j(e.trigger,t));return N(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function vi(e,t){let n=g("div","pf-carousel");n.style.position="relative",n.style.overflow="hidden",n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",w(e.label??"Carousel",t));let r=g("div","pf-carousel-track");r.style.display="flex",r.style.transition="transform 0.3s ease",N(e,r,t);let o=0,i=e.children?.length??0,s=document.createElement("button");s.type="button",s.textContent="‹",s.className="pf-carousel-prev",s.setAttribute("aria-label","Previous slide"),s.style.position="absolute",s.style.left="4px",s.style.top="50%",s.style.transform="translateY(-50%)",s.style.zIndex="10";let a=document.createElement("button");a.type="button",a.textContent="›",a.className="pf-carousel-next",a.setAttribute("aria-label","Next slide"),a.style.position="absolute",a.style.right="4px",a.style.top="50%",a.style.transform="translateY(-50%)",a.style.zIndex="10";let l=()=>{r.style.transform=`translateX(-${o*100}%)`};return s.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),l()}),a.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),l()}),n.appendChild(r),n.appendChild(s),n.appendChild(a),n}function ki(e){if(!S(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Array.isArray(n)?n.filter(Le):[]]))}function Pn(){p("ForEach",Si),p("If",$n),p("Elif",Ei),p("Else",Ri),p("Condition",Ti),p("Define",Ai),p("Use",Mi),p("Slot",Ni)}function Si(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(J(r)){let s=G(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=I(e.let)??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},c={...t,scope:l};if(e.children)ie(e.children,n,c)}return n}function $n(e,t){if(On(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)ie(e.children,r,t);return r}return document.createDocumentFragment()}function Ei(e,t){return $n(e,t)}function Ri(e,t){let n=document.createDocumentFragment();if(e.children)ie(e.children,n,t);return n}function On(e,t){if(!e)return!1;if(J(e))return Boolean(G(e,t.store,t.scope));return Boolean(t.store.get(e))}function Ti(e,t){let n=document.createDocumentFragment(),{cases:r,else:o}=e;if(r){for(let i of r)if(On(i.when,t)){if(i.children)ie(i.children,n,t);return n}}if(o)ie(o,n,t);return n}function Ai(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Mi(e,t){let n=document.createDocumentFragment(),r=b(e.def??e.name),o=r!=null?t.templates?.[r]:void 0;if(!o)return n;let i=I(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...ki(e.slots)};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let c of o)n.appendChild(j(c,l));return n}function Ni(e,t){let n=document.createDocumentFragment(),r=b(e.name)??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(j(s,t));return n}function Dn(){p("Alert",Li),p("AlertTitle",Hi),p("AlertDescription",Pi)}function Li(e,t){let n=g("div","pf-alert");n.setAttribute("role","alert");let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),n.style.padding="12px 16px",e.icon!=null){let o=g("span","pf-alert-icon");o.setAttribute("data-icon",k(e.icon)),o.style.marginRight="8px",n.appendChild(o)}return N(e,n,t),n}function Hi(e,t){let n=g("h5","pf-alert-title");return n.textContent=w(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function Pi(e,t){let n=g("p","pf-alert-description");return n.textContent=w(e.content,t),n.style.fontSize="14px",n}function In(){p("Image",$i),p("Audio",Oi),p("Video",Di),p("Embed",Ii),p("Svg",Fi),p("DropZone",Vi),p("Mermaid",_i)}function $i(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=w(e.src,t),e.alt!=null)n.alt=w(e.alt,t);if(e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Oi(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=w(e.src,t),n.controls=!0,n}function Di(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=w(e.src,t),n.controls=!0,e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.style.maxWidth="100%",n}function Ii(e,t){let n=g("div","pf-embed"),r=document.createElement("iframe");return r.src=w(e.src,t),r.style.width="100%",r.style.height=e.height!=null?`${String(Number(e.height))}px`:"400px",r.style.border="none",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var ji=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","defs","use","symbol","clippath","mask","pattern","lineargradient","radialgradient","stop","filter","fegaussianblur","feoffset","femerge","femergenode","fecolormatrix","feblend","title","desc"]);function Fi(e,t){let n=g("div","pf-svg"),r=w(e.content,t);if(!r.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(r))r=r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let i=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!i)return n;return jn(i),n.appendChild(document.importNode(i,!0)),n}function jn(e){let t=Array.from(e.children);for(let n of t){if(!ji.has(n.tagName.toLowerCase())){n.remove();continue}for(let r of Array.from(n.attributes)){let o=r.name.toLowerCase();if(o.startsWith("on")||o==="href"&&r.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(r.name)}jn(n)}}function Bi(e,t){let n=(t??"").split(",").map((i)=>i.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let r=e.name.toLowerCase(),o=e.type.toLowerCase();return n.some((i)=>{if(i.startsWith("."))return r.endsWith(i);if(i.endsWith("/*"))return o.startsWith(i.slice(0,-1));return o===i})}function Vi(e,t){let n=g("div","pf-dropzone");n.style.padding="32px",n.style.textAlign="center",n.style.cursor="pointer",n.textContent=w(e.label??"Drop files here",t);let r=document.createElement("input");if(r.type="file",r.style.display="none",e.accept!=null)r.accept=k(e.accept);if(e.multiple===!0)r.multiple=!0;n.appendChild(r),n.setAttribute("role","button"),n.tabIndex=0;function o(s){let a=Array.from(s??[]).filter((l)=>Bi(l,b(e.accept)));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;let a=b(e.resultKey);if(a!=null)t.store.set(a,s),t.rerender();if(e.onDrop!=null)O(P(e.onDrop,{...V(t),scope:{...t.scope,$result:s}}),"onDrop")}return r.addEventListener("change",()=>{i(o(r.files)),r.value=""}),n.addEventListener("click",()=>r.click()),n.addEventListener("keydown",(s)=>{if(s.key==="Enter"||s.key===" ")s.preventDefault(),r.click()}),n.addEventListener("dragover",(s)=>{s.preventDefault(),n.classList.add("pf-dropzone-active")}),n.addEventListener("dragleave",()=>{n.classList.remove("pf-dropzone-active")}),n.addEventListener("drop",(s)=>{s.preventDefault(),n.classList.remove("pf-dropzone-active"),i(o(s.dataTransfer?.files??null))}),n}function _i(e,t){let n=g("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=w(e.content,t);if(n.textContent=r,"mermaid"in globalThis)n.classList.add("mermaid"),n.textContent=r;return n}var zi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Wi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",Tt=null,et=null;function Ki(e){return S(e)&&typeof e.getDocument==="function"&&S(e.GlobalWorkerOptions)}function At(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function Ji(e){return e==="fit-page"||e==="fit-width"?e:At(e,0)||"fit-width"}async function Gi(){if(Tt)return Tt;if(et)return et;return et=import(zi).then((e)=>{if(!Ki(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=Wi,Tt=t,t}),et}function Bn(){p("PdfViewer",qi)}function qi(e,t){let n=g("div","pf-pdf-viewer"),r=e.src!=null?w(e.src,t):void 0,o=b(e.data),i=At(e.page,1),s=Ji(e.zoom),a=e.toolbar!==!1,l=At(e.height,600);n.style.height=`${l}px`,n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",n.style.border="1px solid var(--color-border-primary, #e5e7eb)",n.style.borderRadius="var(--border-radius-md, 0.375rem)",n.style.background="var(--color-background-secondary, #f9fafb)";let c=g("div","pf-pdf-loading");return c.textContent="Loading PDF…",c.style.display="flex",c.style.alignItems="center",c.style.justifyContent="center",c.style.flex="1",c.style.color="var(--color-text-secondary, #6b7280)",n.appendChild(c),Ui(n,c,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function Ui(e,t,n){try{let r=await Gi(),o;if(n.src)o={url:n.src};else if(n.data){let m=atob(n.data),h=new Uint8Array(m.length);for(let C=0;C<m.length;C++)h[C]=m.charCodeAt(C);o={data:h}}else{t.textContent="Error: No PDF source provided";return}let i=await r.getDocument(o).promise;t.remove();let s=Math.max(1,Math.min(n.initialPage,i.numPages)),a=null,l=null;if(n.showToolbar){let m=Xi(i.numPages,s,{onPrev:()=>{if(s>1)s--,d()},onNext:()=>{if(s<i.numPages)s++,d()},onPageChange:(h)=>{let C=Math.max(1,Math.min(h,i.numPages));if(C!==s)s=C,d()}});a=m.pageInput,l=m.pageCount,e.insertBefore(m.el,e.firstChild)}let c=g("div","pf-pdf-canvas-container");c.style.flex="1",c.style.overflow="auto",c.style.display="flex",c.style.justifyContent="center",c.style.padding="8px",e.appendChild(c);let u=document.createElement("canvas");u.style.display="block",u.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",c.appendChild(u);async function d(){let m=await i.getPage(s),h=c.clientWidth-16,C,f=m.getViewport({scale:1});if(n.zoom==="fit-width")C=h/f.width;else if(n.zoom==="fit-page"){let v=c.clientHeight-16,R=h/f.width,T=v/f.height;C=Math.min(R,T)}else C=typeof n.zoom==="number"?n.zoom:1;let y=m.getViewport({scale:C});u.width=y.width,u.height=y.height,u.style.width=`${y.width}px`,u.style.height=`${y.height}px`;let x=u.getContext("2d");if(!x)return;if(await m.render({canvasContext:x,viewport:y}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await d()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function Xi(e,t,n){let r=g("div","pf-pdf-toolbar");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.padding="6px 12px",r.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",r.style.background="var(--color-background-primary, #fff)",r.style.flexShrink="0",r.style.fontSize="13px";let o=document.createElement("button");o.textContent="‹",o.title="Previous page",o.className="pf-pdf-btn",Fn(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",Fn(i),i.addEventListener("click",n.onNext);let s=document.createElement("input");s.type="number",s.min="1",s.max=String(e),s.value=String(t),s.style.width="48px",s.style.textAlign="center",s.style.border="1px solid var(--color-border-primary, #e5e7eb)",s.style.borderRadius="4px",s.style.padding="2px 4px",s.style.fontSize="13px",s.addEventListener("change",()=>{let l=parseInt(s.value,10);if(!isNaN(l))n.onPageChange(l)});let a=document.createElement("span");return a.textContent=`/ ${e}`,a.style.color="var(--color-text-secondary, #6b7280)",r.appendChild(o),r.appendChild(s),r.appendChild(a),r.appendChild(i),{el:r,pageInput:s,pageCount:a}}function Fn(e){e.style.border="1px solid var(--color-border-primary, #e5e7eb)",e.style.borderRadius="4px",e.style.background="var(--color-background-primary, #fff)",e.style.cursor="pointer",e.style.padding="2px 8px",e.style.fontSize="16px",e.style.lineHeight="1"}var F=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],X="var(--muted-foreground, #6b7280)",ue="var(--border, #e5e7eb)",ae="10";function tt(e,t,n,r=!1){let o=n?44:0,i=e-(r?44:0),s=10,a=t-24;return{plotLeft:o,plotRight:i,plotTop:10,plotBottom:a,plotWidth:i-o,plotHeight:a-10}}function Vn(e,t=5){if(e<=0)return[0];let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,i=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r,s=[];for(let a=0;a<=e+i*0.01;a+=i)s.push(Math.round(a*1000)/1000);return s}function _n(e,t,n,r,o){let i=Vn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=z("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":ae,fill:X});if(l.textContent=Nt(s,o),e.appendChild(l),r&&s>0)e.appendChild(z("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function zn(e,t,n,r){let o=Vn(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=z("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":ae,fill:X});a.textContent=Nt(i,r),e.appendChild(a)}}function Mt(e,t,n,r,o,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=z("text",{x:r(s),y:o+14,"text-anchor":"middle","font-size":ae,fill:X});l.textContent=a==null?"":i?i(a):k(a),e.appendChild(l)}}function nt(e,t){e.appendChild(z("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function le(e,t,n){if(e==null)return"";let r=W(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return k(r??e)}function Nt(e,t){if(t==="currency")return`$${e.toLocaleString()}`;if(t==="percent")return`${e}%`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1000)return`${(e/1000).toFixed(1)}K`;return String(e)}function ce(e){let t=b(e.yAxisFormat)??b(e.valueFormat);return t&&t!=="auto"?t:void 0}function Lt(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return le(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return Nt(Number(r),i)}}function te(e,t,n){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r.setAttribute("width","100%"),r.setAttribute("height",String(t)),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("role","img"),n)r.setAttribute("aria-label",`${n} chart`);return r.style.overflow="visible",r}function z(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function $e(e,t){let n=z("text",e);return n.textContent=t,n}function fe(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function Ht(e,t,n,r,o){let i=Math.max(2,Math.ceil(Math.abs(o-r)/4)),s=[];for(let a=0;a<=i;a++){let l=fe(e,t,n,r+(o-r)*a/i);s.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return s.join(" ")}function ne(e,t,n){if(!n||t.length<=1)return;let r=g("div","pf-chart-legend");r.style.display="flex",r.style.gap="12px",r.style.fontSize="12px",r.style.marginBottom="8px";for(let o=0;o<t.length;o++){let i=g("div","pf-chart-legend-item");i.style.display="flex",i.style.alignItems="center",i.style.gap="4px";let s=g("span");s.style.width="8px",s.style.height="8px",s.style.borderRadius="50%",s.style.backgroundColor=t[o].color??F[o%F.length];let a=g("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}function re(e,t){let n=document.createElement("div");return n.className="pf-chart-tooltip",e.appendChild(n),e.addEventListener("mouseleave",()=>{n.classList.remove("pf-visible")}),{wrapper:e,tooltip:n,svgEl:t}}function Pt(e,t,n,r,o){let{tooltip:i,svgEl:s,wrapper:a}=e;if(o.length===0)return;let l="";if(r)l+=`<div class="pf-chart-tooltip-label">${rt(r)}</div>`;for(let y of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${rt(y.color)}"></span>`,l+=`<span>${rt(y.label)}:</span> <strong>${rt(String(y.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),u=a.getBoundingClientRect(),d=s.viewBox.baseVal,m=c.width/(d.width||1),h=c.left-u.left+t*m,C=i.offsetWidth||100,f=h+12;if(f+C>u.width)f=h-C-12;i.style.left=`${Math.max(0,f)}px`,i.style.top="4px",i.classList.add("pf-visible")}function rt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function we(e,t,n,r,o,i){let s=()=>{Pt(t,n,r,o,i)},a=()=>{t.tooltip.classList.remove("pf-visible")};e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",a),e.addEventListener("touchstart",s,{passive:!0}),e.addEventListener("touchend",a,{passive:!0})}function Wn(e,t,n,r,o,i,s,a){let l=o.plotWidth/n.length;for(let c=0;c<n.length;c++){let u=o.plotLeft+c*l,d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("x",String(u)),d.setAttribute("y",String(o.plotTop)),d.setAttribute("width",String(l)),d.setAttribute("height",String(o.plotHeight)),d.setAttribute("fill","transparent"),d.style.cursor="default";let m=i?n[c][i]:void 0,h=m!=null?a?a(m):k(m):void 0,C=r.map((v,R)=>({label:v.label??v.dataKey,value:s(n[c][v.dataKey],v,R),color:v.color??F[R%F.length]})),f=u+l/2,y=()=>Pt(e,f,o.plotTop,h,C),x=()=>e.tooltip.classList.remove("pf-visible");d.addEventListener("mouseenter",y),d.addEventListener("mouseleave",x),d.addEventListener("touchstart",y,{passive:!0}),d.addEventListener("touchend",x,{passive:!0}),t.appendChild(d)}}function Kn(e,t,n,r,o,i,s,a,l,c){let u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let d=0;d<n.length;d++){let m=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+d/(n.length-1)*o.plotWidth,h=n.length===1?o.plotLeft:m-u/2,C=n.length===1?o.plotWidth:u,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Math.max(o.plotLeft,h))),f.setAttribute("y",String(o.plotTop)),f.setAttribute("width",String(Math.min(C,o.plotRight-Math.max(o.plotLeft,h)))),f.setAttribute("height",String(o.plotHeight)),f.setAttribute("fill","transparent"),f.style.cursor="default";let y=i?n[d][i]:void 0,x=y!=null?c?c(y):k(y):void 0,v=r.map((E,A)=>({label:E.label??E.dataKey,value:s(n[d][E.dataKey],E,A),color:E.color??F[A%F.length]})),R=()=>{if(Pt(e,m,o.plotTop,x,v),a)a.setAttribute("x1",String(m)),a.setAttribute("x2",String(m)),a.setAttribute("opacity","1");if(l)for(let E of l){for(let A of E)A.setAttribute("data-visible","false");E[d]?.setAttribute("data-visible","true")}},T=()=>{if(e.tooltip.classList.remove("pf-visible"),a)a.setAttribute("opacity","0");if(l)for(let E of l)for(let A of E)A.setAttribute("data-visible","false")};f.addEventListener("mouseenter",R),f.addEventListener("mouseleave",T),f.addEventListener("touchstart",R,{passive:!0}),f.addEventListener("touchend",T,{passive:!0}),t.appendChild(f)}}function me(e,t){return Ee(W(e.data,t))}function Jn(e,t){let n=W(e.data,t);if(!Array.isArray(n))return;let r=n.filter((o)=>typeof o==="number"&&Number.isFinite(o));return r.length>0?r:void 0}function Yi(e){return e==="left"||e==="right"?e:void 0}function Zi(e){if(!S(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=Yi(e.yAxisId),o=b(e.tooltipFormat);return{dataKey:e.dataKey,...t!==void 0&&{label:t},...n!==void 0&&{color:n},...r!==void 0&&{yAxisId:r},...o!==void 0&&{tooltipFormat:o}}}function ge(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=Zi(t);return n?[n]:[]})}function de(e,t){return D(e.height)??t}function Oe(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function $t(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function Ot(e,t){return{rows:me(e,t),series:ge(e),height:de(e,300),showYAxis:e.showYAxis!==!1,showGrid:e.showGrid===!0,showYAxisRight:e.showYAxisRight===!0,showTooltip:e.showTooltip!==!1,showLegend:e.showLegend!==!1,xAxisKey:b(e.xAxis),tooltipXKey:b(e.tooltipXKey),xAxisFormat:b(e.xAxisFormat),tooltipXFormat:b(e.tooltipXFormat),yAxisRightFormat:b(e.yAxisRightFormat)}}function Gn(e,t,n){let r=t.series.filter((d)=>d.yAxisId!=="right"),o=t.series.filter((d)=>d.yAxisId==="right"),i=t.showYAxisRight&&o.length>0,s=r.length>0?Oe(t.rows,r):1,a=i?Oe(t.rows,o):1,l=400,c=tt(400,t.height,t.showYAxis,i),u=te(400,t.height,n);if(t.showYAxis)_n(u,c,s,t.showGrid,ce(e));if(i)zn(u,c,a,t.yAxisRightFormat);return nt(u,c),{layout:c,svg:u,leftMax:s,rightMax:a}}function ot(e,t){return e?(n)=>le(n,e,t):void 0}function qn(e,t){let n=g("div","pf-chart pf-bar-chart"),r=Ot(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let{layout:s,svg:a,leftMax:l,rightMax:c}=Gn(e,r,"Bar"),u=s.plotWidth/o.length,d=u/(i.length+1);for(let m=0;m<o.length;m++)for(let h=0;h<i.length;h++){let C=i[h],f=o[m][C.dataKey];if(f===null||f===void 0)continue;let y=C.yAxisId==="right"?c:l,x=Math.max(0,Number(f)/y*s.plotHeight),v=s.plotLeft+m*u+h*d+d/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(v)),R.setAttribute("y",String(s.plotBottom-x)),R.setAttribute("width",String(d*0.8)),R.setAttribute("height",String(x)),R.setAttribute("fill",C.color??F[h%F.length]),R.setAttribute("rx","2"),a.appendChild(R)}if(r.xAxisKey)Mt(a,o,r.xAxisKey,(m)=>s.plotLeft+m*u+u/2,s.plotBottom,ot(r.xAxisFormat,t));if(r.showTooltip){let m=re(n,a),h=Lt(t,ce(e),r.yAxisRightFormat);Wn(m,a,o,i,s,r.tooltipXKey??r.xAxisKey,h,ot(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(a),n}function Qi(e,t,n,r){let o=[],i=()=>{if(o.length<2){o=[];return}let s=`M ${o[0].x},${n} `+o.map((l)=>`L ${l.x},${l.y}`).join(" ")+` L ${o[o.length-1].x},${n} Z`,a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",s),a.setAttribute("fill",r),a.setAttribute("opacity","0.15"),e.appendChild(a),o=[]};for(let s of t){if(s.isNull){i();continue}o.push(s)}i()}function es(e,t,n,r){let o="";for(let s of t){if(s.isNull)continue;let a=t.indexOf(s),l=a===0||t[a-1].isNull;o+=`${l?"M":"L"} ${s.x},${s.y} `}if(!o)return;let i=document.createElementNS("http://www.w3.org/2000/svg","path");if(i.setAttribute("d",o.trim()),i.setAttribute("fill","none"),i.setAttribute("stroke",n),i.setAttribute("stroke-width","2"),r)i.setAttribute("stroke-dasharray","6 3");e.appendChild(i)}function ts(e,t,n){let r=[];for(let o of t){let i=document.createElementNS("http://www.w3.org/2000/svg","circle");if(i.setAttribute("cx",String(o.x)),i.setAttribute("cy",String(o.y)),i.setAttribute("r","4"),i.setAttribute("fill",n),i.setAttribute("class","pf-data-dot"),i.setAttribute("data-visible","false"),i.style.pointerEvents="none",o.isNull)i.style.display="none";e.appendChild(i),r.push(i)}return r}function ns(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg","line");return n.setAttribute("class","pf-crosshair"),n.setAttribute("x1",String(t.plotLeft)),n.setAttribute("x2",String(t.plotLeft)),n.setAttribute("y1",String(t.plotTop)),n.setAttribute("y2",String(t.plotBottom)),n.setAttribute("stroke",X),n.setAttribute("stroke-width","1"),n.setAttribute("stroke-dasharray","3 3"),n.setAttribute("opacity","0"),e.appendChild(n),n}function Dt(e,t){let n=g("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=Ot(e,t),{rows:o,series:i}=r;if(o.length===0||i.length===0)return n.textContent="No chart data",n;let s=e.type==="AreaChart",{layout:a,svg:l,leftMax:c,rightMax:u}=Gn(e,r,s?"Area":"Line"),d=(C)=>o.length===1?(a.plotLeft+a.plotRight)/2:a.plotLeft+C/(o.length-1)*a.plotWidth,m=[];for(let C=0;C<i.length;C++){let f=i[C],y=f.yAxisId==="right",x=y?u:c,v=f.color??F[C%F.length],R=o.map((T,E)=>{let A=T[f.dataKey],B=A===null||A===void 0,H=B?a.plotBottom:a.plotBottom-Number(A)/x*a.plotHeight;return{x:d(E),y:H,isNull:B}});if(s)Qi(l,R,a.plotBottom,v);es(l,R,v,y),m.push(ts(l,R,v))}let h=ns(l,a);if(r.xAxisKey)Mt(l,o,r.xAxisKey,d,a.plotBottom,ot(r.xAxisFormat,t));if(r.showTooltip){let C=re(n,l),f=Lt(t,ce(e),r.yAxisRightFormat);Kn(C,l,o,i,a,r.tooltipXKey??r.xAxisKey,f,h,m,ot(r.tooltipXFormat,t))}return ne(n,i,r.showLegend),n.appendChild(l),n}function It(e,t){let n=ce(e);return(r)=>n?le(r,n,t):String(r)}function Un(e,t){let n=g("div","pf-chart pf-pie-chart"),r=me(e,t),o=ge(e),i=Math.min(de(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=$t(e,o),c=o.length>0?o:a?[{dataKey:a,label:a}]:[];if(r.length===0||!a)return n.textContent="No chart data",n;let u=te(i,i,"Pie"),d=i/2,m=i/2,h=i/2-10,C=b(e.tooltipXFormat),f=It(e,t),y=r.map((T)=>Number(T[a]??0)),x=y.reduce((T,E)=>T+E,0);if(x===0)return n.textContent="No chart data",n.appendChild(u),n;let v=s?re(n,u):void 0,R=-Math.PI/2;for(let T=0;T<y.length;T++){let E=y[T]/x*2*Math.PI,A=R+E,B=E>Math.PI?1:0,H=d+h*Math.cos(R),_=m+h*Math.sin(R),Y=d+h*Math.cos(A),Z=m+h*Math.sin(A),Q=F[T%F.length],U=document.createElementNS("http://www.w3.org/2000/svg","path");if(U.setAttribute("d",`M ${d},${m} L ${H},${_} A ${h},${h} 0 ${B} 1 ${Y},${Z} Z`),U.setAttribute("fill",Q),U.style.cursor="default",v){let L=l?r[T][l]:void 0,pe=L!=null?C?le(L,C,t):k(L):`Slice ${T+1}`,oe=`${(y[T]/x*100).toFixed(1)}%`,pt=d+h*0.6*Math.cos(R+E/2);we(U,v,pt,m,pe,[{label:c[0].label??a,value:`${f(y[T])} (${oe})`,color:Q}])}u.appendChild(U),R=A}return ne(n,c,e.showLegend!==!1),n.appendChild(u),n}function Xn(e,t){let n=g("div","pf-chart pf-radial-chart"),r=me(e,t),o=ge(e),{valueKey:i,nameKey:s}=$t(e,o);if(r.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(de(e,300),300),l=a/2,c=a/2,u=a/2-10,d=Math.max(0,Math.min(D(e.innerRadius)??30,u-10)),m=D(e.startAngle)??180,h=D(e.endAngle)??0,C=r.map((A)=>Number(A[i]??0)),f=Math.max(...C,1),y=te(a,a,"Radial"),x=(u-d)/r.length,v=Math.max(2,x*0.7),R=It(e,t),T=e.showTooltip!==!1?re(n,y):void 0,E=[];for(let A=0;A<r.length;A++){let B=u-x*A-x/2,H=o[A]?.color??F[A%F.length],_=m+C[A]/f*(h-m),Y=s?r[A][s]:null,Z=Y!=null?k(Y):o[A]?.label??i;E.push({dataKey:Z||i,label:Z||i,color:H}),y.appendChild(z("path",{d:Ht(l,c,B,m,h),fill:"none",stroke:ue,"stroke-width":v,"stroke-linecap":"round"}));let Q=z("path",{d:Ht(l,c,B,m,_),fill:"none",stroke:H,"stroke-width":v,"stroke-linecap":"round"});if(T){let U=fe(l,c,B,(m+_)/2);we(Q,T,U.x,U.y,Z||i,[{label:i,value:R(C[A]),color:H}])}y.appendChild(Q)}return ne(n,E,e.showLegend!==!1),n.appendChild(y),n}function Yn(e,t){let n=g("div","pf-chart pf-radar-chart"),r=me(e,t),o=ge(e),i=b(e.axisKey)??b(e.xAxis);if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.filled!==!1,a=e.showDots===!0,l=e.showGrid!==!1,c=Math.min(de(e,300),320),u=c/2,d=c/2,m=c/2-24,h=r.length,C=Oe(r,o),f=(T)=>90-360*T/h,y=(T)=>T.map((E)=>`${E.x.toFixed(1)},${E.y.toFixed(1)}`).join(" "),x=te(c,c,"Radar");if(l){for(let E=1;E<=4;E++){let A=m*E/4,B=Array.from({length:h},(H,_)=>fe(u,d,A,f(_)));x.appendChild(z("polygon",{points:y(B),fill:"none",stroke:ue,"stroke-width":1}))}for(let E=0;E<h;E++){let A=fe(u,d,m,f(E));x.appendChild(z("line",{x1:u,y1:d,x2:A.x,y2:A.y,stroke:ue,"stroke-width":1}))}}for(let T=0;T<h;T++){let E=fe(u,d,m+12,f(T)),A=i?r[T][i]:null;x.appendChild($e({x:E.x,y:E.y+3,"text-anchor":"middle","font-size":ae,fill:X},k(A)))}let v=e.showTooltip!==!1?re(n,x):void 0,R=It(e,t);for(let T=0;T<o.length;T++){let E=o[T],A=E.color??F[T%F.length],B=r.map((H,_)=>fe(u,d,Number(H[E.dataKey]??0)/C*m,f(_)));if(x.appendChild(z("polygon",{points:y(B),fill:s?A:"none","fill-opacity":s?0.2:0,stroke:A,"stroke-width":2})),!a&&!v)continue;for(let H=0;H<B.length;H++){let _=z("circle",{cx:B[H].x,cy:B[H].y,r:a?3:6,fill:a?A:"transparent","fill-opacity":a?1:0});if(v){let Y=i?r[H][i]:null,Z=Y!=null?k(Y):E.label??E.dataKey,Q=[{label:E.label??E.dataKey,value:R(Number(r[H][E.dataKey]??0)),color:A}];we(_,v,B[H].x,B[H].y,Z,Q)}x.appendChild(_)}}return ne(n,o,e.showLegend!==!1),n.appendChild(x),n}function Zn(e,t){let n=g("div","pf-chart pf-scatter-chart"),r=me(e,t),o=b(e.xAxis),i=b(e.yAxis),s=b(e.zAxis),a=ge(e),l=de(e,300);if(r.length===0||!o||!i)return n.textContent="No chart data",n;let c=e.showGrid!==!1,u=a[0]?.color??F[0],d=ce(e),m=(L)=>d?le(L,d,t):String(Math.round(L*100)/100),h=r.map((L)=>Number(L[o]??0)),C=r.map((L)=>Number(L[i]??0)),f=Math.min(...h),y=Math.max(...h),x=Math.min(...C),v=Math.max(...C),R=y-f||1,T=v-x||1,E=s?r.map((L)=>Number(L[s]??0)):[],A=s?Math.max(...E,1):1,B=400,H=tt(B,l,!0),_=te(B,l,"Scatter"),Y=(L)=>H.plotLeft+(L-f)/R*H.plotWidth,Z=(L)=>H.plotBottom-(L-x)/T*H.plotHeight,Q=4;for(let L=0;L<=Q;L++){let pe=x+T*L/Q,oe=Z(pe);if(_.appendChild($e({x:H.plotLeft-6,y:oe+3,"text-anchor":"end","font-size":ae,fill:X},m(pe))),c&&L>0)_.appendChild(z("line",{x1:H.plotLeft,y1:oe,x2:H.plotRight,y2:oe,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}nt(_,H);for(let L of[f,(f+y)/2,y])_.appendChild($e({x:Y(L),y:H.plotBottom+14,"text-anchor":"middle","font-size":ae,fill:X},String(Math.round(L*100)/100)));let U=e.showTooltip!==!1?re(n,_):void 0;for(let L=0;L<r.length;L++){let pe=Y(h[L]),oe=Z(C[L]),pt=s?4+Math.sqrt(E[L]/A)*14:4,qt=z("circle",{cx:pe,cy:oe,r:pt,fill:u,"fill-opacity":s?0.6:0.85});if(U){let xr=[{label:o,value:m(h[L]),color:u},{label:i,value:m(C[L]),color:u},...s?[{label:s,value:m(E[L]),color:u}]:[]],wr=a[0]?.label??"Point";we(qt,U,pe,oe,wr,xr)}_.appendChild(qt)}return ne(n,a,e.showLegend!==!1),n.appendChild(_),n}function Qn(e,t){let n=g("div","pf-chart pf-histogram"),r=Jn(e,t);if(!r)return n.textContent="No data",n;let o=D(e.bins)??10,i=de(e,200),s=b(e.color)??F[0],a=Math.min(...r),c=(Math.max(...r)-a)/o||1,u=Array(o).fill(0);for(let f of r){let y=Math.min(Math.floor((f-a)/c),o-1);u[y]++}let d=Math.max(...u),m=300,h=m/o,C=te(m,i,"Histogram");for(let f=0;f<o;f++){let y=d>0?u[f]/d*i:0,x=document.createElementNS("http://www.w3.org/2000/svg","rect");x.setAttribute("x",String(f*h)),x.setAttribute("y",String(i-y)),x.setAttribute("width",String(h-1)),x.setAttribute("height",String(y)),x.setAttribute("fill",s),C.appendChild(x)}return n.appendChild(C),n}function er(){p("BarChart",qn),p("LineChart",Dt),p("AreaChart",Dt),p("PieChart",Un),p("RadarChart",Yn),p("ScatterChart",Zn),p("RadialChart",Xn),p("Histogram",Qn)}function tr(){p("Table",rs),p("TableHead",jt("thead")),p("TableBody",jt("tbody")),p("TableFooter",jt("tfoot")),p("TableRow",os),p("TableHeader",is),p("TableCell",ss),p("TableCaption",as),p("ExpandableRow",ls)}function rs(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",N(e,n,t),n}function jt(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,N(t,r,n),r}}function os(e,t){let n=document.createElement("tr");return n.className="pf-table-row",N(e,n,t),n}function is(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.style.textAlign="left",n.style.padding="8px 12px",n.style.fontWeight="600",n.textContent=w(e.content,t),n}function ss(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=Number(e.colSpan);if(e.rowSpan!=null)n.rowSpan=Number(e.rowSpan);return N(e,n,t),n}function as(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.style.padding="8px",n.style.fontSize="14px",n.textContent=w(e.content,t),n}function ls(e,t){let n=g("div","pf-expandable-row"),r=g("div","pf-expandable-row-summary");r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.gap="8px";let o=g("span","pf-expandable-arrow");o.textContent="▶",o.style.transition="transform 0.2s",o.style.fontSize="10px",r.appendChild(o);let i=e.summary;if(i)for(let l of i)r.appendChild(j(l,t));let s=g("div","pf-expandable-row-detail");s.style.display="none",s.style.paddingLeft="24px",N(e,s,t);let a=!1;return r.addEventListener("click",()=>{a=!a,s.style.display=a?"block":"none",o.style.transform=a?"rotate(90deg)":""}),n.appendChild(r),n.appendChild(s),n}var nr=!1;function it(){if(nr)return;nr=!0;let e=new Set(kt());wn(),Sn(),Tn(),An(),Mn(),Ln(),Hn(),Pn(),Dn(),In(),Bn(),er(),tr(),hn(kt().filter((t)=>!e.has(t)))}function Bt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Vt(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Ft(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Bt(n)}: ${Vt(r)};`).join(`
|
|
7
|
-
`)}function
|
|
8
|
-
${
|
|
9
|
-
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=
|
|
3
|
+
`),n=[],o=0;while(o<t.length){let r=t[o];if(r.trimStart().startsWith("```")){let a=r.trimStart().slice(3).trim(),l=[];o++;while(o<t.length&&!t[o].trimStart().startsWith("```"))l.push(te(t[o])),o++;o++;let c=a?` data-language="${te(a)}"`:"";n.push(`<pre class="pf-code"><code${c}>${l.join(`
|
|
4
|
+
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(r)){n.push("<hr />"),o++;continue}let i=/^(#{1,6})\s+(.+)$/.exec(r);if(i){let a=i[1].length;n.push(`<h${a}>${et(i[2])}</h${a}>`),o++;continue}if(r.startsWith("> ")||r===">"){let a=[];while(o<t.length&&(t[o].startsWith("> ")||t[o]===">"))a.push(t[o].replace(/^>\s?/,"")),o++;n.push(`<blockquote>${En(a.join(`
|
|
5
|
+
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(r)){n.push("<ul>");while(o<t.length&&/^[\s]*[-*+]\s+/.test(t[o]))n.push(`<li>${et(t[o].replace(/^[\s]*[-*+]\s+/,""))}</li>`),o++;n.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(r)){n.push("<ol>");while(o<t.length&&/^[\s]*\d+\.\s+/.test(t[o]))n.push(`<li>${et(t[o].replace(/^[\s]*\d+\.\s+/,""))}</li>`),o++;n.push("</ol>");continue}if(r.trim()===""){o++;continue}let s=[];while(o<t.length&&t[o].trim()!==""&&!/^#{1,6}\s/.test(t[o])&&!/^[-*+]\s/.test(t[o])&&!/^\d+\.\s/.test(t[o])&&!t[o].startsWith("> ")&&!t[o].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(t[o]))s.push(t[o]),o++;n.push(`<p>${s.map(et).join("<br />")}</p>`)}return n.join(`
|
|
6
|
+
`)}function _r(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=C(e.content,t),n}function Mn(){p("Card",zr),p("CardHeader",Tt("pf-card-header")),p("CardTitle",Tn("pf-card-title","h3")),p("CardDescription",Tn("pf-card-description","p")),p("CardContent",Tt("pf-card-content")),p("CardFooter",Tt("pf-card-footer"))}function zr(e,t){let n=f("div","pf-card");return n.style.overflow="hidden",N(e,n,t),n}function Tt(e){return(t,n)=>{let o=f("div",e);return o.style.padding="16px 24px",N(t,o,n),o}}function Tn(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 tt(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 Nn(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 Ln(e,t,n,o,r){let i=Nn(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":ae,fill:X});if(l.textContent=Nt(s,r),e.appendChild(l),o&&s>0)e.appendChild(H("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function An(e,t,n,o){let r=Nn(n);for(let i of r){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":ae,fill:X});a.textContent=Nt(i,o),e.appendChild(a)}}function Mt(e,t,n,o,r,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=H("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 nt(e,t){e.appendChild(H("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function ve(e,t,n){if(e==null)return"";let o=J(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return v(o??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 Pe(e){let t=y(e.yAxisFormat)??y(e.valueFormat);return t&&t!=="auto"?t:void 0}function we(e,t,n=String){let o=Pe(e);return(r)=>o?ve(r,o,t):n(r)}function Lt(e,t,n){return(o,r)=>{if(o===null||o===void 0)return"—";if(r.tooltipFormat)return ve(o,r.tooltipFormat,e);let i=r.yAxisId==="right"?n:t;return Nt(Number(o),i)}}function oe(e,t,n){let o=H("svg",{width:"100%",height:t,viewBox:`0 0 ${e} ${t}`,role:"img",...n?{"aria-label":`${n} chart`}:{}});return o.style.overflow="visible",o}function H(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 $e(e,t){let n=H("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 At(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 Hn(){p("DataTable",Jr),p("Badge",Wr),p("Dot",Kr),p("Metric",Gr),p("Ring",qr),p("Progress",Ur),p("Separator",Xr),p("Loader",Yr),p("Icon",Zr),p("Sparkline",Qr)}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=W(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=S(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 Wr(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),ei(n,o),n}function Kr(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 Gr(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 qr(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=H("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=H("circle",{...d,stroke:"var(--muted, #e5e7eb)"}),m=H("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 Ur(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 Xr(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Yr(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 Zr(e,t){let n=f("span","pf-icon");return n.setAttribute("data-icon",C(e.name??e.content,t)),n}function Qr(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=H("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(H("polyline",{points:d,fill:"none",stroke:"var(--primary, #3b82f6)","stroke-width":1.5})),n.appendChild(c),n}function ei(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",ti),p("Input",ni),p("Textarea",ke(oi)),p("Button",ri),p("ButtonGroup",ii),p("Checkbox",si),p("Switch",ai),p("Slider",ke(li)),p("Calendar",di),p("DatePicker",ke(pi)),p("Field",Oe("pf-field")),p("FieldTitle",Se("pf-field-title")),p("FieldDescription",Se("pf-field-description")),p("FieldContent",Oe("pf-field-content")),p("FieldError",Se("pf-field-error"))}function ti(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")}}),N(e,n,t),n}function $n(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 ke(e){return(t,n)=>{let o=e(t,n);return o.style.display="flex",o.style.flexDirection="column",o.style.gap="4px",$n(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 ni(e,t){let n=f("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",$n(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 ot(o),n.appendChild(o),n}function oi(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 ot(o),n.appendChild(o),n}function ri(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),ci(n,o),e.size!=null)n.setAttribute("data-size",v(e.size));if(e.disabled===!0)n.disabled=!0;return n}function ii(e,t){let n=f("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",N(e,n,t),n}function si(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 ai(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 li(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 ot(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function ci(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 Oe(e){return(t,n)=>{let o=f("div",e);return N(t,o,n),o}}function Se(e){return(t,n)=>{let o=f("span",e);return o.textContent=C(t.content,n),o}}function Ht(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function di(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 pi(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",ke(ui)),p("SelectOption",gi),p("SelectGroup",Oe("pf-select-group")),p("SelectLabel",Se("pf-select-label")),p("SelectSeparator",Ht),p("Radio",hi),p("RadioGroup",yi),p("Combobox",ke(bi)),p("ComboboxOption",Ci),p("ComboboxGroup",Oe("pf-combobox-group")),p("ComboboxLabel",Se("pf-combobox-label")),p("ComboboxSeparator",Ht),p("ChoiceCard",xi)}function ui(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),ot(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 W(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)mi(o,i);o.addEventListener("change",()=>{let s=fi(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 fi(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function mi(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 gi(e,t){return f("span")}function hi(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 yi(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)}N(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 bi(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",N(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 Ci(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 xi(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 N(e,n,t),n}function Pt(e,t){if(!Ce(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 Dn(){p("Tabs",vi),p("Tab",wi),p("Accordion",ki),p("AccordionItem",Si),p("Dialog",Ri),p("Popover",Ei),p("Tooltip",Ti),p("HoverCard",Mi),p("Carousel",Ni)}function vi(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,N(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 wi(e,t){let n=f("div","pf-tab");return N(e,n,t),n}function ki(e,t){let n=f("div","pf-accordion");return N(e,n,t),n}function Si(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",N(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 Ri(e,t){let n=f("div","pf-dialog-wrapper"),o=Pt(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(N(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 Ei(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)}N(e,o,t);let r=()=>{o.style.display=o.style.display==="none"?"block":"none"},i=Pt(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 Ti(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",N(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 Mi(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=Pt(e.trigger,t);if(r)n.appendChild(r);return N(e,o,t),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.appendChild(o),n}function Ni(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",N(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 Li(e){if(!S(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,de(n)]))}function In(){p("ForEach",Ai),p("If",jn),p("Elif",Hi),p("Else",Pi),p("Condition",$i),p("Define",Oi),p("Use",Di),p("Slot",Ii)}function Ai(e,t){let n=document.createDocumentFragment(),o=y(e.expression);if(!o)return n;let r;if(G(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=P(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 jn(e,t){if(Fn(y(e.condition)??"",t)){let o=document.createDocumentFragment();if(e.children)pe(e.children,o,t);return o}return document.createDocumentFragment()}function Hi(e,t){return jn(e,t)}function Pi(e,t){let n=document.createDocumentFragment();if(e.children)pe(e.children,n,t);return n}function Fn(e,t){if(!e)return!1;if(G(e))return Boolean(q(e,t.store,t.scope));return Boolean(t.store.get(e))}function $i(e,t){let n=document.createDocumentFragment(),o=W(e.cases).find((r)=>Fn(y(r.when)??"",t));return pe(de(o?o.children:e.else),n,t),n}function Oi(e,t){let n=y(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Di(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=P(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...Li(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 Ii(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 Bn(){p("Alert",ji),p("AlertTitle",Fi),p("AlertDescription",Bi)}function ji(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 N(e,n,t),n}function Fi(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 Bi(e,t){let n=f("p","pf-alert-description");return n.textContent=C(e.content,t),n.style.fontSize="14px",n}function Vn(){p("Image",Vi),p("Audio",_i),p("Video",zi),p("Embed",Ji),p("Svg",Ki),p("DropZone",qi),p("Mermaid",Ui)}function Vi(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 _i(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=C(e.src,t),n.controls=!0,n}function zi(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 Wi=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 Ki(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 _n(i),n.appendChild(document.importNode(i,!0)),n}function _n(e){let t=Array.from(e.children);for(let n of t){if(!Wi.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)}_n(n)}}function Gi(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 qi(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)=>Gi(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 Ui(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 Xi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Yi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",$t=null,rt=null;function Zi(e){return S(e)&&typeof e.getDocument==="function"&&S(e.GlobalWorkerOptions)}function Ot(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function Qi(e){return e==="fit-page"||e==="fit-width"?e:Ot(e,0)||"fit-width"}async function es(){if($t)return $t;if(rt)return rt;return rt=import(Xi).then((e)=>{if(!Zi(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=Yi,$t=t,t}),rt}function Jn(){p("PdfViewer",ts)}function ts(e,t){let n=f("div","pf-pdf-viewer"),o=e.src!=null?C(e.src,t):void 0,r=y(e.data),i=Ot(e.page,1),s=Qi(e.zoom),a=e.toolbar!==!1,l=Ot(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),ns(n,c,{src:o,data:r,initialPage:i,zoom:s,showToolbar:a}),n}async function ns(e,t,n){try{let o=await es(),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=os(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,k=w/h.height;b=Math.min(R,k)}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 os(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",zn(r),r.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",zn(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 zn(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 Kn(e){e.tooltip.classList.remove("pf-visible")}function Gn(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){Gn(e,()=>{Wn(t,n,o,r,i)},()=>{Kn(t)})}function qn(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=H("rect",{x:e,y:n.plotTop,width:t,height:n.plotHeight,fill:"transparent"});return o.style.cursor="default",o}function Xn(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}=qn(l,u);me(g,e,d+c/2,r.plotTop,m,b),t.appendChild(g)}}function Yn(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}=qn(u,g);Gn(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 k of l){for(let T of k)T.setAttribute("data-visible","false");k[g]?.setAttribute("data-visible","true")}},()=>{if(Kn(e),a)a.setAttribute("opacity","0");if(l)for(let k of l)for(let T of k)T.setAttribute("data-visible","false")}),t.appendChild(h)}}function ge(e,t){return W(J(e.data,t))}function Zn(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 rs(e){return e==="left"||e==="right"?e:void 0}function is(e){if(!S(e)||typeof e.dataKey!=="string")return;let t=y(e.label),n=y(e.color),o=rs(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=is(t);return n?[n]:[]})}function ce(e,t){return F(e.height)??t}function De(e,t){return Math.max(...e.flatMap((n)=>t.map((o)=>Number(n[o.dataKey]??0))),1)}function Dt(e,t){return{valueKey:y(e.dataKey)??t[0]?.dataKey,nameKey:y(e.nameKey)??y(e.tooltipXKey)??y(e.xAxis)}}function It(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 Qn(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?De(t.rows,o):1,a=i?De(t.rows,r):1,l=400,c=tt(400,t.height,t.showYAxis,i),u=oe(400,t.height,n);if(t.showYAxis)Ln(u,c,s,t.showGrid,Pe(e));if(i)An(u,c,a,t.yAxisRightFormat);return nt(u,c),{layout:c,svg:u,leftMax:s,rightMax:a}}function it(e,t){return e?(n)=>ve(n,e,t):void 0}function eo(e,t){let n=f("div","pf-chart pf-bar-chart"),o=It(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}=Qn(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(H("rect",{x:w,y:s.plotBottom-E,width:d*0.8,height:E,fill:b.color??_[m%_.length],rx:2}))}if(o.xAxisKey)Mt(a,r,o.xAxisKey,(g)=>s.plotLeft+g*u+u/2,s.plotBottom,it(o.xAxisFormat,t));if(o.showTooltip){let g=ie(n,a),m=Lt(t,Pe(e),o.yAxisRightFormat);Xn(g,a,r,i,s,o.tooltipXKey??o.xAxisKey,m,it(o.tooltipXFormat,t))}return re(n,i,o.showLegend),n.appendChild(a),n}function ss(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(H("path",{d:s,fill:o,opacity:0.15})),r=[]};for(let s of t){if(s.isNull){i();continue}r.push(s)}i()}function as(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(H("path",{d:r.trim(),fill:"none",stroke:n,"stroke-width":2,...o?{"stroke-dasharray":"6 3"}:{}}))}function ls(e,t,n){let o=[];for(let r of t){let i=H("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 cs(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 jt(e,t){let n=f("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),o=It(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}=Qn(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((k,T)=>{let L=k[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)ss(l,R,a.plotBottom,w);as(l,R,w,x),g.push(ls(l,R,w))}let m=cs(l,a);if(o.xAxisKey)Mt(l,r,o.xAxisKey,d,a.plotBottom,it(o.xAxisFormat,t));if(o.showTooltip){let b=ie(n,l),h=Lt(t,Pe(e),o.yAxisRightFormat);Yn(b,l,r,i,a,o.tooltipXKey??o.xAxisKey,h,m,g,it(o.tooltipXFormat,t))}return re(n,i,o.showLegend),n.appendChild(l),n}function to(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}=Dt(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=we(e,t),x=o.map((k)=>Number(k[a]??0)),E=x.reduce((k,T)=>k+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 k=0;k<x.length;k++){let T=x[k]/E*2*Math.PI,L=R+T,I=T>Math.PI?1:0,j=d+m*Math.cos(R),z=g+m*Math.sin(R),Y=d+m*Math.cos(L),Z=g+m*Math.sin(L),Q=_[k%_.length],A=H("path",{d:`M ${d},${g} L ${j},${z} A ${m},${m} 0 ${I} 1 ${Y},${Z} Z`,fill:Q});if(A.style.cursor="default",w){let ne=l?o[k][l]:void 0,se=ne!=null?b?ve(ne,b,t):v(ne):`Slice ${k+1}`,ut=`${(x[k]/E*100).toFixed(1)}%`,Fe=d+m*0.6*Math.cos(R+T/2);me(A,w,Fe,g,se,[{label:c[0].label??a,value:`${h(x[k])} (${ut})`,color:Q}])}u.appendChild(A),R=L}return re(n,c,e.showLegend!==!1),n.appendChild(u),n}function no(e,t){let n=f("div","pf-chart pf-radial-chart"),o=ge(e,t),r=he(e),{valueKey:i,nameKey:s}=Dt(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=we(e,t),k=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],z=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(H("path",{d:At(l,c,I,g,m),fill:"none",stroke:ue,"stroke-width":w,"stroke-linecap":"round"}));let Q=H("path",{d:At(l,c,I,g,z),fill:"none",stroke:j,"stroke-width":w,"stroke-linecap":"round"});if(k){let A=fe(l,c,I,(g+z)/2);me(Q,k,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 oo(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=De(o,r),h=(k)=>90-360*k/m,x=(k)=>k.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,z)=>fe(u,d,L,h(z)));E.appendChild(H("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(H("line",{x1:u,y1:d,x2:L.x,y2:L.y,stroke:ue,"stroke-width":1}))}}for(let k=0;k<m;k++){let T=fe(u,d,g+12,h(k)),L=i?o[k][i]:null;E.appendChild($e({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=we(e,t);for(let k=0;k<r.length;k++){let T=r[k],L=T.color??_[k%_.length],I=o.map((j,z)=>fe(u,d,Number(j[T.dataKey]??0)/b*g,h(z)));if(E.appendChild(H("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 z=H("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(z,w,I[j].x,I[j].y,Z,Q)}E.appendChild(z)}}return re(n,r,e.showLegend!==!1),n.appendChild(E),n}var ro=(e)=>String(Math.round(e*100)/100);function io(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=we(e,t,ro),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,k=s?o.map((A)=>Number(A[s]??0)):[],T=s?Math.max(...k,1):1,L=400,I=tt(L,l,!0),j=oe(L,l,"Scatter"),z=(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($e({x:I.plotLeft-6,y:se+3,"text-anchor":"end","font-size":ae,fill:X},d(ne))),c&&A>0)j.appendChild(H("line",{x1:I.plotLeft,y1:se,x2:I.plotRight,y2:se,stroke:ue,"stroke-width":1,"stroke-dasharray":"4 3"}))}nt(j,I);for(let A of[b,(b+h)/2,h])j.appendChild($e({x:z(A),y:I.plotBottom+14,"text-anchor":"middle","font-size":ae,fill:X},ro(A)));let Q=e.showTooltip!==!1?ie(n,j):void 0;for(let A=0;A<o.length;A++){let ne=z(g[A]),se=Y(m[A]),ut=s?4+Math.sqrt(k[A]/T)*14:4,Fe=H("circle",{cx:ne,cy:se,r:ut,fill:u,"fill-opacity":s?0.6:0.85});if(Q){let Mo=[{label:r,value:d(g[A]),color:u},{label:i,value:d(m[A]),color:u},...s?[{label:s,value:d(k[A]),color:u}]:[]],No=a[0]?.label??"Point";me(Fe,Q,ne,se,No,Mo)}j.appendChild(Fe)}return re(n,a,e.showLegend!==!1),n.appendChild(j),n}function so(e,t){let n=f("div","pf-chart pf-histogram"),o=Zn(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(H("rect",{x:h*m,y:i-x,width:m-1,height:x,fill:s}))}return n.appendChild(b),n}function ao(){p("BarChart",eo),p("LineChart",jt),p("AreaChart",jt),p("PieChart",to),p("RadarChart",oo),p("ScatterChart",io),p("RadialChart",no),p("Histogram",so)}function lo(){p("Table",ds),p("TableHead",Ft("thead")),p("TableBody",Ft("tbody")),p("TableFooter",Ft("tfoot")),p("TableRow",ps),p("TableHeader",us),p("TableCell",fs),p("TableCaption",ms),p("ExpandableRow",gs)}function ds(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",N(e,n,t),n}function Ft(e){return(t,n)=>{let o=document.createElement(e);return o.className=`pf-${e}`,N(t,o,n),o}}function ps(e,t){let n=document.createElement("tr");return n.className="pf-table-row",N(e,n,t),n}function us(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 fs(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=Number(e.colSpan);if(e.rowSpan!=null)n.rowSpan=Number(e.rowSpan);return N(e,n,t),n}function ms(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 gs(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",N(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 co=!1;function st(){if(co)return;co=!0;let e=new Set(Rt());wn(),Rn(),Mn(),Hn(),Pn(),On(),Dn(),In(),Bn(),Vn(),Jn(),ao(),lo(),yn(Rt().filter((t)=>!e.has(t)))}function Vt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function _t(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Bt(e,t=" "){return Object.entries(e).map(([n,o])=>`${t}--${Vt(n)}: ${_t(o)};`).join(`
|
|
7
|
+
`)}function po(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
|
|
8
|
+
${Bt(e.light)}
|
|
9
|
+
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=Bt(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
|
+
${Bt(e.dark," ")}
|
|
14
14
|
}
|
|
15
15
|
}`)}return t.join(`
|
|
16
|
-
`)}function ve(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function _t(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Bt(n)}`,Vt(r));if(t.dark){let r=document.getElementById("prefab-dark-theme");if(!r)r=document.createElement("style"),r.id="prefab-dark-theme",document.head.appendChild(r);r.textContent=rr({dark:t.dark})}}function zt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(cs(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function cs(e,t){let n=e.toLowerCase().split("+").map((i)=>i.trim()),r=n[n.length-1],o=new Set(n.slice(0,-1));if(o.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(o.has("shift")!==t.shiftKey)return!1;if(o.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===r}var or='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',ir='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',sr={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function ds(e,t){try{let r=localStorage.getItem(t);if(r==="light"||r==="dark")return r}catch{}let n=e.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(n==="light"||n==="dark")return n;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function De(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",r=t?.storageKey??"prefab-theme",o=t?.syncDocument??!0,i=getComputedStyle(e).position;if(i==="static"||i==="")e.style.position="relative";let s=document.createElement("button");s.className="pf-theme-toggle",s.setAttribute("aria-label","Toggle theme"),s.setAttribute("title","Toggle light/dark"),Object.assign(s.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let a=sr[n]??sr["top-right"];for(let d of a.split(";")){let[m,h]=d.split(":").map((C)=>C.trim());if(m&&h)s.style.setProperty(m,h)}s.addEventListener("mouseenter",()=>{s.style.opacity="1"}),s.addEventListener("mouseleave",()=>{s.style.opacity="0.7"});function l(d){if(ve(e,d),o)ve(document.documentElement,d);s.innerHTML=d==="dark"?ir:or;try{localStorage.setItem(r,d)}catch{}}let c=ds(e,r);l(c),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";l(d==="dark"?"light":"dark")}),e.appendChild(s);let u;if(o)u=new MutationObserver((d)=>{for(let m of d)if(m.type==="attributes"&&m.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){ve(e,h),s.innerHTML=h==="dark"?ir:or;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function st(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},r=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(o,i){let s=await r(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:o,arguments:i}})});if(!s.ok)throw Error(`MCP tool call failed: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw Error(a.error.message??"MCP tool call returned error");let l=a.result?.content??a.content??[];for(let c of l)if(c.type==="text"&&c.text!==void 0){try{let u=JSON.parse(c.text);if(typeof u==="object"&&u!==null&&"$prefab"in u)return u;return u}catch{}return c.text}return a.result??a},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function at(){return{callTool(e){return M.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return M.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var ar="0.3.20";var ps=["light","dark","auto"],us=["inline","fullscreen","pip"];function lr(e){return S(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||S(e.payload))}function lt(e){return typeof e==="boolean"?e:void 0}function cr(e){let t=I(e.capabilities)??{},n=I(e.theme),r=I(e.toolInput),o=I(e.meta);return{hostName:b(e.hostName),hostVersion:b(e.hostVersion),capabilities:{toast:lt(t.toast),clipboard:lt(t.clipboard),navigation:lt(t.navigation),messaging:lt(t.messaging),displayModes:Wt(t.displayModes)},...n&&{theme:fs(n)},...r&&{toolInput:r},...o&&{meta:o}}}function fs(e){let t=b(e.fontCss);return{...ct({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Wt(e){let t=Array.isArray(e)?e:[];return us.filter((n)=>t.includes(n))}function ct(e){let t={},n=ps.find((s)=>s===e.theme);if(n)t.colorScheme=n;let r=I(e.styles),o=I(r?.variables);if(o)t.variables=Object.fromEntries(Object.entries(o).filter((s)=>typeof s[1]==="string"));let i=b(I(r?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function ms(e){return S(e)&&e.jsonrpc==="2.0"}class he{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=hs();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(ms(r)){this.handleJsonRpc(r);return}if(!lr(r)||!r.type.startsWith("prefab:"))return;let o=r;if(o.type==="prefab:tool-call-response"&&o.id){let s=this.pending.get(o.id);if(s){if(this.pending.delete(o.id),o.payload?.error!=null)s.reject(Error(k(o.payload.error)));else s.resolve(o.payload?.result);return}}let i=this.listeners.get(o.type);if(i)for(let s of i)s(o.payload??{})};window.addEventListener("message",t),this.cleanup=()=>window.removeEventListener("message",t)}async initialize(e){try{return await Promise.any([this.initPrefab(e),this.initJsonRpc(e)])}catch(t){let n=t instanceof AggregateError?t.errors.map((r)=>r.message).join("; "):String(t);throw Error(`Bridge init failed — no host responded. Tried: ${n}`,{cause:t})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:e});else this.sendPrefab("prefab:request-mode",{mode:e})}openLink(e,t){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:e,target:t});else this.sendPrefab("prefab:open-link",{url:e,target:t})}updateContext(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:e});else this.sendPrefab("prefab:update-context",{context:e})}setupAutoResize(e){if(typeof ResizeObserver>"u")return dr;let t=-1,n=-1,r=(s,a)=>{if(s===t&&a===n)return;if(t=s,n=a,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:s,height:a});else this.sendPrefab("prefab:size-changed",{width:s,height:a})},o=new ResizeObserver((s)=>{for(let a of s)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];r(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();r(Math.ceil(l.width),Math.ceil(l.height))}});o.observe(e);let i=e.getBoundingClientRect();return r(Math.ceil(i.width),Math.ceil(i.height)),()=>o.disconnect()}notifyPreferredSize(e){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",e);else this.sendPrefab("prefab:preferred-size",e)}subscribe(e,t,n){let r=(o)=>{if(o.uri!==e)return;t(o.contents??o.data??o)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",r),this.sendRpcRequest("resources/subscribe",{uri:e}).catch((o)=>{this.off("prefab:resource-updated",r),n?.(o)});else this.on("prefab:resource-updated",r),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",r),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e}).catch(dr);else this.sendPrefab("prefab:unsubscribe",{uri:e})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);let n=this.listeners.get(e);if(n)n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,e]of this.pending)e.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,e]of this.rpcPending)e.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab(e){return new Promise((t,n)=>{let r=!1,o=(i)=>{if(r)return;r=!0,this.off("prefab:init-response",o),this.protocol="prefab",this._hostSupportsSubscriptions=I(i.capabilities)?.subscriptions===!0,t(cr(i))};this.on("prefab:init-response",o),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!r)r=!0,this.off("prefab:init-response",o),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((r,o)=>{this.pending.set(n,{resolve:r,reject:o}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),o(Error(`Tool call '${e}' timed out`))},30000)})},sendMessage:(e)=>(this.sendPrefab("prefab:send-message",{message:e}),Promise.resolve()),updateModelContext:(e)=>(this.sendPrefab("prefab:update-context",{context:e.structuredContent,content:e.content}),Promise.resolve()),subscribe:(e,t,n)=>this.subscribe(e,t,n),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab(e,t,n){if(typeof window>"u")return;let r=window.parent!==window?window.parent:window,o={type:e,payload:t,id:n};r.postMessage(o,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let r=this.rpcPending.get(e.id);if(r)if(this.rpcPending.delete(e.id),e.error)r.reject(Error(e.error.message));else r.resolve(e.result);return}let t=e.method,n=e.params??{};if(e.id!=null&&this.sentRpcIds.delete(e.id))return;if(e.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:e.id,result:{}});switch(t){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:n.arguments??n});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:n.arguments??n});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:n});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",n);break;case"ui/notifications/host-context-changed":{this.dispatch("prefab:theme-update",{...ct(n)}),this.dispatch("prefab:host-context-changed",n);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",n);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",n);break}}initJsonRpc(e){return new Promise((t,n)=>{let r=++this.rpcIdCounter,o=!1;this.rpcPending.set(r,{resolve:(i)=>{if(o)return;o=!0,this.protocol="jsonrpc";let s=I(i)??{},a=I(s.hostInfo)??{},l=I(s.hostContext)??{},c=I(s.hostCapabilities)??{},u=typeof l.theme==="string"||S(l.styles)?ct(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let d=I(c.resources);this._hostSupportsSubscriptions=c.subscriptions===!0||d?.subscribe===!0,t({hostName:b(a.name),hostVersion:b(a.version),capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:Wt(l.availableDisplayModes)},theme:u,toolInput:void 0,meta:l})},reject:(i)=>{if(o)return;o=!0,n(i)}}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:ar},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!o)o=!0,this.rpcPending.delete(r),n(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:(e,t)=>this.sendRpcRequest("tools/call",{name:e,arguments:t}),sendMessage:async(e)=>{await this.sendRpcRequest("ui/message",{role:"user",content:[{type:"text",text:e}]})},updateModelContext:async(e)=>{await this.sendRpcRequest("ui/update-model-context",{...e})},subscribe:(e,t,n)=>this.subscribe(e,t,n),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest(e,t){let n=++this.rpcIdCounter;return new Promise((r,o)=>{this.rpcPending.set(n,{resolve:r,reject:o}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),o(Error(`JSON-RPC '${e}' timed out`))},30000)})}sendRpcNotification(e,t){this.postJsonRpc({jsonrpc:"2.0",method:e,params:t})}postJsonRpc(e){if(typeof window>"u")return;if((typeof e.id==="number"||typeof e.id==="string")&&typeof e.method==="string")this.sentRpcIds.add(e.id);if(this.postFn)this.postFn(e);else(window.parent!==window?window.parent:window).postMessage(e,this.hostOrigin)}dispatch(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r(t)}}var dr=()=>{};function Ie(e,t){if(t.variables)for(let[n,r]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,r);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)gs(t.fontCss)}function gs(e){if(document.getElementById("__prefab-host-fonts"))return;let n=document.createElement("style");n.id="__prefab-host-fonts",n.textContent=e,document.head.appendChild(n)}function ke(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function hs(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(S(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(r)=>{Reflect.apply(n,t,[r])}}}}catch{return}return}async function dt(e){it();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&ke(),r,o,i={capabilities:{}};if(n)o=new he(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=st(e.transport);else r=at();if(i.theme&&typeof document<"u")Ie(document.documentElement,i.theme);if(typeof document<"u"&&!o)ys();let s,a,l,c,u,d=i.toolInput,m;if(o)o.on("prefab:tool-input",(f)=>{let y=I(f.args)??f;if(s)s(y);else d=y}),o.on("prefab:tool-result",(f)=>{let y=f.result??f;if(a)a(y);else m=y}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(f)=>{c?.(I(f.args)??f)}),o.on("prefab:theme-update",(f)=>{if(typeof document<"u")Ie(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...y){let x=Kt(f),v=new Re,R={store:v,scope:{},transport:r,rerender:()=>T(),onToast:void 0};function T(){x.innerHTML="";for(let E of y)x.appendChild(j(E,R))}return T(),{rerender:T,store:v,destroy:()=>{x.innerHTML=""}}}return{callTool:(f,y={})=>r.callTool(f,y),sendMessage:(f)=>r.sendMessage(f),onToolInput:(f)=>{if(s=f,d){let y=d;d=void 0,queueMicrotask(()=>f(y))}},onToolResult:(f)=>{if(a=f,m!==void 0){let y=m;m=void 0,queueMicrotask(()=>f(y))}},onToolCancelled:(f)=>{l=f},onToolInputPartial:(f)=>{c=f},onHostContextChanged:(f)=>{u=f},render:h,mount:(f,y,x)=>{let v=Kt(f);return q.mount(v,y,{transport:r,...x})},requestMode:(f)=>o?.requestMode(f),openLink:(f,y)=>{if(o)o.openLink(f,y);else if(typeof window<"u")window.open(f,y??"_blank")},updateContext:(f)=>{if(o)o.updateContext(f)},setupAutoResize:(f)=>{if(!o)return bs;let y=typeof f==="string"?Kt(f):f;return o.setupAutoResize(y)},notifyPreferredSize:(f)=>{if(o)o.notifyPreferredSize(f)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var bs=()=>{};function Kt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}return e}function ys(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let r=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",r)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var pr=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var mr=new Set(pr);function Se(e,t={}){let n=[],r=t.strict??!1;if(!S(e))return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e,i=o.$prefab;if(!S(i))n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof i.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(o.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Jt(o.view,"$.view",n,r);if(o.state!==void 0){if(o.state===null||typeof o.state!=="object"||Array.isArray(o.state))n.push({path:"$.state",message:"state must be a plain object"})}if(o.theme!==void 0)xs(o.theme,n);if(o.css!==void 0)fr(o.css,"$.css",n);if(o.stylesheets!==void 0)fr(o.stylesheets,"$.stylesheets",n);if(o.mode!==void 0&&o.mode!=="light"&&o.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});let s=o.defs;if(s!==void 0)if(!S(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Jt(c,`$.defs.${l}`,n,r);let a=o.keyBindings;if(a!==void 0)if(!S(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))Gt(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function gr(e){return Se(e).valid}function Jt(e,t,n,r){if(!S(e)){n.push({path:t,message:"Component must be a plain object"});return}let o=e;if(typeof o.type!=="string"||o.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(r&&!mr.has(o.type))n.push({path:`${t}.type`,message:`Unknown component type: "${o.type}"`});if(o.children!==void 0)if(!Array.isArray(o.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let s=0;s<o.children.length;s++)Jt(o.children[s],`${t}.children[${s}]`,n,r);let i=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let s of i)if(o[s]!==void 0)Gt(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||Cs.has(s)||i.includes(s))continue;if(ur(a)||Array.isArray(a)&&a.some(ur))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var Cs=new Set(["children","fallback","trigger","empty","else","summary"]);function ur(e){return S(e)&&typeof e.type==="string"&&mr.has(e.type)}function Gt(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)Gt(e[i],`${t}[${i}]`,n);return}if(!S(e)){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.action==="string"&&r.action.length>0?r.action:typeof r.type==="string"&&r.type.length>0?r.type:void 0;if(o===void 0){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if(o.toLowerCase()==="showtoast"){if(typeof r.message!=="string"||r.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function fr(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let r=0;r<e.length;r++)if(typeof e[r]!=="string")n.push({path:`${t}[${r}]`,message:"must be a string"})}function xs(e,t){if(!S(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}for(let n of["light","dark"])if(e[n]!==void 0){if(!S(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var q={mount(e,t,n){if(it(),n?.validate!==!1)for(let x of Se(t).errors)M.warn(`wire validation ${x.path}: ${x.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[x,v]of Object.entries(r.pipes))hr(x,v,o);let i=new Re(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=st(n.transport);else s=at();let a=n?.onToast??vs,l=new Ne;function c(x){if(!q.isPrefabData(x))return;let v=x;if(r=v,v.state)i.merge(v.state);if(v.defs)d.defs=v.defs;if(v.theme)_t(e,v.theme);if(v.mode)br(e,v.mode);if(v.pipes)for(let[R,T]of Object.entries(v.pipes))hr(R,T,o);for(let R of m)R.remove();if(m.length=0,m.push(...yr(v.css,v.stylesheets)),Cr(e,v.layout),h?.(),h=void 0,v.keyBindings)h=zt(v.keyBindings,(R)=>{O(P(R,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});y(),u(v)}function u(x){if(x.onMount!=null)O(P(x.onMount,d),"onMount")}let d={store:i,scope:{},transport:s,rerender:()=>y(),remount:c,onToast:a,defs:r.defs,destroyRegistry:l};if(_t(e,r.theme),r.mode)br(e,r.mode);Cr(e,r.layout);let m=yr(r.css,r.stylesheets),h;if(r.keyBindings)h=zt(r.keyBindings,(x)=>{O(P(x,{store:i,transport:s,scope:{},rerender:()=>y(),remount:c,onToast:a}),"keyBinding")});let C,f=n?.themeToggle??!0;if(f!==!1)C=De(e,typeof f==="object"?f:void 0);function y(){l.flush();let x=e.querySelector(".pf-theme-toggle");e.innerHTML="";let v=j(r.view,d);if(e.appendChild(v),x)e.appendChild(x)}return y(),u(r),{rerender:()=>y(),update(x){if(i.merge(x.update.state),y(),x.update.actions!=null)O(P(x.update.actions,d),"update action")},store:i,destroy(){l.flush(),C?.(),h?.(),on(),ln();for(let x of m)x.remove();for(let x of o.tracked)Ae(x);e.innerHTML=""}}},isPrefabData(e){return e!=null&&typeof e==="object"&&"$prefab"in e},isPrefabUpdate(e){return e!=null&&typeof e==="object"&&"$prefab"in e&&"update"in e}};function ws(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function hr(e,t,n){if(rn.has(e)){M.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(Be(e)!=null){M.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){M.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}Te(e,r),n.tracked.push(e)}catch(r){if(ws(r)){n.evalBlocked=!0,M.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}M.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function vs(e){if(typeof document>"u")return;let t=Ss(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let o=document.createElement("div");if(o.textContent=e.message,o.style.fontWeight="500",n.appendChild(o),e.description){let s=document.createElement("div");s.textContent=e.description,s.style.fontSize="14px",s.style.color="var(--muted-foreground, #6b7280)",n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.style.opacity="0",setTimeout(()=>n.remove(),300)},i)}function br(e,t){if(ve(e,t),typeof document<"u")ve(document.documentElement,t)}function ks(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function yr(e,t){let n=[];if(typeof document>"u")return n;for(let r of e??[]){let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}for(let r of t??[])if(ks(r)){let o=document.createElement("link");o.rel="stylesheet",o.href=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}else{let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}return n}function Cr(e,t){if(e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="",!t)return;if(t.preferredHeight!=null)e.style.height=`${t.preferredHeight}px`;if(t.minHeight!=null)e.style.minHeight=`${t.minHeight}px`;if(t.maxHeight!=null)e.style.maxHeight=`${t.maxHeight}px`,e.style.overflow="auto"}function Ss(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.style.position="fixed",t.style.bottom="16px",t.style.right="16px",t.style.zIndex="9999",t.style.maxWidth="400px",document.body.appendChild(t);return t}if(typeof window<"u"){Object.assign(window,{PrefabRenderer:q}),Object.assign(window,{prefab:{app:dt,mount:q.mount.bind(q),isPrefabData:q.isPrefabData.bind(q),isPrefabUpdate:q.isPrefabUpdate.bind(q),Bridge:he,isIframe:ke,registerPipe:Te,unregisterPipe:Ae,listPipes:Fe,registerComponent:p,createThemeToggle:De,validateWireFormat:Se,setLogLevel:je}});let e=Reflect.get(window,"__PREFAB_DATA__");if(q.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)q.mount(t,e)}}})();
|
|
16
|
+
`)}function Re(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function zt(e,t){if(!t)return;if(t.light)for(let[n,o]of Object.entries(t.light))e.style.setProperty(`--${Vt(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=po({dark:t.dark})}}function Jt(e,t){if(!e||typeof document>"u")return;let n=(o)=>{for(let[r,i]of Object.entries(e))if(hs(r,o))o.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function hs(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 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="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>',fo='<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>',mo={"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 ys(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 Ie(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=mo[n]??mo["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(Re(e,d),r)Re(document.documentElement,d);s.innerHTML=d==="dark"?fo:uo;try{localStorage.setItem(o,d)}catch{}}let c=ys(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")){Re(e,m),s.innerHTML=m==="dark"?fo:uo;try{localStorage.setItem(o,m)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function at(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=P(a);if(!l)return a;if(Boolean(l.error))throw Error(y(P(l.error)?.message)??"MCP tool call returned error");let u=W(P(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 lt(){return{callTool(e){return M.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return M.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var go="0.3.22";var bs=["light","dark","auto"],Cs=["inline","fullscreen","pip"];function ho(e){return S(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||S(e.payload))}function ct(e){return typeof e==="boolean"?e:void 0}function yo(e){let t=P(e.capabilities)??{},n=P(e.theme),o=P(e.toolInput),r=P(e.meta);return{hostName:y(e.hostName),hostVersion:y(e.hostVersion),capabilities:{toast:ct(t.toast),clipboard:ct(t.clipboard),navigation:ct(t.navigation),messaging:ct(t.messaging),displayModes:Wt(t.displayModes)},...n&&{theme:xs(n)},...o&&{toolInput:o},...r&&{meta:r}}}function xs(e){let t=y(e.fontCss);return{...dt({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Wt(e){let t=Array.isArray(e)?e:[];return Cs.filter((n)=>t.includes(n))}function dt(e){let t={},n=bs.find((s)=>s===e.theme);if(n)t.colorScheme=n;let o=P(e.styles),r=P(o?.variables);if(r)t.variables=Object.fromEntries(Object.entries(r).filter((s)=>typeof s[1]==="string"));let i=y(P(o?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function vs(e){return S(e)&&e.jsonrpc==="2.0"}class ye{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=ks();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let o=n.data;if(vs(o)){this.handleJsonRpc(o);return}if(!ho(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 bo;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(bo);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=P(i.capabilities)?.subscriptions===!0,t(yo(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",{...dt(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=P(i)??{},a=P(s.hostInfo)??{},l=P(s.hostContext)??{},c=P(s.hostCapabilities)??{},u=typeof l.theme==="string"||S(l.styles)?dt(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let d=P(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:Wt(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:go},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 bo=()=>{};function je(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)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 Ee(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function ks(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(S(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(o)=>{Reflect.apply(n,t,[o])}}}}catch{return}return}async function pt(e){st();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&Ee(),o,r,i={capabilities:{}};if(n)r=new ye(e?.hostOrigin),r.connect(),i=await r.initialize(e?.capabilities??{toolInput:!0}),o=r.createTransport();else if(e?.transport)o=at(e.transport);else o=lt();if(i.theme&&typeof document<"u")je(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=P(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?.(P(h.args)??h)}),r.on("prefab:theme-update",(h)=>{if(typeof document<"u")je(document.documentElement,h)}),r.on("prefab:host-context-changed",(h)=>{u?.(h)});function m(h,...x){let E=Kt(h),w=new Me,R={store:w,scope:{},transport:o,rerender:()=>k(),onToast:void 0};function k(){E.innerHTML="";for(let T of x)E.appendChild(V(T,R))}return k(),{rerender:k,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=Kt(h);return U.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"?Kt(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 Kt(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 Co=["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 wo=new Set(Co);function Te(e,t={}){let n=[],o=t.strict??!1;if(!S(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(!S(i))n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof i.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(r.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Gt(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)Ts(r.theme,n);if(r.css!==void 0)vo(r.css,"$.css",n);if(r.stylesheets!==void 0)vo(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(!S(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Gt(c,`$.defs.${l}`,n,o);let a=r.keyBindings;if(a!==void 0)if(!S(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))qt(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function ko(e){return Te(e).valid}function Gt(e,t,n,o){if(!S(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&&!wo.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++)Gt(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)qt(r[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(r)){if(s==="type"||Es.has(s)||i.includes(s))continue;if(xo(a)||Array.isArray(a)&&a.some(xo))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var Es=new Set(["children","fallback","trigger","empty","else","summary"]);function xo(e){return S(e)&&typeof e.type==="string"&&wo.has(e.type)}function qt(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)qt(e[i],`${t}[${i}]`,n);return}if(!S(e)){n.push({path:t,message:"Action must be an object or array of objects"});return}let 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 vo(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 Ts(e,t){if(!S(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}for(let n of["light","dark"])if(e[n]!==void 0){if(!S(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var U={mount(e,t,n){if(st(),n?.validate!==!1)for(let w of Te(t).errors)M.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))So(w,R,r);let i=new Me(o.state),s=n?.transport,a;if(!s)a=lt();else if("callTool"in s)a=s;else a=at(s);let l=n?.onToast??Ns,c=new He;function u(w){if(!U.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)zt(e,R.theme);if(R.mode)Ro(e,R.mode);if(R.pipes)for(let[k,T]of Object.entries(R.pipes))So(k,T,r);for(let k of m)k.remove();if(m.length=0,m.push(...Eo(R.css,R.stylesheets)),To(e,R.layout),b?.(),b=void 0,R.keyBindings)b=Jt(R.keyBindings,(k)=>{D(O(k,{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(zt(e,o.theme),o.mode)Ro(e,o.mode);To(e,o.layout);let m=Eo(o.css,o.stylesheets),b;if(o.keyBindings)b=Jt(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=Ie(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?.(),sn(),cn();for(let w of m)w.remove();for(let w of r.tracked)Le(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 Ms(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function So(e,t,n){if(rn.has(e)){M.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(_e(e)!=null){M.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let o=Function("return ("+t+")")();if(!en(o)){M.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}Ne(e,o),n.tracked.push(e)}catch(o){if(Ms(o)){n.evalBlocked=!0,M.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}M.warn(`wire pipe "${e}" — failed to hydrate:`,o)}}function Ns(e){if(typeof document>"u")return;let t=As(),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 Ro(e,t){if(Re(e,t),typeof document<"u")Re(document.documentElement,t)}function Ls(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function Eo(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(Ls(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 To(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 As(){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:U}),Object.assign(window,{prefab:{app:pt,mount:U.mount.bind(U),isPrefabData:U.isPrefabData.bind(U),isPrefabUpdate:U.isPrefabUpdate.bind(U),Bridge:ye,isIframe:Ee,registerPipe:Ne,unregisterPipe:Le,listPipes:Ve,registerComponent:p,createThemeToggle:Ie,validateWireFormat:Te,setLogLevel:Be}});let e=Reflect.get(window,"__PREFAB_DATA__");if(U.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)U.mount(t,e)}}})();
|