import{Component as i,options as n,isValidElement as r,Fragment as t}from"preact";import{useMemo as f,useRef as o,useEffect as e}from"preact/hooks";import{effect as u,Signal as a,computed as c,signal as v,batch as s}from"@preact/signals-core";export{Signal,action,batch,computed,createModel,effect,signal,untracked}from"@preact/signals-core";var l,d,h,p="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,m=[],_=[];u(function(){l=this.N})();function g(i,r){n[i]=r.bind(null,n[i]||function(){})}function b(i){if(h){var n=h;h=void 0;n()}h=i&&i.S()}function y(i){var n=this,t=i.data,o=useSignal(t);o.value=t;var e=f(function(){var i=n,t=n.__v;while(t=t.__)if(t.__c){t.__c.__$f|=4;break}var f=c(function(){var i=o.value.value;return 0===i?0:!0===i?"":i||""}),e=c(function(){return!Array.isArray(f.value)&&!r(f.value)}),a=u(function(){this.N=F;if(e.value){var n=f.value;if(i.__v&&i.__v.__e&&3===i.__v.__e.nodeType)i.__v.__e.data=n}}),v=n.__$u.d;n.__$u.d=function(){a();v.call(this)};return[e,f]},[]),a=e[0],v=e[1];return a.value?v.peek():v.value}y.displayName="ReactiveTextNode";Object.defineProperties(a.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:y},props:{configurable:!0,get:function(){var i=this;return{data:{get value(){return i.value}}}}},__b:{configurable:!0,value:1}});g("__b",function(i,n){if("string"==typeof n.type){var r,t=n.props;for(var f in t)if("children"!==f){var o=t[f];if(o instanceof a){if(!r)n.__np=r={};r[f]=o;t[f]=o.peek()}}}i(n)});g("__r",function(i,n){i(n);if(n.type!==t){b();var r,f=n.__c;if(f){f.__$f&=-2;if(void 0===(r=f.__$u))f.__$u=r=function(i,n){var r;u(function(){r=this},{name:n});r.c=i;return r}(function(){var i;if(p)null==(i=r.y)||i.call(r);f.__$f|=1;f.setState({})},"function"==typeof n.type?n.type.displayName||n.type.name:"")}d=f;b(r)}});g("__e",function(i,n,r,t){b();d=void 0;i(n,r,t)});g("diffed",function(i,n){b();d=void 0;var r;if("string"==typeof n.type&&(r=n.__e)){var t=n.__np,f=n.props,o=r.U;if(o)for(var e in o){var u=o[e];if(!(void 0===u||t&&e in t)){u.d();o[e]=void 0}}if(t){if(!o){o={};r.U=o}for(var a in t){var c=o[a],v=t[a];if(void 0===c){c=w(r,a,v,f);o[a]=c}else c.o(v,f)}}}i(n)});function w(i,n,r,t){var f=n in i&&void 0===i.ownerSVGElement,o=v(r);return{o:function(i,n){o.value=i;t=n},d:u(function(){this.N=F;var r=o.value.value;if(t[n]!==r){t[n]=r;if(f)i[n]=r;else if(null!=r&&(!1!==r||"-"===n[4]))i.setAttribute(n,r);else i.removeAttribute(n)}})}}g("unmount",function(i,n){if("string"==typeof n.type){var r=n.__e;if(r){var t=r.U;if(t){r.U=void 0;for(var f in t){var o=t[f];if(o)o.d()}}}var e=n.__np;if(e){var u=n.props;for(var a in e)u[a]=e[a]}n.__np=void 0}else{var c=n.__c;if(c){var v=c.__$u;if(v){c.__$u=void 0;v.d()}}}i(n)});g("__h",function(i,n,r,t){if(t<3||9===t)n.__$f|=2;i(n,r,t)});i.prototype.shouldComponentUpdate=function(i,n){if(this.__R)return!0;var r=this.__$u,t=r&&void 0!==r.s;for(var f in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var o=2&this.__$f;if(!(t||o||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(t||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var e in i)if("__source"!==e&&i[e]!==this.props[e])return!0;for(var u in this.props)if(!(u in i))return!0;return!1};function useSignal(i,n){return f(function(){return v(i,n)},[])}function useComputed(i,n){var r=o(i);r.current=i;d.__$f|=4;return f(function(){return c(function(){return r.current()},n)},[])}var k="undefined"==typeof requestAnimationFrame?setTimeout:function(i){var n=function(){clearTimeout(r);cancelAnimationFrame(t);i()},r=setTimeout(n,35),t=requestAnimationFrame(n)},q=function(i){queueMicrotask(function(){queueMicrotask(i)})};function A(){s(function(){var i;while(i=m.shift())l.call(i)})}function T(){if(1===m.push(this))(n.requestAnimationFrame||k)(A)}function x(){s(function(){var i;while(i=_.shift())l.call(i)})}function F(){if(1===_.push(this))(n.requestAnimationFrame||q)(x)}function useSignalEffect(i,n){var r=o(i);r.current=i;e(function(){return u(function(){this.N=T;return r.current()},n)},[])}function M(i){var n=f(function(){return i()},[]);e(function(){return n[Symbol.dispose]},[n]);return n}export{useComputed,M as useModel,useSignal,useSignalEffect};//# sourceMappingURL=signals.module.js.map
