{"version":3,"file":"Copycode.CT1kdGAi.mjs","names":["useState","Check"],"sources":["https:/framerusercontent.com/modules/HzfviUtZNSSRvydcZ9iQ/Sw1PA6aqTUqcVuJg34Zr/Copycode.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{Check}from\"lucide-react\";function clamp(n,min,max){return Math.min(Math.max(n,min),max);}/**\n * FIX for Framer publish:\n * Framer can output colors as #RRGGBB, #RGB, **#RRGGBBAA**, rgb(), rgba(), or \"transparent\".\n * Your previous hexToRgba() only handled #RGB/#RRGGBB and fell back to black on publish.\n */function colorWithOpacity(input,opacity){const a=clamp(opacity??1,0,1);if(!input)return`rgba(0,0,0,${a})`;const c=String(input).trim();if(c===\"transparent\")return`rgba(0,0,0,0)`;// rgba(r,g,b,a) -> replace alpha with slider alpha\nconst rgbaMatch=c.match(/^rgba\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*\\)$/i);if(rgbaMatch){const r=Number(rgbaMatch[1]);const g=Number(rgbaMatch[2]);const b=Number(rgbaMatch[3]);return`rgba(${r}, ${g}, ${b}, ${a})`;}// rgb(r,g,b) -> add alpha\nconst rgbMatch=c.match(/^rgb\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*\\)$/i);if(rgbMatch){const r=Number(rgbMatch[1]);const g=Number(rgbMatch[2]);const b=Number(rgbMatch[3]);return`rgba(${r}, ${g}, ${b}, ${a})`;}// hex formats\nlet h=c.replace(\"#\",\"\").trim();// #RGB -> #RRGGBB\nif(h.length===3){h=h.split(\"\").map(ch=>ch+ch).join(\"\");}// #RRGGBBAA (alpha in hex)\nif(h.length===8){const r=parseInt(h.slice(0,2),16);const g=parseInt(h.slice(2,4),16);const b=parseInt(h.slice(4,6),16);const alphaFromHex=parseInt(h.slice(6,8),16)/255;const finalA=clamp(alphaFromHex*a,0,1);return`rgba(${r}, ${g}, ${b}, ${finalA})`;}// #RRGGBB\nif(h.length===6){const r=parseInt(h.slice(0,2),16);const g=parseInt(h.slice(2,4),16);const b=parseInt(h.slice(4,6),16);return`rgba(${r}, ${g}, ${b}, ${a})`;}// last resort (named colors etc.)\nreturn c;}export default function CopyCodeButton(props){const[copied,setCopied]=useState(false);const[showConfirmation,setShowConfirmation]=useState(false);const[progress,setProgress]=useState(0);const code=props.codeText;const successMessage=props.successText;const duration=props.duration;const{fontFamily:codeFontFamily=\"Inter\",fontSize:codeFontSize=\"24px\",fontWeight:codeFontWeight=500,fontStyle:codeFontStyle=\"normal\"}=props.font;const{fontFamily:btnFontFamily=\"Inter\",fontSize:btnFontSize=\"16px\",fontWeight:btnFontWeight=600,fontStyle:btnFontStyle=\"normal\"}=props.buttonFont;const{fontFamily:successFontFamily=\"Inter\",fontSize:successFontSize=\"20px\",fontWeight:successFontWeight=600,fontStyle:successFontStyle=\"normal\"}=props.successFont;useEffect(()=>{if(!copied)return;const showTimer=setTimeout(()=>setShowConfirmation(true),400);setProgress(0);const startTime=Date.now();const interval=setInterval(()=>{const elapsed=Date.now()-startTime;const newProgress=Math.min(elapsed/duration*100,100);setProgress(newProgress);if(elapsed>=duration){clearInterval(interval);setShowConfirmation(false);setTimeout(()=>{setCopied(false);setProgress(0);},400);}},16);return()=>{clearInterval(interval);clearTimeout(showTimer);};},[copied,duration]);const handleCopy=async()=>{try{await navigator.clipboard.writeText(code);}catch(err){const textArea=document.createElement(\"textarea\");textArea.value=code;textArea.style.position=\"fixed\";textArea.style.left=\"-9999px\";textArea.style.top=\"-9999px\";document.body.appendChild(textArea);textArea.focus();textArea.select();document.execCommand(\"Copy\");document.body.removeChild(textArea);}setCopied(true);};// --- Editable colors (Framer controls) ---\n// CHANGED: hexToRgba -> colorWithOpacity (handles #RRGGBBAA on publish)\nconst colors={pillBg:colorWithOpacity(props.pillBgColor,props.pillBgOpacity),progressBg:colorWithOpacity(props.progressBgColor,props.progressBgOpacity),codeText:props.codeTextColor,buttonBg:colorWithOpacity(props.buttonBgColor,props.buttonBgOpacity),buttonText:props.buttonTextColor,buttonHover:colorWithOpacity(props.buttonHoverBgColor,props.buttonHoverBgOpacity),successGreen:props.successColor};// --- Styles ---\nconst containerStyle={display:\"flex\",alignItems:\"center\",justifyContent:\"center\",height:\"100%\",width:\"100%\",backgroundColor:\"transparent\",padding:\"16px\"};const pillStyle={position:\"relative\",overflow:\"hidden\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor:colors.pillBg,borderRadius:\"9999px\",minWidth:\"170px\",height:\"40px\",padding:\"0 40px\"};const progressStyle={position:\"absolute\",left:0,top:0,bottom:0,backgroundColor:colors.progressBg,width:`${progress}%`,opacity:copied?1:0,transition:\"opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1)\"};const contentStyle={position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"space-between\",paddingLeft:\"20px\",paddingRight:\"5px\",opacity:copied?0:1,filter:copied?\"blur(12px)\":\"blur(0px)\",transform:copied?\"scale(0.92)\":\"scale(1)\",transition:\"all 0.5s cubic-bezier(0.4, 0, 0.2, 1)\",pointerEvents:copied?\"none\":\"auto\",zIndex:copied?0:20};const buttonStyle={backgroundColor:colors.buttonBg,color:colors.buttonText,border:\"none\",fontFamily:btnFontFamily,fontSize:btnFontSize,fontWeight:btnFontWeight,fontStyle:btnFontStyle,padding:\"5px 20px\",borderRadius:\"9999px\",cursor:\"pointer\",boxShadow:\"0 1px 2px rgba(0,0,0,0.08)\",transition:\"all 0.3s ease\"};const confirmationStyle={position:\"relative\",display:\"flex\",alignItems:\"center\",gap:\"10px\",opacity:showConfirmation?1:0,filter:showConfirmation?\"blur(0px)\":\"blur(12px)\",transform:showConfirmation?\"scale(1)\":\"scale(1.08)\",transition:\"all 0.8s cubic-bezier(0.4, 0, 0.2, 1)\",pointerEvents:\"none\",zIndex:10};return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:pillStyle,children:[/*#__PURE__*/_jsx(\"div\",{style:progressStyle}),/*#__PURE__*/_jsxs(\"div\",{style:contentStyle,children:[/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:codeFontFamily,fontSize:codeFontSize,fontWeight:codeFontWeight,fontStyle:codeFontStyle,letterSpacing:\"0.025em\",color:colors.codeText,userSelect:\"all\",whiteSpace:\"nowrap\",overflow:\"hidden\",textOverflow:\"ellipsis\",maxWidth:\"192px\"},children:code}),/*#__PURE__*/_jsx(\"button\",{onClick:handleCopy,style:buttonStyle,onMouseEnter:e=>{e.currentTarget.style.backgroundColor=colors.buttonHover;},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=colors.buttonBg;},children:\"Kopiuj\"})]}),/*#__PURE__*/_jsxs(\"div\",{style:confirmationStyle,children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"28px\",height:\"28px\",backgroundColor:colors.successGreen,borderRadius:\"9999px\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",flexShrink:0},children:/*#__PURE__*/_jsx(Check,{size:16,color:\"#ffffff\"})}),/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:successFontFamily,fontSize:successFontSize,fontWeight:successFontWeight,fontStyle:successFontStyle,color:colors.successGreen,whiteSpace:\"nowrap\"},children:successMessage})]})]})});}addPropertyControls(CopyCodeButton,{codeText:{type:ControlType.String,title:\"Content\",defaultValue:\"21DEV-LEO\"},successText:{type:ControlType.String,title:\"Success Text\",defaultValue:\"Code Copied!\"},font:{type:ControlType.Font,title:\"Content Font\",defaultValue:{fontSize:\"24px\",fontWeight:500},controls:\"extended\"},buttonFont:{type:ControlType.Font,title:\"Button Font\",defaultValue:{fontSize:\"16px\",fontWeight:600},controls:\"extended\"},successFont:{type:ControlType.Font,title:\"Success Font\",defaultValue:{fontSize:\"20px\",fontWeight:600},controls:\"extended\"},duration:{type:ControlType.Number,title:\"Duration (ms)\",defaultValue:4e3,min:1e3,max:1e4,step:500},pillBgColor:{type:ControlType.Color,title:\"Pill BG\",defaultValue:\"#f3f4f6\"},pillBgOpacity:{type:ControlType.Number,title:\"Pill BG Op\",defaultValue:1,min:0,max:1,step:.05},progressBgColor:{type:ControlType.Color,title:\"Progress BG\",defaultValue:\"#e5e7eb\"},progressBgOpacity:{type:ControlType.Number,title:\"Progress Op\",defaultValue:1,min:0,max:1,step:.05},codeTextColor:{type:ControlType.Color,title:\"Code Text\",defaultValue:\"#9ca3af\"},buttonBgColor:{type:ControlType.Color,title:\"Btn BG\",defaultValue:\"#ffffff\"},buttonBgOpacity:{type:ControlType.Number,title:\"Btn BG Op\",defaultValue:1,min:0,max:1,step:.05},buttonHoverBgColor:{type:ControlType.Color,title:\"Btn Hover\",defaultValue:\"#f9fafb\"},buttonHoverBgOpacity:{type:ControlType.Number,title:\"Hover Op\",defaultValue:1,min:0,max:1,step:.05},buttonTextColor:{type:ControlType.Color,title:\"Btn Text\",defaultValue:\"#374151\"},successColor:{type:ControlType.Color,title:\"Success\",defaultValue:\"#22c55e\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CopyCodeButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Copycode.map"],"mappings":"6PAAmL,SAAS,EAAM,EAAE,EAAI,EAAI,CAAC,OAAO,KAAK,IAAI,KAAK,IAAI,EAAE,CAAG,EAAE,CAAG,CAAE,CAI/O,SAAS,EAAiB,EAAM,EAAQ,CAAC,IAAM,EAAE,EAAM,GAAS,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,EAAM,MAAM,cAAc,EAAE,GAAG,IAAM,EAAE,OAAO,CAAK,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,cAAc,MAAM,gBACrK,IAAM,EAAU,EAAE,MAAM,wEAAwE,EAAE,GAAG,EAAkG,MAAM,Q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