// @bun
var{defineProperty:J,getOwnPropertyNames:M,getOwnPropertyDescriptor:N}=Object,Q=Object.prototype.hasOwnProperty;function S(q){return this[q]}var W=(q)=>{var B=(K??=new WeakMap).get(q),j;if(B)return B;if(B=J({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var z of M(q))if(!Q.call(B,z))J(B,z,{get:S.bind(q,z),enumerable:!(j=N(q,z))||j.enumerable})}return K.set(q,B),B},K;var U=(q)=>q;function V(q,B){this[q]=U.bind(null,B)}var X=(q,B)=>{for(var j in B)J(q,j,{get:B[j],enumerable:!0,configurable:!0,set:V.bind(B,j)})};var Y=(q,B)=>()=>(q&&(B=q(q=0)),B);var Z=import.meta.require;function $(q,B=250){let j=null,z=null,C=(...D)=>{if(z=D,j!==null)clearTimeout(j);j=setTimeout(()=>{j=null,z=null,q(...D)},B)};if(C.cancel=()=>{if(j!==null)clearTimeout(j),j=null,z=null},C.flush=()=>{if(j!==null&&z!==null){clearTimeout(j),j=null;let D=z;z=null,q(...D)}},C.pending=()=>j!==null,typeof globalThis.onDestroy==="function")globalThis.onDestroy(C.cancel);return C}function O(q,B=250){let j=q(),z=new Set,C=null;(()=>{if(C!==null)clearTimeout(C);C=setTimeout(()=>{C=null;let E=q();if(E!==j)j=E,z.forEach((F)=>F(j))},B)})();let G=()=>{if(C!==null)clearTimeout(C);z.clear()};if(typeof globalThis.onDestroy==="function")globalThis.onDestroy(G);return{get value(){return j},subscribe(E){return z.add(E),()=>{z.delete(E)}}}}function T(q,B=250){let j=null,z=0,C=(...D)=>{let G=Date.now(),E=B-(G-z);if(E<=0){if(j!==null)clearTimeout(j),j=null;z=G,q(...D)}else if(j===null)j=setTimeout(()=>{z=Date.now(),j=null,q(...D)},E)};if(C.cancel=()=>{if(j!==null)clearTimeout(j),j=null},typeof globalThis.onDestroy==="function")globalThis.onDestroy(C.cancel);return C}function x(q=1000,B={}){let j=0,z=null,C=!1,D=new Set,G=()=>{j++,D.forEach((H)=>H(j))},E=()=>{if(C)return;if(C=!0,z=setInterval(G,q),B.immediate)G()},F=()=>{if(!C)return;if(C=!1,z!==null)clearInterval(z),z=null},I=()=>{F(),j=0,D.forEach((H)=>H(j)),E()};E();let L=()=>{F(),D.clear()};if(typeof globalThis.onDestroy==="function")globalThis.onDestroy(L);return{get counter(){return j},pause:F,resume:E,reset:I,subscribe(H){return D.add(H),()=>{D.delete(H)}}}}function R(q,B=1000){let j=null,z=!1,C=new Set,D=(F)=>{if(F!==z)z=F,C.forEach((I)=>I(z))},G=()=>{E(),D(!0),j=setTimeout(()=>{j=null,D(!1),q()},B)},E=()=>{if(j!==null)clearTimeout(j),j=null;D(!1)};if(G(),typeof globalThis.onDestroy==="function")globalThis.onDestroy(E);return{get isPending(){return z},start:G,stop:E,subscribe(F){return C.add(F),()=>{C.delete(F)}}}}export{R as useTimeout,T as useThrottle,x as useInterval,O as useDebouncedValue,$ as useDebounce};
