{"version":3,"file":"ReadingTime.DcmrFNST.mjs","names":[],"sources":["https:/framerusercontent.com/modules/E3Aq2uEZJbLPE31p6LSm/dFWzz3DiMQMSXLKL1sxy/ReadingTime.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{fontControls}from\"https://framer.com/m/framer/default-utils.js@^0.45.0\";import{useEffect,useState,useMemo}from\"react\";/**\n * WordCounter\n * A tiny utility component that can show either the total word count\n * of a rich‑text string or an estimated reading time. Now with full\n * support for variable fonts (font‑variation‑settings) in addition to\n * OpenType features.\n */export function WordCounter(props){const{font,fontColor,title,displayMode}=props;// ────────────────────────────────────────────────────────────────\n// Word‑count logic\n// ────────────────────────────────────────────────────────────────\nconst[countWords,setCountWords]=useState(0);useEffect(()=>{if(typeof window===\"undefined\")return;const div=document.createElement(\"div\");div.innerHTML=typeof title===\"string\"?title:JSON.stringify(title);const text=div.textContent||div.innerText||\"\";setCountWords(text.trim().split(/\\s+/).length);},[title]);// ────────────────────────────────────────────────────────────────\n// Font helpers\n// ────────────────────────────────────────────────────────────────\nconst fontStyle=useMemo(()=>{if(!font)return{};// Separate variable axes and OpenType features from the rest\nconst{variable,opentype,...base}=font;const style={...base};// Apply OpenType feature settings → font-feature-settings\nif(opentype&&typeof opentype===\"object\"&&Object.keys(opentype).length){style.fontFeatureSettings=Object.entries(opentype).filter(([,enabled])=>enabled).map(([tag,value])=>`\"${tag}\" ${value}`).join(\", \");}// Apply variable font axis values → font-variation-settings\nif(variable&&typeof variable===\"object\"&&Object.keys(variable).length){style.fontVariationSettings=Object.entries(variable).map(([axis,value])=>`\"${axis}\" ${value}`).join(\", \");// Provide the most common axis as fallbacks when possible\nif(variable.wght&&!style.fontWeight)style.fontWeight=variable.wght;if(variable.slnt&&!style.fontStyle)style.fontStyle=\"oblique\";}return style;},[font]);// ────────────────────────────────────────────────────────────────\n// Render\n// ────────────────────────────────────────────────────────────────\nconst wordsPerMinute=200;const timeToRead=Math.ceil(countWords/wordsPerMinute);return /*#__PURE__*/_jsx(\"div\",{style:{...fontStyle,color:fontColor,display:\"flex\",justifyContent:\"center\",alignItems:\"center\",padding:0},children:displayMode===\"words\"?`${countWords}`:`${timeToRead} min read`});}// ────────────────────────────────────────────────────────────────────\n// Defaults & Property Controls\n// ────────────────────────────────────────────────────────────────────\nWordCounter.defaultProps={title:\"<p>Your rich text here</p>\",font:fontControls.defaultProps,fontColor:\"#000\",displayMode:\"words\"};addPropertyControls(WordCounter,{title:{title:\"Title\",//@ts-ignore – Framer-specific prop type\ntype:ControlType.RichText},font:{// @ts-expect-error – Internal Framer API uses this signature\ntype:ControlType.Font,controls:\"extended\",title:\"Font\"},fontColor:{title:\"Font Color\",type:ControlType.Color,defaultValue:WordCounter.defaultProps.fontColor},displayMode:{title:\"Display Mode\",type:ControlType.SegmentedEnum,options:[\"words\",\"time\"],optionTitles:[\"Words\",\"Time to Read\"],defaultValue:WordCounter.defaultProps.displayMode}});\nexport const __FramerMetadata__ = {\"exports\":{\"WordCounter\":{\"type\":\"reactComponent\",\"name\":\"WordCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ReadingTime.map"],"mappings":"mcAMG,SAAgB,EAAY,EAAM,CAGrC,GAH2C,CAAC,OAAK,YAAU,QAAM,cAAY,CAAC,EAGzE,CAAC,EAAW,EAAc,CAAC,EAAS,EAAE,CAAC,EAAU,IAAI,CAAC,GAAU,WAAqB,OAAO,IAAM,EAAI,SAAS,cAAc,MAAM,CAAC,EAAI,iBAAiB,GAAQ,SAAS,EAAM,KAAK,UAAU,EAAM,CAAC,IAAM,EAAK,EAAI,aAAa,EAAI,WAAW,GAAG,EAAc,EAAK,MAAM,CAAC,MAAM,MAAM,CAAC,OAAO,AAAE,EAAC,CAAC,CAAM,EAAC,CAUzR,IAPnB,EAAU,EAAQ,IAAI,CAAC,IAAI,EAAK,MAAM,CAAE,E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