@bikdotai/bik-component-library 0.0.654-beta-ctv.4 → 0.0.654-beta-ctv.6

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,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("../../../assets/icons/info.svg.js"),i=require("date-fns"),a=require("lodash"),n=require("react"),s=require("styled-components"),o=require("../../alerts/Alert.js"),u=require("../../alerts/AlertHelper.js"),d=require("../../custom-date-time/CustomDateTime.js"),r=require("../../dropdown/Dropdown.js"),c=require("../../input/Input.js"),p=require("../../product-picker-v2/collectionScreen.js"),v=require("../../template-preview/constants/regexPatterns.js"),m=require("../../template-preview/models/Channels.js"),b=require("../../template-preview/models/WebpushTemplate.js"),g=require("../../template-preview/models/WhatsAppTemplate.js"),O=require("../../TypographyStyle.js"),j=require("../../../utils/StringUtils.js"),x=require("../../../constants/Theme.js"),E=require("../context/templateModalContext.js"),T=require("../custom-hooks/useAdditionalVariables.js"),y=require("../utils/getVariableNameEmail.js"),_=require("./QueryParamsComponent.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var C=h(s);const f=C.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("../../../assets/icons/info.svg.js"),i=require("date-fns"),a=require("lodash"),n=require("react"),s=require("styled-components"),o=require("../../alerts/Alert.js"),u=require("../../alerts/AlertHelper.js"),d=require("../../custom-date-time/CustomDateTime.js"),r=require("../../dropdown/Dropdown.js"),c=require("../../input/Input.js"),p=require("../../product-picker-v2/collectionScreen.js"),v=require("../../template-preview/constants/regexPatterns.js"),m=require("../../template-preview/models/Channels.js"),b=require("../../template-preview/models/WebpushTemplate.js"),g=require("../../template-preview/models/WhatsAppTemplate.js"),O=require("../../TypographyStyle.js"),j=require("../../../utils/StringUtils.js"),x=require("../../../constants/Theme.js"),T=require("../context/templateModalContext.js"),E=require("../custom-hooks/useAdditionalVariables.js"),y=require("../utils/getVariableNameEmail.js"),_=require("./QueryParamsComponent.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=h(s);const C=f.default.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
4
  background: ${e=>e.focused&&e.channel===m.CHANNEL_TYPE.EMAIL?x.COLORS.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,N=C.default.div`
7
+ `,N=f.default.div`
8
8
  position: absolute;
9
9
  top: 0;
10
10
  left: 0;
@@ -12,8 +12,8 @@
12
12
  height: 100%;
13
13
  z-index: 1000;
14
14
  cursor: not-allowed;
15
- `,P=C.default.div`
15
+ `,P=f.default.div`
16
16
  height: 100%;
17
17
  width: 48%;
18
18
  background: rgba(0, 0, 0, 0.1);
19
- `,A={value:"custom_link",label:"Custom URL"},L={value:"custom_text",label:"Custom text"},S={value:"static_expiry",label:"Static Expiry"};exports.Container=f,exports.default=s=>{var h,C,V,H,k,B,D,Y,w;const{onFocus:U,variable:R,index:q,showVariableModal:I,setShowDiscountCheckBox:W,componentType:M,CTAoptions:$,buttonType:z}=s,[Z,F]=n.useState(!1),[G,Q]=n.useState(""),[K,J]=n.useState([]),[X,ee]=n.useState(),[te,le]=n.useState(!1),{variableList:ie,setVariableList:ae,setVariableCallback:ne,setShowVariablePicker:se,device:oe,channel:ue,isError:de,originalVariableList:re,template:ce,templateSelectionTriggered:pe,setTemplate:ve,setDisplayContent:me,setOriginalVariableList:be,globalNormalizedPlaceholders:ge,enabledCustomText:Oe,pod:je,selectedCarouselIndex:xe,isProductCarouselType:Ee,isWhatsappCarousel:Te,disableEditVariable:ye,disableEditExpiry:_e,templateErrorIndexes:he,maxCharLimit:Ce,disableDatePicker:fe,showDiscountCodeExpiryInfo:Ne,cardIndex:Pe=1}=E.useTemplateModalContext();function Ae(e,t){var l,i,a,n;const s=e;Q(""),ee(s),ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS?"custom_text"!==s.value&&"custom_link"!==s.value&&"static_expiry"!==s.value?(Se(null!==(l=s.value)&&void 0!==l?l:"","string"),null==Ve||Ve(null!==(i=R.index)&&void 0!==i?i:0,s.value,!0)):(null==Ve||Ve(null!==(a=R.index)&&void 0!==a?a:0,"",!0,s.value),Se("","url"===s.bikPlaceholderType?"link":"string")):"custom_text"!==s.value&&"custom_link"!==s.value?(Se(s.value,"url"===s.bikPlaceholderType?"link":"string"),ue==m.CHANNEL_TYPE.WEBPUSH&&(null==ke||ke(null!==(n=R.index)&&void 0!==n?n:0,s.value))):(Q(""),Se("",s.value))}function Le(e,t){var l,i;Q(t);const a="custom_link"===(null==X?void 0:X.value)&&t?t.includes("https")?t:`https://${t}`:t;Se(a,"static_expiry"===e?"string":e),ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.RCS||null==Ve||Ve(null!==(l=R.index)&&void 0!==l?l:0,a,"custom_link"===e,e),ue===m.CHANNEL_TYPE.WEBPUSH&&(null==ke||ke(null!==(i=R.index)&&void 0!==i?i:0,a))}function Se(e,t,l){var i,n,s,o,u;const d="custom_link"===t?"link":"custom_text"===t?"string":t;if(ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.WEBPUSH&&ue!==m.CHANNEL_TYPE.RCS){const l=y.getVariableNameForEmailByIndex(q+1),a=null===document||void 0===document?void 0:document.getElementById("mobile"===oe?"template_html_mobile":"template_html_desktop"),n=ue===m.CHANNEL_TYPE.EMAIL?null===(i=null==a?void 0:a.contentWindow)||void 0===i?void 0:i.document.getElementById(l):document.getElementById(l);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:R.variableName);const s=re.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t));null==be||be(s)}if(ue===m.CHANNEL_TYPE.WEBPUSH){const t=re,l=t=>null==t?void 0:t.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)),i={BODY:"BODY"===M?l(t.body):t.body,TITLE:M===b.WEB_PUSH_COMPONENT_TYPE.TITLE.toUpperCase()?l(t.title):t.title};null==be||be((e=>Object.assign(Object.assign({},e),{title:i.TITLE,body:i.BODY,buttons:t.buttons})))}if(ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS){if(null!=xe&&xe>-1&&Ee){const l=Object.assign({},re).cards.map(((l,i)=>{var a,n,s;return"BODY"===M?Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>q===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"TITLE"===M?Object.assign(Object.assign({},l),{title:null===(n=l.title)||void 0===n?void 0:n.map(((t,l)=>q===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"BUTTONS"===M?Object.assign(Object.assign({},l),{buttons:null===(s=l.buttons)||void 0===s?void 0:s.map(((l,i)=>i===q?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==be||be((e=>Object.assign(Object.assign({},e),{cards:l}))))}const i=null!=xe&&xe>-1?re.cards[xe]:re;let r=i.body,c=i.title,p=i.header,v=i.buttons;if("BODY"===M?r=null===(n=i.body)||void 0===n?void 0:n.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"TITLE"===M?c=null===(s=null==i?void 0:i.title)||void 0===s?void 0:s.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"HEADER"===M?p=null===(o=i.header)||void 0===o?void 0:o.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"BUTTONS"===M&&(v=null===(u=i.buttons)||void 0===u?void 0:u.map(((i,a)=>a===q?Object.assign(Object.assign({},i),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===i.type?e:[e],queryParams:null!=l?l:[]}):i))),null!=xe&&xe>-1){const e=a.cloneDeep(re.cards);e[xe]={header:p,body:r,buttons:v,title:c},null==be||be((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==be||be((e=>Object.assign(Object.assign({},e),{header:p,body:r,buttons:v,title:c})))}}function Ve(e,t,l,i){var n,s,o,u,d,r,c,p,v,m,b,g;if(null!=xe&&xe>-1&&Ee){const s=Object.assign({},ce).components.map((l=>{var i;return isCarouselComponent(l.type)?Object.assign(Object.assign({},l),{cards:null===(i=l.cards)||void 0===i?void 0:i.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var i,a,n,s,o,u,d,r,c,p,v;if("BODY"===l.type&&"BODY"===M){if(null===(a=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===a?void 0:a[0]){const i=[...null!==(o=null===(s=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{body_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("TITLE"===l.type&&"TITLE"===M){if(null===(d=null===(u=l.example)||void 0===u?void 0:u.title_text)||void 0===d?void 0:d[0]){const i=[...null!==(p=null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])&&void 0!==p?p:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{title_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("BUTTONS"===l.type&&"BUTTONS"===M){const i=null===(v=l.buttons)||void 0===v?void 0:v.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:[t]}):l));return i?Object.assign(Object.assign({},l),{buttons:i}):l}return l}))})))}):l})),o=a.cloneDeep(ce);if(l){const l=null===(n=Object.assign({},ce).mapping.cards)||void 0===n?void 0:n.map(((l,a)=>{var n,s,o,u;if("BODY"===M)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("TITLE"===M)return Object.assign(Object.assign({},l),{title:null===(s=null==l?void 0:l.title)||void 0===s?void 0:s.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===M&&(null==l?void 0:l.buttons)){let n=-1,s=-1;return null===(o=ce.components[Pe].cards)||void 0===o||o[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(s=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(u=l.buttons)||void 0===u?void 0:u.map(((e,l)=>l===s?"custom_link"===i?"((customPlaceholderName))":t:e))})}return l}));o.mapping.cards=l}return o.components=s,void(null==ve||ve(o))}const O=null!=xe&&xe>-1?{components:null===(s=Object.assign({},ce).components[Pe].cards)||void 0===s?void 0:s[xe].components,mapping:null===(o=Object.assign({},ce).mapping.cards)||void 0===o?void 0:o[xe]}:Object.assign({},ce),j=null===(u=null==O?void 0:O.components)||void 0===u?void 0:u.map((l=>{var i,a,n,s,o,u,d,r,c,p,v,m,b,g,O,j;const x=Object.assign({},l);if("BODY"===l.type&&"BODY"===M&&(Array.isArray(null===(i=l.example)||void 0===i?void 0:i.body_text)||(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]))){const l=[...null!==(u=null===(o=null===(s=x.example)||void 0===s?void 0:s.body_text)||void 0===o?void 0:o[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},x.example),{body_text:[l]});return Object.assign(Object.assign({},x),{example:i})}if("TITLE"===l.type&&"TITLE"===M){if(Array.isArray(null===(d=l.example)||void 0===d?void 0:d.title_text)||(null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])){const l=[...null!==(m=null===(v=null===(p=x.example)||void 0===p?void 0:p.title_text)||void 0===v?void 0:v[0])&&void 0!==m?m:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},x.example),{title_text:[l]});return Object.assign(Object.assign({},x),{example:i})}}else if("HEADER"===l.type&&"HEADER"===M){if(null===(b=l.example)||void 0===b?void 0:b.header_text){const l=[...null!==(O=null===(g=x.example)||void 0===g?void 0:g.header_text)&&void 0!==O?O:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},x.example),{header_text:l});return Object.assign(Object.assign({},x),{example:i})}}else{if("BUTTONS"===l.type&&"BUTTONS"===M){const i=null===(j=l.buttons)||void 0===j?void 0:j.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return i?Object.assign(Object.assign({},x),{buttons:i}):x}if("limited_time_offer"===l.type&&"limited_time_offer"===M)return Object.assign(Object.assign({},x),{example:Object.assign(Object.assign({},x.example),{limited_time_offer:t})})}return l}));if(O.components=j,l)if("BODY"===M&&(null===(d=null==O?void 0:O.mapping)||void 0===d?void 0:d.body))O.mapping=Object.assign(Object.assign({},O.mapping),{body:null===(c=null===(r=O.mapping)||void 0===r?void 0:r.body)||void 0===c?void 0:c.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("TITLE"===M&&(null===(p=null==O?void 0:O.mapping)||void 0===p?void 0:p.title))O.mapping=Object.assign(Object.assign({},O.mapping),{title:null===(m=null===(v=O.mapping)||void 0===v?void 0:v.title)||void 0===m?void 0:m.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===M&&(null===(b=null==O?void 0:O.mapping)||void 0===b?void 0:b.header))O.mapping=Object.assign(Object.assign({},O.mapping),{header:O.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===M&&(null===(g=null==O?void 0:O.mapping)||void 0===g?void 0:g.buttons)){let l=-1,a=-1;j.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),O.mapping=Object.assign(Object.assign({},O.mapping),{buttons:O.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=xe&&xe>-1&&ce){const e=a.cloneDeep(ce);e.components[Pe].cards[xe].components=O.components,e.mapping.cards[xe]=O.mapping,null==ve||ve(e)}else null==ve||ve(Object.assign({},O))}n.useEffect((()=>{Z&&(null==U||U())}),[Z]),n.useEffect((()=>{!function(){var e,t,l,i,a;const n="mobile"===oe?"template_html_mobile":"template_html_desktop",s=document.getElementById(n),o=(null!==(i=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==i?i:"")+(null===(a=null==s?void 0:s.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);ue===m.CHANNEL_TYPE.EMAIL&&(null==me||me(o))}()}),[pe]),n.useEffect((()=>{!function(){var e,t;const l=[];let i=[];if(ue!==m.CHANNEL_TYPE.MESSAGE||Oe){"link"===(null==R?void 0:R.type)?(l.push({label:"",options:[A,L]}),ee(A)):"date_time"===(null==R?void 0:R.type)?(l.push({label:"",options:[A,L]}),ee(S)):(l.push({label:"",options:[A,L,S]}),ee(L));const e=null!=ge?ge:[];J([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:j.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())})}))]),i=[...l,...e]}else{const e=null!=ge?ge:[];J([{label:"",options:[L,A]},...e]),i=[{label:"",options:[L,A]},...e]}if((ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.EMAIL||ue===m.CHANNEL_TYPE.MESSAGE||ue===m.CHANNEL_TYPE.WEBPUSH||ue===m.CHANNEL_TYPE.RCS)&&R.updatedValue)if(v.placeHolderNamePattern.test(R.updatedValue)&&(ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS)||R.updatedValue.startsWith("{{")&&ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.RCS){const e=function(e,t,l){var i;let a={label:"",value:""};const n=l===(m.CHANNEL_TYPE.WHATSAPP||m.CHANNEL_TYPE.RCS)?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(I){let t=e.updatedValue;if(je===g.POD.CHATBOT&&"BUTTONS"===M){const l=null==$?void 0:$.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}a={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(i=e.updatedValue)&&void 0!==i?i:""}}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()&&(a=e)}))}));return a}(R,i,ue);e.value&&ee(e)}else"date_time"===R.type?(ee(S),Q(R.updatedValue),Ve(null!==(e=R.index)&&void 0!==e?e:0,R.updatedValue)):(null===(t=R.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(ee(A),Q(R.updatedValue.split("https://")[1])):(ee(L),Q(R.updatedValue))}()}),[xe]),n.useEffect((()=>{oe&&X&&G&&setTimeout((()=>{Se("custom_link"===(null==X?void 0:X.value)&&G?G.includes("https")?G:`https://${G}`:G,X.value)}),100)}),[oe]),n.useEffect((()=>{!te&&X&&R.updatedValue&&setTimeout((()=>{Se("custom_link"===(null==X?void 0:X.value)&&R.updatedValue?R.updatedValue.includes("https")?R.updatedValue:`https://${R.updatedValue}`:R.updatedValue,X.value),le(!0)}),100)}),[X]);const He=e=>{null==W||W(!1),"{{custom.url}}"===e.actualValue?Ae({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?Ae({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?Ae({label:e.displayName,selected:!0,value:"static_expiry"}):Ae({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})};function ke(e,t){var l;const i=a.cloneDeep(ce),n=M.toLocaleLowerCase();(null===(l=i.webpushBroadcastConfig)||void 0===l?void 0:l[n])&&(i.webpushBroadcastConfig[n][e]=t),null==ve||ve(Object.assign({},i))}return e.jsxs(f,Object.assign({channel:ue,focused:Z,onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(O.BodySecondary,Object.assign({style:{color:de&&!X?x.COLORS.content.negative:x.COLORS.content.primary}},{children:[null===(h=R.variableName)||void 0===h?void 0:h.replace("{{","").replace("}}","")," ","link"===(null==R?void 0:R.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:I?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==X?void 0:X.label)?"space-between":"flex-end"}},{children:[e.jsx(O.BodyPrimary,Object.assign({numberOfLines:1},{children:je===g.POD.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(C=null==X?void 0:X.value)&&void 0!==C?C:"")?null==X?void 0:X.label:null==X?void 0:X.value:p.truncate(null!==(V=null==X?void 0:X.label)&&void 0!==V?V:"",20,!0)})),ye||"date_time"===(null==R?void 0:R.type)&&_e?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{(()=>{let e=Array.isArray(ie)?[...ie]:[];const t=(t,l,i)=>{const a=T.updateVariables({variableList:e,categoryDisplayName:t,variableDisplayName:l,variableValue:i});Array.isArray(a)&&(e=a)};je===g.POD.CHATBOT&&t("Custom Variables","Custom Text","{{custom.text}}"),z===g.BUTTON_TYPE.URL&&je===g.POD.CHATBOT?t("Custom Variables","Custom URL","{{custom.url}}"):"limited_time_offer"===M?t("Static Variables","Static Expiry","{{static.expiry}}"):z===g.BUTTON_TYPE.COPY_CODE&&t("Custom Variables","Custom Text","{{custom.text}}"),ae(e)})(),ne((()=>He)),se(!0)},width:24,height:24,color:x.COLORS.content.primary})]})):e.jsx(r.Dropdown,{disabled:ye,options:K,isSearchable:!1,onSelect:Ae,defaultOptions:X?[Object.assign(Object.assign({},X),{selected:!0})]:[]})})),("custom_text"===(null==X?void 0:X.value)||"custom_link"===(null==X?void 0:X.value))&&e.jsx(c.Input,{state:ye?"disabled":"none",labelText:"custom_text"===(null==X?void 0:X.value)?"Custom text value":"custom_link"===(null==X?void 0:X.value)?"Custom URL value":"",id:`variable-value-${null==X?void 0:X.value}-${q}`,value:G,errorMessage:de&&(null===(H=null==he?void 0:he.buttons)||void 0===H?void 0:H.includes(null!==(k=null==R?void 0:R.index)&&void 0!==k?k:-1))?G&&0!==G.trim().length?"custom_link"!==X.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${G.trim()}`)&&0!==G.trim().length?"custom_link"!==X.value&&G.length>30?"Length cannot be more than 30":"BUTTONS"===M&&"custom_link"!==X.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:Ce||("custom_link"===(null==X?void 0:X.value)?2e3:"BUTTONS"===M?15:30),noKeyDownChange:!0,prefixText:"custom_link"===(null==X?void 0:X.value)?"https://":"",placeholder:"link"===R.type||"custom_link"===X.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{Le(X.value,e)}}),"static_expiry"===(null==X?void 0:X.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[(ye||fe)&&e.jsxs(N,Object.assign({onClick:e=>e.preventDefault(),style:{display:"flex",justifyContent:"space-between"}},{children:[e.jsx(P,{}),e.jsx(P,{})]})),e.jsx(d.CustomDateTime,{placement:"auto",time:G?i.format(new Date(G),"hh:mm a"):i.format(new Date,"hh:mm a"),date:G?new Date(G):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{Le("static_expiry",e.toISOString())}})]})),"static_expiry"===(null==X?void 0:X.value)&&Ne&&e.jsx("div",Object.assign({style:{marginTop:8}},{children:e.jsx(o.Alert,{containerStyle:{padding:"4px 8px"},icon:()=>e.jsx(l.default,{width:16,height:16,color:x.COLORS.content.secondary}),type:u.ALERT_TYPES.NEUTRAL,text:"Please use the same expiration code that you applied when creating \nthe code on Shopify"})})),"link"===R.type&&"custom_link"!==(null==X?void 0:X.value)&&!Ee&&!Te&&je===g.POD.CHATBOT&&e.jsx(_.QueryParamsComponent,{isError:null!==(Y=null===(B=null==he?void 0:he.buttons)||void 0===B?void 0:B.includes(null!==(D=null==R?void 0:R.index)&&void 0!==D?D:-1))&&void 0!==Y&&Y,params:null!==(w=R.queryParams)&&void 0!==w?w:[],onChange:e=>{Se(R.updatedValue,"link",e)},variableValue:R.updatedValue})]}))};
19
+ `,A={value:"custom_link",label:"Custom URL"},L={value:"custom_text",label:"Custom text"},S={value:"static_expiry",label:"Static Expiry"};exports.Container=C,exports.default=s=>{var h,f,V,H,k,B,Y,D,w;const{onFocus:U,variable:R,index:q,showVariableModal:I,setShowDiscountCheckBox:W,componentType:M,CTAoptions:$,buttonType:z}=s,[Z,F]=n.useState(!1),[G,Q]=n.useState(""),[K,J]=n.useState([]),[X,ee]=n.useState(),[te,le]=n.useState(!1),{variableList:ie,setVariableList:ae,setVariableCallback:ne,setShowVariablePicker:se,device:oe,channel:ue,isError:de,originalVariableList:re,template:ce,templateSelectionTriggered:pe,setTemplate:ve,setDisplayContent:me,setOriginalVariableList:be,globalNormalizedPlaceholders:ge,enabledCustomText:Oe,pod:je,selectedCarouselIndex:xe,isProductCarouselType:Te,isWhatsappCarousel:Ee,disableEditVariable:ye,disableEditExpiry:_e,templateErrorIndexes:he,maxCharLimit:fe,disableDatePicker:Ce,showDiscountCodeExpiryInfo:Ne,cardIndex:Pe=1}=T.useTemplateModalContext();function Ae(e,t){var l,i,a,n;const s=e;Q(""),ee(s),ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS?"custom_text"!==s.value&&"custom_link"!==s.value&&"static_expiry"!==s.value?(Se(null!==(l=s.value)&&void 0!==l?l:"","string"),null==Ve||Ve(null!==(i=R.index)&&void 0!==i?i:0,s.value,!0)):(null==Ve||Ve(null!==(a=R.index)&&void 0!==a?a:0,"",!0,s.value),Se("","url"===s.bikPlaceholderType?"link":"string")):"custom_text"!==s.value&&"custom_link"!==s.value?(Se(s.value,"url"===s.bikPlaceholderType?"link":"string"),ue==m.CHANNEL_TYPE.WEBPUSH&&(null==ke||ke(null!==(n=R.index)&&void 0!==n?n:0,s.value))):(Q(""),Se("",s.value))}function Le(e,t){var l,i;Q(t);const a="custom_link"===(null==X?void 0:X.value)&&t?t.includes("https")?t:`https://${t}`:t;Se(a,"static_expiry"===e?"string":e),ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.RCS||null==Ve||Ve(null!==(l=R.index)&&void 0!==l?l:0,a,"custom_link"===e,e),ue===m.CHANNEL_TYPE.WEBPUSH&&(null==ke||ke(null!==(i=R.index)&&void 0!==i?i:0,a))}function Se(e,t,l){var i,n,s,o,u;const d="custom_link"===t?"link":"custom_text"===t?"string":t;if(ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.WEBPUSH&&ue!==m.CHANNEL_TYPE.RCS){const l=y.getVariableNameForEmailByIndex(q+1),a=null===document||void 0===document?void 0:document.getElementById("mobile"===oe?"template_html_mobile":"template_html_desktop"),n=ue===m.CHANNEL_TYPE.EMAIL?null===(i=null==a?void 0:a.contentWindow)||void 0===i?void 0:i.document.getElementById(l):document.getElementById(l);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:R.variableName);const s=re.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t));null==be||be(s)}if(ue===m.CHANNEL_TYPE.WEBPUSH){const t=re,l=t=>null==t?void 0:t.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)),i={BODY:"BODY"===M?l(t.body):t.body,TITLE:M===b.WEB_PUSH_COMPONENT_TYPE.TITLE.toUpperCase()?l(t.title):t.title};null==be||be((e=>Object.assign(Object.assign({},e),{title:i.TITLE,body:i.BODY,buttons:t.buttons})))}if(ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS){if(null!=xe&&xe>-1&&Te){const l=Object.assign({},re).cards.map(((l,i)=>{var a,n,s;return"BODY"===M?Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>q===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"TITLE"===M?Object.assign(Object.assign({},l),{title:null===(n=l.title)||void 0===n?void 0:n.map(((t,l)=>q===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"BUTTONS"===M?Object.assign(Object.assign({},l),{buttons:null===(s=l.buttons)||void 0===s?void 0:s.map(((l,i)=>i===q?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==be||be((e=>Object.assign(Object.assign({},e),{cards:l}))))}const i=null!=xe&&xe>-1?re.cards[xe]:re;let r=i.body,c=i.title,p=i.header,v=i.buttons;if("BODY"===M?r=null===(n=i.body)||void 0===n?void 0:n.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"TITLE"===M?c=null===(s=null==i?void 0:i.title)||void 0===s?void 0:s.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"HEADER"===M?p=null===(o=i.header)||void 0===o?void 0:o.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"BUTTONS"===M&&(v=null===(u=i.buttons)||void 0===u?void 0:u.map(((i,a)=>a===q?Object.assign(Object.assign({},i),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===i.type?e:[e],queryParams:null!=l?l:[]}):i))),null!=xe&&xe>-1){const e=a.cloneDeep(re.cards);e[xe]={header:p,body:r,buttons:v,title:c},null==be||be((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==be||be((e=>Object.assign(Object.assign({},e),{header:p,body:r,buttons:v,title:c})))}}function Ve(e,t,l,i){var n,s,o,u,d,r,c,p,v,m,b,g;if(null!=xe&&xe>-1&&Te){const s=Object.assign({},ce).components.map((l=>{var i;return isCarouselComponent(l.type)?Object.assign(Object.assign({},l),{cards:null===(i=l.cards)||void 0===i?void 0:i.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var i,a,n,s,o,u,d,r,c,p,v;if("BODY"===l.type&&"BODY"===M){if(null===(a=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===a?void 0:a[0]){const i=[...null!==(o=null===(s=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{body_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("TITLE"===l.type&&"TITLE"===M){if(null===(d=null===(u=l.example)||void 0===u?void 0:u.title_text)||void 0===d?void 0:d[0]){const i=[...null!==(p=null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])&&void 0!==p?p:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{title_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("BUTTONS"===l.type&&"BUTTONS"===M){const i=null===(v=l.buttons)||void 0===v?void 0:v.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:[t]}):l));return i?Object.assign(Object.assign({},l),{buttons:i}):l}return l}))})))}):l})),o=a.cloneDeep(ce);if(l){const l=null===(n=Object.assign({},ce).mapping.cards)||void 0===n?void 0:n.map(((l,a)=>{var n,s,o,u;if("BODY"===M)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("TITLE"===M)return Object.assign(Object.assign({},l),{title:null===(s=null==l?void 0:l.title)||void 0===s?void 0:s.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===M&&(null==l?void 0:l.buttons)){let n=-1,s=-1;return null===(o=ce.components[Pe].cards)||void 0===o||o[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(s=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(u=l.buttons)||void 0===u?void 0:u.map(((e,l)=>l===s?"custom_link"===i?"((customPlaceholderName))":t:e))})}return l}));o.mapping.cards=l}return o.components=s,void(null==ve||ve(o))}const O=null!=xe&&xe>-1?{components:null===(s=Object.assign({},ce).components[Pe].cards)||void 0===s?void 0:s[xe].components,mapping:null===(o=Object.assign({},ce).mapping.cards)||void 0===o?void 0:o[xe]}:Object.assign({},ce),j=null===(u=null==O?void 0:O.components)||void 0===u?void 0:u.map((l=>{var i,a,n,s,o,u,d,r,c,p,v,m,b,g,O,j;const x=Object.assign({},l);if("BODY"===l.type&&"BODY"===M&&(Array.isArray(null===(i=l.example)||void 0===i?void 0:i.body_text)||(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]))){const l=[...null!==(u=null===(o=null===(s=x.example)||void 0===s?void 0:s.body_text)||void 0===o?void 0:o[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},x.example),{body_text:[l]});return Object.assign(Object.assign({},x),{example:i})}if("TITLE"===l.type&&"TITLE"===M){if(Array.isArray(null===(d=l.example)||void 0===d?void 0:d.title_text)||(null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])){const l=[...null!==(m=null===(v=null===(p=x.example)||void 0===p?void 0:p.title_text)||void 0===v?void 0:v[0])&&void 0!==m?m:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},x.example),{title_text:[l]});return Object.assign(Object.assign({},x),{example:i})}}else if("HEADER"===l.type&&"HEADER"===M){if(null===(b=l.example)||void 0===b?void 0:b.header_text){const l=[...null!==(O=null===(g=x.example)||void 0===g?void 0:g.header_text)&&void 0!==O?O:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},x.example),{header_text:l});return Object.assign(Object.assign({},x),{example:i})}}else{if("BUTTONS"===l.type&&"BUTTONS"===M){const i=null===(j=l.buttons)||void 0===j?void 0:j.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return i?Object.assign(Object.assign({},x),{buttons:i}):x}if("limited_time_offer"===l.type&&"limited_time_offer"===M)return Object.assign(Object.assign({},x),{example:Object.assign(Object.assign({},x.example),{limited_time_offer:t})})}return l}));if(O.components=j,l)if("BODY"===M&&(null===(d=null==O?void 0:O.mapping)||void 0===d?void 0:d.body))O.mapping=Object.assign(Object.assign({},O.mapping),{body:null===(c=null===(r=O.mapping)||void 0===r?void 0:r.body)||void 0===c?void 0:c.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("TITLE"===M&&(null===(p=null==O?void 0:O.mapping)||void 0===p?void 0:p.title))O.mapping=Object.assign(Object.assign({},O.mapping),{title:null===(m=null===(v=O.mapping)||void 0===v?void 0:v.title)||void 0===m?void 0:m.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===M&&(null===(b=null==O?void 0:O.mapping)||void 0===b?void 0:b.header))O.mapping=Object.assign(Object.assign({},O.mapping),{header:O.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===M&&(null===(g=null==O?void 0:O.mapping)||void 0===g?void 0:g.buttons)){let l=-1,a=-1;j.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),O.mapping=Object.assign(Object.assign({},O.mapping),{buttons:O.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=xe&&xe>-1&&ce){const e=a.cloneDeep(ce);e.components[Pe].cards[xe].components=O.components,e.mapping.cards[xe]=O.mapping,null==ve||ve(e)}else null==ve||ve(Object.assign({},O))}n.useEffect((()=>{Z&&(null==U||U())}),[Z]),n.useEffect((()=>{!function(){var e,t,l,i,a;const n="mobile"===oe?"template_html_mobile":"template_html_desktop",s=document.getElementById(n),o=(null!==(i=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==i?i:"")+(null===(a=null==s?void 0:s.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);ue===m.CHANNEL_TYPE.EMAIL&&(null==me||me(o))}()}),[pe]),n.useEffect((()=>{!function(){var e,t;const l=[];let i=[];if(ue!==m.CHANNEL_TYPE.MESSAGE||Oe){"link"===(null==R?void 0:R.type)?(l.push({label:"",options:[A,L]}),ee(A)):"date_time"===(null==R?void 0:R.type)?(l.push({label:"",options:[A,L]}),ee(S)):(l.push({label:"",options:[A,L,S]}),ee(L));const e=null!=ge?ge:[];J([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:j.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())})}))]),i=[...l,...e]}else{const e=null!=ge?ge:[];J([{label:"",options:[L,A]},...e]),i=[{label:"",options:[L,A]},...e]}if((ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.EMAIL||ue===m.CHANNEL_TYPE.MESSAGE||ue===m.CHANNEL_TYPE.WEBPUSH||ue===m.CHANNEL_TYPE.RCS)&&R.updatedValue)if(v.placeHolderNamePattern.test(R.updatedValue)&&(ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS)||R.updatedValue.startsWith("{{")&&ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.RCS){const e=function(e,t,l){var i;let a={label:"",value:""};const n=l===(m.CHANNEL_TYPE.WHATSAPP||m.CHANNEL_TYPE.RCS)?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(I){let t=e.updatedValue;if(je===g.POD.CHATBOT&&"BUTTONS"===M){const l=null==$?void 0:$.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}a={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(i=e.updatedValue)&&void 0!==i?i:""}}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()&&(a=e)}))}));return a}(R,i,ue);e.value&&ee(e)}else"date_time"===R.type?(ee(S),Q(R.updatedValue),Ve(null!==(e=R.index)&&void 0!==e?e:0,R.updatedValue)):(null===(t=R.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(ee(A),Q(R.updatedValue.split("https://")[1])):(ee(L),Q(R.updatedValue))}()}),[xe]),n.useEffect((()=>{oe&&X&&G&&setTimeout((()=>{Se("custom_link"===(null==X?void 0:X.value)&&G?G.includes("https")?G:`https://${G}`:G,X.value)}),100)}),[oe]),n.useEffect((()=>{!te&&X&&R.updatedValue&&setTimeout((()=>{Se("custom_link"===(null==X?void 0:X.value)&&R.updatedValue?R.updatedValue.includes("https")?R.updatedValue:`https://${R.updatedValue}`:R.updatedValue,X.value),le(!0)}),100)}),[X]);const He=e=>{null==W||W(!1),"{{custom.url}}"===e.actualValue?Ae({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?Ae({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?Ae({label:e.displayName,selected:!0,value:"static_expiry"}):Ae({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})};function ke(e,t){var l;const i=a.cloneDeep(ce),n=M.toLocaleLowerCase();(null===(l=i.webpushBroadcastConfig)||void 0===l?void 0:l[n])&&(i.webpushBroadcastConfig[n][e]=t),null==ve||ve(Object.assign({},i))}return e.jsxs(C,Object.assign({channel:ue,focused:Z,onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(O.BodySecondary,Object.assign({style:{color:de&&!X?x.COLORS.content.negative:x.COLORS.content.primary}},{children:[null===(h=R.variableName)||void 0===h?void 0:h.replace("{{","").replace("}}","")," ","link"===(null==R?void 0:R.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:I?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==X?void 0:X.label)?"space-between":"flex-end"}},{children:[e.jsx(O.BodyPrimary,Object.assign({numberOfLines:1},{children:je===g.POD.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(f=null==X?void 0:X.value)&&void 0!==f?f:"")?null==X?void 0:X.label:null==X?void 0:X.value:p.truncate(null!==(V=null==X?void 0:X.label)&&void 0!==V?V:"",20,!0)})),ye||"date_time"===(null==R?void 0:R.type)&&_e?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{(()=>{let e=Array.isArray(ie)?[...ie]:[];const t=(t,l,i)=>{const a=E.updateVariables({variableList:e,categoryDisplayName:t,variableDisplayName:l,variableValue:i});Array.isArray(a)&&(e=a)};je===g.POD.CHATBOT&&z!==g.BUTTON_TYPE.URL&&"limited_time_offer"!==M&&t("Custom Variables","Custom Text","{{custom.text}}"),z===g.BUTTON_TYPE.URL&&je===g.POD.CHATBOT?t("Custom Variables","Custom URL","{{custom.url}}"):"limited_time_offer"===M?t("Static Variables","Static Expiry","{{static.expiry}}"):z===g.BUTTON_TYPE.COPY_CODE&&t("Custom Variables","Custom Text","{{custom.text}}"),ae(e)})(),ne((()=>He)),se(!0)},width:24,height:24,color:x.COLORS.content.primary})]})):e.jsx(r.Dropdown,{disabled:ye,options:K,isSearchable:!1,onSelect:Ae,defaultOptions:X?[Object.assign(Object.assign({},X),{selected:!0})]:[]})})),("custom_text"===(null==X?void 0:X.value)||"custom_link"===(null==X?void 0:X.value))&&e.jsx(c.Input,{state:ye?"disabled":"none",labelText:"custom_text"===(null==X?void 0:X.value)?"Custom text value":"custom_link"===(null==X?void 0:X.value)?"Custom URL value":"",id:`variable-value-${null==X?void 0:X.value}-${q}`,value:G,errorMessage:de&&(null===(H=null==he?void 0:he.buttons)||void 0===H?void 0:H.includes(null!==(k=null==R?void 0:R.index)&&void 0!==k?k:-1))?G&&0!==G.trim().length?"custom_link"!==X.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${G.trim()}`)&&0!==G.trim().length?"custom_link"!==X.value&&G.length>30?"Length cannot be more than 30":"BUTTONS"===M&&"custom_link"!==X.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:fe||("custom_link"===(null==X?void 0:X.value)?2e3:"BUTTONS"===M?15:30),noKeyDownChange:!0,prefixText:"custom_link"===(null==X?void 0:X.value)?"https://":"",placeholder:"link"===R.type||"custom_link"===X.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{Le(X.value,e)}}),"static_expiry"===(null==X?void 0:X.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[(ye||Ce)&&e.jsxs(N,Object.assign({onClick:e=>e.preventDefault(),style:{display:"flex",justifyContent:"space-between"}},{children:[e.jsx(P,{}),e.jsx(P,{})]})),e.jsx(d.CustomDateTime,{placement:"auto",time:G?i.format(new Date(G),"hh:mm a"):i.format(new Date,"hh:mm a"),date:G?new Date(G):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{Le("static_expiry",e.toISOString())}})]})),"static_expiry"===(null==X?void 0:X.value)&&Ne&&e.jsx("div",Object.assign({style:{marginTop:8}},{children:e.jsx(o.Alert,{containerStyle:{padding:"4px 8px"},icon:()=>e.jsx(l.default,{width:16,height:16,color:x.COLORS.content.secondary}),type:u.ALERT_TYPES.NEUTRAL,text:"Please use the same expiration code that you applied when creating \nthe code on Shopify"})})),"link"===R.type&&"custom_link"!==(null==X?void 0:X.value)&&!Te&&!Ee&&je===g.POD.CHATBOT&&e.jsx(_.QueryParamsComponent,{isError:null!==(D=null===(B=null==he?void 0:he.buttons)||void 0===B?void 0:B.includes(null!==(Y=null==R?void 0:R.index)&&void 0!==Y?Y:-1))&&void 0!==D&&D,params:null!==(w=R.queryParams)&&void 0!==w?w:[],onChange:e=>{Se(R.updatedValue,"link",e)},variableValue:R.updatedValue})]}))};
@@ -16,4 +16,4 @@ import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import i from"..
16
16
  height: 100%;
17
17
  width: 48%;
18
18
  background: rgba(0, 0, 0, 0.1);
19
- `,L={value:"custom_link",label:"Custom URL"},P={value:"custom_text",label:"Custom text"},w={value:"static_expiry",label:"Static Expiry"},D=d=>{var D,U,N,H,I,R,W,Y,$;const{onFocus:M,variable:z,index:Z,showVariableModal:q,setShowDiscountCheckBox:G,componentType:F,CTAoptions:K,buttonType:Q}=d,[J,X]=s(!1),[ee,te]=s(""),[le,ie]=s([]),[ae,ne]=s(),[oe,se]=s(!1),{variableList:ue,setVariableList:de,setVariableCallback:re,setShowVariablePicker:ce,device:pe,channel:me,isError:ve,originalVariableList:be,template:ge,templateSelectionTriggered:Oe,setTemplate:je,setDisplayContent:ye,setOriginalVariableList:xe,globalNormalizedPlaceholders:he,enabledCustomText:fe,pod:Te,selectedCarouselIndex:_e,isProductCarouselType:Ee,isWhatsappCarousel:Ce,disableEditVariable:Ve,disableEditExpiry:Se,templateErrorIndexes:ke,maxCharLimit:Ae,disableDatePicker:Be,showDiscountCodeExpiryInfo:Le,cardIndex:Pe=1}=E();function we(e,t){var l,i,a,n;const o=e;te(""),ne(o),me===O.WHATSAPP||me===O.RCS?"custom_text"!==o.value&&"custom_link"!==o.value&&"static_expiry"!==o.value?(Ue(null!==(l=o.value)&&void 0!==l?l:"","string"),null==Ne||Ne(null!==(i=z.index)&&void 0!==i?i:0,o.value,!0)):(null==Ne||Ne(null!==(a=z.index)&&void 0!==a?a:0,"",!0,o.value),Ue("","url"===o.bikPlaceholderType?"link":"string")):"custom_text"!==o.value&&"custom_link"!==o.value?(Ue(o.value,"url"===o.bikPlaceholderType?"link":"string"),me==O.WEBPUSH&&(null==Ie||Ie(null!==(n=z.index)&&void 0!==n?n:0,o.value))):(te(""),Ue("",o.value))}function De(e,t){var l,i;te(t);const a="custom_link"===(null==ae?void 0:ae.value)&&t?t.includes("https")?t:`https://${t}`:t;Ue(a,"static_expiry"===e?"string":e),me!==O.WHATSAPP&&me!==O.RCS||null==Ne||Ne(null!==(l=z.index)&&void 0!==l?l:0,a,"custom_link"===e,e),me===O.WEBPUSH&&(null==Ie||Ie(null!==(i=z.index)&&void 0!==i?i:0,a))}function Ue(e,t,l){var i,a,n,s,u;const d="custom_link"===t?"link":"custom_text"===t?"string":t;if(me!==O.WHATSAPP&&me!==O.WEBPUSH&&me!==O.RCS){const l=V(Z+1),a=null===document||void 0===document?void 0:document.getElementById("mobile"===pe?"template_html_mobile":"template_html_desktop"),n=me===O.EMAIL?null===(i=null==a?void 0:a.contentWindow)||void 0===i?void 0:i.document.getElementById(l):document.getElementById(l);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:z.variableName);const o=be.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t));null==xe||xe(o)}if(me===O.WEBPUSH){const t=be,l=t=>null==t?void 0:t.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)),i={BODY:"BODY"===F?l(t.body):t.body,TITLE:F===j.TITLE.toUpperCase()?l(t.title):t.title};null==xe||xe((e=>Object.assign(Object.assign({},e),{title:i.TITLE,body:i.BODY,buttons:t.buttons})))}if(me===O.WHATSAPP||me===O.RCS){if(null!=_e&&_e>-1&&Ee){const l=Object.assign({},be).cards.map(((l,i)=>{var a,n,o;return"BODY"===F?Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>Z===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"TITLE"===F?Object.assign(Object.assign({},l),{title:null===(n=l.title)||void 0===n?void 0:n.map(((t,l)=>Z===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"BUTTONS"===F?Object.assign(Object.assign({},l),{buttons:null===(o=l.buttons)||void 0===o?void 0:o.map(((l,i)=>i===Z?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==xe||xe((e=>Object.assign(Object.assign({},e),{cards:l}))))}const i=null!=_e&&_e>-1?be.cards[_e]:be;let r=i.body,c=i.title,p=i.header,m=i.buttons;if("BODY"===F?r=null===(a=i.body)||void 0===a?void 0:a.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"TITLE"===F?c=null===(n=null==i?void 0:i.title)||void 0===n?void 0:n.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"HEADER"===F?p=null===(s=i.header)||void 0===s?void 0:s.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"BUTTONS"===F&&(m=null===(u=i.buttons)||void 0===u?void 0:u.map(((i,a)=>a===Z?Object.assign(Object.assign({},i),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===i.type?e:[e],queryParams:null!=l?l:[]}):i))),null!=_e&&_e>-1){const e=o(be.cards);e[_e]={header:p,body:r,buttons:m,title:c},null==xe||xe((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==xe||xe((e=>Object.assign(Object.assign({},e),{header:p,body:r,buttons:m,title:c})))}}function Ne(e,t,l,i){var a,n,s,u,d,r,c,p,m,v,b,g;if(null!=_e&&_e>-1&&Ee){const n=Object.assign({},ge).components.map((l=>{var i;return isCarouselComponent(l.type)?Object.assign(Object.assign({},l),{cards:null===(i=l.cards)||void 0===i?void 0:i.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var i,a,n,o,s,u,d,r,c,p,m;if("BODY"===l.type&&"BODY"===F){if(null===(a=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===a?void 0:a[0]){const i=[...null!==(s=null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{body_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("TITLE"===l.type&&"TITLE"===F){if(null===(d=null===(u=l.example)||void 0===u?void 0:u.title_text)||void 0===d?void 0:d[0]){const i=[...null!==(p=null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])&&void 0!==p?p:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{title_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("BUTTONS"===l.type&&"BUTTONS"===F){const i=null===(m=l.buttons)||void 0===m?void 0:m.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:[t]}):l));return i?Object.assign(Object.assign({},l),{buttons:i}):l}return l}))})))}):l})),s=o(ge);if(l){const l=null===(a=Object.assign({},ge).mapping.cards)||void 0===a?void 0:a.map(((l,a)=>{var n,o,s,u;if("BODY"===F)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("TITLE"===F)return Object.assign(Object.assign({},l),{title:null===(o=null==l?void 0:l.title)||void 0===o?void 0:o.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===F&&(null==l?void 0:l.buttons)){let n=-1,o=-1;return null===(s=ge.components[Pe].cards)||void 0===s||s[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(o=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(u=l.buttons)||void 0===u?void 0:u.map(((e,l)=>l===o?"custom_link"===i?"((customPlaceholderName))":t:e))})}return l}));s.mapping.cards=l}return s.components=n,void(null==je||je(s))}const O=null!=_e&&_e>-1?{components:null===(n=Object.assign({},ge).components[Pe].cards)||void 0===n?void 0:n[_e].components,mapping:null===(s=Object.assign({},ge).mapping.cards)||void 0===s?void 0:s[_e]}:Object.assign({},ge),j=null===(u=null==O?void 0:O.components)||void 0===u?void 0:u.map((l=>{var i,a,n,o,s,u,d,r,c,p,m,v,b,g,O,j;const y=Object.assign({},l);if("BODY"===l.type&&"BODY"===F&&(Array.isArray(null===(i=l.example)||void 0===i?void 0:i.body_text)||(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]))){const l=[...null!==(u=null===(s=null===(o=y.example)||void 0===o?void 0:o.body_text)||void 0===s?void 0:s[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{body_text:[l]});return Object.assign(Object.assign({},y),{example:i})}if("TITLE"===l.type&&"TITLE"===F){if(Array.isArray(null===(d=l.example)||void 0===d?void 0:d.title_text)||(null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])){const l=[...null!==(v=null===(m=null===(p=y.example)||void 0===p?void 0:p.title_text)||void 0===m?void 0:m[0])&&void 0!==v?v:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{title_text:[l]});return Object.assign(Object.assign({},y),{example:i})}}else if("HEADER"===l.type&&"HEADER"===F){if(null===(b=l.example)||void 0===b?void 0:b.header_text){const l=[...null!==(O=null===(g=y.example)||void 0===g?void 0:g.header_text)&&void 0!==O?O:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{header_text:l});return Object.assign(Object.assign({},y),{example:i})}}else{if("BUTTONS"===l.type&&"BUTTONS"===F){const i=null===(j=l.buttons)||void 0===j?void 0:j.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return i?Object.assign(Object.assign({},y),{buttons:i}):y}if("limited_time_offer"===l.type&&"limited_time_offer"===F)return Object.assign(Object.assign({},y),{example:Object.assign(Object.assign({},y.example),{limited_time_offer:t})})}return l}));if(O.components=j,l)if("BODY"===F&&(null===(d=null==O?void 0:O.mapping)||void 0===d?void 0:d.body))O.mapping=Object.assign(Object.assign({},O.mapping),{body:null===(c=null===(r=O.mapping)||void 0===r?void 0:r.body)||void 0===c?void 0:c.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("TITLE"===F&&(null===(p=null==O?void 0:O.mapping)||void 0===p?void 0:p.title))O.mapping=Object.assign(Object.assign({},O.mapping),{title:null===(v=null===(m=O.mapping)||void 0===m?void 0:m.title)||void 0===v?void 0:v.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===F&&(null===(b=null==O?void 0:O.mapping)||void 0===b?void 0:b.header))O.mapping=Object.assign(Object.assign({},O.mapping),{header:O.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===F&&(null===(g=null==O?void 0:O.mapping)||void 0===g?void 0:g.buttons)){let l=-1,a=-1;j.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),O.mapping=Object.assign(Object.assign({},O.mapping),{buttons:O.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=_e&&_e>-1&&ge){const e=o(ge);e.components[Pe].cards[_e].components=O.components,e.mapping.cards[_e]=O.mapping,null==je||je(e)}else null==je||je(Object.assign({},O))}u((()=>{J&&(null==M||M())}),[J]),u((()=>{!function(){var e,t,l,i,a;const n="mobile"===pe?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(i=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!==i?i:"")+(null===(a=null==o?void 0:o.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);me===O.EMAIL&&(null==ye||ye(s))}()}),[Oe]),u((()=>{!function(){var e,t;const l=[];let i=[];if(me!==O.MESSAGE||fe){"link"===(null==z?void 0:z.type)?(l.push({label:"",options:[L,P]}),ne(L)):"date_time"===(null==z?void 0:z.type)?(l.push({label:"",options:[L,P]}),ne(w)):(l.push({label:"",options:[L,P,w]}),ne(P));const e=null!=he?he:[];ie([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:T.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())})}))]),i=[...l,...e]}else{const e=null!=he?he:[];ie([{label:"",options:[P,L]},...e]),i=[{label:"",options:[P,L]},...e]}if((me===O.WHATSAPP||me===O.EMAIL||me===O.MESSAGE||me===O.WEBPUSH||me===O.RCS)&&z.updatedValue)if(g.test(z.updatedValue)&&(me===O.WHATSAPP||me===O.RCS)||z.updatedValue.startsWith("{{")&&me!==O.WHATSAPP&&me!==O.RCS){const e=function(e,t,l){var i;let a={label:"",value:""};const n=l===(O.WHATSAPP||O.RCS)?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(q){let t=e.updatedValue;if(Te===y.CHATBOT&&"BUTTONS"===F){const l=null==K?void 0:K.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}a={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(i=e.updatedValue)&&void 0!==i?i:""}}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()&&(a=e)}))}));return a}(z,i,me);e.value&&ne(e)}else"date_time"===z.type?(ne(w),te(z.updatedValue),Ne(null!==(e=z.index)&&void 0!==e?e:0,z.updatedValue)):(null===(t=z.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(ne(L),te(z.updatedValue.split("https://")[1])):(ne(P),te(z.updatedValue))}()}),[_e]),u((()=>{pe&&ae&&ee&&setTimeout((()=>{Ue("custom_link"===(null==ae?void 0:ae.value)&&ee?ee.includes("https")?ee:`https://${ee}`:ee,ae.value)}),100)}),[pe]),u((()=>{!oe&&ae&&z.updatedValue&&setTimeout((()=>{Ue("custom_link"===(null==ae?void 0:ae.value)&&z.updatedValue?z.updatedValue.includes("https")?z.updatedValue:`https://${z.updatedValue}`:z.updatedValue,ae.value),se(!0)}),100)}),[ae]);const He=e=>{null==G||G(!1),"{{custom.url}}"===e.actualValue?we({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?we({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?we({label:e.displayName,selected:!0,value:"static_expiry"}):we({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})};function Ie(e,t){var l;const i=o(ge),a=F.toLocaleLowerCase();(null===(l=i.webpushBroadcastConfig)||void 0===l?void 0:l[a])&&(i.webpushBroadcastConfig[a][e]=t),null==je||je(Object.assign({},i))}return e(k,Object.assign({channel:me,focused:J,onMouseEnter:()=>X(!0),onMouseLeave:()=>X(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(h,Object.assign({style:{color:ve&&!ae?_.content.negative:_.content.primary}},{children:[null===(D=z.variableName)||void 0===D?void 0:D.replace("{{","").replace("}}","")," ","link"===(null==z?void 0:z.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:q?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==ae?void 0:ae.label)?"space-between":"flex-end"}},{children:[t(f,Object.assign({numberOfLines:1},{children:Te===y.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(U=null==ae?void 0:ae.value)&&void 0!==U?U:"")?null==ae?void 0:ae.label:null==ae?void 0:ae.value:b(null!==(N=null==ae?void 0:ae.label)&&void 0!==N?N:"",20,!0)})),Ve||"date_time"===(null==z?void 0:z.type)&&Se?t(l,{}):t(i,{onClick:()=>{(()=>{let e=Array.isArray(ue)?[...ue]:[];const t=(t,l,i)=>{const a=C({variableList:e,categoryDisplayName:t,variableDisplayName:l,variableValue:i});Array.isArray(a)&&(e=a)};Te===y.CHATBOT&&t("Custom Variables","Custom Text","{{custom.text}}"),Q===x.URL&&Te===y.CHATBOT?t("Custom Variables","Custom URL","{{custom.url}}"):"limited_time_offer"===F?t("Static Variables","Static Expiry","{{static.expiry}}"):Q===x.COPY_CODE&&t("Custom Variables","Custom Text","{{custom.text}}"),de(e)})(),re((()=>He)),ce(!0)},width:24,height:24,color:_.content.primary})]})):t(m,{disabled:Ve,options:le,isSearchable:!1,onSelect:we,defaultOptions:ae?[Object.assign(Object.assign({},ae),{selected:!0})]:[]})})),("custom_text"===(null==ae?void 0:ae.value)||"custom_link"===(null==ae?void 0:ae.value))&&t(v,{state:Ve?"disabled":"none",labelText:"custom_text"===(null==ae?void 0:ae.value)?"Custom text value":"custom_link"===(null==ae?void 0:ae.value)?"Custom URL value":"",id:`variable-value-${null==ae?void 0:ae.value}-${Z}`,value:ee,errorMessage:ve&&(null===(H=null==ke?void 0:ke.buttons)||void 0===H?void 0:H.includes(null!==(I=null==z?void 0:z.index)&&void 0!==I?I:-1))?ee&&0!==ee.trim().length?"custom_link"!==ae.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${ee.trim()}`)&&0!==ee.trim().length?"custom_link"!==ae.value&&ee.length>30?"Length cannot be more than 30":"BUTTONS"===F&&"custom_link"!==ae.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:Ae||("custom_link"===(null==ae?void 0:ae.value)?2e3:"BUTTONS"===F?15:30),noKeyDownChange:!0,prefixText:"custom_link"===(null==ae?void 0:ae.value)?"https://":"",placeholder:"link"===z.type||"custom_link"===ae.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{De(ae.value,e)}}),"static_expiry"===(null==ae?void 0:ae.value)&&e("div",Object.assign({style:{position:"relative"}},{children:[(Ve||Be)&&e(A,Object.assign({onClick:e=>e.preventDefault(),style:{display:"flex",justifyContent:"space-between"}},{children:[t(B,{}),t(B,{})]})),t(p,{placement:"auto",time:n(ee?new Date(ee):new Date,"hh:mm a"),date:ee?new Date(ee):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{De("static_expiry",e.toISOString())}})]})),"static_expiry"===(null==ae?void 0:ae.value)&&Le&&t("div",Object.assign({style:{marginTop:8}},{children:t(r,{containerStyle:{padding:"4px 8px"},icon:()=>t(a,{width:16,height:16,color:_.content.secondary}),type:c.NEUTRAL,text:"Please use the same expiration code that you applied when creating \nthe code on Shopify"})})),"link"===z.type&&"custom_link"!==(null==ae?void 0:ae.value)&&!Ee&&!Ce&&Te===y.CHATBOT&&t(S,{isError:null!==(Y=null===(R=null==ke?void 0:ke.buttons)||void 0===R?void 0:R.includes(null!==(W=null==z?void 0:z.index)&&void 0!==W?W:-1))&&void 0!==Y&&Y,params:null!==($=z.queryParams)&&void 0!==$?$:[],onChange:e=>{Ue(z.updatedValue,"link",e)},variableValue:z.updatedValue})]}))};export{k as Container,D as default};
19
+ `,L={value:"custom_link",label:"Custom URL"},P={value:"custom_text",label:"Custom text"},w={value:"static_expiry",label:"Static Expiry"},D=d=>{var D,U,N,H,R,I,W,Y,$;const{onFocus:M,variable:z,index:Z,showVariableModal:q,setShowDiscountCheckBox:G,componentType:F,CTAoptions:K,buttonType:Q}=d,[J,X]=s(!1),[ee,te]=s(""),[le,ie]=s([]),[ae,ne]=s(),[oe,se]=s(!1),{variableList:ue,setVariableList:de,setVariableCallback:re,setShowVariablePicker:ce,device:pe,channel:me,isError:ve,originalVariableList:be,template:ge,templateSelectionTriggered:Oe,setTemplate:je,setDisplayContent:ye,setOriginalVariableList:xe,globalNormalizedPlaceholders:he,enabledCustomText:fe,pod:Te,selectedCarouselIndex:_e,isProductCarouselType:Ee,isWhatsappCarousel:Ce,disableEditVariable:Ve,disableEditExpiry:Se,templateErrorIndexes:ke,maxCharLimit:Ae,disableDatePicker:Be,showDiscountCodeExpiryInfo:Le,cardIndex:Pe=1}=E();function we(e,t){var l,i,a,n;const o=e;te(""),ne(o),me===O.WHATSAPP||me===O.RCS?"custom_text"!==o.value&&"custom_link"!==o.value&&"static_expiry"!==o.value?(Ue(null!==(l=o.value)&&void 0!==l?l:"","string"),null==Ne||Ne(null!==(i=z.index)&&void 0!==i?i:0,o.value,!0)):(null==Ne||Ne(null!==(a=z.index)&&void 0!==a?a:0,"",!0,o.value),Ue("","url"===o.bikPlaceholderType?"link":"string")):"custom_text"!==o.value&&"custom_link"!==o.value?(Ue(o.value,"url"===o.bikPlaceholderType?"link":"string"),me==O.WEBPUSH&&(null==Re||Re(null!==(n=z.index)&&void 0!==n?n:0,o.value))):(te(""),Ue("",o.value))}function De(e,t){var l,i;te(t);const a="custom_link"===(null==ae?void 0:ae.value)&&t?t.includes("https")?t:`https://${t}`:t;Ue(a,"static_expiry"===e?"string":e),me!==O.WHATSAPP&&me!==O.RCS||null==Ne||Ne(null!==(l=z.index)&&void 0!==l?l:0,a,"custom_link"===e,e),me===O.WEBPUSH&&(null==Re||Re(null!==(i=z.index)&&void 0!==i?i:0,a))}function Ue(e,t,l){var i,a,n,s,u;const d="custom_link"===t?"link":"custom_text"===t?"string":t;if(me!==O.WHATSAPP&&me!==O.WEBPUSH&&me!==O.RCS){const l=V(Z+1),a=null===document||void 0===document?void 0:document.getElementById("mobile"===pe?"template_html_mobile":"template_html_desktop"),n=me===O.EMAIL?null===(i=null==a?void 0:a.contentWindow)||void 0===i?void 0:i.document.getElementById(l):document.getElementById(l);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:z.variableName);const o=be.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t));null==xe||xe(o)}if(me===O.WEBPUSH){const t=be,l=t=>null==t?void 0:t.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)),i={BODY:"BODY"===F?l(t.body):t.body,TITLE:F===j.TITLE.toUpperCase()?l(t.title):t.title};null==xe||xe((e=>Object.assign(Object.assign({},e),{title:i.TITLE,body:i.BODY,buttons:t.buttons})))}if(me===O.WHATSAPP||me===O.RCS){if(null!=_e&&_e>-1&&Ee){const l=Object.assign({},be).cards.map(((l,i)=>{var a,n,o;return"BODY"===F?Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>Z===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"TITLE"===F?Object.assign(Object.assign({},l),{title:null===(n=l.title)||void 0===n?void 0:n.map(((t,l)=>Z===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"BUTTONS"===F?Object.assign(Object.assign({},l),{buttons:null===(o=l.buttons)||void 0===o?void 0:o.map(((l,i)=>i===Z?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==xe||xe((e=>Object.assign(Object.assign({},e),{cards:l}))))}const i=null!=_e&&_e>-1?be.cards[_e]:be;let r=i.body,c=i.title,p=i.header,m=i.buttons;if("BODY"===F?r=null===(a=i.body)||void 0===a?void 0:a.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"TITLE"===F?c=null===(n=null==i?void 0:i.title)||void 0===n?void 0:n.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"HEADER"===F?p=null===(s=i.header)||void 0===s?void 0:s.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"BUTTONS"===F&&(m=null===(u=i.buttons)||void 0===u?void 0:u.map(((i,a)=>a===Z?Object.assign(Object.assign({},i),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===i.type?e:[e],queryParams:null!=l?l:[]}):i))),null!=_e&&_e>-1){const e=o(be.cards);e[_e]={header:p,body:r,buttons:m,title:c},null==xe||xe((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==xe||xe((e=>Object.assign(Object.assign({},e),{header:p,body:r,buttons:m,title:c})))}}function Ne(e,t,l,i){var a,n,s,u,d,r,c,p,m,v,b,g;if(null!=_e&&_e>-1&&Ee){const n=Object.assign({},ge).components.map((l=>{var i;return isCarouselComponent(l.type)?Object.assign(Object.assign({},l),{cards:null===(i=l.cards)||void 0===i?void 0:i.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var i,a,n,o,s,u,d,r,c,p,m;if("BODY"===l.type&&"BODY"===F){if(null===(a=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===a?void 0:a[0]){const i=[...null!==(s=null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{body_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("TITLE"===l.type&&"TITLE"===F){if(null===(d=null===(u=l.example)||void 0===u?void 0:u.title_text)||void 0===d?void 0:d[0]){const i=[...null!==(p=null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])&&void 0!==p?p:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{title_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("BUTTONS"===l.type&&"BUTTONS"===F){const i=null===(m=l.buttons)||void 0===m?void 0:m.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:[t]}):l));return i?Object.assign(Object.assign({},l),{buttons:i}):l}return l}))})))}):l})),s=o(ge);if(l){const l=null===(a=Object.assign({},ge).mapping.cards)||void 0===a?void 0:a.map(((l,a)=>{var n,o,s,u;if("BODY"===F)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("TITLE"===F)return Object.assign(Object.assign({},l),{title:null===(o=null==l?void 0:l.title)||void 0===o?void 0:o.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===F&&(null==l?void 0:l.buttons)){let n=-1,o=-1;return null===(s=ge.components[Pe].cards)||void 0===s||s[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(o=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(u=l.buttons)||void 0===u?void 0:u.map(((e,l)=>l===o?"custom_link"===i?"((customPlaceholderName))":t:e))})}return l}));s.mapping.cards=l}return s.components=n,void(null==je||je(s))}const O=null!=_e&&_e>-1?{components:null===(n=Object.assign({},ge).components[Pe].cards)||void 0===n?void 0:n[_e].components,mapping:null===(s=Object.assign({},ge).mapping.cards)||void 0===s?void 0:s[_e]}:Object.assign({},ge),j=null===(u=null==O?void 0:O.components)||void 0===u?void 0:u.map((l=>{var i,a,n,o,s,u,d,r,c,p,m,v,b,g,O,j;const y=Object.assign({},l);if("BODY"===l.type&&"BODY"===F&&(Array.isArray(null===(i=l.example)||void 0===i?void 0:i.body_text)||(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]))){const l=[...null!==(u=null===(s=null===(o=y.example)||void 0===o?void 0:o.body_text)||void 0===s?void 0:s[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{body_text:[l]});return Object.assign(Object.assign({},y),{example:i})}if("TITLE"===l.type&&"TITLE"===F){if(Array.isArray(null===(d=l.example)||void 0===d?void 0:d.title_text)||(null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])){const l=[...null!==(v=null===(m=null===(p=y.example)||void 0===p?void 0:p.title_text)||void 0===m?void 0:m[0])&&void 0!==v?v:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{title_text:[l]});return Object.assign(Object.assign({},y),{example:i})}}else if("HEADER"===l.type&&"HEADER"===F){if(null===(b=l.example)||void 0===b?void 0:b.header_text){const l=[...null!==(O=null===(g=y.example)||void 0===g?void 0:g.header_text)&&void 0!==O?O:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{header_text:l});return Object.assign(Object.assign({},y),{example:i})}}else{if("BUTTONS"===l.type&&"BUTTONS"===F){const i=null===(j=l.buttons)||void 0===j?void 0:j.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return i?Object.assign(Object.assign({},y),{buttons:i}):y}if("limited_time_offer"===l.type&&"limited_time_offer"===F)return Object.assign(Object.assign({},y),{example:Object.assign(Object.assign({},y.example),{limited_time_offer:t})})}return l}));if(O.components=j,l)if("BODY"===F&&(null===(d=null==O?void 0:O.mapping)||void 0===d?void 0:d.body))O.mapping=Object.assign(Object.assign({},O.mapping),{body:null===(c=null===(r=O.mapping)||void 0===r?void 0:r.body)||void 0===c?void 0:c.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("TITLE"===F&&(null===(p=null==O?void 0:O.mapping)||void 0===p?void 0:p.title))O.mapping=Object.assign(Object.assign({},O.mapping),{title:null===(v=null===(m=O.mapping)||void 0===m?void 0:m.title)||void 0===v?void 0:v.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===F&&(null===(b=null==O?void 0:O.mapping)||void 0===b?void 0:b.header))O.mapping=Object.assign(Object.assign({},O.mapping),{header:O.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===F&&(null===(g=null==O?void 0:O.mapping)||void 0===g?void 0:g.buttons)){let l=-1,a=-1;j.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),O.mapping=Object.assign(Object.assign({},O.mapping),{buttons:O.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=_e&&_e>-1&&ge){const e=o(ge);e.components[Pe].cards[_e].components=O.components,e.mapping.cards[_e]=O.mapping,null==je||je(e)}else null==je||je(Object.assign({},O))}u((()=>{J&&(null==M||M())}),[J]),u((()=>{!function(){var e,t,l,i,a;const n="mobile"===pe?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(i=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!==i?i:"")+(null===(a=null==o?void 0:o.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);me===O.EMAIL&&(null==ye||ye(s))}()}),[Oe]),u((()=>{!function(){var e,t;const l=[];let i=[];if(me!==O.MESSAGE||fe){"link"===(null==z?void 0:z.type)?(l.push({label:"",options:[L,P]}),ne(L)):"date_time"===(null==z?void 0:z.type)?(l.push({label:"",options:[L,P]}),ne(w)):(l.push({label:"",options:[L,P,w]}),ne(P));const e=null!=he?he:[];ie([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:T.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())})}))]),i=[...l,...e]}else{const e=null!=he?he:[];ie([{label:"",options:[P,L]},...e]),i=[{label:"",options:[P,L]},...e]}if((me===O.WHATSAPP||me===O.EMAIL||me===O.MESSAGE||me===O.WEBPUSH||me===O.RCS)&&z.updatedValue)if(g.test(z.updatedValue)&&(me===O.WHATSAPP||me===O.RCS)||z.updatedValue.startsWith("{{")&&me!==O.WHATSAPP&&me!==O.RCS){const e=function(e,t,l){var i;let a={label:"",value:""};const n=l===(O.WHATSAPP||O.RCS)?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(q){let t=e.updatedValue;if(Te===y.CHATBOT&&"BUTTONS"===F){const l=null==K?void 0:K.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}a={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(i=e.updatedValue)&&void 0!==i?i:""}}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()&&(a=e)}))}));return a}(z,i,me);e.value&&ne(e)}else"date_time"===z.type?(ne(w),te(z.updatedValue),Ne(null!==(e=z.index)&&void 0!==e?e:0,z.updatedValue)):(null===(t=z.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(ne(L),te(z.updatedValue.split("https://")[1])):(ne(P),te(z.updatedValue))}()}),[_e]),u((()=>{pe&&ae&&ee&&setTimeout((()=>{Ue("custom_link"===(null==ae?void 0:ae.value)&&ee?ee.includes("https")?ee:`https://${ee}`:ee,ae.value)}),100)}),[pe]),u((()=>{!oe&&ae&&z.updatedValue&&setTimeout((()=>{Ue("custom_link"===(null==ae?void 0:ae.value)&&z.updatedValue?z.updatedValue.includes("https")?z.updatedValue:`https://${z.updatedValue}`:z.updatedValue,ae.value),se(!0)}),100)}),[ae]);const He=e=>{null==G||G(!1),"{{custom.url}}"===e.actualValue?we({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?we({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?we({label:e.displayName,selected:!0,value:"static_expiry"}):we({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})};function Re(e,t){var l;const i=o(ge),a=F.toLocaleLowerCase();(null===(l=i.webpushBroadcastConfig)||void 0===l?void 0:l[a])&&(i.webpushBroadcastConfig[a][e]=t),null==je||je(Object.assign({},i))}return e(k,Object.assign({channel:me,focused:J,onMouseEnter:()=>X(!0),onMouseLeave:()=>X(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(h,Object.assign({style:{color:ve&&!ae?_.content.negative:_.content.primary}},{children:[null===(D=z.variableName)||void 0===D?void 0:D.replace("{{","").replace("}}","")," ","link"===(null==z?void 0:z.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:q?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==ae?void 0:ae.label)?"space-between":"flex-end"}},{children:[t(f,Object.assign({numberOfLines:1},{children:Te===y.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(U=null==ae?void 0:ae.value)&&void 0!==U?U:"")?null==ae?void 0:ae.label:null==ae?void 0:ae.value:b(null!==(N=null==ae?void 0:ae.label)&&void 0!==N?N:"",20,!0)})),Ve||"date_time"===(null==z?void 0:z.type)&&Se?t(l,{}):t(i,{onClick:()=>{(()=>{let e=Array.isArray(ue)?[...ue]:[];const t=(t,l,i)=>{const a=C({variableList:e,categoryDisplayName:t,variableDisplayName:l,variableValue:i});Array.isArray(a)&&(e=a)};Te===y.CHATBOT&&Q!==x.URL&&"limited_time_offer"!==F&&t("Custom Variables","Custom Text","{{custom.text}}"),Q===x.URL&&Te===y.CHATBOT?t("Custom Variables","Custom URL","{{custom.url}}"):"limited_time_offer"===F?t("Static Variables","Static Expiry","{{static.expiry}}"):Q===x.COPY_CODE&&t("Custom Variables","Custom Text","{{custom.text}}"),de(e)})(),re((()=>He)),ce(!0)},width:24,height:24,color:_.content.primary})]})):t(m,{disabled:Ve,options:le,isSearchable:!1,onSelect:we,defaultOptions:ae?[Object.assign(Object.assign({},ae),{selected:!0})]:[]})})),("custom_text"===(null==ae?void 0:ae.value)||"custom_link"===(null==ae?void 0:ae.value))&&t(v,{state:Ve?"disabled":"none",labelText:"custom_text"===(null==ae?void 0:ae.value)?"Custom text value":"custom_link"===(null==ae?void 0:ae.value)?"Custom URL value":"",id:`variable-value-${null==ae?void 0:ae.value}-${Z}`,value:ee,errorMessage:ve&&(null===(H=null==ke?void 0:ke.buttons)||void 0===H?void 0:H.includes(null!==(R=null==z?void 0:z.index)&&void 0!==R?R:-1))?ee&&0!==ee.trim().length?"custom_link"!==ae.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${ee.trim()}`)&&0!==ee.trim().length?"custom_link"!==ae.value&&ee.length>30?"Length cannot be more than 30":"BUTTONS"===F&&"custom_link"!==ae.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:Ae||("custom_link"===(null==ae?void 0:ae.value)?2e3:"BUTTONS"===F?15:30),noKeyDownChange:!0,prefixText:"custom_link"===(null==ae?void 0:ae.value)?"https://":"",placeholder:"link"===z.type||"custom_link"===ae.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{De(ae.value,e)}}),"static_expiry"===(null==ae?void 0:ae.value)&&e("div",Object.assign({style:{position:"relative"}},{children:[(Ve||Be)&&e(A,Object.assign({onClick:e=>e.preventDefault(),style:{display:"flex",justifyContent:"space-between"}},{children:[t(B,{}),t(B,{})]})),t(p,{placement:"auto",time:n(ee?new Date(ee):new Date,"hh:mm a"),date:ee?new Date(ee):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{De("static_expiry",e.toISOString())}})]})),"static_expiry"===(null==ae?void 0:ae.value)&&Le&&t("div",Object.assign({style:{marginTop:8}},{children:t(r,{containerStyle:{padding:"4px 8px"},icon:()=>t(a,{width:16,height:16,color:_.content.secondary}),type:c.NEUTRAL,text:"Please use the same expiration code that you applied when creating \nthe code on Shopify"})})),"link"===z.type&&"custom_link"!==(null==ae?void 0:ae.value)&&!Ee&&!Ce&&Te===y.CHATBOT&&t(S,{isError:null!==(Y=null===(I=null==ke?void 0:ke.buttons)||void 0===I?void 0:I.includes(null!==(W=null==z?void 0:z.index)&&void 0!==W?W:-1))&&void 0!==Y&&Y,params:null!==($=z.queryParams)&&void 0!==$?$:[],onChange:e=>{Ue(z.updatedValue,"link",e)},variableValue:z.updatedValue})]}))};export{k as Container,D as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.654-beta-ctv.4",
3
+ "version": "0.0.654-beta-ctv.6",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",