@bikdotai/bik-component-library 0.0.697 → 0.0.698-beta.1

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.
Files changed (77) hide show
  1. package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
  2. package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  3. package/dist/cjs/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
  4. package/dist/cjs/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  5. package/dist/cjs/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
  6. package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.d.ts +1 -1
  7. package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.js +1 -1
  8. package/dist/cjs/components/data-source-panel/DataSourcePanel.d.ts +1 -1
  9. package/dist/cjs/components/data-source-panel/DataSourcePanel.js +1 -1
  10. package/dist/cjs/components/discount-modal/DiscountModal.d.ts +1 -1
  11. package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
  12. package/dist/cjs/components/dropdown/Common.styled.d.ts +1 -0
  13. package/dist/cjs/components/dropdown/Common.styled.js +3 -3
  14. package/dist/cjs/components/dropdown/DropdownPopover/index.d.ts +1 -0
  15. package/dist/cjs/components/dropdown/DropdownPopover/index.js +1 -1
  16. package/dist/cjs/components/dropdown-button/DropdownButton.js +1 -1
  17. package/dist/cjs/components/dropdown-button/DropdownButton.style.d.ts +1 -0
  18. package/dist/cjs/components/dropdown-button/DropdownButton.style.js +16 -3
  19. package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +1 -1
  20. package/dist/cjs/components/product-picker-v2/modal.d.ts +1 -1
  21. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  22. package/dist/cjs/components/product-picker-v2/productScreen.d.ts +1 -1
  23. package/dist/cjs/components/product-picker-v2/rearrangeScreen.d.ts +1 -1
  24. package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +1 -1
  25. package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +1 -1
  26. package/dist/cjs/components/product-picker-v2/utility.d.ts +1 -1
  27. package/dist/cjs/components/template-context-mapper/TemplateContextMapper.d.ts +1 -1
  28. package/dist/cjs/components/template-context-mapper/context/templateModalContext.d.ts +1 -1
  29. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
  30. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
  31. package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
  32. package/dist/cjs/components/template-context-mapper/utils/constants.d.ts +1 -0
  33. package/dist/cjs/components/template-context-mapper/utils/constants.js +1 -1
  34. package/dist/cjs/components/template-preview/models/TemplateMeta.d.ts +5 -0
  35. package/dist/cjs/components/template-preview/models/TemplateMeta.js +1 -1
  36. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.d.ts +1 -1
  37. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.js +1 -1
  38. package/dist/cjs/index.js +1 -1
  39. package/dist/esm/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
  40. package/dist/esm/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  41. package/dist/esm/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
  42. package/dist/esm/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  43. package/dist/esm/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
  44. package/dist/esm/components/data-source-panel/DataSourceInfoFooter.d.ts +1 -1
  45. package/dist/esm/components/data-source-panel/DataSourceInfoFooter.js +1 -1
  46. package/dist/esm/components/data-source-panel/DataSourcePanel.d.ts +1 -1
  47. package/dist/esm/components/data-source-panel/DataSourcePanel.js +1 -1
  48. package/dist/esm/components/discount-modal/DiscountModal.d.ts +1 -1
  49. package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
  50. package/dist/esm/components/dropdown/Common.styled.d.ts +1 -0
  51. package/dist/esm/components/dropdown/Common.styled.js +4 -4
  52. package/dist/esm/components/dropdown/DropdownPopover/index.d.ts +1 -0
  53. package/dist/esm/components/dropdown/DropdownPopover/index.js +1 -1
  54. package/dist/esm/components/dropdown-button/DropdownButton.js +1 -1
  55. package/dist/esm/components/dropdown-button/DropdownButton.style.d.ts +1 -0
  56. package/dist/esm/components/dropdown-button/DropdownButton.style.js +17 -4
  57. package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +1 -1
  58. package/dist/esm/components/product-picker-v2/modal.d.ts +1 -1
  59. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  60. package/dist/esm/components/product-picker-v2/productScreen.d.ts +1 -1
  61. package/dist/esm/components/product-picker-v2/rearrangeScreen.d.ts +1 -1
  62. package/dist/esm/components/product-picker-v2/searchScreen.d.ts +1 -1
  63. package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +1 -1
  64. package/dist/esm/components/product-picker-v2/utility.d.ts +1 -1
  65. package/dist/esm/components/template-context-mapper/TemplateContextMapper.d.ts +1 -1
  66. package/dist/esm/components/template-context-mapper/context/templateModalContext.d.ts +1 -1
  67. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
  68. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
  69. package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
  70. package/dist/esm/components/template-context-mapper/utils/constants.d.ts +1 -0
  71. package/dist/esm/components/template-context-mapper/utils/constants.js +1 -1
  72. package/dist/esm/components/template-preview/models/TemplateMeta.d.ts +5 -0
  73. package/dist/esm/components/template-preview/models/TemplateMeta.js +1 -1
  74. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.d.ts +1 -1
  75. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.js +1 -1
  76. package/dist/esm/index.js +1 -1
  77. package/package.json +1 -1
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import s from"../../assets/icons/box_search.svg.js";import i from"../../assets/icons/boxV2.svg.js";import o from"../../assets/icons/chevronDownOutline.svg.js";import n from"../../assets/icons/chevronUpOutline.svg.js";import r from"../../assets/icons/cross.svg.js";import l from"../../assets/icons/edit.svg.js";import a from"../../assets/icons/filePdf.svg.js";import d from"../../assets/icons/help.svg.js";import c from"../../assets/icons/info.svg.js";import p from"../../assets/icons/openai.svg.js";import u from"../../assets/icons/plus.svg.js";import g from"../../assets/icons/redirect.svg.js";import x from"../../assets/icons/text_t9.svg.js";import h from"../../assets/icons/website.svg.js";import{useState as j,useMemo as m,useEffect as f}from"react";import{COLORS as y}from"../../constants/Theme.js";import{Button as v}from"../button/Button.js";import{IconButton as b}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as I}from"../side-modal/SideModal.js";import{Tag as O}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as w,BodySecondary as S}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as N}from"./DataSourcePanel.style.js";import{intentConfig as F}from"./IntentConfig.js";import{DescriptionModal as k}from"./Modals/DescriptionModal.js";import{CustomDataType as A}from"./model.js";const _=_=>{var D,R;const{appType:P,storeId:B,messageSource:U,setMessageSourcePanel:K,hideCloseButton:M,isSourceInfoFetched:W,allSourceInfoDetail:$,ChecklistType:H,title:q,zeroStateButton:Q,editableSources:G,preFillTrainingSourceCount:Y,redirect:z,footerButtonOption:X,fetchTrainingSourceCount:V,fetchProductFAQCount:J,productSourceData:Z,reasonForAiGeneratedResponse:ee,showAiResponseReason:te,aiResponseLoading:se,productSearchRule:ie,onEditProductSearchRule:oe}=_,{sources:ne}=U,re=["blog","article","page","policy"],[le,ae]=j(!1),[de,ce]=j(!1),[pe,ue]=j(!1),[ge,xe]=j(0),[he,je]=j(),[me,fe]=j(null!=Y?Y:{}),[ye,ve]=j(!1),[be,Ce]=j(!1),Ie={};F.forEach((t=>{let{key:s,type:i,tagText:o}=t;H[s]&&(Ie[H[s]]=e.jsx(O,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Oe=ne.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Te=ne.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ee=m((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{H[t]&&(e[H[t]]=H[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[H]);f((()=>{var e,t,s,i;if(!(null==U?void 0:U.messageId))return;ae(!0),ce(!0),ue(!1!==(null===(t=null===(e=U.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=U.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=U.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));J(B,n).then((e=>xe(e))).then((()=>{Y?(fe(Y),setTimeout((()=>{ae(!1),ce(!1)}),100)):(setTimeout((()=>ae(!1)),100),V(B).then((e=>fe(e))).then((()=>setTimeout((()=>{ce(!1)}),100))))}))}),[J,V,null==U?void 0:U.messageId,U.sources,Y,B]);const we=e=>!!(e&&0===e.length||(null==U?void 0:U.isUnsatisfactoryAnswer)),Se=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=A.FILES:re.includes(e)?e=A.FETCHED_LINKS:"url"==e?e=A.WEBSITE_LINKS:"text"===e?e=A.TEXTS:"faq"===e&&(e=A.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Le=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Ne=t=>"products"==t||"product"==t?e.jsx(i,{height:16,width:16,color:y.content.secondary}):"files"==t?e.jsx(a,{height:16,width:16,color:y.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(h,{height:16,width:16,color:y.content.secondary}):"faq"==t?e.jsx(d,{height:16,width:16,color:y.content.secondary}):"texts"==t?e.jsx(x,{height:16,width:16,color:y.content.secondary}):e.jsx(p,{height:16,width:16,color:y.content.secondary}),Fe=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(le||!W)return e.jsx(N,{children:e.jsx(C,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const ke=s=>{const{title:i,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(S,{children:i}),P===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:y.surface.subdued,color:y.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500",border:`1px solid ${y.stroke.primary}`}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:P===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(n,{width:20,height:20,color:y.content.primary}):e.jsx(o,{width:20,height:20,color:y.content.primary})})]})),l&&d]})};return e.jsxs(e.Fragment,{children:[e.jsx(N,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",padding:0,paddingBottom:"12px"}},{children:[!!q&&e.jsx(E,{children:q}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(w,Object.assign({color:y.content.secondary},{children:"Intent"})),null!==(D=Ie[U.intent])&&void 0!==D?D:Ie.GENERIC,!M&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>K(void 0)},{children:e.jsx(r,{height:20,width:20,color:y.content.secondary})}))]})),ie&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(S,Object.assign({color:y.content.primary},{children:ie.rule_name})),oe&&ie.rule_id&&e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsx(s,{width:14,color:y.content.secondary}),e.jsx(w,Object.assign({color:y.content.secondary},{children:"Edit search rule"})),e.jsx(b,{Icon:l,height:16,width:16,bordered:!0,iconColor:y.content.primary,onClick:()=>oe(null==ie?void 0:ie.rule_id)})]}))]})),ie.keywords&&ie.keywords.length>0&&e.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:y.surface.subdued,borderRadius:"8px",border:`1px dashed ${y.stroke.primary}`}},{children:ie.keywords.map(((t,s)=>e.jsx(O,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),we(ne)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${y.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(c,{width:24,height:24,color:y.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(E,{children:"Insufficient data"})})),e.jsx(S,Object.assign({color:y.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),Q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(v,{LeadingIcon:null!==(t=Q.leadingIcon)&&void 0!==t?t:u,buttonText:null!==(s=Q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{Q.onClick()}})}))]}))})()})):!ie&&e.jsx(O,{LeadingIcon:c,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:U.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${P===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),pe&&!we(ne)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(L,{appType:P,storeId:B,messageSource:U,sourceIntent:null!==(R=U.intent)&&void 0!==R?R:H.GENERIC,faqCount:ge,trainingSourceCount:me,ShowTrainingDataSource:Ee,ChecklistType:H,footerButtonOption:X,isFooterLoading:de,reasonForAiGeneratedResponse:ee,showAiResponseReason:te,aiResponseLoading:se})})),!we(ne)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:Oe.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(ke,Object.assign({title:"Product Sources",count:Oe.length,isExpanded:P!==t.MANIFEST||ye,onToggle:()=>ve(!ye)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Oe.map(((t,s)=>{var i,o,n,r;const a=Se(t.type||t.subTitle||"OpenAI"),d=Se(t.type||t.subTitle||"OpenAI",!0),c=Le(a),p=null==G?void 0:G.includes(d),u=$[null!==(i=t.productId)&&void 0!==i?i:"Products"],x=t.title,h=t.productId&&(null==Z?void 0:Z[t.productId]),j=h&&h.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Oe?void 0:Oe.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ne(a),e.jsx(T,Object.assign({body:x,placement:"top"},{children:e.jsx(S,Object.assign({style:d==A.FETCHED_LINKS||d==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>d==A.FETCHED_LINKS||d==A.WEBSITE_LINKS?z(t):{}},{children:x}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==u?void 0:u.onEditClick(u.data,u.type),disabled:!u,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!u,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),h&&e.jsxs(w,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;je({title:x,description:Fe(h.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>je(void 0)})}},{children:`${null===(o=h.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>h.onEditFaqClick(h.faqs)},{children:`${null===(n=h.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(T,Object.assign({body:j,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=h.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Te.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(ke,Object.assign({title:"Content Sources",count:Te.length,isExpanded:P!==t.MANIFEST||be,onToggle:()=>Ce(!be)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Te.map(((t,s)=>{var i,o,n,r,a,d,c,p,u,x,h,j,m,f,v,C,I;const O=Se(t.type||t.subTitle||"OpenAI"),E=Se(t.type||t.subTitle||"OpenAI",!0),L=Le(O),N=null==G?void 0:G.includes(E),F="Products"===t.subTitle?$[null!==(i=t.productId)&&void 0!==i?i:"Products"]:$[null!==(o=t.docId)&&void 0!==o?o:""],k=E.toLowerCase()===(null===(n=A.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:E.toLowerCase()===(null===(a=A.FILES)||void 0===a?void 0:a.toLowerCase())||E.toLowerCase()===(null===(d=A.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||E.toLowerCase()===(null===(c=A.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:E.toLowerCase()===(null===(p=A.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===H.EMAIL_COLLECTION?L:t.title,_="faq"===E.toLowerCase()?null!==(h=null!==(u=null==F?void 0:F.content)&&void 0!==u?u:null===(x=null==F?void 0:F.data)||void 0===x?void 0:x.answer)&&void 0!==h?h:"":E.toLowerCase()===(null===(j=A.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||E.toLowerCase()===(null===(m=A.WEBSITE_LINKS)||void 0===m?void 0:m.toLowerCase())||E.toLowerCase()===(null===(f=A.TEXTS)||void 0===f?void 0:f.toLowerCase())?null!==(I=null!==(v=null==F?void 0:F.content)&&void 0!==v?v:null===(C=null==F?void 0:F.data)||void 0===C?void 0:C.fileContentText)&&void 0!==I?I:"":t.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Te?void 0:Te.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ne(O),e.jsx(T,Object.assign({body:k,placement:"top"},{children:e.jsx(S,Object.assign({style:E==A.FETCHED_LINKS||E==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>E==A.FETCHED_LINKS||E==A.WEBSITE_LINKS?z(t):{}},{children:k}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),(null!=_?_:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${y.stroke.primary}`,borderRadius:"4px",backgroundColor:y.surface.subdued}},{children:e.jsx(w,Object.assign({color:y.content.primary,className:"clamp-description"},{children:Fe(null!=_?_:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]}))]})}),he&&e.jsx(I,Object.assign({header:"Product description",onClose:()=>je(void 0),width:"30%"},{children:e.jsx(k,{title:he.title,description:he.description,imageUrl:he.imageUrl,onClose:he.onClose})}))]})};export{_ as DataSourcePanel};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth/models/bik-store";import s from"../../assets/icons/box_search.svg.js";import i from"../../assets/icons/boxV2.svg.js";import o from"../../assets/icons/chevronDownOutline.svg.js";import n from"../../assets/icons/chevronUpOutline.svg.js";import r from"../../assets/icons/cross.svg.js";import l from"../../assets/icons/edit.svg.js";import d from"../../assets/icons/filePdf.svg.js";import a from"../../assets/icons/help.svg.js";import c from"../../assets/icons/info.svg.js";import p from"../../assets/icons/openai.svg.js";import u from"../../assets/icons/plus.svg.js";import g from"../../assets/icons/redirect.svg.js";import x from"../../assets/icons/text_t9.svg.js";import h from"../../assets/icons/website.svg.js";import{useState as j,useMemo as m,useEffect as f}from"react";import{COLORS as y}from"../../constants/Theme.js";import{Button as v}from"../button/Button.js";import{IconButton as b}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as I}from"../side-modal/SideModal.js";import{Tag as O}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as w,BodySecondary as S}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as N}from"./DataSourcePanel.style.js";import{intentConfig as k}from"./IntentConfig.js";import{DescriptionModal as F}from"./Modals/DescriptionModal.js";import{CustomDataType as A}from"./model.js";const _=_=>{var D,R;const{appType:P,storeId:B,messageSource:U,setMessageSourcePanel:K,hideCloseButton:M,isSourceInfoFetched:W,allSourceInfoDetail:$,ChecklistType:H,title:q,zeroStateButton:Q,editableSources:G,preFillTrainingSourceCount:Y,redirect:z,footerButtonOption:X,fetchTrainingSourceCount:V,fetchProductFAQCount:J,productSourceData:Z,reasonForAiGeneratedResponse:ee,showAiResponseReason:te,aiResponseLoading:se,productSearchRule:ie,onEditProductSearchRule:oe}=_,{sources:ne}=U,re=["blog","article","page","policy"],[le,de]=j(!1),[ae,ce]=j(!1),[pe,ue]=j(!1),[ge,xe]=j(0),[he,je]=j(),[me,fe]=j(null!=Y?Y:{}),[ye,ve]=j(!1),[be,Ce]=j(!1),Ie={};k.forEach((t=>{let{key:s,type:i,tagText:o}=t;H[s]&&(Ie[H[s]]=e.jsx(O,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Oe=ne.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Te=ne.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ee=m((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{H[t]&&(e[H[t]]=H[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[H]);f((()=>{var e,t,s,i;if(!(null==U?void 0:U.messageId))return;de(!0),ce(!0),ue(!1!==(null===(t=null===(e=U.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=U.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=U.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));J(B,n).then((e=>xe(e))).then((()=>{Y?(fe(Y),setTimeout((()=>{de(!1),ce(!1)}),100)):(setTimeout((()=>de(!1)),100),V(B).then((e=>fe(e))).then((()=>setTimeout((()=>{ce(!1)}),100))))}))}),[J,V,null==U?void 0:U.messageId,U.sources,Y,B]);const we=e=>!!(e&&0===e.length||(null==U?void 0:U.isUnsatisfactoryAnswer)),Se=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=A.FILES:re.includes(e)?e=A.FETCHED_LINKS:"url"==e?e=A.WEBSITE_LINKS:"text"===e?e=A.TEXTS:"faq"===e&&(e=A.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Le=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Ne=t=>"products"==t||"product"==t?e.jsx(i,{height:16,width:16,color:y.content.secondary}):"files"==t?e.jsx(d,{height:16,width:16,color:y.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(h,{height:16,width:16,color:y.content.secondary}):"faq"==t?e.jsx(a,{height:16,width:16,color:y.content.secondary}):"texts"==t?e.jsx(x,{height:16,width:16,color:y.content.secondary}):e.jsx(p,{height:16,width:16,color:y.content.secondary}),ke=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(le||!W)return e.jsx(N,{children:e.jsx(C,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Fe=s=>{const{title:i,count:r,isExpanded:l,onToggle:d,children:a}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:d},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(S,{children:i}),P===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:y.surface.subdued,color:y.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500",border:`1px solid ${y.stroke.primary}`}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:P===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(n,{width:20,height:20,color:y.content.primary}):e.jsx(o,{width:20,height:20,color:y.content.primary})})]})),l&&a]})};return e.jsxs(e.Fragment,{children:[e.jsx(N,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",padding:0,paddingBottom:"12px"}},{children:[!!q&&e.jsx(E,{children:q}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(w,Object.assign({color:y.content.secondary},{children:"Intent"})),null!==(D=Ie[U.intent])&&void 0!==D?D:Ie.GENERIC,!M&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>K(void 0)},{children:e.jsx(r,{height:20,width:20,color:y.content.secondary})}))]})),ie&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(S,Object.assign({color:y.content.primary},{children:ie.rule_name})),oe&&ie.rule_id&&e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsx(s,{width:14,color:y.content.secondary}),e.jsx(w,Object.assign({color:y.content.secondary},{children:"Edit search rule"})),e.jsx(b,{Icon:l,height:16,width:16,bordered:!0,iconColor:y.content.primary,onClick:()=>oe(null==ie?void 0:ie.rule_id)})]}))]})),ie.keywords&&ie.keywords.length>0&&e.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:y.surface.subdued,borderRadius:"8px",border:`1px dashed ${y.stroke.primary}`}},{children:ie.keywords.map(((t,s)=>e.jsx(O,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),we(ne)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${y.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(c,{width:24,height:24,color:y.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(E,{children:"Insufficient data"})})),e.jsx(S,Object.assign({color:y.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),Q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(v,{LeadingIcon:null!==(t=Q.leadingIcon)&&void 0!==t?t:u,buttonText:null!==(s=Q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{Q.onClick()}})}))]}))})()})):!ie&&e.jsx(O,{LeadingIcon:c,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:U.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${P===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),pe&&!we(ne)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(L,{appType:P,storeId:B,messageSource:U,sourceIntent:null!==(R=U.intent)&&void 0!==R?R:H.GENERIC,faqCount:ge,trainingSourceCount:me,ShowTrainingDataSource:Ee,ChecklistType:H,footerButtonOption:X,isFooterLoading:ae,reasonForAiGeneratedResponse:ee,showAiResponseReason:te,aiResponseLoading:se})})),!we(ne)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:Oe.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(Fe,Object.assign({title:"Product Sources",count:Oe.length,isExpanded:P!==t.MANIFEST||ye,onToggle:()=>ve(!ye)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Oe.map(((t,s)=>{var i,o,n,r;const d=Se(t.type||t.subTitle||"OpenAI"),a=Se(t.type||t.subTitle||"OpenAI",!0),c=Le(d),p=null==G?void 0:G.includes(a),u=$[null!==(i=t.productId)&&void 0!==i?i:"Products"],x=t.title,h=t.productId&&(null==Z?void 0:Z[t.productId]),j=h&&h.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Oe?void 0:Oe.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ne(d),e.jsx(T,Object.assign({body:x,placement:"top"},{children:e.jsx(S,Object.assign({style:a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?z(t):{}},{children:x}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==u?void 0:u.onEditClick(u.data,u.type),disabled:!u,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!u,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),h&&e.jsxs(w,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;je({title:x,description:ke(h.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>je(void 0)})}},{children:`${null===(o=h.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>h.onEditFaqClick(h.faqs)},{children:`${null===(n=h.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(T,Object.assign({body:j,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=h.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Te.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(Fe,Object.assign({title:"Content Sources",count:Te.length,isExpanded:P!==t.MANIFEST||be,onToggle:()=>Ce(!be)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Te.map(((t,s)=>{var i,o,n,r,d,a,c,p,u,x,h,j,m,f,v,C,I;const O=Se(t.type||t.subTitle||"OpenAI"),E=Se(t.type||t.subTitle||"OpenAI",!0),L=Le(O),N=null==G?void 0:G.includes(E),k="Products"===t.subTitle?$[null!==(i=t.productId)&&void 0!==i?i:"Products"]:$[null!==(o=t.docId)&&void 0!==o?o:""],F=E.toLowerCase()===(null===(n=A.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:E.toLowerCase()===(null===(d=A.FILES)||void 0===d?void 0:d.toLowerCase())||E.toLowerCase()===(null===(a=A.FETCHED_LINKS)||void 0===a?void 0:a.toLowerCase())||E.toLowerCase()===(null===(c=A.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:E.toLowerCase()===(null===(p=A.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===H.EMAIL_COLLECTION?L:t.title,_="faq"===E.toLowerCase()?null!==(h=null!==(u=null==k?void 0:k.content)&&void 0!==u?u:null===(x=null==k?void 0:k.data)||void 0===x?void 0:x.answer)&&void 0!==h?h:"":E.toLowerCase()===(null===(j=A.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||E.toLowerCase()===(null===(m=A.WEBSITE_LINKS)||void 0===m?void 0:m.toLowerCase())||E.toLowerCase()===(null===(f=A.TEXTS)||void 0===f?void 0:f.toLowerCase())?null!==(I=null!==(v=null==k?void 0:k.content)&&void 0!==v?v:null===(C=null==k?void 0:k.data)||void 0===C?void 0:C.fileContentText)&&void 0!==I?I:"":t.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Te?void 0:Te.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ne(O),e.jsx(T,Object.assign({body:F,placement:"top"},{children:e.jsx(S,Object.assign({style:E==A.FETCHED_LINKS||E==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>E==A.FETCHED_LINKS||E==A.WEBSITE_LINKS?z(t):{}},{children:F}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==k?void 0:k.onEditClick(k.data,k.type),disabled:!k,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!k,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),(null!=_?_:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${y.stroke.primary}`,borderRadius:"4px",backgroundColor:y.surface.subdued}},{children:e.jsx(w,Object.assign({color:y.content.primary,className:"clamp-description"},{children:ke(null!=_?_:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]}))]})}),he&&e.jsx(I,Object.assign({header:"Product description",onClose:()=>je(void 0),width:"30%"},{children:e.jsx(F,{title:he.title,description:he.description,imageUrl:he.imageUrl,onClose:he.onClose})}))]})};export{_ as DataSourcePanel};
@@ -1,4 +1,4 @@
1
- import { ApplicationType } from '@bikdotai/bik-models/growth';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
2
  import React from 'react';
3
3
  import { ICouponData } from "./type";
4
4
  import { Collection, Product } from "../product-picker/type";
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as i}from"@bikdotai/bik-models/growth";import{useState as t,useEffect as o}from"react";import{DISCOUNT_TYPES as n,MIN_PURCHASE_REQUIREMENT as l,DISCOUNT_APPLIES_TO as r,OFFER_APPLIES_TO as d,initialStaticCouponErrorState as a,initialDynamicCouponErrorState as s,COUPON_EXPIRATION as c,DISCOUNT_TARGET_TYPES as u,DISCOUNT_TARGET_SELECTION as p,DISCOUNT_VALUE_TYPES as v}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as C}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as m,BodyCaption as b,TitleRegular as y}from"../TypographyStyle.js";import{DEFAULT_THEME as P}from"../../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"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as h}from"../modals/styledModal.js";import{ProductPickerContent as I}from"../product-picker/ProductPickerModal.js";import{Tag as f}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import E from"../../assets/icons/gift_icon.svg.js";import O from"../../assets/icons/percentage_icon.svg.js";import S from"../../assets/icons/shipping_icon.svg.js";import g from"../../assets/icons/triangle_error.svg.js";import j from"../../assets/icons/warning.svg.js";import{ProductPickerModal as x}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as V}from"../variable-picker-v3/model.js";import{VariablePicker as _}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as A,CouponTypeContainerStyled as D,VariablePickerContainer as k}from"./DiscountModal.styled.js";import{validateDiscountData as N,descriptionBuilder as F}from"./DiscountUtils.js";import w,{DISCOUNT_PRODUCTS as R}from"./DynamicCoupon/DynamicCoupon.js";import M from"./StaticCoupon/StaticCoupon.js";const q=q=>{var L,U,B,G,Y,X,Q,H,z,K,$;const Z=[{id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:q.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e.jsx(O,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:n.BUY_X_GET_Y,icon:i=>e.jsx(E,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:n.FREE_SHIPPING,icon:i=>e.jsx(S,{width:24,height:24,color:i})}],[J,W]=t(),[ee,ie]=t(),[te,oe]=t(),[ne,le]=t(null!==(L=q.data)&&void 0!==L?L:"string"==typeof q.hideOption?{isStaticCoupon:"dynamic"===q.hideOption}:{isStaticCoupon:!0}),[re,de]=t(!0),[ae,se]=t(),[ce,ue]=t((null===(U=q.data)||void 0===U?void 0:U.minAmount)?l.AMOUNT:(null===(B=q.data)||void 0===B?void 0:B.minQuantity)?l.QUANTITY:l.NA),[pe,ve]=t(r.ENTIRE_ORDER),[Ce,me]=t(d.SPECIFIC_PRODUCTS),[be,ye]=t(d.SPECIFIC_PRODUCTS),[Pe,he]=t(void 0),[Ie,fe]=t(void 0),[Te,Ee]=t(void 0),[Oe,Se]=t(void 0),[ge,je]=t(void 0),[xe,Ve]=t(void 0),[_e,Ae]=t(0),[De,ke]=t(""),[Ne,Fe]=t(Z[0]),[we,Re]=t(!1),[Me,qe]=t(a),[Le,Ue]=t(s),[Be,Ge]=t(c.DYNAMIC_EXPIRATION),Ye=[{value:n.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:ae===n.AMOUNT_OFF_ORDER},{value:n.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:ae===n.AMOUNT_OFF_PRODUCTS},{value:n.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:ae===n.BUY_X_GET_Y},{value:n.FREE_SHIPPING,label:"Free shipping",selected:ae===n.FREE_SHIPPING}];o((()=>{q.makeExpiryMandatory&&Re(!0)}),[q.makeExpiryMandatory]),o((()=>{var e,i,t,o,l,a,s,u;let p;const{tempCouponData:C,discountType:m}=Xe();se(m);const b=(e,i)=>{Fe(C.valueType===v.FIXED_AMOUNT?Z[e]:Z[i])},y=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==C?void 0:C.expireAfter)||(null==C?void 0:C.expireAt))&&(Re(!0),(null==C?void 0:C.expireAt)&&Ge(c.FIXED_EXPIRATION),(null==C?void 0:C.expireAfter)&&Ge(c.DYNAMIC_EXPIRATION)),m){case n.AMOUNT_OFF_ORDER:b(0,1),ve(r.ENTIRE_ORDER);break;case n.AMOUNT_OFF_PRODUCTS:b(0,1),(null===(e=C.entitledCollectionIds)||void 0===e?void 0:e.length)?ve(r.SPECIFIC_COLLECTIONS):(null===(i=C.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=C.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(ve(r.SPECIFIC_PRODUCTS),y(null===(o=C.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,Se)):ve(r.ENTIRE_ORDER);break;case n.BUY_X_GET_Y:Fe(Z[2]),(null===(l=C.entitledCollectionIds)||void 0===l?void 0:l.length)?ye(d.SPECIFIC_COLLECTIONS):(ye(d.SPECIFIC_PRODUCTS),y(null===(a=C.productVariableConf)||void 0===a?void 0:a.entitledProductVariable,Se)),(null===(s=C.prerequisiteCollectionIds)||void 0===s?void 0:s.length)?me(d.SPECIFIC_COLLECTIONS):(me(d.SPECIFIC_PRODUCTS),y(null===(u=C.productVariableConf)||void 0===u?void 0:u.prerequisiteProductVariable,je));break;case n.FREE_SHIPPING:Fe(Z[3])}le(Object.assign({},C)),q.hideProbability||(p=ze()),de(N(C,ce,m,q.hideProbability||!1,p,!!C.isStaticCoupon)),q.hideProbability||ze()}),[]),o((()=>{let e;q.hideProbability||(e=ze()),de(N(ne,ce,ae,q.hideProbability||!1,e,!!ne.isStaticCoupon))}),[ne,_e,ae,ce]),o((()=>{var e,i,t,o,n,l,r;if(!q.newPickerConf&&((null===(e=q.products)||void 0===e?void 0:e.length)||(null===(i=q.collection)||void 0===i?void 0:i.length))){if(q.products&&(null===(t=q.products)||void 0===t?void 0:t.length)){if(null===(o=q.data)||void 0===o?void 0:o.entitledProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}if(null===(n=q.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));he(e)}}if(q.collection&&q.collection.length){if(null===(l=q.data)||void 0===l?void 0:l.entitledCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ve(e)}if(null===(r=q.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}}}}),[q.products,q.collection]),o((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=q.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&fe(q.data.productsConf.entitledProducts),(null===(o=null===(t=q.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&he(q.data.productsConf.prerequisiteProducts),(null===(l=null===(n=q.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ve(q.data.collectionsConf.entitledCollections),(null===(d=null===(r=q.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&Ee(q.data.collectionsConf.prerequisiteCollections)}),[null===(G=q.data)||void 0===G?void 0:G.productsConf,null===(Y=q.data)||void 0===Y?void 0:Y.collectionsConf]),o((()=>{if(!Ie)return;if(q.newPickerConf){const e=[];return Object.values(Ie).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}const e=Ie.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}),[Ie]),o((()=>{if(!Pe)return;if(q.newPickerConf){const e=[];return Object.values(Pe).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}const e=Pe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}),[Pe]),o((()=>{if(!xe)return;if(q.newPickerConf){(null==xe?void 0:xe.isCustom)&&delete xe.isCustom;const e=Object.keys(xe).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}const e=xe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}),[xe]),o((()=>{if(!Te)return;if(q.newPickerConf){(null==Te?void 0:Te.isCustom)&&delete Te.isCustom;const e=Object.keys(Te).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}const e=Te.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}),[Te]);const Xe=()=>{var e,i;let t,o=ne;return ne.isStaticCoupon||(ne.targetType===u.SHIPPING_LINE?t=n.FREE_SHIPPING:ne.targetType===u.LINE_ITEM?t=ne.targetSelection===p.ENTITLED?(null===(e=ne.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=ne.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||ne.prerequisiteQuantity||ne.entitledQuantity?n.BUY_X_GET_Y:n.AMOUNT_OFF_PRODUCTS:n.AMOUNT_OFF_ORDER:(o=Object.assign(Object.assign({},o),{targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),t=n.AMOUNT_OFF_ORDER)),{discountType:t,tempCouponData:o}},Qe=()=>{qe(a),Ue(s)},He=e=>{var i;const t={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(i=ne.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":ne.isStaticCoupon?"Please add Probability":"Probability should be greater than 0",inValidDiscountAmount:"Please add Discount Amount",inValidMinimumAmount:"Specify minimum amount required",inValidMinimumQuantity:"Specify minimum items required",inValidCouponExpiry:"Please add Coupon Expiry",inValidProductSelection:"Please specify the products",inValidProductVariableSelection:"Please specify the product variables",inValidCollectionSelection:"Please specify the collections",inValidBuyXValue:"Please specify buy product quantity",inValidGetYValue:"Please specify get product quantity",inValidBuyXProductSelection:"Please specify the products",inValidBuyXCollectionSelection:"Please specify the collections",inValidGetYProductSelection:"Please specify the products",inValidGetYCollectionSelection:"Please specify the collections",inValidBuyXProductVariableSelection:"Please specify the product variables",inValidGetYProductVariableSelection:"Please specify the product variables"};let o="";Object.keys(e).forEach((i=>{e[i]&&(o=t[i])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(ke(n>1?"Please add discount details":o),!0)},ze=()=>{if(!q.quadrant||!q.probability)return;const e=[...q.probability];let i=[];e.length>=q.quadrant&&e.splice(q.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(ne.probability||0);return Ae(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ke=e=>{var i,t,o,l,r,d,a,s,c,C,m,b,y,P,h,I;const f=e.value;se(f),he([]),fe([]),Ee([]),Ve([]),f===n.FREE_SHIPPING?le({value:100,targetSelection:p.ALL,targetType:u.SHIPPING_LINE,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(i=ne.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=ne.expireAfter)&&void 0!==t?t:void 0,probability:ne.probability,minQuantity:null!==(o=ne.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(l=ne.minAmount)&&void 0!==l?l:void 0}):f===n.BUY_X_GET_Y?le({value:100,targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(r=ne.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(d=ne.expireAfter)&&void 0!==d?d:void 0,probability:ne.probability,minQuantity:void 0,minAmount:void 0}):f===n.AMOUNT_OFF_ORDER?le({targetSelection:p.ALL,targetType:u.LINE_ITEM,valueType:null!==(a=ne.valueType)&&void 0!==a?a:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(s=ne.expireAt)&&void 0!==s?s:void 0,expireAfter:null!==(c=ne.expireAfter)&&void 0!==c?c:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(C=ne.minQuantity)&&void 0!==C?C:void 0,minAmount:null!==(m=ne.minAmount)&&void 0!==m?m:void 0}):f===n.AMOUNT_OFF_PRODUCTS&&le({targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:null!==(b=ne.valueType)&&void 0!==b?b:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(y=ne.expireAt)&&void 0!==y?y:void 0,expireAfter:null!==(P=ne.expireAfter)&&void 0!==P?P:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(h=ne.minQuantity)&&void 0!==h?h:void 0,minAmount:null!==(I=ne.minAmount)&&void 0!==I?I:void 0})},$e=i=>i&&e.jsx(f,{theme:"light",tagText:i,type:"negative",LeadingIcon:j});return e.jsxs(h,Object.assign({width:(te||J)&&q.newPickerConf?"25px":"640px",open:q.isOpen,hideCrossButton:!!ee,headingTitle:J?"Select Products":q.title,headingSubtitle:J?void 0:q.subTitle,footerLeftCustomElement:De?$e(De):q.errorMsg?$e(q.errorMsg):!q.quadrant||q.hideProbability?e.jsx(e.Fragment,{}):_e<=1?e.jsx(f,{theme:"light",tagText:`Current probability sum: ${_e}`,type:"white"}):e.jsx(T,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(f,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${_e}`,type:"negative",LeadingIcon:g})})})),headerRightCustomElement:q.allowStaticCoupon||J?void 0:e.jsx(C,{options:Ye,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ke(e)}}),onClose:q.onClose,footerContainerStyle:{borderTop:`1px solid ${P.colorsV2.stroke.primary}`},primaryButton:J?{buttonType:"primary",onClick:()=>{W(void 0)},buttonText:"Add"}:te?{buttonType:"primary",onClick:()=>{oe(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(X=q.loading)&&void 0!==X&&X,onClick:()=>{var e,i,t,o,a;if(Qe(),ne.isStaticCoupon){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=ne,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!q.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(He(r))return void qe(r);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:ne.title})}else{const s={invalidCouponTitle:!ne.title,inValidProbability:!q.hideProbability&&(null!==(e=ne.probability)&&void 0!==e?e:-1)<=0||(null!==(i=ne.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=ne.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!ne.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(ae!==n.BUY_X_GET_Y&&ce!==l.NA){const{minAmount:e,minQuantity:i}=ne;s.inValidMinimumAmount=ce===l.AMOUNT&&!e,s.inValidMinimumQuantity=ce===l.QUANTITY&&!i}if(we&&(s.inValidCouponExpiry=!ne.expireAt&&!ne.expireAfter),ae!==n.AMOUNT_OFF_ORDER&&ae!==n.AMOUNT_OFF_PRODUCTS||(pe!==r.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidProductSelection=!0,s.inValidProductVariableSelection=!0),pe===r.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidCollectionSelection=!0)),ae===n.BUY_X_GET_Y&&(ne.prerequisiteQuantity||(s.inValidBuyXValue=!0),ne.entitledQuantity||(s.inValidGetYValue=!0),Ce!==d.SPECIFIC_PRODUCTS||!Pe||Object.keys(Pe).length||ge||(s.inValidBuyXProductSelection=!0,s.inValidBuyXProductVariableSelection=!0),Ce===d.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(s.inValidBuyXCollectionSelection=!0),be!==d.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidGetYProductSelection=!0,s.inValidGetYProductVariableSelection=!0),be===d.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidGetYCollectionSelection=!0)),He(s))return void Ue(s);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked(Object.assign(Object.assign({},ne),{description:F(ne,q.currency,null!==(o=q.products)&&void 0!==o?o:[],null!==(a=q.collection)&&void 0!==a?a:[]),productsConf:{entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[]},collectionsConf:{entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=Oe?Oe:{},prerequisiteProductVariable:null!=ge?ge:{}}}))}}},secondaryButton:J?{buttonType:"tertiaryGray",onClick:()=>{W(void 0)},buttonText:"Back"}:te?{buttonType:"tertiaryGray",onClick:()=>{oe(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:q.onClose,buttonText:"Cancel"}},{children:[!J&&!te&&e.jsxs(A,{children:[q.allowStaticCoupon&&!J&&e.jsxs(D,Object.assign({selectedDiv:ne.isStaticCoupon?1:2},{children:["static"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{ne.isStaticCoupon||(le({isStaticCoupon:!0,quadrant:ne.quadrant}),ke(""),Qe())}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?P.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{color:P.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;ne.isStaticCoupon&&(se(n.AMOUNT_OFF_ORDER),le({isStaticCoupon:!1,quadrant:ne.quadrant,targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),ke(""),Qe(),Fe({id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i}},{children:q.currency||""}))}),Re(null!==(i=q.makeExpiryMandatory)&&void 0!==i&&i),ue(l.NA))}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?void 0:P.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{}:{color:P.colorsV2.content.brand}},{children:"Code will be unique for all customers, with the first 5 letters of the customer's name, followed by 10 random characters."}))]}))]})),e.jsx(y,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),ne.isStaticCoupon&&!J&&e.jsx(M,{discountData:ne,setDiscountData:le,hideProbability:q.hideProbability||!1,discountAdminUrl:q.discountAdminUrl,staticDiscountValidationError:Me,currency:q.currency}),!ne.isStaticCoupon&&!J&&!te&&e.jsx(w,{currency:q.currency,entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[],setEntitledProducts:fe,setPrerequisiteProducts:he,discountData:ne,productPickerOpen:J,productVariablePickerOpen:ee,setIsProductPickerOpen:W,setIsProductVariablePickerOpen:ie,setDiscountData:le,selectedCouponType:ae,setSelectedCouponType:se,selectedMinimumRequirement:ce,setSelectedMinimumRequirement:ue,discountCouponAppliesTo:pe,offerAppliesToBuy:Ce,offerAppliesToGet:be,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:me,setOfferAppliesToGet:ye,hideProbability:q.hideProbability||!1,hideExpiration:q.hideExpiration||!1,allowStaticCoupon:q.allowStaticCoupon,onChangeCouponType:Ke,collectionPickerOpen:te,entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[],setIsCollectionPickerOpen:oe,setEntitledCollections:Ve,setPrerequisiteCollections:Ee,useNewPicker:!!q.newPickerConf,setSelectedDiscountDetails:Fe,selectedDiscountDetails:Ne,isProductVariableSupported:q.isProductVariableSupported,entitledProductVariable:Oe,setEntitledProductVariable:Se,preRequisiteProductVariable:ge,setPreRequisiteProductVariable:je,productVariableList:q.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:Re,dynamicDiscountValidationError:Le,setDynamicDiscountValidationError:Ue,setValidationErrorMessage:ke,resetValidationErrors:Qe,discountDetailsOptions:Z,selectedExpiration:Be,setSelectedExpiration:Ge,makeExpiryMandatory:!!q.makeExpiryMandatory})]}),!!J&&e.jsxs(e.Fragment,{children:[!q.newPickerConf&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(I,{show:!0,onSave:()=>{},products:null!==(Q=q.products)&&void 0!==Q?Q:[],title:"Select Products",onClose:()=>{W(void 0)},selectedProducts:null!==(H=J===R.ENTITLED?Ie:Pe)&&void 0!==H?H:[],setSelectedProducts:J===R.ENTITLED?fe:he,onSearchKeyChange:q.onProductSearch})})),q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>W(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.fetchCollections)?q.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=q.newPickerConf)||void 0===l?void 0:l.fetchProducts)?q.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:J===R.ENTITLED?Ie:Pe,onAdd:e=>{J===R.ENTITLED?fe(e):he(e),W(void 0)},zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=q.newPickerConf)||void 0===n?void 0:n.searchInCollection)?q.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.searchProducts)?q.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!te&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxs(e.Fragment,{children:[q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>oe(void 0),collectionFetcher:q.newPickerConf.fetchCollections,productFetcher:q.newPickerConf.fetchProducts,selectedItems:te===R.ENTITLED?xe:Te,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),te===R.ENTITLED?Ve(e):Ee(e),oe(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:q.newPickerConf.searchInCollection,searchFetcher:q.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!q.newPickerConf&&e.jsx(I,{show:!0,onSave:()=>{},products:null!==(z=q.collection)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{oe(void 0)},selectedProducts:null!==(K=te===R.ENTITLED?xe:Te)&&void 0!==K?K:[],setSelectedProducts:te===R.ENTITLED?Ve:Ee,onSearchKeyChange:q.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),ee&&e.jsx(k,{children:e.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsx(_,{type:V.EMBEDDED,data:null!==($=q.productVariableList)&&void 0!==$?$:[],showHeader:!0,onSelect:e=>{if(ee===R.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;Se({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}if(ee===R.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;je({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}},onClose:()=>{ie(void 0)}})}))})]}))};export{q as DiscountModal};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as i}from"@bikdotai/bik-models/growth/models/bik-store";import{useState as t,useEffect as o}from"react";import{DISCOUNT_TYPES as n,MIN_PURCHASE_REQUIREMENT as l,DISCOUNT_APPLIES_TO as r,OFFER_APPLIES_TO as d,initialStaticCouponErrorState as a,initialDynamicCouponErrorState as s,COUPON_EXPIRATION as c,DISCOUNT_TARGET_TYPES as u,DISCOUNT_TARGET_SELECTION as p,DISCOUNT_VALUE_TYPES as v}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as C}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as m,BodyCaption as b,TitleRegular as y}from"../TypographyStyle.js";import{DEFAULT_THEME as P}from"../../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"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as h}from"../modals/styledModal.js";import{ProductPickerContent as I}from"../product-picker/ProductPickerModal.js";import{Tag as f}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import E from"../../assets/icons/gift_icon.svg.js";import O from"../../assets/icons/percentage_icon.svg.js";import S from"../../assets/icons/shipping_icon.svg.js";import g from"../../assets/icons/triangle_error.svg.js";import j from"../../assets/icons/warning.svg.js";import{ProductPickerModal as x}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as V}from"../variable-picker-v3/model.js";import{VariablePicker as _}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as A,CouponTypeContainerStyled as D,VariablePickerContainer as k}from"./DiscountModal.styled.js";import{validateDiscountData as N,descriptionBuilder as F}from"./DiscountUtils.js";import w,{DISCOUNT_PRODUCTS as R}from"./DynamicCoupon/DynamicCoupon.js";import M from"./StaticCoupon/StaticCoupon.js";const q=q=>{var L,U,B,G,Y,X,Q,H,z,K,$;const Z=[{id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:q.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e.jsx(O,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:n.BUY_X_GET_Y,icon:i=>e.jsx(E,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:n.FREE_SHIPPING,icon:i=>e.jsx(S,{width:24,height:24,color:i})}],[J,W]=t(),[ee,ie]=t(),[te,oe]=t(),[ne,le]=t(null!==(L=q.data)&&void 0!==L?L:"string"==typeof q.hideOption?{isStaticCoupon:"dynamic"===q.hideOption}:{isStaticCoupon:!0}),[re,de]=t(!0),[ae,se]=t(),[ce,ue]=t((null===(U=q.data)||void 0===U?void 0:U.minAmount)?l.AMOUNT:(null===(B=q.data)||void 0===B?void 0:B.minQuantity)?l.QUANTITY:l.NA),[pe,ve]=t(r.ENTIRE_ORDER),[Ce,me]=t(d.SPECIFIC_PRODUCTS),[be,ye]=t(d.SPECIFIC_PRODUCTS),[Pe,he]=t(void 0),[Ie,fe]=t(void 0),[Te,Ee]=t(void 0),[Oe,Se]=t(void 0),[ge,je]=t(void 0),[xe,Ve]=t(void 0),[_e,Ae]=t(0),[De,ke]=t(""),[Ne,Fe]=t(Z[0]),[we,Re]=t(!1),[Me,qe]=t(a),[Le,Ue]=t(s),[Be,Ge]=t(c.DYNAMIC_EXPIRATION),Ye=[{value:n.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:ae===n.AMOUNT_OFF_ORDER},{value:n.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:ae===n.AMOUNT_OFF_PRODUCTS},{value:n.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:ae===n.BUY_X_GET_Y},{value:n.FREE_SHIPPING,label:"Free shipping",selected:ae===n.FREE_SHIPPING}];o((()=>{q.makeExpiryMandatory&&Re(!0)}),[q.makeExpiryMandatory]),o((()=>{var e,i,t,o,l,a,s,u;let p;const{tempCouponData:C,discountType:m}=Xe();se(m);const b=(e,i)=>{Fe(C.valueType===v.FIXED_AMOUNT?Z[e]:Z[i])},y=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==C?void 0:C.expireAfter)||(null==C?void 0:C.expireAt))&&(Re(!0),(null==C?void 0:C.expireAt)&&Ge(c.FIXED_EXPIRATION),(null==C?void 0:C.expireAfter)&&Ge(c.DYNAMIC_EXPIRATION)),m){case n.AMOUNT_OFF_ORDER:b(0,1),ve(r.ENTIRE_ORDER);break;case n.AMOUNT_OFF_PRODUCTS:b(0,1),(null===(e=C.entitledCollectionIds)||void 0===e?void 0:e.length)?ve(r.SPECIFIC_COLLECTIONS):(null===(i=C.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=C.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(ve(r.SPECIFIC_PRODUCTS),y(null===(o=C.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,Se)):ve(r.ENTIRE_ORDER);break;case n.BUY_X_GET_Y:Fe(Z[2]),(null===(l=C.entitledCollectionIds)||void 0===l?void 0:l.length)?ye(d.SPECIFIC_COLLECTIONS):(ye(d.SPECIFIC_PRODUCTS),y(null===(a=C.productVariableConf)||void 0===a?void 0:a.entitledProductVariable,Se)),(null===(s=C.prerequisiteCollectionIds)||void 0===s?void 0:s.length)?me(d.SPECIFIC_COLLECTIONS):(me(d.SPECIFIC_PRODUCTS),y(null===(u=C.productVariableConf)||void 0===u?void 0:u.prerequisiteProductVariable,je));break;case n.FREE_SHIPPING:Fe(Z[3])}le(Object.assign({},C)),q.hideProbability||(p=ze()),de(N(C,ce,m,q.hideProbability||!1,p,!!C.isStaticCoupon)),q.hideProbability||ze()}),[]),o((()=>{let e;q.hideProbability||(e=ze()),de(N(ne,ce,ae,q.hideProbability||!1,e,!!ne.isStaticCoupon))}),[ne,_e,ae,ce]),o((()=>{var e,i,t,o,n,l,r;if(!q.newPickerConf&&((null===(e=q.products)||void 0===e?void 0:e.length)||(null===(i=q.collection)||void 0===i?void 0:i.length))){if(q.products&&(null===(t=q.products)||void 0===t?void 0:t.length)){if(null===(o=q.data)||void 0===o?void 0:o.entitledProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}if(null===(n=q.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));he(e)}}if(q.collection&&q.collection.length){if(null===(l=q.data)||void 0===l?void 0:l.entitledCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ve(e)}if(null===(r=q.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}}}}),[q.products,q.collection]),o((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=q.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&fe(q.data.productsConf.entitledProducts),(null===(o=null===(t=q.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&he(q.data.productsConf.prerequisiteProducts),(null===(l=null===(n=q.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ve(q.data.collectionsConf.entitledCollections),(null===(d=null===(r=q.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&Ee(q.data.collectionsConf.prerequisiteCollections)}),[null===(G=q.data)||void 0===G?void 0:G.productsConf,null===(Y=q.data)||void 0===Y?void 0:Y.collectionsConf]),o((()=>{if(!Ie)return;if(q.newPickerConf){const e=[];return Object.values(Ie).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}const e=Ie.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}),[Ie]),o((()=>{if(!Pe)return;if(q.newPickerConf){const e=[];return Object.values(Pe).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}const e=Pe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}),[Pe]),o((()=>{if(!xe)return;if(q.newPickerConf){(null==xe?void 0:xe.isCustom)&&delete xe.isCustom;const e=Object.keys(xe).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}const e=xe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}),[xe]),o((()=>{if(!Te)return;if(q.newPickerConf){(null==Te?void 0:Te.isCustom)&&delete Te.isCustom;const e=Object.keys(Te).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}const e=Te.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}),[Te]);const Xe=()=>{var e,i;let t,o=ne;return ne.isStaticCoupon||(ne.targetType===u.SHIPPING_LINE?t=n.FREE_SHIPPING:ne.targetType===u.LINE_ITEM?t=ne.targetSelection===p.ENTITLED?(null===(e=ne.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=ne.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||ne.prerequisiteQuantity||ne.entitledQuantity?n.BUY_X_GET_Y:n.AMOUNT_OFF_PRODUCTS:n.AMOUNT_OFF_ORDER:(o=Object.assign(Object.assign({},o),{targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),t=n.AMOUNT_OFF_ORDER)),{discountType:t,tempCouponData:o}},Qe=()=>{qe(a),Ue(s)},He=e=>{var i;const t={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(i=ne.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":ne.isStaticCoupon?"Please add Probability":"Probability should be greater than 0",inValidDiscountAmount:"Please add Discount Amount",inValidMinimumAmount:"Specify minimum amount required",inValidMinimumQuantity:"Specify minimum items required",inValidCouponExpiry:"Please add Coupon Expiry",inValidProductSelection:"Please specify the products",inValidProductVariableSelection:"Please specify the product variables",inValidCollectionSelection:"Please specify the collections",inValidBuyXValue:"Please specify buy product quantity",inValidGetYValue:"Please specify get product quantity",inValidBuyXProductSelection:"Please specify the products",inValidBuyXCollectionSelection:"Please specify the collections",inValidGetYProductSelection:"Please specify the products",inValidGetYCollectionSelection:"Please specify the collections",inValidBuyXProductVariableSelection:"Please specify the product variables",inValidGetYProductVariableSelection:"Please specify the product variables"};let o="";Object.keys(e).forEach((i=>{e[i]&&(o=t[i])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(ke(n>1?"Please add discount details":o),!0)},ze=()=>{if(!q.quadrant||!q.probability)return;const e=[...q.probability];let i=[];e.length>=q.quadrant&&e.splice(q.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(ne.probability||0);return Ae(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ke=e=>{var i,t,o,l,r,d,a,s,c,C,m,b,y,P,h,I;const f=e.value;se(f),he([]),fe([]),Ee([]),Ve([]),f===n.FREE_SHIPPING?le({value:100,targetSelection:p.ALL,targetType:u.SHIPPING_LINE,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(i=ne.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=ne.expireAfter)&&void 0!==t?t:void 0,probability:ne.probability,minQuantity:null!==(o=ne.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(l=ne.minAmount)&&void 0!==l?l:void 0}):f===n.BUY_X_GET_Y?le({value:100,targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(r=ne.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(d=ne.expireAfter)&&void 0!==d?d:void 0,probability:ne.probability,minQuantity:void 0,minAmount:void 0}):f===n.AMOUNT_OFF_ORDER?le({targetSelection:p.ALL,targetType:u.LINE_ITEM,valueType:null!==(a=ne.valueType)&&void 0!==a?a:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(s=ne.expireAt)&&void 0!==s?s:void 0,expireAfter:null!==(c=ne.expireAfter)&&void 0!==c?c:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(C=ne.minQuantity)&&void 0!==C?C:void 0,minAmount:null!==(m=ne.minAmount)&&void 0!==m?m:void 0}):f===n.AMOUNT_OFF_PRODUCTS&&le({targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:null!==(b=ne.valueType)&&void 0!==b?b:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(y=ne.expireAt)&&void 0!==y?y:void 0,expireAfter:null!==(P=ne.expireAfter)&&void 0!==P?P:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(h=ne.minQuantity)&&void 0!==h?h:void 0,minAmount:null!==(I=ne.minAmount)&&void 0!==I?I:void 0})},$e=i=>i&&e.jsx(f,{theme:"light",tagText:i,type:"negative",LeadingIcon:j});return e.jsxs(h,Object.assign({width:(te||J)&&q.newPickerConf?"25px":"640px",open:q.isOpen,hideCrossButton:!!ee,headingTitle:J?"Select Products":q.title,headingSubtitle:J?void 0:q.subTitle,footerLeftCustomElement:De?$e(De):q.errorMsg?$e(q.errorMsg):!q.quadrant||q.hideProbability?e.jsx(e.Fragment,{}):_e<=1?e.jsx(f,{theme:"light",tagText:`Current probability sum: ${_e}`,type:"white"}):e.jsx(T,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(f,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${_e}`,type:"negative",LeadingIcon:g})})})),headerRightCustomElement:q.allowStaticCoupon||J?void 0:e.jsx(C,{options:Ye,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ke(e)}}),onClose:q.onClose,footerContainerStyle:{borderTop:`1px solid ${P.colorsV2.stroke.primary}`},primaryButton:J?{buttonType:"primary",onClick:()=>{W(void 0)},buttonText:"Add"}:te?{buttonType:"primary",onClick:()=>{oe(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(X=q.loading)&&void 0!==X&&X,onClick:()=>{var e,i,t,o,a;if(Qe(),ne.isStaticCoupon){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=ne,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!q.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(He(r))return void qe(r);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:ne.title})}else{const s={invalidCouponTitle:!ne.title,inValidProbability:!q.hideProbability&&(null!==(e=ne.probability)&&void 0!==e?e:-1)<=0||(null!==(i=ne.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=ne.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!ne.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(ae!==n.BUY_X_GET_Y&&ce!==l.NA){const{minAmount:e,minQuantity:i}=ne;s.inValidMinimumAmount=ce===l.AMOUNT&&!e,s.inValidMinimumQuantity=ce===l.QUANTITY&&!i}if(we&&(s.inValidCouponExpiry=!ne.expireAt&&!ne.expireAfter),ae!==n.AMOUNT_OFF_ORDER&&ae!==n.AMOUNT_OFF_PRODUCTS||(pe!==r.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidProductSelection=!0,s.inValidProductVariableSelection=!0),pe===r.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidCollectionSelection=!0)),ae===n.BUY_X_GET_Y&&(ne.prerequisiteQuantity||(s.inValidBuyXValue=!0),ne.entitledQuantity||(s.inValidGetYValue=!0),Ce!==d.SPECIFIC_PRODUCTS||!Pe||Object.keys(Pe).length||ge||(s.inValidBuyXProductSelection=!0,s.inValidBuyXProductVariableSelection=!0),Ce===d.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(s.inValidBuyXCollectionSelection=!0),be!==d.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidGetYProductSelection=!0,s.inValidGetYProductVariableSelection=!0),be===d.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidGetYCollectionSelection=!0)),He(s))return void Ue(s);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked(Object.assign(Object.assign({},ne),{description:F(ne,q.currency,null!==(o=q.products)&&void 0!==o?o:[],null!==(a=q.collection)&&void 0!==a?a:[]),productsConf:{entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[]},collectionsConf:{entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=Oe?Oe:{},prerequisiteProductVariable:null!=ge?ge:{}}}))}}},secondaryButton:J?{buttonType:"tertiaryGray",onClick:()=>{W(void 0)},buttonText:"Back"}:te?{buttonType:"tertiaryGray",onClick:()=>{oe(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:q.onClose,buttonText:"Cancel"}},{children:[!J&&!te&&e.jsxs(A,{children:[q.allowStaticCoupon&&!J&&e.jsxs(D,Object.assign({selectedDiv:ne.isStaticCoupon?1:2},{children:["static"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{ne.isStaticCoupon||(le({isStaticCoupon:!0,quadrant:ne.quadrant}),ke(""),Qe())}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?P.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{color:P.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;ne.isStaticCoupon&&(se(n.AMOUNT_OFF_ORDER),le({isStaticCoupon:!1,quadrant:ne.quadrant,targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),ke(""),Qe(),Fe({id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i}},{children:q.currency||""}))}),Re(null!==(i=q.makeExpiryMandatory)&&void 0!==i&&i),ue(l.NA))}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?void 0:P.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{}:{color:P.colorsV2.content.brand}},{children:"Code will be unique for all customers, with the first 5 letters of the customer's name, followed by 10 random characters."}))]}))]})),e.jsx(y,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),ne.isStaticCoupon&&!J&&e.jsx(M,{discountData:ne,setDiscountData:le,hideProbability:q.hideProbability||!1,discountAdminUrl:q.discountAdminUrl,staticDiscountValidationError:Me,currency:q.currency}),!ne.isStaticCoupon&&!J&&!te&&e.jsx(w,{currency:q.currency,entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[],setEntitledProducts:fe,setPrerequisiteProducts:he,discountData:ne,productPickerOpen:J,productVariablePickerOpen:ee,setIsProductPickerOpen:W,setIsProductVariablePickerOpen:ie,setDiscountData:le,selectedCouponType:ae,setSelectedCouponType:se,selectedMinimumRequirement:ce,setSelectedMinimumRequirement:ue,discountCouponAppliesTo:pe,offerAppliesToBuy:Ce,offerAppliesToGet:be,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:me,setOfferAppliesToGet:ye,hideProbability:q.hideProbability||!1,hideExpiration:q.hideExpiration||!1,allowStaticCoupon:q.allowStaticCoupon,onChangeCouponType:Ke,collectionPickerOpen:te,entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[],setIsCollectionPickerOpen:oe,setEntitledCollections:Ve,setPrerequisiteCollections:Ee,useNewPicker:!!q.newPickerConf,setSelectedDiscountDetails:Fe,selectedDiscountDetails:Ne,isProductVariableSupported:q.isProductVariableSupported,entitledProductVariable:Oe,setEntitledProductVariable:Se,preRequisiteProductVariable:ge,setPreRequisiteProductVariable:je,productVariableList:q.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:Re,dynamicDiscountValidationError:Le,setDynamicDiscountValidationError:Ue,setValidationErrorMessage:ke,resetValidationErrors:Qe,discountDetailsOptions:Z,selectedExpiration:Be,setSelectedExpiration:Ge,makeExpiryMandatory:!!q.makeExpiryMandatory})]}),!!J&&e.jsxs(e.Fragment,{children:[!q.newPickerConf&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(I,{show:!0,onSave:()=>{},products:null!==(Q=q.products)&&void 0!==Q?Q:[],title:"Select Products",onClose:()=>{W(void 0)},selectedProducts:null!==(H=J===R.ENTITLED?Ie:Pe)&&void 0!==H?H:[],setSelectedProducts:J===R.ENTITLED?fe:he,onSearchKeyChange:q.onProductSearch})})),q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>W(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.fetchCollections)?q.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=q.newPickerConf)||void 0===l?void 0:l.fetchProducts)?q.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:J===R.ENTITLED?Ie:Pe,onAdd:e=>{J===R.ENTITLED?fe(e):he(e),W(void 0)},zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=q.newPickerConf)||void 0===n?void 0:n.searchInCollection)?q.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.searchProducts)?q.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!te&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxs(e.Fragment,{children:[q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>oe(void 0),collectionFetcher:q.newPickerConf.fetchCollections,productFetcher:q.newPickerConf.fetchProducts,selectedItems:te===R.ENTITLED?xe:Te,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),te===R.ENTITLED?Ve(e):Ee(e),oe(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:q.newPickerConf.searchInCollection,searchFetcher:q.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!q.newPickerConf&&e.jsx(I,{show:!0,onSave:()=>{},products:null!==(z=q.collection)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{oe(void 0)},selectedProducts:null!==(K=te===R.ENTITLED?xe:Te)&&void 0!==K?K:[],setSelectedProducts:te===R.ENTITLED?Ve:Ee,onSearchKeyChange:q.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),ee&&e.jsx(k,{children:e.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsx(_,{type:V.EMBEDDED,data:null!==($=q.productVariableList)&&void 0!==$?$:[],showHeader:!0,onSelect:e=>{if(ee===R.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;Se({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}if(ee===R.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;je({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}},onClose:()=>{ie(void 0)}})}))})]}))};export{q as DiscountModal};
@@ -1,6 +1,7 @@
1
1
  export declare const OverLapAbs: import("styled-components").StyledComponent<"div", any, {
2
2
  disabled?: boolean | undefined;
3
3
  allowEvents?: boolean | undefined;
4
+ isChildLoading?: boolean | undefined;
4
5
  }, never>;
5
6
  export declare const OpenDropdownContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
6
7
  export declare const LoadingContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,14 +1,14 @@
1
- import e from"styled-components";import{COLORS as i}from"../../constants/Theme.js";const t=e.div`
1
+ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.js";const o=e.div`
2
2
  position:
3
3
  // if allowEvents is true, then position is relative, else position is absolute
4
- ${e=>(null==e?void 0:e.allowEvents)?"relative":"absolute"};
4
+ ${e=>(null==e?void 0:e.allowEvents)||(null==e?void 0:e.isChildLoading)?"relative":"absolute"};
5
5
  left: 0px;
6
6
  top: 0px;
7
7
  width: 100%;
8
8
  height: 100%;
9
9
  z-index: 2;
10
10
  cursor: ${e=>(null==e?void 0:e.disabled)?"not-allowed":"pointer"};
11
- `,o=e.div`
11
+ `,t=e.div`
12
12
  margin-top: 8px;
13
13
  margin-bottom: 8px;
14
14
  `;e.div`
@@ -34,4 +34,4 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
34
34
  flex-wrap: wrap;
35
35
  align-items: center;
36
36
  }
37
- `;export{r as ChipInputWrapper,o as OpenDropdownContainer,t as OverLapAbs};
37
+ `;export{r as ChipInputWrapper,t as OpenDropdownContainer,o as OverLapAbs};
@@ -12,6 +12,7 @@ export declare const DropdownPopover: React.ForwardRefExoticComponent<OpenDropdo
12
12
  showTooltipArrow?: boolean | undefined;
13
13
  allowEvents?: boolean | undefined;
14
14
  'data-test'?: string | undefined;
15
+ isChildLoading?: boolean | undefined;
15
16
  } & React.RefAttributes<{
16
17
  openDropdown: boolean;
17
18
  }>>;
@@ -1 +1 @@
1
- import{__rest as o}from"../../../_virtual/_tslib.js";import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t,{useState as l,useRef as n,useImperativeHandle as r,useEffect as s}from"react";import{usePopper as i}from"react-popper";import{DropShadow as a}from"../../dropShadow/DropShadow.js";import{Tooltip as d}from"../../tooltips/Tooltip.js";import{OverLapAbs as p,OpenDropdownContainer as c}from"../Common.styled.js";import{OpenedDropdown as m}from"../OpenedDropdown/components/OpennedDropdown.js";const j=t.forwardRef(((t,j)=>{var{children:v,onDropdownVisbilityChange:u,version:w="1.0",tooltipContent:b,tooltipDirection:h,showTooltipArrow:f}=t,g=o(t,["children","onDropdownVisbilityChange","version","tooltipContent","tooltipDirection","showTooltipArrow"]);const x=j,[D,O]=l(!1),[y,S]=l(null),[C,z]=l(null),E=n(null),{styles:A,attributes:R}=i(y,C,{placement:g.placement,strategy:g.strategy}),T=o=>{var e,t;"2.0"===w&&g.isMultiSelect&&o&&(null===(e=g.onSelect)||void 0===e||e.call(g,[...o])),O(!1),null===(t=null==g?void 0:g.onClose)||void 0===t||t.call(g)};r(x,(()=>({openDropdown:D})),[]),s((()=>{(null==x?void 0:x.current)&&(x.current.openDropdown=D)}),[D]),s((()=>{null==u||u(D)}),[D]);const _=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{position:"relative"},ref:S},{children:[e.jsx(p,Object.assign({ref:E,allowEvents:g.allowEvents,disabled:g.disabled,onClick:o=>{var e;null===(e=g.onDropdownOpen)||void 0===e||e.call(g),D?(O(!1),o.preventDefault()):g.disabled||O(!0)}},{children:g.allowEvents?v:null})),g.allowEvents?null:v]})),D&&e.jsx(c,Object.assign({ref:z,style:Object.assign(Object.assign({},A.popper),{zIndex:3})},R.popper,{"data-test":g["data-test"]},{children:e.jsx(a,Object.assign({level:"z2",position:"down",style:{borderRadius:8}},{children:e.jsx(m,Object.assign({},g,{onSelect:o=>{var e;"2.0"===w&&g.isMultiSelect||(null===(e=g.onSelect)||void 0===e||e.call(g,o),O(!1))},onClose:T,version:w,headerRef:E,zeroState:null==g?void 0:g.zeroState}))}))}))]});return e.jsx(e.Fragment,{children:D||void 0===b?_():e.jsx(d,Object.assign({body:b,placement:h,hideArrow:!f},{children:e.jsx("div",Object.assign({"data-test":g["data-test"]},{children:_()}))}))})}));j.displayName="DropdownPopover";export{j as DropdownPopover};
1
+ import{__rest as o}from"../../../_virtual/_tslib.js";import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t,{useState as l,useRef as n,useImperativeHandle as i,useEffect as r}from"react";import{usePopper as s}from"react-popper";import{DropShadow as a}from"../../dropShadow/DropShadow.js";import{Tooltip as d}from"../../tooltips/Tooltip.js";import{OverLapAbs as p,OpenDropdownContainer as c}from"../Common.styled.js";import{OpenedDropdown as m}from"../OpenedDropdown/components/OpennedDropdown.js";const j=t.forwardRef(((t,j)=>{var{children:v,onDropdownVisbilityChange:u,version:h="1.0",tooltipContent:w,tooltipDirection:b,showTooltipArrow:g,isChildLoading:f}=t,x=o(t,["children","onDropdownVisbilityChange","version","tooltipContent","tooltipDirection","showTooltipArrow","isChildLoading"]);const D=j,[O,y]=l(!1),[C,S]=l(null),[z,E]=l(null),A=n(null),{styles:L,attributes:R}=s(C,z,{placement:x.placement,strategy:x.strategy}),T=o=>{var e,t;"2.0"===h&&x.isMultiSelect&&o&&(null===(e=x.onSelect)||void 0===e||e.call(x,[...o])),y(!1),null===(t=null==x?void 0:x.onClose)||void 0===t||t.call(x)};i(D,(()=>({openDropdown:O})),[]),r((()=>{(null==D?void 0:D.current)&&(D.current.openDropdown=O)}),[O]),r((()=>{null==u||u(O)}),[O]);const _=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{position:"relative"},ref:S},{children:[e.jsx(p,Object.assign({ref:A,allowEvents:x.allowEvents,disabled:x.disabled,onClick:o=>{var e;null===(e=x.onDropdownOpen)||void 0===e||e.call(x),O?(y(!1),o.preventDefault()):x.disabled||y(!0)},isChildLoading:f},{children:x.allowEvents?v:null})),x.allowEvents?null:v]})),O&&e.jsx(c,Object.assign({ref:E,style:Object.assign(Object.assign({},L.popper),{zIndex:3})},R.popper,{"data-test":x["data-test"]},{children:e.jsx(a,Object.assign({level:"z2",position:"down",style:{borderRadius:8}},{children:e.jsx(m,Object.assign({},x,{onSelect:o=>{var e;"2.0"===h&&x.isMultiSelect||(null===(e=x.onSelect)||void 0===e||e.call(x,o),y(!1))},onClose:T,version:h,headerRef:A,zeroState:null==x?void 0:x.zeroState}))}))}))]});return e.jsx(e.Fragment,{children:O||void 0===w?_():e.jsx(d,Object.assign({body:w,placement:b,hideArrow:!g},{children:e.jsx("div",Object.assign({"data-test":x["data-test"]},{children:_()}))}))})}));j.displayName="DropdownPopover";export{j as DropdownPopover};
@@ -1 +1 @@
1
- import{j as o}from"../../node_modules/react/jsx-runtime.js";import{DropdownPopover as t}from"../dropdown/DropdownPopover/index.js";import"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"react";import"../zeroState/ZeroState.js";import"../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 as e}from"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{DropdownButtonStyle as r}from"./DropdownButton.style.js";const n=n=>o.jsxs(r,Object.assign({type:n.buttonProps.buttonType,disabled:n.buttonProps.disabled},{children:[o.jsx(e,Object.assign({},n.buttonProps,{style:{borderRadius:"0px",borderTopLeftRadius:"4px",borderBottomLeftRadius:"4px",borderRight:"0px"}})),o.jsx("div",{className:"divider"}),o.jsx(t,Object.assign({},n.dropdownProps,{children:o.jsx(e,Object.assign({},n.buttonProps,{buttonText:"",TrailingIcon:n.iconProps,style:{borderRadius:"0px",borderTopRightRadius:"4px",borderBottomRightRadius:"4px"}}))}))]}));export{n as DropdownButton};
1
+ import{__rest as o}from"../../_virtual/_tslib.js";import{j as t}from"../../node_modules/react/jsx-runtime.js";import{DropdownPopover as n}from"../dropdown/DropdownPopover/index.js";import"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"react";import"../zeroState/ZeroState.js";import"../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 as r}from"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{SpinnerColorMap as e}from"../button/themes.js";import{Spinner as s}from"../spinner/Spinner.js";import{DropdownButtonStyle as p,LoaderContainer as i}from"./DropdownButton.style.js";const d=d=>{var m,u;const j=d.buttonProps,l=o(j,["onClick"]);return t.jsxs(p,Object.assign({type:d.buttonProps.buttonType,disabled:d.buttonProps.disabled},{children:[(null===(m=d.buttonProps)||void 0===m?void 0:m.isLoading)&&t.jsx(i,{children:t.jsx(s,{className:"spinner",size:"small",color:e(d.buttonProps.buttonType||"primary",d.buttonProps.inverse)})}),t.jsx(r,Object.assign({},d.buttonProps,{isLoading:!1,style:{borderRadius:"0px",borderTopLeftRadius:"4px",borderBottomLeftRadius:"4px",borderRight:"0px"}})),t.jsx("div",{className:"dd-button-divider"}),t.jsx(n,Object.assign({},d.dropdownProps,{isChildLoading:null===(u=d.buttonProps)||void 0===u?void 0:u.isLoading},{children:t.jsx(r,Object.assign({},l,{isLoading:!1,buttonText:"",TrailingIcon:d.iconProps,style:{borderRadius:"0px",borderTopRightRadius:"4px",borderBottomRightRadius:"4px"}}))}))]}))};export{d as DropdownButton};
@@ -3,3 +3,4 @@ export declare const DropdownButtonStyle: import("styled-components").StyledComp
3
3
  type: Type | undefined;
4
4
  disabled: boolean | undefined;
5
5
  }, never>;
6
+ export declare const LoaderContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,9 +1,22 @@
1
- import t from"styled-components";import{COLORS as e}from"../../constants/Theme.js";const r=t.div`
1
+ import t from"styled-components";import{BASE_COLORS as e,COLORS as i}from"../../constants/Theme.js";const n=t.div`
2
2
  display: flex;
3
3
  flex-direction: row;
4
4
  width: max-content;
5
- .divider {
5
+ position: relative;
6
+ align-items: stretch;
7
+ .dd-button-divider {
6
8
  width: ${t=>["primary","destructive"].includes(t.type)?"1px":"0px"};
7
- background-color: ${t=>{return r=t.type,(null==t?void 0:t.disabled)?e.content.inactive:"primary"===r?"#CDA2FC":e.content.primaryInverse;var r}};
9
+ background-color: ${t=>{return e=t.type,(null==t?void 0:t.disabled)?i.content.inactive:"primary"===e?"#CDA2FC":i.content.primaryInverse;var e}};
8
10
  }
9
- `;export{r as DropdownButtonStyle};
11
+ `,r=t.div`
12
+ position: absolute;
13
+ inset: 0;
14
+ display: flex;
15
+ flex-direction: row;
16
+ align-items: center;
17
+ justify-content: center;
18
+ width: 100%;
19
+ border-radius: 4px;
20
+ background: ${e.brand[50]};
21
+ z-index: 3;
22
+ `;export{n as DropdownButtonStyle,r as LoaderContainer};
@@ -1,4 +1,4 @@
1
- import { ApplicationType } from '@bikdotai/bik-models/growth';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
2
  import React from 'react';
3
3
  import { Collection, CollectionFetcherReturn, SelectedItems } from '.';
4
4
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ApplicationType } from '@bikdotai/bik-models/growth';
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
3
3
  import { ButtonProps } from '../button/model';
4
4
  import { FooterForNonModalI, OUT_OF_STOCK_ACTION, ScreenName } from './type';
5
5
  export interface ProductVariant {
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useRef as r,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import l from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as p}from"../spinner/Spinner.js";import{Tag as h}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as C}from"./productScreen.js";import{RearrangeScreen as j}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as x,selectedColectionsReducer as b,CollectionIdContext as f}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as k}from"./selectedScreen.js";import{ContainerStyle as v,ScrollContainerStyle as I,StyledFooterForNonModal as F}from"./style.js";import{OUT_OF_STOCK_ACTION as P,ScreenName as O}from"./type.js";import{updateAllVariantsForSelectedProducts as T}from"./utility.js";const D=D=>{const{storeId:R,selectedItems:w,onClose:A,visible:B,zIndex:E,exactLimit:L,limit:z,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:M=P.BLUR,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,hideSelectionCount:G,title:K,width:N,left:U,renderWithoutModal:Y,onClickSave:_,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=O.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:se,secondaryButton:re,subtitle:ie}=D,ne=D.appType||t.BIK,[le,ae]=c(y,{}),[de,ue]=s([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections),[pe,he]=s("grid"),[me,ge]=s(""),[Ce,je]=s(""),[ye,xe]=s(0),[be,fe]=s(!1),[Se,ke]=s(0),[ve,Ie]=s(""),[Fe,Pe]=s(!1),[Oe,Te]=s(!1),[De,Re]=c(x,{collections:{},products:{}}),[we,Ae]=c(b,Object.keys(w).length>0?w:{}),Be=r(null),[Ee,Le]=s(!1),[ze,Ve]=s();i((()=>{fe(!0),Te(!0),D.collectionFetcher(ye,R,ne).then((e=>{ae({type:"fetched",data:(null==e?void 0:e.collections)||{}}),fe(!1),xe((e=>e+1)),Te(!1)})).catch()}),[]),i((()=>{let e=0;J?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[le,we,J]),i((()=>{Ce&&(fe(!0),D.productFetcher(Ce,R,ne).then((e=>{Object.keys(e).length&&ae({type:"productsFetched",data:{collectionId:Ce,products:e}}),fe(!1)})).catch())}),[Ce]),i((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(ve.length||"collections"!==de)&&(ve.length?(Pe(!0),D.searchFetcher(R,ve,ne).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),ae({type:"searched",data:e.collections}),ae({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),ae({type:"searched",data:e})),ue("searchProducts"),fe(!1),Pe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[ve]),i((()=>{_&&(D.onAdd(we,Se),$e())}),[_]),i((()=>{Z&&Object.keys(we||{}).length&&Se&&(D.onAdd(we,Se),$e())}),[Z,we,Se]);const $e=()=>{Ae({type:"reset",data:{}})},Me=()=>L&&Se>L?e.jsx(h,{tagText:`You can only select ${L} products`,type:"negative"}):z&&Se>z?e.jsx(h,{tagText:`You can only select ${z} products`,type:"negative"}):Se>0?e.jsx(a,{onClick:()=>{ue(X?O.RearrangeProducts:O.SelectedProducts)},buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}):e.jsx(a,{disabled:!0,buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:"tertiaryGray"}),He=e=>be?"Loading...":de===O.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e.jsxs(v,Object.assign({style:null!=te?te:{}},{children:[D.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:D.postHeader})),!D.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===de||"searchProducts"===de)&&e.jsx("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Fe?e.jsx(p,{size:"small",color:n.content.primary}):e.jsx(o,{})},id:"listInput",height:"24px",type:"text",value:ve,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e.jsxs(I,Object.assign({ref:Be,screenName:de},{children:["collections"===de&&e.jsx(m,{customCollectionRestriction:D.customCollectionRestriction,dataLoading:Oe,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:ge,setSelectedCollectionId:je,setScreen:ue,selectedCollections:we,collectionFetcher:D.collectionFetcher,storeId:R,appType:ne,collectionsDispatch:ae,setSaveDisabled:fe,pagingControls:{curPage:ye,setCurPage:xe},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:q,scrollContainerRef:Be}),"products"===de&&me&&e.jsx(f.Provider,Object.assign({value:me},{children:e.jsx(C,{hideInCollectionSearch:D.hideInCollectionSearch,customCollectionRestriction:D.customCollectionRestriction,productFetcher:D.productFetcher,setScreen:ue,storeId:R,appType:ne,data:le[me],collectionsDispatch:ae,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:fe,searchInCollectionFetcher:D.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,renderWithoutModal:Y,pickerType:q,hideProductVariants:J,fbStatusFetcher:D.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Be})})),"view"===de&&e.jsx(k,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:J,outOfStockAction:M,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"rearrange"===de&&e.jsx(j,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===pe?"list":"grid",scrollContainerRef:Be,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"searchProducts"===de&&e.jsx(S,{customCollectionRestriction:D.customCollectionRestriction,selectedCollections:we||{},searchedCollections:De||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:$,hideProductVariants:J,hideVariantCheckbox:H,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:je,renderWithoutModal:Y,hideCollectionCheckbox:V,outOfStockAction:M})]}))]}));return e.jsx(e.Fragment,{children:Y?e.jsxs(e.Fragment,{children:[We,ce.renderFooter?e.jsxs(F,{children:[Me(),e.jsx(a,{buttonText:He(ce.primaryButtonText),disabled:!ce.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}})]}):e.jsx(e.Fragment,{}),Ee&&ze?e.jsx(g,{productData:ze,outOfStockAction:M,useDynamicInfoImageSize:D.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(u,Object.assign({zIndex:E,open:B,onClose:()=>{null==A||A(),$e()},headingTitle:K||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:N||"600px",left:U||"auto"},headerRightCustomElement:oe?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:A},{children:e.jsx(l,{width:20,height:20,color:n.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:D.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||e.disabled,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}}))(se):{buttonText:He(),disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{D.onAdd(we,Se),$e()}},secondaryButton:re?(e=>Object.assign(Object.assign({},e),{disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{const e=T(we,le,De);D.onAdd(e,Se,!0)}}))(re):void 0,wrapperStyle:D.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:G?e.jsx(e.Fragment,{}):Me(),hideCrossButton:Ee||oe},{children:[We,Ee&&ze?e.jsx(g,{productData:ze,useDynamicInfoImageSize:D.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}))})};export{D as ProductPickerModal};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth/models/bik-store";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useRef as r,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import l from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as p}from"../spinner/Spinner.js";import{Tag as h}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as C}from"./productScreen.js";import{RearrangeScreen as j}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as x,selectedColectionsReducer as b,CollectionIdContext as f}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as k}from"./selectedScreen.js";import{ContainerStyle as v,ScrollContainerStyle as I,StyledFooterForNonModal as F}from"./style.js";import{OUT_OF_STOCK_ACTION as P,ScreenName as O}from"./type.js";import{updateAllVariantsForSelectedProducts as T}from"./utility.js";const D=D=>{const{storeId:R,selectedItems:w,onClose:A,visible:B,zIndex:E,exactLimit:L,limit:z,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:M=P.BLUR,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,hideSelectionCount:G,title:K,width:N,left:U,renderWithoutModal:Y,onClickSave:_,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=O.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:se,secondaryButton:re,subtitle:ie}=D,ne=D.appType||t.BIK,[le,ae]=c(y,{}),[de,ue]=s([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections),[pe,he]=s("grid"),[me,ge]=s(""),[Ce,je]=s(""),[ye,xe]=s(0),[be,fe]=s(!1),[Se,ke]=s(0),[ve,Ie]=s(""),[Fe,Pe]=s(!1),[Oe,Te]=s(!1),[De,Re]=c(x,{collections:{},products:{}}),[we,Ae]=c(b,Object.keys(w).length>0?w:{}),Be=r(null),[Ee,Le]=s(!1),[ze,Ve]=s();i((()=>{fe(!0),Te(!0),D.collectionFetcher(ye,R,ne).then((e=>{ae({type:"fetched",data:(null==e?void 0:e.collections)||{}}),fe(!1),xe((e=>e+1)),Te(!1)})).catch()}),[]),i((()=>{let e=0;J?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[le,we,J]),i((()=>{Ce&&(fe(!0),D.productFetcher(Ce,R,ne).then((e=>{Object.keys(e).length&&ae({type:"productsFetched",data:{collectionId:Ce,products:e}}),fe(!1)})).catch())}),[Ce]),i((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(ve.length||"collections"!==de)&&(ve.length?(Pe(!0),D.searchFetcher(R,ve,ne).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),ae({type:"searched",data:e.collections}),ae({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),ae({type:"searched",data:e})),ue("searchProducts"),fe(!1),Pe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[ve]),i((()=>{_&&(D.onAdd(we,Se),$e())}),[_]),i((()=>{Z&&Object.keys(we||{}).length&&Se&&(D.onAdd(we,Se),$e())}),[Z,we,Se]);const $e=()=>{Ae({type:"reset",data:{}})},Me=()=>L&&Se>L?e.jsx(h,{tagText:`You can only select ${L} products`,type:"negative"}):z&&Se>z?e.jsx(h,{tagText:`You can only select ${z} products`,type:"negative"}):Se>0?e.jsx(a,{onClick:()=>{ue(X?O.RearrangeProducts:O.SelectedProducts)},buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}):e.jsx(a,{disabled:!0,buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:"tertiaryGray"}),He=e=>be?"Loading...":de===O.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e.jsxs(v,Object.assign({style:null!=te?te:{}},{children:[D.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:D.postHeader})),!D.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===de||"searchProducts"===de)&&e.jsx("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Fe?e.jsx(p,{size:"small",color:n.content.primary}):e.jsx(o,{})},id:"listInput",height:"24px",type:"text",value:ve,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e.jsxs(I,Object.assign({ref:Be,screenName:de},{children:["collections"===de&&e.jsx(m,{customCollectionRestriction:D.customCollectionRestriction,dataLoading:Oe,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:ge,setSelectedCollectionId:je,setScreen:ue,selectedCollections:we,collectionFetcher:D.collectionFetcher,storeId:R,appType:ne,collectionsDispatch:ae,setSaveDisabled:fe,pagingControls:{curPage:ye,setCurPage:xe},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:q,scrollContainerRef:Be}),"products"===de&&me&&e.jsx(f.Provider,Object.assign({value:me},{children:e.jsx(C,{hideInCollectionSearch:D.hideInCollectionSearch,customCollectionRestriction:D.customCollectionRestriction,productFetcher:D.productFetcher,setScreen:ue,storeId:R,appType:ne,data:le[me],collectionsDispatch:ae,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:fe,searchInCollectionFetcher:D.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,renderWithoutModal:Y,pickerType:q,hideProductVariants:J,fbStatusFetcher:D.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Be})})),"view"===de&&e.jsx(k,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:J,outOfStockAction:M,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"rearrange"===de&&e.jsx(j,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===pe?"list":"grid",scrollContainerRef:Be,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"searchProducts"===de&&e.jsx(S,{customCollectionRestriction:D.customCollectionRestriction,selectedCollections:we||{},searchedCollections:De||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:$,hideProductVariants:J,hideVariantCheckbox:H,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:je,renderWithoutModal:Y,hideCollectionCheckbox:V,outOfStockAction:M})]}))]}));return e.jsx(e.Fragment,{children:Y?e.jsxs(e.Fragment,{children:[We,ce.renderFooter?e.jsxs(F,{children:[Me(),e.jsx(a,{buttonText:He(ce.primaryButtonText),disabled:!ce.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}})]}):e.jsx(e.Fragment,{}),Ee&&ze?e.jsx(g,{productData:ze,outOfStockAction:M,useDynamicInfoImageSize:D.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(u,Object.assign({zIndex:E,open:B,onClose:()=>{null==A||A(),$e()},headingTitle:K||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:N||"600px",left:U||"auto"},headerRightCustomElement:oe?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:A},{children:e.jsx(l,{width:20,height:20,color:n.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:D.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||e.disabled,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}}))(se):{buttonText:He(),disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{D.onAdd(we,Se),$e()}},secondaryButton:re?(e=>Object.assign(Object.assign({},e),{disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{const e=T(we,le,De);D.onAdd(e,Se,!0)}}))(re):void 0,wrapperStyle:D.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:G?e.jsx(e.Fragment,{}):Me(),hideCrossButton:Ee||oe},{children:[We,Ee&&ze?e.jsx(g,{productData:ze,useDynamicInfoImageSize:D.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}))})};export{D as ProductPickerModal};
@@ -1,4 +1,4 @@
1
- import { ApplicationType } from '@bikdotai/bik-models/growth';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
2
  import React from 'react';
3
3
  import { Collection, FbStatusFetcherReturn, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
4
4
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
@@ -1,4 +1,4 @@
1
- import { ApplicationType } from '@bikdotai/bik-models/growth';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
2
  import React from 'react';
3
3
  import { FbStatusFetcherReturn, SelectedItems } from '.';
4
4
  import { SelectedCollectionsActions } from './reducers';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ApplicationType } from '@bikdotai/bik-models/growth';
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
3
3
  import { Collection, FbStatusFetcherReturn, SearchedItems, SelectedItems } from '.';
4
4
  import { SearchReducerActions, SelectedCollectionsActions } from './reducers';
5
5
  import { OUT_OF_STOCK_ACTION } from './type';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ApplicationType } from '@bikdotai/bik-models/growth';
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
3
3
  import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
4
4
  import { SelectedCollectionsActions } from './reducers';
5
5
  import { OUT_OF_STOCK_ACTION } from './type';
@@ -1,4 +1,4 @@
1
- import { ApplicationType } from '@bikdotai/bik-models/growth';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
2
  import { Collection, FbStatusFetcherReturn, Product, ProductVariant, SearchedItems, SelectedItems } from './modal';
3
3
  import { CollectionsActions } from './reducers';
4
4
  export declare const liftTheStateUp: (payload: any, data: any) => any;
@@ -1,4 +1,4 @@
1
- import { ApplicationType } from '@bikdotai/bik-models/growth';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
2
  import { VariableListInterfaceV2 } from "../add-variableV2/AddVariableV2";
3
3
  import { CarouselProduct } from "./modalElements/EditWhatsAppCarouselTemplateV2";
4
4
  import { WhatsAppCarouselTemplateVariables } from "../template-preview/models/WhatsappCarouselTemplate";
@@ -1,4 +1,4 @@
1
- import { ApplicationType } from '@bikdotai/bik-models/growth';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
2
  import { VariableV3 } from "../../../helpers";
3
3
  import React, { LegacyRef } from 'react';
4
4
  import Slider from 'react-slick';
@@ -1 +1 @@
1
- import{j as e}from"../../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import l from"../../../assets/icons/arrow_back.svg.js";import o from"../../../assets/icons/chevronLeft.svg.js";import n from"../../../assets/icons/chevronRight.svg.js";import i from"../../../assets/icons/PlusIcon.js";import{cloneDeep as r}from"lodash";import{useState as s,useEffect as a}from"react";import{Button as d}from"../../button/Button.js";import{IconButton as c}from"../../icon-button/IconButton.js";import{ProductPickerModal as u}from"../../product-picker-v2/modal.js";import{ScreenName as p}from"../../product-picker-v2/type.js";import{Badge as m}from"../Badge/index.js";import{useTemplateModalContext as v}from"../context/templateModalContext.js";import h from"./EditWhatsAppTemplateV2.js";import{ProductBox as g}from"./ProductBox.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import{COLORS as j}from"../../../constants/Theme.js";import"../../curtain/CurtainHelper.js";import"../../variable-picker-v3/model.js";import"../../template-preview/models/TemplateMeta.js";import{POD as f}from"../../template-preview/models/WhatsAppTemplate.js";import"../../template-preview/models/Channels.js";import{isRCSChannel as y}from"../../template-preview/helpers/templateMiscHelper.js";import{TitleMedium as x,TitleRegular as b,BodySecondary as C,BodyCaption as I}from"../../TypographyStyle.js";const w=w=>{let{template:k,whatsappSpecificPickerMeta:O,showVariableModal:P,variableListForImage:T,discountCode:S,setDiscountCode:L}=w;var B,E,A,F,M,V,D,R;const{selectedCarouselIndex:W,setTemplate:$,pickerConf:q,isProductCarouselType:N,pod:_,cardCount:z,carouselProducts:G,setCarouselProducts:H,isError:K,cardImages:J,disableEditVariable:Q,onDeleteSelectedProducts:U,setSelectedCarouselIndex:X,setVariableCallback:Y,setShowVariablePicker:Z,sliderRef:ee}=v(),[te,le]=s(y(null==k?void 0:k.channel)?"Carousel Cards":-1==W?"First Message (Step 1/2)":N?"Product Carousel "+((null===(E=null===(B=null==k?void 0:k.mapping)||void 0===B?void 0:B.body)||void 0===E?void 0:E.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(F=null===(A=null==k?void 0:k.mapping)||void 0===A?void 0:A.body)||void 0===F?void 0:F.length)?"(Step 2/2)":"")),[oe,ne]=s(!1),[ie,re]=s(!1),se=W===(null!=z?z:-1)-1,ae=(null!=W?W:-1)<1;a((()=>{var e,t,l,o;le(y(null==k?void 0:k.channel)?"Carousel Cards":-1==W?"First Message (Step 1/2)":N?"Product Carousel "+((null===(t=null===(e=null==k?void 0:k.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(o=null===(l=null==k?void 0:k.mapping)||void 0===l?void 0:l.body)||void 0===o?void 0:o.length)?"(Step 2/2)":""))}),[W]);const de=e=>{null==H||H([{name:"variable",productName:e.actualValue}])};return a((()=>{-1===W&&y(null==k?void 0:k.channel)&&(null==X||X(0))}),[W,null==k?void 0:k.channel]),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!y(null==k?void 0:k.channel)&&null!=W&&W>=0&&!!(null===(V=null===(M=null==k?void 0:k.mapping)||void 0===M?void 0:M.body)||void 0===V?void 0:V.length)&&e.jsx(c,{Icon:l,onClick:()=>{null==X||X(-1)}}),e.jsx(x,Object.assign({style:{marginLeft:10}},{children:te}))]})),N&&(null!==(D=null==G?void 0:G.length)&&void 0!==D?D:0)>0&&null!=W&&W>=0&&e.jsxs("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[e.jsx(g,{editItem:()=>{1===(null==G?void 0:G.length)&&"variable"===G[0].name?(Y((()=>de)),Z(!0)):ne(!oe)},cardBody:1===(null==G?void 0:G.length)&&"variable"===G[0].name?`${G[0].productName}`:`${null==G?void 0:G.length} Products Selected`,hideIcon:1===(null==G?void 0:G.length)&&"variable"===G[0].name,deleteItem:()=>{var e;if(1===(null==G?void 0:G.length)&&"variable"===G[0].name)return void(null==H||H([]));const t=r(Object.assign({},k));t&&(J&&J.length>0?null==J||J.forEach(((e,l)=>{var o;t.components[1].cards[l].components[0].example.header_handle=[null!==(o=J[l])&&void 0!==o?o:"https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})):null===(e=null==t?void 0:t.components[1].cards)||void 0===e||e.forEach(((e,l)=>{t.components[1].cards[l].components[0].example.header_handle=["https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})),null==$||$(t)),null==H||H([]),null==U||U()}}),G&&(null==G?void 0:G.length)>0&&"variable"!=G[0].name&&e.jsx(d,{disabled:(null!==(R=null==G?void 0:G.length)&&void 0!==R?R:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{re(!0),ne(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!Q&&N&&0===(null==G?void 0:G.length)&&null!=W&&W>=0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{marginLeft:12}},{children:[e.jsx(b,{children:"Product(s)"}),e.jsx(C,{children:`Select ${null!=z?z:1} products`})]})),e.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:K?16:12,marginRight:K?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsx(d,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:K?`2px dashed ${j.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:K?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsx("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:e.jsx(i,{width:18,height:18,color:j.content.secondary})})),onClick:e=>{ne(!0)}}),_===f.CHATBOT&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsx(I,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsx(d,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:K?`2px dashed ${j.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:K?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(i,{width:18,height:18,color:j.content.secondary})})),onClick:e=>{Y((()=>de)),Z(!0)}})]})]})),K&&e.jsx("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:e.jsx(m,{padding:"8px",errorText:"Please add products"})}))]}),!N&&(null!=W?W:-1)>-1&&e.jsxs("div",Object.assign({style:{display:"flex",background:j.surface.hovered,alignItems:"center"}},{children:[e.jsx(c,{Icon:o,disabled:ae,width:8,height:14,svgStyle:ae?{}:{color:j.content.secondary},onClick:()=>{var e;null===(e=null==ee?void 0:ee.current)||void 0===e||e.slickPrev(),(null!=W?W:-1)<1||null==X||X((e=>e-1))}}),e.jsx(b,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:j.content.secondary},{children:`Card ${(null!=W?W:0)+1}/${z}`})),e.jsx(c,{Icon:n,width:8,height:14,disabled:se,svgStyle:se?{}:{color:j.content.secondary},onClick:()=>{var e;null===(e=null==ee?void 0:ee.current)||void 0===e||e.slickNext(),(null!=W?W:-1)>=(null!=z?z:-1)-1||null==X||X((e=>e+1))}})]})),e.jsx(h,{whatsappSpecificPickerMeta:O,template:k,onTemplateChange:e=>{null==$||$(e)},showVariableModal:P,variableListForImage:T,discountCode:S,setDiscountCode:L}),oe&&q&&e.jsx(u,{zIndex:200,startupScreen:ie?p.RearrangeProducts:p.Collections,rearrangeEnabled:!0,storeId:q.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,o=l.productId,n=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),o in t[e].products||(t[e].products[o]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[o].variants[n]={name:(null==l?void 0:l.name)||"",price:"",image:(null==l?void 0:l.image)||"",quantity:l.quantity||0,displayOrder:l.displayOrder}}return t}return{}})(null!=G?G:[]),collectionFetcher:q.fetchCollections,productFetcher:q.fetchProducts,onAdd:(e,t)=>{var l,o,n,i,s,a;re(!1);const d=[];delete e.isCustom;for(const t of Object.keys(e)){const r=e[t].products;if(void 0!==r&&Object.keys(r).length)for(const e of Object.keys(r)){const c=r[e].variants;if(void 0!==c&&Object.keys(c).length)for(const u of Object.keys(c)){const{name:p,image:m,quantity:v,displayOrder:h}=c[u],g={name:p,image:null!==(o=null!=m?m:null===(l=r[e])||void 0===l?void 0:l.image)&&void 0!==o?o:"",quantity:v,variantId:u,productId:e,displayOrder:h,collectionId:t,productName:null!==(i=null===(n=r[e])||void 0===n?void 0:n.name)&&void 0!==i?i:"",productImage:null!==(a=null===(s=r[e])||void 0===s?void 0:s.image)&&void 0!==a?a:""};d.push(g)}}}const c=d.sort(((e,t)=>e.displayOrder-t.displayOrder)),u=d.map((e=>e.image)),p=r(Object.assign({},k));p&&(u.forEach(((e,t)=>{var l;p.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==J?void 0:J[t])&&void 0!==l?l:""]})),null==$||$(p)),null==H||H(c),ne(!1)},searchInCollectionFetcher:q.searchInCollection,searchFetcher:q.searchProducts,visible:oe,onClose:()=>{ne(!1)},exactLimit:null!=z?z:1,appType:q.appType||t.BIK})]}))};export{w as default};
1
+ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth/models/bik-store";import l from"../../../assets/icons/arrow_back.svg.js";import o from"../../../assets/icons/chevronLeft.svg.js";import i from"../../../assets/icons/chevronRight.svg.js";import n from"../../../assets/icons/PlusIcon.js";import{cloneDeep as r}from"lodash";import{useState as s,useEffect as a}from"react";import{Button as d}from"../../button/Button.js";import{IconButton as c}from"../../icon-button/IconButton.js";import{ProductPickerModal as u}from"../../product-picker-v2/modal.js";import{ScreenName as p}from"../../product-picker-v2/type.js";import{Badge as m}from"../Badge/index.js";import{useTemplateModalContext as v}from"../context/templateModalContext.js";import h from"./EditWhatsAppTemplateV2.js";import{ProductBox as g}from"./ProductBox.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import{COLORS as j}from"../../../constants/Theme.js";import"../../curtain/CurtainHelper.js";import"../../variable-picker-v3/model.js";import"../../template-preview/models/TemplateMeta.js";import{POD as f}from"../../template-preview/models/WhatsAppTemplate.js";import"../../template-preview/models/Channels.js";import{isRCSChannel as y}from"../../template-preview/helpers/templateMiscHelper.js";import{TitleMedium as x,TitleRegular as b,BodySecondary as C,BodyCaption as I}from"../../TypographyStyle.js";const k=k=>{let{template:w,whatsappSpecificPickerMeta:O,showVariableModal:P,variableListForImage:T,discountCode:S,setDiscountCode:L}=k;var B,E,A,F,M,V,D,R;const{selectedCarouselIndex:W,setTemplate:$,pickerConf:q,isProductCarouselType:N,pod:_,cardCount:z,carouselProducts:G,setCarouselProducts:H,isError:K,cardImages:J,disableEditVariable:Q,onDeleteSelectedProducts:U,setSelectedCarouselIndex:X,setVariableCallback:Y,setShowVariablePicker:Z,sliderRef:ee}=v(),[te,le]=s(y(null==w?void 0:w.channel)?"Carousel Cards":-1==W?"First Message (Step 1/2)":N?"Product Carousel "+((null===(E=null===(B=null==w?void 0:w.mapping)||void 0===B?void 0:B.body)||void 0===E?void 0:E.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(F=null===(A=null==w?void 0:w.mapping)||void 0===A?void 0:A.body)||void 0===F?void 0:F.length)?"(Step 2/2)":"")),[oe,ie]=s(!1),[ne,re]=s(!1),se=W===(null!=z?z:-1)-1,ae=(null!=W?W:-1)<1;a((()=>{var e,t,l,o;le(y(null==w?void 0:w.channel)?"Carousel Cards":-1==W?"First Message (Step 1/2)":N?"Product Carousel "+((null===(t=null===(e=null==w?void 0:w.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(o=null===(l=null==w?void 0:w.mapping)||void 0===l?void 0:l.body)||void 0===o?void 0:o.length)?"(Step 2/2)":""))}),[W]);const de=e=>{null==H||H([{name:"variable",productName:e.actualValue}])};return a((()=>{-1===W&&y(null==w?void 0:w.channel)&&(null==X||X(0))}),[W,null==w?void 0:w.channel]),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!y(null==w?void 0:w.channel)&&null!=W&&W>=0&&!!(null===(V=null===(M=null==w?void 0:w.mapping)||void 0===M?void 0:M.body)||void 0===V?void 0:V.length)&&e.jsx(c,{Icon:l,onClick:()=>{null==X||X(-1)}}),e.jsx(x,Object.assign({style:{marginLeft:10}},{children:te}))]})),N&&(null!==(D=null==G?void 0:G.length)&&void 0!==D?D:0)>0&&null!=W&&W>=0&&e.jsxs("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[e.jsx(g,{editItem:()=>{1===(null==G?void 0:G.length)&&"variable"===G[0].name?(Y((()=>de)),Z(!0)):ie(!oe)},cardBody:1===(null==G?void 0:G.length)&&"variable"===G[0].name?`${G[0].productName}`:`${null==G?void 0:G.length} Products Selected`,hideIcon:1===(null==G?void 0:G.length)&&"variable"===G[0].name,deleteItem:()=>{var e;if(1===(null==G?void 0:G.length)&&"variable"===G[0].name)return void(null==H||H([]));const t=r(Object.assign({},w));t&&(J&&J.length>0?null==J||J.forEach(((e,l)=>{var o;t.components[1].cards[l].components[0].example.header_handle=[null!==(o=J[l])&&void 0!==o?o:"https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})):null===(e=null==t?void 0:t.components[1].cards)||void 0===e||e.forEach(((e,l)=>{t.components[1].cards[l].components[0].example.header_handle=["https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})),null==$||$(t)),null==H||H([]),null==U||U()}}),G&&(null==G?void 0:G.length)>0&&"variable"!=G[0].name&&e.jsx(d,{disabled:(null!==(R=null==G?void 0:G.length)&&void 0!==R?R:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{re(!0),ie(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!Q&&N&&0===(null==G?void 0:G.length)&&null!=W&&W>=0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{marginLeft:12}},{children:[e.jsx(b,{children:"Product(s)"}),e.jsx(C,{children:`Select ${null!=z?z:1} products`})]})),e.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:K?16:12,marginRight:K?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsx(d,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:K?`2px dashed ${j.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:K?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsx("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:e.jsx(n,{width:18,height:18,color:j.content.secondary})})),onClick:e=>{ie(!0)}}),_===f.CHATBOT&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsx(I,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsx(d,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:K?`2px dashed ${j.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:K?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(n,{width:18,height:18,color:j.content.secondary})})),onClick:e=>{Y((()=>de)),Z(!0)}})]})]})),K&&e.jsx("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:e.jsx(m,{padding:"8px",errorText:"Please add products"})}))]}),!N&&(null!=W?W:-1)>-1&&e.jsxs("div",Object.assign({style:{display:"flex",background:j.surface.hovered,alignItems:"center"}},{children:[e.jsx(c,{Icon:o,disabled:ae,width:8,height:14,svgStyle:ae?{}:{color:j.content.secondary},onClick:()=>{var e;null===(e=null==ee?void 0:ee.current)||void 0===e||e.slickPrev(),(null!=W?W:-1)<1||null==X||X((e=>e-1))}}),e.jsx(b,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:j.content.secondary},{children:`Card ${(null!=W?W:0)+1}/${z}`})),e.jsx(c,{Icon:i,width:8,height:14,disabled:se,svgStyle:se?{}:{color:j.content.secondary},onClick:()=>{var e;null===(e=null==ee?void 0:ee.current)||void 0===e||e.slickNext(),(null!=W?W:-1)>=(null!=z?z:-1)-1||null==X||X((e=>e+1))}})]})),e.jsx(h,{whatsappSpecificPickerMeta:O,template:w,onTemplateChange:e=>{null==$||$(e)},showVariableModal:P,variableListForImage:T,discountCode:S,setDiscountCode:L}),oe&&q&&e.jsx(u,{zIndex:200,startupScreen:ne?p.RearrangeProducts:p.Collections,rearrangeEnabled:!0,storeId:q.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,o=l.productId,i=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),o in t[e].products||(t[e].products[o]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[o].variants[i]={name:(null==l?void 0:l.name)||"",price:"",image:(null==l?void 0:l.image)||"",quantity:l.quantity||0,displayOrder:l.displayOrder}}return t}return{}})(null!=G?G:[]),collectionFetcher:q.fetchCollections,productFetcher:q.fetchProducts,onAdd:(e,t)=>{var l,o,i,n,s,a;re(!1);const d=[];delete e.isCustom;for(const t of Object.keys(e)){const r=e[t].products;if(void 0!==r&&Object.keys(r).length)for(const e of Object.keys(r)){const c=r[e].variants;if(void 0!==c&&Object.keys(c).length)for(const u of Object.keys(c)){const{name:p,image:m,quantity:v,displayOrder:h}=c[u],g={name:p,image:null!==(o=null!=m?m:null===(l=r[e])||void 0===l?void 0:l.image)&&void 0!==o?o:"",quantity:v,variantId:u,productId:e,displayOrder:h,collectionId:t,productName:null!==(n=null===(i=r[e])||void 0===i?void 0:i.name)&&void 0!==n?n:"",productImage:null!==(a=null===(s=r[e])||void 0===s?void 0:s.image)&&void 0!==a?a:""};d.push(g)}}}const c=d.sort(((e,t)=>e.displayOrder-t.displayOrder)),u=d.map((e=>e.image)),p=r(Object.assign({},w));p&&(u.forEach(((e,t)=>{var l;p.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==J?void 0:J[t])&&void 0!==l?l:""]})),null==$||$(p)),null==H||H(c),ie(!1)},searchInCollectionFetcher:q.searchInCollection,searchFetcher:q.searchProducts,visible:oe,onClose:()=>{ie(!1)},exactLimit:null!=z?z:1,appType:q.appType||t.BIK})]}))};export{k as default};