{"version":3,"file":"CopyCodeButton.CE-znoxZ.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/wXqigQr1rkuDfl5kDA1U/awacE2fr9jMn2KroxwxI/CopyCodeButton.js"],"sourcesContent":["/**\n * CopyCodeButton — Code block with syntax highlighting + copy button\n *\n * v2.0 — Bash syntax highlighting added. Supports bash and plain modes.\n * Colors use Juno's design system tokens.\n */import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState}from\"react\";// ─── Bash tokenizer ──────────────────────────────────────────────────────────\nconst BASH_COMMANDS=new Set([\"curl\",\"grep\",\"cut\",\"bash\",\"sed\",\"awk\",\"sort\",\"uniq\",\"head\",\"tail\",\"cat\",\"echo\",\"export\",\"cd\",\"ls\",\"find\",\"xargs\",\"wc\",\"tr\",\"tee\",\"sh\",\"python\",\"python3\",\"pip\",\"npm\",\"yarn\",\"node\",\"helm\",\"kubectl\",\"docker\",\"git\",\"make\",\"sudo\",\"chmod\",\"chown\",\"mkdir\",\"rm\",\"cp\",\"mv\",\"which\",\"source\",\"env\",\"read\",\"printf\",\"test\",\"true\",\"false\",\"set\",\"unset\",\"exec\",\"eval\",\"ssh\",\"scp\"]);const T={command:\"rgb(52, 213, 131)\",flag:\"rgb(154, 154, 163)\",url:\"rgb(147, 197, 253)\",operator:\"rgb(244, 166, 29)\",string:\"rgb(56, 189, 248)\",number:\"rgb(244, 166, 29)\",plain:\"rgb(201, 201, 207)\"};function tokenizeBash(input){const tokens=[];let i=0;const s=input;while(i<s.length){// Single-quoted string: consume up to (and including) next '\nif(s[i]===\"'\"){let j=i+1;while(j<s.length&&s[j]!==\"'\")j++;if(j<s.length)j++;tokens.push({value:s.slice(i,j),color:T.string});i=j;continue;}// URL — must check before word scanner\nconst urlM=s.slice(i).match(/^https?:\\/\\/[^\\s\"')]+/);if(urlM){tokens.push({value:urlM[0],color:T.url});i+=urlM[0].length;continue;}// $( subshell opener\nif(s[i]===\"$\"&&s[i+1]===\"(\"){tokens.push({value:\"$(\",color:T.operator});i+=2;continue;}// ) closing paren\nif(s[i]===\")\"){tokens.push({value:\")\",color:T.operator});i++;continue;}// Pipe or || \nif(s[i]===\"|\"){const v=s[i+1]===\"|\"?\"||\":\"|\";tokens.push({value:v,color:T.operator});i+=v.length;continue;}// &&\nif(s[i]===\"&\"&&s[i+1]===\"&\"){tokens.push({value:\"&&\",color:T.operator});i+=2;continue;}// >> or >\nif(s[i]===\">\"){const v=s[i+1]===\">\"?\">>\":\">\";tokens.push({value:v,color:T.operator});i+=v.length;continue;}// Flag: - or -- followed by a letter\nif(s[i]===\"-\"&&i+1<s.length&&/[a-zA-Z-]/.test(s[i+1])){const flagM=s.slice(i).match(/^-{1,2}[a-zA-Z][-\\w]*/);if(flagM){tokens.push({value:flagM[0],color:T.flag});i+=flagM[0].length;continue;}}// Word (command or plain identifier — allow hyphens for slug-style names)\nif(/[a-zA-Z_]/.test(s[i])){const wordM=s.slice(i).match(/^[a-zA-Z_][a-zA-Z0-9_./-]*/);if(wordM){const word=wordM[0];const color=BASH_COMMANDS.has(word)?T.command:T.plain;tokens.push({value:word,color});i+=word.length;continue;}}// Standalone number (preceded by whitespace, pipe, or paren)\nif(/\\d/.test(s[i])){const prev=i===0?\" \":s[i-1];if(/[\\s|&(]/.test(prev)){const numM=s.slice(i).match(/^\\d+/);if(numM){tokens.push({value:numM[0],color:T.number});i+=numM[0].length;continue;}}}// Horizontal whitespace — preserve as plain\nif(/[ \\t]/.test(s[i])){let j=i;while(j<s.length&&/[ \\t]/.test(s[j]))j++;tokens.push({value:s.slice(i,j),color:T.plain});i=j;continue;}// Newline\nif(s[i]===\"\\n\"){tokens.push({value:\"\\n\",color:T.plain});i++;continue;}// Everything else: single character, plain\ntokens.push({value:s[i],color:T.plain});i++;}return tokens;}export default function CopyCodeButton({code=\"\",language=\"bash\",showPrompt=false,style}){const[copied,setCopied]=useState(false);const handleCopy=async()=>{try{await navigator.clipboard.writeText(code);}catch{const el=document.createElement(\"textarea\");el.value=code;el.style.position=\"fixed\";el.style.opacity=\"0\";document.body.appendChild(el);el.focus();el.select();document.execCommand(\"copy\");document.body.removeChild(el);}setCopied(true);setTimeout(()=>setCopied(false),2e3);};const tokens=language===\"bash\"?tokenizeBash(code):[];return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",backgroundColor:\"rgb(14, 14, 16)\",borderRadius:\"12px\",border:\"1px solid rgb(46, 46, 51)\",padding:\"20px 24px\",width:\"100%\",boxSizing:\"border-box\",...style},children:[/*#__PURE__*/_jsx(\"button\",{onClick:handleCopy,style:{position:\"absolute\",top:\"12px\",right:\"12px\",fontFamily:\"'Montserrat', sans-serif\",fontSize:\"11px\",fontWeight:600,letterSpacing:\"0.04em\",color:copied?\"rgb(52, 213, 131)\":\"rgb(154, 154, 163)\",backgroundColor:copied?\"rgba(52, 213, 131, 0.08)\":\"rgba(154, 154, 163, 0.08)\",border:`1px solid ${copied?\"rgba(52, 213, 131, 0.25)\":\"rgba(154, 154, 163, 0.2)\"}`,borderRadius:\"5px\",padding:\"4px 10px\",cursor:\"pointer\",transition:\"all 0.15s ease\",outline:\"none\",userSelect:\"none\"},\"aria-label\":\"Copy code\",children:copied?\"✓ Copied\":\"Copy\"}),/*#__PURE__*/_jsxs(\"pre\",{style:{margin:0,paddingRight:\"64px\",fontFamily:\"'SF Mono', 'Fira Code', 'Roboto Mono', monospace\",fontSize:\"13px\",lineHeight:\"1.65\",whiteSpace:\"pre-wrap\",wordBreak:\"break-all\",overflowWrap:\"break-word\"},children:[showPrompt&&/*#__PURE__*/_jsx(\"span\",{style:{color:\"rgb(244, 166, 29)\",userSelect:\"none\",marginRight:\"8px\"},children:\"$\"}),language===\"bash\"&&tokens.length>0?tokens.map((tk,idx)=>/*#__PURE__*/_jsx(\"span\",{style:{color:tk.color},children:tk.value},idx)):/*#__PURE__*/_jsx(\"span\",{style:{color:\"rgb(201, 201, 207)\"},children:code})]})]});}addPropertyControls(CopyCodeButton,{code:{type:ControlType.String,title:\"Code\",displayTextArea:true,defaultValue:'curl -sL \"$(curl -s https://api.github.com/repos/juno-fx/Juno-Bootstrap/releases/latest | grep browser_download_url | grep orion-install-helper | cut -d \\'\"\\' -f 4)\" | bash -'},language:{type:ControlType.Enum,title:\"Language\",options:[\"bash\",\"plain\"],optionTitles:[\"Bash / Shell\",\"Plain text\"],defaultValue:\"bash\"},showPrompt:{type:ControlType.Boolean,title:\"Show $ prompt\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CopyCodeButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CopyCodeButton.map"],"mappings":"+LAMolB,SAAS,EAAa,EAAM,CAAC,IAAM,EAAO,EAAE,CAAK,EAAE,EAAQ,EAAE,EAAM,KAAM,EAAE,EAAE,QAAO,CACxqB,GAAG,EAAE,KAAK,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,KAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,KAAI,IAAO,EAAE,EAAE,QAAO,IAAI,EAAO,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,SACjI,IAAM,EAAK,EAAE,MAAM,EAAE,CAAC,MAAM,wBAAwB,CAAC,GAAG,EAAK,CAAC,EAAO,KAAK,CAAC,MAAM,EAAK,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,EAAK,GAAG,OAAO,SACzH,GAAG,EAAE,KAAK,KAAK,EAAE,EAAE,KAAK,IAAI,CAAC,EAAO,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,EAAE,SAC7E,GAAG,EAAE,KAAK,IAAI,CAAC,EAAO,KAAK,CAAC,MAAM,IAAI,MAAM,EAAE,SAAS,CAAC,CAAC,IAAI,SAC7D,G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