@bikdotai/bik-component-library 0.0.612-beta-vsp.2 → 0.0.612-beta-vsp.4
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/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
- package/dist/cjs/components/template-context-mapper/utils/validateName.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/dist/esm/components/template-context-mapper/utils/validateName.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../curtain/CurtainHelper.js");var n=require("../../variable-picker-v3/model.js"),t=require("lodash"),o=require("react"),i=require("styled-components"),l=require("../../input/Input.js"),a=require("../../input-with-vars/InputWithVariables.js"),s=require("../../template-preview/models/TemplateMeta.js"),d=require("../../template-preview/models/WhatsAppTemplate.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../curtain/CurtainHelper.js");var n=require("../../variable-picker-v3/model.js"),t=require("lodash"),o=require("react"),i=require("styled-components"),l=require("../../input/Input.js"),a=require("../../input-with-vars/InputWithVariables.js"),s=require("../../template-preview/models/TemplateMeta.js"),d=require("../../template-preview/models/WhatsAppTemplate.js"),u=require("../context/templateModalContext.js"),r=require("../utils/constants.js"),p=require("../utils/getDataFromTemplateComponent.js"),c=require("../utils/validateIsUrl.js"),v=require("../utils/validateName.js"),m=require("./BackTrackComponent.js"),b=require("./DiscountCodeComponent.js"),g=require("./EditMediaModal.js"),h=require("./EditMediaV2.js"),j=require("./EditMediaV2.style.js"),f=require("./useEditWhtasappTemplateMedia.js"),C=require("./VariableConnector.js"),x=require("./VariableConnectorsPanel.js"),O=require("./VariableConnectorWhatsApp.js"),T=require("./VariableEditorHeader.js"),y=require("./WhatsAppTemplateCardButtonV2.js");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const V=E(i).default.div`
|
|
2
2
|
padding-top: 24px;
|
|
3
3
|
padding-left: 10px;
|
|
4
4
|
padding-right: 10px;
|
|
5
5
|
margin-bottom: 8px;
|
|
6
6
|
line-height: normal;
|
|
7
|
-
`;exports.default=i=>{let{template:E,onTemplateChange:B,whatsappSpecificPickerMeta:M,showVariableModal:k,variableListForImage:q,setDiscountCode:I,fileName:D,setFileName:R}=i;var L,U,P,w,A,_,N,S,H,F,Q,Y,W,K,$,G,X,z,J,Z,ee,ne,te,oe,ie,le,ae,se,de,re,ue,pe,ce,ve,me,be,ge,he,je;const fe=E.isCarouselType,{originalVariableList:Ce,pod:xe,extras:Oe,selectedCarouselIndex:Te,isProductCarouselType:ye,disableCopyCode:Ee}=r.useTemplateModalContext(),{descriptionComponents:Ve,urlBtns:Be,qrbBtns:Me,imageComponent:ke,bodyVariables:qe,headerVariables:Ie}=p.getAllDataFromTemplateComponent(E),De=o.useRef(null),[Re,Le]=o.useState(!1),[Ue,Pe]=o.useState(-1===Te?{descriptionComponents:Ve,urlBtns:Be,qrbBtns:Me,imageComponent:ke,bodyVariables:qe,headerVariables:Ie}:{}),{uploadMediaLink:we,uploadMediaFiles:Ae,validateMimeType:_e}=M,Ne=f.useEditWhatsappTemplateMedia({uploadMediaLink:we,uploadMediaFiles:Ae,updateTemplateImageUrl:function(e,n){var o,i,l,a,s,d,r,u;let p;p=null!=Te&&Te>-1?{components:null===(i=null===(o=E.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[Te].components,mapping:null===(a=null===(l=null==E?void 0:E.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Te]}:Object.assign({},E);const c=null===(s=null==p?void 0:p.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==p?void 0:p.components[c])){const t=Object.assign(Object.assign({},p.components[c]),{format:n,example:{header_handle:[e]}}),o=[...p.components];o[c]=t,p=Object.assign(Object.assign({},p),{components:o})}p.mapping&&(p.mapping=Object.assign(Object.assign({},p.mapping),{header:void 0}));if(null!=Te&&Te>-1){const e=t.cloneDeep(E);e.components[1].cards[Te].components=p.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==e?void 0:e.mapping)||void 0===r?void 0:r.cards.length)>0&&(e.mapping.cards[Te]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==B||B(Object.assign({},e)),He(!0)}else null==B||B(Object.assign({},p))},validateMimeType:_e,mediaComponent:fe?Ue.imageComponent:ke,fileRef:De}),[Se,He]=o.useState(!1),[Fe,Qe]=o.useState(D),[Ye,We]=o.useState();function Ke(e,n,o){var i,l,a,s,d,r,u,p,c,v;const m=null!=Te&&Te>-1?{components:null===(i=Object.assign({},E).components[1].cards)||void 0===i?void 0:i[Te].components,mapping:null===(l=Object.assign({},E).mapping.cards)||void 0===l?void 0:l[Te]}:Object.assign({},E),b=t.cloneDeep(m),g="custom"===n&&"string"==typeof e,h=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Te&&Te>-1&&ye){const n=Object.assign({},E).components.map((e=>{var n;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(n=e.cards)||void 0===n?void 0:n.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var n,t,i;if("BUTTONS"===e.type){const l=null===(n=e.buttons)||void 0===n?void 0:n.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[o])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[h]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),i=null===(s=null===(a=Object.assign({},E).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((n=>{var t;return Object.assign(Object.assign({},n),{buttons:null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.map((n=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),l=t.cloneDeep(E);return l.components=n,l.mapping.cards=i,void(null==B||B(Object.assign({},l)))}const j=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==j&&j>-1){const t=null===(d=null==b?void 0:b.components[j].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===n&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=t[o];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(p=null===(u=null===(r=b.components)||void 0===r?void 0:r[j])||void 0===u?void 0:u.buttons)&&void 0!==p?p:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[j]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[o]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[j]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?Le(!0):(Le(!1),null==I||I(""))}if(null!=Te&&Te>-1){const e=t.cloneDeep(E);e.components[1].cards[Te].components=b.components,e.mapping.cards[Te]=b.mapping,null==B||B(Object.assign({},e))}else null==B||B(b)}function $e(e,n,o){var i,l,a,s,d,r,u;const p=null!=Te&&Te>-1?{components:null===(i=Object.assign({},E).components[1].cards)||void 0===i?void 0:i[Te].components,mapping:null===(l=Object.assign({},E).mapping.cards)||void 0===l?void 0:l[Te]}:Object.assign({},E);if(null!=Te&&Te>-1&&ye){const n=Object.assign({},E).components.map((n=>{var t;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(t=n.cards)||void 0===t?void 0:t.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var t,i,l;if("BUTTONS"===n.type){const a=null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[o])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==n?void 0:n.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},n),{buttons:d})}return n}))})))}):n})),i=t.cloneDeep(E);return i.components=n,void(null==B||B(Object.assign({},i)))}const c=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const n=null===(s=null===(a=null==p?void 0:p.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(n){let t=n[o];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(u=null===(r=null===(d=p.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==u?u:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},p.components[c]),{buttons:i}),a=[...p.components];a[c]=l,p.components=a}}if(null!=Te&&Te>-1){const e=t.cloneDeep(E);e.components[1].cards[Te].components=p.components,null==B||B(Object.assign({},e))}else null==B||B(p)}o.useEffect((()=>{var e,n;if(null===(e=E.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))Le(!0);else{Le(!1);const e=null===(n=null==Oe?void 0:Oe.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[E]),o.useEffect((()=>{var e,n,t,o;if(null!=Te&&Te>-1){const i={components:null===(n=null===(e=E.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Te].components,mapping:null===(o=null===(t=null==E?void 0:E.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Te]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Pe({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u})}else if(null!=Te&&-1===Te){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=p.getAllDataFromTemplateComponent(E);Pe({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[Te]),o.useEffect((()=>{var e,n,t,o;if(null!=Te&&Te>-1&&Se){const i={components:null===(n=null===(e=E.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Te].components,mapping:null===(o=null===(t=null==E?void 0:E.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Te]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Pe({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}),He(!1)}}),[Se]);const Ge=fe?Ue.imageComponent:ke;return Ne.openEditMedia?e.jsx(x.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(g.default,{mediaComponentFormat:null!==(L=Ge.format)&&void 0!==L?L:s.HEADER_TYPES.IMAGE,uploadMedia:Ne.uploadMedia,variableListForImage:q||[],useEditWhatsappTemplateMediaResponse:Ne,setOpenEditMedia:Ne.setOpenEditMedia,openEditMedia:Ne.openEditMedia,editIconRef:Ne.editIconRef,fileRef:De})})):e.jsxs(x.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:ye?"420px":"auto"}},{children:[!!Ue.imageComponent&&!ye&&e.jsxs(j.EditTemplateMediaContainer,{children:[e.jsx(h.default,{imageName:null!==(P=null===(U=null==Ge?void 0:Ge.example)||void 0===U?void 0:U.header_handle)&&void 0!==P?P:[],handleImageChange:Ne.handleImageChange,mediaType:null==Ge?void 0:Ge.format,error:Ne.error,isLoading:Ne.loading,setOpenEditMedia:Ne.setOpenEditMedia,selectedVariable:c.isVariable(null!==(_=null===(A=null===(w=null==Ge?void 0:Ge.example)||void 0===w?void 0:w.header_handle)||void 0===A?void 0:A[0])&&void 0!==_?_:"")?null===(S=null===(N=null==Ge?void 0:Ge.example)||void 0===N?void 0:N.header_handle)||void 0===S?void 0:S[0]:(null===(F=null===(H=null==E?void 0:E.mapping)||void 0===H?void 0:H.header)||void 0===F?void 0:F[0])?null===(Y=null===(Q=null==E?void 0:E.mapping)||void 0===Q?void 0:Q.header)||void 0===Y?void 0:Y[0]:Ne.selectedVariable}),(null==ke?void 0:ke.format)==s.HEADER_TYPES.DOCUMENT?e.jsx(V,{children:e.jsx(a.InputWithVariables,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Ye||void 0,onBlur:()=>{if(!Fe)return null==R||R(""),void We("PDF name is Required");const e=v.validateInputName(Fe);null==R||R(Fe),We(e?"Please enter a valid PDF name":void 0)},onChange:e=>{We(""),Qe(e.actualValue)},pickerType:n.PickerType.EMBEDDED,noMaxCharCheck:!0,allowMix:!1,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=Fe?Fe:"",variableType:"string"},variablesList:q})}):e.jsx(e.Fragment,{})]}),(null===(W=Ue.bodyVariables)||void 0===W?void 0:W.length)>0&&e.jsx(T.default,{containerStyle:{paddingTop:Ue.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(K=Ue.descriptionComponents)||void 0===K?void 0:K.map(((n,t)=>e.jsx(O.default,{originalVariableList:null!=Te&&Te>-1?Ce.cards[Te]:Ce,type:n.type,descriptionComponent:n.component,showVariableModal:k},t))),(null===(X=null===(G=null!=Te&&Te>-1?null===($=Ce.cards[Te])||void 0===$?void 0:$.buttons:null==Ce?void 0:Ce.buttons)||void 0===G?void 0:G.filter((e=>"URL"===e.type)))||void 0===X?void 0:X.length)>0&&e.jsx(T.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(Z=null===(J=null!=Te&&Te>-1?null===(z=Ce.cards[Te])||void 0===z?void 0:z.buttons:null==Ce?void 0:Ce.buttons)||void 0===J?void 0:J.filter((e=>xe===d.POD.CHATBOT||"URL"===e.type)))||void 0===Z?void 0:Z.map(((n,t)=>{const o=n.buttonVariable===u.STATIC_URL_VARIABLE_NAME;if("URL"===n.type)return e.jsx(y.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==M?void 0:M.CTAoptions,button:n,currentVariableList:null!=Te&&Te>-1?Object.assign({},Ce.cards[Te]):Object.assign({},Ce),updateSelectedURLTemplateBtn:Ke},`${t}_${Te}`)})),xe===d.POD.CHATBOT&&(null===(ne=null===(ee=Me[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)&&(null===(ie=null===(oe=null===(te=Me[0])||void 0===te?void 0:te.component)||void 0===oe?void 0:oe.buttons)||void 0===ie?void 0:ie.length)>0&&e.jsx(m.BackTrackComponent,{backTrackMessage:null===(le=null==Oe?void 0:Oe.backTrackExtra)||void 0===le?void 0:le[0],setBackTrackMessage:null===(ae=null==Oe?void 0:Oe.backTrackExtra)||void 0===ae?void 0:ae[1]}),(null===(re=null===(de=null!=Te&&Te>-1?null===(se=Ce.cards[Te])||void 0===se?void 0:se.buttons:null==Ce?void 0:Ce.buttons)||void 0===de?void 0:de.filter((e=>"QUICK_REPLY"===e.type)))||void 0===re?void 0:re.length)>0&&(xe!==d.POD.CHATBOT?e.jsx(T.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e.jsx(m.BackTrackComponent,{backTrackMessage:null===(ue=null==Oe?void 0:Oe.backTrackExtra)||void 0===ue?void 0:ue[0],setBackTrackMessage:null===(pe=null==Oe?void 0:Oe.backTrackExtra)||void 0===pe?void 0:pe[1]})),null===(me=null===(ve=null!=Te&&Te>-1?null===(ce=Ce.cards[Te])||void 0===ce?void 0:ce.buttons:null==Ce?void 0:Ce.buttons)||void 0===ve?void 0:ve.filter((e=>"QUICK_REPLY"===e.type)))||void 0===me?void 0:me.map(((n,t)=>{if("QUICK_REPLY"===n.type&&xe!==d.POD.CHATBOT)return e.jsx(y.default,{variableListIndex:t,QRBoptions:null==M?void 0:M.QRBoptions,button:n,currentVariableList:null!=Te&&Te>-1?Object.assign({},Ce.cards[Te]):Object.assign({},Ce),updateSelectedQRBTemplateBtn:$e},`${t}_${Te}`)})),xe===d.POD.CHATBOT&&Re&&e.jsx(b.DiscountCodeComponent,{discountCode:null===(be=null==Oe?void 0:Oe.discountCodeExtra)||void 0===be?void 0:be[0],setDiscountCode:null===(ge=null==Oe?void 0:Oe.discountCodeExtra)||void 0===ge?void 0:ge[1]}),null===(je=null!=Te&&Te>-1?null===(he=Ce.cards[Te])||void 0===he?void 0:he.buttons:null==Ce?void 0:Ce.buttons)||void 0===je?void 0:je.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:Ee?e.jsx("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e.jsx(l.Input,{state:"disabled",labelText:null!==(o=n.text)&&void 0!==o?o:"Copy Code",value:null!==(i=n.buttonVariable)&&void 0!==i?i:"",onChangeText:()=>{}})})):e.jsx(C.default,{index:t,variable:{variableName:null!==(a=n.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=n.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=n.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:n.type},t)})}))]}))};
|
|
7
|
+
`;exports.default=i=>{let{template:E,onTemplateChange:B,whatsappSpecificPickerMeta:M,showVariableModal:k,variableListForImage:q,setDiscountCode:I,fileName:D,setFileName:R}=i;var L,U,A,P,w,_,N,S,H,F,W,Q,Y,K,$,G,X,z,J,Z,ee,ne,te,oe,ie,le,ae,se,de,ue,re,pe,ce,ve,me,be,ge,he,je;const fe=E.isCarouselType,{originalVariableList:Ce,pod:xe,extras:Oe,selectedCarouselIndex:Te,isProductCarouselType:ye,disableCopyCode:Ee}=u.useTemplateModalContext(),{descriptionComponents:Ve,urlBtns:Be,qrbBtns:Me,imageComponent:ke,bodyVariables:qe,headerVariables:Ie}=p.getAllDataFromTemplateComponent(E),De=o.useRef(null),[Re,Le]=o.useState(!1),[Ue,Ae]=o.useState(-1===Te?{descriptionComponents:Ve,urlBtns:Be,qrbBtns:Me,imageComponent:ke,bodyVariables:qe,headerVariables:Ie}:{}),{uploadMediaLink:Pe,uploadMediaFiles:we,validateMimeType:_e}=M,Ne=f.useEditWhatsappTemplateMedia({uploadMediaLink:Pe,uploadMediaFiles:we,updateTemplateImageUrl:function(e,n){var o,i,l,a,s,d,u,r;let p;p=null!=Te&&Te>-1?{components:null===(i=null===(o=E.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[Te].components,mapping:null===(a=null===(l=null==E?void 0:E.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Te]}:Object.assign({},E);const c=null===(s=null==p?void 0:p.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==p?void 0:p.components[c])){const t=Object.assign(Object.assign({},p.components[c]),{format:n,example:{header_handle:[e]}}),o=[...p.components];o[c]=t,p=Object.assign(Object.assign({},p),{components:o})}p.mapping&&(p.mapping=Object.assign(Object.assign({},p.mapping),{header:void 0}));if(null!=Te&&Te>-1){const e=t.cloneDeep(E);e.components[1].cards[Te].components=p.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(u=null==e?void 0:e.mapping)||void 0===u?void 0:u.cards.length)>0&&(e.mapping.cards[Te]=null!==(r=p.mapping)&&void 0!==r?r:{}),null==B||B(Object.assign({},e)),He(!0)}else null==B||B(Object.assign({},p))},validateMimeType:_e,mediaComponent:fe?Ue.imageComponent:ke,fileRef:De}),[Se,He]=o.useState(!1),[Fe,We]=o.useState(D),[Qe,Ye]=o.useState();function Ke(e,n,o){var i,l,a,s,d,u,r,p,c,v;const m=null!=Te&&Te>-1?{components:null===(i=Object.assign({},E).components[1].cards)||void 0===i?void 0:i[Te].components,mapping:null===(l=Object.assign({},E).mapping.cards)||void 0===l?void 0:l[Te]}:Object.assign({},E),b=t.cloneDeep(m),g="custom"===n&&"string"==typeof e,h=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Te&&Te>-1&&ye){const n=Object.assign({},E).components.map((e=>{var n;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(n=e.cards)||void 0===n?void 0:n.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var n,t,i;if("BUTTONS"===e.type){const l=null===(n=e.buttons)||void 0===n?void 0:n.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[o])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[h]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),i=null===(s=null===(a=Object.assign({},E).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((n=>{var t;return Object.assign(Object.assign({},n),{buttons:null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.map((n=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),l=t.cloneDeep(E);return l.components=n,l.mapping.cards=i,void(null==B||B(Object.assign({},l)))}const j=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==j&&j>-1){const t=null===(d=null==b?void 0:b.components[j].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===n&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=t[o];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(p=null===(r=null===(u=b.components)||void 0===u?void 0:u[j])||void 0===r?void 0:r.buttons)&&void 0!==p?p:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[j]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[o]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[j]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?Le(!0):(Le(!1),null==I||I(""))}if(null!=Te&&Te>-1){const e=t.cloneDeep(E);e.components[1].cards[Te].components=b.components,e.mapping.cards[Te]=b.mapping,null==B||B(Object.assign({},e))}else null==B||B(b)}function $e(e,n,o){var i,l,a,s,d,u,r;const p=null!=Te&&Te>-1?{components:null===(i=Object.assign({},E).components[1].cards)||void 0===i?void 0:i[Te].components,mapping:null===(l=Object.assign({},E).mapping.cards)||void 0===l?void 0:l[Te]}:Object.assign({},E);if(null!=Te&&Te>-1&&ye){const n=Object.assign({},E).components.map((n=>{var t;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(t=n.cards)||void 0===t?void 0:t.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var t,i,l;if("BUTTONS"===n.type){const a=null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[o])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==n?void 0:n.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},n),{buttons:d})}return n}))})))}):n})),i=t.cloneDeep(E);return i.components=n,void(null==B||B(Object.assign({},i)))}const c=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const n=null===(s=null===(a=null==p?void 0:p.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(n){let t=n[o];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(r=null===(u=null===(d=p.components)||void 0===d?void 0:d[c])||void 0===u?void 0:u.buttons)&&void 0!==r?r:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},p.components[c]),{buttons:i}),a=[...p.components];a[c]=l,p.components=a}}if(null!=Te&&Te>-1){const e=t.cloneDeep(E);e.components[1].cards[Te].components=p.components,null==B||B(Object.assign({},e))}else null==B||B(p)}o.useEffect((()=>{var e,n;if(null===(e=E.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))Le(!0);else{Le(!1);const e=null===(n=null==Oe?void 0:Oe.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[E]),o.useEffect((()=>{var e,n,t,o;if(null!=Te&&Te>-1){const i={components:null===(n=null===(e=E.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Te].components,mapping:null===(o=null===(t=null==E?void 0:E.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Te]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:u,headerVariables:r}=p.getAllDataFromTemplateComponent(i);Ae({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:u,headerVariables:r})}else if(null!=Te&&-1===Te){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=p.getAllDataFromTemplateComponent(E);Ae({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[Te]),o.useEffect((()=>{var e,n,t,o;if(null!=Te&&Te>-1&&Se){const i={components:null===(n=null===(e=E.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Te].components,mapping:null===(o=null===(t=null==E?void 0:E.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Te]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:u,headerVariables:r}=p.getAllDataFromTemplateComponent(i);Ae({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:u,headerVariables:r}),He(!1)}}),[Se]);const Ge=fe?Ue.imageComponent:ke;return Ne.openEditMedia?e.jsx(x.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(g.default,{mediaComponentFormat:null!==(L=Ge.format)&&void 0!==L?L:s.HEADER_TYPES.IMAGE,uploadMedia:Ne.uploadMedia,variableListForImage:q||[],useEditWhatsappTemplateMediaResponse:Ne,setOpenEditMedia:Ne.setOpenEditMedia,openEditMedia:Ne.openEditMedia,editIconRef:Ne.editIconRef,fileRef:De})})):e.jsxs(x.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:ye?"420px":"auto"}},{children:[!!Ue.imageComponent&&!ye&&e.jsxs(j.EditTemplateMediaContainer,{children:[e.jsx(h.default,{imageName:null!==(A=null===(U=null==Ge?void 0:Ge.example)||void 0===U?void 0:U.header_handle)&&void 0!==A?A:[],handleImageChange:Ne.handleImageChange,mediaType:null==Ge?void 0:Ge.format,error:Ne.error,isLoading:Ne.loading,setOpenEditMedia:Ne.setOpenEditMedia,selectedVariable:c.isVariable(null!==(_=null===(w=null===(P=null==Ge?void 0:Ge.example)||void 0===P?void 0:P.header_handle)||void 0===w?void 0:w[0])&&void 0!==_?_:"")?null===(S=null===(N=null==Ge?void 0:Ge.example)||void 0===N?void 0:N.header_handle)||void 0===S?void 0:S[0]:(null===(F=null===(H=null==E?void 0:E.mapping)||void 0===H?void 0:H.header)||void 0===F?void 0:F[0])?null===(Q=null===(W=null==E?void 0:E.mapping)||void 0===W?void 0:W.header)||void 0===Q?void 0:Q[0]:Ne.selectedVariable}),(null==ke?void 0:ke.format)==s.HEADER_TYPES.DOCUMENT?e.jsx(V,{children:e.jsx(a.InputWithVariables,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Qe||void 0,onBlur:()=>{if(!Fe)return null==R||R(""),void Ye("PDF name is Required");const e=v.validateInputName(Fe);null==R||R(Fe),Ye(e?"Please enter a valid PDF name":void 0)},onChange:e=>{var n,t;Ye(""),(null!==(n=null==e?void 0:e.actualValue)&&void 0!==n?n:"").startsWith("{{")&&(null!==(t=null==e?void 0:e.actualValue)&&void 0!==t?t:"").endsWith("}}")?We(Fe+(null==e?void 0:e.actualValue)):We(null==e?void 0:e.actualValue)},pickerType:n.PickerType.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=Fe?Fe:"",variableType:"string"},variablesList:q,showAddButton:xe===d.POD.CHATBOT})}):e.jsx(e.Fragment,{})]}),(null===(Y=Ue.bodyVariables)||void 0===Y?void 0:Y.length)>0&&e.jsx(T.default,{containerStyle:{paddingTop:Ue.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(K=Ue.descriptionComponents)||void 0===K?void 0:K.map(((n,t)=>e.jsx(O.default,{originalVariableList:null!=Te&&Te>-1?Ce.cards[Te]:Ce,type:n.type,descriptionComponent:n.component,showVariableModal:k},t))),(null===(X=null===(G=null!=Te&&Te>-1?null===($=Ce.cards[Te])||void 0===$?void 0:$.buttons:null==Ce?void 0:Ce.buttons)||void 0===G?void 0:G.filter((e=>"URL"===e.type)))||void 0===X?void 0:X.length)>0&&e.jsx(T.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(Z=null===(J=null!=Te&&Te>-1?null===(z=Ce.cards[Te])||void 0===z?void 0:z.buttons:null==Ce?void 0:Ce.buttons)||void 0===J?void 0:J.filter((e=>xe===d.POD.CHATBOT||"URL"===e.type)))||void 0===Z?void 0:Z.map(((n,t)=>{const o=n.buttonVariable===r.STATIC_URL_VARIABLE_NAME;if("URL"===n.type)return e.jsx(y.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==M?void 0:M.CTAoptions,button:n,currentVariableList:null!=Te&&Te>-1?Object.assign({},Ce.cards[Te]):Object.assign({},Ce),updateSelectedURLTemplateBtn:Ke},`${t}_${Te}`)})),xe===d.POD.CHATBOT&&(null===(ne=null===(ee=Me[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)&&(null===(ie=null===(oe=null===(te=Me[0])||void 0===te?void 0:te.component)||void 0===oe?void 0:oe.buttons)||void 0===ie?void 0:ie.length)>0&&e.jsx(m.BackTrackComponent,{backTrackMessage:null===(le=null==Oe?void 0:Oe.backTrackExtra)||void 0===le?void 0:le[0],setBackTrackMessage:null===(ae=null==Oe?void 0:Oe.backTrackExtra)||void 0===ae?void 0:ae[1]}),(null===(ue=null===(de=null!=Te&&Te>-1?null===(se=Ce.cards[Te])||void 0===se?void 0:se.buttons:null==Ce?void 0:Ce.buttons)||void 0===de?void 0:de.filter((e=>"QUICK_REPLY"===e.type)))||void 0===ue?void 0:ue.length)>0&&(xe!==d.POD.CHATBOT?e.jsx(T.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e.jsx(m.BackTrackComponent,{backTrackMessage:null===(re=null==Oe?void 0:Oe.backTrackExtra)||void 0===re?void 0:re[0],setBackTrackMessage:null===(pe=null==Oe?void 0:Oe.backTrackExtra)||void 0===pe?void 0:pe[1]})),null===(me=null===(ve=null!=Te&&Te>-1?null===(ce=Ce.cards[Te])||void 0===ce?void 0:ce.buttons:null==Ce?void 0:Ce.buttons)||void 0===ve?void 0:ve.filter((e=>"QUICK_REPLY"===e.type)))||void 0===me?void 0:me.map(((n,t)=>{if("QUICK_REPLY"===n.type&&xe!==d.POD.CHATBOT)return e.jsx(y.default,{variableListIndex:t,QRBoptions:null==M?void 0:M.QRBoptions,button:n,currentVariableList:null!=Te&&Te>-1?Object.assign({},Ce.cards[Te]):Object.assign({},Ce),updateSelectedQRBTemplateBtn:$e},`${t}_${Te}`)})),xe===d.POD.CHATBOT&&Re&&e.jsx(b.DiscountCodeComponent,{discountCode:null===(be=null==Oe?void 0:Oe.discountCodeExtra)||void 0===be?void 0:be[0],setDiscountCode:null===(ge=null==Oe?void 0:Oe.discountCodeExtra)||void 0===ge?void 0:ge[1]}),null===(je=null!=Te&&Te>-1?null===(he=Ce.cards[Te])||void 0===he?void 0:he.buttons:null==Ce?void 0:Ce.buttons)||void 0===je?void 0:je.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:Ee?e.jsx("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e.jsx(l.Input,{state:"disabled",labelText:null!==(o=n.text)&&void 0!==o?o:"Copy Code",value:null!==(i=n.buttonVariable)&&void 0!==i?i:"",onChangeText:()=>{}})})):e.jsx(C.default,{index:t,variable:{variableName:null!==(a=n.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=n.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=n.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:n.type},t)})}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.validateInputName=e
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.validateInputName=e=>{var t;const s=/[^a-zA-Z0-9._ {}]/.test(e),r=null===(t=e.match(/\{\{[a-zA-Z0-9._]+\}\}/g))||void 0===t?void 0:t.every((e=>e.startsWith("{{")&&e.endsWith("}}")));return!!(s||e.includes("{{")&&!r)};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o,Fragment as n}from"react/jsx-runtime";import"../../curtain/CurtainHelper.js";import{PickerType as t}from"../../variable-picker-v3/model.js";import{cloneDeep as i}from"lodash";import{useRef as l,useState as a,useEffect as s}from"react";import d from"styled-components";import{Input as r}from"../../input/Input.js";import{InputWithVariables as p}from"../../input-with-vars/InputWithVariables.js";import{HEADER_TYPES as u}from"../../template-preview/models/TemplateMeta.js";import{POD as c}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as m}from"../context/templateModalContext.js";import{STATIC_URL_VARIABLE_NAME as v}from"../utils/constants.js";import{getAllDataFromTemplateComponent as b}from"../utils/getDataFromTemplateComponent.js";import{isVariable as g}from"../utils/validateIsUrl.js";import{validateInputName as f}from"../utils/validateName.js";import{BackTrackComponent as h}from"./BackTrackComponent.js";import{DiscountCodeComponent as j}from"./DiscountCodeComponent.js";import O from"./EditMediaModal.js";import C from"./EditMediaV2.js";import{EditTemplateMediaContainer as T}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as x}from"./useEditWhtasappTemplateMedia.js";import y from"./VariableConnector.js";import{Container as E}from"./VariableConnectorsPanel.js";import V from"./VariableConnectorWhatsApp.js";import B from"./VariableEditorHeader.js";import M from"./WhatsAppTemplateCardButtonV2.js";const k=d=>{let{template:k,onTemplateChange:L,whatsappSpecificPickerMeta:R,showVariableModal:U,variableListForImage:w,setDiscountCode:N,fileName:P,setFileName:H}=d;var A,D,_,S,F,Q,q,Y,K,W,$,G,X,z,J,Z,ee,oe,ne,te,ie,le,ae,se,de,re,pe,ue,ce,me,ve,be,ge,fe,he,je,Oe,Ce,Te;const xe=k.isCarouselType,{originalVariableList:ye,pod:Ee,extras:Ve,selectedCarouselIndex:Be,isProductCarouselType:Me,disableCopyCode:ke}=m(),{descriptionComponents:Ie,urlBtns:Le,qrbBtns:Re,imageComponent:Ue,bodyVariables:we,headerVariables:Ne}=b(k),Pe=l(null),[He,Ae]=a(!1),[De,_e]=a(-1===Be?{descriptionComponents:Ie,urlBtns:Le,qrbBtns:Re,imageComponent:Ue,bodyVariables:we,headerVariables:Ne}:{}),{uploadMediaLink:Se,uploadMediaFiles:Fe,validateMimeType:Qe}=R,qe=x({uploadMediaLink:Se,uploadMediaFiles:Fe,updateTemplateImageUrl:function(e,o){var n,t,l,a,s,d,r,p;let u;u=null!=Be&&Be>-1?{components:null===(t=null===(n=k.components[1])||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be].components,mapping:null===(a=null===(l=null==k?void 0:k.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Be]}:Object.assign({},k);const c=null===(s=null==u?void 0:u.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==u?void 0:u.components[c])){const n=Object.assign(Object.assign({},u.components[c]),{format:o,example:{header_handle:[e]}}),t=[...u.components];t[c]=n,u=Object.assign(Object.assign({},u),{components:t})}u.mapping&&(u.mapping=Object.assign(Object.assign({},u.mapping),{header:void 0}));if(null!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].components=u.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==e?void 0:e.mapping)||void 0===r?void 0:r.cards.length)>0&&(e.mapping.cards[Be]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==L||L(Object.assign({},e)),Ke(!0)}else null==L||L(Object.assign({},u))},validateMimeType:Qe,mediaComponent:xe?De.imageComponent:Ue,fileRef:Pe}),[Ye,Ke]=a(!1),[We,$e]=a(P),[Ge,Xe]=a();function ze(e,o,n){var t,l,a,s,d,r,p,u,c,m;const v=null!=Be&&Be>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Be].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Be]}:Object.assign({},k),b=i(v),g="custom"===o&&"string"==typeof e,f=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Be&&Be>-1&&Me){const o=Object.assign({},k).components.map((e=>{var o;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(o=e.cards)||void 0===o?void 0:o.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var o,t,i;if("BUTTONS"===e.type){const l=null===(o=e.buttons)||void 0===o?void 0:o.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[n])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[f]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),t=null===(s=null===(a=Object.assign({},k).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((o=>{var n;return Object.assign(Object.assign({},o),{buttons:null===(n=null==o?void 0:o.buttons)||void 0===n?void 0:n.map((o=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),l=i(k);return l.components=o,l.mapping.cards=t,void(null==L||L(Object.assign({},l)))}const h=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==h&&h>-1){const t=null===(d=null==b?void 0:b.components[h].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===o&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=t[n];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(u=null===(p=null===(r=b.components)||void 0===r?void 0:r[h])||void 0===p?void 0:p.buttons)&&void 0!==u?u:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[h]),{buttons:s}),m=null===(c=b.mapping)||void 0===c?void 0:c.buttons;m&&m.length>0&&(m[n]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const v=Object.assign(Object.assign({},b.mapping),{buttons:m});b.mapping=v;const g=[...b.components];g[h]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(m=e.placeHolder)||void 0===m?void 0:m.slice(2,-2))?Ae(!0):(Ae(!1),null==N||N(""))}if(null!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].components=b.components,e.mapping.cards[Be]=b.mapping,null==L||L(Object.assign({},e))}else null==L||L(b)}function Je(e,o,n){var t,l,a,s,d,r,p;const u=null!=Be&&Be>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Be].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Be]}:Object.assign({},k);if(null!=Be&&Be>-1&&Me){const o=Object.assign({},k).components.map((o=>{var t;return"CAROUSEL"===o.type?Object.assign(Object.assign({},o),{cards:null===(t=o.cards)||void 0===t?void 0:t.map((o=>Object.assign(Object.assign({},o),{components:o.components.map((o=>{var t,i,l;if("BUTTONS"===o.type){const a=null===(t=null==o?void 0:o.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[n])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==o?void 0:o.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},o),{buttons:d})}return o}))})))}):o})),t=i(k);return t.components=o,void(null==L||L(Object.assign({},t)))}const c=null==u?void 0:u.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const o=null===(s=null===(a=null==u?void 0:u.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(o){let t=o[n];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(p=null===(r=null===(d=u.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==p?p:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},u.components[c]),{buttons:i}),a=[...u.components];a[c]=l,u.components=a}}if(null!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].components=u.components,null==L||L(Object.assign({},e))}else null==L||L(u)}s((()=>{var e,o;if(null===(e=k.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))Ae(!0);else{Ae(!1);const e=null===(o=null==Ve?void 0:Ve.discountCodeExtra)||void 0===o?void 0:o[1];null==e||e("")}}),[k]),s((()=>{var e,o,n,t;if(null!=Be&&Be>-1){const i={components:null===(o=null===(e=k.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Be].components,mapping:null===(t=null===(n=null==k?void 0:k.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);_e({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Be&&-1===Be){const{descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=b(k);_e({descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Be]),s((()=>{var e,o,n,t;if(null!=Be&&Be>-1&&Ye){const i={components:null===(o=null===(e=k.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Be].components,mapping:null===(t=null===(n=null==k?void 0:k.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);_e({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),Ke(!1)}}),[Ye]);const Ze=xe?De.imageComponent:Ue;return qe.openEditMedia?e(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e(O,{mediaComponentFormat:null!==(A=Ze.format)&&void 0!==A?A:u.IMAGE,uploadMedia:qe.uploadMedia,variableListForImage:w||[],useEditWhatsappTemplateMediaResponse:qe,setOpenEditMedia:qe.setOpenEditMedia,openEditMedia:qe.openEditMedia,editIconRef:qe.editIconRef,fileRef:Pe})})):o(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Me?"420px":"auto"}},{children:[!!De.imageComponent&&!Me&&o(T,{children:[e(C,{imageName:null!==(_=null===(D=null==Ze?void 0:Ze.example)||void 0===D?void 0:D.header_handle)&&void 0!==_?_:[],handleImageChange:qe.handleImageChange,mediaType:null==Ze?void 0:Ze.format,error:qe.error,isLoading:qe.loading,setOpenEditMedia:qe.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(F=null===(S=null==Ze?void 0:Ze.example)||void 0===S?void 0:S.header_handle)||void 0===F?void 0:F[0])&&void 0!==Q?Q:"")?null===(Y=null===(q=null==Ze?void 0:Ze.example)||void 0===q?void 0:q.header_handle)||void 0===Y?void 0:Y[0]:(null===(W=null===(K=null==k?void 0:k.mapping)||void 0===K?void 0:K.header)||void 0===W?void 0:W[0])?null===(G=null===($=null==k?void 0:k.mapping)||void 0===$?void 0:$.header)||void 0===G?void 0:G[0]:qe.selectedVariable}),(null==Ue?void 0:Ue.format)==u.DOCUMENT?e(I,{children:e(p,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Ge||void 0,onBlur:()=>{if(!We)return null==H||H(""),void Xe("PDF name is Required");const e=f(We);null==H||H(We),Xe(e?"Please enter a valid PDF name":void 0)},onChange:e=>{Xe(""),$e(e.actualValue)},pickerType:t.EMBEDDED,noMaxCharCheck:!0,allowMix:!1,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=We?We:"",variableType:"string"},variablesList:w})}):e(n,{})]}),(null===(X=De.bodyVariables)||void 0===X?void 0:X.length)>0&&e(B,{containerStyle:{paddingTop:De.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(z=De.descriptionComponents)||void 0===z?void 0:z.map(((o,n)=>e(V,{originalVariableList:null!=Be&&Be>-1?ye.cards[Be]:ye,type:o.type,descriptionComponent:o.component,showVariableModal:U},n))),(null===(ee=null===(Z=null!=Be&&Be>-1?null===(J=ye.cards[Be])||void 0===J?void 0:J.buttons:null==ye?void 0:ye.buttons)||void 0===Z?void 0:Z.filter((e=>"URL"===e.type)))||void 0===ee?void 0:ee.length)>0&&e(B,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(te=null===(ne=null!=Be&&Be>-1?null===(oe=ye.cards[Be])||void 0===oe?void 0:oe.buttons:null==ye?void 0:ye.buttons)||void 0===ne?void 0:ne.filter((e=>Ee===c.CHATBOT||"URL"===e.type)))||void 0===te?void 0:te.map(((o,n)=>{const t=o.buttonVariable===v;if("URL"===o.type)return e(M,{variableListIndex:n,disableEdit:t,CTAoptions:null==R?void 0:R.CTAoptions,button:o,currentVariableList:null!=Be&&Be>-1?Object.assign({},ye.cards[Be]):Object.assign({},ye),updateSelectedURLTemplateBtn:ze},`${n}_${Be}`)})),Ee===c.CHATBOT&&(null===(le=null===(ie=Re[0])||void 0===ie?void 0:ie.component)||void 0===le?void 0:le.buttons)&&(null===(de=null===(se=null===(ae=Re[0])||void 0===ae?void 0:ae.component)||void 0===se?void 0:se.buttons)||void 0===de?void 0:de.length)>0&&e(h,{backTrackMessage:null===(re=null==Ve?void 0:Ve.backTrackExtra)||void 0===re?void 0:re[0],setBackTrackMessage:null===(pe=null==Ve?void 0:Ve.backTrackExtra)||void 0===pe?void 0:pe[1]}),(null===(me=null===(ce=null!=Be&&Be>-1?null===(ue=ye.cards[Be])||void 0===ue?void 0:ue.buttons:null==ye?void 0:ye.buttons)||void 0===ce?void 0:ce.filter((e=>"QUICK_REPLY"===e.type)))||void 0===me?void 0:me.length)>0&&(Ee!==c.CHATBOT?e(B,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e(h,{backTrackMessage:null===(ve=null==Ve?void 0:Ve.backTrackExtra)||void 0===ve?void 0:ve[0],setBackTrackMessage:null===(be=null==Ve?void 0:Ve.backTrackExtra)||void 0===be?void 0:be[1]})),null===(he=null===(fe=null!=Be&&Be>-1?null===(ge=ye.cards[Be])||void 0===ge?void 0:ge.buttons:null==ye?void 0:ye.buttons)||void 0===fe?void 0:fe.filter((e=>"QUICK_REPLY"===e.type)))||void 0===he?void 0:he.map(((o,n)=>{if("QUICK_REPLY"===o.type&&Ee!==c.CHATBOT)return e(M,{variableListIndex:n,QRBoptions:null==R?void 0:R.QRBoptions,button:o,currentVariableList:null!=Be&&Be>-1?Object.assign({},ye.cards[Be]):Object.assign({},ye),updateSelectedQRBTemplateBtn:Je},`${n}_${Be}`)})),Ee===c.CHATBOT&&He&&e(j,{discountCode:null===(je=null==Ve?void 0:Ve.discountCodeExtra)||void 0===je?void 0:je[0],setDiscountCode:null===(Oe=null==Ve?void 0:Ve.discountCodeExtra)||void 0===Oe?void 0:Oe[1]}),null===(Te=null!=Be&&Be>-1?null===(Ce=ye.cards[Be])||void 0===Ce?void 0:Ce.buttons:null==ye?void 0:ye.buttons)||void 0===Te?void 0:Te.map(((o,t)=>{var i,l,a,s,d;if("COPY_CODE"===o.type)return e(n,{children:ke?e("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e(r,{state:"disabled",labelText:null!==(i=o.text)&&void 0!==i?i:"Copy Code",value:null!==(l=o.buttonVariable)&&void 0!==l?l:"",onChangeText:()=>{}})})):e(y,{index:t,variable:{variableName:null!==(a=o.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=o.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=o.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:o.type},t)})}))]}))},I=d.div`
|
|
1
|
+
import{jsx as o,jsxs as e,Fragment as n}from"react/jsx-runtime";import"../../curtain/CurtainHelper.js";import{PickerType as t}from"../../variable-picker-v3/model.js";import{cloneDeep as i}from"lodash";import{useRef as l,useState as a,useEffect as s}from"react";import d from"styled-components";import{Input as r}from"../../input/Input.js";import{InputWithVariables as p}from"../../input-with-vars/InputWithVariables.js";import{HEADER_TYPES as u}from"../../template-preview/models/TemplateMeta.js";import{POD as c}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as v}from"../context/templateModalContext.js";import{STATIC_URL_VARIABLE_NAME as m}from"../utils/constants.js";import{getAllDataFromTemplateComponent as b}from"../utils/getDataFromTemplateComponent.js";import{isVariable as g}from"../utils/validateIsUrl.js";import{validateInputName as f}from"../utils/validateName.js";import{BackTrackComponent as h}from"./BackTrackComponent.js";import{DiscountCodeComponent as j}from"./DiscountCodeComponent.js";import O from"./EditMediaModal.js";import C from"./EditMediaV2.js";import{EditTemplateMediaContainer as T}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as x}from"./useEditWhtasappTemplateMedia.js";import y from"./VariableConnector.js";import{Container as V}from"./VariableConnectorsPanel.js";import E from"./VariableConnectorWhatsApp.js";import B from"./VariableEditorHeader.js";import M from"./WhatsAppTemplateCardButtonV2.js";const k=d=>{let{template:k,onTemplateChange:L,whatsappSpecificPickerMeta:R,showVariableModal:U,variableListForImage:w,setDiscountCode:N,fileName:A,setFileName:H}=d;var P,D,_,S,F,Q,q,W,Y,K,$,G,X,z,J,Z,oo,eo,no,to,io,lo,ao,so,ro,po,uo,co,vo,mo,bo,go,fo,ho,jo,Oo,Co,To,xo;const yo=k.isCarouselType,{originalVariableList:Vo,pod:Eo,extras:Bo,selectedCarouselIndex:Mo,isProductCarouselType:ko,disableCopyCode:Io}=v(),{descriptionComponents:Lo,urlBtns:Ro,qrbBtns:Uo,imageComponent:wo,bodyVariables:No,headerVariables:Ao}=b(k),Ho=l(null),[Po,Do]=a(!1),[_o,So]=a(-1===Mo?{descriptionComponents:Lo,urlBtns:Ro,qrbBtns:Uo,imageComponent:wo,bodyVariables:No,headerVariables:Ao}:{}),{uploadMediaLink:Fo,uploadMediaFiles:Qo,validateMimeType:qo}=R,Wo=x({uploadMediaLink:Fo,uploadMediaFiles:Qo,updateTemplateImageUrl:function(o,e){var n,t,l,a,s,d,r,p;let u;u=null!=Mo&&Mo>-1?{components:null===(t=null===(n=k.components[1])||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Mo].components,mapping:null===(a=null===(l=null==k?void 0:k.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Mo]}:Object.assign({},k);const c=null===(s=null==u?void 0:u.components)||void 0===s?void 0:s.findIndex((o=>{if("HEADER"===o.type&&"NONE"!==o.format&&"TEXT"!==o.format)return!0}));if(void 0!==c&&c>-1&&(null==u?void 0:u.components[c])){const n=Object.assign(Object.assign({},u.components[c]),{format:e,example:{header_handle:[o]}}),t=[...u.components];t[c]=n,u=Object.assign(Object.assign({},u),{components:t})}u.mapping&&(u.mapping=Object.assign(Object.assign({},u.mapping),{header:void 0}));if(null!=Mo&&Mo>-1){const o=i(k);o.components[1].cards[Mo].components=u.components,(null===(d=null==o?void 0:o.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==o?void 0:o.mapping)||void 0===r?void 0:r.cards.length)>0&&(o.mapping.cards[Mo]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==L||L(Object.assign({},o)),Ko(!0)}else null==L||L(Object.assign({},u))},validateMimeType:qo,mediaComponent:yo?_o.imageComponent:wo,fileRef:Ho}),[Yo,Ko]=a(!1),[$o,Go]=a(A),[Xo,zo]=a();function Jo(o,e,n){var t,l,a,s,d,r,p,u,c,v;const m=null!=Mo&&Mo>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Mo].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Mo]}:Object.assign({},k),b=i(m),g="custom"===e&&"string"==typeof o,f=g?o:"string"!=typeof o?o.defaultValue?o.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Mo&&Mo>-1&&ko){const e=Object.assign({},k).components.map((o=>{var e;return"CAROUSEL"===o.type?Object.assign(Object.assign({},o),{cards:null===(e=o.cards)||void 0===e?void 0:e.map((o=>Object.assign(Object.assign({},o),{components:o.components.map((o=>{var e,t,i;if("BUTTONS"===o.type){const l=null===(e=o.buttons)||void 0===e?void 0:e.filter((o=>"URL"===o.type));let a=null!==(t=null==l?void 0:l[n])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[f]});const s=null===(i=o.buttons)||void 0===i?void 0:i.map((o=>"URL"===o.type&&(null==o?void 0:o.text)===(null==a?void 0:a.text)?a:o));return Object.assign(Object.assign({},o),{buttons:s})}return o}))})))}):o})),t=null===(s=null===(a=Object.assign({},k).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((e=>{var n;return Object.assign(Object.assign({},e),{buttons:null===(n=null==e?void 0:e.buttons)||void 0===n?void 0:n.map((e=>g?"((customBtnPlaceholder))":"string"!=typeof o?o.placeHolder:""))})})),l=i(k);return l.components=e,l.mapping.cards=t,void(null==L||L(Object.assign({},l)))}const h=null==b?void 0:b.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==h&&h>-1){const t=null===(d=null==b?void 0:b.components[h].buttons)||void 0===d?void 0:d.filter((o=>"URL"===o.type));if((null==t?void 0:t.length)>0){const i="custom"===e&&"string"==typeof o,l=i?o:"string"!=typeof o&&o.defaultValue?o.defaultValue:"https://d.bik.ai/";let a=t[n];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(u=null===(p=null===(r=b.components)||void 0===r?void 0:r[h])||void 0===p?void 0:p.buttons)&&void 0!==u?u:[]].map((o=>"URL"===o.type&&(null==o?void 0:o.text)===(null==a?void 0:a.text)?a:o)),d=Object.assign(Object.assign({},b.components[h]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[n]=i?"((customBtnPlaceholder))":"string"!=typeof o?o.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[h]=d,b.components=g}}if("string"!=typeof o){"checkout.checkoutUrl"===(null===(v=o.placeHolder)||void 0===v?void 0:v.slice(2,-2))?Do(!0):(Do(!1),null==N||N(""))}if(null!=Mo&&Mo>-1){const o=i(k);o.components[1].cards[Mo].components=b.components,o.mapping.cards[Mo]=b.mapping,null==L||L(Object.assign({},o))}else null==L||L(b)}function Zo(o,e,n){var t,l,a,s,d,r,p;const u=null!=Mo&&Mo>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Mo].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Mo]}:Object.assign({},k);if(null!=Mo&&Mo>-1&&ko){const e=Object.assign({},k).components.map((e=>{var t;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(t=e.cards)||void 0===t?void 0:t.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var t,i,l;if("BUTTONS"===e.type){const a=null===(t=null==e?void 0:e.buttons)||void 0===t?void 0:t.filter((o=>"QUICK_REPLY"===o.type));let s=null!==(i=null==a?void 0:a[n])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:o.flowId,flowName:o.flowName});const d=null===(l=null==e?void 0:e.buttons)||void 0===l?void 0:l.map((o=>"QUICK_REPLY"===o.type&&(null==o?void 0:o.text)===(null==s?void 0:s.text)?s:o));return Object.assign(Object.assign({},e),{buttons:d})}return e}))})))}):e})),t=i(k);return t.components=e,void(null==L||L(Object.assign({},t)))}const c=null==u?void 0:u.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==c&&c>-1){const e=null===(s=null===(a=null==u?void 0:u.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((o=>"QUICK_REPLY"===o.type));if(e){let t=e[n];t=Object.assign(Object.assign({},t),{flowId:o.flowId,flowName:o.flowName});const i=[...null!==(p=null===(r=null===(d=u.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==p?p:[]].map((o=>"QUICK_REPLY"===o.type&&(null==o?void 0:o.text)===(null==t?void 0:t.text)?t:o)),l=Object.assign(Object.assign({},u.components[c]),{buttons:i}),a=[...u.components];a[c]=l,u.components=a}}if(null!=Mo&&Mo>-1){const o=i(k);o.components[1].cards[Mo].components=u.components,null==L||L(Object.assign({},o))}else null==L||L(u)}s((()=>{var o,e;if(null===(o=k.mapping.buttons)||void 0===o?void 0:o.find((o=>"checkout.checkoutUrl"===o.slice(2,-2))))Do(!0);else{Do(!1);const o=null===(e=null==Bo?void 0:Bo.discountCodeExtra)||void 0===e?void 0:e[1];null==o||o("")}}),[k]),s((()=>{var o,e,n,t;if(null!=Mo&&Mo>-1){const i={components:null===(e=null===(o=k.components[1])||void 0===o?void 0:o.cards)||void 0===e?void 0:e[Mo].components,mapping:null===(t=null===(n=null==k?void 0:k.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Mo]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);So({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Mo&&-1===Mo){const{descriptionComponents:o,urlBtns:e,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=b(k);So({descriptionComponents:o,urlBtns:e,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Mo]),s((()=>{var o,e,n,t;if(null!=Mo&&Mo>-1&&Yo){const i={components:null===(e=null===(o=k.components[1])||void 0===o?void 0:o.cards)||void 0===e?void 0:e[Mo].components,mapping:null===(t=null===(n=null==k?void 0:k.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Mo]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);So({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),Ko(!1)}}),[Yo]);const oe=yo?_o.imageComponent:wo;return Wo.openEditMedia?o(V,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:o(O,{mediaComponentFormat:null!==(P=oe.format)&&void 0!==P?P:u.IMAGE,uploadMedia:Wo.uploadMedia,variableListForImage:w||[],useEditWhatsappTemplateMediaResponse:Wo,setOpenEditMedia:Wo.setOpenEditMedia,openEditMedia:Wo.openEditMedia,editIconRef:Wo.editIconRef,fileRef:Ho})})):e(V,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:ko?"420px":"auto"}},{children:[!!_o.imageComponent&&!ko&&e(T,{children:[o(C,{imageName:null!==(_=null===(D=null==oe?void 0:oe.example)||void 0===D?void 0:D.header_handle)&&void 0!==_?_:[],handleImageChange:Wo.handleImageChange,mediaType:null==oe?void 0:oe.format,error:Wo.error,isLoading:Wo.loading,setOpenEditMedia:Wo.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(F=null===(S=null==oe?void 0:oe.example)||void 0===S?void 0:S.header_handle)||void 0===F?void 0:F[0])&&void 0!==Q?Q:"")?null===(W=null===(q=null==oe?void 0:oe.example)||void 0===q?void 0:q.header_handle)||void 0===W?void 0:W[0]:(null===(K=null===(Y=null==k?void 0:k.mapping)||void 0===Y?void 0:Y.header)||void 0===K?void 0:K[0])?null===(G=null===($=null==k?void 0:k.mapping)||void 0===$?void 0:$.header)||void 0===G?void 0:G[0]:Wo.selectedVariable}),(null==wo?void 0:wo.format)==u.DOCUMENT?o(I,{children:o(p,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Xo||void 0,onBlur:()=>{if(!$o)return null==H||H(""),void zo("PDF name is Required");const o=f($o);null==H||H($o),zo(o?"Please enter a valid PDF name":void 0)},onChange:o=>{var e,n;zo(""),(null!==(e=null==o?void 0:o.actualValue)&&void 0!==e?e:"").startsWith("{{")&&(null!==(n=null==o?void 0:o.actualValue)&&void 0!==n?n:"").endsWith("}}")?Go($o+(null==o?void 0:o.actualValue)):Go(null==o?void 0:o.actualValue)},pickerType:t.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=$o?$o:"",variableType:"string"},variablesList:w,showAddButton:Eo===c.CHATBOT})}):o(n,{})]}),(null===(X=_o.bodyVariables)||void 0===X?void 0:X.length)>0&&o(B,{containerStyle:{paddingTop:_o.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(z=_o.descriptionComponents)||void 0===z?void 0:z.map(((e,n)=>o(E,{originalVariableList:null!=Mo&&Mo>-1?Vo.cards[Mo]:Vo,type:e.type,descriptionComponent:e.component,showVariableModal:U},n))),(null===(oo=null===(Z=null!=Mo&&Mo>-1?null===(J=Vo.cards[Mo])||void 0===J?void 0:J.buttons:null==Vo?void 0:Vo.buttons)||void 0===Z?void 0:Z.filter((o=>"URL"===o.type)))||void 0===oo?void 0:oo.length)>0&&o(B,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(to=null===(no=null!=Mo&&Mo>-1?null===(eo=Vo.cards[Mo])||void 0===eo?void 0:eo.buttons:null==Vo?void 0:Vo.buttons)||void 0===no?void 0:no.filter((o=>Eo===c.CHATBOT||"URL"===o.type)))||void 0===to?void 0:to.map(((e,n)=>{const t=e.buttonVariable===m;if("URL"===e.type)return o(M,{variableListIndex:n,disableEdit:t,CTAoptions:null==R?void 0:R.CTAoptions,button:e,currentVariableList:null!=Mo&&Mo>-1?Object.assign({},Vo.cards[Mo]):Object.assign({},Vo),updateSelectedURLTemplateBtn:Jo},`${n}_${Mo}`)})),Eo===c.CHATBOT&&(null===(lo=null===(io=Uo[0])||void 0===io?void 0:io.component)||void 0===lo?void 0:lo.buttons)&&(null===(ro=null===(so=null===(ao=Uo[0])||void 0===ao?void 0:ao.component)||void 0===so?void 0:so.buttons)||void 0===ro?void 0:ro.length)>0&&o(h,{backTrackMessage:null===(po=null==Bo?void 0:Bo.backTrackExtra)||void 0===po?void 0:po[0],setBackTrackMessage:null===(uo=null==Bo?void 0:Bo.backTrackExtra)||void 0===uo?void 0:uo[1]}),(null===(mo=null===(vo=null!=Mo&&Mo>-1?null===(co=Vo.cards[Mo])||void 0===co?void 0:co.buttons:null==Vo?void 0:Vo.buttons)||void 0===vo?void 0:vo.filter((o=>"QUICK_REPLY"===o.type)))||void 0===mo?void 0:mo.length)>0&&(Eo!==c.CHATBOT?o(B,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):o(h,{backTrackMessage:null===(bo=null==Bo?void 0:Bo.backTrackExtra)||void 0===bo?void 0:bo[0],setBackTrackMessage:null===(go=null==Bo?void 0:Bo.backTrackExtra)||void 0===go?void 0:go[1]})),null===(jo=null===(ho=null!=Mo&&Mo>-1?null===(fo=Vo.cards[Mo])||void 0===fo?void 0:fo.buttons:null==Vo?void 0:Vo.buttons)||void 0===ho?void 0:ho.filter((o=>"QUICK_REPLY"===o.type)))||void 0===jo?void 0:jo.map(((e,n)=>{if("QUICK_REPLY"===e.type&&Eo!==c.CHATBOT)return o(M,{variableListIndex:n,QRBoptions:null==R?void 0:R.QRBoptions,button:e,currentVariableList:null!=Mo&&Mo>-1?Object.assign({},Vo.cards[Mo]):Object.assign({},Vo),updateSelectedQRBTemplateBtn:Zo},`${n}_${Mo}`)})),Eo===c.CHATBOT&&Po&&o(j,{discountCode:null===(Oo=null==Bo?void 0:Bo.discountCodeExtra)||void 0===Oo?void 0:Oo[0],setDiscountCode:null===(Co=null==Bo?void 0:Bo.discountCodeExtra)||void 0===Co?void 0:Co[1]}),null===(xo=null!=Mo&&Mo>-1?null===(To=Vo.cards[Mo])||void 0===To?void 0:To.buttons:null==Vo?void 0:Vo.buttons)||void 0===xo?void 0:xo.map(((e,t)=>{var i,l,a,s,d;if("COPY_CODE"===e.type)return o(n,{children:Io?o("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:o(r,{state:"disabled",labelText:null!==(i=e.text)&&void 0!==i?i:"Copy Code",value:null!==(l=e.buttonVariable)&&void 0!==l?l:"",onChangeText:()=>{}})})):o(y,{index:t,variable:{variableName:null!==(a=e.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=e.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=e.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:e.type},t)})}))]}))},I=d.div`
|
|
2
2
|
padding-top: 24px;
|
|
3
3
|
padding-left: 10px;
|
|
4
4
|
padding-right: 10px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=t
|
|
1
|
+
const t=t=>{var e;const s=/[^a-zA-Z0-9._ {}]/.test(t),n=null===(e=t.match(/\{\{[a-zA-Z0-9._]+\}\}/g))||void 0===e?void 0:e.every((t=>t.startsWith("{{")&&t.endsWith("}}")));return!!(s||t.includes("{{")&&!n)};export{t as validateInputName};
|