import{r as n,j as a,bw as X,d as Z,c as H,m as q}from"./index-CxGMQRP8.js";import{u as U}from"./useIOSAudioContext-DSBnluc9.js";import{E as Q}from"./ExploreThemesButton-CwfNfMSb.js";const ee=()=>{const{getContext:b}=U(),g=n.useRef(0);return n.useCallback(()=>{const d=Date.now();if(!(d-g.current<80)){g.current=d;try{const i=b();if(!i)return;const u=i.createOscillator(),s=i.createGain();u.connect(s),s.connect(i.destination),u.type="sine",u.frequency.setValueAtTime(600,i.currentTime),u.frequency.exponentialRampToValueAtTime(300,i.currentTime+.05),s.gain.setValueAtTime(.08,i.currentTime),s.gain.exponentialRampToValueAtTime(.01,i.currentTime+.05),u.start(i.currentTime),u.stop(i.currentTime+.05)}catch{}}},[b])},te=[{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,ne=({resistance:b=50,onActiveChange:g,onInteraction:y,themes:d=te,autoRotate:i=!1,autoRotateSpeed:u=.08})=>{const s=n.useRef(null),R=n.useRef([]),k=ee(),{unlockOn:m}=U();n.useEffect(()=>m(s.current,["pointerdown","touchstart","mouseenter"]),[m]);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(i),S=n.useRef(!1),T=n.useRef([]),[j,z]=n.useState(180),[re,G]=n.useState(!1),[F,Y]=n.useState(0),O=n.useRef(0);n.useEffect(()=>{const e=()=>{const r=window.innerWidth<768;G(r),z(r?200:300)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),n.useEffect(()=>{w.current=i},[i]);const I=n.useCallback(()=>{const e=p.current;s.current&&(s.current.style.transform=`translate(-50%, 0) rotate(${e}deg)`,s.current.style.left="100%"),R.current.forEach((r,t)=>{if(!r)return;const o=t*30;let l=e%360;l<0&&(l+=360);let f=(o+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(${o}deg) translate(${j}px) rotate(-${o}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 W=(e,r)=>{if(!s.current)return 0;const t=s.current.getBoundingClientRect(),o=t.left+t.width/2,l=t.top+t.height/2;return Math.atan2(r-l,e-o)*(180/Math.PI)},B=e=>{e.preventDefault(),N.current=!0,S.current=!0,w.current=!1,C.current=W(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=W(e.clientX,e.clientY);let t=r-C.current;t>180&&(t-=360),t<-180&&(t+=360),C.current=r,p.current+=t;const o=Date.now();T.current.push({t:o,v:t}),T.current=T.current.filter(l=>o-l.t<100),I(),c.current=t},$=e=>{N.current=!1,e.target.releasePointerCapture(e.pointerId);const r=Date.now(),t=T.current.filter(o=>r-o.t<100);if(t.length>0){const o=t.reduce((l,f)=>l+f.v,0)/t.length;c.current=o}else c.current=0;T.current=[],setTimeout(()=>{S.current=!1},500),i&&(v.current=setTimeout(()=>{w.current=!0},1500))},K=(e,r)=>{r.stopPropagation(),S.current=!0;const o=180-e*30,l=p.current,f=o-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!==O.current&&(S.current&&k(),O.current=t,Y(t),g&&g(d[t])),_.current=requestAnimationFrame(L)},[u,g,I,d]);return n.useEffect(()=>(_.current=requestAnimationFrame(L),()=>{_.current&&cancelAnimationFrame(_.current)}),[L]),a.jsxs("div",{className:"relative w-full h-[500px] flex items-center touch-none select-none overflow-x-clip overflow-y-visible",children:[a.jsx("div",{ref:s,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:d.map((e,r)=>{const t=F===r;return a.jsx("div",{ref:o=>R.current[r]=o,className:"absolute flex items-center justify-center cursor-pointer",onClick:o=>K(r,o),"data-lumi-interactive":!0,style:{width:M,height:M,left:"50%",top:"50%",marginTop:-M/2,marginLeft:-M/2},children:a.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?a.jsx("img",{src:e.imageSrc,alt:e.name,className:"w-full h-full object-cover"}):a.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)})}),a.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:[a.jsx("h3",{className:"text-base md:text-2xl font-normal text-foreground mb-2 transition-all duration-300",children:d[F]?.name}),a.jsx("p",{className:"font-noto text-xs md:text-[16px] text-muted-foreground transition-all duration-300",children:d[F]?.description})]})]})},ie=({onInteractionComplete:b=()=>{},hasCarouselInteracted:g=!1})=>{Z();const{t:y}=H("landing"),{t:d}=H("themes"),i=["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"],s=d("themes",{returnObjects:!0}),R=i.map((k,m)=>({id:k,name:Array.isArray(s)&&s[m]?s[m].name:k,description:Array.isArray(s)&&s[m]?s[m].description:"",imageSrc:u[m]}));return a.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:a.jsx("div",{className:"container mx-auto max-w-6xl px-6",children:a.jsxs("div",{className:"flex flex-col-reverse lg:flex-row ipad-portrait:!flex-col-reverse items-center gap-4 lg:gap-12",children:[a.jsxs(q.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:[a.jsx("h2",{className:"section-header text-[22px] lg:text-[32px] mb-2 lg:mb-4",children:y("themes.heading")}),a.jsx("p",{className:"section-subtext text-sm lg:text-xl",children:y("themes.subtext")}),a.jsx("div",{className:"mt-4 lg:mt-10",children:a.jsx(Q,{})})]}),a.jsx(q.div,{initial:{x:50,opacity:0},whileInView:{x:0,opacity:1},viewport:{once:!0},transition:{delay:.5},className:"flex-1 w-full",children:a.jsx(ne,{onInteraction:b,autoRotate:!0,autoRotateSpeed:.08,themes:R})})]})})})};export{ie as default};
//# sourceMappingURL=ThemesSection-C3c4vtn1.js.map