import{r,j as o,X as Q}from"./index-BL0y_fpc.js";const Z=({emoji:h,x:f,y:l,size:m,rotation:x=0,onUpdate:b,onDelete:y,isPreview:g=!1})=>{const[e,a]=r.useState(!1),[c,u]=r.useState(!1),[M,S]=r.useState(!1),[E,$]=r.useState(!1),R=r.useRef(null),j=r.useRef(null),i=r.useRef({x:0,y:0,emojiX:0,emojiY:0,size:0,rotation:0});r.useEffect(()=>{const n=(t,d)=>{if(!j.current||!R.current)return;const v=j.current.getBoundingClientRect();if(e){const w=t-i.current.x,s=d-i.current.y,k=Math.max(0,Math.min(100,i.current.emojiX+w/v.width*100)),Y=Math.max(0,Math.min(100,i.current.emojiY+s/v.height*100));b({x:k,y:Y})}else if(c){const w=t-i.current.x,s=Math.max(1,Math.min(6,i.current.size+w/50));b({size:s})}else if(M){const w=v.left+i.current.emojiX/100*v.width,s=v.top+i.current.emojiY/100*v.height,Y=Math.atan2(d-s,t-w)*180/Math.PI;b({rotation:Y})}},T=t=>{n(t.clientX,t.clientY)},L=t=>{t.touches.length>0&&(t.preventDefault(),n(t.touches[0].clientX,t.touches[0].clientY))},z=()=>{a(!1),u(!1),S(!1)};if(e||c||M)return document.addEventListener("mousemove",T),document.addEventListener("mouseup",z),document.addEventListener("touchmove",L,{passive:!1}),document.addEventListener("touchend",z),()=>{document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",L),document.removeEventListener("touchend",z)}},[e,c,M,b]);const p=n=>{n.stopPropagation(),!g&&($(!0),a(!0),i.current={x:n.clientX,y:n.clientY,emojiX:f,emojiY:l,size:m,rotation:x})},D=n=>{n.stopPropagation(),!(g||n.touches.length===0)&&($(!0),a(!0),i.current={x:n.touches[0].clientX,y:n.touches[0].clientY,emojiX:f,emojiY:l,size:m,rotation:x})},O=n=>{n.stopPropagation(),!g&&(u(!0),i.current={x:n.clientX,y:n.clientY,emojiX:f,emojiY:l,size:m,rotation:x})},F=n=>{n.stopPropagation(),!(g||n.touches.length===0)&&(u(!0),i.current={x:n.touches[0].clientX,y:n.touches[0].clientY,emojiX:f,emojiY:l,size:m,rotation:x})},B=n=>{n.stopPropagation(),!g&&(S(!0),i.current={x:n.clientX,y:n.clientY,emojiX:f,emojiY:l,size:m,rotation:x})},P=n=>{n.stopPropagation(),!(g||n.touches.length===0)&&(S(!0),i.current={x:n.touches[0].clientX,y:n.touches[0].clientY,emojiX:f,emojiY:l,size:m,rotation:x})};return r.useEffect(()=>{const n=T=>{R.current&&!R.current.contains(T.target)&&$(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]),r.useEffect(()=>{if(R.current){const n=R.current.closest("[data-card-container]");n&&(j.current=n)}},[]),o.jsxs("div",{ref:R,className:`absolute emoji-interactive ${g?"pointer-events-none":"cursor-move"} select-none`,style:{left:`${f}%`,top:`${l}%`,fontSize:`${m}rem`,transform:`translate(-50%, -50%) rotate(${x}deg)`,zIndex:E?50:10},onMouseDown:p,onTouchStart:D,children:[h,E&&!g&&o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:n=>{n.stopPropagation(),y()},className:"absolute -top-6 -right-6 w-5 h-5 bg-destructive text-destructive-foreground rounded-full flex items-center justify-center hover:bg-destructive/90 transition-colors",style:{fontSize:"0.75rem"},children:o.jsx(Q,{className:"w-3 h-3"})}),o.jsx("div",{onMouseDown:O,onTouchStart:F,className:"absolute -bottom-4 -right-4 w-4 h-4 bg-primary rounded-full cursor-nwse-resize border-2 border-background hover:scale-110 transition-transform"}),o.jsx("div",{onMouseDown:B,onTouchStart:P,className:"absolute -top-8 left-1/2 -translate-x-1/2 w-4 h-4 bg-accent rounded-full cursor-grab active:cursor-grabbing border-2 border-background hover:scale-110 transition-transform"}),o.jsx("div",{className:"absolute inset-0 border-2 border-dashed border-primary rounded -m-2 pointer-events-none",style:{transform:"scale(1.2)"}})]})]})},U=({x:h,y:f,size:l,onUpdate:m,onDelete:x,isPreview:b=!1,animatedOffset:y})=>{const[g,e]=r.useState(!1),[a,c]=r.useState(!1),[u,M]=r.useState(!1),[S,E]=r.useState(!1),[$,R]=r.useState({left:{x:0,y:0},right:{x:0,y:0}}),j=r.useRef(null),i=r.useRef(null),p=r.useRef({x:0,y:0,eyesX:0,eyesY:0,size:0}),D=r.useRef(0);r.useEffect(()=>{const t=(s,k)=>{if(!i.current||!j.current)return;const Y=i.current.getBoundingClientRect();if(g){const X=s-p.current.x,N=k-p.current.y,C=Math.max(0,Math.min(100,p.current.eyesX+X/Y.width*100)),I=Math.max(0,Math.min(100,p.current.eyesY+N/Y.height*100));m({x:C,y:I})}else if(a){const N=(s-p.current.x)/50,C=Math.max(1,Math.min(10,p.current.size+N));Math.abs(C-l)>.1&&m({size:C})}else if(!b&&!y&&j.current){const X=j.current.getBoundingClientRect(),N=X.left+X.width/2,C=X.top+X.height/2,I=Math.atan2(k-C,s-N),A=Math.min(l*3,15),_=Math.cos(I)*A,K=Math.sin(I)*A;R({left:{x:_,y:K},right:{x:_,y:K}})}},d=s=>{t(s.clientX,s.clientY)},v=s=>{if(s.touches.length===1&&g&&!u)s.preventDefault(),s.stopPropagation(),t(s.touches[0].clientX,s.touches[0].clientY);else if(s.touches.length===2&&u){s.preventDefault(),s.stopPropagation();const k=s.touches[0],Y=s.touches[1],X=Math.hypot(Y.clientX-k.clientX,Y.clientY-k.clientY);if(D.current>0){const N=X/D.current,C=Math.max(1,Math.min(10,p.current.size*N));m({size:C})}}},w=()=>{e(!1),c(!1),M(!1),D.current=0};return g||a||u?(document.addEventListener("mousemove",d),document.addEventListener("mouseup",w),document.addEventListener("touchmove",v,{passive:!1}),document.addEventListener("touchend",w),document.addEventListener("touchcancel",w)):document.addEventListener("mousemove",d),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",w),document.removeEventListener("touchmove",v),document.removeEventListener("touchend",w),document.removeEventListener("touchcancel",w)}},[g,a,u,m,l,b,y]),r.useEffect(()=>{y&&R({left:{x:y.x,y:y.y},right:{x:y.x,y:y.y}})},[y]);const O=(t,d)=>{b||!i.current||(E(!0),e(!0),p.current={x:t,y:d,eyesX:h,eyesY:f,size:l})},F=t=>{t.stopPropagation(),O(t.clientX,t.clientY)},B=t=>{if(t.stopPropagation(),!b){if(t.touches.length===1)E(!0),e(!0),p.current={x:t.touches[0].clientX,y:t.touches[0].clientY,eyesX:h,eyesY:f,size:l};else if(t.touches.length===2){M(!0),e(!1);const d=t.touches[0],v=t.touches[1];D.current=Math.hypot(v.clientX-d.clientX,v.clientY-d.clientY),p.current={x:0,y:0,eyesX:h,eyesY:f,size:l}}}},P=(t,d)=>{b||!i.current||(c(!0),p.current={x:t,y:d,eyesX:h,eyesY:f,size:l})},n=t=>{t.stopPropagation(),P(t.clientX,t.clientY)},T=t=>{t.stopPropagation(),t.touches.length>0&&P(t.touches[0].clientX,t.touches[0].clientY)};r.useEffect(()=>{const t=d=>{j.current&&!j.current.contains(d.target)&&E(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]),r.useEffect(()=>{const t=()=>{if(j.current){const v=j.current.closest("[data-card-container]");v&&(i.current=v)}};t();const d=setTimeout(t,50);return()=>clearTimeout(d)},[]);const L=l*20,z=L*.4;return o.jsxs("div",{ref:j,className:`absolute ${b?"pointer-events-none":"cursor-move touch-none"} select-none`,style:{left:`${h}%`,top:`${f}%`,transform:"translate(-50%, -50%)",zIndex:S?50:20},onMouseDown:F,onTouchStart:B,children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("div",{className:"relative rounded-full bg-white border-2 border-black flex items-center justify-center",style:{width:`${L}px`,height:`${L}px`},children:o.jsx("div",{className:"rounded-full bg-black transition-transform duration-100",style:{width:`${z}px`,height:`${z}px`,transform:`translate(${$.left.x}px, ${$.left.y}px)`}})}),o.jsx("div",{className:"relative rounded-full bg-white border-2 border-black flex items-center justify-center",style:{width:`${L}px`,height:`${L}px`},children:o.jsx("div",{className:"rounded-full bg-black transition-transform duration-100",style:{width:`${z}px`,height:`${z}px`,transform:`translate(${$.right.x}px, ${$.right.y}px)`}})})]}),S&&!b&&o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:t=>{t.stopPropagation(),x()},className:"absolute -top-6 -right-6 w-5 h-5 bg-destructive text-destructive-foreground rounded-full flex items-center justify-center hover:bg-destructive/90 transition-colors",style:{fontSize:"0.75rem"},children:o.jsx(Q,{className:"w-3 h-3"})}),o.jsx("div",{onMouseDown:n,onTouchStart:T,className:"absolute -bottom-4 -right-4 w-6 h-6 md:w-4 md:h-4 bg-primary rounded-full cursor-nwse-resize border-2 border-background hover:scale-110 transition-transform touch-none"}),o.jsx("div",{className:"absolute inset-0 border-2 border-dashed border-primary rounded -m-4 pointer-events-none"})]})]})},q=["#ff6b6b","#4ecdc4","#ffe66d","#95e1d3","#f38181","#aa96da","#fcbad3","#a8d8ea"],G=["#ff6b6b","#ff8e8e","#ffaaaa","#ff5252","#e91e63"],H=["#ffd700","#fff8dc","#fffacd","#ffec8b","#ffffff"],W=["#ff6b6b","#4ecdc4","#ffe66d","#aa96da","#f38181","#87ceeb","#98fb98"],J=["#ff0000","#ffa500","#ffff00","#00ff00","#00bfff","#8a2be2","#ff1493"];function ee({effect:h,isPreview:f=!1}){const[l,m]=r.useState([]),x=r.useRef(),b=r.useRef(null);r.useEffect(()=>{if(!h||h==="none"){m([]);return}(()=>{const c=[],u=f?15:30;for(let M=0;M<u;M++)c.push(y(M,h));m(c)})();const a=()=>{m(c=>c.map(u=>{let M=u.y+u.velocityY,S=u.x+u.velocityX,E=u.rotation+u.rotationSpeed;return M>110?y(u.id,h):(S<-5&&(S=105),S>105&&(S=-5),{...u,x:S,y:M,rotation:E})})),x.current=requestAnimationFrame(a)};return x.current=requestAnimationFrame(a),()=>{x.current&&cancelAnimationFrame(x.current)}},[h,f]);const y=(e,a)=>{const c={id:e,x:Math.random()*100,y:Math.random()*-50-10,rotation:Math.random()*360,rotationSpeed:(Math.random()-.5)*4,opacity:.7+Math.random()*.3};switch(a){case"confetti":return{...c,size:8+Math.random()*8,color:q[Math.floor(Math.random()*q.length)],velocityX:(Math.random()-.5)*1,velocityY:.5+Math.random()*1};case"hearts":return{...c,size:12+Math.random()*12,color:G[Math.floor(Math.random()*G.length)],velocityX:(Math.random()-.5)*.5,velocityY:.3+Math.random()*.7,rotationSpeed:0};case"snow":return{...c,size:4+Math.random()*6,color:"#ffffff",velocityX:(Math.random()-.5)*.5,velocityY:.3+Math.random()*.5,rotationSpeed:0,opacity:.6+Math.random()*.4};case"stars":return{...c,size:8+Math.random()*10,color:["#ffd700","#ffec8b","#fff8dc","#fffacd"][Math.floor(Math.random()*4)],velocityX:(Math.random()-.5)*.3,velocityY:.2+Math.random()*.4,rotationSpeed:(Math.random()-.5)*2};case"bubbles":return{...c,y:110+Math.random()*20,size:10+Math.random()*20,color:"rgba(135, 206, 250, 0.5)",velocityX:(Math.random()-.5)*.3,velocityY:-(.3+Math.random()*.5),rotationSpeed:0};case"sparkles":return{...c,size:6+Math.random()*10,color:H[Math.floor(Math.random()*H.length)],velocityX:(Math.random()-.5)*.8,velocityY:.2+Math.random()*.6,rotationSpeed:(Math.random()-.5)*8,opacity:.5+Math.random()*.5};case"balloons":return{...c,y:110+Math.random()*20,size:20+Math.random()*15,color:W[Math.floor(Math.random()*W.length)],velocityX:(Math.random()-.5)*.4,velocityY:-(.4+Math.random()*.4),rotationSpeed:(Math.random()-.5)*1};case"fireworks":return{...c,y:110+Math.random()*20,size:4+Math.random()*4,color:J[Math.floor(Math.random()*J.length)],velocityX:(Math.random()-.5)*2,velocityY:-(1.5+Math.random()*1.5),rotationSpeed:0,opacity:.8+Math.random()*.2};default:return{...c,size:10,color:"#ff6b6b",velocityX:0,velocityY:.5}}},g=e=>{const a={position:"absolute",left:`${e.x}%`,top:`${e.y}%`,transform:`rotate(${e.rotation}deg)`,opacity:e.opacity,pointerEvents:"none",transition:"none"};switch(h){case"confetti":return o.jsx("div",{style:{...a,width:`${e.size}px`,height:`${e.size*.6}px`,backgroundColor:e.color,borderRadius:"2px"}},e.id);case"hearts":return o.jsx("div",{style:{...a,fontSize:`${e.size}px`,color:e.color},children:"❤️"},e.id);case"snow":return o.jsx("div",{style:{...a,width:`${e.size}px`,height:`${e.size}px`,backgroundColor:e.color,borderRadius:"50%",boxShadow:"0 0 10px rgba(255, 255, 255, 0.8)"}},e.id);case"stars":return o.jsx("div",{style:{...a,fontSize:`${e.size}px`,color:e.color,textShadow:"0 0 10px currentColor"},children:"⭐"},e.id);case"bubbles":return o.jsx("div",{style:{...a,width:`${e.size}px`,height:`${e.size}px`,backgroundColor:e.color,borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.5)",boxShadow:"inset 0 0 10px rgba(255, 255, 255, 0.3)"}},e.id);case"sparkles":return o.jsx("div",{style:{...a,fontSize:`${e.size}px`,color:e.color,textShadow:`0 0 ${e.size}px ${e.color}, 0 0 ${e.size*2}px ${e.color}`},children:"✨"},e.id);case"balloons":return o.jsx("div",{style:{...a,fontSize:`${e.size}px`},children:o.jsx("span",{style:{display:"inline-block",filter:`hue-rotate(${e.rotation}deg)`},children:"🎈"})},e.id);case"fireworks":return o.jsx("div",{style:{...a,width:`${e.size}px`,height:`${e.size}px`,backgroundColor:e.color,borderRadius:"50%",boxShadow:`0 0 ${e.size*2}px ${e.color}, 0 0 ${e.size*4}px ${e.color}`}},e.id);default:return null}};return!h||h==="none"?null:o.jsx("div",{ref:b,className:"absolute inset-0 overflow-hidden pointer-events-none z-10",style:{borderRadius:"inherit"},children:l.map(g)})}const te=[{value:"none",label:"None",icon:"✖️"},{value:"confetti",label:"Confetti",icon:"🎊"},{value:"hearts",label:"Hearts",icon:"❤️"},{value:"snow",label:"Snow",icon:"❄️"},{value:"stars",label:"Stars",icon:"⭐"},{value:"bubbles",label:"Bubbles",icon:"🫧"},{value:"sparkles",label:"Sparkles",icon:"✨"},{value:"balloons",label:"Balloons",icon:"🎈"},{value:"fireworks",label:"Fireworks",icon:"🎆"}];export{te as B,Z as I,ee as a,U as b};