temporal-fmt 0.9.2 → 0.9.4

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.
Files changed (103) hide show
  1. package/README.md +480 -9
  2. package/dist/calendarUtils.cjs +259 -4
  3. package/dist/calendarUtils.cjs.map +1 -1
  4. package/dist/calendarUtils.js +33 -1
  5. package/dist/chunk-4N3WCGEY.js +183 -0
  6. package/dist/{chunk-4JWGUR4O.js.map → chunk-4N3WCGEY.js.map} +1 -1
  7. package/dist/chunk-5UTV5VP6.js +984 -0
  8. package/dist/chunk-5UTV5VP6.js.map +1 -0
  9. package/dist/chunk-ACKKWH5Z.js +578 -0
  10. package/dist/{chunk-2JHEV7ZF.js.map → chunk-ACKKWH5Z.js.map} +1 -1
  11. package/dist/chunk-EGUUO6LE.js +439 -0
  12. package/dist/chunk-EGUUO6LE.js.map +1 -0
  13. package/dist/chunk-FBPHNRVW.js +2939 -0
  14. package/dist/chunk-FBPHNRVW.js.map +1 -0
  15. package/dist/chunk-GPB4JHGI.js +65 -0
  16. package/dist/chunk-GPB4JHGI.js.map +1 -0
  17. package/dist/chunk-H7YQX25T.js +170 -0
  18. package/dist/{chunk-J2AQNXF2.js.map → chunk-H7YQX25T.js.map} +1 -1
  19. package/dist/chunk-HXY2GUUM.js +182 -0
  20. package/dist/{chunk-EHLRZULM.js.map → chunk-HXY2GUUM.js.map} +1 -1
  21. package/dist/chunk-L24NPTAJ.js +328 -0
  22. package/dist/chunk-L24NPTAJ.js.map +1 -0
  23. package/dist/chunk-M3GDTHMT.js +169 -0
  24. package/dist/chunk-M3GDTHMT.js.map +1 -0
  25. package/dist/chunk-MKPDLQKD.js +51 -0
  26. package/dist/chunk-MKPDLQKD.js.map +1 -0
  27. package/dist/chunk-TSLPIURC.js +242 -0
  28. package/dist/{chunk-VQXUMFB2.js.map → chunk-TSLPIURC.js.map} +1 -1
  29. package/dist/chunk-UOPAV3WX.js +75 -0
  30. package/dist/chunk-UOPAV3WX.js.map +1 -0
  31. package/dist/chunk-VNIUIQA4.js +398 -0
  32. package/dist/chunk-VNIUIQA4.js.map +1 -0
  33. package/dist/chunk-YEUASGDK.js +9 -0
  34. package/dist/chunk-YEUASGDK.js.map +1 -0
  35. package/dist/chunk-ZQZF5EXW.js +29 -0
  36. package/dist/chunk-ZQZF5EXW.js.map +1 -0
  37. package/dist/config.d.cts +4 -2
  38. package/dist/config.d.ts +4 -2
  39. package/dist/duration.cjs +638 -26
  40. package/dist/duration.cjs.map +1 -1
  41. package/dist/duration.js +28 -1
  42. package/dist/format.cjs +833 -35
  43. package/dist/format.cjs.map +1 -1
  44. package/dist/format.js +20 -1
  45. package/dist/index.cjs +7698 -163
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +108 -24
  48. package/dist/index.d.ts +108 -24
  49. package/dist/index.js +1536 -58
  50. package/dist/index.js.map +1 -1
  51. package/dist/interval.cjs +5480 -35
  52. package/dist/interval.cjs.map +1 -1
  53. package/dist/interval.js +46 -1
  54. package/dist/localeRegistry.cjs +375 -32
  55. package/dist/localeRegistry.cjs.map +1 -1
  56. package/dist/localeRegistry.js +11 -1
  57. package/dist/modApi.d.cts +131 -0
  58. package/dist/modApi.d.ts +131 -0
  59. package/dist/parse.cjs +1797 -70
  60. package/dist/parse.cjs.map +1 -1
  61. package/dist/parse.js +20 -1
  62. package/dist/pattern.d.cts +1 -0
  63. package/dist/pattern.d.ts +1 -0
  64. package/dist/recurrence.cjs +452 -20
  65. package/dist/recurrence.cjs.map +1 -1
  66. package/dist/recurrence.js +19 -1
  67. package/dist/relativeTime.cjs +268 -21
  68. package/dist/relativeTime.cjs.map +1 -1
  69. package/dist/relativeTime.js +14 -1
  70. package/dist/runtime.d.cts +201 -0
  71. package/dist/runtime.d.ts +201 -0
  72. package/dist/timezone.cjs +387 -20
  73. package/dist/timezone.cjs.map +1 -1
  74. package/dist/timezone.js +26 -1
  75. package/package.json +4 -6
  76. package/scripts/cli.mjs +27 -5
  77. package/dist/chunk-2JHEV7ZF.js +0 -7
  78. package/dist/chunk-3MZLTVP3.js +0 -2
  79. package/dist/chunk-3MZLTVP3.js.map +0 -1
  80. package/dist/chunk-4JWGUR4O.js +0 -11
  81. package/dist/chunk-5U5WJ465.js +0 -36
  82. package/dist/chunk-5U5WJ465.js.map +0 -1
  83. package/dist/chunk-C5YESWFT.js +0 -2
  84. package/dist/chunk-C5YESWFT.js.map +0 -1
  85. package/dist/chunk-C6ZZ62ET.js +0 -2
  86. package/dist/chunk-C6ZZ62ET.js.map +0 -1
  87. package/dist/chunk-EHLRZULM.js +0 -5
  88. package/dist/chunk-F4RGUDA3.js +0 -2
  89. package/dist/chunk-F4RGUDA3.js.map +0 -1
  90. package/dist/chunk-J2AQNXF2.js +0 -2
  91. package/dist/chunk-NBXF7V5B.js +0 -2
  92. package/dist/chunk-NBXF7V5B.js.map +0 -1
  93. package/dist/chunk-R52YOKI3.js +0 -7
  94. package/dist/chunk-R52YOKI3.js.map +0 -1
  95. package/dist/chunk-UJR6DHXY.js +0 -2
  96. package/dist/chunk-UJR6DHXY.js.map +0 -1
  97. package/dist/chunk-VQXUMFB2.js +0 -21
  98. package/dist/chunk-XH46JNPK.js +0 -2
  99. package/dist/chunk-XH46JNPK.js.map +0 -1
  100. package/dist/chunk-YB6YAG7E.js +0 -35
  101. package/dist/chunk-YB6YAG7E.js.map +0 -1
  102. package/dist/chunk-ZGMTY52O.js +0 -2
  103. package/dist/chunk-ZGMTY52O.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,59 +1,1537 @@
1
- import{a as nr,b as tr}from"./chunk-NBXF7V5B.js";import{a as Er,b as xr,c as Cr,d as Rr,e as Fr,f as $r,g as Ir,h as Ar,i as Or}from"./chunk-J2AQNXF2.js";import{a as _n,b as Ln,c as Hn,d as Un,e as $e,f as Gn,g as Zn,h as Wn,i as Yn,j as Bn,k as Xn,l as qn,m as Kn,n as Jn,o as Qn}from"./chunk-2JHEV7ZF.js";import{a as ir,b as sr,c as lr,d as mr,e as ur,f as dr,g as cr,h as fr,i as pr,j as yr,k as gr,l as hr,m as Tr,n as wr}from"./chunk-F4RGUDA3.js";import{a as L,b as at,c as it,e as he}from"./chunk-4JWGUR4O.js";import{a as rr,b as or,c as ar}from"./chunk-XH46JNPK.js";import{a as st,b as Ae,c as K,d as lt,e as mt,f as ut,g as dt}from"./chunk-YB6YAG7E.js";import{a as q,b as et,c as nt,d as tt,e as rt,f as ot}from"./chunk-R52YOKI3.js";import{a as _,b as X}from"./chunk-C5YESWFT.js";import{b as Vn,c as A}from"./chunk-3MZLTVP3.js";import{a as Fn,b as w,c as pe,d as $n,e as ye,f as In,g as An,h as On,i as Pn,j as zn,k as ge,l as Nn,o as jn,p as Ie}from"./chunk-5U5WJ465.js";import{a as vr,b as br,c as Sr,d as kr,e as Mr,f as Dr}from"./chunk-ZGMTY52O.js";import{A as Nt,a as v,b as ct,c as ft,d as pt,e as yt,f as gt,g as ht,h as Tt,i as wt,j as vt,k as bt,l as St,m as kt,n as Mt,o as Dt,p as Et,q as xt,r as Ct,s as Rt,t as Ft,u as $t,v as It,w as At,x as Ot,y as Pt,z as zt}from"./chunk-VQXUMFB2.js";import{a as J,b as _t,c as Lt,d as Ht,e as Ut,f as jt,g as Gt,h as Zt,i as Wt,j as Yt,k as Bt,l as Xt,m as qt,n as Kt,o as Jt,p as Qt,q as Vt,r as er}from"./chunk-UJR6DHXY.js";import{a as gn,b as hn,c as Tn,d as wn,e as vn,f as bn,g as Sn,h as kn,i as Mn,j as Dn,k as En,l as xn,m as Cn,n as Rn}from"./chunk-EHLRZULM.js";import{a as fe,b as Fe}from"./chunk-C6ZZ62ET.js";function Oe(e,n){if(e===null||typeof e!="object")throw new Error(`temporal-fmt: formatDistance expects Temporal values, got ${n} = ${String(e)}.`);let t=e,r=typeof t.year=="number",a=typeof t.month=="number",o=typeof t.day=="number";if(r!==a||a!==o)throw new Error(`temporal-fmt: formatDistance got a ${n} with a partial date (some of year/month/day missing). Pass a full Temporal.PlainDate / PlainDateTime / ZonedDateTime.`);return{year:r?t.year:void 0,month:a?t.month:void 0,day:o?t.day:void 0,hour:typeof t.hour=="number"?t.hour:void 0,minute:typeof t.minute=="number"?t.minute:void 0,second:typeof t.second=="number"?t.second:void 0,millisecond:typeof t.millisecond=="number"?t.millisecond:void 0}}var Te=2e3,Q=1e3,V=60*Q,ee=60*V,F=24*ee;function Pr(e,n,t){let r=0;if(e>=Te)for(let a=Te;a<e;a++)r+=fe(a)?366:365;else for(let a=e;a<Te;a++)r-=fe(a)?366:365;return r+=Fe(e,n,t)-1,r}function Pe(e){if(e.year===void 0||e.month===void 0||e.day===void 0)throw new Error("temporal-fmt: formatDistance needs a Temporal value with year/month/day fields (PlainDate, PlainDateTime, or ZonedDateTime). A PlainTime or other shape has no anchor date to diff against.");let n=Pr(e.year,e.month,e.day),t=e.hour??0,r=e.minute??0,a=e.second??0,o=e.millisecond??0;return n*F+t*ee+r*V+a*Q+o}var zr={seconds:60,minutes:60,hours:24,days:30,months:365};function Nr(e){let n={...zr,...e};for(let d of Object.keys(n)){let i=n[d];if(typeof i!="number"||!Number.isFinite(i)||i<=0)throw new Error(`temporal-fmt: formatDistance cutoff "${d}" must be a positive finite number (got ${String(i)}).`)}let t=n.seconds*Q,r=n.minutes*V,a=n.hours*ee,o=n.days*F,s=n.months*F;if(!(t<=r&&r<=a&&a<=o&&o<=s))throw new Error(`temporal-fmt: formatDistance cutoffs must be monotonically non-decreasing in equivalent ms (seconds \u2264 minutes \u2264 hours \u2264 days \u2264 months). Got: seconds=${n.seconds}s, minutes=${n.minutes}min, hours=${n.hours}h, days=${n.days}d, months=${n.months}d \u2014 pick a sequence where each boundary is at least as large as the one before it.`);return[{maxMs:t,unit:"second"},{maxMs:r,unit:"minute"},{maxMs:a,unit:"hour"},{maxMs:o,unit:"day"},{maxMs:s,unit:"month"}]}var G=new Map,_r=100;function Lr(e,n){let t=`${Hr(e)}|${n}`,r=G.get(t);if(r)return r;if(G.size>=_r){let a=G.keys().next().value;a!==void 0&&G.delete(a)}try{r=new Intl.RelativeTimeFormat(Ie(e),{numeric:n})}catch(a){throw new ge({actual:e,reason:a.message})}return G.set(t,r),r}function Hr(e){try{return new Intl.Locale(e.replace(/_/g,"-")).toString().toLowerCase()}catch{return e}}function ze(e,n,t={}){let r=Oe(e,"date1"),a=Oe(n,"date2"),o=Pe(r)-Pe(a),s=Math.abs(o),d=Nr(t.cutoffs),i="year";for(let{maxMs:c,unit:g}of d)if(s<c){i=g;break}let m=jr(i),l=Math.round(o/m),T=t.numeric??"auto",y=t.locale??_;return Lr(y,T).format(l,i)}function Ur(e,n={}){let t=new Date,r={year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds()};return ze(e,r,n)}function jr(e){switch(e){case"second":return Q;case"minute":return V;case"hour":return ee;case"day":return F;case"week":return 7*F;case"month":return 30*F;case"quarter":return 91*F;case"year":return 365*F;default:throw new Error(`temporal-fmt: formatDistance hit unhandled unit "${String(e)}".`)}}var Ne=100,H=[];function Gr(e){if(typeof e.language!="string"||e.language.length===0)throw new Error("temporal-fmt: registerRelativeGrammar requires a non-empty language string.");if(!Array.isArray(e.matchers)||e.matchers.length===0)throw new Error("temporal-fmt: registerRelativeGrammar requires at least one matcher.");let n=H.findIndex(t=>t.language===e.language);if(n>=0)H[n]=e;else{if(H.length>=Ne)throw new RangeError(`temporal-fmt: registerRelativeGrammar reached the ${Ne}-grammar limit.`);H.push(e)}}function _e(e,n,t){for(let r of H)if(r.language===e)for(let a of r.matchers){let o=a(n);if(o===null)continue;let s=A();if(o.resolve){let d=o.resolve(t);return s.PlainDate.from(d,{overflow:"reject"})}return s.PlainDate.from({year:o.year??t.year,month:o.month??t.month,day:o.day??t.day},{overflow:"reject"})}return null}function Zr(){return H.map(e=>e.language)}function k(e){return e.toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Wr(e,n){/* c8 ignore start @preserve -- unreachable through the only call
2
- * site (fuzzyCorrectEnglish): `a` is always a word that already
3
- * failed the `vocabulary.includes(word)` exact-match check, so
4
- * a === b never holds against any `b` drawn from that same
5
- * vocabulary; and neither `a` (split from a non-empty normalized
6
- * string) nor `b` (a vocabulary entry) is ever empty. Kept as
7
- * general-purpose guards in case levenshtein() gets a second caller
8
- * later. */if(e===n)return 0;if(e.length===0)return n.length;if(n.length===0)return e.length;/* c8 ignore stop @preserve */let t=new Array(n.length+1),r=new Array(n.length+1);for(let a=0;a<=n.length;a++)t[a]=a;for(let a=1;a<=e.length;a++){r[0]=a;for(let o=1;o<=n.length;o++){let s=e[a-1]===n[o-1]?0:1;r[o]=Math.min(t[o]+1,r[o-1]+1,t[o-1]+s)}[t,r]=[r,t]}return t[n.length]}var Le=2,te=4096,He=32;function Yr(){return[...Se,...ke,...Me,"today","tomorrow","yesterday","next","last","this","in","ago","day","days","week","weeks","month","months","year","years"].map(k)}var we;function Br(){return we||(we=Object.freeze(Yr())),we}function Xr(e){let n=Br(),t=e.split(" ");if(e.length>te||t.length>He)throw new RangeError(`temporal-fmt: parseRelative fuzzy input is too large (maximum ${te} characters and ${He} words).`);let r=!1,a=t.map(o=>{if(/^\d+(?:st|nd|rd|th)?$/.test(o)||n.includes(o))return o;let s,d=Le+1;for(let i of n){let m=Wr(o,i);m<d&&(d=m,s=i)}return s!==void 0&&d<=Le?(r=!0,s):o});return r?a.join(" "):void 0}function P(e){if(typeof e.year!="number")throw new Error("temporal-fmt: parseRelative reference date is missing year.");return e.year}function z(e){if(typeof e.month!="number")throw new Error("temporal-fmt: parseRelative reference date is missing month.");return e.month}function N(e){if(typeof e.day!="number")throw new Error("temporal-fmt: parseRelative reference date is missing day.");return e.day}function re(e){let n=e.dayOfWeek;if(typeof n!="number")throw new Error("temporal-fmt: parseRelative needs a reference date exposing dayOfWeek (a Temporal.PlainDate / PlainDateTime / ZonedDateTime).");return n}function S(e){return[...e.map(k)].sort((r,a)=>a.length-r.length).map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}function oe(e,n,t,r){return e.PlainDate.from({year:n,month:t,day:r},{overflow:"reject"})}function b(e,n,t){return e.PlainDate.from({year:P(n),month:z(n),day:N(n)}).add({days:t})}function O(e,n,t,r){let a=e.PlainDate.from({year:P(n),month:z(n),day:N(n)}),o={};return r==="day"&&(o.days=t),r==="week"&&(o.weeks=t),r==="month"&&(o.months=t),r==="year"&&(o.years=t),a.add(o)}function ae(e,n,t){if(e==="next"){let r=t-n;return r<=0&&(r+=7),r}if(e==="last"){let r=t-n;return r>=0&&(r-=7),r}return t-n}function ie(e,n,t,r){let a=P(n),o=e.PlainDate.from({year:a,month:z(n),day:N(n)});if(!e.PlainDate.compare)throw new Error("temporal-fmt: parseRelative needs Temporal.PlainDate.compare to resolve month-day phrases; the active implementation does not expose it.");try{let s=e.PlainDate.from({year:a,month:t,day:r},{overflow:"reject"});return e.PlainDate.compare(s,o)>=0?s:e.PlainDate.from({year:a+1,month:t,day:r},{overflow:"reject"})}catch(s){try{return e.PlainDate.from({year:a+1,month:t,day:r},{overflow:"reject"})}catch{throw new Error(`temporal-fmt: parseRelative can't resolve month ${t} day ${r} \u2014 it isn't a valid date in either ${a} or ${a+1}. Original error: ${s.message}`)}}}function se(e,n){let t=k(e),r=n.findIndex(a=>k(a)===t);/* c8 ignore start @preserve -- unreachable: every caller passes a
9
- * name captured by nameAlternation(names), which builds its regex
10
- * alternation from this same list under the same normalizeForMatch
11
- * transform. The regex can't match anything findIndex() wouldn't
12
- * also find here. Defensive throw kept for the type checker and as
13
- * a tripwire if that invariant ever breaks. Ignore comment sits on
14
- * the `if` itself, not just the throw inside it — c8 tracks the
15
- * branch outcome (was the true side ever taken) separately from the
16
- * statements inside, so excluding only the inner throw still leaves
17
- * the branch itself flagged as uncovered. */if(r<0)throw new Error(`temporal-fmt: parseRelative internal error \u2014 weekday "${e}" not in names list.`);/* c8 ignore stop @preserve */return r+1}function le(e,n,t=[]){let r=k(e),a=n.findIndex(s=>k(s)===r);if(a>=0)return a+1;let o=t.findIndex(s=>k(s)===r);if(o>=0)return o+1;/* c8 ignore start @preserve -- unreachable: every caller passes a name
18
- * captured by nameAlternation([...longNames, ...shortNames]), so the
19
- * regex alternation and these two findIndex() scans are built from
20
- * the same lists under the same normalizeForMatch transform. Kept as
21
- * a tripwire for the type checker in case that invariant ever breaks. */throw new Error(`temporal-fmt: parseRelative internal error \u2014 month "${e}" not in names list.`);/* c8 ignore stop @preserve */}var Se=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],ke=["January","February","March","April","May","June","July","August","September","October","November","December"],Me=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z={supportedHint:'Supported: weekday refs ("next Tuesday"), day offsets ("today"/"tomorrow"/"yesterday"), unit offsets ("in 3 days", "2 weeks ago"), and month-day ("March 5th").',matchers:[{pattern:/^today$/i,resolve:(e,n)=>oe(n.temporal,P(n.reference),z(n.reference),N(n.reference))},{pattern:/^tomorrow$/i,resolve:(e,n)=>b(n.temporal,n.reference,1)},{pattern:/^yesterday$/i,resolve:(e,n)=>b(n.temporal,n.reference,-1)},{pattern:new RegExp(`^(next|last|this)\\s+(${S(Se)})$`,"i"),resolve:(e,n)=>{let t=e[1].toLowerCase(),r=se(e[2],Se),a=re(n.reference);return b(n.temporal,n.reference,ae(t,a,r))}},{pattern:/^(in\s+)?(\d+)\s+(day|week|month|year)s?(?:\s+ago)?$/i,resolve:(e,n)=>{let t=e[1],r=e[2],a=e[3].toLowerCase(),o=!!t,s=/\bago\b/i.test(e[0]);if(!o&&!s)throw new Error(`temporal-fmt: parseRelative can't tell whether "${e[0]}" is past or future \u2014 use "in ${r} ${a}s" or "${r} ${a}s ago".`);let d=o?1:-1;return O(n.temporal,n.reference,d*Number(r),a)}},{pattern:new RegExp(`^(${S([...ke,...Me])})\\s+(\\d{1,2})(?:st|nd|rd|th)?(?:,?\\s*(\\d{4}))?$`,"i"),resolve:(e,n)=>{let t=le(e[1],ke,Me),r=Number(e[2]);return ie(n.temporal,n.reference,t,r)}}]},ne=["lunes","martes","mi\xE9rcoles","jueves","viernes","s\xE1bado","domingo"],Ue=["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],je=["ene","feb","mar","abr","may","jun","jul","ago","sept","oct","nov","dic"],qr={supportedHint:'Frases soportadas: referencias de d\xEDa de la semana ("el pr\xF3ximo lunes", "el lunes pasado", "este martes"), offsets de d\xEDa ("hoy"/"ma\xF1ana"/"ayer"), offsets de unidad ("en 3 d\xEDas", "hace 2 semanas"), y mes-d\xEDa ("5 de marzo").',matchers:[{pattern:/^hoy$/i,resolve:(e,n)=>oe(n.temporal,P(n.reference),z(n.reference),N(n.reference))},{pattern:/^ma[ñn]ana$/i,resolve:(e,n)=>b(n.temporal,n.reference,1)},{pattern:/^ayer$/i,resolve:(e,n)=>b(n.temporal,n.reference,-1)},{pattern:new RegExp(`^(?:el\\s+)?(?:(pr[o\xF3]ximo|pasado)\\s+(${S(ne)})|(${S(ne)})\\s+(pr[o\xF3]ximo|pasado)|este\\s+(${S(ne)}))$`,"i"),resolve:(e,n)=>{let t,r;e[1]&&e[2]?(t=e[1],r=e[2]):e[3]&&e[4]?(r=e[3],t=e[4]):(t="este",r=e[5]);let a=k(t)==="proximo"?"next":t.toLowerCase()==="este"?"this":"last",o=se(r,ne),s=re(n.reference);return b(n.temporal,n.reference,ae(a,s,o))}},{pattern:new RegExp("^(?:(en|dentro\\s+de)\\s+(\\d+)\\s+(d[i\xED]a|semana|mes|a[\xF1n]o)s?|(\\d+)\\s+(d[i\xED]a|semana|mes|a[\xF1n]o)s?\\s+(hace))$","i"),resolve:(e,n)=>{let t,r,a;e[1]&&e[2]&&e[3]?(t=e[2],r=e[3],a=1):(t=e[4],r=e[5],a=-1);let o=U(r);return O(n.temporal,n.reference,a*Number(t),o)}},{pattern:new RegExp("^hace\\s+(\\d+)\\s+(d[i\xED]a|semana|mes|a[\xF1n]o)s?$","i"),resolve:(e,n)=>{let t=Number(e[1]),r=U(e[2]);return O(n.temporal,n.reference,-t,r)}},{pattern:new RegExp("^(\\d+)\\s+(d[i\xED]a|semana|mes|a[\xF1n]o)s?$","i"),resolve:(e,n)=>{throw new Error(`temporal-fmt: parseRelative no puede decidir si "${e[0]}" es pasado o futuro \u2014 usa "en ${e[1]} ${e[2]}s" o "hace ${e[1]} ${e[2]}s".`)}},{pattern:new RegExp(`^(\\d{1,2})\\.?\\s+de\\s+(${S([...Ue,...je])})(?:\\s+de\\s+(\\d{4}))?$`,"i"),resolve:(e,n)=>{let t=Number(e[1]),r=le(e[2],Ue,je);return ie(n.temporal,n.reference,r,t)}}]},ve=["lundi","mardi","mercredi","jeudi","vendredi","samedi","dimanche"],Ge=["janvier","f\xE9vrier","mars","avril","mai","juin","juillet","ao\xFBt","septembre","octobre","novembre","d\xE9cembre"],Ze=["janv.","f\xE9vr.","mars","avr.","mai","juin","juil.","ao\xFBt","sept.","oct.","nov.","d\xE9c."],Kr={supportedHint:`Phrases prises en charge : r\xE9f\xE9rences de jour de la semaine ("lundi prochain", "mardi dernier", "ce mercredi"), d\xE9calages de jour ("aujourd'hui"/"demain"/"hier"), d\xE9calages d'unit\xE9 ("dans 3 jours", "il y a 2 semaines"), et mois-jour ("5 mars").`,matchers:[{pattern:/^aujourd'hui$/i,resolve:(e,n)=>oe(n.temporal,P(n.reference),z(n.reference),N(n.reference))},{pattern:/^demain$/i,resolve:(e,n)=>b(n.temporal,n.reference,1)},{pattern:/^hier$/i,resolve:(e,n)=>b(n.temporal,n.reference,-1)},{pattern:new RegExp(`^(?:(${S(ve)})\\s+(prochain|dernier)|ce\\s+(${S(ve)}))$`,"i"),resolve:(e,n)=>{let t,r;e[1]&&e[2]?(r=e[1],t=e[2].toLowerCase()==="prochain"?"next":"last"):(t="this",r=e[3]);let a=se(r,ve),o=re(n.reference);return b(n.temporal,n.reference,ae(t,o,a))}},{pattern:new RegExp("^il\\s+y\\s+a\\s+(\\d+)\\s+(jour|semaine|mois|an|ann[e\xE9e]e)s?$","i"),resolve:(e,n)=>{let t=Number(e[1]),r=U(e[2]);return O(n.temporal,n.reference,-t,r)}},{pattern:new RegExp("^dans\\s+(\\d+)\\s+(jour|semaine|mois|an|ann[e\xE9e]e)s?$","i"),resolve:(e,n)=>{let t=Number(e[1]),r=U(e[2]);return O(n.temporal,n.reference,t,r)}},{pattern:new RegExp("^(\\d+)\\s+(jour|semaine|mois|an|ann[e\xE9e]e)s?$","i"),resolve:(e,n)=>{throw new Error(`temporal-fmt: parseRelative ne peut pas d\xE9terminer si "${e[0]}" est pass\xE9 ou futur \u2014 utilisez "dans ${e[1]} ${e[2]}s" ou "il y a ${e[1]} ${e[2]}s".`)}},{pattern:new RegExp(`^(\\d{1,2})\\s+(${S([...Ge,...Ze])})(?:\\s+(\\d{4}))?$`,"i"),resolve:(e,n)=>{let t=Number(e[1]),r=le(e[2],Ge,Ze);return ie(n.temporal,n.reference,r,t)}}]},We=["Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag","Sonntag"],Ye=["Januar","Februar","M\xE4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],Be=["Jan","Feb","M\xE4r","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],Jr={supportedHint:'Unterst\xFCtzte Phrasen: Wochentag-Bez\xFCge ("n\xE4chsten Dienstag", "letzten Freitag", "diesen Montag"), Tages-Offsets ("heute"/"morgen"/"gestern"), Einheiten-Offsets ("in 3 Tagen", "vor 2 Wochen"), und Monat-Tag ("5. M\xE4rz").',matchers:[{pattern:/^heute$/i,resolve:(e,n)=>oe(n.temporal,P(n.reference),z(n.reference),N(n.reference))},{pattern:/^morgen$/i,resolve:(e,n)=>b(n.temporal,n.reference,1)},{pattern:/^gestern$/i,resolve:(e,n)=>b(n.temporal,n.reference,-1)},{pattern:new RegExp(`^(n(?:ae|a|\xE4)chsten|letzten|diesen)\\s+(${S(We)})$`,"i"),resolve:(e,n)=>{let t=k(e[1]),r=t==="nachsten"||t==="naechsten"?"next":t==="diesen"?"this":"last",a=se(e[2],We),o=re(n.reference);return b(n.temporal,n.reference,ae(r,o,a))}},{pattern:new RegExp("^vor\\s+(\\d+)\\s+(Tag(?:e|n|en)?|Woche(?:n)?|Monat(?:e|n|en)?|Jahr(?:e|n|en)?)$","i"),resolve:(e,n)=>{let t=Number(e[1]),r=U(e[2]);return O(n.temporal,n.reference,-t,r)}},{pattern:new RegExp("^in\\s+(\\d+)\\s+(Tag(?:e|n|en)?|Woche(?:n)?|Monat(?:e|n|en)?|Jahr(?:e|n|en)?)$","i"),resolve:(e,n)=>{let t=Number(e[1]),r=U(e[2]);return O(n.temporal,n.reference,t,r)}},{pattern:new RegExp("^(\\d+)\\s+(Tag(?:e|n|en)?|Woche(?:n)?|Monat(?:e|n|en)?|Jahr(?:e|n|en)?)$","i"),resolve:(e,n)=>{throw new Error(`temporal-fmt: parseRelative kann nicht erkennen, ob "${e[0]}" Vergangenheit oder Zukunft ist \u2014 verwende "in ${e[1]} ${e[2]}" oder "vor ${e[1]} ${e[2]}".`)}},{pattern:new RegExp(`^(\\d{1,2})\\.?\\s+(${S([...Ye,...Be,"Maerz","Maer"])})(?:\\s+(\\d{4}))?$`,"i"),resolve:(e,n)=>{let t=Number(e[1]),r=le(e[2],Ye,Be);return ie(n.temporal,n.reference,r,t)}}]},Qr={en:Z,es:qr,fr:Kr,de:Jr};function Vr(e){if(!e)return Z;try{let t=new Intl.Locale(e.replace(/_/g,"-")).language.toLowerCase();return Qr[t]??Z}catch{return Z}}function eo(e){if(!e)return"en";try{return new Intl.Locale(e.replace(/_/g,"-")).language.toLowerCase()}catch{return"en"}}function U(e){let n=k(e);if(n==="day"||n==="week"||n==="month"||n==="year")return n;if(n==="dia")return"day";if(n==="semana")return"week";if(n==="mes")return"month";if(n==="ano"||n==="a\xF1o")return"year";if(n==="jour")return"day";if(n==="semaine")return"week";if(n==="mois")return"month";if(n==="an"||n==="annee")return"year";if(n==="tag"||n==="tagen")return"day";if(n==="woche"||n==="wochen")return"week";if(n==="monat"||n==="monaten")return"month";if(n==="jahr"||n==="jahren")return"year";/* c8 ignore start @preserve -- unreachable: every caller passes a word
22
- * captured by a regex alternation built from exactly these unit-word
23
- * forms (day/week/month/year across en/es/fr/de), so the branches
24
- * above already cover every string that can reach this function.
25
- * Kept as a tripwire for the type checker in case a grammar adds a
26
- * unit word here without a matching regex update. */throw new Error(`temporal-fmt: parseRelative internal error \u2014 unrecognized unit word "${e}".`);/* c8 ignore stop @preserve */}function no(e,n,t={}){let r=n,a=A(),o=(e??"").trim().replace(/\s+/g," ");if(o.length===0)throw new Error("temporal-fmt: parseRelative got an empty input string.");if(o.length>te)throw new RangeError(`temporal-fmt: parseRelative input is too large (maximum ${te} characters).`);let s=k(o),d=Vr(t.locale),i={temporal:a,reference:r},m=_e(eo(t.locale),o,{year:r.year,month:r.month,day:r.day,dayOfWeek:r.dayOfWeek});if(m!==null)return m;let l=y=>{for(let f of d.matchers){let c=y.match(f.pattern);if(c)return f.resolve(c,i)}return be},T=l(s);if(T!==be)return T;if(t.fuzzy){if(d!==Z)throw new Error("temporal-fmt: parseRelative's { fuzzy: true } option currently only supports English. Pass no locale (or locale: 'en'), or omit { fuzzy: true } for this locale.");let y=Xr(s);if(y!==void 0){let f=l(y);if(f!==be)return f}}throw new Error(`temporal-fmt: parseRelative doesn't recognize "${o}". `+d.supportedHint)}var be=Symbol("temporal-fmt: parseRelative no match");function M(e){return typeof e=="object"&&e!==null}function x(e){return n=>{try{return e(n)}catch{return!1}}}function h(e,n){return typeof e[n]=="function"}function $(e,n){return M(e)?e[Symbol.toStringTag]===`Temporal.${n}`:!1}var Xe=x(function(n){if($(n,"PlainDate"))return!0;if(!M(n))return!1;let t=n;return typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day=="number"&&typeof t.hour>"u"&&h(t,"toPlainDateTime")&&h(t,"withCalendar")}),qe=x(function(n){if($(n,"PlainTime"))return!0;if(!M(n))return!1;let t=n;return typeof t.hour=="number"&&typeof t.year>"u"&&!h(t,"withCalendar")&&!h(t,"toPlainDate")&&!h(t,"toPlainDateTime")}),Ke=x(function(n){if($(n,"PlainDateTime"))return!0;if(!M(n))return!1;let t=n;return typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day=="number"&&typeof t.hour=="number"&&h(t,"withPlainTime")&&!h(t,"toInstant")}),Je=x(function(n){if($(n,"ZonedDateTime"))return!0;if(!M(n))return!1;let t=n;return typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day=="number"&&typeof t.hour=="number"&&h(t,"withTimeZone")&&h(t,"toInstant")}),Qe=x(function(n){if($(n,"Instant"))return!0;if(!M(n))return!1;let t=n;return h(t,"toZonedDateTimeISO")&&!h(t,"toInstant")&&typeof t.year>"u"}),Ve=x(function(n){if($(n,"PlainYearMonth"))return!0;if(!M(n))return!1;let t=n;return typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day>"u"&&h(t,"toPlainDate")}),en=x(function(n){if($(n,"PlainMonthDay"))return!0;if(!M(n))return!1;let t=n;return typeof t.year>"u"&&typeof t.month>"u"&&typeof t.day=="number"&&typeof t.monthCode=="string"&&h(t,"toPlainDate")}),nn=x(function(n){return $(n,"Duration")?!0:M(n)?h(n,"total"):!1}),tn=x(function(n){if(!M(n))return!1;let t=n[Symbol.toStringTag];if(typeof t=="string"&&t.startsWith("Temporal."))return!0;let r=n;return h(r,"toInstant")||h(r,"toPlainDate")||h(r,"toPlainDateTime")||h(r,"toPlainTime")||h(r,"toPlainYearMonth")||h(r,"toPlainMonthDay")||h(r,"toZonedDateTime")||h(r,"toZonedDateTimeISO")||h(r,"withCalendar")||h(r,"withPlainTime")||h(r,"withTimeZone")||h(r,"total")});function to(e){if(e===null)return"null";if(Array.isArray(e))return"array";if(typeof e=="object"){let n=e.constructor;return n&&typeof n.name=="string"&&n.name!=="Object"?`instance of ${n.name}`:"plain object"}return typeof e}function C(e,n,t){if(!n(e))throw new Error(`temporal-fmt: expected a Temporal.${t}, got ${to(e)}.`)}function ro(e){C(e,tn,"object (Instant, PlainDate, PlainTime, PlainDateTime, ZonedDateTime, Duration, PlainYearMonth, or PlainMonthDay)")}function oo(e){C(e,Qe,"Instant")}function ao(e){C(e,Xe,"PlainDate")}function io(e){C(e,qe,"PlainTime")}function so(e){C(e,Ke,"PlainDateTime")}function lo(e){C(e,Je,"ZonedDateTime")}function mo(e){C(e,Ve,"PlainYearMonth")}function uo(e){C(e,en,"PlainMonthDay")}function co(e){C(e,nn,"Duration")}var u={year:["PlainDate","PlainDateTime","ZonedDateTime","PlainYearMonth"],month:["PlainDate","PlainDateTime","ZonedDateTime","PlainYearMonth","PlainMonthDay"],day:["PlainDate","PlainDateTime","ZonedDateTime","PlainMonthDay"],hour:["PlainTime","PlainDateTime","ZonedDateTime","Instant"],minute:["PlainTime","PlainDateTime","ZonedDateTime","Instant"],second:["PlainTime","PlainDateTime","ZonedDateTime","Instant"],millisecond:["PlainTime","PlainDateTime","ZonedDateTime","Instant"],dayOfWeek:["PlainDate","PlainDateTime","ZonedDateTime"],timeZoneId:["ZonedDateTime"],offset:["ZonedDateTime"]},R={yyyy:{meaning:"Four-digit year (preserves sign for BCE; no truncation).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.year,roundTripSafe:!0},yy:{meaning:"Two-digit year (year % 100). Throws on negative years.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.year,roundTripSafe:!1},MMMM:{meaning:'Long month name (locale-aware, e.g. "January", "janvier").',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},MMM:{meaning:'Short month name (locale-aware, e.g. "Jan", "janv.").',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},MM:{meaning:"Two-digit month (01-12, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},M:{meaning:"One- or two-digit month (1-12, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},dd:{meaning:"Two-digit day-of-month (01-31, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!0},d:{meaning:"One- or two-digit day-of-month (1-31, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!0},EEEE:{meaning:'Long weekday name (locale-aware, e.g. "Monday", "lundi"). Parse cross-checks against the parsed date.',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!0},EEE:{meaning:'Short weekday name (locale-aware, e.g. "Mon", "lun."). Parse cross-checks against the parsed date.',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!0},HH:{meaning:"Two-digit hour, 24-hour clock (00-23, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},H:{meaning:"One- or two-digit hour, 24-hour clock (0-23, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},hh:{meaning:"Two-digit hour, 12-hour clock (01-12, zero-padded). Requires `a` token on parse.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},h:{meaning:"One- or two-digit hour, 12-hour clock (1-12, no padding). Requires `a` token on parse.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},mm:{meaning:"Two-digit minute (00-59, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.minute,roundTripSafe:!0},m:{meaning:"One- or two-digit minute (0-59, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.minute,roundTripSafe:!0},ss:{meaning:"Two-digit second (00-59, zero-padded).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.second,roundTripSafe:!0},s:{meaning:"One- or two-digit second (0-59, no padding).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.second,roundTripSafe:!0},S:{meaning:"Fractional second, 1 digit (tenths of a second).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SS:{meaning:"Fractional second, 2 digits (hundredths of a second).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSS:{meaning:"Fractional second, 3 digits (milliseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSS:{meaning:"Fractional second, 4 digits (tens of microseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSS:{meaning:"Fractional second, 5 digits (hundred-thousandths of a second).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSSS:{meaning:"Fractional second, 6 digits (microseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSSSS:{meaning:"Fractional second, 7 digits (tens of nanoseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSSSSS:{meaning:"Fractional second, 8 digits (hundred-millionths of a second).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},SSSSSSSSS:{meaning:"Fractional second, 9 digits (nanoseconds).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.millisecond,roundTripSafe:!0},a:{meaning:'Day period (locale-aware: "AM"/"PM", "\u5348\u524D"/"\u5348\u5F8C", etc.). Required alongside 12-hour tokens on parse.',formatCapable:!0,parseCapable:!0,localeSensitive:!0,calendarSensitive:!1,timezoneSensitive:!1,supportedTypes:u.hour,roundTripSafe:!0},zzz:{meaning:'IANA time zone id (e.g. "America/New_York") or fixed offset ("+05:30"). Requires full date+time on parse.',formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.timeZoneId,roundTripSafe:!0},X:{meaning:"Numeric UTC offset, short (Z for UTC, \xB1HH[MM] otherwise). Minutes omitted when zero.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},XX:{meaning:"Numeric UTC offset, no colon (Z for UTC, \xB1HHMM otherwise).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},XXX:{meaning:"Numeric UTC offset, with colon (Z for UTC, \xB1HH:MM otherwise).",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},x:{meaning:"Numeric UTC offset, short, never Z (always \xB1HH[MM]). Lowercase variant of X.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},xx:{meaning:"Numeric UTC offset, no colon, never Z (always \xB1HHMM). Lowercase variant of XX.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},xxx:{meaning:"Numeric UTC offset, with colon, never Z (always \xB1HH:MM). Lowercase variant of XXX.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.offset,roundTripSafe:!0},do:{meaning:'Ordinal day-of-month with English suffix ("1st", "2nd", "3rd", "4th", ... 21st, 22nd, ...). Format-only \u2014 not parseable.',formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!1},Q:{meaning:"Quarter as a digit (1-4). Derived from month.",formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},QQQ:{meaning:'Quarter with "Q" prefix ("Q1".."Q4"). Derived from month.',formatCapable:!0,parseCapable:!0,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},ww:{meaning:"ISO 8601 week number (01-53). Format-only \u2014 week alone can't reconstruct a date.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!1},RRRR:{meaning:"ISO 8601 week-numbering year (4-digit, may differ from calendar year at year boundaries). Format-only.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!1},D:{meaning:"Day of year, unpadded (1-366). Format-only \u2014 parsing requires resolving against a year.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!1},DD:{meaning:"Day of year, 2-digit minimum (01-366). Format-only.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!1},DDD:{meaning:"Day of year, 3-digit zero-padded (001-366). Format-only.",formatCapable:!0,parseCapable:!1,localeSensitive:!1,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.day,roundTripSafe:!1},LLLL:{meaning:"Stand-alone long month name (nominative case in Slavic locales). Identical to MMMM in most locales.",formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},LLL:{meaning:"Stand-alone short month name. Identical to MMM in most locales.",formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.month,roundTripSafe:!0},cccc:{meaning:"Stand-alone long weekday name. Identical to EEEE in most locales.",formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!0},ccc:{meaning:"Stand-alone short weekday name. Identical to EEE in most locales.",formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.dayOfWeek,roundTripSafe:!0},GGGG:{meaning:'Long era name (locale-aware, e.g. "Anno Domini"/"Before Christ"). Format-only.',formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.year,roundTripSafe:!1},G:{meaning:'Short era name (locale-aware, e.g. "AD"/"BC"). Format-only.',formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!0,timezoneSensitive:!1,supportedTypes:u.year,roundTripSafe:!1},zzzz:{meaning:'Localized long timezone name (e.g. "Eastern Standard Time"). Format-only.',formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.timeZoneId,roundTripSafe:!1},z:{meaning:'Localized short timezone name (e.g. "EST"). Format-only.',formatCapable:!0,parseCapable:!1,localeSensitive:!0,calendarSensitive:!1,timezoneSensitive:!0,supportedTypes:u.timeZoneId,roundTripSafe:!1}},me=Object.keys(R);function fo(e){return q(e)}function rn(){return X.map(([e])=>({name:e,metadata:R[e]}))}function po(e){return R[e]}function W(e){if(e.length>1e3)throw new Error(`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`);let n=q(e),t=[],r=new Set,a=new Set,o=!0,s=!1,d=!1,i=!1,m=!0,l=[],T=0,y=[],f=()=>{y.length>=2&&l.push({code:"AMBIGUOUS_NUMERIC_RUN",message:`Adjacent unpadded numeric tokens "${y.join("")}" with no separator can be ambiguous to parse. Add a separator or use the padded form (e.g. "MM" instead of "M").`}),y.length=0};for(let p of n){if(p.kind==="literal"){T+=p.value.length,f();continue}let E=R[p.value];if(!E){l.push({code:"UNKNOWN_TOKEN_NO_METADATA",message:`Token "${p.value}" is recognized by the tokenizer but has no metadata entry in tokenMetadata.ts \u2014 this is a bug in temporal-fmt.`}),T+=p.value.length;continue}t.push({name:p.value,position:T,metadata:E});let Re=he(p.value);if(Re&&r.add(Re.field),t.length===1)for(let Y of E.supportedTypes)a.add(Y);else{let Y=new Set;for(let B of a)E.supportedTypes.includes(B)&&Y.add(B);a.clear();for(let B of Y)a.add(B)}E.parseCapable||(o=!1,l.push({code:"FORMAT_ONLY_TOKEN",message:`Token "${p.value}" is format-only \u2014 it can't be parsed back into a value. Use a parse-capable variant (e.g. "d" instead of "do") if you need round-trip.`})),E.localeSensitive&&(s=!0),E.calendarSensitive&&(d=!0),E.timezoneSensitive&&(i=!0),E.roundTripSafe||(m=!1),Ae.has(p.value)?y.push(p.value):f(),T+=p.value.length}f();let c=t.map(p=>p.name),g=c.some(p=>p==="hh"||p==="h"),D=c.some(p=>p==="HH"||p==="H"),pn=c.some(p=>p==="a");g&&!pn&&l.push({code:"TWELVE_HOUR_WITHOUT_A",message:`12-hour token ("hh"/"h") used without an "a" (AM/PM) token \u2014 parse() can't tell AM from PM and throws at runtime.`}),g&&D&&l.push({code:"MIXED_12_AND_24_HOUR",message:"Mixing 24-hour and 12-hour tokens \u2014 parse() refuses to guess which is authoritative and throws at runtime."});let Ce=c.some(p=>p==="X"||p==="XX"||p==="XXX"||p==="x"||p==="xx"||p==="xxx"),yn=c.some(p=>p==="zzz");return Ce&&yn&&l.push({code:"ZZZ_WITH_OFFSET_TOKEN",message:`Format string has both "zzz" and an offset token \u2014 parse() cross-checks them and throws if the parsed offset disagrees with the zone's actual offset.`}),Ce&&!r.has("year")&&l.push({code:"OFFSET_WITHOUT_FULL_DATE",message:"Offset token used without a full date \u2014 parse() needs a complete date and time to build a ZonedDateTime and throws at runtime otherwise."}),{tokens:t,requiredFields:[...r].sort(),compatibleTypes:[...a].sort(),parseable:o,localeSensitive:s,calendarSensitive:d,timezoneSensitive:i,ambiguous:l.some(p=>p.code==="AMBIGUOUS_NUMERIC_RUN"),roundTripSafe:m&&o,warnings:l}}function yo(e){let n=W(e),t=[];t.push(`Format string: "${e}"`),t.push(`Tokens (${n.tokens.length}):`);for(let r of n.tokens)t.push(` ${r.name} @${r.position} \u2014 ${r.metadata.meaning}`);if(n.requiredFields.length>0&&t.push(`Required fields: ${n.requiredFields.join(", ")}`),n.compatibleTypes.length>0&&t.push(`Compatible Temporal types: ${n.compatibleTypes.join(", ")}`),t.push(`Parseable: ${n.parseable?"yes":"no"}`),t.push(`Locale-sensitive: ${n.localeSensitive?"yes":"no"}`),t.push(`Calendar-sensitive: ${n.calendarSensitive?"yes":"no"}`),t.push(`Timezone-sensitive: ${n.timezoneSensitive?"yes":"no"}`),t.push(`Ambiguous: ${n.ambiguous?"yes":"no"}`),t.push(`Round-trip safe: ${n.roundTripSafe?"yes":"no"}`),n.warnings.length>0){t.push("Warnings:");for(let r of n.warnings)t.push(` [${r.code}] ${r.message}`)}return t.join(`
27
- `)}function go(e){if(e.length>1e3)return!1;try{return q(e),!0}catch{return!1}}function ho(e){return W(e)}function To(e){return he(e)?.field}function De(e){let n=A();try{if(/^\d{4}-\d{2}-\d{2}T/.test(e)||/T\d{2}:\d{2}/.test(e)){if(/[zZ]$/.test(e)||/[+-]\d{2}:?\d{2}$/.test(e)){let t=e;if(/[zZ]$/.test(t))t=t.slice(0,-1)+"+00:00[UTC]";else{let r=/([+-]\d{2}:?\d{2})$/.exec(t);r&&(t=`${t}[${r[1]}]`)}return n.ZonedDateTime.from(t,{overflow:"reject"})}return n.PlainDateTime.from(e,{overflow:"reject"})}if(/^\d{4}-\d{2}-\d{2}/.test(e))return n.PlainDate.from(e,{overflow:"reject"});if(/^\d{2}:\d{2}/.test(e))return n.PlainTime.from(e);throw new Error(`temporal-fmt: parseISO("${e}") doesn't look like an ISO 8601 string.`)}catch(t){throw new ye({input:e,reason:t.message})}}function on(e){let n=e;if(typeof n?.toString!="function")throw new w({reason:`formatISO() expects a Temporal value with toString(), got ${typeof e}.`});return n.toString()}function wo(e){if(!/^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(\.\d+)?([Zz]|[+-]\d{2}:\d{2})$/.exec(e))throw new w({input:e,reason:"does not match RFC 3339 date-time grammar"});let r=e.replace(/[tT]/,"T").replace(/[zZ]$/,"+00:00[UTC]");return De(r)}function vo(e){let n=on(e);if(!/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$/.test(n))throw new w({input:n,reason:"value did not produce RFC 3339-compliant output"});return n}function bo(e){if(!/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s+)?\d{1,2}\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d{2,4}\s+\d{2}:\d{2}(?::\d{2})?\s+(?:[+-]\d{4}|[A-Za-z]{1,5})$/.test(e.trim()))throw new w({input:e,reason:"not a valid RFC 2822 date"});let t=Date.parse(e);if(Number.isNaN(t))throw new w({input:e,reason:"not a valid RFC 2822 date"});return j().fromEpochMilliseconds(t)}function So(e){let n=e,t;if(typeof n?.toEpochMilliseconds=="function")t=n.toEpochMilliseconds();else if(typeof n?.epochMilliseconds=="number")t=n.epochMilliseconds;else if(typeof n?.toInstant=="function"){let r=n.toInstant();typeof r.epochMilliseconds=="number"&&(t=r.epochMilliseconds)}if(t===void 0)throw new w({reason:`formatRFC2822() expects a value with epochMilliseconds, toEpochMilliseconds(), or toInstant(), got ${typeof e}.`});return ko(t)}function ko(e){try{let t=new Intl.DateTimeFormat("en-US",{weekday:"short",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:"UTC",timeZoneName:"shortOffset",hour12:!1}).formatToParts(new Date(e)),r=i=>t.find(m=>m.type===i)?.value??"",o=r("timeZoneName")?.match(/GMT([+-])(\d+)(?::(\d+))?/),s;if(o){let i=o[1],m=o[2].padStart(2,"0"),l=(o[3]??"0").padStart(2,"0");s=`${i}${m}${l}`;/* c8 ignore start @preserve -- timeZone is hardcoded to 'UTC' above,
28
- which always resolves cleanly, so shortOffset always returns a
29
- parseable "GMT+0"-shaped string in this environment's ICU. This
30
- branch only guards against an ICU build whose shortOffset output
31
- doesn't match the regex; can't trigger it without mocking Intl.
32
- The ignore starts before the closing brace of the if-block so it
33
- covers the whole else-branch node c8 tracks as a single unit. */}else s="+0000";/* c8 ignore stop @preserve */let d=r("hour");/* c8 ignore start @preserve -- hour12:false with a fixed UTC zone
34
- never yields "24" in this environment's ICU (midnight formats as
35
- "00"). Some ICU versions/locales are documented to emit "24" for
36
- hour12:false, so this stays as a defensive normalization; not
37
- reachable here without mocking Intl.DateTimeFormat's output. */d==="24"&&(d="00");/* c8 ignore stop @preserve */return`${r("weekday")}, ${r("day")} ${r("month")} ${r("year")} ${d}:${r("minute")}:${r("second")} ${s}`;/* c8 ignore start @preserve -- Intl.DateTimeFormat is constructed
38
- above with a literal, always-valid timeZone: 'UTC' and no other
39
- user input reaches the constructor or formatToParts call, so this
40
- catch can't be triggered through the public API in a normal Intl
41
- environment (e.g. Node with full-icu). Kept as a genuine fallback
42
- for runtimes with a broken or absent Intl implementation. */}catch{let n=new Date(e),t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],a=t[n.getUTCDay()],o=String(n.getUTCDate()).padStart(2,"0"),s=r[n.getUTCMonth()],d=n.getUTCFullYear(),i=String(n.getUTCHours()).padStart(2,"0"),m=String(n.getUTCMinutes()).padStart(2,"0"),l=String(n.getUTCSeconds()).padStart(2,"0");return`${a}, ${o} ${s} ${d} ${i}:${m}:${l} +0000`}/* c8 ignore stop @preserve */}function Mo(e){let n=e.trim(),t=Date.parse(n);if(Number.isNaN(t))throw new w({input:e,reason:"not a valid HTTP-date"});return j().fromEpochMilliseconds(t)}function Do(e){let n=e?.toInstant?.()??e,t=typeof n=="object"&&n!==null&&"epochMilliseconds"in n?n.epochMilliseconds:(()=>{throw new w({reason:`formatHTTPDate() expects an Instant or ZonedDateTime, got ${typeof e}.`})})(),r=new Date(t),a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],s=a[r.getUTCDay()],d=String(r.getUTCDate()).padStart(2,"0"),i=o[r.getUTCMonth()],m=r.getUTCFullYear(),l=String(r.getUTCHours()).padStart(2,"0"),T=String(r.getUTCMinutes()).padStart(2,"0"),y=String(r.getUTCSeconds()).padStart(2,"0");return`${s}, ${d} ${i} ${m} ${l}:${T}:${y} GMT`}function ue(e){let n=e;if(typeof n?.toInstant=="function"){let t=n.toInstant();return typeof t.epochNanoseconds=="bigint"?{epochMilliseconds:t.epochMilliseconds,epochNanoseconds:t.epochNanoseconds}:{epochMilliseconds:t.epochMilliseconds,epochNanoseconds:BigInt(t.epochMilliseconds)*1000000n}}if(typeof n?.epochNanoseconds=="bigint")return{epochMilliseconds:Number(n.epochNanoseconds/1000000n),epochNanoseconds:n.epochNanoseconds};if(typeof n?.epochMilliseconds=="number")return{epochMilliseconds:n.epochMilliseconds,epochNanoseconds:BigInt(n.epochMilliseconds)*1000000n};throw new w({reason:`expected an Instant or ZonedDateTime, got ${typeof e}.`})}function j(){let e=A().Instant;if(!e)throw new Error("temporal-fmt: Temporal.Instant is not available in this implementation.");return e}function Eo(e){return ue(e).epochMilliseconds/1e3}function xo(e){return j().fromEpochMilliseconds(e*1e3)}function Co(e){return j().fromEpochMilliseconds(e)}function Ro(e){return j().fromEpochNanoseconds(BigInt(e)*1000n)}function Fo(e){return j().fromEpochNanoseconds(e)}function $o(e){return ue(e).epochMilliseconds}function Io(e){let{epochNanoseconds:n}=ue(e);return Number(n/1000n)}function Ao(e){return ue(e).epochNanoseconds}function Oo(e){let n=e.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(n))return K("yyyy-MM-dd",n);if(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(n))return K("yyyy-MM-dd HH:mm:ss",n);if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(n))return De(n);throw new w({input:e,reason:"not a recognized SQL date/time format"})}function Po(e){return typeof e?.hour=="number"?L(e,"yyyy-MM-dd HH:mm:ss"):L(e,"yyyy-MM-dd")}var an={locale:_,numberingSystem:"latn",firstDayOfWeek:1,roundingMode:"nearest",disambiguation:"compatible",overflow:"reject",parseLenient:!1,durationShowZeroValues:!1};function zo(e={}){let n={...an,...e};if(typeof n.locale!="string"||n.locale.length===0)throw new Error(`temporal-fmt: config.locale must be a non-empty string (got ${String(n.locale)}).`);if(n.firstDayOfWeek!==1&&n.firstDayOfWeek!==7)throw new Error(`temporal-fmt: config.firstDayOfWeek must be 1 (Monday) or 7 (Sunday) (got ${n.firstDayOfWeek}).`);if(!["nearest","floor","ceil","trunc"].includes(n.roundingMode))throw new Error(`temporal-fmt: config.roundingMode "${n.roundingMode}" is not recognized.`);if(!["compatible","earlier","later","reject"].includes(n.disambiguation))throw new Error(`temporal-fmt: config.disambiguation "${n.disambiguation}" is not recognized.`);if(!["constrain","reject"].includes(n.overflow))throw new Error(`temporal-fmt: config.overflow "${n.overflow}" is not recognized.`);return Object.freeze(n)}function No(e,n){if(!e)return n;let t={...n};return t.locale===void 0&&(t.locale=e.locale),t.calendar===void 0&&e.calendar!==void 0&&(t.calendar=e.calendar),t.timezone===void 0&&e.timezone!==void 0&&(t.timezone=e.timezone),t.numberingSystem===void 0&&(t.numberingSystem=e.numberingSystem),t.lenient===void 0&&e.parseLenient&&(t.lenient=!0),t}function _o(e={}){let n=new Set(e.weekend??[6,7]),t={...e.workingHours??{}};for(let r=1;r<=7;r++)t[r]===void 0&&(t[r]=n.has(r)?0:8);return{weekend:n,holidays:e.holidays,workingHours:t,halfDays:new Set(e.halfDays??[])}}function ce(e,n){let t=n,r=t.dayOfWeek;if(typeof t.year=="number"&&typeof t.month=="number"&&typeof t.day=="number"){let o=new Date(Date.UTC(t.year,t.month-1,t.day)).getUTCDay();r=o===0?7:o}if(typeof r!="number")throw new Error("temporal-fmt: isBusinessDay() needs a value with dayOfWeek (or year/month/day to compute it).");return!(e.weekend.has(r)||e.holidays&&e.holidays.isHoliday(n))}function ln(e,n){let t=v(n,1,"days");for(let r=0;r<14;r++){if(ce(e,t))return t;t=v(t,1,"days")}throw new Error("temporal-fmt: nextBusinessDay() gave up after 14 days \u2014 likely a misconfigured calendar (e.g. all days are weekends or holidays).")}function mn(e,n){let t=v(n,-1,"days");for(let r=0;r<14;r++){if(ce(e,t))return t;t=v(t,-1,"days")}throw new Error("temporal-fmt: previousBusinessDay() gave up after 14 days \u2014 likely a misconfigured calendar.")}var de=1e5;function un(e){if(!Number.isSafeInteger(e))throw new RangeError(`temporal-fmt: business-day count must be a finite safe integer (got ${e}).`)}function sn(e,n){let t=e,r=n,a=t.year*1e4+t.month*100+t.day,o=r.year*1e4+r.month*100+r.day;return a-o}function dn(e,n,t){if(un(t),t===0)return n;let r=t>0?1:-1,a=Math.abs(t);if(a>de)throw new RangeError(`temporal-fmt: addBusinessDays() exceeded the ${de}-day limit.`);let o=n;for(let s=0;s<a;s++)o=r>0?ln(e,o):mn(e,o);return o}function Lo(e,n,t){return un(t),dn(e,n,-t)}function Ho(e,n,t){let r=sn(t,n);if(r===0)return 0;let a=r>0?1:-1,o=n,s=0,d=0;for(;sn(o,t)!==0;){if(o=v(o,a,"days"),d++,d>de)throw new RangeError(`temporal-fmt: differenceInBusinessDays() exceeded the ${de}-day traversal limit.`);ce(e,o)&&(s+=a)}return s}var cn=5e3;function Uo(e){let n=new Map;function t(r){let a=n.get(r);return a||(a=e.map(o=>{let s;return o.compute?s=o.compute(r):s={month:o.month,day:o.day},{...s,name:o.name}}),n.set(r,a),a)}return{isHoliday(r){let a=r;if(typeof a.year!="number"||typeof a.month!="number"||typeof a.day!="number")throw new Error("temporal-fmt: isHoliday() needs a value with year/month/day.");return t(a.year).some(s=>s.month===a.month&&s.day===a.day)},holidaysBetween(r,a){let o=r,s=a;if(typeof o?.year!="number"||typeof s?.year!="number")throw new Error("temporal-fmt: holidaysBetween() needs start/end values with year/month/day.");if(s.year-o.year>cn)throw new RangeError(`temporal-fmt: holidaysBetween() year range (${o.year}\u2013${s.year}) exceeds the ${cn}-year limit. Split the query into smaller ranges.`);let d=[];for(let i=o.year;i<=s.year;i++){let m=t(i);for(let l of m){let T={year:i,month:l.month,day:l.day};J(T,o)>=0&&J(T,s)<=0&&d.push({year:i,month:l.month,day:l.day})}}return d}}}function jo(e,n){let t=v(n,1,"days");for(let r=0;r<365*5;r++){if(e.isHoliday(t))return t;t=v(t,1,"days")}}function Go(e,n){let t=v(n,-1,"days");for(let r=0;r<365*5;r++){if(e.isHoliday(t))return t;t=v(t,-1,"days")}}function Zo(e,n,t){return e.holidaysBetween(n,t)}function Wo(e={}){let n=[...X],t=new Set;for(let i of e.tokens??[])t.add(i.name);for(let i of e.tokens??[]){let m=n.findIndex(([l])=>l===i.name);m>=0?n[m]=[i.name,i.handler,i.field]:n.push([i.name,i.handler,i.field])}n.sort((i,m)=>m[0].length-i[0].length);let r=new Map(n.map(([i,m,l])=>[i,{handler:m,field:l}])),a=n.map(([i])=>i);function o(i){let m=[],l=0;for(;l<i.length;){let T=i[l];if(T==="'"){if(i[l+1]==="'"){s(m,"'"),l+=2;continue}let f=l+1,c="",g=!1;for(;f<i.length;){if(i[f]==="'"){if(i[f+1]==="'"){c+="'",f+=2;continue}g=!0,f+=1;break}c+=i[f],f+=1}if(!g)throw new Error(`temporal-fmt: unterminated quote in format string "${i}"`);s(m,c),l=f;continue}let y=a.find(f=>i.startsWith(f,l));if(y){let f=y[y.length-1];if(i[l+y.length]===f){let c=l+y.length;for(;i[c]===f;)c+=1;throw new pe({token:i.slice(l,c),format:i,message:`temporal-fmt: "${i.slice(l,c)}" in format string "${i}" isn't a recognized token \u2014 did you mean "${y}"?`})}m.push({kind:"token",value:y}),l+=y.length;continue}s(m,T),l+=1}return m}function s(i,m){let l=i[i.length-1];l&&l.kind==="literal"?l.value+=m:i.push({kind:"literal",value:m})}let d=e.defaultLocale??_;return{format(i,m,l={}){if(m.length>1e3)throw new Error(`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${m.length}).`);let T=l.locale??d,y=o(m),f="";for(let c of y){if(c.kind==="literal"){f+=c.value;continue}let g=r.get(c.value);/* c8 ignore start @preserve -- unreachable: customTokenize only ever produces a
43
- `kind: 'token'` piece via sortedTokenStrings.find(...), and
44
- handlerByToken is built from that same mergedTokens array, so
45
- every token piece is guaranteed a handler entry. Guards against a
46
- future customTokenize change that decouples the two lookups. */if(!g)throw new Error(`temporal-fmt: unknown token "${c.value}"`);/* c8 ignore stop @preserve */if(i[g.field]===void 0)throw new Error(`temporal-fmt: token "${c.value}" requires "${String(g.field)}", which this Temporal object doesn't have.`);f+=g.handler(i,T)}return f},formatToParts(i,m,l={}){if(m.length>1e3)throw new Error(`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${m.length}).`);let T=l.locale??d,y=o(m),f=[];for(let c of y){if(c.kind==="literal"){let D=f[f.length-1];/* c8 ignore start @preserve -- unreachable: customTokenize's own
47
- appendLiteral() already merges adjacent literal chars/quoted
48
- spans into a single piece before this loop ever sees them, so
49
- two literal pieces are never adjacent here. Kept as a guard
50
- against a future customTokenize change that stops merging. */D&&D.type==="literal"?D.value+=c.value:f.push({type:"literal",value:c.value});continue}let g=r.get(c.value);/* c8 ignore start @preserve -- unreachable: customTokenize only emits
51
- kind:'token' pieces found in sortedTokenStrings, the same array
52
- handlerByToken is built from, so every token piece is guaranteed
53
- a handler entry. Guards against future decoupling of the two. */if(!g)throw new Error(`temporal-fmt: unknown token "${c.value}"`);/* c8 ignore stop @preserve */if(i[g.field]===void 0)throw new Error(`temporal-fmt: token "${c.value}" requires "${String(g.field)}".`);f.push({type:"token",value:g.handler(i,T),token:c.value})}return f},compileFormat(i){if(i.length>1e3)throw new Error(`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${i.length}).`);let m=o(i);return{formatStr:i,pieces:m.map(l=>l),format(l,T={}){let y=T.locale??d,f="";for(let c of m){if(c.kind==="literal"){f+=c.value;continue}let g=r.get(c.value);/* c8 ignore start @preserve -- unreachable, see the same guard's comment
54
- above in the un-compiled format(). */if(!g)throw new Error(`temporal-fmt: unknown token "${c.value}"`);/* c8 ignore stop @preserve */if(l[g.field]===void 0)throw new Error(`temporal-fmt: token "${c.value}" requires "${String(g.field)}".`);f+=g.handler(l,y)}return f},formatToParts(l,T={}){let y=T.locale??d,f=[];for(let c of m){if(c.kind==="literal"){let D=f[f.length-1];/* c8 ignore start @preserve -- unreachable, see the same guard's
55
- comment above in the un-compiled formatToParts. */D&&D.type==="literal"?D.value+=c.value:f.push({type:"literal",value:c.value});continue}let g=r.get(c.value);/* c8 ignore start @preserve -- unreachable, see the same guard's
56
- comment above in the un-compiled formatToParts. */if(!g)throw new Error(`temporal-fmt: unknown token "${c.value}"`);/* c8 ignore stop @preserve */if(l[g.field]===void 0)throw new Error(`temporal-fmt: token "${c.value}" requires "${String(g.field)}".`);f.push({type:"token",value:g.handler(l,y),token:c.value})}return f}}}}}function Yo(e){return/^y+$/.test(e)?"Year":/^[ML]+$/.test(e)?"Month":/^[decD]+$/.test(e)?"Day":/^[Ec]+$/.test(e)?"Weekday":/^[Qq]+$/.test(e)?"Quarter":/^[Gg]+$/.test(e)?"Era":/^[Hh]+$/.test(e)?"Hour":/^m+$/.test(e)?"Minute":/^s+$/.test(e)?"Second":/^S+$/.test(e)?"Fractional Second":e==="a"?"Day Period":e==="zzz"?"Time Zone":/^[Xx]+$/.test(e)?"UTC Offset":e==="do"?"Ordinal Day":e==="ww"||e==="RRRR"?"ISO Week":"Other"}function Bo(){return me.map(e=>{let n=R[e];return{label:e,detail:n.meaning,documentation:[n.meaning,"",`Format-capable: ${n.formatCapable}`,`Parse-capable: ${n.parseCapable}`,`Locale-sensitive: ${n.localeSensitive}`,`Calendar-sensitive: ${n.calendarSensitive}`,`Timezone-sensitive: ${n.timezoneSensitive}`,`Round-trip safe: ${n.roundTripSafe}`,`Supported types: ${n.supportedTypes.join(", ")}`].join(`
57
- `),family:Yo(e)}})}function Xo(){let e={};for(let n of me){let t=R[n];e[n]={signature:n,summary:t.meaning,details:[`Format-capable: ${t.formatCapable?"yes":"no"}`,`Parse-capable: ${t.parseCapable?"yes":"no"}`,`Locale-sensitive: ${t.localeSensitive?"yes":"no"}`,`Calendar-sensitive: ${t.calendarSensitive?"yes":"no"}`,`Timezone-sensitive: ${t.timezoneSensitive?"yes":"no"}`,`Round-trip safe: ${t.roundTripSafe?"yes":"no"}`,`Supported types: ${t.supportedTypes.join(", ")}`].join(`
58
- `)}}return e}function qo(e){let n=W(e),t=[];for(let r of n.warnings){let a=r.message,o;r.code==="TWELVE_HOUR_WITHOUT_A"?o='Add an "a" token (e.g. "h:mm a") or use "H:mm" for 24-hour.':r.code==="MIXED_12_AND_24_HOUR"?o='Pick one form: "HH:mm" for 24-hour or "h:mm a" for 12-hour.':r.code==="AMBIGUOUS_NUMERIC_RUN"?o='Add a separator or use padded forms (e.g. "MM" instead of "M").':r.code==="FORMAT_ONLY_TOKEN"&&(o='Use a parse-capable variant (e.g. "d" instead of "do").'),t.push({startColumn:0,endColumn:e.length,severity:"warning",message:a,code:r.code,suggestion:o})}return t}var Ee=[{from:"YYYY",to:"yyyy"},{from:"YY",to:"yy"},{from:"MMMM",to:"MMMM"},{from:"MMM",to:"MMM"},{from:"MM",to:"MM"},{from:"M",to:"M"},{from:"DD",to:"dd"},{from:"D",to:"d"},{from:"Do",to:null,notes:`Ordinal day (AdvancedFormat) \u2014 use temporal-fmt's own "do" token instead.`},{from:"dddd",to:"EEEE"},{from:"ddd",to:"EEE"},{from:"dd",to:null,notes:'Min-name weekday (e.g. "Tu") \u2014 temporal-fmt has no equivalent width.'},{from:"d",to:null,notes:'Numeric weekday (0-6) \u2014 no temporal-fmt equivalent; not the same as "d" here, which is day-of-month.'},{from:"HH",to:"HH"},{from:"H",to:"H"},{from:"hh",to:"hh"},{from:"h",to:"h"},{from:"kk",to:null,notes:"Hour 1-24 (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"k",to:null,notes:"Hour 1-24 (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"mm",to:"mm"},{from:"m",to:"m"},{from:"ss",to:"ss"},{from:"s",to:"s"},{from:"SSS",to:"SSS"},{from:"A",to:"a",notes:"Uppercase AM/PM in Day.js \u2014 temporal-fmt is always lowercase."},{from:"a",to:"a"},{from:"ZZ",to:"XX",notes:"Numeric UTC offset, no colon."},{from:"Z",to:"XXX",notes:"Numeric UTC offset with colon."},{from:"X",to:null,notes:"Unix timestamp (seconds) \u2014 use fromUnixSeconds() instead."},{from:"x",to:null,notes:"Unix timestamp (ms) \u2014 use fromUnixMilliseconds() instead."},{from:"Qo",to:null,notes:"Ordinal quarter (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"Q",to:"Q"},{from:"Mo",to:null,notes:"Ordinal month (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"ww",to:"ww"},{from:"wo",to:null,notes:"Ordinal ISO week (AdvancedFormat) \u2014 no temporal-fmt equivalent."},{from:"w",to:null,notes:`Unpadded ISO week \u2014 temporal-fmt's "ww" is always 2-digit.`},{from:"gggg",to:"RRRR",notes:"Week-numbering year, not the calendar year \u2014 same caveat as temporal-fmt's RRRR."},{from:"L",to:null,notes:"Localized date format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LL",to:null,notes:"Localized date format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LLL",to:null,notes:"Localized date format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LLLL",to:null,notes:"Localized date format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LT",to:null,notes:"Localized time format (AdvancedFormat) \u2014 write the format string out explicitly."},{from:"LTS",to:null,notes:"Localized time format (AdvancedFormat) \u2014 write the format string out explicitly."}],xe=[{from:"yyyy",to:"yyyy"},{from:"yy",to:"yy"},{from:"y",to:null,notes:'Unpadded calendar year, opt-in via useAdditionalWeekYearTokens \u2014 temporal-fmt has no unpadded-year token; use "yyyy".'},{from:"MMMM",to:"MMMM"},{from:"MMM",to:"MMM"},{from:"MM",to:"MM"},{from:"M",to:"M"},{from:"LLLL",to:"LLLL"},{from:"LLL",to:"LLL"},{from:"dd",to:"dd"},{from:"d",to:"d"},{from:"do",to:"do"},{from:"DDD",to:"DDD"},{from:"DD",to:"DD"},{from:"D",to:"D",notes:`Day-of-year, opt-in via useAdditionalDayOfYearTokens \u2014 matches temporal-fmt's own "D" already.`},{from:"EEEE",to:"EEEE"},{from:"EEE",to:"EEE"},{from:"eeee",to:null,notes:"Locale-aware numeric weekday \u2014 no temporal-fmt equivalent."},{from:"cccc",to:"cccc"},{from:"ccc",to:"ccc"},{from:"HH",to:"HH"},{from:"H",to:"H"},{from:"hh",to:"hh"},{from:"h",to:"h"},{from:"mm",to:"mm"},{from:"m",to:"m"},{from:"ss",to:"ss"},{from:"s",to:"s"},{from:"SSS",to:"SSS"},{from:"a",to:"a"},{from:"aaa",to:"a"},{from:"XXX",to:"XXX"},{from:"XX",to:"XX"},{from:"X",to:"X",notes:`Opt-in via useAdditionalDayOfYearTokens-adjacent rules in date-fns v3+; matches temporal-fmt's own "X" already.`},{from:"xxx",to:"xxx"},{from:"xx",to:"xx"},{from:"x",to:"x"},{from:"zzzz",to:"zzzz"},{from:"zzz",to:"zzz"},{from:"z",to:"z"},{from:"QQQ",to:"QQQ"},{from:"Q",to:"Q"},{from:"GGGG",to:"GGGG"},{from:"GGG",to:null,notes:'Abbreviated era \u2014 temporal-fmt only has "G" (short) and "GGGG" (long).'},{from:"GG",to:null,notes:'Abbreviated era \u2014 temporal-fmt only has "G" (short) and "GGGG" (long).'},{from:"G",to:"G"},{from:"ww",to:"ww"},{from:"w",to:null,notes:`Unpadded local week number \u2014 temporal-fmt's "ww" is ISO-week and always 2-digit.`},{from:"RRRR",to:"RRRR"},{from:"R",to:null,notes:`Unpadded ISO week-numbering year \u2014 temporal-fmt's "RRRR" is always 4-digit.`},{from:"Y",to:null,notes:'Week-numbering year (locale week rules), opt-in \u2014 no temporal-fmt equivalent; "RRRR" is ISO week-numbering, a different rule set.'},{from:"PPPP",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"PPP",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"PP",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"P",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"pppp",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"ppp",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"pp",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."},{from:"p",to:null,notes:"Localized composite format \u2014 write the format string out explicitly."}];function Ko(e,n){return L(n??{year:2026,month:8,day:4,hour:15,minute:45,second:30,millisecond:123,dayOfWeek:2,timeZoneId:"UTC",offset:"+00:00",calendarId:"iso8601"},e,{locale:"en-US"})}function Jo(e){return"README.md#token-reference"}function Qo(e){let n=[],t=0;for(;t<e.length;)if(e[t]==="["){let r=e.indexOf("]",t+1);if(r===-1){n.push({kind:"token",value:e.slice(t)});break}n.push({kind:"literal",value:e.slice(t+1,r)}),t=r+1}else{let r=t;for(;r<e.length&&e[r]!=="[";)r+=1;n.push({kind:"token",value:e.slice(t,r)}),t=r}return n}function Vo(e,n){let t=[],r=0;for(;r<e.length;){let a=n.find(s=>e.startsWith(s,r));if(a){t.push({kind:"token",value:a}),r+=a.length;continue}let o=t[t.length-1];o&&o.kind==="literal"?o.value+=e[r]:t.push({kind:"literal",value:e[r]}),r+=1}return t}function fn(e,n,t){let r=new Map(n.map(d=>[d.from,d.to])),a=[...r.keys()].sort((d,i)=>i.length-d.length),o=Qo(e),s="";for(let d of o){if(d.kind==="literal"){s+=`'${d.value.replace(/'/g,"''")}'`;continue}for(let i of Vo(d.value,a))if(i.kind==="token"){let m=r.get(i.value);if(m==null)throw new Error(`temporal-fmt: "${i.value}" has no ${t} -> temporal-fmt mapping (in format string "${e}"). Write the equivalent temporal-fmt token in by hand, or wrap it in brackets if it was meant as literal text.`);s+=m}else/[a-zA-Z]/.test(i.value)?s+=`'${i.value.replace(/'/g,"''")}'`:s+=i.value}return s}function ea(e){return fn(e,Ee,"Day.js")}function na(e){return fn(e,xe,"date-fns")}export{me as ALL_TOKEN_NAMES,zn as AmbiguousInputError,xe as DATE_FNS_TO_TEMPORAL_FMT,Ee as DAYJS_TO_TEMPORAL_FMT,an as DEFAULT_CONFIG,st as FORMAT_ONLY_TOKENS,w as FormatSyntaxError,Pn as InvalidCalendarError,ye as InvalidDateError,Nn as InvalidDurationError,ge as InvalidLocaleError,An as InvalidOffsetError,In as InvalidTimeError,On as InvalidTimeZoneError,$n as ParseMismatchError,et as SUPPORTED_NUMBERING_SYSTEMS,R as TOKEN_METADATA,Fn as TemporalFmtError,pe as UnknownTokenError,v as add,dn as addBusinessDays,gt as addDays,Jn as addDuration,ht as addHours,vt as addMilliseconds,Tt as addMinutes,pt as addMonths,wt as addSeconds,yt as addWeeks,ft as addYears,W as analyzeFormat,rt as applyNumbering,ot as applyParseNumbering,Rn as asDateFieldView,co as assertDuration,oo as assertInstant,ao as assertPlainDate,so as assertPlainDateTime,uo as assertPlainMonthDay,io as assertPlainTime,mo as assertPlainYearMonth,ro as assertTemporal,lo as assertZonedDateTime,Xn as balanceDuration,kr as between,Hn as ceil,Gt as clamp,J as compare,Kn as compareDuration,it as compileFormat,dt as compileParser,nt as convertDigits,tt as convertDigitsToAscii,_o as createBusinessCalendar,zo as createConfig,Wo as createFormatter,Uo as createHolidayCalendar,bn as dayOfYear,gn as daysInMonth,hn as daysInYear,Rt as difference,Ho as differenceInBusinessDays,At as differenceInDays,Ot as differenceInHours,Nt as differenceInMilliseconds,Pt as differenceInMinutes,$t as differenceInMonths,zt as differenceInSeconds,It as differenceInWeeks,Ft as differenceInYears,Cn as endOf,yo as explainFormat,To as fieldForToken,Ln as floor,L as format,ze as formatDistance,Ur as formatDistanceToNow,Gn as formatDuration,Zn as formatDurationToParts,Do as formatHTTPDate,on as formatISO,Yn as formatISODuration,So as formatRFC2822,vo as formatRFC3339,Dr as formatRRule,Tr as formatRange,wr as formatRangeToParts,nr as formatRelative,tr as formatRelativeToNow,Po as formatSQL,at as formatToParts,Ro as fromUnixMicroseconds,Co as fromUnixMilliseconds,Fo as fromUnixNanoseconds,xo as fromUnixSeconds,Bo as getAutocompleteData,Jo as getDocUrl,Xo as getHoverDocs,qo as getInlineDiagnostics,or as getLocale,Dn as getMonth,$r as getNextTransition,Cr as getOffset,Rr as getOffsetNanoseconds,Ir as getPreviousTransition,Mn as getQuarter,xr as getTimeZone,Ar as getTransitions,En as getWeekday,ar as hasLocale,Zo as holidaysBetween,cr as intersection,mr as intersects,ir as interval,sr as intervalContains,pr as intervalDifference,dr as intervalIsAfter,ur as intervalIsBefore,yr as intervalSubtract,Ht as isAfter,Lt as isBefore,Zt as isBetween,ce as isBusinessDay,Fr as isDST,nn as isDuration,_t as isEqual,Qe as isInstant,vn as isLeapMonth,wn as isLeapYear,Xe as isPlainDate,Ke as isPlainDateTime,en as isPlainMonthDay,qe as isPlainTime,Ve as isPlainYearMonth,Wt as isSameDay,Kt as isSameMonth,Jt as isSameQuarter,qt as isSameWeek,Qt as isSameYear,tn as isTemporal,Yt as isToday,Bt as isTomorrow,go as isValidFormat,er as isWeekday,Vt as isWeekend,Xt as isYesterday,Je as isZonedDateTime,Zr as listRegisteredGrammars,rn as listTokens,jt as max,gr as mergeIntervals,No as mergeWithConfig,Ut as min,Tn as monthsInYear,ln as nextBusinessDay,jo as nextHoliday,lr as overlaps,K as parse,Bn as parseDuration,Mo as parseHTTPDate,De as parseISO,Wn as parseISODuration,bo as parseRFC2822,wo as parseRFC3339,Mr as parseRRule,no as parseRelative,Oo as parseSQL,ut as parseToParts,Or as possibleInstantsFor,Ko as previewFormat,mn as previousBusinessDay,Go as previousHoliday,vr as recurrence,rr as registerLocale,jn as registerLocaleVocab,Gr as registerRelativeGrammar,Er as resolveZoned,_n as round,$e as roundDuration,$e as roundDurationAlias,lt as safeParse,Vn as setTemporal,Sr as skip,hr as splitInterval,xn as startOf,ct as subtract,Lo as subtractBusinessDays,Mt as subtractDays,Qn as subtractDuration,Dt as subtractHours,Ct as subtractMilliseconds,Et as subtractMinutes,St as subtractMonths,xt as subtractSeconds,kt as subtractWeeks,bt as subtractYears,br as take,Io as toUnixMicroseconds,$o as toUnixMilliseconds,Ao as toUnixNanoseconds,Eo as toUnixSeconds,po as tokenInfo,fo as tokenizeFormat,qn as totalDuration,na as translateDateFnsFormatString,ea as translateDayjsFormatString,Un as truncate,mt as tryParse,fr as union,ho as validateFormat,Sn as weekOfYear,kn as weekYear};
1
+ import {
2
+ formatRelative,
3
+ formatRelativeToNow
4
+ } from "./chunk-GPB4JHGI.js";
5
+ import {
6
+ ALL_TOKEN_NAMES,
7
+ DATE_FNS_TO_TEMPORAL_FMT,
8
+ DAYJS_TO_TEMPORAL_FMT,
9
+ DEFAULT_CONFIG,
10
+ OverrideConflictError,
11
+ TOKEN_METADATA,
12
+ addBusinessDays,
13
+ analyzeFormat,
14
+ contains,
15
+ createHolidayCalendar,
16
+ difference,
17
+ differenceInBusinessDays,
18
+ formatHTTPDate,
19
+ formatISO,
20
+ formatRFC2822,
21
+ formatRange,
22
+ fromUnixMilliseconds,
23
+ fromUnixSeconds,
24
+ getBalanceDurationImpl,
25
+ getBetweenImpl,
26
+ getCeilImpl,
27
+ getClampImpl,
28
+ getCompareDurationImpl,
29
+ getCompileFormatImpl,
30
+ getCompileParserImpl,
31
+ getCreateBusinessCalendarImpl,
32
+ getCreateConfigImpl,
33
+ getExplainFormatImpl,
34
+ getFieldForTokenImpl,
35
+ getFloorImpl,
36
+ getFormatDurationToPartsImpl,
37
+ getFormatISODurationImpl,
38
+ getFormatImpl,
39
+ getFormatRFC3339Impl,
40
+ getFormatRRuleImpl,
41
+ getFormatRangeToPartsImpl,
42
+ getFormatSQLImpl,
43
+ getFromUnixMicrosecondsImpl,
44
+ getFromUnixNanosecondsImpl,
45
+ getGetAutocompleteDataImpl,
46
+ getGetDocUrlImpl,
47
+ getGetHoverDocsImpl,
48
+ getGetInlineDiagnosticsImpl,
49
+ getGetLocaleImpl,
50
+ getGetMonthImpl,
51
+ getGetNextTransitionImpl,
52
+ getGetPreviousTransitionImpl,
53
+ getGetWeekdayImpl,
54
+ getHasLocaleImpl,
55
+ getIntersectionImpl,
56
+ getIntervalImpl,
57
+ getIsAfterImpl,
58
+ getIsBeforeImpl,
59
+ getIsBetweenImpl,
60
+ getIsEqualImpl,
61
+ getIsLeapMonthImpl,
62
+ getIsLeapYearImpl,
63
+ getIsSameDayImpl,
64
+ getIsSameMonthImpl,
65
+ getIsSameQuarterImpl,
66
+ getIsSameWeekImpl,
67
+ getIsSameYearImpl,
68
+ getIsTodayImpl,
69
+ getIsTomorrowImpl,
70
+ getIsValidFormatImpl,
71
+ getIsWeekdayImpl,
72
+ getIsYesterdayImpl,
73
+ getListRegisteredGrammarsImpl,
74
+ getListTokensImpl,
75
+ getMergeIntervalsImpl,
76
+ getMergeWithConfigImpl,
77
+ getMonthsInYearImpl,
78
+ getNextHolidayImpl,
79
+ getOverlapsImpl,
80
+ getParseDurationImpl,
81
+ getParseHTTPDateImpl,
82
+ getParseISODurationImpl,
83
+ getParseImpl,
84
+ getParseRFC2822Impl,
85
+ getParseRFC3339Impl,
86
+ getParseRRuleImpl,
87
+ getParseRelativeImpl,
88
+ getParseSQLImpl,
89
+ getPossibleInstantsForImpl,
90
+ getPreviewFormatImpl,
91
+ getPreviousHolidayImpl,
92
+ getResolveZonedImpl,
93
+ getSubtractBusinessDaysImpl,
94
+ getSubtractDurationImpl,
95
+ getToUnixMicrosecondsImpl,
96
+ getToUnixMillisecondsImpl,
97
+ getToUnixNanosecondsImpl,
98
+ getToUnixSecondsImpl,
99
+ getTokenInfoImpl,
100
+ getTokenizeFormatImpl,
101
+ getTranslateDateFnsFormatStringImpl,
102
+ getTruncateImpl,
103
+ getUnionImpl,
104
+ getValidateFormatImpl,
105
+ getWeekOfYearImpl,
106
+ getWeekYearImpl,
107
+ holidaysBetween,
108
+ intersects,
109
+ isAfter,
110
+ isBefore,
111
+ isBusinessDay,
112
+ nextBusinessDay,
113
+ parseISO,
114
+ previousBusinessDay,
115
+ registerRelativeGrammar,
116
+ setBalanceDurationOverride,
117
+ setBetweenOverride,
118
+ setCeilOverride,
119
+ setClampOverride,
120
+ setCompareDurationOverride,
121
+ setCompileFormatOverride,
122
+ setCompileParserOverride,
123
+ setCreateBusinessCalendarOverride,
124
+ setCreateConfigOverride,
125
+ setExplainFormatOverride,
126
+ setFieldForTokenOverride,
127
+ setFloorOverride,
128
+ setFormatDurationToPartsOverride,
129
+ setFormatISODurationOverride,
130
+ setFormatOverride,
131
+ setFormatRFC3339Override,
132
+ setFormatRRuleOverride,
133
+ setFormatRangeToPartsOverride,
134
+ setFormatSQLOverride,
135
+ setFromUnixMicrosecondsOverride,
136
+ setFromUnixNanosecondsOverride,
137
+ setGetAutocompleteDataOverride,
138
+ setGetDocUrlOverride,
139
+ setGetHoverDocsOverride,
140
+ setGetInlineDiagnosticsOverride,
141
+ setGetLocaleOverride,
142
+ setGetMonthOverride,
143
+ setGetNextTransitionOverride,
144
+ setGetPreviousTransitionOverride,
145
+ setGetWeekdayOverride,
146
+ setHasLocaleOverride,
147
+ setIntersectionOverride,
148
+ setIntervalOverride,
149
+ setIsAfterOverride,
150
+ setIsBeforeOverride,
151
+ setIsBetweenOverride,
152
+ setIsEqualOverride,
153
+ setIsLeapMonthOverride,
154
+ setIsLeapYearOverride,
155
+ setIsSameDayOverride,
156
+ setIsSameMonthOverride,
157
+ setIsSameQuarterOverride,
158
+ setIsSameWeekOverride,
159
+ setIsSameYearOverride,
160
+ setIsTodayOverride,
161
+ setIsTomorrowOverride,
162
+ setIsValidFormatOverride,
163
+ setIsWeekdayOverride,
164
+ setIsYesterdayOverride,
165
+ setListRegisteredGrammarsOverride,
166
+ setListTokensOverride,
167
+ setMergeIntervalsOverride,
168
+ setMergeWithConfigOverride,
169
+ setMonthsInYearOverride,
170
+ setNextHolidayOverride,
171
+ setOverlapsOverride,
172
+ setParseDurationOverride,
173
+ setParseHTTPDateOverride,
174
+ setParseISODurationOverride,
175
+ setParseOverride,
176
+ setParseRFC2822Override,
177
+ setParseRFC3339Override,
178
+ setParseRRuleOverride,
179
+ setParseRelativeOverride,
180
+ setParseSQLOverride,
181
+ setPossibleInstantsForOverride,
182
+ setPreviewFormatOverride,
183
+ setPreviousHolidayOverride,
184
+ setResolveZonedOverride,
185
+ setSubtractBusinessDaysOverride,
186
+ setSubtractDurationOverride,
187
+ setToUnixMicrosecondsOverride,
188
+ setToUnixMillisecondsOverride,
189
+ setToUnixNanosecondsOverride,
190
+ setToUnixSecondsOverride,
191
+ setTokenInfoOverride,
192
+ setTokenizeFormatOverride,
193
+ setTranslateDateFnsFormatStringOverride,
194
+ setTruncateOverride,
195
+ setUnionOverride,
196
+ setValidateFormatOverride,
197
+ setWeekOfYearOverride,
198
+ setWeekYearOverride,
199
+ splitInterval,
200
+ subtract,
201
+ translateDayjsFormatString
202
+ } from "./chunk-FBPHNRVW.js";
203
+ import {
204
+ getOffset,
205
+ getOffsetNanoseconds,
206
+ getTimeZone,
207
+ getTransitions,
208
+ isDST
209
+ } from "./chunk-H7YQX25T.js";
210
+ import {
211
+ addDuration,
212
+ formatDuration,
213
+ round,
214
+ roundDuration,
215
+ totalDuration
216
+ } from "./chunk-ACKKWH5Z.js";
217
+ import {
218
+ formatToParts
219
+ } from "./chunk-4N3WCGEY.js";
220
+ import {
221
+ registerLocale
222
+ } from "./chunk-UOPAV3WX.js";
223
+ import {
224
+ FORMAT_ONLY_TOKENS,
225
+ parseToParts,
226
+ safeParse,
227
+ tryParse
228
+ } from "./chunk-5UTV5VP6.js";
229
+ import {
230
+ SUPPORTED_NUMBERING_SYSTEMS,
231
+ applyNumbering,
232
+ applyParseNumbering,
233
+ convertDigits,
234
+ convertDigitsToAscii
235
+ } from "./chunk-M3GDTHMT.js";
236
+ import {
237
+ DEFAULT_LOCALE,
238
+ TOKENS
239
+ } from "./chunk-L24NPTAJ.js";
240
+ import {
241
+ setTemporal
242
+ } from "./chunk-ZQZF5EXW.js";
243
+ import {
244
+ MAX_FORMAT_LENGTH
245
+ } from "./chunk-YEUASGDK.js";
246
+ import {
247
+ AmbiguousInputError,
248
+ FormatSyntaxError,
249
+ InvalidCalendarError,
250
+ InvalidDateError,
251
+ InvalidDurationError,
252
+ InvalidLocaleError,
253
+ InvalidOffsetError,
254
+ InvalidTimeError,
255
+ InvalidTimeZoneError,
256
+ ParseMismatchError,
257
+ TemporalFmtError,
258
+ UnknownTokenError,
259
+ normalizeLocaleTag,
260
+ registerLocaleVocab
261
+ } from "./chunk-EGUUO6LE.js";
262
+ import {
263
+ compare,
264
+ isWeekend,
265
+ max,
266
+ min,
267
+ recurrence,
268
+ skip,
269
+ take
270
+ } from "./chunk-VNIUIQA4.js";
271
+ import {
272
+ add,
273
+ addDays,
274
+ addHours,
275
+ addMilliseconds,
276
+ addMinutes,
277
+ addMonths,
278
+ addSeconds,
279
+ addWeeks,
280
+ addYears,
281
+ difference as difference2,
282
+ differenceInDays,
283
+ differenceInHours,
284
+ differenceInMilliseconds,
285
+ differenceInMinutes,
286
+ differenceInMonths,
287
+ differenceInSeconds,
288
+ differenceInWeeks,
289
+ differenceInYears,
290
+ subtract as subtract2,
291
+ subtractDays,
292
+ subtractHours,
293
+ subtractMilliseconds,
294
+ subtractMinutes,
295
+ subtractMonths,
296
+ subtractSeconds,
297
+ subtractWeeks,
298
+ subtractYears
299
+ } from "./chunk-TSLPIURC.js";
300
+ import {
301
+ asDateFieldView,
302
+ dayOfYearHelper,
303
+ daysInMonth,
304
+ daysInYear,
305
+ endOf,
306
+ getQuarter,
307
+ startOf
308
+ } from "./chunk-HXY2GUUM.js";
309
+ import {
310
+ dayOfYear,
311
+ isGregorianLeapYear
312
+ } from "./chunk-MKPDLQKD.js";
313
+
314
+ // src/formatDistance.ts
315
+ function readFields(value, label) {
316
+ if (value === null || typeof value !== "object") {
317
+ throw new Error(
318
+ `temporal-fmt: formatDistance expects Temporal values, got ${label} = ${String(value)}.`
319
+ );
320
+ }
321
+ const obj = value;
322
+ const hasYear = typeof obj.year === "number";
323
+ const hasMonth = typeof obj.month === "number";
324
+ const hasDay = typeof obj.day === "number";
325
+ if (hasYear !== hasMonth || hasMonth !== hasDay) {
326
+ throw new Error(
327
+ `temporal-fmt: formatDistance got a ${label} with a partial date (some of year/month/day missing). Pass a full Temporal.PlainDate / PlainDateTime / ZonedDateTime.`
328
+ );
329
+ }
330
+ return {
331
+ year: hasYear ? obj.year : void 0,
332
+ month: hasMonth ? obj.month : void 0,
333
+ day: hasDay ? obj.day : void 0,
334
+ hour: typeof obj.hour === "number" ? obj.hour : void 0,
335
+ minute: typeof obj.minute === "number" ? obj.minute : void 0,
336
+ second: typeof obj.second === "number" ? obj.second : void 0,
337
+ millisecond: typeof obj.millisecond === "number" ? obj.millisecond : void 0
338
+ };
339
+ }
340
+ var REFERENCE_YEAR = 2e3;
341
+ var MS_PER_SECOND = 1e3;
342
+ var MS_PER_MINUTE = 60 * MS_PER_SECOND;
343
+ var MS_PER_HOUR = 60 * MS_PER_MINUTE;
344
+ var MS_PER_DAY = 24 * MS_PER_HOUR;
345
+ function daysSinceReference(year, month, day) {
346
+ let days = 0;
347
+ if (year >= REFERENCE_YEAR) {
348
+ for (let y = REFERENCE_YEAR; y < year; y++) {
349
+ days += isGregorianLeapYear(y) ? 366 : 365;
350
+ }
351
+ } else {
352
+ for (let y = year; y < REFERENCE_YEAR; y++) {
353
+ days -= isGregorianLeapYear(y) ? 366 : 365;
354
+ }
355
+ }
356
+ days += dayOfYear(year, month, day) - 1;
357
+ return days;
358
+ }
359
+ function toEpochMs(fields) {
360
+ if (fields.year === void 0 || fields.month === void 0 || fields.day === void 0) {
361
+ throw new Error(
362
+ `temporal-fmt: formatDistance needs a Temporal value with year/month/day fields (PlainDate, PlainDateTime, or ZonedDateTime). A PlainTime or other shape has no anchor date to diff against.`
363
+ );
364
+ }
365
+ const days = daysSinceReference(fields.year, fields.month, fields.day);
366
+ const hour = fields.hour ?? 0;
367
+ const minute = fields.minute ?? 0;
368
+ const second = fields.second ?? 0;
369
+ const millisecond = fields.millisecond ?? 0;
370
+ return days * MS_PER_DAY + hour * MS_PER_HOUR + minute * MS_PER_MINUTE + second * MS_PER_SECOND + millisecond;
371
+ }
372
+ var DEFAULT_CUTOFFS = {
373
+ seconds: 60,
374
+ // 60 s
375
+ minutes: 60,
376
+ // 60 min
377
+ hours: 24,
378
+ // 24 h
379
+ days: 30,
380
+ // 30 d
381
+ months: 365
382
+ // 365 d (in days, since the months→years boundary is day-resolution)
383
+ };
384
+ function resolveCutoffs(user) {
385
+ const merged = { ...DEFAULT_CUTOFFS, ...user };
386
+ for (const key of Object.keys(merged)) {
387
+ const value = merged[key];
388
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
389
+ throw new Error(
390
+ `temporal-fmt: formatDistance cutoff "${key}" must be a positive finite number (got ${String(value)}).`
391
+ );
392
+ }
393
+ }
394
+ const secondsMs = merged.seconds * MS_PER_SECOND;
395
+ const minutesMs = merged.minutes * MS_PER_MINUTE;
396
+ const hoursMs = merged.hours * MS_PER_HOUR;
397
+ const daysMs = merged.days * MS_PER_DAY;
398
+ const monthsMs = merged.months * MS_PER_DAY;
399
+ if (!(secondsMs <= minutesMs && minutesMs <= hoursMs && hoursMs <= daysMs && daysMs <= monthsMs)) {
400
+ throw new Error(
401
+ `temporal-fmt: formatDistance cutoffs must be monotonically non-decreasing in equivalent ms (seconds \u2264 minutes \u2264 hours \u2264 days \u2264 months). Got: seconds=${merged.seconds}s, minutes=${merged.minutes}min, hours=${merged.hours}h, days=${merged.days}d, months=${merged.months}d \u2014 pick a sequence where each boundary is at least as large as the one before it.`
402
+ );
403
+ }
404
+ return [
405
+ { maxMs: secondsMs, unit: "second" },
406
+ { maxMs: minutesMs, unit: "minute" },
407
+ { maxMs: hoursMs, unit: "hour" },
408
+ { maxMs: daysMs, unit: "day" },
409
+ { maxMs: monthsMs, unit: "month" }
410
+ ];
411
+ }
412
+ var rtfCache = /* @__PURE__ */ new Map();
413
+ var MAX_RTF_CACHE_SIZE = 100;
414
+ function getRtf(locale, numeric) {
415
+ const key = `${canonicalLocaleKey(locale)}|${numeric}`;
416
+ let rtf = rtfCache.get(key);
417
+ if (rtf) return rtf;
418
+ if (rtfCache.size >= MAX_RTF_CACHE_SIZE) {
419
+ const oldestKey = rtfCache.keys().next().value;
420
+ if (oldestKey !== void 0) rtfCache.delete(oldestKey);
421
+ }
422
+ try {
423
+ rtf = new Intl.RelativeTimeFormat(normalizeLocaleTag(locale), { numeric });
424
+ } catch (err) {
425
+ throw new InvalidLocaleError({ actual: locale, reason: err.message });
426
+ }
427
+ rtfCache.set(key, rtf);
428
+ return rtf;
429
+ }
430
+ function canonicalLocaleKey(locale) {
431
+ try {
432
+ return new Intl.Locale(locale.replace(/_/g, "-")).toString().toLowerCase();
433
+ } catch {
434
+ return locale;
435
+ }
436
+ }
437
+ function formatDistance(date1, date2, options = {}) {
438
+ const fields1 = readFields(date1, "date1");
439
+ const fields2 = readFields(date2, "date2");
440
+ const diffMs = toEpochMs(fields1) - toEpochMs(fields2);
441
+ const absMs = Math.abs(diffMs);
442
+ const unitCutoffs = resolveCutoffs(options.cutoffs);
443
+ let unit = "year";
444
+ for (const { maxMs, unit: candidateUnit } of unitCutoffs) {
445
+ if (absMs < maxMs) {
446
+ unit = candidateUnit;
447
+ break;
448
+ }
449
+ }
450
+ const divisor = unitToMs(unit);
451
+ const rounded = Math.round(diffMs / divisor);
452
+ const numeric = options.numeric ?? "auto";
453
+ const locale = options.locale ?? DEFAULT_LOCALE;
454
+ const rtf = getRtf(locale, numeric);
455
+ return rtf.format(rounded, unit);
456
+ }
457
+ function formatDistanceToNow(date, options = {}) {
458
+ const now = /* @__PURE__ */ new Date();
459
+ const nowFields = {
460
+ year: now.getFullYear(),
461
+ month: now.getMonth() + 1,
462
+ day: now.getDate(),
463
+ hour: now.getHours(),
464
+ minute: now.getMinutes(),
465
+ second: now.getSeconds(),
466
+ millisecond: now.getMilliseconds()
467
+ };
468
+ return formatDistance(date, nowFields, options);
469
+ }
470
+ function unitToMs(unit) {
471
+ switch (unit) {
472
+ case "second":
473
+ return MS_PER_SECOND;
474
+ case "minute":
475
+ return MS_PER_MINUTE;
476
+ case "hour":
477
+ return MS_PER_HOUR;
478
+ case "day":
479
+ return MS_PER_DAY;
480
+ /* c8 ignore start @preserve -- unreachable: unitToMs is only called
481
+ with `unit` values produced by formatDistance's cutoff loop above,
482
+ which only ever yields 'second'/'minute'/'hour'/'day'/'month'
483
+ (from resolveCutoffs' fixed array) or 'year' (the loop's fallback
484
+ default). 'week' and 'quarter' were never wired into
485
+ resolveCutoffs — formatDistance intentionally skips week-
486
+ resolution output (see the comment above DEFAULT_CUTOFFS) — so
487
+ neither can reach this switch. */
488
+ case "week":
489
+ return 7 * MS_PER_DAY;
490
+ /* c8 ignore stop @preserve */
491
+ case "month":
492
+ return 30 * MS_PER_DAY;
493
+ /* c8 ignore start @preserve -- unreachable, same reason as 'week'
494
+ above: resolveCutoffs never produces 'quarter'. */
495
+ case "quarter":
496
+ return 91 * MS_PER_DAY;
497
+ /* c8 ignore stop @preserve */
498
+ case "year":
499
+ return 365 * MS_PER_DAY;
500
+ /* c8 ignore start @preserve -- unreachable: every unit
501
+ resolveCutoffs can actually produce ('second' through 'month', or
502
+ 'year' as the loop's fallback default) has an explicit case
503
+ above, so this exhaustive-switch default can't fire at runtime.
504
+ It exists so TS accepts the function as total — the compiler
505
+ can't see through the cutoff-array iteration in formatDistance()
506
+ to know the input is already narrowed. */
507
+ default:
508
+ throw new Error(`temporal-fmt: formatDistance hit unhandled unit "${String(unit)}".`);
509
+ }
510
+ }
511
+
512
+ // src/typeGuards.ts
513
+ function isObject(v) {
514
+ return typeof v === "object" && v !== null;
515
+ }
516
+ function guardOrFalse(impl) {
517
+ return (value) => {
518
+ try {
519
+ return impl(value);
520
+ } catch {
521
+ return false;
522
+ }
523
+ };
524
+ }
525
+ function hasMethod(v, name) {
526
+ return typeof v[name] === "function";
527
+ }
528
+ function hasTag(value, typeName) {
529
+ if (!isObject(value)) return false;
530
+ const tag = value[Symbol.toStringTag];
531
+ return tag === `Temporal.${typeName}`;
532
+ }
533
+ var isPlainDate = guardOrFalse(function isPlainDateImpl(value) {
534
+ if (hasTag(value, "PlainDate")) return true;
535
+ if (!isObject(value)) return false;
536
+ const v = value;
537
+ return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "number" && typeof v.hour === "undefined" && hasMethod(v, "toPlainDateTime") && hasMethod(v, "withCalendar");
538
+ });
539
+ var isPlainTime = guardOrFalse(function isPlainTimeImpl(value) {
540
+ if (hasTag(value, "PlainTime")) return true;
541
+ if (!isObject(value)) return false;
542
+ const v = value;
543
+ return typeof v.hour === "number" && typeof v.year === "undefined" && !hasMethod(v, "withCalendar") && !hasMethod(v, "toPlainDate") && !hasMethod(v, "toPlainDateTime");
544
+ });
545
+ var isPlainDateTime = guardOrFalse(function isPlainDateTimeImpl(value) {
546
+ if (hasTag(value, "PlainDateTime")) return true;
547
+ if (!isObject(value)) return false;
548
+ const v = value;
549
+ return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "number" && typeof v.hour === "number" && hasMethod(v, "withPlainTime") && !hasMethod(v, "toInstant");
550
+ });
551
+ var isZonedDateTime = guardOrFalse(function isZonedDateTimeImpl(value) {
552
+ if (hasTag(value, "ZonedDateTime")) return true;
553
+ if (!isObject(value)) return false;
554
+ const v = value;
555
+ return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "number" && typeof v.hour === "number" && hasMethod(v, "withTimeZone") && hasMethod(v, "toInstant");
556
+ });
557
+ var isInstant = guardOrFalse(function isInstantImpl(value) {
558
+ if (hasTag(value, "Instant")) return true;
559
+ if (!isObject(value)) return false;
560
+ const v = value;
561
+ return hasMethod(v, "toZonedDateTimeISO") && !hasMethod(v, "toInstant") && typeof v.year === "undefined";
562
+ });
563
+ var isPlainYearMonth = guardOrFalse(function isPlainYearMonthImpl(value) {
564
+ if (hasTag(value, "PlainYearMonth")) return true;
565
+ if (!isObject(value)) return false;
566
+ const v = value;
567
+ return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "undefined" && hasMethod(v, "toPlainDate");
568
+ });
569
+ var isPlainMonthDay = guardOrFalse(function isPlainMonthDayImpl(value) {
570
+ if (hasTag(value, "PlainMonthDay")) return true;
571
+ if (!isObject(value)) return false;
572
+ const v = value;
573
+ return typeof v.year === "undefined" && typeof v.month === "undefined" && typeof v.day === "number" && typeof v.monthCode === "string" && hasMethod(v, "toPlainDate");
574
+ });
575
+ var isDuration = guardOrFalse(function isDurationImpl(value) {
576
+ if (hasTag(value, "Duration")) return true;
577
+ if (!isObject(value)) return false;
578
+ const v = value;
579
+ return hasMethod(v, "total");
580
+ });
581
+ var isTemporal = guardOrFalse(function isTemporalImpl(value) {
582
+ if (!isObject(value)) return false;
583
+ const tag = value[Symbol.toStringTag];
584
+ if (typeof tag === "string" && tag.startsWith("Temporal.")) return true;
585
+ const v = value;
586
+ return hasMethod(v, "toInstant") || hasMethod(v, "toPlainDate") || hasMethod(v, "toPlainDateTime") || hasMethod(v, "toPlainTime") || hasMethod(v, "toPlainYearMonth") || hasMethod(v, "toPlainMonthDay") || hasMethod(v, "toZonedDateTime") || hasMethod(v, "toZonedDateTimeISO") || hasMethod(v, "withCalendar") || hasMethod(v, "withPlainTime") || hasMethod(v, "withTimeZone") || hasMethod(v, "total");
587
+ });
588
+ function describeValue(value) {
589
+ if (value === null) return "null";
590
+ if (Array.isArray(value)) return "array";
591
+ if (typeof value === "object") {
592
+ const ctor = value.constructor;
593
+ if (ctor && typeof ctor.name === "string" && ctor.name !== "Object") {
594
+ return `instance of ${ctor.name}`;
595
+ }
596
+ return "plain object";
597
+ }
598
+ return typeof value;
599
+ }
600
+ function assertImpl(value, guard, expectedType) {
601
+ if (!guard(value)) {
602
+ throw new Error(
603
+ `temporal-fmt: expected a Temporal.${expectedType}, got ${describeValue(value)}.`
604
+ );
605
+ }
606
+ }
607
+ function assertTemporal(value) {
608
+ assertImpl(value, isTemporal, "object (Instant, PlainDate, PlainTime, PlainDateTime, ZonedDateTime, Duration, PlainYearMonth, or PlainMonthDay)");
609
+ }
610
+ function assertInstant(value) {
611
+ assertImpl(value, isInstant, "Instant");
612
+ }
613
+ function assertPlainDate(value) {
614
+ assertImpl(value, isPlainDate, "PlainDate");
615
+ }
616
+ function assertPlainTime(value) {
617
+ assertImpl(value, isPlainTime, "PlainTime");
618
+ }
619
+ function assertPlainDateTime(value) {
620
+ assertImpl(value, isPlainDateTime, "PlainDateTime");
621
+ }
622
+ function assertZonedDateTime(value) {
623
+ assertImpl(value, isZonedDateTime, "ZonedDateTime");
624
+ }
625
+ function assertPlainYearMonth(value) {
626
+ assertImpl(value, isPlainYearMonth, "PlainYearMonth");
627
+ }
628
+ function assertPlainMonthDay(value) {
629
+ assertImpl(value, isPlainMonthDay, "PlainMonthDay");
630
+ }
631
+ function assertDuration(value) {
632
+ assertImpl(value, isDuration, "Duration");
633
+ }
634
+
635
+ // src/extensibility.ts
636
+ function createFormatter(options = {}) {
637
+ const mergedTokens = [...TOKENS];
638
+ const customTokenNames = /* @__PURE__ */ new Set();
639
+ for (const custom of options.tokens ?? []) {
640
+ customTokenNames.add(custom.name);
641
+ }
642
+ for (const custom of options.tokens ?? []) {
643
+ const existingIdx = mergedTokens.findIndex(([name]) => name === custom.name);
644
+ if (existingIdx >= 0) {
645
+ mergedTokens[existingIdx] = [custom.name, custom.handler, custom.field];
646
+ } else {
647
+ mergedTokens.push([custom.name, custom.handler, custom.field]);
648
+ }
649
+ }
650
+ mergedTokens.sort((a, b) => b[0].length - a[0].length);
651
+ const handlerByToken = new Map(mergedTokens.map(([name, handler, field]) => [name, { handler, field }]));
652
+ const sortedTokenStrings = mergedTokens.map(([name]) => name);
653
+ function customTokenize(formatStr) {
654
+ const pieces = [];
655
+ let i = 0;
656
+ while (i < formatStr.length) {
657
+ const ch = formatStr[i];
658
+ if (ch === "'") {
659
+ if (formatStr[i + 1] === "'") {
660
+ appendLiteral(pieces, "'");
661
+ i += 2;
662
+ continue;
663
+ }
664
+ let j = i + 1;
665
+ let literal = "";
666
+ let closed = false;
667
+ while (j < formatStr.length) {
668
+ if (formatStr[j] === "'") {
669
+ if (formatStr[j + 1] === "'") {
670
+ literal += "'";
671
+ j += 2;
672
+ continue;
673
+ }
674
+ closed = true;
675
+ j += 1;
676
+ break;
677
+ }
678
+ literal += formatStr[j];
679
+ j += 1;
680
+ }
681
+ if (!closed) throw new Error(`temporal-fmt: unterminated quote in format string "${formatStr}"`);
682
+ appendLiteral(pieces, literal);
683
+ i = j;
684
+ continue;
685
+ }
686
+ const match = sortedTokenStrings.find((tok) => formatStr.startsWith(tok, i));
687
+ if (match) {
688
+ const runChar = match[match.length - 1];
689
+ if (formatStr[i + match.length] === runChar) {
690
+ let end = i + match.length;
691
+ while (formatStr[end] === runChar) end += 1;
692
+ throw new UnknownTokenError({
693
+ token: formatStr.slice(i, end),
694
+ format: formatStr,
695
+ message: `temporal-fmt: "${formatStr.slice(i, end)}" in format string "${formatStr}" isn't a recognized token \u2014 did you mean "${match}"?`
696
+ });
697
+ }
698
+ pieces.push({ kind: "token", value: match });
699
+ i += match.length;
700
+ continue;
701
+ }
702
+ appendLiteral(pieces, ch);
703
+ i += 1;
704
+ }
705
+ return pieces;
706
+ }
707
+ function appendLiteral(pieces, value) {
708
+ const last = pieces[pieces.length - 1];
709
+ if (last && last.kind === "literal") {
710
+ last.value += value;
711
+ } else {
712
+ pieces.push({ kind: "literal", value });
713
+ }
714
+ }
715
+ const defaultLocale = options.defaultLocale ?? DEFAULT_LOCALE;
716
+ return {
717
+ format(temporal, formatStr, opts = {}) {
718
+ if (formatStr.length > MAX_FORMAT_LENGTH) {
719
+ throw new Error(`temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters (got ${formatStr.length}).`);
720
+ }
721
+ const locale = opts.locale ?? defaultLocale;
722
+ const pieces = customTokenize(formatStr);
723
+ let result = "";
724
+ for (const piece of pieces) {
725
+ if (piece.kind === "literal") {
726
+ result += piece.value;
727
+ continue;
728
+ }
729
+ const handler = handlerByToken.get(piece.value);
730
+ /* c8 ignore start @preserve -- unreachable: customTokenize only ever produces a
731
+ `kind: 'token'` piece via sortedTokenStrings.find(...), and
732
+ handlerByToken is built from that same mergedTokens array, so
733
+ every token piece is guaranteed a handler entry. Guards against a
734
+ future customTokenize change that decouples the two lookups. */
735
+ if (!handler) throw new Error(`temporal-fmt: unknown token "${piece.value}"`);
736
+ /* c8 ignore stop @preserve */
737
+ if (temporal[handler.field] === void 0) {
738
+ throw new Error(
739
+ `temporal-fmt: token "${piece.value}" requires "${String(handler.field)}", which this Temporal object doesn't have.`
740
+ );
741
+ }
742
+ result += handler.handler(temporal, locale);
743
+ }
744
+ return result;
745
+ },
746
+ formatToParts(temporal, formatStr, opts = {}) {
747
+ if (formatStr.length > MAX_FORMAT_LENGTH) {
748
+ throw new Error(`temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters (got ${formatStr.length}).`);
749
+ }
750
+ const locale = opts.locale ?? defaultLocale;
751
+ const pieces = customTokenize(formatStr);
752
+ const out = [];
753
+ for (const piece of pieces) {
754
+ if (piece.kind === "literal") {
755
+ const last = out[out.length - 1];
756
+ /* c8 ignore start @preserve -- unreachable: customTokenize's own
757
+ appendLiteral() already merges adjacent literal chars/quoted
758
+ spans into a single piece before this loop ever sees them, so
759
+ two literal pieces are never adjacent here. Kept as a guard
760
+ against a future customTokenize change that stops merging. */
761
+ if (last && last.type === "literal") last.value += piece.value;
762
+ else out.push({ type: "literal", value: piece.value });
763
+ continue;
764
+ }
765
+ const handler = handlerByToken.get(piece.value);
766
+ /* c8 ignore start @preserve -- unreachable: customTokenize only emits
767
+ kind:'token' pieces found in sortedTokenStrings, the same array
768
+ handlerByToken is built from, so every token piece is guaranteed
769
+ a handler entry. Guards against future decoupling of the two. */
770
+ if (!handler) throw new Error(`temporal-fmt: unknown token "${piece.value}"`);
771
+ /* c8 ignore stop @preserve */
772
+ if (temporal[handler.field] === void 0) {
773
+ throw new Error(`temporal-fmt: token "${piece.value}" requires "${String(handler.field)}".`);
774
+ }
775
+ out.push({ type: "token", value: handler.handler(temporal, locale), token: piece.value });
776
+ }
777
+ return out;
778
+ },
779
+ compileFormat(formatStr) {
780
+ if (formatStr.length > MAX_FORMAT_LENGTH) {
781
+ throw new Error(`temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters (got ${formatStr.length}).`);
782
+ }
783
+ const pieces = customTokenize(formatStr);
784
+ return {
785
+ formatStr,
786
+ pieces: pieces.map((p) => p),
787
+ format(temporal, opts = {}) {
788
+ const locale = opts.locale ?? defaultLocale;
789
+ let result = "";
790
+ for (const piece of pieces) {
791
+ if (piece.kind === "literal") {
792
+ result += piece.value;
793
+ continue;
794
+ }
795
+ const handler = handlerByToken.get(piece.value);
796
+ /* c8 ignore start @preserve -- unreachable, see the same guard's comment
797
+ above in the un-compiled format(). */
798
+ if (!handler) throw new Error(`temporal-fmt: unknown token "${piece.value}"`);
799
+ /* c8 ignore stop @preserve */
800
+ if (temporal[handler.field] === void 0) {
801
+ throw new Error(`temporal-fmt: token "${piece.value}" requires "${String(handler.field)}".`);
802
+ }
803
+ result += handler.handler(temporal, locale);
804
+ }
805
+ return result;
806
+ },
807
+ formatToParts(temporal, opts = {}) {
808
+ const locale = opts.locale ?? defaultLocale;
809
+ const out = [];
810
+ for (const piece of pieces) {
811
+ if (piece.kind === "literal") {
812
+ const last = out[out.length - 1];
813
+ /* c8 ignore start @preserve -- unreachable, see the same guard's
814
+ comment above in the un-compiled formatToParts. */
815
+ if (last && last.type === "literal") last.value += piece.value;
816
+ else out.push({ type: "literal", value: piece.value });
817
+ continue;
818
+ }
819
+ const handler = handlerByToken.get(piece.value);
820
+ /* c8 ignore start @preserve -- unreachable, see the same guard's
821
+ comment above in the un-compiled formatToParts. */
822
+ if (!handler) throw new Error(`temporal-fmt: unknown token "${piece.value}"`);
823
+ /* c8 ignore stop @preserve */
824
+ if (temporal[handler.field] === void 0) {
825
+ throw new Error(`temporal-fmt: token "${piece.value}" requires "${String(handler.field)}".`);
826
+ }
827
+ out.push({ type: "token", value: handler.handler(temporal, locale), token: piece.value });
828
+ }
829
+ return out;
830
+ }
831
+ };
832
+ }
833
+ };
834
+ }
835
+
836
+ // src/modApi.ts
837
+ function buildModContextFor(modName) {
838
+ return {
839
+ registerLocale,
840
+ registerLocaleVocab,
841
+ registerRelativeGrammar,
842
+ createFormatter,
843
+ createHolidayCalendar,
844
+ overrideFormat(impl) {
845
+ const original = getFormatImpl();
846
+ setFormatOverride((...args) => impl(original, ...args), modName);
847
+ },
848
+ overrideParse(impl) {
849
+ const original = getParseImpl();
850
+ setParseOverride((...args) => impl(original, ...args), modName);
851
+ },
852
+ overrideCompileFormat(impl) {
853
+ const original = getCompileFormatImpl();
854
+ setCompileFormatOverride((...args) => impl(original, ...args), modName);
855
+ },
856
+ overrideCompileParser(impl) {
857
+ const original = getCompileParserImpl();
858
+ setCompileParserOverride((...args) => impl(original, ...args), modName);
859
+ },
860
+ overrideParseRelative(impl) {
861
+ const original = getParseRelativeImpl();
862
+ setParseRelativeOverride((...args) => impl(original, ...args), modName);
863
+ },
864
+ overrideExplainFormat(impl) {
865
+ const original = getExplainFormatImpl();
866
+ setExplainFormatOverride((...args) => impl(original, ...args), modName);
867
+ },
868
+ overrideTokenizeFormat(impl) {
869
+ const original = getTokenizeFormatImpl();
870
+ setTokenizeFormatOverride((...args) => impl(original, ...args), modName);
871
+ },
872
+ overrideListTokens(impl) {
873
+ const original = getListTokensImpl();
874
+ setListTokensOverride((...args) => impl(original, ...args), modName);
875
+ },
876
+ overrideTokenInfo(impl) {
877
+ const original = getTokenInfoImpl();
878
+ setTokenInfoOverride((...args) => impl(original, ...args), modName);
879
+ },
880
+ overrideIsValidFormat(impl) {
881
+ const original = getIsValidFormatImpl();
882
+ setIsValidFormatOverride((...args) => impl(original, ...args), modName);
883
+ },
884
+ overrideValidateFormat(impl) {
885
+ const original = getValidateFormatImpl();
886
+ setValidateFormatOverride((...args) => impl(original, ...args), modName);
887
+ },
888
+ overrideFieldForToken(impl) {
889
+ const original = getFieldForTokenImpl();
890
+ setFieldForTokenOverride((...args) => impl(original, ...args), modName);
891
+ },
892
+ overrideMonthsInYear(impl) {
893
+ const original = getMonthsInYearImpl();
894
+ setMonthsInYearOverride((...args) => impl(original, ...args), modName);
895
+ },
896
+ overrideIsLeapYear(impl) {
897
+ const original = getIsLeapYearImpl();
898
+ setIsLeapYearOverride((...args) => impl(original, ...args), modName);
899
+ },
900
+ overrideIsLeapMonth(impl) {
901
+ const original = getIsLeapMonthImpl();
902
+ setIsLeapMonthOverride((...args) => impl(original, ...args), modName);
903
+ },
904
+ overrideWeekOfYear(impl) {
905
+ const original = getWeekOfYearImpl();
906
+ setWeekOfYearOverride((...args) => impl(original, ...args), modName);
907
+ },
908
+ overrideWeekYear(impl) {
909
+ const original = getWeekYearImpl();
910
+ setWeekYearOverride((...args) => impl(original, ...args), modName);
911
+ },
912
+ overrideGetMonth(impl) {
913
+ const original = getGetMonthImpl();
914
+ setGetMonthOverride((...args) => impl(original, ...args), modName);
915
+ },
916
+ overrideGetWeekday(impl) {
917
+ const original = getGetWeekdayImpl();
918
+ setGetWeekdayOverride((...args) => impl(original, ...args), modName);
919
+ },
920
+ overrideIsEqual(impl) {
921
+ const original = getIsEqualImpl();
922
+ setIsEqualOverride((...args) => impl(original, ...args), modName);
923
+ },
924
+ overrideIsBefore(impl) {
925
+ const original = getIsBeforeImpl();
926
+ setIsBeforeOverride((...args) => impl(original, ...args), modName);
927
+ },
928
+ overrideIsAfter(impl) {
929
+ const original = getIsAfterImpl();
930
+ setIsAfterOverride((...args) => impl(original, ...args), modName);
931
+ },
932
+ overrideClamp(impl) {
933
+ const original = getClampImpl();
934
+ setClampOverride((...args) => impl(original, ...args), modName);
935
+ },
936
+ overrideIsBetween(impl) {
937
+ const original = getIsBetweenImpl();
938
+ setIsBetweenOverride((...args) => impl(original, ...args), modName);
939
+ },
940
+ overrideIsToday(impl) {
941
+ const original = getIsTodayImpl();
942
+ setIsTodayOverride((...args) => impl(original, ...args), modName);
943
+ },
944
+ overrideIsTomorrow(impl) {
945
+ const original = getIsTomorrowImpl();
946
+ setIsTomorrowOverride((...args) => impl(original, ...args), modName);
947
+ },
948
+ overrideIsYesterday(impl) {
949
+ const original = getIsYesterdayImpl();
950
+ setIsYesterdayOverride((...args) => impl(original, ...args), modName);
951
+ },
952
+ overrideIsSameDay(impl) {
953
+ const original = getIsSameDayImpl();
954
+ setIsSameDayOverride((...args) => impl(original, ...args), modName);
955
+ },
956
+ overrideIsSameWeek(impl) {
957
+ const original = getIsSameWeekImpl();
958
+ setIsSameWeekOverride((...args) => impl(original, ...args), modName);
959
+ },
960
+ overrideIsSameMonth(impl) {
961
+ const original = getIsSameMonthImpl();
962
+ setIsSameMonthOverride((...args) => impl(original, ...args), modName);
963
+ },
964
+ overrideIsSameQuarter(impl) {
965
+ const original = getIsSameQuarterImpl();
966
+ setIsSameQuarterOverride((...args) => impl(original, ...args), modName);
967
+ },
968
+ overrideIsSameYear(impl) {
969
+ const original = getIsSameYearImpl();
970
+ setIsSameYearOverride((...args) => impl(original, ...args), modName);
971
+ },
972
+ overrideIsWeekday(impl) {
973
+ const original = getIsWeekdayImpl();
974
+ setIsWeekdayOverride((...args) => impl(original, ...args), modName);
975
+ },
976
+ overrideFloor(impl) {
977
+ const original = getFloorImpl();
978
+ setFloorOverride((...args) => impl(original, ...args), modName);
979
+ },
980
+ overrideCeil(impl) {
981
+ const original = getCeilImpl();
982
+ setCeilOverride((...args) => impl(original, ...args), modName);
983
+ },
984
+ overrideTruncate(impl) {
985
+ const original = getTruncateImpl();
986
+ setTruncateOverride((...args) => impl(original, ...args), modName);
987
+ },
988
+ overrideParseRFC3339(impl) {
989
+ const original = getParseRFC3339Impl();
990
+ setParseRFC3339Override((...args) => impl(original, ...args), modName);
991
+ },
992
+ overrideFormatRFC3339(impl) {
993
+ const original = getFormatRFC3339Impl();
994
+ setFormatRFC3339Override((...args) => impl(original, ...args), modName);
995
+ },
996
+ overrideParseRFC2822(impl) {
997
+ const original = getParseRFC2822Impl();
998
+ setParseRFC2822Override((...args) => impl(original, ...args), modName);
999
+ },
1000
+ overrideParseHTTPDate(impl) {
1001
+ const original = getParseHTTPDateImpl();
1002
+ setParseHTTPDateOverride((...args) => impl(original, ...args), modName);
1003
+ },
1004
+ overrideFromUnixMicroseconds(impl) {
1005
+ const original = getFromUnixMicrosecondsImpl();
1006
+ setFromUnixMicrosecondsOverride((...args) => impl(original, ...args), modName);
1007
+ },
1008
+ overrideFromUnixNanoseconds(impl) {
1009
+ const original = getFromUnixNanosecondsImpl();
1010
+ setFromUnixNanosecondsOverride((...args) => impl(original, ...args), modName);
1011
+ },
1012
+ overrideToUnixSeconds(impl) {
1013
+ const original = getToUnixSecondsImpl();
1014
+ setToUnixSecondsOverride((...args) => impl(original, ...args), modName);
1015
+ },
1016
+ overrideToUnixMilliseconds(impl) {
1017
+ const original = getToUnixMillisecondsImpl();
1018
+ setToUnixMillisecondsOverride((...args) => impl(original, ...args), modName);
1019
+ },
1020
+ overrideToUnixMicroseconds(impl) {
1021
+ const original = getToUnixMicrosecondsImpl();
1022
+ setToUnixMicrosecondsOverride((...args) => impl(original, ...args), modName);
1023
+ },
1024
+ overrideToUnixNanoseconds(impl) {
1025
+ const original = getToUnixNanosecondsImpl();
1026
+ setToUnixNanosecondsOverride((...args) => impl(original, ...args), modName);
1027
+ },
1028
+ overrideParseSQL(impl) {
1029
+ const original = getParseSQLImpl();
1030
+ setParseSQLOverride((...args) => impl(original, ...args), modName);
1031
+ },
1032
+ overrideFormatSQL(impl) {
1033
+ const original = getFormatSQLImpl();
1034
+ setFormatSQLOverride((...args) => impl(original, ...args), modName);
1035
+ },
1036
+ overrideFormatDurationToParts(impl) {
1037
+ const original = getFormatDurationToPartsImpl();
1038
+ setFormatDurationToPartsOverride((...args) => impl(original, ...args), modName);
1039
+ },
1040
+ overrideParseDuration(impl) {
1041
+ const original = getParseDurationImpl();
1042
+ setParseDurationOverride((...args) => impl(original, ...args), modName);
1043
+ },
1044
+ overrideParseISODuration(impl) {
1045
+ const original = getParseISODurationImpl();
1046
+ setParseISODurationOverride((...args) => impl(original, ...args), modName);
1047
+ },
1048
+ overrideFormatISODuration(impl) {
1049
+ const original = getFormatISODurationImpl();
1050
+ setFormatISODurationOverride((...args) => impl(original, ...args), modName);
1051
+ },
1052
+ overrideBalanceDuration(impl) {
1053
+ const original = getBalanceDurationImpl();
1054
+ setBalanceDurationOverride((...args) => impl(original, ...args), modName);
1055
+ },
1056
+ overrideCompareDuration(impl) {
1057
+ const original = getCompareDurationImpl();
1058
+ setCompareDurationOverride((...args) => impl(original, ...args), modName);
1059
+ },
1060
+ overrideSubtractDuration(impl) {
1061
+ const original = getSubtractDurationImpl();
1062
+ setSubtractDurationOverride((...args) => impl(original, ...args), modName);
1063
+ },
1064
+ overrideGetLocale(impl) {
1065
+ const original = getGetLocaleImpl();
1066
+ setGetLocaleOverride((...args) => impl(original, ...args), modName);
1067
+ },
1068
+ overrideHasLocale(impl) {
1069
+ const original = getHasLocaleImpl();
1070
+ setHasLocaleOverride((...args) => impl(original, ...args), modName);
1071
+ },
1072
+ overrideCreateConfig(impl) {
1073
+ const original = getCreateConfigImpl();
1074
+ setCreateConfigOverride((...args) => impl(original, ...args), modName);
1075
+ },
1076
+ overrideMergeWithConfig(impl) {
1077
+ const original = getMergeWithConfigImpl();
1078
+ setMergeWithConfigOverride((...args) => impl(original, ...args), modName);
1079
+ },
1080
+ overrideListRegisteredGrammars(impl) {
1081
+ const original = getListRegisteredGrammarsImpl();
1082
+ setListRegisteredGrammarsOverride((...args) => impl(original, ...args), modName);
1083
+ },
1084
+ overrideInterval(impl) {
1085
+ const original = getIntervalImpl();
1086
+ setIntervalOverride((...args) => impl(original, ...args), modName);
1087
+ },
1088
+ overrideOverlaps(impl) {
1089
+ const original = getOverlapsImpl();
1090
+ setOverlapsOverride((...args) => impl(original, ...args), modName);
1091
+ },
1092
+ overrideIntersection(impl) {
1093
+ const original = getIntersectionImpl();
1094
+ setIntersectionOverride((...args) => impl(original, ...args), modName);
1095
+ },
1096
+ overrideUnion(impl) {
1097
+ const original = getUnionImpl();
1098
+ setUnionOverride((...args) => impl(original, ...args), modName);
1099
+ },
1100
+ overrideMergeIntervals(impl) {
1101
+ const original = getMergeIntervalsImpl();
1102
+ setMergeIntervalsOverride((...args) => impl(original, ...args), modName);
1103
+ },
1104
+ overrideFormatRangeToParts(impl) {
1105
+ const original = getFormatRangeToPartsImpl();
1106
+ setFormatRangeToPartsOverride((...args) => impl(original, ...args), modName);
1107
+ },
1108
+ overrideBetween(impl) {
1109
+ const original = getBetweenImpl();
1110
+ setBetweenOverride((...args) => impl(original, ...args), modName);
1111
+ },
1112
+ overrideParseRRule(impl) {
1113
+ const original = getParseRRuleImpl();
1114
+ setParseRRuleOverride((...args) => impl(original, ...args), modName);
1115
+ },
1116
+ overrideFormatRRule(impl) {
1117
+ const original = getFormatRRuleImpl();
1118
+ setFormatRRuleOverride((...args) => impl(original, ...args), modName);
1119
+ },
1120
+ overrideCreateBusinessCalendar(impl) {
1121
+ const original = getCreateBusinessCalendarImpl();
1122
+ setCreateBusinessCalendarOverride((...args) => impl(original, ...args), modName);
1123
+ },
1124
+ overrideSubtractBusinessDays(impl) {
1125
+ const original = getSubtractBusinessDaysImpl();
1126
+ setSubtractBusinessDaysOverride((...args) => impl(original, ...args), modName);
1127
+ },
1128
+ overrideNextHoliday(impl) {
1129
+ const original = getNextHolidayImpl();
1130
+ setNextHolidayOverride((...args) => impl(original, ...args), modName);
1131
+ },
1132
+ overridePreviousHoliday(impl) {
1133
+ const original = getPreviousHolidayImpl();
1134
+ setPreviousHolidayOverride((...args) => impl(original, ...args), modName);
1135
+ },
1136
+ overrideResolveZoned(impl) {
1137
+ const original = getResolveZonedImpl();
1138
+ setResolveZonedOverride((...args) => impl(original, ...args), modName);
1139
+ },
1140
+ overrideGetNextTransition(impl) {
1141
+ const original = getGetNextTransitionImpl();
1142
+ setGetNextTransitionOverride((...args) => impl(original, ...args), modName);
1143
+ },
1144
+ overrideGetPreviousTransition(impl) {
1145
+ const original = getGetPreviousTransitionImpl();
1146
+ setGetPreviousTransitionOverride((...args) => impl(original, ...args), modName);
1147
+ },
1148
+ overridePossibleInstantsFor(impl) {
1149
+ const original = getPossibleInstantsForImpl();
1150
+ setPossibleInstantsForOverride((...args) => impl(original, ...args), modName);
1151
+ },
1152
+ overrideGetAutocompleteData(impl) {
1153
+ const original = getGetAutocompleteDataImpl();
1154
+ setGetAutocompleteDataOverride((...args) => impl(original, ...args), modName);
1155
+ },
1156
+ overrideGetHoverDocs(impl) {
1157
+ const original = getGetHoverDocsImpl();
1158
+ setGetHoverDocsOverride((...args) => impl(original, ...args), modName);
1159
+ },
1160
+ overrideGetInlineDiagnostics(impl) {
1161
+ const original = getGetInlineDiagnosticsImpl();
1162
+ setGetInlineDiagnosticsOverride((...args) => impl(original, ...args), modName);
1163
+ },
1164
+ overridePreviewFormat(impl) {
1165
+ const original = getPreviewFormatImpl();
1166
+ setPreviewFormatOverride((...args) => impl(original, ...args), modName);
1167
+ },
1168
+ overrideGetDocUrl(impl) {
1169
+ const original = getGetDocUrlImpl();
1170
+ setGetDocUrlOverride((...args) => impl(original, ...args), modName);
1171
+ },
1172
+ overrideTranslateDateFnsFormatString(impl) {
1173
+ const original = getTranslateDateFnsFormatStringImpl();
1174
+ setTranslateDateFnsFormatStringOverride((...args) => impl(original, ...args), modName);
1175
+ }
1176
+ };
1177
+ }
1178
+ function buildModContext() {
1179
+ return buildModContextFor("(unattributed)");
1180
+ }
1181
+ function buildTrackedModContext(modName, onRegister) {
1182
+ const base = buildModContextFor(modName);
1183
+ return {
1184
+ // Everything not called out below (all 81 zero-fan-out override
1185
+ // points from runtime.ts, plus createHolidayCalendar) passes through
1186
+ // untracked — see the comment on createHolidayCalendar's own case
1187
+ // above for why untracked is correct for it, and generate.mjs for
1188
+ // why we don't hand-list 81 identical `overrideXxx(impl) { base.
1189
+ // overrideXxx(impl); onRegister(...) }` pass-throughs here: none of
1190
+ // them have a shared key two mods could conflict on the way a locale
1191
+ // tag or token name does, so there's nothing meaningful to track.
1192
+ ...base,
1193
+ registerLocale(locale, vocab) {
1194
+ onRegister({ kind: "locale", key: locale });
1195
+ base.registerLocale(locale, vocab);
1196
+ },
1197
+ registerLocaleVocab(locale, vocab) {
1198
+ onRegister({ kind: "localeVocab", key: locale });
1199
+ base.registerLocaleVocab(locale, vocab);
1200
+ },
1201
+ registerRelativeGrammar(grammar) {
1202
+ onRegister({ kind: "relativeGrammar", key: grammar.language });
1203
+ base.registerRelativeGrammar(grammar);
1204
+ },
1205
+ createFormatter(options) {
1206
+ for (const token of options?.tokens ?? []) {
1207
+ onRegister({ kind: "formatterTokens", key: token.name });
1208
+ }
1209
+ return base.createFormatter(options);
1210
+ },
1211
+ createHolidayCalendar(specs) {
1212
+ return base.createHolidayCalendar(specs);
1213
+ },
1214
+ overrideFormat(impl) {
1215
+ base.overrideFormat(impl);
1216
+ onRegister({ kind: "overrideFormat", key: "format" });
1217
+ },
1218
+ overrideParse(impl) {
1219
+ base.overrideParse(impl);
1220
+ onRegister({ kind: "overrideParse", key: "parse" });
1221
+ }
1222
+ };
1223
+ }
1224
+ function isMod(value) {
1225
+ if (typeof value !== "object" || value === null) return false;
1226
+ const v = value;
1227
+ if (typeof v.name !== "string" || v.name.length === 0) return false;
1228
+ if (typeof v.register !== "function") return false;
1229
+ if (v.requires !== void 0 && !(Array.isArray(v.requires) && v.requires.every((r) => typeof r === "string"))) return false;
1230
+ if (v.priority !== void 0 && typeof v.priority !== "number") return false;
1231
+ return true;
1232
+ }
1233
+
1234
+ // src/index.ts
1235
+ var format = (...args) => getFormatImpl()(...args);
1236
+ var parse = (...args) => getParseImpl()(...args);
1237
+ var compileFormat = (...args) => getCompileFormatImpl()(...args);
1238
+ var compileParser = (...args) => getCompileParserImpl()(...args);
1239
+ var parseRelative = (...args) => getParseRelativeImpl()(...args);
1240
+ var explainFormat = (...args) => getExplainFormatImpl()(...args);
1241
+ var tokenizeFormat = (...args) => getTokenizeFormatImpl()(...args);
1242
+ var listTokens = (...args) => getListTokensImpl()(...args);
1243
+ var tokenInfo = (...args) => getTokenInfoImpl()(...args);
1244
+ var isValidFormat = (...args) => getIsValidFormatImpl()(...args);
1245
+ var validateFormat = (...args) => getValidateFormatImpl()(...args);
1246
+ var fieldForToken = (...args) => getFieldForTokenImpl()(...args);
1247
+ var monthsInYear = (...args) => getMonthsInYearImpl()(...args);
1248
+ var isLeapYear = (...args) => getIsLeapYearImpl()(...args);
1249
+ var isLeapMonth = (...args) => getIsLeapMonthImpl()(...args);
1250
+ var weekOfYear = (...args) => getWeekOfYearImpl()(...args);
1251
+ var weekYear = (...args) => getWeekYearImpl()(...args);
1252
+ var getMonth = (...args) => getGetMonthImpl()(...args);
1253
+ var getWeekday = (...args) => getGetWeekdayImpl()(...args);
1254
+ var isEqual = (...args) => getIsEqualImpl()(...args);
1255
+ var isBefore2 = (...args) => getIsBeforeImpl()(...args);
1256
+ var isAfter2 = (...args) => getIsAfterImpl()(...args);
1257
+ var clamp = (...args) => getClampImpl()(...args);
1258
+ var isBetween = (...args) => getIsBetweenImpl()(...args);
1259
+ var isToday = (...args) => getIsTodayImpl()(...args);
1260
+ var isTomorrow = (...args) => getIsTomorrowImpl()(...args);
1261
+ var isYesterday = (...args) => getIsYesterdayImpl()(...args);
1262
+ var isSameDay = (...args) => getIsSameDayImpl()(...args);
1263
+ var isSameWeek = (...args) => getIsSameWeekImpl()(...args);
1264
+ var isSameMonth = (...args) => getIsSameMonthImpl()(...args);
1265
+ var isSameQuarter = (...args) => getIsSameQuarterImpl()(...args);
1266
+ var isSameYear = (...args) => getIsSameYearImpl()(...args);
1267
+ var isWeekday = (...args) => getIsWeekdayImpl()(...args);
1268
+ var floor = (...args) => getFloorImpl()(...args);
1269
+ var ceil = (...args) => getCeilImpl()(...args);
1270
+ var truncate = (...args) => getTruncateImpl()(...args);
1271
+ var parseRFC3339 = (...args) => getParseRFC3339Impl()(...args);
1272
+ var formatRFC3339 = (...args) => getFormatRFC3339Impl()(...args);
1273
+ var parseRFC2822 = (...args) => getParseRFC2822Impl()(...args);
1274
+ var parseHTTPDate = (...args) => getParseHTTPDateImpl()(...args);
1275
+ var fromUnixMicroseconds = (...args) => getFromUnixMicrosecondsImpl()(...args);
1276
+ var fromUnixNanoseconds = (...args) => getFromUnixNanosecondsImpl()(...args);
1277
+ var toUnixSeconds = (...args) => getToUnixSecondsImpl()(...args);
1278
+ var toUnixMilliseconds = (...args) => getToUnixMillisecondsImpl()(...args);
1279
+ var toUnixMicroseconds = (...args) => getToUnixMicrosecondsImpl()(...args);
1280
+ var toUnixNanoseconds = (...args) => getToUnixNanosecondsImpl()(...args);
1281
+ var parseSQL = (...args) => getParseSQLImpl()(...args);
1282
+ var formatSQL = (...args) => getFormatSQLImpl()(...args);
1283
+ var formatDurationToParts = (...args) => getFormatDurationToPartsImpl()(...args);
1284
+ var parseDuration = (...args) => getParseDurationImpl()(...args);
1285
+ var parseISODuration = (...args) => getParseISODurationImpl()(...args);
1286
+ var formatISODuration = (...args) => getFormatISODurationImpl()(...args);
1287
+ var balanceDuration = (...args) => getBalanceDurationImpl()(...args);
1288
+ var compareDuration = (...args) => getCompareDurationImpl()(...args);
1289
+ var subtractDuration = (...args) => getSubtractDurationImpl()(...args);
1290
+ var getLocale = (...args) => getGetLocaleImpl()(...args);
1291
+ var hasLocale = (...args) => getHasLocaleImpl()(...args);
1292
+ var createConfig = (...args) => getCreateConfigImpl()(...args);
1293
+ var mergeWithConfig = (...args) => getMergeWithConfigImpl()(...args);
1294
+ var listRegisteredGrammars = (...args) => getListRegisteredGrammarsImpl()(...args);
1295
+ var interval = (...args) => getIntervalImpl()(...args);
1296
+ var overlaps = (...args) => getOverlapsImpl()(...args);
1297
+ var intersection = (...args) => getIntersectionImpl()(...args);
1298
+ var union = (...args) => getUnionImpl()(...args);
1299
+ var mergeIntervals = (...args) => getMergeIntervalsImpl()(...args);
1300
+ var formatRangeToParts = (...args) => getFormatRangeToPartsImpl()(...args);
1301
+ var between = (...args) => getBetweenImpl()(...args);
1302
+ var parseRRule = (...args) => getParseRRuleImpl()(...args);
1303
+ var formatRRule = (...args) => getFormatRRuleImpl()(...args);
1304
+ var createBusinessCalendar = (...args) => getCreateBusinessCalendarImpl()(...args);
1305
+ var subtractBusinessDays = (...args) => getSubtractBusinessDaysImpl()(...args);
1306
+ var nextHoliday = (...args) => getNextHolidayImpl()(...args);
1307
+ var previousHoliday = (...args) => getPreviousHolidayImpl()(...args);
1308
+ var resolveZoned = (...args) => getResolveZonedImpl()(...args);
1309
+ var getNextTransition = (...args) => getGetNextTransitionImpl()(...args);
1310
+ var getPreviousTransition = (...args) => getGetPreviousTransitionImpl()(...args);
1311
+ var possibleInstantsFor = (...args) => getPossibleInstantsForImpl()(...args);
1312
+ var getAutocompleteData = (...args) => getGetAutocompleteDataImpl()(...args);
1313
+ var getHoverDocs = (...args) => getGetHoverDocsImpl()(...args);
1314
+ var getInlineDiagnostics = (...args) => getGetInlineDiagnosticsImpl()(...args);
1315
+ var previewFormat = (...args) => getPreviewFormatImpl()(...args);
1316
+ var getDocUrl = (...args) => getGetDocUrlImpl()(...args);
1317
+ var translateDateFnsFormatString = (...args) => getTranslateDateFnsFormatStringImpl()(...args);
1318
+ export {
1319
+ ALL_TOKEN_NAMES,
1320
+ AmbiguousInputError,
1321
+ DATE_FNS_TO_TEMPORAL_FMT,
1322
+ DAYJS_TO_TEMPORAL_FMT,
1323
+ DEFAULT_CONFIG,
1324
+ FORMAT_ONLY_TOKENS,
1325
+ FormatSyntaxError,
1326
+ InvalidCalendarError,
1327
+ InvalidDateError,
1328
+ InvalidDurationError,
1329
+ InvalidLocaleError,
1330
+ InvalidOffsetError,
1331
+ InvalidTimeError,
1332
+ InvalidTimeZoneError,
1333
+ OverrideConflictError,
1334
+ ParseMismatchError,
1335
+ SUPPORTED_NUMBERING_SYSTEMS,
1336
+ TOKEN_METADATA,
1337
+ TemporalFmtError,
1338
+ UnknownTokenError,
1339
+ add,
1340
+ addBusinessDays,
1341
+ addDays,
1342
+ addDuration,
1343
+ addHours,
1344
+ addMilliseconds,
1345
+ addMinutes,
1346
+ addMonths,
1347
+ addSeconds,
1348
+ addWeeks,
1349
+ addYears,
1350
+ analyzeFormat,
1351
+ applyNumbering,
1352
+ applyParseNumbering,
1353
+ asDateFieldView,
1354
+ assertDuration,
1355
+ assertInstant,
1356
+ assertPlainDate,
1357
+ assertPlainDateTime,
1358
+ assertPlainMonthDay,
1359
+ assertPlainTime,
1360
+ assertPlainYearMonth,
1361
+ assertTemporal,
1362
+ assertZonedDateTime,
1363
+ balanceDuration,
1364
+ between,
1365
+ buildModContext,
1366
+ buildModContextFor,
1367
+ buildTrackedModContext,
1368
+ ceil,
1369
+ clamp,
1370
+ compare,
1371
+ compareDuration,
1372
+ compileFormat,
1373
+ compileParser,
1374
+ convertDigits,
1375
+ convertDigitsToAscii,
1376
+ createBusinessCalendar,
1377
+ createConfig,
1378
+ createFormatter,
1379
+ createHolidayCalendar,
1380
+ dayOfYearHelper as dayOfYear,
1381
+ daysInMonth,
1382
+ daysInYear,
1383
+ difference2 as difference,
1384
+ differenceInBusinessDays,
1385
+ differenceInDays,
1386
+ differenceInHours,
1387
+ differenceInMilliseconds,
1388
+ differenceInMinutes,
1389
+ differenceInMonths,
1390
+ differenceInSeconds,
1391
+ differenceInWeeks,
1392
+ differenceInYears,
1393
+ endOf,
1394
+ explainFormat,
1395
+ fieldForToken,
1396
+ floor,
1397
+ format,
1398
+ formatDistance,
1399
+ formatDistanceToNow,
1400
+ formatDuration,
1401
+ formatDurationToParts,
1402
+ formatHTTPDate,
1403
+ formatISO,
1404
+ formatISODuration,
1405
+ formatRFC2822,
1406
+ formatRFC3339,
1407
+ formatRRule,
1408
+ formatRange,
1409
+ formatRangeToParts,
1410
+ formatRelative,
1411
+ formatRelativeToNow,
1412
+ formatSQL,
1413
+ formatToParts,
1414
+ fromUnixMicroseconds,
1415
+ fromUnixMilliseconds,
1416
+ fromUnixNanoseconds,
1417
+ fromUnixSeconds,
1418
+ getAutocompleteData,
1419
+ getDocUrl,
1420
+ getHoverDocs,
1421
+ getInlineDiagnostics,
1422
+ getLocale,
1423
+ getMonth,
1424
+ getNextTransition,
1425
+ getOffset,
1426
+ getOffsetNanoseconds,
1427
+ getPreviousTransition,
1428
+ getQuarter,
1429
+ getTimeZone,
1430
+ getTransitions,
1431
+ getWeekday,
1432
+ hasLocale,
1433
+ holidaysBetween,
1434
+ intersection,
1435
+ intersects,
1436
+ interval,
1437
+ contains as intervalContains,
1438
+ difference as intervalDifference,
1439
+ isAfter as intervalIsAfter,
1440
+ isBefore as intervalIsBefore,
1441
+ subtract as intervalSubtract,
1442
+ isAfter2 as isAfter,
1443
+ isBefore2 as isBefore,
1444
+ isBetween,
1445
+ isBusinessDay,
1446
+ isDST,
1447
+ isDuration,
1448
+ isEqual,
1449
+ isInstant,
1450
+ isLeapMonth,
1451
+ isLeapYear,
1452
+ isMod,
1453
+ isPlainDate,
1454
+ isPlainDateTime,
1455
+ isPlainMonthDay,
1456
+ isPlainTime,
1457
+ isPlainYearMonth,
1458
+ isSameDay,
1459
+ isSameMonth,
1460
+ isSameQuarter,
1461
+ isSameWeek,
1462
+ isSameYear,
1463
+ isTemporal,
1464
+ isToday,
1465
+ isTomorrow,
1466
+ isValidFormat,
1467
+ isWeekday,
1468
+ isWeekend,
1469
+ isYesterday,
1470
+ isZonedDateTime,
1471
+ listRegisteredGrammars,
1472
+ listTokens,
1473
+ max,
1474
+ mergeIntervals,
1475
+ mergeWithConfig,
1476
+ min,
1477
+ monthsInYear,
1478
+ nextBusinessDay,
1479
+ nextHoliday,
1480
+ overlaps,
1481
+ parse,
1482
+ parseDuration,
1483
+ parseHTTPDate,
1484
+ parseISO,
1485
+ parseISODuration,
1486
+ parseRFC2822,
1487
+ parseRFC3339,
1488
+ parseRRule,
1489
+ parseRelative,
1490
+ parseSQL,
1491
+ parseToParts,
1492
+ possibleInstantsFor,
1493
+ previewFormat,
1494
+ previousBusinessDay,
1495
+ previousHoliday,
1496
+ recurrence,
1497
+ registerLocale,
1498
+ registerLocaleVocab,
1499
+ registerRelativeGrammar,
1500
+ resolveZoned,
1501
+ round,
1502
+ roundDuration,
1503
+ roundDuration as roundDurationAlias,
1504
+ safeParse,
1505
+ setTemporal,
1506
+ skip,
1507
+ splitInterval,
1508
+ startOf,
1509
+ subtract2 as subtract,
1510
+ subtractBusinessDays,
1511
+ subtractDays,
1512
+ subtractDuration,
1513
+ subtractHours,
1514
+ subtractMilliseconds,
1515
+ subtractMinutes,
1516
+ subtractMonths,
1517
+ subtractSeconds,
1518
+ subtractWeeks,
1519
+ subtractYears,
1520
+ take,
1521
+ toUnixMicroseconds,
1522
+ toUnixMilliseconds,
1523
+ toUnixNanoseconds,
1524
+ toUnixSeconds,
1525
+ tokenInfo,
1526
+ tokenizeFormat,
1527
+ totalDuration,
1528
+ translateDateFnsFormatString,
1529
+ translateDayjsFormatString,
1530
+ truncate,
1531
+ tryParse,
1532
+ union,
1533
+ validateFormat,
1534
+ weekOfYear,
1535
+ weekYear
1536
+ };
59
1537
  //# sourceMappingURL=index.js.map