Comparing version 22.8.2 to 22.8.3
@@ -1,2 +0,2 @@ | ||
'use strict';function e(e,r){for(var n in e)r(e[n],n)}function r(e,r){e.forEach(r)}function n(e,r){if(!e)throw Error(r)}function t(e,r){var n=A(e).meta||{};ee={id:A(e).id,parent:ee,value:e,template:n.template||ne(),sidRoot:n.sidRoot||ee&&ee.sidRoot,meta:n};try{return r()}finally{re('region'),ee=q(ee)}}function a(e){var n=void 0===e?{}:e,t=n.node,a=void 0===t?[]:t,i=n.parent,o=n.child,u=void 0===o?n.to||n.target:o,s=n.scope,f=void 0===s?{}:s,c=n.meta,d=void 0===c?{}:c,l=n.family,p=void 0===l?{type:'regular'}:l,v=n.regional,m=ie(void 0===i?n.from||n.source:i),g=ie(p.links),h=ie(p.owners),y=[];r(a,(function(e){return e&&$(y,e)}));var b={id:Y(),seq:y,next:ie(u),meta:d,scope:f,family:{type:p.type||"crosslink",links:g,owners:h}};return r(g,(function(e){return $(O(e),b)})),r(h,(function(e){return $(z(e),b)})),r(m,(function(e){return $(e.next,b)})),v&&ee&&ae(N(ee),[b]),b}function i(e,n,t){var a,i=We,o=null,u=qe;if(e.target&&(n=e.params,t=e.defer,a=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),u=F(e)||u,e=e.target),u&&qe&&u!==qe&&(qe=null),Array.isArray(e))for(var s=0;s<e.length;s++)De('pure',i,A(e[s]),o,n[s],u,a);else De('pure',i,A(e),o,n,u,a);if(!t||Le){var f,c,d,l,p,v,m={isRoot:Le,currentPage:We,scope:qe,isWatch:Be,isPure:Te};Le=0;for(var g=function(){var e=l.idx,n=l.stack,t=l.type;d=n.node,We=p=n.page,qe=F(n),p?v=p.reg:qe&&(v=qe.reg);var a=!!p,i=!!qe,o={fail:0,scope:d.scope};f=c=0;for(var u=e;u<d.seq.length&&!f;u++){var s=d.seq[u];if(s.order){var g=s.order,h=g.priority,y=g.barrierID,b=y?p?p.fullID+"_"+y:y:0;if(u!==e||t!==h)return y?Pe.has(b)||(Pe.add(b),Ee(u,n,h,y)):Ee(u,n,h),"continue|kernelLoop";y&&Pe.delete(b)}switch(s.type){case'mov':var x=s.data,w=void 0;switch(x.from){case j:w=N(n);break;case"a":case'b':w=n[x.from];break;case"value":w=x.store;break;case"store":if(v&&!v[x.store.id])if(a){var k=Ue(p,x.store.id);n.page=p=k,k?v=k.reg:i?(Je(qe,x.store,0,1,x.softRead),v=qe.reg):v=void 0}else i&&Je(qe,x.store,0,1,x.softRead);w=Ae(v&&v[x.store.id]||x.store)}switch(x.to){case j:n.value=w;break;case"a":case'b':n[x.to]=w;break;case"store":Ve(p,qe,d,x.target).current=w}break;case'compute':var S=s.data;if(S.fn){Be='watch'===R(d,'op'),Te=S.pure;var M=S.safe?(0,S.fn)(N(n),o.scope,n):Ke(o,S.fn,n);S.filter?c=!M:n.value=M,Be=m.isWatch,Te=m.isPure}}f=o.fail||c}if(Fe&&Fe(n,o),!f){var A=N(n),O=F(n);if(r(d.next,(function(e){De('child',p,e,n,A,O)})),O){R(d,'needFxCounter')&&De('child',p,O.fxCount,n,A,O),R(d,'storeChange')&&De('child',p,O.storeChange,n,A,O),R(d,'warnSerialize')&&De('child',p,O.warnSerializeNode,n,A,O);var z=O.additionalLinks[d.id];z&&r(z,(function(e){De('child',p,e,n,A,O)}))}}};l=Re();)g();Le=m.isRoot,We=m.currentPage,qe=F(m)}}function o(r,n){void 0===n&&(n='combine');var t=n+'(',a='',i=0;return e(r,(function(e){i<25&&(null!=e&&(t+=a,t+=_(e)?E(e).fullName:e.toString()),i+=1,a=', ')})),t+')'}function u(e,r){var n,t,a=e;if(r){var i=E(r);0===e.length?(n=i.path,t=i.fullName):(n=i.path.concat([e]),t=0===i.fullName.length?e:i.fullName+'/'+e)}else n=0===e.length?[]:[e],t=e;return{shortName:a,fullName:t,path:n}}function s(e,r){var n=r?e:e[0];fe(n);var t=n.or,a=n.and;if(a){var i=r?a:a[0];if(oe(i)&&'and'in i){var o=s(a,r);e=o[0],t=Object.assign({},t,o[1])}else e=a}return[e,t]}function f(e){var r=ne();if(r){for(var n=r.handlers[e],t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];if(n)return n.apply(void 0,[r].concat(a))}}function c(e,r,n,t){var a=We,i=null;if(r)for(i=We;i&&i.template!==r;)i=q(i);He(i);var o=e.create(n,t);return He(a),o}function d(e,r){var n=Qe({or:r,and:'string'==typeof e?{name:e}:e}),t=function e(r){J(!R(e,'derived'),'call of derived event','createEvent'),J(!Te,'unit call from pure function','operators like sample');for(var n=arguments.length,t=new Array(n>1?n-1:0),a=1;a<n;a++)t[a-1]=arguments[a];return We?c(e,o,r,t):e.create(r,t)},o=ne(),u=Object.assign(t,{graphite:a({meta:ir(n.actualOp||"event",t,n),regional:1}),create:function(e){return i({target:t,params:e,scope:qe}),e},watch:function(e){return tr(t,e)},map:function(e){return or(t,M,e,[Se()])},filter:function(e){return or(t,"filter",e.fn?e:e.fn,[Se(me,1)])},filterMap:function(e){return or(t,'filterMap',e,[Se(),we((function(e){return!se(e)}),1)])},prepend:function(e){var r=d('* \u2192 '+t.shortName,{parent:q(t)});return f('eventPrepend',A(r)),nr(r,t,[Se()],'prepend',e),ar(t,r),r}});return null!=n&&n.domain&&n.domain.hooks.event(u),re(u.graphite),u}function l(e,t,a,i){return de(a,t,'first argument'),n(ue(i),'second argument should be a function'),J(!R(e,'derived'),t+" in derived store",t+" in store created via createStore"),r(Array.isArray(a)?a:[a],(function(r){e.off(r),I(e).set(r,rr(ur(r,e,'on',ve,i)))})),e}function p(e,t){var o=Qe(t),u=je(e),s=d({named:'updates',derived:1});f('storeBase',u);var c=u.id,v={subscribers:new Map,updates:s,defaultState:e,stateRef:u,getState:function(){var e,r=u;if(We){for(var n=We;n&&!n.reg[c];)n=q(n);n&&(e=n)}return!e&&qe&&(Je(qe,u,1),e=qe),e&&(r=e.reg[c]),Ae(r)},setState:function(e){return i({target:v,params:e,defer:1,scope:qe})},reset:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return r(n,(function(e){return l(v,'.reset',e,(function(){return v.defaultState}))})),v},on:function(e,r){return l(v,'.on',e,r)},off:function(e){var r=I(v).get(e);return r&&(r(),I(v).delete(e)),v},map:function(e,r){var n,t;oe(e)&&(n=e,e=e.fn),J(se(r),'second argument of store.map','updateFilter');var a=v.getState();ne()?t=null:se(a)||(t=e(a,r));var i=p(t,{name:v.shortName+" \u2192 *",derived:1,and:n}),o=ur(v,i,M,pe,e);return Oe(C(i),{type:M,fn:e,from:u}),C(i).noInit=1,f('storeMap',u,o),i},watch:function(e,r){if(!r||!_(e)){var t=tr(v,e);return f('storeWatch',u,e)||e(v.getState()),t}return n(ue(r),'second argument should be a function'),e.watch((function(e){return r(v.getState(),e)}))}},m=ir("store",v,o),g=v.defaultConfig.updateFilter;v.graphite=a({scope:{state:u,fn:g},node:[we((function(e,r,n){return n.scope&&!n.scope.reg[u.id]&&(n.b=1),e})),ke(u),we((function(e,r,n){var t=n.a,a=n.b;return!se(e)&&(e!==t||a)}),1),g&&Se(pe,1),ye({from:j,target:u})],child:s,meta:Object.assign({},m,{defaultState:e}),regional:1});var h=R(v,'serialize'),y=R(v,'derived'),b='ignore'===h,x=R(v,'sid');return x&&(D(v,'storeChange',1),u.sid=x),x||b||y||D(v,'warnSerialize',1),n(y||!se(e),"current state can't be undefined, use null instead"),ae(v,[s]),null!=o&&o.domain&&o.domain.hooks.store(v),y||(v.reinit=d({named:'reinit'}),v.reset(v.reinit)),u.meta=v.graphite.meta,re(v.graphite),v}function v(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var a,i,o,u=s(r);o=u[1];var f,c,d,l=(r=u[0])[r.length-1];if(ue(l)?(i=r.slice(0,-1),a=l):i=r,1===i.length){var p=i[0];L(p)||(f=p,c=1)}if(!c&&(f=i,a)){d=1;var v=a;a=function(e){return v.apply(void 0,e)}}return n(oe(f),'shape should be an object'),sr(Array.isArray(f),!d,f,o,a)}function m(){var e={};return e.req=new Promise((function(r,n){e.rs=r,e.rj=n})),e.req.catch((function(){})),e}function g(e,r){void 0===r&&(r={});var t=Qe(ue(e)?{handler:e}:e,r),o=d(ue(e)?{handler:e}:e,Object.assign({},r,{actualOp:"effect"})),u=A(o);D(u,'op',o.kind="effect"),o.use=function(e){return n(ue(e),'.use argument should be a function'),g.scope.handler=e,o},o.use.getCurrent=function(){return g.scope.handler};var s=o.finally=d({named:'finally',derived:1}),f=o.done=s.filterMap({named:'done',fn:function(e){if('done'===e.status)return{params:e.params,result:e.result}}}),c=o.fail=s.filterMap({named:'fail',fn:function(e){if('fail'===e.status)return{params:e.params,error:e.error}}}),l=o.doneData=f.map({named:'doneData',fn:function(e){return e.result}}),v=o.failData=c.map({named:'failData',fn:function(e){return e.error}}),g=a({scope:{handler:o.defaultConfig.handler||function(){return n(0,"no handler used in "+o.getType())}},node:[we((function(e,r,n){var t=r.handler,a=F(n);if(a){var i=o.sid?a.handlers.sidMap[o.sid]:a.handlers.unitMap.get(o);i&&(t=i)}return e.handler=t,e}),0,1),we((function(e,r,n){var t=e.params,a=e.req,i=e.handler,o=e.args,u=void 0===o?[t]:o,f=cr(n),c=dr(t,a,1,s,n,f),d=dr(t,a,0,s,n,f),l=fr(i,d,u),p=l[1];l[0]&&(oe(p)&&ue(p.then)?p.then(c,d):c(p))}),0,1)],meta:{op:'fx',fx:'runner'}});u.scope.runner=g,$(u.seq,we((function(e,r,n){var t=r.runner,a=q(n)?{params:e,req:{rs:function(){},rj:function(){}}}:e;return n.meta||(n.meta={fxID:Z()}),i({target:t,params:a,defer:1,scope:F(n),meta:n.meta}),a.params}),0,1)),o.create=function(e){var r=m(),n={params:e,req:r};if(qe&&!Be){var t=qe;r.req.finally((function(){Ge(t)})).catch((function(){}))}return i({target:o,params:n,scope:qe}),r.req};var h=o.inFlight=p(0,{serialize:'ignore',named:(R(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(function(e){return e+1})).on(s,(function(e){return e-1})).map({fn:function(e){return e},named:'inFlight'});D(s,'needFxCounter','dec'),D(o,'needFxCounter',1);var y=o.pending=h.map({fn:function(e){return e>0},named:'pending'});return ae(o,[s,f,c,l,v,y,h]),null!=t&&t.domain&&t.domain.hooks.effect(o),o}function h(e,r){de(e,'merge','first argument');var n=d({name:o(e,'merge'),derived:1,and:r});return nr(e,n,[],'merge'),n}function y(e,t){var a=0;return r(pr,(function(r){r in e&&(n(null!=e[r],vr(t,r)),a=1)})),a}function b(e,n,t){var a=[];(function e(i){U(a,i)||($(a,i),"store"===R(i,'op')&&(t||R(i,'sid'))&&n(i,R(i,'sid')),r(i.next,e),r(O(i),e),r(z(i),e))})(e)}function x(e,t){var a=Array.isArray(e)?new Map(e):e,i=new Map;if(a instanceof Map){var o={};return r(a,(function(e,r){n(_(r),'Map key should be a unit'),t&&t(r,e),r.sid?(n(!(r.sid in o),'duplicate sid found'),o[r.sid]=e):i.set(r,e)})),{sidMap:o,unitMap:i}}return{sidMap:a,unitMap:i}}function w(e){var r=function(){return e()};return r.unsubscribe=function(){return e()},r}Object.defineProperty(exports,'__esModule',{value:1});for(var k,S='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',M='map',j='stack',A=function(e){return e.graphite||e},O=function(e){return e.family.owners},z=function(e){return e.family.links},C=function(e){return e.stateRef},N=function(e){return e.value},I=function(e){return e.subscribers},q=function(e){return e.parent},F=function(e){return e.scope},R=function(e,r){return A(e).meta[r]},D=function(e,r,n){return A(e).meta[r]=n},E=function(e){return e.compositeName},_=function(e){return(ue(e)||oe(e))&&'kind'in e},P=function(e){return function(r){return _(r)&&r.kind===e}},L=P("store"),B=P("event"),T=P("effect"),W=P("domain"),G=P("scope"),H={__proto__:null,unit:_,store:L,event:B,effect:T,domain:W,scope:G,attached:function(e){return T(e)&&1==R(e,'attached')}},U=function(e,r){return e.includes(r)},V=function(e,r){var n=e.indexOf(r);-1!==n&&e.splice(n,1)},$=function(e,r){return e.push(r)},J=function(e,r,n){return!e&&console.error(r+" is deprecated"+(n?", use "+n+" instead":''))},K=function(){var e=0;return function(){return""+ ++e}},Q=K(),X=K(),Y=K(),Z=K(),ee=null,re=function(e){k&&k(e,ee)},ne=function(){return ee&&ee.template},te=function(e){return e&&ee&&ee.sidRoot&&(e=ee.sidRoot+"|"+e),e},ae=function(e,n){var t=A(e);r(n,(function(e){var r=A(e);"domain"!==t.family.type&&(r.family.type="crosslink"),$(O(r),t),$(z(t),r)}))},ie=function(e){return void 0===e&&(e=[]),(Array.isArray(e)?e:[e]).flat().map(A)},oe=function(e){return'object'==typeof e&&null!==e},ue=function(e){return'function'==typeof e},se=function(e){return void 0===e},fe=function(e){return n(oe(e)||ue(e),'expect first argument be an object')},ce=function(e,r,t,a){return n(!(!oe(e)&&!ue(e)||!('family'in e)&&!('graphite'in e)),r+": expect "+t+" to be a unit (store, event or effect)"+a)},de=function(e,n,t){Array.isArray(e)?r(e,(function(e,r){return ce(e,n,r+" item of "+t,'')})):ce(e,n,t,' or array of units')},le=function(e,n,t){return void 0===t&&(t='target'),r(ie(n),(function(r){return J(!R(r,'derived'),e+": derived unit in \""+t+"\"","createEvent/createStore")}))},pe=function(e,r,n){return(0,r.fn)(e,n.a)},ve=function(e,r,n){return(0,r.fn)(n.a,e)},me=function(e,r){return(0,r.fn)(e)},ge=function(e,r,n,t){var a={id:X(),type:e,data:r};return n&&(a.order={priority:n},t&&(a.order.barrierID=++he)),a},he=0,ye=function(e){var r=e.from,n=e.target,t=e.to;return ge('mov',{from:void 0===r?"store":r,store:e.store,to:void 0===t?n?"store":j:t,target:n},e.priority,e.batch)},be=function(e){var r=e.safe,n=e.filter,t=e.pure;return ge('compute',{fn:e.fn,safe:void 0===r?0:r,filter:void 0===n?0:n,pure:void 0===t?0:t},e.priority,e.batch)},xe=function(e){return be({fn:e.fn,priority:"effect"})},we=function(e,r,n){return be({fn:e,safe:1,filter:r,priority:n&&"effect"})},ke=function(e,r,n){return ye({store:e,to:r?j:"a",priority:n&&"sampler",batch:1})},Se=function(e,r){return void 0===e&&(e=me),be({fn:e,pure:1,filter:r})},Me={mov:ye,compute:be,filter:function(e){return be({fn:e.fn,filter:1,pure:e.pure})},run:xe},je=function(e){return{id:X(),current:e}},Ae=function(e){return e.current},Oe=function(e,r){e.before||(e.before=[]),$(e.before,r)},ze=null,Ce=function e(r,n){return r?n?((r.v.type===n.v.type&&r.v.id>n.v.id||_e(r.v.type)>_e(n.v.type))&&(t=r,r=n,n=t),t=e(r.r,n),r.r=r.l,r.l=t,r):r:n;var t},Ne=[],Ie=0;Ie<6;)$(Ne,{first:null,last:null,size:0}),Ie+=1;var qe,Fe,Re=function(){for(var e=0;e<6;e++){var r=Ne[e];if(r.size>0){if(3===e||4===e){r.size-=1;var n=ze.v;return ze=Ce(ze.l,ze.r),n}1===r.size&&(r.last=null);var t=r.first;return r.first=t.r,r.size-=1,t.v}}},De=function(e,r,n,t,a,i,o){return Ee(0,{a:null,b:null,node:n,parent:t,value:a,page:r,scope:i,meta:o},e)},Ee=function(e,r,n,t){void 0===t&&(t=0);var a=_e(n),i=Ne[a],o={v:{idx:e,stack:r,type:n,id:t},l:null,r:null};3===a||4===a?ze=Ce(ze,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},_e=function(e){switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case"barrier":return 3;case"sampler":return 4;case"effect":return 5;default:return-1}},Pe=new Set,Le=1,Be=0,Te=0,We=null,Ge=function(e){qe=e},He=function(e){We=e},Ue=function(e,r){if(e){for(;e&&!e.reg[r];)e=q(e);if(e)return e}return null},Ve=function(e,r,n,t,a){var i=Ue(e,t.id);return i?i.reg[t.id]:r?(Je(r,t,a),r.reg[t.id]):t},$e=function(e){return e},Je=function e(n,t,a,i,o){var u,s=n.reg,f=t.sid,c=null==t||null===(u=t.meta)||void 0===u?void 0:u.serialize;if(!s[t.id]){var d={id:t.id,current:t.current,meta:t.meta};if(f&&f in n.values.sidMap&&!(f in n.sidIdMap))d.current=(n.fromSerialize&&'ignore'!==c&&(null==c?void 0:c.read)||$e)(n.values.sidMap[f]);else if(d.id in n.values.idMap)d.current=n.values.idMap[d.id];else if(t.before&&!o){var l=0,p=a||!t.noInit||i;r(t.before,(function(r){switch(r.type){case M:var t=r.from;if(t||r.fn){t&&e(n,t,a,i);var o=t&&s[t.id].current;p&&(d.current=r.fn?r.fn(o):o)}break;case'field':l||(l=1,d.current=Array.isArray(d.current)?[].concat(d.current):Object.assign({},d.current)),e(n,r.from,a,i),p&&(d.current[r.field]=s[s[r.from.id].id].current)}}))}f&&(n.sidIdMap[f]=t.id),s[t.id]=d}},Ke=function(e,r,n){try{return r(N(n),e.scope,n)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Qe=function r(n,t){return void 0===t&&(t={}),oe(n)&&(r(n.or,t),e(n,(function(e,r){se(e)||'or'===r||'and'===r||(t[r]=e)})),r(n.and,t)),t},Xe=function(e,r){V(e.next,r),V(O(e),r),V(z(e),r)},Ye=function e(r,n,t){var a;r.next.length=0,r.seq.length=0,r.scope=null;for(var i=z(r);a=i.pop();)Xe(a,r),(n||t&&'sample'!==R(r,'op')||"crosslink"===a.family.type)&&e(a,n,'on'!==R(a,'op')&&t);for(i=O(r);a=i.pop();)Xe(a,r),t&&"crosslink"===a.family.type&&e(a,n,'on'!==R(a,'op')&&t)},Ze=function(e){return e.clear()},er=function(e,r){var n=(void 0===r?{}:r).deep,t=0;if(e.ownerSet&&e.ownerSet.delete(e),L(e))Ze(I(e));else if(W(e)){t=1;var a=e.history;Ze(a.events),Ze(a.effects),Ze(a.stores),Ze(a.domains)}Ye(A(e),!!n,t)},rr=function(e){var r=function(){return er(e)};return r.unsubscribe=r,r},nr=function(e,r,n,t,i){return a({node:n,parent:e,child:r,scope:{fn:i},meta:{op:t},family:{owners:[e,r],links:r},regional:1})},tr=function(e,r){return n(ue(r),'.watch argument should be a function'),rr(a({scope:{fn:r},node:[xe({fn:me})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))},ar=function(e,r,n){void 0===n&&(n="event"),q(e)&&q(e).hooks[n](r)},ir=function(e,r,n){var t=Qe(n),a="domain"===e,i=Q(),o=t.sid,s=void 0===o?null:o,f=t.named,c=void 0===f?null:f,d=t.domain,l=t.parent,p=void 0===l?void 0===d?null:d:l,v=c||t.name||(a?'':i),m=u(v,p),g={op:r.kind=e,name:r.shortName=v,sid:r.sid=te(s),named:c,unitId:r.id=i,serialize:t.serialize,derived:t.derived,config:t};if(r.parent=p,r.compositeName=m,r.defaultConfig=t,r.thru=function(e){return J(0,'thru','js pipe'),e(r)},r.getType=function(){return m.fullName},!a){r.subscribe=function(e){return fe(e),r.watch(ue(e)?e:function(r){return e.next&&e.next(r)})},r[S]=function(){return r};var h=ne();h&&(g.nativeTemplate=h)}return g},or=function(e,r,n,t){var a;oe(n)&&(a=n,n=n.fn);var i=d({name:e.shortName+" \u2192 *",derived:1,and:a});return nr(e,i,t,r,n),i},ur=function(e,r,n,t,a){var i=C(r),o=ye({store:i,to:"a",priority:'read'});n===M&&(o.data.softRead=1);var u=[o,Se(t)];return f('storeOnMap',i,u,L(e)&&C(e)),nr(e,r,u,n,a)},sr=function(r,t,a,i,u){var s=r?function(e){return[].concat(e)}:function(e){return Object.assign({},e)},c=r?[]:{},d=s(c),l=je(d),v=je(1);l.type=r?'list':'shape',l.noInit=1,f('combineBase',l,v);var m=p(d,{name:o(a),derived:1,and:i}),g=C(m);g.noInit=1,D(m,'isCombine',1);var h=ke(l);h.order={priority:'barrier'};var y=[we((function(e,r,n){return n.scope&&!n.scope.reg[l.id]&&(n.c=1),e})),h,ye({store:v,to:'b'}),we((function(e,r,n){var a=r.key;if(n.c||e!==n.a[a])return t&&n.b&&(n.a=s(n.a)),n.a[a]=e,1}),1),ye({from:"a",target:l}),ye({from:"value",store:0,target:v}),ye({from:"value",store:1,target:v,priority:"barrier",batch:1}),ke(l,1),u&&Se()];return e(a,(function(e,r){if(!L(e))return n(!_(e)&&!se(e),"combine expects a store in a field "+r),void(d[r]=c[r]=e);c[r]=e.defaultState,d[r]=e.getState();var t=nr(e,m,y,'combine',u);t.scope.key=r;var a=C(e);Oe(l,{type:'field',field:r,from:a}),f('combineField',a,t)})),m.defaultShape=a,Oe(g,{type:M,from:l,fn:u}),ne()||(m.defaultState=u?g.current=u(d):c),m},fr=function(e,r,n){try{return[1,e.apply(void 0,n)]}catch(t){return r(t),[0,null]}},cr=function(e){var r=F(e),n={ref:r};return r&&$(r.activeEffects,n),n},dr=function(e,r,n,t,a,o){return function(u){o.ref&&V(o.ref.activeEffects,o),i({target:[t,lr],params:[n?{status:'done',params:e,result:u}:{status:'fail',params:e,error:u},{value:u,fn:n?r.rs:r.rj}],defer:1,page:a.page,scope:o.ref,meta:a.meta})}},lr=a({node:[xe({fn:function(e){return(0,e.fn)(e.value)}})],meta:{op:'fx',fx:'sidechain'}}),pr=['source','clock','target'],vr=function(e,r){return e+": "+r+" should be defined"},mr=function(e,r,t,a,i,o,u,s,c,l,m,g){var y=!!i;n(!se(t)||!se(r),vr(e,'either source or clock'));var b=0;se(t)?b=1:_(t)||(t=v(t)),se(r)?r=t:(de(r,e,'clock'),Array.isArray(r)&&(r=h(r))),b&&(t=r),s||u||(u=t.shortName);var x='none';(m||a)&&(_(a)?x='unit':(n(ue(a),'`filter` should be function or unit'),x='fn')),i?(de(i,e,'target'),le(e,i)):'none'===x&&l&&L(t)&&L(r)?i=p(o?o(Ae(C(t)),Ae(C(r))):Ae(C(t)),{name:u,sid:g,or:s}):(i=d({name:u,derived:1,or:s}),f('sampleTarget',A(i)));var w=je(),k=[];if('unit'===x){var S=hr(a,i,r,w,e),M=S[0];k=[].concat(gr(S[1]),gr(M))}var O=hr(t,i,r,w,e),z=O[0],N=O[1],I=nr(r,i,[f('sampleSourceLoader'),ye({from:j,target:w})].concat(gr(N),[ke(z,1,c)],k,[ke(w),'fn'===x&&Se((function(e,r,n){return a(e,n.a)}),1),o&&Se(pe),f('sampleSourceUpward',y)]),e,o);return ae(t,[I]),Object.assign(I.meta,s,{joint:1}),i},gr=function(e){return[ke(e),we((function(e,r,n){return n.a}),1)]},hr=function(e,r,n,t,i){var o=L(e),u=o?C(e):je(),s=je(o);return o||a({parent:e,node:[ye({from:j,target:u}),ye({from:"value",store:1,target:s})],family:{owners:[e,r,n],links:r},meta:{op:i},regional:1}),f('sampleSource',s,u,t),[u,s]},yr=function(e,r,n,t){var a=e[r];a&&i({target:a,params:Array.isArray(a)?a.map((function(){return n})):n,defer:1,stack:t})},br=function(e){return e};exports.allSettled=function(e,r){var n=void 0===r?{}:r,t=n.scope,a=n.params;if(!_(e))return Promise.reject(new Error('first argument should be unit'));if(!(T(e)||B(e)||L(e)||G(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));G(e)&&(t=e);var o=m();o.parentFork=qe;var u=t.fxCount;$(u.scope.defers,o);var s=[],f=[];return G(e)||($(s,e),$(f,T(e)?{params:a,req:{rs:function(e){o.value={status:'done',value:e}},rj:function(e){o.value={status:'fail',value:e}}}}:a)),$(s,u),$(f,null),i({target:s,params:f,scope:t}),o.req},exports.attach=function(e){var r,n=s(e,1),t=(e=n[0]).source,a=e.effect,o=e.mapParams,f=g(e,n[1]);D(f,'attached',1);var c,d,l=A(f).scope.runner,p=we((function(e,r,n){var a,u=e.params,s=e.req,c=e.handler,d=f.finally,l=cr(n),p=dr(u,s,0,d,n,l),v=n.a,m=T(c),g=1;if(o){var h=fr(o,p,[u,v]);g=h[0],a=h[1]}else a=t&&m?v:u;if(g){if(!m)return e.args=[v,a],1;i({target:c,params:{params:a,req:{rs:dr(u,s,1,d,n,l),rj:p}},page:n.page,defer:1,meta:n.meta})}}),1,1);t?(L(t)?ae(d=t,[f]):(d=v(t),ae(f,[d])),c=[ke(C(d)),p]):c=[p],(r=l.seq).splice.apply(r,[1,0].concat(c)),f.use(a);var m=q(a);return m&&(Object.assign(E(f),u(f.shortName,m)),f.defaultConfig.parent=m),ar(a,f,"effect"),f},exports.clearNode=er,exports.combine=v,exports.createApi=function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var a=s(n),i=a[0],o=i[0],u=i[1],f=a[1],c={};return e(u,(function(e,r){var n=c[r]=d(r,{parent:q(o),config:f});o.on(n,e),ar(o,n)})),c},exports.createDomain=function n(t,o){var u=Qe({or:o,and:'string'==typeof t?{name:t}:t}),s=a({family:{type:"domain"},regional:1,parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent)}),f={history:{},graphite:s,hooks:{}};s.meta=ir("domain",f,{parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent),or:u}),e({Event:d,Effect:g,Store:p,Domain:n},(function(e,n){var t=n.toLowerCase(),a=d({named:"on"+n});f.hooks[t]=a;var o=new Set;f.history[t+"s"]=o,a.create=function(e){return i(a,e),e},$(A(a).seq,we((function(e,r,n){return n.scope=null,e}))),a.watch((function(e){ae(f,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),q(e)||(e.parent=f)})),ae(f,[a]),f["onCreate"+n]=function(e){return r(o,e),a.watch(e)},f["create"+n]=f[t]=function(r,n){var t=Qe({and:n,or:r});return null!=t&&t.domain?e(r,n):a(e(r,{parent:f,or:t}))}}));var c=q(f);return c&&e(f.hooks,(function(e,r){return nr(e,c.hooks[r])})),null!=u&&u.domain&&u.domain.hooks.domain(f),f},exports.createEffect=g,exports.createEvent=d,exports.createNode=a,exports.createStore=p,exports.createStoreObject=function(){return J(0,'createStoreObject','combine'),v.apply(void 0,arguments)},exports.createWatch=function(e){var r=e.unit,n=e.fn,t=e.scope,i=[Me.run({fn:function(e){return n(e)}})];if(t){var o=a({node:i}),u=r.graphite.id,s=t.additionalLinks,f=s[u]||[];return s[u]=f,f.push(o),w((function(){var e=f.indexOf(o);-1!==e&&f.splice(e,1),er(o)}))}var c=a({node:i,parent:[r],family:{owners:r}});return w((function(){er(c)}))},exports.fork=function(e,t){var i,o=e;W(e)&&(i=e,o=t);var u=function(e){var n=a({scope:{defers:[],inFlight:0,fxID:0},node:[we((function(e,r,n){q(n)?'dec'===R(q(n).node,'needFxCounter')?r.inFlight-=1:(r.inFlight+=1,r.fxID+=1):r.fxID+=1})),be({priority:"sampler",batch:1}),we((function(e,n){var t=n.defers,a=n.fxID;n.inFlight>0||0===t.length||Promise.resolve().then((function(){n.fxID===a&&r(t.splice(0,t.length),(function(e){Ge(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),t=a({node:[we((function(e,r,n){var t=q(n);if(t){var a=t.node;if(!R(a,'isCombine')||q(t)&&'combine'!==R(q(t).node,'op')){var i=F(n),o=a.scope.state.id,u=R(a,'sid');i.sidIdMap[u]=o,i.values.sidMap[u]=e;var s=R(a,'serialize');s&&i.sidSerializeSettings.set(u,'ignore'===s?{ignore:1}:{ignore:0,write:s.write})}}}))]}),i=a({node:[we((function(e,r,n){var t=F(n);if(t){var a=q(n);a&&(!R(a.node,'isCombine')||q(a)&&'combine'!==R(q(a).node,'op'))&&(t.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState:function(e){if('current'in e)return Ve(We,o,null,e).current;var r=A(e);return Ve(We,o,r,r.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[n,t,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:n}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:n,storeChange:t,warnSerializeNode:i,activeEffects:[]};return o}(i);if(o){var s=o.scope;if(s){var f=s.activeEffects;s.activeEffects=[],u.activeEffects=f,r(f,(function(e){return e.ref=u}))}if(o.values){var c=x(o.values,(function(e){return n(L(e),'Values map can contain only stores as keys')})),d=c.unitMap;Object.assign(u.values.sidMap,c.sidMap),r(d,(function(e,r){u.values.idMap[r.stateRef.id]=e})),u.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map)}o.handlers&&(u.handlers=x(o.handlers,(function(e){return n(T(e),"Handlers map can contain only effects as keys")})))}return u},exports.forward=function(e){var r='forward',n=s(e,1),t=n[0],i=t.from,o=t.to,u=n[1];return de(i,r,'"from"'),de(o,r,'"to"'),le(r,o,'to'),rr(a({parent:i,child:o,meta:{op:r,config:u},family:{},regional:1}))},exports.fromObservable=function(e){fe(e);var r=S in e?e[S]():e;n(r.subscribe,'expect observable to have .subscribe');var t=d(),a=rr(t);return r.subscribe({next:t,error:a,complete:a}),t},exports.guard=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var t=s(r),a=t[0],i=a[0],o=a[1],u=t[1];return o||(i=(o=i).source),y(o,'guard'),mr('guard',o.clock,i,o.filter,o.target,null,o.name,u,!o.greedy,0,1)},exports.hydrate=function(e,t){var a=t.values;n(oe(a),'values property should be an object');var o=x(a),u=o.sidMap,s=o.unitMap,f=Object.getOwnPropertyNames(u),c={};r(s,(function(e,r){c[r.stateRef.id]=r}));var d,l,p,v=[],m=[];G(e)?(p=1,n((d=e).cloneOf,'scope should be created from domain'),l=A(d.cloneOf)):W(e)?l=A(e):n(0,'first argument of hydrate should be domain or scope'),b(l,(function(e,r){if(r&&U(f,r)){$(v,e);var n=R(e,'serialize');n&&'ignore'!==n&&(u[r]=n.read(u[r])),$(m,u[r])}else e.scope.state.id in c&&($(v,e),$(m,s.get(c[e.scope.state.id])))}),1),i({target:v,params:m,scope:d}),p&&Object.assign(d.values.sidMap,u)},exports.is=H,exports.launch=i,exports.merge=h,exports.restore=function(r,n,t){if(L(r))return J(0,'restore($store)'),r;if(B(r)||T(r)){var a=q(r),i=p(n,{parent:a,name:r.shortName,and:t});return nr(T(r)?r.doneData:r,i),a&&a.hooks.store(i),i}var o=Array.isArray(r)?[]:{};return e(r,(function(e,r){return o[r]=L(e)?e:p(e,{name:r})})),o},exports.sample=function(){for(var e,r,n=arguments.length,t=new Array(n),a=0;a<n;a++)t[a]=arguments[a];var i,o,u=s(t),f=u[0],c=f[0],d=f[1],l=f[2],p=u[1],v=1;return se(d)&&oe(c)&&y(c,"sample")&&(d=c.clock,l=c.fn,v=!c.greedy,o=c.filter,e=c.target,r=c.name,i=c.sid,c=c.source),mr("sample",d,c,o,e,l,r,p,v,1,0,i)},exports.scopeBind=function(e,r){var t=void 0===r?{}:r,a=t.scope;n(a||qe||t.safe,'scopeBind cannot be called outside of forked .watch');var o=a||qe;return T(e)?function(r){var n=m();return i({target:e,params:{params:r,req:n},scope:o}),n.req}:function(r){return i({target:e,params:r,scope:o}),r}},exports.serialize=function(r,t){void 0===t&&(t={}),r.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted');var a=t.ignore?t.ignore.map((function(e){return e.sid})):[],i={};return e(r.values.sidMap,(function(e,n){var t;if(!U(a,n)){var o=r.sidIdMap[n],u=null!==(t=r.sidSerializeSettings.get(n))&&void 0!==t?t:{ignore:0,write:br};u.ignore||(i[n]=(0,u.write)(o&&o in r.reg?r.reg[o].current:e))}})),'onlyChanges'in t&&!t.onlyChanges&&(n(r.cloneOf,'scope should be created from domain'),b(A(r.cloneOf),(function(e,n){n in i||U(a,n)||R(e,'isCombine')||'ignore'===R(e,'serialize')||(i[n]=r.getState(e))}))),i},exports.setGraphInspector=function(e){k=e},exports.setInspector=function(e){Fe=e},exports.setStoreName=function(e,r){e.shortName=r,Object.assign(E(e),u(r,q(e)))},exports.split=function(){for(var r,t,i='split',o=arguments.length,u=new Array(o),c=0;c<o;c++)u[c]=arguments[c];var l=s(u),p=l[0],v=p[0],m=p[1],g=l[1],h=!m;h&&(r=v.cases,m=v.match,t=v.clock,v=v.source);var y=L(m),b=!_(m)&&ue(m),x=!y&&!b&&oe(m);n(_(v),'source must be a unit'),r||(r={}),h?e(r,(function(e,r){return le(i,e,"cases."+r)})):(n(x,'match should be an object'),e(m,(function(e,n){return r[n]=d({derived:1,named:"cases."+n,and:g})})),r.__=d({derived:1,named:'cases.__',and:g}));var w,k=new Set([].concat(v,t||[],Object.values(r))),S=Object.keys(y||b?r:m);if(y||b)y&&k.add(m),w=[y&&ke(C(m),0,1),be({safe:y,filter:1,pure:!y,fn:function(e,r,n){var t=String(y?n.a:m(e));yr(r,U(S,t)?t:'__',e,n)}})];else if(x){var M=je({});M.type='shape';var j,A=[];e(m,(function(e,r){if(_(e)){j=1,$(A,r),k.add(e);var n=nr(e,[],[ke(M),we((function(e,n,t){return t.a[r]=e}))]);if(L(e)){M.current[r]=e.getState();var t=C(e);Oe(M,{from:t,field:r,type:'field'}),f('splitMatchStore',t,n)}}})),j&&f('splitBase',M),w=[j&&ke(M,0,1),Se((function(e,r,n){for(var t=0;t<S.length;t++){var a=S[t];if(U(A,a)?n.a[a]:m[a](e))return void yr(r,a,e,n)}yr(r,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');var O=a({meta:{op:i},parent:t?[]:v,scope:r,node:w,family:{owners:Array.from(k)},regional:1});if(t&&mr(i,t,v,null,O,null,i,g,0,0,0),!h)return r},exports.step=Me,exports.version="22.8.2",exports.withFactory=function(e){var r=e.sid,n=e.name,i=e.loc,o=e.method,u=e.fn;return t(a({meta:{sidRoot:te(r),sid:r,name:n,loc:i,method:o,type:'factory'}}),u)},exports.withRegion=t; | ||
'use strict';function e(e,r){for(var n in e)r(e[n],n)}function r(e,r){e.forEach(r)}function n(e,r){if(!e)throw Error(r)}function t(e,r){var n=A(e).meta||{};ee={id:A(e).id,parent:ee,value:e,template:n.template||ne(),sidRoot:n.sidRoot||ee&&ee.sidRoot,meta:n};try{return r()}finally{re('region'),ee=q(ee)}}function a(e){var n=void 0===e?{}:e,t=n.node,a=void 0===t?[]:t,i=n.parent,o=n.child,u=void 0===o?n.to||n.target:o,f=n.scope,s=void 0===f?{}:f,c=n.meta,d=void 0===c?{}:c,l=n.family,p=void 0===l?{type:'regular'}:l,v=n.regional,m=ie(void 0===i?n.from||n.source:i),g=ie(p.links),h=ie(p.owners),y=[];r(a,(function(e){return e&&$(y,e)}));var b={id:Y(),seq:y,next:ie(u),meta:d,scope:s,family:{type:p.type||"crosslink",links:g,owners:h}};return r(g,(function(e){return $(O(e),b)})),r(h,(function(e){return $(z(e),b)})),r(m,(function(e){return $(e.next,b)})),v&&ee&&ae(I(ee),[b]),b}function i(e,n,t){var a,i=We,o=null,u=qe;if(e.target&&(n=e.params,t=e.defer,a=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),u=F(e)||u,e=e.target),u&&qe&&u!==qe&&(qe=null),Array.isArray(e))for(var f=0;f<e.length;f++)De('pure',i,A(e[f]),o,n[f],u,a);else De('pure',i,A(e),o,n,u,a);if(!t||Le){var s,c,d,l,p,v,m={isRoot:Le,currentPage:We,scope:qe,isWatch:Be,isPure:Te};Le=0;for(var g=function(){var e=l.idx,n=l.stack,t=l.type;d=n.node,We=p=n.page,qe=F(n),p?v=p.reg:qe&&(v=qe.reg);var a=!!p,i=!!qe,o={fail:0,scope:d.scope};s=c=0;for(var u=e;u<d.seq.length&&!s;u++){var f=d.seq[u];if(f.order){var g=f.order,h=g.priority,y=g.barrierID,b=y?p?p.fullID+"_"+y:y:0;if(u!==e||t!==h)return y?Pe.has(b)||(Pe.add(b),Ee(u,n,h,y)):Ee(u,n,h),"continue|kernelLoop";y&&Pe.delete(b)}switch(f.type){case'mov':var x=f.data,w=void 0;switch(x.from){case j:w=I(n);break;case"a":case'b':w=n[x.from];break;case"value":w=x.store;break;case"store":if(v&&!v[x.store.id])if(a){var k=Ue(p,x.store.id);n.page=p=k,k?v=k.reg:i?(Je(qe,x.store,0,1,x.softRead),v=qe.reg):v=void 0}else i&&Je(qe,x.store,0,1,x.softRead);w=Ae(v&&v[x.store.id]||x.store)}switch(x.to){case j:n.value=w;break;case"a":case'b':n[x.to]=w;break;case"store":Ve(p,qe,d,x.target).current=w}break;case'compute':var S=f.data;if(S.fn){Be='watch'===R(d,'op'),Te=S.pure;var M=S.safe?(0,S.fn)(I(n),o.scope,n):Ke(o,S.fn,n);S.filter?c=!M:n.value=M,Be=m.isWatch,Te=m.isPure}}s=o.fail||c}if(Fe&&Fe(n,o),!s){var A=I(n),O=F(n);if(r(d.next,(function(e){De('child',p,e,n,A,O)})),O){R(d,'needFxCounter')&&De('child',p,O.fxCount,n,A,O),R(d,'storeChange')&&De('child',p,O.storeChange,n,A,O),R(d,'warnSerialize')&&De('child',p,O.warnSerializeNode,n,A,O);var z=O.additionalLinks[d.id];z&&r(z,(function(e){De('child',p,e,n,A,O)}))}}};l=Re();)g();Le=m.isRoot,We=m.currentPage,qe=F(m)}}function o(r,n){void 0===n&&(n='combine');var t=n+'(',a='',i=0;return e(r,(function(e){i<25&&(null!=e&&(t+=a,t+=_(e)?E(e).fullName:e.toString()),i+=1,a=', ')})),t+')'}function u(e,r){var n,t,a=e;if(r){var i=E(r);0===e.length?(n=i.path,t=i.fullName):(n=i.path.concat([e]),t=0===i.fullName.length?e:i.fullName+'/'+e)}else n=0===e.length?[]:[e],t=e;return{shortName:a,fullName:t,path:n}}function f(e,r){var n=r?e:e[0];se(n);var t=n.or,a=n.and;if(a){var i=r?a:a[0];if(oe(i)&&'and'in i){var o=f(a,r);e=o[0],t=Object.assign({},t,o[1])}else e=a}return[e,t]}function s(e){var r=ne();if(r){for(var n=r.handlers[e],t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];if(n)return n.apply(void 0,[r].concat(a))}}function c(e,r,n,t){var a=We,i=null;if(r)for(i=We;i&&i.template!==r;)i=q(i);He(i);var o=e.create(n,t);return He(a),o}function d(e,r){var n=Qe({or:r,and:'string'==typeof e?{name:e}:e}),t=function e(r){J(!R(e,'derived'),'call of derived event','createEvent'),J(!Te,'unit call from pure function','operators like sample');for(var n=arguments.length,t=new Array(n>1?n-1:0),a=1;a<n;a++)t[a-1]=arguments[a];return We?c(e,o,r,t):e.create(r,t)},o=ne(),u=Object.assign(t,{graphite:a({meta:ir(n.actualOp||"event",t,n),regional:1}),create:function(e){return i({target:t,params:e,scope:qe}),e},watch:function(e){return tr(t,e)},map:function(e){return or(t,M,e,[Se()])},filter:function(e){return or(t,"filter",e.fn?e:e.fn,[Se(me,1)])},filterMap:function(e){return or(t,'filterMap',e,[Se(),we((function(e){return!fe(e)}),1)])},prepend:function(e){var r=d('* \u2192 '+t.shortName,{parent:q(t)});return s('eventPrepend',A(r)),nr(r,t,[Se()],'prepend',e),ar(t,r),r}});return null!=n&&n.domain&&n.domain.hooks.event(u),D(u,'id',u.graphite.id),re(u.graphite),u}function l(e,t,a,i){return de(a,t,'first argument'),n(ue(i),'second argument should be a function'),J(!R(e,'derived'),t+" in derived store",t+" in store created via createStore"),r(Array.isArray(a)?a:[a],(function(r){e.off(r),N(e).set(r,rr(ur(r,e,'on',ve,i)))})),e}function p(e,t){var o=Qe(t),u=je(e),f=d({named:'updates',derived:1});s('storeBase',u);var c=u.id,v={subscribers:new Map,updates:f,defaultState:e,stateRef:u,getState:function(){var e,r=u;if(We){for(var n=We;n&&!n.reg[c];)n=q(n);n&&(e=n)}return!e&&qe&&(Je(qe,u,1),e=qe),e&&(r=e.reg[c]),Ae(r)},setState:function(e){return i({target:v,params:e,defer:1,scope:qe})},reset:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return r(n,(function(e){return l(v,'.reset',e,(function(){return v.defaultState}))})),v},on:function(e,r){return l(v,'.on',e,r)},off:function(e){var r=N(v).get(e);return r&&(r(),N(v).delete(e)),v},map:function(e,r){var n,t;oe(e)&&(n=e,e=e.fn),J(fe(r),'second argument of store.map','updateFilter');var a=v.getState();ne()?t=null:fe(a)||(t=e(a,r));var i=p(t,{name:v.shortName+" \u2192 *",derived:1,and:n}),o=ur(v,i,M,pe,e);return Oe(C(i),{type:M,fn:e,from:u}),C(i).noInit=1,s('storeMap',u,o),i},watch:function(e,r){if(!r||!_(e)){var t=tr(v,e);return s('storeWatch',u,e)||e(v.getState()),t}return n(ue(r),'second argument should be a function'),e.watch((function(e){return r(v.getState(),e)}))}},m=ir("store",v,o),g=v.defaultConfig.updateFilter;v.graphite=a({scope:{state:u,fn:g},node:[we((function(e,r,n){return n.scope&&!n.scope.reg[u.id]&&(n.b=1),e})),ke(u),we((function(e,r,n){var t=n.a,a=n.b;return!fe(e)&&(e!==t||a)}),1),g&&Se(pe,1),ye({from:j,target:u})],child:f,meta:Object.assign({},m,{defaultState:e}),regional:1}),D(v,'id',v.graphite.id),D(v,'rootStateRefId',c);var h=R(v,'serialize'),y=R(v,'derived'),b='ignore'===h,x=R(v,'sid');return x&&(D(v,'storeChange',1),u.sid=x),x||b||y||D(v,'warnSerialize',1),n(y||!fe(e),"current state can't be undefined, use null instead"),ae(v,[f]),null!=o&&o.domain&&o.domain.hooks.store(v),y||(v.reinit=d({named:'reinit'}),v.reset(v.reinit)),u.meta=v.graphite.meta,re(v.graphite),v}function v(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var a,i,o,u=f(r);o=u[1];var s,c,d,l=(r=u[0])[r.length-1];if(ue(l)?(i=r.slice(0,-1),a=l):i=r,1===i.length){var p=i[0];L(p)||(s=p,c=1)}if(!c&&(s=i,a)){d=1;var v=a;a=function(e){return v.apply(void 0,e)}}return n(oe(s),'shape should be an object'),fr(Array.isArray(s),!d,s,o,a)}function m(){var e={};return e.req=new Promise((function(r,n){e.rs=r,e.rj=n})),e.req.catch((function(){})),e}function g(e,r){void 0===r&&(r={});var t=Qe(ue(e)?{handler:e}:e,r),o=d(ue(e)?{handler:e}:e,Object.assign({},r,{actualOp:"effect"})),u=A(o);D(u,'op',o.kind="effect"),o.use=function(e){return n(ue(e),'.use argument should be a function'),g.scope.handler=e,o},o.use.getCurrent=function(){return g.scope.handler};var f=o.finally=d({named:'finally',derived:1}),s=o.done=f.filterMap({named:'done',fn:function(e){if('done'===e.status)return{params:e.params,result:e.result}}}),c=o.fail=f.filterMap({named:'fail',fn:function(e){if('fail'===e.status)return{params:e.params,error:e.error}}}),l=o.doneData=s.map({named:'doneData',fn:function(e){return e.result}}),v=o.failData=c.map({named:'failData',fn:function(e){return e.error}}),g=a({scope:{handler:o.defaultConfig.handler||function(){return n(0,"no handler used in "+o.getType())}},node:[we((function(e,r,n){var t=r.handler,a=F(n);if(a){var i=o.sid?a.handlers.sidMap[o.sid]:a.handlers.unitMap.get(o);i&&(t=i)}return e.handler=t,e}),0,1),we((function(e,r,n){var t=e.params,a=e.req,i=e.handler,o=e.args,u=void 0===o?[t]:o,s=cr(n),c=dr(t,a,1,f,n,s),d=dr(t,a,0,f,n,s),l=sr(i,d,u),p=l[1];l[0]&&(oe(p)&&ue(p.then)?p.then(c,d):c(p))}),0,1)],meta:{op:'fx',fx:'runner'}});u.scope.runner=g,$(u.seq,we((function(e,r,n){var t=r.runner,a=q(n)?{params:e,req:{rs:function(){},rj:function(){}}}:e;return n.meta||(n.meta={fxID:Z()}),i({target:t,params:a,defer:1,scope:F(n),meta:n.meta}),a.params}),0,1)),o.create=function(e){var r=m(),n={params:e,req:r};if(qe&&!Be){var t=qe;r.req.finally((function(){Ge(t)})).catch((function(){}))}return i({target:o,params:n,scope:qe}),r.req};var h=o.inFlight=p(0,{serialize:'ignore',named:(R(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(function(e){return e+1})).on(f,(function(e){return e-1})).map({fn:function(e){return e},named:'inFlight'});D(f,'needFxCounter','dec'),D(o,'needFxCounter',1);var y=o.pending=h.map({fn:function(e){return e>0},named:'pending'});return ae(o,[f,s,c,l,v,y,h]),null!=t&&t.domain&&t.domain.hooks.effect(o),o}function h(e,r){de(e,'merge','first argument');var n=d({name:o(e,'merge'),derived:1,and:r});return nr(e,n,[],'merge'),n}function y(e,t){var a=0;return r(pr,(function(r){r in e&&(n(null!=e[r],vr(t,r)),a=1)})),a}function b(e,n,t){var a=[];(function e(i){U(a,i)||($(a,i),"store"===R(i,'op')&&(t||R(i,'sid'))&&n(i,R(i,'sid')),r(i.next,e),r(O(i),e),r(z(i),e))})(e)}function x(e,t){var a=Array.isArray(e)?new Map(e):e,i=new Map;if(a instanceof Map){var o={};return r(a,(function(e,r){n(_(r),'Map key should be a unit'),t&&t(r,e),r.sid?(n(!(r.sid in o),'duplicate sid found'),o[r.sid]=e):i.set(r,e)})),{sidMap:o,unitMap:i}}return{sidMap:a,unitMap:i}}function w(e){var r=function(){return e()};return r.unsubscribe=function(){return e()},r}Object.defineProperty(exports,'__esModule',{value:1});for(var k,S='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',M='map',j='stack',A=function(e){return e.graphite||e},O=function(e){return e.family.owners},z=function(e){return e.family.links},C=function(e){return e.stateRef},I=function(e){return e.value},N=function(e){return e.subscribers},q=function(e){return e.parent},F=function(e){return e.scope},R=function(e,r){return A(e).meta[r]},D=function(e,r,n){return A(e).meta[r]=n},E=function(e){return e.compositeName},_=function(e){return(ue(e)||oe(e))&&'kind'in e},P=function(e){return function(r){return _(r)&&r.kind===e}},L=P("store"),B=P("event"),T=P("effect"),W=P("domain"),G=P("scope"),H={__proto__:null,unit:_,store:L,event:B,effect:T,domain:W,scope:G,attached:function(e){return T(e)&&1==R(e,'attached')}},U=function(e,r){return e.includes(r)},V=function(e,r){var n=e.indexOf(r);-1!==n&&e.splice(n,1)},$=function(e,r){return e.push(r)},J=function(e,r,n){return!e&&console.error(r+" is deprecated"+(n?", use "+n+" instead":''))},K=function(){var e=0;return function(){return""+ ++e}},Q=K(),X=K(),Y=K(),Z=K(),ee=null,re=function(e){k&&k(e,ee)},ne=function(){return ee&&ee.template},te=function(e){return e&&ee&&ee.sidRoot&&(e=ee.sidRoot+"|"+e),e},ae=function(e,n){var t=A(e);r(n,(function(e){var r=A(e);"domain"!==t.family.type&&(r.family.type="crosslink"),$(O(r),t),$(z(t),r)}))},ie=function(e){return void 0===e&&(e=[]),(Array.isArray(e)?e:[e]).flat().map(A)},oe=function(e){return'object'==typeof e&&null!==e},ue=function(e){return'function'==typeof e},fe=function(e){return void 0===e},se=function(e){return n(oe(e)||ue(e),'expect first argument be an object')},ce=function(e,r,t,a){return n(!(!oe(e)&&!ue(e)||!('family'in e)&&!('graphite'in e)),r+": expect "+t+" to be a unit (store, event or effect)"+a)},de=function(e,n,t){Array.isArray(e)?r(e,(function(e,r){return ce(e,n,r+" item of "+t,'')})):ce(e,n,t,' or array of units')},le=function(e,n,t){return void 0===t&&(t='target'),r(ie(n),(function(r){return J(!R(r,'derived'),e+": derived unit in \""+t+"\"","createEvent/createStore")}))},pe=function(e,r,n){return(0,r.fn)(e,n.a)},ve=function(e,r,n){return(0,r.fn)(n.a,e)},me=function(e,r){return(0,r.fn)(e)},ge=function(e,r,n,t){var a={id:X(),type:e,data:r};return n&&(a.order={priority:n},t&&(a.order.barrierID=++he)),a},he=0,ye=function(e){var r=e.from,n=e.target,t=e.to;return ge('mov',{from:void 0===r?"store":r,store:e.store,to:void 0===t?n?"store":j:t,target:n},e.priority,e.batch)},be=function(e){var r=e.safe,n=e.filter,t=e.pure;return ge('compute',{fn:e.fn,safe:void 0===r?0:r,filter:void 0===n?0:n,pure:void 0===t?0:t},e.priority,e.batch)},xe=function(e){return be({fn:e.fn,priority:"effect"})},we=function(e,r,n){return be({fn:e,safe:1,filter:r,priority:n&&"effect"})},ke=function(e,r,n){return ye({store:e,to:r?j:"a",priority:n&&"sampler",batch:1})},Se=function(e,r){return void 0===e&&(e=me),be({fn:e,pure:1,filter:r})},Me={mov:ye,compute:be,filter:function(e){return be({fn:e.fn,filter:1,pure:e.pure})},run:xe},je=function(e){return{id:X(),current:e}},Ae=function(e){return e.current},Oe=function(e,r){e.before||(e.before=[]),$(e.before,r)},ze=null,Ce=function e(r,n){return r?n?((r.v.type===n.v.type&&r.v.id>n.v.id||_e(r.v.type)>_e(n.v.type))&&(t=r,r=n,n=t),t=e(r.r,n),r.r=r.l,r.l=t,r):r:n;var t},Ie=[],Ne=0;Ne<6;)$(Ie,{first:null,last:null,size:0}),Ne+=1;var qe,Fe,Re=function(){for(var e=0;e<6;e++){var r=Ie[e];if(r.size>0){if(3===e||4===e){r.size-=1;var n=ze.v;return ze=Ce(ze.l,ze.r),n}1===r.size&&(r.last=null);var t=r.first;return r.first=t.r,r.size-=1,t.v}}},De=function(e,r,n,t,a,i,o){return Ee(0,{a:null,b:null,node:n,parent:t,value:a,page:r,scope:i,meta:o},e)},Ee=function(e,r,n,t){void 0===t&&(t=0);var a=_e(n),i=Ie[a],o={v:{idx:e,stack:r,type:n,id:t},l:null,r:null};3===a||4===a?ze=Ce(ze,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},_e=function(e){switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case"barrier":return 3;case"sampler":return 4;case"effect":return 5;default:return-1}},Pe=new Set,Le=1,Be=0,Te=0,We=null,Ge=function(e){qe=e},He=function(e){We=e},Ue=function(e,r){if(e){for(;e&&!e.reg[r];)e=q(e);if(e)return e}return null},Ve=function(e,r,n,t,a){var i=Ue(e,t.id);return i?i.reg[t.id]:r?(Je(r,t,a),r.reg[t.id]):t},$e=function(e){return e},Je=function e(n,t,a,i,o){var u,f=n.reg,s=t.sid,c=null==t||null===(u=t.meta)||void 0===u?void 0:u.serialize;if(!f[t.id]){var d={id:t.id,current:t.current,meta:t.meta};if(s&&s in n.values.sidMap&&!(s in n.sidIdMap))d.current=(n.fromSerialize&&'ignore'!==c&&(null==c?void 0:c.read)||$e)(n.values.sidMap[s]);else if(d.id in n.values.idMap)d.current=n.values.idMap[d.id];else if(t.before&&!o){var l=0,p=a||!t.noInit||i;r(t.before,(function(r){switch(r.type){case M:var t=r.from;if(t||r.fn){t&&e(n,t,a,i);var o=t&&f[t.id].current;p&&(d.current=r.fn?r.fn(o):o)}break;case'field':l||(l=1,d.current=Array.isArray(d.current)?[].concat(d.current):Object.assign({},d.current)),e(n,r.from,a,i),p&&(d.current[r.field]=f[f[r.from.id].id].current)}}))}s&&(n.sidIdMap[s]=t.id),f[t.id]=d}},Ke=function(e,r,n){try{return r(I(n),e.scope,n)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Qe=function r(n,t){return void 0===t&&(t={}),oe(n)&&(r(n.or,t),e(n,(function(e,r){fe(e)||'or'===r||'and'===r||(t[r]=e)})),r(n.and,t)),t},Xe=function(e,r){V(e.next,r),V(O(e),r),V(z(e),r)},Ye=function e(r,n,t){var a;r.next.length=0,r.seq.length=0,r.scope=null;for(var i=z(r);a=i.pop();)Xe(a,r),(n||t&&'sample'!==R(r,'op')||"crosslink"===a.family.type)&&e(a,n,'on'!==R(a,'op')&&t);for(i=O(r);a=i.pop();)Xe(a,r),t&&"crosslink"===a.family.type&&e(a,n,'on'!==R(a,'op')&&t)},Ze=function(e){return e.clear()},er=function(e,r){var n=(void 0===r?{}:r).deep,t=0;if(e.ownerSet&&e.ownerSet.delete(e),L(e))Ze(N(e));else if(W(e)){t=1;var a=e.history;Ze(a.events),Ze(a.effects),Ze(a.stores),Ze(a.domains)}Ye(A(e),!!n,t)},rr=function(e){var r=function(){return er(e)};return r.unsubscribe=r,r},nr=function(e,r,n,t,i){return a({node:n,parent:e,child:r,scope:{fn:i},meta:{op:t},family:{owners:[e,r],links:r},regional:1})},tr=function(e,r){return n(ue(r),'.watch argument should be a function'),rr(a({scope:{fn:r},node:[xe({fn:me})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))},ar=function(e,r,n){void 0===n&&(n="event"),q(e)&&q(e).hooks[n](r)},ir=function(e,r,n){var t=Qe(n),a="domain"===e,i=Q(),o=t.sid,f=void 0===o?null:o,s=t.named,c=void 0===s?null:s,d=t.domain,l=t.parent,p=void 0===l?void 0===d?null:d:l,v=c||t.name||(a?'':i),m=u(v,p),g={op:r.kind=e,name:r.shortName=v,sid:r.sid=te(f),named:c,unitId:r.id=i,serialize:t.serialize,derived:t.derived,config:t};if(r.parent=p,r.compositeName=m,r.defaultConfig=t,r.thru=function(e){return J(0,'thru','js pipe'),e(r)},r.getType=function(){return m.fullName},!a){r.subscribe=function(e){return se(e),r.watch(ue(e)?e:function(r){return e.next&&e.next(r)})},r[S]=function(){return r};var h=ne();h&&(g.nativeTemplate=h)}return g},or=function(e,r,n,t){var a;oe(n)&&(a=n,n=n.fn);var i=d({name:e.shortName+" \u2192 *",derived:1,and:a});return nr(e,i,t,r,n),i},ur=function(e,r,n,t,a){var i=C(r),o=ye({store:i,to:"a",priority:'read'});n===M&&(o.data.softRead=1);var u=[o,Se(t)];return s('storeOnMap',i,u,L(e)&&C(e)),nr(e,r,u,n,a)},fr=function(r,t,a,i,u){var f=r?function(e){return[].concat(e)}:function(e){return Object.assign({},e)},c=r?[]:{},d=f(c),l=je(d),v=je(1);l.type=r?'list':'shape',l.noInit=1,s('combineBase',l,v);var m=p(d,{name:o(a),derived:1,and:i}),g=C(m);g.noInit=1,D(m,'isCombine',1);var h=ke(l);h.order={priority:'barrier'};var y=[we((function(e,r,n){return n.scope&&!n.scope.reg[l.id]&&(n.c=1),e})),h,ye({store:v,to:'b'}),we((function(e,r,n){var a=r.key;if(n.c||e!==n.a[a])return t&&n.b&&(n.a=f(n.a)),n.a[a]=e,1}),1),ye({from:"a",target:l}),ye({from:"value",store:0,target:v}),ye({from:"value",store:1,target:v,priority:"barrier",batch:1}),ke(l,1),u&&Se()];return e(a,(function(e,r){if(!L(e))return n(!_(e)&&!fe(e),"combine expects a store in a field "+r),void(d[r]=c[r]=e);c[r]=e.defaultState,d[r]=e.getState();var t=nr(e,m,y,'combine',u);t.scope.key=r;var a=C(e);Oe(l,{type:'field',field:r,from:a}),s('combineField',a,t)})),m.defaultShape=a,Oe(g,{type:M,from:l,fn:u}),ne()||(m.defaultState=u?g.current=u(d):c),m},sr=function(e,r,n){try{return[1,e.apply(void 0,n)]}catch(t){return r(t),[0,null]}},cr=function(e){var r=F(e),n={ref:r};return r&&$(r.activeEffects,n),n},dr=function(e,r,n,t,a,o){return function(u){o.ref&&V(o.ref.activeEffects,o),i({target:[t,lr],params:[n?{status:'done',params:e,result:u}:{status:'fail',params:e,error:u},{value:u,fn:n?r.rs:r.rj}],defer:1,page:a.page,scope:o.ref,meta:a.meta})}},lr=a({node:[xe({fn:function(e){return(0,e.fn)(e.value)}})],meta:{op:'fx',fx:'sidechain'}}),pr=['source','clock','target'],vr=function(e,r){return e+": "+r+" should be defined"},mr=function(e,r,t,a,i,o,u,f,c,l,m,g){var y=!!i;n(!fe(t)||!fe(r),vr(e,'either source or clock'));var b=0;fe(t)?b=1:_(t)||(t=v(t)),fe(r)?r=t:(de(r,e,'clock'),Array.isArray(r)&&(r=h(r))),b&&(t=r),f||u||(u=t.shortName);var x='none';(m||a)&&(_(a)?x='unit':(n(ue(a),'`filter` should be function or unit'),x='fn')),i?(de(i,e,'target'),le(e,i)):'none'===x&&l&&L(t)&&L(r)?i=p(o?o(Ae(C(t)),Ae(C(r))):Ae(C(t)),{name:u,sid:g,or:f}):(i=d({name:u,derived:1,or:f}),s('sampleTarget',A(i)));var w=je(),k=[];if('unit'===x){var S=hr(a,i,r,w,e),M=S[0];k=[].concat(gr(S[1]),gr(M))}var O=hr(t,i,r,w,e),z=O[0],I=O[1],N=nr(r,i,[s('sampleSourceLoader'),ye({from:j,target:w})].concat(gr(I),[ke(z,1,c)],k,[ke(w),'fn'===x&&Se((function(e,r,n){return a(e,n.a)}),1),o&&Se(pe),s('sampleSourceUpward',y)]),e,o);return ae(t,[N]),Object.assign(N.meta,f,{joint:1}),i},gr=function(e){return[ke(e),we((function(e,r,n){return n.a}),1)]},hr=function(e,r,n,t,i){var o=L(e),u=o?C(e):je(),f=je(o);return o||a({parent:e,node:[ye({from:j,target:u}),ye({from:"value",store:1,target:f})],family:{owners:[e,r,n],links:r},meta:{op:i},regional:1}),s('sampleSource',f,u,t),[u,f]},yr=function(e,r,n,t){var a=e[r];a&&i({target:a,params:Array.isArray(a)?a.map((function(){return n})):n,defer:1,stack:t})},br=function(e){return e};exports.allSettled=function(e,r){var n=void 0===r?{}:r,t=n.scope,a=n.params;if(!_(e))return Promise.reject(new Error('first argument should be unit'));if(!(T(e)||B(e)||L(e)||G(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));G(e)&&(t=e);var o=m();o.parentFork=qe;var u=t.fxCount;$(u.scope.defers,o);var f=[],s=[];return G(e)||($(f,e),$(s,T(e)?{params:a,req:{rs:function(e){o.value={status:'done',value:e}},rj:function(e){o.value={status:'fail',value:e}}}}:a)),$(f,u),$(s,null),i({target:f,params:s,scope:t}),o.req},exports.attach=function(e){var r,n=f(e,1),t=(e=n[0]).source,a=e.effect,o=e.mapParams,s=g(e,n[1]);D(s,'attached',1);var c,d,l=A(s).scope.runner,p=we((function(e,r,n){var a,u=e.params,f=e.req,c=e.handler,d=s.finally,l=cr(n),p=dr(u,f,0,d,n,l),v=n.a,m=T(c),g=1;if(o){var h=sr(o,p,[u,v]);g=h[0],a=h[1]}else a=t&&m?v:u;if(g){if(!m)return e.args=[v,a],1;i({target:c,params:{params:a,req:{rs:dr(u,f,1,d,n,l),rj:p}},page:n.page,defer:1,meta:n.meta})}}),1,1);t?(L(t)?ae(d=t,[s]):(d=v(t),ae(s,[d])),c=[ke(C(d)),p]):c=[p],(r=l.seq).splice.apply(r,[1,0].concat(c)),s.use(a);var m=q(a);return m&&(Object.assign(E(s),u(s.shortName,m)),s.defaultConfig.parent=m),ar(a,s,"effect"),s},exports.clearNode=er,exports.combine=v,exports.createApi=function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var a=f(n),i=a[0],o=i[0],u=i[1],s=a[1],c={};return e(u,(function(e,r){var n=c[r]=d(r,{parent:q(o),config:s});o.on(n,e),ar(o,n)})),c},exports.createDomain=function n(t,o){var u=Qe({or:o,and:'string'==typeof t?{name:t}:t}),f=a({family:{type:"domain"},regional:1,parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent)}),s={history:{},graphite:f,hooks:{}};f.meta=ir("domain",s,{parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent),or:u}),e({Event:d,Effect:g,Store:p,Domain:n},(function(e,n){var t=n.toLowerCase(),a=d({named:"on"+n});s.hooks[t]=a;var o=new Set;s.history[t+"s"]=o,a.create=function(e){return i(a,e),e},$(A(a).seq,we((function(e,r,n){return n.scope=null,e}))),a.watch((function(e){ae(s,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),q(e)||(e.parent=s)})),ae(s,[a]),s["onCreate"+n]=function(e){return r(o,e),a.watch(e)},s["create"+n]=s[t]=function(r,n){var t=Qe({and:n,or:r});return null!=t&&t.domain?e(r,n):a(e(r,{parent:s,or:t}))}}));var c=q(s);return c&&e(s.hooks,(function(e,r){return nr(e,c.hooks[r])})),null!=u&&u.domain&&u.domain.hooks.domain(s),s},exports.createEffect=g,exports.createEvent=d,exports.createNode=a,exports.createStore=p,exports.createStoreObject=function(){return J(0,'createStoreObject','combine'),v.apply(void 0,arguments)},exports.createWatch=function(e){var r=e.unit,n=e.fn,t=e.scope,i=[Me.run({fn:function(e){return n(e)}})];if(t){var o=a({node:i}),u=r.graphite.id,f=t.additionalLinks,s=f[u]||[];return f[u]=s,s.push(o),w((function(){var e=s.indexOf(o);-1!==e&&s.splice(e,1),er(o)}))}var c=a({node:i,parent:[r],family:{owners:r}});return w((function(){er(c)}))},exports.fork=function(e,t){var i,o=e;W(e)&&(i=e,o=t);var u=function(e){var n=a({scope:{defers:[],inFlight:0,fxID:0},node:[we((function(e,r,n){q(n)?'dec'===R(q(n).node,'needFxCounter')?r.inFlight-=1:(r.inFlight+=1,r.fxID+=1):r.fxID+=1})),be({priority:"sampler",batch:1}),we((function(e,n){var t=n.defers,a=n.fxID;n.inFlight>0||0===t.length||Promise.resolve().then((function(){n.fxID===a&&r(t.splice(0,t.length),(function(e){Ge(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),t=a({node:[we((function(e,r,n){var t=q(n);if(t){var a=t.node;if(!R(a,'isCombine')||q(t)&&'combine'!==R(q(t).node,'op')){var i=F(n),o=a.scope.state.id,u=R(a,'sid');i.sidIdMap[u]=o,i.values.sidMap[u]=e;var f=R(a,'serialize');f&&i.sidSerializeSettings.set(u,'ignore'===f?{ignore:1}:{ignore:0,write:f.write})}}}))]}),i=a({node:[we((function(e,r,n){var t=F(n);if(t){var a=q(n);a&&(!R(a.node,'isCombine')||q(a)&&'combine'!==R(q(a).node,'op'))&&(t.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState:function(e){if('current'in e)return Ve(We,o,null,e).current;var r=A(e);return Ve(We,o,r,r.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[n,t,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:n}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:n,storeChange:t,warnSerializeNode:i,activeEffects:[]};return o}(i);if(o){var f=o.scope;if(f){var s=f.activeEffects;f.activeEffects=[],u.activeEffects=s,r(s,(function(e){return e.ref=u}))}if(o.values){var c=x(o.values,(function(e){return n(L(e),'Values map can contain only stores as keys')})),d=c.unitMap;Object.assign(u.values.sidMap,c.sidMap),r(d,(function(e,r){u.values.idMap[r.stateRef.id]=e})),u.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map)}o.handlers&&(u.handlers=x(o.handlers,(function(e){return n(T(e),"Handlers map can contain only effects as keys")})))}return u},exports.forward=function(e){var r='forward',n=f(e,1),t=n[0],i=t.from,o=t.to,u=n[1];return de(i,r,'"from"'),de(o,r,'"to"'),le(r,o,'to'),rr(a({parent:i,child:o,meta:{op:r,config:u},family:{},regional:1}))},exports.fromObservable=function(e){se(e);var r=S in e?e[S]():e;n(r.subscribe,'expect observable to have .subscribe');var t=d(),a=rr(t);return r.subscribe({next:t,error:a,complete:a}),t},exports.guard=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var t=f(r),a=t[0],i=a[0],o=a[1],u=t[1];return o||(i=(o=i).source),y(o,'guard'),mr('guard',o.clock,i,o.filter,o.target,null,o.name,u,!o.greedy,0,1)},exports.hydrate=function(e,t){var a=t.values;n(oe(a),'values property should be an object');var o=x(a),u=o.sidMap,f=o.unitMap,s=Object.getOwnPropertyNames(u),c={};r(f,(function(e,r){c[r.stateRef.id]=r}));var d,l,p,v=[],m=[];G(e)?(p=1,n((d=e).cloneOf,'scope should be created from domain'),l=A(d.cloneOf)):W(e)?l=A(e):n(0,'first argument of hydrate should be domain or scope'),b(l,(function(e,r){if(r&&U(s,r)){$(v,e);var n=R(e,'serialize');n&&'ignore'!==n&&(u[r]=n.read(u[r])),$(m,u[r])}else e.scope.state.id in c&&($(v,e),$(m,f.get(c[e.scope.state.id])))}),1),i({target:v,params:m,scope:d}),p&&Object.assign(d.values.sidMap,u)},exports.is=H,exports.launch=i,exports.merge=h,exports.restore=function(r,n,t){if(L(r))return J(0,'restore($store)'),r;if(B(r)||T(r)){var a=q(r),i=p(n,{parent:a,name:r.shortName,and:t});return nr(T(r)?r.doneData:r,i),a&&a.hooks.store(i),i}var o=Array.isArray(r)?[]:{};return e(r,(function(e,r){return o[r]=L(e)?e:p(e,{name:r})})),o},exports.sample=function(){for(var e,r,n=arguments.length,t=new Array(n),a=0;a<n;a++)t[a]=arguments[a];var i,o,u=f(t),s=u[0],c=s[0],d=s[1],l=s[2],p=u[1],v=1;return fe(d)&&oe(c)&&y(c,"sample")&&(d=c.clock,l=c.fn,v=!c.greedy,o=c.filter,e=c.target,r=c.name,i=c.sid,c=c.source),mr("sample",d,c,o,e,l,r,p,v,1,0,i)},exports.scopeBind=function(e,r){var t=void 0===r?{}:r,a=t.scope;n(a||qe||t.safe,'scopeBind cannot be called outside of forked .watch');var o=a||qe;return T(e)?function(r){var n=m();return i({target:e,params:{params:r,req:n},scope:o}),n.req}:function(r){return i({target:e,params:r,scope:o}),r}},exports.serialize=function(r,t){void 0===t&&(t={}),r.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted');var a=t.ignore?t.ignore.map((function(e){return e.sid})):[],i={};return e(r.values.sidMap,(function(e,n){var t;if(!U(a,n)){var o=r.sidIdMap[n],u=null!==(t=r.sidSerializeSettings.get(n))&&void 0!==t?t:{ignore:0,write:br};u.ignore||(i[n]=(0,u.write)(o&&o in r.reg?r.reg[o].current:e))}})),'onlyChanges'in t&&!t.onlyChanges&&(n(r.cloneOf,'scope should be created from domain'),b(A(r.cloneOf),(function(e,n){n in i||U(a,n)||R(e,'isCombine')||'ignore'===R(e,'serialize')||(i[n]=r.getState(e))}))),i},exports.setGraphInspector=function(e){k=e},exports.setInspector=function(e){Fe=e},exports.setStoreName=function(e,r){e.shortName=r,Object.assign(E(e),u(r,q(e)))},exports.split=function(){for(var r,t,i='split',o=arguments.length,u=new Array(o),c=0;c<o;c++)u[c]=arguments[c];var l=f(u),p=l[0],v=p[0],m=p[1],g=l[1],h=!m;h&&(r=v.cases,m=v.match,t=v.clock,v=v.source);var y=L(m),b=!_(m)&&ue(m),x=!y&&!b&&oe(m);n(_(v),'source must be a unit'),r||(r={}),h?e(r,(function(e,r){return le(i,e,"cases."+r)})):(n(x,'match should be an object'),e(m,(function(e,n){return r[n]=d({derived:1,named:"cases."+n,and:g})})),r.__=d({derived:1,named:'cases.__',and:g}));var w,k=new Set([].concat(v,t||[],Object.values(r))),S=Object.keys(y||b?r:m);if(y||b)y&&k.add(m),w=[y&&ke(C(m),0,1),be({safe:y,filter:1,pure:!y,fn:function(e,r,n){var t=String(y?n.a:m(e));yr(r,U(S,t)?t:'__',e,n)}})];else if(x){var M=je({});M.type='shape';var j,A=[];e(m,(function(e,r){if(_(e)){j=1,$(A,r),k.add(e);var n=nr(e,[],[ke(M),we((function(e,n,t){return t.a[r]=e}))]);if(L(e)){M.current[r]=e.getState();var t=C(e);Oe(M,{from:t,field:r,type:'field'}),s('splitMatchStore',t,n)}}})),j&&s('splitBase',M),w=[j&&ke(M,0,1),Se((function(e,r,n){for(var t=0;t<S.length;t++){var a=S[t];if(U(A,a)?n.a[a]:m[a](e))return void yr(r,a,e,n)}yr(r,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');var O=a({meta:{op:i},parent:t?[]:v,scope:r,node:w,family:{owners:Array.from(k)},regional:1});if(t&&mr(i,t,v,null,O,null,i,g,0,0,0),!h)return r},exports.step=Me,exports.version="22.8.3",exports.withFactory=function(e){var r=e.sid,n=e.name,i=e.loc,o=e.method,u=e.fn;return t(a({meta:{sidRoot:te(r),sid:r,name:n,loc:i,method:o,type:'factory'}}),u)},exports.withRegion=t; | ||
//# sourceMappingURL=compat.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e,t){for(let r in e)t(e[r],r)}function t(e,t){e.forEach(t)}function r(e,t){if(!e)throw Error(t)}function a(e,t){let r=M(e).meta||{};Z={id:M(e).id,parent:Z,value:e,template:r.template||te(),sidRoot:r.sidRoot||Z&&Z.sidRoot,meta:r};try{return t()}finally{ee('region'),Z=O(Z)}}function n({node:e=[],from:r,source:a,parent:n=r||a,to:i,target:o,child:s=i||o,scope:l={},meta:d={},family:f={type:'regular'},regional:c}={}){let u=ne(n),p=ne(f.links),m=ne(f.owners),g=[];t(e,(e=>e&&H(g,e)));let h={id:X(),seq:g,next:ne(s),meta:d,scope:l,family:{type:f.type||"crosslink",links:p,owners:m}};return t(p,(e=>H($(e),h))),t(m,(e=>H(j(e),h))),t(u,(e=>H(e.next,h))),c&&Z&&ae(C(Z),[h]),h}function i(e,r,a){let n,i=Be,o=null,s=De;if(e.target&&(r=e.params,a=e.defer,n=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),s=N(e)||s,e=e.target),s&&De&&s!==De&&(De=null),Array.isArray(e))for(let t=0;t<e.length;t++)Ie('pure',i,M(e[t]),o,r[t],s,n);else Ie('pure',i,M(e),o,r,s,n);if(a&&!Ee)return;let l,d,f,c,u,p,m={isRoot:Ee,currentPage:Be,scope:De,isWatch:_e,isPure:Pe};Ee=0;e:for(;c=Ne();){let{idx:e,stack:r,type:a}=c;f=r.node,Be=u=r.page,De=N(r),u?p=u.reg:De&&(p=De.reg);let n=!!u,i=!!De,o={fail:0,scope:f.scope};l=d=0;for(let t=e;t<f.seq.length&&!l;t++){let s=f.seq[t];if(s.order){let{priority:n,barrierID:i}=s.order,o=i?u?`${u.fullID}_${i}`:i:0;if(t!==e||a!==n){i?Re.has(o)||(Re.add(o),qe(t,r,n,i)):qe(t,r,n);continue e}i&&Re.delete(o)}switch(s.type){case'mov':{let e,t=s.data;switch(t.from){case S:e=C(r);break;case"a":case'b':e=r[t.from];break;case"value":e=t.store;break;case"store":if(p&&!p[t.store.id])if(n){let e=We(u,t.store.id);r.page=u=e,e?p=e.reg:i?(Ve(De,t.store,0,1,t.softRead),p=De.reg):p=void 0}else i&&Ve(De,t.store,0,1,t.softRead);e=$e(p&&p[t.store.id]||t.store)}switch(t.to){case S:r.value=e;break;case"a":case'b':r[t.to]=e;break;case"store":He(u,De,f,t.target).current=e}break}case'compute':let e=s.data;if(e.fn){_e='watch'===I(f,'op'),Pe=e.pure;let t=e.safe?(0,e.fn)(C(r),o.scope,r):Je(o,e.fn,r);e.filter?d=!t:r.value=t,_e=m.isWatch,Pe=m.isPure}}l=o.fail||d}if(Ge&&Ge(r,o),!l){let e=C(r),a=N(r);if(t(f.next,(t=>{Ie('child',u,t,r,e,a)})),a){I(f,'needFxCounter')&&Ie('child',u,a.fxCount,r,e,a),I(f,'storeChange')&&Ie('child',u,a.storeChange,r,e,a),I(f,'warnSerialize')&&Ie('child',u,a.warnSerializeNode,r,e,a);let n=a.additionalLinks[f.id];n&&t(n,(t=>{Ie('child',u,t,r,e,a)}))}}}Ee=m.isRoot,Be=m.currentPage,De=N(m)}function o(t,r="combine"){let a=r+'(',n='',i=0;return e(t,(e=>{i<25&&(null!=e&&(a+=n,a+=R(e)?F(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function s(e,t){let r,a,n=e;if(t){let n=F(t);0===e.length?(r=n.path,a=n.fullName):(r=n.path.concat([e]),a=0===n.fullName.length?e:n.fullName+'/'+e)}else r=0===e.length?[]:[e],a=e;return{shortName:n,fullName:a,path:r}}function l(e,t){let r=t?e:e[0];le(r);let a=r.or,n=r.and;if(n){let r=t?n:n[0];if(ie(r)&&'and'in r){let r=l(n,t);e=r[0],a={...a,...r[1]}}else e=n}return[e,a]}function d(e,...t){let r=te();if(r){let a=r.handlers[e];if(a)return a(r,...t)}}function f(e,t){let r=Ke({or:t,and:'string'==typeof e?{name:e}:e}),a=(e,...t)=>(U(!I(a,'derived'),'call of derived event','createEvent'),U(!Pe,'unit call from pure function','operators like sample'),Be?((e,t,r,a)=>{let n=Be,i=null;if(t)for(i=Be;i&&i.template!==t;)i=O(i);Te(i);let o=e.create(r,a);return Te(n),o})(a,o,e,t):a.create(e,t)),o=te(),s=Object.assign(a,{graphite:n({meta:nt(r.actualOp||"event",a,r),regional:1}),create:e=>(i({target:a,params:e,scope:De}),e),watch:e=>rt(a,e),map:e=>ot(a,w,e,[we()]),filter:e=>ot(a,"filter",e.fn?e:e.fn,[we(me,1)]),filterMap:e=>ot(a,'filterMap',e,[we(),xe((e=>!se(e)),1)]),prepend(e){let t=f('* \u2192 '+a.shortName,{parent:O(a)});return d('eventPrepend',M(t)),tt(t,a,[we()],'prepend',e),at(a,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(s),ee(s.graphite),s}function c(e,a,n,i){return fe(n,a,'first argument'),r(oe(i),'second argument should be a function'),U(!I(e,'derived'),`${a} in derived store`,`${a} in store created via createStore`),t(Array.isArray(n)?n:[n],(t=>{e.off(t),A(e).set(t,et(st(t,e,'on',pe,i)))})),e}function u(e,a){let o=Ke(a),s=Me(e),l=f({named:'updates',derived:1});d('storeBase',s);let p=s.id,m={subscribers:new Map,updates:l,defaultState:e,stateRef:s,getState(){let e,t=s;if(Be){let t=Be;for(;t&&!t.reg[p];)t=O(t);t&&(e=t)}return!e&&De&&(Ve(De,s,1),e=De),e&&(t=e.reg[p]),$e(t)},setState:e=>i({target:m,params:e,defer:1,scope:De}),reset:(...e)=>(t(e,(e=>c(m,'.reset',e,(()=>m.defaultState)))),m),on:(e,t)=>c(m,'.on',e,t),off(e){let t=A(m).get(e);return t&&(t(),A(m).delete(e)),m},map(e,t){let r,a;ie(e)&&(r=e,e=e.fn),U(se(t),'second argument of store.map','updateFilter');let n=m.getState();te()?a=null:se(n)||(a=e(n,t));let i=u(a,{name:`${m.shortName} \u2192 *`,derived:1,and:r}),o=st(m,i,w,ue,e);return je(z(i),{type:w,fn:e,from:s}),z(i).noInit=1,d('storeMap',s,o),i},watch(e,t){if(!t||!R(e)){let t=rt(m,e);return d('storeWatch',s,e)||e(m.getState()),t}return r(oe(t),'second argument should be a function'),e.watch((e=>t(m.getState(),e)))}},g=nt("store",m,o),h=m.defaultConfig.updateFilter;m.graphite=n({scope:{state:s,fn:h},node:[xe(((e,t,r)=>(r.scope&&!r.scope.reg[s.id]&&(r.b=1),e))),ke(s),xe(((e,t,{a:r,b:a})=>!se(e)&&(e!==r||a)),1),h&&we(ue,1),ye({from:S,target:s})],child:l,meta:{...g,defaultState:e},regional:1});let y=I(m,'serialize'),v=I(m,'derived'),b='ignore'===y,x=I(m,'sid');return x&&(q(m,'storeChange',1),s.sid=x),x||b||v||q(m,'warnSerialize',1),r(v||!se(e),"current state can't be undefined, use null instead"),ae(m,[l]),null!=o&&o.domain&&o.domain.hooks.store(m),v||(m.reinit=f({named:'reinit'}),m.reset(m.reinit)),s.meta=m.graphite.meta,ee(m.graphite),m}function p(...e){let t,a,n;[e,n]=l(e);let i,o,s,d=e[e.length-1];if(oe(d)?(a=e.slice(0,-1),t=d):a=e,1===a.length){let e=a[0];E(e)||(i=e,o=1)}if(!o&&(i=a,t)){s=1;let e=t;t=t=>e(...t)}return r(ie(i),'shape should be an object'),lt(Array.isArray(i),!s,i,n,t)}function m(){let e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function g(e,t={}){let a=Ke(oe(e)?{handler:e}:e,t),o=f(oe(e)?{handler:e}:e,{...t,actualOp:"effect"}),s=M(o);q(s,'op',o.kind="effect"),o.use=e=>(r(oe(e),'.use argument should be a function'),h.scope.handler=e,o),o.use.getCurrent=()=>h.scope.handler;let l=o.finally=f({named:'finally',derived:1}),d=o.done=l.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),c=o.fail=l.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),p=o.doneData=d.map({named:'doneData',fn:({result:e})=>e}),g=o.failData=c.map({named:'failData',fn:({error:e})=>e}),h=n({scope:{handler:o.defaultConfig.handler||(()=>r(0,`no handler used in ${o.getType()}`))},node:[xe(((e,t,r)=>{let a=t.handler,n=N(r);if(n){let e=o.sid?n.handlers.sidMap[o.sid]:n.handlers.unitMap.get(o);e&&(a=e)}return e.handler=a,e}),0,1),xe((({params:e,req:t,handler:r,args:a=[e]},n,i)=>{let o=ft(i),s=ct(e,t,1,l,i,o),d=ct(e,t,0,l,i,o),[f,c]=dt(r,d,a);f&&(ie(c)&&oe(c.then)?c.then(s,d):s(c))}),0,1)],meta:{op:'fx',fx:'runner'}});s.scope.runner=h,H(s.seq,xe(((e,{runner:t},r)=>{let a=O(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:Y()}),i({target:t,params:a,defer:1,scope:N(r),meta:r.meta}),a.params}),0,1)),o.create=e=>{let t=m(),r={params:e,req:t};if(De&&!_e){let e=De;t.req.finally((()=>{Le(e)})).catch((()=>{}))}return i({target:o,params:r,scope:De}),t.req};let y=o.inFlight=u(0,{serialize:'ignore',named:(I(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(e=>e+1)).on(l,(e=>e-1)).map({fn:e=>e,named:'inFlight'});q(l,'needFxCounter','dec'),q(o,'needFxCounter',1);let v=o.pending=y.map({fn:e=>e>0,named:'pending'});return ae(o,[l,d,c,p,g,v,y]),null!=a&&a.domain&&a.domain.hooks.effect(o),o}function h(e,t){fe(e,'merge','first argument');let r=f({name:o(e,'merge'),derived:1,and:t});return tt(e,r,[],'merge'),r}function y(e,a){let n=0;return t(pt,(t=>{t in e&&(r(null!=e[t],mt(a,t)),n=1)})),n}function v(e,r,a){let n=[];(function e(i){W(n,i)||(H(n,i),"store"===I(i,'op')&&(a||I(i,'sid'))&&r(i,I(i,'sid')),t(i.next,e),t($(i),e),t(j(i),e))})(e)}function b(e,a){let n=Array.isArray(e)?new Map(e):e,i=new Map;if(n instanceof Map){let e={};return t(n,((t,n)=>{r(R(n),'Map key should be a unit'),a&&a(n,t),n.sid?(r(!(n.sid in e),'duplicate sid found'),e[n.sid]=t):i.set(n,t)})),{sidMap:e,unitMap:i}}return{sidMap:n,unitMap:i}}function x(e){let t=()=>e();return t.unsubscribe=()=>e(),t}Object.defineProperty(exports,'__esModule',{value:1});let k='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',w='map',S='stack',M=e=>e.graphite||e,$=e=>e.family.owners,j=e=>e.family.links,z=e=>e.stateRef,C=e=>e.value,A=e=>e.subscribers,O=e=>e.parent,N=e=>e.scope,I=(e,t)=>M(e).meta[t],q=(e,t,r)=>M(e).meta[t]=r,F=e=>e.compositeName,R=e=>(oe(e)||ie(e))&&'kind'in e;const D=e=>t=>R(t)&&t.kind===e;let E=D("store"),_=D("event"),P=D("effect"),B=D("domain"),L=D("scope");var T={__proto__:null,unit:R,store:E,event:_,effect:P,domain:B,scope:L,attached:e=>P(e)&&1==I(e,'attached')};let W=(e,t)=>e.includes(t),G=(e,t)=>{let r=e.indexOf(t);-1!==r&&e.splice(r,1)},H=(e,t)=>e.push(t),U=(e,t,r)=>!e&&console.error(`${t} is deprecated${r?`, use ${r} instead`:''}`);const V=()=>{let e=0;return()=>""+ ++e};let J,K=V(),Q=V(),X=V(),Y=V(),Z=null,ee=e=>{J&&J(e,Z)},te=()=>Z&&Z.template,re=e=>(e&&Z&&Z.sidRoot&&(e=`${Z.sidRoot}|${e}`),e),ae=(e,r)=>{let a=M(e);t(r,(e=>{let t=M(e);"domain"!==a.family.type&&(t.family.type="crosslink"),H($(t),a),H(j(a),t)}))},ne=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(M),ie=e=>'object'==typeof e&&null!==e,oe=e=>'function'==typeof e,se=e=>void 0===e,le=e=>r(ie(e)||oe(e),'expect first argument be an object');const de=(e,t,a,n)=>r(!(!ie(e)&&!oe(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${a} to be a unit (store, event or effect)${n}`);let fe=(e,r,a)=>{Array.isArray(e)?t(e,((e,t)=>de(e,r,`${t} item of ${a}`,''))):de(e,r,a,' or array of units')},ce=(e,r,a="target")=>t(ne(r),(t=>U(!I(t,'derived'),`${e}: derived unit in "${a}"`,"createEvent/createStore"))),ue=(e,{fn:t},{a:r})=>t(e,r),pe=(e,{fn:t},{a:r})=>t(r,e),me=(e,{fn:t})=>t(e);const ge=(e,t,r,a)=>{let n={id:Q(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++he)),n};let he=0,ye=({from:e="store",store:t,target:r,to:a=(r?"store":S),batch:n,priority:i})=>ge('mov',{from:e,store:t,to:a,target:r},i,n),ve=({fn:e,batch:t,priority:r,safe:a=0,filter:n=0,pure:i=0})=>ge('compute',{fn:e,safe:a,filter:n,pure:i},r,t),be=({fn:e})=>ve({fn:e,priority:"effect"}),xe=(e,t,r)=>ve({fn:e,safe:1,filter:t,priority:r&&"effect"}),ke=(e,t,r)=>ye({store:e,to:t?S:"a",priority:r&&"sampler",batch:1}),we=(e=me,t)=>ve({fn:e,pure:1,filter:t}),Se={mov:ye,compute:ve,filter:({fn:e,pure:t})=>ve({fn:e,filter:1,pure:t}),run:be},Me=e=>({id:Q(),current:e}),$e=({current:e})=>e,je=(e,t)=>{e.before||(e.before=[]),H(e.before,t)},ze=null;const Ce=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Fe(e.v.type)>Fe(t.v.type))&&(r=e,e=t,t=r),r=Ce(e.r,t),e.r=e.l,e.l=r,e},Ae=[];let Oe=0;for(;Oe<6;)H(Ae,{first:null,last:null,size:0}),Oe+=1;const Ne=()=>{for(let e=0;e<6;e++){let t=Ae[e];if(t.size>0){if(3===e||4===e){t.size-=1;let e=ze.v;return ze=Ce(ze.l,ze.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},Ie=(e,t,r,a,n,i,o)=>qe(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),qe=(e,t,r,a=0)=>{let n=Fe(r),i=Ae[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?ze=Ce(ze,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Fe=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case"barrier":return 3;case"sampler":return 4;case"effect":return 5;default:return-1}},Re=new Set;let De,Ee=1,_e=0,Pe=0,Be=null,Le=e=>{De=e},Te=e=>{Be=e};const We=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=O(e);if(e)return e}return null};let Ge,He=(e,t,r,a,n)=>{let i=We(e,a.id);return i?i.reg[a.id]:t?(Ve(t,a,n),t.reg[a.id]):a};const Ue=e=>e;let Ve=(e,r,a,n,i)=>{var o;let s=e.reg,l=r.sid,d=null==r||null===(o=r.meta)||void 0===o?void 0:o.serialize;if(s[r.id])return;let f={id:r.id,current:r.current,meta:r.meta};if(l&&l in e.values.sidMap&&!(l in e.sidIdMap))f.current=(e.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||Ue)(e.values.sidMap[l]);else if(f.id in e.values.idMap)f.current=e.values.idMap[f.id];else if(r.before&&!i){let i=0,o=a||!r.noInit||n;t(r.before,(t=>{switch(t.type){case w:{let r=t.from;if(r||t.fn){r&&Ve(e,r,a,n);let i=r&&s[r.id].current;o&&(f.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,f.current=Array.isArray(f.current)?[...f.current]:{...f.current}),Ve(e,t.from,a,n),o&&(f.current[t.field]=s[s[t.from.id].id].current)}}))}l&&(e.sidIdMap[l]=r.id),s[r.id]=f};const Je=(e,t,r)=>{try{return t(C(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}};let Ke=(t,r={})=>(ie(t)&&(Ke(t.or,r),e(t,((e,t)=>{se(e)||'or'===t||'and'===t||(r[t]=e)})),Ke(t.and,r)),r);const Qe=(e,t)=>{G(e.next,t),G($(e),t),G(j(e),t)},Xe=(e,t,r)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let n=j(e);for(;a=n.pop();)Qe(a,e),(t||r&&'sample'!==I(e,'op')||"crosslink"===a.family.type)&&Xe(a,t,'on'!==I(a,'op')&&r);for(n=$(e);a=n.pop();)Qe(a,e),r&&"crosslink"===a.family.type&&Xe(a,t,'on'!==I(a,'op')&&r)},Ye=e=>e.clear();let Ze=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),E(e))Ye(A(e));else if(B(e)){r=1;let t=e.history;Ye(t.events),Ye(t.effects),Ye(t.stores),Ye(t.domains)}Xe(M(e),!!t,r)},et=e=>{let t=()=>Ze(e);return t.unsubscribe=t,t},tt=(e,t,r,a,i)=>n({node:r,parent:e,child:t,scope:{fn:i},meta:{op:a},family:{owners:[e,t],links:t},regional:1}),rt=(e,t)=>(r(oe(t),'.watch argument should be a function'),et(n({scope:{fn:t},node:[be({fn:me})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),at=(e,t,r="event")=>{O(e)&&O(e).hooks[r](t)},nt=(e,t,r)=>{let a=Ke(r),n="domain"===e,i=K(),{sid:o=null,named:l=null,domain:d=null,parent:f=d}=a,c=l||a.name||(n?'':i),u=s(c,f),p={op:t.kind=e,name:t.shortName=c,sid:t.sid=re(o),named:l,unitId:t.id=i,serialize:a.serialize,derived:a.derived,config:a};if(t.parent=f,t.compositeName=u,t.defaultConfig=a,t.thru=e=>(U(0,'thru','js pipe'),e(t)),t.getType=()=>u.fullName,!n){t.subscribe=e=>(le(e),t.watch(oe(e)?e:t=>e.next&&e.next(t))),t[k]=()=>t;let e=te();e&&(p.nativeTemplate=e)}return p};const ot=(e,t,r,a)=>{let n;ie(r)&&(n=r,r=r.fn);let i=f({name:`${e.shortName} \u2192 *`,derived:1,and:n});return tt(e,i,a,t,r),i},st=(e,t,r,a,n)=>{let i=z(t),o=ye({store:i,to:"a",priority:'read'});r===w&&(o.data.softRead=1);let s=[o,we(a)];return d('storeOnMap',i,s,E(e)&&z(e)),tt(e,t,s,r,n)},lt=(t,a,n,i,s)=>{let l=t?e=>[...e]:e=>({...e}),f=t?[]:{},c=l(f),p=Me(c),m=Me(1);p.type=t?'list':'shape',p.noInit=1,d('combineBase',p,m);let g=u(c,{name:o(n),derived:1,and:i}),h=z(g);h.noInit=1,q(g,'isCombine',1);let y=ke(p);y.order={priority:'barrier'};let v=[xe(((e,t,r)=>(r.scope&&!r.scope.reg[p.id]&&(r.c=1),e))),y,ye({store:m,to:'b'}),xe(((e,{key:t},r)=>{if(r.c||e!==r.a[t])return a&&r.b&&(r.a=l(r.a)),r.a[t]=e,1}),1),ye({from:"a",target:p}),ye({from:"value",store:0,target:m}),ye({from:"value",store:1,target:m,priority:"barrier",batch:1}),ke(p,1),s&&we()];return e(n,((e,t)=>{if(!E(e))return r(!R(e)&&!se(e),`combine expects a store in a field ${t}`),void(c[t]=f[t]=e);f[t]=e.defaultState,c[t]=e.getState();let a=tt(e,g,v,'combine',s);a.scope.key=t;let n=z(e);je(p,{type:'field',field:t,from:n}),d('combineField',n,a)})),g.defaultShape=n,je(h,{type:w,from:p,fn:s}),te()||(g.defaultState=s?h.current=s(c):f),g};let dt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},ft=e=>{let t=N(e),r={ref:t};return t&&H(t.activeEffects,r),r},ct=(e,t,r,a,n,o)=>s=>{o.ref&&G(o.ref.activeEffects,o),i({target:[a,ut],params:[r?{status:'done',params:e,result:s}:{status:'fail',params:e,error:s},{value:s,fn:r?t.rs:t.rj}],defer:1,page:n.page,scope:o.ref,meta:n.meta})};const ut=n({node:[be({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),pt=['source','clock','target'],mt=(e,t)=>e+`: ${t} should be defined`;let gt=(e,t,a,n,i,o,s,l,c,m,g,y)=>{let v=!!i;r(!se(a)||!se(t),mt(e,'either source or clock'));let b=0;se(a)?b=1:R(a)||(a=p(a)),se(t)?t=a:(fe(t,e,'clock'),Array.isArray(t)&&(t=h(t))),b&&(a=t),l||s||(s=a.shortName);let x='none';(g||n)&&(R(n)?x='unit':(r(oe(n),'`filter` should be function or unit'),x='fn')),i?(fe(i,e,'target'),ce(e,i)):'none'===x&&m&&E(a)&&E(t)?i=u(o?o($e(z(a)),$e(z(t))):$e(z(a)),{name:s,sid:y,or:l}):(i=f({name:s,derived:1,or:l}),d('sampleTarget',M(i)));let k=Me(),w=[];if('unit'===x){let[r,a]=yt(n,i,t,k,e);w=[...ht(a),...ht(r)]}let[$,j]=yt(a,i,t,k,e),C=tt(t,i,[d('sampleSourceLoader'),ye({from:S,target:k}),...ht(j),ke($,1,c),...w,ke(k),'fn'===x&&we(((e,t,{a:r})=>n(e,r)),1),o&&we(ue),d('sampleSourceUpward',v)],e,o);return ae(a,[C]),Object.assign(C.meta,l,{joint:1}),i};const ht=e=>[ke(e),xe(((e,t,{a:r})=>r),1)],yt=(e,t,r,a,i)=>{let o=E(e),s=o?z(e):Me(),l=Me(o);return o||n({parent:e,node:[ye({from:S,target:s}),ye({from:"value",store:1,target:l})],family:{owners:[e,t,r],links:t},meta:{op:i},regional:1}),d('sampleSource',l,s,a),[s,l]},vt=(e,t,r,a)=>{let n=e[t];n&&i({target:n,params:Array.isArray(n)?n.map((()=>r)):r,defer:1,stack:a})},bt=e=>e;exports.allSettled=(e,{scope:t,params:r}={})=>{if(!R(e))return Promise.reject(new Error('first argument should be unit'));if(!(P(e)||_(e)||E(e)||L(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));L(e)&&(t=e);let a=m();a.parentFork=De;let{fxCount:n}=t;H(n.scope.defers,a);let o=[],s=[];return L(e)||(H(o,e),H(s,P(e)?{params:r,req:{rs(e){a.value={status:'done',value:e}},rj(e){a.value={status:'fail',value:e}}}}:r)),H(o,n),H(s,null),i({target:o,params:s,scope:t}),a.req},exports.attach=e=>{let t;[e,t]=l(e,1);let{source:r,effect:a,mapParams:n}=e,o=g(e,t);q(o,'attached',1);let d,{runner:f}=M(o).scope,c=xe(((e,t,a)=>{let s,{params:l,req:d,handler:f}=e,c=o.finally,u=ft(a),p=ct(l,d,0,c,a,u),m=a.a,g=P(f),h=1;if(n?[h,s]=dt(n,p,[l,m]):s=r&&g?m:l,h){if(!g)return e.args=[m,s],1;i({target:f,params:{params:s,req:{rs:ct(l,d,1,c,a,u),rj:p}},page:a.page,defer:1,meta:a.meta})}}),1,1);if(r){let e;E(r)?(e=r,ae(e,[o])):(e=p(r),ae(o,[e])),d=[ke(z(e)),c]}else d=[c];f.seq.splice(1,0,...d),o.use(a);let u=O(a);return u&&(Object.assign(F(o),s(o.shortName,u)),o.defaultConfig.parent=u),at(a,o,"effect"),o},exports.clearNode=Ze,exports.combine=p,exports.createApi=(...t)=>{let[[r,a],n]=l(t),i={};return e(a,((e,t)=>{let a=i[t]=f(t,{parent:O(r),config:n});r.on(a,e),at(r,a)})),i},exports.createDomain=function r(a,o){let s=Ke({or:o,and:'string'==typeof a?{name:a}:a}),l=n({family:{type:"domain"},regional:1,parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent)}),d={history:{},graphite:l,hooks:{}};l.meta=nt("domain",d,{parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent),or:s}),e({Event:f,Effect:g,Store:u,Domain:r},((e,r)=>{let a=r.toLowerCase(),n=f({named:`on${r}`});d.hooks[a]=n;let o=new Set;d.history[`${a}s`]=o,n.create=e=>(i(n,e),e),H(M(n).seq,xe(((e,t,r)=>(r.scope=null,e)))),n.watch((e=>{ae(d,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),O(e)||(e.parent=d)})),ae(d,[n]),d[`onCreate${r}`]=e=>(t(o,e),n.watch(e)),d[`create${r}`]=d[a]=(t,r)=>{let a=Ke({and:r,or:t});return null!=a&&a.domain?e(t,r):n(e(t,{parent:d,or:a}))}}));let c=O(d);return c&&e(d.hooks,((e,t)=>tt(e,c.hooks[t]))),null!=s&&s.domain&&s.domain.hooks.domain(d),d},exports.createEffect=g,exports.createEvent=f,exports.createNode=n,exports.createStore=u,exports.createStoreObject=(...e)=>(U(0,'createStoreObject','combine'),p(...e)),exports.createWatch=({unit:e,fn:t,scope:r})=>{let a=[Se.run({fn:e=>t(e)})];if(r){let t=n({node:a}),i=e.graphite.id,o=r.additionalLinks,s=o[i]||[];return o[i]=s,s.push(t),x((()=>{let e=s.indexOf(t);-1!==e&&s.splice(e,1),Ze(t)}))}{let t=n({node:a,parent:[e],family:{owners:e}});return x((()=>{Ze(t)}))}},exports.fork=(e,a)=>{let i,o=e;B(e)&&(i=e,o=a);let s=(e=>{let r=n({scope:{defers:[],inFlight:0,fxID:0},node:[xe(((e,t,r)=>{O(r)?'dec'===I(O(r).node,'needFxCounter')?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),ve({priority:"sampler",batch:1}),xe(((e,r)=>{let{defers:a,fxID:n}=r;r.inFlight>0||0===a.length||Promise.resolve().then((()=>{r.fxID===n&&t(a.splice(0,a.length),(e=>{Le(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),a=n({node:[xe(((e,t,r)=>{let a=O(r);if(a){let t=a.node;if(!I(t,'isCombine')||O(a)&&'combine'!==I(O(a).node,'op')){let a=N(r),n=t.scope.state.id,i=I(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=I(t,'serialize');o&&a.sidSerializeSettings.set(i,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),i=n({node:[xe(((e,t,r)=>{let a=N(r);if(a){let e=O(r);e&&(!I(e.node,'isCombine')||O(e)&&'combine'!==I(O(e).node,'op'))&&(a.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return He(Be,o,null,e).current;let t=M(e);return He(Be,o,t,t.scope.state,1).current},kind:"scope",graphite:n({family:{type:"domain",links:[r,a,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:r}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:r,storeChange:a,warnSerializeNode:i,activeEffects:[]};return o})(i);if(o){let e=o.scope;if(e){let r=e.activeEffects;e.activeEffects=[],s.activeEffects=r,t(r,(e=>e.ref=s))}if(o.values){let{sidMap:e,unitMap:a}=b(o.values,(e=>r(E(e),'Values map can contain only stores as keys')));Object.assign(s.values.sidMap,e),t(a,((e,t)=>{s.values.idMap[t.stateRef.id]=e})),s.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map)}o.handlers&&(s.handlers=b(o.handlers,(e=>r(P(e),"Handlers map can contain only effects as keys"))))}return s},exports.forward=e=>{let t='forward',[{from:r,to:a},i]=l(e,1);return fe(r,t,'"from"'),fe(a,t,'"to"'),ce(t,a,'to'),et(n({parent:r,child:a,meta:{op:t,config:i},family:{},regional:1}))},exports.fromObservable=e=>{le(e);let t=k in e?e[k]():e;r(t.subscribe,'expect observable to have .subscribe');let a=f(),n=et(a);return t.subscribe({next:a,error:n,complete:n}),a},exports.guard=(...e)=>{let[[t,r],a]=l(e);return r||(r=t,t=r.source),y(r,'guard'),gt('guard',r.clock,t,r.filter,r.target,null,r.name,a,!r.greedy,0,1)},exports.hydrate=(e,{values:a})=>{r(ie(a),'values property should be an object');let{sidMap:n,unitMap:o}=b(a),s=Object.getOwnPropertyNames(n),l={};t(o,((e,t)=>{l[t.stateRef.id]=t}));let d,f,c,u=[],p=[];L(e)?(d=e,c=1,r(d.cloneOf,'scope should be created from domain'),f=M(d.cloneOf)):B(e)?f=M(e):r(0,'first argument of hydrate should be domain or scope'),v(f,((e,t)=>{if(t&&W(s,t)){H(u,e);let r=I(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),H(p,n[t])}else e.scope.state.id in l&&(H(u,e),H(p,o.get(l[e.scope.state.id])))}),1),i({target:u,params:p,scope:d}),c&&Object.assign(d.values.sidMap,n)},exports.is=T,exports.launch=i,exports.merge=h,exports.restore=(t,r,a)=>{if(E(t))return U(0,'restore($store)'),t;if(_(t)||P(t)){let e=O(t),n=u(r,{parent:e,name:t.shortName,and:a});return tt(P(t)?t.doneData:t,n),e&&e.hooks.store(n),n}let n=Array.isArray(t)?[]:{};return e(t,((e,t)=>n[t]=E(e)?e:u(e,{name:t}))),n},exports.sample=(...e)=>{let t,r,a,n,[[i,o,s],d]=l(e),f=1;return se(o)&&ie(i)&&y(i,"sample")&&(o=i.clock,s=i.fn,f=!i.greedy,n=i.filter,t=i.target,r=i.name,a=i.sid,i=i.source),gt("sample",o,i,n,t,s,r,d,f,1,0,a)},exports.scopeBind=(e,{scope:t,safe:a}={})=>{r(t||De||a,'scopeBind cannot be called outside of forked .watch');let n=t||De;return P(e)?t=>{let r=m();return i({target:e,params:{params:t,req:r},scope:n}),r.req}:t=>(i({target:e,params:t,scope:n}),t)},exports.serialize=(t,a={})=>{t.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted');let n=a.ignore?a.ignore.map((({sid:e})=>e)):[],i={};return e(t.values.sidMap,((e,r)=>{var a;if(W(n,r))return;let o=t.sidIdMap[r],s=null!==(a=t.sidSerializeSettings.get(r))&&void 0!==a?a:{ignore:0,write:bt};s.ignore||(i[r]=(0,s.write)(o&&o in t.reg?t.reg[o].current:e))})),'onlyChanges'in a&&!a.onlyChanges&&(r(t.cloneOf,'scope should be created from domain'),v(M(t.cloneOf),((e,r)=>{r in i||W(n,r)||I(e,'isCombine')||'ignore'===I(e,'serialize')||(i[r]=t.getState(e))}))),i},exports.setGraphInspector=e=>{J=e},exports.setInspector=e=>{Ge=e},exports.setStoreName=(e,t)=>{e.shortName=t,Object.assign(F(e),s(t,O(e)))},exports.split=(...t)=>{let a,i,o='split',[[s,c],u]=l(t),p=!c;p&&(a=s.cases,c=s.match,i=s.clock,s=s.source);let m=E(c),g=!R(c)&&oe(c),h=!m&&!g&&ie(c);r(R(s),'source must be a unit'),a||(a={}),p?e(a,((e,t)=>ce(o,e,`cases.${t}`))):(r(h,'match should be an object'),e(c,((e,t)=>a[t]=f({derived:1,named:`cases.${t}`,and:u}))),a.__=f({derived:1,named:'cases.__',and:u}));let y,v=new Set([].concat(s,i||[],Object.values(a))),b=Object.keys(m||g?a:c);if(m||g)m&&v.add(c),y=[m&&ke(z(c),0,1),ve({safe:m,filter:1,pure:!m,fn(e,t,r){let a=String(m?r.a:c(e));vt(t,W(b,a)?a:'__',e,r)}})];else if(h){let t=Me({});t.type='shape';let r,a=[];e(c,((e,n)=>{if(R(e)){r=1,H(a,n),v.add(e);let i=tt(e,[],[ke(t),xe(((e,t,{a:r})=>r[n]=e))]);if(E(e)){t.current[n]=e.getState();let r=z(e);je(t,{from:r,field:n,type:'field'}),d('splitMatchStore',r,i)}}})),r&&d('splitBase',t),y=[r&&ke(t,0,1),we(((e,t,r)=>{for(let n=0;n<b.length;n++){let i=b[n];if(W(a,i)?r.a[i]:c[i](e))return void vt(t,i,e,r)}vt(t,'__',e,r)}),1)]}else r(0,'expect match to be unit, function or object');let x=n({meta:{op:o},parent:i?[]:s,scope:a,node:y,family:{owners:Array.from(v)},regional:1});if(i&>(o,i,s,null,x,null,o,u,0,0,0),!p)return a},exports.step=Se,exports.version="22.8.2",exports.withFactory=({sid:e,name:t,loc:r,method:i,fn:o})=>a(n({meta:{sidRoot:re(e),sid:e,name:t,loc:r,method:i,type:'factory'}}),o),exports.withRegion=a; | ||
function e(e,t){for(let r in e)t(e[r],r)}function t(e,t){e.forEach(t)}function r(e,t){if(!e)throw Error(t)}function a(e,t){let r=M(e).meta||{};Z={id:M(e).id,parent:Z,value:e,template:r.template||te(),sidRoot:r.sidRoot||Z&&Z.sidRoot,meta:r};try{return t()}finally{ee('region'),Z=O(Z)}}function n({node:e=[],from:r,source:a,parent:n=r||a,to:i,target:o,child:s=i||o,scope:l={},meta:d={},family:f={type:'regular'},regional:c}={}){let u=ne(n),p=ne(f.links),m=ne(f.owners),g=[];t(e,(e=>e&&H(g,e)));let h={id:X(),seq:g,next:ne(s),meta:d,scope:l,family:{type:f.type||"crosslink",links:p,owners:m}};return t(p,(e=>H($(e),h))),t(m,(e=>H(j(e),h))),t(u,(e=>H(e.next,h))),c&&Z&&ae(C(Z),[h]),h}function i(e,r,a){let n,i=Be,o=null,s=De;if(e.target&&(r=e.params,a=e.defer,n=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),s=I(e)||s,e=e.target),s&&De&&s!==De&&(De=null),Array.isArray(e))for(let t=0;t<e.length;t++)Ne('pure',i,M(e[t]),o,r[t],s,n);else Ne('pure',i,M(e),o,r,s,n);if(a&&!Ee)return;let l,d,f,c,u,p,m={isRoot:Ee,currentPage:Be,scope:De,isWatch:_e,isPure:Pe};Ee=0;e:for(;c=Ie();){let{idx:e,stack:r,type:a}=c;f=r.node,Be=u=r.page,De=I(r),u?p=u.reg:De&&(p=De.reg);let n=!!u,i=!!De,o={fail:0,scope:f.scope};l=d=0;for(let t=e;t<f.seq.length&&!l;t++){let s=f.seq[t];if(s.order){let{priority:n,barrierID:i}=s.order,o=i?u?`${u.fullID}_${i}`:i:0;if(t!==e||a!==n){i?Re.has(o)||(Re.add(o),qe(t,r,n,i)):qe(t,r,n);continue e}i&&Re.delete(o)}switch(s.type){case'mov':{let e,t=s.data;switch(t.from){case S:e=C(r);break;case"a":case'b':e=r[t.from];break;case"value":e=t.store;break;case"store":if(p&&!p[t.store.id])if(n){let e=We(u,t.store.id);r.page=u=e,e?p=e.reg:i?(Ve(De,t.store,0,1,t.softRead),p=De.reg):p=void 0}else i&&Ve(De,t.store,0,1,t.softRead);e=$e(p&&p[t.store.id]||t.store)}switch(t.to){case S:r.value=e;break;case"a":case'b':r[t.to]=e;break;case"store":He(u,De,f,t.target).current=e}break}case'compute':let e=s.data;if(e.fn){_e='watch'===N(f,'op'),Pe=e.pure;let t=e.safe?(0,e.fn)(C(r),o.scope,r):Je(o,e.fn,r);e.filter?d=!t:r.value=t,_e=m.isWatch,Pe=m.isPure}}l=o.fail||d}if(Ge&&Ge(r,o),!l){let e=C(r),a=I(r);if(t(f.next,(t=>{Ne('child',u,t,r,e,a)})),a){N(f,'needFxCounter')&&Ne('child',u,a.fxCount,r,e,a),N(f,'storeChange')&&Ne('child',u,a.storeChange,r,e,a),N(f,'warnSerialize')&&Ne('child',u,a.warnSerializeNode,r,e,a);let n=a.additionalLinks[f.id];n&&t(n,(t=>{Ne('child',u,t,r,e,a)}))}}}Ee=m.isRoot,Be=m.currentPage,De=I(m)}function o(t,r="combine"){let a=r+'(',n='',i=0;return e(t,(e=>{i<25&&(null!=e&&(a+=n,a+=R(e)?F(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function s(e,t){let r,a,n=e;if(t){let n=F(t);0===e.length?(r=n.path,a=n.fullName):(r=n.path.concat([e]),a=0===n.fullName.length?e:n.fullName+'/'+e)}else r=0===e.length?[]:[e],a=e;return{shortName:n,fullName:a,path:r}}function l(e,t){let r=t?e:e[0];le(r);let a=r.or,n=r.and;if(n){let r=t?n:n[0];if(ie(r)&&'and'in r){let r=l(n,t);e=r[0],a={...a,...r[1]}}else e=n}return[e,a]}function d(e,...t){let r=te();if(r){let a=r.handlers[e];if(a)return a(r,...t)}}function f(e,t){let r=Ke({or:t,and:'string'==typeof e?{name:e}:e}),a=(e,...t)=>(U(!N(a,'derived'),'call of derived event','createEvent'),U(!Pe,'unit call from pure function','operators like sample'),Be?((e,t,r,a)=>{let n=Be,i=null;if(t)for(i=Be;i&&i.template!==t;)i=O(i);Te(i);let o=e.create(r,a);return Te(n),o})(a,o,e,t):a.create(e,t)),o=te(),s=Object.assign(a,{graphite:n({meta:nt(r.actualOp||"event",a,r),regional:1}),create:e=>(i({target:a,params:e,scope:De}),e),watch:e=>rt(a,e),map:e=>ot(a,w,e,[we()]),filter:e=>ot(a,"filter",e.fn?e:e.fn,[we(me,1)]),filterMap:e=>ot(a,'filterMap',e,[we(),xe((e=>!se(e)),1)]),prepend(e){let t=f('* \u2192 '+a.shortName,{parent:O(a)});return d('eventPrepend',M(t)),tt(t,a,[we()],'prepend',e),at(a,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(s),q(s,'id',s.graphite.id),ee(s.graphite),s}function c(e,a,n,i){return fe(n,a,'first argument'),r(oe(i),'second argument should be a function'),U(!N(e,'derived'),`${a} in derived store`,`${a} in store created via createStore`),t(Array.isArray(n)?n:[n],(t=>{e.off(t),A(e).set(t,et(st(t,e,'on',pe,i)))})),e}function u(e,a){let o=Ke(a),s=Me(e),l=f({named:'updates',derived:1});d('storeBase',s);let p=s.id,m={subscribers:new Map,updates:l,defaultState:e,stateRef:s,getState(){let e,t=s;if(Be){let t=Be;for(;t&&!t.reg[p];)t=O(t);t&&(e=t)}return!e&&De&&(Ve(De,s,1),e=De),e&&(t=e.reg[p]),$e(t)},setState:e=>i({target:m,params:e,defer:1,scope:De}),reset:(...e)=>(t(e,(e=>c(m,'.reset',e,(()=>m.defaultState)))),m),on:(e,t)=>c(m,'.on',e,t),off(e){let t=A(m).get(e);return t&&(t(),A(m).delete(e)),m},map(e,t){let r,a;ie(e)&&(r=e,e=e.fn),U(se(t),'second argument of store.map','updateFilter');let n=m.getState();te()?a=null:se(n)||(a=e(n,t));let i=u(a,{name:`${m.shortName} \u2192 *`,derived:1,and:r}),o=st(m,i,w,ue,e);return je(z(i),{type:w,fn:e,from:s}),z(i).noInit=1,d('storeMap',s,o),i},watch(e,t){if(!t||!R(e)){let t=rt(m,e);return d('storeWatch',s,e)||e(m.getState()),t}return r(oe(t),'second argument should be a function'),e.watch((e=>t(m.getState(),e)))}},g=nt("store",m,o),h=m.defaultConfig.updateFilter;m.graphite=n({scope:{state:s,fn:h},node:[xe(((e,t,r)=>(r.scope&&!r.scope.reg[s.id]&&(r.b=1),e))),ke(s),xe(((e,t,{a:r,b:a})=>!se(e)&&(e!==r||a)),1),h&&we(ue,1),ye({from:S,target:s})],child:l,meta:{...g,defaultState:e},regional:1}),q(m,'id',m.graphite.id),q(m,'rootStateRefId',p);let y=N(m,'serialize'),v=N(m,'derived'),b='ignore'===y,x=N(m,'sid');return x&&(q(m,'storeChange',1),s.sid=x),x||b||v||q(m,'warnSerialize',1),r(v||!se(e),"current state can't be undefined, use null instead"),ae(m,[l]),null!=o&&o.domain&&o.domain.hooks.store(m),v||(m.reinit=f({named:'reinit'}),m.reset(m.reinit)),s.meta=m.graphite.meta,ee(m.graphite),m}function p(...e){let t,a,n;[e,n]=l(e);let i,o,s,d=e[e.length-1];if(oe(d)?(a=e.slice(0,-1),t=d):a=e,1===a.length){let e=a[0];E(e)||(i=e,o=1)}if(!o&&(i=a,t)){s=1;let e=t;t=t=>e(...t)}return r(ie(i),'shape should be an object'),lt(Array.isArray(i),!s,i,n,t)}function m(){let e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function g(e,t={}){let a=Ke(oe(e)?{handler:e}:e,t),o=f(oe(e)?{handler:e}:e,{...t,actualOp:"effect"}),s=M(o);q(s,'op',o.kind="effect"),o.use=e=>(r(oe(e),'.use argument should be a function'),h.scope.handler=e,o),o.use.getCurrent=()=>h.scope.handler;let l=o.finally=f({named:'finally',derived:1}),d=o.done=l.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),c=o.fail=l.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),p=o.doneData=d.map({named:'doneData',fn:({result:e})=>e}),g=o.failData=c.map({named:'failData',fn:({error:e})=>e}),h=n({scope:{handler:o.defaultConfig.handler||(()=>r(0,`no handler used in ${o.getType()}`))},node:[xe(((e,t,r)=>{let a=t.handler,n=I(r);if(n){let e=o.sid?n.handlers.sidMap[o.sid]:n.handlers.unitMap.get(o);e&&(a=e)}return e.handler=a,e}),0,1),xe((({params:e,req:t,handler:r,args:a=[e]},n,i)=>{let o=ft(i),s=ct(e,t,1,l,i,o),d=ct(e,t,0,l,i,o),[f,c]=dt(r,d,a);f&&(ie(c)&&oe(c.then)?c.then(s,d):s(c))}),0,1)],meta:{op:'fx',fx:'runner'}});s.scope.runner=h,H(s.seq,xe(((e,{runner:t},r)=>{let a=O(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:Y()}),i({target:t,params:a,defer:1,scope:I(r),meta:r.meta}),a.params}),0,1)),o.create=e=>{let t=m(),r={params:e,req:t};if(De&&!_e){let e=De;t.req.finally((()=>{Le(e)})).catch((()=>{}))}return i({target:o,params:r,scope:De}),t.req};let y=o.inFlight=u(0,{serialize:'ignore',named:(N(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(e=>e+1)).on(l,(e=>e-1)).map({fn:e=>e,named:'inFlight'});q(l,'needFxCounter','dec'),q(o,'needFxCounter',1);let v=o.pending=y.map({fn:e=>e>0,named:'pending'});return ae(o,[l,d,c,p,g,v,y]),null!=a&&a.domain&&a.domain.hooks.effect(o),o}function h(e,t){fe(e,'merge','first argument');let r=f({name:o(e,'merge'),derived:1,and:t});return tt(e,r,[],'merge'),r}function y(e,a){let n=0;return t(pt,(t=>{t in e&&(r(null!=e[t],mt(a,t)),n=1)})),n}function v(e,r,a){let n=[];(function e(i){W(n,i)||(H(n,i),"store"===N(i,'op')&&(a||N(i,'sid'))&&r(i,N(i,'sid')),t(i.next,e),t($(i),e),t(j(i),e))})(e)}function b(e,a){let n=Array.isArray(e)?new Map(e):e,i=new Map;if(n instanceof Map){let e={};return t(n,((t,n)=>{r(R(n),'Map key should be a unit'),a&&a(n,t),n.sid?(r(!(n.sid in e),'duplicate sid found'),e[n.sid]=t):i.set(n,t)})),{sidMap:e,unitMap:i}}return{sidMap:n,unitMap:i}}function x(e){let t=()=>e();return t.unsubscribe=()=>e(),t}Object.defineProperty(exports,'__esModule',{value:1});let k='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',w='map',S='stack',M=e=>e.graphite||e,$=e=>e.family.owners,j=e=>e.family.links,z=e=>e.stateRef,C=e=>e.value,A=e=>e.subscribers,O=e=>e.parent,I=e=>e.scope,N=(e,t)=>M(e).meta[t],q=(e,t,r)=>M(e).meta[t]=r,F=e=>e.compositeName,R=e=>(oe(e)||ie(e))&&'kind'in e;const D=e=>t=>R(t)&&t.kind===e;let E=D("store"),_=D("event"),P=D("effect"),B=D("domain"),L=D("scope");var T={__proto__:null,unit:R,store:E,event:_,effect:P,domain:B,scope:L,attached:e=>P(e)&&1==N(e,'attached')};let W=(e,t)=>e.includes(t),G=(e,t)=>{let r=e.indexOf(t);-1!==r&&e.splice(r,1)},H=(e,t)=>e.push(t),U=(e,t,r)=>!e&&console.error(`${t} is deprecated${r?`, use ${r} instead`:''}`);const V=()=>{let e=0;return()=>""+ ++e};let J,K=V(),Q=V(),X=V(),Y=V(),Z=null,ee=e=>{J&&J(e,Z)},te=()=>Z&&Z.template,re=e=>(e&&Z&&Z.sidRoot&&(e=`${Z.sidRoot}|${e}`),e),ae=(e,r)=>{let a=M(e);t(r,(e=>{let t=M(e);"domain"!==a.family.type&&(t.family.type="crosslink"),H($(t),a),H(j(a),t)}))},ne=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(M),ie=e=>'object'==typeof e&&null!==e,oe=e=>'function'==typeof e,se=e=>void 0===e,le=e=>r(ie(e)||oe(e),'expect first argument be an object');const de=(e,t,a,n)=>r(!(!ie(e)&&!oe(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${a} to be a unit (store, event or effect)${n}`);let fe=(e,r,a)=>{Array.isArray(e)?t(e,((e,t)=>de(e,r,`${t} item of ${a}`,''))):de(e,r,a,' or array of units')},ce=(e,r,a="target")=>t(ne(r),(t=>U(!N(t,'derived'),`${e}: derived unit in "${a}"`,"createEvent/createStore"))),ue=(e,{fn:t},{a:r})=>t(e,r),pe=(e,{fn:t},{a:r})=>t(r,e),me=(e,{fn:t})=>t(e);const ge=(e,t,r,a)=>{let n={id:Q(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++he)),n};let he=0,ye=({from:e="store",store:t,target:r,to:a=(r?"store":S),batch:n,priority:i})=>ge('mov',{from:e,store:t,to:a,target:r},i,n),ve=({fn:e,batch:t,priority:r,safe:a=0,filter:n=0,pure:i=0})=>ge('compute',{fn:e,safe:a,filter:n,pure:i},r,t),be=({fn:e})=>ve({fn:e,priority:"effect"}),xe=(e,t,r)=>ve({fn:e,safe:1,filter:t,priority:r&&"effect"}),ke=(e,t,r)=>ye({store:e,to:t?S:"a",priority:r&&"sampler",batch:1}),we=(e=me,t)=>ve({fn:e,pure:1,filter:t}),Se={mov:ye,compute:ve,filter:({fn:e,pure:t})=>ve({fn:e,filter:1,pure:t}),run:be},Me=e=>({id:Q(),current:e}),$e=({current:e})=>e,je=(e,t)=>{e.before||(e.before=[]),H(e.before,t)},ze=null;const Ce=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Fe(e.v.type)>Fe(t.v.type))&&(r=e,e=t,t=r),r=Ce(e.r,t),e.r=e.l,e.l=r,e},Ae=[];let Oe=0;for(;Oe<6;)H(Ae,{first:null,last:null,size:0}),Oe+=1;const Ie=()=>{for(let e=0;e<6;e++){let t=Ae[e];if(t.size>0){if(3===e||4===e){t.size-=1;let e=ze.v;return ze=Ce(ze.l,ze.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},Ne=(e,t,r,a,n,i,o)=>qe(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),qe=(e,t,r,a=0)=>{let n=Fe(r),i=Ae[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?ze=Ce(ze,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Fe=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case"barrier":return 3;case"sampler":return 4;case"effect":return 5;default:return-1}},Re=new Set;let De,Ee=1,_e=0,Pe=0,Be=null,Le=e=>{De=e},Te=e=>{Be=e};const We=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=O(e);if(e)return e}return null};let Ge,He=(e,t,r,a,n)=>{let i=We(e,a.id);return i?i.reg[a.id]:t?(Ve(t,a,n),t.reg[a.id]):a};const Ue=e=>e;let Ve=(e,r,a,n,i)=>{var o;let s=e.reg,l=r.sid,d=null==r||null===(o=r.meta)||void 0===o?void 0:o.serialize;if(s[r.id])return;let f={id:r.id,current:r.current,meta:r.meta};if(l&&l in e.values.sidMap&&!(l in e.sidIdMap))f.current=(e.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||Ue)(e.values.sidMap[l]);else if(f.id in e.values.idMap)f.current=e.values.idMap[f.id];else if(r.before&&!i){let i=0,o=a||!r.noInit||n;t(r.before,(t=>{switch(t.type){case w:{let r=t.from;if(r||t.fn){r&&Ve(e,r,a,n);let i=r&&s[r.id].current;o&&(f.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,f.current=Array.isArray(f.current)?[...f.current]:{...f.current}),Ve(e,t.from,a,n),o&&(f.current[t.field]=s[s[t.from.id].id].current)}}))}l&&(e.sidIdMap[l]=r.id),s[r.id]=f};const Je=(e,t,r)=>{try{return t(C(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}};let Ke=(t,r={})=>(ie(t)&&(Ke(t.or,r),e(t,((e,t)=>{se(e)||'or'===t||'and'===t||(r[t]=e)})),Ke(t.and,r)),r);const Qe=(e,t)=>{G(e.next,t),G($(e),t),G(j(e),t)},Xe=(e,t,r)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let n=j(e);for(;a=n.pop();)Qe(a,e),(t||r&&'sample'!==N(e,'op')||"crosslink"===a.family.type)&&Xe(a,t,'on'!==N(a,'op')&&r);for(n=$(e);a=n.pop();)Qe(a,e),r&&"crosslink"===a.family.type&&Xe(a,t,'on'!==N(a,'op')&&r)},Ye=e=>e.clear();let Ze=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),E(e))Ye(A(e));else if(B(e)){r=1;let t=e.history;Ye(t.events),Ye(t.effects),Ye(t.stores),Ye(t.domains)}Xe(M(e),!!t,r)},et=e=>{let t=()=>Ze(e);return t.unsubscribe=t,t},tt=(e,t,r,a,i)=>n({node:r,parent:e,child:t,scope:{fn:i},meta:{op:a},family:{owners:[e,t],links:t},regional:1}),rt=(e,t)=>(r(oe(t),'.watch argument should be a function'),et(n({scope:{fn:t},node:[be({fn:me})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),at=(e,t,r="event")=>{O(e)&&O(e).hooks[r](t)},nt=(e,t,r)=>{let a=Ke(r),n="domain"===e,i=K(),{sid:o=null,named:l=null,domain:d=null,parent:f=d}=a,c=l||a.name||(n?'':i),u=s(c,f),p={op:t.kind=e,name:t.shortName=c,sid:t.sid=re(o),named:l,unitId:t.id=i,serialize:a.serialize,derived:a.derived,config:a};if(t.parent=f,t.compositeName=u,t.defaultConfig=a,t.thru=e=>(U(0,'thru','js pipe'),e(t)),t.getType=()=>u.fullName,!n){t.subscribe=e=>(le(e),t.watch(oe(e)?e:t=>e.next&&e.next(t))),t[k]=()=>t;let e=te();e&&(p.nativeTemplate=e)}return p};const ot=(e,t,r,a)=>{let n;ie(r)&&(n=r,r=r.fn);let i=f({name:`${e.shortName} \u2192 *`,derived:1,and:n});return tt(e,i,a,t,r),i},st=(e,t,r,a,n)=>{let i=z(t),o=ye({store:i,to:"a",priority:'read'});r===w&&(o.data.softRead=1);let s=[o,we(a)];return d('storeOnMap',i,s,E(e)&&z(e)),tt(e,t,s,r,n)},lt=(t,a,n,i,s)=>{let l=t?e=>[...e]:e=>({...e}),f=t?[]:{},c=l(f),p=Me(c),m=Me(1);p.type=t?'list':'shape',p.noInit=1,d('combineBase',p,m);let g=u(c,{name:o(n),derived:1,and:i}),h=z(g);h.noInit=1,q(g,'isCombine',1);let y=ke(p);y.order={priority:'barrier'};let v=[xe(((e,t,r)=>(r.scope&&!r.scope.reg[p.id]&&(r.c=1),e))),y,ye({store:m,to:'b'}),xe(((e,{key:t},r)=>{if(r.c||e!==r.a[t])return a&&r.b&&(r.a=l(r.a)),r.a[t]=e,1}),1),ye({from:"a",target:p}),ye({from:"value",store:0,target:m}),ye({from:"value",store:1,target:m,priority:"barrier",batch:1}),ke(p,1),s&&we()];return e(n,((e,t)=>{if(!E(e))return r(!R(e)&&!se(e),`combine expects a store in a field ${t}`),void(c[t]=f[t]=e);f[t]=e.defaultState,c[t]=e.getState();let a=tt(e,g,v,'combine',s);a.scope.key=t;let n=z(e);je(p,{type:'field',field:t,from:n}),d('combineField',n,a)})),g.defaultShape=n,je(h,{type:w,from:p,fn:s}),te()||(g.defaultState=s?h.current=s(c):f),g};let dt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},ft=e=>{let t=I(e),r={ref:t};return t&&H(t.activeEffects,r),r},ct=(e,t,r,a,n,o)=>s=>{o.ref&&G(o.ref.activeEffects,o),i({target:[a,ut],params:[r?{status:'done',params:e,result:s}:{status:'fail',params:e,error:s},{value:s,fn:r?t.rs:t.rj}],defer:1,page:n.page,scope:o.ref,meta:n.meta})};const ut=n({node:[be({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),pt=['source','clock','target'],mt=(e,t)=>e+`: ${t} should be defined`;let gt=(e,t,a,n,i,o,s,l,c,m,g,y)=>{let v=!!i;r(!se(a)||!se(t),mt(e,'either source or clock'));let b=0;se(a)?b=1:R(a)||(a=p(a)),se(t)?t=a:(fe(t,e,'clock'),Array.isArray(t)&&(t=h(t))),b&&(a=t),l||s||(s=a.shortName);let x='none';(g||n)&&(R(n)?x='unit':(r(oe(n),'`filter` should be function or unit'),x='fn')),i?(fe(i,e,'target'),ce(e,i)):'none'===x&&m&&E(a)&&E(t)?i=u(o?o($e(z(a)),$e(z(t))):$e(z(a)),{name:s,sid:y,or:l}):(i=f({name:s,derived:1,or:l}),d('sampleTarget',M(i)));let k=Me(),w=[];if('unit'===x){let[r,a]=yt(n,i,t,k,e);w=[...ht(a),...ht(r)]}let[$,j]=yt(a,i,t,k,e),C=tt(t,i,[d('sampleSourceLoader'),ye({from:S,target:k}),...ht(j),ke($,1,c),...w,ke(k),'fn'===x&&we(((e,t,{a:r})=>n(e,r)),1),o&&we(ue),d('sampleSourceUpward',v)],e,o);return ae(a,[C]),Object.assign(C.meta,l,{joint:1}),i};const ht=e=>[ke(e),xe(((e,t,{a:r})=>r),1)],yt=(e,t,r,a,i)=>{let o=E(e),s=o?z(e):Me(),l=Me(o);return o||n({parent:e,node:[ye({from:S,target:s}),ye({from:"value",store:1,target:l})],family:{owners:[e,t,r],links:t},meta:{op:i},regional:1}),d('sampleSource',l,s,a),[s,l]},vt=(e,t,r,a)=>{let n=e[t];n&&i({target:n,params:Array.isArray(n)?n.map((()=>r)):r,defer:1,stack:a})},bt=e=>e;exports.allSettled=(e,{scope:t,params:r}={})=>{if(!R(e))return Promise.reject(new Error('first argument should be unit'));if(!(P(e)||_(e)||E(e)||L(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));L(e)&&(t=e);let a=m();a.parentFork=De;let{fxCount:n}=t;H(n.scope.defers,a);let o=[],s=[];return L(e)||(H(o,e),H(s,P(e)?{params:r,req:{rs(e){a.value={status:'done',value:e}},rj(e){a.value={status:'fail',value:e}}}}:r)),H(o,n),H(s,null),i({target:o,params:s,scope:t}),a.req},exports.attach=e=>{let t;[e,t]=l(e,1);let{source:r,effect:a,mapParams:n}=e,o=g(e,t);q(o,'attached',1);let d,{runner:f}=M(o).scope,c=xe(((e,t,a)=>{let s,{params:l,req:d,handler:f}=e,c=o.finally,u=ft(a),p=ct(l,d,0,c,a,u),m=a.a,g=P(f),h=1;if(n?[h,s]=dt(n,p,[l,m]):s=r&&g?m:l,h){if(!g)return e.args=[m,s],1;i({target:f,params:{params:s,req:{rs:ct(l,d,1,c,a,u),rj:p}},page:a.page,defer:1,meta:a.meta})}}),1,1);if(r){let e;E(r)?(e=r,ae(e,[o])):(e=p(r),ae(o,[e])),d=[ke(z(e)),c]}else d=[c];f.seq.splice(1,0,...d),o.use(a);let u=O(a);return u&&(Object.assign(F(o),s(o.shortName,u)),o.defaultConfig.parent=u),at(a,o,"effect"),o},exports.clearNode=Ze,exports.combine=p,exports.createApi=(...t)=>{let[[r,a],n]=l(t),i={};return e(a,((e,t)=>{let a=i[t]=f(t,{parent:O(r),config:n});r.on(a,e),at(r,a)})),i},exports.createDomain=function r(a,o){let s=Ke({or:o,and:'string'==typeof a?{name:a}:a}),l=n({family:{type:"domain"},regional:1,parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent)}),d={history:{},graphite:l,hooks:{}};l.meta=nt("domain",d,{parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent),or:s}),e({Event:f,Effect:g,Store:u,Domain:r},((e,r)=>{let a=r.toLowerCase(),n=f({named:`on${r}`});d.hooks[a]=n;let o=new Set;d.history[`${a}s`]=o,n.create=e=>(i(n,e),e),H(M(n).seq,xe(((e,t,r)=>(r.scope=null,e)))),n.watch((e=>{ae(d,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),O(e)||(e.parent=d)})),ae(d,[n]),d[`onCreate${r}`]=e=>(t(o,e),n.watch(e)),d[`create${r}`]=d[a]=(t,r)=>{let a=Ke({and:r,or:t});return null!=a&&a.domain?e(t,r):n(e(t,{parent:d,or:a}))}}));let c=O(d);return c&&e(d.hooks,((e,t)=>tt(e,c.hooks[t]))),null!=s&&s.domain&&s.domain.hooks.domain(d),d},exports.createEffect=g,exports.createEvent=f,exports.createNode=n,exports.createStore=u,exports.createStoreObject=(...e)=>(U(0,'createStoreObject','combine'),p(...e)),exports.createWatch=({unit:e,fn:t,scope:r})=>{let a=[Se.run({fn:e=>t(e)})];if(r){let t=n({node:a}),i=e.graphite.id,o=r.additionalLinks,s=o[i]||[];return o[i]=s,s.push(t),x((()=>{let e=s.indexOf(t);-1!==e&&s.splice(e,1),Ze(t)}))}{let t=n({node:a,parent:[e],family:{owners:e}});return x((()=>{Ze(t)}))}},exports.fork=(e,a)=>{let i,o=e;B(e)&&(i=e,o=a);let s=(e=>{let r=n({scope:{defers:[],inFlight:0,fxID:0},node:[xe(((e,t,r)=>{O(r)?'dec'===N(O(r).node,'needFxCounter')?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),ve({priority:"sampler",batch:1}),xe(((e,r)=>{let{defers:a,fxID:n}=r;r.inFlight>0||0===a.length||Promise.resolve().then((()=>{r.fxID===n&&t(a.splice(0,a.length),(e=>{Le(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),a=n({node:[xe(((e,t,r)=>{let a=O(r);if(a){let t=a.node;if(!N(t,'isCombine')||O(a)&&'combine'!==N(O(a).node,'op')){let a=I(r),n=t.scope.state.id,i=N(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=N(t,'serialize');o&&a.sidSerializeSettings.set(i,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),i=n({node:[xe(((e,t,r)=>{let a=I(r);if(a){let e=O(r);e&&(!N(e.node,'isCombine')||O(e)&&'combine'!==N(O(e).node,'op'))&&(a.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return He(Be,o,null,e).current;let t=M(e);return He(Be,o,t,t.scope.state,1).current},kind:"scope",graphite:n({family:{type:"domain",links:[r,a,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:r}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:r,storeChange:a,warnSerializeNode:i,activeEffects:[]};return o})(i);if(o){let e=o.scope;if(e){let r=e.activeEffects;e.activeEffects=[],s.activeEffects=r,t(r,(e=>e.ref=s))}if(o.values){let{sidMap:e,unitMap:a}=b(o.values,(e=>r(E(e),'Values map can contain only stores as keys')));Object.assign(s.values.sidMap,e),t(a,((e,t)=>{s.values.idMap[t.stateRef.id]=e})),s.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map)}o.handlers&&(s.handlers=b(o.handlers,(e=>r(P(e),"Handlers map can contain only effects as keys"))))}return s},exports.forward=e=>{let t='forward',[{from:r,to:a},i]=l(e,1);return fe(r,t,'"from"'),fe(a,t,'"to"'),ce(t,a,'to'),et(n({parent:r,child:a,meta:{op:t,config:i},family:{},regional:1}))},exports.fromObservable=e=>{le(e);let t=k in e?e[k]():e;r(t.subscribe,'expect observable to have .subscribe');let a=f(),n=et(a);return t.subscribe({next:a,error:n,complete:n}),a},exports.guard=(...e)=>{let[[t,r],a]=l(e);return r||(r=t,t=r.source),y(r,'guard'),gt('guard',r.clock,t,r.filter,r.target,null,r.name,a,!r.greedy,0,1)},exports.hydrate=(e,{values:a})=>{r(ie(a),'values property should be an object');let{sidMap:n,unitMap:o}=b(a),s=Object.getOwnPropertyNames(n),l={};t(o,((e,t)=>{l[t.stateRef.id]=t}));let d,f,c,u=[],p=[];L(e)?(d=e,c=1,r(d.cloneOf,'scope should be created from domain'),f=M(d.cloneOf)):B(e)?f=M(e):r(0,'first argument of hydrate should be domain or scope'),v(f,((e,t)=>{if(t&&W(s,t)){H(u,e);let r=N(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),H(p,n[t])}else e.scope.state.id in l&&(H(u,e),H(p,o.get(l[e.scope.state.id])))}),1),i({target:u,params:p,scope:d}),c&&Object.assign(d.values.sidMap,n)},exports.is=T,exports.launch=i,exports.merge=h,exports.restore=(t,r,a)=>{if(E(t))return U(0,'restore($store)'),t;if(_(t)||P(t)){let e=O(t),n=u(r,{parent:e,name:t.shortName,and:a});return tt(P(t)?t.doneData:t,n),e&&e.hooks.store(n),n}let n=Array.isArray(t)?[]:{};return e(t,((e,t)=>n[t]=E(e)?e:u(e,{name:t}))),n},exports.sample=(...e)=>{let t,r,a,n,[[i,o,s],d]=l(e),f=1;return se(o)&&ie(i)&&y(i,"sample")&&(o=i.clock,s=i.fn,f=!i.greedy,n=i.filter,t=i.target,r=i.name,a=i.sid,i=i.source),gt("sample",o,i,n,t,s,r,d,f,1,0,a)},exports.scopeBind=(e,{scope:t,safe:a}={})=>{r(t||De||a,'scopeBind cannot be called outside of forked .watch');let n=t||De;return P(e)?t=>{let r=m();return i({target:e,params:{params:t,req:r},scope:n}),r.req}:t=>(i({target:e,params:t,scope:n}),t)},exports.serialize=(t,a={})=>{t.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted');let n=a.ignore?a.ignore.map((({sid:e})=>e)):[],i={};return e(t.values.sidMap,((e,r)=>{var a;if(W(n,r))return;let o=t.sidIdMap[r],s=null!==(a=t.sidSerializeSettings.get(r))&&void 0!==a?a:{ignore:0,write:bt};s.ignore||(i[r]=(0,s.write)(o&&o in t.reg?t.reg[o].current:e))})),'onlyChanges'in a&&!a.onlyChanges&&(r(t.cloneOf,'scope should be created from domain'),v(M(t.cloneOf),((e,r)=>{r in i||W(n,r)||N(e,'isCombine')||'ignore'===N(e,'serialize')||(i[r]=t.getState(e))}))),i},exports.setGraphInspector=e=>{J=e},exports.setInspector=e=>{Ge=e},exports.setStoreName=(e,t)=>{e.shortName=t,Object.assign(F(e),s(t,O(e)))},exports.split=(...t)=>{let a,i,o='split',[[s,c],u]=l(t),p=!c;p&&(a=s.cases,c=s.match,i=s.clock,s=s.source);let m=E(c),g=!R(c)&&oe(c),h=!m&&!g&&ie(c);r(R(s),'source must be a unit'),a||(a={}),p?e(a,((e,t)=>ce(o,e,`cases.${t}`))):(r(h,'match should be an object'),e(c,((e,t)=>a[t]=f({derived:1,named:`cases.${t}`,and:u}))),a.__=f({derived:1,named:'cases.__',and:u}));let y,v=new Set([].concat(s,i||[],Object.values(a))),b=Object.keys(m||g?a:c);if(m||g)m&&v.add(c),y=[m&&ke(z(c),0,1),ve({safe:m,filter:1,pure:!m,fn(e,t,r){let a=String(m?r.a:c(e));vt(t,W(b,a)?a:'__',e,r)}})];else if(h){let t=Me({});t.type='shape';let r,a=[];e(c,((e,n)=>{if(R(e)){r=1,H(a,n),v.add(e);let i=tt(e,[],[ke(t),xe(((e,t,{a:r})=>r[n]=e))]);if(E(e)){t.current[n]=e.getState();let r=z(e);je(t,{from:r,field:n,type:'field'}),d('splitMatchStore',r,i)}}})),r&&d('splitBase',t),y=[r&&ke(t,0,1),we(((e,t,r)=>{for(let n=0;n<b.length;n++){let i=b[n];if(W(a,i)?r.a[i]:c[i](e))return void vt(t,i,e,r)}vt(t,'__',e,r)}),1)]}else r(0,'expect match to be unit, function or object');let x=n({meta:{op:o},parent:i?[]:s,scope:a,node:y,family:{owners:Array.from(v)},regional:1});if(i&>(o,i,s,null,x,null,o,u,0,0,0),!p)return a},exports.step=Se,exports.version="22.8.3",exports.withFactory=({sid:e,name:t,loc:r,method:i,fn:o})=>a(n({meta:{sidRoot:re(e),sid:e,name:t,loc:r,method:i,type:'factory'}}),o),exports.withRegion=a; | ||
//# sourceMappingURL=effector.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e='undefined'!=typeof globalThis?globalThis:e||self).effector={})})(this,(e=>{function t(e,t){for(let r in e)t(e[r],r)}function r(e,t){e.forEach(t)}function a(e,t){if(!e)throw Error(t)}function n(e,t){let r=D(e).meta||{};ue={id:D(e).id,parent:ue,value:e,template:r.template||pe(),sidRoot:r.sidRoot||ue&&ue.sidRoot,meta:r};try{return t()}finally{ce('region'),ue=L(ue)}}function i({node:e=[],from:t,source:a,parent:n=t||a,to:i,target:o,child:l=i||o,scope:s={},meta:d={},family:f={type:'regular'},regional:u}={}){let c=he(n),p=he(f.links),m=he(f.owners),g=[];r(e,(e=>e&&ae(g,e)));let h={id:de(),seq:g,next:he(l),meta:d,scope:s,family:{type:f.type||A,links:p,owners:m}};return r(p,(e=>ae(E(e),h))),r(m,(e=>ae(_(e),h))),r(c,(e=>ae(e.next,h))),u&&ue&&ge(T(ue),[h]),h}function o(e,t,a){let n,i=Ye,o=null,l=Je;if(e.target&&(t=e.params,a=e.defer,n=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),l=W(e)||l,e=e.target),l&&Je&&l!==Je&&(Je=null),Array.isArray(e))for(let r=0;r<e.length;r++)Ge('pure',i,D(e[r]),o,t[r],l,n);else Ge('pure',i,D(e),o,t,l,n);if(a&&!Ke)return;let s,d,f,u,c,p,m={isRoot:Ke,currentPage:Ye,scope:Je,isWatch:Qe,isPure:Xe};Ke=0;e:for(;u=We();){let{idx:e,stack:t,type:a}=u;f=t.node,Ye=c=t.page,Je=W(t),c?p=c.reg:Je&&(p=Je.reg);let n=!!c,i=!!Je,o={fail:0,scope:f.scope};s=d=0;for(let r=e;r<f.seq.length&&!s;r++){let l=f.seq[r];if(l.order){let{priority:n,barrierID:i}=l.order,o=i?c?`${c.fullID}_${i}`:i:0;if(r!==e||a!==n){i?Ve.has(o)||(Ve.add(o),He(r,t,n,i)):He(r,t,n);continue e}i&&Ve.delete(o)}switch(l.type){case'mov':{let e,r=l.data;switch(r.from){case N:e=T(t);break;case R:case'b':e=t[r.from];break;case q:e=r.store;break;case M:if(p&&!p[r.store.id])if(n){let e=tt(c,r.store.id);t.page=c=e,e?p=e.reg:i?(ot(Je,r.store,0,1,r.softRead),p=Je.reg):p=void 0}else i&&ot(Je,r.store,0,1,r.softRead);e=Ee(p&&p[r.store.id]||r.store)}switch(r.to){case N:t.value=e;break;case R:case'b':t[r.to]=e;break;case M:at(c,Je,f,r.target).current=e}break}case'compute':let e=l.data;if(e.fn){Qe='watch'===G(f,'op'),Xe=e.pure;let r=e.safe?(0,e.fn)(T(t),o.scope,t):lt(o,e.fn,t);e.filter?d=!r:t.value=r,Qe=m.isWatch,Xe=m.isPure}}s=o.fail||d}if(rt&&rt(t,o),!s){let e=T(t),a=W(t);if(r(f.next,(r=>{Ge('child',c,r,t,e,a)})),a){G(f,'needFxCounter')&&Ge('child',c,a.fxCount,t,e,a),G(f,'storeChange')&&Ge('child',c,a.storeChange,t,e,a),G(f,'warnSerialize')&&Ge('child',c,a.warnSerializeNode,t,e,a);let n=a.additionalLinks[f.id];n&&r(n,(r=>{Ge('child',c,r,t,e,a)}))}}}Ke=m.isRoot,Ye=m.currentPage,Je=W(m)}function l(e,r="combine"){let a=r+'(',n='',i=0;return t(e,(e=>{i<25&&(null!=e&&(a+=n,a+=V(e)?U(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function s(e,t){let r,a,n=e;if(t){let n=U(t);0===e.length?(r=n.path,a=n.fullName):(r=n.path.concat([e]),a=0===n.fullName.length?e:n.fullName+'/'+e)}else r=0===e.length?[]:[e],a=e;return{shortName:n,fullName:a,path:r}}function d(e,t){let r=t?e:e[0];ke(r);let a=r.or,n=r.and;if(n){let r=t?n:n[0];if(ye(r)&&'and'in r){let r=d(n,t);e=r[0],a={...a,...r[1]}}else e=n}return[e,a]}function f(e,...t){let r=pe();if(r){let a=r.handlers[e];if(a)return a(r,...t)}}function u(e,t){let r=st({or:t,and:'string'==typeof e?{name:e}:e}),a=(e,...t)=>(ne(!G(a,'derived'),'call of derived event','createEvent'),ne(!Xe,'unit call from pure function','operators like sample'),Ye?((e,t,r,a)=>{let n=Ye,i=null;if(t)for(i=Ye;i&&i.template!==t;)i=L(i);et(i);let o=e.create(r,a);return et(n),o})(a,n,e,t):a.create(e,t)),n=pe(),l=Object.assign(a,{graphite:i({meta:yt(r.actualOp||x,a,r),regional:1}),create:e=>(o({target:a,params:e,scope:Je}),e),watch:e=>gt(a,e),map:e=>bt(a,O,e,[Fe()]),filter:e=>bt(a,"filter",e.fn?e:e.fn,[Fe($e,1)]),filterMap:e=>bt(a,'filterMap',e,[Fe(),Ie((e=>!ve(e)),1)]),prepend(e){let t=u('* \u2192 '+a.shortName,{parent:L(a)});return f('eventPrepend',D(t)),mt(t,a,[Fe()],'prepend',e),ht(a,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(l),ce(l.graphite),l}function c(e,t,n,i){return Se(n,t,'first argument'),a(be(i),'second argument should be a function'),ne(!G(e,'derived'),`${t} in derived store`,`${t} in store created via createStore`),r(Array.isArray(n)?n:[n],(t=>{e.off(t),B(e).set(t,pt(vt(t,e,'on',je,i)))})),e}function p(e,t){let n=st(t),l=De(e),s=u({named:'updates',derived:1});f('storeBase',l);let d=l.id,m={subscribers:new Map,updates:s,defaultState:e,stateRef:l,getState(){let e,t=l;if(Ye){let t=Ye;for(;t&&!t.reg[d];)t=L(t);t&&(e=t)}return!e&&Je&&(ot(Je,l,1),e=Je),e&&(t=e.reg[d]),Ee(t)},setState:e=>o({target:m,params:e,defer:1,scope:Je}),reset:(...e)=>(r(e,(e=>c(m,'.reset',e,(()=>m.defaultState)))),m),on:(e,t)=>c(m,'.on',e,t),off(e){let t=B(m).get(e);return t&&(t(),B(m).delete(e)),m},map(e,t){let r,a;ye(e)&&(r=e,e=e.fn),ne(ve(t),'second argument of store.map','updateFilter');let n=m.getState();pe()?a=null:ve(n)||(a=e(n,t));let i=p(a,{name:`${m.shortName} \u2192 *`,derived:1,and:r}),o=vt(m,i,O,xe,e);return _e(P(i),{type:O,fn:e,from:l}),P(i).noInit=1,f('storeMap',l,o),i},watch(e,t){if(!t||!V(e)){let t=gt(m,e);return f('storeWatch',l,e)||e(m.getState()),t}return a(be(t),'second argument should be a function'),e.watch((e=>t(m.getState(),e)))}},g=yt(M,m,n),h=m.defaultConfig.updateFilter;m.graphite=i({scope:{state:l,fn:h},node:[Ie(((e,t,r)=>(r.scope&&!r.scope.reg[l.id]&&(r.b=1),e))),qe(l),Ie(((e,t,{a:r,b:a})=>!ve(e)&&(e!==r||a)),1),h&&Fe(xe,1),Ae({from:N,target:l})],child:s,meta:{...g,defaultState:e},regional:1});let y=G(m,'serialize'),b=G(m,'derived'),v='ignore'===y,k=G(m,'sid');return k&&(H(m,'storeChange',1),l.sid=k),k||v||b||H(m,'warnSerialize',1),a(b||!ve(e),"current state can't be undefined, use null instead"),ge(m,[s]),null!=n&&n.domain&&n.domain.hooks.store(m),b||(m.reinit=u({named:'reinit'}),m.reset(m.reinit)),l.meta=m.graphite.meta,ce(m.graphite),m}function m(...e){let t,r,n;[e,n]=d(e);let i,o,l,s=e[e.length-1];if(be(s)?(r=e.slice(0,-1),t=s):r=e,1===r.length){let e=r[0];K(e)||(i=e,o=1)}if(!o&&(i=r,t)){l=1;let e=t;t=t=>e(...t)}return a(ye(i),'shape should be an object'),kt(Array.isArray(i),!l,i,n,t)}function g(){let e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function h(e,t={}){let r=st(be(e)?{handler:e}:e,t),n=u(be(e)?{handler:e}:e,{...t,actualOp:j}),l=D(n);H(l,'op',n.kind=j),n.use=e=>(a(be(e),'.use argument should be a function'),h.scope.handler=e,n),n.use.getCurrent=()=>h.scope.handler;let s=n.finally=u({named:'finally',derived:1}),d=n.done=s.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),f=n.fail=s.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),c=n.doneData=d.map({named:'doneData',fn:({result:e})=>e}),m=n.failData=f.map({named:'failData',fn:({error:e})=>e}),h=i({scope:{handler:n.defaultConfig.handler||(()=>a(0,`no handler used in ${n.getType()}`))},node:[Ie(((e,t,r)=>{let a=t.handler,i=W(r);if(i){let e=n.sid?i.handlers.sidMap[n.sid]:i.handlers.unitMap.get(n);e&&(a=e)}return e.handler=a,e}),0,1),Ie((({params:e,req:t,handler:r,args:a=[e]},n,i)=>{let o=St(i),l=Mt(e,t,1,s,i,o),d=Mt(e,t,0,s,i,o),[f,u]=wt(r,d,a);f&&(ye(u)&&be(u.then)?u.then(l,d):l(u))}),0,1)],meta:{op:'fx',fx:'runner'}});l.scope.runner=h,ae(l.seq,Ie(((e,{runner:t},r)=>{let a=L(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:fe()}),o({target:t,params:a,defer:1,scope:W(r),meta:r.meta}),a.params}),0,1)),n.create=e=>{let t=g(),r={params:e,req:t};if(Je&&!Qe){let e=Je;t.req.finally((()=>{Ze(e)})).catch((()=>{}))}return o({target:n,params:r,scope:Je}),t.req};let y=n.inFlight=p(0,{serialize:'ignore',named:(G(n,'name')||n.graphite.id)+'.inFlight'}).on(n,(e=>e+1)).on(s,(e=>e-1)).map({fn:e=>e,named:'inFlight'});H(s,'needFxCounter','dec'),H(n,'needFxCounter',1);let b=n.pending=y.map({fn:e=>e>0,named:'pending'});return ge(n,[s,d,f,c,m,b,y]),null!=r&&r.domain&&r.domain.hooks.effect(n),n}function y(e,t){Se(e,'merge','first argument');let r=u({name:l(e,'merge'),derived:1,and:t});return mt(e,r,[],'merge'),r}function b(e,t){let n=0;return r(jt,(r=>{r in e&&(a(null!=e[r],$t(t,r)),n=1)})),n}function v(e,t,a){let n=[];(function e(i){te(n,i)||(ae(n,i),G(i,'op')===M&&(a||G(i,'sid'))&&t(i,G(i,'sid')),r(i.next,e),r(E(i),e),r(_(i),e))})(e)}function k(e,t){let n=Array.isArray(e)?new Map(e):e,i=new Map;if(n instanceof Map){let e={};return r(n,((r,n)=>{a(V(n),'Map key should be a unit'),t&&t(n,r),n.sid?(a(!(n.sid in e),'duplicate sid found'),e[n.sid]=r):i.set(n,r)})),{sidMap:e,unitMap:i}}return{sidMap:n,unitMap:i}}function w(e){let t=()=>e();return t.unsubscribe=()=>e(),t}let S='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',M='store',x='event',j='effect',$='domain',z='scope',C='sampler',A='crosslink',O='map',N='stack',I='barrier',q='value',F='sample',R='a',D=e=>e.graphite||e,E=e=>e.family.owners,_=e=>e.family.links,P=e=>e.stateRef,T=e=>e.value,B=e=>e.subscribers,L=e=>e.parent,W=e=>e.scope,G=(e,t)=>D(e).meta[t],H=(e,t,r)=>D(e).meta[t]=r,U=e=>e.compositeName,V=e=>(be(e)||ye(e))&&'kind'in e;const J=e=>t=>V(t)&&t.kind===e;let K=J(M),Q=J(x),X=J(j),Y=J($),Z=J(z);var ee={__proto__:null,unit:V,store:K,event:Q,effect:X,domain:Y,scope:Z,attached:e=>X(e)&&1==G(e,'attached')};let te=(e,t)=>e.includes(t),re=(e,t)=>{let r=e.indexOf(t);-1!==r&&e.splice(r,1)},ae=(e,t)=>e.push(t),ne=(e,t,r)=>!e&&console.error(`${t} is deprecated${r?`, use ${r} instead`:''}`);const ie=()=>{let e=0;return()=>""+ ++e};let oe,le=ie(),se=ie(),de=ie(),fe=ie(),ue=null,ce=e=>{oe&&oe(e,ue)},pe=()=>ue&&ue.template,me=e=>(e&&ue&&ue.sidRoot&&(e=`${ue.sidRoot}|${e}`),e),ge=(e,t)=>{let a=D(e);r(t,(e=>{let t=D(e);a.family.type!==$&&(t.family.type=A),ae(E(t),a),ae(_(a),t)}))},he=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(D),ye=e=>'object'==typeof e&&null!==e,be=e=>'function'==typeof e,ve=e=>void 0===e,ke=e=>a(ye(e)||be(e),'expect first argument be an object');const we=(e,t,r,n)=>a(!(!ye(e)&&!be(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${r} to be a unit (store, event or effect)${n}`);let Se=(e,t,a)=>{Array.isArray(e)?r(e,((e,r)=>we(e,t,`${r} item of ${a}`,''))):we(e,t,a,' or array of units')},Me=(e,t,a="target")=>r(he(t),(t=>ne(!G(t,'derived'),`${e}: derived unit in "${a}"`,"createEvent/createStore"))),xe=(e,{fn:t},{a:r})=>t(e,r),je=(e,{fn:t},{a:r})=>t(r,e),$e=(e,{fn:t})=>t(e);const ze=(e,t,r,a)=>{let n={id:se(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++Ce)),n};let Ce=0,Ae=({from:e=M,store:t,target:r,to:a=(r?M:N),batch:n,priority:i})=>ze('mov',{from:e,store:t,to:a,target:r},i,n),Oe=({fn:e,batch:t,priority:r,safe:a=0,filter:n=0,pure:i=0})=>ze('compute',{fn:e,safe:a,filter:n,pure:i},r,t),Ne=({fn:e})=>Oe({fn:e,priority:j}),Ie=(e,t,r)=>Oe({fn:e,safe:1,filter:t,priority:r&&j}),qe=(e,t,r)=>Ae({store:e,to:t?N:R,priority:r&&C,batch:1}),Fe=(e=$e,t)=>Oe({fn:e,pure:1,filter:t}),Re={mov:Ae,compute:Oe,filter:({fn:e,pure:t})=>Oe({fn:e,filter:1,pure:t}),run:Ne},De=e=>({id:se(),current:e}),Ee=({current:e})=>e,_e=(e,t)=>{e.before||(e.before=[]),ae(e.before,t)},Pe=null;const Te=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Ue(e.v.type)>Ue(t.v.type))&&(r=e,e=t,t=r),r=Te(e.r,t),e.r=e.l,e.l=r,e},Be=[];let Le=0;for(;Le<6;)ae(Be,{first:null,last:null,size:0}),Le+=1;const We=()=>{for(let e=0;e<6;e++){let t=Be[e];if(t.size>0){if(3===e||4===e){t.size-=1;let e=Pe.v;return Pe=Te(Pe.l,Pe.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},Ge=(e,t,r,a,n,i,o)=>He(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),He=(e,t,r,a=0)=>{let n=Ue(r),i=Be[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?Pe=Te(Pe,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Ue=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case I:return 3;case C:return 4;case j:return 5;default:return-1}},Ve=new Set;let Je,Ke=1,Qe=0,Xe=0,Ye=null,Ze=e=>{Je=e},et=e=>{Ye=e};const tt=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=L(e);if(e)return e}return null};let rt,at=(e,t,r,a,n)=>{let i=tt(e,a.id);return i?i.reg[a.id]:t?(ot(t,a,n),t.reg[a.id]):a};const nt=e=>e;let ot=(e,t,a,n,i)=>{var o;let l=e.reg,s=t.sid,d=null==t||null===(o=t.meta)||void 0===o?void 0:o.serialize;if(l[t.id])return;let f={id:t.id,current:t.current,meta:t.meta};if(s&&s in e.values.sidMap&&!(s in e.sidIdMap))f.current=(e.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||nt)(e.values.sidMap[s]);else if(f.id in e.values.idMap)f.current=e.values.idMap[f.id];else if(t.before&&!i){let i=0,o=a||!t.noInit||n;r(t.before,(t=>{switch(t.type){case O:{let r=t.from;if(r||t.fn){r&&ot(e,r,a,n);let i=r&&l[r.id].current;o&&(f.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,f.current=Array.isArray(f.current)?[...f.current]:{...f.current}),ot(e,t.from,a,n),o&&(f.current[t.field]=l[l[t.from.id].id].current)}}))}s&&(e.sidIdMap[s]=t.id),l[t.id]=f};const lt=(e,t,r)=>{try{return t(T(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}};let st=(e,r={})=>(ye(e)&&(st(e.or,r),t(e,((e,t)=>{ve(e)||'or'===t||'and'===t||(r[t]=e)})),st(e.and,r)),r);const dt=(e,t)=>{re(e.next,t),re(E(e),t),re(_(e),t)},ft=(e,t,r)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let n=_(e);for(;a=n.pop();)dt(a,e),(t||r&&'sample'!==G(e,'op')||a.family.type===A)&&ft(a,t,'on'!==G(a,'op')&&r);for(n=E(e);a=n.pop();)dt(a,e),r&&a.family.type===A&&ft(a,t,'on'!==G(a,'op')&&r)},ut=e=>e.clear();let ct=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),K(e))ut(B(e));else if(Y(e)){r=1;let t=e.history;ut(t.events),ut(t.effects),ut(t.stores),ut(t.domains)}ft(D(e),!!t,r)},pt=e=>{let t=()=>ct(e);return t.unsubscribe=t,t},mt=(e,t,r,a,n)=>i({node:r,parent:e,child:t,scope:{fn:n},meta:{op:a},family:{owners:[e,t],links:t},regional:1}),gt=(e,t)=>(a(be(t),'.watch argument should be a function'),pt(i({scope:{fn:t},node:[Ne({fn:$e})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),ht=(e,t,r=x)=>{L(e)&&L(e).hooks[r](t)},yt=(e,t,r)=>{let a=st(r),n=e===$,i=le(),{sid:o=null,named:l=null,domain:d=null,parent:f=d}=a,u=l||a.name||(n?'':i),c=s(u,f),p={op:t.kind=e,name:t.shortName=u,sid:t.sid=me(o),named:l,unitId:t.id=i,serialize:a.serialize,derived:a.derived,config:a};if(t.parent=f,t.compositeName=c,t.defaultConfig=a,t.thru=e=>(ne(0,'thru','js pipe'),e(t)),t.getType=()=>c.fullName,!n){t.subscribe=e=>(ke(e),t.watch(be(e)?e:t=>e.next&&e.next(t))),t[S]=()=>t;let e=pe();e&&(p.nativeTemplate=e)}return p};const bt=(e,t,r,a)=>{let n;ye(r)&&(n=r,r=r.fn);let i=u({name:`${e.shortName} \u2192 *`,derived:1,and:n});return mt(e,i,a,t,r),i},vt=(e,t,r,a,n)=>{let i=P(t),o=Ae({store:i,to:R,priority:'read'});r===O&&(o.data.softRead=1);let l=[o,Fe(a)];return f('storeOnMap',i,l,K(e)&&P(e)),mt(e,t,l,r,n)},kt=(e,r,n,i,o)=>{let s=e?e=>[...e]:e=>({...e}),d=e?[]:{},u=s(d),c=De(u),m=De(1);c.type=e?'list':'shape',c.noInit=1,f('combineBase',c,m);let g=p(u,{name:l(n),derived:1,and:i}),h=P(g);h.noInit=1,H(g,'isCombine',1);let y=qe(c);y.order={priority:'barrier'};let b=[Ie(((e,t,r)=>(r.scope&&!r.scope.reg[c.id]&&(r.c=1),e))),y,Ae({store:m,to:'b'}),Ie(((e,{key:t},a)=>{if(a.c||e!==a.a[t])return r&&a.b&&(a.a=s(a.a)),a.a[t]=e,1}),1),Ae({from:R,target:c}),Ae({from:q,store:0,target:m}),Ae({from:q,store:1,target:m,priority:I,batch:1}),qe(c,1),o&&Fe()];return t(n,((e,t)=>{if(!K(e))return a(!V(e)&&!ve(e),`combine expects a store in a field ${t}`),void(u[t]=d[t]=e);d[t]=e.defaultState,u[t]=e.getState();let r=mt(e,g,b,'combine',o);r.scope.key=t;let n=P(e);_e(c,{type:'field',field:t,from:n}),f('combineField',n,r)})),g.defaultShape=n,_e(h,{type:O,from:c,fn:o}),pe()||(g.defaultState=o?h.current=o(u):d),g};let wt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},St=e=>{let t=W(e),r={ref:t};return t&&ae(t.activeEffects,r),r},Mt=(e,t,r,a,n,i)=>l=>{i.ref&&re(i.ref.activeEffects,i),o({target:[a,xt],params:[r?{status:'done',params:e,result:l}:{status:'fail',params:e,error:l},{value:l,fn:r?t.rs:t.rj}],defer:1,page:n.page,scope:i.ref,meta:n.meta})};const xt=i({node:[Ne({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),jt=['source','clock','target'],$t=(e,t)=>e+`: ${t} should be defined`;let zt=(e,t,r,n,i,o,l,s,d,c,g,h)=>{let b=!!i;a(!ve(r)||!ve(t),$t(e,'either source or clock'));let v=0;ve(r)?v=1:V(r)||(r=m(r)),ve(t)?t=r:(Se(t,e,'clock'),Array.isArray(t)&&(t=y(t))),v&&(r=t),s||l||(l=r.shortName);let k='none';(g||n)&&(V(n)?k='unit':(a(be(n),'`filter` should be function or unit'),k='fn')),i?(Se(i,e,'target'),Me(e,i)):'none'===k&&c&&K(r)&&K(t)?i=p(o?o(Ee(P(r)),Ee(P(t))):Ee(P(r)),{name:l,sid:h,or:s}):(i=u({name:l,derived:1,or:s}),f('sampleTarget',D(i)));let w=De(),S=[];if('unit'===k){let[r,a]=At(n,i,t,w,e);S=[...Ct(a),...Ct(r)]}let[M,x]=At(r,i,t,w,e),j=mt(t,i,[f('sampleSourceLoader'),Ae({from:N,target:w}),...Ct(x),qe(M,1,d),...S,qe(w),'fn'===k&&Fe(((e,t,{a:r})=>n(e,r)),1),o&&Fe(xe),f('sampleSourceUpward',b)],e,o);return ge(r,[j]),Object.assign(j.meta,s,{joint:1}),i};const Ct=e=>[qe(e),Ie(((e,t,{a:r})=>r),1)],At=(e,t,r,a,n)=>{let o=K(e),l=o?P(e):De(),s=De(o);return o||i({parent:e,node:[Ae({from:N,target:l}),Ae({from:q,store:1,target:s})],family:{owners:[e,t,r],links:t},meta:{op:n},regional:1}),f('sampleSource',s,l,a),[l,s]},Ot=(e,t,r,a)=>{let n=e[t];n&&o({target:n,params:Array.isArray(n)?n.map((()=>r)):r,defer:1,stack:a})},Nt=e=>e;e.allSettled=(e,{scope:t,params:r}={})=>{if(!V(e))return Promise.reject(new Error('first argument should be unit'));if(!(X(e)||Q(e)||K(e)||Z(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));Z(e)&&(t=e);let a=g();a.parentFork=Je;let{fxCount:n}=t;ae(n.scope.defers,a);let i=[],l=[];return Z(e)||(ae(i,e),ae(l,X(e)?{params:r,req:{rs(e){a.value={status:'done',value:e}},rj(e){a.value={status:'fail',value:e}}}}:r)),ae(i,n),ae(l,null),o({target:i,params:l,scope:t}),a.req},e.attach=e=>{let t;[e,t]=d(e,1);let{source:r,effect:a,mapParams:n}=e,i=h(e,t);H(i,'attached',1);let l,{runner:f}=D(i).scope,u=Ie(((e,t,a)=>{let l,{params:s,req:d,handler:f}=e,u=i.finally,c=St(a),p=Mt(s,d,0,u,a,c),m=a.a,g=X(f),h=1;if(n?[h,l]=wt(n,p,[s,m]):l=r&&g?m:s,h){if(!g)return e.args=[m,l],1;o({target:f,params:{params:l,req:{rs:Mt(s,d,1,u,a,c),rj:p}},page:a.page,defer:1,meta:a.meta})}}),1,1);if(r){let e;K(r)?(e=r,ge(e,[i])):(e=m(r),ge(i,[e])),l=[qe(P(e)),u]}else l=[u];f.seq.splice(1,0,...l),i.use(a);let c=L(a);return c&&(Object.assign(U(i),s(i.shortName,c)),i.defaultConfig.parent=c),ht(a,i,j),i},e.clearNode=ct,e.combine=m,e.createApi=(...e)=>{let[[r,a],n]=d(e),i={};return t(a,((e,t)=>{let a=i[t]=u(t,{parent:L(r),config:n});r.on(a,e),ht(r,a)})),i},e.createDomain=function e(a,n){let l=st({or:n,and:'string'==typeof a?{name:a}:a}),s=i({family:{type:$},regional:1,parent:(null==l?void 0:l.domain)||(null==l?void 0:l.parent)}),d={history:{},graphite:s,hooks:{}};s.meta=yt($,d,{parent:(null==l?void 0:l.domain)||(null==l?void 0:l.parent),or:l}),t({Event:u,Effect:h,Store:p,Domain:e},((e,t)=>{let a=t.toLowerCase(),n=(e=>u({named:e}))(`on${t}`);d.hooks[a]=n;let i=new Set;d.history[`${a}s`]=i,n.create=e=>(o(n,e),e),ae(D(n).seq,Ie(((e,t,r)=>(r.scope=null,e)))),n.watch((e=>{ge(d,[e]),i.add(e),e.ownerSet||(e.ownerSet=i),L(e)||(e.parent=d)})),ge(d,[n]),d[`onCreate${t}`]=e=>(r(i,e),n.watch(e)),d[`create${t}`]=d[a]=(t,r)=>{let a=st({and:r,or:t});return null!=a&&a.domain?e(t,r):n(e(t,{parent:d,or:a}))}}));let f=L(d);return f&&t(d.hooks,((e,t)=>mt(e,f.hooks[t]))),null!=l&&l.domain&&l.domain.hooks.domain(d),d},e.createEffect=h,e.createEvent=u,e.createNode=i,e.createStore=p,e.createStoreObject=(...e)=>(ne(0,'createStoreObject','combine'),m(...e)),e.createWatch=({unit:e,fn:t,scope:r})=>{let a=[Re.run({fn:e=>t(e)})];if(r){let t=i({node:a}),n=e.graphite.id,o=r.additionalLinks,l=o[n]||[];return o[n]=l,l.push(t),w((()=>{let e=l.indexOf(t);-1!==e&&l.splice(e,1),ct(t)}))}{let t=i({node:a,parent:[e],family:{owners:e}});return w((()=>{ct(t)}))}},e.fork=(e,t)=>{let n,o=e;Y(e)&&(n=e,o=t);let l=(e=>{let t=i({scope:{defers:[],inFlight:0,fxID:0},node:[Ie(((e,t,r)=>{L(r)?'dec'===G(L(r).node,'needFxCounter')?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),Oe({priority:C,batch:1}),Ie(((e,t)=>{let{defers:a,fxID:n}=t;t.inFlight>0||0===a.length||Promise.resolve().then((()=>{t.fxID===n&&r(a.splice(0,a.length),(e=>{Ze(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),a=i({node:[Ie(((e,t,r)=>{let a=L(r);if(a){let t=a.node;if(!G(t,'isCombine')||L(a)&&'combine'!==G(L(a).node,'op')){let a=W(r),n=t.scope.state.id,i=G(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=G(t,'serialize');o&&a.sidSerializeSettings.set(i,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),n=i({node:[Ie(((e,t,r)=>{let a=W(r);if(a){let e=L(r);e&&(!G(e.node,'isCombine')||L(e)&&'combine'!==G(L(e).node,'op'))&&(a.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return at(Ye,o,null,e).current;let t=D(e);return at(Ye,o,t,t.scope.state,1).current},kind:z,graphite:i({family:{type:$,links:[t,a,n]},meta:{unit:'fork'},scope:{forkInFlightCounter:t}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:t,storeChange:a,warnSerializeNode:n,activeEffects:[]};return o})(n);if(o){let e=o.scope;if(e){let t=e.activeEffects;e.activeEffects=[],l.activeEffects=t,r(t,(e=>e.ref=l))}if(o.values){let{sidMap:e,unitMap:t}=k(o.values,(e=>a(K(e),'Values map can contain only stores as keys')));Object.assign(l.values.sidMap,e),r(t,((e,t)=>{l.values.idMap[t.stateRef.id]=e})),l.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map)}o.handlers&&(l.handlers=k(o.handlers,(e=>a(X(e),"Handlers map can contain only effects as keys"))))}return l},e.forward=e=>{let t='forward',[{from:r,to:a},n]=d(e,1);return Se(r,t,'"from"'),Se(a,t,'"to"'),Me(t,a,'to'),pt(i({parent:r,child:a,meta:{op:t,config:n},family:{},regional:1}))},e.fromObservable=e=>{ke(e);let t=S in e?e[S]():e;a(t.subscribe,'expect observable to have .subscribe');let r=u(),n=pt(r);return t.subscribe({next:r,error:n,complete:n}),r},e.guard=(...e)=>{let[[t,r],a]=d(e);return r||(r=t,t=r.source),b(r,'guard'),zt('guard',r.clock,t,r.filter,r.target,null,r.name,a,!r.greedy,0,1)},e.hydrate=(e,{values:t})=>{a(ye(t),'values property should be an object');let{sidMap:n,unitMap:i}=k(t),l=Object.getOwnPropertyNames(n),s={};r(i,((e,t)=>{s[t.stateRef.id]=t}));let d,f,u,c=[],p=[];Z(e)?(d=e,u=1,a(d.cloneOf,'scope should be created from domain'),f=D(d.cloneOf)):Y(e)?f=D(e):a(0,'first argument of hydrate should be domain or scope'),v(f,((e,t)=>{if(t&&te(l,t)){ae(c,e);let r=G(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),ae(p,n[t])}else e.scope.state.id in s&&(ae(c,e),ae(p,i.get(s[e.scope.state.id])))}),1),o({target:c,params:p,scope:d}),u&&Object.assign(d.values.sidMap,n)},e.is=ee,e.launch=o,e.merge=y,e.restore=(e,r,a)=>{if(K(e))return ne(0,'restore($store)'),e;if(Q(e)||X(e)){let t=L(e),n=p(r,{parent:t,name:e.shortName,and:a});return mt(X(e)?e.doneData:e,n),t&&t.hooks.store(n),n}let n=Array.isArray(e)?[]:{};return t(e,((e,t)=>n[t]=K(e)?e:p(e,{name:t}))),n},e.sample=(...e)=>{let t,r,a,n,[[i,o,l],s]=d(e),f=1;return ve(o)&&ye(i)&&b(i,F)&&(o=i.clock,l=i.fn,f=!i.greedy,n=i.filter,t=i.target,r=i.name,a=i.sid,i=i.source),zt(F,o,i,n,t,l,r,s,f,1,0,a)},e.scopeBind=(e,{scope:t,safe:r}={})=>{a(t||Je||r,'scopeBind cannot be called outside of forked .watch');let n=t||Je;return X(e)?t=>{let r=g();return o({target:e,params:{params:t,req:r},scope:n}),r.req}:t=>(o({target:e,params:t,scope:n}),t)},e.serialize=(e,r={})=>{e.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted');let n=r.ignore?r.ignore.map((({sid:e})=>e)):[],i={};return t(e.values.sidMap,((t,r)=>{var a;if(te(n,r))return;let o=e.sidIdMap[r],l=null!==(a=e.sidSerializeSettings.get(r))&&void 0!==a?a:{ignore:0,write:Nt};l.ignore||(i[r]=(0,l.write)(o&&o in e.reg?e.reg[o].current:t))})),'onlyChanges'in r&&!r.onlyChanges&&(a(e.cloneOf,'scope should be created from domain'),v(D(e.cloneOf),((t,r)=>{r in i||te(n,r)||G(t,'isCombine')||'ignore'===G(t,'serialize')||(i[r]=e.getState(t))}))),i},e.setGraphInspector=e=>{oe=e},e.setInspector=e=>{rt=e},e.setStoreName=(e,t)=>{e.shortName=t,Object.assign(U(e),s(t,L(e)))},e.split=(...e)=>{let r,n,o='split',[[l,s],c]=d(e),p=!s;p&&(r=l.cases,s=l.match,n=l.clock,l=l.source);let m=K(s),g=!V(s)&&be(s),h=!m&&!g&&ye(s);a(V(l),'source must be a unit'),r||(r={}),p?t(r,((e,t)=>Me(o,e,`cases.${t}`))):(a(h,'match should be an object'),t(s,((e,t)=>r[t]=u({derived:1,named:`cases.${t}`,and:c}))),r.__=u({derived:1,named:'cases.__',and:c}));let y,b=new Set([].concat(l,n||[],Object.values(r))),v=Object.keys(m||g?r:s);if(m||g)m&&b.add(s),y=[m&&qe(P(s),0,1),Oe({safe:m,filter:1,pure:!m,fn(e,t,r){let a=String(m?r.a:s(e));Ot(t,te(v,a)?a:'__',e,r)}})];else if(h){let e=De({});e.type='shape';let r,a=[];t(s,((t,n)=>{if(V(t)){r=1,ae(a,n),b.add(t);let i=mt(t,[],[qe(e),Ie(((e,t,{a:r})=>r[n]=e))]);if(K(t)){e.current[n]=t.getState();let r=P(t);_e(e,{from:r,field:n,type:'field'}),f('splitMatchStore',r,i)}}})),r&&f('splitBase',e),y=[r&&qe(e,0,1),Fe(((e,t,r)=>{for(let n=0;n<v.length;n++){let i=v[n];if(te(a,i)?r.a[i]:s[i](e))return void Ot(t,i,e,r)}Ot(t,'__',e,r)}),1)]}else a(0,'expect match to be unit, function or object');let k=i({meta:{op:o},parent:n?[]:l,scope:r,node:y,family:{owners:Array.from(b)},regional:1});if(n&&zt(o,n,l,null,k,null,o,c,0,0,0),!p)return r},e.step=Re,e.version="22.8.2",e.withFactory=({sid:e,name:t,loc:r,method:a,fn:o})=>n(i({meta:{sidRoot:me(e),sid:e,name:t,loc:r,method:a,type:'factory'}}),o),e.withRegion=n,Object.defineProperty(e,'__esModule',{value:1})})); | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e='undefined'!=typeof globalThis?globalThis:e||self).effector={})})(this,(e=>{function t(e,t){for(let r in e)t(e[r],r)}function r(e,t){e.forEach(t)}function a(e,t){if(!e)throw Error(t)}function n(e,t){let r=D(e).meta||{};ue={id:D(e).id,parent:ue,value:e,template:r.template||pe(),sidRoot:r.sidRoot||ue&&ue.sidRoot,meta:r};try{return t()}finally{ce('region'),ue=L(ue)}}function i({node:e=[],from:t,source:a,parent:n=t||a,to:i,target:o,child:l=i||o,scope:s={},meta:d={},family:f={type:'regular'},regional:u}={}){let c=he(n),p=he(f.links),m=he(f.owners),g=[];r(e,(e=>e&&ae(g,e)));let h={id:de(),seq:g,next:he(l),meta:d,scope:s,family:{type:f.type||A,links:p,owners:m}};return r(p,(e=>ae(E(e),h))),r(m,(e=>ae(_(e),h))),r(c,(e=>ae(e.next,h))),u&&ue&&ge(T(ue),[h]),h}function o(e,t,a){let n,i=Ye,o=null,l=Je;if(e.target&&(t=e.params,a=e.defer,n=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),l=W(e)||l,e=e.target),l&&Je&&l!==Je&&(Je=null),Array.isArray(e))for(let r=0;r<e.length;r++)Ge('pure',i,D(e[r]),o,t[r],l,n);else Ge('pure',i,D(e),o,t,l,n);if(a&&!Ke)return;let s,d,f,u,c,p,m={isRoot:Ke,currentPage:Ye,scope:Je,isWatch:Qe,isPure:Xe};Ke=0;e:for(;u=We();){let{idx:e,stack:t,type:a}=u;f=t.node,Ye=c=t.page,Je=W(t),c?p=c.reg:Je&&(p=Je.reg);let n=!!c,i=!!Je,o={fail:0,scope:f.scope};s=d=0;for(let r=e;r<f.seq.length&&!s;r++){let l=f.seq[r];if(l.order){let{priority:n,barrierID:i}=l.order,o=i?c?`${c.fullID}_${i}`:i:0;if(r!==e||a!==n){i?Ve.has(o)||(Ve.add(o),He(r,t,n,i)):He(r,t,n);continue e}i&&Ve.delete(o)}switch(l.type){case'mov':{let e,r=l.data;switch(r.from){case I:e=T(t);break;case R:case'b':e=t[r.from];break;case q:e=r.store;break;case M:if(p&&!p[r.store.id])if(n){let e=tt(c,r.store.id);t.page=c=e,e?p=e.reg:i?(ot(Je,r.store,0,1,r.softRead),p=Je.reg):p=void 0}else i&&ot(Je,r.store,0,1,r.softRead);e=Ee(p&&p[r.store.id]||r.store)}switch(r.to){case I:t.value=e;break;case R:case'b':t[r.to]=e;break;case M:at(c,Je,f,r.target).current=e}break}case'compute':let e=l.data;if(e.fn){Qe='watch'===G(f,'op'),Xe=e.pure;let r=e.safe?(0,e.fn)(T(t),o.scope,t):lt(o,e.fn,t);e.filter?d=!r:t.value=r,Qe=m.isWatch,Xe=m.isPure}}s=o.fail||d}if(rt&&rt(t,o),!s){let e=T(t),a=W(t);if(r(f.next,(r=>{Ge('child',c,r,t,e,a)})),a){G(f,'needFxCounter')&&Ge('child',c,a.fxCount,t,e,a),G(f,'storeChange')&&Ge('child',c,a.storeChange,t,e,a),G(f,'warnSerialize')&&Ge('child',c,a.warnSerializeNode,t,e,a);let n=a.additionalLinks[f.id];n&&r(n,(r=>{Ge('child',c,r,t,e,a)}))}}}Ke=m.isRoot,Ye=m.currentPage,Je=W(m)}function l(e,r="combine"){let a=r+'(',n='',i=0;return t(e,(e=>{i<25&&(null!=e&&(a+=n,a+=V(e)?U(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function s(e,t){let r,a,n=e;if(t){let n=U(t);0===e.length?(r=n.path,a=n.fullName):(r=n.path.concat([e]),a=0===n.fullName.length?e:n.fullName+'/'+e)}else r=0===e.length?[]:[e],a=e;return{shortName:n,fullName:a,path:r}}function d(e,t){let r=t?e:e[0];ke(r);let a=r.or,n=r.and;if(n){let r=t?n:n[0];if(ye(r)&&'and'in r){let r=d(n,t);e=r[0],a={...a,...r[1]}}else e=n}return[e,a]}function f(e,...t){let r=pe();if(r){let a=r.handlers[e];if(a)return a(r,...t)}}function u(e,t){let r=st({or:t,and:'string'==typeof e?{name:e}:e}),a=(e,...t)=>(ne(!G(a,'derived'),'call of derived event','createEvent'),ne(!Xe,'unit call from pure function','operators like sample'),Ye?((e,t,r,a)=>{let n=Ye,i=null;if(t)for(i=Ye;i&&i.template!==t;)i=L(i);et(i);let o=e.create(r,a);return et(n),o})(a,n,e,t):a.create(e,t)),n=pe(),l=Object.assign(a,{graphite:i({meta:yt(r.actualOp||x,a,r),regional:1}),create:e=>(o({target:a,params:e,scope:Je}),e),watch:e=>gt(a,e),map:e=>bt(a,O,e,[Fe()]),filter:e=>bt(a,"filter",e.fn?e:e.fn,[Fe($e,1)]),filterMap:e=>bt(a,'filterMap',e,[Fe(),Ne((e=>!ve(e)),1)]),prepend(e){let t=u('* \u2192 '+a.shortName,{parent:L(a)});return f('eventPrepend',D(t)),mt(t,a,[Fe()],'prepend',e),ht(a,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(l),H(l,'id',l.graphite.id),ce(l.graphite),l}function c(e,t,n,i){return Se(n,t,'first argument'),a(be(i),'second argument should be a function'),ne(!G(e,'derived'),`${t} in derived store`,`${t} in store created via createStore`),r(Array.isArray(n)?n:[n],(t=>{e.off(t),B(e).set(t,pt(vt(t,e,'on',je,i)))})),e}function p(e,t){let n=st(t),l=De(e),s=u({named:'updates',derived:1});f('storeBase',l);let d=l.id,m={subscribers:new Map,updates:s,defaultState:e,stateRef:l,getState(){let e,t=l;if(Ye){let t=Ye;for(;t&&!t.reg[d];)t=L(t);t&&(e=t)}return!e&&Je&&(ot(Je,l,1),e=Je),e&&(t=e.reg[d]),Ee(t)},setState:e=>o({target:m,params:e,defer:1,scope:Je}),reset:(...e)=>(r(e,(e=>c(m,'.reset',e,(()=>m.defaultState)))),m),on:(e,t)=>c(m,'.on',e,t),off(e){let t=B(m).get(e);return t&&(t(),B(m).delete(e)),m},map(e,t){let r,a;ye(e)&&(r=e,e=e.fn),ne(ve(t),'second argument of store.map','updateFilter');let n=m.getState();pe()?a=null:ve(n)||(a=e(n,t));let i=p(a,{name:`${m.shortName} \u2192 *`,derived:1,and:r}),o=vt(m,i,O,xe,e);return _e(P(i),{type:O,fn:e,from:l}),P(i).noInit=1,f('storeMap',l,o),i},watch(e,t){if(!t||!V(e)){let t=gt(m,e);return f('storeWatch',l,e)||e(m.getState()),t}return a(be(t),'second argument should be a function'),e.watch((e=>t(m.getState(),e)))}},g=yt(M,m,n),h=m.defaultConfig.updateFilter;m.graphite=i({scope:{state:l,fn:h},node:[Ne(((e,t,r)=>(r.scope&&!r.scope.reg[l.id]&&(r.b=1),e))),qe(l),Ne(((e,t,{a:r,b:a})=>!ve(e)&&(e!==r||a)),1),h&&Fe(xe,1),Ae({from:I,target:l})],child:s,meta:{...g,defaultState:e},regional:1}),H(m,'id',m.graphite.id),H(m,'rootStateRefId',d);let y=G(m,'serialize'),b=G(m,'derived'),v='ignore'===y,k=G(m,'sid');return k&&(H(m,'storeChange',1),l.sid=k),k||v||b||H(m,'warnSerialize',1),a(b||!ve(e),"current state can't be undefined, use null instead"),ge(m,[s]),null!=n&&n.domain&&n.domain.hooks.store(m),b||(m.reinit=u({named:'reinit'}),m.reset(m.reinit)),l.meta=m.graphite.meta,ce(m.graphite),m}function m(...e){let t,r,n;[e,n]=d(e);let i,o,l,s=e[e.length-1];if(be(s)?(r=e.slice(0,-1),t=s):r=e,1===r.length){let e=r[0];K(e)||(i=e,o=1)}if(!o&&(i=r,t)){l=1;let e=t;t=t=>e(...t)}return a(ye(i),'shape should be an object'),kt(Array.isArray(i),!l,i,n,t)}function g(){let e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function h(e,t={}){let r=st(be(e)?{handler:e}:e,t),n=u(be(e)?{handler:e}:e,{...t,actualOp:j}),l=D(n);H(l,'op',n.kind=j),n.use=e=>(a(be(e),'.use argument should be a function'),h.scope.handler=e,n),n.use.getCurrent=()=>h.scope.handler;let s=n.finally=u({named:'finally',derived:1}),d=n.done=s.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),f=n.fail=s.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),c=n.doneData=d.map({named:'doneData',fn:({result:e})=>e}),m=n.failData=f.map({named:'failData',fn:({error:e})=>e}),h=i({scope:{handler:n.defaultConfig.handler||(()=>a(0,`no handler used in ${n.getType()}`))},node:[Ne(((e,t,r)=>{let a=t.handler,i=W(r);if(i){let e=n.sid?i.handlers.sidMap[n.sid]:i.handlers.unitMap.get(n);e&&(a=e)}return e.handler=a,e}),0,1),Ne((({params:e,req:t,handler:r,args:a=[e]},n,i)=>{let o=St(i),l=Mt(e,t,1,s,i,o),d=Mt(e,t,0,s,i,o),[f,u]=wt(r,d,a);f&&(ye(u)&&be(u.then)?u.then(l,d):l(u))}),0,1)],meta:{op:'fx',fx:'runner'}});l.scope.runner=h,ae(l.seq,Ne(((e,{runner:t},r)=>{let a=L(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:fe()}),o({target:t,params:a,defer:1,scope:W(r),meta:r.meta}),a.params}),0,1)),n.create=e=>{let t=g(),r={params:e,req:t};if(Je&&!Qe){let e=Je;t.req.finally((()=>{Ze(e)})).catch((()=>{}))}return o({target:n,params:r,scope:Je}),t.req};let y=n.inFlight=p(0,{serialize:'ignore',named:(G(n,'name')||n.graphite.id)+'.inFlight'}).on(n,(e=>e+1)).on(s,(e=>e-1)).map({fn:e=>e,named:'inFlight'});H(s,'needFxCounter','dec'),H(n,'needFxCounter',1);let b=n.pending=y.map({fn:e=>e>0,named:'pending'});return ge(n,[s,d,f,c,m,b,y]),null!=r&&r.domain&&r.domain.hooks.effect(n),n}function y(e,t){Se(e,'merge','first argument');let r=u({name:l(e,'merge'),derived:1,and:t});return mt(e,r,[],'merge'),r}function b(e,t){let n=0;return r(jt,(r=>{r in e&&(a(null!=e[r],$t(t,r)),n=1)})),n}function v(e,t,a){let n=[];(function e(i){te(n,i)||(ae(n,i),G(i,'op')===M&&(a||G(i,'sid'))&&t(i,G(i,'sid')),r(i.next,e),r(E(i),e),r(_(i),e))})(e)}function k(e,t){let n=Array.isArray(e)?new Map(e):e,i=new Map;if(n instanceof Map){let e={};return r(n,((r,n)=>{a(V(n),'Map key should be a unit'),t&&t(n,r),n.sid?(a(!(n.sid in e),'duplicate sid found'),e[n.sid]=r):i.set(n,r)})),{sidMap:e,unitMap:i}}return{sidMap:n,unitMap:i}}function w(e){let t=()=>e();return t.unsubscribe=()=>e(),t}let S='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',M='store',x='event',j='effect',$='domain',z='scope',C='sampler',A='crosslink',O='map',I='stack',N='barrier',q='value',F='sample',R='a',D=e=>e.graphite||e,E=e=>e.family.owners,_=e=>e.family.links,P=e=>e.stateRef,T=e=>e.value,B=e=>e.subscribers,L=e=>e.parent,W=e=>e.scope,G=(e,t)=>D(e).meta[t],H=(e,t,r)=>D(e).meta[t]=r,U=e=>e.compositeName,V=e=>(be(e)||ye(e))&&'kind'in e;const J=e=>t=>V(t)&&t.kind===e;let K=J(M),Q=J(x),X=J(j),Y=J($),Z=J(z);var ee={__proto__:null,unit:V,store:K,event:Q,effect:X,domain:Y,scope:Z,attached:e=>X(e)&&1==G(e,'attached')};let te=(e,t)=>e.includes(t),re=(e,t)=>{let r=e.indexOf(t);-1!==r&&e.splice(r,1)},ae=(e,t)=>e.push(t),ne=(e,t,r)=>!e&&console.error(`${t} is deprecated${r?`, use ${r} instead`:''}`);const ie=()=>{let e=0;return()=>""+ ++e};let oe,le=ie(),se=ie(),de=ie(),fe=ie(),ue=null,ce=e=>{oe&&oe(e,ue)},pe=()=>ue&&ue.template,me=e=>(e&&ue&&ue.sidRoot&&(e=`${ue.sidRoot}|${e}`),e),ge=(e,t)=>{let a=D(e);r(t,(e=>{let t=D(e);a.family.type!==$&&(t.family.type=A),ae(E(t),a),ae(_(a),t)}))},he=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(D),ye=e=>'object'==typeof e&&null!==e,be=e=>'function'==typeof e,ve=e=>void 0===e,ke=e=>a(ye(e)||be(e),'expect first argument be an object');const we=(e,t,r,n)=>a(!(!ye(e)&&!be(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${r} to be a unit (store, event or effect)${n}`);let Se=(e,t,a)=>{Array.isArray(e)?r(e,((e,r)=>we(e,t,`${r} item of ${a}`,''))):we(e,t,a,' or array of units')},Me=(e,t,a="target")=>r(he(t),(t=>ne(!G(t,'derived'),`${e}: derived unit in "${a}"`,"createEvent/createStore"))),xe=(e,{fn:t},{a:r})=>t(e,r),je=(e,{fn:t},{a:r})=>t(r,e),$e=(e,{fn:t})=>t(e);const ze=(e,t,r,a)=>{let n={id:se(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++Ce)),n};let Ce=0,Ae=({from:e=M,store:t,target:r,to:a=(r?M:I),batch:n,priority:i})=>ze('mov',{from:e,store:t,to:a,target:r},i,n),Oe=({fn:e,batch:t,priority:r,safe:a=0,filter:n=0,pure:i=0})=>ze('compute',{fn:e,safe:a,filter:n,pure:i},r,t),Ie=({fn:e})=>Oe({fn:e,priority:j}),Ne=(e,t,r)=>Oe({fn:e,safe:1,filter:t,priority:r&&j}),qe=(e,t,r)=>Ae({store:e,to:t?I:R,priority:r&&C,batch:1}),Fe=(e=$e,t)=>Oe({fn:e,pure:1,filter:t}),Re={mov:Ae,compute:Oe,filter:({fn:e,pure:t})=>Oe({fn:e,filter:1,pure:t}),run:Ie},De=e=>({id:se(),current:e}),Ee=({current:e})=>e,_e=(e,t)=>{e.before||(e.before=[]),ae(e.before,t)},Pe=null;const Te=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Ue(e.v.type)>Ue(t.v.type))&&(r=e,e=t,t=r),r=Te(e.r,t),e.r=e.l,e.l=r,e},Be=[];let Le=0;for(;Le<6;)ae(Be,{first:null,last:null,size:0}),Le+=1;const We=()=>{for(let e=0;e<6;e++){let t=Be[e];if(t.size>0){if(3===e||4===e){t.size-=1;let e=Pe.v;return Pe=Te(Pe.l,Pe.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},Ge=(e,t,r,a,n,i,o)=>He(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),He=(e,t,r,a=0)=>{let n=Ue(r),i=Be[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?Pe=Te(Pe,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Ue=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case N:return 3;case C:return 4;case j:return 5;default:return-1}},Ve=new Set;let Je,Ke=1,Qe=0,Xe=0,Ye=null,Ze=e=>{Je=e},et=e=>{Ye=e};const tt=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=L(e);if(e)return e}return null};let rt,at=(e,t,r,a,n)=>{let i=tt(e,a.id);return i?i.reg[a.id]:t?(ot(t,a,n),t.reg[a.id]):a};const nt=e=>e;let ot=(e,t,a,n,i)=>{var o;let l=e.reg,s=t.sid,d=null==t||null===(o=t.meta)||void 0===o?void 0:o.serialize;if(l[t.id])return;let f={id:t.id,current:t.current,meta:t.meta};if(s&&s in e.values.sidMap&&!(s in e.sidIdMap))f.current=(e.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||nt)(e.values.sidMap[s]);else if(f.id in e.values.idMap)f.current=e.values.idMap[f.id];else if(t.before&&!i){let i=0,o=a||!t.noInit||n;r(t.before,(t=>{switch(t.type){case O:{let r=t.from;if(r||t.fn){r&&ot(e,r,a,n);let i=r&&l[r.id].current;o&&(f.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,f.current=Array.isArray(f.current)?[...f.current]:{...f.current}),ot(e,t.from,a,n),o&&(f.current[t.field]=l[l[t.from.id].id].current)}}))}s&&(e.sidIdMap[s]=t.id),l[t.id]=f};const lt=(e,t,r)=>{try{return t(T(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}};let st=(e,r={})=>(ye(e)&&(st(e.or,r),t(e,((e,t)=>{ve(e)||'or'===t||'and'===t||(r[t]=e)})),st(e.and,r)),r);const dt=(e,t)=>{re(e.next,t),re(E(e),t),re(_(e),t)},ft=(e,t,r)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let n=_(e);for(;a=n.pop();)dt(a,e),(t||r&&'sample'!==G(e,'op')||a.family.type===A)&&ft(a,t,'on'!==G(a,'op')&&r);for(n=E(e);a=n.pop();)dt(a,e),r&&a.family.type===A&&ft(a,t,'on'!==G(a,'op')&&r)},ut=e=>e.clear();let ct=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),K(e))ut(B(e));else if(Y(e)){r=1;let t=e.history;ut(t.events),ut(t.effects),ut(t.stores),ut(t.domains)}ft(D(e),!!t,r)},pt=e=>{let t=()=>ct(e);return t.unsubscribe=t,t},mt=(e,t,r,a,n)=>i({node:r,parent:e,child:t,scope:{fn:n},meta:{op:a},family:{owners:[e,t],links:t},regional:1}),gt=(e,t)=>(a(be(t),'.watch argument should be a function'),pt(i({scope:{fn:t},node:[Ie({fn:$e})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),ht=(e,t,r=x)=>{L(e)&&L(e).hooks[r](t)},yt=(e,t,r)=>{let a=st(r),n=e===$,i=le(),{sid:o=null,named:l=null,domain:d=null,parent:f=d}=a,u=l||a.name||(n?'':i),c=s(u,f),p={op:t.kind=e,name:t.shortName=u,sid:t.sid=me(o),named:l,unitId:t.id=i,serialize:a.serialize,derived:a.derived,config:a};if(t.parent=f,t.compositeName=c,t.defaultConfig=a,t.thru=e=>(ne(0,'thru','js pipe'),e(t)),t.getType=()=>c.fullName,!n){t.subscribe=e=>(ke(e),t.watch(be(e)?e:t=>e.next&&e.next(t))),t[S]=()=>t;let e=pe();e&&(p.nativeTemplate=e)}return p};const bt=(e,t,r,a)=>{let n;ye(r)&&(n=r,r=r.fn);let i=u({name:`${e.shortName} \u2192 *`,derived:1,and:n});return mt(e,i,a,t,r),i},vt=(e,t,r,a,n)=>{let i=P(t),o=Ae({store:i,to:R,priority:'read'});r===O&&(o.data.softRead=1);let l=[o,Fe(a)];return f('storeOnMap',i,l,K(e)&&P(e)),mt(e,t,l,r,n)},kt=(e,r,n,i,o)=>{let s=e?e=>[...e]:e=>({...e}),d=e?[]:{},u=s(d),c=De(u),m=De(1);c.type=e?'list':'shape',c.noInit=1,f('combineBase',c,m);let g=p(u,{name:l(n),derived:1,and:i}),h=P(g);h.noInit=1,H(g,'isCombine',1);let y=qe(c);y.order={priority:'barrier'};let b=[Ne(((e,t,r)=>(r.scope&&!r.scope.reg[c.id]&&(r.c=1),e))),y,Ae({store:m,to:'b'}),Ne(((e,{key:t},a)=>{if(a.c||e!==a.a[t])return r&&a.b&&(a.a=s(a.a)),a.a[t]=e,1}),1),Ae({from:R,target:c}),Ae({from:q,store:0,target:m}),Ae({from:q,store:1,target:m,priority:N,batch:1}),qe(c,1),o&&Fe()];return t(n,((e,t)=>{if(!K(e))return a(!V(e)&&!ve(e),`combine expects a store in a field ${t}`),void(u[t]=d[t]=e);d[t]=e.defaultState,u[t]=e.getState();let r=mt(e,g,b,'combine',o);r.scope.key=t;let n=P(e);_e(c,{type:'field',field:t,from:n}),f('combineField',n,r)})),g.defaultShape=n,_e(h,{type:O,from:c,fn:o}),pe()||(g.defaultState=o?h.current=o(u):d),g};let wt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},St=e=>{let t=W(e),r={ref:t};return t&&ae(t.activeEffects,r),r},Mt=(e,t,r,a,n,i)=>l=>{i.ref&&re(i.ref.activeEffects,i),o({target:[a,xt],params:[r?{status:'done',params:e,result:l}:{status:'fail',params:e,error:l},{value:l,fn:r?t.rs:t.rj}],defer:1,page:n.page,scope:i.ref,meta:n.meta})};const xt=i({node:[Ie({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),jt=['source','clock','target'],$t=(e,t)=>e+`: ${t} should be defined`;let zt=(e,t,r,n,i,o,l,s,d,c,g,h)=>{let b=!!i;a(!ve(r)||!ve(t),$t(e,'either source or clock'));let v=0;ve(r)?v=1:V(r)||(r=m(r)),ve(t)?t=r:(Se(t,e,'clock'),Array.isArray(t)&&(t=y(t))),v&&(r=t),s||l||(l=r.shortName);let k='none';(g||n)&&(V(n)?k='unit':(a(be(n),'`filter` should be function or unit'),k='fn')),i?(Se(i,e,'target'),Me(e,i)):'none'===k&&c&&K(r)&&K(t)?i=p(o?o(Ee(P(r)),Ee(P(t))):Ee(P(r)),{name:l,sid:h,or:s}):(i=u({name:l,derived:1,or:s}),f('sampleTarget',D(i)));let w=De(),S=[];if('unit'===k){let[r,a]=At(n,i,t,w,e);S=[...Ct(a),...Ct(r)]}let[M,x]=At(r,i,t,w,e),j=mt(t,i,[f('sampleSourceLoader'),Ae({from:I,target:w}),...Ct(x),qe(M,1,d),...S,qe(w),'fn'===k&&Fe(((e,t,{a:r})=>n(e,r)),1),o&&Fe(xe),f('sampleSourceUpward',b)],e,o);return ge(r,[j]),Object.assign(j.meta,s,{joint:1}),i};const Ct=e=>[qe(e),Ne(((e,t,{a:r})=>r),1)],At=(e,t,r,a,n)=>{let o=K(e),l=o?P(e):De(),s=De(o);return o||i({parent:e,node:[Ae({from:I,target:l}),Ae({from:q,store:1,target:s})],family:{owners:[e,t,r],links:t},meta:{op:n},regional:1}),f('sampleSource',s,l,a),[l,s]},Ot=(e,t,r,a)=>{let n=e[t];n&&o({target:n,params:Array.isArray(n)?n.map((()=>r)):r,defer:1,stack:a})},It=e=>e;e.allSettled=(e,{scope:t,params:r}={})=>{if(!V(e))return Promise.reject(new Error('first argument should be unit'));if(!(X(e)||Q(e)||K(e)||Z(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));Z(e)&&(t=e);let a=g();a.parentFork=Je;let{fxCount:n}=t;ae(n.scope.defers,a);let i=[],l=[];return Z(e)||(ae(i,e),ae(l,X(e)?{params:r,req:{rs(e){a.value={status:'done',value:e}},rj(e){a.value={status:'fail',value:e}}}}:r)),ae(i,n),ae(l,null),o({target:i,params:l,scope:t}),a.req},e.attach=e=>{let t;[e,t]=d(e,1);let{source:r,effect:a,mapParams:n}=e,i=h(e,t);H(i,'attached',1);let l,{runner:f}=D(i).scope,u=Ne(((e,t,a)=>{let l,{params:s,req:d,handler:f}=e,u=i.finally,c=St(a),p=Mt(s,d,0,u,a,c),m=a.a,g=X(f),h=1;if(n?[h,l]=wt(n,p,[s,m]):l=r&&g?m:s,h){if(!g)return e.args=[m,l],1;o({target:f,params:{params:l,req:{rs:Mt(s,d,1,u,a,c),rj:p}},page:a.page,defer:1,meta:a.meta})}}),1,1);if(r){let e;K(r)?(e=r,ge(e,[i])):(e=m(r),ge(i,[e])),l=[qe(P(e)),u]}else l=[u];f.seq.splice(1,0,...l),i.use(a);let c=L(a);return c&&(Object.assign(U(i),s(i.shortName,c)),i.defaultConfig.parent=c),ht(a,i,j),i},e.clearNode=ct,e.combine=m,e.createApi=(...e)=>{let[[r,a],n]=d(e),i={};return t(a,((e,t)=>{let a=i[t]=u(t,{parent:L(r),config:n});r.on(a,e),ht(r,a)})),i},e.createDomain=function e(a,n){let l=st({or:n,and:'string'==typeof a?{name:a}:a}),s=i({family:{type:$},regional:1,parent:(null==l?void 0:l.domain)||(null==l?void 0:l.parent)}),d={history:{},graphite:s,hooks:{}};s.meta=yt($,d,{parent:(null==l?void 0:l.domain)||(null==l?void 0:l.parent),or:l}),t({Event:u,Effect:h,Store:p,Domain:e},((e,t)=>{let a=t.toLowerCase(),n=(e=>u({named:e}))(`on${t}`);d.hooks[a]=n;let i=new Set;d.history[`${a}s`]=i,n.create=e=>(o(n,e),e),ae(D(n).seq,Ne(((e,t,r)=>(r.scope=null,e)))),n.watch((e=>{ge(d,[e]),i.add(e),e.ownerSet||(e.ownerSet=i),L(e)||(e.parent=d)})),ge(d,[n]),d[`onCreate${t}`]=e=>(r(i,e),n.watch(e)),d[`create${t}`]=d[a]=(t,r)=>{let a=st({and:r,or:t});return null!=a&&a.domain?e(t,r):n(e(t,{parent:d,or:a}))}}));let f=L(d);return f&&t(d.hooks,((e,t)=>mt(e,f.hooks[t]))),null!=l&&l.domain&&l.domain.hooks.domain(d),d},e.createEffect=h,e.createEvent=u,e.createNode=i,e.createStore=p,e.createStoreObject=(...e)=>(ne(0,'createStoreObject','combine'),m(...e)),e.createWatch=({unit:e,fn:t,scope:r})=>{let a=[Re.run({fn:e=>t(e)})];if(r){let t=i({node:a}),n=e.graphite.id,o=r.additionalLinks,l=o[n]||[];return o[n]=l,l.push(t),w((()=>{let e=l.indexOf(t);-1!==e&&l.splice(e,1),ct(t)}))}{let t=i({node:a,parent:[e],family:{owners:e}});return w((()=>{ct(t)}))}},e.fork=(e,t)=>{let n,o=e;Y(e)&&(n=e,o=t);let l=(e=>{let t=i({scope:{defers:[],inFlight:0,fxID:0},node:[Ne(((e,t,r)=>{L(r)?'dec'===G(L(r).node,'needFxCounter')?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),Oe({priority:C,batch:1}),Ne(((e,t)=>{let{defers:a,fxID:n}=t;t.inFlight>0||0===a.length||Promise.resolve().then((()=>{t.fxID===n&&r(a.splice(0,a.length),(e=>{Ze(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),a=i({node:[Ne(((e,t,r)=>{let a=L(r);if(a){let t=a.node;if(!G(t,'isCombine')||L(a)&&'combine'!==G(L(a).node,'op')){let a=W(r),n=t.scope.state.id,i=G(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=G(t,'serialize');o&&a.sidSerializeSettings.set(i,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),n=i({node:[Ne(((e,t,r)=>{let a=W(r);if(a){let e=L(r);e&&(!G(e.node,'isCombine')||L(e)&&'combine'!==G(L(e).node,'op'))&&(a.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return at(Ye,o,null,e).current;let t=D(e);return at(Ye,o,t,t.scope.state,1).current},kind:z,graphite:i({family:{type:$,links:[t,a,n]},meta:{unit:'fork'},scope:{forkInFlightCounter:t}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:t,storeChange:a,warnSerializeNode:n,activeEffects:[]};return o})(n);if(o){let e=o.scope;if(e){let t=e.activeEffects;e.activeEffects=[],l.activeEffects=t,r(t,(e=>e.ref=l))}if(o.values){let{sidMap:e,unitMap:t}=k(o.values,(e=>a(K(e),'Values map can contain only stores as keys')));Object.assign(l.values.sidMap,e),r(t,((e,t)=>{l.values.idMap[t.stateRef.id]=e})),l.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map)}o.handlers&&(l.handlers=k(o.handlers,(e=>a(X(e),"Handlers map can contain only effects as keys"))))}return l},e.forward=e=>{let t='forward',[{from:r,to:a},n]=d(e,1);return Se(r,t,'"from"'),Se(a,t,'"to"'),Me(t,a,'to'),pt(i({parent:r,child:a,meta:{op:t,config:n},family:{},regional:1}))},e.fromObservable=e=>{ke(e);let t=S in e?e[S]():e;a(t.subscribe,'expect observable to have .subscribe');let r=u(),n=pt(r);return t.subscribe({next:r,error:n,complete:n}),r},e.guard=(...e)=>{let[[t,r],a]=d(e);return r||(r=t,t=r.source),b(r,'guard'),zt('guard',r.clock,t,r.filter,r.target,null,r.name,a,!r.greedy,0,1)},e.hydrate=(e,{values:t})=>{a(ye(t),'values property should be an object');let{sidMap:n,unitMap:i}=k(t),l=Object.getOwnPropertyNames(n),s={};r(i,((e,t)=>{s[t.stateRef.id]=t}));let d,f,u,c=[],p=[];Z(e)?(d=e,u=1,a(d.cloneOf,'scope should be created from domain'),f=D(d.cloneOf)):Y(e)?f=D(e):a(0,'first argument of hydrate should be domain or scope'),v(f,((e,t)=>{if(t&&te(l,t)){ae(c,e);let r=G(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),ae(p,n[t])}else e.scope.state.id in s&&(ae(c,e),ae(p,i.get(s[e.scope.state.id])))}),1),o({target:c,params:p,scope:d}),u&&Object.assign(d.values.sidMap,n)},e.is=ee,e.launch=o,e.merge=y,e.restore=(e,r,a)=>{if(K(e))return ne(0,'restore($store)'),e;if(Q(e)||X(e)){let t=L(e),n=p(r,{parent:t,name:e.shortName,and:a});return mt(X(e)?e.doneData:e,n),t&&t.hooks.store(n),n}let n=Array.isArray(e)?[]:{};return t(e,((e,t)=>n[t]=K(e)?e:p(e,{name:t}))),n},e.sample=(...e)=>{let t,r,a,n,[[i,o,l],s]=d(e),f=1;return ve(o)&&ye(i)&&b(i,F)&&(o=i.clock,l=i.fn,f=!i.greedy,n=i.filter,t=i.target,r=i.name,a=i.sid,i=i.source),zt(F,o,i,n,t,l,r,s,f,1,0,a)},e.scopeBind=(e,{scope:t,safe:r}={})=>{a(t||Je||r,'scopeBind cannot be called outside of forked .watch');let n=t||Je;return X(e)?t=>{let r=g();return o({target:e,params:{params:t,req:r},scope:n}),r.req}:t=>(o({target:e,params:t,scope:n}),t)},e.serialize=(e,r={})=>{e.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted');let n=r.ignore?r.ignore.map((({sid:e})=>e)):[],i={};return t(e.values.sidMap,((t,r)=>{var a;if(te(n,r))return;let o=e.sidIdMap[r],l=null!==(a=e.sidSerializeSettings.get(r))&&void 0!==a?a:{ignore:0,write:It};l.ignore||(i[r]=(0,l.write)(o&&o in e.reg?e.reg[o].current:t))})),'onlyChanges'in r&&!r.onlyChanges&&(a(e.cloneOf,'scope should be created from domain'),v(D(e.cloneOf),((t,r)=>{r in i||te(n,r)||G(t,'isCombine')||'ignore'===G(t,'serialize')||(i[r]=e.getState(t))}))),i},e.setGraphInspector=e=>{oe=e},e.setInspector=e=>{rt=e},e.setStoreName=(e,t)=>{e.shortName=t,Object.assign(U(e),s(t,L(e)))},e.split=(...e)=>{let r,n,o='split',[[l,s],c]=d(e),p=!s;p&&(r=l.cases,s=l.match,n=l.clock,l=l.source);let m=K(s),g=!V(s)&&be(s),h=!m&&!g&&ye(s);a(V(l),'source must be a unit'),r||(r={}),p?t(r,((e,t)=>Me(o,e,`cases.${t}`))):(a(h,'match should be an object'),t(s,((e,t)=>r[t]=u({derived:1,named:`cases.${t}`,and:c}))),r.__=u({derived:1,named:'cases.__',and:c}));let y,b=new Set([].concat(l,n||[],Object.values(r))),v=Object.keys(m||g?r:s);if(m||g)m&&b.add(s),y=[m&&qe(P(s),0,1),Oe({safe:m,filter:1,pure:!m,fn(e,t,r){let a=String(m?r.a:s(e));Ot(t,te(v,a)?a:'__',e,r)}})];else if(h){let e=De({});e.type='shape';let r,a=[];t(s,((t,n)=>{if(V(t)){r=1,ae(a,n),b.add(t);let i=mt(t,[],[qe(e),Ne(((e,t,{a:r})=>r[n]=e))]);if(K(t)){e.current[n]=t.getState();let r=P(t);_e(e,{from:r,field:n,type:'field'}),f('splitMatchStore',r,i)}}})),r&&f('splitBase',e),y=[r&&qe(e,0,1),Fe(((e,t,r)=>{for(let n=0;n<v.length;n++){let i=v[n];if(te(a,i)?r.a[i]:s[i](e))return void Ot(t,i,e,r)}Ot(t,'__',e,r)}),1)]}else a(0,'expect match to be unit, function or object');let k=i({meta:{op:o},parent:n?[]:l,scope:r,node:y,family:{owners:Array.from(b)},regional:1});if(n&&zt(o,n,l,null,k,null,o,c,0,0,0),!p)return r},e.step=Re,e.version="22.8.3",e.withFactory=({sid:e,name:t,loc:r,method:a,fn:o})=>n(i({meta:{sidRoot:me(e),sid:e,name:t,loc:r,method:a,type:'factory'}}),o),e.withRegion=n,Object.defineProperty(e,'__esModule',{value:1})})); | ||
//# sourceMappingURL=effector.umd.js.map |
{ | ||
"name": "effector", | ||
"version": "22.8.2", | ||
"version": "22.8.3", | ||
"description": "Business logic with ease", | ||
@@ -5,0 +5,0 @@ "main": "effector.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1391364
16703