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.7 to 0.0.8

63

dist/doura.d.ts

@@ -68,8 +68,35 @@ export declare type Action = ModifyAction | PatchAction | ReplaceAction;

export declare function draft<T extends Objectish>(target: T & Target, parent?: DraftState): T & Drafted;
declare type Drafted = {
[ReactiveFlags.STATE]: DraftState;
};
declare type DraftState = ObjectDraftState | MapDraftState | SetDraftState;
declare interface DraftStateBase<T extends AnyObject = AnyObject> {
id: number;
root: DraftState;
parent?: DraftState;
base: T;
proxy: T;
copy: T | null;
modified: boolean;
disposed: boolean;
listeners: Array<() => void>;
children: DraftState[];
}
declare const enum DraftType {
Object = 0,
Map = 1,
Set = 2
}
export declare function each<T extends Objectish>(obj: T, iter: (key: string | number, value: any, source: T) => void, enumerableOnly?: boolean): void;
export declare const emptyArray: readonly [];
export declare const emptyObject: any;
export declare const extend: (d: any, b: any) => any;
export declare interface FunctionModel<S extends State, A extends ActionOptions, V extends ViewOptions> {

@@ -103,2 +130,6 @@ (): ObjectModel<S, A, V>;

declare interface MapDraftState extends DraftStateBase<AnyMap> {
type: DraftType.Map;
}
declare interface ModelAction {

@@ -188,2 +219,6 @@ name: string;

declare interface ObjectDraftState extends DraftStateBase<AnyObject> {
type: DraftType.Object;
}
declare type Objectish = AnyObject | AnyArray | AnyMap | AnySet;

@@ -228,2 +263,9 @@

declare const enum ReactiveFlags {
SKIP = "__r_skip",
IS_REACTIVE = "__r_isReactive",
RAW = "__r_raw",
STATE = "__r_state"
}
declare interface ReplaceAction extends ActionBase {

@@ -237,4 +279,11 @@ type: ActionType.REPLACE;

declare interface SetDraftState extends DraftStateBase<AnySet> {
type: DraftType.Set;
drafts: Map<any, Drafted>;
}
export declare function shallowCopy(base: any): any;
export declare function snapshot<T>(value: T, draft: Drafted): T;
export declare type State = StateObject;

@@ -250,2 +299,8 @@

declare interface Target {
[ReactiveFlags.SKIP]?: boolean;
[ReactiveFlags.IS_REACTIVE]?: boolean;
[ReactiveFlags.STATE]?: DraftState;
}
export declare const toRawType: (value: unknown) => string;

@@ -261,6 +316,6 @@

export declare type ViewOptions<State = any> = Record<string, ((s: State) => any) | (() => any)>;
export declare type ViewOptions<State = any> = Record<string, ((s: State, ...args: any[]) => any) | (() => any)>;
declare type Views<ViewOptions> = {
[K in keyof ViewOptions]: ViewOptions[K] extends (...args: any) => any ? ReturnType<ViewOptions[K]> : never;
[K in keyof ViewOptions]: ViewOptions[K] extends (...args: infer Args) => any ? Args extends [] | [s: any] ? ReturnType<ViewOptions[K]> : Args extends [s: any, ...extArgs: infer ExtArgs] ? (...args: ExtArgs) => ReturnType<ViewOptions[K]> : never : never;
};

@@ -267,0 +322,0 @@

2

dist/doura.esm-browser.prod.js

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

const t=()=>{},e=Object.create(null),s=Object.assign,n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])},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 m=Array.prototype.slice;function S(t){if(l(t))return new Map(t);if(h(t))return new Set(t);if(Array.isArray(t))return m.call(t);const e=Object.getOwnPropertyDescriptors(t);let s=Reflect.ownKeys(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)}const O="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?t=>Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)):Object.getOwnPropertyNames;function x(t,e,s=!1){y(t)?(s?Object.keys:O)(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 j=t=>t;function P(t){switch(_(t)){case"Object":return 1;case"Array":return 2;case"Set":return 3;case"Map":return 4;default:return 0}}function R(t){return!!t&&!!t.__r_state}function C(t){const e=M(t);return e?C(e.base):t}function M(t){return t&&t.__r_state}function D(t){return t.copy||t.base}function A(t){t.modified||(t.modified=!0,t.parent&&A(t.parent))}let I;class ${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 k=t=>{const e=new Set(t);return e.w=0,e.n=0,e},T=t=>(t.w&U)>0,L=t=>(t.n&U)>0,N=new WeakMap,V=new WeakMap;let H=0,U=1;let X;const K=Symbol(""),z=Symbol("");let Y=0;class J{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.id=Y++,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=X,e=W;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=X,X=this,W=!0,U=1<<++H,H<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=U})(this):F(this),this.fn()}finally{H<=30&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];T(i)&&!L(i)?i.delete(t):e[s++]=i,i.w&=~U,i.n&=~U}e.length=s}})(this),U=1<<--H,X=this.parent,W=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){X===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 W=!0;const B=[];function q(){B.push(W),W=!1}function G(){const t=B.pop();W=void 0===t||t}function Q(t,e,s){if(W&&X){let e=N.get(t);e||N.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=k()),tt(n)}}function Z(t){if(W&&X){const e=t.__r_state;if(!e)return;let s=V.get(e);s||V.set(e,s=k()),tt(s)}}function tt(t){let e=!1;H<=30?L(t)||(t.n|=U,e=!T(t)):e=!t.has(X),e&&(t.add(X),X.deps.push(t))}function et(t){const e=V.get(t);if(e){const t=[...e];for(const e of t)e.view&&(e.view.mightChange=!0)}}function st(t,e,s,n,i){var r;const o=N.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(K)),l(c)&&h.push(o.get(z)));break;case"delete":a(c)||(h.push(o.get(K)),l(c)&&h.push(o.get(z)));break;case"set":l(c)&&h.push(o.get(K))}if(1===h.length)h[0]&&nt(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);nt(k(t))}const u=null===(r=t.root)||void 0===r?void 0:r.listeners;u&&u.length&&u.forEach((t=>t()))}function nt(t){const e=a(t)?t:[...t];for(const s of e)s.view&&it(s);for(const s of e)s.view||it(s)}function it(t){(t!==X||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}class rt{constructor(t,{disableCache:e=!1}){this.dep=void 0,this.mightChange=!1,this._dirty=!0,this.effect=new J(t,(()=>{this._dirty||(this._dirty=!0,function(t,e){(t=C(t)).dep&&nt(t.dep)}(this))})),this.effect.view=this,this.effect.active=this._cacheable=!e}get value(){const t=C(this);return function(t){W&&X&&tt((t=C(t)).dep||(t.dep=k()))}(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){}}const ot=new Set(["__proto__"]),ct=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(p));function at(t){t.copy||(t.copy=S(t.base))}function lt(t,e){const s=t.__r_state;return(s?D(s):t)[e]}const ht=pt(),ut=ft();function ft(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=M(this),n=D(s);for(let e=0,r=this.length;e<r;e++)Q(s,0,e+"");const i=n[e](...t);return-1===i||!1===i?n[e](...t.map(C)):i}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){q();const s=D(M(this))[e].apply(this,t);return G(),s}})),t}function pt(){return function(t,e,s){const n=D(t);if("__r_isReactive"===e)return!0;if("__r_state"===e&&s===Rt.get(t))return t;if(a(n)&&r(ut,e))return Reflect.get(ut,e,s);let i=Reflect.get(n,e,s);return(p(e)?ct.has(e):ot.has(e))?i:(Q(t,0,e),r(n,e)?(t.disposed||!d(i)||(R(i)||(at(t),i=t.copy[e]=Mt(i,t)),Z(i)),i):i)}}function dt(){return function(t,e,s,n){const i=D(t),o=lt(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;at(t),A(t)}return b(t.copy[e],s)&&(void 0!==s||e in t.copy)||(t.copy[e]=s,t===M(n)&&(c?b(s,o)||st(t,"set",e,s):st(t,"add",e,s),function(t){let e=t;for(;e;)et(e),e=e.parent}(t))),!0}}const _t={get:ht,set:dt(),deleteProperty:function(t,e){const s=r(D(t),e);if((void 0!==lt(t.base,e)||e in t.base)&&(at(t),A(t)),t.copy){const n=delete t.copy[e];return n&&s&&st(t,"delete",e,void 0),n}return!0},has:function(t,e){const s=D(t),n=Reflect.has(s,e);return p(e)&&ct.has(e)||Q(t,0,e),n},ownKeys:function(t){const e=D(t);return Q(t,0,a(e)?"length":K),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=D(t),n=Reflect.getOwnPropertyDescriptor(s,e);return n?{writable:!0,configurable:!a(s)||"length"!==e,enumerable:n.enumerable,value:s[e]}:n}};function yt(t){t.copy||(t.copy=new Set,t.base.forEach((e=>{if(d(e)){const s=Mt(e,t);Z(s),e!==s&&t.drafts.set(e,s),t.copy.add(s)}else t.copy.add(e)})))}function gt(t){1===t.type?function(t){t.copy||(t.copy=new Map(t.base))}(t):yt(t)}function bt(t){const e=this.__r_state,s=D(e);if(Q(e,0,t),!s.has(t))return;let n=s.get(t);return d(n)?(R(n)||(gt(e),n=Mt(n,e),e.copy.set(t,n)),Z(n),n):n}function wt(t,e){const s=this.__r_state,n=D(s),i=n.has(t),r=n.get(t),o=()=>{gt(s),A(s),s.copy.set(t,e)};return i?b(e,r)||(o(),st(s,"set",t,e)):(o(),st(s,"add",t,e)),this}function vt(t){const e=this.__r_state;return D(e).has(t)||(yt(e),A(e),e.copy.add(t),st(e,"add",t,t)),this}function mt(t){const e=this.__r_state;return Q(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=D(e),n=s.has(t);"get"in s&&s.get(t),gt(e),A(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&&st(e,"delete",t,void 0),i}function Ot(){const t=this.__r_state,e=D(t),s=0!==e.size,n=e.clear();return s&&(gt(t),A(t),t.copy.clear(),st(t,"clear",void 0,void 0)),n}function xt(){const t={get:bt,get size(){return Q(t=this.__r_state,0,K),D(t).size;var t},has:mt,add:vt,set:wt,delete:St,clear:Ot,keys(){const t=this.__r_state;return 1===t.type?function(t){return Q(t,0,z),D(t).keys()}(t):function(t){return Q(t,0,K),yt(t),t.copy.values()}(t)},forEach(t,e){const s=this.__r_state;1===s.type?function(t,e,s,n){Q(e,0,K),D(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 Q(s,0,K),yt(s),s.copy[t](...e)}}(e)})),[t]}const[Et]=xt();function jt(){const t=Et;return(e,s,n)=>{if("__r_isReactive"===s)return!0;if("__r_state"===s)return e;const i=D(e);return Reflect.get(r(t,s)&&s in i?t:i,s,n)}}const Pt={get:jt()};const Rt=new WeakMap;let Ct=0;function Mt(t,e){const s=P(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:Ct++,root:null,parent:e,base:t,proxy:null,copy:null,modified:!1,disposed:!1,listeners:[],children:[]},i=n,r=_t;3===s?(n.type=2,n.drafts=new Map,i=new Set,r=Pt):4===s?(n.type=1,i=new Map,r=Pt):2===s&&(i=new Array),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,Rt.set(i,o),i.proxy}function Dt(t,e){const s=function(t,{copies:e,proxies:s}){const n=t=>{switch(P(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(R(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(R(t)){return new Proxy(e.copies.get(t.__r_state),s)}return new Proxy(S(t),s)}function At(t,e){if(!d(t))return t;const s=function(t){const e=new Map,s={copies:e,proxies:new Map},n=[t.__r_state];for(;n.length;){const t=n.pop();let s;t.modified?(s=S(t.copy),It(t,s)):s=t.base,e.set(t,s);for(const e of t.children)n.push(e)}return s}(e);return Dt(t,s)}function It(t,e){t.modified=!1,t.base=e}function $t(t,e){const s=t.createView((function(){return e(this,this.$actions)})),n=function(){return s.value};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 kt=s({$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=>$t.bind(null,t)}),Tt={get:({_:t},e)=>{const{actions:s,views:n,accessCache:i,ctx:o,stateValue:c}=t;if("$"!==e[0]){const t=i[e];if(void 0!==t)switch(t){case 0:return c[e];case 2:return n[e];case 1:return s[e];case 3:return o[e]}else{if(r(c,e))return i[e]=0,c[e];if(r(o,e))return i[e]=3,o[e]}}const a=kt[e];return a?a(t):r(o,e)?(i[e]=3,o[e]):void((t=>"_"===t||"$"===t)(e[0])&&r(c,e)&&function(t,...e){console.warn(`[Doura warn] ${t}`,...e)}(`Property ${JSON.stringify(e)} must be accessed via $state because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`))},set({_: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(kt,e))&&(n[e]=s,!0)))},has({_:t},e){const{actions:s,views:n,accessCache:i,accessContext:o,ctx:c,stateValue:a}=t;return!!i[e]||r(a,e)||r(n,e)||1!==o&&r(s,e)||r(c,e)||r(kt,e)}},Lt={0:"scheduler flush. This is likely a Doura internals bug. Please open an issue at https://github.com/dourajs/doura/issues/new"};function Nt(t,e,...s){const n=Lt[e],i=n?"function"==typeof n?n.apply(null,s):n:"unknown error nr: "+Nt;throw new Error(`[Doura] ${i}`)}let Vt=!1,Ht=!1;const Ut=[];let Xt=0;const Kt=[];let zt=null,Yt=0;const Jt=[];let Ft=null,Wt=0;const Bt=Promise.resolve();let qt=null,Gt=null;function Qt(t){const e=qt||Bt;return t?e.then(this?t.bind(this):t):e}function Zt(t){Ut.length&&Ut.includes(t,Vt&&t.allowRecurse?Xt+1:Xt)||t===Gt||(null==t.id?Ut.push(t):Ut.splice(function(t){let e=Xt+1,s=Ut.length;for(;e<s;){const n=e+s>>>1;ee(Ut[n])<t?e=n+1:s=n}return e}(t.id),0,t),Vt||Ht||(Ht=!0,qt=Bt.then(se)))}function te(t,e=null){if(Kt.length){for(Gt=e,zt=[...new Set(Kt)],Kt.length=0,Yt=0;Yt<zt.length;Yt++)zt[Yt]();zt=null,Yt=0,Gt=null,te(t,e)}}const ee=t=>null==t.id?1/0:t.id;function se(t){Ht=!1,Vt=!0,te(t),Ut.sort(((t,e)=>ee(t)-ee(e)));try{for(Xt=0;Xt<Ut.length;Xt++){const t=Ut[Xt];if(t&&!1!==t.active){0;try{t()}catch(e){Nt(0,0)}}}}finally{Xt=0,Ut.length=0,function(t){if(te(),Jt.length){const t=[...new Set(Jt)];if(Jt.length=0,Ft)return void Ft.push(...t);for(Ft=t,Ft.sort(((t,e)=>ee(t)-ee(e))),Wt=0;Wt<Ft.length;Wt++)Ft[Wt]();Ft=null,Wt=0}}(),Vt=!1,qt=null,(Ut.length||Kt.length||Jt.length)&&se(t)}}var ne;function ie(t,e){const s=Object.keys(e);s.length&&s.forEach((s=>{r(t,s)&&y(e[s])?ie(t[s],e[s]):t[s]=e[s]}))}!function(t){t.REPLACE="replace",t.MODIFY="modify",t.PATCH="patch"}(ne||(ne={}));class re{constructor(e,{name:s,initState:n}){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.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.options=e,this.name=s||"",this._isDispatching=!1,this._initState=n||e.state,this.stateRef=Mt({value:this._initState});const i=this._update.bind(this);var r;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&&Zt(i)})),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,Tt),this.effectScope=new $(r),this._initActions(),this._initViews()}patch(t){y(t)&&this._currentState&&(this._watchStateChange=!1,ie(this.proxy.$state,t),this._watchStateChange=!0,this.dispatch({type:ne.PATCH,payload:At(this.stateRef.value,this.stateRef.value),args:{patch:t}}))}replace(t){this._watchStateChange=!1,this.stateRef.value=t,this._watchStateChange=!0;for(const e of this.viewInstances)e.effect.scheduler();this.dispatch({type:ne.REPLACE,payload: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 G(),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 rt(t,e)}((()=>{const e=this.accessContext;this.accessContext=1;try{return t.call(this.proxy,this.proxy)}finally{this.accessContext=e}}))})),this.viewInstances.push(e),e}reducer(t,e){switch(e.type){case ne.REPLACE:case ne.MODIFY:case ne.PATCH: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._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:ne.MODIFY,payload:At(this.stateRef.value,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&&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=this.createView(t[e]),n=this;Object.defineProperty(this.views,e,{configurable:!0,enumerable:!0,get(){const t=s;let e=s.value;return s.mightChange?(s.mightChange=!1,t.__snapshot=At(e,n.stateRef.value)):t.__pre!==e&&(t.__snapshot=At(e,n.stateRef.value)),t.__pre=e,t.__snapshot},set:()=>!1})}}}function oe(t,e={}){return new re(t,e)}let ce=null;function ae(t){ce=t}class le{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=()=>{Zt(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}).proxy}getDetachedModel(t){return this.getModelInstance({model:t}).proxy}getModelInstance({name:t,model:e}){const s=t&&this._models.get(t);if(s)return s;let n;if("function"==typeof e){let s=ce;const i=this._createModelProxy();try{ae({manager:this,model:i}),n=this._initModel({name:t,model:e()})}finally{ae(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 oe(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=oe(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.proxy,{doura:this})})),s}_getInitialState(t){const e=this._initialState[t];return e&&delete this._initialState[t],e}}function he(t,e){if(!ce)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}=ce;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 ue({initialState:t,plugins:e=[]}={}){return function({initialState:t,plugins:e}={}){return new le(t,e)}({initialState:t,plugins:e})}var fe=function(){if("undefined"==typeof window||!window.__REDUX_DEVTOOLS_EXTENSION__)return{};let t=0;const e=new Set;let s;return{onInit({},{doura:n}){if(window.__doura=n,"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){s=window.__REDUX_DEVTOOLS_EXTENSION__.connect({name:`doura${0===t?"":t}`}),t+=1,s.init(n.getState());const i=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(n.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(n.getState());case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return}}};e.add(s.subscribe(i))}},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","target","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,s as assign,w as def,j as defineModel,fe as devtool,ue as doura,x as each,e as emptyObject,n as extend,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,Qt as nextTick,o as objectToString,O as ownKeys,E as set,S as shallowCopy,_ as toRawType,c as toTypeString,he 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 m=Array.prototype.slice;function S(t){if(l(t))return new Map(t);if(h(t))return new Set(t);if(Array.isArray(t))return m.call(t);const e=Object.getOwnPropertyDescriptors(t),s=Reflect.ownKeys(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)}const O="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?t=>Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)):Object.getOwnPropertyNames;function x(t,e,s=!1){y(t)?(s?Object.keys:O)(t).forEach((n=>{s&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach(((s,n)=>e(n,s,t)))}function j(t,e,s){l(t)?t.set(e,s):h(t)?(t.delete(e),t.add(s)):t[e]=s}const E=t=>t;function P(t,...e){console.warn(`[Doura warn] ${t}`,...e)}function M(t){switch(_(t)){case"Object":return 1;case"Array":return 2;case"Set":return 3;case"Map":return 4;default:return 0}}function R(t){return!!t&&!!t.__r_state}function C(t){const e=I(t);return e?C(e.base):t}function I(t){return t&&t.__r_state}function A(t){return t.copy||t.base}function D(t){t.modified||(t.modified=!0,t.parent&&D(t.parent))}let $;class k{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&$&&(this.parent=$,this.index=($.scopes||($.scopes=[])).push(this)-1)}run(t){if(this.active){const e=$;try{return $=this,t()}finally{$=e}}}on(){$=this}off(){$=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},T=t=>(t.w&X)>0,N=t=>(t.n&X)>0,V=new WeakMap,H=new WeakMap;let U=0,X=1;let K;const z=Symbol(""),Y=Symbol("");let J=0;class F{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.id=J++,this.deps=[],this.active=!0,this.parent=void 0,function(t,e=$){e&&e.active&&e.effects.push(t)}(this,s)}run(){if(!this.active)return this.fn();let t=K;const e=B;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=K,K=this,B=!0,X=1<<++U,U<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=X})(this):W(this),this.fn()}finally{U<=30&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];T(i)&&!N(i)?i.delete(t):e[s++]=i,i.w&=~X,i.n&=~X}e.length=s}})(this),X=1<<--U,K=this.parent,B=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){K===this?this.deferStop=!0:this.active&&(W(this),this.onStop&&this.onStop(),this.active=!1)}}function W(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let B=!0;const q=[];function G(){q.push(B),B=!1}function Q(){const t=q.pop();B=void 0===t||t}function Z(t,e,s){if(B&&K){let e=V.get(t);e||V.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=L()),et(n)}}function tt(t){if(B&&K){const e=t.__r_state;if(!e)return;let s=H.get(e);s||H.set(e,s=L()),et(s)}}function et(t){let e=!1;U<=30?N(t)||(t.n|=X,e=!T(t)):e=!t.has(K),e&&(t.add(K),K.deps.push(t))}function st(t){const e=H.get(t);if(e){const t=[...e];for(const e of t)e.view&&(e.view.mightChange=!0)}}function nt(t,e,s,n,i){var r;const o=V.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(z)),l(c)&&h.push(o.get(Y)));break;case"delete":a(c)||(h.push(o.get(z)),l(c)&&h.push(o.get(Y)));break;case"set":l(c)&&h.push(o.get(z))}if(1===h.length)h[0]&&it(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);it(L(t))}const u=null===(r=t.root)||void 0===r?void 0:r.listeners;u&&u.length&&u.forEach((t=>t()))}function it(t){const e=a(t)?t:[...t];for(const s of e)s.view&&rt(s);for(const s of e)s.view||rt(s)}function rt(t){(t!==K||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}class ot{constructor(t,{disableCache:e=!1}){this.dep=void 0,this.mightChange=!1,this.dirty=!0,this.effect=new F(t,(()=>{this.dirty||(this.dirty=!0,function(t){(t=C(t)).dep&&it(t.dep)}(this))})),this.effect.view=this,this.effect.active=this._cacheable=!e}get value(){const t=C(this);return function(t){B&&K&&et((t=C(t)).dep||(t.dep=L()))}(t),!t.dirty&&t._cacheable||(t.dirty=!1,t._value=t.effect.run()),t._value}set value(t){}}const ct=new Set(["__proto__"]),at=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(p));function lt(t){t.copy||(t.copy=S(t.base))}function ht(t,e){const s=t.__r_state;return(s?A(s):t)[e]}const ut=dt(),ft=pt();function pt(){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++)Z(s,0,e+"");const i=n[e](...t);return-1===i||!1===i?n[e](...t.map(C)):i}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){G();const s=A(I(this))[e].apply(this,t);return Q(),s}})),t}function dt(){return function(t,e,s){const n=A(t);if("__r_isReactive"===e)return!0;if("__r_state"===e&&s===Rt.get(t))return t;if(a(n)&&r(ft,e))return Reflect.get(ft,e,s);let i=Reflect.get(n,e,s);return(p(e)?at.has(e):ct.has(e))?i:(Z(t,0,e),r(n,e)?(t.disposed||!d(i)||(R(i)||(lt(t),i=t.copy[e]=It(i,t)),tt(i)),i):i)}}function _t(){return function(t,e,s,n){const i=A(t),o=ht(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;lt(t),D(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)||nt(t,"set",e,s):nt(t,"add",e,s),function(t){let e=t;for(;e;)st(e),e=e.parent}(t))),!0}}const yt={get:ut,set:_t(),deleteProperty:function(t,e){const s=r(A(t),e);if((void 0!==ht(t.base,e)||e in t.base)&&(lt(t),D(t)),t.copy){const n=delete t.copy[e];return n&&s&&nt(t,"delete",e,void 0),n}return!0},has:function(t,e){const s=A(t),n=Reflect.has(s,e);return p(e)&&at.has(e)||Z(t,0,e),n},ownKeys:function(t){const e=A(t);return Z(t,0,a(e)?"length":z),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 gt(t){t.copy||(t.copy=new Set,t.base.forEach((e=>{if(d(e)){const s=It(e,t);tt(s),e!==s&&t.drafts.set(e,s),t.copy.add(s)}else t.copy.add(e)})))}function bt(t){1===t.type?function(t){t.copy||(t.copy=new Map(t.base))}(t):gt(t)}function wt(t){const e=this.__r_state,s=A(e);if(Z(e,0,t),!s.has(t))return;let n=s.get(t);return d(n)?(R(n)||(bt(e),n=It(n,e),e.copy.set(t,n)),tt(n),n):n}function vt(t,e){const s=this.__r_state,n=A(s),i=n.has(t),r=n.get(t),o=()=>{bt(s),D(s),s.copy.set(t,e)};return i?b(e,r)||(o(),nt(s,"set",t,e)):(o(),nt(s,"add",t,e)),this}function mt(t){const e=this.__r_state;return A(e).has(t)||(gt(e),D(e),e.copy.add(t),nt(e,"add",t,t)),this}function St(t){const e=this.__r_state;return Z(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 Ot(t){const e=this.__r_state,s=A(e),n=s.has(t);"get"in s&&s.get(t),bt(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&&nt(e,"delete",t,void 0),i}function xt(){const t=this.__r_state,e=A(t),s=0!==e.size,n=e.clear();return s&&(bt(t),D(t),t.copy.clear(),nt(t,"clear",void 0,void 0)),n}function jt(){const t={get:wt,get size(){return Z(t=this.__r_state,0,z),A(t).size;var t},has:St,add:mt,set:vt,delete:Ot,clear:xt,keys(){const t=this.__r_state;return 1===t.type?function(t){return Z(t,0,Y),A(t).keys()}(t):function(t){return Z(t,0,z),gt(t),t.copy.values()}(t)},forEach(t,e){const s=this.__r_state;1===s.type?function(t,e,s,n){Z(e,0,z),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 Z(s,0,z),gt(s),s.copy[t](...e)}}(e)})),[t]}const[Et]=jt();function Pt(){const t=Et;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 Mt={get:Pt()};const Rt=new WeakMap;let Ct=0;function It(t,e){const s=M(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:Ct++,root:null,parent:e,base:t,proxy:null,copy:null,modified:!1,disposed:!1,listeners:[],children:[]},i=n,r=yt;3===s?(n.type=2,n.drafts=new Map,i=new Set,r=Mt):4===s?(n.type=1,i=new Map,r=Mt):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,Rt.set(i,o),i.proxy}function At(t,e){const s=function(t,{copies:e,proxies:s}){const n=t=>{switch(M(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(R(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(R(t)){return new Proxy(e.copies.get(t.__r_state),s)}return new Proxy(S(t),s)}function Dt(t,e){if(!d(t))return t;const s=function(t){const e=new Map,s={copies:e,proxies:new Map},n=[t.__r_state];for(;n.length;){const t=n.pop();let s;t.modified?(s=S(t.copy),$t(t,s)):s=t.base,e.set(t,s);for(const e of t.children)n.push(e)}return s}(e);return At(t,s)}function $t(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)}),Tt=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)&&P(`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.`))},Nt=({_: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)))},Vt={get:Tt(!1),set:Nt},Ht={get:Tt(!0),set:Nt};function Ut(t,e,...s){console.error(t)}let Xt=!1,Kt=!1;const zt=[];let Yt=0;const Jt=[];let Ft=null,Wt=0;const Bt=[];let qt=null,Gt=0;const Qt=Promise.resolve();let Zt=null,te=null;function ee(t){const e=Zt||Qt;return t?e.then(this?t.bind(this):t):e}function se(t){zt.length&&zt.includes(t,Xt&&t.allowRecurse?Yt+1:Yt)||t===te||(null==t.id?zt.push(t):zt.splice(function(t){let e=Yt+1,s=zt.length;for(;e<s;){const n=e+s>>>1;ie(zt[n])<t?e=n+1:s=n}return e}(t.id),0,t),Xt||Kt||(Kt=!0,Zt=Qt.then(re)))}function ne(t,e=null){if(Jt.length){for(te=e,Ft=[...new Set(Jt)],Jt.length=0,Wt=0;Wt<Ft.length;Wt++)Ft[Wt]();Ft=null,Wt=0,te=null,ne(t,e)}}const ie=t=>null==t.id?1/0:t.id;function re(t){Kt=!1,Xt=!0,ne(t),zt.sort(((t,e)=>ie(t)-ie(e)));try{for(Yt=0;Yt<zt.length;Yt++){const t=zt[Yt];if(t&&!1!==t.active){0;try{t()}catch(e){Ut(e)}}}}finally{Yt=0,zt.length=0,function(t){if(ne(),Bt.length){const t=[...new Set(Bt)];if(Bt.length=0,qt)return void qt.push(...t);for(qt=t,qt.sort(((t,e)=>ie(t)-ie(e))),Gt=0;Gt<qt.length;Gt++)qt[Gt]();qt=null,Gt=0}}(),Xt=!1,Zt=null,(zt.length||Jt.length||Bt.length)&&re(t)}}var oe;function ce(t,e){const s=Object.keys(e);s.length&&s.forEach((s=>{r(t,s)&&y(e[s])?ce(t[s],e[s]):t[s]=e[s]}))}function ae(t){t.dirty=!0}!function(t){t.REPLACE="replace",t.MODIFY="modify",t.PATCH="patch"}(oe||(oe={}));class le{constructor(e,{name:s,initState:n}){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.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.options=e,this.name=s||"",this._isDispatching=!1,this._initState=n||e.state,this.stateRef=It({value:this._initState});const i=this._update.bind(this);var r;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&&se(i)})),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,Vt),this.publicInst=new Proxy(this.ctx,Ht),this.effectScope=new k(r),this._initActions(),this._initViews()}patch(t){y(t)&&this._currentState&&(this._watchStateChange=!1,ce(this.proxy.$state,t),this._watchStateChange=!0,this.dispatch({type:oe.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:oe.REPLACE,payload:t})}else P(`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){G();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 ot(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=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 oe.MODIFY:case oe.PATCH:return Dt(this.stateRef.value,this.stateRef.value);case oe.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._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.value)&&this.dispatch({type:oe.MODIFY})}_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&&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;Object.defineProperty(this.views,e,{configurable:!0,enumerable:!0,get:n?()=>(...t)=>{const e=r.__externalArgs;if(e){if(e.length!==t.length)ae(i);else for(let s=0;s<e.length;s++)if(e[s]!==t[s]){ae(i);break}}else ae(i);return r.__externalArgs=t,i.getSnapshot()}:i.getSnapshot,set:()=>!1})}}}function he(t,e={}){return new le(t,e)}let ue=null;function fe(t){ue=t}class pe{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=()=>{se(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=ue,i=this._createModelProxy();try{fe({manager:this,model:i}),n=this._initModel({name:t,model:e()})}finally{fe(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 he(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=he(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 de(t,e){if(!ue)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}=ue;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 _e({initialState:t,plugins:e=[]}={}){return function({initialState:t,plugins:e}={}){return new pe(t,e)}({initialState:t,plugins:e})}var ye=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,E as defineModel,ye as devtool,_e as doura,It as draft,x 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,ee as nextTick,o as objectToString,O as ownKeys,j as set,S as shallowCopy,Dt as snapshot,_ as toRawType,c as toTypeString,de as use};

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

var Doura=function(t){"use strict";const e=()=>{},s=Object.create(null),n=Object.assign,i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])},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 m=Array.prototype.slice;function S(t){if(h(t))return new Map(t);if(u(t))return new Set(t);if(Array.isArray(t))return m.call(t);const e=Object.getOwnPropertyDescriptors(t);let s=Reflect.ownKeys(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)}const O="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?t=>Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)):Object.getOwnPropertyNames;function x(t){switch(_(t)){case"Object":return 1;case"Array":return 2;case"Set":return 3;case"Map":return 4;default:return 0}}function j(t){return!!t&&!!t.__r_state}function E(t){const e=P(t);return e?E(e.base):t}function P(t){return t&&t.__r_state}function R(t){return t.copy||t.base}function M(t){t.modified||(t.modified=!0,t.parent&&M(t.parent))}let C;class D{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&C&&(this.parent=C,this.index=(C.scopes||(C.scopes=[])).push(this)-1)}run(t){if(this.active){const e=C;try{return C=this,t()}finally{C=e}}}on(){C=this}off(){C=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 A=t=>{const e=new Set(t);return e.w=0,e.n=0,e},I=t=>(t.w&N)>0,$=t=>(t.n&N)>0,T=new WeakMap,k=new WeakMap;let L=0,N=1;let V;const H=Symbol(""),K=Symbol("");let U=0;class X{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.id=U++,this.deps=[],this.active=!0,this.parent=void 0,function(t,e=C){e&&e.active&&e.effects.push(t)}(this,s)}run(){if(!this.active)return this.fn();let t=V,e=Y;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=V,V=this,Y=!0,N=1<<++L,L<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=N})(this):z(this),this.fn()}finally{L<=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(i)&&!$(i)?i.delete(t):e[s++]=i,i.w&=~N,i.n&=~N}e.length=s}})(this),N=1<<--L,V=this.parent,Y=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){V===this?this.deferStop=!0:this.active&&(z(this),this.onStop&&this.onStop(),this.active=!1)}}function z(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let Y=!0;const F=[];function J(){F.push(Y),Y=!1}function W(){const t=F.pop();Y=void 0===t||t}function B(t,e,s){if(Y&&V){let e=T.get(t);e||T.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=A()),G(n)}}function q(t){if(Y&&V){const e=t.__r_state;if(!e)return;let s=k.get(e);s||k.set(e,s=A()),G(s)}}function G(t){let e=!1;L<=30?$(t)||(t.n|=N,e=!I(t)):e=!t.has(V),e&&(t.add(V),V.deps.push(t))}function Q(t){const e=k.get(t);if(e){const t=[...e];for(const e of t)e.view&&(e.view.mightChange=!0)}}function Z(t,e,s,n,i){var r;const o=T.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(H)),h(c)&&a.push(o.get(K)));break;case"delete":l(c)||(a.push(o.get(H)),h(c)&&a.push(o.get(K)));break;case"set":h(c)&&a.push(o.get(H))}if(1===a.length)a[0]&&tt(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);tt(A(t))}const u=null===(r=t.root)||void 0===r?void 0:r.listeners;u&&u.length&&u.forEach((t=>t()))}function tt(t){const e=l(t)?t:[...t];for(const s of e)s.view&&et(s);for(const s of e)s.view||et(s)}function et(t){(t!==V||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}class st{constructor(t,{disableCache:e=!1}){this.dep=void 0,this.mightChange=!1,this._dirty=!0,this.effect=new X(t,(()=>{this._dirty||(this._dirty=!0,function(t,e){(t=E(t)).dep&&tt(t.dep)}(this))})),this.effect.view=this,this.effect.active=this._cacheable=!e}get value(){const t=E(this);return function(t){Y&&V&&G((t=E(t)).dep||(t.dep=A()))}(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){}}const nt=new Set(["__proto__"]),it=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(p));function rt(t){t.copy||(t.copy=S(t.base))}function ot(t,e){const s=t.__r_state;return(s?R(s):t)[e]}const ct=ht(),at=lt();function lt(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=P(this),n=R(s);for(let e=0,r=this.length;e<r;e++)B(s,0,e+"");const i=n[e](...t);return-1===i||!1===i?n[e](...t.map(E)):i}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){J();const s=R(P(this))[e].apply(this,t);return W(),s}})),t}function ht(){return function(t,e,s){const n=R(t);if("__r_isReactive"===e)return!0;if("__r_state"===e&&s===jt.get(t))return t;if(l(n)&&o(at,e))return Reflect.get(at,e,s);let i=Reflect.get(n,e,s);return(p(e)?it.has(e):nt.has(e))?i:(B(t,0,e),o(n,e)?(t.disposed||!d(i)||(j(i)||(rt(t),i=t.copy[e]=Pt(i,t)),q(i)),i):i)}}function ut(){return function(t,e,s,n){const i=R(t),r=ot(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;rt(t),M(t)}return b(t.copy[e],s)&&(void 0!==s||e in t.copy)||(t.copy[e]=s,t===P(n)&&(c?b(s,r)||Z(t,"set",e,s):Z(t,"add",e,s),function(t){let e=t;for(;e;)Q(e),e=e.parent}(t))),!0}}const ft={get:ct,set:ut(),deleteProperty:function(t,e){const s=o(R(t),e);if((void 0!==ot(t.base,e)||e in t.base)&&(rt(t),M(t)),t.copy){const n=delete t.copy[e];return n&&s&&Z(t,"delete",e,void 0),n}return!0},has:function(t,e){const s=R(t),n=Reflect.has(s,e);return p(e)&&it.has(e)||B(t,0,e),n},ownKeys:function(t){const e=R(t);return B(t,0,l(e)?"length":H),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=R(t),n=Reflect.getOwnPropertyDescriptor(s,e);return n?{writable:!0,configurable:!l(s)||"length"!==e,enumerable:n.enumerable,value:s[e]}:n}};function pt(t){t.copy||(t.copy=new Set,t.base.forEach((e=>{if(d(e)){const s=Pt(e,t);q(s),e!==s&&t.drafts.set(e,s),t.copy.add(s)}else t.copy.add(e)})))}function dt(t){1===t.type?function(t){t.copy||(t.copy=new Map(t.base))}(t):pt(t)}function _t(t){const e=this.__r_state,s=R(e);if(B(e,0,t),!s.has(t))return;let n=s.get(t);return d(n)?(j(n)||(dt(e),n=Pt(n,e),e.copy.set(t,n)),q(n),n):n}function yt(t,e){const s=this.__r_state,n=R(s),i=n.has(t),r=n.get(t),o=()=>{dt(s),M(s),s.copy.set(t,e)};return i?b(e,r)||(o(),Z(s,"set",t,e)):(o(),Z(s,"add",t,e)),this}function gt(t){const e=this.__r_state;return R(e).has(t)||(pt(e),M(e),e.copy.add(t),Z(e,"add",t,t)),this}function bt(t){const e=this.__r_state;return B(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 wt(t){const e=this.__r_state,s=R(e),n=s.has(t);"get"in s&&s.get(t),dt(e),M(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&&Z(e,"delete",t,void 0),i}function vt(){const t=this.__r_state,e=R(t),s=0!==e.size,n=e.clear();return s&&(dt(t),M(t),t.copy.clear(),Z(t,"clear",void 0,void 0)),n}function mt(){const t={get:_t,get size(){return B(t=this.__r_state,0,H),R(t).size;var t},has:bt,add:gt,set:yt,delete:wt,clear:vt,keys(){const t=this.__r_state;return 1===t.type?function(t){return B(t,0,K),R(t).keys()}(t):function(t){return B(t,0,H),pt(t),t.copy.values()}(t)},forEach(t,e){const s=this.__r_state;1===s.type?function(t,e,s,n){B(e,0,H),R(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 B(s,0,H),pt(s),s.copy[t](...e)}}(e)})),[t]}const[St]=mt();function Ot(){const t=St;return(e,s,n)=>{if("__r_isReactive"===s)return!0;if("__r_state"===s)return e;const i=R(e);return Reflect.get(o(t,s)&&s in i?t:i,s,n)}}const xt={get:Ot()};const jt=new WeakMap;let Et=0;function Pt(t,e){const s=x(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:Et++,root:null,parent:e,base:t,proxy:null,copy:null,modified:!1,disposed:!1,listeners:[],children:[]},i=n,r=ft;3===s?(n.type=2,n.drafts=new Map,i=new Set,r=xt):4===s?(n.type=1,i=new Map,r=xt):2===s&&(i=new Array),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,jt.set(i,o),i.proxy}function Rt(t,e){const s=function(t,{copies:e,proxies:s}){const n=t=>{switch(x(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(j(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(j(t)){return new Proxy(e.copies.get(t.__r_state),s)}return new Proxy(S(t),s)}function Mt(t,e){if(!d(t))return t;const s=function(t){const e=new Map,s={copies:e,proxies:new Map},n=[t.__r_state];for(;n.length;){const t=n.pop();let s;t.modified?(s=S(t.copy),Ct(t,s)):s=t.base,e.set(t,s);for(const e of t.children)n.push(e)}return s}(e);return Rt(t,s)}function Ct(t,e){t.modified=!1,t.base=e}function Dt(t,e){const s=t.createView((function(){return e(this,this.$actions)})),n=function(){return s.value};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 At=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=>Dt.bind(null,t)}),It={get:({_:t},e)=>{const{actions:s,views:n,accessCache:i,ctx:r,stateValue:c}=t;if("$"!==e[0]){const t=i[e];if(void 0!==t)switch(t){case 0:return c[e];case 2:return n[e];case 1:return s[e];case 3:return r[e]}else{if(o(c,e))return i[e]=0,c[e];if(o(r,e))return i[e]=3,r[e]}}const a=At[e];return a?a(t):o(r,e)?(i[e]=3,r[e]):void((t=>"_"===t||"$"===t)(e[0])&&o(c,e)&&function(t,...e){console.warn(`[Doura warn] ${t}`,...e)}(`Property ${JSON.stringify(e)} must be accessed via $state because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`))},set({_: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(At,e))&&(n[e]=s,!0)))},has({_:t},e){const{actions:s,views:n,accessCache:i,accessContext:r,ctx:c,stateValue:a}=t;return!!i[e]||o(a,e)||o(n,e)||1!==r&&o(s,e)||o(c,e)||o(At,e)}},$t={0:"scheduler flush. This is likely a Doura internals bug. Please open an issue at https://github.com/dourajs/doura/issues/new"};function Tt(t,e,...s){const n=$t[e],i=n?"function"==typeof n?n.apply(null,s):n:"unknown error nr: "+Tt;throw new Error(`[Doura] ${i}`)}let kt=!1,Lt=!1;const Nt=[];let Vt=0;const Ht=[];let Kt=null,Ut=0;const Xt=[];let zt=null,Yt=0;const Ft=Promise.resolve();let Jt=null,Wt=null;function Bt(t){Nt.length&&Nt.includes(t,kt&&t.allowRecurse?Vt+1:Vt)||t===Wt||(null==t.id?Nt.push(t):Nt.splice(function(t){let e=Vt+1,s=Nt.length;for(;e<s;){const n=e+s>>>1;Gt(Nt[n])<t?e=n+1:s=n}return e}(t.id),0,t),kt||Lt||(Lt=!0,Jt=Ft.then(Qt)))}function qt(t,e=null){if(Ht.length){for(Wt=e,Kt=[...new Set(Ht)],Ht.length=0,Ut=0;Ut<Kt.length;Ut++)Kt[Ut]();Kt=null,Ut=0,Wt=null,qt(t,e)}}const Gt=t=>null==t.id?1/0:t.id;function Qt(t){Lt=!1,kt=!0,qt(t),Nt.sort(((t,e)=>Gt(t)-Gt(e)));try{for(Vt=0;Vt<Nt.length;Vt++){const t=Nt[Vt];if(t&&!1!==t.active){0;try{t()}catch(e){Tt(0,0)}}}}finally{Vt=0,Nt.length=0,function(t){if(qt(),Xt.length){const t=[...new Set(Xt)];if(Xt.length=0,zt)return void zt.push(...t);for(zt=t,zt.sort(((t,e)=>Gt(t)-Gt(e))),Yt=0;Yt<zt.length;Yt++)zt[Yt]();zt=null,Yt=0}}(),kt=!1,Jt=null,(Nt.length||Ht.length||Xt.length)&&Qt(t)}}var Zt;function te(t,e){const s=Object.keys(e);s.length&&s.forEach((s=>{o(t,s)&&y(e[s])?te(t[s],e[s]):t[s]=e[s]}))}!function(t){t.REPLACE="replace",t.MODIFY="modify",t.PATCH="patch"}(Zt||(Zt={}));class ee{constructor(t,{name:s,initState:n}){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.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.options=t,this.name=s||"",this._isDispatching=!1,this._initState=n||t.state,this.stateRef=Pt({value:this._initState});const i=this._update.bind(this);var r;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&&Bt(i)})),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,It),this.effectScope=new D(r),this._initActions(),this._initViews()}patch(t){y(t)&&this._currentState&&(this._watchStateChange=!1,te(this.proxy.$state,t),this._watchStateChange=!0,this.dispatch({type:Zt.PATCH,payload:Mt(this.stateRef.value,this.stateRef.value),args:{patch:t}}))}replace(t){this._watchStateChange=!1,this.stateRef.value=t,this._watchStateChange=!0;for(const e of this.viewInstances)e.effect.scheduler();this.dispatch({type:Zt.REPLACE,payload: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){J();const e=t(this.stateValue);return W(),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 st(t,e)}((()=>{const e=this.accessContext;this.accessContext=1;try{return t.call(this.proxy,this.proxy)}finally{this.accessContext=e}}))})),this.viewInstances.push(e),e}reducer(t,e){switch(e.type){case Zt.REPLACE:case Zt.MODIFY:case Zt.PATCH: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._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:Zt.MODIFY,payload:Mt(this.stateRef.value,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&&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=this.createView(t[e]),n=this;Object.defineProperty(this.views,e,{configurable:!0,enumerable:!0,get(){const t=s;let e=s.value;return s.mightChange?(s.mightChange=!1,t.__snapshot=Mt(e,n.stateRef.value)):t.__pre!==e&&(t.__snapshot=Mt(e,n.stateRef.value)),t.__pre=e,t.__snapshot},set:()=>!1})}}}function se(t,e={}){return new ee(t,e)}let ne=null;function ie(t){ne=t}class re{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=()=>{Bt(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}).proxy}getDetachedModel(t){return this.getModelInstance({model:t}).proxy}getModelInstance({name:t,model:e}){const s=t&&this._models.get(t);if(s)return s;let n;if("function"==typeof e){let s=ne;const i=this._createModelProxy();try{ie({manager:this,model:i}),n=this._initModel({name:t,model:e()})}finally{ie(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 se(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=se(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.proxy,{doura:this})})),s}_getInitialState(t){const e=this._initialState[t];return e&&delete this._initialState[t],e}}var oe=function(){if("undefined"==typeof window||!window.__REDUX_DEVTOOLS_EXTENSION__)return{};let t=0;const e=new Set;let s;return{onInit({},{doura:n}){if(window.__doura=n,"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){s=window.__REDUX_DEVTOOLS_EXTENSION__.connect({name:`doura${0===t?"":t}`}),t+=1,s.init(n.getState());const i=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(n.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(n.getState());case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return}}};e.add(s.subscribe(i))}},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","target","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=n,t.def=w,t.defineModel=t=>t,t.devtool=oe,t.doura=function({initialState:t,plugins:e=[]}={}){return function({initialState:t,plugins:e}={}){return new re(t,e)}({initialState:t,plugins:e})},t.each=function(t,e,s=!1){y(t)?(s?Object.keys:O)(t).forEach((n=>{s&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach(((s,n)=>e(n,s,t)))},t.emptyObject=s,t.extend=i,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=Jt||Ft;return t?e.then(this?t.bind(this):t):e},t.objectToString=c,t.ownKeys=O,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=S,t.toRawType=_,t.toTypeString=a,t.use=function(t,e){if(!ne)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}=ne;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;function m(t){if(h(t))return new Map(t);if(u(t))return new Set(t);if(Array.isArray(t))return S.call(t);const e=Object.getOwnPropertyDescriptors(t),s=Reflect.ownKeys(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)}const O="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?t=>Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)):Object.getOwnPropertyNames;function x(t,...e){console.warn(`[Doura warn] ${t}`,...e)}function j(t){switch(_(t)){case"Object":return 1;case"Array":return 2;case"Set":return 3;case"Map":return 4;default:return 0}}function E(t){return!!t&&!!t.__r_state}function P(t){const e=M(t);return e?P(e.base):t}function M(t){return t&&t.__r_state}function R(t){return t.copy||t.base}function C(t){t.modified||(t.modified=!0,t.parent&&C(t.parent))}let A;class I{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&A&&(this.parent=A,this.index=(A.scopes||(A.scopes=[])).push(this)-1)}run(t){if(this.active){const e=A;try{return A=this,t()}finally{A=e}}}on(){A=this}off(){A=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 D=t=>{const e=new Set(t);return e.w=0,e.n=0,e},$=t=>(t.w&V)>0,T=t=>(t.n&V)>0,k=new WeakMap,L=new WeakMap;let N=0,V=1;let H;const K=Symbol(""),U=Symbol("");let X=0;class z{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.id=X++,this.deps=[],this.active=!0,this.parent=void 0,function(t,e=A){e&&e.active&&e.effects.push(t)}(this,s)}run(){if(!this.active)return this.fn();let t=H;const e=F;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=H,H=this,F=!0,V=1<<++N,N<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=V})(this):Y(this),this.fn()}finally{N<=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)&&!T(i)?i.delete(t):e[s++]=i,i.w&=~V,i.n&=~V}e.length=s}})(this),V=1<<--N,H=this.parent,F=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){H===this?this.deferStop=!0:this.active&&(Y(this),this.onStop&&this.onStop(),this.active=!1)}}function Y(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}let F=!0;const J=[];function W(){J.push(F),F=!1}function B(){const t=J.pop();F=void 0===t||t}function q(t,e,s){if(F&&H){let e=k.get(t);e||k.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=D()),Q(n)}}function G(t){if(F&&H){const e=t.__r_state;if(!e)return;let s=L.get(e);s||L.set(e,s=D()),Q(s)}}function Q(t){let e=!1;N<=30?T(t)||(t.n|=V,e=!$(t)):e=!t.has(H),e&&(t.add(H),H.deps.push(t))}function Z(t){const e=L.get(t);if(e){const t=[...e];for(const e of t)e.view&&(e.view.mightChange=!0)}}function tt(t,e,s,n,i){var r;const o=k.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(K)),h(c)&&a.push(o.get(U)));break;case"delete":l(c)||(a.push(o.get(K)),h(c)&&a.push(o.get(U)));break;case"set":h(c)&&a.push(o.get(K))}if(1===a.length)a[0]&&et(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);et(D(t))}const u=null===(r=t.root)||void 0===r?void 0:r.listeners;u&&u.length&&u.forEach((t=>t()))}function et(t){const e=l(t)?t:[...t];for(const s of e)s.view&&st(s);for(const s of e)s.view||st(s)}function st(t){(t!==H||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}class nt{constructor(t,{disableCache:e=!1}){this.dep=void 0,this.mightChange=!1,this.dirty=!0,this.effect=new z(t,(()=>{this.dirty||(this.dirty=!0,function(t){(t=P(t)).dep&&et(t.dep)}(this))})),this.effect.view=this,this.effect.active=this._cacheable=!e}get value(){const t=P(this);return function(t){F&&H&&Q((t=P(t)).dep||(t.dep=D()))}(t),!t.dirty&&t._cacheable||(t.dirty=!1,t._value=t.effect.run()),t._value}set value(t){}}const it=new Set(["__proto__"]),rt=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(p));function ot(t){t.copy||(t.copy=m(t.base))}function ct(t,e){const s=t.__r_state;return(s?R(s):t)[e]}const at=ut(),lt=ht();function ht(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=M(this),n=R(s);for(let e=0,r=this.length;e<r;e++)q(s,0,e+"");const i=n[e](...t);return-1===i||!1===i?n[e](...t.map(P)):i}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){W();const s=R(M(this))[e].apply(this,t);return B(),s}})),t}function ut(){return function(t,e,s){const n=R(t);if("__r_isReactive"===e)return!0;if("__r_state"===e&&s===Et.get(t))return t;if(l(n)&&o(lt,e))return Reflect.get(lt,e,s);let i=Reflect.get(n,e,s);return(p(e)?rt.has(e):it.has(e))?i:(q(t,0,e),o(n,e)?(t.disposed||!d(i)||(E(i)||(ot(t),i=t.copy[e]=Mt(i,t)),G(i)),i):i)}}function ft(){return function(t,e,s,n){const i=R(t),r=ct(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;ot(t),C(t)}return b(t.copy[e],s)&&(void 0!==s||e in t.copy)||(t.copy[e]=s,t===M(n)&&(c?b(s,r)||tt(t,"set",e,s):tt(t,"add",e,s),function(t){let e=t;for(;e;)Z(e),e=e.parent}(t))),!0}}const pt={get:at,set:ft(),deleteProperty:function(t,e){const s=o(R(t),e);if((void 0!==ct(t.base,e)||e in t.base)&&(ot(t),C(t)),t.copy){const n=delete t.copy[e];return n&&s&&tt(t,"delete",e,void 0),n}return!0},has:function(t,e){const s=R(t),n=Reflect.has(s,e);return p(e)&&rt.has(e)||q(t,0,e),n},ownKeys:function(t){const e=R(t);return q(t,0,l(e)?"length":K),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=R(t),n=Reflect.getOwnPropertyDescriptor(s,e);return n?{writable:!0,configurable:!l(s)||"length"!==e,enumerable:n.enumerable,value:s[e]}:n}};function dt(t){t.copy||(t.copy=new Set,t.base.forEach((e=>{if(d(e)){const s=Mt(e,t);G(s),e!==s&&t.drafts.set(e,s),t.copy.add(s)}else t.copy.add(e)})))}function _t(t){1===t.type?function(t){t.copy||(t.copy=new Map(t.base))}(t):dt(t)}function yt(t){const e=this.__r_state,s=R(e);if(q(e,0,t),!s.has(t))return;let n=s.get(t);return d(n)?(E(n)||(_t(e),n=Mt(n,e),e.copy.set(t,n)),G(n),n):n}function gt(t,e){const s=this.__r_state,n=R(s),i=n.has(t),r=n.get(t),o=()=>{_t(s),C(s),s.copy.set(t,e)};return i?b(e,r)||(o(),tt(s,"set",t,e)):(o(),tt(s,"add",t,e)),this}function bt(t){const e=this.__r_state;return R(e).has(t)||(dt(e),C(e),e.copy.add(t),tt(e,"add",t,t)),this}function wt(t){const e=this.__r_state;return q(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 vt(t){const e=this.__r_state,s=R(e),n=s.has(t);"get"in s&&s.get(t),_t(e),C(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&&tt(e,"delete",t,void 0),i}function St(){const t=this.__r_state,e=R(t),s=0!==e.size,n=e.clear();return s&&(_t(t),C(t),t.copy.clear(),tt(t,"clear",void 0,void 0)),n}function mt(){const t={get:yt,get size(){return q(t=this.__r_state,0,K),R(t).size;var t},has:wt,add:bt,set:gt,delete:vt,clear:St,keys(){const t=this.__r_state;return 1===t.type?function(t){return q(t,0,U),R(t).keys()}(t):function(t){return q(t,0,K),dt(t),t.copy.values()}(t)},forEach(t,e){const s=this.__r_state;1===s.type?function(t,e,s,n){q(e,0,K),R(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 q(s,0,K),dt(s),s.copy[t](...e)}}(e)})),[t]}const[Ot]=mt();function xt(){const t=Ot;return(e,s,n)=>{if("__r_isReactive"===s)return!0;if("__r_state"===s)return e;const i=R(e);return Reflect.get(o(t,s)&&s in i?t:i,s,n)}}const jt={get:xt()};const Et=new WeakMap;let Pt=0;function Mt(t,e){const s=j(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:Pt++,root:null,parent:e,base:t,proxy:null,copy:null,modified:!1,disposed:!1,listeners:[],children:[]},i=n,r=pt;3===s?(n.type=2,n.drafts=new Map,i=new Set,r=jt):4===s?(n.type=1,i=new Map,r=jt):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,Et.set(i,o),i.proxy}function Rt(t,e){const s=function(t,{copies:e,proxies:s}){const n=t=>{switch(j(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(E(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(E(t)){return new Proxy(e.copies.get(t.__r_state),s)}return new Proxy(m(t),s)}function Ct(t,e){if(!d(t))return t;const s=function(t){const e=new Map,s={copies:e,proxies:new Map},n=[t.__r_state];for(;n.length;){const t=n.pop();let s;t.modified?(s=m(t.copy),At(t,s)):s=t.base,e.set(t,s);for(const e of t.children)n.push(e)}return s}(e);return Rt(t,s)}function At(t,e){t.modified=!1,t.base=e}function It(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 Dt=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=>It.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=Dt[s];return l?l(e):o(c,s)?(r[s]=3,c[s]):void((t=>"_"===t||"$"===t)(s[0])&&o(a,s)&&x(`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.`))},Tt=({_: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(Dt,e))&&(n[e]=s,!0)))},kt={get:$t(!1),set:Tt},Lt={get:$t(!0),set:Tt};function Nt(t,e,...s){console.error(t)}let Vt=!1,Ht=!1;const Kt=[];let Ut=0;const Xt=[];let zt=null,Yt=0;const Ft=[];let Jt=null,Wt=0;const Bt=Promise.resolve();let qt=null,Gt=null;function Qt(t){Kt.length&&Kt.includes(t,Vt&&t.allowRecurse?Ut+1:Ut)||t===Gt||(null==t.id?Kt.push(t):Kt.splice(function(t){let e=Ut+1,s=Kt.length;for(;e<s;){const n=e+s>>>1;te(Kt[n])<t?e=n+1:s=n}return e}(t.id),0,t),Vt||Ht||(Ht=!0,qt=Bt.then(ee)))}function Zt(t,e=null){if(Xt.length){for(Gt=e,zt=[...new Set(Xt)],Xt.length=0,Yt=0;Yt<zt.length;Yt++)zt[Yt]();zt=null,Yt=0,Gt=null,Zt(t,e)}}const te=t=>null==t.id?1/0:t.id;function ee(t){Ht=!1,Vt=!0,Zt(t),Kt.sort(((t,e)=>te(t)-te(e)));try{for(Ut=0;Ut<Kt.length;Ut++){const t=Kt[Ut];if(t&&!1!==t.active){0;try{t()}catch(e){Nt(e)}}}}finally{Ut=0,Kt.length=0,function(t){if(Zt(),Ft.length){const t=[...new Set(Ft)];if(Ft.length=0,Jt)return void Jt.push(...t);for(Jt=t,Jt.sort(((t,e)=>te(t)-te(e))),Wt=0;Wt<Jt.length;Wt++)Jt[Wt]();Jt=null,Wt=0}}(),Vt=!1,qt=null,(Kt.length||Xt.length||Ft.length)&&ee(t)}}var se;function ne(t,e){const s=Object.keys(e);s.length&&s.forEach((s=>{o(t,s)&&y(e[s])?ne(t[s],e[s]):t[s]=e[s]}))}function ie(t){t.dirty=!0}!function(t){t.REPLACE="replace",t.MODIFY="modify",t.PATCH="patch"}(se||(se={}));class re{constructor(t,{name:s,initState:n}){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.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.options=t,this.name=s||"",this._isDispatching=!1,this._initState=n||t.state,this.stateRef=Mt({value:this._initState});const i=this._update.bind(this);var r;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&&Qt(i)})),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,kt),this.publicInst=new Proxy(this.ctx,Lt),this.effectScope=new I(r),this._initActions(),this._initViews()}patch(t){y(t)&&this._currentState&&(this._watchStateChange=!1,ne(this.proxy.$state,t),this._watchStateChange=!0,this.dispatch({type:se.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:se.REPLACE,payload:t})}else x(`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){W();const e=t(this.stateValue);return B(),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 nt(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=Ct(t,this.stateRef.value)):e.__pre!==t&&(e.__snapshot=Ct(t,this.stateRef.value)),e.__pre=t,e.__snapshot},this.viewInstances.push(e),e}reducer(t,e){switch(e.type){case se.MODIFY:case se.PATCH:return Ct(this.stateRef.value,this.stateRef.value);case se.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._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.value)&&this.dispatch({type:se.MODIFY})}_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&&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;Object.defineProperty(this.views,e,{configurable:!0,enumerable:!0,get:n?()=>(...t)=>{const e=r.__externalArgs;if(e){if(e.length!==t.length)ie(i);else for(let s=0;s<e.length;s++)if(e[s]!==t[s]){ie(i);break}}else ie(i);return r.__externalArgs=t,i.getSnapshot()}:i.getSnapshot,set:()=>!1})}}}function oe(t,e={}){return new re(t,e)}let ce=null;function ae(t){ce=t}class le{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=()=>{Qt(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=ce,i=this._createModelProxy();try{ae({manager:this,model:i}),n=this._initModel({name:t,model:e()})}finally{ae(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 oe(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=oe(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 he=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=he,t.doura=function({initialState:t,plugins:e=[]}={}){return function({initialState:t,plugins:e}={}){return new le(t,e)}({initialState:t,plugins:e})},t.draft=Mt,t.each=function(t,e,s=!1){y(t)?(s?Object.keys:O)(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=qt||Bt;return t?e.then(this?t.bind(this):t):e},t.objectToString=c,t.ownKeys=O,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=m,t.snapshot=Ct,t.toRawType=_,t.toTypeString=a,t.use=function(t,e){if(!ce)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}=ce;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.7",
"version": "0.0.8",
"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