{"version":3,"file":"TextReplacements.CCfbqaLF.mjs","names":["React"],"sources":["https:/framerusercontent.com/modules/DbqFMbrH5QNojgFqPqC0/xv47Y78rLcQTOFw3iFMH/TextReplacements.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function TextReplacements(props){const{originalText,font,textColor,text1,text2,text3,text4,text5,date,time,boldReplacements}=props;// Format time in seconds to appropriate unit (pt-BR)\nconst formatTime=seconds=>{if(seconds<60){// Show in seconds\nreturn`${Math.round(seconds)} segundo${seconds!==1?\"s\":\"\"}`;}else if(seconds<3600){// Show in minutes\nconst minutes=Math.round(seconds/60);return`${minutes} minuto${minutes!==1?\"s\":\"\"}`;}else if(seconds<86400){// Show in hours\nconst hours=Math.round(seconds/3600);return`${hours} hora${hours!==1?\"s\":\"\"}`;}else{// Show in days\nconst days=Math.round(seconds/86400);return`${days} dia${days!==1?\"s\":\"\"}`;}};// Format date to pt-BR\nconst formatDate=dateString=>{if(!dateString)return\"\";const dateObj=new Date(dateString);return dateObj.toLocaleDateString(\"pt-BR\",{day:\"2-digit\",month:\"2-digit\",year:\"numeric\"});};// Process the text by replacing placeholders with actual values\nconst getProcessedText=()=>{if(!originalText)return null;// Define replacements\nconst replacements={\"[text1]\":text1||\"\",\"[text2]\":text2||\"\",\"[text3]\":text3||\"\",\"[text4]\":text4||\"\",\"[text5]\":text5||\"\",\"[date]\":date?formatDate(date):\"\",\"[time]\":time!==undefined?formatTime(time):\"\"};// If bold is not enabled, just do simple replacement\nif(!boldReplacements){let processedText=originalText;Object.entries(replacements).forEach(([placeholder,replacement])=>{processedText=processedText.split(placeholder).join(replacement);});return processedText;}// Split text into parts and mark which are replacements\nlet parts=[{text:originalText,isReplacement:false}];Object.entries(replacements).forEach(([placeholder,replacement])=>{if(!replacement)return;// Skip empty replacements\nconst newParts=[];parts.forEach(part=>{if(part.isReplacement){newParts.push(part);}else{const segments=part.text.split(placeholder);segments.forEach((segment,index)=>{if(segment){newParts.push({text:segment,isReplacement:false});}if(index<segments.length-1){newParts.push({text:replacement,isReplacement:true});}});}});parts=newParts;});// Render parts with bold for replacements\nreturn parts.map((part,index)=>part.isReplacement?/*#__PURE__*/_jsx(\"strong\",{children:part.text},index):/*#__PURE__*/_jsx(React.Fragment,{children:part.text},index));};const finalText=getProcessedText();return /*#__PURE__*/_jsx(\"div\",{style:{...font,color:textColor,whiteSpace:\"pre-wrap\",...props.style},children:finalText});}TextReplacements.displayName=\"Text Replacements\";TextReplacements.defaultProps={boldReplacements:false};addPropertyControls(TextReplacements,{originalText:{type:ControlType.String,title:\"Original Text\",defaultValue:\"Hello [text1], welcome to [text2]!\\nData: [date]\\nTempo: [time]\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:16,lineHeight:1.4}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},boldReplacements:{type:ControlType.Boolean,title:\"Bold Replacements\",defaultValue:false},text1:{type:ControlType.String,title:\"Text 1 [text1]\",defaultValue:\"John\"},text2:{type:ControlType.String,title:\"Text 2 [text2]\",defaultValue:\"Framer\"},text3:{type:ControlType.String,title:\"Text 3 [text3]\",defaultValue:\"\"},text4:{type:ControlType.String,title:\"Text 4 [text4]\",defaultValue:\"\"},text5:{type:ControlType.String,title:\"Text 5 [text5]\",defaultValue:\"\"},date:{type:ControlType.Date,title:\"Date [date]\"},time:{type:ControlType.Number,title:\"Time (seconds) [time]\",defaultValue:0,min:0,step:1,displayStepper:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextReplacements\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# s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