@heroui/agent 0.2.0-beta.12 → 0.2.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/chunk-4JEZZR5J.js +1 -0
- package/dist/{chunk-XVBG56YE.js → chunk-S3NBK5KL.js} +2 -2
- package/dist/chunk-WVP7S2A4.js +2 -0
- package/dist/contracts.d.ts +1 -1
- package/dist/contracts.js +1 -1
- package/dist/css/index.css +1 -1
- package/dist/{embed-runtime-INDWW2WQ.js → embed-runtime-7MSWJUQM.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/internal/theme.js +1 -1
- package/dist/next.js +1 -1
- package/dist/server.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-2XBFFSW2.js +0 -1
- package/dist/chunk-IMH6S52M.js +0 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as m,b as a}from"./chunk-
|
|
1
|
+
import{a as m,b as a}from"./chunk-S3NBK5KL.js";import"./chunk-WVP7S2A4.js";import"./chunk-6ZJJN322.js";import{a as e}from"./chunk-64RI74L5.js";import{a as t,b as n,c as o,d as r,e as A,f as g,g as i}from"./chunk-UHHKMESI.js";import{a as s}from"./chunk-7KCGPNEN.js";import{a as p}from"./chunk-4JEZZR5J.js";export{p as AGENT_DESIGN_THEMES,t as AGENT_MODEL_IDS,A as AGENT_MODEL_OPTIONS,r as DEFAULT_AGENT_PICKER_MODEL_ID,s as HEROUI_AGENT_RUNTIME_TIMING_EVENT,a as HeroUIAgent,n as LEGACY_AGENT_MODEL_IDS,e as createToolHelper,i as getAgentModelTier,g as isAgentModelId,o as resolveAgentModelId,m as useAgent};
|
package/dist/internal/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f}from"../chunk-
|
|
1
|
+
import{a,b,c,d,e,f}from"../chunk-4JEZZR5J.js";export{c as ACCENT_FOREGROUND_CSS,a as AGENT_DESIGN_THEMES,d as LAUNCHER_FOREGROUND_CSS,e as buildLauncherStyle,f as buildThemeStyle,b as resolveAgentDesignTheme};
|
package/dist/next.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i,b as p}from"./chunk-
|
|
1
|
+
import{a as i,b as p}from"./chunk-S3NBK5KL.js";import"./chunk-WVP7S2A4.js";import"./chunk-6ZJJN322.js";import{a as e}from"./chunk-64RI74L5.js";import{a as t,d as n,e as o,f as r,g as A}from"./chunk-UHHKMESI.js";import{a as g}from"./chunk-7KCGPNEN.js";import"./chunk-4JEZZR5J.js";export{t as AGENT_MODEL_IDS,o as AGENT_MODEL_OPTIONS,n as DEFAULT_AGENT_PICKER_MODEL_ID,g as HEROUI_AGENT_RUNTIME_TIMING_EVENT,p as HeroUIAgent,e as createToolHelper,A as getAgentModelTier,r as isAgentModelId,i as useAgent};
|
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";var m="0.2.0-beta.
|
|
1
|
+
import{z as e}from"zod";var m="0.2.0-beta.13",u="https://api.heroui.pro";var d=e.enum(["light","dark","system"]),y=e.enum(["outline","plain","surface","surface-secondary"]),f=new Set(["[object object]","0","anonymous","distinct_id","distinctid","email","false","guest","id","nan","none","not_authenticated","null","true","undefined"]),c=e.string().trim().min(1).max(200).refine(t=>!f.has(t.toLowerCase()),{message:"Identity id is reserved"}),I=e.discriminatedUnion("type",[e.object({id:c,type:e.literal("anonymous")}),e.object({id:c,type:e.literal("user")})]),S=e.object({avatarUrl:e.string().trim().pipe(e.url()).optional(),email:e.string().trim().max(320).pipe(e.email()).optional(),name:e.string().trim().max(120).optional()}),g=e.object({anonymousId:c.optional(),identity:I,profile:S.optional()}),h=e.object({expiresAt:e.number().int().positive(),token:e.string().trim().min(1)}),O=e.object({agentId:e.string().trim().min(1).max(100),apiKeyId:e.string().trim().min(1).max(100),aud:e.literal("heroui-agent"),exp:e.number().int().positive(),iat:e.number().int().positive(),iss:e.literal("https://api.heroui.com"),jti:e.uuid(),protocolVersion:e.literal(6),sub:e.string().trim().min(1).max(200)});var _=e.object({agentId:e.string(),minimumProtocolVersion:e.literal(6),name:e.string().trim().min(1).max(120),protocolVersion:e.literal(6),sdkVersion:e.string().default(m),suggestedPrompts:e.array(e.string().trim().min(1).max(160)).max(5),surfaceVariant:y.default("plain"),theme:d});var n=class extends Error{status;constructor(o,i,a){super(o,a),this.name="HeroUIAgentAuthError",this.status=i}};async function C(t){let o=t.apiKey.trim(),i=t.agentId.trim(),a=g.safeParse({anonymousId:t.anonymousId,identity:t.identity,profile:t.profile});if(!o||!i||!a.success)throw new n("Invalid HeroUI Agent auth token request",400);let l=(t.apiBaseUrl?.trim()||u).replace(/\/$/,""),r;try{r=await fetch(`${l}/v1/agents/${encodeURIComponent(i)}/auth-tokens`,{body:JSON.stringify(a.data),cache:"no-store",headers:{Accept:"application/json","Content-Type":"application/json","X-HeroUI-Agent-Key":o},method:"POST"})}catch(A){throw new n("HeroUI Agent authentication is unavailable",503,{cause:A})}if(!r.ok)throw new n("HeroUI Agent authentication failed",r.status);let p=h.safeParse(await r.json().catch(()=>null));if(!p.success)throw new n("HeroUI Agent authentication returned invalid data",502);return p.data}export{n as HeroUIAgentAuthError,C as createAuthToken};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroui/agent",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.13",
|
|
4
4
|
"description": "Embed a hosted HeroUI Agent that turns application data into interactive UI.",
|
|
5
5
|
"homepage": "https://www.heroui.com/agents",
|
|
6
6
|
"bugs": {
|
|
@@ -110,10 +110,10 @@
|
|
|
110
110
|
"tsup": "8.5.0",
|
|
111
111
|
"typescript": "5.9.3",
|
|
112
112
|
"vitest": "4.1.0",
|
|
113
|
-
"@heroui-pro/react": "1.0.0-beta.8",
|
|
114
|
-
"@heroui/agent-client": "0.0.0",
|
|
115
113
|
"@heroui-pro/config": "0.0.0",
|
|
116
|
-
"@heroui/
|
|
114
|
+
"@heroui-pro/react": "1.0.0-beta.8",
|
|
115
|
+
"@heroui/agent-ui": "0.0.0",
|
|
116
|
+
"@heroui/agent-client": "0.0.0"
|
|
117
117
|
},
|
|
118
118
|
"scripts": {
|
|
119
119
|
"build": "rm -rf dist && tsup && pnpm build:styles",
|
package/dist/chunk-2XBFFSW2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=["base","brutalism","glass","mouve"];function S(e){return f.includes(e)?e:"base"}var m={accent:"accent",background:"background",foreground:"foreground",overlay:"overlay",surface:"surface",surfaceSecondary:"surface-secondary",tooltip:"tooltip"},h="oklch(from var(--ha-accent) clamp(0, (0.7 - l) * 1000, 1) 0 h)",l="oklch(from var(--ha-launcher-bg) clamp(0, (0.7 - l) * 1000, 1) 0 h)";function C(e){let r={},o=t(e,"light"),n=t(e,"dark");return o&&(r["--ha-theme-launcher-background-light"]=o,r["--ha-theme-launcher-foreground-light"]=l),n&&(r["--ha-theme-launcher-background-dark"]=n,r["--ha-theme-launcher-foreground-dark"]=l),r}var p="oklch(from var(--ha-card-secondary) calc(l - 0.0151) c h)",A="oklch(from var(--ha-card-secondary) calc(l + 0.017) c h)",d={pill:"0.875rem",round:"0.5rem",sharp:"0.125rem",soft:"0.375rem"},y=12,T=18;function u(e){let r=e?.trim();if(!(!r||r.length>256||/[;{}]/.test(r)))return r}function t(e,r){if(e!==void 0)return u(typeof e=="string"?e:e[r])}function k(e){if(!e)return{};let r={};e.radius&&e.radius in d&&(r["--radius"]=d[e.radius]);let o=u(e.typography?.fontFamily);o&&(r["--ha-font-family"]=o);let n=e.typography?.baseSize;if(typeof n=="number"&&Number.isFinite(n)){let a=Math.min(Math.max(Math.round(n),y),T);r["--ha-font-size"]=`${a}px`}for(let[a,s]of Object.entries(m)){let i=e.colors?.[a],c=t(i,"light"),g=t(i,"dark");c&&(r[`--ha-theme-${s}-light`]=c),g&&(r[`--ha-theme-${s}-dark`]=g)}return t(e.colors?.accent,"light")&&(r["--ha-theme-accent-foreground-light"]=h),t(e.colors?.accent,"dark")&&(r["--ha-theme-accent-foreground-dark"]=h),t(e.colors?.surfaceSecondary,"light")&&(r["--ha-theme-surface-tertiary-light"]=p),t(e.colors?.surfaceSecondary,"dark")&&(r["--ha-theme-surface-tertiary-dark"]=A),r}export{f as a,S as b,h as c,l as d,C as e,k as f};
|
package/dist/chunk-IMH6S52M.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as ce,e as de,f as ue}from"./chunk-2XBFFSW2.js";var ft="0.2.0-beta.12",me="https://api.heroui.pro";import{jsx as Be,jsxs as We}from"react/jsx-runtime";function bt({indicator:e,label:t="Loading agent\u2026"}){return We("div",{"aria-live":"polite",className:"ha-agent-loading",role:"status",children:[e,Be("span",{children:t})]})}import{jsx as pe,jsxs as Ge}from"react/jsx-runtime";function B({children:e,shortcut:t}){return Ge("span",{"aria-hidden":"true",className:"ha-control-tooltip",children:[pe("span",{children:e}),t?pe("kbd",{className:"ha-control-tooltip__shortcut",children:t}):null]})}import{ChevronsCollapseUpRight as $e,ChevronsExpandUpRight as Xe}from"@gravity-ui/icons";import{useCallback as fe,useEffect as W,useEffectEvent as je,useRef as Q,useState as G}from"react";function ge(e){return`heroui-agent:sidebar-width:${e}`}function Z(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 he(e,t){let n=Number.NaN;try{n=Number(localStorage.getItem(ge(e))??Number.NaN)}catch{}return Z(Number.isFinite(n)?n:420,t)}function J(e,t){try{localStorage.setItem(ge(e),String(Math.round(t)))}catch{}}import{jsx as d,jsxs as _}from"react/jsx-runtime";function Ct({actionsSlot:e,agentId:t,children:n,defaultExpanded:o=!1,expandable:s=!0,expandedSidebarSlot:f,expandedTitle:y,historySlot:a,keepMounted:c=!1,modal:p,name:S,onClose:E,onNewConversation:w,open:h}){let v=Q(null),u=Q(0),[k,q]=G(!1),O=je(E),[g,H]=G(o),R=!p&&!k,A=p||k||R&&g,[P,M]=G(!1),i=!k&&s,m=R&&g&&f;return W(()=>{let r=window.matchMedia?.("(max-width: 639px)");if(!r)return;let T=()=>q(r.matches);return T(),r.addEventListener?.("change",T),()=>r.removeEventListener?.("change",T)},[]),W(()=>{if(!P)return;let r=v.current;if(!r)return;let T=()=>M(!1),C=L=>{let{propertyName:F,target:Y}=L;Y===r&&(F!=="width"&&F!=="height"||T())},D=window.setTimeout(T,600);return r.addEventListener("transitionend",C),()=>{window.clearTimeout(D),r.removeEventListener("transitionend",C)}},[P]),W(()=>{if(!h)return;let r=v.current;if(!r)return;let T=document.activeElement instanceof HTMLElement?document.activeElement:null;r.open||(A&&typeof r.showModal=="function"?r.showModal():!A&&typeof r.show=="function"?r.show():r.open=!0);let C=document.documentElement,D=window.scrollX,L=window.scrollY,F=C.style.overflow,Y=document.body.style.overflow,Ie=document.body.style.position,Oe=document.body.style.top,De=document.body.style.left,Le=document.body.style.right,Fe=document.body.style.width;A&&(C.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`${-L}px`,document.body.style.left=`${-D}px`,document.body.style.right="0",document.body.style.width="100%");let Ue=r.querySelector("button,textarea,input,[tabindex]:not([tabindex='-1'])");r.contains(document.activeElement)||Ue?.focus();let re=b=>{if(!A&&b.key==="Escape"){if(Ae(r)){u.current=Date.now(),b.preventDefault(),b.stopPropagation();return}b.preventDefault(),O();return}if(!A||b.key!=="Tab")return;let U=Array.from(r.querySelectorAll("button:not(:disabled),textarea:not(:disabled),input:not(:disabled),[tabindex]:not([tabindex='-1'])"));if(U.length===0)return;let ae=U[0],se=U[U.length-1],ie=r.getRootNode(),le=ie instanceof ShadowRoot?ie.activeElement:document.activeElement;b.shiftKey&&le===ae?(b.preventDefault(),se.focus()):!b.shiftKey&&le===se&&(b.preventDefault(),ae.focus())};return r.addEventListener("keydown",re),()=>{r.removeEventListener("keydown",re),typeof r.close=="function"?r.close():r.open=!1,C.style.overflow=F,document.body.style.overflow=Y,document.body.style.position=Ie,document.body.style.top=Oe,document.body.style.left=De,document.body.style.right=Le,document.body.style.width=Fe,A&&window.scrollTo(D,L),document.activeElement===document.body&&T?.focus()}},[A,h]),!h&&!c?null:_("dialog",{ref:v,"aria-label":S,"aria-modal":A,className:"ha-panel","data-agent-overlay-root":"","data-expanded":!k&&g?"true":void 0,"data-expanded-sidebar":m?"true":void 0,"data-resizing":P?"true":void 0,hidden:!h,onCancel:r=>{if(r.preventDefault(),Date.now()-u.current<350||Ae(v.current)){u.current=Date.now();return}E()},children:[R&&!g?d(qe,{agentId:t,panelRef:v}):null,m?d("aside",{"aria-label":"Chat history",className:"ha-expanded-sidebar",children:f}):null,_("div",{className:"ha-panel-main",children:[_("header",{className:"ha-header",children:[m?d("span",{className:"ha-session-title ha-expanded-chat-title",children:y??S}):a??d("strong",{children:S}),_("div",{className:"ha-header-actions",children:[m?null:e??(w?d("button",{"aria-label":"New chat",className:"ha-icon-button ha-new-chat-button",type:"button",onClick:w,children:d(Ze,{})}):null),i?d("button",{"aria-expanded":g,"aria-label":g?"Collapse assistant":"Expand assistant",className:"ha-expand-button ha-icon-button",type:"button",onClick:()=>{M(!0),H(r=>!r)},children:g?d($e,{"aria-hidden":"true"}):d(Xe,{"aria-hidden":"true"})}):null,_("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:E,children:[d(Ye,{}),d(B,{shortcut:"ESC",children:"Close assistant"})]})]})]}),n,d("div",{className:"ha-overlay-portal","data-agent-overlay-portal":""})]})]})}function Ae(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]=G(420),s=Q(null),f=fe(a=>{let c=t.current,p=c?.getRootNode();(p instanceof ShadowRoot?p.host:c?.closest("[data-heroui-agent]"))?.style.setProperty("--ha-sidebar-width",`${a}px`),window.innerWidth>=640&&(document.documentElement.style.marginRight=`${Math.min(a,window.innerWidth)}px`),o(a)},[t]);W(()=>{o(he(e,window.innerWidth))},[e]);let y=fe((a,c)=>{let p=Z(a,window.innerWidth);return f(p),c&&J(e,p),p},[f,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:a=>{let c=a.key==="ArrowLeft"?24:a.key==="ArrowRight"?-24:0;c!==0&&(a.preventDefault(),y(n+c,!0))},onPointerCancel:a=>{let c=s.current;c&&(s.current=null,delete a.currentTarget.dataset.resizing,t.current&&delete t.current.dataset.dragResizing,document.documentElement.style.transition=c.pageTransition,y(c.startWidth,!1))},onPointerDown:a=>{a.button!==0&&a.pointerType==="mouse"||(a.preventDefault(),a.currentTarget.setPointerCapture(a.pointerId),a.currentTarget.dataset.resizing="true",s.current={currentWidth:n,pageTransition:document.documentElement.style.transition,startWidth:n,startX:a.clientX},document.documentElement.style.transition="none",t.current&&(t.current.dataset.dragResizing="true"))},onPointerMove:a=>{let c=s.current;c&&(c.currentWidth=y(c.startWidth+(c.startX-a.clientX),!1))},onPointerUp:a=>{let c=s.current;c&&(s.current=null,delete a.currentTarget.dataset.resizing,t.current&&delete t.current.dataset.dragResizing,a.currentTarget.releasePointerCapture(a.pointerId),document.documentElement.style.transition=c.pageTransition,J(e,c.currentWidth))}})}function Ye(){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 Ze(){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 be(e,{generateConversationTitle:t=!0}={}){let n=performance.now(),o=Date.now(),s=e.trim();return s?{...t?{}:{generateConversationTitle:!1},messageId:crypto.randomUUID(),prompt:s,startedAt:n,startedAtWallClock:o,submitted:!0}:null}var N=new Map,z=new Map,Je=10080*60*1e3,K=new Map;function ye(e){return`heroui-agent:shell-draft:${e}:composer-draft:v1`}function ee(e,t){try{let n=ye(e);t.trim()?localStorage.setItem(n,JSON.stringify({prompt:t,savedAt:Date.now()})):localStorage.removeItem(n)}catch{}}function Qe(e){let t=ye(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<=Je)return n.prompt;localStorage.removeItem(t)}catch{}return""}function V(e,t){if(!t.prompt.trim()&&!t.submitted){N.delete(e),ee(e,"");return}N.set(e,t),t.submitted||ee(e,t.prompt)}function te(e){let t=N.get(e);if(t)return t;let n=Qe(e);return n?{prompt:n,submitted:!1}:void 0}function ve(e,t,n){let o=N.get(e);!o?.submitted||o.messageId!==t||o.firstFeedbackPaintedAt!==void 0||N.set(e,{...o,firstFeedbackPaintedAt:n})}function Rt(e){let t=te(e);return N.delete(e),ee(e,""),t}function I(e,t,n){t?K.set(e,[n?.selectionStart??0,n?.selectionEnd??0,n?.selectionDirection??"none"]):K.delete(e)}function Te(e,t){let n=K.get(e);if(!n||!t)return;t.focus({preventScroll:!0});let o=Math.min(n[0],t.value.length),s=Math.min(n[1],t.value.length);t.setSelectionRange(o,s,n[2]),K.set(e,[o,s,n[2]])}function we(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 Pt(e,t){t.length===0?z.delete(e):z.set(e,t)}function et(e){return z.get(e)??[]}function _t(e){let t=et(e);return z.delete(e),t}function xe(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function tt(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 nt(e){let t=getComputedStyle(e);return xe(t.paddingTop)+xe(t.paddingBottom)}function ot(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 s=e.scrollHeight;return e.style.height=t,e.style.minHeight=n,e.style.maxHeight=o,s}function rt(e){if(e.value.includes(`
|
|
2
|
-
`))return!0;if(e.clientWidth===0)return!1;let t=ot(e),n=nt(e),o=tt(e);return Math.max(0,t-n)>o*1.5}function ne(e,{hasAttachments:t=!1,maxHeight:n=120}={}){if(!e)return!1;let o=e.value.length>0;return t||o&&rt(e)?(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,n)}px`,!0):(e.style.height="auto",!1)}import{jsx as oe,jsxs as Se}from"react/jsx-runtime";var at="https://heroui.pro/?utm_source=heroui-agent&utm_medium=referral&utm_campaign=powered-by-hero";function Ee(){return Se("a",{"aria-label":"Powered by HeroUI Pro (opens in a new tab)",className:"ha-powered-by",href:at,rel:"noopener noreferrer",target:"_blank",children:[oe("span",{children:"Powered by"}),Se("svg",{"aria-hidden":"true",className:"ha-powered-by-logo",fill:"none",viewBox:"0 0 140 44",children:[oe("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"}),oe("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 ke=new Set(["ask","auto","full"]);function $(e){return ke.has(e)?e:"auto"}function Ft(e,t){return`${e}:permission-mode:${t}:v1`}function Ut(e,t){return`${e}:active-permission-mode:${t}:v1`}function Bt(e){try{let t=localStorage.getItem(e);return t!==null&&ke.has(t)?$(t):void 0}catch{return}}function Wt(e,t){try{localStorage.setItem(e,t)}catch{}}function Gt(e){try{localStorage.removeItem(e)}catch{}}function zt(e,t){let n=$(t);if(n==="auto")return e;let o=n==="ask";return e.map(s=>!!s.needsApproval===o?s:{...s,needsApproval:o})}function Me(e){return`heroui-agent:anonymous:${e}`}var Ce=class{constructor(t,n){this.agentId=t;this.getAuthToken=n}cached=null;generation=0;pending=null;clear(){this.generation+=1,this.cached=null,this.pending=null}reset(){this.clear();try{localStorage.removeItem(Me(this.agentId))}catch{}}async get(){if(this.cached&&this.expiresAt(this.cached)>Date.now()+6e4)return this.cached.token;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,o.token)}finally{this.pending===n&&(this.pending=null)}}async subjectHash(){let t=await this.get(),n=st(t),o=typeof n.sub=="string"?n.sub:"anonymous",s=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${this.agentId}:${o}`));return Array.from(new Uint8Array(s),f=>f.toString(16).padStart(2,"0")).join("").slice(0,24)}anonymousId(){let t=Me(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 st(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 it={"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"},X=Object.freeze(Object.keys(it)),$t=X.join(","),lt=new Set(X);function Ne(e){return lt.has(e.trim().toLowerCase())}import{useEffect as ct,useLayoutEffect as He,useRef as dt,useState as j}from"react";import{Fragment as Re,jsx as l,jsxs as x}from"react/jsx-runtime";function Qt({agentId:e,composerConnecting:t=!1,composerControlsAvailable:n,composerControlsRevealed:o,composerEndSlot:s,composerFooterSlot:f,composerStartSlot:y,greeting:a,onComposerControlsReveal:c,onIntent:p,placeholder:S,suggestedPrompts:E}){let[w]=j(()=>te(e)),[h,v]=j(()=>w?.submitted?"":w?.prompt??""),[u,k]=j(()=>w?.submitted?w:null),[q,O]=j(!1),g=dt(null),H=n??!!(y||s),R=o??(H&&q),A=i=>{I(e,!0,i.currentTarget),O(H),H&&c?.(),p()},P=i=>{let m=i.currentTarget.querySelector(".ha-composer");m&&we(m,i.relatedTarget)||(O(!1),I(e,!1))};He(()=>{Te(e,g.current),ne(g.current)},[e]),ct(()=>{u||V(e,{prompt:h,submitted:!1})},[h,e,u]),He(()=>{if(!u)return;let i=requestAnimationFrame(m=>{ve(e,u.messageId,m)});return()=>cancelAnimationFrame(i)},[e,u]);let M=(i,m=!0)=>{if(u)return;let r=be(i,{generateConversationTitle:m});r&&(k(r),v(""),g.current.style.height="auto",V(e,r),p())};return x(Re,{children:[l("div",{className:"ha-conversation",children:l("div",{"aria-live":"polite",className:"ha-messages",role:"log",children:u?x(Re,{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:u.prompt})})})}),l("div",{className:"ha-message","data-role":"assistant","data-stream-anchor":"true","data-turn-feedback-id":u.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("span",{"aria-hidden":"true",className:"ha-shimmer",children:"Thinking\u2026"})})})})]}):x("div",{className:"ha-empty",children:[l("h2",{children:a}),l("p",{children:"Live answers with charts, metrics, and tables."})]})})}),x("form",{className:"ha-composer-wrap",onBlur:P,onSubmit:i=>{i.preventDefault(),M(h)},children:[!u&&E.length>0?l("div",{"aria-label":"Suggested prompts",className:"ha-suggestions",role:"group",children:E.map(i=>x("button",{className:"ha-suggestion",type:"button",onClick:()=>M(i,!1),children:[l("span",{children:i}),l(mt,{})]},i))}):null,x("div",{className:"@container ha-composer","data-connecting":t||void 0,"data-controls-revealed":R||void 0,children:[y,l("textarea",{ref:g,"aria-label":"Message the assistant",placeholder:S,readOnly:!!u,rows:1,value:h,onFocus:A,onSelect:i=>I(e,!0,i.currentTarget),onChange:i=>{let m=i.currentTarget.value;V(e,{prompt:m,submitted:!1}),I(e,!0,i.currentTarget),v(m),ne(i.currentTarget),p()},onKeyDown:i=>{i.key!=="Enter"||i.shiftKey||(i.preventDefault(),M(h))}}),s,x("button",{"aria-label":"Send message",className:"ha-send",disabled:!h.trim()||!!u,type:"submit",children:[l(ut,{}),l(B,{shortcut:"\u21B5",children:"Send message"})]})]}),l("div",{className:"ha-composer-footer","data-revealed":!!f||void 0,children:l("div",{className:"ha-composer-footer-content",children:f})}),l(Ee,{})]})]})}function ut(){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 mt(){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 pt={animation:"fadeIn",duration:160,easing:"ease-out",sep:"word",stagger:18};function Pe(e){return typeof e=="number"?Number.isFinite(e)?`${Math.round(e)}px`:void 0:e?.trim()||void 0}function gt(e){let t=Pe(e?.initialWidth),n=Pe(e?.initialHeight);return{...t?{"--ha-panel-width":t}:{},...n?{"--ha-panel-height":n}:{}}}function _e(e){return e===void 0||!Number.isFinite(e)?24:Math.min(Math.max(Math.round(e),0),200)}function ht(e){if(e===void 0)return[...X];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();Ne(o)&&t.add(o)}return[...t]}function sn(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=ht(e.composer?.attachments),n=typeof e.composer?.disclaimer=="string"&&e.composer.disclaimer.trim().slice(0,240)||void 0;return{apiBaseUrl:(e._api?.baseUrl??me).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:ce(e.appearance?.theme?.designTheme),...n?{composerDisclaimer:n}:{},agentId:e.agentId,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??pt,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:gt(e.appearance?.panel),permissionDefaultMode:$(e.permissions?.defaultMode),permissionShowPicker:e.permissions?.showPicker===!0,preload:e.preload??!0,reopenOnRefresh:e.reopenOnRefresh??!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:_e(e.appearance.launcher.offset.x),y:_e(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(o=>o.trim()).filter(Boolean).slice(0,5),themeStyle:{...ue(e.appearance?.theme),...de(e.appearance?.launcher?.background)},tools:e.tools??[],viewMode:e.appearance?.viewMode??"floating",webSearch:e.capabilities?.webSearch??!1}}export{Ce as a,ft as b,me as c,bt as d,B as e,he as f,Ct as g,it as h,X as i,Ne as j,be as k,V as l,te as m,Rt as n,I as o,Te as p,we as q,Pt as r,et as s,_t as t,ne as u,Ee as v,Qt as w,Ft as x,Ut as y,Bt as z,Wt as A,Gt as B,zt as C,pt as D,sn as E};
|