Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

doura

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doura - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

6

dist/doura.d.ts

@@ -133,2 +133,6 @@ export declare type Action = ModifyAction | PatchAction | ReplaceAction;

export declare function markRaw<T extends object>(value: T): T & {
[RawSymbol]?: true;
};
declare interface ModelAction {

@@ -261,2 +265,4 @@ name: string;

declare const RawSymbol: unique symbol;
declare const enum ReactiveFlags {

@@ -263,0 +269,0 @@ SKIP = "__r_skip",

2

dist/doura.esm-browser.prod.js

@@ -1,1 +0,1 @@

const t=()=>{},e=Object.create(null),s=[],n=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),o=Object.prototype.toString,c=t=>o.call(t),a=Array.isArray,l=t=>"[object Map]"===c(t),h=t=>"[object Set]"===c(t),u=t=>"function"==typeof t,f=t=>"string"==typeof t,p=t=>"symbol"==typeof t,d=t=>null!==t&&"object"==typeof t,_=t=>c(t).slice(8,-1),y=t=>"[object Object]"===c(t),g=t=>f(t)&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,b=(t,e)=>Object.is(t,e),w=(t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})};function v(t,e){if(!t)throw new Error(`[Doura] ${e||""}`)}const S=Array.prototype.slice;const m=Object.prototype.propertyIsEnumerable;function O(t){return Array.isArray(t)?S.call(t):l(t)?new Map(t):h(t)?new Set(t):Object.getPrototypeOf(t)===Object.prototype?function(t){const e={},s=x(t);for(let n=0;n<s.length;n++){const i=s[n],r=t[i];m.call(t,i)?e[i]=r:Object.defineProperty(e,i,{configurable:!0,writable:!0,enumerable:!1,value:r})}return e}(t):function(t){const e=Object.getOwnPropertyDescriptors(t),s=x(e);for(let n=0;n<s.length;n++){const i=s[n],r=e[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(e[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:t[i]})}return Object.create(Object.getPrototypeOf(t),e)}(t)}const x="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?t=>Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)):Object.getOwnPropertyNames;function j(t,e,s=!1){y(t)?(s?Object.keys:x)(t).forEach((n=>{s&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach(((s,n)=>e(n,s,t)))}function E(t,e,s){l(t)?t.set(e,s):h(t)?(t.delete(e),t.add(s)):t[e]=s}const P=t=>t;function M(t,...e){console.warn(`[Doura warn] ${t}`,...e)}function R(t){switch(_(t)){case"Object":return 1;case"Array":return 2;case"Set":return 3;case"Map":return 4;default:return 0}}function C(t){return!!t&&!!t.__r_state}function D(t){const e=I(t);return e?D(e.base):t}function I(t){return t&&t.__r_state}function A(t){return t.copy||t.base}function $(t){t.modified||(t.modified=!0,t.parent&&$(t.parent))}let T;class k{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&T&&(this.parent=T,this.index=(T.scopes||(T.scopes=[])).push(this)-1)}run(t){if(this.active){const e=T;try{return T=this,t()}finally{T=e}}}on(){T=this}off(){T=this.parent}stop(t){if(this.active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.active=!1}}}const L=t=>{const e=new Set(t);return e.w=0,e.n=0,e},N=t=>(t.w&K)>0,V=t=>(t.n&K)>0,H=new WeakMap,U=new WeakMap;let X=0,K=1;let z;const Y=Symbol(""),J=Symbol("");let F=0;class W{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.id=F++,this.deps=[],this.active=!0,this.parent=void 0,function(t,e=T){e&&e.active&&e.effects.push(t)}(this,s)}run(){if(!this.active)return this.fn();let t=z;const e=q;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=z,z=this,q=!0,K=1<<++X,X<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=K})(this):B(this),this.fn()}finally{X<=30&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];N(i)&&!V(i)?i.delete(t):e[s++]=i,i.w&=~K,i.n&=~K}e.length=s}})(this),K=1<<--X,z=this.parent,q=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){z===this?this.deferStop=!0:this.active&&(B(this),this.onStop&&this.onStop(),this.active=!1)}}function B(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let q=!0;const G=[];function Q(){G.push(q),q=!1}function Z(){const t=G.pop();q=void 0===t||t}function tt(t,e,s){if(q&&z){let e=H.get(t);e||H.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=L()),st(n)}}function et(t){if(q&&z){const e=t.__r_state;if(!e)return;let s=U.get(e);s||U.set(e,s=L()),st(s)}}function st(t){let e=!1;X<=30?V(t)||(t.n|=K,e=!N(t)):e=!t.has(z),e&&(t.add(z),z.deps.push(t))}function nt(t){const e=U.get(t);if(e){const t=[...e];for(const e of t)e.view&&(e.view.mightChange=!0)}}function it(t,e,s,n,i){var r;const o=H.get(t),c=t.base;let h=[];if(o)if("clear"===e)h=[...o.values()];else if("length"===s&&a(c))o.forEach(((t,e)=>{("length"===e||e>=n)&&h.push(t)}));else switch(void 0!==s&&h.push(o.get(s)),e){case"add":a(c)?g(s)&&h.push(o.get("length")):(h.push(o.get(Y)),l(c)&&h.push(o.get(J)));break;case"delete":a(c)||(h.push(o.get(Y)),l(c)&&h.push(o.get(J)));break;case"set":l(c)&&h.push(o.get(Y))}if(1===h.length)h[0]&&rt(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);rt(L(t))}const u=null===(r=t.root)||void 0===r?void 0:r.listeners;u&&u.length&&u.forEach((t=>t()))}function rt(t){const e=a(t)?t:[...t];for(const s of e)s.view&&ot(s);for(const s of e)s.view||ot(s)}function ot(t){(t!==z||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}class ct{constructor(t,{disableCache:e=!1}){this.dep=void 0,this.mightChange=!1,this.dirty=!0,this.effect=new W(t,(()=>{this.dirty||(this.dirty=!0,function(t){(t=D(t)).dep&&rt(t.dep)}(this))})),this.effect.view=this,this.effect.active=this._cacheable=!e}get value(){const t=D(this);return function(t){q&&z&&st((t=D(t)).dep||(t.dep=L()))}(t),!t.dirty&&t._cacheable||(t.dirty=!1,t._value=t.effect.run()),t._value}set value(t){}}const at=new Set(["__proto__"]),lt=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(p));function ht(t){t.copy||(t.copy=O(t.base))}function ut(t,e){const s=t.__r_state;return(s?A(s):t)[e]}const ft=_t(),pt=dt();function dt(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=I(this),n=A(s);for(let e=0,r=this.length;e<r;e++)tt(s,0,e+"");const i=n[e](...t);return-1===i||!1===i?n[e](...t.map(D)):i}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){Q();const s=A(I(this))[e].apply(this,t);return Z(),s}})),t}function _t(){return function(t,e,s){const n=A(t);if("__r_isReactive"===e)return!0;if("__r_state"===e&&s===Ct.get(t))return t;if(a(n)&&r(pt,e))return Reflect.get(pt,e,s);let i=Reflect.get(n,e,s);return(p(e)?lt.has(e):at.has(e))?i:(tt(t,0,e),r(n,e)?(t.disposed||!d(i)||(C(i)||(ht(t),i=t.copy[e]=It(i,t)),et(i)),i):i)}}function yt(){return function(t,e,s,n){const i=A(t),o=ut(i,e),c=a(i)&&g(e)?Number(e)<i.length:r(i,e);if(!t.modified){const n=null==o?void 0:o.__r_state;if(n&&n.base===s)return t.copy[e]=s,!0;if(b(s,o)&&(void 0!==s||r(t.base,e)))return!0;ht(t),$(t)}return b(t.copy[e],s)&&(void 0!==s||e in t.copy)||(t.copy[e]=s,t===I(n)&&(c?b(s,o)||it(t,"set",e,s):it(t,"add",e,s),function(t){let e=t;for(;e;)nt(e),e=e.parent}(t))),!0}}const gt={get:ft,set:yt(),deleteProperty:function(t,e){const s=r(A(t),e);if((void 0!==ut(t.base,e)||e in t.base)&&(ht(t),$(t)),t.copy){const n=delete t.copy[e];return n&&s&&it(t,"delete",e,void 0),n}return!0},has:function(t,e){const s=A(t),n=Reflect.has(s,e);return p(e)&&lt.has(e)||tt(t,0,e),n},ownKeys:function(t){const e=A(t);return tt(t,0,a(e)?"length":Y),Reflect.ownKeys(e)},setPrototypeOf:function(t,e){const s=Reflect.setPrototypeOf(t.base,e);return s&&t.copy&&Reflect.setPrototypeOf(t.copy,e),s},getOwnPropertyDescriptor:function(t,e){const s=A(t),n=Reflect.getOwnPropertyDescriptor(s,e);return n?{writable:!0,configurable:!a(s)||"length"!==e,enumerable:n.enumerable,value:s[e]}:n}};function bt(t){t.copy||(t.copy=new Set,t.base.forEach((e=>{if(d(e)){const s=It(e,t);et(s),e!==s&&t.drafts.set(e,s),t.copy.add(s)}else t.copy.add(e)})))}function wt(t){1===t.type?function(t){t.copy||(t.copy=new Map(t.base))}(t):bt(t)}function vt(t){const e=this.__r_state,s=A(e);if(tt(e,0,t),!s.has(t))return;let n=s.get(t);return d(n)?(C(n)||(wt(e),n=It(n,e),e.copy.set(t,n)),et(n),n):n}function St(t,e){const s=this.__r_state,n=A(s),i=n.has(t),r=n.get(t),o=()=>{wt(s),$(s),s.copy.set(t,e)};return i?b(e,r)||(o(),it(s,"set",t,e)):(o(),it(s,"add",t,e)),this}function mt(t){const e=this.__r_state;return A(e).has(t)||(bt(e),$(e),e.copy.add(t),it(e,"add",t,t)),this}function Ot(t){const e=this.__r_state;return tt(e,0,t),e.copy?!!e.copy.has(t)||2===e.type&&(e.drafts.has(t)&&e.drafts.has(e.drafts.get(t))):e.base.has(t)}function xt(t){const e=this.__r_state,s=A(e),n=s.has(t);"get"in s&&s.get(t),wt(e),$(e);let i=e.copy.delete(t);return 2!==e.type||i||(i=!!e.drafts.has(t)&&e.drafts.delete(e.drafts.get(t))),n&&it(e,"delete",t,void 0),i}function jt(){const t=this.__r_state,e=A(t),s=0!==e.size,n=e.clear();return s&&(wt(t),$(t),t.copy.clear(),it(t,"clear",void 0,void 0)),n}function Et(){const t={get:vt,get size(){return tt(t=this.__r_state,0,Y),A(t).size;var t},has:Ot,add:mt,set:St,delete:xt,clear:jt,keys(){const t=this.__r_state;return 1===t.type?function(t){return tt(t,0,J),A(t).keys()}(t):function(t){return tt(t,0,Y),bt(t),t.copy.values()}(t)},forEach(t,e){const s=this.__r_state;1===s.type?function(t,e,s,n){tt(e,0,Y),A(e).forEach(((i,r)=>s.call(n,e.proxy.get(r),r,t)))}(this,s,t,e):function(t,e,s,n){const i=e.proxy.values();let r=i.next();for(;!r.done;)s.call(n,r.value,r.value,t),r=i.next()}(this,s,t,e)}};return["values","entries",Symbol.iterator].forEach((e=>{t[e]=function(t){return function(...e){const s=this.__r_state,n=1===s.type,i="entries"===t||t===Symbol.iterator&&n;if(n){const t=s.proxy.keys();return{next(){const{value:e,done:n}=t.next(),r=s.proxy.get(e);return n?{value:r,done:n}:{value:i?[e,r]:r,done:n}},[Symbol.iterator](){return this}}}return tt(s,0,Y),bt(s),s.copy[t](...e)}}(e)})),[t]}const[Pt]=Et();function Mt(){const t=Pt;return(e,s,n)=>{if("__r_isReactive"===s)return!0;if("__r_state"===s)return e;const i=A(e);return Reflect.get(r(t,s)&&s in i?t:i,s,n)}}const Rt={get:Mt()};const Ct=new WeakMap;let Dt=0;function It(t,e){const s=R(t);if(0===s)return t;if(t.__r_skip||!Object.isExtensible(t))return t;if(t.__r_state)return t;let n={type:0,id:Dt++,root:null,parent:e,base:t,proxy:null,copy:null,modified:!1,disposed:!1,listeners:[],children:[]},i=n,r=gt;3===s?(n.type=2,n.drafts=new Map,i=new Set,r=Rt):4===s?(n.type=1,i=new Map,r=Rt):2===s&&(i=[]),i!==n&&Object.keys(n).forEach((t=>{Object.defineProperty(i,t,{configurable:!0,enumerable:!0,writable:!0,value:n[t]})}));const o=new Proxy(i,r);return i.proxy=o,e?(i.root=e.root,e.children.push(i)):i.root=i,Ct.set(i,o),i.proxy}function At(t,e){const s=function(t,{copies:e,snapshots:s}){const n=t=>{switch(R(t)){case 1:case 2:return u;case 4:case 3:return h;default:throw new Error("Unpected Error. Please file an issue on https://github.com/dourajs/doura")}},i=t=>{if(!d(t))return t;if(C(t)){let i=s.get(t);if(!i){const r=e.get(t.__r_state);s.set(t,i=new Proxy(r,n(r)))}return i}return t},o=t=>function(...e){const s=this.__r_raw,n="entries"===t||t===Symbol.iterator&&l(this),r=s[t](...e);return{next(){const{value:t,done:e}=r.next();return e?{value:i(t),done:e}:{value:n?[t[0],i(t[1])]:i(t),done:e}},[Symbol.iterator](){return this}}},c=t=>function(...e){return this.__r_raw[t](...e)},a={get size(){return this.__r_raw.size},get(t){const e=this.__r_raw;if(e.has(t))return i(e.get(t))},forEach(t,e){const s=this.__r_raw;return s.forEach(((n,r)=>(n=i(n),t.call(e,n,l(s)?r:n,s))))}};["has","add","set","delete","clear"].forEach((t=>{a[t]=c(t)})),["keys","values","entries",Symbol.iterator].forEach((t=>{a[t]=o(t)}));const h={get:(t,e,s)=>"__r_raw"===e?t:Reflect.get(r(a,e)&&e in t?a:t,e,s)},u={get:(t,e,s)=>i(Reflect.get(t,e,s))};return n(t)}(t,e);if(C(t)){return new Proxy(e.copies.get(t.__r_state),s)}return new Proxy(t,s)}function $t(t,e,s){if(!d(t))return t;const n=function(t,e){const s=new Map,n={copies:s,snapshots:e||new Map},i=n.snapshots,r=[t.__r_state];for(;r.length;){const t=r.pop();let e;t.modified?(e=O(t.copy),Tt(t,e),i.delete(t.proxy)):e=At(t.base,n),s.set(t,e);for(const s of t.children)r.push(s)}return n}(e,s);return At(t,n)}function Tt(t,e){t.modified=!1,t.base=e}function kt(t,e){const s=t.createView((function(){return e(this,this.$actions)})),n=s.getSnapshot;return n.destory=function(){s.effect.stop();const e=t.effectScope.effects.indexOf(s.effect);e>=0&&t.effectScope.effects.splice(e,1)},n}const Lt=n({$name:t=>t.name,$rawState:t=>t.getState(),$state:t=>t.stateValue,$actions:t=>t.actions,$views:t=>t.views,$patch:t=>t.patch,$onAction:t=>t.onAction,$subscribe:t=>t.subscribe,$isolate:t=>t.isolate,$getApi:t=>t.getApi,$createView:t=>kt.bind(null,t)}),Nt=t=>({_:e},s)=>{const{actions:n,views:i,accessCache:o,ctx:c}=e;let a;if(a=t?e.getState():e.stateValue,"$"!==s[0]){const t=o[s];if(void 0!==t)switch(t){case 0:return a[s];case 2:return i[s];case 1:return n[s];case 3:return c[s]}else{if(r(a,s))return o[s]=0,a[s];if(r(c,s))return o[s]=3,c[s]}}const l=Lt[s];return l?l(e):r(c,s)?(o[s]=3,c[s]):void((t=>"_"===t||"$"===t)(s[0])&&r(a,s)&&M(`Property ${JSON.stringify(s)} must be accessed via $state because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`))},Vt=({_:t},e,s)=>{const{ctx:n,actions:i,views:o,accessContext:c,stateRef:{value:a}}=t;return r(a,e)?1!==c&&(a[e]=s,!0):!r(i,e)&&(!r(o,e)&&("$state"===e?"bigint"!=typeof s&&"symbol"!=typeof s&&(t.replace(s),!0):("$"!==e[0]||!r(Lt,e))&&(n[e]=s,!0)))},Ht={get:Nt(!1),set:Vt},Ut={get:Nt(!0),set:Vt};function Xt(t,e,...s){console.error(t)}let Kt=!1,zt=!1;const Yt=[];let Jt=0;const Ft=[];let Wt=null,Bt=0;const qt=[];let Gt=null,Qt=0;const Zt=Promise.resolve();let te=null,ee=null;function se(t){const e=te||Zt;return t?e.then(this?t.bind(this):t):e}function ne(t){Yt.length&&Yt.includes(t,Kt&&t.allowRecurse?Jt+1:Jt)||t===ee||(null==t.id?Yt.push(t):Yt.splice(function(t){let e=Jt+1,s=Yt.length;for(;e<s;){const n=e+s>>>1;oe(Yt[n])<t?e=n+1:s=n}return e}(t.id),0,t),Kt||zt||(zt=!0,te=Zt.then(ce)))}function ie(t){const e=Yt.indexOf(t);e>=Jt&&Yt.splice(e,1)}function re(t,e=null){if(Ft.length){for(ee=e,Wt=[...new Set(Ft)],Ft.length=0,Bt=0;Bt<Wt.length;Bt++)Wt[Bt]();Wt=null,Bt=0,ee=null,re(t,e)}}const oe=t=>null==t.id?1/0:t.id;function ce(t){zt=!1,Kt=!0,re(t),Yt.sort(((t,e)=>oe(t)-oe(e)));try{for(Jt=0;Jt<Yt.length;Jt++){const t=Yt[Jt];if(t&&!1!==t.active){0;try{t()}catch(e){Xt(e)}}}}finally{Jt=0,Yt.length=0,function(t){if(re(),qt.length){const t=[...new Set(qt)];if(qt.length=0,Gt)return void Gt.push(...t);for(Gt=t,Gt.sort(((t,e)=>oe(t)-oe(e))),Qt=0;Qt<Gt.length;Qt++)Gt[Qt]();Gt=null,Qt=0}}(),Kt=!1,te=null,(Yt.length||Ft.length||qt.length)&&ce(t)}}var ae;function le(t,e){const s=Object.keys(e);s.length&&s.forEach((s=>{r(t,s)&&y(e[s])?le(t[s],e[s]):t[s]=e[s]}))}function he(t){t.dirty=!0}!function(t){t.REPLACE="replace",t.MODIFY="modify",t.PATCH="patch"}(ae||(ae={}));class ue{constructor(e,{name:s,initState:n}){var i;this.viewInstances=[],this._actionDepth=0,this._api=null,this._actionListeners=new Set,this._subscribers=new Set,this._depListenersHandlers=[],this._watchStateChange=!0,this._destroyed=!1,this._lastDraftToSnapshot=new Map,this.patch=this.patch.bind(this),this.onAction=this.onAction.bind(this),this.subscribe=this.subscribe.bind(this),this.isolate=this.isolate.bind(this),this.getApi=this.getApi.bind(this),this._update=this._update.bind(this),this.options=e,this.name=s||"",this._isDispatching=!1,this._initState=n||e.state,this.stateRef=It({value:this._initState}),this._update.__name=s,this._draftListenerHandler=function(e,s){const n=e.__r_state;return n.disposed?t:(n.listeners.push(s),()=>{const t=n.listeners.indexOf(s);t>=0&&n.listeners.splice(t,1)})}(this.stateRef,(()=>{this._watchStateChange&&ne(this._update)})),this._setState(this._initState),this.actions=Object.create(null),this.views=Object.create(null),this.accessContext=0,this.ctx={},w(this.ctx,"_",this),this.accessCache=Object.create(null),this.proxy=new Proxy(this.ctx,Ht),this.publicInst=new Proxy(this.ctx,Ut),this.effectScope=new k(i),this._initActions(),this._initViews()}patch(t){y(t)&&this._currentState&&(this._watchStateChange=!1,le(this.proxy.$state,t),this._watchStateChange=!0,this.dispatch({type:ae.PATCH,args:{patch:t}}))}replace(t){if(d(t)){this._watchStateChange=!1,this.stateRef.value=t,this._watchStateChange=!0;for(const t of this.viewInstances)t.effect.scheduler();this.dispatch({type:ae.REPLACE,payload:t})}else M(`replace argument should be an object, but receive a ${Object.prototype.toString.call(t)}`)}getState(){return this._currentState}getApi(){if(null===this._api){const t=this._api=Object.assign(Object.assign({},this._currentState),this.views);for(const e of Object.keys(this.actions))w(t,e,this.actions[e])}return this._api}onAction(t){return this._actionListeners.add(t),()=>{this._actionListeners.delete(t)}}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}isolate(t){Q();const e=t(this.stateValue);return Z(),e}depend(t){this._depListenersHandlers.push(t.subscribe((t=>{this._triggerListener(Object.assign(Object.assign({},t),{model:this.proxy}))})))}createView(t){let e;return this.effectScope.run((()=>{e=function(t,e={}){return new ct(t,e)}((()=>{const n=this.accessContext;this.accessContext=1;const i=e.__externalArgs;try{return t.call(this.proxy,this.proxy,...i||s)}finally{this.accessContext=n}}))})),e.getSnapshot=()=>{const t=e.value;return e.mightChange?(e.mightChange=!1,e.__snapshot=$t(t,this.stateRef.value)):e.__pre!==t&&(e.__snapshot=$t(t,this.stateRef.value)),e.__pre=t,e.__snapshot},this.viewInstances.push(e),e}reducer(t,e){switch(e.type){case ae.MODIFY:case ae.PATCH:{const t=new Map(this._lastDraftToSnapshot);return this._lastDraftToSnapshot=t,$t(this.stateRef.value,this.stateRef.value,this._lastDraftToSnapshot)}case ae.REPLACE:return e.payload;default:return t}}dispatch(t){if(void 0===t.type)return t;if(this._isDispatching)return t;let e;try{this._isDispatching=!0,e=this.reducer(this._currentState,t)}finally{this._isDispatching=!1}return e!==this._currentState&&(this._setState(e),this._triggerListener(Object.assign({type:t.type,model:this.proxy,target:this.proxy},t.args))),t}destroy(){this._destroyed=!0,this._api=null,this._lastDraftToSnapshot.clear(),this._currentState=null,this.stateRef={value:null},this._subscribers.clear(),this.effectScope.stop();for(const t of this._depListenersHandlers)t();this._draftListenerHandler()}_setState(t){this._api=null,this._currentState=t,this.stateValue=this.stateRef.value}_update(){!this._destroyed&&function(t){return t.__r_state.modified}(this.stateRef)&&(this.dispatch({type:ae.MODIFY}),function(t){const e=t.__r_state;e&&(e.modified=!1)}(this.stateRef))}_triggerListener(t){for(const e of this._subscribers)e(t)}_initActions(){const t=this.options.actions;if(t)for(const e of Object.keys(t)){this.accessCache[e]=1;const s=t[e];Object.defineProperty(this.actions,e,{configurable:!0,enumerable:!0,writable:!1,value:(...t)=>{if(1===this.accessContext)return;let n;this._actionDepth++;try{for(const s of this._actionListeners)s({name:e,args:t});n=s.call(this.proxy,...t)}finally{0==--this._actionDepth&&(ie(this._update),this._update())}return n}})}}_initViews(){const t=this.options.views;if(t)for(const e of Object.keys(t)){this.accessCache[e]=2;const s=t[e],n=s.length>1,i=this.createView(s),r=i;0;Object.defineProperty(this.views,e,{configurable:!0,enumerable:!0,get:n?()=>(...t)=>{const e=r.__externalArgs;if(e){if(e.length!==t.length)he(i);else for(let s=0;s<e.length;s++)if(e[s]!==t[s]){he(i);break}}else he(i);return r.__externalArgs=t,i.getSnapshot()}:i.getSnapshot,set:()=>!1})}}}function fe(t,e={}){return new ue(t,e)}let pe=null;function de(t){pe=t}class _e{constructor(t=e,s=[]){this._subscribers=new Set,this._initialState=t,this._models=(()=>{const t=new Map,e={get:e=>t.get(e),set(e,s){t.set(e,s)},each(e){for(const[s,n]of t.entries())e(n,s)},clear(){e.each((t=>t.destroy())),t.clear()}};return e})();const n=()=>{for(const t of this._subscribers)t()};this._onModelChange=()=>{ne(n)},this._hooks=s.map((([t,e])=>t(e))),this._hooks.map((e=>{var s;return null===(s=e.onInit)||void 0===s?void 0:s.call(e,{initialState:t},{doura:this})}))}getModel(t,e){return this.getModelInstance({name:t,model:e}).publicInst}getDetachedModel(t){return this.getModelInstance({model:t}).publicInst}getModelInstance({name:t,model:e}){const s=t&&this._models.get(t);if(s)return s;let n;if("function"==typeof e){const s=pe,i=this._createModelProxy();try{de({manager:this,model:i}),n=this._initModel({name:t,model:e()})}finally{de(s)}i.setModel(n)}else{if("object"!=typeof e)throw new Error("invalid model");n=this._initModel({name:t,model:e})}return n}getState(){const t={};return this._models.each(((e,s)=>{t[s]=e.getState()})),t}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}destroy(){this._hooks.map((t=>{var e;return null===(e=t.onDestroy)||void 0===e?void 0:e.call(t)})),this._models.clear(),this._subscribers.clear(),this._initialState=e}_createModelProxy(){const t=[];return{addChild(e){t.push(e)},setModel(e){for(const s of t)e.depend(s);t.length=0}}}_initModel({name:t,model:e}){if(!t)return fe(e);this._hooks.map((s=>{var n;return null===(n=s.onModel)||void 0===n?void 0:n.call(s,t,e,{doura:this})}));const s=fe(e,{name:t,initState:this._getInitialState(t)});return s.subscribe(this._onModelChange),this._models.set(t,s),this._hooks.map((t=>{var e;null===(e=t.onModelInstance)||void 0===e||e.call(t,s.publicInst,{doura:this})})),s}_getInitialState(t){const e=this._initialState[t];return e&&delete this._initialState[t],e}}function ye(t,e){if(!pe)throw new Error("Invalid use() call. use() can only be called inside of the body of a function model. This could happen for one of the following reasons:\n1. You might be breaking the Rules of Doura\n2. You might have more than one copy of Doura in the same app");const{manager:s,model:n}=pe;let i,r;return"string"==typeof t?(r=t,i=s.getModelInstance({name:r,model:e})):i=s.getModelInstance({model:e=t}),n.addChild(i),i.proxy}function ge({initialState:t,plugins:e=[]}={}){return function({initialState:t,plugins:e}={}){return new _e(t,e)}({initialState:t,plugins:e})}var be=function(){if("undefined"==typeof window||!window.__REDUX_DEVTOOLS_EXTENSION__)return{};let t=0;const e=new Set;let s;return{onInit(n,{doura:i}){if(window.__doura=i,"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){s=window.__REDUX_DEVTOOLS_EXTENSION__.connect({name:`doura${0===t?"":t}`}),t+=1,s.init(i.getState());const n=t=>{switch(t.type){case"ACTION":return void v("string"==typeof t.payload,"Unsupported action format");case"DISPATCH":switch(t.payload.type){case"RESET":case"COMMIT":return s.init(i.getState());case"ROLLBACK":try{const e=JSON.parse(t.state);return s.init(e)}catch(e){console.warn("[Doura Devtool] Could not parse the received json.")}return s.init(i.getState());case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return}}};e.add(s.subscribe(n))}},onModelInstance(t,{doura:e}){t.$subscribe((t=>{var{type:n,model:i}=t,r=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(s[n[i]]=t[n[i]])}return s}(t,["type","model"]);const o=e.getState();delete o._,s.send(Object.assign({type:`${i.$name||"anonymous"}@${n}`},r),o)}))},onDestroy(){window.__REDUX_DEVTOOLS_EXTENSION__.disconnect(s);for(const t of e.values())t();e.clear()}}};export{t as NOOP,n as assign,w as def,P as defineModel,be as devtool,ge as doura,It as draft,j as each,s as emptyArray,e as emptyObject,r as hasOwn,v as invariant,b as is,a as isArray,u as isFunction,g as isIntegerKey,l as isMap,d as isObject,y as isPlainObject,h as isSet,f as isString,p as isSymbol,se as nextTick,o as objectToString,x as ownKeys,E as set,O as shallowCopy,$t as snapshot,_ as toRawType,c as toTypeString,ye as use};
const t=()=>{},e=Object.create(null),s=[],n=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),o=Object.prototype.toString,c=t=>o.call(t),a=Array.isArray,l=t=>"[object Map]"===c(t),h=t=>"[object Set]"===c(t),u=t=>"function"==typeof t,f=t=>"string"==typeof t,p=t=>"symbol"==typeof t,d=t=>null!==t&&"object"==typeof t,_=t=>c(t).slice(8,-1),y=t=>"[object Object]"===c(t),g=t=>f(t)&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,b=(t,e)=>Object.is(t,e),w=(t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})};function v(t,e){if(!t)throw new Error(`[Doura] ${e||""}`)}const S=Array.prototype.slice;const m=Object.prototype.propertyIsEnumerable;function O(t){return Array.isArray(t)?S.call(t):l(t)?new Map(t):h(t)?new Set(t):Object.getPrototypeOf(t)===Object.prototype?function(t){const e={},s=x(t);for(let n=0;n<s.length;n++){const i=s[n],r=t[i];m.call(t,i)?e[i]=r:Object.defineProperty(e,i,{configurable:!0,writable:!0,enumerable:!1,value:r})}return e}(t):function(t){const e=Object.getOwnPropertyDescriptors(t),s=x(e);for(let n=0;n<s.length;n++){const i=s[n],r=e[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(e[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:t[i]})}return Object.create(Object.getPrototypeOf(t),e)}(t)}const x="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?t=>Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)):Object.getOwnPropertyNames;function j(t,e,s=!1){y(t)?(s?Object.keys:x)(t).forEach((n=>{s&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach(((s,n)=>e(n,s,t)))}function E(t,e,s){l(t)?t.set(e,s):h(t)?(t.delete(e),t.add(s)):t[e]=s}const P=t=>t;function M(t,...e){console.warn(`[Doura warn] ${t}`,...e)}function R(t){switch(_(t)){case"Object":return 1;case"Array":return 2;case"Set":return 3;case"Map":return 4;default:return 0}}function C(t){return w(t,"__r_skip",!0),t}function D(t){return!!t&&!!t.__r_state}function I(t){const e=A(t);return e?I(e.base):t}function A(t){return t&&t.__r_state}function $(t){return t.copy||t.base}function T(t){t.modified||(t.modified=!0,t.parent&&T(t.parent))}let k;class L{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&k&&(this.parent=k,this.index=(k.scopes||(k.scopes=[])).push(this)-1)}run(t){if(this.active){const e=k;try{return k=this,t()}finally{k=e}}}on(){k=this}off(){k=this.parent}stop(t){if(this.active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.active=!1}}}const N=t=>{const e=new Set(t);return e.w=0,e.n=0,e},V=t=>(t.w&z)>0,H=t=>(t.n&z)>0,U=new WeakMap,X=new WeakMap;let K=0,z=1;let Y;const J=Symbol(""),F=Symbol("");let W=0;class B{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.id=W++,this.deps=[],this.active=!0,this.parent=void 0,function(t,e=k){e&&e.active&&e.effects.push(t)}(this,s)}run(){if(!this.active)return this.fn();let t=Y;const e=G;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=Y,Y=this,G=!0,z=1<<++K,K<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=z})(this):q(this),this.fn()}finally{K<=30&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];V(i)&&!H(i)?i.delete(t):e[s++]=i,i.w&=~z,i.n&=~z}e.length=s}})(this),z=1<<--K,Y=this.parent,G=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){Y===this?this.deferStop=!0:this.active&&(q(this),this.onStop&&this.onStop(),this.active=!1)}}function q(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let G=!0;const Q=[];function Z(){Q.push(G),G=!1}function tt(){const t=Q.pop();G=void 0===t||t}function et(t,e,s){if(G&&Y){let e=U.get(t);e||U.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=N()),nt(n)}}function st(t){if(G&&Y){const e=t.__r_state;if(!e)return;let s=X.get(e);s||X.set(e,s=N()),nt(s)}}function nt(t){let e=!1;K<=30?H(t)||(t.n|=z,e=!V(t)):e=!t.has(Y),e&&(t.add(Y),Y.deps.push(t))}function it(t){const e=X.get(t);if(e){const t=[...e];for(const e of t)e.view&&(e.view.mightChange=!0)}}function rt(t,e,s,n,i){var r;const o=U.get(t),c=t.base;let h=[];if(o)if("clear"===e)h=[...o.values()];else if("length"===s&&a(c))o.forEach(((t,e)=>{("length"===e||e>=n)&&h.push(t)}));else switch(void 0!==s&&h.push(o.get(s)),e){case"add":a(c)?g(s)&&h.push(o.get("length")):(h.push(o.get(J)),l(c)&&h.push(o.get(F)));break;case"delete":a(c)||(h.push(o.get(J)),l(c)&&h.push(o.get(F)));break;case"set":l(c)&&h.push(o.get(J))}if(1===h.length)h[0]&&ot(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);ot(N(t))}const u=null===(r=t.root)||void 0===r?void 0:r.listeners;u&&u.length&&u.forEach((t=>t()))}function ot(t){const e=a(t)?t:[...t];for(const s of e)s.view&&ct(s);for(const s of e)s.view||ct(s)}function ct(t){(t!==Y||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}class at{constructor(t,{disableCache:e=!1}){this.dep=void 0,this.mightChange=!1,this.dirty=!0,this.effect=new B(t,(()=>{this.dirty||(this.dirty=!0,function(t){(t=I(t)).dep&&ot(t.dep)}(this))})),this.effect.view=this,this.effect.active=this._cacheable=!e}get value(){const t=I(this);return function(t){G&&Y&&nt((t=I(t)).dep||(t.dep=N()))}(t),!t.dirty&&t._cacheable||(t.dirty=!1,t._value=t.effect.run()),t._value}set value(t){}}const lt=new Set(["__proto__"]),ht=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(p));function ut(t){t.copy||(t.copy=O(t.base))}function ft(t,e){const s=t.__r_state;return(s?$(s):t)[e]}const pt=yt(),dt=_t();function _t(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=A(this),n=$(s);for(let e=0,r=this.length;e<r;e++)et(s,0,e+"");const i=n[e](...t);return-1===i||!1===i?n[e](...t.map(I)):i}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){Z();const s=$(A(this))[e].apply(this,t);return tt(),s}})),t}function yt(){return function(t,e,s){const n=$(t);if("__r_isReactive"===e)return!0;if("__r_state"===e&&s===Dt.get(t))return t;if(a(n)&&r(dt,e))return Reflect.get(dt,e,s);let i=Reflect.get(n,e,s);return(p(e)?ht.has(e):lt.has(e))?i:(et(t,0,e),r(n,e)?(t.disposed||!d(i)||(D(i)||(ut(t),i=t.copy[e]=At(i,t)),st(i)),i):i)}}function gt(){return function(t,e,s,n){const i=$(t),o=ft(i,e),c=a(i)&&g(e)?Number(e)<i.length:r(i,e);if(!t.modified){const n=null==o?void 0:o.__r_state;if(n&&n.base===s)return t.copy[e]=s,!0;if(b(s,o)&&(void 0!==s||r(t.base,e)))return!0;ut(t),T(t)}return b(t.copy[e],s)&&(void 0!==s||e in t.copy)||(t.copy[e]=s,t===A(n)&&(c?b(s,o)||rt(t,"set",e,s):rt(t,"add",e,s),function(t){let e=t;for(;e;)it(e),e=e.parent}(t))),!0}}const bt={get:pt,set:gt(),deleteProperty:function(t,e){const s=r($(t),e);if((void 0!==ft(t.base,e)||e in t.base)&&(ut(t),T(t)),t.copy){const n=delete t.copy[e];return n&&s&&rt(t,"delete",e,void 0),n}return!0},has:function(t,e){const s=$(t),n=Reflect.has(s,e);return p(e)&&ht.has(e)||et(t,0,e),n},ownKeys:function(t){const e=$(t);return et(t,0,a(e)?"length":J),Reflect.ownKeys(e)},setPrototypeOf:function(t,e){const s=Reflect.setPrototypeOf(t.base,e);return s&&t.copy&&Reflect.setPrototypeOf(t.copy,e),s},getOwnPropertyDescriptor:function(t,e){const s=$(t),n=Reflect.getOwnPropertyDescriptor(s,e);return n?{writable:!0,configurable:!a(s)||"length"!==e,enumerable:n.enumerable,value:s[e]}:n}};function wt(t){t.copy||(t.copy=new Set,t.base.forEach((e=>{if(d(e)){const s=At(e,t);st(s),e!==s&&t.drafts.set(e,s),t.copy.add(s)}else t.copy.add(e)})))}function vt(t){1===t.type?function(t){t.copy||(t.copy=new Map(t.base))}(t):wt(t)}function St(t){const e=this.__r_state,s=$(e);if(et(e,0,t),!s.has(t))return;let n=s.get(t);return d(n)?(D(n)||(vt(e),n=At(n,e),e.copy.set(t,n)),st(n),n):n}function mt(t,e){const s=this.__r_state,n=$(s),i=n.has(t),r=n.get(t),o=()=>{vt(s),T(s),s.copy.set(t,e)};return i?b(e,r)||(o(),rt(s,"set",t,e)):(o(),rt(s,"add",t,e)),this}function Ot(t){const e=this.__r_state;return $(e).has(t)||(wt(e),T(e),e.copy.add(t),rt(e,"add",t,t)),this}function xt(t){const e=this.__r_state;return et(e,0,t),e.copy?!!e.copy.has(t)||2===e.type&&(e.drafts.has(t)&&e.drafts.has(e.drafts.get(t))):e.base.has(t)}function jt(t){const e=this.__r_state,s=$(e),n=s.has(t);"get"in s&&s.get(t),vt(e),T(e);let i=e.copy.delete(t);return 2!==e.type||i||(i=!!e.drafts.has(t)&&e.drafts.delete(e.drafts.get(t))),n&&rt(e,"delete",t,void 0),i}function Et(){const t=this.__r_state,e=$(t),s=0!==e.size,n=e.clear();return s&&(vt(t),T(t),t.copy.clear(),rt(t,"clear",void 0,void 0)),n}function Pt(){const t={get:St,get size(){return et(t=this.__r_state,0,J),$(t).size;var t},has:xt,add:Ot,set:mt,delete:jt,clear:Et,keys(){const t=this.__r_state;return 1===t.type?function(t){return et(t,0,F),$(t).keys()}(t):function(t){return et(t,0,J),wt(t),t.copy.values()}(t)},forEach(t,e){const s=this.__r_state;1===s.type?function(t,e,s,n){et(e,0,J),$(e).forEach(((i,r)=>s.call(n,e.proxy.get(r),r,t)))}(this,s,t,e):function(t,e,s,n){const i=e.proxy.values();let r=i.next();for(;!r.done;)s.call(n,r.value,r.value,t),r=i.next()}(this,s,t,e)}};return["values","entries",Symbol.iterator].forEach((e=>{t[e]=function(t){return function(...e){const s=this.__r_state,n=1===s.type,i="entries"===t||t===Symbol.iterator&&n;if(n){const t=s.proxy.keys();return{next(){const{value:e,done:n}=t.next(),r=s.proxy.get(e);return n?{value:r,done:n}:{value:i?[e,r]:r,done:n}},[Symbol.iterator](){return this}}}return et(s,0,J),wt(s),s.copy[t](...e)}}(e)})),[t]}const[Mt]=Pt();function Rt(){const t=Mt;return(e,s,n)=>{if("__r_isReactive"===s)return!0;if("__r_state"===s)return e;const i=$(e);return Reflect.get(r(t,s)&&s in i?t:i,s,n)}}const Ct={get:Rt()};const Dt=new WeakMap;let It=0;function At(t,e){const s=R(t);if(0===s)return t;if(t.__r_skip||!Object.isExtensible(t))return t;if(t.__r_state)return t;let n={type:0,id:It++,root:null,parent:e,base:t,proxy:null,copy:null,modified:!1,disposed:!1,listeners:[],children:[]},i=n,r=bt;3===s?(n.type=2,n.drafts=new Map,i=new Set,r=Ct):4===s?(n.type=1,i=new Map,r=Ct):2===s&&(i=[]),i!==n&&Object.keys(n).forEach((t=>{Object.defineProperty(i,t,{configurable:!0,enumerable:!0,writable:!0,value:n[t]})}));const o=new Proxy(i,r);return i.proxy=o,e?(i.root=e.root,e.children.push(i)):i.root=i,Dt.set(i,o),i.proxy}function $t(t,e){const s=function(t,{copies:e,snapshots:s}){const n=t=>{switch(R(t)){case 1:case 2:return u;case 4:case 3:return h;default:throw new Error("Unpected Error. Please file an issue on https://github.com/dourajs/doura")}},i=t=>{if(!d(t))return t;if(D(t)){let i=s.get(t);if(!i){const r=e.get(t.__r_state);s.set(t,i=new Proxy(r,n(r)))}return i}return t},o=t=>function(...e){const s=this.__r_raw,n="entries"===t||t===Symbol.iterator&&l(this),r=s[t](...e);return{next(){const{value:t,done:e}=r.next();return e?{value:i(t),done:e}:{value:n?[t[0],i(t[1])]:i(t),done:e}},[Symbol.iterator](){return this}}},c=t=>function(...e){return this.__r_raw[t](...e)},a={get size(){return this.__r_raw.size},get(t){const e=this.__r_raw;if(e.has(t))return i(e.get(t))},forEach(t,e){const s=this.__r_raw;return s.forEach(((n,r)=>(n=i(n),t.call(e,n,l(s)?r:n,s))))}};["has","add","set","delete","clear"].forEach((t=>{a[t]=c(t)})),["keys","values","entries",Symbol.iterator].forEach((t=>{a[t]=o(t)}));const h={get:(t,e,s)=>"__r_raw"===e?t:Reflect.get(r(a,e)&&e in t?a:t,e,s)},u={get:(t,e,s)=>i(Reflect.get(t,e,s))};return n(t)}(t,e);if(D(t)){return new Proxy(e.copies.get(t.__r_state),s)}return new Proxy(t,s)}function Tt(t,e,s){if(!d(t))return t;const n=function(t,e){const s=new Map,n={copies:s,snapshots:e||new Map},i=n.snapshots,r=[t.__r_state];for(;r.length;){const t=r.pop();let e;t.modified?(e=O(t.copy),kt(t,e),i.delete(t.proxy)):e=$t(t.base,n),s.set(t,e);for(const s of t.children)r.push(s)}return n}(e,s);return $t(t,n)}function kt(t,e){t.modified=!1,t.base=e}function Lt(t,e){const s=t.createView((function(){return e(this,this.$actions)})),n=s.getSnapshot;return n.destory=function(){s.effect.stop();const e=t.effectScope.effects.indexOf(s.effect);e>=0&&t.effectScope.effects.splice(e,1)},n}const Nt=n({$name:t=>t.name,$rawState:t=>t.getState(),$state:t=>t.stateValue,$actions:t=>t.actions,$views:t=>t.views,$patch:t=>t.patch,$onAction:t=>t.onAction,$subscribe:t=>t.subscribe,$isolate:t=>t.isolate,$getApi:t=>t.getApi,$createView:t=>Lt.bind(null,t)}),Vt=t=>({_:e},s)=>{const{actions:n,views:i,accessCache:o,ctx:c}=e;let a;if(a=t?e.getState():e.stateValue,"$"!==s[0]){const t=o[s];if(void 0!==t)switch(t){case 0:return a[s];case 2:return i[s];case 1:return n[s];case 3:return c[s]}else{if(r(a,s))return o[s]=0,a[s];if(r(c,s))return o[s]=3,c[s]}}const l=Nt[s];return l?l(e):r(c,s)?(o[s]=3,c[s]):void((t=>"_"===t||"$"===t)(s[0])&&r(a,s)&&M(`Property ${JSON.stringify(s)} must be accessed via $state because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`))},Ht=({_:t},e,s)=>{const{ctx:n,actions:i,views:o,accessContext:c,stateRef:{value:a}}=t;return r(a,e)?1!==c&&(a[e]=s,!0):!r(i,e)&&(!r(o,e)&&("$state"===e?"bigint"!=typeof s&&"symbol"!=typeof s&&(t.replace(s),!0):("$"!==e[0]||!r(Nt,e))&&(n[e]=s,!0)))},Ut={get:Vt(!1),set:Ht},Xt={get:Vt(!0),set:Ht};function Kt(t,e,...s){console.error(t)}let zt=!1,Yt=!1;const Jt=[];let Ft=0;const Wt=[];let Bt=null,qt=0;const Gt=[];let Qt=null,Zt=0;const te=Promise.resolve();let ee=null,se=null;function ne(t){const e=ee||te;return t?e.then(this?t.bind(this):t):e}function ie(t){Jt.length&&Jt.includes(t,zt&&t.allowRecurse?Ft+1:Ft)||t===se||(null==t.id?Jt.push(t):Jt.splice(function(t){let e=Ft+1,s=Jt.length;for(;e<s;){const n=e+s>>>1;ce(Jt[n])<t?e=n+1:s=n}return e}(t.id),0,t),zt||Yt||(Yt=!0,ee=te.then(ae)))}function re(t){const e=Jt.indexOf(t);e>=Ft&&Jt.splice(e,1)}function oe(t,e=null){if(Wt.length){for(se=e,Bt=[...new Set(Wt)],Wt.length=0,qt=0;qt<Bt.length;qt++)Bt[qt]();Bt=null,qt=0,se=null,oe(t,e)}}const ce=t=>null==t.id?1/0:t.id;function ae(t){Yt=!1,zt=!0,oe(t),Jt.sort(((t,e)=>ce(t)-ce(e)));try{for(Ft=0;Ft<Jt.length;Ft++){const t=Jt[Ft];if(t&&!1!==t.active){0;try{t()}catch(e){Kt(e)}}}}finally{Ft=0,Jt.length=0,function(t){if(oe(),Gt.length){const t=[...new Set(Gt)];if(Gt.length=0,Qt)return void Qt.push(...t);for(Qt=t,Qt.sort(((t,e)=>ce(t)-ce(e))),Zt=0;Zt<Qt.length;Zt++)Qt[Zt]();Qt=null,Zt=0}}(),zt=!1,ee=null,(Jt.length||Wt.length||Gt.length)&&ae(t)}}var le;function he(t,e){const s=Object.keys(e);s.length&&s.forEach((s=>{r(t,s)&&y(e[s])?he(t[s],e[s]):t[s]=e[s]}))}function ue(t){t.dirty=!0}!function(t){t.REPLACE="replace",t.MODIFY="modify",t.PATCH="patch"}(le||(le={}));class fe{constructor(e,{name:s,initState:n}){var i;this.viewInstances=[],this._actionDepth=0,this._api=null,this._actionListeners=new Set,this._subscribers=new Set,this._depListenersHandlers=[],this._watchStateChange=!0,this._destroyed=!1,this._lastDraftToSnapshot=new Map,this.patch=this.patch.bind(this),this.onAction=this.onAction.bind(this),this.subscribe=this.subscribe.bind(this),this.isolate=this.isolate.bind(this),this.getApi=this.getApi.bind(this),this._update=this._update.bind(this),this.options=e,this.name=s||"",this._isDispatching=!1,this._initState=n||e.state,this.stateRef=At({value:this._initState}),this._update.__name=s,this._draftListenerHandler=function(e,s){const n=e.__r_state;return n.disposed?t:(n.listeners.push(s),()=>{const t=n.listeners.indexOf(s);t>=0&&n.listeners.splice(t,1)})}(this.stateRef,(()=>{this._watchStateChange&&ie(this._update)})),this._setState(this._initState),this.actions=Object.create(null),this.views=Object.create(null),this.accessContext=0,this.ctx={},w(this.ctx,"_",this),this.accessCache=Object.create(null),this.proxy=new Proxy(this.ctx,Ut),this.publicInst=new Proxy(this.ctx,Xt),this.effectScope=new L(i),this._initActions(),this._initViews()}patch(t){y(t)&&this._currentState&&(this._watchStateChange=!1,he(this.proxy.$state,t),this._watchStateChange=!0,this.dispatch({type:le.PATCH,args:{patch:t}}))}replace(t){if(d(t)){this._watchStateChange=!1,this.stateRef.value=t,this._watchStateChange=!0;for(const t of this.viewInstances)t.effect.scheduler();this.dispatch({type:le.REPLACE,payload:t})}else M(`replace argument should be an object, but receive a ${Object.prototype.toString.call(t)}`)}getState(){return this._currentState}getApi(){if(null===this._api){const t=this._api=Object.assign(Object.assign({},this._currentState),this.views);for(const e of Object.keys(this.actions))w(t,e,this.actions[e])}return this._api}onAction(t){return this._actionListeners.add(t),()=>{this._actionListeners.delete(t)}}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}isolate(t){Z();const e=t(this.stateValue);return tt(),e}depend(t){this._depListenersHandlers.push(t.subscribe((t=>{this._triggerListener(Object.assign(Object.assign({},t),{model:this.proxy}))})))}createView(t){let e;return this.effectScope.run((()=>{e=function(t,e={}){return new at(t,e)}((()=>{const n=this.accessContext;this.accessContext=1;const i=e.__externalArgs;try{return t.call(this.proxy,this.proxy,...i||s)}finally{this.accessContext=n}}))})),e.getSnapshot=()=>{const t=e.value;return e.mightChange?(e.mightChange=!1,e.__snapshot=Tt(t,this.stateRef.value)):e.__pre!==t&&(e.__snapshot=Tt(t,this.stateRef.value)),e.__pre=t,e.__snapshot},this.viewInstances.push(e),e}reducer(t,e){switch(e.type){case le.MODIFY:case le.PATCH:{const t=new Map(this._lastDraftToSnapshot);return this._lastDraftToSnapshot=t,Tt(this.stateRef.value,this.stateRef.value,this._lastDraftToSnapshot)}case le.REPLACE:return e.payload;default:return t}}dispatch(t){if(void 0===t.type)return t;if(this._isDispatching)return t;let e;try{this._isDispatching=!0,e=this.reducer(this._currentState,t)}finally{this._isDispatching=!1}return e!==this._currentState&&(this._setState(e),this._triggerListener(Object.assign({type:t.type,model:this.proxy,target:this.proxy},t.args))),t}destroy(){this._destroyed=!0,this._api=null,this._lastDraftToSnapshot.clear(),this._currentState=null,this.stateRef={value:null},this._subscribers.clear(),this.effectScope.stop();for(const t of this._depListenersHandlers)t();this._draftListenerHandler()}_setState(t){this._api=null,this._currentState=t,this.stateValue=this.stateRef.value}_update(){!this._destroyed&&function(t){return t.__r_state.modified}(this.stateRef)&&(this.dispatch({type:le.MODIFY}),function(t){const e=t.__r_state;e&&(e.modified=!1)}(this.stateRef))}_triggerListener(t){for(const e of this._subscribers)e(t)}_initActions(){const t=this.options.actions;if(t)for(const e of Object.keys(t)){this.accessCache[e]=1;const s=t[e];Object.defineProperty(this.actions,e,{configurable:!0,enumerable:!0,writable:!1,value:(...t)=>{if(1===this.accessContext)return;let n;this._actionDepth++;try{for(const s of this._actionListeners)s({name:e,args:t});n=s.call(this.proxy,...t)}finally{0==--this._actionDepth&&(re(this._update),this._update())}return n}})}}_initViews(){const t=this.options.views;if(t)for(const e of Object.keys(t)){this.accessCache[e]=2;const s=t[e],n=s.length>1,i=this.createView(s),r=i;0;Object.defineProperty(this.views,e,{configurable:!0,enumerable:!0,get:n?()=>(...t)=>{const e=r.__externalArgs;if(e){if(e.length!==t.length)ue(i);else for(let s=0;s<e.length;s++)if(e[s]!==t[s]){ue(i);break}}else ue(i);return r.__externalArgs=t,i.getSnapshot()}:i.getSnapshot,set:()=>!1})}}}function pe(t,e={}){return new fe(t,e)}let de=null;function _e(t){de=t}class ye{constructor(t=e,s=[]){this._subscribers=new Set,this._initialState=t,this._models=(()=>{const t=new Map,e={get:e=>t.get(e),set(e,s){t.set(e,s)},each(e){for(const[s,n]of t.entries())e(n,s)},clear(){e.each((t=>t.destroy())),t.clear()}};return e})();const n=()=>{for(const t of this._subscribers)t()};this._onModelChange=()=>{ie(n)},this._hooks=s.map((([t,e])=>t(e))),this._hooks.map((e=>{var s;return null===(s=e.onInit)||void 0===s?void 0:s.call(e,{initialState:t},{doura:this})}))}getModel(t,e){return this.getModelInstance({name:t,model:e}).publicInst}getDetachedModel(t){return this.getModelInstance({model:t}).publicInst}getModelInstance({name:t,model:e}){const s=t&&this._models.get(t);if(s)return s;let n;if("function"==typeof e){const s=de,i=this._createModelProxy();try{_e({manager:this,model:i}),n=this._initModel({name:t,model:e()})}finally{_e(s)}i.setModel(n)}else{if("object"!=typeof e)throw new Error("invalid model");n=this._initModel({name:t,model:e})}return n}getState(){const t={};return this._models.each(((e,s)=>{t[s]=e.getState()})),t}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}destroy(){this._hooks.map((t=>{var e;return null===(e=t.onDestroy)||void 0===e?void 0:e.call(t)})),this._models.clear(),this._subscribers.clear(),this._initialState=e}_createModelProxy(){const t=[];return{addChild(e){t.push(e)},setModel(e){for(const s of t)e.depend(s);t.length=0}}}_initModel({name:t,model:e}){if(!t)return pe(e);this._hooks.map((s=>{var n;return null===(n=s.onModel)||void 0===n?void 0:n.call(s,t,e,{doura:this})}));const s=pe(e,{name:t,initState:this._getInitialState(t)});return s.subscribe(this._onModelChange),this._models.set(t,s),this._hooks.map((t=>{var e;null===(e=t.onModelInstance)||void 0===e||e.call(t,s.publicInst,{doura:this})})),s}_getInitialState(t){const e=this._initialState[t];return e&&delete this._initialState[t],e}}function ge(t,e){if(!de)throw new Error("Invalid use() call. use() can only be called inside of the body of a function model. This could happen for one of the following reasons:\n1. You might be breaking the Rules of Doura\n2. You might have more than one copy of Doura in the same app");const{manager:s,model:n}=de;let i,r;return"string"==typeof t?(r=t,i=s.getModelInstance({name:r,model:e})):i=s.getModelInstance({model:e=t}),n.addChild(i),i.proxy}function be({initialState:t,plugins:e=[]}={}){return function({initialState:t,plugins:e}={}){return new ye(t,e)}({initialState:t,plugins:e})}var we=function(){if("undefined"==typeof window||!window.__REDUX_DEVTOOLS_EXTENSION__)return{};let t=0;const e=new Set;let s;return{onInit(n,{doura:i}){if(window.__doura=i,"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){s=window.__REDUX_DEVTOOLS_EXTENSION__.connect({name:`doura${0===t?"":t}`}),t+=1,s.init(i.getState());const n=t=>{switch(t.type){case"ACTION":return void v("string"==typeof t.payload,"Unsupported action format");case"DISPATCH":switch(t.payload.type){case"RESET":case"COMMIT":return s.init(i.getState());case"ROLLBACK":try{const e=JSON.parse(t.state);return s.init(e)}catch(e){console.warn("[Doura Devtool] Could not parse the received json.")}return s.init(i.getState());case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return}}};e.add(s.subscribe(n))}},onModelInstance(t,{doura:e}){t.$subscribe((t=>{var{type:n,model:i}=t,r=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(s[n[i]]=t[n[i]])}return s}(t,["type","model"]);const o=e.getState();delete o._,s.send(Object.assign({type:`${i.$name||"anonymous"}@${n}`},r),o)}))},onDestroy(){window.__REDUX_DEVTOOLS_EXTENSION__.disconnect(s);for(const t of e.values())t();e.clear()}}};export{t as NOOP,n as assign,w as def,P as defineModel,we as devtool,be as doura,At as draft,j as each,s as emptyArray,e as emptyObject,r as hasOwn,v as invariant,b as is,a as isArray,u as isFunction,g as isIntegerKey,l as isMap,d as isObject,y as isPlainObject,h as isSet,f as isString,p as isSymbol,C as markRaw,ne as nextTick,o as objectToString,x as ownKeys,E as set,O as shallowCopy,Tt as snapshot,_ as toRawType,c as toTypeString,ge as use};

@@ -1,1 +0,1 @@

var Doura=function(t){"use strict";const e=()=>{},s=Object.create(null),n=[],i=Object.assign,r=Object.prototype.hasOwnProperty,o=(t,e)=>r.call(t,e),c=Object.prototype.toString,a=t=>c.call(t),l=Array.isArray,h=t=>"[object Map]"===a(t),u=t=>"[object Set]"===a(t),f=t=>"string"==typeof t,p=t=>"symbol"==typeof t,d=t=>null!==t&&"object"==typeof t,_=t=>a(t).slice(8,-1),y=t=>"[object Object]"===a(t),g=t=>f(t)&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,b=(t,e)=>Object.is(t,e),w=(t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})};function v(t,e){if(!t)throw new Error(`[Doura] ${e||""}`)}const S=Array.prototype.slice;const m=Object.prototype.propertyIsEnumerable;function O(t){return Array.isArray(t)?S.call(t):h(t)?new Map(t):u(t)?new Set(t):Object.getPrototypeOf(t)===Object.prototype?function(t){const e={},s=x(t);for(let n=0;n<s.length;n++){const i=s[n],r=t[i];m.call(t,i)?e[i]=r:Object.defineProperty(e,i,{configurable:!0,writable:!0,enumerable:!1,value:r})}return e}(t):function(t){const e=Object.getOwnPropertyDescriptors(t),s=x(e);for(let n=0;n<s.length;n++){const i=s[n],r=e[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(e[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:t[i]})}return Object.create(Object.getPrototypeOf(t),e)}(t)}const x="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?t=>Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)):Object.getOwnPropertyNames;function j(t,...e){console.warn(`[Doura warn] ${t}`,...e)}function E(t){switch(_(t)){case"Object":return 1;case"Array":return 2;case"Set":return 3;case"Map":return 4;default:return 0}}function P(t){return!!t&&!!t.__r_state}function M(t){const e=R(t);return e?M(e.base):t}function R(t){return t&&t.__r_state}function C(t){return t.copy||t.base}function D(t){t.modified||(t.modified=!0,t.parent&&D(t.parent))}let I;class A{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&I&&(this.parent=I,this.index=(I.scopes||(I.scopes=[])).push(this)-1)}run(t){if(this.active){const e=I;try{return I=this,t()}finally{I=e}}}on(){I=this}off(){I=this.parent}stop(t){if(this.active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.active=!1}}}const T=t=>{const e=new Set(t);return e.w=0,e.n=0,e},$=t=>(t.w&H)>0,k=t=>(t.n&H)>0,L=new WeakMap,N=new WeakMap;let V=0,H=1;let U;const X=Symbol(""),K=Symbol("");let z=0;class Y{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.id=z++,this.deps=[],this.active=!0,this.parent=void 0,function(t,e=I){e&&e.active&&e.effects.push(t)}(this,s)}run(){if(!this.active)return this.fn();let t=U;const e=J;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=U,U=this,J=!0,H=1<<++V,V<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=H})(this):F(this),this.fn()}finally{V<=30&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];$(i)&&!k(i)?i.delete(t):e[s++]=i,i.w&=~H,i.n&=~H}e.length=s}})(this),H=1<<--V,U=this.parent,J=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){U===this?this.deferStop=!0:this.active&&(F(this),this.onStop&&this.onStop(),this.active=!1)}}function F(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let J=!0;const W=[];function B(){W.push(J),J=!1}function q(){const t=W.pop();J=void 0===t||t}function G(t,e,s){if(J&&U){let e=L.get(t);e||L.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=T()),Z(n)}}function Q(t){if(J&&U){const e=t.__r_state;if(!e)return;let s=N.get(e);s||N.set(e,s=T()),Z(s)}}function Z(t){let e=!1;V<=30?k(t)||(t.n|=H,e=!$(t)):e=!t.has(U),e&&(t.add(U),U.deps.push(t))}function tt(t){const e=N.get(t);if(e){const t=[...e];for(const e of t)e.view&&(e.view.mightChange=!0)}}function et(t,e,s,n,i){var r;const o=L.get(t),c=t.base;let a=[];if(o)if("clear"===e)a=[...o.values()];else if("length"===s&&l(c))o.forEach(((t,e)=>{("length"===e||e>=n)&&a.push(t)}));else switch(void 0!==s&&a.push(o.get(s)),e){case"add":l(c)?g(s)&&a.push(o.get("length")):(a.push(o.get(X)),h(c)&&a.push(o.get(K)));break;case"delete":l(c)||(a.push(o.get(X)),h(c)&&a.push(o.get(K)));break;case"set":h(c)&&a.push(o.get(X))}if(1===a.length)a[0]&&st(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);st(T(t))}const u=null===(r=t.root)||void 0===r?void 0:r.listeners;u&&u.length&&u.forEach((t=>t()))}function st(t){const e=l(t)?t:[...t];for(const s of e)s.view&&nt(s);for(const s of e)s.view||nt(s)}function nt(t){(t!==U||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}class it{constructor(t,{disableCache:e=!1}){this.dep=void 0,this.mightChange=!1,this.dirty=!0,this.effect=new Y(t,(()=>{this.dirty||(this.dirty=!0,function(t){(t=M(t)).dep&&st(t.dep)}(this))})),this.effect.view=this,this.effect.active=this._cacheable=!e}get value(){const t=M(this);return function(t){J&&U&&Z((t=M(t)).dep||(t.dep=T()))}(t),!t.dirty&&t._cacheable||(t.dirty=!1,t._value=t.effect.run()),t._value}set value(t){}}const rt=new Set(["__proto__"]),ot=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(p));function ct(t){t.copy||(t.copy=O(t.base))}function at(t,e){const s=t.__r_state;return(s?C(s):t)[e]}const lt=ft(),ht=ut();function ut(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=R(this),n=C(s);for(let e=0,r=this.length;e<r;e++)G(s,0,e+"");const i=n[e](...t);return-1===i||!1===i?n[e](...t.map(M)):i}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){B();const s=C(R(this))[e].apply(this,t);return q(),s}})),t}function ft(){return function(t,e,s){const n=C(t);if("__r_isReactive"===e)return!0;if("__r_state"===e&&s===Pt.get(t))return t;if(l(n)&&o(ht,e))return Reflect.get(ht,e,s);let i=Reflect.get(n,e,s);return(p(e)?ot.has(e):rt.has(e))?i:(G(t,0,e),o(n,e)?(t.disposed||!d(i)||(P(i)||(ct(t),i=t.copy[e]=Rt(i,t)),Q(i)),i):i)}}function pt(){return function(t,e,s,n){const i=C(t),r=at(i,e),c=l(i)&&g(e)?Number(e)<i.length:o(i,e);if(!t.modified){const n=null==r?void 0:r.__r_state;if(n&&n.base===s)return t.copy[e]=s,!0;if(b(s,r)&&(void 0!==s||o(t.base,e)))return!0;ct(t),D(t)}return b(t.copy[e],s)&&(void 0!==s||e in t.copy)||(t.copy[e]=s,t===R(n)&&(c?b(s,r)||et(t,"set",e,s):et(t,"add",e,s),function(t){let e=t;for(;e;)tt(e),e=e.parent}(t))),!0}}const dt={get:lt,set:pt(),deleteProperty:function(t,e){const s=o(C(t),e);if((void 0!==at(t.base,e)||e in t.base)&&(ct(t),D(t)),t.copy){const n=delete t.copy[e];return n&&s&&et(t,"delete",e,void 0),n}return!0},has:function(t,e){const s=C(t),n=Reflect.has(s,e);return p(e)&&ot.has(e)||G(t,0,e),n},ownKeys:function(t){const e=C(t);return G(t,0,l(e)?"length":X),Reflect.ownKeys(e)},setPrototypeOf:function(t,e){const s=Reflect.setPrototypeOf(t.base,e);return s&&t.copy&&Reflect.setPrototypeOf(t.copy,e),s},getOwnPropertyDescriptor:function(t,e){const s=C(t),n=Reflect.getOwnPropertyDescriptor(s,e);return n?{writable:!0,configurable:!l(s)||"length"!==e,enumerable:n.enumerable,value:s[e]}:n}};function _t(t){t.copy||(t.copy=new Set,t.base.forEach((e=>{if(d(e)){const s=Rt(e,t);Q(s),e!==s&&t.drafts.set(e,s),t.copy.add(s)}else t.copy.add(e)})))}function yt(t){1===t.type?function(t){t.copy||(t.copy=new Map(t.base))}(t):_t(t)}function gt(t){const e=this.__r_state,s=C(e);if(G(e,0,t),!s.has(t))return;let n=s.get(t);return d(n)?(P(n)||(yt(e),n=Rt(n,e),e.copy.set(t,n)),Q(n),n):n}function bt(t,e){const s=this.__r_state,n=C(s),i=n.has(t),r=n.get(t),o=()=>{yt(s),D(s),s.copy.set(t,e)};return i?b(e,r)||(o(),et(s,"set",t,e)):(o(),et(s,"add",t,e)),this}function wt(t){const e=this.__r_state;return C(e).has(t)||(_t(e),D(e),e.copy.add(t),et(e,"add",t,t)),this}function vt(t){const e=this.__r_state;return G(e,0,t),e.copy?!!e.copy.has(t)||2===e.type&&(e.drafts.has(t)&&e.drafts.has(e.drafts.get(t))):e.base.has(t)}function St(t){const e=this.__r_state,s=C(e),n=s.has(t);"get"in s&&s.get(t),yt(e),D(e);let i=e.copy.delete(t);return 2!==e.type||i||(i=!!e.drafts.has(t)&&e.drafts.delete(e.drafts.get(t))),n&&et(e,"delete",t,void 0),i}function mt(){const t=this.__r_state,e=C(t),s=0!==e.size,n=e.clear();return s&&(yt(t),D(t),t.copy.clear(),et(t,"clear",void 0,void 0)),n}function Ot(){const t={get:gt,get size(){return G(t=this.__r_state,0,X),C(t).size;var t},has:vt,add:wt,set:bt,delete:St,clear:mt,keys(){const t=this.__r_state;return 1===t.type?function(t){return G(t,0,K),C(t).keys()}(t):function(t){return G(t,0,X),_t(t),t.copy.values()}(t)},forEach(t,e){const s=this.__r_state;1===s.type?function(t,e,s,n){G(e,0,X),C(e).forEach(((i,r)=>s.call(n,e.proxy.get(r),r,t)))}(this,s,t,e):function(t,e,s,n){const i=e.proxy.values();let r=i.next();for(;!r.done;)s.call(n,r.value,r.value,t),r=i.next()}(this,s,t,e)}};return["values","entries",Symbol.iterator].forEach((e=>{t[e]=function(t){return function(...e){const s=this.__r_state,n=1===s.type,i="entries"===t||t===Symbol.iterator&&n;if(n){const t=s.proxy.keys();return{next(){const{value:e,done:n}=t.next(),r=s.proxy.get(e);return n?{value:r,done:n}:{value:i?[e,r]:r,done:n}},[Symbol.iterator](){return this}}}return G(s,0,X),_t(s),s.copy[t](...e)}}(e)})),[t]}const[xt]=Ot();function jt(){const t=xt;return(e,s,n)=>{if("__r_isReactive"===s)return!0;if("__r_state"===s)return e;const i=C(e);return Reflect.get(o(t,s)&&s in i?t:i,s,n)}}const Et={get:jt()};const Pt=new WeakMap;let Mt=0;function Rt(t,e){const s=E(t);if(0===s)return t;if(t.__r_skip||!Object.isExtensible(t))return t;if(t.__r_state)return t;let n={type:0,id:Mt++,root:null,parent:e,base:t,proxy:null,copy:null,modified:!1,disposed:!1,listeners:[],children:[]},i=n,r=dt;3===s?(n.type=2,n.drafts=new Map,i=new Set,r=Et):4===s?(n.type=1,i=new Map,r=Et):2===s&&(i=[]),i!==n&&Object.keys(n).forEach((t=>{Object.defineProperty(i,t,{configurable:!0,enumerable:!0,writable:!0,value:n[t]})}));const o=new Proxy(i,r);return i.proxy=o,e?(i.root=e.root,e.children.push(i)):i.root=i,Pt.set(i,o),i.proxy}function Ct(t,e){const s=function(t,{copies:e,snapshots:s}){const n=t=>{switch(E(t)){case 1:case 2:return u;case 4:case 3:return l;default:throw new Error("Unpected Error. Please file an issue on https://github.com/dourajs/doura")}},i=t=>{if(!d(t))return t;if(P(t)){let i=s.get(t);if(!i){const r=e.get(t.__r_state);s.set(t,i=new Proxy(r,n(r)))}return i}return t},r=t=>function(...e){const s=this.__r_raw,n="entries"===t||t===Symbol.iterator&&h(this),r=s[t](...e);return{next(){const{value:t,done:e}=r.next();return e?{value:i(t),done:e}:{value:n?[t[0],i(t[1])]:i(t),done:e}},[Symbol.iterator](){return this}}},c=t=>function(...e){return this.__r_raw[t](...e)},a={get size(){return this.__r_raw.size},get(t){const e=this.__r_raw;if(e.has(t))return i(e.get(t))},forEach(t,e){const s=this.__r_raw;return s.forEach(((n,r)=>(n=i(n),t.call(e,n,h(s)?r:n,s))))}};["has","add","set","delete","clear"].forEach((t=>{a[t]=c(t)})),["keys","values","entries",Symbol.iterator].forEach((t=>{a[t]=r(t)}));const l={get:(t,e,s)=>"__r_raw"===e?t:Reflect.get(o(a,e)&&e in t?a:t,e,s)},u={get:(t,e,s)=>i(Reflect.get(t,e,s))};return n(t)}(t,e);if(P(t)){return new Proxy(e.copies.get(t.__r_state),s)}return new Proxy(t,s)}function Dt(t,e,s){if(!d(t))return t;const n=function(t,e){const s=new Map,n={copies:s,snapshots:e||new Map},i=n.snapshots,r=[t.__r_state];for(;r.length;){const t=r.pop();let e;t.modified?(e=O(t.copy),It(t,e),i.delete(t.proxy)):e=Ct(t.base,n),s.set(t,e);for(const s of t.children)r.push(s)}return n}(e,s);return Ct(t,n)}function It(t,e){t.modified=!1,t.base=e}function At(t,e){const s=t.createView((function(){return e(this,this.$actions)})),n=s.getSnapshot;return n.destory=function(){s.effect.stop();const e=t.effectScope.effects.indexOf(s.effect);e>=0&&t.effectScope.effects.splice(e,1)},n}const Tt=i({$name:t=>t.name,$rawState:t=>t.getState(),$state:t=>t.stateValue,$actions:t=>t.actions,$views:t=>t.views,$patch:t=>t.patch,$onAction:t=>t.onAction,$subscribe:t=>t.subscribe,$isolate:t=>t.isolate,$getApi:t=>t.getApi,$createView:t=>At.bind(null,t)}),$t=t=>({_:e},s)=>{const{actions:n,views:i,accessCache:r,ctx:c}=e;let a;if(a=t?e.getState():e.stateValue,"$"!==s[0]){const t=r[s];if(void 0!==t)switch(t){case 0:return a[s];case 2:return i[s];case 1:return n[s];case 3:return c[s]}else{if(o(a,s))return r[s]=0,a[s];if(o(c,s))return r[s]=3,c[s]}}const l=Tt[s];return l?l(e):o(c,s)?(r[s]=3,c[s]):void((t=>"_"===t||"$"===t)(s[0])&&o(a,s)&&j(`Property ${JSON.stringify(s)} must be accessed via $state because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`))},kt=({_:t},e,s)=>{const{ctx:n,actions:i,views:r,accessContext:c,stateRef:{value:a}}=t;return o(a,e)?1!==c&&(a[e]=s,!0):!o(i,e)&&(!o(r,e)&&("$state"===e?"bigint"!=typeof s&&"symbol"!=typeof s&&(t.replace(s),!0):("$"!==e[0]||!o(Tt,e))&&(n[e]=s,!0)))},Lt={get:$t(!1),set:kt},Nt={get:$t(!0),set:kt};function Vt(t,e,...s){console.error(t)}let Ht=!1,Ut=!1;const Xt=[];let Kt=0;const zt=[];let Yt=null,Ft=0;const Jt=[];let Wt=null,Bt=0;const qt=Promise.resolve();let Gt=null,Qt=null;function Zt(t){Xt.length&&Xt.includes(t,Ht&&t.allowRecurse?Kt+1:Kt)||t===Qt||(null==t.id?Xt.push(t):Xt.splice(function(t){let e=Kt+1,s=Xt.length;for(;e<s;){const n=e+s>>>1;se(Xt[n])<t?e=n+1:s=n}return e}(t.id),0,t),Ht||Ut||(Ut=!0,Gt=qt.then(ne)))}function te(t){const e=Xt.indexOf(t);e>=Kt&&Xt.splice(e,1)}function ee(t,e=null){if(zt.length){for(Qt=e,Yt=[...new Set(zt)],zt.length=0,Ft=0;Ft<Yt.length;Ft++)Yt[Ft]();Yt=null,Ft=0,Qt=null,ee(t,e)}}const se=t=>null==t.id?1/0:t.id;function ne(t){Ut=!1,Ht=!0,ee(t),Xt.sort(((t,e)=>se(t)-se(e)));try{for(Kt=0;Kt<Xt.length;Kt++){const t=Xt[Kt];if(t&&!1!==t.active){0;try{t()}catch(e){Vt(e)}}}}finally{Kt=0,Xt.length=0,function(t){if(ee(),Jt.length){const t=[...new Set(Jt)];if(Jt.length=0,Wt)return void Wt.push(...t);for(Wt=t,Wt.sort(((t,e)=>se(t)-se(e))),Bt=0;Bt<Wt.length;Bt++)Wt[Bt]();Wt=null,Bt=0}}(),Ht=!1,Gt=null,(Xt.length||zt.length||Jt.length)&&ne(t)}}var ie;function re(t,e){const s=Object.keys(e);s.length&&s.forEach((s=>{o(t,s)&&y(e[s])?re(t[s],e[s]):t[s]=e[s]}))}function oe(t){t.dirty=!0}!function(t){t.REPLACE="replace",t.MODIFY="modify",t.PATCH="patch"}(ie||(ie={}));class ce{constructor(t,{name:s,initState:n}){var i;this.viewInstances=[],this._actionDepth=0,this._api=null,this._actionListeners=new Set,this._subscribers=new Set,this._depListenersHandlers=[],this._watchStateChange=!0,this._destroyed=!1,this._lastDraftToSnapshot=new Map,this.patch=this.patch.bind(this),this.onAction=this.onAction.bind(this),this.subscribe=this.subscribe.bind(this),this.isolate=this.isolate.bind(this),this.getApi=this.getApi.bind(this),this._update=this._update.bind(this),this.options=t,this.name=s||"",this._isDispatching=!1,this._initState=n||t.state,this.stateRef=Rt({value:this._initState}),this._update.__name=s,this._draftListenerHandler=function(t,s){const n=t.__r_state;return n.disposed?e:(n.listeners.push(s),()=>{const t=n.listeners.indexOf(s);t>=0&&n.listeners.splice(t,1)})}(this.stateRef,(()=>{this._watchStateChange&&Zt(this._update)})),this._setState(this._initState),this.actions=Object.create(null),this.views=Object.create(null),this.accessContext=0,this.ctx={},w(this.ctx,"_",this),this.accessCache=Object.create(null),this.proxy=new Proxy(this.ctx,Lt),this.publicInst=new Proxy(this.ctx,Nt),this.effectScope=new A(i),this._initActions(),this._initViews()}patch(t){y(t)&&this._currentState&&(this._watchStateChange=!1,re(this.proxy.$state,t),this._watchStateChange=!0,this.dispatch({type:ie.PATCH,args:{patch:t}}))}replace(t){if(d(t)){this._watchStateChange=!1,this.stateRef.value=t,this._watchStateChange=!0;for(const t of this.viewInstances)t.effect.scheduler();this.dispatch({type:ie.REPLACE,payload:t})}else j(`replace argument should be an object, but receive a ${Object.prototype.toString.call(t)}`)}getState(){return this._currentState}getApi(){if(null===this._api){const t=this._api=Object.assign(Object.assign({},this._currentState),this.views);for(const e of Object.keys(this.actions))w(t,e,this.actions[e])}return this._api}onAction(t){return this._actionListeners.add(t),()=>{this._actionListeners.delete(t)}}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}isolate(t){B();const e=t(this.stateValue);return q(),e}depend(t){this._depListenersHandlers.push(t.subscribe((t=>{this._triggerListener(Object.assign(Object.assign({},t),{model:this.proxy}))})))}createView(t){let e;return this.effectScope.run((()=>{e=function(t,e={}){return new it(t,e)}((()=>{const s=this.accessContext;this.accessContext=1;const i=e.__externalArgs;try{return t.call(this.proxy,this.proxy,...i||n)}finally{this.accessContext=s}}))})),e.getSnapshot=()=>{const t=e.value;return e.mightChange?(e.mightChange=!1,e.__snapshot=Dt(t,this.stateRef.value)):e.__pre!==t&&(e.__snapshot=Dt(t,this.stateRef.value)),e.__pre=t,e.__snapshot},this.viewInstances.push(e),e}reducer(t,e){switch(e.type){case ie.MODIFY:case ie.PATCH:{const t=new Map(this._lastDraftToSnapshot);return this._lastDraftToSnapshot=t,Dt(this.stateRef.value,this.stateRef.value,this._lastDraftToSnapshot)}case ie.REPLACE:return e.payload;default:return t}}dispatch(t){if(void 0===t.type)return t;if(this._isDispatching)return t;let e;try{this._isDispatching=!0,e=this.reducer(this._currentState,t)}finally{this._isDispatching=!1}return e!==this._currentState&&(this._setState(e),this._triggerListener(Object.assign({type:t.type,model:this.proxy,target:this.proxy},t.args))),t}destroy(){this._destroyed=!0,this._api=null,this._lastDraftToSnapshot.clear(),this._currentState=null,this.stateRef={value:null},this._subscribers.clear(),this.effectScope.stop();for(const t of this._depListenersHandlers)t();this._draftListenerHandler()}_setState(t){this._api=null,this._currentState=t,this.stateValue=this.stateRef.value}_update(){!this._destroyed&&function(t){return t.__r_state.modified}(this.stateRef)&&(this.dispatch({type:ie.MODIFY}),function(t){const e=t.__r_state;e&&(e.modified=!1)}(this.stateRef))}_triggerListener(t){for(const e of this._subscribers)e(t)}_initActions(){const t=this.options.actions;if(t)for(const e of Object.keys(t)){this.accessCache[e]=1;const s=t[e];Object.defineProperty(this.actions,e,{configurable:!0,enumerable:!0,writable:!1,value:(...t)=>{if(1===this.accessContext)return;let n;this._actionDepth++;try{for(const s of this._actionListeners)s({name:e,args:t});n=s.call(this.proxy,...t)}finally{0==--this._actionDepth&&(te(this._update),this._update())}return n}})}}_initViews(){const t=this.options.views;if(t)for(const e of Object.keys(t)){this.accessCache[e]=2;const s=t[e],n=s.length>1,i=this.createView(s),r=i;0;Object.defineProperty(this.views,e,{configurable:!0,enumerable:!0,get:n?()=>(...t)=>{const e=r.__externalArgs;if(e){if(e.length!==t.length)oe(i);else for(let s=0;s<e.length;s++)if(e[s]!==t[s]){oe(i);break}}else oe(i);return r.__externalArgs=t,i.getSnapshot()}:i.getSnapshot,set:()=>!1})}}}function ae(t,e={}){return new ce(t,e)}let le=null;function he(t){le=t}class ue{constructor(t=s,e=[]){this._subscribers=new Set,this._initialState=t,this._models=(()=>{const t=new Map,e={get:e=>t.get(e),set(e,s){t.set(e,s)},each(e){for(const[s,n]of t.entries())e(n,s)},clear(){e.each((t=>t.destroy())),t.clear()}};return e})();const n=()=>{for(const t of this._subscribers)t()};this._onModelChange=()=>{Zt(n)},this._hooks=e.map((([t,e])=>t(e))),this._hooks.map((e=>{var s;return null===(s=e.onInit)||void 0===s?void 0:s.call(e,{initialState:t},{doura:this})}))}getModel(t,e){return this.getModelInstance({name:t,model:e}).publicInst}getDetachedModel(t){return this.getModelInstance({model:t}).publicInst}getModelInstance({name:t,model:e}){const s=t&&this._models.get(t);if(s)return s;let n;if("function"==typeof e){const s=le,i=this._createModelProxy();try{he({manager:this,model:i}),n=this._initModel({name:t,model:e()})}finally{he(s)}i.setModel(n)}else{if("object"!=typeof e)throw new Error("invalid model");n=this._initModel({name:t,model:e})}return n}getState(){const t={};return this._models.each(((e,s)=>{t[s]=e.getState()})),t}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}destroy(){this._hooks.map((t=>{var e;return null===(e=t.onDestroy)||void 0===e?void 0:e.call(t)})),this._models.clear(),this._subscribers.clear(),this._initialState=s}_createModelProxy(){const t=[];return{addChild(e){t.push(e)},setModel(e){for(const s of t)e.depend(s);t.length=0}}}_initModel({name:t,model:e}){if(!t)return ae(e);this._hooks.map((s=>{var n;return null===(n=s.onModel)||void 0===n?void 0:n.call(s,t,e,{doura:this})}));const s=ae(e,{name:t,initState:this._getInitialState(t)});return s.subscribe(this._onModelChange),this._models.set(t,s),this._hooks.map((t=>{var e;null===(e=t.onModelInstance)||void 0===e||e.call(t,s.publicInst,{doura:this})})),s}_getInitialState(t){const e=this._initialState[t];return e&&delete this._initialState[t],e}}var fe=function(){if("undefined"==typeof window||!window.__REDUX_DEVTOOLS_EXTENSION__)return{};let t=0;const e=new Set;let s;return{onInit(n,{doura:i}){if(window.__doura=i,"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){s=window.__REDUX_DEVTOOLS_EXTENSION__.connect({name:`doura${0===t?"":t}`}),t+=1,s.init(i.getState());const n=t=>{switch(t.type){case"ACTION":return void v("string"==typeof t.payload,"Unsupported action format");case"DISPATCH":switch(t.payload.type){case"RESET":case"COMMIT":return s.init(i.getState());case"ROLLBACK":try{const e=JSON.parse(t.state);return s.init(e)}catch(e){console.warn("[Doura Devtool] Could not parse the received json.")}return s.init(i.getState());case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return}}};e.add(s.subscribe(n))}},onModelInstance(t,{doura:e}){t.$subscribe((t=>{var{type:n,model:i}=t,r=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(s[n[i]]=t[n[i]])}return s}(t,["type","model"]);const o=e.getState();delete o._,s.send(Object.assign({type:`${i.$name||"anonymous"}@${n}`},r),o)}))},onDestroy(){window.__REDUX_DEVTOOLS_EXTENSION__.disconnect(s);for(const t of e.values())t();e.clear()}}};return t.NOOP=e,t.assign=i,t.def=w,t.defineModel=t=>t,t.devtool=fe,t.doura=function({initialState:t,plugins:e=[]}={}){return function({initialState:t,plugins:e}={}){return new ue(t,e)}({initialState:t,plugins:e})},t.draft=Rt,t.each=function(t,e,s=!1){y(t)?(s?Object.keys:x)(t).forEach((n=>{s&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach(((s,n)=>e(n,s,t)))},t.emptyArray=n,t.emptyObject=s,t.hasOwn=o,t.invariant=v,t.is=b,t.isArray=l,t.isFunction=t=>"function"==typeof t,t.isIntegerKey=g,t.isMap=h,t.isObject=d,t.isPlainObject=y,t.isSet=u,t.isString=f,t.isSymbol=p,t.nextTick=function(t){const e=Gt||qt;return t?e.then(this?t.bind(this):t):e},t.objectToString=c,t.ownKeys=x,t.set=function(t,e,s){h(t)?t.set(e,s):u(t)?(t.delete(e),t.add(s)):t[e]=s},t.shallowCopy=O,t.snapshot=Dt,t.toRawType=_,t.toTypeString=a,t.use=function(t,e){if(!le)throw new Error("Invalid use() call. use() can only be called inside of the body of a function model. This could happen for one of the following reasons:\n1. You might be breaking the Rules of Doura\n2. You might have more than one copy of Doura in the same app");const{manager:s,model:n}=le;let i,r;return"string"==typeof t?(r=t,i=s.getModelInstance({name:r,model:e})):i=s.getModelInstance({model:e=t}),n.addChild(i),i.proxy},t}({});
var Doura=function(t){"use strict";const e=()=>{},s=Object.create(null),n=[],i=Object.assign,r=Object.prototype.hasOwnProperty,o=(t,e)=>r.call(t,e),c=Object.prototype.toString,a=t=>c.call(t),l=Array.isArray,h=t=>"[object Map]"===a(t),u=t=>"[object Set]"===a(t),f=t=>"string"==typeof t,p=t=>"symbol"==typeof t,d=t=>null!==t&&"object"==typeof t,_=t=>a(t).slice(8,-1),y=t=>"[object Object]"===a(t),g=t=>f(t)&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,b=(t,e)=>Object.is(t,e),w=(t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})};function v(t,e){if(!t)throw new Error(`[Doura] ${e||""}`)}const S=Array.prototype.slice;const m=Object.prototype.propertyIsEnumerable;function O(t){return Array.isArray(t)?S.call(t):h(t)?new Map(t):u(t)?new Set(t):Object.getPrototypeOf(t)===Object.prototype?function(t){const e={},s=x(t);for(let n=0;n<s.length;n++){const i=s[n],r=t[i];m.call(t,i)?e[i]=r:Object.defineProperty(e,i,{configurable:!0,writable:!0,enumerable:!1,value:r})}return e}(t):function(t){const e=Object.getOwnPropertyDescriptors(t),s=x(e);for(let n=0;n<s.length;n++){const i=s[n],r=e[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(e[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:t[i]})}return Object.create(Object.getPrototypeOf(t),e)}(t)}const x="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?t=>Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)):Object.getOwnPropertyNames;function j(t,...e){console.warn(`[Doura warn] ${t}`,...e)}function E(t){switch(_(t)){case"Object":return 1;case"Array":return 2;case"Set":return 3;case"Map":return 4;default:return 0}}function P(t){return!!t&&!!t.__r_state}function M(t){const e=R(t);return e?M(e.base):t}function R(t){return t&&t.__r_state}function C(t){return t.copy||t.base}function D(t){t.modified||(t.modified=!0,t.parent&&D(t.parent))}let I;class A{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&I&&(this.parent=I,this.index=(I.scopes||(I.scopes=[])).push(this)-1)}run(t){if(this.active){const e=I;try{return I=this,t()}finally{I=e}}}on(){I=this}off(){I=this.parent}stop(t){if(this.active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.active=!1}}}const T=t=>{const e=new Set(t);return e.w=0,e.n=0,e},$=t=>(t.w&H)>0,k=t=>(t.n&H)>0,L=new WeakMap,N=new WeakMap;let V=0,H=1;let U;const X=Symbol(""),K=Symbol("");let z=0;class Y{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.id=z++,this.deps=[],this.active=!0,this.parent=void 0,function(t,e=I){e&&e.active&&e.effects.push(t)}(this,s)}run(){if(!this.active)return this.fn();let t=U;const e=J;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=U,U=this,J=!0,H=1<<++V,V<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=H})(this):F(this),this.fn()}finally{V<=30&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];$(i)&&!k(i)?i.delete(t):e[s++]=i,i.w&=~H,i.n&=~H}e.length=s}})(this),H=1<<--V,U=this.parent,J=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){U===this?this.deferStop=!0:this.active&&(F(this),this.onStop&&this.onStop(),this.active=!1)}}function F(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let J=!0;const W=[];function B(){W.push(J),J=!1}function q(){const t=W.pop();J=void 0===t||t}function G(t,e,s){if(J&&U){let e=L.get(t);e||L.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=T()),Z(n)}}function Q(t){if(J&&U){const e=t.__r_state;if(!e)return;let s=N.get(e);s||N.set(e,s=T()),Z(s)}}function Z(t){let e=!1;V<=30?k(t)||(t.n|=H,e=!$(t)):e=!t.has(U),e&&(t.add(U),U.deps.push(t))}function tt(t){const e=N.get(t);if(e){const t=[...e];for(const e of t)e.view&&(e.view.mightChange=!0)}}function et(t,e,s,n,i){var r;const o=L.get(t),c=t.base;let a=[];if(o)if("clear"===e)a=[...o.values()];else if("length"===s&&l(c))o.forEach(((t,e)=>{("length"===e||e>=n)&&a.push(t)}));else switch(void 0!==s&&a.push(o.get(s)),e){case"add":l(c)?g(s)&&a.push(o.get("length")):(a.push(o.get(X)),h(c)&&a.push(o.get(K)));break;case"delete":l(c)||(a.push(o.get(X)),h(c)&&a.push(o.get(K)));break;case"set":h(c)&&a.push(o.get(X))}if(1===a.length)a[0]&&st(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);st(T(t))}const u=null===(r=t.root)||void 0===r?void 0:r.listeners;u&&u.length&&u.forEach((t=>t()))}function st(t){const e=l(t)?t:[...t];for(const s of e)s.view&&nt(s);for(const s of e)s.view||nt(s)}function nt(t){(t!==U||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}class it{constructor(t,{disableCache:e=!1}){this.dep=void 0,this.mightChange=!1,this.dirty=!0,this.effect=new Y(t,(()=>{this.dirty||(this.dirty=!0,function(t){(t=M(t)).dep&&st(t.dep)}(this))})),this.effect.view=this,this.effect.active=this._cacheable=!e}get value(){const t=M(this);return function(t){J&&U&&Z((t=M(t)).dep||(t.dep=T()))}(t),!t.dirty&&t._cacheable||(t.dirty=!1,t._value=t.effect.run()),t._value}set value(t){}}const rt=new Set(["__proto__"]),ot=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(p));function ct(t){t.copy||(t.copy=O(t.base))}function at(t,e){const s=t.__r_state;return(s?C(s):t)[e]}const lt=ft(),ht=ut();function ut(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=R(this),n=C(s);for(let e=0,r=this.length;e<r;e++)G(s,0,e+"");const i=n[e](...t);return-1===i||!1===i?n[e](...t.map(M)):i}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){B();const s=C(R(this))[e].apply(this,t);return q(),s}})),t}function ft(){return function(t,e,s){const n=C(t);if("__r_isReactive"===e)return!0;if("__r_state"===e&&s===Pt.get(t))return t;if(l(n)&&o(ht,e))return Reflect.get(ht,e,s);let i=Reflect.get(n,e,s);return(p(e)?ot.has(e):rt.has(e))?i:(G(t,0,e),o(n,e)?(t.disposed||!d(i)||(P(i)||(ct(t),i=t.copy[e]=Rt(i,t)),Q(i)),i):i)}}function pt(){return function(t,e,s,n){const i=C(t),r=at(i,e),c=l(i)&&g(e)?Number(e)<i.length:o(i,e);if(!t.modified){const n=null==r?void 0:r.__r_state;if(n&&n.base===s)return t.copy[e]=s,!0;if(b(s,r)&&(void 0!==s||o(t.base,e)))return!0;ct(t),D(t)}return b(t.copy[e],s)&&(void 0!==s||e in t.copy)||(t.copy[e]=s,t===R(n)&&(c?b(s,r)||et(t,"set",e,s):et(t,"add",e,s),function(t){let e=t;for(;e;)tt(e),e=e.parent}(t))),!0}}const dt={get:lt,set:pt(),deleteProperty:function(t,e){const s=o(C(t),e);if((void 0!==at(t.base,e)||e in t.base)&&(ct(t),D(t)),t.copy){const n=delete t.copy[e];return n&&s&&et(t,"delete",e,void 0),n}return!0},has:function(t,e){const s=C(t),n=Reflect.has(s,e);return p(e)&&ot.has(e)||G(t,0,e),n},ownKeys:function(t){const e=C(t);return G(t,0,l(e)?"length":X),Reflect.ownKeys(e)},setPrototypeOf:function(t,e){const s=Reflect.setPrototypeOf(t.base,e);return s&&t.copy&&Reflect.setPrototypeOf(t.copy,e),s},getOwnPropertyDescriptor:function(t,e){const s=C(t),n=Reflect.getOwnPropertyDescriptor(s,e);return n?{writable:!0,configurable:!l(s)||"length"!==e,enumerable:n.enumerable,value:s[e]}:n}};function _t(t){t.copy||(t.copy=new Set,t.base.forEach((e=>{if(d(e)){const s=Rt(e,t);Q(s),e!==s&&t.drafts.set(e,s),t.copy.add(s)}else t.copy.add(e)})))}function yt(t){1===t.type?function(t){t.copy||(t.copy=new Map(t.base))}(t):_t(t)}function gt(t){const e=this.__r_state,s=C(e);if(G(e,0,t),!s.has(t))return;let n=s.get(t);return d(n)?(P(n)||(yt(e),n=Rt(n,e),e.copy.set(t,n)),Q(n),n):n}function bt(t,e){const s=this.__r_state,n=C(s),i=n.has(t),r=n.get(t),o=()=>{yt(s),D(s),s.copy.set(t,e)};return i?b(e,r)||(o(),et(s,"set",t,e)):(o(),et(s,"add",t,e)),this}function wt(t){const e=this.__r_state;return C(e).has(t)||(_t(e),D(e),e.copy.add(t),et(e,"add",t,t)),this}function vt(t){const e=this.__r_state;return G(e,0,t),e.copy?!!e.copy.has(t)||2===e.type&&(e.drafts.has(t)&&e.drafts.has(e.drafts.get(t))):e.base.has(t)}function St(t){const e=this.__r_state,s=C(e),n=s.has(t);"get"in s&&s.get(t),yt(e),D(e);let i=e.copy.delete(t);return 2!==e.type||i||(i=!!e.drafts.has(t)&&e.drafts.delete(e.drafts.get(t))),n&&et(e,"delete",t,void 0),i}function mt(){const t=this.__r_state,e=C(t),s=0!==e.size,n=e.clear();return s&&(yt(t),D(t),t.copy.clear(),et(t,"clear",void 0,void 0)),n}function Ot(){const t={get:gt,get size(){return G(t=this.__r_state,0,X),C(t).size;var t},has:vt,add:wt,set:bt,delete:St,clear:mt,keys(){const t=this.__r_state;return 1===t.type?function(t){return G(t,0,K),C(t).keys()}(t):function(t){return G(t,0,X),_t(t),t.copy.values()}(t)},forEach(t,e){const s=this.__r_state;1===s.type?function(t,e,s,n){G(e,0,X),C(e).forEach(((i,r)=>s.call(n,e.proxy.get(r),r,t)))}(this,s,t,e):function(t,e,s,n){const i=e.proxy.values();let r=i.next();for(;!r.done;)s.call(n,r.value,r.value,t),r=i.next()}(this,s,t,e)}};return["values","entries",Symbol.iterator].forEach((e=>{t[e]=function(t){return function(...e){const s=this.__r_state,n=1===s.type,i="entries"===t||t===Symbol.iterator&&n;if(n){const t=s.proxy.keys();return{next(){const{value:e,done:n}=t.next(),r=s.proxy.get(e);return n?{value:r,done:n}:{value:i?[e,r]:r,done:n}},[Symbol.iterator](){return this}}}return G(s,0,X),_t(s),s.copy[t](...e)}}(e)})),[t]}const[xt]=Ot();function jt(){const t=xt;return(e,s,n)=>{if("__r_isReactive"===s)return!0;if("__r_state"===s)return e;const i=C(e);return Reflect.get(o(t,s)&&s in i?t:i,s,n)}}const Et={get:jt()};const Pt=new WeakMap;let Mt=0;function Rt(t,e){const s=E(t);if(0===s)return t;if(t.__r_skip||!Object.isExtensible(t))return t;if(t.__r_state)return t;let n={type:0,id:Mt++,root:null,parent:e,base:t,proxy:null,copy:null,modified:!1,disposed:!1,listeners:[],children:[]},i=n,r=dt;3===s?(n.type=2,n.drafts=new Map,i=new Set,r=Et):4===s?(n.type=1,i=new Map,r=Et):2===s&&(i=[]),i!==n&&Object.keys(n).forEach((t=>{Object.defineProperty(i,t,{configurable:!0,enumerable:!0,writable:!0,value:n[t]})}));const o=new Proxy(i,r);return i.proxy=o,e?(i.root=e.root,e.children.push(i)):i.root=i,Pt.set(i,o),i.proxy}function Ct(t,e){const s=function(t,{copies:e,snapshots:s}){const n=t=>{switch(E(t)){case 1:case 2:return u;case 4:case 3:return l;default:throw new Error("Unpected Error. Please file an issue on https://github.com/dourajs/doura")}},i=t=>{if(!d(t))return t;if(P(t)){let i=s.get(t);if(!i){const r=e.get(t.__r_state);s.set(t,i=new Proxy(r,n(r)))}return i}return t},r=t=>function(...e){const s=this.__r_raw,n="entries"===t||t===Symbol.iterator&&h(this),r=s[t](...e);return{next(){const{value:t,done:e}=r.next();return e?{value:i(t),done:e}:{value:n?[t[0],i(t[1])]:i(t),done:e}},[Symbol.iterator](){return this}}},c=t=>function(...e){return this.__r_raw[t](...e)},a={get size(){return this.__r_raw.size},get(t){const e=this.__r_raw;if(e.has(t))return i(e.get(t))},forEach(t,e){const s=this.__r_raw;return s.forEach(((n,r)=>(n=i(n),t.call(e,n,h(s)?r:n,s))))}};["has","add","set","delete","clear"].forEach((t=>{a[t]=c(t)})),["keys","values","entries",Symbol.iterator].forEach((t=>{a[t]=r(t)}));const l={get:(t,e,s)=>"__r_raw"===e?t:Reflect.get(o(a,e)&&e in t?a:t,e,s)},u={get:(t,e,s)=>i(Reflect.get(t,e,s))};return n(t)}(t,e);if(P(t)){return new Proxy(e.copies.get(t.__r_state),s)}return new Proxy(t,s)}function Dt(t,e,s){if(!d(t))return t;const n=function(t,e){const s=new Map,n={copies:s,snapshots:e||new Map},i=n.snapshots,r=[t.__r_state];for(;r.length;){const t=r.pop();let e;t.modified?(e=O(t.copy),It(t,e),i.delete(t.proxy)):e=Ct(t.base,n),s.set(t,e);for(const s of t.children)r.push(s)}return n}(e,s);return Ct(t,n)}function It(t,e){t.modified=!1,t.base=e}function At(t,e){const s=t.createView((function(){return e(this,this.$actions)})),n=s.getSnapshot;return n.destory=function(){s.effect.stop();const e=t.effectScope.effects.indexOf(s.effect);e>=0&&t.effectScope.effects.splice(e,1)},n}const Tt=i({$name:t=>t.name,$rawState:t=>t.getState(),$state:t=>t.stateValue,$actions:t=>t.actions,$views:t=>t.views,$patch:t=>t.patch,$onAction:t=>t.onAction,$subscribe:t=>t.subscribe,$isolate:t=>t.isolate,$getApi:t=>t.getApi,$createView:t=>At.bind(null,t)}),$t=t=>({_:e},s)=>{const{actions:n,views:i,accessCache:r,ctx:c}=e;let a;if(a=t?e.getState():e.stateValue,"$"!==s[0]){const t=r[s];if(void 0!==t)switch(t){case 0:return a[s];case 2:return i[s];case 1:return n[s];case 3:return c[s]}else{if(o(a,s))return r[s]=0,a[s];if(o(c,s))return r[s]=3,c[s]}}const l=Tt[s];return l?l(e):o(c,s)?(r[s]=3,c[s]):void((t=>"_"===t||"$"===t)(s[0])&&o(a,s)&&j(`Property ${JSON.stringify(s)} must be accessed via $state because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`))},kt=({_:t},e,s)=>{const{ctx:n,actions:i,views:r,accessContext:c,stateRef:{value:a}}=t;return o(a,e)?1!==c&&(a[e]=s,!0):!o(i,e)&&(!o(r,e)&&("$state"===e?"bigint"!=typeof s&&"symbol"!=typeof s&&(t.replace(s),!0):("$"!==e[0]||!o(Tt,e))&&(n[e]=s,!0)))},Lt={get:$t(!1),set:kt},Nt={get:$t(!0),set:kt};function Vt(t,e,...s){console.error(t)}let Ht=!1,Ut=!1;const Xt=[];let Kt=0;const zt=[];let Yt=null,Ft=0;const Jt=[];let Wt=null,Bt=0;const qt=Promise.resolve();let Gt=null,Qt=null;function Zt(t){Xt.length&&Xt.includes(t,Ht&&t.allowRecurse?Kt+1:Kt)||t===Qt||(null==t.id?Xt.push(t):Xt.splice(function(t){let e=Kt+1,s=Xt.length;for(;e<s;){const n=e+s>>>1;se(Xt[n])<t?e=n+1:s=n}return e}(t.id),0,t),Ht||Ut||(Ut=!0,Gt=qt.then(ne)))}function te(t){const e=Xt.indexOf(t);e>=Kt&&Xt.splice(e,1)}function ee(t,e=null){if(zt.length){for(Qt=e,Yt=[...new Set(zt)],zt.length=0,Ft=0;Ft<Yt.length;Ft++)Yt[Ft]();Yt=null,Ft=0,Qt=null,ee(t,e)}}const se=t=>null==t.id?1/0:t.id;function ne(t){Ut=!1,Ht=!0,ee(t),Xt.sort(((t,e)=>se(t)-se(e)));try{for(Kt=0;Kt<Xt.length;Kt++){const t=Xt[Kt];if(t&&!1!==t.active){0;try{t()}catch(e){Vt(e)}}}}finally{Kt=0,Xt.length=0,function(t){if(ee(),Jt.length){const t=[...new Set(Jt)];if(Jt.length=0,Wt)return void Wt.push(...t);for(Wt=t,Wt.sort(((t,e)=>se(t)-se(e))),Bt=0;Bt<Wt.length;Bt++)Wt[Bt]();Wt=null,Bt=0}}(),Ht=!1,Gt=null,(Xt.length||zt.length||Jt.length)&&ne(t)}}var ie;function re(t,e){const s=Object.keys(e);s.length&&s.forEach((s=>{o(t,s)&&y(e[s])?re(t[s],e[s]):t[s]=e[s]}))}function oe(t){t.dirty=!0}!function(t){t.REPLACE="replace",t.MODIFY="modify",t.PATCH="patch"}(ie||(ie={}));class ce{constructor(t,{name:s,initState:n}){var i;this.viewInstances=[],this._actionDepth=0,this._api=null,this._actionListeners=new Set,this._subscribers=new Set,this._depListenersHandlers=[],this._watchStateChange=!0,this._destroyed=!1,this._lastDraftToSnapshot=new Map,this.patch=this.patch.bind(this),this.onAction=this.onAction.bind(this),this.subscribe=this.subscribe.bind(this),this.isolate=this.isolate.bind(this),this.getApi=this.getApi.bind(this),this._update=this._update.bind(this),this.options=t,this.name=s||"",this._isDispatching=!1,this._initState=n||t.state,this.stateRef=Rt({value:this._initState}),this._update.__name=s,this._draftListenerHandler=function(t,s){const n=t.__r_state;return n.disposed?e:(n.listeners.push(s),()=>{const t=n.listeners.indexOf(s);t>=0&&n.listeners.splice(t,1)})}(this.stateRef,(()=>{this._watchStateChange&&Zt(this._update)})),this._setState(this._initState),this.actions=Object.create(null),this.views=Object.create(null),this.accessContext=0,this.ctx={},w(this.ctx,"_",this),this.accessCache=Object.create(null),this.proxy=new Proxy(this.ctx,Lt),this.publicInst=new Proxy(this.ctx,Nt),this.effectScope=new A(i),this._initActions(),this._initViews()}patch(t){y(t)&&this._currentState&&(this._watchStateChange=!1,re(this.proxy.$state,t),this._watchStateChange=!0,this.dispatch({type:ie.PATCH,args:{patch:t}}))}replace(t){if(d(t)){this._watchStateChange=!1,this.stateRef.value=t,this._watchStateChange=!0;for(const t of this.viewInstances)t.effect.scheduler();this.dispatch({type:ie.REPLACE,payload:t})}else j(`replace argument should be an object, but receive a ${Object.prototype.toString.call(t)}`)}getState(){return this._currentState}getApi(){if(null===this._api){const t=this._api=Object.assign(Object.assign({},this._currentState),this.views);for(const e of Object.keys(this.actions))w(t,e,this.actions[e])}return this._api}onAction(t){return this._actionListeners.add(t),()=>{this._actionListeners.delete(t)}}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}isolate(t){B();const e=t(this.stateValue);return q(),e}depend(t){this._depListenersHandlers.push(t.subscribe((t=>{this._triggerListener(Object.assign(Object.assign({},t),{model:this.proxy}))})))}createView(t){let e;return this.effectScope.run((()=>{e=function(t,e={}){return new it(t,e)}((()=>{const s=this.accessContext;this.accessContext=1;const i=e.__externalArgs;try{return t.call(this.proxy,this.proxy,...i||n)}finally{this.accessContext=s}}))})),e.getSnapshot=()=>{const t=e.value;return e.mightChange?(e.mightChange=!1,e.__snapshot=Dt(t,this.stateRef.value)):e.__pre!==t&&(e.__snapshot=Dt(t,this.stateRef.value)),e.__pre=t,e.__snapshot},this.viewInstances.push(e),e}reducer(t,e){switch(e.type){case ie.MODIFY:case ie.PATCH:{const t=new Map(this._lastDraftToSnapshot);return this._lastDraftToSnapshot=t,Dt(this.stateRef.value,this.stateRef.value,this._lastDraftToSnapshot)}case ie.REPLACE:return e.payload;default:return t}}dispatch(t){if(void 0===t.type)return t;if(this._isDispatching)return t;let e;try{this._isDispatching=!0,e=this.reducer(this._currentState,t)}finally{this._isDispatching=!1}return e!==this._currentState&&(this._setState(e),this._triggerListener(Object.assign({type:t.type,model:this.proxy,target:this.proxy},t.args))),t}destroy(){this._destroyed=!0,this._api=null,this._lastDraftToSnapshot.clear(),this._currentState=null,this.stateRef={value:null},this._subscribers.clear(),this.effectScope.stop();for(const t of this._depListenersHandlers)t();this._draftListenerHandler()}_setState(t){this._api=null,this._currentState=t,this.stateValue=this.stateRef.value}_update(){!this._destroyed&&function(t){return t.__r_state.modified}(this.stateRef)&&(this.dispatch({type:ie.MODIFY}),function(t){const e=t.__r_state;e&&(e.modified=!1)}(this.stateRef))}_triggerListener(t){for(const e of this._subscribers)e(t)}_initActions(){const t=this.options.actions;if(t)for(const e of Object.keys(t)){this.accessCache[e]=1;const s=t[e];Object.defineProperty(this.actions,e,{configurable:!0,enumerable:!0,writable:!1,value:(...t)=>{if(1===this.accessContext)return;let n;this._actionDepth++;try{for(const s of this._actionListeners)s({name:e,args:t});n=s.call(this.proxy,...t)}finally{0==--this._actionDepth&&(te(this._update),this._update())}return n}})}}_initViews(){const t=this.options.views;if(t)for(const e of Object.keys(t)){this.accessCache[e]=2;const s=t[e],n=s.length>1,i=this.createView(s),r=i;0;Object.defineProperty(this.views,e,{configurable:!0,enumerable:!0,get:n?()=>(...t)=>{const e=r.__externalArgs;if(e){if(e.length!==t.length)oe(i);else for(let s=0;s<e.length;s++)if(e[s]!==t[s]){oe(i);break}}else oe(i);return r.__externalArgs=t,i.getSnapshot()}:i.getSnapshot,set:()=>!1})}}}function ae(t,e={}){return new ce(t,e)}let le=null;function he(t){le=t}class ue{constructor(t=s,e=[]){this._subscribers=new Set,this._initialState=t,this._models=(()=>{const t=new Map,e={get:e=>t.get(e),set(e,s){t.set(e,s)},each(e){for(const[s,n]of t.entries())e(n,s)},clear(){e.each((t=>t.destroy())),t.clear()}};return e})();const n=()=>{for(const t of this._subscribers)t()};this._onModelChange=()=>{Zt(n)},this._hooks=e.map((([t,e])=>t(e))),this._hooks.map((e=>{var s;return null===(s=e.onInit)||void 0===s?void 0:s.call(e,{initialState:t},{doura:this})}))}getModel(t,e){return this.getModelInstance({name:t,model:e}).publicInst}getDetachedModel(t){return this.getModelInstance({model:t}).publicInst}getModelInstance({name:t,model:e}){const s=t&&this._models.get(t);if(s)return s;let n;if("function"==typeof e){const s=le,i=this._createModelProxy();try{he({manager:this,model:i}),n=this._initModel({name:t,model:e()})}finally{he(s)}i.setModel(n)}else{if("object"!=typeof e)throw new Error("invalid model");n=this._initModel({name:t,model:e})}return n}getState(){const t={};return this._models.each(((e,s)=>{t[s]=e.getState()})),t}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}destroy(){this._hooks.map((t=>{var e;return null===(e=t.onDestroy)||void 0===e?void 0:e.call(t)})),this._models.clear(),this._subscribers.clear(),this._initialState=s}_createModelProxy(){const t=[];return{addChild(e){t.push(e)},setModel(e){for(const s of t)e.depend(s);t.length=0}}}_initModel({name:t,model:e}){if(!t)return ae(e);this._hooks.map((s=>{var n;return null===(n=s.onModel)||void 0===n?void 0:n.call(s,t,e,{doura:this})}));const s=ae(e,{name:t,initState:this._getInitialState(t)});return s.subscribe(this._onModelChange),this._models.set(t,s),this._hooks.map((t=>{var e;null===(e=t.onModelInstance)||void 0===e||e.call(t,s.publicInst,{doura:this})})),s}_getInitialState(t){const e=this._initialState[t];return e&&delete this._initialState[t],e}}var fe=function(){if("undefined"==typeof window||!window.__REDUX_DEVTOOLS_EXTENSION__)return{};let t=0;const e=new Set;let s;return{onInit(n,{doura:i}){if(window.__doura=i,"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){s=window.__REDUX_DEVTOOLS_EXTENSION__.connect({name:`doura${0===t?"":t}`}),t+=1,s.init(i.getState());const n=t=>{switch(t.type){case"ACTION":return void v("string"==typeof t.payload,"Unsupported action format");case"DISPATCH":switch(t.payload.type){case"RESET":case"COMMIT":return s.init(i.getState());case"ROLLBACK":try{const e=JSON.parse(t.state);return s.init(e)}catch(e){console.warn("[Doura Devtool] Could not parse the received json.")}return s.init(i.getState());case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return}}};e.add(s.subscribe(n))}},onModelInstance(t,{doura:e}){t.$subscribe((t=>{var{type:n,model:i}=t,r=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(s[n[i]]=t[n[i]])}return s}(t,["type","model"]);const o=e.getState();delete o._,s.send(Object.assign({type:`${i.$name||"anonymous"}@${n}`},r),o)}))},onDestroy(){window.__REDUX_DEVTOOLS_EXTENSION__.disconnect(s);for(const t of e.values())t();e.clear()}}};return t.NOOP=e,t.assign=i,t.def=w,t.defineModel=t=>t,t.devtool=fe,t.doura=function({initialState:t,plugins:e=[]}={}){return function({initialState:t,plugins:e}={}){return new ue(t,e)}({initialState:t,plugins:e})},t.draft=Rt,t.each=function(t,e,s=!1){y(t)?(s?Object.keys:x)(t).forEach((n=>{s&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach(((s,n)=>e(n,s,t)))},t.emptyArray=n,t.emptyObject=s,t.hasOwn=o,t.invariant=v,t.is=b,t.isArray=l,t.isFunction=t=>"function"==typeof t,t.isIntegerKey=g,t.isMap=h,t.isObject=d,t.isPlainObject=y,t.isSet=u,t.isString=f,t.isSymbol=p,t.markRaw=function(t){return w(t,"__r_skip",!0),t},t.nextTick=function(t){const e=Gt||qt;return t?e.then(this?t.bind(this):t):e},t.objectToString=c,t.ownKeys=x,t.set=function(t,e,s){h(t)?t.set(e,s):u(t)?(t.delete(e),t.add(s)):t[e]=s},t.shallowCopy=O,t.snapshot=Dt,t.toRawType=_,t.toTypeString=a,t.use=function(t,e){if(!le)throw new Error("Invalid use() call. use() can only be called inside of the body of a function model. This could happen for one of the following reasons:\n1. You might be breaking the Rules of Doura\n2. You might have more than one copy of Doura in the same app");const{manager:s,model:n}=le;let i,r;return"string"==typeof t?(r=t,i=s.getModelInstance({name:r,model:e})):i=s.getModelInstance({model:e=t}),n.addChild(i),i.proxy},t}({});
{
"name": "doura",
"version": "0.0.12",
"version": "0.0.13",
"description": "Reactive and intuitive state management",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc