1var lt=Object.defineProperty;var ct=(e,n,o)=>n in e?lt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o;var je=(e,n,o)=>ct(e,typeof n!="symbol"?n+"":n,o);import{r as l,j as t}from"./react-DT6guO4n.js";import{af as dt,a5 as Y,ag as pt,D as ut,w as ye,a as be,ah as me,R as ht,ai as mt,aj as ft,ak as gt,al as xt,am as yt,an as bt,ao as wt,ap as Ct,aq as vt,ar as It,as as _t,s as jt,at as kt,aa as Tt,au as St,C as Nt,H as At,J as Ht,av as Et,P as Mt,aw as Pt,ax as zt,ay as Dt,ac as Lt,ab as $t,U as Rt,az as Ot,aA as Wt}from"./_phosphor-icons_react-CxHS0iTv.js";import{u as Be,c as Bt,d as Ft,n as qt}from"./Navbar.styled-CqLaXfGf.js";import{fd as Qt,fe as Ut,n as D,aP as R,B as S,g as oe,d as Fe,e as J,aQ as we,ff as qe,e7 as Kt,fg as Gt,aX as Vt,fh as Yt,bP as Xt,bQ as Jt,L as Zt,cZ as re,aN as en,i as F,u as Qe}from"./main-BL5zgPyM.js";import{u as Z,b as L,f as tn,e as Ce}from"./react-query-CULkuBWQ.js";import{g as nn,b as on,c as sn,u as ee,d as an,e as rn,p as ln}from"./useAssistant-Db_BDwAf.js";import{C as cn,u as dn}from"./_ai-sdk_react-DrUeegM3.js";import{u as pn}from"./react-redux-DOC9nX-u.js";import{D as un}from"./ai-D9R4uuUM.js";import{y as ke}from"./userManager-DmZdVoMm.js";import"./hoist-non-react-statics-k0Ol7z-C.js";import"./react-is-DieEVaj3.js";import{h as ve,C as hn}from"./CodeHighlighter-EMDZKRnL.js";import{T as A}from"./Tooltip-DSelQfsB.js";import{d as a,m as Ue,l as Ke}from"./styled-components-B57Umeu6.js";import{S as mn}from"./SearchInput-Cx5-a80p.js";import{M as fn,ao as gn}from"./_mui_material-qlWpdCXu.js";import{m as E,A as Q,u as xn,a as Te,b as B}from"./framer-motion-CrjgtsHD.js";import{c as M,a as I,f as G,j as yn,d as bn}from"./yup-CQnK4sJK.js";import"./lodash-CWlkvKj-.js";import"./dayjs-CnNg6fAM.js";import{a as wn,u as Ie}from"./react-router-BcEcYxhP.js";import{L as Ge}from"./react-router-dom-BOl-Cqxw.js";import{B as ie}from"./Badge-x04xu7od.js";import{d as Cn}from"./marked-CcNCqhLH.js";import{M as vn}from"./react-markdown-DE8mAI2O.js";import{r as In}from"./remark-gfm-DsZ_FkQS.js";import"./NavIcon.const-UjTg48Zy.js";import"./react-dom-aC8izt2d.js";import"./scheduler-C6wT7SwS.js";import"./axios-CyZX-0Aq.js";import"./react-lazily-D0Gu-wQD.js";import"./sonner-BAIRKie7.js";import"./redux-DmAxXYtO.js";import"./_babel_runtime-q5swkfHD.js";import"./_redux-devtools_extension-CJlOaIZW.js";import"./redux-thunk-C7u9vEBE.js";import"./redux-responsive-Bex-p5NA.js";import"./mediaquery-B6UHGVxm.js";import"./_reduxjs_toolkit-CmhpJ4b4.js";import"./immer-DyKKngzo.js";import"./jwt-decode-DG8-DTcQ.js";import"./oidc-client-ts-31uKIj6n.js";import"./userpilot-DvXxTX2Y.js";import"./react-loading-skeleton-DTKXK-WS.js";import"./_sentry_core-BQLQGxJC.js";import"./_sentry_react-BLRC8jqs.js";import"./_sentry_browser-DtvKl6oi.js";import"./_sentry-internal_browser-utils-ty-ljt34.js";import"./_sentry-internal_replay-DKusQVg3.js";import"./history-B_VsH3l1.js";import"./resolve-pathname-DDWomiuY.js";import"./value-equal-Bi9TveP1.js";import"./tiny-invariant-8XFOl4Ix.js";import"./use-sync-external-store-CYkyu1wA.js";import"./tslib-CdgRgkfm.js";import"./_emotion_unitless-BgJuBvcv.js";import"./stylis-Cee4o_pc.js";import"./_mui_utils-CL4euAKP.js";import"./clsx-B2UhURHB.js";import"./prop-types-BiHeSDec.js";import"./react-transition-group-DXQlNCub.js";import"./dom-helpers-Ch5ni-Yy.js";import"./_mui_system-B5Rji5W9.js";import"./_mui_styled-engine-CDwmo2OG.js";import"./_emotion_styled-BHk0IVOr.js";import"./_emotion_is-prop-valid-DdJ3Q1kW.js";import"./_emotion_memoize-bPQddURB.js";import"./_emotion_utils-NurU61FY.js";import"./_emotion_serialize-CO8XPw6B.js";import"./_emotion_hash-CHEqu8kg.js";import"./_emotion_use-insertion-effect-with-fallbacks-VmzL0uDb.js";import"./_emotion_react-OKlLFgt9.js";import"./_emotion_cache-Ce5vM9pC.js";import"./_emotion_sheet-B1Z110SH.js";import"./_mui_private-theming-DkNboAHQ.js";import"./_popperjs_core-qF6yP002.js";import"./path-to-regexp-BZRQKXoA.js";import"./isarray-Bnallxef.js";import"./throttleit-DXYw97O8.js";import"./_ai-sdk_provider-utils-B7jFNo8z.js";import"./_ai-sdk_provider-Bc1IEspm.js";import"./eventsource-parser--U5pbko6.js";import"./zod-BmFVnU-J.js";import"./prismjs-NYFr3h4T.js";import"./Input-CqwnEALZ.js";import"./motion-dom-Bin9gG58.js";import"./motion-utils-DY2gLE65.js";import"./property-expr-HeqoNzBe.js";import"./tiny-case-dcCnzP3_.js";import"./toposort-lECIw1j-.js";import"./devlop-CGaZJrjI.js";import"./unified-BsVST1yz.js";import"./bail-cvuQ_uEQ.js";import"./extend-C-9h8PO9.js";import"./is-plain-obj-VkkEowPv.js";import"./trough-DUMx89cQ.js";import"./vfile-zLR15OdQ.js";import"./vfile-message-CNXSwW8x.js";import"./unist-util-stringify-position-Jcsxzvxq.js";import"./remark-parse-DZVWekAw.js";import"./mdast-util-from-markdown-Fo60UTjg.js";import"./micromark-util-decode-numeric-character-reference-CaZ-VJuE.js";import"./micromark-util-decode-string-BbmpDg9e.js";import"./decode-named-character-reference-CLI5GZIn.js";import"./micromark-util-normalize-identifier-BncrczRx.js";import"./micromark-DBK3N_-p.js";import"./micromark-util-combine-extensions-DXXmENh4.js";import"./micromark-util-chunked-MplN7W53.js";import"./micromark-factory-space-CcOhafxS.js";import"./micromark-util-character-hAyXJIkK.js";import"./micromark-core-commonmark-CwXZ3JSQ.js";import"./micromark-util-classify-character-Gja8cUZk.js";import"./micromark-util-resolve-all-DYhjblZ0.js";import"./micromark-util-subtokenize-hZmoTLIc.js";import"./micromark-factory-destination-Bkt1VvjO.js";import"./micromark-factory-label-sqScxVfM.js";import"./micromark-factory-title-CX2fBK0X.js";import"./micromark-factory-whitespace-CzSAI22R.js";
1import"./micromark-util-html-tag-name-BT7xHaFw.js";import"./mdast-util-to-string-BJphoaWN.js";import"./remark-rehype-DvKRPcsM.js";import"./mdast-util-to-hast-BCx6nXjk.js";import"./_ungap_structured-clone-BAfncxEi.js";import"./micromark-util-sanitize-uri-DA__kORu.js";import"./unist-util-position-BizxyA6v.js";import"./trim-lines-CMCD2ItW.js";import"./unist-util-visit-CJozuYt0.js";import"./unist-util-visit-parents-CWWxk1oU.js";import"./unist-util-is-BU4Hz0Tb.js";import"./hast-util-to-jsx-runtime-Ddfxh49A.js";import"./comma-separated-tokens-ChDGoPaM.js";import"./property-information-Cro7RXod.js";import"./space-separated-tokens-DVZ3kTcc.js";import"./style-to-object-DLJklif7.js";import"./inline-style-parser-DKlhjY6b.js";import"./hast-util-whitespace-DwPtdnU0.js";import"./estree-util-is-identifier-name-D4nqO9DC.js";import"./html-url-attributes-CxF_15C2.js";import"./micromark-extension-gfm-zeLB-JpK.js";import"./micromark-extension-gfm-autolink-literal-CTXELaEg.js";import"./micromark-extension-gfm-footnote-IToUiL1W.js";import"./micromark-extension-gfm-strikethrough-Bfxr_p91.js";import"./micromark-extension-gfm-table-CSU6iVIR.js";import"./micromark-extension-gfm-task-list-item-Zwt-9G6w.js";import"./mdast-util-gfm-UlX8Egt0.js";import"./mdast-util-gfm-autolink-literal-DJti-npa.js";import"./ccount-Be1sgG-I.js";import"./mdast-util-find-and-replace-ClHydLtF.js";import"./escape-string-regexp-nclnYhp3.js";import"./mdast-util-gfm-footnote-DSX_6a0N.js";import"./mdast-util-gfm-strikethrough-DzJfO_P2.js";import"./mdast-util-gfm-table-FftqLi3m.js";import"./markdown-table-BelhBvvZ.js";import"./mdast-util-to-markdown-CUCy7Y1N.js";import"./longest-streak-BLsbEHJx.js";import"./mdast-util-phrasing-DZYlF5vn.js";import"./mdast-util-gfm-task-list-item-B9jp5rAq.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"6ee5f8e92223815c8c6364c9f56a5e04b2af25b3"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;
1n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6bc79be6-1e37-4716-bf0c-0f6e05caf493",e._sentryDebugIdIdentifier="sentry-dbid-6bc79be6-1e37-4716-bf0c-0f6e05caf493")})()}catch{}class _n{constructor(){je(this,"chats",new Map)}getOrCreate(n,o){const s=this.chats.get(n);if(s)return s;const i=new cn({messages:o.messages,onData:o.onData,onFinish:o.onFinish,transport:o.transport});return this.chats.set(n,i),i}remove(n){this.chats.delete(n)}has(n){return this.chats.has(n)}migrateNewToExisting(n){const o=this.chats.get("new");o&&(this.chats.set(n,o),this.chats.delete("new"))}}const se=new _n,jn=({conversationId:e,initialMessages:n=[],jwtToken:o=""})=>{const s=Z(),i=pn(),r=l.useRef(e);r.current=e;const c=l.useCallback(()=>{s.invalidateQueries(["assistant","conversations","list"])},[s]),d=l.useCallback(u=>{switch(u.type){case"data-conversation":{const{conversationId:m,title:g}=u.data;g||(s.setQueryData(["assistant","conversations",m,"messages"],{messages:n}),se.migrateNewToExisting(m),i(Ut(m))),s.setQueryData(["assistant","conversations",m],()=>({conversation_id:m,created_at:new Date().toISOString(),title:g??""}));break}case"data-usage-limit":{i(Qt(!0));break}}},[i,s]),p=l.useMemo(()=>new un({prepareSendMessagesRequest:({messages:u})=>{const m=u[u.length-1].parts[0],g=r.current;return{api:g?`${ke}/conversations/${g}/messages`:`${ke}/conversations`,body:{content:m.type==="text"?m.text:""},headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"}}}}),[o]),h=l.useMemo(()=>se.getOrCreate(e??"new",{messages:n,onData:d,onFinish:c,transport:p}),[e,p,n,d,c]);return dn({chat:h,experimental_throttle:50})},kn=e=>{const{getAccessToken:n}=R(),{data:o}=L({queryFn:n,queryKey:["user","jwt"]});return L({enabled:!!e&&!!o,onError:s=>D.error(ve(s)),queryFn:()=>nn(e??"",o??""),queryKey:["assistant","conversations",e],refetchOnWindowFocus:!1})},Tn=e=>{const{getAccessToken:n}=R(),{data:o}=L({queryFn:n,queryKey:["user","jwt"]});return L({enabled:!!e&&!!o,onError:s=>D.error(ve(s)),queryFn:()=>on(e,"",o??""),queryKey:["assistant","conversations",e,"messages"],refetchOnWindowFocus:!1,select:s=>s.messages.toReversed()})},Sn=(e,n,o="100%")=>{const[s,i]=l.useState(o);return l.useEffect(()=>{if(!e)return;if(n===""){const d=o;e.style.height=d,i(d);return}e.style.height="0px";const{scrollHeight:r}=e,c=`${r}px`;e.style.height=c,i(c)},[e,n,o]),s},Nn=a.div.withConfig({displayName:"ChatInput.styled__InputContainer",componentId:"sc-254fc141-0"})(["display:flex;align-items:center;justify-content:center;background-color:",";border:1px solid ",";border-radius:",";&:focus-within{border-color:",";}&& > button{display:flex;align-items:center;justify-content:center;width:40px;height:36px;margin-inline-end:0.75em;padding-inline:0;border-radius:",";}"],({theme:e})=>e.colors.neutral[1e3],({theme:e})=>e.colors.input.border,({theme:e})=>e.radii.xlarge,({theme:e})=>e.colors.input.borderFocus,({theme:e})=>e.radii.large),Ve=a.div.withConfig({displayName:"ChatInput.styled__Container",componentId:"sc-254fc141-1"})(["isolation:isolate;position:relative;display:flex;flex-direction:column;margin-inline:1.5em;span{padding-block:0.5em 1.25em;font-size:",";color:",";text-align:center;background-color:",";}"],({theme:e})=>e.fonts.xs,({theme:e})=>e.colors.neutral[550],({theme:e})=>e.colors.neutral[1e3]),An=a.textarea.withConfig({displayName:"ChatInput.styled__Textarea",componentId:"sc-254fc141-2"})(["resize:none;width:100%;max-width:500px;height:",";min-height:",";max-height:200px;margin-block-end:0.25em;padding:1em;line-height:1.4;background-color:transparent;border:none;&:disabled{cursor:not-allowed;}&:placeholder-shown{overflow:hidden;}"],({$size:e})=>e==="large"?"68px":"44px",({$size:e})=>e==="large"?"68px":"44px"),Se=a.div.withConfig({displayName:"ChatInput.styled__SpinnerContainer",componentId:"sc-254fc141-3"})(["display:flex;align-items:center;justify-content:center;animation:spin 1s linear infinite;@keyframes spin{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}"]),ne={error:{allowRegenerate:!0,isButtonDisabled:!1,isInputDisabled:!0,text:t.jsx(pt,{"aria-label":"regenerate message",size:24})},streaming:{allowRegenerate:!1,isButtonDisabled:!0,isInputDisabled:!1,text:t.jsx(Se,{children:t.jsx(Y,{"aria-label":"loading",size:24})})},submitted:{allowRegenerate:!1,isButtonDisabled:!0,isInputDisabled:!1,text:t.jsx(Se,{children:t.jsx(Y,{"aria-label":"loading",size:24})})},ready:{allowRegenerate:!1,isButtonDisabled:!1,isInputDisabled:!1,text:t.jsx(dt,{"aria-label":"send message",size:24})}},Ye=({defaultQuestion:e="",status:n,sendMessage:o,regenerateMessage:s,hasReachedUsageLimit:i,onFocus:r,placeholder:c="What can I help you with?",showDisclaimer:d,size:p="default"})=>{var x,f,C;const[h,u]=l.useState(""),m=l.useRef(null);Sn(m.current,h||e,p==="large"?"68px":"44px");const g=l.useCallback(()=>
1{if(ne[n].allowRegenerate){s();return}h.trim()&&(n==="submitted"||n==="streaming"||(o(h),u("")))},[o,u,h,n,s]),_=w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),g())},v=w=>{u(w.target.value)};return t.jsxs(Ve,{children:[t.jsxs(Nn,{children:[t.jsx(An,{$size:p,disabled:((x=ne[n])==null?void 0:x.isInputDisabled)||i,onChange:v,onFocus:r,onKeyDown:_,placeholder:e||c,ref:m,rows:1,value:h}),t.jsx(S,{color:"purple",disabled:((f=ne[n])==null?void 0:f.isButtonDisabled)||i,onClick:g,type:"button",variant:"contained",children:(C=ne[n])==null?void 0:C.text})]}),d?t.jsx("span",{children:"Cleeng AI Assistant can make mistakes, please double-check important information."}):null]})},Hn=15,En=e=>{const{getAccessToken:n}=R(),{data:o}=L({queryFn:n,queryKey:["user","jwt"]}),{data:s,...i}=tn({getNextPageParam:r=>r.nextCursor||void 0,onError:r=>D.error(ve(r)),queryFn:({pageParam:r=""})=>sn(Hn,r,e,o??""),queryKey:["assistant","conversations","list",e]});return{data:(s==null?void 0:s.pages.flatMap(r=>r.conversations))??[],...i}},Mn=e=>{const n=l.useRef(null);return l.useEffect(()=>{const o=n.current;if(!o)return;const s=new IntersectionObserver(i=>{i[0].isIntersecting&&e()});return s.observe(o),()=>{o&&s.unobserve(o)}},[e]),n},Pn=()=>{const e=Z(),{conversationId:n,setConversationId:o}=ee(),{getAccessToken:s}=R(),{data:i}=L({queryFn:s,queryKey:["user","jwt"]});return Ce({mutationFn:r=>an(r,i??""),onMutate:async r=>{await e.cancelQueries({queryKey:["assistant","conversations","list"]});const c=e.getQueryData(["assistant","conversations"]);return e.setQueriesData(["assistant","conversations","list"],d=>d&&{...d,pages:d.pages.map(p=>({...p,conversations:p.conversations.filter(h=>h.conversation_id!==r)}))}),se.remove(r),n===r&&o(null),{conversationsSnapshot:c}},onError:(r,c,d)=>{d&&(e.setQueryData(["assistant","conversations","list"],d.conversationsSnapshot),D.error("Failed to delete conversation "))},onSettled:()=>{}})},Xe=async e=>{try{const n=new URL(window.location.href);n.searchParams.set("conversationId",e??""),await navigator.clipboard.writeText(n.toString()),D.success("Copied link to clipboard")}catch{D.error("Failed to copy to clipboard")}},zn=a(S).withConfig({displayName:"ChatHistoryActions.styled__Button",componentId:"sc-b229f3f-0"})(["&&{padding-inline:0.25em;border-radius:100%;}"]),le=a(fn).withConfig({displayName:"ChatHistoryActions.styled__MenuItem",componentId:"sc-b229f3f-1"})(["&&{height:46px;font-size:",";font-weight:600;}"],({theme:e})=>e.fonts.xs),Dn={MenuListProps:{"aria-labelledby":"chat-actions-button",style:{padding:0}},anchorOrigin:{horizontal:"right",vertical:"bottom"},transformOrigin:{horizontal:"right",vertical:"top"}},Ln=({conversationId:e,onEditTitle:n})=>{const[o,s]=l.useState(null),i=!!o,r=l.useRef(null),{mutate:c}=Pn(),d=l.useCallback(g=>{s(g.currentTarget)},[]),p=l.useCallback(()=>{s(null)},[]),h=async()=>{Xe(e),p()},u=l.useCallback(()=>{c(e)},[e,c]),m=l.useCallback(()=>{p(),n==null||n()},[p,n]);return t.jsxs(t.Fragment,{children:[t.jsx(zn,{"aria-controls":i?"chat-actions-menu":void 0,"aria-expanded":i?"true":void 0,"aria-haspopup":"true","aria-label":"chat actions",color:"purple",onClick:d,ref:r,size:"small",children:t.jsx(ut,{size:24})}),t.jsxs(gn,{anchorEl:o,id:"chat-actions-menu",onClose:p,open:i,...Dn,children:[t.jsx(le,{onClick:h,children:"Share conversation"}),t.jsx(le,{onClick:m,children:"Edit title"}),t.jsx(le,{onClick:u,children:"Delete conversation"})]})]})},Je=()=>{const e=Z(),{getAccessToken:n}=R(),{data:o}=L({queryFn:n,queryKey:["user","jwt"]});return Ce({mutationFn:({title:s,conversationId:i})=>rn(i,s,o??""),onMutate:async({conversationId:s,title:i})=>{await e.cancelQueries({queryKey:["assistant","conversations",s]});const r=e.getQueryData(["assistant","conversations",s]),c=e.getQueriesData(["assistant","conversations","list"]);return e.setQueryData(["assistant","conversations",s],d=>d&&{...d,title:i}),e.setQueriesData(["assistant","conversations","list"],d=>d!=null&&d.pages?{...d,pages:d.pages.map(p=>({...p,conversations:p.conversations.map(h=>h.conversation_id===s?{...h,title:i}:h)}))}
1:d),{conversationSnapshot:r,listQueriesSnapshot:c}},onError:(s,i,r)=>{r&&(e.setQueryData(["assistant","conversations",i.conversationId],r.conversationSnapshot),r.listQueriesSnapshot.forEach(([c,d])=>{e.setQueryData(c,d)}),D.error("Failed to update conversation title"))},onSettled:(s,i,{conversationId:r})=>{e.invalidateQueries(["assistant","conversations",r])}})},$n=a.span.withConfig({displayName:"EditableTitle.styled__Title",componentId:"sc-eb3d4fec-0"})(["overflow:hidden;flex:1;min-width:0;font-weight:bold;line-height:1.3;color:",";text-overflow:ellipsis;white-space:nowrap;"],({theme:e})=>e.colors.neutral[200]),Rn=a.div.withConfig({displayName:"EditableTitle.styled__EditContainer",componentId:"sc-eb3d4fec-1"})(["display:flex;gap:0.5rem;align-items:center;width:100%;"]),On=a.input.withConfig({displayName:"EditableTitle.styled__Input",componentId:"sc-eb3d4fec-2"})(["all:unset;flex:1;min-width:0;font-weight:bold;line-height:1.3;color:",";text-align:start;"],({theme:e})=>e.colors.neutral[200]),Wn=a.div.withConfig({displayName:"EditableTitle.styled__ButtonContainer",componentId:"sc-eb3d4fec-3"})(["display:flex;gap:0.25rem;align-items:center;"]),Ne=a.button.withConfig({displayName:"EditableTitle.styled__ActionButton",componentId:"sc-eb3d4fec-4"})(["all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:20px;height:20px;color:",";background-color:",";border-radius:4px;transition:all 0.15s ease;&:hover{color:",";background-color:",";}&:focus-visible{outline:2px solid ",";outline-offset:1px;}"],({theme:e})=>e.colors.neutral[400],({theme:e})=>e.colors.getColor("light",90),({theme:e})=>e.colors.neutral[200],({theme:e})=>e.colors.getColor("purple",10,!1),({theme:e})=>e.colors.getColor("purple")),Ae=({conversationId:e,initialTitle:n,isEditing:o,onEditComplete:s})=>{const[i,r]=l.useState(n),c=l.useRef(null),d=l.useRef(null),{mutate:p}=Je();l.useEffect(()=>{o&&c.current&&(c.current.focus(),c.current.select())},[o]),l.useEffect(()=>{r(n)},[n]);const h=l.useCallback(()=>{const f=i.trim();f!=null&&f.length&&(f!==n&&p({conversationId:e,title:f}),s())},[e,i,n,p,s]),u=l.useCallback(()=>{r(n),s()},[n,s]),m=l.useCallback(f=>{f.key==="Enter"?(f.preventDefault(),h()):f.key==="Escape"&&(f.preventDefault(),u())},[h,u]),g=l.useCallback(f=>{f.stopPropagation()},[]),_=l.useCallback(f=>{f.stopPropagation(),h()},[h]),v=l.useCallback(f=>{f.stopPropagation(),u()},[u]),x=l.useCallback(f=>{const C=f.relatedTarget;if(C&&d.current&&d.current.contains(C))return;const k=i.trim();k&&k.length>=1?h():u()},[i,h,u]);return o?t.jsxs(Rn,{ref:d,children:[t.jsx(On,{maxLength:100,minLength:1,onBlur:x,onChange:f=>r(f.target.value),onClick:g,onKeyDown:m,ref:c,value:i}),t.jsxs(Wn,{children:[t.jsx(Ne,{"aria-label":"Save title",disabled:!i.trim()||i.trim().length<1,onClick:_,type:"button",children:t.jsx(ye,{size:14})}),t.jsx(Ne,{"aria-label":"Cancel editing",onClick:v,type:"button",children:t.jsx(be,{size:14})})]})]}):t.jsx($n,{children:i})},Bn=a.div.withConfig({displayName:"ChatHistory.styled__HistoryContainer",componentId:"sc-922803e0-0"})(["display:flex;flex-direction:column;min-height:100%;> div{margin:1.2em 2em 0;}"]),Fn=a(E.ol).withConfig({displayName:"ChatHistory.styled__HistoryList",componentId:"sc-922803e0-1"})(["position:relative;overflow:auto;display:flex;flex-direction:column;margin:0;padding:0.6em 1.25em 1.2em;list-style:none;"]),He=a.span.withConfig({displayName:"ChatHistory.styled__IconWrapper",componentId:"sc-922803e0-2"})(["display:flex;flex-shrink:0;align-items:center;justify-content:center;width:36px;height:36px;color:",";background-color:",";border-radius:10px;"],({theme:e})=>e.colors.getColor("purple"),({theme:e})=>e.colors.getColor("purple",8,!1)),qn=a.strong.withConfig({displayName:"ChatHistory.styled__ConversationTitle",componentId:"sc-922803e0-3"})(["overflow:hidden;flex:1;min-width:0;line-height:1.3;color:",";text-overflow:ellipsis;white-space:nowrap;"],({theme:e})=>e.colors.neutral[200]),fe=a.span.withConfig({displayName:"ChatHistory.styled__ConversationTimestamp",componentId:"sc-922803e0-4"})(["flex-shrink:0;margin-inline-start:auto;font-size:0.75rem;color:",";transition:opacity 0.15s ease-in-out;"],({theme:e})=>e.colors.neutral[500]),ge=a.span.withConfig({displayName:"ChatHistory.styled__Actions",componentId:"sc-922803e0-5"})(["position:absolute;inset-inline-end:0.5em;opacity:0;pointer-events:none;transition:opacity 0.15s ease-in-out;"]),Qn=a.button.withConfig({displayName:"ChatHistory.styled__ConversationButton",componentId:"sc-922803e0-6"})(["all:unset;cursor:pointer;display:flex;gap:0.75em;align-items:center;width:100%;min-width:0;padding:0.6em 0.75em;"]),Un=a.div.withConfig({displayName:"ChatHistory.styled__EditingContainer",componentId:"sc-922803e0-7"})(["display:flex;gap:0.75em;align-items:center;width:100%;min-width:0;padding:0.6em 0.75em;"]),Kn=a(E.li).withConfig({displayName:"ChatHistory.styled__HistoryItem",componentId:"sc-922803e0-8"})(["position:relative;display:flex;align-items:center;width:100%;margin-block-end:0.125rem;color:",";border-radius:10px;transition:background-color 0.15s ease-in-out;&:hover,&:focus-within{background-color:",";}&:hover ",",&:focus-within ","{opacity:0;}&:hover ",",&:focus-within ","{opacity:1;pointer-events:auto;}"],({theme:e})=>e.colors.neutral[500],({theme:e})=>e.colors.getColor("light",90),fe,fe,ge,ge),Gn=a(E.div).withConfig({displayName:"ChatHistory.styled__LoadingContainer",componentId:"sc-922803e0-9"})(["display:flex;align-items:center;justify-content:center;height:100%;padding:2rem;font-size:0.9rem;color:",";"],({theme:e})=>e.colors.neutral[500]),Vn=a.h3.withConfig({displayName:"ChatHistory.styled__GroupLabel",componentId:"sc-922803e0-10"})(["margin-block:1.25em 0.5em;font-size:",";font-weight:600;color:",";letter-spacing:0.5px;text-transform:uppercase;"],({theme:e})=>
1e.fonts.xs,({theme:e})=>e.colors.neutral[400]),Yn=a.div.withConfig({displayName:"ChatHistory.styled__InfiniteLoader",componentId:"sc-922803e0-11"})(["display:flex;align-items:center;justify-content:center;padding-block:1em;svg{animation:spin 1s linear infinite;}@keyframes spin{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}"]),Xn=a.div.withConfig({displayName:"ChatHistory.styled__Trigger",componentId:"sc-922803e0-12"})(["min-height:70px;"]),ce={container:{visible:{transition:{delayChildren:.05,staggerChildren:.03}}},item:{hidden:{opacity:0,y:12},visible:{opacity:1,transition:{duration:.15,ease:[.25,.46,.45,.94]},y:0}},loader:{hidden:{opacity:0,transition:{duration:10}},visible:{opacity:1}}},Jn=e=>{const n=oe(),o=n.subtract(1,"day"),s=n.subtract(7,"days"),i=n.subtract(30,"days"),r=[{conversations:[],label:"Today"},{conversations:[],label:"Yesterday"},{conversations:[],label:"Previous 7 days"},{conversations:[],label:"Previous 30 days"},{conversations:[],label:"Older"}];return e.forEach(c=>{const d=oe(c.created_at);d.isSame(n,"day")?r[0].conversations.push(c):d.isSame(o,"day")?r[1].conversations.push(c):d.isAfter(s)?r[2].conversations.push(c):d.isAfter(i)?r[3].conversations.push(c):r[4].conversations.push(c)}),r.filter(c=>c.conversations.length>0)},Zn=e=>{const n=oe(e),o=oe();return n.isSame(o,"day")||n.isSame(o.subtract(1,"day"),"day")?n.format("h:mm A"):n.isAfter(o.subtract(7,"days"))?n.format("ddd · h:mm A"):n.format("MMM D · h:mm A")},eo=300,to=()=>{const[e,n]=l.useState(""),[o,s]=l.useState(""),[i,r]=l.useState(null),{setConversationId:c,setView:d}=ee();l.useEffect(()=>{const j=setTimeout(()=>{s(e)},eo);return()=>{clearTimeout(j)}},[e]);const{data:p,isLoading:h,hasNextPage:u,fetchNextPage:m,isFetchingNextPage:g}=En(o),_=l.useMemo(()=>Jn(p),[p]),v=Mn(()=>{!u||g||m()}),x=l.useCallback(j=>{i!==j&&(c(j),d("chat"))},[c,d,i]),f=l.useCallback(j=>{n(j.target.value)},[]),C=l.useCallback(j=>{r(j)},[]),w=l.useCallback(()=>{r(null)},[]),k=l.useCallback(j=>()=>C(j),[C]);return t.jsxs(Bn,{children:[t.jsx(mn,{onChange:f,placeholder:"Search conversations",value:e}),h||_.length===0?t.jsx(Gn,{animate:"visible",exit:"hidden",initial:"hidden",variants:ce.loader,children:h?"Loading conversations...":"No results"}):t.jsxs(Fn,{animate:"visible",id:"chat-history-container",initial:"hidden",variants:ce.container,children:[_.map(j=>t.jsxs(l.Fragment,{children:[t.jsx("li",{children:t.jsx(Vn,{children:j.label})}),j.conversations.map(({conversation_id:N,created_at:z,title:y})=>{const b=i===N;return t.jsxs(Kn,{variants:ce.item,children:[b?t.jsxs(Un,{children:[t.jsx(He,{children:t.jsx(me,{size:20})}),t.jsx(Ae,{conversationId:N,initialTitle:y,isEditing:b,onEditComplete:w})]}):t.jsxs(Qn,{onClick:()=>x(N),type:"button",children:[t.jsx(He,{children:t.jsx(me,{size:20})}
1),t.jsx(A,{placement:"top",title:y,children:t.jsx(qn,{children:t.jsx(Ae,{conversationId:N,initialTitle:y,isEditing:b,onEditComplete:w})})}),t.jsx(fe,{children:Zn(z)})]}),b?null:t.jsx(ge,{children:t.jsx(Ln,{conversationId:N,onEditTitle:k(N)})})]},N)})]},j.label)),g?t.jsx(Yn,{children:t.jsx(Y,{"aria-label":"loading more conversations"})}):null,u?t.jsx(Xn,{ref:v}):null]})]})},Ze=e=>"content"in e&&typeof e.content=="string"?e.content:"parts"in e&&Array.isArray(e.parts)?e.parts.filter(n=>n.type==="text").map(n=>n.text||"").join(` 2 3`):"",et=e=>"parts"in e&&Array.isArray(e.parts)?e.parts.filter(n=>{var o;return(o=n.type)==null?void 0:o.startsWith("tool-")}):[],no=()=>{const e=Z(),{getAccessToken:n}=R(),{data:o}=L({queryFn:n,queryKey:["user","jwt"]});return Ce({mutationFn:({messageId:s,conversationId:i,rating:r,comment:c})=>ln({conversationId:i,messageId:s,rating:r,comment:c,jwtToken:o??""}),onMutate:async({conversationId:s,messageId:i,comment:r,rating:c})=>{var p,h;await e.cancelQueries({queryKey:["assistant","conversations",s,"messages"]});const d=(h=(p=e.getQueryData(["assistant","conversations",s,"messages"]))==null?void 0:p.messages)==null?void 0:h.find(u=>u.id===i);return e.setQueryData(["assistant","conversations",s,"messages"],u=>{if(u)return{...u,messages:u.messages.map(m=>m.id!==i?m:{...m,feedback:{comment:r,created_at:new Date().toISOString(),rating:c,updated_at:new Date().toISOString()}})}}),{messageSnapshot:d}},onError:(s,i,r)=>{D.error("Failed to provide a feedback, please try again."),r!=null&&r.messageSnapshot&&e.setQueryData(["assistant","conversations",i.conversationId,"messages"],c=>{if(c)return{...c,messages:c.messages.map(d=>{var p;return d.id!==i.messageId?d:{...d,feedback:(p=r.messageSnapshot)==null?void 0:p.feedback}})}})}})},oo=Ue(["from{transform:rotate(0deg);}to{transform:rotate(360deg);}"]);a.div.withConfig({displayName:"Loader.styled__Container",componentId:"sc-3c900b41-0"})(["display:flex;flex-direction:column;gap:0.5em;margin-top:1em;"]);const so=a(E.div).withConfig({displayName:"Loader.styled__LoaderContainer",componentId:"sc-3c900b41-1"})(["display:flex;gap:0.5em;align-items:center;margin-inline-start:0.25em;padding-block:0.75em;"]),io=a.span.withConfig({displayName:"Loader.styled__LoaderIcon",componentId:"sc-3c900b41-2"})(["display:inline-flex;flex-shrink:0;color:",";svg{animation:"," 1s linear infinite;}"],({theme:e})=>e.colors.getColor("purple"),oo),ao=a.span.withConfig({displayName:"Loader.styled__ThinkingText",componentId:"sc-3c900b41-3"})(["font-size:14px;font-weight:500;color:",";"],({theme:e})=>e.colors.getColor("black")),ro={animate:{opacity:0,y:4},initial:{opacity:1,y:0}},tt=({children:e="Thinking...",...n})=>t.jsxs(so,{transition:{duration:.3,ease:"easeOut"},variants:ro,...n,children:[t.jsx(io,{children:t.jsx(Y,{size:16,weight:"bold"})}),t.jsx(ao,{children:e})]}),lo=a.div.withConfig({displayName:"Tools.styled__ToolContainer",componentId:"sc-a05e0cc-0"})(["display:flex;flex-direction:column;gap:0.5em;padding:0.75em 0.25em 0;margin-block-start:0.5em;"]),X=a(S).withConfig({displayName:"Tools.styled__ToolButton",componentId:"sc-a05e0cc-1"})(["position:relative;overflow:hidden;display:flex;justify-content:center;width:",";max-width:280px;> div{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}"],({$width:e})=>e||"auto"),co=a(tt).withConfig({displayName:"Tools.styled__Loader",componentId:"sc-a05e0cc-2"})(["margin-inline-start:0;"]),q=a(E.div).withConfig({displayName:"Tools.styled__LoaderContainer",componentId:"sc-a05e0cc-3"})(["display:flex;gap:0.5em;align-items:center;justify-content:center;#loader-icon{animation:spin 1s linear infinite;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]),po=a.p.withConfig({displayName:"Tools.styled__ToolInfo",componentId:"sc-a05e0cc-4"})(["display:flex;gap:0.2em;align-items:center;margin-inline-start:0.5em;font-size:1em;opacity:0.5;"]),V={animate:{opacity:1,y:0},exit:{opacity:0,y:-20},initial:{opacity:0,y:20}},O=(e,n)=>{try{return n.validateSync(JSON.parse(e))}catch{return null}},uo=e=>{if(!e)return"";const n=e.match(/fields=[^ ]+/);return n?n[0]:""},ho=e=>e.substring(e.indexOf("fields=")).replace(/^`+|`+$/g,"").trim(),mo=e=>{const n=uo(e),o=ho(n),s=new URLSearchParams(o);return{...Object.fromEntries(s),toggle:"pik,vis"}},fo=M({value:I().required()}),Ee=({messageId:e,rawArgs:n,name:o,path:s})=>{const i=wn(),r=Fe(),c=J(g=>g.assistant.toolStatus),{pathname:d}
3=Ie(),{churniqStudioFlag:p}=we(),h=O(n,fo);l.useEffect(()=>{d.includes(s)||(c==null?void 0:c.arguments.type)!=="explore"||r(qe())},[d,s,r,c]);const u=l.useCallback(()=>(c==null?void 0:c.messageId)!==e||!c?t.jsx(q,{...V,children:"Open chart in ChurnIQ Studio"},"initial"):(c==null?void 0:c.status)==="loading"?t.jsxs(q,{...V,children:[t.jsx(Y,{id:"loader-icon"}),"Opening chart"]},"loading"):t.jsx(q,{...V,children:"Chart opened"},"success"),[c,e]),m=()=>{r(Kt(o)),r(Gt(mo((h==null?void 0:h.value)??""))),i.push(s),r(Vt({messageId:e,status:"loading"}))};return h?t.jsxs(t.Fragment,{children:[t.jsx(X,{$width:"220px",color:"purple",disabled:!p,onClick:m,size:"small",type:"button",variant:"contained",children:t.jsx(Q,{initial:!1,mode:"popLayout",children:u()})}),p?null:t.jsxs(po,{children:[t.jsx(ht,{}),t.jsx("span",{children:"ChurnIQ Studio access required"})]})]}):null},go=M({path:I().required(),title:I().required()}),xo=({rawArgs:e})=>{const n=O(e,go);return n?t.jsx(lo,{children:t.jsx(X,{color:"purple",size:"small",to:n.path,type:"button",variant:"contained",children:t.jsxs(q,{children:["Navigate to ",n.title]})})}):null},yo=M({offerId:I().required()}),bo=({messageId:e,rawArgs:n})=>{const o=Fe(),s=J(d=>d.assistant.toolStatus),{pathname:i}=Ie(),r=O(n,yo),c=l.useCallback(()=>(s==null?void 0:s.arguments.type)==="offer"&&(s==null?void 0:s.arguments.offerId)===(r==null?void 0:r.offerId)&&(s==null?void 0:s.status)==="ready"?t.jsx(q,{...V,children:"Offer opened"},"success"):t.jsx(q,{...V,children:"Open offer"},"initial"),[s,r]);return l.useEffect(()=>{i.includes(`/offers/${r==null?void 0:r.offerId}`)||(s==null?void 0:s.arguments.type)==="explore"||(s==null?void 0:s.arguments.offerId)!==(r==null?void 0:r.offerId)||o(qe())},[i,r,o,s]),r?t.jsx(X,{$width:"120px",color:"purple",onClick:()=>o(Yt({messageId:e,offerId:r.offerId,status:"ready"})),size:"small",to:`/offers/${r.offerId}`,type:"button",variant:"contained",children:t.jsx(Q,{initial:!1,mode:"popLayout",children:c()})}):null},nt=a.div.withConfig({displayName:"PrioritySegmentsTool.styled__ChevronIcon",componentId:"sc-413102bf-0"})(["display:flex;color:",";"],({theme:e})=>e.colors.neutral[800]),wo=a(Ge).withConfig({displayName:"PrioritySegmentsTool.styled__SegmentCard",componentId:"sc-413102bf-1"})(["display:flex;flex-direction:column;width:100%;padding:12px;border:1px solid ",";border-radius:",";background-color:",";cursor:pointer;transition:all 0.2s ease;&:hover,&:focus-visible{","{color:",";}border-color:",";}"],({theme:e})=>e.colors.neutral[900],({theme:e})=>e.radii.large,({theme:e})=>e.colors.neutral[1e3],nt,({theme:e})=>e.colors.system.purple,({theme:e})=>e.colors.system.purple),Co=a.div.withConfig({displayName:"PrioritySegmentsTool.styled__SegmentHeader",componentId:"sc-413102bf-2"})(["display:flex;justify-content:space-between;align-items:center;"]),vo=a.h3.withConfig({displayName:"PrioritySegmentsTool.styled__SegmentTitle",componentId:"sc-413102bf-3"})(["margin:0;font-size:",";font-weight:600;color:",";"],({theme:e})=>e.fonts.md,({theme:e})=>e.colors.neutral[200]),Io=a.div.withConfig({displayName:"PrioritySegmentsTool.styled__BadgeContainer",componentId:"sc-413102bf-4"})(["display:flex;gap:8px;margin-block-start:12px;flex-wrap:wrap;"]),Me=a(ie).withConfig({displayName:"PrioritySegmentsTool.styled__Badge",componentId:"sc-413102bf-5"})(["display:flex;justify-content:center;align-items:center;gap:0.4em;text-transform:capitalize;"]),_o=a(ie).withConfig({displayName:"PrioritySegmentsTool.styled__PlatformBadge",componentId:"sc-413102bf-6"})(["display:flex;justify-content:center;align-items:center;gap:0.4em;&&{background-color:",";color:",";}"],({theme:e,group:n})=>n?e.colors.paymentMethod[n].bg:"",({theme:e,group:n})=>n?e.colors.paymentMethod[n].text:""),jo=[["apple",new Set(["ios","applepay","storekit2","storekit2-sandbox","tvos"])],["tv",new Set(["roku","samsung_tv","vizio"])],["android",new Set(["android","googlepay"])],["bank",new Set(["ideal","directdebit_NL","sepadirectdebit","bancontact_card","bancontact_mobile","sofort"])],["paypal",new Set(["paypal"])]],ko=new Set(["amex","mc","visa","discover","maestrouk","solo","card","default"]),To={android:"Android",applepay:"Apple Pay",bancontact_card:"Bancontact Card",bancontact_mobile:"Bancontact Mobile",card:"Card",directdebit_NL:"Direct Debit NL",googlepay:"Google Pay",ideal:"iDEAL",ios:"iOS",paypal:"PayPal",roku:"Roku",samsung_tv:"Samsung TV",sepadirectdebit:"SEPA Direct Debit",sofort:"Sofort",storekit2:"StoreKit 2","storekit2-sandbox":"StoreKit 2 Sandbox",tvos:"tvOS",vizio:"Vizio"},So=e=>{var n;return ko.has(e)?null:((n=jo.find(([,o])=>o.has(e)))==null?void 0:n[0])??"wallet"}
3,No={android:bt,apple:yt,bank:xt,paypal:gt,tv:ft,wallet:mt},Ao=e=>e?No[e]:wt,Ho=M({priority_segments:G(M({date:I().required(),name:I().required(),offerId:I().required(),platform:yn().required(),segment_id:I().required(),subscriptionDuration:I().required(),type:I().required(),url:I().required()})).required()}),Eo=({platform:e})=>{const n=So(e),o=Ao(n),s=To[e]??e;return t.jsxs(_o,{group:n,size:"small",children:[t.jsx(o,{size:16,weight:"fill"}),s]})},Mo=({rawArgs:e})=>{const n=O(e,Ho);return n?t.jsx(t.Fragment,{children:n.priority_segments.map(({segment_id:o,url:s,type:i,platform:r,subscriptionDuration:c,offerId:d})=>t.jsxs(wo,{to:s,children:[t.jsxs(Co,{children:[t.jsx(vo,{children:i}),t.jsx(nt,{children:t.jsx(Ct,{size:20,weight:"bold"})})]}),t.jsxs(Io,{children:[t.jsx(Eo,{platform:r}),t.jsx(Me,{size:"small",children:c.replace("-"," ")}),t.jsxs(Me,{size:"small",children:[t.jsx(vt,{size:16,weight:"fill"}),d]})]})]},o))}):null},Po=a.div.withConfig({displayName:"CardTool.styled__Container",componentId:"sc-3f3f9bdb-0"})(["display:flex;flex-direction:column;gap:12px;padding:16px;background-color:",";border-radius:",";width:100%;"],({theme:e})=>e.colors.getColor("light",90),({theme:e})=>e.radii.xlarge),zo=a.div.withConfig({displayName:"CardTool.styled__Card",componentId:"sc-3f3f9bdb-1"})(["overflow:hidden;width:100%;background-color:",";border:0.5px solid ",";border-radius:",";box-shadow:",";"],({theme:e})=>e.colors.neutral[1e3],({theme:e})=>e.colors.neutral[900],({theme:e})=>e.radii.large,({theme:e})=>e.effects.shadow.sm),Do=a.div.withConfig({displayName:"CardTool.styled__Header",componentId:"sc-3f3f9bdb-2"})(["display:flex;align-items:center;gap:0.75em;padding-inline:2px;"]),Lo=a.div.withConfig({displayName:"CardTool.styled__HeaderInfo",componentId:"sc-3f3f9bdb-3"})(["display:flex;flex:1;flex-direction:column;gap:0.15em;min-width:0;"]),$o=a.h3.withConfig({displayName:"CardTool.styled__Title",componentId:"sc-3f3f9bdb-4"})(["overflow:hidden;font-size:",";font-weight:600;color:",";white-space:nowrap;text-overflow:ellipsis;"],({theme:e})=>e.fonts.md,({theme:e})=>e.colors.system.dark),Ro=a.p.withConfig({displayName:"CardTool.styled__Subtitle",componentId:"sc-3f3f9bdb-5"})(["overflow:hidden;font-size:",";color:",";white-space:nowrap;text-overflow:ellipsis;"],({theme:e})=>e.fonts.xs,({theme:e})=>e.colors.getColor("dark",70));a.hr.withConfig({displayName:"CardTool.styled__Divider",componentId:"sc-3f3f9bdb-6"})(["margin:0;border:none;border-top:1px solid ",";"],({theme:e})=>e.colors.neutral[900]);const Oo=a.div.withConfig({displayName:"CardTool.styled__EntriesList",componentId:"sc-3f3f9bdb-7"})(["display:flex;flex-direction:column;gap:12px;padding:16px;"]),Wo=a.div.withConfig({displayName:"CardTool.styled__Entry",componentId:"sc-3f3f9bdb-8"})(["display:flex;gap:20px;align-items:center;"]),Bo=a.span.withConfig({displayName:"CardTool.styled__EntryLabel",componentId:"sc-3f3f9bdb-9"})(["flex:1;min-width:max-content;font-size:",";color:",";"],({theme:e})=>e.fonts.md,({theme:e})=>e.colors.getColor("dark",70)),Fo=a.span.withConfig({displayName:"CardTool.styled__EntryValue",componentId:"sc-3f3f9bdb-10"})(["font-size:",";font-weight:500;color:",";white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;"],({theme:e})=>e.fonts.md,({theme:e})=>e.colors.system.dark),qo=M({label:I().required(),value:I().required()}),Qo=M({entries:G(qo).required(),status:M({label:I().required(),variant:I().oneOf(["error","info","success","warning"]).optional()}).optional().default(void 0),subtitle:I().optional(),title:I().required()}),Uo=({rawArgs:e})=>{const n=O(e,Qo);if(!n)return null;const{entries:o,status:s,subtitle:i,title:r}=n;return t.jsxs(Po,{children:[t.jsxs(Do,{children:[t.jsxs(Lo,{children:[t.jsx($o,{children:r}),i?t.jsx(Ro,{children:i}):null]}),s?t.jsx(ie,{color:s.variant,size:"small",children:s.label}):null]}),t.jsx(zo,{children:t.jsx(Oo,{children:o.map((c,d)=>t.jsxs(Wo,{children:[t.jsx(Bo,{children:c.label}),t.jsx(A,{enterDelay:1e3,title:c.value,children:t.jsx(Fo,{children:c.value})})]},`${c.label}-${d}`))})})]})},Ko=M({href:I().required().matches(/^(\/|https?:\/\/)/),label:I().required()}),Go=({rawArgs:e})=>{const n=O(e,Ko);return n?n.href.startsWith("/")?t.jsx(X,{color:"purple",size:"small",to:n.href,type:"button",variant:"contained",children:n.label}):t.jsx(X,{color:"purple",href:n.href,rel:"noopener noreferrer",size:"small",target:"_blank",variant:"contained",children:n.label}):null},Vo={error:"textError",info:"textInfo",success:"textSuccess",warning:"textWarning"},Yo=a.div.withConfig({displayName:"TableTool.styled__Container",componentId:"sc-a05f8cd5-0"})(["display:flex;flex-direction:column;gap:12px;padding:16px;border-radius:",";background-color:",";"],({theme:e})=>e.radii.xlarge,({theme:e})=>e.colors.getColor("light",90)),Xo=a.div.withConfig({displayName:"TableTool.styled__Header",componentId:"sc-a05f8cd5-1"})(["display:flex;align-items:baseline;justify-content:space-between;gap:0.75em;padding-inline:2px;"]),Jo=a.h3.withConfig({displayName:"TableTool.styled__Title",componentId:"sc-a05f8cd5-2"})(["font-size:",";color:",";font-weight:600;"],({theme:e})=>e.fonts.md,({theme:e})=>e.colors.system.dark),Zo=a.span.withConfig({displayName:"TableTool.styled__Subtitle",componentId:"sc-a05f8cd5-3"})(["font-size:",";color:",";white-space:nowrap;"],({theme:e})=>e.fonts.sm,({theme:e})=>e.colors.getColor("dark",70)),es=a.div.withConfig({displayName:"TableTool.styled__TableScroll",componentId:"sc-a05f8cd5-4"})(["overflow-x:auto;background-color:",";
3border:0.5px solid ",";border-radius:",";box-shadow:",";padding:16px;"],({theme:e})=>e.colors.neutral[1e3],({theme:e})=>e.colors.neutral[900],({theme:e})=>e.radii.large,({theme:e})=>e.effects.shadow.sm),ts=a.table.withConfig({displayName:"TableTool.styled__Table",componentId:"sc-a05f8cd5-5"})(["width:max-content;min-width:100%;border-collapse:collapse;"]),ns=a.th.withConfig({displayName:"TableTool.styled__Th",componentId:"sc-a05f8cd5-6"})(["min-width:80px;max-width:150px;padding:6px 14px;font-weight:500;font-size:",";color:",";color:",";text-align:start;text-transform:uppercase;border-block-end:1px solid ",";overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],({theme:e})=>e.fonts.xs,({theme:e})=>e.colors.neutral[600],({theme:e})=>e.colors.getColor("dark",55),({theme:e})=>e.colors.neutral[900]),os=a.td.withConfig({displayName:"TableTool.styled__Td",componentId:"sc-a05f8cd5-7"})(["min-width:80px;max-width:150px;padding:14px 14px 4px 14px;font-size:",";color:",";overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500;"],({theme:e})=>e.fonts.sm,({theme:e})=>e.colors.system.dark),ss=a.span.withConfig({displayName:"TableTool.styled__ColoredText",componentId:"sc-a05f8cd5-8"})(["color:",";"],({theme:e,$variant:n})=>e.colors.badgeColors[Vo[n]]),is=M({chip:bn().optional(),text:I().required(),variant:I().oneOf(["success","warning","error","info"]).optional()}),as=M({columns:G(M({label:I().required()}).required()).required(),rows:G(G(is.required()).required()).required(),subtitle:I().optional(),title:I().required()}),rs=({cell:e})=>e.variant&&e.chip?t.jsx(ie,{color:e.variant,size:"small",children:e.text}):e.variant?t.jsx(ss,{$variant:e.variant,children:e.text}):t.jsx("span",{children:e.text}),ls=({rawArgs:e})=>{const n=O(e,as);return n?t.jsxs(Yo,{children:[t.jsxs(Xo,{children:[t.jsx(Jo,{children:n.title}),n.subtitle?t.jsx(Zo,{children:n.subtitle}):null]}),t.jsx(es,{children:t.jsxs(ts,{children:[t.jsx("thead",{children:t.jsx("tr",{children:n.columns.map(o=>t.jsx(ns,{children:o.label},o.label))})}),t.jsx("tbody",{children:n.rows.map((o,s)=>t.jsx("tr",{children:o.map((i,r)=>t.jsx(os,{children:t.jsx(rs,{cell:i})},r))},s))})]})})]}):null},cs={default:"Executing tool...","knowledge-base-chat-bot":"Searching knowledge base...","navigation-agent":"Finding page...","subscriber-explore-agent":"Analyzing subscribers...","transaction-explore-agent":"Analyzing transactions..."},ds={open_offer_link:(e,n)=>t.jsx(bo,{messageId:n,rawArgs:e}),render_card:e=>t.jsx(Uo,{rawArgs:e}),render_link:e=>t.jsx(Go,{rawArgs:e}),render_table:e=>t.jsx(ls,{rawArgs:e}),show_navigation:e=>t.jsx(xo,{rawArgs:e}),show_subscribers_explore:(e,n)=>t.jsx(Ee,{messageId:n,name:"churniq_studio_subscribers",path:Jt.path,rawArgs:e}),show_transactions_explore:(e,n)=>t.jsx(Ee,{messageId:n,name:"churniq_studio_transactions",path:Xt.path,rawArgs:e}),view_priority_segments:e=>t.jsx(Mo,{rawArgs:e})},ps=({state:e,output:n,toolCallId:o})=>e!=="output-available"||!(n!=null&&n.tools)?null:n.tools.map(s=>ds[s.name](s.arguments,o)),us=({toolParts:e})=>{var s;if(e.length===0)return null;const n=e.find(i=>i.state==="input-available"),o=e.filter(i=>i.state!=="input-available");return t.jsxs(t.Fragment,{children:[o.map(i=>ps(i)),n?t.jsx(co,{children:cs[((s=n.input)==null?void 0:s.name)??"default"]}):null]})},hs=a.code.withConfig({displayName:"index.styled__InlineCode",componentId:"sc-ed01f242-0"})(["padding:0.1em 0.2em;color:",";white-space:normal;background:",";border-radius:0.3em;"],({theme:e})=>e.colors.code.operator,({theme:e})=>e.colors.code.background),ms=a.a.withConfig({displayName:"index.styled__A",componentId:"sc-ed01f242-1"})(["color:",";&&{text-decoration:underline;&:hover{text-decoration-thickness:2px;}}"],({theme:e})=>e.colors.links.highlight),fs=({children:e})=>{if(!l.isValidElement(e))return null;const{props:n}=e,o=/language-(\w+)/.exec(n.className??""),s=String(n.children??"").replace(/\n$/,""),i=(o==null?void 0:o[1])??"html";return t.jsx(hn,{code:s,lang:i})},gs=e=>t.jsx(hs,{...e}),xs=e=>{var n;return(n=e.href)!=null&&n.startsWith("mailto:")?t.jsx("span",{children:e.children}):t.jsx(ms,{rel:"noopener noreferrer",target:"_blank",...e})},ys={a:({node:e,...n})=>t.jsx(xs,{...n}),code:gs,h1:({node:e,...n})=>t.jsx("h2",{...n}),h2:({node:e,...n})=>t.jsx("h3",{...n}),h3:({node:e,...n})=>t.jsx("h4",{...n}),h4:({node:e,...n})=>t.jsx("h5",{...n}),h5:({node:e,...n})=>t.jsx("h6",{...n}),pre:fs},bs=[In],ot=l.memo(({content:e})=>t.jsx(vn,{className:"markdown",components:ys,remarkPlugins:bs,children:e}));ot.displayName="MarkdownBlock";const ws=e=>{try{const n=Cn.lexer(e),o=[],s=[];if(n.forEach(i=>
3{"raw"in i&&i.raw&&(i.type==="def"?s.push(i.raw):i.type!=="space"&&o.push(i.raw))}),s.length>0){const i=s.join(` 4`);return o.map(r=>`${i} 5${r}`)}return o}catch{return[e]}},st=l.memo(({content:e,id:n})=>{const o=l.useMemo(()=>ws(e),[e]);return e!=null&&e.trim()?t.jsx("div",{className:"memoized-markdown",children:o.map((s,i)=>t.jsx(ot,{content:s},`${n}-${i}`))}):null},(e,n)=>e.content===n.content);st.displayName="MarkdownChunked";const xe=a.div.withConfig({displayName:"Message.styled__MessageActions",componentId:"sc-a9172d57-0"})(["display:flex;gap:1em;justify-content:flex-end;margin-block-start:1em;margin-inline-start:0.5em;opacity:0;transition:opacity 0.2s ease-in-out;"]);a(Ge).withConfig({displayName:"Message.styled__UserAvatar",componentId:"sc-a9172d57-1"})(["display:flex;align-items:center;justify-content:center;aspect-ratio:1/1;height:43px;font-size:16px;font-weight:600;color:",";text-align:center;background-color:",";border-radius:100%;"],({theme:e})=>e.colors.neutral[1e3],({theme:e})=>e.colors.getColor("purple"));const Cs=a.li.withConfig({displayName:"Message.styled__Message",componentId:"sc-a9172d57-2"})(["position:relative;width:100%;list-style:none;display:flex;flex-direction:",";gap:0.5em;margin-block-start:1em;word-wrap:break-word;&:hover,&:focus-within{","{opacity:1;}}&:last-child ","{opacity:1;}"],({$role:e})=>e==="user"?"row":"column",xe,xe),vs=a.div.withConfig({displayName:"Message.styled__Content",componentId:"sc-a9172d57-3"})(["display:flex;flex-direction:column;align-items:",";justify-content:center;width:100%;min-width:0;.memoized-markdown{display:flex;flex-direction:column;align-items:",";width:",";max-width:",";","}.markdown{max-width:100%;padding:",";border-radius:",";ul,menu{margin-block:0.2em;margin-inline-start:1em;list-style:disc;}ol{margin-block:0.2em;margin-inline-start:1em;list-style:decimal;}h1,h2,h3,h4{margin-block:0.5em;font-weight:600;color:",";}h1{font-size:2em;}h2{font-size:1.5em;}h3{.markdown{font-size:1.2em;}h4{font-size:1em;}.footnotes{ol{padding-left:0;list-style:none;}li{cursor:pointer;position:relative;margin-bottom:1rem;transition:transform 0.15s ease-in-out;&:hover{transform:translate(0,-4px);}}p{margin:0;padding:0.75rem 1rem;background:",";border-left:4px solid ",";border-radius:0.25rem;box-shadow:0 2px 6px rgb(0 0 0 / 5%);}.data-footnote-backref{display:block;width:0;height:0;opacity:0;}}#footnote-label{display:none;}}}"],({$role:e})=>e==="user"?"flex-end":"flex-start",({$role:e})=>e==="user"?"end":"initial",({$role:e})=>e==="user"?"fit-content":"100%",({$role:e})=>e==="user"?"88%":"100%",({$role:e,theme:n})=>e==="user"&&` 6 overflow-wrap: break-word; 7 padding: 0.75em 1em; 8 background-color: ${n.colors.getColor("light",90)}; 9 border-radius: ${n.radii.large} ${n.radii.large} 0 ${n.radii.large}; 10 `,({$role:e})=>e==="user"?"0":"0.75em 0.25em 0 0.25em",({theme:e})=>e.radii.medium,({theme:e})=>e.colors.layout.contentHeader,({theme:e})=>e.colors.getColor("light",90),({theme:e})=>e.colors.system.brand),Is=a.div.withConfig({displayName:"Message.styled__ToolsContainer",componentId:"sc-a9172d57-4"})(["display:flex;flex-direction:column;gap:0.75em;margin-block-start:0.5em;width:100%;"]),de=a(E.button).withConfig({displayName:"Message.styled__Action",componentId:"sc-a9172d57-5"})(["all:unset;will-change:filter;cursor:pointer;display:flex;color:gray;transition:color 0.2s ease-in-out;&:hover,&:focus-visible{color:black;}&:disabled{cursor:initial;}svg{width:20px;height:20px;}"]),_s={hidden:{filter:"blur(4px)",opacity:0,scale:0},visible:{filter:"blur(0px)",opacity:1,scale:1}},js=(e,n,o)=>e?t.jsx(st,{content:e,id:n}):o.length===0?t.jsx(tt,{}):null,it=l.forwardRef(({message:e,conversationId:n,status:o,onFeedbackUpdate:s,...i},r)=>{const{id:c,role:d,feedback:p}=e,h=l.useMemo(()=>Ze(e),[e]),u=l.useMemo(()=>et(e),[e]),{mutate:m}=no(),[g,_]=l.useState(!1),v=l.useRef(null),x=C=>{const w={comment:C==="positive"?"Good AI response":"Bad AI response",created_at:new Date().toISOString(),rating:C,updated_at:new Date().toISOString()};s(c,w),m({comment:w.comment,conversationId:n,messageId:c,rating:C})},f=async()=>{var C;try{const w=[h],k=(C=v.current)==null?void 0:C.innerText;k&&w.push(k),await navigator.clipboard.writeText(`${w.join(` 11 12`)} 13 14Generated by Cleeng AI Assistant`),_(!0),setTimeout(()=>_(!1),2e3)}catch{D.error("Failed to copy to clipboard")}};return t.jsx(Cs,{$role:d,"data-role":d,id:c,ref:r,...i,children:t.jsxs(vs,{$role:d,children:[js(h,c,u),d==="assistant"?t.jsx(Is,{ref:v,children:t.jsx(us,{toolParts:u})}):null,d==="assistant"&&n&&o!=="streaming"?t.jsxs(xe,{children:[t.jsx(A,{title:"Good response",children:t.jsx("span",{children:t.jsx(de,{"aria-label":"Good response",onClick:()=>x("positive"),children:t.jsx(It,{weight:(p==null?void 0:p.rating)==="positive"?"fill":"regular"})})})}),t.jsx(A,{title:"Bad response",children:t.jsx("span",{children:t.jsx(de,{"aria-label":"Bad response",onClick:()=>x("negative"),children:t.jsx(_t,{weight:(p==null?void 0:p.rating)==="negative"?"fill":"regular"})})})}),h?t.jsx(Q,{initial:!1,mode:"popLayout",children:t.jsxs(de,{animate:"visible",exit:"hidden",initial:"hidden",onClick:f,transition:{duration:.2},variants:_s,children:[t.jsx(A,{title:g?"Copied to clipboard":"Copy to clipboard",children:g?t.jsx(ye,{}):t.jsx(jt,{})})," "]},g?"copied":"copy")}):null]}):null]})})});it.displayName="Message";const ks=a.li.withConfig({displayName:"ChatError.styled__Container",componentId:"sc-29515c73-0"})(["display:flex;flex-direction:column;gap:1.25em;"]),Ts=a.div.withConfig({displayName:"ChatError.styled__MessageContainer",componentId:"sc-29515c73-1"})(["display:flex;flex-direction:column;gap:0.5em;padding:1em;background-color:",";border:1px solid ",";border-radius:",";"],({theme:e})=>e.colors.getColor("purple",20),({theme:e})=>e.colors.getColor("purple",50),({theme:e})=>e.radii.small),Ss=(e,n,o)=>e==="error"?t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"Something went wrong and I couldn't generate your answer. Please try again."}),t.jsx(S,{color:"purple",onClick:o,size:"small",type:"button",variant:"contained",children:"Try Again"})]}):n?t.jsxs(t.Fragment,{children:[t.jsxs("p",{children:["You've reached your daily message limit. To continue using AI Assistant, request additional messages."," ",t.jsx(Zt,{color:"auth",href:"https://publisher.support.cleeng.com/hc/en-us",rel:"noopener noreferrer",target:"_blank",children:"Learn more"})," ","or submit a request below."]}),t.jsx(S,{color:"purple",href:"https://publisher.support.cleeng.com/hc/en-us/requests/new",rel:"noopener noreferrer",size:"small",target:"_blank",variant:"contained",children:"Request messages"})]}):null,Ns=({status:e,regenerateMessage:n})=>{const o=J(s=>s.assistant.hasReachedUsageLimit);return e!=="error"&&!o?null:t.jsx(ks,{children:t.jsx(Ts,{children:Ss(e,o,n)})})},As=a.div.withConfig({displayName:"ChatMessageList.styled__Container",componentId:"sc-e299dc03-0"})(["display:grid;grid-template-areas:'chat';flex:1;min-height:0;"]),Hs=a.div.withConfig({displayName:"ChatMessageList.styled__ScrollToBottomButton",componentId:"sc-e299dc03-1"})(["z-index:1;grid-area:chat;place-self:end center;margin-block-end:1em;&&& button{background-color:",";border-radius:50%;box-shadow:0 2px 8px rgb(0 0 0 / 15%);&:hover{color:",";background-color:",";border:1px solid ",";}}"],({theme:e})=>e.colors.neutral[1e3],({theme:e})=>e.colors.system.purple,({theme:e})=>e.colors.neutral[1e3],({theme:e})=>e.colors.system.purple),Es=a.ol.withConfig({displayName:"ChatMessageList.styled__MessageList",componentId:"sc-e299dc03-2"})(["scroll-behavior:auto;overflow:hidden auto;display:flex;grid-area:chat;flex:1;flex-direction:column;gap:1em;height:100%;min-height:0;max-height:100%;padding-bottom:2em;padding-block:1.25em;padding-inline:1.5em;line-height:1.55;"]),Ms=a.div.withConfig({displayName:"ChatMessageList.styled__LoadingContainer",componentId:"sc-e299dc03-3"})(["display:flex;align-items:center;justify-content:center;height:100%;padding:2rem;font-size:0.9rem;color:",";"],({theme:e})=>e.colors.neutral[500]);a.li.withConfig({displayName:"ChatMessageList.styled__MessageItem",componentId:"sc-e299dc03-4"})(["width:100%;list-style:none;"]);a.div.withConfig({displayName:"ChatMessageList.styled__Trigger",componentId:"sc-e299dc03-5"})(["min-height:10px;"]);a.div.withConfig({displayName:"ChatMessageList.styled__InfiniteLoader",componentId:"sc-e299dc03-6"})(["display:flex;align-items:center;justify-content:center;padding-block:1em;svg{animation:spin 1s linear infinite;}@keyframes spin{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}"]);const Ps=150,zs=({conversationId:e,isLoading:n,messages:o,onFeedbackUpdate:s,regenerateMessage:i,status:r})=>{const c=l.useRef(null),[d,p]=l.useState(!1),h=l.useRef(null),u=J(x=>x.assistant.hasReachedUsageLimit),m=l.useCallback((x="smooth")=>{var f;(f=c.current)==null||f.scrollTo({behavior:x,top:c.current.scrollHeight})},[]),g=l.useCallback(()=>
14{if(!c.current)return;const{scrollTop:x,scrollHeight:f,clientHeight:C}=c.current,w=f-x-C;p(w>Ps)},[]);l.useEffect(()=>{if(n||o.length===0||h.current===e)return;const x=h.current==="";h.current=e,x||m("auto")},[e,n,o,m]),l.useEffect(()=>{const x=o[o.length-1],f=(x==null?void 0:x.role)==="assistant"&&(Ze(x)!==""||et(x).length>0);(r==="submitted"||r==="streaming")&&!f&&m("auto"),g()},[o,r,m,g]);const _=l.useCallback(()=>{m("smooth")},[m]),v=u?o.slice(0,-1):o;return n?t.jsx(Ms,{children:"Loading messages..."}):t.jsxs(As,{children:[t.jsxs(Es,{onScroll:g,ref:c,children:[v.map(x=>t.jsx(it,{conversationId:e??"",message:x,onFeedbackUpdate:s,status:r},x.id)),t.jsx(Ns,{regenerateMessage:i,status:r})]}),d?t.jsx(Hs,{children:t.jsx(S,{"aria-label":"Scroll to bottom",hasIcon:!0,onClick:_,size:"small",type:"button",variant:"subtle",children:t.jsx(kt,{size:18})})}):null]})},K=(e,n)=>e.colors.assistantCategories[n],Ds=a.div.withConfig({displayName:"ChatPrompts.styled__WelcomeContainer",componentId:"sc-2ba627d-0"})(["overflow-y:auto;display:flex;flex:1;flex-direction:column;gap:1em;width:100%;padding-block:5em;padding-inline:1.5em;line-height:1.55;","{margin-inline:0;}"],Ve),Ls=a.header.withConfig({displayName:"ChatPrompts.styled__WelcomeHeader",componentId:"sc-2ba627d-1"})(["display:flex;flex-direction:column;gap:0.35em;align-items:center;margin-block:1em 0.5em;text-align:center;"]),$s=a.span.withConfig({displayName:"ChatPrompts.styled__Greeting",componentId:"sc-2ba627d-2"})(["font-weight:600;color:",";"],({theme:e})=>e.colors.getColor("purple")),Rs=a.h2.withConfig({displayName:"ChatPrompts.styled__WelcomeTitle",componentId:"sc-2ba627d-3"})(["font-size:1.75em;font-weight:700;line-height:1.2;"]),Os=a.p.withConfig({displayName:"ChatPrompts.styled__WelcomeSubtitle",componentId:"sc-2ba627d-4"})(["font-size:1.1em;color:",";"],({theme:e})=>e.colors.neutral[650]),Ws=a(S.Wrapper).withConfig({displayName:"ChatPrompts.styled__ChipsWrapper",componentId:"sc-2ba627d-5"})(["justify-content:center;"]),Bs=a(S).withConfig({displayName:"ChatPrompts.styled__CategoryChip",componentId:"sc-2ba627d-6"})(["&&{padding:1em;font-weight:normal;color:",";background-color:",";border:1px solid ",";border-radius:",";fill:currentColor;}&&:hover:is(:not([aria-disabled='true'])){background-color:",";}"],({theme:e,$isSelected:n,$categoryKey:o})=>n?K(e,o):e.colors.neutral[0],({theme:e,$isSelected:n,$categoryKey:o})=>n?`oklch(from ${K(e,o)} l c h / 0.12)`:"transparent",({theme:e,$isActive:n,$categoryKey:o})=>n?K(e,o):e.colors.getColor("dark",20),({theme:e})=>e.radii.full,({theme:e,$isSelected:n,$categoryKey:o})=>n?`oklch(from ${K(e,o)} l c h / 0.18)`:e.colors.getColor("dark",5)),Fs=a.div.withConfig({displayName:"ChatPrompts.styled__PromptPanel",componentId:"sc-2ba627d-7"})(["display:flex;flex-direction:column;gap:0.5em;padding:1em;color:",";background-color:",";border:1px solid ",";border-radius:",";"],({theme:e})=>e.colors.neutral[0],({theme:e})=>e.colors.neutral[1e3],({theme:e})=>e.colors.input.border,({theme:e})=>e.radii.xlarge),qs=a.div.withConfig({displayName:"ChatPrompts.styled__PanelHeader",componentId:"sc-2ba627d-8"})(["display:flex;gap:0.5em;align-items:flex-start;svg{flex-shrink:0;}> svg{margin-block-start:0.1em;color:",";fill:currentColor;}"],({theme:e,$categoryKey:n})=>K(e,n)),Qs=a.div.withConfig({displayName:"ChatPrompts.styled__PanelHeadings",componentId:"sc-2ba627d-9"})(["display:flex;flex-direction:column;gap:0.15em;min-width:0;"]),Us=a.span.withConfig({displayName:"ChatPrompts.styled__PanelTitle",componentId:"sc-2ba627d-10"})(["font-weight:600;"]),Ks=a.span.withConfig({displayName:"ChatPrompts.styled__PanelSubtitle",componentId:"sc-2ba627d-11"})(["font-size:13px;color:",";"],({theme:e})=>e.colors.neutral[700]),Gs=a(S).withConfig({displayName:"ChatPrompts.styled__CloseButton",componentId:"sc-2ba627d-12"})(["&&{color:",";fill:currentColor;}"],({theme:e})=>e.colors.neutral[700]),Vs=a.ul.withConfig({displayName:"ChatPrompts.styled__PromptList",componentId:"sc-2ba627d-13"})(["display:flex;flex-direction:column;"]),Pe=a(S).withConfig({displayName:"ChatPrompts.styled__PromptItem",componentId:"sc-2ba627d-14"})(["&&{justify-content:space-between;width:100%;height:auto;padding-block:0.65em;padding-inline:calc(16px + 0.5rem) 0.5rem;font-weight:400;line-height:1.3;color:",";text-align:start;white-space:normal;border-radius:",";fill:currentColor;}&&:hover:is(:not([aria-disabled='true'])){background-color:",";}"],({theme:e})=>e.colors.neutral[0],({theme:e})=>e.radii.small,({theme:e})=>e.colors.getColor("dark",5)),Ys=3e3,Xs=20,Js=5,Zs=(e,n=Js)=>[...e].sort(()=>Math.random()-.5).slice(0,n),ei=[{icon:Tt,key:"learn",prompts:[{text:"What payment methods are supported?"},{text:"How do I test before going live?"},{text:"Can I migrate data from Sandbox to Production?"},{text:"What emails are sent to my customers?"},{text:"How do I configure payment retries (dunning)?"},{text:"Can I export subscriber data?"},{text:"Does Cleeng support in-app purchases?"},{text:"How do I terminate a subscription via API?"},{text:"What is SRM?"},{text:"How do payouts work if Cleeng is MoR?"},{text:"How does Cleeng handle taxes?"},{text:"Can I customize checkout design?"},{text:"Can I customize transactional emails?"},{text:"Is Cleeng GDPR compliant?"},{text:"What is Hi5?"},{text:"How do I authenticate API requests?"},{text:"What is the base URL for Cleeng APIs?"},{text:"What's the difference between REST and JSON-RPC APIs?"}
14,{text:"How do I check subscriber entitlements?"},{text:"What webhook events does Cleeng support?"},{text:"How do I handle coupons via API?"},{text:"How do I integrate Adyen payments?"},{text:"How do I reconcile transactions?"},{text:"What are common API error codes?"},{text:"How do I use the Identity API?"},{text:"How do I enable Google In-App Billing?"},{text:"How do I integrate Roku billing?"},{text:"How do refunds work?"},{text:"Can I use Cleeng with multiple currencies?"},{text:"Where is subscriber data stored?"},{text:"Does Cleeng provide SSO integration?"},{text:"What is MediaStore SDK?"},{text:"How do I integrate Cleeng with my existing platform?"},{text:"How does Cleeng handle taxes and compliance?"},{text:"What are the key API endpoints I need?"},{text:"How do I handle webhook notifications?"},{text:"What error codes should I handle?"},{text:"How do I implement StoreKit 2 with Cleeng?"},{text:"How do I track revenue and LTV metrics?"},{text:"What are Cleeng's pricing and fees?"},{text:"How does dunning management work?"},{text:"Can I get real-time financial reporting?"},{text:"How do chargebacks and refunds work?"},{text:"How accurate is ChurnIQ's churn prediction?"},{text:"How do I create a subscription offer?"},{text:"Can I create coupon codes and promotions?"},{text:"How do I implement gift subscriptions?"},{text:"What about seasonal or limited-time offers?"},{text:"I need help with a large subscriber payout issue"},{text:"Can you help with compliance and legal questions?"},{text:"How can I track campaign performance and subscriber acquisition?"},{text:"Can I personalize the subscriber experience?"},{text:"Can I customize the customer support interface?"},{text:"What mobile optimization options are available?"},{text:"How do I create a seamless user onboarding flow?"},{text:"Can I customize email templates and notifications?"},{text:"What security certifications does Cleeng have?"},{text:"How does Cleeng handle GDPR compliance?"},{text:"What fraud prevention measures are in place?"},{text:"How is subscriber data protected?"},{text:"Can Cleeng help with PCI DSS compliance?"},{text:"How do I identify my best performing content?"},{text:"What cohort analysis capabilities do you offer?"},{text:"What is Hi5 and how does it work?"},{text:"Can Hi5 provide multilingual support?"},{text:"How does the AI chatbot handle complex subscriber issues?"},{text:"What analytics does Hi5 provide?"},{text:"How does Hi5 integrate with subscriber management?"},{text:"How do I reduce subscriber churn effectively?"},{text:"What's the best way to scale internationally?"},{text:"How quickly can I launch with Cleeng?"},{text:"How do I handle failed payment retries and dunning?"},{text:"What's the best way to implement subscriber entitlements?"},{text:"How do I integrate Cleeng with my CMS or video platform?"},{text:"Can I migrate existing subscribers from another platform?"},{text:"How do I implement single sign-on (SSO) with Cleeng?"},{text:"How do I implement webhook signature verification?"},{text:"What's the rate limit for Cleeng APIs?"},{text:"How do I handle timezone differences for scheduled content?"},{text:"Can I customize the MediaStore SDK checkout flow?"},{text:"How do I implement server-side subscription validation?"},{text:"What happens when a subscriber's payment method expires?"},{text:"How do I monetize fitness and wellness content?"},{text:"What about podcast and audio content monetization?"},{text:"How does Cleeng handle B2B enterprise subscriptions?"},{text:"What's included in Cleeng's onboarding process?"},{text:"How do I train my team on Cleeng's platform?"},{text:"What ongoing support does Cleeng provide?"},{text:"How do I manage user roles and permissions in Cleeng?"},{text:"Can I set up automated reports and notifications?"},{text:"How do I backup and export my subscriber data?"},{text:"What monitoring and alerting options are available?"},{text:"How do I handle subscriber data migration during platform changes?"},{text:"How do I handle refunds and chargebacks efficiently?"},{text:"What financial reporting capabilities does Cleeng offer?"},{text:"How do I optimize my payment acceptance rates?"},{text:"Can I set up revenue sharing with content creators?"},{text:"How do I handle sales tax across different jurisdictions?"},{text:"What happens if my subscriber's bank rejects recurring payments?"},{text:"How do I handle subscribers who want to pause their subscription?"},{text:"What if a subscriber disputes a charge after canceling?"},{text:"How do I handle family sharing and multiple device access?"},{text:"What happens during planned maintenance or outages?"},{text:"How do I migrate from a competitor to Cleeng without losing subscribers?"},{text:"How does ChurnIQ handle seasonal subscription patterns?"},{text:"How do I use ChurnIQ data for investor reporting?"},{text:"How do I integrate Cleeng with WordPress?"},{text:"Can I integrate Cleeng with Shopify or ecommerce platforms?"},{text:"How does Cleeng integrate with video platforms like Vimeo or YouTube?"},{text:"Can I use Cleeng with mobile apps built in React Native or Flutter?"},{text:"How does Cleeng handle different currencies and exchange rates?"},{text:"Can I set different pricing by geographic region?"}
14,{text:"How do I comply with local regulations in different countries?"},{text:"What local payment methods does Cleeng support?"},{text:"How does Cleeng handle traffic spikes during major events?"},{text:"What's Cleeng's global infrastructure like?"},{text:"How do I optimize API performance for high-volume applications?"},{text:"Can Cleeng handle millions of subscribers?"},{text:"Can I create student or military discounts?"},{text:"How do I handle content licensing and geographic restrictions?"},{text:"What happens if I need to change my pricing model mid-stream?"},{text:"Can I offer free trials with or without credit card requirement?"},{text:"How does Cleeng's customer success team help optimize my business?"},{text:"What advanced security features does Cleeng offer beyond basic compliance?"},{text:"What is the process for adding new team members?"},{text:"How do I set up customer notifications for expiring credit cards?"},{text:"How do I review and resolve support tickets through Hi5?"}],show:()=>!0,subtitle:"Setup, configuration, and how things work",title:"Learn",trackingEvent:"ai_assistant_learn_clicked"},{icon:St,key:"data",prompts:[{text:"How many customers canceled their subscriptions this week?"},{text:"Show me the users who have changed their subscription levels, either upgrading or downgrading."},{text:"What percentage of new subscriptions come from returning customers?"},{text:"What is the number of returning customers among our new subscribers?"},{text:"What's the renewal-to-churn ratio among subscribers?"},{text:"How many converted trials did we have last quarter?"},{text:"Which offers had the most cancellations last month?"},{text:"How has revenue changed monthly in the past?"},{text:"Which offers generated the most revenue this month?"},{text:"What is the revenue by country?"},{text:"Show the top 20 campaigns in the last 90 days."},{text:"Show me a trend of upgrades and downgrades on a weekly basis."},{text:"Show me revenue by offer in the last 6 months."},{text:"Show me a trend of usage of different payment methods."},{text:"What is the revenue by channel?"},{text:"What is my transaction volume for each month over the past 6 months?"},{text:"Which offers have generated the highest revenue in the last quarter?"},{text:"How has my transaction volume changed year-over-year?"}],show:({churniqStudioFlag:e})=>e,subtitle:"Charts and answers from your data",title:"Data",trackingEvent:"ai_assistant_data_clicked"},{icon:Nt,key:"insights",prompts:[{text:"What are the key weekly insights?"}],show:({privileges:e})=>e.includes(re.personalDataAccess),subtitle:"Weekly analysis and trends",title:"Insights",trackingEvent:"ai_assistant_insights_clicked"},{icon:At,key:"offers",prompts:[{text:"Create a monthly subscription plan with a 7-day free trial."},{text:"Create an annual subscription offer at â¬99.99."},{text:"Create a 3-month subscription plan with a 14-day free trial."}],show:({privileges:e})=>e.includes(re.offerManagement),subtitle:"Create and manage offers",title:"Offers",trackingEvent:"ai_assistant_offers_clicked"},{icon:Ht,key:"customers",prompts:[{text:"Find a customer by email address."},{text:"Look up a subscriber by their customer ID."},{text:"Show me the full profile for this subscriber."},{text:"What subscriptions does this customer have?"},{text:"Show this customer's current subscription status."},{text:"When does this subscriber's plan renew next?"},{text:"What offer is this subscriber currently on?"},{text:"Show the transaction history for this customer."},{text:"What's this subscriber's total spend to date?"},{text:"Update this customer's email address."},{text:"Change this customer's country."},{text:"Change this customer's first name."},{text:"Change this customer's last name."}],show:({privileges:e})=>e.includes(re.customerAccounts),subtitle:"Manage and understand your subscribers",title:"Customers",trackingEvent:"ai_assistant_customers_clicked"}],ti=()=>{const e=new Date().getHours();return e<12?"Good morning":e<18?"Good afternoon":"Good evening"},ni=e=>{const n=ti();return e?`${n}, ${e}`:n},oi=({hasReachedUsageLimit:e,regenerateMessage:n,sendMessage:o,status:s})=>{const{personalProfile:i,publisherPrivileges:r}=en(),{churniqStudioFlag:c}=we(),{firstName:d,roles:p}=i.data,h=l.useMemo(()=>p?ei.filter(y=>y.show({churniqStudioFlag:c,privileges:r})).map(y=>({...y,prompts:Zs(y.prompts)})):[],[p,r,c]),[u,m]=l.useState(null),[g,_]=l.useState(!0),[v,x]=l.useState(!1);l.useEffect(()=>{if(!g||h.length===0)return;let y=0;m(h[y].key);const b=setInterval(()=>{y=(y+1)%h.length,m(h[y].key)},Ys);return()=>clearInterval(b)}
14,[g,h]);const f=h.find(y=>y.key===u)??null,C=l.useMemo(()=>{var b;const y=(f==null?void 0:f.prompts.filter(T=>!T.to))??[];return((b=y[Math.floor(Math.random()*y.length)])==null?void 0:b.text)??""},[f]),[w,k]=l.useState("");l.useEffect(()=>{if(k(""),!C)return;let y=0;const b=setInterval(()=>{y+=1,k(C.slice(0,y)),y>=C.length&&clearInterval(b)},Xs);return()=>clearInterval(b)},[C]);const j=(y,b)=>{if(_(!1),v&&u===y){x(!1),m(null);return}F.track(b),x(!0),m(y)},N=()=>{x(!1),m(null)},z=l.useCallback(()=>{_(!1)},[]);return t.jsxs(Ds,{children:[t.jsxs(Ls,{children:[t.jsx($s,{children:ni(d)}),t.jsx(Rs,{children:"What can I help you with?"}),t.jsx(Os,{children:"Ask about your data, subscribers, or setup."})]}),t.jsx(Ye,{defaultQuestion:w,hasReachedUsageLimit:e,onFocus:z,placeholder:"",regenerateMessage:n,sendMessage:o,showDisclaimer:!1,size:"large",status:s}),t.jsx(Ws,{align:"start",children:h.map(({icon:y,key:b,title:T,trackingEvent:P})=>t.jsxs(Bs,{$categoryKey:b,$isActive:b===u,$isSelected:v?b===u:!1,onClick:()=>j(b,P),size:"small",children:[t.jsx(y,{size:16}),T]},b))}),f&&v?t.jsxs(Fs,{children:[t.jsxs(qs,{$categoryKey:f.key,children:[t.jsx(f.icon,{size:16}),t.jsxs(Qs,{children:[t.jsx(Us,{children:f.title}),t.jsx(Ks,{children:f.subtitle})]}),t.jsx(Gs,{align:"end","aria-label":`Close ${f.title} prompts`,hasIcon:!0,onClick:N,size:"smallest",children:t.jsx(be,{size:16})})]}),t.jsx(Vs,{children:f.prompts.map(({text:y,to:b})=>b?t.jsxs(Pe,{to:b,children:[y,t.jsx(Et,{size:16})]},y):t.jsx(Pe,{onClick:()=>o(y),children:y},y))})]}):null]})},si=a.h3.withConfig({displayName:"ChatTitle.styled__Title",componentId:"sc-b50b9a22-0"})(["overflow:hidden;display:flex;align-items:center;min-width:0;svg{display:",";}"],({$disableEdit:e})=>e?"none":"block"),ii=a.div.withConfig({displayName:"ChatTitle.styled__TitleContainer",componentId:"sc-b50b9a22-1"})(["overflow:hidden;min-width:0;max-width:100%;"]),ai=a.span.withConfig({displayName:"ChatTitle.styled__TitleText",componentId:"sc-b50b9a22-2"})(["overflow:hidden;flex:1;min-width:0;text-overflow:ellipsis;white-space:nowrap;"]),ri=a.form.withConfig({displayName:"ChatTitle.styled__EditContainer",componentId:"sc-b50b9a22-3"})(["display:flex;gap:0.5em;align-items:center;width:100%;"]),li=a.input.withConfig({displayName:"ChatTitle.styled__EditInput",componentId:"sc-b50b9a22-4"})(["all:unset;width:100%;font-size:1em;font-weight:600;line-height:1.2;text-align:start;"]),ze=a.div.withConfig({displayName:"ChatTitle.styled__EditButtons",componentId:"sc-b50b9a22-5"})(["display:flex;gap:0.5em;margin-inline-start:0.5em;button{all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;color:",";transition:scale 200ms ease-in;&:hover,&:focus-visible{scale:1.4;}}"],({theme:e})=>e.colors.neutral[200]),ci=({title:e,conversationId:n,conversationLoading:o})=>{const[s,i]=l.useState("default"),{mutate:r}=Je(),c=()=>{n&&i("edit")},d=u=>{u.preventDefault();const g=new FormData(u.target).get("title");i("default"),g&&r({conversationId:n,title:g})},p=u=>{u.stopPropagation()},h=async()=>{Xe(n)};return l.useEffect(()=>{i("default")},[n]),t.jsx(ii,{children:s==="edit"?t.jsxs(ri,{onSubmit:d,children:[t.jsx(li,{autoFocus:!0,defaultValue:e,id:"title",name:"title",onKeyDown:p}),t.jsxs(ze,{children:[t.jsx("button",{type:"submit",children:t.jsx(ye,{"aria-label":"confirm edit",width:16})}),t.jsx("button",{color:"red",onClick:()=>i("default"),type:"button",children:t.jsx(be,{"aria-label":"cancel edit",width:16})})]})]}):t.jsxs(si,{$disableEdit:!n,children:[t.jsx(A,{title:e,children:t.jsx(ai,{children:o?"Loading...":t.jsx(Q,{mode:"wait",children:t.jsx(E.span,{animate:"visible",exit:"exit",initial:"hidden",style:{display:"inline-block"},children:e.split("").map((u,m)=>t.jsx(E.span,{animate:{opacity:1},initial:{opacity:0}
14,transition:{duration:.02,delay:m*.01},children:u},`${e}-${m}`))},e)})})}),t.jsxs(ze,{children:[t.jsx("button",{onClick:c,type:"button",children:t.jsx(Mt,{"aria-label":"edit conversation title",width:16})}),t.jsx("button",{onClick:h,type:"button",children:t.jsx(Pt,{"aria-label":"share conversation",width:16})})]})]})})},di=a.div.withConfig({displayName:"Chat.styled__Chat",componentId:"sc-509fad32-0"})(["position:relative;display:flex;flex-direction:column;width:",";height:100%;&::after{content:'';position:absolute;top:50%;right:0;transform:translateY(-50%);width:1px;height:95%;background-color:",";}"],({$isFullscreen:e})=>e?"100%":"419px",({theme:e})=>e.colors.getColor("black",20)),pi=a.h2.withConfig({displayName:"Chat.styled__ChatTitle",componentId:"sc-509fad32-1"})(["display:flex;gap:0.5em;align-items:center;&& div{padding:0.5em 0.75em;}"]),ui=a.header.withConfig({displayName:"Chat.styled__ChatHeader",componentId:"sc-509fad32-2"})(["display:flex;flex-direction:column;gap:0.5em;padding:1.25em 1.5em;h2{font-size:1.5em;font-weight:bold;}h3{max-width:100%;font-size:1em;font-weight:600;line-height:1.2;}div{display:flex;align-items:center;justify-content:space-between;}"]),hi=a.div.withConfig({displayName:"Chat.styled__HeaderActions",componentId:"sc-509fad32-3"})(["display:flex;gap:6px;align-items:center;&& button{color:",";}"],({theme:e})=>e.colors.neutral[550]),De=a.div.withConfig({displayName:"Chat.styled__TabPanel",componentId:"sc-509fad32-4"})(["overflow-y:hidden;display:flex;flex:1;flex-direction:column;&[hidden]{display:none;}",""],({$isFullscreen:e})=>e?Ke(["&& > *{width:100%;max-width:760px;margin-inline:auto;}&& textarea{max-width:none;}"]):null),mi=()=>{const{view:e,setChatOpen:n,setMode:o,mode:s,conversationId:i}=ee(),r=J($=>$.assistant.hasReachedUsageLimit),c=s==="floating",d=s==="fullscreen",{getAccessToken:p}=R(),{data:h}=L({queryFn:p,queryKey:["user","jwt"]}),{data:u,isLoading:m}=kn(i),{data:g=[],isLoading:_}=Tn(i),{messages:v,status:x,setMessages:f,sendMessage:C,regenerate:w,clearError:k}=jn({conversationId:i,initialMessages:g,jwtToken:h??""});l.useEffect(()=>{i&&g.length>0&&v.length<g.length&&x!=="streaming"&&f(g)},[i,g,v.length,f,x]);const j=l.useCallback(()=>{n(!1)},[n]),N=l.useCallback(()=>{o(d?"docked":"fullscreen")},[d,o]),z=l.useCallback(()=>{c||F.track("chat_pinned"),o(c?"docked":"floating")},[c,o]),y=l.useCallback($=>{k(),C({text:$})},[C,k]),b=l.useCallback(()=>{k(),w()},[w,k]),T=l.useCallback(($,W)=>{f(te=>te.map(H=>H.id===$?{...H,feedback:W}:H))},[f]),P=m||_;return t.jsxs(di,{$isFullscreen:d,children:[t.jsxs(ui,{children:[t.jsxs("div",{children:[t.jsx(pi,{children:"Cleeng AI Assistant"}),t.jsxs(hi,{children:[t.jsx(A,{disableInteractive:!0,title:d?"Exit full screen":"Expand AI Assistant to full screen",children:t.jsx(S,{"aria-label":d?"Exit full screen":"Expand AI Assistant to full screen",color:"darkBlue",onClick:N,size:"small",type:"button",children:d?t.jsx(zt,{size:22}):t.jsx(Dt,{size:22})})}),t.jsx(A,{disableInteractive:!0,title:c?"Pin AI Assistant to the side":"Unpin AI Assistant",children:t.jsx(S,{"aria-label":c?"Pin AI Assistant to the side":"Unpin AI Assistant",color:"darkBlue",onClick:z,size:"small",type:"button",children:t.jsx(Lt,{size:22,weight:c?"regular":"fill"})})}),c?null:t.jsx(A,{title:"Hide AI Assistant",children:t.jsx(S,{"aria-label":"Hide AI Assistant",color:"darkBlue",onClick:j,size:"small",type:"button",children:t.jsx($t,{size:22})})})]})]}),e==="chat"?t.jsx(ci,{conversationId:i??"",conversationLoading:P,title:(u==null?void 0:u.title)??"New Conversation"}):null]}),e==="history"?t.jsx(De,{$isFullscreen:d,children:t.jsx(to,{})}):t.jsx(De,{$isFullscreen:d,children:!P&&v.length===0?t.jsx(oi,{hasReachedUsageLimit:r,regenerateMessage:b,sendMessage:y,status:x}):t.jsxs(t.Fragment,{children:[t.jsx(zs,{conversationId:i??"",isLoading:P,messages:v,onFeedbackUpdate:T,regenerateMessage:b,status:x}),t.jsx(Ye,{hasReachedUsageLimit:r,regenerateMessage:b,sendMessage:y,showDisclaimer:!0,status:x})]})})]})},fi=a(E.div).withConfig({displayName:"Assistant.styled__FloatWrapper",componentId:"sc-daacbd61-0"})(["position:relative;flex-shrink:0;height:100%;overflow:visible;"]),gi=a(E.div).withConfig({displayName:"Assistant.styled__AnimationContainer",componentId:"sc-daacbd61-1"})(["position:",";z-index:",";top:0;right:0;overflow:hidden;background-color:",";border-radius:",";box-shadow:",";"],({$isMobileFullscreen:e})=>e?"fixed":"absolute",({$isFloating:e,$isFullscreen:n})=>e?1400:n?1200:"auto",({theme:e})=>e.colors.neutral[1e3],({$isMobileFullscreen:e,theme:n})=>e?"0":n.radii.large,({$isMobileFullscreen:e,theme:n})=>e?"none":n.effects.shadow.sm),Le=a(E.div).withConfig({displayName:"Assistant.styled__ScreenContainer",componentId:"sc-daacbd61-2"})(["overflow:hidden;flex-shrink:0;width:77px;height:100%;"]),xi=a.div.withConfig({displayName:"Assistant.styled__DragHandle",componentId:"sc-daacbd61-3"})(["display:flex;justify-content:center;align-items:center;background-color:white;width:100%;padding:4px 0;cursor:grab;touch-action:none;user-select:none;&:active{cursor:grabbing;}"]),yi=a.div.withConfig({displayName:"Assistant.styled__ChatScreenWrapper",componentId:"sc-daacbd61-4"})(["display:flex;flex-direction:column;height:100%;overflow:hidden;> :last-child{flex:1;height:auto;min-height:0;}"]),bi=a.div.withConfig({displayName:"Assistant.styled__ChatContainer",componentId:"sc-daacbd61-5"})(["position:relative;display:flex;justify-content:end;width:100%;height:100%;"]),wi=(e,n)=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 50 50",ref:n,...e},l.createElement("rect",{width:50,height:50,fill:"#766ab2",rx:8,transform:"matrix(-1 0 0 1 50 0)"}),l.createElement("path",{fill:"#DBDCF0",d:"M34.022 28.31c-.285-.775-1.38-.775-1.675 0l-.944 2.558a.9.9 0 0 1-.526.525l-2.557.945c-.775.285-.775 1.38 0 1.675l2.557.944a.9.9 0 0 1 .526.526l.944 2.557c.285.775 1.381.775 1.675 0l.945-2.557a.9.9 0 0 1 .525-.526l2.558-.944c.775-.285.775-1.381 0-1.675l-2.558-.945a.9.9 0 0 1-.525-.525z"}),l.createElement("path",{fill:"#fff",d:"M23.749 13.404c-.428-1.167-2.076-1.167-2.504 0l-1.907 5.141c-.134.365-.428.65-.793.793l-5.14 1.907c-1.168.427-1.168 2.076 0 2.503l5.14 1.907c.365.134.65.428.793.793l1.907 5.141c.428 1.168 2.076 1.168 2.504 0l1.906-5.14c.134-.366.428-.651.793-.794l5.141-1.907c1.168-.427 1.168-2.076 0-2.503l-5.14-1.9
1407a1.36 1.36 0 0 1-.794-.793z"})),Ci=l.forwardRef(wi),vi=Ue(["0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}"]),Ii=a.button.withConfig({displayName:"ChatSidebar.styled__IconButton",componentId:"sc-e368a3c2-0"})(["all:unset;position:relative;cursor:pointer;border-radius:",";padding:3px;svg{width:42px;position:relative;z-index:1;}",";"],({theme:e})=>e.radii.medium,({$animate:e,theme:n})=>e&&Ke(["padding:5px;overflow:hidden;&::before{content:'';position:absolute;inset:-50%;background:conic-gradient( from 0deg,transparent 0deg,"," 90deg,"," 180deg,transparent 360deg );animation:"," 3s linear infinite;}&::after{content:'';position:absolute;inset:7px;background-color:theme.colors.neutral[1000];border-radius:theme.radii[500];}"],n.colors.neutral[1e3],n.colors.getColor("purple"),vi)),_i=a.aside.withConfig({displayName:"ChatSidebar.styled__Sidebar",componentId:"sc-e368a3c2-1"})(["display:flex;flex-direction:column;align-items:center;height:100%;padding:1.25em 1.5em;background-color:",";> div{display:flex;flex-direction:column;gap:1em;margin-block-start:1em;> button{display:flex;flex-direction:column;justify-content:center;width:58px;height:auto !important;margin-inline:auto;padding-block:0.5em;font-size:0.8rem;font-weight:500;}}"],({theme:e})=>e.colors.neutral[1e3]),$e=a(S).withConfig({displayName:"ChatSidebar.styled__TabButton",componentId:"sc-e368a3c2-2"})(["isolation:isolate;position:relative;display:flex;flex-direction:column;justify-content:center;width:58px;height:auto !important;margin-inline:auto;padding-block:0.5em;font-size:0.8rem;font-weight:500;"]),Re=a(E.div).withConfig({displayName:"ChatSidebar.styled__ActiveIndicator",componentId:"sc-e368a3c2-3"})(["position:absolute;z-index:-1;top:0;left:0;width:100%;height:100%;background-color:color-mix(in srgb,",",transparent 92%);border-radius:8px;"],({theme:e})=>e.colors.button.darkBlue),U="assistant-seen",ji=()=>{const{handleCollapsing:e}=Be(),{setConversationId:n,setChatOpen:o,setView:s,chatOpen:i,conversationId:r,view:c,mode:d,openUserAgreementModal:p}=ee(),{deleteSearchParam:h}=Qe(),u=Z(),m=l.useCallback(()=>{i||e(!0)},[i,e]),g=l.useCallback(()=>{const w=u.getQueryData(["assistant","user-agreement"]);return(w==null?void 0:w.accepted)!==!1},[u]),_=l.useCallback(()=>{if(m(),se.remove("new"),localStorage.setItem(U,"true"),!g()){p("chat");return}F.track("ai_assistant_was_opened"),n(null),h("conversationId",!0),o(!0),s("chat")},[n,o,s,m,h,g,p]),v=l.useCallback(()=>{if(m(),localStorage.setItem(U,"true"),!g()){p("chat");return}F.track("ai_assistant_was_opened"),o(!0),s("chat")},[o,s,m,g,p]),x=l.useCallback(()=>{if(m(),localStorage.setItem(U,"true"),!g()){p("history");return}F.track("ai_assistant_was_opened"),o(!0),s("history")},[o,s,m,g,p]),f=i&&c==="chat"&&!r,C=l.useCallback(()=>{if(d!=="floating"){if(m(),localStorage.setItem(U,"true"),!i){if(!g()){p("chat");return}F.track("ai_assistant_was_opened")}o(!i)}},[o,i,m,d,g,p]);return t.jsxs(_i,{children:[t.jsx(A,{disableInteractive:!0,title:"Open AI Assistant",children:t.jsx(Ii,{$animate:!localStorage.getItem(U),"aria-label":"Open AI Assistant",onClick:C,type:"button",children:t.jsx(Ci,{})})}),t.jsxs("div",{"aria-label":"Assistant navigation",role:"tablist",children:[t.jsx(A,{disableInteractive:!0,title:"Create new chat",children:t.jsxs(S,{"aria-label":"Create new chat",color:"darkBlue",disabled:f,onClick:_,type:"button",children:[t.jsx(Rt,{size:22}),"New"]})}),t.jsx(A,{disableInteractive:!0,title:"Open chat",children:t.jsxs($e,{"aria-label":"Open chat","aria-selected":c==="chat",color:"darkBlue",onClick:v,role:"tab",type:"button",children:[i&&c==="chat"?t.jsx(Re,{layout:!0,layoutId:"sidebar-tab-highlight"}):null,t.jsx(me,{size:22}),"Chat"]})}),t.jsx(A,{disableInteractive:!0,title:"Open chat history",children:t.jsxs($e,{"aria-label":"Open chat history","aria-selected":c==="history",color:"darkBlue",onClick:x,role:"tab",type:"button",children:[i&&c==="history"?t.jsx(Re,{layout:!0,layoutId:"sidebar-tab-highlight"}):null,t.jsx(Ot,{size:22}),"History"]})})]})]})},pe="assistant-active-conversation",at=500,rt=500,ki=854,Oe=77;let ue=0,he=0;const We=()=>({bottom:window.innerHeight-rt,left:-(window.innerWidth-at),right:0,top:0}),Ti=e=>{const n=xn(),o=Te(0),s=Te(0),[i,r]=l.useState(void 0),c=()=>{ue=o.get(),he=s.get()};return l.useEffect(()=>{if(e==="floating"){B(o,ue,{duration:.3,ease:"easeInOut"}),B(s,he,{duration:.3,ease:"easeInOut"}),r(We());return}r(void 0),B(o,0,{duration:.3,ease:"easeInOut"}),B(s,0,{duration:.3,ease:"easeInOut"})},[e,o,s]),l.useEffect(()=>{if(e!=="floating")return;const d=()=>{const p=We();r(p);const h=Math.min(p.right,Math.max(p.left,o.get())),u=Math.min(p.bottom,Math.max(p.top,s.get()));h!==o.get()&&(B(o,h,{duration:.2}),ue=h),u!==s.get()&&(B(s,u,{duration:.2}
14),he=u)};return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[e]),{constraints:i,dragControls:n,savePosition:c,x:o,y:s}},Si=(e,n,o)=>({chat:{animate:{opacity:1,width:n?`${e-Oe}px`:"423px"},exit:{opacity:0,width:"0px"},initial:{opacity:0,width:"0px"}},container:{closed:{height:"100%",width:"77px"},floating:{height:`${rt}px`,transition:{duration:.2,width:{delay:.2}},width:`${at}px`},fullscreen:{height:"100%",width:`${e}px`},open:{height:"100%",width:"500px"}},sidebar:{closed:{width:"77px"},floating:{width:"77px"},fullscreen:{width:`${Oe}px`},open:{width:"77px"}},wrapper:{closed:{width:"77px"},floating:{transition:{duration:.3},width:"0px"},fullscreen:{width:o?"0px":"500px"},open:{width:"500px"}}}),kl=()=>{const{aiAssistantFlag:e}=we(),{chatOpen:n,conversationId:o,isUserAgreementFetched:s,mode:i,openUserAgreementModal:r,setChatOpen:c,setConversationId:d,setMode:p,setView:h,userAgreement:u}=ee(),{getSearchParam:m}=Qe(),{isCollapsed:g}=Be(),{constraints:_,dragControls:v,savePosition:x,x:f,y:C}=Ti(i),{pathname:w}=Ie(),k=l.useRef(!1),j=l.useRef(n),N=l.useRef(w),[z,y]=l.useState(()=>window.innerWidth),b=i==="floating",T=i==="fullscreen";l.useEffect(()=>{w!==N.current&&(N.current=w,T&&p("docked"))},[w,T,p]),l.useLayoutEffect(()=>{if(!T)return;const H=new ResizeObserver(([ae])=>{y(ae.contentRect.width)});return H.observe(document.documentElement),()=>H.disconnect()},[T]),l.useEffect(()=>{const H=j.current;j.current=n,n&&o?localStorage.setItem(pe,o):!n&&H&&localStorage.setItem(pe,"")},[n,o]),l.useEffect(()=>{if(k.current||!s)return;const H=m("conversationId"),ae=localStorage.getItem(pe),_e=H||ae;if(_e){if(k.current=!0,d(_e),(u==null?void 0:u.accepted)===!1){r("chat");return}c(!0),h("chat")}},[s,u==null?void 0:u.accepted]);const P=T&&z<=ki,$=P?z:z-(g?Bt:Ft)-qt*2,W=l.useMemo(()=>Si($,T,P),[$,T,P]),te=l.useMemo(()=>n?b?"floating":T?"fullscreen":"open":"closed",[n,b,T]);return e?t.jsx(Q,{initial:!1,children:t.jsx(fi,{animate:te,variants:W.wrapper,children:t.jsx(gi,{$isFloating:b,$isFullscreen:T,$isMobileFullscreen:P,animate:te,drag:b,dragConstraints:_,dragControls:v,dragElastic:0,dragListener:!1,dragMomentum:!1,onDragEnd:x,style:{x:f,y:C},variants:W.container,children:t.jsxs(bi,{children:[t.jsx(Q,{mode:"wait",children:n?t.jsx(Le,{...W.chat,children:t.jsxs(yi,{children:[b?t.jsx(xi,{onPointerDown:H=>v.start(H),children:t.jsx(Wt,{size:22})}):null,t.jsx(mi,{})]})}):null}),t.jsx(Le,{variants:W.sidebar,children:t.jsx(ji,{})})]})})})}):null};export{kl as Assistant}; 15//# sourceMappingURL=Assistant-D4VU6IQG.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.