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