{"version":3,"file":"Bad_handwriting.CWJrOXRF.mjs","names":["useRef","_Fragment"],"sources":["https:/framerusercontent.com/modules/DDIJly0lMboaWf7F1MSl/I6TKxjBq5bXosmoBhfAG/Bad_handwriting.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef}from\"react\";// Google Fonts CSS import\nconst fontImport=`\n@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=Indie+Flower&family=Nothing+You+Could+Do&family=Reenie+Beanie&family=Shadows+Into+Light&display=swap');\n`;export default function BadHandwriting({text=\"The quick brown fox jumps over the lazy dog.\",fontSize=48,color=\"#000000\",letterSpacing=0,lineHeight=1.2,fontWeight=400,seed=12,alignment=\"left\"}){const containerRef=useRef(null);// Seeded random function\nfunction seededRandom(seedValue){let x=Math.sin(seedValue++)*1e4;return x-Math.floor(x);}// Wrap each letter in a span with a random font\nfunction wrapLetters(str,element,seedValue){const fonts=[\"Caveat\",\"Indie Flower\",\"Nothing You Could Do\",\"Reenie Beanie\",\"Shadows Into Light\"];// Some fonts don't render certain letters well\nconst blacklist={l:[\"Nothing You Could Do\"]};const lastUsed={};element.innerHTML=\"\";let currentSeed=seedValue;for(const char of str){const span=document.createElement(\"span\");// Handle spaces specially - don't apply font randomization\nif(char===\" \"){span.textContent=\" \";span.style.display=\"inline-block\";span.style.whiteSpace=\"pre\";element.appendChild(span);currentSeed++;continue;}const lowerChar=char.toLowerCase();let availableFonts=fonts;// Filter out blacklisted fonts for specific characters\nif(blacklist[lowerChar]){availableFonts=fonts.filter(f=>!blacklist[lowerChar].includes(f));}// Don't use the same font twice in a row for the same character\nif(lastUsed[lowerChar]){availableFonts=availableFonts.filter(f=>f!==lastUsed[lowerChar]);}const fontIndex=Math.floor(seededRandom(currentSeed)*availableFonts.length);const font=availableFonts[fontIndex]||fonts[0];lastUsed[lowerChar]=font;span.style.fontFamily=`\"${font}\", cursive`;span.textContent=char;element.appendChild(span);currentSeed++;}}useEffect(()=>{if(containerRef.current){wrapLetters(text,containerRef.current,seed);}},[text,seed]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:fontImport}),/*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{fontSize:`${fontSize}px`,color:color,letterSpacing:`${letterSpacing}px`,lineHeight:lineHeight,fontWeight:fontWeight,textAlign:alignment,width:\"100%\",height:\"auto\",wordWrap:\"break-word\",overflowWrap:\"break-word\"}})]});}// Framer property controls\naddPropertyControls(BadHandwriting,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"The quick brown fox jumps over the lazy dog.\",displayTextArea:true},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:48,min:12,max:200,step:1,unit:\"px\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},letterSpacing:{type:ControlType.Number,title:\"Letter Spacing\",defaultValue:0,min:-5,max:20,step:.5,unit:\"px\"},lineHeight:{type:ControlType.Number,title:\"Line Height\",defaultValue:1.2,min:.8,max:3,step:.1},fontWeight:{type:ControlType.Number,title:\"Font Weight\",defaultValue:400,min:400,max:700,step:50,displayStepper:true,description:\"Only affects Caveat font (other fonts are always 400)\"},seed:{type:ControlType.Number,title:\"Pattern\",defaultValue:12,min:1,max:1e4,step:1,displayStepper:true,description:\"# means nothing. Change to get different random patterns\"},alignment:{type:ControlType.Enum,title:\"Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BadHandwriting\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Bad_handwriting.map"],"mappings":"+LAGE,SAAwB,EAAe,CAAC,OAAK,+CAA+C,WAAS,GAAG,QAAM,UAAU,gBAA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