UNPKG

react-kofi

Version:

Ko-fi buttons, modals, and react components built with Radix for React.js projects (unofficial)

2 lines (1 loc) 35.2 kB
import*as e from"react";import t,{useState as n,forwardRef as r,createElement as o,useEffect as i}from"react";import{jsx as a,Fragment as c,jsxs as u}from"react/jsx-runtime";import*as s from"react-dom";import l from"react-dom";function d(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function f(...e){return t=>e.forEach((e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t)))}function p(...t){return e.useCallback(f(...t),t)}function m(...t){const n=t[0];if(1===t.length)return n;const r=()=>{const r=t.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(t){const o=r.reduce(((e,{useScope:n,scopeName:r})=>({...e,...n(t)[`__scope${r}`]})),{});return e.useMemo((()=>({[`__scope${n.scopeName}`]:o})),[o])}};return r.scopeName=n.scopeName,r}var v=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},h=e["useId".toString()]||(()=>{}),g=0;function y(t){const[n,r]=e.useState(h());return v((()=>{t||r((e=>e??String(g++)))}),[t]),t||(n?`radix-${n}`:"")}function b(t){const n=e.useRef(t);return e.useEffect((()=>{n.current=t})),e.useMemo((()=>(...e)=>n.current?.(...e)),[])}function E({prop:t,defaultProp:n,onChange:r=()=>{}}){const[o,i]=function({defaultProp:t,onChange:n}){const r=e.useState(t),[o]=r,i=e.useRef(o),a=b(n);return e.useEffect((()=>{i.current!==o&&(a(o),i.current=o)}),[o,i,a]),r}({defaultProp:n,onChange:r}),a=void 0!==t,c=a?t:o,u=b(r);return[c,e.useCallback((e=>{if(a){const n="function"==typeof e?e(t):e;n!==t&&u(n)}else i(e)}),[a,t,i,u])]}var w=e.forwardRef(((t,n)=>{const{children:r,...o}=t,i=e.Children.toArray(r),c=i.find(O);if(c){const t=c.props.children,r=i.map((n=>n===c?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:n));return a(C,{...o,ref:n,children:e.isValidElement(t)?e.cloneElement(t,void 0,r):null})}return a(C,{...o,ref:n,children:r})}));w.displayName="Slot";var C=e.forwardRef(((t,n)=>{const{children:r,...o}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(r);return e.cloneElement(r,{...x(o,r.props),ref:n?f(n,t):t})}return e.Children.count(r)>1?e.Children.only(null):null}));C.displayName="SlotClone";var N=({children:e})=>a(c,{children:e});function O(t){return e.isValidElement(t)&&t.type===N}function x(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...e)=>{i(...e),o(...e)}:o&&(n[r]=o):"style"===r?n[r]={...o,...i}:"className"===r&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}var R=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((t,n)=>{const r=e.forwardRef(((e,t)=>{const{asChild:r,...o}=e,i=r?w:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),a(i,{...o,ref:t})}));return r.displayName=`Primitive.${n}`,{...t,[n]:r}}),{});var k,S="dismissableLayer.update",D="dismissableLayer.pointerDownOutside",P="dismissableLayer.focusOutside",L=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),T=e.forwardRef(((t,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:c,onInteractOutside:u,onDismiss:s,...l}=t,f=e.useContext(L),[m,v]=e.useState(null),h=m?.ownerDocument??globalThis?.document,[,g]=e.useState({}),y=p(n,(e=>v(e))),E=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),C=E.indexOf(w),N=m?E.indexOf(m):-1,O=f.layersWithOutsidePointerEventsDisabled.size>0,x=N>=C,T=function(t,n=globalThis?.document){const r=b(t),o=e.useRef(!1),i=e.useRef((()=>{}));return e.useEffect((()=>{const e=e=>{if(e.target&&!o.current){let t=function(){_(D,r,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",i.current),i.current=t,n.addEventListener("click",i.current,{once:!0})):t()}else n.removeEventListener("click",i.current);o.current=!1},t=window.setTimeout((()=>{n.addEventListener("pointerdown",e)}),0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",i.current)}}),[n,r]),{onPointerDownCapture:()=>o.current=!0}}((e=>{const t=e.target,n=[...f.branches].some((e=>e.contains(t)));x&&!n&&(i?.(e),u?.(e),e.defaultPrevented||s?.())}),h),I=function(t,n=globalThis?.document){const r=b(t),o=e.useRef(!1);return e.useEffect((()=>{const e=e=>{if(e.target&&!o.current){_(P,r,{originalEvent:e},{discrete:!1})}};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)}),[n,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}((e=>{const t=e.target;[...f.branches].some((e=>e.contains(t)))||(c?.(e),u?.(e),e.defaultPrevented||s?.())}),h);return function(t,n=globalThis?.document){const r=b(t);e.useEffect((()=>{const e=e=>{"Escape"===e.key&&r(e)};return n.addEventListener("keydown",e,{capture:!0}),()=>n.removeEventListener("keydown",e,{capture:!0})}),[r,n])}((e=>{N===f.layers.size-1&&(o?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))}),h),e.useEffect((()=>{if(m)return r&&(0===f.layersWithOutsidePointerEventsDisabled.size&&(k=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(m)),f.layers.add(m),M(),()=>{r&&1===f.layersWithOutsidePointerEventsDisabled.size&&(h.body.style.pointerEvents=k)}}),[m,h,r,f]),e.useEffect((()=>()=>{m&&(f.layers.delete(m),f.layersWithOutsidePointerEventsDisabled.delete(m),M())}),[m,f]),e.useEffect((()=>{const e=()=>g({});return document.addEventListener(S,e),()=>document.removeEventListener(S,e)}),[]),a(R.div,{...l,ref:y,style:{pointerEvents:O?x?"auto":"none":void 0,...t.style},onFocusCapture:d(t.onFocusCapture,I.onFocusCapture),onBlurCapture:d(t.onBlurCapture,I.onBlurCapture),onPointerDownCapture:d(t.onPointerDownCapture,T.onPointerDownCapture)})}));T.displayName="DismissableLayer";function M(){const e=new CustomEvent(S);document.dispatchEvent(e)}function _(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?function(e,t){e&&s.flushSync((()=>e.dispatchEvent(t)))}(o,i):o.dispatchEvent(i)}e.forwardRef(((t,n)=>{const r=e.useContext(L),o=e.useRef(null),i=p(n,o);return e.useEffect((()=>{const e=o.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}}),[r.branches]),a(R.div,{...t,ref:i})})).displayName="DismissableLayerBranch";var I="focusScope.autoFocusOnMount",A="focusScope.autoFocusOnUnmount",F={bubbles:!1,cancelable:!0},W=e.forwardRef(((t,n)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:i,onUnmountAutoFocus:c,...u}=t,[s,l]=e.useState(null),d=b(i),f=b(c),m=e.useRef(null),v=p(n,(e=>l(e))),h=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect((()=>{if(o){let e=function(e){if(h.paused||!s)return;const t=e.target;s.contains(t)?m.current=t:U(m.current,{select:!0})},t=function(e){if(h.paused||!s)return;const t=e.relatedTarget;null!==t&&(s.contains(t)||U(m.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&U(s)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}}),[o,s,h.paused]),e.useEffect((()=>{if(s){K.add(h);const t=document.activeElement;if(!s.contains(t)){const n=new CustomEvent(I,F);s.addEventListener(I,d),s.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(U(r,{select:t}),document.activeElement!==n)return}((e=j(s),e.filter((e=>"A"!==e.tagName))),{select:!0}),document.activeElement===t&&U(s))}return()=>{s.removeEventListener(I,d),setTimeout((()=>{const e=new CustomEvent(A,F);s.addEventListener(A,f),s.dispatchEvent(e),e.defaultPrevented||U(t??document.body,{select:!0}),s.removeEventListener(A,f),K.remove(h)}),0)}}var e}),[s,d,f,h]);const g=e.useCallback((e=>{if(!r&&!o)return;if(h.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[o,i]=function(e){const t=j(e),n=B(t,e),r=B(t.reverse(),e);return[n,r]}(t);o&&i?e.shiftKey||n!==i?e.shiftKey&&n===o&&(e.preventDefault(),r&&U(i,{select:!0})):(e.preventDefault(),r&&U(o,{select:!0})):n===t&&e.preventDefault()}}),[r,o,h.paused]);return a(R.div,{tabIndex:-1,...u,ref:v,onKeyDown:g})}));function j(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function B(e,t){for(const n of e)if(!$(n,{upTo:t}))return n}function $(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function U(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}W.displayName="FocusScope";var K=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=z(e,t),e.unshift(t)},remove(t){e=z(e,t),e[0]?.resume()}}}();function z(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var H=e.forwardRef(((t,n)=>{const{container:r,...o}=t,[i,c]=e.useState(!1);v((()=>c(!0)),[]);const u=r||i&&globalThis?.document?.body;return u?l.createPortal(a(R.div,{...o,ref:n}),u):null}));H.displayName="Portal";var Y=t=>{const{present:n,children:r}=t,o=function(t){const[n,r]=e.useState(),o=e.useRef({}),i=e.useRef(t),a=e.useRef("none"),c=t?"mounted":"unmounted",[u,l]=function(t,n){return e.useReducer(((e,t)=>n[e][t]??e),t)}(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect((()=>{const e=X(o.current);a.current="mounted"===u?e:"none"}),[u]),v((()=>{const e=o.current,n=i.current;if(n!==t){const r=a.current,o=X(e);if(t)l("MOUNT");else if("none"===o||"none"===e?.display)l("UNMOUNT");else{l(n&&r!==o?"ANIMATION_OUT":"UNMOUNT")}i.current=t}}),[t,l]),v((()=>{if(n){const e=e=>{const t=X(o.current).includes(e.animationName);e.target===n&&t&&s.flushSync((()=>l("ANIMATION_END")))},t=e=>{e.target===n&&(a.current=X(o.current))};return n.addEventListener("animationstart",t),n.addEventListener("animationcancel",e),n.addEventListener("animationend",e),()=>{n.removeEventListener("animationstart",t),n.removeEventListener("animationcancel",e),n.removeEventListener("animationend",e)}}l("ANIMATION_END")}),[n,l]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:e.useCallback((e=>{e&&(o.current=getComputedStyle(e)),r(e)}),[])}}(n),i="function"==typeof r?r({present:o.isPresent}):e.Children.only(r),a=p(o.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof r||o.isPresent?e.cloneElement(i,{ref:a}):null};function X(e){return e?.animationName||"none"}Y.displayName="Presence";var Z=0;function V(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}var q=function(){return q=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},q.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var G="right-scroll-bar-position",J="width-before-scroll-bar";function Q(e,t){return r=t||null,o=function(t){return e.forEach((function(e){return function(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}(e,t)}))},(i=n((function(){return{value:r,callback:o,facade:{get current(){return i.value},set current(e){var t=i.value;t!==e&&(i.value=e,i.callback(e,t))}}}}))[0]).callback=o,i.facade;var r,o,i}var ee=function(){return ee=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ee.apply(this,arguments)};function te(e){return e}var ne=function(t){var n=t.sideCar,r=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=n.read();if(!o)throw new Error("Sidecar medium not found");return e.createElement(o,ee({},r))};ne.isSideCarExport=!0;var re=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=te);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var o=t(e,r);return n.push(o),function(){n=n.filter((function(e){return e!==o}))}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var o=n;n=[],o.forEach(e),t=n}var i=function(){var n=t;t=[],n.forEach(e)},a=function(){return Promise.resolve().then(i)};a(),n={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=ee({async:!0,ssr:!1},e),t}(),oe=function(){},ie=e.forwardRef((function(t,n){var r=e.useRef(null),o=e.useState({onScrollCapture:oe,onWheelCapture:oe,onTouchMoveCapture:oe}),i=o[0],a=o[1],c=t.forwardProps,u=t.children,s=t.className,l=t.removeScrollBar,d=t.enabled,f=t.shards,p=t.sideCar,m=t.noIsolation,v=t.inert,h=t.allowPinchZoom,g=t.as,y=void 0===g?"div":g,b=t.gapMode,E=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=p,C=Q([r,n]),N=q(q({},E),i);return e.createElement(e.Fragment,null,d&&e.createElement(w,{sideCar:re,removeScrollBar:l,shards:f,noIsolation:m,inert:v,setCallbacks:a,allowPinchZoom:!!h,lockRef:r,gapMode:b}),c?e.cloneElement(e.Children.only(u),q(q({},N),{ref:C})):e.createElement(y,q({},N,{className:s,ref:C}),u))}));ie.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ie.classNames={fullWidth:J,zeroRight:G};function ae(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var ce=function(){var e=0,t=null;return{add:function(n){var r,o;0==e&&(t=ae())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ue=function(){var t,n=(t=ce(),function(n,r){e.useEffect((function(){return t.add(n),function(){t.remove()}}),[n&&r])});return function(e){var t=e.styles,r=e.dynamic;return n(t,r),null}},se={left:0,top:0,right:0,gap:0},le=function(e){return parseInt(e||"",10)||0},de=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return se;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],o=t["padding"===e?"paddingRight":"marginRight"];return[le(n),le(r),le(o)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},fe=ue(),pe=function(e,t,n,r){var o=e.left,i=e.top,a=e.right,c=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(c,"px ").concat(r,";\n }\n body {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(o,"px;\n padding-top: ").concat(i,"px;\n padding-right: ").concat(a,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(c,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(G," {\n right: ").concat(c,"px ").concat(r,";\n }\n \n .").concat(J," {\n margin-right: ").concat(c,"px ").concat(r,";\n }\n \n .").concat(G," .").concat(G," {\n right: 0 ").concat(r,";\n }\n \n .").concat(J," .").concat(J," {\n margin-right: 0 ").concat(r,";\n }\n \n body {\n ").concat("--removed-body-scroll-bar-size",": ").concat(c,"px;\n }\n")},me=function(t){var n=t.noRelative,r=t.noImportant,o=t.gapMode,i=void 0===o?"margin":o,a=e.useMemo((function(){return de(i)}),[i]);return e.createElement(fe,{styles:pe(a,!n,i,r?"":"!important")})},ve=!1;if("undefined"!=typeof window)try{var he=Object.defineProperty({},"passive",{get:function(){return ve=!0,!0}});window.addEventListener("test",he,he),window.removeEventListener("test",he,he)}catch(e){ve=!1}var ge=!!ve&&{passive:!1},ye=function(e,t){var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},be=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),Ee(e,r)){var o=we(e,r);if(o[1]>o[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ee=function(e,t){return"v"===e?function(e){return ye(e,"overflowY")}(t):function(e){return ye(e,"overflowX")}(t)},we=function(e,t){return"v"===e?[(n=t).scrollTop,n.scrollHeight,n.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var n},Ce=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ne=function(e){return[e.deltaX,e.deltaY]},Oe=function(e){return e&&"current"in e?e.current:e},xe=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Re=0,ke=[];function Se(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var De,Pe=(De=function(t){var n=e.useRef([]),r=e.useRef([0,0]),o=e.useRef(),i=e.useState(Re++)[0],a=e.useState(ue)[0],c=e.useRef(t);e.useEffect((function(){c.current=t}),[t]),e.useEffect((function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var e=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(Oe),!0).filter(Boolean);return e.forEach((function(e){return e.classList.add("allow-interactivity-".concat(i))})),function(){document.body.classList.remove("block-interactivity-".concat(i)),e.forEach((function(e){return e.classList.remove("allow-interactivity-".concat(i))}))}}}),[t.inert,t.lockRef.current,t.shards]);var u=e.useCallback((function(e,t){if("touches"in e&&2===e.touches.length)return!c.current.allowPinchZoom;var n,i=Ce(e),a=r.current,u="deltaX"in e?e.deltaX:a[0]-i[0],s="deltaY"in e?e.deltaY:a[1]-i[1],l=e.target,d=Math.abs(u)>Math.abs(s)?"h":"v";if("touches"in e&&"h"===d&&"range"===l.type)return!1;var f=be(d,l);if(!f)return!0;if(f?n=d:(n="v"===d?"h":"v",f=be(d,l)),!f)return!1;if(!o.current&&"changedTouches"in e&&(u||s)&&(o.current=n),!n)return!0;var p=o.current||n;return function(e,t,n,r,o){var i=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=i*r,c=n.target,u=t.contains(c),s=!1,l=a>0,d=0,f=0;do{var p=we(e,c),m=p[0],v=p[1]-p[2]-i*m;(m||v)&&Ee(e,c)&&(d+=v,f+=m),c=c instanceof ShadowRoot?c.host:c.parentNode}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(l&&(o&&Math.abs(d)<1||!o&&a>d)||!l&&(o&&Math.abs(f)<1||!o&&-a>f))&&(s=!0),s}(p,t,e,"h"===p?u:s,!0)}),[]),s=e.useCallback((function(e){var t=e;if(ke.length&&ke[ke.length-1]===a){var r="deltaY"in t?Ne(t):Ce(t),o=n.current.filter((function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&(n=e.delta,o=r,n[0]===o[0]&&n[1]===o[1]);var n,o}))[0];if(o&&o.should)t.cancelable&&t.preventDefault();else if(!o){var i=(c.current.shards||[]).map(Oe).filter(Boolean).filter((function(e){return e.contains(t.target)}));(i.length>0?u(t,i[0]):!c.current.noIsolation)&&t.cancelable&&t.preventDefault()}}}),[]),l=e.useCallback((function(e,t,r,o){var i={name:e,delta:t,target:r,should:o,shadowParent:Se(r)};n.current.push(i),setTimeout((function(){n.current=n.current.filter((function(e){return e!==i}))}),1)}),[]),d=e.useCallback((function(e){r.current=Ce(e),o.current=void 0}),[]),f=e.useCallback((function(e){l(e.type,Ne(e),e.target,u(e,t.lockRef.current))}),[]),p=e.useCallback((function(e){l(e.type,Ce(e),e.target,u(e,t.lockRef.current))}),[]);e.useEffect((function(){return ke.push(a),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",s,ge),document.addEventListener("touchmove",s,ge),document.addEventListener("touchstart",d,ge),function(){ke=ke.filter((function(e){return e!==a})),document.removeEventListener("wheel",s,ge),document.removeEventListener("touchmove",s,ge),document.removeEventListener("touchstart",d,ge)}}),[]);var m=t.removeScrollBar,v=t.inert;return e.createElement(e.Fragment,null,v?e.createElement(a,{styles:xe(i)}):null,m?e.createElement(me,{gapMode:t.gapMode}):null)},re.useMedium(De),ne),Le=e.forwardRef((function(t,n){return e.createElement(ie,q({},t,{ref:n,sideCar:Pe}))}));Le.classNames=ie.classNames;var Te=Le,Me=new WeakMap,_e=new WeakMap,Ie={},Ae=0,Fe=function(e,t,n){void 0===t&&(t=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===n&&(n="data-aria-hidden");var r=Array.isArray(e)?e:[e];Ie[n]||(Ie[n]=new WeakMap);var o=Ie[n],i=[],a=new Set,c=function(e){e&&!a.has(e)&&(a.add(e),c(e.parentNode))};r.forEach(c);var u=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(a.has(e))u(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,c=(Me.get(e)||0)+1,s=(o.get(e)||0)+1;Me.set(e,c),o.set(e,s),i.push(e),1===c&&r&&_e.set(e,!0),1===s&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return u(t),a.clear(),Ae++,function(){i.forEach((function(e){var t=Me.get(e)-1,r=o.get(e)-1;Me.set(e,t),o.set(e,r),t||(_e.has(e)||e.removeAttribute("aria-hidden"),_e.delete(e)),r||e.removeAttribute(n)})),--Ae||(Me=new WeakMap,Me=new WeakMap,_e=new WeakMap,Ie={})}},We="Dialog",[je,Be]=function(t,n=[]){let r=[];const o=()=>{const n=r.map((t=>e.createContext(t)));return function(r){const o=r?.[t]||n;return e.useMemo((()=>({[`__scope${t}`]:{...r,[t]:o}})),[r,o])}};return o.scopeName=t,[function(n,o){const i=e.createContext(o),c=r.length;function u(n){const{scope:r,children:o,...u}=n,s=r?.[t][c]||i,l=e.useMemo((()=>u),Object.values(u));return a(s.Provider,{value:l,children:o})}return r=[...r,o],u.displayName=n+"Provider",[u,function(r,a){const u=a?.[t][c]||i,s=e.useContext(u);if(s)return s;if(void 0!==o)return o;throw new Error(`\`${r}\` must be used within \`${n}\``)}]},m(o,...n)]}(We),[$e,Ue]=je(We),Ke=t=>{const{__scopeDialog:n,children:r,open:o,defaultOpen:i,onOpenChange:c,modal:u=!0}=t,s=e.useRef(null),l=e.useRef(null),[d=!1,f]=E({prop:o,defaultProp:i,onChange:c});return a($e,{scope:n,triggerRef:s,contentRef:l,contentId:y(),titleId:y(),descriptionId:y(),open:d,onOpenChange:f,onOpenToggle:e.useCallback((()=>f((e=>!e))),[f]),modal:u,children:r})};Ke.displayName=We;var ze="DialogTrigger",He=e.forwardRef(((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(ze,n),i=p(t,o.triggerRef);return a(R.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ut(o.open),...r,ref:i,onClick:d(e.onClick,o.onOpenToggle)})}));He.displayName=ze;var Ye="DialogPortal",[Xe,Ze]=je(Ye,{forceMount:void 0}),Ve=t=>{const{__scopeDialog:n,forceMount:r,children:o,container:i}=t,c=Ue(Ye,n);return a(Xe,{scope:n,forceMount:r,children:e.Children.map(o,(e=>a(Y,{present:r||c.open,children:a(H,{asChild:!0,container:i,children:e})})))})};Ve.displayName=Ye;var qe="DialogOverlay",Ge=e.forwardRef(((e,t)=>{const n=Ze(qe,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Ue(qe,e.__scopeDialog);return i.modal?a(Y,{present:r||i.open,children:a(Je,{...o,ref:t})}):null}));Ge.displayName=qe;var Je=e.forwardRef(((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(qe,n);return a(Te,{as:w,allowPinchZoom:!0,shards:[o.contentRef],children:a(R.div,{"data-state":ut(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})})),Qe="DialogContent",et=e.forwardRef(((e,t)=>{const n=Ze(Qe,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Ue(Qe,e.__scopeDialog);return a(Y,{present:r||i.open,children:i.modal?a(tt,{...o,ref:t}):a(nt,{...o,ref:t})})}));et.displayName=Qe;var tt=e.forwardRef(((t,n)=>{const r=Ue(Qe,t.__scopeDialog),o=e.useRef(null),i=p(n,r.contentRef,o);return e.useEffect((()=>{const e=o.current;if(e)return Fe(e)}),[]),a(rt,{...t,ref:i,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:d(t.onCloseAutoFocus,(e=>{e.preventDefault(),r.triggerRef.current?.focus()})),onPointerDownOutside:d(t.onPointerDownOutside,(e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()})),onFocusOutside:d(t.onFocusOutside,(e=>e.preventDefault()))})})),nt=e.forwardRef(((t,n)=>{const r=Ue(Qe,t.__scopeDialog),o=e.useRef(!1),i=e.useRef(!1);return a(rt,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(o.current||r.triggerRef.current?.focus(),e.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(o.current=!0,"pointerdown"===e.detail.originalEvent.type&&(i.current=!0));const n=e.target,a=r.triggerRef.current?.contains(n);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&i.current&&e.preventDefault()}})})),rt=e.forwardRef(((t,n)=>{const{__scopeDialog:r,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:s,...l}=t,d=Ue(Qe,r),f=e.useRef(null),m=p(n,f);return e.useEffect((()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??V()),document.body.insertAdjacentElement("beforeend",e[1]??V()),Z++,()=>{1===Z&&document.querySelectorAll("[data-radix-focus-guard]").forEach((e=>e.remove())),Z--}}),[]),u(c,{children:[a(W,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:s,children:a(T,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":ut(d.open),...l,ref:m,onDismiss:()=>d.onOpenChange(!1)})}),u(c,{children:[a(ft,{titleId:d.titleId}),a(pt,{contentRef:f,descriptionId:d.descriptionId})]})]})})),ot="DialogTitle";e.forwardRef(((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(ot,n);return a(R.h2,{id:o.titleId,...r,ref:t})})).displayName=ot;var it="DialogDescription";e.forwardRef(((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(it,n);return a(R.p,{id:o.descriptionId,...r,ref:t})})).displayName=it;var at="DialogClose",ct=e.forwardRef(((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(at,n);return a(R.button,{type:"button",...r,ref:t,onClick:d(e.onClick,(()=>o.onOpenChange(!1)))})}));function ut(e){return e?"open":"closed"}ct.displayName=at;var st="DialogTitleWarning",[lt,dt]=function(t,n){const r=e.createContext(n);function o(t){const{children:n,...o}=t,i=e.useMemo((()=>o),Object.values(o));return a(r.Provider,{value:i,children:n})}return o.displayName=t+"Provider",[o,function(o){const i=e.useContext(r);if(i)return i;if(void 0!==n)return n;throw new Error(`\`${o}\` must be used within \`${t}\``)}]}(st,{contentName:Qe,titleName:ot,docsSlug:"dialog"}),ft=({titleId:t})=>{const n=dt(st),r=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return e.useEffect((()=>{if(t){document.getElementById(t)||console.error(r)}}),[r,t]),null},pt=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${dt("DialogDescriptionWarning").contentName}}.`;return e.useEffect((()=>{const e=t.current?.getAttribute("aria-describedby");if(n&&e){document.getElementById(n)||console.warn(r)}}),[r,t,n]),null},mt=Ke,vt=He,ht=Ve,gt=Ge,yt=et,bt=ct;var Et=["color"],wt=r((function(e,t){var n=e.color,r=void 0===n?"currentColor":n,i=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,Et);return o("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),o("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}));const Ct=({color:e="#00b4f7",textColor:r="#fff",id:o="prototypr",label:i="Support me",padding:a=0,width:c=400,backgroundColor:u="#fff",iframe:s,buttonRadius:l="8px"})=>{const[d,f]=n(!1);return t.createElement(mt,{open:d,onOpenChange:f},t.createElement(vt,{asChild:!0},t.createElement("div",{title:i,className:"kofi-button w-fit text-sm hover:shadow-md transition transition-all duration-400 cursor-pointer px-3 h-[28px] flex flex-col justify-center",style:{backgroundColor:e,borderRadius:l},onClick:()=>f(!d)},t.createElement("div",{className:"kofitext gap-1 flex my-auto items-center"},t.createElement("img",{src:"https://ko-fi.com/img/cup-border.png",className:"kofiimg",alt:"Ko-Fi button"}),t.createElement("div",{className:"flex my-auto text-xs items-center",style:{color:r}},i)))),t.createElement(ht,null,t.createElement(gt,{className:"fixed inset-0 bg-black bg-opacity-50 z-[9999]"}),t.createElement(yt,{style:{padding:a,width:c,backgroundColor:u},className:"fixed h-[712px] overflow-hidden top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 rounded-xl shadow-lg z-[9999]"},t.createElement("div",{className:"relative w-full h-full"},t.createElement("div",{className:"flex flex-col h-full z-10 justify-center items-center kofi-button"},t.createElement("div",{className:"gap-1 flex my-auto items-center"},t.createElement("div",{className:"flex flex-col gap-2"},t.createElement("img",{src:"https://ko-fi.com/img/cup-border.png",className:"kofiimg !h-[auto] !w-[32px] !mx-auto animate-[kofi-wiggle_3s_infinite]",alt:"Ko-Fi button"}),t.createElement("div",{className:"mx-auto text-sm text-gray-600"},"Loading...")))),t.createElement("div",{className:"z-20 absolute top-0 left-0 w-full h-full"},s?t.createElement("div",{style:{width:"100%",height:"100%",background:"transparent"},dangerouslySetInnerHTML:{__html:s}}):t.createElement("iframe",{id:"kofiframe",src:`https://ko-fi.com/${o}/?hidefeed=true&widget=true&embed=true&preview=true`,style:{border:"none",width:"100%",background:"transparent"},height:"712",title:"prototypr"}))),t.createElement(bt,{asChild:!0},t.createElement("button",{className:"absolute z-30 top-2 bg-gray-200 right-2 p-1 rounded-full hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200"},t.createElement(wt,{className:"w-4 h-4 text-gray-500"}))))))};function Nt({color:e="#00b4f7",id:n="prototypr",label:r="Support me on Ko-Fi",size:o="w-10 h-10",radius:i="12px"}){return t.createElement("div",{className:"flex justify-start"},t.createElement("div",{class:"btn-container"},t.createElement("a",{title:r,className:(r?"kofi-button ":`rounded-full ${o||"w-10 h-10"} block flex justify-center`)+" rounded-full",style:{backgroundColor:e,borderRadius:i},href:"https://ko-fi.com/"+n,target:"_blank",rel:"noopener noreferrer"},t.createElement("span",{class:"kofitext"},t.createElement("img",{src:"https://ko-fi.com/img/cup-border.png",class:"kofiimg",alt:"Ko-Fi button"}),r||null))))}function Ot({attachOnScroll:e=!1,id:t="prototypr",label:n="Support me",color:r="#00b9fe",textColor:o="#fff"}){function a(){window.innerHeight+window.scrollY>=document.body.scrollHeight/2&&c()}function c(){e&&window.removeEventListener("scroll",a,!1);var i=document.createElement("script");i.setAttribute("src","https://storage.ko-fi.com/cdn/scripts/overlay-widget.js"),i.setAttribute("type","text/javascript"),document.head.appendChild(i),i.onload=()=>{var e=document.createElement("script");e.setAttribute("type","text/javascript"),e.innerHTML=`\n window.kofiWidgetOverlay = kofiWidgetOverlay\n kofiWidgetOverlay.draw('${t}', {\n 'type': 'floating-chat',\n 'floating-chat.donateButton.text': '${n}',\n 'floating-chat.donateButton.background-color': '${r}',\n 'floating-chat.donateButton.text-color': '${o}'\n });\n `,document.head.appendChild(e)}}return i((()=>{if("undefined"!=typeof window&&!window.kofiWidgetOverlay){if(e)return window.addEventListener("scroll",a,!1),()=>{window.removeEventListener("scroll",a,!1)};c()}}),[]),null}function xt({id:e="prototypr"}){return t.createElement("iframe",{id:"kofiframe",src:`https://ko-fi.com/${e}/?hidefeed=true&widget=true&embed=true&preview=true`,style:{border:"none",width:"100%",padding:"4px",background:"#f9f9f9"},height:"712",title:e})}export{Nt as KoFiButton,Ct as KoFiDialog,xt as KoFiPanel,Ot as KoFiWidget};