@marketrix.ai/widget 3.2.178 → 3.2.180

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.
@@ -1 +1 @@
1
- {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/MessageList.tsx"],"names":[],"mappings":"AACA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAmBhE,UAAU,gBAAgB;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,WAAW,GAAI,6FAOzB,gBAAgB,4CAgKlB,CAAC"}
1
+ {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/MessageList.tsx"],"names":[],"mappings":"AACA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkBhE,UAAU,gBAAgB;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,WAAW,GAAI,6FAOzB,gBAAgB,4CA4JlB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThinkingIndicator.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/ThinkingIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,UAAU,sBAAsB;IAC9B,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAU9D,CAAC"}
1
+ {"version":3,"file":"ThinkingIndicator.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/ThinkingIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,UAAU,sBAAsB;IAC9B,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAS9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ChatView.d.ts","sourceRoot":"","sources":["../../../../src/components/views/ChatView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoC9E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,WAAW,EAAE,eAAe,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,eAAe,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,OAAO,KACtB,IAAI,CAAC;IACV,SAAS,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC3C,YAAY,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAC7C,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC5E,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,qBAAqB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,iEAAiE;IACjE,qBAAqB,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACpE,oBAAoB,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACnE,6DAA6D;IAC7D,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CAC/D;AAwBD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAgL5C,CAAC"}
1
+ {"version":3,"file":"ChatView.d.ts","sourceRoot":"","sources":["../../../../src/components/views/ChatView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqC9E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,WAAW,EAAE,eAAe,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,eAAe,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,OAAO,KACtB,IAAI,CAAC;IACV,SAAS,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC3C,YAAY,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAC7C,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC5E,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,qBAAqB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,iEAAiE;IACjE,qBAAqB,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACpE,oBAAoB,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACnE,6DAA6D;IAC7D,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CAC/D;AAwBD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA8K5C,CAAC"}
package/dist/widget.mjs CHANGED
@@ -15,9 +15,9 @@ return f(ku,{className:"fixed",style:{zIndex:b,maxWidth:"420px",opacity:l?0:1,tr
15
15
  return g(ku,{ref:_,className:`${O} ${C?"":z} ${S?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:p,pointerEvents:e?"none":"auto",...R,...C},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:[w&&/* @__PURE__ */f(ku,{className:v,"aria-hidden":!0}),b&&!S&&/* @__PURE__ */f(lp,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},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 "+(h.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:"bare",onClick:()=>{Date.now()<M.current||i()},onDragStart:e=>e.preventDefault(),onPointerDown:I,onPointerMove:E,onPointerUp:A,onPointerCancel:T,className:"relative z-10 w-14 h-14 min-w-14",style:{touchAction:"none",cursor:S?"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:l,backgroundColor:e?a:s,boxShadow:Ep},children:[w&&/* @__PURE__ */f("svg",{className:x,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:k+1,ry:k+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:l,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 ${h.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:c,color:d},children:[/* @__PURE__ */f(vp,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */f(ku,{"aria-hidden":!0,className:`absolute top-full ${h.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:c}})]})]})},Pp="3.2.178";function Lp(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 Dp(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function $p(e,t,n){return Math.min(Math.max(e,t),n)}function jp(e,t,n,r,i){const o={"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:i-n,cursor:o[e]};case"bottom-left":return{dx:t-r,dy:i-n,cursor:o[e]};case"top-right":return{dx:r-t,dy:n-i,cursor:o[e]};case"top-left":return{dx:t-r,dy:n-i,cursor:o[e]}}}var Fp={live:"inline-flex items-center gap-1",status:"inline-flex items-center text-[9px] font-medium px-1.5 py-0.5 rounded"},Up=i(function({variant:e,className:t,style:n,children:r,...i},o){/* @__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 ${h.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:c,color:d},children:[/* @__PURE__ */f(vp,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */f(ku,{"aria-hidden":!0,className:`absolute top-full ${h.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:c}})]})]})},Pp="3.2.180";function Lp(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 Dp(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function $p(e,t,n){return Math.min(Math.max(e,t),n)}function jp(e,t,n,r,i){const o={"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:i-n,cursor:o[e]};case"bottom-left":return{dx:t-r,dy:i-n,cursor:o[e]};case"top-right":return{dx:r-t,dy:n-i,cursor:o[e]};case"top-left":return{dx:t-r,dy:n-i,cursor:o[e]}}}var Fp={live:"inline-flex items-center gap-1",status:"inline-flex items-center text-[9px] font-medium px-1.5 py-0.5 rounded"},Up=i(function({variant:e,className:t,style:n,children:r,...i},o){/* @__PURE__ */
19
19
  return g("span",{...i,ref:o,className:yu(Fp[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]})}),Bp=i(function({className:e,style:t,children:n,...r},i){/* @__PURE__ */
20
- return f("div",{...r,ref:i,className:yu(e),style:{padding:"10px 16px",borderRadius:"var(--radius-xl, 12px)",border:"1px solid transparent",backgroundColor:"var(--card)",boxShadow:Sp,...t},children:n})});var Wp=n(null);function Gp(e){const t=s(Wp);if(!t)throw new Error(`${e} must be used within Dialog`);return t}function Hp({children:e,onOpenChange:t,open:n}){const{isOpen:r,setIsOpen:i}=function({defaultOpen:e=!1,onOpenChange:t,open:n}){const[r,i]=p(e),s=void 0!==n;return{isOpen:s?n:r,setIsOpen:o(e=>{s||i(e),t?.(e)},[s,t])}}({onOpenChange:t,open:n}),s=l(),a=l(),c=l(),u=d(()=>({contentId:s,descriptionId:c,open:r,setOpen:i,titleId:a}),[s,c,r,i,a]);/* @__PURE__ */
20
+ return f("div",{...r,ref:i,className:yu(e),style:{padding:"8px 12px",borderRadius:"var(--radius-xl, 12px)",border:"1px solid transparent",backgroundColor:"#ffffff",boxShadow:Sp,...t},children:n})});var Wp=n(null);function Gp(e){const t=s(Wp);if(!t)throw new Error(`${e} must be used within Dialog`);return t}function Hp({children:e,onOpenChange:t,open:n}){const{isOpen:r,setIsOpen:i}=function({defaultOpen:e=!1,onOpenChange:t,open:n}){const[r,i]=p(e),s=void 0!==n;return{isOpen:s?n:r,setIsOpen:o(e=>{s||i(e),t?.(e)},[s,t])}}({onOpenChange:t,open:n}),s=l(),a=l(),c=l(),u=d(()=>({contentId:s,descriptionId:c,open:r,setOpen:i,titleId:a}),[s,c,r,i,a]);/* @__PURE__ */
21
21
  return f(Wp.Provider,{value:u,children:e})}function Zp({children:e,className:t,onKeyDown:n,...r}){const i=Gp("DialogContent");return a(()=>{if(!i.open)return;const e=e=>{"Escape"===e.key&&i.setOpen(!1)};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[i]),i.open?/* @__PURE__ */f("div",{...r,"aria-describedby":i.descriptionId,"aria-labelledby":i.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:i.contentId,onKeyDown:e=>{n?.(e),e.defaultPrevented||"Escape"!==e.key||i.setOpen(!1)},role:"dialog",tabIndex:-1,children:e}):null}function Vp({className:e,...t}){const n=Gp("DialogTitle");/* @__PURE__ */
22
22
  return f("h2",{...t,className:yu("text-lg font-semibold text-card-foreground mb-2",e),id:n.titleId})}function qp({className:e,...t}){const n=Gp("DialogDescription");/* @__PURE__ */
23
23
  return f("p",{...t,className:yu("text-sm text-muted-foreground mb-4",e),id:n.descriptionId})}function Jp({children:e,className:t,onClick:n,...r}){const i=Gp("DialogClose");/* @__PURE__ */
@@ -34,27 +34,26 @@ return g(lp,{role:"tab","aria-selected":r,"aria-controls":`view-${e.id}`,id:`tab
34
34
  return f(sh,{variant:"info",open:e,onClose:t,title:`Widget v${n.version} (${o})`,rows:r,status:i})};function ch({onScreenSharingChange:e,onStartScreenShareRef:t,onStopScreenShareRef:n,onAddMessage:r,onUpdateMessage:i,onRemoveMessage:o,onSendMessage:s,pendingMessage:l,setPendingMessage:c}){const[d,h]=p(!1),[m,f]=p(null),[g,y]=p(null),[w,b]=p(null),[v,x]=p(!1),k=u(d),_=u(g),S=u(r),C=u(o),I=u(e);a(()=>{k.current=d},[d]),a(()=>{_.current=g},[g]),a(()=>{S.current=r},[r]),a(()=>{C.current=o},[o]),a(()=>{I.current=e},[e]),a(()=>{const e=()=>{const e=Vc(),t=k.current,n=_.current;if(e!==t&&(k.current=e,h(e),I.current?.(e)),t&&!e&&n){C.current?.(n);const e=zc("Stopped screenshare","show","user","stopped-sharing");S.current(e),y(null)}};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[]);const E=()=>{x(!0)},A=()=>{Hc&&(Hc.getTracks().forEach(e=>e.stop()),Hc=null),h(!1),f(null),e?.(!1),g&&o&&o(g),r(zc("Stopped screenshare","show","user","stopped-sharing")),y(null)};return a(()=>(t&&(t.current=E),n&&(n.current=A),()=>{t&&(t.current=null),n&&(n.current=null)})),{isScreenSharing:d,screenStream:m,showScreenAccessDialog:v,handleScreenAccessDialogAllow:async()=>{x(!1);try{const t=await Zc();h(!0),f(t),e?.(!0),r(Oc("show"));const n=Rc(t,"show");y(n.id),r(n)}catch(t){h(!1),f(null),e?.(!1)}},handleScreenAccessDialogDeny:()=>{x(!1)},handleScreenAccessAllow:async()=>{try{const t=await Zc();h(!0),f(t),e?.(!0),w&&(i(w,{screenShareStatus:"allowed"}),b(null)),r(Oc("show"));const n=Rc(t,"show");if(y(n.id),r(n),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}catch(t){if(h(!1),f(null),e?.(!1),w&&(i(w,{screenShareStatus:"denied"}),b(null)),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}},handleScreenAccessDeny:()=>{if(w&&(i(w,{screenShareStatus:"denied"}),b(null)),l){const e=l;c(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}},requestScreenAccess:e=>{if(w)return;const t=function(e){const t="Can I take a look at your screen?";return{id:`screen-access-request-${Date.now()}`,content:t,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:e,isScreenAccessRequest:!0,parts:[{type:"text",content:t}]}}(e);b(t.id),r(t)}}}function dh(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}var uh=t.forwardRef(function({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:i,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=o(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=o(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),b=Boolean(e.trim())&&!l;/* @__PURE__ */
35
35
  return g(fp,{className:"rounded-xl border border-border overflow-hidden focus-within:border-foreground-faint transition-colors",children:[/* @__PURE__ */f(th,{ref:dh(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 pt-1 pb-1.5",children:[/* @__PURE__ */f(cp,{className:"items-center gap-1",children:r.map(e=>/* @__PURE__ */g(Qp,{active:i===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})})]})]})}),ph=({variant:e,message:t})=>{const n="error"===e,r="loading"===e;/* @__PURE__ */
36
36
  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(eh,{size:"lg"}),/* @__PURE__ */f(vp,{as:"p",size:"sm",align:"center",children:t})]})},hh=({content:e,status:t="pending",hideIcon:n=!1,textStyle:r="default"})=>{const{config:i}=Qc(),o=i.widget_accent_color;/* @__PURE__ */
37
- return g(cp,{align:"start",gap:"md",children:[!n&&(()=>{switch(t){case"completed":/* @__PURE__ */return f(up,{name:"checkCircle",style:{color:o,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(eh,{size:"sm",style:{color:o,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"===r?.5:1},children:e})]})},mh=({isWaitingForUser:e})=>{const{config:t}=Qc();/* @__PURE__ */
38
- return g(cp,{align:"center",gap:"sm",paddingY:"xs",children:[/* @__PURE__ */f(eh,{size:"sm",style:{color:t.widget_accent_color}}),/* @__PURE__ */f(vp,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]})},fh=({message:e,isLastMessage:t})=>{const{state:n}=Qc(),r="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=(r=t.content,r.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:"sm",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(hh,{content:t.content,status:t.status||"running",...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${n}`):null;var r}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */f(mh,{isWaitingForUser:r})]}):e.isPlaceholder||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */f(mh,{isWaitingForUser:r}):e.content?/* @__PURE__ */f(vp,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e.content}):/* @__PURE__ */f(ku,{})},gh=({status:e})=>{const{config:t}=Qc(),n=t.widget_accent_color;switch(e){case"done":/* @__PURE__ */return f(up,{name:"checkCircle",style:{color:n,flexShrink:0},size:14});case"failed":/* @__PURE__ */return f(up,{name:"exclamationCircle",style:{color:k(n,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return f(up,{name:"circle",style:{color:k(n,.5),flexShrink:0},size:14});default:/* @__PURE__ */return f(eh,{size:"sm",style:{color:n}})}},yh="8px 8px 0 0",wh="#111827",bh="rgba(255,255,255,0.7)",vh=({stream:e})=>{const t=u(null),n=u(null),[r,i]=p(!1),[o,s]=p(!1);return a(()=>{if(t.current&&e){const r=t.current;i(!1),s(!1),n.current&&(n.current.catch(()=>{}),n.current=null),r.srcObject=e;const o=()=>{i(!0)},a=()=>{s(!0),i(!1)};r.addEventListener("loadedmetadata",o),r.addEventListener("error",a);const l=r.play();return n.current=l,l.then(()=>{i(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&s(!0),n.current=null}),()=>{r.removeEventListener("loadedmetadata",o),r.removeEventListener("error",a)}}return()=>{n.current&&(n.current.catch(()=>{}),n.current=null),t.current&&(t.current.srcObject=null),i(!1),s(!1)}},[e]),e?/* @__PURE__ */g(ku,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:yh,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&&!o&&/* @__PURE__ */f(cp,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:wh,borderRadius:yh,zIndex:10,transition:"opacity 300ms",opacity:r?0:1},children:/* @__PURE__ */g(cp,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */f(eh,{size:"lg",style:{color:"white"}}),/* @__PURE__ */f(vp,{as:"span",size:"xs",weight:"medium",style:{color:bh},children:"Loading stream..."})]})}),o&&/* @__PURE__ */f(cp,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:wh,borderRadius:yh,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:bh},children:"Failed to load stream"})]})}),
37
+ return g(cp,{align:"start",gap:"md",children:[!n&&(()=>{switch(t){case"completed":/* @__PURE__ */return f(up,{name:"checkCircle",style:{color:o,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(eh,{size:"sm",style:{color:o,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"===r?.5:1},children:e})]})},mh=({isWaitingForUser:e})=>/* @__PURE__ */g(cp,{align:"center",gap:"sm",paddingY:"xs",className:"text-foreground-faint",children:[/* @__PURE__ */f(eh,{size:"sm"}),/* @__PURE__ */f(vp,{as:"span",size:"xs",weight:"normal",children:e?"Waiting for you to complete the action":"Thinking"})]}),fh=({message:e,isLastMessage:t})=>{const{state:n}=Qc(),r="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=(r=t.content,r.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:"sm",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(hh,{content:t.content,status:t.status||"running",...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${n}`):null;var r}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */f(mh,{isWaitingForUser:r})]}):e.isPlaceholder||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */f(mh,{isWaitingForUser:r}):e.content?/* @__PURE__ */f(vp,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e.content}):/* @__PURE__ */f(ku,{})},gh=({status:e})=>{const{config:t}=Qc(),n=t.widget_accent_color;switch(e){case"done":/* @__PURE__ */return f(up,{name:"checkCircle",style:{color:n,flexShrink:0},size:14});case"failed":/* @__PURE__ */return f(up,{name:"exclamationCircle",style:{color:k(n,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return f(up,{name:"circle",style:{color:k(n,.5),flexShrink:0},size:14});default:/* @__PURE__ */return f(eh,{size:"sm",style:{color:n}})}},yh="8px 8px 0 0",wh="#111827",bh="rgba(255,255,255,0.7)",vh=({stream:e})=>{const t=u(null),n=u(null),[r,i]=p(!1),[o,s]=p(!1);return a(()=>{if(t.current&&e){const r=t.current;i(!1),s(!1),n.current&&(n.current.catch(()=>{}),n.current=null),r.srcObject=e;const o=()=>{i(!0)},a=()=>{s(!0),i(!1)};r.addEventListener("loadedmetadata",o),r.addEventListener("error",a);const l=r.play();return n.current=l,l.then(()=>{i(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&s(!0),n.current=null}),()=>{r.removeEventListener("loadedmetadata",o),r.removeEventListener("error",a)}}return()=>{n.current&&(n.current.catch(()=>{}),n.current=null),t.current&&(t.current.srcObject=null),i(!1),s(!1)}},[e]),e?/* @__PURE__ */g(ku,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:yh,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&&!o&&/* @__PURE__ */f(cp,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:wh,borderRadius:yh,zIndex:10,transition:"opacity 300ms",opacity:r?0:1},children:/* @__PURE__ */g(cp,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */f(eh,{size:"lg",style:{color:"white"}}),/* @__PURE__ */f(vp,{as:"span",size:"xs",weight:"medium",style:{color:bh},children:"Loading stream..."})]})}),o&&/* @__PURE__ */f(cp,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:wh,borderRadius:yh,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:bh},children:"Failed to load stream"})]})}),
39
38
  /* @__PURE__ */f(nh,{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:yh,transition:"opacity 500ms",opacity:r?1:0,minHeight:"120px",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"}}),r&&!o&&/* @__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"})]}),
40
39
  /* @__PURE__ */f(cp,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:yh,backgroundColor:"rgba(0,0,0,0)",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */f(ku,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */f(vp,{as:"div",size:"xs",weight:"medium",style:{color:"white"},children:"Screen Sharing Active"})})})]}):null},xh=({message:e,index:t,isLastMessage:n,onScreenAccessAllow:r,onScreenAccessDeny:i})=>{if(e.isSystemMessage)/* @__PURE__ */return f(cp,{justify:"center",align:"center",children:/* @__PURE__ */f(vp,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})},`message-${e.id}-${t}`);const o="user"===e.sender;/* @__PURE__ */
41
40
  return g(fp,{style:{marginTop:"10px"},role:"article","aria-roledescription":"message","aria-label":o?"You said…":"Agent says…",animate:n?"fadeIn":void 0,children:[/* @__PURE__ */g(cp,{align:"start",gap:"sm",width:"full",children:[
42
41
  /* @__PURE__ */f(cp,{shrink:!1,style:{width:"20px",height:"20px",marginTop:"6px"},children:!o&&/* @__PURE__ */f(Cu,{src:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20361%20360'%3e%3c!--%20Generator:%20Adobe%20Illustrator%2030.1.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%20136)%20--%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20display:%20none;%20fill:%20none;%20stroke:%20%23cdc9c2;%20stroke-width:%201.3px;%20}%20.st1%20{%20fill:%20%23fff;%20}%20.st2,%20.st3%20{%20fill:%20%237cffa6;%20}%20.st3%20{%20stroke:%20%237cffa6;%20stroke-width:%20.38px;%20}%20.st4%20{%20fill:%20%23101828;%20}%20%3c/style%3e%3c/defs%3e%3crect%20class='st4'%20x='.5'%20width='360'%20height='360'/%3e%3cpath%20class='st2'%20d='M83.37,209.58c15.35,0,27.8-12.45,27.8-27.8s-12.44-27.79-27.8-27.79-27.8,12.44-27.8,27.79,12.44,27.8,27.8,27.8Z'/%3e%3cpath%20class='st1'%20d='M85.86,68.28l152.45,223.44h67.29l-70.62-113.77,68.13-109.67h-67.29l-41.12,65.31-41.54-65.31h-67.29Z'/%3e%3cpath%20class='st3'%20d='M176.61,249.83l-35.08-51-57.82,92.71h66.85l26.05-41.7Z'/%3e%3crect%20class='st0'%20x='1.25'%20y='.65'%20width='358.7'%20height='358.7'%20rx='43.35'%20ry='43.35'/%3e%3c/svg%3e",alt:"Marketrix AI",size:20,style:{border:"none",outline:"none",display:"block",objectFit:"cover",backgroundColor:"transparent",borderRadius:"calc(var(--radius) * 0.6)"}})}),
43
42
  /* @__PURE__ */g(fp,{grow:!0,position:"relative",style:{padding:e.videoStream?"0":"8px 10px",borderRadius:"var(--radius)",boxShadow:Sp,border:"1px solid transparent",backgroundColor:o?"var(--primary)":void 0,color:o?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */f(vh,{stream:e.videoStream}),!e.videoStream&&/* @__PURE__ */f(fh,{message:e,isLastMessage:n}),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */g(cp,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */f(lp,{type:"button",variant:"primary",size:"sm",className:"rounded-full",onClick:()=>r?.(),children:"Yes"}),/* @__PURE__ */f(lp,{type:"button",variant:"secondary",size:"sm",className:"rounded-full",onClick:()=>i?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */f(vp,{as:"div",variant:"faint",size:"xs",style:{marginTop:"2px",fontStyle:"italic"},children:"allowed"===e.screenShareStatus?"Sure":"Check HTML Instead"}),!o&&e.taskStatus&&/* @__PURE__ */f(cp,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */f(gh,{status:e.taskStatus})})]}),
44
- /* @__PURE__ */f(cp,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */f(vp,{as:"div",variant:"faint",style:{marginTop:"2px",textAlign:"right",marginRight:"26px",fontSize:"10px"},children:S(e.timestamp)})]},`message-${e.id}-${t}`)},kh={padding:"6px",borderRadius:"9999px",boxShadow:Ap,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},_h=({messages:e,messagesEndRef:t,config:n,onScreenAccessAllow:r,onScreenAccessDeny:i,onClearChat:o})=>{const{config:s,state:l,isPreviewMode:c}=Qc({config:n}),[h,m]=p(!1),[y,w]=p(!1),b=u(null),v=d(()=>({id:"welcome",content:s.widget_body??"How can I help you today?",sender:"agent",timestamp:/* @__PURE__ */new Date,isPlaceholder:!1}),[s.widget_body]),x=d(()=>[v,...e],[v,e]),_=()=>{if(b.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=b.current;m(e>200),w(!(Math.abs(t-e-n)<50)&&t>n)}};return a(()=>{window.requestAnimationFrame(()=>{t.current&&(!c&&t.current.scrollIntoView({behavior:"auto"}),!c&&_())})},[e.length,c]),/* @__PURE__ */g(ku,{position:"relative",height:"full",children:[
43
+ /* @__PURE__ */f(cp,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */f(vp,{as:"div",variant:"faint",style:{marginTop:"2px",textAlign:"right",marginRight:"26px",fontSize:"10px"},children:S(e.timestamp)})]},`message-${e.id}-${t}`)},kh={boxShadow:Ap,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},_h=({messages:e,messagesEndRef:t,config:n,onScreenAccessAllow:r,onScreenAccessDeny:i,onClearChat:o})=>{const{config:s,state:l,isPreviewMode:c}=Qc({config:n}),[h,m]=p(!1),[y,w]=p(!1),b=u(null),v=d(()=>({id:"welcome",content:s.widget_body??"How can I help you today?",sender:"agent",timestamp:/* @__PURE__ */new Date,isPlaceholder:!1}),[s.widget_body]),x=d(()=>[v,...e],[v,e]),_=()=>{if(b.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=b.current;m(e>200),w(!(Math.abs(t-e-n)<50)&&t>n)}};return a(()=>{window.requestAnimationFrame(()=>{t.current&&(!c&&t.current.scrollIntoView({behavior:"auto"}),!c&&_())})},[e.length,c]),/* @__PURE__ */g(ku,{position:"relative",height:"full",children:[
45
44
  /* @__PURE__ */g(ku,{ref:b,onScroll:_,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:s.widget_background_color.includes("gradient")?"transparent":s.widget_background_color,backgroundImage:s.widget_background_color.includes("gradient")?s.widget_background_color:`linear-gradient(135deg, ${s.widget_background_color} 0%, ${s.widget_background_color} 100%)`,scrollbarColor:`${k(s.widget_border_color,.3)} ${k(s.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[0===e.length&&l.isLoading&&/* @__PURE__ */f(ph,{variant:"loading",message:"Connecting…"}),x.map((e,t)=>/* @__PURE__ */f(xh,{message:e,index:t,isLastMessage:t===x.length-1,onScreenAccessAllow:r,onScreenAccessDeny:i},`message-${e.id}-${t}`)),e.length>0&&o&&/* @__PURE__ */f(cp,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */f(lp,{type:"button",variant:"bare",onClick:()=>{const e=o();e instanceof Promise&&e.catch(e=>{})},children:/* @__PURE__ */f(vp,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
46
- /* @__PURE__ */f(ku,{ref:t},"scroll-anchor")]},"message-list-container"),h&&/* @__PURE__ */f(cp,{position:"absolute",justify:"center",style:{top:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */f(lp,{type:"button",variant:"secondary",size:"sm",onClick:()=>{b.current?.scrollTo({top:0,behavior:"smooth"})},style:kh,title:"Scroll to top","aria-label":"Scroll to top",children:/* @__PURE__ */f(up,{name:"arrowUp",size:10,style:{color:s.widget_accent_color}})})}),y&&/* @__PURE__ */f(cp,{position:"absolute",justify:"center",style:{bottom:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */f(lp,{type:"button",variant:"secondary",size:"sm",onClick:()=>{t.current&&!c&&t.current.scrollIntoView({behavior:"smooth"})},style:kh,title:"Scroll to bottom","aria-label":"Scroll to bottom",children:/* @__PURE__ */f(up,{name:"arrowDown",size:10,style:{color:s.widget_accent_color}})})})]})},Sh=class extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){}render(){return this.state.hasError?/* @__PURE__ */f(vp,{as:"div",size:"xs",align:"center",style:{padding:"16px",color:"var(--muted-foreground)"},children:"Something went wrong displaying messages. Please refresh."}):this.props.children}},Ch={show:"mousePointerClick",tell:"chatBubble",do:"ticktick"},Ih=["tell","show","do"];var Eh=({config:e,messages:t,currentMode:n,isTaskRunning:r=!1,taskProgress:i=[],onSendMessage:o,onSetMode:s,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onStopTask:d,onClearChat:h,onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,messageInputRef:b})=>{const[v,x]=p(""),_=u(null),[S,I]=p(null),{isScreenSharing:E,showScreenAccessDialog:A,handleScreenAccessDialogAllow:T,handleScreenAccessDialogDeny:M,handleScreenAccessAllow:z,handleScreenAccessDeny:O,requestScreenAccess:R}=ch({onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onSendMessage:o,pendingMessage:S,setPendingMessage:I}),N=e;/* @__PURE__ */
45
+ /* @__PURE__ */f(ku,{ref:t},"scroll-anchor")]},"message-list-container"),h&&/* @__PURE__ */f(cp,{position:"absolute",justify:"center",style:{top:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */f(mp,{variant:"secondary",size:"sm",label:"Scroll to top",onClick:()=>{b.current?.scrollTo({top:0,behavior:"smooth"})},style:kh,children:/* @__PURE__ */f(up,{name:"arrowUp",size:10,style:{color:s.widget_accent_color}})})}),y&&/* @__PURE__ */f(cp,{position:"absolute",justify:"center",style:{bottom:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */f(mp,{variant:"secondary",size:"sm",label:"Scroll to bottom",onClick:()=>{t.current&&!c&&t.current.scrollIntoView({behavior:"smooth"})},style:kh,children:/* @__PURE__ */f(up,{name:"arrowDown",size:10,style:{color:s.widget_accent_color}})})})]})},Sh=class extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){}render(){return this.state.hasError?/* @__PURE__ */f(vp,{as:"div",size:"xs",align:"center",style:{padding:"16px",color:"var(--muted-foreground)"},children:"Something went wrong displaying messages. Please refresh."}):this.props.children}},Ch={show:"mousePointerClick",tell:"chatBubble",do:"ticktick"},Ih=["tell","show","do"];var Eh=({config:e,messages:t,currentMode:n,isTaskRunning:r=!1,taskProgress:i=[],onSendMessage:o,onSetMode:s,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onStopTask:d,onClearChat:h,onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,messageInputRef:b})=>{const[v,x]=p(""),_=u(null),[S,I]=p(null),{isScreenSharing:E,showScreenAccessDialog:A,handleScreenAccessDialogAllow:T,handleScreenAccessDialogDeny:M,handleScreenAccessAllow:z,handleScreenAccessDeny:O,requestScreenAccess:R}=ch({onScreenSharingChange:m,onStartScreenShareRef:y,onStopScreenShareRef:w,onAddMessage:a,onUpdateMessage:l,onRemoveMessage:c,onSendMessage:o,pendingMessage:S,setPendingMessage:I}),N=e;/* @__PURE__ */
47
46
  return g(fp,{height:"full",id:"view-chat",role:"tabpanel","aria-labelledby":"tab-chat",children:[A&&/* @__PURE__ */f(sh,{variant:"confirm",open:A,onClose:M,title:"Can I take a look at your screen?",description:"By allowing screen access, Marketrix can understand your current context to guide you better and complete tasks on your behalf.",onConfirm:T,confirmLabel:"Yes",cancelLabel:"No"}),
48
47
  /* @__PURE__ */f(ku,{grow:!0,overflow:"hidden",paddingY:"xs",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */f(Sh,{children:/* @__PURE__ */f(_h,{messages:t,messagesEndRef:_,config:e,onScreenAccessAllow:z,onScreenAccessDeny:O,onClearChat:h})})}),
49
- /* @__PURE__ */g(ku,{shrink:!1,rounded:"theme",margin:"md",style:{marginTop:"auto",backgroundColor:"var(--card)"},children:[r&&i.length>0&&/* @__PURE__ */g(ku,{rounded:!0,overflowY:"auto",style:{margin:"0 8px 8px",padding:"8px",maxHeight:"128px",backgroundColor:k(e.widget_background_color??"#fff",.8),borderColor:e.widget_border_color,borderWidth:"1px",borderStyle:"solid"},children:[/* @__PURE__ */g(vp,{as:"div",weight:"semibold",style:{marginBottom:"4px",color:e.widget_text_color},children:["Task Progress (",i.length," steps)"]}),/* @__PURE__ */f(fp,{gap:"xs",children:i.map((t,n)=>/* @__PURE__ */g(cp,{align:"start",gap:"sm",style:{fontSize:"12px",opacity:.8,color:e.widget_text_color},children:[
50
- /* @__PURE__ */g(vp,{as:"span",weight:"medium",children:["Step ",t.step,":"]})," ",t.tool_name,t.tool_params&&Object.keys(t.tool_params).length>0&&/* @__PURE__ */g(vp,{as:"span",style:{opacity:.7,marginLeft:"4px"},children:["(",Object.keys(t.tool_params).join(", "),")"]})]},n))})]}),/* @__PURE__ */f(ku,{paddingY:"sm",paddingX:"md",style:{backgroundColor:"transparent"},children:/* @__PURE__ */f(uh,{ref:b,value:v,onChange:x,onSubmit:()=>{const r=t.some(e=>e.isPlaceholder);if(v.trim()&&!r){const t=v.trim();x(""),a(Tc(t,n)),!1===e.use_screenshare||"show"!==n&&"do"!==n||E?o(t,n,void 0,void 0,!0):(I({content:t,mode:n,alreadyAdded:!0}),R(n))}},modes:Ih.filter(e=>function(e){return[...e.widget_feature_show?["show"]:[],...e.widget_feature_tell?["tell"]:[],...e.widget_feature_do?["do"]:[]]}(N).includes(e)).map(e=>({id:e,icon:Ch[e],label:C(e)})),activeMode:n,onModeChange:e=>(e=>{e!==n&&(a(zc(`Switched to ${{show:"Show",tell:"Tell",do:"Do"}[e]} mode`,e,"agent","mode-change")),s(e))})(e),disabled:t.some(e=>e.isPlaceholder),taskRunning:r,onStop:()=>{qc.cleanup(),d?.()}})})]})]})},Ah=[{id:"show-add-product",text:"Show me how to add a new product",icon:/* @__PURE__ */f(up,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"show-login",text:"Show me how to login",icon:/* @__PURE__ */f(up,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"do-login",text:"Do the login process for me",icon:/* @__PURE__ */f(up,{name:"ticktick",size:16}),type:"do",isShow:!1},{id:"show-revenue",text:"Show me the revenue metrics",icon:/* @__PURE__ */f(up,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",icon:/* @__PURE__ */f(up,{name:"chatBubble",size:20}),type:"tell",isShow:!1}];function Th(e){switch(e){case"do":/* @__PURE__ */return f(up,{name:"ticktick",size:12});case"show":/* @__PURE__ */return f(up,{name:"mousePointerClick",size:12});default:/* @__PURE__ */return f(up,{name:"chatBubble",size:12})}}var Mh=({actions:e,onActionClick:t})=>{const{config:n}=Qc();return 0===e.length?null:/* @__PURE__ */f(fp,{gap:"sm",children:e.map((e,r)=>/* @__PURE__ */f(lp,{variant:"ghost",size:"sm",full:!0,onClick:n=>t(e,n),className:"hover:bg-primary hover:text-primary-foreground hover:border-primary",style:{backgroundColor:"var(--secondary-bg)",color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px",boxShadow:Sp},children:/* @__PURE__ */f(vp,{as:"span",weight:"normal",style:{lineHeight:1},children:"show"===e.type?/* @__PURE__ */g(m,{children:["Show me ",e.text.replace(/^Show me\s*/i,"")]}):"do"===e.type?/* @__PURE__ */g(m,{children:["Do ",e.text.replace(/^Do\s*/i,"")]}):e.text})},`welcome-chip-${e.id}-${r}`))})},zh=({config:e,messages:t,onNavigateToChat:n,onChipClick:r})=>{const i=function(e){const t=e.widget_chips;if(t&&Array.isArray(t)&&t.length>0){const e=/* @__PURE__ */new Set;return t.map((t,n)=>{const r=t.chip_text||t.question||"",i=t.chip_mode||t.type||"tell",o="show"===i||"tell"===i||"do"===i?i:"tell",s=`chip-${r.replace(/\s+/g,"-").toLowerCase()}-${n}`;let a=s,l=0;for(;e.has(a);)l++,a=`${s}-${l}`;return e.add(a),{id:a,text:r,icon:Th(o),type:o,isShow:"show"===o}})}return Ah}(e);/* @__PURE__ */
48
+ /* @__PURE__ */g(Bp,{style:{margin:"0 12px 12px 12px",marginTop:"auto"},children:[r&&i.length>0&&/* @__PURE__ */g(ku,{rounded:!0,overflowY:"auto",style:{margin:"0 8px 8px",padding:"8px",maxHeight:"128px",backgroundColor:k(e.widget_background_color??"#fff",.8),borderColor:e.widget_border_color,borderWidth:"1px",borderStyle:"solid"},children:[/* @__PURE__ */g(vp,{as:"div",weight:"semibold",style:{marginBottom:"4px",color:e.widget_text_color},children:["Task Progress (",i.length," steps)"]}),/* @__PURE__ */f(fp,{gap:"xs",children:i.map((t,n)=>/* @__PURE__ */g(cp,{align:"start",gap:"sm",style:{fontSize:"12px",opacity:.8,color:e.widget_text_color},children:[
49
+ /* @__PURE__ */g(vp,{as:"span",weight:"medium",children:["Step ",t.step,":"]})," ",t.tool_name,t.tool_params&&Object.keys(t.tool_params).length>0&&/* @__PURE__ */g(vp,{as:"span",style:{opacity:.7,marginLeft:"4px"},children:["(",Object.keys(t.tool_params).join(", "),")"]})]},n))})]}),/* @__PURE__ */f(uh,{ref:b,value:v,onChange:x,onSubmit:()=>{const r=t.some(e=>e.isPlaceholder);if(v.trim()&&!r){const t=v.trim();x(""),a(Tc(t,n)),!1===e.use_screenshare||"show"!==n&&"do"!==n||E?o(t,n,void 0,void 0,!0):(I({content:t,mode:n,alreadyAdded:!0}),R(n))}},modes:Ih.filter(e=>function(e){return[...e.widget_feature_show?["show"]:[],...e.widget_feature_tell?["tell"]:[],...e.widget_feature_do?["do"]:[]]}(N).includes(e)).map(e=>({id:e,icon:Ch[e],label:C(e)})),activeMode:n,onModeChange:e=>(e=>{e!==n&&(a(zc(`Switched to ${{show:"Show",tell:"Tell",do:"Do"}[e]} mode`,e,"agent","mode-change")),s(e))})(e),disabled:t.some(e=>e.isPlaceholder),taskRunning:r,onStop:()=>{qc.cleanup(),d?.()}})]})]})},Ah=[{id:"show-add-product",text:"Show me how to add a new product",icon:/* @__PURE__ */f(up,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"show-login",text:"Show me how to login",icon:/* @__PURE__ */f(up,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"do-login",text:"Do the login process for me",icon:/* @__PURE__ */f(up,{name:"ticktick",size:16}),type:"do",isShow:!1},{id:"show-revenue",text:"Show me the revenue metrics",icon:/* @__PURE__ */f(up,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",icon:/* @__PURE__ */f(up,{name:"chatBubble",size:20}),type:"tell",isShow:!1}];function Th(e){switch(e){case"do":/* @__PURE__ */return f(up,{name:"ticktick",size:12});case"show":/* @__PURE__ */return f(up,{name:"mousePointerClick",size:12});default:/* @__PURE__ */return f(up,{name:"chatBubble",size:12})}}var Mh=({actions:e,onActionClick:t})=>{const{config:n}=Qc();return 0===e.length?null:/* @__PURE__ */f(fp,{gap:"sm",children:e.map((e,r)=>/* @__PURE__ */f(lp,{variant:"ghost",size:"sm",full:!0,onClick:n=>t(e,n),className:"hover:bg-primary hover:text-primary-foreground hover:border-primary",style:{backgroundColor:"var(--secondary-bg)",color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px",boxShadow:Sp},children:/* @__PURE__ */f(vp,{as:"span",weight:"normal",style:{lineHeight:1},children:"show"===e.type?/* @__PURE__ */g(m,{children:["Show me ",e.text.replace(/^Show me\s*/i,"")]}):"do"===e.type?/* @__PURE__ */g(m,{children:["Do ",e.text.replace(/^Do\s*/i,"")]}):e.text})},`welcome-chip-${e.id}-${r}`))})},zh=({config:e,messages:t,onNavigateToChat:n,onChipClick:r})=>{const i=function(e){const t=e.widget_chips;if(t&&Array.isArray(t)&&t.length>0){const e=/* @__PURE__ */new Set;return t.map((t,n)=>{const r=t.chip_text||t.question||"",i=t.chip_mode||t.type||"tell",o="show"===i||"tell"===i||"do"===i?i:"tell",s=`chip-${r.replace(/\s+/g,"-").toLowerCase()}-${n}`;let a=s,l=0;for(;e.has(a);)l++,a=`${s}-${l}`;return e.add(a),{id:a,text:r,icon:Th(o),type:o,isShow:"show"===o}})}return Ah}(e);/* @__PURE__ */
51
50
  return g(fp,{height:"full",overflow:"hidden",id:"view-home",role:"tabpanel","aria-labelledby":"tab-home",children:[/* @__PURE__ */g(fp,{grow:!0,overflowY:"auto",padding:"lg",children:[/* @__PURE__ */g(ku,{style:{textAlign:"center",paddingTop:"8px",paddingBottom:"16px"},children:[/* @__PURE__ */f(vp,{as:"h2",size:"lg",weight:"semibold",children:e.widget_greeting??"Hey There!"}),/* @__PURE__ */f(vp,{as:"p",variant:"muted",size:"sm",style:{marginTop:"2px"},children:e.widget_body??"How can I help you today?"})]}),/* @__PURE__ */g(fp,{gap:"sm",children:[/* @__PURE__ */g(lp,{type:"button",variant:"primary",full:!0,onClick:n,"aria-label":"Ask a question",style:{paddingTop:"10px",paddingBottom:"10px"},children:[/* @__PURE__ */f(up,{name:"chat",size:16}),"Ask a question"]}),/* @__PURE__ */f(Mh,{actions:i,onActionClick:async(e,t)=>{t.preventDefault(),t.stopPropagation(),n(),r(e)}})]})]}),t.length>0&&/* @__PURE__ */g(Bp,{style:{margin:"0 12px 12px 12px"},children:[
52
51
  /* @__PURE__ */f(vp,{as:"p",size:"xs",weight:"semibold",style:{marginBottom:"2px"},children:"Recent conversation"}),
53
52
  /* @__PURE__ */f(vp,{as:"p",size:"xs",variant:"muted",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t[t.length-1].content||"Message"}),
54
53
  /* @__PURE__ */f(vp,{as:"p",size:"xs",variant:"muted",onClick:n,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},Oh=({children:e,direction:t})=>/* @__PURE__ */f(ku,{"data-view-transition":!0,"data-direction":t,style:{width:"100%",height:"100%"},children:e}),Rh=["top-left","top-right","bottom-left","bottom-right"];function Nh(e){const t=e.startsWith("top"),n=e.endsWith("left");return{position:"absolute",width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:t?"flex-start":"flex-end",justifyContent:n?"flex-start":"flex-end",cursor:t&&n||!t&&!n?"nwse-resize":"nesw-resize",top:t?0:void 0,bottom:t?void 0:0,left:n?0:void 0,right:n?void 0:0}}function Ph({onResizeStart:e}){/* @__PURE__ */
55
54
  return f(m,{children:Rh.map(t=>/* @__PURE__ */f("div",{role:"separator","aria-label":`Resize widget from ${t.replace("-"," ")}`,title:"Drag to resize",style:Nh(t),onMouseDown:e(t)},t))})}var Lh,Dh=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"},{id:"help",icon:"help",label:"Help"}],$h=({config:e,isOpen:t,isMinimized:n,messages:r,currentMode:i,isTaskRunning:s=!1,taskProgress:l=[],activeView:c,onClose:h,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:S,setActiveView:C})=>{const{config:I,isPreviewMode:E}=Qc({config:e}),A=d(()=>e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default"),[e.mtxId,e.mtxApp]),{widthPx:T,heightPx:M,onResizeStart:z,containerRef:O}=function(e,t,n,r,i){const s=d(()=>`marketrix_widget_size_${n}`,[n]),a=u({width:360,height:450}),l=u(null),[c,h]=p(()=>{if("undefined"==typeof localStorage)return{width:Dp(e),height:Dp(t)};const n=localStorage.getItem(s);if(n)try{const e=JSON.parse(n);if("number"==typeof e.width&&"number"==typeof e.height){const t=$p(e.width,280,600),n=$p(e.height,320,Math.floor(.85*window.innerHeight));return a.current={width:t,height:n},{width:t,height:n}}}catch{}const r=Dp(e),i=Dp(t);return a.current={width:r,height:i},{width:r,height:i}});a.current=c;const m=o(e=>t=>{if(t.preventDefault(),t.stopPropagation(),r||i)return;const n=t.clientX,o=t.clientY,c=a.current.width,d=a.current.height,{cursor:u}=jp(e,n,o,n,o);l.current&&(l.current.dataset.resizing="true");const p=t=>{const{dx:r,dy:i}=jp(e,n,o,t.clientX,t.clientY),s=Math.floor(.85*window.innerHeight),u={width:$p(c+r,280,600),height:$p(d+i,320,s)};a.current=u,l.current&&(l.current.style.width=`${u.width}px`,l.current.style.height=`${u.height}px`)},m=()=>{if(document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect="",l.current&&delete l.current.dataset.resizing,h({...a.current}),!i&&"undefined"!=typeof localStorage){const{width:e,height:t}=a.current;localStorage.setItem(s,JSON.stringify({width:e,height:t}))}};document.body.style.cursor=u,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",m)},[r,i,s]);return{width:c.width,height:c.height,widthPx:`${c.width}px`,heightPx:`${c.height}px`,onResizeStart:m,containerRef:l}}(I.widget_width,I.widget_height,A,n,E),R=u(null),[N,P]=p("forward"),L=u(c);a(()=>{L.current!==c&&(P("chat"===c?"forward":"back"),L.current=c)},[c]),function(e,t,n){const r=u(!1),i=u(null),s=o(()=>{const t=e.current;if(!t)return;const r=n?.focusTargetRef?.current;if(r)return void r.focus({preventScroll:!0});const i=Lp(t);i[0]&&i[0].focus({preventScroll:!0})},[e,n?.focusTargetRef]);a(()=>{if(!t)return r.current&&(i.current?.focus({preventScroll:!0}),i.current=null),void(r.current=!1);r.current||(i.current=document.activeElement||null),r.current=!0;const o=e.current;if(!o)return;s();const a=e=>{if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const t=Lp(o);if(0===t.length)return;const r=document.activeElement,i=t.indexOf(r);-1!==i&&(e.shiftKey?0===i&&(e.preventDefault(),t[t.length-1].focus()):i===t.length-1&&(e.preventDefault(),t[0].focus()))};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[t,e,s,n?.onEscape])}(O,t,{onEscape:h,focusTargetRef:"chat"===c?R:void 0});const D=I.widget_position,$=I.widget_position_z_index??40,j=(e=>{const t="20px",n="20px";switch(e){case"bottom_right":default:return{bottom:t,right:n};case"bottom_left":return{bottom:t,left:n};case"top_right":return{top:t,right:n};case"top_left":return{top:t,left:n}}})(D),[F,U]=p(!1),[B,W]=p(!1),G=u(null),H=u(null),Z=o(e=>{W(e),S?.(e)},[S]);if(!t)return null;const V=I.widget_background_color.includes("gradient")?I.widget_background_color:`linear-gradient(135deg, ${I.widget_background_color} 0%, ${I.widget_background_color} 100%)`,q={width:T,height:n?"48px":M,fontSize:I.widget_font_size,backgroundImage:V,zIndex:$},J=E?"absolute":"fixed",Y=E?D.includes("top")?{top:"20px",...D.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...D.includes("right")?{right:"20px"}:{left:"20px"}}:{},K=`${D.includes("top")?"top":"bottom"} ${D.includes("right")?"right":"left"}`,Q="chat"===c&&!1!==e.use_screenshare?()=>{B?H.current?.():G.current?.()}:void 0;/* @__PURE__ */
56
55
  return g(fp,{ref:O,position:J,rounded:"theme",border:!0,overflow:"hidden",style:{zIndex:$,backgroundImage:V,transformOrigin:K,...q,...E?Y:j,pointerEvents:"auto",scrollbarWidth:"thin",animation:"messenger-entrance 300ms cubic-bezier(0, 1.2, 1, 1)",boxShadow:Ip},children:[
57
- /* @__PURE__ */f(rh,{title:e.agent_name??"AI Agent",subtitle:n?void 0:e.agent_description??"How can I help?",minimized:n,onClose:h,controls:Q&&/* @__PURE__ */g(mp,{variant:"ghost",size:"sm",label:B?"Stop screen sharing":"Start screen sharing",onClick:Q,children:[B&&/* @__PURE__ */f(Up,{variant:"live",className:"absolute top-0.5 right-0.5"}),/* @__PURE__ */f(up,{name:"screenShare",size:16})]})}),!n&&/* @__PURE__ */g(m,{children:[/* @__PURE__ */f(ku,{grow:!0,overflow:"hidden",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */g(Oh,{direction:N,children:["home"===c&&/* @__PURE__ */f(zh,{config:e,messages:r,onNavigateToChat:()=>{P("forward"),C("chat")},onChipClick:e=>{b(Tc(e.text,e.type,"chip-message")),w(e.type),y(e.text,e.type,void 0,void 0,!0)}}),"chat"===c&&/* @__PURE__ */f(Eh,{config:e,messages:r,currentMode:i,isTaskRunning:s,taskProgress:l,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:Z,onStartScreenShareRef:G,onStopScreenShareRef:H,messageInputRef:R}),"help"===c&&/* @__PURE__ */g(fp,{id:"view-help",role:"tabpanel","aria-labelledby":"tab-help",height:"full",padding:"lg",children:[/* @__PURE__ */g(fp,{grow:!0,align:"center",justify:"center",gap:"sm",children:[/* @__PURE__ */f(up,{name:"help",size:32,className:"text-foreground-faint"}),/* @__PURE__ */f(vp,{size:"sm",variant:"muted",children:"Help – coming soon"})]}),/* @__PURE__ */g(Bp,{style:{margin:"0 0 4px 0"},children:[/* @__PURE__ */g(vp,{size:"xs",variant:"faint",style:{display:"block"},children:["Widget v",Pp]}),/* @__PURE__ */g(vp,{size:"xs",variant:"faint",style:{display:"block"},children:["API"," ",(()=>{try{return"connected"===Lc.getInstance().getStatus()?"connected":"disconnected"}catch{return"—"}})()]})]})]}),"news"===c&&/* @__PURE__ */g(fp,{id:"view-news",role:"tabpanel","aria-labelledby":"tab-news",height:"full",align:"center",justify:"center",gap:"sm",padding:"lg",children:[/* @__PURE__ */f(up,{name:"info",size:32,className:"text-foreground-faint"}),/* @__PURE__ */f(vp,{size:"sm",variant:"muted",children:"News – coming soon"})]})]},c)}),/* @__PURE__ */f(ih,{tabs:Dh,active:c,onChange:e=>{C(e)}})]}),!n&&!E&&/* @__PURE__ */f(Ph,{onResizeStart:z}),
56
+ /* @__PURE__ */f(rh,{title:e.agent_name??"AI Agent",subtitle:n?void 0:e.agent_description??"How can I help?",minimized:n,onClose:h,controls:Q&&/* @__PURE__ */g(mp,{variant:"ghost",size:"sm",label:B?"Stop screen sharing":"Start screen sharing",onClick:Q,children:[B&&/* @__PURE__ */f(Up,{variant:"live",className:"absolute top-0.5 right-0.5"}),/* @__PURE__ */f(up,{name:"screenShare",size:16})]})}),!n&&/* @__PURE__ */g(m,{children:[/* @__PURE__ */f(ku,{grow:!0,overflow:"hidden",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */g(Oh,{direction:N,children:["home"===c&&/* @__PURE__ */f(zh,{config:e,messages:r,onNavigateToChat:()=>{P("forward"),C("chat")},onChipClick:e=>{b(Tc(e.text,e.type,"chip-message")),w(e.type),y(e.text,e.type,void 0,void 0,!0)}}),"chat"===c&&/* @__PURE__ */f(Eh,{config:e,messages:r,currentMode:i,isTaskRunning:s,taskProgress:l,onSendMessage:y,onSetMode:w,onAddMessage:b,onUpdateMessage:v,onRemoveMessage:x,onStopTask:k,onClearChat:_,onScreenSharingChange:Z,onStartScreenShareRef:G,onStopScreenShareRef:H,messageInputRef:R}),"help"===c&&/* @__PURE__ */g(fp,{id:"view-help",role:"tabpanel","aria-labelledby":"tab-help",height:"full",padding:"lg",children:[/* @__PURE__ */g(fp,{grow:!0,align:"center",justify:"center",gap:"sm",children:[/* @__PURE__ */f(up,{name:"help",size:32,className:"text-foreground-faint"}),/* @__PURE__ */f(vp,{size:"sm",variant:"muted",children:"Help – coming soon"})]}),/* @__PURE__ */g(Bp,{style:{margin:"0 12px 12px 12px"},children:[/* @__PURE__ */g(vp,{size:"xs",variant:"faint",style:{display:"block"},children:["Widget v",Pp]}),/* @__PURE__ */g(vp,{size:"xs",variant:"faint",style:{display:"block"},children:["API"," ",(()=>{try{return"connected"===Lc.getInstance().getStatus()?"connected":"disconnected"}catch{return"—"}})()]})]})]}),"news"===c&&/* @__PURE__ */g(fp,{id:"view-news",role:"tabpanel","aria-labelledby":"tab-news",height:"full",align:"center",justify:"center",gap:"sm",padding:"lg",children:[/* @__PURE__ */f(up,{name:"info",size:32,className:"text-foreground-faint"}),/* @__PURE__ */f(vp,{size:"sm",variant:"muted",children:"News – coming soon"})]})]},c)}),/* @__PURE__ */f(ih,{tabs:Dh,active:c,onChange:e=>{C(e)}})]}),!n&&!E&&/* @__PURE__ */f(Ph,{onResizeStart:z}),
58
57
  /* @__PURE__ */f(lh,{isOpen:F,onClose:()=>U(!1),diagnosticData:{chatId:Pc.getChatId(),streamEndpoint:(()=>{const t=$c.getConfig()?.mtxApiHost||e.mtxApiHost;return t?`${t.replace(/\/$/,"")}/widget/stream`:null})(),connectionStatus:(()=>{try{return Lc.getInstance().getStatus()}catch{return"disconnected"}})(),applicationId:$c.getConfig()?.mtxApp,agentId:$c.getConfig()?.mtxAgent,version:Pp,build:"dev"}})]})},jh=class extends t.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){}render(){return this.state.hasError?null:this.props.children}},Fh=({config:e})=>{const[t,n]=p(!1),{state:r,actions:i,config:o,shouldShow:s,isPreviewMode:l,configValid:c}=Qc({config:e});var u;u=r.isOpen,a(()=>{if(!u)return;if(!window.matchMedia("(max-width: 767px)").matches)return;const e=document.documentElement,t=document.body,n=e.style.overflow,r=t.style.overflow;return e.style.overflow="hidden",t.style.overflow="hidden",()=>{e.style.overflow=n,t.style.overflow=r}},[u]);const[h,m]=p(e.widget_position??"bottom_right"),b=d(()=>`marketrix_widget_position_${e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}`,[e.mtxApp,e.mtxId]);a(()=>{m(o.widget_position??"bottom_right")},[o.widget_position]),a(()=>{if(l||"undefined"==typeof localStorage)return;const e=o.widget_position??"bottom_right",t=localStorage.getItem(b);"bottom_left"!==t&&"bottom_right"!==t&&"top_left"!==t&&"top_right"!==t?(localStorage.setItem(b,e),m(e)):m(t)},[l,b,o.widget_position]),a(()=>{if(r.isOpen||l||"default"!==o.widget_appearance)return void n(!1);const e=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(e)},[r.isOpen,l,o.widget_appearance]);if(!c)return null;if(!(l?e.widget_enabled??o.widget_enabled:s&&o.widget_enabled&&!1!==e.show_widget))return null;const v=(S=function(e={}){return E({...I,widget_background_color:e.widget_background_color??I.widget_background_color,widget_text_color:e.widget_text_color??I.widget_text_color,widget_border_color:e.widget_border_color??I.widget_border_color,widget_accent_color:e.widget_accent_color??I.widget_accent_color,widget_secondary_color:e.widget_secondary_color??I.widget_secondary_color,widget_border_radius:e.widget_border_radius??I.widget_border_radius,widget_font_size:e.widget_font_size??I.widget_font_size,widget_width:e.widget_width??I.widget_width,widget_height:e.widget_height??I.widget_height,widget_shadow:e.widget_shadow??I.widget_shadow,widget_animation_duration:e.widget_animation_duration??I.widget_animation_duration,widget_fade_duration:e.widget_fade_duration??I.widget_fade_duration})}(o),{"--background":S.color.background,"--foreground":S.color.foreground,"--card":S.color.background,"--card-foreground":S.color.foreground,"--popover":S.color.background,"--popover-foreground":S.color.foreground,"--primary":S.color.primary,"--foreground-muted":S.color.foregroundMuted,"--foreground-faint":S.color.foregroundFaint,"--border-muted":S.color.borderMuted,"--primary-foreground":S.color.primaryForeground,"--primary-hover":S.color.primaryHover,"--primary-muted":S.color.primaryMuted,"--secondary":S.color.secondary,"--secondary-foreground":S.color.secondaryForeground,"--secondary-bg":S.color.secondaryBg,"--secondary-hover":S.color.secondaryHover,"--muted":S.color.border,"--muted-foreground":S.color.secondary,"--accent":S.color.background,"--accent-foreground":S.color.foreground,"--border":S.color.border,"--input":S.color.border,"--ring":S.color.primary,"--radius":S.radius,"--shadow":S.shadow,"--duration-animation":S.motion.durationAnimation,"--duration-fade":S.motion.durationFade,"--widget-width":S.size.widgetWidth,"--widget-height":S.size.widgetHeight});var S;const C=Math.max(o.widget_position_z_index??0,y),A={...o,widget_position:h,widget_position_z_index:C,show_widget:e.show_widget,use_screenshare:e.use_screenshare},T=r.isLoading||r.isTaskRunning,M={...v,"--widget-z-index":C};/* @__PURE__ */
59
58
  return g(ku,{"data-marketrix-widget":!0,position:"relative",style:{...M,...l&&{width:"100%",height:"100%"}},"data-widget-mode":o?.widget_feature_human?"hybrid":"ai",children:[T&&/* @__PURE__ */f(ku,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${k(o.widget_accent_color,.72)}, inset 0 0 46px 10px ${k(o.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:w}}),
60
59
  /* @__PURE__ */f(jh,{children:/* @__PURE__ */f($h,{config:A,isOpen:r.isOpen,isMinimized:r.isMinimized,messages:r.messages,currentMode:r.currentMode,isTaskRunning:r.isTaskRunning,taskProgress:r.taskProgress,activeView:r.activeView,onClose:i.closeWidget,onSendMessage:i.sendMessage,onSetMode:i.setMode,onAddMessage:i.addMessage,onUpdateMessage:i.updateMessage,onRemoveMessage:i.removeMessage,onStopTask:i.stopTask,onClearChat:i.clearChatHistory,setActiveView:i.setActiveView})}),