'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),Link=require("next/link"),React=require("react"),reactTransitionGroup=require("react-transition-group"),ChevronLeft=require("../../icons/ChevronLeft.js"),Dismiss=require("../../icons/Dismiss.js");const duration=300,defaultStyle={transitionDuration:"300ms",opacity:0},transitionStyles={entering:{opacity:1,transform:"translateX(0)"},entered:{opacity:1,transform:"translateX(0)"},exiting:{opacity:0,transform:"translateX(50px)"},exited:{opacity:0,transform:"translateX(50px)"},unmounted:{opacity:0}},MenuMobileItem=({id:e,menu:t,arrow:s,menuBg:l,menuTextColor:r,closeMenu:n,depth:i=0,maxDepth:a=2,typo:o,typography:p,enableHoverEffect:c})=>{let[u,g]=React.useState(!1),m=React.useRef(null),x=core.composeTypographyStyle(o,p),d=t?.[e];if(!d||i>a)return null;let f=i===a,j=!!d?.childrens?.length&&!f,y=j&&!!s,h=e=>{e.preventDefault(),e.stopPropagation(),g(e=>!e)},b=core.getGlobalColorStateStyle("c",r),R=c?b:core.filterHoverVariables(b);return jsxRuntime.jsxs("li",{className:core.cls("gp-group gp-flex gp-cursor-pointer gp-gap-2 gp-whitespace-nowrap gp-px-4 gp-py-2",{"gp-flex-col gp-border-b last:gp-border-b-transparent":i>0}),style:{...R,...core.getGlobalColorResponsiveStyle("bgc",l)},children:[jsxRuntime.jsxs("div",{className:"gp-flex gp-w-full gp-items-center gp-justify-between","aria-hidden":!0,onClick:!d?.link&&y?h:void 0,children:[d?.link?jsxRuntime.jsx(Link,{href:d.link,title:d.title,className:"gp-w-full",children:d.title}):jsxRuntime.jsx("span",{style:{...x},children:d?.title}),y&&jsxRuntime.jsx("span",{role:"button",tabIndex:0,"aria-expanded":u,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&h(e)},onClick:h,dangerouslySetInnerHTML:{__html:s},className:core.cls("gp-ml-auto gp-transition-all gp-duration-200 [&>svg]:gp-w-5",{"gp-rotate-0":i>0&&!u,"gp-rotate-180":i>0&&u,"-gp-rotate-90":0===i}),style:{...x}})]}),j&&jsxRuntime.jsx(reactTransitionGroup.Transition,{in:u,timeout:300,nodeRef:m,unmountOnExit:!0,children:e=>jsxRuntime.jsxs("div",{ref:m,className:core.cls("gp-z-10 gp-flex gp-cursor-default gp-flex-col gp-transition-all",{"gp-absolute gp-left-0 gp-top-0 gp-h-full gp-w-full":0===i}),style:{...core.getGlobalColorResponsiveStyle("bgc",l),...defaultStyle,...transitionStyles[e]},children:[0===i&&jsxRuntime.jsxs("div",{className:"gp-relative gp-flex gp-h-10 gp-w-full gp-items-center gp-justify-between gp-border-b",children:[jsxRuntime.jsx("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),g(!1)},className:"gp-relative gp-z-1 gp-flex gp-aspect-square gp-h-full gp-items-center gp-justify-center",children:jsxRuntime.jsx(ChevronLeft.default,{className:"gp-w-5"})}),jsxRuntime.jsx("div",{"aria-hidden":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),g(!1)},className:"gp-absolute gp-inset-0 gp-flex gp-items-center gp-justify-center",children:jsxRuntime.jsx("span",{className:"gp-font-semibold",children:d.title})}),jsxRuntime.jsx("button",{onClick:n,"aria-label":"Close menu",className:"gp-relative gp-z-1 gp-flex gp-aspect-square gp-h-full gp-items-center gp-justify-center",style:{...core.getGlobalColorStateStyle("c",r)},children:jsxRuntime.jsx(Dismiss.default,{className:"gp-w-5"})})]}),jsxRuntime.jsx("ul",{className:core.cls("gp-flex gp-flex-col"),children:d?.childrens?.map(e=>jsxRuntime.jsx(MenuMobileItem,{id:e,menu:t,depth:i+1,maxDepth:a,arrow:s,menuBg:l,menuTextColor:r},e))})]})})]})};exports.default=MenuMobileItem;
