import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{ki as t}from"./lucide-icons-BjbcRgLk.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{D as r,S as i}from"./useTheme-DAiZ1C6g.js";import{c as a}from"./fontLoader-B9KxicFi.js";import{a as o,f as s,i as c,r as l}from"./letterTypes-BPWQWRGQ.js";var u=e(t(),1),d=n();function f(e){return e<=3?{cols:e,rows:1}:e===4?{cols:2,rows:2}:{cols:3,rows:2}}function p(e,t){let n=.5,r=e/t*360-90-n,i=(e+1)/t*360-90+n,a=[`50% 50%`];for(let e=0;e<=12;e++){let t=(r+e/12*(i-r))*Math.PI/180,n=50+150*Math.cos(t),o=50+150*Math.sin(t);a.push(`${n.toFixed(2)}% ${o.toFixed(2)}%`)}return`polygon(${a.join(`, `)})`}function m({colors:e}){return(0,d.jsx)(`div`,{className:`flex flex-col w-full h-full`,children:e.map((e,t)=>(0,d.jsx)(`div`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function h({colors:e}){return(0,d.jsx)(`div`,{className:`flex w-full h-full`,children:e.map((e,t)=>(0,d.jsx)(`div`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function g({colors:e}){let{cols:t,rows:n}=f(e.length);return(0,d.jsx)(`div`,{className:`w-full h-full`,style:{display:`grid`,gridTemplateColumns:`repeat(${t}, 1fr)`,gridTemplateRows:`repeat(${n}, 1fr)`},children:e.map((e,t)=>(0,d.jsx)(`div`,{style:{backgroundColor:e}},t))})}function _({colors:e}){let t=e.length;return(0,d.jsx)(`div`,{className:`relative w-full h-full`,style:{backgroundColor:e[0]},children:e.map((e,n)=>(0,d.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundColor:e,clipPath:p(n,t)}},n))})}var v=/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;function y(e){return v.test(e)?e:`#000000`}function b({colors:e}){let t=e.length,n=t*Math.max(2,4-t),r=n,i=20*r,a=[];for(let i=0;i`)}let o=`${a.join(``)}`;return(0,d.jsx)(`div`,{className:`w-full h-full`,style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(o)}")`,backgroundSize:`${100/r*20}% ${100/n*20}%`,backgroundRepeat:`repeat`,imageRendering:`pixelated`}})}function x({colors:e}){let t=600/e.length,n=`${e.map((e,n)=>{let r=y(e),i=n*t,a=(n+1)*t;return``}).join(``)}`;return(0,d.jsx)(`div`,{className:`w-full h-full`,style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(n)}")`,backgroundSize:`100% 100%`,backgroundRepeat:`no-repeat`}})}function S({colors:e,layout:t=`horizontal`,className:n=``,children:i}){if(e.length===0)return null;let a=e.reduce((e,t)=>e+r(t),0)/e.length>.5?`text-black/80`:`text-white/90`;return(0,d.jsxs)(`div`,{className:`overflow-hidden ${n}`,children:[t===`horizontal`&&(0,d.jsx)(m,{colors:e}),t===`vertical`&&(0,d.jsx)(h,{colors:e}),t===`grid`&&(0,d.jsx)(g,{colors:e}),t===`star`&&(0,d.jsx)(_,{colors:e}),t===`checkerboard`&&(0,d.jsx)(b,{colors:e}),t===`diagonalStripes`&&(0,d.jsx)(x,{colors:e}),i&&(0,d.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none select-none ${a}`,children:i})]})}var C={color:l};function w(e){return e.primaryColor?e.primaryColor:e.colors&&e.colors.length>=1?e.colors[0]:e.color??`#3a7a3a`}function T(e,t){let n=Math.sin(e*127.1+t*311.7)*43758.5453;return n-Math.floor(n)}function E({tint:e,thickness:t,emojis:n,defaultBg:r,scatter:a,keepDefaultBg:o}){let s=t,c=e&&!o?i(e,.45):r,l=(0,u.useMemo)(()=>{let e=a?40:48,t=s-4,r=[],i=0,o=()=>n[i++%n.length],c=(e,t)=>{let n=r.length;r.push(a?{emoji:o(),left:e,top:t,size:26+T(n,1)*18,rot:(T(n,2)-.5)*60,jx:(T(n,3)-.5)*14,jy:(T(n,4)-.5)*14}:{emoji:o(),left:e,top:t,size:40,rot:0,jx:0,jy:0})};for(let n of[8,t]){for(let t=8;t<800;t+=e)c(`${t}px`,`${n}px`);for(let t=8;t<800;t+=e)c(`${t}px`,`calc(100% - ${n}px)`)}for(let n of[8,t]){for(let t=s+e;t<800;t+=e)c(`${n}px`,`${t}px`);for(let t=s+e;t<800;t+=e)c(`calc(100% - ${n}px)`,`${t}px`)}return r},[n,s,a]);return(0,d.jsxs)(`div`,{className:`absolute pointer-events-none select-none overflow-hidden`,"aria-hidden":!0,style:{inset:-s,borderRadius:`2rem`,zIndex:-1,backgroundColor:c},children:[l.map((e,t)=>(0,d.jsx)(`span`,{style:{position:`absolute`,left:e.left,top:e.top,fontSize:`${e.size}px`,transform:`translate(${e.jx}px, ${e.jy}px) rotate(${e.rot}deg) translate(-50%, -50%)`,lineHeight:1},children:e.emoji},t)),e&&(0,d.jsx)(`div`,{style:{position:`absolute`,inset:0,backgroundColor:e,mixBlendMode:`color`,opacity:.6}})]})}function D(e){return[...e].filter(e=>/\p{Emoji_Presentation}|\p{Extended_Pictographic}/u.test(e)).join(``).slice(0,8)}function O({emoji:e}){let t=D(e);if(!t)return null;let n=`${t}`;return(0,d.jsx)(`div`,{className:`absolute inset-0 pointer-events-none overflow-hidden select-none`,"aria-hidden":!0,style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(n)}")`,backgroundSize:`64px 64px`,backgroundRepeat:`repeat`}})}function k({emoji:e}){return(0,d.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none select-none`,"aria-hidden":!0,children:(0,d.jsx)(`span`,{style:{fontSize:`4rem`,lineHeight:1,opacity:.1,transform:`scale(3.5)`,display:`inline-block`},children:e})})}function A({frame:e,tint:t,thickness:n}){let r=o.find(t=>t.id===e);return!r?.emojis||!r.bgColor?null:(0,d.jsx)(E,{tint:t,thickness:n,emojis:r.emojis,defaultBg:r.bgColor},e)}function j({stationery:e,frame:t,frameTint:n=!1,className:r=``,children:i}){let a=s(e??C),o=a.colors&&a.colors.length>=2,c=n?w(a):null,l=o?{}:{backgroundColor:a.color},u=r.match(/rounded-\S+/g)?.join(` `)??``,f=t&&t!==`none`;return(0,d.jsxs)(`div`,{className:f?`isolate relative ${r}`:`relative ${r}`,style:f?{overflow:`visible`}:{overflow:`hidden`,...l},children:[f&&(0,d.jsx)(A,{frame:t,tint:c,thickness:28}),(0,d.jsxs)(`div`,{className:f?`relative overflow-hidden ${u}`:``,style:f?l:{},children:[o&&(0,d.jsx)(S,{colors:a.colors,layout:a.layout??`horizontal`,className:`absolute inset-0 w-full h-full`}),o&&a.emoji&&(a.emojiMode===`emblem`?(0,d.jsx)(k,{emoji:a.emoji}):(0,d.jsx)(O,{emoji:a.emoji})),!o&&a.imageUrl&&(0,d.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundImage:`url("${a.imageUrl}")`,backgroundSize:a.imageMode===`tile`?`auto`:`cover`,backgroundPosition:`center`,backgroundRepeat:a.imageMode===`tile`?`repeat`:`no-repeat`,opacity:.5}}),!o&&a.emoji&&(a.emojiMode===`emblem`?(0,d.jsx)(k,{emoji:a.emoji}):(0,d.jsx)(O,{emoji:a.emoji})),i]})]})}function M({stationery:e}){let t=s(e),n=t.color,i=t.textColor??`#333333`,a=t.primaryColor??`#4CAF50`,o=r(n)<.3?`${n}dd`:`#ffffffcc`;return(0,d.jsxs)(`div`,{className:`absolute inset-0 p-1.5 flex flex-col gap-1`,style:{backgroundColor:n},children:[t.imageUrl&&(0,d.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundImage:`url("${t.imageUrl}")`,backgroundSize:`cover`,backgroundPosition:`center`,opacity:.35}}),(0,d.jsx)(`div`,{className:`relative z-10 h-2 rounded-sm`,style:{backgroundColor:o}}),(0,d.jsxs)(`div`,{className:`relative z-10 flex-1 rounded-sm p-1 flex flex-col justify-between overflow-hidden`,style:{backgroundColor:o},children:[(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`div`,{className:`h-1 w-3/4 rounded-full opacity-60`,style:{backgroundColor:i}}),(0,d.jsx)(`div`,{className:`h-1 w-1/2 rounded-full opacity-40`,style:{backgroundColor:i}})]}),(0,d.jsx)(`div`,{className:`h-2 w-8 rounded-sm`,style:{backgroundColor:a}})]}),(0,d.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-3 z-10`,style:{backgroundColor:a,opacity:.6}})]})}function N({stationery:e,selected:t,className:n=``}){let r=s(e),i=t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:``;return r.colors&&r.colors.length>=2?(0,d.jsx)(`div`,{className:`relative overflow-hidden rounded-2xl ${i} ${n}`,children:(0,d.jsx)(S,{colors:r.colors,layout:r.layout??`horizontal`,className:`w-full h-full`,children:r.emoji&&(0,d.jsx)(`span`,{className:`text-xl drop-shadow select-none`,children:r.emoji})})}):r.textColor||r.primaryColor?(0,d.jsx)(`div`,{className:`relative overflow-hidden rounded-2xl ${i} ${n}`,children:(0,d.jsx)(M,{stationery:e})}):(0,d.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl ${i} ${n}`,style:{backgroundColor:r.color},children:[r.imageUrl&&(0,d.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundImage:`url("${r.imageUrl}")`,backgroundSize:`cover`,backgroundPosition:`center`}}),r.emoji&&!r.imageUrl&&(0,d.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none select-none`,children:(0,d.jsx)(`span`,{className:`text-3xl opacity-70`,children:r.emoji})})]})}function P(e,t){let n=c[0].family,r=e===n?t:e;return r?r.includes(`,`)?r:`${r}, ${n}`:n}function F(e){if(!e)return;let t=e.split(`,`).map(e=>e.trim().replace(/^["']|["']$/g,``));for(let e of t)e&&a(e)}export{N as a,j as i,P as n,S as o,E as r,F as t};