{"version":3,"file":"VoteCounter.D-e1wHrl.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/gk77tU1PRLa3dJcT5MZV/g6szieOQ7d3PnCWJcSQf/fuTlpz488.js","https:/framerusercontent.com/modules/Hd0TJ077u5NS4qJLLSCh/QalE6lU9B787zrvWhNs3/voteFunctions.js","https:/framerusercontent.com/modules/1ydziJCKm9uWuJHfU7o6/jC4kaXzWmcNqZJ0ZIZDR/VoteCounter.js"],"sourcesContent":["// Generated by Framer (6ca5d98)\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,cx,motion,withCSS}from\"framer\";import*as React from\"react\";import{forwardRef}from\"react\";const mask='url(\\'data:image/svg+xml,<svg display=\"block\" role=\"presentation\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M 7.289 10 C 8.064 11.391 9.456 12.329 11.035 12.526 C 12.615 12.724 14.195 12.157 15.289 11 L 19.289 7 C 21.222 5.067 21.222 1.933 19.289 0 C 17.356 -1.933 14.222 -1.933 12.289 0 L 10.289 2 M 13.289 8 C 12.513 6.609 11.122 5.671 9.542 5.474 C 7.962 5.276 6.383 5.843 5.289 7 L 1.289 11 C -0.644 12.933 -0.644 16.067 1.289 18 C 3.222 19.933 6.356 19.933 8.289 18 L 10.289 16\" fill=\"transparent\" height=\"19.449747481763218px\" id=\"OxcCJRtX6\" stroke-dasharray=\"\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" stroke=\"var(--1df8v9o, rgb(0,0,0))\" transform=\"translate(1.711 3)\" width=\"20.738411809278734px\"/></svg>\\') alpha no-repeat center / auto var(--framer-icon-mask-mode, add), var(--framer-icon-mask, none)';const SVG=/*#__PURE__*/forwardRef((props,ref)=>{const{animated,layoutId,children,...rest}=props;return animated?/*#__PURE__*/_jsx(motion.div,{...rest,layoutId:layoutId,ref:ref}):/*#__PURE__*/_jsx(\"div\",{...rest,ref:ref});});const getProps=({height,id,stroke,width,...props})=>{return{...props,n2nHSaXfp:stroke??props.n2nHSaXfp??\"rgb(0, 0, 0)\"};};const Component=/*#__PURE__*/React.forwardRef(function(props,ref){const{style,className,layoutId,variant,n2nHSaXfp,...restProps}=getProps(props);return /*#__PURE__*/_jsx(SVG,{...restProps,className:cx(\"framer-OWYJA\",className),layoutId:layoutId,ref:ref,style:{\"--1df8v9o\":n2nHSaXfp,...style}});});const css=[`.framer-OWYJA { -webkit-mask: ${mask}; aspect-ratio: 1; background-color: var(--1df8v9o); mask: ${mask}; width: 24px; }`];/**\n * This is a generated Framer component.\n * @framerIntrinsicWidth 24\n * @framerIntrinsicHeight 24\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerVariables {\"n2nHSaXfp\":\"stroke\"}\n * @framerImmutableVariables true\n * @framerVector {\"name\":\"Link\",\"color\":{\"type\":\"variable\",\"value\":\"1df8v9o\"},\"set\":{\"localId\":\"vectorSet/yXo17f3GZ\",\"id\":\"yXo17f3GZ\",\"moduleId\":\"eO37kitVCMcNEgHMGd3K\"}}\n * @framerDisableUnlink true\n */const Icon=withCSS(Component,css,\"framer-OWYJA\");Icon.displayName=\"Link\";export default Icon;addPropertyControls(Icon,{n2nHSaXfp:{defaultValue:\"rgb(0, 0, 0)\",hidden:false,title:\"Stroke\",type:ControlType.Color}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Icon\",\"slots\":[],\"annotations\":{\"framerVector\":\"{\\\"name\\\":\\\"Link\\\",\\\"color\\\":{\\\"type\\\":\\\"variable\\\",\\\"value\\\":\\\"1df8v9o\\\"},\\\"set\\\":{\\\"localId\\\":\\\"vectorSet/yXo17f3GZ\\\",\\\"id\\\":\\\"yXo17f3GZ\\\",\\\"moduleId\\\":\\\"eO37kitVCMcNEgHMGd3K\\\"}}\",\"framerImmutableVariables\":\"true\",\"framerDisableUnlink\":\"true\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"24\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerVariables\":\"{\\\"n2nHSaXfp\\\":\\\"stroke\\\"}\",\"framerIntrinsicHeight\":\"24\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{supabase}from\"https://framerusercontent.com/modules/Mdy9Rtf8T9cG74v4bZSr/r8actqTFhXEjFlDsDRA3/supabaseClient.js\";// Oy sayısını getir\nexport async function getVotes(slug){const{data,error}=await supabase.from(\"votes\").select(\"*\").eq(\"slug\",slug).limit(1)// <-- Güvenli seçim\n.maybeSingle()// veya .then(res => res[0])\n;if(error){console.error(\"getVotes error:\",error);return 0;}return data?.count??0;}// Upvote ekle\nexport async function upvote(slug){const voted=localStorage.getItem(`voted-${slug}`);if(voted){return;}const current=await getVotes(slug);const newCount=current+1;const{error}=await supabase.from(\"votes\").upsert([{slug,count:newCount}],{onConflict:[\"slug\"]});if(error){console.error(\"upvote error:\",error);}else{localStorage.setItem(`voted-${slug}`,\"true\");}}\nexport const __FramerMetadata__ = {\"exports\":{\"upvote\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getVotes\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,startTransition,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";import{getVotes,upvote}from\"https://framerusercontent.com/modules/Hd0TJ077u5NS4qJLLSCh/QalE6lU9B787zrvWhNs3/voteFunctions.js\";export function Spinner({size=12,color=\"#999\"}){return /*#__PURE__*/_jsx(motion.div,{style:{width:size,height:size,border:`1px solid ${color}`,borderTop:`1px solid transparent`,borderRadius:\"50%\",display:\"inline-block\"},animate:{rotate:360},transition:{repeat:Infinity,ease:\"linear\",duration:.6}});}export default function VoteCounter(props){const{postId=\"default\",backgroundColor,iconColor,scoreColor,hoverColor,font,borderRadius,iconSize,padding,border,upvoteIconType,customUpvoteIcon={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Custom Icon\"}}=props;const[score,setScore]=useState(null);const[hasVoted,setHasVoted]=useState(false);const[upvoteHover,setUpvoteHover]=useState(false);const[isAnimating,setIsAnimating]=useState(false);useEffect(()=>{async function fetchVotes(){const count=await getVotes(postId);setScore(count);}fetchVotes();},[postId]);const handleUpvote=async()=>{if(hasVoted)return;startTransition(async()=>{await upvote(postId);const newCount=await getVotes(postId);setScore(newCount);setHasVoted(true);setIsAnimating(true);});};useEffect(()=>{if(isAnimating){const timer=setTimeout(()=>setIsAnimating(false),300);return()=>clearTimeout(timer);}},[isAnimating]);const isFixedWidth=props?.style?.width===\"100%\";const isFixedHeight=props?.style?.height===\"100%\";return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,...isFixedWidth?{}:{width:\"max-content\"},...isFixedHeight?{}:{height:\"max-content\"},display:\"flex\",flexDirection:\"column\",alignItems:\"center\",backgroundColor,borderRadius,padding,gap:0,...border},children:[/*#__PURE__*/_jsx(\"button\",{onClick:handleUpvote,onMouseEnter:()=>setUpvoteHover(true),onMouseLeave:()=>setUpvoteHover(false),style:{background:\"none\",border:\"none\",cursor:\"pointer\",padding:\"4px\",borderRadius:\"4px\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",transition:\"all 0.2s ease\",color:upvoteHover?hoverColor:iconColor,transform:isAnimating?\"scale(1.2)\":\"scale(1)\"},\"aria-label\":\"Upvote\",children:upvoteIconType===\"custom\"?/*#__PURE__*/_jsx(\"img\",{src:customUpvoteIcon.src,alt:customUpvoteIcon.alt,width:iconSize,height:iconSize,style:{objectFit:\"contain\"}}):/*#__PURE__*/_jsx(\"svg\",{width:iconSize,height:iconSize,viewBox:\"0 0 24 24\",fill:\"currentColor\",children:upvoteIconType===\"arrow\"?/*#__PURE__*/_jsx(\"path\",{d:\"M12 4l8 8H4l8-8z\"}):upvoteIconType===\"thumbs\"?/*#__PURE__*/_jsx(\"path\",{d:\"M14,9V5a3,3 0 0,0 -6,0v6H6a2,2 0 0,0 -2,2v7a2,2 0 0,0 2,2H18a2,2 0 0,0 2,-2V13a2,2 0 0,0 -2,-2H16l-2,-2Z\"}):upvoteIconType===\"heart\"?/*#__PURE__*/_jsx(\"path\",{d:\"M12,21.35l-1.45-1.32C5.4,15.36,2,12.28,2,8.5 C2,5.42,4.42,3,7.5,3c1.74,0,3.41,0.81,4.5,2.09C13.09,3.81,14.76,3,16.5,3 C19.58,3,22,5.42,22,8.5c0,3.78-3.4,6.86-8.55,11.54L12,21.35z\"}):upvoteIconType===\"star\"?/*#__PURE__*/_jsx(\"path\",{d:\"M12,17.27L18.18,21l-1.64-7.03L22,9.24l-7.19-0.61L12,2L9.19,8.63L2,9.24l5.46,4.73L5.82,21L12,17.27z\"}):upvoteIconType===\"plus\"?/*#__PURE__*/_jsx(\"path\",{d:\"M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z\"}):null})}),/*#__PURE__*/_jsx(\"div\",{style:{...font,color:isAnimating?hoverColor:scoreColor,textAlign:\"center\",minWidth:\"24px\",transform:isAnimating?\"scale(1.3)\":\"scale(1)\",transition:\"all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)\"},children:score===null?/*#__PURE__*/_jsx(Spinner,{size:10,color:scoreColor}):score})]});}addPropertyControls(VoteCounter,{postId:{type:ControlType.String,title:\"Post ID (Unique)\",defaultValue:\"post1\"},initialScore:{type:ControlType.Number,title:\"Initial Score\",defaultValue:0},backgroundColor:{type:ControlType.Color,title:\"Background\"},iconColor:{type:ControlType.Color,title:\"Icon Color\"},scoreColor:{type:ControlType.Color,title:\"Score Color\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},borderRadius:{type:ControlType.Number,title:\"Radius\"},iconSize:{type:ControlType.Number,title:\"Icon Size\"},padding:{type:ControlType.Padding,title:\"Padding\"},border:{type:ControlType.Border,title:\"Border\"},upvoteIconType:{type:ControlType.Enum,title:\"Upvote Icon\",options:[\"arrow\",\"thumbs\",\"heart\",\"star\",\"plus\",\"custom\"]},customUpvoteIcon:{type:ControlType.ResponsiveImage,title:\"Custom Icon\",hidden:({upvoteIconType})=>upvoteIconType!==\"custom\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VoteCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"Spinner\":{\"type\":\"reactComponent\",\"name\":\"Spinner\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"4fACiL,EAAK,w1BAAg2B,EAAiB,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,WAAS,WAAS,WAAS,GAAG,EAAK,CAAC,EAAM,OAAO,EAAsB,EAAK,EAAO,IAAI,CAAC,GAAG,EAAc,WAAa,MAAI,EAAe,EAAK,MAAM,CAAC,GAAG,EAAS,MAAI,CAAG,GAAQ,GAAU,CAAC,SAAO,KAAG,SAAO,QAAM,GAAG,EAAM,IAAU,CAAC,GAAG,EAAM,UAAU,GAAQ,EAAM,WAAW,eAAe,EAAS,EAAuB,EAAiB,SAAS,EAAM,EAAI,CAAC,GAAK,CAAC,QAAM,YAAU,WAAS,UAAQ,YAAU,GAAG,EAAU,CAAC,EAAS,GAAO,OAAoB,EAAK,EAAI,CAAC,GAAG,EAAU,UAAU,EAAG,eAAe,GAAoB,WAAa,MAAI,MAAM,CAAC,YAAY,EAAU,GAAG,EAAM,CAAC,CAAG,GAAQ,EAAI,CAAC,iCAAiC,EAAK,6DAA6D,EAAK,kBAAkB,CAU/wD,EAAK,EAAQ,EAAU,EAAI,gBAAgB,EAAK,YAAY,OAA2B,EAAoB,EAAK,CAAC,UAAU,CAAC,aAAa,eAAe,OAAO,GAAM,MAAM,SAAS,KAA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