{"version":3,"file":"ReadingTimeMulti.CQFJOIeC.mjs","names":["Children","isValidElement","useMemo","_jsx","__esmMin","init_npm_react_18_3_1","j","pe","init_jsx_runtime","K","c","addPropertyControls","init_framer_B3LLf74D","ControlType","readTree","node","out","child","type","isBlock","BLOCK_TAGS","countText","input","unspaced","UNSPACED_SCRIPT","chars","word","ReadingTimeMulti","props","richText","label","font","color","style","words","parts","minutes","WORDS_PER_MINUTE","CHARS_PER_MINUTE","output","init_ReadingTimeMulti","[\n\t\t\t\"address\",\n\t\t\t\"article\",\n\t\t\t\"aside\",\n\t\t\t\"blockquote\",\n\t\t\t\"br\",\n\t\t\t\"dd\",\n\t\t\t\"div\",\n\t\t\t\"dl\",\n\t\t\t\"dt\",\n\t\t\t\"fieldset\",\n\t\t\t\"figcaption\",\n\t\t\t\"figure\",\n\t\t\t\"footer\",\n\t\t\t\"form\",\n\t\t\t\"h1\",\n\t\t\t\"h2\",\n\t\t\t\"h3\",\n\t\t\t\"h4\",\n\t\t\t\"h5\",\n\t\t\t\"h6\",\n\t\t\t\"header\",\n\t\t\t\"hr\",\n\t\t\t\"li\",\n\t\t\t\"main\",\n\t\t\t\"nav\",\n\t\t\t\"ol\",\n\t\t\t\"p\",\n\t\t\t\"pre\",\n\t\t\t\"section\",\n\t\t\t\"table\",\n\t\t\t\"td\",\n\t\t\t\"th\",\n\t\t\t\"tr\",\n\t\t\t\"ul\"\n\t\t]"],"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,SAASc,EAASC,EAAKC,EAAI,CAAChB,EAAS,QAAQe,EAAKE,GAAO,CAAC,GAAGA,GAAQ,MAAyB,OAAOA,GAAQ,UAAU,OAAO,GAAG,OAAOA,GAAQ,UAAU,OAAOA,GAAQ,SAAS,CAACD,EAAI,KAAK,OAAOC,CAAK,CAAC,EAAE,MAAO,CAAC,GAAG,CAAchB,gBAAegB,CAAK,EAAE,OAAO,IAAMC,EAAKD,EAAM,KAAWE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