@bikdotai/bik-component-library 0.0.407-beta.12 → 0.0.407-beta.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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("date-fns"),t=require("react"),o=require("./DateSelector/DateSelector.js"),s=require("../dropdown/DropdownPopover/index.js");require("../dropdown/Dropdown.js"),require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js");require("../../constants/Theme.js"),require("../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../checkBox/CheckBox.styled.js"),require("../list-item/ListItem.js"),require("../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js");var i=require("../input/Input.js");require("../dropdown/MenuItem/MenuItem.js");var d=require("../../utils/DateUtils.js"),u=require("../../assets/icons/chevronDown.svg.js"),a=require("../../assets/icons/clock.svg.js"),l=require("./CustomDateTime.styled.js");const c=()=>{const e=[];for(let r=0;r<2;r++)for(let t=0;t<12;t++){let o;o=0===t?"12":t<10?`0${t}`:`${t}`;const s=`${o}:00 ${0===r?"AM":"PM"}`,n=`${o}:30 ${0===r?"AM":"PM"}`;e.push({label:s,value:s,selected:!1},{label:n,value:n,selected:!1})}return e};exports.CustomDateTime=p=>{const[m,j]=t.useState(p.time),[D,w]=t.useState(p.date);t.useEffect((()=>{p.setError(void 0);const e=d.default.convert12HourTimeTo24Hour(m),t=r.format(new Date,"HH:mm:ss");if(r.isToday(D)&&e<t)return void p.setError("Selected time should be later than current time");p.setError(void 0);const[o,s]=e.split(":"),n=new Date(D.getTime());n.setHours(+o,+s),p.onChange(n)}),[D,m]);return e.jsxs(l.CustomDateTimeStyle,{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:16}},{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(o.default,{customDate:D,setCustomDate:w,placement:p.placement,minDate:p.minDate})})),e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(s.DropdownPopover,Object.assign({options:c(),onSelect:e=>{j(e.value)}},{children:e.jsx(i.Input,{value:m,leftIcon:{icon:a.default},rightIcon:{icon:u.default},onChangeText:e=>(e=>{if(d.default.timeFormatValidation(e)){const t=d.default.convert12HourTimeTo24Hour(e),o=r.format(new Date,"HH:mm:ss");if(r.isToday(D)&&t<o)return void p.setError("Selected time should be later than current time");p.setError(void 0),j(e)}else p.setError('Format of time should be "HH:MM AM" or "HH:MM PM"')})(e)})}))}))]})),p.error&&e.jsx(n.BodySecondary,Object.assign({style:{paddingTop:8}},{children:p.error}))]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("date-fns"),t=require("react"),o=require("./DateSelector/DateSelector.js"),s=require("../dropdown/DropdownPopover/index.js");require("../dropdown/Dropdown.js"),require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js");require("../../constants/Theme.js"),require("../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../checkBox/CheckBox.styled.js"),require("../list-item/ListItem.js"),require("../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js");var i=require("../input/Input.js");require("../dropdown/MenuItem/MenuItem.js");var d=require("../../utils/DateUtils.js"),u=require("../../assets/icons/chevronDown.svg.js"),a=require("../../assets/icons/clock.svg.js"),l=require("./CustomDateTime.styled.js");const c=e=>{const r=[];for(let t=0;t<2;t++)for(let o=0;o<12;o++){let s;s=0===o?"12":o<10?`0${o}`:`${o}`;const n=`${s}:00 ${0===t?"AM":"PM"}`,i=`${s}:30 ${0===t?"AM":"PM"}`;r.push({label:n,value:n,selected:n===e},{label:i,value:i,selected:i===e})}return r};exports.CustomDateTime=p=>{const[m,j]=t.useState(p.time),[D,w]=t.useState(p.date);t.useEffect((()=>{p.setError(void 0);const e=d.default.convert12HourTimeTo24Hour(m),t=r.format(new Date,"HH:mm:ss");if(r.isToday(D)&&e<t)return void p.setError("Selected time should be later than current time");p.setError(void 0);const[o,s]=e.split(":"),n=new Date(D.getTime());n.setHours(+o,+s),p.onChange(n)}),[D,m]);return e.jsxs(l.CustomDateTimeStyle,{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:16}},{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(o.default,{customDate:D,setCustomDate:w,placement:p.placement,minDate:p.minDate})})),e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(s.DropdownPopover,Object.assign({options:c(m),onSelect:e=>{j(e.value)}},{children:e.jsx(i.Input,{value:m,leftIcon:{icon:a.default},rightIcon:{icon:u.default},onChangeText:e=>(e=>{if(d.default.timeFormatValidation(e)){const t=d.default.convert12HourTimeTo24Hour(e),o=r.format(new Date,"HH:mm:ss");if(r.isToday(D)&&t<o)return void p.setError("Selected time should be later than current time");p.setError(void 0),j(e)}else p.setError('Format of time should be "HH:MM AM" or "HH:MM PM"')})(e)})}))}))]})),p.error&&e.jsx(n.BodySecondary,Object.assign({style:{paddingTop:8}},{children:p.error}))]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("../../template-preview/models/WhatsAppTemplate.js"),i=require("../context/templateModalContext.js"),n=require("../custom-hooks/useAdditionalVariables.js"),a=require("../utils/getDataFromTemplateComponent.js"),l=require("./BackTrackComponent.js"),s=require("./DiscountCodeComponent.js"),d=require("./EditMediaV2.style.js"),r=require("./EditWhatsAppTemplateMediaV2.js"),u=require("./VariableConnector.js"),c=require("./VariableConnectorsPanel.js"),p=require("./VariableConnectorWhatsApp.js"),v=require("./VariableEditorHeader.js"),b=require("./WhatsAppTemplateCardButtonV2.js");exports.default=m=>{let{template:g,onTemplateChange:h,whatsappSpecificPickerMeta:f,showVariableModal:j,variableList:x,variableListForImage:T,discountCode:C,setDiscountCode:O}=m;var y,E,V,k,L,B,q,w,I,A,D,M,U,N,P,R,S;const{originalVariableList:H,pod:_,extras:Q}=i.useTemplateModalContext(),{descriptionComponents:W,urlBtns:F,qrbBtns:Y,imageComponent:K,bodyVariables:$,headerVariables:X}=a.getAllDataFromTemplateComponent(g),[z,G]=t.useState(!1);function J(e,t){var o,i,n,a,l;const s=Object.assign({},g),d=null==s?void 0:s.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==d&&d>-1){const l=null===(o=null==s?void 0:s.components[d].buttons)||void 0===o?void 0:o.findIndex((e=>"URL"===e.type));if(void 0!==l&&l>-1){const o="custom"===t&&"string"==typeof e,r=[...null!==(a=null===(n=null===(i=s.components)||void 0===i?void 0:i[d])||void 0===n?void 0:n.buttons)&&void 0!==a?a:[]];r[l]=Object.assign(Object.assign({},r[l]),{url:"https://d.bik.ai/{{1}}",example:[o?e:"string"!=typeof e?e.defaultValue:""]});const u=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:o?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});s.mapping=c;const p=[...s.components];p[d]=u,s.components=p}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(l=e.placeHolder)||void 0===l?void 0:l.slice(2,-2))?G(!0):(G(!1),null==O||O(""))}null==h||h(s)}function Z(e,t,o){var i;const n=Object.assign({},g),a=null==n?void 0:n.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==a&&a>-1){const t=null===(i=null==n?void 0:n.components[a].buttons)||void 0===i?void 0:i.filter((e=>"QUICK_REPLY"===e.type));t&&(t[o]=Object.assign(Object.assign({},t[o]),{flowId:e.flowId,flowName:e.flowName}));const l=Object.assign(Object.assign({},n.components[a]),{buttons:t}),s=[...n.components];s[a]=l,n.components=s}null==h||h(n)}t.useEffect((()=>{var e;const t=null===(e=g.mapping.buttons)||void 0===e?void 0:e[0];"checkout.checkoutUrl"===(null==t?void 0:t.slice(2,-2))?G(!0):(G(!1),null==O||O(""))}),[g]);const ee=n.useAdditionalVariables({variableList:x,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return e.jsxs(c.Container,Object.assign({style:{flexDirection:"column",maxWidth:400,maxHeight:460}},{children:[!!K&&e.jsx(d.EditTemplateMediaContainer,{children:e.jsx(r.default,{whatsappSpecificPickerMeta:f,mediaComponent:K,updateTemplateImageUrl:function(e,t){var o;let i=Object.assign({},g);const n=null===(o=null==i?void 0:i.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==n&&n>-1&&(null==i?void 0:i.components[n])){const o=Object.assign(Object.assign({},i.components[n]),{format:t,example:{header_handle:[e]}}),a=[...i.components];a[n]=o,i=Object.assign(Object.assign({},i),{components:a})}i.mapping&&(i.mapping=Object.assign(Object.assign({},i.mapping),{header:void 0})),null==h||h(Object.assign({},i))},template:g,variableListForImage:T})}),($.length>0||X.length>0)&&e.jsx(v.default,{containerStyle:{paddingTop:K?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==W?void 0:W.map(((t,o)=>e.jsx(p.default,{originalVariableList:H,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?g.mapping.header:g.mapping.body,showVariableModal:j,variableList:x},o))),(null===(E=null===(y=F[0])||void 0===y?void 0:y.component)||void 0===E?void 0:E.buttons)&&(null===(L=null===(k=null===(V=F[0])||void 0===V?void 0:V.component)||void 0===k?void 0:k.buttons)||void 0===L?void 0:L.length)>0&&e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(B=null==H?void 0:H.buttons)||void 0===B?void 0:B.map(((t,o)=>{if("URL"===t.type)return e.jsx(b.default,{variableListIndex:o,CTAoptions:null==f?void 0:f.CTAoptions,button:t,originalVariableList:H,updateSelectedURLTemplateBtn:J,variableList:x},`${o}`)})),(null===(w=null===(q=Y[0])||void 0===q?void 0:q.component)||void 0===w?void 0:w.buttons)&&(null===(D=null===(A=null===(I=Y[0])||void 0===I?void 0:I.component)||void 0===A?void 0:A.buttons)||void 0===D?void 0:D.length)>0&&(_!==o.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(l.BackTrackComponent,{backTrackMessage:null===(M=null==Q?void 0:Q.backTrackExtra)||void 0===M?void 0:M[0],setBackTrackMessage:null===(U=null==Q?void 0:Q.backTrackExtra)||void 0===U?void 0:U[1]})),null===(N=null==H?void 0:H.buttons)||void 0===N?void 0:N.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e.jsx(b.default,{variableListIndex:o,QRBoptions:null==f?void 0:f.QRBoptions,button:t,originalVariableList:H,updateSelectedQRBTemplateBtn:Z},`${o}`)})),_===o.POD.CHATBOT&&z&&e.jsx(s.DiscountCodeComponent,{discountCode:null===(P=null==Q?void 0:Q.discountCodeExtra)||void 0===P?void 0:P[0],setDiscountCode:null===(R=null==Q?void 0:Q.discountCodeExtra)||void 0===R?void 0:R[1],variableList:x}),null===(S=null==H?void 0:H.buttons)||void 0===S?void 0:S.map(((t,o)=>{var i,n,a;if("COPY_CODE"===t.type)return e.jsx(u.default,{index:o,variable:{variableName:null!==(i=t.text)&&void 0!==i?i:"",updatedValue:null!==(n=t.buttonVariable)&&void 0!==n?n:"",type:"string",isEditableVariable:!0,index:null!==(a=t.index)&&void 0!==a?a:0},showVariableModal:!0,variableList:ee,componentType:"BUTTONS"},o)}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("../../template-preview/models/WhatsAppTemplate.js"),i=require("../context/templateModalContext.js"),n=require("../custom-hooks/useAdditionalVariables.js"),a=require("../utils/getDataFromTemplateComponent.js"),l=require("./BackTrackComponent.js"),s=require("./DiscountCodeComponent.js"),d=require("./EditMediaV2.style.js"),r=require("./EditWhatsAppTemplateMediaV2.js"),u=require("./VariableConnector.js"),c=require("./VariableConnectorsPanel.js"),p=require("./VariableConnectorWhatsApp.js"),v=require("./VariableEditorHeader.js"),b=require("./WhatsAppTemplateCardButtonV2.js");exports.default=m=>{let{template:g,onTemplateChange:h,whatsappSpecificPickerMeta:f,showVariableModal:j,variableList:x,variableListForImage:T,discountCode:C,setDiscountCode:O}=m;var y,E,V,k,L,w,B,q,I,A,D,M,U,N,P,R,S;const{originalVariableList:H,pod:_,extras:Q}=i.useTemplateModalContext(),{descriptionComponents:F,urlBtns:W,qrbBtns:Y,imageComponent:K,bodyVariables:$,headerVariables:X}=a.getAllDataFromTemplateComponent(g),[z,G]=t.useState(!1);function J(e,t){var o,i,n,a,l;const s=Object.assign({},g),d=null==s?void 0:s.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==d&&d>-1){const l=null===(o=null==s?void 0:s.components[d].buttons)||void 0===o?void 0:o.findIndex((e=>"URL"===e.type));if(void 0!==l&&l>-1){const o="custom"===t&&"string"==typeof e,r=[...null!==(a=null===(n=null===(i=s.components)||void 0===i?void 0:i[d])||void 0===n?void 0:n.buttons)&&void 0!==a?a:[]];r[l]=Object.assign(Object.assign({},r[l]),{url:"https://d.bik.ai/{{1}}",example:[o?e:"string"!=typeof e?e.defaultValue:""]});const u=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:o?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});s.mapping=c;const p=[...s.components];p[d]=u,s.components=p}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(l=e.placeHolder)||void 0===l?void 0:l.slice(2,-2))?G(!0):(G(!1),null==O||O(""))}null==h||h(s)}function Z(e,t,o){var i;const n=Object.assign({},g),a=null==n?void 0:n.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==a&&a>-1){const t=null===(i=null==n?void 0:n.components[a].buttons)||void 0===i?void 0:i.filter((e=>"QUICK_REPLY"===e.type));t&&(t[o]=Object.assign(Object.assign({},t[o]),{flowId:e.flowId,flowName:e.flowName}));const l=Object.assign(Object.assign({},n.components[a]),{buttons:t}),s=[...n.components];s[a]=l,n.components=s}null==h||h(n)}t.useEffect((()=>{var e;const t=null===(e=g.mapping.buttons)||void 0===e?void 0:e[0];"checkout.checkoutUrl"===(null==t?void 0:t.slice(2,-2))?G(!0):(G(!1),null==O||O(""))}),[g]);const ee=n.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:[!!K&&e.jsx(d.EditTemplateMediaContainer,{children:e.jsx(r.default,{whatsappSpecificPickerMeta:f,mediaComponent:K,updateTemplateImageUrl:function(e,t){var o;let i=Object.assign({},g);const n=null===(o=null==i?void 0:i.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==n&&n>-1&&(null==i?void 0:i.components[n])){const o=Object.assign(Object.assign({},i.components[n]),{format:t,example:{header_handle:[e]}}),a=[...i.components];a[n]=o,i=Object.assign(Object.assign({},i),{components:a})}i.mapping&&(i.mapping=Object.assign(Object.assign({},i.mapping),{header:void 0})),null==h||h(Object.assign({},i))},template:g,variableListForImage:T})}),($.length>0||X.length>0)&&e.jsx(v.default,{containerStyle:{paddingTop:K?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==F?void 0:F.map(((t,o)=>e.jsx(p.default,{originalVariableList:H,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?g.mapping.header:g.mapping.body,showVariableModal:j,variableList:x},o))),(null===(E=null===(y=W[0])||void 0===y?void 0:y.component)||void 0===E?void 0:E.buttons)&&(null===(L=null===(k=null===(V=W[0])||void 0===V?void 0:V.component)||void 0===k?void 0:k.buttons)||void 0===L?void 0:L.length)>0&&e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(w=null==H?void 0:H.buttons)||void 0===w?void 0:w.map(((t,o)=>{if("URL"===t.type)return e.jsx(b.default,{variableListIndex:o,CTAoptions:null==f?void 0:f.CTAoptions,button:t,originalVariableList:H,updateSelectedURLTemplateBtn:J,variableList:x},`${o}`)})),(null===(q=null===(B=Y[0])||void 0===B?void 0:B.component)||void 0===q?void 0:q.buttons)&&(null===(D=null===(A=null===(I=Y[0])||void 0===I?void 0:I.component)||void 0===A?void 0:A.buttons)||void 0===D?void 0:D.length)>0&&(_!==o.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(l.BackTrackComponent,{backTrackMessage:null===(M=null==Q?void 0:Q.backTrackExtra)||void 0===M?void 0:M[0],setBackTrackMessage:null===(U=null==Q?void 0:Q.backTrackExtra)||void 0===U?void 0:U[1]})),null===(N=null==H?void 0:H.buttons)||void 0===N?void 0:N.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e.jsx(b.default,{variableListIndex:o,QRBoptions:null==f?void 0:f.QRBoptions,button:t,originalVariableList:H,updateSelectedQRBTemplateBtn:Z},`${o}`)})),_===o.POD.CHATBOT&&z&&e.jsx(s.DiscountCodeComponent,{discountCode:null===(P=null==Q?void 0:Q.discountCodeExtra)||void 0===P?void 0:P[0],setDiscountCode:null===(R=null==Q?void 0:Q.discountCodeExtra)||void 0===R?void 0:R[1],variableList:x}),null===(S=null==H?void 0:H.buttons)||void 0===S?void 0:S.map(((t,o)=>{var i,n,a;if("COPY_CODE"===t.type)return e.jsx(u.default,{index:o,variable:{variableName:null!==(i=t.text)&&void 0!==i?i:"",updatedValue:null!==(n=t.buttonVariable)&&void 0!==n?n:"",type:"string",isEditableVariable:!0,index:null!==(a=t.index)&&void 0!==a?a:0},showVariableModal:!0,variableList:ee,componentType:"BUTTONS"},o)}))]}))};
@@ -1,7 +1,7 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("date-fns"),a=require("react"),i=require("styled-components"),n=require("../../add-variableV2/AddVariableV2SideModal.js"),o=require("../../custom-date-time/CustomDateTime.js"),s=require("../../dropdown/Dropdown.js"),u=require("../../input/Input.js"),d=require("../../product-picker-v2/collectionScreen.js"),r=require("../../template-preview/constants/regexPatterns.js"),c=require("../../template-preview/models/Channels.js"),p=require("../../template-preview/models/WhatsAppTemplate.js"),m=require("../../TypographyStyle.js"),v=require("../../../utils/StringUtils.js"),b=require("../../../constants/Theme.js"),g=require("../context/templateModalContext.js"),x=require("../utils/getVariableNameEmail.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const j=h(i).default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("date-fns"),a=require("react"),i=require("styled-components"),n=require("../../add-variableV2/AddVariableV2SideModal.js"),o=require("../../custom-date-time/CustomDateTime.js"),s=require("../../dropdown/Dropdown.js"),u=require("../../input/Input.js"),d=require("../../product-picker-v2/collectionScreen.js"),r=require("../../template-preview/constants/regexPatterns.js"),c=require("../../template-preview/models/Channels.js"),p=require("../../template-preview/models/WhatsAppTemplate.js"),m=require("../../TypographyStyle.js"),v=require("../../../utils/StringUtils.js"),b=require("../../../constants/Theme.js"),g=require("../context/templateModalContext.js"),h=require("../utils/getVariableNameEmail.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const j=x(i).default.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
4
  background: ${e=>e.focused&&e.channel===c.CHANNEL_TYPE.EMAIL?b.COLORS.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,_={value:"custom_link",label:"Custom URL"},O={value:"custom_text",label:"Custom text"},E={value:"static_expiry",label:"Static Expiry"};exports.Container=j,exports.default=i=>{let{onFocus:h,variable:y,index:f,showVariableModal:T,variableList:A,setShowDiscountCheckBox:N,componentType:S,CTAoptions:V}=i;var C,P;const[k,L]=a.useState(!1),[H,w]=a.useState(""),[B,D]=a.useState([]),[q,Y]=a.useState(),[M,R]=a.useState(!1),[U,W]=a.useState(!1),{device:I,channel:$,isError:z,originalVariableList:Z,template:F,templateSelectionTriggered:G,setTemplate:J,setDisplayContent:K,setOriginalVariableList:Q,globalNormalizedPlaceholders:X,enabledCustomText:ee,pod:te}=g.useTemplateModalContext();function le(e,t){var l,a,i;const n=e;w(""),console.log("vj: single option",n),Y(n),$===c.CHANNEL_TYPE.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(ie(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ne||ne(null!==(a=y.index)&&void 0!==a?a:0,n.value,!0)):(null==ne||ne(null!==(i=y.index)&&void 0!==i?i:0,H,!0,n.value),ie("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?ie(n.value,"url"===n.bikPlaceholderType?"link":"string"):(w(""),ie("",n.value))}function ae(e,t){var l;w(t);const a="custom_link"===(null==q?void 0:q.value)&&t?t.includes("https")?t:`https://${t}`:t;ie(a,"static_expiry"===e?"string":e),$===c.CHANNEL_TYPE.WHATSAPP&&(null==ne||ne(null!==(l=y.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function ie(e,t){var l,a,i,n;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if($!==c.CHANNEL_TYPE.WHATSAPP){const a=x.getVariableNameForEmailByIndex(f+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===I?"template_html_mobile":"template_html_desktop"),n=$===c.CHANNEL_TYPE.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:y.variableName);const s=Z.map(((t,l)=>l===f?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==Q||Q(s)}if($===c.CHANNEL_TYPE.WHATSAPP){const l=Z;let s=l.body,u=l.header,d=l.buttons;"BODY"===S?s=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===f?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===S?u=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===f?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===S&&(d=null===(n=l.buttons)||void 0===n?void 0:n.map(((l,a)=>a===f?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null==Q||Q((e=>Object.assign(Object.assign({},e),{header:u,body:s,buttons:d})))}}function ne(e,t,l,a){var i,n,o,s;const u=Object.assign({},F);console.log("vj: update",{index:e,newValue:t,type:a});const d=null===(i=null==u?void 0:u.components)||void 0===i?void 0:i.map((l=>{var a,i,n,o,s,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===S){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===S){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===S){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===S)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(console.log("vj: update components",d),u.components=d,l)if("BODY"===S&&(null===(n=null==u?void 0:u.mapping)||void 0===n?void 0:n.body))u.mapping=Object.assign(Object.assign({},u.mapping),{body:u.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===S&&(null===(o=null==u?void 0:u.mapping)||void 0===o?void 0:o.header))u.mapping=Object.assign(Object.assign({},u.mapping),{header:u.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===S&&(null===(s=null==u?void 0:u.mapping)||void 0===s?void 0:s.buttons)){let l=-1,i=-1;d.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),u.mapping=Object.assign(Object.assign({},u.mapping),{buttons:u.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}null==J||J(Object.assign({},u))}return a.useEffect((()=>{k&&(null==h||h())}),[k]),a.useEffect((()=>{!function(){var e,t,l,a,i;const n="mobile"===I?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);$===c.CHANNEL_TYPE.EMAIL&&(null==K||K(s))}()}),[G]),a.useEffect((()=>{var e,t;const l=[];let a=[];if($!==c.CHANNEL_TYPE.MESSAGE||ee){"link"===(null==y?void 0:y.type)?(l.push({label:"",options:[_,O]}),Y(_)):"date_time"===(null==y?void 0:y.type)?(l.push({label:"",options:[_,O]}),Y(E)):(l.push({label:"",options:[_,O,E]}),Y(O));const e=null!=X?X:[];D([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:v.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=X?X:[];D([{label:"",options:[O,_]},...e]),a=[{label:"",options:[O,_]},...e]}if(($===c.CHANNEL_TYPE.WHATSAPP||$===c.CHANNEL_TYPE.EMAIL||$===c.CHANNEL_TYPE.MESSAGE)&&y.updatedValue)if(r.placeHolderNamePattern.test(y.updatedValue)&&$===c.CHANNEL_TYPE.WHATSAPP||y.updatedValue.startsWith("{{")&&$!==c.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===c.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(T){let t=e.updatedValue;if(te===p.POD.CHATBOT&&"BUTTONS"===S){const l=null==V?void 0:V.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(y,a,$);e.value&&Y(e)}else"date_time"===y.type?(Y(E),w(y.updatedValue),ne(null!==(e=y.index)&&void 0!==e?e:0,y.updatedValue)):(null===(t=y.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(Y(_),w(y.updatedValue.split("https://")[1])):(Y(O),w(y.updatedValue))}),[]),a.useEffect((()=>{I&&q&&H&&setTimeout((()=>{ie("custom_link"===(null==q?void 0:q.value)&&H?H.includes("https")?H:`https://${H}`:H,q.value)}),100)}),[I]),a.useEffect((()=>{!U&&q&&y.updatedValue&&setTimeout((()=>{ie("custom_link"===(null==q?void 0:q.value)&&y.updatedValue?y.updatedValue.includes("https")?y.updatedValue:`https://${y.updatedValue}`:y.updatedValue,q.value),W(!0)}),100)}),[q]),e.jsxs(j,Object.assign({channel:$,focused:k,onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(m.BodySecondary,Object.assign({style:{color:z&&!q?b.COLORS.content.negative:b.COLORS.content.primary}},{children:[null===(C=y.variableName)||void 0===C?void 0:C.replace("{{","").replace("}}","")," ","link"===(null==y?void 0:y.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:T?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==q?void 0:q.label)?"space-between":"flex-end"}},{children:[e.jsx(m.BodyPrimary,{children:d.truncate(null!==(P=null==q?void 0:q.label)&&void 0!==P?P:"",20,!0)}),e.jsx(t.default,{onClick:()=>{R(!M)},width:24,height:24,color:b.COLORS.content.primary})]})):e.jsx(s.Dropdown,{options:B,isSearchable:!1,onSelect:le,defaultOptions:q?[Object.assign(Object.assign({},q),{selected:!0})]:[]})})),("custom_text"===(null==q?void 0:q.value)||"custom_link"===(null==q?void 0:q.value))&&e.jsx(u.Input,{labelText:"custom_text"===(null==q?void 0:q.value)?"Custom text value":"custom_link"===(null==q?void 0:q.value)?"Custom URL value":"",id:`variable-value-${null==q?void 0:q.value}-${f}`,value:H,errorMessage:z?H&&0!==H.trim().length?"custom_link"!==q.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${H.trim()}`)&&0!==H.trim().length?"custom_link"!==q.value&&H.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==q?void 0:q.value)?2e3:"BUTTONS"===S?15:30,prefixText:"custom_link"===(null==q?void 0:q.value)?"https://":"",placeholder:"link"===y.type||"custom_link"===q.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{ae(q.value,e)}}),"static_expiry"===(null==q?void 0:q.value)&&e.jsx(o.CustomDateTime,{placement:"auto",time:H?l.format(new Date(H),"hh:mm a"):l.format(new Date,"hh:mm a"),date:H?new Date(H):new Date,minDate:new Date,error:"",setError:function(e){},onChange:e=>{console.log("vj: change date",e),ae("static_expiry",e.toISOString())}}),M&&e.jsx(n.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:M,setShowVariable:R,placeholder:"Add a variable",customTrigger:e=>{null==N||N(!1),"{{custom.url}}"===e.actualValue?le({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?le({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?le({label:e.displayName,selected:!0,value:"static_expiry"}):le({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
7
+ `,_={value:"custom_link",label:"Custom URL"},O={value:"custom_text",label:"Custom text"},f={value:"static_expiry",label:"Static Expiry"};exports.Container=j,exports.default=i=>{let{onFocus:x,variable:E,index:y,showVariableModal:T,variableList:A,setShowDiscountCheckBox:N,componentType:S,CTAoptions:V}=i;var C,P;const[k,L]=a.useState(!1),[H,w]=a.useState(""),[B,D]=a.useState([]),[q,Y]=a.useState(),[M,R]=a.useState(!1),[U,W]=a.useState(!1),{device:I,channel:$,isError:z,originalVariableList:Z,template:F,templateSelectionTriggered:G,setTemplate:J,setDisplayContent:K,setOriginalVariableList:Q,globalNormalizedPlaceholders:X,enabledCustomText:ee,pod:te}=g.useTemplateModalContext();function le(e,t){var l,a,i;const n=e;w(""),console.log("vj: single option",n),Y(n),$===c.CHANNEL_TYPE.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(ie(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ne||ne(null!==(a=E.index)&&void 0!==a?a:0,n.value,!0)):(null==ne||ne(null!==(i=E.index)&&void 0!==i?i:0,H,!0,n.value),ie("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?ie(n.value,"url"===n.bikPlaceholderType?"link":"string"):(w(""),ie("",n.value))}function ae(e,t){var l;w(t);const a="custom_link"===(null==q?void 0:q.value)&&t?t.includes("https")?t:`https://${t}`:t;ie(a,"static_expiry"===e?"string":e),$===c.CHANNEL_TYPE.WHATSAPP&&(null==ne||ne(null!==(l=E.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function ie(e,t){var l,a,i,n;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if($!==c.CHANNEL_TYPE.WHATSAPP){const a=h.getVariableNameForEmailByIndex(y+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===I?"template_html_mobile":"template_html_desktop"),n=$===c.CHANNEL_TYPE.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:E.variableName);const s=Z.map(((t,l)=>l===y?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==Q||Q(s)}if($===c.CHANNEL_TYPE.WHATSAPP){const l=Z;let s=l.body,u=l.header,d=l.buttons;"BODY"===S?s=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===y?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===S?u=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===y?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===S&&(d=null===(n=l.buttons)||void 0===n?void 0:n.map(((l,a)=>a===y?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null==Q||Q((e=>Object.assign(Object.assign({},e),{header:u,body:s,buttons:d})))}}function ne(e,t,l,a){var i,n,o,s;const u=Object.assign({},F);console.log("vj: update",{index:e,newValue:t,type:a});const d=null===(i=null==u?void 0:u.components)||void 0===i?void 0:i.map((l=>{var a,i,n,o,s,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===S){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===S){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===S){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===S)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(console.log("vj: update components",d),u.components=d,l)if("BODY"===S&&(null===(n=null==u?void 0:u.mapping)||void 0===n?void 0:n.body))u.mapping=Object.assign(Object.assign({},u.mapping),{body:u.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===S&&(null===(o=null==u?void 0:u.mapping)||void 0===o?void 0:o.header))u.mapping=Object.assign(Object.assign({},u.mapping),{header:u.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===S&&(null===(s=null==u?void 0:u.mapping)||void 0===s?void 0:s.buttons)){let l=-1,i=-1;d.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),u.mapping=Object.assign(Object.assign({},u.mapping),{buttons:u.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}null==J||J(Object.assign({},u))}a.useEffect((()=>{k&&(null==x||x())}),[k]),a.useEffect((()=>{!function(){var e,t,l,a,i;const n="mobile"===I?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);$===c.CHANNEL_TYPE.EMAIL&&(null==K||K(s))}()}),[G]),a.useEffect((()=>{var e,t;const l=[];let a=[];if($!==c.CHANNEL_TYPE.MESSAGE||ee){"link"===(null==E?void 0:E.type)?(l.push({label:"",options:[_,O]}),Y(_)):"date_time"===(null==E?void 0:E.type)?(l.push({label:"",options:[_,O]}),Y(f)):(l.push({label:"",options:[_,O,f]}),Y(O));const e=null!=X?X:[];D([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:v.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=X?X:[];D([{label:"",options:[O,_]},...e]),a=[{label:"",options:[O,_]},...e]}if(($===c.CHANNEL_TYPE.WHATSAPP||$===c.CHANNEL_TYPE.EMAIL||$===c.CHANNEL_TYPE.MESSAGE)&&E.updatedValue)if(r.placeHolderNamePattern.test(E.updatedValue)&&$===c.CHANNEL_TYPE.WHATSAPP||E.updatedValue.startsWith("{{")&&$!==c.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===c.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(T){let t=e.updatedValue;if(te===p.POD.CHATBOT&&"BUTTONS"===S){const l=null==V?void 0:V.filter((t=>t.placeHolder===e.updatedValue));t=l&&l.length>0?l[0].label:oe(e.updatedValue)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(E,a,$);e.value&&Y(e)}else"date_time"===E.type?(Y(f),w(E.updatedValue),ne(null!==(e=E.index)&&void 0!==e?e:0,E.updatedValue)):(null===(t=E.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(Y(_),w(E.updatedValue.split("https://")[1])):(Y(O),w(E.updatedValue))}),[]),a.useEffect((()=>{I&&q&&H&&setTimeout((()=>{ie("custom_link"===(null==q?void 0:q.value)&&H?H.includes("https")?H:`https://${H}`:H,q.value)}),100)}),[I]),a.useEffect((()=>{!U&&q&&E.updatedValue&&setTimeout((()=>{ie("custom_link"===(null==q?void 0:q.value)&&E.updatedValue?E.updatedValue.includes("https")?E.updatedValue:`https://${E.updatedValue}`:E.updatedValue,q.value),W(!0)}),100)}),[q]);const oe=e=>{let t;return null==A||A.forEach((l=>{var a;const i=null!==(a=l.variables)&&void 0!==a?a:{};Object.keys(i).forEach((l=>{var a;const n=i[l];n.isSubHeader&&Object.keys(null!==(a=n.variables)&&void 0!==a?a:[]).forEach((l=>{if(n.variables){const a=n.variables[l];if(a.actualValue===e)return void(t=a.displayName)}}))}))})),t};return e.jsxs(j,Object.assign({channel:$,focused:k,onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(m.BodySecondary,Object.assign({style:{color:z&&!q?b.COLORS.content.negative:b.COLORS.content.primary}},{children:[null===(C=E.variableName)||void 0===C?void 0:C.replace("{{","").replace("}}","")," ","link"===(null==E?void 0:E.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:T?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==q?void 0:q.label)?"space-between":"flex-end"}},{children:[e.jsx(m.BodyPrimary,{children:d.truncate(null!==(P=null==q?void 0:q.label)&&void 0!==P?P:"",20,!0)}),e.jsx(t.default,{onClick:()=>{R(!M)},width:24,height:24,color:b.COLORS.content.primary})]})):e.jsx(s.Dropdown,{options:B,isSearchable:!1,onSelect:le,defaultOptions:q?[Object.assign(Object.assign({},q),{selected:!0})]:[]})})),("custom_text"===(null==q?void 0:q.value)||"custom_link"===(null==q?void 0:q.value))&&e.jsx(u.Input,{labelText:"custom_text"===(null==q?void 0:q.value)?"Custom text value":"custom_link"===(null==q?void 0:q.value)?"Custom URL value":"",id:`variable-value-${null==q?void 0:q.value}-${y}`,value:H,errorMessage:z?H&&0!==H.trim().length?"custom_link"!==q.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${H.trim()}`)&&0!==H.trim().length?"custom_link"!==q.value&&H.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==q?void 0:q.value)?2e3:"BUTTONS"===S?15:30,prefixText:"custom_link"===(null==q?void 0:q.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===q.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{ae(q.value,e)}}),"static_expiry"===(null==q?void 0:q.value)&&e.jsx(o.CustomDateTime,{placement:"auto",time:H?l.format(new Date(H),"hh:mm a"):l.format(new Date,"hh:mm a"),date:H?new Date(H):new Date,minDate:new Date,error:"",setError:function(e){},onChange:e=>{console.log("vj: change date",e),ae("static_expiry",e.toISOString())}}),M&&e.jsx(n.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:M,setShowVariable:R,placeholder:"Add a variable",customTrigger:e=>{null==N||N(!1),"{{custom.url}}"===e.actualValue?le({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?le({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?le({label:e.displayName,selected:!0,value:"static_expiry"}):le({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../assets/icons/lto_icon.svg.js"),r=require("styled-components"),i=require("../../../TypographyStyle.js"),n=require("../../../../constants/Theme.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(r);const d=o.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../assets/icons/lto_icon.svg.js"),r=require("styled-components"),n=require("../../../TypographyStyle.js"),i=require("../../../../constants/Theme.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(r);const d=o.default.div`
2
2
  display: flex;
3
3
  flex-direction: row;
4
4
  background: #f6f6f6;
5
- width: 152px;
6
5
  margin: 0px 10px;
7
- `,c=o.default.div`
6
+ overflow: hidden;
7
+ `,l=o.default.div`
8
8
  width: 48px;
9
9
  height: 48px;
10
10
  display: flex;
@@ -13,9 +13,8 @@
13
13
  border-radius: 24px;
14
14
  background: #d8f0e7;
15
15
  margin: 5px;
16
- `,l=o.default.div`
16
+ `,c=o.default.div`
17
17
  display: flex;
18
18
  flex-direction: column;
19
- margin-top: 5px;
20
- margin-right: 3px;
21
- `;exports.LimitedTimeOffer=r=>{const{text:s,dateTime:o,code:a}=r;return e.jsxs(d,{children:[e.jsx(c,{children:e.jsx(t.default,{width:24,height:24,style:{display:"flex"}})}),e.jsxs(l,{children:[e.jsx(i.BodySecondary,Object.assign({numberOfLines:2,color:n.COLORS.content.primary},{children:s})),e.jsxs(i.BodyTiny,Object.assign({numberOfLines:2,color:n.COLORS.content.secondary},{children:["Ends on ",o]})),e.jsxs(i.BodyTiny,Object.assign({numberOfLines:2,color:n.COLORS.content.placeholder},{children:["Code ",a]}))]})]})},exports.StyledLimitedOfferTime=d,exports.StyledLtoIcon=c,exports.StyledLtoText=l;
19
+ flex: 1;
20
+ `;exports.LimitedTimeOffer=r=>{const{text:s,dateTime:o,code:a}=r;return e.jsxs(d,{children:[e.jsx(l,{children:e.jsx(t.default,{width:24,height:24,style:{display:"flex"}})}),e.jsxs(c,{children:[e.jsx(n.BodySecondary,Object.assign({numberOfLines:2,color:i.COLORS.content.primary},{children:s})),e.jsxs(n.BodyTiny,Object.assign({numberOfLines:3,style:{overflowWrap:"anywhere"},color:i.COLORS.content.secondary},{children:["Ends on ",o]})),e.jsxs(n.BodyTiny,Object.assign({numberOfLines:2,color:i.COLORS.content.placeholder},{children:["Code ",a]}))]})]})},exports.StyledLimitedOfferTime=d,exports.StyledLtoIcon=l,exports.StyledLtoText=c;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as o}from"react/jsx-runtime";import{format as t,isToday as r}from"date-fns";import{useState as n,useEffect as s}from"react";import i from"./DateSelector/DateSelector.js";import{DropdownPopover as m}from"../dropdown/DropdownPopover/index.js";import"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{BodySecondary as p}from"../TypographyStyle.js";import"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import{Input as d}from"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import l from"../../utils/DateUtils.js";import c from"../../assets/icons/chevronDown.svg.js";import a from"../../assets/icons/clock.svg.js";import{CustomDateTimeStyle as u}from"./CustomDateTime.styled.js";const j=()=>{const e=[];for(let o=0;o<2;o++)for(let t=0;t<12;t++){let r;r=0===t?"12":t<10?`0${t}`:`${t}`;const n=`${r}:00 ${0===o?"AM":"PM"}`,s=`${r}:30 ${0===o?"AM":"PM"}`;e.push({label:n,value:n,selected:!1},{label:s,value:s,selected:!1})}return e},w=w=>{const[D,f]=n(w.time),[h,v]=n(w.date);s((()=>{w.setError(void 0);const e=l.convert12HourTimeTo24Hour(D),o=t(new Date,"HH:mm:ss");if(r(h)&&e<o)return void w.setError("Selected time should be later than current time");w.setError(void 0);const[n,s]=e.split(":"),i=new Date(h.getTime());i.setHours(+n,+s),w.onChange(i)}),[h,D]);return e(u,{children:[e("div",Object.assign({style:{display:"flex",gap:16}},{children:[o("div",Object.assign({style:{flex:1}},{children:o(i,{customDate:h,setCustomDate:v,placement:w.placement,minDate:w.minDate})})),o("div",Object.assign({style:{flex:1}},{children:o(m,Object.assign({options:j(),onSelect:e=>{f(e.value)}},{children:o(d,{value:D,leftIcon:{icon:a},rightIcon:{icon:c},onChangeText:e=>(e=>{if(l.timeFormatValidation(e)){const o=l.convert12HourTimeTo24Hour(e),n=t(new Date,"HH:mm:ss");if(r(h)&&o<n)return void w.setError("Selected time should be later than current time");w.setError(void 0),f(e)}else w.setError('Format of time should be "HH:MM AM" or "HH:MM PM"')})(e)})}))}))]})),w.error&&o(p,Object.assign({style:{paddingTop:8}},{children:w.error}))]})};export{w as CustomDateTime};
1
+ import{jsxs as e,jsx as o}from"react/jsx-runtime";import{format as t,isToday as r}from"date-fns";import{useState as n,useEffect as s}from"react";import i from"./DateSelector/DateSelector.js";import{DropdownPopover as m}from"../dropdown/DropdownPopover/index.js";import"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{BodySecondary as p}from"../TypographyStyle.js";import"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import{Input as d}from"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import l from"../../utils/DateUtils.js";import c from"../../assets/icons/chevronDown.svg.js";import a from"../../assets/icons/clock.svg.js";import{CustomDateTimeStyle as u}from"./CustomDateTime.styled.js";const j=e=>{const o=[];for(let t=0;t<2;t++)for(let r=0;r<12;r++){let n;n=0===r?"12":r<10?`0${r}`:`${r}`;const s=`${n}:00 ${0===t?"AM":"PM"}`,i=`${n}:30 ${0===t?"AM":"PM"}`;o.push({label:s,value:s,selected:s===e},{label:i,value:i,selected:i===e})}return o},w=w=>{const[D,f]=n(w.time),[h,v]=n(w.date);s((()=>{w.setError(void 0);const e=l.convert12HourTimeTo24Hour(D),o=t(new Date,"HH:mm:ss");if(r(h)&&e<o)return void w.setError("Selected time should be later than current time");w.setError(void 0);const[n,s]=e.split(":"),i=new Date(h.getTime());i.setHours(+n,+s),w.onChange(i)}),[h,D]);return e(u,{children:[e("div",Object.assign({style:{display:"flex",gap:16}},{children:[o("div",Object.assign({style:{flex:1}},{children:o(i,{customDate:h,setCustomDate:v,placement:w.placement,minDate:w.minDate})})),o("div",Object.assign({style:{flex:1}},{children:o(m,Object.assign({options:j(D),onSelect:e=>{f(e.value)}},{children:o(d,{value:D,leftIcon:{icon:a},rightIcon:{icon:c},onChangeText:e=>(e=>{if(l.timeFormatValidation(e)){const o=l.convert12HourTimeTo24Hour(e),n=t(new Date,"HH:mm:ss");if(r(h)&&o<n)return void w.setError("Selected time should be later than current time");w.setError(void 0),f(e)}else w.setError('Format of time should be "HH:MM AM" or "HH:MM PM"')})(e)})}))}))]})),w.error&&o(p,Object.assign({style:{paddingTop:8}},{children:w.error}))]})};export{w as CustomDateTime};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as e,useEffect as i}from"react";import{POD as n}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as a}from"../context/templateModalContext.js";import{useAdditionalVariables as l}from"../custom-hooks/useAdditionalVariables.js";import{getAllDataFromTemplateComponent as s}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as d}from"./BackTrackComponent.js";import{DiscountCodeComponent as r}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as p}from"./EditMediaV2.style.js";import c from"./EditWhatsAppTemplateMediaV2.js";import u from"./VariableConnector.js";import{Container as m}from"./VariableConnectorsPanel.js";import v from"./VariableConnectorWhatsApp.js";import b from"./VariableEditorHeader.js";import g from"./WhatsAppTemplateCardButtonV2.js";const h=h=>{let{template:f,onTemplateChange:T,whatsappSpecificPickerMeta:j,showVariableModal:x,variableList:C,variableListForImage:O,discountCode:y,setDiscountCode:V}=h;var E,k,L,w,B,I,A,M,U,D,N,R,H,S,P,Q,W;const{originalVariableList:_,pod:F,extras:Y}=a(),{descriptionComponents:K,urlBtns:$,qrbBtns:q,imageComponent:X,bodyVariables:z,headerVariables:G}=s(f),[J,Z]=e(!1);function tt(t,o){var e,i,n,a,l;const s=Object.assign({},f),d=null==s?void 0:s.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==d&&d>-1){const l=null===(e=null==s?void 0:s.components[d].buttons)||void 0===e?void 0:e.findIndex((t=>"URL"===t.type));if(void 0!==l&&l>-1){const e="custom"===o&&"string"==typeof t,r=[...null!==(a=null===(n=null===(i=s.components)||void 0===i?void 0:i[d])||void 0===n?void 0:n.buttons)&&void 0!==a?a:[]];r[l]=Object.assign(Object.assign({},r[l]),{url:"https://d.bik.ai/{{1}}",example:[e?t:"string"!=typeof t?t.defaultValue:""]});const p=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:e?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});s.mapping=c;const u=[...s.components];u[d]=p,s.components=u}}if("string"!=typeof t){"checkout.checkoutUrl"===(null===(l=t.placeHolder)||void 0===l?void 0:l.slice(2,-2))?Z(!0):(Z(!1),null==V||V(""))}null==T||T(s)}function ot(t,o,e){var i;const n=Object.assign({},f),a=null==n?void 0:n.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==a&&a>-1){const o=null===(i=null==n?void 0:n.components[a].buttons)||void 0===i?void 0:i.filter((t=>"QUICK_REPLY"===t.type));o&&(o[e]=Object.assign(Object.assign({},o[e]),{flowId:t.flowId,flowName:t.flowName}));const l=Object.assign(Object.assign({},n.components[a]),{buttons:o}),s=[...n.components];s[a]=l,n.components=s}null==T||T(n)}i((()=>{var t;const o=null===(t=f.mapping.buttons)||void 0===t?void 0:t[0];"checkout.checkoutUrl"===(null==o?void 0:o.slice(2,-2))?Z(!0):(Z(!1),null==V||V(""))}),[f]);const et=l({variableList:C,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return t(m,Object.assign({style:{flexDirection:"column",maxWidth:400,maxHeight:460}},{children:[!!X&&o(p,{children:o(c,{whatsappSpecificPickerMeta:j,mediaComponent:X,updateTemplateImageUrl:function(t,o){var e;let i=Object.assign({},f);const n=null===(e=null==i?void 0:i.components)||void 0===e?void 0:e.findIndex((t=>{if("HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format)return!0}));if(void 0!==n&&n>-1&&(null==i?void 0:i.components[n])){const e=Object.assign(Object.assign({},i.components[n]),{format:o,example:{header_handle:[t]}}),a=[...i.components];a[n]=e,i=Object.assign(Object.assign({},i),{components:a})}i.mapping&&(i.mapping=Object.assign(Object.assign({},i.mapping),{header:void 0})),null==T||T(Object.assign({},i))},template:f,variableListForImage:O})}),(z.length>0||G.length>0)&&o(b,{containerStyle:{paddingTop:X?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?void 0:K.map(((t,e)=>o(v,{originalVariableList:_,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?f.mapping.header:f.mapping.body,showVariableModal:x,variableList:C},e))),(null===(k=null===(E=$[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)&&(null===(B=null===(w=null===(L=$[0])||void 0===L?void 0:L.component)||void 0===w?void 0:w.buttons)||void 0===B?void 0:B.length)>0&&o(b,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(I=null==_?void 0:_.buttons)||void 0===I?void 0:I.map(((t,e)=>{if("URL"===t.type)return o(g,{variableListIndex:e,CTAoptions:null==j?void 0:j.CTAoptions,button:t,originalVariableList:_,updateSelectedURLTemplateBtn:tt,variableList:C},`${e}`)})),(null===(M=null===(A=q[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)&&(null===(N=null===(D=null===(U=q[0])||void 0===U?void 0:U.component)||void 0===D?void 0:D.buttons)||void 0===N?void 0:N.length)>0&&(F!==n.CHATBOT?o(b,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):o(d,{backTrackMessage:null===(R=null==Y?void 0:Y.backTrackExtra)||void 0===R?void 0:R[0],setBackTrackMessage:null===(H=null==Y?void 0:Y.backTrackExtra)||void 0===H?void 0:H[1]})),null===(S=null==_?void 0:_.buttons)||void 0===S?void 0:S.map(((t,e)=>{if("QUICK_REPLY"===t.type)return o(g,{variableListIndex:e,QRBoptions:null==j?void 0:j.QRBoptions,button:t,originalVariableList:_,updateSelectedQRBTemplateBtn:ot},`${e}`)})),F===n.CHATBOT&&J&&o(r,{discountCode:null===(P=null==Y?void 0:Y.discountCodeExtra)||void 0===P?void 0:P[0],setDiscountCode:null===(Q=null==Y?void 0:Y.discountCodeExtra)||void 0===Q?void 0:Q[1],variableList:C}),null===(W=null==_?void 0:_.buttons)||void 0===W?void 0:W.map(((t,e)=>{var i,n,a;if("COPY_CODE"===t.type)return o(u,{index:e,variable:{variableName:null!==(i=t.text)&&void 0!==i?i:"",updatedValue:null!==(n=t.buttonVariable)&&void 0!==n?n:"",type:"string",isEditableVariable:!0,index:null!==(a=t.index)&&void 0!==a?a:0},showVariableModal:!0,variableList:et,componentType:"BUTTONS"},e)}))]}))};export{h as default};
1
+ import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as e,useEffect as i}from"react";import{POD as n}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as a}from"../context/templateModalContext.js";import{useAdditionalVariables as l}from"../custom-hooks/useAdditionalVariables.js";import{getAllDataFromTemplateComponent as s}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as d}from"./BackTrackComponent.js";import{DiscountCodeComponent as r}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as p}from"./EditMediaV2.style.js";import c from"./EditWhatsAppTemplateMediaV2.js";import u from"./VariableConnector.js";import{Container as m}from"./VariableConnectorsPanel.js";import v from"./VariableConnectorWhatsApp.js";import b from"./VariableEditorHeader.js";import g from"./WhatsAppTemplateCardButtonV2.js";const h=h=>{let{template:f,onTemplateChange:T,whatsappSpecificPickerMeta:j,showVariableModal:x,variableList:C,variableListForImage:O,discountCode:y,setDiscountCode:V}=h;var E,k,L,w,B,I,A,M,U,D,N,R,H,S,P,Q,W;const{originalVariableList:_,pod:F,extras:Y}=a(),{descriptionComponents:K,urlBtns:$,qrbBtns:q,imageComponent:X,bodyVariables:z,headerVariables:G}=s(f),[J,Z]=e(!1);function tt(t,o){var e,i,n,a,l;const s=Object.assign({},f),d=null==s?void 0:s.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==d&&d>-1){const l=null===(e=null==s?void 0:s.components[d].buttons)||void 0===e?void 0:e.findIndex((t=>"URL"===t.type));if(void 0!==l&&l>-1){const e="custom"===o&&"string"==typeof t,r=[...null!==(a=null===(n=null===(i=s.components)||void 0===i?void 0:i[d])||void 0===n?void 0:n.buttons)&&void 0!==a?a:[]];r[l]=Object.assign(Object.assign({},r[l]),{url:"https://d.bik.ai/{{1}}",example:[e?t:"string"!=typeof t?t.defaultValue:""]});const p=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:e?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});s.mapping=c;const u=[...s.components];u[d]=p,s.components=u}}if("string"!=typeof t){"checkout.checkoutUrl"===(null===(l=t.placeHolder)||void 0===l?void 0:l.slice(2,-2))?Z(!0):(Z(!1),null==V||V(""))}null==T||T(s)}function ot(t,o,e){var i;const n=Object.assign({},f),a=null==n?void 0:n.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==a&&a>-1){const o=null===(i=null==n?void 0:n.components[a].buttons)||void 0===i?void 0:i.filter((t=>"QUICK_REPLY"===t.type));o&&(o[e]=Object.assign(Object.assign({},o[e]),{flowId:t.flowId,flowName:t.flowName}));const l=Object.assign(Object.assign({},n.components[a]),{buttons:o}),s=[...n.components];s[a]=l,n.components=s}null==T||T(n)}i((()=>{var t;const o=null===(t=f.mapping.buttons)||void 0===t?void 0:t[0];"checkout.checkoutUrl"===(null==o?void 0:o.slice(2,-2))?Z(!0):(Z(!1),null==V||V(""))}),[f]);const et=l({variableList:C,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return t(m,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!X&&o(p,{children:o(c,{whatsappSpecificPickerMeta:j,mediaComponent:X,updateTemplateImageUrl:function(t,o){var e;let i=Object.assign({},f);const n=null===(e=null==i?void 0:i.components)||void 0===e?void 0:e.findIndex((t=>{if("HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format)return!0}));if(void 0!==n&&n>-1&&(null==i?void 0:i.components[n])){const e=Object.assign(Object.assign({},i.components[n]),{format:o,example:{header_handle:[t]}}),a=[...i.components];a[n]=e,i=Object.assign(Object.assign({},i),{components:a})}i.mapping&&(i.mapping=Object.assign(Object.assign({},i.mapping),{header:void 0})),null==T||T(Object.assign({},i))},template:f,variableListForImage:O})}),(z.length>0||G.length>0)&&o(b,{containerStyle:{paddingTop:X?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?void 0:K.map(((t,e)=>o(v,{originalVariableList:_,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?f.mapping.header:f.mapping.body,showVariableModal:x,variableList:C},e))),(null===(k=null===(E=$[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)&&(null===(B=null===(w=null===(L=$[0])||void 0===L?void 0:L.component)||void 0===w?void 0:w.buttons)||void 0===B?void 0:B.length)>0&&o(b,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(I=null==_?void 0:_.buttons)||void 0===I?void 0:I.map(((t,e)=>{if("URL"===t.type)return o(g,{variableListIndex:e,CTAoptions:null==j?void 0:j.CTAoptions,button:t,originalVariableList:_,updateSelectedURLTemplateBtn:tt,variableList:C},`${e}`)})),(null===(M=null===(A=q[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)&&(null===(N=null===(D=null===(U=q[0])||void 0===U?void 0:U.component)||void 0===D?void 0:D.buttons)||void 0===N?void 0:N.length)>0&&(F!==n.CHATBOT?o(b,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):o(d,{backTrackMessage:null===(R=null==Y?void 0:Y.backTrackExtra)||void 0===R?void 0:R[0],setBackTrackMessage:null===(H=null==Y?void 0:Y.backTrackExtra)||void 0===H?void 0:H[1]})),null===(S=null==_?void 0:_.buttons)||void 0===S?void 0:S.map(((t,e)=>{if("QUICK_REPLY"===t.type)return o(g,{variableListIndex:e,QRBoptions:null==j?void 0:j.QRBoptions,button:t,originalVariableList:_,updateSelectedQRBTemplateBtn:ot},`${e}`)})),F===n.CHATBOT&&J&&o(r,{discountCode:null===(P=null==Y?void 0:Y.discountCodeExtra)||void 0===P?void 0:P[0],setDiscountCode:null===(Q=null==Y?void 0:Y.discountCodeExtra)||void 0===Q?void 0:Q[1],variableList:C}),null===(W=null==_?void 0:_.buttons)||void 0===W?void 0:W.map(((t,e)=>{var i,n,a;if("COPY_CODE"===t.type)return o(u,{index:e,variable:{variableName:null!==(i=t.text)&&void 0!==i?i:"",updatedValue:null!==(n=t.buttonVariable)&&void 0!==n?n:"",type:"string",isEditableVariable:!0,index:null!==(a=t.index)&&void 0!==a?a:0},showVariableModal:!0,variableList:et,componentType:"BUTTONS"},e)}))]}))};export{h as default};
@@ -1,7 +1,7 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import l from"../../../assets/icons/edit.svg.js";import{format as a}from"date-fns";import{useState as i,useEffect as n}from"react";import o from"styled-components";import{AddVariableV2SideModal as s}from"../../add-variableV2/AddVariableV2SideModal.js";import{CustomDateTime as u}from"../../custom-date-time/CustomDateTime.js";import{Dropdown as d}from"../../dropdown/Dropdown.js";import{Input as r}from"../../input/Input.js";import{truncate as c}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as p}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as m}from"../../template-preview/models/Channels.js";import{POD as v}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as b,BodyPrimary as g}from"../../TypographyStyle.js";import h from"../../../utils/StringUtils.js";import{COLORS as x}from"../../../constants/Theme.js";import{useTemplateModalContext as j}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as f}from"../utils/getVariableNameEmail.js";const y=o.div`
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import l from"../../../assets/icons/edit.svg.js";import{format as a}from"date-fns";import{useState as i,useEffect as n}from"react";import o from"styled-components";import{AddVariableV2SideModal as s}from"../../add-variableV2/AddVariableV2SideModal.js";import{CustomDateTime as u}from"../../custom-date-time/CustomDateTime.js";import{Dropdown as d}from"../../dropdown/Dropdown.js";import{Input as r}from"../../input/Input.js";import{truncate as c}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as p}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as m}from"../../template-preview/models/Channels.js";import{POD as v}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as b,BodyPrimary as g}from"../../TypographyStyle.js";import h from"../../../utils/StringUtils.js";import{COLORS as f}from"../../../constants/Theme.js";import{useTemplateModalContext as x}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as j}from"../utils/getVariableNameEmail.js";const y=o.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
- background: ${e=>e.focused&&e.channel===m.EMAIL?x.background.warning.light:"transparent"};
4
+ background: ${e=>e.focused&&e.channel===m.EMAIL?f.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,O={value:"custom_link",label:"Custom URL"},_={value:"custom_text",label:"Custom text"},T={value:"static_expiry",label:"Static Expiry"},V=o=>{let{onFocus:V,variable:k,index:A,showVariableModal:E,variableList:S,setShowDiscountCheckBox:w,componentType:P,CTAoptions:C}=o;var B,L;const[D,N]=i(!1),[H,M]=i(""),[U,W]=i([]),[R,$]=i(),[I,z]=i(!1),[Y,Z]=i(!1),{device:G,channel:q,isError:F,originalVariableList:J,template:K,templateSelectionTriggered:Q,setTemplate:X,setDisplayContent:ee,setOriginalVariableList:te,globalNormalizedPlaceholders:le,enabledCustomText:ae,pod:ie}=j();function ne(e,t){var l,a,i;const n=e;M(""),console.log("vj: single option",n),$(n),q===m.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(se(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ue||ue(null!==(a=k.index)&&void 0!==a?a:0,n.value,!0)):(null==ue||ue(null!==(i=k.index)&&void 0!==i?i:0,H,!0,n.value),se("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?se(n.value,"url"===n.bikPlaceholderType?"link":"string"):(M(""),se("",n.value))}function oe(e,t){var l;M(t);const a="custom_link"===(null==R?void 0:R.value)&&t?t.includes("https")?t:`https://${t}`:t;se(a,"static_expiry"===e?"string":e),q===m.WHATSAPP&&(null==ue||ue(null!==(l=k.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function se(e,t){var l,a,i,n;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(q!==m.WHATSAPP){const a=f(A+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===G?"template_html_mobile":"template_html_desktop"),n=q===m.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:k.variableName);const s=J.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==te||te(s)}if(q===m.WHATSAPP){const l=J;let s=l.body,u=l.header,d=l.buttons;"BODY"===P?s=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===P?u=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===P&&(d=null===(n=l.buttons)||void 0===n?void 0:n.map(((l,a)=>a===A?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null==te||te((e=>Object.assign(Object.assign({},e),{header:u,body:s,buttons:d})))}}function ue(e,t,l,a){var i,n,o,s;const u=Object.assign({},K);console.log("vj: update",{index:e,newValue:t,type:a});const d=null===(i=null==u?void 0:u.components)||void 0===i?void 0:i.map((l=>{var a,i,n,o,s,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===P){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===P){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===P){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===P)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(console.log("vj: update components",d),u.components=d,l)if("BODY"===P&&(null===(n=null==u?void 0:u.mapping)||void 0===n?void 0:n.body))u.mapping=Object.assign(Object.assign({},u.mapping),{body:u.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===P&&(null===(o=null==u?void 0:u.mapping)||void 0===o?void 0:o.header))u.mapping=Object.assign(Object.assign({},u.mapping),{header:u.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===P&&(null===(s=null==u?void 0:u.mapping)||void 0===s?void 0:s.buttons)){let l=-1,i=-1;d.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),u.mapping=Object.assign(Object.assign({},u.mapping),{buttons:u.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}null==X||X(Object.assign({},u))}return n((()=>{D&&(null==V||V())}),[D]),n((()=>{!function(){var e,t,l,a,i;const n="mobile"===G?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);q===m.EMAIL&&(null==ee||ee(s))}()}),[Q]),n((()=>{var e,t;const l=[];let a=[];if(q!==m.MESSAGE||ae){"link"===(null==k?void 0:k.type)?(l.push({label:"",options:[O,_]}),$(O)):"date_time"===(null==k?void 0:k.type)?(l.push({label:"",options:[O,_]}),$(T)):(l.push({label:"",options:[O,_,T]}),$(_));const e=null!=le?le:[];W([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:h.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=le?le:[];W([{label:"",options:[_,O]},...e]),a=[{label:"",options:[_,O]},...e]}if((q===m.WHATSAPP||q===m.EMAIL||q===m.MESSAGE)&&k.updatedValue)if(p.test(k.updatedValue)&&q===m.WHATSAPP||k.updatedValue.startsWith("{{")&&q!==m.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===m.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(E){let t=e.updatedValue;if(ie===v.CHATBOT&&"BUTTONS"===P){const l=null==C?void 0:C.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(k,a,q);e.value&&$(e)}else"date_time"===k.type?($(T),M(k.updatedValue),ue(null!==(e=k.index)&&void 0!==e?e:0,k.updatedValue)):(null===(t=k.updatedValue)||void 0===t?void 0:t.startsWith("https"))?($(O),M(k.updatedValue.split("https://")[1])):($(_),M(k.updatedValue))}),[]),n((()=>{G&&R&&H&&setTimeout((()=>{se("custom_link"===(null==R?void 0:R.value)&&H?H.includes("https")?H:`https://${H}`:H,R.value)}),100)}),[G]),n((()=>{!Y&&R&&k.updatedValue&&setTimeout((()=>{se("custom_link"===(null==R?void 0:R.value)&&k.updatedValue?k.updatedValue.includes("https")?k.updatedValue:`https://${k.updatedValue}`:k.updatedValue,R.value),Z(!0)}),100)}),[R]),e(y,Object.assign({channel:q,focused:D,onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(b,Object.assign({style:{color:F&&!R?x.content.negative:x.content.primary}},{children:[null===(B=k.variableName)||void 0===B?void 0:B.replace("{{","").replace("}}","")," ","link"===(null==k?void 0:k.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:E?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==R?void 0:R.label)?"space-between":"flex-end"}},{children:[t(g,{children:c(null!==(L=null==R?void 0:R.label)&&void 0!==L?L:"",20,!0)}),t(l,{onClick:()=>{z(!I)},width:24,height:24,color:x.content.primary})]})):t(d,{options:U,isSearchable:!1,onSelect:ne,defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),("custom_text"===(null==R?void 0:R.value)||"custom_link"===(null==R?void 0:R.value))&&t(r,{labelText:"custom_text"===(null==R?void 0:R.value)?"Custom text value":"custom_link"===(null==R?void 0:R.value)?"Custom URL value":"",id:`variable-value-${null==R?void 0:R.value}-${A}`,value:H,errorMessage:F?H&&0!==H.trim().length?"custom_link"!==R.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${H.trim()}`)&&0!==H.trim().length?"custom_link"!==R.value&&H.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==R?void 0:R.value)?2e3:"BUTTONS"===P?15:30,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"link"===k.type||"custom_link"===R.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{oe(R.value,e)}}),"static_expiry"===(null==R?void 0:R.value)&&t(u,{placement:"auto",time:a(H?new Date(H):new Date,"hh:mm a"),date:H?new Date(H):new Date,minDate:new Date,error:"",setError:function(e){},onChange:e=>{console.log("vj: change date",e),oe("static_expiry",e.toISOString())}}),I&&t(s,{zIndex:2e3,data:null!=S?S:[],showVariable:I,setShowVariable:z,placeholder:"Add a variable",customTrigger:e=>{null==w||w(!1),"{{custom.url}}"===e.actualValue?ne({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ne({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ne({label:e.displayName,selected:!0,value:"static_expiry"}):ne({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{y as Container,V as default};
7
+ `,O={value:"custom_link",label:"Custom URL"},_={value:"custom_text",label:"Custom text"},T={value:"static_expiry",label:"Static Expiry"},V=o=>{let{onFocus:V,variable:k,index:E,showVariableModal:A,variableList:S,setShowDiscountCheckBox:w,componentType:P,CTAoptions:C}=o;var B,L;const[D,N]=i(!1),[H,M]=i(""),[U,W]=i([]),[R,$]=i(),[I,z]=i(!1),[Y,Z]=i(!1),{device:G,channel:q,isError:F,originalVariableList:J,template:K,templateSelectionTriggered:Q,setTemplate:X,setDisplayContent:ee,setOriginalVariableList:te,globalNormalizedPlaceholders:le,enabledCustomText:ae,pod:ie}=x();function ne(e,t){var l,a,i;const n=e;M(""),console.log("vj: single option",n),$(n),q===m.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(se(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ue||ue(null!==(a=k.index)&&void 0!==a?a:0,n.value,!0)):(null==ue||ue(null!==(i=k.index)&&void 0!==i?i:0,H,!0,n.value),se("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?se(n.value,"url"===n.bikPlaceholderType?"link":"string"):(M(""),se("",n.value))}function oe(e,t){var l;M(t);const a="custom_link"===(null==R?void 0:R.value)&&t?t.includes("https")?t:`https://${t}`:t;se(a,"static_expiry"===e?"string":e),q===m.WHATSAPP&&(null==ue||ue(null!==(l=k.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function se(e,t){var l,a,i,n;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(q!==m.WHATSAPP){const a=j(E+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===G?"template_html_mobile":"template_html_desktop"),n=q===m.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:k.variableName);const s=J.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==te||te(s)}if(q===m.WHATSAPP){const l=J;let s=l.body,u=l.header,d=l.buttons;"BODY"===P?s=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===P?u=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===E?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===P&&(d=null===(n=l.buttons)||void 0===n?void 0:n.map(((l,a)=>a===E?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null==te||te((e=>Object.assign(Object.assign({},e),{header:u,body:s,buttons:d})))}}function ue(e,t,l,a){var i,n,o,s;const u=Object.assign({},K);console.log("vj: update",{index:e,newValue:t,type:a});const d=null===(i=null==u?void 0:u.components)||void 0===i?void 0:i.map((l=>{var a,i,n,o,s,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===P){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=m.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===P){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===P){if(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}}else if("limited_time_offer"===l.type&&"limited_time_offer"===P)return Object.assign(Object.assign({},m),{example:Object.assign(Object.assign({},m.example),{limited_time_offer:t})});return l}));if(console.log("vj: update components",d),u.components=d,l)if("BODY"===P&&(null===(n=null==u?void 0:u.mapping)||void 0===n?void 0:n.body))u.mapping=Object.assign(Object.assign({},u.mapping),{body:u.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===P&&(null===(o=null==u?void 0:u.mapping)||void 0===o?void 0:o.header))u.mapping=Object.assign(Object.assign({},u.mapping),{header:u.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===P&&(null===(s=null==u?void 0:u.mapping)||void 0===s?void 0:s.buttons)){let l=-1,i=-1;d.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),u.mapping=Object.assign(Object.assign({},u.mapping),{buttons:u.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}null==X||X(Object.assign({},u))}n((()=>{D&&(null==V||V())}),[D]),n((()=>{!function(){var e,t,l,a,i;const n="mobile"===G?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);q===m.EMAIL&&(null==ee||ee(s))}()}),[Q]),n((()=>{var e,t;const l=[];let a=[];if(q!==m.MESSAGE||ae){"link"===(null==k?void 0:k.type)?(l.push({label:"",options:[O,_]}),$(O)):"date_time"===(null==k?void 0:k.type)?(l.push({label:"",options:[O,_]}),$(T)):(l.push({label:"",options:[O,_,T]}),$(_));const e=null!=le?le:[];W([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:h.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=le?le:[];W([{label:"",options:[_,O]},...e]),a=[{label:"",options:[_,O]},...e]}if((q===m.WHATSAPP||q===m.EMAIL||q===m.MESSAGE)&&k.updatedValue)if(p.test(k.updatedValue)&&q===m.WHATSAPP||k.updatedValue.startsWith("{{")&&q!==m.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===m.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(A){let t=e.updatedValue;if(ie===v.CHATBOT&&"BUTTONS"===P){const l=null==C?void 0:C.filter((t=>t.placeHolder===e.updatedValue));t=l&&l.length>0?l[0].label:de(e.updatedValue)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(k,a,q);e.value&&$(e)}else"date_time"===k.type?($(T),M(k.updatedValue),ue(null!==(e=k.index)&&void 0!==e?e:0,k.updatedValue)):(null===(t=k.updatedValue)||void 0===t?void 0:t.startsWith("https"))?($(O),M(k.updatedValue.split("https://")[1])):($(_),M(k.updatedValue))}),[]),n((()=>{G&&R&&H&&setTimeout((()=>{se("custom_link"===(null==R?void 0:R.value)&&H?H.includes("https")?H:`https://${H}`:H,R.value)}),100)}),[G]),n((()=>{!Y&&R&&k.updatedValue&&setTimeout((()=>{se("custom_link"===(null==R?void 0:R.value)&&k.updatedValue?k.updatedValue.includes("https")?k.updatedValue:`https://${k.updatedValue}`:k.updatedValue,R.value),Z(!0)}),100)}),[R]);const de=e=>{let t;return null==S||S.forEach((l=>{var a;const i=null!==(a=l.variables)&&void 0!==a?a:{};Object.keys(i).forEach((l=>{var a;const n=i[l];n.isSubHeader&&Object.keys(null!==(a=n.variables)&&void 0!==a?a:[]).forEach((l=>{if(n.variables){const a=n.variables[l];if(a.actualValue===e)return void(t=a.displayName)}}))}))})),t};return e(y,Object.assign({channel:q,focused:D,onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(b,Object.assign({style:{color:F&&!R?f.content.negative:f.content.primary}},{children:[null===(B=k.variableName)||void 0===B?void 0:B.replace("{{","").replace("}}","")," ","link"===(null==k?void 0:k.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:A?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==R?void 0:R.label)?"space-between":"flex-end"}},{children:[t(g,{children:c(null!==(L=null==R?void 0:R.label)&&void 0!==L?L:"",20,!0)}),t(l,{onClick:()=>{z(!I)},width:24,height:24,color:f.content.primary})]})):t(d,{options:U,isSearchable:!1,onSelect:ne,defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),("custom_text"===(null==R?void 0:R.value)||"custom_link"===(null==R?void 0:R.value))&&t(r,{labelText:"custom_text"===(null==R?void 0:R.value)?"Custom text value":"custom_link"===(null==R?void 0:R.value)?"Custom URL value":"",id:`variable-value-${null==R?void 0:R.value}-${E}`,value:H,errorMessage:F?H&&0!==H.trim().length?"custom_link"!==R.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${H.trim()}`)&&0!==H.trim().length?"custom_link"!==R.value&&H.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==R?void 0:R.value)?2e3:"BUTTONS"===P?15:30,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"link"===k.type||"custom_link"===R.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{oe(R.value,e)}}),"static_expiry"===(null==R?void 0:R.value)&&t(u,{placement:"auto",time:a(H?new Date(H):new Date,"hh:mm a"),date:H?new Date(H):new Date,minDate:new Date,error:"",setError:function(e){},onChange:e=>{console.log("vj: change date",e),oe("static_expiry",e.toISOString())}}),I&&t(s,{zIndex:2e3,data:null!=S?S:[],showVariable:I,setShowVariable:z,placeholder:"Add a variable",customTrigger:e=>{null==w||w(!1),"{{custom.url}}"===e.actualValue?ne({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ne({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ne({label:e.displayName,selected:!0,value:"static_expiry"}):ne({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{y as Container,V as default};
@@ -1,10 +1,10 @@
1
- import{jsxs as e,jsx as n}from"react/jsx-runtime";import i from"../../../../assets/icons/lto_icon.svg.js";import r from"styled-components";import{BodySecondary as t,BodyTiny as o}from"../../../TypographyStyle.js";import{COLORS as s}from"../../../../constants/Theme.js";const c=r=>{const{text:c,dateTime:m,code:a}=r;return e(d,{children:[n(l,{children:n(i,{width:24,height:24,style:{display:"flex"}})}),e(p,{children:[n(t,Object.assign({numberOfLines:2,color:s.content.primary},{children:c})),e(o,Object.assign({numberOfLines:2,color:s.content.secondary},{children:["Ends on ",m]})),e(o,Object.assign({numberOfLines:2,color:s.content.placeholder},{children:["Code ",a]}))]})]})},d=r.div`
1
+ import{jsxs as e,jsx as n}from"react/jsx-runtime";import r from"../../../../assets/icons/lto_icon.svg.js";import o from"styled-components";import{BodySecondary as i,BodyTiny as t}from"../../../TypographyStyle.js";import{COLORS as s}from"../../../../constants/Theme.js";const c=o=>{const{text:c,dateTime:f,code:m}=o;return e(d,{children:[n(l,{children:n(r,{width:24,height:24,style:{display:"flex"}})}),e(a,{children:[n(i,Object.assign({numberOfLines:2,color:s.content.primary},{children:c})),e(t,Object.assign({numberOfLines:3,style:{overflowWrap:"anywhere"},color:s.content.secondary},{children:["Ends on ",f]})),e(t,Object.assign({numberOfLines:2,color:s.content.placeholder},{children:["Code ",m]}))]})]})},d=o.div`
2
2
  display: flex;
3
3
  flex-direction: row;
4
4
  background: #f6f6f6;
5
- width: 152px;
6
5
  margin: 0px 10px;
7
- `,l=r.div`
6
+ overflow: hidden;
7
+ `,l=o.div`
8
8
  width: 48px;
9
9
  height: 48px;
10
10
  display: flex;
@@ -13,9 +13,8 @@ import{jsxs as e,jsx as n}from"react/jsx-runtime";import i from"../../../../asse
13
13
  border-radius: 24px;
14
14
  background: #d8f0e7;
15
15
  margin: 5px;
16
- `,p=r.div`
16
+ `,a=o.div`
17
17
  display: flex;
18
18
  flex-direction: column;
19
- margin-top: 5px;
20
- margin-right: 3px;
21
- `;export{c as LimitedTimeOffer,d as StyledLimitedOfferTime,l as StyledLtoIcon,p as StyledLtoText};
19
+ flex: 1;
20
+ `;export{c as LimitedTimeOffer,d as StyledLimitedOfferTime,l as StyledLtoIcon,a as StyledLtoText};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.407-beta.12",
3
+ "version": "0.0.407-beta.14",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",