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