{"version":3,"file":"TextWrap.CiT3VMDx.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/5HTFXfbRIQdu7EyKmBG3/iP5Kq8KIpqg0QTlfhRXz/TextWrap.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}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,subtext,slotWrapper=\"[]\",tag=\"div\",textColor,subtextColor,font,gap,subtextGap,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__*/_jsxs(\"div\",{style:{...style,margin:0,padding:0,position:\"relative\",width:style?.width===\"100%\"?\"100%\":\"auto\",display:\"flex\",flexDirection:\"column\",gap:subtext?subtextGap:0},children:[/*#__PURE__*/_jsx(Tag,{style:{margin:0,padding:0,display:isInline?\"inline\":\"block\",color:textColor,textAlign,overflowWrap:\"break-word\",wordWrap:\"break-word\",...font},children:elements}),subtext?/*#__PURE__*/_jsx(\"div\",{style:{margin:0,padding:0,color:subtextColor,textAlign,overflowWrap:\"break-word\",wordWrap:\"break-word\",whiteSpace:\"pre-wrap\",...font},children:subtext}):null]});}addPropertyControls(TextWrap,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is some text with [] and [] placeholders.\",displayTextArea:true},subtext:{type:ControlType.String,title:\"Subtext\",defaultValue:\"\",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\"},subtextColor:{type:ControlType.Color,title:\"Subtext 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,defaultValue:\"left\"},subtextGap:{type:ControlType.Number,title:\"Subtext Gap\",defaultValue:8,min:0,max:100,step:1,unit:\"px\"},gap:{type:ControlType.Number,title:\"Slot Gap\",defaultValue:4,min:0,max:100,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"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