@opencx/widget-react 4.0.38 → 4.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/src/hooks/useTranslation.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
${h.screens.welcome.width},
|
|
15
15
|
${h.screens.sessions.width},
|
|
16
16
|
${h.screens.chat.width}
|
|
17
|
-
)`)};return{theme:h,computed:k,cssVars:Yt({palette:h.palette,primary:h.primaryColor})}}function Yt({palette:t,primary:r}){const s=mt(t),o=Ye(r).toHsl(),n=Ye(r).isLight()?s[950]:s[50];return{"--opencx-primary":`${o.h} ${o.s*100}% ${o.l*100}%`,"--opencx-primary-foreground":n,"--opencx-background":s[100],"--opencx-foreground":s[950],"--opencx-destructive":"0 72.2% 50.6%","--opencx-destructive-foreground":s[50],"--opencx-accent":s[200],"--opencx-accent-foreground":"var(--opencx-foreground)","--opencx-secondary":s[200],"--opencx-secondary-foreground":"var(--opencx-foreground)","--opencx-muted":s[200],"--opencx-muted-foreground":s[500],"--opencx-input":s[300],"--opencx-border":s[300],"--opencx-ring":"var(--opencx-foreground)"}}function mt(t){const r={50:"0 0% 98%",100:"0 0% 96.1%",200:"0 0% 89.8%",300:"0 0% 83.1%",400:"0 0% 63.9%",500:"0 0% 45.1%",600:"0 0% 32.2%",700:"0 0% 25.1%",800:"0 0% 14.9%",900:"0 0% 9%",950:"0 0% 3.9%"},s={50:"60 9.1% 97.8%",100:"60 4.8% 95.9%",200:"20 5.9% 90%",300:"24 5.7% 82.9%",400:"24 5.4% 63.9%",500:"25 5.3% 44.7%",600:"33.3 5.5% 32.4%",700:"30 6.3% 25.1%",800:"12 6.5% 15.1%",900:"24 9.8% 10%",950:"20 14.3% 4.1%"},o={50:"0 0% 98%",100:"240 4.8% 95.9%",200:"240 5.9% 90%",300:"240 4.9% 83.9%",400:"240 5% 64.9%",500:"240 3.8% 46.1%",600:"240 5.2% 33.9%",700:"240 5.3% 26.1%",800:"240 3.7% 15.9%",900:"240 5.9% 10%",950:"240 10% 3.9%"},n={50:"210 40% 98%",100:"210 40% 96.1%",200:"214.3 31.8% 91.4%",300:"212.7 26.8% 83.9%",400:"215 20.2% 65.1%",500:"215.4 16.3% 46.9%",600:"215.3 19.3% 34.5%",700:"215.3 25% 26.7%",800:"217.2 32.6% 17.5%",900:"222.2 47.4% 11.2%",950:"222.2 84% 4.9%"};switch(t){case"neutral":return r;case"stone":return s;case"zinc":return o;case"slate":return n;default:return I.isExhaustive(t,mt.name),r}}function ut(){const{contentIframeRef:t}=l.useWidget(),{inline:r}=l.useConfig();return{setWidth:s=>{var o;(o=t==null?void 0:t.current)==null||o.style.setProperty("--opencx-widget-width",r?"100%":s)},setHeight:s=>{var o;(o=t==null?void 0:t.current)==null||o.style.setProperty("--opencx-widget-height",r?"100%":s)}}}function me({width:t,height:r}){const{isSmallScreen:s}=E(),{setWidth:o,setHeight:n}=ut();m.useEffect(()=>{t&&o(t),r&&n(r)},[s,r,t,o,n])}const Ve=u.CircleDashedIcon;function X({name:t,className:r}){const s=(()=>{switch(t){case"Check":return u.CheckIcon;case"CheckCheck":return u.CheckCheckIcon;case"CircleCheck":return u.CircleCheckIcon;case"CircleCheckBig":return u.CircleCheckBigIcon;case"CircleX":return u.CircleXIcon;case"Expand":return u.ExpandIcon;case"Maximize":return u.MaximizeIcon;case"Maximize2":return u.Maximize2Icon;case"Minimize":return u.MinimizeIcon;case"Minimize2":return u.Minimize2Icon;case"Shrink":return u.ShrinkIcon;case"SquareCheck":return u.SquareCheckIcon;case"SquareCheckBig":return u.SquareCheckBigIcon;case"SquareX":return u.SquareXIcon;case"X":return u.XIcon;case void 0:return Ve;default:return I.isExhaustive(t,X.name),Ve}})();return e.jsx(s,{className:p("size-4",r)})}function G(){const{widgetCtx:{org:t}}=l.useWidget(),{sessionState:{session:r}}=l.useSessions(),s=l.useConfig(),{messagesState:{messages:o}}=l.useMessages(),{routerState:{screen:n}}=l.useWidgetRouter();return{react:m,org:t,session:r,config:s,messages:o,currentScreen:n}}function Xt(){var s;const t=G(),r=(s=t.config.customComponents)==null?void 0:s.headerBottom;return r?e.jsx(r,{...t}):null}function Vt({fallback:t}){var o;const r=G(),s=(o=r.config.customComponents)==null?void 0:o.headerTitle;return s?e.jsx(s,{...r}):t}function ue(){const{widgetCtx:{org:t}}=l.useWidget(),{routerState:{screen:r}}=l.useWidgetRouter(),{textContent:s}=l.useConfig();return(()=>{var n,a;switch(r){case"chat":return(n=s==null?void 0:s.chatScreen)==null?void 0:n.headerTitle;case"sessions":return(a=s==null?void 0:s.sessionsScreen)==null?void 0:a.headerTitle;case"welcome":return;default:I.isExhaustive(r,ue.name);return}})()??t.name??"Chat"}function Gt(t){switch(t){case"chat":return w("chat/header");case"sessions":return w("sessions/header");case"welcome":return;default:I.isExhaustive(t,ue.name);return}}function Kt(){const{router:t}=l.useConfig(),{routerState:{screen:r},toSessionsScreen:s}=l.useWidgetRouter();return r!=="chat"||t!=null&&t.chatScreenOnly?null:e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",onClick:s,children:e.jsx(u.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})})}function Qt({button:t}){const{setIsOpen:r}=l.useWidgetTrigger(),{isSmallScreen:s}=E();if(s&&t.hideOnSmallScreen||!s&&t.hideOnLargeScreen)return null;const o=()=>{if(t.handleClick)return t.handleClick();r(!1)};return e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",onClick:o,children:e.jsx(X,{name:t.icon})})}function ae({button:t}){const[r,s]=m.useState(!1),{routerState:{screen:o}}=l.useWidgetRouter(),{isSmallScreen:n}=E(),{theme:a}=q(),{setWidth:i,setHeight:c}=ut();if(o!=="chat"&&o!=="sessions")return null;const d=(()=>{switch(o){case"chat":return a.screens.chat.height;case"sessions":return a.screens.sessions.height;default:return I.isExhaustive(o,ae.name),a.screens.chat.height}})(),h=(()=>{switch(o){case"chat":return a.screens.chat.width;case"sessions":return a.screens.sessions.width;default:return I.isExhaustive(o,ae.name),a.screens.chat.width}})(),k=()=>{s(j=>{const g=!j;return c(g?"100vh":d),i(g?`max(40vw, ${h})`:h),g})};return n&&t.hideOnSmallScreen||!n&&t.hideOnLargeScreen?null:e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",onClick:k,children:e.jsx(X,{name:t.icon||(r?t.shrinkIcon:t.expandIcon)})})}function gt({button:t}){var C,T;const{close:r}=se(),{widgetCtx:s}=l.useWidget(),{setIsOpen:o}=l.useWidgetTrigger(),{resolveSession:n,sessionState:a}=l.useSessions(),{isSmallScreen:i}=E(),c=!a.session,d=((C=a.session)==null?void 0:C.isOpened)===!1,h=t.onResolved||"stay-in-chat",k=t.behaviorBeforeSessionCreation||"disabled",j=t.behaviorIfSessionIsResolved||"disabled",g=!!(a.isResolvingSession||c&&k==="disabled"||d&&j==="disabled"),S=async()=>{const{success:v,error:M}=await n();if(r(),!v)return console.error(M);switch(h){case"stay-in-chat":return;case"close-widget":o(!1);break;case"reset-chat":s.resetChat();break;case"reset-chat-and-close-widget":o(!1),s.resetChat();break;default:I.isExhaustive(h,gt.name);break}},f=()=>{if(c)switch(k){case"disabled":return;case"close-widget":o(!1);break;default:I.isExhaustive(k,f.name)}if(d)switch(j){case"disabled":return;case"close-widget":o(!1);break;case"reset-chat":s.resetChat();break;case"reset-chat-and-close-widget":o(!1),setTimeout(()=>{s.resetChat()},200);break;default:I.isExhaustive(j,f.name)}};return i&&t.hideOnSmallScreen||!i&&t.hideOnLargeScreen?null:((T=t.confirmation)==null?void 0:T.type)==="modal"&&!d&&!c?e.jsx(lt,{trigger:e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",disabled:g,children:e.jsx(X,{name:t.icon})}),children:e.jsxs(st,{children:[e.jsx(rt,{children:e.jsx(it,{children:t.confirmation.title||"Close conversation"})}),e.jsx(ot,{children:e.jsx(at,{children:t.confirmation.description||"Are you sure you want to close this conversation?"})}),e.jsxs(nt,{children:[e.jsx(z,{variant:"secondary",onClick:r,disabled:a.isResolvingSession,children:t.confirmation.cancelButtonText||"No"}),e.jsx(z,{variant:"destructive",onClick:S,disabled:a.isResolvingSession,children:t.confirmation.confirmButtonText||"Yes"})]})]})}):e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",onClick:d||c?f:S,disabled:g,children:e.jsx(X,{name:t.icon})})}function le({button:t}){switch(t.functionality){case"close-widget":return e.jsx(Qt,{button:t});case"expand-shrink":return e.jsx(ae,{button:t});case"resolve-session":return e.jsx(gt,{button:t});default:return I.isExhaustive(t,le.name),null}}const Zt={functionality:"close-widget",hideOnLargeScreen:!0,icon:"X"};function Jt(){const{routerState:{screen:t}}=l.useWidgetRouter(),{headerButtons:r}=l.useConfig(),s=t==="chat"?r==null?void 0:r.chatScreen:t==="sessions"?r==null?void 0:r.sessionsScreen:[];return!s||s.length===0?e.jsx(le,{button:Zt}):e.jsx(e.Fragment,{children:s.map(o=>e.jsx(le,{button:o},`${o.functionality}-${o.icon}`))})}function wt(){const{routerState:{screen:t}}=l.useWidgetRouter(),r=Gt(t),s=ue();return e.jsxs("header",{...r,className:"py-2 px-4 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kt,{}),e.jsx("div",{className:p("flex-1 h-8 flex items-center",t==="sessions"&&"ps-2"),children:e.jsx(Vt,{fallback:e.jsx("h2",{className:"font-semibold",children:s})})}),e.jsx(Jt,{})]}),e.jsx(Xt,{})]})}function ft({className:t}){return e.jsx(u.LoaderIcon,{className:p("size-4 animate-spin",t)})}function es(){const{messagesState:{isInitialFetchLoading:t}}=l.useMessages(),{isSmallScreen:r}=E(),{activeMode:s,Component:o}=l.useModes();return{isCanvasOpen:!t&&!r&&!!s&&!!o}}function ts(){const t=G(),{activeMode:r,Component:s}=l.useModes(),{sendMessage:o}=l.useMessages(),{createStateCheckpoint:n}=l.useSessions(),[a,i]=m.useState(!1),c=async d=>{try{i(!0),await o(d)}catch(h){console.error(h)}finally{i(!1)}};return!r||!s?null:e.jsx(s,{...t,mode:r,createStateCheckpoint:n,sendMessage:c,isSendingMessage:a})}const R=m.forwardRef((t,r)=>{var s,o,n;return e.jsx(x,{...t,ref:r,className:p("overflow-hidden",t.className),overrides:{initial:{height:0,opacity:0,...(s=t.overrides)==null?void 0:s.initial},animate:{height:"auto",opacity:1,...(o=t.overrides)==null?void 0:o.animate},exit:{height:0,opacity:0,...(n=t.overrides)==null?void 0:n.exit}}})});R.displayName="MotionDiv__VerticalReveal";const ss=[{label:"Terrible",value:1,emoji:"😡"},{label:"Poor",value:2,emoji:"😞"},{label:"Okay",value:3,emoji:"😐"},{label:"Good",value:4,emoji:"😊"},{label:"Great",value:5,emoji:"😍"}];function rs(){const{isSmallScreen:t}=E(),{submitCsat:r,isCsatRequested:s,isCsatSubmitted:o,submittedScore:n,submittedFeedback:a}=l.useCsat(),[i,c]=m.useState(null),[d,h]=m.useState(null),k=g=>{c(S=>S===g?null:g)},j=()=>{i&&r({score:i,feedback:d||void 0})};return!s&&!o?null:e.jsxs("div",{className:"w-1/2 min-w-80 max-w-96 mx-auto overflow-hidden",children:[e.jsx(y.AnimatePresence,{mode:"wait",children:s&&!i?e.jsx(R,{children:e.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:"How was your conversation?"})},"csat-requested-title"):o?e.jsx(R,{children:e.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:"You rated the conversation as"})},"csat-submitted-title"):null}),e.jsx("div",{className:p("flex gap-4 justify-between pt-2 px-2 pb-2","transition-all",o&&"gap-0 justify-center"),children:ss.map(g=>e.jsx(z,{variant:g.value===i?"secondary":"ghost",size:"selfless",className:p("transition-all overflow-hidden","text-2xl size-8 rounded-full","opacity-35","hover:opacity-100",!i&&"opacity-100",g.value===i&&"opacity-100",o&&g.value!==n&&"opacity-0 size-0",o&&g.value===n&&"opacity-100 size-fit text-4xl"),onClick:s?()=>k(g.value):void 0,children:g.emoji},g.value))}),e.jsx(y.AnimatePresence,{mode:"wait",children:(i||n)&&e.jsx(R,{children:e.jsxs("div",{className:"pb-2 px-2 flex items-end",children:[e.jsx("textarea",{rows:3,className:p("transition-all","max-h-40 [field-sizing:content]","w-full resize-none","bg-transparent outline-none","placeholder:text-muted-foreground",t?"text-[16px]":"text-sm",o&&"text-center"),value:o?a||"":d||"",onChange:s?g=>h(g.target.value):void 0,readOnly:o,placeholder:s?"Tell us more... (optional)":void 0}),e.jsx(z,{size:"fit",onClick:j,disabled:!i,className:p("transition-all overflow-hidden","rounded-full size-8 flex items-center justify-center p-0",o&&"opacity-0 size-0"),children:e.jsx(u.ArrowUpIcon,{className:"size-4"})})]})},"feedback-box")}),e.jsx("div",{className:p("h-0 transition-[height]",o&&"h-4")})]})}function $(){const{dir:t}=l.useDocumentDir(),r=l.useConfig();return m.useMemo(()=>{const s=I.isSupportedLanguage(r.language)?r.language:"en";return{t:o=>I.getTranslation(o,s,r.translationOverrides),language:s,dir:s==="ar"?"rtl":"ltr",hostDocumentDir:t}},[r.language,t])}function ge({suggestion:t,className:r,...s}){const{sendMessage:o}=l.useMessages(),n=()=>{const a=t.trim();a&&o({content:a})};return e.jsx(z,{...w("chat/suggested_reply_btn"),size:"sm",className:p("rounded-xl w-fit",r),...s,onClick:n,children:t})}function os(){const{t}=$(),r=[t("i_need_more_help"),t("this_was_helpful")];return e.jsx("div",{...w("chat/might_solve_user_issue_suggested_replies_container"),className:"flex items-center gap-2 p-2 pb-0 flex-wrap",children:r.map(s=>e.jsx(ge,{suggestion:s,className:"flex-1"},s))})}function Ge(){const{sessionState:t}=l.useSessions(),{chatFooterItems:r}=l.useConfig(),s=!!t.session&&!t.session.isOpened,o=!s;return e.jsx(y.AnimatePresence,{mode:"wait",children:r==null?void 0:r.map((n,a)=>n.showWhenSessionIsOpen===!1&&o||n.showWhenSessionIsResolved===!1&&s?null:e.jsx(R,{children:e.jsx("div",{className:"pb-2 text-center text-xs",children:e.jsx(ce,{children:n.message})})},`${n.message}-${a}`))})}function ns({file:{status:t,file:r,error:s},onCancel:o}){const[n,a]=m.useState(null);m.useEffect(()=>{if(!r.type.startsWith("image/"))return;const d=new FileReader;return d.onload=()=>a(d.result),d.onerror=()=>console.error("Error reading file"),d.readAsDataURL(r),()=>d.abort()},[r]);const i=()=>{switch(t){case"uploading":return e.jsx(u.Loader2,{className:"size-4 animate-spin"});case"error":return e.jsx(u.AlertCircle,{className:"size-4 text-destructive"});default:return null}},c=()=>{const d=r.type.split("/")[0];return d==="image"&&n?e.jsx("img",{src:typeof n=="string"?n:"",className:"object-cover bg-secondary size-full",alt:r.name}):d==="audio"?e.jsx(u.FileAudio2Icon,{}):d==="video"?e.jsx(u.FileVideo2Icon,{}):e.jsx(u.FileIcon,{})};return e.jsx(Y,{side:"bottom",content:t==="error"?e.jsxs("span",{className:"text-destructive",children:["Failed to upload: ",s]}):r.name,children:e.jsxs("div",{className:p(t==="uploading"&&"opacity-50","group","size-12 border rounded-2xl overflow-hidden relative","flex items-center justify-center shrink-0"),children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:i()}),e.jsx("button",{type:"button",className:p("absolute bg-black/50 inset-0 size-full z-10 opacity-0","flex items-center justify-center","opacity-0 group-hover:opacity-100 transition"),onClick:o,children:e.jsx(u.XIcon,{className:"size-4 text-primary-foreground"})}),e.jsx(c,{})]})})}function is(){var D;const{isSmallScreen:t}=E(),r=m.useRef(null),{sendMessage:s}=l.useMessages(),{sessionState:o}=l.useSessions(),{t:n}=$(),[a,i]=m.useState(""),{allFiles:c,emptyTheFiles:d,handleCancelUpload:h,appendFiles:k,isUploading:j,successFiles:g}=l.useUploadFiles(),S=!!((D=o.session)!=null&&D.isHandedOff),{isAwaitingBotReply:f}=l.useIsAwaitingBotReply(),C=b=>{k(b)},T=!a.trim()&&g.length===0,v=async()=>{if(f||T)return;j&&console.info("please wait for the file(s) to upload");const b=a.trim();s({content:b,attachments:g.flatMap(N=>N.fileUrl?[{url:N.fileUrl,type:N.file.type,name:N.file.name,id:N.id,size:N.file.size}]:[])}),i(""),d()},{getRootProps:M,getInputProps:P,open:W}=It.useDropzone({onDrop:C,noClick:!0,onDropRejected(){console.error("unsupported file type, or the file is too large")},maxSize:5*1024*1024,accept:S?{"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],"application/pdf":[".pdf"]}:{"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]}}),A=b=>{const N=b.clipboardData;N&&N.files.length>0&&C(Array.from(N.files))};return e.jsxs("div",{...w("chat/input_box/root"),className:"p-2 relative space-y-1",...M(),children:[e.jsx("input",{...P()}),e.jsxs("div",{...w("chat/input_box/inner_root"),className:p("transition-all","bg-white","relative rounded-3xl flex flex-col gap-2 p-2","hover:border-primary focus-within:border-primary"),children:[e.jsxs("div",{...w("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[c.length>0&&e.jsx("div",{...w("chat/input_box/attachments_container"),className:"flex items-center gap-1",children:e.jsx(y.AnimatePresence,{mode:"popLayout",children:c.map(b=>e.jsx(x,{snapExit:!0,children:e.jsx(ns,{onCancel:()=>h(b.id),file:b})},b.id))})}),e.jsx("textarea",{...w("chat/input_box/textarea"),onPaste:A,ref:r,id:"chat-input",value:a,rows:3,className:p("max-h-16 [field-sizing:content]","w-full resize-none px-2",c.length===0&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground",t?"text-[16px]":"text-sm"),onChange:b=>i(b.target.value),onKeyDown:async b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),v())},placeholder:n("write_a_message_placeholder")})]}),e.jsxs("div",{className:"gap-2 flex justify-between",children:[e.jsx(Y,{side:"top",align:"start",content:"attach files, (maximum size 5mb)",children:e.jsx(z,{onClick:W,size:"fit",variant:"ghost",className:p("rounded-full size-8 flex items-center justify-center p-0 overflow-hidden"),children:e.jsx(y.AnimatePresence,{mode:"wait",children:S&&!f?e.jsx(x,{children:e.jsx(u.PaperclipIcon,{className:"size-4"})},"paper-clip"):e.jsx(x,{children:e.jsx(u.ImageIcon,{className:"size-4"})},"image-icon")})})}),e.jsx(Y,{content:"send message",side:"top",align:"end",children:e.jsx(z,{size:"fit",onClick:v,disabled:f||j||T,className:"rounded-full size-8 flex items-center justify-center p-0",children:e.jsx(y.AnimatePresence,{mode:"wait",children:f||j?e.jsx(x,{snapExit:!0,children:e.jsx(u.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):e.jsx(x,{snapExit:!0,children:e.jsx(u.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})}function Ke(){const{widgetCtx:t}=l.useWidget(),{router:r}=l.useConfig(),{canCreateNewSession:s}=l.useSessions(),{toSessionsScreen:o}=l.useWidgetRouter(),{t:n}=$();return e.jsx(e.Fragment,{children:s||r!=null&&r.chatScreenOnly?e.jsx(z,{onClick:t.resetChat,className:"rounded-2xl w-full",children:n("new_conversation")}):e.jsx(z,{onClick:o,className:"rounded-2xl w-full",children:n("back_to_conversations")})})}function as(){const{t}=$(),{isCsatRequested:r,isCsatSubmitted:s}=l.useCsat();return e.jsx("div",{className:"p-2",children:e.jsx("div",{className:"p-2 bg-muted rounded-3xl",children:e.jsx(y.AnimatePresence,{mode:"wait",children:r||s?e.jsxs(R,{children:[e.jsx(rs,{}),e.jsx(y.AnimatePresence,{mode:"wait",children:s&&e.jsx(R,{children:e.jsx(Ke,{})},"new-conv-or-back-to-convs-button")})]},"csat"):e.jsxs(R,{children:[e.jsxs("div",{className:"ps-2 flex items-center gap-1 pb-2",children:[e.jsx(u.CircleCheckIcon,{className:"size-4 text-emerald-600"}),e.jsx("h2",{className:"text-sm font-medium",children:t("your_issue_has_been_resolved")})]}),e.jsx(Ke,{})]},"session-closed")})})})}function ls(){var i;const{initialQuestions:t,initialQuestionsPosition:r,thisWasHelpfulOrNot:s}=l.useConfig(),{sessionState:o}=l.useSessions(),{messagesState:n}=l.useMessages(),a=n.messages.length===0;return e.jsx("footer",{children:e.jsx(y.AnimatePresence,{mode:"wait",children:o.session&&!((i=o.session)!=null&&i.isOpened)?e.jsxs(R,{children:[e.jsx(as,{}),e.jsx(Ge,{})]},"session-closed"):e.jsxs(R,{children:[n.lastAIResMightSolveUserIssue&&(s==null?void 0:s.enabled)!==!1&&e.jsx(os,{}),a&&t&&r!=="below-initial-messages"&&e.jsx("div",{className:"flex items-center flex-row justify-end gap-2 flex-wrap px-2",children:t==null?void 0:t.map((c,d)=>e.jsx(ge,{suggestion:c},`${c}-${d}`))}),e.jsx(is,{}),e.jsx(Ge,{})]},"chat-input")})})}function cs({isFirstInGroup:t,isLastInGroup:r,isAloneInGroup:s,...o}){const{componentStore:n}=l.useWidget();if(o.type!=="AGENT"&&o.type!=="AI")return null;if(o.data.action){const i=n.getComponent(o.data.action.name);if(i)return e.jsx(i,{...o,id:o.id,isFirstInGroup:t,isLastInGroup:r,isAloneInGroup:s})}const a=n.getComponent(o.component);return a?e.jsx(a,{...o,id:o.id,isFirstInGroup:t,isLastInGroup:r,isAloneInGroup:s}):e.jsx(ne,{...o,isFirstInGroup:t,isLastInGroup:r,isAloneInGroup:s})}function xt({messages:t,className:r,containerClassName:s}){var i,c;const{timestamps:o}=l.useConfig();if(!((i=o==null?void 0:o.perMessageGroup)!=null&&i.enabled))return null;const n=(c=t[t.length-1])==null?void 0:c.timestamp;if(!n)return null;const a=(()=>{try{return new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(d){return console.error(d),null}})();return a?e.jsx("div",{className:s,children:e.jsx("span",{className:p("text-xs text-muted-foreground",r),children:a})}):null}function J({messages:t,agent:r,suggestedReplies:s}){return e.jsxs("div",{...w("chat/agent_msg_group/root"),className:p("flex items-end gap-2"),children:[e.jsx(Y,{content:r==null?void 0:r.name,side:"right",align:"end",children:e.jsx(ie,{...w("chat/agent_msg_group/root/avatar"),agent:r,className:"hidden"})}),e.jsxs("div",{className:p("flex-1 flex flex-col gap-1"),children:[e.jsxs("div",{...w("chat/agent_msg_group/avatar_and_msgs/root"),className:p("flex items-end gap-2"),children:[e.jsx(Y,{content:r==null?void 0:r.name,side:"right",align:"end",children:e.jsx(ie,{...w("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:r})}),e.jsxs("div",{...w("chat/agent_msg_group/avatar_and_msgs/msgs"),className:p("flex-1 flex flex-col gap-1"),children:[t.map((o,n,a)=>e.jsx(cs,{isFirstInGroup:n===0,isLastInGroup:n===a.length-1,isAloneInGroup:a.length===1,...o},o.id)),e.jsx(xt,{messages:t})]})]}),s&&s.length>0&&e.jsx("div",{...w("chat/agent_msg_group/suggestions"),className:p("flex flex-col gap-1 ps-8"),children:s==null?void 0:s.map((o,n)=>e.jsx(ge,{suggestion:o},`${o}-${n}`))})]})]})}function ds(){var s,o;const t=G();if((s=t.session)!=null&&s.isOpened||!t.session)return null;const r=(o=t.config.customComponents)==null?void 0:o.onSessionResolved;return r?e.jsx(r,{...t}):null}function ps({message:t,isFirstInGroup:r,isLastInGroup:s,isAloneInGroup:o}){var n;return e.jsxs("div",{...w("chat/user_msg/root"),className:"w-5/6 flex flex-col items-end gap-1",children:[t.attachments&&t.attachments.length>0&&e.jsx("div",{className:"w-full flex gap-1 flex-wrap justify-end",children:(n=t.attachments)==null?void 0:n.map(a=>e.jsx(ct,{attachment:a},a.id))}),t.content.length>0&&e.jsx("div",{...w("chat/user_msg/msg"),"data-first":r,"data-last":s,"data-alone":o,className:p("transition-all","w-fit py-3 px-4 rounded-3xl text-sm","bg-primary text-primary-foreground","break-words [word-break:break-word]","whitespace-pre-wrap",r&&!o&&"rounded-br-md",s&&!o&&"rounded-tr-md",!r&&!s&&!o&&"rounded-r-md"),children:t.content})]})}function hs({messages:t}){return e.jsxs("div",{...w("chat/user_msg_group/root"),className:p("group","flex flex-col gap-1 justify-end items-end"),children:[t.map((r,s,o)=>e.jsx(ps,{message:r,isFirstInGroup:s===0,isLastInGroup:s===o.length-1,isAloneInGroup:o.length===1},r.id)),e.jsx(xt,{messages:t,containerClassName:"ms-auto"})]})}function ms(t){const r=[];let s=null;return t.forEach(o=>{var n,a,i,c,d,h;(((n=s==null?void 0:s[0])==null?void 0:n.type)!==o.type||((a=s[0])==null?void 0:a.type)==="AGENT"&&o.type==="AGENT"&&(((i=o.agent)==null?void 0:i.id)!==((c=s[0].agent)==null?void 0:c.id)||((d=o.agent)==null?void 0:d.name)!==((h=s[0].agent)==null?void 0:h.name)))&&(s=[],r.push(s)),s.push(o)}),r}function us(t){var r;return((r=t==null?void 0:t[0])==null?void 0:r.type)==="USER"}function gs(t){var r;return((r=t==null?void 0:t[0])==null?void 0:r.type)==="AI"}function ws(t){var r;return((r=t==null?void 0:t[0])==null?void 0:r.type)==="AGENT"}function fs(){const{messagesState:{messages:t}}=l.useMessages(),{advancedInitialMessages:r=[],initialQuestionsPosition:s,initialQuestions:o,bot:n}=l.useConfig();return e.jsx(e.Fragment,{children:t.length===0&&r.length>0&&e.jsx(J,{messages:r.map(({message:a},i)=>({component:"bot_message",data:{message:a},id:`${i}-${a}`,type:"AI",timestamp:null})),suggestedReplies:t.length===0&&s==="below-initial-messages"?o:void 0,agent:n?{...n,isAi:!0,id:null}:void 0})})}function xs(){const{messagesState:{messages:t}}=l.useMessages(),{chatBannerItems:r}=l.useConfig();return!(r!=null&&r.length)||t.length>0&&r.every(s=>!s.persistent)?null:e.jsx("div",{className:"w-full text-center text-xs",children:r.map(({message:s,persistent:o},n)=>t.length>0&&!o?null:e.jsx("div",{children:e.jsx(ce,{children:s})},`${s}-${n}`))})}function vs(){const{messagesState:{messages:t}}=l.useMessages(),r=l.useConfig(),{advancedInitialMessages:s=[],initialQuestions:o,initialQuestionsPosition:n}=r,a=(()=>{var i;return s.length?[]:t.length?[]:(i=r.initialMessages)!=null&&i.length?r.initialMessages:["Hello, how can I help you?"]})();return e.jsx(e.Fragment,{children:t.length===0&&a.length>0&&e.jsx(J,{messages:a.map((i,c)=>({component:"bot_message",data:{message:i},id:`${c}-${i}`,type:"AI",timestamp:null})),suggestedReplies:n==="below-initial-messages"?o:void 0,agent:r.bot?{...r.bot,isAi:!0,id:null}:void 0})})}function bs(){var s;const t=G(),r=(s=t.config.customComponents)==null?void 0:s.chatBottomComponents;return r?e.jsx("div",{children:r.map(({key:o,component:n})=>e.jsx(n,{...t},o))}):null}function ys(){const{messagesState:{messages:t}}=l.useMessages(),{isAwaitingBotReply:r}=l.useIsAwaitingBotReply(),{componentStore:s}=l.useWidget(),{bot:o,humanAgent:n}=l.useConfig(),a=m.useMemo(()=>ms(t),[t]),i=s.getComponent("loading"),c=m.useRef(null);function d(){setTimeout(()=>{const h=c.current;h&&(h.scrollTop=h.scrollHeight)},0)}return m.useEffect(()=>{d()},[t]),e.jsxs("div",{...w("chat/msgs/root"),ref:c,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[e.jsx(xs,{}),e.jsx(fs,{}),e.jsx(vs,{}),a.map((h,k)=>{var S,f,C,T;const j=(S=h==null?void 0:h[0])==null?void 0:S.type,g=(f=h[0])==null?void 0:f.id;if(!j||!g)return null;if(us(h))return e.jsx(hs,{messages:h},g);if(gs(h)){const v=k===a.length-1;return r&&v?null:((C=h[0])==null||C.agent,e.jsx(J,{messages:h,agent:o?{...o,isAi:!0,id:null}:void 0},g))}if(ws(h)){const v=(T=h[0])==null?void 0:T.agent;return e.jsx(J,{messages:h,agent:v?{...v,name:(n==null?void 0:n.name)||v.name||"",avatarUrl:(n==null?void 0:n.avatarUrl)||v.avatarUrl||null}:n?{isAi:!1,id:null,name:n.name||"",avatarUrl:n.avatarUrl||null}:void 0},g)}return null}),r&&i&&e.jsx(i,{agent:o}),e.jsx(bs,{}),e.jsx(ds,{})]})}function js(){const{messagesState:{isInitialFetchLoading:t}}=l.useMessages(),{sessionState:{session:r}}=l.useSessions(),{isCanvasOpen:s}=es(),{theme:o}=q();me({width:s?o.screens.chat.withCanvas.width:o.screens.chat.width,height:s?o.screens.chat.withCanvas.height:o.screens.chat.height});const n=m.useRef((r==null?void 0:r.id)||"chat").current;return e.jsx("div",{...w("chat/root"),className:p("flex flex-col overflow-hidden"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:e.jsxs("div",{className:"size-full justify-between flex flex-col",children:[e.jsx(wt,{}),e.jsx(y.AnimatePresence,{mode:"wait",children:t?e.jsx(x,{className:"flex flex-col items-center justify-center w-full flex-1",children:e.jsx(ft,{})},"loading"):e.jsxs(x,{className:"flex items-start h-full flex-1 overflow-auto",snapExit:!0,children:[e.jsxs("div",{...w("chat/main/root"),className:p("flex flex-col h-full overflow-auto transition-all",s?"w-2/5":"w-full"),style:{transitionTimingFunction:o.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:o.screens.chat.withCanvas.transitionDuration},children:[e.jsx(ys,{}),e.jsx(ls,{})]}),e.jsx("div",{...w("chat/canvas/root"),className:p("h-full overflow-auto transition-all",s?"w-3/5":"w-0"),style:{transitionTimingFunction:o.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:o.screens.chat.withCanvas.transitionDuration},children:e.jsx(ts,{})})]},n)})]})})}function ks({className:t,...r}){return e.jsx("div",{className:p("animate-pulse rounded-md bg-secondary",t),...r})}function Cs({className:t}){return e.jsx("svg",{width:"26",height:"32",viewBox:"0 0 26 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:p("text-primary-foreground",t),children:e.jsx("path",{d:"M1.34103 25.6132H5.44245C5.74203 25.6228 6.02673 25.7462 6.23867 25.9582C6.45062 26.1703 6.5739 26.4551 6.58348 26.7548V30.8584C6.59305 31.1581 6.71634 31.443 6.92828 31.655C7.14023 31.8671 7.42492 31.9904 7.7245 32H18.2894C18.589 31.9904 18.8737 31.8671 19.0856 31.655C19.2976 31.443 19.4209 31.1581 19.4304 30.8584V26.7548C19.4401 26.4545 19.5638 26.1692 19.7765 25.957C19.9892 25.7449 20.2748 25.6219 20.5749 25.6132H24.659C24.9586 25.6036 25.2433 25.4803 25.4552 25.2682C25.6671 25.0562 25.7904 24.7713 25.8 24.4716V7.52839C25.7904 7.22865 25.6671 6.94381 25.4552 6.73176C25.2433 6.5197 24.9586 6.39635 24.659 6.38677H20.561C20.2603 6.37802 19.9742 6.25457 19.7614 6.04169C19.5487 5.82881 19.4253 5.54261 19.4165 5.24168V1.14161C19.4072 0.84419 19.2858 0.561291 19.0768 0.349589C18.8678 0.137887 18.5865 0.0130193 18.2894 0L7.7245 0C7.42492 0.00957792 7.14023 0.132929 6.92828 0.344983C6.71634 0.557036 6.59305 0.841878 6.58348 1.14161V5.24168C6.57477 5.54203 6.45187 5.82773 6.23983 6.04052C6.0278 6.25331 5.74262 6.37715 5.44245 6.38677H1.34103C1.04144 6.39635 0.756749 6.5197 0.544805 6.73176C0.332861 6.94381 0.209574 7.22865 0.200001 7.52839V24.4716C0.209574 24.7713 0.332861 25.0562 0.544805 25.2682C0.756749 25.4803 1.04144 25.6036 1.34103 25.6132ZM6.58348 24.4716V7.52839C6.59305 7.22865 6.71634 6.94381 6.92828 6.73176C7.14023 6.5197 7.42492 6.39635 7.7245 6.38677H18.2894C18.589 6.39635 18.8737 6.5197 19.0856 6.73176C19.2976 6.94381 19.4209 7.22865 19.4304 7.52839V24.4716C19.4209 24.7713 19.2976 25.0562 19.0856 25.2682C18.8737 25.4803 18.589 25.6036 18.2894 25.6132H7.7245C7.42492 25.6036 7.14023 25.4803 6.92828 25.2682C6.71634 25.0562 6.59305 24.7713 6.58348 24.4716Z",fill:"currentColor"})})}function vt({className:t}){const{token:r}=l.useConfig();return e.jsx("div",{className:p("flex items-center justify-center gap-2 p-2 pt-0",t),children:e.jsx(O,{children:e.jsxs("a",{href:`https://open.cx/?ref=${r}`,target:"_blank",rel:"noreferrer",className:p("text-[10px] flex items-center","text-muted-foreground/70 [&_svg]:text-muted-foreground/70","hover:text-primary [&_svg]:hover:text-primary"),children:[e.jsx("span",{children:"Powered by"}),e.jsx("span",{children:" "}),e.jsxs("span",{className:"flex items-center gap-[1px]",children:[e.jsx("span",{children:e.jsx(Cs,{className:"size-3 inline-block"})}),e.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function zs({children:t}){return e.jsx("p",{className:"ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:t})}function Qe({session:t,className:r}){const{bot:s,humanAgent:o}=l.useConfig(),{toChatScreen:n}=l.useWidgetRouter(),a=t.assignee.kind==="human"?(o==null?void 0:o.name)||t.assignee.name||"Support Agent":(s==null?void 0:s.name)||"AI Support Agent",i=t.assignee.kind==="human"?(o==null?void 0:o.avatarUrl)||t.assignee.avatarUrl||"":(s==null?void 0:s.avatarUrl)||(s==null?void 0:s.avatar)||"";return e.jsxs(z,{variant:"ghost",size:"lg",className:p("rounded-full p-2 pe-4 flex text-start justify-between w-full whitespace-normal",r),onClick:()=>n(t.id),children:[e.jsxs("div",{className:"flex-1 flex gap-2 items-center",children:[e.jsx(y.AnimatePresence,{mode:"wait",children:e.jsx(x,{snapExit:!0,children:e.jsxs(de,{className:"size-10",children:[e.jsx(pe,{src:i,alt:"Agent Icon"}),e.jsx(he,{children:e.jsx(u.UserRoundIcon,{className:"size-4"})})]})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(y.AnimatePresence,{mode:"wait",children:e.jsx(x,{snapExit:!0,children:a},a)}),e.jsx(y.AnimatePresence,{mode:"wait",children:t.lastMessage?e.jsx(x,{snapExit:!0,children:e.jsx(dt,{remarkPlugins:[Ze],rehypePlugins:[Je],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:t.lastMessage})},t.lastMessage||"content"):e.jsx(x,{className:"w-1/2",snapExit:!0,children:e.jsx(ks,{className:"h-4 w-full"})},"skeleton")})]})]}),e.jsx(u.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0 rtl:-scale-100"})]})}function Ss(){const{t}=$(),{toChatScreen:r}=l.useWidgetRouter(),{sessionsState:{data:s,isInitialFetchLoading:o},openSessions:n,closedSessions:a,canCreateNewSession:i}=l.useSessions();return e.jsx("div",{className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:e.jsx(y.AnimatePresence,{mode:"wait",children:o?e.jsx(x,{className:"flex-1 flex items-center justify-center",children:e.jsx(ft,{})},"loading"):e.jsx(x,{className:"flex-1 flex flex-col gap-2 relative",children:s.length?e.jsxs(e.Fragment,{children:[e.jsxs(y.AnimatePresence,{children:[n.length>0&&e.jsx(x,{fadeIn:"up",delay:.2,className:"space-y-2",snapExit:!0,children:n.map(c=>e.jsx(Qe,{session:c},c.id))},"open-sessions"),a.length>0&&e.jsxs(x,{className:"space-y-2",delay:.2,snapExit:!0,children:[e.jsx(zs,{children:t("closed_conversations")}),a.map(c=>e.jsx(Qe,{session:c,className:"opacity-50 hover:opacity-100"},c.id))]},"closed-sessions")]}),i&&e.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:m.createElement(z,{...w("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>r()},t("new_conversation"))})]}):e.jsxs("div",{className:"flex-1 flex flex-col gap-2 items-center",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:t("no_conversations_yet")})}),m.createElement(z,{...w("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>r()},t("new_conversation"))]})},"sessions")})})}function Ns(){const{theme:t}=q();return me({width:t.screens.sessions.width,height:t.screens.sessions.height}),e.jsx("div",{...w("sessions/root"),className:p("flex flex-col overflow-hidden bg-background"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:e.jsxs("div",{className:"size-full flex flex-col",children:[e.jsx(wt,{}),e.jsx(Ss,{}),e.jsx(vt,{})]})})}const Z=B.forwardRef(({className:t,type:r,...s},o)=>{const{isSmallScreen:n}=E();return e.jsx(O,{ref:o,children:e.jsx("input",{type:r,className:p(n?"text-[16px]":"text-sm","flex w-full rounded-xl p-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-primary-foreground placeholder:text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition","rounded-2xl px-4","border shadow-sm",t),...s})})});Z.displayName="Input";function _s(){const{contentIframeRef:t}=l.useWidget(),{inline:r}=l.useConfig(),s=m.useRef(null);return m.useEffect(()=>{const o=t==null?void 0:t.current;if(o&&s.current){const n=s.current;let a;const i=new ResizeObserver(()=>{a=requestAnimationFrame(()=>{const c=n.offsetHeight;o.style.setProperty("--opencx-widget-height",r?"100%":`${c.toFixed(1)}px`)})});return i.observe(n),()=>{cancelAnimationFrame(a),i.unobserve(n)}}},[t,r]),{observedElementRef:s}}const Ts=oe.z.object({name:oe.z.string().min(2),email:oe.z.string().email()});function Is(){var v,M,P,W,A,D,b,N;const{widgetCtx:{org:t}}=l.useWidget(),{setIsOpen:r}=l.useWidgetTrigger(),{createUnverifiedContact:s}=l.useContact(),{isSmallScreen:o}=E(),n=l.useConfig(),{theme:a}=q(),{t:i}=$(),{observedElementRef:c}=_s();me({height:void 0,width:a.screens.welcome.width});const[d,h]=m.useState(((v=n.prefillUserData)==null?void 0:v.name)||""),[k,j]=m.useState(((M=n.prefillUserData)==null?void 0:M.email)||""),g=(n.extraDataCollectionFields||[]).filter(_=>_!=="name"&&_!=="email"&&!!_),[S,f]=m.useState({}),[C,T]=Mt(async _=>{_.preventDefault();const F=Ts.safeParse({name:d,email:k});F.success&&await s({email:F.data.email,non_verified_name:F.data.name},Object.values(S).filter(Boolean).length?S:void 0)},[d,k,S]);return e.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:a.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:e.jsxs("div",{ref:c,className:p("flex flex-col",o&&"h-full","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[e.jsxs("div",{className:p("flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10","text-primary-foreground"),children:[o&&e.jsx(x,{className:"absolute top-6 end-6",children:e.jsx(z,{size:"selfless",onClick:()=>r(!1),children:e.jsx(u.XIcon,{className:"size-4"})})}),e.jsx("div",{className:"flex items-center justify-between w-full mb-2",children:(P=n.assets)!=null&&P.organizationLogo?e.jsx("img",{src:(W=n.assets)==null?void 0:W.organizationLogo,alt:"Company Logo",className:"h-8 w-auto object-contain"}):e.jsx("h2",{className:"font-bold text-sm",children:t.name})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-[1.75rem] font-semibold tracking-tight leading-none",children:((D=(A=n.textContent)==null?void 0:A.welcomeScreen)==null?void 0:D.title)||i("welcome_screen_title")}),e.jsx("p",{className:"text-sm",children:((N=(b=n.textContent)==null?void 0:b.welcomeScreen)==null?void 0:N.description)||i("welcome_screen_description")})]})]}),e.jsxs("div",{className:p("z-10 m-2 px-2 pt-2 bp-0 space-y-2","bg-[white]","border shadow","rounded-3xl"),children:[e.jsxs("form",{onSubmit:T,className:"space-y-2",children:[e.jsx(Z,{value:d,onChange:_=>h(_.target.value),required:!0,placeholder:i("your_name_placeholder"),name:"name"}),e.jsx(Z,{required:!0,value:k,onChange:_=>j(_.target.value),type:"email",placeholder:i("your_email_placeholder"),name:"email"}),g.map(_=>e.jsx(Z,{value:S[_],onChange:F=>f(K=>({...K,[_]:F.target.value})),placeholder:`${_} (${i("optional")})`},_)),e.jsxs(z,{disabled:C.loading,className:"w-full",size:"lg",children:[C.loading?i("start_chat_button_loading"):i("start_chat_button"),e.jsx(u.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),e.jsx(vt,{})]})]})})}function bt(){const{routerState:{screen:t}}=l.useWidgetRouter();return e.jsx("div",{className:"relative bg-background size-full",children:e.jsx(y.AnimatePresence,{mode:"wait",children:(()=>{switch(t){case"welcome":return e.jsx(x,{fadeIn:"right",className:"size-full",snapExit:!0,children:e.jsx(Is,{})},t);case"sessions":return e.jsx(x,{fadeIn:"right",className:"size-full",snapExit:!0,children:e.jsx(Ns,{})},t);case"chat":return e.jsx(x,{fadeIn:"right",className:"size-full",snapExit:!0,children:e.jsx(js,{})},t);default:return I.isExhaustive(t,bt.name),null}})()})})}const Ms="4.0.38",Ds=`<!DOCTYPE html>
|
|
17
|
+
)`)};return{theme:h,computed:k,cssVars:Yt({palette:h.palette,primary:h.primaryColor})}}function Yt({palette:t,primary:r}){const s=mt(t),o=Ye(r).toHsl(),n=Ye(r).isLight()?s[950]:s[50];return{"--opencx-primary":`${o.h} ${o.s*100}% ${o.l*100}%`,"--opencx-primary-foreground":n,"--opencx-background":s[100],"--opencx-foreground":s[950],"--opencx-destructive":"0 72.2% 50.6%","--opencx-destructive-foreground":s[50],"--opencx-accent":s[200],"--opencx-accent-foreground":"var(--opencx-foreground)","--opencx-secondary":s[200],"--opencx-secondary-foreground":"var(--opencx-foreground)","--opencx-muted":s[200],"--opencx-muted-foreground":s[500],"--opencx-input":s[300],"--opencx-border":s[300],"--opencx-ring":"var(--opencx-foreground)"}}function mt(t){const r={50:"0 0% 98%",100:"0 0% 96.1%",200:"0 0% 89.8%",300:"0 0% 83.1%",400:"0 0% 63.9%",500:"0 0% 45.1%",600:"0 0% 32.2%",700:"0 0% 25.1%",800:"0 0% 14.9%",900:"0 0% 9%",950:"0 0% 3.9%"},s={50:"60 9.1% 97.8%",100:"60 4.8% 95.9%",200:"20 5.9% 90%",300:"24 5.7% 82.9%",400:"24 5.4% 63.9%",500:"25 5.3% 44.7%",600:"33.3 5.5% 32.4%",700:"30 6.3% 25.1%",800:"12 6.5% 15.1%",900:"24 9.8% 10%",950:"20 14.3% 4.1%"},o={50:"0 0% 98%",100:"240 4.8% 95.9%",200:"240 5.9% 90%",300:"240 4.9% 83.9%",400:"240 5% 64.9%",500:"240 3.8% 46.1%",600:"240 5.2% 33.9%",700:"240 5.3% 26.1%",800:"240 3.7% 15.9%",900:"240 5.9% 10%",950:"240 10% 3.9%"},n={50:"210 40% 98%",100:"210 40% 96.1%",200:"214.3 31.8% 91.4%",300:"212.7 26.8% 83.9%",400:"215 20.2% 65.1%",500:"215.4 16.3% 46.9%",600:"215.3 19.3% 34.5%",700:"215.3 25% 26.7%",800:"217.2 32.6% 17.5%",900:"222.2 47.4% 11.2%",950:"222.2 84% 4.9%"};switch(t){case"neutral":return r;case"stone":return s;case"zinc":return o;case"slate":return n;default:return I.isExhaustive(t,mt.name),r}}function ut(){const{contentIframeRef:t}=l.useWidget(),{inline:r}=l.useConfig();return{setWidth:s=>{var o;(o=t==null?void 0:t.current)==null||o.style.setProperty("--opencx-widget-width",r?"100%":s)},setHeight:s=>{var o;(o=t==null?void 0:t.current)==null||o.style.setProperty("--opencx-widget-height",r?"100%":s)}}}function me({width:t,height:r}){const{isSmallScreen:s}=E(),{setWidth:o,setHeight:n}=ut();m.useEffect(()=>{t&&o(t),r&&n(r)},[s,r,t,o,n])}const Ve=u.CircleDashedIcon;function X({name:t,className:r}){const s=(()=>{switch(t){case"Check":return u.CheckIcon;case"CheckCheck":return u.CheckCheckIcon;case"CircleCheck":return u.CircleCheckIcon;case"CircleCheckBig":return u.CircleCheckBigIcon;case"CircleX":return u.CircleXIcon;case"Expand":return u.ExpandIcon;case"Maximize":return u.MaximizeIcon;case"Maximize2":return u.Maximize2Icon;case"Minimize":return u.MinimizeIcon;case"Minimize2":return u.Minimize2Icon;case"Shrink":return u.ShrinkIcon;case"SquareCheck":return u.SquareCheckIcon;case"SquareCheckBig":return u.SquareCheckBigIcon;case"SquareX":return u.SquareXIcon;case"X":return u.XIcon;case void 0:return Ve;default:return I.isExhaustive(t,X.name),Ve}})();return e.jsx(s,{className:p("size-4",r)})}function G(){const{widgetCtx:{org:t}}=l.useWidget(),{sessionState:{session:r}}=l.useSessions(),s=l.useConfig(),{messagesState:{messages:o}}=l.useMessages(),{routerState:{screen:n}}=l.useWidgetRouter();return{react:m,org:t,session:r,config:s,messages:o,currentScreen:n}}function Xt(){var s;const t=G(),r=(s=t.config.customComponents)==null?void 0:s.headerBottom;return r?e.jsx(r,{...t}):null}function Vt({fallback:t}){var o;const r=G(),s=(o=r.config.customComponents)==null?void 0:o.headerTitle;return s?e.jsx(s,{...r}):t}function ue(){const{widgetCtx:{org:t}}=l.useWidget(),{routerState:{screen:r}}=l.useWidgetRouter(),{textContent:s}=l.useConfig();return(()=>{var n,a;switch(r){case"chat":return(n=s==null?void 0:s.chatScreen)==null?void 0:n.headerTitle;case"sessions":return(a=s==null?void 0:s.sessionsScreen)==null?void 0:a.headerTitle;case"welcome":return;default:I.isExhaustive(r,ue.name);return}})()??t.name??"Chat"}function Gt(t){switch(t){case"chat":return w("chat/header");case"sessions":return w("sessions/header");case"welcome":return;default:I.isExhaustive(t,ue.name);return}}function Kt(){const{router:t}=l.useConfig(),{routerState:{screen:r},toSessionsScreen:s}=l.useWidgetRouter();return r!=="chat"||t!=null&&t.chatScreenOnly?null:e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",onClick:s,children:e.jsx(u.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})})}function Qt({button:t}){const{setIsOpen:r}=l.useWidgetTrigger(),{isSmallScreen:s}=E();if(s&&t.hideOnSmallScreen||!s&&t.hideOnLargeScreen)return null;const o=()=>{if(t.handleClick)return t.handleClick();r(!1)};return e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",onClick:o,children:e.jsx(X,{name:t.icon})})}function ae({button:t}){const[r,s]=m.useState(!1),{routerState:{screen:o}}=l.useWidgetRouter(),{isSmallScreen:n}=E(),{theme:a}=q(),{setWidth:i,setHeight:c}=ut();if(o!=="chat"&&o!=="sessions")return null;const d=(()=>{switch(o){case"chat":return a.screens.chat.height;case"sessions":return a.screens.sessions.height;default:return I.isExhaustive(o,ae.name),a.screens.chat.height}})(),h=(()=>{switch(o){case"chat":return a.screens.chat.width;case"sessions":return a.screens.sessions.width;default:return I.isExhaustive(o,ae.name),a.screens.chat.width}})(),k=()=>{s(j=>{const g=!j;return c(g?"100vh":d),i(g?`max(40vw, ${h})`:h),g})};return n&&t.hideOnSmallScreen||!n&&t.hideOnLargeScreen?null:e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",onClick:k,children:e.jsx(X,{name:t.icon||(r?t.shrinkIcon:t.expandIcon)})})}function gt({button:t}){var C,T;const{close:r}=se(),{widgetCtx:s}=l.useWidget(),{setIsOpen:o}=l.useWidgetTrigger(),{resolveSession:n,sessionState:a}=l.useSessions(),{isSmallScreen:i}=E(),c=!a.session,d=((C=a.session)==null?void 0:C.isOpened)===!1,h=t.onResolved||"stay-in-chat",k=t.behaviorBeforeSessionCreation||"disabled",j=t.behaviorIfSessionIsResolved||"disabled",g=!!(a.isResolvingSession||c&&k==="disabled"||d&&j==="disabled"),S=async()=>{const{success:v,error:M}=await n();if(r(),!v)return console.error(M);switch(h){case"stay-in-chat":return;case"close-widget":o(!1);break;case"reset-chat":s.resetChat();break;case"reset-chat-and-close-widget":o(!1),s.resetChat();break;default:I.isExhaustive(h,gt.name);break}},f=()=>{if(c)switch(k){case"disabled":return;case"close-widget":o(!1);break;default:I.isExhaustive(k,f.name)}if(d)switch(j){case"disabled":return;case"close-widget":o(!1);break;case"reset-chat":s.resetChat();break;case"reset-chat-and-close-widget":o(!1),setTimeout(()=>{s.resetChat()},200);break;default:I.isExhaustive(j,f.name)}};return i&&t.hideOnSmallScreen||!i&&t.hideOnLargeScreen?null:((T=t.confirmation)==null?void 0:T.type)==="modal"&&!d&&!c?e.jsx(lt,{trigger:e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",disabled:g,children:e.jsx(X,{name:t.icon})}),children:e.jsxs(st,{children:[e.jsx(rt,{children:e.jsx(it,{children:t.confirmation.title||"Close conversation"})}),e.jsx(ot,{children:e.jsx(at,{children:t.confirmation.description||"Are you sure you want to close this conversation?"})}),e.jsxs(nt,{children:[e.jsx(z,{variant:"secondary",onClick:r,disabled:a.isResolvingSession,children:t.confirmation.cancelButtonText||"No"}),e.jsx(z,{variant:"destructive",onClick:S,disabled:a.isResolvingSession,children:t.confirmation.confirmButtonText||"Yes"})]})]})}):e.jsx(z,{variant:"ghost",size:"fit",className:"rounded-full",onClick:d||c?f:S,disabled:g,children:e.jsx(X,{name:t.icon})})}function le({button:t}){switch(t.functionality){case"close-widget":return e.jsx(Qt,{button:t});case"expand-shrink":return e.jsx(ae,{button:t});case"resolve-session":return e.jsx(gt,{button:t});default:return I.isExhaustive(t,le.name),null}}const Zt={functionality:"close-widget",hideOnLargeScreen:!0,icon:"X"};function Jt(){const{routerState:{screen:t}}=l.useWidgetRouter(),{headerButtons:r}=l.useConfig(),s=t==="chat"?r==null?void 0:r.chatScreen:t==="sessions"?r==null?void 0:r.sessionsScreen:[];return!s||s.length===0?e.jsx(le,{button:Zt}):e.jsx(e.Fragment,{children:s.map(o=>e.jsx(le,{button:o},`${o.functionality}-${o.icon}`))})}function wt(){const{routerState:{screen:t}}=l.useWidgetRouter(),r=Gt(t),s=ue();return e.jsxs("header",{...r,className:"py-2 px-4 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kt,{}),e.jsx("div",{className:p("flex-1 h-8 flex items-center",t==="sessions"&&"ps-2"),children:e.jsx(Vt,{fallback:e.jsx("h2",{className:"font-semibold",children:s})})}),e.jsx(Jt,{})]}),e.jsx(Xt,{})]})}function ft({className:t}){return e.jsx(u.LoaderIcon,{className:p("size-4 animate-spin",t)})}function es(){const{messagesState:{isInitialFetchLoading:t}}=l.useMessages(),{isSmallScreen:r}=E(),{activeMode:s,Component:o}=l.useModes();return{isCanvasOpen:!t&&!r&&!!s&&!!o}}function ts(){const t=G(),{activeMode:r,Component:s}=l.useModes(),{sendMessage:o}=l.useMessages(),{createStateCheckpoint:n}=l.useSessions(),[a,i]=m.useState(!1),c=async d=>{try{i(!0),await o(d)}catch(h){console.error(h)}finally{i(!1)}};return!r||!s?null:e.jsx(s,{...t,mode:r,createStateCheckpoint:n,sendMessage:c,isSendingMessage:a})}const R=m.forwardRef((t,r)=>{var s,o,n;return e.jsx(x,{...t,ref:r,className:p("overflow-hidden",t.className),overrides:{initial:{height:0,opacity:0,...(s=t.overrides)==null?void 0:s.initial},animate:{height:"auto",opacity:1,...(o=t.overrides)==null?void 0:o.animate},exit:{height:0,opacity:0,...(n=t.overrides)==null?void 0:n.exit}}})});R.displayName="MotionDiv__VerticalReveal";const ss=[{label:"Terrible",value:1,emoji:"😡"},{label:"Poor",value:2,emoji:"😞"},{label:"Okay",value:3,emoji:"😐"},{label:"Good",value:4,emoji:"😊"},{label:"Great",value:5,emoji:"😍"}];function rs(){const{isSmallScreen:t}=E(),{submitCsat:r,isCsatRequested:s,isCsatSubmitted:o,submittedScore:n,submittedFeedback:a}=l.useCsat(),[i,c]=m.useState(null),[d,h]=m.useState(null),k=g=>{c(S=>S===g?null:g)},j=()=>{i&&r({score:i,feedback:d||void 0})};return!s&&!o?null:e.jsxs("div",{className:"w-1/2 min-w-80 max-w-96 mx-auto overflow-hidden",children:[e.jsx(y.AnimatePresence,{mode:"wait",children:s&&!i?e.jsx(R,{children:e.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:"How was your conversation?"})},"csat-requested-title"):o?e.jsx(R,{children:e.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:"You rated the conversation as"})},"csat-submitted-title"):null}),e.jsx("div",{className:p("flex gap-4 justify-between pt-2 px-2 pb-2","transition-all",o&&"gap-0 justify-center"),children:ss.map(g=>e.jsx(z,{variant:g.value===i?"secondary":"ghost",size:"selfless",className:p("transition-all overflow-hidden","text-2xl size-8 rounded-full","opacity-35","hover:opacity-100",!i&&"opacity-100",g.value===i&&"opacity-100",o&&g.value!==n&&"opacity-0 size-0",o&&g.value===n&&"opacity-100 size-fit text-4xl"),onClick:s?()=>k(g.value):void 0,children:g.emoji},g.value))}),e.jsx(y.AnimatePresence,{mode:"wait",children:(i||n)&&e.jsx(R,{children:e.jsxs("div",{className:"pb-2 px-2 flex items-end",children:[e.jsx("textarea",{rows:3,className:p("transition-all","max-h-40 [field-sizing:content]","w-full resize-none","bg-transparent outline-none","placeholder:text-muted-foreground",t?"text-[16px]":"text-sm",o&&"text-center"),value:o?a||"":d||"",onChange:s?g=>h(g.target.value):void 0,readOnly:o,placeholder:s?"Tell us more... (optional)":void 0}),e.jsx(z,{size:"fit",onClick:j,disabled:!i,className:p("transition-all overflow-hidden","rounded-full size-8 flex items-center justify-center p-0",o&&"opacity-0 size-0"),children:e.jsx(u.ArrowUpIcon,{className:"size-4"})})]})},"feedback-box")}),e.jsx("div",{className:p("h-0 transition-[height]",o&&"h-4")})]})}function $(){const{dir:t}=l.useDocumentDir(),r=l.useConfig();return m.useMemo(()=>{const s=I.isSupportedLanguage(r.language)?r.language:"en";return{t:o=>I.getTranslation(o,s,r.translationOverrides),language:s,dir:s==="ar"?"rtl":"ltr",hostDocumentDir:t}},[r.language,t])}function ge({suggestion:t,className:r,...s}){const{sendMessage:o}=l.useMessages(),n=()=>{const a=t.trim();a&&o({content:a})};return e.jsx(z,{...w("chat/suggested_reply_btn"),size:"sm",className:p("rounded-xl w-fit",r),...s,onClick:n,children:t})}function os(){const{t}=$(),r=[t("i_need_more_help"),t("this_was_helpful")];return e.jsx("div",{...w("chat/might_solve_user_issue_suggested_replies_container"),className:"flex items-center gap-2 p-2 pb-0 flex-wrap",children:r.map(s=>e.jsx(ge,{suggestion:s,className:"flex-1"},s))})}function Ge(){const{sessionState:t}=l.useSessions(),{chatFooterItems:r}=l.useConfig(),s=!!t.session&&!t.session.isOpened,o=!s;return e.jsx(y.AnimatePresence,{mode:"wait",children:r==null?void 0:r.map((n,a)=>n.showWhenSessionIsOpen===!1&&o||n.showWhenSessionIsResolved===!1&&s?null:e.jsx(R,{children:e.jsx("div",{className:"pb-2 text-center text-xs",children:e.jsx(ce,{children:n.message})})},`${n.message}-${a}`))})}function ns({file:{status:t,file:r,error:s},onCancel:o}){const[n,a]=m.useState(null);m.useEffect(()=>{if(!r.type.startsWith("image/"))return;const d=new FileReader;return d.onload=()=>a(d.result),d.onerror=()=>console.error("Error reading file"),d.readAsDataURL(r),()=>d.abort()},[r]);const i=()=>{switch(t){case"uploading":return e.jsx(u.Loader2,{className:"size-4 animate-spin"});case"error":return e.jsx(u.AlertCircle,{className:"size-4 text-destructive"});default:return null}},c=()=>{const d=r.type.split("/")[0];return d==="image"&&n?e.jsx("img",{src:typeof n=="string"?n:"",className:"object-cover bg-secondary size-full",alt:r.name}):d==="audio"?e.jsx(u.FileAudio2Icon,{}):d==="video"?e.jsx(u.FileVideo2Icon,{}):e.jsx(u.FileIcon,{})};return e.jsx(Y,{side:"bottom",content:t==="error"?e.jsxs("span",{className:"text-destructive",children:["Failed to upload: ",s]}):r.name,children:e.jsxs("div",{className:p(t==="uploading"&&"opacity-50","group","size-12 border rounded-2xl overflow-hidden relative","flex items-center justify-center shrink-0"),children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:i()}),e.jsx("button",{type:"button",className:p("absolute bg-black/50 inset-0 size-full z-10 opacity-0","flex items-center justify-center","opacity-0 group-hover:opacity-100 transition"),onClick:o,children:e.jsx(u.XIcon,{className:"size-4 text-primary-foreground"})}),e.jsx(c,{})]})})}function is(){var D;const{isSmallScreen:t}=E(),r=m.useRef(null),{sendMessage:s}=l.useMessages(),{sessionState:o}=l.useSessions(),{t:n}=$(),[a,i]=m.useState(""),{allFiles:c,emptyTheFiles:d,handleCancelUpload:h,appendFiles:k,isUploading:j,successFiles:g}=l.useUploadFiles(),S=!!((D=o.session)!=null&&D.isHandedOff),{isAwaitingBotReply:f}=l.useIsAwaitingBotReply(),C=b=>{k(b)},T=!a.trim()&&g.length===0,v=async()=>{if(f||T)return;j&&console.info("please wait for the file(s) to upload");const b=a.trim();s({content:b,attachments:g.flatMap(N=>N.fileUrl?[{url:N.fileUrl,type:N.file.type,name:N.file.name,id:N.id,size:N.file.size}]:[])}),i(""),d()},{getRootProps:M,getInputProps:P,open:W}=It.useDropzone({onDrop:C,noClick:!0,onDropRejected(){console.error("unsupported file type, or the file is too large")},maxSize:5*1024*1024,accept:S?{"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],"application/pdf":[".pdf"]}:{"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]}}),A=b=>{const N=b.clipboardData;N&&N.files.length>0&&C(Array.from(N.files))};return e.jsxs("div",{...w("chat/input_box/root"),className:"p-2 relative space-y-1",...M(),children:[e.jsx("input",{...P()}),e.jsxs("div",{...w("chat/input_box/inner_root"),className:p("transition-all","bg-white","relative rounded-3xl flex flex-col gap-2 p-2","hover:border-primary focus-within:border-primary"),children:[e.jsxs("div",{...w("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[c.length>0&&e.jsx("div",{...w("chat/input_box/attachments_container"),className:"flex items-center gap-1",children:e.jsx(y.AnimatePresence,{mode:"popLayout",children:c.map(b=>e.jsx(x,{snapExit:!0,children:e.jsx(ns,{onCancel:()=>h(b.id),file:b})},b.id))})}),e.jsx("textarea",{...w("chat/input_box/textarea"),onPaste:A,ref:r,id:"chat-input",value:a,rows:3,className:p("max-h-16 [field-sizing:content]","w-full resize-none px-2",c.length===0&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground",t?"text-[16px]":"text-sm"),onChange:b=>i(b.target.value),onKeyDown:async b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),v())},placeholder:n("write_a_message_placeholder")})]}),e.jsxs("div",{className:"gap-2 flex justify-between",children:[e.jsx(Y,{side:"top",align:"start",content:"attach files, (maximum size 5mb)",children:e.jsx(z,{onClick:W,size:"fit",variant:"ghost",className:p("rounded-full size-8 flex items-center justify-center p-0 overflow-hidden"),children:e.jsx(y.AnimatePresence,{mode:"wait",children:S&&!f?e.jsx(x,{children:e.jsx(u.PaperclipIcon,{className:"size-4"})},"paper-clip"):e.jsx(x,{children:e.jsx(u.ImageIcon,{className:"size-4"})},"image-icon")})})}),e.jsx(Y,{content:"send message",side:"top",align:"end",children:e.jsx(z,{size:"fit",onClick:v,disabled:f||j||T,className:"rounded-full size-8 flex items-center justify-center p-0",children:e.jsx(y.AnimatePresence,{mode:"wait",children:f||j?e.jsx(x,{snapExit:!0,children:e.jsx(u.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):e.jsx(x,{snapExit:!0,children:e.jsx(u.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})}function Ke(){const{widgetCtx:t}=l.useWidget(),{router:r}=l.useConfig(),{canCreateNewSession:s}=l.useSessions(),{toSessionsScreen:o}=l.useWidgetRouter(),{t:n}=$();return e.jsx(e.Fragment,{children:s||r!=null&&r.chatScreenOnly?e.jsx(z,{onClick:t.resetChat,className:"rounded-2xl w-full",children:n("new_conversation")}):e.jsx(z,{onClick:o,className:"rounded-2xl w-full",children:n("back_to_conversations")})})}function as(){const{t}=$(),{isCsatRequested:r,isCsatSubmitted:s}=l.useCsat();return e.jsx("div",{className:"p-2",children:e.jsx("div",{className:"p-2 bg-muted rounded-3xl",children:e.jsx(y.AnimatePresence,{mode:"wait",children:r||s?e.jsxs(R,{children:[e.jsx(rs,{}),e.jsx(y.AnimatePresence,{mode:"wait",children:s&&e.jsx(R,{children:e.jsx(Ke,{})},"new-conv-or-back-to-convs-button")})]},"csat"):e.jsxs(R,{children:[e.jsxs("div",{className:"ps-2 flex items-center gap-1 pb-2",children:[e.jsx(u.CircleCheckIcon,{className:"size-4 text-emerald-600"}),e.jsx("h2",{className:"text-sm font-medium",children:t("your_issue_has_been_resolved")})]}),e.jsx(Ke,{})]},"session-closed")})})})}function ls(){var i;const{initialQuestions:t,initialQuestionsPosition:r,thisWasHelpfulOrNot:s}=l.useConfig(),{sessionState:o}=l.useSessions(),{messagesState:n}=l.useMessages(),a=n.messages.length===0;return e.jsx("footer",{children:e.jsx(y.AnimatePresence,{mode:"wait",children:o.session&&!((i=o.session)!=null&&i.isOpened)?e.jsxs(R,{children:[e.jsx(as,{}),e.jsx(Ge,{})]},"session-closed"):e.jsxs(R,{children:[n.lastAIResMightSolveUserIssue&&(s==null?void 0:s.enabled)!==!1&&e.jsx(os,{}),a&&t&&r!=="below-initial-messages"&&e.jsx("div",{className:"flex items-center flex-row justify-end gap-2 flex-wrap px-2",children:t==null?void 0:t.map((c,d)=>e.jsx(ge,{suggestion:c},`${c}-${d}`))}),e.jsx(is,{}),e.jsx(Ge,{})]},"chat-input")})})}function cs({isFirstInGroup:t,isLastInGroup:r,isAloneInGroup:s,...o}){const{componentStore:n}=l.useWidget();if(o.type!=="AGENT"&&o.type!=="AI")return null;if(o.data.action){const i=n.getComponent(o.data.action.name);if(i)return e.jsx(i,{...o,id:o.id,isFirstInGroup:t,isLastInGroup:r,isAloneInGroup:s})}const a=n.getComponent(o.component);return a?e.jsx(a,{...o,id:o.id,isFirstInGroup:t,isLastInGroup:r,isAloneInGroup:s}):e.jsx(ne,{...o,isFirstInGroup:t,isLastInGroup:r,isAloneInGroup:s})}function xt({messages:t,className:r,containerClassName:s}){var i,c;const{timestamps:o}=l.useConfig();if(!((i=o==null?void 0:o.perMessageGroup)!=null&&i.enabled))return null;const n=(c=t[t.length-1])==null?void 0:c.timestamp;if(!n)return null;const a=(()=>{try{return new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(d){return console.error(d),null}})();return a?e.jsx("div",{className:s,children:e.jsx("span",{className:p("text-xs text-muted-foreground",r),children:a})}):null}function J({messages:t,agent:r,suggestedReplies:s}){return e.jsxs("div",{...w("chat/agent_msg_group/root"),className:p("flex items-end gap-2"),children:[e.jsx(Y,{content:r==null?void 0:r.name,side:"right",align:"end",children:e.jsx(ie,{...w("chat/agent_msg_group/root/avatar"),agent:r,className:"hidden"})}),e.jsxs("div",{className:p("flex-1 flex flex-col gap-1"),children:[e.jsxs("div",{...w("chat/agent_msg_group/avatar_and_msgs/root"),className:p("flex items-end gap-2"),children:[e.jsx(Y,{content:r==null?void 0:r.name,side:"right",align:"end",children:e.jsx(ie,{...w("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:r})}),e.jsxs("div",{...w("chat/agent_msg_group/avatar_and_msgs/msgs"),className:p("flex-1 flex flex-col gap-1"),children:[t.map((o,n,a)=>e.jsx(cs,{isFirstInGroup:n===0,isLastInGroup:n===a.length-1,isAloneInGroup:a.length===1,...o},o.id)),e.jsx(xt,{messages:t})]})]}),s&&s.length>0&&e.jsx("div",{...w("chat/agent_msg_group/suggestions"),className:p("flex flex-col gap-1 ps-8"),children:s==null?void 0:s.map((o,n)=>e.jsx(ge,{suggestion:o},`${o}-${n}`))})]})]})}function ds(){var s,o;const t=G();if((s=t.session)!=null&&s.isOpened||!t.session)return null;const r=(o=t.config.customComponents)==null?void 0:o.onSessionResolved;return r?e.jsx(r,{...t}):null}function ps({message:t,isFirstInGroup:r,isLastInGroup:s,isAloneInGroup:o}){var n;return e.jsxs("div",{...w("chat/user_msg/root"),className:"w-5/6 flex flex-col items-end gap-1",children:[t.attachments&&t.attachments.length>0&&e.jsx("div",{className:"w-full flex gap-1 flex-wrap justify-end",children:(n=t.attachments)==null?void 0:n.map(a=>e.jsx(ct,{attachment:a},a.id))}),t.content.length>0&&e.jsx("div",{...w("chat/user_msg/msg"),"data-first":r,"data-last":s,"data-alone":o,className:p("transition-all","w-fit py-3 px-4 rounded-3xl text-sm","bg-primary text-primary-foreground","break-words [word-break:break-word]","whitespace-pre-wrap",r&&!o&&"rounded-br-md",s&&!o&&"rounded-tr-md",!r&&!s&&!o&&"rounded-r-md"),children:t.content})]})}function hs({messages:t}){return e.jsxs("div",{...w("chat/user_msg_group/root"),className:p("group","flex flex-col gap-1 justify-end items-end"),children:[t.map((r,s,o)=>e.jsx(ps,{message:r,isFirstInGroup:s===0,isLastInGroup:s===o.length-1,isAloneInGroup:o.length===1},r.id)),e.jsx(xt,{messages:t,containerClassName:"ms-auto"})]})}function ms(t){const r=[];let s=null;return t.forEach(o=>{var n,a,i,c,d,h;(((n=s==null?void 0:s[0])==null?void 0:n.type)!==o.type||((a=s[0])==null?void 0:a.type)==="AGENT"&&o.type==="AGENT"&&(((i=o.agent)==null?void 0:i.id)!==((c=s[0].agent)==null?void 0:c.id)||((d=o.agent)==null?void 0:d.name)!==((h=s[0].agent)==null?void 0:h.name)))&&(s=[],r.push(s)),s.push(o)}),r}function us(t){var r;return((r=t==null?void 0:t[0])==null?void 0:r.type)==="USER"}function gs(t){var r;return((r=t==null?void 0:t[0])==null?void 0:r.type)==="AI"}function ws(t){var r;return((r=t==null?void 0:t[0])==null?void 0:r.type)==="AGENT"}function fs(){const{messagesState:{messages:t}}=l.useMessages(),{advancedInitialMessages:r=[],initialQuestionsPosition:s,initialQuestions:o,bot:n}=l.useConfig();return e.jsx(e.Fragment,{children:t.length===0&&r.length>0&&e.jsx(J,{messages:r.map(({message:a},i)=>({component:"bot_message",data:{message:a},id:`${i}-${a}`,type:"AI",timestamp:null})),suggestedReplies:t.length===0&&s==="below-initial-messages"?o:void 0,agent:n?{...n,isAi:!0,id:null}:void 0})})}function xs(){const{messagesState:{messages:t}}=l.useMessages(),{chatBannerItems:r}=l.useConfig();return!(r!=null&&r.length)||t.length>0&&r.every(s=>!s.persistent)?null:e.jsx("div",{className:"w-full text-center text-xs",children:r.map(({message:s,persistent:o},n)=>t.length>0&&!o?null:e.jsx("div",{children:e.jsx(ce,{children:s})},`${s}-${n}`))})}function vs(){const{messagesState:{messages:t}}=l.useMessages(),r=l.useConfig(),{advancedInitialMessages:s=[],initialQuestions:o,initialQuestionsPosition:n}=r,a=(()=>{var i;return s.length?[]:t.length?[]:(i=r.initialMessages)!=null&&i.length?r.initialMessages:["Hello, how can I help you?"]})();return e.jsx(e.Fragment,{children:t.length===0&&a.length>0&&e.jsx(J,{messages:a.map((i,c)=>({component:"bot_message",data:{message:i},id:`${c}-${i}`,type:"AI",timestamp:null})),suggestedReplies:n==="below-initial-messages"?o:void 0,agent:r.bot?{...r.bot,isAi:!0,id:null}:void 0})})}function bs(){var s;const t=G(),r=(s=t.config.customComponents)==null?void 0:s.chatBottomComponents;return r?e.jsx("div",{children:r.map(({key:o,component:n})=>e.jsx(n,{...t},o))}):null}function ys(){const{messagesState:{messages:t}}=l.useMessages(),{isAwaitingBotReply:r}=l.useIsAwaitingBotReply(),{componentStore:s}=l.useWidget(),{bot:o,humanAgent:n}=l.useConfig(),a=m.useMemo(()=>ms(t),[t]),i=s.getComponent("loading"),c=m.useRef(null);function d(){setTimeout(()=>{const h=c.current;h&&(h.scrollTop=h.scrollHeight)},0)}return m.useEffect(()=>{d()},[t]),e.jsxs("div",{...w("chat/msgs/root"),ref:c,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[e.jsx(xs,{}),e.jsx(fs,{}),e.jsx(vs,{}),a.map((h,k)=>{var S,f,C,T;const j=(S=h==null?void 0:h[0])==null?void 0:S.type,g=(f=h[0])==null?void 0:f.id;if(!j||!g)return null;if(us(h))return e.jsx(hs,{messages:h},g);if(gs(h)){const v=k===a.length-1;return r&&v?null:((C=h[0])==null||C.agent,e.jsx(J,{messages:h,agent:o?{...o,isAi:!0,id:null}:void 0},g))}if(ws(h)){const v=(T=h[0])==null?void 0:T.agent;return e.jsx(J,{messages:h,agent:v?{...v,name:(n==null?void 0:n.name)||v.name||"",avatarUrl:(n==null?void 0:n.avatarUrl)||v.avatarUrl||null}:n?{isAi:!1,id:null,name:n.name||"",avatarUrl:n.avatarUrl||null}:void 0},g)}return null}),r&&i&&e.jsx(i,{agent:o}),e.jsx(bs,{}),e.jsx(ds,{})]})}function js(){const{messagesState:{isInitialFetchLoading:t}}=l.useMessages(),{sessionState:{session:r}}=l.useSessions(),{isCanvasOpen:s}=es(),{theme:o}=q();me({width:s?o.screens.chat.withCanvas.width:o.screens.chat.width,height:s?o.screens.chat.withCanvas.height:o.screens.chat.height});const n=m.useRef((r==null?void 0:r.id)||"chat").current;return e.jsx("div",{...w("chat/root"),className:p("flex flex-col overflow-hidden"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:e.jsxs("div",{className:"size-full justify-between flex flex-col",children:[e.jsx(wt,{}),e.jsx(y.AnimatePresence,{mode:"wait",children:t?e.jsx(x,{className:"flex flex-col items-center justify-center w-full flex-1",children:e.jsx(ft,{})},"loading"):e.jsxs(x,{className:"flex items-start h-full flex-1 overflow-auto",snapExit:!0,children:[e.jsxs("div",{...w("chat/main/root"),className:p("flex flex-col h-full overflow-auto transition-all",s?"w-2/5":"w-full"),style:{transitionTimingFunction:o.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:o.screens.chat.withCanvas.transitionDuration},children:[e.jsx(ys,{}),e.jsx(ls,{})]}),e.jsx("div",{...w("chat/canvas/root"),className:p("h-full overflow-auto transition-all",s?"w-3/5":"w-0"),style:{transitionTimingFunction:o.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:o.screens.chat.withCanvas.transitionDuration},children:e.jsx(ts,{})})]},n)})]})})}function ks({className:t,...r}){return e.jsx("div",{className:p("animate-pulse rounded-md bg-secondary",t),...r})}function Cs({className:t}){return e.jsx("svg",{width:"26",height:"32",viewBox:"0 0 26 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:p("text-primary-foreground",t),children:e.jsx("path",{d:"M1.34103 25.6132H5.44245C5.74203 25.6228 6.02673 25.7462 6.23867 25.9582C6.45062 26.1703 6.5739 26.4551 6.58348 26.7548V30.8584C6.59305 31.1581 6.71634 31.443 6.92828 31.655C7.14023 31.8671 7.42492 31.9904 7.7245 32H18.2894C18.589 31.9904 18.8737 31.8671 19.0856 31.655C19.2976 31.443 19.4209 31.1581 19.4304 30.8584V26.7548C19.4401 26.4545 19.5638 26.1692 19.7765 25.957C19.9892 25.7449 20.2748 25.6219 20.5749 25.6132H24.659C24.9586 25.6036 25.2433 25.4803 25.4552 25.2682C25.6671 25.0562 25.7904 24.7713 25.8 24.4716V7.52839C25.7904 7.22865 25.6671 6.94381 25.4552 6.73176C25.2433 6.5197 24.9586 6.39635 24.659 6.38677H20.561C20.2603 6.37802 19.9742 6.25457 19.7614 6.04169C19.5487 5.82881 19.4253 5.54261 19.4165 5.24168V1.14161C19.4072 0.84419 19.2858 0.561291 19.0768 0.349589C18.8678 0.137887 18.5865 0.0130193 18.2894 0L7.7245 0C7.42492 0.00957792 7.14023 0.132929 6.92828 0.344983C6.71634 0.557036 6.59305 0.841878 6.58348 1.14161V5.24168C6.57477 5.54203 6.45187 5.82773 6.23983 6.04052C6.0278 6.25331 5.74262 6.37715 5.44245 6.38677H1.34103C1.04144 6.39635 0.756749 6.5197 0.544805 6.73176C0.332861 6.94381 0.209574 7.22865 0.200001 7.52839V24.4716C0.209574 24.7713 0.332861 25.0562 0.544805 25.2682C0.756749 25.4803 1.04144 25.6036 1.34103 25.6132ZM6.58348 24.4716V7.52839C6.59305 7.22865 6.71634 6.94381 6.92828 6.73176C7.14023 6.5197 7.42492 6.39635 7.7245 6.38677H18.2894C18.589 6.39635 18.8737 6.5197 19.0856 6.73176C19.2976 6.94381 19.4209 7.22865 19.4304 7.52839V24.4716C19.4209 24.7713 19.2976 25.0562 19.0856 25.2682C18.8737 25.4803 18.589 25.6036 18.2894 25.6132H7.7245C7.42492 25.6036 7.14023 25.4803 6.92828 25.2682C6.71634 25.0562 6.59305 24.7713 6.58348 24.4716Z",fill:"currentColor"})})}function vt({className:t}){const{token:r}=l.useConfig();return e.jsx("div",{className:p("flex items-center justify-center gap-2 p-2 pt-0",t),children:e.jsx(O,{children:e.jsxs("a",{href:`https://open.cx/?ref=${r}`,target:"_blank",rel:"noreferrer",className:p("text-[10px] flex items-center","text-muted-foreground/70 [&_svg]:text-muted-foreground/70","hover:text-primary [&_svg]:hover:text-primary"),children:[e.jsx("span",{children:"Powered by"}),e.jsx("span",{children:" "}),e.jsxs("span",{className:"flex items-center gap-[1px]",children:[e.jsx("span",{children:e.jsx(Cs,{className:"size-3 inline-block"})}),e.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function zs({children:t}){return e.jsx("p",{className:"ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:t})}function Qe({session:t,className:r}){const{bot:s,humanAgent:o}=l.useConfig(),{toChatScreen:n}=l.useWidgetRouter(),a=t.assignee.kind==="human"?(o==null?void 0:o.name)||t.assignee.name||"Support Agent":(s==null?void 0:s.name)||"AI Support Agent",i=t.assignee.kind==="human"?(o==null?void 0:o.avatarUrl)||t.assignee.avatarUrl||"":(s==null?void 0:s.avatarUrl)||(s==null?void 0:s.avatar)||"";return e.jsxs(z,{variant:"ghost",size:"lg",className:p("rounded-full p-2 pe-4 flex text-start justify-between w-full whitespace-normal",r),onClick:()=>n(t.id),children:[e.jsxs("div",{className:"flex-1 flex gap-2 items-center",children:[e.jsx(y.AnimatePresence,{mode:"wait",children:e.jsx(x,{snapExit:!0,children:e.jsxs(de,{className:"size-10",children:[e.jsx(pe,{src:i,alt:"Agent Icon"}),e.jsx(he,{children:e.jsx(u.UserRoundIcon,{className:"size-4"})})]})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(y.AnimatePresence,{mode:"wait",children:e.jsx(x,{snapExit:!0,children:a},a)}),e.jsx(y.AnimatePresence,{mode:"wait",children:t.lastMessage?e.jsx(x,{snapExit:!0,children:e.jsx(dt,{remarkPlugins:[Ze],rehypePlugins:[Je],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:t.lastMessage})},t.lastMessage||"content"):e.jsx(x,{className:"w-1/2",snapExit:!0,children:e.jsx(ks,{className:"h-4 w-full"})},"skeleton")})]})]}),e.jsx(u.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0 rtl:-scale-100"})]})}function Ss(){const{t}=$(),{toChatScreen:r}=l.useWidgetRouter(),{sessionsState:{data:s,isInitialFetchLoading:o},openSessions:n,closedSessions:a,canCreateNewSession:i}=l.useSessions();return e.jsx("div",{className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:e.jsx(y.AnimatePresence,{mode:"wait",children:o?e.jsx(x,{className:"flex-1 flex items-center justify-center",children:e.jsx(ft,{})},"loading"):e.jsx(x,{className:"flex-1 flex flex-col gap-2 relative",children:s.length?e.jsxs(e.Fragment,{children:[e.jsxs(y.AnimatePresence,{children:[n.length>0&&e.jsx(x,{fadeIn:"up",delay:.2,className:"space-y-2",snapExit:!0,children:n.map(c=>e.jsx(Qe,{session:c},c.id))},"open-sessions"),a.length>0&&e.jsxs(x,{className:"space-y-2",delay:.2,snapExit:!0,children:[e.jsx(zs,{children:t("closed_conversations")}),a.map(c=>e.jsx(Qe,{session:c,className:"opacity-50 hover:opacity-100"},c.id))]},"closed-sessions")]}),i&&e.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:m.createElement(z,{...w("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>r()},t("new_conversation"))})]}):e.jsxs("div",{className:"flex-1 flex flex-col gap-2 items-center",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:t("no_conversations_yet")})}),m.createElement(z,{...w("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>r()},t("new_conversation"))]})},"sessions")})})}function Ns(){const{theme:t}=q();return me({width:t.screens.sessions.width,height:t.screens.sessions.height}),e.jsx("div",{...w("sessions/root"),className:p("flex flex-col overflow-hidden bg-background"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:e.jsxs("div",{className:"size-full flex flex-col",children:[e.jsx(wt,{}),e.jsx(Ss,{}),e.jsx(vt,{})]})})}const Z=B.forwardRef(({className:t,type:r,...s},o)=>{const{isSmallScreen:n}=E();return e.jsx(O,{ref:o,children:e.jsx("input",{type:r,className:p(n?"text-[16px]":"text-sm","flex w-full rounded-xl p-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-primary-foreground placeholder:text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition","rounded-2xl px-4","border shadow-sm",t),...s})})});Z.displayName="Input";function _s(){const{contentIframeRef:t}=l.useWidget(),{inline:r}=l.useConfig(),s=m.useRef(null);return m.useEffect(()=>{const o=t==null?void 0:t.current;if(o&&s.current){const n=s.current;let a;const i=new ResizeObserver(()=>{a=requestAnimationFrame(()=>{const c=n.offsetHeight;o.style.setProperty("--opencx-widget-height",r?"100%":`${c.toFixed(1)}px`)})});return i.observe(n),()=>{cancelAnimationFrame(a),i.unobserve(n)}}},[t,r]),{observedElementRef:s}}const Ts=oe.z.object({name:oe.z.string().min(2),email:oe.z.string().email()});function Is(){var v,M,P,W,A,D,b,N;const{widgetCtx:{org:t}}=l.useWidget(),{setIsOpen:r}=l.useWidgetTrigger(),{createUnverifiedContact:s}=l.useContact(),{isSmallScreen:o}=E(),n=l.useConfig(),{theme:a}=q(),{t:i}=$(),{observedElementRef:c}=_s();me({height:void 0,width:a.screens.welcome.width});const[d,h]=m.useState(((v=n.prefillUserData)==null?void 0:v.name)||""),[k,j]=m.useState(((M=n.prefillUserData)==null?void 0:M.email)||""),g=(n.extraDataCollectionFields||[]).filter(_=>_!=="name"&&_!=="email"&&!!_),[S,f]=m.useState({}),[C,T]=Mt(async _=>{_.preventDefault();const F=Ts.safeParse({name:d,email:k});F.success&&await s({email:F.data.email,non_verified_name:F.data.name},Object.values(S).filter(Boolean).length?S:void 0)},[d,k,S]);return e.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:a.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:e.jsxs("div",{ref:c,className:p("flex flex-col",o&&"h-full","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[e.jsxs("div",{className:p("flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10","text-primary-foreground"),children:[o&&e.jsx(x,{className:"absolute top-6 end-6",children:e.jsx(z,{size:"selfless",onClick:()=>r(!1),children:e.jsx(u.XIcon,{className:"size-4"})})}),e.jsx("div",{className:"flex items-center justify-between w-full mb-2",children:(P=n.assets)!=null&&P.organizationLogo?e.jsx("img",{src:(W=n.assets)==null?void 0:W.organizationLogo,alt:"Company Logo",className:"h-8 w-auto object-contain"}):e.jsx("h2",{className:"font-bold text-sm",children:t.name})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-[1.75rem] font-semibold tracking-tight leading-none",children:((D=(A=n.textContent)==null?void 0:A.welcomeScreen)==null?void 0:D.title)||i("welcome_screen_title")}),e.jsx("p",{className:"text-sm",children:((N=(b=n.textContent)==null?void 0:b.welcomeScreen)==null?void 0:N.description)||i("welcome_screen_description")})]})]}),e.jsxs("div",{className:p("z-10 m-2 px-2 pt-2 bp-0 space-y-2","bg-[white]","border shadow","rounded-3xl"),children:[e.jsxs("form",{onSubmit:T,className:"space-y-2",children:[e.jsx(Z,{value:d,onChange:_=>h(_.target.value),required:!0,placeholder:i("your_name_placeholder"),name:"name"}),e.jsx(Z,{required:!0,value:k,onChange:_=>j(_.target.value),type:"email",placeholder:i("your_email_placeholder"),name:"email"}),g.map(_=>e.jsx(Z,{value:S[_],onChange:F=>f(K=>({...K,[_]:F.target.value})),placeholder:`${_} (${i("optional")})`},_)),e.jsxs(z,{disabled:C.loading,className:"w-full",size:"lg",children:[C.loading?i("start_chat_button_loading"):i("start_chat_button"),e.jsx(u.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),e.jsx(vt,{})]})]})})}function bt(){const{routerState:{screen:t}}=l.useWidgetRouter();return e.jsx("div",{className:"relative bg-background size-full",children:e.jsx(y.AnimatePresence,{mode:"wait",children:(()=>{switch(t){case"welcome":return e.jsx(x,{fadeIn:"right",className:"size-full",snapExit:!0,children:e.jsx(Is,{})},t);case"sessions":return e.jsx(x,{fadeIn:"right",className:"size-full",snapExit:!0,children:e.jsx(Ns,{})},t);case"chat":return e.jsx(x,{fadeIn:"right",className:"size-full",snapExit:!0,children:e.jsx(js,{})},t);default:return I.isExhaustive(t,bt.name),null}})()})})}const Ms="4.0.39",Ds=`<!DOCTYPE html>
|
|
18
18
|
<html>
|
|
19
19
|
<head>
|
|
20
20
|
<style>
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TranslationKeyU } from '@opencx/widget-core';
|
|
2
2
|
export declare function useTranslation(): {
|
|
3
3
|
t: (key: TranslationKeyU) => string;
|
|
4
|
-
language: "tr" | "fr" | "no" | "ar" | "da" | "de" | "el" | "en" | "es" | "fi" | "it" | "nl" | "pl" | "pt" | "ro" | "ru" | "sv";
|
|
4
|
+
language: "th" | "tr" | "fr" | "no" | "ar" | "bg" | "cs" | "da" | "de" | "el" | "en" | "es" | "fi" | "it" | "nl" | "pl" | "pt" | "ro" | "ru" | "sv" | "vi";
|
|
5
5
|
dir: string;
|
|
6
6
|
hostDocumentDir: import('@opencx/widget-core').StringOrLiteral<"ltr" | "rtl">;
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencx/widget-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.39",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"tailwind-merge": "^2.4.0",
|
|
38
38
|
"tinycolor2": "^1.6.0",
|
|
39
39
|
"zod": "^3.23.8",
|
|
40
|
-
"@opencx/widget-
|
|
41
|
-
"@opencx/widget-
|
|
40
|
+
"@opencx/widget-core": "4.0.39",
|
|
41
|
+
"@opencx/widget-react-headless": "4.0.39"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@types/react": ">=18 <20",
|