1"use strict"; 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a06f8015-dfaa-5fc3-8af2-5abf3abfd023")}catch(e){}}(); 3(self.webpackChunkchatbot_builder=self.webpackChunkchatbot_builder||[]).push([[940],{85636:(e,t,a)=>{a.d(t,{s:()=>s});var l=a(12481),i=a(53488);class s extends i.OL{async fetchStoreMeta(e){try{const t=this.getDatabase(),a=(0,l.JU)(t,"store-meta",e),i=await(0,l.QT)(a);if(i)return i.data()}catch(t){console.error(t)}}async fetchMultiChannelConfiguration(e){try{const t=await this.fetchStoreMeta(e);if(!t)return;return t.multichannelConfiguration}catch(t){console.error(t)}}async fetchGupShupEnabled(e){try{var t;const a=await this.fetchStoreMeta(e);return!!a&&Object.keys(null!==(t=a.gupshupIntegrationInfo)&&void 0!==t?t:{}).length>0}catch(a){return console.error(a),!1}}}},56896:(e,t,a)=>{a.d(t,{Z:()=>E,u:()=>S});var l=a(72791),i=a(45339),s=a(64291),n=a(42578),r=a(16945),d=a(29377),o=a(97355),c=a(75756),u=a(50329),m=a(39616),h=a(48839),p=a(33263),v=a(70390),g=a(6277),b=a(26092),x=a(85636),f=a(64755),y=a(80184);const S=[{header:"All",id:"All"},{header:"Order status updates",id:"Order status updates"},{header:"Reviews",id:"Reviews"}
3,{header:"Feedback",id:"Feedback"},{header:"Other",id:"Other"},{header:"Others",id:"Others"},{header:"OTP",id:"OTP"},{header:"Brand awareness",id:"Brand awareness"},{header:"Product recommendations",id:"Product recommendations"},{header:"Sales and offers",id:"Sales and offers"},{header:"Seasonal",id:"Seasonal"},{header:"Support",id:"Support"},{header:"Opt out",id:"Opt out"},{header:"Opt out transactional",id:"Opt out transactional"},{header:"Customer support",id:"Customer support"},{header:"AI Marketing",id:"AI Marketing"},{header:"Call invite",id:"Call invite"},{header:"Call permission",id:"Call permission"}].filter((e=>"All"!==e.id)).map((e=>e.id)),C=[{header:"All",id:"All"},{header:"CSAT",id:"CSAT"},{header:"NPS",id:"NPS"}],j=[{header:"Brand awareness",id:"Brand awareness"},{header:"Product recommendations",id:"Product recommendations"},{header:"Sales and offers",id:"Sales and offers"},{header:"Seasonal",id:"Seasonal"},{header:"Opt out",id:"Opt out"},{header:"AI Marketing",id:"AI Marketing"},{header:"Call invite",id:"Call invite"},{header:"Call permission",id:"Call permission"},{header:"Others",id:"Others"}],T=[{header:"Order status updates",id:"Order status updates"},{header:"Reviews",id:"Reviews"}
3,{header:"Feedback",id:"Feedback"},{header:"Opt out transactional",id:"Opt out transactional"},{header:"Customer support",id:"Customer support"},{header:"Call invite",id:"Call invite"},{header:"Call permission",id:"Call permission"},{header:"Other",id:"Other"}],_=[{header:"Marketing",id:"Marketing"},{header:"Transaction",id:"Transaction"}];let w=null;const E=e=>{var t,a,E;const{storeId:I,onCancel:k,title:N,originalTemplateList:V,subType:M,setIsFetchedTemplate:A,isFetchedTemplate:P,fetchMoreTemplateList:O,setFetchMoreTemplateList:L,templatesCount:B,offset:D,isWhatsappCarousel:H,fetchMediaCarouselTemplates:$,fetchProductCarouselTemplates:R}=e,[z,F]=(0,l.useState)([]),[Z,W]=(0,l.useState)(""),[U,q]=(0,l.useState)("All"),[K,G]=(0,l.useState)(),[J,Q]=(0,l.useState)(!0),Y=d.r.getInstance(),X=M===o.PC.email_temp_new?"email":M===o.PC.send_sms?"message":"email_csat"===M?"email":M===o.PC.send_rcs?"rcs":"whatsapp",ee="email_csat"===M,te=e=>{q(e.value||"All")},ae=()=>{const e="All"===U?ee?["CSAT","NPS"]:S:[U];Y.fetchTemplateHelper(I,X,e,Z,void 0,$,R).then((e=>{const{templateListTemp:t}=e;t.length>0?setTimeout((()=>{F([...t]),A(!0)}),200):(F([...t]),A(!0))})).catch((e=>{F([]),A(!0)}))};(0,l.useEffect)((()=>{Z.length<=0&&"All"===U?F(V):Z.length<=0&&"All"!==U&&ae()}),[Z]),(0,l.useEffect)((()=>{"All"!==U?(A(!1),ae()):"All"===U&&(W(""),F(V))}),[U]),(0,l.useEffect)((()=>{I&&new x.s("","").fetchGupShupEnabled(I).then((e=>{Q(e)})).catch((e=>(0,f.d)(e,"Error in fetchGupShupEnabled")))}),[I]),(0,l.useEffect)((()=>{K&&Y.fetchTemplateHelper(I,X,(()=>{const e=["Brand awareness","Product recommendations","Sales and offers","Seasonal","Opt out","Others","NPS","CSAT","AI Marketing"];return"Marketing"!==K?["Order status updates","Reviews","Feedback","Other","Opt out transactional","Customer support"]:"template"!==M?e.filter((e=>"AI Marketing"!==e)):e})(),Z,void 0,$,R).then((e=>{const{templateListTemp:t}=e;t.length>0?setTimeout((()=>{F([...t]),A(!0)}),200):(F([...t]),A(!0))})).catch((e=>{F([]),A(!0)}))}),[K]);return(0,l.useEffect)((()=>{F(V)}),[V]),(0,y.jsx)(c.o,{centralContainerStyles:{width:H?1360:1080},zIndex:200,onClose:k,open:!0,headingTitle:N?`Select a ${N} template message`:"Select a template message",children:(0,y.jsxs)(g.N,{width:H?"420px":"328px",children:[(0,y.jsxs)("div",{className:"modal__dropdown",children:[(0,y.jsx)("div",{className:"modal__dropdown__search",style:{marginRight:16},children:(0,y.jsx)(i.Z,{placeHolder:"Search (min 3 character)",onChangeHandle:e=>{A(!1);const t=e.target.value;W(t),w&&clearTimeout(w),w=setTimeout((()=>{if(e.target.value.length>0){const e="All"===U?ee?["CSAT","NPS"]:"email"===X?S:[]:[U];Y.fetchTemplateHelper(I,X,e,t,void 0,$,R).then((e=>{const{templateListTemp:t}=e;t.length>0?setTimeout((()=>{F([...t]),A(!0)}),400):(F([...t]),A(!0))})).catch()}else t.length<=0&&"All"===U&&(F(V),A(!0))}),1e3)},value:Z})}),P&&M!==o.PC.send_sms&&(0,y.jsxs)("div",{style:{display:"flex",gap:8},children:[!ee&&(0,y.jsx)(u.L,{width:"160px",onSelect:e=>{var t;"Marketing"===(t=e).value?G("Marketing"):"Transaction"===t.value&&G("Transaction"),te({value:"All"})},placement:"bottom-end",placeHolder:"Type",isSearchable:!1,options:null!==(t=null===_||void 0===_?void 0:_.map((e=>({label:e.header,value:e.header,selected:e.header===K}))))&&void 0!==t?t:[]}),(ee||K)&&(0,y.jsx)(u.L,{width:"240px",height:"200px",onSelect:e=>{te(e)},placement:"bottom-end",placeHolder:"Sub-Category",isSearchable:!1,options:null!==(a=null===(E=ee?C:"Marketing"!==K?T:"template"!==M?j.filter((e=>"AI Marketing"!==e.id)):j)||void 0===E?void 0:E.map((e=>({label:e.header,value:e.header,selected:e.header===U}))))&&void 0!==a?a:[]})]}),M!==o.PC.send_sms&&!J&&(0,y.jsx)("div",{style:{marginLeft:"auto"},children:(0,y.jsx)(m.z,{matchParentWidth:!0,onClick:()=>{let t=b.W;[o.PC.email_temp_new,o.PC.email_csat].includes(e.subType)&&(t=b.g),window.open(t,"_blank","noreferrer")},buttonText:"Create new template",buttonType:"primary",size:"large"})})]}),(Z&&Z.length||U.length)&&!z.length&&P?(0,y.jsxs)("div",{className:"err-screen",style:{padding:"50px 0"},children:[(0,y.jsx)("div",{className:"err-screen__icon_holder",children:(0,y.jsx)("div",{className:"err-screen__icon_holder__icon",children:(0,y.jsx)(r.Z,{})})}),(0,y.jsxs)("div",{className:"err-screen__desc",children:[(0,y.jsx)("div",{className:"err-screen__desc__title",children:"No results found"}),(0,y.jsx)("div",{children:Z.length?`We could not find any results for ${Z}`:"We could not find any results for the selected category"}),Z.length>0&&(0,y.jsx)("div",{children:"Please try searching for something else"})]})]}):P?(0,y.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,y.jsx)("div",{className:"template-grid-container",children:(t=>t.map(((t,a)=>(0,y.jsx)(s.Z,{template:t,hoverStyle:{opacity:.7,border:"1px solid #BDBDBD",outline:"none"},onCardClick:(t,a)=>{e.onSelectTemplate(t,a)},isWhatsappCarousel:H},a))))(z)}),"All"===U&&!Z&&(0,y.jsxs)("div",{style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",marginTop:8,marginBottom:8},children:[(0,y.jsxs)(h.HO,{style:{color:p.DM.content.placeholder},children:["Showing ",`${D}`," out of ",`${B}`," templates"]}),(0,y.jsx)(m.z,{style:{flexDirection:"row-reverse",marginLeft:12},buttonText:"Show more",buttonType:"tertiaryGray",size:"small",isLoading:!O,onClick:()=>{L(!1)},disabled:B<=D,TrailingIcon:()=>(0,y.jsx)("div",{style:{display:"flex"},children:(0,y.jsx)(v.Z,{color:p.DM.content.secondary})})})]})]}):(0,y.jsx)(n.kq,{}),z.length<=0&&P&&!Z&&!U&&(0,y.jsxs)("div",{className:"err-screen",style:{padding:"50px 0"},children:[(0,y.jsx)("div",{className:"err-screen__icon_holder",children:(0,y.jsx)("div",{className:"err-screen__icon_holder__icon",children:(0,y.jsx)(r.Z,{})})}),(0,y.jsxs)("div",{className:"err-screen__desc",children:[(0,y.jsx)("div",{className:"err-screen__desc__title",children:"No results found"}),(0,y.jsx)("div",{children:"We could not find any results"})]})]})]})})}},72571:(e,t,a)=>{a.d(t,{H:()=>o});var l=a(33263),i=a(18666);const s=/{{(.*?)}}/g,n=/\{\{[\s\S]*?\}\}/g,r=/<a(?!.*>)(.)*href=(\"|\')$/,d=/<img(?!.*>)(\n| )*(.)*(\n| )*src=(\"|\')$/;class o{normalizeVariableObject(e){let t=[];return Object.keys(e).map((a=>{const l=e[a];t=[...t,...l]})),t}processHtmlContent(e,t){var a;let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.DM.content.brand;let r=!1,d=0;return null===e||void 0===e||null===(a=e.split(n))||void 0===a?void 0:a.map(((e,a)=>{var l,n,o,c,u,m;if(!t[a])return e;"{{##orderProducts}}"===t[a].variableName||"{{##abandonedCartProducts}}"===t[a].variableName?r=!0:"{{//orderProducts}}"!==t[a].variableName&&"{{//abandonedCartProducts}}"!==t[a].variableName||(r=!1);const h=null===(l=t[a])||void 0===l||!l.updatedValue||null!==(n=t[a])&&void 0!==n&&n.updatedValue.startsWith("https://")?null!==(c=null===(u=t[a])||void 0===u?void 0:u.variableName)&&void 0!==c?c:"":null===(o=t[a])||void 0===o?void 0:o.updatedValue,p="link"===(null===(m=t[a])||void 0===m?void 0:m.type);return r||["{{##single}}","{{//single}}","{{//orderProducts}}","{{//abandonedCartProducts}}"].includes(t[a].variableName)||i._p.includes(t[a].variableName)||i.en.includes(t[a].variableName)?`${e}<span></span><span style="color: ${s}; text-decoration: underline;">${h}</span><span> </span>`:(d+=1,p||(null===(v=t[a])||void 0===v||!v.updatedValue)&&e.endsWith('src="')?`${e}${h}`:e.endsWith("src=")?`${e}"<span></span><span style="color: ${s}; text-decoration: underline;">${h}</span><span> </span>"`:`${e}<span></span><span id="connectors_variable_${d}" style="color: ${s}; text-decoration: underline;">${h}</span><span> </span>`);var v})).join("")}getVariableList(e,t){const a=e,l=this.normalizeVariableObject(t),i=["unsubscribe"];l.forEach((e=>{var t;return null!==e&&void 0!==e&&e.values?null===e||void 0===e||null===(t=e.values)||void 0===t?void 0:t.forEach((e=>{var t;return i.push(null===e||void 0===e||null===(t=e.slice(2,-2))||void 0===t?void 0:t.trim())})):i.push(e.title)}));const o=a.match(s),c=null===o||void 0===o?void 0:o.map((e=>{var t,a,l;const s=e;return{variableName:s,type:"string",isEditableVariable:!i.includes(null===s||void 0===s||null===(t=s.slice(2,-2))||void 0===t?void 0:t.trim()),updatedValue:i.includes(null===s||void 0===s||null===(a=s.slice(2,-2))||void 0===a?void 0:a.trim())?`{{${null===s||void 0===s||null===(l=s.slice(2,-2))||void 0===l?void 0:l.trim()}}}`:""}}));
3return null===a||void 0===a||a.split(n).forEach(((e,t)=>{null!==c&&void 0!==c&&c.length&&c[t]&&(r.test(e)||d.test(e))&&(c[t].type="link")})),null!==c&&void 0!==c?c:[]}}},42262:(e,t,a)=>{a.d(t,{Z:()=>B});var l=a(72791),i=a(27368),s=a(75756),n=a(99907),r=a(67658),d=a(26913),o=a(42578),c=a(97355),u=a(61990),m=a(95048),h=a(29377),p=a(35107),v=a(72571),g=a(33263),b=a(20999),x=a(5673),f=a(4229),y=a(48839),S=a(95129),C=a(87115),j=a(55737),T=a(50329),_=a(62071),w=a(39616),E=a(90082),I=a(66918),k=a(64813),N=a(24154),V=a(80184);const M=E.ZP.div` 4 padding-left: 24px; 5 padding-right: 24px; 6 padding-bottom: 16px; 7 border-radius: 4px; 8 flex-direction: row; 9 align-items: flex-start; 10 justify-content: center; 11 margin-left: auto; 12 margin-right: auto; 13 background-color: ${g.DM.surface.standard}; 14`,A=E.ZP.div` 15 flex-direction: row; 16 justify-content: space-between; 17 align-items: center; 18 margin-top: 16px; 19 display: flex; 20`,P=e=>{var t,a,i,n,r,d;const{handleEmailAddTemplate:o,onEditCancel:c,messageTemplate:m}=e,[p,v]=(0,l.useState)({actualValue:null!==(t=null===m||void 0===m?void 0:m.subject)&&void 0!==t?t:"",variableType:"string"}),[E,P]=(0,l.useState)(""),[O,L]=(0,l.useState)(null!==(a=null===m||void 0===m?void 0:m.senderName)&&void 0!==a?a:""),[B,D]=(0,l.useState)(null!==m&&void 0!==m&&m.from?m.from.split("@")[0]:""),[H,$]=(0,l.useState)(null!==m&&void 0!==m&&m.from?"BIK"===m.channelStatus?m.from.split("@")[1]:m.from:""),[R,z]=(0,l.useState)(null!==(i=null===m||void 0===m?void 0:m.replyEmail)&&void 0!==i?i:""),[F,Z]=(0,l.useState)(""),[W,U]=(0,l.useState)(""),[q,K]=(0,l.useState)(""),[G,J]=(0,l.useState)(null!==(n=null===m||void 0===m?void 0:m.isSameAsReplyEmail)&&void 0!==n&&n),Q=h.r.getInstance(),[Y,X]=(0,l.useState)([]),[ee,te]=(0,l.useState)([]),[ae,le]=(0,l.useState)(null!==(r=null===m||void 0===m?void 0:m.channelStatus)&&void 0!==r?r:""),ie=(0,u.C)((e=>{var t;return null===(t=e.homeState)||void 0===t?void 0:t.storeId})),[se,ne]=(0,l.useState)(!1),[re,de]=(0,l.useState)({actualValue:null!==(d=null===m||void 0===m?void 0:m.preHeader)&&void 0!==d?d:"",variableType:"string"}),[oe,ce]=(0,l.useState)(void 0),[ue,me]=(0,l.useState)(!1),{variablesList:he}=(0,N.Z)();(0,l.useEffect)((()=>{ie&&(async()=>{if(!ie)return;const{status:e,verifyDomains:t,verifySenders:a}=await Q.fetchChannelIntegrationStatus(ie,null===m||void 0===m?void 0:m.channelStatus);if(le(null!==e&&void 0!==e?e:""),ee||a)if("BIK"===e){const e=[];t.forEach((t=>{"VERIFIED"===t.status&&e.push({label:t.domainName,value:t.domainName})}));let a=-1;!H&&e.length?$(e[0].value):H&&e.forEach(((e,t)=>{e.value===H&&(a=t)})),-1===a&&e.length&&$(e[0].value),te([...e])}else{const e=[];a.forEach((t=>{e.push({label:t.fromEmail,value:t.fromEmail})}));let t=-1;!H&&e.length?$(e[0].value):H&&e.forEach(((e,a)=>{e.value===H&&(t=a)})),-1===t&&e.length&&$(e[0].value),X([...e])}})()}),[ie]),(0,l.useEffect)((()=>{const e=document.getElementById("bik-modal");if(e){const t=e.querySelector("div");if(t){const e=t.querySelector("div");e&&ce(e)}}}),[ae]);function pe(e){$(e.value)}const ve=e=>{me(!!e)};return(0,V.jsxs)(s.o,{hideCrossButton:ue,centralContainerStyles:{width:600},zIndex:200,onClose:c,open:!0,headingTitle:"Add email details",footerShadow:!0,primaryButton:{buttonText:"Save",buttonType:"primary",size:"small",onClick:()=>{(()=>{var e,t;const a=null!==(e=null===p||void 0===p?void 0:p.actualValue)&&void 0!==e?e:"",l=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;let i=!1;a?0===a.trim().length&&(P("Required field!"),i=!0):(P("Required field!"),i=!0),"BIK"!==ae||O||(Z("Required!"),i=!0),[",","<",">",";",":"].some((e=>O.includes(e)))&&(Z("Invalid sender name!"),i=!0);const s=H.includes("@")?H:B+"@"+H;if("BIK"!==ae||B&&l.test(s.trim())||(U("Required!"),i=!0),"BIK"!==ae||G||R?"BIK"!==ae||G||!R||l.test(R.trim())||(K("Invalid Email!"),i=!0):(K("Required!"),i=!0),i)return;const n={subject:a,preHeader:null!==(t=null===re||void 0===re?void 0:re.actualValue)&&void 0!==t?t:"",from:s,senderName:O,replyEmail:G?s:R,isSameAsReplyEmail:G,channelStatus:ae};o(n)})()},disabled:!ae},secondaryButton:{buttonText:"Cancel",buttonType:"tertiaryGray",size:"small",onClick:()=>c(),disabled:!ae},children:[!ae&&(0,V.jsx)("div",{style:{marginTop:120,marginBottom:120},children:(0,V.jsx)(b.$,{size:"large"})}),!!ae&&(0,V.jsxs)(M,{className:"email_details",children:[(0,V.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,V.jsx)(x.p,{onPickerToggle:ve,labelText:"Subject",variablesList:he,noMaxCharCheck:!1,maxCharLimit:60,onChange:e=>{v(e),P("")},showVarHeader:!0,varHeaderText:"Select Variable",allowMix:!0,prevVariable:p,errorMessage:E,pickerType:f.u.EMBEDDED,portalElement:null!==oe&&void 0!==oe?oe:document.body},"add_subject")}),"BIK"===ae&&(0,V.jsxs)("div",{style:{marginTop:4},children:[(0,V.jsx)(x.p,{onPickerToggle:ve,showVarHeader:!0,varHeaderText:"Select Variable",noMaxCharCheck:!1,maxCharLimit:60,variablesList:he,onCh
20ange:e=>{de(e)},allowMix:!0,prevVariable:re,pickerType:f.u.EMBEDDED,portalElement:null!==oe&&void 0!==oe?oe:document.body,labelElement:(0,V.jsxs)("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"},children:[(0,V.jsx)(y.HO,{children:"Pre-header"}),(0,V.jsx)("div",{children:(0,V.jsx)(S.u,{width:400,placement:"right",body:"An email pre-header is the brief text that your customers would see after the sender information and the subject line when they look at an email in their inbox",children:(0,V.jsx)(C.h,{width:16,height:16,style:{display:"flex",color:"#9E9E9E"},Icon:k.Z})})})]})},"add_pre_header"),(0,V.jsx)(j.I,{id:"email-sender-name",labelText:"Sender name",placeholder:"Add a person's or organisation's name",errorMessage:F||"",maxCharLimit:60,hintText:"This would be visible alongside the from email address",value:O,onChangeText:e=>{Z(""),L(e.trim())}})]}),(0,V.jsxs)("div",{style:{marginTop:24,display:"flex",flexDirection:"column"},children:["BIK"===ae&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)("div",{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},children:[(0,V.jsx)(j.I,{width:"45%",labelText:"From email address",placeholder:"John",onChangeText:e=>{U(""),D(e.trim())},hintText:" ",value:B,errorMessage:W||""}),(0,V.jsx)("span",{style:{margin:"0 5px"},children:"@"}),(0,V.jsx)(T.L,{width:"300px",onSelect:e=>{pe(e)},placement:"bottom-end",placeHolder:"Select domain",isSearchable:!1,options:function(){var e;let t=!1;return null!==(e=null===ee||void 0===ee?void 0:ee.map((e=>{const a=H?H===e.value:e.value===(null===ee||void 0===ee?void 0:ee[0].value),l={label:e.label,value:e.value,selected:a&&!t};return a&&!t&&(t=!0),l})))&&void 0!==e?e:[]}()})]}),(0,V.jsxs)("div",{style:{marginTop:12},children:[(0,V.jsx)(j.I,{id:"reply-to-email",labelText:"Reply to email address",placeholder:"[email protected]",errorMessage:q||"",state:G?"disabled":"none",value:G?B+"@"+H:R,onChangeText:e=>{K(""),z(e.trim())}}),(0,V.jsx)(y.J2,{style:{marginTop:10},children:"Customer replies will be received on this email address"})]}),(0,V.jsxs)("div",{style:{marginTop:24,display:"flex",gap:8,alignItems:"center"},children:[(0,V.jsx)(_.J,{onValueChange:e=>{e&&(z(""),K("")),J(e)},isChecked:G}),(0,V.jsx)(y.J2,{children:"Same as \u2018From email address\u2019"})]})]}),"SENDGRID"===ae&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(y.HO,{style:{marginBottom:8},children:"From email address"}),(0,V.jsx)("div",{children:(0,V.jsx)(T.L,{width:"100%",onSelect:e=>{pe(e)},placement:"bottom-start",placeHolder:"Select from emails linked",isSearchable:!1,isMultiSelect:!1,options:function(){var e;let t=!1;return null!==(e=null===Y||void 0===Y?void 0:Y.map((e=>{const a=H?H===e.value:e.value===(null===Y||void 0===Y?void 0:Y[0].value),l={label:e.label,value:e.value,selected:a&&!t};return a&&!t&&(t=!0),l})))&&void 0!==e?e:[]}()})}),(0,V.jsxs)(A,{children:[(0,V.jsx)(y.YS,{children:"Sync SendGrid email accounts here"}),(0,V.jsx)(w.z,{size:"chip",buttonType:"tertiary",buttonText:"Sync",onClick:e=>{e.stopPropagation(),ne(!0),(async()=>{const e=await Q.syncVerifiedSenders(ie),t=[];e&&0!==e.length&&(e.forEach((e=>{t.push({label:e.fromEmail,value:e.fromEmail})})),X([...t]),ne(!1))})()},isLoading:se,LeadingIcon:()=>(0,V.jsx)("div",{style:{display:"flex"},children:(0,V.jsx)(I.Z,{color:g.DM.icon.placeholder,width:16,height:16})})})]})]})]})]})]})};var O=a(25138),L=a(18666);const B=e=>{const{storeId:t,template:a,emailHtml:g,conf:b,config:x,variablesList:f,setSaveTo:y,onEditCancel:S,onBackClick:C,onSelect:j}=e,[T,_]=(0,l.useState)(!0),[w,E]=(0,l.useState)(!1),[I,k]=(0,l.useState)(),[N,M]=(0,l.useState)([]),[A,B]=(0,l.useState)({}),[D,H]=(0,l.useState)(""),[$,R]=(0,l.useState)(),[z,F]=(0,l.useState)(),[Z,W]=(0,l.useState)(!1),[U,q]=(0,l.useState)([]),{getHtmlContent:K}=(0,d.L)(t),G=((0,m.I0)(),(0,u.C)((e=>e.nodeClickState)),h.r.getInstance()),[J,Q]=(0,l.useState)(""),Y=new v.H,[X,ee]=(0,l.useState)(!0),[te,ae]=(0,l.useState)(),le=async(e,t,a)=>{var l;let i="";const s=!(null===e||void 0===e||!e.htmlContentWithoutProductVarUrl),n=new RegExp(`\\{\\{##(${["baseUrl","podName","reviewUrl"].join("|")})\\}\\}`,"g");
20"string"===typeof t&&t?(i=t,(!a||null!==a&&void 0!==a&&a.isV2)&&(i=t.replace(/<!--[\s\S]*?-->/g,"").replace(n,""),ee(!1))):W(!0);const r=Y.getVariableList(i,A,s),d=await Y.processHtmlContent(i,r);let o=!1,c="";const u=[];r.forEach((e=>{L._p.includes(e.variableName)?(o=!0,c=e.variableName):L.en.includes(e.variableName)&&(o=!1,c=""),L._p.includes(e.variableName)||L.en.includes(e.variableName)||(L.tx.includes(c)?u.push(e):o||L.en.includes(e.variableName)||u.push(e))}));const m=u.map(((e,t)=>{var l;const i=G.getChatBotMappingsV2(f,e.variableName.trim());let s="";var n;null!==a&&void 0!==a&&null!==(l=a.body)&&void 0!==l&&l.selectedFields[t]?s=null===a||void 0===a||null===(n=a.body)||void 0===n?void 0:n.selectedFields[t]:"{{unsubscribeUrl}}"===e.variableName?s=e.variableName:i&&(s=i.includes("{{")?i:"{{"+i+"}}");return{variableName:null!==i&&void 0!==i?i:e.variableName,type:s.includes("https://")?"link":"string",isEditableVariable:"{{unsubscribeUrl}}"!==e.variableName,updatedValue:s}}));Q(null!==(l=null===a||void 0===a?void 0:a.discountCode)&&void 0!==l?l:""),H(d),k(e),M(m),R(a),_(!1)};return(0,l.useEffect)((()=>{const e=[...f];e.push(p.Cp),e.sort(((e,t)=>e.orderId-t.orderId)),q(e)}),[f]),(0,l.useEffect)((()=>{f&&f.length>0&&(b.message_template&&b.message_template.approvedTemplateId?G.fetchTemplateById(t,b.message_template.approvedTemplateId).then((e=>{K(e).then((t=>{t&&(null===t||void 0===t?void 0:t.length)>0?le(e,t,b.message_template):W(!0)}))})).catch():g&&(null===g||void 0===g?void 0:g.length)>0?le(a,g):W(!0))}),[b,a,g,f]),(0,V.jsxs)("div",{children:[T&&0===N.length&&!I?(0,V.jsx)(s.o,{centralContainerStyles:{width:1080,height:700},zIndex:200,onClose:S,open:!0,headingTitle:"",headingSubtitle:"",children:(0,V.jsx)(o.T4,{})}):w?(0,V.jsx)(P,{onEditCancel:S,handleEmailAddTemplate:e=>{var t;const a={message_template:{...null===z||void 0===z?void 0:z.message_template,from:e.from,subject:e.subject,senderName:e.senderName,replyEmail:e.replyEmail,isSameAsReplyEmail:e.isSameAsReplyEmail,channelStatus:e.channelStatus,isV2:!X,preHeader:e.preHeader},default_node:null!==(t=b.default_node)&&void 0!==t?t:""},l={...z,...a},i={type:"Message",subType:c.PC.email_temp_new,isMicroFlow:!1,header:`${l.message_template.name}`,description:`${l.message_template.subject}`,slang:"",childNodes:[]};l.sub_type=x.subType,x.nodeIndex&&(l.node_index=x.nodeIndex),j(te,D,l,i)},messageTemplate:$}):(0,V.jsx)(n.b,{onTemplateSelect:(e,t)=>{var a,l;ae(e);let i=!1;if(t.forEach((e=>{if(!e.isEditableVariable||e.updatedValue&&0!==e.updatedValue.trim().length)if(e.updatedValue&&e.updatedValue.includes("https")&&!e.updatedValue.includes("https://{{unsubscribeUrl}}")){const t=e.updatedValue.split("https://");O.y.test(e.updatedValue.trim())&&t[1]&&0!==t[1].trim().length||(i=!0)}else e.updatedValue&&e.updatedValue.length>30&&!e.updatedValue.includes("{{")&&(i=!0);else i=!0})),i)return{error:"Some inputs are missing"};const s={approvedTemplateId:e.templateId,message_template:{actionType:"EMAIL",approvedTemplateId:e.templateId,body:{content:e.htmlContentUrl,uiContent:(null===e||void 0===e?void 0:e.htmlContentWithoutProductVarUrl)||"",selectedFields:t.map((e=>e.updatedValue.length>0?e.updatedValue.trim():e.variableName))||[]},name:null!==(a=e.name)&&void 0!==a?a:"",templateCategory:null!==(l=e.templateCategory)&&void 0!==l?l:"",discountCode:J,category:"Marketing",channel:"EMAIL",to:"{{customer.email}}"},type:"message"};F(s),_(!1),E(!0)},selectedTemplate:I,showVariableMapping:0!==N.length,channel:i.i_.EMAIL,globalPlaceholders:A,htmlContent:D,templateVariables:N,closeDialog:S,zIndex:11,variableList:U,showVariableModal:!0,onBackPress:()=>{C()},discountCode:J,setDiscountCode:Q}),Z&&(0,V.jsx)(r.x,{text:"Loading failed!, Please try again",width:"300px",type:"error",autoClose:3e3,onCloseToast:()=>{W(!1)}})]})}}}]); 21//# sourceMappingURL=940.47af7e75.chunk.js.map 22//# debugId=a06f8015-dfaa-5fc3-8af2-5abf3abfd023
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.