@bikdotai/bik-component-library 0.0.433-beta.7 → 0.0.433-beta.8

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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("lodash"),o=require("react"),t=require("../../template-preview/models/WhatsAppTemplate.js"),i=require("../context/templateModalContext.js"),l=require("../custom-hooks/useAdditionalVariables.js"),s=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),d=require("./DiscountCodeComponent.js"),r=require("./EditMediaV2.style.js"),p=require("./EditWhatsAppTemplateMediaV2.js"),u=require("./VariableConnector.js"),c=require("./VariableConnectorsPanel.js"),m=require("./VariableConnectorWhatsApp.js"),v=require("./VariableEditorHeader.js"),b=require("./WhatsAppTemplateCardButtonV2.js");exports.default=g=>{let{template:h,onTemplateChange:f,whatsappSpecificPickerMeta:C,showVariableModal:j,variableList:x,variableListForImage:T,discountCode:V,setDiscountCode:O}=g;var B,y,q,E,k,D,L,w,I,A,M,S,U,N,P,R,F,H;const{originalVariableList:_,pod:Q,extras:W,selectedCarouselIndex:Y}=i.useTemplateModalContext(),{descriptionComponents:K,urlBtns:$,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}=s.getAllDataFromTemplateComponent(h),[Z,ee]=o.useState(!1),[ne,oe]=o.useState(-1===Y?{descriptionComponents:K,urlBtns:$,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}:{}),[te,ie]=o.useState(!1);function le(e,o){var t,i,l,s,a,d,r;const p=null!=Y&&Y>-1?{components:null===(t=Object.assign({},h).components[1].cards)||void 0===t?void 0:t[Y].components,mapping:null===(i=Object.assign({},h).mapping.cards)||void 0===i?void 0:i[Y]}:Object.assign({},h),u=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==u&&u>-1){const n=null===(l=null==p?void 0:p.components[u].buttons)||void 0===l?void 0:l.findIndex((e=>"URL"===e.type));if(void 0!==n&&n>-1){const t="custom"===o&&"string"==typeof e,i=[...null!==(d=null===(a=null===(s=p.components)||void 0===s?void 0:s[u])||void 0===a?void 0:a.buttons)&&void 0!==d?d:[]];i[n]=Object.assign(Object.assign({},i[n]),{url:"https://d.bik.ai/{{1}}",example:[t?e:"string"!=typeof e?e.defaultValue:""]});const l=Object.assign(Object.assign({},p.components[u]),{buttons:i}),r=Object.assign(Object.assign({},p.mapping),{buttons:t?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});p.mapping=r;const c=[...p.components];c[u]=l,p.components=c}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(r=e.placeHolder)||void 0===r?void 0:r.slice(2,-2))?ee(!0):(ee(!1),null==O||O(""))}if(null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=p.components,e.mapping.cards[Y]=p.mapping,null==f||f(Object.assign({},e))}else null==f||f(p)}function se(e,o,t){var i,l,s;console.log("template 55: ",h),console.log("qrbBtns 55: ",X),console.log("urlBtns 55: ",$);const a=null!=Y&&Y>-1?{components:null===(i=Object.assign({},h).components[1].cards)||void 0===i?void 0:i[Y].components,mapping:null===(l=Object.assign({},h).mapping.cards)||void 0===l?void 0:l[Y]}:Object.assign({},h),d=null==a?void 0:a.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==d&&d>-1){const n=null===(s=null==a?void 0:a.components[d].buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));n&&(n[t]=Object.assign(Object.assign({},n[t]),{flowId:e.flowId,flowName:e.flowName}));const o=Object.assign(Object.assign({},a.components[d]),{buttons:n}),i=[...a.components];i[d]=o,a.components=i}if(null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=a.components,e.mapping.cards[Y]=a.mapping,null==f||f(Object.assign({},e))}else null==f||f(a)}o.useEffect((()=>{var e,n;if(null===(e=h.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))ee(!0);else{ee(!1);const e=null===(n=null==W?void 0:W.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[h]),o.useEffect((()=>{var e,n,o,t;if(null!=Y&&Y>-1){const i={components:null===(n=null===(e=h.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Y].components,mapping:null===(t=null===(o=null==h?void 0:h.mapping)||void 0===o?void 0:o.cards)||void 0===t?void 0:t[Y]},{descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}=s.getAllDataFromTemplateComponent(i);oe({descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u})}else if(null!=Y&&-1===Y){const{descriptionComponents:e,urlBtns:n,qrbBtns:o,imageComponent:t,bodyVariables:i,headerVariables:l}=s.getAllDataFromTemplateComponent(h);oe({descriptionComponents:e,urlBtns:n,qrbBtns:o,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Y]),o.useEffect((()=>{var e,n,o,t;if(console.log("right panel selectedCarouselIndex: ",Y),null!=Y&&Y>-1&&te){const i={components:null===(n=null===(e=h.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Y].components,mapping:null===(t=null===(o=null==h?void 0:h.mapping)||void 0===o?void 0:o.cards)||void 0===t?void 0:t[Y]},{descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}=s.getAllDataFromTemplateComponent(i);oe({descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}),ie(!1)}}),[te]);const ae=l.useAdditionalVariables({variableList:x,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return e.jsxs(c.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!ne.imageComponent&&e.jsx(r.EditTemplateMediaContainer,{children:e.jsx(p.default,{whatsappSpecificPickerMeta:C,mediaComponent:ne.imageComponent,updateTemplateImageUrl:function(e,o){var t,i,l,s,a;let d;d=null!=Y&&Y>-1?{components:null===(i=null===(t=h.components[1])||void 0===t?void 0:t.cards)||void 0===i?void 0:i[Y].components,mapping:null===(s=null===(l=null==h?void 0:h.mapping)||void 0===l?void 0:l.cards)||void 0===s?void 0:s[Y]}:Object.assign({},h);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const n=Object.assign(Object.assign({},d.components[r]),{format:o,example:{header_handle:[e]}}),t=[...d.components];t[r]=n,d=Object.assign(Object.assign({},d),{components:t})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=d.components,e.mapping.cards[Y]=d.mapping,null==f||f(Object.assign({},e)),ie(!0)}else null==f||f(Object.assign({},d))},template:h,variableListForImage:T})}),(ne.bodyVariables.length>0||ne.headerVariables.length>0)&&e.jsx(v.default,{containerStyle:{paddingTop:ne.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===(B=ne.descriptionComponents)||void 0===B?void 0:B.map(((n,o)=>e.jsx(m.default,{originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,type:n.type,descriptionComponent:n.component,showVariableModal:j,variableList:x},o))),(null===(q=null===(y=ne.urlBtns[0])||void 0===y?void 0:y.component)||void 0===q?void 0:q.buttons)&&(null===(D=null===(k=null===(E=ne.urlBtns[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)||void 0===D?void 0:D.length)>0&&e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(L=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===L?void 0:L.map(((n,o)=>{if("URL"===n.type)return e.jsx(b.default,{variableListIndex:o,CTAoptions:null==C?void 0:C.CTAoptions,button:n,originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,updateSelectedURLTemplateBtn:le,variableList:x},`${o}`)})),(null===(I=null===(w=ne.qrbBtns[0])||void 0===w?void 0:w.component)||void 0===I?void 0:I.buttons)&&(null===(S=null===(M=null===(A=ne.qrbBtns[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)||void 0===S?void 0:S.length)>0&&(Q!==t.POD.CHATBOT?e.jsx(v.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(a.BackTrackComponent,{backTrackMessage:null===(U=null==W?void 0:W.backTrackExtra)||void 0===U?void 0:U[0],setBackTrackMessage:null===(N=null==W?void 0:W.backTrackExtra)||void 0===N?void 0:N[1]})),null===(P=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===P?void 0:P.map(((n,o)=>{if("QUICK_REPLY"===n.type)return e.jsx(b.default,{variableListIndex:o,QRBoptions:null==C?void 0:C.QRBoptions,button:n,originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,updateSelectedQRBTemplateBtn:se},`${o}`)})),Q===t.POD.CHATBOT&&Z&&e.jsx(d.DiscountCodeComponent,{discountCode:null===(R=null==W?void 0:W.discountCodeExtra)||void 0===R?void 0:R[0],setDiscountCode:null===(F=null==W?void 0:W.discountCodeExtra)||void 0===F?void 0:F[1],variableList:x}),null===(H=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===H?void 0:H.map(((n,o)=>{var t,i,l;if("COPY_CODE"===n.type)return e.jsx(u.default,{index:o,variable:{variableName:null!==(t=n.text)&&void 0!==t?t:"",updatedValue:null!==(i=n.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=n.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:ae,componentType:"BUTTONS"},o)}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("lodash"),o=require("react"),t=require("../../template-preview/models/WhatsAppTemplate.js"),i=require("../context/templateModalContext.js"),l=require("../custom-hooks/useAdditionalVariables.js"),s=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),d=require("./DiscountCodeComponent.js"),r=require("./EditMediaV2.style.js"),p=require("./EditWhatsAppTemplateMediaV2.js"),u=require("./VariableConnector.js"),c=require("./VariableConnectorsPanel.js"),m=require("./VariableConnectorWhatsApp.js"),v=require("./VariableEditorHeader.js"),b=require("./WhatsAppTemplateCardButtonV2.js");exports.default=g=>{let{template:h,onTemplateChange:f,whatsappSpecificPickerMeta:C,showVariableModal:j,variableList:x,variableListForImage:T,discountCode:V,setDiscountCode:B}=g;var O,y,q,E,k,D,L,w,I,A,M,S,U,N,P,R,F,H;const{originalVariableList:_,pod:Q,extras:W,selectedCarouselIndex:Y}=i.useTemplateModalContext(),{descriptionComponents:K,urlBtns:$,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}=s.getAllDataFromTemplateComponent(h),[Z,ee]=o.useState(!1),[ne,oe]=o.useState(-1===Y?{descriptionComponents:K,urlBtns:$,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}:{}),[te,ie]=o.useState(!1);function le(e,o){var t,i,l,s,a,d,r;const p=null!=Y&&Y>-1?{components:null===(t=Object.assign({},h).components[1].cards)||void 0===t?void 0:t[Y].components,mapping:null===(i=Object.assign({},h).mapping.cards)||void 0===i?void 0:i[Y]}:Object.assign({},h),u=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==u&&u>-1){const n=null===(l=null==p?void 0:p.components[u].buttons)||void 0===l?void 0:l.findIndex((e=>"URL"===e.type));if(void 0!==n&&n>-1){const t="custom"===o&&"string"==typeof e,i=[...null!==(d=null===(a=null===(s=p.components)||void 0===s?void 0:s[u])||void 0===a?void 0:a.buttons)&&void 0!==d?d:[]];i[n]=Object.assign(Object.assign({},i[n]),{url:"https://d.bik.ai/{{1}}",example:[t?e:"string"!=typeof e?e.defaultValue:""]});const l=Object.assign(Object.assign({},p.components[u]),{buttons:i}),r=Object.assign(Object.assign({},p.mapping),{buttons:t?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});p.mapping=r;const c=[...p.components];c[u]=l,p.components=c}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(r=e.placeHolder)||void 0===r?void 0:r.slice(2,-2))?ee(!0):(ee(!1),null==B||B(""))}if(null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=p.components,e.mapping.cards[Y]=p.mapping,null==f||f(Object.assign({},e))}else null==f||f(p)}function se(e,o,t){var i,l,s;console.log("template 55: ",h),console.log("qrbBtns 55: ",X),console.log("urlBtns 55: ",$);const a=null!=Y&&Y>-1?{components:null===(i=Object.assign({},h).components[1].cards)||void 0===i?void 0:i[Y].components,mapping:null===(l=Object.assign({},h).mapping.cards)||void 0===l?void 0:l[Y]}:Object.assign({},h),d=null==a?void 0:a.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==d&&d>-1){const n=null===(s=null==a?void 0:a.components[d].buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));n&&(n[t]=Object.assign(Object.assign({},n[t]),{flowId:e.flowId,flowName:e.flowName}));const o=Object.assign(Object.assign({},a.components[d]),{buttons:n}),i=[...a.components];i[d]=o,a.components=i}if(null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=a.components,e.mapping.cards[Y]=a.mapping,null==f||f(Object.assign({},e))}else null==f||f(a)}o.useEffect((()=>{var e,n;if(null===(e=h.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))ee(!0);else{ee(!1);const e=null===(n=null==W?void 0:W.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[h]),o.useEffect((()=>{var e,n,o,t;if(null!=Y&&Y>-1){const i={components:null===(n=null===(e=h.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Y].components,mapping:null===(t=null===(o=null==h?void 0:h.mapping)||void 0===o?void 0:o.cards)||void 0===t?void 0:t[Y]},{descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}=s.getAllDataFromTemplateComponent(i);oe({descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}),console.log("urlBtns 89: ",a),console.log("urlBtns 89: ",a)}else if(null!=Y&&-1===Y){const{descriptionComponents:e,urlBtns:n,qrbBtns:o,imageComponent:t,bodyVariables:i,headerVariables:l}=s.getAllDataFromTemplateComponent(h);oe({descriptionComponents:e,urlBtns:n,qrbBtns:o,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Y]),o.useEffect((()=>{var e,n,o,t;if(console.log("right panel selectedCarouselIndex: ",Y),null!=Y&&Y>-1&&te){const i={components:null===(n=null===(e=h.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Y].components,mapping:null===(t=null===(o=null==h?void 0:h.mapping)||void 0===o?void 0:o.cards)||void 0===t?void 0:t[Y]},{descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}=s.getAllDataFromTemplateComponent(i);oe({descriptionComponents:l,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:p,headerVariables:u}),ie(!1)}}),[te]);const ae=l.useAdditionalVariables({variableList:x,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return e.jsxs(c.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!ne.imageComponent&&e.jsx(r.EditTemplateMediaContainer,{children:e.jsx(p.default,{whatsappSpecificPickerMeta:C,mediaComponent:ne.imageComponent,updateTemplateImageUrl:function(e,o){var t,i,l,s,a;let d;d=null!=Y&&Y>-1?{components:null===(i=null===(t=h.components[1])||void 0===t?void 0:t.cards)||void 0===i?void 0:i[Y].components,mapping:null===(s=null===(l=null==h?void 0:h.mapping)||void 0===l?void 0:l.cards)||void 0===s?void 0:s[Y]}:Object.assign({},h);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const n=Object.assign(Object.assign({},d.components[r]),{format:o,example:{header_handle:[e]}}),t=[...d.components];t[r]=n,d=Object.assign(Object.assign({},d),{components:t})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=Y&&Y>-1){const e=n.cloneDeep(h);e.components[1].cards[Y].components=d.components,e.mapping.cards[Y]=d.mapping,null==f||f(Object.assign({},e)),ie(!0)}else null==f||f(Object.assign({},d))},template:h,variableListForImage:T})}),(ne.bodyVariables.length>0||ne.headerVariables.length>0)&&e.jsx(v.default,{containerStyle:{paddingTop:ne.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===(O=ne.descriptionComponents)||void 0===O?void 0:O.map(((n,o)=>e.jsx(m.default,{originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,type:n.type,descriptionComponent:n.component,showVariableModal:j,variableList:x},o))),(null===(q=null===(y=ne.urlBtns[0])||void 0===y?void 0:y.component)||void 0===q?void 0:q.buttons)&&(null===(D=null===(k=null===(E=ne.urlBtns[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)||void 0===D?void 0:D.length)>0&&e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(L=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===L?void 0:L.map(((n,o)=>{if("URL"===n.type)return e.jsx(b.default,{variableListIndex:o,CTAoptions:null==C?void 0:C.CTAoptions,button:n,originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,updateSelectedURLTemplateBtn:le,variableList:x},`${o}`)})),(null===(I=null===(w=ne.qrbBtns[0])||void 0===w?void 0:w.component)||void 0===I?void 0:I.buttons)&&(null===(S=null===(M=null===(A=ne.qrbBtns[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)||void 0===S?void 0:S.length)>0&&(Q!==t.POD.CHATBOT?e.jsx(v.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(a.BackTrackComponent,{backTrackMessage:null===(U=null==W?void 0:W.backTrackExtra)||void 0===U?void 0:U[0],setBackTrackMessage:null===(N=null==W?void 0:W.backTrackExtra)||void 0===N?void 0:N[1]})),null===(P=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===P?void 0:P.map(((n,o)=>{if("QUICK_REPLY"===n.type)return e.jsx(b.default,{variableListIndex:o,QRBoptions:null==C?void 0:C.QRBoptions,button:n,originalVariableList:null!=Y&&Y>-1?_.cards[Y]:_,updateSelectedQRBTemplateBtn:se},`${o}`)})),Q===t.POD.CHATBOT&&Z&&e.jsx(d.DiscountCodeComponent,{discountCode:null===(R=null==W?void 0:W.discountCodeExtra)||void 0===R?void 0:R[0],setDiscountCode:null===(F=null==W?void 0:W.discountCodeExtra)||void 0===F?void 0:F[1],variableList:x}),null===(H=null!=Y&&Y>-1?_.cards[Y].buttons:null==_?void 0:_.buttons)||void 0===H?void 0:H.map(((n,o)=>{var t,i,l;if("COPY_CODE"===n.type)return e.jsx(u.default,{index:o,variable:{variableName:null!==(t=n.text)&&void 0!==t?t:"",updatedValue:null!==(i=n.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=n.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:ae,componentType:"BUTTONS"},o)}))]}))};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as n}from"react/jsx-runtime";import{cloneDeep as e}from"lodash";import{useState as t,useEffect as i}from"react";import{POD as l}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as s}from"../context/templateModalContext.js";import{useAdditionalVariables as a}from"../custom-hooks/useAdditionalVariables.js";import{getAllDataFromTemplateComponent as d}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as r}from"./BackTrackComponent.js";import{DiscountCodeComponent as p}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as c}from"./EditMediaV2.style.js";import m from"./EditWhatsAppTemplateMediaV2.js";import u from"./VariableConnector.js";import{Container as v}from"./VariableConnectorsPanel.js";import b from"./VariableConnectorWhatsApp.js";import g from"./VariableEditorHeader.js";import h from"./WhatsAppTemplateCardButtonV2.js";const f=f=>{let{template:C,onTemplateChange:j,whatsappSpecificPickerMeta:T,showVariableModal:V,variableList:x,variableListForImage:B,discountCode:O,setDiscountCode:y}=f;var E,k,L,w,I,q,A,U,M,N,D,R,S,H,P,Q,W,_;const{originalVariableList:F,pod:Y,extras:K,selectedCarouselIndex:$}=s(),{descriptionComponents:X,urlBtns:z,qrbBtns:G,imageComponent:J,bodyVariables:Z,headerVariables:oo}=d(C),[no,eo]=t(!1),[to,io]=t(-1===$?{descriptionComponents:X,urlBtns:z,qrbBtns:G,imageComponent:J,bodyVariables:Z,headerVariables:oo}:{}),[lo,so]=t(!1);function ao(o,n){var t,i,l,s,a,d,r;const p=null!=$&&$>-1?{components:null===(t=Object.assign({},C).components[1].cards)||void 0===t?void 0:t[$].components,mapping:null===(i=Object.assign({},C).mapping.cards)||void 0===i?void 0:i[$]}:Object.assign({},C),c=null==p?void 0:p.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==c&&c>-1){const e=null===(l=null==p?void 0:p.components[c].buttons)||void 0===l?void 0:l.findIndex((o=>"URL"===o.type));if(void 0!==e&&e>-1){const t="custom"===n&&"string"==typeof o,i=[...null!==(d=null===(a=null===(s=p.components)||void 0===s?void 0:s[c])||void 0===a?void 0:a.buttons)&&void 0!==d?d:[]];i[e]=Object.assign(Object.assign({},i[e]),{url:"https://d.bik.ai/{{1}}",example:[t?o:"string"!=typeof o?o.defaultValue:""]});const l=Object.assign(Object.assign({},p.components[c]),{buttons:i}),r=Object.assign(Object.assign({},p.mapping),{buttons:t?["((customBtnPlaceholder))"]:"string"!=typeof o?[o.placeHolder]:void 0});p.mapping=r;const m=[...p.components];m[c]=l,p.components=m}}if("string"!=typeof o){"checkout.checkoutUrl"===(null===(r=o.placeHolder)||void 0===r?void 0:r.slice(2,-2))?eo(!0):(eo(!1),null==y||y(""))}if(null!=$&&$>-1){const o=e(C);o.components[1].cards[$].components=p.components,o.mapping.cards[$]=p.mapping,null==j||j(Object.assign({},o))}else null==j||j(p)}function ro(o,n,t){var i,l,s;console.log("template 55: ",C),console.log("qrbBtns 55: ",G),console.log("urlBtns 55: ",z);const a=null!=$&&$>-1?{components:null===(i=Object.assign({},C).components[1].cards)||void 0===i?void 0:i[$].components,mapping:null===(l=Object.assign({},C).mapping.cards)||void 0===l?void 0:l[$]}:Object.assign({},C),d=null==a?void 0:a.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==d&&d>-1){const n=null===(s=null==a?void 0:a.components[d].buttons)||void 0===s?void 0:s.filter((o=>"QUICK_REPLY"===o.type));n&&(n[t]=Object.assign(Object.assign({},n[t]),{flowId:o.flowId,flowName:o.flowName}));const e=Object.assign(Object.assign({},a.components[d]),{buttons:n}),i=[...a.components];i[d]=e,a.components=i}if(null!=$&&$>-1){const o=e(C);o.components[1].cards[$].components=a.components,o.mapping.cards[$]=a.mapping,null==j||j(Object.assign({},o))}else null==j||j(a)}i((()=>{var o,n;if(null===(o=C.mapping.buttons)||void 0===o?void 0:o.find((o=>"checkout.checkoutUrl"===o.slice(2,-2))))eo(!0);else{eo(!1);const o=null===(n=null==K?void 0:K.discountCodeExtra)||void 0===n?void 0:n[1];null==o||o("")}}),[C]),i((()=>{var o,n,e,t;if(null!=$&&$>-1){const i={components:null===(n=null===(o=C.components[1])||void 0===o?void 0:o.cards)||void 0===n?void 0:n[$].components,mapping:null===(t=null===(e=null==C?void 0:C.mapping)||void 0===e?void 0:e.cards)||void 0===t?void 0:t[$]},{descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);io({descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c})}else if(null!=$&&-1===$){const{descriptionComponents:o,urlBtns:n,qrbBtns:e,imageComponent:t,bodyVariables:i,headerVariables:l}=d(C);io({descriptionComponents:o,urlBtns:n,qrbBtns:e,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[$]),i((()=>{var o,n,e,t;if(console.log("right panel selectedCarouselIndex: ",$),null!=$&&$>-1&&lo){const i={components:null===(n=null===(o=C.components[1])||void 0===o?void 0:o.cards)||void 0===n?void 0:n[$].components,mapping:null===(t=null===(e=null==C?void 0:C.mapping)||void 0===e?void 0:e.cards)||void 0===t?void 0:t[$]},{descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);io({descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}),so(!1)}}),[lo]);const po=a({variableList:x,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return o(v,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!to.imageComponent&&n(c,{children:n(m,{whatsappSpecificPickerMeta:T,mediaComponent:to.imageComponent,updateTemplateImageUrl:function(o,n){var t,i,l,s,a;let d;d=null!=$&&$>-1?{components:null===(i=null===(t=C.components[1])||void 0===t?void 0:t.cards)||void 0===i?void 0:i[$].components,mapping:null===(s=null===(l=null==C?void 0:C.mapping)||void 0===l?void 0:l.cards)||void 0===s?void 0:s[$]}:Object.assign({},C);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((o=>{if("HEADER"===o.type&&"NONE"!==o.format&&"TEXT"!==o.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const e=Object.assign(Object.assign({},d.components[r]),{format:n,example:{header_handle:[o]}}),t=[...d.components];t[r]=e,d=Object.assign(Object.assign({},d),{components:t})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=$&&$>-1){const o=e(C);o.components[1].cards[$].components=d.components,o.mapping.cards[$]=d.mapping,null==j||j(Object.assign({},o)),so(!0)}else null==j||j(Object.assign({},d))},template:C,variableListForImage:B})}),(to.bodyVariables.length>0||to.headerVariables.length>0)&&n(g,{containerStyle:{paddingTop:to.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===(E=to.descriptionComponents)||void 0===E?void 0:E.map(((o,e)=>n(b,{originalVariableList:null!=$&&$>-1?F.cards[$]:F,type:o.type,descriptionComponent:o.component,showVariableModal:V,variableList:x},e))),(null===(L=null===(k=to.urlBtns[0])||void 0===k?void 0:k.component)||void 0===L?void 0:L.buttons)&&(null===(q=null===(I=null===(w=to.urlBtns[0])||void 0===w?void 0:w.component)||void 0===I?void 0:I.buttons)||void 0===q?void 0:q.length)>0&&n(g,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(A=null!=$&&$>-1?F.cards[$].buttons:null==F?void 0:F.buttons)||void 0===A?void 0:A.map(((o,e)=>{if("URL"===o.type)return n(h,{variableListIndex:e,CTAoptions:null==T?void 0:T.CTAoptions,button:o,originalVariableList:null!=$&&$>-1?F.cards[$]:F,updateSelectedURLTemplateBtn:ao,variableList:x},`${e}`)})),(null===(M=null===(U=to.qrbBtns[0])||void 0===U?void 0:U.component)||void 0===M?void 0:M.buttons)&&(null===(R=null===(D=null===(N=to.qrbBtns[0])||void 0===N?void 0:N.component)||void 0===D?void 0:D.buttons)||void 0===R?void 0:R.length)>0&&(Y!==l.CHATBOT?n(g,{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"}):n(r,{backTrackMessage:null===(S=null==K?void 0:K.backTrackExtra)||void 0===S?void 0:S[0],setBackTrackMessage:null===(H=null==K?void 0:K.backTrackExtra)||void 0===H?void 0:H[1]})),null===(P=null!=$&&$>-1?F.cards[$].buttons:null==F?void 0:F.buttons)||void 0===P?void 0:P.map(((o,e)=>{if("QUICK_REPLY"===o.type)return n(h,{variableListIndex:e,QRBoptions:null==T?void 0:T.QRBoptions,button:o,originalVariableList:null!=$&&$>-1?F.cards[$]:F,updateSelectedQRBTemplateBtn:ro},`${e}`)})),Y===l.CHATBOT&&no&&n(p,{discountCode:null===(Q=null==K?void 0:K.discountCodeExtra)||void 0===Q?void 0:Q[0],setDiscountCode:null===(W=null==K?void 0:K.discountCodeExtra)||void 0===W?void 0:W[1],variableList:x}),null===(_=null!=$&&$>-1?F.cards[$].buttons:null==F?void 0:F.buttons)||void 0===_?void 0:_.map(((o,e)=>{var t,i,l;if("COPY_CODE"===o.type)return n(u,{index:e,variable:{variableName:null!==(t=o.text)&&void 0!==t?t:"",updatedValue:null!==(i=o.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=o.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:po,componentType:"BUTTONS"},e)}))]}))};export{f as default};
1
+ import{jsxs as o,jsx as n}from"react/jsx-runtime";import{cloneDeep as e}from"lodash";import{useState as t,useEffect as i}from"react";import{POD as l}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as s}from"../context/templateModalContext.js";import{useAdditionalVariables as a}from"../custom-hooks/useAdditionalVariables.js";import{getAllDataFromTemplateComponent as d}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as r}from"./BackTrackComponent.js";import{DiscountCodeComponent as p}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as c}from"./EditMediaV2.style.js";import m from"./EditWhatsAppTemplateMediaV2.js";import u from"./VariableConnector.js";import{Container as v}from"./VariableConnectorsPanel.js";import b from"./VariableConnectorWhatsApp.js";import g from"./VariableEditorHeader.js";import h from"./WhatsAppTemplateCardButtonV2.js";const f=f=>{let{template:C,onTemplateChange:j,whatsappSpecificPickerMeta:T,showVariableModal:V,variableList:B,variableListForImage:x,discountCode:O,setDiscountCode:y}=f;var E,k,L,w,I,q,A,U,M,N,D,R,S,H,P,Q,W,_;const{originalVariableList:F,pod:Y,extras:K,selectedCarouselIndex:$}=s(),{descriptionComponents:X,urlBtns:z,qrbBtns:G,imageComponent:J,bodyVariables:Z,headerVariables:oo}=d(C),[no,eo]=t(!1),[to,io]=t(-1===$?{descriptionComponents:X,urlBtns:z,qrbBtns:G,imageComponent:J,bodyVariables:Z,headerVariables:oo}:{}),[lo,so]=t(!1);function ao(o,n){var t,i,l,s,a,d,r;const p=null!=$&&$>-1?{components:null===(t=Object.assign({},C).components[1].cards)||void 0===t?void 0:t[$].components,mapping:null===(i=Object.assign({},C).mapping.cards)||void 0===i?void 0:i[$]}:Object.assign({},C),c=null==p?void 0:p.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==c&&c>-1){const e=null===(l=null==p?void 0:p.components[c].buttons)||void 0===l?void 0:l.findIndex((o=>"URL"===o.type));if(void 0!==e&&e>-1){const t="custom"===n&&"string"==typeof o,i=[...null!==(d=null===(a=null===(s=p.components)||void 0===s?void 0:s[c])||void 0===a?void 0:a.buttons)&&void 0!==d?d:[]];i[e]=Object.assign(Object.assign({},i[e]),{url:"https://d.bik.ai/{{1}}",example:[t?o:"string"!=typeof o?o.defaultValue:""]});const l=Object.assign(Object.assign({},p.components[c]),{buttons:i}),r=Object.assign(Object.assign({},p.mapping),{buttons:t?["((customBtnPlaceholder))"]:"string"!=typeof o?[o.placeHolder]:void 0});p.mapping=r;const m=[...p.components];m[c]=l,p.components=m}}if("string"!=typeof o){"checkout.checkoutUrl"===(null===(r=o.placeHolder)||void 0===r?void 0:r.slice(2,-2))?eo(!0):(eo(!1),null==y||y(""))}if(null!=$&&$>-1){const o=e(C);o.components[1].cards[$].components=p.components,o.mapping.cards[$]=p.mapping,null==j||j(Object.assign({},o))}else null==j||j(p)}function ro(o,n,t){var i,l,s;console.log("template 55: ",C),console.log("qrbBtns 55: ",G),console.log("urlBtns 55: ",z);const a=null!=$&&$>-1?{components:null===(i=Object.assign({},C).components[1].cards)||void 0===i?void 0:i[$].components,mapping:null===(l=Object.assign({},C).mapping.cards)||void 0===l?void 0:l[$]}:Object.assign({},C),d=null==a?void 0:a.components.findIndex((o=>"BUTTONS"===o.type));if(void 0!==d&&d>-1){const n=null===(s=null==a?void 0:a.components[d].buttons)||void 0===s?void 0:s.filter((o=>"QUICK_REPLY"===o.type));n&&(n[t]=Object.assign(Object.assign({},n[t]),{flowId:o.flowId,flowName:o.flowName}));const e=Object.assign(Object.assign({},a.components[d]),{buttons:n}),i=[...a.components];i[d]=e,a.components=i}if(null!=$&&$>-1){const o=e(C);o.components[1].cards[$].components=a.components,o.mapping.cards[$]=a.mapping,null==j||j(Object.assign({},o))}else null==j||j(a)}i((()=>{var o,n;if(null===(o=C.mapping.buttons)||void 0===o?void 0:o.find((o=>"checkout.checkoutUrl"===o.slice(2,-2))))eo(!0);else{eo(!1);const o=null===(n=null==K?void 0:K.discountCodeExtra)||void 0===n?void 0:n[1];null==o||o("")}}),[C]),i((()=>{var o,n,e,t;if(null!=$&&$>-1){const i={components:null===(n=null===(o=C.components[1])||void 0===o?void 0:o.cards)||void 0===n?void 0:n[$].components,mapping:null===(t=null===(e=null==C?void 0:C.mapping)||void 0===e?void 0:e.cards)||void 0===t?void 0:t[$]},{descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);io({descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}),console.log("urlBtns 89: ",s),console.log("urlBtns 89: ",s)}else if(null!=$&&-1===$){const{descriptionComponents:o,urlBtns:n,qrbBtns:e,imageComponent:t,bodyVariables:i,headerVariables:l}=d(C);io({descriptionComponents:o,urlBtns:n,qrbBtns:e,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[$]),i((()=>{var o,n,e,t;if(console.log("right panel selectedCarouselIndex: ",$),null!=$&&$>-1&&lo){const i={components:null===(n=null===(o=C.components[1])||void 0===o?void 0:o.cards)||void 0===n?void 0:n[$].components,mapping:null===(t=null===(e=null==C?void 0:C.mapping)||void 0===e?void 0:e.cards)||void 0===t?void 0:t[$]},{descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);io({descriptionComponents:l,urlBtns:s,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}),so(!1)}}),[lo]);const po=a({variableList:B,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return o(v,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!to.imageComponent&&n(c,{children:n(m,{whatsappSpecificPickerMeta:T,mediaComponent:to.imageComponent,updateTemplateImageUrl:function(o,n){var t,i,l,s,a;let d;d=null!=$&&$>-1?{components:null===(i=null===(t=C.components[1])||void 0===t?void 0:t.cards)||void 0===i?void 0:i[$].components,mapping:null===(s=null===(l=null==C?void 0:C.mapping)||void 0===l?void 0:l.cards)||void 0===s?void 0:s[$]}:Object.assign({},C);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((o=>{if("HEADER"===o.type&&"NONE"!==o.format&&"TEXT"!==o.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const e=Object.assign(Object.assign({},d.components[r]),{format:n,example:{header_handle:[o]}}),t=[...d.components];t[r]=e,d=Object.assign(Object.assign({},d),{components:t})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=$&&$>-1){const o=e(C);o.components[1].cards[$].components=d.components,o.mapping.cards[$]=d.mapping,null==j||j(Object.assign({},o)),so(!0)}else null==j||j(Object.assign({},d))},template:C,variableListForImage:x})}),(to.bodyVariables.length>0||to.headerVariables.length>0)&&n(g,{containerStyle:{paddingTop:to.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===(E=to.descriptionComponents)||void 0===E?void 0:E.map(((o,e)=>n(b,{originalVariableList:null!=$&&$>-1?F.cards[$]:F,type:o.type,descriptionComponent:o.component,showVariableModal:V,variableList:B},e))),(null===(L=null===(k=to.urlBtns[0])||void 0===k?void 0:k.component)||void 0===L?void 0:L.buttons)&&(null===(q=null===(I=null===(w=to.urlBtns[0])||void 0===w?void 0:w.component)||void 0===I?void 0:I.buttons)||void 0===q?void 0:q.length)>0&&n(g,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(A=null!=$&&$>-1?F.cards[$].buttons:null==F?void 0:F.buttons)||void 0===A?void 0:A.map(((o,e)=>{if("URL"===o.type)return n(h,{variableListIndex:e,CTAoptions:null==T?void 0:T.CTAoptions,button:o,originalVariableList:null!=$&&$>-1?F.cards[$]:F,updateSelectedURLTemplateBtn:ao,variableList:B},`${e}`)})),(null===(M=null===(U=to.qrbBtns[0])||void 0===U?void 0:U.component)||void 0===M?void 0:M.buttons)&&(null===(R=null===(D=null===(N=to.qrbBtns[0])||void 0===N?void 0:N.component)||void 0===D?void 0:D.buttons)||void 0===R?void 0:R.length)>0&&(Y!==l.CHATBOT?n(g,{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"}):n(r,{backTrackMessage:null===(S=null==K?void 0:K.backTrackExtra)||void 0===S?void 0:S[0],setBackTrackMessage:null===(H=null==K?void 0:K.backTrackExtra)||void 0===H?void 0:H[1]})),null===(P=null!=$&&$>-1?F.cards[$].buttons:null==F?void 0:F.buttons)||void 0===P?void 0:P.map(((o,e)=>{if("QUICK_REPLY"===o.type)return n(h,{variableListIndex:e,QRBoptions:null==T?void 0:T.QRBoptions,button:o,originalVariableList:null!=$&&$>-1?F.cards[$]:F,updateSelectedQRBTemplateBtn:ro},`${e}`)})),Y===l.CHATBOT&&no&&n(p,{discountCode:null===(Q=null==K?void 0:K.discountCodeExtra)||void 0===Q?void 0:Q[0],setDiscountCode:null===(W=null==K?void 0:K.discountCodeExtra)||void 0===W?void 0:W[1],variableList:B}),null===(_=null!=$&&$>-1?F.cards[$].buttons:null==F?void 0:F.buttons)||void 0===_?void 0:_.map(((o,e)=>{var t,i,l;if("COPY_CODE"===o.type)return n(u,{index:e,variable:{variableName:null!==(t=o.text)&&void 0!==t?t:"",updatedValue:null!==(i=o.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(l=o.index)&&void 0!==l?l:0},showVariableModal:!0,variableList:po,componentType:"BUTTONS"},e)}))]}))};export{f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.433-beta.7",
3
+ "version": "0.0.433-beta.8",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",