1import{a6 as ne,j as t,dG as fe,dH as Fe,dI as Le,cx as Re,s as o,B as S,F as q,cf as Oe,T as j,cw as K,r as a,x as ie,dJ as ke,b3 as se,dK as pe,aE as Ne,M as Pe,P as He,b as Be,cy as We,bY as Ge,bI as Qe,dL as Ue,o as $e,b0 as ze,V as ce,cG as Ve}from"./index-CCrC0TJJ.js";import{u as de}from"./usePermission-Co1KQMC_.js";import{u as Xe,S as Ke,L as Je}from"./useScrollToSettingsHash-CoWei8Ep.js";import{A as Ye}from"./AddCircleOutline-BN679ppu.js";import"./RefreshOutlined-DWSOEJGU.js";const Ze=ne(t.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m4 11h-3v3c0 .55-.45 1-1 1s-1-.45-1-1v-3H8c-.55 0-1-.45-1-1s.45-1 1-1h3V8c0-.55.45-1 1-1s1 .45 1 1v3h3c.55 0 1 .45 1 1s-.45 1-1 1"})),et=ne(t.jsx("path",{d:"M20 9H4v2h16zM4 15h16v-2H4z"})),tt=ne(t.jsx("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 14H4V8l8 5 8-5zm-8-7L4 6h16z"})),st=ne(t.jsx("path",{d:"M12 5.9c1.16 0 2.1.94 2.1 2.1s-.94 2.1-2.1 2.1S9.9 9.16 9.9 8s.94-2.1 2.1-2.1m0 9c2.97 0 6.1 1.46 6.1 2.1v1.1H5.9V17c0-.64 3.13-2.1 6.1-2.1M12 4C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4m0 9c-2.67 0-8 1.34-8 4v3h16v-3c0-2.66-5.33-4-8-4"})),ye=80,Se=50,nt=5,ot=3,xe={info_collector_intro_msg:300,intro_msg:300},it=["info_collector_intro_msg","is_username_required","is_email_required","is_voice_input_enabled"],rt=["Where is my order?","Do you offer refunds?","Check product availability"],at=[{id:"info_collector_intro_msg",label:"Message for Collecting User Info",type:"text",multiline:!0,rows:2,maxLength:xe.info_collector_intro_msg,validation:{validate:(e,s)=>!(s?.is_username_required||s?.is_email_required)||(e??"").trim().length>=5||"Message must be at least 5 characters"}}],lt=[{toggleName:"is_username_required",title:"Name",storedKey:"name"},{toggleName:"is_email_required",title:"Email",storedKey:"email"}],ct={id:"intro_msg",label:"Welcome Message",type:"text",multiline:!1,rows:1,maxLength:xe.intro_msg},Z=e=>{const s=e?.other_settings||{};return{is_username_required:Le(s),is_email_required:Fe(s),info_collector_intro_msg:s.info_collector_intro_msg||fe,intro_msg:e?.intro_msg||"Hello! How Can I help you?",show_suggested_questions:e?.is_suggested_questions_enabled??!1,suggested_questions:e?.suggested_questions?.questions?.length?e.suggested_questions.questions:rt,waiting_response_msgs:e?.waiting_response_msgs||["Waiting for Ai response..."],other_settings:{is_voice_input_enabled:s.is_voice_input_enabled??!0}}},dt=(e,s={})=>{const l={info_collector_intro_msg:fe,is_username_required:!1,is_email_required:!1,is_voice_input_enabled:!0},_={...l,...s},d={};return it.forEach(f=>{const g=e[f]??l[f];g!==_[f]&&(d[f]=g)}),Object.keys(d).length?Re(d):{}},ut=o(S)(({theme:{customSpacing:e}})=>({display:"flex",flexDirection:"column",gap:e["3xl"]})),ue=o(S)(({theme:{spacing:e,palette:s,customBorderRadius:l}})=>({display:"flex",flexDirection:"column",gap:e(2),padding:e(3),backgroundColor:s.common.white,borderRadius:l.lg})),gt=o(q)(({theme:{spacing:e}})=>({alignItems:"center",gap:e(1)})),ht=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[900]})),mt=o(S)(({theme:{palette:e,typography:s,customBorderRadius:l,customSpacing:_}})=>({...s["body-sm-bold"],display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",width:_["4xl"],height:_["4xl"],padding:_.xs,borderRadius:l.sm,backgroundColor:e.primary[50],color:e.primary[700],textAlign:"center",flexShrink:0})),_t=o(j)(({theme:{palette:e,spacing:s}})=>({color:e.colors.neutral[500],marginTop:s(.5)})),ft=o(q,{shouldForwardProp:e=>e!=="compact"&&e!=="$switchEnd"})(({theme:{spacing:e},compact:s,$switchEnd:l})=>({alignItems:s?"center":"flex-start",justifyContent:l?"space-between":"flex-start",gap:e(1.5),width:"100%","& .MuiSwitch-root":{marginTop:s||l?0:e(.25),flexShrink:0}})),pt=o(S,{shouldForwardProp:e=>e!=="compact"})(({theme:{spacing:e},compact:s})=>({display:"flex",flexDirection:"column",gap:e(.25),minWidth:0,flex:1,paddingTop:s?0:e(.125)})),yt=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[900]})),St=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[500]})),ge=o(Oe)(({theme:{palette:e,spacing:s}})=>({color:e.colors.neutral[400],fontSize:s(2.25)})),xt=o(S)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"column",gap:e(2)})),bt=o(q)(()=>({alignItems:"center",justifyContent:"space-between",width:"100%"})),jt=o(q)(({theme:{spacing:e}})=>({alignItems:"center",gap:e(1.5),minWidth:0})),wt=o(S)(({theme:{palette:e,spacing:s,customBorderRadius:l,customSpacing:_}})=>({width:s(4.5),height:s(4.5),minWidth:s(4.5),minHeight:s(4.5),borderRadius:l.sm,backgroundColor:e.primary[50],c
1olor:e.primary.main,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& .MuiSvgIcon-root":{fontSize:_["2xl"],width:_["2xl"],height:_["2xl"]}})),It=o(S)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"column",gap:e(.125),minWidth:0})),vt=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[900]})),Ct=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[400],textTransform:"uppercase"})),Et=o(q)(({theme:{spacing:e}})=>({alignItems:"center",gap:e(1),flexShrink:0})),Tt=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[600]})),qt=o(q)(({theme:{spacing:e}})=>({alignItems:"center",gap:e(1)})),he=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[500]})),At=o(S)(()=>({width:"100%"})),Dt=o(q)(({theme:{spacing:e}})=>({justifyContent:"space-between",alignItems:"center",marginBottom:e(2)})),Mt=o(j)(({theme:{spacing:e,palette:s}})=>({marginBottom:e(2),color:s.colors.neutral[500]})),Ft=o(q)(({theme:{spacing:e}})=>({gap:e(1),marginBottom:e(2),alignItems:"center"})),Lt=o(S)(()=>({flex:1})),be=o(S)(({theme:{spacing:e}})=>({width:e(7),height:e(7),display:"flex",alignItems:"center",justifyContent:"center"})),Rt=o(q)(({theme:{spacing:e}})=>({alignItems:"flex-start",justifyContent:"space-between",gap:e(2),width:"100%"})),Ot=o(S)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"column",gap:e(.5),flex:1,minWidth:0})),kt=o(q)(({theme:{spacing:e}})=>({alignItems:"center",gap:e(1)})),Nt=o(q,{shouldForwardProp:e=>e!=="disabled"})(({theme:{spacing:e},disabled:s})=>({flexDirection:"column",alignItems:"stretch",gap:e(2),width:"100%",opacity:s?.5:1,pointerEvents:s?"none":"auto"}
1)),je=o(S)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"column",gap:e(2)})),Pt=o(S)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"column",gap:e(2)})),Ht=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[900]})),Bt=o(q)(({theme:{spacing:e}})=>({justifyContent:"space-between",alignItems:"center",gap:e(2)})),Wt=o(S)(({theme:{spacing:e}})=>({display:"flex",flexDirection:"column",gap:e(.5),flex:1})),Gt=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[900]})),Qt=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[500]})),Ut=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[500]})),$t=o(q,{shouldForwardProp:e=>e!=="dragging"})(({theme:{spacing:e},dragging:s})=>({alignItems:"center",gap:e(1),width:"100%",opacity:s?.4:1})),zt=o(S)(({theme:{palette:e,spacing:s}})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.neutral[400],cursor:"grab",flexShrink:0,padding:s(.5),"&:active":{cursor:"grabbing"},"& .MuiSvgIcon-root":{fontSize:s(3)}})),Vt=o(S)(()=>({flex:1,minWidth:0})),Xt=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[500]})),we=o(j)(({theme:{palette:e}})=>({color:e.colors.neutral[900]})),Kt=o(S)(()=>({display:"inline-flex",cursor:"help"})),Jt=({icon:e,title:s,storedKey:l,toggleName:_,checked:d,onToggle:f,onFocus:g})=>t.jsx(xt,{children:t.jsxs(bt,{children:[t.jsxs(jt,{children:[t.jsx(wt,{children:t.jsx(e,{})}),t.jsxs(It,{children:[t.jsx(vt,{variant:"body-sm-semibold",children:s}),t.jsx(Ct,{variant:"body-xs-semibold",children:`Stored as '${l}'`})]})]}),t.jsxs(Et,{children:[t.jsx(Tt,{variant:"body-sm",children:"Shown"}),t.jsx(K,{name:_,checked:!!d,handleChange:f,onFocus:()=>g(_)})]})]})}),me=({step:e,title:s,description:l})=>t.jsxs("div",{children:[t.jsxs(gt,{children:[e!=null&&t.jsx(mt,{children:e}),t.jsx(ht,{variant:"body-lg-bold",children:s})]}),l&&t.jsx(_t,{variant:"body-sm",children:l})]}),Yt=({name:e,checked:s,onChange:l,onFocus:_,title:d,description:f,titleVariant:g="body-medium",switchPlacement:w="start"})=>t.jsxs(ft,{compact:!f,$switchEnd:w==="end",children:[w==="start"&&t.jsx(K,{name:e,checked:s,handleChange:l,onFocus:_}),t.jsxs(pt,{compact:!f,children:[t.jsx(yt,{variant:g,children:d}),f&&t.jsx(St,{variant:"body-sm",children:f})]}),w==="end"&&t.jsx(K,{name:e,checked:s,handleChange:l,onFocus:_})]}),ee=nt,te=ye,Ie=a.forwardRef(({showSuggestedQuestions:e,suggestedQuestions:s,setValue:l,watch:_,onFieldFocus:d},f)=>{const g=Array.isArray(s)?s:[],[w,M]=a.useState(new Set),[A,I]=a.useState(!1),[D,N]=a.useState(0),[v,F]=a.useState(null),[u,i]=a.useState(null),m=_?_("show_suggested_questions"):e,C=g.length<ee,P=r=>{M(c=>new Set(c).add(r))},H=r=>{l?.("show_suggested_questions",r.show_suggested_questions)},L=(r,c)=>{const E=[...g];E[r]=c,l("suggested_questions",E)},n=()=>{g.length>=ee||l("suggested_questions",[...g,""])},p=r=>{const c=g.filter((E,b)=>b!==r);l("suggested_questions",c),M(E=>{const b=new Set;return E.forEach(B=>{B<r?b.add(B):B>r&&b.add(B-1)}),b})},x=r=>F(r),R=r=>{r!==v&&i(r)},y=()=>{if(v!==null&&u!==null&&v!==u){const r=[...g],[c]=r.splice(v,1);r.splice(u,0,c),l("suggested_questions",r)}F(null),i(null)};return a.useImperativeHandle(f,()=>({validate:()=>{if(!m)return!0;const r=g.every(c=>c&&c.trim().length>0&&c.length<=te);return r||(I(!0),N(g.length)),r}})),a.useEffect(()=>{A&&D>0&&M(r=>{const c=new Set(r);for(let E=0;E<D;E++)c.add(E);return c})},[A,D]),t.jsxs(je,{children:[t.jsxs(Bt,{children:[t.jsxs(Wt,{children:[t.jsx(Gt,{variant:"body-medium",children:"Suggested Questions"}),t.jsxs(Qt,{variant:"body-sm",children:["Show clickable conversation starters when users open the chatbot. Maximum ",ee," ","suggested questions allowed."]})]}),t.jsx(K,{name:"show_suggested_questions",checked:!!m,onFocus:()=>d?.("show_suggested_questions"),handleChange:H})]}),t.jsxs(Nt,{disabled:!m,children:[t.jsxs(Ut,{variant:"body-sm-medium",children:[g.length,"/",ee," Questions Added"]}),g.map((r,c)=>{const E=!r||r.trim().length===0,b=r&&r.length>te,J=w.has(c)&&(E||b);let $="";J&&(E?$="This field cannot be empty":b&&($=`Maximum ${te} characters allowed`));const z=`suggested_question_${c}`;return t.jsxs($t,{dragging:v===c,onDragOver:V=>{V.preventDefault(),R(c)},onDrop:y,children:[t.jsx(zt,{draggable:!0,onDragStart:()=>x(c),onDragEnd:y,children:t.jsx(et,{})}),t.jsx(Vt,{children:t.jsx(ie,{id:z,type:"text",fullWidth:!0,label:`Question ${c+1}`,value:r,onChange:V=>L(c,V.target.value),onFocus:()=>d?.(`suggested_questions.${c}`),onBlur:()=>P(c),errors:J?{[z]:{message:$}}:{},endAdornment:t.jsx(ke,{position:"end",children:t.jsxs(Xt,{variant:"body-sm",children:[r?.length??0,"/",te]})})})}),t.jsx(be,{children:c===0?C&&t.jsx(se,{color:"primary",onClick:n,"aria-label":"Add question",children:t.jsx(Ze,{})}):t.jsx(se,{color:"error",onClick:()=>p(c),"aria-label":"Delete question",children:t.jsx(pe,{})})})]},z)})]})]})});Ie.displayName="SuggestedQuestionsInput";const _e=ot,oe=Se,ve=a.forwardRef(({value:e=[],onChange:s,label:l="Waiting Response Message",onFieldFocus:_},d)=>
1{const[f,g]=a.useState(new Set),[w,M]=a.useState(!1),[A,I]=a.useState(0),D=u=>{g(i=>new Set(i).add(u))},N=()=>{e.length>=_e||s([...e,""])},v=u=>{s(e.filter((i,m)=>m!==u)),g(i=>{const m=new Set;return i.forEach(C=>{C<u?m.add(C):C>u&&m.add(C-1)}),m})},F=(u,i)=>{const m=[...e];m[u]=i,s(m)};return a.useImperativeHandle(d,()=>({validate:()=>{const u=e.every(i=>i&&i.trim().length>0&&i.length<=oe);return u||(M(!0),I(e.length)),u}})),a.useEffect(()=>{!w||A<=0||g(u=>{const i=new Set(u);for(let m=0;m<A;m++)i.add(m);return i})},[w,A]),t.jsxs(At,{children:[t.jsx(Dt,{children:t.jsx(we,{variant:"body-medium",children:"Messages Shown During Response Generation"})}),e.length===0&&t.jsx(Mt,{variant:"body-sm",children:"No messages added. Click the add button to add a message."}),e.map((u,i)=>{const m=!u||u.trim().length===0,C=u&&u.length>oe,P=f.has(i)&&(m||C),H=m?"This field cannot be empty":C?`Maximum ${oe} characters allowed`:"",L=`waiting_msg_${i}`,n=e.length<_e;return t.jsxs(Ft,{children:[t.jsx(Lt,{children:t.jsx(ie,{id:L,type:"text",fullWidth:!0,label:`${l} ${i+1}`,value:u,onChange:p=>F(i,p.target.value),onFocus:()=>_?.(i),onBlur:()=>D(i),errors:P?{[L]:{message:H}}:{}})}),t.jsx(be,{children:i===0?n&&t.jsx(se,{color:"primary",onClick:N,"aria-label":"Add message",children:t.jsx(Ye,{})}):t.jsx(se,{color:"error",onClick:()=>v(i),"aria-label":"Delete message",children:t.jsx(pe,{})})})]},L)})]})});ve.displayName="WaitingMessageArrayInput";const Zt={name:st,email:tt},es=({formValues:e,initialData:s,formVersion:l,register:_,setValue:d,watch:f,errors:g,clearErrors:w,waitingMessagesRef:M,suggestedQuestionsRef:A,setActiveField:I,isGorgiasConnected:D,notify:N})=>{const v=a.useRef(s);v.current=s;const[F,u]=a.useState({is_username_required:!1,is_email_required:!1}),[i,m]=a.useState(!1);a.useEffect(()=>{const n=v.current;if(!n)return;const p=n.is_username_required===!0,x=n.is_email_required===!0;u({is_username_required:p,is_email_required:x}),m(p||x)},[l]);const C=()=>D?(N({success:!1,message:"You cannot turn off user information collection while Gorgias is connected. Please disconnect Gorgias first."}),!0):!1,P=n=>{const p=n.collect_user_info;if(!(!p&&C())){if(!p)m(!1),d("is_username_required",!1,{shouldDirty:!0}),d("is_email_required",!1,{shouldDirty:!0}),w?.("info_collector_intro_msg");else{const x=F.is_username_required===!0,R=F.is_email_required===!0,y=x||R,r=y?x:!0,c=y?R:!0;y||u({is_username_required:!0,is_email_required:!0}),m(!0),d("is_username_required",r,{shouldDirty:!0}),d("is_email_required",c,{shouldDirty:!0})}I("is_username_required")}},H=n=>p=>{const x=p[n],R=n==="is_username_required"?"is_email_required":"is_username_required";!x&&C()||!x&&!F[R]||(u(y=>({...y,[n]:x})),d(n,x,{shouldDirty:!0}),I(n))},L=(n,p,x)=>t.jsx(ie,{id:n.id,type:n.type,fullWidth:!0,label:n.label,multiline:n.multiline||!1,rows:n.rows||1,register:_,errors:g,defaultValue:x,setValue:d,watch:f,inputProps:n.maxLength?{maxLength:n.maxLength}:void 0,validation:{...n.maxLength?{maxLength:{value:n.maxLength,message:`Maximum ${n.maxLength} characters allowed`}}:{},...n.validation},onFocus:()=>I(p||n.id)},n.id);return t.jsxs(ut,{children:[t.jsxs(ue,{id:"starting-the-conversation",children:[t.jsx(me,{step:1,title:"Starting the conversation"}),t.jsx(Yt,{name:"collect_user_info",checked:i,onChange:P,onFocus:()=>I("is_username_required"),title:"Collect User Information",description:"Collect visitor details before the chat begins.",titleVariant:"body-medium",switchPlacement:"end"}),i&&t.jsxs(t.Fragment,{children:[at.map(n=>L(n,"info_collector_intro_msg",e.info_collector_intro_msg)),lt.map(n=>t.jsx(Jt,{icon:Zt[n.storedKey],title:n.title,storedKey:n.storedKey,toggleName:n.toggleName,checked:F[n.toggleName]===!0,onToggle:H(n.toggleName),onFocus:I},n.toggleName)),t.jsxs(qt,{children:[t.jsx(ge,{}),t.jsx(he,{variant:"body-xs",children:"At least one field stays on. Turn off 'Collect User Information' above to skip the form entirely."})]})]}),t.jsxs(Pt,{id:"welcome-message",children:[t.jsx(Ht,{variant:"body-medium",children:"Welcome Message"}),L(ct,"welcome_message")]}),t.jsx(Ie,{ref:A,showSuggestedQuestions:e.show_suggested_questions,suggestedQuestions:e.suggested_questions,setValue:d,watch:f,onFieldFocus:n=>I(n)})]}),t.jsxs(ue,{id:"while-chatting",children:[t.jsx(me,{step:2,title:"While chatting"}),t.jsx(je,{children:t.jsxs(Rt,{children:[t.jsxs(Ot,{children:[t.jsxs(kt,{children:[t.jsx(we,{variant:"body-medium",children:"Voice-to-text"}),t.jsx(Ne,{title:"Show a microphone button so visitors can dictate their message instead of typing. Their speech is converted to text.",placement:"top",children:t.jsx(Kt,{component:"span",children:t.jsx(ge,{})})})]}),t.jsx(he,{variant:"body-sm",children:"Let visitors speak to type, their speech is converted to the text in the message window."})]}),t.jsx(K,{name:"other_settings.is_voice_input_enabled",checked:!!e.other_settings?.is_voice_input_enabled,handleChange:n=>d("other_settings.is_voice_input_enabled",n["other_settings.is_voice_input_enabled"]),onFocus:()=>I("other_settings.is_voice_input_enabled")})]})}),t.jsx(ve,{ref:M,value:e.waiting_response_msgs||["Please wait for the response..."],onChange:n=>d("waiting_response_msgs",n),label:"Waiting Response Message",onFieldFocus:n=>I(`waiting_response_msgs.${n}`)})]})]})},rs=()=>{Xe();const{chatbotId:e}=Pe(),s=He(),l=de("view_bot"),_=de("update_bot"),d=Be(),f=We(),{selectedChatbot:g}
1=Ge(),w=a.useRef(),M=a.useRef(),A=a.useRef(!1),[I,D]=a.useState(null),[N,v]=a.useState(null),[F,u]=a.useState(0),{data:i,isLoading:m}=Qe(e),{data:C}=Ue(e),{register:P,handleSubmit:H,setValue:L,watch:n,reset:p,formState:{errors:x},clearErrors:R}=$e({});a.useEffect(()=>{A.current=!1,D(null),v(null)},[e]),a.useEffect(()=>{i?.data&&!A.current&&(p(Z(i.data)),A.current=!0,u(h=>h+1))},[i,p]);const y=n(),r=!!C?.data?.username,{mutateAsync:c,isPending:E}=ze("bot/update/",[[ce]],{useRefetch:!0,idInPath:!0}),b=a.useMemo(()=>i?.data?Z(i.data):null,[i?.data]),B=a.useMemo(()=>{if(!b)return!1;for(const h in b){if(h==="waiting_response_msgs"||h==="suggested_questions"){const T=b[h]||[],W=y[h]||[];if(T.length!==W.length||T.some((G,Q)=>G!==W[Q]))return!0;continue}if(h==="other_settings"){const T=b[h]||{},W=y[h]||{},G=Object.keys(T);if(G.length!==Object.keys(W).length||G.some(Q=>String(T[Q]??"")!==String(W[Q]??"")))return!0;continue}if(String(y[h]??"")!==String(b[h]??""))return!0}return!1},[y,b]),J=!!y?.show_suggested_questions&&Array.isArray(y?.suggested_questions)&&y.suggested_questions.some(h=>!h||h.trim().length===0||h.length>ye),$=Array.isArray(y?.waiting_response_msgs)&&y.waiting_response_msgs.some(h=>!h||h.trim().length===0||h.length>Se),z=J||$,V=a.useCallback(async h=>{if(w.current&&!w.current.validate()){d({success:!1,message:"Please fill in all waiting response messages"});return}if(M.current&&!M.current.validate()){d({success:!1,message:"Please fill in all suggested questions"});return}try{const{info_collector_intro_msg:T,is_username_required:W,is_email_required:G,show_suggested_questions:Q,suggested_questions:re,other_settings:qe,...Ae}=h,De=Array.isArray(re)?re.filter(O=>O?.trim().length>0):[],Y=i?.data||{},Me=!!qe?.is_voice_input_enabled,ae=dt({info_collector_intro_msg:T,is_username_required:W,is_email_required:G,is_voice_input_enabled:Me},Y.other_settings),U={...Ae,is_suggested_questions_enabled:!!Q,suggested_questions:{questions:De},...Object.keys(ae).length>0?{other_settings:ae}:{}};Array.isArray(U.waiting_response_msgs)&&(U.waiting_response_msgs=U.waiting_response_msgs.filter(O=>O?.trim().length>0));const le=Object.fromEntries(Object.entries(U).filter(([O,k])=>JSON.stringify(k)!==JSON.stringify(Y[O])));if(Object.keys(le).length===0){d({success:!0,message:"No changes to save"});return}const X=await c({id:e,data:le});if(X?.success){f({type:Ve,payload:{...g,bot_name:X?.data?.bot_name}});const O={...Y,...X?.data||{},...U.other_settings?{other_settings:{...Y.other_settings||{},...U.other_settings,...X?.data?.other_settings||{}}}:{}};s.setQueriesData({queryKey:[ce]},k=>k&&{...k,data:{...k.data||{},...O}}),p(Z(O)),u(k=>k+1)}d(X)}catch(T){console.error("Chat experience update error:",T),d(T?.response?.data||{success:!1,message:T?.message||"Something went wrong. Please try again."})}},[i?.data,e,f,d,s,g,c,p]),Ce=a.useCallback(()=>{i?.data&&(p(Z(i.data)),u(h=>h+1),D(null),v(null))},[i?.data,p]),Ee=a.useCallback(h=>{D(h),v(h)},[]),Te=a.useCallback(()=>{D(null)},[]);return t.jsx(Ke,{title:"Chat Experience",hasViewPermission:l,hasUpdatePermission:_,isLoading:m||E,formChanged:B,disableSave:z,onDiscard:Ce,onSubmit:H(V),onClearFocus:Te,flushLeftPanel:!0,leftPanel:t.jsx(es,{formValues:y,initialData:b,formVersion:F,register:P,setValue:L,watch:n,errors:x,clearErrors:R,waitingMessagesRef:w,suggestedQuestionsRef:M,setActiveField:Ee,isGorgiasConnected:r,notify:d}),rightPanel:t.jsx(Je,{botData:i?.data,formData:y,activeField:I,activeFieldForMessages:N,sourcePage:"ChatExperience"})})};export{rs as default};
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.