{"version":3,"file":"ReadTime.f0mNuHqw.mjs","names":["useRef","useState","__esmMin","init_npm_react_18_3_1","ce","Ha","init_jsx_runtime","init_npm_react_dom_18_3_1","c","de","_e","addPropertyControls","init_framer_DcGZRLrs","ControlType","imageReadingSeconds","seconds","i","imageCount","calculateReadTime","wordMinutes","wordCount","wpm","imageMinutes","countImages","ReadTime","hiddenRef","setWordCount","setImageCount","frame","cleaned","words","images","content","textStyles","font","hiddenRenderer","MIN_WORD_THRESHOLD","emptyState","style","minutes","wordsPerMinute","suffix","suffixSingular","suffixPlural","label","prefix","parts","separatorBefore","separatorAfter","display","clockIcon","gap","showIcon","init_ReadTime","props"],"sources":["https:/framerusercontent.com/modules/4lwCgmg2AOuONtBkm1K1/dzSbp77XFLJFss5k2AYz/ReadTime.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect,useRef}from\"react\";import{createPortal}from\"react-dom\";/**\n * ReadTime — Framer Code Component\n *\n * Calculates and displays the estimated reading time for article content.\n * Accounts for both word count and image viewing time (Medium's formula).\n *\n * Connect the \"Content\" prop to your CMS Rich Text field.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */// ── helpers ────────────────────────────────────────────────────────────\nfunction imageReadingSeconds(imageCount){let seconds=0;for(let i=0;i<imageCount;i++){seconds+=Math.max(12-i,3);}return seconds;}function calculateReadTime(wordCount,imageCount,wpm,countImages){const wordMinutes=wordCount/wpm;const imageMinutes=countImages?imageReadingSeconds(imageCount)/60:0;return Math.ceil(wordMinutes+imageMinutes);}const MIN_WORD_THRESHOLD=10;export default function ReadTime({content,emptyState=\"Connect content...\",wordsPerMinute=238,countImages=true,prefix=\"\",suffixSingular=\"min read\",suffixPlural=\"min read\",showIcon=false,gap=6,separatorBefore=\"\",separatorAfter=\"\",font,textTransform=\"none\",color=\"#0A0A0A\",style}){const hiddenRef=useRef(null);const[wordCount,setWordCount]=useState(0);const[imageCount,setImageCount]=useState(0);useEffect(()=>{const frame=requestAnimationFrame(()=>{if(hiddenRef.current){const text=hiddenRef.current.textContent||\"\";const cleaned=text.replace(/\\s+/g,\" \").trim();const words=cleaned?cleaned.split(/\\s+/).filter(Boolean).length:0;const images=hiddenRef.current.querySelectorAll(\"img\").length;setWordCount(words);setImageCount(images);}});return()=>cancelAnimationFrame(frame);},[content]);// ── Shared text styles ──\nconst textStyles={...font,textTransform:textTransform,color,whiteSpace:\"nowrap\"};// ── Hidden renderer via portal — rendered into document.body\n//    so it's never nested inside a parent <a> tag ──\nconst hiddenRenderer=typeof document!==\"undefined\"?/*#__PURE__*/createPortal(/*#__PURE__*/_jsx(\"div\",{ref:hiddenRef,\"aria-hidden\":\"true\",style:{position:\"absolute\",width:0,height:0,overflow:\"hidden\",visibility:\"hidden\",pointerEvents:\"none\"},children:content}),document.body):null;// ── Empty state ──\nconst hasContent=wordCount>=MIN_WORD_THRESHOLD||imageCount>0;if(!hasContent){if(emptyState){return /*#__PURE__*/_jsxs(\"div\",{style:{...textStyles,opacity:.5,...style},children:[hiddenRenderer,emptyState]});}return /*#__PURE__*/_jsx(\"div\",{style:{display:\"contents\",...style},children:hiddenRenderer});}// ── Calculation ──\nconst minutes=Math.max(1,calculateReadTime(wordCount,imageCount,wordsPerMinute,countImages));const suffix=minutes===1?suffixSingular:suffixPlural;const label=[prefix,`${minutes}`,suffix].filter(Boolean).join(\" \");const parts=[];if(separatorBefore)parts.push(separatorBefore);parts.push(label);if(separatorAfter)parts.push(separatorAfter);const display=parts.join(\" \");const clockIcon=/*#__PURE__*/_jsxs(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:\"1em\",height:\"1em\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",style:{flexShrink:0},children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"12 6 12 12 16 14\"})]});return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap:`${gap}px`,...textStyles,...style},children:[hiddenRenderer,showIcon&&clockIcon,/*#__PURE__*/_jsx(\"span\",{children:display})]});}// ── property controls ──────────────────────────────────────────────────\naddPropertyControls(ReadTime,{// ─ Content ─\ncontent:{title:\"Content\",type:ControlType.RichText,defaultValue:\"\"},emptyState:{title:\"Empty Text\",type:ControlType.String,defaultValue:\"Connect content...\",placeholder:\"e.g. Connect content…\",description:\"Shown when no content is connected or the article is empty. Leave blank to hide the component.\"},// ─ Calculation ─\nwordsPerMinute:{title:\"Words / Min\",type:ControlType.Number,defaultValue:238,min:50,max:500,step:1,description:\"Average reading speed. 238 wpm is the research average.\"},countImages:{title:\"Count Images\",type:ControlType.Boolean,defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\",description:\"Add image viewing time using Medium's formula (12s first image, decreasing to 3s).\"},// ─ Label ─\nprefix:{title:\"Prefix\",type:ControlType.String,defaultValue:\"\",placeholder:\"e.g. Reading time:\"},suffixSingular:{title:\"Suffix (1)\",type:ControlType.String,defaultValue:\"min read\",placeholder:\"e.g. minute\",description:\"Shown when read time is exactly 1.\"},suffixPlural:{title:\"Suffix (2+)\",type:ControlType.String,defaultValue:\"min read\",placeholder:\"e.g. minutes\",description:\"Shown when read time is 2 or more.\"},// ─ Separators ─\nseparatorBefore:{title:\"Sep. Before\",type:ControlType.String,defaultValue:\"\",placeholder:\"e.g. \\xb7  —  |  /\",description:\"Character before the label, for inline use with other metadata.\"},separatorAfter:{title:\"Sep. After\",type:ControlType.String,defaultValue:\"\",placeholder:\"e.g. \\xb7  —  |  /\",description:\"Character after the label.\"},// ─ Icon ─\nshowIcon:{title:\"Show Icon\",type:ControlType.Boolean,defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},gap:{title:\"Icon Gap\",type:ControlType.Number,defaultValue:6,min:0,max:24,step:1,unit:\"px\",hidden:props=>props.showIcon===false},// ─ Typography ─\nfont:{title:\"Font\",type:ControlType.Font,controls:\"extended\",displayFontSize:true,displayTextAlignment:false,defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:\"1.4em\"}},textTransform:{title:\"Text Transform\",type:ControlType.Enum,defaultValue:\"none\",options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"]},// ─ Color ─\ncolor:{title:\"Color\",type:ControlType.Color,defaultValue:\"#0A0A0A\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ReadTime\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ReadTime.map"],"mappings":"A,8MAWA,SAASc,EAAoB,EAAW,CAAC,IAAIC,EAAQ,EAAE,IAAI,IAAIC,EAAE,EAAEA,EAAEC,EAAW,IAAK,GAAS,KAAK,IAAI,GAAGD,EAAE,CAAC,EAAG,OAAOD,CAAQ,CAAC,SAASG,EAAkB,EAAU,EAAW,EAAI,EAAY,CAAC,IAAMC,EAAYC,EAAUC,EAAUC,EAAaC,EAAYT,EAAoBG,CAAU,EAAE,GAAG,EAAE,OAAO,KAAK,KAAKE,EAAYG,CAAY,CAAE,CAA6B,SAAwBE,EAAS,CAAC,UAAQ,aAAW,qBAAqB,iBAAe,IAAI,cAAY,GAAK,SAAO,GAAG,iBAAe,WAAW,eAAa,WAAW,WAAS,GAAM,MAAI,EAAE,kBAAgB,GAAG,iBAAe,GAAG,OAAK,gBAAc,OAAO,QAAM,UAAU,SAAO,CAAC,IAAMC,EAAUzB,EAAO,IAAI,EAAO,CAACoB,EAAUM,GAAczB,EAAS,CAAC,EAAO,CAACgB,EAAWU,GAAe1B,EAAS,CAAC,EAAEG,MAAc,CAAC,IAAMwB,EAAM,0BAA0B,CAAC,GAAGH,EAA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