@reach/router
Version:
Next generation Routing for React.
2 lines (1 loc) • 23.6 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e(t.ReachRouter={},t.React)}(this,function(t,e){"use strict";var n="default"in e?e.default:e,o="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var a=i(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n="function"==typeof Symbol&&Symbol.for,o=n?Symbol.for("react.element"):60103,r=n?Symbol.for("react.portal"):60106,i=n?Symbol.for("react.fragment"):60107,a=n?Symbol.for("react.strict_mode"):60108,u=n?Symbol.for("react.profiler"):60114,s=n?Symbol.for("react.provider"):60109,c=n?Symbol.for("react.context"):60110,l=n?Symbol.for("react.async_mode"):60111,p=n?Symbol.for("react.concurrent_mode"):60111,f=n?Symbol.for("react.forward_ref"):60112,h=n?Symbol.for("react.suspense"):60113,d=n?Symbol.for("react.suspense_list"):60120,m=n?Symbol.for("react.memo"):60115,v=n?Symbol.for("react.lazy"):60116,y=n?Symbol.for("react.fundamental"):60117,b=n?Symbol.for("react.responder"):60118,g=n?Symbol.for("react.scope"):60119;function w(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case o:switch(t=t.type){case l:case p:case i:case u:case a:case h:return t;default:switch(t=t&&t.$$typeof){case c:case f:case v:case m:case s:return t;default:return e}}case r:return e}}}function P(t){return w(t)===p}e.typeOf=w,e.AsyncMode=l,e.ConcurrentMode=p,e.ContextConsumer=c,e.ContextProvider=s,e.Element=o,e.ForwardRef=f,e.Fragment=i,e.Lazy=v,e.Memo=m,e.Portal=r,e.Profiler=u,e.StrictMode=a,e.Suspense=h,e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===i||t===p||t===u||t===a||t===h||t===d||"object"==typeof t&&null!==t&&(t.$$typeof===v||t.$$typeof===m||t.$$typeof===s||t.$$typeof===c||t.$$typeof===f||t.$$typeof===y||t.$$typeof===b||t.$$typeof===g)},e.isAsyncMode=function(t){return P(t)||w(t)===l},e.isConcurrentMode=P,e.isContextConsumer=function(t){return w(t)===c},e.isContextProvider=function(t){return w(t)===s},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===o},e.isForwardRef=function(t){return w(t)===f},e.isFragment=function(t){return w(t)===i},e.isLazy=function(t){return w(t)===v},e.isMemo=function(t){return w(t)===m},e.isPortal=function(t){return w(t)===r},e.isProfiler=function(t){return w(t)===u},e.isStrictMode=function(t){return w(t)===a},e.isSuspense=function(t){return w(t)===h}});r(a);a.typeOf,a.AsyncMode,a.ConcurrentMode,a.ContextConsumer,a.ContextProvider,a.Element,a.ForwardRef,a.Fragment,a.Lazy,a.Memo,a.Portal,a.Profiler,a.StrictMode,a.Suspense,a.isValidElementType,a.isAsyncMode,a.isConcurrentMode,a.isContextConsumer,a.isContextProvider,a.isElement,a.isForwardRef,a.isFragment,a.isLazy,a.isMemo,a.isPortal,a.isProfiler,a.isStrictMode,a.isSuspense;var u=i(function(t,e){});r(u);u.typeOf,u.AsyncMode,u.ConcurrentMode,u.ContextConsumer,u.ContextProvider,u.Element,u.ForwardRef,u.Fragment,u.Lazy,u.Memo,u.Portal,u.Profiler,u.StrictMode,u.Suspense,u.isValidElementType,u.isAsyncMode,u.isConcurrentMode,u.isContextConsumer,u.isContextProvider,u.isElement,u.isForwardRef,u.isFragment,u.isLazy,u.isMemo,u.isPortal,u.isProfiler,u.isStrictMode,u.isSuspense,i(function(t){t.exports=a});var s=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable;(function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(t){o[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(t){return!1}})()&&Object.assign;var p="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";Function.call.bind(Object.prototype.hasOwnProperty);function f(){}function h(){}h.resetWarningCache=f;var d=i(function(t){t.exports=function(){function t(t,e,n,o,r,i){if(i!==p){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:h,resetWarningCache:f};return n.PropTypes=n,n}()}),m=function(t,e,n,o,r,i,a,u){if(!t){var s;if(void 0===e)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,o,r,i,a,u],l=0;(s=new Error(e.replace(/%s/g,function(){return c[l++]}))).name="Invariant Violation"}throw s.framesToPop=1,s}},v="__global_unique_id__",y=function(){return o[v]=(o[v]||0)+1},b=function(){},g=b,w=i(function(t,e){e.__esModule=!0;i(n);var o=i(d),r=i(y);i(g);function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var c=1073741823;e.default=function(t,e){var i,l,p="__create-react-context-"+(0,r.default)()+"__",f=function(t){function n(){var e,o,r,i;a(this,n);for(var s=arguments.length,c=Array(s),l=0;l<s;l++)c[l]=arguments[l];return e=o=u(this,t.call.apply(t,[this].concat(c))),o.emitter=(r=o.props.value,i=[],{on:function(t){i.push(t)},off:function(t){i=i.filter(function(e){return e!==t})},get:function(){return r},set:function(t,e){r=t,i.forEach(function(t){return t(r,e)})}}),u(o,e)}return s(n,t),n.prototype.getChildContext=function(){var t;return(t={})[p]=this.emitter,t},n.prototype.componentWillReceiveProps=function(t){if(this.props.value!==t.value){var n=this.props.value,o=t.value,r=void 0;((i=n)===(a=o)?0!==i||1/i==1/a:i!=i&&a!=a)?r=0:(r="function"==typeof e?e(n,o):c,0!=(r|=0)&&this.emitter.set(t.value,r))}var i,a},n.prototype.render=function(){return this.props.children},n}(n.Component);f.childContextTypes=((i={})[p]=o.default.object.isRequired,i);var h=function(e){function n(){var t,o;a(this,n);for(var r=arguments.length,i=Array(r),s=0;s<r;s++)i[s]=arguments[s];return t=o=u(this,e.call.apply(e,[this].concat(i))),o.state={value:o.getValue()},o.onUpdate=function(t,e){0!=((0|o.observedBits)&e)&&o.setState({value:o.getValue()})},u(o,t)}return s(n,e),n.prototype.componentWillReceiveProps=function(t){var e=t.observedBits;this.observedBits=void 0===e||null===e?c:e},n.prototype.componentDidMount=function(){this.context[p]&&this.context[p].on(this.onUpdate);var t=this.props.observedBits;this.observedBits=void 0===t||null===t?c:t},n.prototype.componentWillUnmount=function(){this.context[p]&&this.context[p].off(this.onUpdate)},n.prototype.getValue=function(){return this.context[p]?this.context[p].get():t},n.prototype.render=function(){return(t=this.props.children,Array.isArray(t)?t[0]:t)(this.state.value);var t},n}(n.Component);return h.contextTypes=((l={})[p]=o.default.object,l),{Provider:f,Consumer:h}},t.exports=e.default});r(w);var P=r(i(function(t,e){e.__esModule=!0;var o=i(n),r=i(w);function i(t){return t&&t.__esModule?t:{default:t}}e.default=o.default.createContext||r.default,t.exports=e.default}));function C(){var t=this.constructor.getDerivedStateFromProps(this.props,this.state);null!==t&&void 0!==t&&this.setState(t)}function S(t){this.setState(function(e){var n=this.constructor.getDerivedStateFromProps(t,e);return null!==n&&void 0!==n?n:null}.bind(this))}function E(t,e){try{var n=this.props,o=this.state;this.props=t,this.state=e,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,o)}finally{this.props=n,this.state=o}}C.__suppressDeprecationWarning=!0,S.__suppressDeprecationWarning=!0,E.__suppressDeprecationWarning=!0;var _=function(t,e){return t.substr(0,e.length)===e},x=function(t,e){for(var n=void 0,o=void 0,r=e.split("?")[0],i=L(r),a=""===i[0],u=T(t),s=0,c=u.length;s<c;s++){var l=!1,p=u[s].route;if(p.default)o={route:p,params:{},uri:e};else{for(var f=L(p.path),h={},d=Math.max(i.length,f.length),v=0;v<d;v++){var y=f[v],b=i[v];if(U(y)){h[y.slice(1)||"*"]=i.slice(v).map(decodeURIComponent).join("/");break}if(void 0===b){l=!0;break}var g=F.exec(y);if(g&&!a){-1===D.indexOf(g[1])||m(!1);var w=decodeURIComponent(b);h[g[1]]=w}else if(y!==b){l=!0;break}}if(!l){n={route:p,params:h,uri:"/"+i.slice(0,v).join("/")};break}}}return n||o||null},O=function(t,e){return x([{path:t}],e)},M=function(t,e){if(_(t,"/"))return t;var n=t.split("?"),o=n[0],r=n[1],i=e.split("?")[0],a=L(o),u=L(i);if(""===a[0])return W(i,r);if(!_(a[0],".")){var s=u.concat(a).join("/");return W(("/"===i?"":"/")+s,r)}for(var c=u.concat(a),l=[],p=0,f=c.length;p<f;p++){var h=c[p];".."===h?l.pop():"."!==h&&l.push(h)}return W("/"+l.join("/"),r)},j=function(t,e){var n=t.split("?"),o=n[0],r=n[1],i=void 0===r?"":r,a="/"+L(o).map(function(t){var n=F.exec(t);return n?e[n[1]]:t}).join("/"),u=e.location,s=(u=void 0===u?{}:u).search,c=(void 0===s?"":s).split("?")[1]||"";return a=W(a,i,c)},F=/^:(.+)/,R=function(t){return F.test(t)},U=function(t){return t&&"*"===t[0]},k=function(t,e){return{route:t,score:t.default?0:L(t.path).reduce(function(t,e){return t+=4,!function(t){return""===t}(e)?R(e)?t+=2:U(e)?t-=5:t+=3:t+=1,t},0),index:e}},T=function(t){return t.map(k).sort(function(t,e){return t.score<e.score?1:t.score>e.score?-1:t.index-e.index})},L=function(t){return t.replace(/(^\/+|\/+$)/g,"").split("/")},W=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];return t+((n=n.filter(function(t){return t&&t.length>0}))&&n.length>0?"?"+n.join("&"):"")},D=["uri","path"],$=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},A=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},I=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},q=function(t,e){var n={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n},N=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},B=function(t){var e=t.location,n=e.search,o=e.hash,r=e.href,i=e.origin,a=e.protocol,u=e.host,s=e.hostname,c=e.port,l=t.location.pathname;!l&&r&&H&&(l=new URL(r).pathname);return{pathname:encodeURI(decodeURI(l)),search:n,hash:o,href:r,origin:i,protocol:a,host:u,hostname:s,port:c,state:t.history.state,key:t.history.state&&t.history.state.key||"initial"}},V=function(t,e){var n=[],o=B(t),r=!1,i=function(){};return{get location(){return o},get transitioning(){return r},_onTransitionComplete:function(){r=!1,i()},listen:function(e){n.push(e);var r=function(){o=B(t),e({location:o,action:"POP"})};return t.addEventListener("popstate",r),function(){t.removeEventListener("popstate",r),n=n.filter(function(t){return t!==e})}},navigate:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=a.state,s=a.replace,c=void 0!==s&&s;if("number"==typeof e)t.history.go(e);else{u=A({},u,{key:Date.now()+""});try{r||c?t.history.replaceState(u,null,e):t.history.pushState(u,null,e)}catch(n){t.location[c?"replace":"assign"](e)}}o=B(t),r=!0;var l=new Promise(function(t){return i=t});return n.forEach(function(t){return t({location:o,action:"PUSH"})}),l}}},z=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/",e=t.indexOf("?"),n=0,o=[{pathname:e>-1?t.substr(0,e):t,search:e>-1?t.substr(e):""}],r=[null];return{get location(){return o[n]},addEventListener:function(t,e){},removeEventListener:function(t,e){},history:{get entries(){return o},get index(){return n},get state(){return r[n]},pushState:function(t,e,i){var a=i.split("?"),u=a[0],s=a[1],c=void 0===s?"":s;n++,o.push({pathname:u,search:c.length?"?"+c:c}),r.push(t)},replaceState:function(t,e,i){var a=i.split("?"),u=a[0],s=a[1],c=void 0===s?"":s;o[n]={pathname:u,search:c},r[n]=t},go:function(t){var e=n+t;e<0||e>r.length-1||(n=e)}}}},H=!("undefined"==typeof window||!window.document||!window.document.createElement),K=V(H?window:z()),Y=K.navigate,G=function(t,e){var n=P(e);return n.displayName=t,n},J=G("Location"),Q=function(t){var e=t.children;return n.createElement(J.Consumer,null,function(t){return t?e(t):n.createElement(X,null,e)})},X=function(t){function e(){var n,o;$(this,e);for(var r=arguments.length,i=Array(r),a=0;a<r;a++)i[a]=arguments[a];return n=o=N(this,t.call.apply(t,[this].concat(i))),o.state={context:o.getContext(),refs:{unlisten:null}},N(o,n)}return I(e,t),e.prototype.getContext=function(){var t=this.props.history;return{navigate:t.navigate,location:t.location}},e.prototype.componentDidCatch=function(t,e){if(!pt(t))throw t;(0,this.props.history.navigate)(t.uri,{replace:!0})},e.prototype.componentDidUpdate=function(t,e){e.context.location!==this.state.context.location&&this.props.history._onTransitionComplete()},e.prototype.componentDidMount=function(){var t=this,e=this.state.refs,n=this.props.history;n._onTransitionComplete(),e.unlisten=n.listen(function(){Promise.resolve().then(function(){requestAnimationFrame(function(){t.unmounted||t.setState(function(){return{context:t.getContext()}})})})})},e.prototype.componentWillUnmount=function(){var t=this.state.refs;this.unmounted=!0,t.unlisten()},e.prototype.render=function(){var t=this.state.context,e=this.props.children;return n.createElement(J.Provider,{value:t},"function"==typeof e?e(t):e||null)},e}(n.Component);X.defaultProps={history:K};var Z=G("Base",{baseuri:"/",basepath:"/"}),tt=function(t){return n.createElement(Z.Consumer,null,function(e){return n.createElement(Q,null,function(o){return n.createElement(et,A({},e,o,t))})})},et=function(t){function e(){return $(this,e),N(this,t.apply(this,arguments))}return I(e,t),e.prototype.render=function(){var t=this.props,e=t.location,o=t.navigate,r=t.basepath,i=t.primary,a=t.children,u=(t.baseuri,t.component),s=void 0===u?"div":u,c=q(t,["location","navigate","basepath","primary","children","baseuri","component"]),l=n.Children.toArray(a).reduce(function(t,e){var n=yt(r)(e);return t.concat(n)},[]),p=e.pathname,f=x(l,p);if(f){var h=f.params,d=f.uri,m=f.route,v=f.route.value;r=m.default?r:m.path.replace(/\*$/,"");var y=A({},h,{uri:d,location:e,navigate:function(t,e){return o(M(t,d),e)}}),b=n.cloneElement(v,y,v.props.children?n.createElement(tt,{location:e,primary:i},v.props.children):void 0),g=i?ot:s,w=i?A({uri:d,location:e,component:s},c):c;return n.createElement(Z.Provider,{value:{baseuri:d,basepath:r}},n.createElement(g,w,b))}return null},e}(n.PureComponent);et.defaultProps={primary:!0};var nt=G("Focus"),ot=function(t){var e=t.uri,o=t.location,r=t.component,i=q(t,["uri","location","component"]);return n.createElement(nt.Consumer,null,function(t){return n.createElement(at,A({},i,{component:r,requestFocus:t,uri:e,location:o}))})},rt=!0,it=0,at=function(t){function e(){var n,o;$(this,e);for(var r=arguments.length,i=Array(r),a=0;a<r;a++)i[a]=arguments[a];return n=o=N(this,t.call.apply(t,[this].concat(i))),o.state={},o.requestFocus=function(t){!o.state.shouldFocus&&t&&t.focus()},N(o,n)}return I(e,t),e.getDerivedStateFromProps=function(t,e){if(null==e.uri)return A({shouldFocus:!0},t);var n=t.uri!==e.uri,o=e.location.pathname!==t.location.pathname&&t.location.pathname===t.uri;return A({shouldFocus:n||o},t)},e.prototype.componentDidMount=function(){it++,this.focus()},e.prototype.componentWillUnmount=function(){0===--it&&(rt=!0)},e.prototype.componentDidUpdate=function(t,e){t.location!==this.props.location&&this.state.shouldFocus&&this.focus()},e.prototype.focus=function(){var t=this.props.requestFocus;t?t(this.node):rt?rt=!1:this.node&&(this.node.contains(document.activeElement)||this.node.focus())},e.prototype.render=function(){var t=this,e=this.props,o=(e.children,e.style),r=(e.requestFocus,e.component),i=void 0===r?"div":r,a=(e.uri,e.location,q(e,["children","style","requestFocus","component","uri","location"]));return n.createElement(i,A({style:A({outline:"none"},o),tabIndex:"-1",ref:function(e){return t.node=e}},a),n.createElement(nt.Provider,{value:this.requestFocus},this.props.children))},e}(n.Component);!function(t){var e=t.prototype;if(!e||!e.isReactComponent)throw new Error("Can only polyfill class components");if("function"!=typeof t.getDerivedStateFromProps&&"function"!=typeof e.getSnapshotBeforeUpdate)return t;var n=null,o=null,r=null;if("function"==typeof e.componentWillMount?n="componentWillMount":"function"==typeof e.UNSAFE_componentWillMount&&(n="UNSAFE_componentWillMount"),"function"==typeof e.componentWillReceiveProps?o="componentWillReceiveProps":"function"==typeof e.UNSAFE_componentWillReceiveProps&&(o="UNSAFE_componentWillReceiveProps"),"function"==typeof e.componentWillUpdate?r="componentWillUpdate":"function"==typeof e.UNSAFE_componentWillUpdate&&(r="UNSAFE_componentWillUpdate"),null!==n||null!==o||null!==r){var i=t.displayName||t.name,a="function"==typeof t.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n"+i+" uses "+a+" but also contains the following legacy lifecycles:"+(null!==n?"\n "+n:"")+(null!==o?"\n "+o:"")+(null!==r?"\n "+r:"")+"\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks")}if("function"==typeof t.getDerivedStateFromProps&&(e.componentWillMount=C,e.componentWillReceiveProps=S),"function"==typeof e.getSnapshotBeforeUpdate){if("function"!=typeof e.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");e.componentWillUpdate=E;var u=e.componentDidUpdate;e.componentDidUpdate=function(t,e,n){var o=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:n;u.call(this,t,e,o)}}}(at);var ut=function(){},st=n.forwardRef;void 0===st&&(st=function(t){return t});var ct=st(function(t,e){var o=t.innerRef,r=q(t,["innerRef"]);return n.createElement(Z.Consumer,null,function(t){t.basepath;var i=t.baseuri;return n.createElement(Q,null,function(t){var a=t.location,u=t.navigate,s=r.to,c=r.state,l=r.replace,p=r.getProps,f=void 0===p?ut:p,h=q(r,["to","state","replace","getProps"]),d=M(s,i),m=encodeURI(d),v=a.pathname===m,y=_(a.pathname,m);return n.createElement("a",A({ref:e||o,"aria-current":v?"page":void 0},h,f({isCurrent:v,isPartiallyCurrent:y,href:d,location:a}),{href:d,onClick:function(t){if(h.onClick&&h.onClick(t),bt(t)){t.preventDefault();var e=l;if("boolean"!=typeof l&&v){var n=A({},a.state),o=(n.key,q(n,["key"]));r=A({},c),i=o,e=(s=Object.keys(r)).length===Object.keys(i).length&&s.every(function(t){return i.hasOwnProperty(t)&&r[t]===i[t]})}u(d,{state:c,replace:e})}var r,i,s}}))})})});function lt(t){this.uri=t}ct.displayName="Link";var pt=function(t){return t instanceof lt},ft=function(t){throw new lt(t)},ht=function(t){function e(){return $(this,e),N(this,t.apply(this,arguments))}return I(e,t),e.prototype.componentDidMount=function(){var t=this.props,e=t.navigate,n=t.to,o=(t.from,t.replace),r=void 0===o||o,i=t.state,a=(t.noThrow,t.baseuri),u=q(t,["navigate","to","from","replace","state","noThrow","baseuri"]);Promise.resolve().then(function(){var t=M(n,a);e(j(t,u),{replace:r,state:i})})},e.prototype.render=function(){var t=this.props,e=(t.navigate,t.to),n=(t.from,t.replace,t.state,t.noThrow),o=t.baseuri,r=q(t,["navigate","to","from","replace","state","noThrow","baseuri"]),i=M(e,o);return n||ft(j(i,r)),null},e}(n.Component),dt=function(t){return n.createElement(Z.Consumer,null,function(e){var o=e.baseuri;return n.createElement(Q,null,function(e){return n.createElement(ht,A({},e,{baseuri:o},t))})})},mt=function(){var t=e.useContext(J);if(!t)throw new Error("useLocation hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");return t.location},vt=function(t){return t.replace(/(^\/+|\/+$)/g,"")},yt=function t(e){return function(o){if(!o)return null;if(o.type===n.Fragment&&o.props.children)return n.Children.map(o.props.children,t(e));var r,i,a;if(o.props.path||o.props.default||o.type===dt||m(!1),o.type!==dt||o.props.from&&o.props.to||m(!1),o.type===dt&&(r=o.props.from,i=o.props.to,a=function(t){return R(t)},L(r).filter(a).sort().join("/")!==L(i).filter(a).sort().join("/"))&&m(!1),o.props.default)return{value:o,default:!0};var u=o.type===dt?o.props.from:o.props.path,s="/"===u?e:vt(e)+"/"+vt(u);return{value:o,default:o.props.default,path:o.props.children?vt(s)+"/*":s}}},bt=function(t){return!t.defaultPrevented&&0===t.button&&!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)};t.Link=ct,t.Location=Q,t.LocationProvider=X,t.Match=function(t){var e=t.path,o=t.children;return n.createElement(Z.Consumer,null,function(t){var r=t.baseuri;return n.createElement(Q,null,function(t){var n=t.navigate,i=t.location,a=M(e,r),u=O(a,i.pathname);return o({navigate:n,location:i,match:u?A({},u.params,{uri:u.uri,path:e}):null})})})},t.Redirect=dt,t.Router=tt,t.ServerLocation=function(t){var e=t.url,o=t.children,r=e.indexOf("?"),i=void 0,a="";return r>-1?(i=e.substring(0,r),a=e.substring(r)):i=e,n.createElement(J.Provider,{value:{location:{pathname:i,search:a,hash:""},navigate:function(){throw new Error("You can't call navigate on the server.")}}},o)},t.createHistory=V,t.createMemorySource=z,t.isRedirect=pt,t.navigate=Y,t.redirectTo=ft,t.globalHistory=K,t.matchPath=O,t.useLocation=mt,t.useNavigate=function(){var t=e.useContext(J);if(!t)throw new Error("useNavigate hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");return t.navigate},t.useParams=function(){var t=e.useContext(Z);if(!t)throw new Error("useParams hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");var n=mt(),o=O(t.basepath,n.pathname);return o?o.params:null},t.useMatch=function(t){if(!t)throw new Error("useMatch(path: string) requires an argument of a string to match against");var n=e.useContext(Z);if(!n)throw new Error("useMatch hook was used but a LocationContext.Provider was not found in the parent tree. Make sure this is used in a component that is a child of Router");var o=mt(),r=M(t,n.baseuri),i=O(r,o.pathname);return i?A({},i.params,{uri:i.uri,path:t}):null},Object.defineProperty(t,"__esModule",{value:!0})});