@bikdotai/bik-component-library 0.0.725-beta.2 → 0.0.725-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("../../node_modules/react/jsx-runtime.js"),o=require("react"),n=require("react-joyride");require("./constants/animations.js");var a=require("./constants/selectors.js"),r=require("./hooks/useFeatureAnnouncements.js"),s=require("./MajorUpdatePopup.js"),i=require("./MinorUpdatePopup.js"),l=require("./VideoModal.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=d(n);exports.default=d=>{let{children:c,fetchVisibleFeatures:p,getStoreFeatureProgress:f,fetchFeatureById:b,markFeatureAsViewedForStore:g,isFeatureApplicableToCurrentPage:h,module:m,router:x}=d;var y;const{majorUpdateFeatures:S,minorUpdateFeatures:C,isLoading:k,markFeatureAsViewed:T}=r.useFeatureAnnouncements({fetchVisibleFeatures:p,getStoreFeatureProgress:f,fetchFeatureById:b,markFeatureAsViewedForStore:g,isFeatureApplicableToCurrentPage:h,module:m,router:x}),[v,w]=o.useState(null),[j,E]=o.useState(null),[B,I]=o.useState(!1),[F,N]=o.useState([]),[q,R]=o.useState(!1),[P,_]=o.useState([]),[O,W]=o.useState(!1),[M,V]=o.useState(!1),[A,L]=o.useState([]),[U,$]=o.useState(!1),[z,H]=o.useState(!1),[Z,D]=o.useState(!1),[G,J]=o.useState(""),[K,Q]=o.useState(!1),[X,Y]=o.useState(!1),[ee,te]=o.useState(!1),[oe,ne]=o.useState(0),[ae,re]=o.useState(0),[se,ie]=o.useState(new Set);o.useEffect((()=>{const e="minor-spotlight-cutout-style";let t=document.getElementById(e);return t||(t=document.createElement("style"),t.id=e,document.head.appendChild(t)),t.textContent="\n\t\t\t.react-joyride__spotlight {\n\t\t\t\ttransition: box-shadow 0.3s ease-in-out !important;\n\t\t\t\twill-change: box-shadow, transform;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t\t.react-joyride__tooltip {\n\t\t\t\twill-change: transform, opacity;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t",()=>{const t=document.getElementById(e);t&&t.remove()}}),[]),o.useEffect((()=>{ne((e=>e+1)),re((e=>e+1)),Y(!1),te(!1),ie(new Set)}),[null==x?void 0:x.pathname]),o.useEffect((()=>{if(!(S.length>0)||v||k||O||K)0!==S.length||k||H(!0);else{H(!1),$(!1),I(!1),N([]),E(null),L([]);const e=()=>{document.querySelector('[data-testid="whats-new-button"]')?le(S[0]):setTimeout(e,1e3)};e()}}),[S,v,k,O,K]),o.useEffect((()=>{var e;const t=null===(e=null==x?void 0:x.query)||void 0===e?void 0:e.featureId;if(!t||k||0===C.length)return;const o=C.find((e=>e.id===t));if(!o||!o.featureTag)return;$(!0),V(!0);let n=0;const a=setInterval((()=>{n++;const e=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`;if(document.querySelector(e)){const e=[o];L(e),he(o,e),clearInterval(a)}else n>=25&&(V(!1),clearInterval(a))}),200);return()=>{clearInterval(a)}}),[C,null===(y=null==x?void 0:x.query)||void 0===y?void 0:y.featureId,k]),o.useEffect((()=>{var e;if(C.length>0&&!k&&!B&&!M&&!j&&!U&&z&&!K){let e=null,t=null,o=null,n=!1;const a=()=>{if(n||M||j||U||!z)return;const a=C.filter((e=>{if(!e.featureTag||""===e.featureTag.trim())return!1;if(se.has(e.id))return!1;const t=e.featureTag.startsWith("#")||e.featureTag.startsWith(".")||e.featureTag.startsWith("[")?e.featureTag:`#${e.featureTag}`;return null!==document.querySelector(t)}));a.length>0&&(L(a),he(a[0],a),e&&(e.disconnect(),e=null),t&&(window.removeEventListener("scroll",t),t=null),o&&(clearTimeout(o),o=null))};return e=new MutationObserver((e=>{let t=!1;for(const o of e){if("childList"===o.type&&o.addedNodes.length>0)for(let e=0;e<o.addedNodes.length;e++){const n=o.addedNodes[e];if(n.nodeType===Node.ELEMENT_NODE){const e=n;if(e.id||e.querySelector("[id]")){t=!0;break}}}if(t)break}B||n||M||j||U||!z||!t||(o&&clearTimeout(o),o=setTimeout((()=>{n||M||j||U||!z||a()}),200))})),t=()=>{B||n||M||j||U||!z||(o&&clearTimeout(o),requestAnimationFrame((()=>{o=setTimeout((()=>{n||M||j||U||!z||a()}),300)})))},e&&e.observe(document.body,{childList:!0,subtree:!0}),t&&window.addEventListener("scroll",t,{passive:!0}),a(),setTimeout((()=>{n||M||j||U||!z||a()}),100),setTimeout((()=>{n||M||j||U||!z||a()}),1e3),setTimeout((()=>{n||M||j||U||!z||a()}),500),()=>{n=!0,e&&e.disconnect(),t&&window.removeEventListener("scroll",t),o&&clearTimeout(o)}}if(0===C.length||k){(null===(e=null==x?void 0:x.query)||void 0===e?void 0:e.featureId)&&j||(I(!1),N([]),E(null),L([]),$(!1))}}),[C,k,B,M,j,U,z,T,K]);const le=e=>{w(e);const o=S.findIndex((t=>t.id===e.id)),n=S.length,r=[{target:a.SELECTORS.WHATS_NEW_BUTTON,content:t.jsxRuntimeExports.jsx(s.default,{feature:e,currentIndex:o,totalFeatures:n,onSkip:()=>de(e),onExplore:()=>ue(e),onPrevious:()=>ce(e),onNext:()=>pe(e),setIsClosing:Y}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];_(r),R(!0)},de=o.useCallback((e=>{(e||v)&&(W(!0),S.forEach((e=>{T(e.id)})),R(!1),w(null),_([]),H(!0),setTimeout((()=>{W(!1)}),500))}),[v,S,T]),ue=o.useCallback((e=>{W(!0),T(e.id),e.productVideo&&(J(e.productVideo),D(!0),Q(!0)),R(!1),w(null),_([]);S.findIndex((t=>t.id===e.id))===S.length-1&&H(!0),setTimeout((()=>{W(!1)}),500)}),[S,T]),ce=o.useCallback((e=>{const o=e||v;if(!o)return;const n=S.findIndex((e=>e.id===o.id));if(n>0){const e=S[n-1];w(e);const o=n-1,a=S.length,r=[{target:'[data-testid="whats-new-button"]',content:t.jsxRuntimeExports.jsx(s.default,{feature:e,currentIndex:o,totalFeatures:a,onSkip:()=>de(e),onExplore:()=>ue(e),onPrevious:()=>ce(e),onNext:()=>pe(e),setIsClosing:Y}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];_(r)}}),[v,S]),pe=o.useCallback((e=>{const o=e||v;if(!o)return;const n=S.findIndex((e=>e.id===o.id));if(n<S.length-1){const e=S[n+1];w(e);const o=n+1,a=S.length,r=[{target:'[data-testid="whats-new-button"]',content:t.jsxRuntimeExports.jsx(s.default,{feature:e,currentIndex:o,totalFeatures:a,onSkip:()=>de(e),onExplore:()=>ue(e),onPrevious:()=>ce(e),onNext:()=>pe(e),setIsClosing:Y}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];_(r)}else W(!0),T(o.id),R(!1),w(null),_([]),H(!0),setTimeout((()=>{W(!1)}),500)}),[v,S,T]),fe=()=>{if(S.length>0&&!v){document.querySelector('[data-testid="whats-new-button"]')&&le(S[0])}};o.useEffect((()=>(window.showMajorUpdatePopup=fe,()=>{delete window.showMajorUpdatePopup})),[S,v]);const be=o.useCallback((e=>{const{action:t}=e;t===n.ACTIONS.CLOSE&&(v&&(W(!0),S.forEach((e=>{T(e.id)})),H(!0),setTimeout((()=>{W(!1)}),500)),R(!1),w(null),_([]))}),[v,S,T]),ge=o.useCallback((e=>{const{action:t}=e;if(t===n.ACTIONS.CLOSE){if(j){V(!0),T(j.id);A.findIndex((e=>e.id===j.id))===A.length-1&&$(!0),setTimeout((()=>{V(!1)}),500)}I(!1),E(null),N([])}}),[j,A,T]),he=(o,n)=>e.__awaiter(void 0,void 0,void 0,(function*(){E(o);const e=n||A,a=e.findIndex((e=>e.id===o.id)),r=e.length,s=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`,l=document.querySelector(s);if(l)try{const{scrollToElementSmooth:e}=yield Promise.resolve().then((function(){return require("./utils/elementHelpers.js")}));yield e(l,120)}catch(e){}const d=[{target:s,content:t.jsxRuntimeExports.jsx(i.default,{feature:o,currentIndex:a,totalFeatures:r,onSkip:()=>me(o),onExplore:()=>xe(o),onPrevious:()=>ye(o),onNext:()=>Se(o),setIsClosing:te}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:o,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];N(d),I(!0)})),me=o.useCallback((e=>{const t=e||j;if(t){V(!0),T(t.id),ie((e=>new Set(e).add(t.id))),I(!1),E(null),N([]);const e=A.find((e=>e.id!==t.id&&!se.has(e.id)));setTimeout((()=>{V(!1),e?he(e,A):$(!0)}),500)}}),[j,A,T,se]),xe=o.useCallback((e=>{V(!0),T(e.id),ie((t=>new Set(t).add(e.id))),e.productVideo&&(J(e.productVideo),D(!0),Q(!0)),I(!1),E(null),N([]);const t=A.find((t=>t.id!==e.id&&!se.has(t.id)));setTimeout((()=>{V(!1),t&&!e.productVideo?he(t,A):t||$(!0)}),500)}),[A,T,se]),ye=o.useCallback((o=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=o||j;if(!e)return;const n=A.findIndex((t=>t.id===e.id));if(n>0){const e=A[n-1];E(e);const o=e.featureTag.startsWith("#")||e.featureTag.startsWith(".")||e.featureTag.startsWith("[")?e.featureTag:`#${e.featureTag}`,a=document.querySelector(o);if(a)try{const{scrollToElementSmooth:e}=yield Promise.resolve().then((function(){return require("./utils/elementHelpers.js")}));yield e(a,120)}catch(e){}const r=n-1,s=A.length,l=[{target:o,content:t.jsxRuntimeExports.jsx(i.default,{feature:e,currentIndex:r,totalFeatures:s,onSkip:()=>me(e),onExplore:()=>xe(e),onPrevious:()=>ye(e),onNext:()=>Se(e),setIsClosing:te}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];N(l)}}))),[j,A]),Se=o.useCallback((o=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=o||j;if(!e)return;const n=A.findIndex((t=>t.id===e.id));if(n<A.length-1){const e=A[n+1];E(e);const o=e.featureTag.startsWith("#")||e.featureTag.startsWith(".")||e.featureTag.startsWith("[")?e.featureTag:`#${e.featureTag}`,a=document.querySelector(o);if(a)try{const{scrollToElementSmooth:e}=yield Promise.resolve().then((function(){return require("./utils/elementHelpers.js")}));yield e(a,120)}catch(e){}const r=n+1,s=A.length,l=[{target:o,content:t.jsxRuntimeExports.jsx(i.default,{feature:e,currentIndex:r,totalFeatures:s,onSkip:()=>me(e),onExplore:()=>xe(e),onPrevious:()=>ye(e),onNext:()=>Se(e),setIsClosing:te}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];N(l)}else V(!0),$(!0),T(e.id),I(!1),E(null),N([]),setTimeout((()=>{V(!1)}),500)}))),[j,A,T]);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[c,P.length>0&&t.jsxRuntimeExports.jsx(u.default,{steps:P,run:q,continuous:!1,showProgress:!1,showSkipButton:!1,callback:be,disableOverlayClose:!0,disableCloseOnEsc:!1,disableOverlay:!1,spotlightClicks:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:X?"transparent":"#212121"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",border:"none",boxShadow:"none"},tooltip:{borderRadius:"16px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`major-joyride-${oe}`),F.length>0&&t.jsxRuntimeExports.jsx(u.default,{steps:F,run:B,continuous:!1,showProgress:!1,showSkipButton:!1,callback:ge,disableOverlayClose:!0,disableCloseOnEsc:!1,disableOverlay:!1,scrollToFirstStep:!0,scrollOffset:120,disableScrolling:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:ee?"transparent":"#ffffff"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",borderRadius:"8px",boxShadow:ee?"none":"0 0 0 9999px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 20px 8px rgba(255, 255, 255, 0.4)"},tooltip:{borderRadius:"4px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonSkip:{display:"none"},buttonClose:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`minor-joyride-${ae}`),t.jsxRuntimeExports.jsx(l.VideoModal,{isOpen:Z,videoUrl:G,onClose:()=>{D(!1),J(""),Q(!1);const e=A.find((e=>!se.has(e.id)));e?setTimeout((()=>{he(e,A)}),300):$(!0)}})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("../../node_modules/react/jsx-runtime.js"),o=require("react"),n=require("react-joyride");require("./constants/animations.js");var a=require("./constants/selectors.js"),r=require("./hooks/useFeatureAnnouncements.js"),s=require("./MajorUpdatePopup.js"),i=require("./MinorUpdatePopup.js"),l=require("./VideoModal.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=u(n);exports.default=u=>{let{children:c,fetchVisibleFeatures:p,getStoreFeatureProgress:f,fetchFeatureById:b,markFeatureAsViewedForStore:g,isFeatureApplicableToCurrentPage:h,module:m,router:x}=u;var y;const{majorUpdateFeatures:S,minorUpdateFeatures:C,isLoading:k,markFeatureAsViewed:v}=r.useFeatureAnnouncements({fetchVisibleFeatures:p,getStoreFeatureProgress:f,fetchFeatureById:b,markFeatureAsViewedForStore:g,isFeatureApplicableToCurrentPage:h,module:m,router:x}),[T,w]=o.useState(null),[j,E]=o.useState(null),[B,F]=o.useState(!1),[I,N]=o.useState([]),[q,P]=o.useState(!1),[R,U]=o.useState([]),[W,M]=o.useState(!1),[O,_]=o.useState(!1),[A,D]=o.useState([]),[V,L]=o.useState(!1),[G,$]=o.useState(!1),[z,H]=o.useState(!1),[Z,J]=o.useState(""),[K,Q]=o.useState(!1),[X,Y]=o.useState(!1),[ee,te]=o.useState(!1),[oe,ne]=o.useState(0),[ae,re]=o.useState(0),[se,ie]=o.useState(new Set);o.useEffect((()=>{const e="minor-spotlight-cutout-style";let t=document.getElementById(e);return t||(t=document.createElement("style"),t.id=e,document.head.appendChild(t)),t.textContent="\n\t\t\t.react-joyride__spotlight {\n\t\t\t\ttransition: box-shadow 0.3s ease-in-out !important;\n\t\t\t\twill-change: box-shadow, transform;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t\t.react-joyride__tooltip {\n\t\t\t\twill-change: transform, opacity;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t",()=>{const t=document.getElementById(e);t&&t.remove()}}),[]),o.useEffect((()=>{ne((e=>e+1)),re((e=>e+1)),Y(!1),te(!1),ie(new Set)}),[null==x?void 0:x.pathname]),o.useEffect((()=>{if(console.log("🔍 [DEBUG] Route check:",{pathname:null==x?void 0:x.pathname,query:null==x?void 0:x.query,majorFeaturesCount:S.length,minorFeaturesCount:C.length,currentMajorFeature:null==T?void 0:T.id,isLoading:k,blockPopups:K,isProcessingMajorUpdate:W}),S.length>0)if(console.log("🔍 [DEBUG] First major feature details:",{featureId:S[0].id,title:S[0].title,featureUpdateType:S[0].featureUpdateType}),h){const e=h(S[0]);console.log("🔍 [DEBUG] Is major feature applicable to current page?",e)}else console.log("🔍 [DEBUG] isFeatureApplicableToCurrentPage function not provided");const e=document.querySelector('[data-testid="whats-new-button"]');console.log("🔍 [DEBUG] What's New button exists in DOM?",!!e)}),[null==x?void 0:x.pathname,null==x?void 0:x.query,S,C,k,T,K,W,h]),o.useEffect((()=>{if(!(S.length>0)||T||k||W||K)0!==S.length||k||(console.log("🔍 [DEBUG] No major features, enabling minor updates"),$(!0));else{console.log("🔍 [DEBUG] Starting major popup flow..."),$(!1),L(!1),F(!1),N([]),E(null),D([]);let e=0;const t=10,o=()=>{e++;const n=document.querySelector('[data-testid="whats-new-button"]');console.log(`🔍 [DEBUG] Polling for What's New button - Attempt ${e}/${t}`,{buttonFound:!!n,pathname:null==x?void 0:x.pathname}),n?(console.log("✅ [DEBUG] What's New button found! Showing major popup"),le(S[0])):e<t?setTimeout(o,1e3):(console.warn("⚠️ [DEBUG] What's New button not found after 10s. Allowing minor updates.",{pathname:null==x?void 0:x.pathname}),$(!0))};o()}}),[S,T,k,W,K]),o.useEffect((()=>{var e;const t=null===(e=null==x?void 0:x.query)||void 0===e?void 0:e.featureId;if(!t||k||0===C.length)return;const o=C.find((e=>e.id===t));if(!o||!o.featureTag)return;L(!0),_(!0);let n=0;const a=setInterval((()=>{n++;const e=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`;if(document.querySelector(e)){const e=[o];D(e),he(o,e),clearInterval(a)}else n>=25&&(_(!1),clearInterval(a))}),200);return()=>{clearInterval(a)}}),[C,null===(y=null==x?void 0:x.query)||void 0===y?void 0:y.featureId,k]),o.useEffect((()=>{var e;if(C.length>0&&!k&&!B&&!O&&!j&&!V&&G&&!K){let e=null,t=null,o=null,n=!1;const a=()=>{if(n||O||j||V||!G)return;const a=C.filter((e=>{if(!e.featureTag||""===e.featureTag.trim())return!1;if(se.has(e.id))return!1;const t=e.featureTag.startsWith("#")||e.featureTag.startsWith(".")||e.featureTag.startsWith("[")?e.featureTag:`#${e.featureTag}`;return null!==document.querySelector(t)}));a.length>0&&(D(a),he(a[0],a),e&&(e.disconnect(),e=null),t&&(window.removeEventListener("scroll",t),t=null),o&&(clearTimeout(o),o=null))};return e=new MutationObserver((e=>{let t=!1;for(const o of e){if("childList"===o.type&&o.addedNodes.length>0)for(let e=0;e<o.addedNodes.length;e++){const n=o.addedNodes[e];if(n.nodeType===Node.ELEMENT_NODE){const e=n;if(e.id||e.querySelector("[id]")){t=!0;break}}}if(t)break}B||n||O||j||V||!G||!t||(o&&clearTimeout(o),o=setTimeout((()=>{n||O||j||V||!G||a()}),200))})),t=()=>{B||n||O||j||V||!G||(o&&clearTimeout(o),requestAnimationFrame((()=>{o=setTimeout((()=>{n||O||j||V||!G||a()}),300)})))},e&&e.observe(document.body,{childList:!0,subtree:!0}),t&&window.addEventListener("scroll",t,{passive:!0}),a(),setTimeout((()=>{n||O||j||V||!G||a()}),100),setTimeout((()=>{n||O||j||V||!G||a()}),1e3),setTimeout((()=>{n||O||j||V||!G||a()}),500),()=>{n=!0,e&&e.disconnect(),t&&window.removeEventListener("scroll",t),o&&clearTimeout(o)}}if(0===C.length||k){(null===(e=null==x?void 0:x.query)||void 0===e?void 0:e.featureId)&&j||(F(!1),N([]),E(null),D([]),L(!1))}}),[C,k,B,O,j,V,G,v,K]);const le=e=>{w(e);const o=S.findIndex((t=>t.id===e.id)),n=S.length,r=[{target:a.SELECTORS.WHATS_NEW_BUTTON,content:t.jsxRuntimeExports.jsx(s.default,{feature:e,currentIndex:o,totalFeatures:n,onSkip:()=>ue(e),onExplore:()=>de(e),onPrevious:()=>ce(e),onNext:()=>pe(e),setIsClosing:Y}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];U(r),P(!0)},ue=o.useCallback((e=>{(e||T)&&(M(!0),S.forEach((e=>{v(e.id)})),P(!1),w(null),U([]),$(!0),setTimeout((()=>{M(!1)}),500))}),[T,S,v]),de=o.useCallback((e=>{M(!0),v(e.id),e.productVideo&&(J(e.productVideo),H(!0),Q(!0)),P(!1),w(null),U([]);S.findIndex((t=>t.id===e.id))===S.length-1&&$(!0),setTimeout((()=>{M(!1)}),500)}),[S,v]),ce=o.useCallback((e=>{const o=e||T;if(!o)return;const n=S.findIndex((e=>e.id===o.id));if(n>0){const e=S[n-1];w(e);const o=n-1,a=S.length,r=[{target:'[data-testid="whats-new-button"]',content:t.jsxRuntimeExports.jsx(s.default,{feature:e,currentIndex:o,totalFeatures:a,onSkip:()=>ue(e),onExplore:()=>de(e),onPrevious:()=>ce(e),onNext:()=>pe(e),setIsClosing:Y}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];U(r)}}),[T,S]),pe=o.useCallback((e=>{const o=e||T;if(!o)return;const n=S.findIndex((e=>e.id===o.id));if(n<S.length-1){const e=S[n+1];w(e);const o=n+1,a=S.length,r=[{target:'[data-testid="whats-new-button"]',content:t.jsxRuntimeExports.jsx(s.default,{feature:e,currentIndex:o,totalFeatures:a,onSkip:()=>ue(e),onExplore:()=>de(e),onPrevious:()=>ce(e),onNext:()=>pe(e),setIsClosing:Y}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];U(r)}else M(!0),v(o.id),P(!1),w(null),U([]),$(!0),setTimeout((()=>{M(!1)}),500)}),[T,S,v]),fe=()=>{if(S.length>0&&!T){document.querySelector('[data-testid="whats-new-button"]')&&le(S[0])}};o.useEffect((()=>(window.showMajorUpdatePopup=fe,()=>{delete window.showMajorUpdatePopup})),[S,T]);const be=o.useCallback((e=>{const{action:t}=e;t===n.ACTIONS.CLOSE&&(T&&(M(!0),S.forEach((e=>{v(e.id)})),$(!0),setTimeout((()=>{M(!1)}),500)),P(!1),w(null),U([]))}),[T,S,v]),ge=o.useCallback((e=>{const{action:t}=e;if(t===n.ACTIONS.CLOSE){if(j){_(!0),v(j.id);A.findIndex((e=>e.id===j.id))===A.length-1&&L(!0),setTimeout((()=>{_(!1)}),500)}F(!1),E(null),N([])}}),[j,A,v]),he=(o,n)=>e.__awaiter(void 0,void 0,void 0,(function*(){E(o);const e=n||A,a=e.findIndex((e=>e.id===o.id)),r=e.length,s=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`,l=document.querySelector(s);if(l)try{const{scrollToElementSmooth:e}=yield Promise.resolve().then((function(){return require("./utils/elementHelpers.js")}));yield e(l,120)}catch(e){}const u=[{target:s,content:t.jsxRuntimeExports.jsx(i.default,{feature:o,currentIndex:a,totalFeatures:r,onSkip:()=>me(o),onExplore:()=>xe(o),onPrevious:()=>ye(o),onNext:()=>Se(o),setIsClosing:te}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:o,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];N(u),F(!0)})),me=o.useCallback((e=>{const t=e||j;if(t){_(!0),v(t.id),ie((e=>new Set(e).add(t.id))),F(!1),E(null),N([]);const e=A.find((e=>e.id!==t.id&&!se.has(e.id)));setTimeout((()=>{_(!1),e?he(e,A):L(!0)}),500)}}),[j,A,v,se]),xe=o.useCallback((e=>{_(!0),v(e.id),ie((t=>new Set(t).add(e.id))),e.productVideo&&(J(e.productVideo),H(!0),Q(!0)),F(!1),E(null),N([]);const t=A.find((t=>t.id!==e.id&&!se.has(t.id)));setTimeout((()=>{_(!1),t&&!e.productVideo?he(t,A):t||L(!0)}),500)}),[A,v,se]),ye=o.useCallback((o=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=o||j;if(!e)return;const n=A.findIndex((t=>t.id===e.id));if(n>0){const e=A[n-1];E(e);const o=e.featureTag.startsWith("#")||e.featureTag.startsWith(".")||e.featureTag.startsWith("[")?e.featureTag:`#${e.featureTag}`,a=document.querySelector(o);if(a)try{const{scrollToElementSmooth:e}=yield Promise.resolve().then((function(){return require("./utils/elementHelpers.js")}));yield e(a,120)}catch(e){}const r=n-1,s=A.length,l=[{target:o,content:t.jsxRuntimeExports.jsx(i.default,{feature:e,currentIndex:r,totalFeatures:s,onSkip:()=>me(e),onExplore:()=>xe(e),onPrevious:()=>ye(e),onNext:()=>Se(e),setIsClosing:te}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];N(l)}}))),[j,A]),Se=o.useCallback((o=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=o||j;if(!e)return;const n=A.findIndex((t=>t.id===e.id));if(n<A.length-1){const e=A[n+1];E(e);const o=e.featureTag.startsWith("#")||e.featureTag.startsWith(".")||e.featureTag.startsWith("[")?e.featureTag:`#${e.featureTag}`,a=document.querySelector(o);if(a)try{const{scrollToElementSmooth:e}=yield Promise.resolve().then((function(){return require("./utils/elementHelpers.js")}));yield e(a,120)}catch(e){}const r=n+1,s=A.length,l=[{target:o,content:t.jsxRuntimeExports.jsx(i.default,{feature:e,currentIndex:r,totalFeatures:s,onSkip:()=>me(e),onExplore:()=>xe(e),onPrevious:()=>ye(e),onNext:()=>Se(e),setIsClosing:te}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:e,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];N(l)}else _(!0),L(!0),v(e.id),F(!1),E(null),N([]),setTimeout((()=>{_(!1)}),500)}))),[j,A,v]);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[c,R.length>0&&t.jsxRuntimeExports.jsx(d.default,{steps:R,run:q,continuous:!1,showProgress:!1,showSkipButton:!1,callback:be,disableOverlayClose:!0,disableCloseOnEsc:!1,disableOverlay:!1,spotlightClicks:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:X?"transparent":"#212121"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",border:"none",boxShadow:"none"},tooltip:{borderRadius:"16px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`major-joyride-${oe}`),I.length>0&&t.jsxRuntimeExports.jsx(d.default,{steps:I,run:B,continuous:!1,showProgress:!1,showSkipButton:!1,callback:ge,disableOverlayClose:!0,disableCloseOnEsc:!1,disableOverlay:!1,scrollToFirstStep:!0,scrollOffset:120,disableScrolling:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:ee?"transparent":"#ffffff"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",borderRadius:"8px",boxShadow:ee?"none":"0 0 0 9999px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 20px 8px rgba(255, 255, 255, 0.4)"},tooltip:{borderRadius:"4px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonSkip:{display:"none"},buttonClose:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`minor-joyride-${ae}`),t.jsxRuntimeExports.jsx(l.VideoModal,{isOpen:z,videoUrl:Z,onClose:()=>{H(!1),J(""),Q(!1);const e=A.find((e=>!se.has(e.id)));e?setTimeout((()=>{he(e,A)}),300):L(!0)}})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react"),r=require("../constants/animations.js"),a=require("../constants/localStorageKeys.js");exports.useFeatureAnnouncements=o=>{let{fetchVisibleFeatures:n,getStoreFeatureProgress:i,fetchFeatureById:l,markFeatureAsViewedForStore:s,isFeatureApplicableToCurrentPage:u,module:c,router:d}=o;var f;const p=(()=>{const[e,r]=t.useState(null);return t.useEffect((()=>{if("undefined"!=typeof window){let e=null;try{if(e=localStorage.getItem(a.LOCAL_STORAGE_KEYS.STORE_ID)||localStorage.getItem(a.LOCAL_STORAGE_KEYS.BIK_STORE_ID)||localStorage.getItem(a.LOCAL_STORAGE_KEYS.CURRENT_STORE)||localStorage.getItem(a.LOCAL_STORAGE_KEYS.STORE),!e){const t=localStorage.getItem(a.LOCAL_STORAGE_KEYS.CURRENT_USER);t&&(e=JSON.parse(t).storeId)}e||(e=new URLSearchParams(window.location.search).get(a.LOCAL_STORAGE_KEYS.QUERY_PARAM))}catch(e){console.error("FeatureAnnouncements: Failed to get store ID",e)}r(e)}}),[]),e})(),[A,S]=t.useState([]),[_,v]=t.useState([]),[g,y]=t.useState([]),[E,m]=t.useState(!1),[R,w]=t.useState(null),F=t.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(p){m(!0),w(null);try{const[e,t]=yield n(c);if(e||!t)return console.error("FeatureAnnouncements: Failed to fetch features",e),void w("Failed to fetch features");const[a,o]=yield i(p);a&&console.warn("FeatureAnnouncements: Progress fetch failed, treating all features as new",a);const l=new Date,s="undefined"!=typeof window?window.location.pathname:"",d=e=>{if(!e.expirationDate)return!0;let t;return"object"==typeof e.expirationDate&&null!==e.expirationDate&&("seconds"in e.expirationDate||"nanoseconds"in e.expirationDate)?t=new Date(1e3*e.expirationDate.seconds):"string"==typeof e.expirationDate?t=new Date(e.expirationDate):e.expirationDate instanceof Date&&(t=e.expirationDate),!(!t||isNaN(t.getTime()))&&l<t},f=e=>{if("Major"===e.featureUpdateType){let t=[];return Array.isArray(e.pageUrls)?t=e.pageUrls:"object"==typeof e.pageUrls&&null!==e.pageUrls&&"length"in e.pageUrls&&(t=Array.from(e.pageUrls)),t.includes(s)}return!0},A=t.filter((e=>{var t;const r=(null===(t=null==o?void 0:o.viewedFeatures)||void 0===t?void 0:t[e.id])||!1,a=e.archived||!1;return!r&&!a&&u(e)&&d(e)&&f(e)})),_=A.filter((e=>"Major"===e.featureUpdateType)),g=A.filter((e=>"Minor"===e.featureUpdateType));S(A),v(_),setTimeout((()=>{y(g)}),r.ANIMATION_TIMING.MINOR_POPUP_DELAY)}catch(e){console.error("FeatureAnnouncements: Unexpected error in fetchFeatures",e),w("An unexpected error occurred")}finally{m(!1)}}}))),[p,n,i,u,c]),T=t.useCallback((t=>e.__awaiter(void 0,void 0,void 0,(function*(){m(!0),w(null);try{const[e,r]=yield l(t);if(e||!r)return void w("Failed to fetch feature by ID");"Major"===r.featureUpdateType?v([r]):y([r]),S([r])}catch(e){w("An unexpected error occurred while fetching by ID")}finally{m(!1)}}))),[l]),U=t.useCallback((t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!p)return;const[e]=yield s(p,t);e?(console.warn("FeatureAnnouncements: Failed to mark feature as viewed, removing from local state anyway",e),S((e=>e.filter((e=>e.id!==t)))),v((e=>e.filter((e=>e.id!==t)))),y((e=>e.filter((e=>e.id!==t))))):(S((e=>e.filter((e=>e.id!==t)))),v((e=>e.filter((e=>e.id!==t)))),y((e=>e.filter((e=>e.id!==t)))))}))),[p,s]);return t.useEffect((()=>{var e;const t=null===(e=null==d?void 0:d.query)||void 0===e?void 0:e[a.QUERY_PARAMS.FEATURE_ID];t&&d?T(t):F()}),[null==d?void 0:d.pathname,null===(f=null==d?void 0:d.query)||void 0===f?void 0:f[a.QUERY_PARAMS.FEATURE_ID],p,F,T,d]),{features:A,majorUpdateFeatures:_,minorUpdateFeatures:g,isLoading:E,error:R,markFeatureAsViewed:U,refetch:F}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react"),r=require("../constants/animations.js"),a=require("../constants/localStorageKeys.js");exports.useFeatureAnnouncements=o=>{let{fetchVisibleFeatures:n,getStoreFeatureProgress:i,fetchFeatureById:l,markFeatureAsViewedForStore:s,isFeatureApplicableToCurrentPage:u,module:c,router:d}=o;var f;const p=(()=>{const[e,r]=t.useState(null);return t.useEffect((()=>{if("undefined"!=typeof window){let e=null;try{if(e=localStorage.getItem(a.LOCAL_STORAGE_KEYS.STORE_ID)||localStorage.getItem(a.LOCAL_STORAGE_KEYS.BIK_STORE_ID)||localStorage.getItem(a.LOCAL_STORAGE_KEYS.CURRENT_STORE)||localStorage.getItem(a.LOCAL_STORAGE_KEYS.STORE),!e){const t=localStorage.getItem(a.LOCAL_STORAGE_KEYS.CURRENT_USER);t&&(e=JSON.parse(t).storeId)}e||(e=new URLSearchParams(window.location.search).get(a.LOCAL_STORAGE_KEYS.QUERY_PARAM))}catch(e){console.error("FeatureAnnouncements: Failed to get store ID",e)}r(e)}}),[]),e})(),[A,g]=t.useState([]),[S,_]=t.useState([]),[E,v]=t.useState([]),[y,R]=t.useState(!1),[m,w]=t.useState(null),U=t.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(p){R(!0),w(null);try{const[e,t]=yield n(c);if(e||!t)return console.error("FeatureAnnouncements: Failed to fetch features",e),void w("Failed to fetch features");const[a,o]=yield i(p);a&&console.warn("FeatureAnnouncements: Progress fetch failed, treating all features as new",a);const l=new Date,s="undefined"!=typeof window?window.location.pathname:"",d=e=>{if(!e.expirationDate)return!0;let t;return"object"==typeof e.expirationDate&&null!==e.expirationDate&&("seconds"in e.expirationDate||"nanoseconds"in e.expirationDate)?t=new Date(1e3*e.expirationDate.seconds):"string"==typeof e.expirationDate?t=new Date(e.expirationDate):e.expirationDate instanceof Date&&(t=e.expirationDate),!(!t||isNaN(t.getTime()))&&l<t},f=e=>{if("Major"===e.featureUpdateType){let t=[];return Array.isArray(e.pageUrls)?t=e.pageUrls:"object"==typeof e.pageUrls&&null!==e.pageUrls&&"length"in e.pageUrls&&(t=Array.from(e.pageUrls)),t.some((e=>{if(e===s)return!0;const t=e.replace(/\[([^\]]+)\]/g,"[^/]+").replace(/\//g,"\\/");return new RegExp(`^${t}$`).test(s)}))}return!0},A=t.filter((e=>{var t;const r=(null===(t=null==o?void 0:o.viewedFeatures)||void 0===t?void 0:t[e.id])||!1,a=e.archived||!1,n=u(e),i=d(e),l=f(e),c=!r&&!a&&n&&i&&l;return"Major"===e.featureUpdateType&&console.log("🔍 [FILTER DEBUG] Major feature:",{featureId:e.id,title:e.title,pageUrls:e.pageUrls,currentRoute:s,isViewed:r,isArchived:a,isApplicable:n,notExpired:i,onCorrectPage:l,shouldShow:c}),c})),S=A.filter((e=>"Major"===e.featureUpdateType)),E=A.filter((e=>"Minor"===e.featureUpdateType));g(A),_(S),setTimeout((()=>{v(E)}),r.ANIMATION_TIMING.MINOR_POPUP_DELAY)}catch(e){console.error("FeatureAnnouncements: Unexpected error in fetchFeatures",e),w("An unexpected error occurred")}finally{R(!1)}}}))),[p,n,i,u,c]),F=t.useCallback((t=>e.__awaiter(void 0,void 0,void 0,(function*(){R(!0),w(null);try{const[e,r]=yield l(t);if(e||!r)return void w("Failed to fetch feature by ID");"Major"===r.featureUpdateType?_([r]):v([r]),g([r])}catch(e){w("An unexpected error occurred while fetching by ID")}finally{R(!1)}}))),[l]),T=t.useCallback((t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!p)return;const[e]=yield s(p,t);e?(console.warn("FeatureAnnouncements: Failed to mark feature as viewed, removing from local state anyway",e),g((e=>e.filter((e=>e.id!==t)))),_((e=>e.filter((e=>e.id!==t)))),v((e=>e.filter((e=>e.id!==t))))):(g((e=>e.filter((e=>e.id!==t)))),_((e=>e.filter((e=>e.id!==t)))),v((e=>e.filter((e=>e.id!==t)))))}))),[p,s]);return t.useEffect((()=>{var e;const t=null===(e=null==d?void 0:d.query)||void 0===e?void 0:e[a.QUERY_PARAMS.FEATURE_ID];t&&d?F(t):U()}),[null==d?void 0:d.pathname,null===(f=null==d?void 0:d.query)||void 0===f?void 0:f[a.QUERY_PARAMS.FEATURE_ID],p,U,F,d]),{features:A,majorUpdateFeatures:S,minorUpdateFeatures:E,isLoading:y,error:m,markFeatureAsViewed:T,refetch:U}};
@@ -1 +1 @@
1
- import{__awaiter as t}from"../../_virtual/_tslib.js";import{j as e}from"../../node_modules/react/jsx-runtime.js";import{useState as o,useEffect as n,useCallback as r}from"react";import a,{ACTIONS as i}from"react-joyride";import"./constants/animations.js";import{SELECTORS as s}from"./constants/selectors.js";import{useFeatureAnnouncements as d}from"./hooks/useFeatureAnnouncements.js";import l from"./MajorUpdatePopup.js";import u from"./MinorUpdatePopup.js";import{VideoModal as c}from"./VideoModal.js";const p=p=>{let{children:f,fetchVisibleFeatures:b,getStoreFeatureProgress:m,fetchFeatureById:g,markFeatureAsViewedForStore:h,isFeatureApplicableToCurrentPage:y,module:x,router:C}=p;var S;const{majorUpdateFeatures:k,minorUpdateFeatures:T,isLoading:w,markFeatureAsViewed:v}=d({fetchVisibleFeatures:b,getStoreFeatureProgress:m,fetchFeatureById:g,markFeatureAsViewedForStore:h,isFeatureApplicableToCurrentPage:y,module:x,router:C}),[B,j]=o(null),[I,F]=o(null),[E,N]=o(!1),[W,P]=o([]),[M,O]=o(!1),[q,V]=o([]),[_,L]=o(!1),[R,A]=o(!1),[U,$]=o([]),[z,H]=o(!1),[Z,D]=o(!1),[G,J]=o(!1),[K,Q]=o(""),[X,Y]=o(!1),[tt,et]=o(!1),[ot,nt]=o(!1),[rt,at]=o(0),[it,st]=o(0),[dt,lt]=o(new Set);n((()=>{const t="minor-spotlight-cutout-style";let e=document.getElementById(t);return e||(e=document.createElement("style"),e.id=t,document.head.appendChild(e)),e.textContent="\n\t\t\t.react-joyride__spotlight {\n\t\t\t\ttransition: box-shadow 0.3s ease-in-out !important;\n\t\t\t\twill-change: box-shadow, transform;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t\t.react-joyride__tooltip {\n\t\t\t\twill-change: transform, opacity;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t",()=>{const e=document.getElementById(t);e&&e.remove()}}),[]),n((()=>{at((t=>t+1)),st((t=>t+1)),et(!1),nt(!1),lt(new Set)}),[null==C?void 0:C.pathname]),n((()=>{if(!(k.length>0)||B||w||_||X)0!==k.length||w||D(!0);else{D(!1),H(!1),N(!1),P([]),F(null),$([]);const t=()=>{document.querySelector('[data-testid="whats-new-button"]')?ut(k[0]):setTimeout(t,1e3)};t()}}),[k,B,w,_,X]),n((()=>{var t;const e=null===(t=null==C?void 0:C.query)||void 0===t?void 0:t.featureId;if(!e||w||0===T.length)return;const o=T.find((t=>t.id===e));if(!o||!o.featureTag)return;H(!0),A(!0);let n=0;const r=setInterval((()=>{n++;const t=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`;if(document.querySelector(t)){const t=[o];$(t),yt(o,t),clearInterval(r)}else n>=25&&(A(!1),clearInterval(r))}),200);return()=>{clearInterval(r)}}),[T,null===(S=null==C?void 0:C.query)||void 0===S?void 0:S.featureId,w]),n((()=>{var t;if(T.length>0&&!w&&!E&&!R&&!I&&!z&&Z&&!X){let t=null,e=null,o=null,n=!1;const r=()=>{if(n||R||I||z||!Z)return;const r=T.filter((t=>{if(!t.featureTag||""===t.featureTag.trim())return!1;if(dt.has(t.id))return!1;const e=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`;return null!==document.querySelector(e)}));r.length>0&&($(r),yt(r[0],r),t&&(t.disconnect(),t=null),e&&(window.removeEventListener("scroll",e),e=null),o&&(clearTimeout(o),o=null))};return t=new MutationObserver((t=>{let e=!1;for(const o of t){if("childList"===o.type&&o.addedNodes.length>0)for(let t=0;t<o.addedNodes.length;t++){const n=o.addedNodes[t];if(n.nodeType===Node.ELEMENT_NODE){const t=n;if(t.id||t.querySelector("[id]")){e=!0;break}}}if(e)break}E||n||R||I||z||!Z||!e||(o&&clearTimeout(o),o=setTimeout((()=>{n||R||I||z||!Z||r()}),200))})),e=()=>{E||n||R||I||z||!Z||(o&&clearTimeout(o),requestAnimationFrame((()=>{o=setTimeout((()=>{n||R||I||z||!Z||r()}),300)})))},t&&t.observe(document.body,{childList:!0,subtree:!0}),e&&window.addEventListener("scroll",e,{passive:!0}),r(),setTimeout((()=>{n||R||I||z||!Z||r()}),100),setTimeout((()=>{n||R||I||z||!Z||r()}),1e3),setTimeout((()=>{n||R||I||z||!Z||r()}),500),()=>{n=!0,t&&t.disconnect(),e&&window.removeEventListener("scroll",e),o&&clearTimeout(o)}}if(0===T.length||w){(null===(t=null==C?void 0:C.query)||void 0===t?void 0:t.featureId)&&I||(N(!1),P([]),F(null),$([]),H(!1))}}),[T,w,E,R,I,z,Z,v,X]);const ut=t=>{j(t);const o=k.findIndex((e=>e.id===t.id)),n=k.length,r=[{target:s.WHATS_NEW_BUTTON,content:e.jsx(l,{feature:t,currentIndex:o,totalFeatures:n,onSkip:()=>ct(t),onExplore:()=>pt(t),onPrevious:()=>ft(t),onNext:()=>bt(t),setIsClosing:et}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];V(r),O(!0)},ct=r((t=>{(t||B)&&(L(!0),k.forEach((t=>{v(t.id)})),O(!1),j(null),V([]),D(!0),setTimeout((()=>{L(!1)}),500))}),[B,k,v]),pt=r((t=>{L(!0),v(t.id),t.productVideo&&(Q(t.productVideo),J(!0),Y(!0)),O(!1),j(null),V([]);k.findIndex((e=>e.id===t.id))===k.length-1&&D(!0),setTimeout((()=>{L(!1)}),500)}),[k,v]),ft=r((t=>{const o=t||B;if(!o)return;const n=k.findIndex((t=>t.id===o.id));if(n>0){const t=k[n-1];j(t);const o=n-1,r=k.length,a=[{target:'[data-testid="whats-new-button"]',content:e.jsx(l,{feature:t,currentIndex:o,totalFeatures:r,onSkip:()=>ct(t),onExplore:()=>pt(t),onPrevious:()=>ft(t),onNext:()=>bt(t),setIsClosing:et}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];V(a)}}),[B,k]),bt=r((t=>{const o=t||B;if(!o)return;const n=k.findIndex((t=>t.id===o.id));if(n<k.length-1){const t=k[n+1];j(t);const o=n+1,r=k.length,a=[{target:'[data-testid="whats-new-button"]',content:e.jsx(l,{feature:t,currentIndex:o,totalFeatures:r,onSkip:()=>ct(t),onExplore:()=>pt(t),onPrevious:()=>ft(t),onNext:()=>bt(t),setIsClosing:et}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];V(a)}else L(!0),v(o.id),O(!1),j(null),V([]),D(!0),setTimeout((()=>{L(!1)}),500)}),[B,k,v]),mt=()=>{if(k.length>0&&!B){document.querySelector('[data-testid="whats-new-button"]')&&ut(k[0])}};n((()=>(window.showMajorUpdatePopup=mt,()=>{delete window.showMajorUpdatePopup})),[k,B]);const gt=r((t=>{const{action:e}=t;e===i.CLOSE&&(B&&(L(!0),k.forEach((t=>{v(t.id)})),D(!0),setTimeout((()=>{L(!1)}),500)),O(!1),j(null),V([]))}),[B,k,v]),ht=r((t=>{const{action:e}=t;if(e===i.CLOSE){if(I){A(!0),v(I.id);U.findIndex((t=>t.id===I.id))===U.length-1&&H(!0),setTimeout((()=>{A(!1)}),500)}N(!1),F(null),P([])}}),[I,U,v]),yt=(o,n)=>t(void 0,void 0,void 0,(function*(){F(o);const t=n||U,r=t.findIndex((t=>t.id===o.id)),a=t.length,i=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`,s=document.querySelector(i);if(s)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(s,120)}catch(t){}const d=[{target:i,content:e.jsx(u,{feature:o,currentIndex:r,totalFeatures:a,onSkip:()=>xt(o),onExplore:()=>Ct(o),onPrevious:()=>St(o),onNext:()=>kt(o),setIsClosing:nt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:o,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];P(d),N(!0)})),xt=r((t=>{const e=t||I;if(e){A(!0),v(e.id),lt((t=>new Set(t).add(e.id))),N(!1),F(null),P([]);const t=U.find((t=>t.id!==e.id&&!dt.has(t.id)));setTimeout((()=>{A(!1),t?yt(t,U):H(!0)}),500)}}),[I,U,v,dt]),Ct=r((t=>{A(!0),v(t.id),lt((e=>new Set(e).add(t.id))),t.productVideo&&(Q(t.productVideo),J(!0),Y(!0)),N(!1),F(null),P([]);const e=U.find((e=>e.id!==t.id&&!dt.has(e.id)));setTimeout((()=>{A(!1),e&&!t.productVideo?yt(e,U):e||H(!0)}),500)}),[U,v,dt]),St=r((o=>t(void 0,void 0,void 0,(function*(){const t=o||I;if(!t)return;const n=U.findIndex((e=>e.id===t.id));if(n>0){const t=U[n-1];F(t);const o=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`,r=document.querySelector(o);if(r)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(r,120)}catch(t){}const a=n-1,i=U.length,s=[{target:o,content:e.jsx(u,{feature:t,currentIndex:a,totalFeatures:i,onSkip:()=>xt(t),onExplore:()=>Ct(t),onPrevious:()=>St(t),onNext:()=>kt(t),setIsClosing:nt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];P(s)}}))),[I,U]),kt=r((o=>t(void 0,void 0,void 0,(function*(){const t=o||I;if(!t)return;const n=U.findIndex((e=>e.id===t.id));if(n<U.length-1){const t=U[n+1];F(t);const o=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`,r=document.querySelector(o);if(r)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(r,120)}catch(t){}const a=n+1,i=U.length,s=[{target:o,content:e.jsx(u,{feature:t,currentIndex:a,totalFeatures:i,onSkip:()=>xt(t),onExplore:()=>Ct(t),onPrevious:()=>St(t),onNext:()=>kt(t),setIsClosing:nt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];P(s)}else A(!0),H(!0),v(t.id),N(!1),F(null),P([]),setTimeout((()=>{A(!1)}),500)}))),[I,U,v]);return e.jsxs(e.Fragment,{children:[f,q.length>0&&e.jsx(a,{steps:q,run:M,continuous:!1,showProgress:!1,showSkipButton:!1,callback:gt,disableOverlayClose:!0,disableCloseOnEsc:!1,disableOverlay:!1,spotlightClicks:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:tt?"transparent":"#212121"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",border:"none",boxShadow:"none"},tooltip:{borderRadius:"16px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`major-joyride-${rt}`),W.length>0&&e.jsx(a,{steps:W,run:E,continuous:!1,showProgress:!1,showSkipButton:!1,callback:ht,disableOverlayClose:!0,disableCloseOnEsc:!1,disableOverlay:!1,scrollToFirstStep:!0,scrollOffset:120,disableScrolling:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:ot?"transparent":"#ffffff"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",borderRadius:"8px",boxShadow:ot?"none":"0 0 0 9999px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 20px 8px rgba(255, 255, 255, 0.4)"},tooltip:{borderRadius:"4px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonSkip:{display:"none"},buttonClose:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`minor-joyride-${it}`),e.jsx(c,{isOpen:G,videoUrl:K,onClose:()=>{J(!1),Q(""),Y(!1);const t=U.find((t=>!dt.has(t.id)));t?setTimeout((()=>{yt(t,U)}),300):H(!0)}})]})};export{p as default};
1
+ import{__awaiter as t}from"../../_virtual/_tslib.js";import{j as e}from"../../node_modules/react/jsx-runtime.js";import{useState as o,useEffect as n,useCallback as a}from"react";import r,{ACTIONS as i}from"react-joyride";import"./constants/animations.js";import{SELECTORS as s}from"./constants/selectors.js";import{useFeatureAnnouncements as l}from"./hooks/useFeatureAnnouncements.js";import d from"./MajorUpdatePopup.js";import u from"./MinorUpdatePopup.js";import{VideoModal as p}from"./VideoModal.js";const c=c=>{let{children:f,fetchVisibleFeatures:g,getStoreFeatureProgress:m,fetchFeatureById:b,markFeatureAsViewedForStore:h,isFeatureApplicableToCurrentPage:y,module:x,router:C}=c;var S;const{majorUpdateFeatures:k,minorUpdateFeatures:T,isLoading:w,markFeatureAsViewed:v}=l({fetchVisibleFeatures:g,getStoreFeatureProgress:m,fetchFeatureById:b,markFeatureAsViewedForStore:h,isFeatureApplicableToCurrentPage:y,module:x,router:C}),[B,j]=o(null),[F,E]=o(null),[I,N]=o(!1),[U,W]=o([]),[P,q]=o(!1),[M,O]=o([]),[D,A]=o(!1),[V,G]=o(!1),[L,R]=o([]),[_,$]=o(!1),[z,H]=o(!1),[Z,J]=o(!1),[K,Q]=o(""),[X,Y]=o(!1),[tt,et]=o(!1),[ot,nt]=o(!1),[at,rt]=o(0),[it,st]=o(0),[lt,dt]=o(new Set);n((()=>{const t="minor-spotlight-cutout-style";let e=document.getElementById(t);return e||(e=document.createElement("style"),e.id=t,document.head.appendChild(e)),e.textContent="\n\t\t\t.react-joyride__spotlight {\n\t\t\t\ttransition: box-shadow 0.3s ease-in-out !important;\n\t\t\t\twill-change: box-shadow, transform;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t\t.react-joyride__tooltip {\n\t\t\t\twill-change: transform, opacity;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t",()=>{const e=document.getElementById(t);e&&e.remove()}}),[]),n((()=>{rt((t=>t+1)),st((t=>t+1)),et(!1),nt(!1),dt(new Set)}),[null==C?void 0:C.pathname]),n((()=>{if(console.log("🔍 [DEBUG] Route check:",{pathname:null==C?void 0:C.pathname,query:null==C?void 0:C.query,majorFeaturesCount:k.length,minorFeaturesCount:T.length,currentMajorFeature:null==B?void 0:B.id,isLoading:w,blockPopups:X,isProcessingMajorUpdate:D}),k.length>0)if(console.log("🔍 [DEBUG] First major feature details:",{featureId:k[0].id,title:k[0].title,featureUpdateType:k[0].featureUpdateType}),y){const t=y(k[0]);console.log("🔍 [DEBUG] Is major feature applicable to current page?",t)}else console.log("🔍 [DEBUG] isFeatureApplicableToCurrentPage function not provided");const t=document.querySelector('[data-testid="whats-new-button"]');console.log("🔍 [DEBUG] What's New button exists in DOM?",!!t)}),[null==C?void 0:C.pathname,null==C?void 0:C.query,k,T,w,B,X,D,y]),n((()=>{if(!(k.length>0)||B||w||D||X)0!==k.length||w||(console.log("🔍 [DEBUG] No major features, enabling minor updates"),H(!0));else{console.log("🔍 [DEBUG] Starting major popup flow..."),H(!1),$(!1),N(!1),W([]),E(null),R([]);let t=0;const e=10,o=()=>{t++;const n=document.querySelector('[data-testid="whats-new-button"]');console.log(`🔍 [DEBUG] Polling for What's New button - Attempt ${t}/${e}`,{buttonFound:!!n,pathname:null==C?void 0:C.pathname}),n?(console.log("✅ [DEBUG] What's New button found! Showing major popup"),ut(k[0])):t<e?setTimeout(o,1e3):(console.warn("⚠️ [DEBUG] What's New button not found after 10s. Allowing minor updates.",{pathname:null==C?void 0:C.pathname}),H(!0))};o()}}),[k,B,w,D,X]),n((()=>{var t;const e=null===(t=null==C?void 0:C.query)||void 0===t?void 0:t.featureId;if(!e||w||0===T.length)return;const o=T.find((t=>t.id===e));if(!o||!o.featureTag)return;$(!0),G(!0);let n=0;const a=setInterval((()=>{n++;const t=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`;if(document.querySelector(t)){const t=[o];R(t),yt(o,t),clearInterval(a)}else n>=25&&(G(!1),clearInterval(a))}),200);return()=>{clearInterval(a)}}),[T,null===(S=null==C?void 0:C.query)||void 0===S?void 0:S.featureId,w]),n((()=>{var t;if(T.length>0&&!w&&!I&&!V&&!F&&!_&&z&&!X){let t=null,e=null,o=null,n=!1;const a=()=>{if(n||V||F||_||!z)return;const a=T.filter((t=>{if(!t.featureTag||""===t.featureTag.trim())return!1;if(lt.has(t.id))return!1;const e=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`;return null!==document.querySelector(e)}));a.length>0&&(R(a),yt(a[0],a),t&&(t.disconnect(),t=null),e&&(window.removeEventListener("scroll",e),e=null),o&&(clearTimeout(o),o=null))};return t=new MutationObserver((t=>{let e=!1;for(const o of t){if("childList"===o.type&&o.addedNodes.length>0)for(let t=0;t<o.addedNodes.length;t++){const n=o.addedNodes[t];if(n.nodeType===Node.ELEMENT_NODE){const t=n;if(t.id||t.querySelector("[id]")){e=!0;break}}}if(e)break}I||n||V||F||_||!z||!e||(o&&clearTimeout(o),o=setTimeout((()=>{n||V||F||_||!z||a()}),200))})),e=()=>{I||n||V||F||_||!z||(o&&clearTimeout(o),requestAnimationFrame((()=>{o=setTimeout((()=>{n||V||F||_||!z||a()}),300)})))},t&&t.observe(document.body,{childList:!0,subtree:!0}),e&&window.addEventListener("scroll",e,{passive:!0}),a(),setTimeout((()=>{n||V||F||_||!z||a()}),100),setTimeout((()=>{n||V||F||_||!z||a()}),1e3),setTimeout((()=>{n||V||F||_||!z||a()}),500),()=>{n=!0,t&&t.disconnect(),e&&window.removeEventListener("scroll",e),o&&clearTimeout(o)}}if(0===T.length||w){(null===(t=null==C?void 0:C.query)||void 0===t?void 0:t.featureId)&&F||(N(!1),W([]),E(null),R([]),$(!1))}}),[T,w,I,V,F,_,z,v,X]);const ut=t=>{j(t);const o=k.findIndex((e=>e.id===t.id)),n=k.length,a=[{target:s.WHATS_NEW_BUTTON,content:e.jsx(d,{feature:t,currentIndex:o,totalFeatures:n,onSkip:()=>pt(t),onExplore:()=>ct(t),onPrevious:()=>ft(t),onNext:()=>gt(t),setIsClosing:et}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];O(a),q(!0)},pt=a((t=>{(t||B)&&(A(!0),k.forEach((t=>{v(t.id)})),q(!1),j(null),O([]),H(!0),setTimeout((()=>{A(!1)}),500))}),[B,k,v]),ct=a((t=>{A(!0),v(t.id),t.productVideo&&(Q(t.productVideo),J(!0),Y(!0)),q(!1),j(null),O([]);k.findIndex((e=>e.id===t.id))===k.length-1&&H(!0),setTimeout((()=>{A(!1)}),500)}),[k,v]),ft=a((t=>{const o=t||B;if(!o)return;const n=k.findIndex((t=>t.id===o.id));if(n>0){const t=k[n-1];j(t);const o=n-1,a=k.length,r=[{target:'[data-testid="whats-new-button"]',content:e.jsx(d,{feature:t,currentIndex:o,totalFeatures:a,onSkip:()=>pt(t),onExplore:()=>ct(t),onPrevious:()=>ft(t),onNext:()=>gt(t),setIsClosing:et}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];O(r)}}),[B,k]),gt=a((t=>{const o=t||B;if(!o)return;const n=k.findIndex((t=>t.id===o.id));if(n<k.length-1){const t=k[n+1];j(t);const o=n+1,a=k.length,r=[{target:'[data-testid="whats-new-button"]',content:e.jsx(d,{feature:t,currentIndex:o,totalFeatures:a,onSkip:()=>pt(t),onExplore:()=>ct(t),onPrevious:()=>ft(t),onNext:()=>gt(t),setIsClosing:et}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];O(r)}else A(!0),v(o.id),q(!1),j(null),O([]),H(!0),setTimeout((()=>{A(!1)}),500)}),[B,k,v]),mt=()=>{if(k.length>0&&!B){document.querySelector('[data-testid="whats-new-button"]')&&ut(k[0])}};n((()=>(window.showMajorUpdatePopup=mt,()=>{delete window.showMajorUpdatePopup})),[k,B]);const bt=a((t=>{const{action:e}=t;e===i.CLOSE&&(B&&(A(!0),k.forEach((t=>{v(t.id)})),H(!0),setTimeout((()=>{A(!1)}),500)),q(!1),j(null),O([]))}),[B,k,v]),ht=a((t=>{const{action:e}=t;if(e===i.CLOSE){if(F){G(!0),v(F.id);L.findIndex((t=>t.id===F.id))===L.length-1&&$(!0),setTimeout((()=>{G(!1)}),500)}N(!1),E(null),W([])}}),[F,L,v]),yt=(o,n)=>t(void 0,void 0,void 0,(function*(){E(o);const t=n||L,a=t.findIndex((t=>t.id===o.id)),r=t.length,i=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`,s=document.querySelector(i);if(s)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(s,120)}catch(t){}const l=[{target:i,content:e.jsx(u,{feature:o,currentIndex:a,totalFeatures:r,onSkip:()=>xt(o),onExplore:()=>Ct(o),onPrevious:()=>St(o),onNext:()=>kt(o),setIsClosing:nt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:o,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];W(l),N(!0)})),xt=a((t=>{const e=t||F;if(e){G(!0),v(e.id),dt((t=>new Set(t).add(e.id))),N(!1),E(null),W([]);const t=L.find((t=>t.id!==e.id&&!lt.has(t.id)));setTimeout((()=>{G(!1),t?yt(t,L):$(!0)}),500)}}),[F,L,v,lt]),Ct=a((t=>{G(!0),v(t.id),dt((e=>new Set(e).add(t.id))),t.productVideo&&(Q(t.productVideo),J(!0),Y(!0)),N(!1),E(null),W([]);const e=L.find((e=>e.id!==t.id&&!lt.has(e.id)));setTimeout((()=>{G(!1),e&&!t.productVideo?yt(e,L):e||$(!0)}),500)}),[L,v,lt]),St=a((o=>t(void 0,void 0,void 0,(function*(){const t=o||F;if(!t)return;const n=L.findIndex((e=>e.id===t.id));if(n>0){const t=L[n-1];E(t);const o=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`,a=document.querySelector(o);if(a)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(a,120)}catch(t){}const r=n-1,i=L.length,s=[{target:o,content:e.jsx(u,{feature:t,currentIndex:r,totalFeatures:i,onSkip:()=>xt(t),onExplore:()=>Ct(t),onPrevious:()=>St(t),onNext:()=>kt(t),setIsClosing:nt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];W(s)}}))),[F,L]),kt=a((o=>t(void 0,void 0,void 0,(function*(){const t=o||F;if(!t)return;const n=L.findIndex((e=>e.id===t.id));if(n<L.length-1){const t=L[n+1];E(t);const o=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`,a=document.querySelector(o);if(a)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(a,120)}catch(t){}const r=n+1,i=L.length,s=[{target:o,content:e.jsx(u,{feature:t,currentIndex:r,totalFeatures:i,onSkip:()=>xt(t),onExplore:()=>Ct(t),onPrevious:()=>St(t),onNext:()=>kt(t),setIsClosing:nt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];W(s)}else G(!0),$(!0),v(t.id),N(!1),E(null),W([]),setTimeout((()=>{G(!1)}),500)}))),[F,L,v]);return e.jsxs(e.Fragment,{children:[f,M.length>0&&e.jsx(r,{steps:M,run:P,continuous:!1,showProgress:!1,showSkipButton:!1,callback:bt,disableOverlayClose:!0,disableCloseOnEsc:!1,disableOverlay:!1,spotlightClicks:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:tt?"transparent":"#212121"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",border:"none",boxShadow:"none"},tooltip:{borderRadius:"16px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`major-joyride-${at}`),U.length>0&&e.jsx(r,{steps:U,run:I,continuous:!1,showProgress:!1,showSkipButton:!1,callback:ht,disableOverlayClose:!0,disableCloseOnEsc:!1,disableOverlay:!1,scrollToFirstStep:!0,scrollOffset:120,disableScrolling:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:ot?"transparent":"#ffffff"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",borderRadius:"8px",boxShadow:ot?"none":"0 0 0 9999px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 20px 8px rgba(255, 255, 255, 0.4)"},tooltip:{borderRadius:"4px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonSkip:{display:"none"},buttonClose:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`minor-joyride-${it}`),e.jsx(p,{isOpen:Z,videoUrl:K,onClose:()=>{J(!1),Q(""),Y(!1);const t=L.find((t=>!lt.has(t.id)));t?setTimeout((()=>{yt(t,L)}),300):$(!0)}})]})};export{c as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import{useState as t,useCallback as r,useEffect as o}from"react";import{ANIMATION_TIMING as a}from"../constants/animations.js";import{QUERY_PARAMS as n,LOCAL_STORAGE_KEYS as i}from"../constants/localStorageKeys.js";const l=l=>{let{fetchVisibleFeatures:s,getStoreFeatureProgress:u,fetchFeatureById:d,markFeatureAsViewedForStore:c,isFeatureApplicableToCurrentPage:f,module:p,router:m}=l;var g;const v=(()=>{const[e,r]=t(null);return o((()=>{if("undefined"!=typeof window){let e=null;try{if(e=localStorage.getItem(i.STORE_ID)||localStorage.getItem(i.BIK_STORE_ID)||localStorage.getItem(i.CURRENT_STORE)||localStorage.getItem(i.STORE),!e){const t=localStorage.getItem(i.CURRENT_USER);t&&(e=JSON.parse(t).storeId)}e||(e=new URLSearchParams(window.location.search).get(i.QUERY_PARAM))}catch(e){console.error("FeatureAnnouncements: Failed to get store ID",e)}r(e)}}),[]),e})(),[y,F]=t([]),[D,w]=t([]),[U,h]=t([]),[A,I]=t(!1),[R,S]=t(null),T=r((()=>e(void 0,void 0,void 0,(function*(){if(v){I(!0),S(null);try{const[e,t]=yield s(p);if(e||!t)return console.error("FeatureAnnouncements: Failed to fetch features",e),void S("Failed to fetch features");const[r,o]=yield u(v);r&&console.warn("FeatureAnnouncements: Progress fetch failed, treating all features as new",r);const n=new Date,i="undefined"!=typeof window?window.location.pathname:"",l=e=>{if(!e.expirationDate)return!0;let t;return"object"==typeof e.expirationDate&&null!==e.expirationDate&&("seconds"in e.expirationDate||"nanoseconds"in e.expirationDate)?t=new Date(1e3*e.expirationDate.seconds):"string"==typeof e.expirationDate?t=new Date(e.expirationDate):e.expirationDate instanceof Date&&(t=e.expirationDate),!(!t||isNaN(t.getTime()))&&n<t},d=e=>{if("Major"===e.featureUpdateType){let t=[];return Array.isArray(e.pageUrls)?t=e.pageUrls:"object"==typeof e.pageUrls&&null!==e.pageUrls&&"length"in e.pageUrls&&(t=Array.from(e.pageUrls)),t.includes(i)}return!0},c=t.filter((e=>{var t;const r=(null===(t=null==o?void 0:o.viewedFeatures)||void 0===t?void 0:t[e.id])||!1,a=e.archived||!1;return!r&&!a&&f(e)&&l(e)&&d(e)})),m=c.filter((e=>"Major"===e.featureUpdateType)),g=c.filter((e=>"Minor"===e.featureUpdateType));F(c),w(m),setTimeout((()=>{h(g)}),a.MINOR_POPUP_DELAY)}catch(e){console.error("FeatureAnnouncements: Unexpected error in fetchFeatures",e),S("An unexpected error occurred")}finally{I(!1)}}}))),[v,s,u,f,p]),x=r((t=>e(void 0,void 0,void 0,(function*(){I(!0),S(null);try{const[e,r]=yield d(t);if(e||!r)return void S("Failed to fetch feature by ID");"Major"===r.featureUpdateType?w([r]):h([r]),F([r])}catch(e){S("An unexpected error occurred while fetching by ID")}finally{I(!1)}}))),[d]),E=r((t=>e(void 0,void 0,void 0,(function*(){if(!v)return;const[e]=yield c(v,t);e?(console.warn("FeatureAnnouncements: Failed to mark feature as viewed, removing from local state anyway",e),F((e=>e.filter((e=>e.id!==t)))),w((e=>e.filter((e=>e.id!==t)))),h((e=>e.filter((e=>e.id!==t))))):(F((e=>e.filter((e=>e.id!==t)))),w((e=>e.filter((e=>e.id!==t)))),h((e=>e.filter((e=>e.id!==t)))))}))),[v,c]);return o((()=>{var e;const t=null===(e=null==m?void 0:m.query)||void 0===e?void 0:e[n.FEATURE_ID];t&&m?x(t):T()}),[null==m?void 0:m.pathname,null===(g=null==m?void 0:m.query)||void 0===g?void 0:g[n.FEATURE_ID],v,T,x,m]),{features:y,majorUpdateFeatures:D,minorUpdateFeatures:U,isLoading:A,error:R,markFeatureAsViewed:E,refetch:T}};export{l as useFeatureAnnouncements};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{useState as t,useCallback as r,useEffect as o}from"react";import{ANIMATION_TIMING as a}from"../constants/animations.js";import{QUERY_PARAMS as n,LOCAL_STORAGE_KEYS as i}from"../constants/localStorageKeys.js";const l=l=>{let{fetchVisibleFeatures:s,getStoreFeatureProgress:u,fetchFeatureById:c,markFeatureAsViewedForStore:d,isFeatureApplicableToCurrentPage:f,module:p,router:g}=l;var m;const v=(()=>{const[e,r]=t(null);return o((()=>{if("undefined"!=typeof window){let e=null;try{if(e=localStorage.getItem(i.STORE_ID)||localStorage.getItem(i.BIK_STORE_ID)||localStorage.getItem(i.CURRENT_STORE)||localStorage.getItem(i.STORE),!e){const t=localStorage.getItem(i.CURRENT_USER);t&&(e=JSON.parse(t).storeId)}e||(e=new URLSearchParams(window.location.search).get(i.QUERY_PARAM))}catch(e){console.error("FeatureAnnouncements: Failed to get store ID",e)}r(e)}}),[]),e})(),[y,U]=t([]),[w,F]=t([]),[D,h]=t([]),[A,I]=t(!1),[R,E]=t(null),T=r((()=>e(void 0,void 0,void 0,(function*(){if(v){I(!0),E(null);try{const[e,t]=yield s(p);if(e||!t)return console.error("FeatureAnnouncements: Failed to fetch features",e),void E("Failed to fetch features");const[r,o]=yield u(v);r&&console.warn("FeatureAnnouncements: Progress fetch failed, treating all features as new",r);const n=new Date,i="undefined"!=typeof window?window.location.pathname:"",l=e=>{if(!e.expirationDate)return!0;let t;return"object"==typeof e.expirationDate&&null!==e.expirationDate&&("seconds"in e.expirationDate||"nanoseconds"in e.expirationDate)?t=new Date(1e3*e.expirationDate.seconds):"string"==typeof e.expirationDate?t=new Date(e.expirationDate):e.expirationDate instanceof Date&&(t=e.expirationDate),!(!t||isNaN(t.getTime()))&&n<t},c=e=>{if("Major"===e.featureUpdateType){let t=[];return Array.isArray(e.pageUrls)?t=e.pageUrls:"object"==typeof e.pageUrls&&null!==e.pageUrls&&"length"in e.pageUrls&&(t=Array.from(e.pageUrls)),t.some((e=>{if(e===i)return!0;const t=e.replace(/\[([^\]]+)\]/g,"[^/]+").replace(/\//g,"\\/");return new RegExp(`^${t}$`).test(i)}))}return!0},d=t.filter((e=>{var t;const r=(null===(t=null==o?void 0:o.viewedFeatures)||void 0===t?void 0:t[e.id])||!1,a=e.archived||!1,n=f(e),s=l(e),u=c(e),d=!r&&!a&&n&&s&&u;return"Major"===e.featureUpdateType&&console.log("🔍 [FILTER DEBUG] Major feature:",{featureId:e.id,title:e.title,pageUrls:e.pageUrls,currentRoute:i,isViewed:r,isArchived:a,isApplicable:n,notExpired:s,onCorrectPage:u,shouldShow:d}),d})),g=d.filter((e=>"Major"===e.featureUpdateType)),m=d.filter((e=>"Minor"===e.featureUpdateType));U(d),F(g),setTimeout((()=>{h(m)}),a.MINOR_POPUP_DELAY)}catch(e){console.error("FeatureAnnouncements: Unexpected error in fetchFeatures",e),E("An unexpected error occurred")}finally{I(!1)}}}))),[v,s,u,f,p]),x=r((t=>e(void 0,void 0,void 0,(function*(){I(!0),E(null);try{const[e,r]=yield c(t);if(e||!r)return void E("Failed to fetch feature by ID");"Major"===r.featureUpdateType?F([r]):h([r]),U([r])}catch(e){E("An unexpected error occurred while fetching by ID")}finally{I(!1)}}))),[c]),S=r((t=>e(void 0,void 0,void 0,(function*(){if(!v)return;const[e]=yield d(v,t);e?(console.warn("FeatureAnnouncements: Failed to mark feature as viewed, removing from local state anyway",e),U((e=>e.filter((e=>e.id!==t)))),F((e=>e.filter((e=>e.id!==t)))),h((e=>e.filter((e=>e.id!==t))))):(U((e=>e.filter((e=>e.id!==t)))),F((e=>e.filter((e=>e.id!==t)))),h((e=>e.filter((e=>e.id!==t)))))}))),[v,d]);return o((()=>{var e;const t=null===(e=null==g?void 0:g.query)||void 0===e?void 0:e[n.FEATURE_ID];t&&g?x(t):T()}),[null==g?void 0:g.pathname,null===(m=null==g?void 0:g.query)||void 0===m?void 0:m[n.FEATURE_ID],v,T,x,g]),{features:y,majorUpdateFeatures:w,minorUpdateFeatures:D,isLoading:A,error:R,markFeatureAsViewed:S,refetch:T}};export{l as useFeatureAnnouncements};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.725-beta.2",
3
+ "version": "0.0.725-beta.4",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",