@marketrix.ai/widget 3.2.173 → 3.2.174

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/dist/widget.mjs CHANGED
@@ -12,10 +12,10 @@ return f(ku,{className:"fixed",style:{zIndex:b,maxWidth:"420px",opacity:l?0:1,tr
12
12
  /* @__PURE__ */f(Cu,{src:_u,alt:"",size:28,className:"flex-shrink-0",style:{borderRadius:"50%"}}),
13
13
  /* @__PURE__ */g(fp,{className:"flex-1 min-w-0",children:[/* @__PURE__ */f(vp,{as:"span",weight:"medium",className:"block text-inherit",style:{fontSize:"13px",color:u.titleColor,whiteSpace:o?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),n&&/* @__PURE__ */f(vp,{as:"span",className:"block text-inherit",style:{fontSize:"12px",color:u.bodyColor,opacity:.8,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]}),o&&/* @__PURE__ */f(lp,{type:"button",variant:"ghost",onClick:()=>{o(),d()},className:"flex-shrink-0 rounded-full px-3 py-1 text-xs font-semibold transition-colors",style:{color:u.titleColor,backgroundColor:"error"===e?"#fee2e2":"#e0f2fe",border:u.border},"aria-label":"Retry",children:"Retry"}),
14
14
  /* @__PURE__ */f(mp,{label:"Dismiss",onClick:e=>{e.stopPropagation(),d()},className:"flex-shrink-0",style:{width:"20px",height:"20px",padding:"2px",color:u.closeColor},children:/* @__PURE__ */f(up,{name:"closeSmall",size:12})})]})})},_p=20,Sp=(e,t,n,r,o)=>{switch(e){case"top_left":return{x:_p,y:_p};case"top_right":return{x:t-_p-r,y:_p};case"bottom_left":return{x:_p,y:n-_p-o};default:return{x:t-_p-r,y:n-_p-o}}},Cp=(e,t,n,r,o,i)=>{const s=Sp(e,n,r,o,i),a=s.x+o/2,l=s.y+i/2;let c,d;switch(t){case"top_left":c=_p+o/2,d=_p+i/2;break;case"top_right":c=n-_p-o/2,d=_p+i/2;break;case"bottom_left":c=_p+o/2,d=r-_p-i/2;break;default:c=n-_p-o/2,d=r-_p-i/2}return{dx:c-a,dy:d-l}},Ip="cubic-bezier(0.16, 1, 0.3, 1)",Ep=({open:e,processing:n=!1,error:r=!1,taskRunning:o=!1,onClick:s,onStop:a,accentColor:l,backgroundColor:d,borderRadius:h="12px",tooltipBgColor:m,tooltipTextColor:y,zIndex:w=50,position:b,onDrag:v,isPreviewMode:x=!1})=>{const k=!e&&(n||o),_=!e&&o&&null!=a,S=r?"marketrix-widget-button-error-glow":"marketrix-widget-button-processing-glow",C=r?"marketrix-widget-button-error-activity-ring":"marketrix-widget-button-processing-activity-ring",I=Math.max(6,Math.min(22,Number.parseFloat(h)||12)),[E,T]=p(!1),A=u(null),[M,z]=p({w:56,h:56}),[,O]=p(0),R=u(null),N=u(null),P=u(null),L=u(0),D=u([]),$=u(0);t.useEffect(()=>()=>{null!==P.current&&window.cancelAnimationFrame(P.current)},[]),t.useEffect(()=>{if(x)return;const e=()=>O(e=>e+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[x]);const j=i(()=>{if(!A.current||"undefined"==typeof window)return;const e=A.current.getBoundingClientRect();z(t=>t.w===e.width&&t.h===e.height?t:{w:e.width,h:e.height})},[]);c(()=>{j();const e="undefined"!=typeof window&&A.current?new ResizeObserver(j):null;return e&&A.current&&e.observe(A.current),()=>e?.disconnect()},[j,b]);const F="undefined"!=typeof window?window.innerWidth:0,U="undefined"!=typeof window?window.innerHeight:0,B=Sp(b,F,U,M.w,M.h),W=!x&&F>0&&U>0?{left:B.x,top:B.y}:void 0,G=(e=>{switch(e){case"bottom_right":default:return"bottom-5 right-5";case"bottom_left":return"bottom-5 left-5";case"top_right":return"top-5 right-5";case"top_left":return"top-5 left-5"}})(b),H=x?"absolute":"fixed",Z=x?b.includes("top")?{top:"20px",...b.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...b.includes("right")?{right:"20px"}:{left:"20px"}}:{},V=(e,t=.999)=>e/1e3*t/(1-t),q=()=>{null!==P.current&&(window.cancelAnimationFrame(P.current),P.current=null),A.current&&(A.current.style.transform="",A.current.style.willChange="",A.current.style.transition="")},J=i((e,t)=>{if(R.current)return;let n=!1;const r=()=>{n||(n=!0,R.current=null,t.style.transition="none",t.style.willChange="",v(e),T(!1),requestAnimationFrame(()=>{A.current&&(A.current.style.transition="")}))};R.current=r;const o=window.setTimeout(r,650);t.addEventListener("transitionend",function e(n){n.target===t&&"left"===n.propertyName&&(window.clearTimeout(o),t.removeEventListener("transitionend",e),r())})},[v]);/* @__PURE__ */
15
- return g(ku,{ref:A,className:`${H} ${W?"":G} ${E?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:w,pointerEvents:"auto",...Z,...W},children:[/* @__PURE__ */g(ku,{className:`\n group relative w-14 h-14 overflow-visible transition-all duration-300 ease-in-out\n ${e?"scale-0 opacity-0 pointer-events-none":"scale-100 opacity-100 hover:scale-110"}\n `,children:[k&&/* @__PURE__ */f(ku,{className:S,"aria-hidden":!0}),_&&!E&&/* @__PURE__ */f(lp,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),a?.()},className:"absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-white/25 bg-gray-900 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow-lg opacity-0 transition-opacity duration-150 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto "+(b.includes("left")?"left-full ml-2":"right-full mr-2"),style:{border:"1px solid rgba(255,255,255,0.25)"},"aria-label":"Stop running task",children:"Stop"}),
15
+ return g(ku,{ref:A,className:`${H} ${W?"":G} ${E?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:w,pointerEvents:e?"none":"auto",...Z,...W},children:[/* @__PURE__ */g(ku,{className:`\n group relative w-14 h-14 overflow-visible transition-all duration-300 ease-in-out\n ${e?"scale-0 opacity-0 pointer-events-none":"scale-100 opacity-100 hover:scale-110"}\n `,children:[k&&/* @__PURE__ */f(ku,{className:S,"aria-hidden":!0}),_&&!E&&/* @__PURE__ */f(lp,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),a?.()},className:"absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-white/25 bg-gray-900 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow-lg opacity-0 transition-opacity duration-150 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto "+(b.includes("left")?"left-full ml-2":"right-full mr-2"),style:{border:"1px solid rgba(255,255,255,0.25)"},"aria-label":"Stop running task",children:"Stop"}),
16
16
  /* @__PURE__ */f(lp,{type:"button",variant:"primary",onClick:()=>{Date.now()<L.current||s()},onDragStart:e=>e.preventDefault(),onPointerDown:t=>{e||(N.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,dragging:!1,lastX:0,lastY:0},t.currentTarget.setPointerCapture(t.pointerId))},onPointerMove:e=>{const t=N.current;if(t?.pointerId!==e.pointerId)return;const n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.dragging&&Math.hypot(n,r)>5&&(t.dragging=!0,T(!0),D.current=[],$.current=0,A.current&&(A.current.style.willChange="transform",A.current.style.transition="none")),!t.dragging)return;t.lastX=n,t.lastY=r;const o=Date.now();o-$.current>=10&&($.current=o,D.current=[...D.current.slice(-5),{x:e.clientX,y:e.clientY,t:o}]),null===P.current&&(P.current=window.requestAnimationFrame(()=>{P.current=null;const e=N.current,t=A.current;t&&e&&(t.style.transform=`translate3d(${e.lastX}px, ${e.lastY}px, 0)`)}))},onPointerUp:e=>{const t=N.current;if(t?.pointerId===e.pointerId){if(t.dragging){const n=(()=>{const e=D.current;if(e.length<2)return{x:0,y:0};const t=e[e.length-1].t-e[0].t;return t<=0?{x:0,y:0}:{x:(e[e.length-1].x-e[0].x)/t*1e3,y:(e[e.length-1].y-e[0].y)/t*1e3}})(),r=V(n.x),o=V(n.y),i={dx:t.lastX+r,dy:t.lastY+o};let s;if("undefined"!=typeof window&&A.current){const e=A.current.getBoundingClientRect();s=((e,t,n,r,o,i)=>{const s=["top_left","top_right","bottom_left","bottom_right"];let a=t,l=1/0;for(const c of s){const s=Cp(t,c,n,r,o,i),d=Math.hypot(e.dx-s.dx,e.dy-s.dy);d<l&&(l=d,a=c)}return a})(i,b,window.innerWidth,window.innerHeight,e.width,e.height)}else s=b;return((e,t,n)=>{if(!A.current||!W)return q(),v(e),void T(!1);null!==P.current&&(window.cancelAnimationFrame(P.current),P.current=null);const r=A.current,o=Sp(b,F,U,M.w,M.h),i=Sp(e,F,U,M.w,M.h);r.style.transition="none",r.style.transform="none",r.style.willChange="left, top",r.style.left=`${o.x+t}px`,r.style.top=`${o.y+n}px`,requestAnimationFrame(()=>{r.style.transition=`left 600ms ${Ip}, top 600ms ${Ip}`,r.style.left=`${i.x}px`,r.style.top=`${i.y}px`}),J(e,r)})(s,t.lastX,t.lastY),L.current=Date.now()+600,N.current=null,void e.currentTarget.releasePointerCapture(e.pointerId)}q(),N.current=null,T(!1),e.currentTarget.releasePointerCapture(e.pointerId)}},onPointerCancel:e=>{N.current?.pointerId===e.pointerId&&(q(),N.current=null,T(!1),e.currentTarget.releasePointerCapture(e.pointerId))},className:"relative z-10 w-14 h-14 min-w-14 rounded-[27px] border-0 bg-transparent p-0 text-primary-foreground",style:{touchAction:"none",cursor:E?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},"aria-label":e?"Close":"Open","aria-live":"polite",children:/* @__PURE__ */f(cp,{className:"w-full h-full items-center justify-center relative",children:/* @__PURE__ */g(ku,{className:"\n relative w-12 h-12 overflow-hidden transition-[transform,opacity,background-color] duration-[167ms] ease-[cubic-bezier(0.33,0,0,1)]\n hover:scale-110 hover:duration-[250ms] active:scale-[0.85] active:duration-[134ms] active:ease-[cubic-bezier(0.45,0,0.2,1)]\n animate-launcher-entrance\n ",style:{borderRadius:h,backgroundColor:e?d:l},children:[k&&/* @__PURE__ */f("svg",{className:C,viewBox:"0 0 54 54",fill:"none","aria-hidden":!0,children:/* @__PURE__ */f("rect",{x:"1.25",y:"1.25",width:"51.5",height:"51.5",rx:I+1,ry:I+1})}),
17
17
  /* @__PURE__ */f(cp,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(30deg) scale(0)":"rotate(0deg) scale(1)",opacity:e?0:1,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":e,children:/* @__PURE__ */f(Cu,{src:_u,alt:"",className:"relative z-10 w-full h-full object-contain",draggable:!1,onDragStart:e=>e.preventDefault(),style:{borderRadius:h,border:"none",outline:"none",backgroundColor:"transparent",pointerEvents:"none",userSelect:"none"}})}),
18
- /* @__PURE__ */f(cp,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(0deg) scale(1)":"rotate(-30deg) scale(0)",opacity:e?1:0,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":!e,children:/* @__PURE__ */f(up,{name:"chevronDown",size:24,className:"relative z-10 text-foreground pointer-events-none"})})]})})})]}),!e&&/* @__PURE__ */g(ku,{className:`absolute bottom-16 ${b.includes("left")?"left-0":"right-0"} mb-2 px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200`,style:{backgroundColor:m,color:y},children:[/* @__PURE__ */f(vp,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */f(ku,{"aria-hidden":!0,className:`absolute top-full ${b.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:m}})]})]})},Tp="3.2.173";function Ap(e){return Array.from(e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent&&!e.hasAttribute("aria-hidden"))}function Mp(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function zp(e,t,n){return Math.min(Math.max(e,t),n)}function Op(e,t,n,r,o){const i={"bottom-right":"nwse-resize","bottom-left":"nesw-resize","top-right":"nesw-resize","top-left":"nwse-resize"};switch(e){case"bottom-right":return{dx:r-t,dy:o-n,cursor:i[e]};case"bottom-left":return{dx:t-r,dy:o-n,cursor:i[e]};case"top-right":return{dx:r-t,dy:n-o,cursor:i[e]};case"top-left":return{dx:t-r,dy:n-o,cursor:i[e]}}}var Rp={live:"inline-flex items-center gap-1",status:"inline-flex items-center text-[9px] font-medium px-1.5 py-0.5 rounded"},Np=o(function({variant:e,className:t,style:n,children:r,...o},i){/* @__PURE__ */
18
+ /* @__PURE__ */f(cp,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(0deg) scale(1)":"rotate(-30deg) scale(0)",opacity:e?1:0,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":!e,children:/* @__PURE__ */f(up,{name:"chevronDown",size:24,className:"relative z-10 text-foreground pointer-events-none"})})]})})})]}),!e&&/* @__PURE__ */g(ku,{className:`absolute bottom-16 ${b.includes("left")?"left-0":"right-0"} mb-2 px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200`,style:{backgroundColor:m,color:y},children:[/* @__PURE__ */f(vp,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */f(ku,{"aria-hidden":!0,className:`absolute top-full ${b.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:m}})]})]})},Tp="3.2.174";function Ap(e){return Array.from(e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent&&!e.hasAttribute("aria-hidden"))}function Mp(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function zp(e,t,n){return Math.min(Math.max(e,t),n)}function Op(e,t,n,r,o){const i={"bottom-right":"nwse-resize","bottom-left":"nesw-resize","top-right":"nesw-resize","top-left":"nwse-resize"};switch(e){case"bottom-right":return{dx:r-t,dy:o-n,cursor:i[e]};case"bottom-left":return{dx:t-r,dy:o-n,cursor:i[e]};case"top-right":return{dx:r-t,dy:n-o,cursor:i[e]};case"top-left":return{dx:t-r,dy:n-o,cursor:i[e]}}}var Rp={live:"inline-flex items-center gap-1",status:"inline-flex items-center text-[9px] font-medium px-1.5 py-0.5 rounded"},Np=o(function({variant:e,className:t,style:n,children:r,...o},i){/* @__PURE__ */
19
19
  return g("span",{...o,ref:i,className:yu(Rp[e],t),"data-variant":e,style:n,children:["live"===e&&/* @__PURE__ */g("span",{className:"relative flex h-1.5 w-1.5",children:[/* @__PURE__ */f("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),/* @__PURE__ */f("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),r]})});function Pp({defaultOpen:e=!1,onOpenChange:t,open:n}){const[r,o]=p(e),s=void 0!==n;return{isOpen:s?n:r,setIsOpen:i(e=>{s||o(e),t?.(e)},[s,t])}}var Lp=n(null);function Dp(e){const t=s(Lp);if(!t)throw new Error(`${e} must be used within Dialog`);return t}function $p({children:e,onOpenChange:t,open:n}){const{isOpen:r,setIsOpen:o}=Pp({onOpenChange:t,open:n}),i=l(),s=l(),a=l(),c=d(()=>({contentId:i,descriptionId:a,open:r,setOpen:o,titleId:s}),[i,a,r,o,s]);/* @__PURE__ */
20
20
  return f(Lp.Provider,{value:c,children:e})}function jp({children:e,className:t,onKeyDown:n,...r}){const o=Dp("DialogContent");return a(()=>{if(!o.open)return;const e=e=>{"Escape"===e.key&&o.setOpen(!1)};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[o]),o.open?/* @__PURE__ */f("div",{...r,"aria-describedby":o.descriptionId,"aria-labelledby":o.titleId,"aria-modal":"true",className:yu("fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[calc(var(--layer-dialog)+1)] flex flex-col w-full max-w-[500px] max-h-[85vh] overflow-auto bg-card rounded-lg shadow-xl p-6 animate-dialog-content-in",t),"data-state":"open",id:o.contentId,onKeyDown:e=>{n?.(e),e.defaultPrevented||"Escape"!==e.key||o.setOpen(!1)},role:"dialog",tabIndex:-1,children:e}):null}function Fp({className:e,...t}){const n=Dp("DialogTitle");/* @__PURE__ */
21
21
  return f("h2",{...t,className:yu("text-lg font-semibold text-card-foreground mb-2",e),id:n.titleId})}function Up({className:e,...t}){const n=Dp("DialogDescription");/* @__PURE__ */
@@ -34,8 +34,8 @@ return g(lp,{role:"tab","aria-selected":r,"aria-controls":`view-${e.id}`,id:`tab
34
34
  /* @__PURE__ */f(vp,{as:"span",size:"xs",className:"truncate w-full text-center text-inherit",children:e.label})]},e.id)})}),oh={green:"bg-green-100 text-green-700",blue:"bg-blue-100 text-blue-700",yellow:"bg-yellow-100 text-yellow-700",gray:"bg-gray-100 text-gray-600"},ih=({variant:e,open:t,onClose:n,title:r,description:o,onConfirm:i,confirmLabel:s="Confirm",cancelLabel:a="Cancel",rows:l=[],status:c})=>/* @__PURE__ */f($p,{open:t,onOpenChange:e=>{e||n()},children:/* @__PURE__ */g(jp,"confirm"===e?{className:"bg-white rounded-lg p-4 max-w-sm shadow-xl",children:[
35
35
  /* @__PURE__ */f(Fp,{className:"text-base font-semibold text-gray-900 mb-1",children:r}),null!=o&&/* @__PURE__ */f(Up,{className:"text-sm text-gray-600 mb-4 leading-relaxed",children:o}),
36
36
  /* @__PURE__ */g(cp,{className:"gap-2 justify-end",children:[/* @__PURE__ */f(lp,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:"px-4 py-1.5 rounded-full text-sm font-medium border border-gray-200",children:a}),/* @__PURE__ */f(lp,{type:"button",variant:"primary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),i?.()},className:"px-4 py-1.5 rounded-full text-sm font-medium",children:s})]})]}:{className:"bg-white rounded-md shadow-lg border border-gray-200 w-64 p-0",children:[/* @__PURE__ */g(cp,{className:"items-center justify-between px-3 py-1.5 border-b border-gray-100",children:[/* @__PURE__ */f(Fp,{className:"text-[11px] font-semibold text-gray-700 flex-1 text-center mb-0",children:r}),/* @__PURE__ */f(Bp,{className:"text-gray-400 hover:text-gray-600 -mr-1 static w-auto h-auto","aria-label":"Close",children:/* @__PURE__ */f(up,{name:"x",size:12})})]}),/* @__PURE__ */g(fp,{className:"px-3 py-1.5",children:[l.map(e=>/* @__PURE__ */g(cp,{className:"items-center justify-between py-[3px]",children:[/* @__PURE__ */f(vp,{as:"span",className:"text-[10px] text-gray-500",children:e.label}),/* @__PURE__ */g(cp,{className:"items-center gap-1",children:[/* @__PURE__ */f(vp,{as:"code",className:"text-[9px] text-gray-600 bg-gray-50 px-1 py-0.5 rounded max-w-[120px] truncate",children:e.value||"N/A"}),!0===e.copyable&&e.value&&/* @__PURE__ */f(lp,{type:"button",variant:"ghost",size:"sm",onClick:()=>{return t=e.value,void navigator.clipboard.writeText(t);var t},className:"text-[9px] text-blue-500 hover:text-blue-600 min-w-0 p-0 h-auto",children:"Copy"})]})]},e.label)),null!=c&&/* @__PURE__ */g(cp,{className:"items-center justify-between py-[3px]",children:[/* @__PURE__ */f(vp,{as:"span",className:"text-[10px] text-gray-500",children:"Status"}),/* @__PURE__ */f(Np,{variant:"status",className:oh[c.color],children:c.label})]})]})]})});function sh(e){return"registered"===e?"green":"connected"===e?"blue":"connecting"===e?"yellow":"gray"}var ah=({isOpen:e,onClose:t,diagnosticData:n})=>{const r=[{label:"Chat ID",value:n.chatId??"N/A",copyable:!!n.chatId},{label:"Stream Endpoint",value:n.streamEndpoint??"N/A",copyable:!!n.streamEndpoint},{label:"Application ID",value:n.applicationId?.toString()??"N/A",copyable:!!n.applicationId},{label:"Agent ID",value:n.agentId?.toString()??"N/A",copyable:!!n.agentId}],o={label:n.connectionStatus,color:sh(n.connectionStatus)},i="dev"===n.build?"dev":n.build.slice(0,7);/* @__PURE__ */
37
- return f(ih,{variant:"info",open:e,onClose:t,title:`Widget v${n.version} (${i})`,rows:r,status:o})};function lh(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}var ch=t.forwardRef(function({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:o,onModeChange:s,disabled:l=!1,taskRunning:c=!1,onStop:d,placeholder:p="Ask anything"},h){const m=u(null);a(()=>{const e=m.current;if(e){e.style.height="auto";const t=e.scrollHeight,n=Math.min(t,46);e.style.height=`${n}px`,e.style.overflowY=t>46?"auto":"hidden"}},[e]);const y=i(e=>{t(e.target.value);const n=e.target;n.style.height="auto";const r=Math.min(n.scrollHeight,46);n.style.height=`${r}px`,n.style.overflowY=n.scrollHeight>46?"auto":"hidden"},[t]),w=i(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),b=Boolean(e.trim())&&!l;/* @__PURE__ */
38
- return g(fp,{className:"rounded-xl border border-border overflow-hidden focus-within:border-foreground-faint transition-colors bg-card/70 backdrop-blur-sm",children:[/* @__PURE__ */f(eh,{ref:lh(m,h),value:e,onChange:y,onKeyDown:w,placeholder:p,disabled:l,rows:1,className:"w-full px-3 text-sm text-foreground placeholder:text-foreground-faint resize-none focus:outline-none focus:ring-0 border-none shadow-none disabled:opacity-50 disabled:cursor-not-allowed",style:{backgroundColor:"transparent",lineHeight:"20px",paddingTop:"4px",paddingBottom:"2px",minHeight:"unset"}}),/* @__PURE__ */g(cp,{className:"items-center justify-between px-1.5 pb-1.5",children:[/* @__PURE__ */f(cp,{className:"items-center gap-1",children:r.map(e=>/* @__PURE__ */g(Kp,{active:o===e.id,size:"sm",onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */f(up,{name:e.icon,size:12}),/* @__PURE__ */f(vp,{as:"span",className:"text-inherit",children:e.label})]},e.id))}),/* @__PURE__ */f(mp,{variant:c?"secondary":b?"primary":"ghost",size:"sm",disabled:!c&&!b,label:c?"Stop task":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),c&&d?d():n()},children:/* @__PURE__ */f(up,c?{name:"stop",size:14}:{name:"send",size:16})})]})]})}),dh=({variant:e,message:t})=>{const n="error"===e,r="loading"===e;/* @__PURE__ */
37
+ return f(ih,{variant:"info",open:e,onClose:t,title:`Widget v${n.version} (${i})`,rows:r,status:o})};function lh(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}var ch=t.forwardRef(function({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:o,onModeChange:s,disabled:l=!1,taskRunning:c=!1,onStop:d,placeholder:p="Ask anything"},h){const m=u(null);a(()=>{const e=m.current;if(e){e.style.height="auto";const t=e.scrollHeight,n=Math.min(t,66);e.style.height=`${n}px`,e.style.overflowY=t>66?"auto":"hidden"}},[e]);const y=i(e=>{t(e.target.value);const n=e.target;n.style.height="auto";const r=Math.min(n.scrollHeight,66);n.style.height=`${r}px`,n.style.overflowY=n.scrollHeight>66?"auto":"hidden"},[t]),w=i(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),b=Boolean(e.trim())&&!l;/* @__PURE__ */
38
+ return g(fp,{className:"rounded-xl border border-border overflow-hidden focus-within:border-foreground-faint transition-colors bg-card/70 backdrop-blur-sm",children:[/* @__PURE__ */f(eh,{ref:lh(m,h),value:e,onChange:y,onKeyDown:w,placeholder:p,disabled:l,rows:1,className:"w-full px-3 text-sm text-foreground placeholder:text-foreground-faint resize-none focus:outline-none focus:ring-0 border-none shadow-none disabled:opacity-50 disabled:cursor-not-allowed",style:{backgroundColor:"transparent",lineHeight:"20px",paddingTop:"4px",paddingBottom:"2px",minHeight:"unset"}}),/* @__PURE__ */g(cp,{className:"items-center justify-between px-1.5 pb-1.5",children:[/* @__PURE__ */f(cp,{className:"items-center gap-1",children:r.map(e=>/* @__PURE__ */g(Kp,{active:o===e.id,size:"sm",onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */f(up,{name:e.icon,size:12}),/* @__PURE__ */f(vp,{as:"span",className:"text-inherit",children:e.label})]},e.id))}),/* @__PURE__ */f(mp,{variant:c?"secondary":"primary",size:"sm",disabled:!c&&!b,label:c?"Stop task":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),c&&d?d():n()},children:/* @__PURE__ */f(up,c?{name:"stop",size:14}:{name:"send",size:16})})]})]})}),dh=({variant:e,message:t})=>{const n="error"===e,r="loading"===e;/* @__PURE__ */
39
39
  return g(fp,{align:"center",justify:"center",gap:"lg",paddingY:"2xl",paddingX:"xl",role:r?"status":void 0,"aria-live":n?"assertive":"polite",style:n?{color:"var(--color-red-600, #dc2626)"}:void 0,children:[r&&/* @__PURE__ */f(Xp,{size:"lg"}),/* @__PURE__ */f(vp,{as:"p",size:"sm",align:"center",children:t})]})},uh=({content:e,status:t="pending",accentColor:n,hideIcon:r=!1,textStyle:o="default"})=>/* @__PURE__ */g(cp,{align:"start",gap:"md",children:[!r&&(()=>{switch(t){case"completed":/* @__PURE__ */return f(up,{name:"checkCircle",style:{color:n,marginTop:"2px",flexShrink:0},size:16});case"failed":/* @__PURE__ */return f(up,{name:"timesCircle",style:{opacity:.65,marginTop:"2px",flexShrink:0},size:16});case"canceled":/* @__PURE__ */return f(up,{name:"ban",style:{opacity:.5,marginTop:"2px",flexShrink:0},size:16});case"running":/* @__PURE__ */return f(Xp,{size:"sm",style:{color:n,marginTop:"2px"}});default:/* @__PURE__ */return f(up,{name:"circle",style:{opacity:.5,marginTop:"2px",flexShrink:0},size:16})}})(),/* @__PURE__ */f(vp,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap",lineHeight:"tight",opacity:"muted"===o?.5:1},children:e})]}),ph=({isWaitingForUser:e,accentColor:t})=>/* @__PURE__ */g(cp,{align:"center",gap:"sm",paddingY:"xs",children:[/* @__PURE__ */f(Xp,{size:"sm",style:{color:t}}),/* @__PURE__ */f(vp,{as:"span",weight:"normal",style:{fontSize:"10px",opacity:.5},children:e?"Waiting for you to complete the action":"Thinking"})]}),hh=({message:e,isLastMessage:t,widgetState:n,accentColor:r})=>{const o="waiting-for-user"===(e.placeholderState||"thinking");return e.parts&&e.parts.length>0?/* @__PURE__ */g(fp,{gap:"sm",children:[e.parts.map((t,n)=>{if("text"===t.type){let e=(o=t.content,o.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,"")).trim();return e=e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\s+/g," ").trim(),e?/* @__PURE__ */f(vp,{as:"div",size:"xs",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e},`part-${n}`):null}return"progress"===t.type?"done"===t.toolName&&"done"===e.taskStatus?null:/* @__PURE__ */f(uh,{content:t.content,status:t.status||"running",accentColor:r,...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${n}`):null;var o}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */f(ph,{isWaitingForUser:o,accentColor:r})]}):e.isPlaceholder||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */f(ph,{isWaitingForUser:o,accentColor:r}):/* @__PURE__ */f(ku,{})},mh=({status:e,accentColor:t})=>{switch(e){case"done":/* @__PURE__ */return f(up,{name:"checkCircle",style:{color:t,flexShrink:0},size:14});case"failed":/* @__PURE__ */return f(up,{name:"exclamationCircle",style:{color:k(t,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return f(up,{name:"circle",style:{color:k(t,.5),flexShrink:0},size:14});default:/* @__PURE__ */return f(Xp,{size:"sm",style:{color:t}})}},fh=({stream:e})=>{const t=u(null),n=u(null),[r,o]=p(!1),[i,s]=p(!1);if(a(()=>{if(t.current&&e){const r=t.current;o(!1),s(!1),n.current&&(n.current.catch(()=>{}),n.current=null),r.srcObject=e;const i=()=>{o(!0)},a=()=>{s(!0),o(!1)};r.addEventListener("loadedmetadata",i),r.addEventListener("error",a);const l=r.play();return n.current=l,l.then(()=>{o(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&s(!0),n.current=null}),()=>{r.removeEventListener("loadedmetadata",i),r.removeEventListener("error",a)}}return()=>{n.current&&(n.current.catch(()=>{}),n.current=null),t.current&&(t.current.srcObject=null),o(!1),s(!1)}},[e]),!e)return null;const l="8px";/* @__PURE__ */
40
40
  return g(ku,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:`${l} ${l} 0 0`,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!r&&!i&&/* @__PURE__ */f(cp,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:"#111827",borderRadius:`${l} ${l} 0 0`,zIndex:10,transition:"opacity 300ms",opacity:r?0:1},children:/* @__PURE__ */g(cp,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */g(ku,{position:"relative",style:{width:"32px",height:"32px"},children:[/* @__PURE__ */f(ku,{position:"absolute",inset:"0",rounded:"full",animate:"spin",style:{border:"2px solid white",borderTopColor:"transparent"}}),/* @__PURE__ */f(ku,{position:"absolute",inset:"0",rounded:"full",animate:"spin",style:{border:"2px solid transparent",borderRightColor:"white",animationDirection:"reverse",animationDuration:"0.8s"}})]}),/* @__PURE__ */f(vp,{as:"span",size:"xs",weight:"medium",style:{color:"rgba(255,255,255,0.7)"},children:"Loading stream..."})]})}),i&&/* @__PURE__ */f(cp,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:"#111827",borderRadius:`${l} ${l} 0 0`,zIndex:10},children:/* @__PURE__ */g(cp,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",paddingLeft:"16px",paddingRight:"16px"},children:[/* @__PURE__ */f(up,{name:"alertCircle",size:32,style:{color:"#9ca3af"}}),/* @__PURE__ */f(vp,{as:"span",size:"xs",weight:"medium",style:{color:"rgba(255,255,255,0.7)"},children:"Failed to load stream"})]})}),
41
41
  /* @__PURE__ */f(th,{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:`${l} ${l} 0 0`,transition:"opacity 500ms",opacity:r?1:0,minHeight:"120px",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"}}),r&&!i&&/* @__PURE__ */g(cp,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"9999px",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px rgba(31, 41, 55, 0.4)"},children:[/* @__PURE__ */g(cp,{position:"relative",align:"center",justify:"center",children:[/* @__PURE__ */f(ku,{position:"absolute",rounded:"full",animate:"ping",style:{width:"8px",height:"8px",backgroundColor:"white",opacity:.75}}),/* @__PURE__ */f(ku,{position:"relative",rounded:"full",style:{width:"6px",height:"6px",backgroundColor:"white"}})]}),/* @__PURE__ */f(vp,{as:"span",size:"xs",weight:"semibold",style:{color:"white",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),