@bikdotai/bik-component-library 0.0.656-9 → 0.0.656-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 (37) hide show
  1. package/dist/cjs/_virtual/bik-store.js +1 -0
  2. package/dist/cjs/components/bik-layout/MockMenus.d.ts +0 -1
  3. package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +3 -1
  4. package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
  5. package/dist/cjs/components/product-picker-v2/modal.d.ts +7 -5
  6. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  7. package/dist/cjs/components/product-picker-v2/productScreen.d.ts +5 -3
  8. package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
  9. package/dist/cjs/components/product-picker-v2/rearrangeScreen.d.ts +3 -1
  10. package/dist/cjs/components/product-picker-v2/rearrangeScreen.js +1 -1
  11. package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +3 -1
  12. package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
  13. package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +3 -1
  14. package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
  15. package/dist/cjs/components/product-picker-v2/utility.d.ts +4 -3
  16. package/dist/cjs/components/product-picker-v2/utility.js +1 -1
  17. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +2 -2
  18. package/dist/cjs/node_modules/@bikdotai/bik-models/growth/models/bik-store.js +1 -0
  19. package/dist/esm/_virtual/bik-store.js +1 -0
  20. package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
  21. package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +3 -1
  22. package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
  23. package/dist/esm/components/product-picker-v2/modal.d.ts +7 -5
  24. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  25. package/dist/esm/components/product-picker-v2/productScreen.d.ts +5 -3
  26. package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
  27. package/dist/esm/components/product-picker-v2/rearrangeScreen.d.ts +3 -1
  28. package/dist/esm/components/product-picker-v2/rearrangeScreen.js +1 -1
  29. package/dist/esm/components/product-picker-v2/searchScreen.d.ts +3 -1
  30. package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
  31. package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +3 -1
  32. package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
  33. package/dist/esm/components/product-picker-v2/utility.d.ts +4 -3
  34. package/dist/esm/components/product-picker-v2/utility.js +1 -1
  35. package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +1 -1
  36. package/dist/esm/node_modules/@bikdotai/bik-models/growth/models/bik-store.js +1 -0
  37. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.__exports={};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -1,3 +1,4 @@
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
1
2
  import React from 'react';
2
3
  import { Collection, CollectionFetcherReturn, SelectedItems } from '.';
3
4
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
@@ -9,7 +10,7 @@ interface CollectionsScreenInterface {
9
10
  [key: string]: Collection;
10
11
  };
11
12
  selectedCollections: SelectedItems;
12
- collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
13
+ collectionFetcher: (offset: number, storeId: string, appType: ApplicationType) => CollectionFetcherReturn;
13
14
  storeId: string;
14
15
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
15
16
  setCollectionId: React.Dispatch<React.SetStateAction<string>>;
@@ -25,6 +26,7 @@ interface CollectionsScreenInterface {
25
26
  renderWithoutModal?: boolean;
26
27
  pickerType?: 'COLLECTION' | 'PRODUCT';
27
28
  scrollContainerRef: React.RefObject<HTMLDivElement>;
29
+ appType: ApplicationType;
28
30
  }
29
31
  export declare const CollectionsScreen: (props: CollectionsScreenInterface) => import("react/jsx-runtime").JSX.Element;
30
32
  export interface CollectionCardInterface {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),l=require("react"),i=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),s=require("../tag/Tag.js"),c=require("../tooltips/Tooltip.js"),r=require("../TypographyStyle.js"),n=require("./emptyState.js"),d=require("./ProductPickerShimmer.js"),a=require("./style.js"),u=require("./utility.js");const h=l=>{const{customCollectionRestriction:n,data:d,selectedCollectionsDispatch:u,setCollectionId:h,setSelectedCollectionId:C,isPartiallyChecked:p,setScreen:j,id:v,isChecked:g,isDisabled:y,hideCollectionCheckbox:x,pickerType:m,usedInSearch:b}=l;return d?e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:y,onClick:e=>{if(!y){if("COLLECTION"===m)return e.stopPropagation(),u({type:"reset",data:{}}),u({type:"selected",data:{id:v,val:d,isRestricted:n}}),h(v),void C(v);h(v),C(v),j("products")}},isActive:g,usedInSearch:null!=b&&b},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[!x&&e.jsx(i.CheckBox,{isDisabled:y,isChecked:g,isPartiallyChecked:p,onValueChange:function(e,t,l){null==l||l.stopPropagation(),u(e?{type:"selected",data:{id:v,val:d,isRestricted:n}}:{type:"unselected",data:{id:v}}),C(e?v:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsx(c.Tooltip,Object.assign({body:d.name,placement:"bottom",delay:400,variant:"light"},{children:e.jsxs(a.CollectionNameHolder,{children:[b?e.jsx(r.BodyPrimary,Object.assign({numberOfLines:1},{children:d.name})):e.jsx(r.TitleRegular,Object.assign({numberOfLines:1},{children:d.name})),d.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(s.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:y,Icon:t.default})]})):e.jsx(e.Fragment,{})};exports.CollectionCard=h,exports.CollectionsScreen=t=>{var i;const{customCollectionRestriction:o,dataLoading:s,collections:c,selectedCollectionsDispatch:r,setCollectionId:a,setSelectedCollectionId:C,selectedCollections:p,setScreen:j,collectionFetcher:v,collectionsDispatch:g,pagingControls:y,storeId:x,setSaveDisabled:m,hideCollectionCheckbox:b,renderWithoutModal:k,pickerType:f,scrollContainerRef:S}=t,P=l.useRef(y.curPage),O=!!o&&(null==p?void 0:p.isCustom),[I,T]=l.useState(!1),q=l.useRef(!1),R=l.useRef(!1),D=()=>{if(!S||!(null==S?void 0:S.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:l}=S.current;e+t>=l-20&&!q.current&&!R.current&&(m(!0),T(!0),R.current=!0,m(!0),T(!0),v(P.current,x).then((e=>{g({type:"paged",data:(null==e?void 0:e.collections)||{}}),y.setCurPage(P.current+1),T(!1),m(!1),R.current=!1,Object.keys(null==e?void 0:e.collections).length||(q.current=!0)})).catch())};return l.useEffect((()=>{var e;return null===(e=null==S?void 0:S.current)||void 0===e||e.addEventListener("scroll",D),()=>{var e;null===(e=null==S?void 0:S.current)||void 0===e||e.removeEventListener("scroll",D)}}),[]),l.useEffect((()=>{P.current=y.curPage}),[y.curPage]),e.jsxs("div",{children:[(null===(i=Object.keys(null!=c?c:{}))||void 0===i?void 0:i.length)?Object.keys(c).map((t=>{var l,i;const s=!!(null==p?void 0:p[t])&&("PRODUCT"!==f||!!Object.keys(null!==(i=null===(l=null==p?void 0:p[t])||void 0===l?void 0:l.products)&&void 0!==i?i:{}).length);return e.jsx(h,{customCollectionRestriction:o,data:c[t],isDisabled:O&&!(null==p?void 0:p[t]),isChecked:s,isPartiallyChecked:u.isCollectionPartiallyChecked(t,null==c?void 0:c[t],p),selectedCollectionsDispatch:r,setCollectionId:a,setSelectedCollectionId:C,setScreen:j,id:t,hideCollectionCheckbox:b||"-1"===t,selectedCollections:p,renderWithoutModal:k,pickerType:f},t)})):s?e.jsx(d.ProductPickerShimmer,{}):e.jsx(n.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),I&&e.jsx(d.ProductPickerShimmer,{})]})},exports.truncate=(e,t,l)=>{if(!e)return"";if(e.length<=t)return e;const i=e.slice(0,t-1);return(l?i.slice(0,i.lastIndexOf(" ")):i)+"..."};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),l=require("react"),i=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),s=require("../tag/Tag.js"),c=require("../tooltips/Tooltip.js"),r=require("../TypographyStyle.js"),n=require("./emptyState.js"),d=require("./ProductPickerShimmer.js"),a=require("./style.js"),u=require("./utility.js");const h=l=>{const{customCollectionRestriction:n,data:d,selectedCollectionsDispatch:u,setCollectionId:h,setSelectedCollectionId:C,isPartiallyChecked:p,setScreen:j,id:v,isChecked:y,isDisabled:g,hideCollectionCheckbox:x,pickerType:m,usedInSearch:b}=l;return d?e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:g,onClick:e=>{if(!g){if("COLLECTION"===m)return e.stopPropagation(),u({type:"reset",data:{}}),u({type:"selected",data:{id:v,val:d,isRestricted:n}}),h(v),void C(v);h(v),C(v),j("products")}},isActive:y,usedInSearch:null!=b&&b},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[!x&&e.jsx(i.CheckBox,{isDisabled:g,isChecked:y,isPartiallyChecked:p,onValueChange:function(e,t,l){null==l||l.stopPropagation(),u(e?{type:"selected",data:{id:v,val:d,isRestricted:n}}:{type:"unselected",data:{id:v}}),C(e?v:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsx(c.Tooltip,Object.assign({body:d.name,placement:"bottom",delay:400,variant:"light"},{children:e.jsxs(a.CollectionNameHolder,{children:[b?e.jsx(r.BodyPrimary,Object.assign({numberOfLines:1},{children:d.name})):e.jsx(r.TitleRegular,Object.assign({numberOfLines:1},{children:d.name})),d.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(s.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:g,Icon:t.default})]})):e.jsx(e.Fragment,{})};exports.CollectionCard=h,exports.CollectionsScreen=t=>{var i;const{customCollectionRestriction:o,dataLoading:s,collections:c,selectedCollectionsDispatch:r,setCollectionId:a,setSelectedCollectionId:C,selectedCollections:p,setScreen:j,collectionFetcher:v,collectionsDispatch:y,pagingControls:g,storeId:x,setSaveDisabled:m,hideCollectionCheckbox:b,renderWithoutModal:k,pickerType:f,scrollContainerRef:S,appType:P}=t,O=l.useRef(g.curPage),I=!!o&&(null==p?void 0:p.isCustom),[T,q]=l.useState(!1),R=l.useRef(!1),D=l.useRef(!1),L=()=>{if(!S||!(null==S?void 0:S.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:l}=S.current;e+t>=l-20&&!R.current&&!D.current&&(m(!0),q(!0),D.current=!0,m(!0),q(!0),v(O.current,x,P).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),g.setCurPage(O.current+1),q(!1),m(!1),D.current=!1,Object.keys(null==e?void 0:e.collections).length||(R.current=!0)})).catch())};return l.useEffect((()=>{var e;return null===(e=null==S?void 0:S.current)||void 0===e||e.addEventListener("scroll",L),()=>{var e;null===(e=null==S?void 0:S.current)||void 0===e||e.removeEventListener("scroll",L)}}),[]),l.useEffect((()=>{O.current=g.curPage}),[g.curPage]),e.jsxs("div",{children:[(null===(i=Object.keys(null!=c?c:{}))||void 0===i?void 0:i.length)?Object.keys(c).map((t=>{var l,i;const s=!!(null==p?void 0:p[t])&&("PRODUCT"!==f||!!Object.keys(null!==(i=null===(l=null==p?void 0:p[t])||void 0===l?void 0:l.products)&&void 0!==i?i:{}).length);return e.jsx(h,{customCollectionRestriction:o,data:c[t],isDisabled:I&&!(null==p?void 0:p[t]),isChecked:s,isPartiallyChecked:u.isCollectionPartiallyChecked(t,null==c?void 0:c[t],p),selectedCollectionsDispatch:r,setCollectionId:a,setSelectedCollectionId:C,setScreen:j,id:t,hideCollectionCheckbox:b||"-1"===t,selectedCollections:p,renderWithoutModal:k,pickerType:f},t)})):s?e.jsx(d.ProductPickerShimmer,{}):e.jsx(n.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),T&&e.jsx(d.ProductPickerShimmer,{})]})},exports.truncate=(e,t,l)=>{if(!e)return"";if(e.length<=t)return e;const i=e.slice(0,t-1);return(l?i.slice(0,i.lastIndexOf(" ")):i)+"..."};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
3
  import { ButtonProps } from '../button/model';
3
4
  import { FooterForNonModalI, OUT_OF_STOCK_ACTION } from './type';
4
5
  export interface ProductVariant {
@@ -67,12 +68,13 @@ export type ProductPickerInterface = {
67
68
  hideGlobalSearch?: boolean;
68
69
  hideInCollectionSearch?: boolean;
69
70
  customCollectionRestriction?: boolean;
70
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
71
- searchFetcher: (storeId: string, query: string) => Promise<SearchedItems | SelectedItems>;
72
- collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
73
- productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
74
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
71
+ searchInCollectionFetcher: (storeId: string, collectionId: string, query: string, appType: ApplicationType) => ProductFetcherReturn;
72
+ searchFetcher: (storeId: string, query: string, appType: ApplicationType) => Promise<SearchedItems | SelectedItems>;
73
+ collectionFetcher: (offset: number, storeId: string, appType: ApplicationType) => CollectionFetcherReturn;
74
+ productFetcher: (collectionId: string, storeId: string, appType: ApplicationType, limit?: number, offset?: number) => ProductFetcherReturn;
75
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
75
76
  storeId: string;
77
+ appType?: ApplicationType;
76
78
  selectedItems: SelectedItems;
77
79
  onAdd: (items: SelectedItems, total: number, secondaryClick?: boolean) => void;
78
80
  onClose?: () => void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),h=require("./productInfoOverlay.js"),p=require("./productScreen.js"),S=require("./rearrangeScreen.js"),C=require("./reducers.js"),x=require("./searchScreen.js"),g=require("./selectedScreen.js"),j=require("./style.js"),y=require("./type.js"),m=require("./utility.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:b,selectedItems:f,onClose:v,visible:k,zIndex:I,exactLimit:P,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:R,outOfStockAction:T=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:E,width:A,left:w,renderWithoutModal:B,onClickSave:L,pickerType:M,hideProductVariants:V=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:_=!1,showProductDetails:H,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:K={},primaryButton:U,secondaryButton:Y,subtitle:J}=e,[Q,X]=c.useReducer(C.collectionsReducer,{}),[Z,ee]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections),[te,oe]=c.useState("grid"),[ce,re]=c.useState(""),[se,ne]=c.useState(""),[ie,le]=c.useState(0),[ae,de]=c.useState(!1),[ue,he]=c.useState(0),[pe,Se]=c.useState(""),[Ce,xe]=c.useState(!1),[ge,je]=c.useState(!1),[ye,me]=c.useReducer(C.searchReducer,{collections:{},products:{}}),[be,fe]=c.useReducer(C.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=c.useRef(null),[ke,Ie]=c.useState(!1),[Pe,Oe]=c.useState();c.useEffect((()=>{de(!0),je(!0),e.collectionFetcher(ie,b).then((e=>{X({type:"fetched",data:(null==e?void 0:e.collections)||{}}),de(!1),le((e=>e+1)),je(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;V?Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&be[-1]&&(null===(c=be[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(be||[]).forEach((t=>{var o;Object.keys((null===(o=be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=be[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Q,be,V]),c.useEffect((()=>{se&&(de(!0),e.productFetcher(se,b).then((e=>{Object.keys(e).length&&X({type:"productsFetched",data:{collectionId:se,products:e}}),de(!1)})).catch())}),[se]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==Z&&(pe.length||"collections"!==Z)&&(pe.length?(xe(!0),e.searchFetcher(b,pe).then((e=>{"collections"in e&&"products"in e?(me({type:"set",data:e}),X({type:"searched",data:e.collections})):(me({type:"set",data:{collections:{},products:e}}),X({type:"searched",data:e})),ee("searchProducts"),de(!1),xe(!1)}))):ee("collections"))}),800);return()=>clearTimeout(t)}),[pe]),c.useEffect((()=>{L&&(e.onAdd(be,ue),Fe())}),[L]),c.useEffect((()=>{_&&Object.keys(be||{}).length&&ue&&(e.onAdd(be,ue),Fe())}),[_,be,ue]);const Fe=()=>{fe({type:"reset",data:{}})},Re=()=>P&&ue>P?t.jsx(d.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):O&&ue>O?t.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):ue>0?t.jsx(n.Button,{onClick:()=>{ee($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${ue}/${P} products selected`:`${ue} products selected`,buttonType:["rearrange","view"].includes(Z)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(Z)}):t.jsx(n.Button,{disabled:!0,buttonText:P?`${ue}/${P} products selected`:`${ue} products selected`,buttonType:"tertiaryGray"}),Te=e=>ae?"Loading...":Z===exports.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",De=t.jsxs(j.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===Z||"searchProducts"===Z)&&t.jsx("div",Object.assign({style:{padding:B?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(i.Input,{placeholder:"Search for collections and products, or type a product ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Ce?t.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:pe,onChangeText:e=>{e.length&&e.trim().length?Se(e):Se("")}})}))}),t.jsxs(j.ScrollContainerStyle,Object.assign({ref:ve,screenName:Z},{children:["collections"===Z&&t.jsx(u.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ge,collections:Q,selectedCollectionsDispatch:fe,setCollectionId:re,setSelectedCollectionId:ne,setScreen:ee,selectedCollections:be,collectionFetcher:e.collectionFetcher,storeId:b,collectionsDispatch:X,setSaveDisabled:de,pagingControls:{curPage:ie,setCurPage:le},hideCollectionCheckbox:F,renderWithoutModal:B,pickerType:M,scrollContainerRef:ve}),"products"===Z&&ce&&t.jsx(C.CollectionIdContext.Provider,Object.assign({value:ce},{children:t.jsx(p.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:ee,storeId:b,data:Q[ce],collectionsDispatch:X,selectedCollectionsDispatch:fe,selectedData:be,setSaveDisabled:de,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:R,outOfStockAction:T,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,renderWithoutModal:B,pickerType:M,hideProductVariants:V,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Oe(e)},showProductDetailInfoIcon:H,scrollContainerRef:ve})})),"view"===Z&&t.jsx(g.SelectedScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,hideProductVariants:V,outOfStockAction:T,storeId:b,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===Z&&t.jsx(S.RearrangeScreen,{selectedCollections:be||{},selectedCollectionsDispatch:fe,setScreen:ee,outOfStockAction:T,rearrangeViewType:"grid"===te?"list":"grid",scrollContainerRef:ve,storeId:b,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===Z&&t.jsx(x.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:be||{},searchedCollections:ye||{},searchedCollectionsDispatch:me,selectedCollectionsDispatch:fe,setScreen:ee,collections:Q,onBackPress:()=>{Se(""),me({type:"set",data:{collections:{},products:{}}})},pickerType:M,hideProductCheckbox:R,hideProductVariants:V,hideVariantCheckbox:D,storeId:b,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:re,setSelectedCollectionId:ne,renderWithoutModal:B,hideCollectionCheckbox:F,outOfStockAction:T})]}))]}));return t.jsx(t.Fragment,{children:B?t.jsxs(t.Fragment,{children:[De,K.renderFooter?t.jsxs(j.StyledFooterForNonModal,{children:[Re(),t.jsx(n.Button,{buttonText:Te(K.primaryButtonText),disabled:!K.isLoading&&(ae||ue<1||P&&ue<P||!P&&O&&ue>O)||K.primaryButtonDisabled,isLoading:K.isLoading,onClick:()=>{e.onAdd(be,ue),Fe(),ee([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}})]}):t.jsx(t.Fragment,{}),ke&&Pe?t.jsx(h.ProductInfoOverlay,{productData:Pe,outOfStockAction:T,useDynamicInfoImageSize:e.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):t.jsx(t.Fragment,{})]}):t.jsxs(l.StyledModal,Object.assign({zIndex:I,open:k,onClose:()=>{null==v||v(),Fe()},headingTitle:E||("collections"===Z||"products"===Z?"Select Products":"view"===Z?"Selected Products":"searchProducts"===Z?"Searched Results":"rearrange"===Z?"Rearrange Products":void 0),headingSubtitle:J,footerShadow:!0,centralContainerStyles:{width:A||"600px",left:w||"auto"},headerRightCustomElement:G?t.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:v},{children:t.jsx(s.default,{width:20,height:20,color:r.COLORS.content.secondary})})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:U?(t=>Object.assign(Object.assign({},t),{disabled:!t.isLoading&&(ae||ue<1||P&&ue<P||!P&&O&&ue>O)||t.disabled,onClick:()=>{e.onAdd(be,ue),Fe(),ee([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}}))(U):{buttonText:Te(),disabled:ae||ue<1||P&&ue<P||!P&&O&&ue>O||!1,onClick:()=>{e.onAdd(be,ue),Fe()}},secondaryButton:Y?(t=>Object.assign(Object.assign({},t),{disabled:ae||ue<1||P&&ue<P||!P&&O&&ue>O||!1,onClick:()=>{const t=m.updateAllVariantsForSelectedProducts(be,Q,ye);e.onAdd(t,ue,!0)}}))(Y):void 0,wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?t.jsx(t.Fragment,{}):Re(),hideCrossButton:ke||G},{children:[De,ke&&Pe?t.jsx(h.ProductInfoOverlay,{productData:Pe,useDynamicInfoImageSize:e.useDynamicInfoImageSize,outOfStockAction:T,onClose:()=>{Ie(!1)}}):t.jsx(t.Fragment,{})]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../node_modules/@bikdotai/bik-models/growth/models/bik-store.js");var t,o=require("../../assets/icons/search.svg.js"),r=require("react"),c=require("../../constants/Theme.js"),s=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),p=require("./productInfoOverlay.js"),h=require("./productScreen.js"),S=require("./rearrangeScreen.js"),x=require("./reducers.js"),C=require("./searchScreen.js"),g=require("./selectedScreen.js"),y=require("./style.js"),j=require("./type.js"),m=require("./utility.js"),b=require("../../_virtual/bik-store.js");exports.ScreenName=void 0,(t=exports.ScreenName||(exports.ScreenName={})).Collections="collections",t.RearrangeProducts="rearrange",t.SelectedProducts="view",t.SearchProducts="searchProducts",t.Products="products";exports.ProductPickerModal=t=>{const{storeId:f,selectedItems:v,onClose:k,visible:I,zIndex:P,exactLimit:O,limit:F,hideCollectionCheckbox:T,hideProductCheckbox:R,outOfStockAction:D=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:q,selectProductsFromCustomCollection:N,hideSelectionCount:E,title:A,width:w,left:B,renderWithoutModal:L,onClickSave:M,pickerType:V,hideProductVariants:_=!1,startupScreen:z=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:H=!1,showProductDetails:W,containerStyle:G,crossButtonInsideHeader:K=!1,footerForNonModal:U={},primaryButton:Y,secondaryButton:J,subtitle:Q}=t,X=t.appType||b.__exports.ApplicationType.BIK,[Z,ee]=r.useReducer(x.collectionsReducer,{}),[te,oe]=r.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections),[re,ce]=r.useState("grid"),[se,ne]=r.useState(""),[ie,le]=r.useState(""),[ae,de]=r.useState(0),[ue,pe]=r.useState(!1),[he,Se]=r.useState(0),[xe,Ce]=r.useState(""),[ge,ye]=r.useState(!1),[je,me]=r.useState(!1),[be,fe]=r.useReducer(x.searchReducer,{collections:{},products:{}}),[ve,ke]=r.useReducer(x.selectedColectionsReducer,Object.keys(v).length>0?v:{}),Ie=r.useRef(null),[Pe,Oe]=r.useState(!1),[Fe,Te]=r.useState();r.useEffect((()=>{pe(!0),me(!0),t.collectionFetcher(ae,f,X).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),pe(!1),de((e=>e+1)),me(!1)})).catch()}),[]),r.useEffect((()=>{let e=0;_?Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var r;"-1"!==t&&ve[-1]&&(null===(r=ve[-1].products)||void 0===r?void 0:r[o])||(e+=1)}))})):Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var r,c;Object.keys((null===(c=null===(r=ve[t].products)||void 0===r?void 0:r[o])||void 0===c?void 0:c.variants)||[]).forEach((()=>{e+=1}))}))})),Se(e)}),[Z,ve,_]),r.useEffect((()=>{ie&&(pe(!0),t.productFetcher(ie,f,X).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),pe(!1)})).catch())}),[ie]),r.useEffect((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(xe.length||"collections"!==te)&&(xe.length?(ye(!0),t.searchFetcher(f,xe,X).then((e=>{"collections"in e&&"products"in e?(fe({type:"set",data:e}),ee({type:"searched",data:e.collections})):(fe({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),pe(!1),ye(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[xe]),r.useEffect((()=>{M&&(t.onAdd(ve,he),Re())}),[M]),r.useEffect((()=>{H&&Object.keys(ve||{}).length&&he&&(t.onAdd(ve,he),Re())}),[H,ve,he]);const Re=()=>{ke({type:"reset",data:{}})},De=()=>O&&he>O?e.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):F&&he>F?e.jsx(d.Tag,{tagText:`You can only select ${F} products`,type:"negative"}):he>0?e.jsx(n.Button,{onClick:()=>{oe($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:O?`${he}/${O} products selected`:`${he} products selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}):e.jsx(n.Button,{disabled:!0,buttonText:O?`${he}/${O} products selected`:`${he} products selected`,buttonType:"tertiaryGray"}),qe=e=>ue?"Loading...":te===exports.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Ne=e.jsxs(y.ContainerStyle,Object.assign({style:null!=G?G:{}},{children:[t.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:t.postHeader})),!t.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===te||"searchProducts"===te)&&e.jsx("div",Object.assign({style:{padding:L?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(i.Input,{placeholder:"Search for collections and products, or type a product ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ge?e.jsx(a.Spinner,{size:"small",color:c.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:xe,onChangeText:e=>{e.length&&e.trim().length?Ce(e):Ce("")}})}))}),e.jsxs(y.ScrollContainerStyle,Object.assign({ref:Ie,screenName:te},{children:["collections"===te&&e.jsx(u.CollectionsScreen,{customCollectionRestriction:t.customCollectionRestriction,dataLoading:je,collections:Z,selectedCollectionsDispatch:ke,setCollectionId:ne,setSelectedCollectionId:le,setScreen:oe,selectedCollections:ve,collectionFetcher:t.collectionFetcher,storeId:f,appType:X,collectionsDispatch:ee,setSaveDisabled:pe,pagingControls:{curPage:ae,setCurPage:de},hideCollectionCheckbox:T,renderWithoutModal:L,pickerType:V,scrollContainerRef:Ie}),"products"===te&&se&&e.jsx(x.CollectionIdContext.Provider,Object.assign({value:se},{children:e.jsx(h.ProductsScreen,{hideInCollectionSearch:t.hideInCollectionSearch,customCollectionRestriction:t.customCollectionRestriction,productFetcher:t.productFetcher,setScreen:oe,storeId:f,appType:X,data:Z[se],collectionsDispatch:ee,selectedCollectionsDispatch:ke,selectedData:ve,setSaveDisabled:pe,searchInCollectionFetcher:t.searchInCollectionFetcher,hideProductCheckbox:R,outOfStockAction:D,hideVariantCheckbox:q,selectProductsFromCustomCollection:N,renderWithoutModal:L,pickerType:V,hideProductVariants:_,fbStatusFetcher:t.fbStatusFetcher,onProductDetailClick:e=>{Oe(!0),Te(e)},showProductDetailInfoIcon:W,scrollContainerRef:Ie})})),"view"===te&&e.jsx(g.SelectedScreen,{selectedCollections:ve||{},selectedCollectionsDispatch:ke,setScreen:oe,collections:Z,hideProductVariants:_,outOfStockAction:D,storeId:f,appType:X,fbStatusFetcher:t.fbStatusFetcher}),"rearrange"===te&&e.jsx(S.RearrangeScreen,{selectedCollections:ve||{},selectedCollectionsDispatch:ke,setScreen:oe,outOfStockAction:D,rearrangeViewType:"grid"===re?"list":"grid",scrollContainerRef:Ie,storeId:f,appType:X,fbStatusFetcher:t.fbStatusFetcher}),"searchProducts"===te&&e.jsx(C.SearchScreen,{customCollectionRestriction:t.customCollectionRestriction,selectedCollections:ve||{},searchedCollections:be||{},searchedCollectionsDispatch:fe,selectedCollectionsDispatch:ke,setScreen:oe,collections:Z,onBackPress:()=>{Ce(""),fe({type:"set",data:{collections:{},products:{}}})},pickerType:V,hideProductCheckbox:R,hideProductVariants:_,hideVariantCheckbox:q,storeId:f,appType:X,fbStatusFetcher:t.fbStatusFetcher,setCollectionId:ne,setSelectedCollectionId:le,renderWithoutModal:L,hideCollectionCheckbox:T,outOfStockAction:D})]}))]}));return e.jsx(e.Fragment,{children:L?e.jsxs(e.Fragment,{children:[Ne,U.renderFooter?e.jsxs(y.StyledFooterForNonModal,{children:[De(),e.jsx(n.Button,{buttonText:qe(U.primaryButtonText),disabled:!U.isLoading&&(ue||he<1||O&&he<O||!O&&F&&he>F)||U.primaryButtonDisabled,isLoading:U.isLoading,onClick:()=>{t.onAdd(ve,he),Re(),oe([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}})]}):e.jsx(e.Fragment,{}),Pe&&Fe?e.jsx(p.ProductInfoOverlay,{productData:Fe,outOfStockAction:D,useDynamicInfoImageSize:t.useDynamicInfoImageSize,onClose:()=>{Oe(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(l.StyledModal,Object.assign({zIndex:P,open:I,onClose:()=>{null==k||k(),Re()},headingTitle:A||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),headingSubtitle:Q,footerShadow:!0,centralContainerStyles:{width:w||"600px",left:B||"auto"},headerRightCustomElement:K?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:k},{children:e.jsx(s.default,{width:20,height:20,color:c.COLORS.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:t.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:c.COLORS.surface.standard}:void 0,primaryButton:Y?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ue||he<1||O&&he<O||!O&&F&&he>F)||e.disabled,onClick:()=>{t.onAdd(ve,he),Re(),oe([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(z)?z:exports.ScreenName.Collections)}}))(Y):{buttonText:qe(),disabled:ue||he<1||O&&he<O||!O&&F&&he>F||!1,onClick:()=>{t.onAdd(ve,he),Re()}},secondaryButton:J?(e=>Object.assign(Object.assign({},e),{disabled:ue||he<1||O&&he<O||!O&&F&&he>F||!1,onClick:()=>{const e=m.updateAllVariantsForSelectedProducts(ve,Z);t.onAdd(e,he,!0)}}))(J):void 0,wrapperStyle:t.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:E?e.jsx(e.Fragment,{}):De(),hideCrossButton:Pe||K},{children:[Ne,Pe&&Fe?e.jsx(p.ProductInfoOverlay,{productData:Fe,useDynamicInfoImageSize:t.useDynamicInfoImageSize,outOfStockAction:D,onClose:()=>{Oe(!1)}}):e.jsx(e.Fragment,{})]}))})};
@@ -1,3 +1,4 @@
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
1
2
  import React from 'react';
2
3
  import { Collection, FbStatusFetcherReturn, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
3
4
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
@@ -9,9 +10,10 @@ interface ProductsScreenInterface {
9
10
  collectionsDispatch: React.Dispatch<CollectionsActions>;
10
11
  selectedData: SelectedItems;
11
12
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
12
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
13
- productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
13
+ searchInCollectionFetcher: (storeId: string, collectionId: string, query: string, appType: ApplicationType) => ProductFetcherReturn;
14
+ productFetcher: (collectionId: string, storeId: string, appType: ApplicationType, limit?: number, offset?: number) => ProductFetcherReturn;
14
15
  storeId: string;
16
+ appType: ApplicationType;
15
17
  setScreen: React.Dispatch<React.SetStateAction<string>>;
16
18
  setSaveDisabled: React.Dispatch<React.SetStateAction<boolean>>;
17
19
  hideProductCheckbox?: boolean;
@@ -22,7 +24,7 @@ interface ProductsScreenInterface {
22
24
  pickerType?: 'COLLECTION' | 'PRODUCT';
23
25
  hideProductVariants?: boolean;
24
26
  showProductDetailInfoIcon?: boolean;
25
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
27
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
26
28
  onProductDetailClick: (productData: Product | ProductVariant) => void;
27
29
  scrollContainerRef: React.RefObject<HTMLDivElement>;
28
30
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),s=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),d=require("../InfiniteScroll/InfiniteScroll.js"),u=require("../input/Input.js"),a=require("../spinner/Spinner.js"),h=require("../TypographyStyle.js"),p=require("./emptyState.js"),j=require("./product.js"),v=require("./ProductPickerShimmer.js"),g=require("./reducers.js"),y=require("./style.js"),O=require("./type.js"),b=require("./utility.js");exports.ProductsScreen=f=>{var k,C;const{data:P,collectionsDispatch:x,selectedData:S,selectedCollectionsDispatch:I,productFetcher:m,storeId:q,setScreen:A,setSaveDisabled:D,hideInCollectionSearch:E,customCollectionRestriction:T,hideProductCheckbox:R,outOfStockAction:V=O.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:F=!1,pickerType:w,hideProductVariants:B,fbStatusFetcher:_,onProductDetailClick:M,showProductDetailInfoIcon:U,scrollContainerRef:H}=f,J=s.useContext(g.CollectionIdContext),K=s.useRef(0),N=s.useRef(!1),[W,z]=s.useState(""),[G,Q]=s.useState(!1),[X,Y]=s.useState(P),Z=s.useRef(!0),$=s.useRef(!1);s.useEffect((()=>{if(Z.current)return void(Z.current=!1);const e=setTimeout((()=>{W.length?(Q(!0),f.searchInCollectionFetcher(q,J,W).then((e=>{const t=c.cloneDeep(P);t.products=e,Y(t);const r=b.getVariantIdsToFetchAtProductLevel(null!=e?e:{});te(r,null!=e?e:{},!0),D(!1),Q(!1)}))):Y(P)}),800);return()=>clearTimeout(e)}),[W]);s.useEffect((()=>{var e,t,r,o;$.current=!1,K.current=Math.floor((null===(t=Object.keys(null!==(e=P.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const c=b.getVariantIdsToFetchAtProductLevel(null!==(r=P.products)&&void 0!==r?r:{});te(c,null!==(o=P.products)&&void 0!==o?o:{})}),[J]);const ee=!!T&&P.isSmartCollection;s.useEffect((()=>{(null==P?void 0:P.products)||re(10)}),[]);const te=(e,t,r)=>{_||(r?b.markVariantsAsApprovedProductsLevel(t,x,J,X,Y):b.markVariantsAsApprovedProductsLevel(t,x,J)),e.length>0&&_&&_(q,e).then((e=>{const o=Object.assign({},t);Object.keys(t).forEach((r=>{var c,s;Object.keys(null!==(s=null===(c=null==t?void 0:t[r])||void 0===c?void 0:c.variants)&&void 0!==s?s:{}).forEach((c=>{var s,n;const i=null===(s=null==t?void 0:t[r].variants)||void 0===s?void 0:s[c];i&&"REJECTED"===e[c]?i.fbStatus="REJECTED":i&&"APPROVED"===e[c]&&(i.fbStatus="APPROVED");const l=null===(n=null==o?void 0:o[r])||void 0===n?void 0:n.variants;l&&l[c]&&(l[c]=i)}))})),r?(Y((e=>{const t=Object.assign({},e);return t.products=o,t})),x({type:"productsPaged",data:{collectionId:J,products:o}})):x({type:"productsPaged",data:{collectionId:J,products:o}})})).catch((e=>{r?b.markVariantsAsApprovedProductsLevel(t,x,J,X,Y):b.markVariantsAsApprovedProductsLevel(t,x,J)}))},re=e=>{D(!0),Q(!0),m(J,q,e,0).then((t=>{if(Object.keys(t).length||($.current=!0),Object.keys(t).length){Y(Object.assign(Object.assign({},X),{products:t}));const e=b.getVariantIdsToFetchAtProductLevel(t);te(e,t),K.current=1}e||I({type:"selected",data:{id:J,val:Object.assign(Object.assign({},P),{products:t})}}),D(!1),Q(!1)})).catch()},oe=(e,t)=>{const r=b.liftTheStateUp(t,P);I({type:e,data:Object.assign(Object.assign({},r),{isRestricted:T})})},ce=!!(null==S?void 0:S[J])&&!!Object.keys(null!==(C=null===(k=null==S?void 0:S[J])||void 0===k?void 0:k.products)&&void 0!==C?C:{}).length;return e.jsxs("div",{children:[e.jsxs(y.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{A("collections")}}),e.jsx(h.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:P.name}))]}),!E&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>G&&W.length?e.jsx(a.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:W,onChangeText:e=>{e.length&&e.trim().length?z(e):z("")},placeholder:"Search for a product or type a product ID"})})),Object.keys((null==X?void 0:X.products)||[]).length>0&&!ee&&!W.length&&!R&&"-1"!==J&&e.jsxs(y.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:ce,isPartiallyChecked:b.isCollectionPartiallyChecked(J,X,S,B),onValueChange:function(e){e?re():I({type:"unselected",data:{id:J}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(r.default,{})})),e.jsx(h.TitleRegular,{children:"All Products"})]}),e.jsx(d.InfiniteScroll,Object.assign({hasData:!(Object.keys((null==X?void 0:X.products)||[]).length<10)&&!!Object.keys((null==X?void 0:X.products)||[]).length,fetchMore:()=>(N.current=!0,m(J,q,10,K.current).then((e=>{let t=!1;if(Object.keys(e).length||(t=!0),Object.keys(e).length){const t=X;t.products=Object.assign(Object.assign({},X.products),e),Y(Object.assign({},t));const r=b.getVariantIdsToFetchAtProductLevel(e);te(r,e)}return D(!1),N.current=!1,K.current+=1,t}))),containerRef:H},{children:Object.keys((null==X?void 0:X.products)||[]).length?Object.keys(X.products||[]).map((t=>e.jsx(j.ProductGroup,{outOfStockAction:V,collectionId:J,isProductPartiallyChecked:b.isProductPartiallyChecked(J,t,S,X,B),productId:t,data:X.products[t],selectedData:S,selectedCollectionsDispatch:I,viewOnly:!F&&!!ee,upliftAdditions:oe,hideProductCheckbox:R,hideVariantCheckbox:L,hideProductVariants:B,pickerType:w,onProductDetailClick:M,showProductDetailInfoIcon:U},t))):G?e.jsx(v.ProductPickerShimmer,{limit:10}):e.jsx(p.EmptyState,{title:"No products to show",subtitle:W.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})}))]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),s=require("react"),n=require("../../constants/Theme.js"),i=require("../checkBox/CheckBox.js"),l=require("../icon-button/IconButton.js"),d=require("../InfiniteScroll/InfiniteScroll.js"),u=require("../input/Input.js"),a=require("../spinner/Spinner.js"),h=require("../TypographyStyle.js"),p=require("./emptyState.js"),j=require("./product.js"),v=require("./ProductPickerShimmer.js"),g=require("./reducers.js"),y=require("./style.js"),O=require("./type.js"),b=require("./utility.js");exports.ProductsScreen=f=>{var k,C;const{data:P,collectionsDispatch:x,selectedData:S,selectedCollectionsDispatch:I,productFetcher:m,storeId:q,setScreen:A,setSaveDisabled:T,hideInCollectionSearch:D,customCollectionRestriction:E,hideProductCheckbox:R,outOfStockAction:V=O.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:F=!1,pickerType:w,hideProductVariants:B,fbStatusFetcher:_,onProductDetailClick:M,showProductDetailInfoIcon:U,scrollContainerRef:H,appType:J}=f,K=s.useContext(g.CollectionIdContext),N=s.useRef(0),W=s.useRef(!1),[z,G]=s.useState(""),[Q,X]=s.useState(!1),[Y,Z]=s.useState(P),$=s.useRef(!0),ee=s.useRef(!1);s.useEffect((()=>{if($.current)return void($.current=!1);const e=setTimeout((()=>{z.length?(X(!0),f.searchInCollectionFetcher(q,K,z,J).then((e=>{const t=c.cloneDeep(P);t.products=e,Z(t);const r=b.getVariantIdsToFetchAtProductLevel(null!=e?e:{});re(r,null!=e?e:{},!0),T(!1),X(!1)}))):Z(P)}),800);return()=>clearTimeout(e)}),[z]);s.useEffect((()=>{var e,t,r,o;ee.current=!1,N.current=Math.floor((null===(t=Object.keys(null!==(e=P.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length)/10);const c=b.getVariantIdsToFetchAtProductLevel(null!==(r=P.products)&&void 0!==r?r:{});re(c,null!==(o=P.products)&&void 0!==o?o:{})}),[K]);const te=!!E&&P.isSmartCollection;s.useEffect((()=>{(null==P?void 0:P.products)||oe(10)}),[]);const re=(e,t,r)=>{_||(r?b.markVariantsAsApprovedProductsLevel(t,x,K,Y,Z):b.markVariantsAsApprovedProductsLevel(t,x,K)),e.length>0&&_&&_(q,e,J).then((e=>{const o=Object.assign({},t);Object.keys(t).forEach((r=>{var c,s;Object.keys(null!==(s=null===(c=null==t?void 0:t[r])||void 0===c?void 0:c.variants)&&void 0!==s?s:{}).forEach((c=>{var s,n;const i=null===(s=null==t?void 0:t[r].variants)||void 0===s?void 0:s[c];i&&"REJECTED"===e[c]?i.fbStatus="REJECTED":i&&"APPROVED"===e[c]&&(i.fbStatus="APPROVED");const l=null===(n=null==o?void 0:o[r])||void 0===n?void 0:n.variants;l&&l[c]&&(l[c]=i)}))})),r?(Z((e=>{const t=Object.assign({},e);return t.products=o,t})),x({type:"productsPaged",data:{collectionId:K,products:o}})):x({type:"productsPaged",data:{collectionId:K,products:o}})})).catch((e=>{r?b.markVariantsAsApprovedProductsLevel(t,x,K,Y,Z):b.markVariantsAsApprovedProductsLevel(t,x,K)}))},oe=e=>{T(!0),X(!0),m(K,q,J,e,0).then((t=>{if(Object.keys(t).length||(ee.current=!0),Object.keys(t).length){Z(Object.assign(Object.assign({},Y),{products:t}));const e=b.getVariantIdsToFetchAtProductLevel(t);re(e,t),N.current=1}e||I({type:"selected",data:{id:K,val:Object.assign(Object.assign({},P),{products:t})}}),T(!1),X(!1)})).catch()},ce=(e,t)=>{const r=b.liftTheStateUp(t,P);I({type:e,data:Object.assign(Object.assign({},r),{isRestricted:E})})},se=!!(null==S?void 0:S[K])&&!!Object.keys(null!==(C=null===(k=null==S?void 0:S[K])||void 0===k?void 0:k.products)&&void 0!==C?C:{}).length;return e.jsxs("div",{children:[e.jsxs(y.ProductScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,height:16,onClick:()=>{A("collections")}}),e.jsx(h.BodyCaption,Object.assign({style:{color:n.COLORS.content.secondary}},{children:P.name}))]}),!D&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Q&&z.length?e.jsx(a.Spinner,{size:"small",color:n.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:z,onChangeText:e=>{e.length&&e.trim().length?G(e):G("")},placeholder:"Search for a product or type a product ID"})})),Object.keys((null==Y?void 0:Y.products)||[]).length>0&&!te&&!z.length&&!R&&"-1"!==K&&e.jsxs(y.ProductScreenCollectionCardStyle,{children:[e.jsx(i.CheckBox,{isChecked:se,isPartiallyChecked:b.isCollectionPartiallyChecked(K,Y,S,B),onValueChange:function(e){e?oe():I({type:"unselected",data:{id:K}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(r.default,{})})),e.jsx(h.TitleRegular,{children:"All Products"})]}),e.jsx(d.InfiniteScroll,Object.assign({hasData:!(Object.keys((null==Y?void 0:Y.products)||[]).length<10)&&!!Object.keys((null==Y?void 0:Y.products)||[]).length,fetchMore:()=>(W.current=!0,m(K,q,J,10,N.current).then((e=>{let t=!1;if(Object.keys(e).length||(t=!0),Object.keys(e).length){const t=Y;t.products=Object.assign(Object.assign({},Y.products),e),Z(Object.assign({},t));const r=b.getVariantIdsToFetchAtProductLevel(e);re(r,e)}return T(!1),W.current=!1,N.current+=1,t}))),containerRef:H},{children:Object.keys((null==Y?void 0:Y.products)||[]).length?Object.keys(Y.products||[]).map((t=>e.jsx(j.ProductGroup,{outOfStockAction:V,collectionId:K,isProductPartiallyChecked:b.isProductPartiallyChecked(K,t,S,Y,B),productId:t,data:Y.products[t],selectedData:S,selectedCollectionsDispatch:I,viewOnly:!F&&!!te,upliftAdditions:ce,hideProductCheckbox:R,hideVariantCheckbox:L,hideProductVariants:B,pickerType:w,onProductDetailClick:M,showProductDetailInfoIcon:U},t))):Q?e.jsx(v.ProductPickerShimmer,{limit:10}):e.jsx(p.EmptyState,{title:"No products to show",subtitle:z.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})}))]})};
@@ -1,3 +1,4 @@
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
1
2
  import React from 'react';
2
3
  import { FbStatusFetcherReturn, SelectedItems } from '.';
3
4
  import { SelectedCollectionsActions } from './reducers';
@@ -10,7 +11,8 @@ interface RearrangeScreenInterface {
10
11
  outOfStockAction?: OUT_OF_STOCK_ACTION;
11
12
  scrollContainerRef: React.RefObject<HTMLDivElement>;
12
13
  storeId: string;
13
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
14
+ appType: ApplicationType;
15
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
14
16
  }
15
17
  /**
16
18
  * Screen will be opened on two conditions -
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),s=require("react-beautiful-dnd"),c=require("../../constants/Theme.js"),o=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),n=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),d=require("./utility.js"),u=require("./variantComponents.js");exports.RearrangeScreen=p=>{const{selectedCollections:j,selectedCollectionsDispatch:S,setScreen:h,rearrangeViewType:y,outOfStockAction:f,scrollContainerRef:x,storeId:q,fbStatusFetcher:C}=p,[O,g]=r.useState(a.parseSelectedVariantsToArray(j));r.useEffect((()=>{g(a.parseSelectedVariantsToArray(j))}),[j]),r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),d.fetchFbStatusCollection(j,q,S,C,"update")}),[]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=O,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),g(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,width:16,height:16,color:c.COLORS.content.secondary,onClick:()=>{h("collections")}}),e.jsx(i.BodyCaption,Object.assign({color:c.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===y?e.jsx(u.VariantsList,{selectedVariants:O,setSelectedVariants:g,selectedCollectionsDispatch:S,outOfStockAction:f}):e.jsx(u.VariantsGrid,{selectedVariants:O,setSelectedVariants:g,selectedCollectionsDispatch:S}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),s=require("react-beautiful-dnd"),c=require("../../constants/Theme.js"),o=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),n=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),d=require("./utility.js"),u=require("./variantComponents.js");exports.RearrangeScreen=p=>{const{selectedCollections:j,selectedCollectionsDispatch:S,setScreen:h,rearrangeViewType:y,outOfStockAction:f,scrollContainerRef:x,storeId:q,fbStatusFetcher:C,appType:O}=p,[g,b]=r.useState(a.parseSelectedVariantsToArray(j));r.useEffect((()=>{b(a.parseSelectedVariantsToArray(j))}),[j]),r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),d.fetchFbStatusCollection(j,q,O,S,C,"update")}),[]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=g,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),b(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,width:16,height:16,color:c.COLORS.content.secondary,onClick:()=>{h("collections")}}),e.jsx(i.BodyCaption,Object.assign({color:c.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===y?e.jsx(u.VariantsList,{selectedVariants:g,setSelectedVariants:b,selectedCollectionsDispatch:S,outOfStockAction:f}):e.jsx(u.VariantsGrid,{selectedVariants:g,setSelectedVariants:b,selectedCollectionsDispatch:S}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
3
  import { Collection, FbStatusFetcherReturn, SearchedItems, SelectedItems } from '.';
3
4
  import { SearchReducerActions, SelectedCollectionsActions } from './reducers';
4
5
  import { OUT_OF_STOCK_ACTION } from './type';
@@ -20,7 +21,8 @@ interface SearchScreenInterface {
20
21
  hideProductVariants?: boolean;
21
22
  hideProductCheckbox?: boolean;
22
23
  storeId: string;
23
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
24
+ appType: ApplicationType;
25
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
24
26
  hideCollectionCheckbox?: boolean;
25
27
  renderWithoutModal?: boolean;
26
28
  outOfStockAction?: OUT_OF_STOCK_ACTION;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),l=require("../icon-button/IconButton.js"),c=require("../TypographyStyle.js"),i=require("./collectionScreen.js"),s=require("./emptyState.js"),d=require("./product.js"),r=require("./style.js"),n=require("./utility.js");exports.SearchScreen=u=>{var a;const{customCollectionRestriction:h,selectedCollections:v,searchedCollections:p,searchedCollectionsDispatch:C,selectedCollectionsDispatch:j,setScreen:k,collections:y,onBackPress:b,hideVariantCheckbox:x,pickerType:S,hideProductVariants:P,hideProductCheckbox:f,storeId:m,fbStatusFetcher:O,setCollectionId:g,setSelectedCollectionId:I,hideCollectionCheckbox:q,renderWithoutModal:D,outOfStockAction:F}=u;o.useEffect((()=>{var e;n.fetchFbStatusCollection(null!==(e=p.products)&&void 0!==e?e:{},m,C,O,"setProducts")}),[null==p?void 0:p.products]);const T=!!h&&(null==v?void 0:v.isCustom);return e.jsxs("div",{children:[e.jsxs(r.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{k("collections"),b()}}),e.jsx(c.BodyCaption,{children:(null===(a=Object.keys(null==p?void 0:p.collections))||void 0===a?void 0:a.length)?"Searched Collections & Products":"Searched Products"})]}),e.jsx("div",{children:Object.keys(null==p?void 0:p.products).length||Object.keys(null==p?void 0:p.collections).length?e.jsxs(e.Fragment,{children:[e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.collections).map((t=>e.jsx(i.CollectionCard,{customCollectionRestriction:h,data:null==y?void 0:y[t],isDisabled:T&&!(null==v?void 0:v[t]),isChecked:!!(null==v?void 0:v[t]),isPartiallyChecked:n.isCollectionPartiallyChecked(t,null==y?void 0:y[t],v,P),selectedCollectionsDispatch:j,setCollectionId:g,setSelectedCollectionId:I,setScreen:k,id:t,hideCollectionCheckbox:q||"-1"===t,selectedCollections:v,renderWithoutModal:D,pickerType:S,usedInSearch:!0},t)))}),e.jsx(e.Fragment,{children:Object.keys(null==p?void 0:p.products).map((t=>{var o,l;return Object.keys((null===(l=null===(o=null==p?void 0:p.products)||void 0===o?void 0:o[t])||void 0===l?void 0:l.products)||[]).map((o=>{var l,c,i;let s=!1;return(null===(l=null==p?void 0:p.products)||void 0===l?void 0:l.isCustom)&&(s=!0),e.jsx(d.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{var l;const c=n.liftTheStateUp(o,null===(l=null==p?void 0:p.products)||void 0===l?void 0:l[e]);j({type:t,data:Object.assign(Object.assign({},c),{isRestricted:h})})})(t,e,o),productId:o,data:(null===(c=null==p?void 0:p.products)||void 0===c?void 0:c[t].products)[o],isProductPartiallyChecked:n.isProductPartiallyChecked(t,o,v,null===(i=p.products)||void 0===i?void 0:i[t],P),selectedData:v,selectedCollectionsDispatch:j,viewOnly:s,hideProductCheckbox:f,hideVariantCheckbox:x,hideProductVariants:P,pickerType:S,outOfStockAction:F},o)}))}))})]}):e.jsx(s.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),l=require("../icon-button/IconButton.js"),c=require("../TypographyStyle.js"),i=require("./collectionScreen.js"),s=require("./emptyState.js"),d=require("./product.js"),r=require("./style.js"),n=require("./utility.js");exports.SearchScreen=u=>{var a;const{customCollectionRestriction:h,selectedCollections:p,searchedCollections:v,searchedCollectionsDispatch:C,selectedCollectionsDispatch:j,setScreen:y,collections:k,onBackPress:b,hideVariantCheckbox:x,pickerType:S,hideProductVariants:P,hideProductCheckbox:f,storeId:m,fbStatusFetcher:O,setCollectionId:g,setSelectedCollectionId:I,hideCollectionCheckbox:q,renderWithoutModal:D,outOfStockAction:T,appType:F}=u;o.useEffect((()=>{var e;n.fetchFbStatusCollection(null!==(e=v.products)&&void 0!==e?e:{},m,F,C,O,"setProducts")}),[null==v?void 0:v.products]);const B=!!h&&(null==p?void 0:p.isCustom);return e.jsxs("div",{children:[e.jsxs(r.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{y("collections"),b()}}),e.jsx(c.BodyCaption,{children:(null===(a=Object.keys(null==v?void 0:v.collections))||void 0===a?void 0:a.length)?"Searched Collections & Products":"Searched Products"})]}),e.jsx("div",{children:Object.keys(null==v?void 0:v.products).length||Object.keys(null==v?void 0:v.collections).length?e.jsxs(e.Fragment,{children:[e.jsx(e.Fragment,{children:Object.keys(null==v?void 0:v.collections).map((t=>e.jsx(i.CollectionCard,{customCollectionRestriction:h,data:null==k?void 0:k[t],isDisabled:B&&!(null==p?void 0:p[t]),isChecked:!!(null==p?void 0:p[t]),isPartiallyChecked:n.isCollectionPartiallyChecked(t,null==k?void 0:k[t],p,P),selectedCollectionsDispatch:j,setCollectionId:g,setSelectedCollectionId:I,setScreen:y,id:t,hideCollectionCheckbox:q||"-1"===t,selectedCollections:p,renderWithoutModal:D,pickerType:S,usedInSearch:!0},t)))}),e.jsx(e.Fragment,{children:Object.keys(null==v?void 0:v.products).map((t=>{var o,l;return Object.keys((null===(l=null===(o=null==v?void 0:v.products)||void 0===o?void 0:o[t])||void 0===l?void 0:l.products)||[]).map((o=>{var l,c,i;let s=!1;return(null===(l=null==v?void 0:v.products)||void 0===l?void 0:l.isCustom)&&(s=!0),e.jsx(d.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{var l;const c=n.liftTheStateUp(o,null===(l=null==v?void 0:v.products)||void 0===l?void 0:l[e]);j({type:t,data:Object.assign(Object.assign({},c),{isRestricted:h})})})(t,e,o),productId:o,data:(null===(c=null==v?void 0:v.products)||void 0===c?void 0:c[t].products)[o],isProductPartiallyChecked:n.isProductPartiallyChecked(t,o,p,null===(i=v.products)||void 0===i?void 0:i[t],P),selectedData:p,selectedCollectionsDispatch:j,viewOnly:s,hideProductCheckbox:f,hideVariantCheckbox:x,hideProductVariants:P,pickerType:S,outOfStockAction:T},o)}))}))})]}):e.jsx(s.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
3
  import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
3
4
  import { SelectedCollectionsActions } from './reducers';
4
5
  import { OUT_OF_STOCK_ACTION } from './type';
@@ -12,7 +13,8 @@ interface SelectedScreenInterface {
12
13
  hideProductVariants?: boolean;
13
14
  outOfStockAction?: OUT_OF_STOCK_ACTION;
14
15
  storeId: string;
15
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
16
+ appType: ApplicationType;
17
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
16
18
  }
17
19
  export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
18
20
  export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),c=require("../icon-button/IconButton.js"),s=require("../TypographyStyle.js"),n=require("./emptyState.js"),i=require("./product.js"),o=require("./reducers.js"),u=require("./style.js"),l=require("./utility.js");exports.SelectedScreen=d=>{const{selectedCollections:a,selectedCollectionsDispatch:p,setScreen:j,collections:f,hideProductVariants:h=!1,outOfStockAction:y,storeId:S,fbStatusFetcher:v}=d,b=r.useRef(0),x=r.useRef(null),[g,q]=r.useReducer(o.paginationReducer,{});r.useEffect((()=>{b.current=0;const e=l.paginateSelectedItems(a,10,0);q({type:"paginate",data:e}),l.fetchFbStatusCollection(e,S,q,v,"set"),b.current+=1}),[]),r.useEffect((()=>{q({type:"filter",data:a})}),[a]),r.useEffect((()=>{const e=new IntersectionObserver((e=>{if(e[0].isIntersecting&&b.current>0){const e=l.paginateSelectedItems(a,10,b.current);q({type:"paginate",data:e}),l.fetchFbStatusCollection(e,S,q,v,"update"),b.current+=1}}),{threshold:1});return x.current&&e.observe(x.current),()=>{x.current&&e.unobserve(x.current)}}),[x,a]);const C=a;return e.jsxs("div",{children:[e.jsxs(u.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,onClick:()=>{j("collections")}}),e.jsx(s.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(g).length>0?e.jsx(e.Fragment,{children:Object.keys(g).map((t=>{var r;return Object.keys((null===(r=null==g?void 0:g[t])||void 0===r?void 0:r.products)||[]).map((r=>{let c=!1;return(null==C?void 0:C.isCustom)&&(c=!0),e.jsx(i.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:g[t].products[r],isProductPartiallyChecked:l.isProductPartiallyChecked(t,r,C,null==f?void 0:f[t],h),selectedData:C,selectedCollectionsDispatch:p,viewOnly:c,hideProductVariants:h,outOfStockAction:y},r)}))}))}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:x})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),c=require("../icon-button/IconButton.js"),s=require("../TypographyStyle.js"),n=require("./emptyState.js"),i=require("./product.js"),o=require("./reducers.js"),u=require("./style.js"),l=require("./utility.js");exports.SelectedScreen=d=>{const{selectedCollections:a,selectedCollectionsDispatch:p,setScreen:j,collections:f,hideProductVariants:h=!1,outOfStockAction:y,storeId:S,fbStatusFetcher:v,appType:b}=d,x=r.useRef(0),g=r.useRef(null),[q,C]=r.useReducer(o.paginationReducer,{});r.useEffect((()=>{x.current=0;const e=l.paginateSelectedItems(a,10,0);C({type:"paginate",data:e}),l.fetchFbStatusCollection(e,S,b,C,v,"set"),x.current+=1}),[]),r.useEffect((()=>{C({type:"filter",data:a})}),[a]),r.useEffect((()=>{const e=new IntersectionObserver((e=>{if(e[0].isIntersecting&&x.current>0){const e=l.paginateSelectedItems(a,10,x.current);C({type:"paginate",data:e}),l.fetchFbStatusCollection(e,S,b,C,v,"update"),x.current+=1}}),{threshold:1});return g.current&&e.observe(g.current),()=>{g.current&&e.unobserve(g.current)}}),[g,a]);const I=a;return e.jsxs("div",{children:[e.jsxs(u.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,onClick:()=>{j("collections")}}),e.jsx(s.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(q).length>0?e.jsx(e.Fragment,{children:Object.keys(q).map((t=>{var r;return Object.keys((null===(r=null==q?void 0:q[t])||void 0===r?void 0:r.products)||[]).map((r=>{let c=!1;return(null==I?void 0:I.isCustom)&&(c=!0),e.jsx(i.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:q[t].products[r],isProductPartiallyChecked:l.isProductPartiallyChecked(t,r,I,null==f?void 0:f[t],h),selectedData:I,selectedCollectionsDispatch:p,viewOnly:c,hideProductVariants:h,outOfStockAction:y},r)}))}))}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:g})]})]})};
@@ -1,4 +1,5 @@
1
- import { Collection, FbStatusFetcherReturn, Product, ProductVariant, SearchedItems, SelectedItems } from './modal';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
+ import { Collection, FbStatusFetcherReturn, Product, ProductVariant, SelectedItems } from './modal';
2
3
  import { CollectionsActions } from './reducers';
3
4
  export declare const liftTheStateUp: (payload: any, data: any) => any;
4
5
  export declare function paginateSelectedItems(selectedItems: SelectedItems, limit: number, offset: number): {
@@ -12,7 +13,7 @@ export declare function paginateSelectedItems(selectedItems: SelectedItems, limi
12
13
  *
13
14
  * We first get the variant ids to fetch and only if we have variant ids, we call api.
14
15
  */
15
- export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
16
+ export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, appType: ApplicationType, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
16
17
  /**
17
18
  * Instead of collection level, we do it product level.
18
19
  *
@@ -47,4 +48,4 @@ export declare const updateAllVariantsForSelectedProducts: (selectedItems: {
47
48
  };
48
49
  } | undefined;
49
50
  };
50
- }, collections: Collection, searchedProducts: SearchedItems) => Record<string, any>;
51
+ }, collections: Collection) => Record<string, any>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function l(o,l,t){if(!o)return{};const d=Object.keys(o).slice(t,t+l),i={};return d.forEach((l=>{i[l]=o[l]})),i}const t=(o,l,t)=>{Object.keys(o).forEach((l=>{var t,d;const i=null!==(d=null===(t=o[l])||void 0===t?void 0:t.products)&&void 0!==d?d:{};Object.keys(i).forEach((t=>{var d,i,n,s;const e=null!==(s=null===(n=null===(i=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===i?void 0:i[t])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(e).forEach((d=>{var i,n,s,e;const v=null===(e=null===(s=null===(n=null===(i=o[l])||void 0===i?void 0:i.products)||void 0===n?void 0:n[t])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[d];v&&!v.fbStatus&&(v.fbStatus="APPROVED")}))}))})),l({type:t,data:o})};exports.fetchFbStatusCollection=function(o,l,d,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";i||t(o,d,n);const s=(o=>{const l=[];return Object.keys(o).forEach((t=>{var d,i;const n=null!==(i=null===(d=o[t])||void 0===d?void 0:d.products)&&void 0!==i?i:{};Object.keys(n).forEach((d=>{var i,n,s,e;const v=null!==(e=null===(s=null===(n=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===n?void 0:n[d])||void 0===s?void 0:s.variants)&&void 0!==e?e:{};Object.keys(v).forEach((i=>{var n,s,e,v;const c=null===(v=null===(e=null===(s=null===(n=o[t])||void 0===n?void 0:n.products)||void 0===s?void 0:s[d])||void 0===e?void 0:e.variants)||void 0===v?void 0:v[i];(null==c?void 0:c.fbStatus)||l.push(i)}))}))})),l})(o);s.length>0&&i&&i(l,s).then((l=>{const t=Object.assign({},o);Object.keys(t).forEach((o=>{var d,i;const n=null!==(i=null===(d=t[o])||void 0===d?void 0:d.products)&&void 0!==i?i:{};Object.keys(n).forEach((d=>{var i,n,s,e;const v=null!==(e=null===(s=null===(n=null===(i=t[o])||void 0===i?void 0:i.products)||void 0===n?void 0:n[d])||void 0===s?void 0:s.variants)&&void 0!==e?e:{};Object.keys(v).forEach((i=>{var n,s,e,v;const c=null===(v=null===(e=null===(s=null===(n=t[o])||void 0===n?void 0:n.products)||void 0===s?void 0:s[d])||void 0===e?void 0:e.variants)||void 0===v?void 0:v[i];c&&"REJECTED"===l[i]?c.fbStatus="REJECTED":c&&"APPROVED"===l[i]&&(c.fbStatus="APPROVED")}))}))})),d({type:n,data:t})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,d,n)}))},exports.getVariantIdsToFetchAtProductLevel=(o,l)=>{const t=[];return Object.keys(null!=o?o:{}).forEach((d=>{var i,n;const s=null!==(n=null===(i=null==o?void 0:o[d])||void 0===i?void 0:i.variants)&&void 0!==n?n:{};Object.keys(s).forEach((i=>{var n,s,e,v,c;let u;u=l?null===(e=null===(s=null===(n=null==l?void 0:l.products)||void 0===n?void 0:n[d])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[i]:null===(c=null===(v=null==o?void 0:o[d])||void 0===v?void 0:v.variants)||void 0===c?void 0:c[i],(null==u?void 0:u.fbStatus)||t.push(i)}))})),t},exports.isCollectionPartiallyChecked=function(o,l,t){var d,i,n,s;let e=0,v=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const s=null!==(d=null==l?void 0:l.products)&&void 0!==d?d:{};e=Object.keys(s).length;const c=null!==(n=null===(i=t[o])||void 0===i?void 0:i.products)&&void 0!==n?n:{};v=Object.keys(c).length}else if(t[o]){const d=null==l?void 0:l.products;d&&Object.keys(d).forEach((o=>{var l;const t=null===(l=d[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>e+=1))}));const i=null===(s=t[o])||void 0===s?void 0:s.products;if(i&&Object.keys(i).forEach((o=>{var l;const t=null===(l=i[o])||void 0===l?void 0:l.variants;t&&Object.keys(t).forEach((o=>v+=1))})),e<=0&&v>0)return!1}return v>0&&e!==v},exports.isProductPartiallyChecked=(o,l,t,d,i)=>{var n,s,e,v,c,u,r,a,p,b,O,f,j,h,y,g,E,k,P;let I=0,D=0;if(null===(s=null===(n=null==t?void 0:t[o])||void 0===n?void 0:n.products)||void 0===s?void 0:s[l]){if(i)return!1;const n=(null===(c=null===(v=null===(e=null==t?void 0:t[o])||void 0===e?void 0:e.products)||void 0===v?void 0:v[l])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(n).length)for(const d in n){const i=null===(r=null===(u=null==t?void 0:t[o])||void 0===u?void 0:u.products)||void 0===r?void 0:r[l],n=null===(O=null===(b=null===(p=null===(a=null==t?void 0:t[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[d];if(null===(f=null==n?void 0:n.name)||void 0===f?void 0:f.includes(null!==(j=null==i?void 0:i.name)&&void 0!==j?j:""))return!1}if(null===(g=Object.keys((null===(y=null===(h=null==d?void 0:d.products)||void 0===h?void 0:h[l])||void 0===y?void 0:y.variants)||[]))||void 0===g||g.forEach((()=>D++)),Object.keys((null===(P=null===(k=null===(E=null==t?void 0:t[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>I++)),I>0&&D!==I)return!0}return!1},exports.liftTheStateUp=(l,t)=>{const d=o.cloneDeep(t);if(delete d.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:d})).productId&&t.products){const i=o.cloneDeep(t.products[l.productId]);(null==i?void 0:i.variants)&&delete i.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:d,productOnlyData:i})}return l},exports.markVariantsAsApprovedProductsLevel=(o,l,t,d,i)=>{const n=Object.assign({},o);if(Object.keys(o).forEach((l=>{var t,d;Object.keys(null!==(d=null===(t=null==o?void 0:o[l])||void 0===t?void 0:t.variants)&&void 0!==d?d:{}).forEach((t=>{var d,i;const s=null===(d=null==o?void 0:o[l].variants)||void 0===d?void 0:d[t];s&&(s.fbStatus="APPROVED");const e=null===(i=null==n?void 0:n[l])||void 0===i?void 0:i.variants;e&&e[t]&&(e[t]=s)}))})),d&&i){const o=Object.assign({},d);o.products=n,i(o),l({type:"productsPaged",data:{collectionId:t,products:n}})}else l({type:"productsPaged",data:{collectionId:t,products:n}})},exports.paginateSelectedItems=function(o,t,d){var i;const n={};let s=0;for(const e in o)if(Object.prototype.hasOwnProperty.call(o,e)){const v=o[e],c=l(v.products,t,d-s);c&&Object.keys(c).length>0&&(n[e]=Object.assign(Object.assign({},v),{products:c})),s+=Object.keys(null!==(i=v.products)&&void 0!==i?i:{}).length}return n},exports.shouldShowVariant=o=>{const l=Object.keys(o.variants||[]);let t=!1;return!(l.length<=1)||(l.forEach((l=>{var d,i;t=null!==(i=null===(d=o.variants)||void 0===d?void 0:d[l].name.includes(o.name))&&void 0!==i&&i})),!t)},exports.updateAllVariantsForSelectedProducts=(l,t,d)=>{console.log({selectedItems:l,collections:t,searchedProducts:d});return Object.keys(l).reduce(((i,n)=>{var s;return n in t?(i[n]=Object.assign(Object.assign({},l[n]),{products:Object.keys(null!==(s=l[n].products)&&void 0!==s?s:{}).reduce(((i,s)=>{var e,v,c,u,r,a,p,b,O,f,j,h;const y=null===(e=t[n].products)||void 0===e?void 0:e[s],g=null===(u=null===(c=null===(v=null==d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===c?void 0:c.products)||void 0===u?void 0:u[s];return y?(i[s]=Object.assign(Object.assign({},(null===(r=l[n].products)||void 0===r?void 0:r[s])||{}),{allVariants:o.cloneDeep(y.variants)}),console.log("productInCollection 1",y,{updatedProducts:i,collectionId:n,productId:s})):g?(i[s]=Object.assign(Object.assign({},(null===(a=l[n].products)||void 0===a?void 0:a[s])||{}),{allVariants:o.cloneDeep(g.variants)}),console.log("productInCollection 2",g,{updatedProducts:i,collectionId:n,productId:s})):(null===(b=null===(p=l[n].products)||void 0===p?void 0:p[s])||void 0===b?void 0:b.allVariants)&&(i[s]=Object.assign(Object.assign({},(null===(O=l[n].products)||void 0===O?void 0:O[s])||{}),{allVariants:o.cloneDeep(null===(f=l[n].products)||void 0===f?void 0:f[s].allVariants)}),console.log("productInCollection 3",null===(h=null===(j=l[n].products)||void 0===j?void 0:j[s])||void 0===h?void 0:h.allVariants,{updatedProducts:i,collectionId:n,productId:s})),i}),{})}),i):i}),{})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function t(o,t,l){if(!o)return{};const i=Object.keys(o).slice(l,l+t),n={};return i.forEach((t=>{n[t]=o[t]})),n}const l=(o,t,l)=>{Object.keys(o).forEach((t=>{var l,i;const n=null!==(i=null===(l=o[t])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(n).forEach((l=>{var i,n,d,v;const s=null!==(v=null===(d=null===(n=null===(i=o[t])||void 0===i?void 0:i.products)||void 0===n?void 0:n[l])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((i=>{var n,d,v,s;const e=null===(s=null===(v=null===(d=null===(n=o[t])||void 0===n?void 0:n.products)||void 0===d?void 0:d[l])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[i];e&&!e.fbStatus&&(e.fbStatus="APPROVED")}))}))})),t({type:l,data:o})};exports.fetchFbStatusCollection=function(o,t,i,n,d){let v=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"paged";d||l(o,n,v);const s=(o=>{const t=[];return Object.keys(o).forEach((l=>{var i,n;const d=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,s;const e=null!==(s=null===(v=null===(d=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(e).forEach((n=>{var d,v,s,e;const r=null===(e=null===(s=null===(v=null===(d=o[l])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[n];(null==r?void 0:r.fbStatus)||t.push(n)}))}))})),t})(o);s.length>0&&d&&d(t,s,i).then((t=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var i,n;const d=null!==(n=null===(i=l[o])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(d).forEach((i=>{var n,d,v,s;const e=null!==(s=null===(v=null===(d=null===(n=l[o])||void 0===n?void 0:n.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(e).forEach((n=>{var d,v,s,e;const r=null===(e=null===(s=null===(v=null===(d=l[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===e?void 0:e[n];r&&"REJECTED"===t[n]?r.fbStatus="REJECTED":r&&"APPROVED"===t[n]&&(r.fbStatus="APPROVED")}))}))})),n({type:v,data:l})})).catch((t=>{console.error("Error in fbStatusFetcher",t),l(o,n,v)}))},exports.getVariantIdsToFetchAtProductLevel=(o,t)=>{const l=[];return Object.keys(null!=o?o:{}).forEach((i=>{var n,d;const v=null!==(d=null===(n=null==o?void 0:o[i])||void 0===n?void 0:n.variants)&&void 0!==d?d:{};Object.keys(v).forEach((n=>{var d,v,s,e,r;let u;u=t?null===(s=null===(v=null===(d=null==t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n]:null===(r=null===(e=null==o?void 0:o[i])||void 0===e?void 0:e.variants)||void 0===r?void 0:r[n],(null==u?void 0:u.fbStatus)||l.push(n)}))})),l},exports.isCollectionPartiallyChecked=function(o,t,l){var i,n,d,v;let s=0,e=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(i=null==t?void 0:t.products)&&void 0!==i?i:{};s=Object.keys(v).length;const r=null!==(d=null===(n=l[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};e=Object.keys(r).length}else if(l[o]){const i=null==t?void 0:t.products;i&&Object.keys(i).forEach((o=>{var t;const l=null===(t=i[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>s+=1))}));const n=null===(v=l[o])||void 0===v?void 0:v.products;if(n&&Object.keys(n).forEach((o=>{var t;const l=null===(t=n[o])||void 0===t?void 0:t.variants;l&&Object.keys(l).forEach((o=>e+=1))})),s<=0&&e>0)return!1}return e>0&&s!==e},exports.isProductPartiallyChecked=(o,t,l,i,n)=>{var d,v,s,e,r,u,c,a,p,b,O,f,j,h,y,E,g,k,P;let D=0,S=0;if(null===(v=null===(d=null==l?void 0:l[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[t]){if(n)return!1;const d=(null===(r=null===(e=null===(s=null==l?void 0:l[o])||void 0===s?void 0:s.products)||void 0===e?void 0:e[t])||void 0===r?void 0:r.variants)||[];if(1===Object.keys(d).length)for(const i in d){const n=null===(c=null===(u=null==l?void 0:l[o])||void 0===u?void 0:u.products)||void 0===c?void 0:c[t],d=null===(O=null===(b=null===(p=null===(a=null==l?void 0:l[o])||void 0===a?void 0:a.products)||void 0===p?void 0:p[t])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[i];if(null===(f=null==d?void 0:d.name)||void 0===f?void 0:f.includes(null!==(j=null==n?void 0:n.name)&&void 0!==j?j:""))return!1}if(null===(E=Object.keys((null===(y=null===(h=null==i?void 0:i.products)||void 0===h?void 0:h[t])||void 0===y?void 0:y.variants)||[]))||void 0===E||E.forEach((()=>S++)),Object.keys((null===(P=null===(k=null===(g=null==l?void 0:l[o])||void 0===g?void 0:g.products)||void 0===k?void 0:k[t])||void 0===P?void 0:P.variants)||[]).forEach((()=>D++)),D>0&&S!==D)return!0}return!1},exports.liftTheStateUp=(t,l)=>{const i=o.cloneDeep(l);if(delete i.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:i})).productId&&l.products){const n=o.cloneDeep(l.products[t.productId]);(null==n?void 0:n.variants)&&delete n.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:i,productOnlyData:n})}return t},exports.markVariantsAsApprovedProductsLevel=(o,t,l,i,n)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((t=>{var l,i;Object.keys(null!==(i=null===(l=null==o?void 0:o[t])||void 0===l?void 0:l.variants)&&void 0!==i?i:{}).forEach((l=>{var i,n;const v=null===(i=null==o?void 0:o[t].variants)||void 0===i?void 0:i[l];v&&(v.fbStatus="APPROVED");const s=null===(n=null==d?void 0:d[t])||void 0===n?void 0:n.variants;s&&s[l]&&(s[l]=v)}))})),i&&n){const o=Object.assign({},i);o.products=d,n(o),t({type:"productsPaged",data:{collectionId:l,products:d}})}else t({type:"productsPaged",data:{collectionId:l,products:d}})},exports.paginateSelectedItems=function(o,l,i){var n;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const e=o[s],r=t(e.products,l,i-v);r&&Object.keys(r).length>0&&(d[s]=Object.assign(Object.assign({},e),{products:r})),v+=Object.keys(null!==(n=e.products)&&void 0!==n?n:{}).length}return d},exports.shouldShowVariant=o=>{const t=Object.keys(o.variants||[]);let l=!1;return!(t.length<=1)||(t.forEach((t=>{var i,n;l=null!==(n=null===(i=o.variants)||void 0===i?void 0:i[t].name.includes(o.name))&&void 0!==n&&n})),!l)},exports.updateAllVariantsForSelectedProducts=(t,l)=>Object.keys(t).reduce(((i,n)=>{var d;return n in l?(i[n]=Object.assign(Object.assign({},t[n]),{products:Object.keys(null!==(d=t[n].products)&&void 0!==d?d:{}).reduce(((i,d)=>{var v,s,e,r,u,c;const a=null===(v=l[n].products)||void 0===v?void 0:v[d];return a?i[d]=Object.assign(Object.assign({},(null===(s=t[n].products)||void 0===s?void 0:s[d])||{}),{allVariants:o.cloneDeep(a.variants)}):(null===(r=null===(e=t[n].products)||void 0===e?void 0:e[d])||void 0===r?void 0:r.allVariants)&&(i[d]=Object.assign(Object.assign({},(null===(u=t[n].products)||void 0===u?void 0:u[d])||{}),{allVariants:o.cloneDeep(null===(c=t[n].products)||void 0===c?void 0:c[d].allVariants)})),i}),{})}),i):i}),{});
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("../../../assets/icons/info.svg.js"),a=require("date-fns"),i=require("lodash"),n=require("react"),s=require("styled-components"),o=require("../../alerts/Alert.js"),u=require("../../alerts/AlertHelper.js"),d=require("../../custom-date-time/CustomDateTime.js"),r=require("../../dropdown/Dropdown.js"),c=require("../../input/Input.js"),p=require("../../product-picker-v2/collectionScreen.js"),v=require("../../template-preview/constants/regexPatterns.js"),m=require("../../template-preview/models/Channels.js"),b=require("../../template-preview/models/WebpushTemplate.js"),g=require("../../template-preview/models/WhatsAppTemplate.js"),O=require("../../TypographyStyle.js"),j=require("../../../utils/StringUtils.js"),x=require("../../../constants/Theme.js"),E=require("../context/templateModalContext.js"),y=require("../custom-hooks/useAdditionalVariables.js"),T=require("../utils/getVariableNameEmail.js"),_=require("./QueryParamsComponent.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=h(s);const C=f.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("../../../assets/icons/info.svg.js"),a=require("date-fns"),i=require("lodash"),n=require("react"),s=require("styled-components"),o=require("../../alerts/Alert.js"),u=require("../../alerts/AlertHelper.js"),d=require("../../custom-date-time/CustomDateTime.js"),r=require("../../dropdown/Dropdown.js"),c=require("../../input/Input.js"),p=require("../../product-picker-v2/collectionScreen.js"),v=require("../../template-preview/constants/regexPatterns.js"),m=require("../../template-preview/models/Channels.js"),b=require("../../template-preview/models/WebpushTemplate.js"),g=require("../../template-preview/models/WhatsAppTemplate.js"),O=require("../../TypographyStyle.js"),j=require("../../../utils/StringUtils.js"),x=require("../../../constants/Theme.js"),y=require("../context/templateModalContext.js"),E=require("../custom-hooks/useAdditionalVariables.js"),T=require("../utils/getVariableNameEmail.js"),_=require("./QueryParamsComponent.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=h(s);const C=f.default.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
4
  background: ${e=>e.focused&&e.channel===m.CHANNEL_TYPE.EMAIL?x.COLORS.background.warning.light:"transparent"};
@@ -16,4 +16,4 @@
16
16
  height: 100%;
17
17
  width: 48%;
18
18
  background: rgba(0, 0, 0, 0.1);
19
- `,L={value:"custom_link",label:"Custom URL"},A={value:"custom_text",label:"Custom text"},S={value:"static_expiry",label:"Static Expiry"};exports.Container=C,exports.default=s=>{var h,f,V,H,k,D,B,Y,w;const{onFocus:U,variable:R,index:q,showVariableModal:I,setShowDiscountCheckBox:W,componentType:M,CTAoptions:$,buttonType:z}=s,[Z,F]=n.useState(!1),[G,Q]=n.useState(""),[K,J]=n.useState([]),[X,ee]=n.useState(),[te,le]=n.useState(!1),{variableList:ae,setVariableList:ie,setVariableCallback:ne,setShowVariablePicker:se,device:oe,channel:ue,isError:de,originalVariableList:re,template:ce,templateSelectionTriggered:pe,setTemplate:ve,setDisplayContent:me,setOriginalVariableList:be,globalNormalizedPlaceholders:ge,enabledCustomText:Oe,pod:je,selectedCarouselIndex:xe,isProductCarouselType:Ee,isWhatsappCarousel:ye,disableEditVariable:Te,disableEditExpiry:_e,templateErrorIndexes:he,maxCharLimit:fe,disableDatePicker:Ce,showDiscountCodeExpiryInfo:Ne,cardIndex:Pe=1}=E.useTemplateModalContext();function Le(e,t){var l,a,i,n;const s=e;Q(""),ee(s),ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS?"custom_text"!==s.value&&"custom_link"!==s.value&&"static_expiry"!==s.value?(Se(null!==(l=s.value)&&void 0!==l?l:"","string"),null==Ve||Ve(null!==(a=R.index)&&void 0!==a?a:0,s.value,!0)):(null==Ve||Ve(null!==(i=R.index)&&void 0!==i?i:0,"",!0,s.value),Se("","url"===s.bikPlaceholderType?"link":"string")):"custom_text"!==s.value&&"custom_link"!==s.value?(Se(s.value,"url"===s.bikPlaceholderType?"link":"string"),ue==m.CHANNEL_TYPE.WEBPUSH&&(null==ke||ke(null!==(n=R.index)&&void 0!==n?n:0,s.value))):(Q(""),Se("",s.value))}function Ae(e,t){var l,a;Q(t);const i="custom_link"===(null==X?void 0:X.value)&&t?t.includes("https")?t:`https://${t}`:t;Se(i,"static_expiry"===e?"string":e),ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.RCS||null==Ve||Ve(null!==(l=R.index)&&void 0!==l?l:0,i,"custom_link"===e,e),ue===m.CHANNEL_TYPE.WEBPUSH&&(null==ke||ke(null!==(a=R.index)&&void 0!==a?a:0,i))}function Se(e,t,l){var a,n,s,o,u;const d="custom_link"===t?"link":"custom_text"===t?"string":t;if(ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.WEBPUSH&&ue!==m.CHANNEL_TYPE.RCS){const l=T.getVariableNameForEmailByIndex(q+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===oe?"template_html_mobile":"template_html_desktop"),n=ue===m.CHANNEL_TYPE.EMAIL?null===(a=null==i?void 0:i.contentWindow)||void 0===a?void 0:a.document.getElementById(l):document.getElementById(l);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:R.variableName);const s=re.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t));null==be||be(s)}if(ue===m.CHANNEL_TYPE.WEBPUSH){const t=re,l=t=>null==t?void 0:t.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)),a={BODY:"BODY"===M?l(t.body):t.body,TITLE:M===b.WEB_PUSH_COMPONENT_TYPE.TITLE.toUpperCase()?l(t.title):t.title};null==be||be((e=>Object.assign(Object.assign({},e),{title:a.TITLE,body:a.BODY,buttons:t.buttons})))}if(ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS){if(null!=xe&&xe>-1&&Ee){const l=Object.assign({},re).cards.map(((l,a)=>{var i,n,s;return"BODY"===M?Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((t,l)=>q===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"TITLE"===M?Object.assign(Object.assign({},l),{title:null===(n=l.title)||void 0===n?void 0:n.map(((t,l)=>q===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"BUTTONS"===M?Object.assign(Object.assign({},l),{buttons:null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===q?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==be||be((e=>Object.assign(Object.assign({},e),{cards:l}))))}const a=null!=xe&&xe>-1?re.cards[xe]:re;let r=a.body,c=a.title,p=a.header,v=a.buttons;if("BODY"===M?r=null===(n=a.body)||void 0===n?void 0:n.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"TITLE"===M?c=null===(s=null==a?void 0:a.title)||void 0===s?void 0:s.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"HEADER"===M?p=null===(o=a.header)||void 0===o?void 0:o.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"BUTTONS"===M&&(v=null===(u=a.buttons)||void 0===u?void 0:u.map(((a,i)=>i===q?Object.assign(Object.assign({},a),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===a.type?e:[e],queryParams:null!=l?l:[]}):a))),null!=xe&&xe>-1){const e=i.cloneDeep(re.cards);e[xe]={header:p,body:r,buttons:v,title:c},null==be||be((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==be||be((e=>Object.assign(Object.assign({},e),{header:p,body:r,buttons:v,title:c})))}}function Ve(e,t,l,a){var n,s,o,u,d,r,c,p,v,m,b,g;if(null!=xe&&xe>-1&&Ee){const s=Object.assign({},ce).components.map((l=>{var a;return isCarouselComponent(l.type)?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,i,n,s,o,u,d,r,c,p,v;if("BODY"===l.type&&"BODY"===M){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const a=[...null!==(o=null===(s=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:i})}return l}if("TITLE"===l.type&&"TITLE"===M){if(null===(d=null===(u=l.example)||void 0===u?void 0:u.title_text)||void 0===d?void 0:d[0]){const a=[...null!==(p=null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])&&void 0!==p?p:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{title_text:[a]});return Object.assign(Object.assign({},l),{example:i})}return l}if("BUTTONS"===l.type&&"BUTTONS"===M){const a=null===(v=l.buttons)||void 0===v?void 0:v.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return a?Object.assign(Object.assign({},l),{buttons:a}):l}return l}))})))}):l})),o=i.cloneDeep(ce);if(l){const l=null===(n=Object.assign({},ce).mapping.cards)||void 0===n?void 0:n.map(((l,i)=>{var n,s,o,u;if("BODY"===M)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});if("TITLE"===M)return Object.assign(Object.assign({},l),{title:null===(s=null==l?void 0:l.title)||void 0===s?void 0:s.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});if("BUTTONS"===M&&(null==l?void 0:l.buttons)){let n=-1,s=-1;return null===(o=ce.components[Pe].cards)||void 0===o||o[i].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(s=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(u=l.buttons)||void 0===u?void 0:u.map(((e,l)=>l===s?"custom_link"===a?"((customPlaceholderName))":t:e))})}return l}));o.mapping.cards=l}return o.components=s,void(null==ve||ve(o))}const O=null!=xe&&xe>-1?{components:null===(s=Object.assign({},ce).components[Pe].cards)||void 0===s?void 0:s[xe].components,mapping:null===(o=Object.assign({},ce).mapping.cards)||void 0===o?void 0:o[xe]}:Object.assign({},ce),j=null===(u=null==O?void 0:O.components)||void 0===u?void 0:u.map((l=>{var a,i,n,s,o,u,d,r,c,p,v,m,b,g,O,j;const x=Object.assign({},l);if("BODY"===l.type&&"BODY"===M&&(Array.isArray(null===(a=l.example)||void 0===a?void 0:a.body_text)||(null===(n=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===n?void 0:n[0]))){const l=[...null!==(u=null===(o=null===(s=x.example)||void 0===s?void 0:s.body_text)||void 0===o?void 0:o[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},x.example),{body_text:[l]});return Object.assign(Object.assign({},x),{example:a})}if("TITLE"===l.type&&"TITLE"===M){if(Array.isArray(null===(d=l.example)||void 0===d?void 0:d.title_text)||(null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])){const l=[...null!==(m=null===(v=null===(p=x.example)||void 0===p?void 0:p.title_text)||void 0===v?void 0:v[0])&&void 0!==m?m:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},x.example),{title_text:[l]});return Object.assign(Object.assign({},x),{example:a})}}else if("HEADER"===l.type&&"HEADER"===M){if(null===(b=l.example)||void 0===b?void 0:b.header_text){const l=[...null!==(O=null===(g=x.example)||void 0===g?void 0:g.header_text)&&void 0!==O?O:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},x.example),{header_text:l});return Object.assign(Object.assign({},x),{example:a})}}else{if("BUTTONS"===l.type&&"BUTTONS"===M){const a=null===(j=l.buttons)||void 0===j?void 0:j.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return a?Object.assign(Object.assign({},x),{buttons:a}):x}if("limited_time_offer"===l.type&&"limited_time_offer"===M)return Object.assign(Object.assign({},x),{example:Object.assign(Object.assign({},x.example),{limited_time_offer:t})})}return l}));if(O.components=j,l)if("BODY"===M&&(null===(d=null==O?void 0:O.mapping)||void 0===d?void 0:d.body))O.mapping=Object.assign(Object.assign({},O.mapping),{body:null===(c=null===(r=O.mapping)||void 0===r?void 0:r.body)||void 0===c?void 0:c.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("TITLE"===M&&(null===(p=null==O?void 0:O.mapping)||void 0===p?void 0:p.title))O.mapping=Object.assign(Object.assign({},O.mapping),{title:null===(m=null===(v=O.mapping)||void 0===v?void 0:v.title)||void 0===m?void 0:m.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===M&&(null===(b=null==O?void 0:O.mapping)||void 0===b?void 0:b.header))O.mapping=Object.assign(Object.assign({},O.mapping),{header:O.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===M&&(null===(g=null==O?void 0:O.mapping)||void 0===g?void 0:g.buttons)){let l=-1,i=-1;j.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),O.mapping=Object.assign(Object.assign({},O.mapping),{buttons:O.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}if(null!=xe&&xe>-1&&ce){const e=i.cloneDeep(ce);e.components[Pe].cards[xe].components=O.components,e.mapping.cards[xe]=O.mapping,null==ve||ve(e)}else null==ve||ve(Object.assign({},O))}n.useEffect((()=>{Z&&(null==U||U())}),[Z]),n.useEffect((()=>{!function(){var e,t,l,a,i;const n="mobile"===oe?"template_html_mobile":"template_html_desktop",s=document.getElementById(n),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==s?void 0:s.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);ue===m.CHANNEL_TYPE.EMAIL&&(null==me||me(o))}()}),[pe]),n.useEffect((()=>{!function(){var e,t;const l=[];let a=[];if(ue!==m.CHANNEL_TYPE.MESSAGE||Oe){"link"===(null==R?void 0:R.type)?(l.push({label:"",options:[L,A]}),ee(L)):"date_time"===(null==R?void 0:R.type)?(l.push({label:"",options:[L,A]}),ee(S)):(l.push({label:"",options:[L,A,S]}),ee(A));const e=null!=ge?ge:[];J([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:j.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ge?ge:[];J([{label:"",options:[A,L]},...e]),a=[{label:"",options:[A,L]},...e]}if((ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.EMAIL||ue===m.CHANNEL_TYPE.MESSAGE||ue===m.CHANNEL_TYPE.WEBPUSH||ue===m.CHANNEL_TYPE.RCS)&&R.updatedValue)if(v.placeHolderNamePattern.test(R.updatedValue)&&(ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS)||R.updatedValue.startsWith("{{")&&ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.RCS){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===(m.CHANNEL_TYPE.WHATSAPP||m.CHANNEL_TYPE.RCS)?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(I){let t=e.updatedValue;if(je===g.POD.CHATBOT&&"BUTTONS"===M){const l=null==$?void 0:$.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(R,a,ue);e.value&&ee(e)}else"date_time"===R.type?(ee(S),Q(R.updatedValue),Ve(null!==(e=R.index)&&void 0!==e?e:0,R.updatedValue)):(null===(t=R.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(ee(L),Q(R.updatedValue.split("https://")[1])):(ee(A),Q(R.updatedValue))}()}),[xe]),n.useEffect((()=>{oe&&X&&G&&setTimeout((()=>{Se("custom_link"===(null==X?void 0:X.value)&&G?G.includes("https")?G:`https://${G}`:G,X.value)}),100)}),[oe]),n.useEffect((()=>{!te&&X&&R.updatedValue&&setTimeout((()=>{Se("custom_link"===(null==X?void 0:X.value)&&R.updatedValue?R.updatedValue.includes("https")?R.updatedValue:`https://${R.updatedValue}`:R.updatedValue,X.value),le(!0)}),100)}),[X]);const He=e=>{null==W||W(!1),"{{custom.url}}"===e.actualValue?Le({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?Le({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?Le({label:e.displayName,selected:!0,value:"static_expiry"}):Le({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})};function ke(e,t){var l;const a=i.cloneDeep(ce),n=M.toLocaleLowerCase();(null===(l=a.webpushBroadcastConfig)||void 0===l?void 0:l[n])&&(a.webpushBroadcastConfig[n][e]=t),null==ve||ve(Object.assign({},a))}return e.jsxs(C,Object.assign({channel:ue,focused:Z,onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(O.BodySecondary,Object.assign({style:{color:de&&!X?x.COLORS.content.negative:x.COLORS.content.primary}},{children:[null===(h=R.variableName)||void 0===h?void 0:h.replace("{{","").replace("}}","")," ","link"===(null==R?void 0:R.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:I?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==X?void 0:X.label)?"space-between":"flex-end"}},{children:[e.jsx(O.BodyPrimary,Object.assign({numberOfLines:1},{children:je===g.POD.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(f=null==X?void 0:X.value)&&void 0!==f?f:"")?null==X?void 0:X.label:null==X?void 0:X.value:p.truncate(null!==(V=null==X?void 0:X.label)&&void 0!==V?V:"",20,!0)})),Te||"date_time"===(null==R?void 0:R.type)&&_e?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{(()=>{if(z===g.BUTTON_TYPE.URL&&je===g.POD.CHATBOT){const e=y.updateVariables({variableList:ae,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom URL",variableValue:"{{custom.url}}"});ie(e)}else if("limited_time_offer"===M){const e=y.updateVariables({variableList:ae,categoryDisplayName:"Static Variables",variableDisplayName:"Static Expiry",variableValue:"{{static.expiry}}"});ie(e)}else if(z===g.BUTTON_TYPE.COPY_CODE){const e=y.updateVariables({variableList:ae,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});ie(e)}})(),ne((()=>He)),se(!0)},width:24,height:24,color:x.COLORS.content.primary})]})):e.jsx(r.Dropdown,{disabled:Te,options:K,isSearchable:!1,onSelect:Le,defaultOptions:X?[Object.assign(Object.assign({},X),{selected:!0})]:[]})})),("custom_text"===(null==X?void 0:X.value)||"custom_link"===(null==X?void 0:X.value))&&e.jsx(c.Input,{state:Te?"disabled":"none",labelText:"custom_text"===(null==X?void 0:X.value)?"Custom text value":"custom_link"===(null==X?void 0:X.value)?"Custom URL value":"",id:`variable-value-${null==X?void 0:X.value}-${q}`,value:G,errorMessage:de&&(null===(H=null==he?void 0:he.buttons)||void 0===H?void 0:H.includes(null!==(k=null==R?void 0:R.index)&&void 0!==k?k:-1))?G&&0!==G.trim().length?"custom_link"!==X.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${G.trim()}`)&&0!==G.trim().length?"custom_link"!==X.value&&G.length>30?"Length cannot be more than 30":"BUTTONS"===M&&"custom_link"!==X.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:fe||("custom_link"===(null==X?void 0:X.value)?2e3:"BUTTONS"===M?15:30),noKeyDownChange:!0,prefixText:"custom_link"===(null==X?void 0:X.value)?"https://":"",placeholder:"link"===R.type||"custom_link"===X.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{Ae(X.value,e)}}),"static_expiry"===(null==X?void 0:X.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[(Te||Ce)&&e.jsxs(N,Object.assign({onClick:e=>e.preventDefault(),style:{display:"flex",justifyContent:"space-between"}},{children:[e.jsx(P,{}),e.jsx(P,{})]})),e.jsx(d.CustomDateTime,{placement:"auto",time:G?a.format(new Date(G),"hh:mm a"):a.format(new Date,"hh:mm a"),date:G?new Date(G):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{Ae("static_expiry",e.toISOString())}})]})),"static_expiry"===(null==X?void 0:X.value)&&Ne&&e.jsx("div",Object.assign({style:{marginTop:8}},{children:e.jsx(o.Alert,{containerStyle:{padding:"4px 8px"},icon:()=>e.jsx(l.default,{width:16,height:16,color:x.COLORS.content.secondary}),type:u.ALERT_TYPES.NEUTRAL,text:"Please use the same expiration code that you applied when creating \nthe code on Shopify"})})),"link"===R.type&&"custom_link"!==(null==X?void 0:X.value)&&!Ee&&!ye&&je===g.POD.CHATBOT&&e.jsx(_.QueryParamsComponent,{isError:null!==(Y=null===(D=null==he?void 0:he.buttons)||void 0===D?void 0:D.includes(null!==(B=null==R?void 0:R.index)&&void 0!==B?B:-1))&&void 0!==Y&&Y,params:null!==(w=R.queryParams)&&void 0!==w?w:[],onChange:e=>{Se(R.updatedValue,"link",e)},variableValue:R.updatedValue})]}))};
19
+ `,L={value:"custom_link",label:"Custom URL"},A={value:"custom_text",label:"Custom text"},S={value:"static_expiry",label:"Static Expiry"};exports.Container=C,exports.default=s=>{var h,f,V,H,k,D,B,Y,w;const{onFocus:U,variable:R,index:q,showVariableModal:I,setShowDiscountCheckBox:W,componentType:M,CTAoptions:$,buttonType:z}=s,[Z,F]=n.useState(!1),[G,Q]=n.useState(""),[K,J]=n.useState([]),[X,ee]=n.useState(),[te,le]=n.useState(!1),{variableList:ae,setVariableList:ie,setVariableCallback:ne,setShowVariablePicker:se,device:oe,channel:ue,isError:de,originalVariableList:re,template:ce,templateSelectionTriggered:pe,setTemplate:ve,setDisplayContent:me,setOriginalVariableList:be,globalNormalizedPlaceholders:ge,enabledCustomText:Oe,pod:je,selectedCarouselIndex:xe,isProductCarouselType:ye,isWhatsappCarousel:Ee,disableEditVariable:Te,disableEditExpiry:_e,templateErrorIndexes:he,maxCharLimit:fe,disableDatePicker:Ce,showDiscountCodeExpiryInfo:Ne,cardIndex:Pe=1}=y.useTemplateModalContext();function Le(e,t){var l,a,i,n;const s=e;Q(""),ee(s),ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS?"custom_text"!==s.value&&"custom_link"!==s.value&&"static_expiry"!==s.value?(Se(null!==(l=s.value)&&void 0!==l?l:"","string"),null==Ve||Ve(null!==(a=R.index)&&void 0!==a?a:0,s.value,!0)):(null==Ve||Ve(null!==(i=R.index)&&void 0!==i?i:0,"",!0,s.value),Se("","url"===s.bikPlaceholderType?"link":"string")):"custom_text"!==s.value&&"custom_link"!==s.value?(Se(s.value,"url"===s.bikPlaceholderType?"link":"string"),ue==m.CHANNEL_TYPE.WEBPUSH&&(null==ke||ke(null!==(n=R.index)&&void 0!==n?n:0,s.value))):(Q(""),Se("",s.value))}function Ae(e,t){var l,a;Q(t);const i="custom_link"===(null==X?void 0:X.value)&&t?t.includes("https")?t:`https://${t}`:t;Se(i,"static_expiry"===e?"string":e),ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.RCS||null==Ve||Ve(null!==(l=R.index)&&void 0!==l?l:0,i,"custom_link"===e,e),ue===m.CHANNEL_TYPE.WEBPUSH&&(null==ke||ke(null!==(a=R.index)&&void 0!==a?a:0,i))}function Se(e,t,l){var a,n,s,o,u;const d="custom_link"===t?"link":"custom_text"===t?"string":t;if(ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.WEBPUSH&&ue!==m.CHANNEL_TYPE.RCS){const l=T.getVariableNameForEmailByIndex(q+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===oe?"template_html_mobile":"template_html_desktop"),n=ue===m.CHANNEL_TYPE.EMAIL?null===(a=null==i?void 0:i.contentWindow)||void 0===a?void 0:a.document.getElementById(l):document.getElementById(l);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:R.variableName);const s=re.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t));null==be||be(s)}if(ue===m.CHANNEL_TYPE.WEBPUSH){const t=re,l=t=>null==t?void 0:t.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)),a={BODY:"BODY"===M?l(t.body):t.body,TITLE:M===b.WEB_PUSH_COMPONENT_TYPE.TITLE.toUpperCase()?l(t.title):t.title};null==be||be((e=>Object.assign(Object.assign({},e),{title:a.TITLE,body:a.BODY,buttons:t.buttons})))}if(ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS){if(null!=xe&&xe>-1&&ye){const l=Object.assign({},re).cards.map(((l,a)=>{var i,n,s;return"BODY"===M?Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((t,l)=>q===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"TITLE"===M?Object.assign(Object.assign({},l),{title:null===(n=l.title)||void 0===n?void 0:n.map(((t,l)=>q===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"BUTTONS"===M?Object.assign(Object.assign({},l),{buttons:null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===q?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==be||be((e=>Object.assign(Object.assign({},e),{cards:l}))))}const a=null!=xe&&xe>-1?re.cards[xe]:re;let r=a.body,c=a.title,p=a.header,v=a.buttons;if("BODY"===M?r=null===(n=a.body)||void 0===n?void 0:n.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"TITLE"===M?c=null===(s=null==a?void 0:a.title)||void 0===s?void 0:s.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"HEADER"===M?p=null===(o=a.header)||void 0===o?void 0:o.map(((t,l)=>l===q?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"BUTTONS"===M&&(v=null===(u=a.buttons)||void 0===u?void 0:u.map(((a,i)=>i===q?Object.assign(Object.assign({},a),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===a.type?e:[e],queryParams:null!=l?l:[]}):a))),null!=xe&&xe>-1){const e=i.cloneDeep(re.cards);e[xe]={header:p,body:r,buttons:v,title:c},null==be||be((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==be||be((e=>Object.assign(Object.assign({},e),{header:p,body:r,buttons:v,title:c})))}}function Ve(e,t,l,a){var n,s,o,u,d,r,c,p,v,m,b,g;if(null!=xe&&xe>-1&&ye){const s=Object.assign({},ce).components.map((l=>{var a;return isCarouselComponent(l.type)?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,i,n,s,o,u,d,r,c,p,v;if("BODY"===l.type&&"BODY"===M){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const a=[...null!==(o=null===(s=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:i})}return l}if("TITLE"===l.type&&"TITLE"===M){if(null===(d=null===(u=l.example)||void 0===u?void 0:u.title_text)||void 0===d?void 0:d[0]){const a=[...null!==(p=null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])&&void 0!==p?p:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{title_text:[a]});return Object.assign(Object.assign({},l),{example:i})}return l}if("BUTTONS"===l.type&&"BUTTONS"===M){const a=null===(v=l.buttons)||void 0===v?void 0:v.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return a?Object.assign(Object.assign({},l),{buttons:a}):l}return l}))})))}):l})),o=i.cloneDeep(ce);if(l){const l=null===(n=Object.assign({},ce).mapping.cards)||void 0===n?void 0:n.map(((l,i)=>{var n,s,o,u;if("BODY"===M)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});if("TITLE"===M)return Object.assign(Object.assign({},l),{title:null===(s=null==l?void 0:l.title)||void 0===s?void 0:s.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});if("BUTTONS"===M&&(null==l?void 0:l.buttons)){let n=-1,s=-1;return null===(o=ce.components[Pe].cards)||void 0===o||o[i].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(s=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(u=l.buttons)||void 0===u?void 0:u.map(((e,l)=>l===s?"custom_link"===a?"((customPlaceholderName))":t:e))})}return l}));o.mapping.cards=l}return o.components=s,void(null==ve||ve(o))}const O=null!=xe&&xe>-1?{components:null===(s=Object.assign({},ce).components[Pe].cards)||void 0===s?void 0:s[xe].components,mapping:null===(o=Object.assign({},ce).mapping.cards)||void 0===o?void 0:o[xe]}:Object.assign({},ce),j=null===(u=null==O?void 0:O.components)||void 0===u?void 0:u.map((l=>{var a,i,n,s,o,u,d,r,c,p,v,m,b,g,O,j;const x=Object.assign({},l);if("BODY"===l.type&&"BODY"===M&&(Array.isArray(null===(a=l.example)||void 0===a?void 0:a.body_text)||(null===(n=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===n?void 0:n[0]))){const l=[...null!==(u=null===(o=null===(s=x.example)||void 0===s?void 0:s.body_text)||void 0===o?void 0:o[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},x.example),{body_text:[l]});return Object.assign(Object.assign({},x),{example:a})}if("TITLE"===l.type&&"TITLE"===M){if(Array.isArray(null===(d=l.example)||void 0===d?void 0:d.title_text)||(null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])){const l=[...null!==(m=null===(v=null===(p=x.example)||void 0===p?void 0:p.title_text)||void 0===v?void 0:v[0])&&void 0!==m?m:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},x.example),{title_text:[l]});return Object.assign(Object.assign({},x),{example:a})}}else if("HEADER"===l.type&&"HEADER"===M){if(null===(b=l.example)||void 0===b?void 0:b.header_text){const l=[...null!==(O=null===(g=x.example)||void 0===g?void 0:g.header_text)&&void 0!==O?O:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},x.example),{header_text:l});return Object.assign(Object.assign({},x),{example:a})}}else{if("BUTTONS"===l.type&&"BUTTONS"===M){const a=null===(j=l.buttons)||void 0===j?void 0:j.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return a?Object.assign(Object.assign({},x),{buttons:a}):x}if("limited_time_offer"===l.type&&"limited_time_offer"===M)return Object.assign(Object.assign({},x),{example:Object.assign(Object.assign({},x.example),{limited_time_offer:t})})}return l}));if(O.components=j,l)if("BODY"===M&&(null===(d=null==O?void 0:O.mapping)||void 0===d?void 0:d.body))O.mapping=Object.assign(Object.assign({},O.mapping),{body:null===(c=null===(r=O.mapping)||void 0===r?void 0:r.body)||void 0===c?void 0:c.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("TITLE"===M&&(null===(p=null==O?void 0:O.mapping)||void 0===p?void 0:p.title))O.mapping=Object.assign(Object.assign({},O.mapping),{title:null===(m=null===(v=O.mapping)||void 0===v?void 0:v.title)||void 0===m?void 0:m.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===M&&(null===(b=null==O?void 0:O.mapping)||void 0===b?void 0:b.header))O.mapping=Object.assign(Object.assign({},O.mapping),{header:O.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===M&&(null===(g=null==O?void 0:O.mapping)||void 0===g?void 0:g.buttons)){let l=-1,i=-1;j.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),O.mapping=Object.assign(Object.assign({},O.mapping),{buttons:O.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}if(null!=xe&&xe>-1&&ce){const e=i.cloneDeep(ce);e.components[Pe].cards[xe].components=O.components,e.mapping.cards[xe]=O.mapping,null==ve||ve(e)}else null==ve||ve(Object.assign({},O))}n.useEffect((()=>{Z&&(null==U||U())}),[Z]),n.useEffect((()=>{!function(){var e,t,l,a,i;const n="mobile"===oe?"template_html_mobile":"template_html_desktop",s=document.getElementById(n),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==s?void 0:s.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);ue===m.CHANNEL_TYPE.EMAIL&&(null==me||me(o))}()}),[pe]),n.useEffect((()=>{!function(){var e,t;const l=[];let a=[];if(ue!==m.CHANNEL_TYPE.MESSAGE||Oe){"link"===(null==R?void 0:R.type)?(l.push({label:"",options:[L,A]}),ee(L)):"date_time"===(null==R?void 0:R.type)?(l.push({label:"",options:[L,A]}),ee(S)):(l.push({label:"",options:[L,A,S]}),ee(A));const e=null!=ge?ge:[];J([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:j.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=ge?ge:[];J([{label:"",options:[A,L]},...e]),a=[{label:"",options:[A,L]},...e]}if((ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.EMAIL||ue===m.CHANNEL_TYPE.MESSAGE||ue===m.CHANNEL_TYPE.WEBPUSH||ue===m.CHANNEL_TYPE.RCS)&&R.updatedValue)if(v.placeHolderNamePattern.test(R.updatedValue)&&(ue===m.CHANNEL_TYPE.WHATSAPP||ue===m.CHANNEL_TYPE.RCS)||R.updatedValue.startsWith("{{")&&ue!==m.CHANNEL_TYPE.WHATSAPP&&ue!==m.CHANNEL_TYPE.RCS){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===(m.CHANNEL_TYPE.WHATSAPP||m.CHANNEL_TYPE.RCS)?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(I){let t=e.updatedValue;if(je===g.POD.CHATBOT&&"BUTTONS"===M){const l=null==$?void 0:$.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(R,a,ue);e.value&&ee(e)}else"date_time"===R.type?(ee(S),Q(R.updatedValue),Ve(null!==(e=R.index)&&void 0!==e?e:0,R.updatedValue)):(null===(t=R.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(ee(L),Q(R.updatedValue.split("https://")[1])):(ee(A),Q(R.updatedValue))}()}),[xe]),n.useEffect((()=>{oe&&X&&G&&setTimeout((()=>{Se("custom_link"===(null==X?void 0:X.value)&&G?G.includes("https")?G:`https://${G}`:G,X.value)}),100)}),[oe]),n.useEffect((()=>{!te&&X&&R.updatedValue&&setTimeout((()=>{Se("custom_link"===(null==X?void 0:X.value)&&R.updatedValue?R.updatedValue.includes("https")?R.updatedValue:`https://${R.updatedValue}`:R.updatedValue,X.value),le(!0)}),100)}),[X]);const He=e=>{null==W||W(!1),"{{custom.url}}"===e.actualValue?Le({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?Le({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?Le({label:e.displayName,selected:!0,value:"static_expiry"}):Le({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})};function ke(e,t){var l;const a=i.cloneDeep(ce),n=M.toLocaleLowerCase();(null===(l=a.webpushBroadcastConfig)||void 0===l?void 0:l[n])&&(a.webpushBroadcastConfig[n][e]=t),null==ve||ve(Object.assign({},a))}return e.jsxs(C,Object.assign({channel:ue,focused:Z,onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(O.BodySecondary,Object.assign({style:{color:de&&!X?x.COLORS.content.negative:x.COLORS.content.primary}},{children:[null===(h=R.variableName)||void 0===h?void 0:h.replace("{{","").replace("}}","")," ","link"===(null==R?void 0:R.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:I?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==X?void 0:X.label)?"space-between":"flex-end",backgroundColor:"date_time"===(null==R?void 0:R.type)&&_e?x.COLORS.background.base:void 0}},{children:[e.jsx(O.BodyPrimary,Object.assign({numberOfLines:1},{children:je===g.POD.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(f=null==X?void 0:X.value)&&void 0!==f?f:"")?null==X?void 0:X.label:null==X?void 0:X.value:p.truncate(null!==(V=null==X?void 0:X.label)&&void 0!==V?V:"",20,!0)})),Te||"date_time"===(null==R?void 0:R.type)&&_e?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{(()=>{if(z===g.BUTTON_TYPE.URL&&je===g.POD.CHATBOT){const e=E.updateVariables({variableList:ae,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom URL",variableValue:"{{custom.url}}"});ie(e)}else if("limited_time_offer"===M){const e=E.updateVariables({variableList:ae,categoryDisplayName:"Static Variables",variableDisplayName:"Static Expiry",variableValue:"{{static.expiry}}"});ie(e)}else if(z===g.BUTTON_TYPE.COPY_CODE){const e=E.updateVariables({variableList:ae,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});ie(e)}})(),ne((()=>He)),se(!0)},width:24,height:24,color:x.COLORS.content.primary})]})):e.jsx(r.Dropdown,{disabled:Te,options:K,isSearchable:!1,onSelect:Le,defaultOptions:X?[Object.assign(Object.assign({},X),{selected:!0})]:[]})})),("custom_text"===(null==X?void 0:X.value)||"custom_link"===(null==X?void 0:X.value))&&e.jsx(c.Input,{state:Te?"disabled":"none",labelText:"custom_text"===(null==X?void 0:X.value)?"Custom text value":"custom_link"===(null==X?void 0:X.value)?"Custom URL value":"",id:`variable-value-${null==X?void 0:X.value}-${q}`,value:G,errorMessage:de&&(null===(H=null==he?void 0:he.buttons)||void 0===H?void 0:H.includes(null!==(k=null==R?void 0:R.index)&&void 0!==k?k:-1))?G&&0!==G.trim().length?"custom_link"!==X.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${G.trim()}`)&&0!==G.trim().length?"custom_link"!==X.value&&G.length>30?"Length cannot be more than 30":"BUTTONS"===M&&"custom_link"!==X.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:fe||("custom_link"===(null==X?void 0:X.value)?2e3:"BUTTONS"===M?15:30),noKeyDownChange:!0,prefixText:"custom_link"===(null==X?void 0:X.value)?"https://":"",placeholder:"link"===R.type||"custom_link"===X.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{Ae(X.value,e)}}),"static_expiry"===(null==X?void 0:X.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[(Te||Ce)&&e.jsxs(N,Object.assign({onClick:e=>e.preventDefault(),style:{display:"flex",justifyContent:"space-between"}},{children:[e.jsx(P,{}),e.jsx(P,{})]})),e.jsx(d.CustomDateTime,{placement:"auto",time:G?a.format(new Date(G),"hh:mm a"):a.format(new Date,"hh:mm a"),date:G?new Date(G):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{Ae("static_expiry",e.toISOString())}})]})),"static_expiry"===(null==X?void 0:X.value)&&Ne&&e.jsx("div",Object.assign({style:{marginTop:8}},{children:e.jsx(o.Alert,{containerStyle:{padding:"4px 8px"},icon:()=>e.jsx(l.default,{width:16,height:16,color:x.COLORS.content.secondary}),type:u.ALERT_TYPES.NEUTRAL,text:"Please use the same expiration code that you applied when creating\nthe code on Shopify"})})),"link"===R.type&&"custom_link"!==(null==X?void 0:X.value)&&!ye&&!Ee&&je===g.POD.CHATBOT&&e.jsx(_.QueryParamsComponent,{isError:null!==(Y=null===(D=null==he?void 0:he.buttons)||void 0===D?void 0:D.includes(null!==(B=null==R?void 0:R.index)&&void 0!==B?B:-1))&&void 0!==Y&&Y,params:null!==(w=R.queryParams)&&void 0!==w?w:[],onChange:e=>{Se(R.updatedValue,"link",e)},variableValue:R.updatedValue})]}))};
@@ -0,0 +1 @@
1
+ "use strict";var e,i,p=require("../../../../../_virtual/bik-store.js");e=p.__exports,Object.defineProperty(e,"__esModule",{value:!0}),e.ApplicationType=void 0,(i=e.ApplicationType||(e.ApplicationType={})).BIK="BIK",i.MANIFEST="MANIFEST",i.BSP="BSP";
@@ -0,0 +1 @@
1
+ var r={};export{r as __exports};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -1,3 +1,4 @@
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
1
2
  import React from 'react';
2
3
  import { Collection, CollectionFetcherReturn, SelectedItems } from '.';
3
4
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
@@ -9,7 +10,7 @@ interface CollectionsScreenInterface {
9
10
  [key: string]: Collection;
10
11
  };
11
12
  selectedCollections: SelectedItems;
12
- collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
13
+ collectionFetcher: (offset: number, storeId: string, appType: ApplicationType) => CollectionFetcherReturn;
13
14
  storeId: string;
14
15
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
15
16
  setCollectionId: React.Dispatch<React.SetStateAction<string>>;
@@ -25,6 +26,7 @@ interface CollectionsScreenInterface {
25
26
  renderWithoutModal?: boolean;
26
27
  pickerType?: 'COLLECTION' | 'PRODUCT';
27
28
  scrollContainerRef: React.RefObject<HTMLDivElement>;
29
+ appType: ApplicationType;
28
30
  }
29
31
  export declare const CollectionsScreen: (props: CollectionsScreenInterface) => import("react/jsx-runtime").JSX.Element;
30
32
  export interface CollectionCardInterface {
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as l,useState as c,useEffect as n}from"react";import{CheckBox as r}from"../checkBox/CheckBox.js";import{IconButton as s}from"../icon-button/IconButton.js";import{Tag as d}from"../tag/Tag.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{TitleRegular as u,BodyPrimary as h}from"../TypographyStyle.js";import{EmptyState as p}from"./emptyState.js";import{ProductPickerShimmer as m}from"./ProductPickerShimmer.js";import{CollectionCardStyle as C,CollectionCardInfoStyle as v,CollectionCardDetailStyle as g,CollectionNameHolder as y}from"./style.js";import{isCollectionPartiallyChecked as f}from"./utility.js";const b=(e,t,o)=>{if(!e)return"";if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},k=o=>{var i;const{customCollectionRestriction:r,dataLoading:s,collections:d,selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,selectedCollections:C,setScreen:v,collectionFetcher:g,collectionsDispatch:y,pagingControls:b,storeId:k,setSaveDisabled:O,hideCollectionCheckbox:I,renderWithoutModal:S,pickerType:P,scrollContainerRef:T}=o,x=l(b.curPage),D=!!r&&(null==C?void 0:C.isCustom),[L,R]=c(!1),E=l(!1),w=l(!1),B=()=>{if(!T||!(null==T?void 0:T.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:o}=T.current;e+t>=o-20&&!E.current&&!w.current&&(O(!0),R(!0),w.current=!0,O(!0),R(!0),g(x.current,k).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),b.setCurPage(x.current+1),R(!1),O(!1),w.current=!1,Object.keys(null==e?void 0:e.collections).length||(E.current=!0)})).catch())};return n((()=>{var e;return null===(e=null==T?void 0:T.current)||void 0===e||e.addEventListener("scroll",B),()=>{var e;null===(e=null==T?void 0:T.current)||void 0===e||e.removeEventListener("scroll",B)}}),[]),n((()=>{x.current=b.curPage}),[b.curPage]),e("div",{children:[(null===(i=Object.keys(null!=d?d:{}))||void 0===i?void 0:i.length)?Object.keys(d).map((e=>{var o,i;const l=!!(null==C?void 0:C[e])&&("PRODUCT"!==P||!!Object.keys(null!==(i=null===(o=null==C?void 0:C[e])||void 0===o?void 0:o.products)&&void 0!==i?i:{}).length);return t(j,{customCollectionRestriction:r,data:d[e],isDisabled:D&&!(null==C?void 0:C[e]),isChecked:l,isPartiallyChecked:f(e,null==d?void 0:d[e],C),selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,setScreen:v,id:e,hideCollectionCheckbox:I||"-1"===e,selectedCollections:C,renderWithoutModal:S,pickerType:P},e)})):s?t(m,{}):t(p,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),L&&t(m,{})]})},j=l=>{const{customCollectionRestriction:c,data:n,selectedCollectionsDispatch:p,setCollectionId:m,setSelectedCollectionId:f,isPartiallyChecked:b,setScreen:k,id:j,isChecked:O,isDisabled:I,hideCollectionCheckbox:S,pickerType:P,usedInSearch:T}=l;return n?e(C,Object.assign({isDisabled:I,onClick:e=>{if(!I){if("COLLECTION"===P)return e.stopPropagation(),p({type:"reset",data:{}}),p({type:"selected",data:{id:j,val:n,isRestricted:c}}),m(j),void f(j);m(j),f(j),k("products")}},isActive:O,usedInSearch:null!=T&&T},{children:[e(v,{children:[!S&&t(r,{isDisabled:I,isChecked:O,isPartiallyChecked:b,onValueChange:function(e,t,o){null==o||o.stopPropagation(),p(e?{type:"selected",data:{id:j,val:n,isRestricted:c}}:{type:"unselected",data:{id:j}}),f(e?j:"")}}),t(g,{children:t(a,Object.assign({body:n.name,placement:"bottom",delay:400,variant:"light"},{children:e(y,{children:[t(T?h:u,Object.assign({numberOfLines:1},{children:n.name})),n.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(d,{tagText:"Smart Collection",type:"warning"})})):t(o,{})]})}))})]}),"COLLECTION"!==P&&t(s,{height:12,width:12,disabled:I,Icon:i})]})):t(o,{})};export{j as CollectionCard,k as CollectionsScreen,b as truncate};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as l,useState as c,useEffect as n}from"react";import{CheckBox as r}from"../checkBox/CheckBox.js";import{IconButton as s}from"../icon-button/IconButton.js";import{Tag as d}from"../tag/Tag.js";import{Tooltip as a}from"../tooltips/Tooltip.js";import{TitleRegular as u,BodyPrimary as h}from"../TypographyStyle.js";import{EmptyState as p}from"./emptyState.js";import{ProductPickerShimmer as m}from"./ProductPickerShimmer.js";import{CollectionCardStyle as C,CollectionCardInfoStyle as v,CollectionCardDetailStyle as g,CollectionNameHolder as y}from"./style.js";import{isCollectionPartiallyChecked as f}from"./utility.js";const b=(e,t,o)=>{if(!e)return"";if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},k=o=>{var i;const{customCollectionRestriction:r,dataLoading:s,collections:d,selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,selectedCollections:C,setScreen:v,collectionFetcher:g,collectionsDispatch:y,pagingControls:b,storeId:k,setSaveDisabled:O,hideCollectionCheckbox:I,renderWithoutModal:S,pickerType:P,scrollContainerRef:T,appType:x}=o,D=l(b.curPage),L=!!r&&(null==C?void 0:C.isCustom),[R,E]=c(!1),w=l(!1),B=l(!1),N=()=>{if(!T||!(null==T?void 0:T.current))return;const{scrollTop:e,clientHeight:t,scrollHeight:o}=T.current;e+t>=o-20&&!w.current&&!B.current&&(O(!0),E(!0),B.current=!0,O(!0),E(!0),g(D.current,k,x).then((e=>{y({type:"paged",data:(null==e?void 0:e.collections)||{}}),b.setCurPage(D.current+1),E(!1),O(!1),B.current=!1,Object.keys(null==e?void 0:e.collections).length||(w.current=!0)})).catch())};return n((()=>{var e;return null===(e=null==T?void 0:T.current)||void 0===e||e.addEventListener("scroll",N),()=>{var e;null===(e=null==T?void 0:T.current)||void 0===e||e.removeEventListener("scroll",N)}}),[]),n((()=>{D.current=b.curPage}),[b.curPage]),e("div",{children:[(null===(i=Object.keys(null!=d?d:{}))||void 0===i?void 0:i.length)?Object.keys(d).map((e=>{var o,i;const l=!!(null==C?void 0:C[e])&&("PRODUCT"!==P||!!Object.keys(null!==(i=null===(o=null==C?void 0:C[e])||void 0===o?void 0:o.products)&&void 0!==i?i:{}).length);return t(j,{customCollectionRestriction:r,data:d[e],isDisabled:L&&!(null==C?void 0:C[e]),isChecked:l,isPartiallyChecked:f(e,null==d?void 0:d[e],C),selectedCollectionsDispatch:a,setCollectionId:u,setSelectedCollectionId:h,setScreen:v,id:e,hideCollectionCheckbox:I||"-1"===e,selectedCollections:C,renderWithoutModal:S,pickerType:P},e)})):s?t(m,{}):t(p,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),R&&t(m,{})]})},j=l=>{const{customCollectionRestriction:c,data:n,selectedCollectionsDispatch:p,setCollectionId:m,setSelectedCollectionId:f,isPartiallyChecked:b,setScreen:k,id:j,isChecked:O,isDisabled:I,hideCollectionCheckbox:S,pickerType:P,usedInSearch:T}=l;return n?e(C,Object.assign({isDisabled:I,onClick:e=>{if(!I){if("COLLECTION"===P)return e.stopPropagation(),p({type:"reset",data:{}}),p({type:"selected",data:{id:j,val:n,isRestricted:c}}),m(j),void f(j);m(j),f(j),k("products")}},isActive:O,usedInSearch:null!=T&&T},{children:[e(v,{children:[!S&&t(r,{isDisabled:I,isChecked:O,isPartiallyChecked:b,onValueChange:function(e,t,o){null==o||o.stopPropagation(),p(e?{type:"selected",data:{id:j,val:n,isRestricted:c}}:{type:"unselected",data:{id:j}}),f(e?j:"")}}),t(g,{children:t(a,Object.assign({body:n.name,placement:"bottom",delay:400,variant:"light"},{children:e(y,{children:[t(T?h:u,Object.assign({numberOfLines:1},{children:n.name})),n.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(d,{tagText:"Smart Collection",type:"warning"})})):t(o,{})]})}))})]}),"COLLECTION"!==P&&t(s,{height:12,width:12,disabled:I,Icon:i})]})):t(o,{})};export{j as CollectionCard,k as CollectionsScreen,b as truncate};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
3
  import { ButtonProps } from '../button/model';
3
4
  import { FooterForNonModalI, OUT_OF_STOCK_ACTION } from './type';
4
5
  export interface ProductVariant {
@@ -67,12 +68,13 @@ export type ProductPickerInterface = {
67
68
  hideGlobalSearch?: boolean;
68
69
  hideInCollectionSearch?: boolean;
69
70
  customCollectionRestriction?: boolean;
70
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
71
- searchFetcher: (storeId: string, query: string) => Promise<SearchedItems | SelectedItems>;
72
- collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
73
- productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
74
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
71
+ searchInCollectionFetcher: (storeId: string, collectionId: string, query: string, appType: ApplicationType) => ProductFetcherReturn;
72
+ searchFetcher: (storeId: string, query: string, appType: ApplicationType) => Promise<SearchedItems | SelectedItems>;
73
+ collectionFetcher: (offset: number, storeId: string, appType: ApplicationType) => CollectionFetcherReturn;
74
+ productFetcher: (collectionId: string, storeId: string, appType: ApplicationType, limit?: number, offset?: number) => ProductFetcherReturn;
75
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
75
76
  storeId: string;
77
+ appType?: ApplicationType;
76
78
  selectedItems: SelectedItems;
77
79
  onAdd: (items: SelectedItems, total: number, secondaryClick?: boolean) => void;
78
80
  onClose?: () => void;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as i,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import d from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as u}from"../input/Input.js";import{StyledModal as h}from"../modals/styledModal.js";import{Spinner as p}from"../spinner/Spinner.js";import{Tag as m}from"../tag/Tag.js";import{CollectionsScreen as C}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as f}from"./productScreen.js";import{RearrangeScreen as y}from"./rearrangeScreen.js";import{collectionsReducer as b,searchReducer as S,selectedColectionsReducer as v,CollectionIdContext as k}from"./reducers.js";import{SearchScreen as j}from"./searchScreen.js";import{SelectedScreen as I}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as P,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";import{updateAllVariantsForSelectedProducts as F}from"./utility.js";var T;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(T||(T={}));const R=R=>{const{storeId:w,selectedItems:A,onClose:B,visible:E,zIndex:L,exactLimit:z,limit:V,hideCollectionCheckbox:$,hideProductCheckbox:M,outOfStockAction:H=D.BLUR,hideVariantCheckbox:W,selectProductsFromCustomCollection:G,hideSelectionCount:N,title:Y,width:K,left:U,renderWithoutModal:q,onClickSave:J,pickerType:Q,hideProductVariants:X=!1,startupScreen:Z=T.Collections,rearrangeEnabled:_,selectSingleItem:ee=!1,showProductDetails:te,containerStyle:oe,crossButtonInsideHeader:ce=!1,footerForNonModal:re={},primaryButton:se,secondaryButton:ie,subtitle:ne}=R,[le,de]=r(b,{}),[ae,ue]=s([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections),[he,pe]=s("grid"),[me,Ce]=s(""),[ge,fe]=s(""),[ye,be]=s(0),[Se,ve]=s(!1),[ke,je]=s(0),[Ie,xe]=s(""),[Pe,Oe]=s(!1),[De,Fe]=s(!1),[Te,Re]=r(S,{collections:{},products:{}}),[we,Ae]=r(v,Object.keys(A).length>0?A:{}),Be=i(null),[Ee,Le]=s(!1),[ze,Ve]=s();n((()=>{ve(!0),Fe(!0),R.collectionFetcher(ye,w).then((e=>{de({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ve(!1),be((e=>e+1)),Fe(!1)})).catch()}),[]),n((()=>{let e=0;X?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,r;Object.keys((null===(r=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),je(e)}),[le,we,X]),n((()=>{ge&&(ve(!0),R.productFetcher(ge,w).then((e=>{Object.keys(e).length&&de({type:"productsFetched",data:{collectionId:ge,products:e}}),ve(!1)})).catch())}),[ge]),n((()=>{const e=setTimeout((()=>{"rearrange"!==ae&&(Ie.length||"collections"!==ae)&&(Ie.length?(Oe(!0),R.searchFetcher(w,Ie).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),de({type:"searched",data:e.collections})):(Re({type:"set",data:{collections:{},products:e}}),de({type:"searched",data:e})),ue("searchProducts"),ve(!1),Oe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[Ie]),n((()=>{J&&(R.onAdd(we,ke),$e())}),[J]),n((()=>{ee&&Object.keys(we||{}).length&&ke&&(R.onAdd(we,ke),$e())}),[ee,we,ke]);const $e=()=>{Ae({type:"reset",data:{}})},Me=()=>z&&ke>z?t(m,{tagText:`You can only select ${z} products`,type:"negative"}):V&&ke>V?t(m,{tagText:`You can only select ${V} products`,type:"negative"}):t(a,ke>0?{onClick:()=>{ue(_?T.RearrangeProducts:T.SelectedProducts)},buttonText:z?`${ke}/${z} products selected`:`${ke} products selected`,buttonType:["rearrange","view"].includes(ae)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ae)}:{disabled:!0,buttonText:z?`${ke}/${z} products selected`:`${ke} products selected`,buttonType:"tertiaryGray"}),He=e=>Se?"Loading...":ae===T.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e(x,Object.assign({style:null!=oe?oe:{}},{children:[R.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&t(o,{children:("collections"===ae||"searchProducts"===ae)&&t("div",Object.assign({style:{padding:q?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search for collections and products, or type a product ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Pe?t(p,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:Ie,onChangeText:e=>{e.length&&e.trim().length?xe(e):xe("")}})}))}),e(P,Object.assign({ref:Be,screenName:ae},{children:["collections"===ae&&t(C,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:De,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:Ce,setSelectedCollectionId:fe,setScreen:ue,selectedCollections:we,collectionFetcher:R.collectionFetcher,storeId:w,collectionsDispatch:de,setSaveDisabled:ve,pagingControls:{curPage:ye,setCurPage:be},hideCollectionCheckbox:$,renderWithoutModal:q,pickerType:Q,scrollContainerRef:Be}),"products"===ae&&me&&t(k.Provider,Object.assign({value:me},{children:t(f,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:ue,storeId:w,data:le[me],collectionsDispatch:de,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:ve,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:M,outOfStockAction:H,hideVariantCheckbox:W,selectProductsFromCustomCollection:G,renderWithoutModal:q,pickerType:Q,hideProductVariants:X,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:te,scrollContainerRef:Be})})),"view"===ae&&t(I,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:X,outOfStockAction:H,storeId:w,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===ae&&t(y,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:H,rearrangeViewType:"grid"===he?"list":"grid",scrollContainerRef:Be,storeId:w,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===ae&&t(j,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:we||{},searchedCollections:Te||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{xe(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:Q,hideProductCheckbox:M,hideProductVariants:X,hideVariantCheckbox:W,storeId:w,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:Ce,setSelectedCollectionId:fe,renderWithoutModal:q,hideCollectionCheckbox:$,outOfStockAction:H})]}))]}));return t(o,{children:q?e(o,{children:[We,re.renderFooter?e(O,{children:[Me(),t(a,{buttonText:He(re.primaryButtonText),disabled:!re.isLoading&&(Se||ke<1||z&&ke<z||!z&&V&&ke>V)||re.primaryButtonDisabled,isLoading:re.isLoading,onClick:()=>{R.onAdd(we,ke),$e(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}})]}):t(o,{}),Ee&&ze?t(g,{productData:ze,outOfStockAction:H,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):t(o,{})]}):e(h,Object.assign({zIndex:L,open:E,onClose:()=>{null==B||B(),$e()},headingTitle:Y||("collections"===ae||"products"===ae?"Select Products":"view"===ae?"Selected Products":"searchProducts"===ae?"Searched Results":"rearrange"===ae?"Rearrange Products":void 0),headingSubtitle:ne,footerShadow:!0,centralContainerStyles:{width:K||"600px",left:U||"auto"},headerRightCustomElement:ce?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:B},{children:t(d,{width:20,height:20,color:l.content.secondary})})):t(o,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(Se||ke<1||z&&ke<z||!z&&V&&ke>V)||e.disabled,onClick:()=>{R.onAdd(we,ke),$e(),ue([T.Collections,T.RearrangeProducts].includes(Z)?Z:T.Collections)}}))(se):{buttonText:He(),disabled:Se||ke<1||z&&ke<z||!z&&V&&ke>V||!1,onClick:()=>{R.onAdd(we,ke),$e()}},secondaryButton:ie?(e=>Object.assign(Object.assign({},e),{disabled:Se||ke<1||z&&ke<z||!z&&V&&ke>V||!1,onClick:()=>{const e=F(we,le,Te);R.onAdd(e,ke,!0)}}))(ie):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?t(o,{}):Me(),hideCrossButton:Ee||ce},{children:[We,Ee&&ze?t(g,{productData:ze,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:H,onClose:()=>{Le(!1)}}):t(o,{})]}))})};export{R as ProductPickerModal,T as ScreenName};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/models/bik-store.js";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as i,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import d from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as u}from"../input/Input.js";import{StyledModal as p}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as m}from"../tag/Tag.js";import{CollectionsScreen as C}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as y}from"./productScreen.js";import{RearrangeScreen as b}from"./rearrangeScreen.js";import{collectionsReducer as f,searchReducer as S,selectedColectionsReducer as k,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as j}from"./searchScreen.js";import{SelectedScreen as I}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as P,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as T}from"./type.js";import{updateAllVariantsForSelectedProducts as D}from"./utility.js";import{__exports as F}from"../../_virtual/bik-store.js";var R;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(R||(R={}));const w=w=>{const{storeId:A,selectedItems:B,onClose:E,visible:L,zIndex:z,exactLimit:V,limit:$,hideCollectionCheckbox:M,hideProductCheckbox:H,outOfStockAction:W=T.BLUR,hideVariantCheckbox:_,selectProductsFromCustomCollection:G,hideSelectionCount:K,title:N,width:Y,left:U,renderWithoutModal:q,onClickSave:J,pickerType:Q,hideProductVariants:X=!1,startupScreen:Z=R.Collections,rearrangeEnabled:ee,selectSingleItem:te=!1,showProductDetails:oe,containerStyle:ce,crossButtonInsideHeader:re=!1,footerForNonModal:se={},primaryButton:ie,secondaryButton:ne,subtitle:le}=w,de=w.appType||F.ApplicationType.BIK,[ae,ue]=r(f,{}),[pe,he]=s([R.Collections,R.RearrangeProducts].includes(Z)?Z:R.Collections),[me,Ce]=s("grid"),[ge,ye]=s(""),[be,fe]=s(""),[Se,ke]=s(0),[ve,je]=s(!1),[Ie,xe]=s(0),[Pe,Oe]=s(""),[Te,De]=s(!1),[Fe,Re]=s(!1),[we,Ae]=r(S,{collections:{},products:{}}),[Be,Ee]=r(k,Object.keys(B).length>0?B:{}),Le=i(null),[ze,Ve]=s(!1),[$e,Me]=s();n((()=>{je(!0),Re(!0),w.collectionFetcher(Se,A,de).then((e=>{ue({type:"fetched",data:(null==e?void 0:e.collections)||{}}),je(!1),ke((e=>e+1)),Re(!1)})).catch()}),[]),n((()=>{let e=0;X?Object.keys(Be||[]).forEach((t=>{var o;Object.keys((null===(o=Be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Be[-1]&&(null===(c=Be[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Be||[]).forEach((t=>{var o;Object.keys((null===(o=Be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Be[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),xe(e)}),[ae,Be,X]),n((()=>{be&&(je(!0),w.productFetcher(be,A,de).then((e=>{Object.keys(e).length&&ue({type:"productsFetched",data:{collectionId:be,products:e}}),je(!1)})).catch())}),[be]),n((()=>{const e=setTimeout((()=>{"rearrange"!==pe&&(Pe.length||"collections"!==pe)&&(Pe.length?(De(!0),w.searchFetcher(A,Pe,de).then((e=>{"collections"in e&&"products"in e?(Ae({type:"set",data:e}),ue({type:"searched",data:e.collections})):(Ae({type:"set",data:{collections:{},products:e}}),ue({type:"searched",data:e})),he("searchProducts"),je(!1),De(!1)}))):he("collections"))}),800);return()=>clearTimeout(e)}),[Pe]),n((()=>{J&&(w.onAdd(Be,Ie),He())}),[J]),n((()=>{te&&Object.keys(Be||{}).length&&Ie&&(w.onAdd(Be,Ie),He())}),[te,Be,Ie]);const He=()=>{Ee({type:"reset",data:{}})},We=()=>V&&Ie>V?t(m,{tagText:`You can only select ${V} products`,type:"negative"}):$&&Ie>$?t(m,{tagText:`You can only select ${$} products`,type:"negative"}):t(a,Ie>0?{onClick:()=>{he(ee?R.RearrangeProducts:R.SelectedProducts)},buttonText:V?`${Ie}/${V} products selected`:`${Ie} products selected`,buttonType:["rearrange","view"].includes(pe)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(pe)}:{disabled:!0,buttonText:V?`${Ie}/${V} products selected`:`${Ie} products selected`,buttonType:"tertiaryGray"}),_e=e=>ve?"Loading...":pe===R.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Ge=e(x,Object.assign({style:null!=ce?ce:{}},{children:[w.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:w.postHeader})),!w.hideGlobalSearch&&t(o,{children:("collections"===pe||"searchProducts"===pe)&&t("div",Object.assign({style:{padding:q?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search for collections and products, or type a product ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Te?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:Pe,onChangeText:e=>{e.length&&e.trim().length?Oe(e):Oe("")}})}))}),e(P,Object.assign({ref:Le,screenName:pe},{children:["collections"===pe&&t(C,{customCollectionRestriction:w.customCollectionRestriction,dataLoading:Fe,collections:ae,selectedCollectionsDispatch:Ee,setCollectionId:ye,setSelectedCollectionId:fe,setScreen:he,selectedCollections:Be,collectionFetcher:w.collectionFetcher,storeId:A,appType:de,collectionsDispatch:ue,setSaveDisabled:je,pagingControls:{curPage:Se,setCurPage:ke},hideCollectionCheckbox:M,renderWithoutModal:q,pickerType:Q,scrollContainerRef:Le}),"products"===pe&&ge&&t(v.Provider,Object.assign({value:ge},{children:t(y,{hideInCollectionSearch:w.hideInCollectionSearch,customCollectionRestriction:w.customCollectionRestriction,productFetcher:w.productFetcher,setScreen:he,storeId:A,appType:de,data:ae[ge],collectionsDispatch:ue,selectedCollectionsDispatch:Ee,selectedData:Be,setSaveDisabled:je,searchInCollectionFetcher:w.searchInCollectionFetcher,hideProductCheckbox:H,outOfStockAction:W,hideVariantCheckbox:_,selectProductsFromCustomCollection:G,renderWithoutModal:q,pickerType:Q,hideProductVariants:X,fbStatusFetcher:w.fbStatusFetcher,onProductDetailClick:e=>{Ve(!0),Me(e)},showProductDetailInfoIcon:oe,scrollContainerRef:Le})})),"view"===pe&&t(I,{selectedCollections:Be||{},selectedCollectionsDispatch:Ee,setScreen:he,collections:ae,hideProductVariants:X,outOfStockAction:W,storeId:A,appType:de,fbStatusFetcher:w.fbStatusFetcher}),"rearrange"===pe&&t(b,{selectedCollections:Be||{},selectedCollectionsDispatch:Ee,setScreen:he,outOfStockAction:W,rearrangeViewType:"grid"===me?"list":"grid",scrollContainerRef:Le,storeId:A,appType:de,fbStatusFetcher:w.fbStatusFetcher}),"searchProducts"===pe&&t(j,{customCollectionRestriction:w.customCollectionRestriction,selectedCollections:Be||{},searchedCollections:we||{},searchedCollectionsDispatch:Ae,selectedCollectionsDispatch:Ee,setScreen:he,collections:ae,onBackPress:()=>{Oe(""),Ae({type:"set",data:{collections:{},products:{}}})},pickerType:Q,hideProductCheckbox:H,hideProductVariants:X,hideVariantCheckbox:_,storeId:A,appType:de,fbStatusFetcher:w.fbStatusFetcher,setCollectionId:ye,setSelectedCollectionId:fe,renderWithoutModal:q,hideCollectionCheckbox:M,outOfStockAction:W})]}))]}));return t(o,{children:q?e(o,{children:[Ge,se.renderFooter?e(O,{children:[We(),t(a,{buttonText:_e(se.primaryButtonText),disabled:!se.isLoading&&(ve||Ie<1||V&&Ie<V||!V&&$&&Ie>$)||se.primaryButtonDisabled,isLoading:se.isLoading,onClick:()=>{w.onAdd(Be,Ie),He(),he([R.Collections,R.RearrangeProducts].includes(Z)?Z:R.Collections)}})]}):t(o,{}),ze&&$e?t(g,{productData:$e,outOfStockAction:W,useDynamicInfoImageSize:w.useDynamicInfoImageSize,onClose:()=>{Ve(!1)}}):t(o,{})]}):e(p,Object.assign({zIndex:z,open:L,onClose:()=>{null==E||E(),He()},headingTitle:N||("collections"===pe||"products"===pe?"Select Products":"view"===pe?"Selected Products":"searchProducts"===pe?"Searched Results":"rearrange"===pe?"Rearrange Products":void 0),headingSubtitle:le,footerShadow:!0,centralContainerStyles:{width:Y||"600px",left:U||"auto"},headerRightCustomElement:re?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:E},{children:t(d,{width:20,height:20,color:l.content.secondary})})):t(o,{}),footerContainerStyle:w.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:ie?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ve||Ie<1||V&&Ie<V||!V&&$&&Ie>$)||e.disabled,onClick:()=>{w.onAdd(Be,Ie),He(),he([R.Collections,R.RearrangeProducts].includes(Z)?Z:R.Collections)}}))(ie):{buttonText:_e(),disabled:ve||Ie<1||V&&Ie<V||!V&&$&&Ie>$||!1,onClick:()=>{w.onAdd(Be,Ie),He()}},secondaryButton:ne?(e=>Object.assign(Object.assign({},e),{disabled:ve||Ie<1||V&&Ie<V||!V&&$&&Ie>$||!1,onClick:()=>{const e=D(Be,ae);w.onAdd(e,Ie,!0)}}))(ne):void 0,wrapperStyle:w.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:K?t(o,{}):We(),hideCrossButton:ze||re},{children:[Ge,ze&&$e?t(g,{productData:$e,useDynamicInfoImageSize:w.useDynamicInfoImageSize,outOfStockAction:W,onClose:()=>{Ve(!1)}}):t(o,{})]}))})};export{w as ProductPickerModal,R as ScreenName};
@@ -1,3 +1,4 @@
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
1
2
  import React from 'react';
2
3
  import { Collection, FbStatusFetcherReturn, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
3
4
  import { CollectionsActions, SelectedCollectionsActions } from './reducers';
@@ -9,9 +10,10 @@ interface ProductsScreenInterface {
9
10
  collectionsDispatch: React.Dispatch<CollectionsActions>;
10
11
  selectedData: SelectedItems;
11
12
  selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
12
- searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
13
- productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
13
+ searchInCollectionFetcher: (storeId: string, collectionId: string, query: string, appType: ApplicationType) => ProductFetcherReturn;
14
+ productFetcher: (collectionId: string, storeId: string, appType: ApplicationType, limit?: number, offset?: number) => ProductFetcherReturn;
14
15
  storeId: string;
16
+ appType: ApplicationType;
15
17
  setScreen: React.Dispatch<React.SetStateAction<string>>;
16
18
  setSaveDisabled: React.Dispatch<React.SetStateAction<boolean>>;
17
19
  hideProductCheckbox?: boolean;
@@ -22,7 +24,7 @@ interface ProductsScreenInterface {
22
24
  pickerType?: 'COLLECTION' | 'PRODUCT';
23
25
  hideProductVariants?: boolean;
24
26
  showProductDetailInfoIcon?: boolean;
25
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
27
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
26
28
  onProductDetailClick: (productData: Product | ProductVariant) => void;
27
29
  scrollContainerRef: React.RefObject<HTMLDivElement>;
28
30
  }
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as i,useRef as s,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{InfiniteScroll as p}from"../InfiniteScroll/InfiniteScroll.js";import{Input as m}from"../input/Input.js";import{Spinner as g}from"../spinner/Spinner.js";import{BodyCaption as j,TitleRegular as f}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as b}from"./product.js";import{ProductPickerShimmer as y}from"./ProductPickerShimmer.js";import{CollectionIdContext as O}from"./reducers.js";import{ProductScreenHeader as k,ProductScreenCollectionCardStyle as C}from"./style.js";import{OUT_OF_STOCK_ACTION as P}from"./type.js";import{getVariantIdsToFetchAtProductLevel as I,markVariantsAsApprovedProductsLevel as D,isCollectionPartiallyChecked as S,isProductPartiallyChecked as x,liftTheStateUp as E}from"./utility.js";const R=R=>{var T,w;const{data:V,collectionsDispatch:A,selectedData:B,selectedCollectionsDispatch:F,productFetcher:J,storeId:M,setScreen:W,setSaveDisabled:z,hideInCollectionSearch:H,customCollectionRestriction:K,hideProductCheckbox:L,outOfStockAction:N=P.BLUR,hideVariantCheckbox:U=!1,selectProductsFromCustomCollection:_=!1,pickerType:q,hideProductVariants:G,fbStatusFetcher:Q,onProductDetailClick:X,showProductDetailInfoIcon:Y,scrollContainerRef:Z}=R,$=i(O),tt=s(0),et=s(!1),[ot,ct]=l(""),[rt,nt]=l(!1),[it,st]=l(V),lt=s(!0),dt=s(!1);d((()=>{if(lt.current)return void(lt.current=!1);const t=setTimeout((()=>{ot.length?(nt(!0),R.searchInCollectionFetcher(M,$,ot).then((t=>{const e=n(V);e.products=t,st(e);const o=I(null!=t?t:{});ut(o,null!=t?t:{},!0),z(!1),nt(!1)}))):st(V)}),800);return()=>clearTimeout(t)}),[ot]);d((()=>{var t,e,o,c;dt.current=!1,tt.current=Math.floor((null===(e=Object.keys(null!==(t=V.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=I(null!==(o=V.products)&&void 0!==o?o:{});ut(r,null!==(c=V.products)&&void 0!==c?c:{})}),[$]);const at=!!K&&V.isSmartCollection;d((()=>{(null==V?void 0:V.products)||ht(10)}),[]);const ut=(t,e,o)=>{Q||(o?D(e,A,$,it,st):D(e,A,$)),t.length>0&&Q&&Q(M,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,i;const s=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];s&&"REJECTED"===t[r]?s.fbStatus="REJECTED":s&&"APPROVED"===t[r]&&(s.fbStatus="APPROVED");const l=null===(i=null==c?void 0:c[o])||void 0===i?void 0:i.variants;l&&l[r]&&(l[r]=s)}))})),o?(st((t=>{const e=Object.assign({},t);return e.products=c,e})),A({type:"productsPaged",data:{collectionId:$,products:c}})):A({type:"productsPaged",data:{collectionId:$,products:c}})})).catch((t=>{o?D(e,A,$,it,st):D(e,A,$)}))},ht=t=>{z(!0),nt(!0),J($,M,t,0).then((e=>{if(Object.keys(e).length||(dt.current=!0),Object.keys(e).length){st(Object.assign(Object.assign({},it),{products:e}));const t=I(e);ut(t,e),tt.current=1}t||F({type:"selected",data:{id:$,val:Object.assign(Object.assign({},V),{products:e})}}),z(!1),nt(!1)})).catch()},pt=(t,e)=>{const o=E(e,V);F({type:t,data:Object.assign(Object.assign({},o),{isRestricted:K})})},mt=!!(null==B?void 0:B[$])&&!!Object.keys(null!==(w=null===(T=null==B?void 0:B[$])||void 0===T?void 0:T.products)&&void 0!==w?w:{}).length;return t("div",{children:[t(k,{children:[e(h,{Icon:o,height:16,onClick:()=>{W("collections")}}),e(j,Object.assign({style:{color:a.content.secondary}},{children:V.name}))]}),!H&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(m,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>rt&&ot.length?e(g,{size:"small",color:a.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:ot,onChangeText:t=>{t.length&&t.trim().length?ct(t):ct("")},placeholder:"Search for a product or type a product ID"})})),Object.keys((null==it?void 0:it.products)||[]).length>0&&!at&&!ot.length&&!L&&"-1"!==$&&t(C,{children:[e(u,{isChecked:mt,isPartiallyChecked:S($,it,B,G),onValueChange:function(t){t?ht():F({type:"unselected",data:{id:$}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(f,{children:"All Products"})]}),e(p,Object.assign({hasData:!(Object.keys((null==it?void 0:it.products)||[]).length<10)&&!!Object.keys((null==it?void 0:it.products)||[]).length,fetchMore:()=>(et.current=!0,J($,M,10,tt.current).then((t=>{let e=!1;if(Object.keys(t).length||(e=!0),Object.keys(t).length){const e=it;e.products=Object.assign(Object.assign({},it.products),t),st(Object.assign({},e));const o=I(t);ut(o,t)}return z(!1),et.current=!1,tt.current+=1,e}))),containerRef:Z},{children:Object.keys((null==it?void 0:it.products)||[]).length?Object.keys(it.products||[]).map((t=>e(b,{outOfStockAction:N,collectionId:$,isProductPartiallyChecked:x($,t,B,it,G),productId:t,data:it.products[t],selectedData:B,selectedCollectionsDispatch:F,viewOnly:!_&&!!at,upliftAdditions:pt,hideProductCheckbox:L,hideVariantCheckbox:U,hideProductVariants:G,pickerType:q,onProductDetailClick:X,showProductDetailInfoIcon:Y},t))):rt?e(y,{limit:10}):e(v,{title:"No products to show",subtitle:ot.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})}))]})};export{R as ProductsScreen};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as i,useRef as s,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{InfiniteScroll as p}from"../InfiniteScroll/InfiniteScroll.js";import{Input as m}from"../input/Input.js";import{Spinner as g}from"../spinner/Spinner.js";import{BodyCaption as j,TitleRegular as f}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as y}from"./product.js";import{ProductPickerShimmer as b}from"./ProductPickerShimmer.js";import{CollectionIdContext as O}from"./reducers.js";import{ProductScreenHeader as k,ProductScreenCollectionCardStyle as C}from"./style.js";import{OUT_OF_STOCK_ACTION as P}from"./type.js";import{getVariantIdsToFetchAtProductLevel as I,markVariantsAsApprovedProductsLevel as D,isCollectionPartiallyChecked as S,isProductPartiallyChecked as x,liftTheStateUp as E}from"./utility.js";const T=T=>{var R,w;const{data:V,collectionsDispatch:A,selectedData:B,selectedCollectionsDispatch:F,productFetcher:J,storeId:M,setScreen:W,setSaveDisabled:z,hideInCollectionSearch:H,customCollectionRestriction:K,hideProductCheckbox:L,outOfStockAction:N=P.BLUR,hideVariantCheckbox:U=!1,selectProductsFromCustomCollection:_=!1,pickerType:q,hideProductVariants:G,fbStatusFetcher:Q,onProductDetailClick:X,showProductDetailInfoIcon:Y,scrollContainerRef:Z,appType:$}=T,tt=i(O),et=s(0),ot=s(!1),[ct,rt]=l(""),[nt,it]=l(!1),[st,lt]=l(V),dt=s(!0),at=s(!1);d((()=>{if(dt.current)return void(dt.current=!1);const t=setTimeout((()=>{ct.length?(it(!0),T.searchInCollectionFetcher(M,tt,ct,$).then((t=>{const e=n(V);e.products=t,lt(e);const o=I(null!=t?t:{});ht(o,null!=t?t:{},!0),z(!1),it(!1)}))):lt(V)}),800);return()=>clearTimeout(t)}),[ct]);d((()=>{var t,e,o,c;at.current=!1,et.current=Math.floor((null===(e=Object.keys(null!==(t=V.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=I(null!==(o=V.products)&&void 0!==o?o:{});ht(r,null!==(c=V.products)&&void 0!==c?c:{})}),[tt]);const ut=!!K&&V.isSmartCollection;d((()=>{(null==V?void 0:V.products)||pt(10)}),[]);const ht=(t,e,o)=>{Q||(o?D(e,A,tt,st,lt):D(e,A,tt)),t.length>0&&Q&&Q(M,t,$).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,i;const s=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];s&&"REJECTED"===t[r]?s.fbStatus="REJECTED":s&&"APPROVED"===t[r]&&(s.fbStatus="APPROVED");const l=null===(i=null==c?void 0:c[o])||void 0===i?void 0:i.variants;l&&l[r]&&(l[r]=s)}))})),o?(lt((t=>{const e=Object.assign({},t);return e.products=c,e})),A({type:"productsPaged",data:{collectionId:tt,products:c}})):A({type:"productsPaged",data:{collectionId:tt,products:c}})})).catch((t=>{o?D(e,A,tt,st,lt):D(e,A,tt)}))},pt=t=>{z(!0),it(!0),J(tt,M,$,t,0).then((e=>{if(Object.keys(e).length||(at.current=!0),Object.keys(e).length){lt(Object.assign(Object.assign({},st),{products:e}));const t=I(e);ht(t,e),et.current=1}t||F({type:"selected",data:{id:tt,val:Object.assign(Object.assign({},V),{products:e})}}),z(!1),it(!1)})).catch()},mt=(t,e)=>{const o=E(e,V);F({type:t,data:Object.assign(Object.assign({},o),{isRestricted:K})})},gt=!!(null==B?void 0:B[tt])&&!!Object.keys(null!==(w=null===(R=null==B?void 0:B[tt])||void 0===R?void 0:R.products)&&void 0!==w?w:{}).length;return t("div",{children:[t(k,{children:[e(h,{Icon:o,height:16,onClick:()=>{W("collections")}}),e(j,Object.assign({style:{color:a.content.secondary}},{children:V.name}))]}),!H&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(m,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>nt&&ct.length?e(g,{size:"small",color:a.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:ct,onChangeText:t=>{t.length&&t.trim().length?rt(t):rt("")},placeholder:"Search for a product or type a product ID"})})),Object.keys((null==st?void 0:st.products)||[]).length>0&&!ut&&!ct.length&&!L&&"-1"!==tt&&t(C,{children:[e(u,{isChecked:gt,isPartiallyChecked:S(tt,st,B,G),onValueChange:function(t){t?pt():F({type:"unselected",data:{id:tt}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(f,{children:"All Products"})]}),e(p,Object.assign({hasData:!(Object.keys((null==st?void 0:st.products)||[]).length<10)&&!!Object.keys((null==st?void 0:st.products)||[]).length,fetchMore:()=>(ot.current=!0,J(tt,M,$,10,et.current).then((t=>{let e=!1;if(Object.keys(t).length||(e=!0),Object.keys(t).length){const e=st;e.products=Object.assign(Object.assign({},st.products),t),lt(Object.assign({},e));const o=I(t);ht(o,t)}return z(!1),ot.current=!1,et.current+=1,e}))),containerRef:Z},{children:Object.keys((null==st?void 0:st.products)||[]).length?Object.keys(st.products||[]).map((t=>e(y,{outOfStockAction:N,collectionId:tt,isProductPartiallyChecked:x(tt,t,B,st,G),productId:t,data:st.products[t],selectedData:B,selectedCollectionsDispatch:F,viewOnly:!_&&!!ut,upliftAdditions:mt,hideProductCheckbox:L,hideVariantCheckbox:U,hideProductVariants:G,pickerType:q,onProductDetailClick:X,showProductDetailInfoIcon:Y},t))):nt?e(b,{limit:10}):e(v,{title:"No products to show",subtitle:ct.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})}))]})};export{T as ProductsScreen};
@@ -1,3 +1,4 @@
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
1
2
  import React from 'react';
2
3
  import { FbStatusFetcherReturn, SelectedItems } from '.';
3
4
  import { SelectedCollectionsActions } from './reducers';
@@ -10,7 +11,8 @@ interface RearrangeScreenInterface {
10
11
  outOfStockAction?: OUT_OF_STOCK_ACTION;
11
12
  scrollContainerRef: React.RefObject<HTMLDivElement>;
12
13
  storeId: string;
13
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
14
+ appType: ApplicationType;
15
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
14
16
  }
15
17
  /**
16
18
  * Screen will be opened on two conditions -
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useState as r,useEffect as s}from"react";import{DragDropContext as c}from"react-beautiful-dnd";import{COLORS as i}from"../../constants/Theme.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as a}from"./emptyState.js";import{parseSelectedVariantsToArray as d}from"./helpers/ProductHelper.js";import{SelectedScreenHeader as p}from"./style.js";import{fetchFbStatusCollection as m}from"./utility.js";import{VariantsList as u,VariantsGrid as f}from"./variantComponents.js";const h=h=>{const{selectedCollections:j,selectedCollectionsDispatch:y,setScreen:S,rearrangeViewType:g,outOfStockAction:b,scrollContainerRef:C,storeId:O,fbStatusFetcher:v}=h,[V,k]=r(d(j));s((()=>{k(d(j))}),[j]),s((()=>{var t;null===(t=null==C?void 0:C.current)||void 0===t||t.scrollTo({top:0}),m(j,O,y,v,"update")}),[]);return t(c,Object.assign({onDragEnd:t=>{if(!t.destination)return;const e=V,[o]=e.splice(t.source.index,1);e.splice(t.destination.index,0,o),e.forEach(((t,e)=>{t.displayOrder=e})),k(e)}},{children:[t(p,{children:[e(n,{Icon:o,width:16,height:16,color:i.content.secondary,onClick:()=>{S("collections")}}),e(l,Object.assign({color:i.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===g?e(u,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y,outOfStockAction:b}):e(f,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y}):e(a,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};export{h as RearrangeScreen};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useState as r,useEffect as s}from"react";import{DragDropContext as c}from"react-beautiful-dnd";import{COLORS as i}from"../../constants/Theme.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as a}from"./emptyState.js";import{parseSelectedVariantsToArray as p}from"./helpers/ProductHelper.js";import{SelectedScreenHeader as d}from"./style.js";import{fetchFbStatusCollection as m}from"./utility.js";import{VariantsList as u,VariantsGrid as f}from"./variantComponents.js";const h=h=>{const{selectedCollections:j,selectedCollectionsDispatch:y,setScreen:S,rearrangeViewType:g,outOfStockAction:b,scrollContainerRef:C,storeId:O,fbStatusFetcher:v,appType:T}=h,[V,k]=r(p(j));s((()=>{k(p(j))}),[j]),s((()=>{var t;null===(t=null==C?void 0:C.current)||void 0===t||t.scrollTo({top:0}),m(j,O,T,y,v,"update")}),[]);return t(c,Object.assign({onDragEnd:t=>{if(!t.destination)return;const e=V,[o]=e.splice(t.source.index,1);e.splice(t.destination.index,0,o),e.forEach(((t,e)=>{t.displayOrder=e})),k(e)}},{children:[t(d,{children:[e(n,{Icon:o,width:16,height:16,color:i.content.secondary,onClick:()=>{S("collections")}}),e(l,Object.assign({color:i.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===g?e(u,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y,outOfStockAction:b}):e(f,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y}):e(a,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};export{h as RearrangeScreen};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
3
  import { Collection, FbStatusFetcherReturn, SearchedItems, SelectedItems } from '.';
3
4
  import { SearchReducerActions, SelectedCollectionsActions } from './reducers';
4
5
  import { OUT_OF_STOCK_ACTION } from './type';
@@ -20,7 +21,8 @@ interface SearchScreenInterface {
20
21
  hideProductVariants?: boolean;
21
22
  hideProductCheckbox?: boolean;
22
23
  storeId: string;
23
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
24
+ appType: ApplicationType;
25
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
24
26
  hideCollectionCheckbox?: boolean;
25
27
  renderWithoutModal?: boolean;
26
28
  outOfStockAction?: OUT_OF_STOCK_ACTION;
@@ -1 +1 @@
1
- import{jsxs as o,jsx as e,Fragment as t}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useEffect as i}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{var C;const{customCollectionRestriction:k,selectedCollections:y,searchedCollections:b,searchedCollectionsDispatch:f,selectedCollectionsDispatch:j,setScreen:S,collections:O,onBackPress:P,hideVariantCheckbox:I,pickerType:g,hideProductVariants:x,hideProductCheckbox:D,storeId:T,fbStatusFetcher:V,setCollectionId:w,setSelectedCollectionId:A,hideCollectionCheckbox:R,renderWithoutModal:W,outOfStockAction:B}=m;i((()=>{var o;a(null!==(o=b.products)&&void 0!==o?o:{},T,f,V,"setProducts")}),[null==b?void 0:b.products]);const M=!!k&&(null==y?void 0:y.isCustom);return o("div",{children:[o(u,{children:[e(c,{Icon:l,onClick:()=>{S("collections"),P()}}),e(d,{children:(null===(C=Object.keys(null==b?void 0:b.collections))||void 0===C?void 0:C.length)?"Searched Collections & Products":"Searched Products"})]}),e("div",{children:Object.keys(null==b?void 0:b.products).length||Object.keys(null==b?void 0:b.collections).length?o(t,{children:[e(t,{children:Object.keys(null==b?void 0:b.collections).map((o=>e(s,{customCollectionRestriction:k,data:null==O?void 0:O[o],isDisabled:M&&!(null==y?void 0:y[o]),isChecked:!!(null==y?void 0:y[o]),isPartiallyChecked:p(o,null==O?void 0:O[o],y,x),selectedCollectionsDispatch:j,setCollectionId:w,setSelectedCollectionId:A,setScreen:S,id:o,hideCollectionCheckbox:R||"-1"===o,selectedCollections:y,renderWithoutModal:W,pickerType:g,usedInSearch:!0},o)))}),e(t,{children:Object.keys(null==b?void 0:b.products).map((o=>{var t,l;return Object.keys((null===(l=null===(t=null==b?void 0:b.products)||void 0===t?void 0:t[o])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i,c;let d=!1;return(null===(l=null==b?void 0:b.products)||void 0===l?void 0:l.isCustom)&&(d=!0),e(n,{collectionId:o,upliftAdditions:(e,t)=>((o,e,t)=>{var l;const i=v(t,null===(l=null==b?void 0:b.products)||void 0===l?void 0:l[o]);j({type:e,data:Object.assign(Object.assign({},i),{isRestricted:k})})})(o,e,t),productId:t,data:(null===(i=null==b?void 0:b.products)||void 0===i?void 0:i[o].products)[t],isProductPartiallyChecked:h(o,t,y,null===(c=b.products)||void 0===c?void 0:c[o],x),selectedData:y,selectedCollectionsDispatch:j,viewOnly:d,hideProductCheckbox:D,hideVariantCheckbox:I,hideProductVariants:x,pickerType:g,outOfStockAction:B},t)}))}))})]}):e(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
1
+ import{jsxs as o,jsx as e,Fragment as t}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useEffect as i}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{var C;const{customCollectionRestriction:k,selectedCollections:y,searchedCollections:b,searchedCollectionsDispatch:f,selectedCollectionsDispatch:j,setScreen:S,collections:O,onBackPress:P,hideVariantCheckbox:I,pickerType:g,hideProductVariants:x,hideProductCheckbox:D,storeId:T,fbStatusFetcher:V,setCollectionId:w,setSelectedCollectionId:A,hideCollectionCheckbox:R,renderWithoutModal:W,outOfStockAction:B,appType:M}=m;i((()=>{var o;a(null!==(o=b.products)&&void 0!==o?o:{},T,M,f,V,"setProducts")}),[null==b?void 0:b.products]);const F=!!k&&(null==y?void 0:y.isCustom);return o("div",{children:[o(u,{children:[e(c,{Icon:l,onClick:()=>{S("collections"),P()}}),e(d,{children:(null===(C=Object.keys(null==b?void 0:b.collections))||void 0===C?void 0:C.length)?"Searched Collections & Products":"Searched Products"})]}),e("div",{children:Object.keys(null==b?void 0:b.products).length||Object.keys(null==b?void 0:b.collections).length?o(t,{children:[e(t,{children:Object.keys(null==b?void 0:b.collections).map((o=>e(s,{customCollectionRestriction:k,data:null==O?void 0:O[o],isDisabled:F&&!(null==y?void 0:y[o]),isChecked:!!(null==y?void 0:y[o]),isPartiallyChecked:p(o,null==O?void 0:O[o],y,x),selectedCollectionsDispatch:j,setCollectionId:w,setSelectedCollectionId:A,setScreen:S,id:o,hideCollectionCheckbox:R||"-1"===o,selectedCollections:y,renderWithoutModal:W,pickerType:g,usedInSearch:!0},o)))}),e(t,{children:Object.keys(null==b?void 0:b.products).map((o=>{var t,l;return Object.keys((null===(l=null===(t=null==b?void 0:b.products)||void 0===t?void 0:t[o])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i,c;let d=!1;return(null===(l=null==b?void 0:b.products)||void 0===l?void 0:l.isCustom)&&(d=!0),e(n,{collectionId:o,upliftAdditions:(e,t)=>((o,e,t)=>{var l;const i=v(t,null===(l=null==b?void 0:b.products)||void 0===l?void 0:l[o]);j({type:e,data:Object.assign(Object.assign({},i),{isRestricted:k})})})(o,e,t),productId:t,data:(null===(i=null==b?void 0:b.products)||void 0===i?void 0:i[o].products)[t],isProductPartiallyChecked:h(o,t,y,null===(c=b.products)||void 0===c?void 0:c[o],x),selectedData:y,selectedCollectionsDispatch:j,viewOnly:d,hideProductCheckbox:D,hideVariantCheckbox:I,hideProductVariants:x,pickerType:g,outOfStockAction:B},t)}))}))})]}):e(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
3
  import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
3
4
  import { SelectedCollectionsActions } from './reducers';
4
5
  import { OUT_OF_STOCK_ACTION } from './type';
@@ -12,7 +13,8 @@ interface SelectedScreenInterface {
12
13
  hideProductVariants?: boolean;
13
14
  outOfStockAction?: OUT_OF_STOCK_ACTION;
14
15
  storeId: string;
15
- fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
16
+ appType: ApplicationType;
17
+ fbStatusFetcher?: (storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn;
16
18
  }
17
19
  export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
18
20
  export {};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e,Fragment as r}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as i,useEffect as n}from"react";import{IconButton as s}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as u}from"./product.js";import{paginationReducer as a}from"./reducers.js";import{SelectedScreenHeader as p}from"./style.js";import{paginateSelectedItems as m,fetchFbStatusCollection as f,isProductPartiallyChecked as h}from"./utility.js";const v=v=>{const{selectedCollections:y,selectedCollectionsDispatch:j,setScreen:b,collections:S,hideProductVariants:k=!1,outOfStockAction:I,storeId:O,fbStatusFetcher:g}=v,C=c(0),P=c(null),[w,A]=i(a,{});n((()=>{C.current=0;const t=m(y,10,0);A({type:"paginate",data:t}),f(t,O,A,g,"set"),C.current+=1}),[]),n((()=>{A({type:"filter",data:y})}),[y]),n((()=>{const t=new IntersectionObserver((t=>{if(t[0].isIntersecting&&C.current>0){const t=m(y,10,C.current);A({type:"paginate",data:t}),f(t,O,A,g,"update"),C.current+=1}}),{threshold:1});return P.current&&t.observe(P.current),()=>{P.current&&t.unobserve(P.current)}}),[P,y]);const D=y;return t("div",{children:[t(p,{children:[e(s,{Icon:o,onClick:()=>{b("collections")}}),e(l,{children:"Selected Products"})]}),t("div",{children:[Object.keys(w).length>0?e(r,{children:Object.keys(w).map((t=>{var r;return Object.keys((null===(r=null==w?void 0:w[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==D?void 0:D.isCustom)&&(o=!0),e(u,{upliftAdditions:null,collectionId:t,productId:r,data:w[t].products[r],isProductPartiallyChecked:h(t,r,D,null==S?void 0:S[t],k),selectedData:D,selectedCollectionsDispatch:j,viewOnly:o,hideProductVariants:k,outOfStockAction:I},r)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:P})]})]})};export{v as SelectedScreen};
1
+ import{jsxs as t,jsx as e,Fragment as r}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as i,useEffect as n}from"react";import{IconButton as s}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as u}from"./product.js";import{paginationReducer as a}from"./reducers.js";import{SelectedScreenHeader as p}from"./style.js";import{paginateSelectedItems as m,fetchFbStatusCollection as f,isProductPartiallyChecked as h}from"./utility.js";const y=y=>{const{selectedCollections:v,selectedCollectionsDispatch:j,setScreen:b,collections:S,hideProductVariants:k=!1,outOfStockAction:I,storeId:O,fbStatusFetcher:g,appType:C}=y,P=c(0),w=c(null),[A,D]=i(a,{});n((()=>{P.current=0;const t=m(v,10,0);D({type:"paginate",data:t}),f(t,O,C,D,g,"set"),P.current+=1}),[]),n((()=>{D({type:"filter",data:v})}),[v]),n((()=>{const t=new IntersectionObserver((t=>{if(t[0].isIntersecting&&P.current>0){const t=m(v,10,P.current);D({type:"paginate",data:t}),f(t,O,C,D,g,"update"),P.current+=1}}),{threshold:1});return w.current&&t.observe(w.current),()=>{w.current&&t.unobserve(w.current)}}),[w,v]);const x=v;return t("div",{children:[t(p,{children:[e(s,{Icon:o,onClick:()=>{b("collections")}}),e(l,{children:"Selected Products"})]}),t("div",{children:[Object.keys(A).length>0?e(r,{children:Object.keys(A).map((t=>{var r;return Object.keys((null===(r=null==A?void 0:A[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==x?void 0:x.isCustom)&&(o=!0),e(u,{upliftAdditions:null,collectionId:t,productId:r,data:A[t].products[r],isProductPartiallyChecked:h(t,r,x,null==S?void 0:S[t],k),selectedData:x,selectedCollectionsDispatch:j,viewOnly:o,hideProductVariants:k,outOfStockAction:I},r)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:w})]})]})};export{y as SelectedScreen};
@@ -1,4 +1,5 @@
1
- import { Collection, FbStatusFetcherReturn, Product, ProductVariant, SearchedItems, SelectedItems } from './modal';
1
+ import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
2
+ import { Collection, FbStatusFetcherReturn, Product, ProductVariant, SelectedItems } from './modal';
2
3
  import { CollectionsActions } from './reducers';
3
4
  export declare const liftTheStateUp: (payload: any, data: any) => any;
4
5
  export declare function paginateSelectedItems(selectedItems: SelectedItems, limit: number, offset: number): {
@@ -12,7 +13,7 @@ export declare function paginateSelectedItems(selectedItems: SelectedItems, limi
12
13
  *
13
14
  * We first get the variant ids to fetch and only if we have variant ids, we call api.
14
15
  */
15
- export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
16
+ export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, appType: ApplicationType, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[], appType: ApplicationType) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
16
17
  /**
17
18
  * Instead of collection level, we do it product level.
18
19
  *
@@ -47,4 +48,4 @@ export declare const updateAllVariantsForSelectedProducts: (selectedItems: {
47
48
  };
48
49
  } | undefined;
49
50
  };
50
- }, collections: Collection, searchedProducts: SearchedItems) => Record<string, any>;
51
+ }, collections: Collection) => Record<string, any>;
@@ -1 +1 @@
1
- import{cloneDeep as o}from"lodash";const l=(l,d)=>{const t=o(d);if(delete t.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:t})).productId&&d.products){const n=o(d.products[l.productId]);(null==n?void 0:n.variants)&&delete n.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:t,productOnlyData:n})}return l};function d(o,l,d){var n;const i={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const c=o[s],u=t(c.products,l,d-v);u&&Object.keys(u).length>0&&(i[s]=Object.assign(Object.assign({},c),{products:u})),v+=Object.keys(null!==(n=c.products)&&void 0!==n?n:{}).length}return i}function t(o,l,d){if(!o)return{};const t=Object.keys(o).slice(d,d+l),n={};return t.forEach((l=>{n[l]=o[l]})),n}const n=(o,l,d)=>{Object.keys(o).forEach((l=>{var d,t;const n=null!==(t=null===(d=o[l])||void 0===d?void 0:d.products)&&void 0!==t?t:{};Object.keys(n).forEach((d=>{var t,n,i,v;const s=null!==(v=null===(i=null===(n=null===(t=o[l])||void 0===t?void 0:t.products)||void 0===n?void 0:n[d])||void 0===i?void 0:i.variants)&&void 0!==v?v:{};Object.keys(s).forEach((t=>{var n,i,v,s;const c=null===(s=null===(v=null===(i=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===i?void 0:i[d])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[t];c&&!c.fbStatus&&(c.fbStatus="APPROVED")}))}))})),l({type:d,data:o})},i=function(o,l,d,t){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";t||n(o,d,i);const v=(o=>{const l=[];return Object.keys(o).forEach((d=>{var t,n;const i=null!==(n=null===(t=o[d])||void 0===t?void 0:t.products)&&void 0!==n?n:{};Object.keys(i).forEach((t=>{var n,i,v,s;const c=null!==(s=null===(v=null===(i=null===(n=o[d])||void 0===n?void 0:n.products)||void 0===i?void 0:i[t])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(c).forEach((n=>{var i,v,s,c;const u=null===(c=null===(s=null===(v=null===(i=o[d])||void 0===i?void 0:i.products)||void 0===v?void 0:v[t])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[n];(null==u?void 0:u.fbStatus)||l.push(n)}))}))})),l})(o);v.length>0&&t&&t(l,v).then((l=>{const t=Object.assign({},o);Object.keys(t).forEach((o=>{var d,n;const i=null!==(n=null===(d=t[o])||void 0===d?void 0:d.products)&&void 0!==n?n:{};Object.keys(i).forEach((d=>{var n,i,v,s;const c=null!==(s=null===(v=null===(i=null===(n=t[o])||void 0===n?void 0:n.products)||void 0===i?void 0:i[d])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(c).forEach((n=>{var i,v,s,c;const u=null===(c=null===(s=null===(v=null===(i=t[o])||void 0===i?void 0:i.products)||void 0===v?void 0:v[d])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[n];u&&"REJECTED"===l[n]?u.fbStatus="REJECTED":u&&"APPROVED"===l[n]&&(u.fbStatus="APPROVED")}))}))})),d({type:i,data:t})})).catch((l=>{console.error("Error in fbStatusFetcher",l),n(o,d,i)}))},v=(o,l)=>{const d=[];return Object.keys(null!=o?o:{}).forEach((t=>{var n,i;const v=null!==(i=null===(n=null==o?void 0:o[t])||void 0===n?void 0:n.variants)&&void 0!==i?i:{};Object.keys(v).forEach((n=>{var i,v,s,c,u;let r;r=l?null===(s=null===(v=null===(i=null==l?void 0:l.products)||void 0===i?void 0:i[t])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n]:null===(u=null===(c=null==o?void 0:o[t])||void 0===c?void 0:c.variants)||void 0===u?void 0:u[n],(null==r?void 0:r.fbStatus)||d.push(n)}))})),d},s=(o,l,d,t,n)=>{const i=Object.assign({},o);if(Object.keys(o).forEach((l=>{var d,t;Object.keys(null!==(t=null===(d=null==o?void 0:o[l])||void 0===d?void 0:d.variants)&&void 0!==t?t:{}).forEach((d=>{var t,n;const v=null===(t=null==o?void 0:o[l].variants)||void 0===t?void 0:t[d];v&&(v.fbStatus="APPROVED");const s=null===(n=null==i?void 0:i[l])||void 0===n?void 0:n.variants;s&&s[d]&&(s[d]=v)}))})),t&&n){const o=Object.assign({},t);o.products=i,n(o),l({type:"productsPaged",data:{collectionId:d,products:i}})}else l({type:"productsPaged",data:{collectionId:d,products:i}})},c=o=>{const l=Object.keys(o.variants||[]);let d=!1;return!(l.length<=1)||(l.forEach((l=>{var t,n;d=null!==(n=null===(t=o.variants)||void 0===t?void 0:t[l].name.includes(o.name))&&void 0!==n&&n})),!d)},u=(o,l,d,t,n)=>{var i,v,s,c,u,r,a,e,p,b,O,f,j,h,y,g,E,k,P;let I=0,V=0;if(null===(v=null===(i=null==d?void 0:d[o])||void 0===i?void 0:i.products)||void 0===v?void 0:v[l]){if(n)return!1;const i=(null===(u=null===(c=null===(s=null==d?void 0:d[o])||void 0===s?void 0:s.products)||void 0===c?void 0:c[l])||void 0===u?void 0:u.variants)||[];if(1===Object.keys(i).length)for(const t in i){const n=null===(a=null===(r=null==d?void 0:d[o])||void 0===r?void 0:r.products)||void 0===a?void 0:a[l],i=null===(O=null===(b=null===(p=null===(e=null==d?void 0:d[o])||void 0===e?void 0:e.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[t];if(null===(f=null==i?void 0:i.name)||void 0===f?void 0:f.includes(null!==(j=null==n?void 0:n.name)&&void 0!==j?j:""))return!1}if(null===(g=Object.keys((null===(y=null===(h=null==t?void 0:t.products)||void 0===h?void 0:h[l])||void 0===y?void 0:y.variants)||[]))||void 0===g||g.forEach((()=>V++)),Object.keys((null===(P=null===(k=null===(E=null==d?void 0:d[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>I++)),I>0&&V!==I)return!0}return!1},r=function(o,l,d){var t,n,i,v;let s=0,c=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(t=null==l?void 0:l.products)&&void 0!==t?t:{};s=Object.keys(v).length;const u=null!==(i=null===(n=d[o])||void 0===n?void 0:n.products)&&void 0!==i?i:{};c=Object.keys(u).length}else if(d[o]){const t=null==l?void 0:l.products;t&&Object.keys(t).forEach((o=>{var l;const d=null===(l=t[o])||void 0===l?void 0:l.variants;d&&Object.keys(d).forEach((o=>s+=1))}));const n=null===(v=d[o])||void 0===v?void 0:v.products;if(n&&Object.keys(n).forEach((o=>{var l;const d=null===(l=n[o])||void 0===l?void 0:l.variants;d&&Object.keys(d).forEach((o=>c+=1))})),s<=0&&c>0)return!1}return c>0&&s!==c},a=(l,d,t)=>{console.log({selectedItems:l,collections:d,searchedProducts:t});return Object.keys(l).reduce(((n,i)=>{var v;return i in d?(n[i]=Object.assign(Object.assign({},l[i]),{products:Object.keys(null!==(v=l[i].products)&&void 0!==v?v:{}).reduce(((n,v)=>{var s,c,u,r,a,e,p,b,O,f,j,h;const y=null===(s=d[i].products)||void 0===s?void 0:s[v],g=null===(r=null===(u=null===(c=null==t?void 0:t.products)||void 0===c?void 0:c[i])||void 0===u?void 0:u.products)||void 0===r?void 0:r[v];return y?(n[v]=Object.assign(Object.assign({},(null===(a=l[i].products)||void 0===a?void 0:a[v])||{}),{allVariants:o(y.variants)}),console.log("productInCollection 1",y,{updatedProducts:n,collectionId:i,productId:v})):g?(n[v]=Object.assign(Object.assign({},(null===(e=l[i].products)||void 0===e?void 0:e[v])||{}),{allVariants:o(g.variants)}),console.log("productInCollection 2",g,{updatedProducts:n,collectionId:i,productId:v})):(null===(b=null===(p=l[i].products)||void 0===p?void 0:p[v])||void 0===b?void 0:b.allVariants)&&(n[v]=Object.assign(Object.assign({},(null===(O=l[i].products)||void 0===O?void 0:O[v])||{}),{allVariants:o(null===(f=l[i].products)||void 0===f?void 0:f[v].allVariants)}),console.log("productInCollection 3",null===(h=null===(j=l[i].products)||void 0===j?void 0:j[v])||void 0===h?void 0:h.allVariants,{updatedProducts:n,collectionId:i,productId:v})),n}),{})}),n):n}),{})};export{i as fetchFbStatusCollection,v as getVariantIdsToFetchAtProductLevel,r as isCollectionPartiallyChecked,u as isProductPartiallyChecked,l as liftTheStateUp,s as markVariantsAsApprovedProductsLevel,d as paginateSelectedItems,c as shouldShowVariant,a as updateAllVariantsForSelectedProducts};
1
+ import{cloneDeep as o}from"lodash";const l=(l,i)=>{const n=o(i);if(delete n.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:n})).productId&&i.products){const t=o(i.products[l.productId]);(null==t?void 0:t.variants)&&delete t.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:n,productOnlyData:t})}return l};function i(o,l,i){var t;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const u=o[s],c=n(u.products,l,i-v);c&&Object.keys(c).length>0&&(d[s]=Object.assign(Object.assign({},u),{products:c})),v+=Object.keys(null!==(t=u.products)&&void 0!==t?t:{}).length}return d}function n(o,l,i){if(!o)return{};const n=Object.keys(o).slice(i,i+l),t={};return n.forEach((l=>{t[l]=o[l]})),t}const t=(o,l,i)=>{Object.keys(o).forEach((l=>{var i,n;const t=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(t).forEach((i=>{var n,t,d,v;const s=null!==(v=null===(d=null===(t=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===t?void 0:t[i])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((n=>{var t,d,v,s;const u=null===(s=null===(v=null===(d=null===(t=o[l])||void 0===t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n];u&&!u.fbStatus&&(u.fbStatus="APPROVED")}))}))})),l({type:i,data:o})},d=function(o,l,i,n,d){let v=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"paged";d||t(o,n,v);const s=(o=>{const l=[];return Object.keys(o).forEach((i=>{var n,t;const d=null!==(t=null===(n=o[i])||void 0===n?void 0:n.products)&&void 0!==t?t:{};Object.keys(d).forEach((n=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=o[i])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=o[i])||void 0===d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];(null==c?void 0:c.fbStatus)||l.push(t)}))}))})),l})(o);s.length>0&&d&&d(l,s,i).then((l=>{const i=Object.assign({},o);Object.keys(i).forEach((o=>{var n,t;const d=null!==(t=null===(n=i[o])||void 0===n?void 0:n.products)&&void 0!==t?t:{};Object.keys(d).forEach((n=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=i[o])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=i[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];c&&"REJECTED"===l[t]?c.fbStatus="REJECTED":c&&"APPROVED"===l[t]&&(c.fbStatus="APPROVED")}))}))})),n({type:v,data:i})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,n,v)}))},v=(o,l)=>{const i=[];return Object.keys(null!=o?o:{}).forEach((n=>{var t,d;const v=null!==(d=null===(t=null==o?void 0:o[n])||void 0===t?void 0:t.variants)&&void 0!==d?d:{};Object.keys(v).forEach((t=>{var d,v,s,u,c;let r;r=l?null===(s=null===(v=null===(d=null==l?void 0:l.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[t]:null===(c=null===(u=null==o?void 0:o[n])||void 0===u?void 0:u.variants)||void 0===c?void 0:c[t],(null==r?void 0:r.fbStatus)||i.push(t)}))})),i},s=(o,l,i,n,t)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((l=>{var i,n;Object.keys(null!==(n=null===(i=null==o?void 0:o[l])||void 0===i?void 0:i.variants)&&void 0!==n?n:{}).forEach((i=>{var n,t;const v=null===(n=null==o?void 0:o[l].variants)||void 0===n?void 0:n[i];v&&(v.fbStatus="APPROVED");const s=null===(t=null==d?void 0:d[l])||void 0===t?void 0:t.variants;s&&s[i]&&(s[i]=v)}))})),n&&t){const o=Object.assign({},n);o.products=d,t(o),l({type:"productsPaged",data:{collectionId:i,products:d}})}else l({type:"productsPaged",data:{collectionId:i,products:d}})},u=o=>{const l=Object.keys(o.variants||[]);let i=!1;return!(l.length<=1)||(l.forEach((l=>{var n,t;i=null!==(t=null===(n=o.variants)||void 0===n?void 0:n[l].name.includes(o.name))&&void 0!==t&&t})),!i)},c=(o,l,i,n,t)=>{var d,v,s,u,c,r,a,e,p,b,O,f,j,h,y,E,g,k,P;let D=0,S=0;if(null===(v=null===(d=null==i?void 0:i[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[l]){if(t)return!1;const d=(null===(c=null===(u=null===(s=null==i?void 0:i[o])||void 0===s?void 0:s.products)||void 0===u?void 0:u[l])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(d).length)for(const n in d){const t=null===(a=null===(r=null==i?void 0:i[o])||void 0===r?void 0:r.products)||void 0===a?void 0:a[l],d=null===(O=null===(b=null===(p=null===(e=null==i?void 0:i[o])||void 0===e?void 0:e.products)||void 0===p?void 0:p[l])||void 0===b?void 0:b.variants)||void 0===O?void 0:O[n];if(null===(f=null==d?void 0:d.name)||void 0===f?void 0:f.includes(null!==(j=null==t?void 0:t.name)&&void 0!==j?j:""))return!1}if(null===(E=Object.keys((null===(y=null===(h=null==n?void 0:n.products)||void 0===h?void 0:h[l])||void 0===y?void 0:y.variants)||[]))||void 0===E||E.forEach((()=>S++)),Object.keys((null===(P=null===(k=null===(g=null==i?void 0:i[o])||void 0===g?void 0:g.products)||void 0===k?void 0:k[l])||void 0===P?void 0:P.variants)||[]).forEach((()=>D++)),D>0&&S!==D)return!0}return!1},r=function(o,l,i){var n,t,d,v;let s=0,u=0;if(arguments.length>3&&void 0!==arguments[3]&&arguments[3]){const v=null!==(n=null==l?void 0:l.products)&&void 0!==n?n:{};s=Object.keys(v).length;const c=null!==(d=null===(t=i[o])||void 0===t?void 0:t.products)&&void 0!==d?d:{};u=Object.keys(c).length}else if(i[o]){const n=null==l?void 0:l.products;n&&Object.keys(n).forEach((o=>{var l;const i=null===(l=n[o])||void 0===l?void 0:l.variants;i&&Object.keys(i).forEach((o=>s+=1))}));const t=null===(v=i[o])||void 0===v?void 0:v.products;if(t&&Object.keys(t).forEach((o=>{var l;const i=null===(l=t[o])||void 0===l?void 0:l.variants;i&&Object.keys(i).forEach((o=>u+=1))})),s<=0&&u>0)return!1}return u>0&&s!==u},a=(l,i)=>Object.keys(l).reduce(((n,t)=>{var d;return t in i?(n[t]=Object.assign(Object.assign({},l[t]),{products:Object.keys(null!==(d=l[t].products)&&void 0!==d?d:{}).reduce(((n,d)=>{var v,s,u,c,r,a;const e=null===(v=i[t].products)||void 0===v?void 0:v[d];return e?n[d]=Object.assign(Object.assign({},(null===(s=l[t].products)||void 0===s?void 0:s[d])||{}),{allVariants:o(e.variants)}):(null===(c=null===(u=l[t].products)||void 0===u?void 0:u[d])||void 0===c?void 0:c.allVariants)&&(n[d]=Object.assign(Object.assign({},(null===(r=l[t].products)||void 0===r?void 0:r[d])||{}),{allVariants:o(null===(a=l[t].products)||void 0===a?void 0:a[d].allVariants)})),n}),{})}),n):n}),{});export{d as fetchFbStatusCollection,v as getVariantIdsToFetchAtProductLevel,r as isCollectionPartiallyChecked,c as isProductPartiallyChecked,l as liftTheStateUp,s as markVariantsAsApprovedProductsLevel,i as paginateSelectedItems,u as shouldShowVariant,a as updateAllVariantsForSelectedProducts};
@@ -16,4 +16,4 @@ import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import i from"..
16
16
  height: 100%;
17
17
  width: 48%;
18
18
  background: rgba(0, 0, 0, 0.1);
19
- `,B={value:"custom_link",label:"Custom URL"},P={value:"custom_text",label:"Custom text"},D={value:"static_expiry",label:"Static Expiry"},w=d=>{var w,N,U,H,I,R,W,Y,$;const{onFocus:M,variable:z,index:Z,showVariableModal:q,setShowDiscountCheckBox:G,componentType:F,CTAoptions:K,buttonType:Q}=d,[J,X]=s(!1),[ee,te]=s(""),[le,ie]=s([]),[ae,ne]=s(),[oe,se]=s(!1),{variableList:ue,setVariableList:de,setVariableCallback:re,setShowVariablePicker:ce,device:pe,channel:me,isError:ve,originalVariableList:be,template:ge,templateSelectionTriggered:Oe,setTemplate:je,setDisplayContent:ye,setOriginalVariableList:xe,globalNormalizedPlaceholders:he,enabledCustomText:fe,pod:Te,selectedCarouselIndex:_e,isProductCarouselType:Ee,isWhatsappCarousel:Ce,disableEditVariable:Ve,disableEditExpiry:Se,templateErrorIndexes:ke,maxCharLimit:Ae,disableDatePicker:Le,showDiscountCodeExpiryInfo:Be,cardIndex:Pe=1}=E();function De(e,t){var l,i,a,n;const o=e;te(""),ne(o),me===O.WHATSAPP||me===O.RCS?"custom_text"!==o.value&&"custom_link"!==o.value&&"static_expiry"!==o.value?(Ne(null!==(l=o.value)&&void 0!==l?l:"","string"),null==Ue||Ue(null!==(i=z.index)&&void 0!==i?i:0,o.value,!0)):(null==Ue||Ue(null!==(a=z.index)&&void 0!==a?a:0,"",!0,o.value),Ne("","url"===o.bikPlaceholderType?"link":"string")):"custom_text"!==o.value&&"custom_link"!==o.value?(Ne(o.value,"url"===o.bikPlaceholderType?"link":"string"),me==O.WEBPUSH&&(null==Ie||Ie(null!==(n=z.index)&&void 0!==n?n:0,o.value))):(te(""),Ne("",o.value))}function we(e,t){var l,i;te(t);const a="custom_link"===(null==ae?void 0:ae.value)&&t?t.includes("https")?t:`https://${t}`:t;Ne(a,"static_expiry"===e?"string":e),me!==O.WHATSAPP&&me!==O.RCS||null==Ue||Ue(null!==(l=z.index)&&void 0!==l?l:0,a,"custom_link"===e,e),me===O.WEBPUSH&&(null==Ie||Ie(null!==(i=z.index)&&void 0!==i?i:0,a))}function Ne(e,t,l){var i,a,n,s,u;const d="custom_link"===t?"link":"custom_text"===t?"string":t;if(me!==O.WHATSAPP&&me!==O.WEBPUSH&&me!==O.RCS){const l=V(Z+1),a=null===document||void 0===document?void 0:document.getElementById("mobile"===pe?"template_html_mobile":"template_html_desktop"),n=me===O.EMAIL?null===(i=null==a?void 0:a.contentWindow)||void 0===i?void 0:i.document.getElementById(l):document.getElementById(l);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:z.variableName);const o=be.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t));null==xe||xe(o)}if(me===O.WEBPUSH){const t=be,l=t=>null==t?void 0:t.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)),i={BODY:"BODY"===F?l(t.body):t.body,TITLE:F===j.TITLE.toUpperCase()?l(t.title):t.title};null==xe||xe((e=>Object.assign(Object.assign({},e),{title:i.TITLE,body:i.BODY,buttons:t.buttons})))}if(me===O.WHATSAPP||me===O.RCS){if(null!=_e&&_e>-1&&Ee){const l=Object.assign({},be).cards.map(((l,i)=>{var a,n,o;return"BODY"===F?Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>Z===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"TITLE"===F?Object.assign(Object.assign({},l),{title:null===(n=l.title)||void 0===n?void 0:n.map(((t,l)=>Z===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"BUTTONS"===F?Object.assign(Object.assign({},l),{buttons:null===(o=l.buttons)||void 0===o?void 0:o.map(((l,i)=>i===Z?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==xe||xe((e=>Object.assign(Object.assign({},e),{cards:l}))))}const i=null!=_e&&_e>-1?be.cards[_e]:be;let r=i.body,c=i.title,p=i.header,m=i.buttons;if("BODY"===F?r=null===(a=i.body)||void 0===a?void 0:a.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"TITLE"===F?c=null===(n=null==i?void 0:i.title)||void 0===n?void 0:n.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"HEADER"===F?p=null===(s=i.header)||void 0===s?void 0:s.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"BUTTONS"===F&&(m=null===(u=i.buttons)||void 0===u?void 0:u.map(((i,a)=>a===Z?Object.assign(Object.assign({},i),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===i.type?e:[e],queryParams:null!=l?l:[]}):i))),null!=_e&&_e>-1){const e=o(be.cards);e[_e]={header:p,body:r,buttons:m,title:c},null==xe||xe((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==xe||xe((e=>Object.assign(Object.assign({},e),{header:p,body:r,buttons:m,title:c})))}}function Ue(e,t,l,i){var a,n,s,u,d,r,c,p,m,v,b,g;if(null!=_e&&_e>-1&&Ee){const n=Object.assign({},ge).components.map((l=>{var i;return isCarouselComponent(l.type)?Object.assign(Object.assign({},l),{cards:null===(i=l.cards)||void 0===i?void 0:i.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var i,a,n,o,s,u,d,r,c,p,m;if("BODY"===l.type&&"BODY"===F){if(null===(a=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===a?void 0:a[0]){const i=[...null!==(s=null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{body_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("TITLE"===l.type&&"TITLE"===F){if(null===(d=null===(u=l.example)||void 0===u?void 0:u.title_text)||void 0===d?void 0:d[0]){const i=[...null!==(p=null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])&&void 0!==p?p:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{title_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("BUTTONS"===l.type&&"BUTTONS"===F){const i=null===(m=l.buttons)||void 0===m?void 0:m.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:[t]}):l));return i?Object.assign(Object.assign({},l),{buttons:i}):l}return l}))})))}):l})),s=o(ge);if(l){const l=null===(a=Object.assign({},ge).mapping.cards)||void 0===a?void 0:a.map(((l,a)=>{var n,o,s,u;if("BODY"===F)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("TITLE"===F)return Object.assign(Object.assign({},l),{title:null===(o=null==l?void 0:l.title)||void 0===o?void 0:o.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===F&&(null==l?void 0:l.buttons)){let n=-1,o=-1;return null===(s=ge.components[Pe].cards)||void 0===s||s[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(o=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(u=l.buttons)||void 0===u?void 0:u.map(((e,l)=>l===o?"custom_link"===i?"((customPlaceholderName))":t:e))})}return l}));s.mapping.cards=l}return s.components=n,void(null==je||je(s))}const O=null!=_e&&_e>-1?{components:null===(n=Object.assign({},ge).components[Pe].cards)||void 0===n?void 0:n[_e].components,mapping:null===(s=Object.assign({},ge).mapping.cards)||void 0===s?void 0:s[_e]}:Object.assign({},ge),j=null===(u=null==O?void 0:O.components)||void 0===u?void 0:u.map((l=>{var i,a,n,o,s,u,d,r,c,p,m,v,b,g,O,j;const y=Object.assign({},l);if("BODY"===l.type&&"BODY"===F&&(Array.isArray(null===(i=l.example)||void 0===i?void 0:i.body_text)||(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]))){const l=[...null!==(u=null===(s=null===(o=y.example)||void 0===o?void 0:o.body_text)||void 0===s?void 0:s[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{body_text:[l]});return Object.assign(Object.assign({},y),{example:i})}if("TITLE"===l.type&&"TITLE"===F){if(Array.isArray(null===(d=l.example)||void 0===d?void 0:d.title_text)||(null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])){const l=[...null!==(v=null===(m=null===(p=y.example)||void 0===p?void 0:p.title_text)||void 0===m?void 0:m[0])&&void 0!==v?v:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{title_text:[l]});return Object.assign(Object.assign({},y),{example:i})}}else if("HEADER"===l.type&&"HEADER"===F){if(null===(b=l.example)||void 0===b?void 0:b.header_text){const l=[...null!==(O=null===(g=y.example)||void 0===g?void 0:g.header_text)&&void 0!==O?O:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{header_text:l});return Object.assign(Object.assign({},y),{example:i})}}else{if("BUTTONS"===l.type&&"BUTTONS"===F){const i=null===(j=l.buttons)||void 0===j?void 0:j.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return i?Object.assign(Object.assign({},y),{buttons:i}):y}if("limited_time_offer"===l.type&&"limited_time_offer"===F)return Object.assign(Object.assign({},y),{example:Object.assign(Object.assign({},y.example),{limited_time_offer:t})})}return l}));if(O.components=j,l)if("BODY"===F&&(null===(d=null==O?void 0:O.mapping)||void 0===d?void 0:d.body))O.mapping=Object.assign(Object.assign({},O.mapping),{body:null===(c=null===(r=O.mapping)||void 0===r?void 0:r.body)||void 0===c?void 0:c.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("TITLE"===F&&(null===(p=null==O?void 0:O.mapping)||void 0===p?void 0:p.title))O.mapping=Object.assign(Object.assign({},O.mapping),{title:null===(v=null===(m=O.mapping)||void 0===m?void 0:m.title)||void 0===v?void 0:v.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===F&&(null===(b=null==O?void 0:O.mapping)||void 0===b?void 0:b.header))O.mapping=Object.assign(Object.assign({},O.mapping),{header:O.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===F&&(null===(g=null==O?void 0:O.mapping)||void 0===g?void 0:g.buttons)){let l=-1,a=-1;j.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),O.mapping=Object.assign(Object.assign({},O.mapping),{buttons:O.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=_e&&_e>-1&&ge){const e=o(ge);e.components[Pe].cards[_e].components=O.components,e.mapping.cards[_e]=O.mapping,null==je||je(e)}else null==je||je(Object.assign({},O))}u((()=>{J&&(null==M||M())}),[J]),u((()=>{!function(){var e,t,l,i,a;const n="mobile"===pe?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(i=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==i?i:"")+(null===(a=null==o?void 0:o.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);me===O.EMAIL&&(null==ye||ye(s))}()}),[Oe]),u((()=>{!function(){var e,t;const l=[];let i=[];if(me!==O.MESSAGE||fe){"link"===(null==z?void 0:z.type)?(l.push({label:"",options:[B,P]}),ne(B)):"date_time"===(null==z?void 0:z.type)?(l.push({label:"",options:[B,P]}),ne(D)):(l.push({label:"",options:[B,P,D]}),ne(P));const e=null!=he?he:[];ie([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:T.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),i=[...l,...e]}else{const e=null!=he?he:[];ie([{label:"",options:[P,B]},...e]),i=[{label:"",options:[P,B]},...e]}if((me===O.WHATSAPP||me===O.EMAIL||me===O.MESSAGE||me===O.WEBPUSH||me===O.RCS)&&z.updatedValue)if(g.test(z.updatedValue)&&(me===O.WHATSAPP||me===O.RCS)||z.updatedValue.startsWith("{{")&&me!==O.WHATSAPP&&me!==O.RCS){const e=function(e,t,l){var i;let a={label:"",value:""};const n=l===(O.WHATSAPP||O.RCS)?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(q){let t=e.updatedValue;if(Te===y.CHATBOT&&"BUTTONS"===F){const l=null==K?void 0:K.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}a={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(i=e.updatedValue)&&void 0!==i?i:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(a=e)}))}));return a}(z,i,me);e.value&&ne(e)}else"date_time"===z.type?(ne(D),te(z.updatedValue),Ue(null!==(e=z.index)&&void 0!==e?e:0,z.updatedValue)):(null===(t=z.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(ne(B),te(z.updatedValue.split("https://")[1])):(ne(P),te(z.updatedValue))}()}),[_e]),u((()=>{pe&&ae&&ee&&setTimeout((()=>{Ne("custom_link"===(null==ae?void 0:ae.value)&&ee?ee.includes("https")?ee:`https://${ee}`:ee,ae.value)}),100)}),[pe]),u((()=>{!oe&&ae&&z.updatedValue&&setTimeout((()=>{Ne("custom_link"===(null==ae?void 0:ae.value)&&z.updatedValue?z.updatedValue.includes("https")?z.updatedValue:`https://${z.updatedValue}`:z.updatedValue,ae.value),se(!0)}),100)}),[ae]);const He=e=>{null==G||G(!1),"{{custom.url}}"===e.actualValue?De({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?De({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?De({label:e.displayName,selected:!0,value:"static_expiry"}):De({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})};function Ie(e,t){var l;const i=o(ge),a=F.toLocaleLowerCase();(null===(l=i.webpushBroadcastConfig)||void 0===l?void 0:l[a])&&(i.webpushBroadcastConfig[a][e]=t),null==je||je(Object.assign({},i))}return e(k,Object.assign({channel:me,focused:J,onMouseEnter:()=>X(!0),onMouseLeave:()=>X(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(h,Object.assign({style:{color:ve&&!ae?_.content.negative:_.content.primary}},{children:[null===(w=z.variableName)||void 0===w?void 0:w.replace("{{","").replace("}}","")," ","link"===(null==z?void 0:z.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:q?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==ae?void 0:ae.label)?"space-between":"flex-end"}},{children:[t(f,Object.assign({numberOfLines:1},{children:Te===y.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(N=null==ae?void 0:ae.value)&&void 0!==N?N:"")?null==ae?void 0:ae.label:null==ae?void 0:ae.value:b(null!==(U=null==ae?void 0:ae.label)&&void 0!==U?U:"",20,!0)})),Ve||"date_time"===(null==z?void 0:z.type)&&Se?t(l,{}):t(i,{onClick:()=>{(()=>{if(Q===x.URL&&Te===y.CHATBOT){const e=C({variableList:ue,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom URL",variableValue:"{{custom.url}}"});de(e)}else if("limited_time_offer"===F){const e=C({variableList:ue,categoryDisplayName:"Static Variables",variableDisplayName:"Static Expiry",variableValue:"{{static.expiry}}"});de(e)}else if(Q===x.COPY_CODE){const e=C({variableList:ue,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});de(e)}})(),re((()=>He)),ce(!0)},width:24,height:24,color:_.content.primary})]})):t(m,{disabled:Ve,options:le,isSearchable:!1,onSelect:De,defaultOptions:ae?[Object.assign(Object.assign({},ae),{selected:!0})]:[]})})),("custom_text"===(null==ae?void 0:ae.value)||"custom_link"===(null==ae?void 0:ae.value))&&t(v,{state:Ve?"disabled":"none",labelText:"custom_text"===(null==ae?void 0:ae.value)?"Custom text value":"custom_link"===(null==ae?void 0:ae.value)?"Custom URL value":"",id:`variable-value-${null==ae?void 0:ae.value}-${Z}`,value:ee,errorMessage:ve&&(null===(H=null==ke?void 0:ke.buttons)||void 0===H?void 0:H.includes(null!==(I=null==z?void 0:z.index)&&void 0!==I?I:-1))?ee&&0!==ee.trim().length?"custom_link"!==ae.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${ee.trim()}`)&&0!==ee.trim().length?"custom_link"!==ae.value&&ee.length>30?"Length cannot be more than 30":"BUTTONS"===F&&"custom_link"!==ae.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:Ae||("custom_link"===(null==ae?void 0:ae.value)?2e3:"BUTTONS"===F?15:30),noKeyDownChange:!0,prefixText:"custom_link"===(null==ae?void 0:ae.value)?"https://":"",placeholder:"link"===z.type||"custom_link"===ae.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{we(ae.value,e)}}),"static_expiry"===(null==ae?void 0:ae.value)&&e("div",Object.assign({style:{position:"relative"}},{children:[(Ve||Le)&&e(A,Object.assign({onClick:e=>e.preventDefault(),style:{display:"flex",justifyContent:"space-between"}},{children:[t(L,{}),t(L,{})]})),t(p,{placement:"auto",time:n(ee?new Date(ee):new Date,"hh:mm a"),date:ee?new Date(ee):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{we("static_expiry",e.toISOString())}})]})),"static_expiry"===(null==ae?void 0:ae.value)&&Be&&t("div",Object.assign({style:{marginTop:8}},{children:t(r,{containerStyle:{padding:"4px 8px"},icon:()=>t(a,{width:16,height:16,color:_.content.secondary}),type:c.NEUTRAL,text:"Please use the same expiration code that you applied when creating \nthe code on Shopify"})})),"link"===z.type&&"custom_link"!==(null==ae?void 0:ae.value)&&!Ee&&!Ce&&Te===y.CHATBOT&&t(S,{isError:null!==(Y=null===(R=null==ke?void 0:ke.buttons)||void 0===R?void 0:R.includes(null!==(W=null==z?void 0:z.index)&&void 0!==W?W:-1))&&void 0!==Y&&Y,params:null!==($=z.queryParams)&&void 0!==$?$:[],onChange:e=>{Ne(z.updatedValue,"link",e)},variableValue:z.updatedValue})]}))};export{k as Container,w as default};
19
+ `,B={value:"custom_link",label:"Custom URL"},P={value:"custom_text",label:"Custom text"},D={value:"static_expiry",label:"Static Expiry"},w=d=>{var w,N,U,H,I,R,W,Y,$;const{onFocus:M,variable:z,index:Z,showVariableModal:q,setShowDiscountCheckBox:G,componentType:F,CTAoptions:K,buttonType:Q}=d,[J,X]=s(!1),[ee,te]=s(""),[le,ie]=s([]),[ae,ne]=s(),[oe,se]=s(!1),{variableList:ue,setVariableList:de,setVariableCallback:re,setShowVariablePicker:ce,device:pe,channel:me,isError:ve,originalVariableList:be,template:ge,templateSelectionTriggered:Oe,setTemplate:je,setDisplayContent:ye,setOriginalVariableList:xe,globalNormalizedPlaceholders:he,enabledCustomText:fe,pod:Te,selectedCarouselIndex:_e,isProductCarouselType:Ee,isWhatsappCarousel:Ce,disableEditVariable:Ve,disableEditExpiry:Se,templateErrorIndexes:ke,maxCharLimit:Ae,disableDatePicker:Le,showDiscountCodeExpiryInfo:Be,cardIndex:Pe=1}=E();function De(e,t){var l,i,a,n;const o=e;te(""),ne(o),me===O.WHATSAPP||me===O.RCS?"custom_text"!==o.value&&"custom_link"!==o.value&&"static_expiry"!==o.value?(Ne(null!==(l=o.value)&&void 0!==l?l:"","string"),null==Ue||Ue(null!==(i=z.index)&&void 0!==i?i:0,o.value,!0)):(null==Ue||Ue(null!==(a=z.index)&&void 0!==a?a:0,"",!0,o.value),Ne("","url"===o.bikPlaceholderType?"link":"string")):"custom_text"!==o.value&&"custom_link"!==o.value?(Ne(o.value,"url"===o.bikPlaceholderType?"link":"string"),me==O.WEBPUSH&&(null==Ie||Ie(null!==(n=z.index)&&void 0!==n?n:0,o.value))):(te(""),Ne("",o.value))}function we(e,t){var l,i;te(t);const a="custom_link"===(null==ae?void 0:ae.value)&&t?t.includes("https")?t:`https://${t}`:t;Ne(a,"static_expiry"===e?"string":e),me!==O.WHATSAPP&&me!==O.RCS||null==Ue||Ue(null!==(l=z.index)&&void 0!==l?l:0,a,"custom_link"===e,e),me===O.WEBPUSH&&(null==Ie||Ie(null!==(i=z.index)&&void 0!==i?i:0,a))}function Ne(e,t,l){var i,a,n,s,u;const d="custom_link"===t?"link":"custom_text"===t?"string":t;if(me!==O.WHATSAPP&&me!==O.WEBPUSH&&me!==O.RCS){const l=V(Z+1),a=null===document||void 0===document?void 0:document.getElementById("mobile"===pe?"template_html_mobile":"template_html_desktop"),n=me===O.EMAIL?null===(i=null==a?void 0:a.contentWindow)||void 0===i?void 0:i.document.getElementById(l):document.getElementById(l);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:z.variableName);const o=be.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t));null==xe||xe(o)}if(me===O.WEBPUSH){const t=be,l=t=>null==t?void 0:t.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)),i={BODY:"BODY"===F?l(t.body):t.body,TITLE:F===j.TITLE.toUpperCase()?l(t.title):t.title};null==xe||xe((e=>Object.assign(Object.assign({},e),{title:i.TITLE,body:i.BODY,buttons:t.buttons})))}if(me===O.WHATSAPP||me===O.RCS){if(null!=_e&&_e>-1&&Ee){const l=Object.assign({},be).cards.map(((l,i)=>{var a,n,o;return"BODY"===F?Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>Z===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"TITLE"===F?Object.assign(Object.assign({},l),{title:null===(n=l.title)||void 0===n?void 0:n.map(((t,l)=>Z===l?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t))}):"BUTTONS"===F?Object.assign(Object.assign({},l),{buttons:null===(o=l.buttons)||void 0===o?void 0:o.map(((l,i)=>i===Z?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==xe||xe((e=>Object.assign(Object.assign({},e),{cards:l}))))}const i=null!=_e&&_e>-1?be.cards[_e]:be;let r=i.body,c=i.title,p=i.header,m=i.buttons;if("BODY"===F?r=null===(a=i.body)||void 0===a?void 0:a.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"TITLE"===F?c=null===(n=null==i?void 0:i.title)||void 0===n?void 0:n.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"HEADER"===F?p=null===(s=i.header)||void 0===s?void 0:s.map(((t,l)=>l===Z?Object.assign(Object.assign({},t),{type:d,updatedValue:e}):t)):"BUTTONS"===F&&(m=null===(u=i.buttons)||void 0===u?void 0:u.map(((i,a)=>a===Z?Object.assign(Object.assign({},i),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===i.type?e:[e],queryParams:null!=l?l:[]}):i))),null!=_e&&_e>-1){const e=o(be.cards);e[_e]={header:p,body:r,buttons:m,title:c},null==xe||xe((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==xe||xe((e=>Object.assign(Object.assign({},e),{header:p,body:r,buttons:m,title:c})))}}function Ue(e,t,l,i){var a,n,s,u,d,r,c,p,m,v,b,g;if(null!=_e&&_e>-1&&Ee){const n=Object.assign({},ge).components.map((l=>{var i;return isCarouselComponent(l.type)?Object.assign(Object.assign({},l),{cards:null===(i=l.cards)||void 0===i?void 0:i.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var i,a,n,o,s,u,d,r,c,p,m;if("BODY"===l.type&&"BODY"===F){if(null===(a=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===a?void 0:a[0]){const i=[...null!==(s=null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{body_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("TITLE"===l.type&&"TITLE"===F){if(null===(d=null===(u=l.example)||void 0===u?void 0:u.title_text)||void 0===d?void 0:d[0]){const i=[...null!==(p=null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])&&void 0!==p?p:[]];i[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},l.example),{title_text:[i]});return Object.assign(Object.assign({},l),{example:a})}return l}if("BUTTONS"===l.type&&"BUTTONS"===F){const i=null===(m=l.buttons)||void 0===m?void 0:m.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:[t]}):l));return i?Object.assign(Object.assign({},l),{buttons:i}):l}return l}))})))}):l})),s=o(ge);if(l){const l=null===(a=Object.assign({},ge).mapping.cards)||void 0===a?void 0:a.map(((l,a)=>{var n,o,s,u;if("BODY"===F)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("TITLE"===F)return Object.assign(Object.assign({},l),{title:null===(o=null==l?void 0:l.title)||void 0===o?void 0:o.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===F&&(null==l?void 0:l.buttons)){let n=-1,o=-1;return null===(s=ge.components[Pe].cards)||void 0===s||s[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(o=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(u=l.buttons)||void 0===u?void 0:u.map(((e,l)=>l===o?"custom_link"===i?"((customPlaceholderName))":t:e))})}return l}));s.mapping.cards=l}return s.components=n,void(null==je||je(s))}const O=null!=_e&&_e>-1?{components:null===(n=Object.assign({},ge).components[Pe].cards)||void 0===n?void 0:n[_e].components,mapping:null===(s=Object.assign({},ge).mapping.cards)||void 0===s?void 0:s[_e]}:Object.assign({},ge),j=null===(u=null==O?void 0:O.components)||void 0===u?void 0:u.map((l=>{var i,a,n,o,s,u,d,r,c,p,m,v,b,g,O,j;const y=Object.assign({},l);if("BODY"===l.type&&"BODY"===F&&(Array.isArray(null===(i=l.example)||void 0===i?void 0:i.body_text)||(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]))){const l=[...null!==(u=null===(s=null===(o=y.example)||void 0===o?void 0:o.body_text)||void 0===s?void 0:s[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{body_text:[l]});return Object.assign(Object.assign({},y),{example:i})}if("TITLE"===l.type&&"TITLE"===F){if(Array.isArray(null===(d=l.example)||void 0===d?void 0:d.title_text)||(null===(c=null===(r=l.example)||void 0===r?void 0:r.title_text)||void 0===c?void 0:c[0])){const l=[...null!==(v=null===(m=null===(p=y.example)||void 0===p?void 0:p.title_text)||void 0===m?void 0:m[0])&&void 0!==v?v:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{title_text:[l]});return Object.assign(Object.assign({},y),{example:i})}}else if("HEADER"===l.type&&"HEADER"===F){if(null===(b=l.example)||void 0===b?void 0:b.header_text){const l=[...null!==(O=null===(g=y.example)||void 0===g?void 0:g.header_text)&&void 0!==O?O:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},y.example),{header_text:l});return Object.assign(Object.assign({},y),{example:i})}}else{if("BUTTONS"===l.type&&"BUTTONS"===F){const i=null===(j=l.buttons)||void 0===j?void 0:j.map(((l,i)=>i===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return i?Object.assign(Object.assign({},y),{buttons:i}):y}if("limited_time_offer"===l.type&&"limited_time_offer"===F)return Object.assign(Object.assign({},y),{example:Object.assign(Object.assign({},y.example),{limited_time_offer:t})})}return l}));if(O.components=j,l)if("BODY"===F&&(null===(d=null==O?void 0:O.mapping)||void 0===d?void 0:d.body))O.mapping=Object.assign(Object.assign({},O.mapping),{body:null===(c=null===(r=O.mapping)||void 0===r?void 0:r.body)||void 0===c?void 0:c.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("TITLE"===F&&(null===(p=null==O?void 0:O.mapping)||void 0===p?void 0:p.title))O.mapping=Object.assign(Object.assign({},O.mapping),{title:null===(v=null===(m=O.mapping)||void 0===m?void 0:m.title)||void 0===v?void 0:v.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===F&&(null===(b=null==O?void 0:O.mapping)||void 0===b?void 0:b.header))O.mapping=Object.assign(Object.assign({},O.mapping),{header:O.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===F&&(null===(g=null==O?void 0:O.mapping)||void 0===g?void 0:g.buttons)){let l=-1,a=-1;j.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),O.mapping=Object.assign(Object.assign({},O.mapping),{buttons:O.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=_e&&_e>-1&&ge){const e=o(ge);e.components[Pe].cards[_e].components=O.components,e.mapping.cards[_e]=O.mapping,null==je||je(e)}else null==je||je(Object.assign({},O))}u((()=>{J&&(null==M||M())}),[J]),u((()=>{!function(){var e,t,l,i,a;const n="mobile"===pe?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(i=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==i?i:"")+(null===(a=null==o?void 0:o.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);me===O.EMAIL&&(null==ye||ye(s))}()}),[Oe]),u((()=>{!function(){var e,t;const l=[];let i=[];if(me!==O.MESSAGE||fe){"link"===(null==z?void 0:z.type)?(l.push({label:"",options:[B,P]}),ne(B)):"date_time"===(null==z?void 0:z.type)?(l.push({label:"",options:[B,P]}),ne(D)):(l.push({label:"",options:[B,P,D]}),ne(P));const e=null!=he?he:[];ie([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:T.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),i=[...l,...e]}else{const e=null!=he?he:[];ie([{label:"",options:[P,B]},...e]),i=[{label:"",options:[P,B]},...e]}if((me===O.WHATSAPP||me===O.EMAIL||me===O.MESSAGE||me===O.WEBPUSH||me===O.RCS)&&z.updatedValue)if(g.test(z.updatedValue)&&(me===O.WHATSAPP||me===O.RCS)||z.updatedValue.startsWith("{{")&&me!==O.WHATSAPP&&me!==O.RCS){const e=function(e,t,l){var i;let a={label:"",value:""};const n=l===(O.WHATSAPP||O.RCS)?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(q){let t=e.updatedValue;if(Te===y.CHATBOT&&"BUTTONS"===F){const l=null==K?void 0:K.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}a={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(i=e.updatedValue)&&void 0!==i?i:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(a=e)}))}));return a}(z,i,me);e.value&&ne(e)}else"date_time"===z.type?(ne(D),te(z.updatedValue),Ue(null!==(e=z.index)&&void 0!==e?e:0,z.updatedValue)):(null===(t=z.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(ne(B),te(z.updatedValue.split("https://")[1])):(ne(P),te(z.updatedValue))}()}),[_e]),u((()=>{pe&&ae&&ee&&setTimeout((()=>{Ne("custom_link"===(null==ae?void 0:ae.value)&&ee?ee.includes("https")?ee:`https://${ee}`:ee,ae.value)}),100)}),[pe]),u((()=>{!oe&&ae&&z.updatedValue&&setTimeout((()=>{Ne("custom_link"===(null==ae?void 0:ae.value)&&z.updatedValue?z.updatedValue.includes("https")?z.updatedValue:`https://${z.updatedValue}`:z.updatedValue,ae.value),se(!0)}),100)}),[ae]);const He=e=>{null==G||G(!1),"{{custom.url}}"===e.actualValue?De({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?De({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?De({label:e.displayName,selected:!0,value:"static_expiry"}):De({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})};function Ie(e,t){var l;const i=o(ge),a=F.toLocaleLowerCase();(null===(l=i.webpushBroadcastConfig)||void 0===l?void 0:l[a])&&(i.webpushBroadcastConfig[a][e]=t),null==je||je(Object.assign({},i))}return e(k,Object.assign({channel:me,focused:J,onMouseEnter:()=>X(!0),onMouseLeave:()=>X(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(h,Object.assign({style:{color:ve&&!ae?_.content.negative:_.content.primary}},{children:[null===(w=z.variableName)||void 0===w?void 0:w.replace("{{","").replace("}}","")," ","link"===(null==z?void 0:z.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:q?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==ae?void 0:ae.label)?"space-between":"flex-end",backgroundColor:"date_time"===(null==z?void 0:z.type)&&Se?_.background.base:void 0}},{children:[t(f,Object.assign({numberOfLines:1},{children:Te===y.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(N=null==ae?void 0:ae.value)&&void 0!==N?N:"")?null==ae?void 0:ae.label:null==ae?void 0:ae.value:b(null!==(U=null==ae?void 0:ae.label)&&void 0!==U?U:"",20,!0)})),Ve||"date_time"===(null==z?void 0:z.type)&&Se?t(l,{}):t(i,{onClick:()=>{(()=>{if(Q===x.URL&&Te===y.CHATBOT){const e=C({variableList:ue,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom URL",variableValue:"{{custom.url}}"});de(e)}else if("limited_time_offer"===F){const e=C({variableList:ue,categoryDisplayName:"Static Variables",variableDisplayName:"Static Expiry",variableValue:"{{static.expiry}}"});de(e)}else if(Q===x.COPY_CODE){const e=C({variableList:ue,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});de(e)}})(),re((()=>He)),ce(!0)},width:24,height:24,color:_.content.primary})]})):t(m,{disabled:Ve,options:le,isSearchable:!1,onSelect:De,defaultOptions:ae?[Object.assign(Object.assign({},ae),{selected:!0})]:[]})})),("custom_text"===(null==ae?void 0:ae.value)||"custom_link"===(null==ae?void 0:ae.value))&&t(v,{state:Ve?"disabled":"none",labelText:"custom_text"===(null==ae?void 0:ae.value)?"Custom text value":"custom_link"===(null==ae?void 0:ae.value)?"Custom URL value":"",id:`variable-value-${null==ae?void 0:ae.value}-${Z}`,value:ee,errorMessage:ve&&(null===(H=null==ke?void 0:ke.buttons)||void 0===H?void 0:H.includes(null!==(I=null==z?void 0:z.index)&&void 0!==I?I:-1))?ee&&0!==ee.trim().length?"custom_link"!==ae.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${ee.trim()}`)&&0!==ee.trim().length?"custom_link"!==ae.value&&ee.length>30?"Length cannot be more than 30":"BUTTONS"===F&&"custom_link"!==ae.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:Ae||("custom_link"===(null==ae?void 0:ae.value)?2e3:"BUTTONS"===F?15:30),noKeyDownChange:!0,prefixText:"custom_link"===(null==ae?void 0:ae.value)?"https://":"",placeholder:"link"===z.type||"custom_link"===ae.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{we(ae.value,e)}}),"static_expiry"===(null==ae?void 0:ae.value)&&e("div",Object.assign({style:{position:"relative"}},{children:[(Ve||Le)&&e(A,Object.assign({onClick:e=>e.preventDefault(),style:{display:"flex",justifyContent:"space-between"}},{children:[t(L,{}),t(L,{})]})),t(p,{placement:"auto",time:n(ee?new Date(ee):new Date,"hh:mm a"),date:ee?new Date(ee):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{we("static_expiry",e.toISOString())}})]})),"static_expiry"===(null==ae?void 0:ae.value)&&Be&&t("div",Object.assign({style:{marginTop:8}},{children:t(r,{containerStyle:{padding:"4px 8px"},icon:()=>t(a,{width:16,height:16,color:_.content.secondary}),type:c.NEUTRAL,text:"Please use the same expiration code that you applied when creating\nthe code on Shopify"})})),"link"===z.type&&"custom_link"!==(null==ae?void 0:ae.value)&&!Ee&&!Ce&&Te===y.CHATBOT&&t(S,{isError:null!==(Y=null===(R=null==ke?void 0:ke.buttons)||void 0===R?void 0:R.includes(null!==(W=null==z?void 0:z.index)&&void 0!==W?W:-1))&&void 0!==Y&&Y,params:null!==($=z.queryParams)&&void 0!==$?$:[],onChange:e=>{Ne(z.updatedValue,"link",e)},variableValue:z.updatedValue})]}))};export{k as Container,w as default};
@@ -0,0 +1 @@
1
+ import{__exports as e}from"../../../../../_virtual/bik-store.js";var p,i;p=e,Object.defineProperty(p,"__esModule",{value:!0}),p.ApplicationType=void 0,(i=p.ApplicationType||(p.ApplicationType={})).BIK="BIK",i.MANIFEST="MANIFEST",i.BSP="BSP";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.656-9",
3
+ "version": "0.0.656-beta.1",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -80,7 +80,7 @@
80
80
  "@babel/plugin-transform-runtime": "^7.19.6",
81
81
  "@babel/preset-env": "^7.20.2",
82
82
  "@babel/preset-react": "^7.18.6",
83
- "@bikdotai/bik-models": "^1.13.532",
83
+ "@bikdotai/bik-models": "1.25.113-beta.11",
84
84
  "@changesets/cli": "^2.26.0",
85
85
  "@commitlint/cli": "^17.4.1",
86
86
  "@commitlint/config-conventional": "^17.4.0",