@anker-in/headless-ui 1.3.75 → 1.3.76

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.
@@ -89,7 +89,7 @@ interface AiuiContextType {
89
89
  /**
90
90
  * 设置导航折叠状态。仅供 HeaderNavigation 内部写入,消费方无需关心。
91
91
  */
92
- setNavCollapsed?: (_collapsed: boolean) => void;
92
+ setNavCollapsed?: (_collapsed: boolean | undefined) => void;
93
93
  }
94
94
  export declare const AiuiContext: React.Context<AiuiContextType>;
95
95
  export declare const useAiuiContext: () => AiuiContextType;
@@ -1 +1 @@
1
- "use strict";"use client";var d=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var M=(a,e)=>{for(var i in e)d(a,i,{get:e[i],enumerable:!0})},P=(a,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of T(e))!_.call(a,o)&&o!==i&&d(a,o,{get:()=>e[o],enumerable:!(c=D(e,o))||c.enumerable});return a};var R=a=>P(d({},"__esModule",{value:!0}),a);var S={};M(S,{AiuiContext:()=>m,default:()=>O,useAiuiContext:()=>L});module.exports=R(S);var g=require("react/jsx-runtime"),h=require("../../shared/track.js"),t=require("react"),k=require("../../helpers/index.js");const m=(0,t.createContext)({trackingData:{},locale:void 0,copyWriting:{}}),L=()=>{const a=(0,t.useContext)(m);if(!a)throw new Error("useAiui must be used in <AiuiProvider>");return a},N=({children:a,...e})=>{const i=(0,t.useRef)(null),c=(0,t.useRef)(e?.trackingData),[o,x]=(0,t.useState)(!1);(0,t.useEffect)(()=>{e.localeMap&&Object.keys(e.localeMap).length>0&&(0,k.extendLocaleMap)(e.localeMap)},[e.localeMap]),(0,t.useEffect)(()=>{c.current=e?.trackingData},[e?.trackingData]),(0,t.useEffect)(()=>{const p=i.current;if(!p)return;const y=(n,r)=>{const s={};if(!r||!r.attributes)return s;for(const E of Array.from(r.attributes)){const u=E?.name;u?.startsWith("data-headless-")&&(s[u]=r.getAttribute(u))}const A=s?.["data-headless-sku"],b=s?.["data-headless-type-name"]?.split?.("#"),l=s?.["data-headless-title-desc-button"]?.split?.("#"),f=s?.["data-headless-nav-position"]?.split?.("#");(0,h.gaTrack)({event:"ga4Event",event_name:"component_click",event_parameters:{page_group:c.current?.pageGroup||"Home Page",component_type:b?.[0]||"",component_name:b?.[1]||"",position:f?.[1]||"",navigation:f?.[0]||"",button_name:l?.[2]||"",SKU:A||"",component_title:l?.[0]||"",component_description:l?.[1]||""}})},v=new MutationObserver(()=>{p.querySelectorAll("[data-headless-type-name]").forEach(n=>{n.hasAttribute("data-headless-track-bound")||(n.addEventListener("click",r=>y(r,n)),n.setAttribute("data-headless-track-bound","true"))})});return v.observe(p,{childList:!0,subtree:!0}),p.querySelectorAll("[data-headless-type-name]").forEach(n=>{n.hasAttribute("data-headless-track-bound")||(n.addEventListener("click",r=>y(r,n)),n.setAttribute("data-headless-track-bound","true"))}),()=>v.disconnect()},[]);const C=(0,t.useMemo)(()=>({...e,navCollapsed:o,setNavCollapsed:x}),[e,o]);return(0,g.jsx)(m.Provider,{value:C,children:(0,g.jsx)("div",{ref:i,children:a})})};var O=N;
1
+ "use strict";"use client";var d=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var M=(n,e)=>{for(var i in e)d(n,i,{get:e[i],enumerable:!0})},P=(n,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of T(e))!_.call(n,o)&&o!==i&&d(n,o,{get:()=>e[o],enumerable:!(c=D(e,o))||c.enumerable});return n};var R=n=>P(d({},"__esModule",{value:!0}),n);var S={};M(S,{AiuiContext:()=>m,default:()=>O,useAiuiContext:()=>L});module.exports=R(S);var g=require("react/jsx-runtime"),h=require("../../shared/track.js"),t=require("react"),k=require("../../helpers/index.js");const m=(0,t.createContext)({trackingData:{},locale:void 0,copyWriting:{}}),L=()=>{const n=(0,t.useContext)(m);if(!n)throw new Error("useAiui must be used in <AiuiProvider>");return n},N=({children:n,...e})=>{const i=(0,t.useRef)(null),c=(0,t.useRef)(e?.trackingData),[o,x]=(0,t.useState)(void 0);(0,t.useEffect)(()=>{e.localeMap&&Object.keys(e.localeMap).length>0&&(0,k.extendLocaleMap)(e.localeMap)},[e.localeMap]),(0,t.useEffect)(()=>{c.current=e?.trackingData},[e?.trackingData]),(0,t.useEffect)(()=>{const p=i.current;if(!p)return;const y=(a,r)=>{const s={};if(!r||!r.attributes)return s;for(const E of Array.from(r.attributes)){const l=E?.name;l?.startsWith("data-headless-")&&(s[l]=r.getAttribute(l))}const A=s?.["data-headless-sku"],v=s?.["data-headless-type-name"]?.split?.("#"),u=s?.["data-headless-title-desc-button"]?.split?.("#"),b=s?.["data-headless-nav-position"]?.split?.("#");(0,h.gaTrack)({event:"ga4Event",event_name:"component_click",event_parameters:{page_group:c.current?.pageGroup||"Home Page",component_type:v?.[0]||"",component_name:v?.[1]||"",position:b?.[1]||"",navigation:b?.[0]||"",button_name:u?.[2]||"",SKU:A||"",component_title:u?.[0]||"",component_description:u?.[1]||""}})},f=new MutationObserver(()=>{p.querySelectorAll("[data-headless-type-name]").forEach(a=>{a.hasAttribute("data-headless-track-bound")||(a.addEventListener("click",r=>y(r,a)),a.setAttribute("data-headless-track-bound","true"))})});return f.observe(p,{childList:!0,subtree:!0}),p.querySelectorAll("[data-headless-type-name]").forEach(a=>{a.hasAttribute("data-headless-track-bound")||(a.addEventListener("click",r=>y(r,a)),a.setAttribute("data-headless-track-bound","true"))}),()=>f.disconnect()},[]);const C=(0,t.useMemo)(()=>({...e,navCollapsed:o,setNavCollapsed:x}),[e,o]);return(0,g.jsx)(m.Provider,{value:C,children:(0,g.jsx)("div",{ref:i,children:n})})};var O=N;
@@ -1 +1 @@
1
- "use strict";"use client";var Be=Object.create;var ie=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var je=(t,o)=>{for(var i in o)ie(t,i,{get:o[i],enumerable:!0})},pe=(t,o,i,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let u of Ie(o))!Oe.call(t,u)&&u!==i&&ie(t,u,{get:()=>o[u],enumerable:!(c=ze(o,u))||c.enumerable});return t};var le=(t,o,i)=>(i=t!=null?Be(Ae(t)):{},pe(o||!t||!t.__esModule?ie(i,"default",{value:t,enumerable:!0}):i,t)),_e=t=>pe(ie({},"__esModule",{value:!0}),t);var Ge={};je(Ge,{default:()=>Fe});module.exports=_e(Ge);var e=require("react/jsx-runtime"),a=require("react"),s=require("../../components/index.js"),xe=require("../../shared/Styles.js"),v=require("../../helpers/utils.js"),K=le(require("./NavProvider.js")),r=require("./types.js"),Ce=le(require("jump.js")),se=require("@gsap/react"),te=require("gsap"),M=require("./withCategory.js"),w=require("./icons/index.js"),we=le(require("../NavigationSearch/index.js")),Me=require("./ResourceSidebarDropdown.js"),Se=require("./MobileResourceSidebarMenu.js"),Te=require("./SidebarDropdown.js"),ce=require("./useScrollLock.js"),De=require("./MulticolDropdown.js"),Le=require("./SupportsDropdown.js"),Pe=require("./MobileSidebarMenu.js"),Ee=require("./MobileSupportMenu.js"),He=require("./MobileMulticolMenu.js"),ue=require("./MobileMenuComponents.js"),q=require("../AiuiProvider/index.js"),me=le(require("../../shared/throttle.js")),Re=require("./useNavCollapse.js");const fe=t=>!!t?.components?.length&&t?.components?.[0]?.blockType!==r.HeaderNavigationBlockType.Links,be=t=>t?.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links&&t?.components?.[0]?.url||t?.url||void 0,ve=t=>t?.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links&&t?.components?.[0]?.target||t?.target,$e=({groupCategories:t})=>(0,e.jsx)("div",{className:"pointer-events-none invisible absolute inset-x-0 top-0 overflow-hidden","aria-hidden":"true",children:(0,e.jsx)(s.Container,{className:"h-[92px]",children:(0,e.jsx)("nav",{className:"flex h-full items-end justify-between",children:t?.map((o,i)=>(0,e.jsx)("div",{className:"flex gap-3","data-nav-item":!0,children:o?.map(c=>(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(s.Text,{html:c.text,"data-nav-item-label":!0,className:"desktop:text-pretty text-nowrap text-sm font-bold leading-[1.4]"}),fe(c)&&(0,e.jsx)(w.DownArrow,{className:"size-4 opacity-0","aria-hidden":"true"})]},c.id))},`measure-group-${i}`))})})}),ge=(0,a.forwardRef)((t,o)=>{const{data:{header:i}={},buildProps:c,event:u,profile:P,theme:m="light",isTop:l=!1,searchResult:p,onSearch:f,isSearching:b,keywords:E,onPrimaryNavClick:T,onSeriesProductClick:y,onSidebarNavClick:D,onMobileMenuToggle:F,headerId:S,cartCount:H,menuData:B,render:z,componentOverrides:G,...U}=t,[k,I]=(0,a.useState)(!1),[g,A]=(0,a.useState)(!1),[J,O]=(0,a.useState)(!1),L=(0,a.useRef)(null),d=(0,a.useRef)(null),_=(0,a.useMemo)(()=>(0,M.WithGroupCategory)(i?.categories?.filter(x=>x?.pcShow)),[i]),R=(0,Re.useNavCollapse)(d),{setNavCollapsed:ae}=(0,q.useAiuiContext)();(0,a.useEffect)(()=>{ae?.(R)},[R,ae]),(0,a.useImperativeHandle)(o,()=>d.current),(0,a.useEffect)(()=>{d.current&&l&&(0,Ce.default)(d.current,{duration:0,offset:d.current?.getBoundingClientRect()?.bottom||0})},[l]),(0,a.useEffect)(()=>{if(l){A(!1),O(!1);return}let x=0,Y=0,V=0;const re=()=>document?.documentElement?.scrollTop||document?.body?.scrollTop||0,W=re();x=W,A(W>300),O(W>30);const j=(0,me.default)(()=>{const $=re(),n=$-x;O($>30),n>0?(Y=0,V+=n,V>=300&&$>300&&A(!0)):n<0&&(V=0,Y+=Math.abs(n),Y>=300&&(A(!1),Y=0)),x=$},100);return window.addEventListener("scroll",j,{passive:!0}),()=>window.removeEventListener("scroll",j)},[l]),(0,a.useEffect)(()=>{u&&(u.search=()=>I(!0))},[u]),(0,se.useGSAP)(()=>{L?.current&&k&&te.gsap.fromTo(L.current,{height:0},{height:"auto",duration:.3})},[k]),(0,ce.useScrollLock)(k);const Q=(0,a.useMemo)(()=>i?.bar?.actions?.find(x=>x?.blockType===r.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[i]),ne=z?.mobileHeaderNavigation;return(0,e.jsx)(K.default,{buildProps:c,profile:P,isMobile:R,event:u,payloadData:i,onSidebarNavClick:D,onSeriesProductClick:y,cartCount:H,componentOverrides:G,children:(0,e.jsx)("header",{...U,id:S||"header","data-ui-component-id":"HeaderNavigation",className:l?"relative z-[100] bg-white":(0,v.cn)("sticky top-0 z-[100] transition-transform duration-500 ease-in-out",{"translate-y-[-100%]":g}),ref:d,children:(0,e.jsxs)("div",{className:(0,v.cn)("hover:bg-white hover:text-black",m==="light"?"text-black":"text-white",{"!bg-white transition-all duration-500 ease-in-out":!l&&J},{"hover:!text-black":m==="dark","!text-black":!l&&J}),onClick:()=>!l&&O(!0),children:[(0,e.jsx)($e,{groupCategories:_}),(0,e.jsx)("div",{className:(0,v.cn)("hidden",R?"laptop:hidden":"laptop:block","desktop:block"),children:(0,e.jsx)(he,{data:i,groupCategories:_,theme:m,onNavItemClick:()=>!l&&O(!0),onPrimaryNavClick:T,className:"!bg-white"})}),(0,e.jsx)("div",{className:(0,v.cn)("block",R?"laptop:block":"laptop:hidden","desktop:hidden"),children:ne?(0,e.jsx)(ne,{menuData:B,data:i,onPrimaryNavClick:T}):(0,e.jsx)(ye,{menuData:B,data:i,onPrimaryNavClick:T,onMobileMenuToggle:F,className:"!bg-white"})}),k&&(0,e.jsxs)("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${d?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[(0,e.jsx)("div",{ref:L,className:(0,v.cn)("overflow-y-auto",{}),children:(0,e.jsx)(we.default,{data:Q,keywords:E,isSearching:b,searchResult:p,onSearch:x=>{f?.(x)},onClose:()=>{f?.(),I(!1)}})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>I(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:x=>{(x.key==="Enter"||x.key===" "||x.key==="Escape")&&(x.preventDefault(),I(!1))}})]})]})})})}),he=(0,a.forwardRef)((t,o)=>{const{data:i,onNavItemClick:c,className:u,theme:P,onPrimaryNavClick:m,groupCategories:l}=t,{event:p,profile:f}=(0,K.useNavContext)(),[b,E]=(0,a.useState)(!1),{locale:T="us"}=(0,q.useAiuiContext)(),[y,D]=(0,a.useState)(null),[F,S]=(0,a.useState)([]),H=(0,a.useRef)(null),[B,z]=(0,a.useState)(!1),G=(0,a.useRef)(null),U=(0,a.useRef)(null),k=(0,a.useRef)(null),I=(0,a.useRef)(l.map(n=>Array(n?.length||0).fill(null)));(0,a.useEffect)(()=>{l?.length&&S(l?.map((n,h)=>n?.map((N,C)=>({groupIndex:h,index:C,open:!1}))))},[l]);const g=(0,a.useMemo)(()=>{let n=null;for(const h of F){for(const N of h)if(N.open){n=N;break}if(n)break}return n},[F]);(0,ce.useScrollLock)(!!g?.open||B);const A=(n,h)=>{z(!1),c?.();const N=l?.flat()||[],C=N?.findIndex(X=>X?.id===l[n][h]?.id);m?.(N[C],C)},J=(n,h)=>{const N=l[n][h],C=N?.components?.[0];C&&C?.blockType!==r.HeaderNavigationBlockType.Links&&(D(N),S(Z=>Z.map(ee=>ee.map(oe=>oe.groupIndex===n&&oe.index===h?{...oe,open:!0}:{...oe,open:!1}))))},O=(n,h,N)=>{n.key==="Escape"&&g?.groupIndex===h&&g?.index===N&&(n.preventDefault(),L())},L=()=>{S(n=>n.map(h=>h.map(N=>({...N,open:!1}))))},d=()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{L()},200)},_=()=>{k.current&&clearTimeout(k.current)},R=()=>{k.current&&clearTimeout(k.current)},ae=()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{L()},200)},Q=(0,a.useMemo)(()=>{if(y)return y?.components?.[0]?.blockType},[y]),ne=(0,M.WithSidebar)(Te.SidebarDropdown,y),x=(0,M.WithResource)(Me.ResourceSidebarDropdown,y),Y=(0,M.WithMulticol)(De.MulticolDropdown,y),V=(0,M.WithSupports)(Le.SupportsDropdown,{categoriesItem:y,currentNavItemRef:I.current?.[g?.groupIndex||0]?.[g?.index||0]}),re=(0,a.useMemo)(()=>{switch(Q){case r.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(ne,{});case r.HeaderNavigationBlockType.Resource:return(0,e.jsx)(x,{});case r.HeaderNavigationBlockType.Supports:return(0,e.jsx)(V,{});case r.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(Y,{});default:return null}},[Q,y]),W=(0,a.useMemo)(()=>i?.bar?.actions?.filter(n=>n?.pcShow),[i]),j=(0,a.useMemo)(()=>W?.find(n=>n?.blockType===r.HeaderNavigationActionBlockType.Profile),[W]),$=(0,a.useCallback)(()=>{z(n=>!n)},[]);return(0,a.useEffect)(()=>{if(H?.current){const n=H.current;return n.addEventListener("click",$),()=>{n.removeEventListener("click",$)}}},[$]),(0,se.useGSAP)(()=>{g?.open&&U?.current&&te.gsap.fromTo(U?.current,{height:0},{height:"auto"})},[g?.open]),(0,e.jsxs)(s.Container,{className:(0,v.cn)("relative h-[92px]",u),children:[(0,e.jsxs)("div",{ref:G,onClick:L,className:"flex h-full flex-col justify-end gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(Ne,{}),(0,e.jsx)(de,{ref:H,actions:W,activeStatus:B})]}),(0,e.jsx)("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",onMouseEnter:_,onMouseLeave:d,children:l?.map((n,h)=>(0,e.jsx)("div",{className:"flex gap-3",children:n?.map((N,C)=>{const X=g?.groupIndex===h&&g?.index===C,Z=ve(N);return(0,e.jsx)("div",{ref:ee=>{I.current[h][C]=ee},className:"group",onMouseEnter:()=>J(h,C),children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("a",{href:(0,v.getLocalizedPath)(be(N),T,"ref=navMenu"),...Z?{target:Z}:{},rel:Z==="_blank"?"noopener noreferrer":void 0,className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4 no-underline",onClick:()=>A(h,C),onKeyDown:ee=>O(ee,h,C),"aria-expanded":X,"aria-haspopup":"true","aria-label":N.text,children:[(0,e.jsx)(s.Text,{html:N.text,className:"desktop:text-pretty text-nowrap text-sm font-bold leading-[1.4]"}),(0,e.jsx)(w.DownArrow,{className:(0,v.cn)("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":g?.groupIndex===h&&g?.index===C,"opacity-100":b&&g?.groupIndex===h&&g?.index===C,hidden:!fe(N)})})]}),(0,e.jsx)("div",{className:(0,v.cn)("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":X},P==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},N.id)})},`groupCategory-${h}`))})]}),(0,e.jsxs)("div",{role:"menu","aria-hidden":!(g?.open&&y),className:(0,v.cn)("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(g?.open&&y)}),style:{height:`calc(100dvh - ${G?.current?.getBoundingClientRect()?.bottom}px)`},children:[(0,e.jsx)("div",{ref:U,className:(0,v.cn)("relative z-50",{"overflow-hidden":Q!==r.HeaderNavigationBlockType.Supports}),onMouseEnter:()=>{R(),E(!0)},onMouseLeave:()=>{ae(),E(!1)},children:re}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:L,onMouseEnter:L,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:n=>{(n.key==="Enter"||n.key===" "||n.key==="Escape")&&(n.preventDefault(),L())}})]}),B&&(0,e.jsxs)("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[(0,e.jsx)("div",{className:"rounded-box absolute w-[272px] overflow-hidden bg-white p-4",style:{right:`calc(100% - ${H?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:f?.email?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Text,{html:f?.nick_name||j?.welcome,className:"text-sm font-bold"}),(0,e.jsx)("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),(0,e.jsx)("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:j?.profiles?.map(n=>(0,e.jsx)(ue.MenuItem,{className:"py-2",label:n?.title,href:(0,v.getLocalizedPath)(n?.url,T,"ref=navMenu")},n.id))})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(w.Polygon,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),(0,e.jsx)(s.Text,{html:j?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:j?.benefits?.map(n=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(s.Picture,{source:n.benefitIcon?.url,className:"size-4 shrink-0",alt:n.benefit,width:16,height:16}),(0,e.jsx)(s.Text,{html:n.benefit,className:"text-sm font-bold leading-[1.4]"})]},n.id))}),(0,e.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,e.jsx)(s.Button,{className:"grow",variant:"secondary",size:"lg",onClick:()=>p?.join?.(),children:(0,e.jsx)(s.Text,{html:j?.primaryButton||"Join Now",className:"font-bold"})}),(0,e.jsx)(s.Button,{className:"grow",variant:"primary",size:"lg",onClick:()=>p?.login?.(),children:(0,e.jsx)(s.Text,{html:j?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>z(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:n=>{(n.key==="Enter"||n.key===" "||n.key==="Escape")&&(n.preventDefault(),z(!1))}})]})]})}),ye=(0,a.forwardRef)(({data:t,menuData:o,className:i,onPrimaryNavClick:c,onMobileMenuToggle:u},P)=>{const m=(0,a.useMemo)(()=>(0,M.WithGroupCategory)(t?.categories?.filter(d=>d?.mobileShow)),[t]),{currentMenu:l,setCurrentMenu:p,subSubCategory:f}=(0,K.useNavContext)(),[b,E]=(0,a.useState)(!1),[T,y]=(0,a.useState)(0),[D,F]=(0,a.useState)(null),S=(0,a.useRef)(null),H=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(S?.current&&b){const d=S?.current?.getBoundingClientRect();y(window?.innerHeight-(d?.top||0))}u?.({open:b})},[b,u]),(0,a.useEffect)(()=>{if(!b)return;const d=(0,me.default)(()=>{if(S?.current){const _=S.current.getBoundingClientRect();H.current=!0,y(window?.innerHeight-(_?.top||0))}},100);return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[b]),(0,se.useGSAP)(()=>{if(S.current){if(H.current){te.gsap.set(S.current,{height:T}),H.current=!1;return}te.gsap.fromTo(S.current,{height:0},{height:T,duration:.3})}},[T]),(0,ce.useScrollLock)(b);const B=(0,a.useMemo)(()=>D?.components?.[0]?.blockType,[D]),z=(0,M.WithSupports)(Ee.MobileSupportMenu,{categoriesItem:D}),G=(0,M.WithSidebar)(Pe.MobileSidebarMenu,D),U=(0,M.WithResource)(Se.MobileResourceSidebarMenu,D),k=(0,M.WithMulticol)(He.MobileMulticolMenu,D),I=(0,a.useMemo)(()=>{switch(B){case r.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(G,{});case r.HeaderNavigationBlockType.Resource:return(0,e.jsx)(U,{});case r.HeaderNavigationBlockType.Supports:return(0,e.jsx)(z,{});case r.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(k,{});default:return null}},[B,D,z]),g=(0,a.useCallback)(()=>{E(!1),y(0),p&&p(r.HeaderNavigationMenu.Primary)},[E,y,p]),A=(0,a.useMemo)(()=>t?.bar?.actions?.filter(d=>d?.mobileShow&&d?.blockType!==r.HeaderNavigationActionBlockType.Profile),[t]),J=(0,a.useMemo)(()=>t?.bar?.actions?.find(d=>d?.mobileShow&&d?.blockType===r.HeaderNavigationActionBlockType.Profile)||{},[t]),O=(0,a.useMemo)(()=>{switch(l){case r.HeaderNavigationMenu.Primary:return(0,e.jsx)(We,{actions:A,menuOpen:b,onMenuOpenClose:()=>{E(!1),y(0)},onMenuOpenClick:()=>E(!0)});case r.HeaderNavigationMenu.Secondary:return(0,e.jsx)(ke,{title:D?.text,onMenuOpenClose:g,onMenuBackClick:()=>p?.(r.HeaderNavigationMenu.Primary)});case r.HeaderNavigationMenu.Third:return(0,e.jsx)(ke,{title:f?.label,onMenuOpenClose:g,onMenuBackClick:()=>p?.(r.HeaderNavigationMenu.Secondary)});default:return null}},[b,l,p,D,A,f,g]),L=(0,a.useCallback)((d,_)=>{const R=Array.isArray(m)?Array.isArray(m[d])?m[d][_]:{}:{};R?.components?.[0]?.blockType!==r.HeaderNavigationBlockType.Links&&(F(R),p?.(r.HeaderNavigationMenu.Secondary))},[m,p]);return(0,e.jsxs)(s.Container,{className:(0,v.cn)("relative h-[56px]",i),children:[O,b&&(0,e.jsxs)("nav",{ref:S,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:T},role:"navigation","aria-label":"Mobile navigation menu",children:[l===r.HeaderNavigationMenu.Primary&&o?(0,e.jsx)("div",{className:"pt-4",children:(0,e.jsx)(s.BrandStrip,{data:o})}):null,l===r.HeaderNavigationMenu.Primary?(0,e.jsx)(Ke,{categories:m,onPrimaryMenuClick:L,onPrimaryNavClick:c,profileAction:J,menuData:o}):I]})]})}),Ke=({categories:t,onPrimaryMenuClick:o,profileAction:i,onPrimaryNavClick:c,menuData:u})=>{const{locale:P="us"}=(0,q.useAiuiContext)();return(0,e.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map((m,l)=>(0,e.jsxs)("div",{className:"",children:[l>0||u?(0,e.jsx)("div",{className:(0,v.cn)("my-2 h-px w-full bg-[#E5E5E7]")}):null,m?.map((p,f)=>{const b=p.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links;return(0,e.jsx)(ue.MenuItem,{label:p.text,href:b?(0,v.getLocalizedPath)(be(p),P,"ref=navMenu"):void 0,target:b?ve(p):void 0,onClick:()=>{const T=(t?.flat()||[])?.findIndex(y=>y?.id===t[l][f]?.id);o(l,f),c?.(p,T)},icon:p.components?.[0]?.icon},p.id)})]},`groupCategory-${l}`))}),(0,e.jsx)(Ue,{profileAction:i})]})},Ue=({profileAction:t})=>{const[o,i]=(0,a.useState)(!1),{profile:c,event:u}=(0,K.useNavContext)(),{locale:P="us"}=(0,q.useAiuiContext)();return(0,e.jsxs)("div",{className:(0,v.cn)("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":o}),children:[(0,e.jsxs)("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>i(!o),"aria-expanded":o,"aria-label":c?.nick_name||t?.welcome,children:[(0,e.jsxs)("div",{className:"flex items-center gap-[14px]",children:[(0,e.jsx)("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:(0,e.jsx)(w.User,{"aria-hidden":"true"})}),(0,e.jsx)(s.Text,{html:c?.nick_name||t?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!c?.email&&(0,e.jsx)(w.DownArrow,{"aria-hidden":"true",className:(0,v.cn)("laptop:size-4 size-5",{"rotate-180":o})})]}),c?.email&&(0,e.jsx)("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:t?.profiles?.map(m=>(0,e.jsx)(ue.MenuItem,{label:m?.title,href:(0,v.getLocalizedPath)(m?.url,P,"ref=navMenu")},m.id))}),o&&!c?.email&&(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)(s.Text,{html:t?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:t?.benefits?.map(m=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(s.Picture,{source:m.benefitIcon?.url,className:"size-4",alt:m.benefit,width:16,height:16}),(0,e.jsx)(s.Text,{html:m.benefit,className:"text-sm font-bold leading-[1.4]"})]},m.id))})]}),!c?.email&&(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-3",children:[(0,e.jsx)(s.Button,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>u?.join?.(),children:(0,e.jsx)(s.Text,{html:t?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),(0,e.jsx)(s.Button,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>u?.login?.(),children:(0,e.jsx)(s.Text,{html:t?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},We=({menuOpen:t,onMenuOpenClose:o,onMenuOpenClick:i,actions:c})=>(0,e.jsxs)("div",{className:"flex h-full items-center justify-between gap-4",children:[(0,e.jsx)(Ne,{}),(0,e.jsxs)("div",{className:"desktop:gap-6 flex items-center gap-4",children:[(0,e.jsx)(de,{actions:c}),t?(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>o(),"aria-label":"Close menu","aria-expanded":"true",children:(0,e.jsx)(w.Close,{className:"size-5","aria-hidden":"true"})}):(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:(0,e.jsx)(w.Menu,{className:"size-5","aria-hidden":"true"})})]})]}),Ne=()=>{const{payloadData:t,isMobile:o}=(0,K.useNavContext)(),{locale:i="us"}=(0,q.useAiuiContext)();return(0,e.jsx)("a",{href:(0,v.getLocalizedPath)("/",i,"ref=logo"),className:"hover:text-[#00CBEB] [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:o?t?.bar?.mobileLogo:t?.bar?.desktopLogo}})},de=(0,a.forwardRef)(({actions:t,activeStatus:o=!1},i)=>{const{event:c,cartCount:u}=(0,K.useNavContext)(),[P,m]=(0,a.useState)(null),l=f=>{switch(f){case r.HeaderNavigationActionBlockType.Search:return"Search";case r.HeaderNavigationActionBlockType.Cart:return`Shopping cart${u>0?` (${u} items)`:""}`;case r.HeaderNavigationActionBlockType.Profile:return"User profile";case r.HeaderNavigationActionBlockType.Livestream:return"Livestream";default:return"Action"}},p=(0,a.useCallback)((f,b)=>{switch(m(b),f?.blockType){case r.HeaderNavigationActionBlockType.Search:c?.search?.();break;case r.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case r.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case r.HeaderNavigationActionBlockType.Livestream:c?.livestream?.();break;default:return()=>{}}},[c]);return(0,e.jsx)("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(t)&&t?.map((f,b)=>(0,e.jsxs)("button",{className:"relative cursor-pointer border-0 bg-transparent p-0","data-tag":f?.tag||"",ref:f.blockType===r.HeaderNavigationActionBlockType.Profile?i:null,onClick:()=>p(f,b),"aria-label":l(f.blockType),"aria-pressed":o&&P===b,children:[(0,e.jsx)(s.Text,{html:f.icon,className:(0,v.cn)("size-5",{"text-brand-0":o&&P===b}),"aria-hidden":"true"}),f.blockType===r.HeaderNavigationActionBlockType.Cart&&u>0&&(0,e.jsx)("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:(0,e.jsx)(s.Text,{html:u?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},f.id))})}),ke=({title:t,onMenuOpenClose:o,onMenuBackClick:i})=>(0,e.jsxs)("div",{className:"flex h-full items-center gap-3",children:[(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Back to previous menu",children:(0,e.jsx)(w.LeftArrow,{className:"size-5","aria-hidden":"true"})}),(0,e.jsx)(s.Text,{html:t,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>o(),"aria-label":"Close menu",children:(0,e.jsx)(w.Close,{className:"size-5","aria-hidden":"true"})})]});ye.displayName="MobileNavigation",de.displayName="Actions",ge.displayName="HeaderNavigation",he.displayName="DesktopNavigation";var Fe=(0,xe.withLayout)(ge);
1
+ "use strict";"use client";var Be=Object.create;var ie=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var je=(t,o)=>{for(var i in o)ie(t,i,{get:o[i],enumerable:!0})},pe=(t,o,i,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let u of Ie(o))!Oe.call(t,u)&&u!==i&&ie(t,u,{get:()=>o[u],enumerable:!(c=ze(o,u))||c.enumerable});return t};var le=(t,o,i)=>(i=t!=null?Be(Ae(t)):{},pe(o||!t||!t.__esModule?ie(i,"default",{value:t,enumerable:!0}):i,t)),_e=t=>pe(ie({},"__esModule",{value:!0}),t);var Ge={};je(Ge,{default:()=>Fe});module.exports=_e(Ge);var e=require("react/jsx-runtime"),a=require("react"),s=require("../../components/index.js"),xe=require("../../shared/Styles.js"),v=require("../../helpers/utils.js"),K=le(require("./NavProvider.js")),r=require("./types.js"),Ce=le(require("jump.js")),se=require("@gsap/react"),ae=require("gsap"),M=require("./withCategory.js"),w=require("./icons/index.js"),we=le(require("../NavigationSearch/index.js")),Me=require("./ResourceSidebarDropdown.js"),Se=require("./MobileResourceSidebarMenu.js"),Te=require("./SidebarDropdown.js"),ce=require("./useScrollLock.js"),De=require("./MulticolDropdown.js"),Le=require("./SupportsDropdown.js"),Pe=require("./MobileSidebarMenu.js"),Ee=require("./MobileSupportMenu.js"),He=require("./MobileMulticolMenu.js"),ue=require("./MobileMenuComponents.js"),q=require("../AiuiProvider/index.js"),me=le(require("../../shared/throttle.js")),Re=require("./useNavCollapse.js");const fe=t=>!!t?.components?.length&&t?.components?.[0]?.blockType!==r.HeaderNavigationBlockType.Links,be=t=>t?.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links&&t?.components?.[0]?.url||t?.url||void 0,ve=t=>t?.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links&&t?.components?.[0]?.target||t?.target,$e=({groupCategories:t})=>(0,e.jsx)("div",{className:"pointer-events-none invisible absolute inset-x-0 top-0 overflow-hidden","aria-hidden":"true",children:(0,e.jsx)(s.Container,{className:"h-[92px]",children:(0,e.jsx)("nav",{className:"flex h-full items-end justify-between",children:t?.map((o,i)=>(0,e.jsx)("div",{className:"flex gap-3","data-nav-item":!0,children:o?.map(c=>(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(s.Text,{html:c.text,"data-nav-item-label":!0,className:"desktop:text-pretty text-nowrap text-sm font-bold leading-[1.4]"}),fe(c)&&(0,e.jsx)(w.DownArrow,{className:"size-4 opacity-0","aria-hidden":"true"})]},c.id))},`measure-group-${i}`))})})}),ge=(0,a.forwardRef)((t,o)=>{const{data:{header:i}={},buildProps:c,event:u,profile:P,theme:m="light",isTop:l=!1,searchResult:p,onSearch:f,isSearching:b,keywords:E,onPrimaryNavClick:T,onSeriesProductClick:y,onSidebarNavClick:D,onMobileMenuToggle:F,headerId:S,cartCount:H,menuData:B,render:z,componentOverrides:G,...U}=t,[k,I]=(0,a.useState)(!1),[g,A]=(0,a.useState)(!1),[J,O]=(0,a.useState)(!1),L=(0,a.useRef)(null),d=(0,a.useRef)(null),_=(0,a.useMemo)(()=>(0,M.WithGroupCategory)(i?.categories?.filter(x=>x?.pcShow)),[i]),R=(0,Re.useNavCollapse)(d),{setNavCollapsed:Q}=(0,q.useAiuiContext)();(0,a.useEffect)(()=>(Q?.(R),()=>Q?.(void 0)),[R,Q]),(0,a.useImperativeHandle)(o,()=>d.current),(0,a.useEffect)(()=>{d.current&&l&&(0,Ce.default)(d.current,{duration:0,offset:d.current?.getBoundingClientRect()?.bottom||0})},[l]),(0,a.useEffect)(()=>{if(l){A(!1),O(!1);return}let x=0,Y=0,X=0;const re=()=>document?.documentElement?.scrollTop||document?.body?.scrollTop||0,W=re();x=W,A(W>300),O(W>30);const j=(0,me.default)(()=>{const $=re(),n=$-x;O($>30),n>0?(Y=0,X+=n,X>=300&&$>300&&A(!0)):n<0&&(X=0,Y+=Math.abs(n),Y>=300&&(A(!1),Y=0)),x=$},100);return window.addEventListener("scroll",j,{passive:!0}),()=>window.removeEventListener("scroll",j)},[l]),(0,a.useEffect)(()=>{u&&(u.search=()=>I(!0))},[u]),(0,se.useGSAP)(()=>{L?.current&&k&&ae.gsap.fromTo(L.current,{height:0},{height:"auto",duration:.3})},[k]),(0,ce.useScrollLock)(k);const V=(0,a.useMemo)(()=>i?.bar?.actions?.find(x=>x?.blockType===r.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[i]),ne=z?.mobileHeaderNavigation;return(0,e.jsx)(K.default,{buildProps:c,profile:P,isMobile:R,event:u,payloadData:i,onSidebarNavClick:D,onSeriesProductClick:y,cartCount:H,componentOverrides:G,children:(0,e.jsx)("header",{...U,id:S||"header","data-ui-component-id":"HeaderNavigation",className:l?"relative z-[100] bg-white":(0,v.cn)("sticky top-0 z-[100] transition-transform duration-500 ease-in-out",{"translate-y-[-100%]":g}),ref:d,children:(0,e.jsxs)("div",{className:(0,v.cn)("hover:bg-white hover:text-black",m==="light"?"text-black":"text-white",{"!bg-white transition-all duration-500 ease-in-out":!l&&J},{"hover:!text-black":m==="dark","!text-black":!l&&J}),onClick:()=>!l&&O(!0),children:[(0,e.jsx)($e,{groupCategories:_}),(0,e.jsx)("div",{className:(0,v.cn)("hidden",R?"laptop:hidden":"laptop:block","desktop:block"),children:(0,e.jsx)(he,{data:i,groupCategories:_,theme:m,onNavItemClick:()=>!l&&O(!0),onPrimaryNavClick:T,className:"!bg-white"})}),(0,e.jsx)("div",{className:(0,v.cn)("block",R?"laptop:block":"laptop:hidden","desktop:hidden"),children:ne?(0,e.jsx)(ne,{menuData:B,data:i,onPrimaryNavClick:T}):(0,e.jsx)(ye,{menuData:B,data:i,onPrimaryNavClick:T,onMobileMenuToggle:F,className:"!bg-white"})}),k&&(0,e.jsxs)("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${d?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[(0,e.jsx)("div",{ref:L,className:(0,v.cn)("overflow-y-auto",{}),children:(0,e.jsx)(we.default,{data:V,keywords:E,isSearching:b,searchResult:p,onSearch:x=>{f?.(x)},onClose:()=>{f?.(),I(!1)}})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>I(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:x=>{(x.key==="Enter"||x.key===" "||x.key==="Escape")&&(x.preventDefault(),I(!1))}})]})]})})})}),he=(0,a.forwardRef)((t,o)=>{const{data:i,onNavItemClick:c,className:u,theme:P,onPrimaryNavClick:m,groupCategories:l}=t,{event:p,profile:f}=(0,K.useNavContext)(),[b,E]=(0,a.useState)(!1),{locale:T="us"}=(0,q.useAiuiContext)(),[y,D]=(0,a.useState)(null),[F,S]=(0,a.useState)([]),H=(0,a.useRef)(null),[B,z]=(0,a.useState)(!1),G=(0,a.useRef)(null),U=(0,a.useRef)(null),k=(0,a.useRef)(null),I=(0,a.useRef)(l.map(n=>Array(n?.length||0).fill(null)));(0,a.useEffect)(()=>{l?.length&&S(l?.map((n,h)=>n?.map((N,C)=>({groupIndex:h,index:C,open:!1}))))},[l]);const g=(0,a.useMemo)(()=>{let n=null;for(const h of F){for(const N of h)if(N.open){n=N;break}if(n)break}return n},[F]);(0,ce.useScrollLock)(!!g?.open||B);const A=(n,h)=>{z(!1),c?.();const N=l?.flat()||[],C=N?.findIndex(Z=>Z?.id===l[n][h]?.id);m?.(N[C],C)},J=(n,h)=>{const N=l[n][h],C=N?.components?.[0];C&&C?.blockType!==r.HeaderNavigationBlockType.Links&&(D(N),S(ee=>ee.map(te=>te.map(oe=>oe.groupIndex===n&&oe.index===h?{...oe,open:!0}:{...oe,open:!1}))))},O=(n,h,N)=>{n.key==="Escape"&&g?.groupIndex===h&&g?.index===N&&(n.preventDefault(),L())},L=()=>{S(n=>n.map(h=>h.map(N=>({...N,open:!1}))))},d=()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{L()},200)},_=()=>{k.current&&clearTimeout(k.current)},R=()=>{k.current&&clearTimeout(k.current)},Q=()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{L()},200)},V=(0,a.useMemo)(()=>{if(y)return y?.components?.[0]?.blockType},[y]),ne=(0,M.WithSidebar)(Te.SidebarDropdown,y),x=(0,M.WithResource)(Me.ResourceSidebarDropdown,y),Y=(0,M.WithMulticol)(De.MulticolDropdown,y),X=(0,M.WithSupports)(Le.SupportsDropdown,{categoriesItem:y,currentNavItemRef:I.current?.[g?.groupIndex||0]?.[g?.index||0]}),re=(0,a.useMemo)(()=>{switch(V){case r.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(ne,{});case r.HeaderNavigationBlockType.Resource:return(0,e.jsx)(x,{});case r.HeaderNavigationBlockType.Supports:return(0,e.jsx)(X,{});case r.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(Y,{});default:return null}},[V,y]),W=(0,a.useMemo)(()=>i?.bar?.actions?.filter(n=>n?.pcShow),[i]),j=(0,a.useMemo)(()=>W?.find(n=>n?.blockType===r.HeaderNavigationActionBlockType.Profile),[W]),$=(0,a.useCallback)(()=>{z(n=>!n)},[]);return(0,a.useEffect)(()=>{if(H?.current){const n=H.current;return n.addEventListener("click",$),()=>{n.removeEventListener("click",$)}}},[$]),(0,se.useGSAP)(()=>{g?.open&&U?.current&&ae.gsap.fromTo(U?.current,{height:0},{height:"auto"})},[g?.open]),(0,e.jsxs)(s.Container,{className:(0,v.cn)("relative h-[92px]",u),children:[(0,e.jsxs)("div",{ref:G,onClick:L,className:"flex h-full flex-col justify-end gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(Ne,{}),(0,e.jsx)(de,{ref:H,actions:W,activeStatus:B})]}),(0,e.jsx)("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",onMouseEnter:_,onMouseLeave:d,children:l?.map((n,h)=>(0,e.jsx)("div",{className:"flex gap-3",children:n?.map((N,C)=>{const Z=g?.groupIndex===h&&g?.index===C,ee=ve(N);return(0,e.jsx)("div",{ref:te=>{I.current[h][C]=te},className:"group",onMouseEnter:()=>J(h,C),children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("a",{href:(0,v.getLocalizedPath)(be(N),T,"ref=navMenu"),...ee?{target:ee}:{},rel:ee==="_blank"?"noopener noreferrer":void 0,className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4 no-underline",onClick:()=>A(h,C),onKeyDown:te=>O(te,h,C),"aria-expanded":Z,"aria-haspopup":"true","aria-label":N.text,children:[(0,e.jsx)(s.Text,{html:N.text,className:"desktop:text-pretty text-nowrap text-sm font-bold leading-[1.4]"}),(0,e.jsx)(w.DownArrow,{className:(0,v.cn)("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":g?.groupIndex===h&&g?.index===C,"opacity-100":b&&g?.groupIndex===h&&g?.index===C,hidden:!fe(N)})})]}),(0,e.jsx)("div",{className:(0,v.cn)("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":Z},P==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},N.id)})},`groupCategory-${h}`))})]}),(0,e.jsxs)("div",{role:"menu","aria-hidden":!(g?.open&&y),className:(0,v.cn)("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(g?.open&&y)}),style:{height:`calc(100dvh - ${G?.current?.getBoundingClientRect()?.bottom}px)`},children:[(0,e.jsx)("div",{ref:U,className:(0,v.cn)("relative z-50",{"overflow-hidden":V!==r.HeaderNavigationBlockType.Supports}),onMouseEnter:()=>{R(),E(!0)},onMouseLeave:()=>{Q(),E(!1)},children:re}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:L,onMouseEnter:L,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:n=>{(n.key==="Enter"||n.key===" "||n.key==="Escape")&&(n.preventDefault(),L())}})]}),B&&(0,e.jsxs)("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[(0,e.jsx)("div",{className:"rounded-box absolute w-[272px] overflow-hidden bg-white p-4",style:{right:`calc(100% - ${H?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:f?.email?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Text,{html:f?.nick_name||j?.welcome,className:"text-sm font-bold"}),(0,e.jsx)("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),(0,e.jsx)("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:j?.profiles?.map(n=>(0,e.jsx)(ue.MenuItem,{className:"py-2",label:n?.title,href:(0,v.getLocalizedPath)(n?.url,T,"ref=navMenu")},n.id))})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(w.Polygon,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),(0,e.jsx)(s.Text,{html:j?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:j?.benefits?.map(n=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(s.Picture,{source:n.benefitIcon?.url,className:"size-4 shrink-0",alt:n.benefit,width:16,height:16}),(0,e.jsx)(s.Text,{html:n.benefit,className:"text-sm font-bold leading-[1.4]"})]},n.id))}),(0,e.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,e.jsx)(s.Button,{className:"grow",variant:"secondary",size:"lg",onClick:()=>p?.join?.(),children:(0,e.jsx)(s.Text,{html:j?.primaryButton||"Join Now",className:"font-bold"})}),(0,e.jsx)(s.Button,{className:"grow",variant:"primary",size:"lg",onClick:()=>p?.login?.(),children:(0,e.jsx)(s.Text,{html:j?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>z(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:n=>{(n.key==="Enter"||n.key===" "||n.key==="Escape")&&(n.preventDefault(),z(!1))}})]})]})}),ye=(0,a.forwardRef)(({data:t,menuData:o,className:i,onPrimaryNavClick:c,onMobileMenuToggle:u},P)=>{const m=(0,a.useMemo)(()=>(0,M.WithGroupCategory)(t?.categories?.filter(d=>d?.mobileShow)),[t]),{currentMenu:l,setCurrentMenu:p,subSubCategory:f}=(0,K.useNavContext)(),[b,E]=(0,a.useState)(!1),[T,y]=(0,a.useState)(0),[D,F]=(0,a.useState)(null),S=(0,a.useRef)(null),H=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(S?.current&&b){const d=S?.current?.getBoundingClientRect();y(window?.innerHeight-(d?.top||0))}u?.({open:b})},[b,u]),(0,a.useEffect)(()=>{if(!b)return;const d=(0,me.default)(()=>{if(S?.current){const _=S.current.getBoundingClientRect();H.current=!0,y(window?.innerHeight-(_?.top||0))}},100);return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[b]),(0,se.useGSAP)(()=>{if(S.current){if(H.current){ae.gsap.set(S.current,{height:T}),H.current=!1;return}ae.gsap.fromTo(S.current,{height:0},{height:T,duration:.3})}},[T]),(0,ce.useScrollLock)(b);const B=(0,a.useMemo)(()=>D?.components?.[0]?.blockType,[D]),z=(0,M.WithSupports)(Ee.MobileSupportMenu,{categoriesItem:D}),G=(0,M.WithSidebar)(Pe.MobileSidebarMenu,D),U=(0,M.WithResource)(Se.MobileResourceSidebarMenu,D),k=(0,M.WithMulticol)(He.MobileMulticolMenu,D),I=(0,a.useMemo)(()=>{switch(B){case r.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(G,{});case r.HeaderNavigationBlockType.Resource:return(0,e.jsx)(U,{});case r.HeaderNavigationBlockType.Supports:return(0,e.jsx)(z,{});case r.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(k,{});default:return null}},[B,D,z]),g=(0,a.useCallback)(()=>{E(!1),y(0),p&&p(r.HeaderNavigationMenu.Primary)},[E,y,p]),A=(0,a.useMemo)(()=>t?.bar?.actions?.filter(d=>d?.mobileShow&&d?.blockType!==r.HeaderNavigationActionBlockType.Profile),[t]),J=(0,a.useMemo)(()=>t?.bar?.actions?.find(d=>d?.mobileShow&&d?.blockType===r.HeaderNavigationActionBlockType.Profile)||{},[t]),O=(0,a.useMemo)(()=>{switch(l){case r.HeaderNavigationMenu.Primary:return(0,e.jsx)(We,{actions:A,menuOpen:b,onMenuOpenClose:()=>{E(!1),y(0)},onMenuOpenClick:()=>E(!0)});case r.HeaderNavigationMenu.Secondary:return(0,e.jsx)(ke,{title:D?.text,onMenuOpenClose:g,onMenuBackClick:()=>p?.(r.HeaderNavigationMenu.Primary)});case r.HeaderNavigationMenu.Third:return(0,e.jsx)(ke,{title:f?.label,onMenuOpenClose:g,onMenuBackClick:()=>p?.(r.HeaderNavigationMenu.Secondary)});default:return null}},[b,l,p,D,A,f,g]),L=(0,a.useCallback)((d,_)=>{const R=Array.isArray(m)?Array.isArray(m[d])?m[d][_]:{}:{};R?.components?.[0]?.blockType!==r.HeaderNavigationBlockType.Links&&(F(R),p?.(r.HeaderNavigationMenu.Secondary))},[m,p]);return(0,e.jsxs)(s.Container,{className:(0,v.cn)("relative h-[56px]",i),children:[O,b&&(0,e.jsxs)("nav",{ref:S,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:T},role:"navigation","aria-label":"Mobile navigation menu",children:[l===r.HeaderNavigationMenu.Primary&&o?(0,e.jsx)("div",{className:"pt-4",children:(0,e.jsx)(s.BrandStrip,{data:o})}):null,l===r.HeaderNavigationMenu.Primary?(0,e.jsx)(Ke,{categories:m,onPrimaryMenuClick:L,onPrimaryNavClick:c,profileAction:J,menuData:o}):I]})]})}),Ke=({categories:t,onPrimaryMenuClick:o,profileAction:i,onPrimaryNavClick:c,menuData:u})=>{const{locale:P="us"}=(0,q.useAiuiContext)();return(0,e.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:t?.map((m,l)=>(0,e.jsxs)("div",{className:"",children:[l>0||u?(0,e.jsx)("div",{className:(0,v.cn)("my-2 h-px w-full bg-[#E5E5E7]")}):null,m?.map((p,f)=>{const b=p.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links;return(0,e.jsx)(ue.MenuItem,{label:p.text,href:b?(0,v.getLocalizedPath)(be(p),P,"ref=navMenu"):void 0,target:b?ve(p):void 0,onClick:()=>{const T=(t?.flat()||[])?.findIndex(y=>y?.id===t[l][f]?.id);o(l,f),c?.(p,T)},icon:p.components?.[0]?.icon},p.id)})]},`groupCategory-${l}`))}),(0,e.jsx)(Ue,{profileAction:i})]})},Ue=({profileAction:t})=>{const[o,i]=(0,a.useState)(!1),{profile:c,event:u}=(0,K.useNavContext)(),{locale:P="us"}=(0,q.useAiuiContext)();return(0,e.jsxs)("div",{className:(0,v.cn)("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":o}),children:[(0,e.jsxs)("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>i(!o),"aria-expanded":o,"aria-label":c?.nick_name||t?.welcome,children:[(0,e.jsxs)("div",{className:"flex items-center gap-[14px]",children:[(0,e.jsx)("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:(0,e.jsx)(w.User,{"aria-hidden":"true"})}),(0,e.jsx)(s.Text,{html:c?.nick_name||t?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!c?.email&&(0,e.jsx)(w.DownArrow,{"aria-hidden":"true",className:(0,v.cn)("laptop:size-4 size-5",{"rotate-180":o})})]}),c?.email&&(0,e.jsx)("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:t?.profiles?.map(m=>(0,e.jsx)(ue.MenuItem,{label:m?.title,href:(0,v.getLocalizedPath)(m?.url,P,"ref=navMenu")},m.id))}),o&&!c?.email&&(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)(s.Text,{html:t?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:t?.benefits?.map(m=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(s.Picture,{source:m.benefitIcon?.url,className:"size-4",alt:m.benefit,width:16,height:16}),(0,e.jsx)(s.Text,{html:m.benefit,className:"text-sm font-bold leading-[1.4]"})]},m.id))})]}),!c?.email&&(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-3",children:[(0,e.jsx)(s.Button,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>u?.join?.(),children:(0,e.jsx)(s.Text,{html:t?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),(0,e.jsx)(s.Button,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>u?.login?.(),children:(0,e.jsx)(s.Text,{html:t?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},We=({menuOpen:t,onMenuOpenClose:o,onMenuOpenClick:i,actions:c})=>(0,e.jsxs)("div",{className:"flex h-full items-center justify-between gap-4",children:[(0,e.jsx)(Ne,{}),(0,e.jsxs)("div",{className:"desktop:gap-6 flex items-center gap-4",children:[(0,e.jsx)(de,{actions:c}),t?(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>o(),"aria-label":"Close menu","aria-expanded":"true",children:(0,e.jsx)(w.Close,{className:"size-5","aria-hidden":"true"})}):(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:(0,e.jsx)(w.Menu,{className:"size-5","aria-hidden":"true"})})]})]}),Ne=()=>{const{payloadData:t,isMobile:o}=(0,K.useNavContext)(),{locale:i="us"}=(0,q.useAiuiContext)();return(0,e.jsx)("a",{href:(0,v.getLocalizedPath)("/",i,"ref=logo"),className:"hover:text-[#00CBEB] [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:o?t?.bar?.mobileLogo:t?.bar?.desktopLogo}})},de=(0,a.forwardRef)(({actions:t,activeStatus:o=!1},i)=>{const{event:c,cartCount:u}=(0,K.useNavContext)(),[P,m]=(0,a.useState)(null),l=f=>{switch(f){case r.HeaderNavigationActionBlockType.Search:return"Search";case r.HeaderNavigationActionBlockType.Cart:return`Shopping cart${u>0?` (${u} items)`:""}`;case r.HeaderNavigationActionBlockType.Profile:return"User profile";case r.HeaderNavigationActionBlockType.Livestream:return"Livestream";default:return"Action"}},p=(0,a.useCallback)((f,b)=>{switch(m(b),f?.blockType){case r.HeaderNavigationActionBlockType.Search:c?.search?.();break;case r.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case r.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case r.HeaderNavigationActionBlockType.Livestream:c?.livestream?.();break;default:return()=>{}}},[c]);return(0,e.jsx)("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(t)&&t?.map((f,b)=>(0,e.jsxs)("button",{className:"relative cursor-pointer border-0 bg-transparent p-0","data-tag":f?.tag||"",ref:f.blockType===r.HeaderNavigationActionBlockType.Profile?i:null,onClick:()=>p(f,b),"aria-label":l(f.blockType),"aria-pressed":o&&P===b,children:[(0,e.jsx)(s.Text,{html:f.icon,className:(0,v.cn)("size-5",{"text-brand-0":o&&P===b}),"aria-hidden":"true"}),f.blockType===r.HeaderNavigationActionBlockType.Cart&&u>0&&(0,e.jsx)("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:(0,e.jsx)(s.Text,{html:u?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},f.id))})}),ke=({title:t,onMenuOpenClose:o,onMenuBackClick:i})=>(0,e.jsxs)("div",{className:"flex h-full items-center gap-3",children:[(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Back to previous menu",children:(0,e.jsx)(w.LeftArrow,{className:"size-5","aria-hidden":"true"})}),(0,e.jsx)(s.Text,{html:t,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>o(),"aria-label":"Close menu",children:(0,e.jsx)(w.Close,{className:"size-5","aria-hidden":"true"})})]});ye.displayName="MobileNavigation",de.displayName="Actions",ge.displayName="HeaderNavigation",he.displayName="DesktopNavigation";var Fe=(0,xe.withLayout)(ge);
@@ -89,7 +89,7 @@ interface AiuiContextType {
89
89
  /**
90
90
  * 设置导航折叠状态。仅供 HeaderNavigation 内部写入,消费方无需关心。
91
91
  */
92
- setNavCollapsed?: (_collapsed: boolean) => void;
92
+ setNavCollapsed?: (_collapsed: boolean | undefined) => void;
93
93
  }
94
94
  export declare const AiuiContext: React.Context<AiuiContextType>;
95
95
  export declare const useAiuiContext: () => AiuiContextType;
@@ -1 +1 @@
1
- "use client";import{jsx as f}from"react/jsx-runtime";import{gaTrack as A}from"../../shared/track.js";import{createContext as E,useContext as D,useEffect as c,useMemo as T,useRef as v,useState as _}from"react";import{extendLocaleMap as M}from"../../helpers/index.js";const b=E({trackingData:{},locale:void 0,copyWriting:{}}),S=()=>{const o=D(b);if(!o)throw new Error("useAiui must be used in <AiuiProvider>");return o},P=({children:o,...t})=>{const p=v(null),l=v(t?.trackingData),[u,h]=_(!1);c(()=>{t.localeMap&&Object.keys(t.localeMap).length>0&&M(t.localeMap)},[t.localeMap]),c(()=>{l.current=t?.trackingData},[t?.trackingData]),c(()=>{const r=p.current;if(!r)return;const d=(e,a)=>{const n={};if(!a||!a.attributes)return n;for(const C of Array.from(a.attributes)){const s=C?.name;s?.startsWith("data-headless-")&&(n[s]=a.getAttribute(s))}const x=n?.["data-headless-sku"],g=n?.["data-headless-type-name"]?.split?.("#"),i=n?.["data-headless-title-desc-button"]?.split?.("#"),y=n?.["data-headless-nav-position"]?.split?.("#");A({event:"ga4Event",event_name:"component_click",event_parameters:{page_group:l.current?.pageGroup||"Home Page",component_type:g?.[0]||"",component_name:g?.[1]||"",position:y?.[1]||"",navigation:y?.[0]||"",button_name:i?.[2]||"",SKU:x||"",component_title:i?.[0]||"",component_description:i?.[1]||""}})},m=new MutationObserver(()=>{r.querySelectorAll("[data-headless-type-name]").forEach(e=>{e.hasAttribute("data-headless-track-bound")||(e.addEventListener("click",a=>d(a,e)),e.setAttribute("data-headless-track-bound","true"))})});return m.observe(r,{childList:!0,subtree:!0}),r.querySelectorAll("[data-headless-type-name]").forEach(e=>{e.hasAttribute("data-headless-track-bound")||(e.addEventListener("click",a=>d(a,e)),e.setAttribute("data-headless-track-bound","true"))}),()=>m.disconnect()},[]);const k=T(()=>({...t,navCollapsed:u,setNavCollapsed:h}),[t,u]);return f(b.Provider,{value:k,children:f("div",{ref:p,children:o})})};var w=P;export{b as AiuiContext,w as default,S as useAiuiContext};
1
+ "use client";import{jsx as b}from"react/jsx-runtime";import{gaTrack as A}from"../../shared/track.js";import{createContext as E,useContext as D,useEffect as c,useMemo as T,useRef as f,useState as _}from"react";import{extendLocaleMap as M}from"../../helpers/index.js";const v=E({trackingData:{},locale:void 0,copyWriting:{}}),S=()=>{const o=D(v);if(!o)throw new Error("useAiui must be used in <AiuiProvider>");return o},P=({children:o,...t})=>{const p=f(null),u=f(t?.trackingData),[l,h]=_(void 0);c(()=>{t.localeMap&&Object.keys(t.localeMap).length>0&&M(t.localeMap)},[t.localeMap]),c(()=>{u.current=t?.trackingData},[t?.trackingData]),c(()=>{const r=p.current;if(!r)return;const d=(e,n)=>{const a={};if(!n||!n.attributes)return a;for(const C of Array.from(n.attributes)){const s=C?.name;s?.startsWith("data-headless-")&&(a[s]=n.getAttribute(s))}const x=a?.["data-headless-sku"],g=a?.["data-headless-type-name"]?.split?.("#"),i=a?.["data-headless-title-desc-button"]?.split?.("#"),y=a?.["data-headless-nav-position"]?.split?.("#");A({event:"ga4Event",event_name:"component_click",event_parameters:{page_group:u.current?.pageGroup||"Home Page",component_type:g?.[0]||"",component_name:g?.[1]||"",position:y?.[1]||"",navigation:y?.[0]||"",button_name:i?.[2]||"",SKU:x||"",component_title:i?.[0]||"",component_description:i?.[1]||""}})},m=new MutationObserver(()=>{r.querySelectorAll("[data-headless-type-name]").forEach(e=>{e.hasAttribute("data-headless-track-bound")||(e.addEventListener("click",n=>d(n,e)),e.setAttribute("data-headless-track-bound","true"))})});return m.observe(r,{childList:!0,subtree:!0}),r.querySelectorAll("[data-headless-type-name]").forEach(e=>{e.hasAttribute("data-headless-track-bound")||(e.addEventListener("click",n=>d(n,e)),e.setAttribute("data-headless-track-bound","true"))}),()=>m.disconnect()},[]);const k=T(()=>({...t,navCollapsed:l,setNavCollapsed:h}),[t,l]);return b(v.Provider,{value:k,children:b("div",{ref:p,children:o})})};var w=P;export{v as AiuiContext,w as default,S as useAiuiContext};
@@ -1 +1 @@
1
- "use client";import{Fragment as Ie,jsx as e,jsxs as o}from"react/jsx-runtime";import{forwardRef as ue,useCallback as de,useEffect as F,useImperativeHandle as Ae,useMemo as L,useRef as $,useState as P}from"react";import{Picture as Ne,Text as k,Button as me,Container as fe,BrandStrip as Oe}from"../../components/index.js";import{withLayout as je}from"../../shared/Styles.js";import{cn as x,getLocalizedPath as ne}from"../../helpers/utils.js";import _e,{useNavContext as re}from"./NavProvider.js";import{HeaderNavigationMenu as K,HeaderNavigationBlockType as C,HeaderNavigationActionBlockType as M}from"./types.js";import $e from"jump.js";import{useGSAP as be}from"@gsap/react";import{gsap as pe}from"gsap";import{WithSidebar as ke,WithSupports as xe,WithMulticol as Ce,WithGroupCategory as we,WithResource as Me}from"./withCategory.js";import{Menu as Ke,Close as Se,User as Ue,LeftArrow as We,DownArrow as ve,Polygon as Fe}from"./icons/index.js";import Ge from"../NavigationSearch/index.js";import{ResourceSidebarDropdown as Je}from"./ResourceSidebarDropdown.js";import{MobileResourceSidebarMenu as Ye}from"./MobileResourceSidebarMenu.js";import{SidebarDropdown as qe}from"./SidebarDropdown.js";import{useScrollLock as ge}from"./useScrollLock.js";import{MulticolDropdown as Qe}from"./MulticolDropdown.js";import{SupportsDropdown as Ve}from"./SupportsDropdown.js";import{MobileSidebarMenu as Xe}from"./MobileSidebarMenu.js";import{MobileSupportMenu as Ze}from"./MobileSupportMenu.js";import{MobileMulticolMenu as et}from"./MobileMulticolMenu.js";import{MenuItem as he}from"./MobileMenuComponents.js";import{useAiuiContext as oe}from"../AiuiProvider/index.js";import Te from"../../shared/throttle.js";import{useNavCollapse as tt}from"./useNavCollapse.js";const De=a=>!!a?.components?.length&&a?.components?.[0]?.blockType!==C.Links,Le=a=>a?.components?.[0]?.blockType===C.Links&&a?.components?.[0]?.url||a?.url||void 0,Pe=a=>a?.components?.[0]?.blockType===C.Links&&a?.components?.[0]?.target||a?.target,at=({groupCategories:a})=>e("div",{className:"pointer-events-none invisible absolute inset-x-0 top-0 overflow-hidden","aria-hidden":"true",children:e(fe,{className:"h-[92px]",children:e("nav",{className:"flex h-full items-end justify-between",children:a?.map((i,r)=>e("div",{className:"flex gap-3","data-nav-item":!0,children:i?.map(l=>o("div",{className:"flex items-center gap-1",children:[e(k,{html:l.text,"data-nav-item-label":!0,className:"desktop:text-pretty text-nowrap text-sm font-bold leading-[1.4]"}),De(l)&&e(ve,{className:"size-4 opacity-0","aria-hidden":"true"})]},l.id))},`measure-group-${r}`))})})}),Ee=ue((a,i)=>{const{data:{header:r}={},buildProps:l,event:g,profile:E,theme:c="light",isTop:n=!1,searchResult:u,onSearch:d,isSearching:m,keywords:H,onPrimaryNavClick:S,onSeriesProductClick:b,onSidebarNavClick:T,onMobileMenuToggle:Y,headerId:w,cartCount:R,menuData:z,render:I,componentOverrides:q,...G}=a,[h,A]=P(!1),[p,O]=P(!1),[Q,j]=P(!1),D=$(null),s=$(null),U=L(()=>we(r?.categories?.filter(y=>y?.pcShow)),[r]),B=tt(s),{setNavCollapsed:ie}=oe();F(()=>{ie?.(B)},[B,ie]),Ae(i,()=>s.current),F(()=>{s.current&&n&&$e(s.current,{duration:0,offset:s.current?.getBoundingClientRect()?.bottom||0})},[n]),F(()=>{if(n){O(!1),j(!1);return}let y=0,V=0,Z=0;const se=()=>document?.documentElement?.scrollTop||document?.body?.scrollTop||0,J=se();y=J,O(J>300),j(J>30);const _=Te(()=>{const W=se(),t=W-y;j(W>30),t>0?(V=0,Z+=t,Z>=300&&W>300&&O(!0)):t<0&&(Z=0,V+=Math.abs(t),V>=300&&(O(!1),V=0)),y=W},100);return window.addEventListener("scroll",_,{passive:!0}),()=>window.removeEventListener("scroll",_)},[n]),F(()=>{g&&(g.search=()=>A(!0))},[g]),be(()=>{D?.current&&h&&pe.fromTo(D.current,{height:0},{height:"auto",duration:.3})},[h]),ge(h);const X=L(()=>r?.bar?.actions?.find(y=>y?.blockType===M.Search)?.searchBar?.[0]||{},[r]),le=I?.mobileHeaderNavigation;return e(_e,{buildProps:l,profile:E,isMobile:B,event:g,payloadData:r,onSidebarNavClick:T,onSeriesProductClick:b,cartCount:R,componentOverrides:q,children:e("header",{...G,id:w||"header","data-ui-component-id":"HeaderNavigation",className:n?"relative z-[100] bg-white":x("sticky top-0 z-[100] transition-transform duration-500 ease-in-out",{"translate-y-[-100%]":p}),ref:s,children:o("div",{className:x("hover:bg-white hover:text-black",c==="light"?"text-black":"text-white",{"!bg-white transition-all duration-500 ease-in-out":!n&&Q},{"hover:!text-black":c==="dark","!text-black":!n&&Q}),onClick:()=>!n&&j(!0),children:[e(at,{groupCategories:U}),e("div",{className:x("hidden",B?"laptop:hidden":"laptop:block","desktop:block"),children:e(He,{data:r,groupCategories:U,theme:c,onNavItemClick:()=>!n&&j(!0),onPrimaryNavClick:S,className:"!bg-white"})}),e("div",{className:x("block",B?"laptop:block":"laptop:hidden","desktop:hidden"),children:le?e(le,{menuData:z,data:r,onPrimaryNavClick:S}):e(Re,{menuData:z,data:r,onPrimaryNavClick:S,onMobileMenuToggle:Y,className:"!bg-white"})}),h&&o("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${s?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[e("div",{ref:D,className:x("overflow-y-auto",{}),children:e(Ge,{data:X,keywords:H,isSearching:m,searchResult:u,onSearch:y=>{d?.(y)},onClose:()=>{d?.(),A(!1)}})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>A(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:y=>{(y.key==="Enter"||y.key===" "||y.key==="Escape")&&(y.preventDefault(),A(!1))}})]})]})})})}),He=ue((a,i)=>{const{data:r,onNavItemClick:l,className:g,theme:E,onPrimaryNavClick:c,groupCategories:n}=a,{event:u,profile:d}=re(),[m,H]=P(!1),{locale:S="us"}=oe(),[b,T]=P(null),[Y,w]=P([]),R=$(null),[z,I]=P(!1),q=$(null),G=$(null),h=$(null),A=$(n.map(t=>Array(t?.length||0).fill(null)));F(()=>{n?.length&&w(n?.map((t,f)=>t?.map((v,N)=>({groupIndex:f,index:N,open:!1}))))},[n]);const p=L(()=>{let t=null;for(const f of Y){for(const v of f)if(v.open){t=v;break}if(t)break}return t},[Y]);ge(!!p?.open||z);const O=(t,f)=>{I(!1),l?.();const v=n?.flat()||[],N=v?.findIndex(ee=>ee?.id===n[t][f]?.id);c?.(v[N],N)},Q=(t,f)=>{const v=n[t][f],N=v?.components?.[0];N&&N?.blockType!==C.Links&&(T(v),w(te=>te.map(ae=>ae.map(ce=>ce.groupIndex===t&&ce.index===f?{...ce,open:!0}:{...ce,open:!1}))))},j=(t,f,v)=>{t.key==="Escape"&&p?.groupIndex===f&&p?.index===v&&(t.preventDefault(),D())},D=()=>{w(t=>t.map(f=>f.map(v=>({...v,open:!1}))))},s=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{D()},200)},U=()=>{h.current&&clearTimeout(h.current)},B=()=>{h.current&&clearTimeout(h.current)},ie=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{D()},200)},X=L(()=>{if(b)return b?.components?.[0]?.blockType},[b]),le=ke(qe,b),y=Me(Je,b),V=Ce(Qe,b),Z=xe(Ve,{categoriesItem:b,currentNavItemRef:A.current?.[p?.groupIndex||0]?.[p?.index||0]}),se=L(()=>{switch(X){case C.Sidebar:return e(le,{});case C.Resource:return e(y,{});case C.Supports:return e(Z,{});case C.Multicol:return e(V,{});default:return null}},[X,b]),J=L(()=>r?.bar?.actions?.filter(t=>t?.pcShow),[r]),_=L(()=>J?.find(t=>t?.blockType===M.Profile),[J]),W=de(()=>{I(t=>!t)},[]);return F(()=>{if(R?.current){const t=R.current;return t.addEventListener("click",W),()=>{t.removeEventListener("click",W)}}},[W]),be(()=>{p?.open&&G?.current&&pe.fromTo(G?.current,{height:0},{height:"auto"})},[p?.open]),o(fe,{className:x("relative h-[92px]",g),children:[o("div",{ref:q,onClick:D,className:"flex h-full flex-col justify-end gap-4",children:[o("div",{className:"flex items-center justify-between",children:[e(Be,{}),e(ye,{ref:R,actions:J,activeStatus:z})]}),e("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",onMouseEnter:U,onMouseLeave:s,children:n?.map((t,f)=>e("div",{className:"flex gap-3",children:t?.map((v,N)=>{const ee=p?.groupIndex===f&&p?.index===N,te=Pe(v);return e("div",{ref:ae=>{A.current[f][N]=ae},className:"group",onMouseEnter:()=>Q(f,N),children:o("div",{className:"relative",children:[o("a",{href:ne(Le(v),S,"ref=navMenu"),...te?{target:te}:{},rel:te==="_blank"?"noopener noreferrer":void 0,className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4 no-underline",onClick:()=>O(f,N),onKeyDown:ae=>j(ae,f,N),"aria-expanded":ee,"aria-haspopup":"true","aria-label":v.text,children:[e(k,{html:v.text,className:"desktop:text-pretty text-nowrap text-sm font-bold leading-[1.4]"}),e(ve,{className:x("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":p?.groupIndex===f&&p?.index===N,"opacity-100":m&&p?.groupIndex===f&&p?.index===N,hidden:!De(v)})})]}),e("div",{className:x("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":ee},E==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},v.id)})},`groupCategory-${f}`))})]}),o("div",{role:"menu","aria-hidden":!(p?.open&&b),className:x("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(p?.open&&b)}),style:{height:`calc(100dvh - ${q?.current?.getBoundingClientRect()?.bottom}px)`},children:[e("div",{ref:G,className:x("relative z-50",{"overflow-hidden":X!==C.Supports}),onMouseEnter:()=>{B(),H(!0)},onMouseLeave:()=>{ie(),H(!1)},children:se}),e("div",{className:"flex-1 bg-transparent",onClick:D,onMouseEnter:D,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:t=>{(t.key==="Enter"||t.key===" "||t.key==="Escape")&&(t.preventDefault(),D())}})]}),z&&o("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[e("div",{className:"rounded-box absolute w-[272px] overflow-hidden bg-white p-4",style:{right:`calc(100% - ${R?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:d?.email?o(Ie,{children:[e(k,{html:d?.nick_name||_?.welcome,className:"text-sm font-bold"}),e("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),e("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:_?.profiles?.map(t=>e(he,{className:"py-2",label:t?.title,href:ne(t?.url,S,"ref=navMenu")},t.id))})]}):o(Ie,{children:[e(Fe,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),e(k,{html:_?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:_?.benefits?.map(t=>o("div",{className:"flex items-center gap-[6px]",children:[e(Ne,{source:t.benefitIcon?.url,className:"size-4 shrink-0",alt:t.benefit,width:16,height:16}),e(k,{html:t.benefit,className:"text-sm font-bold leading-[1.4]"})]},t.id))}),o("div",{className:"mt-4 flex flex-wrap gap-2",children:[e(me,{className:"grow",variant:"secondary",size:"lg",onClick:()=>u?.join?.(),children:e(k,{html:_?.primaryButton||"Join Now",className:"font-bold"})}),e(me,{className:"grow",variant:"primary",size:"lg",onClick:()=>u?.login?.(),children:e(k,{html:_?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>I(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:t=>{(t.key==="Enter"||t.key===" "||t.key==="Escape")&&(t.preventDefault(),I(!1))}})]})]})}),Re=ue(({data:a,menuData:i,className:r,onPrimaryNavClick:l,onMobileMenuToggle:g},E)=>{const c=L(()=>we(a?.categories?.filter(s=>s?.mobileShow)),[a]),{currentMenu:n,setCurrentMenu:u,subSubCategory:d}=re(),[m,H]=P(!1),[S,b]=P(0),[T,Y]=P(null),w=$(null),R=$(!1);F(()=>{if(w?.current&&m){const s=w?.current?.getBoundingClientRect();b(window?.innerHeight-(s?.top||0))}g?.({open:m})},[m,g]),F(()=>{if(!m)return;const s=Te(()=>{if(w?.current){const U=w.current.getBoundingClientRect();R.current=!0,b(window?.innerHeight-(U?.top||0))}},100);return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[m]),be(()=>{if(w.current){if(R.current){pe.set(w.current,{height:S}),R.current=!1;return}pe.fromTo(w.current,{height:0},{height:S,duration:.3})}},[S]),ge(m);const z=L(()=>T?.components?.[0]?.blockType,[T]),I=xe(Ze,{categoriesItem:T}),q=ke(Xe,T),G=Me(Ye,T),h=Ce(et,T),A=L(()=>{switch(z){case C.Sidebar:return e(q,{});case C.Resource:return e(G,{});case C.Supports:return e(I,{});case C.Multicol:return e(h,{});default:return null}},[z,T,I]),p=de(()=>{H(!1),b(0),u&&u(K.Primary)},[H,b,u]),O=L(()=>a?.bar?.actions?.filter(s=>s?.mobileShow&&s?.blockType!==M.Profile),[a]),Q=L(()=>a?.bar?.actions?.find(s=>s?.mobileShow&&s?.blockType===M.Profile)||{},[a]),j=L(()=>{switch(n){case K.Primary:return e(ot,{actions:O,menuOpen:m,onMenuOpenClose:()=>{H(!1),b(0)},onMenuOpenClick:()=>H(!0)});case K.Secondary:return e(ze,{title:T?.text,onMenuOpenClose:p,onMenuBackClick:()=>u?.(K.Primary)});case K.Third:return e(ze,{title:d?.label,onMenuOpenClose:p,onMenuBackClick:()=>u?.(K.Secondary)});default:return null}},[m,n,u,T,O,d,p]),D=de((s,U)=>{const B=Array.isArray(c)?Array.isArray(c[s])?c[s][U]:{}:{};B?.components?.[0]?.blockType!==C.Links&&(Y(B),u?.(K.Secondary))},[c,u]);return o(fe,{className:x("relative h-[56px]",r),children:[j,m&&o("nav",{ref:w,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:S},role:"navigation","aria-label":"Mobile navigation menu",children:[n===K.Primary&&i?e("div",{className:"pt-4",children:e(Oe,{data:i})}):null,n===K.Primary?e(nt,{categories:c,onPrimaryMenuClick:D,onPrimaryNavClick:l,profileAction:Q,menuData:i}):A]})]})}),nt=({categories:a,onPrimaryMenuClick:i,profileAction:r,onPrimaryNavClick:l,menuData:g})=>{const{locale:E="us"}=oe();return o("div",{className:"flex h-full flex-col justify-between",children:[e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:a?.map((c,n)=>o("div",{className:"",children:[n>0||g?e("div",{className:x("my-2 h-px w-full bg-[#E5E5E7]")}):null,c?.map((u,d)=>{const m=u.components?.[0]?.blockType===C.Links;return e(he,{label:u.text,href:m?ne(Le(u),E,"ref=navMenu"):void 0,target:m?Pe(u):void 0,onClick:()=>{const S=(a?.flat()||[])?.findIndex(b=>b?.id===a[n][d]?.id);i(n,d),l?.(u,S)},icon:u.components?.[0]?.icon},u.id)})]},`groupCategory-${n}`))}),e(rt,{profileAction:r})]})},rt=({profileAction:a})=>{const[i,r]=P(!1),{profile:l,event:g}=re(),{locale:E="us"}=oe();return o("div",{className:x("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":i}),children:[o("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>r(!i),"aria-expanded":i,"aria-label":l?.nick_name||a?.welcome,children:[o("div",{className:"flex items-center gap-[14px]",children:[e("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:e(Ue,{"aria-hidden":"true"})}),e(k,{html:l?.nick_name||a?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!l?.email&&e(ve,{"aria-hidden":"true",className:x("laptop:size-4 size-5",{"rotate-180":i})})]}),l?.email&&e("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:a?.profiles?.map(c=>e(he,{label:c?.title,href:ne(c?.url,E,"ref=navMenu")},c.id))}),i&&!l?.email&&o("div",{className:"mt-4",children:[e(k,{html:a?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:a?.benefits?.map(c=>o("div",{className:"flex items-center gap-[6px]",children:[e(Ne,{source:c.benefitIcon?.url,className:"size-4",alt:c.benefit,width:16,height:16}),e(k,{html:c.benefit,className:"text-sm font-bold leading-[1.4]"})]},c.id))})]}),!l?.email&&o("div",{className:"mt-4 flex items-center gap-3",children:[e(me,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>g?.join?.(),children:e(k,{html:a?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),e(me,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>g?.login?.(),children:e(k,{html:a?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},ot=({menuOpen:a,onMenuOpenClose:i,onMenuOpenClick:r,actions:l})=>o("div",{className:"flex h-full items-center justify-between gap-4",children:[e(Be,{}),o("div",{className:"desktop:gap-6 flex items-center gap-4",children:[e(ye,{actions:l}),a?e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Close menu","aria-expanded":"true",children:e(Se,{className:"size-5","aria-hidden":"true"})}):e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:e(Ke,{className:"size-5","aria-hidden":"true"})})]})]}),Be=()=>{const{payloadData:a,isMobile:i}=re(),{locale:r="us"}=oe();return e("a",{href:ne("/",r,"ref=logo"),className:"hover:text-[#00CBEB] [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:i?a?.bar?.mobileLogo:a?.bar?.desktopLogo}})},ye=ue(({actions:a,activeStatus:i=!1},r)=>{const{event:l,cartCount:g}=re(),[E,c]=P(null),n=d=>{switch(d){case M.Search:return"Search";case M.Cart:return`Shopping cart${g>0?` (${g} items)`:""}`;case M.Profile:return"User profile";case M.Livestream:return"Livestream";default:return"Action"}},u=de((d,m)=>{switch(c(m),d?.blockType){case M.Search:l?.search?.();break;case M.Cart:l?.cart?.();break;case M.Profile:l?.profile?.();break;case M.Livestream:l?.livestream?.();break;default:return()=>{}}},[l]);return e("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(a)&&a?.map((d,m)=>o("button",{className:"relative cursor-pointer border-0 bg-transparent p-0","data-tag":d?.tag||"",ref:d.blockType===M.Profile?r:null,onClick:()=>u(d,m),"aria-label":n(d.blockType),"aria-pressed":i&&E===m,children:[e(k,{html:d.icon,className:x("size-5",{"text-brand-0":i&&E===m}),"aria-hidden":"true"}),d.blockType===M.Cart&&g>0&&e("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:e(k,{html:g?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},d.id))})}),ze=({title:a,onMenuOpenClose:i,onMenuBackClick:r})=>o("div",{className:"flex h-full items-center gap-3",children:[e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Back to previous menu",children:e(We,{className:"size-5","aria-hidden":"true"})}),e(k,{html:a,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Close menu",children:e(Se,{className:"size-5","aria-hidden":"true"})})]});Re.displayName="MobileNavigation",ye.displayName="Actions",Ee.displayName="HeaderNavigation",He.displayName="DesktopNavigation";var Ht=je(Ee);export{Ht as default};
1
+ "use client";import{Fragment as Ie,jsx as e,jsxs as o}from"react/jsx-runtime";import{forwardRef as ue,useCallback as de,useEffect as F,useImperativeHandle as Ae,useMemo as L,useRef as $,useState as P}from"react";import{Picture as Ne,Text as k,Button as me,Container as fe,BrandStrip as Oe}from"../../components/index.js";import{withLayout as je}from"../../shared/Styles.js";import{cn as x,getLocalizedPath as re}from"../../helpers/utils.js";import _e,{useNavContext as oe}from"./NavProvider.js";import{HeaderNavigationMenu as K,HeaderNavigationBlockType as C,HeaderNavigationActionBlockType as M}from"./types.js";import $e from"jump.js";import{useGSAP as be}from"@gsap/react";import{gsap as pe}from"gsap";import{WithSidebar as ke,WithSupports as xe,WithMulticol as Ce,WithGroupCategory as we,WithResource as Me}from"./withCategory.js";import{Menu as Ke,Close as Se,User as Ue,LeftArrow as We,DownArrow as ve,Polygon as Fe}from"./icons/index.js";import Ge from"../NavigationSearch/index.js";import{ResourceSidebarDropdown as Je}from"./ResourceSidebarDropdown.js";import{MobileResourceSidebarMenu as Ye}from"./MobileResourceSidebarMenu.js";import{SidebarDropdown as qe}from"./SidebarDropdown.js";import{useScrollLock as ge}from"./useScrollLock.js";import{MulticolDropdown as Qe}from"./MulticolDropdown.js";import{SupportsDropdown as Ve}from"./SupportsDropdown.js";import{MobileSidebarMenu as Xe}from"./MobileSidebarMenu.js";import{MobileSupportMenu as Ze}from"./MobileSupportMenu.js";import{MobileMulticolMenu as et}from"./MobileMulticolMenu.js";import{MenuItem as he}from"./MobileMenuComponents.js";import{useAiuiContext as ie}from"../AiuiProvider/index.js";import Te from"../../shared/throttle.js";import{useNavCollapse as tt}from"./useNavCollapse.js";const De=a=>!!a?.components?.length&&a?.components?.[0]?.blockType!==C.Links,Le=a=>a?.components?.[0]?.blockType===C.Links&&a?.components?.[0]?.url||a?.url||void 0,Pe=a=>a?.components?.[0]?.blockType===C.Links&&a?.components?.[0]?.target||a?.target,at=({groupCategories:a})=>e("div",{className:"pointer-events-none invisible absolute inset-x-0 top-0 overflow-hidden","aria-hidden":"true",children:e(fe,{className:"h-[92px]",children:e("nav",{className:"flex h-full items-end justify-between",children:a?.map((i,r)=>e("div",{className:"flex gap-3","data-nav-item":!0,children:i?.map(l=>o("div",{className:"flex items-center gap-1",children:[e(k,{html:l.text,"data-nav-item-label":!0,className:"desktop:text-pretty text-nowrap text-sm font-bold leading-[1.4]"}),De(l)&&e(ve,{className:"size-4 opacity-0","aria-hidden":"true"})]},l.id))},`measure-group-${r}`))})})}),Ee=ue((a,i)=>{const{data:{header:r}={},buildProps:l,event:g,profile:E,theme:c="light",isTop:n=!1,searchResult:u,onSearch:d,isSearching:m,keywords:H,onPrimaryNavClick:S,onSeriesProductClick:b,onSidebarNavClick:T,onMobileMenuToggle:Y,headerId:w,cartCount:R,menuData:z,render:I,componentOverrides:q,...G}=a,[h,A]=P(!1),[p,O]=P(!1),[Q,j]=P(!1),D=$(null),s=$(null),U=L(()=>we(r?.categories?.filter(y=>y?.pcShow)),[r]),B=tt(s),{setNavCollapsed:X}=ie();F(()=>(X?.(B),()=>X?.(void 0)),[B,X]),Ae(i,()=>s.current),F(()=>{s.current&&n&&$e(s.current,{duration:0,offset:s.current?.getBoundingClientRect()?.bottom||0})},[n]),F(()=>{if(n){O(!1),j(!1);return}let y=0,V=0,ee=0;const se=()=>document?.documentElement?.scrollTop||document?.body?.scrollTop||0,J=se();y=J,O(J>300),j(J>30);const _=Te(()=>{const W=se(),t=W-y;j(W>30),t>0?(V=0,ee+=t,ee>=300&&W>300&&O(!0)):t<0&&(ee=0,V+=Math.abs(t),V>=300&&(O(!1),V=0)),y=W},100);return window.addEventListener("scroll",_,{passive:!0}),()=>window.removeEventListener("scroll",_)},[n]),F(()=>{g&&(g.search=()=>A(!0))},[g]),be(()=>{D?.current&&h&&pe.fromTo(D.current,{height:0},{height:"auto",duration:.3})},[h]),ge(h);const Z=L(()=>r?.bar?.actions?.find(y=>y?.blockType===M.Search)?.searchBar?.[0]||{},[r]),le=I?.mobileHeaderNavigation;return e(_e,{buildProps:l,profile:E,isMobile:B,event:g,payloadData:r,onSidebarNavClick:T,onSeriesProductClick:b,cartCount:R,componentOverrides:q,children:e("header",{...G,id:w||"header","data-ui-component-id":"HeaderNavigation",className:n?"relative z-[100] bg-white":x("sticky top-0 z-[100] transition-transform duration-500 ease-in-out",{"translate-y-[-100%]":p}),ref:s,children:o("div",{className:x("hover:bg-white hover:text-black",c==="light"?"text-black":"text-white",{"!bg-white transition-all duration-500 ease-in-out":!n&&Q},{"hover:!text-black":c==="dark","!text-black":!n&&Q}),onClick:()=>!n&&j(!0),children:[e(at,{groupCategories:U}),e("div",{className:x("hidden",B?"laptop:hidden":"laptop:block","desktop:block"),children:e(He,{data:r,groupCategories:U,theme:c,onNavItemClick:()=>!n&&j(!0),onPrimaryNavClick:S,className:"!bg-white"})}),e("div",{className:x("block",B?"laptop:block":"laptop:hidden","desktop:hidden"),children:le?e(le,{menuData:z,data:r,onPrimaryNavClick:S}):e(Re,{menuData:z,data:r,onPrimaryNavClick:S,onMobileMenuToggle:Y,className:"!bg-white"})}),h&&o("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${s?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[e("div",{ref:D,className:x("overflow-y-auto",{}),children:e(Ge,{data:Z,keywords:H,isSearching:m,searchResult:u,onSearch:y=>{d?.(y)},onClose:()=>{d?.(),A(!1)}})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>A(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:y=>{(y.key==="Enter"||y.key===" "||y.key==="Escape")&&(y.preventDefault(),A(!1))}})]})]})})})}),He=ue((a,i)=>{const{data:r,onNavItemClick:l,className:g,theme:E,onPrimaryNavClick:c,groupCategories:n}=a,{event:u,profile:d}=oe(),[m,H]=P(!1),{locale:S="us"}=ie(),[b,T]=P(null),[Y,w]=P([]),R=$(null),[z,I]=P(!1),q=$(null),G=$(null),h=$(null),A=$(n.map(t=>Array(t?.length||0).fill(null)));F(()=>{n?.length&&w(n?.map((t,f)=>t?.map((v,N)=>({groupIndex:f,index:N,open:!1}))))},[n]);const p=L(()=>{let t=null;for(const f of Y){for(const v of f)if(v.open){t=v;break}if(t)break}return t},[Y]);ge(!!p?.open||z);const O=(t,f)=>{I(!1),l?.();const v=n?.flat()||[],N=v?.findIndex(te=>te?.id===n[t][f]?.id);c?.(v[N],N)},Q=(t,f)=>{const v=n[t][f],N=v?.components?.[0];N&&N?.blockType!==C.Links&&(T(v),w(ae=>ae.map(ne=>ne.map(ce=>ce.groupIndex===t&&ce.index===f?{...ce,open:!0}:{...ce,open:!1}))))},j=(t,f,v)=>{t.key==="Escape"&&p?.groupIndex===f&&p?.index===v&&(t.preventDefault(),D())},D=()=>{w(t=>t.map(f=>f.map(v=>({...v,open:!1}))))},s=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{D()},200)},U=()=>{h.current&&clearTimeout(h.current)},B=()=>{h.current&&clearTimeout(h.current)},X=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{D()},200)},Z=L(()=>{if(b)return b?.components?.[0]?.blockType},[b]),le=ke(qe,b),y=Me(Je,b),V=Ce(Qe,b),ee=xe(Ve,{categoriesItem:b,currentNavItemRef:A.current?.[p?.groupIndex||0]?.[p?.index||0]}),se=L(()=>{switch(Z){case C.Sidebar:return e(le,{});case C.Resource:return e(y,{});case C.Supports:return e(ee,{});case C.Multicol:return e(V,{});default:return null}},[Z,b]),J=L(()=>r?.bar?.actions?.filter(t=>t?.pcShow),[r]),_=L(()=>J?.find(t=>t?.blockType===M.Profile),[J]),W=de(()=>{I(t=>!t)},[]);return F(()=>{if(R?.current){const t=R.current;return t.addEventListener("click",W),()=>{t.removeEventListener("click",W)}}},[W]),be(()=>{p?.open&&G?.current&&pe.fromTo(G?.current,{height:0},{height:"auto"})},[p?.open]),o(fe,{className:x("relative h-[92px]",g),children:[o("div",{ref:q,onClick:D,className:"flex h-full flex-col justify-end gap-4",children:[o("div",{className:"flex items-center justify-between",children:[e(Be,{}),e(ye,{ref:R,actions:J,activeStatus:z})]}),e("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",onMouseEnter:U,onMouseLeave:s,children:n?.map((t,f)=>e("div",{className:"flex gap-3",children:t?.map((v,N)=>{const te=p?.groupIndex===f&&p?.index===N,ae=Pe(v);return e("div",{ref:ne=>{A.current[f][N]=ne},className:"group",onMouseEnter:()=>Q(f,N),children:o("div",{className:"relative",children:[o("a",{href:re(Le(v),S,"ref=navMenu"),...ae?{target:ae}:{},rel:ae==="_blank"?"noopener noreferrer":void 0,className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4 no-underline",onClick:()=>O(f,N),onKeyDown:ne=>j(ne,f,N),"aria-expanded":te,"aria-haspopup":"true","aria-label":v.text,children:[e(k,{html:v.text,className:"desktop:text-pretty text-nowrap text-sm font-bold leading-[1.4]"}),e(ve,{className:x("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":p?.groupIndex===f&&p?.index===N,"opacity-100":m&&p?.groupIndex===f&&p?.index===N,hidden:!De(v)})})]}),e("div",{className:x("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":te},E==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},v.id)})},`groupCategory-${f}`))})]}),o("div",{role:"menu","aria-hidden":!(p?.open&&b),className:x("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(p?.open&&b)}),style:{height:`calc(100dvh - ${q?.current?.getBoundingClientRect()?.bottom}px)`},children:[e("div",{ref:G,className:x("relative z-50",{"overflow-hidden":Z!==C.Supports}),onMouseEnter:()=>{B(),H(!0)},onMouseLeave:()=>{X(),H(!1)},children:se}),e("div",{className:"flex-1 bg-transparent",onClick:D,onMouseEnter:D,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:t=>{(t.key==="Enter"||t.key===" "||t.key==="Escape")&&(t.preventDefault(),D())}})]}),z&&o("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[e("div",{className:"rounded-box absolute w-[272px] overflow-hidden bg-white p-4",style:{right:`calc(100% - ${R?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:d?.email?o(Ie,{children:[e(k,{html:d?.nick_name||_?.welcome,className:"text-sm font-bold"}),e("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),e("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:_?.profiles?.map(t=>e(he,{className:"py-2",label:t?.title,href:re(t?.url,S,"ref=navMenu")},t.id))})]}):o(Ie,{children:[e(Fe,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),e(k,{html:_?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:_?.benefits?.map(t=>o("div",{className:"flex items-center gap-[6px]",children:[e(Ne,{source:t.benefitIcon?.url,className:"size-4 shrink-0",alt:t.benefit,width:16,height:16}),e(k,{html:t.benefit,className:"text-sm font-bold leading-[1.4]"})]},t.id))}),o("div",{className:"mt-4 flex flex-wrap gap-2",children:[e(me,{className:"grow",variant:"secondary",size:"lg",onClick:()=>u?.join?.(),children:e(k,{html:_?.primaryButton||"Join Now",className:"font-bold"})}),e(me,{className:"grow",variant:"primary",size:"lg",onClick:()=>u?.login?.(),children:e(k,{html:_?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),e("div",{className:"flex-1 bg-transparent",onClick:()=>I(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:t=>{(t.key==="Enter"||t.key===" "||t.key==="Escape")&&(t.preventDefault(),I(!1))}})]})]})}),Re=ue(({data:a,menuData:i,className:r,onPrimaryNavClick:l,onMobileMenuToggle:g},E)=>{const c=L(()=>we(a?.categories?.filter(s=>s?.mobileShow)),[a]),{currentMenu:n,setCurrentMenu:u,subSubCategory:d}=oe(),[m,H]=P(!1),[S,b]=P(0),[T,Y]=P(null),w=$(null),R=$(!1);F(()=>{if(w?.current&&m){const s=w?.current?.getBoundingClientRect();b(window?.innerHeight-(s?.top||0))}g?.({open:m})},[m,g]),F(()=>{if(!m)return;const s=Te(()=>{if(w?.current){const U=w.current.getBoundingClientRect();R.current=!0,b(window?.innerHeight-(U?.top||0))}},100);return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[m]),be(()=>{if(w.current){if(R.current){pe.set(w.current,{height:S}),R.current=!1;return}pe.fromTo(w.current,{height:0},{height:S,duration:.3})}},[S]),ge(m);const z=L(()=>T?.components?.[0]?.blockType,[T]),I=xe(Ze,{categoriesItem:T}),q=ke(Xe,T),G=Me(Ye,T),h=Ce(et,T),A=L(()=>{switch(z){case C.Sidebar:return e(q,{});case C.Resource:return e(G,{});case C.Supports:return e(I,{});case C.Multicol:return e(h,{});default:return null}},[z,T,I]),p=de(()=>{H(!1),b(0),u&&u(K.Primary)},[H,b,u]),O=L(()=>a?.bar?.actions?.filter(s=>s?.mobileShow&&s?.blockType!==M.Profile),[a]),Q=L(()=>a?.bar?.actions?.find(s=>s?.mobileShow&&s?.blockType===M.Profile)||{},[a]),j=L(()=>{switch(n){case K.Primary:return e(ot,{actions:O,menuOpen:m,onMenuOpenClose:()=>{H(!1),b(0)},onMenuOpenClick:()=>H(!0)});case K.Secondary:return e(ze,{title:T?.text,onMenuOpenClose:p,onMenuBackClick:()=>u?.(K.Primary)});case K.Third:return e(ze,{title:d?.label,onMenuOpenClose:p,onMenuBackClick:()=>u?.(K.Secondary)});default:return null}},[m,n,u,T,O,d,p]),D=de((s,U)=>{const B=Array.isArray(c)?Array.isArray(c[s])?c[s][U]:{}:{};B?.components?.[0]?.blockType!==C.Links&&(Y(B),u?.(K.Secondary))},[c,u]);return o(fe,{className:x("relative h-[56px]",r),children:[j,m&&o("nav",{ref:w,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:S},role:"navigation","aria-label":"Mobile navigation menu",children:[n===K.Primary&&i?e("div",{className:"pt-4",children:e(Oe,{data:i})}):null,n===K.Primary?e(nt,{categories:c,onPrimaryMenuClick:D,onPrimaryNavClick:l,profileAction:Q,menuData:i}):A]})]})}),nt=({categories:a,onPrimaryMenuClick:i,profileAction:r,onPrimaryNavClick:l,menuData:g})=>{const{locale:E="us"}=ie();return o("div",{className:"flex h-full flex-col justify-between",children:[e("div",{className:"tablet:px-8 laptop:px-16 p-4",children:a?.map((c,n)=>o("div",{className:"",children:[n>0||g?e("div",{className:x("my-2 h-px w-full bg-[#E5E5E7]")}):null,c?.map((u,d)=>{const m=u.components?.[0]?.blockType===C.Links;return e(he,{label:u.text,href:m?re(Le(u),E,"ref=navMenu"):void 0,target:m?Pe(u):void 0,onClick:()=>{const S=(a?.flat()||[])?.findIndex(b=>b?.id===a[n][d]?.id);i(n,d),l?.(u,S)},icon:u.components?.[0]?.icon},u.id)})]},`groupCategory-${n}`))}),e(rt,{profileAction:r})]})},rt=({profileAction:a})=>{const[i,r]=P(!1),{profile:l,event:g}=oe(),{locale:E="us"}=ie();return o("div",{className:x("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":i}),children:[o("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>r(!i),"aria-expanded":i,"aria-label":l?.nick_name||a?.welcome,children:[o("div",{className:"flex items-center gap-[14px]",children:[e("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:e(Ue,{"aria-hidden":"true"})}),e(k,{html:l?.nick_name||a?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!l?.email&&e(ve,{"aria-hidden":"true",className:x("laptop:size-4 size-5",{"rotate-180":i})})]}),l?.email&&e("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:a?.profiles?.map(c=>e(he,{label:c?.title,href:re(c?.url,E,"ref=navMenu")},c.id))}),i&&!l?.email&&o("div",{className:"mt-4",children:[e(k,{html:a?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),e("div",{className:"mt-2 flex flex-col gap-1",children:a?.benefits?.map(c=>o("div",{className:"flex items-center gap-[6px]",children:[e(Ne,{source:c.benefitIcon?.url,className:"size-4",alt:c.benefit,width:16,height:16}),e(k,{html:c.benefit,className:"text-sm font-bold leading-[1.4]"})]},c.id))})]}),!l?.email&&o("div",{className:"mt-4 flex items-center gap-3",children:[e(me,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>g?.join?.(),children:e(k,{html:a?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),e(me,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>g?.login?.(),children:e(k,{html:a?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},ot=({menuOpen:a,onMenuOpenClose:i,onMenuOpenClick:r,actions:l})=>o("div",{className:"flex h-full items-center justify-between gap-4",children:[e(Be,{}),o("div",{className:"desktop:gap-6 flex items-center gap-4",children:[e(ye,{actions:l}),a?e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Close menu","aria-expanded":"true",children:e(Se,{className:"size-5","aria-hidden":"true"})}):e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:e(Ke,{className:"size-5","aria-hidden":"true"})})]})]}),Be=()=>{const{payloadData:a,isMobile:i}=oe(),{locale:r="us"}=ie();return e("a",{href:re("/",r,"ref=logo"),className:"hover:text-[#00CBEB] [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:i?a?.bar?.mobileLogo:a?.bar?.desktopLogo}})},ye=ue(({actions:a,activeStatus:i=!1},r)=>{const{event:l,cartCount:g}=oe(),[E,c]=P(null),n=d=>{switch(d){case M.Search:return"Search";case M.Cart:return`Shopping cart${g>0?` (${g} items)`:""}`;case M.Profile:return"User profile";case M.Livestream:return"Livestream";default:return"Action"}},u=de((d,m)=>{switch(c(m),d?.blockType){case M.Search:l?.search?.();break;case M.Cart:l?.cart?.();break;case M.Profile:l?.profile?.();break;case M.Livestream:l?.livestream?.();break;default:return()=>{}}},[l]);return e("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(a)&&a?.map((d,m)=>o("button",{className:"relative cursor-pointer border-0 bg-transparent p-0","data-tag":d?.tag||"",ref:d.blockType===M.Profile?r:null,onClick:()=>u(d,m),"aria-label":n(d.blockType),"aria-pressed":i&&E===m,children:[e(k,{html:d.icon,className:x("size-5",{"text-brand-0":i&&E===m}),"aria-hidden":"true"}),d.blockType===M.Cart&&g>0&&e("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:e(k,{html:g?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},d.id))})}),ze=({title:a,onMenuOpenClose:i,onMenuBackClick:r})=>o("div",{className:"flex h-full items-center gap-3",children:[e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Back to previous menu",children:e(We,{className:"size-5","aria-hidden":"true"})}),e(k,{html:a,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),e("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Close menu",children:e(Se,{className:"size-5","aria-hidden":"true"})})]});Re.displayName="MobileNavigation",ye.displayName="Actions",Ee.displayName="HeaderNavigation",He.displayName="DesktopNavigation";var Ht=je(Ee);export{Ht as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/headless-ui",
3
- "version": "1.3.75",
3
+ "version": "1.3.76",
4
4
  "type": "commonjs",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/cjs/index.d.ts",