@heroui/agent 0.2.0-beta.8 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +2 -2
  3. package/dist/chart-content-BBHQVMP4.js +1 -0
  4. package/dist/chunk-4JEZZR5J.js +1 -0
  5. package/dist/chunk-5RHO3S5E.js +2 -0
  6. package/dist/chunk-64RI74L5.js +1 -0
  7. package/dist/chunk-6ZJJN322.js +1 -0
  8. package/dist/chunk-7KCGPNEN.js +1 -0
  9. package/dist/chunk-BBB5EHDN.js +5 -0
  10. package/dist/chunk-CLHBM3HQ.js +1 -0
  11. package/dist/chunk-CR3H7AVI.js +1 -0
  12. package/dist/chunk-HCLXS4HQ.js +1 -0
  13. package/dist/chunk-PZJ4NC3J.js +1 -0
  14. package/dist/chunk-RNNGE7KM.js +1 -0
  15. package/dist/chunk-S6OIAJSC.js +1 -0
  16. package/dist/chunk-UHHKMESI.js +1 -0
  17. package/dist/chunk-USFF5UMB.js +2 -0
  18. package/dist/component-renderer-XOCP6UFF.js +1 -0
  19. package/dist/composer-draft-NSKK65F3.js +1 -0
  20. package/dist/composer-image-draft-KAGTNQR7.js +1 -0
  21. package/dist/contracts.d.ts +275 -8
  22. package/dist/contracts.js +2 -2445
  23. package/dist/css/index.css +1 -1
  24. package/dist/embed-runtime-FP77ORXA.js +5 -0
  25. package/dist/index.d.ts +31 -5
  26. package/dist/index.js +1 -31
  27. package/dist/interactive-map-surface-WC2LPCR7.js +1 -0
  28. package/dist/internal/client-tools.js +1 -0
  29. package/dist/internal/models.js +1 -0
  30. package/dist/internal/runtime.js +1 -0
  31. package/dist/internal/theme.js +1 -0
  32. package/dist/next.js +1 -25
  33. package/dist/server.js +1 -136
  34. package/package.json +7 -6
  35. package/dist/chart-content-E4NPTUPR.js +0 -2696
  36. package/dist/chunk-3FG5NRTX.js +0 -9
  37. package/dist/chunk-CMZDZGUZ.js +0 -1132
  38. package/dist/chunk-DS4X5K2R.js +0 -56
  39. package/dist/chunk-FNGGMHVR.js +0 -625
  40. package/dist/chunk-G6GFNSG4.js +0 -284
  41. package/dist/chunk-Q7LGTVBL.js +0 -43
  42. package/dist/chunk-TOOT6SZ2.js +0 -74
  43. package/dist/chunk-UUPU3MYB.js +0 -42
  44. package/dist/chunk-VJA52U5P.js +0 -137
  45. package/dist/chunk-W7SCMB3O.js +0 -1285
  46. package/dist/component-renderer-MDDQMQTU.js +0 -10629
  47. package/dist/composer-draft-DTQAEO5K.js +0 -20
  48. package/dist/composer-image-draft-IVJ352E6.js +0 -174
  49. package/dist/embed-runtime-VVAGDPYY.js +0 -9422
  50. package/dist/interactive-map-surface-67KHT3VB.js +0 -362
package/CHANGELOG.md CHANGED
@@ -1,5 +1,75 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ - Keep the built-in Agent palette isolated from generic host variables such as
6
+ `--background` and `--foreground`, which may contain framework-specific color
7
+ channels rather than valid CSS colors and previously made panels transparent.
8
+ - Scope Glass and Mouve effects to an explicitly themed Agent root so similarly
9
+ named classes in the host application cannot restyle the embed.
10
+ - Add `appearance.zIndex` for applications that need the Agent below their own
11
+ dialogs or above unusually high application chrome.
12
+ - Use a default Agent layer of `40`, below HeroUI overlays at `50`, and keep
13
+ internal Agent layers relative to that host stacking context.
14
+ - Expose `--ha-z-index`, `--ha-panel-z-index`, `--ha-launcher-z-index`,
15
+ `--ha-popover-z-index`, `--ha-modal-z-index`, and `--ha-overlay-z-index` for
16
+ CSS-level control of the Agent layer scale.
17
+
18
+ ## 0.2.0-beta.17
19
+
20
+ - Publish prereleases with `--tag latest` so `npm i @heroui/agent` gets this
21
+ version. OIDC trusted publishing cannot `dist-tag add` (E401 on 0.2.0-beta.16).
22
+
23
+ ## 0.2.0-beta.16
24
+
25
+ - Move conversation shimmers to the GPU with a mask and translate animation;
26
+ reduced-motion keeps readable contrast instead of leaving the shimmer at low
27
+ opacity (#1020).
28
+
29
+ ## 0.2.0-beta.15
30
+
31
+ - Add `appearance.shouldCloseOnInteractOutside` for floating panels: omitted or
32
+ `true` closes on outside click; `false` or a predicate that returns false keeps
33
+ the panel open. Type is `boolean | ((element: Element) => boolean)`, matching
34
+ React Aria (#997).
35
+ - Add optional `showBetaBadge` to render a compact Beta chip in the open panel
36
+ header, including when set from the project's remote appearance configuration
37
+ (#994).
38
+ - Move optional runtime libraries (including `mermaid`, `maplibre-gl`, `motion`,
39
+ `shiki`, `recharts`, and related HeroUI packages) from peer dependencies into
40
+ `@heroui/agent` dependencies so `npm i @heroui/agent@beta` installs the full
41
+ graph. React and React DOM remain the only peer dependencies hosts must
42
+ provide. Renderers still load heavy libraries on demand and do not bundle them
43
+ into the published JavaScript (#993).
44
+
45
+ ## 0.2.0-beta.14
46
+
47
+ - Restore user-message bubbles to `--ha-surface` / `--ha-fg`, reverting the accent bubble from
48
+ `0.2.0-beta.13` / #949 (#959).
49
+
50
+ ## 0.2.0-beta.13
51
+
52
+ - Apply the configured Design System accent across Agent controls, generated UI, focus states,
53
+ launchers, and user-message bubbles, including when a Pro design theme is active.
54
+ - Keep the host page scrollable when the Agent is open as a floating desktop panel while
55
+ preserving modal scroll locking on mobile and expanded sidebars.
56
+
57
+ ## 0.2.0-beta.12
58
+
59
+ - Default the Agent API origin to `https://api.heroui.pro` so embeds and `createAuthToken` reach
60
+ production without an `_api.baseUrl` override.
61
+ - Default the Agent model picker to Gemini 3.7 Flash, and keep retired Gemini 3.5/3.6 Flash ids
62
+ resolving to it.
63
+ - Sanitize generated HTML and SVG markup with DOMPurify before rendering, and keep the sanitizer
64
+ external to the published bundle.
65
+ - Preserve suggested-prompt titles on first-turn submission instead of replacing them with a
66
+ generated conversation title.
67
+
68
+ ## 0.2.0-beta.9
69
+
70
+ - Reduce the published JavaScript footprint while preserving ESM code splitting, lazy UI tiers,
71
+ webpack prefetching, and downstream tree shaking.
72
+
3
73
  ## 0.2.0-beta.8
4
74
 
5
75
  - Replace the HeroUI Agents Trigger.dev transport with a preconnected protocol-v6 Durable Object
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # HeroUI Agents SDK
4
4
 
5
- Embed a hosted generative-UI agent in your React app with [`@heroui/agent`](https://www.heroui.com/agents). Declare typed client tools that read your data — the hosted runtime plans the answer, runs calculations in a sandbox, and streams back charts, tables, and metrics.
5
+ Embed a hosted generative-UI agent in your React app with [`@heroui/agent`](https://heroui.pro/agents). Declare typed client tools that read your data — the hosted runtime plans the answer, runs calculations in a sandbox, and streams back charts, tables, and metrics.
6
6
 
7
7
  ## Installation
8
8
 
@@ -202,7 +202,7 @@ This SDK speaks protocol version `6`. The hosted API returns `426 Upgrade Requir
202
202
  ## Support
203
203
 
204
204
  - [Documentation](https://heroui.pro/docs/agent)
205
- - [Agents product](https://www.heroui.com/agents)
205
+ - [Agents product](https://heroui.pro/agents)
206
206
  - [Issues](https://github.com/heroui-inc/heroui-platform/issues)
207
207
  - [Discord](https://discord.gg/9b6yyZKmH4)
208
208
 
@@ -0,0 +1 @@
1
+ "use client";import{a as Me,c as W,d as _,e as ce,i as j,j as Ke,l as L,m as Ne}from"./chunk-BBB5EHDN.js";import{b as U}from"./chunk-S6OIAJSC.js";import{a as J}from"./chunk-CR3H7AVI.js";import{useId as qe,useMemo as ae,useState as X}from"react";import{Area as Ue,Bar as je,CartesianGrid as Je,Cell as At,Label as Nt,Line as Ze,Pie as St,PolarAngleAxis as Qe,PolarGrid as kt,PolarRadiusAxis as wt,Radar as _t,RadialBar as Rt,AreaChart as $t,BarChart as Mt,ComposedChart as Kt,LineChart as Lt,PieChart as Pt,RadarChart as Tt,RadialBarChart as Gt,ScatterChart as It,ReferenceLine as Et,ResponsiveContainer as oe,Sankey as Vt,Scatter as Bt,Tooltip as ue,XAxis as Re,YAxis as be,ZAxis as Dt}from"recharts";import{createContext as at,useCallback as rt,useContext as nt,useMemo as it,useState as st}from"react";import{jsx as he,jsxs as lt}from"react/jsx-runtime";var Le=at(null);function Se({children:t,className:e,defaultSelectedKey:r,isDisabled:i=!1,onSelectionChange:n,selectedKey:s,size:h="md",variant:g="default",...m}){let[o,d]=st(r),u=s??o,p=rt(v=>{i||v===u||(s===void 0&&d(v),n?.(v))},[u,i,n,s]),k=it(()=>({isDisabled:i,select:p,selectedKey:u}),[u,i,p]);return he(Le,{value:k,children:he("div",{className:J("aui-segment",e),"data-disabled":i||void 0,"data-size":h,"data-slot":"agent-ui-segment","data-variant":g,role:"group",...m,children:t})})}function Pe({children:t,className:e,disabled:r,id:i,onClick:n,...s}){let h=nt(Le);if(!h)throw new Error("Segment.Item must be rendered inside Segment.");let g=h.isDisabled||r,m=h.selectedKey===i;return lt("button",{"aria-pressed":m,className:J("aui-segment__item",e),"data-selected":m,"data-slot":"agent-ui-segment-item",disabled:g,type:"button",onClick:o=>{n?.(o),o.defaultPrevented||h.select(i)},...s,children:[he("span",{"aria-hidden":"true",className:"aui-segment__indicator"}),he("span",{className:"aui-segment__label",children:t})]})}function Te({className:t,...e}){return he("span",{"aria-hidden":"true",className:J("aui-segment__separator",t),"data-slot":"agent-ui-segment-separator",...e})}var ke=Object.assign(Se,{Item:Pe,Root:Se,Separator:Te});var ot=[4,4,4,4],ut=[4,0,0,4],Ge=[0,0,0,0],Ie=[0,4,4,0],Ee=[4,4,0,0];function we({dataKey:t,horizontal:e,stacked:r,visibleStackKeys:i}){if(!r)return e?Ie:Ee;let n=i.indexOf(t);return n<0?Ge:e&&i.length===1?ot:e&&n===0?ut:e&&n===i.length-1?Ie:!e&&n===i.length-1?Ee:Ge}function Ve(t,{height:e,margins:r,width:i}){if(t.length===0||!mt(i,e,r)||!t.every(bt))return null;let n={bottom:e-r.bottom,height:e-r.top-r.bottom,left:r.left,right:i-r.right,top:r.top,width:i-r.left-r.right};if(n.width<1||n.height<1)return null;let s=Math.min(...t.map(c=>c.low)),h=Math.max(...t.map(c=>c.high)),g=ct(s,h);if(!g)return null;let m=ht(g[0],g[1]),o=[m[0],m.at(-1)],d=o[1]-o[0];if(!Number.isFinite(d)||d<=0)return null;let u=c=>n.top+(o[1]-c)/d*n.height,p=n.width/t.length,k=Math.max(1,Math.min(14,p*.62)),v=t.map((c,y)=>{let A=n.left+p*(y+.5),$=u(c.open),w=u(c.close),S=($+w)/2,f=Math.max(1,Math.abs(w-$)),M=dt(S-f/2,n.top,n.bottom-f);return{body:{height:f,width:k,x:A-k/2,y:M},direction:c.close>c.open?"up":c.close<c.open?"down":"flat",index:y,label:c.label,wick:{bottom:u(c.low),top:u(c.high),x:A},x:A}});return{bounds:n,candles:v,xLabelIndices:gt(t.length,n.width),yDomain:o,yTicks:m.map(c=>({value:c,y:u(c)}))}}function dt(t,e,r){return Math.min(Math.max(t,e),r)}function _e(t){let e=Number(t.toPrecision(12));return Object.is(e,-0)?0:e}function ct(t,e){if(e>t)return[t,e];let r=t===0?1:Math.abs(t)*.05,i=t-r,n=e+r;return Number.isFinite(i)&&Number.isFinite(n)&&n>i?[i,n]:null}function ht(t,e){let r=e-t,i=r/4,n=Math.floor(Math.log10(i)),s=[],h=new Set;for(let g=n-2;g<=n+2;g+=1)for(let m of[1,2,2.5,5,10]){let o=_e(m*10**g);if(!Number.isFinite(o)||o<=0||h.has(o))continue;h.add(o);let d=Math.floor(t/o)*o,u=Math.ceil(e/o)*o,p=Math.round((u-d)/o)+1;if(p<4||p>6)continue;let k=Array.from({length:p},(y,A)=>_e(d+A*o)),v=Math.max(0,u-d-r)/r,c=Math.abs(p-5)*100+v+Math.abs(Math.log10(o/i))*.01;s.push({score:c,ticks:k})}return s.sort((g,m)=>g.score-m.score),s[0]?.ticks??Array.from({length:5},(g,m)=>_e(t+r*m/4))}function gt(t,e){if(t===1)return[0];let r=Math.min(t,6,Math.max(2,Math.floor(e/72)+1));return r===t?Array.from({length:t},(i,n)=>n):Array.from({length:r},(i,n)=>Math.round(n*(t-1)/(r-1)))}function mt(t,e,r){return Number.isFinite(t)&&t>0&&Number.isFinite(e)&&e>0&&Object.values(r).every(i=>Number.isFinite(i)&&i>=0)}function bt(t){return[t.open,t.high,t.low,t.close].every(Number.isFinite)&&t.high>=Math.max(t.open,t.close,t.low)&&t.low<=Math.min(t.open,t.close,t.high)}function Be(t,e,r){if(![t,e,r].every(Number.isFinite)||e===r)return 0;let i=(t-e)/(r-e);return Math.min(1,Math.max(0,i))}function De(t){let{centerX:e,centerY:r,count:i,endAngle:n=405,height:s,max:h,min:g,notchLength:m,notchWidth:o,padding:d=0,radius:u,startAngle:p=135,value:k,width:v}=t;if(!Oe(v,s)||!He(i)||!ft(e,r,m,o,u)||![n,d,p].every(Number.isFinite)||d<0||m!==void 0&&m<=0||o!==void 0&&o<=0||u!==void 0&&u<=0)return null;let c=e??v/2,y=r??s/2;if(c<0||c>v||y<0||y>s)return null;let A=Math.min(c,v-c,y,s-y)-d;if(A<=0)return null;let $=Math.min(u??A,A),w=Math.min(m??Math.max(2,$*.16),$),S=Math.min(o??Math.max(1,$*.035),$*2);if(w<=0||S<=0)return null;let f=ie(c,y),M=Be(k,g,h),b=Array.from({length:i},(I,F)=>{let V=i===1?.5:F/(i-1),x=(F+1)/i,K=p+(n-p)*V,G=K*Math.PI/180,P=Math.cos(G),B=Math.sin(G),R=-B,E=P,H=$-w,T=S/2,D=ie(c+P*H,y+B*H),Y=ie(c+P*$,y+B*$),ne=ie(D.x-R*T,D.y-E*T),ee=ie(Y.x-R*T,Y.y-E*T),xe=ie(Y.x+R*T,Y.y+E*T),le=ie(D.x+R*T,D.y+E*T);return{active:M>=x,angle:O(K,1e6),index:F,inner:D,outer:Y,path:`M ${me(ne)} L ${me(ee)} L ${me(xe)} L ${me(le)} Z`,position:O(V,1e6),threshold:O(x,1e6)}});return{center:f,notchLength:O(w),notchWidth:O(S),notches:b,progress:M,radius:O($)}}function Fe(t){let{count:e,gap:r=2,height:i,inset:n=0,max:s,min:h,orientation:g="horizontal",value:m,width:o}=t;if(!Oe(o,i)||!He(e)||![r,n].every(Number.isFinite)||r<0||n<0)return null;let d=i-n*2,u=o-n*2;if(d<=0||u<=0)return null;let v=((g==="horizontal"?u:d)-r*(e-1))/e;if(!Number.isFinite(v)||v<=0)return null;let c=Be(m,h,s);return{notches:Array.from({length:e},(A,$)=>{let w=($+1)/e;return g==="horizontal"?{active:c>=w,height:O(d),index:$,threshold:O(w,1e6),width:O(v),x:O(n+$*(v+r)),y:O(n)}:{active:c>=w,height:O(v),index:$,threshold:O(w,1e6),width:O(u),x:O(n),y:O(i-n-v-$*(v+r))}}),orientation:g,progress:c}}function ft(...t){return t.every(e=>e===void 0||Number.isFinite(e))}function ie(t,e){return{x:O(t),y:O(e)}}function me(t){return`${t.x} ${t.y}`}function O(t,e=1e3){let r=Math.round(t*e)/e;return Object.is(r,-0)?0:r}function Oe(t,e){return[t,e].every(Number.isFinite)&&t>0&&e>0}function He(t){return Number.isInteger(t)&&t>=1&&t<=512}function Ye(t,e){if(!t)return[];let r=We(t,new Set),i=se(e.innerRadius,0),n=se(e.outerRadius,0),s=xt(e.maxDepth),h=se(e.startAngle,-90),g=se(e.endAngle,h+360),m=Math.min(g-h,360);if(!r||r.value<=0||s===0||i<0||n<=i||m<=1e-6)return[];let o=ze(r.children,1,s);if(o===0)return[];let d={arcs:[],centerX:se(e.centerX,0),centerY:se(e.centerY,0),gapAngle:Math.max(0,se(e.gapAngle,0)),innerRadius:i,maxDepth:s,ringWidth:(n-i)/o};return Xe(r.children,h,h+m,1,[r.id],d),d.arcs}function We(t,e){if(e.has(t))return null;e.add(t);let r=Array.isArray(t.children)?t.children:[],i=r.map(s=>We(s,e)).filter(s=>s!==null);e.delete(t);let n=r.length>0?i.reduce((s,h)=>s+h.value,0):Ct(t.value);return{children:i,id:t.id,label:t.label,value:n}}function ze(t,e,r){if(e>r)return 0;let i=0;for(let n of t)n.value<=0||(i=Math.max(i,e),e<r&&(i=Math.max(i,ze(n.children,e+1,r))));return i}function Xe(t,e,r,i,n,s){if(i>s.maxDepth)return;let h=t.filter(o=>o.value>0),g=h.reduce((o,d)=>o+d.value,0);if(g<=0)return;let m=e;for(let[o,d]of h.entries()){let u=o===h.length-1?r:m+(r-e)*d.value/g,[p,k]=yt(m,u,s.gapAngle),v=s.innerRadius+(i-1)*s.ringWidth,c=v+s.ringWidth,y=[...n,d.id];s.arcs.push({d:pt({centerX:s.centerX,centerY:s.centerY,endAngle:k,innerRadius:v,outerRadius:c,startAngle:p}),depth:i,endAngle:k,id:d.id,innerRadius:v,label:d.label,outerRadius:c,path:y,startAngle:p,value:d.value}),Xe(d.children,m,u,i+1,y,s),m=u}}function yt(t,e,r){let i=e-t,n=Math.min(r,Math.max(0,i-1e-6));return[t+n/2,e-n/2]}function pt(t){let e=t.endAngle-t.startAngle;if(e>=360-1e-6)return vt(t);let r=te(t,t.outerRadius,t.startAngle),i=te(t,t.outerRadius,t.endAngle),n=e>180?1:0,s=`M ${q(r)} A ${z(t.outerRadius)} ${z(t.outerRadius)} 0 ${n} 1 ${q(i)}`;if(t.innerRadius<=0)return`${s} L ${z(t.centerX)} ${z(t.centerY)} Z`;let h=te(t,t.innerRadius,t.endAngle),g=te(t,t.innerRadius,t.startAngle);return`${s} L ${q(h)} A ${z(t.innerRadius)} ${z(t.innerRadius)} 0 ${n} 0 ${q(g)} Z`}function vt(t){let e=t.startAngle+180,r=te(t,t.outerRadius,t.startAngle),i=te(t,t.outerRadius,e),n=`M ${q(r)} A ${z(t.outerRadius)} ${z(t.outerRadius)} 0 0 1 ${q(i)} A ${z(t.outerRadius)} ${z(t.outerRadius)} 0 0 1 ${q(r)}`;if(t.innerRadius<=0)return`${n} Z`;let s=te(t,t.innerRadius,t.startAngle),h=te(t,t.innerRadius,e);return`${n} L ${q(s)} A ${z(t.innerRadius)} ${z(t.innerRadius)} 0 0 0 ${q(h)} A ${z(t.innerRadius)} ${z(t.innerRadius)} 0 0 0 ${q(s)} Z`}function te(t,e,r){let i=r*Math.PI/180;return{x:t.centerX+Math.cos(i)*e,y:t.centerY+Math.sin(i)*e}}function q(t){return`${z(t.x)} ${z(t.y)}`}function z(t){let e=Math.round(t*1e6)/1e6;return String(Object.is(e,-0)?0:e)}function se(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function Ct(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:0}function xt(t){return t===void 0||t===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Number.isFinite(t)?Math.max(0,Math.floor(t)):0}import{Fragment as fe,jsx as a,jsxs as C}from"react/jsx-runtime";function ye(t,e,r){return r<1?null:t==="Home"?0:t==="End"?r-1:t==="ArrowRight"||t==="ArrowDown"?(e+1)%r:t==="ArrowLeft"||t==="ArrowUp"?(e-1+r)%r:null}function pe(t,e,r){let n=t.currentTarget.ownerSVGElement?.querySelectorAll(`[data-slot="${e}"]`)?.item(r);n&&typeof n.focus=="function"&&n.focus()}function Q({activeKeys:t,ariaLabel:e,items:r,onToggle:i}){let n=i!=null&&r.length>1,s=r.some(h=>h.value!=null);return a("div",{"aria-label":e,className:J("aui-legend",s?"aui-legend--values":void 0),"data-slot":"agent-ui-chart-legend",role:n?"group":"list",children:r.map(h=>{let g=C(fe,{children:[a("span",{className:"aui-legend__dot","data-slot":"agent-ui-chart-legend-indicator",style:{backgroundColor:h.color}}),a("span",{className:"aui-legend__label",children:h.label}),h.value!=null?a("span",{className:"aui-legend__value",children:h.value}):null]});return n?a("button",{"aria-pressed":t?.has(h.id)??!0,className:"aui-legend__button","data-slot":"agent-ui-chart-legend-item",type:"button",onClick:()=>i(h.id),children:g},h.id):a("span",{className:"aui-legend__item","data-slot":"agent-ui-chart-legend-item",role:"listitem",children:g},h.id)})})}function et({className:t,id:e,items:r,label:i,placement:n,style:s,visuallyHiddenFromAssistiveTechnology:h}){return C("div",{"aria-hidden":h||void 0,className:J("aui-chart-tooltip",t),"data-placement":n,"data-slot":"agent-ui-chart-tooltip",id:e,role:"tooltip",style:s,children:[i!==void 0&&i!==""?a("div",{className:"aui-chart-tooltip__header","data-slot":"agent-ui-chart-tooltip-header",children:i}):null,r.map(g=>C("div",{className:"aui-chart-tooltip__item","data-slot":"agent-ui-chart-tooltip-item",children:[a("span",{className:"aui-chart-tooltip__indicator","data-slot":"agent-ui-chart-tooltip-indicator",style:{backgroundColor:g.color}}),a("span",{className:"aui-chart-tooltip__label","data-slot":"agent-ui-chart-tooltip-label",children:g.label}),a("span",{className:"aui-chart-tooltip__value","data-slot":"agent-ui-chart-tooltip-value",children:g.value})]},g.id))]})}function de({active:t,indicatorColor:e,label:r,payload:i,series:n}){return!t||!i?.length?null:a(et,{label:r,items:i.map((s,h)=>{let g=n?.find(m=>m.dataKey===s.dataKey)?.format;return{color:e?.(s,h)??s.color??s.payload?.fill??s.fill??s.stroke??Ne(h),id:String(s.dataKey??s.name??`series-${h}`),label:s.name??s.dataKey,value:typeof s.value=="number"?_(s.value,g):s.value}})})}function ve({state:t}){return t?a(et,{visuallyHiddenFromAssistiveTechnology:!0,className:"aui-chart-tooltip--floating",items:t.items,label:t.label,placement:t.placement,style:{left:t.anchorX,top:t.anchorY}}):null}function re(t,e,r){let i=t.currentTarget.ownerSVGElement,n=i?.parentElement;if(!i||!n)return{...r,anchorX:0,anchorY:0,placement:"bottom"};let s=n.getBoundingClientRect(),h=s.width/2,g=s.height/2,m=typeof i.getScreenCTM=="function"?i.getScreenCTM():null;if(m)h=m.a*e.x+m.c*e.y+m.e-s.left,g=m.b*e.x+m.d*e.y+m.f-s.top;else{let d=i.getBoundingClientRect(),u=i.getAttribute("viewBox")?.trim().split(/[ ,]+/).map(Number);if(u?.length===4&&u.every(Number.isFinite)&&u[2]>0&&u[3]>0&&d.width>0&&d.height>0){let p=Math.min(d.width/u[2],d.height/u[3]),k=u[2]*p,v=u[3]*p;h=d.left-s.left+(d.width-k)/2+(e.x-u[0])*p,g=d.top-s.top+(d.height-v)/2+(e.y-u[1])*p}}let o=Math.min(95,s.width/2);return h=Math.min(Math.max(h,o),Math.max(o,s.width-o)),g=Math.min(Math.max(g,0),s.height),{...r,anchorX:h,anchorY:g,placement:g<92?"bottom":"top"}}function Ft({color:t,cx:e,cy:r,index:i,lastIndex:n}){return i!==n||e===void 0||r===void 0?null:C("g",{"aria-hidden":"true","data-slot":"agent-ui-chart-live-point",children:[a("circle",{className:"aui-chart-live-point__pulse",cx:e,cy:r,fill:t,r:"7"}),a("circle",{className:"aui-chart-live-point__core",cx:e,cy:r,fill:t,r:"3.5"})]})}function Ot(t,e){let r=Number(typeof e=="number"?e:e??NaN);return Number.isInteger(r)?t[r]:void 0}function Ce({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,type:s,viewAction:h}){let g=qe().replaceAll(":",""),[m,o]=X(()=>new Set),d=e.ranges??[],u=d.find(l=>l.id===e.defaultRangeId)?.id??d.at(-1)?.id,[p,k]=X(u),v=d.find(l=>l.id===p)??d.find(l=>l.id===u),c=ae(()=>new Set(e.series.map(l=>l.dataKey)),[e.series]),y=ae(()=>{let l=new Set([...m].filter(N=>c.has(N)));return l.size<e.series.length?l:new Set},[e.series.length,m,c]),A=ae(()=>e.data.map(l=>Object.fromEntries(Object.entries(l).map(([N,Z])=>[N,typeof Z=="number"||typeof Z=="string"?Z:String(Z??"")]))),[e.data]),$=v?.maxItems?A.slice(-v.maxItems):A,w=e.kind==="line-chart"&&e.mode==="live"?$.slice(-(e.windowSize??30)):$,S=e.series[0],f=(()=>{if(!e.showSummary||!S||w.length===0)return null;let l=Number(w[0]?.[S.dataKey]),N=Number(w.at(-1)?.[S.dataKey]);return!Number.isFinite(l)||!Number.isFinite(N)?null:{change:l===0?void 0:(N-l)/Math.abs(l)*100,format:S.format&&S.format.style!=="percent"?{...S.format,compact:!1}:S.format,label:S.label,value:N}})(),M=s==="bar"&&e.kind==="bar-chart"&&e.layout==="horizontal",b=e.kind==="composed-chart",I=e.series.filter(l=>!y.has(l.dataKey)).map(l=>l.dataKey),F=b?e.series.filter(l=>l.type==="bar"&&l.stacked&&!y.has(l.dataKey)).map(l=>l.dataKey):[],V=b?e.series.find(l=>l.axis!=="right")?.format:e.series[0]?.format,x=b?e.series.find(l=>l.axis==="right")?.format:void 0,K=b&&e.series.some(l=>l.axis==="right"),G=(l,N=V)=>N?_(l,N):ce(l),P=e.kind==="line-chart"?e.mode??"standard":"standard",B=e.kind==="line-chart"?e.baseline??0:0,R=S?w.flatMap(l=>{let N=Number(l[S.dataKey]);return Number.isFinite(N)?[N]:[]}):[],E=Math.min(B,...R),H=Math.max(B,...R),T=H===E?50:(H-B)/(H-E)*100,D=L(e.kind==="line-chart"?e.positiveColor??"success":"success",0),Y=L(e.kind==="line-chart"?e.negativeColor??"danger":"danger",1),ne=P==="live"&&S?Number(w.at(-1)?.[S.dataKey]):void 0,ee=new Set(e.series.filter(l=>!y.has(l.dataKey)).map(l=>l.dataKey)),xe=P==="profit-loss"?a(Q,{ariaLabel:"Chart direction",items:[{color:D,id:"positive",label:"Above baseline"},{color:Y,id:"negative",label:"Below baseline"}]}):a(Q,{activeKeys:ee,ariaLabel:"Chart series",items:e.series.map((l,N)=>({color:L(l.color,N),id:l.dataKey,label:l.label})),onToggle:e.series.length>1?l=>o(()=>{let N=new Set(y),Z=e.series.length-N.size;return N.has(l)?N.delete(l):Z>1&&N.add(l),N}):void 0}),le=C(fe,{children:[a(Je,{vertical:!1}),M?C(fe,{children:[a(Re,{tickFormatter:l=>G(l),type:"number"}),a(be,{dataKey:e.xKey,type:"category",width:88})]}):C(fe,{children:[a(Re,{dataKey:e.xKey,interval:"preserveStartEnd",minTickGap:28,tickMargin:10}),a(be,{domain:s==="line"?["auto","auto"]:void 0,tickFormatter:l=>G(l),width:"auto",yAxisId:b?"left":void 0}),K?a(be,{orientation:"right",tickFormatter:l=>G(l,x),width:"auto",yAxisId:"right"}):null]}),a(ue,{isAnimationActive:!1,content:a(de,{series:e.series,indicatorColor:P==="profit-loss"?l=>{let N=Number(l.value);return Number.isFinite(N)?N>=B?D:Y:void 0}:void 0})})]}),ge={data:w,margin:{bottom:2,left:8,right:K?8:12,top:8},...n&&{onClick:l=>{let N=Ot(w,l.activeIndex);N&&n(W(e,N))}}};return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||h?a(j,{component:e,formats:r,viewAction:h,onAction:i}):null,children:[f||d.length>0||P==="live"?C("div",{className:"aui-chart-toolbar","data-slot":"agent-ui-chart-toolbar",children:[f?C("div",{className:"aui-chart-summary","data-slot":"agent-ui-chart-summary",children:[a("span",{className:"aui-chart-summary__label",children:f.label}),C("div",{className:"aui-chart-summary__value-row",children:[a("strong",{className:"aui-chart-summary__value",children:_(f.value,f.format)}),f.change!==void 0?a(Ke,{value:f.change}):null,v?a("span",{className:"aui-chart-summary__range","data-slot":"agent-ui-chart-summary-range",children:v.label}):null]})]}):null,P==="live"?C("span",{className:"aui-chart-live","data-slot":"agent-ui-chart-live",children:[a("span",{"aria-hidden":"true",className:"aui-chart-live__dot"}),"Live",S&&Number.isFinite(ne)?a("span",{className:"aui-chart-accessible-value",children:`Latest ${S.label}: ${_(ne,S.format)}`}):null]}):null,d.length>0?a(ke,{"aria-label":"Chart range",className:"aui-chart-ranges",selectedKey:v?.id,variant:"text",onSelectionChange:k,children:d.map(l=>a(ke.Item,{id:l.id,children:l.label},l.id))}):null]}):null,a("div",{"aria-label":`${e.title} chart`,"data-slot":"agent-ui-chart",role:"img",className:J(`aui-chart aui-chart--${s}`,P==="live"?"aui-chart--live":void 0,P==="profit-loss"?"aui-chart--profit-loss":void 0),children:a(oe,{height:220,width:"100%",children:s==="composed"&&e.kind==="composed-chart"?C(Kt,{accessibilityLayer:!0,...ge,children:[a("defs",{children:e.series.map((l,N)=>C("linearGradient",{id:`${g}-${N}`,x1:"0",x2:"0",y1:"0",y2:"1",children:[a("stop",{offset:"0%",stopColor:L(l.color,N),stopOpacity:.18}),a("stop",{offset:"100%",stopColor:L(l.color,N),stopOpacity:.02})]},l.dataKey))}),le,e.series.map((l,N)=>{let Z=L(l.color,N),Ae=l.axis??"left";return l.type==="area"?a(Ue,{dataKey:l.dataKey,dot:!1,fill:`url(#${g}-${N})`,hide:y.has(l.dataKey),isAnimationActive:!1,name:l.label,stackId:l.stacked?"area-stack":void 0,stroke:Z,strokeWidth:2,type:"monotone",yAxisId:Ae},l.dataKey):l.type==="bar"?a(je,{dataKey:l.dataKey,fill:Z,hide:y.has(l.dataKey),isAnimationActive:!1,name:l.label,stackId:l.stacked?"bar-stack":void 0,yAxisId:Ae,radius:we({dataKey:l.dataKey,horizontal:!1,stacked:!!l.stacked,visibleStackKeys:F})},l.dataKey):a(Ze,{dataKey:l.dataKey,dot:!1,hide:y.has(l.dataKey),isAnimationActive:!1,name:l.label,stroke:Z,strokeWidth:2,type:"monotone",yAxisId:Ae},l.dataKey)})]}):s==="line"?C(Lt,{accessibilityLayer:!0,...ge,children:[P==="profit-loss"&&e.kind==="line-chart"?a("defs",{children:C("linearGradient",{id:`${g}-profit-loss`,x1:"0",x2:"0",y1:"0",y2:"1",children:[a("stop",{offset:`${T}%`,stopColor:D}),a("stop",{offset:`${T}%`,stopColor:Y})]})}):null,le,P==="profit-loss"?a(Et,{stroke:"var(--border)",strokeDasharray:"4 4",y:B}):null,e.series.map((l,N)=>a(Ze,{dataKey:l.dataKey,hide:y.has(l.dataKey),isAnimationActive:!1,name:l.label,strokeWidth:2,type:"monotone",dot:P==="live"?a(Ft,{color:L(l.color,N),lastIndex:w.length-1}):!1,stroke:P==="profit-loss"?`url(#${g}-profit-loss)`:L(l.color,N)},l.dataKey))]}):s==="area"?C($t,{accessibilityLayer:!0,...ge,children:[a("defs",{children:e.series.map((l,N)=>C("linearGradient",{id:`${g}-${N}`,x1:"0",x2:"0",y1:"0",y2:"1",children:[a("stop",{offset:"0%",stopColor:L(l.color,N),stopOpacity:.2}),a("stop",{offset:"100%",stopColor:L(l.color,N),stopOpacity:.01})]},l.dataKey))}),le,e.series.map((l,N)=>a(Ue,{dataKey:l.dataKey,dot:!1,fill:`url(#${g}-${N})`,hide:y.has(l.dataKey),isAnimationActive:!1,name:l.label,stroke:L(l.color,N),strokeWidth:2,type:"monotone",stackId:e.kind==="area-chart"&&e.stacked?"stack":void 0},l.dataKey))]}):C(Mt,{accessibilityLayer:!0,...ge,layout:M?"vertical":"horizontal",children:[le,e.series.map((l,N)=>a(je,{dataKey:l.dataKey,fill:L(l.color,N),hide:y.has(l.dataKey),isAnimationActive:!1,name:l.label,radius:we({dataKey:l.dataKey,horizontal:M,stacked:e.kind==="bar-chart"&&!!e.stacked,visibleStackKeys:I}),stackId:e.kind==="bar-chart"&&e.stacked?"stack":void 0},l.dataKey))]})})}),xe]})}function fa(t){return a(Ce,{...t,type:"line"})}function ya(t){return a(Ce,{...t,type:"area"})}function pa(t){return a(Ce,{...t,type:"bar"})}function va(t){return a(Ce,{...t,type:"composed"})}function tt({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,variant:s,viewAction:h}){let[g,m]=X(()=>new Set),o=ae(()=>new Set(e.data.map(c=>String(c[e.labelKey]??""))),[e.data,e.labelKey]),d=ae(()=>{let c=new Set([...g].filter(y=>o.has(y)));return c.size<e.data.length?c:new Set},[e.data.length,g,o]),u=e.data.flatMap((c,y)=>{let A=String(c[e.labelKey]??"");return d.has(A)?[]:[{color:L(e.colors?.[A],y),name:A,original:c,value:Number(c[e.valueKey]??0)}]}),p=u.reduce((c,y)=>c+y.value,0),k=new Set(e.data.map(c=>String(c[e.labelKey]??"")).filter(c=>!d.has(c))),v=a(Q,{activeKeys:k,ariaLabel:"Chart categories",items:e.data.map((c,y)=>{let A=String(c[e.labelKey]??"");return{color:L(e.colors?.[A],y),id:A,label:A,value:_(Number(c[e.valueKey]??0),e.format)}}),onToggle:c=>m(()=>{let y=new Set(d);return y.has(c)?y.delete(c):y.size<e.data.length-1&&y.add(c),y})});return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||h?a(j,{component:e,formats:r,viewAction:h,onAction:i}):null,children:[a("div",{"aria-label":`${e.title} ${s} chart`,className:"aui-chart aui-chart--pie","data-slot":"agent-ui-chart",role:"img",children:a(oe,{height:220,width:"100%",children:C(Pt,{accessibilityLayer:!0,children:[C(St,{cx:"50%",cy:"50%",data:u,dataKey:"value",innerRadius:s==="donut"?58:0,isAnimationActive:!1,nameKey:"name",outerRadius:88,paddingAngle:0,strokeWidth:0,onClick:(c,y)=>{let A=u[y]?.original;A&&n?.(W(e,A))},children:[u.map(c=>a(At,{fill:c.color},c.name)),s==="donut"?a(Nt,{className:"aui-donut-total",position:"center",value:_(p,e.format)}):null]}),a(ue,{content:a(de,{series:[{dataKey:"value",format:e.format}]}),isAnimationActive:!1})]})})}),v]})}function Ca(t){return a(tt,{...t,variant:"pie"})}function xa(t){return a(tt,{...t,variant:"donut"})}function Aa({className:t,component:e,exportFormats:r,onAction:i,viewAction:n}){let[s,h]=X(()=>new Set),g=ae(()=>new Set(e.series.map(u=>u.dataKey)),[e.series]),m=ae(()=>{let u=new Set([...s].filter(p=>g.has(p)));return u.size<e.series.length?u:new Set},[e.series.length,s,g]),o=new Set(e.series.filter(u=>!m.has(u.dataKey)).map(u=>u.dataKey)),d=a(Q,{activeKeys:o,ariaLabel:"Chart series",items:e.series.map((u,p)=>({color:L(u.color,p),id:u.dataKey,label:u.label})),onToggle:e.series.length>1?u=>h(()=>{let p=new Set(m),k=e.series.length-p.size;return p.has(u)?p.delete(u):k>1&&p.add(u),p}):void 0});return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||n?a(j,{component:e,formats:r,viewAction:n,onAction:i}):null,children:[a("div",{"aria-label":`${e.title} radar chart`,className:"aui-chart aui-chart--radar","data-slot":"agent-ui-chart",role:"img",children:a(oe,{height:240,width:"100%",children:C(Tt,{data:e.data,margin:{bottom:8,left:20,right:20,top:8},children:[a(kt,{}),a(Qe,{dataKey:e.angleKey}),a(wt,{axisLine:!1,tick:!1}),e.series.map((u,p)=>m.has(u.dataKey)?null:a(_t,{dataKey:u.dataKey,fill:L(u.color,p),fillOpacity:.12,isAnimationActive:!1,name:u.label,stroke:L(u.color,p),strokeWidth:2},u.dataKey)),a(ue,{content:a(de,{series:e.series}),isAnimationActive:!1})]})})}),d]})}function Na({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,viewAction:s}){let h=e.data.map((m,o)=>({...m,fill:L(e.colors?.[String(m[e.labelKey]??"")],o)})),g=a(Q,{ariaLabel:"Chart categories",items:e.data.map((m,o)=>{let d=String(m[e.labelKey]??"");return{color:L(e.colors?.[d],o),id:`${d}-${o}`,label:d,value:_(Number(m[e.valueKey]??0),e.format)}})});return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||s?a(j,{component:e,formats:r,viewAction:s,onAction:i}):null,children:[a("div",{"aria-label":`${e.title} radial chart`,className:"aui-chart aui-chart--radial","data-slot":"agent-ui-chart",role:"img",children:a(oe,{height:230,width:"100%",children:C(Gt,{cx:"50%",cy:"50%",data:h,endAngle:e.endAngle??-270,innerRadius:"24%",outerRadius:"92%",startAngle:e.startAngle??90,children:[a(Qe,{domain:[0,e.maxValue??"auto"],tick:!1,type:"number"}),a(Rt,{background:!0,dataKey:e.valueKey,isAnimationActive:!1,name:e.labelKey,onClick:m=>n?.(W(e,m))}),a(ue,{isAnimationActive:!1,content:a(de,{series:[{dataKey:e.valueKey,format:e.format}]})})]})})}),g]})}function Sa({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,viewAction:s}){let h=ae(()=>{let o=new Map;for(let d of e.data){let u=e.groupKey?String(d[e.groupKey]??"Other"):e.title,p=o.get(u)??[];p.push(d),o.set(u,p)}return[...o.entries()]},[e.data,e.groupKey,e.title]),g=[{dataKey:e.xKey,format:e.format},{dataKey:e.yKey,format:e.format},...e.sizeKey?[{dataKey:e.sizeKey,format:e.format}]:[]],m=a(Q,{ariaLabel:"Chart groups",items:h.map(([o],d)=>({color:L(e.colors?.[o],d),id:o,label:o}))});return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||s?a(j,{component:e,formats:r,viewAction:s,onAction:i}):null,children:[a("div",{"aria-label":`${e.title} scatter chart`,className:"aui-chart aui-chart--scatter","data-slot":"agent-ui-chart",role:"img",children:a(oe,{height:240,width:"100%",children:C(It,{accessibilityLayer:!0,margin:{bottom:8,left:0,right:8,top:8},children:[a(Je,{}),a(Re,{dataKey:e.xKey,name:e.xKey,tickFormatter:o=>ce(o),type:"number"}),a(be,{dataKey:e.yKey,name:e.yKey,tickFormatter:o=>ce(o),type:"number",width:42}),e.sizeKey?a(Dt,{dataKey:e.sizeKey,range:[48,320],type:"number"}):null,a(ue,{content:a(de,{series:g}),cursor:{strokeDasharray:"4 4"},isAnimationActive:!1}),h.map(([o,d],u)=>a(Bt,{data:d,fill:L(e.colors?.[o],u),isAnimationActive:!1,name:o,onClick:p=>{let k="payload"in p?p.payload:p;n?.(W(e,k))}},o))]})})}),m]})}function ka({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,viewAction:s}){let[h,g]=X(0),m=[...new Set(e.data.map(x=>String(x[e.xKey]??"")))],o=[...new Set(e.data.map(x=>String(x[e.yKey]??"")))],d=e.data.map(x=>Number(x[e.valueKey]??0)),u=Math.min(...d),p=Math.max(...d),k=p-u||1,v=420,c=84,y=28,A=8,$=44,w=(v-c-A)/Math.max(1,m.length),S=Math.max(26,Math.min(44,230/Math.max(1,o.length))),f=y+o.length*S+$,M=new Map(e.data.map(x=>[`${String(x[e.xKey]??"")}\0${String(x[e.yKey]??"")}`,x])),b=new Map([...M.keys()].map((x,K)=>[x,K])),I=Math.min(h,Math.max(0,M.size-1)),F=L(e.color,0),V=C("div",{"aria-label":"Heatmap intensity",className:"aui-legend aui-legend--scale","data-slot":"agent-ui-chart-legend",role:"img",children:[a("span",{className:"aui-legend__value",children:_(u,e.format)}),a("span",{className:"aui-legend__scale",style:{background:`linear-gradient(90deg, color-mix(in srgb, ${F} 8%, transparent), ${F})`}}),a("span",{className:"aui-legend__value",children:_(p,e.format)})]});return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||s?a(j,{component:e,formats:r,viewAction:s,onAction:i}):null,children:[a("div",{"aria-label":`${e.title} heatmap`,className:"aui-chart aui-chart--heatmap","data-slot":"agent-ui-chart",role:n?"group":"img",children:C("svg",{"aria-hidden":n?void 0:!0,preserveAspectRatio:"xMidYMid meet",viewBox:`0 0 ${v} ${f}`,children:[m.map((x,K)=>a("text",{className:"aui-heatmap__axis",textAnchor:"middle",x:c+K*w+w/2,y:f-14,children:x},x)),o.map((x,K)=>C("g",{children:[a("text",{className:"aui-heatmap__axis",dominantBaseline:"middle",textAnchor:"end",x:c-8,y:y+K*S+S/2,children:x}),m.map((G,P)=>{let B=`${G}\0${x}`,R=M.get(B),E=b.get(B),H=Number(R?.[e.valueKey]??0),T=R?.14+(H-u)/k*.76:.04;return C("g",{className:"aui-heatmap__cell","data-slot":R?"agent-ui-heatmap-cell":void 0,role:R&&n?"button":void 0,tabIndex:R&&n&&E!==void 0?E===I?0:-1:void 0,onClick:()=>{R&&n?.(W(e,R))},onFocus:()=>{E!==void 0&&g(E)},onKeyDown:D=>{if(!R||!n||E===void 0)return;let Y=ye(D.key,E,M.size);if(Y!==null){D.preventDefault(),g(Y),pe(D,"agent-ui-heatmap-cell",Y);return}D.key!=="Enter"&&D.key!==" "||(D.preventDefault(),n(W(e,R)))},children:[a("rect",{fill:F,fillOpacity:T,height:Math.max(1,S-3),rx:6,width:Math.max(1,w-3),x:c+P*w+1.5,y:y+K*S+1.5}),R?a("title",{children:`${x}, ${G}: ${_(H,e.format)}`}):null]},G)})]},x))]})}),V]})}function wa({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,viewAction:s}){let[h,g]=X(0),[m,o]=X(null),[d,u]=X(null),p=d??m,k=420,v=260,c=e.data.map(f=>({close:Number(f[e.closeKey]),high:Number(f[e.highKey]),label:String(f[e.xKey]??""),low:Number(f[e.lowKey]),open:Number(f[e.openKey])})),y=Ve(c,{height:v,margins:{bottom:34,left:58,right:8,top:10},width:k}),A=L(e.upColor??"success",0),$=L(e.downColor??"danger",1),w=L("default",2),S=Math.min(h,e.data.length-1);return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||s?a(j,{component:e,formats:r,viewAction:s,onAction:i}):null,children:[C("div",{"aria-label":`${e.title} candlestick chart`,className:"aui-chart aui-chart--candlestick","data-slot":"agent-ui-chart",role:"group",children:[C("svg",{preserveAspectRatio:"xMidYMid meet",viewBox:`0 0 ${k} ${v}`,children:[y?.yTicks.map(f=>C("g",{children:[a("line",{className:"aui-chart-grid-line",x1:y.bounds.left,x2:y.bounds.right,y1:f.y,y2:f.y}),a("text",{className:"aui-chart-axis-label",dominantBaseline:"middle",textAnchor:"end",x:y.bounds.left-9,y:f.y,children:e.format?_(f.value,e.format):ce(f.value)})]},f.value)),y?.candles.map(f=>{let M=e.data[f.index],b=c[f.index],I=f.direction==="up"?A:f.direction==="down"?$:w,F={items:[{color:I,id:"open",label:"Open",value:_(b.open,e.format)},{color:I,id:"high",label:"High",value:_(b.high,e.format)},{color:I,id:"low",label:"Low",value:_(b.low,e.format)},{color:I,id:"close",label:"Close",value:_(b.close,e.format)}],label:f.label};return C("g",{"aria-label":`${f.label}: open ${_(b.open,e.format)}, high ${_(b.high,e.format)}, low ${_(b.low,e.format)}, close ${_(b.close,e.format)}`,className:"aui-chart-mark","data-slot":"agent-ui-candlestick",role:M&&n?"button":"img",tabIndex:f.index===S?0:-1,onBlur:()=>o(null),onPointerLeave:()=>u(null),onClick:M&&n?()=>n(W(e,M)):void 0,onFocus:V=>{g(f.index),o(re(V,{x:f.x,y:Math.min(f.wick.top,f.body.y)},F))},onKeyDown:V=>{let x=ye(V.key,f.index,y.candles.length);if(x!==null){V.preventDefault(),g(x),pe(V,"agent-ui-candlestick",x);return}!M||!n||V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),n(W(e,M)))},onPointerEnter:V=>{u(re(V,{x:f.x,y:Math.min(f.wick.top,f.body.y)},F))},children:[a("line",{stroke:I,strokeWidth:1.5,x1:f.wick.x,x2:f.wick.x,y1:f.wick.top,y2:f.wick.bottom}),a("rect",{fill:I,height:f.body.height,rx:Math.min(2,f.body.width/2),width:f.body.width,x:f.body.x,y:f.body.y})]},`${f.label}-${f.index}`)}),y?.xLabelIndices.map(f=>{let M=y.candles[f];return M?a("text",{className:"aui-chart-axis-label",textAnchor:"middle",x:M.x,y:v-10,children:M.label},`${M.label}-${f}`):null})]}),a(ve,{state:p})]}),a(Q,{ariaLabel:"Price direction",items:[{color:A,id:"up",label:"Close above open"},{color:$,id:"down",label:"Close below open"}]})]})}function _a({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,viewAction:s}){let[h,g]=X(0),[m,o]=X(null),[d,u]=X(null),p=d??m,k=640,v=250,c=12,y=238,A=22,$=618,w=(e.orientation??"vertical")==="vertical",S=e.data.map(x=>Math.max(0,Number(x[e.valueKey]??0))),f=Math.max(...S,1),M=S[0]??0,b=Math.min(h,e.data.length-1),I=w?(y-c)/e.data.length:($-A)/e.data.length,F=x=>{let K=(S[x]??0)/f,G=(S[x+1]??S[x]??0)/f;if(w){let T=c+I*x,D=c+I*(x+1)-3,Y=Math.max(8,K*($-A)),ne=Math.max(8,G*($-A)),ee=k/2;return`${ee-Y/2},${T} ${ee+Y/2},${T} ${ee+ne/2},${D} ${ee-ne/2},${D}`}let P=A+I*x,B=A+I*(x+1)-3,R=Math.max(8,K*(y-c)),E=Math.max(8,G*(y-c)),H=v/2;return`${P},${H-R/2} ${B},${H-E/2} ${B},${H+E/2} ${P},${H+R/2}`},V=e.data.map((x,K)=>{let G=String(x[e.labelKey]??""),P=S[K]??0,B=M>0?P/M:0;return{color:L(e.colors?.[G],K),id:`${G}-${K}`,label:G,value:e.showPercentages?`${_(P,e.format)} \xB7 ${_(B,{maximumFractionDigits:1,style:"percent"})}`:_(P,e.format)}});return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||s?a(j,{component:e,formats:r,viewAction:s,onAction:i}):null,children:[C("div",{"aria-label":`${e.title} funnel chart`,"data-slot":"agent-ui-chart",role:"group",className:J("aui-chart aui-chart--funnel",w?"aui-chart--funnel-vertical":"aui-chart--funnel-horizontal"),children:[a("svg",{preserveAspectRatio:"xMidYMid meet",viewBox:`0 0 ${k} ${v}`,children:e.data.map((x,K)=>{let G=String(x[e.labelKey]??""),P=L(e.colors?.[G],K),B=S[K]??0,R=M>0?B/M:0,E={items:[{color:P,id:"value",label:"Value",value:_(B,e.format)},...e.showPercentages?[{color:P,id:"conversion",label:"From first stage",value:_(R,{maximumFractionDigits:1,style:"percent"})}]:[]],label:G},H=w?{x:k/2,y:c+I*K}:{x:A+I*(K+.5),y:c};return a("g",{"aria-label":`${G}: ${_(S[K]??0,e.format)}`,className:"aui-chart-mark","data-slot":"agent-ui-funnel-stage",role:n?"button":"img",tabIndex:K===b?0:-1,onBlur:()=>o(null),onPointerLeave:()=>u(null),onClick:n?()=>n(W(e,x)):void 0,onFocus:T=>{g(K),o(re(T,H,E))},onKeyDown:T=>{let D=ye(T.key,K,e.data.length);if(D!==null){T.preventDefault(),g(D),pe(T,"agent-ui-funnel-stage",D);return}n&&(T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),n(W(e,x))))},onPointerEnter:T=>{u(re(T,H,E))},children:a("polygon",{fill:P,points:F(K)})},`${G}-${K}`)})}),a(ve,{state:p})]}),a(Q,{ariaLabel:"Funnel stages",items:V})]})}function Ra({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,viewAction:s}){let[h,g]=X(null),[m,o]=X(null),d=m??h,{maximum:u,minimum:p}=Me(e),k=e.notches??30,v=L(e.color,0),c=_(e.value,e.format),y={label:e.label,max:u,min:p,value:e.value},A=e.orientation??"arc",$={items:[{color:v,id:"value",label:"Value",value:c},{color:v,id:"range",label:"Range",value:`${_(p,e.format)} \u2013 ${_(u,e.format)}`}],label:e.label},w=A==="arc"?{x:240,y:4}:{x:280,y:34},S={"aria-label":`${e.label}: ${c}`,onBlur:()=>g(null),onClick:n?()=>n(W(e,y)):void 0,onFocus:b=>{g(re(b,w,$))},onKeyDown:b=>{!n||b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),n(W(e,y)))},onPointerEnter:b=>{o(re(b,w,$))},onPointerLeave:()=>o(null),role:n?"button":"img",tabIndex:0},f=A==="arc"?De({centerX:240,centerY:126,count:k,height:240,max:u,min:p,padding:12,radius:104,value:e.value,width:480}):null,M=A==="linear"?Fe({count:k,gap:3,height:24,max:u,min:p,value:e.value,width:520}):null;return a(U,{className:t,description:e.description,title:e.title,actions:r?.length||s?a(j,{component:e,formats:r,viewAction:s,onAction:i}):null,children:C("div",{"aria-label":`${e.title} gauge chart`,className:`aui-chart aui-chart--gauge aui-chart--gauge-${A}`,"data-slot":"agent-ui-chart",role:"group",children:[A==="arc"?a("svg",{preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 480 240",children:C("g",{className:"aui-chart-mark","data-slot":"agent-ui-gauge",...S,children:[f?.notches.map(b=>a("path",{className:"aui-gauge__notch",d:b.path,"data-active":b.active,fill:b.active?v:"var(--surface-secondary)"},b.index)),a("text",{className:"aui-gauge__value",textAnchor:"middle",x:"240",y:"126",children:c}),a("text",{className:"aui-gauge__label",textAnchor:"middle",x:"240",y:"150",children:e.label}),a("text",{className:"aui-gauge__bound",textAnchor:"end",x:"154",y:"220",children:_(p,e.format)}),a("text",{className:"aui-gauge__bound",textAnchor:"start",x:"326",y:"220",children:_(u,e.format)})]})}):a("svg",{preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 560 130",children:C("g",{className:"aui-chart-mark","data-slot":"agent-ui-gauge",...S,children:[a("text",{className:"aui-gauge__label",x:"20",y:"24",children:e.label}),a("text",{className:"aui-gauge__value",textAnchor:"end",x:"540",y:"24",children:c}),M?.notches.map(b=>a("rect",{className:"aui-gauge__notch","data-active":b.active,fill:b.active?v:"var(--surface-secondary)",height:b.height,rx:Math.min(3,b.width/2),width:b.width,x:20+b.x,y:44+b.y},b.index)),a("text",{className:"aui-gauge__bound",x:"20",y:"96",children:_(p,e.format)}),a("text",{className:"aui-gauge__bound",textAnchor:"end",x:"540",y:"96",children:_(u,e.format)})]})}),a(ve,{state:d})]})})}function $e(t){return t.children?.length?t.children.reduce((e,r)=>e+$e(r),0):t.value??0}function $a({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,viewAction:s}){let[h,g]=X(0),[m,o]=X(null),[d,u]=X(null),p=d??m,k=360,v=250,c=Ye(e.data,{centerX:k/2,centerY:v/2,gapAngle:1.1,innerRadius:34,maxDepth:4,outerRadius:112}),y=new Map,A=new Map,$=0,w=(b,I=!1)=>{y.set(b.id,b),I||(A.set(b.id,L(b.color,$)),$+=1),b.children?.forEach(F=>w(F))};w(e.data,!0);let S=$e(e.data),f=Math.min(h,Math.max(0,c.length-1)),M=(e.data.children??[]).map(b=>({color:A.get(b.id)??L(b.color,0),id:b.id,label:b.label,value:_($e(b),e.format)}));return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||s?a(j,{component:e,formats:r,viewAction:s,onAction:i}):null,children:[C("div",{"aria-label":`${e.title} sunburst chart`,className:"aui-chart aui-chart--sunburst","data-slot":"agent-ui-chart",role:"group",children:[C("svg",{preserveAspectRatio:"xMidYMid meet",viewBox:`0 0 ${k} ${v}`,children:[c.map((b,I)=>{let F=A.get(b.id)??L(void 0,b.depth),V=b.path.map(R=>y.get(R)?.label??R),x=(b.startAngle+b.endAngle)/2*(Math.PI/180),K=(b.innerRadius+b.outerRadius)/2,G={items:[{color:F,id:"value",label:"Value",value:_(b.value,e.format)},{color:F,id:"share",label:"Share of total",value:_(S>0?b.value/S:0,{maximumFractionDigits:1,style:"percent"})}],label:V.join(" / ")},P={x:k/2+Math.cos(x)*K,y:v/2+Math.sin(x)*K},B={depth:b.depth,id:b.id,label:b.label,path:V.join(" / "),value:b.value};return a("g",{"aria-label":`${V.join(", ")}: ${_(b.value,e.format)}`,className:"aui-chart-mark","data-slot":"agent-ui-sunburst-segment",role:n?"button":"img",tabIndex:I===f?0:-1,onBlur:()=>o(null),onPointerLeave:()=>u(null),onClick:n?()=>n(W(e,B)):void 0,onFocus:R=>{g(I),o(re(R,P,G))},onKeyDown:R=>{let E=ye(R.key,I,c.length);if(E!==null){R.preventDefault(),g(E),pe(R,"agent-ui-sunburst-segment",E);return}n&&(R.key!=="Enter"&&R.key!==" "||(R.preventDefault(),n(W(e,B))))},onPointerEnter:R=>{u(re(R,P,G))},children:a("path",{className:"aui-sunburst__arc",d:b.d,fill:F})},b.id)}),a("text",{className:"aui-sunburst__total",textAnchor:"middle",x:k/2,y:v/2-2,children:_(S,e.format)}),a("text",{className:"aui-sunburst__root",textAnchor:"middle",x:k/2,y:v/2+16,children:e.data.label})]}),a(ve,{state:p})]}),M.length?a(Q,{ariaLabel:"Top-level categories",items:M}):null]})}function Ht({height:t,index:e,payload:r,width:i,x:n,y:s}){return C("g",{children:[a("rect",{className:"aui-sankey__node",fill:Ne(e),height:t,rx:4,width:i,x:n,y:s}),a("text",{className:"aui-sankey__label",dominantBaseline:"middle",x:n+i+7,y:s+t/2,children:r.name})]})}function Yt({chartId:t,index:e,linkWidth:r,payload:i,sourceControlX:n,sourceX:s,sourceY:h,targetControlX:g,targetX:m,targetY:o}){let d=Math.max(1,r)/2,u=`M${s},${h-d} C${n},${h-d} ${g},${o-d} ${m},${o-d} L${m},${o+d} C${g},${o+d} ${n},${h+d} ${s},${h+d} Z`;return C("g",{children:[C("defs",{children:[C("linearGradient",{id:`${t}-link-${e}`,x1:"0",x2:"1",children:[a("stop",{offset:"0%",stopColor:"var(--chart-3, var(--accent))",stopOpacity:.2}),a("stop",{offset:"50%",stopColor:"var(--chart-4, oklch(from var(--accent) calc(l + 0.12) c h))",stopOpacity:.55}),a("stop",{offset:"100%",stopColor:"var(--chart-1, oklch(from var(--accent) calc(l - 0.24) c h))",stopOpacity:.25})]}),a("filter",{height:"180%",id:`${t}-glow-${e}`,width:"180%",x:"-40%",y:"-40%",children:a("feGaussianBlur",{stdDeviation:"2.5"})})]}),a("path",{d:u,fill:`url(#${t}-link-${e})`,filter:`url(#${t}-glow-${e})`,opacity:.35}),a("path",{d:u,fill:`url(#${t}-link-${e})`,opacity:.8}),a("title",{children:`${i.source.name} \u2192 ${i.target.name}: ${i.value}`})]})}function Ma({className:t,component:e,exportFormats:r,onAction:i,onSelect:n,viewAction:s}){let h=qe().replaceAll(":",""),g=new Map(e.nodes.map((o,d)=>[o.id,d])),m={links:e.links.flatMap(o=>{let d=g.get(o.source),u=g.get(o.target);return d===void 0||u===void 0?[]:[{source:d,target:u,value:o.value}]}),nodes:e.nodes.map(o=>({name:o.label}))};return C(U,{className:t,description:e.description,title:e.title,actions:r?.length||s?a(j,{component:e,formats:r,viewAction:s,onAction:i}):null,children:[a("div",{"aria-label":`${e.title} sankey chart`,className:"aui-chart aui-chart--sankey aui-sankey","data-slot":"agent-ui-chart",role:"img",children:a(oe,{height:260,width:"100%",children:a(Vt,{data:m,link:o=>a(Yt,{...o,chartId:h}),linkCurvature:.55,margin:{bottom:12,left:8,right:92,top:12},node:o=>a(Ht,{...o}),nodePadding:18,nodeWidth:12,onClick:(o,d)=>n?.(W(e,{element:d,index:o.index,value:"payload"in o?o.payload.value:void 0})),children:a(ue,{content:a(de,{series:[{dataKey:"value",format:e.format}]}),isAnimationActive:!1})})})}),a("div",{"aria-label":"Chart encoding",className:"aui-legend","data-slot":"agent-ui-chart-legend",role:"list",children:C("span",{className:"aui-legend__item","data-slot":"agent-ui-chart-legend-item",role:"listitem",children:[a("span",{className:"aui-legend__flow"}),a("span",{className:"aui-legend__label",children:"Flow volume"})]})})]})}export{ya as AreaChartComponentContent,pa as BarChartComponentContent,wa as CandlestickChartComponentContent,va as ComposedChartComponentContent,xa as DonutChartComponentContent,_a as FunnelChartComponentContent,Ra as GaugeChartComponentContent,ka as HeatmapComponentContent,fa as LineChartComponentContent,Ca as PieChartComponentContent,Aa as RadarChartComponentContent,Na as RadialChartComponentContent,Ma as SankeyChartComponentContent,Sa as ScatterChartComponentContent,$a as SunburstChartComponentContent};
@@ -0,0 +1 @@
1
+ var m=["base","brutalism","glass","mouve"];function k(e){return m.includes(e)?e:"base"}var A={accent:"accent",background:"background",foreground:"foreground",overlay:"overlay",surface:"surface",surfaceSecondary:"surface-secondary",tooltip:"tooltip"},p={"--accent":"var(--ha-accent)","--accent-foreground":"var(--ha-accent-foreground)","--accent-hover":"var(--ha-accent)","--field-border-focus":"var(--ha-accent)","--focus":"var(--ha-accent)"},l="oklch(from var(--ha-accent) clamp(0, (0.7 - l) * 1000, 1) 0 h)",d="oklch(from var(--ha-launcher-bg) clamp(0, (0.7 - l) * 1000, 1) 0 h)";function R(e){let r={},o=n(e,"light"),t=n(e,"dark");return o&&(r["--ha-theme-launcher-background-light"]=o,r["--ha-theme-launcher-foreground-light"]=d),t&&(r["--ha-theme-launcher-background-dark"]=t,r["--ha-theme-launcher-foreground-dark"]=d),r}var y="oklch(from var(--ha-card-secondary) calc(l - 0.0151) c h)",T="oklch(from var(--ha-card-secondary) calc(l + 0.017) c h)",u={pill:"0.875rem",round:"0.5rem",sharp:"0.125rem",soft:"0.375rem"},C=12,S=18;function f(e){let r=e?.trim();if(!(!r||r.length>256||/[;{}]/.test(r)))return r}function n(e,r){if(e!==void 0)return f(typeof e=="string"?e:e[r])}function b(e){if(!e)return{};let r={},o=!!(n(e.colors?.accent,"light")||n(e.colors?.accent,"dark"));e.radius&&e.radius in u&&(r["--radius"]=u[e.radius]);let t=f(e.typography?.fontFamily);t&&(r["--ha-font-family"]=t);let a=e.typography?.baseSize;if(typeof a=="number"&&Number.isFinite(a)){let c=Math.min(Math.max(Math.round(a),C),S);r["--ha-font-size"]=`${c}px`}for(let[c,s]of Object.entries(A)){let i=e.colors?.[c],g=n(i,"light"),h=n(i,"dark");g&&(r[`--ha-theme-${s}-light`]=g),h&&(r[`--ha-theme-${s}-dark`]=h)}return o&&Object.assign(r,p),n(e.colors?.accent,"light")&&(r["--ha-theme-accent-foreground-light"]=l),n(e.colors?.accent,"dark")&&(r["--ha-theme-accent-foreground-dark"]=l),n(e.colors?.surfaceSecondary,"light")&&(r["--ha-theme-surface-tertiary-light"]=y),n(e.colors?.surfaceSecondary,"dark")&&(r["--ha-theme-surface-tertiary-dark"]=T),r}export{m as a,k as b,l as c,d,R as e,b as f};
@@ -0,0 +1,2 @@
1
+ import{b as de,e as ue,f as me}from"./chunk-4JEZZR5J.js";var St="1.0.0-beta.1",pe="https://api.heroui.pro";import{jsx as Ge,jsxs as ze}from"react/jsx-runtime";function Mt({indicator:e,label:t="Loading agent\u2026"}){return ze("div",{"aria-live":"polite",className:"ha-agent-loading",role:"status",children:[e,Ge("span",{children:t})]})}import{jsx as ge,jsxs as Ke}from"react/jsx-runtime";function K({children:e,shortcut:t}){return Ke("span",{"aria-hidden":"true",className:"ha-control-tooltip",children:[ge("span",{children:e}),t?ge("kbd",{className:"ha-control-tooltip__shortcut",children:t}):null]})}import{ChevronsCollapseUpRight as Ye,ChevronsExpandUpRight as qe}from"@gravity-ui/icons";import{useCallback as Ae,useEffect as V,useEffectEvent as je,useLayoutEffect as Ze,useRef as re,useState as $}from"react";function he(e){return`heroui-agent:sidebar-width:${e}`}function ne(e,t){let n=Math.min(720,Math.floor(t*.9)),o=Math.max(n,320);return Math.min(Math.max(Math.round(e),320),o)}function fe(e,t){let n=Number.NaN;try{n=Number(localStorage.getItem(he(e))??Number.NaN)}catch{}return ne(Number.isFinite(n)?n:420,t)}function oe(e,t){try{localStorage.setItem(he(e),String(Math.round(t)))}catch{}}import{jsx as d,jsxs as R}from"react/jsx-runtime";function Je(e,t){return e===!1?!1:e===void 0||e===!0||!(t instanceof Element)?!0:e(t)}function Dt({actionsSlot:e,agentId:t,children:n,defaultExpanded:o=!1,expandable:a=!0,expandedSidebarSlot:b,expandedTitle:w,historySlot:i,keepMounted:c=!1,name:m,onClose:C,onNewConversation:H,open:f,shouldCloseOnInteractOutside:y,showBetaBadge:L=!1,viewMode:p}){let x=re(null),_=re(0),[O,k]=$(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:null),N=je(C),[v,Q]=$(o),F=O!==null,S=O??!1,s=p==="floating",g=!s&&!S,h=S||g&&v,[ee,ce]=$(!1),Le=!S&&a,B=g&&v&&b;return Ze(()=>{let r=window.matchMedia?.("(max-width: 639px)");if(!r)return;let A=()=>k(r.matches);return A(),r.addEventListener?.("change",A),()=>r.removeEventListener?.("change",A)},[]),V(()=>{if(!ee)return;let r=x.current;if(!r)return;let A=()=>ce(!1),E=U=>{let{propertyName:u,target:T}=U;T===r&&(u!=="width"&&u!=="height"||A())},te=window.setTimeout(A,600);return r.addEventListener("transitionend",E),()=>{window.clearTimeout(te),r.removeEventListener("transitionend",E)}},[ee]),V(()=>{if(!f||!F)return;let r=x.current;if(!r)return;let A=document.activeElement instanceof HTMLElement?document.activeElement:null;r.open||(h&&typeof r.showModal=="function"?r.showModal():!h&&typeof r.show=="function"?r.show():r.open=!0);let E;if(h){let u=document.documentElement,T=window.scrollX,I=window.scrollY,W=u.style.overflow,G=document.body.style.overflow,z=document.body.style.position,Fe=document.body.style.top,Be=document.body.style.left,Ue=document.body.style.right,We=document.body.style.width;u.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`${-I}px`,document.body.style.left=`${-T}px`,document.body.style.right="0",document.body.style.width="100%",E=()=>{u.style.overflow=W,document.body.style.overflow=G,document.body.style.position=z,document.body.style.top=Fe,document.body.style.left=Be,document.body.style.right=Ue,document.body.style.width=We,window.scrollTo(T,I)}}let te=r.querySelector("button,textarea,input,[tabindex]:not([tabindex='-1'])");r.contains(document.activeElement)||te?.focus();let U=u=>{if(!h&&u.key==="Escape"){if(be(r)){_.current=Date.now(),u.preventDefault(),u.stopPropagation();return}u.preventDefault(),N();return}if(!h||u.key!=="Tab")return;let T=Array.from(r.querySelectorAll("button:not(:disabled),textarea:not(:disabled),input:not(:disabled),[tabindex]:not([tabindex='-1'])"));if(T.length===0)return;let I=T[0],W=T[T.length-1],G=r.getRootNode(),z=G instanceof ShadowRoot?G.activeElement:document.activeElement;u.shiftKey&&z===I?(u.preventDefault(),W.focus()):!u.shiftKey&&z===W&&(u.preventDefault(),I.focus())};return r.addEventListener("keydown",U),()=>{r.removeEventListener("keydown",U),typeof r.close=="function"?r.close():r.open=!1,E?.(),document.activeElement===document.body&&A?.focus()}},[h,f,F]),V(()=>{if(!f||!s||h)return;let r=x.current;if(!r)return;let A=E=>{E.composedPath().includes(r)||Je(y,E.target)&&N()};return document.addEventListener("click",A,!0),()=>document.removeEventListener("click",A,!0)},[h,s,f,y]),!f&&!c?null:R("dialog",{ref:x,"aria-label":m,"aria-modal":h,className:"ha-panel","data-agent-overlay-root":"","data-expanded":!S&&v?"true":void 0,"data-expanded-sidebar":B?"true":void 0,"data-resizing":ee?"true":void 0,hidden:!f,onCancel:r=>{if(r.preventDefault(),Date.now()-_.current<350||be(x.current)){_.current=Date.now();return}C()},children:[g&&!v?d(Qe,{agentId:t,panelRef:x}):null,B?d("aside",{"aria-label":"Chat history",className:"ha-expanded-sidebar",children:b}):null,R("div",{className:"ha-panel-main",children:[R("header",{className:"ha-header",children:[R("div",{className:"ha-header-title",children:[B?d("span",{className:"ha-session-title ha-expanded-chat-title",children:w??m}):i??d("strong",{children:m}),L?d("span",{className:"ha-beta-badge",children:"Beta"}):null]}),R("div",{className:"ha-header-actions",children:[B?null:e??(H?d("button",{"aria-label":"New chat",className:"ha-icon-button ha-new-chat-button",type:"button",onClick:H,children:d(tt,{})}):null),Le?d("button",{"aria-expanded":v,"aria-label":v?"Collapse assistant":"Expand assistant",className:"ha-expand-button ha-icon-button",type:"button",onClick:()=>{ce(!0),Q(r=>!r)},children:v?d(Ye,{"aria-hidden":"true"}):d(qe,{"aria-hidden":"true"})}):null,R("button",{"aria-keyshortcuts":"Escape","aria-label":"Close assistant",className:"ha-close-button ha-icon-button","data-shortcut":"ESC","data-tooltip":"Close assistant",type:"button",onClick:C,children:[d(et,{}),d(K,{shortcut:"ESC",children:"Close assistant"})]})]})]}),n,d("div",{className:"ha-overlay-portal","data-agent-overlay-portal":""})]})]})}function be(e){let t=e?.querySelector(['[data-slot$="-popover"]','[data-slot="agent-ui-image-modal"]','[data-slot="modal-dialog"]',".ha-feedback-popover"].join(","));return t?(t.querySelector('button[aria-label="Dismiss"]')?.click(),!0):!1}function Qe({agentId:e,panelRef:t}){let[n,o]=$(420),a=re(null),b=Ae(i=>{let c=t.current,m=c?.getRootNode();(m instanceof ShadowRoot?m.host:c?.closest("[data-heroui-agent]"))?.style.setProperty("--ha-sidebar-width",`${i}px`),window.innerWidth>=640&&(document.documentElement.style.marginRight=`${Math.min(i,window.innerWidth)}px`),o(i)},[t]);V(()=>{o(fe(e,window.innerWidth))},[e]);let w=Ae((i,c)=>{let m=ne(i,window.innerWidth);return b(m),c&&oe(e,m),m},[b,e]);return d("div",{"aria-label":"Resize assistant panel","aria-orientation":"vertical","aria-valuemax":720,"aria-valuemin":320,"aria-valuenow":n,className:"ha-resize-handle",role:"separator",tabIndex:0,onKeyDown:i=>{let c=i.key==="ArrowLeft"?24:i.key==="ArrowRight"?-24:0;c!==0&&(i.preventDefault(),w(n+c,!0))},onPointerCancel:i=>{let c=a.current;c&&(a.current=null,delete i.currentTarget.dataset.resizing,t.current&&delete t.current.dataset.dragResizing,document.documentElement.style.transition=c.pageTransition,w(c.startWidth,!1))},onPointerDown:i=>{i.button!==0&&i.pointerType==="mouse"||(i.preventDefault(),i.currentTarget.setPointerCapture(i.pointerId),i.currentTarget.dataset.resizing="true",a.current={currentWidth:n,pageTransition:document.documentElement.style.transition,startWidth:n,startX:i.clientX},document.documentElement.style.transition="none",t.current&&(t.current.dataset.dragResizing="true"))},onPointerMove:i=>{let c=a.current;c&&(c.currentWidth=w(c.startWidth+(c.startX-i.clientX),!1))},onPointerUp:i=>{let c=a.current;c&&(a.current=null,delete i.currentTarget.dataset.resizing,t.current&&delete t.current.dataset.dragResizing,i.currentTarget.releasePointerCapture(i.pointerId),document.documentElement.style.transition=c.pageTransition,oe(e,c.currentWidth))}})}function et(){return d("svg",{"aria-hidden":"true",fill:"none",height:"18",viewBox:"0 0 18 18",width:"18",children:d("path",{d:"m4.25 4.25 9.5 9.5m0-9.5-9.5 9.5",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.6"})})}function tt(){return d("svg",{"aria-hidden":"true",fill:"none",height:"18",viewBox:"0 0 18 18",width:"18",children:d("path",{d:"M9 4v10M4 9h10",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.6"})})}function ye(e,{generateConversationTitle:t=!0}={}){let n=performance.now(),o=Date.now(),a=e.trim();return a?{...t?{}:{generateConversationTitle:!1},messageId:crypto.randomUUID(),prompt:a,startedAt:n,startedAtWallClock:o,submitted:!0}:null}var P=new Map,X=new Map,nt=10080*60*1e3,Y=new Map;function ve(e){return`heroui-agent:shell-draft:${e}:composer-draft:v1`}function ae(e,t){try{let n=ve(e);t.trim()?localStorage.setItem(n,JSON.stringify({prompt:t,savedAt:Date.now()})):localStorage.removeItem(n)}catch{}}function ot(e){let t=ve(e);try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&typeof n.prompt=="string"&&n.prompt.trim()&&typeof n.savedAt=="number"&&Date.now()-n.savedAt<=nt)return n.prompt;localStorage.removeItem(t)}catch{}return""}function q(e,t){if(!t.prompt.trim()&&!t.submitted){P.delete(e),ae(e,"");return}P.set(e,t),t.submitted||ae(e,t.prompt)}function ie(e){let t=P.get(e);if(t)return t;let n=ot(e);return n?{prompt:n,submitted:!1}:void 0}function Te(e,t,n){let o=P.get(e);!o?.submitted||o.messageId!==t||o.firstFeedbackPaintedAt!==void 0||P.set(e,{...o,firstFeedbackPaintedAt:n})}function Bt(e){let t=ie(e);return P.delete(e),ae(e,""),t}function D(e,t,n){t?Y.set(e,[n?.selectionStart??0,n?.selectionEnd??0,n?.selectionDirection??"none"]):Y.delete(e)}function we(e,t){let n=Y.get(e);if(!n||!t)return;t.focus({preventScroll:!0});let o=Math.min(n[0],t.value.length),a=Math.min(n[1],t.value.length);t.setSelectionRange(o,a,n[2]),Y.set(e,[o,a,n[2]])}function xe(e,t){return t instanceof Node?e.contains(t)||e.closest(".ha-composer-wrap")?.querySelector(".ha-footnote")?.contains(t)===!0||e.closest(".ha-root")?.querySelector(".ha-overlay-portal")?.contains(t)===!0:!1}function Ut(e,t){t.length===0?X.delete(e):X.set(e,t)}function rt(e){return X.get(e)??[]}function Wt(e){let t=rt(e);return X.delete(e),t}function Se(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function at(e){let t=getComputedStyle(e),n=Number.parseFloat(t.lineHeight);if(Number.isFinite(n)&&n>0)return n;let o=Number.parseFloat(t.fontSize);return Number.isFinite(o)&&o>0?o*1.2:20}function it(e){let t=getComputedStyle(e);return Se(t.paddingTop)+Se(t.paddingBottom)}function st(e){let t=e.style.height,n=e.style.minHeight,o=e.style.maxHeight;e.style.height="0px",e.style.minHeight="0px",e.style.maxHeight="none";let a=e.scrollHeight;return e.style.height=t,e.style.minHeight=n,e.style.maxHeight=o,a}function lt(e){if(e.value.includes(`
2
+ `))return!0;if(e.clientWidth===0)return!1;let t=st(e),n=it(e),o=at(e);return Math.max(0,t-n)>o*1.5}function se(e,{hasAttachments:t=!1,maxHeight:n=120}={}){if(!e)return!1;let o=e.value.length>0;return t||o&&lt(e)?(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,n)}px`,!0):(e.style.height="auto",!1)}import{jsx as le,jsxs as Ee}from"react/jsx-runtime";var ct="https://heroui.pro/?utm_source=heroui-agent&utm_medium=referral&utm_campaign=powered-by-hero";function Me(){return Ee("a",{"aria-label":"Powered by HeroUI Pro (opens in a new tab)",className:"ha-powered-by",href:ct,rel:"noopener noreferrer",target:"_blank",children:[le("span",{children:"Powered by"}),Ee("svg",{"aria-hidden":"true",className:"ha-powered-by-logo",fill:"none",viewBox:"0 0 140 44",children:[le("path",{d:"M.678 11.385V24.04c0 .599.307 1.155.813 1.471l8.628 5.396c1.15.719 2.639-.11 2.639-1.47V18.798c0-.612.322-1.18.847-1.491l5.263-3.13v27.267c0 1.355 1.48 2.186 2.63 1.476l8.905-5.497a1.72 1.72 0 0 0 .822-1.476V9.765c0-1.349-1.467-2.18-2.618-1.484l-9.74 5.897V2.556c0-1.345-1.46-2.177-2.61-1.488L1.52 9.897a1.72 1.72 0 0 0-.842 1.488Z",fill:"currentColor"}),le("path",{d:"M63.876 24.071c0-3.59-1.468-5.246-4.405-5.246-3.363 0-5.732 2.255-5.732 7.316v11.595h-6.063V5.528h6.063v11.779c1.468-2.393 3.884-3.59 7.2-3.59 5.637 0 8.953 3.451 8.953 9.25v14.769h-6.016V24.071ZM84.9 38.473c-7.533 0-12.317-4.877-12.317-12.378 0-7.408 4.737-12.378 12.317-12.378 8.195 0 12.648 5.798 11.416 13.942H78.647c.331 3.865 2.605 6.075 6.253 6.075 2.984 0 4.784-1.52 5.258-3.037h6.016c-.947 4.509-5.115 7.776-11.274 7.776ZM78.789 23.657h11.653c-.047-3.175-2.132-5.338-5.685-5.338-3.174 0-5.4 1.84-5.968 5.338ZM99.623 20.344c0-3.82 2.131-5.89 6.205-5.89h7.77v4.97h-7.912v18.312h-6.063V20.344ZM126.863 38.473c-7.674 0-12.553-4.924-12.553-12.378 0-7.454 4.879-12.378 12.553-12.378 7.58 0 12.459 4.924 12.459 12.378 0 7.454-4.88 12.378-12.46 12.378Zm0-5.016c3.79 0 6.3-2.898 6.3-7.362 0-4.463-2.51-7.408-6.3-7.408-3.838 0-6.348 2.945-6.348 7.408 0 4.464 2.51 7.362 6.348 7.362Z",fill:"currentColor"})]})]})}var Ce=new Set(["ask","auto","full"]);function j(e){return Ce.has(e)?e:"auto"}function $t(e,t){return`${e}:permission-mode:${t}:v1`}function Xt(e,t){return`${e}:active-permission-mode:${t}:v1`}function Yt(e){try{let t=localStorage.getItem(e);return t!==null&&Ce.has(t)?j(t):void 0}catch{return}}function qt(e,t){try{localStorage.setItem(e,t)}catch{}}function jt(e){try{localStorage.removeItem(e)}catch{}}function Zt(e,t){let n=j(t);if(n==="auto")return e;let o=n==="ask";return e.map(a=>!!a.needsApproval===o?a:{...a,needsApproval:o})}function ke(e){return`heroui-agent:anonymous:${e}`}function dt(e){return e instanceof Error?e:new Error("Auth token request failed")}var Ne=class{constructor(t,n){this.agentId=t;this.getAuthToken=n}cached=null;failure=null;generation=0;pending=null;clear(){this.generation+=1,this.cached=null,this.failure=null,this.pending=null}reset(){this.clear();try{localStorage.removeItem(ke(this.agentId))}catch{}}async get(){if(this.cached&&this.expiresAt(this.cached)>Date.now()+6e4)return this.cached.token;if(!this.pending&&this.failure&&Date.now()<this.failure.retryAt)throw this.failure.error;let t=this.generation,n=this.pending??this.refresh();this.pending||(this.pending=n);try{let o=await n;return t!==this.generation?this.get():(this.cached=o,this.failure=null,o.token)}catch(o){throw t===this.generation&&(this.failure={error:dt(o),retryAt:Date.now()+5e3}),o}finally{this.pending===n&&(this.pending=null)}}async subjectHash(){let t=await this.get(),n=ut(t),o=typeof n.sub=="string"?n.sub:"anonymous",a=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${this.agentId}:${o}`));return Array.from(new Uint8Array(a),b=>b.toString(16).padStart(2,"0")).join("").slice(0,24)}anonymousId(){let t=ke(this.agentId);try{let n=localStorage.getItem(t);if(n)return n;let o=crypto.randomUUID();return localStorage.setItem(t,o),o}catch{return crypto.randomUUID()}}expiresAt(t){return t.expiresAt}async refresh(){let t=await this.getAuthToken({agentId:this.agentId,anonymousId:this.anonymousId()});if(!t||typeof t.token!="string"||!t.token.trim()||typeof t.expiresAt!="number"||!Number.isFinite(t.expiresAt)||t.expiresAt<=0)throw new Error("Auth token callback returned invalid data");return{expiresAt:t.expiresAt,token:t.token}}};function ut(e){try{let t=e.split(".")[1];if(!t)return{};let n=t.replace(/-/g,"+").replace(/_/g,"/"),o=n.padEnd(Math.ceil(n.length/4)*4,"=");return JSON.parse(atob(o))}catch{return{}}}var mt={"application/json":"json","application/pdf":"pdf","image/gif":"gif","image/jpeg":"jpg","image/png":"png","image/webp":"webp","text/csv":"csv","text/markdown":"md","text/plain":"txt","text/tab-separated-values":"tsv"},Z=Object.freeze(Object.keys(mt)),en=Z.join(","),pt=new Set(Z);function Re(e){return pt.has(e.trim().toLowerCase())}import{useId as gt}from"react";import{jsx as Pe,jsxs as ht}from"react/jsx-runtime";function He({children:e,className:t,...n}){let o=`ha-shimmer-${gt().replaceAll(":","")}`,a={"--_ha-firefox-mask":`-moz-element(#${o})`};return ht("span",{...n,className:`ha-shimmer${t?` ${t}`:""}`,children:[Pe("span",{className:"ha-shimmer__text",id:o,children:e}),Pe("span",{inert:!0,"aria-hidden":"true",className:"ha-shimmer__highlight",style:a,children:e})]})}import{useEffect as ft,useLayoutEffect as _e,useRef as At,useState as J}from"react";import{Fragment as Oe,jsx as l,jsxs as M}from"react/jsx-runtime";function mn({agentId:e,composerConnecting:t=!1,composerControlsAvailable:n,composerControlsRevealed:o,composerEndSlot:a,composerFooterSlot:b,composerStartSlot:w,greeting:i,onComposerControlsReveal:c,onIntent:m,placeholder:C,suggestedPrompts:H}){let[f]=J(()=>ie(e)),[y,L]=J(()=>f?.submitted?"":f?.prompt??""),[p,x]=J(()=>f?.submitted?f:null),[_,O]=J(!1),k=At(null),N=n??!!(w||a),v=o??(N&&_),Q=s=>{D(e,!0,s.currentTarget),O(N),N&&c?.(),m()},F=s=>{let g=s.currentTarget.querySelector(".ha-composer");g&&xe(g,s.relatedTarget)||(O(!1),D(e,!1))};_e(()=>{we(e,k.current),se(k.current)},[e]),ft(()=>{p||q(e,{prompt:y,submitted:!1})},[y,e,p]),_e(()=>{if(!p)return;let s=requestAnimationFrame(g=>{Te(e,p.messageId,g)});return()=>cancelAnimationFrame(s)},[e,p]);let S=(s,g=!0)=>{if(p)return;let h=ye(s,{generateConversationTitle:g});h&&(x(h),L(""),k.current.style.height="auto",q(e,h),m())};return M(Oe,{children:[l("div",{className:"ha-conversation",children:l("div",{"aria-live":"polite",className:"ha-messages",role:"log",children:p?M(Oe,{children:[l("div",{className:"ha-message","data-role":"user",children:l("div",{className:"ha-bubble",children:l("div",{className:"ha-message-content",children:l("p",{className:"ha-message-text",children:p.prompt})})})}),l("div",{className:"ha-message","data-role":"assistant","data-stream-anchor":"true","data-turn-feedback-id":p.messageId,children:l("div",{className:"ha-message-body",children:l("div",{"aria-label":"Working on your request\u2026",className:"ha-progress ha-activity-status ha-progress-shimmer",role:"status",children:l(He,{"aria-hidden":"true",children:"Thinking\u2026"})})})})]}):M("div",{className:"ha-empty",children:[l("h2",{children:i}),l("p",{children:"Live answers with charts, metrics, and tables."})]})})}),M("form",{className:"ha-composer-wrap",onBlur:F,onSubmit:s=>{s.preventDefault(),S(y)},children:[!p&&H.length>0?l("div",{"aria-label":"Suggested prompts",className:"ha-suggestions",role:"group",children:H.map(s=>M("button",{className:"ha-suggestion",type:"button",onClick:()=>S(s,!1),children:[l("span",{children:s}),l(yt,{})]},s))}):null,M("div",{className:"@container ha-composer","data-connecting":t||void 0,"data-controls-revealed":v||void 0,children:[w,l("textarea",{ref:k,"aria-label":"Message the assistant",placeholder:C,readOnly:!!p,rows:1,value:y,onFocus:Q,onSelect:s=>D(e,!0,s.currentTarget),onChange:s=>{let g=s.currentTarget.value;q(e,{prompt:g,submitted:!1}),D(e,!0,s.currentTarget),L(g),se(s.currentTarget),m()},onKeyDown:s=>{s.key!=="Enter"||s.shiftKey||(s.preventDefault(),S(y))}}),a,M("button",{"aria-label":"Send message",className:"ha-send",disabled:!y.trim()||!!p,type:"submit",children:[l(bt,{}),l(K,{shortcut:"\u21B5",children:"Send message"})]})]}),l("div",{className:"ha-composer-footer","data-revealed":!!b||void 0,children:l("div",{className:"ha-composer-footer-content",children:b})}),l(Me,{})]})]})}function bt(){return l("svg",{"aria-hidden":"true",fill:"none",height:"18",viewBox:"0 0 18 18",width:"18",children:l("path",{d:"M9 14.5V3.5m0 0L4.5 8M9 3.5 13.5 8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function yt(){return l("svg",{"aria-hidden":"true",fill:"none",height:"16",viewBox:"0 0 16 16",width:"16",children:l("path",{d:"M5 11 11 5m0 0H6m5 0v5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})})}var vt={animation:"fadeIn",duration:160,easing:"ease-out",sep:"word",stagger:18};function Ie(e){return typeof e=="number"?Number.isFinite(e)?`${Math.round(e)}px`:void 0:e?.trim()||void 0}function Tt(e){let t=Ie(e?.initialWidth),n=Ie(e?.initialHeight);return{...t?{"--ha-panel-width":t}:{},...n?{"--ha-panel-height":n}:{}}}function De(e){return e===void 0||!Number.isFinite(e)?24:Math.min(Math.max(Math.round(e),0),200)}function wt(e){if(!(e===void 0||!Number.isFinite(e)))return Math.min(Math.max(Math.round(e),0),2147483647)}function xt(e){if(e===void 0)return[...Z];if(e===!1||!Array.isArray(e))return[];let t=new Set;for(let n of e){if(typeof n!="string")continue;let o=n.trim().toLowerCase();Re(o)&&t.add(o)}return[...t]}function yn(e){if(typeof e.agentId!="string"||!e.agentId.trim())throw new Error("HeroUI Agent agentId is required");if(typeof e.getAuthToken!="function")throw new Error("HeroUI Agent getAuthToken is required");let t=xt(e.composer?.attachments),n=typeof e.composer?.disclaimer=="string"&&e.composer.disclaimer.trim().slice(0,240)||void 0,o=wt(e.appearance?.zIndex);return{apiBaseUrl:(e._api?.baseUrl??pe).replace(/\/$/,""),colorScheme:e.appearance?.theme?.colorScheme??"system",componentExportFormats:e.componentExports===!1?[]:e.componentExports??["csv","svg","png"],composerAttachmentAccept:t.join(","),composerAttachmentContentTypes:t,composerControlsAvailable:t.length>0||e.permissions?.showPicker===!0&&!!e.tools?.length||e.composer?.modelPicker===!0||(e.composer?.dictation??!0),composerDefaultModel:e.composer?.defaultModel,composerDictation:e.composer?.dictation??!0,designTheme:de(e.appearance?.theme?.designTheme),...n?{composerDisclaimer:n}:{},agentId:e.agentId,...e.appearance?.shouldCloseOnInteractOutside!==void 0?{shouldCloseOnInteractOutside:e.appearance.shouldCloseOnInteractOutside}:{},composerModelPicker:e.composer?.modelPicker??!1,composerPlaceholder:e.composer?.placeholder?.trim().slice(0,120)||"Ask anything\u2026",context:e.context,getAuthToken:e.getAuthToken,greeting:e.startScreen?.greeting?.trim().slice(0,120)||"Ask about your data",launcherPosition:e.appearance?.launcher?.position??"bottom-right",markdownAnimation:e.markdown?.animated??vt,markdownCaret:e.markdown?.caret??"block",markdownPlugins:e.markdown?.plugins,messageActions:e.responseActions===!1?[]:e.responseActions??["copy","feedback","retry"],onFeedback:e.onFeedback,panelExpandable:e.appearance?.panel?.expandable??!0,panelExpanded:e.appearance?.panel?.expanded??!1,panelStyle:Tt(e.appearance?.panel),permissionDefaultMode:j(e.permissions?.defaultMode),permissionShowPicker:e.permissions?.showPicker===!0,preload:e.preload??!0,reopenOnRefresh:e.reopenOnRefresh??!1,showBetaBadge:e.showBetaBadge??!1,showLauncher:e.showLauncher??!0,startNewConversationOnOpen:e.startNewConversationOnOpen??!1,suggestedPromptShortcuts:e.startScreen?.promptShortcuts??!1,...e.appearance?.launcher?.icon?.trim()?{launcherIcon:e.appearance.launcher.icon.trim()}:{},...e.appearance?.launcher?.style?{launcherStyle:e.appearance.launcher.style}:{},...e.appearance?.launcher?.offset?{launcherOffset:{x:De(e.appearance.launcher.offset.x),y:De(e.appearance.launcher.offset.y)}}:{},imageSearch:(e.capabilities?.webSearch??!1)&&(e.capabilities?.imageSearch??!0),newsSearch:(e.capabilities?.webSearch??!1)&&(e.capabilities?.newsSearch??!1),suggestedPrompts:e.startScreen?.prompts?.map(a=>a.trim()).filter(Boolean).slice(0,5),themeStyle:{...me(e.appearance?.theme),...ue(e.appearance?.launcher?.background)},tools:e.tools??[],viewMode:e.appearance?.viewMode??"floating",webSearch:e.capabilities?.webSearch??!1,...o!==void 0?{zIndex:o}:{}}}export{Ne as a,St as b,pe as c,Mt as d,K as e,fe as f,Dt as g,mt as h,Z as i,Re as j,ye as k,q as l,ie as m,Bt as n,D as o,we as p,xe as q,Ut as r,rt as s,Wt as t,se as u,Me as v,He as w,mn as x,$t as y,Xt as z,Yt as A,qt as B,jt as C,Zt as D,vt as E,yn as F};
@@ -0,0 +1 @@
1
+ function r(){return function(n){return n}}function t(e){return!!(e&&typeof e=="object"&&typeof e.safeParse=="function")}function s(e,n){return t(e.parameters)?e.parameters.parse(n):n}function i(e,n){let o=e.get(n);return!o||o.needsApproval?null:o}export{r as a,t as b,s as c,i as d};
@@ -0,0 +1 @@
1
+ import{jsx as r}from"react/jsx-runtime";var f=/(\*\*[^*\n]+\*\*|\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_|`[^`\n]+`|\[[^\]\n]+\]\([^\s)\n]+\))/g,h=/^\[([^\]]+)\]\(([^\s)]+)\)$/,l=/^(?:[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?\.)+[a-z]{2,63}(?::\d{1,5})?(?:[/?#][^\s]*)?$/i;function g(n){let t=/^https?:\/\//i.test(n)?n:l.test(n)?`https://${n}`:void 0;if(t)try{let s=new URL(t);return s.protocol==="http:"||s.protocol==="https:"?t:void 0}catch{return}}function k(n){let t=n.split(f);if(t.length===1)return n;let s=new Map;return t.map(e=>{let c=(s.get(e)??0)+1,i=`${e}:${c}`;if(s.set(e,c),e.startsWith("**")&&e.endsWith("**")&&e.length>4)return r("strong",{children:e.slice(2,-2)},i);if(e.startsWith("*")&&e.endsWith("*")&&e.length>2)return r("em",{children:e.slice(1,-1)},i);if(e.startsWith("_")&&e.endsWith("_")&&e.length>2)return r("em",{children:e.slice(1,-1)},i);if(e.startsWith("`")&&e.endsWith("`")&&e.length>2)return r("code",{children:e.slice(1,-1)},i);let o=h.exec(e),d=o?.[2],u=d?g(d):void 0;return o&&u?r("a",{href:u,rel:"noopener noreferrer",target:"_blank",children:o[1]},i):e})}export{k as a};
@@ -0,0 +1 @@
1
+ var t="heroui-agent:runtime-timing",e="heroui_agent_turn_admitted",n="getTurnAdmissionStatuses",r=50;export{t as a,e as b,n as c,r as d};
@@ -0,0 +1,5 @@
1
+ import{c as A}from"./chunk-S6OIAJSC.js";function D(t){return{maximum:t.max??(t.format?.style==="percent"?1:100),minimum:t.min??0}}function gt(t,e){return e.toolCall?{actionId:e.id,args:e.toolCall.arguments,componentId:t,label:e.label,prompt:e.prompt,toolName:e.toolCall.name,type:"tool"}:e.prompt?{componentId:t,label:e.label,prompt:e.prompt,type:"followup"}:null}function dt(t,e){return{componentId:t.id,componentTitle:t.title,datum:e}}var I=new Map;function v(t){try{return Intl.NumberFormat.supportedLocalesOf([t])[0]??"en"}catch{return"en"}}function V(t,e,a="en"){let r=v(a);if(!e)return t.toLocaleString(r);let n={...e.style==="currency"?{currency:e.currency,style:"currency"}:{},...e.style==="percent"?{style:"percent"}:{},...e.style==="percent"&&e.maximumFractionDigits!==void 0?{maximumFractionDigits:e.maximumFractionDigits}:{},...e.style!=="percent"&&e.compact?{notation:"compact"}:{}},i=`${r}:${JSON.stringify(n)}`,o=I.get(i);return o||(o=new Intl.NumberFormat(r,n),I.set(i,o)),o.format(t)}function ft(t,e="en"){let a=v(e),r=Math.abs(t);return r>=1e6?`${(t/1e6).toLocaleString(a,{maximumFractionDigits:1})}M`:r>=1e3?`${(t/1e3).toLocaleString(a,{maximumFractionDigits:1})}K`:t.toLocaleString(a,{maximumFractionDigits:1})}function F(t,e={},a="en"){return new Intl.NumberFormat(v(a),{maximumFractionDigits:e.maximumFractionDigits??2,signDisplay:"always",style:e.style==="percent"?"percent":"decimal"}).format(t)}function L(t,e,a="en"){return typeof t=="number"?V(t,e,a):String(t??"")}import{ChartColumn as Z,Copy as Q,Ellipsis as tt,FileCode as et,FileText as rt,LayoutCells as nt,Picture as at}from"@gravity-ui/icons";import{Button as ot,Dropdown as d,Label as T}from"@heroui/react";import{useCallback as it,useRef as B,useState as U}from"react";function j(t){let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?`${e[0]?.toUpperCase()}${e.slice(1)}`:t}function _(t){let e=[],a=(r,n,i)=>{let o=[...n,r.label],s=r.children?.reduce((c,u)=>c+a(u,o,i+1),0),m=r.children?.length?s??0:r.value??0;return i>0&&e.push({depth:i,id:r.id,label:r.label,path:o.join(" / "),value:m}),m};return a(t,[],0),e}function E(t){let e=[],a=new Set,r=o=>{a.has(o.key)||(a.add(o.key),e.push(o))},n=(o,s)=>r({format:s,key:o,label:j(o)});switch(t.kind){case"line-chart":case"area-chart":case"bar-chart":case"composed-chart":n(t.xKey),t.series.forEach(o=>r({format:o.format,key:o.dataKey,label:o.label}));break;case"candlestick-chart":n(t.xKey),n(t.openKey,t.format),n(t.highKey,t.format),n(t.lowKey,t.format),n(t.closeKey,t.format);break;case"funnel-chart":n(t.labelKey),n(t.valueKey,t.format);break;case"gauge-chart":n("label"),n("value",t.format),n("min",t.format),n("max",t.format);break;case"pie-chart":case"donut-chart":case"radial-chart":n(t.labelKey),n(t.valueKey,t.format);break;case"radar-chart":n(t.angleKey),t.series.forEach(o=>r({format:o.format,key:o.dataKey,label:o.label}));break;case"scatter-chart":t.labelKey&&n(t.labelKey),t.groupKey&&n(t.groupKey),n(t.xKey,t.format),n(t.yKey,t.format),t.sizeKey&&n(t.sizeKey,t.format);break;case"heatmap":n(t.xKey),n(t.yKey),n(t.valueKey,t.format);break;case"sankey-chart":n("source"),n("target"),n("value",t.format);break;case"sunburst-chart":n("id"),n("label"),n("path"),n("depth"),n("value",t.format);break}let i;if(t.kind==="sankey-chart"){let o=new Map(t.nodes.map(s=>[s.id,s.label]));i=t.links.map(s=>({source:o.get(s.source)??s.source,target:o.get(s.target)??s.target,value:s.value}))}else if(t.kind==="gauge-chart"){let{maximum:o,minimum:s}=D(t);i=[{label:t.label,max:o,min:s,value:t.value}]}else t.kind==="sunburst-chart"?i=_(t.data):i=t.data;return{columns:e,description:t.description,id:t.id,kind:"data-table",rows:i,title:t.title,variant:"secondary"}}var z=new Set(["area-chart","bar-chart","candlestick-chart","composed-chart","donut-chart","funnel-chart","gauge-chart","heatmap","line-chart","pie-chart","radar-chart","radial-chart","sankey-chart","scatter-chart","sunburst-chart"]);function G(t){return z.has(t.kind)}function w(t,e){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,80)||"agent-ui"}.${e}`}function k(t,e,a){if(typeof document>"u"||typeof URL.createObjectURL!="function")return;let r=URL.createObjectURL(new Blob([t],{type:e})),n=document.createElement("a");n.download=a,n.href=r,n.click(),URL.revokeObjectURL(r)}function N(t){let e=String(t??"");return/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function S(t){let e,a;if(t.kind==="data-table")e=t.rows,a=t.columns.map(r=>r.key);else if(G(t)){let r=E(t);e=r.rows,a=r.columns.map(n=>n.key)}return!e||!a?.length?null:[a.map(N).join(","),...e.map(r=>a.map(n=>N(r[n])).join(","))].join(`
2
+ `)}function R(t){return t.replace(/[\t\r\n]+/g," ")}function H(t){return[t.columns.map(e=>R(e.label)).join(" "),...t.rows.map(e=>t.columns.map(a=>R(L(e[a.key],a.format))).join(" "))].join(`
3
+ `)}var J=["--accent","--border","--chart-1","--chart-2","--chart-3","--chart-4","--chart-5","--danger","--default-foreground","--focus","--foreground","--muted","--success","--surface","--surface-secondary","--warning"],q=["color","display","dominant-baseline","fill","fill-opacity","font-family","font-size","font-style","font-weight","letter-spacing","opacity","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","vector-effect","visibility"];function $(t){if(!t||t.trim().endsWith("%"))return 0;let e=Number.parseFloat(t);return Number.isFinite(e)&&e>0?e:0}function W(t){let e=t.getAttribute("viewBox")?.trim().split(/[ ,]+/).map(Number);return{height:e?.length===4&&Number.isFinite(e[3])?Math.max(0,e[3]):0,width:e?.length===4&&Number.isFinite(e[2])?Math.max(0,e[2]):0}}function X(t,e){let a=[t,...Array.from(t.querySelectorAll("*"))],r=[e,...Array.from(e.querySelectorAll("*"))];a.forEach((n,i)=>{let o=r[i];if(!o)return;let s=getComputedStyle(n),m=q.flatMap(c=>{let u=s.getPropertyValue(c).trim();return u?[`${c}:${u}`]:[]});m.length!==0&&o.setAttribute("style",[o.getAttribute("style"),...m].filter(Boolean).join(";"))})}function O(t){let e=t.closest('[data-slot="agent-ui-card"]'),a=e?.querySelector('[data-slot="agent-ui-chart"] svg');if(!(e instanceof HTMLElement)||!(a instanceof SVGElement))return null;let r=a.cloneNode(!0),n=a.closest('[data-slot="agent-ui-chart"]')?.getAttribute("aria-label")?.trim(),i=a.getBoundingClientRect(),o=W(a),s=Math.max(1,Math.round(i.width||$(a.getAttribute("width"))||o.width)),m=Math.max(1,Math.round(i.height||$(a.getAttribute("height"))||o.height)),c=getComputedStyle(e),u=J.flatMap(g=>{let f=c.getPropertyValue(g).trim();return f?[`${g}:${f}`]:[]}).join(";");if(X(a,r),r.removeAttribute("aria-hidden"),r.setAttribute("role","img"),n){let g=document.createElementNS("http://www.w3.org/2000/svg","title");g.textContent=n,r.prepend(g),r.setAttribute("aria-label",n)}return r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("height",String(m)),r.setAttribute("width",String(s)),r.hasAttribute("viewBox")||r.setAttribute("viewBox",`0 0 ${s} ${m}`),r.setAttribute("style",[r.getAttribute("style"),u].filter(Boolean).join(";")),{height:m,markup:new XMLSerializer().serializeToString(r),width:s}}async function Y(t,e){let a=O(t);if(!a||typeof Image>"u"||typeof URL.createObjectURL!="function")return;let r=URL.createObjectURL(new Blob([a.markup],{type:"image/svg+xml;charset=utf-8"})),n=new Image;await new Promise((c,u)=>{n.onload=()=>c(),n.onerror=()=>{URL.revokeObjectURL(r),u(new Error("Unable to render component image"))},n.src=r}),URL.revokeObjectURL(r);let i=document.createElement("canvas"),o=Math.max(1,window.devicePixelRatio||1);i.width=a.width*o,i.height=a.height*o;let s=i.getContext("2d");if(!s)return;s.scale(o,o),s.drawImage(n,0,0,a.width,a.height);let m=await new Promise(c=>i.toBlob(c,"image/png"));m&&k(m,"image/png",w(e,"png"))}function K(t,e,a){if(a==="csv"){let r=S(e);r&&k(r,"text/csv;charset=utf-8",w(e.title,"csv"))}else if(a==="svg"){let r=O(t);r&&k(r.markup,"image/svg+xml;charset=utf-8",w(e.title,"svg"))}else Y(t,e.title).catch(()=>{})}async function wt(t,e){let a=e==="json"?JSON.stringify(t,null,2):t.kind==="data-table"?H(t):t.kind==="record-card"?[t.title,t.description,t.status?.label,...t.fields.map(r=>`${r.label}: ${r.value}`)].filter(Boolean).join(`
4
+ `):t.kind==="product-card"?[t.title,t.description,...t.products.flatMap(r=>[[r.name,r.meta].filter(Boolean).join(" \xB7 "),`${r.price.currency??"USD"} ${r.price.amount}`,r.rating?`Rated ${r.rating.value}/5${r.rating.count===void 0?"":` (${r.rating.count})`}`:void 0])].filter(Boolean).join(`
5
+ `):JSON.stringify(t);await navigator.clipboard?.writeText(a)}import{jsx as p,jsxs as h}from"react/jsx-runtime";var M={csv:"Export as CSV",png:"Export as PNG",svg:"Export as SVG"},st={csv:rt,png:at,svg:et};function Ft({component:t,copyAction:e,formats:a=[],onAction:r,viewAction:n}){let i=B(null),[o,s]=U(),[m,c]=U(!1),u=B(0),g=l=>{!l&&Date.now()-u.current<350||c(l)},f=it(l=>{i.current=l,s(A(l))},[]),x=a.filter(l=>l!=="csv"||S(t)),P=e?`Table options for ${t.title}`:n?`${x.length>0?"View and export":"View"} options for ${t.title}`:`Export options for ${t.title}`;return x.length===0&&!n&&!e?null:p("div",{className:"aui-export-actions","data-slot":"agent-ui-export-actions",children:h(d,{isOpen:m,onOpenChange:g,children:[p(ot,{ref:f,isIconOnly:!0,"aria-label":P,size:"sm",variant:"ghost",onPointerDown:()=>{u.current=Date.now()},children:p(tt,{})}),p(d.Popover,{placement:"bottom end",UNSTABLE_portalContainer:o,children:h(d.Menu,{onAction:l=>{if(l==="view"){n?.onAction(),c(!1);return}if(l==="copy"){e?.(),r?.({componentId:t.id,format:"text",type:"copy"}),c(!1);return}let C=l;i.current&&K(i.current,t,C),r?.({componentId:t.id,format:C,type:"export"}),c(!1)},children:[n?h(d.Item,{id:"view",textValue:n.label,children:[n.target==="table"?p(nt,{"aria-hidden":"true",className:"size-4 shrink-0"}):p(Z,{"aria-hidden":"true",className:"size-4 shrink-0"}),p(T,{children:n.label})]}):null,e?h(d.Item,{id:"copy",textValue:"Copy table",children:[p(Q,{"aria-hidden":"true",className:"size-4 shrink-0"}),p(T,{children:"Copy table"})]}):null,x.map(l=>{let C=st[l];return h(d.Item,{id:l,textValue:M[l],children:[p(C,{"aria-hidden":"true",className:"size-4 shrink-0"}),p(T,{children:M[l]})]},l)})]})})]})})}import{jsx as b,jsxs as mt}from"react/jsx-runtime";function lt({direction:t}){return b("svg",{"aria-hidden":"true",className:"aui-change__indicator",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:t==="up"?b("path",{d:"M12 19V5m-5 5 5-5 5 5"}):b("path",{d:"M12 5v14m5-5-5 5-5-5"})})}function ct({slot:t,value:e}){return mt("span",{className:"aui-change","data-slot":t,"data-trend":e>0?"up":e<0?"down":"neutral",children:[e===0?null:b(lt,{direction:e>0?"up":"down"}),F(e),"%"]})}var y=["var(--chart-3, var(--accent))","var(--chart-1, oklch(from var(--accent) calc(l - 0.24) c h))","var(--chart-4, oklch(from var(--accent) calc(l + 0.12) c h))","var(--chart-2, oklch(from var(--accent) calc(l - 0.12) c h))","var(--chart-5, oklch(from var(--accent) calc(l + 0.24) c h))"],ut={accent:"var(--accent)","chart-1":"var(--chart-1, oklch(from var(--accent) calc(l - 0.24) c h))","chart-2":"var(--chart-2, oklch(from var(--accent) calc(l - 0.12) c h))","chart-3":"var(--chart-3, var(--accent))","chart-4":"var(--chart-4, oklch(from var(--accent) calc(l + 0.12) c h))","chart-5":"var(--chart-5, oklch(from var(--accent) calc(l + 0.24) c h))",danger:"var(--danger)",default:"var(--default-foreground, var(--foreground))",success:"var(--success)",warning:"var(--warning)"};function Bt(t,e){return t?ut[t]:y[e%y.length]}function Ut(t){return y[t%y.length]}export{D as a,gt as b,dt as c,V as d,ft as e,L as f,E as g,wt as h,Ft as i,ct as j,ut as k,Bt as l,Ut as m};
@@ -0,0 +1 @@
1
+ import{a as h}from"./chunk-CR3H7AVI.js";import{useCallback as A,useEffect as C,useRef as f}from"react";import{jsx as R}from"react/jsx-runtime";function E({children:e,className:t,offset:r=0,size:i=32,style:l,...d}){let p=f(null),a=f(null),s=f(null),c=A(()=>{let n=p.current;if(!n)return;let u=n.scrollLeft>r,y=n.scrollLeft+n.clientWidth+r<n.scrollWidth,m=u&&y?"both":u?"left":y?"right":"none";a.current!==m&&(a.current=m,s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null,delete n.dataset.leftScroll,delete n.dataset.rightScroll,delete n.dataset.leftRightScroll,m==="both"?n.dataset.leftRightScroll="true":m!=="none"&&(n.dataset[`${m}Scroll`]="true")}))},[r]);return C(()=>{let n=p.current;if(!n)return;c(),n.addEventListener("scroll",c,{passive:!0});let u=typeof ResizeObserver>"u"?null:new ResizeObserver(c);return u?.observe(n),()=>{n.removeEventListener("scroll",c),u?.disconnect(),s.current!==null&&cancelAnimationFrame(s.current),s.current=null,a.current=null}},[c]),R("div",{ref:p,className:h("aui-scroll-shadow",t),"data-slot":"agent-ui-scroll-shadow",style:{"--scroll-shadow-size":`${i}px`,...l},...d,children:e})}import{jsx as H}from"react/jsx-runtime";function J({className:e,size:t="sm",variant:r="secondary",...i}){return H("button",{className:h("aui-button",e),"data-size":t,"data-slot":"agent-ui-action-button","data-variant":r,type:"button",...i})}import{Button as M}from"@heroui/react";import{useEffect as b,useLayoutEffect as x,useRef as w,useState as L}from"react";import v from"dompurify";function S(e){return v.sanitize(e,{RETURN_DOM_FRAGMENT:!0,USE_PROFILES:{html:!0}})}function ee(e){return v.sanitize(e,{RETURN_DOM_FRAGMENT:!0,USE_PROFILES:{html:!0,svg:!0,svgFilters:!0}})}import{jsx as o,jsxs as g}from"react/jsx-runtime";var N=2e3,k="github-dark",z="github-light",T={bash:()=>import("shiki/langs/bash.mjs"),css:()=>import("shiki/langs/css.mjs"),html:()=>import("shiki/langs/html.mjs"),javascript:()=>import("shiki/langs/javascript.mjs"),json:()=>import("shiki/langs/json.mjs"),jsx:()=>import("shiki/langs/jsx.mjs"),markdown:()=>import("shiki/langs/markdown.mjs"),python:()=>import("shiki/langs/python.mjs"),shellscript:()=>import("shiki/langs/shellscript.mjs"),sql:()=>import("shiki/langs/sql.mjs"),tsx:()=>import("shiki/langs/tsx.mjs"),typescript:()=>import("shiki/langs/typescript.mjs")},_=new Map;function P(e){let t={js:"javascript",md:"markdown",py:"python",sh:"shellscript",shell:"shellscript",ts:"typescript"},r=e.toLowerCase();return r in T?r:t[r]??null}async function B(e){let[{createHighlighterCore:t},{createJavaScriptRegexEngine:r},i,l,d]=await Promise.all([import("shiki/core"),import("shiki/engine/javascript"),import("shiki/themes/github-light.mjs"),import("shiki/themes/github-dark.mjs"),T[e]()]);return t({engine:r(),langs:[d.default],themes:[i.default,l.default]})}async function F(e,t){let r=P(t);if(!r)return null;let i=_.get(r),l=i??B(r);return i||_.set(r,l),(await l).codeToHtml(e,{defaultColor:!1,lang:r,themes:{dark:k,light:z}})}async function D(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();try{return document.execCommand?.("copy")??!1}catch{return!1}finally{t.remove()}}}function O({html:e}){let t=w(null);return x(()=>{let r=t.current;if(r)return r.replaceChildren(S(e)),()=>r.replaceChildren()},[e]),o("div",{ref:t,className:"aui-code__content","data-slot":"agent-ui-code"})}function V(){return o("svg",{"aria-hidden":"true",fill:"none",viewBox:"0 0 16 16",children:o("path",{clipRule:"evenodd",d:"M10.218 3.216a.75.75 0 0 0-1.436-.431l-3 10a.75.75 0 0 0 1.436.43zM4.53 4.97a.75.75 0 0 1 0 1.06L2.56 8l1.97 1.97a.75.75 0 0 1-1.06 1.06l-2.5-2.5a.75.75 0 0 1 0-1.06l2.5-2.5a.75.75 0 0 1 1.06 0m6.94 6.06a.75.75 0 0 1 0-1.06L13.44 8l-1.97-1.97a.75.75 0 0 1 1.06-1.06l2.5 2.5a.75.75 0 0 1 0 1.06l-2.5 2.5a.75.75 0 0 1-1.06 0",fill:"currentColor",fillRule:"evenodd"})})}function U(){return o("svg",{"aria-hidden":"true",fill:"none",viewBox:"0 0 16 16",children:o("path",{clipRule:"evenodd",d:"M12 2.5H8A1.5 1.5 0 0 0 6.5 4v1H8a3 3 0 0 1 3 3v1.5h1A1.5 1.5 0 0 0 13.5 8V4A1.5 1.5 0 0 0 12 2.5M11 11h1a3 3 0 0 0 3-3V4a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v1H4a3 3 0 0 0-3 3v4a3 3 0 0 0 3 3h4a3 3 0 0 0 3-3zM4 6.5h4A1.5 1.5 0 0 1 9.5 8v4A1.5 1.5 0 0 1 8 13.5H4A1.5 1.5 0 0 1 2.5 12V8A1.5 1.5 0 0 1 4 6.5",fill:"currentColor",fillRule:"evenodd"})})}function G(){return o("svg",{"aria-hidden":"true",fill:"none",viewBox:"0 0 16 16",children:o("path",{clipRule:"evenodd",d:"M13.488 3.43a.75.75 0 0 1 .081 1.058l-6 7a.75.75 0 0 1-1.1.042l-3.5-3.5A.75.75 0 0 1 4.03 6.97l2.928 2.927 5.473-6.385a.75.75 0 0 1 1.057-.081",fill:"currentColor",fillRule:"evenodd"})})}function ie({code:e,language:t="text"}){let r=`${t}:${e}`,[i,l]=L(null),[d,p]=L(!1),a=w(null);b(()=>{let c=!1;async function n(){try{let u=await F(e,t);c||l(u?{html:u,key:r}:null)}catch{c||l(null)}}return n(),()=>{c=!0}},[e,r,t]),b(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);let s=async()=>{await D(e)&&(p(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{p(!1),a.current=null},N))};return g("div",{className:"aui-code","data-slot":"agent-ui-code-block",children:[g("header",{className:"aui-code__header","data-slot":"agent-ui-code-header",children:[g("span",{className:"aui-code__language",children:[o(V,{}),o("span",{children:t.toUpperCase()})]}),o(M,{isIconOnly:!0,"aria-label":d?"Code copied":"Copy code",className:"aui-code__copy","data-slot":"agent-ui-code-copy",size:"sm",variant:"ghost",onPress:s,children:g("span",{className:"aui-code__copy-swap","data-copied":d||void 0,"data-slot":"agent-ui-code-copy-icon",children:[o("span",{className:"aui-code__copy-icon aui-code__copy-icon--copy",children:o(U,{})}),o("span",{className:"aui-code__copy-icon aui-code__copy-icon--check",children:o(G,{})})]})})]}),i?.key===r?o(O,{html:i.html}):o("div",{className:"aui-code__content","data-slot":"agent-ui-code",children:o("pre",{children:o("code",{children:e})})})]})}export{J as a,E as b,ee as c,ie as d};
@@ -0,0 +1 @@
1
+ function s(...e){return e.filter(Boolean).join(" ")||void 0}export{s as a};
@@ -0,0 +1 @@
1
+ var I=85.051129,p=256,m=3,C=2;function _(t,n,o){let e=t.find(i=>i.id===n);return e?{latitude:e.latitude,longitude:e.longitude}:o}function x(t,n,o){return Math.min(Math.max(t,n),o)}function M({latitude:t,longitude:n},o){let e=p*2**o,r=x(t,-I,I)*Math.PI/180,c=Math.sin(r);return{x:(n+180)/360*e,y:(.5-Math.log((1+c)/(1-c))/(4*Math.PI))*e}}function L(t,n){return t>n/2?t-n:t<-n/2?t+n:t}function T(t){if(t.length===1)return t[0].longitude;let n=t.map(r=>(r.longitude+360)%360).sort((r,c)=>r-c),o=-1,e=n[0];for(let r=0;r<n.length;r+=1){let c=n[r],s=r===n.length-1?n[0]+360:n[r+1],l=s-c;l>o&&(o=l,e=s%360)}let i=(e+(360-o)/2)%360;return i>180?i-360:i}function v(t,n){if(n)return n;let o=t[0].latitude,e=t[0].latitude;for(let i of t.slice(1))o=Math.min(o,i.latitude),e=Math.max(e,i.latitude);return{latitude:(o+e)/2,longitude:T(t)}}function X(t,n,o,e){if(o!==void 0)return x(o,1,e);if(t.length===1)return Math.min(14,e);for(let i=Math.min(16,e);i>=2;i-=1){let r=M(n,i),c=p*2**i,s=M(t[0],i),l=L(s.x-r.x,c),a=s.y-r.y,u=l,d=l,f=a,y=a;for(let P of t.slice(1)){let h=M(P,i),b=L(h.x-r.x,c),g=h.y-r.y;u=Math.min(u,b),d=Math.max(d,b),f=Math.min(f,g),y=Math.max(y,g)}if(d-u<=420&&y-f<=190)return i}return Math.min(2,e)}function E(t,n=18){n=Number.isFinite(n)?x(Math.floor(n),1,18):18;let o=v(t.locations,t.viewport?.center),e=X(t.locations,o,t.viewport?.zoom,n),i=M(o,e),r=Math.floor(i.x/p),c=Math.floor(i.y/p),s=2**e,l=[];for(let a=c-C;a<=c+C;a+=1)if(!(a<0||a>=s))for(let u=r-m;u<=r+m;u+=1){let d=(u%s+s)%s;l.push({key:`${e}-${u}-${a}`,x:u*p-i.x,xIndex:d,y:a*p-i.y,yIndex:a,zoom:e})}return{center:o,points:t.locations.map(a=>{let u=M(a,e),d=p*2**e;return{id:a.id,x:L(u.x-i.x,d),y:u.y-i.y}}),tiles:l,zoom:e}}function Y(t){if(t.initialLocationId&&t.locations.some(o=>o.id===t.initialLocationId))return t.initialLocationId;let n=t.locations[0];for(let o of t.locations.slice(1))(o.relevance??-1)>(n.relevance??-1)&&(n=o);return n.id}export{_ as a,E as b,Y as c};
@@ -0,0 +1 @@
1
+ function a(t,e=Date.now()){if(typeof window>"u")return"";try{let o=window.localStorage.getItem(t);if(!o)return"";let r=JSON.parse(o);return!(typeof r.savedAt=="number"&&e-r.savedAt<=6048e5)||typeof r.prompt!="string"||!r.prompt.trim()?(window.localStorage.removeItem(t),""):r.prompt}catch{try{window.localStorage.removeItem(t)}catch{}return""}}function i(t,e,o=Date.now()){if(!(typeof window>"u"))try{if(!e.trim()){window.localStorage.removeItem(t);return}window.localStorage.setItem(t,JSON.stringify({prompt:e,savedAt:o}))}catch{}}export{a,i as b};
@@ -0,0 +1 @@
1
+ var a=":composer-draft:";function i(t,r){return`${t}${a}${r}:v1`}async function m(t,r=Date.now()){try{return await(await import("./composer-image-draft-KAGTNQR7.js")).readAgentComposerImageDraft(t,r)}catch{return[]}}async function g(t,r,e=Date.now()){try{await(await import("./composer-image-draft-KAGTNQR7.js")).saveAgentComposerImageDraft(t,r,e)}catch{}}async function f(t){try{localStorage.removeItem(t)}catch{}try{await(await import("./composer-image-draft-KAGTNQR7.js")).clearAgentComposerImageDraft(t)}catch{}}async function p(t){let r=`heroui-agent:conversation:${t}:`;try{for(let e=localStorage.length-1;e>=0;e-=1){let o=localStorage.key(e);o?.startsWith(r)&&o.includes(a)&&localStorage.removeItem(o)}}catch{}try{await(await import("./composer-image-draft-KAGTNQR7.js")).clearAgentComposerImageDraftsForProject(r)}catch{}}export{i as a,m as b,g as c,f as d,p as e};
@@ -0,0 +1 @@
1
+ import{a as c}from"./chunk-CR3H7AVI.js";import{createContext as N,useContext as g}from"react";import{jsx as e,jsxs as i}from"react/jsx-runtime";var u=N(void 0);function v({children:a,variant:t}){return e(u,{value:t,children:a})}function h({actions:a,children:t,className:r,"data-component-kind":p,description:n,footer:o,legend:l,title:d,variant:m}){let C=g(u),s=d!=null||n!=null||l!=null||a!=null,f=C??m??"surface";return i("section",{className:c("aui-card",r),"data-component-kind":p,"data-has-footer":o!=null,"data-has-header":s,"data-slot":"agent-ui-card","data-variant":f,children:[s?i("header",{className:"aui-card__header","data-has-actions":a!=null,"data-slot":"agent-ui-card-header",children:[i("span",{className:"aui-card__heading","data-slot":"agent-ui-card-heading",children:[d!=null?e("span",{className:"aui-card__title","data-slot":"agent-ui-card-title",children:d}):null,n!=null?e("span",{className:"aui-card__description","data-slot":"agent-ui-card-description",children:n}):null]}),a!=null?e("span",{className:"aui-card__actions","data-slot":"agent-ui-card-actions",children:a}):null,l]}):null,e("div",{className:"aui-card__content","data-slot":"agent-ui-card-content",children:t}),o!=null?e("footer",{className:"aui-card__footer","data-slot":"agent-ui-card-footer",children:o}):null]})}function k(a){if(!a)return;let t=a.closest("[data-agent-overlay-root], dialog");if(t)return t.querySelector("[data-agent-overlay-portal]")??t;let r=a.getRootNode();return typeof ShadowRoot<"u"&&r instanceof ShadowRoot?r:void 0}export{v as a,h as b,k as c};
@@ -0,0 +1 @@
1
+ var n=["moonshotai/Kimi-K3","openai/gpt-5.6-luna","openai/gpt-5.6-terra","openai/gpt-5.6-sol","google/gemini-3.7-flash","anthropic/claude-sonnet-5","anthropic/claude-opus-4.8"],t={"google/gemini-3.5-flash":"google/gemini-3.7-flash","google/gemini-3.6-flash":"google/gemini-3.7-flash"};function r(e){return t[e]??e}var a="google/gemini-3.7-flash",l=[{description:"Flagship model for coding, reasoning, and knowledge work",id:"moonshotai/Kimi-K3",label:"Kimi K3",provider:"Moonshot AI",tier:"light"},{description:"Fast answers and lightweight agent workflows",id:"openai/gpt-5.6-luna",label:"GPT-5.6 Luna",provider:"OpenAI",tier:"light"},{description:"Balanced reasoning for everyday agent tasks",id:"openai/gpt-5.6-terra",label:"GPT-5.6 Terra",provider:"OpenAI",tier:"codegen"},{description:"Deep reasoning for complex, multi-step analysis",id:"openai/gpt-5.6-sol",label:"GPT-5.6 Sol",provider:"OpenAI",tier:"complex"},{description:"Fast multimodal analysis with a large context window",id:"google/gemini-3.7-flash",label:"Gemini 3.7 Flash",provider:"Google",tier:"light"},{description:"Strong agentic reasoning and polished UI decisions",id:"anthropic/claude-sonnet-5",label:"Claude Sonnet 5",provider:"Anthropic",tier:"codegen"},{description:"Highest-capability Claude for difficult research and analysis",id:"anthropic/claude-opus-4.8",label:"Claude Opus 4.8",provider:"Anthropic",tier:"complex"}],s=new Set(n);function g(e){return typeof e=="string"&&s.has(e)}function d(e){let o=e?r(e):void 0;return l.find(i=>i.id===o)?.tier??"light"}export{n as a,t as b,r as c,a as d,l as e,g as f,d as g};
@@ -0,0 +1,2 @@
1
+ import{F as rn,a as ze,c as qe,d as je,f as fe,g as Ke,j as Je,k as Ze,l as en,o as me,q as nn,r as tn,x as on}from"./chunk-5RHO3S5E.js";import{a as Xe}from"./chunk-6ZJJN322.js";import{d as Ye,e as Qe}from"./chunk-UHHKMESI.js";import{useCallback as b,useEffect as C,useEffectEvent as yt,useLayoutEffect as kn,useMemo as Ce,useRef as E,useState as p,useSyncExternalStore as Tn}from"react";import{createRoot as wt}from"react-dom/client";import{SparklesFill as Jn}from"@gravity-ui/icons";import{jsx as Xn}from"react/jsx-runtime";function sn(e){return Xn(Jn,{...e})}import{jsx as pe}from"react/jsx-runtime";function Yn(e){return/\.svg(?:[?#]|$)/i.test(e)||/^data:image\/svg\+xml[;,]/i.test(e)}function an(e){return`url("${e.replace(/["\\\n\r]/g,encodeURIComponent)}")`}function cn({icon:e}){return e?Yn(e)?pe("span",{"aria-hidden":"true",className:"ha-launcher__icon ha-launcher__icon--tinted",style:{WebkitMaskImage:an(e),maskImage:an(e)}}):pe("img",{alt:"",className:"ha-launcher__icon",src:e}):pe(sn,{})}function ln(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function un(e,n){if(n===void 0)return e;if(!ln(e)||!ln(n))return n;let t={...e};for(let[r,a]of Object.entries(n))a!==void 0&&(t[r]=r in e?un(e[r],a):a);return t}function dn(e,n){if(!e)return n;let t={appearance:e.appearance,capabilities:e.capabilities,composer:e.composer,markdown:e.markdown,permissions:e.permissions,responseActions:e.responseActions,showBetaBadge:e.showBetaBadge,startScreen:e.startScreen},r=un(t,{appearance:n.appearance,capabilities:n.capabilities,composer:n.composer,markdown:n.markdown?{...n.markdown,plugins:void 0}:void 0,permissions:n.permissions,responseActions:n.responseActions,showBetaBadge:n.showBetaBadge,startScreen:n.startScreen});return{...n,...r}}function fn(e){return!!e.appearance?.theme?.typography?.fontFamily?.trim()}var mn=1,c=Symbol("invalid");function G(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function k(e){if(e!==void 0)return typeof e=="string"?e:c}function S(e){if(e!==void 0)return typeof e=="boolean"?e:c}function ge(e){if(e!==void 0)return typeof e=="number"&&Number.isFinite(e)?e:c}function M(e){return n=>{if(n!==void 0)return typeof n=="string"&&e.includes(n)?n:c}}function pn(e){if(e===void 0)return;if(typeof e=="string")return e;if(!G(e))return c;let n=k(e.dark),t=k(e.light);return n===c||t===c?c:{...n===void 0?{}:{dark:n},...t===void 0?{}:{light:t}}}function Qn(e){if(e===void 0)return;if(!G(e))return c;let n={};for(let[t,r]of Object.entries(e)){if(typeof r!="string")return c;n[t]=r}return n}function Zn(e){if(e!==void 0)return!Array.isArray(e)||e.some(n=>typeof n!="string")?c:e}function w(e,n){if(e===void 0||!G(e))return c;let t={};for(let[r,a]of Object.entries(n)){let l=a(e[r]);if(l===c)return c;l!==void 0&&(t[r]=l)}return t}function v(e){return e===c?void 0:e}var et=["accent","background","foreground","overlay","surface","surfaceSecondary","tooltip"];function nt(e){return w(e,{launcher:n=>n===void 0?void 0:w(n,{background:pn,icon:k,position:M(["bottom-left","bottom-right"]),style:Qn}),panel:n=>n===void 0?void 0:w(n,{expandable:S,expanded:S,initialHeight:t=>t===void 0||typeof t=="string"?t:ge(t),initialWidth:t=>t===void 0||typeof t=="string"?t:ge(t)}),theme:n=>n===void 0?void 0:w(n,{colorScheme:M(["dark","light","system"]),colors:t=>t===void 0?void 0:w(t,Object.fromEntries(et.map(r=>[r,pn]))),designTheme:M(["base","brutalism","glass","mouve"]),radius:M(["pill","round","sharp","soft"]),typography:t=>t===void 0?void 0:w(t,{baseSize:ge,fontFamily:k})}),viewMode:M(["floating","sidebar"])})}function tt(e){return w(e,{attachments:n=>{if(n===void 0||n===!1)return n;if(!Array.isArray(n))return c;let t=n.filter(r=>typeof r=="string"&&Je(r));return t.length===n.length?t:c},defaultModel:k,dictation:S,disclaimer:n=>n===!1?!1:k(n),modelPicker:S,placeholder:k})}function ot(e){return w(e,{animated:n=>{if(n===void 0||n===!1)return n;if(!G(n))return c;let t=M(["blurIn","fadeIn","slideUp"])(n.animation);return t===c||t===void 0?c:{...n,animation:t}},caret:n=>n===!1?!1:M(["block","circle"])(n)})}function rt(e){if(e===void 0||e===!1)return e;if(!Array.isArray(e))return c;let n=["copy","feedback","retry"],t=e.filter(r=>typeof r=="string"&&n.includes(r));return t.length===e.length?t:c}function Z(e){if(!G(e)||e.version!==mn)return null;let n=e.revision;if(typeof n!="string"||!n)return null;let t=v(nt(e.appearance)),r=v(w(e.capabilities,{imageSearch:S,newsSearch:S,webSearch:S})),a=v(tt(e.composer)),l=v(ot(e.markdown)),f=v(w(e.permissions,{defaultMode:M(["ask","auto","full"]),showPicker:S})),u=v(rt(e.responseActions)),m=v(S(e.showBetaBadge)),I=v(w(e.startScreen,{greeting:k,promptShortcuts:S,prompts:Zn})),h=v(w(e.webfont,{familyName:N=>typeof N=="string"&&N?N:c,fontFaceUrl:k,stylesheetUrl:k}));return{...t?{appearance:t}:{},...r?{capabilities:r}:{},...a?{composer:a}:{},...l?{markdown:l}:{},...f?{permissions:f}:{},...u===void 0?{}:{responseActions:u},...m===void 0?{}:{showBetaBadge:m},...I?{startScreen:I}:{},...h?{webfont:h}:{},revision:n,version:mn}}function he(e){return`heroui-agent:config:${e}`}var gn=1;function hn(e){try{let n=window.localStorage.getItem(he(e));if(!n)return null;let t=JSON.parse(n);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let a=t;if(a.cacheVersion===gn&&typeof a.cachedAt=="number"&&Number.isFinite(a.cachedAt)){let l=Z(a.config);return l?{cachedAt:a.cachedAt,config:l,legacy:!1}:null}}let r=Z(t);return r?{cachedAt:0,config:r,legacy:!0}:null}catch{return null}}function ye(e,n,t=Date.now()){try{let r={cacheVersion:gn,cachedAt:t,config:n};window.localStorage.setItem(he(e),JSON.stringify(r))}catch{}}function yn(e){try{window.localStorage.removeItem(he(e))}catch{}}async function wn(e,n,t={}){try{let r=await fetch(`${e}/v1/agents/${encodeURIComponent(n)}/appearance`,{headers:t.revision?{"If-None-Match":`"${t.revision}"`}:{},...t.signal?{signal:t.signal}:{}});if(r.status===304)return{status:"not-modified"};if(r.status===404||r.status===410)return{status:"missing"};if(!r.ok)return{status:"unavailable"};let a=Z(await r.json());return a?{config:a,status:"ok"}:{status:"unavailable"}}catch{return{status:"unavailable"}}}import{ChevronDown as st,Microphone as it,Plus as at,ShieldCheck as ct}from"@gravity-ui/icons";import{useEffect as lt,useRef as ut}from"react";import{Fragment as Rn,jsx as g,jsxs as we}from"react/jsx-runtime";var dt={ask:"Ask for approval",auto:"Approve for me",full:"Full access"};function Cn({onFileDialogActiveChange:e,onIntent:n,options:t}){return{end:g(mt,{options:t}),footer:t.composerDisclaimer?g("p",{className:"ha-footnote",children:Xe(t.composerDisclaimer)}):null,start:t.composerAttachmentContentTypes.length>0?g(ft,{accept:t.composerAttachmentAccept,agentId:t.agentId,onFileDialogActiveChange:e,onIntent:n}):null}}function ft({accept:e,agentId:n,onFileDialogActiveChange:t,onIntent:r}){let a=ut(null);return lt(()=>{let l=a.current,f,u=()=>t(!1),m=()=>{f=window.setTimeout(u,0)};return l?.addEventListener("cancel",u),window.addEventListener("focus",m),()=>{l?.removeEventListener("cancel",u),window.removeEventListener("focus",m),window.clearTimeout(f)}},[t]),we(Rn,{children:[g("input",{ref:a,multiple:!0,accept:e,"aria-label":"Choose files to attach",className:"ha-file-input",type:"file",onChange:l=>{tn(n,Array.from(l.currentTarget.files??[])),l.currentTarget.value="",t(!1),r()}}),g("button",{"aria-label":"Attach files",className:"ha-attach",type:"button",onClick:()=>{t(!0),a.current?.click()},children:g(at,{"aria-hidden":"true"})})]})}function mt({options:e}){let n=e.composerDefaultModel??Ye,t=Qe.find(r=>r.id===n)?.label??n;return we(Rn,{children:[e.permissionShowPicker&&e.tools.length>0?g(bn,{icon:g(ct,{"aria-hidden":"true",className:"aui-permission-picker__trigger-icon"}),kind:"permission",label:dt[e.permissionDefaultMode],tone:e.permissionDefaultMode==="full"?"warning":void 0}):null,e.composerModelPicker?g(bn,{kind:"model",label:t}):null,e.composerDictation?g("button",{disabled:!0,"aria-label":"Dictate message",className:"ha-dictation",type:"button",children:g(it,{"aria-hidden":"true"})}):null]})}function bn({icon:e,kind:n,label:t,tone:r}){let a=`aui-${n}-picker`;return g("div",{className:`${a} ha-${n}-picker`,"data-tone":r,children:we("button",{disabled:!0,"aria-label":n==="model"?"AI model":"Tool permissions",className:`${a}__trigger ha-shell-picker-trigger`,type:"button",children:[e,g("span",{className:`${a}__value`,children:t}),g(st,{"aria-hidden":"true",className:`${a}__indicator`})]})})}var pt=[".woff2",".woff",".ttf",".otf",".eot"];function gt(e){return`heroui-agent-font-${e.familyName.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`}function ht(e){let n=e.includes(":vf@")||e.includes("-wght-")||e.includes("-opsz-");return e.endsWith(".woff")?"woff":e.endsWith(".ttf")?"truetype":e.endsWith(".otf")?"opentype":n?"woff2-variations":"woff2"}function An(e,n){try{let t=new URL(e);if(t.protocol!=="https:")return!1;if(!n)return!0;let r=t.pathname.toLowerCase();return pt.some(a=>r.endsWith(a))}catch{return!1}}function Sn(e){if(!e||typeof document>"u")return()=>{};let n=gt(e);if(document.getElementById(n))return()=>{};if(e.stylesheetUrl&&An(e.stylesheetUrl,!1)){let t=document.createElement("link");return t.id=n,t.rel="stylesheet",t.href=e.stylesheetUrl,document.head.append(t),()=>t.remove()}if(e.fontFaceUrl&&An(e.fontFaceUrl,!0)){let t=document.createElement("style"),r=e.fontFaceUrl.includes(":vf@")||e.fontFaceUrl.includes("-wght-")||e.fontFaceUrl.includes("-opsz-");return t.id=n,t.textContent=["@font-face {",` font-family: '${e.familyName.replaceAll("'","")}';`," font-style: normal;"," font-display: swap;",` font-weight: ${r?"100 900":"400"};`,` src: url(${e.fontFaceUrl}) format('${ht(e.fontFaceUrl)}');`,"}"].join(`
2
+ `),document.head.append(t),()=>t.remove()}return()=>{}}import{Fragment as On,jsx as P,jsxs as Nn}from"react/jsx-runtime";var bt=600,Ct=5*6e4,Rt="heroui-agent:open:";function Re(e){return`${Rt}${e}`}function At(e){if(typeof window>"u")return!1;try{return window.sessionStorage.getItem(Re(e))==="true"}catch{return!1}}function be(e,n){try{n?window.sessionStorage.setItem(Re(e),"true"):window.sessionStorage.removeItem(Re(e))}catch{}}var In;function vn(){return In??=import(/* webpackPrefetch: true */"./embed-runtime-FP77ORXA.js").then(e=>e.default),In}var D=new Map,Ae=new Set;function Mn(e){return e?D.get(e):[...D.values()][D.size-1]}function En(){for(let e of Ae)e()}function St(e){return Ae.add(e),()=>Ae.delete(e)}function kt(e){let n=window.matchMedia?.("(prefers-color-scheme: dark)");return n?.addEventListener?.("change",e),()=>n?.removeEventListener?.("change",e)}function It(){return window.matchMedia?.("(prefers-color-scheme: dark)").matches===!0}function L(e,n,...t){let r=Mn(e);if(!r){console.warn("HeroUI Agent is not mounted yet. Add <HeroUIAgent /> to your layout.");return}let a=r[n];a(...t)}function vt(e,n,t){let[r]=p(()=>!t||typeof window>"u"?null:hn(e)),[a,l]=p(()=>{if(!t)return{config:null,presentationReady:!0};let f=r?Date.now()-r.cachedAt:Number.POSITIVE_INFINITY,u=r!==null&&!r.legacy&&f>=0&&f<=Ct;return{config:u?r.config:null,presentationReady:u}});return C(()=>{if(!t)return;let f=new AbortController,u=!0,m=h=>{l(N=>N.presentationReady?N:{config:h,presentationReady:!0})},I=window.setTimeout(()=>{u&&(f.abort(),m(r?.config??null))},bt);return wn(n,e,{...r?.config.revision?{revision:r.config.revision}:{},signal:f.signal}).then(h=>{if(!(!u||f.signal.aborted)){if(h.status==="ok"){ye(e,h.config),m(h.config);return}if(h.status==="not-modified"){r&&ye(e,r.config),m(r?.config??null);return}if(h.status==="missing"){yn(e),m(null);return}m(r?.config??null)}}).finally(()=>{!u||f.signal.aborted||window.clearTimeout(I)}),()=>{u=!1,f.abort(),window.clearTimeout(I)}},[n,r,t,e]),t?a:{config:null,presentationReady:!0}}function co(e){let n=b(()=>Mn(e)?.ready??!1,[e]),t=Tn(St,n,()=>!1);return Ce(()=>({hide:()=>L(e,"hide"),newConversation:r=>L(e,"newConversation",r),preload:()=>L(e,"preload"),ready:t,refreshAuth:()=>L(e,"refreshAuth"),show:()=>L(e,"show"),shutdown:()=>L(e,"shutdown"),toggle:()=>L(e,"toggle")}),[e,t])}function lo(e){let n=`${e.agentId}\0${e._api?.baseUrl??""}\0${e.remoteConfig!==!1}`;return P(Et,{...e},n)}function Et(e){let{_api:n,agentId:t,appearance:r,capabilities:a,componentExports:l,composer:f,context:u,getAuthToken:m,markdown:I,onFeedback:h,onReady:N,permissions:Pn,preload:_n,remoteConfig:xn=!0,reopenOnRefresh:Se,responseActions:Un,showLauncher:Ln,startNewConversationOnOpen:Fn,startScreen:$n,tools:ke}=e,z=I?.plugins,ee=r?.shouldCloseOnInteractOutside,Hn=(n?.baseUrl??qe).replace(/\/$/,""),{config:Ie,presentationReady:F}=vt(t,Hn,xn),ve=JSON.stringify({_api:n,appearance:r?{...r,shouldCloseOnInteractOutside:void 0}:void 0,capabilities:a,componentExports:l,composer:f,markdown:I?{...I,plugins:void 0}:void 0,permissions:Pn,preload:_n,remote:Ie,reopenOnRefresh:Se,responseActions:Un,showLauncher:Ln,startNewConversationOnOpen:Fn,startScreen:$n}),o=Ce(()=>{let{remote:s,...i}=JSON.parse(ve),d=dn(s,{...i,agentId:t,getAuthToken:m,...ee!==void 0?{appearance:{...i.appearance,shouldCloseOnInteractOutside:ee}}:{}});return rn({...d,context:u,markdown:d.markdown?{...d.markdown,plugins:z}:z?{plugins:z}:void 0,onFeedback:h,tools:ke})},[u,m,z,h,t,ve,ee,ke]),q=Ce(()=>new ze(t,m),[t,m]),Ee=fn(e),Ne=Ie?.webfont;C(()=>{if(!Ee)return Sn(Ne)},[Ee,Ne]);let[j]=p(()=>Se===!0&&At(t)),[ne,V]=p(j),[_,Bn]=p(1),[Oe,Te]=p(1),[Me,Pe]=p(!1),[K,Dn]=p(j||o.startNewConversationOnOpen?null:void 0),[O,Vn]=p(null),[J,Wn]=p(null),[_e,Gn]=p(!1),[te,oe]=p(!1),[zn,xe]=p(null),re=E(1),Ue=E(null),se=E(!1),ie=E(null),Le=E(null),$=E(j),ae=E(null),X=E(null),ce=E([]),qn=Tn(kt,It,()=>!1),le=o.designTheme==="base"?null:`${o.designTheme}-${o.colorScheme==="system"?qn?"dark":"light":o.colorScheme}`,x=F&&zn===_&&J!==null,y=F&&ne,[Y,jn]=p(j||o.preload),R=b(()=>jn(!0),[]),[W,H]=p(!1),[Fe,$e]=p(!1),ue=b(()=>H(!0),[]);C(()=>{if(!W||!O)return;let s=()=>{queueMicrotask(()=>{let i=O.querySelector(".ha-composer:not([hidden] *)");i&&nn(i,document.activeElement)||H(!1)})};return O.addEventListener("focusout",s),()=>O.removeEventListener("focusout",s)},[W,O]),C(()=>{Y&&q.get().catch(()=>{})},[Y,q]),C(()=>{o.reopenOnRefresh?be(o.agentId,ne):be(o.agentId,!1)},[ne,o.agentId,o.reopenOnRefresh]),C(()=>{if(!Y)return;if(!F){vn().catch(()=>{});return}let s=!0;return vn().then(i=>{s&&Wn(()=>i)}).catch(()=>{}),()=>{s=!1}},[F,Y]),C(()=>{if(!y||o.viewMode!=="sidebar"||window.innerWidth<640)return;let s=document.documentElement,i=s.style.marginRight,d=s.style.transition,A=window.matchMedia("(prefers-reduced-motion: reduce)").matches,de=Math.min(fe(o.agentId,window.innerWidth),window.innerWidth);return A||(s.style.transition=[d,"margin-right .28s cubic-bezier(.2,.8,.2,1)"].filter(Boolean).join(", ")),s.style.marginRight=`${de}px`,()=>{s.style.marginRight=i,window.setTimeout(()=>{s.style.transition=d},300)}},[y,o.agentId,o.viewMode]),C(()=>{let s=document.createElement("div"),i=document.createElement("div");s.dataset.herouiAgent=o.agentId,i.className="ha-root",ae.current=s,ie.current=i,X.current=wt(i),s.append(i),document.body.append(s);let d=!0;return queueMicrotask(()=>{d&&Vn(i)}),()=>{d=!1,me(o.agentId,!1);let A=X.current;ie.current=null,ae.current=null,X.current=null,ce.current=[],queueMicrotask(()=>{A?.unmount(),s.remove()})}},[o.agentId]),kn(()=>{let s=ie.current,i=ae.current;if(!s||!i)return;s.className=le?`ha-root ${le}`:"ha-root",s.dataset.theme=o.colorScheme,s.dataset.viewMode=o.viewMode,s.dataset.position=o.launcherPosition,i.dataset.open=y?"true":"false",i.dataset.viewMode=o.viewMode,i.dataset.position=o.launcherPosition,o.zIndex===void 0?i.style.removeProperty("--ha-z-index"):i.style.setProperty("--ha-z-index",String(o.zIndex)),o.launcherOffset?(i.style.setProperty("--ha-launcher-x",`${o.launcherOffset.x}px`),i.style.setProperty("--ha-launcher-y",`${o.launcherOffset.y}px`)):(i.style.removeProperty("--ha-launcher-x"),i.style.removeProperty("--ha-launcher-y")),o.viewMode==="sidebar"&&i.style.setProperty("--ha-sidebar-width",`${fe(o.agentId,window.innerWidth)}px`);let d={...o.themeStyle,...o.panelStyle};for(let A of ce.current)A in d||s.style.removeProperty(A);for(let[A,de]of Object.entries(d))s.style.setProperty(A,de);ce.current=Object.keys(d)},[le,y,o.colorScheme,o.agentId,o.launcherOffset,o.launcherPosition,o.panelStyle,o.themeStyle,o.viewMode,o.zIndex,O]);let T=b(s=>{me(o.agentId,!1),$e(!1),xe(null),Dn(s);let i=re.current+1;re.current=i,Bn(i)},[o.agentId]),He=b(s=>{re.current===s&&(Gn(!0),xe(s))},[]),Kn=yt(()=>N?.());C(()=>{!x||Le.current===_||(Le.current=_,Kn())},[_,x]);let U=b(()=>{$.current=!1,se.current=!0,V(!1),H(!1),T(o.startNewConversationOnOpen?null:void 0)},[o.startNewConversationOnOpen,T]);C(()=>{y||!x||!se.current||(se.current=!1,requestAnimationFrame(()=>Ue.current?.focus()))},[y,x]);let B=b(()=>{$.current=!0,V(!0),R()},[R]),Be=R,Q=b(s=>{let i=s?Ze(s):null;i&&en(o.agentId,i),$.current=!0,V(!0),H(!1),R(),T(null)},[o.agentId,T,R]),De=b(s=>{$.current=!0,V(!0),H(!1),R(),T(s)},[T,R]),Ve=b(()=>{y||$.current?U():B()},[U,y,B]),We=b(()=>{oe(!1),Pe(!1),Te(s=>s+1)},[]),Ge=b(()=>{let s=[`heroui-agent:anonymous:${o.agentId}`,`heroui-agent:conversation:${o.agentId}:`,`heroui-agent:history:${o.agentId}:`];for(let i=localStorage.length-1;i>=0;i-=1){let d=localStorage.key(i);d&&s.some(A=>d.startsWith(A))&&localStorage.removeItem(d)}$.current=!1,oe(!1),V(!1),H(!1),be(o.agentId,!1),Pe(!0),Te(i=>i+1),T(),window.setTimeout(()=>{import("./composer-draft-NSKK65F3.js").then(({clearAgentComposerDraftsForProject:i})=>i(o.agentId)).catch(()=>{})},0)},[o.agentId,T]);return C(()=>{let s={hide:U,newConversation:Q,preload:Be,ready:x,refreshAuth:We,show:B,shutdown:Ge,toggle:Ve};return D.set(o.agentId,s),En(),()=>{D.get(o.agentId)===s&&(D.delete(o.agentId),En())}},[U,Q,o.agentId,Be,x,We,B,Ge,Ve]),kn(()=>{let s=X.current;if(!O||!s)return;let i=Cn({onFileDialogActiveChange:$e,onIntent:R,options:o});s.render(Nn(On,{children:[F&&o.showLauncher&&!y?Nn("button",{ref:Ue,"aria-expanded":!1,"aria-haspopup":"dialog",className:"ha-launcher",style:o.launcherStyle,type:"button","aria-label":te?"Open data assistant, unread messages":"Open data assistant",onClick:B,children:[P(cn,{icon:o.launcherIcon}),te?P("span",{"aria-hidden":"true",className:"ha-launcher__unread"}):null]}):null,J&&!Fe?P(J,{composerControlsRevealed:W,conversationEpoch:_,identityEpoch:Oe,identityReset:Me,open:y,options:o,requestedConversationId:K,shellComposerEndSlot:i.end,shellComposerFooterSlot:i.footer,showReadyLoader:!_e&&K!==null,tokenManager:q,onClose:U,onComposerControlsReveal:ue,onNewConversation:Q,onReady:He,onSelectConversation:De,onUnreadChange:oe}):P(Ke,{agentId:o.agentId,shouldCloseOnInteractOutside:o.shouldCloseOnInteractOutside,defaultExpanded:o.panelExpanded,expandable:o.panelExpandable,historySlot:P(On,{}),name:"Data assistant",open:y,showBetaBadge:o.showBetaBadge,viewMode:o.viewMode,onClose:U,children:K===null?P(on,{composerConnecting:!0,agentId:o.agentId,composerControlsAvailable:o.composerControlsAvailable,composerControlsRevealed:W,composerEndSlot:i.end,composerFooterSlot:i.footer,composerStartSlot:i.start,greeting:o.greeting,placeholder:o.composerPlaceholder,suggestedPrompts:o.suggestedPrompts??[],onComposerControlsReveal:ue,onIntent:R},`shell-${_}`):P(je,{})})]}))},[J,W,Fe,_,He,te,_e,U,Oe,Me,y,Q,o,O,x,F,K,R,ue,De,B,q]),null}export{co as a,lo as b};