PageSourceSearch

https://web-whisperer-96.lovable.app/assets/CardCustomizer-BCqj_EMm.js

js web-whisperer-96.lovable.app collected 2026-10-03 03:46:00 UTC 66,124 bytes, 11 lines download raw bytes

1import{h as hn,r,i as ia,a as la,b as ca,j as t,d as da,p as ua,B as v,k as ma,c as p,g as x,I as ls,f as ha,s as ga}from"./index-B3_8eyoK.js";import{g as He}from"./uuid-Ca9MTT-r.js";import{Q as fa}from"./index-Qazrfg1S.js";import{L as C}from"./label-BKcyM16a.js";import{S as Qe}from"./slider-DPMhZ-eD.js";import{S as Tt}from"./scroll-area-D6QjpE-Z.js";import{S as ye}from"./separator-DIX3NNen.js";import{T as Ks}from"./textarea-jXjtLbCv.js";import{D as Zs,a as en,b as tn,c as sn,d as nn,e as an}from"./dialog-DhwTtLPn.js";import{u as pa,U as xa,R as ya,T as cs,a as ot,F as on,A as va,b as wa,c as ba,S as ja,P as Sa,v as Na}from"./use-auth-guard-CdQPzR4B.js";import{R as rn}from"./rotate-ccw-CsEMZvoW.js";import{D as Ra}from"./download-CttKh03D.js";import{A as Ca}from"./arrow-right-Dewsv3wg.js";import{I as ln}from"./image-vBGAP3qw.js";import{T as Q}from"./trash-2-CGdevqX-.js";import{U as ds}from"./upload-BJK92w0a.js";import{Z as Ma,a as cn}from"./zoom-out-Cr44P37N.js";import{S as It}from"./sparkles-B894pk4V.js";import{B as ka}from"./building-2-CHy4ZPQA.js";import{P as Da}from"./palette-CoBDbV3-.js";import"./index-BdQq_4o_.js";import"./index-CQ85HnqL.js";import"./index-ClPB03zo.js";import"./index-BEqSZs92.js";import"./index-C6E1zrYh.js";import"./check-ZUqXiT-c.js";import"./alert-dialog-BTBxzKX7.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const dn=hn("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ya=hn("Shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);function Xa(z={}){const{canvasRootRef:k}=z,Y=r.useRef(!1),l=r.useRef(0),X=r.useRef(null),T=r.useCallback(()=>{if(Y.current)return;Y.current=!0,l.current=window.scrollY||0,X.current={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,right:document.body.style.right,width:document.body.style.width,overflow:document.body.style.overflow,overflowX:document.body.style.overflowX,overflowY:document.body.style.overflowY,paddingRight:document.body.style.paddingRight,touchAction:document.body.style.touchAction,userSelect:document.body.style.userSelect,webkitUserSelect:document.body.style.webkitUserSelect??"",htmlOverflow:document.documentElement.style.overflow,htmlOverflowX:document.documentElement.style.overflowX,htmlOverflowY:document.documentElement.style.overflowY,htmlPaddingRight:document.documentElement.style.paddingRight};const g=window.innerWidth-document.documentElement.clientWidth,W=g>0?`${g}px`:"0px";document.body.style.overflowX="hidden",document.body.style.overflowY="hidden",document.body.style.paddingRight=W,document.body.style.touchAction="none",document.body.style.userSelect="none",document.body.style.webkitUserSelect="none",document.documentElement.style.overflowX="hidden",document.documentElement.style.overflowY="hidden",document.documentElement.style.paddingRight=W,document.documentElement.style.touchAction="none"},[]),y=r.useCallback(()=>{if(!Y.current)return;Y.current=!1;const g=X.current;g?(document.body.style.position=g.position,document.body.style.top=g.top,document.body.style.left=g.left,document.body.style.right=g.right,document.body.style.width=g.width,document.body.style.overflow=g.overflow,document.body.style.overflowX=g.overflowX,document.body.style.overflowY=g.overflowY,document.body.style.paddingRight=g.paddingRight,document.body.style.touchAction=g.touchAction,document.body.style.userSelect=g.userSelect,document.body.style.webkitUserSelect=g.webkitUserSelect,document.documentElement.style.overflow=g.htmlOverflow,document.documentElement.style.overflowX=g.htmlOverflowX,document.documentElement.style.overflowY=g.htmlOverflowY,document.documentElement.style.paddingRight=g.htmlPaddingRight,document.documentElement.style.touchAction=""):(document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",document.body.style.overflow="",document.body.style.overflowX="",document.body.style.overflowY="",document.body.style.paddingRight="",document.body.style.touchAction="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",document.documentElement.style.overflow="",document.documentElement.style.overflowX="",document.documentElement.style.overflowY="",document.documentElement.style.paddingRight="",document.documentElement.style.touchAction="")},[]);r.useEffect(()=>()=>{y()},[y]),r.useEffect(()=>{const g=A=>{Y.current&&k!=null&&k.current&&k.current.contains(A.target)&&(A.preventDefault(),A.stopPropagation())},W=A=>{Y.current&&k!=null&&k.current&&k.current.contains(A.target)&&(A.preventDefault(),A.stopPropagation())};return window.addEventListener("wheel",g,{passive:!1,capture:!0}),window.addEventListener("touchmove",W,{passive:!1,capture:!0}),()=>{window.removeEventListener("wheel",g,{capture:!0}),window.removeEventListener("touchmove",W,{capture:!0})}},[k]);const ve=r.useCallback((g=!1)=>({touchAction:"none",userSelect:"none",WebkitUserSelect:"none",cursor:g?"grabbing":"grab"}),[]);return{lockScroll:T,unlockScroll:y,getDragStyles:ve,isInteracting:Y.current}}const Bt="design_your_own_state_v1",Pa=1e3;function za(){const z=r.useRef(null),k=r.useCallback(T=>{z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{try{const y={...T,savedAt:Date.now()};sessionStorage.setItem(Bt,JSON.stringify(y))}catch(y){console.warn("Failed to save design state:",y)}},Pa)},[]),Y=r.useCallback(()=>{try{const T=sessionStorage.getItem(Bt);if(!T)return null;const y=JSON.parse(T),ve=60*60*1e3;return Date.now()-y.savedAt>ve?(sessionStorage.removeItem(Bt),null):y}catch(T){return console.warn("Failed to load design state:",T),null}},[]),l=r.useCallback(()=>{z.current&&clearTimeout(z.current),sessionStorage.removeItem(Bt)},[]),X=r.useCallback(()=>Y()!==null,[Y]);return r.useEffect(()=>()=>{z.current&&clearTimeout(z.current)},[]),{saveState:k,loadState:Y,clearState:l,hasPersistedState:X}}const un=[{id:"serif",name:"Elegant Serif",value:"'Playfair Display', serif"},{id:"sans",name:"Clean Sans",value:"'Inter', sans-serif"},{id:"script",name:"Script",value:"'Dancing Script', cursive"}],us=[{id:"artis",name:"Artis",fontFamily:"'Artis', cursive"},{id:"bittersweet",name:"Bittersweet",fontFamily:"'Bittersweet', cursive"},{id:"bleecker",name:"Bleecker",fontFamily:"'Bleecker', cursive"},{id:"bowery",name:"Bowery",fontFamily:"'Bowery', cursive"},{id:"brooklyn",name:"Brooklyn",fontFamily:"'Brooklyn', cursive"},{id:"dune",name:"Dune",fontFamily:"'Dune', cursive"},{id:"eleventh",name:"Eleventh",fontFamily:"'Eleventh', cursive"},{id:"elm",name:"Elm",fontFamily:"'Elm', cursive"},{id:"gansett",name:"Gansett",fontFamily:"'Gansett', cursive"},{id:"gille",name:"Gille",fontFamily:"'Gille', cursive"},{id:"halsey",name:"Halsey",fontFamily:"'Halsey', cursive"},{id:"harper",name:"Harper",fontFamily:"'Harper', cursive"}
11,{id:"hemingway",name:"Hemingway",fontFamily:"'Hemingway', cursive"},{id:"jane",name:"Jane",fontFamily:"'Jane', cursive"},{id:"kinn",name:"Kinn",fontFamily:"'Kinn', cursive"},{id:"moneta",name:"Moneta",fontFamily:"'Moneta', cursive"},{id:"orchard",name:"Orchard",fontFamily:"'Orchard', cursive"},{id:"orwell",name:"Orwell",fontFamily:"'Orwell', cursive"},{id:"pleasant",name:"Pleasant",fontFamily:"'Pleasant', cursive"},{id:"septembre",name:"Septembre",fontFamily:"'Septembre', cursive"}],mn=["#000000","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#3B82F6","#8B5CF6","#EC4899","#6B7280"],po=()=>{var Os,Hs,Qs,qs,Gs,Ws,$s,_s,Vs;const[z]=ia(),k=la(),l=ca().state,X=z.get("type")||"landscape-folded",T=r.useRef(null),y=r.useRef(null),ve=r.useRef(null),g=r.useRef(!1),{saveState:W,loadState:A,clearState:At}=za(),Et=r.useRef(!1),Ft=(l==null?void 0:l.recipients)??[],[$,rt]=r.useState((l==null?void 0:l.backgroundImage)??null),[we,Lt]=r.useState((l==null?void 0:l.backgroundColor)??"#FFFFFF"),[ae,_]=r.useState((l==null?void 0:l.textElements)??[]),[oe,q]=r.useState(null),[V,gn]=r.useState("uploads"),[m,ms]=r.useState(()=>X.includes("portrait")?80:90),[qe,be]=r.useState((l==null?void 0:l.bgImagePosition)??{x:0,y:0}),[R,re]=r.useState((l==null?void 0:l.bgImageScale)??100),[hs,ie]=r.useState(!1),[it,je]=r.useState(!1),[Ut,Se]=r.useState(!1),[lt,gs]=r.useState({x:0,y:0}),[Ne,fs]=r.useState({scale:100,mouseX:0,mouseY:0}),fn=r.useRef(null),[ct,Ge]=r.useState(!1),[We,$e]=r.useState(null),[dt,ps]=r.useState({x:0,y:0}),[Ot,I]=r.useState(!1),[Ht,B]=r.useState(!1),[Re,xs]=r.useState({fontSize:32,mouseX:0,mouseY:0}),[E,ys]=r.useState({rotation:0,startAngle:0,elementId:""}),Ce=r.useRef(new Map),[vs,pn]=r.useState("Your Text Here"),[ws,xn]=r.useState("#000000"),[Qt,yn]=r.useState([32]),[bs,vn]=r.useState(un[0].value),[qt,ut]=r.useState(""),[js,Ss]=r.useState(""),[Me,wn]=r.useState((l==null?void 0:l.handwritingStyle)??((Os=us.find(e=>e.id==="orwell"))==null?void 0:Os.fontFamily)??us[0].fontFamily),[bn,Ta]=r.useState([39]),[mt,Ia]=r.useState([(l==null?void 0:l.backLineHeight)??1.8]),[ht,Ba]=r.useState([(l==null?void 0:l.backLetterSpacing)??0]),[le,Gt]=r.useState((l==null?void 0:l.backTextAlign)??"left"),[M,D]=r.useState((l==null?void 0:l.messageBlocks)??[{id:He(),text:"",x:40,y:55,rotation:-2,fontSize:39,lineHeight:1.8,letterSpacing:0},{id:He(),text:"Second sentence",x:200,y:190,rotation:1,fontSize:39,lineHeight:1.8,letterSpacing:0},{id:He(),text:"third",x:35,y:340,rotation:-3,fontSize:39,lineHeight:1.8,letterSpacing:0}]),[w,ke]=r.useState(null),[F,gt]=r.useState(null),[ce,De]=r.useState(null),[de,J]=r.useState(null),[ft,Ns]=r.useState({x:0,y:0}),[pt,Rs]=r.useState({rotation:0,startAngle:0}),L=r.useRef(new Map),[Ye,Cs]=r.useState((l==null?void 0:l.qrCodeImage)??null),[Xe,Ms]=r.useState((l==null?void 0:l.qrCodeUrl)??""),ks=r.useRef(null),[ue,xt]=r.useState((l==null?void 0:l.logoImage)??null),[K,me]=r.useState((l==null?void 0:l.logoPosition)??null),[U,Wt]=r.useState([(l==null?void 0:l.logoSize)??80]),[he,$t]=r.useState((l==null?void 0:l.logoRotation)??0),[Pe,ze]=r.useState(!1),[yt,Z]=r.useState(!1),[vt,ee]=r.useState(!1),[Te,Ds]=r.useState({size:80,mouseX:0,mouseY:0}),[wt,Ys]=r.useState({rotation:0,startAngle:0}),[bt,Xs]=r.useState({x:0,y:0}),[_t,jt]=r.useState(!1),[Vt,P]=r.useState(!1),[jn,Sn]=r.useState(!(l!=null&&l.logoImage)),Jt=r.useRef(null),G=r.useRef(null),S=r.useRef(null),[te,Kt]=r.useState((l==null?void 0:l.signatureImage)??null),[ge,St]=r.useState((l==null?void 0:l.signaturePosition)??null),[_e,Nn]=r.useState((l==null?void 0:l.signatureSize)??60),[Ie,Ps]=r.useState((l==null?void 0:l.signatureRotation)??0),[Rn,Cn]=r.useState((l==null?void 0:l.signatureStrokes)??null),[Nt,O]=r.useState(!1),[Ve,Je]=r.useState(!1),[Zt,Be]=r.useState(!1),[es,Ae]=r.useState(!1),[Rt,Mn]=r.useState({x:0,y:0}),[ts,kn]=r.useState({size:60,mouseX:0,mouseY:0}),[zs,Dn]=r.useState({rotation:0,startAngle:0}),Ke=r.useRef(null),[Yn,Ct]=r.useState(!1),[Xn,Pn]=r.useState(!(l!=null&&l.signatureImage)),[fe,Mt]=r.useState((l==null?void 0:l.qrPosition)??null),[pe,zn]=r.useState((l==null?void 0:l.qrSize)??80),[Ee,Ts]=r.useState((l==null?void 0:l.qrRotation)??0),[kt,H]=r.useState(!1),[Ze,et]=r.useState(!1),[ss,Fe]=r.useState(!1),[ns,Le]=r.useState(!1),[Dt,Tn]=r.useState({x:0,y:0}),[as,In]=r.useState({size:80,mouseX:0,mouseY:0}),[Is,Bn]=r.useState({rotation:0,startAngle:0}),tt=r.useRef(null),[An,En]=r.useState(!(l!=null&&l.qrCodeUrl||l!=null&&l.qrCodeImage)),[Fn,st]=r.useState(!1),[se,Bs]=r.useState(""),[Ln,Yt]=r.useState(!1),[os,As]=r.useState(""),[Es,Fs]=r.useState(!1),[Un,Xt]=r.useState(!1),[On,Pt]=r.useState(!1),[Hn,Aa]=r.useState(!1),[Qn,Ea]=r.useState(!1),[qn,Fa]=r.useState(!1),[Gn,La]=r.useState(!1),Ls=15,{lockScroll:Ue,unlockScroll:Oe,getDragStyles:Ua}=Xa({canvasRootRef:ve}),{checkAuth:Wn,AuthDialog:$n}=pa({message:"Please sign in to preview your card. Your design will be saved and you'll continue right where you left off."}),xe=ct||Pe||Ve||Ze||it||ce!==null||yt||Zt||ss||Ut||Ot||vt||es||ns||de!==null||Ht;r.useEffect(()=>{xe?Ue():Oe()},[xe,Ue,Oe]),r.useEffect(()=>{const e=()=>{Ge(!1),$e(null),ze(!1),Z(!1),ee(!1),Je(!1),Be(!1),Ae(!1),et(!1),Fe(!1),Le(!1),je(!1),Se(!1),De(null),J(null),I(!1),B(!1),g.current=!1,Oe()};return window.addEventListener("mouseup",e),window.addEventListener("touchend",e),window.addEventListener("touchcancel",e),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("touchend",e),window.removeEventListener("touchcancel",e)}},[Oe]),r.useEffect(()=>{if(!Et.current&&!l){const e=A();if(e&&e.cardType===X){Et.current=!0;return}}Et.current=!0,W({cardType:X,backgroundImage:$,bgImagePosition:qe,bgImageScale:R,backgroundColor:we,textElements:ae,messageBlocks:M,handwritingStyle:Me,backLineHeight:mt[0],backLetterSpacing:ht[0],backTextAlign:le,logoImage:ue,logoPosition:K,logoSize:U[0],logoRotation:he,signatureImage:te,signaturePosition:ge,signatureSize:_e,signatureRotation:Ie,qrCodeUrl:Xe,qrCodeImage:Ye,qrPosition:fe,qrSize:pe,qrRotation:Ee,recipients:Ft})},[X,$,qe,R,we,ae,M,Me,mt,ht,le,ue,K,U,he,te,ge,_e,Ie,Xe,Ye,fe,pe,Ee,Ft,W,A,l]),r.useCallback(()=>{At()},[At]);const rs=X.includes("portrait"),b=rs?650:950,N=rs?950:650,_n=(e,n)=>{g.current=!0,Ue(),e.preventDefault(),e.stopPropagation();const s=ae.find(u=>u.id===n);if(!s||!y.current)return;const a=y.current.getBoundingClientRect(),o=s.x/b*a.width,i=s.y/N*a.height,c=e.clientX-a.left,d=e.clientY-a.top;ps({x:c-o,y:d-i}),Ge(!0),$e(n),q(n)},Us=e=>{const n=m/100;if(Ht&&E.elementId){const h=Ce.current.get(E.elementId);if(h){const f=h.getBoundingClientRect(),j=f.left+f.width/2,ne=f.top+f.height/2,nt=Math.atan2(e.clientY-ne,e.clientX-j)*(180/Math.PI)-E.startAngle;let at=E.rotation+nt;for(;at>180;)at-=360;for(;at<-180;)at+=360;_(ra=>ra.map(is=>is.id===E.elementId?{...is,rotation:at}:is))}return}if(Ot&&oe){const h=(e.clientX-Re.mouseX)/n,f=(e.clientY-Re.mouseY)/n,j=Math.max(h,f)*.5,ne=Math.max(12,Math.min(200,Re.fontSize+j));_(Js=>Js.map(nt=>nt.id===oe?{...nt,fontSize:ne}:nt));return}if(!ct||!We||!y.current)return;const s=y.current.getBoundingClientRect(),a=e.clientX-s.left-dt.x,o=e.clientY-s.top-dt.y,i=a/s.width*b,c=o/s.height*N,d=Math.max(20,Math.min(b-20,i)),u=Math.max(20,Math.min(N-20,c));_(h=>h.map(f=>f.id===We?{...f,x:d,y:u}:f))},zt=()=>{g.current=!1,Oe(),Ge(!1),$e(null),I(!1),B(!1)},Vn=(e,n)=>{g.current=!0,Ue(),e.preventDefault(),e.stopPropagation();const s=ae.find(h=>h.id===n);if(!s||!y.current)return;const a=e.touches[0],o=y.current.getBoundingClientRect(),i=s.x/b*o.width,c=s.y/N*o.height,d=a.clientX-o.left,u=a.clientY-o.top;ps({x:d-i,y:u-c}),Ge(!0),$e(n),q(n)},Jn=e=>{if(!ct||!We||!y.current)return;e.preventDefault(),e.stopPropagation();const n=e.touches[0],s=y.current.getBoundingClientRect(),a=n.clientX-s.left-dt.x,o=n.clientY-s.top-dt.y,i=a/s.width*b,c=o/s.height*N,d=Math.max(20,Math.min(b-20,i)),u=Math.max(20,Math.min(N-20,c));_(h=>h.map(f=>f.id===We?{...f,x:d,y:u}:f))},Kn=()=>{g.current=!1,Oe(),Ge(!1),$e(null)},Zn=e=>{var a;const n=(a=e.target.files)==null?void 0:a[0];if(!n)return;
11if(!n.type.startsWith("image/")){x.error("Please upload an image file");return}const s=new FileReader;s.onload=o=>{var i;rt((i=o.target)==null?void 0:i.result),be({x:0,y:0}),re(100),ie(!1),x.success("Background image uploaded!")},s.readAsDataURL(n)},ea=e=>{var a;e.preventDefault(),e.stopPropagation(),jt(!1);const n=(a=e.dataTransfer.files)==null?void 0:a[0];if(!n)return;if(!n.type.startsWith("image/")){x.error("Please drop an image file");return}const s=new FileReader;s.onload=o=>{var i;xt((i=o.target)==null?void 0:i.result),me(null),x.success("Logo uploaded!")},s.readAsDataURL(n)},ta=()=>{const e={id:He(),text:vs,x:b/2,y:N/2,fontSize:Qt[0],color:ws,fontFamily:bs,rotation:0};_(n=>[...n,e]),q(e.id),x.success("Text added to canvas")},sa=()=>{rt(null),be({x:0,y:0}),re(100),ie(!1),Lt("#FFFFFF"),_([]),q(null),ut(""),Ss(""),x.success("Canvas reset")},na=()=>{const e=M.map(a=>{const o=L.current.get(a.id);if(o){const i=o.querySelector("[contenteditable]");if(i){const c=i.innerText.trim();if(c&&!Sa.includes(c))return{...a,text:c}}}return a}),n=Na(e);if(!n.isValid){x.error(n.errorMessage);return}n.warningMessage&&x.warning(n.warningMessage);const s={cardType:X,backgroundImage:$,bgImagePosition:qe,bgImageScale:R,backgroundColor:we,textElements:ae,messageBlocks:e,handwritingStyle:Me,backLineHeight:mt[0],backLetterSpacing:ht[0],backTextAlign:le,logoImage:ue,logoPosition:K,logoSize:U[0],logoRotation:he,signatureImage:te,signaturePosition:ge,signatureSize:_e,signatureRotation:Ie,signatureStrokes:Rn,qrCodeUrl:Xe,qrCodeImage:Ye,qrPosition:fe,qrSize:pe,qrRotation:Ee,recipients:Ft};Wn(()=>{At(),k("/design-your-own/preview",{state:s})},{stateToPreserve:s})},aa=async()=>{Fs(!0);try{const{data:e,error:n}=await ga.functions.invoke("draft-message",{body:{category:"greeting",context:os}});if(n)throw n;if(e!=null&&e.message){const s=e.message.trim(),a=s.match(/[^.!?]+[.!?]+/g)||[s];let o=[];if(a.length<=3)for(o=a.map(c=>c.trim());o.length<3;)o.push("");else{const c=Math.ceil(a.length/3);for(let d=0;d<3;d++){const u=d*c,h=Math.min(u+c,a.length);o.push(a.slice(u,h).join(" ").trim())}}o=o.filter((c,d)=>c.length>0||d<o.filter(u=>u.length>0).length),o.length===0&&(o=[s]);const i=o.map((c,d)=>({id:He(),text:c,x:40+d*60,y:55+d*120,rotation:[-2,1,-3][d]||0,fontSize:bn[0],lineHeight:mt[0],letterSpacing:ht[0]}));D(i),ut(s),Yt(!1),As(""),x.success("Message drafted into editable blocks! Feel free to customize.")}}catch(e){console.error("Error generating message:",e),x.error("Failed to generate message. Please try again.")}finally{Fs(!1)}},oa=[{id:"templates",icon:It,label:"Templates"},{id:"uploads",icon:ds,label:"Uploads"},{id:"text",icon:cs,label:"Text"},{id:"elements",icon:on,label:"Draw"},{id:"logos",icon:ka,label:"Logos"},{id:"background",icon:Da,label:"Background"}];return t.jsxs("div",{className:"h-screen h-[100dvh] flex flex-col bg-background overflow-y-hidden",children:[t.jsxs("header",{className:"h-16 border-b border-border bg-card flex items-center justify-between px-4 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(da,{to:"/",className:"flex items-center",children:t.jsx("img",{src:ua,alt:"Pen&Cards",className:"h-10 md:h-12 w-auto object-contain mix-blend-multiply"})}),t.jsx(ye,{orientation:"vertical",className:"h-8"}),t.jsxs(v,{variant:"ghost",size:"sm",onClick:()=>k("/send-a-card"),className:"gap-2",children:[t.jsx(ma,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Back"})]}),t.jsx(ye,{orientation:"vertical",className:"h-6 hidden sm:block"}),t.jsx("div",{className:"hidden sm:block",children:t.jsxs("h1",{className:"font-medium text-sm",children:[X.replace("-"," ").replace(/\b\w/g,e=>e.toUpperCase())," Card"]})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"hidden md:flex items-center gap-1 mr-4",children:[t.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:!0,children:t.jsx(xa,{className:"h-4 w-4"})}),t.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:!0,children:t.jsx(ya,{className:"h-4 w-4"})})]}),t.jsxs(v,{variant:"ghost",size:"sm",onClick:sa,className:"gap-2",children:[t.jsx(rn,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Reset"})]}),t.jsxs(v,{variant:"outline",size:"sm",className:"gap-2",children:[t.jsx(Ra,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Download"})]}),t.jsxs(v,{size:"sm",onClick:na,className:"gap-2",children:[t.jsx("span",{children:"Use Design"}),t.jsx(Ca,{className:"h-4 w-4"})]})]})]}),t.jsxs("div",{className:"flex flex-1 overflow-hidden min-w-0",children:[t.jsx("aside",{className:"w-14 min-w-14 bg-card border-r border-border flex flex-col items-center py-3 gap-0.5 shrink-0 h-[calc(100dvh-4rem)] overflow-y-auto",children:oa.map(e=>t.jsxs("button",{onClick:()=>gn(e.id),className:p("w-11 h-11 rounded-lg flex flex-col items-center justify-center gap-1 transition-all",V===e.id?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[t.jsx(e.icon,{className:"h-5 w-5"}),t.jsx("span",{className:"text-[10px] font-medium leading-tight",children:e.label})]},e.id))}),t.jsxs("aside",{className:"w-52 bg-card border-r border-border flex flex-col shrink-0 h-[calc(100vh-4rem)] overflow-hidden",children:[t.jsx("div",{className:"p-4 border-b border-border",children:t.jsx("h2",{className:"font-semibold text-sm capitalize",children:V})}),t.jsx(Tt,{className:"flex-1",children:t.jsxs("div",{className:"p-4",children:[V==="templates"&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose from our pre-designed templates"}),t.jsx("div",{className:"grid grid-cols-2 gap-3",children:[1,2,3,4,5,6].map(e=>t.jsx("div",{className:"aspect-[4/3] rounded-lg bg-muted border border-border hover:border-primary curs
11or-pointer transition-colors flex items-center justify-center",children:t.jsxs("span",{className:"text-xs text-muted-foreground",children:["Template ",e]})},e))})]}),V==="uploads"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"border-2 border-dashed border-border rounded-lg p-6 text-center cursor-pointer hover:border-primary/50 hover:bg-muted/50 transition-all",onClick:()=>{var e;return(e=T.current)==null?void 0:e.click()},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{var a;e.preventDefault(),e.stopPropagation();const n=(a=e.dataTransfer.files)==null?void 0:a[0];if(!n)return;if(!n.type.startsWith("image/")){x.error("Please drop an image file");return}const s=new FileReader;s.onload=o=>{var i;rt((i=o.target)==null?void 0:i.result),x.success("Background image uploaded!")},s.readAsDataURL(n)},children:[t.jsx(ln,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-sm font-medium",children:"Upload an image"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"or drag and drop"})]}),t.jsx("input",{ref:T,type:"file",accept:"image/*",onChange:Zn,className:"hidden"}),$&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Current Backgroun
11d"}),t.jsxs("div",{className:"relative aspect-video rounded-lg overflow-hidden border border-border",children:[t.jsx("img",{src:$,alt:"Background",className:"w-full h-full object-cover"}),t.jsx(v,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{rt(null),be({x:0,y:0}),re(100),ie(!1)},children:t.jsx(Q,{className:"h-3 w-3"})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx(C,{className:"text-xs font-medium",children:"Image Scale"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(R),"%"]})]}),t.jsx(Qe,{value:[R],onValueChange:e=>re(e[0]),min:50,max:200,step:1})]}),t.jsxs(v,{variant:"outline",size:"sm",className:"w-full gap-2",onClick:()=>{be({x:0,y:0}),re(100)},children:[t.jsx(rn,{className:"h-3 w-3"}),"Reset Position & Scale"]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Click the image on the canvas to drag or resize it directly."})]})]}),V==="text"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(C,{className:"text-xs font-medium",children:"Text Content"}),t.jsx(ls,{value:vs,onChange:e=>pn(e.target.value),placeholder:"Enter your text"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(C,{className:"text-xs font-medium",children:"Font Style"}),t.jsx("div",{className:"space-y-1",children:un.map(e=>t.jsx("button",{onClick:()=>vn(e.value),className:p("w-full p-2 rounded-lg border text-left transition-all text-sm",bs===e.value?"border-primary bg-primary/10":"border-border hover:border-primary/50"),children:t.jsx("span",{style:{fontFamily:e.value},children:e.name})},e.id))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx(C,{className:"text-xs font-medium",children:"Font Size"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[Qt[0],"px"]})]}),t.jsx(Qe,{value:Qt,onValueChange:yn,min:12,max:72,step:1})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(C,{className:"text-xs font-medium",children:"Text Color"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:mn.map(e=>t.jsx("button",{onClick:()=>xn(e),className:p("w-6 h-6 rounded-full border-2 transition-all",ws===e?"border-primary scale-110":"border-transparent hover:scale-105"),style:{backgroundColor:e}},e))})]}),t.jsxs(v,{onClick:ta,className:"w-full",size:"sm",children:[t.jsx(cs,{className:"mr-2 h-4 w-4"}),"Add Text"]})]}),V==="elements"&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Draw and add elements"}),t.jsx("div",{className:"grid grid-cols-3 gap-2",children:["Line","Circle","Square","Arrow","Heart","Star"].map(e=>t.jsx("button",{className:"aspect-square rounded-lg border border-border hover:border-primary hover:bg-muted/50 flex items-center justify-center transition-colors",children:t.jsx("span",{className:"text-xs text-muted-foreground",children:e})},e))})]}),V==="logos"&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload your company logo to personalize your card"}),t.jsxs("div",{className:"border-2 border-dashed border-border rounded-lg p-6 text-center cursor-pointer hover:border-primary/50 hover:bg-muted/50 transition-all",onClick:()=>{var e;return(e=Jt.current)==null?void 0:e.click()},children:[t.jsx(ds,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Upload Logo"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"PNG, JPG, or SVG"})]})]}),V==="background"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(C,{className:"text-xs font-medium",children:"Solid Colors"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:mn.map(e=>t.jsx("button",{onClick:()=>Lt(e),className:p("w-8 h-8 rounded-lg border-2 transition-all",we===e?"border-primary scale-110":"border-transparent hover:scale-105"),style:{backgroundColor:e}},e))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(C,{className:"text-xs font-medium",children:"Custom Color"}),t.jsx(ls,{type:"color",value:we,onChange:e=>Lt(e.target.value),className:"h-10 w-full p-1 cursor-pointer"})]})]})]})})]}),t.jsxs("main",{className:"flex-1 min-w-0 bg-muted/30 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"h-12 border-b border-border bg-card/50 backdrop-blur-sm flex items-center justify-between px-4 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ms(Math.max(50,m-10)),children:t.jsx(Ma,{className:"h-4 w-4"})}),t.jsxs("span",{className:"text-xs font-medium w-12 text-center",children:[m,"%"]}),t.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ms(Math.min(150,m+10)),children:t.jsx(cn,{className:"h-4 w-4"})})]}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[b," × ",N,"px per side"]}),t.jsx("div",{})]}),t.jsx(Tt,{className:"flex-1 h-full canvas-scroll-area",children:t.jsxs("div",{ref:ve,className:p("flex justify-center p-6 min-w-0 min-h-full canvas-workspace",rs?"flex-col lg:flex-row items-start gap-8":"flex-col items-center gap-4",xe&&"is-dragging"),onMouseMove:e=>{Us(e);const n=m/100;if(de){const s=L.current.get(de);if(s){const a=s.getBoundingClientRect(),o=a.left+a.width/2,i=a.top+a.height/2,d=Math.atan2(e.clientY-i,e.clientX-o)*(180/Math.PI)-pt.startAngle;let u=pt.rotation+d;for(;u>180;)u-=360;for(;u<-180;)u+=360;D(h=>h.map(f=>f.id===de?{...f,rotation:u}:f))}return}if(ce&&S.current){const s=S.current.getBoundingClientRect(),a=(e.clientX-s.left-ft.x)/n,o=(e.clientY-s.top-ft.y)/n;D(i=>i.map(c=>c.id===ce?{...c,x:Math.max(-20,Math.min(b-40,a)),y:Math.max(-20,Math.min(N-40,o))}:c))}if(vt&&G.current){const s=G.current.getBoundingClientRect(),a=s.left+s.width/2,o=s.top+s.height/2,c=Math.atan2(e.clientY-o,e.clientX-a)*(180/Math.PI)-wt.startAngle;let d=wt.rotation+c;for(;d>180;)d-=360;for(;d<-180;)d+=360;$t(d);return}if(yt){const s=(e.clientX-Te.mouseX)/n,a=(e.clientY-Te.mouseY)/n,o=Math.max(s,a),i=Math.max(30,Math.min(250,Te.size+o));Wt([i]);return}if(Pe&&S.current){const s=S.current.getBoundingClientRect();let a=(e.clientX-s.left-bt.x)/n,o=(e.clientY-s.top-bt.y)/n;const i=U[0],c=i*1.5,d=(b-c)/2,u=(N-i)/2,h=Math.abs(a-d)<Ls,f=Math.abs(o-u)<Ls;h&&(a=d),f&&(o=u),Xt(h),Pt(f);const j=i*.8;me({x:Math.max(-j,Math.min(b-c+j,a)),y:Math.max(-j,Math.min(N-i+j,o))})}if(es&&Ke.current){const s=Ke.current.getBoundingClientRect(),a=s.left+s.width/2,o=s.top+s.height/2,c=Math.atan2(e.clientY-o,e.clientX-a)*(180/Math.PI)-zs.startAngle;let d=zs.rotation+c;for(;d>180;)d-=360;for(;d<-180;)d+=360;Ps(d);return}if(Zt){const s=(e.clientX-ts.mouseX)/n,a=(e.clientY-ts.mouseY)/n,o=Math.max(s,a),i=Math.max(30,Math.min(200,ts.size+o));Nn(i);return}if(Ve&&S.current){const s=S.current.getBoundingClientRect(),a=(e.clientX-s.left-Rt.x)/n,o=(e.clientY-s.top-Rt.y)/n;St({x:Math.max(-20,Math.min(b-40,a)),y:Math.max(-20,Math.min(N-20,o))})}if(ns&&tt.current){const s=tt.current.getBoundingClientRect(),a=s.left+s.width/2,o=s.top+s.height/2,c=Math.atan2(e.clientY-o,e.clientX-a)*(180/Math.PI)-Is.startAngle;let d=Is.rotation+c;for(;d>180;)d-=360;for(;d<-180;)d+=360;Ts(d);return}if(ss){const s=(e.clientX-as.mouseX)/n,a=(e.clientY-as.mouseY)/n,o=Math.max(s,a),i=Math.max(40,Math.min(200,as.size+o));zn(i);return}if(Ze&&S.current){const s=S.current.getBoundingClientRect(),a=(e.clientX-s.left-Dt.x)/n,o=(e.clientY-s.top-Dt.y)
11/n;Mt({x:Math.max(-20,Math.min(b-40,a)),y:Math.max(-20,Math.min(N-40,o))})}if(Ut&&y.current){const s=e.clientX-Ne.mouseX,a=e.clientY-Ne.mouseY,o=Math.sqrt(s*s+a*a),i=s+a>0?1:-1,c=o*i*.15/n,d=Math.max(50,Math.min(300,Ne.scale+c));re(d);return}if(it&&y.current){const s=y.current.getBoundingClientRect(),a=s.width/2,o=s.height/2,i=(e.clientX-s.left-a)/n,c=(e.clientY-s.top-o)/n,d=lt.x-R/100*b/2,u=lt.y-R/100*N/2,h=i-d/n,f=c-u/n,j=Math.max(0,(R/100-1)*b/2+50);be({x:Math.max(-j,Math.min(j,h)),y:Math.max(-j,Math.min(j,f))})}},onMouseUp:()=>{zt(),ze(!1),Z(!1),ee(!1),Je(!1),Be(!1),Ae(!1),et(!1),Fe(!1),Le(!1),De(null),J(null),I(!1),B(!1),Xt(!1),Pt(!1),je(!1),Se(!1)},onMouseLeave:()=>{zt(),ze(!1),Z(!1),ee(!1),Je(!1),Be(!1),Ae(!1),et(!1),Fe(!1),Le(!1),De(null),J(null),I(!1),B(!1),Xt(!1),Pt(!1),je(!1),Se(!1)},onTouchMove:e=>{if(Jn(e),e.touches.length===0)return;const n=e.touches[0],s=m/100;if(de){e.preventDefault(),e.stopPropagation();const a=L.current.get(de);if(a){const o=a.getBoundingClientRect(),i=o.left+o.width/2,c=o.top+o.height/2,u=Math.atan2(n.clientY-c,n.clientX-i)*(180/Math.PI)-pt.startAngle;let h=pt.rotation+u;for(;h>180;)h-=360;for(;h<-180;)h+=360;D(f=>f.map(j=>j.id===de?{...j,rotation:h}:j))}return}if(ce&&S.current){e.preventDefault(),e.stopPropagation();const a=S.current.getBoundingClientRect(),o=(n.clientX-a.left-ft.x)/s,i=(n.clientY-a.top-ft.y)/s;D(c=>c.map(d=>d.id===ce?{...d,x:Math.max(-20,Math.min(b-40,o)),y:Math.max(-20,Math.min(N-40,i))}:d));return}if(Ht&&E.elementId){const a=Ce.current.get(E.elementId);if(a){const o=a.getBoundingClientRect(),i=o.left+o.width/2,c=o.top+o.height/2,u=Math.atan2(n.clientY-c,n.clientX-i)*(180/Math.PI)-E.startAngle;let h=E.rotation+u;for(;h>180;)h-=360;for(;h<-180;)h+=360;_(f=>f.map(j=>j.id===E.elementId?{...j,rotation:h}:j))}return}if(Ot&&oe){const a=(n.clientX-Re.mouseX)/s,o=(n.clientY-Re.mouseY)/s,i=Math.max(a,o)*.5,c=Math.max(12,Math.min(200,Re.fontSize+i));_(d=>d.map(u=>u.id===oe?{...u,fontSize:c}:u));return}if(vt&&G.current){const a=G.current.getBoundingClientRect(),o=a.left+a.width/2,i=a.top+a.height/2,d=Math.atan2(n.clientY-i,n.clientX-o)*(180/Math.PI)-wt.startAngle;let u=wt.rotation+d;for(;u>180;)u-=360;for(;u<-180;)u+=360;$t(u);return}if(yt){const a=(n.clientX-Te.mouseX)/s,o=(n.clientY-Te.mouseY)/s,i=Math.max(a,o),c=Math.max(30,Math.min(250,Te.size+i));Wt([c]);return}if(Pe&&S.current){const a=S.current.getBoundingClientRect();let o=(n.clientX-a.left-bt.x)/s,i=(n.clientY-a.top-bt.y)/s;const c=U[0],d=c*1.5,u=c*.8;me({x:Math.max(-u,Math.min(b-d+u,o)),y:Math.max(-u,Math.min(N-c+u,i))})}if(Ve&&S.current){const a=S.current.getBoundingClientRect(),o=(n.clientX-a.left-Rt.x)/s,i=(n.clientY-a.top-Rt.y)/s;St({x:o,y:i})}if(Ze&&S.current){const a=S.current.getBoundingClientRect(),o=(n.clientX-a.left-Dt.x)/s,i=(n.clientY-a.top-Dt.y)/s;Mt({x:o,y:i})}if(Ut&&y.current){const a=n.clientX-Ne.mouseX,o=n.clientY-Ne.mouseY,i=Math.sqrt(a*a+o*o),c=a+o>0?1:-1,d=i*c*.15/s,u=Math.max(50,Math.min(300,Ne.scale+d));re(u);return}if(it&&y.current){const a=y.current.getBoundingClientRect(),o=a.width/2,i=a.height/2,c=(n.clientX-a.left-o)/s,d=(n.clientY-a.top-i)/s,u=lt.x-R/100*b/2,h=lt.y-R/100*N/2,f=c-u/s,j=d-h/s,ne=Math.max(0,(R/100-1)*b/2+50);be({x:Math.max(-ne,Math.min(ne,f)),y:Math.max(-ne,Math.min(ne,j))})}},onTouchEnd:()=>{Kn(),ze(!1),Z(!1),ee(!1),Je(!1),Be(!1),Ae(!1),et(!1),Fe(!1),Le(!1),De(null),J(null),I(!1),B(!1),Xt(!1),Pt(!1),je(!1),Se(!1)},children:[t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("div",{className:"mb-3",children:t.jsx("span",{className:"text-sm font-medium text-foreground bg-card px-3 py-1 rounded-full border border-border",children:"Front of Card"})}),t.jsxs("div",{ref:y,className:p("relative shadow-xl rounded-lg transition-transform border border-border overflow-hidden",xe&&"is-dragging",ct&&"cursor-grabbing"),style:{width:b*(m/100),height:N*(m/100),backgroundColor:we,touchAction:xe?"none":"auto",overflow:"hidden"},onClick:()=>{q(null),ie(!1)},onMouseMove:Us,onMouseUp:()=>{zt(),I(!1),B(!1)},onMouseLeave:()=>{zt(),I(!1),B(!1)},children:[t.jsx("div",{className:"absolute inset-0 overflow-hidden rounded-lg",children:$&&t.jsxs("div",{ref:fn,className:p("absolute select-none canvas-draggable",it?"cursor-grabbing dragging":"cursor-grab",hs&&"ring-2 ring-primary ring-offset-2"),style:{width:`${R}%`,height:`${R}%`,left:`${50+qe.x/b*100}%`,top:`${50+qe.y/N*100}%`,transform:"translate(-50%, -50%)",touchAction:"none"},onClick:e=>{e.stopPropagation(),ie(!0),q(null)},onMouseDown:e=>{g.current=!0,Ue(),e.preventDefault(),e.stopPropagation(),ie(!0),q(null);const n=e.currentTarget.getBoundingClientRect();gs({x:e.clientX-n.left,y:e.clientY-n.top}),je(!0)},onTouchStart:e=>{if(g.current=!0,Ue(),e.preventDefault(),e.stopPropagation(),e.touches.length===0)return;const n=e.touches[0];ie(!0),q(null);const s=e.currentTarget.getBoundingClientRect();
11gs({x:n.clientX-s.left,y:n.clientY-s.top}),je(!0)},children:[t.jsx("img",{src:$,alt:"Background",className:"w-full h-full object-cover pointer-events-none",draggable:!1}),hs&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute -bottom-3 -right-3 w-7 h-7 bg-primary rounded-full cursor-se-resize flex items-center justify-center shadow-lg border-2 border-white z-20 hover:scale-110 transition-transform",onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),Se(!0),fs({scale:R,mouseX:e.clientX,mouseY:e.clientY})},onTouchStart:e=>{if(e.stopPropagation(),e.touches.length===0)return;const n=e.touches[0];Se(!0),fs({scale:R,mouseX:n.clientX,mouseY:n.clientY})},children:t.jsx(cn,{className:"w-3.5 h-3.5 text-white"})}),t.jsxs("div",{className:"absolute top-2 left-2 bg-black/60 text-white text-xs px-2 py-1 rounded pointer-events-none",children:[Math.round(R),"%"]}),t.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 bg-black/60 text-white text-xs px-2 py-1 rounded pointer-events-none whitespace-nowrap",children:"Drag to move • Corner to resize"})]})]})}),ae.map(e=>t.jsxs("div",{ref:n=>{n?Ce.current.set(e.id,n):Ce.current.delete(e.id)},className:p("absolute select-none transition-shadow ring-2 ring-offset-2 rounded-xl p-2 canvas-draggable",We===e.id?"cursor-grabbing dragging ring-primary":"cursor-grab",oe===e.id?"ring-primary":"ring-primary/40"),style:{left:`${e.x/b*100}%`,top:`${e.y/N*100}%`,transform:`translate(-50%, -50%) rotate(${e.rotation}deg)`,color:e.color,fontSize:e.fontSize*(m/100),fontFamily:e.fontFamily,touchAction:"none"},onMouseDown:n=>_n(n,e.id),onTouchStart:n=>Vn(n,e.id),onClick:n=>{n.stopPropagation(),q(e.id)},children:[e.text,t.jsx("div",{className:p("absolute -bottom-3 -right-3 w-6 h-6 bg-primary rounded-full cursor-se-resize flex items-center justify-center shadow-md border-2 border-white z-10 transition-opacity canvas-draggable-handle",oe===e.id?"opacity-100":"opacity-60 hover:opacity-100"),style:{touchAction:"none"},onMouseDown:n=>{n.stopPropagation(),n.preventDefault(),I(!0),xs({fontSize:e.fontSize,mouseX:n.clientX,mouseY:n.clientY})},onMouseUp:n=>{n.stopPropagation(),I(!1)},onTouchStart:n=>{n.preventDefault(),n.stopPropagation();const s=n.touches[0];I(!0),xs({fontSize:e.fontSize,mouseX:s.clientX,mouseY:s.clientY})},onTouchEnd:n=>{n.stopPropagation(),I(!1)},children:t.jsx("div",{className:"w-2 h-2 border-r-2 border-b-2 border-white"})}),t.jsx("div",{className:p("absolute -top-8 left-1/2 -translate-x-1/2 w-6 h-6 bg-primary rounded-full cursor-grab flex items-center justify-center shadow-md border-2 border-white z-10 transition-opacity canvas-draggable-handle",oe===e.id?"opacity-100":"opacity-60 hover:opacity-100"),style:{touchAction:"none"},onMouseDown:n=>{n.stopPropagation(),n.preventDefault();const s=Ce.current.get(e.id);if(s){const a=s.getBoundingClientRect(),o=a.left+a.width/2,i=a.top+a.height/2,c=Math.atan2(n.clientY-i,n.clientX-o)*(180/Math.PI);B(!0),ys({rotation:e.rotation,startAngle:c,elementId:e.id})}},onMouseUp:n=>{n.stopPropagation(),B(!1)},onTouchStart:n=>{n.preventDefault(),n.stopPropagation();const s=n.touches[0],a=Ce.current.get(e.id);if(a){const o=a.getBoundingClientRect(),i=o.left+o.width/2,c=o.top+o.height/2,d=Math.atan2(s.clientY-c,s.clientX-i)*(180/Math.PI);B(!0),ys({rotation:e.rotation,startAngle:d,elementId:e.id})}},onTouchEnd:n=>{n.stopPropagation(),B(!1)},children:t.jsx(ot,{className:"w-3 h-3 text-white"})})]},e.id)),!$&&ae.length===0&&t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2",children:[t.jsx(ln,{className:"h-8 w-8 text-muted-foreground/30"}),t.jsx("p",{className:"text-muted-foreground/50 text-xs text-center px-4",children:"Upload an image or add text"})]})]})]}),t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("div",{className:"mb-3",children:t.jsx("span",{className:"text-sm font-medium text-foreground bg-card px-3 py-1 rounded-full border border-border",children:"Inside of Card"})}),t.jsxs("div",{ref:S,className:p("relative shadow-xl rounded-lg overflow-hidden border border-border bg-white",xe&&"is-dragging"),style:{width:b*(m/100),height:N*(m/100),touchAction:xe?"none":"auto"},onClick:()=>P(!1),children:[Pe&&t.jsxs(t.Fragment,{children:[Un&&t.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-primary pointer-events-none z-50",style:{left:"50%"}}),On&&t.jsx("div",{className:"absolute left-0 right-0 h-px bg-primary pointer-events-none z-50",style:{to
11p:"50%"}}),Hn&&t.jsx("div",{className:"absolute left-0 right-0 h-px bg-primary/70 pointer-events-none z-50",style:{top:20*(m/100)}}),Qn&&t.jsx("div",{className:"absolute left-0 right-0 h-px bg-primary/70 pointer-events-none z-50",style:{bottom:20*(m/100)}}),qn&&t.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-primary/70 pointer-events-none z-50",style:{left:20*(m/100)}}),Gn&&t.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-primary/70 pointer-events-none z-50",style:{right:20*(m/100)}})]}),!ue&&jn&&t.jsxs("div",{className:p("absolute left-1/2 -translate-x-1/2 w-20 h-20 border-2 border-dashed rounded-lg flex items-center justify-center cursor-pointer transition-all",_t?"border-primary bg-primary/10 scale-105":"border-muted-foreground/30 hover:border-primary/50 hover:bg-muted/20"),style:{top:16*(m/100)},onClick:()=>{var e;return(e=Jt.current)==null?void 0:e.click()},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),jt(!0)},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),jt(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),jt(!1)},onDrop:ea,children:[t.jsx("span",{className:p("text-[10px] text-center px-1",_t?"text-primary font-medium":"text-muted-foreground/50"),children:_t?"Drop here":"Upload Logo"}),t.jsx("div",{className:"absolute -top-2 -right-2 w-5 h-5 bg-destructive rounded-full cursor-pointer border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",onClick:e=>{e.preventDefault(),e.stopPropagation(),Sn(!1),x.success("Logo placeholder hidden")},children:t.jsx(Q,{className:"h-3 w-3 text-white"})})]}),ue&&t.jsxs("div",{ref:G,className:p("absolute select-none group ring-2 ring-offset-1 canvas-draggable",Pe?"cursor-grabbing dragging ring-primary":"cursor-grab",Vt||Pe||yt||vt?"ring-primary":"ring-primary/40"),style:{...K===null?{top:20*(m/100),left:"50%",transform:`translateX(-50%) rotate(${he}deg)`}:{left:K.x*(m/100),top:K.y*(m/100),transform:`rotate(${he}deg)`},touchAction:"none"},onClick:e=>{e.stopPropagation(),P(!0),O(!1),H(!1)},onMouseDown:e=>{var a;e.preventDefault(),e.stopPropagation(),P(!0),O(!1),H(!1);const n=e.currentTarget.getBoundingClientRect(),s=(a=S.current)==null?void 0:a.getBoundingClientRect();if(s&&K===null){const o=m/100;me({x:(n.left-s.left)/o,y:(n.top-s.top)/o})}Xs({x:e.clientX-n.left,y:e.clientY-n.top}),ze(!0)},onTouchStart:e=>{var o;e.preventDefault(),e.stopPropagation(),P(!0);const n=e.touches[0],s=e.currentTarget.getBoundingClientRect(),a=(o=S.current)==null?void 0:o.getBoundingClientRect();if(a&&K===null){const i=m/100;me({x:(s.left-a.left)/i,y:(s.top-a.top)/i})}Xs({x:n.clientX-s.left,y:n.clientY-s.top}),ze(!0)},children:[t.jsx("img",{src:ue,alt:"Logo",style:{height:U[0]*(m/100),width:"auto"},className:"pointer-events-none",draggable:!1}),t.jsxs(t.Fragment,{children:[t.jsx("div",{className:p("absolute -bottom-1.5 -right-1.5 w-4 h-4 bg-primary rounded-sm cursor-se-resize border-2 border-white shadow-sm hover:scale-110 transition-all",Vt?"opacity-100":"opacity-60 hover:opacity-100"),onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),Ds({size:U[0],mouseX:e.clientX,mouseY:e.clientY}),Z(!0)},onMouseUp:e=>{e.stopPropagation(),Z(!1)},onTouchStart:e=>{e.preventDefault(),e.stopPropagation();const n=e.touches[0];Ds({size:U[0],mouseX:n.clientX,mouseY:n.clientY}),Z(!0)},onTouchEnd:e=>{e.stopPropagation(),Z(!1)}}),t.jsx("div",{className:p("absolute -top-6 left-1/2 -translate-x-1/2 w-5 h-5 bg-primary rounded-full cursor-grab border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",Vt?"opacity-100":"opacity-60 hover:opacity-100"),onMouseDown:e=>{if(e.preventDefault(),e.stopPropagation(),G.current){const n=G.current.getBoundingClientRect(),s=n.left+n.width/2,a=n.top+n.height/2,o=Math.atan2(e.clientY-a,e.clientX-s)*(180/Math.PI);Ys({rotation:he,startAngle:o}),ee(!0)}},onMouseUp:e=>{e.stopPropagation(),ee(!1)},onTouchStart:e=>{if(e.preventDefault(),e.stopPropagation(),G.current&&e.touches.length>0){const n=e.touches[0],s=G.current.getBoundingClientRect(),a=s.left+s.width/2,o=s.top+s.height/2,i=Math.atan2(n.clientY-o,n.clientX-a)*(180/Math.PI);Ys({rotation:he,startAngle:i}),ee(!0)}},onTouchEnd:e=>{e.stopPropagation(),ee(!1)},children:t.jsx(ot,{className:"h-3 w-3 text-white"})}),t.jsx("div",{className:"absolute -top-6 -right-1 w-5 h-5 bg-destructive rounded-full cursor-pointer border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",onClick:e=>{e.preventDefault(),e.stopPropagation(),xt(null),me(null),$t(0),P(!1),x.success("Logo removed")},children:t.jsx(Q,{className:"h-3 w-3 text-white"})})]})]}),M.map((e,n)=>t.jsxs("div",{ref:s=>{s?L.current.set(e.id,s):L.current.delete(e.id)},className:p("absolute select-none p-2 rounded-xl",F===e.id?"cursor-text":ce===e.id?"cursor-grabbing ring-2 ring-offset-2 ring-primary":"cursor-grab ring-2 ring-offset-2",F!==e.id&&(w===e.id||ce===e.id?"ring-primary":"ring-primary/30")),style:{left:e.x*(m/100),top:e.y*(m/100),transform:`rotate(${e.rotation}deg)`,fontFamily:Me,fontSize:e.fontSize*(m/100),lineHeight:e.lineHeight,letterSpacing:e.letterSpacing*(m/100),color:"#0028fd",textAlign:le,maxWidth:(b-80)*(m/100),touchAction:F===e.id?"manipulation":"none"},onClick:s=>{if(s.stopPropagation(),w===e.id&&F!==e.id){gt(e.id),setTimeout(()=>{const a=L.current.get(e.id);if(a){const o=a.querySelector("[contenteditable]");if(o){const i=o.innerText;(i==="Tap to type..."||i==="Add more text...")&&(o.innerText=""),o.focus();const c=document.createRange(),d=window.getSelection();c.selectNodeContents(o),c.collapse(!1),d==null||d.removeAllRanges(),d==null||d.addRange(c)}}},0);return}ke(e.id),P(!1),O(!1),H(!1)},onDoubleClick:s=>
11{s.stopPropagation(),gt(e.id),ke(e.id),setTimeout(()=>{const a=L.current.get(e.id);if(a){const o=a.querySelector("[contenteditable]");if(o){const i=o.innerText;(i==="Tap to type..."||i==="Add more text...")&&(o.innerText=""),o.focus();const c=document.createRange(),d=window.getSelection();c.selectNodeContents(o),c.collapse(!1),d==null||d.removeAllRanges(),d==null||d.addRange(c)}}},0)},onMouseDown:s=>{if(F===e.id)return;s.preventDefault(),s.stopPropagation(),ke(e.id),P(!1),O(!1),H(!1);const a=s.currentTarget.getBoundingClientRect();Ns({x:s.clientX-a.left,y:s.clientY-a.top}),De(e.id)},onTouchStart:s=>{if(F===e.id)return;if(w===e.id){s.stopPropagation(),gt(e.id);const i=s.currentTarget;setTimeout(()=>{const c=i.querySelector("[contenteditable]");if(c){const d=c.innerText;(d==="Tap to type..."||d==="Add more text...")&&(c.innerText=""),c.focus();const u=window.getSelection(),h=document.createRange();h.selectNodeContents(c),u==null||u.removeAllRanges(),u==null||u.addRange(h)}},0);return}if(s.preventDefault(),s.stopPropagation(),s.touches.length===0)return;const a=s.touches[0];ke(e.id),P(!1),O(!1),H(!1);const o=s.currentTarget.getBoundingClientRect();Ns({x:a.clientX-o.left,y:a.clientY-o.top}),De(e.id)},children:[t.jsx("div",{contentEditable:F===e.id,suppressContentEditableWarning:!0,className:p("outline-none min-w-[200px] min-h-[2em] whitespace-pre-wrap",F===e.id&&"bg-white/80 px-2 py-1 cursor-text"),onFocus:s=>{const a=s.currentTarget.innerText;["Tap to type...","Double-click to type...","Second sentence","Third","third","New text...","Add more text..."].includes(a)&&(s.currentTarget.innerText="")},onBlur:s=>{gt(null);const a=s.currentTarget.innerText.trim(),o=n===0?"Tap to type...":"New text...";a===""?(s.currentTarget.innerText=o,D(i=>i.map(c=>c.id===e.id?{...c,text:o}:c))):D(i=>i.map(c=>c.id===e.id?{...c,text:a}:c))},onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),s.currentTarget.blur()),s.key==="Enter"&&!s.shiftKey&&s.stopPropagation()},onClick:s=>{F===e.id&&s.stopPropagation()},onMouseDown:s=>{F===e.id&&s.stopPropagation()},children:e.text}),n===0&&js&&t.jsxs("div",{contentEditable:!0,suppressContentEditableWarning:!0,className:"mt-4 outline-none cursor-text",style:{color:"#0028fd"},onInput:s=>{const a=s.currentTarget.innerText||"";Ss(a.replace(/^—\s*/,""))},onMouseDown:s=>s.stopPropagation(),onClick:s=>s.stopPropagation(),children:["— ",js]}),t.jsx("div",{className:p("absolute -top-6 left-1/2 -translate-x-1/2 w-5 h-5 bg-primary rounded-full cursor-grab border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",w===e.id?"opacity-100":"opacity-60 hover:opacity-100"),onMouseDown:s=>{s.preventDefault(),s.stopPropagation();const a=L.current.get(e.id);if(a){const o=a.getBoundingClientRect(),i=o.left+o.width/2,c=o.top+o.height/2,d=Math.atan2(s.clientY-c,s.clientX-i)*(180/Math.PI);Rs({rotation:e.rotation,startAngle:d}),J(e.id)}},onMouseUp:s=>{s.stopPropagation(),J(null)},onTouchStart:s=>{s.stopPropagation();const a=L.current.get(e.id);if(!a||s.touches.length===0)return;const o=s.touches[0],i=a.getBoundingClientRect(),c=i.left+i.width/2,d=i.top+i.height/2,u=Math.atan2(o.clientY-d,o.clientX-c)*(180/Math.PI);Rs({rotation:e.rotation,startAngle:u}),J(e.id)},onTouchEnd:s=>{s.stopPropagation(),J(null)},children:t.jsx(ot,{className:"h-3 w-3 text-white"})}),n>0&&t.jsx("div",{className:p("absolute -top-6 -right-1 w-5 h-5 bg-destructive rounded-full cursor-pointer border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",w===e.id?"opacity-100":"opacity-60 hover:opacity-100"),onClick:s=>{s.preventDefault(),s.stopPropagation(),D(a=>a.filter(o=>o.id!==e.id)),w===e.id&&ke(null),x.success("Text block removed")},children:t.jsx(Q,{className:"h-3 w-3 text-white"})})]},e.id)),te?t.jsxs("div",{ref:Ke,className:p("absolute select-none ring-2 ring-offset-1 canvas-draggable",Ve?"cursor-grabbing dragging ring-primary":"cursor-grab",Nt||Ve||Zt||es?"ring-primary":"ring-primary/40"),style:{...ge===null?{bottom:16*(m/100),left:16*(m/100),transform:`rotate(${Ie}deg)`}:{left:ge.x*(m/100),top:ge.y*(m/100),transform:`rotate(${Ie}deg)`},touchAction:"none"},onClick:e=>{e.stopPropagation(),O(!0),P(!1),H(!1)},onMouseDown:e=>{var a;e.preventDefault(),e.stopPropagation(),O(!0),P(!1),H(!1);const n=e.currentTarget.getBoundingClientRect(),s=(a=S.current)==null?void 0:a.getBoundingClientRect();if(s&&ge===null){const o=m/100;St({x:(n.left-s.left)/o,y:(n.top-s.top)/o})}Mn({x:e.clientX-n.left,y:e.clientY-n.top}),Je(!0)},children:[t.jsx("img",{src:te,alt:"Signature",style:{height:_e*(m/100),width:"auto"},className:"pointer-events-none",draggable:!1}),t.jsxs(t.Fragment,{children:[t.jsx("div",{className:p("absolute -bottom-1.5 -right-1.5 w-4 h-4 bg-primary rounded-sm cursor-se-resize border-2 border-white shadow-sm hover:scale-110 transition-all",Nt?"opacity-100":"opacity-60 hover:opacity-100"),onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),kn({size:_e,mouseX:e.clientX,mouseY:e.clientY}),Be(!0)},onMouseUp:e=>{e.stopPropagation(),Be(!1)}}),t.jsx("div",{className:p("absolute -top-6 left-1/2 -translate-x-1/2 w-5 h-5 bg-primary rounded-full cursor-grab border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",Nt?"opacity-100":"opacity-60 hover:opacity-100"),onMouseDown:e=>{if(e.preventDefault(),e.stopPropagation(),Ke.current){const n=Ke.current.getBoundingClientRect(),s=n.left+n.width/2,a=n.top+n.height/2,o=Math.atan2(e.clientY-a,e.clientX-s)*(180/Math.PI);Dn({rotation:Ie,startAngle:o}),Ae(!0)}},onMouseUp:e=>{e.stopPropagation(),Ae(!1)},children:t.jsx(ot,{className:"h-3 w-3 text-white"})}),t.jsx("div",{className:p("absolute -top-6 -right-1 w-5 h-5 bg-destructive rounded-full cursor-pointer border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",Nt?"opacity-100":"opacity-60 hover:opacity-100"),onClick:e=>{e.preventDefault(),e.stopPropagation(),Kt(null),St(null),Ps(0),O(!1),x.success("Signature removed")},children:t.jsx(Q,{className:"h-3 w-3 text-white"})})]})]}):Xn&&t.jsxs("div",{className:"absolute bottom-4 left-4 w-24 h-16 border-2 border-dashed border-muted-foreground
11/30 rounded-lg flex items-center justify-center cursor-pointer hover:border-primary/50 hover:bg-muted/20 transition-all",onClick:()=>Ct(!0),children:[t.jsx("span",{className:"text-[10px] text-muted-foreground/50 text-center px-1",children:"Add Signature"}),t.jsx("div",{className:"absolute -top-2 -right-2 w-5 h-5 bg-destructive rounded-full cursor-pointer border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",onClick:e=>{e.preventDefault(),e.stopPropagation(),Pn(!1),x.success("Signature placeholder hidden")},children:t.jsx(Q,{className:"h-3 w-3 text-white"})})]}),Xe||Ye?t.jsxs("div",{ref:tt,className:p("absolute select-none ring-2 ring-offset-1 canvas-draggable",Ze?"cursor-grabbing dragging ring-primary":"cursor-grab",kt||Ze||ss||ns?"ring-primary":"ring-primary/40"),style:{...fe===null?{bottom:16*(m/100),right:16*(m/100),transform:`rotate(${Ee}deg)`}:{left:fe.x*(m/100),top:fe.y*(m/100),transform:`rotate(${Ee}deg)`},touchAction:"none"},onClick:e=>{e.stopPropagation(),H(!0),P(!1),O(!1)},onMouseDown:e=>{var a;e.preventDefault(),e.stopPropagation(),H(!0),P(!1),O(!1);const n=e.currentTarget.getBoundingClientRect(),s=(a=S.current)==null?void 0:a.getBoundingClientRect();if(s&&fe===null){const o=m/100;Mt({x:(n.left-s.left)/o,y:(n.top-s.top)/o})}Tn({x:e.clientX-n.left,y:e.clientY-n.top}),et(!0)},children:[Xe?t.jsx(fa,{value:Xe,size:pe*(m/100)}):Ye?t.jsx("img",{src:Ye,alt:"QR Code",style:{width:pe*(m/100),height:pe*(m/100)},className:"pointer-events-none",draggable:!1}):null,t.jsxs(t.Fragment,{children:[t.jsx("div",{className:p("absolute -bottom-1.5 -right-1.5 w-4 h-4 bg-primary rounded-sm cursor-se-resize border-2 border-white shadow-sm hover:scale-110 transition-all",kt?"opacity-100":"opacity-60 hover:opacity-100"),onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),In({size:pe,mouseX:e.clientX,mouseY:e.clientY}),Fe(!0)},onMouseUp:e=>{e.stopPropagation(),Fe(!1)}}),t.jsx("div",{className:p("absolute -top-6 left-1/2 -translate-x-1/2 w-5 h-5 bg-primary rounded-full cursor-grab border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",kt?"opacity-100":"opacity-60 hover:opacity-100"),onMouseDown:e=>{if(e.preventDefault(),e.stopPropagation(),tt.current){const n=tt.current.getBoundingClientRect(),s=n.left+n.width/2,a=n.top+n.height/2,o=Math.atan2(e.clientY-a,e.clientX-s)*(180/Math.PI);Bn({rotation:Ee,startAngle:o}),Le(!0)}},onMouseUp:e=>{e.stopPropagation(),Le(!1)},children:t.jsx(ot,{className:"h-3 w-3 text-white"})}),t.jsx("div",{className:p("absolute -top-6 -right-1 w-5 h-5 bg-destructive rounded-full cursor-pointer border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",kt?"opacity-100":"opacity-60 hover:opacity-100"),onClick:e=>{e.preventDefault(),e.stopPropagation(),Ms(""),Cs(null),Mt(null),Ts(0),H(!1),x.success("QR code removed")},children:t.jsx(Q,{className:"h-3 w-3 text-white"})})]})]}):An&&t.jsxs("div",{className:"absolute bottom-4 right-4 w-20 h-20 border-2 border-dashed border-muted-foreground/30 rounded-lg flex flex-col items-center justify-center cursor-pointer hover:border-primary/50 hover:bg-muted/20 transition-all",onClick:()=>st(!0),children:[t.jsx(dn,{className:"h-6 w-6 text-muted-foreground/30 mb-1"}),t.jsx("span",{className:"text-[10px] text-muted-foreground/50 text-center px-1",children:"Add QR"}),t.jsx("div",{className:"absolute -top-2 -right-2 w-5 h-5 bg-destructive rounded-full cursor-pointer border-2 border-white shadow-sm hover:scale-110 transition-all flex items-center justify-center",onClick:e=>{e.preventDefault(),e.stopPropagation(),En(!1),x.success("QR placeholder hidden")},children:t.jsx(Q,{className:"h-3 w-3 text-white"})})]}),t.jsx("input",{ref:ks,type:"file",accept:"image/*",onChange:e=>{var s;const n=(s=e.target.files)==null?void 0:s[0];if(n){const a=new FileReader;a.onload=o=>{var i;return Cs((i=o.target)==null?void 0:i.result)},a.readAsDataURL(n)}},className:"hidden"})]})]})]})})]}),t.jsx("aside",{className:"w-72 bg-card border-l border-border flex flex-col shrink-0 sticky top-0 h-[calc(100dvh-4rem)] supports-[height:100dvh]:h-[calc(100dvh-4rem)]",children:t.jsx(Tt,{className:"flex-1",children:t.jsxs("div",{className:"p-3 space-y-3",children:[t.jsx("input",{ref:Jt,type:"file",accept:"image/*",onChange:e=>{var s;const n=(s=e.target.files)==null?void 0:s[0];if(n){const a=new FileReader;a.onload=o=>{var i;return xt((i=o.target)==null?void 0:i.result)},a.readAsDataURL(n)}},className:"hidden"}),ue&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(C,{className:"text-xs font-medium",children:"Logo"}),t.jsxs(v,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-destructive hover:text-destructive",onClick:()=>{xt(null),me(null),x.success("Logo removed")},children:[t.jsx(Q,{className:"h-3 w-3 mr-1"}),"Remove"]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Size"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[U[0],"px"]})]}),t.jsx(Qe,{value:U,onValueChange:Wt,min:30,max:200,step:5,className:"w-full"})]}),t.jsx(ye,{})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(C,{className:"text-xs font-medium",children:"Robot Writing Style"}),t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Real pen & ink"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 bg-primary/5 rounded-md border border-primary/20",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Written by robots with ballpoint pen"})]}),t.jsx(Tt,{className:"h-[280px]",children:t.jsx("div",{className:"space-y-1 pr-3",children:us.map(e=>t.jsxs("button",{onClick:()=>wn(e.fontFamily),className:p("w-full py-2 px-2.5 rounded-md border text-left transition-all group",Me===e.fontFamily?"border-primary bg-primary/10 ring-1 ring-primary/30":"border-border hover:border-primary/50 hover:bg-muted/30"),children:[t.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[t.jsx("span",{className:"text-[10px] text-muted-foreground",children:e.name}),Me===e.fontFamily&&t.jsx("span",{className:"text-[9px] text-primary font-medium",children:"Selected"})]}),t.jsx("span",{style:{fontFamily:e.fontFamily},className:"text-lg text-[#0028fd] block leading-tight",children:"Hello World"})]},e.id))})}),t.jsx("p",{className:"text-[10px] text-muted-foreground text-center leading-snug",children:"Preview is a
11pproximate. Physical cards have natural pen variations."})]}),t.jsx(ye,{}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx(C,{className:"text-xs font-medium",children:"Font Size"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:w?`${((Hs=M.find(e=>e.id===w))==null?void 0:Hs.fontSize)||39}px`:`${((Qs=M[0])==null?void 0:Qs.fontSize)||39}px`})]}),t.jsx(Qe,{value:[w?((qs=M.find(e=>e.id===w))==null?void 0:qs.fontSize)||39:((Gs=M[0])==null?void 0:Gs.fontSize)||39],onValueChange:e=>{var s;const n=w||((s=M[0])==null?void 0:s.id);n&&D(a=>a.map(o=>o.id===n?{...o,fontSize:e[0]}:o))},min:14,max:120,step:1})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx(C,{className:"text-xs font-medium",children:"Line Spacing"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:(((Ws=M.find(e=>e.id===w))==null?void 0:Ws.lineHeight)??1.8).toFixed(1)})]}),t.jsx(Qe,{value:[(($s=M.find(e=>e.id===w))==null?void 0:$s.lineHeight)??1.8],onValueChange:e=>{w&&D(n=>n.map(s=>s.id===w?{...s,lineHeight:e[0]}:s))},min:.8,max:3,step:.1,disabled:!w})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx(C,{className:"text-xs font-medium",children:"Letter Spacing"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[(((_s=M.find(e=>e.id===w))==null?void 0:_s.letterSpacing)??0).toFixed(1),"px"]})]}),t.jsx(Qe,{value:[((Vs=M.find(e=>e.id===w))==null?void 0:Vs.letterSpacing)??0],onValueChange:e=>{w&&D(n=>n.map(s=>s.id===w?{...s,letterSpacing:e[0]}:s))},min:-2,max:10,step:.5,disabled:!w})]}),t.jsx(ye,{}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(C,{className:"text-xs font-medium",children:"Merge Fields"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:[{label:"First Name",value:"{{first_name}}"},{label:"Last Name",value:"{{last_name}}"},{label:"Company",value:"{{company}}"}].map(e=>t.jsx(v,{type:"button",variant:"outline",size:"sm",className:"h-6 text-[10px] px-2",disabled:!w,onClick:()=>{if(w){D(s=>s.map(a=>a.id===w?{...a,text:a.text+e.value}:a));const n=L.current.get(w);if(n){const s=n.querySelector("[contenteditable]");if(s){const a=s.innerText;a==="Double-click to type..."||a==="Second sentence"||a==="third"?s.innerText=e.value:s.innerText=a+e.value}}x.success(`${e.label} added`)}},children:e.label},e.value))})]}),t.jsx(ye,{}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(C,{className:"text-xs font-medium",children:"Add Text Block"}),t.jsx(Ks,{value:qt,onChange:e=>ut(e.target.value),placeholder:"Type message, then Add Block...",className:"min-h-[180px] resize-none w-full text-sm"}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsxs(v,{type:"button",variant:"outline",size:"sm",className:"flex-1 gap-1 h-7",onClick:()=>{if(!qt.trim()){x.error("Please type a message first");return}const e=M[M.length-1],n={id:He(),text:qt,x:e?e.x:24,y:e?e.y+80:110,rotation:0,fontSize:e?e.fontSize:39,lineHeight:e?e.lineHeight:1.8,letterSpacing:e?e.letterSpacing:0};D(s=>[...s,n]),ke(n.id),ut(""),x.success("Text block added!")},children:[t.jsx(cs,{className:"h-3 w-3"}),"Add"]}),t.jsx(v,{type:"button",variant:"outline",size:"sm",className:"gap-1 h-7",onClick:()=>{D(e=>e.map(n=>({...n,x:n.x+(Math.random()-.5)*30,y:n.y+(Math.random()-.5)*20,rotation:(Math.random()-.5)*8}))),x.success("Randomized!")},children:t.jsx(Ya,{className:"h-3 w-3"})})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[t.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:()=>Yt(!0),className:"gap-1 h-7 border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground",children:[t.jsx(It,{className:"h-3 w-3"}),"AI"]}),t.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:()=>Ct(!0),className:"gap-1 h-7 border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground",children:[t.jsx(on,{className:"h-3 w-3"}),te?"Edit Sig":"Signature"]}),te&&t.jsx(v,{type:"button",variant:"outline",size:"sm",onClick:()=>{Kt(null),x.success("Signature cleared")},className:"gap-1 h-7 text-destructive hover:text-destructive",children:t.jsx(Q,{className:"h-3 w-3"})})]}),t.jsx(ye,{}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(C,{className:"text-xs font-medium",children:"Text Alignment"}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(v,{variant:le==="left"?"default":"outline",size:"sm",className:"flex-1 h-7",onClick:()=>Gt("left"),children:t.jsx(va,{className:"h-3.5 w-3.5"})}),t.jsx(v,{variant:le==="center"?"default":"outline",size:"sm",className:"flex-1 h-7",onClick:()=>Gt("center"),children:t.jsx(wa,{className:"h-3.5 w-3.5"})}),t.jsx(v,{variant:le==="right"?"default":"outline",size:"sm",className:"flex-1 h-7",onClick:()=>Gt("right"),children:t.jsx(ba,{className:"h-3.5 w-3.5"})})]})]})]})})})]}),t.jsx(Zs,{open:Ln,onOpenChange:Yt,children:t.jsxs(en,{className:"sm:max-w-md",children:[t.jsxs(tn,{children:[t.jsxs(sn,{className:"flex items-center gap-2",children:[t.jsx(It,{className:"h-5 w-5 text-primary"}),"AI Message Assistant"]}),t.jsx(nn,{children:"Describe what kind of message you'd like to write and AI will draft one for you."})]}),t.jsx("div",{className:"space-y-4 py-4",children:t.jsx(Ks,{placeholder:"E.g., A warm thank you message for a business partner who helped close a big deal...",value:os,onChange:e=>As(e.target.value),className:"min-h-[100px]"})}),t.jsxs(an,{children:[t.jsx(v,{variant:"outline",onClick:()=>Yt(!1),children:"Cancel"}),t.jsx(v,{onClick:aa,disabled:Es||!os.trim(),children:Es?t.jsxs(t.Fragment,{children:[t.jsx(ha,{size:"sm",className:"mr-2"}),"Generating..."]}):t.jsxs(t.Fragment,{children:[t.jsx(It,{className:"mr-2 h-4 w-4"}),"Generate Message"]})})]})]})}),t.jsx(ja,{open:Yn,onClose:()=>Ct(!1),onSave:(e,n)=>{Kt(e),n&&Cn({strokes:n.strokes,bounds:n.bounds}),Ct(!1),x.success("Signature saved!")},existingSignature:te||void 0}),t.jsx(Zs,{open:Fn,onOpenChange:st,children:t.jsxs(en,{className:"sm:max-w-md",children:[t.jsxs(tn,{children:[t.jsx(sn,{children:"Add QR Code"}),t.jsx(nn,{children:"Enter a URL to generate a QR code, or upload an existing QR code image."})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(C,{htmlFor:"qr-url",children:"Website URL"}),t.jsx(ls,{id:"qr-url",placeholder:"https://example.com",value:se,onChange:e=>Bs(e.target.value)})]}),t.jsx("div",{className:"text-center text-xs text-muted-foreground",children:"or"}),t.jsxs(v,{type:"button",variant:"outline",className:"w-full",onClick:()=>{var e;(e=ks.current)==null||e.click(),st(!1)},children:[t.jsx(ds,{className:"mr-2 h-4 w-4"}),"Upload QR Code Image"]})]}),t.jsxs(an,{children:[t.jsx(v,{variant:"outline",onClick:()=>st(!1),children:"Cancel"}),t.jsxs(v,{onClick:()=>
11{if(!se.trim()){x.error("Please enter a URL");return}try{new URL(se.startsWith("http")?se:`https://${se}`)}catch{x.error("Please enter a valid URL");return}const e=se.startsWith("http")?se:`https://${se}`;Ms(e),st(!1),Bs(""),x.success("QR code generated!")},children:[t.jsx(dn,{className:"mr-2 h-4 w-4"}),"Generate QR Code"]})]})]})}),t.jsx($n,{})]})};export{po as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.