@bikdotai/bik-component-library 0.0.612-beta-vsp.12 → 0.0.612-beta-vsp.14

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.
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -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"),r=require("../context/templateModalContext.js"),u=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"),f=require("./EditMediaV2.style.js"),j=require("./useEditWhtasappTemplateMedia.js"),C=require("./VariableConnector.js"),T=require("./VariableConnectorsPanel.js"),O=require("./VariableConnectorWhatsApp.js"),x=require("./VariableEditorHeader.js"),E=require("./WhatsAppTemplateCardButtonV2.js");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const V=y(i).default.div`
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"),r=require("../context/templateModalContext.js"),u=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"),f=require("./EditMediaV2.style.js"),j=require("./useEditWhtasappTemplateMedia.js"),T=require("./VariableConnector.js"),C=require("./VariableConnectorsPanel.js"),O=require("./VariableConnectorWhatsApp.js"),x=require("./VariableEditorHeader.js"),E=require("./WhatsAppTemplateCardButtonV2.js");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const B=y(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:y,onTemplateChange:B,whatsappSpecificPickerMeta:M,showVariableModal:k,variableListForImage:D,setDiscountCode:I,fileName:q,setFileName:R}=i;var L,P,A,U,w,H,N,_,S,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,fe;const je=y.isCarouselType,{originalVariableList:Ce,pod:Te,extras:Oe,selectedCarouselIndex:xe,isProductCarouselType:Ee,disableCopyCode:ye,isError:Ve}=r.useTemplateModalContext(),{descriptionComponents:Be,urlBtns:Me,qrbBtns:ke,imageComponent:De,bodyVariables:Ie,headerVariables:qe}=p.getAllDataFromTemplateComponent(y),Re=o.useRef(null),[Le,Pe]=o.useState(!1),[Ae,Ue]=o.useState(-1===xe?{descriptionComponents:Be,urlBtns:Me,qrbBtns:ke,imageComponent:De,bodyVariables:Ie,headerVariables:qe}:{}),{uploadMediaLink:we,uploadMediaFiles:He,validateMimeType:Ne}=M,_e=j.useEditWhatsappTemplateMedia({uploadMediaLink:we,uploadMediaFiles:He,updateTemplateImageUrl:function(e,n){var o,i,l,a,s,d,r,u;let p;p=null!=xe&&xe>-1?{components:null===(i=null===(o=y.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[xe].components,mapping:null===(a=null===(l=null==y?void 0:y.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[xe]}:Object.assign({},y);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!=xe&&xe>-1){const e=t.cloneDeep(y);e.components[1].cards[xe].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[xe]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==B||B(Object.assign({},e)),Fe(!0)}else null==B||B(Object.assign({},p))},validateMimeType:Ne,mediaComponent:je?Ae.imageComponent:De,fileRef:Re}),[Se,Fe]=o.useState(!1),[Qe,Ye]=o.useState(q),[We,Ke]=o.useState();function $e(e,n,o){var i,l,a,s,d,r,u,p,c,v;const m=null!=xe&&xe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[xe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[xe]}:Object.assign({},y),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!=xe&&xe>-1&&Ee){const n=Object.assign({},y).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({},y).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(y);return l.components=n,l.mapping.cards=i,void(null==B||B(Object.assign({},l)))}const f=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==f&&f>-1){const t=null===(d=null==b?void 0:b.components[f].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[f])||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[f]),{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[f]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?Pe(!0):(Pe(!1),null==I||I(""))}if(null!=xe&&xe>-1){const e=t.cloneDeep(y);e.components[1].cards[xe].components=b.components,e.mapping.cards[xe]=b.mapping,null==B||B(Object.assign({},e))}else null==B||B(b)}function Ge(e,n,o){var i,l,a,s,d,r,u;const p=null!=xe&&xe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[xe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[xe]}:Object.assign({},y);if(null!=xe&&xe>-1&&Ee){const n=Object.assign({},y).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(y);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!=xe&&xe>-1){const e=t.cloneDeep(y);e.components[1].cards[xe].components=p.components,null==B||B(Object.assign({},e))}else null==B||B(p)}o.useEffect((()=>{var e,n;if(null===(e=y.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))Pe(!0);else{Pe(!1);const e=null===(n=null==Oe?void 0:Oe.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[y]),o.useEffect((()=>{var e,n,t,o;if(null!=xe&&xe>-1){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[xe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[xe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u})}else if(null!=xe&&-1===xe){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=p.getAllDataFromTemplateComponent(y);Ue({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[xe]),o.useEffect((()=>{var e,n,t,o;if(null!=xe&&xe>-1&&Se){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[xe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[xe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}),Fe(!1)}}),[Se]);const Xe=()=>{if(!Qe)return null==R||R(""),void Ke("PDF name is Required");const e=v.validateInputName(null!=Qe?Qe:"",Te);null==R||R(Qe),Ke(e?"Please enter a valid PDF name":void 0)};o.useEffect((()=>{Ve&&Te===d.POD.CHATBOT&&Xe()}),[Ve]);const ze=je?Ae.imageComponent:De;return _e.openEditMedia?e.jsx(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(g.default,{mediaComponentFormat:null!==(L=ze.format)&&void 0!==L?L:s.HEADER_TYPES.IMAGE,uploadMedia:_e.uploadMedia,variableListForImage:D||[],useEditWhatsappTemplateMediaResponse:_e,setOpenEditMedia:_e.setOpenEditMedia,openEditMedia:_e.openEditMedia,editIconRef:_e.editIconRef,fileRef:Re})})):e.jsxs(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Ee?"420px":"auto"}},{children:[!!Ae.imageComponent&&!Ee&&e.jsxs(f.EditTemplateMediaContainer,{children:[e.jsx(h.default,{imageName:null!==(A=null===(P=null==ze?void 0:ze.example)||void 0===P?void 0:P.header_handle)&&void 0!==A?A:[],handleImageChange:_e.handleImageChange,mediaType:null==ze?void 0:ze.format,error:_e.error,isLoading:_e.loading,setOpenEditMedia:_e.setOpenEditMedia,selectedVariable:c.isVariable(null!==(H=null===(w=null===(U=null==ze?void 0:ze.example)||void 0===U?void 0:U.header_handle)||void 0===w?void 0:w[0])&&void 0!==H?H:"")?null===(_=null===(N=null==ze?void 0:ze.example)||void 0===N?void 0:N.header_handle)||void 0===_?void 0:_[0]:(null===(F=null===(S=null==y?void 0:y.mapping)||void 0===S?void 0:S.header)||void 0===F?void 0:F[0])?null===(Y=null===(Q=null==y?void 0:y.mapping)||void 0===Q?void 0:Q.header)||void 0===Y?void 0:Y[0]:_e.selectedVariable}),(null==De?void 0:De.format)==s.HEADER_TYPES.DOCUMENT?e.jsx(V,{children:Te===d.POD.CHATBOT?e.jsx(a.InputWithVariables,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:We||void 0,onBlur:Te!==d.POD.CHATBOT?Xe:void 0,onChange:e=>{Ke(""),Ye(null==e?void 0:e.actualValue)},pickerType:n.PickerType.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=Qe?Qe:"",variableType:"string"},variablesList:D,showAddButton:Te===d.POD.CHATBOT}):e.jsx(l.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:Qe,errorMessage:We||void 0,onBlur:Xe,onChangeText:e=>{Ke(""),Ye(e)}})}):e.jsx(e.Fragment,{})]}),(null===(W=Ae.bodyVariables)||void 0===W?void 0:W.length)>0&&e.jsx(x.default,{containerStyle:{paddingTop:Ae.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=Ae.descriptionComponents)||void 0===K?void 0:K.map(((n,t)=>e.jsx(O.default,{originalVariableList:null!=xe&&xe>-1?Ce.cards[xe]:Ce,type:n.type,descriptionComponent:n.component,showVariableModal:k},t))),(null===(X=null===(G=null!=xe&&xe>-1?null===($=Ce.cards[xe])||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(x.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(Z=null===(J=null!=xe&&xe>-1?null===(z=Ce.cards[xe])||void 0===z?void 0:z.buttons:null==Ce?void 0:Ce.buttons)||void 0===J?void 0:J.filter((e=>Te===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(E.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==M?void 0:M.CTAoptions,button:n,currentVariableList:null!=xe&&xe>-1?Object.assign({},Ce.cards[xe]):Object.assign({},Ce),updateSelectedURLTemplateBtn:$e},`${t}_${xe}`)})),Te===d.POD.CHATBOT&&(null===(ne=null===(ee=ke[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)&&(null===(ie=null===(oe=null===(te=ke[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!=xe&&xe>-1?null===(se=Ce.cards[xe])||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&&(Te!==d.POD.CHATBOT?e.jsx(x.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!=xe&&xe>-1?null===(ce=Ce.cards[xe])||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&&Te!==d.POD.CHATBOT)return e.jsx(E.default,{variableListIndex:t,QRBoptions:null==M?void 0:M.QRBoptions,button:n,currentVariableList:null!=xe&&xe>-1?Object.assign({},Ce.cards[xe]):Object.assign({},Ce),updateSelectedQRBTemplateBtn:Ge},`${t}_${xe}`)})),Te===d.POD.CHATBOT&&Le&&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===(fe=null!=xe&&xe>-1?null===(he=Ce.cards[xe])||void 0===he?void 0:he.buttons:null==Ce?void 0:Ce.buttons)||void 0===fe?void 0:fe.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:ye?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:y,onTemplateChange:V,whatsappSpecificPickerMeta:M,showVariableModal:k,variableListForImage:D,setDiscountCode:I,fileName:q,setFileName:P}=i;var R,A,L,U,w,H,N,_,S,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,fe;const je=y.isCarouselType,{originalVariableList:Te,pod:Ce,extras:Oe,selectedCarouselIndex:xe,isProductCarouselType:Ee,disableCopyCode:ye,isError:Be}=r.useTemplateModalContext(),{descriptionComponents:Ve,urlBtns:Me,qrbBtns:ke,imageComponent:De,bodyVariables:Ie,headerVariables:qe}=p.getAllDataFromTemplateComponent(y),Pe=o.useRef(null),[Re,Ae]=o.useState(!1),[Le,Ue]=o.useState(-1===xe?{descriptionComponents:Ve,urlBtns:Me,qrbBtns:ke,imageComponent:De,bodyVariables:Ie,headerVariables:qe}:{}),{uploadMediaLink:we,uploadMediaFiles:He,validateMimeType:Ne}=M,_e=j.useEditWhatsappTemplateMedia({uploadMediaLink:we,uploadMediaFiles:He,updateTemplateImageUrl:function(e,n){var o,i,l,a,s,d,r,u;let p;p=null!=xe&&xe>-1?{components:null===(i=null===(o=y.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[xe].components,mapping:null===(a=null===(l=null==y?void 0:y.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[xe]}:Object.assign({},y);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!=xe&&xe>-1){const e=t.cloneDeep(y);e.components[1].cards[xe].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[xe]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==V||V(Object.assign({},e)),Fe(!0)}else null==V||V(Object.assign({},p))},validateMimeType:Ne,mediaComponent:je?Le.imageComponent:De,fileRef:Pe}),[Se,Fe]=o.useState(!1),[Qe,Ye]=o.useState(q),[We,Ke]=o.useState();function $e(e,n,o){var i,l,a,s,d,r,u,p,c,v;const m=null!=xe&&xe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[xe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[xe]}:Object.assign({},y),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!=xe&&xe>-1&&Ee){const n=Object.assign({},y).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({},y).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(y);return l.components=n,l.mapping.cards=i,void(null==V||V(Object.assign({},l)))}const f=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==f&&f>-1){const t=null===(d=null==b?void 0:b.components[f].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[f])||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[f]),{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[f]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?Ae(!0):(Ae(!1),null==I||I(""))}if(null!=xe&&xe>-1){const e=t.cloneDeep(y);e.components[1].cards[xe].components=b.components,e.mapping.cards[xe]=b.mapping,null==V||V(Object.assign({},e))}else null==V||V(b)}function Ge(e,n,o){var i,l,a,s,d,r,u;const p=null!=xe&&xe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[xe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[xe]}:Object.assign({},y);if(null!=xe&&xe>-1&&Ee){const n=Object.assign({},y).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(y);return i.components=n,void(null==V||V(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!=xe&&xe>-1){const e=t.cloneDeep(y);e.components[1].cards[xe].components=p.components,null==V||V(Object.assign({},e))}else null==V||V(p)}o.useEffect((()=>{var e,n;if(null===(e=y.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))Ae(!0);else{Ae(!1);const e=null===(n=null==Oe?void 0:Oe.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[y]),o.useEffect((()=>{var e,n,t,o;if(null!=xe&&xe>-1){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[xe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[xe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u})}else if(null!=xe&&-1===xe){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=p.getAllDataFromTemplateComponent(y);Ue({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[xe]),o.useEffect((()=>{var e,n,t,o;if(null!=xe&&xe>-1&&Se){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[xe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[xe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}),Fe(!1)}}),[Se]);const Xe=()=>{if(Ce!==d.POD.CHATBOT&&!Qe)return null==P||P(""),void Ke("PDF name is Required");const e=v.validateInputName(null!=Qe?Qe:"",Ce);Ce!==d.POD.CHATBOT&&(null==P||P(null!=Qe?Qe:"")),Ke(e?"Please enter a valid PDF name":void 0)};o.useEffect((()=>{Be&&Ce===d.POD.CHATBOT&&Xe()}),[Be]);const ze=je?Le.imageComponent:De;return _e.openEditMedia?e.jsx(C.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(g.default,{mediaComponentFormat:null!==(R=ze.format)&&void 0!==R?R:s.HEADER_TYPES.IMAGE,uploadMedia:_e.uploadMedia,variableListForImage:D||[],useEditWhatsappTemplateMediaResponse:_e,setOpenEditMedia:_e.setOpenEditMedia,openEditMedia:_e.openEditMedia,editIconRef:_e.editIconRef,fileRef:Pe})})):e.jsxs(C.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Ee?"420px":"auto"}},{children:[!!Le.imageComponent&&!Ee&&e.jsxs(f.EditTemplateMediaContainer,{children:[e.jsx(h.default,{imageName:null!==(L=null===(A=null==ze?void 0:ze.example)||void 0===A?void 0:A.header_handle)&&void 0!==L?L:[],handleImageChange:_e.handleImageChange,mediaType:null==ze?void 0:ze.format,error:_e.error,isLoading:_e.loading,setOpenEditMedia:_e.setOpenEditMedia,selectedVariable:c.isVariable(null!==(H=null===(w=null===(U=null==ze?void 0:ze.example)||void 0===U?void 0:U.header_handle)||void 0===w?void 0:w[0])&&void 0!==H?H:"")?null===(_=null===(N=null==ze?void 0:ze.example)||void 0===N?void 0:N.header_handle)||void 0===_?void 0:_[0]:(null===(F=null===(S=null==y?void 0:y.mapping)||void 0===S?void 0:S.header)||void 0===F?void 0:F[0])?null===(Y=null===(Q=null==y?void 0:y.mapping)||void 0===Q?void 0:Q.header)||void 0===Y?void 0:Y[0]:_e.selectedVariable}),(null==De?void 0:De.format)==s.HEADER_TYPES.DOCUMENT?e.jsx(B,{children:Ce===d.POD.CHATBOT?e.jsx(a.InputWithVariables,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:We||void 0,onBlur:Ce!==d.POD.CHATBOT?Xe:void 0,onChange:e=>{var n;Ke(""),null==P||P(null!==(n=null==e?void 0:e.actualValue)&&void 0!==n?n:"")},pickerType:n.PickerType.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=Qe?Qe:"",variableType:"string"},variablesList:D,showAddButton:Ce===d.POD.CHATBOT}):e.jsx(l.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:Qe,errorMessage:We||void 0,onBlur:Xe,onChangeText:e=>{Ke(""),Ye(e)}})}):e.jsx(e.Fragment,{})]}),(null===(W=Le.bodyVariables)||void 0===W?void 0:W.length)>0&&e.jsx(x.default,{containerStyle:{paddingTop:Le.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=Le.descriptionComponents)||void 0===K?void 0:K.map(((n,t)=>e.jsx(O.default,{originalVariableList:null!=xe&&xe>-1?Te.cards[xe]:Te,type:n.type,descriptionComponent:n.component,showVariableModal:k},t))),(null===(X=null===(G=null!=xe&&xe>-1?null===($=Te.cards[xe])||void 0===$?void 0:$.buttons:null==Te?void 0:Te.buttons)||void 0===G?void 0:G.filter((e=>"URL"===e.type)))||void 0===X?void 0:X.length)>0&&e.jsx(x.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(Z=null===(J=null!=xe&&xe>-1?null===(z=Te.cards[xe])||void 0===z?void 0:z.buttons:null==Te?void 0:Te.buttons)||void 0===J?void 0:J.filter((e=>Ce===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(E.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==M?void 0:M.CTAoptions,button:n,currentVariableList:null!=xe&&xe>-1?Object.assign({},Te.cards[xe]):Object.assign({},Te),updateSelectedURLTemplateBtn:$e},`${t}_${xe}`)})),Ce===d.POD.CHATBOT&&(null===(ne=null===(ee=ke[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)&&(null===(ie=null===(oe=null===(te=ke[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!=xe&&xe>-1?null===(se=Te.cards[xe])||void 0===se?void 0:se.buttons:null==Te?void 0:Te.buttons)||void 0===de?void 0:de.filter((e=>"QUICK_REPLY"===e.type)))||void 0===re?void 0:re.length)>0&&(Ce!==d.POD.CHATBOT?e.jsx(x.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!=xe&&xe>-1?null===(ce=Te.cards[xe])||void 0===ce?void 0:ce.buttons:null==Te?void 0:Te.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&&Ce!==d.POD.CHATBOT)return e.jsx(E.default,{variableListIndex:t,QRBoptions:null==M?void 0:M.QRBoptions,button:n,currentVariableList:null!=xe&&xe>-1?Object.assign({},Te.cards[xe]):Object.assign({},Te),updateSelectedQRBTemplateBtn:Ge},`${t}_${xe}`)})),Ce===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===(fe=null!=xe&&xe>-1?null===(he=Te.cards[xe])||void 0===he?void 0:he.buttons:null==Te?void 0:Te.buttons)||void 0===fe?void 0:fe.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:ye?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(T.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,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -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 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 C}from"./DiscountCodeComponent.js";import O from"./EditMediaModal.js";import j 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:A,fileName:H,setFileName:N}=d;var P,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,ve,me,be,ge,fe,he,Ce,Oe,je,Te;const xe=k.isCarouselType,{originalVariableList:ye,pod:Ee,extras:Ve,selectedCarouselIndex:Be,isProductCarouselType:Me,disableCopyCode:ke,isError:Ie}=v(),{descriptionComponents:Le,urlBtns:Re,qrbBtns:Ue,imageComponent:we,bodyVariables:Ae,headerVariables:He}=b(k),Ne=l(null),[Pe,De]=a(!1),[_e,Se]=a(-1===Be?{descriptionComponents:Le,urlBtns:Re,qrbBtns:Ue,imageComponent:we,bodyVariables:Ae,headerVariables:He}:{}),{uploadMediaLink:Fe,uploadMediaFiles:Qe,validateMimeType:qe}=R,Ye=x({uploadMediaLink:Fe,uploadMediaFiles:Qe,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)),We(!0)}else null==L||L(Object.assign({},u))},validateMimeType:qe,mediaComponent:xe?_e.imageComponent:we,fileRef:Ne}),[Ke,We]=a(!1),[$e,Ge]=a(H),[Xe,ze]=a();function Je(e,o,n){var t,l,a,s,d,r,p,u,c,v;const m=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(m),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}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[n]=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[h]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?De(!0):(De(!1),null==A||A(""))}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 Ze(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))))De(!0);else{De(!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);Se({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);Se({descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Be]),s((()=>{var e,o,n,t;if(null!=Be&&Be>-1&&Ke){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);Se({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),We(!1)}}),[Ke]);const eo=()=>{if(!$e)return null==N||N(""),void ze("PDF name is Required");const e=f(null!=$e?$e:"",Ee);null==N||N($e),ze(e?"Please enter a valid PDF name":void 0)};s((()=>{Ie&&Ee===c.CHATBOT&&eo()}),[Ie]);const oo=xe?_e.imageComponent:we;return Ye.openEditMedia?e(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e(O,{mediaComponentFormat:null!==(P=oo.format)&&void 0!==P?P:u.IMAGE,uploadMedia:Ye.uploadMedia,variableListForImage:w||[],useEditWhatsappTemplateMediaResponse:Ye,setOpenEditMedia:Ye.setOpenEditMedia,openEditMedia:Ye.openEditMedia,editIconRef:Ye.editIconRef,fileRef:Ne})})):o(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Me?"420px":"auto"}},{children:[!!_e.imageComponent&&!Me&&o(T,{children:[e(j,{imageName:null!==(_=null===(D=null==oo?void 0:oo.example)||void 0===D?void 0:D.header_handle)&&void 0!==_?_:[],handleImageChange:Ye.handleImageChange,mediaType:null==oo?void 0:oo.format,error:Ye.error,isLoading:Ye.loading,setOpenEditMedia:Ye.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(F=null===(S=null==oo?void 0:oo.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==oo?void 0:oo.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]:Ye.selectedVariable}),(null==we?void 0:we.format)==u.DOCUMENT?e(I,{children:Ee===c.CHATBOT?e(p,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Xe||void 0,onBlur:Ee!==c.CHATBOT?eo:void 0,onChange:e=>{ze(""),Ge(null==e?void 0:e.actualValue)},pickerType:t.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=$e?$e:"",variableType:"string"},variablesList:w,showAddButton:Ee===c.CHATBOT}):e(r,{labelText:"PDF Name",placeholder:"Enter the name",value:$e,errorMessage:Xe||void 0,onBlur:eo,onChangeText:e=>{ze(""),Ge(e)}})}):e(n,{})]}),(null===(X=_e.bodyVariables)||void 0===X?void 0:X.length)>0&&e(B,{containerStyle:{paddingTop:_e.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=_e.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===m;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:Je},`${n}_${Be}`)})),Ee===c.CHATBOT&&(null===(le=null===(ie=Ue[0])||void 0===ie?void 0:ie.component)||void 0===le?void 0:le.buttons)&&(null===(de=null===(se=null===(ae=Ue[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===(ve=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===ve?void 0:ve.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===(me=null==Ve?void 0:Ve.backTrackExtra)||void 0===me?void 0:me[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:Ze},`${n}_${Be}`)})),Ee===c.CHATBOT&&Pe&&e(C,{discountCode:null===(Ce=null==Ve?void 0:Ve.discountCodeExtra)||void 0===Ce?void 0:Ce[0],setDiscountCode:null===(Oe=null==Ve?void 0:Ve.discountCodeExtra)||void 0===Oe?void 0:Oe[1]}),null===(Te=null!=Be&&Be>-1?null===(je=ye.cards[Be])||void 0===je?void 0:je.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 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 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 C}from"./DiscountCodeComponent.js";import O from"./EditMediaModal.js";import T from"./EditMediaV2.js";import{EditTemplateMediaContainer as j}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as x}from"./useEditWhtasappTemplateMedia.js";import y from"./VariableConnector.js";import{Container as E}from"./VariableConnectorsPanel.js";import B from"./VariableConnectorWhatsApp.js";import V from"./VariableEditorHeader.js";import M from"./WhatsAppTemplateCardButtonV2.js";const k=d=>{let{template:k,onTemplateChange:L,whatsappSpecificPickerMeta:R,showVariableModal:U,variableListForImage:w,setDiscountCode:A,fileName:H,setFileName:N}=d;var P,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,ve,me,be,ge,fe,he,Ce,Oe,Te,je;const xe=k.isCarouselType,{originalVariableList:ye,pod:Ee,extras:Be,selectedCarouselIndex:Ve,isProductCarouselType:Me,disableCopyCode:ke,isError:Ie}=v(),{descriptionComponents:Le,urlBtns:Re,qrbBtns:Ue,imageComponent:we,bodyVariables:Ae,headerVariables:He}=b(k),Ne=l(null),[Pe,De]=a(!1),[_e,Se]=a(-1===Ve?{descriptionComponents:Le,urlBtns:Re,qrbBtns:Ue,imageComponent:we,bodyVariables:Ae,headerVariables:He}:{}),{uploadMediaLink:Fe,uploadMediaFiles:Qe,validateMimeType:qe}=R,Ye=x({uploadMediaLink:Fe,uploadMediaFiles:Qe,updateTemplateImageUrl:function(e,o){var n,t,l,a,s,d,r,p;let u;u=null!=Ve&&Ve>-1?{components:null===(t=null===(n=k.components[1])||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Ve].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[Ve]}: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!=Ve&&Ve>-1){const e=i(k);e.components[1].cards[Ve].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[Ve]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==L||L(Object.assign({},e)),We(!0)}else null==L||L(Object.assign({},u))},validateMimeType:qe,mediaComponent:xe?_e.imageComponent:we,fileRef:Ne}),[Ke,We]=a(!1),[$e,Ge]=a(H),[Xe,ze]=a();function Je(e,o,n){var t,l,a,s,d,r,p,u,c,v;const m=null!=Ve&&Ve>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Ve].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Ve]}:Object.assign({},k),b=i(m),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!=Ve&&Ve>-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}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[n]=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[h]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?De(!0):(De(!1),null==A||A(""))}if(null!=Ve&&Ve>-1){const e=i(k);e.components[1].cards[Ve].components=b.components,e.mapping.cards[Ve]=b.mapping,null==L||L(Object.assign({},e))}else null==L||L(b)}function Ze(e,o,n){var t,l,a,s,d,r,p;const u=null!=Ve&&Ve>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Ve].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Ve]}:Object.assign({},k);if(null!=Ve&&Ve>-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!=Ve&&Ve>-1){const e=i(k);e.components[1].cards[Ve].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))))De(!0);else{De(!1);const e=null===(o=null==Be?void 0:Be.discountCodeExtra)||void 0===o?void 0:o[1];null==e||e("")}}),[k]),s((()=>{var e,o,n,t;if(null!=Ve&&Ve>-1){const i={components:null===(o=null===(e=k.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Ve].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[Ve]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);Se({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Ve&&-1===Ve){const{descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=b(k);Se({descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Ve]),s((()=>{var e,o,n,t;if(null!=Ve&&Ve>-1&&Ke){const i={components:null===(o=null===(e=k.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Ve].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[Ve]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);Se({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),We(!1)}}),[Ke]);const eo=()=>{if(Ee!==c.CHATBOT&&!$e)return null==N||N(""),void ze("PDF name is Required");const e=f(null!=$e?$e:"",Ee);Ee!==c.CHATBOT&&(null==N||N(null!=$e?$e:"")),ze(e?"Please enter a valid PDF name":void 0)};s((()=>{Ie&&Ee===c.CHATBOT&&eo()}),[Ie]);const oo=xe?_e.imageComponent:we;return Ye.openEditMedia?e(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e(O,{mediaComponentFormat:null!==(P=oo.format)&&void 0!==P?P:u.IMAGE,uploadMedia:Ye.uploadMedia,variableListForImage:w||[],useEditWhatsappTemplateMediaResponse:Ye,setOpenEditMedia:Ye.setOpenEditMedia,openEditMedia:Ye.openEditMedia,editIconRef:Ye.editIconRef,fileRef:Ne})})):o(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Me?"420px":"auto"}},{children:[!!_e.imageComponent&&!Me&&o(j,{children:[e(T,{imageName:null!==(_=null===(D=null==oo?void 0:oo.example)||void 0===D?void 0:D.header_handle)&&void 0!==_?_:[],handleImageChange:Ye.handleImageChange,mediaType:null==oo?void 0:oo.format,error:Ye.error,isLoading:Ye.loading,setOpenEditMedia:Ye.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(F=null===(S=null==oo?void 0:oo.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==oo?void 0:oo.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]:Ye.selectedVariable}),(null==we?void 0:we.format)==u.DOCUMENT?e(I,{children:Ee===c.CHATBOT?e(p,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Xe||void 0,onBlur:Ee!==c.CHATBOT?eo:void 0,onChange:e=>{var o;ze(""),null==N||N(null!==(o=null==e?void 0:e.actualValue)&&void 0!==o?o:"")},pickerType:t.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=$e?$e:"",variableType:"string"},variablesList:w,showAddButton:Ee===c.CHATBOT}):e(r,{labelText:"PDF Name",placeholder:"Enter the name",value:$e,errorMessage:Xe||void 0,onBlur:eo,onChangeText:e=>{ze(""),Ge(e)}})}):e(n,{})]}),(null===(X=_e.bodyVariables)||void 0===X?void 0:X.length)>0&&e(V,{containerStyle:{paddingTop:_e.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=_e.descriptionComponents)||void 0===z?void 0:z.map(((o,n)=>e(B,{originalVariableList:null!=Ve&&Ve>-1?ye.cards[Ve]:ye,type:o.type,descriptionComponent:o.component,showVariableModal:U},n))),(null===(ee=null===(Z=null!=Ve&&Ve>-1?null===(J=ye.cards[Ve])||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(V,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(te=null===(ne=null!=Ve&&Ve>-1?null===(oe=ye.cards[Ve])||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===m;if("URL"===o.type)return e(M,{variableListIndex:n,disableEdit:t,CTAoptions:null==R?void 0:R.CTAoptions,button:o,currentVariableList:null!=Ve&&Ve>-1?Object.assign({},ye.cards[Ve]):Object.assign({},ye),updateSelectedURLTemplateBtn:Je},`${n}_${Ve}`)})),Ee===c.CHATBOT&&(null===(le=null===(ie=Ue[0])||void 0===ie?void 0:ie.component)||void 0===le?void 0:le.buttons)&&(null===(de=null===(se=null===(ae=Ue[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==Be?void 0:Be.backTrackExtra)||void 0===re?void 0:re[0],setBackTrackMessage:null===(pe=null==Be?void 0:Be.backTrackExtra)||void 0===pe?void 0:pe[1]}),(null===(ve=null===(ce=null!=Ve&&Ve>-1?null===(ue=ye.cards[Ve])||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===ve?void 0:ve.length)>0&&(Ee!==c.CHATBOT?e(V,{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===(me=null==Be?void 0:Be.backTrackExtra)||void 0===me?void 0:me[0],setBackTrackMessage:null===(be=null==Be?void 0:Be.backTrackExtra)||void 0===be?void 0:be[1]})),null===(he=null===(fe=null!=Ve&&Ve>-1?null===(ge=ye.cards[Ve])||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!=Ve&&Ve>-1?Object.assign({},ye.cards[Ve]):Object.assign({},ye),updateSelectedQRBTemplateBtn:Ze},`${n}_${Ve}`)})),Ee===c.CHATBOT&&Pe&&e(C,{discountCode:null===(Ce=null==Be?void 0:Be.discountCodeExtra)||void 0===Ce?void 0:Ce[0],setDiscountCode:null===(Oe=null==Be?void 0:Be.discountCodeExtra)||void 0===Oe?void 0:Oe[1]}),null===(je=null!=Ve&&Ve>-1?null===(Te=ye.cards[Ve])||void 0===Te?void 0:Te.buttons:null==ye?void 0:ye.buttons)||void 0===je?void 0:je.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`
2
2
  padding-top: 24px;
3
3
  padding-left: 10px;
4
4
  padding-right: 10px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.612-beta-vsp.12",
3
+ "version": "0.0.612-beta-vsp.14",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",