atomic-router
Advanced tools
Comparing version 0.6.1 to 0.6.2
@@ -1,2 +0,2 @@ | ||
function e(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,n)}return t}function r(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?e(Object(n),1).forEach((e=>{o(r,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((e=>{Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function t(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:1,configurable:1,writable:1}),e[r]}function r(e,r,t,o){var i=Object.create((r&&r.prototype instanceof a?r:a).prototype),c=new l(o||[]);return i._invoke=((e,r,t)=>{var a="suspendedStart";return(o,i)=>{if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===o)throw i;return{value:void 0,done:1}}for(t.method=o,t.arg=i;;){var c=t.delegate;if(c){var s=u(c,t);if(s){if(s===k)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===a)throw a="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);a="executing";var d=n(e,r,t);if("normal"===d.type){if(a=t.done?"completed":"suspendedYield",d.arg===k)continue;return{value:d.arg,done:t.done}}"throw"===d.type&&(a="completed",t.method="throw",t.arg=d.arg)}}})(e,t,c),i}function n(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function a(){}function o(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function s(e,r){function t(a,o,i,c){var s=n(e[a],e,o);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&v.call(d,"__await")?r.resolve(d.__await).then((e=>{t("next",e,i,c)}),(e=>{t("throw",e,i,c)})):r.resolve(d).then((e=>{u.value=e,i(u)}),(e=>t("throw",e,i,c)))}c(s.arg)}var a;this._invoke=(e,n)=>{function o(){return new r(((r,a)=>{t(e,n,r,a)}))}return a=a?a.then(o,o):o()}}function u(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,u(e,r),"throw"===r.method))return k;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return k}var a=n(t,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,k;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,k):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,k)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function p(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function l(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(1)}function h(e){if(e){var r=e[b];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(v.call(e,t))return r.value=e[t],r.done=0,r;return r.value=void 0,r.done=1,r};return n.next=n}}return{next:f}}function f(){return{value:void 0,done:1}}t=()=>m;var m={},y=Object.prototype,v=y.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},b=g.iterator||"@@iterator",w=g.asyncIterator||"@@asyncIterator",O=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var k={},x={};e(x,b,(function(){return this}));var j=Object.getPrototypeOf,q=j&&j(j(h([])));q&&q!==y&&v.call(q,b)&&(x=q);var E=i.prototype=a.prototype=Object.create(x);return o.prototype=i,e(E,"constructor",i),e(i,"constructor",o),o.displayName=e(i,O,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===o||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,O,"GeneratorFunction")),r.prototype=Object.create(E),r),m.awrap=e=>({__await:e}),c(s.prototype),e(s.prototype,w,(function(){return this})),m.AsyncIterator=s,m.async=(e,t,n,a,o)=>{void 0===o&&(o=Promise);var i=new s(r(e,t,n,a),o);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(E),e(E,O,"Generator"),e(E,b,(function(){return this})),e(E,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=0,t}return t.done=1,t}},m.values=h,l.prototype={constructor:l,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=0,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(p),!e)for(var r in this)"t"===r.charAt(0)&&v.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=1;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}if(this.done)throw e;for(var t=this,n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var i=v.call(a,"catchLoc"),c=v.call(a,"finallyLoc");if(i&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,1);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(i){if(this.prev<a.catchLoc)return r(a.catchLoc,1)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&v.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=r,a?(this.method="next",this.next=a.finallyLoc,k):this.complete(o)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),k},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),p(t),k}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;p(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:h(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),k}},m}function n(e,r,t,n,a,o,i){try{var c=e[o](i),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,a)}function a(e){return function(){var r=this,t=arguments;return new Promise(((a,o)=>{function i(e){n(s,a,o,i,c,"next",e)}function c(e){n(s,a,o,i,c,"throw",e)}var s=e.apply(r,t);i(void 0)}))}}function o(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:1,configurable:1,writable:1}):e[r]=t,e}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function c(e,r){var it="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(it)return(it=it.call(e)).next.bind(it);if(Array.isArray(e)||(it=((e,r)=>{if(e){if("string"==typeof e)return i(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:1}:{done:0,value:e[t++]}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e){var r=e.params,t=e.query;return d.compile(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function u(e){var r=e.actualPath,t=d.match(e.pathCreator.replace('://','\\://'))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return t?{matches:1,params:t.params}:{matches:0}}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector'),d=require('path-to-regexp'),p={ROUTE:Symbol()},l=function(e){void 0===e&&(e={});var r=effector.createEffect(function(){var e=a(t().mark((function e(r){return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{}});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"-1r3y8c"}),n=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"betlrc"}}),o=effector.createStore(0,{name:"$isOpened",sid:"-lpbmtu"}),i=effector.createStore({},{name:"$params",sid:"-s1jw4p"}),c=effector.createStore({},{name:"$query",sid:"-sl9wq7"}),s=effector.createEvent({name:"opened",sid:"gya9jo"}),u=effector.createEvent({name:"updated",sid:"-a825r0"}),d=effector.createEvent({name:"left",sid:"-3vusfj"}),l=effector.createEvent({name:"closed",sid:"du28m6"});return o.on(s,(()=>1)).on(d,(()=>0)),i.on(s,((e,r)=>r.params)).on(u,((e,r)=>r.params)),c.on(s,((e,r)=>r.query)).on(u,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:o.map((e=>e?'updated':'opened')),cases:{opened:s,updated:u}}],or:{sid:"-vrcd1r"}}),effector.sample({and:[{clock:l,target:d}],or:{sid:"-vauj8x"}}),e.filter&&effector.split({and:[{source:effector.sample({and:[{clock:e.filter}],or:{name:"source",sid:"hc5kab"}}),match:e=>e?'true':'false',cases:{true:s,false:l}}],or:{sid:"-v6zz1o"}}),{$isOpened:o,$params:i,$query:c,opened:s,updated:u,closed:l,left:d,navigate:r,open:n,kind:p.ROUTE,settings:{derived:Boolean(e.filter)}}},h=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return 0;for(var t in e)if(""+e[t]!=""+r[t])return 0;return 1},f=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===p.ROUTE,m=effector.createEffect((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),y=e=>effector.is.store(e,{sid:"gjk14e"})?e:effector.createStore(e,{sid:"fmgfpp"});exports.Kind=p,exports.buildPath=s,exports.chainRoute=e=>{var t=(e=>{if(f(e))return{route:e,chainedRoute:effector.withFactory({sid:"wj2jy7",fn:()=>l(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"uyxd6d"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:effector.merge([effector.createEvent({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var t=r({},e);if(effector.is.unit(t.beforeOpen)||(t.beforeOpen=effector.attach({and:t.beforeOpen,or:{sid:"-gadjdw"}})),effector.is.effect(t.beforeOpen,{sid:"ohaial"}))return{route:t.route,chainedRoute:t.chainedRoute||effector.withFactory({sid:"-cgk8n3",fn:()=>l(),name:"chainedRoute",method:"createRoute"}),beforeOpen:t.beforeOpen,openOn:'openOn'in t?t.openOn:t.beforeOpen.doneData,cancelOn:'cancelOn'in t?t.cancelOn:t.beforeOpen.failData};var n=e;return{route:n.route,chainedRoute:n.chainedRoute||effector.withFactory({sid:"rtbqmw",fn:()=>l(),name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:effector.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:effector.sample({and:[{clock:n.cancelOn||effector.createEvent({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),n=t.route,a=t.chainedRoute,o=t.beforeOpen,i=t.openOn,c=t.cancelOn,s=effector.createStore({},{name:"$params",sid:"-e7xr51"}),u=effector.createStore({},{name:"$query",sid:"-mfs2i3"}),d=effector.combine({and:[effector.combine({and:[[n.$params,n.$query]],or:{name:"and",sid:"-34jx4h"}}),effector.combine({and:[[s,u]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),p=effector.sample({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});effector.sample({and:[{clock:p,target:o}],or:{sid:"ggm0br"}}),s.on(p,((e,r)=>r.params)),u.on(p,((e,r)=>r.query));var h=effector.guard({and:[{clock:i,source:{params:s,query:u},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});effector.sample({and:[{clock:h,target:a.navigate}],or:{sid:"gyr7wo"}});var m=effector.merge([n.closed,c],{name:"aborted",sid:"4m2b1e"});return s.reset(m),u.reset(m),effector.sample({and:[{clock:m,target:a.closed}],or:{sid:"hf91pi"}}),a},exports.createHistoryRouter=function(e){var n=((e,t)=>{void 0===t&&(t='');for(var n,a=[],o=()=>{var e,t=n.value;Array.isArray(t.route)?(e=a).push.apply(e,t.route.map((e=>r(r({},t),{},{route:e})))):a.push(t)},i=c(e);!(n=i()).done;)o();a=a.map((e=>r(r({},e),{},{path:""+t+e.path})));for(var s,u=[],d=[],p=c(a);!(s=p()).done;){var l=s.value;l.route.settings.derived?u.push(l):d.push(l)}if(u.length)for(var h,f=c(u);!(h=f()).done;)console.error("createHistoryRouter: "+h.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),o=effector.createEvent({name:"setHistory",sid:"-7gknvs"}),i=effector.createEvent({name:"routeNotFound",sid:"-z1d04m"}),d=effector.createStore({},{name:"$query",sid:"-5p9ozk"}),p=effector.createStore('',{name:"$path",sid:"-npzcwr"}),l=effector.createStore([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"x18bma"}),y=effector.createStore(0,{name:"$isFirstCheckPassed",sid:"-m3xotb"}),v=effector.createStore(null,{and:{serialize:'ignore'},name:"$history",sid:"pamx59"});v.on(o,((e,r)=>r));var g=effector.attach({and:{source:{history:v},effect:m,mapParams:(e,t)=>r({history:t.history},e)},or:{name:"pushFx",sid:"8huosv"}}),b=effector.createEffect((e=>{var r=e.params,t=e.query;return{path:s({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:'push'}}),{name:"openedFx",sid:"q4jus9"}),w=effector.createEffect((e=>{for(var r,t=e.path,a=e.query,o=e.hash,i=[],s=[],d=c(n);!(r=d()).done;){var p=r.value,l=p.path.includes('#')?""+t+o:""+t,h=u({pathCreator:""+p.path,actualPath:l});(h.matches?i:s).push({route:p,params:h.params,query:a})}var f=e=>{var r=e;i.some((e=>e.route.route===s[r].route.route))&&(s[r]=null)};for(var m in s)f(m);return s=s.filter(Boolean),{opened:i,closed:s}}),{name:"recalculateFx",sid:"p5mrym"});p.on(w.done,((e,r)=>r.params.path)),d.on(w.done,((e,r)=>r.params.query)),l.on(w.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),effector.sample({and:[{clock:b.doneData,target:g}],or:{sid:"-57xmhh"}}),effector.guard({and:[{clock:w.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4esj1c"}});for(var O,k=w.doneData.map((e=>e.opened)),x=w.doneData.map((e=>e.closed)),j=()=>{var e=O.value,r=effector.createStore(0,{name:"$isOpenedManually",sid:"bvkm8m"}),t=e.route.navigate.done;effector.sample({and:[{clock:t,fn:r=>{var t=r.result;return{route:e,params:t.params,query:t.query}},target:b}],or:{sid:"-3uzxmm"}});var n=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},a={opened:effector.guard({and:[{clock:k.filterMap(n),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"5wpt54"}}),updated:effector.guard({and:[{clock:k.filterMap(n),filter:e.route.$isOpened}],or:{name:"updated",sid:"-i5q4hs"}}),closed:effector.guard({and:[{clock:x.filterMap(n),filter:e.route.$isOpened}],or:{name:"closed",sid:"id1lfy"}})};r.on(t,(()=>1));var o=effector.guard({and:[{clock:a.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-1l5c2l"}});effector.sample({and:[{source:effector.restore(o,null,{name:"source",sid:"f5o03n"}),clock:effector.guard({and:[{clock:o,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!h(e[0],r.params)||!h(t,r.query)}}],or:{name:"clock",sid:"tci0vq"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1jf7fq"}}),effector.guard({and:[{clock:a.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"-yj0w0"}}),effector.sample({and:[{clock:a.closed,target:e.route.closed}],or:{sid:"9eta07"}}),r.reset(effector.sample({and:[{clock:k}],or:{sid:"kez4m6"}}))},q=c(n);!(O=q()).done;)j();if(f(e.notFoundRoute)){var E=effector.sample({and:[{clock:l,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"39vknv"}});effector.sample({and:[{clock:E,source:{query:d},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"accq78"}}),effector.sample({and:[{clock:E,source:{query:d},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"asuk02"}}),effector.sample({and:[{clock:E,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"b9cdsw"}})}var R,L=effector.attach({and:{source:{history:v},effect:(R=a(t().mark((function e(r){var n,a;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return a=[(n=r.history).location.pathname,Object.fromEntries(new URLSearchParams(n.location.search)),n.location.hash],e.abrupt("return",{path:a[0],query:a[1],hash:a[2]});case 3:case"end":return e.stop()}}),e)}))),function(e){return R.apply(this,arguments)})},or:{name:"recheckFx",sid:"-pkcc0g"}});effector.sample({and:[{source:L.doneData,target:w}],or:{sid:"coh8xr"}});var S,P=effector.attach({and:{source:{history:v},effect:(S=a(t().mark((function e(r){var n,a;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:n=r.history,a=L;try{a=effector.scopeBind(L)}catch(e){}return n.listen((()=>{a()})),e.abrupt("return",1);case 5:case"end":return e.stop()}}),e)}))),function(e){return S.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-rq379k"}});e.hydrate||effector.sample({and:[{clock:P.doneData,target:L}],or:{sid:"dpv9c1"}}),effector.sample({and:[{clock:v,target:P}],or:{sid:"o2nrl5"}}),y.on(w.doneData,(()=>1)).reset(v);var $=effector.sample({and:[{clock:effector.guard({and:[{clock:y,filter:Boolean}],or:{name:"clock",sid:"-g82n00"}}),source:{activeRoutes:l,path:p,query:d}}],or:{name:"initialized",sid:"-1il1ih"}});return{$path:p,$query:d,$activeRoutes:l,$history:v,setHistory:o,push:g,routes:n,initialized:$,routeNotFound:i}},exports.createRoute=l,exports.isRoute=f,exports.matchPath=u,exports.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):effector.createEvent({name:"clock",sid:"-oj7ut5"}),t=y(e.params||{}),n=y(e.query||{});return effector.sample({and:[{clock:r,source:{params:t,query:n},fn:(e,r)=>{var t=e.params,n=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),r}; | ||
function e(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,n)}return t}function r(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?e(Object(n),!0).forEach((e=>{o(r,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((e=>{Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function t(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}function r(e,r,t,o){var i=Object.create((r&&r.prototype instanceof a?r:a).prototype),c=new l(o||[]);return i._invoke=((e,r,t)=>{var a="suspendedStart";return(o,i)=>{if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===o)throw i;return{value:void 0,done:!0}}for(t.method=o,t.arg=i;;){var c=t.delegate;if(c){var s=u(c,t);if(s){if(s===k)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===a)throw a="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);a="executing";var d=n(e,r,t);if("normal"===d.type){if(a=t.done?"completed":"suspendedYield",d.arg===k)continue;return{value:d.arg,done:t.done}}"throw"===d.type&&(a="completed",t.method="throw",t.arg=d.arg)}}})(e,t,c),i}function n(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function a(){}function o(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function s(e,r){function t(a,o,i,c){var s=n(e[a],e,o);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&v.call(d,"__await")?r.resolve(d.__await).then((e=>{t("next",e,i,c)}),(e=>{t("throw",e,i,c)})):r.resolve(d).then((e=>{u.value=e,i(u)}),(e=>t("throw",e,i,c)))}c(s.arg)}var a;this._invoke=(e,n)=>{function o(){return new r(((r,a)=>{t(e,n,r,a)}))}return a=a?a.then(o,o):o()}}function u(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,u(e,r),"throw"===r.method))return k;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return k}var a=n(t,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,k;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,k):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,k)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function p(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function l(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(!0)}function h(e){if(e){var r=e[b];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(v.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return n.next=n}}return{next:f}}function f(){return{value:void 0,done:!0}}t=()=>m;var m={},y=Object.prototype,v=y.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},b=g.iterator||"@@iterator",w=g.asyncIterator||"@@asyncIterator",O=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var k={},x={};e(x,b,(function(){return this}));var j=Object.getPrototypeOf,q=j&&j(j(h([])));q&&q!==y&&v.call(q,b)&&(x=q);var E=i.prototype=a.prototype=Object.create(x);return o.prototype=i,e(E,"constructor",i),e(i,"constructor",o),o.displayName=e(i,O,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===o||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,O,"GeneratorFunction")),r.prototype=Object.create(E),r),m.awrap=e=>({__await:e}),c(s.prototype),e(s.prototype,w,(function(){return this})),m.AsyncIterator=s,m.async=(e,t,n,a,o)=>{void 0===o&&(o=Promise);var i=new s(r(e,t,n,a),o);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(E),e(E,O,"Generator"),e(E,b,(function(){return this})),e(E,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},m.values=h,l.prototype={constructor:l,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(p),!e)for(var r in this)"t"===r.charAt(0)&&v.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}if(this.done)throw e;for(var t=this,n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var i=v.call(a,"catchLoc"),c=v.call(a,"finallyLoc");if(i&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(i){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&v.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=r,a?(this.method="next",this.next=a.finallyLoc,k):this.complete(o)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),k},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),p(t),k}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;p(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:h(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),k}},m}function n(e,r,t,n,a,o,i){try{var c=e[o](i),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,a)}function a(e){return function(){var r=this,t=arguments;return new Promise(((a,o)=>{function i(e){n(s,a,o,i,c,"next",e)}function c(e){n(s,a,o,i,c,"throw",e)}var s=e.apply(r,t);i(void 0)}))}}function o(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function c(e,r){var it="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(it)return(it=it.call(e)).next.bind(it);if(Array.isArray(e)||(it=((e,r)=>{if(e){if("string"==typeof e)return i(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:!0}:{done:!1,value:e[t++]}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e){var r=e.params,t=e.query;return d.compile(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function u(e){var r=e.actualPath,t=d.match(e.pathCreator.replace('://','\\://'))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return t?{matches:!0,params:t.params}:{matches:!1}}Object.defineProperty(exports,'__esModule',{value:!0});var effector=require('effector'),d=require('path-to-regexp'),p={ROUTE:Symbol()},l=function(e){void 0===e&&(e={});var r=effector.createEffect(function(){var e=a(t().mark((function e(r){return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{}});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"-1r3y8c"}),n=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"betlrc"}}),o=effector.createStore(!1,{name:"$isOpened",sid:"-lpbmtu"}),i=effector.createStore({},{name:"$params",sid:"-s1jw4p"}),c=effector.createStore({},{name:"$query",sid:"-sl9wq7"}),s=effector.createEvent({name:"opened",sid:"gya9jo"}),u=effector.createEvent({name:"updated",sid:"-a825r0"}),d=effector.createEvent({name:"left",sid:"-3vusfj"}),l=effector.createEvent({name:"closed",sid:"du28m6"});return o.on(s,(()=>!0)).on(d,(()=>!1)),i.on(s,((e,r)=>r.params)).on(u,((e,r)=>r.params)),c.on(s,((e,r)=>r.query)).on(u,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:o.map((e=>e?'updated':'opened')),cases:{opened:s,updated:u}}],or:{sid:"-vrcd1r"}}),effector.sample({and:[{clock:l,target:d}],or:{sid:"-vauj8x"}}),e.filter&&effector.split({and:[{source:effector.sample({and:[{clock:e.filter}],or:{name:"source",sid:"hc5kab"}}),match:e=>e?'true':'false',cases:{true:s,false:l}}],or:{sid:"-v6zz1o"}}),{$isOpened:o,$params:i,$query:c,opened:s,updated:u,closed:l,left:d,navigate:r,open:n,kind:p.ROUTE,settings:{derived:Boolean(e.filter)}}},h=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return!1;for(var t in e)if(""+e[t]!=""+r[t])return!1;return!0},f=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===p.ROUTE,m=effector.createEffect((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),y=e=>effector.is.store(e,{sid:"gjk14e"})?e:effector.createStore(e,{sid:"fmgfpp"});exports.Kind=p,exports.buildPath=s,exports.chainRoute=e=>{var t=(e=>{if(f(e))return{route:e,chainedRoute:effector.withFactory({sid:"wj2jy7",fn:()=>l(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"uyxd6d"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:effector.merge([effector.createEvent({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var t=r({},e);if(effector.is.unit(t.beforeOpen)||(t.beforeOpen=effector.attach({and:t.beforeOpen,or:{sid:"-gadjdw"}})),effector.is.effect(t.beforeOpen,{sid:"ohaial"}))return{route:t.route,chainedRoute:t.chainedRoute||effector.withFactory({sid:"-cgk8n3",fn:()=>l(),name:"chainedRoute",method:"createRoute"}),beforeOpen:t.beforeOpen,openOn:'openOn'in t?t.openOn:t.beforeOpen.doneData,cancelOn:'cancelOn'in t?t.cancelOn:t.beforeOpen.failData};var n=e;return{route:n.route,chainedRoute:n.chainedRoute||effector.withFactory({sid:"rtbqmw",fn:()=>l(),name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:effector.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:effector.sample({and:[{clock:n.cancelOn||effector.createEvent({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),n=t.route,a=t.chainedRoute,o=t.beforeOpen,i=t.openOn,c=t.cancelOn,s=effector.createStore({},{name:"$params",sid:"-e7xr51"}),u=effector.createStore({},{name:"$query",sid:"-mfs2i3"}),d=effector.combine({and:[effector.combine({and:[[n.$params,n.$query]],or:{name:"and",sid:"-34jx4h"}}),effector.combine({and:[[s,u]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),p=effector.sample({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});effector.sample({and:[{clock:p,target:o}],or:{sid:"ggm0br"}}),s.on(p,((e,r)=>r.params)),u.on(p,((e,r)=>r.query));var h=effector.guard({and:[{clock:i,source:{params:s,query:u},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});effector.sample({and:[{clock:h,target:a.navigate}],or:{sid:"gyr7wo"}});var m=effector.merge([n.closed,c],{name:"aborted",sid:"4m2b1e"});return s.reset(m),u.reset(m),effector.sample({and:[{clock:m,target:a.closed}],or:{sid:"hf91pi"}}),a},exports.createHistoryRouter=function(e){var n=((e,t)=>{void 0===t&&(t='');for(var n,a=[],o=()=>{var e,t=n.value;Array.isArray(t.route)?(e=a).push.apply(e,t.route.map((e=>r(r({},t),{},{route:e})))):a.push(t)},i=c(e);!(n=i()).done;)o();a=a.map((e=>r(r({},e),{},{path:""+t+e.path})));for(var s,u=[],d=[],p=c(a);!(s=p()).done;){var l=s.value;l.route.settings.derived?u.push(l):d.push(l)}if(u.length)for(var h,f=c(u);!(h=f()).done;)console.error("createHistoryRouter: "+h.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),o=effector.createEvent({name:"setHistory",sid:"-7gknvs"}),i=effector.createEvent({name:"routeNotFound",sid:"-z1d04m"}),d=effector.createStore({},{name:"$query",sid:"-5p9ozk"}),p=effector.createStore('',{name:"$path",sid:"-npzcwr"}),l=effector.createStore([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"x18bma"}),y=effector.createStore(!1,{name:"$isFirstCheckPassed",sid:"-m3xotb"}),v=effector.createStore(null,{and:{serialize:'ignore'},name:"$history",sid:"pamx59"});v.on(o,((e,r)=>r));var g=effector.attach({and:{source:{history:v},effect:m,mapParams:(e,t)=>r({history:t.history},e)},or:{name:"pushFx",sid:"8huosv"}}),b=effector.createEffect((e=>{var r=e.params,t=e.query;return{path:s({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:'push'}}),{name:"openedFx",sid:"q4jus9"}),w=effector.createEffect((e=>{for(var r,t=e.path,a=e.query,o=e.hash,i=[],s=[],d=c(n);!(r=d()).done;){var p=r.value,l=p.path.includes('#')?""+t+o:""+t,h=u({pathCreator:""+p.path,actualPath:l});(h.matches?i:s).push({route:p,params:h.params,query:a})}var f=e=>{var r=e;i.some((e=>e.route.route===s[r].route.route))&&(s[r]=null)};for(var m in s)f(m);return s=s.filter(Boolean),{opened:i,closed:s}}),{name:"recalculateFx",sid:"p5mrym"});p.on(w.done,((e,r)=>r.params.path)),d.on(w.done,((e,r)=>r.params.query)),l.on(w.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),effector.sample({and:[{clock:b.doneData,target:g}],or:{sid:"-57xmhh"}}),effector.guard({and:[{clock:w.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4esj1c"}});for(var O,k=w.doneData.map((e=>e.opened)),x=w.doneData.map((e=>e.closed)),j=()=>{var e=O.value,r=effector.createStore(!1,{name:"$isOpenedManually",sid:"bvkm8m"}),t=e.route.navigate.done;effector.sample({and:[{clock:t,fn:r=>{var t=r.result;return{route:e,params:t.params,query:t.query}},target:b}],or:{sid:"-3uzxmm"}});var n=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},a={opened:effector.guard({and:[{clock:k.filterMap(n),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"5wpt54"}}),updated:effector.guard({and:[{clock:k.filterMap(n),filter:e.route.$isOpened}],or:{name:"updated",sid:"-i5q4hs"}}),closed:effector.guard({and:[{clock:x.filterMap(n),filter:e.route.$isOpened}],or:{name:"closed",sid:"id1lfy"}})};r.on(t,(()=>!0));var o=effector.guard({and:[{clock:a.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-1l5c2l"}});effector.sample({and:[{source:effector.restore(o,null,{name:"source",sid:"f5o03n"}),clock:effector.guard({and:[{clock:o,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!h(e[0],r.params)||!h(t,r.query)}}],or:{name:"clock",sid:"tci0vq"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1jf7fq"}}),effector.guard({and:[{clock:a.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"-yj0w0"}}),effector.sample({and:[{clock:a.closed,target:e.route.closed}],or:{sid:"9eta07"}}),r.reset(effector.sample({and:[{clock:k}],or:{sid:"kez4m6"}}))},q=c(n);!(O=q()).done;)j();if(f(e.notFoundRoute)){var E=effector.sample({and:[{clock:l,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"39vknv"}});effector.sample({and:[{clock:E,source:{query:d},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"accq78"}}),effector.sample({and:[{clock:E,source:{query:d},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"asuk02"}}),effector.sample({and:[{clock:E,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"b9cdsw"}})}var R,L=effector.attach({and:{source:{history:v},effect:(R=a(t().mark((function e(r){var n,a;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return a=[(n=r.history).location.pathname,Object.fromEntries(new URLSearchParams(n.location.search)),n.location.hash],e.abrupt("return",{path:a[0],query:a[1],hash:a[2]});case 3:case"end":return e.stop()}}),e)}))),function(e){return R.apply(this,arguments)})},or:{name:"recheckFx",sid:"-pkcc0g"}});effector.sample({and:[{source:L.doneData,target:w}],or:{sid:"coh8xr"}});var S,P=effector.attach({and:{source:{history:v},effect:(S=a(t().mark((function e(r){var n,a;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:n=r.history,a=L;try{a=effector.scopeBind(L)}catch(e){}return n.listen((()=>{a()})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e)}))),function(e){return S.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-rq379k"}});e.hydrate||effector.sample({and:[{clock:P.doneData,target:L}],or:{sid:"dpv9c1"}}),effector.sample({and:[{clock:v,target:P}],or:{sid:"o2nrl5"}}),y.on(w.doneData,(()=>!0)).reset(v);var $=effector.sample({and:[{clock:effector.guard({and:[{clock:y,filter:Boolean}],or:{name:"clock",sid:"-g82n00"}}),source:{activeRoutes:l,path:p,query:d}}],or:{name:"initialized",sid:"-1il1ih"}});return{$path:p,$query:d,$activeRoutes:l,$history:v,setHistory:o,push:g,routes:n,initialized:$,routeNotFound:i}},exports.createRoute=l,exports.isRoute=f,exports.matchPath=u,exports.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):effector.createEvent({name:"clock",sid:"-oj7ut5"}),t=y(e.params||{}),n=y(e.query||{});return effector.sample({and:[{clock:r,source:{params:t,query:n},fn:(e,r)=>{var t=e.params,n=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),r}; | ||
//# sourceMappingURL=atomic-router.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,n)}return t}function r(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?e(Object(n),1).forEach((e=>{a(r,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((e=>{Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function t(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:1,configurable:1,writable:1}),e[r]}function r(e,r,t,a){var i=Object.create((r&&r.prototype instanceof o?r:o).prototype),c=new p(a||[]);return i._invoke=((e,r,t)=>{var o="suspendedStart";return(a,i)=>{if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===a)throw i;return{value:void 0,done:1}}for(t.method=a,t.arg=i;;){var c=t.delegate;if(c){var s=u(c,t);if(s){if(s===k)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===o)throw o="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);o="executing";var d=n(e,r,t);if("normal"===d.type){if(o=t.done?"completed":"suspendedYield",d.arg===k)continue;return{value:d.arg,done:t.done}}"throw"===d.type&&(o="completed",t.method="throw",t.arg=d.arg)}}})(e,t,c),i}function n(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function s(e,r){function t(o,a,i,c){var s=n(e[o],e,a);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&v.call(d,"__await")?r.resolve(d.__await).then((e=>{t("next",e,i,c)}),(e=>{t("throw",e,i,c)})):r.resolve(d).then((e=>{u.value=e,i(u)}),(e=>t("throw",e,i,c)))}c(s.arg)}var o;this._invoke=(e,n)=>{function a(){return new r(((r,o)=>{t(e,n,r,o)}))}return o=o?o.then(a,a):a()}}function u(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,u(e,r),"throw"===r.method))return k;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return k}var o=n(t,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,k;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,k):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,k)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function l(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function p(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(1)}function h(e){if(e){var r=e[b];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(v.call(e,t))return r.value=e[t],r.done=0,r;return r.value=void 0,r.done=1,r};return n.next=n}}return{next:f}}function f(){return{value:void 0,done:1}}t=()=>m;var m={},y=Object.prototype,v=y.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},b=g.iterator||"@@iterator",O=g.asyncIterator||"@@asyncIterator",w=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var k={},x={};e(x,b,(function(){return this}));var j=Object.getPrototypeOf,q=j&&j(j(h([])));q&&q!==y&&v.call(q,b)&&(x=q);var R=i.prototype=o.prototype=Object.create(x);return a.prototype=i,e(R,"constructor",i),e(i,"constructor",a),a.displayName=e(i,w,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===a||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,w,"GeneratorFunction")),r.prototype=Object.create(R),r),m.awrap=e=>({__await:e}),c(s.prototype),e(s.prototype,O,(function(){return this})),m.AsyncIterator=s,m.async=(e,t,n,o,a)=>{void 0===a&&(a=Promise);var i=new s(r(e,t,n,o),a);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(R),e(R,w,"Generator"),e(R,b,(function(){return this})),e(R,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=0,t}return t.done=1,t}},m.values=h,p.prototype={constructor:p,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=0,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!e)for(var r in this)"t"===r.charAt(0)&&v.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=1;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}if(this.done)throw e;for(var t=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var i=v.call(o,"catchLoc"),c=v.call(o,"finallyLoc");if(i&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,1);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return r(o.catchLoc,1)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&v.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,k):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),k},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),l(t),k}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;l(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:h(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),k}},m}function n(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,o)}function o(e){return function(){var r=this,t=arguments;return new Promise(((o,a)=>{function i(e){n(s,o,a,i,c,"next",e)}function c(e){n(s,o,a,i,c,"throw",e)}var s=e.apply(r,t);i(void 0)}))}}function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:1,configurable:1,writable:1}):e[r]=t,e}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function c(e,r){var it="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(it)return(it=it.call(e)).next.bind(it);if(Array.isArray(e)||(it=((e,r)=>{if(e){if("string"==typeof e)return i(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:1}:{done:0,value:e[t++]}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e){var r=e.params,t=e.query;return j(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function u(e){var r=e.actualPath,t=q(e.pathCreator.replace('://','\\://'))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return t?{matches:1,params:t.params}:{matches:0}}function d(e){var t=(e=>{if($(e))return{route:e,chainedRoute:x({sid:"wj2jy7",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:f({name:"beforeOpen",sid:"uyxd6d"}),openOn:k([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:k([f({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var t=r({},e);if(O.unit(t.beforeOpen)||(t.beforeOpen=p({and:t.beforeOpen,or:{sid:"-gadjdw"}})),O.effect(t.beforeOpen,{sid:"ohaial"}))return{route:t.route,chainedRoute:t.chainedRoute||x({sid:"-cgk8n3",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:t.beforeOpen,openOn:'openOn'in t?t.openOn:t.beforeOpen.doneData,cancelOn:'cancelOn'in t?t.cancelOn:t.beforeOpen.failData};var n=e;return{route:n.route,chainedRoute:n.chainedRoute||x({sid:"rtbqmw",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:y({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:y({and:[{clock:n.cancelOn||f({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),n=t.route,o=t.chainedRoute,a=t.beforeOpen,i=t.openOn,c=t.cancelOn,s=h({},{name:"$params",sid:"-e7xr51"}),u=h({},{name:"$query",sid:"-mfs2i3"}),d=w({and:[w({and:[[n.$params,n.$query]],or:{name:"and",sid:"-34jx4h"}}),w({and:[[s,u]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),l=y({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});y({and:[{clock:l,target:a}],or:{sid:"ggm0br"}}),s.on(l,((e,r)=>r.params)),u.on(l,((e,r)=>r.query));var m=v({and:[{clock:i,source:{params:s,query:u},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});y({and:[{clock:m,target:o.navigate}],or:{sid:"gyr7wo"}});var g=k([n.closed,c],{name:"aborted",sid:"4m2b1e"});return s.reset(g),u.reset(g),y({and:[{clock:g,target:o.closed}],or:{sid:"hf91pi"}}),o}import{createEffect as l,attach as p,createStore as h,createEvent as f,split as m,sample as y,guard as v,restore as g,scopeBind as b,is as O,combine as w,merge as k,withFactory as x}from'effector';import{compile as j,match as q}from'path-to-regexp';var R={ROUTE:Symbol()},L=function(e){void 0===e&&(e={});var r=l(function(){var e=o(t().mark((function e(r){return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{}});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"-1r3y8c"}),n=p({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"betlrc"}}),a=h(0,{name:"$isOpened",sid:"-lpbmtu"}),i=h({},{name:"$params",sid:"-s1jw4p"}),c=h({},{name:"$query",sid:"-sl9wq7"}),s=f({name:"opened",sid:"gya9jo"}),u=f({name:"updated",sid:"-a825r0"}),d=f({name:"left",sid:"-3vusfj"}),v=f({name:"closed",sid:"du28m6"});return a.on(s,(()=>1)).on(d,(()=>0)),i.on(s,((e,r)=>r.params)).on(u,((e,r)=>r.params)),c.on(s,((e,r)=>r.query)).on(u,((e,r)=>r.query)),m({and:[{source:r.doneData,match:a.map((e=>e?'updated':'opened')),cases:{opened:s,updated:u}}],or:{sid:"-vrcd1r"}}),y({and:[{clock:v,target:d}],or:{sid:"-vauj8x"}}),e.filter&&m({and:[{source:y({and:[{clock:e.filter}],or:{name:"source",sid:"hc5kab"}}),match:e=>e?'true':'false',cases:{true:s,false:v}}],or:{sid:"-v6zz1o"}}),{$isOpened:a,$params:i,$query:c,opened:s,updated:u,closed:v,left:d,navigate:r,open:n,kind:R.ROUTE,settings:{derived:Boolean(e.filter)}}},E=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return 0;for(var t in e)if(""+e[t]!=""+r[t])return 0;return 1},$=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===R.ROUTE,P=l((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),F=function(e){var n=((e,t)=>{void 0===t&&(t='');for(var n,o=[],a=()=>{var e,t=n.value;Array.isArray(t.route)?(e=o).push.apply(e,t.route.map((e=>r(r({},t),{},{route:e})))):o.push(t)},i=c(e);!(n=i()).done;)a();o=o.map((e=>r(r({},e),{},{path:""+t+e.path})));for(var s,u=[],d=[],l=c(o);!(s=l()).done;){var p=s.value;p.route.settings.derived?u.push(p):d.push(p)}if(u.length)for(var h,f=c(u);!(h=f()).done;)console.error("createHistoryRouter: "+h.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),a=f({name:"setHistory",sid:"-7gknvs"}),i=f({name:"routeNotFound",sid:"-z1d04m"}),d=h({},{name:"$query",sid:"-5p9ozk"}),m=h('',{name:"$path",sid:"-npzcwr"}),O=h([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"x18bma"}),w=h(0,{name:"$isFirstCheckPassed",sid:"-m3xotb"}),k=h(null,{and:{serialize:'ignore'},name:"$history",sid:"pamx59"});k.on(a,((e,r)=>r));var x=p({and:{source:{history:k},effect:P,mapParams:(e,t)=>r({history:t.history},e)},or:{name:"pushFx",sid:"8huosv"}}),j=l((e=>{var r=e.params,t=e.query;return{path:s({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:'push'}}),{name:"openedFx",sid:"q4jus9"}),q=l((e=>{for(var r,t=e.path,o=e.query,a=e.hash,i=[],s=[],d=c(n);!(r=d()).done;){var l=r.value,p=l.path.includes('#')?""+t+a:""+t,h=u({pathCreator:""+l.path,actualPath:p});(h.matches?i:s).push({route:l,params:h.params,query:o})}var f=e=>{var r=e;i.some((e=>e.route.route===s[r].route.route))&&(s[r]=null)};for(var m in s)f(m);return s=s.filter(Boolean),{opened:i,closed:s}}),{name:"recalculateFx",sid:"p5mrym"});m.on(q.done,((e,r)=>r.params.path)),d.on(q.done,((e,r)=>r.params.query)),O.on(q.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),y({and:[{clock:j.doneData,target:x}],or:{sid:"-57xmhh"}}),v({and:[{clock:q.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4esj1c"}});for(var R,L=q.doneData.map((e=>e.opened)),F=q.doneData.map((e=>e.closed)),S=()=>{var e=R.value,r=h(0,{name:"$isOpenedManually",sid:"bvkm8m"}),t=e.route.navigate.done;y({and:[{clock:t,fn:r=>{var t=r.result;return{route:e,params:t.params,query:t.query}},target:j}],or:{sid:"-3uzxmm"}});var n=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},o={opened:v({and:[{clock:L.filterMap(n),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"5wpt54"}}),updated:v({and:[{clock:L.filterMap(n),filter:e.route.$isOpened}],or:{name:"updated",sid:"-i5q4hs"}}),closed:v({and:[{clock:F.filterMap(n),filter:e.route.$isOpened}],or:{name:"closed",sid:"id1lfy"}})};r.on(t,(()=>1));var a=v({and:[{clock:o.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-1l5c2l"}});y({and:[{source:g(a,null,{name:"source",sid:"f5o03n"}),clock:v({and:[{clock:a,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!E(e[0],r.params)||!E(t,r.query)}}],or:{name:"clock",sid:"tci0vq"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1jf7fq"}}),v({and:[{clock:o.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"-yj0w0"}}),y({and:[{clock:o.closed,target:e.route.closed}],or:{sid:"9eta07"}}),r.reset(y({and:[{clock:L}],or:{sid:"kez4m6"}}))},_=c(n);!(R=_()).done;)S();if($(e.notFoundRoute)){var D=y({and:[{clock:O,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"39vknv"}});y({and:[{clock:D,source:{query:d},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"accq78"}}),y({and:[{clock:D,source:{query:d},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"asuk02"}}),y({and:[{clock:D,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"b9cdsw"}})}var z,N=p({and:{source:{history:k},effect:(z=o(t().mark((function e(r){var n,o;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return o=[(n=r.history).location.pathname,Object.fromEntries(new URLSearchParams(n.location.search)),n.location.hash],e.abrupt("return",{path:o[0],query:o[1],hash:o[2]});case 3:case"end":return e.stop()}}),e)}))),function(e){return z.apply(this,arguments)})},or:{name:"recheckFx",sid:"-pkcc0g"}});y({and:[{source:N.doneData,target:q}],or:{sid:"coh8xr"}});var T,A=p({and:{source:{history:k},effect:(T=o(t().mark((function e(r){var n,o;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:n=r.history,o=N;try{o=b(N)}catch(e){}return n.listen((()=>{o()})),e.abrupt("return",1);case 5:case"end":return e.stop()}}),e)}))),function(e){return T.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-rq379k"}});e.hydrate||y({and:[{clock:A.doneData,target:N}],or:{sid:"dpv9c1"}}),y({and:[{clock:k,target:A}],or:{sid:"o2nrl5"}}),w.on(q.doneData,(()=>1)).reset(k);var C=y({and:[{clock:v({and:[{clock:w,filter:Boolean}],or:{name:"clock",sid:"-g82n00"}}),source:{activeRoutes:O,path:m,query:d}}],or:{name:"initialized",sid:"-1il1ih"}});return{$path:m,$query:d,$activeRoutes:O,$history:k,setHistory:a,push:x,routes:n,initialized:C,routeNotFound:i}},S=e=>{var r=e.clock?y({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):f({name:"clock",sid:"-oj7ut5"}),t=_(e.params||{}),n=_(e.query||{});return y({and:[{clock:r,source:{params:t,query:n},fn:(e,r)=>{var t=e.params,n=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),r},_=e=>O.store(e,{sid:"gjk14e"})?e:h(e,{sid:"fmgfpp"});export{R as Kind,s as buildPath,d as chainRoute,F as createHistoryRouter,L as createRoute,$ as isRoute,u as matchPath,S as redirect}; | ||
function e(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,n)}return t}function r(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?e(Object(n),!0).forEach((e=>{a(r,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((e=>{Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function t(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}function r(e,r,t,a){var i=Object.create((r&&r.prototype instanceof o?r:o).prototype),c=new p(a||[]);return i._invoke=((e,r,t)=>{var o="suspendedStart";return(a,i)=>{if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===a)throw i;return{value:void 0,done:!0}}for(t.method=a,t.arg=i;;){var c=t.delegate;if(c){var s=u(c,t);if(s){if(s===k)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===o)throw o="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);o="executing";var d=n(e,r,t);if("normal"===d.type){if(o=t.done?"completed":"suspendedYield",d.arg===k)continue;return{value:d.arg,done:t.done}}"throw"===d.type&&(o="completed",t.method="throw",t.arg=d.arg)}}})(e,t,c),i}function n(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function s(e,r){function t(o,a,i,c){var s=n(e[o],e,a);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&v.call(d,"__await")?r.resolve(d.__await).then((e=>{t("next",e,i,c)}),(e=>{t("throw",e,i,c)})):r.resolve(d).then((e=>{u.value=e,i(u)}),(e=>t("throw",e,i,c)))}c(s.arg)}var o;this._invoke=(e,n)=>{function a(){return new r(((r,o)=>{t(e,n,r,o)}))}return o=o?o.then(a,a):a()}}function u(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,u(e,r),"throw"===r.method))return k;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return k}var o=n(t,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,k;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,k):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,k)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function l(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function p(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(!0)}function h(e){if(e){var r=e[b];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(v.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return n.next=n}}return{next:f}}function f(){return{value:void 0,done:!0}}t=()=>m;var m={},y=Object.prototype,v=y.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},b=g.iterator||"@@iterator",O=g.asyncIterator||"@@asyncIterator",w=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var k={},x={};e(x,b,(function(){return this}));var j=Object.getPrototypeOf,q=j&&j(j(h([])));q&&q!==y&&v.call(q,b)&&(x=q);var R=i.prototype=o.prototype=Object.create(x);return a.prototype=i,e(R,"constructor",i),e(i,"constructor",a),a.displayName=e(i,w,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===a||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,w,"GeneratorFunction")),r.prototype=Object.create(R),r),m.awrap=e=>({__await:e}),c(s.prototype),e(s.prototype,O,(function(){return this})),m.AsyncIterator=s,m.async=(e,t,n,o,a)=>{void 0===a&&(a=Promise);var i=new s(r(e,t,n,o),a);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(R),e(R,w,"Generator"),e(R,b,(function(){return this})),e(R,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},m.values=h,p.prototype={constructor:p,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!e)for(var r in this)"t"===r.charAt(0)&&v.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}if(this.done)throw e;for(var t=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var i=v.call(o,"catchLoc"),c=v.call(o,"finallyLoc");if(i&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&v.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,k):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),k},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),l(t),k}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;l(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:h(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),k}},m}function n(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,o)}function o(e){return function(){var r=this,t=arguments;return new Promise(((o,a)=>{function i(e){n(s,o,a,i,c,"next",e)}function c(e){n(s,o,a,i,c,"throw",e)}var s=e.apply(r,t);i(void 0)}))}}function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function c(e,r){var it="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(it)return(it=it.call(e)).next.bind(it);if(Array.isArray(e)||(it=((e,r)=>{if(e){if("string"==typeof e)return i(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:!0}:{done:!1,value:e[t++]}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e){var r=e.params,t=e.query;return j(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function u(e){var r=e.actualPath,t=q(e.pathCreator.replace('://','\\://'))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return t?{matches:!0,params:t.params}:{matches:!1}}function d(e){var t=(e=>{if($(e))return{route:e,chainedRoute:x({sid:"wj2jy7",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:f({name:"beforeOpen",sid:"uyxd6d"}),openOn:k([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:k([f({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var t=r({},e);if(O.unit(t.beforeOpen)||(t.beforeOpen=p({and:t.beforeOpen,or:{sid:"-gadjdw"}})),O.effect(t.beforeOpen,{sid:"ohaial"}))return{route:t.route,chainedRoute:t.chainedRoute||x({sid:"-cgk8n3",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:t.beforeOpen,openOn:'openOn'in t?t.openOn:t.beforeOpen.doneData,cancelOn:'cancelOn'in t?t.cancelOn:t.beforeOpen.failData};var n=e;return{route:n.route,chainedRoute:n.chainedRoute||x({sid:"rtbqmw",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:y({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:y({and:[{clock:n.cancelOn||f({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),n=t.route,o=t.chainedRoute,a=t.beforeOpen,i=t.openOn,c=t.cancelOn,s=h({},{name:"$params",sid:"-e7xr51"}),u=h({},{name:"$query",sid:"-mfs2i3"}),d=w({and:[w({and:[[n.$params,n.$query]],or:{name:"and",sid:"-34jx4h"}}),w({and:[[s,u]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),l=y({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});y({and:[{clock:l,target:a}],or:{sid:"ggm0br"}}),s.on(l,((e,r)=>r.params)),u.on(l,((e,r)=>r.query));var m=v({and:[{clock:i,source:{params:s,query:u},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});y({and:[{clock:m,target:o.navigate}],or:{sid:"gyr7wo"}});var g=k([n.closed,c],{name:"aborted",sid:"4m2b1e"});return s.reset(g),u.reset(g),y({and:[{clock:g,target:o.closed}],or:{sid:"hf91pi"}}),o}import{createEffect as l,attach as p,createStore as h,createEvent as f,split as m,sample as y,guard as v,restore as g,scopeBind as b,is as O,combine as w,merge as k,withFactory as x}from'effector';import{compile as j,match as q}from'path-to-regexp';var R={ROUTE:Symbol()},L=function(e){void 0===e&&(e={});var r=l(function(){var e=o(t().mark((function e(r){return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{}});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"-1r3y8c"}),n=p({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"betlrc"}}),a=h(!1,{name:"$isOpened",sid:"-lpbmtu"}),i=h({},{name:"$params",sid:"-s1jw4p"}),c=h({},{name:"$query",sid:"-sl9wq7"}),s=f({name:"opened",sid:"gya9jo"}),u=f({name:"updated",sid:"-a825r0"}),d=f({name:"left",sid:"-3vusfj"}),v=f({name:"closed",sid:"du28m6"});return a.on(s,(()=>!0)).on(d,(()=>!1)),i.on(s,((e,r)=>r.params)).on(u,((e,r)=>r.params)),c.on(s,((e,r)=>r.query)).on(u,((e,r)=>r.query)),m({and:[{source:r.doneData,match:a.map((e=>e?'updated':'opened')),cases:{opened:s,updated:u}}],or:{sid:"-vrcd1r"}}),y({and:[{clock:v,target:d}],or:{sid:"-vauj8x"}}),e.filter&&m({and:[{source:y({and:[{clock:e.filter}],or:{name:"source",sid:"hc5kab"}}),match:e=>e?'true':'false',cases:{true:s,false:v}}],or:{sid:"-v6zz1o"}}),{$isOpened:a,$params:i,$query:c,opened:s,updated:u,closed:v,left:d,navigate:r,open:n,kind:R.ROUTE,settings:{derived:Boolean(e.filter)}}},E=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return!1;for(var t in e)if(""+e[t]!=""+r[t])return!1;return!0},$=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===R.ROUTE,P=l((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),F=function(e){var n=((e,t)=>{void 0===t&&(t='');for(var n,o=[],a=()=>{var e,t=n.value;Array.isArray(t.route)?(e=o).push.apply(e,t.route.map((e=>r(r({},t),{},{route:e})))):o.push(t)},i=c(e);!(n=i()).done;)a();o=o.map((e=>r(r({},e),{},{path:""+t+e.path})));for(var s,u=[],d=[],l=c(o);!(s=l()).done;){var p=s.value;p.route.settings.derived?u.push(p):d.push(p)}if(u.length)for(var h,f=c(u);!(h=f()).done;)console.error("createHistoryRouter: "+h.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),a=f({name:"setHistory",sid:"-7gknvs"}),i=f({name:"routeNotFound",sid:"-z1d04m"}),d=h({},{name:"$query",sid:"-5p9ozk"}),m=h('',{name:"$path",sid:"-npzcwr"}),O=h([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"x18bma"}),w=h(!1,{name:"$isFirstCheckPassed",sid:"-m3xotb"}),k=h(null,{and:{serialize:'ignore'},name:"$history",sid:"pamx59"});k.on(a,((e,r)=>r));var x=p({and:{source:{history:k},effect:P,mapParams:(e,t)=>r({history:t.history},e)},or:{name:"pushFx",sid:"8huosv"}}),j=l((e=>{var r=e.params,t=e.query;return{path:s({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:'push'}}),{name:"openedFx",sid:"q4jus9"}),q=l((e=>{for(var r,t=e.path,o=e.query,a=e.hash,i=[],s=[],d=c(n);!(r=d()).done;){var l=r.value,p=l.path.includes('#')?""+t+a:""+t,h=u({pathCreator:""+l.path,actualPath:p});(h.matches?i:s).push({route:l,params:h.params,query:o})}var f=e=>{var r=e;i.some((e=>e.route.route===s[r].route.route))&&(s[r]=null)};for(var m in s)f(m);return s=s.filter(Boolean),{opened:i,closed:s}}),{name:"recalculateFx",sid:"p5mrym"});m.on(q.done,((e,r)=>r.params.path)),d.on(q.done,((e,r)=>r.params.query)),O.on(q.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),y({and:[{clock:j.doneData,target:x}],or:{sid:"-57xmhh"}}),v({and:[{clock:q.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4esj1c"}});for(var R,L=q.doneData.map((e=>e.opened)),F=q.doneData.map((e=>e.closed)),S=()=>{var e=R.value,r=h(!1,{name:"$isOpenedManually",sid:"bvkm8m"}),t=e.route.navigate.done;y({and:[{clock:t,fn:r=>{var t=r.result;return{route:e,params:t.params,query:t.query}},target:j}],or:{sid:"-3uzxmm"}});var n=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},o={opened:v({and:[{clock:L.filterMap(n),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"5wpt54"}}),updated:v({and:[{clock:L.filterMap(n),filter:e.route.$isOpened}],or:{name:"updated",sid:"-i5q4hs"}}),closed:v({and:[{clock:F.filterMap(n),filter:e.route.$isOpened}],or:{name:"closed",sid:"id1lfy"}})};r.on(t,(()=>!0));var a=v({and:[{clock:o.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-1l5c2l"}});y({and:[{source:g(a,null,{name:"source",sid:"f5o03n"}),clock:v({and:[{clock:a,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!E(e[0],r.params)||!E(t,r.query)}}],or:{name:"clock",sid:"tci0vq"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1jf7fq"}}),v({and:[{clock:o.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"-yj0w0"}}),y({and:[{clock:o.closed,target:e.route.closed}],or:{sid:"9eta07"}}),r.reset(y({and:[{clock:L}],or:{sid:"kez4m6"}}))},_=c(n);!(R=_()).done;)S();if($(e.notFoundRoute)){var D=y({and:[{clock:O,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"39vknv"}});y({and:[{clock:D,source:{query:d},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"accq78"}}),y({and:[{clock:D,source:{query:d},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"asuk02"}}),y({and:[{clock:D,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"b9cdsw"}})}var z,N=p({and:{source:{history:k},effect:(z=o(t().mark((function e(r){var n,o;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return o=[(n=r.history).location.pathname,Object.fromEntries(new URLSearchParams(n.location.search)),n.location.hash],e.abrupt("return",{path:o[0],query:o[1],hash:o[2]});case 3:case"end":return e.stop()}}),e)}))),function(e){return z.apply(this,arguments)})},or:{name:"recheckFx",sid:"-pkcc0g"}});y({and:[{source:N.doneData,target:q}],or:{sid:"coh8xr"}});var T,A=p({and:{source:{history:k},effect:(T=o(t().mark((function e(r){var n,o;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:n=r.history,o=N;try{o=b(N)}catch(e){}return n.listen((()=>{o()})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e)}))),function(e){return T.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-rq379k"}});e.hydrate||y({and:[{clock:A.doneData,target:N}],or:{sid:"dpv9c1"}}),y({and:[{clock:k,target:A}],or:{sid:"o2nrl5"}}),w.on(q.doneData,(()=>!0)).reset(k);var C=y({and:[{clock:v({and:[{clock:w,filter:Boolean}],or:{name:"clock",sid:"-g82n00"}}),source:{activeRoutes:O,path:m,query:d}}],or:{name:"initialized",sid:"-1il1ih"}});return{$path:m,$query:d,$activeRoutes:O,$history:k,setHistory:a,push:x,routes:n,initialized:C,routeNotFound:i}},S=e=>{var r=e.clock?y({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):f({name:"clock",sid:"-oj7ut5"}),t=_(e.params||{}),n=_(e.query||{});return y({and:[{clock:r,source:{params:t,query:n},fn:(e,r)=>{var t=e.params,n=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),r},_=e=>O.store(e,{sid:"gjk14e"})?e:h(e,{sid:"fmgfpp"});export{R as Kind,s as buildPath,d as chainRoute,F as createHistoryRouter,L as createRoute,$ as isRoute,u as matchPath,S as redirect}; | ||
//# sourceMappingURL=atomic-router.esm.js.map |
@@ -1,2 +0,2 @@ | ||
((e,r)=>{'object'==typeof exports&&'undefined'!=typeof module?r(exports,require('effector')):'function'==typeof define&&define.amd?define(['exports','effector'],r):r((e='undefined'!=typeof globalThis?globalThis:e||self).atomicRouter={},e.effector)})(this,(function(e,effector){function r(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,n)}return t}function t(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),1).forEach((r=>{i(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((r=>{Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function n(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:1,configurable:1,writable:1}),e[r]}function r(e,r,n,o){var i=Object.create((r&&r.prototype instanceof a?r:a).prototype),c=new l(o||[]);return i._invoke=((e,r,n)=>{var a="suspendedStart";return(o,i)=>{if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===o)throw i;return h()}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var s=u(c,n);if(s){if(s===O)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var d=t(e,r,n);if("normal"===d.type){if(a=n.done?"completed":"suspendedYield",d.arg===O)continue;return{value:d.arg,done:n.done}}"throw"===d.type&&(a="completed",n.method="throw",n.arg=d.arg)}}})(e,n,c),i}function t(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function a(){}function o(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function s(e,r){function n(a,o,i,c){var s=t(e[a],e,o);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&y.call(d,"__await")?r.resolve(d.__await).then((e=>{n("next",e,i,c)}),(e=>{n("throw",e,i,c)})):r.resolve(d).then((e=>{u.value=e,i(u)}),(e=>n("throw",e,i,c)))}c(s.arg)}var a;this._invoke=(e,t)=>{function o(){return new r(((r,a)=>{n(e,t,r,a)}))}return a=a?a.then(o,o):o()}}function u(e,r){var n=e.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,u(e,r),"throw"===r.method))return O;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return O}var a=t(n,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,O;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,O):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,O)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function p(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function l(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(1)}function f(e){if(e){var r=e[w];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(y.call(e,t))return r.value=e[t],r.done=0,r;return r.value=void 0,r.done=1,r};return n.next=n}}return{next:h}}function h(){return{value:void 0,done:1}}n=()=>m;var m={},v=Object.prototype,y=v.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},w=g.iterator||"@@iterator",b=g.asyncIterator||"@@asyncIterator",x=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var O={},E={};e(E,w,(function(){return this}));var k=Object.getPrototypeOf,R=k&&k(k(f([])));R&&R!==v&&y.call(R,w)&&(E=R);var j=i.prototype=a.prototype=Object.create(E);return o.prototype=i,e(j,"constructor",i),e(i,"constructor",o),o.displayName=e(i,x,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===o||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,x,"GeneratorFunction")),r.prototype=Object.create(j),r),m.awrap=e=>({__await:e}),c(s.prototype),e(s.prototype,b,(function(){return this})),m.AsyncIterator=s,m.async=(e,t,n,a,o)=>{void 0===o&&(o=Promise);var i=new s(r(e,t,n,a),o);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(j),e(j,x,"Generator"),e(j,w,(function(){return this})),e(j,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=0,t}return t.done=1,t}},m.values=f,l.prototype={constructor:l,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=0,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(p),!e)for(var r in this)"t"===r.charAt(0)&&y.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=1;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}if(this.done)throw e;for(var t=this,n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var i=y.call(a,"catchLoc"),c=y.call(a,"finallyLoc");if(i&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,1);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(i){if(this.prev<a.catchLoc)return r(a.catchLoc,1)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&y.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=r,a?(this.method="next",this.next=a.finallyLoc,O):this.complete(o)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),O},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),p(t),O}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;p(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:f(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),O}},m}function a(e,r,t,n,a,o,i){try{var c=e[o](i),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,a)}function o(e){return function(){var r=this,t=arguments;return new Promise(((n,o)=>{function i(e){a(s,n,o,i,c,"next",e)}function c(e){a(s,n,o,i,c,"throw",e)}var s=e.apply(r,t);i(void 0)}))}}function i(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:1,configurable:1,writable:1}):e[r]=t,e}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function s(e,r){var it="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(it)return(it=it.call(e)).next.bind(it);if(Array.isArray(e)||(it=((e,r)=>{if(e){if("string"==typeof e)return c(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:1}:{done:0,value:e[t++]}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,r){void 0===r&&(r={});for(var t=(e=>{for(var r=[],t=0;t<e.length;){var n=e[t];if("*"!==n&&"+"!==n&&"?"!==n)if("\\"!==n)if("{"!==n)if("}"!==n)if(":"!==n)if("("!==n)r.push({type:"CHAR",index:t,value:e[t++]});else{var a=1,o="";if("?"===e[c=t+1])throw new TypeError("Pattern cannot start with \"?\" at ".concat(c));for(;c<e.length;)if("\\"!==e[c]){if(")"===e[c]){if(0==--a){c++;break}}else if("("===e[c]&&(a++,"?"!==e[c+1]))throw new TypeError("Capturing groups are not allowed at ".concat(c));o+=e[c++]}else o+=e[c++]+e[c++];if(a)throw new TypeError("Unbalanced pattern at ".concat(t));if(!o)throw new TypeError("Missing pattern at ".concat(t));r.push({type:"PATTERN",index:t,value:o}),t=c}else{for(var i="",c=t+1;c<e.length;){var s=e.charCodeAt(c);if(!(s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||95===s))break;i+=e[c++]}if(!i)throw new TypeError("Missing parameter name at ".concat(t));r.push({type:"NAME",index:t,value:i}),t=c}else r.push({type:"CLOSE",index:t,value:e[t++]});else r.push({type:"OPEN",index:t,value:e[t++]});else r.push({type:"ESCAPED_CHAR",index:t++,value:e[t++]});else r.push({type:"MODIFIER",index:t,value:e[t++]})}return r.push({type:"END",index:t,value:""}),r})(e),n=r.prefixes,a=void 0===n?"./":n,o="[^".concat(p(r.delimiter||"/#?"),"]+?"),i=[],c=0,s=0,u="",d=e=>{if(s<t.length&&t[s].type===e)return t[s++].value},l=e=>{var r=d(e);if(void 0!==r)return r;var n=t[s],a=n.index;throw new TypeError("Unexpected ".concat(n.type," at ").concat(a,", expected ").concat(e))},f=()=>{for(var e,r="";e=d("CHAR")||d("ESCAPED_CHAR");)r+=e;return r};s<t.length;){var h=d("CHAR"),m=d("NAME"),v=d("PATTERN");if(m||v)-1===a.indexOf(g=h||"")&&(u+=g,g=""),u&&(i.push(u),u=""),i.push({name:m||c++,prefix:g,suffix:"",pattern:v||o,modifier:d("MODIFIER")||""});else{var y=h||d("ESCAPED_CHAR");if(y)u+=y;else if(u&&(i.push(u),u=""),d("OPEN")){var g=f(),w=d("NAME")||"",b=d("PATTERN")||"",x=f();l("CLOSE"),i.push({name:w||(b?c++:""),pattern:w&&!b?o:b,prefix:g,suffix:x,modifier:d("MODIFIER")||""})}else l("END")}}return i}function d(e,r){var t=[];return((e,r,t)=>{void 0===t&&(t={});var n=t.decode,a=void 0===n?e=>e:n;return t=>{var n=e.exec(t);if(!n)return 0;for(var o=n[0],i=n.index,c=Object.create(null),s=e=>{if(void 0===n[e])return"continue";var t=r[e-1];c[t.name]="*"===t.modifier||"+"===t.modifier?n[e].split(t.prefix+t.suffix).map((e=>a(e,t))):a(n[e],t)},u=1;u<n.length;u++)s(u);return{path:o,index:i,params:c}}})(f(e,t,r),t,r)}function p(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function l(e){return e&&e.sensitive?"":"i"}function f(e,r,t){return e instanceof RegExp?((e,r)=>{if(!r)return e;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,a=t.exec(e.source);a;)r.push({name:a[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),a=t.exec(e.source);return e})(e,r):Array.isArray(e)?((e,r,t)=>{var n=e.map((e=>f(e,r,t).source));return new RegExp("(?:".concat(n.join("|"),")"),l(t))})(e,r,t):((e,r,t)=>((e,r,t)=>{void 0===t&&(t={});for(var n=t.strict,a=void 0===n?0:n,o=t.start,i=void 0===o?1:o,c=t.end,s=void 0===c?1:c,u=t.encode,d=void 0===u?e=>e:u,f=t.delimiter,h=void 0===f?"/#?":f,m=t.endsWith,v="[".concat(p(void 0===m?"":m),"]|$"),y="[".concat(p(h),"]"),g=i?"^":"",w=0,b=e;w<b.length;w++){var x=b[w];if("string"==typeof x)g+=p(d(x));else{var O=p(d(x.prefix)),E=p(d(x.suffix));if(x.pattern)if(r&&r.push(x),O||E)if("+"===x.modifier||"*"===x.modifier){var k="*"===x.modifier?"?":"";g+="(?:".concat(O,"((?:").concat(x.pattern,")(?:").concat(E).concat(O,"(?:").concat(x.pattern,"))*)").concat(E,")").concat(k)}else g+="(?:".concat(O,"(").concat(x.pattern,")").concat(E,")").concat(x.modifier);else g+="+"===x.modifier||"*"===x.modifier?"((?:".concat(x.pattern,")").concat(x.modifier,")"):"(".concat(x.pattern,")").concat(x.modifier);else g+="(?:".concat(O).concat(E,")").concat(x.modifier)}}if(s)a||(g+="".concat(y,"?")),g+=t.endsWith?"(?=".concat(v,")"):"$";else{var R=e[e.length-1],j="string"==typeof R?y.indexOf(R[R.length-1])>-1:void 0===R;a||(g+="(?:".concat(y,"(?=").concat(v,"))?")),j||(g+="(?=".concat(y,"|").concat(v,")"))}return new RegExp(g,l(t))})(u(e,t),r,t))(e,r,t)}function h(e){var r=e.params,t=e.query;return((e,r)=>((e,r)=>{void 0===r&&(r={});var t=l(r),n=r.encode,a=void 0===n?e=>e:n,o=r.validate,i=void 0===o?1:o,c=e.map((e=>{if("object"==typeof e)return new RegExp("^(?:".concat(e.pattern,")$"),t)}));return r=>{for(var t="",n=0;n<e.length;n++){var o=e[n];if("string"!=typeof o){var s=r?r[o.name]:void 0,u="?"===o.modifier||"*"===o.modifier,d="*"===o.modifier||"+"===o.modifier;if(Array.isArray(s)){if(!d)throw new TypeError("Expected \"".concat(o.name,"\" to not repeat, but got an array"));if(0===s.length){if(u)continue;throw new TypeError("Expected \"".concat(o.name,"\" to not be empty"))}for(var p=0;p<s.length;p++){var l=a(s[p],o);if(i&&!c[n].test(l))throw new TypeError("Expected all \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(l,"\""));t+=o.prefix+l+o.suffix}}else if("string"!=typeof s&&"number"!=typeof s){if(!u){var f=d?"an array":"a string";throw new TypeError("Expected \"".concat(o.name,"\" to be ").concat(f))}}else{if(l=a(String(s),o),i&&!c[n].test(l))throw new TypeError("Expected \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(l,"\""));t+=o.prefix+l+o.suffix}}else t+=o}return t}})(u(e,r),r))(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function m(e){var r=e.actualPath,t=d((e=>e.replace('://','\\://'))(e.pathCreator))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return t?{matches:1,params:t.params}:{matches:0}}var v={ROUTE:Symbol()},y=function(e){void 0===e&&(e={});var r=effector.createEffect(function(){var e=o(n().mark((function e(r){return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{}});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"-1r3y8c"}),t=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"betlrc"}}),a=effector.createStore(0,{name:"$isOpened",sid:"-lpbmtu"}),i=effector.createStore({},{name:"$params",sid:"-s1jw4p"}),c=effector.createStore({},{name:"$query",sid:"-sl9wq7"}),s=effector.createEvent({name:"opened",sid:"gya9jo"}),u=effector.createEvent({name:"updated",sid:"-a825r0"}),d=effector.createEvent({name:"left",sid:"-3vusfj"}),p=effector.createEvent({name:"closed",sid:"du28m6"});return a.on(s,(()=>1)).on(d,(()=>0)),i.on(s,((e,r)=>r.params)).on(u,((e,r)=>r.params)),c.on(s,((e,r)=>r.query)).on(u,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:a.map((e=>e?'updated':'opened')),cases:{opened:s,updated:u}}],or:{sid:"-vrcd1r"}}),effector.sample({and:[{clock:p,target:d}],or:{sid:"-vauj8x"}}),e.filter&&effector.split({and:[{source:effector.sample({and:[{clock:e.filter}],or:{name:"source",sid:"hc5kab"}}),match:e=>e?'true':'false',cases:{true:s,false:p}}],or:{sid:"-v6zz1o"}}),{$isOpened:a,$params:i,$query:c,opened:s,updated:u,closed:p,left:d,navigate:r,open:t,kind:v.ROUTE,settings:{derived:Boolean(e.filter)}}},g=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return 0;for(var t in e)if(""+e[t]!=""+r[t])return 0;return 1},w=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===v.ROUTE,b=effector.createEffect((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),x=e=>effector.is.store(e,{sid:"gjk14e"})?e:effector.createStore(e,{sid:"fmgfpp"});e.Kind=v,e.buildPath=h,e.chainRoute=e=>{var r=(e=>{if(w(e))return{route:e,chainedRoute:effector.withFactory({sid:"wj2jy7",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"uyxd6d"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:effector.merge([effector.createEvent({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var r=t({},e);if(effector.is.unit(r.beforeOpen)||(r.beforeOpen=effector.attach({and:r.beforeOpen,or:{sid:"-gadjdw"}})),effector.is.effect(r.beforeOpen,{sid:"ohaial"}))return{route:r.route,chainedRoute:r.chainedRoute||effector.withFactory({sid:"-cgk8n3",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:r.beforeOpen,openOn:'openOn'in r?r.openOn:r.beforeOpen.doneData,cancelOn:'cancelOn'in r?r.cancelOn:r.beforeOpen.failData};var n=e;return{route:n.route,chainedRoute:n.chainedRoute||effector.withFactory({sid:"rtbqmw",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:effector.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:effector.sample({and:[{clock:n.cancelOn||effector.createEvent({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),n=r.route,a=r.chainedRoute,o=r.beforeOpen,i=r.openOn,c=r.cancelOn,s=effector.createStore({},{name:"$params",sid:"-e7xr51"}),u=effector.createStore({},{name:"$query",sid:"-mfs2i3"}),d=effector.combine({and:[effector.combine({and:[[n.$params,n.$query]],or:{name:"and",sid:"-34jx4h"}}),effector.combine({and:[[s,u]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),p=effector.sample({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});effector.sample({and:[{clock:p,target:o}],or:{sid:"ggm0br"}}),s.on(p,((e,r)=>r.params)),u.on(p,((e,r)=>r.query));var l=effector.guard({and:[{clock:i,source:{params:s,query:u},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});effector.sample({and:[{clock:l,target:a.navigate}],or:{sid:"gyr7wo"}});var f=effector.merge([n.closed,c],{name:"aborted",sid:"4m2b1e"});return s.reset(f),u.reset(f),effector.sample({and:[{clock:f,target:a.closed}],or:{sid:"hf91pi"}}),a},e.createHistoryRouter=function(e){var r=((e,r)=>{void 0===r&&(r='');for(var n,a=[],o=()=>{var e,r=n.value;Array.isArray(r.route)?(e=a).push.apply(e,r.route.map((e=>t(t({},r),{},{route:e})))):a.push(r)},i=s(e);!(n=i()).done;)o();a=a.map((e=>t(t({},e),{},{path:""+r+e.path})));for(var c,u=[],d=[],p=s(a);!(c=p()).done;){var l=c.value;l.route.settings.derived?u.push(l):d.push(l)}if(u.length)for(var f,h=s(u);!(f=h()).done;)console.error("createHistoryRouter: "+f.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),a=effector.createEvent({name:"setHistory",sid:"-7gknvs"}),i=effector.createEvent({name:"routeNotFound",sid:"-z1d04m"}),c=effector.createStore({},{name:"$query",sid:"-5p9ozk"}),u=effector.createStore('',{name:"$path",sid:"-npzcwr"}),d=effector.createStore([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"x18bma"}),p=effector.createStore(0,{name:"$isFirstCheckPassed",sid:"-m3xotb"}),l=effector.createStore(null,{and:{serialize:'ignore'},name:"$history",sid:"pamx59"});l.on(a,((e,r)=>r));var f=effector.attach({and:{source:{history:l},effect:b,mapParams:(e,r)=>t({history:r.history},e)},or:{name:"pushFx",sid:"8huosv"}}),v=effector.createEffect((e=>{var r=e.params,t=e.query;return{path:h({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:'push'}}),{name:"openedFx",sid:"q4jus9"}),y=effector.createEffect((e=>{for(var t,n=e.path,a=e.query,o=e.hash,i=[],c=[],u=s(r);!(t=u()).done;){var d=t.value,p=d.path.includes('#')?""+n+o:""+n,l=m({pathCreator:""+d.path,actualPath:p});(l.matches?i:c).push({route:d,params:l.params,query:a})}var f=e=>{var r=e;i.some((e=>e.route.route===c[r].route.route))&&(c[r]=null)};for(var h in c)f(h);return c=c.filter(Boolean),{opened:i,closed:c}}),{name:"recalculateFx",sid:"p5mrym"});u.on(y.done,((e,r)=>r.params.path)),c.on(y.done,((e,r)=>r.params.query)),d.on(y.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),effector.sample({and:[{clock:v.doneData,target:f}],or:{sid:"-57xmhh"}}),effector.guard({and:[{clock:y.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4esj1c"}});for(var x,O=y.doneData.map((e=>e.opened)),E=y.doneData.map((e=>e.closed)),k=()=>{var e=x.value,r=effector.createStore(0,{name:"$isOpenedManually",sid:"bvkm8m"}),t=e.route.navigate.done;effector.sample({and:[{clock:t,fn:r=>{var t=r.result;return{route:e,params:t.params,query:t.query}},target:v}],or:{sid:"-3uzxmm"}});var n=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},a={opened:effector.guard({and:[{clock:O.filterMap(n),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"5wpt54"}}),updated:effector.guard({and:[{clock:O.filterMap(n),filter:e.route.$isOpened}],or:{name:"updated",sid:"-i5q4hs"}}),closed:effector.guard({and:[{clock:E.filterMap(n),filter:e.route.$isOpened}],or:{name:"closed",sid:"id1lfy"}})};r.on(t,(()=>1));var o=effector.guard({and:[{clock:a.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-1l5c2l"}});effector.sample({and:[{source:effector.restore(o,null,{name:"source",sid:"f5o03n"}),clock:effector.guard({and:[{clock:o,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!g(e[0],r.params)||!g(t,r.query)}}],or:{name:"clock",sid:"tci0vq"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1jf7fq"}}),effector.guard({and:[{clock:a.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"-yj0w0"}}),effector.sample({and:[{clock:a.closed,target:e.route.closed}],or:{sid:"9eta07"}}),r.reset(effector.sample({and:[{clock:O}],or:{sid:"kez4m6"}}))},R=s(r);!(x=R()).done;)k();if(w(e.notFoundRoute)){var j=effector.sample({and:[{clock:d,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"39vknv"}});effector.sample({and:[{clock:j,source:{query:c},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"accq78"}}),effector.sample({and:[{clock:j,source:{query:c},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"asuk02"}}),effector.sample({and:[{clock:j,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"b9cdsw"}})}var q=effector.attach({and:{source:{history:l},effect:function(){var e=o(n().mark((function e(r){var t,a;return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return a=[(t=r.history).location.pathname,Object.fromEntries(new URLSearchParams(t.location.search)),t.location.hash],e.abrupt("return",{path:a[0],query:a[1],hash:a[2]});case 3:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}()},or:{name:"recheckFx",sid:"-pkcc0g"}});effector.sample({and:[{source:q.doneData,target:y}],or:{sid:"coh8xr"}});var P=effector.attach({and:{source:{history:l},effect:function(){var e=o(n().mark((function e(r){var t,a;return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:t=r.history,a=q;try{a=effector.scopeBind(q)}catch(e){}return t.listen((()=>{a()})),e.abrupt("return",1);case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}()},or:{name:"subscribeHistoryFx",sid:"-rq379k"}});e.hydrate||effector.sample({and:[{clock:P.doneData,target:q}],or:{sid:"dpv9c1"}}),effector.sample({and:[{clock:l,target:P}],or:{sid:"o2nrl5"}}),p.on(y.doneData,(()=>1)).reset(l);var S=effector.sample({and:[{clock:effector.guard({and:[{clock:p,filter:Boolean}],or:{name:"clock",sid:"-g82n00"}}),source:{activeRoutes:d,path:u,query:c}}],or:{name:"initialized",sid:"-1il1ih"}});return{$path:u,$query:c,$activeRoutes:d,$history:l,setHistory:a,push:f,routes:r,initialized:S,routeNotFound:i}},e.createRoute=y,e.isRoute=w,e.matchPath=m,e.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):effector.createEvent({name:"clock",sid:"-oj7ut5"}),t=x(e.params||{}),n=x(e.query||{});return effector.sample({and:[{clock:r,source:{params:t,query:n},fn:(e,r)=>{var t=e.params,n=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),r},Object.defineProperty(e,'__esModule',{value:1})})); | ||
((e,r)=>{'object'==typeof exports&&'undefined'!=typeof module?r(exports,require('effector')):'function'==typeof define&&define.amd?define(['exports','effector'],r):r((e='undefined'!=typeof globalThis?globalThis:e||self).atomicRouter={},e.effector)})(this,(function(e,effector){function r(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,n)}return t}function t(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((r=>{i(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((r=>{Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function n(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}function r(e,r,n,o){var i=Object.create((r&&r.prototype instanceof a?r:a).prototype),c=new l(o||[]);return i._invoke=((e,r,n)=>{var a="suspendedStart";return(o,i)=>{if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===o)throw i;return h()}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var s=u(c,n);if(s){if(s===O)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var d=t(e,r,n);if("normal"===d.type){if(a=n.done?"completed":"suspendedYield",d.arg===O)continue;return{value:d.arg,done:n.done}}"throw"===d.type&&(a="completed",n.method="throw",n.arg=d.arg)}}})(e,n,c),i}function t(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function a(){}function o(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function s(e,r){function n(a,o,i,c){var s=t(e[a],e,o);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&y.call(d,"__await")?r.resolve(d.__await).then((e=>{n("next",e,i,c)}),(e=>{n("throw",e,i,c)})):r.resolve(d).then((e=>{u.value=e,i(u)}),(e=>n("throw",e,i,c)))}c(s.arg)}var a;this._invoke=(e,t)=>{function o(){return new r(((r,a)=>{n(e,t,r,a)}))}return a=a?a.then(o,o):o()}}function u(e,r){var n=e.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,u(e,r),"throw"===r.method))return O;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return O}var a=t(n,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,O;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,O):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,O)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function p(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function l(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(!0)}function f(e){if(e){var r=e[w];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(y.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return n.next=n}}return{next:h}}function h(){return{value:void 0,done:!0}}n=()=>m;var m={},v=Object.prototype,y=v.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},w=g.iterator||"@@iterator",b=g.asyncIterator||"@@asyncIterator",x=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var O={},E={};e(E,w,(function(){return this}));var k=Object.getPrototypeOf,R=k&&k(k(f([])));R&&R!==v&&y.call(R,w)&&(E=R);var j=i.prototype=a.prototype=Object.create(E);return o.prototype=i,e(j,"constructor",i),e(i,"constructor",o),o.displayName=e(i,x,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===o||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,x,"GeneratorFunction")),r.prototype=Object.create(j),r),m.awrap=e=>({__await:e}),c(s.prototype),e(s.prototype,b,(function(){return this})),m.AsyncIterator=s,m.async=(e,t,n,a,o)=>{void 0===o&&(o=Promise);var i=new s(r(e,t,n,a),o);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(j),e(j,x,"Generator"),e(j,w,(function(){return this})),e(j,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},m.values=f,l.prototype={constructor:l,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(p),!e)for(var r in this)"t"===r.charAt(0)&&y.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}if(this.done)throw e;for(var t=this,n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var i=y.call(a,"catchLoc"),c=y.call(a,"finallyLoc");if(i&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(i){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&y.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=r,a?(this.method="next",this.next=a.finallyLoc,O):this.complete(o)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),O},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),p(t),O}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;p(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:f(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),O}},m}function a(e,r,t,n,a,o,i){try{var c=e[o](i),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,a)}function o(e){return function(){var r=this,t=arguments;return new Promise(((n,o)=>{function i(e){a(s,n,o,i,c,"next",e)}function c(e){a(s,n,o,i,c,"throw",e)}var s=e.apply(r,t);i(void 0)}))}}function i(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function s(e,r){var it="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(it)return(it=it.call(e)).next.bind(it);if(Array.isArray(e)||(it=((e,r)=>{if(e){if("string"==typeof e)return c(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:!0}:{done:!1,value:e[t++]}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,r){void 0===r&&(r={});for(var t=(e=>{for(var r=[],t=0;t<e.length;){var n=e[t];if("*"!==n&&"+"!==n&&"?"!==n)if("\\"!==n)if("{"!==n)if("}"!==n)if(":"!==n)if("("!==n)r.push({type:"CHAR",index:t,value:e[t++]});else{var a=1,o="";if("?"===e[c=t+1])throw new TypeError("Pattern cannot start with \"?\" at ".concat(c));for(;c<e.length;)if("\\"!==e[c]){if(")"===e[c]){if(0==--a){c++;break}}else if("("===e[c]&&(a++,"?"!==e[c+1]))throw new TypeError("Capturing groups are not allowed at ".concat(c));o+=e[c++]}else o+=e[c++]+e[c++];if(a)throw new TypeError("Unbalanced pattern at ".concat(t));if(!o)throw new TypeError("Missing pattern at ".concat(t));r.push({type:"PATTERN",index:t,value:o}),t=c}else{for(var i="",c=t+1;c<e.length;){var s=e.charCodeAt(c);if(!(s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||95===s))break;i+=e[c++]}if(!i)throw new TypeError("Missing parameter name at ".concat(t));r.push({type:"NAME",index:t,value:i}),t=c}else r.push({type:"CLOSE",index:t,value:e[t++]});else r.push({type:"OPEN",index:t,value:e[t++]});else r.push({type:"ESCAPED_CHAR",index:t++,value:e[t++]});else r.push({type:"MODIFIER",index:t,value:e[t++]})}return r.push({type:"END",index:t,value:""}),r})(e),n=r.prefixes,a=void 0===n?"./":n,o="[^".concat(p(r.delimiter||"/#?"),"]+?"),i=[],c=0,s=0,u="",d=e=>{if(s<t.length&&t[s].type===e)return t[s++].value},l=e=>{var r=d(e);if(void 0!==r)return r;var n=t[s],a=n.index;throw new TypeError("Unexpected ".concat(n.type," at ").concat(a,", expected ").concat(e))},f=()=>{for(var e,r="";e=d("CHAR")||d("ESCAPED_CHAR");)r+=e;return r};s<t.length;){var h=d("CHAR"),m=d("NAME"),v=d("PATTERN");if(m||v)-1===a.indexOf(g=h||"")&&(u+=g,g=""),u&&(i.push(u),u=""),i.push({name:m||c++,prefix:g,suffix:"",pattern:v||o,modifier:d("MODIFIER")||""});else{var y=h||d("ESCAPED_CHAR");if(y)u+=y;else if(u&&(i.push(u),u=""),d("OPEN")){var g=f(),w=d("NAME")||"",b=d("PATTERN")||"",x=f();l("CLOSE"),i.push({name:w||(b?c++:""),pattern:w&&!b?o:b,prefix:g,suffix:x,modifier:d("MODIFIER")||""})}else l("END")}}return i}function d(e,r){var t=[];return((e,r,t)=>{void 0===t&&(t={});var n=t.decode,a=void 0===n?e=>e:n;return t=>{var n=e.exec(t);if(!n)return!1;for(var o=n[0],i=n.index,c=Object.create(null),s=e=>{if(void 0===n[e])return"continue";var t=r[e-1];c[t.name]="*"===t.modifier||"+"===t.modifier?n[e].split(t.prefix+t.suffix).map((e=>a(e,t))):a(n[e],t)},u=1;u<n.length;u++)s(u);return{path:o,index:i,params:c}}})(f(e,t,r),t,r)}function p(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function l(e){return e&&e.sensitive?"":"i"}function f(e,r,t){return e instanceof RegExp?((e,r)=>{if(!r)return e;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,a=t.exec(e.source);a;)r.push({name:a[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),a=t.exec(e.source);return e})(e,r):Array.isArray(e)?((e,r,t)=>{var n=e.map((e=>f(e,r,t).source));return new RegExp("(?:".concat(n.join("|"),")"),l(t))})(e,r,t):((e,r,t)=>((e,r,t)=>{void 0===t&&(t={});for(var n=t.strict,a=void 0!==n&&n,o=t.start,i=void 0===o||o,c=t.end,s=void 0===c||c,u=t.encode,d=void 0===u?e=>e:u,f=t.delimiter,h=void 0===f?"/#?":f,m=t.endsWith,v="[".concat(p(void 0===m?"":m),"]|$"),y="[".concat(p(h),"]"),g=i?"^":"",w=0,b=e;w<b.length;w++){var x=b[w];if("string"==typeof x)g+=p(d(x));else{var O=p(d(x.prefix)),E=p(d(x.suffix));if(x.pattern)if(r&&r.push(x),O||E)if("+"===x.modifier||"*"===x.modifier){var k="*"===x.modifier?"?":"";g+="(?:".concat(O,"((?:").concat(x.pattern,")(?:").concat(E).concat(O,"(?:").concat(x.pattern,"))*)").concat(E,")").concat(k)}else g+="(?:".concat(O,"(").concat(x.pattern,")").concat(E,")").concat(x.modifier);else g+="+"===x.modifier||"*"===x.modifier?"((?:".concat(x.pattern,")").concat(x.modifier,")"):"(".concat(x.pattern,")").concat(x.modifier);else g+="(?:".concat(O).concat(E,")").concat(x.modifier)}}if(s)a||(g+="".concat(y,"?")),g+=t.endsWith?"(?=".concat(v,")"):"$";else{var R=e[e.length-1],j="string"==typeof R?y.indexOf(R[R.length-1])>-1:void 0===R;a||(g+="(?:".concat(y,"(?=").concat(v,"))?")),j||(g+="(?=".concat(y,"|").concat(v,")"))}return new RegExp(g,l(t))})(u(e,t),r,t))(e,r,t)}function h(e){var r=e.params,t=e.query;return((e,r)=>((e,r)=>{void 0===r&&(r={});var t=l(r),n=r.encode,a=void 0===n?e=>e:n,o=r.validate,i=void 0===o||o,c=e.map((e=>{if("object"==typeof e)return new RegExp("^(?:".concat(e.pattern,")$"),t)}));return r=>{for(var t="",n=0;n<e.length;n++){var o=e[n];if("string"!=typeof o){var s=r?r[o.name]:void 0,u="?"===o.modifier||"*"===o.modifier,d="*"===o.modifier||"+"===o.modifier;if(Array.isArray(s)){if(!d)throw new TypeError("Expected \"".concat(o.name,"\" to not repeat, but got an array"));if(0===s.length){if(u)continue;throw new TypeError("Expected \"".concat(o.name,"\" to not be empty"))}for(var p=0;p<s.length;p++){var l=a(s[p],o);if(i&&!c[n].test(l))throw new TypeError("Expected all \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(l,"\""));t+=o.prefix+l+o.suffix}}else if("string"!=typeof s&&"number"!=typeof s){if(!u){var f=d?"an array":"a string";throw new TypeError("Expected \"".concat(o.name,"\" to be ").concat(f))}}else{if(l=a(String(s),o),i&&!c[n].test(l))throw new TypeError("Expected \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(l,"\""));t+=o.prefix+l+o.suffix}}else t+=o}return t}})(u(e,r),r))(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function m(e){var r=e.actualPath,t=d((e=>e.replace('://','\\://'))(e.pathCreator))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return t?{matches:!0,params:t.params}:{matches:!1}}var v={ROUTE:Symbol()},y=function(e){void 0===e&&(e={});var r=effector.createEffect(function(){var e=o(n().mark((function e(r){return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{}});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"-1r3y8c"}),t=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"betlrc"}}),a=effector.createStore(!1,{name:"$isOpened",sid:"-lpbmtu"}),i=effector.createStore({},{name:"$params",sid:"-s1jw4p"}),c=effector.createStore({},{name:"$query",sid:"-sl9wq7"}),s=effector.createEvent({name:"opened",sid:"gya9jo"}),u=effector.createEvent({name:"updated",sid:"-a825r0"}),d=effector.createEvent({name:"left",sid:"-3vusfj"}),p=effector.createEvent({name:"closed",sid:"du28m6"});return a.on(s,(()=>!0)).on(d,(()=>!1)),i.on(s,((e,r)=>r.params)).on(u,((e,r)=>r.params)),c.on(s,((e,r)=>r.query)).on(u,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:a.map((e=>e?'updated':'opened')),cases:{opened:s,updated:u}}],or:{sid:"-vrcd1r"}}),effector.sample({and:[{clock:p,target:d}],or:{sid:"-vauj8x"}}),e.filter&&effector.split({and:[{source:effector.sample({and:[{clock:e.filter}],or:{name:"source",sid:"hc5kab"}}),match:e=>e?'true':'false',cases:{true:s,false:p}}],or:{sid:"-v6zz1o"}}),{$isOpened:a,$params:i,$query:c,opened:s,updated:u,closed:p,left:d,navigate:r,open:t,kind:v.ROUTE,settings:{derived:Boolean(e.filter)}}},g=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return!1;for(var t in e)if(""+e[t]!=""+r[t])return!1;return!0},w=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===v.ROUTE,b=effector.createEffect((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),x=e=>effector.is.store(e,{sid:"gjk14e"})?e:effector.createStore(e,{sid:"fmgfpp"});e.Kind=v,e.buildPath=h,e.chainRoute=e=>{var r=(e=>{if(w(e))return{route:e,chainedRoute:effector.withFactory({sid:"wj2jy7",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"uyxd6d"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:effector.merge([effector.createEvent({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var r=t({},e);if(effector.is.unit(r.beforeOpen)||(r.beforeOpen=effector.attach({and:r.beforeOpen,or:{sid:"-gadjdw"}})),effector.is.effect(r.beforeOpen,{sid:"ohaial"}))return{route:r.route,chainedRoute:r.chainedRoute||effector.withFactory({sid:"-cgk8n3",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:r.beforeOpen,openOn:'openOn'in r?r.openOn:r.beforeOpen.doneData,cancelOn:'cancelOn'in r?r.cancelOn:r.beforeOpen.failData};var n=e;return{route:n.route,chainedRoute:n.chainedRoute||effector.withFactory({sid:"rtbqmw",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:effector.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:effector.sample({and:[{clock:n.cancelOn||effector.createEvent({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),n=r.route,a=r.chainedRoute,o=r.beforeOpen,i=r.openOn,c=r.cancelOn,s=effector.createStore({},{name:"$params",sid:"-e7xr51"}),u=effector.createStore({},{name:"$query",sid:"-mfs2i3"}),d=effector.combine({and:[effector.combine({and:[[n.$params,n.$query]],or:{name:"and",sid:"-34jx4h"}}),effector.combine({and:[[s,u]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),p=effector.sample({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});effector.sample({and:[{clock:p,target:o}],or:{sid:"ggm0br"}}),s.on(p,((e,r)=>r.params)),u.on(p,((e,r)=>r.query));var l=effector.guard({and:[{clock:i,source:{params:s,query:u},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});effector.sample({and:[{clock:l,target:a.navigate}],or:{sid:"gyr7wo"}});var f=effector.merge([n.closed,c],{name:"aborted",sid:"4m2b1e"});return s.reset(f),u.reset(f),effector.sample({and:[{clock:f,target:a.closed}],or:{sid:"hf91pi"}}),a},e.createHistoryRouter=function(e){var r=((e,r)=>{void 0===r&&(r='');for(var n,a=[],o=()=>{var e,r=n.value;Array.isArray(r.route)?(e=a).push.apply(e,r.route.map((e=>t(t({},r),{},{route:e})))):a.push(r)},i=s(e);!(n=i()).done;)o();a=a.map((e=>t(t({},e),{},{path:""+r+e.path})));for(var c,u=[],d=[],p=s(a);!(c=p()).done;){var l=c.value;l.route.settings.derived?u.push(l):d.push(l)}if(u.length)for(var f,h=s(u);!(f=h()).done;)console.error("createHistoryRouter: "+f.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),a=effector.createEvent({name:"setHistory",sid:"-7gknvs"}),i=effector.createEvent({name:"routeNotFound",sid:"-z1d04m"}),c=effector.createStore({},{name:"$query",sid:"-5p9ozk"}),u=effector.createStore('',{name:"$path",sid:"-npzcwr"}),d=effector.createStore([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"x18bma"}),p=effector.createStore(!1,{name:"$isFirstCheckPassed",sid:"-m3xotb"}),l=effector.createStore(null,{and:{serialize:'ignore'},name:"$history",sid:"pamx59"});l.on(a,((e,r)=>r));var f=effector.attach({and:{source:{history:l},effect:b,mapParams:(e,r)=>t({history:r.history},e)},or:{name:"pushFx",sid:"8huosv"}}),v=effector.createEffect((e=>{var r=e.params,t=e.query;return{path:h({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:'push'}}),{name:"openedFx",sid:"q4jus9"}),y=effector.createEffect((e=>{for(var t,n=e.path,a=e.query,o=e.hash,i=[],c=[],u=s(r);!(t=u()).done;){var d=t.value,p=d.path.includes('#')?""+n+o:""+n,l=m({pathCreator:""+d.path,actualPath:p});(l.matches?i:c).push({route:d,params:l.params,query:a})}var f=e=>{var r=e;i.some((e=>e.route.route===c[r].route.route))&&(c[r]=null)};for(var h in c)f(h);return c=c.filter(Boolean),{opened:i,closed:c}}),{name:"recalculateFx",sid:"p5mrym"});u.on(y.done,((e,r)=>r.params.path)),c.on(y.done,((e,r)=>r.params.query)),d.on(y.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),effector.sample({and:[{clock:v.doneData,target:f}],or:{sid:"-57xmhh"}}),effector.guard({and:[{clock:y.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4esj1c"}});for(var x,O=y.doneData.map((e=>e.opened)),E=y.doneData.map((e=>e.closed)),k=()=>{var e=x.value,r=effector.createStore(!1,{name:"$isOpenedManually",sid:"bvkm8m"}),t=e.route.navigate.done;effector.sample({and:[{clock:t,fn:r=>{var t=r.result;return{route:e,params:t.params,query:t.query}},target:v}],or:{sid:"-3uzxmm"}});var n=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},a={opened:effector.guard({and:[{clock:O.filterMap(n),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"5wpt54"}}),updated:effector.guard({and:[{clock:O.filterMap(n),filter:e.route.$isOpened}],or:{name:"updated",sid:"-i5q4hs"}}),closed:effector.guard({and:[{clock:E.filterMap(n),filter:e.route.$isOpened}],or:{name:"closed",sid:"id1lfy"}})};r.on(t,(()=>!0));var o=effector.guard({and:[{clock:a.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-1l5c2l"}});effector.sample({and:[{source:effector.restore(o,null,{name:"source",sid:"f5o03n"}),clock:effector.guard({and:[{clock:o,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!g(e[0],r.params)||!g(t,r.query)}}],or:{name:"clock",sid:"tci0vq"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1jf7fq"}}),effector.guard({and:[{clock:a.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"-yj0w0"}}),effector.sample({and:[{clock:a.closed,target:e.route.closed}],or:{sid:"9eta07"}}),r.reset(effector.sample({and:[{clock:O}],or:{sid:"kez4m6"}}))},R=s(r);!(x=R()).done;)k();if(w(e.notFoundRoute)){var j=effector.sample({and:[{clock:d,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"39vknv"}});effector.sample({and:[{clock:j,source:{query:c},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"accq78"}}),effector.sample({and:[{clock:j,source:{query:c},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"asuk02"}}),effector.sample({and:[{clock:j,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"b9cdsw"}})}var q=effector.attach({and:{source:{history:l},effect:function(){var e=o(n().mark((function e(r){var t,a;return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return a=[(t=r.history).location.pathname,Object.fromEntries(new URLSearchParams(t.location.search)),t.location.hash],e.abrupt("return",{path:a[0],query:a[1],hash:a[2]});case 3:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}()},or:{name:"recheckFx",sid:"-pkcc0g"}});effector.sample({and:[{source:q.doneData,target:y}],or:{sid:"coh8xr"}});var P=effector.attach({and:{source:{history:l},effect:function(){var e=o(n().mark((function e(r){var t,a;return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:t=r.history,a=q;try{a=effector.scopeBind(q)}catch(e){}return t.listen((()=>{a()})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}()},or:{name:"subscribeHistoryFx",sid:"-rq379k"}});e.hydrate||effector.sample({and:[{clock:P.doneData,target:q}],or:{sid:"dpv9c1"}}),effector.sample({and:[{clock:l,target:P}],or:{sid:"o2nrl5"}}),p.on(y.doneData,(()=>!0)).reset(l);var S=effector.sample({and:[{clock:effector.guard({and:[{clock:p,filter:Boolean}],or:{name:"clock",sid:"-g82n00"}}),source:{activeRoutes:d,path:u,query:c}}],or:{name:"initialized",sid:"-1il1ih"}});return{$path:u,$query:c,$activeRoutes:d,$history:l,setHistory:a,push:f,routes:r,initialized:S,routeNotFound:i}},e.createRoute=y,e.isRoute=w,e.matchPath=m,e.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):effector.createEvent({name:"clock",sid:"-oj7ut5"}),t=x(e.params||{}),n=x(e.query||{});return effector.sample({and:[{clock:r,source:{params:t,query:n},fn:(e,r)=>{var t=e.params,n=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),r},Object.defineProperty(e,'__esModule',{value:!0})})); | ||
//# sourceMappingURL=atomic-router.umd.js.map |
{ | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/atomic-router.cjs.js", |
@@ -46,3 +46,3 @@ # Atomic Router | ||
import { homeRoute } from '@/pages/home'; | ||
import { postsRoute } from '@/pages/home'; | ||
import { postsRoute } from '@/pages/posts'; | ||
@@ -49,0 +49,0 @@ const routes = [ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
219327
389