import{Signal as n,signal as t,computed as e,effect as o}from"@preact/signals-core";import{version as i,useRef as r,useMemo as u,useEffect as f,useState as s,useLayoutEffect as c}from"react";import{useSyncExternalStore as l}from"use-sync-external-store/shim/index.js";const[a]=i.split(".").map(Number),d=[],m=Symbol.for(a>=19?"react.transitional.element":"react.element"),p="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__;function b(t){if("function"!=typeof t)return t;else return function(e,o,...i){if("string"==typeof e&&o)for(let t in o){let e=o[t];if("children"!==t&&e instanceof n)o[t]=e.value}return t.call(t,e,o,...i)}}const y=Symbol.dispose||Symbol.for("Symbol.dispose");let g;function v(n,t){const e=t.effect.S();g=t;return h.bind(t,n,e)}function h(n,t){t();g=n}const w=()=>{},_={o:0,effect:{s:void 0,c(){},S:()=>w,d(){}},subscribe:()=>w,getSnapshot:()=>0,S(){},f(){},[y](){}},S=Promise.prototype.then.bind(Promise.resolve());let x;function j(){if(!x)x=S(P)}function P(){var n;x=void 0;null==(n=g)||n.f()}const $="undefined"!=typeof window?c:f;function k(n=0,t){j();const e=r();if(null==e.current)if("undefined"==typeof window)e.current=_;else e.current=function(n,t){let e,i,r,u=0,f=o(function(){e=this},{name:t||"Component"});e.c=function(){u=u+1|0;if(p){var n;null==(n=e.y)||n.call(e)}if(r)r()};return{o:n,effect:e,subscribe(n){r=n;return function(){u=u+1|0;r=void 0;f()}},getSnapshot:()=>u,S(){if(null==g){i=v(void 0,this);return}const n=g.o,t=this.o;if(0==n&&0==t||0==n&&1==t){g.f();i=v(void 0,this)}else if(1==n&&0==t||2==n&&0==t);else i=v(g,this)},f(){const n=i;i=void 0;null==n||n()},[y](){this.f()}}}(n,t);const i=e.current;l(i.subscribe,i.getSnapshot,i.getSnapshot);i.S();if(0===n)$(P);return i}Object.defineProperties(n.prototype,{$$typeof:{configurable:!0,value:m},type:{configurable:!0,value:function({data:n}){const t=k(1);try{return n.value}finally{t.f()}}},props:{configurable:!0,get(){const n=this;return{data:{get value(){return n.value}}}}},ref:{configurable:!0,value:null}});function C(n,t){return k(n,t)}function useSignal(n,e){return u(()=>t(n,e),d)}function useComputed(n,t){const o=r(n);o.current=n;return u(()=>e(()=>o.current(),t),d)}function useSignalEffect(n,t){const e=r(n);e.current=n;f(()=>o(function(){return e.current()},t),d)}function N(n){const[t]=s(()=>n());f(()=>t[Symbol.dispose],[t]);return t}export{k as _useSignalsImplementation,j as ensureFinalCleanup,useComputed,N as useModel,useSignal,useSignalEffect,C as useSignals,b as wrapJsx};//# sourceMappingURL=runtime.mjs.map
