mettle
Version:
A approachable, fast, flexible JavaScript library for building user interfaces.
7 lines (6 loc) • 21.6 kB
JavaScript
/*!
* Mettle.js v1.7.6
* (c) 2021-2025 maomincoding
* Released under the MIT License.
*/
const t=(e,n,o,r)=>{let i;n[0]=0;for(let s=1;s<n.length;s++){const c=n[s++],u=n[s]?(n[0]|=c?1:2,o[n[s++]]):n[++s];3===c?r[0]=u:4===c?r[1]=Object.assign(r[1]||{},u):5===c?(r[1]=r[1]||{})[n[++s]]=u:6===c?r[1][n[++s]]+=u+"":c?(i=e.apply(u,t(e,u,o,["",null])),r.push(i),u[0]?n[0]|=2:(n[s-2]=0,n[s]=i)):r.push(u)}return r},e=new Map,n=function(n){let o=e.get(this);return o||(o=new Map,e.set(this,o)),o=t(this,o.get(n)||(o.set(n,o=function(t){let e,n,o=1,r="",i="",s=[0];const c=t=>{1===o&&(t||(r=r.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?s.push(0,t,r):3===o&&(t||r)?(s.push(3,t,r),o=2):2===o&&"..."===r&&t?s.push(4,t,0):2===o&&r&&!t?s.push(5,0,!0,r):o>=5&&((r||!t&&5===o)&&(s.push(o,0,r,n),o=6),t&&(s.push(o,t,0,n),o=6)),r=""};for(let u=0;u<t.length;u++){u&&(1===o&&c(),c(u));for(let l=0;l<t[u].length;l++)e=t[u][l],1===o?"<"===e?(c(),s=[s],o=3):r+=e:4===o?"--"===r&&">"===e?(o=1,r=""):r=e+r[0]:i?e===i?i="":r+=e:'"'===e||"'"===e?i=e:">"===e?(c(),o=1):o&&("="===e?(o=5,n=r,r=""):"/"===e&&(o<5||">"===t[u][l+1])?(c(),3===o&&(s=s[0]),o=s,(s=s[0]).push(2,0,o),o=0):" "===e||"\t"===e||"\n"===e||"\r"===e?(c(),o=2):r+=e),3===o&&"!--"===r&&(o=4,s=s[0])}return c(),s}(n)),o),arguments,[]),o.length>1?o:o[0]}.bind((function(t,e,n){let o=null,r=null,i=null;for(r in e)"key"===r&&(o=e[r]);return arguments.length>2&&(i=arguments.length>3?Array.prototype.slice.call(arguments,2):n),{tag:t,props:e,children:i,key:o,el:null}})),o=Symbol.for("signals"),r=32;function i(){if(a>1)return void a--;let t,e=!1;for(;void 0!==u;){let n=u;for(u=void 0,f++;void 0!==n;){const o=n._nextBatchedEffect;if(n._nextBatchedEffect=void 0,n._flags&=-3,!(8&n._flags)&&y(n))try{n._callback()}catch(n){e||(t=n,e=!0)}n=o}}if(f=0,a--,e)throw t}function s(t){if(a>0)return t();a++;try{return t()}finally{i()}}let c,u;function l(t){const e=c;c=void 0;try{return t()}finally{c=e}}let a=0,f=0,_=0;function h(t){if(void 0===c)return;let e=t._node;return void 0===e||e._target!==c?(e={_version:0,_source:t,_prevSource:c._sources,_nextSource:void 0,_target:c,_prevTarget:void 0,_nextTarget:void 0,_rollbackNode:e},void 0!==c._sources&&(c._sources._nextSource=e),c._sources=e,t._node=e,c._flags&r&&t._subscribe(e),e):-1===e._version?(e._version=0,void 0!==e._nextSource&&(e._nextSource._prevSource=e._prevSource,void 0!==e._prevSource&&(e._prevSource._nextSource=e._nextSource),e._prevSource=c._sources,e._nextSource=void 0,c._sources._nextSource=e,c._sources=e),e):void 0}function p(t,e){this._value=t,this._version=0,this._node=void 0,this._targets=void 0,this._watched=e?.watched,this._unwatched=e?.unwatched,this.name=e?.name}function d(t,e){return new p(t,e)}function y(t){for(let e=t._sources;void 0!==e;e=e._nextSource)if(e._source._version!==e._version||!e._source._refresh()||e._source._version!==e._version)return!0;return!1}function g(t){for(let e=t._sources;void 0!==e;e=e._nextSource){const n=e._source._node;if(void 0!==n&&(e._rollbackNode=n),e._source._node=e,e._version=-1,void 0===e._nextSource){t._sources=e;break}}}function v(t){let e,n=t._sources;for(;void 0!==n;){const t=n._prevSource;-1===n._version?(n._source._unsubscribe(n),void 0!==t&&(t._nextSource=n._nextSource),void 0!==n._nextSource&&(n._nextSource._prevSource=t)):e=n,n._source._node=n._rollbackNode,void 0!==n._rollbackNode&&(n._rollbackNode=void 0),n=t}t._sources=e}function b(t,e){p.call(this,void 0),this._fn=t,this._sources=void 0,this._globalVersion=_-1,this._flags=4,this._watched=e?.watched,this._unwatched=e?.unwatched,this.name=e?.name}function m(t,e){return new b(t,e)}function w(t){const e=t._cleanup;if(t._cleanup=void 0,"function"==typeof e){a++;const n=c;c=void 0;try{e()}catch(e){throw t._flags&=-2,t._flags|=8,S(t),e}finally{c=n,i()}}}function S(t){for(let e=t._sources;void 0!==e;e=e._nextSource)e._source._unsubscribe(e);t._fn=void 0,t._sources=void 0,w(t)}function x(t){if(c!==this)throw new Error("Out-of-order effect");v(this),c=t,this._flags&=-2,8&this._flags&&S(this),i()}function k(t,e){this._fn=t,this._cleanup=void 0,this._sources=void 0,this._nextBatchedEffect=void 0,this._flags=r,this.name=e?.name}function O(t,e){const n=new k(t,e);try{n._callback()}catch(t){throw n._dispose(),t}const o=n._dispose.bind(n);return o[Symbol.dispose]=o,o}p.prototype.brand=o,p.prototype._refresh=function(){return!0},p.prototype._subscribe=function(t){const e=this._targets;e!==t&&void 0===t._prevTarget&&(t._nextTarget=e,this._targets=t,void 0!==e?e._prevTarget=t:l((()=>{this._watched?.call(this)})))},p.prototype._unsubscribe=function(t){if(void 0!==this._targets){const e=t._prevTarget,n=t._nextTarget;void 0!==e&&(e._nextTarget=n,t._prevTarget=void 0),void 0!==n&&(n._prevTarget=e,t._nextTarget=void 0),t===this._targets&&(this._targets=n,void 0===n&&l((()=>{this._unwatched?.call(this)})))}},p.prototype.subscribe=function(t){return O((()=>{const e=this.value,n=c;c=void 0;try{t(e)}finally{c=n}}),{name:"sub"})},p.prototype.valueOf=function(){return this.value},p.prototype.toString=function(){return this.value+""},p.prototype.toJSON=function(){return this.value},p.prototype.peek=function(){const t=c;c=void 0;try{return this.value}finally{c=t}},Object.defineProperty(p.prototype,"value",{get(){const t=h(this);return void 0!==t&&(t._version=this._version),this._value},set(t){if(t!==this._value){if(f>100)throw new Error("Cycle detected");this._value=t,this._version++,_++,a++;try{for(let t=this._targets;void 0!==t;t=t._nextTarget)t._target._notify()}finally{i()}}}}),b.prototype=new p,b.prototype._refresh=function(){if(this._flags&=-3,1&this._flags)return!1;if((36&this._flags)===r)return!0;if(this._flags&=-5,this._globalVersion===_)return!0;if(this._globalVersion=_,this._flags|=1,this._version>0&&!y(this))return this._flags&=-2,!0;const t=c;try{g(this),c=this;const t=this._fn();(16&this._flags||this._value!==t||0===this._version)&&(this._value=t,this._flags&=-17,this._version++)}catch(t){this._value=t,this._flags|=16,this._version++}return c=t,v(this),this._flags&=-2,!0},b.prototype._subscribe=function(t){if(void 0===this._targets){this._flags|=36;for(let t=this._sources;void 0!==t;t=t._nextSource)t._source._subscribe(t)}p.prototype._subscribe.call(this,t)},b.prototype._unsubscribe=function(t){if(void 0!==this._targets&&(p.prototype._unsubscribe.call(this,t),void 0===this._targets)){this._flags&=-33;for(let t=this._sources;void 0!==t;t=t._nextSource)t._source._unsubscribe(t)}},b.prototype._notify=function(){if(!(2&this._flags)){this._flags|=6;for(let t=this._targets;void 0!==t;t=t._nextTarget)t._target._notify()}},Object.defineProperty(b.prototype,"value",{get(){if(1&this._flags)throw new Error("Cycle detected");const t=h(this);if(this._refresh(),void 0!==t&&(t._version=this._version),16&this._flags)throw this._value;return this._value}}),k.prototype._callback=function(){const t=this._start();try{if(8&this._flags)return;if(void 0===this._fn)return;const t=this._fn();"function"==typeof t&&(this._cleanup=t)}finally{t()}},k.prototype._start=function(){if(1&this._flags)throw new Error("Cycle detected");this._flags|=1,this._flags&=-9,w(this),g(this),a++;const t=c;return c=this,x.bind(this,t)},k.prototype._notify=function(){2&this._flags||(this._flags|=2,this._nextBatchedEffect=u,u=this)},k.prototype._dispose=function(){this._flags|=8,1&this._flags||S(this)},k.prototype.dispose=function(){this._dispose()};function A(t){const e=Object.create(null),n=t.split(",");for(let t=0;t<n.length;t++)e[n[t]]=!0;return function(t){return e[t]}}const P=A("svg,animate,circle,clippath,cursor,image,defs,desc,ellipse,filter,font-face,foreignobject,g,glyph,line,marker,mask,missing-glyph,path,pattern,polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feFlood,feGaussianBlur,feImage,feMerge,feMorphology,feOffset,feSpecularLighting,feTile,feTurbulence,feDistantLight,fePointLight,feSpotLight,linearGradient,stop,radialGradient,animateTransform,animateMotion"),j={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};const M=Object.prototype.hasOwnProperty,z=(t,e)=>M.call(t,e),C=t=>null!==t&&"object"==typeof t,E=t=>null==t,T=(t,e)=>t.tag===e.tag&&t.key===e.key,F=t=>null!=t&&"object"==typeof t&&"tag"in t,N=t=>!F(t)&&!Array.isArray(t);function D(t){console.warn(`[Mettle.js warn]: ${t}`)}function L(t,e){Object.assign(t.style,e)}function W(t,e,n){if("function"!=typeof n)return;const o=e.slice(2).toLowerCase();t.addEventListener(o,n)}function B(t,e,n){if("function"!=typeof n)return;const o=e.slice(2).toLowerCase();t.removeEventListener(o,n)}const $="http://www.w3.org/1999/xlink",R=new Set(["checked","disabled","readonly","selected","multiple","hidden"]);function K(t,e,n){R.has(e)?n?t.setAttribute(e,""):t.removeAttribute(e):e.startsWith("xlink:")?t.setAttributeNS($,e,n):t.setAttribute(e,n)}function G(t,e){e.startsWith("xlink:")?t.removeAttributeNS($,e):t.removeAttribute(e)}const U=document.createElement.bind(document),V=document.createDocumentFragment.bind(document),H=document.createComment.bind(document);function I(t){return"fragment"===t?V():"comment"===t||"null"===t?H(""):P(t)?(e=function(t){return P(t)?"svg":"math"===t?"math":void 0}(t),n=t,document.createElementNS(j[e],n)):U(t);var e,n}function q(t,e){const n=t.children,o=e.children;if(Array.isArray(o))for(let t=0;t<o.length;t++){const e=o[t],r=n[t];F(e)&&(e.el=r.el,q(r,e))}else C(o)&&(o.el=n.el)}const J="1.7.6",Q=A("$ref,$once,$memo");let X=new WeakMap;const Y=new WeakMap;let Z=new WeakMap;function tt(t,e){e.textContent=t}function et(t,e,n){const{tag:o,props:r,children:i}=t;if(!E(o))if("string"==typeof o){const s=I(o);if(t.el=s,!E(r)){const t=Object.keys(r);for(let e=0;e<t.length;e++){const n=t[e],o=r[n],i=C(o);n.startsWith("on")&&W(s,n,o),"function"==typeof o||"key"===n||Q(n)||K(s,n,o),"style"===n&&i&&L(s,o),"$ref"===n&&i&&Y.set(o,s)}}if(!E(i))if(N(i))s&&tt(i,s);else{const t=C(i);if(Array.isArray(i))for(let t=0;t<i.length;t++){const e=i[t];F(e)&&et(e,s)}else t&&et(i,s)}if(n)e.insertBefore(s,n);else{if(!e)return s;e.appendChild(s)}}else if("function"==typeof o){const t=rt(o.call(o,r,o,ot.bind(o)),o);X.set(o,t),et(t,e)}}function nt(t,e,n){const o=t.props||{};if(!z(o,"$once")&&((t,e)=>"function"!=typeof t.tag&&"function"!=typeof e.tag)(t,e))if(T(t,e)){const o=e.el=t.el,r=t.props||{},i=e.props||{},s={},c=Object.keys(i),u=Object.keys(r),l=new Set(c);for(let t=0;t<c.length;t++)s[c[t]]=!0;for(let t=0;t<u.length;t++)s[u[t]]=!0;const a=Object.keys(s);for(let t=0;t<a.length;t++){const e=a[t],n=i[e],s=r[e];if(n===s)continue;if(E(n)){G(o,e);continue}const c=C(n),u="function"==typeof n,l="style"===e;if(u){n.toString()!==s.toString()&&(B(o,e,s),W(o,e,n));continue}if(l&&c){L(o,n);continue}"key"!==e&&!Q(e)&&!u&&K(o,e,n)}for(let t=0;t<u.length;t++){const e=u[t];l.has(e)||G(o,e)}if(z(r,"$memo")){const o=r.$memo;if(n===o[1]&&!o[0])return void(o[2]&&q(t,e))}const f=t.children,_=e.children;Array.isArray(f)&&Array.isArray(_)?function(t,e,n,o){const r=e.length;let i=0,s=t.length-1,c=r-1;for(;i<=s&&i<=c&&T(t[i],e[i]);)nt(t[i],e[i],o),i++;for(;i<=s&&i<=c&&T(t[s],e[c]);)nt(t[s],e[c],o),s--,c--;if(i>s){if(i<=c){const t=c+1,o=t<r?e[t].el:null;for(;i<=c;)n.insertBefore(et(e[i]),o),i++}}else if(i>c)for(;i<=s;)n.removeChild(t[i].el),i++;else{const u=i,l=i,a=new Map;for(i=l;i<=c;i++){const t=e[i];null!=t.key&&a.set(t.key,i)}let f,_=0;const h=c-l+1;let p=!1,d=0;const y=new Array(h);for(i=0;i<h;i++)y[i]=0;for(let r=u;r<=s;r++){if(_>=h){n.removeChild(t[r].el);continue}let i;if(null!==t[r].key)i=a.get(t[r].key);else for(f=l;f<=c;f++)if(0===y[f-l]&&T(t[r],e[f])){i=f;break}void 0===i?n.removeChild(t[r].el):(y[i-l]=r+1,i>d?d=i:p=!0,nt(t[r],e[i],o),_++)}const g=p?function(t){const e=t.slice(),n=[0];let o,r,i,s,c;const u=t.length;for(o=0;o<u;o++){const u=t[o];if(0!==u){if(r=n[n.length-1],t[r]<u){e[o]=r,n.push(o);continue}for(i=0,s=n.length-1;i<s;)c=(i+s)/2|0,t[n[c]]<u?i=c+1:s=c;u<t[n[i]]&&(i>0&&(e[o]=n[i-1]),n[i]=o)}}for(i=n.length,s=n[i-1];i-- >0;)n[i]=s,s=e[s];return n}(y):[];f=g.length-1;for(let t=h-1;t>=0;t--){const o=t+l,i=o+1<r?e[o+1].el:null;0===y[t]?n.insertBefore(et(e[o]),i):p&&(f<0||t!==g[f]?n.insertBefore(e[o].el,i):f--)}}}(f,_,o,n):F(f)&&F(_)?nt(f,_,n):N(f)&&N(_)&&f!==_&&tt(_,o)}else{const n=t.el.parentNode,o=t.el.nextSibling;n.removeChild(t.el),et(e,n,o)}}function ot(t,e){Z.set(this,e),"function"==typeof t&&t()}function rt(t,e){let n=!0;return O((()=>{e.template=t;const o=t();if(n)n=null;else{const t=Z.get(e);!function(t,e,n){try{nt(X.get(t),e,n),X.set(t,e)}catch(t){D(t)}}(e,o,t),Z.has(e)&&(Z=new WeakMap)}})),t()}function it(t){if("string"==typeof t){const e=document.querySelector(t);if(!e){let e=null;return t.startsWith("#")?(e=document.createElement("div"),e.setAttribute("id",t.substring(1,t.length))):t.startsWith(".")?(e=document.createElement("div"),e.setAttribute("class",t.substring(1,t.length))):D(`Failed to mount app: mount target selector "${t}" returned null.`),document.body.insertAdjacentElement("afterbegin",e),e}return e}return t instanceof HTMLElement?t:window.ShadowRoot&&t instanceof window.ShadowRoot&&"closed"===t.mode?(D('mounting on a ShadowRoot with `{mode: "closed"}` may lead to unpredictable bugs.'),null):null}let st=Object.create(null);function ct(t,e){const n=t.tag,o=rt(n.call(n,t.props,n,ot.bind(n)),n),r=it(e);et(o,r),X.set(n,o),st=r,_t()}let ut=[],lt=0,at=0;function ft(t=null){null!==t&&("function"==typeof t?ut.push(t):D("The parameter of onMounted is not a function!"))}function _t(){if(ut.length>0)for(let t=0,e=ut.length;t<e;t++)ut[t]&&ut[t]();at=lt,lt=0,ut=[]}let ht=[];function pt(t=null){null!==t&&("function"==typeof t?(lt+=1,ht.push(t)):D("The parameter of onUnmounted is not a function!"))}function dt(t,e){!function(){if(ht.length>0){for(let t=0;t<at;t++)ht[t]&&ht[t]();ht.splice(0,at)}at=lt}();const n=e?it(e):st;n.innerHTML="";const o=rt(t.call(t,t,ot.bind(t)),t);et(o,n),X.set(t,o),_t()}var yt=Symbol.for("immer-nothing"),gt=Symbol.for("immer-draftable"),vt=Symbol.for("immer-state");function bt(t,...e){throw new Error("Error")}var mt=Object.getPrototypeOf;function wt(t){return!!t&&!!t[vt]}function St(t){return!!t&&(kt(t)||Array.isArray(t)||!!t[gt]||!!t.constructor?.[gt]||Mt(t)||zt(t))}var xt=Object.prototype.constructor.toString();function kt(t){if(!t||"object"!=typeof t)return!1;const e=mt(t);if(null===e)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===xt}function Ot(t,e){0===At(t)?Reflect.ownKeys(t).forEach((n=>{e(n,t[n],t)})):t.forEach(((n,o)=>e(o,n,t)))}function At(t){const e=t[vt];return e?e.type_:Array.isArray(t)?1:Mt(t)?2:zt(t)?3:0}function Pt(t,e){return 2===At(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function jt(t,e,n){const o=At(t);2===o?t.set(e,n):3===o?t.add(n):t[e]=n}function Mt(t){return t instanceof Map}function zt(t){return t instanceof Set}function Ct(t){return t.copy_||t.base_}function Et(t,e){if(Mt(t))return new Map(t);if(zt(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=kt(t);if(!0===e||"class_only"===e&&!n){const e=Object.getOwnPropertyDescriptors(t);delete e[vt];let n=Reflect.ownKeys(e);for(let o=0;o<n.length;o++){const r=n[o],i=e[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(e[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:t[r]})}return Object.create(mt(t),e)}{const e=mt(t);if(null!==e&&n)return{...t};const o=Object.create(e);return Object.assign(o,t)}}function Tt(t,e=!1){return Nt(t)||wt(t)||!St(t)||(At(t)>1&&(t.set=t.add=t.clear=t.delete=Ft),Object.freeze(t),e&&Object.entries(t).forEach((([t,e])=>Tt(e,!0)))),t}function Ft(){bt()}function Nt(t){return Object.isFrozen(t)}var Dt,Lt={};function Wt(t){const e=Lt[t];return e||bt(0),e}function Bt(){return Dt}function $t(t,e){e&&(Wt("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Rt(t){Kt(t),t.drafts_.forEach(Ut),t.drafts_=null}function Kt(t){t===Dt&&(Dt=t.parent_)}function Gt(t){return Dt={drafts_:[],parent_:Dt,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ut(t){const e=t[vt];0===e.type_||1===e.type_?e.revoke_():e.revoked_=!0}function Vt(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return void 0!==t&&t!==n?(n[vt].modified_&&(Rt(e),bt()),St(t)&&(t=Ht(e,t),e.parent_||qt(e,t)),e.patches_&&Wt("Patches").generateReplacementPatches_(n[vt].base_,t,e.patches_,e.inversePatches_)):t=Ht(e,n,[]),Rt(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==yt?t:void 0}function Ht(t,e,n){if(Nt(e))return e;const o=e[vt];if(!o)return Ot(e,((r,i)=>It(t,o,e,r,i,n))),e;if(o.scope_!==t)return e;if(!o.modified_)return qt(t,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const e=o.copy_;let r=e,i=!1;3===o.type_&&(r=new Set(e),e.clear(),i=!0),Ot(r,((r,s)=>It(t,o,e,r,s,n,i))),qt(t,e,!1),n&&t.patches_&&Wt("Patches").generatePatches_(o,n,t.patches_,t.inversePatches_)}return o.copy_}function It(t,e,n,o,r,i,s){if(wt(r)){const s=Ht(t,r,i&&e&&3!==e.type_&&!Pt(e.assigned_,o)?i.concat(o):void 0);if(jt(n,o,s),!wt(s))return;t.canAutoFreeze_=!1}else s&&n.add(r);if(St(r)&&!Nt(r)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Ht(t,r),e&&e.scope_.parent_||"symbol"==typeof o||!Object.prototype.propertyIsEnumerable.call(n,o)||qt(t,r)}}function qt(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Tt(e,n)}var Jt={get(t,e){if(e===vt)return t;const n=Ct(t);if(!Pt(n,e))return function(t,e,n){const o=Yt(e,n);return o?"value"in o?o.value:o.get?.call(t.draft_):void 0}(t,n,e);const o=n[e];return t.finalized_||!St(o)?o:o===Xt(t.base_,e)?(te(t),t.copy_[e]=ee(o,t)):o},has:(t,e)=>e in Ct(t),ownKeys:t=>Reflect.ownKeys(Ct(t)),set(t,e,n){const o=Yt(Ct(t),e);if(o?.set)return o.set.call(t.draft_,n),!0;if(!t.modified_){const o=Xt(Ct(t),e),s=o?.[vt];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(((r=n)===(i=o)?0!==r||1/r==1/i:r!=r&&i!=i)&&(void 0!==n||Pt(t.base_,e)))return!0;te(t),Zt(t)}var r,i;return t.copy_[e]===n&&(void 0!==n||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty:(t,e)=>(void 0!==Xt(t.base_,e)||e in t.base_?(t.assigned_[e]=!1,te(t),Zt(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0),getOwnPropertyDescriptor(t,e){const n=Ct(t),o=Reflect.getOwnPropertyDescriptor(n,e);return o?{writable:!0,configurable:1!==t.type_||"length"!==e,enumerable:o.enumerable,value:n[e]}:o},defineProperty(){bt()},getPrototypeOf:t=>mt(t.base_),setPrototypeOf(){bt()}},Qt={};function Xt(t,e){const n=t[vt];return(n?Ct(n):t)[e]}function Yt(t,e){if(!(e in t))return;let n=mt(t);for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t)return t;n=mt(n)}}function Zt(t){t.modified_||(t.modified_=!0,t.parent_&&Zt(t.parent_))}function te(t){t.copy_||(t.copy_=Et(t.base_,t.scope_.immer_.useStrictShallowCopy_))}Ot(Jt,((t,e)=>{Qt[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),Qt.deleteProperty=function(t,e){return Qt.set.call(this,t,e,void 0)},Qt.set=function(t,e,n){return Jt.set.call(this,t[0],e,n,t[0])};function ee(t,e){const n=Mt(t)?Wt("MapSet").proxyMap_(t,e):zt(t)?Wt("MapSet").proxySet_(t,e):function(t,e){const n=Array.isArray(t),o={type_:n?1:0,scope_:e?e.scope_:Bt(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=Jt;n&&(r=[o],i=Qt);const{revoke:s,proxy:c}=Proxy.revocable(r,i);return o.draft_=c,o.revoke_=s,c}(t,e);return(e?e.scope_:Bt()).drafts_.push(n),n}function ne(t){if(!St(t)||Nt(t))return t;const e=t[vt];let n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Et(t,e.scope_.immer_.useStrictShallowCopy_)}else n=Et(t,!0);return Ot(n,((t,e)=>{jt(n,t,ne(e))})),e&&(e.finalized_=!1),n}var oe=new class{autoFreeze_;useStrictShallowCopy_;produce;produceWithPatches;constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,e,n)=>{if("function"==typeof t&&"function"!=typeof e){const n=e;e=t;const o=this;return function(t=n,...r){return o.produce(t,(t=>e.call(this,t,...r)))}}let o;if("function"!=typeof e&&bt(),void 0!==n&&"function"!=typeof n&&bt(),St(t)){const r=Gt(this),i=ee(t,void 0);let s=!0;try{o=e(i),s=!1}finally{s?Rt(r):Kt(r)}return $t(r,n),Vt(o,r)}if(!t||"object"!=typeof t){if(o=e(t),void 0===o&&(o=t),o===yt&&(o=void 0),this.autoFreeze_&&Tt(o,!0),n){const e=[],r=[];Wt("Patches").generateReplacementPatches_(t,o,e,r),n(e,r)}return o}bt(0)},this.produceWithPatches=(t,e)=>{if("function"==typeof t)return(e,...n)=>this.produceWithPatches(e,(e=>t(e,...n)));let n,o;return[this.produce(t,e,((t,e)=>{n=t,o=e})),n,o]},"boolean"==typeof t?.autoFreeze&&this.setAutoFreeze(t.autoFreeze),"boolean"==typeof t?.useStrictShallowCopy&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){St(t)||bt(),wt(t)&&(t=function(t){wt(t)||bt(0);return ne(t)}(t));const e=Gt(this),n=ee(t,void 0);return n[vt].isManual_=!0,Kt(e),n}finishDraft(t,e){const n=t&&t[vt];n&&n.isManual_||bt();const{scope_:o}=n;return $t(o,e),Vt(void 0,o)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const o=e[n];if(0===o.path.length&&"replace"===o.op){t=o.value;break}}n>-1&&(e=e.slice(n+1));const o=Wt("Patches").applyPatches_;return wt(t)?o(t,e):this.produce(t,(t=>o(t,e)))}},re=oe.produce;export{s as batch,m as computed,ct as createApp,Y as domInfo,O as effect,n as html,ft as onMounted,pt as onUnmounted,re as produce,dt as resetView,d as signal,l as untracked,J as version};