1(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[12],{ 2 3/***/ "LhCv": 4/***/ (function(module, __webpack_exports__, __webpack_require__) { 5 6"use strict"; 7/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return createBrowserHistory; }); 8/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return createHashHistory; }); 9/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return createMemoryHistory; }); 10/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return createLocation; }); 11/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return locationsAreEqual; }); 12/* unused harmony export parsePath */ 13/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return createPath; }); 14/* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("wx14"); 15/* harmony import */ var resolve_pathname__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("lCFh"); 16/* harmony import */ var value_equal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("xhmd"); 17/* harmony import */ var tiny_invariant__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("9R94"); 18 19 20 21 22 23 24function addLeadingSlash(path) { 25 return path.charAt(0) === '/' ? path : '/' + path; 26} 27function stripLeadingSlash(path) { 28 return path.charAt(0) === '/' ? path.substr(1) : path; 29} 30function hasBasename(path, prefix) { 31 return path.toLowerCase().indexOf(prefix.toLowerCase()) === 0 && '/?#'.indexOf(path.charAt(prefix.length)) !== -1; 32} 33function stripBasename(path, prefix) { 34 return hasBasename(path, prefix) ? path.substr(prefix.length) : path; 35} 36function stripTrailingSlash(path) { 37 return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path; 38} 39function parsePath(path) { 40 var pathname = path || '/'; 41 var search = ''; 42 var hash = ''; 43 var hashIndex = pathname.indexOf('#'); 44 45 if (hashIndex !== -1) { 46 hash = pathname.substr(hashIndex); 47 pathname = pathname.substr(0, hashIndex); 48 } 49 50 var searchIndex = pathname.indexOf('?'); 51 52 if (searchIndex !== -1) { 53 search = pathname.substr(searchIndex); 54 pathname = pathname.substr(0, searchIndex); 55 } 56 57 return { 58 pathname: pathname, 59 search: search === '?' ? '' : search, 60 hash: hash === '#' ? '' : hash 61 }; 62} 63function createPath(location) { 64 var pathname = location.pathname, 65 search = location.search, 66 hash = location.hash; 67 var path = pathname || '/'; 68 if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search; 69 if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash; 70 return path; 71} 72 73function createLocation(path, state, key, currentLocation) { 74 var location; 75 76 if (typeof path === 'string') { 77 // Two-arg form: push(path, state) 78 location = parsePath(path); 79 location.state = state; 80 } else { 81 // One-arg form: push(location) 82 location = Object(_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])({}, path); 83 if (location.pathname === undefined) location.pathname = ''; 84 85 if (location.search) { 86 if (location.search.charAt(0) !== '?') location.search = '?' + location.search; 87 } else { 88 location.search = ''; 89 } 90 91 if (location.hash) { 92 if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash; 93 } else { 94 location.hash = ''; 95 } 96 97 if (state !== undefined && location.state === undefined) location.state = state; 98 } 99 100 try { 101 location.pathname = decodeURI(location.pathname); 102 } catch (e) { 103 if (e instanceof URIError) { 104 throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.'); 105 } else { 106 throw e; 107 } 108 } 109 110 if (key) location.key = key; 111 112 if (currentLocation) { 113 // Resolve incomplete/relative pathname relative to current location. 114 if (!location.pathname) { 115 location.pathname = currentLocation.pathname; 116 } else if (location.pathname.charAt(0) !== '/') { 117 location.pathname = Object(resolve_pathname__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(location.pathname, currentLocation.pathname); 118 } 119 } else { 120 // When there is no prior location and pathname is empty, set it to / 121 if (!location.pathname) { 122 location.pathname = '/'; 123 } 124 } 125 126 return location; 127} 128function locationsAreEqual(a, b) { 129 return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.ke
129y && Object(value_equal__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"])(a.state, b.state); 130} 131 132function createTransitionManager() { 133 var prompt = null; 134 135 function setPrompt(nextPrompt) { 136 false ? undefined : void 0; 137 prompt = nextPrompt; 138 return function () { 139 if (prompt === nextPrompt) prompt = null; 140 }; 141 } 142 143 function confirmTransitionTo(location, action, getUserConfirmation, callback) { 144 // TODO: If another transition starts while we're still confirming 145 // the previous one, we may end up in a weird state. Figure out the 146 // best way to handle this. 147 if (prompt != null) { 148 var result = typeof prompt === 'function' ? prompt(location, action) : prompt; 149 150 if (typeof result === 'string') { 151 if (typeof getUserConfirmation === 'function') { 152 getUserConfirmation(result, callback); 153 } else { 154 false ? undefined : void 0; 155 callback(true); 156 } 157 } else { 158 // Return false from a transition hook to cancel the transition. 159 callback(result !== false); 160 } 161 } else { 162 callback(true); 163 } 164 } 165 166 var listeners = []; 167 168 function appendListener(fn) { 169 var isActive = true; 170 171 function listener() { 172 if (isActive) fn.apply(void 0, arguments); 173 } 174 175 listeners.push(listener); 176 return function () { 177 isActive = false; 178 listeners = listeners.filter(function (item) { 179 return item !== listener; 180 }); 181 }; 182 } 183 184 function notifyListeners() { 185 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 186 args[_key] = arguments[_key]; 187 } 188 189 listeners.forEach(function (listener) { 190 return listener.apply(void 0, args); 191 }); 192 } 193 194 return { 195 setPrompt: setPrompt, 196 confirmTransitionTo: confirmTransitionTo, 197 appendListener: appendListener, 198 notifyListeners: notifyListeners 199 }; 200} 201 202var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); 203function getConfirmation(message, callback) { 204 callback(window.confirm(message)); // eslint-disable-line no-alert 205} 206/** 207 * Returns true if the HTML5 history API is supported. Taken from Modernizr. 208 * 209 * https://github.com/Modernizr/Modernizr/blob/master/LICENSE 210 * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js 211 * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586 212 */ 213 214function supportsHistory() { 215 var ua = window.navigator.userAgent; 216 if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false; 217 return window.history && 'pushState' in window.history; 218} 219/** 220 * Returns true if browser fires popstate on hash change. 221 * IE10 and IE11 do not. 222 */ 223 224function supportsPopStateOnHashChange() { 225 return window.navigator.userAgent.indexOf('Trident') === -1; 226} 227/** 228 * Returns false if using go(n) with hash history causes a full page reload. 229 */ 230 231function supportsGoWithoutReloadUsingHash() { 232 return window.navigator.userAgent.indexOf('Firefox') === -1; 233} 234/** 235 * Returns true if a given popstate event is an extraneous WebKit event. 236 * Accounts for the fact that Chrome on iOS fires real popstate events 237 * containing undefined state when pressing the back button. 238 */ 239 240function isExtraneousPopstateEvent(event) { 241 return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1; 242} 243 244var PopStateEvent = 'popstate'; 245var HashChangeEvent = 'hashchange'; 246 247function getHistoryState() { 248 try { 249 return window.history.state || {}; 250 } catch (e) { 251 // IE 11 sometimes throws when accessing window.history.state 252 // See https://github.com/ReactTraining/history/pull/289 253 return {}; 254 } 255} 256/** 257 * Creates a history object that uses the HTML5 history API including 258 * pushState, replaceState, and the popstate event. 259 */ 260 261 262function createBrowserHistory(props) { 263 if (props === void 0) { 264 props = {}; 265 } 266 267 !canUseDOM ? false ? undefined : Object(tiny_invariant__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"])(false) : void 0; 268 var globalHistory = window.history; 269 var canUseHistory = supportsHistory(); 270 var needsHashChangeListener = !supportsPopStateOnHashChange(); 271 var _props = props, 272 _props$forceRefresh = _props.forceRefresh, 273 forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh, 274 _props$getUserConfirm = _props.getUserConfirmation, 275 getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm, 276 _props$keyLength = _props.keyLength,
277 keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength; 278 var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : ''; 279 280 function getDOMLocation(historyState) { 281 var _ref = historyState || {}, 282 key = _ref.key, 283 state = _ref.state; 284 285 var _window$location = window.location, 286 pathname = _window$location.pathname, 287 search = _window$location.search, 288 hash = _window$location.hash; 289 var path = pathname + search + hash; 290 false ? undefined : void 0; 291 if (basename) path = stripBasename(path, basename); 292 return createLocation(path, state, key); 293 } 294 295 function createKey() { 296 return Math.random().toString(36).substr(2, keyLength); 297 } 298 299 var transitionManager = createTransitionManager(); 300 301 function setState(nextState) { 302 Object(_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(history, nextState); 303 304 history.length = globalHistory.length; 305 transitionManager.notifyListeners(history.location, history.action); 306 } 307 308 function handlePopState(event) { 309 // Ignore extraneous popstate events in WebKit. 310 if (isExtraneousPopstateEvent(event)) return; 311 handlePop(getDOMLocation(event.state)); 312 } 313 314 function handleHashChange() { 315 handlePop(getDOMLocation(getHistoryState())); 316 } 317 318 var forceNextPop = false; 319 320 function handlePop(location) { 321 if (forceNextPop) { 322 forceNextPop = false; 323 setState(); 324 } else { 325 var action = 'POP'; 326 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 327 if (ok) { 328 setState({ 329 action: action, 330 location: location 331 }); 332 } else { 333 revertPop(location); 334 } 335 }); 336 } 337 } 338 339 function revertPop(fromLocation) { 340 var toLocation = history.location; // TODO: We could probably make this more reliable by 341 // keeping a list of keys we've seen in sessionStorage. 342 // Instead, we just default to 0 for keys we don't know. 343 344 var toIndex = allKeys.indexOf(toLocation.key); 345 if (toIndex === -1) toIndex = 0; 346 var fromIndex = allKeys.indexOf(fromLocation.key); 347 if (fromIndex === -1) fromIndex = 0; 348 var delta = toIndex - fromIndex; 349 350 if (delta) { 351 forceNextPop = true; 352 go(delta); 353 } 354 } 355 356 var initialLocation = getDOMLocation(getHistoryState()); 357 var allKeys = [initialLocation.key]; // Public interface 358 359 function createHref(location) { 360 return basename + createPath(location); 361 } 362 363 function push(path, state) { 364 false ? undefined : void 0; 365 var action = 'PUSH'; 366 var location = createLocation(path, state, createKey(), history.location); 367 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 368 if (!ok) return; 369 var href = createHref(location); 370 var key = location.key, 371 state = location.state; 372 373 if (canUseHistory) { 374 globalHistory.pushState({ 375 key: key, 376 state: state 377 }, null, href); 378 379 if (forceRefresh) { 380 window.location.href = href; 381 } else { 382 var prevIndex = allKeys.indexOf(history.location.key); 383 var nextKeys = allKeys.slice(0, prevIndex + 1); 384 nextKeys.push(location.key); 385 allKeys = nextKeys; 386 setState({ 387 action: action, 388 location: location 389 }); 390 } 391 } else { 392 false ? undefined : void 0; 393 window.location.href = href; 394 } 395 }); 396 } 397 398 function replace(path, state) { 399 false ? undefined : void 0; 400 var action = 'REPLACE'; 401 var location = createLocation(path, state, createKey(), history.location); 402 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 403 if (!ok) return; 404 var href = createHref(location); 405 var key = location.key, 406 state = location.state; 407 408 if (canUseHistory) { 409 globalHistory.replaceState({ 410 key: key, 411 state: state 412 }, null, href); 413 414 if (forceRefresh) { 415 window.location.replace(href); 416 } else {
417 var prevIndex = allKeys.indexOf(history.location.key); 418 if (prevIndex !== -1) allKeys[prevIndex] = location.key; 419 setState({ 420 action: action, 421 location: location 422 }); 423 } 424 } else { 425 false ? undefined : void 0; 426 window.location.replace(href); 427 } 428 }); 429 } 430 431 function go(n) { 432 globalHistory.go(n); 433 } 434 435 function goBack() { 436 go(-1); 437 } 438 439 function goForward() { 440 go(1); 441 } 442 443 var listenerCount = 0; 444 445 function checkDOMListeners(delta) { 446 listenerCount += delta; 447 448 if (listenerCount === 1 && delta === 1) { 449 window.addEventListener(PopStateEvent, handlePopState); 450 if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange); 451 } else if (listenerCount === 0) { 452 window.removeEventListener(PopStateEvent, handlePopState); 453 if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange); 454 } 455 } 456 457 var isBlocked = false; 458 459 function block(prompt) { 460 if (prompt === void 0) { 461 prompt = false; 462 } 463 464 var unblock = transitionManager.setPrompt(prompt); 465 466 if (!isBlocked) { 467 checkDOMListeners(1); 468 isBlocked = true; 469 } 470 471 return function () { 472 if (isBlocked) { 473 isBlocked = false; 474 checkDOMListeners(-1); 475 } 476 477 return unblock(); 478 }; 479 } 480 481 function listen(listener) { 482 var unlisten = transitionManager.appendListener(listener); 483 checkDOMListeners(1); 484 return function () { 485 checkDOMListeners(-1); 486 unlisten(); 487 }; 488 } 489 490 var history = { 491 length: globalHistory.length, 492 action: 'POP', 493 location: initialLocation, 494 createHref: createHref, 495 push: push, 496 replace: replace, 497 go: go, 498 goBack: goBack, 499 goForward: goForward, 500 block: block, 501 listen: listen 502 }; 503 return history; 504} 505 506var HashChangeEvent$1 = 'hashchange'; 507var HashPathCoders = { 508 hashbang: { 509 encodePath: function encodePath(path) { 510 return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path); 511 }, 512 decodePath: function decodePath(path) { 513 return path.charAt(0) === '!' ? path.substr(1) : path; 514 } 515 }, 516 noslash: { 517 encodePath: stripLeadingSlash, 518 decodePath: addLeadingSlash 519 }, 520 slash: { 521 encodePath: addLeadingSlash, 522 decodePath: addLeadingSlash 523 } 524}; 525 526function stripHash(url) { 527 var hashIndex = url.indexOf('#'); 528 return hashIndex === -1 ? url : url.slice(0, hashIndex); 529} 530 531function getHashPath() { 532 // We can't use window.location.hash here because it's not 533 // consistent across browsers - Firefox will pre-decode it! 534 var href = window.location.href; 535 var hashIndex = href.indexOf('#'); 536 return hashIndex === -1 ? '' : href.substring(hashIndex + 1); 537} 538 539function pushHashPath(path) { 540 window.location.hash = path; 541} 542 543function replaceHashPath(path) { 544 window.location.replace(stripHash(window.location.href) + '#' + path); 545} 546 547function createHashHistory(props) { 548 if (props === void 0) { 549 props = {}; 550 } 551 552 !canUseDOM ? false ? undefined : Object(tiny_invariant__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"])(false) : void 0; 553 var globalHistory = window.history; 554 var canGoWithoutReload = supportsGoWithoutReloadUsingHash(); 555 var _props = props, 556 _props$getUserConfirm = _props.getUserConfirmation, 557 getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm, 558 _props$hashType = _props.hashType, 559 hashType = _props$hashType === void 0 ? 'slash' : _props$hashType; 560 var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : ''; 561 var _HashPathCoders$hashT = HashPathCoders[hashType], 562 encodePath = _HashPathCoders$hashT.encodePath, 563 decodePath = _HashPathCoders$hashT.decodePath; 564 565 function getDOMLocation() { 566 var path = decodePath(getHashPath()); 567 false ? undefined : void 0; 568 if (basename) path = stripBasename(path, basename); 569 return createLocation(path); 570 } 571 572 var transitionManager = createTransitionManager(); 573 574 function setState(nextState) { 575 Object(_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(history, nextState); 576 577 history.length = globalHistory.length; 578 transitionManager.notifyListeners(history.location, history.action); 579 } 580 581 var forceNextPop = false;
582 var ignorePath = null; 583 584 function locationsAreEqual$$1(a, b) { 585 return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash; 586 } 587 588 function handleHashChange() { 589 var path = getHashPath(); 590 var encodedPath = encodePath(path); 591 592 if (path !== encodedPath) { 593 // Ensure we always have a properly-encoded hash. 594 replaceHashPath(encodedPath); 595 } else { 596 var location = getDOMLocation(); 597 var prevLocation = history.location; 598 if (!forceNextPop && locationsAreEqual$$1(prevLocation, location)) return; // A hashchange doesn't always == location change. 599 600 if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace. 601 602 ignorePath = null; 603 handlePop(location); 604 } 605 } 606 607 function handlePop(location) { 608 if (forceNextPop) { 609 forceNextPop = false; 610 setState(); 611 } else { 612 var action = 'POP'; 613 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 614 if (ok) { 615 setState({ 616 action: action, 617 location: location 618 }); 619 } else { 620 revertPop(location); 621 } 622 }); 623 } 624 } 625 626 function revertPop(fromLocation) { 627 var toLocation = history.location; // TODO: We could probably make this more reliable by 628 // keeping a list of paths we've seen in sessionStorage. 629 // Instead, we just default to 0 for paths we don't know. 630 631 var toIndex = allPaths.lastIndexOf(createPath(toLocation)); 632 if (toIndex === -1) toIndex = 0; 633 var fromIndex = allPaths.lastIndexOf(createPath(fromLocation)); 634 if (fromIndex === -1) fromIndex = 0; 635 var delta = toIndex - fromIndex; 636 637 if (delta) { 638 forceNextPop = true; 639 go(delta); 640 } 641 } // Ensure the hash is encoded properly before doing anything else. 642 643 644 var path = getHashPath(); 645 var encodedPath = encodePath(path); 646 if (path !== encodedPath) replaceHashPath(encodedPath); 647 var initialLocation = getDOMLocation(); 648 var allPaths = [createPath(initialLocation)]; // Public interface 649 650 function createHref(location) { 651 var baseTag = document.querySelector('base'); 652 var href = ''; 653 654 if (baseTag && baseTag.getAttribute('href')) { 655 href = stripHash(window.location.href); 656 } 657 658 return href + '#' + encodePath(basename + createPath(location)); 659 } 660 661 function push(path, state) { 662 false ? undefined : void 0; 663 var action = 'PUSH'; 664 var location = createLocation(path, undefined, undefined, history.location); 665 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 666 if (!ok) return; 667 var path = createPath(location); 668 var encodedPath = encodePath(basename + path); 669 var hashChanged = getHashPath() !== encodedPath; 670 671 if (hashChanged) { 672 // We cannot tell if a hashchange was caused by a PUSH, so we'd 673 // rather setState here and ignore the hashchange. The caveat here 674 // is that other hash histories in the page will consider it a POP. 675 ignorePath = path; 676 pushHashPath(encodedPath); 677 var prevIndex = allPaths.lastIndexOf(createPath(history.location)); 678 var nextPaths = allPaths.slice(0, prevIndex + 1); 679 nextPaths.push(path); 680 allPaths = nextPaths; 681 setState({ 682 action: action, 683 location: location 684 }); 685 } else { 686 false ? undefined : void 0; 687 setState(); 688 } 689 }); 690 } 691 692 function replace(path, state) { 693 false ? undefined : void 0; 694 var action = 'REPLACE'; 695 var location = createLocation(path, undefined, undefined, history.location); 696 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 697 if (!ok) return; 698 var path = createPath(location); 699 var encodedPath = encodePath(basename + path); 700 var hashChanged = getHashPath() !== encodedPath; 701 702 if (hashChanged) { 703 // We cannot tell if a hashchange was caused by a REPLACE, so we'd 704 // rather setState here and ignore the hashchange. The caveat here 705 // is that other hash histories in the page will consider it a POP. 706 ignorePath = path; 707 replaceHashPath(encodedPath); 708 } 709 710 var prevIndex = allPaths.indexOf(createPath(history.location)); 711 if (prevIndex !== -1) allPaths[prevIndex] = path; 712 setState({ 713 action: action, 714 location: location 715 }); 716 }); 717 } 718 719 function go(n) { 720 false ? undefined : void 0; 721 globalHistory.go(n); 722 } 723 724 function goBack() { 725 go(-1); 726 } 727 728 function goForward() { 729 go(1); 730 } 731 732 var listenerCount = 0; 733 734 function checkDOMListeners(delta) { 735 listenerCount += delta; 736 737 if (listenerCount === 1 && delta === 1) { 738 window.addEventListener(HashChangeEvent$1, handleHashChange); 739 } else if (listenerCount === 0) { 740 window.removeEventListener(HashChangeEvent$1, handleHashChange); 741 } 742 } 743 744 var isBlocked = false;
745 746 function block(prompt) { 747 if (prompt === void 0) { 748 prompt = false; 749 } 750 751 var unblock = transitionManager.setPrompt(prompt); 752 753 if (!isBlocked) { 754 checkDOMListeners(1); 755 isBlocked = true; 756 } 757 758 return function () { 759 if (isBlocked) { 760 isBlocked = false; 761 checkDOMListeners(-1); 762 } 763 764 return unblock(); 765 }; 766 } 767 768 function listen(listener) { 769 var unlisten = transitionManager.appendListener(listener); 770 checkDOMListeners(1); 771 return function () { 772 checkDOMListeners(-1); 773 unlisten(); 774 }; 775 } 776 777 var history = { 778 length: globalHistory.length, 779 action: 'POP', 780 location: initialLocation, 781 createHref: createHref, 782 push: push, 783 replace: replace, 784 go: go, 785 goBack: goBack, 786 goForward: goForward, 787 block: block, 788 listen: listen 789 }; 790 return history; 791} 792 793function clamp(n, lowerBound, upperBound) { 794 return Math.min(Math.max(n, lowerBound), upperBound); 795} 796/** 797 * Creates a history object that stores locations in memory. 798 */ 799 800 801function createMemoryHistory(props) { 802 if (props === void 0) { 803 props = {}; 804 } 805 806 var _props = props, 807 getUserConfirmation = _props.getUserConfirmation, 808 _props$initialEntries = _props.initialEntries, 809 initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries, 810 _props$initialIndex = _props.initialIndex, 811 initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex, 812 _props$keyLength = _props.keyLength, 813 keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength; 814 var transitionManager = createTransitionManager(); 815 816 function setState(nextState) { 817 Object(_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(history, nextState); 818 819 history.length = history.entries.length; 820 transitionManager.notifyListeners(history.location, history.action); 821 } 822 823 function createKey() { 824 return Math.random().toString(36).substr(2, keyLength); 825 } 826 827 var index = clamp(initialIndex, 0, initialEntries.length - 1); 828 var entries = initialEntries.map(function (entry) { 829 return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey()); 830 }); // Public interface 831 832 var createHref = createPath; 833 834 function push(path, state) { 835 false ? undefined : void 0; 836 var action = 'PUSH'; 837 var location = createLocation(path, state, createKey(), history.location); 838 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 839 if (!ok) return; 840 var prevIndex = history.index; 841 var nextIndex = prevIndex + 1; 842 var nextEntries = history.entries.slice(0); 843 844 if (nextEntries.length > nextIndex) { 845 nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location); 846 } else { 847 nextEntries.push(location); 848 } 849 850 setState({ 851 action: action, 852 location: location, 853 index: nextIndex, 854 entries: nextEntries 855 }); 856 }); 857 } 858 859 function replace(path, state) { 860 false ? undefined : void 0; 861 var action = 'REPLACE'; 862 var location = createLocation(path, state, createKey(), history.location); 863 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 864 if (!ok) return; 865 history.entries[history.index] = location; 866 setState({ 867 action: action, 868 location: location 869 }); 870 }); 871 } 872 873 function go(n) { 874 var nextIndex = clamp(history.index + n, 0, history.entries.length - 1); 875 var action = 'POP'; 876 var location = history.entries[nextIndex]; 877 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { 878 if (ok) { 879 setState({ 880 action: action, 881 location: location, 882 index: nextIndex 883 }); 884 } else { 885 // Mimic the behavior of DOM histories by 886 // causing a render after a cancelled POP. 887 setState(); 888 } 889 }); 890 } 891 892 function goBack() { 893 go(-1); 894 } 895 896 function goForward() { 897 go(1); 898 } 899 900 function canGo(n) { 901 var nextIndex = history.index + n; 902 return nextIndex >= 0 && nextIndex < history.entries.length; 903 } 904 905 function block(prompt) { 906 if (prompt === void 0) { 907 prompt = false;
908 } 909 910 return transitionManager.setPrompt(prompt); 911 } 912 913 function listen(listener) { 914 return transitionManager.appendListener(listener); 915 } 916 917 var history = { 918 length: entries.length, 919 action: 'POP', 920 location: entries[index], 921 index: index, 922 entries: entries, 923 createHref: createHref, 924 push: push, 925 replace: replace, 926 go: go, 927 goBack: goBack, 928 goForward: goForward, 929 canGo: canGo, 930 block: block, 931 listen: listen 932 }; 933 return history; 934} 935 936 937 938 939/***/ }) 940 941}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.