{"version":3,"file":"CodeBlock.B8JMWI04.mjs","names":["useMemo","useState"],"sources":["https:/framerusercontent.com/modules/i9OGPfT8N1246IydPzZ5/3Qou0mwGs2xHo8jXwnWs/CodeBlock.js"],"sourcesContent":["// Code Block component that displays code lines like an editor, with configurable content, background, text color, font, and optional line numbers. Ensures code fits inside the block and text wraps as needed.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo,useState,useEffect,startTransition}from\"react\";/**\n * Code Block\n *\n * @framerIntrinsicWidth 500\n * @framerIntrinsicHeight 200\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CodeBlock(props){const{code,showLineNumbers,background,textColor,font,borderRadius,style,typewriterEffect,typingSpeed}=props;const lines=useMemo(()=>code.split(\"\\n\"),[code]);const[displayedLines,setDisplayedLines]=useState([]);const[currentLineIndex,setCurrentLineIndex]=useState(0);const[currentCharIndex,setCurrentCharIndex]=useState(0);// Reset typewriter when code changes\nuseEffect(()=>{if(typewriterEffect){startTransition(()=>{setDisplayedLines([]);setCurrentLineIndex(0);setCurrentCharIndex(0);});}else{startTransition(()=>{setDisplayedLines(lines);});}},[code,typewriterEffect,lines]);// Typewriter effect\nuseEffect(()=>{if(!typewriterEffect||currentLineIndex>=lines.length){return;}const currentLine=lines[currentLineIndex];if(currentCharIndex<currentLine.length){const timer=setTimeout(()=>{startTransition(()=>{setDisplayedLines(prev=>{const newLines=[...prev];newLines[currentLineIndex]=currentLine.slice(0,currentCharIndex+1);return newLines;});setCurrentCharIndex(prev=>prev+1);});},typingSpeed);return()=>clearTimeout(timer);}else{// Current line is complete, move to next line\nconst timer=setTimeout(()=>{startTransition(()=>{setCurrentLineIndex(prev=>prev+1);setCurrentCharIndex(0);});},typingSpeed*3)// Pause between lines\n;return()=>clearTimeout(timer);}},[typewriterEffect,currentLineIndex,currentCharIndex,lines,typingSpeed]);const linesToDisplay=typewriterEffect?displayedLines:lines;// Safe syntax highlighting using React elements\nfunction highlightLine(line){// Add safety check for undefined line\nif(!line)return[];const hashIdx=line.indexOf(\"#\");const codePart=hashIdx===-1?line:line.slice(0,hashIdx);const commentPart=hashIdx===-1?\"\":line.slice(hashIdx);const elements=[];// Process code part\nif(codePart){const tokens=tokenize(codePart);elements.push(...tokens);}// Process comment part\nif(commentPart){elements.push(/*#__PURE__*/_jsx(\"span\",{style:{color:props.commentColor},children:commentPart},\"comment\"));}return elements;}function tokenize(text){const elements=[];let remaining=text;let keyCounter=0;while(remaining.length>0){// Check for URLs\nconst urlMatch=remaining.match(/^(https?:\\/\\/[^\\s\"']+)/);if(urlMatch){elements.push(/*#__PURE__*/_jsx(\"span\",{style:{color:props.urlColor},children:urlMatch[1]},`url-${keyCounter++}`));remaining=remaining.slice(urlMatch[1].length);continue;}// Check for numbers\nconst numberMatch=remaining.match(/^(\\d+(?:\\.\\d+)?)/);if(numberMatch){elements.push(/*#__PURE__*/_jsx(\"span\",{style:{color:props.urlColor},children:numberMatch[1]},`number-${keyCounter++}`));remaining=remaining.slice(numberMatch[1].length);continue;}// Check for keywords\nconst keywordMatch=remaining.match(/^(import|from|def|class|return|if|else|elif|for|while|in|with|as|try|except|finally|pass|break|continue|True|False|None|print|model|config|summary|client|nn|Sequential|ReLU|Conv2d|compile|Configuration|api_host|api_token|compilation_target|optimize_backward_pass|NVIDIA_A100|optimized_model)\\b/);if(keywordMatch){elements.push(/*#__PURE__*/_jsx(\"span\",{style:{color:props.keywordColor},children:keywordMatch[1]},`keyword-${keyCounter++}`));remaining=remaining.slice(keywordMatch[1].length);continue;}// No match, take one character\nelements.push(remaining[0]);remaining=remaining.slice(1);}return elements;}return /*#__PURE__*/_jsxs(\"div\",{style:{...style,background,color:textColor,borderRadius,padding:20,margin:0,overflow:\"auto\",fontFamily:font.fontFamily,fontSize:font.fontSize,fontWeight:font.fontWeight,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,fontStyle:font.fontStyle,minHeight:80,width:\"100%\",height:\"100%\",boxSizing:\"border-box\",display:\"flex\",flexDirection:\"column\",justifyContent:\"flex-start\",boxShadow:props.shadow?\"0 4px 16px 0 rgba(0,0,0,0.12)\":\"none\",border:`1.5px solid ${props.borderColor}`},\"aria-label\":\"Code block\",children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",overflow:\"auto\"},children:linesToDisplay.map((line,idx)=>/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",width:\"100%\"},children:[showLineNumbers&&/*#__PURE__*/_jsx(\"span\",{style:{userSelect:\"none\",color:\"#999\",minWidth:32,textAlign:\"right\",marginRight:16,opacity:.7,fontVariantNumeric:\"tabular-nums\"},\"aria-hidden\":\"true\",children:idx+1}),/*#__PURE__*/_jsxs(\"div\",{style:{whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",flex:1},children:[highlightLine(line),typewriterEffect&&idx===currentLineIndex&&currentCharIndex<lines[currentLineIndex]?.length&&/*#__PURE__*/_jsx(\"span\",{style:{animation:\"blink 1s infinite\"},children:\"|\"})]})]},idx))}),typewriterEffect&&/*#__PURE__*/_jsx(\"style\",{children:`\n                        @keyframes blink {\n                            0%, 50% { opacity: 1; }\n                            51%, 100% { opacity: 0; }\n                        }\n                    `})]});}addPropertyControls(CodeBlock,{code:{type:ControlType.String,title:\"Code\",defaultValue:\"function hello() {\\n  console.log('Hello, world!')\\n}\",displayTextArea:true},typewriterEffect:{type:ControlType.Boolean,title:\"Typewriter Effect\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},typingSpeed:{type:ControlType.Number,title:\"Typing Speed\",defaultValue:50,min:10,max:200,step:10,unit:\"ms\",hidden:({typewriterEffect})=>!typewriterEffect},showLineNumbers:{type:ControlType.Boolean,title:\"Line Numbers\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#1e1e1e\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#d4d4d4\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"monospace\",defaultValue:{fontSize:\"15px\",lineHeight:\"1.5em\",letterSpacing:\"0em\"},displayFontSize:true},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:32},shadow:{type:ControlType.Boolean,title:\"Shadow\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#333\"},urlColor:{type:ControlType.Color,title:\"URL/Number Color\",defaultValue:\"#6ca4f8\"},keywordColor:{type:ControlType.Color,title:\"Keyword Color\",defaultValue:\"#e055a0\"},commentColor:{type:ControlType.Color,title:\"Comment Color\",defaultValue:\"#fff\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CodeBlock\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"500\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CodeBlock.map"],"mappings":"gSASG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,OAAK,kBAAgB,aAAW,YAAU,OAAK,eAAa,QAAM,mBAAiB,eAAa,EAAY,EAAMA,MAAY,EAAK,MAAM;EAAK,CAAC,CAAC,EAAK,CAAC,CAAM,CAAC,EAAe,GAAmBC,EAAS,EAAE,CAAC,CAAM,CAAC,EAAiB,GAAqBA,EAAS,EAAE,CAAM,CAAC,EAAiB,GAAqBA,EAAS,EAAE,CAC7W,MAAc,CAAsB,EAAlB,MAAsC,CAAC,EAAkB,EAAE,CAAC,CAAC,EAAoB,EAAE,CAAC,EAAoB,EAAE,MAA8B,CAAC,EAAkB,EAAM,EAAG,EAAI,CAAC,EAAK,EAAiB,EAA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