-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchunk-BE__v2Cg.js
More file actions
1 lines (1 loc) · 5.82 KB
/
Copy pathchunk-BE__v2Cg.js
File metadata and controls
1 lines (1 loc) · 5.82 KB
1
import{r as b,j as e,A as M,m as E,i as L}from"../entries/pages.BZkyDMuN.js";import{o as F}from"./chunk-B1EIeR-U.js";const R=[{name:"Pure Void",hex:"#050505"},{name:"Paper White",hex:"#F5F5F5"},{name:"Emerald Flux",hex:"#10b981"},{name:"Salmon Signal",hex:"#FA8072"},{name:"Cyber Cyan",hex:"#00FFFF"},{name:"Neon Violet",hex:"#a855f7"},{name:"Amber Warning",hex:"#f59e0b"},{name:"Royal Gold",hex:"#D4AF37"},{name:"Crimson Data",hex:"#ef4444"},{name:"Cobalt Core",hex:"#3b82f6"},{name:"Deep Slate",hex:"#1e293b"},{name:"Ghost Gray",hex:"#94a3b8"}],S=t=>{let o=0,s=0,r=0;t.length===4?(o=parseInt(t[1]+t[1],16),s=parseInt(t[2]+t[2],16),r=parseInt(t[3]+t[3],16)):t.length===7&&(o=parseInt(t.substring(1,3),16),s=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16)),o/=255,s/=255,r/=255;const n=Math.max(o,s,r),l=Math.min(o,s,r);let a,h,u=n;const c=n-l;if(h=n===0?0:c/n,n===l)a=0;else{switch(n){case o:a=(s-r)/c+(s<r?6:0);break;case s:a=(r-o)/c+2;break;case r:a=(o-s)/c+4;break}a/=6}return{h:a,s:h,v:u}},j=(t,o,s)=>{let r,n,l;const a=Math.floor(t*6),h=t*6-a,u=s*(1-o),c=s*(1-h*o),f=s*(1-(1-h)*o);switch(a%6){case 0:r=s,n=f,l=u;break;case 1:r=c,n=s,l=u;break;case 2:r=u,n=s,l=f;break;case 3:r=u,n=c,l=s;break;case 4:r=f,n=u,l=s;break;case 5:r=s,n=u,l=c;break}const w=g=>Math.round(g*255).toString(16).padStart(2,"0");return`#${w(r)}${w(n)}${w(l)}`},_=({value:t,onChange:o,label:s,variant:r="default"})=>{const[n,l]=b.useState(!1),[a,h]=b.useState({h:0,s:0,v:0}),[u,c]=b.useState(t),f=b.useRef(null),w=b.useRef(null),g=b.useRef(null),y=r==="brutalist";b.useEffect(()=>{try{h(S(t)),c(t)}catch{h({h:0,s:0,v:0})}},[t]),b.useEffect(()=>{const i=m=>{f.current&&!f.current.contains(m.target)&&l(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[]);const N=i=>{const m=v=>{const p=w.current.getBoundingClientRect();let x=(v.clientX-p.left)/p.width,k=1-(v.clientY-p.top)/p.height;x=Math.max(0,Math.min(1,x)),k=Math.max(0,Math.min(1,k)),o(j(a.h,x,k))},d=()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",d)};window.addEventListener("mousemove",m),window.addEventListener("mouseup",d),m(i)},C=i=>{const m=v=>{const p=g.current.getBoundingClientRect();let x=(v.clientX-p.left)/p.width;x=Math.max(0,Math.min(1,x)),o(j(x,a.s,a.v))},d=()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",d)};window.addEventListener("mousemove",m),window.addEventListener("mouseup",d),m(i)};return e.jsxs("div",{className:"space-y-2",ref:f,children:[s&&e.jsx("label",{className:"block font-mono text-[9px] uppercase text-gray-600 tracking-widest",children:s}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>l(!n),className:`w-full flex items-center gap-3 p-2 bg-black/40 border transition-all rounded-sm group ${y?"border-white/20 hover:border-emerald-500/50":"border-white/10 hover:border-white/30"}`,children:[e.jsx("div",{className:"w-6 h-6 rounded-sm border border-white/20 shadow-inner shrink-0",style:{backgroundColor:t}}),e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-gray-400 group-hover:text-white transition-colors",children:t.toUpperCase()}),e.jsx(F,{className:"ml-auto text-gray-600 group-hover:text-emerald-500 transition-colors",size:14})]}),e.jsx(M,{children:n&&e.jsxs(E.div,{initial:{opacity:0,y:5,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:5,scale:.95},className:"absolute z-50 top-full mt-2 w-64 bg-[#0a0a0a] border border-white/20 p-4 shadow-[0_20px_50px_rgba(0,0,0,0.8)] rounded-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-white/5",children:[e.jsx("span",{className:"font-mono text-[9px] font-bold text-emerald-500 uppercase tracking-widest",children:"Color_Matrix"}),e.jsx("button",{onClick:()=>l(!1),className:"text-gray-600 hover:text-white",children:e.jsx(L,{size:12})})]}),e.jsxs("div",{ref:w,onMouseDown:N,className:"relative w-full aspect-video mb-4 cursor-crosshair rounded-sm overflow-hidden border border-white/10",style:{backgroundColor:j(a.h,1,1)},children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-white to-transparent"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black to-transparent"}),e.jsx("div",{className:"absolute w-3 h-3 border-2 border-white rounded-full -translate-x-1/2 -translate-y-1/2 shadow-[0_0_5px_rgba(0,0,0,0.5)] pointer-events-none",style:{left:`${a.s*100}%`,top:`${(1-a.v)*100}%`}})]}),e.jsx("div",{ref:g,onMouseDown:C,className:"relative w-full h-4 mb-6 cursor-pointer rounded-sm border border-white/10",style:{background:"linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%)"},children:e.jsx("div",{className:"absolute top-0 bottom-0 w-1.5 bg-white border border-black/40 -translate-x-1/2 shadow-md pointer-events-none",style:{left:`${a.h*100}%`}})}),e.jsx("div",{className:"grid grid-cols-6 gap-1.5 mb-4",children:R.map(i=>e.jsx("button",{onClick:()=>{o(i.hex)},className:`w-full aspect-square rounded-sm border transition-all ${t.toLowerCase()===i.hex.toLowerCase()?"border-emerald-500 scale-110 z-10":"border-white/10 hover:border-white/40"}`,style:{backgroundColor:i.hex},title:i.name},i.hex))}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"relative w-full bg-black/40 border border-white/10 rounded-sm overflow-hidden flex items-center px-3 h-8",children:[e.jsx("input",{type:"text",value:u.toUpperCase(),onChange:i=>{const m=i.target.value;c(m);let d=m;!d.startsWith("#")&&d.length>0&&(d="#"+d),(/^#([0-9A-F]{3}){1,2}$/i.test(d)||/^#([0-9A-F]{4}){1,2}$/i.test(d))&&o(d)},onBlur:()=>c(t),className:"w-full bg-transparent font-mono text-[10px] text-white outline-none uppercase tracking-widest"}),e.jsx("div",{className:"w-4 h-4 rounded-sm border border-white/10 shrink-0",style:{backgroundColor:t}})]})})]})})]})]})};export{_ as C};