import{r as l,j as e,L as re}from"./vendor-BXQAQzXu.js";import{S as ne,N as ie,M as oe,a as ce}from"./ui-CbCB892d.js";import{S as le,a as de}from"./svg-DmTSu4C7.js";import{T as ue}from"./TabList-qNpk1Pqk.js";import{A as pe}from"./AnimatedPopUp-ClLwm94-.js";import{a as me}from"./appendURL-CIK5EvW3.js";const se=({list:d,slideSpace:S=32,width:$=352,slidePerView:P=0,assetUrl:_,onDetailsClick:y,cta_text:V,cta_url:L})=>{const[v,O]=l.useState(!1),h=d,k=l.useRef(null);let n=P;return n<=0&&(n="auto"),(h==null?void 0:h.length)>0?e.jsxs("div",{className:`w-full max-w-1120 mx-auto !overflow-visible px-6 text-left md:px-0`,children:[e.jsx(ne,{modules:[ie,oe],spaceBetween:S,slidesPerView:n,onBeforeInit:t=>{k.current=t},freeMode:!0,mousewheel:{forceToAxis:!0,releaseOnEdges:!0,sensitivity:1},className:"!overflow-visible",children:h.map(t=>{var R,A,f,x,F,p,B,b,N,M,T,E,z,I,C,G,H,w,D;return e.jsx(ce,{style:{width:`${$}px`},className:"border border-grayscale-3",children:e.jsxs("div",{className:"shadow-drop-shadow-base",children:[e.jsx("div",{onClick:()=>{var m;return y((m=t==null?void 0:t.attributes)==null?void 0:m.packageSlug)},children:e.jsx("img",{loading:"lazy",src:`${(x=(f=(A=(R=t==null?void 0:t.attributes)==null?void 0:R.packageFeaturedImage)==null?void 0:A.data)==null?void 0:f.attributes)!=null&&x.url?_+((F=t.attributes)==null?void 0:F.packageFeaturedImage.data.attributes.url):"https://placehold.co/600x400.png"}`,alt:((N=(b=(B=(p=t==null?void 0:t.attributes)==null?void 0:p.packageFeaturedImage)==null?void 0:B.data)==null?void 0:b.attributes)==null?void 0:N.title)??"wellness-packages",className:"object-cover w-full h-[170px] md:h-[240px] cursor-pointer"})}),e.jsxs("div",{className:"flex flex-col gap-2 bg-bluekarmaWhite-base p-3 justify-between md:p-6 !h-[189px]",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("span",{className:"golden-technicaltext",children:(E=(T=(M=t.attributes)==null?void 0:M.properties)==null?void 0:T.data[0])!=null&&E.attributes.propertyDisplayName?(C=(I=(z=t.attributes)==null?void 0:z.properties)==null?void 0:I.data[0])==null?void 0:C.attributes.propertyDisplayName:"Property"}),e.jsx("div",{onClick:()=>{var m;return y((m=t==null?void 0:t.attributes)==null?void 0:m.packageSlug)},children:e.jsx("p",{className:"heading4-subheadline-rev line-clamp-1 cursor-pointer font-medium",children:(G=t==null?void 0:t.attributes)!=null&&G.packageName?(H=t==null?void 0:t.attributes)==null?void 0:H.packageName:"Wellness Name"})}),e.jsx("div",{className:"bodytext2-leadingtrim line-clamp-3 py-[2px]",dangerouslySetInnerHTML:{__html:(w=t==null?void 0:t.attributes)==null?void 0:w.packageShortDesc}})]}),e.jsxs("div",{className:`flex justify-between items-center md:justify-start`,children:[e.jsx(re,{to:((D=t==null?void 0:t.attributes)==null?void 0:D.ctaURL)??"#",target:"_blank",rel:"noreferrer",className:"button-primary",children:"Book Now"}),e.jsxs("button",{onClick:()=>{var m;return y((m=t==null?void 0:t.attributes)==null?void 0:m.packageSlug)},className:"button-popup",onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),children:["Discover More",e.jsx("span",{className:`${v?"hidden":""}`,children:e.jsx(le,{})}),e.jsx("span",{className:`${v?"":"hidden"}`,children:e.jsx(de,{})})]})]})]})]})},t.id)})}),h.length>3&&e.jsx("div",{className:"flex justify-between w-full max-w-1120 mx-auto mt-8 md:mt-12",children:e.jsxs("div",{className:`hidden md:flex gap-9`,children:[e.jsx("button",{onClick:()=>{var t;return(t=k.current)==null?void 0:t.slidePrev()},children:e.jsx("img",{src:"/icon/chevron-prev.svg",width:"40",height:"40",className:"invert",alt:"prev-icon"})}),e.jsx("button",{onClick:()=>{var t;return(t=k.current)==null?void 0:t.slideNext()},children:e.jsx("img",{src:"/icon/chevron-next.svg",width:"40",height:"40",className:"invert",alt:"next-icon"})})]})})]}):e.jsx("p",{children:"No Wellness Available"})};let j=0;function ve({allWellnessPackages:d,assetUrl:S,tag:$,title:P,description:_,cta_text:y,cta_url:V,env:L,randomList:v,headingTag:O="h1"}){var m,J,q,W,Z,K,Q,X,Y,U,ee,te;const[h,k]=l.useState(!1),[n,t]=l.useState(null),[R,A]=l.useState(!1),f=l.useMemo(()=>{const a=new Set;return d.forEach(i=>{var r,c;(c=(r=i.attributes)==null?void 0:r.properties)!=null&&c.data&&i.attributes.properties.data.forEach(u=>{var s,o,g,ae;(ae=(g=(o=(s=u.attributes)==null?void 0:s.areas)==null?void 0:o.data)==null?void 0:g.attributes)!=null&&ae.area&&a.add(u.attributes.areas.data.attributes.area)})}),Array.from(a).sort()},[d]),[x,F]=l.useState("all"),[p,B]=l.useState("all"),[b,N]=l.useState(!1),M=l.useMemo(()=>{if(x==="all"){if(v){const a=[...d];let c=new Date().toISOString().split("T")[0].split("-").reduce((s,o)=>s+parseInt(o),0)+1;const u=()=>(c=(c*9301+49297)%233280,c/233280);for(let s=a.length-1;s>0;s--){const o=Math.floor(u()*(s+1));[a[s],a[o]]=[a[o],a[s]]}return a}return d}return d.filter(a=>{var i,r;return(r=(i=a.attributes)==null?void 0:i.properties)!=null&&r.data?a.attributes.properties.data.some(c=>{var u,s,o,g;return((g=(o=(s=(u=c.attributes)==null?void 0:u.areas)==null?void 0:s.data)==null?void 0:o.attributes)==null?void 0:g.area)===x}):!1})},[d,x,v]),T=l.useMemo(()=>{if(p==="all"){if(v){const a=[...d];let c=new Date().toISOString().split("T")[0].split("-").reduce((s,o)=>s+parseInt(o),0)+2;const u=()=>(c=(c*9301+49297)%233280,c/233280);for(let s=a.length-1;s>0;s--){const o=Math.floor(u()*(s+1));[a[s],a[o]]=[a[o],a[s]]}return a}return d}return d.filter(a=>{var i,r;return(r=(i=a.attributes)==null?void 0:i.properties)!=null&&r.data?a.attributes.properties.data.some(c=>{var u,s,o,g;return((g=(o=(s=(u=c.attributes)==null?void 0:u.areas)==null?void 0:s.data)==null?void 0:o.attributes)==null?void 0:g.area)===p}):!1})},[d,p,v]),E=async a=>{var i;if(k(r=>!r),!h){A(!0);try{const r=await z(`wellness-packages?filters[packageSlug][$eq]=${a}&populate[properties][populate][areas]=*&populate[packageFeaturedImage]=*&populate[wellness_category_packages]=*`);t(((i=r==null?void 0:r.data)==null?void 0:i.data[0])??null)}catch(r){console.error("Error fetching popup data:",r),t(null)}finally{A(!1)}}};async function z(a){if(!L.JWT_SECRET||!L.API_ENDPOINT)return{error:"API configuration not found"};const i=new Headers;i.set("Content-Type","application/json"),i.set("Authorization",`Bearer ${L.JWT_SECRET}`);try{const r=await fetch(`${L.API_ENDPOINT}${a}`,{method:"GET",headers:i});if(!r.ok)throw new Error("Failed to fetch data of properties");return{data:await r.json()}}catch(r){return{error:r.message}}}const I=a=>{F(a)},C=a=>{B(a),N(!1)},G=l.useMemo(()=>f.map((a,i)=>e.jsx("button",{className:`tabitems ${x===a?"active":""}`,onClick:()=>I(a),children:a},i)),[x,f]),H=l.useMemo(()=>f.map((a,i)=>e.jsx("button",{className:`${p===a?"active":""}`,onClick:()=>C(a),children:a},i)),[p,f]);l.useEffect(()=>(b?(j===0&&(document.body.classList.add("overflow-hidden"),document.body.classList.add("fixed")),j+=1):j>0&&(j-=1,j===0&&(document.body.classList.remove("overflow-hidden"),document.body.classList.remove("fixed"))),()=>{j>0&&(j-=1,j===0&&(document.body.classList.remove("overflow-hidden"),document.body.classList.remove("fixed")))}),[b]);const w=f.length>0,D=O;return e.jsxs(e.Fragment,{children:[e.jsx("section",{id:"wellness-packages",className:"section-wrapper-primary",children:e.jsxs("div",{className:"section-content-with-tabs",children:[e.jsxs("div",{className:"section-content-heading max-w-[736px] px-6 md:px-0 mx-auto",children:[$&&e.jsx("span",{className:"golden-overline",children:$}),P&&e.jsx(D,{className:"heading2-title-leadingtrim",children:P}),_&&e.jsx("p",{className:"bodytext2-leadingtrim md:bodytext1-leadingtrim",children:_})]}),e.jsxs("div",{className:"section-content-desktop",children:[w&&e.jsx("div",{className:"destination-tabs tab-wrapper mx-auto flex justify-center",children:e.jsxs(ue,{children:[e.jsx("button",{className:`tabitems ${x==="all"?"active":""}`,onClick:()=>I("all"),children:"All Areas"}),G]})}),e.jsx("div",{className:"section-slider-wrapper",children:e.jsx("div",{className:"animate-dissolve",children:M.length>0?e.jsx(se,{list:M,onDetailsClick:a=>E(a),assetUrl:S,cta_text:y,cta_url:V}):e.jsx("div",{className:"text-center py-4",children:"No wellness packages available for this area"})})})]}),e.jsxs("div",{className:"section-content-mobile",children:[w&&e.jsxs("button",{className:"tabitems-mobile",onClick:()=>N(!b),children:[p==="all"?"All Areas":p,e.jsx("img",{src:"/icon/chevron-bottom-gold.svg",className:"w-4 h-4",alt:"chevron"})]}),e.jsx("div",{className:"section-slider-wrapper",children:e.jsx("div",{className:"animate-dissolve",children:T.length>0?e.jsx(se,{list:T,onDetailsClick:a=>E(a),assetUrl:S,width:256,slideSpace:16,hasMore:!0,cta_text:y,cta_url:V}):e.jsx("div",{className:"text-center py-4",children:"No wellness packages available for this area"})})})]})]})}),h&&e.jsx(pe,{logo:"/logo/logo-dijiwa.webp",header:"Wellness Package",isOpen:h,onClose:()=>{window.history.pushState("","",window.location.pathname),k(!1)},children:R?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("p",{children:"Loading..."})}):n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"popup-body-wrapper pb-[70px] pt-[24px]",children:e.jsxs("div",{className:"popup-body",children:[e.jsx("img",{className:"max-h-[414px] object-cover",src:me(S,(W=(q=(J=(m=n.attributes)==null?void 0:m.packageFeaturedImage)==null?void 0:J.data)==null?void 0:q.attributes)==null?void 0:W.url),alt:((Z=n==null?void 0:n.attributes)==null?void 0:Z.packageName)||"Welness Package"}),e.jsx("p",{className:"popup-offers-overline",children:(Y=(X=(Q=(K=n==null?void 0:n.attributes)==null?void 0:K.properties)==null?void 0:Q.data[0])==null?void 0:X.attributes)==null?void 0:Y.propertyDisplayName}),e.jsx("p",{className:"popup-offers-title",children:(U=n==null?void 0:n.attributes)==null?void 0:U.packageName}),e.jsx("div",{className:"popup-offers-bodytext",dangerouslySetInnerHTML:{__html:(ee=n==null?void 0:n.attributes)==null?void 0:ee.packageLongDesc}})]})}),e.jsx("div",{className:"popup-button-wrapper bg-bluekarmaWhite-base border-t border-[#E1DACB]",children:e.jsx(re,{to:(te=n==null?void 0:n.attributes)==null?void 0:te.ctaURL,target:"_blank",rel:"noreferrer",className:"popup-button",children:"Book Now"})})]}):e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("p",{children:"Failed to load data. Please try again."})})}),w&&b&&e.jsx("div",{className:"absolute w-full h-full bg-[rgba(0,0,0,0.5)] top-0 left-0 z-30",onClick:()=>N(!1)}),w&&e.jsx("div",{className:`fixed h-[400px] inset-x-0 bottom-0 transform transition-transform duration-300 ease-in-out z-30 ${b?"translate-y-0":"translate-y-full"}`,children:b&&e.jsxs("div",{className:"bottom-popup",children:[e.jsxs("div",{className:"header flex justify-between items-center p-2 border-b border-b-sundanceGold-base",children:[e.jsx("p",{children:"Area"}),e.jsx("button",{className:"bg-grayscale-3 p-[6px]",onClick:()=>N(!1),children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M16 2.65165L13.3483 0L8.00002 5.34833L2.65165 0L0 2.65165L5.34836 7.99998L0 13.3483L2.65165 16L8.00002 10.6517L13.3483 16L16 13.3483L10.6516 7.99998L16 2.65165Z",fill:"#312E28"})})})]}),e.jsxs("div",{className:"bodycontent grid grid-cols-1 justify-center items-center max-h-[424px] overflow-y-auto",children:[e.jsx("button",{className:`${p==="all"?"active":""}`,onClick:()=>C("all"),children:"All Areas"}),H]})]})})]})}export{ve as S};