import{j as s}from"./query-vendor-CZu0EHPe.js";import{r as n}from"./react-vendor-0bvDbF03.js";import{bA as X,e as Z,m as H,W as Q}from"./index-B8QAlx5l.js";import{u as U}from"./useIOSAudioContext-DtqQj9l7.js";import{E as ee}from"./ExploreThemesButton-C8pDvqep.js";import{u as q}from"./i18n-vendor-Bg2yf_Zw.js";import"./supabase-vendor-CNV44oIa.js";import"./helmet-vendor-NlTFkN97.js";import"./compass-7nweGSar.js";const te=()=>{const{getContext:b}=U(),g=n.useRef(0);return n.useCallback(()=>{const m=Date.now();if(!(m-g.current<80)){g.current=m;try{const a=b();if(!a)return;const u=a.createOscillator(),o=a.createGain();u.connect(o),o.connect(a.destination),u.type="sine",u.frequency.setValueAtTime(600,a.currentTime),u.frequency.exponentialRampToValueAtTime(300,a.currentTime+.05),o.gain.setValueAtTime(.08,a.currentTime),o.gain.exponentialRampToValueAtTime(.01,a.currentTime+.05),u.start(a.currentTime),u.stop(a.currentTime+.05)}catch{}}},[b])},ne=[{id:"magic-wonder",name:"Magic & Wonder",description:"Stories that inspire awe and imagination through magical elements",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Magic%20and%20Wonder.webp"},{id:"nature-animals",name:"Nature & Animals",description:"Stories that explore the natural world and creatures",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Nature%20and%20Animals.webp"},{id:"adventure-curiosity",name:"Adventure & Curiosity",description:"Exciting journeys of discovery and exploration",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Adventure%20and%20Curiosity.webp"},{id:"problem-solution",name:"Problem & Solution",description:"Challenges to overcome through critical thinking",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Problem%20and%20Solution.webp"},{id:"friendship-teamwork",name:"Friendship & Teamwork",description:"Stories about bonds and collaborative efforts",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Friendship%20and%20Teamwork.webp"},{id:"fun-wit",name:"Fun & Wit",description:"Lighthearted stories with humor and clever situations",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Fun%20and%20Wit.webp"},{id:"kindness-empathy",name:"Kindness & Empathy",description:"Stories highlighting compassion and helping others",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Kindness%20and%20Empathy.webp"},{id:"fear-courage",name:"Fear & Courage",description:"Facing fears and finding bravery in challenges",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Fear%20and%20Courage.webp"},{id:"sadness-loss",name:"Sadness & Loss",description:"Exploring feelings of grief and saying goodbye",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Sadness%20and%20Loss.webp"},{id:"anger-frustration",name:"Anger & Frustration",description:"Managing strong emotions constructively",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Anger%20and%20Frustration.webp"},{id:"confidence-determination",name:"Confidence & Determination",description:"Perseverance and believing in oneself",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Confidence%20and%20Determination.webp"},{id:"jealousy-appreciation",name:"Jealousy & Appreciation",description:"Learning gratitude and valuing what one has",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Jealousy%20and%20Appreciation.webp"}],M=100,re=({resistance:b=50,onActiveChange:g,onInteraction:y,themes:m=ne,autoRotate:a=!1,autoRotateSpeed:u=.08})=>{const o=n.useRef(null),R=n.useRef([]),k=te(),{unlockOn:d}=U();n.useEffect(()=>d(o.current,["pointerdown","touchstart","mouseenter"]),[d]);const p=n.useRef(180),c=n.useRef(0),N=n.useRef(!1),C=n.useRef(0),_=n.useRef(),E=n.useRef(!1),v=n.useRef(null),w=n.useRef(a),S=n.useRef(!1),T=n.useRef([]),[j,W]=n.useState(180),[se,G]=n.useState(!1),[F,Y]=n.useState(0),z=n.useRef(0);n.useEffect(()=>{const e=()=>{const r=window.innerWidth<768;G(r),W(r?200:300)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),n.useEffect(()=>{w.current=a},[a]);const I=n.useCallback(()=>{const e=p.current;o.current&&(o.current.style.transform=`translate(-50%, 0) rotate(${e}deg)`,o.current.style.left="100%"),R.current.forEach((r,t)=>{if(!r)return;const i=t*30;let l=e%360;l<0&&(l+=360);let f=(i+l)%360,h=Math.abs(f-180);h>180&&(h=360-h);const D=1.6,x=.5,A=Math.max(0,1-h/80),P=x+(D-x)*A,V=100-Math.round(h);r.style.transform=`rotate(${i}deg) translate(${j}px) rotate(-${i}deg) rotate(${-e}deg) scale(${P})`,r.style.zIndex=V.toString(),r.style.opacity=A>.2?"1":"0.3"})},[j]);n.useEffect(()=>{I()},[I]);const O=(e,r)=>{if(!o.current)return 0;const t=o.current.getBoundingClientRect(),i=t.left+t.width/2,l=t.top+t.height/2;return Math.atan2(r-l,e-i)*(180/Math.PI)},B=e=>{e.preventDefault(),N.current=!0,S.current=!0,w.current=!1,C.current=O(e.clientX,e.clientY),c.current=0,T.current=[],e.target.setPointerCapture(e.pointerId),v.current&&clearTimeout(v.current),E.current||(E.current=!0,y?.())},J=e=>{if(!N.current)return;const r=O(e.clientX,e.clientY);let t=r-C.current;t>180&&(t-=360),t<-180&&(t+=360),C.current=r,p.current+=t;const i=Date.now();T.current.push({t:i,v:t}),T.current=T.current.filter(l=>i-l.t<100),I(),c.current=t},$=e=>{N.current=!1,e.target.releasePointerCapture(e.pointerId);const r=Date.now(),t=T.current.filter(i=>r-i.t<100);if(t.length>0){const i=t.reduce((l,f)=>l+f.v,0)/t.length;c.current=i}else c.current=0;T.current=[],setTimeout(()=>{S.current=!1},500),a&&(v.current=setTimeout(()=>{w.current=!0},1500))},K=(e,r)=>{r.stopPropagation(),S.current=!0;const i=180-e*30,l=p.current,f=i-l,h=Math.round(f/360),x=l+(f-h*360)-l;c.current=x*.1,E.current||(E.current=!0,y?.()),setTimeout(()=>{S.current=!1},500)};n.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const L=n.useCallback(()=>{if(!N.current){if(w.current&&Math.abs(c.current)<.1&&(c.current=u),Math.abs(c.current)<.12&&!w.current){const x=p.current,A=Math.round(x/30)*30,P=A-x,V=P*.03;c.current+=V,c.current*=.92,Math.abs(c.current)<.001&&Math.abs(P)<.01?(c.current=0,p.current=A):p.current+=c.current}else p.current+=c.current,w.current||(c.current*=.97);I()}let e=p.current%360;e<0&&(e+=360);const r=(180-e+360)%360,t=Math.round(r/30)%12;t!==z.current&&(S.current&&k(),z.current=t,Y(t),g&&g(m[t])),_.current=requestAnimationFrame(L)},[u,g,I,m]);return n.useEffect(()=>(_.current=requestAnimationFrame(L),()=>{_.current&&cancelAnimationFrame(_.current)}),[L]),s.jsxs("div",{className:"relative w-full h-[500px] flex items-center touch-none select-none overflow-x-clip overflow-y-visible",children:[s.jsx("div",{ref:o,className:"relative rounded-full cursor-grab active:cursor-grabbing",style:{width:j*2.5,height:j*2.5,position:"absolute",touchAction:"none",left:"100%",transform:"translate(-50%, 0) rotate(180deg)"},onPointerDown:B,onPointerMove:J,onPointerUp:$,onPointerLeave:$,children:m.map((e,r)=>{const t=F===r;return s.jsx("div",{ref:i=>R.current[r]=i,className:"absolute flex items-center justify-center cursor-pointer",onClick:i=>K(r,i),"data-lumi-interactive":!0,style:{width:M,height:M,left:"50%",top:"50%",marginTop:-M/2,marginLeft:-M/2},children:s.jsx("div",{className:`
                  flex items-center justify-center rounded-full transition-all duration-300 overflow-hidden
                  ${t?"w-24 h-24":"w-20 h-20 hover:opacity-80"}
                `,style:t?{boxShadow:"0 0 30px 8px rgba(251, 191, 36, 0.6), 0 0 60px 15px rgba(251, 191, 36, 0.3)"}:void 0,children:e.imageSrc?s.jsx("img",{src:e.imageSrc,alt:e.name,className:"w-full h-full object-cover"}):s.jsx(X,{placeholder:e.name.substring(0,3).toUpperCase(),description:`Theme: ${e.name}`,size:"full",aspectRatio:"square",className:"w-full h-full text-[8px]"})})},e.id)})}),s.jsxs("div",{className:"absolute right-4 md:right-6 lg:right-8 top-1/2 -translate-y-1/2 max-w-[120px] md:max-w-[160px] z-10 text-right",children:[s.jsx("h3",{className:"text-base md:text-2xl font-normal text-foreground mb-2 transition-all duration-300",children:m[F]?.name}),s.jsx("p",{className:"font-noto text-xs md:text-[16px] text-muted-foreground transition-all duration-300",children:m[F]?.description})]})]})},he=({onInteractionComplete:b=()=>{},hasCarouselInteracted:g=!1})=>{Z();const{t:y}=q("landing"),{t:m}=q("themes"),a=["magic-wonder","nature-animals","adventure-curiosity","problem-solution","friendship-teamwork","fun-wit","kindness-empathy","fear-courage","sadness-loss","anger-frustration","confidence-determination","jealousy-appreciation"],u=["https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Magic%20and%20Wonder.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Nature%20and%20Animals.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Adventure%20and%20Curiosity.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Problem%20and%20Solution.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Friendship%20and%20Teamwork.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Fun%20and%20Wit.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Kindness%20and%20Empathy.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Fear%20and%20Courage.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Sadness%20and%20Loss.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Anger%20and%20Frustration.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Confidence%20and%20Determination.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Jealousy%20and%20Appreciation.webp"],o=m("themes",{returnObjects:!0}),R=a.map((k,d)=>({id:k,name:Array.isArray(o)&&o[d]?o[d].name:k,description:Array.isArray(o)&&o[d]?o[d].description:"",imageSrc:u[d]}));return s.jsx("section",{className:"relative min-h-0 py-8 lg:py-16 ipad-portrait:!py-8 lg:min-h-screen flex items-center justify-center",style:{background:"#F0FDF4"},children:s.jsx("div",{className:"container mx-auto max-w-6xl px-6",children:s.jsxs("div",{className:"flex flex-col-reverse lg:flex-row ipad-portrait:!flex-col-reverse items-center gap-4 lg:gap-12",children:[s.jsxs(H.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6},className:"max-w-lg text-center lg:text-left ipad-portrait:!text-center flex flex-col",children:[s.jsx("h2",{className:"section-header text-[22px] lg:text-[32px] mb-2 lg:mb-4",children:y("themes.heading")}),s.jsx("h3",{className:"section-subtext text-sm lg:text-xl",children:y("themes.subtext")}),s.jsxs("div",{className:"mt-4 lg:mt-10 flex flex-col items-center gap-3 lg:items-start ipad-portrait:!items-center",children:[s.jsx(ee,{}),s.jsx(Q,{slug:"choose-the-right-reading-level"})]})]}),s.jsx(H.div,{initial:{x:50,opacity:0},whileInView:{x:0,opacity:1},viewport:{once:!0},transition:{delay:.5},className:"flex-1 w-full",children:s.jsx(re,{onInteraction:b,autoRotate:!0,autoRotateSpeed:.08,themes:R})})]})})})};export{he as default};