{"version":3,"file":"TextWrap.CUGoJoXb.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/zpdu5C9A7gbGZnFMVUHi/VXdj2KHLmL3dsu0Yfd09/TextWrap.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */function escapeRegex(value){return value.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");}function getSlotRegex(wrapper){const mid=Math.floor(wrapper.length/2);const start=wrapper.slice(0,mid);const end=wrapper.slice(mid);return new RegExp(`${escapeRegex(start)}${escapeRegex(end)}`,\"g\");}function normalizeChildren(children){if(!children)return[];return Array.isArray(children)?children:[children];}function parseText({text,slotWrapper,slots,gap}){const parts=[];const regex=getSlotRegex(slotWrapper);let lastIndex=0;let match;let slotIndex=0;const mid=Math.floor(slotWrapper.length/2);const start=slotWrapper.slice(0,mid);const end=slotWrapper.slice(mid);while((match=regex.exec(text))!==null){if(match.index>lastIndex){parts.push(/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre-wrap\"},children:text.slice(lastIndex,match.index)},`text-${lastIndex}`));}const content=slots[slotIndex];parts.push(/*#__PURE__*/_jsx(\"span\",{style:{display:content?\"inline-block\":\"inline\",verticalAlign:\"baseline\",paddingInline:gap/2,color:content?undefined:\"currentColor\",opacity:content?undefined:.35},children:content??`${start}${end}`},`slot-${slotIndex}`));slotIndex+=1;lastIndex=match.index+match[0].length;}if(lastIndex<text.length){parts.push(/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre-wrap\"},children:text.slice(lastIndex)},`text-${lastIndex}`));}return parts;}export default function TextWrap(props){const{text,slotWrapper=\"[]\",tag=\"div\",textColor,font,gap,textAlign,children,style}=props;const Tag=tag;const isInline=tag===\"span\";const elements=useMemo(()=>{return parseText({text,slotWrapper,slots:normalizeChildren(children),gap});},[text,slotWrapper,children,gap]);return /*#__PURE__*/_jsx(Tag,{style:{...style,margin:0,padding:0,display:isInline?\"inline\":\"block\",position:\"relative\",width:style?.width===\"100%\"?\"100%\":\"auto\",color:textColor,textAlign,overflowWrap:\"break-word\",wordWrap:\"break-word\",...font},children:elements});}addPropertyControls(TextWrap,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is some text with [] and [] placeholders.\",displayTextArea:true},slotWrapper:{type:ControlType.String,title:\"Slot Marker\",defaultValue:\"[]\"},children:{type:ControlType.Array,title:\"Slots\",control:{type:ControlType.ComponentInstance},maxCount:10},tag:{type:ControlType.Enum,title:\"HTML Tag\",options:[\"div\",\"p\",\"span\",\"h1\",\"h2\",\"h3\",\"h4\"],optionTitles:[\"Div\",\"Paragraph\",\"Span\",\"H1\",\"H2\",\"H3\",\"H4\"],defaultValue:\"div\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],displaySegmentedControl:true},gap:{type:ControlType.Number,title:\"Slot Gap\",defaultValue:4,min:0,max:100,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextWrap\",\"slots\":[\"children\"],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextWrap.map"],"mappings":"0KAGG,SAAS,EAAY,EAAM,CAAC,OAAO,EAAM,QAAQ,sBAAsB,OAAO,CAAE,SAAS,EAAa,EAAQ,CAAC,IAAM,EAAI,KAAK,MAAM,EAAQ,OAAO,EAAE,CAAO,EAAM,EAAQ,MAAM,EAAE,EAAI,CAAO,EAAI,EAAQ,MAAM,EAAI,CAAC,OAAW,OAAO,GAAG,EAAY,EAAM,GAAG,EAAY,EAAI,GAAG,IAAI,CAAE,SAAS,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