{
  "version": 3,
  "sources": ["stale_day_core.js"],
  "sourcesContent": ["// @ts-check\n/*\n * static/js/stale_day_core.js \u2014 is this page's own \"today\" old? (SNOW-920)\n *\n * The service worker's network-first navigation waits NAVIGATION_FETCH_BUDGET_MS\n * for the shell and then serves the cached copy. That copy carries the day it\n * was RENDERED on as ``#season-scrubber[data-today]``, and SNOW-793 makes that\n * attribute the only authority for \"today\" (the browser clock is refused, so a\n * device with the wrong date cannot move the map). So a cached shell opened\n * after midnight quietly shows yesterday as today, and nothing compared it\n * with the server's day.\n *\n * ``stale_day.js`` asks ``/api/version`` for the server's day; this file holds\n * the two pure decisions made with the answer, so they are tested without a\n * DOM:\n *\n *   - ``isStale`` \u2014 the page is stale only when BOTH days are well-formed and\n *     they differ, and no day was asked for in the URL. A missing or\n *     malformed day on either side is \"cannot confirm\", and cannot confirm\n *     never raises an alarm. An explicit ``?d=`` is the visitor's own choice\n *     of day and is not what the label is about.\n *   - ``formatDay`` \u2014 the label's day, from an ISO string, in the page's\n *     language. It formats a date it was GIVEN; it never reads the clock.\n */\n(function () {\n  'use strict';\n\n  const ISO_DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n  /**\n   * Whether a string is a calendar day in ``YYYY-MM-DD`` form.\n   *\n   * @param {unknown} value\n   * @returns {value is string}\n   */\n  function isIsoDay(value) {\n    if (typeof value !== 'string' || !ISO_DAY.test(value)) return false;\n    const parsed = new Date(value + 'T00:00:00Z');\n    return !Number.isNaN(parsed.getTime()) && parsed.toISOString().slice(0, 10) === value;\n  }\n\n  /**\n   * Whether the page's rendered day is older than the server's.\n   *\n   * @param {unknown} pageDay The page's ``data-today``.\n   * @param {unknown} serverDay ``today`` from ``/api/version``.\n   * @param {unknown} [explicitDay] The URL's ``?d=``, when it has one.\n   * @returns {boolean}\n   */\n  function isStale(pageDay, serverDay, explicitDay) {\n    if (explicitDay) return false;\n    if (!isIsoDay(pageDay) || !isIsoDay(serverDay)) return false;\n    return pageDay !== serverDay;\n  }\n\n  /**\n   * A short, locale-aware day for the label (\"18 Oct\").\n   *\n   * Formatted in UTC so the calendar day never shifts with the device's\n   * zone; the input is a date, not a moment.\n   *\n   * @param {string} isoDay ``YYYY-MM-DD``.\n   * @param {string} [locale] A BCP 47 tag; the runtime default when empty.\n   * @returns {string} The formatted day, or the input when it cannot be\n   *   formatted.\n   */\n  function formatDay(isoDay, locale) {\n    if (!isIsoDay(isoDay)) return String(isoDay || '');\n    try {\n      return new Intl.DateTimeFormat(locale || undefined, {\n        day: 'numeric',\n        month: 'short',\n        timeZone: 'UTC',\n      }).format(new Date(isoDay + 'T00:00:00Z'));\n    } catch (_err) {\n      return isoDay;\n    }\n  }\n\n  window.pwaStaleDayCore = Object.freeze({\n    isIsoDay: isIsoDay,\n    isStale: isStale,\n    formatDay: formatDay,\n  });\n})();\n"],
  "mappings": "CAwBC,UAAY,CACX,aAEA,MAAMA,EAAU,sBAQhB,SAASC,EAASC,EAAO,CACvB,GAAI,OAAOA,GAAU,UAAY,CAACF,EAAQ,KAAKE,CAAK,EAAG,MAAO,GAC9D,MAAMC,EAAS,IAAI,KAAKD,EAAQ,YAAY,EAC5C,MAAO,CAAC,OAAO,MAAMC,EAAO,QAAQ,CAAC,GAAKA,EAAO,YAAY,EAAE,MAAM,EAAG,EAAE,IAAMD,CAClF,CAUA,SAASE,EAAQC,EAASC,EAAWC,EAAa,CAEhD,OADIA,GACA,CAACN,EAASI,CAAO,GAAK,CAACJ,EAASK,CAAS,EAAU,GAChDD,IAAYC,CACrB,CAaA,SAASE,EAAUC,EAAQC,EAAQ,CACjC,GAAI,CAACT,EAASQ,CAAM,EAAG,OAAO,OAAOA,GAAU,EAAE,EACjD,GAAI,CACF,OAAO,IAAI,KAAK,eAAeC,GAAU,OAAW,CAClD,IAAK,UACL,MAAO,QACP,SAAU,KACZ,CAAC,EAAE,OAAO,IAAI,KAAKD,EAAS,YAAY,CAAC,CAC3C,MAAe,CACb,OAAOA,CACT,CACF,CAEA,OAAO,gBAAkB,OAAO,OAAO,CACrC,SAAUR,EACV,QAASG,EACT,UAAWI,CACb,CAAC,CACH,GAAG",
  "names": ["ISO_DAY", "isIsoDay", "value", "parsed", "isStale", "pageDay", "serverDay", "explicitDay", "formatDay", "isoDay", "locale"]
}
