{"version":3,"file":"View_Counter.DYxUbbCE.mjs","names":[],"sources":["https:/framerusercontent.com/modules/go4G6RozEpIBDHUVLqLI/Xp88lH4S6oUKR38SSW0Y/View_Counter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function PageViews(props){const{textColor,font,setup,suffix}=props;const[views,setViews]=useState(0);const isCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{const incrementViews=async()=>{try{if(typeof window===\"undefined\")return;const{pathname,host}=window.location;const slug=host+pathname;const response=await fetch(`${setup.url}/rest/v1/rpc/increment_page_view`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\",apikey:setup.key,Authorization:`Bearer ${setup.key}`},body:JSON.stringify({slug:slug})});if(!response.ok)throw new Error(\"Failed to increment views\");const newViews=await response.json();setViews(newViews);}catch(error){console.error(\"Error:\",error);}};if(!isCanvas){incrementViews();}},[setup]);return /*#__PURE__*/_jsx(\"div\",{style:{...props.style},children:/*#__PURE__*/_jsxs(\"p\",{style:{margin:0,color:textColor,...font},children:[isCanvas?\"123\":views,\" \",suffix]})});}PageViews.defaultProps={suffix:\"views\",setup:{url:\"https://nlbllifiywwihhynrcgn.supabase.co\",key:\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5sYmxsaWZpeXd3aWhoeW5yY2duIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzIxNzU2ODUsImV4cCI6MjA0Nzc1MTY4NX0.aEc2tzhVPBdVuf_zZpOvyvosNbicoXnawczlyTJQhY4\"}};addPropertyControls(PageViews,{// setup: {\n//     type: ControlType.Object,\n//     controls: {\n//         url: {\n//             type: ControlType.String,\n//             title: \"URL\",\n//         },\n//         key: {\n//             type: ControlType.String,\n//             title: \"Anon/Public Key\",\n//             description:\n//                 \"The component will work by default. If you'd like to self host, create a Supabase project and click [here](https://www.google.com), run the command and plugin your own URL and key\",\n//         },\n//     },\n// },\nsuffix:{type:ControlType.String,title:\"Suffix\"},font:{type:ControlType.Font,controls:\"extended\",title:\"Font\"},textColor:{type:ControlType.Color,defaultValue:\"#000000\",title:\"Color\",description:\"Publish to see this in effect. Views may not reflect accurately in preview mode.\\n\\nv1.0 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PageViews\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./View_Counter.map"],"mappings":"2UAKG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,YAAU,OAAK,QAAM,SAAO,CAAC,EAAW,CAAC,EAAM,EAAS,CAAC,EAAS,EAAE,CAAO,EAAS,EAAa,SAAS,GAAG,EAAa,OAAykB,MAAlkB,GAAU,IAAI,CAAC,IAAM,EAAe,SAAS,CAAC,GAAG,CAAC,GAAU,WAAqB,OAAO,GAAK,CAAC,WAAS,OAAK,CAAC,EAAO,SAAe,EAAK,EAAK,EAAe,EAAS,KAAM,UAAS,EAAM,IAAI,kCAAkC,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,mBAAmB,OAAO,EAAM,IAAI,eAAe,SAAS,EAAM,KAAM,EAAC,KAAK,KAAK,UAAU,CAAM,MAAK,EAAC,AAAC,EAAC,CAAC,IAAI,EAAS,GAAG,KAAM,CAAI,MAAM,4BAAA,CAA6B,IAAM,EAAS,KAAM,GAAS,MAAM,CAAC,EAAS,EAAS,AAAE,OAAM,EAAM,CAAC,QAAQ,MAAM,SAAS,EAAM,AAAE,CAAC,EAAC,AAAI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