= 48 && code <= 57) ||\n // `A-Z`\n (code >= 65 && code <= 90) ||\n // `a-z`\n (code >= 97 && code <= 122) ||\n // `_`\n code === 95\n ) {\n name += str[j++];\n continue;\n }\n\n break;\n }\n\n if (!name) throw new TypeError(`Missing parameter name at ${i}`);\n\n tokens.push({ type: \"NAME\", index: i, value: name });\n i = j;\n continue;\n }\n\n if (char === \"(\") {\n let count = 1;\n let pattern = \"\";\n let j = i + 1;\n\n if (str[j] === \"?\") {\n throw new TypeError(`Pattern cannot start with \"?\" at ${j}`);\n }\n\n while (j < str.length) {\n if (str[j] === \"\\\\\") {\n pattern += str[j++] + str[j++];\n continue;\n }\n\n if (str[j] === \")\") {\n count--;\n if (count === 0) {\n j++;\n break;\n }\n } else if (str[j] === \"(\") {\n count++;\n if (str[j + 1] !== \"?\") {\n throw new TypeError(`Capturing groups are not allowed at ${j}`);\n }\n }\n\n pattern += str[j++];\n }\n\n if (count) throw new TypeError(`Unbalanced pattern at ${i}`);\n if (!pattern) throw new TypeError(`Missing pattern at ${i}`);\n\n tokens.push({ type: \"PATTERN\", index: i, value: pattern });\n i = j;\n continue;\n }\n\n tokens.push({ type: \"CHAR\", index: i, value: str[i++] });\n }\n\n tokens.push({ type: \"END\", index: i, value: \"\" });\n\n return tokens;\n}\n\nexport interface ParseOptions {\n /**\n * Set the default delimiter for repeat parameters. (default: `'/'`)\n */\n delimiter?: string;\n /**\n * List of characters to automatically consider prefixes when parsing.\n */\n prefixes?: string;\n}\n\n/**\n * Parse a string for the raw tokens.\n */\nexport function parse(str: string, options: ParseOptions = {}): Token[] {\n const tokens = lexer(str);\n const { prefixes = \"./\" } = options;\n const defaultPattern = `[^${escapeString(options.delimiter || \"/#?\")}]+?`;\n const result: Token[] = [];\n let key = 0;\n let i = 0;\n let path = \"\";\n\n const tryConsume = (type: LexToken[\"type\"]): string | undefined => {\n if (i < tokens.length && tokens[i].type === type) return tokens[i++].value;\n };\n\n const mustConsume = (type: LexToken[\"type\"]): string => {\n const value = tryConsume(type);\n if (value !== undefined) return value;\n const { type: nextType, index } = tokens[i];\n throw new TypeError(`Unexpected ${nextType} at ${index}, expected ${type}`);\n };\n\n const consumeText = (): string => {\n let result = \"\";\n let value: string | undefined;\n // tslint:disable-next-line\n while ((value = tryConsume(\"CHAR\") || tryConsume(\"ESCAPED_CHAR\"))) {\n result += value;\n }\n return result;\n };\n\n while (i < tokens.length) {\n const char = tryConsume(\"CHAR\");\n const name = tryConsume(\"NAME\");\n const pattern = tryConsume(\"PATTERN\");\n\n if (name || pattern) {\n let prefix = char || \"\";\n\n if (prefixes.indexOf(prefix) === -1) {\n path += prefix;\n prefix = \"\";\n }\n\n if (path) {\n result.push(path);\n path = \"\";\n }\n\n result.push({\n name: name || key++,\n prefix,\n suffix: \"\",\n pattern: pattern || defaultPattern,\n modifier: tryConsume(\"MODIFIER\") || \"\"\n });\n continue;\n }\n\n const value = char || tryConsume(\"ESCAPED_CHAR\");\n if (value) {\n path += value;\n continue;\n }\n\n if (path) {\n result.push(path);\n path = \"\";\n }\n\n const open = tryConsume(\"OPEN\");\n if (open) {\n const prefix = consumeText();\n const name = tryConsume(\"NAME\") || \"\";\n const pattern = tryConsume(\"PATTERN\") || \"\";\n const suffix = consumeText();\n\n mustConsume(\"CLOSE\");\n\n result.push({\n name: name || (pattern ? key++ : \"\"),\n pattern: name && !pattern ? defaultPattern : pattern,\n prefix,\n suffix,\n modifier: tryConsume(\"MODIFIER\") || \"\"\n });\n continue;\n }\n\n mustConsume(\"END\");\n }\n\n return result;\n}\n\nexport interface TokensToFunctionOptions {\n /**\n * When `true` the regexp will be case sensitive. (default: `false`)\n */\n sensitive?: boolean;\n /**\n * Function for encoding input strings for output.\n */\n encode?: (value: string, token: Key) => string;\n /**\n * When `false` the function can produce an invalid (unmatched) path. (default: `true`)\n */\n validate?: boolean;\n}\n\n/**\n * Compile a string to a template function for the path.\n */\nexport function compile(\n str: string,\n options?: ParseOptions & TokensToFunctionOptions\n) {\n return tokensToFunction
(parse(str, options), options);\n}\n\nexport type PathFunction
= (data?: P) => string;\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nexport function tokensToFunction
(\n tokens: Token[],\n options: TokensToFunctionOptions = {}\n): PathFunction
{\n const reFlags = flags(options);\n const { encode = (x: string) => x, validate = true } = options;\n\n // Compile all the tokens into regexps.\n const matches = tokens.map(token => {\n if (typeof token === \"object\") {\n return new RegExp(`^(?:${token.pattern})$`, reFlags);\n }\n });\n\n return (data: Record | null | undefined) => {\n let path = \"\";\n\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n\n if (typeof token === \"string\") {\n path += token;\n continue;\n }\n\n const value = data ? data[token.name] : undefined;\n const optional = token.modifier === \"?\" || token.modifier === \"*\";\n const repeat = token.modifier === \"*\" || token.modifier === \"+\";\n\n if (Array.isArray(value)) {\n if (!repeat) {\n throw new TypeError(\n `Expected \"${token.name}\" to not repeat, but got an array`\n );\n }\n\n if (value.length === 0) {\n if (optional) continue;\n\n throw new TypeError(`Expected \"${token.name}\" to not be empty`);\n }\n\n for (let j = 0; j < value.length; j++) {\n const segment = encode(value[j], token);\n\n if (validate && !(matches[i] as RegExp).test(segment)) {\n throw new TypeError(\n `Expected all \"${token.name}\" to match \"${token.pattern}\", but got \"${segment}\"`\n );\n }\n\n path += token.prefix + segment + token.suffix;\n }\n\n continue;\n }\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n const segment = encode(String(value), token);\n\n if (validate && !(matches[i] as RegExp).test(segment)) {\n throw new TypeError(\n `Expected \"${token.name}\" to match \"${token.pattern}\", but got \"${segment}\"`\n );\n }\n\n path += token.prefix + segment + token.suffix;\n continue;\n }\n\n if (optional) continue;\n\n const typeOfMessage = repeat ? \"an array\" : \"a string\";\n throw new TypeError(`Expected \"${token.name}\" to be ${typeOfMessage}`);\n }\n\n return path;\n };\n}\n\nexport interface RegexpToFunctionOptions {\n /**\n * Function for decoding strings for params.\n */\n decode?: (value: string, token: Key) => string;\n}\n\n/**\n * A match result contains data about the path match.\n */\nexport interface MatchResult {\n path: string;\n index: number;\n params: P;\n}\n\n/**\n * A match is either `false` (no match) or a match result.\n */\nexport type Match
= false | MatchResult
;\n\n/**\n * The match function takes a string and returns whether it matched the path.\n */\nexport type MatchFunction
= (\n path: string\n) => Match
;\n\n/**\n * Create path match function from `path-to-regexp` spec.\n */\nexport function match
(\n str: Path,\n options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions\n) {\n const keys: Key[] = [];\n const re = pathToRegexp(str, keys, options);\n return regexpToFunction
(re, keys, options);\n}\n\n/**\n * Create a path match function from `path-to-regexp` output.\n */\nexport function regexpToFunction
(\n re: RegExp,\n keys: Key[],\n options: RegexpToFunctionOptions = {}\n): MatchFunction
{\n const { decode = (x: string) => x } = options;\n\n return function(pathname: string) {\n const m = re.exec(pathname);\n if (!m) return false;\n\n const { 0: path, index } = m;\n const params = Object.create(null);\n\n for (let i = 1; i < m.length; i++) {\n // tslint:disable-next-line\n if (m[i] === undefined) continue;\n\n const key = keys[i - 1];\n\n if (key.modifier === \"*\" || key.modifier === \"+\") {\n params[key.name] = m[i].split(key.prefix + key.suffix).map(value => {\n return decode(value, key);\n });\n } else {\n params[key.name] = decode(m[i], key);\n }\n }\n\n return { path, index, params };\n };\n}\n\n/**\n * Escape a regular expression string.\n */\nfunction escapeString(str: string) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, \"\\\\$1\");\n}\n\n/**\n * Get the flags for a regexp from the options.\n */\nfunction flags(options?: { sensitive?: boolean }) {\n return options && options.sensitive ? \"\" : \"i\";\n}\n\n/**\n * Metadata about a key.\n */\nexport interface Key {\n name: string | number;\n prefix: string;\n suffix: string;\n pattern: string;\n modifier: string;\n}\n\n/**\n * A token is a string (nothing special) or key metadata (capture group).\n */\nexport type Token = string | Key;\n\n/**\n * Pull out keys from a regexp.\n */\nfunction regexpToRegexp(path: RegExp, keys?: Key[]): RegExp {\n if (!keys) return path;\n\n const groupsRegex = /\\((?:\\?<(.*?)>)?(?!\\?)/g;\n\n let index = 0;\n let execResult = groupsRegex.exec(path.source);\n while (execResult) {\n keys.push({\n // Use parenthesized substring match if available, index otherwise\n name: execResult[1] || index++,\n prefix: \"\",\n suffix: \"\",\n modifier: \"\",\n pattern: \"\"\n });\n execResult = groupsRegex.exec(path.source);\n }\n\n return path;\n}\n\n/**\n * Transform an array into a regexp.\n */\nfunction arrayToRegexp(\n paths: Array,\n keys?: Key[],\n options?: TokensToRegexpOptions & ParseOptions\n): RegExp {\n const parts = paths.map(path => pathToRegexp(path, keys, options).source);\n return new RegExp(`(?:${parts.join(\"|\")})`, flags(options));\n}\n\n/**\n * Create a path regexp from string input.\n */\nfunction stringToRegexp(\n path: string,\n keys?: Key[],\n options?: TokensToRegexpOptions & ParseOptions\n) {\n return tokensToRegexp(parse(path, options), keys, options);\n}\n\nexport interface TokensToRegexpOptions {\n /**\n * When `true` the regexp will be case sensitive. (default: `false`)\n */\n sensitive?: boolean;\n /**\n * When `true` the regexp won't allow an optional trailing delimiter to match. (default: `false`)\n */\n strict?: boolean;\n /**\n * When `true` the regexp will match to the end of the string. (default: `true`)\n */\n end?: boolean;\n /**\n * When `true` the regexp will match from the beginning of the string. (default: `true`)\n */\n start?: boolean;\n /**\n * Sets the final character for non-ending optimistic matches. (default: `/`)\n */\n delimiter?: string;\n /**\n * List of characters that can also be \"end\" characters.\n */\n endsWith?: string;\n /**\n * Encode path tokens for use in the `RegExp`.\n */\n encode?: (value: string) => string;\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n */\nexport function tokensToRegexp(\n tokens: Token[],\n keys?: Key[],\n options: TokensToRegexpOptions = {}\n) {\n const {\n strict = false,\n start = true,\n end = true,\n encode = (x: string) => x\n } = options;\n const endsWith = `[${escapeString(options.endsWith || \"\")}]|$`;\n const delimiter = `[${escapeString(options.delimiter || \"/#?\")}]`;\n let route = start ? \"^\" : \"\";\n\n // Iterate over the tokens and create our regexp string.\n for (const token of tokens) {\n if (typeof token === \"string\") {\n route += escapeString(encode(token));\n } else {\n const prefix = escapeString(encode(token.prefix));\n const suffix = escapeString(encode(token.suffix));\n\n if (token.pattern) {\n if (keys) keys.push(token);\n\n if (prefix || suffix) {\n if (token.modifier === \"+\" || token.modifier === \"*\") {\n const mod = token.modifier === \"*\" ? \"?\" : \"\";\n route += `(?:${prefix}((?:${token.pattern})(?:${suffix}${prefix}(?:${token.pattern}))*)${suffix})${mod}`;\n } else {\n route += `(?:${prefix}(${token.pattern})${suffix})${token.modifier}`;\n }\n } else {\n route += `(${token.pattern})${token.modifier}`;\n }\n } else {\n route += `(?:${prefix}${suffix})${token.modifier}`;\n }\n }\n }\n\n if (end) {\n if (!strict) route += `${delimiter}?`;\n\n route += !options.endsWith ? \"$\" : `(?=${endsWith})`;\n } else {\n const endToken = tokens[tokens.length - 1];\n const isEndDelimited =\n typeof endToken === \"string\"\n ? delimiter.indexOf(endToken[endToken.length - 1]) > -1\n : // tslint:disable-next-line\n endToken === undefined;\n\n if (!strict) {\n route += `(?:${delimiter}(?=${endsWith}))?`;\n }\n\n if (!isEndDelimited) {\n route += `(?=${delimiter}|${endsWith})`;\n }\n }\n\n return new RegExp(route, flags(options));\n}\n\n/**\n * Supported `path-to-regexp` input types.\n */\nexport type Path = string | RegExp | Array;\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n */\nexport function pathToRegexp(\n path: Path,\n keys?: Key[],\n options?: TokensToRegexpOptions & ParseOptions\n) {\n if (path instanceof RegExp) return regexpToRegexp(path, keys);\n if (Array.isArray(path)) return arrayToRegexp(path, keys, options);\n return stringToRegexp(path, keys, options);\n}\n","import $ from '../../shared/dom7';\nimport History from '../../shared/history';\nimport { getSupport } from '../../shared/get-support';\nimport { getDevice } from '../../shared/get-device';\nimport { now } from '../../shared/utils';\n\nfunction SwipeBack(r) {\n var router = r;\n var $el = router.$el,\n $navbarsEl = router.$navbarsEl,\n app = router.app,\n params = router.params;\n var support = getSupport();\n var device = getDevice();\n var isTouched = false;\n var isMoved = false;\n var touchesStart = {};\n var isScrolling;\n var $currentPageEl = [];\n var $previousPageEl = [];\n var viewContainerWidth;\n var touchesDiff;\n var allowViewTouchMove = true;\n var touchStartTime;\n var $currentNavbarEl = [];\n var $previousNavbarEl = [];\n var dynamicNavbar;\n var $pageShadowEl;\n var $pageOpacityEl;\n var animatableNavEls;\n var paramsSwipeBackAnimateShadow = params[app.theme + \"SwipeBackAnimateShadow\"];\n var paramsSwipeBackAnimateOpacity = params[app.theme + \"SwipeBackAnimateOpacity\"];\n var paramsSwipeBackActiveArea = params[app.theme + \"SwipeBackActiveArea\"];\n var paramsSwipeBackThreshold = params[app.theme + \"SwipeBackThreshold\"];\n var transformOrigin = app.rtl ? 'right center' : 'left center';\n var transformOriginTitleLarge = app.rtl ? 'calc(100% - var(--f7-navbar-large-title-padding-left) - var(--f7-safe-area-left)) center' : 'calc(var(--f7-navbar-large-title-padding-left) + var(--f7-safe-area-left)) center';\n\n function animatableNavElements() {\n var els = [];\n var inverter = app.rtl ? -1 : 1;\n var currentNavIsTransparent = $currentNavbarEl.hasClass('navbar-transparent') && !$currentNavbarEl.hasClass('navbar-large') && !$currentNavbarEl.hasClass('navbar-transparent-visible');\n var currentNavIsLarge = $currentNavbarEl.hasClass('navbar-large');\n var currentNavIsCollapsed = $currentNavbarEl.hasClass('navbar-large-collapsed');\n var currentNavIsLargeTransparent = $currentNavbarEl.hasClass('navbar-large-transparent') || $currentNavbarEl.hasClass('navbar-large') && $currentNavbarEl.hasClass('navbar-transparent');\n var previousNavIsTransparent = $previousNavbarEl.hasClass('navbar-transparent') && !$previousNavbarEl.hasClass('navbar-large') && !$previousNavbarEl.hasClass('navbar-transparent-visible');\n var previousNavIsLarge = $previousNavbarEl.hasClass('navbar-large');\n var previousNavIsCollapsed = $previousNavbarEl.hasClass('navbar-large-collapsed');\n var previousNavIsLargeTransparent = $previousNavbarEl.hasClass('navbar-large-transparent') || $previousNavbarEl.hasClass('navbar-large') && $previousNavbarEl.hasClass('navbar-transparent');\n var fromLarge = currentNavIsLarge && !currentNavIsCollapsed;\n var toLarge = previousNavIsLarge && !previousNavIsCollapsed;\n var $currentNavElements = $currentNavbarEl.find('.left, .title, .right, .subnavbar, .fading, .title-large, .navbar-bg');\n var $previousNavElements = $previousNavbarEl.find('.left, .title, .right, .subnavbar, .fading, .title-large, .navbar-bg');\n var activeNavBackIconText;\n var previousNavBackIconText;\n\n if (params.iosAnimateNavbarBackIcon) {\n if ($currentNavbarEl.hasClass('sliding') || $currentNavbarEl.find('.navbar-inner.sliding').length) {\n activeNavBackIconText = $currentNavbarEl.find('.left').find('.back .icon + span').eq(0);\n } else {\n activeNavBackIconText = $currentNavbarEl.find('.left.sliding').find('.back .icon + span').eq(0);\n }\n\n if ($previousNavbarEl.hasClass('sliding') || $previousNavbarEl.find('.navbar-inner.sliding').length) {\n previousNavBackIconText = $previousNavbarEl.find('.left').find('.back .icon + span').eq(0);\n } else {\n previousNavBackIconText = $previousNavbarEl.find('.left.sliding').find('.back .icon + span').eq(0);\n }\n\n if (activeNavBackIconText.length) {\n $previousNavElements.each(function (el) {\n if (!$(el).hasClass('title')) return;\n el.f7NavbarLeftOffset += activeNavBackIconText.prev('.icon')[0].offsetWidth;\n });\n }\n }\n\n $currentNavElements.each(function (navEl) {\n var $navEl = $(navEl);\n var isSubnavbar = $navEl.hasClass('subnavbar');\n var isLeft = $navEl.hasClass('left');\n var isTitle = $navEl.hasClass('title');\n var isBg = $navEl.hasClass('navbar-bg');\n if ((isTitle || isBg) && currentNavIsTransparent) return;\n if (!fromLarge && $navEl.hasClass('.title-large')) return;\n var el = {\n el: navEl\n };\n\n if (fromLarge) {\n if (isTitle) return;\n\n if ($navEl.hasClass('title-large')) {\n if (els.indexOf(el) < 0) els.push(el);\n el.overflow = 'visible';\n $navEl.find('.title-large-text').each(function (subNavEl) {\n els.push({\n el: subNavEl,\n transform: function transform(progress) {\n return \"translateX(\" + progress * 100 * inverter + \"%)\";\n }\n });\n });\n return;\n }\n }\n\n if (toLarge) {\n if (!fromLarge) {\n if ($navEl.hasClass('title-large')) {\n if (els.indexOf(el) < 0) els.push(el);\n el.opacity = 0;\n }\n }\n\n if (isLeft) {\n if (els.indexOf(el) < 0) els.push(el);\n\n el.opacity = function (progress) {\n return 1 - Math.pow(progress, 0.33);\n };\n\n $navEl.find('.back span').each(function (subNavEl) {\n els.push({\n el: subNavEl,\n 'transform-origin': transformOrigin,\n transform: function transform(progress) {\n return \"translateX(calc(\" + progress + \" * (var(--f7-navbarTitleLargeOffset) - var(--f7-navbarLeftTextOffset)))) translateY(calc(\" + progress + \" * (var(--f7-navbar-large-title-height) - var(--f7-navbar-large-title-padding-vertical) / 2))) scale(\" + (1 + 1 * progress) + \")\";\n }\n });\n });\n return;\n }\n }\n\n if (isBg) {\n if (els.indexOf(el) < 0) els.push(el);\n\n if (!fromLarge && !toLarge) {\n if (currentNavIsCollapsed) {\n if (currentNavIsLargeTransparent) {\n el.className = 'ios-swipeback-navbar-bg-large';\n }\n\n el.transform = function (progress) {\n return \"translateX(\" + 100 * progress * inverter + \"%) translateY(calc(-1 * var(--f7-navbar-large-title-height)))\";\n };\n } else {\n el.transform = function (progress) {\n return \"translateX(\" + 100 * progress * inverter + \"%)\";\n };\n }\n }\n\n if (!fromLarge && toLarge) {\n el.className = 'ios-swipeback-navbar-bg-large';\n\n el.transform = function (progress) {\n return \"translateX(\" + 100 * progress * inverter + \"%) translateY(calc(-1 * \" + (1 - progress) + \" * var(--f7-navbar-large-title-height)))\";\n };\n }\n\n if (fromLarge && toLarge) {\n el.transform = function (progress) {\n return \"translateX(\" + 100 * progress * inverter + \"%)\";\n };\n }\n\n if (fromLarge && !toLarge) {\n el.transform = function (progress) {\n return \"translateX(\" + 100 * progress * inverter + \"%) translateY(calc(-\" + progress + \" * var(--f7-navbar-large-title-height)))\";\n };\n }\n\n return;\n }\n\n if ($navEl.hasClass('title-large')) return;\n var isSliding = $navEl.hasClass('sliding') || $navEl.parents('.navbar-inner.sliding').length;\n if (els.indexOf(el) < 0) els.push(el);\n\n if (!isSubnavbar || isSubnavbar && !isSliding) {\n el.opacity = function (progress) {\n return 1 - Math.pow(progress, 0.33);\n };\n }\n\n if (isSliding) {\n var transformTarget = el;\n\n if (isLeft && activeNavBackIconText.length && params.iosAnimateNavbarBackIcon) {\n var textEl = {\n el: activeNavBackIconText[0]\n };\n transformTarget = textEl;\n els.push(textEl);\n }\n\n transformTarget.transform = function (progress) {\n var activeNavTranslate = progress * transformTarget.el.f7NavbarRightOffset;\n if (device.pixelRatio === 1) activeNavTranslate = Math.round(activeNavTranslate);\n\n if (isSubnavbar && currentNavIsLarge) {\n return \"translate3d(\" + activeNavTranslate + \"px, calc(-1 * var(--f7-navbar-large-collapse-progress) * var(--f7-navbar-large-title-height)), 0)\";\n }\n\n return \"translate3d(\" + activeNavTranslate + \"px,0,0)\";\n };\n }\n });\n $previousNavElements.each(function (navEl) {\n var $navEl = $(navEl);\n var isSubnavbar = $navEl.hasClass('subnavbar');\n var isLeft = $navEl.hasClass('left');\n var isTitle = $navEl.hasClass('title');\n var isBg = $navEl.hasClass('navbar-bg');\n if ((isTitle || isBg) && previousNavIsTransparent) return;\n var el = {\n el: navEl\n };\n\n if (toLarge) {\n if (isTitle) return;\n if (els.indexOf(el) < 0) els.push(el);\n\n if ($navEl.hasClass('title-large')) {\n el.opacity = 1;\n el.overflow = 'visible';\n $navEl.find('.title-large-text').each(function (subNavEl) {\n els.push({\n el: subNavEl,\n 'transform-origin': transformOriginTitleLarge,\n opacity: function opacity(progress) {\n return Math.pow(progress, 3);\n },\n transform: function transform(progress) {\n return \"translateX(calc(\" + (1 - progress) + \" * (var(--f7-navbarLeftTextOffset) - var(--f7-navbarTitleLargeOffset)))) translateY(calc(\" + (progress - 1) + \" * var(--f7-navbar-large-title-height) + \" + (1 - progress) + \" * var(--f7-navbar-large-title-padding-vertical))) scale(\" + (0.5 + progress * 0.5) + \")\";\n }\n });\n });\n return;\n }\n }\n\n if (isBg) {\n if (els.indexOf(el) < 0) els.push(el);\n\n if (!fromLarge && !toLarge) {\n if (previousNavIsCollapsed) {\n if (previousNavIsLargeTransparent) {\n el.className = 'ios-swipeback-navbar-bg-large';\n }\n\n el.transform = function (progress) {\n return \"translateX(\" + (-100 + 100 * progress) * inverter + \"%) translateY(calc(-1 * var(--f7-navbar-large-title-height)))\";\n };\n } else {\n el.transform = function (progress) {\n return \"translateX(\" + (-100 + 100 * progress) * inverter + \"%)\";\n };\n }\n }\n\n if (!fromLarge && toLarge) {\n el.transform = function (progress) {\n return \"translateX(\" + (-100 + 100 * progress) * inverter + \"%) translateY(calc(-1 * \" + (1 - progress) + \" * var(--f7-navbar-large-title-height)))\";\n };\n }\n\n if (fromLarge && !toLarge) {\n el.className = 'ios-swipeback-navbar-bg-large';\n\n el.transform = function (progress) {\n return \"translateX(\" + (-100 + 100 * progress) * inverter + \"%) translateY(calc(-\" + progress + \" * var(--f7-navbar-large-title-height)))\";\n };\n }\n\n if (fromLarge && toLarge) {\n el.transform = function (progress) {\n return \"translateX(\" + (-100 + 100 * progress) * inverter + \"%)\";\n };\n }\n\n return;\n }\n\n if ($navEl.hasClass('title-large')) return;\n var isSliding = $navEl.hasClass('sliding') || $previousNavbarEl.children('.navbar-inner.sliding').length;\n if (els.indexOf(el) < 0) els.push(el);\n\n if (!isSubnavbar || isSubnavbar && !isSliding) {\n el.opacity = function (progress) {\n return Math.pow(progress, 3);\n };\n }\n\n if (isSliding) {\n var transformTarget = el;\n\n if (isLeft && previousNavBackIconText.length && params.iosAnimateNavbarBackIcon) {\n var textEl = {\n el: previousNavBackIconText[0]\n };\n transformTarget = textEl;\n els.push(textEl);\n }\n\n transformTarget.transform = function (progress) {\n var previousNavTranslate = transformTarget.el.f7NavbarLeftOffset * (1 - progress);\n if (device.pixelRatio === 1) previousNavTranslate = Math.round(previousNavTranslate);\n\n if (isSubnavbar && previousNavIsLarge) {\n return \"translate3d(\" + previousNavTranslate + \"px, calc(-1 * var(--f7-navbar-large-collapse-progress) * var(--f7-navbar-large-title-height)), 0)\";\n }\n\n return \"translate3d(\" + previousNavTranslate + \"px,0,0)\";\n };\n }\n });\n return els;\n }\n\n function setAnimatableNavElements(_temp) {\n var _ref = _temp === void 0 ? {} : _temp,\n progress = _ref.progress,\n reset = _ref.reset,\n transition = _ref.transition,\n reflow = _ref.reflow;\n\n var styles = ['overflow', 'transform', 'transform-origin', 'opacity'];\n\n if (transition === true || transition === false) {\n for (var i = 0; i < animatableNavEls.length; i += 1) {\n var el = animatableNavEls[i];\n\n if (el && el.el) {\n if (transition === true) el.el.classList.add('navbar-page-transitioning');\n if (transition === false) el.el.classList.remove('navbar-page-transitioning');\n }\n }\n }\n\n if (reflow && animatableNavEls.length && animatableNavEls[0] && animatableNavEls[0].el) {\n // eslint-disable-next-line\n animatableNavEls[0].el._clientLeft = animatableNavEls[0].el.clientLeft;\n }\n\n for (var _i = 0; _i < animatableNavEls.length; _i += 1) {\n var _el = animatableNavEls[_i];\n\n if (_el && _el.el) {\n if (_el.className && !_el.classNameSet && !reset) {\n _el.el.classList.add(_el.className);\n\n _el.classNameSet = true;\n }\n\n if (_el.className && reset) {\n _el.el.classList.remove(_el.className);\n }\n\n for (var j = 0; j < styles.length; j += 1) {\n var styleProp = styles[j];\n\n if (_el[styleProp]) {\n if (reset) {\n _el.el.style[styleProp] = '';\n } else if (typeof _el[styleProp] === 'function') {\n _el.el.style[styleProp] = _el[styleProp](progress);\n } else {\n _el.el.style[styleProp] = _el[styleProp];\n }\n }\n }\n }\n }\n }\n\n function handleTouchStart(e) {\n var swipeBackEnabled = params[app.theme + \"SwipeBack\"];\n if (!allowViewTouchMove || !swipeBackEnabled || isTouched || app.swipeout && app.swipeout.el || !router.allowPageChange) return;\n if ($(e.target).closest('.range-slider, .calendar-months').length > 0) return;\n if ($(e.target).closest('.page-master, .page-master-detail').length > 0 && params.masterDetailBreakpoint > 0 && app.width >= params.masterDetailBreakpoint) return;\n isMoved = false;\n isTouched = true;\n isScrolling = undefined;\n touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;\n touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;\n touchStartTime = now();\n dynamicNavbar = router.dynamicNavbar;\n }\n\n function handleTouchMove(e) {\n if (!isTouched) return;\n var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;\n var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;\n\n if (typeof isScrolling === 'undefined') {\n isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x)) || pageX < touchesStart.x && !app.rtl || pageX > touchesStart.x && app.rtl;\n }\n\n if (isScrolling || e.f7PreventSwipeBack || app.preventSwipeBack) {\n isTouched = false;\n return;\n }\n\n if (!isMoved) {\n // Calc values during first move fired\n var cancel = false;\n var target = $(e.target);\n var swipeout = target.closest('.swipeout');\n\n if (swipeout.length > 0) {\n if (!app.rtl && swipeout.find('.swipeout-actions-left').length > 0) cancel = true;\n if (app.rtl && swipeout.find('.swipeout-actions-right').length > 0) cancel = true;\n }\n\n $currentPageEl = target.closest('.page');\n if ($currentPageEl.hasClass('no-swipeback') || target.closest('.no-swipeback, .card-opened').length > 0) cancel = true;\n $previousPageEl = $el.find('.page-previous:not(.stacked)');\n\n if ($previousPageEl.length > 1) {\n $previousPageEl = $previousPageEl.eq($previousPageEl.length - 1);\n }\n\n var notFromBorder = touchesStart.x - $el.offset().left > paramsSwipeBackActiveArea;\n viewContainerWidth = $el.width();\n\n if (app.rtl) {\n notFromBorder = touchesStart.x < $el.offset().left - $el[0].scrollLeft + (viewContainerWidth - paramsSwipeBackActiveArea);\n } else {\n notFromBorder = touchesStart.x - $el.offset().left > paramsSwipeBackActiveArea;\n }\n\n if (notFromBorder) cancel = true;\n if ($previousPageEl.length === 0 || $currentPageEl.length === 0) cancel = true;\n\n if (cancel) {\n isTouched = false;\n return;\n }\n\n if (paramsSwipeBackAnimateShadow) {\n $pageShadowEl = $currentPageEl.find('.page-shadow-effect');\n\n if ($pageShadowEl.length === 0) {\n $pageShadowEl = $('');\n $currentPageEl.append($pageShadowEl);\n }\n }\n\n if (paramsSwipeBackAnimateOpacity) {\n $pageOpacityEl = $previousPageEl.find('.page-opacity-effect');\n\n if ($pageOpacityEl.length === 0) {\n $pageOpacityEl = $('');\n $previousPageEl.append($pageOpacityEl);\n }\n }\n\n if (dynamicNavbar) {\n $currentNavbarEl = $navbarsEl.find('.navbar-current:not(.stacked)');\n $previousNavbarEl = $navbarsEl.find('.navbar-previous:not(.stacked)');\n\n if ($previousNavbarEl.length > 1) {\n $previousNavbarEl = $previousNavbarEl.eq($previousNavbarEl.length - 1);\n }\n\n animatableNavEls = animatableNavElements($previousNavbarEl, $currentNavbarEl);\n } // Close/Hide Any Picker\n\n\n if ($('.sheet.modal-in').length > 0 && app.sheet) {\n app.sheet.close($('.sheet.modal-in'));\n }\n }\n\n e.f7PreventSwipePanel = true;\n isMoved = true;\n app.preventSwipePanelBySwipeBack = true;\n e.preventDefault(); // RTL inverter\n\n var inverter = app.rtl ? -1 : 1; // Touches diff\n\n touchesDiff = (pageX - touchesStart.x - paramsSwipeBackThreshold) * inverter;\n if (touchesDiff < 0) touchesDiff = 0;\n var percentage = Math.min(Math.max(touchesDiff / viewContainerWidth, 0), 1); // Swipe Back Callback\n\n var callbackData = {\n percentage: percentage,\n progress: percentage,\n currentPageEl: $currentPageEl[0],\n previousPageEl: $previousPageEl[0],\n currentNavbarEl: $currentNavbarEl[0],\n previousNavbarEl: $previousNavbarEl[0]\n };\n $el.trigger('swipeback:move', callbackData);\n router.emit('swipebackMove', callbackData); // Transform pages\n\n var currentPageTranslate = touchesDiff * inverter;\n var previousPageTranslate = (touchesDiff / 5 - viewContainerWidth / 5) * inverter;\n\n if (!app.rtl) {\n currentPageTranslate = Math.min(currentPageTranslate, viewContainerWidth);\n previousPageTranslate = Math.min(previousPageTranslate, 0);\n } else {\n currentPageTranslate = Math.max(currentPageTranslate, -viewContainerWidth);\n previousPageTranslate = Math.max(previousPageTranslate, 0);\n }\n\n if (device.pixelRatio === 1) {\n currentPageTranslate = Math.round(currentPageTranslate);\n previousPageTranslate = Math.round(previousPageTranslate);\n }\n\n router.swipeBackActive = true;\n $([$currentPageEl[0], $previousPageEl[0]]).addClass('page-swipeback-active');\n $currentPageEl.transform(\"translate3d(\" + currentPageTranslate + \"px,0,0)\");\n if (paramsSwipeBackAnimateShadow) $pageShadowEl[0].style.opacity = 1 - 1 * percentage;\n\n if (app.theme === 'ios') {\n $previousPageEl.transform(\"translate3d(\" + previousPageTranslate + \"px,0,0)\");\n }\n\n if (paramsSwipeBackAnimateOpacity) $pageOpacityEl[0].style.opacity = 1 - 1 * percentage; // Dynamic Navbars Animation\n\n if (!dynamicNavbar) return;\n setAnimatableNavElements({\n progress: percentage\n });\n }\n\n function handleTouchEnd() {\n app.preventSwipePanelBySwipeBack = false;\n\n if (!isTouched || !isMoved) {\n isTouched = false;\n isMoved = false;\n return;\n }\n\n isTouched = false;\n isMoved = false;\n router.swipeBackActive = false;\n var $pages = $([$currentPageEl[0], $previousPageEl[0]]);\n $pages.removeClass('page-swipeback-active');\n\n if (touchesDiff === 0) {\n $pages.transform('');\n if ($pageShadowEl && $pageShadowEl.length > 0) $pageShadowEl.remove();\n if ($pageOpacityEl && $pageOpacityEl.length > 0) $pageOpacityEl.remove();\n\n if (dynamicNavbar) {\n setAnimatableNavElements({\n reset: true\n });\n }\n\n return;\n }\n\n var timeDiff = now() - touchStartTime;\n var pageChanged = false; // Swipe back to previous page\n\n if (timeDiff < 300 && touchesDiff > 10 || timeDiff >= 300 && touchesDiff > viewContainerWidth / 2) {\n $currentPageEl.removeClass('page-current').addClass(\"page-next\" + (app.theme !== 'ios' ? ' page-next-on-right' : ''));\n $previousPageEl.removeClass('page-previous').addClass('page-current').removeAttr('aria-hidden');\n if ($pageShadowEl) $pageShadowEl[0].style.opacity = '';\n if ($pageOpacityEl) $pageOpacityEl[0].style.opacity = '';\n\n if (dynamicNavbar) {\n router.setNavbarPosition($currentNavbarEl, 'next');\n router.setNavbarPosition($previousNavbarEl, 'current', false);\n }\n\n pageChanged = true;\n } // Reset custom styles\n // Add transitioning class for transition-duration\n\n\n $pages.addClass('page-transitioning page-transitioning-swipeback');\n\n if (device.ios) {\n // eslint-disable-next-line\n $currentPageEl[0]._clientLeft = $currentPageEl[0].clientLeft;\n }\n\n $pages.transform('');\n\n if (dynamicNavbar) {\n setAnimatableNavElements({\n progress: pageChanged ? 1 : 0,\n transition: true,\n reflow: !!device.ios\n });\n }\n\n allowViewTouchMove = false;\n router.allowPageChange = false; // Swipe Back Callback\n\n var callbackData = {\n currentPageEl: $currentPageEl[0],\n previousPageEl: $previousPageEl[0],\n currentNavbarEl: $currentNavbarEl[0],\n previousNavbarEl: $previousNavbarEl[0]\n };\n\n if (pageChanged) {\n // Update Route\n router.currentRoute = $previousPageEl[0].f7Page.route;\n router.currentPage = $previousPageEl[0]; // Page before animation callback\n\n router.pageCallback('beforeOut', $currentPageEl, $currentNavbarEl, 'current', 'next', {\n route: $currentPageEl[0].f7Page.route,\n swipeBack: true\n });\n router.pageCallback('beforeIn', $previousPageEl, $previousNavbarEl, 'previous', 'current', {\n route: $previousPageEl[0].f7Page.route,\n swipeBack: true\n }, $currentPageEl[0]);\n $el.trigger('swipeback:beforechange', callbackData);\n router.emit('swipebackBeforeChange', callbackData);\n } else {\n $el.trigger('swipeback:beforereset', callbackData);\n router.emit('swipebackBeforeReset', callbackData);\n }\n\n $currentPageEl.transitionEnd(function () {\n $pages.removeClass('page-transitioning page-transitioning-swipeback');\n\n if (dynamicNavbar) {\n setAnimatableNavElements({\n reset: true,\n transition: false\n });\n }\n\n allowViewTouchMove = true;\n router.allowPageChange = true;\n\n if (pageChanged) {\n // Update History\n if (router.history.length === 1) {\n router.history.unshift(router.url);\n }\n\n router.history.pop();\n router.saveHistory(); // Update push state\n\n if (params.browserHistory) {\n History.back();\n } // Page after animation callback\n\n\n router.pageCallback('afterOut', $currentPageEl, $currentNavbarEl, 'current', 'next', {\n route: $currentPageEl[0].f7Page.route,\n swipeBack: true\n });\n router.pageCallback('afterIn', $previousPageEl, $previousNavbarEl, 'previous', 'current', {\n route: $previousPageEl[0].f7Page.route,\n swipeBack: true\n }); // Remove Old Page\n\n if (params.stackPages && router.initialPages.indexOf($currentPageEl[0]) >= 0) {\n $currentPageEl.addClass('stacked');\n\n if (dynamicNavbar) {\n $currentNavbarEl.addClass('stacked');\n }\n } else {\n router.pageCallback('beforeRemove', $currentPageEl, $currentNavbarEl, 'next', {\n swipeBack: true\n });\n router.removePage($currentPageEl);\n\n if (dynamicNavbar) {\n router.removeNavbar($currentNavbarEl);\n }\n }\n\n $el.trigger('swipeback:afterchange', callbackData);\n router.emit('swipebackAfterChange', callbackData);\n router.emit('routeChanged', router.currentRoute, router.previousRoute, router);\n\n if (params.preloadPreviousPage) {\n router.back(router.history[router.history.length - 2], {\n preload: true\n });\n }\n } else {\n $el.trigger('swipeback:afterreset', callbackData);\n router.emit('swipebackAfterReset', callbackData);\n }\n\n if ($pageShadowEl && $pageShadowEl.length > 0) $pageShadowEl.remove();\n if ($pageOpacityEl && $pageOpacityEl.length > 0) $pageOpacityEl.remove();\n });\n }\n\n function attachEvents() {\n var passiveListener = app.touchEvents.start === 'touchstart' && support.passiveListener ? {\n passive: true,\n capture: false\n } : false;\n $el.on(app.touchEvents.start, handleTouchStart, passiveListener);\n app.on('touchmove:active', handleTouchMove);\n app.on('touchend:passive', handleTouchEnd);\n }\n\n function detachEvents() {\n var passiveListener = app.touchEvents.start === 'touchstart' && support.passiveListener ? {\n passive: true,\n capture: false\n } : false;\n $el.off(app.touchEvents.start, handleTouchStart, passiveListener);\n app.off('touchmove:active', handleTouchMove);\n app.off('touchend:passive', handleTouchEnd);\n }\n\n attachEvents();\n router.on('routerDestroy', detachEvents);\n}\n\nexport default SwipeBack;","import { extend } from '../../shared/utils';\nexport default function redirect(direction, route, options) {\n var router = this;\n var r = route.route.redirect;\n var method = direction === 'forward' ? 'navigate' : 'back';\n\n if (options.initial && router.params.browserHistory) {\n options.replaceState = true; // eslint-disable-line\n\n options.history = true; // eslint-disable-line\n }\n\n function redirectResolve(redirectUrl, redirectOptions) {\n if (redirectOptions === void 0) {\n redirectOptions = {};\n }\n\n router.allowPageChange = true;\n router[method](redirectUrl, extend({}, options, redirectOptions));\n }\n\n function redirectReject() {\n router.allowPageChange = true;\n }\n\n if (typeof r === 'function') {\n router.allowPageChange = false;\n var redirectUrl = r.call(router, {\n router: router,\n to: route,\n resolve: redirectResolve,\n reject: redirectReject,\n direction: direction,\n app: router.app\n });\n\n if (redirectUrl && typeof redirectUrl === 'string') {\n router.allowPageChange = true;\n return router[method](redirectUrl, options);\n }\n\n return router;\n }\n\n return router[method](r, options);\n}","function processQueue(router, routerQueue, routeQueue, to, from, resolve, _reject, direction) {\n var queue = [];\n\n if (Array.isArray(routeQueue)) {\n queue.push.apply(queue, routeQueue);\n } else if (routeQueue && typeof routeQueue === 'function') {\n queue.push(routeQueue);\n }\n\n if (routerQueue) {\n if (Array.isArray(routerQueue)) {\n queue.push.apply(queue, routerQueue);\n } else {\n queue.push(routerQueue);\n }\n }\n\n function next() {\n if (queue.length === 0) {\n resolve();\n return;\n }\n\n var queueItem = queue.shift();\n queueItem.call(router, {\n router: router,\n to: to,\n from: from,\n resolve: function resolve() {\n next();\n },\n reject: function reject() {\n _reject();\n },\n direction: direction,\n app: router.app\n });\n }\n\n next();\n}\n\nexport default function processRouteQueue(to, from, resolve, reject, direction) {\n var router = this;\n\n function enterNextRoute() {\n if (to && to.route && (router.params.routesBeforeEnter || to.route.beforeEnter)) {\n router.allowPageChange = false;\n processQueue(router, router.params.routesBeforeEnter, to.route.beforeEnter, to, from, function () {\n router.allowPageChange = true;\n resolve();\n }, function () {\n reject();\n }, direction);\n } else {\n resolve();\n }\n }\n\n function leaveCurrentRoute() {\n if (from && from.route && (router.params.routesBeforeLeave || from.route.beforeLeave)) {\n router.allowPageChange = false;\n processQueue(router, router.params.routesBeforeLeave, from.route.beforeLeave, to, from, function () {\n router.allowPageChange = true;\n enterNextRoute();\n }, function () {\n reject();\n }, direction);\n } else {\n enterNextRoute();\n }\n }\n\n leaveCurrentRoute();\n}","export default function appRouterCheck(router, method) {\n if (!router.view) {\n throw new Error(\"Framework7: it is not allowed to use router methods on global app router. Use router methods only on related View, e.g. app.views.main.router.\" + method + \"(...)\");\n }\n}","export default function asyncComponent(router, component, resolve, reject) {\n function resolvePromise(componentPromise) {\n componentPromise.then(function (c) {\n // eslint-disable-next-line\n resolve({\n component: c.default || c._default || c\n });\n }).catch(function (err) {\n reject();\n throw new Error(err);\n });\n }\n\n if (component instanceof Promise) {\n resolvePromise(component);\n return;\n }\n\n var asyncComponentResult = component.call(router);\n\n if (asyncComponentResult instanceof Promise) {\n resolvePromise(asyncComponentResult);\n } else {\n resolve({\n component: asyncComponentResult\n });\n }\n}","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nimport { getDocument } from 'ssr-window';\nimport $ from '../../shared/dom7';\nimport { extend, parseUrlQuery } from '../../shared/utils';\nimport History from '../../shared/history';\nimport redirect from './redirect';\nimport processRouteQueue from './process-route-queue';\nimport appRouterCheck from './app-router-check';\nimport asyncComponent from './async-component';\n\nfunction refreshPage() {\n var router = this;\n appRouterCheck(router, 'refreshPage');\n return router.navigate(router.currentRoute.url, {\n ignoreCache: true,\n reloadCurrent: true\n });\n}\n\nfunction forward(router, el, forwardOptions) {\n if (forwardOptions === void 0) {\n forwardOptions = {};\n }\n\n var document = getDocument();\n var $el = $(el);\n var app = router.app;\n var view = router.view;\n var options = extend(false, {\n animate: router.params.animate,\n browserHistory: true,\n replaceState: false,\n history: true,\n reloadCurrent: router.params.reloadPages,\n reloadPrevious: false,\n reloadAll: false,\n clearPreviousHistory: false,\n reloadDetail: router.params.reloadDetail,\n on: {}\n }, forwardOptions);\n var masterDetailEnabled = router.params.masterDetailBreakpoint > 0;\n var isMaster = masterDetailEnabled && options.route && options.route.route && (options.route.route.master === true || typeof options.route.route.master === 'function' && options.route.route.master(app, router));\n var masterPageEl;\n var otherDetailPageEl;\n var detailsInBetweenRemoved = 0;\n var currentRouteIsModal = router.currentRoute.modal;\n var modalType;\n\n if (!currentRouteIsModal) {\n 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {\n if (router.currentRoute && router.currentRoute.route && router.currentRoute.route[modalLoadProp]) {\n currentRouteIsModal = true;\n modalType = modalLoadProp;\n }\n });\n }\n\n if (currentRouteIsModal) {\n var modalToClose = router.currentRoute.modal || router.currentRoute.route.modalInstance || app[modalType].get();\n var previousUrl = router.history[router.history.length - 2];\n var previousRoute = router.findMatchingRoute(previousUrl);\n\n if (!previousRoute && previousUrl) {\n previousRoute = {\n url: previousUrl,\n path: previousUrl.split('?')[0],\n query: parseUrlQuery(previousUrl),\n route: {\n path: previousUrl.split('?')[0],\n url: previousUrl\n }\n };\n }\n\n router.modalRemove(modalToClose);\n }\n\n var dynamicNavbar = router.dynamicNavbar;\n var $viewEl = router.$el;\n var $newPage = $el;\n var reload = options.reloadPrevious || options.reloadCurrent || options.reloadAll;\n var $oldPage;\n var $navbarsEl;\n var $newNavbarEl;\n var $oldNavbarEl;\n router.allowPageChange = false;\n\n if ($newPage.length === 0) {\n router.allowPageChange = true;\n return router;\n }\n\n if ($newPage.length) {\n // Remove theme elements\n router.removeThemeElements($newPage);\n }\n\n if (dynamicNavbar) {\n $newNavbarEl = $newPage.children('.navbar');\n $navbarsEl = router.$navbarsEl;\n\n if ($newNavbarEl.length === 0 && $newPage[0] && $newPage[0].f7Page) {\n // Try from pageData\n $newNavbarEl = $newPage[0].f7Page.$navbarEl;\n }\n } // Save Keep Alive Cache\n\n\n if (options.route && options.route.route && options.route.route.keepAlive && !options.route.route.keepAliveData) {\n options.route.route.keepAliveData = {\n pageEl: $el[0]\n };\n } // Pages In View\n\n\n var $pagesInView = $viewEl.children('.page:not(.stacked)').filter(function (pageInView) {\n return pageInView !== $newPage[0];\n }); // Navbars In View\n\n var $navbarsInView;\n\n if (dynamicNavbar) {\n $navbarsInView = $navbarsEl.children('.navbar:not(.stacked)').filter(function (navbarInView) {\n return navbarInView !== $newNavbarEl[0];\n });\n } // Exit when reload previous and only 1 page in view so nothing ro reload\n\n\n if (options.reloadPrevious && $pagesInView.length < 2) {\n router.allowPageChange = true;\n return router;\n } // Find Detail' master page\n\n\n var isDetail;\n var reloadDetail;\n var isDetailRoot;\n\n if (masterDetailEnabled && !options.reloadAll) {\n for (var i = 0; i < $pagesInView.length; i += 1) {\n if (!masterPageEl && $pagesInView[i].classList.contains('page-master')) {\n masterPageEl = $pagesInView[i];\n continue; // eslint-disable-line\n }\n }\n\n isDetail = !isMaster && masterPageEl;\n\n if (isDetail) {\n // Find Other Detail\n if (masterPageEl) {\n for (var _i = 0; _i < $pagesInView.length; _i += 1) {\n if ($pagesInView[_i].classList.contains('page-master-detail')) {\n otherDetailPageEl = $pagesInView[_i];\n continue; // eslint-disable-line\n }\n }\n }\n }\n\n reloadDetail = isDetail && options.reloadDetail && app.width >= router.params.masterDetailBreakpoint && masterPageEl;\n }\n\n if (isDetail) {\n isDetailRoot = !otherDetailPageEl || reloadDetail || options.reloadAll || options.reloadCurrent;\n } // New Page\n\n\n var newPagePosition = 'next';\n\n if (options.reloadCurrent || options.reloadAll || reloadDetail) {\n newPagePosition = 'current';\n } else if (options.reloadPrevious) {\n newPagePosition = 'previous';\n }\n\n $newPage.removeClass('page-previous page-current page-next').addClass(\"page-\" + newPagePosition + (isMaster ? ' page-master' : '') + (isDetail ? ' page-master-detail' : '') + (isDetailRoot ? ' page-master-detail-root' : '')).removeClass('stacked').trigger('page:unstack').trigger('page:position', {\n position: newPagePosition\n });\n router.emit('pageUnstack', $newPage[0]);\n router.emit('pagePosition', $newPage[0], newPagePosition);\n\n if (isMaster || isDetail) {\n $newPage.trigger('page:role', {\n role: isMaster ? 'master' : 'detail',\n root: !!isDetailRoot\n });\n router.emit('pageRole', $newPage[0], {\n role: isMaster ? 'master' : 'detail',\n detailRoot: !!isDetailRoot\n });\n }\n\n if (dynamicNavbar && $newNavbarEl.length) {\n $newNavbarEl.removeClass('navbar-previous navbar-current navbar-next').addClass(\"navbar-\" + newPagePosition + (isMaster ? ' navbar-master' : '') + (isDetail ? ' navbar-master-detail' : '') + (isDetailRoot ? ' navbar-master-detail-root' : '')).removeClass('stacked');\n $newNavbarEl.trigger('navbar:position', {\n position: newPagePosition\n });\n router.emit('navbarPosition', $newNavbarEl[0], newPagePosition);\n\n if (isMaster || isDetail) {\n router.emit('navbarRole', $newNavbarEl[0], {\n role: isMaster ? 'master' : 'detail',\n detailRoot: !!isDetailRoot\n });\n }\n } // Find Old Page\n\n\n if (options.reloadCurrent || reloadDetail) {\n if (reloadDetail) {\n $oldPage = $pagesInView.filter(function (pageEl) {\n return !pageEl.classList.contains('page-master');\n });\n\n if (dynamicNavbar) {\n $oldNavbarEl = $($oldPage.map(function (pageEl) {\n return app.navbar.getElByPage(pageEl);\n }));\n }\n\n if ($oldPage.length > 1 && masterPageEl) {\n detailsInBetweenRemoved = $oldPage.length - 1;\n $(masterPageEl).removeClass('page-master-stacked').trigger('page:masterunstack');\n router.emit('pageMasterUnstack', masterPageEl);\n\n if (dynamicNavbar) {\n $(app.navbar.getElByPage(masterPageEl)).removeClass('navbar-master-stacked');\n router.emit('navbarMasterUnstack', app.navbar.getElByPage(masterPageEl));\n }\n }\n } else {\n $oldPage = $pagesInView.eq($pagesInView.length - 1);\n\n if (dynamicNavbar) {\n $oldNavbarEl = $(app.navbar.getElByPage($oldPage));\n }\n }\n } else if (options.reloadPrevious) {\n $oldPage = $pagesInView.eq($pagesInView.length - 2);\n\n if (dynamicNavbar) {\n // $oldNavbarEl = $navbarsInView.eq($pagesInView.length - 2);\n $oldNavbarEl = $(app.navbar.getElByPage($oldPage));\n }\n } else if (options.reloadAll) {\n $oldPage = $pagesInView.filter(function (pageEl) {\n return pageEl !== $newPage[0];\n });\n\n if (dynamicNavbar) {\n $oldNavbarEl = $navbarsInView.filter(function (navbarEl) {\n return navbarEl !== $newNavbarEl[0];\n });\n }\n } else {\n var removedPageEls = [];\n var removedNavbarEls = [];\n\n if ($pagesInView.length > 1) {\n var _i2 = 0;\n\n for (_i2 = 0; _i2 < $pagesInView.length - 1; _i2 += 1) {\n if (masterPageEl && $pagesInView[_i2] === masterPageEl) {\n $pagesInView.eq(_i2).addClass('page-master-stacked');\n $pagesInView.eq(_i2).trigger('page:masterstack');\n router.emit('pageMasterStack', $pagesInView[_i2]);\n\n if (dynamicNavbar) {\n $(app.navbar.getElByPage(masterPageEl)).addClass('navbar-master-stacked');\n router.emit('navbarMasterStack', app.navbar.getElByPage(masterPageEl));\n }\n\n continue; // eslint-disable-line\n }\n\n var oldNavbarEl = app.navbar.getElByPage($pagesInView.eq(_i2));\n\n if (router.params.stackPages) {\n $pagesInView.eq(_i2).addClass('stacked');\n $pagesInView.eq(_i2).trigger('page:stack');\n router.emit('pageStack', $pagesInView[_i2]);\n\n if (dynamicNavbar) {\n $(oldNavbarEl).addClass('stacked');\n }\n } else {\n // Page remove event\n removedPageEls.push($pagesInView[_i2]);\n router.pageCallback('beforeRemove', $pagesInView[_i2], $navbarsInView && $navbarsInView[_i2], 'previous', undefined, options);\n router.removePage($pagesInView[_i2]);\n\n if (dynamicNavbar && oldNavbarEl) {\n removedNavbarEls.push(oldNavbarEl);\n router.removeNavbar(oldNavbarEl);\n }\n }\n }\n }\n\n $oldPage = $viewEl.children('.page:not(.stacked)').filter(function (pageEl) {\n return pageEl !== $newPage[0] && removedPageEls.indexOf(pageEl) < 0;\n });\n\n if (dynamicNavbar) {\n $oldNavbarEl = $navbarsEl.children('.navbar:not(.stacked)').filter(function (navbarEl) {\n return navbarEl !== $newNavbarEl[0] && removedNavbarEls.indexOf(removedNavbarEls) < 0;\n });\n }\n\n removedPageEls = [];\n removedNavbarEls = [];\n }\n\n if (isDetail && !options.reloadAll) {\n if ($oldPage.length > 1 || reloadDetail) {\n $oldPage = $oldPage.filter(function (pageEl) {\n return !pageEl.classList.contains('page-master');\n });\n }\n\n if ($oldNavbarEl && ($oldNavbarEl.length > 1 || reloadDetail)) {\n $oldNavbarEl = $oldNavbarEl.filter(function (navbarEl) {\n return !navbarEl.classList.contains('navbar-master');\n });\n }\n } // Push State\n\n\n if (router.params.browserHistory && (options.browserHistory || options.replaceState) && !options.reloadPrevious) {\n var browserHistoryRoot = router.params.browserHistoryRoot || '';\n History[options.reloadCurrent || reloadDetail && otherDetailPageEl || options.reloadAll || options.replaceState ? 'replace' : 'push'](view.id, {\n url: options.route.url\n }, browserHistoryRoot + router.params.browserHistorySeparator + options.route.url);\n }\n\n if (!options.reloadPrevious) {\n // Current Page & Navbar\n router.currentPageEl = $newPage[0];\n\n if (dynamicNavbar && $newNavbarEl.length) {\n router.currentNavbarEl = $newNavbarEl[0];\n } else {\n delete router.currentNavbarEl;\n } // Current Route\n\n\n router.currentRoute = options.route;\n } // Update router history\n\n\n var url = options.route.url;\n\n if (options.history) {\n if (((options.reloadCurrent || reloadDetail && otherDetailPageEl) && router.history.length) > 0 || options.replaceState) {\n if (reloadDetail && detailsInBetweenRemoved > 0) {\n router.history = router.history.slice(0, router.history.length - detailsInBetweenRemoved);\n }\n\n router.history[router.history.length - (options.reloadPrevious ? 2 : 1)] = url;\n } else if (options.reloadPrevious) {\n router.history[router.history.length - 2] = url;\n } else if (options.reloadAll) {\n router.history = [url];\n } else {\n router.history.push(url);\n }\n }\n\n router.saveHistory(); // Insert new page and navbar\n\n var newPageInDom = $newPage.parents(document).length > 0;\n var f7Component = $newPage[0].f7Component;\n\n if (options.reloadPrevious) {\n if (f7Component && !newPageInDom) {\n f7Component.mount(function (componentEl) {\n $(componentEl).insertBefore($oldPage);\n });\n } else {\n $newPage.insertBefore($oldPage);\n }\n\n if (dynamicNavbar && $newNavbarEl.length) {\n if ($newNavbarEl.find('.title-large').length) {\n $newNavbarEl.addClass('navbar-large');\n }\n\n if ($oldNavbarEl.length) {\n $newNavbarEl.insertBefore($oldNavbarEl);\n } else {\n if (!router.$navbarsEl.parents(document).length) {\n router.$el.prepend(router.$navbarsEl);\n }\n\n $navbarsEl.append($newNavbarEl);\n }\n }\n } else {\n if ($oldPage.next('.page')[0] !== $newPage[0]) {\n if (f7Component && !newPageInDom) {\n f7Component.mount(function (componentEl) {\n $viewEl.append(componentEl);\n });\n } else {\n $viewEl.append($newPage[0]);\n }\n }\n\n if (dynamicNavbar && $newNavbarEl.length) {\n if ($newNavbarEl.find('.title-large').length) {\n $newNavbarEl.addClass('navbar-large');\n }\n\n if (!router.$navbarsEl.parents(document).length) {\n router.$el.prepend(router.$navbarsEl);\n }\n\n $navbarsEl.append($newNavbarEl[0]);\n }\n }\n\n if (!newPageInDom) {\n router.pageCallback('mounted', $newPage, $newNavbarEl, newPagePosition, reload ? newPagePosition : 'current', options, $oldPage);\n } else if (options.route && options.route.route && options.route.route.keepAlive && !$newPage[0].f7PageMounted) {\n $newPage[0].f7PageMounted = true;\n router.pageCallback('mounted', $newPage, $newNavbarEl, newPagePosition, reload ? newPagePosition : 'current', options, $oldPage);\n } // Remove old page\n\n\n if ((options.reloadCurrent || reloadDetail) && $oldPage.length > 0) {\n if (router.params.stackPages && router.initialPages.indexOf($oldPage[0]) >= 0) {\n $oldPage.addClass('stacked');\n $oldPage.trigger('page:stack');\n router.emit('pageStack', $oldPage[0]);\n\n if (dynamicNavbar) {\n $oldNavbarEl.addClass('stacked');\n }\n } else {\n // Page remove event\n router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', undefined, options);\n router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', undefined, options);\n router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'current', undefined, options);\n router.removePage($oldPage);\n\n if (dynamicNavbar && $oldNavbarEl && $oldNavbarEl.length) {\n router.removeNavbar($oldNavbarEl);\n }\n }\n } else if (options.reloadAll) {\n $oldPage.each(function (pageEl, index) {\n var $oldPageEl = $(pageEl);\n var $oldNavbarElEl = $(app.navbar.getElByPage($oldPageEl));\n\n if (router.params.stackPages && router.initialPages.indexOf($oldPageEl[0]) >= 0) {\n $oldPageEl.addClass('stacked');\n $oldPageEl.trigger('page:stack');\n router.emit('pageStack', $oldPageEl[0]);\n\n if (dynamicNavbar) {\n $oldNavbarElEl.addClass('stacked');\n }\n } else {\n // Page remove event\n if ($oldPageEl.hasClass('page-current')) {\n router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', undefined, options);\n router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', undefined, options);\n }\n\n router.pageCallback('beforeRemove', $oldPageEl, $oldNavbarEl && $oldNavbarEl.eq(index), 'previous', undefined, options);\n router.removePage($oldPageEl);\n\n if (dynamicNavbar && $oldNavbarElEl.length) {\n router.removeNavbar($oldNavbarElEl);\n }\n }\n });\n } else if (options.reloadPrevious) {\n if (router.params.stackPages && router.initialPages.indexOf($oldPage[0]) >= 0) {\n $oldPage.addClass('stacked');\n $oldPage.trigger('page:stack');\n router.emit('pageStack', $oldPage[0]);\n\n if (dynamicNavbar) {\n $oldNavbarEl.addClass('stacked');\n }\n } else {\n // Page remove event\n router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'previous', undefined, options);\n router.removePage($oldPage);\n\n if (dynamicNavbar && $oldNavbarEl && $oldNavbarEl.length) {\n router.removeNavbar($oldNavbarEl);\n }\n }\n } // Load Tab\n\n\n if (options.route.route.tab) {\n router.tabLoad(options.route.route.tab, extend({}, options, {\n history: false,\n browserHistory: false\n }));\n } // Check master detail\n\n\n if (masterDetailEnabled) {\n view.checkMasterDetailBreakpoint();\n } // Page init and before init events\n\n\n router.pageCallback('init', $newPage, $newNavbarEl, newPagePosition, reload ? newPagePosition : 'current', options, $oldPage);\n\n if (options.reloadCurrent || options.reloadAll || reloadDetail) {\n router.allowPageChange = true;\n router.pageCallback('beforeIn', $newPage, $newNavbarEl, newPagePosition, 'current', options);\n $newPage.removeAttr('aria-hidden');\n\n if (dynamicNavbar && $newNavbarEl) {\n $newNavbarEl.removeAttr('aria-hidden');\n }\n\n router.pageCallback('afterIn', $newPage, $newNavbarEl, newPagePosition, 'current', options);\n if (options.reloadCurrent && options.clearPreviousHistory) router.clearPreviousHistory();\n\n if (reloadDetail) {\n router.setPagePosition($(masterPageEl), 'previous');\n\n if (masterPageEl.f7Page && masterPageEl.f7Page.navbarEl) {\n router.setNavbarPosition($(masterPageEl.f7Page.navbarEl), 'previous');\n }\n }\n\n return router;\n }\n\n if (options.reloadPrevious) {\n router.allowPageChange = true;\n return router;\n } // Before animation event\n\n\n router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', 'previous', options);\n router.pageCallback('beforeIn', $newPage, $newNavbarEl, 'next', 'current', options); // Animation\n\n function afterAnimation() {\n router.setPagePosition($newPage, 'current', false);\n router.setPagePosition($oldPage, 'previous', !$oldPage.hasClass('page-master'));\n\n if (dynamicNavbar) {\n router.setNavbarPosition($newNavbarEl, 'current', false);\n router.setNavbarPosition($oldNavbarEl, 'previous', !$oldNavbarEl.hasClass('navbar-master'));\n } // After animation event\n\n\n router.allowPageChange = true;\n router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', 'previous', options);\n router.pageCallback('afterIn', $newPage, $newNavbarEl, 'next', 'current', options);\n var keepOldPage = (router.params.preloadPreviousPage || router.params[app.theme + \"SwipeBack\"]) && !isMaster;\n\n if (!keepOldPage) {\n if ($newPage.hasClass('smart-select-page') || $newPage.hasClass('photo-browser-page') || $newPage.hasClass('autocomplete-page') || $newPage.hasClass('color-picker-page')) {\n keepOldPage = true;\n }\n }\n\n if (!keepOldPage) {\n if (router.params.stackPages) {\n $oldPage.addClass('stacked');\n $oldPage.trigger('page:stack');\n router.emit('pageStack', $oldPage[0]);\n\n if (dynamicNavbar) {\n $oldNavbarEl.addClass('stacked');\n }\n } else if (!($newPage.attr('data-name') && $newPage.attr('data-name') === 'smart-select-page')) {\n // Remove event\n router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'previous', undefined, options);\n router.removePage($oldPage);\n\n if (dynamicNavbar && $oldNavbarEl.length) {\n router.removeNavbar($oldNavbarEl);\n }\n }\n }\n\n if (options.clearPreviousHistory) router.clearPreviousHistory();\n router.emit('routeChanged', router.currentRoute, router.previousRoute, router);\n\n if (router.params.browserHistory) {\n History.clearRouterQueue();\n }\n }\n\n function setPositionClasses() {\n router.setPagePosition($oldPage, 'current', false);\n router.setPagePosition($newPage, 'next', false);\n\n if (dynamicNavbar) {\n router.setNavbarPosition($oldNavbarEl, 'current', false);\n router.setNavbarPosition($newNavbarEl, 'next', false);\n }\n }\n\n if (options.animate && !(isMaster && app.width >= router.params.masterDetailBreakpoint)) {\n var delay = router.params[router.app.theme + \"PageLoadDelay\"];\n var transition = router.params.transition;\n if (options.transition) transition = options.transition;\n\n if (!transition && router.currentRoute && router.currentRoute.route) {\n transition = router.currentRoute.route.transition;\n }\n\n if (!transition && router.currentRoute && router.currentRoute.route.options) {\n transition = router.currentRoute.route.options.transition;\n }\n\n if (transition) {\n $newPage[0].f7PageTransition = transition;\n }\n\n if (delay) {\n setTimeout(function () {\n setPositionClasses();\n router.animate($oldPage, $newPage, $oldNavbarEl, $newNavbarEl, 'forward', transition, function () {\n afterAnimation();\n });\n }, delay);\n } else {\n setPositionClasses();\n router.animate($oldPage, $newPage, $oldNavbarEl, $newNavbarEl, 'forward', transition, function () {\n afterAnimation();\n });\n }\n } else {\n afterAnimation();\n }\n\n return router;\n}\n\nfunction load(router, loadParams, loadOptions, ignorePageChange) {\n if (loadParams === void 0) {\n loadParams = {};\n }\n\n if (loadOptions === void 0) {\n loadOptions = {};\n }\n\n if (!router.allowPageChange && !ignorePageChange) return router;\n var params = loadParams;\n var options = loadOptions;\n var url = params.url,\n content = params.content,\n el = params.el,\n pageName = params.pageName,\n component = params.component,\n componentUrl = params.componentUrl;\n\n if (!options.reloadCurrent && options.route && options.route.route && options.route.route.parentPath && router.currentRoute.route && router.currentRoute.route.parentPath === options.route.route.parentPath) {\n // Do something nested\n if (options.route.url === router.url) {\n router.allowPageChange = true;\n return false;\n } // Check for same params\n\n\n var sameParams = Object.keys(options.route.params).length === Object.keys(router.currentRoute.params).length;\n\n if (sameParams) {\n // Check for equal params name\n Object.keys(options.route.params).forEach(function (paramName) {\n if (!(paramName in router.currentRoute.params) || router.currentRoute.params[paramName] !== options.route.params[paramName]) {\n sameParams = false;\n }\n });\n }\n\n if (sameParams) {\n if (options.route.route.tab) {\n return router.tabLoad(options.route.route.tab, options);\n }\n\n return false;\n }\n\n if (!sameParams && options.route.route.tab && router.currentRoute.route.tab && router.currentRoute.parentPath === options.route.parentPath) {\n return router.tabLoad(options.route.route.tab, options);\n }\n }\n\n if (options.route && options.route.url && router.url === options.route.url && !(options.reloadCurrent || options.reloadPrevious) && !router.params.allowDuplicateUrls) {\n router.allowPageChange = true;\n return false;\n }\n\n if (!options.route && url) {\n options.route = router.parseRouteUrl(url);\n extend(options.route, {\n route: {\n url: url,\n path: url\n }\n });\n } // Component Callbacks\n\n\n function resolve(pageEl, newOptions) {\n return forward(router, pageEl, extend(options, newOptions));\n }\n\n function reject() {\n router.allowPageChange = true;\n return router;\n }\n\n if (url || componentUrl || component) {\n router.allowPageChange = false;\n } // Proceed\n\n\n if (content) {\n forward(router, router.getPageEl(content), options);\n } else if (el) {\n // Load page from specified HTMLElement or by page name in pages container\n forward(router, router.getPageEl(el), options);\n } else if (pageName) {\n // Load page by page name in pages container\n forward(router, router.$el.children(\".page[data-name=\\\"\" + pageName + \"\\\"]\").eq(0), options);\n } else if (component || componentUrl) {\n // Load from component (F7/Vue/React/...)\n try {\n router.pageComponentLoader({\n routerEl: router.el,\n component: component,\n componentUrl: componentUrl,\n options: options,\n resolve: resolve,\n reject: reject\n });\n } catch (err) {\n router.allowPageChange = true;\n throw err;\n }\n } else if (url) {\n // Load using XHR\n if (router.xhrAbortController) {\n router.xhrAbortController.abort();\n router.xhrAbortController = false;\n }\n\n router.xhrRequest(url, options).then(function (pageContent) {\n forward(router, router.getPageEl(pageContent), options);\n }).catch(function () {\n router.allowPageChange = true;\n });\n }\n\n return router;\n}\n\nfunction openIn(router, url, options) {\n var navigateOptions = {\n url: url,\n route: {\n path: url,\n options: _extends({}, options, {\n openIn: undefined\n })\n }\n };\n\n var params = _extends({}, options);\n\n if (options.openIn === 'popup') {\n params.content = \"\";\n navigateOptions.route.popup = params;\n }\n\n if (options.openIn === 'loginScreen') {\n params.content = \"\";\n navigateOptions.route.loginScreen = params;\n }\n\n if (options.openIn === 'sheet') {\n params.content = \"\";\n navigateOptions.route.sheet = params;\n }\n\n if (options.openIn === 'popover') {\n params.targetEl = options.clickedEl || options.targetEl;\n params.content = \"\";\n navigateOptions.route.popover = params;\n }\n\n if (options.openIn.indexOf('panel') >= 0) {\n var parts = options.openIn.split(':');\n var side = parts[1] || 'left';\n var effect = parts[2] || 'cover';\n params.targetEl = options.clickedEl || options.targetEl;\n params.content = \"\";\n navigateOptions.route.panel = params;\n }\n\n return router.navigate(navigateOptions);\n}\n\nfunction navigate(navigateParams, navigateOptions) {\n if (navigateOptions === void 0) {\n navigateOptions = {};\n }\n\n var router = this;\n if (router.swipeBackActive) return router;\n var url;\n var createRoute;\n var name;\n var path;\n var query;\n var params;\n var route;\n\n if (typeof navigateParams === 'string') {\n url = navigateParams;\n } else {\n url = navigateParams.url;\n createRoute = navigateParams.route;\n name = navigateParams.name;\n path = navigateParams.path;\n query = navigateParams.query;\n params = navigateParams.params;\n }\n\n if (name || path) {\n url = router.generateUrl({\n path: path,\n name: name,\n params: params,\n query: query\n });\n\n if (url) {\n return router.navigate(url, navigateOptions);\n }\n\n return router;\n }\n\n var app = router.app;\n appRouterCheck(router, 'navigate');\n\n if (url === '#' || url === '') {\n return router;\n }\n\n var navigateUrl = url.replace('./', '');\n\n if (navigateUrl[0] !== '/' && navigateUrl.indexOf('#') !== 0) {\n var currentPath = router.currentRoute.parentPath || router.currentRoute.path;\n navigateUrl = ((currentPath ? currentPath + \"/\" : '/') + navigateUrl).replace('///', '/').replace('//', '/');\n }\n\n if (createRoute) {\n route = extend(router.parseRouteUrl(navigateUrl), {\n route: extend({}, createRoute)\n });\n } else {\n route = router.findMatchingRoute(navigateUrl);\n }\n\n if (!route) {\n return router;\n }\n\n if (route.route && route.route.viewName) {\n var anotherViewName = route.route.viewName;\n var anotherView = app.views[anotherViewName];\n\n if (!anotherView) {\n throw new Error(\"Framework7: There is no View with \\\"\" + anotherViewName + \"\\\" name that was specified in this route\");\n }\n\n if (anotherView !== router.view) {\n return anotherView.router.navigate(navigateParams, navigateOptions);\n }\n }\n\n if (route.route.redirect) {\n return redirect.call(router, 'forward', route, navigateOptions);\n }\n\n var options = {};\n\n if (route.route.options) {\n extend(options, route.route.options, navigateOptions);\n } else {\n extend(options, navigateOptions);\n }\n\n if (options.openIn && (!router.params.ignoreOpenIn || router.params.ignoreOpenIn && router.history.length > 0)) {\n return openIn(router, navigateUrl, options);\n }\n\n options.route = route;\n\n function resolve() {\n var routerLoaded = false;\n 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {\n if (route.route[modalLoadProp] && !routerLoaded) {\n routerLoaded = true;\n router.modalLoad(modalLoadProp, route, options, 'forward');\n }\n });\n\n if (route.route.keepAlive && route.route.keepAliveData) {\n load(router, {\n el: route.route.keepAliveData.pageEl\n }, options, false);\n routerLoaded = true;\n }\n\n 'url content component pageName el componentUrl'.split(' ').forEach(function (pageLoadProp) {\n if (route.route[pageLoadProp] && !routerLoaded) {\n var _load;\n\n routerLoaded = true;\n load(router, (_load = {}, _load[pageLoadProp] = route.route[pageLoadProp], _load), options, false);\n }\n });\n if (routerLoaded) return; // Async\n\n function asyncResolve(resolveParams, resolveOptions) {\n router.allowPageChange = false;\n var resolvedAsModal = false;\n 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {\n if (resolveParams[modalLoadProp]) {\n resolvedAsModal = true;\n var modalRoute = extend({}, route, {\n route: resolveParams\n });\n router.allowPageChange = true;\n router.modalLoad(modalLoadProp, modalRoute, extend(options, resolveOptions), 'forward');\n }\n });\n if (resolvedAsModal) return;\n load(router, resolveParams, extend(options, resolveOptions), true);\n }\n\n function asyncReject() {\n router.allowPageChange = true;\n }\n\n if (route.route.async) {\n router.allowPageChange = false;\n route.route.async.call(router, {\n router: router,\n to: options.route,\n from: router.currentRoute,\n resolve: asyncResolve,\n reject: asyncReject,\n direction: 'forward',\n app: app\n });\n }\n\n if (route.route.asyncComponent) {\n asyncComponent(router, route.route.asyncComponent, asyncResolve, asyncReject);\n }\n }\n\n function reject() {\n router.allowPageChange = true;\n }\n\n if (router.params.masterDetailBreakpoint > 0 && route.route.masterRoute) {\n // load detail route\n var preloadMaster = true;\n var masterLoaded = false;\n\n if (router.currentRoute && router.currentRoute.route) {\n if ((router.currentRoute.route.master === true || typeof router.currentRoute.route.master === 'function' && router.currentRoute.route.master(app, router)) && (router.currentRoute.route === route.route.masterRoute || router.currentRoute.route.path === route.route.masterRoute.path)) {\n preloadMaster = false;\n }\n\n if (router.currentRoute.route.masterRoute && (router.currentRoute.route.masterRoute === route.route.masterRoute || router.currentRoute.route.masterRoute.path === route.route.masterRoute.path)) {\n preloadMaster = false;\n masterLoaded = true;\n }\n }\n\n if (preloadMaster || masterLoaded && navigateOptions.reloadAll) {\n router.navigate({\n path: route.route.masterRoute.path,\n params: route.params || {}\n }, {\n animate: false,\n reloadAll: navigateOptions.reloadAll,\n reloadCurrent: navigateOptions.reloadCurrent,\n reloadPrevious: navigateOptions.reloadPrevious,\n browserHistory: !navigateOptions.initial,\n history: !navigateOptions.initial,\n once: {\n pageAfterIn: function pageAfterIn() {\n router.navigate(navigateParams, extend({}, navigateOptions, {\n animate: false,\n reloadAll: false,\n reloadCurrent: false,\n reloadPrevious: false,\n history: !navigateOptions.initial,\n browserHistory: !navigateOptions.initial\n }));\n }\n }\n });\n return router;\n }\n }\n\n processRouteQueue.call(router, route, router.currentRoute, function () {\n if (route.route.modules) {\n app.loadModules(Array.isArray(route.route.modules) ? route.route.modules : [route.route.modules]).then(function () {\n resolve();\n }).catch(function () {\n reject();\n });\n } else {\n resolve();\n }\n }, function () {\n reject();\n }, 'forward'); // Return Router\n\n return router;\n}\n\nexport { refreshPage, navigate };","import { getDocument } from 'ssr-window';\nimport $ from '../../shared/dom7';\nimport { extend, parseUrlQuery } from '../../shared/utils';\nimport { getDevice } from '../../shared/get-device';\nimport History from '../../shared/history';\nimport redirect from './redirect';\nimport processRouteQueue from './process-route-queue';\nimport appRouterCheck from './app-router-check';\nimport asyncComponent from './async-component';\n\nfunction backward(router, el, backwardOptions) {\n var device = getDevice();\n var document = getDocument();\n var $el = $(el);\n var app = router.app;\n var view = router.view;\n var options = extend({\n animate: router.params.animate,\n browserHistory: true,\n replaceState: false\n }, backwardOptions);\n var masterDetailEnabled = router.params.masterDetailBreakpoint > 0;\n var isMaster = masterDetailEnabled && options.route && options.route.route && (options.route.route.master === true || typeof options.route.route.master === 'function' && options.route.route.master(app, router));\n var masterPageEl;\n var masterPageRemoved;\n var dynamicNavbar = router.dynamicNavbar;\n var $newPage = $el;\n var $oldPage = router.$el.children('.page-current');\n var initialPreload = $oldPage.length === 0 && options.preload;\n var currentIsMaster = masterDetailEnabled && $oldPage.hasClass('page-master');\n\n if ($newPage.length) {\n // Remove theme elements\n router.removeThemeElements($newPage);\n }\n\n var $navbarsEl;\n var $newNavbarEl;\n var $oldNavbarEl;\n\n if (dynamicNavbar) {\n $newNavbarEl = $newPage.children('.navbar');\n $navbarsEl = router.$navbarsEl;\n\n if ($newNavbarEl.length === 0 && $newPage[0] && $newPage[0].f7Page) {\n // Try from pageData\n $newNavbarEl = $newPage[0].f7Page.$navbarEl;\n }\n\n $oldNavbarEl = $navbarsEl.find('.navbar-current');\n }\n\n router.allowPageChange = false;\n\n if ($newPage.length === 0 || $oldPage.length === 0 && !options.preload) {\n router.allowPageChange = true;\n return router;\n } // Remove theme elements\n\n\n router.removeThemeElements($newPage); // Save Keep Alive Cache\n\n if (options.route && options.route.route && options.route.route.keepAlive && !options.route.route.keepAliveData) {\n options.route.route.keepAliveData = {\n pageEl: $el[0]\n };\n } // Pages In View\n\n\n var isDetail;\n var isDetailRoot;\n\n if (masterDetailEnabled) {\n var $pagesInView = router.$el.children('.page:not(.stacked)').filter(function (pageInView) {\n return pageInView !== $newPage[0];\n }); // Find Detail' master page\n\n for (var i = 0; i < $pagesInView.length; i += 1) {\n if (!masterPageEl && $pagesInView[i].classList.contains('page-master')) {\n masterPageEl = $pagesInView[i];\n continue; // eslint-disable-line\n }\n }\n\n isDetail = !isMaster && masterPageEl && router.history.indexOf(options.route.url) > router.history.indexOf(masterPageEl.f7Page.route.url);\n\n if (!isDetail && !isMaster && masterPageEl && masterPageEl.f7Page && options.route.route.masterRoute) {\n isDetail = options.route.route.masterRoute.path === masterPageEl.f7Page.route.route.path;\n }\n }\n\n if (isDetail && masterPageEl && masterPageEl.f7Page) {\n isDetailRoot = router.history.indexOf(options.route.url) - router.history.indexOf(masterPageEl.f7Page.route.url) === 1;\n } // New Page\n\n\n $newPage.addClass(\"page-\" + (initialPreload ? 'current' : 'previous') + (isMaster ? ' page-master' : '') + (isDetail ? ' page-master-detail' : '') + (isDetailRoot ? ' page-master-detail-root' : '')).removeClass('stacked').removeAttr('aria-hidden').trigger('page:unstack').trigger('page:position', {\n position: initialPreload ? 'current' : 'previous'\n });\n router.emit('pageUnstack', $newPage[0]);\n router.emit('pagePosition', $newPage[0], initialPreload ? 'current' : 'previous');\n\n if (isMaster || isDetail) {\n $newPage.trigger('page:role', {\n role: isMaster ? 'master' : 'detail',\n root: !!isDetailRoot\n });\n router.emit('pageRole', $newPage[0], {\n role: isMaster ? 'master' : 'detail',\n detailRoot: !!isDetailRoot\n });\n }\n\n if (dynamicNavbar && $newNavbarEl.length > 0) {\n $newNavbarEl.addClass(\"navbar-\" + (initialPreload ? 'current' : 'previous') + (isMaster ? ' navbar-master' : '') + (isDetail ? ' navbar-master-detail' : '') + (isDetailRoot ? ' navbar-master-detail-root' : '')).removeClass('stacked').removeAttr('aria-hidden');\n $newNavbarEl.trigger('navbar:position', {\n position: initialPreload ? 'current' : 'previous'\n });\n router.emit('navbarPosition', $newNavbarEl[0], initialPreload ? 'current' : 'previous');\n\n if (isMaster || isDetailRoot) {\n router.emit('navbarRole', $newNavbarEl[0], {\n role: isMaster ? 'master' : 'detail',\n detailRoot: !!isDetailRoot\n });\n }\n } // Remove previous page in case of \"forced\"\n\n\n var backIndex;\n\n if (options.force) {\n if ($oldPage.prev('.page-previous:not(.stacked)').length > 0 || $oldPage.prev('.page-previous').length === 0) {\n if (router.history.indexOf(options.route.url) >= 0) {\n backIndex = router.history.length - router.history.indexOf(options.route.url) - 1;\n router.history = router.history.slice(0, router.history.indexOf(options.route.url) + 2);\n view.history = router.history;\n } else if (router.history[[router.history.length - 2]]) {\n router.history[router.history.length - 2] = options.route.url;\n } else {\n router.history.unshift(router.url);\n }\n\n if (backIndex && router.params.stackPages) {\n $oldPage.prevAll('.page-previous').each(function (pageToRemove) {\n var $pageToRemove = $(pageToRemove);\n var $navbarToRemove;\n\n if (dynamicNavbar) {\n // $navbarToRemove = $oldNavbarEl.prevAll('.navbar-previous').eq(index);\n $navbarToRemove = $(app.navbar.getElByPage($pageToRemove));\n }\n\n if ($pageToRemove[0] !== $newPage[0] && $pageToRemove.index() > $newPage.index()) {\n if (router.initialPages.indexOf($pageToRemove[0]) >= 0) {\n $pageToRemove.addClass('stacked');\n $pageToRemove.trigger('page:stack');\n router.emit('pageStack', $pageToRemove[0]);\n\n if (dynamicNavbar) {\n $navbarToRemove.addClass('stacked');\n }\n } else {\n router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined, options);\n\n if ($pageToRemove[0] === masterPageEl) {\n masterPageRemoved = true;\n }\n\n router.removePage($pageToRemove);\n\n if (dynamicNavbar && $navbarToRemove.length > 0) {\n router.removeNavbar($navbarToRemove);\n }\n }\n }\n });\n } else {\n var $pageToRemove = $oldPage.prev('.page-previous:not(.stacked)');\n var $navbarToRemove;\n\n if (dynamicNavbar) {\n // $navbarToRemove = $oldNavbarEl.prev('.navbar-inner:not(.stacked)');\n $navbarToRemove = $(app.navbar.getElByPage($pageToRemove));\n }\n\n if (router.params.stackPages && router.initialPages.indexOf($pageToRemove[0]) >= 0) {\n $pageToRemove.addClass('stacked');\n $pageToRemove.trigger('page:stack');\n router.emit('pageStack', $pageToRemove[0]);\n $navbarToRemove.addClass('stacked');\n } else if ($pageToRemove.length > 0) {\n router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined, options);\n\n if ($pageToRemove[0] === masterPageEl) {\n masterPageRemoved = true;\n }\n\n router.removePage($pageToRemove);\n\n if (dynamicNavbar && $navbarToRemove.length) {\n router.removeNavbar($navbarToRemove);\n }\n }\n }\n }\n } // Insert new page\n\n\n var newPageInDom = $newPage.parents(document).length > 0;\n var f7Component = $newPage[0].f7Component;\n\n function insertPage() {\n if (initialPreload) {\n if (!newPageInDom && f7Component) {\n f7Component.mount(function (componentEl) {\n router.$el.append(componentEl);\n });\n } else {\n router.$el.append($newPage);\n }\n }\n\n if ($newPage.next($oldPage).length === 0) {\n if (!newPageInDom && f7Component) {\n f7Component.mount(function (componentEl) {\n $(componentEl).insertBefore($oldPage);\n });\n } else {\n $newPage.insertBefore($oldPage);\n }\n }\n\n if (dynamicNavbar && $newNavbarEl.length) {\n if ($newNavbarEl.find('.title-large').length) {\n $newNavbarEl.addClass('navbar-large');\n }\n\n $newNavbarEl.insertBefore($oldNavbarEl);\n\n if ($oldNavbarEl.length > 0) {\n $newNavbarEl.insertBefore($oldNavbarEl);\n } else {\n if (!router.$navbarsEl.parents(document).length) {\n router.$el.prepend(router.$navbarsEl);\n }\n\n $navbarsEl.append($newNavbarEl);\n }\n }\n\n if (!newPageInDom) {\n router.pageCallback('mounted', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);\n } else if (options.route && options.route.route && options.route.route.keepAlive && !$newPage[0].f7PageMounted) {\n $newPage[0].f7PageMounted = true;\n router.pageCallback('mounted', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);\n }\n }\n\n if (options.preload) {\n // Insert Page\n insertPage(); // Tab route\n\n if (options.route.route.tab) {\n router.tabLoad(options.route.route.tab, extend({}, options, {\n history: false,\n browserHistory: false,\n preload: true\n }));\n }\n\n if (isMaster) {\n $newPage.removeClass('page-master-stacked').trigger('page:masterunstack');\n router.emit('pageMasterUnstack', $newPage[0]);\n\n if (dynamicNavbar) {\n $(app.navbar.getElByPage($newPage)).removeClass('navbar-master-stacked');\n router.emit('navbarMasterUnstack', app.navbar.getElByPage($newPage));\n }\n } // Page init and before init events\n\n\n router.pageCallback('init', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);\n\n if (initialPreload) {\n router.pageCallback('beforeIn', $newPage, $newNavbarEl, 'current', undefined, options);\n router.pageCallback('afterIn', $newPage, $newNavbarEl, 'current', undefined, options);\n }\n\n var $previousPages = $newPage.prevAll('.page-previous:not(.stacked):not(.page-master)');\n\n if ($previousPages.length > 0) {\n $previousPages.each(function (pageToRemove) {\n var $pageToRemove = $(pageToRemove);\n var $navbarToRemove;\n\n if (dynamicNavbar) {\n // $navbarToRemove = $newNavbarEl.prevAll('.navbar-previous:not(.stacked)').eq(index);\n $navbarToRemove = $(app.navbar.getElByPage($pageToRemove));\n }\n\n if (router.params.stackPages && router.initialPages.indexOf(pageToRemove) >= 0) {\n $pageToRemove.addClass('stacked');\n $pageToRemove.trigger('page:stack');\n router.emit('pageStack', $pageToRemove[0]);\n\n if (dynamicNavbar) {\n $navbarToRemove.addClass('stacked');\n }\n } else {\n router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined);\n router.removePage($pageToRemove);\n\n if (dynamicNavbar && $navbarToRemove.length) {\n router.removeNavbar($navbarToRemove);\n }\n }\n });\n }\n\n router.allowPageChange = true;\n return router;\n } // History State\n\n\n if (!(device.ie || device.edge || device.firefox && !device.ios)) {\n if (router.params.browserHistory && options.browserHistory) {\n if (options.replaceState) {\n var browserHistoryRoot = router.params.browserHistoryRoot || '';\n History.replace(view.id, {\n url: options.route.url\n }, browserHistoryRoot + router.params.browserHistorySeparator + options.route.url);\n } else if (backIndex) {\n History.go(-backIndex);\n } else {\n History.back();\n }\n }\n } // Update History\n\n\n if (options.replaceState) {\n router.history[router.history.length - 1] = options.route.url;\n } else {\n if (router.history.length === 1) {\n router.history.unshift(router.url);\n }\n\n router.history.pop();\n }\n\n router.saveHistory(); // Current Page & Navbar\n\n router.currentPageEl = $newPage[0];\n\n if (dynamicNavbar && $newNavbarEl.length) {\n router.currentNavbarEl = $newNavbarEl[0];\n } else {\n delete router.currentNavbarEl;\n } // Current Route\n\n\n router.currentRoute = options.route; // History State\n\n if (device.ie || device.edge || device.firefox && !device.ios) {\n if (router.params.browserHistory && options.browserHistory) {\n if (options.replaceState) {\n var _browserHistoryRoot = router.params.browserHistoryRoot || '';\n\n History.replace(view.id, {\n url: options.route.url\n }, _browserHistoryRoot + router.params.browserHistorySeparator + options.route.url);\n } else if (backIndex) {\n History.go(-backIndex);\n } else {\n History.back();\n }\n }\n } // Insert Page\n\n\n insertPage(); // Load Tab\n\n if (options.route.route.tab) {\n router.tabLoad(options.route.route.tab, extend({}, options, {\n history: false,\n browserHistory: false\n }));\n } // Check master detail\n\n\n if (masterDetailEnabled && (currentIsMaster || masterPageRemoved)) {\n view.checkMasterDetailBreakpoint(false);\n } // Page init and before init events\n\n\n router.pageCallback('init', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage); // Before animation callback\n\n router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', 'next', options);\n router.pageCallback('beforeIn', $newPage, $newNavbarEl, 'previous', 'current', options); // Animation\n\n function afterAnimation() {\n // Set classes\n router.setPagePosition($newPage, 'current', false);\n router.setPagePosition($oldPage, 'next', true);\n\n if (dynamicNavbar) {\n router.setNavbarPosition($newNavbarEl, 'current', false);\n router.setNavbarPosition($oldNavbarEl, 'next', true);\n } // After animation event\n\n\n router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', 'next', options);\n router.pageCallback('afterIn', $newPage, $newNavbarEl, 'previous', 'current', options); // Remove Old Page\n\n if (router.params.stackPages && router.initialPages.indexOf($oldPage[0]) >= 0) {\n $oldPage.addClass('stacked');\n $oldPage.trigger('page:stack');\n router.emit('pageStack', $oldPage[0]);\n\n if (dynamicNavbar) {\n $oldNavbarEl.addClass('stacked');\n }\n } else {\n router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'next', undefined, options);\n router.removePage($oldPage);\n\n if (dynamicNavbar && $oldNavbarEl.length) {\n router.removeNavbar($oldNavbarEl);\n }\n }\n\n router.allowPageChange = true;\n router.emit('routeChanged', router.currentRoute, router.previousRoute, router); // Preload previous page\n\n var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + \"SwipeBack\"];\n\n if (preloadPreviousPage && router.history[router.history.length - 2] && !isMaster) {\n router.back(router.history[router.history.length - 2], {\n preload: true\n });\n }\n\n if (router.params.browserHistory) {\n History.clearRouterQueue();\n }\n }\n\n function setPositionClasses() {\n router.setPagePosition($oldPage, 'current');\n router.setPagePosition($newPage, 'previous', false);\n\n if (dynamicNavbar) {\n router.setNavbarPosition($oldNavbarEl, 'current');\n router.setNavbarPosition($newNavbarEl, 'previous', false);\n }\n }\n\n if (options.animate && !(currentIsMaster && app.width >= router.params.masterDetailBreakpoint)) {\n var transition = router.params.transition;\n\n if ($oldPage[0] && $oldPage[0].f7PageTransition) {\n transition = $oldPage[0].f7PageTransition;\n delete $oldPage[0].f7PageTransition;\n }\n\n if (options.transition) transition = options.transition;\n\n if (!transition && router.previousRoute && router.previousRoute.route) {\n transition = router.previousRoute.route.transition;\n }\n\n if (!transition && router.previousRoute && router.previousRoute.route && router.previousRoute.route.options) {\n transition = router.previousRoute.route.options.transition;\n }\n\n setPositionClasses();\n router.animate($oldPage, $newPage, $oldNavbarEl, $newNavbarEl, 'backward', transition, function () {\n afterAnimation();\n });\n } else {\n afterAnimation();\n }\n\n return router;\n}\n\nfunction loadBack(router, backParams, backOptions, ignorePageChange) {\n if (!router.allowPageChange && !ignorePageChange) return router;\n var params = backParams;\n var options = backOptions;\n var url = params.url,\n content = params.content,\n el = params.el,\n pageName = params.pageName,\n component = params.component,\n componentUrl = params.componentUrl;\n\n if (options.route.url && router.url === options.route.url && !(options.reloadCurrent || options.reloadPrevious) && !router.params.allowDuplicateUrls) {\n return false;\n }\n\n if (!options.route && url) {\n options.route = router.parseRouteUrl(url);\n } // Component Callbacks\n\n\n function resolve(pageEl, newOptions) {\n return backward(router, pageEl, extend(options, newOptions));\n }\n\n function reject() {\n router.allowPageChange = true;\n return router;\n }\n\n if (url || componentUrl || component) {\n router.allowPageChange = false;\n } // Proceed\n\n\n if (content) {\n backward(router, router.getPageEl(content), options);\n } else if (el) {\n // Load page from specified HTMLElement or by page name in pages container\n backward(router, router.getPageEl(el), options);\n } else if (pageName) {\n // Load page by page name in pages container\n backward(router, router.$el.children(\".page[data-name=\\\"\" + pageName + \"\\\"]\").eq(0), options);\n } else if (component || componentUrl) {\n // Load from component (F7/Vue/React/...)\n try {\n router.pageComponentLoader({\n routerEl: router.el,\n component: component,\n componentUrl: componentUrl,\n options: options,\n resolve: resolve,\n reject: reject\n });\n } catch (err) {\n router.allowPageChange = true;\n throw err;\n }\n } else if (url) {\n // Load using XHR\n if (router.xhrAbortController) {\n router.xhrAbortController.abort();\n router.xhrAbortController = false;\n }\n\n router.xhrRequest(url, options).then(function (pageContent) {\n backward(router, router.getPageEl(pageContent), options);\n }).catch(function () {\n router.allowPageChange = true;\n });\n }\n\n return router;\n}\n\nfunction back() {\n var router = this;\n var device = getDevice();\n if (router.swipeBackActive) return router;\n var navigateUrl;\n var navigateOptions;\n var route;\n\n if (typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'object') {\n navigateOptions = (arguments.length <= 0 ? undefined : arguments[0]) || {};\n } else {\n navigateUrl = arguments.length <= 0 ? undefined : arguments[0];\n navigateOptions = (arguments.length <= 1 ? undefined : arguments[1]) || {};\n }\n\n var _navigateOptions = navigateOptions,\n name = _navigateOptions.name,\n params = _navigateOptions.params,\n query = _navigateOptions.query;\n\n if (name) {\n navigateUrl = router.generateUrl({\n name: name,\n params: params,\n query: query\n });\n\n if (navigateUrl) {\n return router.back(navigateUrl, extend({}, navigateOptions, {\n name: null,\n params: null,\n query: null\n }));\n }\n\n return router;\n }\n\n var app = router.app;\n appRouterCheck(router, 'back');\n var currentRouteIsModal = router.currentRoute.modal;\n var modalType;\n\n if (!currentRouteIsModal) {\n 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {\n if (router.currentRoute.route[modalLoadProp]) {\n currentRouteIsModal = true;\n modalType = modalLoadProp;\n }\n });\n }\n\n if (currentRouteIsModal && !navigateOptions.preload) {\n var modalToClose = router.currentRoute.modal || router.currentRoute.route.modalInstance || app[modalType].get();\n var previousUrl = router.history[router.history.length - 2];\n var previousRoute; // check if previous route is modal too\n\n if (modalToClose && modalToClose.$el) {\n var prevOpenedModals = modalToClose.$el.prevAll('.modal-in');\n\n if (prevOpenedModals.length && prevOpenedModals[0].f7Modal) {\n var modalEl = prevOpenedModals[0]; // check if current router not inside of the modalEl\n\n if (!router.$el.parents(modalEl).length) {\n previousRoute = modalEl.f7Modal.route;\n }\n }\n }\n\n if (!previousRoute) {\n previousRoute = router.findMatchingRoute(previousUrl);\n }\n\n if (!previousRoute && previousUrl) {\n previousRoute = {\n url: previousUrl,\n path: previousUrl.split('?')[0],\n query: parseUrlQuery(previousUrl),\n route: {\n path: previousUrl.split('?')[0],\n url: previousUrl\n }\n };\n }\n\n if (!navigateUrl || navigateUrl.replace(/[# ]/g, '').trim().length === 0) {\n if (!previousRoute || !modalToClose) {\n return router;\n }\n }\n\n var forceOtherUrl = navigateOptions.force && previousRoute && navigateUrl;\n\n if (previousRoute && modalToClose) {\n var isBrokenBrowserHistory = device.ie || device.edge || device.firefox && !device.ios;\n var needHistoryBack = router.params.browserHistory && navigateOptions.browserHistory !== false;\n var currentRouteWithoutBrowserHistory = router.currentRoute && router.currentRoute.route && router.currentRoute.route.options && router.currentRoute.route.options.browserHistory === false;\n\n if (needHistoryBack && !isBrokenBrowserHistory && !currentRouteWithoutBrowserHistory) {\n History.back();\n }\n\n router.currentRoute = previousRoute;\n router.history.pop();\n router.saveHistory();\n\n if (needHistoryBack && isBrokenBrowserHistory && !currentRouteWithoutBrowserHistory) {\n History.back();\n }\n\n router.modalRemove(modalToClose);\n\n if (forceOtherUrl) {\n router.navigate(navigateUrl, {\n reloadCurrent: true\n });\n }\n } else if (modalToClose) {\n router.modalRemove(modalToClose);\n\n if (navigateUrl) {\n router.navigate(navigateUrl, {\n reloadCurrent: true\n });\n }\n }\n\n return router;\n }\n\n var $previousPage = router.$el.children('.page-current').prevAll('.page-previous:not(.page-master)').eq(0);\n var skipMaster;\n\n if (router.params.masterDetailBreakpoint > 0) {\n var classes = [];\n router.$el.children('.page').each(function (pageEl) {\n classes.push(pageEl.className);\n });\n var $previousMaster = router.$el.children('.page-current').prevAll('.page-master').eq(0);\n\n if ($previousMaster.length) {\n var expectedPreviousPageUrl = router.history[router.history.length - 2];\n var expectedPreviousPageRoute = router.findMatchingRoute(expectedPreviousPageUrl);\n\n if (expectedPreviousPageRoute && $previousMaster[0].f7Page && expectedPreviousPageRoute.route === $previousMaster[0].f7Page.route.route) {\n $previousPage = $previousMaster;\n\n if (!navigateOptions.preload) {\n skipMaster = app.width >= router.params.masterDetailBreakpoint;\n }\n }\n }\n }\n\n if (!navigateOptions.force && $previousPage.length && !skipMaster) {\n if (router.params.browserHistory && $previousPage[0].f7Page && router.history[router.history.length - 2] !== $previousPage[0].f7Page.route.url) {\n router.back(router.history[router.history.length - 2], extend(navigateOptions, {\n force: true\n }));\n return router;\n }\n\n var previousPageRoute = $previousPage[0].f7Page.route;\n processRouteQueue.call(router, previousPageRoute, router.currentRoute, function () {\n loadBack(router, {\n el: $previousPage\n }, extend(navigateOptions, {\n route: previousPageRoute\n }));\n }, function () {}, 'backward');\n return router;\n } // Navigate URL\n\n\n if (navigateUrl === '#') {\n navigateUrl = undefined;\n }\n\n if (navigateUrl && navigateUrl[0] !== '/' && navigateUrl.indexOf('#') !== 0) {\n navigateUrl = ((router.path || '/') + navigateUrl).replace('//', '/');\n }\n\n if (!navigateUrl && router.history.length > 1) {\n navigateUrl = router.history[router.history.length - 2];\n }\n\n if (skipMaster && !navigateOptions.force && router.history[router.history.length - 3]) {\n return router.back(router.history[router.history.length - 3], extend({}, navigateOptions || {}, {\n force: true,\n animate: false\n }));\n }\n\n if (skipMaster && !navigateOptions.force) {\n return router;\n } // Find route to load\n\n\n route = router.findMatchingRoute(navigateUrl);\n\n if (!route) {\n if (navigateUrl) {\n route = {\n url: navigateUrl,\n path: navigateUrl.split('?')[0],\n query: parseUrlQuery(navigateUrl),\n route: {\n path: navigateUrl.split('?')[0],\n url: navigateUrl\n }\n };\n }\n }\n\n if (!route) {\n return router;\n }\n\n if (route.route.redirect) {\n return redirect.call(router, 'backward', route, navigateOptions);\n }\n\n var options = {};\n\n if (route.route.options) {\n extend(options, route.route.options, navigateOptions);\n } else {\n extend(options, navigateOptions);\n }\n\n options.route = route;\n var backForceLoaded;\n\n if (options.force && router.params.stackPages) {\n router.$el.children('.page-previous.stacked').each(function (pageEl) {\n if (pageEl.f7Page && pageEl.f7Page.route && pageEl.f7Page.route.url === route.url) {\n backForceLoaded = true;\n loadBack(router, {\n el: pageEl\n }, options);\n }\n });\n\n if (backForceLoaded) {\n return router;\n }\n }\n\n function resolve() {\n var routerLoaded = false;\n\n if (route.route.keepAlive && route.route.keepAliveData) {\n loadBack(router, {\n el: route.route.keepAliveData.pageEl\n }, options);\n routerLoaded = true;\n }\n\n 'url content component pageName el componentUrl'.split(' ').forEach(function (pageLoadProp) {\n if (route.route[pageLoadProp] && !routerLoaded) {\n var _loadBack;\n\n routerLoaded = true;\n loadBack(router, (_loadBack = {}, _loadBack[pageLoadProp] = route.route[pageLoadProp], _loadBack), options);\n }\n });\n if (routerLoaded) return; // Async\n\n function asyncResolve(resolveParams, resolveOptions) {\n router.allowPageChange = false;\n loadBack(router, resolveParams, extend(options, resolveOptions), true);\n }\n\n function asyncReject() {\n router.allowPageChange = true;\n }\n\n if (route.route.async) {\n router.allowPageChange = false;\n route.route.async.call(router, {\n router: router,\n to: route,\n from: router.currentRoute,\n resolve: asyncResolve,\n reject: asyncReject,\n direction: 'backward',\n app: app\n });\n }\n\n if (route.route.asyncComponent) {\n asyncComponent(router, route.route.asyncComponent, asyncResolve, asyncReject);\n }\n }\n\n function reject() {\n router.allowPageChange = true;\n }\n\n if (options.preload) {\n resolve();\n } else {\n processRouteQueue.call(router, route, router.currentRoute, function () {\n if (route.route.modules) {\n app.loadModules(Array.isArray(route.route.modules) ? route.route.modules : [route.route.modules]).then(function () {\n resolve();\n }).catch(function () {\n reject();\n });\n } else {\n resolve();\n }\n }, function () {\n reject();\n }, 'backward');\n } // Return Router\n\n\n return router;\n}\n\nexport { back };","function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nimport { getWindow, getDocument } from 'ssr-window';\nimport { pathToRegexp, compile } from 'path-to-regexp';\nimport $ from '../../shared/dom7';\nimport Framework7Class from '../../shared/class';\nimport { extend, nextFrame, parseUrlQuery, serializeObject, now, eventNameToColonCase } from '../../shared/utils';\nimport History from '../../shared/history';\nimport SwipeBack from './swipe-back';\nimport { refreshPage, navigate } from './navigate';\nimport { tabLoad, tabRemove } from './tab';\nimport { modalLoad, modalRemove } from './modal';\nimport { back } from './back';\nimport { clearPreviousHistory } from './clear-previous-history';\nimport appRouterCheck from './app-router-check';\n\nvar Router = /*#__PURE__*/function (_Framework7Class) {\n _inheritsLoose(Router, _Framework7Class);\n\n function Router(app, view) {\n var _this;\n\n _this = _Framework7Class.call(this, {}, [typeof view === 'undefined' ? app : view]) || this;\n\n var router = _assertThisInitialized(_this); // Is App Router\n\n\n router.isAppRouter = typeof view === 'undefined';\n\n if (router.isAppRouter) {\n // App Router\n extend(false, router, {\n app: app,\n params: app.params.view,\n routes: app.routes || [],\n cache: app.cache\n });\n } else {\n // View Router\n extend(false, router, {\n app: app,\n view: view,\n viewId: view.id,\n id: view.params.routerId,\n params: view.params,\n routes: view.routes,\n history: view.history,\n scrollHistory: view.scrollHistory,\n cache: app.cache,\n dynamicNavbar: app.theme === 'ios' && view.params.iosDynamicNavbar,\n initialPages: [],\n initialNavbars: []\n });\n } // Install Modules\n\n\n router.useModules(); // AllowPageChage\n\n router.allowPageChange = true; // Current Route\n\n var currentRoute = {};\n var previousRoute = {};\n Object.defineProperty(router, 'currentRoute', {\n enumerable: true,\n configurable: true,\n set: function set(newRoute) {\n if (newRoute === void 0) {\n newRoute = {};\n }\n\n previousRoute = extend({}, currentRoute);\n currentRoute = newRoute;\n if (!currentRoute) return;\n router.url = currentRoute.url;\n router.emit('routeChange', newRoute, previousRoute, router);\n },\n get: function get() {\n return currentRoute;\n }\n });\n Object.defineProperty(router, 'previousRoute', {\n enumerable: true,\n configurable: true,\n get: function get() {\n return previousRoute;\n },\n set: function set(newRoute) {\n previousRoute = newRoute;\n }\n });\n return router || _assertThisInitialized(_this);\n }\n\n var _proto = Router.prototype;\n\n _proto.mount = function mount() {\n var router = this;\n var view = router.view;\n var document = getDocument();\n extend(false, router, {\n tempDom: document.createElement('div'),\n $el: view.$el,\n el: view.el,\n $navbarsEl: view.$navbarsEl,\n navbarsEl: view.navbarsEl\n });\n router.emit('local::mount routerMount', router);\n };\n\n _proto.animatableNavElements = function animatableNavElements($newNavbarEl, $oldNavbarEl, toLarge, fromLarge, direction) {\n var router = this;\n var dynamicNavbar = router.dynamicNavbar;\n var animateIcon = router.params.iosAnimateNavbarBackIcon;\n var newNavEls;\n var oldNavEls;\n\n function animatableNavEl($el, $navbarInner) {\n var isSliding = $el.hasClass('sliding') || $navbarInner.hasClass('sliding');\n var isSubnavbar = $el.hasClass('subnavbar');\n var needsOpacityTransition = isSliding ? !isSubnavbar : true;\n var $iconEl = $el.find('.back .icon');\n var isIconLabel;\n\n if (isSliding && animateIcon && $el.hasClass('left') && $iconEl.length > 0 && $iconEl.next('span').length) {\n $el = $iconEl.next('span'); // eslint-disable-line\n\n isIconLabel = true;\n }\n\n return {\n $el: $el,\n isIconLabel: isIconLabel,\n leftOffset: $el[0].f7NavbarLeftOffset,\n rightOffset: $el[0].f7NavbarRightOffset,\n isSliding: isSliding,\n isSubnavbar: isSubnavbar,\n needsOpacityTransition: needsOpacityTransition\n };\n }\n\n if (dynamicNavbar) {\n newNavEls = [];\n oldNavEls = [];\n $newNavbarEl.children('.navbar-inner').children('.left, .right, .title, .subnavbar').each(function (navEl) {\n var $navEl = $(navEl);\n if ($navEl.hasClass('left') && fromLarge && direction === 'forward') return;\n if ($navEl.hasClass('title') && toLarge) return;\n newNavEls.push(animatableNavEl($navEl, $newNavbarEl.children('.navbar-inner')));\n });\n\n if (!($oldNavbarEl.hasClass('navbar-master') && router.params.masterDetailBreakpoint > 0 && router.app.width >= router.params.masterDetailBreakpoint)) {\n $oldNavbarEl.children('.navbar-inner').children('.left, .right, .title, .subnavbar').each(function (navEl) {\n var $navEl = $(navEl);\n if ($navEl.hasClass('left') && toLarge && !fromLarge && direction === 'forward') return;\n if ($navEl.hasClass('left') && toLarge && direction === 'backward') return;\n\n if ($navEl.hasClass('title') && fromLarge) {\n return;\n }\n\n oldNavEls.push(animatableNavEl($navEl, $oldNavbarEl.children('.navbar-inner')));\n });\n }\n\n [oldNavEls, newNavEls].forEach(function (navEls) {\n navEls.forEach(function (navEl) {\n var n = navEl;\n var isSliding = navEl.isSliding,\n $el = navEl.$el;\n var otherEls = navEls === oldNavEls ? newNavEls : oldNavEls;\n if (!(isSliding && $el.hasClass('title') && otherEls)) return;\n otherEls.forEach(function (otherNavEl) {\n if (otherNavEl.isIconLabel) {\n var iconTextEl = otherNavEl.$el[0];\n n.leftOffset += iconTextEl ? iconTextEl.offsetLeft || 0 : 0;\n }\n });\n });\n });\n }\n\n return {\n newNavEls: newNavEls,\n oldNavEls: oldNavEls\n };\n };\n\n _proto.animate = function animate($oldPageEl, $newPageEl, $oldNavbarEl, $newNavbarEl, direction, transition, callback) {\n var router = this;\n\n if (router.params.animateCustom) {\n router.params.animateCustom.apply(router, [$oldPageEl, $newPageEl, $oldNavbarEl, $newNavbarEl, direction, callback]);\n return;\n }\n\n var dynamicNavbar = router.dynamicNavbar;\n var ios = router.app.theme === 'ios';\n\n if (transition) {\n var routerCustomTransitionClass = \"router-transition-custom router-transition-\" + transition + \"-\" + direction; // Animate\n\n var onCustomTransitionDone = function onCustomTransitionDone() {\n router.$el.removeClass(routerCustomTransitionClass);\n\n if (dynamicNavbar && router.$navbarsEl.length) {\n if ($newNavbarEl) {\n router.$navbarsEl.prepend($newNavbarEl);\n }\n\n if ($oldNavbarEl) {\n router.$navbarsEl.prepend($oldNavbarEl);\n }\n }\n\n if (callback) callback();\n };\n\n (direction === 'forward' ? $newPageEl : $oldPageEl).animationEnd(onCustomTransitionDone);\n\n if (dynamicNavbar) {\n if ($newNavbarEl && $newPageEl) {\n router.setNavbarPosition($newNavbarEl, '');\n $newNavbarEl.removeClass('navbar-next navbar-previous navbar-current');\n $newPageEl.prepend($newNavbarEl);\n }\n\n if ($oldNavbarEl && $oldPageEl) {\n router.setNavbarPosition($oldNavbarEl, '');\n $oldNavbarEl.removeClass('navbar-next navbar-previous navbar-current');\n $oldPageEl.prepend($oldNavbarEl);\n }\n }\n\n router.$el.addClass(routerCustomTransitionClass);\n return;\n } // Router Animation class\n\n\n var routerTransitionClass = \"router-transition-\" + direction + \" router-transition\";\n var newNavEls;\n var oldNavEls;\n var fromLarge;\n var toLarge;\n var toDifferent;\n var oldIsLarge;\n var newIsLarge;\n\n if (ios && dynamicNavbar) {\n var betweenMasterAndDetail = router.params.masterDetailBreakpoint > 0 && router.app.width >= router.params.masterDetailBreakpoint && ($oldNavbarEl.hasClass('navbar-master') && $newNavbarEl.hasClass('navbar-master-detail') || $oldNavbarEl.hasClass('navbar-master-detail') && $newNavbarEl.hasClass('navbar-master'));\n\n if (!betweenMasterAndDetail) {\n oldIsLarge = $oldNavbarEl && $oldNavbarEl.hasClass('navbar-large');\n newIsLarge = $newNavbarEl && $newNavbarEl.hasClass('navbar-large');\n fromLarge = oldIsLarge && !$oldNavbarEl.hasClass('navbar-large-collapsed');\n toLarge = newIsLarge && !$newNavbarEl.hasClass('navbar-large-collapsed');\n toDifferent = fromLarge && !toLarge || toLarge && !fromLarge;\n }\n\n var navEls = router.animatableNavElements($newNavbarEl, $oldNavbarEl, toLarge, fromLarge, direction);\n newNavEls = navEls.newNavEls;\n oldNavEls = navEls.oldNavEls;\n }\n\n function animateNavbars(progress) {\n if (!(ios && dynamicNavbar)) return;\n\n if (progress === 1) {\n if (toLarge) {\n $newNavbarEl.addClass('router-navbar-transition-to-large');\n $oldNavbarEl.addClass('router-navbar-transition-to-large');\n }\n\n if (fromLarge) {\n $newNavbarEl.addClass('router-navbar-transition-from-large');\n $oldNavbarEl.addClass('router-navbar-transition-from-large');\n }\n }\n\n newNavEls.forEach(function (navEl) {\n var $el = navEl.$el;\n var offset = direction === 'forward' ? navEl.rightOffset : navEl.leftOffset;\n\n if (navEl.isSliding) {\n if (navEl.isSubnavbar && newIsLarge) {\n // prettier-ignore\n $el[0].style.setProperty('transform', \"translate3d(\" + offset * (1 - progress) + \"px, calc(-1 * var(--f7-navbar-large-collapse-progress) * var(--f7-navbar-large-title-height)), 0)\", 'important');\n } else {\n $el.transform(\"translate3d(\" + offset * (1 - progress) + \"px,0,0)\");\n }\n }\n });\n oldNavEls.forEach(function (navEl) {\n var $el = navEl.$el;\n var offset = direction === 'forward' ? navEl.leftOffset : navEl.rightOffset;\n\n if (navEl.isSliding) {\n if (navEl.isSubnavbar && oldIsLarge) {\n $el.transform(\"translate3d(\" + offset * progress + \"px, calc(-1 * var(--f7-navbar-large-collapse-progress) * var(--f7-navbar-large-title-height)), 0)\");\n } else {\n $el.transform(\"translate3d(\" + offset * progress + \"px,0,0)\");\n }\n }\n });\n } // AnimationEnd Callback\n\n\n function onDone() {\n if (router.dynamicNavbar) {\n if ($newNavbarEl) {\n $newNavbarEl.removeClass('router-navbar-transition-to-large router-navbar-transition-from-large');\n $newNavbarEl.addClass('navbar-no-title-large-transition');\n nextFrame(function () {\n $newNavbarEl.removeClass('navbar-no-title-large-transition');\n });\n }\n\n if ($oldNavbarEl) {\n $oldNavbarEl.removeClass('router-navbar-transition-to-large router-navbar-transition-from-large');\n }\n\n if ($newNavbarEl.hasClass('sliding') || $newNavbarEl.children('.navbar-inner.sliding').length) {\n $newNavbarEl.find('.title, .left, .right, .left .icon, .subnavbar').transform('');\n } else {\n $newNavbarEl.find('.sliding').transform('');\n }\n\n if ($oldNavbarEl.hasClass('sliding') || $oldNavbarEl.children('.navbar-inner.sliding').length) {\n $oldNavbarEl.find('.title, .left, .right, .left .icon, .subnavbar').transform('');\n } else {\n $oldNavbarEl.find('.sliding').transform('');\n }\n }\n\n router.$el.removeClass(routerTransitionClass);\n if (callback) callback();\n }\n\n (direction === 'forward' ? $newPageEl : $oldPageEl).animationEnd(function () {\n onDone();\n }); // Animate\n\n if (dynamicNavbar) {\n // Prepare Navbars\n animateNavbars(0);\n nextFrame(function () {\n // Add class, start animation\n router.$el.addClass(routerTransitionClass);\n\n if (toDifferent) {\n // eslint-disable-next-line\n router.el._clientLeft = router.el.clientLeft;\n }\n\n animateNavbars(1);\n });\n } else {\n // Add class, start animation\n router.$el.addClass(routerTransitionClass);\n }\n };\n\n _proto.removeModal = function removeModal(modalEl) {\n var router = this;\n router.removeEl(modalEl);\n } // eslint-disable-next-line\n ;\n\n _proto.removeTabContent = function removeTabContent(tabEl) {\n var $tabEl = $(tabEl);\n $tabEl.html('');\n };\n\n _proto.removeNavbar = function removeNavbar(el) {\n var router = this;\n router.removeEl(el);\n };\n\n _proto.removePage = function removePage(el) {\n var $el = $(el);\n var f7Page = $el && $el[0] && $el[0].f7Page;\n var router = this;\n\n if (f7Page && f7Page.route && f7Page.route.route && f7Page.route.route.keepAlive) {\n $el.remove();\n return;\n }\n\n router.removeEl(el);\n };\n\n _proto.removeEl = function removeEl(el) {\n if (!el) return;\n var router = this;\n var $el = $(el);\n if ($el.length === 0) return;\n $el.find('.tab').each(function (tabEl) {\n $(tabEl).children().each(function (tabChild) {\n if (tabChild.f7Component) {\n $(tabChild).trigger('tab:beforeremove');\n tabChild.f7Component.destroy();\n }\n });\n });\n\n if ($el[0].f7Component && $el[0].f7Component.destroy) {\n $el[0].f7Component.destroy();\n }\n\n if (!router.params.removeElements) {\n return;\n }\n\n if (router.params.removeElementsWithTimeout) {\n setTimeout(function () {\n $el.remove();\n }, router.params.removeElementsTimeout);\n } else {\n $el.remove();\n }\n };\n\n _proto.getPageEl = function getPageEl(content) {\n var router = this;\n\n if (typeof content === 'string') {\n router.tempDom.innerHTML = content;\n } else {\n if ($(content).hasClass('page')) {\n return content;\n }\n\n router.tempDom.innerHTML = '';\n $(router.tempDom).append(content);\n }\n\n return router.findElement('.page', router.tempDom);\n };\n\n _proto.findElement = function findElement(stringSelector, container, notStacked) {\n var router = this;\n var view = router.view;\n var app = router.app; // Modals Selector\n\n var modalsSelector = '.popup, .dialog, .popover, .actions-modal, .sheet-modal, .login-screen, .page';\n var $container = $(container);\n var selector = stringSelector;\n if (notStacked) selector += ':not(.stacked)';\n var found = $container.find(selector).filter(function (el) {\n return $(el).parents(modalsSelector).length === 0;\n });\n\n if (found.length > 1) {\n if (typeof view.selector === 'string') {\n // Search in related view\n found = $container.find(view.selector + \" \" + selector);\n }\n\n if (found.length > 1) {\n // Search in main view\n found = $container.find(\".\" + app.params.viewMainClass + \" \" + selector);\n }\n }\n\n if (found.length === 1) return found; // Try to find not stacked\n\n if (!notStacked) found = router.findElement(selector, $container, true);\n if (found && found.length === 1) return found;\n if (found && found.length > 1) return $(found[0]);\n return undefined;\n };\n\n _proto.flattenRoutes = function flattenRoutes(routes) {\n if (routes === void 0) {\n routes = this.routes;\n }\n\n var router = this;\n var flattenedRoutes = [];\n routes.forEach(function (route) {\n var hasTabRoutes = false;\n\n if ('tabs' in route && route.tabs) {\n var mergedPathsRoutes = route.tabs.map(function (tabRoute) {\n var tRoute = extend({}, route, {\n path: (route.path + \"/\" + tabRoute.path).replace('///', '/').replace('//', '/'),\n parentPath: route.path,\n tab: tabRoute\n });\n delete tRoute.tabs;\n delete tRoute.routes;\n return tRoute;\n });\n hasTabRoutes = true;\n flattenedRoutes = flattenedRoutes.concat(router.flattenRoutes(mergedPathsRoutes));\n }\n\n if ('detailRoutes' in route) {\n var _mergedPathsRoutes = route.detailRoutes.map(function (detailRoute) {\n var dRoute = extend({}, detailRoute);\n dRoute.masterRoute = route;\n dRoute.masterRoutePath = route.path;\n return dRoute;\n });\n\n flattenedRoutes = flattenedRoutes.concat(route, router.flattenRoutes(_mergedPathsRoutes));\n }\n\n if ('routes' in route) {\n var _mergedPathsRoutes2 = route.routes.map(function (childRoute) {\n var cRoute = extend({}, childRoute);\n cRoute.path = (route.path + \"/\" + cRoute.path).replace('///', '/').replace('//', '/');\n return cRoute;\n });\n\n if (hasTabRoutes) {\n flattenedRoutes = flattenedRoutes.concat(router.flattenRoutes(_mergedPathsRoutes2));\n } else {\n flattenedRoutes = flattenedRoutes.concat(route, router.flattenRoutes(_mergedPathsRoutes2));\n }\n }\n\n if (!('routes' in route) && !('tabs' in route && route.tabs) && !('detailRoutes' in route)) {\n flattenedRoutes.push(route);\n }\n });\n return flattenedRoutes;\n } // eslint-disable-next-line\n ;\n\n _proto.parseRouteUrl = function parseRouteUrl(url) {\n if (!url) return {};\n var query = parseUrlQuery(url);\n var hash = url.split('#')[1];\n var params = {};\n var path = url.split('#')[0].split('?')[0];\n return {\n query: query,\n hash: hash,\n params: params,\n url: url,\n path: path\n };\n };\n\n _proto.generateUrl = function generateUrl(parameters) {\n if (parameters === void 0) {\n parameters = {};\n }\n\n if (typeof parameters === 'string') {\n return parameters;\n }\n\n var _parameters = parameters,\n name = _parameters.name,\n path = _parameters.path,\n params = _parameters.params,\n query = _parameters.query;\n\n if (!name && !path) {\n throw new Error('Framework7: \"name\" or \"path\" parameter is required');\n }\n\n var router = this;\n var route = name ? router.findRouteByKey('name', name) : router.findRouteByKey('path', path);\n\n if (!route) {\n if (name) {\n throw new Error(\"Framework7: route with name \\\"\" + name + \"\\\" not found\");\n } else {\n throw new Error(\"Framework7: route with path \\\"\" + path + \"\\\" not found\");\n }\n }\n\n var url = router.constructRouteUrl(route, {\n params: params,\n query: query\n });\n\n if (!url) {\n throw new Error(\"Framework7: can't construct URL for route with name \\\"\" + name + \"\\\"\");\n }\n\n return url;\n } // eslint-disable-next-line\n ;\n\n _proto.constructRouteUrl = function constructRouteUrl(route, _temp) {\n var _ref = _temp === void 0 ? {} : _temp,\n params = _ref.params,\n query = _ref.query;\n\n var path = route.path;\n var toUrl = compile(path);\n var url;\n\n try {\n url = toUrl(params || {});\n } catch (error) {\n throw new Error(\"Framework7: error constructing route URL from passed params:\\nRoute: \" + path + \"\\n\" + error.toString());\n }\n\n if (query) {\n if (typeof query === 'string') url += \"?\" + query;else url += \"?\" + serializeObject(query);\n }\n\n return url;\n };\n\n _proto.findTabRoute = function findTabRoute(tabEl) {\n var router = this;\n var $tabEl = $(tabEl);\n var parentPath = router.currentRoute.route.parentPath;\n var tabId = $tabEl.attr('id');\n var flattenedRoutes = router.flattenRoutes(router.routes);\n var foundTabRoute;\n flattenedRoutes.forEach(function (route) {\n if (route.parentPath === parentPath && route.tab && route.tab.id === tabId) {\n foundTabRoute = route;\n }\n });\n return foundTabRoute;\n };\n\n _proto.findRouteByKey = function findRouteByKey(key, value) {\n var router = this;\n var routes = router.routes;\n var flattenedRoutes = router.flattenRoutes(routes);\n var matchingRoute;\n flattenedRoutes.forEach(function (route) {\n if (matchingRoute) return;\n\n if (route[key] === value) {\n matchingRoute = route;\n }\n });\n return matchingRoute;\n };\n\n _proto.findMatchingRoute = function findMatchingRoute(url) {\n if (!url) return undefined;\n var router = this;\n var routes = router.routes;\n var flattenedRoutes = router.flattenRoutes(routes);\n\n var _router$parseRouteUrl = router.parseRouteUrl(url),\n path = _router$parseRouteUrl.path,\n query = _router$parseRouteUrl.query,\n hash = _router$parseRouteUrl.hash,\n params = _router$parseRouteUrl.params;\n\n var matchingRoute;\n flattenedRoutes.forEach(function (route) {\n if (matchingRoute) return;\n var keys = [];\n var pathsToMatch = [route.path];\n\n if (route.alias) {\n if (typeof route.alias === 'string') pathsToMatch.push(route.alias);else if (Array.isArray(route.alias)) {\n route.alias.forEach(function (aliasPath) {\n pathsToMatch.push(aliasPath);\n });\n }\n }\n\n var matched;\n pathsToMatch.forEach(function (pathToMatch) {\n if (matched) return;\n matched = pathToRegexp(pathToMatch, keys).exec(path);\n });\n\n if (matched) {\n keys.forEach(function (keyObj, index) {\n if (typeof keyObj.name === 'number') return;\n var paramValue = matched[index + 1];\n\n if (typeof paramValue === 'undefined' || paramValue === null) {\n params[keyObj.name] = paramValue;\n } else {\n params[keyObj.name] = decodeURIComponent(paramValue);\n }\n });\n var parentPath;\n\n if (route.parentPath) {\n parentPath = path.split('/').slice(0, route.parentPath.split('/').length - 1).join('/');\n }\n\n matchingRoute = {\n query: query,\n hash: hash,\n params: params,\n url: url,\n path: path,\n parentPath: parentPath,\n route: route,\n name: route.name\n };\n }\n });\n return matchingRoute;\n } // eslint-disable-next-line\n ;\n\n _proto.replaceRequestUrlParams = function replaceRequestUrlParams(url, options) {\n if (url === void 0) {\n url = '';\n }\n\n if (options === void 0) {\n options = {};\n }\n\n var compiledUrl = url;\n\n if (typeof compiledUrl === 'string' && compiledUrl.indexOf('{{') >= 0 && options && options.route && options.route.params && Object.keys(options.route.params).length) {\n Object.keys(options.route.params).forEach(function (paramName) {\n var regExp = new RegExp(\"{{\" + paramName + \"}}\", 'g');\n compiledUrl = compiledUrl.replace(regExp, options.route.params[paramName] || '');\n });\n }\n\n return compiledUrl;\n };\n\n _proto.removeFromXhrCache = function removeFromXhrCache(url) {\n var router = this;\n var xhrCache = router.cache.xhr;\n var index = false;\n\n for (var i = 0; i < xhrCache.length; i += 1) {\n if (xhrCache[i].url === url) index = i;\n }\n\n if (index !== false) xhrCache.splice(index, 1);\n };\n\n _proto.xhrRequest = function xhrRequest(requestUrl, options) {\n var router = this;\n var params = router.params;\n var ignoreCache = options.ignoreCache;\n var url = requestUrl;\n var hasQuery = url.indexOf('?') >= 0;\n\n if (params.passRouteQueryToRequest && options && options.route && options.route.query && Object.keys(options.route.query).length) {\n url += \"\" + (hasQuery ? '&' : '?') + serializeObject(options.route.query);\n hasQuery = true;\n }\n\n if (params.passRouteParamsToRequest && options && options.route && options.route.params && Object.keys(options.route.params).length) {\n url += \"\" + (hasQuery ? '&' : '?') + serializeObject(options.route.params);\n hasQuery = true;\n }\n\n if (url.indexOf('{{') >= 0) {\n url = router.replaceRequestUrlParams(url, options);\n } // should we ignore get params or not\n\n\n if (params.xhrCacheIgnoreGetParameters && url.indexOf('?') >= 0) {\n url = url.split('?')[0];\n }\n\n return new Promise(function (resolve, reject) {\n if (params.xhrCache && !ignoreCache && url.indexOf('nocache') < 0 && params.xhrCacheIgnore.indexOf(url) < 0) {\n for (var i = 0; i < router.cache.xhr.length; i += 1) {\n var cachedUrl = router.cache.xhr[i];\n\n if (cachedUrl.url === url) {\n // Check expiration\n if (now() - cachedUrl.time < params.xhrCacheDuration) {\n // Load from cache\n resolve(cachedUrl.content);\n return;\n }\n }\n }\n }\n\n router.xhrAbortController = router.app.request.abortController();\n router.app.request({\n abortController: router.xhrAbortController,\n url: url,\n method: 'GET',\n beforeSend: function beforeSend(xhr) {\n router.emit('routerAjaxStart', xhr, options);\n },\n complete: function complete(xhr, status) {\n router.emit('routerAjaxComplete', xhr);\n\n if (status !== 'error' && status !== 'timeout' && xhr.status >= 200 && xhr.status < 300 || xhr.status === 0) {\n if (params.xhrCache && xhr.responseText !== '') {\n router.removeFromXhrCache(url);\n router.cache.xhr.push({\n url: url,\n time: now(),\n content: xhr.responseText\n });\n }\n\n router.emit('routerAjaxSuccess', xhr, options);\n resolve(xhr.responseText);\n } else {\n router.emit('routerAjaxError', xhr, options);\n reject(xhr);\n }\n },\n error: function error(xhr) {\n router.emit('routerAjaxError', xhr, options);\n reject(xhr);\n }\n });\n });\n };\n\n _proto.setNavbarPosition = function setNavbarPosition($el, position, ariaHidden) {\n var router = this;\n $el.removeClass('navbar-previous navbar-current navbar-next');\n\n if (position) {\n $el.addClass(\"navbar-\" + position);\n }\n\n if (ariaHidden === false) {\n $el.removeAttr('aria-hidden');\n } else if (ariaHidden === true) {\n $el.attr('aria-hidden', 'true');\n }\n\n $el.trigger('navbar:position', {\n position: position\n });\n router.emit('navbarPosition', $el[0], position);\n };\n\n _proto.setPagePosition = function setPagePosition($el, position, ariaHidden) {\n var router = this;\n $el.removeClass('page-previous page-current page-next');\n $el.addClass(\"page-\" + position);\n\n if (ariaHidden === false) {\n $el.removeAttr('aria-hidden');\n } else if (ariaHidden === true) {\n $el.attr('aria-hidden', 'true');\n }\n\n $el.trigger('page:position', {\n position: position\n });\n router.emit('pagePosition', $el[0], position);\n } // Remove theme elements\n ;\n\n _proto.removeThemeElements = function removeThemeElements(el) {\n var router = this;\n var theme = router.app.theme;\n var toRemove;\n\n if (theme === 'ios') {\n toRemove = '.md-only, .aurora-only, .if-md, .if-aurora, .if-not-ios, .not-ios';\n } else if (theme === 'md') {\n toRemove = '.ios-only, .aurora-only, .if-ios, .if-aurora, .if-not-md, .not-md';\n } else if (theme === 'aurora') {\n toRemove = '.ios-only, .md-only, .if-ios, .if-md, .if-not-aurora, .not-aurora';\n }\n\n $(el).find(toRemove).remove();\n };\n\n _proto.getPageData = function getPageData(pageEl, navbarEl, from, to, route, pageFromEl) {\n if (route === void 0) {\n route = {};\n }\n\n var router = this;\n var $pageEl = $(pageEl).eq(0);\n var $navbarEl = $(navbarEl).eq(0);\n var currentPage = $pageEl[0].f7Page || {};\n var direction;\n var pageFrom;\n if (from === 'next' && to === 'current' || from === 'current' && to === 'previous') direction = 'forward';\n if (from === 'current' && to === 'next' || from === 'previous' && to === 'current') direction = 'backward';\n\n if (currentPage && !currentPage.fromPage) {\n var $pageFromEl = $(pageFromEl);\n\n if ($pageFromEl.length) {\n pageFrom = $pageFromEl[0].f7Page;\n }\n }\n\n pageFrom = currentPage.pageFrom || pageFrom;\n\n if (pageFrom && pageFrom.pageFrom) {\n pageFrom.pageFrom = null;\n }\n\n var page = {\n app: router.app,\n view: router.view,\n router: router,\n $el: $pageEl,\n el: $pageEl[0],\n $pageEl: $pageEl,\n pageEl: $pageEl[0],\n $navbarEl: $navbarEl,\n navbarEl: $navbarEl[0],\n name: $pageEl.attr('data-name'),\n position: from,\n from: from,\n to: to,\n direction: direction,\n route: currentPage.route ? currentPage.route : route,\n pageFrom: pageFrom\n };\n $pageEl[0].f7Page = page;\n return page;\n } // Callbacks\n ;\n\n _proto.pageCallback = function pageCallback(callback, pageEl, navbarEl, from, to, options, pageFromEl) {\n if (options === void 0) {\n options = {};\n }\n\n if (!pageEl) return;\n var router = this;\n var $pageEl = $(pageEl);\n if (!$pageEl.length) return;\n var $navbarEl = $(navbarEl);\n var _options = options,\n route = _options.route;\n var restoreScrollTopOnBack = router.params.restoreScrollTopOnBack && !(router.params.masterDetailBreakpoint > 0 && $pageEl.hasClass('page-master') && router.app.width >= router.params.masterDetailBreakpoint);\n var keepAlive = $pageEl[0].f7Page && $pageEl[0].f7Page.route && $pageEl[0].f7Page.route.route && $pageEl[0].f7Page.route.route.keepAlive;\n\n if (callback === 'beforeRemove' && keepAlive) {\n callback = 'beforeUnmount'; // eslint-disable-line\n }\n\n var camelName = \"page\" + (callback[0].toUpperCase() + callback.slice(1, callback.length));\n var colonName = \"page:\" + callback.toLowerCase();\n var page = {};\n\n if (callback === 'beforeRemove' && $pageEl[0].f7Page) {\n page = extend($pageEl[0].f7Page, {\n from: from,\n to: to,\n position: from\n });\n } else {\n page = router.getPageData($pageEl[0], $navbarEl[0], from, to, route, pageFromEl);\n }\n\n page.swipeBack = !!options.swipeBack;\n\n var _ref2 = options.route ? options.route.route : {},\n _ref2$on = _ref2.on,\n on = _ref2$on === void 0 ? {} : _ref2$on,\n _ref2$once = _ref2.once,\n once = _ref2$once === void 0 ? {} : _ref2$once;\n\n if (options.on) {\n extend(on, options.on);\n }\n\n if (options.once) {\n extend(once, options.once);\n }\n\n function attachEvents() {\n if ($pageEl[0].f7RouteEventsAttached) return;\n $pageEl[0].f7RouteEventsAttached = true;\n\n if (on && Object.keys(on).length > 0) {\n $pageEl[0].f7RouteEventsOn = on;\n Object.keys(on).forEach(function (eventName) {\n on[eventName] = on[eventName].bind(router);\n $pageEl.on(eventNameToColonCase(eventName), on[eventName]);\n });\n }\n\n if (once && Object.keys(once).length > 0) {\n $pageEl[0].f7RouteEventsOnce = once;\n Object.keys(once).forEach(function (eventName) {\n once[eventName] = once[eventName].bind(router);\n $pageEl.once(eventNameToColonCase(eventName), once[eventName]);\n });\n }\n }\n\n function detachEvents() {\n if (!$pageEl[0].f7RouteEventsAttached) return;\n\n if ($pageEl[0].f7RouteEventsOn) {\n Object.keys($pageEl[0].f7RouteEventsOn).forEach(function (eventName) {\n $pageEl.off(eventNameToColonCase(eventName), $pageEl[0].f7RouteEventsOn[eventName]);\n });\n }\n\n if ($pageEl[0].f7RouteEventsOnce) {\n Object.keys($pageEl[0].f7RouteEventsOnce).forEach(function (eventName) {\n $pageEl.off(eventNameToColonCase(eventName), $pageEl[0].f7RouteEventsOnce[eventName]);\n });\n }\n\n $pageEl[0].f7RouteEventsAttached = null;\n $pageEl[0].f7RouteEventsOn = null;\n $pageEl[0].f7RouteEventsOnce = null;\n delete $pageEl[0].f7RouteEventsAttached;\n delete $pageEl[0].f7RouteEventsOn;\n delete $pageEl[0].f7RouteEventsOnce;\n }\n\n if (callback === 'mounted') {\n attachEvents();\n }\n\n if (callback === 'init') {\n if (restoreScrollTopOnBack && (from === 'previous' || !from) && to === 'current' && router.scrollHistory[page.route.url] && !$pageEl.hasClass('no-restore-scroll')) {\n var $pageContent = $pageEl.find('.page-content');\n\n if ($pageContent.length > 0) {\n // eslint-disable-next-line\n $pageContent = $pageContent.filter(function (pageContentEl) {\n return $(pageContentEl).parents('.tab:not(.tab-active)').length === 0 && !$(pageContentEl).is('.tab:not(.tab-active)');\n });\n }\n\n $pageContent.scrollTop(router.scrollHistory[page.route.url]);\n }\n\n attachEvents();\n\n if ($pageEl[0].f7PageInitialized) {\n $pageEl.trigger('page:reinit', page);\n router.emit('pageReinit', page);\n return;\n }\n\n $pageEl[0].f7PageInitialized = true;\n }\n\n if (restoreScrollTopOnBack && callback === 'beforeOut' && from === 'current' && to === 'previous') {\n // Save scroll position\n var _$pageContent = $pageEl.find('.page-content');\n\n if (_$pageContent.length > 0) {\n // eslint-disable-next-line\n _$pageContent = _$pageContent.filter(function (pageContentEl) {\n return $(pageContentEl).parents('.tab:not(.tab-active)').length === 0 && !$(pageContentEl).is('.tab:not(.tab-active)');\n });\n }\n\n router.scrollHistory[page.route.url] = _$pageContent.scrollTop();\n }\n\n if (restoreScrollTopOnBack && callback === 'beforeOut' && from === 'current' && to === 'next') {\n // Delete scroll position\n delete router.scrollHistory[page.route.url];\n }\n\n $pageEl.trigger(colonName, page);\n router.emit(camelName, page);\n\n if (callback === 'beforeRemove' || callback === 'beforeUnmount') {\n detachEvents();\n\n if (!keepAlive) {\n if ($pageEl[0].f7Page && $pageEl[0].f7Page.navbarEl) {\n delete $pageEl[0].f7Page.navbarEl.f7Page;\n }\n\n $pageEl[0].f7Page = null;\n }\n }\n };\n\n _proto.saveHistory = function saveHistory() {\n var router = this;\n var window = getWindow();\n router.view.history = router.history;\n\n if (router.params.browserHistory && router.params.browserHistoryStoreHistory && window.localStorage) {\n window.localStorage[\"f7router-\" + router.view.id + \"-history\"] = JSON.stringify(router.history);\n }\n };\n\n _proto.restoreHistory = function restoreHistory() {\n var router = this;\n var window = getWindow();\n\n if (router.params.browserHistory && router.params.browserHistoryStoreHistory && window.localStorage && window.localStorage[\"f7router-\" + router.view.id + \"-history\"]) {\n router.history = JSON.parse(window.localStorage[\"f7router-\" + router.view.id + \"-history\"]);\n router.view.history = router.history;\n }\n };\n\n _proto.clearHistory = function clearHistory() {\n var router = this;\n router.history = [];\n if (router.view) router.view.history = [];\n router.saveHistory();\n };\n\n _proto.updateCurrentUrl = function updateCurrentUrl(newUrl) {\n var router = this;\n appRouterCheck(router, 'updateCurrentUrl'); // Update history\n\n if (router.history.length) {\n router.history[router.history.length - 1] = newUrl;\n } else {\n router.history.push(newUrl);\n } // Update current route params\n\n\n var _router$parseRouteUrl2 = router.parseRouteUrl(newUrl),\n query = _router$parseRouteUrl2.query,\n hash = _router$parseRouteUrl2.hash,\n params = _router$parseRouteUrl2.params,\n url = _router$parseRouteUrl2.url,\n path = _router$parseRouteUrl2.path;\n\n if (router.currentRoute) {\n extend(router.currentRoute, {\n query: query,\n hash: hash,\n params: params,\n url: url,\n path: path\n });\n }\n\n if (router.params.browserHistory) {\n var browserHistoryRoot = router.params.browserHistoryRoot || '';\n History.replace(router.view.id, {\n url: newUrl\n }, browserHistoryRoot + router.params.browserHistorySeparator + newUrl);\n } // Save History\n\n\n router.saveHistory();\n router.emit('routeUrlUpdate', router.currentRoute, router);\n };\n\n _proto.getInitialUrl = function getInitialUrl() {\n var router = this;\n\n if (router.initialUrl) {\n return {\n initialUrl: router.initialUrl,\n historyRestored: router.historyRestored\n };\n }\n\n var app = router.app,\n view = router.view;\n var document = getDocument();\n var window = getWindow();\n var location = app.params.url && typeof app.params.url === 'string' && typeof URL !== 'undefined' ? new URL(app.params.url) : document.location;\n var initialUrl = router.params.url;\n var documentUrl = location.href.split(location.origin)[1];\n var historyRestored;\n var _router$params = router.params,\n browserHistory = _router$params.browserHistory,\n browserHistoryOnLoad = _router$params.browserHistoryOnLoad,\n browserHistorySeparator = _router$params.browserHistorySeparator;\n var browserHistoryRoot = router.params.browserHistoryRoot;\n\n if ((window.cordova || window.Capacitor && window.Capacitor.isNative) && browserHistory && !browserHistorySeparator && !browserHistoryRoot && location.pathname.indexOf('index.html')) {\n // eslint-disable-next-line\n console.warn('Framework7: wrong or not complete browserHistory configuration, trying to guess browserHistoryRoot');\n browserHistoryRoot = location.pathname.split('index.html')[0];\n }\n\n if (!browserHistory || !browserHistoryOnLoad) {\n if (!initialUrl) {\n initialUrl = documentUrl;\n }\n\n if (location.search && initialUrl.indexOf('?') < 0) {\n initialUrl += location.search;\n }\n\n if (location.hash && initialUrl.indexOf('#') < 0) {\n initialUrl += location.hash;\n }\n } else {\n if (browserHistoryRoot && documentUrl.indexOf(browserHistoryRoot) >= 0) {\n documentUrl = documentUrl.split(browserHistoryRoot)[1];\n if (documentUrl === '') documentUrl = '/';\n }\n\n if (browserHistorySeparator.length > 0 && documentUrl.indexOf(browserHistorySeparator) >= 0) {\n initialUrl = documentUrl.split(browserHistorySeparator)[1];\n } else {\n initialUrl = documentUrl;\n }\n\n router.restoreHistory();\n\n if (router.history.indexOf(initialUrl) >= 0) {\n router.history = router.history.slice(0, router.history.indexOf(initialUrl) + 1);\n } else if (router.params.url === initialUrl) {\n router.history = [initialUrl];\n } else if (History.state && History.state[view.id] && History.state[view.id].url === router.history[router.history.length - 1]) {\n initialUrl = router.history[router.history.length - 1];\n } else {\n router.history = [documentUrl.split(browserHistorySeparator)[0] || '/', initialUrl];\n }\n\n if (router.history.length > 1) {\n historyRestored = true;\n } else {\n router.history = [];\n }\n\n router.saveHistory();\n }\n\n router.initialUrl = initialUrl;\n router.historyRestored = historyRestored;\n return {\n initialUrl: initialUrl,\n historyRestored: historyRestored\n };\n };\n\n _proto.init = function init() {\n var router = this;\n var app = router.app,\n view = router.view;\n var document = getDocument();\n router.mount();\n\n var _router$getInitialUrl = router.getInitialUrl(),\n initialUrl = _router$getInitialUrl.initialUrl,\n historyRestored = _router$getInitialUrl.historyRestored; // Init Swipeback\n\n\n if (view && router.params.iosSwipeBack && app.theme === 'ios' || view && router.params.mdSwipeBack && app.theme === 'md' || view && router.params.auroraSwipeBack && app.theme === 'aurora') {\n SwipeBack(router);\n }\n\n var _router$params2 = router.params,\n browserHistory = _router$params2.browserHistory,\n browserHistoryOnLoad = _router$params2.browserHistoryOnLoad,\n browserHistoryAnimateOnLoad = _router$params2.browserHistoryAnimateOnLoad,\n browserHistoryInitialMatch = _router$params2.browserHistoryInitialMatch;\n var currentRoute;\n\n if (router.history.length > 1) {\n // Will load page\n var initUrl = browserHistoryInitialMatch ? initialUrl : router.history[0];\n currentRoute = router.findMatchingRoute(initUrl);\n\n if (!currentRoute) {\n currentRoute = extend(router.parseRouteUrl(initUrl), {\n route: {\n url: initUrl,\n path: initUrl.split('?')[0]\n }\n });\n }\n } else {\n // Don't load page\n currentRoute = router.findMatchingRoute(initialUrl);\n\n if (!currentRoute) {\n currentRoute = extend(router.parseRouteUrl(initialUrl), {\n route: {\n url: initialUrl,\n path: initialUrl.split('?')[0]\n }\n });\n }\n }\n\n if (router.params.stackPages) {\n router.$el.children('.page').each(function (pageEl) {\n var $pageEl = $(pageEl);\n router.initialPages.push($pageEl[0]);\n\n if (router.dynamicNavbar && $pageEl.children('.navbar').length > 0) {\n router.initialNavbars.push($pageEl.children('.navbar')[0]);\n }\n });\n }\n\n if (router.$el.children('.page:not(.stacked)').length === 0 && initialUrl && router.params.loadInitialPage) {\n // No pages presented in DOM, reload new page\n router.navigate(initialUrl, {\n initial: true,\n reloadCurrent: true,\n browserHistory: false,\n animate: false,\n once: {\n modalOpen: function modalOpen() {\n if (!historyRestored) return;\n var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + \"SwipeBack\"];\n\n if (preloadPreviousPage && router.history.length > 1) {\n router.back({\n preload: true\n });\n }\n },\n pageAfterIn: function pageAfterIn() {\n if (!historyRestored) return;\n var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + \"SwipeBack\"];\n\n if (preloadPreviousPage && router.history.length > 1) {\n router.back({\n preload: true\n });\n }\n }\n }\n });\n } else if (router.$el.children('.page:not(.stacked)').length) {\n // Init current DOM page\n var hasTabRoute;\n router.currentRoute = currentRoute;\n router.$el.children('.page:not(.stacked)').each(function (pageEl) {\n var $pageEl = $(pageEl);\n var $navbarEl;\n router.setPagePosition($pageEl, 'current');\n\n if (router.dynamicNavbar) {\n $navbarEl = $pageEl.children('.navbar');\n\n if ($navbarEl.length > 0) {\n if (!router.$navbarsEl.parents(document).length) {\n router.$el.prepend(router.$navbarsEl);\n }\n\n router.setNavbarPosition($navbarEl, 'current');\n router.$navbarsEl.append($navbarEl);\n\n if ($navbarEl.children('.title-large').length) {\n $navbarEl.addClass('navbar-large');\n }\n\n $pageEl.children('.navbar').remove();\n } else {\n router.$navbarsEl.addClass('navbar-hidden');\n\n if ($navbarEl.children('.title-large').length) {\n router.$navbarsEl.addClass('navbar-hidden navbar-large-hidden');\n }\n }\n }\n\n if (router.currentRoute && router.currentRoute.route && (router.currentRoute.route.master === true || typeof router.currentRoute.route.master === 'function' && router.currentRoute.route.master(app, router)) && router.params.masterDetailBreakpoint > 0) {\n $pageEl.addClass('page-master');\n $pageEl.trigger('page:role', {\n role: 'master'\n });\n\n if ($navbarEl && $navbarEl.length) {\n $navbarEl.addClass('navbar-master');\n }\n\n view.checkMasterDetailBreakpoint();\n }\n\n var initOptions = {\n route: router.currentRoute\n };\n\n if (router.currentRoute && router.currentRoute.route && router.currentRoute.route.options) {\n extend(initOptions, router.currentRoute.route.options);\n }\n\n router.currentPageEl = $pageEl[0];\n\n if (router.dynamicNavbar && $navbarEl.length) {\n router.currentNavbarEl = $navbarEl[0];\n }\n\n router.removeThemeElements($pageEl);\n\n if (router.dynamicNavbar && $navbarEl.length) {\n router.removeThemeElements($navbarEl);\n }\n\n if (initOptions.route.route.tab) {\n hasTabRoute = true;\n router.tabLoad(initOptions.route.route.tab, extend({}, initOptions));\n }\n\n router.pageCallback('init', $pageEl, $navbarEl, 'current', undefined, initOptions);\n router.pageCallback('beforeIn', $pageEl, $navbarEl, 'current', undefined, initOptions);\n router.pageCallback('afterIn', $pageEl, $navbarEl, 'current', undefined, initOptions);\n });\n\n if (historyRestored) {\n if (browserHistoryInitialMatch) {\n var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + \"SwipeBack\"];\n\n if (preloadPreviousPage && router.history.length > 1) {\n router.back({\n preload: true\n });\n }\n } else {\n router.navigate(initialUrl, {\n initial: true,\n browserHistory: false,\n history: false,\n animate: browserHistoryAnimateOnLoad,\n once: {\n pageAfterIn: function pageAfterIn() {\n var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + \"SwipeBack\"];\n\n if (preloadPreviousPage && router.history.length > 2) {\n router.back({\n preload: true\n });\n }\n }\n }\n });\n }\n }\n\n if (!historyRestored && !hasTabRoute) {\n router.history.push(initialUrl);\n router.saveHistory();\n }\n }\n\n if (initialUrl && browserHistory && browserHistoryOnLoad && (!History.state || !History.state[view.id])) {\n History.initViewState(view.id, {\n url: initialUrl\n });\n }\n\n router.emit('local::init routerInit', router);\n };\n\n _proto.destroy = function destroy() {\n var router = this;\n router.emit('local::destroy routerDestroy', router); // Delete props & methods\n\n Object.keys(router).forEach(function (routerProp) {\n router[routerProp] = null;\n delete router[routerProp];\n });\n router = null;\n };\n\n return Router;\n}(Framework7Class); // Load\n\n\nRouter.prototype.navigate = navigate;\nRouter.prototype.refreshPage = refreshPage; // Tab\n\nRouter.prototype.tabLoad = tabLoad;\nRouter.prototype.tabRemove = tabRemove; // Modal\n\nRouter.prototype.modalLoad = modalLoad;\nRouter.prototype.modalRemove = modalRemove; // Back\n\nRouter.prototype.back = back; // Clear history\n\nRouter.prototype.clearPreviousHistory = clearPreviousHistory;\nexport default Router;","import $ from '../../shared/dom7';\nimport { extend } from '../../shared/utils';\nimport History from '../../shared/history';\nimport asyncComponent from './async-component';\n\nfunction tabLoad(tabRoute, loadOptions) {\n if (loadOptions === void 0) {\n loadOptions = {};\n }\n\n var router = this;\n var options = extend({\n animate: router.params.animate,\n browserHistory: true,\n history: true,\n parentPageEl: null,\n preload: false,\n on: {}\n }, loadOptions);\n var currentRoute;\n var previousRoute;\n\n if (options.route) {\n // Set Route\n if (!options.preload && options.route !== router.currentRoute) {\n previousRoute = router.previousRoute;\n router.currentRoute = options.route;\n }\n\n if (options.preload) {\n currentRoute = options.route;\n previousRoute = router.currentRoute;\n } else {\n currentRoute = router.currentRoute;\n if (!previousRoute) previousRoute = router.previousRoute;\n } // Update Browser History\n\n\n if (router.params.browserHistory && options.browserHistory && !options.reloadPrevious) {\n History.replace(router.view.id, {\n url: options.route.url\n }, (router.params.browserHistoryRoot || '') + router.params.browserHistorySeparator + options.route.url);\n } // Update Router History\n\n\n if (options.history) {\n router.history[Math.max(router.history.length - 1, 0)] = options.route.url;\n router.saveHistory();\n }\n } // Show Tab\n\n\n var $parentPageEl = $(options.parentPageEl || router.currentPageEl);\n var tabEl;\n\n if ($parentPageEl.length && $parentPageEl.find(\"#\" + tabRoute.id).length) {\n tabEl = $parentPageEl.find(\"#\" + tabRoute.id).eq(0);\n } else if (router.view.selector) {\n tabEl = router.view.selector + \" #\" + tabRoute.id;\n } else {\n tabEl = \"#\" + tabRoute.id;\n }\n\n var tabShowResult = router.app.tab.show({\n tabEl: tabEl,\n animate: options.animate,\n tabRoute: options.route\n });\n var $newTabEl = tabShowResult.$newTabEl,\n $oldTabEl = tabShowResult.$oldTabEl,\n animated = tabShowResult.animated,\n onTabsChanged = tabShowResult.onTabsChanged;\n\n if ($newTabEl && $newTabEl.parents('.page').length > 0 && options.route) {\n var tabParentPageData = $newTabEl.parents('.page')[0].f7Page;\n\n if (tabParentPageData && options.route) {\n tabParentPageData.route = options.route;\n }\n } // Tab Content Loaded\n\n\n function onTabLoaded(contentEl) {\n // Remove theme elements\n router.removeThemeElements($newTabEl);\n var tabEventTarget = $newTabEl;\n if (typeof contentEl !== 'string') tabEventTarget = $(contentEl);\n tabEventTarget.trigger('tab:init tab:mounted', tabRoute);\n router.emit('tabInit tabMounted', $newTabEl[0], tabRoute);\n\n if ($oldTabEl && $oldTabEl.length) {\n if (animated) {\n onTabsChanged(function () {\n router.emit('routeChanged', router.currentRoute, router.previousRoute, router);\n\n if (router.params.unloadTabContent) {\n router.tabRemove($oldTabEl, $newTabEl, tabRoute);\n }\n });\n } else {\n router.emit('routeChanged', router.currentRoute, router.previousRoute, router);\n\n if (router.params.unloadTabContent) {\n router.tabRemove($oldTabEl, $newTabEl, tabRoute);\n }\n }\n }\n }\n\n if ($newTabEl[0].f7RouterTabLoaded) {\n if (!$oldTabEl || !$oldTabEl.length) return router;\n\n if (animated) {\n onTabsChanged(function () {\n router.emit('routeChanged', router.currentRoute, router.previousRoute, router);\n });\n } else {\n router.emit('routeChanged', router.currentRoute, router.previousRoute, router);\n }\n\n return router;\n } // Load Tab Content\n\n\n function loadTab(loadTabParams, loadTabOptions) {\n // Load Tab Props\n var url = loadTabParams.url,\n content = loadTabParams.content,\n el = loadTabParams.el,\n component = loadTabParams.component,\n componentUrl = loadTabParams.componentUrl; // Component/Template Callbacks\n\n function resolve(contentEl) {\n router.allowPageChange = true;\n if (!contentEl) return;\n\n if (typeof contentEl === 'string') {\n $newTabEl.html(contentEl);\n } else {\n $newTabEl.html('');\n\n if (contentEl.f7Component) {\n contentEl.f7Component.mount(function (componentEl) {\n $newTabEl.append(componentEl);\n });\n } else {\n $newTabEl.append(contentEl);\n }\n }\n\n $newTabEl[0].f7RouterTabLoaded = true;\n onTabLoaded(contentEl);\n }\n\n function reject() {\n router.allowPageChange = true;\n return router;\n }\n\n if (content) {\n resolve(content);\n } else if (el) {\n resolve(el);\n } else if (component || componentUrl) {\n // Load from component (F7/Vue/React/...)\n try {\n router.tabComponentLoader({\n tabEl: $newTabEl[0],\n component: component,\n componentUrl: componentUrl,\n options: loadTabOptions,\n resolve: resolve,\n reject: reject\n });\n } catch (err) {\n router.allowPageChange = true;\n throw err;\n }\n } else if (url) {\n // Load using XHR\n if (router.xhrAbortController) {\n router.xhrAbortController.abort();\n router.xhrAbortController = false;\n }\n\n router.xhrRequest(url, loadTabOptions).then(function (tabContent) {\n resolve(tabContent);\n }).catch(function () {\n router.allowPageChange = true;\n });\n }\n }\n\n var hasContentLoadProp;\n 'url content component el componentUrl'.split(' ').forEach(function (tabLoadProp) {\n if (tabRoute[tabLoadProp]) {\n var _loadTab;\n\n hasContentLoadProp = true;\n loadTab((_loadTab = {}, _loadTab[tabLoadProp] = tabRoute[tabLoadProp], _loadTab), options);\n }\n }); // Async\n\n function asyncResolve(resolveParams, resolveOptions) {\n loadTab(resolveParams, extend(options, resolveOptions));\n }\n\n function asyncReject() {\n router.allowPageChange = true;\n }\n\n if (tabRoute.async) {\n tabRoute.async.call(router, {\n router: router,\n to: currentRoute,\n from: previousRoute,\n resolve: asyncResolve,\n reject: asyncReject,\n app: router.app\n });\n } else if (tabRoute.asyncComponent) {\n asyncComponent(router, tabRoute.asyncComponent, asyncResolve, asyncReject);\n } else if (!hasContentLoadProp) {\n router.allowPageChange = true;\n }\n\n return router;\n}\n\nfunction tabRemove($oldTabEl, $newTabEl, tabRoute) {\n var router = this;\n var hasTabComponentChild;\n\n if ($oldTabEl[0]) {\n $oldTabEl[0].f7RouterTabLoaded = false;\n delete $oldTabEl[0].f7RouterTabLoaded;\n }\n\n $oldTabEl.children().each(function (tabChild) {\n if (tabChild.f7Component) {\n hasTabComponentChild = true;\n $(tabChild).trigger('tab:beforeremove', tabRoute);\n tabChild.f7Component.destroy();\n }\n });\n\n if (!hasTabComponentChild) {\n $oldTabEl.trigger('tab:beforeremove', tabRoute);\n }\n\n router.emit('tabBeforeRemove', $oldTabEl[0], $newTabEl[0], tabRoute);\n router.removeTabContent($oldTabEl[0], tabRoute);\n}\n\nexport { tabLoad, tabRemove };","import { extend, nextTick } from '../../shared/utils';\nimport History from '../../shared/history';\nimport asyncComponent from './async-component';\n\nfunction modalLoad(modalType, route, loadOptions, direction) {\n if (loadOptions === void 0) {\n loadOptions = {};\n }\n\n var router = this;\n var app = router.app;\n var isPanel = modalType === 'panel';\n var modalOrPanel = isPanel ? 'panel' : 'modal';\n var options = extend({\n animate: router.params.animate,\n browserHistory: true,\n history: true,\n on: {},\n once: {}\n }, loadOptions);\n var modalParams = extend({}, route.route[modalType]);\n var modalRoute = route.route;\n\n var routeCallback = function routeCallback(modal, name) {\n var on = options.on,\n once = options.once;\n var callback;\n\n if (name === 'open') {\n callback = on.modalOpen || once.modalOpen || on.panelOpen || once.panelOpen;\n }\n\n if (name === 'close') {\n callback = on.modalClose || once.modalClose || on.panelClose || once.panelClose;\n }\n\n if (name === 'closed') {\n callback = on.modalClosed || once.modalClosed || on.panelClosed || once.panelClosed;\n }\n\n if (callback) callback(modal);\n };\n\n function onModalLoaded() {\n // Create Modal\n var modal = app[modalType].create(modalParams);\n modalRoute.modalInstance = modal;\n var hasEl = modal.el;\n\n function closeOnSwipeBack() {\n modal.close();\n }\n\n modal.on(modalOrPanel + \"Open\", function () {\n if (!hasEl) {\n // Remove theme elements\n router.removeThemeElements(modal.el); // Emit events\n\n modal.$el.trigger(modalType.toLowerCase() + \":init \" + modalType.toLowerCase() + \":mounted\", route, modal);\n router.emit((!isPanel ? 'modalInit' : '') + \" \" + modalType + \"Init \" + modalType + \"Mounted\", modal.el, route, modal);\n }\n\n router.once('swipeBackMove', closeOnSwipeBack);\n routeCallback(modal, 'open');\n });\n modal.on(modalOrPanel + \"Close\", function () {\n router.off('swipeBackMove', closeOnSwipeBack);\n\n if (!modal.closeByRouter) {\n router.back();\n }\n\n routeCallback(modal, 'close');\n });\n modal.on(modalOrPanel + \"Closed\", function () {\n modal.$el.trigger(modalType.toLowerCase() + \":beforeremove\", route, modal);\n modal.emit(\"\" + (!isPanel ? 'modalBeforeRemove ' : '') + modalType + \"BeforeRemove\", modal.el, route, modal);\n var modalComponent = modal.el.f7Component;\n routeCallback(modal, 'closed');\n\n if (modalComponent) {\n modalComponent.destroy();\n }\n\n nextTick(function () {\n if (modalComponent || modalParams.component) {\n router.removeModal(modal.el);\n }\n\n modal.destroy();\n delete modal.route;\n delete modalRoute.modalInstance;\n });\n });\n\n if (options.route) {\n // Update Browser History\n if (router.params.browserHistory && options.browserHistory) {\n History.push(router.view.id, {\n url: options.route.url,\n modal: modalType\n }, (router.params.browserHistoryRoot || '') + router.params.browserHistorySeparator + options.route.url);\n } // Set Route\n\n\n if (options.route !== router.currentRoute) {\n modal.route = extend(options.route, {\n modal: modal\n });\n router.currentRoute = modal.route;\n } // Update Router History\n\n\n if (options.history && !options.reloadCurrent) {\n router.history.push(options.route.url);\n router.saveHistory();\n }\n }\n\n if (hasEl) {\n // Remove theme elements\n router.removeThemeElements(modal.el); // Emit events\n\n modal.$el.trigger(modalType.toLowerCase() + \":init \" + modalType.toLowerCase() + \":mounted\", route, modal);\n router.emit(modalOrPanel + \"Init \" + modalType + \"Init \" + modalType + \"Mounted\", modal.el, route, modal);\n } // Open\n\n\n modal.open(options.animate === false || options.animate === true ? options.animate : undefined);\n } // Load Modal Content\n\n\n function loadModal(loadModalParams, loadModalOptions) {\n // Load Modal Props\n var url = loadModalParams.url,\n content = loadModalParams.content,\n component = loadModalParams.component,\n componentUrl = loadModalParams.componentUrl; // Component/Template Callbacks\n\n function resolve(contentEl) {\n if (contentEl) {\n if (typeof contentEl === 'string') {\n modalParams.content = contentEl;\n } else if (contentEl.f7Component) {\n contentEl.f7Component.mount(function (componentEl) {\n modalParams.el = componentEl;\n app.$el.append(componentEl);\n });\n } else {\n modalParams.el = contentEl;\n }\n\n onModalLoaded();\n }\n }\n\n function reject() {\n router.allowPageChange = true;\n return router;\n }\n\n if (content) {\n resolve(content);\n } else if (component || componentUrl) {\n // Load from component (F7/Vue/React/...)\n try {\n router.modalComponentLoader({\n rootEl: app.el,\n component: component,\n componentUrl: componentUrl,\n options: loadModalOptions,\n resolve: resolve,\n reject: reject\n });\n } catch (err) {\n router.allowPageChange = true;\n throw err;\n }\n } else if (url) {\n // Load using XHR\n if (router.xhrAbortController) {\n router.xhrAbortController.abort();\n router.xhrAbortController = false;\n }\n\n router.xhrRequest(url, loadModalOptions).then(function (modalContent) {\n modalParams.content = modalContent;\n onModalLoaded();\n }).catch(function () {\n router.allowPageChange = true;\n });\n } else {\n onModalLoaded();\n }\n }\n\n var foundLoadProp;\n 'url content component el componentUrl template'.split(' ').forEach(function (modalLoadProp) {\n if (modalParams[modalLoadProp] && !foundLoadProp) {\n var _loadModal;\n\n foundLoadProp = true;\n loadModal((_loadModal = {}, _loadModal[modalLoadProp] = modalParams[modalLoadProp], _loadModal), options);\n }\n });\n\n if (!foundLoadProp && modalType === 'actions') {\n onModalLoaded();\n } // Async\n\n\n function asyncResolve(resolveParams, resolveOptions) {\n loadModal(resolveParams, extend(options, resolveOptions));\n }\n\n function asyncReject() {\n router.allowPageChange = true;\n }\n\n if (modalParams.async) {\n modalParams.async.call(router, {\n router: router,\n to: options.route,\n from: router.currentRoute,\n resolve: asyncResolve,\n reject: asyncReject,\n direction: direction,\n app: app\n });\n }\n\n if (modalParams.asyncComponent) {\n asyncComponent(router, modalParams.asyncComponent, asyncResolve, asyncReject);\n }\n\n return router;\n}\n\nfunction modalRemove(modal) {\n extend(modal, {\n closeByRouter: true\n });\n modal.close();\n}\n\nexport { modalLoad, modalRemove };","import $ from '../../shared/dom7';\nimport appRouterCheck from './app-router-check';\n\nfunction clearPreviousPages(router) {\n appRouterCheck(router, 'clearPreviousPages');\n var app = router.app;\n var dynamicNavbar = router.dynamicNavbar;\n var $pagesToRemove = router.$el.children('.page').filter(function (pageInView) {\n if (router.currentRoute && (router.currentRoute.modal || router.currentRoute.panel)) return true;\n return pageInView !== router.currentPageEl;\n });\n $pagesToRemove.each(function (pageEl) {\n var $oldPageEl = $(pageEl);\n var $oldNavbarEl = $(app.navbar.getElByPage($oldPageEl));\n\n if (router.params.stackPages && router.initialPages.indexOf($oldPageEl[0]) >= 0) {\n $oldPageEl.addClass('stacked');\n\n if (dynamicNavbar) {\n $oldNavbarEl.addClass('stacked');\n }\n } else {\n // Page remove event\n router.pageCallback('beforeRemove', $oldPageEl, $oldNavbarEl, 'previous', undefined, {});\n router.removePage($oldPageEl);\n\n if (dynamicNavbar && $oldNavbarEl.length) {\n router.removeNavbar($oldNavbarEl);\n }\n }\n });\n}\n\nfunction clearPreviousHistory() {\n var router = this;\n appRouterCheck(router, 'clearPreviousHistory');\n var url = router.history[router.history.length - 1];\n clearPreviousPages(router);\n router.history = [url];\n router.view.history = [url];\n router.saveHistory();\n}\n\nexport { clearPreviousHistory }; // eslint-disable-line","import Router from './router-class';\nexport default {\n name: 'router',\n static: {\n Router: Router\n },\n instance: {\n cache: {\n xhr: [],\n templates: [],\n components: []\n }\n },\n create: function create() {\n var instance = this;\n\n if (instance.app) {\n // View Router\n if (instance.params.router) {\n instance.router = new Router(instance.app, instance);\n }\n } else {\n // App Router\n instance.router = new Router(instance);\n }\n }\n};","import { getWindow, getDocument } from 'ssr-window';\nimport { id } from '../../shared/utils';\nimport $ from '../../shared/dom7';\nvar fetchedModules = [];\n\nfunction loadModule(moduleToLoad) {\n var Framework7 = this;\n var window = getWindow();\n var document = getDocument();\n return new Promise(function (resolve, reject) {\n var app = Framework7.instance;\n var modulePath;\n var moduleObj;\n var moduleFunc;\n\n if (!moduleToLoad) {\n reject(new Error('Framework7: Lazy module must be specified'));\n return;\n }\n\n function install(module) {\n Framework7.use(module);\n\n if (app) {\n app.useModuleParams(module, app.params);\n app.useModule(module);\n }\n }\n\n if (typeof moduleToLoad === 'string') {\n var matchNamePattern = moduleToLoad.match(/([a-z0-9-]*)/i);\n\n if (moduleToLoad.indexOf('.') < 0 && matchNamePattern && matchNamePattern[0].length === moduleToLoad.length) {\n if (!app || app && !app.params.lazyModulesPath) {\n reject(new Error('Framework7: \"lazyModulesPath\" app parameter must be specified to fetch module by name'));\n return;\n }\n\n modulePath = app.params.lazyModulesPath + \"/\" + moduleToLoad + \"/\" + moduleToLoad + \".js\";\n } else {\n modulePath = moduleToLoad;\n }\n } else if (typeof moduleToLoad === 'function') {\n moduleFunc = moduleToLoad;\n } else {\n // considering F7-Plugin object\n moduleObj = moduleToLoad;\n }\n\n if (moduleFunc) {\n var module = moduleFunc(Framework7, false);\n\n if (!module) {\n reject(new Error(\"Framework7: Can't find Framework7 component in specified component function\"));\n return;\n } // Check if it was added\n\n\n if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) {\n resolve();\n return;\n } // Install It\n\n\n install(module);\n resolve();\n }\n\n if (moduleObj) {\n var _module = moduleObj;\n\n if (!_module) {\n reject(new Error(\"Framework7: Can't find Framework7 component in specified component\"));\n return;\n } // Check if it was added\n\n\n if (Framework7.prototype.modules && Framework7.prototype.modules[_module.name]) {\n resolve();\n return;\n } // Install It\n\n\n install(_module);\n resolve();\n }\n\n if (modulePath) {\n if (fetchedModules.indexOf(modulePath) >= 0) {\n resolve();\n return;\n }\n\n fetchedModules.push(modulePath);\n var scriptLoad = new Promise(function (resolveScript, rejectScript) {\n Framework7.request.get(modulePath, function (scriptContent) {\n var callbackId = id();\n var callbackLoadName = \"f7_component_loader_callback_\" + callbackId;\n var scriptEl = document.createElement('script');\n scriptEl.innerHTML = \"window.\" + callbackLoadName + \" = function (Framework7, Framework7AutoInstallComponent) {return \" + scriptContent.trim() + \"}\";\n $('head').append(scriptEl);\n var componentLoader = window[callbackLoadName];\n delete window[callbackLoadName];\n $(scriptEl).remove();\n var module = componentLoader(Framework7, false);\n\n if (!module) {\n rejectScript(new Error(\"Framework7: Can't find Framework7 component in \" + modulePath + \" file\"));\n return;\n } // Check if it was added\n\n\n if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) {\n resolveScript();\n return;\n } // Install It\n\n\n install(module);\n resolveScript();\n }, function (xhr, status) {\n rejectScript(xhr, status);\n });\n });\n var styleLoad = new Promise(function (resolveStyle) {\n Framework7.request.get(modulePath.replace('.js', app.rtl ? '.rtl.css' : '.css'), function (styleContent) {\n var styleEl = document.createElement('style');\n styleEl.innerHTML = styleContent;\n $('head').append(styleEl);\n resolveStyle();\n }, function () {\n resolveStyle();\n });\n });\n Promise.all([scriptLoad, styleLoad]).then(function () {\n resolve();\n }).catch(function (err) {\n reject(err);\n });\n }\n });\n}\n\nexport default loadModule;","function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\n/* eslint-disable no-underscore-dangle */\nimport { getWindow, getDocument } from 'ssr-window';\nimport { extend, nextFrame } from '../../shared/utils';\nimport { getDevice } from '../../shared/get-device';\nimport { getSupport } from '../../shared/get-support';\nimport Framework7Class from '../../shared/class';\nimport EventsClass from '../../shared/events-class';\nimport ConstructorMethods from '../../shared/constructor-methods';\nimport ModalMethods from '../../shared/modal-methods';\nimport $ from '../../shared/dom7';\nimport loadModule from './load-module';\n\nvar Framework7 = /*#__PURE__*/function (_Framework7Class) {\n _inheritsLoose(Framework7, _Framework7Class);\n\n function Framework7(params) {\n var _this;\n\n if (params === void 0) {\n params = {};\n }\n\n _this = _Framework7Class.call(this, params) || this; // eslint-disable-next-line\n\n if (Framework7.instance && typeof window !== 'undefined') {\n throw new Error(\"Framework7 is already initialized and can't be initialized more than once\");\n }\n\n var device = getDevice({\n userAgent: params.userAgent || undefined\n });\n var support = getSupport();\n var passedParams = extend({}, params); // App Instance\n\n var app = _assertThisInitialized(_this);\n\n app.device = device;\n app.support = support;\n var w = getWindow();\n var d = getDocument();\n Framework7.instance = app; // Default\n\n var defaults = {\n version: '1.0.0',\n id: 'io.framework7.myapp',\n el: 'body',\n theme: 'auto',\n language: w.navigator.language,\n routes: [],\n name: 'Framework7',\n lazyModulesPath: null,\n initOnDeviceReady: true,\n init: true,\n autoDarkTheme: false,\n iosTranslucentBars: true,\n iosTranslucentModals: true,\n component: undefined,\n componentUrl: undefined,\n userAgent: null,\n url: null\n }; // Extend defaults with modules params\n\n app.useModulesParams(defaults); // Extend defaults with passed params\n\n app.params = extend(defaults, params);\n extend(app, {\n // App Id\n id: app.params.id,\n // App Name\n name: app.params.name,\n // App version\n version: app.params.version,\n // Routes\n routes: app.params.routes,\n // Lang\n language: app.params.language,\n // Theme\n theme: function getTheme() {\n if (app.params.theme === 'auto') {\n if (device.ios) return 'ios';\n if (device.desktop && device.electron) return 'aurora';\n return 'md';\n }\n\n return app.params.theme;\n }(),\n // Initially passed parameters\n passedParams: passedParams,\n online: w.navigator.onLine\n });\n if (params.store) app.params.store = params.store; // Save Root\n\n if (app.$el && app.$el[0]) {\n app.$el[0].f7 = app;\n } // Install Modules\n\n\n app.useModules(); // Init Store\n\n app.initStore(); // Init\n\n if (app.params.init) {\n if (device.cordova && app.params.initOnDeviceReady) {\n $(d).on('deviceready', function () {\n app.init();\n });\n } else {\n app.init();\n }\n } // Return app instance\n\n\n return app || _assertThisInitialized(_this);\n }\n\n var _proto = Framework7.prototype;\n\n _proto.mount = function mount(rootEl) {\n var app = this;\n var window = getWindow();\n var document = getDocument();\n var $rootEl = $(rootEl || app.params.el).eq(0);\n app.$el = $rootEl;\n\n if (app.$el && app.$el[0]) {\n app.el = app.$el[0];\n app.el.f7 = app;\n app.rtl = $rootEl.css('direction') === 'rtl';\n } // Auto Dark Theme\n\n\n var DARK = '(prefers-color-scheme: dark)';\n var LIGHT = '(prefers-color-scheme: light)';\n app.mq = {};\n\n if (window.matchMedia) {\n app.mq.dark = window.matchMedia(DARK);\n app.mq.light = window.matchMedia(LIGHT);\n }\n\n app.colorSchemeListener = function colorSchemeListener(_ref) {\n var matches = _ref.matches,\n media = _ref.media;\n\n if (!matches) {\n return;\n }\n\n var html = document.querySelector('html');\n\n if (media === DARK) {\n html.classList.add('theme-dark');\n app.darkTheme = true;\n app.emit('darkThemeChange', true);\n } else if (media === LIGHT) {\n html.classList.remove('theme-dark');\n app.darkTheme = false;\n app.emit('darkThemeChange', false);\n }\n };\n\n app.emit('mount');\n };\n\n _proto.initStore = function initStore() {\n var app = this;\n\n if (typeof app.params.store !== 'undefined' && app.params.store.__store) {\n app.store = app.params.store;\n } else {\n app.store = app.createStore(app.params.store);\n }\n };\n\n _proto.enableAutoDarkTheme = function enableAutoDarkTheme() {\n var window = getWindow();\n var document = getDocument();\n if (!window.matchMedia) return;\n var app = this;\n var html = document.querySelector('html');\n\n if (app.mq.dark && app.mq.light) {\n app.mq.dark.addListener(app.colorSchemeListener);\n app.mq.light.addListener(app.colorSchemeListener);\n }\n\n if (app.mq.dark && app.mq.dark.matches) {\n html.classList.add('theme-dark');\n app.darkTheme = true;\n app.emit('darkThemeChange', true);\n } else if (app.mq.light && app.mq.light.matches) {\n html.classList.remove('theme-dark');\n app.darkTheme = false;\n app.emit('darkThemeChange', false);\n }\n };\n\n _proto.disableAutoDarkTheme = function disableAutoDarkTheme() {\n var window = getWindow();\n if (!window.matchMedia) return;\n var app = this;\n if (app.mq.dark) app.mq.dark.removeListener(app.colorSchemeListener);\n if (app.mq.light) app.mq.light.removeListener(app.colorSchemeListener);\n };\n\n _proto.initAppComponent = function initAppComponent(callback) {\n var app = this;\n app.router.componentLoader(app.params.component, app.params.componentUrl, {\n componentOptions: {\n el: app.$el[0]\n }\n }, function (el) {\n app.$el = $(el);\n app.$el[0].f7 = app;\n app.$elComponent = el.f7Component;\n app.el = app.$el[0];\n if (callback) callback();\n }, function () {});\n };\n\n _proto.init = function init(rootEl) {\n var app = this;\n app.mount(rootEl);\n\n var init = function init() {\n if (app.initialized) return;\n app.$el.addClass('framework7-initializing'); // RTL attr\n\n if (app.rtl) {\n $('html').attr('dir', 'rtl');\n } // Auto Dark Theme\n\n\n if (app.params.autoDarkTheme) {\n app.enableAutoDarkTheme();\n } // Watch for online/offline state\n\n\n var window = getWindow();\n window.addEventListener('offline', function () {\n app.online = false;\n app.emit('offline');\n app.emit('connection', false);\n });\n window.addEventListener('online', function () {\n app.online = true;\n app.emit('online');\n app.emit('connection', true);\n }); // Root class\n\n app.$el.addClass('framework7-root'); // Theme class\n\n $('html').removeClass('ios md aurora').addClass(app.theme); // iOS Translucent\n\n var device = app.device;\n\n if (app.params.iosTranslucentBars && app.theme === 'ios' && device.ios) {\n $('html').addClass('ios-translucent-bars');\n }\n\n if (app.params.iosTranslucentModals && app.theme === 'ios' && device.ios) {\n $('html').addClass('ios-translucent-modals');\n } // Init class\n\n\n nextFrame(function () {\n app.$el.removeClass('framework7-initializing');\n }); // Emit, init other modules\n\n app.initialized = true;\n app.emit('init');\n };\n\n if (app.params.component || app.params.componentUrl) {\n app.initAppComponent(function () {\n init();\n });\n } else {\n init();\n }\n\n return app;\n } // eslint-disable-next-line\n ;\n\n _proto.loadModule = function loadModule() {\n return Framework7.loadModule.apply(Framework7, arguments);\n } // eslint-disable-next-line\n ;\n\n _proto.loadModules = function loadModules() {\n return Framework7.loadModules.apply(Framework7, arguments);\n };\n\n _proto.getVnodeHooks = function getVnodeHooks(hook, id) {\n var app = this;\n if (!app.vnodeHooks || !app.vnodeHooks[hook]) return [];\n return app.vnodeHooks[hook][id] || [];\n } // eslint-disable-next-line\n ;\n\n _createClass(Framework7, [{\n key: \"$\",\n get: function get() {\n return $;\n }\n }], [{\n key: \"Dom7\",\n get: function get() {\n return $;\n }\n }, {\n key: \"$\",\n get: function get() {\n return $;\n }\n }, {\n key: \"device\",\n get: function get() {\n return getDevice();\n }\n }, {\n key: \"support\",\n get: function get() {\n return getSupport();\n }\n }, {\n key: \"Class\",\n get: function get() {\n return Framework7Class;\n }\n }, {\n key: \"Events\",\n get: function get() {\n return EventsClass;\n }\n }]);\n\n return Framework7;\n}(Framework7Class);\n\nFramework7.ModalMethods = ModalMethods;\nFramework7.ConstructorMethods = ConstructorMethods;\nFramework7.loadModule = loadModule;\n\nFramework7.loadModules = function loadModules(modules) {\n return Promise.all(modules.map(function (module) {\n return Framework7.loadModule(module);\n }));\n};\n\nexport default Framework7;","'use strict';\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _require = require('../'),\n difference = _require.difference,\n flatMap = _require.flatMap;\n\nvar setSimulcastInMediaSection = require('./simulcast');\n\nvar ptToFixedBitrateAudioCodecName = {\n 0: 'PCMU',\n 8: 'PCMA'\n};\n\n/**\n * A payload type\n * @typedef {number} PT\n */\n\n/**\n * An {@link AudioCodec} or {@link VideoCodec}\n * @typedef {AudioCodec|VideoCodec} Codec\n */\n\n// NOTE(mmalavalli): This value is derived from the IETF spec\n// for JSEP, and it is used to convert a 'b=TIAS' value in bps\n// to a 'b=AS' value in kbps.\n// Spec: https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-21#section-5.9\nvar RTCP_BITRATE = 16000;\n\n/**\n * Construct a b= line string for the given max bitrate in bps. If the modifier\n * is 'AS', then the max bitrate will be converted to kbps using the formula\n * specified in the IETF spec for JSEP mentioned above.\n * @param {string} modifier - 'AS' | 'TIAS'\n * @param {?number} maxBitrate - Max outgoing bitrate (bps)\n * @returns {?string} - If \"maxBitrate\" is null, then returns null;\n * otherwise return the constructed b= line string\n */\nfunction createBLine(modifier, maxBitrate) {\n if (!maxBitrate) {\n return null;\n }\n return '\\r\\nb=' + modifier + ':' + (modifier === 'AS' ? Math.round((maxBitrate + RTCP_BITRATE) / 950) : maxBitrate);\n}\n\n/**\n * Create a Codec Map for the given m= section.\n * @param {string} section - The given m= section\n * @returns {Map>}\n */\nfunction createCodecMapForMediaSection(section) {\n return Array.from(createPtToCodecName(section)).reduce(function (codecMap, pair) {\n var pt = pair[0];\n var codecName = pair[1];\n var pts = codecMap.get(codecName) || [];\n return codecMap.set(codecName, pts.concat(pt));\n }, new Map());\n}\n\n/**\n * Create a Map of MIDs to m= sections for the given SDP.\n * @param {string} sdp\n * @returns {Map}\n */\nfunction createMidToMediaSectionMap(sdp) {\n return getMediaSections(sdp).reduce(function (midsToMediaSections, mediaSection) {\n var mid = getMidForMediaSection(mediaSection);\n return mid ? midsToMediaSections.set(mid, mediaSection) : midsToMediaSections;\n }, new Map());\n}\n\n/**\n * Create a Map from PTs to codec names for the given m= section.\n * @param {string} mediaSection - The given m= section.\n * @returns {Map} ptToCodecName\n */\nfunction createPtToCodecName(mediaSection) {\n return getPayloadTypesInMediaSection(mediaSection).reduce(function (ptToCodecName, pt) {\n var rtpmapPattern = new RegExp('a=rtpmap:' + pt + ' ([^/]+)');\n var matches = mediaSection.match(rtpmapPattern);\n var codecName = matches ? matches[1].toLowerCase() : ptToFixedBitrateAudioCodecName[pt] ? ptToFixedBitrateAudioCodecName[pt].toLowerCase() : '';\n return ptToCodecName.set(pt, codecName);\n }, new Map());\n}\n\n/**\n * Get the associated fmtp attributes for the given Payload Type in an m= section.\n * @param {PT} pt\n * @param {string} mediaSection\n * @returns {?object}\n */\nfunction getFmtpAttributesForPt(pt, mediaSection) {\n // In \"a=fmtp: =[;=]*\", the regex matches the codec\n // profile parameters expressed as name/value pairs separated by \";\".\n var fmtpRegex = new RegExp('^a=fmtp:' + pt + ' (.+)$', 'm');\n var matches = mediaSection.match(fmtpRegex);\n return matches && matches[1].split(';').reduce(function (attrs, nvPair) {\n var _nvPair$split = nvPair.split('='),\n _nvPair$split2 = _slicedToArray(_nvPair$split, 2),\n name = _nvPair$split2[0],\n value = _nvPair$split2[1];\n\n attrs[name] = isNaN(value) ? value : parseInt(value, 10);\n return attrs;\n }, {});\n}\n\n/**\n * Get the MID for the given m= section.\n * @param {string} mediaSection\n * @return {?string}\n */\nfunction getMidForMediaSection(mediaSection) {\n // In \"a=mid:\", the regex matches .\n var midMatches = mediaSection.match(/^a=mid:(.+)$/m);\n return midMatches && midMatches[1];\n}\n\n/**\n * Get the m= sections of a particular kind and direction from an sdp.\n * @param {string} sdp - SDP string\n * @param {string} [kind] - Pattern for matching kind\n * @param {string} [direction] - Pattern for matching direction\n * @returns {Array} mediaSections\n */\nfunction getMediaSections(sdp, kind, direction) {\n return sdp.replace(/\\r\\n\\r\\n$/, '\\r\\n').split('\\r\\nm=').slice(1).map(function (mediaSection) {\n return 'm=' + mediaSection;\n }).filter(function (mediaSection) {\n var kindPattern = new RegExp('m=' + (kind || '.*'), 'gm');\n var directionPattern = new RegExp('a=' + (direction || '.*'), 'gm');\n return kindPattern.test(mediaSection) && directionPattern.test(mediaSection);\n });\n}\n\n/**\n * Get the Codec Payload Types present in the first line of the given m= section\n * @param {string} section - The m= section\n * @returns {Array} Payload Types\n */\nfunction getPayloadTypesInMediaSection(section) {\n var mLine = section.split('\\r\\n')[0];\n\n // In \"m= ... \",\n // the regex matches and the Payload Types.\n var matches = mLine.match(/([0-9]+)/g);\n\n // This should not happen, but in case there are no Payload Types in\n // the m= line, return an empty array.\n if (!matches) {\n return [];\n }\n\n // Since only the Payload Types are needed, we discard the .\n return matches.slice(1).map(function (match) {\n return parseInt(match, 10);\n });\n}\n\n/**\n * Create the reordered Codec Payload Types based on the preferred Codec Names.\n * @param {Map>} codecMap - Codec Map\n * @param {Array} preferredCodecs - Preferred Codecs\n * @returns {Array} Reordered Payload Types\n */\nfunction getReorderedPayloadTypes(codecMap, preferredCodecs) {\n preferredCodecs = preferredCodecs.map(function (_ref) {\n var codec = _ref.codec;\n return codec.toLowerCase();\n });\n var preferredPayloadTypes = flatMap(preferredCodecs, function (codecName) {\n return codecMap.get(codecName) || [];\n });\n var remainingCodecs = difference(Array.from(codecMap.keys()), preferredCodecs);\n var remainingPayloadTypes = flatMap(remainingCodecs, function (codecName) {\n return codecMap.get(codecName);\n });\n return preferredPayloadTypes.concat(remainingPayloadTypes);\n}\n\n/**\n * Set the specified max bitrate in the given m= section.\n * @param {string} modifier - 'AS' | 'TIAS'\n * @param {?number} maxBitrate - Max outgoing bitrate (bps)\n * @param {string} section - m= section string\n * @returns {string} The updated m= section\n */\nfunction setBitrateInMediaSection(modifier, maxBitrate, section) {\n var bLine = createBLine(modifier, maxBitrate) || '';\n var bLinePattern = /\\r\\nb=(AS|TIAS):([0-9]+)/;\n var bLineMatched = section.match(bLinePattern);\n\n if (!bLineMatched) {\n return section.replace(/(\\r\\n)?$/, bLine + '$1');\n }\n\n var maxBitrateMatched = parseInt(bLineMatched[2], 10);\n maxBitrate = maxBitrate || Infinity;\n bLine = createBLine(modifier, Math.min(maxBitrateMatched, maxBitrate));\n return section.replace(bLinePattern, bLine);\n}\n\n/**\n * Set maximum bitrates to the media sections in a given sdp.\n * @param {string} sdp - sdp string\n * @param {string} modifier - 'AS' | 'TIAS\"\n * @param {?number} maxAudioBitrate - Max outgoing audio bitrate (bps), null\n * if no limit is to be applied\n * @param {?number} maxVideoBitrate - Max outgoing video bitrate (bps), null\n * if no limit is to be applied\n * @returns {string} - The updated sdp string\n */\nfunction setBitrateParameters(sdp, modifier, maxAudioBitrate, maxVideoBitrate) {\n var mediaSections = getMediaSections(sdp);\n var session = sdp.split('\\r\\nm=')[0];\n return [session].concat(mediaSections.map(function (section) {\n // Bitrate parameters should not be applied to m=application sections\n // or to m=(audio|video) sections that do not receive media.\n if (!/^m=(audio|video)/.test(section) || !/a=(recvonly|sendrecv)/.test(section)) {\n return section;\n }\n var kind = section.match(/^m=(audio|video)/)[1];\n var maxBitrate = kind === 'audio' ? maxAudioBitrate : maxVideoBitrate;\n return setBitrateInMediaSection(modifier, maxBitrate, section);\n })).join('\\r\\n');\n}\n\n/**\n * Set the given Codec Payload Types in the first line of the given m= section.\n * @param {Array} payloadTypes - Payload Types\n * @param {string} section - Given m= section\n * @returns {string} - Updated m= section\n */\nfunction setPayloadTypesInMediaSection(payloadTypes, section) {\n var lines = section.split('\\r\\n');\n var mLine = lines[0];\n var otherLines = lines.slice(1);\n mLine = mLine.replace(/([0-9]+\\s?)+$/, payloadTypes.join(' '));\n return [mLine].concat(otherLines).join('\\r\\n');\n}\n\n/**\n * Return a new SDP string with the re-ordered codec preferences.\n * @param {string} sdp\n * @param {Array} preferredAudioCodecs - If empty, the existing order\n * of audio codecs is preserved\n * @param {Array} preferredVideoCodecs - If empty, the\n * existing order of video codecs is preserved\n * @returns {string} Updated SDP string\n */\nfunction setCodecPreferences(sdp, preferredAudioCodecs, preferredVideoCodecs) {\n var mediaSections = getMediaSections(sdp);\n var session = sdp.split('\\r\\nm=')[0];\n return [session].concat(mediaSections.map(function (section) {\n // Codec preferences should not be applied to m=application sections.\n if (!/^m=(audio|video)/.test(section)) {\n return section;\n }\n var kind = section.match(/^m=(audio|video)/)[1];\n var codecMap = createCodecMapForMediaSection(section);\n var preferredCodecs = kind === 'audio' ? preferredAudioCodecs : preferredVideoCodecs;\n var payloadTypes = getReorderedPayloadTypes(codecMap, preferredCodecs);\n var newSection = setPayloadTypesInMediaSection(payloadTypes, section);\n\n var pcmaPayloadTypes = codecMap.get('pcma') || [];\n var pcmuPayloadTypes = codecMap.get('pcmu') || [];\n var fixedBitratePayloadTypes = kind === 'audio' ? new Set(pcmaPayloadTypes.concat(pcmuPayloadTypes)) : new Set();\n\n return fixedBitratePayloadTypes.has(payloadTypes[0]) ? newSection.replace(/\\r\\nb=(AS|TIAS):([0-9]+)/g, '') : newSection;\n })).join('\\r\\n');\n}\n\n/**\n * Return a new SDP string with simulcast settings.\n * @param {string} sdp\n * @param {'planb' | 'unified'} sdpFormat\n * @param {Map} trackIdsToAttributes\n * @returns {string} Updated SDP string\n */\nfunction setSimulcast(sdp, sdpFormat, trackIdsToAttributes) {\n var mediaSections = getMediaSections(sdp);\n var session = sdp.split('\\r\\nm=')[0];\n return [session].concat(mediaSections.map(function (section) {\n section = section.replace(/\\r\\n$/, '');\n if (!/^m=video/.test(section)) {\n return section;\n }\n var codecMap = createCodecMapForMediaSection(section);\n var payloadTypes = getPayloadTypesInMediaSection(section);\n var vp8PayloadTypes = new Set(codecMap.get('vp8') || []);\n\n var hasVP8PayloadType = payloadTypes.some(function (payloadType) {\n return vp8PayloadTypes.has(payloadType);\n });\n return hasVP8PayloadType ? setSimulcastInMediaSection(section, sdpFormat, trackIdsToAttributes) : section;\n })).concat('').join('\\r\\n');\n}\n\n/**\n * Get the matching Payload Types in a unified plan m= section for a particular peer codec.\n * @param {Codec} peerCodec\n * @param {PT} peerPt\n * @param {Map} codecsToPts\n * @param {string} section\n * @param {string} peerSection\n * @returns {Array}\n */\nfunction unifiedPlanGetMatchingPayloadTypes(peerCodec, peerPt, codecsToPts, section, peerSection) {\n // If there is at most one local Payload Type that matches the remote codec, retain it.\n var matchingPts = codecsToPts.get(peerCodec) || [];\n if (matchingPts.length <= 1) {\n return matchingPts;\n }\n\n // If there are no fmtp attributes for the codec in the peer m= section, then we\n // cannot get a match in the m= section. In that case, retain all matching Payload\n // Types.\n var peerFmtpAttrs = getFmtpAttributesForPt(peerPt, peerSection);\n if (!peerFmtpAttrs) {\n return matchingPts;\n }\n\n // Among the matched local Payload Types, find the one that matches the remote\n // fmtp attributes.\n var matchingPt = matchingPts.find(function (pt) {\n var fmtpAttrs = getFmtpAttributesForPt(pt, section);\n return fmtpAttrs && Object.keys(peerFmtpAttrs).every(function (attr) {\n return peerFmtpAttrs[attr] === fmtpAttrs[attr];\n });\n });\n\n // If none of the matched Payload Types also have matching fmtp attributes,\n // then retain all of them, otherwise retain only the Payload Type that\n // matches the peer fmtp attributes.\n return typeof matchingPt === 'number' ? [matchingPt] : matchingPts;\n}\n\n/**\n * Filter codecs in a unified plan m= section based on its peer m= section.\n * from the other peer.\n * @param {string} section\n * @param {Map} peerMidsToMediaSections\n * @param {Array} codecsToRemove\n * @returns {string}\n */\nfunction unifiedPlanFilterCodecsInMediaSection(section, peerMidsToMediaSections, codecsToRemove) {\n // Do nothing if the m= section represents neither audio nor video.\n if (!/^m=(audio|video)/.test(section)) {\n return section;\n }\n\n // Do nothing if the m= section does not have an equivalent remote m= section.\n var mid = getMidForMediaSection(section);\n var peerSection = mid && peerMidsToMediaSections.get(mid);\n if (!peerSection) {\n return section;\n }\n\n // Construct a Map of the peer Payload Types to their codec names.\n var peerPtToCodecs = createPtToCodecName(peerSection);\n // Construct a Map of the codec names to their Payload Types.\n var codecsToPts = createCodecMapForMediaSection(section);\n // Maintain a list of non-rtx Payload Types to retain.\n var pts = flatMap(Array.from(peerPtToCodecs), function (_ref2) {\n var _ref3 = _slicedToArray(_ref2, 2),\n peerPt = _ref3[0],\n peerCodec = _ref3[1];\n\n return peerCodec !== 'rtx' && !codecsToRemove.includes(peerCodec) ? unifiedPlanGetMatchingPayloadTypes(peerCodec, peerPt, codecsToPts, section, peerSection) : [];\n });\n\n // For each Payload Type that will be retained, retain their corresponding rtx\n // Payload Type if present.\n var rtxPts = codecsToPts.get('rtx') || [];\n // In \"a=fmtp: apt=\", extract the codec PT associated with rtxPt.\n pts = pts.concat(rtxPts.filter(function (rtxPt) {\n var fmtpAttrs = getFmtpAttributesForPt(rtxPt, section);\n return fmtpAttrs && pts.includes(fmtpAttrs.apt);\n }));\n\n // Filter out the below mentioned attribute lines in the m= section that do not\n // belong to one of the Payload Types that are to be retained.\n // 1. \"a=rtpmap: \"\n // 2. \"a=rtcp-fb: [ ]*\"\n // 3. \"a=fmtp: =[;=]*\"\n var lines = section.split('\\r\\n').filter(function (line) {\n var ptMatches = line.match(/^a=(rtpmap|fmtp|rtcp-fb):(.+) .+$/);\n var pt = ptMatches && ptMatches[2];\n return !ptMatches || pt && pts.includes(parseInt(pt, 10));\n });\n\n // Filter the list of Payload Types in the first line of the m= section.\n var orderedPts = getPayloadTypesInMediaSection(section).filter(function (pt) {\n return pts.includes(pt);\n });\n return setPayloadTypesInMediaSection(orderedPts, lines.join('\\r\\n'));\n}\n\n/**\n * Filter local codecs based on the remote unified plan SDP.\n * @param {string} localSdp\n * @param {string} remoteSdp\n * @returns {string} - Updated local SDP\n */\nfunction unifiedPlanFilterLocalCodecs(localSdp, remoteSdp) {\n var localMediaSections = getMediaSections(localSdp);\n var localSession = localSdp.split('\\r\\nm=')[0];\n var remoteMidsToMediaSections = createMidToMediaSectionMap(remoteSdp);\n return [localSession].concat(localMediaSections.map(function (localSection) {\n return unifiedPlanFilterCodecsInMediaSection(localSection, remoteMidsToMediaSections, []);\n })).join('\\r\\n');\n}\n\n/**\n * Return a new SDP string after reverting simulcast for non vp8 sections in remote sdp.\n * @param localSdp - simulcast enabled local sdp\n * @param localSdpWithoutSimulcast - local sdp before simulcast was set\n * @param remoteSdp - remote sdp\n * @return {string} Updated SDP string\n */\nfunction revertSimulcastForNonVP8MediaSections(localSdp, localSdpWithoutSimulcast, remoteSdp) {\n var remoteMidToMediaSections = createMidToMediaSectionMap(remoteSdp);\n var localMidToMediaSectionsWithoutSimulcast = createMidToMediaSectionMap(localSdpWithoutSimulcast);\n var mediaSections = getMediaSections(localSdp);\n var session = localSdp.split('\\r\\nm=')[0];\n return [session].concat(mediaSections.map(function (section) {\n section = section.replace(/\\r\\n$/, '');\n if (!/^m=video/.test(section)) {\n return section;\n }\n var midMatches = section.match(/^a=mid:(.+)$/m);\n var mid = midMatches && midMatches[1];\n if (!mid) {\n return section;\n }\n\n var remoteSection = remoteMidToMediaSections.get(mid);\n var remotePtToCodecs = createPtToCodecName(remoteSection);\n var remotePayloadTypes = getPayloadTypesInMediaSection(remoteSection);\n\n var isVP8ThePreferredCodec = remotePayloadTypes.length && remotePtToCodecs.get(remotePayloadTypes[0]) === 'vp8';\n return isVP8ThePreferredCodec ? section : localMidToMediaSectionsWithoutSimulcast.get(mid).replace(/\\r\\n$/, '');\n })).concat('').join('\\r\\n');\n}\n\n/**\n * Add or rewrite MSIDs for new m= sections in the given Unified Plan SDP with their\n * corresponding local MediaStreamTrack IDs. These can be different when previously\n * removed MediaStreamTracks are added back (or Track IDs may not be present in the\n * SDPs at all once browsers implement the latest WebRTC spec).\n * @param {string} sdp\n * @param {Map} activeMidsToTrackIds\n * @param {Map>} trackIdsByKind\n * @returns {string}\n */\nfunction unifiedPlanAddOrRewriteNewTrackIds(sdp, activeMidsToTrackIds, trackIdsByKind) {\n // NOTE(mmalavalli): The m= sections for the new MediaStreamTracks are usually\n // present after the m= sections for the existing MediaStreamTracks, in order\n // of addition.\n var newMidsToTrackIds = Array.from(trackIdsByKind).reduce(function (midsToTrackIds, _ref4) {\n var _ref5 = _slicedToArray(_ref4, 2),\n kind = _ref5[0],\n trackIds = _ref5[1];\n\n var mediaSections = getMediaSections(sdp, kind, 'send(only|recv)');\n var newMids = mediaSections.map(getMidForMediaSection).filter(function (mid) {\n return !activeMidsToTrackIds.has(mid);\n });\n newMids.forEach(function (mid, i) {\n return midsToTrackIds.set(mid, trackIds[i]);\n });\n return midsToTrackIds;\n }, new Map());\n return unifiedPlanAddOrRewriteTrackIds(sdp, newMidsToTrackIds);\n}\n\n/**\n * Add or rewrite MSIDs in the given Unified Plan SDP with their corresponding local\n * MediaStreamTrack IDs. These IDs need not be the same (or Track IDs may not be\n * present in the SDPs at all once browsers implement the latest WebRTC spec).\n * @param {string} sdp\n * @param {Map} midsToTrackIds\n * @returns {string}\n */\nfunction unifiedPlanAddOrRewriteTrackIds(sdp, midsToTrackIds) {\n var mediaSections = getMediaSections(sdp);\n var session = sdp.split('\\r\\nm=')[0];\n return [session].concat(mediaSections.map(function (mediaSection) {\n // Do nothing if the m= section represents neither audio nor video.\n if (!/^m=(audio|video)/.test(mediaSection)) {\n return mediaSection;\n }\n // This shouldn't happen, but in case there is no MID for the m= section, do nothing.\n var mid = getMidForMediaSection(mediaSection);\n if (!mid) {\n return mediaSection;\n }\n // In case there is no Track ID for the given MID in the map, do nothing.\n var trackId = midsToTrackIds.get(mid);\n if (!trackId) {\n return mediaSection;\n }\n // This shouldn't happen, but in case there is no a=msid: line, do nothing.\n var attributes = (mediaSection.match(/^a=msid:(.+)$/m) || [])[1];\n if (!attributes) {\n return mediaSection;\n }\n // If the a=msid: line contains the \"appdata\" field, then replace it with the Track ID,\n // otherwise append the Track ID.\n\n var _attributes$split = attributes.split(' '),\n _attributes$split2 = _slicedToArray(_attributes$split, 2),\n msid = _attributes$split2[0],\n trackIdToRewrite = _attributes$split2[1];\n\n var msidRegex = new RegExp('msid:' + msid + (trackIdToRewrite ? ' ' + trackIdToRewrite : '') + '$', 'gm');\n return mediaSection.replace(msidRegex, 'msid:' + msid + ' ' + trackId);\n })).join('\\r\\n');\n}\n\n/**\n * removes specified ssrc attributes from given sdp\n * @param {string} sdp\n * @param {Array} ssrcAttributesToRemove\n * @returns {string}\n */\nfunction removeSSRCAttributes(sdp, ssrcAttributesToRemove) {\n return sdp.split('\\r\\n').filter(function (line) {\n return !ssrcAttributesToRemove.find(function (srcAttribute) {\n return new RegExp('a=ssrc:.*' + srcAttribute + ':', 'g').test(line);\n });\n }).join('\\r\\n');\n}\n\n/**\n * Disable RTX in a given sdp.\n * @param {string} sdp\n * @returns {string} sdp without RTX\n */\nfunction disableRtx(sdp) {\n var mediaSections = getMediaSections(sdp);\n var session = sdp.split('\\r\\nm=')[0];\n return [session].concat(mediaSections.map(function (mediaSection) {\n // Do nothing if the m= section does not represent a video track.\n if (!/^m=video/.test(mediaSection)) {\n return mediaSection;\n }\n\n // Create a map of codecs to payload types.\n var codecsToPts = createCodecMapForMediaSection(mediaSection);\n // Get the RTX payload types.\n var rtxPts = codecsToPts.get('rtx');\n\n // Do nothing if there are no RTX payload types.\n if (!rtxPts) {\n return mediaSection;\n }\n\n // Remove the RTX payload types.\n var pts = new Set(getPayloadTypesInMediaSection(mediaSection));\n rtxPts.forEach(function (rtxPt) {\n return pts.delete(rtxPt);\n });\n\n // Get the RTX SSRC.\n var rtxSSRCMatches = mediaSection.match(/a=ssrc-group:FID [0-9]+ ([0-9]+)/);\n var rtxSSRC = rtxSSRCMatches && rtxSSRCMatches[1];\n\n // Remove the following lines associated with the RTX payload types:\n // 1. \"a=fmtp: apt=\"\n // 2. \"a=rtpmap: rtx/...\"\n // 3. \"a=ssrc: cname:...\"\n // 4. \"a=ssrc-group:FID \"\n var filterRegexes = [/^a=fmtp:.+ apt=.+$/, /^a=rtpmap:.+ rtx\\/.+$/, /^a=ssrc-group:.+$/].concat(rtxSSRC ? [new RegExp('^a=ssrc:' + rtxSSRC + ' .+$')] : []);\n\n mediaSection = mediaSection.split('\\r\\n').filter(function (line) {\n return filterRegexes.every(function (regex) {\n return !regex.test(line);\n });\n }).join('\\r\\n');\n\n // Reconstruct the m= section without the RTX payload types.\n return setPayloadTypesInMediaSection(Array.from(pts), mediaSection);\n })).join('\\r\\n');\n}\n\n/**\n * Generate an a=fmtp: line from the given payload type and attributes.\n * @param {PT} pt\n * @param {*} fmtpAttrs\n * @returns {string}\n */\nfunction generateFmtpLineFromPtAndAttributes(pt, fmtpAttrs) {\n var serializedFmtpAttrs = Object.entries(fmtpAttrs).map(function (_ref6) {\n var _ref7 = _slicedToArray(_ref6, 2),\n name = _ref7[0],\n value = _ref7[1];\n\n return name + '=' + value;\n }).join(';');\n return 'a=fmtp:' + pt + ' ' + serializedFmtpAttrs;\n}\n\n/**\n * Enable DTX for opus in the m= sections for the given MIDs.`\n * @param {string} sdp\n * @param {Array} [mids] - If not specified, enables opus DTX for all\n * audio m= lines.\n * @returns {string}\n */\nfunction enableDtxForOpus(sdp, mids) {\n var mediaSections = getMediaSections(sdp);\n var session = sdp.split('\\r\\nm=')[0];\n\n mids = mids || mediaSections.filter(function (section) {\n return (/^m=audio/.test(section)\n );\n }).map(getMidForMediaSection);\n\n return [session].concat(mediaSections.map(function (section) {\n // Do nothing if the m= section is not audio.\n if (!/^m=audio/.test(section)) {\n return section;\n }\n\n // Build a map codecs to payload types.\n var codecsToPts = createCodecMapForMediaSection(section);\n\n // Do nothing if a payload type for opus does not exist.\n var opusPt = codecsToPts.get('opus');\n if (!opusPt) {\n return section;\n }\n\n // If no fmtp attributes are found for opus, do nothing.\n var opusFmtpAttrs = getFmtpAttributesForPt(opusPt, section);\n if (!opusFmtpAttrs) {\n return section;\n }\n\n // Add usedtx=1 to the a=fmtp: line for opus.\n var origOpusFmtpLine = generateFmtpLineFromPtAndAttributes(opusPt, opusFmtpAttrs);\n var origOpusFmtpRegex = new RegExp(origOpusFmtpLine);\n\n // If the m= section's MID is in the list of MIDs, then enable dtx. Otherwise disable it.\n var mid = getMidForMediaSection(section);\n if (mids.includes(mid)) {\n opusFmtpAttrs.usedtx = 1;\n } else {\n delete opusFmtpAttrs.usedtx;\n }\n\n var opusFmtpLineWithDtx = generateFmtpLineFromPtAndAttributes(opusPt, opusFmtpAttrs);\n return section.replace(origOpusFmtpRegex, opusFmtpLineWithDtx);\n })).join('\\r\\n');\n}\n\nexports.createCodecMapForMediaSection = createCodecMapForMediaSection;\nexports.createPtToCodecName = createPtToCodecName;\nexports.disableRtx = disableRtx;\nexports.enableDtxForOpus = enableDtxForOpus;\nexports.getMediaSections = getMediaSections;\nexports.removeSSRCAttributes = removeSSRCAttributes;\nexports.revertSimulcastForNonVP8MediaSections = revertSimulcastForNonVP8MediaSections;\nexports.setBitrateParameters = setBitrateParameters;\nexports.setCodecPreferences = setCodecPreferences;\nexports.setSimulcast = setSimulcast;\nexports.unifiedPlanFilterLocalCodecs = unifiedPlanFilterLocalCodecs;\nexports.unifiedPlanAddOrRewriteNewTrackIds = unifiedPlanAddOrRewriteNewTrackIds;\nexports.unifiedPlanAddOrRewriteTrackIds = unifiedPlanAddOrRewriteTrackIds;","/* eslint callback-return:0 */\n'use strict';\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar EventEmitter = require('events');\n\nvar nInstances = 0;\n\nvar MediaSignaling = function (_EventEmitter) {\n _inherits(MediaSignaling, _EventEmitter);\n\n /**\n * Construct a {@link MediaSignaling}.\n * @param {Promise} getReceive\n * @param {string} channel\n */\n function MediaSignaling(getReceiver, channel, options) {\n _classCallCheck(this, MediaSignaling);\n\n var _this = _possibleConstructorReturn(this, (MediaSignaling.__proto__ || Object.getPrototypeOf(MediaSignaling)).call(this));\n\n Object.defineProperties(_this, {\n _instanceId: {\n value: nInstances++\n },\n channel: {\n value: channel\n },\n _log: {\n value: options.log.createLog('default', _this)\n },\n _getReceiver: {\n value: getReceiver\n },\n _receiverPromise: {\n value: null,\n writable: true\n },\n _transport: {\n value: null,\n writable: true\n }\n });\n return _this;\n }\n\n _createClass(MediaSignaling, [{\n key: 'toString',\n value: function toString() {\n return '[MediaSignaling #' + this._instanceId + ':' + this.channel + ']';\n }\n }, {\n key: 'setup',\n value: function setup(id) {\n var _this2 = this;\n\n this._teardown();\n this._log.info('setting up msp transport for id:', id);\n var receiverPromise = this._getReceiver(id).then(function (receiver) {\n if (receiver.kind !== 'data') {\n _this2._log.error('Expected a DataTrackReceiver');\n throw new Error('Expected a DataTrackReceiver');\n }if (_this2._receiverPromise !== receiverPromise) {\n return;\n }\n\n try {\n _this2._transport = receiver.toDataTransport();\n } catch (ex) {\n _this2._log.error('Failed to toDataTransport');\n throw new Error('Failed to toDataTransport');\n }\n _this2.emit('ready', _this2._transport);\n\n receiver.once('close', function () {\n return _this2._teardown();\n });\n });\n this._receiverPromise = receiverPromise;\n }\n }, {\n key: '_teardown',\n value: function _teardown() {\n if (this._transport) {\n this._log.info('Tearing down');\n this._transport = null;\n this._receiverPromise = null;\n this.emit('teardown');\n }\n }\n }, {\n key: 'isSetup',\n get: function get() {\n return !!this._receiverPromise;\n }\n }]);\n\n return MediaSignaling;\n}(EventEmitter);\n\nmodule.exports = MediaSignaling;","//! moment.js\n//! version : 2.29.1\n//! authors : Tim Wood, Iskren Chernev, Moment.js contributors\n//! license : MIT\n//! momentjs.com\n\n;(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.moment = factory()\n}(this, (function () { 'use strict';\n\n var hookCallback;\n\n function hooks() {\n return hookCallback.apply(null, arguments);\n }\n\n // This is done to register the method called with moment()\n // without creating circular dependencies.\n function setHookCallback(callback) {\n hookCallback = callback;\n }\n\n function isArray(input) {\n return (\n input instanceof Array ||\n Object.prototype.toString.call(input) === '[object Array]'\n );\n }\n\n function isObject(input) {\n // IE8 will treat undefined and null as object if it wasn't for\n // input != null\n return (\n input != null &&\n Object.prototype.toString.call(input) === '[object Object]'\n );\n }\n\n function hasOwnProp(a, b) {\n return Object.prototype.hasOwnProperty.call(a, b);\n }\n\n function isObjectEmpty(obj) {\n if (Object.getOwnPropertyNames) {\n return Object.getOwnPropertyNames(obj).length === 0;\n } else {\n var k;\n for (k in obj) {\n if (hasOwnProp(obj, k)) {\n return false;\n }\n }\n return true;\n }\n }\n\n function isUndefined(input) {\n return input === void 0;\n }\n\n function isNumber(input) {\n return (\n typeof input === 'number' ||\n Object.prototype.toString.call(input) === '[object Number]'\n );\n }\n\n function isDate(input) {\n return (\n input instanceof Date ||\n Object.prototype.toString.call(input) === '[object Date]'\n );\n }\n\n function map(arr, fn) {\n var res = [],\n i;\n for (i = 0; i < arr.length; ++i) {\n res.push(fn(arr[i], i));\n }\n return res;\n }\n\n function extend(a, b) {\n for (var i in b) {\n if (hasOwnProp(b, i)) {\n a[i] = b[i];\n }\n }\n\n if (hasOwnProp(b, 'toString')) {\n a.toString = b.toString;\n }\n\n if (hasOwnProp(b, 'valueOf')) {\n a.valueOf = b.valueOf;\n }\n\n return a;\n }\n\n function createUTC(input, format, locale, strict) {\n return createLocalOrUTC(input, format, locale, strict, true).utc();\n }\n\n function defaultParsingFlags() {\n // We need to deep clone this object.\n return {\n empty: false,\n unusedTokens: [],\n unusedInput: [],\n overflow: -2,\n charsLeftOver: 0,\n nullInput: false,\n invalidEra: null,\n invalidMonth: null,\n invalidFormat: false,\n userInvalidated: false,\n iso: false,\n parsedDateParts: [],\n era: null,\n meridiem: null,\n rfc2822: false,\n weekdayMismatch: false,\n };\n }\n\n function getParsingFlags(m) {\n if (m._pf == null) {\n m._pf = defaultParsingFlags();\n }\n return m._pf;\n }\n\n var some;\n if (Array.prototype.some) {\n some = Array.prototype.some;\n } else {\n some = function (fun) {\n var t = Object(this),\n len = t.length >>> 0,\n i;\n\n for (i = 0; i < len; i++) {\n if (i in t && fun.call(this, t[i], i, t)) {\n return true;\n }\n }\n\n return false;\n };\n }\n\n function isValid(m) {\n if (m._isValid == null) {\n var flags = getParsingFlags(m),\n parsedParts = some.call(flags.parsedDateParts, function (i) {\n return i != null;\n }),\n isNowValid =\n !isNaN(m._d.getTime()) &&\n flags.overflow < 0 &&\n !flags.empty &&\n !flags.invalidEra &&\n !flags.invalidMonth &&\n !flags.invalidWeekday &&\n !flags.weekdayMismatch &&\n !flags.nullInput &&\n !flags.invalidFormat &&\n !flags.userInvalidated &&\n (!flags.meridiem || (flags.meridiem && parsedParts));\n\n if (m._strict) {\n isNowValid =\n isNowValid &&\n flags.charsLeftOver === 0 &&\n flags.unusedTokens.length === 0 &&\n flags.bigHour === undefined;\n }\n\n if (Object.isFrozen == null || !Object.isFrozen(m)) {\n m._isValid = isNowValid;\n } else {\n return isNowValid;\n }\n }\n return m._isValid;\n }\n\n function createInvalid(flags) {\n var m = createUTC(NaN);\n if (flags != null) {\n extend(getParsingFlags(m), flags);\n } else {\n getParsingFlags(m).userInvalidated = true;\n }\n\n return m;\n }\n\n // Plugins that add properties should also add the key here (null value),\n // so we can properly clone ourselves.\n var momentProperties = (hooks.momentProperties = []),\n updateInProgress = false;\n\n function copyConfig(to, from) {\n var i, prop, val;\n\n if (!isUndefined(from._isAMomentObject)) {\n to._isAMomentObject = from._isAMomentObject;\n }\n if (!isUndefined(from._i)) {\n to._i = from._i;\n }\n if (!isUndefined(from._f)) {\n to._f = from._f;\n }\n if (!isUndefined(from._l)) {\n to._l = from._l;\n }\n if (!isUndefined(from._strict)) {\n to._strict = from._strict;\n }\n if (!isUndefined(from._tzm)) {\n to._tzm = from._tzm;\n }\n if (!isUndefined(from._isUTC)) {\n to._isUTC = from._isUTC;\n }\n if (!isUndefined(from._offset)) {\n to._offset = from._offset;\n }\n if (!isUndefined(from._pf)) {\n to._pf = getParsingFlags(from);\n }\n if (!isUndefined(from._locale)) {\n to._locale = from._locale;\n }\n\n if (momentProperties.length > 0) {\n for (i = 0; i < momentProperties.length; i++) {\n prop = momentProperties[i];\n val = from[prop];\n if (!isUndefined(val)) {\n to[prop] = val;\n }\n }\n }\n\n return to;\n }\n\n // Moment prototype object\n function Moment(config) {\n copyConfig(this, config);\n this._d = new Date(config._d != null ? config._d.getTime() : NaN);\n if (!this.isValid()) {\n this._d = new Date(NaN);\n }\n // Prevent infinite loop in case updateOffset creates new moment\n // objects.\n if (updateInProgress === false) {\n updateInProgress = true;\n hooks.updateOffset(this);\n updateInProgress = false;\n }\n }\n\n function isMoment(obj) {\n return (\n obj instanceof Moment || (obj != null && obj._isAMomentObject != null)\n );\n }\n\n function warn(msg) {\n if (\n hooks.suppressDeprecationWarnings === false &&\n typeof console !== 'undefined' &&\n console.warn\n ) {\n console.warn('Deprecation warning: ' + msg);\n }\n }\n\n function deprecate(msg, fn) {\n var firstTime = true;\n\n return extend(function () {\n if (hooks.deprecationHandler != null) {\n hooks.deprecationHandler(null, msg);\n }\n if (firstTime) {\n var args = [],\n arg,\n i,\n key;\n for (i = 0; i < arguments.length; i++) {\n arg = '';\n if (typeof arguments[i] === 'object') {\n arg += '\\n[' + i + '] ';\n for (key in arguments[0]) {\n if (hasOwnProp(arguments[0], key)) {\n arg += key + ': ' + arguments[0][key] + ', ';\n }\n }\n arg = arg.slice(0, -2); // Remove trailing comma and space\n } else {\n arg = arguments[i];\n }\n args.push(arg);\n }\n warn(\n msg +\n '\\nArguments: ' +\n Array.prototype.slice.call(args).join('') +\n '\\n' +\n new Error().stack\n );\n firstTime = false;\n }\n return fn.apply(this, arguments);\n }, fn);\n }\n\n var deprecations = {};\n\n function deprecateSimple(name, msg) {\n if (hooks.deprecationHandler != null) {\n hooks.deprecationHandler(name, msg);\n }\n if (!deprecations[name]) {\n warn(msg);\n deprecations[name] = true;\n }\n }\n\n hooks.suppressDeprecationWarnings = false;\n hooks.deprecationHandler = null;\n\n function isFunction(input) {\n return (\n (typeof Function !== 'undefined' && input instanceof Function) ||\n Object.prototype.toString.call(input) === '[object Function]'\n );\n }\n\n function set(config) {\n var prop, i;\n for (i in config) {\n if (hasOwnProp(config, i)) {\n prop = config[i];\n if (isFunction(prop)) {\n this[i] = prop;\n } else {\n this['_' + i] = prop;\n }\n }\n }\n this._config = config;\n // Lenient ordinal parsing accepts just a number in addition to\n // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.\n // TODO: Remove \"ordinalParse\" fallback in next major release.\n this._dayOfMonthOrdinalParseLenient = new RegExp(\n (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +\n '|' +\n /\\d{1,2}/.source\n );\n }\n\n function mergeConfigs(parentConfig, childConfig) {\n var res = extend({}, parentConfig),\n prop;\n for (prop in childConfig) {\n if (hasOwnProp(childConfig, prop)) {\n if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {\n res[prop] = {};\n extend(res[prop], parentConfig[prop]);\n extend(res[prop], childConfig[prop]);\n } else if (childConfig[prop] != null) {\n res[prop] = childConfig[prop];\n } else {\n delete res[prop];\n }\n }\n }\n for (prop in parentConfig) {\n if (\n hasOwnProp(parentConfig, prop) &&\n !hasOwnProp(childConfig, prop) &&\n isObject(parentConfig[prop])\n ) {\n // make sure changes to properties don't modify parent config\n res[prop] = extend({}, res[prop]);\n }\n }\n return res;\n }\n\n function Locale(config) {\n if (config != null) {\n this.set(config);\n }\n }\n\n var keys;\n\n if (Object.keys) {\n keys = Object.keys;\n } else {\n keys = function (obj) {\n var i,\n res = [];\n for (i in obj) {\n if (hasOwnProp(obj, i)) {\n res.push(i);\n }\n }\n return res;\n };\n }\n\n var defaultCalendar = {\n sameDay: '[Today at] LT',\n nextDay: '[Tomorrow at] LT',\n nextWeek: 'dddd [at] LT',\n lastDay: '[Yesterday at] LT',\n lastWeek: '[Last] dddd [at] LT',\n sameElse: 'L',\n };\n\n function calendar(key, mom, now) {\n var output = this._calendar[key] || this._calendar['sameElse'];\n return isFunction(output) ? output.call(mom, now) : output;\n }\n\n function zeroFill(number, targetLength, forceSign) {\n var absNumber = '' + Math.abs(number),\n zerosToFill = targetLength - absNumber.length,\n sign = number >= 0;\n return (\n (sign ? (forceSign ? '+' : '') : '-') +\n Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +\n absNumber\n );\n }\n\n var formattingTokens = /(\\[[^\\[]*\\])|(\\\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,\n localFormattingTokens = /(\\[[^\\[]*\\])|(\\\\)?(LTS|LT|LL?L?L?|l{1,4})/g,\n formatFunctions = {},\n formatTokenFunctions = {};\n\n // token: 'M'\n // padded: ['MM', 2]\n // ordinal: 'Mo'\n // callback: function () { this.month() + 1 }\n function addFormatToken(token, padded, ordinal, callback) {\n var func = callback;\n if (typeof callback === 'string') {\n func = function () {\n return this[callback]();\n };\n }\n if (token) {\n formatTokenFunctions[token] = func;\n }\n if (padded) {\n formatTokenFunctions[padded[0]] = function () {\n return zeroFill(func.apply(this, arguments), padded[1], padded[2]);\n };\n }\n if (ordinal) {\n formatTokenFunctions[ordinal] = function () {\n return this.localeData().ordinal(\n func.apply(this, arguments),\n token\n );\n };\n }\n }\n\n function removeFormattingTokens(input) {\n if (input.match(/\\[[\\s\\S]/)) {\n return input.replace(/^\\[|\\]$/g, '');\n }\n return input.replace(/\\\\/g, '');\n }\n\n function makeFormatFunction(format) {\n var array = format.match(formattingTokens),\n i,\n length;\n\n for (i = 0, length = array.length; i < length; i++) {\n if (formatTokenFunctions[array[i]]) {\n array[i] = formatTokenFunctions[array[i]];\n } else {\n array[i] = removeFormattingTokens(array[i]);\n }\n }\n\n return function (mom) {\n var output = '',\n i;\n for (i = 0; i < length; i++) {\n output += isFunction(array[i])\n ? array[i].call(mom, format)\n : array[i];\n }\n return output;\n };\n }\n\n // format date using native date object\n function formatMoment(m, format) {\n if (!m.isValid()) {\n return m.localeData().invalidDate();\n }\n\n format = expandFormat(format, m.localeData());\n formatFunctions[format] =\n formatFunctions[format] || makeFormatFunction(format);\n\n return formatFunctions[format](m);\n }\n\n function expandFormat(format, locale) {\n var i = 5;\n\n function replaceLongDateFormatTokens(input) {\n return locale.longDateFormat(input) || input;\n }\n\n localFormattingTokens.lastIndex = 0;\n while (i >= 0 && localFormattingTokens.test(format)) {\n format = format.replace(\n localFormattingTokens,\n replaceLongDateFormatTokens\n );\n localFormattingTokens.lastIndex = 0;\n i -= 1;\n }\n\n return format;\n }\n\n var defaultLongDateFormat = {\n LTS: 'h:mm:ss A',\n LT: 'h:mm A',\n L: 'MM/DD/YYYY',\n LL: 'MMMM D, YYYY',\n LLL: 'MMMM D, YYYY h:mm A',\n LLLL: 'dddd, MMMM D, YYYY h:mm A',\n };\n\n function longDateFormat(key) {\n var format = this._longDateFormat[key],\n formatUpper = this._longDateFormat[key.toUpperCase()];\n\n if (format || !formatUpper) {\n return format;\n }\n\n this._longDateFormat[key] = formatUpper\n .match(formattingTokens)\n .map(function (tok) {\n if (\n tok === 'MMMM' ||\n tok === 'MM' ||\n tok === 'DD' ||\n tok === 'dddd'\n ) {\n return tok.slice(1);\n }\n return tok;\n })\n .join('');\n\n return this._longDateFormat[key];\n }\n\n var defaultInvalidDate = 'Invalid date';\n\n function invalidDate() {\n return this._invalidDate;\n }\n\n var defaultOrdinal = '%d',\n defaultDayOfMonthOrdinalParse = /\\d{1,2}/;\n\n function ordinal(number) {\n return this._ordinal.replace('%d', number);\n }\n\n var defaultRelativeTime = {\n future: 'in %s',\n past: '%s ago',\n s: 'a few seconds',\n ss: '%d seconds',\n m: 'a minute',\n mm: '%d minutes',\n h: 'an hour',\n hh: '%d hours',\n d: 'a day',\n dd: '%d days',\n w: 'a week',\n ww: '%d weeks',\n M: 'a month',\n MM: '%d months',\n y: 'a year',\n yy: '%d years',\n };\n\n function relativeTime(number, withoutSuffix, string, isFuture) {\n var output = this._relativeTime[string];\n return isFunction(output)\n ? output(number, withoutSuffix, string, isFuture)\n : output.replace(/%d/i, number);\n }\n\n function pastFuture(diff, output) {\n var format = this._relativeTime[diff > 0 ? 'future' : 'past'];\n return isFunction(format) ? format(output) : format.replace(/%s/i, output);\n }\n\n var aliases = {};\n\n function addUnitAlias(unit, shorthand) {\n var lowerCase = unit.toLowerCase();\n aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;\n }\n\n function normalizeUnits(units) {\n return typeof units === 'string'\n ? aliases[units] || aliases[units.toLowerCase()]\n : undefined;\n }\n\n function normalizeObjectUnits(inputObject) {\n var normalizedInput = {},\n normalizedProp,\n prop;\n\n for (prop in inputObject) {\n if (hasOwnProp(inputObject, prop)) {\n normalizedProp = normalizeUnits(prop);\n if (normalizedProp) {\n normalizedInput[normalizedProp] = inputObject[prop];\n }\n }\n }\n\n return normalizedInput;\n }\n\n var priorities = {};\n\n function addUnitPriority(unit, priority) {\n priorities[unit] = priority;\n }\n\n function getPrioritizedUnits(unitsObj) {\n var units = [],\n u;\n for (u in unitsObj) {\n if (hasOwnProp(unitsObj, u)) {\n units.push({ unit: u, priority: priorities[u] });\n }\n }\n units.sort(function (a, b) {\n return a.priority - b.priority;\n });\n return units;\n }\n\n function isLeapYear(year) {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n }\n\n function absFloor(number) {\n if (number < 0) {\n // -0 -> 0\n return Math.ceil(number) || 0;\n } else {\n return Math.floor(number);\n }\n }\n\n function toInt(argumentForCoercion) {\n var coercedNumber = +argumentForCoercion,\n value = 0;\n\n if (coercedNumber !== 0 && isFinite(coercedNumber)) {\n value = absFloor(coercedNumber);\n }\n\n return value;\n }\n\n function makeGetSet(unit, keepTime) {\n return function (value) {\n if (value != null) {\n set$1(this, unit, value);\n hooks.updateOffset(this, keepTime);\n return this;\n } else {\n return get(this, unit);\n }\n };\n }\n\n function get(mom, unit) {\n return mom.isValid()\n ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()\n : NaN;\n }\n\n function set$1(mom, unit, value) {\n if (mom.isValid() && !isNaN(value)) {\n if (\n unit === 'FullYear' &&\n isLeapYear(mom.year()) &&\n mom.month() === 1 &&\n mom.date() === 29\n ) {\n value = toInt(value);\n mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](\n value,\n mom.month(),\n daysInMonth(value, mom.month())\n );\n } else {\n mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);\n }\n }\n }\n\n // MOMENTS\n\n function stringGet(units) {\n units = normalizeUnits(units);\n if (isFunction(this[units])) {\n return this[units]();\n }\n return this;\n }\n\n function stringSet(units, value) {\n if (typeof units === 'object') {\n units = normalizeObjectUnits(units);\n var prioritized = getPrioritizedUnits(units),\n i;\n for (i = 0; i < prioritized.length; i++) {\n this[prioritized[i].unit](units[prioritized[i].unit]);\n }\n } else {\n units = normalizeUnits(units);\n if (isFunction(this[units])) {\n return this[units](value);\n }\n }\n return this;\n }\n\n var match1 = /\\d/, // 0 - 9\n match2 = /\\d\\d/, // 00 - 99\n match3 = /\\d{3}/, // 000 - 999\n match4 = /\\d{4}/, // 0000 - 9999\n match6 = /[+-]?\\d{6}/, // -999999 - 999999\n match1to2 = /\\d\\d?/, // 0 - 99\n match3to4 = /\\d\\d\\d\\d?/, // 999 - 9999\n match5to6 = /\\d\\d\\d\\d\\d\\d?/, // 99999 - 999999\n match1to3 = /\\d{1,3}/, // 0 - 999\n match1to4 = /\\d{1,4}/, // 0 - 9999\n match1to6 = /[+-]?\\d{1,6}/, // -999999 - 999999\n matchUnsigned = /\\d+/, // 0 - inf\n matchSigned = /[+-]?\\d+/, // -inf - inf\n matchOffset = /Z|[+-]\\d\\d:?\\d\\d/gi, // +00:00 -00:00 +0000 -0000 or Z\n matchShortOffset = /Z|[+-]\\d\\d(?::?\\d\\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z\n matchTimestamp = /[+-]?\\d+(\\.\\d{1,3})?/, // 123456789 123456789.123\n // any word (or two) characters or numbers including two/three word month in arabic.\n // includes scottish gaelic two word and hyphenated months\n matchWord = /[0-9]{0,256}['a-z\\u00A0-\\u05FF\\u0700-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFF07\\uFF10-\\uFFEF]{1,256}|[\\u0600-\\u06FF\\/]{1,256}(\\s*?[\\u0600-\\u06FF]{1,256}){1,2}/i,\n regexes;\n\n regexes = {};\n\n function addRegexToken(token, regex, strictRegex) {\n regexes[token] = isFunction(regex)\n ? regex\n : function (isStrict, localeData) {\n return isStrict && strictRegex ? strictRegex : regex;\n };\n }\n\n function getParseRegexForToken(token, config) {\n if (!hasOwnProp(regexes, token)) {\n return new RegExp(unescapeFormat(token));\n }\n\n return regexes[token](config._strict, config._locale);\n }\n\n // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript\n function unescapeFormat(s) {\n return regexEscape(\n s\n .replace('\\\\', '')\n .replace(/\\\\(\\[)|\\\\(\\])|\\[([^\\]\\[]*)\\]|\\\\(.)/g, function (\n matched,\n p1,\n p2,\n p3,\n p4\n ) {\n return p1 || p2 || p3 || p4;\n })\n );\n }\n\n function regexEscape(s) {\n return s.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n }\n\n var tokens = {};\n\n function addParseToken(token, callback) {\n var i,\n func = callback;\n if (typeof token === 'string') {\n token = [token];\n }\n if (isNumber(callback)) {\n func = function (input, array) {\n array[callback] = toInt(input);\n };\n }\n for (i = 0; i < token.length; i++) {\n tokens[token[i]] = func;\n }\n }\n\n function addWeekParseToken(token, callback) {\n addParseToken(token, function (input, array, config, token) {\n config._w = config._w || {};\n callback(input, config._w, config, token);\n });\n }\n\n function addTimeToArrayFromToken(token, input, config) {\n if (input != null && hasOwnProp(tokens, token)) {\n tokens[token](input, config._a, config, token);\n }\n }\n\n var YEAR = 0,\n MONTH = 1,\n DATE = 2,\n HOUR = 3,\n MINUTE = 4,\n SECOND = 5,\n MILLISECOND = 6,\n WEEK = 7,\n WEEKDAY = 8;\n\n function mod(n, x) {\n return ((n % x) + x) % x;\n }\n\n var indexOf;\n\n if (Array.prototype.indexOf) {\n indexOf = Array.prototype.indexOf;\n } else {\n indexOf = function (o) {\n // I know\n var i;\n for (i = 0; i < this.length; ++i) {\n if (this[i] === o) {\n return i;\n }\n }\n return -1;\n };\n }\n\n function daysInMonth(year, month) {\n if (isNaN(year) || isNaN(month)) {\n return NaN;\n }\n var modMonth = mod(month, 12);\n year += (month - modMonth) / 12;\n return modMonth === 1\n ? isLeapYear(year)\n ? 29\n : 28\n : 31 - ((modMonth % 7) % 2);\n }\n\n // FORMATTING\n\n addFormatToken('M', ['MM', 2], 'Mo', function () {\n return this.month() + 1;\n });\n\n addFormatToken('MMM', 0, 0, function (format) {\n return this.localeData().monthsShort(this, format);\n });\n\n addFormatToken('MMMM', 0, 0, function (format) {\n return this.localeData().months(this, format);\n });\n\n // ALIASES\n\n addUnitAlias('month', 'M');\n\n // PRIORITY\n\n addUnitPriority('month', 8);\n\n // PARSING\n\n addRegexToken('M', match1to2);\n addRegexToken('MM', match1to2, match2);\n addRegexToken('MMM', function (isStrict, locale) {\n return locale.monthsShortRegex(isStrict);\n });\n addRegexToken('MMMM', function (isStrict, locale) {\n return locale.monthsRegex(isStrict);\n });\n\n addParseToken(['M', 'MM'], function (input, array) {\n array[MONTH] = toInt(input) - 1;\n });\n\n addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {\n var month = config._locale.monthsParse(input, token, config._strict);\n // if we didn't find a month name, mark the date as invalid.\n if (month != null) {\n array[MONTH] = month;\n } else {\n getParsingFlags(config).invalidMonth = input;\n }\n });\n\n // LOCALES\n\n var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split(\n '_'\n ),\n defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split(\n '_'\n ),\n MONTHS_IN_FORMAT = /D[oD]?(\\[[^\\[\\]]*\\]|\\s)+MMMM?/,\n defaultMonthsShortRegex = matchWord,\n defaultMonthsRegex = matchWord;\n\n function localeMonths(m, format) {\n if (!m) {\n return isArray(this._months)\n ? this._months\n : this._months['standalone'];\n }\n return isArray(this._months)\n ? this._months[m.month()]\n : this._months[\n (this._months.isFormat || MONTHS_IN_FORMAT).test(format)\n ? 'format'\n : 'standalone'\n ][m.month()];\n }\n\n function localeMonthsShort(m, format) {\n if (!m) {\n return isArray(this._monthsShort)\n ? this._monthsShort\n : this._monthsShort['standalone'];\n }\n return isArray(this._monthsShort)\n ? this._monthsShort[m.month()]\n : this._monthsShort[\n MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'\n ][m.month()];\n }\n\n function handleStrictParse(monthName, format, strict) {\n var i,\n ii,\n mom,\n llc = monthName.toLocaleLowerCase();\n if (!this._monthsParse) {\n // this is not used\n this._monthsParse = [];\n this._longMonthsParse = [];\n this._shortMonthsParse = [];\n for (i = 0; i < 12; ++i) {\n mom = createUTC([2000, i]);\n this._shortMonthsParse[i] = this.monthsShort(\n mom,\n ''\n ).toLocaleLowerCase();\n this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();\n }\n }\n\n if (strict) {\n if (format === 'MMM') {\n ii = indexOf.call(this._shortMonthsParse, llc);\n return ii !== -1 ? ii : null;\n } else {\n ii = indexOf.call(this._longMonthsParse, llc);\n return ii !== -1 ? ii : null;\n }\n } else {\n if (format === 'MMM') {\n ii = indexOf.call(this._shortMonthsParse, llc);\n if (ii !== -1) {\n return ii;\n }\n ii = indexOf.call(this._longMonthsParse, llc);\n return ii !== -1 ? ii : null;\n } else {\n ii = indexOf.call(this._longMonthsParse, llc);\n if (ii !== -1) {\n return ii;\n }\n ii = indexOf.call(this._shortMonthsParse, llc);\n return ii !== -1 ? ii : null;\n }\n }\n }\n\n function localeMonthsParse(monthName, format, strict) {\n var i, mom, regex;\n\n if (this._monthsParseExact) {\n return handleStrictParse.call(this, monthName, format, strict);\n }\n\n if (!this._monthsParse) {\n this._monthsParse = [];\n this._longMonthsParse = [];\n this._shortMonthsParse = [];\n }\n\n // TODO: add sorting\n // Sorting makes sure if one month (or abbr) is a prefix of another\n // see sorting in computeMonthsParse\n for (i = 0; i < 12; i++) {\n // make the regex if we don't have it already\n mom = createUTC([2000, i]);\n if (strict && !this._longMonthsParse[i]) {\n this._longMonthsParse[i] = new RegExp(\n '^' + this.months(mom, '').replace('.', '') + '$',\n 'i'\n );\n this._shortMonthsParse[i] = new RegExp(\n '^' + this.monthsShort(mom, '').replace('.', '') + '$',\n 'i'\n );\n }\n if (!strict && !this._monthsParse[i]) {\n regex =\n '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');\n this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');\n }\n // test the regex\n if (\n strict &&\n format === 'MMMM' &&\n this._longMonthsParse[i].test(monthName)\n ) {\n return i;\n } else if (\n strict &&\n format === 'MMM' &&\n this._shortMonthsParse[i].test(monthName)\n ) {\n return i;\n } else if (!strict && this._monthsParse[i].test(monthName)) {\n return i;\n }\n }\n }\n\n // MOMENTS\n\n function setMonth(mom, value) {\n var dayOfMonth;\n\n if (!mom.isValid()) {\n // No op\n return mom;\n }\n\n if (typeof value === 'string') {\n if (/^\\d+$/.test(value)) {\n value = toInt(value);\n } else {\n value = mom.localeData().monthsParse(value);\n // TODO: Another silent failure?\n if (!isNumber(value)) {\n return mom;\n }\n }\n }\n\n dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));\n mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);\n return mom;\n }\n\n function getSetMonth(value) {\n if (value != null) {\n setMonth(this, value);\n hooks.updateOffset(this, true);\n return this;\n } else {\n return get(this, 'Month');\n }\n }\n\n function getDaysInMonth() {\n return daysInMonth(this.year(), this.month());\n }\n\n function monthsShortRegex(isStrict) {\n if (this._monthsParseExact) {\n if (!hasOwnProp(this, '_monthsRegex')) {\n computeMonthsParse.call(this);\n }\n if (isStrict) {\n return this._monthsShortStrictRegex;\n } else {\n return this._monthsShortRegex;\n }\n } else {\n if (!hasOwnProp(this, '_monthsShortRegex')) {\n this._monthsShortRegex = defaultMonthsShortRegex;\n }\n return this._monthsShortStrictRegex && isStrict\n ? this._monthsShortStrictRegex\n : this._monthsShortRegex;\n }\n }\n\n function monthsRegex(isStrict) {\n if (this._monthsParseExact) {\n if (!hasOwnProp(this, '_monthsRegex')) {\n computeMonthsParse.call(this);\n }\n if (isStrict) {\n return this._monthsStrictRegex;\n } else {\n return this._monthsRegex;\n }\n } else {\n if (!hasOwnProp(this, '_monthsRegex')) {\n this._monthsRegex = defaultMonthsRegex;\n }\n return this._monthsStrictRegex && isStrict\n ? this._monthsStrictRegex\n : this._monthsRegex;\n }\n }\n\n function computeMonthsParse() {\n function cmpLenRev(a, b) {\n return b.length - a.length;\n }\n\n var shortPieces = [],\n longPieces = [],\n mixedPieces = [],\n i,\n mom;\n for (i = 0; i < 12; i++) {\n // make the regex if we don't have it already\n mom = createUTC([2000, i]);\n shortPieces.push(this.monthsShort(mom, ''));\n longPieces.push(this.months(mom, ''));\n mixedPieces.push(this.months(mom, ''));\n mixedPieces.push(this.monthsShort(mom, ''));\n }\n // Sorting makes sure if one month (or abbr) is a prefix of another it\n // will match the longer piece.\n shortPieces.sort(cmpLenRev);\n longPieces.sort(cmpLenRev);\n mixedPieces.sort(cmpLenRev);\n for (i = 0; i < 12; i++) {\n shortPieces[i] = regexEscape(shortPieces[i]);\n longPieces[i] = regexEscape(longPieces[i]);\n }\n for (i = 0; i < 24; i++) {\n mixedPieces[i] = regexEscape(mixedPieces[i]);\n }\n\n this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');\n this._monthsShortRegex = this._monthsRegex;\n this._monthsStrictRegex = new RegExp(\n '^(' + longPieces.join('|') + ')',\n 'i'\n );\n this._monthsShortStrictRegex = new RegExp(\n '^(' + shortPieces.join('|') + ')',\n 'i'\n );\n }\n\n // FORMATTING\n\n addFormatToken('Y', 0, 0, function () {\n var y = this.year();\n return y <= 9999 ? zeroFill(y, 4) : '+' + y;\n });\n\n addFormatToken(0, ['YY', 2], 0, function () {\n return this.year() % 100;\n });\n\n addFormatToken(0, ['YYYY', 4], 0, 'year');\n addFormatToken(0, ['YYYYY', 5], 0, 'year');\n addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');\n\n // ALIASES\n\n addUnitAlias('year', 'y');\n\n // PRIORITIES\n\n addUnitPriority('year', 1);\n\n // PARSING\n\n addRegexToken('Y', matchSigned);\n addRegexToken('YY', match1to2, match2);\n addRegexToken('YYYY', match1to4, match4);\n addRegexToken('YYYYY', match1to6, match6);\n addRegexToken('YYYYYY', match1to6, match6);\n\n addParseToken(['YYYYY', 'YYYYYY'], YEAR);\n addParseToken('YYYY', function (input, array) {\n array[YEAR] =\n input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);\n });\n addParseToken('YY', function (input, array) {\n array[YEAR] = hooks.parseTwoDigitYear(input);\n });\n addParseToken('Y', function (input, array) {\n array[YEAR] = parseInt(input, 10);\n });\n\n // HELPERS\n\n function daysInYear(year) {\n return isLeapYear(year) ? 366 : 365;\n }\n\n // HOOKS\n\n hooks.parseTwoDigitYear = function (input) {\n return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);\n };\n\n // MOMENTS\n\n var getSetYear = makeGetSet('FullYear', true);\n\n function getIsLeapYear() {\n return isLeapYear(this.year());\n }\n\n function createDate(y, m, d, h, M, s, ms) {\n // can't just apply() to create a date:\n // https://stackoverflow.com/q/181348\n var date;\n // the date constructor remaps years 0-99 to 1900-1999\n if (y < 100 && y >= 0) {\n // preserve leap years using a full 400 year cycle, then reset\n date = new Date(y + 400, m, d, h, M, s, ms);\n if (isFinite(date.getFullYear())) {\n date.setFullYear(y);\n }\n } else {\n date = new Date(y, m, d, h, M, s, ms);\n }\n\n return date;\n }\n\n function createUTCDate(y) {\n var date, args;\n // the Date.UTC function remaps years 0-99 to 1900-1999\n if (y < 100 && y >= 0) {\n args = Array.prototype.slice.call(arguments);\n // preserve leap years using a full 400 year cycle, then reset\n args[0] = y + 400;\n date = new Date(Date.UTC.apply(null, args));\n if (isFinite(date.getUTCFullYear())) {\n date.setUTCFullYear(y);\n }\n } else {\n date = new Date(Date.UTC.apply(null, arguments));\n }\n\n return date;\n }\n\n // start-of-first-week - start-of-year\n function firstWeekOffset(year, dow, doy) {\n var // first-week day -- which january is always in the first week (4 for iso, 1 for other)\n fwd = 7 + dow - doy,\n // first-week day local weekday -- which local weekday is fwd\n fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;\n\n return -fwdlw + fwd - 1;\n }\n\n // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday\n function dayOfYearFromWeeks(year, week, weekday, dow, doy) {\n var localWeekday = (7 + weekday - dow) % 7,\n weekOffset = firstWeekOffset(year, dow, doy),\n dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,\n resYear,\n resDayOfYear;\n\n if (dayOfYear <= 0) {\n resYear = year - 1;\n resDayOfYear = daysInYear(resYear) + dayOfYear;\n } else if (dayOfYear > daysInYear(year)) {\n resYear = year + 1;\n resDayOfYear = dayOfYear - daysInYear(year);\n } else {\n resYear = year;\n resDayOfYear = dayOfYear;\n }\n\n return {\n year: resYear,\n dayOfYear: resDayOfYear,\n };\n }\n\n function weekOfYear(mom, dow, doy) {\n var weekOffset = firstWeekOffset(mom.year(), dow, doy),\n week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,\n resWeek,\n resYear;\n\n if (week < 1) {\n resYear = mom.year() - 1;\n resWeek = week + weeksInYear(resYear, dow, doy);\n } else if (week > weeksInYear(mom.year(), dow, doy)) {\n resWeek = week - weeksInYear(mom.year(), dow, doy);\n resYear = mom.year() + 1;\n } else {\n resYear = mom.year();\n resWeek = week;\n }\n\n return {\n week: resWeek,\n year: resYear,\n };\n }\n\n function weeksInYear(year, dow, doy) {\n var weekOffset = firstWeekOffset(year, dow, doy),\n weekOffsetNext = firstWeekOffset(year + 1, dow, doy);\n return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;\n }\n\n // FORMATTING\n\n addFormatToken('w', ['ww', 2], 'wo', 'week');\n addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');\n\n // ALIASES\n\n addUnitAlias('week', 'w');\n addUnitAlias('isoWeek', 'W');\n\n // PRIORITIES\n\n addUnitPriority('week', 5);\n addUnitPriority('isoWeek', 5);\n\n // PARSING\n\n addRegexToken('w', match1to2);\n addRegexToken('ww', match1to2, match2);\n addRegexToken('W', match1to2);\n addRegexToken('WW', match1to2, match2);\n\n addWeekParseToken(['w', 'ww', 'W', 'WW'], function (\n input,\n week,\n config,\n token\n ) {\n week[token.substr(0, 1)] = toInt(input);\n });\n\n // HELPERS\n\n // LOCALES\n\n function localeWeek(mom) {\n return weekOfYear(mom, this._week.dow, this._week.doy).week;\n }\n\n var defaultLocaleWeek = {\n dow: 0, // Sunday is the first day of the week.\n doy: 6, // The week that contains Jan 6th is the first week of the year.\n };\n\n function localeFirstDayOfWeek() {\n return this._week.dow;\n }\n\n function localeFirstDayOfYear() {\n return this._week.doy;\n }\n\n // MOMENTS\n\n function getSetWeek(input) {\n var week = this.localeData().week(this);\n return input == null ? week : this.add((input - week) * 7, 'd');\n }\n\n function getSetISOWeek(input) {\n var week = weekOfYear(this, 1, 4).week;\n return input == null ? week : this.add((input - week) * 7, 'd');\n }\n\n // FORMATTING\n\n addFormatToken('d', 0, 'do', 'day');\n\n addFormatToken('dd', 0, 0, function (format) {\n return this.localeData().weekdaysMin(this, format);\n });\n\n addFormatToken('ddd', 0, 0, function (format) {\n return this.localeData().weekdaysShort(this, format);\n });\n\n addFormatToken('dddd', 0, 0, function (format) {\n return this.localeData().weekdays(this, format);\n });\n\n addFormatToken('e', 0, 0, 'weekday');\n addFormatToken('E', 0, 0, 'isoWeekday');\n\n // ALIASES\n\n addUnitAlias('day', 'd');\n addUnitAlias('weekday', 'e');\n addUnitAlias('isoWeekday', 'E');\n\n // PRIORITY\n addUnitPriority('day', 11);\n addUnitPriority('weekday', 11);\n addUnitPriority('isoWeekday', 11);\n\n // PARSING\n\n addRegexToken('d', match1to2);\n addRegexToken('e', match1to2);\n addRegexToken('E', match1to2);\n addRegexToken('dd', function (isStrict, locale) {\n return locale.weekdaysMinRegex(isStrict);\n });\n addRegexToken('ddd', function (isStrict, locale) {\n return locale.weekdaysShortRegex(isStrict);\n });\n addRegexToken('dddd', function (isStrict, locale) {\n return locale.weekdaysRegex(isStrict);\n });\n\n addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {\n var weekday = config._locale.weekdaysParse(input, token, config._strict);\n // if we didn't get a weekday name, mark the date as invalid\n if (weekday != null) {\n week.d = weekday;\n } else {\n getParsingFlags(config).invalidWeekday = input;\n }\n });\n\n addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {\n week[token] = toInt(input);\n });\n\n // HELPERS\n\n function parseWeekday(input, locale) {\n if (typeof input !== 'string') {\n return input;\n }\n\n if (!isNaN(input)) {\n return parseInt(input, 10);\n }\n\n input = locale.weekdaysParse(input);\n if (typeof input === 'number') {\n return input;\n }\n\n return null;\n }\n\n function parseIsoWeekday(input, locale) {\n if (typeof input === 'string') {\n return locale.weekdaysParse(input) % 7 || 7;\n }\n return isNaN(input) ? null : input;\n }\n\n // LOCALES\n function shiftWeekdays(ws, n) {\n return ws.slice(n, 7).concat(ws.slice(0, n));\n }\n\n var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split(\n '_'\n ),\n defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),\n defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),\n defaultWeekdaysRegex = matchWord,\n defaultWeekdaysShortRegex = matchWord,\n defaultWeekdaysMinRegex = matchWord;\n\n function localeWeekdays(m, format) {\n var weekdays = isArray(this._weekdays)\n ? this._weekdays\n : this._weekdays[\n m && m !== true && this._weekdays.isFormat.test(format)\n ? 'format'\n : 'standalone'\n ];\n return m === true\n ? shiftWeekdays(weekdays, this._week.dow)\n : m\n ? weekdays[m.day()]\n : weekdays;\n }\n\n function localeWeekdaysShort(m) {\n return m === true\n ? shiftWeekdays(this._weekdaysShort, this._week.dow)\n : m\n ? this._weekdaysShort[m.day()]\n : this._weekdaysShort;\n }\n\n function localeWeekdaysMin(m) {\n return m === true\n ? shiftWeekdays(this._weekdaysMin, this._week.dow)\n : m\n ? this._weekdaysMin[m.day()]\n : this._weekdaysMin;\n }\n\n function handleStrictParse$1(weekdayName, format, strict) {\n var i,\n ii,\n mom,\n llc = weekdayName.toLocaleLowerCase();\n if (!this._weekdaysParse) {\n this._weekdaysParse = [];\n this._shortWeekdaysParse = [];\n this._minWeekdaysParse = [];\n\n for (i = 0; i < 7; ++i) {\n mom = createUTC([2000, 1]).day(i);\n this._minWeekdaysParse[i] = this.weekdaysMin(\n mom,\n ''\n ).toLocaleLowerCase();\n this._shortWeekdaysParse[i] = this.weekdaysShort(\n mom,\n ''\n ).toLocaleLowerCase();\n this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();\n }\n }\n\n if (strict) {\n if (format === 'dddd') {\n ii = indexOf.call(this._weekdaysParse, llc);\n return ii !== -1 ? ii : null;\n } else if (format === 'ddd') {\n ii = indexOf.call(this._shortWeekdaysParse, llc);\n return ii !== -1 ? ii : null;\n } else {\n ii = indexOf.call(this._minWeekdaysParse, llc);\n return ii !== -1 ? ii : null;\n }\n } else {\n if (format === 'dddd') {\n ii = indexOf.call(this._weekdaysParse, llc);\n if (ii !== -1) {\n return ii;\n }\n ii = indexOf.call(this._shortWeekdaysParse, llc);\n if (ii !== -1) {\n return ii;\n }\n ii = indexOf.call(this._minWeekdaysParse, llc);\n return ii !== -1 ? ii : null;\n } else if (format === 'ddd') {\n ii = indexOf.call(this._shortWeekdaysParse, llc);\n if (ii !== -1) {\n return ii;\n }\n ii = indexOf.call(this._weekdaysParse, llc);\n if (ii !== -1) {\n return ii;\n }\n ii = indexOf.call(this._minWeekdaysParse, llc);\n return ii !== -1 ? ii : null;\n } else {\n ii = indexOf.call(this._minWeekdaysParse, llc);\n if (ii !== -1) {\n return ii;\n }\n ii = indexOf.call(this._weekdaysParse, llc);\n if (ii !== -1) {\n return ii;\n }\n ii = indexOf.call(this._shortWeekdaysParse, llc);\n return ii !== -1 ? ii : null;\n }\n }\n }\n\n function localeWeekdaysParse(weekdayName, format, strict) {\n var i, mom, regex;\n\n if (this._weekdaysParseExact) {\n return handleStrictParse$1.call(this, weekdayName, format, strict);\n }\n\n if (!this._weekdaysParse) {\n this._weekdaysParse = [];\n this._minWeekdaysParse = [];\n this._shortWeekdaysParse = [];\n this._fullWeekdaysParse = [];\n }\n\n for (i = 0; i < 7; i++) {\n // make the regex if we don't have it already\n\n mom = createUTC([2000, 1]).day(i);\n if (strict && !this._fullWeekdaysParse[i]) {\n this._fullWeekdaysParse[i] = new RegExp(\n '^' + this.weekdays(mom, '').replace('.', '\\\\.?') + '$',\n 'i'\n );\n this._shortWeekdaysParse[i] = new RegExp(\n '^' + this.weekdaysShort(mom, '').replace('.', '\\\\.?') + '$',\n 'i'\n );\n this._minWeekdaysParse[i] = new RegExp(\n '^' + this.weekdaysMin(mom, '').replace('.', '\\\\.?') + '$',\n 'i'\n );\n }\n if (!this._weekdaysParse[i]) {\n regex =\n '^' +\n this.weekdays(mom, '') +\n '|^' +\n this.weekdaysShort(mom, '') +\n '|^' +\n this.weekdaysMin(mom, '');\n this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');\n }\n // test the regex\n if (\n strict &&\n format === 'dddd' &&\n this._fullWeekdaysParse[i].test(weekdayName)\n ) {\n return i;\n } else if (\n strict &&\n format === 'ddd' &&\n this._shortWeekdaysParse[i].test(weekdayName)\n ) {\n return i;\n } else if (\n strict &&\n format === 'dd' &&\n this._minWeekdaysParse[i].test(weekdayName)\n ) {\n return i;\n } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {\n return i;\n }\n }\n }\n\n // MOMENTS\n\n function getSetDayOfWeek(input) {\n if (!this.isValid()) {\n return input != null ? this : NaN;\n }\n var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();\n if (input != null) {\n input = parseWeekday(input, this.localeData());\n return this.add(input - day, 'd');\n } else {\n return day;\n }\n }\n\n function getSetLocaleDayOfWeek(input) {\n if (!this.isValid()) {\n return input != null ? this : NaN;\n }\n var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;\n return input == null ? weekday : this.add(input - weekday, 'd');\n }\n\n function getSetISODayOfWeek(input) {\n if (!this.isValid()) {\n return input != null ? this : NaN;\n }\n\n // behaves the same as moment#day except\n // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)\n // as a setter, sunday should belong to the previous week.\n\n if (input != null) {\n var weekday = parseIsoWeekday(input, this.localeData());\n return this.day(this.day() % 7 ? weekday : weekday - 7);\n } else {\n return this.day() || 7;\n }\n }\n\n function weekdaysRegex(isStrict) {\n if (this._weekdaysParseExact) {\n if (!hasOwnProp(this, '_weekdaysRegex')) {\n computeWeekdaysParse.call(this);\n }\n if (isStrict) {\n return this._weekdaysStrictRegex;\n } else {\n return this._weekdaysRegex;\n }\n } else {\n if (!hasOwnProp(this, '_weekdaysRegex')) {\n this._weekdaysRegex = defaultWeekdaysRegex;\n }\n return this._weekdaysStrictRegex && isStrict\n ? this._weekdaysStrictRegex\n : this._weekdaysRegex;\n }\n }\n\n function weekdaysShortRegex(isStrict) {\n if (this._weekdaysParseExact) {\n if (!hasOwnProp(this, '_weekdaysRegex')) {\n computeWeekdaysParse.call(this);\n }\n if (isStrict) {\n return this._weekdaysShortStrictRegex;\n } else {\n return this._weekdaysShortRegex;\n }\n } else {\n if (!hasOwnProp(this, '_weekdaysShortRegex')) {\n this._weekdaysShortRegex = defaultWeekdaysShortRegex;\n }\n return this._weekdaysShortStrictRegex && isStrict\n ? this._weekdaysShortStrictRegex\n : this._weekdaysShortRegex;\n }\n }\n\n function weekdaysMinRegex(isStrict) {\n if (this._weekdaysParseExact) {\n if (!hasOwnProp(this, '_weekdaysRegex')) {\n computeWeekdaysParse.call(this);\n }\n if (isStrict) {\n return this._weekdaysMinStrictRegex;\n } else {\n return this._weekdaysMinRegex;\n }\n } else {\n if (!hasOwnProp(this, '_weekdaysMinRegex')) {\n this._weekdaysMinRegex = defaultWeekdaysMinRegex;\n }\n return this._weekdaysMinStrictRegex && isStrict\n ? this._weekdaysMinStrictRegex\n : this._weekdaysMinRegex;\n }\n }\n\n function computeWeekdaysParse() {\n function cmpLenRev(a, b) {\n return b.length - a.length;\n }\n\n var minPieces = [],\n shortPieces = [],\n longPieces = [],\n mixedPieces = [],\n i,\n mom,\n minp,\n shortp,\n longp;\n for (i = 0; i < 7; i++) {\n // make the regex if we don't have it already\n mom = createUTC([2000, 1]).day(i);\n minp = regexEscape(this.weekdaysMin(mom, ''));\n shortp = regexEscape(this.weekdaysShort(mom, ''));\n longp = regexEscape(this.weekdays(mom, ''));\n minPieces.push(minp);\n shortPieces.push(shortp);\n longPieces.push(longp);\n mixedPieces.push(minp);\n mixedPieces.push(shortp);\n mixedPieces.push(longp);\n }\n // Sorting makes sure if one weekday (or abbr) is a prefix of another it\n // will match the longer piece.\n minPieces.sort(cmpLenRev);\n shortPieces.sort(cmpLenRev);\n longPieces.sort(cmpLenRev);\n mixedPieces.sort(cmpLenRev);\n\n this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');\n this._weekdaysShortRegex = this._weekdaysRegex;\n this._weekdaysMinRegex = this._weekdaysRegex;\n\n this._weekdaysStrictRegex = new RegExp(\n '^(' + longPieces.join('|') + ')',\n 'i'\n );\n this._weekdaysShortStrictRegex = new RegExp(\n '^(' + shortPieces.join('|') + ')',\n 'i'\n );\n this._weekdaysMinStrictRegex = new RegExp(\n '^(' + minPieces.join('|') + ')',\n 'i'\n );\n }\n\n // FORMATTING\n\n function hFormat() {\n return this.hours() % 12 || 12;\n }\n\n function kFormat() {\n return this.hours() || 24;\n }\n\n addFormatToken('H', ['HH', 2], 0, 'hour');\n addFormatToken('h', ['hh', 2], 0, hFormat);\n addFormatToken('k', ['kk', 2], 0, kFormat);\n\n addFormatToken('hmm', 0, 0, function () {\n return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);\n });\n\n addFormatToken('hmmss', 0, 0, function () {\n return (\n '' +\n hFormat.apply(this) +\n zeroFill(this.minutes(), 2) +\n zeroFill(this.seconds(), 2)\n );\n });\n\n addFormatToken('Hmm', 0, 0, function () {\n return '' + this.hours() + zeroFill(this.minutes(), 2);\n });\n\n addFormatToken('Hmmss', 0, 0, function () {\n return (\n '' +\n this.hours() +\n zeroFill(this.minutes(), 2) +\n zeroFill(this.seconds(), 2)\n );\n });\n\n function meridiem(token, lowercase) {\n addFormatToken(token, 0, 0, function () {\n return this.localeData().meridiem(\n this.hours(),\n this.minutes(),\n lowercase\n );\n });\n }\n\n meridiem('a', true);\n meridiem('A', false);\n\n // ALIASES\n\n addUnitAlias('hour', 'h');\n\n // PRIORITY\n addUnitPriority('hour', 13);\n\n // PARSING\n\n function matchMeridiem(isStrict, locale) {\n return locale._meridiemParse;\n }\n\n addRegexToken('a', matchMeridiem);\n addRegexToken('A', matchMeridiem);\n addRegexToken('H', match1to2);\n addRegexToken('h', match1to2);\n addRegexToken('k', match1to2);\n addRegexToken('HH', match1to2, match2);\n addRegexToken('hh', match1to2, match2);\n addRegexToken('kk', match1to2, match2);\n\n addRegexToken('hmm', match3to4);\n addRegexToken('hmmss', match5to6);\n addRegexToken('Hmm', match3to4);\n addRegexToken('Hmmss', match5to6);\n\n addParseToken(['H', 'HH'], HOUR);\n addParseToken(['k', 'kk'], function (input, array, config) {\n var kInput = toInt(input);\n array[HOUR] = kInput === 24 ? 0 : kInput;\n });\n addParseToken(['a', 'A'], function (input, array, config) {\n config._isPm = config._locale.isPM(input);\n config._meridiem = input;\n });\n addParseToken(['h', 'hh'], function (input, array, config) {\n array[HOUR] = toInt(input);\n getParsingFlags(config).bigHour = true;\n });\n addParseToken('hmm', function (input, array, config) {\n var pos = input.length - 2;\n array[HOUR] = toInt(input.substr(0, pos));\n array[MINUTE] = toInt(input.substr(pos));\n getParsingFlags(config).bigHour = true;\n });\n addParseToken('hmmss', function (input, array, config) {\n var pos1 = input.length - 4,\n pos2 = input.length - 2;\n array[HOUR] = toInt(input.substr(0, pos1));\n array[MINUTE] = toInt(input.substr(pos1, 2));\n array[SECOND] = toInt(input.substr(pos2));\n getParsingFlags(config).bigHour = true;\n });\n addParseToken('Hmm', function (input, array, config) {\n var pos = input.length - 2;\n array[HOUR] = toInt(input.substr(0, pos));\n array[MINUTE] = toInt(input.substr(pos));\n });\n addParseToken('Hmmss', function (input, array, config) {\n var pos1 = input.length - 4,\n pos2 = input.length - 2;\n array[HOUR] = toInt(input.substr(0, pos1));\n array[MINUTE] = toInt(input.substr(pos1, 2));\n array[SECOND] = toInt(input.substr(pos2));\n });\n\n // LOCALES\n\n function localeIsPM(input) {\n // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays\n // Using charAt should be more compatible.\n return (input + '').toLowerCase().charAt(0) === 'p';\n }\n\n var defaultLocaleMeridiemParse = /[ap]\\.?m?\\.?/i,\n // Setting the hour should keep the time, because the user explicitly\n // specified which hour they want. So trying to maintain the same hour (in\n // a new timezone) makes sense. Adding/subtracting hours does not follow\n // this rule.\n getSetHour = makeGetSet('Hours', true);\n\n function localeMeridiem(hours, minutes, isLower) {\n if (hours > 11) {\n return isLower ? 'pm' : 'PM';\n } else {\n return isLower ? 'am' : 'AM';\n }\n }\n\n var baseConfig = {\n calendar: defaultCalendar,\n longDateFormat: defaultLongDateFormat,\n invalidDate: defaultInvalidDate,\n ordinal: defaultOrdinal,\n dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,\n relativeTime: defaultRelativeTime,\n\n months: defaultLocaleMonths,\n monthsShort: defaultLocaleMonthsShort,\n\n week: defaultLocaleWeek,\n\n weekdays: defaultLocaleWeekdays,\n weekdaysMin: defaultLocaleWeekdaysMin,\n weekdaysShort: defaultLocaleWeekdaysShort,\n\n meridiemParse: defaultLocaleMeridiemParse,\n };\n\n // internal storage for locale config files\n var locales = {},\n localeFamilies = {},\n globalLocale;\n\n function commonPrefix(arr1, arr2) {\n var i,\n minl = Math.min(arr1.length, arr2.length);\n for (i = 0; i < minl; i += 1) {\n if (arr1[i] !== arr2[i]) {\n return i;\n }\n }\n return minl;\n }\n\n function normalizeLocale(key) {\n return key ? key.toLowerCase().replace('_', '-') : key;\n }\n\n // pick the locale from the array\n // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each\n // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root\n function chooseLocale(names) {\n var i = 0,\n j,\n next,\n locale,\n split;\n\n while (i < names.length) {\n split = normalizeLocale(names[i]).split('-');\n j = split.length;\n next = normalizeLocale(names[i + 1]);\n next = next ? next.split('-') : null;\n while (j > 0) {\n locale = loadLocale(split.slice(0, j).join('-'));\n if (locale) {\n return locale;\n }\n if (\n next &&\n next.length >= j &&\n commonPrefix(split, next) >= j - 1\n ) {\n //the next array item is better than a shallower substring of this one\n break;\n }\n j--;\n }\n i++;\n }\n return globalLocale;\n }\n\n function loadLocale(name) {\n var oldLocale = null,\n aliasedRequire;\n // TODO: Find a better way to register and load all the locales in Node\n if (\n locales[name] === undefined &&\n typeof module !== 'undefined' &&\n module &&\n module.exports\n ) {\n try {\n oldLocale = globalLocale._abbr;\n aliasedRequire = require;\n aliasedRequire('./locale/' + name);\n getSetGlobalLocale(oldLocale);\n } catch (e) {\n // mark as not found to avoid repeating expensive file require call causing high CPU\n // when trying to find en-US, en_US, en-us for every format call\n locales[name] = null; // null means not found\n }\n }\n return locales[name];\n }\n\n // This function will load locale and then set the global locale. If\n // no arguments are passed in, it will simply return the current global\n // locale key.\n function getSetGlobalLocale(key, values) {\n var data;\n if (key) {\n if (isUndefined(values)) {\n data = getLocale(key);\n } else {\n data = defineLocale(key, values);\n }\n\n if (data) {\n // moment.duration._locale = moment._locale = data;\n globalLocale = data;\n } else {\n if (typeof console !== 'undefined' && console.warn) {\n //warn user if arguments are passed but the locale could not be set\n console.warn(\n 'Locale ' + key + ' not found. Did you forget to load it?'\n );\n }\n }\n }\n\n return globalLocale._abbr;\n }\n\n function defineLocale(name, config) {\n if (config !== null) {\n var locale,\n parentConfig = baseConfig;\n config.abbr = name;\n if (locales[name] != null) {\n deprecateSimple(\n 'defineLocaleOverride',\n 'use moment.updateLocale(localeName, config) to change ' +\n 'an existing locale. moment.defineLocale(localeName, ' +\n 'config) should only be used for creating a new locale ' +\n 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'\n );\n parentConfig = locales[name]._config;\n } else if (config.parentLocale != null) {\n if (locales[config.parentLocale] != null) {\n parentConfig = locales[config.parentLocale]._config;\n } else {\n locale = loadLocale(config.parentLocale);\n if (locale != null) {\n parentConfig = locale._config;\n } else {\n if (!localeFamilies[config.parentLocale]) {\n localeFamilies[config.parentLocale] = [];\n }\n localeFamilies[config.parentLocale].push({\n name: name,\n config: config,\n });\n return null;\n }\n }\n }\n locales[name] = new Locale(mergeConfigs(parentConfig, config));\n\n if (localeFamilies[name]) {\n localeFamilies[name].forEach(function (x) {\n defineLocale(x.name, x.config);\n });\n }\n\n // backwards compat for now: also set the locale\n // make sure we set the locale AFTER all child locales have been\n // created, so we won't end up with the child locale set.\n getSetGlobalLocale(name);\n\n return locales[name];\n } else {\n // useful for testing\n delete locales[name];\n return null;\n }\n }\n\n function updateLocale(name, config) {\n if (config != null) {\n var locale,\n tmpLocale,\n parentConfig = baseConfig;\n\n if (locales[name] != null && locales[name].parentLocale != null) {\n // Update existing child locale in-place to avoid memory-leaks\n locales[name].set(mergeConfigs(locales[name]._config, config));\n } else {\n // MERGE\n tmpLocale = loadLocale(name);\n if (tmpLocale != null) {\n parentConfig = tmpLocale._config;\n }\n config = mergeConfigs(parentConfig, config);\n if (tmpLocale == null) {\n // updateLocale is called for creating a new locale\n // Set abbr so it will have a name (getters return\n // undefined otherwise).\n config.abbr = name;\n }\n locale = new Locale(config);\n locale.parentLocale = locales[name];\n locales[name] = locale;\n }\n\n // backwards compat for now: also set the locale\n getSetGlobalLocale(name);\n } else {\n // pass null for config to unupdate, useful for tests\n if (locales[name] != null) {\n if (locales[name].parentLocale != null) {\n locales[name] = locales[name].parentLocale;\n if (name === getSetGlobalLocale()) {\n getSetGlobalLocale(name);\n }\n } else if (locales[name] != null) {\n delete locales[name];\n }\n }\n }\n return locales[name];\n }\n\n // returns locale data\n function getLocale(key) {\n var locale;\n\n if (key && key._locale && key._locale._abbr) {\n key = key._locale._abbr;\n }\n\n if (!key) {\n return globalLocale;\n }\n\n if (!isArray(key)) {\n //short-circuit everything else\n locale = loadLocale(key);\n if (locale) {\n return locale;\n }\n key = [key];\n }\n\n return chooseLocale(key);\n }\n\n function listLocales() {\n return keys(locales);\n }\n\n function checkOverflow(m) {\n var overflow,\n a = m._a;\n\n if (a && getParsingFlags(m).overflow === -2) {\n overflow =\n a[MONTH] < 0 || a[MONTH] > 11\n ? MONTH\n : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])\n ? DATE\n : a[HOUR] < 0 ||\n a[HOUR] > 24 ||\n (a[HOUR] === 24 &&\n (a[MINUTE] !== 0 ||\n a[SECOND] !== 0 ||\n a[MILLISECOND] !== 0))\n ? HOUR\n : a[MINUTE] < 0 || a[MINUTE] > 59\n ? MINUTE\n : a[SECOND] < 0 || a[SECOND] > 59\n ? SECOND\n : a[MILLISECOND] < 0 || a[MILLISECOND] > 999\n ? MILLISECOND\n : -1;\n\n if (\n getParsingFlags(m)._overflowDayOfYear &&\n (overflow < YEAR || overflow > DATE)\n ) {\n overflow = DATE;\n }\n if (getParsingFlags(m)._overflowWeeks && overflow === -1) {\n overflow = WEEK;\n }\n if (getParsingFlags(m)._overflowWeekday && overflow === -1) {\n overflow = WEEKDAY;\n }\n\n getParsingFlags(m).overflow = overflow;\n }\n\n return m;\n }\n\n // iso 8601 regex\n // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)\n var extendedIsoRegex = /^\\s*((?:[+-]\\d{6}|\\d{4})-(?:\\d\\d-\\d\\d|W\\d\\d-\\d|W\\d\\d|\\d\\d\\d|\\d\\d))(?:(T| )(\\d\\d(?::\\d\\d(?::\\d\\d(?:[.,]\\d+)?)?)?)([+-]\\d\\d(?::?\\d\\d)?|\\s*Z)?)?$/,\n basicIsoRegex = /^\\s*((?:[+-]\\d{6}|\\d{4})(?:\\d\\d\\d\\d|W\\d\\d\\d|W\\d\\d|\\d\\d\\d|\\d\\d|))(?:(T| )(\\d\\d(?:\\d\\d(?:\\d\\d(?:[.,]\\d+)?)?)?)([+-]\\d\\d(?::?\\d\\d)?|\\s*Z)?)?$/,\n tzRegex = /Z|[+-]\\d\\d(?::?\\d\\d)?/,\n isoDates = [\n ['YYYYYY-MM-DD', /[+-]\\d{6}-\\d\\d-\\d\\d/],\n ['YYYY-MM-DD', /\\d{4}-\\d\\d-\\d\\d/],\n ['GGGG-[W]WW-E', /\\d{4}-W\\d\\d-\\d/],\n ['GGGG-[W]WW', /\\d{4}-W\\d\\d/, false],\n ['YYYY-DDD', /\\d{4}-\\d{3}/],\n ['YYYY-MM', /\\d{4}-\\d\\d/, false],\n ['YYYYYYMMDD', /[+-]\\d{10}/],\n ['YYYYMMDD', /\\d{8}/],\n ['GGGG[W]WWE', /\\d{4}W\\d{3}/],\n ['GGGG[W]WW', /\\d{4}W\\d{2}/, false],\n ['YYYYDDD', /\\d{7}/],\n ['YYYYMM', /\\d{6}/, false],\n ['YYYY', /\\d{4}/, false],\n ],\n // iso time formats and regexes\n isoTimes = [\n ['HH:mm:ss.SSSS', /\\d\\d:\\d\\d:\\d\\d\\.\\d+/],\n ['HH:mm:ss,SSSS', /\\d\\d:\\d\\d:\\d\\d,\\d+/],\n ['HH:mm:ss', /\\d\\d:\\d\\d:\\d\\d/],\n ['HH:mm', /\\d\\d:\\d\\d/],\n ['HHmmss.SSSS', /\\d\\d\\d\\d\\d\\d\\.\\d+/],\n ['HHmmss,SSSS', /\\d\\d\\d\\d\\d\\d,\\d+/],\n ['HHmmss', /\\d\\d\\d\\d\\d\\d/],\n ['HHmm', /\\d\\d\\d\\d/],\n ['HH', /\\d\\d/],\n ],\n aspNetJsonRegex = /^\\/?Date\\((-?\\d+)/i,\n // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3\n rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\\s)?(\\d{1,2})\\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s(\\d{2,4})\\s(\\d\\d):(\\d\\d)(?::(\\d\\d))?\\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\\d{4}))$/,\n obsOffsets = {\n UT: 0,\n GMT: 0,\n EDT: -4 * 60,\n EST: -5 * 60,\n CDT: -5 * 60,\n CST: -6 * 60,\n MDT: -6 * 60,\n MST: -7 * 60,\n PDT: -7 * 60,\n PST: -8 * 60,\n };\n\n // date from iso format\n function configFromISO(config) {\n var i,\n l,\n string = config._i,\n match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),\n allowTime,\n dateFormat,\n timeFormat,\n tzFormat;\n\n if (match) {\n getParsingFlags(config).iso = true;\n\n for (i = 0, l = isoDates.length; i < l; i++) {\n if (isoDates[i][1].exec(match[1])) {\n dateFormat = isoDates[i][0];\n allowTime = isoDates[i][2] !== false;\n break;\n }\n }\n if (dateFormat == null) {\n config._isValid = false;\n return;\n }\n if (match[3]) {\n for (i = 0, l = isoTimes.length; i < l; i++) {\n if (isoTimes[i][1].exec(match[3])) {\n // match[2] should be 'T' or space\n timeFormat = (match[2] || ' ') + isoTimes[i][0];\n break;\n }\n }\n if (timeFormat == null) {\n config._isValid = false;\n return;\n }\n }\n if (!allowTime && timeFormat != null) {\n config._isValid = false;\n return;\n }\n if (match[4]) {\n if (tzRegex.exec(match[4])) {\n tzFormat = 'Z';\n } else {\n config._isValid = false;\n return;\n }\n }\n config._f = dateFormat + (timeFormat || '') + (tzFormat || '');\n configFromStringAndFormat(config);\n } else {\n config._isValid = false;\n }\n }\n\n function extractFromRFC2822Strings(\n yearStr,\n monthStr,\n dayStr,\n hourStr,\n minuteStr,\n secondStr\n ) {\n var result = [\n untruncateYear(yearStr),\n defaultLocaleMonthsShort.indexOf(monthStr),\n parseInt(dayStr, 10),\n parseInt(hourStr, 10),\n parseInt(minuteStr, 10),\n ];\n\n if (secondStr) {\n result.push(parseInt(secondStr, 10));\n }\n\n return result;\n }\n\n function untruncateYear(yearStr) {\n var year = parseInt(yearStr, 10);\n if (year <= 49) {\n return 2000 + year;\n } else if (year <= 999) {\n return 1900 + year;\n }\n return year;\n }\n\n function preprocessRFC2822(s) {\n // Remove comments and folding whitespace and replace multiple-spaces with a single space\n return s\n .replace(/\\([^)]*\\)|[\\n\\t]/g, ' ')\n .replace(/(\\s\\s+)/g, ' ')\n .replace(/^\\s\\s*/, '')\n .replace(/\\s\\s*$/, '');\n }\n\n function checkWeekday(weekdayStr, parsedInput, config) {\n if (weekdayStr) {\n // TODO: Replace the vanilla JS Date object with an independent day-of-week check.\n var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),\n weekdayActual = new Date(\n parsedInput[0],\n parsedInput[1],\n parsedInput[2]\n ).getDay();\n if (weekdayProvided !== weekdayActual) {\n getParsingFlags(config).weekdayMismatch = true;\n config._isValid = false;\n return false;\n }\n }\n return true;\n }\n\n function calculateOffset(obsOffset, militaryOffset, numOffset) {\n if (obsOffset) {\n return obsOffsets[obsOffset];\n } else if (militaryOffset) {\n // the only allowed military tz is Z\n return 0;\n } else {\n var hm = parseInt(numOffset, 10),\n m = hm % 100,\n h = (hm - m) / 100;\n return h * 60 + m;\n }\n }\n\n // date and time from ref 2822 format\n function configFromRFC2822(config) {\n var match = rfc2822.exec(preprocessRFC2822(config._i)),\n parsedArray;\n if (match) {\n parsedArray = extractFromRFC2822Strings(\n match[4],\n match[3],\n match[2],\n match[5],\n match[6],\n match[7]\n );\n if (!checkWeekday(match[1], parsedArray, config)) {\n return;\n }\n\n config._a = parsedArray;\n config._tzm = calculateOffset(match[8], match[9], match[10]);\n\n config._d = createUTCDate.apply(null, config._a);\n config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);\n\n getParsingFlags(config).rfc2822 = true;\n } else {\n config._isValid = false;\n }\n }\n\n // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict\n function configFromString(config) {\n var matched = aspNetJsonRegex.exec(config._i);\n if (matched !== null) {\n config._d = new Date(+matched[1]);\n return;\n }\n\n configFromISO(config);\n if (config._isValid === false) {\n delete config._isValid;\n } else {\n return;\n }\n\n configFromRFC2822(config);\n if (config._isValid === false) {\n delete config._isValid;\n } else {\n return;\n }\n\n if (config._strict) {\n config._isValid = false;\n } else {\n // Final attempt, use Input Fallback\n hooks.createFromInputFallback(config);\n }\n }\n\n hooks.createFromInputFallback = deprecate(\n 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +\n 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +\n 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',\n function (config) {\n config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));\n }\n );\n\n // Pick the first defined of two or three arguments.\n function defaults(a, b, c) {\n if (a != null) {\n return a;\n }\n if (b != null) {\n return b;\n }\n return c;\n }\n\n function currentDateArray(config) {\n // hooks is actually the exported moment object\n var nowValue = new Date(hooks.now());\n if (config._useUTC) {\n return [\n nowValue.getUTCFullYear(),\n nowValue.getUTCMonth(),\n nowValue.getUTCDate(),\n ];\n }\n return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];\n }\n\n // convert an array to a date.\n // the array should mirror the parameters below\n // note: all values past the year are optional and will default to the lowest possible value.\n // [year, month, day , hour, minute, second, millisecond]\n function configFromArray(config) {\n var i,\n date,\n input = [],\n currentDate,\n expectedWeekday,\n yearToUse;\n\n if (config._d) {\n return;\n }\n\n currentDate = currentDateArray(config);\n\n //compute day of the year from weeks and weekdays\n if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {\n dayOfYearFromWeekInfo(config);\n }\n\n //if the day of the year is set, figure out what it is\n if (config._dayOfYear != null) {\n yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);\n\n if (\n config._dayOfYear > daysInYear(yearToUse) ||\n config._dayOfYear === 0\n ) {\n getParsingFlags(config)._overflowDayOfYear = true;\n }\n\n date = createUTCDate(yearToUse, 0, config._dayOfYear);\n config._a[MONTH] = date.getUTCMonth();\n config._a[DATE] = date.getUTCDate();\n }\n\n // Default to current date.\n // * if no year, month, day of month are given, default to today\n // * if day of month is given, default month and year\n // * if month is given, default only year\n // * if year is given, don't default anything\n for (i = 0; i < 3 && config._a[i] == null; ++i) {\n config._a[i] = input[i] = currentDate[i];\n }\n\n // Zero out whatever was not defaulted, including time\n for (; i < 7; i++) {\n config._a[i] = input[i] =\n config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];\n }\n\n // Check for 24:00:00.000\n if (\n config._a[HOUR] === 24 &&\n config._a[MINUTE] === 0 &&\n config._a[SECOND] === 0 &&\n config._a[MILLISECOND] === 0\n ) {\n config._nextDay = true;\n config._a[HOUR] = 0;\n }\n\n config._d = (config._useUTC ? createUTCDate : createDate).apply(\n null,\n input\n );\n expectedWeekday = config._useUTC\n ? config._d.getUTCDay()\n : config._d.getDay();\n\n // Apply timezone offset from input. The actual utcOffset can be changed\n // with parseZone.\n if (config._tzm != null) {\n config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);\n }\n\n if (config._nextDay) {\n config._a[HOUR] = 24;\n }\n\n // check for mismatching day of week\n if (\n config._w &&\n typeof config._w.d !== 'undefined' &&\n config._w.d !== expectedWeekday\n ) {\n getParsingFlags(config).weekdayMismatch = true;\n }\n }\n\n function dayOfYearFromWeekInfo(config) {\n var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;\n\n w = config._w;\n if (w.GG != null || w.W != null || w.E != null) {\n dow = 1;\n doy = 4;\n\n // TODO: We need to take the current isoWeekYear, but that depends on\n // how we interpret now (local, utc, fixed offset). So create\n // a now version of current config (take local/utc/offset flags, and\n // create now).\n weekYear = defaults(\n w.GG,\n config._a[YEAR],\n weekOfYear(createLocal(), 1, 4).year\n );\n week = defaults(w.W, 1);\n weekday = defaults(w.E, 1);\n if (weekday < 1 || weekday > 7) {\n weekdayOverflow = true;\n }\n } else {\n dow = config._locale._week.dow;\n doy = config._locale._week.doy;\n\n curWeek = weekOfYear(createLocal(), dow, doy);\n\n weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);\n\n // Default to current week.\n week = defaults(w.w, curWeek.week);\n\n if (w.d != null) {\n // weekday -- low day numbers are considered next week\n weekday = w.d;\n if (weekday < 0 || weekday > 6) {\n weekdayOverflow = true;\n }\n } else if (w.e != null) {\n // local weekday -- counting starts from beginning of week\n weekday = w.e + dow;\n if (w.e < 0 || w.e > 6) {\n weekdayOverflow = true;\n }\n } else {\n // default to beginning of week\n weekday = dow;\n }\n }\n if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {\n getParsingFlags(config)._overflowWeeks = true;\n } else if (weekdayOverflow != null) {\n getParsingFlags(config)._overflowWeekday = true;\n } else {\n temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);\n config._a[YEAR] = temp.year;\n config._dayOfYear = temp.dayOfYear;\n }\n }\n\n // constant that refers to the ISO standard\n hooks.ISO_8601 = function () {};\n\n // constant that refers to the RFC 2822 form\n hooks.RFC_2822 = function () {};\n\n // date from string and format string\n function configFromStringAndFormat(config) {\n // TODO: Move this to another part of the creation flow to prevent circular deps\n if (config._f === hooks.ISO_8601) {\n configFromISO(config);\n return;\n }\n if (config._f === hooks.RFC_2822) {\n configFromRFC2822(config);\n return;\n }\n config._a = [];\n getParsingFlags(config).empty = true;\n\n // This array is used to make a Date, either with `new Date` or `Date.UTC`\n var string = '' + config._i,\n i,\n parsedInput,\n tokens,\n token,\n skipped,\n stringLength = string.length,\n totalParsedInputLength = 0,\n era;\n\n tokens =\n expandFormat(config._f, config._locale).match(formattingTokens) || [];\n\n for (i = 0; i < tokens.length; i++) {\n token = tokens[i];\n parsedInput = (string.match(getParseRegexForToken(token, config)) ||\n [])[0];\n if (parsedInput) {\n skipped = string.substr(0, string.indexOf(parsedInput));\n if (skipped.length > 0) {\n getParsingFlags(config).unusedInput.push(skipped);\n }\n string = string.slice(\n string.indexOf(parsedInput) + parsedInput.length\n );\n totalParsedInputLength += parsedInput.length;\n }\n // don't parse if it's not a known token\n if (formatTokenFunctions[token]) {\n if (parsedInput) {\n getParsingFlags(config).empty = false;\n } else {\n getParsingFlags(config).unusedTokens.push(token);\n }\n addTimeToArrayFromToken(token, parsedInput, config);\n } else if (config._strict && !parsedInput) {\n getParsingFlags(config).unusedTokens.push(token);\n }\n }\n\n // add remaining unparsed input length to the string\n getParsingFlags(config).charsLeftOver =\n stringLength - totalParsedInputLength;\n if (string.length > 0) {\n getParsingFlags(config).unusedInput.push(string);\n }\n\n // clear _12h flag if hour is <= 12\n if (\n config._a[HOUR] <= 12 &&\n getParsingFlags(config).bigHour === true &&\n config._a[HOUR] > 0\n ) {\n getParsingFlags(config).bigHour = undefined;\n }\n\n getParsingFlags(config).parsedDateParts = config._a.slice(0);\n getParsingFlags(config).meridiem = config._meridiem;\n // handle meridiem\n config._a[HOUR] = meridiemFixWrap(\n config._locale,\n config._a[HOUR],\n config._meridiem\n );\n\n // handle era\n era = getParsingFlags(config).era;\n if (era !== null) {\n config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);\n }\n\n configFromArray(config);\n checkOverflow(config);\n }\n\n function meridiemFixWrap(locale, hour, meridiem) {\n var isPm;\n\n if (meridiem == null) {\n // nothing to do\n return hour;\n }\n if (locale.meridiemHour != null) {\n return locale.meridiemHour(hour, meridiem);\n } else if (locale.isPM != null) {\n // Fallback\n isPm = locale.isPM(meridiem);\n if (isPm && hour < 12) {\n hour += 12;\n }\n if (!isPm && hour === 12) {\n hour = 0;\n }\n return hour;\n } else {\n // this is not supposed to happen\n return hour;\n }\n }\n\n // date from string and array of format strings\n function configFromStringAndArray(config) {\n var tempConfig,\n bestMoment,\n scoreToBeat,\n i,\n currentScore,\n validFormatFound,\n bestFormatIsValid = false;\n\n if (config._f.length === 0) {\n getParsingFlags(config).invalidFormat = true;\n config._d = new Date(NaN);\n return;\n }\n\n for (i = 0; i < config._f.length; i++) {\n currentScore = 0;\n validFormatFound = false;\n tempConfig = copyConfig({}, config);\n if (config._useUTC != null) {\n tempConfig._useUTC = config._useUTC;\n }\n tempConfig._f = config._f[i];\n configFromStringAndFormat(tempConfig);\n\n if (isValid(tempConfig)) {\n validFormatFound = true;\n }\n\n // if there is any input that was not parsed add a penalty for that format\n currentScore += getParsingFlags(tempConfig).charsLeftOver;\n\n //or tokens\n currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;\n\n getParsingFlags(tempConfig).score = currentScore;\n\n if (!bestFormatIsValid) {\n if (\n scoreToBeat == null ||\n currentScore < scoreToBeat ||\n validFormatFound\n ) {\n scoreToBeat = currentScore;\n bestMoment = tempConfig;\n if (validFormatFound) {\n bestFormatIsValid = true;\n }\n }\n } else {\n if (currentScore < scoreToBeat) {\n scoreToBeat = currentScore;\n bestMoment = tempConfig;\n }\n }\n }\n\n extend(config, bestMoment || tempConfig);\n }\n\n function configFromObject(config) {\n if (config._d) {\n return;\n }\n\n var i = normalizeObjectUnits(config._i),\n dayOrDate = i.day === undefined ? i.date : i.day;\n config._a = map(\n [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],\n function (obj) {\n return obj && parseInt(obj, 10);\n }\n );\n\n configFromArray(config);\n }\n\n function createFromConfig(config) {\n var res = new Moment(checkOverflow(prepareConfig(config)));\n if (res._nextDay) {\n // Adding is smart enough around DST\n res.add(1, 'd');\n res._nextDay = undefined;\n }\n\n return res;\n }\n\n function prepareConfig(config) {\n var input = config._i,\n format = config._f;\n\n config._locale = config._locale || getLocale(config._l);\n\n if (input === null || (format === undefined && input === '')) {\n return createInvalid({ nullInput: true });\n }\n\n if (typeof input === 'string') {\n config._i = input = config._locale.preparse(input);\n }\n\n if (isMoment(input)) {\n return new Moment(checkOverflow(input));\n } else if (isDate(input)) {\n config._d = input;\n } else if (isArray(format)) {\n configFromStringAndArray(config);\n } else if (format) {\n configFromStringAndFormat(config);\n } else {\n configFromInput(config);\n }\n\n if (!isValid(config)) {\n config._d = null;\n }\n\n return config;\n }\n\n function configFromInput(config) {\n var input = config._i;\n if (isUndefined(input)) {\n config._d = new Date(hooks.now());\n } else if (isDate(input)) {\n config._d = new Date(input.valueOf());\n } else if (typeof input === 'string') {\n configFromString(config);\n } else if (isArray(input)) {\n config._a = map(input.slice(0), function (obj) {\n return parseInt(obj, 10);\n });\n configFromArray(config);\n } else if (isObject(input)) {\n configFromObject(config);\n } else if (isNumber(input)) {\n // from milliseconds\n config._d = new Date(input);\n } else {\n hooks.createFromInputFallback(config);\n }\n }\n\n function createLocalOrUTC(input, format, locale, strict, isUTC) {\n var c = {};\n\n if (format === true || format === false) {\n strict = format;\n format = undefined;\n }\n\n if (locale === true || locale === false) {\n strict = locale;\n locale = undefined;\n }\n\n if (\n (isObject(input) && isObjectEmpty(input)) ||\n (isArray(input) && input.length === 0)\n ) {\n input = undefined;\n }\n // object construction must be done this way.\n // https://github.com/moment/moment/issues/1423\n c._isAMomentObject = true;\n c._useUTC = c._isUTC = isUTC;\n c._l = locale;\n c._i = input;\n c._f = format;\n c._strict = strict;\n\n return createFromConfig(c);\n }\n\n function createLocal(input, format, locale, strict) {\n return createLocalOrUTC(input, format, locale, strict, false);\n }\n\n var prototypeMin = deprecate(\n 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',\n function () {\n var other = createLocal.apply(null, arguments);\n if (this.isValid() && other.isValid()) {\n return other < this ? this : other;\n } else {\n return createInvalid();\n }\n }\n ),\n prototypeMax = deprecate(\n 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',\n function () {\n var other = createLocal.apply(null, arguments);\n if (this.isValid() && other.isValid()) {\n return other > this ? this : other;\n } else {\n return createInvalid();\n }\n }\n );\n\n // Pick a moment m from moments so that m[fn](other) is true for all\n // other. This relies on the function fn to be transitive.\n //\n // moments should either be an array of moment objects or an array, whose\n // first element is an array of moment objects.\n function pickBy(fn, moments) {\n var res, i;\n if (moments.length === 1 && isArray(moments[0])) {\n moments = moments[0];\n }\n if (!moments.length) {\n return createLocal();\n }\n res = moments[0];\n for (i = 1; i < moments.length; ++i) {\n if (!moments[i].isValid() || moments[i][fn](res)) {\n res = moments[i];\n }\n }\n return res;\n }\n\n // TODO: Use [].sort instead?\n function min() {\n var args = [].slice.call(arguments, 0);\n\n return pickBy('isBefore', args);\n }\n\n function max() {\n var args = [].slice.call(arguments, 0);\n\n return pickBy('isAfter', args);\n }\n\n var now = function () {\n return Date.now ? Date.now() : +new Date();\n };\n\n var ordering = [\n 'year',\n 'quarter',\n 'month',\n 'week',\n 'day',\n 'hour',\n 'minute',\n 'second',\n 'millisecond',\n ];\n\n function isDurationValid(m) {\n var key,\n unitHasDecimal = false,\n i;\n for (key in m) {\n if (\n hasOwnProp(m, key) &&\n !(\n indexOf.call(ordering, key) !== -1 &&\n (m[key] == null || !isNaN(m[key]))\n )\n ) {\n return false;\n }\n }\n\n for (i = 0; i < ordering.length; ++i) {\n if (m[ordering[i]]) {\n if (unitHasDecimal) {\n return false; // only allow non-integers for smallest unit\n }\n if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {\n unitHasDecimal = true;\n }\n }\n }\n\n return true;\n }\n\n function isValid$1() {\n return this._isValid;\n }\n\n function createInvalid$1() {\n return createDuration(NaN);\n }\n\n function Duration(duration) {\n var normalizedInput = normalizeObjectUnits(duration),\n years = normalizedInput.year || 0,\n quarters = normalizedInput.quarter || 0,\n months = normalizedInput.month || 0,\n weeks = normalizedInput.week || normalizedInput.isoWeek || 0,\n days = normalizedInput.day || 0,\n hours = normalizedInput.hour || 0,\n minutes = normalizedInput.minute || 0,\n seconds = normalizedInput.second || 0,\n milliseconds = normalizedInput.millisecond || 0;\n\n this._isValid = isDurationValid(normalizedInput);\n\n // representation for dateAddRemove\n this._milliseconds =\n +milliseconds +\n seconds * 1e3 + // 1000\n minutes * 6e4 + // 1000 * 60\n hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978\n // Because of dateAddRemove treats 24 hours as different from a\n // day when working around DST, we need to store them separately\n this._days = +days + weeks * 7;\n // It is impossible to translate months into days without knowing\n // which months you are are talking about, so we have to store\n // it separately.\n this._months = +months + quarters * 3 + years * 12;\n\n this._data = {};\n\n this._locale = getLocale();\n\n this._bubble();\n }\n\n function isDuration(obj) {\n return obj instanceof Duration;\n }\n\n function absRound(number) {\n if (number < 0) {\n return Math.round(-1 * number) * -1;\n } else {\n return Math.round(number);\n }\n }\n\n // compare two arrays, return the number of differences\n function compareArrays(array1, array2, dontConvert) {\n var len = Math.min(array1.length, array2.length),\n lengthDiff = Math.abs(array1.length - array2.length),\n diffs = 0,\n i;\n for (i = 0; i < len; i++) {\n if (\n (dontConvert && array1[i] !== array2[i]) ||\n (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))\n ) {\n diffs++;\n }\n }\n return diffs + lengthDiff;\n }\n\n // FORMATTING\n\n function offset(token, separator) {\n addFormatToken(token, 0, 0, function () {\n var offset = this.utcOffset(),\n sign = '+';\n if (offset < 0) {\n offset = -offset;\n sign = '-';\n }\n return (\n sign +\n zeroFill(~~(offset / 60), 2) +\n separator +\n zeroFill(~~offset % 60, 2)\n );\n });\n }\n\n offset('Z', ':');\n offset('ZZ', '');\n\n // PARSING\n\n addRegexToken('Z', matchShortOffset);\n addRegexToken('ZZ', matchShortOffset);\n addParseToken(['Z', 'ZZ'], function (input, array, config) {\n config._useUTC = true;\n config._tzm = offsetFromString(matchShortOffset, input);\n });\n\n // HELPERS\n\n // timezone chunker\n // '+10:00' > ['10', '00']\n // '-1530' > ['-15', '30']\n var chunkOffset = /([\\+\\-]|\\d\\d)/gi;\n\n function offsetFromString(matcher, string) {\n var matches = (string || '').match(matcher),\n chunk,\n parts,\n minutes;\n\n if (matches === null) {\n return null;\n }\n\n chunk = matches[matches.length - 1] || [];\n parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];\n minutes = +(parts[1] * 60) + toInt(parts[2]);\n\n return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;\n }\n\n // Return a moment from input, that is local/utc/zone equivalent to model.\n function cloneWithOffset(input, model) {\n var res, diff;\n if (model._isUTC) {\n res = model.clone();\n diff =\n (isMoment(input) || isDate(input)\n ? input.valueOf()\n : createLocal(input).valueOf()) - res.valueOf();\n // Use low-level api, because this fn is low-level api.\n res._d.setTime(res._d.valueOf() + diff);\n hooks.updateOffset(res, false);\n return res;\n } else {\n return createLocal(input).local();\n }\n }\n\n function getDateOffset(m) {\n // On Firefox.24 Date#getTimezoneOffset returns a floating point.\n // https://github.com/moment/moment/pull/1871\n return -Math.round(m._d.getTimezoneOffset());\n }\n\n // HOOKS\n\n // This function will be called whenever a moment is mutated.\n // It is intended to keep the offset in sync with the timezone.\n hooks.updateOffset = function () {};\n\n // MOMENTS\n\n // keepLocalTime = true means only change the timezone, without\n // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->\n // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset\n // +0200, so we adjust the time as needed, to be valid.\n //\n // Keeping the time actually adds/subtracts (one hour)\n // from the actual represented time. That is why we call updateOffset\n // a second time. In case it wants us to change the offset again\n // _changeInProgress == true case, then we have to adjust, because\n // there is no such time in the given timezone.\n function getSetOffset(input, keepLocalTime, keepMinutes) {\n var offset = this._offset || 0,\n localAdjust;\n if (!this.isValid()) {\n return input != null ? this : NaN;\n }\n if (input != null) {\n if (typeof input === 'string') {\n input = offsetFromString(matchShortOffset, input);\n if (input === null) {\n return this;\n }\n } else if (Math.abs(input) < 16 && !keepMinutes) {\n input = input * 60;\n }\n if (!this._isUTC && keepLocalTime) {\n localAdjust = getDateOffset(this);\n }\n this._offset = input;\n this._isUTC = true;\n if (localAdjust != null) {\n this.add(localAdjust, 'm');\n }\n if (offset !== input) {\n if (!keepLocalTime || this._changeInProgress) {\n addSubtract(\n this,\n createDuration(input - offset, 'm'),\n 1,\n false\n );\n } else if (!this._changeInProgress) {\n this._changeInProgress = true;\n hooks.updateOffset(this, true);\n this._changeInProgress = null;\n }\n }\n return this;\n } else {\n return this._isUTC ? offset : getDateOffset(this);\n }\n }\n\n function getSetZone(input, keepLocalTime) {\n if (input != null) {\n if (typeof input !== 'string') {\n input = -input;\n }\n\n this.utcOffset(input, keepLocalTime);\n\n return this;\n } else {\n return -this.utcOffset();\n }\n }\n\n function setOffsetToUTC(keepLocalTime) {\n return this.utcOffset(0, keepLocalTime);\n }\n\n function setOffsetToLocal(keepLocalTime) {\n if (this._isUTC) {\n this.utcOffset(0, keepLocalTime);\n this._isUTC = false;\n\n if (keepLocalTime) {\n this.subtract(getDateOffset(this), 'm');\n }\n }\n return this;\n }\n\n function setOffsetToParsedOffset() {\n if (this._tzm != null) {\n this.utcOffset(this._tzm, false, true);\n } else if (typeof this._i === 'string') {\n var tZone = offsetFromString(matchOffset, this._i);\n if (tZone != null) {\n this.utcOffset(tZone);\n } else {\n this.utcOffset(0, true);\n }\n }\n return this;\n }\n\n function hasAlignedHourOffset(input) {\n if (!this.isValid()) {\n return false;\n }\n input = input ? createLocal(input).utcOffset() : 0;\n\n return (this.utcOffset() - input) % 60 === 0;\n }\n\n function isDaylightSavingTime() {\n return (\n this.utcOffset() > this.clone().month(0).utcOffset() ||\n this.utcOffset() > this.clone().month(5).utcOffset()\n );\n }\n\n function isDaylightSavingTimeShifted() {\n if (!isUndefined(this._isDSTShifted)) {\n return this._isDSTShifted;\n }\n\n var c = {},\n other;\n\n copyConfig(c, this);\n c = prepareConfig(c);\n\n if (c._a) {\n other = c._isUTC ? createUTC(c._a) : createLocal(c._a);\n this._isDSTShifted =\n this.isValid() && compareArrays(c._a, other.toArray()) > 0;\n } else {\n this._isDSTShifted = false;\n }\n\n return this._isDSTShifted;\n }\n\n function isLocal() {\n return this.isValid() ? !this._isUTC : false;\n }\n\n function isUtcOffset() {\n return this.isValid() ? this._isUTC : false;\n }\n\n function isUtc() {\n return this.isValid() ? this._isUTC && this._offset === 0 : false;\n }\n\n // ASP.NET json date format regex\n var aspNetRegex = /^(-|\\+)?(?:(\\d*)[. ])?(\\d+):(\\d+)(?::(\\d+)(\\.\\d*)?)?$/,\n // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html\n // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere\n // and further modified to allow for strings containing both week and day\n isoRegex = /^(-|\\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;\n\n function createDuration(input, key) {\n var duration = input,\n // matching against regexp is expensive, do it on demand\n match = null,\n sign,\n ret,\n diffRes;\n\n if (isDuration(input)) {\n duration = {\n ms: input._milliseconds,\n d: input._days,\n M: input._months,\n };\n } else if (isNumber(input) || !isNaN(+input)) {\n duration = {};\n if (key) {\n duration[key] = +input;\n } else {\n duration.milliseconds = +input;\n }\n } else if ((match = aspNetRegex.exec(input))) {\n sign = match[1] === '-' ? -1 : 1;\n duration = {\n y: 0,\n d: toInt(match[DATE]) * sign,\n h: toInt(match[HOUR]) * sign,\n m: toInt(match[MINUTE]) * sign,\n s: toInt(match[SECOND]) * sign,\n ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match\n };\n } else if ((match = isoRegex.exec(input))) {\n sign = match[1] === '-' ? -1 : 1;\n duration = {\n y: parseIso(match[2], sign),\n M: parseIso(match[3], sign),\n w: parseIso(match[4], sign),\n d: parseIso(match[5], sign),\n h: parseIso(match[6], sign),\n m: parseIso(match[7], sign),\n s: parseIso(match[8], sign),\n };\n } else if (duration == null) {\n // checks for null or undefined\n duration = {};\n } else if (\n typeof duration === 'object' &&\n ('from' in duration || 'to' in duration)\n ) {\n diffRes = momentsDifference(\n createLocal(duration.from),\n createLocal(duration.to)\n );\n\n duration = {};\n duration.ms = diffRes.milliseconds;\n duration.M = diffRes.months;\n }\n\n ret = new Duration(duration);\n\n if (isDuration(input) && hasOwnProp(input, '_locale')) {\n ret._locale = input._locale;\n }\n\n if (isDuration(input) && hasOwnProp(input, '_isValid')) {\n ret._isValid = input._isValid;\n }\n\n return ret;\n }\n\n createDuration.fn = Duration.prototype;\n createDuration.invalid = createInvalid$1;\n\n function parseIso(inp, sign) {\n // We'd normally use ~~inp for this, but unfortunately it also\n // converts floats to ints.\n // inp may be undefined, so careful calling replace on it.\n var res = inp && parseFloat(inp.replace(',', '.'));\n // apply sign while we're at it\n return (isNaN(res) ? 0 : res) * sign;\n }\n\n function positiveMomentsDifference(base, other) {\n var res = {};\n\n res.months =\n other.month() - base.month() + (other.year() - base.year()) * 12;\n if (base.clone().add(res.months, 'M').isAfter(other)) {\n --res.months;\n }\n\n res.milliseconds = +other - +base.clone().add(res.months, 'M');\n\n return res;\n }\n\n function momentsDifference(base, other) {\n var res;\n if (!(base.isValid() && other.isValid())) {\n return { milliseconds: 0, months: 0 };\n }\n\n other = cloneWithOffset(other, base);\n if (base.isBefore(other)) {\n res = positiveMomentsDifference(base, other);\n } else {\n res = positiveMomentsDifference(other, base);\n res.milliseconds = -res.milliseconds;\n res.months = -res.months;\n }\n\n return res;\n }\n\n // TODO: remove 'name' arg after deprecation is removed\n function createAdder(direction, name) {\n return function (val, period) {\n var dur, tmp;\n //invert the arguments, but complain about it\n if (period !== null && !isNaN(+period)) {\n deprecateSimple(\n name,\n 'moment().' +\n name +\n '(period, number) is deprecated. Please use moment().' +\n name +\n '(number, period). ' +\n 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'\n );\n tmp = val;\n val = period;\n period = tmp;\n }\n\n dur = createDuration(val, period);\n addSubtract(this, dur, direction);\n return this;\n };\n }\n\n function addSubtract(mom, duration, isAdding, updateOffset) {\n var milliseconds = duration._milliseconds,\n days = absRound(duration._days),\n months = absRound(duration._months);\n\n if (!mom.isValid()) {\n // No op\n return;\n }\n\n updateOffset = updateOffset == null ? true : updateOffset;\n\n if (months) {\n setMonth(mom, get(mom, 'Month') + months * isAdding);\n }\n if (days) {\n set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);\n }\n if (milliseconds) {\n mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);\n }\n if (updateOffset) {\n hooks.updateOffset(mom, days || months);\n }\n }\n\n var add = createAdder(1, 'add'),\n subtract = createAdder(-1, 'subtract');\n\n function isString(input) {\n return typeof input === 'string' || input instanceof String;\n }\n\n // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined\n function isMomentInput(input) {\n return (\n isMoment(input) ||\n isDate(input) ||\n isString(input) ||\n isNumber(input) ||\n isNumberOrStringArray(input) ||\n isMomentInputObject(input) ||\n input === null ||\n input === undefined\n );\n }\n\n function isMomentInputObject(input) {\n var objectTest = isObject(input) && !isObjectEmpty(input),\n propertyTest = false,\n properties = [\n 'years',\n 'year',\n 'y',\n 'months',\n 'month',\n 'M',\n 'days',\n 'day',\n 'd',\n 'dates',\n 'date',\n 'D',\n 'hours',\n 'hour',\n 'h',\n 'minutes',\n 'minute',\n 'm',\n 'seconds',\n 'second',\n 's',\n 'milliseconds',\n 'millisecond',\n 'ms',\n ],\n i,\n property;\n\n for (i = 0; i < properties.length; i += 1) {\n property = properties[i];\n propertyTest = propertyTest || hasOwnProp(input, property);\n }\n\n return objectTest && propertyTest;\n }\n\n function isNumberOrStringArray(input) {\n var arrayTest = isArray(input),\n dataTypeTest = false;\n if (arrayTest) {\n dataTypeTest =\n input.filter(function (item) {\n return !isNumber(item) && isString(input);\n }).length === 0;\n }\n return arrayTest && dataTypeTest;\n }\n\n function isCalendarSpec(input) {\n var objectTest = isObject(input) && !isObjectEmpty(input),\n propertyTest = false,\n properties = [\n 'sameDay',\n 'nextDay',\n 'lastDay',\n 'nextWeek',\n 'lastWeek',\n 'sameElse',\n ],\n i,\n property;\n\n for (i = 0; i < properties.length; i += 1) {\n property = properties[i];\n propertyTest = propertyTest || hasOwnProp(input, property);\n }\n\n return objectTest && propertyTest;\n }\n\n function getCalendarFormat(myMoment, now) {\n var diff = myMoment.diff(now, 'days', true);\n return diff < -6\n ? 'sameElse'\n : diff < -1\n ? 'lastWeek'\n : diff < 0\n ? 'lastDay'\n : diff < 1\n ? 'sameDay'\n : diff < 2\n ? 'nextDay'\n : diff < 7\n ? 'nextWeek'\n : 'sameElse';\n }\n\n function calendar$1(time, formats) {\n // Support for single parameter, formats only overload to the calendar function\n if (arguments.length === 1) {\n if (!arguments[0]) {\n time = undefined;\n formats = undefined;\n } else if (isMomentInput(arguments[0])) {\n time = arguments[0];\n formats = undefined;\n } else if (isCalendarSpec(arguments[0])) {\n formats = arguments[0];\n time = undefined;\n }\n }\n // We want to compare the start of today, vs this.\n // Getting start-of-today depends on whether we're local/utc/offset or not.\n var now = time || createLocal(),\n sod = cloneWithOffset(now, this).startOf('day'),\n format = hooks.calendarFormat(this, sod) || 'sameElse',\n output =\n formats &&\n (isFunction(formats[format])\n ? formats[format].call(this, now)\n : formats[format]);\n\n return this.format(\n output || this.localeData().calendar(format, this, createLocal(now))\n );\n }\n\n function clone() {\n return new Moment(this);\n }\n\n function isAfter(input, units) {\n var localInput = isMoment(input) ? input : createLocal(input);\n if (!(this.isValid() && localInput.isValid())) {\n return false;\n }\n units = normalizeUnits(units) || 'millisecond';\n if (units === 'millisecond') {\n return this.valueOf() > localInput.valueOf();\n } else {\n return localInput.valueOf() < this.clone().startOf(units).valueOf();\n }\n }\n\n function isBefore(input, units) {\n var localInput = isMoment(input) ? input : createLocal(input);\n if (!(this.isValid() && localInput.isValid())) {\n return false;\n }\n units = normalizeUnits(units) || 'millisecond';\n if (units === 'millisecond') {\n return this.valueOf() < localInput.valueOf();\n } else {\n return this.clone().endOf(units).valueOf() < localInput.valueOf();\n }\n }\n\n function isBetween(from, to, units, inclusivity) {\n var localFrom = isMoment(from) ? from : createLocal(from),\n localTo = isMoment(to) ? to : createLocal(to);\n if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {\n return false;\n }\n inclusivity = inclusivity || '()';\n return (\n (inclusivity[0] === '('\n ? this.isAfter(localFrom, units)\n : !this.isBefore(localFrom, units)) &&\n (inclusivity[1] === ')'\n ? this.isBefore(localTo, units)\n : !this.isAfter(localTo, units))\n );\n }\n\n function isSame(input, units) {\n var localInput = isMoment(input) ? input : createLocal(input),\n inputMs;\n if (!(this.isValid() && localInput.isValid())) {\n return false;\n }\n units = normalizeUnits(units) || 'millisecond';\n if (units === 'millisecond') {\n return this.valueOf() === localInput.valueOf();\n } else {\n inputMs = localInput.valueOf();\n return (\n this.clone().startOf(units).valueOf() <= inputMs &&\n inputMs <= this.clone().endOf(units).valueOf()\n );\n }\n }\n\n function isSameOrAfter(input, units) {\n return this.isSame(input, units) || this.isAfter(input, units);\n }\n\n function isSameOrBefore(input, units) {\n return this.isSame(input, units) || this.isBefore(input, units);\n }\n\n function diff(input, units, asFloat) {\n var that, zoneDelta, output;\n\n if (!this.isValid()) {\n return NaN;\n }\n\n that = cloneWithOffset(input, this);\n\n if (!that.isValid()) {\n return NaN;\n }\n\n zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;\n\n units = normalizeUnits(units);\n\n switch (units) {\n case 'year':\n output = monthDiff(this, that) / 12;\n break;\n case 'month':\n output = monthDiff(this, that);\n break;\n case 'quarter':\n output = monthDiff(this, that) / 3;\n break;\n case 'second':\n output = (this - that) / 1e3;\n break; // 1000\n case 'minute':\n output = (this - that) / 6e4;\n break; // 1000 * 60\n case 'hour':\n output = (this - that) / 36e5;\n break; // 1000 * 60 * 60\n case 'day':\n output = (this - that - zoneDelta) / 864e5;\n break; // 1000 * 60 * 60 * 24, negate dst\n case 'week':\n output = (this - that - zoneDelta) / 6048e5;\n break; // 1000 * 60 * 60 * 24 * 7, negate dst\n default:\n output = this - that;\n }\n\n return asFloat ? output : absFloor(output);\n }\n\n function monthDiff(a, b) {\n if (a.date() < b.date()) {\n // end-of-month calculations work correct when the start month has more\n // days than the end month.\n return -monthDiff(b, a);\n }\n // difference in months\n var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),\n // b is in (anchor - 1 month, anchor + 1 month)\n anchor = a.clone().add(wholeMonthDiff, 'months'),\n anchor2,\n adjust;\n\n if (b - anchor < 0) {\n anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');\n // linear across the month\n adjust = (b - anchor) / (anchor - anchor2);\n } else {\n anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');\n // linear across the month\n adjust = (b - anchor) / (anchor2 - anchor);\n }\n\n //check for negative zero, return zero if negative zero\n return -(wholeMonthDiff + adjust) || 0;\n }\n\n hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';\n hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';\n\n function toString() {\n return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');\n }\n\n function toISOString(keepOffset) {\n if (!this.isValid()) {\n return null;\n }\n var utc = keepOffset !== true,\n m = utc ? this.clone().utc() : this;\n if (m.year() < 0 || m.year() > 9999) {\n return formatMoment(\n m,\n utc\n ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'\n : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'\n );\n }\n if (isFunction(Date.prototype.toISOString)) {\n // native implementation is ~50x faster, use it when we can\n if (utc) {\n return this.toDate().toISOString();\n } else {\n return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)\n .toISOString()\n .replace('Z', formatMoment(m, 'Z'));\n }\n }\n return formatMoment(\n m,\n utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'\n );\n }\n\n /**\n * Return a human readable representation of a moment that can\n * also be evaluated to get a new moment which is the same\n *\n * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects\n */\n function inspect() {\n if (!this.isValid()) {\n return 'moment.invalid(/* ' + this._i + ' */)';\n }\n var func = 'moment',\n zone = '',\n prefix,\n year,\n datetime,\n suffix;\n if (!this.isLocal()) {\n func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';\n zone = 'Z';\n }\n prefix = '[' + func + '(\"]';\n year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';\n datetime = '-MM-DD[T]HH:mm:ss.SSS';\n suffix = zone + '[\")]';\n\n return this.format(prefix + year + datetime + suffix);\n }\n\n function format(inputString) {\n if (!inputString) {\n inputString = this.isUtc()\n ? hooks.defaultFormatUtc\n : hooks.defaultFormat;\n }\n var output = formatMoment(this, inputString);\n return this.localeData().postformat(output);\n }\n\n function from(time, withoutSuffix) {\n if (\n this.isValid() &&\n ((isMoment(time) && time.isValid()) || createLocal(time).isValid())\n ) {\n return createDuration({ to: this, from: time })\n .locale(this.locale())\n .humanize(!withoutSuffix);\n } else {\n return this.localeData().invalidDate();\n }\n }\n\n function fromNow(withoutSuffix) {\n return this.from(createLocal(), withoutSuffix);\n }\n\n function to(time, withoutSuffix) {\n if (\n this.isValid() &&\n ((isMoment(time) && time.isValid()) || createLocal(time).isValid())\n ) {\n return createDuration({ from: this, to: time })\n .locale(this.locale())\n .humanize(!withoutSuffix);\n } else {\n return this.localeData().invalidDate();\n }\n }\n\n function toNow(withoutSuffix) {\n return this.to(createLocal(), withoutSuffix);\n }\n\n // If passed a locale key, it will set the locale for this\n // instance. Otherwise, it will return the locale configuration\n // variables for this instance.\n function locale(key) {\n var newLocaleData;\n\n if (key === undefined) {\n return this._locale._abbr;\n } else {\n newLocaleData = getLocale(key);\n if (newLocaleData != null) {\n this._locale = newLocaleData;\n }\n return this;\n }\n }\n\n var lang = deprecate(\n 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',\n function (key) {\n if (key === undefined) {\n return this.localeData();\n } else {\n return this.locale(key);\n }\n }\n );\n\n function localeData() {\n return this._locale;\n }\n\n var MS_PER_SECOND = 1000,\n MS_PER_MINUTE = 60 * MS_PER_SECOND,\n MS_PER_HOUR = 60 * MS_PER_MINUTE,\n MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;\n\n // actual modulo - handles negative numbers (for dates before 1970):\n function mod$1(dividend, divisor) {\n return ((dividend % divisor) + divisor) % divisor;\n }\n\n function localStartOfDate(y, m, d) {\n // the date constructor remaps years 0-99 to 1900-1999\n if (y < 100 && y >= 0) {\n // preserve leap years using a full 400 year cycle, then reset\n return new Date(y + 400, m, d) - MS_PER_400_YEARS;\n } else {\n return new Date(y, m, d).valueOf();\n }\n }\n\n function utcStartOfDate(y, m, d) {\n // Date.UTC remaps years 0-99 to 1900-1999\n if (y < 100 && y >= 0) {\n // preserve leap years using a full 400 year cycle, then reset\n return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;\n } else {\n return Date.UTC(y, m, d);\n }\n }\n\n function startOf(units) {\n var time, startOfDate;\n units = normalizeUnits(units);\n if (units === undefined || units === 'millisecond' || !this.isValid()) {\n return this;\n }\n\n startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;\n\n switch (units) {\n case 'year':\n time = startOfDate(this.year(), 0, 1);\n break;\n case 'quarter':\n time = startOfDate(\n this.year(),\n this.month() - (this.month() % 3),\n 1\n );\n break;\n case 'month':\n time = startOfDate(this.year(), this.month(), 1);\n break;\n case 'week':\n time = startOfDate(\n this.year(),\n this.month(),\n this.date() - this.weekday()\n );\n break;\n case 'isoWeek':\n time = startOfDate(\n this.year(),\n this.month(),\n this.date() - (this.isoWeekday() - 1)\n );\n break;\n case 'day':\n case 'date':\n time = startOfDate(this.year(), this.month(), this.date());\n break;\n case 'hour':\n time = this._d.valueOf();\n time -= mod$1(\n time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),\n MS_PER_HOUR\n );\n break;\n case 'minute':\n time = this._d.valueOf();\n time -= mod$1(time, MS_PER_MINUTE);\n break;\n case 'second':\n time = this._d.valueOf();\n time -= mod$1(time, MS_PER_SECOND);\n break;\n }\n\n this._d.setTime(time);\n hooks.updateOffset(this, true);\n return this;\n }\n\n function endOf(units) {\n var time, startOfDate;\n units = normalizeUnits(units);\n if (units === undefined || units === 'millisecond' || !this.isValid()) {\n return this;\n }\n\n startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;\n\n switch (units) {\n case 'year':\n time = startOfDate(this.year() + 1, 0, 1) - 1;\n break;\n case 'quarter':\n time =\n startOfDate(\n this.year(),\n this.month() - (this.month() % 3) + 3,\n 1\n ) - 1;\n break;\n case 'month':\n time = startOfDate(this.year(), this.month() + 1, 1) - 1;\n break;\n case 'week':\n time =\n startOfDate(\n this.year(),\n this.month(),\n this.date() - this.weekday() + 7\n ) - 1;\n break;\n case 'isoWeek':\n time =\n startOfDate(\n this.year(),\n this.month(),\n this.date() - (this.isoWeekday() - 1) + 7\n ) - 1;\n break;\n case 'day':\n case 'date':\n time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;\n break;\n case 'hour':\n time = this._d.valueOf();\n time +=\n MS_PER_HOUR -\n mod$1(\n time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),\n MS_PER_HOUR\n ) -\n 1;\n break;\n case 'minute':\n time = this._d.valueOf();\n time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;\n break;\n case 'second':\n time = this._d.valueOf();\n time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;\n break;\n }\n\n this._d.setTime(time);\n hooks.updateOffset(this, true);\n return this;\n }\n\n function valueOf() {\n return this._d.valueOf() - (this._offset || 0) * 60000;\n }\n\n function unix() {\n return Math.floor(this.valueOf() / 1000);\n }\n\n function toDate() {\n return new Date(this.valueOf());\n }\n\n function toArray() {\n var m = this;\n return [\n m.year(),\n m.month(),\n m.date(),\n m.hour(),\n m.minute(),\n m.second(),\n m.millisecond(),\n ];\n }\n\n function toObject() {\n var m = this;\n return {\n years: m.year(),\n months: m.month(),\n date: m.date(),\n hours: m.hours(),\n minutes: m.minutes(),\n seconds: m.seconds(),\n milliseconds: m.milliseconds(),\n };\n }\n\n function toJSON() {\n // new Date(NaN).toJSON() === null\n return this.isValid() ? this.toISOString() : null;\n }\n\n function isValid$2() {\n return isValid(this);\n }\n\n function parsingFlags() {\n return extend({}, getParsingFlags(this));\n }\n\n function invalidAt() {\n return getParsingFlags(this).overflow;\n }\n\n function creationData() {\n return {\n input: this._i,\n format: this._f,\n locale: this._locale,\n isUTC: this._isUTC,\n strict: this._strict,\n };\n }\n\n addFormatToken('N', 0, 0, 'eraAbbr');\n addFormatToken('NN', 0, 0, 'eraAbbr');\n addFormatToken('NNN', 0, 0, 'eraAbbr');\n addFormatToken('NNNN', 0, 0, 'eraName');\n addFormatToken('NNNNN', 0, 0, 'eraNarrow');\n\n addFormatToken('y', ['y', 1], 'yo', 'eraYear');\n addFormatToken('y', ['yy', 2], 0, 'eraYear');\n addFormatToken('y', ['yyy', 3], 0, 'eraYear');\n addFormatToken('y', ['yyyy', 4], 0, 'eraYear');\n\n addRegexToken('N', matchEraAbbr);\n addRegexToken('NN', matchEraAbbr);\n addRegexToken('NNN', matchEraAbbr);\n addRegexToken('NNNN', matchEraName);\n addRegexToken('NNNNN', matchEraNarrow);\n\n addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function (\n input,\n array,\n config,\n token\n ) {\n var era = config._locale.erasParse(input, token, config._strict);\n if (era) {\n getParsingFlags(config).era = era;\n } else {\n getParsingFlags(config).invalidEra = input;\n }\n });\n\n addRegexToken('y', matchUnsigned);\n addRegexToken('yy', matchUnsigned);\n addRegexToken('yyy', matchUnsigned);\n addRegexToken('yyyy', matchUnsigned);\n addRegexToken('yo', matchEraYearOrdinal);\n\n addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);\n addParseToken(['yo'], function (input, array, config, token) {\n var match;\n if (config._locale._eraYearOrdinalRegex) {\n match = input.match(config._locale._eraYearOrdinalRegex);\n }\n\n if (config._locale.eraYearOrdinalParse) {\n array[YEAR] = config._locale.eraYearOrdinalParse(input, match);\n } else {\n array[YEAR] = parseInt(input, 10);\n }\n });\n\n function localeEras(m, format) {\n var i,\n l,\n date,\n eras = this._eras || getLocale('en')._eras;\n for (i = 0, l = eras.length; i < l; ++i) {\n switch (typeof eras[i].since) {\n case 'string':\n // truncate time\n date = hooks(eras[i].since).startOf('day');\n eras[i].since = date.valueOf();\n break;\n }\n\n switch (typeof eras[i].until) {\n case 'undefined':\n eras[i].until = +Infinity;\n break;\n case 'string':\n // truncate time\n date = hooks(eras[i].until).startOf('day').valueOf();\n eras[i].until = date.valueOf();\n break;\n }\n }\n return eras;\n }\n\n function localeErasParse(eraName, format, strict) {\n var i,\n l,\n eras = this.eras(),\n name,\n abbr,\n narrow;\n eraName = eraName.toUpperCase();\n\n for (i = 0, l = eras.length; i < l; ++i) {\n name = eras[i].name.toUpperCase();\n abbr = eras[i].abbr.toUpperCase();\n narrow = eras[i].narrow.toUpperCase();\n\n if (strict) {\n switch (format) {\n case 'N':\n case 'NN':\n case 'NNN':\n if (abbr === eraName) {\n return eras[i];\n }\n break;\n\n case 'NNNN':\n if (name === eraName) {\n return eras[i];\n }\n break;\n\n case 'NNNNN':\n if (narrow === eraName) {\n return eras[i];\n }\n break;\n }\n } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {\n return eras[i];\n }\n }\n }\n\n function localeErasConvertYear(era, year) {\n var dir = era.since <= era.until ? +1 : -1;\n if (year === undefined) {\n return hooks(era.since).year();\n } else {\n return hooks(era.since).year() + (year - era.offset) * dir;\n }\n }\n\n function getEraName() {\n var i,\n l,\n val,\n eras = this.localeData().eras();\n for (i = 0, l = eras.length; i < l; ++i) {\n // truncate time\n val = this.clone().startOf('day').valueOf();\n\n if (eras[i].since <= val && val <= eras[i].until) {\n return eras[i].name;\n }\n if (eras[i].until <= val && val <= eras[i].since) {\n return eras[i].name;\n }\n }\n\n return '';\n }\n\n function getEraNarrow() {\n var i,\n l,\n val,\n eras = this.localeData().eras();\n for (i = 0, l = eras.length; i < l; ++i) {\n // truncate time\n val = this.clone().startOf('day').valueOf();\n\n if (eras[i].since <= val && val <= eras[i].until) {\n return eras[i].narrow;\n }\n if (eras[i].until <= val && val <= eras[i].since) {\n return eras[i].narrow;\n }\n }\n\n return '';\n }\n\n function getEraAbbr() {\n var i,\n l,\n val,\n eras = this.localeData().eras();\n for (i = 0, l = eras.length; i < l; ++i) {\n // truncate time\n val = this.clone().startOf('day').valueOf();\n\n if (eras[i].since <= val && val <= eras[i].until) {\n return eras[i].abbr;\n }\n if (eras[i].until <= val && val <= eras[i].since) {\n return eras[i].abbr;\n }\n }\n\n return '';\n }\n\n function getEraYear() {\n var i,\n l,\n dir,\n val,\n eras = this.localeData().eras();\n for (i = 0, l = eras.length; i < l; ++i) {\n dir = eras[i].since <= eras[i].until ? +1 : -1;\n\n // truncate time\n val = this.clone().startOf('day').valueOf();\n\n if (\n (eras[i].since <= val && val <= eras[i].until) ||\n (eras[i].until <= val && val <= eras[i].since)\n ) {\n return (\n (this.year() - hooks(eras[i].since).year()) * dir +\n eras[i].offset\n );\n }\n }\n\n return this.year();\n }\n\n function erasNameRegex(isStrict) {\n if (!hasOwnProp(this, '_erasNameRegex')) {\n computeErasParse.call(this);\n }\n return isStrict ? this._erasNameRegex : this._erasRegex;\n }\n\n function erasAbbrRegex(isStrict) {\n if (!hasOwnProp(this, '_erasAbbrRegex')) {\n computeErasParse.call(this);\n }\n return isStrict ? this._erasAbbrRegex : this._erasRegex;\n }\n\n function erasNarrowRegex(isStrict) {\n if (!hasOwnProp(this, '_erasNarrowRegex')) {\n computeErasParse.call(this);\n }\n return isStrict ? this._erasNarrowRegex : this._erasRegex;\n }\n\n function matchEraAbbr(isStrict, locale) {\n return locale.erasAbbrRegex(isStrict);\n }\n\n function matchEraName(isStrict, locale) {\n return locale.erasNameRegex(isStrict);\n }\n\n function matchEraNarrow(isStrict, locale) {\n return locale.erasNarrowRegex(isStrict);\n }\n\n function matchEraYearOrdinal(isStrict, locale) {\n return locale._eraYearOrdinalRegex || matchUnsigned;\n }\n\n function computeErasParse() {\n var abbrPieces = [],\n namePieces = [],\n narrowPieces = [],\n mixedPieces = [],\n i,\n l,\n eras = this.eras();\n\n for (i = 0, l = eras.length; i < l; ++i) {\n namePieces.push(regexEscape(eras[i].name));\n abbrPieces.push(regexEscape(eras[i].abbr));\n narrowPieces.push(regexEscape(eras[i].narrow));\n\n mixedPieces.push(regexEscape(eras[i].name));\n mixedPieces.push(regexEscape(eras[i].abbr));\n mixedPieces.push(regexEscape(eras[i].narrow));\n }\n\n this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');\n this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');\n this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');\n this._erasNarrowRegex = new RegExp(\n '^(' + narrowPieces.join('|') + ')',\n 'i'\n );\n }\n\n // FORMATTING\n\n addFormatToken(0, ['gg', 2], 0, function () {\n return this.weekYear() % 100;\n });\n\n addFormatToken(0, ['GG', 2], 0, function () {\n return this.isoWeekYear() % 100;\n });\n\n function addWeekYearFormatToken(token, getter) {\n addFormatToken(0, [token, token.length], 0, getter);\n }\n\n addWeekYearFormatToken('gggg', 'weekYear');\n addWeekYearFormatToken('ggggg', 'weekYear');\n addWeekYearFormatToken('GGGG', 'isoWeekYear');\n addWeekYearFormatToken('GGGGG', 'isoWeekYear');\n\n // ALIASES\n\n addUnitAlias('weekYear', 'gg');\n addUnitAlias('isoWeekYear', 'GG');\n\n // PRIORITY\n\n addUnitPriority('weekYear', 1);\n addUnitPriority('isoWeekYear', 1);\n\n // PARSING\n\n addRegexToken('G', matchSigned);\n addRegexToken('g', matchSigned);\n addRegexToken('GG', match1to2, match2);\n addRegexToken('gg', match1to2, match2);\n addRegexToken('GGGG', match1to4, match4);\n addRegexToken('gggg', match1to4, match4);\n addRegexToken('GGGGG', match1to6, match6);\n addRegexToken('ggggg', match1to6, match6);\n\n addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (\n input,\n week,\n config,\n token\n ) {\n week[token.substr(0, 2)] = toInt(input);\n });\n\n addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {\n week[token] = hooks.parseTwoDigitYear(input);\n });\n\n // MOMENTS\n\n function getSetWeekYear(input) {\n return getSetWeekYearHelper.call(\n this,\n input,\n this.week(),\n this.weekday(),\n this.localeData()._week.dow,\n this.localeData()._week.doy\n );\n }\n\n function getSetISOWeekYear(input) {\n return getSetWeekYearHelper.call(\n this,\n input,\n this.isoWeek(),\n this.isoWeekday(),\n 1,\n 4\n );\n }\n\n function getISOWeeksInYear() {\n return weeksInYear(this.year(), 1, 4);\n }\n\n function getISOWeeksInISOWeekYear() {\n return weeksInYear(this.isoWeekYear(), 1, 4);\n }\n\n function getWeeksInYear() {\n var weekInfo = this.localeData()._week;\n return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);\n }\n\n function getWeeksInWeekYear() {\n var weekInfo = this.localeData()._week;\n return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);\n }\n\n function getSetWeekYearHelper(input, week, weekday, dow, doy) {\n var weeksTarget;\n if (input == null) {\n return weekOfYear(this, dow, doy).year;\n } else {\n weeksTarget = weeksInYear(input, dow, doy);\n if (week > weeksTarget) {\n week = weeksTarget;\n }\n return setWeekAll.call(this, input, week, weekday, dow, doy);\n }\n }\n\n function setWeekAll(weekYear, week, weekday, dow, doy) {\n var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),\n date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);\n\n this.year(date.getUTCFullYear());\n this.month(date.getUTCMonth());\n this.date(date.getUTCDate());\n return this;\n }\n\n // FORMATTING\n\n addFormatToken('Q', 0, 'Qo', 'quarter');\n\n // ALIASES\n\n addUnitAlias('quarter', 'Q');\n\n // PRIORITY\n\n addUnitPriority('quarter', 7);\n\n // PARSING\n\n addRegexToken('Q', match1);\n addParseToken('Q', function (input, array) {\n array[MONTH] = (toInt(input) - 1) * 3;\n });\n\n // MOMENTS\n\n function getSetQuarter(input) {\n return input == null\n ? Math.ceil((this.month() + 1) / 3)\n : this.month((input - 1) * 3 + (this.month() % 3));\n }\n\n // FORMATTING\n\n addFormatToken('D', ['DD', 2], 'Do', 'date');\n\n // ALIASES\n\n addUnitAlias('date', 'D');\n\n // PRIORITY\n addUnitPriority('date', 9);\n\n // PARSING\n\n addRegexToken('D', match1to2);\n addRegexToken('DD', match1to2, match2);\n addRegexToken('Do', function (isStrict, locale) {\n // TODO: Remove \"ordinalParse\" fallback in next major release.\n return isStrict\n ? locale._dayOfMonthOrdinalParse || locale._ordinalParse\n : locale._dayOfMonthOrdinalParseLenient;\n });\n\n addParseToken(['D', 'DD'], DATE);\n addParseToken('Do', function (input, array) {\n array[DATE] = toInt(input.match(match1to2)[0]);\n });\n\n // MOMENTS\n\n var getSetDayOfMonth = makeGetSet('Date', true);\n\n // FORMATTING\n\n addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');\n\n // ALIASES\n\n addUnitAlias('dayOfYear', 'DDD');\n\n // PRIORITY\n addUnitPriority('dayOfYear', 4);\n\n // PARSING\n\n addRegexToken('DDD', match1to3);\n addRegexToken('DDDD', match3);\n addParseToken(['DDD', 'DDDD'], function (input, array, config) {\n config._dayOfYear = toInt(input);\n });\n\n // HELPERS\n\n // MOMENTS\n\n function getSetDayOfYear(input) {\n var dayOfYear =\n Math.round(\n (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5\n ) + 1;\n return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');\n }\n\n // FORMATTING\n\n addFormatToken('m', ['mm', 2], 0, 'minute');\n\n // ALIASES\n\n addUnitAlias('minute', 'm');\n\n // PRIORITY\n\n addUnitPriority('minute', 14);\n\n // PARSING\n\n addRegexToken('m', match1to2);\n addRegexToken('mm', match1to2, match2);\n addParseToken(['m', 'mm'], MINUTE);\n\n // MOMENTS\n\n var getSetMinute = makeGetSet('Minutes', false);\n\n // FORMATTING\n\n addFormatToken('s', ['ss', 2], 0, 'second');\n\n // ALIASES\n\n addUnitAlias('second', 's');\n\n // PRIORITY\n\n addUnitPriority('second', 15);\n\n // PARSING\n\n addRegexToken('s', match1to2);\n addRegexToken('ss', match1to2, match2);\n addParseToken(['s', 'ss'], SECOND);\n\n // MOMENTS\n\n var getSetSecond = makeGetSet('Seconds', false);\n\n // FORMATTING\n\n addFormatToken('S', 0, 0, function () {\n return ~~(this.millisecond() / 100);\n });\n\n addFormatToken(0, ['SS', 2], 0, function () {\n return ~~(this.millisecond() / 10);\n });\n\n addFormatToken(0, ['SSS', 3], 0, 'millisecond');\n addFormatToken(0, ['SSSS', 4], 0, function () {\n return this.millisecond() * 10;\n });\n addFormatToken(0, ['SSSSS', 5], 0, function () {\n return this.millisecond() * 100;\n });\n addFormatToken(0, ['SSSSSS', 6], 0, function () {\n return this.millisecond() * 1000;\n });\n addFormatToken(0, ['SSSSSSS', 7], 0, function () {\n return this.millisecond() * 10000;\n });\n addFormatToken(0, ['SSSSSSSS', 8], 0, function () {\n return this.millisecond() * 100000;\n });\n addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {\n return this.millisecond() * 1000000;\n });\n\n // ALIASES\n\n addUnitAlias('millisecond', 'ms');\n\n // PRIORITY\n\n addUnitPriority('millisecond', 16);\n\n // PARSING\n\n addRegexToken('S', match1to3, match1);\n addRegexToken('SS', match1to3, match2);\n addRegexToken('SSS', match1to3, match3);\n\n var token, getSetMillisecond;\n for (token = 'SSSS'; token.length <= 9; token += 'S') {\n addRegexToken(token, matchUnsigned);\n }\n\n function parseMs(input, array) {\n array[MILLISECOND] = toInt(('0.' + input) * 1000);\n }\n\n for (token = 'S'; token.length <= 9; token += 'S') {\n addParseToken(token, parseMs);\n }\n\n getSetMillisecond = makeGetSet('Milliseconds', false);\n\n // FORMATTING\n\n addFormatToken('z', 0, 0, 'zoneAbbr');\n addFormatToken('zz', 0, 0, 'zoneName');\n\n // MOMENTS\n\n function getZoneAbbr() {\n return this._isUTC ? 'UTC' : '';\n }\n\n function getZoneName() {\n return this._isUTC ? 'Coordinated Universal Time' : '';\n }\n\n var proto = Moment.prototype;\n\n proto.add = add;\n proto.calendar = calendar$1;\n proto.clone = clone;\n proto.diff = diff;\n proto.endOf = endOf;\n proto.format = format;\n proto.from = from;\n proto.fromNow = fromNow;\n proto.to = to;\n proto.toNow = toNow;\n proto.get = stringGet;\n proto.invalidAt = invalidAt;\n proto.isAfter = isAfter;\n proto.isBefore = isBefore;\n proto.isBetween = isBetween;\n proto.isSame = isSame;\n proto.isSameOrAfter = isSameOrAfter;\n proto.isSameOrBefore = isSameOrBefore;\n proto.isValid = isValid$2;\n proto.lang = lang;\n proto.locale = locale;\n proto.localeData = localeData;\n proto.max = prototypeMax;\n proto.min = prototypeMin;\n proto.parsingFlags = parsingFlags;\n proto.set = stringSet;\n proto.startOf = startOf;\n proto.subtract = subtract;\n proto.toArray = toArray;\n proto.toObject = toObject;\n proto.toDate = toDate;\n proto.toISOString = toISOString;\n proto.inspect = inspect;\n if (typeof Symbol !== 'undefined' && Symbol.for != null) {\n proto[Symbol.for('nodejs.util.inspect.custom')] = function () {\n return 'Moment<' + this.format() + '>';\n };\n }\n proto.toJSON = toJSON;\n proto.toString = toString;\n proto.unix = unix;\n proto.valueOf = valueOf;\n proto.creationData = creationData;\n proto.eraName = getEraName;\n proto.eraNarrow = getEraNarrow;\n proto.eraAbbr = getEraAbbr;\n proto.eraYear = getEraYear;\n proto.year = getSetYear;\n proto.isLeapYear = getIsLeapYear;\n proto.weekYear = getSetWeekYear;\n proto.isoWeekYear = getSetISOWeekYear;\n proto.quarter = proto.quarters = getSetQuarter;\n proto.month = getSetMonth;\n proto.daysInMonth = getDaysInMonth;\n proto.week = proto.weeks = getSetWeek;\n proto.isoWeek = proto.isoWeeks = getSetISOWeek;\n proto.weeksInYear = getWeeksInYear;\n proto.weeksInWeekYear = getWeeksInWeekYear;\n proto.isoWeeksInYear = getISOWeeksInYear;\n proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;\n proto.date = getSetDayOfMonth;\n proto.day = proto.days = getSetDayOfWeek;\n proto.weekday = getSetLocaleDayOfWeek;\n proto.isoWeekday = getSetISODayOfWeek;\n proto.dayOfYear = getSetDayOfYear;\n proto.hour = proto.hours = getSetHour;\n proto.minute = proto.minutes = getSetMinute;\n proto.second = proto.seconds = getSetSecond;\n proto.millisecond = proto.milliseconds = getSetMillisecond;\n proto.utcOffset = getSetOffset;\n proto.utc = setOffsetToUTC;\n proto.local = setOffsetToLocal;\n proto.parseZone = setOffsetToParsedOffset;\n proto.hasAlignedHourOffset = hasAlignedHourOffset;\n proto.isDST = isDaylightSavingTime;\n proto.isLocal = isLocal;\n proto.isUtcOffset = isUtcOffset;\n proto.isUtc = isUtc;\n proto.isUTC = isUtc;\n proto.zoneAbbr = getZoneAbbr;\n proto.zoneName = getZoneName;\n proto.dates = deprecate(\n 'dates accessor is deprecated. Use date instead.',\n getSetDayOfMonth\n );\n proto.months = deprecate(\n 'months accessor is deprecated. Use month instead',\n getSetMonth\n );\n proto.years = deprecate(\n 'years accessor is deprecated. Use year instead',\n getSetYear\n );\n proto.zone = deprecate(\n 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',\n getSetZone\n );\n proto.isDSTShifted = deprecate(\n 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',\n isDaylightSavingTimeShifted\n );\n\n function createUnix(input) {\n return createLocal(input * 1000);\n }\n\n function createInZone() {\n return createLocal.apply(null, arguments).parseZone();\n }\n\n function preParsePostFormat(string) {\n return string;\n }\n\n var proto$1 = Locale.prototype;\n\n proto$1.calendar = calendar;\n proto$1.longDateFormat = longDateFormat;\n proto$1.invalidDate = invalidDate;\n proto$1.ordinal = ordinal;\n proto$1.preparse = preParsePostFormat;\n proto$1.postformat = preParsePostFormat;\n proto$1.relativeTime = relativeTime;\n proto$1.pastFuture = pastFuture;\n proto$1.set = set;\n proto$1.eras = localeEras;\n proto$1.erasParse = localeErasParse;\n proto$1.erasConvertYear = localeErasConvertYear;\n proto$1.erasAbbrRegex = erasAbbrRegex;\n proto$1.erasNameRegex = erasNameRegex;\n proto$1.erasNarrowRegex = erasNarrowRegex;\n\n proto$1.months = localeMonths;\n proto$1.monthsShort = localeMonthsShort;\n proto$1.monthsParse = localeMonthsParse;\n proto$1.monthsRegex = monthsRegex;\n proto$1.monthsShortRegex = monthsShortRegex;\n proto$1.week = localeWeek;\n proto$1.firstDayOfYear = localeFirstDayOfYear;\n proto$1.firstDayOfWeek = localeFirstDayOfWeek;\n\n proto$1.weekdays = localeWeekdays;\n proto$1.weekdaysMin = localeWeekdaysMin;\n proto$1.weekdaysShort = localeWeekdaysShort;\n proto$1.weekdaysParse = localeWeekdaysParse;\n\n proto$1.weekdaysRegex = weekdaysRegex;\n proto$1.weekdaysShortRegex = weekdaysShortRegex;\n proto$1.weekdaysMinRegex = weekdaysMinRegex;\n\n proto$1.isPM = localeIsPM;\n proto$1.meridiem = localeMeridiem;\n\n function get$1(format, index, field, setter) {\n var locale = getLocale(),\n utc = createUTC().set(setter, index);\n return locale[field](utc, format);\n }\n\n function listMonthsImpl(format, index, field) {\n if (isNumber(format)) {\n index = format;\n format = undefined;\n }\n\n format = format || '';\n\n if (index != null) {\n return get$1(format, index, field, 'month');\n }\n\n var i,\n out = [];\n for (i = 0; i < 12; i++) {\n out[i] = get$1(format, i, field, 'month');\n }\n return out;\n }\n\n // ()\n // (5)\n // (fmt, 5)\n // (fmt)\n // (true)\n // (true, 5)\n // (true, fmt, 5)\n // (true, fmt)\n function listWeekdaysImpl(localeSorted, format, index, field) {\n if (typeof localeSorted === 'boolean') {\n if (isNumber(format)) {\n index = format;\n format = undefined;\n }\n\n format = format || '';\n } else {\n format = localeSorted;\n index = format;\n localeSorted = false;\n\n if (isNumber(format)) {\n index = format;\n format = undefined;\n }\n\n format = format || '';\n }\n\n var locale = getLocale(),\n shift = localeSorted ? locale._week.dow : 0,\n i,\n out = [];\n\n if (index != null) {\n return get$1(format, (index + shift) % 7, field, 'day');\n }\n\n for (i = 0; i < 7; i++) {\n out[i] = get$1(format, (i + shift) % 7, field, 'day');\n }\n return out;\n }\n\n function listMonths(format, index) {\n return listMonthsImpl(format, index, 'months');\n }\n\n function listMonthsShort(format, index) {\n return listMonthsImpl(format, index, 'monthsShort');\n }\n\n function listWeekdays(localeSorted, format, index) {\n return listWeekdaysImpl(localeSorted, format, index, 'weekdays');\n }\n\n function listWeekdaysShort(localeSorted, format, index) {\n return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');\n }\n\n function listWeekdaysMin(localeSorted, format, index) {\n return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');\n }\n\n getSetGlobalLocale('en', {\n eras: [\n {\n since: '0001-01-01',\n until: +Infinity,\n offset: 1,\n name: 'Anno Domini',\n narrow: 'AD',\n abbr: 'AD',\n },\n {\n since: '0000-12-31',\n until: -Infinity,\n offset: 1,\n name: 'Before Christ',\n narrow: 'BC',\n abbr: 'BC',\n },\n ],\n dayOfMonthOrdinalParse: /\\d{1,2}(th|st|nd|rd)/,\n ordinal: function (number) {\n var b = number % 10,\n output =\n toInt((number % 100) / 10) === 1\n ? 'th'\n : b === 1\n ? 'st'\n : b === 2\n ? 'nd'\n : b === 3\n ? 'rd'\n : 'th';\n return number + output;\n },\n });\n\n // Side effect imports\n\n hooks.lang = deprecate(\n 'moment.lang is deprecated. Use moment.locale instead.',\n getSetGlobalLocale\n );\n hooks.langData = deprecate(\n 'moment.langData is deprecated. Use moment.localeData instead.',\n getLocale\n );\n\n var mathAbs = Math.abs;\n\n function abs() {\n var data = this._data;\n\n this._milliseconds = mathAbs(this._milliseconds);\n this._days = mathAbs(this._days);\n this._months = mathAbs(this._months);\n\n data.milliseconds = mathAbs(data.milliseconds);\n data.seconds = mathAbs(data.seconds);\n data.minutes = mathAbs(data.minutes);\n data.hours = mathAbs(data.hours);\n data.months = mathAbs(data.months);\n data.years = mathAbs(data.years);\n\n return this;\n }\n\n function addSubtract$1(duration, input, value, direction) {\n var other = createDuration(input, value);\n\n duration._milliseconds += direction * other._milliseconds;\n duration._days += direction * other._days;\n duration._months += direction * other._months;\n\n return duration._bubble();\n }\n\n // supports only 2.0-style add(1, 's') or add(duration)\n function add$1(input, value) {\n return addSubtract$1(this, input, value, 1);\n }\n\n // supports only 2.0-style subtract(1, 's') or subtract(duration)\n function subtract$1(input, value) {\n return addSubtract$1(this, input, value, -1);\n }\n\n function absCeil(number) {\n if (number < 0) {\n return Math.floor(number);\n } else {\n return Math.ceil(number);\n }\n }\n\n function bubble() {\n var milliseconds = this._milliseconds,\n days = this._days,\n months = this._months,\n data = this._data,\n seconds,\n minutes,\n hours,\n years,\n monthsFromDays;\n\n // if we have a mix of positive and negative values, bubble down first\n // check: https://github.com/moment/moment/issues/2166\n if (\n !(\n (milliseconds >= 0 && days >= 0 && months >= 0) ||\n (milliseconds <= 0 && days <= 0 && months <= 0)\n )\n ) {\n milliseconds += absCeil(monthsToDays(months) + days) * 864e5;\n days = 0;\n months = 0;\n }\n\n // The following code bubbles up values, see the tests for\n // examples of what that means.\n data.milliseconds = milliseconds % 1000;\n\n seconds = absFloor(milliseconds / 1000);\n data.seconds = seconds % 60;\n\n minutes = absFloor(seconds / 60);\n data.minutes = minutes % 60;\n\n hours = absFloor(minutes / 60);\n data.hours = hours % 24;\n\n days += absFloor(hours / 24);\n\n // convert days to months\n monthsFromDays = absFloor(daysToMonths(days));\n months += monthsFromDays;\n days -= absCeil(monthsToDays(monthsFromDays));\n\n // 12 months -> 1 year\n years = absFloor(months / 12);\n months %= 12;\n\n data.days = days;\n data.months = months;\n data.years = years;\n\n return this;\n }\n\n function daysToMonths(days) {\n // 400 years have 146097 days (taking into account leap year rules)\n // 400 years have 12 months === 4800\n return (days * 4800) / 146097;\n }\n\n function monthsToDays(months) {\n // the reverse of daysToMonths\n return (months * 146097) / 4800;\n }\n\n function as(units) {\n if (!this.isValid()) {\n return NaN;\n }\n var days,\n months,\n milliseconds = this._milliseconds;\n\n units = normalizeUnits(units);\n\n if (units === 'month' || units === 'quarter' || units === 'year') {\n days = this._days + milliseconds / 864e5;\n months = this._months + daysToMonths(days);\n switch (units) {\n case 'month':\n return months;\n case 'quarter':\n return months / 3;\n case 'year':\n return months / 12;\n }\n } else {\n // handle milliseconds separately because of floating point math errors (issue #1867)\n days = this._days + Math.round(monthsToDays(this._months));\n switch (units) {\n case 'week':\n return days / 7 + milliseconds / 6048e5;\n case 'day':\n return days + milliseconds / 864e5;\n case 'hour':\n return days * 24 + milliseconds / 36e5;\n case 'minute':\n return days * 1440 + milliseconds / 6e4;\n case 'second':\n return days * 86400 + milliseconds / 1000;\n // Math.floor prevents floating point math errors here\n case 'millisecond':\n return Math.floor(days * 864e5) + milliseconds;\n default:\n throw new Error('Unknown unit ' + units);\n }\n }\n }\n\n // TODO: Use this.as('ms')?\n function valueOf$1() {\n if (!this.isValid()) {\n return NaN;\n }\n return (\n this._milliseconds +\n this._days * 864e5 +\n (this._months % 12) * 2592e6 +\n toInt(this._months / 12) * 31536e6\n );\n }\n\n function makeAs(alias) {\n return function () {\n return this.as(alias);\n };\n }\n\n var asMilliseconds = makeAs('ms'),\n asSeconds = makeAs('s'),\n asMinutes = makeAs('m'),\n asHours = makeAs('h'),\n asDays = makeAs('d'),\n asWeeks = makeAs('w'),\n asMonths = makeAs('M'),\n asQuarters = makeAs('Q'),\n asYears = makeAs('y');\n\n function clone$1() {\n return createDuration(this);\n }\n\n function get$2(units) {\n units = normalizeUnits(units);\n return this.isValid() ? this[units + 's']() : NaN;\n }\n\n function makeGetter(name) {\n return function () {\n return this.isValid() ? this._data[name] : NaN;\n };\n }\n\n var milliseconds = makeGetter('milliseconds'),\n seconds = makeGetter('seconds'),\n minutes = makeGetter('minutes'),\n hours = makeGetter('hours'),\n days = makeGetter('days'),\n months = makeGetter('months'),\n years = makeGetter('years');\n\n function weeks() {\n return absFloor(this.days() / 7);\n }\n\n var round = Math.round,\n thresholds = {\n ss: 44, // a few seconds to seconds\n s: 45, // seconds to minute\n m: 45, // minutes to hour\n h: 22, // hours to day\n d: 26, // days to month/week\n w: null, // weeks to month\n M: 11, // months to year\n };\n\n // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize\n function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {\n return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);\n }\n\n function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {\n var duration = createDuration(posNegDuration).abs(),\n seconds = round(duration.as('s')),\n minutes = round(duration.as('m')),\n hours = round(duration.as('h')),\n days = round(duration.as('d')),\n months = round(duration.as('M')),\n weeks = round(duration.as('w')),\n years = round(duration.as('y')),\n a =\n (seconds <= thresholds.ss && ['s', seconds]) ||\n (seconds < thresholds.s && ['ss', seconds]) ||\n (minutes <= 1 && ['m']) ||\n (minutes < thresholds.m && ['mm', minutes]) ||\n (hours <= 1 && ['h']) ||\n (hours < thresholds.h && ['hh', hours]) ||\n (days <= 1 && ['d']) ||\n (days < thresholds.d && ['dd', days]);\n\n if (thresholds.w != null) {\n a =\n a ||\n (weeks <= 1 && ['w']) ||\n (weeks < thresholds.w && ['ww', weeks]);\n }\n a = a ||\n (months <= 1 && ['M']) ||\n (months < thresholds.M && ['MM', months]) ||\n (years <= 1 && ['y']) || ['yy', years];\n\n a[2] = withoutSuffix;\n a[3] = +posNegDuration > 0;\n a[4] = locale;\n return substituteTimeAgo.apply(null, a);\n }\n\n // This function allows you to set the rounding function for relative time strings\n function getSetRelativeTimeRounding(roundingFunction) {\n if (roundingFunction === undefined) {\n return round;\n }\n if (typeof roundingFunction === 'function') {\n round = roundingFunction;\n return true;\n }\n return false;\n }\n\n // This function allows you to set a threshold for relative time strings\n function getSetRelativeTimeThreshold(threshold, limit) {\n if (thresholds[threshold] === undefined) {\n return false;\n }\n if (limit === undefined) {\n return thresholds[threshold];\n }\n thresholds[threshold] = limit;\n if (threshold === 's') {\n thresholds.ss = limit - 1;\n }\n return true;\n }\n\n function humanize(argWithSuffix, argThresholds) {\n if (!this.isValid()) {\n return this.localeData().invalidDate();\n }\n\n var withSuffix = false,\n th = thresholds,\n locale,\n output;\n\n if (typeof argWithSuffix === 'object') {\n argThresholds = argWithSuffix;\n argWithSuffix = false;\n }\n if (typeof argWithSuffix === 'boolean') {\n withSuffix = argWithSuffix;\n }\n if (typeof argThresholds === 'object') {\n th = Object.assign({}, thresholds, argThresholds);\n if (argThresholds.s != null && argThresholds.ss == null) {\n th.ss = argThresholds.s - 1;\n }\n }\n\n locale = this.localeData();\n output = relativeTime$1(this, !withSuffix, th, locale);\n\n if (withSuffix) {\n output = locale.pastFuture(+this, output);\n }\n\n return locale.postformat(output);\n }\n\n var abs$1 = Math.abs;\n\n function sign(x) {\n return (x > 0) - (x < 0) || +x;\n }\n\n function toISOString$1() {\n // for ISO strings we do not use the normal bubbling rules:\n // * milliseconds bubble up until they become hours\n // * days do not bubble at all\n // * months bubble up until they become years\n // This is because there is no context-free conversion between hours and days\n // (think of clock changes)\n // and also not between days and months (28-31 days per month)\n if (!this.isValid()) {\n return this.localeData().invalidDate();\n }\n\n var seconds = abs$1(this._milliseconds) / 1000,\n days = abs$1(this._days),\n months = abs$1(this._months),\n minutes,\n hours,\n years,\n s,\n total = this.asSeconds(),\n totalSign,\n ymSign,\n daysSign,\n hmsSign;\n\n if (!total) {\n // this is the same as C#'s (Noda) and python (isodate)...\n // but not other JS (goog.date)\n return 'P0D';\n }\n\n // 3600 seconds -> 60 minutes -> 1 hour\n minutes = absFloor(seconds / 60);\n hours = absFloor(minutes / 60);\n seconds %= 60;\n minutes %= 60;\n\n // 12 months -> 1 year\n years = absFloor(months / 12);\n months %= 12;\n\n // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js\n s = seconds ? seconds.toFixed(3).replace(/\\.?0+$/, '') : '';\n\n totalSign = total < 0 ? '-' : '';\n ymSign = sign(this._months) !== sign(total) ? '-' : '';\n daysSign = sign(this._days) !== sign(total) ? '-' : '';\n hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';\n\n return (\n totalSign +\n 'P' +\n (years ? ymSign + years + 'Y' : '') +\n (months ? ymSign + months + 'M' : '') +\n (days ? daysSign + days + 'D' : '') +\n (hours || minutes || seconds ? 'T' : '') +\n (hours ? hmsSign + hours + 'H' : '') +\n (minutes ? hmsSign + minutes + 'M' : '') +\n (seconds ? hmsSign + s + 'S' : '')\n );\n }\n\n var proto$2 = Duration.prototype;\n\n proto$2.isValid = isValid$1;\n proto$2.abs = abs;\n proto$2.add = add$1;\n proto$2.subtract = subtract$1;\n proto$2.as = as;\n proto$2.asMilliseconds = asMilliseconds;\n proto$2.asSeconds = asSeconds;\n proto$2.asMinutes = asMinutes;\n proto$2.asHours = asHours;\n proto$2.asDays = asDays;\n proto$2.asWeeks = asWeeks;\n proto$2.asMonths = asMonths;\n proto$2.asQuarters = asQuarters;\n proto$2.asYears = asYears;\n proto$2.valueOf = valueOf$1;\n proto$2._bubble = bubble;\n proto$2.clone = clone$1;\n proto$2.get = get$2;\n proto$2.milliseconds = milliseconds;\n proto$2.seconds = seconds;\n proto$2.minutes = minutes;\n proto$2.hours = hours;\n proto$2.days = days;\n proto$2.weeks = weeks;\n proto$2.months = months;\n proto$2.years = years;\n proto$2.humanize = humanize;\n proto$2.toISOString = toISOString$1;\n proto$2.toString = toISOString$1;\n proto$2.toJSON = toISOString$1;\n proto$2.locale = locale;\n proto$2.localeData = localeData;\n\n proto$2.toIsoString = deprecate(\n 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',\n toISOString$1\n );\n proto$2.lang = lang;\n\n // FORMATTING\n\n addFormatToken('X', 0, 0, 'unix');\n addFormatToken('x', 0, 0, 'valueOf');\n\n // PARSING\n\n addRegexToken('x', matchSigned);\n addRegexToken('X', matchTimestamp);\n addParseToken('X', function (input, array, config) {\n config._d = new Date(parseFloat(input) * 1000);\n });\n addParseToken('x', function (input, array, config) {\n config._d = new Date(toInt(input));\n });\n\n //! moment.js\n\n hooks.version = '2.29.1';\n\n setHookCallback(createLocal);\n\n hooks.fn = proto;\n hooks.min = min;\n hooks.max = max;\n hooks.now = now;\n hooks.utc = createUTC;\n hooks.unix = createUnix;\n hooks.months = listMonths;\n hooks.isDate = isDate;\n hooks.locale = getSetGlobalLocale;\n hooks.invalid = createInvalid;\n hooks.duration = createDuration;\n hooks.isMoment = isMoment;\n hooks.weekdays = listWeekdays;\n hooks.parseZone = createInZone;\n hooks.localeData = getLocale;\n hooks.isDuration = isDuration;\n hooks.monthsShort = listMonthsShort;\n hooks.weekdaysMin = listWeekdaysMin;\n hooks.defineLocale = defineLocale;\n hooks.updateLocale = updateLocale;\n hooks.locales = listLocales;\n hooks.weekdaysShort = listWeekdaysShort;\n hooks.normalizeUnits = normalizeUnits;\n hooks.relativeTimeRounding = getSetRelativeTimeRounding;\n hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;\n hooks.calendarFormat = getCalendarFormat;\n hooks.prototype = proto;\n\n // currently HTML5 input type only supports 24-hour formats\n hooks.HTML5_FMT = {\n DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // \n DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // \n DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // \n DATE: 'YYYY-MM-DD', // \n TIME: 'HH:mm', // \n TIME_SECONDS: 'HH:mm:ss', // \n TIME_MS: 'HH:mm:ss.SSS', // \n WEEK: 'GGGG-[W]WW', // \n MONTH: 'YYYY-MM', // \n };\n\n return hooks;\n\n})));\n","'use strict'\nvar inherits = require('inherits')\nvar MD5 = require('md5.js')\nvar RIPEMD160 = require('ripemd160')\nvar sha = require('sha.js')\nvar Base = require('cipher-base')\n\nfunction Hash (hash) {\n Base.call(this, 'digest')\n\n this._hash = hash\n}\n\ninherits(Hash, Base)\n\nHash.prototype._update = function (data) {\n this._hash.update(data)\n}\n\nHash.prototype._final = function () {\n return this._hash.digest()\n}\n\nmodule.exports = function createHash (alg) {\n alg = alg.toLowerCase()\n if (alg === 'md5') return new MD5()\n if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()\n\n return new Hash(sha(alg))\n}\n","module.exports = function xor (a, b) {\n var length = Math.min(a.length, b.length)\n var buffer = new Buffer(length)\n\n for (var i = 0; i < length; ++i) {\n buffer[i] = a[i] ^ b[i]\n }\n\n return buffer\n}\n","'use strict';\n\nvar utils = require('./utils');\nvar assert = require('minimalistic-assert');\n\nfunction BlockHash() {\n this.pending = null;\n this.pendingTotal = 0;\n this.blockSize = this.constructor.blockSize;\n this.outSize = this.constructor.outSize;\n this.hmacStrength = this.constructor.hmacStrength;\n this.padLength = this.constructor.padLength / 8;\n this.endian = 'big';\n\n this._delta8 = this.blockSize / 8;\n this._delta32 = this.blockSize / 32;\n}\nexports.BlockHash = BlockHash;\n\nBlockHash.prototype.update = function update(msg, enc) {\n // Convert message to array, pad it, and join into 32bit blocks\n msg = utils.toArray(msg, enc);\n if (!this.pending)\n this.pending = msg;\n else\n this.pending = this.pending.concat(msg);\n this.pendingTotal += msg.length;\n\n // Enough data, try updating\n if (this.pending.length >= this._delta8) {\n msg = this.pending;\n\n // Process pending data in blocks\n var r = msg.length % this._delta8;\n this.pending = msg.slice(msg.length - r, msg.length);\n if (this.pending.length === 0)\n this.pending = null;\n\n msg = utils.join32(msg, 0, msg.length - r, this.endian);\n for (var i = 0; i < msg.length; i += this._delta32)\n this._update(msg, i, i + this._delta32);\n }\n\n return this;\n};\n\nBlockHash.prototype.digest = function digest(enc) {\n this.update(this._pad());\n assert(this.pending === null);\n\n return this._digest(enc);\n};\n\nBlockHash.prototype._pad = function pad() {\n var len = this.pendingTotal;\n var bytes = this._delta8;\n var k = bytes - ((len + this.padLength) % bytes);\n var res = new Array(k + this.padLength);\n res[0] = 0x80;\n for (var i = 1; i < k; i++)\n res[i] = 0;\n\n // Append length\n len <<= 3;\n if (this.endian === 'big') {\n for (var t = 8; t < this.padLength; t++)\n res[i++] = 0;\n\n res[i++] = 0;\n res[i++] = 0;\n res[i++] = 0;\n res[i++] = 0;\n res[i++] = (len >>> 24) & 0xff;\n res[i++] = (len >>> 16) & 0xff;\n res[i++] = (len >>> 8) & 0xff;\n res[i++] = len & 0xff;\n } else {\n res[i++] = len & 0xff;\n res[i++] = (len >>> 8) & 0xff;\n res[i++] = (len >>> 16) & 0xff;\n res[i++] = (len >>> 24) & 0xff;\n res[i++] = 0;\n res[i++] = 0;\n res[i++] = 0;\n res[i++] = 0;\n\n for (t = 8; t < this.padLength; t++)\n res[i++] = 0;\n }\n\n return res;\n};\n","'use strict';\n\nconst inherits = require('inherits');\nconst Reporter = require('../base/reporter').Reporter;\nconst Buffer = require('safer-buffer').Buffer;\n\nfunction DecoderBuffer(base, options) {\n Reporter.call(this, options);\n if (!Buffer.isBuffer(base)) {\n this.error('Input not Buffer');\n return;\n }\n\n this.base = base;\n this.offset = 0;\n this.length = base.length;\n}\ninherits(DecoderBuffer, Reporter);\nexports.DecoderBuffer = DecoderBuffer;\n\nDecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) {\n if (data instanceof DecoderBuffer) {\n return true;\n }\n\n // Or accept compatible API\n const isCompatible = typeof data === 'object' &&\n Buffer.isBuffer(data.base) &&\n data.constructor.name === 'DecoderBuffer' &&\n typeof data.offset === 'number' &&\n typeof data.length === 'number' &&\n typeof data.save === 'function' &&\n typeof data.restore === 'function' &&\n typeof data.isEmpty === 'function' &&\n typeof data.readUInt8 === 'function' &&\n typeof data.skip === 'function' &&\n typeof data.raw === 'function';\n\n return isCompatible;\n};\n\nDecoderBuffer.prototype.save = function save() {\n return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };\n};\n\nDecoderBuffer.prototype.restore = function restore(save) {\n // Return skipped data\n const res = new DecoderBuffer(this.base);\n res.offset = save.offset;\n res.length = this.offset;\n\n this.offset = save.offset;\n Reporter.prototype.restore.call(this, save.reporter);\n\n return res;\n};\n\nDecoderBuffer.prototype.isEmpty = function isEmpty() {\n return this.offset === this.length;\n};\n\nDecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {\n if (this.offset + 1 <= this.length)\n return this.base.readUInt8(this.offset++, true);\n else\n return this.error(fail || 'DecoderBuffer overrun');\n};\n\nDecoderBuffer.prototype.skip = function skip(bytes, fail) {\n if (!(this.offset + bytes <= this.length))\n return this.error(fail || 'DecoderBuffer overrun');\n\n const res = new DecoderBuffer(this.base);\n\n // Share reporter state\n res._reporterState = this._reporterState;\n\n res.offset = this.offset;\n res.length = this.offset + bytes;\n this.offset += bytes;\n return res;\n};\n\nDecoderBuffer.prototype.raw = function raw(save) {\n return this.base.slice(save ? save.offset : this.offset, this.length);\n};\n\nfunction EncoderBuffer(value, reporter) {\n if (Array.isArray(value)) {\n this.length = 0;\n this.value = value.map(function(item) {\n if (!EncoderBuffer.isEncoderBuffer(item))\n item = new EncoderBuffer(item, reporter);\n this.length += item.length;\n return item;\n }, this);\n } else if (typeof value === 'number') {\n if (!(0 <= value && value <= 0xff))\n return reporter.error('non-byte EncoderBuffer value');\n this.value = value;\n this.length = 1;\n } else if (typeof value === 'string') {\n this.value = value;\n this.length = Buffer.byteLength(value);\n } else if (Buffer.isBuffer(value)) {\n this.value = value;\n this.length = value.length;\n } else {\n return reporter.error('Unsupported type: ' + typeof value);\n }\n}\nexports.EncoderBuffer = EncoderBuffer;\n\nEncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) {\n if (data instanceof EncoderBuffer) {\n return true;\n }\n\n // Or accept compatible API\n const isCompatible = typeof data === 'object' &&\n data.constructor.name === 'EncoderBuffer' &&\n typeof data.length === 'number' &&\n typeof data.join === 'function';\n\n return isCompatible;\n};\n\nEncoderBuffer.prototype.join = function join(out, offset) {\n if (!out)\n out = Buffer.alloc(this.length);\n if (!offset)\n offset = 0;\n\n if (this.length === 0)\n return out;\n\n if (Array.isArray(this.value)) {\n this.value.forEach(function(item) {\n item.join(out, offset);\n offset += item.length;\n });\n } else {\n if (typeof this.value === 'number')\n out[offset] = this.value;\n else if (typeof this.value === 'string')\n out.write(this.value, offset);\n else if (Buffer.isBuffer(this.value))\n this.value.copy(out, offset);\n offset += this.length;\n }\n\n return out;\n};\n","//Types of elements found in the DOM\nmodule.exports = {\n\tText: \"text\", //Text\n\tDirective: \"directive\", // ... ?>\n\tComment: \"comment\", //\n\tScript: \"script\", //