{"version":3,"file":"ReadingTime.BCGF5a6e.mjs","names":["useState","useMemo"],"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":"gZAMG,SAAgB,EAAY,EAAM,CAAC,GAAK,CAAC,OAAK,YAAU,QAAM,cAAY,CAAC,EAGzE,CAAC,EAAW,EAAc,CAACA,EAAS,GAAG,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAI,SAAS,cAAc,OAAO,EAAI,UAAU,OAAO,GAAQ,SAAS,EAAM,KAAK,UAAU,GAAO,IAAM,EAAK,EAAI,aAAa,EAAI,WAAW,GAAG,EAAc,EAAK,OAAO,MAAM,OAAO,OAAS,EAAC,CAAC,EAAM,EAGjT,IAAM,EAAUC,MAAY,CAAC,GAAG,CAAC,EAAK,MAAM,EAAE,CAC9C,GAAK,CAAC,WAAS,WAAS,GA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