{"version":3,"file":"ReadingTimeMulti.DMZ8Bp5m.mjs","names":["useMemo","__esmMin","j","init_npm_react_18_3_1","pe","init_jsx_runtime","K","c","addPropertyControls","init_framer_D1IzEvwH","ControlType","readTree","node","child","out","type","isBlock","BLOCK_TAGS","countText","input","unspaced","UNSPACED_SCRIPT","chars","word","ReadingTimeMulti","props","parts","richText","minutes","words","WORDS_PER_MINUTE","CHARS_PER_MINUTE","output","label","style","font","init_ReadingTimeMulti"],"sources":["https:/framerusercontent.com/modules/JRVVsAc81KXLsba5dQDe/m0bte3ztecoBWJsPyQ4l/ReadingTimeMulti.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{Children,isValidElement,useMemo}from\"react\";// 200 words per minute: the figure blog reading-time plugins settle on, and\n// the one the ReadingTime override on this project already uses. Reading out\n// loud would be ~150, silent reading ~238.\nconst WORDS_PER_MINUTE=200;// Scripts without spaces are counted by character instead of by word.\nconst CHARS_PER_MINUTE=500;const UNSPACED_SCRIPT=/[ᄀ-ᇿ⺀-〾ぁ-㏿㐀-䶿一-鿿豈-﫿︰-﹏ｦ-ﾟ가-힯]/g;// Tags that end a line. Run together, \"<p>six seven</p><p>eight</p>\" would be\n// read as \"six seveneight\", one word short, so block boundaries are put back.\nconst BLOCK_TAGS=new Set([\"address\",\"article\",\"aside\",\"blockquote\",\"br\",\"dd\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"li\",\"main\",\"nav\",\"ol\",\"p\",\"pre\",\"section\",\"table\",\"td\",\"th\",\"tr\",\"ul\"]);// Framer hands the slot over as ordinary React elements — <p dir=\"ltr\">, <h4>,\n// and so on, with the CMS text already resolved in their children. Reading it\n// here, instead of rendering a hidden copy and measuring the DOM, means the\n// article is never emitted: no duplicated markup, and no <a> inside the card's\n// own link, which is what the \"nested link\" publish error was about.\nfunction readTree(node,out){Children.forEach(node,child=>{if(child===null||child===undefined||typeof child===\"boolean\")return;if(typeof child===\"string\"||typeof child===\"number\"){out.push(String(child));return;}if(!/*#__PURE__*/isValidElement(child))return;const type=child.type;const isBlock=typeof type===\"string\"&&BLOCK_TAGS.has(type);if(isBlock)out.push(\"\\n\");readTree((child.props??{}).children,out);if(isBlock)out.push(\"\\n\");});}function countText(input){if(!input)return{words:0,chars:0};const unspaced=input.match(UNSPACED_SCRIPT);const chars=unspaced?unspaced.length:0;const words=input.replace(UNSPACED_SCRIPT,\" \").split(/\\s+/).filter(word=>RegExp(\"[\\\\p{L}\\\\p{N}]\",\"u\").test(word)).length;return{words,chars};}/**\n * Reading Time\n *\n * Counts every layer dropped in the Rich text slot — a text layer bound to a\n * Formatted Text CMS field, for instance — and prints the estimate.\n *\n * @framerIntrinsicWidth 100\n * @framerIntrinsicHeight 20\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function ReadingTimeMulti(props){const{richText,label=\"{time} min read\",font,color=\"#000\",style}=props;const{words,chars}=useMemo(()=>{const parts=[];readTree(richText,parts);return countText(parts.join(\"\"));},[richText]);const minutes=Math.max(1,Math.ceil(words/WORDS_PER_MINUTE+chars/CHARS_PER_MINUTE));const output=label.replace(/\\{time\\}/g,String(minutes)).replace(/\\{words\\}/g,String(words+chars));return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",minWidth:\"max-content\",color,...font},children:output});}addPropertyControls(ReadingTimeMulti,{richText:{type:ControlType.Slot,title:\"Rich text\",description:\"The text layers to count, bound to Formatted Text fields. Counted, never shown. Put the source layer outside the breakpoint frames so every breakpoint can use it.\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"{time} min read\",description:\"{time} is the estimate, {words} the word count.\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"17px\",variant:\"Medium\",letterSpacing:\"0em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ReadingTimeMulti\",\"slots\":[\"richText\"],\"annotations\":{\"framerIntrinsicWidth\":\"100\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"20\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ReadingTimeMulti.map"],"mappings":"A,yLAWA,SAASW,EAAS,EAAK,EAAI,CAACT,EAAS,QAAQU,EAAK,GAAO,CAAC,GAAGC,GAAQ,MAAyB,OAAOA,GAAQ,UAAU,OAAO,GAAG,OAAOA,GAAQ,UAAU,OAAOA,GAAQ,SAAS,CAACC,EAAI,KAAK,OAAOD,CAAK,CAAC,EAAE,MAAO,CAAC,GAAG,CAAc,gBAAeA,CAAK,EAAE,OAAO,IAAME,EAAKF,EAAM,KAAWG,EAAQ,OAAOD,GAAO,UAAUE,EAAW,IAAIF,CAAI,EAAKC,GAAQF,EAAI,KAAK;CAAI,EAAEH,GAAUE,EAAM,OAAO,CAAC,EAAA,CAAG,SAASC,CAAG,EAAKE,GAAQF,EAAI,KAAK;CAAI,CAAE,CAAC,CAAE,CAAC,SAASI,EAAU,EAAM,CAAC,GAAG,CAACC,EAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAMC,EAASD,EAAM,MAAME,CAAe,EAAQC,EAAMF,EAASA,EAAS,OAAO,EAA2H,MAAM,CAAC,MAApHD,EAAM,QAAQE,EAAgB,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,GAAM,OAAO,iBAAiB,GAAG,CAAC,CAAC,KAAKE,CAAI,CAAC,CAAC,CAAC,OAAoB,OAAK,CAAE,CAW5sB,SAAwBC,EAAiB,EAAM,CAAC,GAAK,CAAC,WAAS,QAAM,kBAAkB,OA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