temporal-fmt 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -1
- package/dist/chunk-4JDAJSEM.js +35 -0
- package/dist/chunk-4JDAJSEM.js.map +1 -0
- package/dist/{chunk-F4RGUDA3.js → chunk-4XRE37WT.js} +2 -2
- package/dist/chunk-GMGZZG6I.js +2 -0
- package/dist/chunk-GMGZZG6I.js.map +1 -0
- package/dist/{chunk-R52YOKI3.js → chunk-NPKJ7QFK.js} +2 -2
- package/dist/{chunk-NBXF7V5B.js → chunk-R4YEFOVE.js} +2 -2
- package/dist/{chunk-4JWGUR4O.js → chunk-SSPABEUR.js} +2 -2
- package/dist/format.cjs +5 -5
- package/dist/format.cjs.map +1 -1
- package/dist/format.js +1 -1
- package/dist/index.cjs +24 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interval.cjs +2 -2
- package/dist/interval.cjs.map +1 -1
- package/dist/interval.js +1 -1
- package/dist/parse.cjs +9 -9
- package/dist/parse.cjs.map +1 -1
- package/dist/parse.js +1 -1
- package/dist/pattern.d.cts +1 -0
- package/dist/pattern.d.ts +1 -0
- package/dist/relativeTime.cjs +1 -1
- package/dist/relativeTime.cjs.map +1 -1
- package/dist/relativeTime.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-C5YESWFT.js +0 -2
- package/dist/chunk-C5YESWFT.js.map +0 -1
- package/dist/chunk-YB6YAG7E.js +0 -35
- package/dist/chunk-YB6YAG7E.js.map +0 -1
- /package/dist/{chunk-F4RGUDA3.js.map → chunk-4XRE37WT.js.map} +0 -0
- /package/dist/{chunk-R52YOKI3.js.map → chunk-NPKJ7QFK.js.map} +0 -0
- /package/dist/{chunk-NBXF7V5B.js.map → chunk-R4YEFOVE.js.map} +0 -0
- /package/dist/{chunk-4JWGUR4O.js.map → chunk-SSPABEUR.js.map} +0 -0
package/dist/relativeTime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-R4YEFOVE.js";import"./chunk-GMGZZG6I.js";import"./chunk-3MZLTVP3.js";import"./chunk-5U5WJ465.js";import"./chunk-VQXUMFB2.js";import"./chunk-EHLRZULM.js";import"./chunk-C6ZZ62ET.js";export{a as formatRelative,b as formatRelativeToNow};
|
|
2
2
|
//# sourceMappingURL=relativeTime.js.map
|
package/package.json
CHANGED
package/dist/chunk-C5YESWFT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as I,c as L}from"./chunk-3MZLTVP3.js";import{k as D,p as O,q as b,s}from"./chunk-5U5WJ465.js";import{b as p,c as w}from"./chunk-C6ZZ62ET.js";function r(e,t){let n=e<0,o=String(Math.abs(e)).padStart(t,"0");return n?"-"+o:o}r.fraction=function(t,n){let o=t.millisecond*1e6+(t.microsecond??0)*1e3+(t.nanosecond??0);return r(o,9).slice(0,n)};var G="en-US",l=new Map,$=500;function F(e,t){let n=JSON.stringify([b(e),t]),o=l.get(n);if(o)return o;if(l.size>=$){let a=l.keys().next().value;a!==void 0&&l.delete(a)}try{o=new Intl.DateTimeFormat(O(e),t)}catch(a){throw new D({actual:e,reason:a.message})}return l.set(n,o),o}var y;I(()=>{y=void 0});function M(){if(y===void 0){y=!1;try{let e=L();new Intl.DateTimeFormat("en-US",{day:"numeric"}).formatToParts(e.PlainDate.from({year:1970,month:1,day:1})),y=!0}catch{}}return y}function h(e,t,n,o){let a=e?.calendarId,i={...n,calendar:a&&a!=="iso8601"?a:"gregory"},d=e.toLocaleString;if(typeof d!="function"||d===Object.prototype.toLocaleString)throw new Error(`temporal-fmt: locale-aware part "${o}" needs a value that implements toLocaleString (a real Temporal object). A plain field bag cannot render locale-aware names \u2014 pass a Temporal.PlainDate/PlainDateTime/ZonedDateTime.`);if(!M())try{return d.call(e,O(t),i)}catch(u){throw u instanceof RangeError?new D({actual:t,reason:u.message}):u}let{toInstant:E,timeZoneId:X}=e,x=typeof E=="function"&&typeof X=="string",Z=x?e.toInstant():e,P={...i,...x?{timeZone:X}:{}},S=F(t,P).formatToParts(Z),g=S.findIndex(u=>u.type===o);if(g===-1)throw new Error(`temporal-fmt: locale "${t}" produced no "${o}" part for this token. This usually means the Temporal object is missing the field the token needs.`);let f=S[g].value,T=S[g-1],k=S[g+1];return T?.type==="literal"&&!/\s/.test(T.value)&&(f=T.value+f),k?.type==="literal"&&!/\s/.test(k.value)&&(f=f+k.value),f}function W(e,t){let n=s(t);if(n)return e<12?n.dayPeriod[0]:n.dayPeriod[1];let o=new Date(Date.UTC(1970,0,1,e)),i=F(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(o).find(d=>d.type==="dayPeriod");if(!i)throw new Error(`temporal-fmt: locale "${t}" produced no "dayPeriod" part for token "a".`);return i.value}function m(e,t,n,o,a,i){return a&&i!==void 0&&i>=0&&i<a.length?a[i]:h(e,t,n,o)}function c(e,t){if(e==="+00:00"&&(t==="X"||t==="XX"||t==="XXX"))return"Z";let n=e[0],o=e.slice(1,3),a=e.slice(4,6);switch(t){case"X":case"x":return a==="00"?`${n}${o}`:`${n}${o}${a}`;case"XX":case"xx":return`${n}${o}${a}`;case"XXX":case"xxx":return`${n}${o}:${a}`}}var H=[["yyyy",e=>r(e.year,4),"year"],["yy",e=>{if(e.year<0)throw new Error(`temporal-fmt: token "yy" doesn't support negative years (got ${e.year}), since truncating to 2 digits would make it indistinguishable from a positive year. Use "yyyy" instead.`);return r(e.year%100,2)},"year"],["MMMM",(e,t)=>{let n=s(t);return m(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["MMM",(e,t)=>{let n=s(t);return m(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["MM",e=>r(e.month,2),"month"],["M",e=>String(e.month),"month"],["dd",e=>r(e.day,2),"day"],["d",e=>String(e.day),"day"],["EEEE",(e,t)=>{let n=s(t);return m(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["EEE",(e,t)=>{let n=s(t);return m(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["HH",e=>r(e.hour,2),"hour"],["H",e=>String(e.hour),"hour"],["hh",e=>r(e.hour%12||12,2),"hour"],["h",e=>String(e.hour%12||12),"hour"],["mm",e=>r(e.minute,2),"minute"],["m",e=>String(e.minute),"minute"],["ss",e=>r(e.second,2),"second"],["s",e=>String(e.second),"second"],["SSSSSSSSS",e=>r.fraction(e,9),"millisecond"],["SSSSSSSS",e=>r.fraction(e,8),"millisecond"],["SSSSSSS",e=>r.fraction(e,7),"millisecond"],["SSSSSS",e=>r.fraction(e,6),"millisecond"],["SSSSS",e=>r.fraction(e,5),"millisecond"],["SSSS",e=>r.fraction(e,4),"millisecond"],["SSS",e=>r.fraction(e,3),"millisecond"],["SS",e=>r.fraction(e,2),"millisecond"],["S",e=>r.fraction(e,1),"millisecond"],["a",(e,t)=>W(e.hour,t),"hour"],["zzz",e=>e.timeZoneId,"timeZoneId"],["xxx",e=>c(e.offset,"xxx"),"offset"],["xx",e=>c(e.offset,"xx"),"offset"],["X",e=>c(e.offset,"X"),"offset"],["XX",e=>c(e.offset,"XX"),"offset"],["XXX",e=>c(e.offset,"XXX"),"offset"],["x",e=>c(e.offset,"x"),"offset"],["do",e=>{let t=e.day,n=t%10,o=t%100;return o>=11&&o<=13?t+"th":n===1?t+"st":n===2?t+"nd":n===3?t+"rd":t+"th"},"day"],["Q",e=>String(Math.ceil(e.month/3)),"month"],["QQQ",e=>"Q"+Math.ceil(e.month/3),"month"],["ww",e=>{let{week:t}=w(e.year,e.month,e.day,e.dayOfWeek);return r(t,2)},"dayOfWeek"],["RRRR",e=>{let{isoYear:t}=w(e.year,e.month,e.day,e.dayOfWeek);return r(t,4)},"dayOfWeek"],["D",e=>String(p(e.year,e.month,e.day)),"day"],["DD",e=>r(p(e.year,e.month,e.day),2),"day"],["DDD",e=>r(p(e.year,e.month,e.day),3),"day"],["LLLL",(e,t)=>{let n=s(t);return m(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["LLL",(e,t)=>{let n=s(t);return m(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["cccc",(e,t)=>{let n=s(t);return m(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["ccc",(e,t)=>{let n=s(t);return m(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["GGGG",(e,t)=>h(e,t,{era:"long"},"era"),"year"],["G",(e,t)=>h(e,t,{era:"short"},"era"),"year"],["zzzz",(e,t)=>h(e,t,{timeZoneName:"longGeneric"},"timeZoneName"),"timeZoneId"],["z",(e,t)=>h(e,t,{timeZoneName:"short"},"timeZoneName"),"timeZoneId"]];export{G as a,H as b};
|
|
2
|
-
//# sourceMappingURL=chunk-C5YESWFT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tokens.ts"],"sourcesContent":["import { getTemporal, subscribeToTemporalChanges } from './temporalProvider.js';\nimport { canonicalCacheKey, getCustomVocab, normalizeLocaleTag } from './localeVocab.js';\nimport { InvalidLocaleError } from './errors.js';\nimport { isoWeekYearAndWeek, dayOfYear } from './isoWeek.js';\n\nexport function pad(n: number, len: number): string {\n // padStart pads the whole string, sign included, so pad(-45, 4) used to\n // come out \"0-45\" instead of \"-045\" — split the sign off first.\n const negative = n < 0;\n const digits = String(Math.abs(n)).padStart(len, '0');\n return negative ? '-' + digits : digits;\n}\n\n// Combines the three sub-second fields Temporal exposes into one 9-digit\n// nanosecond-of-second value, then truncates (never rounds) to the\n// requested width. Truncating matches what every digit-width token in\n// this library already does elsewhere (yy, MM, dd, ...) — the token\n// asked for N digits of precision, not a rounded N-digit approximation.\n// A caller asking for SSS on a value with nanosecond precision gets the\n// leading 3 digits of it, same as they'd get the leading 3 digits of any\n// other multi-digit field this library formats.\n//\n// Attached to pad() rather than declared standalone: the bundler's\n// per-function coverage instrumentation attributes hits to each of the\n// 9 fraction-token arrow functions individually but not to a shared\n// helper they all close over, so a correctly-exercised helper still\n// shows as 0 hits under c8. pad() itself is called directly all over\n// this file and is reliably attributed — routing through it here keeps\n// the coverage numbers honest without duplicating the slice logic\n// across every token entry below.\npad.fraction = function formatFraction(t: TemporalLike, width: number): string {\n const nanoOfSecond = t.millisecond! * 1_000_000 + (t.microsecond ?? 0) * 1_000 + (t.nanosecond ?? 0);\n return pad(nanoOfSecond, 9).slice(0, width);\n};\n\n// Not every field exists on every Temporal type (PlainDate has no .hour,\n// etc). Callers check for undefined before formatting a token.\nexport interface TemporalLike {\n year?: number;\n month?: number;\n day?: number;\n hour?: number;\n minute?: number;\n second?: number;\n millisecond?: number;\n microsecond?: number;\n nanosecond?: number;\n timeZoneId?: string;\n // ZonedDateTime.prototype.offset — always `±HH:MM` (6 chars) for any\n // modern date. Historical LMT offsets with seconds exist in IANA but\n // aren't reachable through this Temporal field, so format-side offset\n // tokens can assume the canonical 6-char shape. Parse-side writes a\n // canonicalized `+HH:MM` here before handing it to\n // Temporal.ZonedDateTime.from as the `timeZone` value.\n offset?: string;\n dayOfWeek?: number; // 1=Mon, 7=Sun, per Temporal spec\n calendarId?: string;\n toInstant?: () => unknown;\n toLocaleString?: (locale: string, options: Intl.DateTimeFormatOptions) => string;\n}\n\nexport interface FormatOptions {\n /** BCP 47 locale tag, e.g. 'en-US', 'fr-FR', 'ar-EG'. Defaults to 'en-US'. */\n locale?: string;\n /**\n * When set on parse(), opts into the lenient split heuristic for ambiguous\n * glued numeric runs (e.g. \"121\" against \"Md\"). Default (false) keeps\n * parse()'s strict behavior — throw on ambiguity rather than guess.\n * See README \"Lenient parse mode\" for the heuristic and why it's opt-in.\n */\n lenient?: boolean;\n}\n\nexport const DEFAULT_LOCALE = 'en-US';\n\n// Intl.DateTimeFormat is expensive to construct and format() can run in a\n// loop (rendering a table of dates), so cache by (locale, options).\nconst formatterCache = new Map<string, Intl.DateTimeFormat>();\nconst MAX_CACHE_SIZE = 500;\n\nfunction getFormatter(locale: string, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat {\n const key = JSON.stringify([canonicalCacheKey(locale), options]);\n let formatter = formatterCache.get(key);\n if (formatter) {\n return formatter;\n }\n if (formatterCache.size >= MAX_CACHE_SIZE) {\n // not real LRU, just evicts oldest insertion — fine for this key space\n const oldestKey = formatterCache.keys().next().value;\n if (oldestKey !== undefined) formatterCache.delete(oldestKey);\n }\n try {\n formatter = new Intl.DateTimeFormat(normalizeLocaleTag(locale), options);\n } catch (err) {\n // Malformed locale tags reach Intl as a bare RangeError; surface the\n // library's typed error instead (reached via dayPeriodPart — the\n // 'a' token — on any runtime, and the native-Intl path for the rest).\n // Every failure mode of this constructor with a string locale is a\n // RangeError, so converting unconditionally preserves the original\n // message in `reason` either way.\n throw new InvalidLocaleError({ actual: locale, reason: (err as Error).message });\n }\n formatterCache.set(key, formatter);\n return formatter;\n}\n\n// Passing a Temporal object straight into `new Intl.DateTimeFormat().formatToParts()`\n// only works when the engine's Intl implementation has special-cased support for\n// *native* Temporal instances (checked via internal slots and/or gated behind a V8 flag,\n// not tied to a specific Node version).\n//\n// A Temporal polyfill's instances don't have those slots, so the engine falls back to ToNumber() -> .valueOf(),\n// which the polyfill deliberately throws on (\"Cannot use valueOf\").\n// Probed once and memoized and only from intlPart(), so it never\n// runs unless a format string actually uses a locale-aware token.\nlet nativeSupport: boolean | undefined;\n// Invalidate the memoized probe whenever setTemporal() swaps the active\n// implementation — otherwise a probe result from \"is native Temporal\n// supported\" could keep being used after the active implementation is\n// no longer the one that was probed. See setTemporal() in\n// temporalProvider.ts for the other half of this.\nsubscribeToTemporalChanges(() => { nativeSupport = undefined; });\n\nfunction intlSupportsNativeTemporal(): boolean {\n if (nativeSupport === undefined) {\n nativeSupport = false;\n try {\n const temporal = getTemporal();\n new Intl.DateTimeFormat('en-US', { day: 'numeric' })\n .formatToParts(temporal.PlainDate.from({ year: 1970, month: 1, day: 1 }) as Date);\n // Version-gated, not dead — see the matching note on the\n // !intlSupportsNativeTemporal() branch in intlPart() below for\n // why this can't be exercised from this environment.\n /* c8 ignore next */\n nativeSupport = true;\n /* c8 ignore start */\n } catch {\n // native Temporal absent, or present but not recognized by Intl — fall back.\n // Version-gated, not dead: this catch only fires on runtimes where the\n // probe above throws (no native Temporal, or Intl doesn't recognize it).\n // On a runtime with full native support (e.g. Node builds where Intl\n // accepts native Temporal instances directly) the try succeeds and this\n // branch is unreachable — mirror case of the block below.\n }\n /* c8 ignore stop */\n }\n return nativeSupport;\n}\n\nfunction intlPart(\n temporal: TemporalLike,\n locale: string,\n options: Intl.DateTimeFormatOptions,\n partType: Intl.DateTimeFormatPartTypes\n): string {\n // Intl throws \"Mismatching Calendars\" if the formatter's calendar doesn't\n // match the object's own (e.g. en-US formatter defaults to gregory, but\n // a hebrew/islamic PlainDate needs its own calendar passed through).\n //\n // For iso8601 specifically, force 'gregory' rather than leaving calendar\n // unset: numeric fields (yyyy/dd, see tokens' pad()-based handlers) are\n // always pulled straight off the object's own ISO fields — so if the\n // *locale* carries a `-u-ca-*` extension (e.g. 'en-u-ca-hebrew') and this\n // step left calendar unset, the formatter would resolve its own default\n // calendar from the locale and format MMMM/EEEE in that calendar while\n // yyyy/dd stay ISO, producing a date that looks internally consistent\n // (a real Hebrew month name next to a real-looking day/year) but names a\n // completely different day than the object actually represents. Forcing\n // 'gregory' here keeps every field of an ISO object's output anchored to\n // the same (ISO/Gregorian) calendar — a locale's calendar extension only\n // takes effect when the object itself already carries a non-ISO calendar\n // (via `.withCalendar()`), matching what the README documents.\n //\n // 'gregory' specifically, not 'iso8601' — passing `calendar: 'iso8601'`\n // explicitly alongside a single-field options object makes\n // formatToParts() come back empty for some reason, but 'gregory' doesn't\n // have that problem and Temporal's iso8601 calendar is Gregorian-shaped\n // (proleptic Gregorian throughout, no Julian cutover) so the two agree\n // on every numeric field this library ever reads.\n const calendar = temporal?.calendarId;\n const formatterOptions: Intl.DateTimeFormatOptions = {\n ...options,\n calendar: calendar && calendar !== 'iso8601' ? calendar : 'gregory',\n };\n\n // Field-bag guard: a plain { year, month, day } object only has\n // Object.prototype.toLocaleString, which ignores both arguments and\n // returns \"[object Object]\". On engines without native Temporal\n // support in Intl this used to be caught below, but on engines where\n // Intl *does* recognize native Temporal instances (Node 26+), a bag\n // skips that branch entirely and reaches formatToParts() directly —\n // which doesn't throw \"[object Object]\", it throws a bare\n // \"RangeError: Invalid time value\" once the bag fails ToNumber()\n // coercion. Neither failure mode is useful to a caller, so check for\n // a real toLocaleString up front, before branching on native support,\n // so the descriptive error fires on every engine.\n const ls = temporal.toLocaleString;\n if (typeof ls !== 'function' || ls === Object.prototype.toLocaleString) {\n throw new Error(\n `temporal-fmt: locale-aware part \"${partType}\" needs a value that implements ` +\n `toLocaleString (a real Temporal object). A plain field bag cannot render ` +\n `locale-aware names — pass a Temporal.PlainDate/PlainDateTime/ZonedDateTime.`\n );\n }\n\n // Temporal.prototype.toLocaleString() is part of the Temporal spec itself:\n // polyfills implement the ICU formatting internally without needing the\n // engine to recognize the object, so it works without native Intl support.\n //\n // Everything from here to the end of this function is genuinely\n // reachable — NOT dead code — but only on a Node build where a global\n // `Temporal` exists AND Intl.DateTimeFormat.formatToParts() recognizes\n // native Temporal instances directly (this is real, observed to vary\n // across Node versions: absent on the Node 22/24 builds this suite has\n // been run against, present on at least one Node 26 build). This\n // environment has no native Temporal (`typeof globalThis.Temporal ===\n // 'undefined'`), so intlSupportsNativeTemporal() always returns false\n // here and this branch can't be exercised from this test suite without\n // faking native-instance recognition, which turned out to be\n // impractical (Intl's native-Temporal detection isn't spoofable via a\n // Proxy or valueOf() shim — see the M-02 regression test in\n // temporalProvider.test.js for the same conclusion reached about the\n // sibling probe function). Coverage numbers for this block will differ\n // between Node versions for that reason; that's expected, not a\n // regression.\n /* c8 ignore start */\n if (!intlSupportsNativeTemporal()) {\n // normalizeLocaleTag: the active Temporal implementation's\n // toLocaleString forwards the locale to Intl.DateTimeFormat, which\n // (unlike this library's cache keys) rejects underscore-separated\n // tags like 'en_US' outright.\n // (Field-bag guard now runs unconditionally above, before this\n // native-support branch, so it's not repeated here.)\n try {\n return ls.call(temporal, normalizeLocaleTag(locale), formatterOptions);\n } catch (err) {\n // The active Temporal implementation forwards the tag to Intl, which\n // throws a bare RangeError for a malformed one — rethrow typed.\n if (err instanceof RangeError) {\n throw new InvalidLocaleError({ actual: locale, reason: err.message });\n }\n throw err;\n }\n }\n\n // formatToParts() throws on ZonedDateTime directly (per spec), so convert\n // to Instant and pass the zone via `timeZone` instead. Don't convert to\n // PlainDateTime — that drops the zone, which breaks 'MMMM' + 'zzz' combos.\n const { toInstant, timeZoneId } = temporal;\n const isZoned = typeof toInstant === 'function' && typeof timeZoneId === 'string';\n // has to be called as temporal.toInstant() because destructuring it off breaks\n // the receiver and throws\n const intlSafeTemporal = isZoned ? temporal.toInstant!() : temporal;\n const nativeOptions: Intl.DateTimeFormatOptions = {\n ...formatterOptions,\n ...(isZoned ? { timeZone: timeZoneId } : {}),\n };\n\n const formatter = getFormatter(locale, nativeOptions);\n const parts = formatter.formatToParts(intlSafeTemporal as Date | number);\n const index = parts.findIndex((p) => p.type === partType);\n if (index === -1) {\n throw new Error(\n `temporal-fmt: locale \"${locale}\" produced no \"${partType}\" part for this token. ` +\n `This usually means the Temporal object is missing the field the token needs.`\n );\n }\n // some locales (ja-JP) split a field across two parts — e.g. month \"8\"\n // plus a counter suffix \"月\" as a separate sibling literal part. Merge in\n // an adjacent literal only if it has no whitespace, so a genuine suffix\n // gets folded in but an ordinary separator (the space before \"AM\") stays\n // a separator. Mirrors partValue() in localeVocab.ts, which builds the\n // vocab this token's output needs to match for parse() to round-trip.\n let value = parts[index]!.value;\n const prev = parts[index - 1];\n const next = parts[index + 1];\n if (prev?.type === 'literal' && !/\\s/.test(prev.value)) value = prev.value + value;\n if (next?.type === 'literal' && !/\\s/.test(next.value)) value = value + next.value;\n return value;\n}\n/* c8 ignore stop */\n\n// Temporal.prototype.toLocaleString() can't isolate a single field the way\n// formatToParts() can — asking for `hour` + `dayPeriod` together returns one\n// joined string (e.g. \"3 in the afternoon\"), and `dayPeriod` alone resolves\n// against a different, non-hour-anchored set of periods (\"in the\n// afternoon\"/\"昼\" instead of \"PM\"/\"午後\"). Day period only depends on the\n// hour anyway, so route it through a plain UTC Date and Intl.DateTimeFormat\n// instead — that's worked the same on every engine regardless of whether\n// Temporal itself is native or polyfilled.\nfunction dayPeriodPart(hour: number, locale: string): string {\n // Custom vocab (when registered) takes precedence over Intl — same\n // contract as the other locale-aware tokens. Intl won't know about a\n // caller-supplied AM/PM string for a made-up locale key, so going\n // through Intl would produce something other than what the caller\n // registered.\n const custom = getCustomVocab(locale);\n if (custom) {\n return hour < 12 ? custom.dayPeriod[0]! : custom.dayPeriod[1]!;\n }\n const date = new Date(Date.UTC(1970, 0, 1, hour));\n const formatter = getFormatter(locale, { hour: 'numeric', hour12: true, timeZone: 'UTC' });\n const part = formatter.formatToParts(date).find((p) => p.type === 'dayPeriod');\n // Defensive guard, confirmed unreachable on this ICU build: forcing\n // hour12: true (as this call always does) produces a dayPeriod part\n // for every locale checked, including 24-hour-clock locales (ja-JP,\n // zh-CN, th-TH, he-IL) and a wide sweep of less-common tags (dz-BT,\n // bo-CN, am-ET, etc.). Same finding as partValue()'s twin guard in\n // localeVocab.ts. Kept in case a future ICU/locale-data update\n // produces a locale that genuinely omits it.\n /* c8 ignore start */\n if (!part) {\n throw new Error(`temporal-fmt: locale \"${locale}\" produced no \"dayPeriod\" part for token \"a\".`);\n }\n /* c8 ignore stop */\n return part.value;\n}\n\n// Resolves a locale-aware month/weekday name from the registered custom\n// vocab when one exists for this locale, falling through to Intl otherwise.\n// Without this, format() would silently keep producing Intl's strings while\n// parse() matched against the registered vocab — the two would round-trip-fail\n// against each other.\nfunction localeAwareName(\n temporal: TemporalLike,\n locale: string,\n options: Intl.DateTimeFormatOptions,\n partType: Intl.DateTimeFormatPartTypes,\n customArray: string[] | undefined,\n customIndex: number | undefined,\n): string {\n if (customArray && customIndex !== undefined && customIndex >= 0 && customIndex < customArray.length) {\n return customArray[customIndex]!;\n }\n return intlPart(temporal, locale, options, partType);\n}\n\n// Formats a `±HH:MM` offset string (the shape Temporal exposes on\n// ZonedDateTime.prototype.offset) into one of the six offset-token widths.\n// Width and Z-handling come from the variant letter+case:\n//\n// X / x — short form: minutes omitted when zero, no colon otherwise\n// XX / xx — hours + minutes, no colon\n// XXX / xxx — hours + minutes, with colon\n//\n// Uppercase (X) collapses +00:00 to \"Z\"; lowercase (x) always emits a\n// numeric offset, even for UTC. Mirrors the date-fns/Unicode-LDML offset\n// family — see README for the full variant table.\nfunction formatOffset(offset: string, variant: 'X' | 'XX' | 'XXX' | 'x' | 'xx' | 'xxx'): string {\n if (offset === '+00:00' && (variant === 'X' || variant === 'XX' || variant === 'XXX')) {\n return 'Z';\n }\n // offset is always 6 chars: sign + HH + ':' + MM\n const sign = offset[0]!;\n const hours = offset.slice(1, 3);\n const minutes = offset.slice(4, 6);\n switch (variant) {\n case 'X': case 'x':\n // minutes only matter when they're non-zero — otherwise drop them\n // entirely. Matches LDML: \"With a single X, the hours field is\n // required. The minutes field is optional, but only if the\n // minutes value is 0.\"\n return minutes === '00' ? `${sign}${hours}` : `${sign}${hours}${minutes}`;\n case 'XX': case 'xx':\n return `${sign}${hours}${minutes}`;\n case 'XXX': case 'xxx':\n return `${sign}${hours}:${minutes}`;\n }\n}\n\ntype TokenHandler = (t: TemporalLike, locale: string) => string;\n\n// Longest-first — tokenizer is greedy, \"yyyy\" has to be tried before \"yy\".\n//\n// Numeric tokens always render in ASCII digits, never locale-native\n// (Arabic-Indic, Devanagari, etc). Padding non-ASCII digits isn't as simple\n// as padding \"3\", and most consumers parsing these back out want plain\n// digits anyway.\nexport const TOKENS: Array<[string, TokenHandler, keyof TemporalLike]> = [\n ['yyyy', (t) => pad(t.year!, 4), 'year'],\n ['yy', (t) => {\n // -45 % 100 === -45, so truncating negative years to 2 digits doesn't\n // work and Math.abs() would make 45 CE and 45 BCE render the same.\n if (t.year! < 0) {\n throw new Error(\n `temporal-fmt: token \"yy\" doesn't support negative years (got ${t.year}), ` +\n `since truncating to 2 digits would make it indistinguishable from a ` +\n `positive year. Use \"yyyy\" instead.`\n );\n }\n return pad(t.year! % 100, 2);\n }, 'year'],\n ['MMMM', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { month: 'long' }, 'month', custom?.monthLong, t.month! - 1);\n }, 'month'],\n ['MMM', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { month: 'short' }, 'month', custom?.monthShort, t.month! - 1);\n }, 'month'],\n ['MM', (t) => pad(t.month!, 2), 'month'],\n ['M', (t) => String(t.month!), 'month'],\n ['dd', (t) => pad(t.day!, 2), 'day'],\n ['d', (t) => String(t.day!), 'day'],\n ['EEEE', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { weekday: 'long' }, 'weekday', custom?.weekdayLong, t.dayOfWeek! - 1);\n }, 'dayOfWeek'],\n ['EEE', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { weekday: 'short' }, 'weekday', custom?.weekdayShort, t.dayOfWeek! - 1);\n }, 'dayOfWeek'],\n ['HH', (t) => pad(t.hour!, 2), 'hour'],\n ['H', (t) => String(t.hour!), 'hour'],\n ['hh', (t) => pad(t.hour! % 12 || 12, 2), 'hour'],\n ['h', (t) => String(t.hour! % 12 || 12), 'hour'],\n ['mm', (t) => pad(t.minute!, 2), 'minute'],\n ['m', (t) => String(t.minute!), 'minute'],\n ['ss', (t) => pad(t.second!, 2), 'second'],\n ['s', (t) => String(t.second!), 'second'],\n // Fractional-second tokens, S through SSSSSSSSS (1-9 digits). Each token\n // formats a slice of the same underlying nanosecond-of-second value —\n // combining millisecond/microsecond/nanosecond into one 9-digit number\n // and truncating to the token's width — so \"SSS\" keeps meaning exactly\n // what it always meant (3-digit milliseconds) while wider tokens expose\n // the precision Temporal actually carries. formatFraction below is the\n // shared implementation; see its comment for the truncate-not-round\n // rule and why.\n ['SSSSSSSSS', (t) => pad.fraction(t, 9), 'millisecond'],\n ['SSSSSSSS', (t) => pad.fraction(t, 8), 'millisecond'],\n ['SSSSSSS', (t) => pad.fraction(t, 7), 'millisecond'],\n ['SSSSSS', (t) => pad.fraction(t, 6), 'millisecond'],\n ['SSSSS', (t) => pad.fraction(t, 5), 'millisecond'],\n ['SSSS', (t) => pad.fraction(t, 4), 'millisecond'],\n ['SSS', (t) => pad.fraction(t, 3), 'millisecond'],\n ['SS', (t) => pad.fraction(t, 2), 'millisecond'],\n ['S', (t) => pad.fraction(t, 1), 'millisecond'],\n // dayPeriod text is locale-specific (AM/PM in en-US, م/ص in ar-EG) but\n // still needs .hour on the input to compute which period it is\n ['a', (t, locale) => dayPeriodPart(t.hour!, locale), 'hour'],\n ['zzz', (t) => t.timeZoneId!, 'timeZoneId'],\n // Numeric UTC offset tokens (date-fns/Unicode-LDML family). Only\n // ZonedDateTime carries an offset, so the field check in format() throws\n // the same \"requires offset, which this Temporal object doesn't have\"\n // error zzz throws on PlainDate/PlainTime/PlainDateTime — same\n // validation path, just a different field name. See formatOffset above\n // for the per-variant width and Z/numeric distinction.\n ['xxx', (t) => formatOffset(t.offset!, 'xxx'), 'offset'],\n ['xx', (t) => formatOffset(t.offset!, 'xx'), 'offset'],\n ['X', (t) => formatOffset(t.offset!, 'X'), 'offset'],\n ['XX', (t) => formatOffset(t.offset!, 'XX'), 'offset'],\n ['XXX', (t) => formatOffset(t.offset!, 'XXX'), 'offset'],\n ['x', (t) => formatOffset(t.offset!, 'x'), 'offset'],\n\n // Ordinal day (1st, 2nd, 3rd, ... 21st). English suffix rules only —\n // locale-aware ordinals (\"2.\" in de-DE, \"2日\" in ja-JP) are out of scope,\n // since the rest of this library routes locale-specific names through\n // Intl.DateTimeFormat, and Intl has no part type for ordinals. Format-only:\n // the suffix isn't structurally distinguishable from a literal in a parse\n // context (a \"st\"/\"nd\"/\"rd\"/\"th\" suffix isn't a digit and would collide\n // with any adjacent literal text), so there's no good way to read it back.\n ['do', (t) => {\n const day = t.day!;\n const lastDigit = day % 10;\n // 11, 12, 13 are the exception — they'd otherwise match the 1/2/3 rule\n // and produce \"11st\"/\"12nd\"/\"13rd\", which is wrong. They always take \"th\".\n const lastTwoDigits = day % 100;\n if (lastTwoDigits >= 11 && lastTwoDigits <= 13) {\n return day + 'th';\n }\n if (lastDigit === 1) return day + 'st';\n if (lastDigit === 2) return day + 'nd';\n if (lastDigit === 3) return day + 'rd';\n return day + 'th';\n }, 'day'],\n\n // Quarter computed from month: 1-3=Q1, 4-6=Q2, 7-9=Q3, 10-12=Q4.\n // `Q` is plain numeric, `QQQ` renders as \"Q3\" — same convention as\n // date-fns's `Q` and `QQQ` for parity with the most common prior art.\n // Both format and parse; parse() cross-checks Q/QQQ against the parsed\n // month in the same spirit as the EEEE-vs-date cross-check.\n ['Q', (t) => String(Math.ceil(t.month! / 3)), 'month'],\n ['QQQ', (t) => 'Q' + Math.ceil(t.month! / 3), 'month'],\n\n // ISO 8601 week and week-numbering year. Both are format-only — parsing\n // \"ww\"/\"RRRR\" back into a real date requires resolving an ISO week + a\n // weekday (or some other disambiguator) to a specific date, which is a\n // different parsing surface than the token-based parse() here. The\n // ISO-week year (RRRR) can differ from the calendar year at the boundary:\n // Dec 29-31 often belong to week 1 of the *next* year; Jan 1-3 often\n // belong to week 52/53 of the *previous* year. See isoWeekYearAndWeek().\n ['ww', (t) => {\n const { week } = isoWeekYearAndWeek(t.year!, t.month!, t.day!, t.dayOfWeek!);\n return pad(week, 2);\n }, 'dayOfWeek'],\n ['RRRR', (t) => {\n const { isoYear } = isoWeekYearAndWeek(t.year!, t.month!, t.day!, t.dayOfWeek!);\n return pad(isoYear, 4);\n }, 'dayOfWeek'],\n\n // Day of year — number of days since Jan 1 (1-366). Three widths:\n // D — unpadded (1, 2, 366)\n // DD — 2-digit minimum (zero-padded if <100)\n // DDD — 3-digit zero-padded (001, 002, 366)\n // Format-only — parsing day-of-year requires resolving against a year,\n // which is a different shape from the token-based parse() surface.\n // The dayOfYearHelper() in calendarUtils.ts covers the same field for\n // callers who need the numeric value.\n ['D', (t) => String(dayOfYear(t.year!, t.month!, t.day!)), 'day'],\n ['DD', (t) => pad(dayOfYear(t.year!, t.month!, t.day!), 2), 'day'],\n ['DDD', (t) => pad(dayOfYear(t.year!, t.month!, t.day!), 3), 'day'],\n\n // Stand-alone month — uses Intl's stand-alone form. In most locales\n // (en, fr, de, es) this is identical to MMMM/MMM. In Slavic/Baltic\n // locales (cs, sk, pl, ru) the stand-alone form differs from the\n // format form (nominative vs genitive case). LLLL = long, LLL = short.\n ['LLLL', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { month: 'long' }, 'month', custom?.monthLong, t.month! - 1);\n }, 'month'],\n ['LLL', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { month: 'short' }, 'month', custom?.monthShort, t.month! - 1);\n }, 'month'],\n\n // Stand-alone weekday — same pattern as stand-alone month but for\n // weekday names. cccc = long, ccc = short.\n ['cccc', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { weekday: 'long' }, 'weekday', custom?.weekdayLong, t.dayOfWeek! - 1);\n }, 'dayOfWeek'],\n ['ccc', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { weekday: 'short' }, 'weekday', custom?.weekdayShort, t.dayOfWeek! - 1);\n }, 'dayOfWeek'],\n\n // Era — locale-aware (\"AD\"/\"BC\" in en, \"ap. J.-C.\"/\"av. J.-C.\" in fr).\n // GGGG = long, G = short. Format-only.\n ['GGGG', (t, locale) => {\n return intlPart(t, locale, { era: 'long' }, 'era');\n }, 'year'],\n ['G', (t, locale) => {\n return intlPart(t, locale, { era: 'short' }, 'era');\n }, 'year'],\n\n // Localized timezone name — uses Intl's longLocalized/short timezone\n // name option. Format-only — these names are locale-dependent and\n // vary by season (EST vs EDT), so parsing them back requires a\n // lookup table that isn't practical to ship.\n ['zzzz', (t, locale) => {\n return intlPart(t, locale, { timeZoneName: 'longGeneric' as Intl.DateTimeFormatOptions['timeZoneName'] }, 'timeZoneName' as Intl.DateTimeFormatPartTypes);\n }, 'timeZoneId'],\n ['z', (t, locale) => {\n return intlPart(t, locale, { timeZoneName: 'short' as Intl.DateTimeFormatOptions['timeZoneName'] }, 'timeZoneName' as Intl.DateTimeFormatPartTypes);\n }, 'timeZoneId'],\n\n];"],"mappings":"sJAKO,SAASA,EAAIC,EAAWC,EAAqB,CAGlD,IAAMC,EAAWF,EAAI,EACfG,EAAS,OAAO,KAAK,IAAIH,CAAC,CAAC,EAAE,SAASC,EAAK,GAAG,EACpD,OAAOC,EAAW,IAAMC,EAASA,CACnC,CAmBAJ,EAAI,SAAW,SAAwB,EAAiBK,EAAuB,CAC7E,IAAMC,EAAe,EAAE,YAAe,KAAa,EAAE,aAAe,GAAK,KAAS,EAAE,YAAc,GAClG,OAAON,EAAIM,EAAc,CAAC,EAAE,MAAM,EAAGD,CAAK,CAC5C,EAwCO,IAAME,EAAiB,QAIxBC,EAAiB,IAAI,IACrBC,EAAiB,IAEvB,SAASC,EAAaC,EAAgBC,EAA0D,CAC9F,IAAMC,EAAM,KAAK,UAAU,CAACC,EAAkBH,CAAM,EAAGC,CAAO,CAAC,EAC3DG,EAAYP,EAAe,IAAIK,CAAG,EACtC,GAAIE,EACF,OAAOA,EAET,GAAIP,EAAe,MAAQC,EAAgB,CAEzC,IAAMO,EAAYR,EAAe,KAAK,EAAE,KAAK,EAAE,MAC3CQ,IAAc,QAAWR,EAAe,OAAOQ,CAAS,CAC9D,CACA,GAAI,CACFD,EAAY,IAAI,KAAK,eAAeE,EAAmBN,CAAM,EAAGC,CAAO,CACzE,OAASM,EAAK,CAOZ,MAAM,IAAIC,EAAmB,CAAE,OAAQR,EAAQ,OAASO,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AAG9C,IAAW,CACrB,IAAMgC,EAASC,EAAejC,CAAM,EACpC,OAAOoC,EAAgBU,EAAG9C,EAAQ,CAAE,QAAS,OAAQ,EAAG,UAAWgC,GAAQ,aAAcc,EAAE,UAAa,CAAC,CAC3G,EAAG,WAAW,EAId,CAAC,OAAQ,CAACA,EAAG9C,IACJc,EAASgC,EAAG9C,EAAQ,CAAE,IAAK,MAAO,EAAG,KAAK,EAChD,MAAM,EACT,CAAC,IAAK,CAAC8C,EAAG9C,IACDc,EAASgC,EAAG9C,EAAQ,CAAE,IAAK,OAAQ,EAAG,KAAK,EACjD,MAAM,EAMT,CAAC,OAAQ,CAAC8C,EAAG9C,IACJc,EAASgC,EAAG9C,EAAQ,CAAE,aAAc,aAA4D,EAAG,cAA8C,EACvJ,YAAY,EACf,CAAC,IAAK,CAAC8C,EAAG9C,IACDc,EAASgC,EAAG9C,EAAQ,CAAE,aAAc,OAAsD,EAAG,cAA8C,EACjJ,YAAY,CAEjB","names":["pad","n","len","negative","digits","width","nanoOfSecond","DEFAULT_LOCALE","formatterCache","MAX_CACHE_SIZE","getFormatter","locale","options","key","canonicalCacheKey","formatter","oldestKey","normalizeLocaleTag","err","InvalidLocaleError","nativeSupport","subscribeToTemporalChanges","intlSupportsNativeTemporal","temporal","getTemporal","intlPart","partType","calendar","formatterOptions","ls","toInstant","timeZoneId","isZoned","intlSafeTemporal","nativeOptions","parts","index","p","value","prev","next","dayPeriodPart","hour","custom","getCustomVocab","date","part","localeAwareName","customArray","customIndex","formatOffset","offset","variant","sign","hours","minutes","TOKENS","t","day","lastDigit","lastTwoDigits","week","isoWeekYearAndWeek","isoYear","dayOfYear"]}
|
package/dist/chunk-YB6YAG7E.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import{a as ue,f as q}from"./chunk-R52YOKI3.js";import{a as F}from"./chunk-C5YESWFT.js";import{c as me}from"./chunk-3MZLTVP3.js";import{a as se,b as h,c as G,d as $,e as M,g as A,h as V,j as K,m as oe,n as ae,q as j,r as ie,t as v}from"./chunk-5U5WJ465.js";function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function R(e,n=!1){let t=e.map(Se);return n?`(?:${t.map(ye).join("|")})`:`(?:${t.join("|")})`}function ye(e){return e.replace(/[a-zA-Z]/g,n=>`[${n.toLowerCase()}${n.toUpperCase()}]`)}var be="(?:UTC|[+-]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,9})?)?|[A-Za-z_]+(?:[+-]\\d{1,2})?(?:\\/[A-Za-z0-9_+-]+)*)",xe={X:"(?:Z|[+-]\\d{2}(?:\\d{2})?)",XX:"(?:Z|[+-]\\d{4})",XXX:"(?:Z|[+-]\\d{2}:\\d{2})",x:"[+-]\\d{2}(?:\\d{2})?",xx:"[+-]\\d{4}",xxx:"[+-]\\d{2}:\\d{2}"};function ke(){return be}var Z;function $e(){return Z||(Z=new Set(Intl.supportedValuesOf("timeZone")),Z.add("UTC")),Z}var Ee=/^[+-]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/;function J(e){return Ee.test(e)||$e().has(e)}var Pe={yy:"\\d{2}",MM:"(?:0[1-9]|1[0-2])",M:"(?:1[0-2]|[1-9])",dd:"(?:0[1-9]|[12]\\d|3[01])",d:"(?:[12]\\d|3[01]|[1-9])",HH:"(?:[01]\\d|2[0-3])",H:"(?:1\\d|2[0-3]|[0-9])",hh:"(?:0[1-9]|1[0-2])",h:"(?:1[0-2]|[1-9])",mm:"(?:[0-5]\\d)",m:"(?:[1-5]\\d|[0-9])",ss:"(?:[0-5]\\d)",s:"(?:[1-5]\\d|[0-9])",SSSSSSSSS:"\\d{9}",SSSSSSSS:"\\d{8}",SSSSSSS:"\\d{7}",SSSSSS:"\\d{6}",SSSSS:"\\d{5}",SSSS:"\\d{4}",SSS:"\\d{3}",SS:"\\d{2}",S:"\\d",Q:"[1-4]"},Ne="Q[1-4]",Me=new Set(["do","ww","RRRR","D","DD","DDD","LLLL","LLL","cccc","ccc","GGGG","G","zzzz","z"]),ve="-?\\d{4}",Te="-?\\d{4,}",B=new Set(["yyyy","yy","MM","M","dd","d","HH","H","hh","h","mm","m","ss","s","SSSSSSSSS","SSSSSSSS","SSSSSSS","SSSSSS","SSSSS","SSSS","SSS","SS","S"]);function H(e,n,t){if(e==="yyyy")return t!==void 0&&B.has(t)?ve:Te;let r=Pe[e];if(r)return r;if(e==="QQQ")return Ne;if(Me.has(e))throw new G({token:e,message:`temporal-fmt: token "${e}" is format-only \u2014 it can't be parsed back into a value. Use a different token in the parse format string (e.g. "d" for "do", "MM" for "ww").`});let s=v(n);switch(e){case"MMMM":return R(s.monthLong);case"MMM":return R(s.monthShort);case"EEEE":return R(s.weekdayLong);case"EEE":return R(s.weekdayShort);case"a":return R(s.dayPeriod,!0);case"zzz":return ke();case"X":case"XX":case"XXX":case"x":case"xx":case"xxx":return xe[e];default:throw new G({token:e,message:`temporal-fmt: unknown token "${e}"`})}}var de=new Set(["M","d","H","h","m","s"]),Oe={M:[{digits:1,min:1,max:9},{digits:2,min:10,max:12}],d:[{digits:1,min:1,max:9},{digits:2,min:10,max:31}],H:[{digits:1,min:0,max:9},{digits:2,min:10,max:23}],h:[{digits:1,min:1,max:9},{digits:2,min:10,max:12}],m:[{digits:1,min:0,max:9},{digits:2,min:10,max:59}],s:[{digits:1,min:0,max:9},{digits:2,min:10,max:59}]};function W(e,n){let t=new Map;function r(s,o){let i=`${s}:${o}`,u=t.get(i);if(u)return u;if(s===n.length){let a=o===e.length?[[]]:[];return t.set(i,a),a}let S=n[s],l=Oe[S];/* c8 ignore start @preserve -- defensive guard, not reachable through
|
|
2
|
-
the public API. enumerateValidSplits's only caller (parse.ts, both
|
|
3
|
-
call sites) passes run.tokens straight from
|
|
4
|
-
pattern.ambiguousRuns, which parsePattern.ts only ever populates
|
|
5
|
-
with tokens already checked against UNPADDED_NUMERIC_TOKENS — the
|
|
6
|
-
exact same key set as UNPADDED_NUMERIC_RANGES. There's no path
|
|
7
|
-
where a token reaches here without having already passed that
|
|
8
|
-
check. */if(!l)throw new Error(`temporal-fmt: internal error \u2014 "${S}" is not an unpadded numeric token`);/* c8 ignore stop @preserve */let m=[];for(let{digits:a,min:g,max:f}of l){if(o+a>e.length)continue;let p=e.slice(o,o+a);if(a===2&&p[0]==="0")continue;let y=Number(p);if(!(y<g||y>f)){for(let D of r(s+1,o+a))if(m.push([y,...D]),m.length===2)break;if(m.length===2)break}}return t.set(i,m),m}return r(0,0)}function De(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ce=12;function Xe(e){return Math.ceil(Math.log2(Math.max(e,1)))}function ee(e){return e===void 0?!1:e.kind==="literal"?/^[0-9]/.test(e.value):B.has(e.value)}function ge(e,n){let t=[],r=[],s="",o=0,i=0,u={names:[],tokens:[]},S=l=>{if(u.tokens.length===1){let m=u.names[0],a=u.tokens[0];s+=`(?<${m}>${H(a,n)})`,ee(l)&&(i+=1)}else if(u.tokens.length>=2){let m=`r${o++}`,a=u.tokens.length;s+=`(?<${m}>\\d{${a},${a*2}})`,r.push({groupName:m,groupNames:u.names,tokens:u.tokens}),ee(l)&&(i+=Xe(a+1))}u={names:[],tokens:[]}};for(let[l,m]of e.entries()){if(m.kind==="literal"){S(m),s+=De(m.value);continue}if(de.has(m.value)){let p=`g${o++}`;t.push({name:p,token:m.value}),u.names.push(p),u.tokens.push(m.value);continue}S(m);let a=`g${o++}`;t.push({name:a,token:m.value});let g=e[l+1],f=g?.kind==="token"?g.value:void 0;m.value==="yyyy"&&f===void 0&&ee(g)?s+=`(?<${a}>${H(m.value,n,"M")})`:s+=`(?<${a}>${H(m.value,n,f)})`}if(S(void 0),i>ce)throw new h({reason:`format string has too many variable-width numeric tokens glued to digit-consuming neighbors (ambiguity score ${i} > ${ce}). This shape makes the regex engine backtrack exponentially on near-miss input. Add a non-digit separator between these tokens (e.g. "-" or " ") or use their padded forms (MM/dd/HH/mm/ss).`});return{regex:new RegExp(`^(?:${s})$`,"ud"),groups:t,ambiguousRuns:r}}var O=new Map,Ce=500;ae(()=>{O.clear()});function te(e,n){let t=JSON.stringify([j(n),e]),r=O.get(t);if(r)return r;if(O.size>=Ce){let s=O.keys().next().value;s!==void 0&&O.delete(s)}return r=ge(ue(e),n),O.set(t,r),r}var T=new Map,Ae=500;function Re(e){ie(e);let n=j(e);if(T.has(n))return T.get(n);if(T.size>=Ae){let i=T.keys().next().value;i!==void 0&&T.delete(i)}let t,r=n.split("-"),s=r.indexOf("u"),o=s===-1?-1:r.indexOf("ca",s+1);if(o!==-1&&o+1<r.length){let i=new Intl.DateTimeFormat(n).resolvedOptions().calendar;t=i==="gregory"?void 0:i}return T.set(n,t),t}function _e(e,n){if(e==="Z"){/* c8 ignore start @preserve -- unreachable: lowercase tokens' regex
|
|
9
|
-
(OFFSET_SHAPES in pattern.ts) has no "Z" alternative at all, so
|
|
10
|
-
raw === 'Z' can only ever be reached when token is one of the
|
|
11
|
-
uppercase variants (X/XX/XXX). A lowercase token can't even
|
|
12
|
-
capture "Z" as `raw` in the first place. */if(n==="x"||n==="xx"||n==="xxx")throw new Error(`temporal-fmt: offset token "${n}" doesn't accept "Z" \u2014 only the uppercase variants (X/XX/XXX) emit "Z" for UTC. Use "+00:00", "+0000", or "+00" depending on the variant's width.`);/* c8 ignore stop @preserve */return"+00:00"}let t=e[0];/* c8 ignore start @preserve -- unreachable: raw is a regex-captured
|
|
13
|
-
group from an offset token, and every OFFSET_SHAPES pattern
|
|
14
|
-
(pattern.ts) is anchored to either "Z" or a leading [+-]. raw's
|
|
15
|
-
first character can never be anything else by the time it reaches
|
|
16
|
-
this function. */if(t!=="+"&&t!=="-")throw new Error(`temporal-fmt: offset "${e}" for token "${n}" doesn't start with "+", "-", or "Z".`);/* c8 ignore stop @preserve */let r=e.slice(1),s,o;if(r.length===2){/* c8 ignore start @preserve -- unreachable: each offset token's own
|
|
17
|
-
regex shape in OFFSET_SHAPES (pattern.ts) already gates which
|
|
18
|
-
body shapes it can capture. Only X and x ever match a 2-digit
|
|
19
|
-
body — XX/xx/XXX/xxx's regexes can't produce one — so this
|
|
20
|
-
mismatch can never actually fire through parse(). */if(n!=="X"&&n!=="x")throw new Error(`temporal-fmt: offset token "${n}" can't match "${e}" \u2014 it requires minutes, but "${e}" has none.`);/* c8 ignore stop @preserve */s=r,o="00"}else if(r.length===4){/* c8 ignore start @preserve -- unreachable, same reason as the
|
|
21
|
-
2-digit case above: XXX/xxx's regex requires a colon, so it can
|
|
22
|
-
never capture a 4-digit no-colon body in the first place. */if(n==="XXX"||n==="xxx")throw new Error(`temporal-fmt: offset token "${n}" can't match "${e}" \u2014 it requires a colon between hours and minutes (e.g. "${t}${r.slice(0,2)}:${r.slice(2)}").`);/* c8 ignore stop @preserve */s=r.slice(0,2),o=r.slice(2,4)}else if(r.length===5&&r[2]===":"){/* c8 ignore start @preserve -- unreachable, same reason again: only
|
|
23
|
-
XXX/xxx's regex can produce a colon-shaped body; X/x/XX/xx never
|
|
24
|
-
capture one. */if(n!=="XXX"&&n!=="xxx")throw new Error(`temporal-fmt: offset token "${n}" can't match "${e}" \u2014 it doesn't use a colon (use "${t}${r.slice(0,2)}${r.slice(3)}" instead).`);/* c8 ignore stop @preserve */s=r.slice(0,2),o=r.slice(3,5);/* c8 ignore start @preserve -- unreachable: every offset token's
|
|
25
|
-
regex only ever produces a body of length 2, length 4, or length 5
|
|
26
|
-
with a colon at index 2 (see OFFSET_SHAPES in pattern.ts) — no
|
|
27
|
-
shape falls outside those three cases, so this else arm can't be
|
|
28
|
-
taken through parse(). Kept as an exhaustiveness fallback so
|
|
29
|
-
hoursStr/minutesStr are assigned on every path TypeScript can see. */}else throw new Error(`temporal-fmt: offset "${e}" doesn't match the shape token "${n}" accepts.`);/* c8 ignore stop @preserve */let i=Number(s),u=Number(o);if(i>14)throw new A({actual:e,message:`temporal-fmt: offset hours ${i} in "${e}" out of range (max 14 \u2014 Kiritimati, Line Islands is +14:00).`});if(u>59)throw new A({actual:e,message:`temporal-fmt: offset minutes ${u} in "${e}" out of range (max 59).`});if(t==="+"&&i===14&&u!==0)throw new A({actual:e,message:`temporal-fmt: offset "${e}" exceeds the maximum supported UTC offset of +14:00.`});if(t==="-"&&i===12&&u!==0)throw new A({actual:e,message:`temporal-fmt: offset "${e}" exceeds the maximum supported negative UTC offset of -12:00.`});return`${t}${s}:${o}`}function d(e,n,t){e[n]=t}function ze(e,n,t,r,s){let o=v(r);switch(n){case"yyyy":d(e,"year",Number(t));break;case"yy":d(e,"twoDigitYear",Number(t));break;case"MM":case"M":d(e,"month",Number(t));break;case"MMMM":d(e,"month",o.monthLong.indexOf(t)+1);break;case"MMM":d(e,"month",o.monthShort.indexOf(t)+1);break;case"dd":case"d":d(e,"day",Number(t));break;case"EEEE":d(e,"weekdayRaw",t),d(e,"weekdayExpected",o.weekdayLong.indexOf(t)+1);break;case"EEE":d(e,"weekdayRaw",t),d(e,"weekdayExpected",o.weekdayShort.indexOf(t)+1);break;case"HH":case"H":d(e,"hour",Number(t));break;case"hh":case"h":d(e,"hour12",Number(t));break;case"mm":case"m":d(e,"minute",Number(t));break;case"ss":case"s":d(e,"second",Number(t));break;case"S":case"SS":case"SSS":case"SSSS":case"SSSSS":case"SSSSSS":case"SSSSSSS":case"SSSSSSSS":case"SSSSSSSSS":{let i=Number(t.padEnd(9,"0"));d(e,"millisecond",Math.floor(i/1e6)),d(e,"microsecond",Math.floor(i/1e3)%1e3),d(e,"nanosecond",i%1e3);break}case"a":{let i=o.dayPeriod.findIndex(u=>u.toLowerCase()===t.toLowerCase());/* c8 ignore start @preserve -- unreachable: the 'a' token's regex
|
|
30
|
-
fragment (pattern.ts's alternation() over vocab.dayPeriod) can
|
|
31
|
-
only ever capture a case-insensitive match of one of
|
|
32
|
-
vocab.dayPeriod's own entries. Both the regex and this lookup
|
|
33
|
-
derive their vocab from the same `locale` via getLocaleVocab(),
|
|
34
|
-
so periodIndex can't come back negative through parse(). */if(i<0)throw new Error(`temporal-fmt: unknown day period "${t}" for locale "${r}".`);/* c8 ignore stop @preserve */d(e,"dayPeriodRaw",t),d(e,"isPM",i===1);break}case"zzz":d(e,"timeZoneId",t);break;case"X":case"XX":case"XXX":case"x":case"xx":case"xxx":d(e,"offsetString",_e(t,n));break;case"Q":d(e,"quarter",Number(t));break;case"QQQ":d(e,"quarter",Number(t.slice(1)));break}}function fe(e,n){let t=n.indexOf("d");if(t!==-1){let r=e.filter(s=>s[t]<=12);if(r.length>0)return r[0]}return e[0]}function Ie(e){if(e.year!==void 0&&e.twoDigitYear!==void 0)throw new h({message:'temporal-fmt: format string mixes "yyyy" and "yy" year representations.'});if(e.year!==void 0)return e.year;if(e.twoDigitYear!==void 0)return e.twoDigitYear<=68?2e3+e.twoDigitYear:1900+e.twoDigitYear}function Le(e,n,t){if(e.hour!==void 0&&e.hour12!==void 0)throw new h({format:n,message:`temporal-fmt: format string "${n}" mixes a 24-hour token ("HH"/"H") with a 12-hour token ("hh"/"h").`});if(e.hour!==void 0){if(e.dayPeriodRaw!==void 0){let r=v(t),s=e.hour<12?r.dayPeriod[0]:r.dayPeriod[1];if(e.dayPeriodRaw.toLowerCase()!==s?.toLowerCase())throw new h({format:n,message:`temporal-fmt: format string "${n}" contains a day period that contradicts the 24-hour value.`})}return e.hour}if(e.hour12!==void 0){if(e.isPM===void 0)throw new h({format:n,message:`temporal-fmt: format string "${n}" uses a 12-hour token ("hh"/"h") without an "a" token, so parse() can't tell AM from PM.`});return e.hour12%12+(e.isPM?12:0)}}function re(e,n,t={}){if(e.length>1e3)throw new h({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});if(n.length>1e5)throw new h({input:n,message:`temporal-fmt: input exceeds maximum length of ${1e5} characters (got ${n.length}).`});t.parseNumberingSystem&&(n=q(n,t));let r=t.locale??F,s=Re(r),o=te(e,r),i=o.regex.exec(n);if(!i)throw new $({input:n,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(o.groups.length===0)throw new $({format:e,reason:`format string "${e}" has no tokens \u2014 nothing to parse into a value.`,message:`temporal-fmt: format string "${e}" has no tokens \u2014 nothing to parse into a value.`});for(let{name:c,token:w}of o.groups)if(w==="zzz"&&!J(i.groups[c]))throw new V({input:n,format:e,actual:i.groups[c],reason:"not a recognized IANA time zone identifier"});let u=new Map;for(let c of o.ambiguousRuns){let w=i.groups[c.groupName],b=W(w,c.tokens);if(b.length===0)throw new $({input:n,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(b.length>1){if(!t.lenient)throw new K({input:n,format:e,message:`temporal-fmt: "${w}" in format string "${e}" is ambiguous \u2014 ${b.length} different ways to read tokens "${c.tokens.join("")}" (with no separator between them) are all individually valid (e.g. ${JSON.stringify(b[0])} vs ${JSON.stringify(b[1])}). parse() won't guess; add a separator between these tokens, or use their padded form (e.g. "MM" instead of "M") so each one has a fixed width. Pass { lenient: true } to opt into a documented heuristic that picks one.`});let N=fe(b,c.tokens);c.groupNames.forEach((Y,we)=>u.set(Y,String(N[we])))}else c.groupNames.forEach((N,Y)=>u.set(N,String(b[0][Y])))}let S={};for(let{name:c,token:w}of o.groups){let b=u.get(c)??i.groups[c];ze(S,w,b,r,e)}let l=Ie(S),m=Le(S,e,r),{month:a,day:g,minute:f,second:p,millisecond:y,microsecond:D,nanosecond:le,timeZoneId:X,offsetString:x,weekdayExpected:U,weekdayRaw:he,quarter:Q}=S,pe=l!==void 0||a!==void 0||g!==void 0,E=l!==void 0&&a!==void 0&&g!==void 0;if(pe&&!E)throw new M({format:e,message:`temporal-fmt: format string "${e}" has an incomplete date \u2014 year, month, and day tokens must all be present together.`});let z=m!==void 0||f!==void 0||p!==void 0||y!==void 0;if(X!==void 0&&!(E&&z))throw new h({format:e,message:`temporal-fmt: format string "${e}" has a "zzz" token but needs a full date and time to build a ZonedDateTime.`});if(x!==void 0&&!(E&&z))throw new h({format:e,message:`temporal-fmt: format string "${e}" has an offset token (X/XX/XXX/x/xx/xxx) but needs a full date and time to build a ZonedDateTime.`});if(U!==void 0&&!E)throw new h({format:e,message:`temporal-fmt: format string "${e}" has a weekday token ("EEEE"/"EEE") but needs a full date to validate it against.`});if(!E&&!z)throw new h({format:e,message:`temporal-fmt: format string "${e}" has no date or time tokens to parse.`});let C=me(),P={hour:m??0,minute:f??0,second:p??0,millisecond:y??0,microsecond:D??0,nanosecond:le??0},I=s?{calendar:s}:{},L={overflow:"reject"},k;try{if(X!==void 0){let c={overflow:"reject",offset:"prefer"};if(k=C.ZonedDateTime.from({year:l,month:a,day:g,...P,...I,timeZone:X,...x!==void 0?{offset:x}:{}},c),x!==void 0){let w=k;if(w.hour!==P.hour||w.minute!==P.minute||w.second!==P.second)throw new M({input:n,format:e,message:`"${X}" has no such wall-clock time on this date \u2014 it falls in a DST gap, not an ambiguous or valid instant.`});let N=w.offset;if(N!==x)throw new $({input:n,format:e,message:`has both a "zzz" zone (${X}) and an offset token (${x}), but the zone's actual offset at this date/time is ${N}, not ${x}.`})}}else x!==void 0?k=C.ZonedDateTime.from({year:l,month:a,day:g,...P,...I,timeZone:x},L):E&&z?k=C.PlainDateTime.from({year:l,month:a,day:g,...P,...I},L):E?k=C.PlainDate.from({year:l,month:a,day:g,...I},L):k=C.PlainTime.from(P,L)}catch(c){throw new M({input:n,format:e,message:`temporal-fmt: "${n}" doesn't describe a valid date/time for format "${e}": ${c.message}`})}if(U!==void 0){let c=k.dayOfWeek;if(c!==U){let w=v(r);throw new M({input:n,format:e,message:`temporal-fmt: "${he}" doesn't match the actual weekday (${w.weekdayLong[c-1]}) for the parsed date.`})}}if(Q!==void 0&&a!==void 0){let c=Math.ceil(a/3);if(Q!==c)throw new M({format:e,message:`temporal-fmt: format string "${e}" contains a quarter token (Q/QQQ) whose value (Q${Q}) disagrees with the parsed month's actual quarter \u2014 month ${a} is in Q${c}.`})}return k}function Fe(e,n,t={}){try{return{ok:!0,value:re(e,n,t)}}catch(r){/* c8 ignore start @preserve */return r instanceof se?{ok:!1,error:r}:{ok:!1,error:oe(r,{input:n,format:e})}}/* c8 ignore stop @preserve */}function Ze(e,n,t={}){try{return re(e,n,t)}catch{return}}function He(e,n,t={}){if(e.length>1e3)throw new h({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});if(n.length>1e5)throw new h({input:n,message:`temporal-fmt: input exceeds maximum length of ${1e5} characters (got ${n.length}).`});t.parseNumberingSystem&&(n=q(n,t));let r=t.locale??F,s=te(e,r),o=s.regex.exec(n);if(!o)throw new $({input:n,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(s.groups.length===0)throw new $({format:e,reason:`format string "${e}" has no tokens \u2014 nothing to parse into a value.`,message:`temporal-fmt: format string "${e}" has no tokens \u2014 nothing to parse into a value.`});for(let{name:a,token:g}of s.groups)if(g==="zzz"&&!J(o.groups[a]))throw new V({input:n,format:e,actual:o.groups[a],reason:"not a recognized IANA time zone identifier"});let i=new Map;for(let a of s.ambiguousRuns){let g=o.groups[a.groupName],f=W(g,a.tokens);if(f.length===0)throw new $({input:n,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(f.length>1){if(!t.lenient)throw new K({input:n,format:e,message:`temporal-fmt: "${g}" in format string "${e}" is ambiguous \u2014 ${f.length} different ways to read tokens "${a.tokens.join("")}" (with no separator between them) are all individually valid (e.g. ${JSON.stringify(f[0])} vs ${JSON.stringify(f[1])}). parse() won't guess; add a separator between these tokens, or use their padded form (e.g. "MM" instead of "M") so each one has a fixed width. Pass { lenient: true } to opt into a documented heuristic that picks one.`});let p=fe(f,a.tokens);a.groupNames.forEach((y,D)=>i.set(y,String(p[D])))}else a.groupNames.forEach((p,y)=>i.set(p,String(f[0][y])))}let u=[],l=o.indices?.groups,m=0;for(let{name:a,token:g}of s.groups){let f=i.get(a)??o.groups[a],p=!i.has(a)&&l?.[a],y=p?p[0]:(o.index??0)+m;u.push({token:g,raw:f,position:y}),m+=f.length}return u}function rn(e,n={}){if(e.length>1e3)throw new h({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});let t=n.locale??F,r=te(e,t);return{formatStr:e,pattern:r,parse(s,o={}){return re(e,s,{locale:t,...o})},safeParse(s,o={}){return Fe(e,s,{locale:t,...o})},tryParse(s,o={}){return Ze(e,s,{locale:t,...o})},parseToParts(s,o={}){return He(e,s,{locale:t,...o})}}}export{Me as a,de as b,re as c,Fe as d,Ze as e,He as f,rn as g};
|
|
35
|
-
//# sourceMappingURL=chunk-YB6YAG7E.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/pattern.ts","../src/parsePattern.ts","../src/parse.ts"],"sourcesContent":["import { getLocaleVocab } from './localeVocab.js';\nimport { UnknownTokenError } from './errors.js';\n\nfunction escapeRegExp(literal: string): string {\n return literal.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction alternation(values: string[], caseInsensitive = false): string {\n const escaped = values.map(escapeRegExp);\n if (!caseInsensitive) return `(?:${escaped.join('|')})`;\n // JS regex has no per-group inline case-insensitive flag, and this\n // fragment gets embedded in one larger pattern built with a single flag\n // set — so case-folding here means listing both cases explicitly rather\n // than relying on a flag.\n return `(?:${escaped.map(foldCase).join('|')})`;\n}\n\n// Expands \"PM\" into a character-class-per-letter pattern matching any\n// casing of it (\"[Pp][Mm]\"), so \"pm\", \"Pm\", \"PM\" all match the same\n// alternative. Only used for the day-period token (see the 'a' case\n// below) — not applied to month/weekday names, where case-folding across\n// scripts is a different and riskier problem this doesn't need to solve.\nfunction foldCase(value: string): string {\n return value.replace(/[a-zA-Z]/g, (ch) => `[${ch.toLowerCase()}${ch.toUpperCase()}]`);\n}\n\n// Every real IANA zone id is letters/digits/'_'/'+'/'-' segments joined by\n// '/' (e.g. \"America/Argentina/Buenos_Aires\", \"Etc/GMT+12\"); UTC and\n// fixed-offset strings are the only other shapes zzz accepts. Matching that\n// *shape* here — instead of alternating all ~400 zone names inline — keeps\n// the compiled regex small regardless of how many zzz tokens appear in a\n// format string. The captured text still gets checked against the real\n// zone set in isValidTimeZone() after the overall pattern matches, so this\n// is strictly a matching-cost change, not a validation-strictness change:\n// a bogus zone id fails \"no valid pattern matches\" exactly like it did when\n// the zone list was inlined (see isValidTimeZone's caller in parse.ts).\nconst TIME_ZONE_SHAPE = '(?:UTC|[+-]\\\\d{2}:\\\\d{2}(?::\\\\d{2}(?:\\\\.\\\\d{1,9})?)?|[A-Za-z_]+(?:[+-]\\\\d{1,2})?(?:\\\\/[A-Za-z0-9_+-]+)*)';\n\n// Per-variant regex shapes for the six offset tokens. Each matches the\n// shape its own format counterpart produces, so a round-trip\n// format->parse succeeds for any input the library itself emitted.\n//\n// Kept loose (no hour/minute range bounds inline) on purpose, mirroring\n// how TIME_ZONE_SHAPE is loose: a permissive shape here lets parse()\n// surface a descriptive out-of-range error post-match (see\n// parseOffsetString in parse.ts) instead of the generic \"no valid pattern\n// matches\" the regex throws when the shape itself fails. \"+99:99\" should\n// tell the user it's out of range, not look like the input never matched\n// the format at all.\n//\n// X / x accept an optional minutes group so whole-hour offsets can be\n// written short (\"+05\") while non-whole-hour offsets still parse\n// (\"+0530\"). The optional group is greedy, so for input \"+0530\" the\n// engine prefers the 4-digit match; only falls back to 2-digit when\n// there's nothing else to consume — same longer-first preference the\n// unpadded numeric tokens use elsewhere in this file (see the comment on\n// NUMERIC_FRAGMENTS).\nconst OFFSET_SHAPES: Record<string, string> = {\n X: '(?:Z|[+-]\\\\d{2}(?:\\\\d{2})?)',\n XX: '(?:Z|[+-]\\\\d{4})',\n XXX: '(?:Z|[+-]\\\\d{2}:\\\\d{2})',\n x: '[+-]\\\\d{2}(?:\\\\d{2})?',\n xx: '[+-]\\\\d{4}',\n xxx: '[+-]\\\\d{2}:\\\\d{2}',\n};\n\nfunction getTimeZoneFragment(): string {\n return TIME_ZONE_SHAPE;\n}\n\nlet validZoneSet: Set<string> | undefined;\n\n// Real zone ids plus the couple of aliases zzz has always accepted even\n// though Intl.supportedValuesOf('timeZone') doesn't list them (UTC isn't\n// itself an IANA zone name, it's the identity offset).\nfunction getValidZoneSet(): Set<string> {\n if (!validZoneSet) {\n validZoneSet = new Set(Intl.supportedValuesOf('timeZone'));\n validZoneSet.add('UTC');\n }\n return validZoneSet;\n}\n\nconst FIXED_OFFSET_RE = /^[+-]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,9})?)?$/;\n\n// Called post-match on whatever the bounded TIME_ZONE_SHAPE captured, since\n// that shape is deliberately looser than \"a real zone id\" (it has to be, to\n// stay a fixed-size regex fragment — see the comment above). A fixed offset\n// is valid by construction; anything else has to be a real IANA name.\nexport function isValidTimeZone(raw: string): boolean {\n return FIXED_OFFSET_RE.test(raw) || getValidZoneSet().has(raw);\n}\n\n// mirrors the ranges pad() in tokens.ts actually produces — keep in sync\n// if those ever change\n//\n// Unpadded alternatives (M, H, h, m, s) list the longer branch first\n// (e.g. '1[0-2]|[1-9]', not '[1-9]|1[0-2]'). This matters only when two\n// unpadded tokens are glued with no separator: with short-first ordering,\n// a regex engine takes the first successful overall match, and won't\n// backtrack into a token's second alternative unless its first choice\n// makes the *rest* of the pattern fail outright. If the short reading also\n// happens to leave a valid match for the next token, the engine stops\n// there — silently, deterministically, and with no relation to which\n// reading a human intended. E.g. \"Md\" against \"121\": short-first order\n// resolves it as month=1/day=21 (M grabs '1', d gets '21', which is a\n// valid day) instead of month=12/day=1. Longer-first ordering fixes this\n// by making the greedy match try to consume as many digits as possible\n// before ever handing digits to the next token, which is the reading\n// that matches how format() itself produces glued output in the first\n// place (format() always emits the token's natural width, so decoding\n// should prefer the same). Found via the token×token combinatorial glue\n// matrix in combinatorial.test.js — see that file for the full case list.\nconst NUMERIC_FRAGMENTS: Record<string, string> = {\n yy: '\\\\d{2}',\n MM: '(?:0[1-9]|1[0-2])',\n M: '(?:1[0-2]|[1-9])',\n dd: '(?:0[1-9]|[12]\\\\d|3[01])',\n d: '(?:[12]\\\\d|3[01]|[1-9])',\n HH: '(?:[01]\\\\d|2[0-3])',\n H: '(?:1\\\\d|2[0-3]|[0-9])',\n hh: '(?:0[1-9]|1[0-2])',\n h: '(?:1[0-2]|[1-9])',\n mm: '(?:[0-5]\\\\d)',\n m: '(?:[1-5]\\\\d|[0-9])',\n ss: '(?:[0-5]\\\\d)',\n s: '(?:[1-5]\\\\d|[0-9])',\n SSSSSSSSS: '\\\\d{9}',\n SSSSSSSS: '\\\\d{8}',\n SSSSSSS: '\\\\d{7}',\n SSSSSS: '\\\\d{6}',\n SSSSS: '\\\\d{5}',\n SSSS: '\\\\d{4}',\n SSS: '\\\\d{3}',\n SS: '\\\\d{2}',\n S: '\\\\d',\n // Q is always a single digit 1-4 (no padding variant, so no width ambiguity\n // with adjacent digit tokens the way M/d/H/m/s have).\n Q: '[1-4]',\n};\n\n// QQQ matches its own formatted output: the literal \"Q\" prefix plus a single\n// digit 1-4. Kept as a static fragment rather than routed through vocab,\n// since the \"Q\" prefix is part of the token's own contract, not locale-vocab\n// data that could ever differ.\nconst QQQ_FRAGMENT = 'Q[1-4]';\n\n// Format-only tokens — they have no parse counterpart. The tokenizer still\n// recognizes them (so format() can use them), but parse()'s regex builder\n// rejects them with a clear error rather than silently dropping the token\n// or falling through to the generic \"unknown token\" message.\n// Exported so analyze.ts can include them in the public analyzer surface.\nexport const FORMAT_ONLY_TOKENS = new Set(['do', 'ww', 'RRRR', 'D', 'DD', 'DDD', 'LLLL', 'LLL', 'cccc', 'ccc', 'GGGG', 'G', 'zzzz', 'z']);\n\n// pad()'s year formatter (tokens.ts) never truncates: it preserves the sign\n// for BCE years and doesn't cap width past 9999, so a formatted \"yyyy\" can\n// be longer than 4 digits or start with '-'. YYYY_EXTENDED accepts that;\n// YYYY_EXACT is the plain 4-unsigned-digit case. Which one a given \"yyyy\"\n// occurrence gets depends on what follows it — see buildCapturingPattern in\n// parsePattern.ts. Two separate fragments instead of one `-?\\d{4,}` because\n// an open-ended-width year directly followed by another digit token (e.g.\n// \"yyyyMM\") lets the year's own greediness silently eat digits meant for\n// the next token — same class of bug as UNPADDED_NUMERIC_TOKENS below, but\n// unbounded-width, so it can't reuse enumerateValidSplits' fixed-range\n// splitting. Restricting to exactly 4 digits whenever something could\n// follow closes that off entirely, at the cost of \"yyyyMM\" not being able\n// to represent a 5-digit year — an already-rare case doubly rare in\n// combination with a glued adjacent token.\nconst YYYY_EXACT = '-?\\\\d{4}';\nconst YYYY_EXTENDED = '-?\\\\d{4,}';\n\n// True for any token whose matched text can start with a digit — i.e.\n// every token here except the locale-named ones (MMMM/MMM/EEEE/EEE/a) and\n// zzz (which can start with a digit only via a fixed offset like \"+09:00\",\n// already handled by requiring a leading sign there). Used to decide\n// whether a \"yyyy\" immediately before this token needs the exact-4-digit\n// fragment instead of the open-ended one.\n// Exported for parsePattern.ts's ReDoS guard: a token whose regex\n// fragment can begin with a bare digit (see the guard comments there).\nexport const DIGIT_LEADING_TOKENS = new Set([\n 'yyyy', 'yy', 'MM', 'M', 'dd', 'd', 'HH', 'H', 'hh', 'h', 'mm', 'm', 'ss', 's',\n 'SSSSSSSSS', 'SSSSSSSS', 'SSSSSSS', 'SSSSSS', 'SSSSS', 'SSSS', 'SSS', 'SS', 'S',\n]);\n\nexport function tokenFragment(token: string, locale: string, nextToken?: string): string {\n if (token === 'yyyy') {\n return nextToken !== undefined && DIGIT_LEADING_TOKENS.has(nextToken) ? YYYY_EXACT : YYYY_EXTENDED;\n }\n\n const numeric = NUMERIC_FRAGMENTS[token];\n if (numeric) {\n return numeric;\n }\n\n if (token === 'QQQ') {\n return QQQ_FRAGMENT;\n }\n\n if (FORMAT_ONLY_TOKENS.has(token)) {\n throw new UnknownTokenError({\n token,\n message:\n `temporal-fmt: token \"${token}\" is format-only — it can't be parsed back into a value. ` +\n `Use a different token in the parse format string (e.g. \"d\" for \"do\", \"MM\" for \"ww\").`,\n });\n }\n\n const vocab = getLocaleVocab(locale);\n switch (token) {\n case 'MMMM': return alternation(vocab.monthLong);\n case 'MMM': return alternation(vocab.monthShort);\n case 'EEEE': return alternation(vocab.weekdayLong);\n case 'EEE': return alternation(vocab.weekdayShort);\n // Case-insensitive on purpose: \"pm\"/\"Pm\"/\"PM\" all mean the same thing,\n // and unlike the Md-glue ambiguity elsewhere in this file, there's no\n // second valid reading to guess wrong — so rejecting on case buys no\n // correctness, only friction against real-world data (mixed-case CSV\n // exports, lowercase log timestamps).\n case 'a': return alternation(vocab.dayPeriod, true);\n case 'zzz': return getTimeZoneFragment();\n case 'X': case 'XX': case 'XXX':\n case 'x': case 'xx': case 'xxx':\n return OFFSET_SHAPES[token]!;\n /* c8 ignore start @preserve -- defensive guard, not reachable through\n the public API. tokenFragment's only caller (buildCapturingPattern\n in parsePattern.ts) always passes piece.value straight from\n tokenize.ts, which only ever emits strings from tokens.ts's TOKENS\n table. Every token in that table is handled above: the numeric\n ones via NUMERIC_FRAGMENTS, QQQ via QQQ_FRAGMENT, the format-only\n ones via the FORMAT_ONLY_TOKENS check earlier in this function, and\n everything else via one of the switch cases. There's no token\n string that can reach this default without either tokens.ts\n registering something new or tokenize.ts being bypassed, neither of\n which happens on the parse() path. */\n default:\n throw new UnknownTokenError({ token, message: `temporal-fmt: unknown token \"${token}\"` });\n /* c8 ignore stop @preserve */\n }\n}\n\n// Tokens whose fragment is variable-width (1-2 digits, no leading zero).\n// Two or more of these glued with no literal separator between them can\n// have more than one digit-split that's independently valid against every\n// fragment in the run — see the big comment on NUMERIC_FRAGMENTS above.\n// Reordering alternation branches picks a winner for *some* of these\n// cases, but can't make both directions of a pair (e.g. \"Md\" and \"dM\")\n// agree, because the ambiguity is in the input string itself, not in how\n// any one fragment is written. exported so parsePattern.ts can find runs\n// of these that need split-counting at match time instead of a single\n// fixed regex.\nexport const UNPADDED_NUMERIC_TOKENS = new Set(['M', 'd', 'H', 'h', 'm', 's']);\n\n// Every accept width for a given unpadded numeric token, as plain min/max\n// value + digit-length pairs — used to enumerate candidate splits of a\n// digit run at match time. Mirrors NUMERIC_FRAGMENTS's semantics exactly\n// (same accepted values), just as data instead of regex source, since\n// enumerating splits against a compiled regex per-candidate would be\n// slower and harder to reason about than checking numeric ranges directly.\nexport const UNPADDED_NUMERIC_RANGES: Record<string, Array<{ digits: 1 | 2; min: number; max: number }>> = {\n M: [{ digits: 1, min: 1, max: 9 }, { digits: 2, min: 10, max: 12 }],\n d: [{ digits: 1, min: 1, max: 9 }, { digits: 2, min: 10, max: 31 }],\n H: [{ digits: 1, min: 0, max: 9 }, { digits: 2, min: 10, max: 23 }],\n h: [{ digits: 1, min: 1, max: 9 }, { digits: 2, min: 10, max: 12 }],\n m: [{ digits: 1, min: 0, max: 9 }, { digits: 2, min: 10, max: 59 }],\n s: [{ digits: 1, min: 0, max: 9 }, { digits: 2, min: 10, max: 59 }],\n};\n\n/**\n * Given the literal digit string a run of N adjacent unpadded-numeric\n * tokens matched as a whole (e.g. \"112\" for a 2-token run), enumerates\n * every way to split it into N pieces (one per token, each piece 1-2\n * digits per that token's own width rule) and returns every split where\n * every piece is independently valid for its token. Length 0 means the\n * run's regex match shouldn't have been possible in the first place\n * (shouldn't happen — the caller only invokes this after the whole\n * pattern already matched, meaning at least one split exists: the one the\n * regex actually took). Length 1 means the reading is unambiguous.\n * Length 2+ means true ambiguity — the caller should throw rather than\n * pick one.\n *\n * Recursive over token count rather than hardcoded to 2, so a 3+ token\n * unseparated run (e.g. \"Hms\") is covered by the same logic without a\n * special case — those are rarer in practice but not impossible, and a\n * partial fix that only covered pairs would leave the identical bug for\n * anyone writing a 3-token glued run.\n */\nexport function enumerateValidSplits(digits: string, tokens: string[]): number[][] {\n const memo = new Map<string, number[][]>();\n\n function solve(tokenIndex: number, offset: number): number[][] {\n const key = `${tokenIndex}:${offset}`;\n const cached = memo.get(key);\n if (cached) {\n return cached;\n }\n\n if (tokenIndex === tokens.length) {\n const result = offset === digits.length ? [[]] : [];\n memo.set(key, result);\n return result;\n }\n\n const token = tokens[tokenIndex];\n const ranges = UNPADDED_NUMERIC_RANGES[token!];\n /* c8 ignore start @preserve -- defensive guard, not reachable through\n the public API. enumerateValidSplits's only caller (parse.ts, both\n call sites) passes run.tokens straight from\n pattern.ambiguousRuns, which parsePattern.ts only ever populates\n with tokens already checked against UNPADDED_NUMERIC_TOKENS — the\n exact same key set as UNPADDED_NUMERIC_RANGES. There's no path\n where a token reaches here without having already passed that\n check. */\n if (!ranges) {\n throw new Error(`temporal-fmt: internal error — \"${token}\" is not an unpadded numeric token`);\n }\n /* c8 ignore stop @preserve */\n\n const results: number[][] = [];\n for (const { digits: width, min, max } of ranges) {\n if (offset + width > digits.length) continue;\n const piece = digits.slice(offset, offset + width);\n if (width === 2 && piece[0] === '0') continue;\n const value = Number(piece);\n if (value < min || value > max) continue;\n\n for (const restSplit of solve(tokenIndex + 1, offset + width)) {\n results.push([value, ...restSplit]);\n if (results.length === 2) break;\n }\n if (results.length === 2) break;\n }\n\n memo.set(key, results);\n return results;\n }\n\n return solve(0, 0);\n}","import type { Piece } from './tokenize.js';\nimport { tokenFragment, UNPADDED_NUMERIC_TOKENS, DIGIT_LEADING_TOKENS } from './pattern.js';\nimport { FormatSyntaxError } from './errors.js';\n\nfunction escapeRegExp(literal: string): string {\n return literal.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n// Guards against catastrophic-backtracking (ReDoS) patterns.\n//\n// Every confirmed ReDoS in this library shares one shape: two or more\n// variable-width digit-consuming regex fragments placed so the engine\n// can't tell where one ends and the next begins — either glued with no\n// separator (\"MdMdMd…\", \"HmsHms…\") or separated only by a literal that\n// itself starts with a digit (\"M1M1M1…\", \"yyyy1yyyy1…\"). Each fragment\n// then has multiple ways to divide the digit run, and a failing match\n// makes the engine explore every combination — exponential in the number\n// of fragments. Measured against the pre-fix code: \"Md\"×13 (26-char\n// format, 40-char input) ≈ 2.7 s; \"yyyy1\"×8 (48-char format) ≈ 26 s;\n// both grow roughly ×3–14 per additional fragment.\n//\n// Three structural defenses, applied at pattern-build time:\n//\n// 1. A run of 2+ glued unpadded-numeric tokens is emitted as ONE\n// bounded digit group `(?<rN>\\d{R,2R})` instead of R separate\n// variable-width fragments. The per-token split is resolved after\n// the match by enumerateValidSplits() (pattern.ts) — the exact\n// machinery parse() already used to detect ambiguous glued runs —\n// so the documented behavior (unique split resolves; 2+ valid\n// splits throws in strict mode / heuristic-picks in lenient; 0\n// splits is a mismatch) is preserved. A lone `\\d{R,2R}` group\n// backtracks at most R+1 times, which is linear.\n//\n// 2. yyyy uses the exact `-?\\d{4}` fragment not only when the next\n// *token* is digit-leading (existing rule) but also when the next\n// *literal* starts with a digit. An open-ended `-?\\d{4,}` year\n// glued to a digit literal is the cheapest exponential engine\n// there is (unbounded width choices per year), and the exact form\n// matches everything the open-ended form matched in that position\n// except years with 5+ digits glued directly to an unquoted digit\n// literal — a pathological corner deliberately traded away.\n//\n// 3. An ambiguity budget for what's left: every adjacency between a\n// variable-width digit consumer (a lone unpadded token, or a glued\n// run group) and a digit-consuming successor (a digit-leading token\n// or a literal starting with a digit) costs log2 of the consumer's\n// width choices. A pattern whose total exceeds MAX_AMBIGUITY_BITS\n// (12 — a hard ceiling of 4096 backtrack paths) is rejected at\n// build time with a FormatSyntaxError. Realistic format strings\n// score 0–3; the \"M1M1M1…\" attack scores one bit per glued pair.\nconst MAX_AMBIGUITY_BITS = 12;\n\nfunction widthChoicesBits(choices: number): number {\n return Math.ceil(Math.log2(Math.max(choices, 1)));\n}\n\n// Does this piece's regex fragment START by consuming a bare digit?\n// (Tokens whose match can begin with 0-9, and literals whose first\n// character is a digit.) Used to find the boundaries where a preceding\n// variable-width digit consumer could trade digits with a successor.\nfunction isDigitConsumingStart(piece: Piece | undefined): boolean {\n if (piece === undefined) return false;\n if (piece.kind === 'literal') return /^[0-9]/.test(piece.value);\n return DIGIT_LEADING_TOKENS.has(piece.value);\n}\n\nexport interface CapturingPattern {\n regex: RegExp;\n groups: Array<{ name: string; token: string }>; // token pieces, in order\n // Runs of 2+ adjacent unpadded-numeric tokens with no literal separator\n // between them (e.g. \"Md\", \"Hms\"). Each run is captured by ONE regex\n // group named `groupName` spanning the run's whole digit run\n // (R..2·R digits); per-token values come from enumerateValidSplits()\n // at match time. `groupNames` lists the per-token group names — they\n // appear in `groups` for structure/positions but have no counterpart\n // in the regex itself, so consumers must read their values from the\n // split enumeration, not from match.groups.\n ambiguousRuns: Array<{ groupName: string; groupNames: string[]; tokens: string[] }>;\n}\n\n/**\n * Same walk as buildPatternSource() in pattern.ts, but each token piece\n * gets its own named capture group (positionally named so the same token,\n * e.g. \"yyyy\", could in theory appear twice) so a caller can pull the\n * matched substring for each token back out after a successful match.\n */\nexport function buildCapturingPattern(pieces: Piece[], locale: string): CapturingPattern {\n const groups: Array<{ name: string; token: string }> = [];\n const ambiguousRuns: Array<{ groupName: string; groupNames: string[]; tokens: string[] }> = [];\n let source = '';\n let i = 0;\n let ambiguityBits = 0;\n\n // Tracks the current run of adjacent unpadded-numeric token pieces (no\n // literal or non-unpadded token has broken it yet). Names are recorded\n // in declaration order so a run of 2+ can emit one group while its\n // member tokens still get individual entries in `groups`.\n let currentRun: { names: string[]; tokens: string[] } = { names: [], tokens: [] };\n\n const flushRun = (nextPiece: Piece | undefined) => {\n if (currentRun.tokens.length === 1) {\n // A lone unpadded token: emit its normal (two-way) fragment. Two\n // width choices are harmless on their own; if the next element\n // can consume a digit, charge one ambiguity bit for the boundary.\n const name = currentRun.names[0]!;\n const token = currentRun.tokens[0]!;\n source += `(?<${name}>${tokenFragment(token, locale)})`;\n if (isDigitConsumingStart(nextPiece)) ambiguityBits += 1;\n } else if (currentRun.tokens.length >= 2) {\n // Emit the accumulated run as ONE bounded digit group. R unpadded\n // tokens accept between R and 2R digits in total; anything outside\n // that span can't match regardless of how the digits split, so the\n // single group's acceptance region is exactly the union of the old\n // per-token fragments' regions. Backtracking into this group is\n // bounded at R+1 width choices — linear, not exponential.\n const runName = `r${i++}`;\n const tokenCount = currentRun.tokens.length;\n source += `(?<${runName}>\\\\d{${tokenCount},${tokenCount * 2}})`;\n // Note: no `groups` entry for the run group itself — `groups` lists\n // per-token pieces only (its members were already pushed when\n // visited), so consumers like parseToParts see exactly one entry\n // per token, same as before this run-group change. The regex group\n // is reached through ambiguousRuns[].groupName.\n ambiguousRuns.push({\n groupName: runName,\n groupNames: currentRun.names,\n tokens: currentRun.tokens,\n });\n // A run group adjacent to a digit-consuming successor keeps its\n // (R+1) width choices at that boundary — charge the budget.\n if (isDigitConsumingStart(nextPiece)) {\n ambiguityBits += widthChoicesBits(tokenCount + 1);\n }\n }\n currentRun = { names: [], tokens: [] };\n };\n\n for (const [idx, piece] of pieces.entries()) {\n if (piece.kind === 'literal') {\n flushRun(piece);\n source += escapeRegExp(piece.value);\n continue;\n }\n\n if (UNPADDED_NUMERIC_TOKENS.has(piece.value)) {\n // Part of a (potential) glued run — defer fragment emission to\n // flushRun so a run of 2+ collapses into one bounded group.\n const name = `g${i++}`;\n groups.push({ name, token: piece.value });\n currentRun.names.push(name);\n currentRun.tokens.push(piece.value);\n continue;\n }\n\n flushRun(piece);\n const name = `g${i++}`;\n groups.push({ name, token: piece.value });\n const nextPiece = pieces[idx + 1];\n const nextToken = nextPiece?.kind === 'token' ? nextPiece.value : undefined;\n // yyyy picks its fragment based on what follows: the exact 4-digit\n // form whenever a digit-consuming element comes next (digit-leading\n // token — the pre-existing rule — OR a literal starting with a\n // digit, added by the ReDoS fix; see the guard block above). The\n // open-ended form is only safe when nothing digit-consuming can\n // follow it.\n if (piece.value === 'yyyy' && nextToken === undefined && isDigitConsumingStart(nextPiece)) {\n source += `(?<${name}>${tokenFragment(piece.value, locale, 'M')})`;\n } else {\n source += `(?<${name}>${tokenFragment(piece.value, locale, nextToken)})`;\n }\n }\n flushRun(undefined);\n\n if (ambiguityBits > MAX_AMBIGUITY_BITS) {\n throw new FormatSyntaxError({\n reason:\n `format string has too many variable-width numeric tokens glued to digit-consuming neighbors ` +\n `(ambiguity score ${ambiguityBits} > ${MAX_AMBIGUITY_BITS}). ` +\n `This shape makes the regex engine backtrack exponentially on near-miss input. ` +\n `Add a non-digit separator between these tokens (e.g. \"-\" or \" \") or use their padded forms (MM/dd/HH/mm/ss).`,\n });\n }\n\n // 'd' flag enables match.indices.groups — used by parseToParts to\n // report each token's actual position in the input. Without it,\n // computing per-group positions would require a separate walk of the\n // piece list against the input, duplicating logic the regex already\n // has. Backward-compatible: 'd' only adds an `indices` property to\n // the match result, no behavioral change to the match itself.\n return { regex: new RegExp(`^(?:${source})$`, 'ud'), groups, ambiguousRuns };\n}\n","import { DEFAULT_LOCALE, type FormatOptions } from './tokens.js';\nimport { tokenize } from './tokenize.js';\nimport { buildCapturingPattern, type CapturingPattern } from './parsePattern.js';\nimport { enumerateValidSplits, isValidTimeZone } from './pattern.js';\nimport { getLocaleVocab, canonicalCacheKey, assertValidLocaleTag, subscribeToVocabChanges } from './localeVocab.js';\nimport { getTemporal } from './temporalProvider.js';\nimport { MAX_FORMAT_LENGTH, MAX_INPUT_LENGTH } from './constants.js';\nimport { TemporalFmtError, InvalidTimeZoneError, InvalidOffsetError, FormatSyntaxError, ParseMismatchError, AmbiguousInputError, InvalidDateError, wrapUntypedError } from './errors.js';\nimport { applyParseNumbering, type NumberingParseOptions } from './numbering.js';\n\n// format strings are short hand-written literals reused across many calls —\n// cache the compiled capturing pattern per (formatStr, locale) pair instead\n// of rebuilding it every call.\nconst patternCache = new Map<string, CapturingPattern>();\nconst MAX_CACHE_SIZE = 500;\n\n// A compiled pattern embeds locale-vocabulary alternations (MMMM/MMM/\n// EEEE/EEE/a fragments) at build time. When registerLocaleVocab()\n// swaps a locale's vocabulary, every cached pattern for any locale\n// becomes potentially stale — the cached regex would keep matching the\n// OLD vocabulary while format() renders the new one, breaking the\n// format→parse round-trip for the library's own output. Clear the whole\n// cache on any vocab change: rebuilds are cheap and self-limiting via\n// the cache size cap.\nsubscribeToVocabChanges(() => { patternCache.clear(); });\n\nfunction getPattern(formatStr: string, locale: string): CapturingPattern {\n const key = JSON.stringify([canonicalCacheKey(locale), formatStr]);\n let pattern = patternCache.get(key);\n if (pattern) {\n return pattern;\n }\n if (patternCache.size >= MAX_CACHE_SIZE) {\n const oldestKey = patternCache.keys().next().value;\n if (oldestKey !== undefined) patternCache.delete(oldestKey);\n }\n pattern = buildCapturingPattern(tokenize(formatStr), locale);\n patternCache.set(key, pattern);\n return pattern;\n}\n\n// Requires an explicit `-u-ca-` extension (e.g. 'en-u-ca-hebrew') to apply\n// a non-Gregorian calendar, per parse()'s own docstring. 'gregory' counts\n// as \"no calendar\" so the default locale keeps constructing plain ISO 8601.\n//\n// Used to key off resolvedOptions().calendar instead — a locale's\n// *default* calendar, whether the caller asked for one or not. That broke\n// th-TH silently: its default is 'buddhist', so plain Gregorian-looking\n// digits parsed 543 years off, while format() has no matching calendar\n// step and just prints the object's own ISO fields either way.\nconst calendarCache = new Map<string, string | undefined>();\nconst MAX_CALENDAR_CACHE_SIZE = 500;\n\nfunction resolveCalendar(locale: string): string | undefined {\n // Typed validation first: a genuinely malformed tag (bare private-use\n // singleton, control characters, garbage) surfaces as the library's\n // InvalidLocaleError instead of a raw engine RangeError — same code as\n // before, different (documented, structured) error class.\n assertValidLocaleTag(locale);\n // canonicalCacheKey is memoized (localeVocab.ts), so the common path —\n // repeated parse() calls with the same locale — no longer constructs a\n // fresh Intl.Locale per call just to compute the calendar-cache key.\n const canonicalLocale = canonicalCacheKey(locale);\n if (calendarCache.has(canonicalLocale)) {\n return calendarCache.get(canonicalLocale);\n }\n if (calendarCache.size >= MAX_CALENDAR_CACHE_SIZE) {\n const oldestKey = calendarCache.keys().next().value;\n if (oldestKey !== undefined) calendarCache.delete(oldestKey);\n }\n let calendar: string | undefined;\n const parts = canonicalLocale.split('-');\n const extensionIndex = parts.indexOf('u');\n const calendarKeyIndex = extensionIndex === -1 ? -1 : parts.indexOf('ca', extensionIndex + 1);\n if (calendarKeyIndex !== -1 && calendarKeyIndex + 1 < parts.length) {\n const resolved = new Intl.DateTimeFormat(canonicalLocale).resolvedOptions().calendar;\n calendar = resolved === 'gregory' ? undefined : resolved;\n }\n calendarCache.set(canonicalLocale, calendar);\n return calendar;\n}\n\ninterface Fields {\n year?: number;\n twoDigitYear?: number;\n month?: number;\n day?: number;\n hour?: number;\n hour12?: number;\n dayPeriodRaw?: string;\n isPM?: boolean;\n minute?: number;\n second?: number;\n millisecond?: number;\n microsecond?: number;\n nanosecond?: number;\n timeZoneId?: string;\n // Canonical `+HH:MM` form of any offset token (X/XX/XXX/x/xx/xxx)\n // captured in this pattern. Distinct from timeZoneId because the two\n // can coexist in the same pattern (e.g. \"yyyy-MM-dd HH:mm zzz XXX\") —\n // see the cross-check after construction for how a mismatch between\n // them is resolved.\n offsetString?: string;\n weekdayExpected?: number;\n weekdayRaw?: string;\n quarter?: number;\n}\n\n// Normalizes a captured offset-token string into the canonical `+HH:MM`\n// shape Temporal.ZonedDateTime.from accepts as a `timeZone` value. Throws\n// descriptive errors for out-of-range hours/minutes, since the regex\n// shape (OFFSET_SHAPES in pattern.ts) is deliberately permissive — a\n// post-match range check here gives the user a specific error (\"offset\n// hours 99 out of range, max 14\") instead of \"no valid pattern matches\".\n//\n// Range bounds: -12:00 to +14:00, the standard IANA offset range\n// (Baker/Howland at -12, Kiritimati at +14). +14:01 / -12:01 etc. are\n// rejected explicitly even though the per-piece bounds (hours ≤ 14,\n// minutes ≤ 59) alone wouldn't catch them.\nfunction parseOffsetString(raw: string, token: string): string {\n if (raw === 'Z') {\n /* c8 ignore start @preserve -- unreachable: lowercase tokens' regex\n (OFFSET_SHAPES in pattern.ts) has no \"Z\" alternative at all, so\n raw === 'Z' can only ever be reached when token is one of the\n uppercase variants (X/XX/XXX). A lowercase token can't even\n capture \"Z\" as `raw` in the first place. */\n if (token === 'x' || token === 'xx' || token === 'xxx') {\n throw new Error(\n `temporal-fmt: offset token \"${token}\" doesn't accept \"Z\" — only the uppercase variants (X/XX/XXX) emit \"Z\" for UTC. ` +\n `Use \"+00:00\", \"+0000\", or \"+00\" depending on the variant's width.`\n );\n }\n /* c8 ignore stop @preserve */\n return '+00:00';\n }\n\n const sign = raw[0];\n /* c8 ignore start @preserve -- unreachable: raw is a regex-captured\n group from an offset token, and every OFFSET_SHAPES pattern\n (pattern.ts) is anchored to either \"Z\" or a leading [+-]. raw's\n first character can never be anything else by the time it reaches\n this function. */\n if (sign !== '+' && sign !== '-') {\n throw new Error(`temporal-fmt: offset \"${raw}\" for token \"${token}\" doesn't start with \"+\", \"-\", or \"Z\".`);\n }\n /* c8 ignore stop @preserve */\n const body = raw.slice(1);\n let hoursStr: string;\n let minutesStr: string;\n if (body.length === 2) {\n /* c8 ignore start @preserve -- unreachable: each offset token's own\n regex shape in OFFSET_SHAPES (pattern.ts) already gates which\n body shapes it can capture. Only X and x ever match a 2-digit\n body — XX/xx/XXX/xxx's regexes can't produce one — so this\n mismatch can never actually fire through parse(). */\n // +HH — only X/x emit this shape; XX/xx/XXX/xxx always carry minutes.\n if (token !== 'X' && token !== 'x') {\n throw new Error(\n `temporal-fmt: offset token \"${token}\" can't match \"${raw}\" — it requires minutes, but \"${raw}\" has none.`\n );\n }\n /* c8 ignore stop @preserve */\n hoursStr = body;\n minutesStr = '00';\n } else if (body.length === 4) {\n /* c8 ignore start @preserve -- unreachable, same reason as the\n 2-digit case above: XXX/xxx's regex requires a colon, so it can\n never capture a 4-digit no-colon body in the first place. */\n // +HHMM — X/x (when minutes are non-zero) or XX/xx.\n if (token === 'XXX' || token === 'xxx') {\n throw new Error(\n `temporal-fmt: offset token \"${token}\" can't match \"${raw}\" — it requires a colon between hours and minutes (e.g. \"${sign}${body.slice(0, 2)}:${body.slice(2)}\").`\n );\n }\n /* c8 ignore stop @preserve */\n hoursStr = body.slice(0, 2);\n minutesStr = body.slice(2, 4);\n } else if (body.length === 5 && body[2] === ':') {\n /* c8 ignore start @preserve -- unreachable, same reason again: only\n XXX/xxx's regex can produce a colon-shaped body; X/x/XX/xx never\n capture one. */\n // +HH:MM — XXX/xxx only.\n if (token !== 'XXX' && token !== 'xxx') {\n throw new Error(\n `temporal-fmt: offset token \"${token}\" can't match \"${raw}\" — it doesn't use a colon (use \"${sign}${body.slice(0, 2)}${body.slice(3)}\" instead).`\n );\n }\n /* c8 ignore stop @preserve */\n hoursStr = body.slice(0, 2);\n minutesStr = body.slice(3, 5);\n /* c8 ignore start @preserve -- unreachable: every offset token's\n regex only ever produces a body of length 2, length 4, or length 5\n with a colon at index 2 (see OFFSET_SHAPES in pattern.ts) — no\n shape falls outside those three cases, so this else arm can't be\n taken through parse(). Kept as an exhaustiveness fallback so\n hoursStr/minutesStr are assigned on every path TypeScript can see. */\n } else {\n throw new Error(`temporal-fmt: offset \"${raw}\" doesn't match the shape token \"${token}\" accepts.`);\n }\n /* c8 ignore stop @preserve */\n\n const hours = Number(hoursStr);\n const minutes = Number(minutesStr);\n // Per-piece range checks catch most malformed input.\n if (hours > 14) {\n throw new InvalidOffsetError({\n actual: raw,\n message: `temporal-fmt: offset hours ${hours} in \"${raw}\" out of range (max 14 — Kiritimati, Line Islands is +14:00).`,\n });\n }\n if (minutes > 59) {\n throw new InvalidOffsetError({\n actual: raw,\n message: `temporal-fmt: offset minutes ${minutes} in \"${raw}\" out of range (max 59).`,\n });\n }\n // Boundary: +14:01..+14:59 and -12:01..-12:59 are out of range even\n // though each piece alone is in bounds — the overall offset exceeds\n // the IANA-supported range.\n if (sign === '+' && hours === 14 && minutes !== 0) {\n throw new InvalidOffsetError({\n actual: raw,\n message: `temporal-fmt: offset \"${raw}\" exceeds the maximum supported UTC offset of +14:00.`,\n });\n }\n if (sign === '-' && hours === 12 && minutes !== 0) {\n throw new InvalidOffsetError({\n actual: raw,\n message: `temporal-fmt: offset \"${raw}\" exceeds the maximum supported negative UTC offset of -12:00.`,\n });\n }\n return `${sign}${hoursStr}:${minutesStr}`;\n}\n\nfunction assignField<T>(fields: Fields, key: keyof Fields, value: T): void {\n (fields as Record<string, T | undefined>)[key] = value;\n}\n\nfunction applyGroup(fields: Fields, token: string, raw: string, locale: string, formatStr: string): void {\n const vocab = getLocaleVocab(locale);\n switch (token) {\n case 'yyyy':\n assignField(fields, 'year', Number(raw));\n break;\n case 'yy':\n assignField(fields, 'twoDigitYear', Number(raw));\n break;\n case 'MM': case 'M':\n assignField(fields, 'month', Number(raw));\n break;\n case 'MMMM':\n assignField(fields, 'month', vocab.monthLong.indexOf(raw) + 1);\n break;\n case 'MMM':\n assignField(fields, 'month', vocab.monthShort.indexOf(raw) + 1);\n break;\n case 'dd': case 'd':\n assignField(fields, 'day', Number(raw));\n break;\n case 'EEEE':\n assignField(fields, 'weekdayRaw', raw);\n assignField(fields, 'weekdayExpected', vocab.weekdayLong.indexOf(raw) + 1);\n break;\n case 'EEE':\n assignField(fields, 'weekdayRaw', raw);\n assignField(fields, 'weekdayExpected', vocab.weekdayShort.indexOf(raw) + 1);\n break;\n case 'HH': case 'H':\n assignField(fields, 'hour', Number(raw));\n break;\n case 'hh': case 'h':\n assignField(fields, 'hour12', Number(raw));\n break;\n case 'mm': case 'm':\n assignField(fields, 'minute', Number(raw));\n break;\n case 'ss': case 's':\n assignField(fields, 'second', Number(raw));\n break;\n case 'S': case 'SS': case 'SSS': case 'SSSS': case 'SSSSS':\n case 'SSSSSS': case 'SSSSSSS': case 'SSSSSSSS': case 'SSSSSSSSS': {\n // The captured digits are the leading N digits of a nanosecond-of-second\n // value, not the whole thing — \"5\" under SSSSSSSSS means 500000000ns\n // (half a second), not 5ns. Right-padding to 9 digits before splitting\n // is what makes that work; left-padding (or just Number(raw)) would\n // read \"5\" as 5ns instead.\n const nanoOfSecond = Number(raw.padEnd(9, '0'));\n assignField(fields, 'millisecond', Math.floor(nanoOfSecond / 1_000_000));\n assignField(fields, 'microsecond', Math.floor(nanoOfSecond / 1_000) % 1_000);\n assignField(fields, 'nanosecond', nanoOfSecond % 1_000);\n break;\n }\n case 'a': {\n // Matches case-insensitively (see pattern.ts's foldCase), so the\n // lookup here has to fold too, or \"pm\" would pass the regex and\n // then fail this indexOf against the exact-case vocab.\n const periodIndex = vocab.dayPeriod.findIndex((p) => p.toLowerCase() === raw.toLowerCase());\n /* c8 ignore start @preserve -- unreachable: the 'a' token's regex\n fragment (pattern.ts's alternation() over vocab.dayPeriod) can\n only ever capture a case-insensitive match of one of\n vocab.dayPeriod's own entries. Both the regex and this lookup\n derive their vocab from the same `locale` via getLocaleVocab(),\n so periodIndex can't come back negative through parse(). */\n if (periodIndex < 0) throw new Error(`temporal-fmt: unknown day period \"${raw}\" for locale \"${locale}\".`);\n /* c8 ignore stop @preserve */\n assignField(fields, 'dayPeriodRaw', raw);\n assignField(fields, 'isPM', periodIndex === 1);\n break;\n }\n case 'zzz':\n assignField(fields, 'timeZoneId', raw);\n break;\n case 'X': case 'XX': case 'XXX':\n case 'x': case 'xx': case 'xxx':\n assignField(fields, 'offsetString', parseOffsetString(raw, token));\n break;\n case 'Q':\n assignField(fields, 'quarter', Number(raw));\n break;\n case 'QQQ':\n // strips the literal \"Q\" prefix the token itself formats; the suffix\n // digit is the quarter value 1-4\n assignField(fields, 'quarter', Number(raw.slice(1)));\n break;\n }\n}\n\n// The lenient split-selection heuristic for ambiguous glued numeric runs.\n// See README \"Lenient parse mode\" — the strict default throws on these,\n// lenient mode opts into picking one split instead.\nfunction pickLenientSplit(splits: number[][], tokens: string[]): number[] {\n // Prefer the split where a \"d\" (day) token, if any, has a value of 12 or\n // less. Rationale: when a person writes a glued run like \"121\" for an\n // Md format string, the reading \"Dec 1\" (M=12, d=1) is what they\n // typically meant — if they meant \"Jan 21\" they would more often have\n // written it as \"1/21\" or \"01/21\" with a separator or padding, since the\n // 2-digit day is the more naturally-cohesive unit to keep glued. This\n // isn't a guarantee, which is exactly why lenient mode is opt-in — but\n // it's a reasonable default when the caller has asked us to guess.\n const dayIndex = tokens.indexOf('d');\n if (dayIndex !== -1) {\n const smallDaySplits = splits.filter((s) => s[dayIndex]! <= 12);\n if (smallDaySplits.length > 0) {\n return smallDaySplits[0]!;\n }\n }\n // Fallback to the first valid split when the day heuristic doesn't\n // narrow it down — deterministic, and \"first\" here means \"whichever\n // enumerateValidSplits returned first\", which is a depth-first\n // leftmost-shortest walk over the candidate splits.\n return splits[0]!;\n}\n\n// emulates strptime (POSIX) for 2-digit years so the result doesn't depend\n// on the current clock: 00-68 -> 2000-2068, 69-99 -> 1900-1999\n// https://www.man7.org/linux//man-pages/man3/strptime.3p.html\nfunction resolveYear(fields: Fields): number | undefined {\n if (fields.year !== undefined && fields.twoDigitYear !== undefined) {\n // FormatSyntaxError, not ParseMismatchError: this is a contradiction\n // in the format string itself (both \"yyyy\" and \"yy\" present), not a\n // mismatch between the format and a specific input.\n throw new FormatSyntaxError({\n message: 'temporal-fmt: format string mixes \"yyyy\" and \"yy\" year representations.',\n });\n }\n if (fields.year !== undefined) return fields.year;\n if (fields.twoDigitYear !== undefined) {\n return fields.twoDigitYear <= 68 ? 2000 + fields.twoDigitYear : 1900 + fields.twoDigitYear;\n }\n return undefined;\n}\n\nfunction resolveHour(fields: Fields, formatStr: string, locale: string): number | undefined {\n if (fields.hour !== undefined && fields.hour12 !== undefined) {\n throw new FormatSyntaxError({\n format: formatStr,\n message:\n `temporal-fmt: format string \"${formatStr}\" mixes a 24-hour token (\"HH\"/\"H\") with a ` +\n `12-hour token (\"hh\"/\"h\").`,\n });\n }\n if (fields.hour !== undefined) {\n if (fields.dayPeriodRaw !== undefined) {\n const vocab = getLocaleVocab(locale);\n const expected = fields.hour < 12 ? vocab.dayPeriod[0] : vocab.dayPeriod[1];\n if (fields.dayPeriodRaw.toLowerCase() !== expected?.toLowerCase()) {\n throw new FormatSyntaxError({\n format: formatStr,\n message: `temporal-fmt: format string \"${formatStr}\" contains a day period that contradicts the 24-hour value.`,\n });\n }\n }\n return fields.hour;\n }\n if (fields.hour12 !== undefined) {\n if (fields.isPM === undefined) {\n throw new FormatSyntaxError({\n format: formatStr,\n message:\n `temporal-fmt: format string \"${formatStr}\" uses a 12-hour token (\"hh\"/\"h\") without an \"a\" token, ` +\n `so parse() can't tell AM from PM.`,\n });\n }\n return (fields.hour12 % 12) + (fields.isPM ? 12 : 0);\n }\n return undefined;\n}\n\n/**\n * Parses `input` against `formatStr` and builds the real Temporal value it\n * describes: a `Temporal.PlainDate`, `PlainTime`, `PlainDateTime`, or\n * `ZonedDateTime` depending on which tokens are present.\n *\n * Returns `unknown` — this package has no ambient `Temporal` types to return\n * a real one against.\n *\n * `options.locale` picks the calendar the result is built in. Pass a locale\n * tag with a `-u-ca-` extension (e.g. `'en-u-ca-hebrew'`) to parse into a\n * non-Gregorian calendar.\n *\n * @throws if `input` doesn't match `formatStr`'s shape at all\n * @throws if it matches the shape but describes an impossible date (e.g. Feb\n * 30) or self-contradictory data (e.g. a weekday name that doesn't match the\n * actual date)\n *\n * @example\n * parse('yyyy-MM-dd HH:mm', '2026-08-04 15:45') // Temporal.PlainDateTime\n * parse('yyyy-MM', '2026-08-04T15:45:30') // throws — shape doesn't match\n * parse('yyyy-MM-dd', '2026-02-30') // throws — not a real date\n */\nexport function parse(formatStr: string, input: string, options: NumberingParseOptions = {}): unknown | undefined {\n if (formatStr.length > MAX_FORMAT_LENGTH) {\n throw new FormatSyntaxError({\n format: formatStr,\n message:\n `temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters ` +\n `(got ${formatStr.length}).`,\n });\n }\n\n if (input.length > MAX_INPUT_LENGTH) {\n throw new FormatSyntaxError({\n input,\n message: `temporal-fmt: input exceeds maximum length of ${MAX_INPUT_LENGTH} characters (got ${input.length}).`,\n });\n }\n\n // Transliterate non-ASCII numerals to ASCII before any matching happens,\n // when the caller opts in via parseNumberingSystem. Every regex this\n // module builds expects 0-9; this is the one place that assumption\n // could otherwise be violated by locale-native input digits.\n if (options.parseNumberingSystem) {\n input = applyParseNumbering(input, options);\n }\n\n const locale = options.locale ?? DEFAULT_LOCALE;\n const calendar = resolveCalendar(locale);\n const pattern = getPattern(formatStr, locale);\n const match = pattern.regex.exec(input);\n if (!match) {\n throw new ParseMismatchError({\n input, format: formatStr,\n // reason set explicitly (not just message): parse.test.js's\n // \"safeParse: failure returns { ok: false, error } with a\n // TemporalFmtError\" asserts result.error.reason carries the\n // underlying detail text, matching what wrapUntypedError used to\n // populate when this message reached it as a caught plain Error.\n reason: 'no valid pattern matches the format string and input shape',\n message: `temporal-fmt: no valid pattern matches the format string and input shape`,\n });\n }\n\n if (pattern.groups.length === 0) {\n // ParseMismatchError, not FormatSyntaxError: pinned by\n // errors.test.js's \"format string with no tokens at all falls\n // through to ParseMismatchError\" — wrapUntypedError's classifier\n // has no branch for this message, so it lands on the\n // PARSE_MISMATCH fallback, and a direct throw here needs to\n // agree with that.\n throw new ParseMismatchError({\n format: formatStr,\n // reason set explicitly: errors.test.js's \"format string with no\n // tokens at all falls through to ParseMismatchError\" asserts\n // error.reason matches /has no tokens/.\n reason: `format string \"${formatStr}\" has no tokens — nothing to parse into a value.`,\n message: `temporal-fmt: format string \"${formatStr}\" has no tokens — nothing to parse into a value.`,\n });\n }\n\n // The regex's zzz fragment only matches a bounded zone-id *shape* (see\n // TIME_ZONE_SHAPE in pattern.ts) rather than alternating every real IANA\n // name inline, so a shape match isn't proof of a real zone yet — check\n // Zone ids can't be enumerated in the regex itself (there are ~400 of\n // them and they change over time as IANA updates the tz database), so\n // the regex only captures the zzz group's shape and this loop checks\n // each captured zzz group against the actual zone list here. Unlike a\n // regex-shape mismatch, this failure has a specific cause worth\n // naming: the shape matched but the zone id itself isn't recognized.\n for (const { name, token } of pattern.groups) {\n if (token === 'zzz' && !isValidTimeZone(match.groups![name]!)) {\n throw new InvalidTimeZoneError({\n input, format: formatStr, actual: match.groups![name],\n reason: 'not a recognized IANA time zone identifier',\n });\n }\n }\n\n // A run of 2+ adjacent unpadded-numeric tokens with no literal separator\n // (e.g. \"Md\", \"dM\", \"Hms\") is captured by a single bounded digit group in\n // the regex (see buildCapturingPattern — per-token variable-width\n // fragments made near-miss matching exponential in the number of glued\n // tokens). Resolve each run's per-token split here instead: unique valid\n // split resolves (identical to what the old regex's own greedy match\n // produced, since the old match was always one of the valid splits);\n // 2+ valid splits is genuinely ambiguous input — strict mode throws,\n // lenient opts into the documented heuristic. A span with 0 valid\n // splits matched the run's width window but names no valid per-token\n // assignment, which the old per-token fragments rejected at match\n // time — surface the same \"no valid pattern matches\" error.\n const runValues = new Map<string, string>();\n for (const run of pattern.ambiguousRuns) {\n const runDigits = match.groups![run.groupName]!;\n const splits = enumerateValidSplits(runDigits, run.tokens);\n if (splits.length === 0) {\n throw new ParseMismatchError({\n input, format: formatStr,\n reason: 'no valid pattern matches the format string and input shape',\n message: `temporal-fmt: no valid pattern matches the format string and input shape`,\n });\n }\n if (splits.length > 1) {\n // Strict default — throw on ambiguity. The whole point of the\n // library's parse() is to refuse to guess when the same input has\n // more than one valid reading. Lenient mode (opt-in via\n // options.lenient) instead picks one split via a documented\n // heuristic — see pickLenientSplit() above and the README section\n // \"Lenient parse mode\" for why this is strictly additive and never\n // the default.\n if (!options.lenient) {\n throw new AmbiguousInputError({\n input, format: formatStr,\n message:\n `temporal-fmt: \"${runDigits}\" in format string \"${formatStr}\" is ambiguous — ` +\n `${splits.length} different ways to read tokens \"${run.tokens.join('')}\" (with no separator ` +\n `between them) are all individually valid (e.g. ${JSON.stringify(splits[0])} vs ${JSON.stringify(splits[1])}). ` +\n `parse() won't guess; add a separator between these tokens, or use their padded form ` +\n `(e.g. \"MM\" instead of \"M\") so each one has a fixed width. ` +\n `Pass { lenient: true } to opt into a documented heuristic that picks one.`,\n });\n }\n const picked = pickLenientSplit(splits, run.tokens);\n run.groupNames.forEach((name, idx) => runValues.set(name, String(picked[idx])));\n } else {\n run.groupNames.forEach((name, idx) => runValues.set(name, String(splits[0]![idx])));\n }\n }\n const fields: Fields = {};\n // Per-token values for glued-run members come from the split\n // enumeration above (runValues); every other token reads its own\n // regex group directly.\n for (const { name, token } of pattern.groups) {\n const raw = runValues.get(name) ?? match.groups![name]!;\n applyGroup(fields, token, raw, locale, formatStr);\n }\n\n const year = resolveYear(fields);\n const hour = resolveHour(fields, formatStr, locale);\n const { month, day, minute, second, millisecond, microsecond, nanosecond, timeZoneId, offsetString, weekdayExpected, weekdayRaw, quarter } = fields;\n\n const hasAnyDatePart = year !== undefined || month !== undefined || day !== undefined;\n const hasFullDate = year !== undefined && month !== undefined && day !== undefined;\n if (hasAnyDatePart && !hasFullDate) {\n throw new InvalidDateError({\n format: formatStr,\n message:\n `temporal-fmt: format string \"${formatStr}\" has an incomplete date — ` +\n `year, month, and day tokens must all be present together.`,\n });\n }\n\n const hasTime = hour !== undefined || minute !== undefined || second !== undefined || millisecond !== undefined;\n\n if (timeZoneId !== undefined && !(hasFullDate && hasTime)) {\n throw new FormatSyntaxError({\n format: formatStr,\n message:\n `temporal-fmt: format string \"${formatStr}\" has a \"zzz\" token but needs a full date and time ` +\n `to build a ZonedDateTime.`,\n });\n }\n\n // Mirror zzz's full-date-and-time requirement: an offset alone is\n // meaningless without a wall-clock instant to anchor it to. Throws the\n // same kind of \"needs full date and time\" error zzz throws — separate\n // message so a caller reading it can tell which token type they\n // forgot to pair with a full date+time.\n if (offsetString !== undefined && !(hasFullDate && hasTime)) {\n throw new FormatSyntaxError({\n format: formatStr,\n message:\n `temporal-fmt: format string \"${formatStr}\" has an offset token (X/XX/XXX/x/xx/xxx) but needs a full date and time ` +\n `to build a ZonedDateTime.`,\n });\n }\n\n if (weekdayExpected !== undefined && !hasFullDate) {\n throw new FormatSyntaxError({\n format: formatStr,\n message:\n `temporal-fmt: format string \"${formatStr}\" has a weekday token (\"EEEE\"/\"EEE\") but needs ` +\n `a full date to validate it against.`,\n });\n }\n\n if (!hasFullDate && !hasTime) {\n // shouldn't happen — every token maps to a date, time, zone, or\n // weekday field, and weekday-without-date already threw above\n throw new FormatSyntaxError({\n format: formatStr,\n message: `temporal-fmt: format string \"${formatStr}\" has no date or time tokens to parse.`,\n });\n }\n\n const temporal = getTemporal();\n const timeFields = {\n hour: hour ?? 0,\n minute: minute ?? 0,\n second: second ?? 0,\n millisecond: millisecond ?? 0,\n microsecond: microsecond ?? 0,\n nanosecond: nanosecond ?? 0,\n };\n // omitted entirely for the default calendar (see resolveCalendar) so\n // construction stays plain ISO 8601 unless a caller's locale asks for\n // something else — Temporal calendars don't apply to time-only values.\n const calendarField = calendar ? { calendar } : {};\n\n // overflow: 'reject' — without it Temporal *clamps* out-of-range fields\n // (Feb 30 silently becomes Feb 28) instead of throwing, which would\n // contradict the \"throws on genuinely invalid data\" behavior parse() promises.\n const reject = { overflow: 'reject' as const };\n\n let result: unknown;\n try {\n if (timeZoneId !== undefined) {\n // offset: 'prefer' never throws on a mismatch — it just falls back to\n // the zone's real offset at this instant, silently overriding\n // whatever the offset token said. That's also what resolves a\n // repeated wall-clock time (DST fall-back): without an explicit\n // offset, Temporal defaults to the first occurrence, so passing the\n // token's offset here is what lets a second-occurrence input resolve\n // to the second occurrence instead of always falling back to the\n // first. Either way, \"prefer\" can't be used to detect disagreement —\n // that's checked explicitly below, once we have a real ZonedDateTime\n // to compare against, instead of relying on the wording of whatever\n // error Temporal's active implementation happens to throw (that\n // wording isn't part of the spec and differs between the native\n // Temporal global and userland polyfills).\n const zoneOptions: Temporal.ZonedDateTimeFromOptions = { overflow: 'reject', offset: 'prefer' };\n result = temporal.ZonedDateTime.from(\n {\n year: year!, month: month!, day: day!, ...timeFields, ...calendarField,\n timeZone: timeZoneId,\n ...(offsetString !== undefined ? { offset: offsetString } : {}),\n },\n zoneOptions\n );\n if (offsetString !== undefined) {\n // 'prefer' silently rewrites the wall-clock time itself when the\n // input falls in a DST gap (the time never occurred, so there's\n // no instant to prefer toward) — it doesn't just pick a\n // different offset for the same clock time, the way it does for\n // an overlap. Checking offsetString alone can't tell \"gap,\n // silently moved\" apart from \"overlap, correctly resolved,\"\n // since both can produce an actualOffset that differs from what\n // was parsed. Comparing the wall-clock fields catches the gap\n // case: they can only drift from the parsed input if Temporal\n // moved the clock time to escape the gap.\n //\n // Only checked when an offset token was given: with no offset\n // token to disagree with, a gap shifting forward is the\n // documented, wanted behavior (there's nothing to reject against).\n const zdt = result as Temporal.ZonedDateTime;\n const wallClockShifted =\n zdt.hour !== timeFields.hour ||\n zdt.minute !== timeFields.minute ||\n zdt.second !== timeFields.second;\n if (wallClockShifted) {\n // InvalidDateError, not AmbiguousInputError: the message\n // *mentions* \"not an ambiguous... instant\" as a negation, which\n // is a false-positive match against wrapUntypedError's\n // /ambiguous/i classifier regex — the actual failure here is a\n // wall-clock time that doesn't exist (DST gap), which is an\n // invalid-value problem, not an ambiguous-reading-of-input\n // problem the way the numeric-token-glue ambiguity above is.\n throw new InvalidDateError({\n input, format: formatStr,\n message:\n `\"${timeZoneId}\" has no such wall-clock time on this date — it falls in a DST gap, ` +\n `not an ambiguous or valid instant.`,\n });\n }\n const actualOffset = zdt.offset;\n if (actualOffset !== offsetString) {\n throw new ParseMismatchError({\n input, format: formatStr,\n message:\n `has both a \"zzz\" zone (${timeZoneId}) and an offset token (${offsetString}), ` +\n `but the zone's actual offset at this date/time is ${actualOffset}, not ${offsetString}.`,\n });\n }\n }\n } else if (offsetString !== undefined) {\n // Pattern had an offset token but no zzz. Use the offset string\n // directly as the timeZone — Temporal accepts a fixed-offset\n // string and produces a ZonedDateTime whose timeZoneId is the\n // offset string itself (e.g. \"+09:00\"). Same shape zzz produces\n // when it parses a fixed offset, just reached via a different\n // token.\n result = temporal.ZonedDateTime.from({ year: year!, month: month!, day: day!, ...timeFields, ...calendarField, timeZone: offsetString }, reject);\n } else if (hasFullDate && hasTime) {\n result = temporal.PlainDateTime.from({ year: year!, month: month!, day: day!, ...timeFields, ...calendarField }, reject);\n } else if (hasFullDate) {\n result = temporal.PlainDate.from({ year: year!, month: month!, day: day!, ...calendarField }, reject);\n } else {\n result = temporal.PlainTime.from(timeFields, reject);\n }\n } catch (err) {\n throw new InvalidDateError({\n input, format: formatStr,\n message:\n `temporal-fmt: \"${input}\" doesn't describe a valid date/time for format \"${formatStr}\": ` +\n `${(err as Error).message}`,\n });\n }\n\n if (weekdayExpected !== undefined) {\n const actual = (result as { dayOfWeek: number }).dayOfWeek;\n if (actual !== weekdayExpected) {\n const vocab = getLocaleVocab(locale);\n throw new InvalidDateError({\n input, format: formatStr,\n message:\n `temporal-fmt: \"${weekdayRaw}\" doesn't match the actual weekday (${vocab.weekdayLong[actual - 1]}) ` +\n `for the parsed date.`,\n });\n }\n }\n\n // Q/QQQ is a derived field of the month: 1-3 -> Q1, 4-6 -> Q2, 7-9 -> Q3,\n // 10-12 -> Q4. If a format string carries a quarter token alongside\n // month/date tokens, parse() cross-checks the parsed quarter against the\n // month the same way EEEE cross-checks weekday against date — silently\n // accepting a mismatch would defeat the point of having a quarter token\n // at all, since you'd be telling parse() one thing and the date another.\n if (quarter !== undefined && month !== undefined) {\n const expectedQuarter = Math.ceil(month / 3);\n if (quarter !== expectedQuarter) {\n throw new InvalidDateError({\n format: formatStr,\n message:\n `temporal-fmt: format string \"${formatStr}\" contains a quarter token (Q/QQQ) whose value ` +\n `(Q${quarter}) disagrees with the parsed month's actual quarter — month ${month} is in ` +\n `Q${expectedQuarter}.`,\n });\n }\n }\n\n return result;\n}\n\n// safeParse: returns a discriminated union instead of throwing. The\n// happy path returns `{ ok: true, value }` with the Temporal instance\n// (typed as `unknown` since this package has no ambient Temporal types).\n// The error path returns `{ ok: false, error }` where `error` is a\n// `TemporalFmtError` subclass when the failure is one the typed-error\n// surface in errors.ts knows how to classify (most of them), or a\n// wrapped plain `Error` (still inside a TemporalFmtError shell) when\n// the throw site hasn't been migrated yet. Callers needing the original\n// thrown object for backward compatibility should use parse() directly.\nexport type SafeParseResult =\n | { ok: true; value: unknown }\n | { ok: false; error: TemporalFmtError };\n\nexport function safeParse(formatStr: string, input: string, options: NumberingParseOptions = {}): SafeParseResult {\n try {\n return { ok: true, value: parse(formatStr, input, options) };\n } catch (err) {\n // Pass through typed errors unchanged — preserves the structured\n // fields (code/token/position/etc.) the existing typed-error\n // surface already populated.\n //\n // Every reachable throw site in parse()'s call graph now throws a\n // TemporalFmtError directly, so this condition is always true in the\n // current test suite; the false path (falling through to\n // wrapUntypedError below) is kept as a safety net for any throw site\n // added later without being migrated to a typed class immediately —\n // removing it would silently break the \"safeParse always returns a\n // TemporalFmtError\" contract documented above. Ignoring the whole\n // if/else as one unit is harmless for the true branch (real tests\n // still execute and count it — c8 just excludes it from the\n // denominator), and it's the only shape that actually suppresses the\n // false-branch marker, since c8 has no standalone \"ignore else\".\n /* c8 ignore start @preserve */\n if (err instanceof TemporalFmtError) {\n return { ok: false, error: err };\n }\n return { ok: false, error: wrapUntypedError(err as Error, { input, format: formatStr }) };\n }\n /* c8 ignore stop @preserve */\n}\n\n// tryParse: best-effort variant. Returns the parsed value or undefined.\n// Suppresses diagnostics entirely — when callers need the reason for\n// a failure, they should use safeParse(). Intentionally loose on the\n// return type (unknown) since this package has no ambient Temporal\n// types to return a real one against.\nexport function tryParse(formatStr: string, input: string, options: NumberingParseOptions = {}): unknown | undefined {\n try {\n return parse(formatStr, input, options);\n } catch {\n return undefined;\n }\n}\n\n// parseToParts: returns the matched groups with token labels, before\n// any Temporal construction. Useful for callers that want to inspect\n// what each token captured (e.g. to build a non-Temporal result, or to\n// cross-check fields themselves) without committing to the inferred\n// Temporal type parse() would build.\n//\n// Throws the same errors parse() throws for early validation (unknown\n// token, unterminated quote, no-match, ambiguity in strict mode) since\n// those failures happen before any group assignment. Construction-time\n// errors (Feb 30, weekday mismatch, etc.) do not happen here —\n// parseToParts doesn't construct anything, so it can't fail at that step.\nexport interface ParsedPart {\n token: string;\n raw: string;\n // Field name (year/month/day/...) this token would assign if handed\n // to parse()'s applyGroup loop. undefined for tokens that don't map\n // to a single field (none today, but kept here so future additions\n // don't have to widen the type).\n field?: string;\n // Position of `raw` in `input`, 0-indexed. Lets a caller highlight\n // the matched span in an editor/CLI.\n position: number;\n}\n\nexport function parseToParts(formatStr: string, input: string, options: NumberingParseOptions = {}): ParsedPart[] {\n if (formatStr.length > MAX_FORMAT_LENGTH) {\n throw new FormatSyntaxError({\n format: formatStr,\n message:\n `temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters ` +\n `(got ${formatStr.length}).`,\n });\n }\n if (input.length > MAX_INPUT_LENGTH) {\n throw new FormatSyntaxError({\n input,\n message: `temporal-fmt: input exceeds maximum length of ${MAX_INPUT_LENGTH} characters (got ${input.length}).`,\n });\n }\n\n // Same numeral transliteration parse() does — see the comment there.\n if (options.parseNumberingSystem) {\n input = applyParseNumbering(input, options);\n }\n\n const locale = options.locale ?? DEFAULT_LOCALE;\n const pattern = getPattern(formatStr, locale);\n const match = pattern.regex.exec(input);\n if (!match) {\n throw new ParseMismatchError({\n input, format: formatStr,\n // reason set explicitly (not just message): parse.test.js's\n // \"safeParse: failure returns { ok: false, error } with a\n // TemporalFmtError\" asserts result.error.reason carries the\n // underlying detail text, matching what wrapUntypedError used to\n // populate when this message reached it as a caught plain Error.\n reason: 'no valid pattern matches the format string and input shape',\n message: `temporal-fmt: no valid pattern matches the format string and input shape`,\n });\n }\n if (pattern.groups.length === 0) {\n // ParseMismatchError, not FormatSyntaxError: pinned by\n // errors.test.js's \"format string with no tokens at all falls\n // through to ParseMismatchError\" — wrapUntypedError's classifier\n // has no branch for this message, so it lands on the\n // PARSE_MISMATCH fallback, and a direct throw here needs to\n // agree with that.\n throw new ParseMismatchError({\n format: formatStr,\n // reason set explicitly: errors.test.js's \"format string with no\n // tokens at all falls through to ParseMismatchError\" asserts\n // error.reason matches /has no tokens/.\n reason: `format string \"${formatStr}\" has no tokens — nothing to parse into a value.`,\n message: `temporal-fmt: format string \"${formatStr}\" has no tokens — nothing to parse into a value.`,\n });\n }\n // Same zzz shape-validation parse() does — kept here for parity, so\n // a caller using parseToParts sees the same InvalidTimeZoneError for\n // a bogus zone id, not a silently-accepted bogus zone.\n for (const { name, token } of pattern.groups) {\n if (token === 'zzz' && !isValidTimeZone(match.groups![name]!)) {\n throw new InvalidTimeZoneError({\n input, format: formatStr, actual: match.groups![name],\n reason: 'not a recognized IANA time zone identifier',\n });\n }\n }\n\n // Glued-run split handling: same as parse() — each run's single regex\n // group is split into per-token values by enumerateValidSplits();\n // unique split resolves, 2+ splits throws in strict mode / heuristic-\n // picks in lenient, 0 splits is a shape mismatch. parseToParts mirrors\n // parse() so callers switching between the two on the same input get\n // consistent results.\n const runValues = new Map<string, string>();\n for (const run of pattern.ambiguousRuns) {\n const runDigits = match.groups![run.groupName]!;\n const splits = enumerateValidSplits(runDigits, run.tokens);\n if (splits.length === 0) {\n throw new ParseMismatchError({\n input, format: formatStr,\n reason: 'no valid pattern matches the format string and input shape',\n message: `temporal-fmt: no valid pattern matches the format string and input shape`,\n });\n }\n if (splits.length > 1) {\n if (!options.lenient) {\n throw new AmbiguousInputError({\n input, format: formatStr,\n message:\n `temporal-fmt: \"${runDigits}\" in format string \"${formatStr}\" is ambiguous — ` +\n `${splits.length} different ways to read tokens \"${run.tokens.join('')}\" (with no separator ` +\n `between them) are all individually valid (e.g. ${JSON.stringify(splits[0])} vs ${JSON.stringify(splits[1])}). ` +\n `parse() won't guess; add a separator between these tokens, or use their padded form ` +\n `(e.g. \"MM\" instead of \"M\") so each one has a fixed width. ` +\n `Pass { lenient: true } to opt into a documented heuristic that picks one.`,\n });\n }\n const picked = pickLenientSplit(splits, run.tokens);\n run.groupNames.forEach((name, idx) => runValues.set(name, String(picked[idx])));\n } else {\n run.groupNames.forEach((name, idx) => runValues.set(name, String(splits[0]![idx])));\n }\n }\n\n const parts: ParsedPart[] = [];\n // match.indices.groups (provided by the regex 'd' flag) gives the\n // [start, end] of each named group in the input. Used here so positions\n // are accurate even when literals separate tokens — summing raw\n // lengths alone wouldn't account for the literal characters between\n // groups. Falls back to the cumulative-raw-length heuristic on engines\n // without 'd' support (none we target, but the fallback keeps the\n // code robust if the flag is ever removed).\n const indices = (match as RegExpMatchArray & { indices?: { groups?: Record<string, [number, number]> } }).indices;\n const groupIndices = indices?.groups;\n let consumed = 0;\n for (const { name, token } of pattern.groups) {\n const raw = runValues.get(name) ?? match.groups![name]!;\n // Glued-run members have no regex group of their own — the regex's\n // recorded indices point at the run's overall span, not the\n // individual token's slice within it — so fall back to cumulative-\n // raw-length for them. Positions stay monotonic but may not be\n // exact for tokens inside a resolved run. Documented as a known\n // limitation; the alternative (re-running the regex with the chosen\n // split baked in) would mean a second match pass for a corner case\n // the caller opted into by gluing unpadded tokens.\n const fromIndices = !runValues.has(name) && groupIndices?.[name];\n /* c8 ignore next */\n const position = fromIndices ? fromIndices[0] : (match.index ?? 0) + consumed;\n parts.push({ token, raw, position });\n consumed += raw.length;\n }\n return parts;\n}\n\n// compileParser: pre-compiles a format string into an object whose\n// parse()/safeParse()/parseToParts() methods skip the per-call\n// pattern-cache lookup. The patternCache in this module means a plain\n// parse(fmt, input) call already pays only a Map lookup after the first\n// call, so compileParser is mostly an ergonomics affordance — useful\n// for callers who want to hold the compiled parser explicitly (e.g. to\n// inspect the pattern via the .pattern property).\nexport interface CompiledParser {\n parse(input: string, options?: NumberingParseOptions): unknown;\n safeParse(input: string, options?: NumberingParseOptions): SafeParseResult;\n tryParse(input: string, options?: NumberingParseOptions): unknown | undefined;\n parseToParts(input: string, options?: NumberingParseOptions): ParsedPart[];\n readonly formatStr: string;\n readonly pattern: CapturingPattern;\n}\n\nexport function compileParser(formatStr: string, options: NumberingParseOptions = {}): CompiledParser {\n if (formatStr.length > MAX_FORMAT_LENGTH) {\n throw new FormatSyntaxError({\n format: formatStr,\n message:\n `temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters ` +\n `(got ${formatStr.length}).`,\n });\n }\n // Pre-compile against the default locale; per-call locales will\n // re-resolve via getPattern() if they differ. Most callers use one\n // locale consistently, so pre-compiling against the default keeps\n // the fast path fast.\n const locale = options.locale ?? DEFAULT_LOCALE;\n const pattern = getPattern(formatStr, locale);\n return {\n formatStr,\n pattern,\n parse(input: string, opts: NumberingParseOptions = {}) {\n return parse(formatStr, input, { locale, ...opts });\n },\n safeParse(input: string, opts: NumberingParseOptions = {}) {\n return safeParse(formatStr, input, { locale, ...opts });\n },\n tryParse(input: string, opts: NumberingParseOptions = {}) {\n return tryParse(formatStr, input, { locale, ...opts });\n },\n parseToParts(input: string, opts: NumberingParseOptions = {}) {\n return parseToParts(formatStr, input, { locale, ...opts });\n },\n };\n}"],"mappings":"iQAGA,SAASA,GAAaC,EAAyB,CAC7C,OAAOA,EAAQ,QAAQ,sBAAuB,MAAM,CACtD,CAEA,SAASC,EAAYC,EAAkBC,EAAkB,GAAe,CACtE,IAAMC,EAAUF,EAAO,IAAIH,EAAY,EACvC,OAAKI,EAKE,MAAMC,EAAQ,IAAIC,EAAQ,EAAE,KAAK,GAAG,CAAC,IALf,MAAMD,EAAQ,KAAK,GAAG,CAAC,GAMtD,CAOA,SAASC,GAASC,EAAuB,CACvC,OAAOA,EAAM,QAAQ,YAAcC,GAAO,IAAIA,EAAG,YAAY,CAAC,GAAGA,EAAG,YAAY,CAAC,GAAG,CACtF,CAYA,IAAMC,GAAkB,2GAqBlBC,GAAwC,CAC5C,EAAK,8BACL,GAAK,mBACL,IAAK,0BACL,EAAK,wBACL,GAAK,aACL,IAAK,mBACP,EAEA,SAASC,IAA8B,CACrC,OAAOF,EACT,CAEA,IAAIG,EAKJ,SAASC,IAA+B,CACtC,OAAKD,IACHA,EAAe,IAAI,IAAI,KAAK,kBAAkB,UAAU,CAAC,EACzDA,EAAa,IAAI,KAAK,GAEjBA,CACT,CAEA,IAAME,GAAkB,6CAMjB,SAASC,EAAgBC,EAAsB,CACpD,OAAOF,GAAgB,KAAKE,CAAG,GAAKH,GAAgB,EAAE,IAAIG,CAAG,CAC/D,CAsBA,IAAMC,GAA4C,CAChD,GAAI,SACJ,GAAI,oBACJ,EAAG,mBACH,GAAI,2BACJ,EAAG,0BACH,GAAI,qBACJ,EAAG,wBACH,GAAI,oBACJ,EAAG,mBACH,GAAI,eACJ,EAAG,qBACH,GAAI,eACJ,EAAG,qBACH,UAAW,SACX,SAAU,SACV,QAAS,SACT,OAAQ,SACR,MA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itive","escaped","foldCase","value","ch","TIME_ZONE_SHAPE","OFFSET_SHAPES","getTimeZoneFragment","validZoneSet","getValidZoneSet","FIXED_OFFSET_RE","isValidTimeZone","raw","NUMERIC_FRAGMENTS","QQQ_FRAGMENT","FORMAT_ONLY_TOKENS","YYYY_EXACT","YYYY_EXTENDED","DIGIT_LEADING_TOKENS","tokenFragment","token","locale","nextToken","numeric","UnknownTokenError","vocab","getLocaleVocab","UNPADDED_NUMERIC_TOKENS","UNPADDED_NUMERIC_RANGES","enumerateValidSplits","digits","tokens","memo","solve","tokenIndex","offset","key","cached","result","ranges","results","width","min","max","piece","restSplit","escapeRegExp","literal","MAX_AMBIGUITY_BITS","widthChoicesBits","choices","isDigitConsumingStart","piece","DIGIT_LEADING_TOKENS","buildCapturingPattern","pieces","locale","groups","ambiguousRuns","source","i","ambiguityBits","currentRun","flushRun","nextPiece","name","token","tokenFragment","runName","tokenCount","idx","UNPADDED_NUMERIC_TOKENS","nextToken","FormatSyntaxError","patternCache","MAX_CACHE_SIZE","subscribeToVocabChanges","getPattern","formatStr","locale","key","canonicalCacheKey","pattern","oldestKey","buildCapturingPattern","tokenize","calendarCache","MAX_CALENDAR_CACHE_SIZE","resolveCalendar","assertValidLocaleTag","canonicalLocale","calendar","parts","extensionIndex","calendarKeyIndex","resolved","parseOffsetString","raw","token","sign","body","hoursStr","minutesStr","hours","minutes","InvalidOffsetError","assignField","fields","value","applyGroup","vocab","getLocaleVocab","nanoOfSecond","periodIndex","p","pickLenientSplit","splits","tokens","dayIndex","smallDaySplits","resolveYear","FormatSyntaxError","resolveHour","expected","parse","input","options","applyParseNumbering","DEFAULT_LOCALE","match","ParseMismatchError","name","isValidTimeZone","InvalidTimeZoneError","runValues","run","runDigits","enumerateValidSplits","AmbiguousInputError","picked","idx","year","hour","month","day","minute","second","millisecond","microsecond","nanosecond","timeZoneId","offsetString","weekdayExpected","weekdayRaw","quarter","hasAnyDatePart","hasFullDate","InvalidDateError","hasTime","temporal","getTemporal","timeFields","calendarField","reject","result","zoneOptions","zdt","actualOffset","err","actual","expectedQuarter","safeParse","TemporalFmtError","wrapUntypedError","tryParse","parseToParts","groupIndices","consumed","fromIndices","position","compileParser","opts"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|