solve-engine 2.28.0 → 2.29.0

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 (152) hide show
  1. package/dist/{EngineError-CA2tiVaI.d.cts → EngineError-CqGtaT_v.d.cts} +4 -0
  2. package/dist/{EngineError-CA2tiVaI.d.ts → EngineError-CqGtaT_v.d.ts} +4 -0
  3. package/dist/{Lexer-B62Hn9I-.d.ts → Lexer-CqFjYoRA.d.ts} +1 -1
  4. package/dist/{Lexer-DOXatsjO.d.cts → Lexer-sCI05tqO.d.cts} +1 -1
  5. package/dist/{PackageCompatibility-DW18LqED.d.cts → PackageCompatibility-Bn-T_xKW.d.cts} +1 -1
  6. package/dist/{PackageCompatibility-DT1IPlQx.d.ts → PackageCompatibility-phvSFP4f.d.ts} +1 -1
  7. package/dist/{PackageRegistry-CevYUzRn.d.cts → PackageRegistry-B-C1duZw.d.cts} +3 -3
  8. package/dist/{PackageRegistry-Dl9kNP14.d.ts → PackageRegistry-C78jVkI9.d.ts} +3 -3
  9. package/dist/{VMBuiltins-AIivGl0a.d.cts → VMBuiltins-BkKzhj6C.d.cts} +1 -1
  10. package/dist/{VMBuiltins-CbuFfIgQ.d.ts → VMBuiltins-Du9y8sEo.d.ts} +1 -1
  11. package/dist/{VMCheckpoints-BVrJwfZY.d.cts → VMCheckpoints-WdUQrdc9.d.cts} +1 -1
  12. package/dist/{VMCheckpoints-DFCl63K5.d.ts → VMCheckpoints-gvy_yxYh.d.ts} +1 -1
  13. package/dist/{WorkerError-DDtwl4oH.d.cts → WorkerError-CRoM8Ju1.d.cts} +1 -1
  14. package/dist/{WorkerError-BuO9MrRr.d.ts → WorkerError-DTrl3Jag.d.ts} +1 -1
  15. package/dist/{chunk-IEBWLNI5.js → chunk-2PGGPFF3.js} +2 -2
  16. package/dist/{chunk-IEBWLNI5.js.map → chunk-2PGGPFF3.js.map} +1 -1
  17. package/dist/{chunk-I6WGOM3C.js → chunk-3ZGFAE3Q.js} +2 -2
  18. package/dist/{chunk-I6WGOM3C.js.map → chunk-3ZGFAE3Q.js.map} +1 -1
  19. package/dist/{chunk-UMW5PO42.cjs → chunk-4DR5RBHQ.cjs} +2 -2
  20. package/dist/{chunk-UMW5PO42.cjs.map → chunk-4DR5RBHQ.cjs.map} +1 -1
  21. package/dist/{chunk-FSNBYRNA.cjs → chunk-4PILWX4F.cjs} +3 -3
  22. package/dist/{chunk-FSNBYRNA.cjs.map → chunk-4PILWX4F.cjs.map} +1 -1
  23. package/dist/{chunk-WXOJ3DS3.cjs → chunk-5AKT36UK.cjs} +2 -2
  24. package/dist/{chunk-WXOJ3DS3.cjs.map → chunk-5AKT36UK.cjs.map} +1 -1
  25. package/dist/{chunk-APU5LON7.js → chunk-6K6ZW4B6.js} +3 -3
  26. package/dist/{chunk-APU5LON7.js.map → chunk-6K6ZW4B6.js.map} +1 -1
  27. package/dist/{chunk-MKBB7IVN.cjs → chunk-7DJYS5PO.cjs} +2 -2
  28. package/dist/{chunk-MKBB7IVN.cjs.map → chunk-7DJYS5PO.cjs.map} +1 -1
  29. package/dist/{chunk-KYE5BWPN.cjs → chunk-A755LVPT.cjs} +2 -2
  30. package/dist/{chunk-KYE5BWPN.cjs.map → chunk-A755LVPT.cjs.map} +1 -1
  31. package/dist/{chunk-5J2XDCSV.cjs → chunk-A764BY7L.cjs} +2 -2
  32. package/dist/{chunk-5J2XDCSV.cjs.map → chunk-A764BY7L.cjs.map} +1 -1
  33. package/dist/{chunk-TTHCH7V2.cjs → chunk-AGCNMEP2.cjs} +2 -2
  34. package/dist/{chunk-TTHCH7V2.cjs.map → chunk-AGCNMEP2.cjs.map} +1 -1
  35. package/dist/{chunk-MONPHAHO.js → chunk-B2NL65FI.js} +2 -2
  36. package/dist/{chunk-MONPHAHO.js.map → chunk-B2NL65FI.js.map} +1 -1
  37. package/dist/{chunk-RRJ77SF6.js → chunk-CB3EXUM2.js} +2 -2
  38. package/dist/{chunk-RRJ77SF6.js.map → chunk-CB3EXUM2.js.map} +1 -1
  39. package/dist/{chunk-OKSAUK5C.js → chunk-CDE2ZUGG.js} +2 -2
  40. package/dist/{chunk-OKSAUK5C.js.map → chunk-CDE2ZUGG.js.map} +1 -1
  41. package/dist/{chunk-YLTNXYA7.cjs → chunk-CM2WM5CM.cjs} +2 -2
  42. package/dist/{chunk-YLTNXYA7.cjs.map → chunk-CM2WM5CM.cjs.map} +1 -1
  43. package/dist/chunk-CT3PD7L3.cjs +3 -0
  44. package/dist/chunk-CT3PD7L3.cjs.map +1 -0
  45. package/dist/{chunk-2YNRIT2L.cjs → chunk-DUFEONVN.cjs} +3 -3
  46. package/dist/{chunk-2YNRIT2L.cjs.map → chunk-DUFEONVN.cjs.map} +1 -1
  47. package/dist/{chunk-7ASISMXA.js → chunk-FXB5GCBT.js} +2 -2
  48. package/dist/{chunk-7ASISMXA.js.map → chunk-FXB5GCBT.js.map} +1 -1
  49. package/dist/{chunk-2RLNVS6G.js → chunk-G3POUURF.js} +2 -2
  50. package/dist/{chunk-2RLNVS6G.js.map → chunk-G3POUURF.js.map} +1 -1
  51. package/dist/{chunk-2G3AW6OQ.cjs → chunk-GWV273KZ.cjs} +2 -2
  52. package/dist/{chunk-2G3AW6OQ.cjs.map → chunk-GWV273KZ.cjs.map} +1 -1
  53. package/dist/{chunk-N22D5ZD4.js → chunk-IQVSCL2R.js} +3 -3
  54. package/dist/{chunk-N22D5ZD4.js.map → chunk-IQVSCL2R.js.map} +1 -1
  55. package/dist/{chunk-IIBR4LVH.cjs → chunk-IY3GI2AM.cjs} +4 -4
  56. package/dist/{chunk-IIBR4LVH.cjs.map → chunk-IY3GI2AM.cjs.map} +1 -1
  57. package/dist/{chunk-6T5HPIZX.js → chunk-KH4QXKLT.js} +2 -2
  58. package/dist/{chunk-6T5HPIZX.js.map → chunk-KH4QXKLT.js.map} +1 -1
  59. package/dist/{chunk-OLATJABN.js → chunk-LP3JYC3A.js} +2 -2
  60. package/dist/{chunk-OLATJABN.js.map → chunk-LP3JYC3A.js.map} +1 -1
  61. package/dist/{chunk-A7RRWNLE.js → chunk-NQFCXLEF.js} +2 -2
  62. package/dist/{chunk-A7RRWNLE.js.map → chunk-NQFCXLEF.js.map} +1 -1
  63. package/dist/{chunk-O5ZLOZPH.cjs → chunk-OM7NOHJF.cjs} +2 -2
  64. package/dist/{chunk-O5ZLOZPH.cjs.map → chunk-OM7NOHJF.cjs.map} +1 -1
  65. package/dist/{chunk-QXGKONTZ.cjs → chunk-P43SV4NJ.cjs} +3 -3
  66. package/dist/{chunk-QXGKONTZ.cjs.map → chunk-P43SV4NJ.cjs.map} +1 -1
  67. package/dist/{chunk-DDVDRWCK.js → chunk-PTXUWGRR.js} +3 -3
  68. package/dist/{chunk-DDVDRWCK.js.map → chunk-PTXUWGRR.js.map} +1 -1
  69. package/dist/{chunk-GWEINEJG.cjs → chunk-Q7TBBV62.cjs} +2 -2
  70. package/dist/{chunk-GWEINEJG.cjs.map → chunk-Q7TBBV62.cjs.map} +1 -1
  71. package/dist/{chunk-POIHAKBX.js → chunk-QOEO7CKE.js} +2 -2
  72. package/dist/{chunk-POIHAKBX.js.map → chunk-QOEO7CKE.js.map} +1 -1
  73. package/dist/chunk-RAFOQ4T5.cjs +2 -0
  74. package/dist/{chunk-5NQE5JMU.cjs.map → chunk-RAFOQ4T5.cjs.map} +1 -1
  75. package/dist/{chunk-Z5DA5UXY.js → chunk-RELMEWY6.js} +2 -2
  76. package/dist/chunk-RELMEWY6.js.map +1 -0
  77. package/dist/{chunk-Z5VBXZ4A.js → chunk-SFM4XFGJ.js} +2 -2
  78. package/dist/{chunk-Z5VBXZ4A.js.map → chunk-SFM4XFGJ.js.map} +1 -1
  79. package/dist/{chunk-HTAT4MGN.cjs → chunk-SUAGBRQ7.cjs} +2 -2
  80. package/dist/chunk-SUAGBRQ7.cjs.map +1 -0
  81. package/dist/chunk-SYJAH6CD.js +3 -0
  82. package/dist/chunk-SYJAH6CD.js.map +1 -0
  83. package/dist/{chunk-JHHSQ2YR.js → chunk-TBAUKHEC.js} +3 -3
  84. package/dist/{chunk-JHHSQ2YR.js.map → chunk-TBAUKHEC.js.map} +1 -1
  85. package/dist/{chunk-7ZYYWSLT.js → chunk-VLX7ZVK4.js} +2 -2
  86. package/dist/{chunk-7ZYYWSLT.js.map → chunk-VLX7ZVK4.js.map} +1 -1
  87. package/dist/{chunk-W5BBKLNS.cjs → chunk-WQGHJAW2.cjs} +2 -2
  88. package/dist/{chunk-W5BBKLNS.cjs.map → chunk-WQGHJAW2.cjs.map} +1 -1
  89. package/dist/{chunk-U7CNADCJ.cjs → chunk-WU7SBKVU.cjs} +2 -2
  90. package/dist/{chunk-U7CNADCJ.cjs.map → chunk-WU7SBKVU.cjs.map} +1 -1
  91. package/dist/{chunk-LV7PJ2MU.js → chunk-X5K72MBV.js} +2 -2
  92. package/dist/{chunk-LV7PJ2MU.js.map → chunk-X5K72MBV.js.map} +1 -1
  93. package/dist/{chunk-IAL64FCP.js → chunk-YN5H54GM.js} +2 -2
  94. package/dist/{chunk-IAL64FCP.js.map → chunk-YN5H54GM.js.map} +1 -1
  95. package/dist/{chunk-UBKWHRFL.cjs → chunk-YWF6C2IO.cjs} +2 -2
  96. package/dist/{chunk-UBKWHRFL.cjs.map → chunk-YWF6C2IO.cjs.map} +1 -1
  97. package/dist/{chunk-RVNW627Y.cjs → chunk-ZBMWLTE6.cjs} +2 -2
  98. package/dist/{chunk-RVNW627Y.cjs.map → chunk-ZBMWLTE6.cjs.map} +1 -1
  99. package/dist/constants.cjs +1 -1
  100. package/dist/constants.js +1 -1
  101. package/dist/engine.cjs +1 -1
  102. package/dist/engine.d.cts +6 -6
  103. package/dist/engine.d.ts +6 -6
  104. package/dist/engine.js +1 -1
  105. package/dist/errors.cjs +1 -1
  106. package/dist/errors.d.cts +3 -3
  107. package/dist/errors.d.ts +3 -3
  108. package/dist/errors.js +1 -1
  109. package/dist/format.cjs +1 -1
  110. package/dist/format.js +1 -1
  111. package/dist/index.cjs +1 -1
  112. package/dist/index.d.cts +6 -6
  113. package/dist/index.d.ts +6 -6
  114. package/dist/index.js +1 -1
  115. package/dist/language.d.cts +5 -5
  116. package/dist/language.d.ts +5 -5
  117. package/dist/lexer.cjs +1 -1
  118. package/dist/lexer.d.cts +3 -3
  119. package/dist/lexer.d.ts +3 -3
  120. package/dist/lexer.js +1 -1
  121. package/dist/normalizer.cjs +1 -1
  122. package/dist/normalizer.js +1 -1
  123. package/dist/packages.cjs +1 -1
  124. package/dist/packages.d.cts +4 -4
  125. package/dist/packages.d.ts +4 -4
  126. package/dist/packages.js +1 -1
  127. package/dist/parser.cjs +1 -1
  128. package/dist/parser.js +1 -1
  129. package/dist/temporal.cjs +1 -1
  130. package/dist/temporal.js +1 -1
  131. package/dist/testing.cjs +2 -2
  132. package/dist/testing.d.cts +5 -5
  133. package/dist/testing.d.ts +5 -5
  134. package/dist/testing.js +1 -1
  135. package/dist/uom.cjs +1 -1
  136. package/dist/uom.js +1 -1
  137. package/dist/vm.cjs +1 -1
  138. package/dist/vm.d.cts +3 -3
  139. package/dist/vm.d.ts +3 -3
  140. package/dist/vm.js +1 -1
  141. package/dist/worker.cjs +2 -2
  142. package/dist/worker.d.cts +5 -5
  143. package/dist/worker.d.ts +5 -5
  144. package/dist/worker.js +1 -1
  145. package/package.json +1 -1
  146. package/dist/chunk-3LWK33TJ.js +0 -3
  147. package/dist/chunk-3LWK33TJ.js.map +0 -1
  148. package/dist/chunk-5NQE5JMU.cjs +0 -2
  149. package/dist/chunk-HTAT4MGN.cjs.map +0 -1
  150. package/dist/chunk-YIXCPLCN.cjs +0 -3
  151. package/dist/chunk-YIXCPLCN.cjs.map +0 -1
  152. package/dist/chunk-Z5DA5UXY.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import {b,m,n}from'./chunk-J4K72CQN.js';import {c,r}from'./chunk-Z5DA5UXY.js';function x(m,n,e){let r=Math.trunc(m),o=Math.trunc(n),a=Math.trunc(e);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(a))return Number.NaN;let t=r+Math.floor(o/12),i=(o%12+12)%12+1,s=t-(i<=2?1:0),l=Math.floor(s/400),u=s-l*400,N=Math.floor((153*(i+(i>2?-3:9))+2)/5),c=u*365+Math.floor(u/4)-Math.floor(u/100)+N;return l*146097+c-719468+(a-1)}function F(m){if(!Number.isFinite(m))return {year:Number.NaN,month0:Number.NaN,day:Number.NaN};let n=Math.trunc(m)+719468,e=Math.floor(n/146097),r=n-e*146097,o=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),a=r-(365*o+Math.floor(o/4)-Math.floor(o/100)),t=Math.floor((5*a+2)/153),i=a-Math.floor((153*t+2)/5)+1,s=t<10?t+3:t-9;return {year:o+e*400+(s<=2?1:0),month0:s-1,day:i}}var P=Object.freeze({year:Number.NaN,month0:Number.NaN,day:Number.NaN,weekday:Number.NaN,hour:Number.NaN,minute:Number.NaN,second:Number.NaN,millisecond:Number.NaN}),Z=864e13,d=864e5;function D(m){return !Number.isFinite(m)||Math.abs(m)>Z?Number.NaN:Math.trunc(m)}function z(m,n,e,r,o,a,t){let i=Math.trunc(r)*36e5+Math.trunc(o)*6e4+Math.trunc(a)*1e3+Math.trunc(t);return {dayNumber:x(m,n,e)+Math.floor(i/d),timeOfDay:(i%d+d)%d}}var S=/^([+-]\d{6}|\d{4})(?:-(\d{2})(?:-(\d{2}))?)?(?:[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?([Zz]|[+-]\d{2}:?\d{2})?$/,k=class{constructor(n,e={}){A(n),this.temporal=n;let r$1=e.timeZone??n.Now.timeZoneId(),o;try{o=n.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(r$1);}catch(a){throw c.config(r.TEMPORAL_TIME_ZONE_UNKNOWN,`The Temporal implementation does not know the time zone "${r$1}"`,{timeZone:r$1,cause:a instanceof Error?a.message:String(a)})}this.timeZone=o.timeZoneId,this.clock=e.now??(()=>n.Now.instant().epochMilliseconds);}now(){return this.clock()}fields(n){let e=this.zoned(n,this.timeZone);return e===null?P:{year:e.year,month0:e.month-1,day:e.day,weekday:e.dayOfWeek%7,hour:e.hour,minute:e.minute,second:e.second,millisecond:e.millisecond}}localMidnight(n,e,r){return this.wallClock(n,e,r,0,0,0,0)}localWallClock(n,e,r,o){let a=this.localMidnight(n,e,r),t=this.fields(a);return Number.isNaN(t.year)?Number.NaN:this.wallClock(t.year,t.month0,t.day,t.hour,o,t.second,t.millisecond)}addDays(n,e){let r=this.fields(n);return Number.isNaN(r.year)?Number.NaN:this.wallClock(r.year,r.month0,r.day+e,r.hour,r.minute,r.second,r.millisecond)}addMonths(n,e){let r=this.fields(n);if(Number.isNaN(r.year))return Number.NaN;let o=r.day,a=this.fields(this.wallClock(r.year,r.month0,1,r.hour,r.minute,r.second,r.millisecond));if(Number.isNaN(a.year))return Number.NaN;let t=this.fields(this.wallClock(a.year,a.month0+e,a.day,a.hour,a.minute,a.second,a.millisecond));if(Number.isNaN(t.year))return Number.NaN;let i=Math.min(o,b(t.year,t.month0));return this.wallClock(t.year,t.month0,i,t.hour,t.minute,t.second,t.millisecond)}utcOffsetMinutes(n){let e=this.zoned(n,this.timeZone);return e===null?Number.NaN:Math.trunc(e.offsetNanoseconds/6e10)||0}parseIso8601(n){let e=S.exec(n);if(e===null)return Number.NaN;let[,r,o,a,t,i,s,l,u]=e;if(r==="-000000")return Number.NaN;let N=Number(r),c=o===void 0?1:Number(o),f=a===void 0?1:Number(a),b=t===void 0?0:Number(t),h=i===void 0?0:Number(i),y=s===void 0?0:Number(s),I=l===void 0?0:Number(l.slice(0,3).padEnd(3,"0"));if(c<1||c>12||f<1||f>31||b>24||h>59||y>59||b===24&&(h!==0||y!==0||I!==0))return Number.NaN;let p=z(N,c-1,f,b,h,y,I);if(u===void 0&&t!==void 0)return this.resolve(p);let g=0;if(u!==void 0&&u!=="Z"&&u!=="z"){let _=u.slice(1).replace(":",""),w=Number(_.slice(0,2)),C=Number(_.slice(2,4));if(w>23||C>59)return Number.NaN;g=(u[0]==="-"?-1:1)*(w*60+C);}let O=p.dayNumber*d+p.timeOfDay-g*6e4;return Math.abs(O)>Z?Number.NaN:O}formatLongDate(n,e){let r=D(n);return Number.isNaN(r)?"Invalid Date":new Intl.DateTimeFormat(e,{timeZone:this.timeZone,weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(r)}formatTimeOfDay(n,e){let r=D(n);return Number.isNaN(r)?"Invalid Date":new Intl.DateTimeFormat(e,{timeZone:this.timeZone,hour:"numeric",minute:"numeric",second:"numeric"}).format(r)}zoneOffsetMinutes(n,e){let r=Number.isFinite(e)?Math.trunc(e):e,o=this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(n),a=Math.floor((r+o.offsetNanoseconds/1e6)/1e3)*1e3;return Math.round((a-e)/6e4)||0}fieldsInZone(n,e){let r=Number.isFinite(e)?Math.trunc(e):e,o=this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(n);return {year:o.year,month0:o.month-1,day:o.day,hour:o.hour,minute:o.minute,second:o.second}}zone(){return this.timeZone}formatTimeInZone(n,e){return m(n,e)}formatDateInZone(n$1,e){return n(n$1,e)}zoned(n,e){let r=D(n);if(Number.isNaN(r))return null;try{return this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(e)}catch{return null}}wallClock(n,e,r,o,a,t,i){let s=n>=0&&n<=99?1900+Math.trunc(n):n;return this.resolve(z(s,e,r,o,a,t,i))}resolve(n){let e=F(n.dayNumber);if(Number.isNaN(e.year))return Number.NaN;let r=Math.floor(n.timeOfDay/36e5),o=Math.floor(n.timeOfDay/6e4)%60,a=Math.floor(n.timeOfDay/1e3)%60,t=n.timeOfDay%1e3;try{let s=this.temporal.PlainDateTime.from({year:e.year,month:e.month0+1,day:e.day,hour:r,minute:o,second:a,millisecond:t},{overflow:"reject"}).toZonedDateTime(this.timeZone,{disambiguation:"compatible"}).epochMilliseconds;return Math.abs(s)>Z?Number.NaN:s}catch{return Number.NaN}}};function A(m){let n=m,e=typeof n?.Now?.instant!="function"?"Now.instant":typeof n?.Now?.timeZoneId!="function"?"Now.timeZoneId":typeof n?.Instant?.fromEpochMilliseconds!="function"?"Instant.fromEpochMilliseconds":typeof n?.PlainDateTime?.from!="function"?"PlainDateTime.from":null;if(e!==null)throw c.config(r.TEMPORAL_IMPLEMENTATION_INVALID,`createTemporalCalendar needs a Temporal implementation (globalThis.Temporal on a runtime that ships it, or a polyfill's export); the value given has no ${e}`,{missing:e})}function q(m,n={}){return new k(m,n)}export{k as a,q as b};//# sourceMappingURL=chunk-I6WGOM3C.js.map
2
- //# sourceMappingURL=chunk-I6WGOM3C.js.map
1
+ import {b,m,n}from'./chunk-J4K72CQN.js';import {c,r}from'./chunk-RELMEWY6.js';function x(m,n,e){let r=Math.trunc(m),o=Math.trunc(n),a=Math.trunc(e);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(a))return Number.NaN;let t=r+Math.floor(o/12),i=(o%12+12)%12+1,s=t-(i<=2?1:0),l=Math.floor(s/400),u=s-l*400,N=Math.floor((153*(i+(i>2?-3:9))+2)/5),c=u*365+Math.floor(u/4)-Math.floor(u/100)+N;return l*146097+c-719468+(a-1)}function F(m){if(!Number.isFinite(m))return {year:Number.NaN,month0:Number.NaN,day:Number.NaN};let n=Math.trunc(m)+719468,e=Math.floor(n/146097),r=n-e*146097,o=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),a=r-(365*o+Math.floor(o/4)-Math.floor(o/100)),t=Math.floor((5*a+2)/153),i=a-Math.floor((153*t+2)/5)+1,s=t<10?t+3:t-9;return {year:o+e*400+(s<=2?1:0),month0:s-1,day:i}}var P=Object.freeze({year:Number.NaN,month0:Number.NaN,day:Number.NaN,weekday:Number.NaN,hour:Number.NaN,minute:Number.NaN,second:Number.NaN,millisecond:Number.NaN}),Z=864e13,d=864e5;function D(m){return !Number.isFinite(m)||Math.abs(m)>Z?Number.NaN:Math.trunc(m)}function z(m,n,e,r,o,a,t){let i=Math.trunc(r)*36e5+Math.trunc(o)*6e4+Math.trunc(a)*1e3+Math.trunc(t);return {dayNumber:x(m,n,e)+Math.floor(i/d),timeOfDay:(i%d+d)%d}}var S=/^([+-]\d{6}|\d{4})(?:-(\d{2})(?:-(\d{2}))?)?(?:[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?([Zz]|[+-]\d{2}:?\d{2})?$/,k=class{constructor(n,e={}){A(n),this.temporal=n;let r$1=e.timeZone??n.Now.timeZoneId(),o;try{o=n.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(r$1);}catch(a){throw c.config(r.TEMPORAL_TIME_ZONE_UNKNOWN,`The Temporal implementation does not know the time zone "${r$1}"`,{timeZone:r$1,cause:a instanceof Error?a.message:String(a)})}this.timeZone=o.timeZoneId,this.clock=e.now??(()=>n.Now.instant().epochMilliseconds);}now(){return this.clock()}fields(n){let e=this.zoned(n,this.timeZone);return e===null?P:{year:e.year,month0:e.month-1,day:e.day,weekday:e.dayOfWeek%7,hour:e.hour,minute:e.minute,second:e.second,millisecond:e.millisecond}}localMidnight(n,e,r){return this.wallClock(n,e,r,0,0,0,0)}localWallClock(n,e,r,o){let a=this.localMidnight(n,e,r),t=this.fields(a);return Number.isNaN(t.year)?Number.NaN:this.wallClock(t.year,t.month0,t.day,t.hour,o,t.second,t.millisecond)}addDays(n,e){let r=this.fields(n);return Number.isNaN(r.year)?Number.NaN:this.wallClock(r.year,r.month0,r.day+e,r.hour,r.minute,r.second,r.millisecond)}addMonths(n,e){let r=this.fields(n);if(Number.isNaN(r.year))return Number.NaN;let o=r.day,a=this.fields(this.wallClock(r.year,r.month0,1,r.hour,r.minute,r.second,r.millisecond));if(Number.isNaN(a.year))return Number.NaN;let t=this.fields(this.wallClock(a.year,a.month0+e,a.day,a.hour,a.minute,a.second,a.millisecond));if(Number.isNaN(t.year))return Number.NaN;let i=Math.min(o,b(t.year,t.month0));return this.wallClock(t.year,t.month0,i,t.hour,t.minute,t.second,t.millisecond)}utcOffsetMinutes(n){let e=this.zoned(n,this.timeZone);return e===null?Number.NaN:Math.trunc(e.offsetNanoseconds/6e10)||0}parseIso8601(n){let e=S.exec(n);if(e===null)return Number.NaN;let[,r,o,a,t,i,s,l,u]=e;if(r==="-000000")return Number.NaN;let N=Number(r),c=o===void 0?1:Number(o),f=a===void 0?1:Number(a),b=t===void 0?0:Number(t),h=i===void 0?0:Number(i),y=s===void 0?0:Number(s),I=l===void 0?0:Number(l.slice(0,3).padEnd(3,"0"));if(c<1||c>12||f<1||f>31||b>24||h>59||y>59||b===24&&(h!==0||y!==0||I!==0))return Number.NaN;let p=z(N,c-1,f,b,h,y,I);if(u===void 0&&t!==void 0)return this.resolve(p);let g=0;if(u!==void 0&&u!=="Z"&&u!=="z"){let _=u.slice(1).replace(":",""),w=Number(_.slice(0,2)),C=Number(_.slice(2,4));if(w>23||C>59)return Number.NaN;g=(u[0]==="-"?-1:1)*(w*60+C);}let O=p.dayNumber*d+p.timeOfDay-g*6e4;return Math.abs(O)>Z?Number.NaN:O}formatLongDate(n,e){let r=D(n);return Number.isNaN(r)?"Invalid Date":new Intl.DateTimeFormat(e,{timeZone:this.timeZone,weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(r)}formatTimeOfDay(n,e){let r=D(n);return Number.isNaN(r)?"Invalid Date":new Intl.DateTimeFormat(e,{timeZone:this.timeZone,hour:"numeric",minute:"numeric",second:"numeric"}).format(r)}zoneOffsetMinutes(n,e){let r=Number.isFinite(e)?Math.trunc(e):e,o=this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(n),a=Math.floor((r+o.offsetNanoseconds/1e6)/1e3)*1e3;return Math.round((a-e)/6e4)||0}fieldsInZone(n,e){let r=Number.isFinite(e)?Math.trunc(e):e,o=this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(n);return {year:o.year,month0:o.month-1,day:o.day,hour:o.hour,minute:o.minute,second:o.second}}zone(){return this.timeZone}formatTimeInZone(n,e){return m(n,e)}formatDateInZone(n$1,e){return n(n$1,e)}zoned(n,e){let r=D(n);if(Number.isNaN(r))return null;try{return this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(e)}catch{return null}}wallClock(n,e,r,o,a,t,i){let s=n>=0&&n<=99?1900+Math.trunc(n):n;return this.resolve(z(s,e,r,o,a,t,i))}resolve(n){let e=F(n.dayNumber);if(Number.isNaN(e.year))return Number.NaN;let r=Math.floor(n.timeOfDay/36e5),o=Math.floor(n.timeOfDay/6e4)%60,a=Math.floor(n.timeOfDay/1e3)%60,t=n.timeOfDay%1e3;try{let s=this.temporal.PlainDateTime.from({year:e.year,month:e.month0+1,day:e.day,hour:r,minute:o,second:a,millisecond:t},{overflow:"reject"}).toZonedDateTime(this.timeZone,{disambiguation:"compatible"}).epochMilliseconds;return Math.abs(s)>Z?Number.NaN:s}catch{return Number.NaN}}};function A(m){let n=m,e=typeof n?.Now?.instant!="function"?"Now.instant":typeof n?.Now?.timeZoneId!="function"?"Now.timeZoneId":typeof n?.Instant?.fromEpochMilliseconds!="function"?"Instant.fromEpochMilliseconds":typeof n?.PlainDateTime?.from!="function"?"PlainDateTime.from":null;if(e!==null)throw c.config(r.TEMPORAL_IMPLEMENTATION_INVALID,`createTemporalCalendar needs a Temporal implementation (globalThis.Temporal on a runtime that ships it, or a polyfill's export); the value given has no ${e}`,{missing:e})}function q(m,n={}){return new k(m,n)}export{k as a,q as b};//# sourceMappingURL=chunk-3ZGFAE3Q.js.map
2
+ //# sourceMappingURL=chunk-3ZGFAE3Q.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/temporal/CivilDays.ts","../src/temporal/TemporalCalendar.ts"],"names":["civilDayNumber","year","month0","day","y0","m0","d","y","m","shiftedYear","era","yearOfEra","dayOfYear","dayOfEra","civilFromDayNumber","days","z","monthFromMarch","month","NAN_FIELDS","MAX_INSTANT","MS_PER_DAY","clip","epochMs","normaliseWallClock","hour","minute","second","millisecond","time","ISO_DATE_TIME","TemporalCalendar","temporal","options","assertTemporalLike","requested","probe","error","ErrorFactory","CoreErrorCodes","minutesPastMidnight","anchored","a","f","months","f0","dayOfMonth","f1","f2","daysInMonth","text","yearText","monthText","dayText","hourText","minuteText","secondText","fractionText","zoneText","wall","offsetMinutes","digits","offsetHours","offsetMinutesPart","instant","locale","t","zone","wallSecond","timeInZone","dateInZone","windowed","civil","candidate","missing","createTemporalCalendar"],"mappings":"8EAkDO,SAASA,EAAeC,CAAAA,CAAcC,CAAAA,CAAgBC,CAAAA,CAAqB,CACjF,IAAMC,CAAAA,CAAK,IAAA,CAAK,KAAA,CAAMH,CAAI,EACpBI,CAAAA,CAAK,IAAA,CAAK,KAAA,CAAMH,CAAM,EACtBI,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMH,CAAG,EACxB,GAAI,CAAC,MAAA,CAAO,QAAA,CAASC,CAAE,CAAA,EAAK,CAAC,MAAA,CAAO,QAAA,CAASC,CAAE,CAAA,EAAK,CAAC,OAAO,QAAA,CAASC,CAAC,EAAG,OAAO,MAAA,CAAO,GAAA,CAGvF,IAAMC,EAAIH,CAAAA,CAAK,IAAA,CAAK,KAAA,CAAMC,CAAAA,CAAK,EAAE,CAAA,CAC3BG,CAAAA,CAAAA,CAAMH,CAAAA,CAAK,EAAA,CAAM,IAAM,EAAA,CAAK,CAAA,CAG5BI,EAAcF,CAAAA,EAAKC,CAAAA,EAAK,EAAI,CAAA,CAAI,CAAA,CAAA,CAChCE,CAAAA,CAAM,IAAA,CAAK,MAAMD,CAAAA,CAAc,GAAG,CAAA,CAClCE,CAAAA,CAAYF,EAAcC,CAAAA,CAAM,GAAA,CAChCE,CAAAA,CAAY,IAAA,CAAK,OAAO,GAAA,EAAOJ,CAAAA,EAAKA,EAAI,CAAA,CAAI,EAAA,CAAK,IAAM,CAAA,EAAK,CAAC,CAAA,CAC7DK,CAAAA,CAAWF,EAAY,GAAA,CAAM,IAAA,CAAK,KAAA,CAAMA,CAAAA,CAAY,C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D,CAChF,IAAMyC,CAAAA,CAAYzC,CAAAA,CACZ0C,CAAAA,CACL,OAAOD,CAAAA,EAAW,GAAA,EAAK,OAAA,EAAY,UAAA,CAAa,cAChD,OAAOA,CAAAA,EAAW,KAAK,UAAA,EAAe,UAAA,CAAa,iBACnD,OAAOA,CAAAA,EAAW,OAAA,EAAS,qBAAA,EAA0B,WAAa,+BAAA,CAClE,OAAOA,CAAAA,EAAW,aAAA,EAAe,MAAS,UAAA,CAAa,oBAAA,CACvD,IAAA,CACD,GAAIC,IAAY,IAAA,CACf,MAAMpC,EAAa,MAAA,CAClBC,CAAAA,CAAe,gCACf,CAAA,wJAAA,EAA2JmC,CAAO,CAAA,CAAA,CAClK,CAAE,QAAAA,CAAQ,CACX,CAEF,CAoBO,SAASC,CAAAA,CAAuB3C,CAAAA,CAAwBC,CAAAA,CAAmC,GAAsB,CACvH,OAAO,IAAIF,CAAAA,CAAiBC,CAAAA,CAAUC,CAAO,CAC9C","file":"chunk-I6WGOM3C.js","sourcesContent":["/**\n * The day arithmetic behind `Date`'s field normalisation, for the `Temporal`\n * backend.\n *\n * `Date` normalises a set of wall-clock fields before it resolves them in a\n * zone: month 13 rolls into the next year, day 0 into the month before, a\n * time past midnight into the next day, and only the final instant is\n * clipped to the range `Date` represents. That is the `MakeDay` and\n * `MakeTime` order of the ECMAScript specification, and a backend built on\n * another library has to follow it to answer what `Date` answers on the last\n * representable day and for a rolled-over literal. `Date` does this\n * arithmetic inside its own setters, where a second backend cannot reach it,\n * so it is written out here with nothing clipped.\n *\n * Under `temporal/` rather than `calendar/Gregorian.ts` because only the\n * `Temporal` backend needs it: the `Date` backend gets the same arithmetic\n * from `Date` itself, and keeping it here keeps it out of the root entry's\n * bundle. The unit spec measures it against `Date.UTC` and `setUTCFullYear`\n * wherever `Date` can represent the date.\n *\n * @module CivilDays\n */\n\n/** A calendar date as year, zero-based month and day, the shape the civil-day arithmetic exchanges. */\nexport interface CivilDate {\n\treadonly year: number;\n\t/** Zero-based month: 0 is January, 11 is December. */\n\treadonly month0: number;\n\t/** Day of the month, from 1. */\n\treadonly day: number;\n}\n\n/**\n * The day number of a calendar date, counted from 1 January 1970, by\n * arithmetic alone: no `Date`, so no clip to the range `Date` represents.\n *\n * This is the `MakeDay` step of the ECMAScript specification, which a\n * backend needs unclipped: `Date` normalises a set of fields (month 13, day\n * 0, a time past midnight) before it resolves them in a zone and clips the\n * result, so a wall-clock time on the last representable day is an instant,\n * not `NaN`, and a backend built on another library must follow the same\n * order. An overflowing month or day rolls into the adjacent year or month,\n * as {@link utcMs}'s do, and a fractional field is truncated, as `Date`\n * truncates it.\n *\n * @param year - The calendar year, read as written.\n * @param month0 - Zero-based month; overflow rolls into the adjacent year.\n * @param day - Day of the month; overflow rolls into the adjacent month.\n * @returns Whole days since 1 January 1970, negative before it, or `NaN` when a field is not finite.\n */\nexport function civilDayNumber(year: number, month0: number, day: number): number {\n\tconst y0 = Math.trunc(year);\n\tconst m0 = Math.trunc(month0);\n\tconst d = Math.trunc(day);\n\tif (!Number.isFinite(y0) || !Number.isFinite(m0) || !Number.isFinite(d)) return Number.NaN;\n\t// Normalise the month into the year first, then count from the first of\n\t// that month, so a day of 0 or 40 is a plain offset from a real month.\n\tconst y = y0 + Math.floor(m0 / 12);\n\tconst m = ((m0 % 12) + 12) % 12 + 1;\n\t// The days-from-civil arithmetic, with the year taken to start in March\n\t// so a leap day is the last day of the cycle rather than an exception.\n\tconst shiftedYear = y - (m <= 2 ? 1 : 0);\n\tconst era = Math.floor(shiftedYear / 400);\n\tconst yearOfEra = shiftedYear - era * 400;\n\tconst dayOfYear = Math.floor((153 * (m + (m > 2 ? -3 : 9)) + 2) / 5);\n\tconst dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;\n\treturn era * 146_097 + dayOfEra - 719_468 + (d - 1);\n}\n\n/**\n * The calendar date of a day number, the inverse of {@link civilDayNumber}.\n *\n * @param days - Whole days since 1 January 1970, negative before it.\n * @returns The date, or `NaN` in every field when `days` is not finite.\n */\nexport function civilFromDayNumber(days: number): CivilDate {\n\tif (!Number.isFinite(days)) return { year: Number.NaN, month0: Number.NaN, day: Number.NaN };\n\tconst z = Math.trunc(days) + 719_468;\n\tconst era = Math.floor(z / 146_097);\n\tconst dayOfEra = z - era * 146_097;\n\tconst yearOfEra = Math.floor((dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36_524) - Math.floor(dayOfEra / 146_096)) / 365);\n\tconst dayOfYear = dayOfEra - (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));\n\tconst monthFromMarch = Math.floor((5 * dayOfYear + 2) / 153);\n\tconst day = dayOfYear - Math.floor((153 * monthFromMarch + 2) / 5) + 1;\n\tconst month = monthFromMarch < 10 ? monthFromMarch + 3 : monthFromMarch - 9;\n\tconst year = yearOfEra + era * 400 + (month <= 2 ? 1 : 0);\n\treturn { year, month0: month - 1, day };\n}\n","/**\n * The `Temporal` calendar backend: the engine's date questions answered\n * through a `Temporal` implementation the host supplies, in a time zone the\n * host chooses.\n *\n * `Temporal` is the JavaScript standard library's replacement for `Date`. It\n * ships unflagged in Node 26 and in current Chrome, Firefox and Deno, but not\n * in Safari nor in Node 22 and 24, and the smallest polyfill adds about twenty\n * kilobytes gzipped to a bundle. The engine therefore imports no `Temporal`\n * and no polyfill: this module is reached only through the\n * `solve-engine/temporal` entry, and the host hands it the implementation to\n * use, `globalThis.Temporal` on a runtime that has one or a polyfill's export.\n * A host that never imports the entry pays nothing for it.\n *\n * The backend answers exactly what the `Date` backend answers. That is a\n * design constraint rather than a hope: `Temporal` and `Date` differ in what\n * they do with an out-of-range instant (`RangeError` against `NaN`), a\n * fractional millisecond (a throw against truncation), a day past the end of\n * a month (a clamp or a throw against a roll into the next month) and a year\n * from 0 to 99 (read literally against read as the 1900s), and every one of\n * those is reproduced here the way `Date` does it, because the engine's\n * results are measured against `Date` and a host switching backends must see\n * no result move. The differential suite under `__tests__/temporal/` is what\n * holds that line.\n *\n * The one thing that does change is the zone. `Date` reads the process's own\n * zone and nothing else; this backend reads the zone it was constructed with,\n * so a document can be computed in Tokyo from a server in London, or in a\n * zone the reader picks. That is the capability the backend adds, and the\n * only observable difference.\n *\n * The named-zone display strings go through the same `Intl.DateTimeFormat`\n * helpers the `Date` backend uses (`calendar/IntlZone.ts`), and the zone-free\n * arithmetic through `calendar/Gregorian.ts`, so the two backends share one\n * implementation wherever an answer does not depend on which backend is in\n * use. The one piece of arithmetic `Date` keeps inside its own setters, the\n * normalisation of overflowing fields, is written out in `CivilDays.ts`.\n *\n * @module TemporalCalendar\n */\n\nimport type { CalendarBackend, CalendarFields, ZonedFields } from \"@solve-js/calendar/CalendarBackend\";\nimport { daysInMonth } from \"@solve-js/calendar/Gregorian\";\nimport { civilDayNumber, civilFromDayNumber } from \"./CivilDays\";\nimport { dateInZone, timeInZone } from \"@solve-js/calendar/IntlZone\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { CoreErrorCodes } from \"@solve-js/errors/ErrorCode\";\n\n/**\n * The part of a `Temporal.Instant` the backend reads: its epoch milliseconds,\n * and the zoned date-time it shows in a named zone.\n */\nexport interface TemporalInstantLike {\n\treadonly epochMilliseconds: number;\n\ttoZonedDateTimeISO(timeZone: string): TemporalZonedDateTimeLike;\n}\n\n/**\n * The part of a `Temporal.ZonedDateTime` the backend reads: the calendar\n * fields (a one-based month and an ISO weekday, Monday 1 to Sunday 7, both\n * translated at the boundary), the offset, and the instant.\n */\nexport interface TemporalZonedDateTimeLike {\n\treadonly year: number;\n\t/** One-based month, 1 is January, as `Temporal` counts. */\n\treadonly month: number;\n\treadonly day: number;\n\t/** ISO weekday: Monday is 1, Sunday is 7. */\n\treadonly dayOfWeek: number;\n\treadonly hour: number;\n\treadonly minute: number;\n\treadonly second: number;\n\treadonly millisecond: number;\n\t/** The zone's offset from UTC at this instant, in nanoseconds, positive when ahead. */\n\treadonly offsetNanoseconds: number;\n\treadonly epochMilliseconds: number;\n\t/** The zone's canonical IANA identifier. */\n\treadonly timeZoneId: string;\n}\n\n/** The part of a `Temporal.PlainDateTime` the backend uses: resolving a wall-clock time to an instant in a zone. */\nexport interface TemporalPlainDateTimeLike {\n\ttoZonedDateTime(\n\t\ttimeZone: string,\n\t\toptions?: { disambiguation?: \"compatible\" | \"earlier\" | \"later\" | \"reject\" },\n\t): TemporalZonedDateTimeLike;\n}\n\n/** The wall-clock fields a `Temporal.PlainDateTime` is built from, with a one-based month. */\nexport interface TemporalDateTimeFields {\n\tyear: number;\n\t/** One-based month, 1 is January. */\n\tmonth: number;\n\tday: number;\n\thour: number;\n\tminute: number;\n\tsecond: number;\n\tmillisecond: number;\n}\n\n/**\n * The subset of the `Temporal` namespace the backend uses, as a structural\n * type, so the engine compiles and ships with no `Temporal` type installed\n * and a host passes whichever implementation it has: `globalThis.Temporal`\n * on Node 26 or a current browser, or the export of a polyfill such as\n * `temporal-polyfill`. Both satisfy this shape as they are.\n */\nexport interface TemporalLike {\n\treadonly Now: {\n\t\tinstant(): TemporalInstantLike;\n\t\ttimeZoneId(): string;\n\t};\n\treadonly Instant: {\n\t\tfromEpochMilliseconds(epochMilliseconds: number): TemporalInstantLike;\n\t};\n\treadonly PlainDateTime: {\n\t\tfrom(fields: TemporalDateTimeFields, options?: { overflow?: \"constrain\" | \"reject\" }): TemporalPlainDateTimeLike;\n\t};\n}\n\n/** What {@link createTemporalCalendar} takes beside the implementation. */\nexport interface TemporalCalendarOptions {\n\t/**\n\t * The IANA time zone the engine computes dates in (`\"Asia/Tokyo\"`,\n\t * `\"UTC\"`). Defaults to the runtime's own zone, `Temporal.Now.timeZoneId()`,\n\t * which is what the `Date` backend reads. A zone the implementation does\n\t * not know is refused at construction with `TEMPORAL_TIME_ZONE_UNKNOWN`.\n\t */\n\ttimeZone?: string;\n\t/**\n\t * The clock `now()` reads, in epoch milliseconds. Defaults to\n\t * `Temporal.Now.instant()`. A test pins a date with this: a fake-timer\n\t * library replaces `Date.now`, which the `Date` backend reads, but not\n\t * `Temporal.Now`, so this backend needs telling separately.\n\t */\n\tnow?: () => number;\n}\n\n/** The fields the `Date` backend answers for an instant it cannot represent. */\nconst NAN_FIELDS: CalendarFields = Object.freeze({\n\tyear: Number.NaN, month0: Number.NaN, day: Number.NaN, weekday: Number.NaN,\n\thour: Number.NaN, minute: Number.NaN, second: Number.NaN, millisecond: Number.NaN,\n});\n\n/** The largest magnitude `Date` represents, in milliseconds either side of the epoch. */\nconst MAX_INSTANT = 8.64e15;\n\n/** Milliseconds in a day of wall-clock fields, before any zone is consulted. */\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * An instant as `Date` would hold it: truncated to a whole millisecond, or\n * `NaN` when it is not finite or lies past the range `Date` represents. This\n * is `Date`'s own clip (its `TimeClip`), applied before an instant reaches\n * `Temporal`, which throws for both cases where `Date` answers `NaN`.\n */\nfunction clip(epochMs: number): number {\n\tif (!Number.isFinite(epochMs) || Math.abs(epochMs) > MAX_INSTANT) return Number.NaN;\n\treturn Math.trunc(epochMs);\n}\n\n/**\n * Wall-clock fields normalised the way `Date`'s `MakeDay` and `MakeTime`\n * normalise them, with nothing clipped: the day number of the date the\n * fields land on after any overflow rolls, and the time within that day.\n * Each field is truncated to an integer first, as `Date` truncates it.\n */\ninterface WallClock {\n\treadonly dayNumber: number;\n\treadonly timeOfDay: number;\n}\n\n/** `MakeDay` and `MakeTime`, then `MakeDate`, with a time past midnight carried into the day. */\nfunction normaliseWallClock(year: number, month0: number, day: number, hour: number, minute: number, second: number, millisecond: number): WallClock {\n\tconst time = Math.trunc(hour) * 3_600_000 + Math.trunc(minute) * 60_000 + Math.trunc(second) * 1_000 + Math.trunc(millisecond);\n\tconst dayNumber = civilDayNumber(year, month0, day) + Math.floor(time / MS_PER_DAY);\n\treturn { dayNumber, timeOfDay: ((time % MS_PER_DAY) + MS_PER_DAY) % MS_PER_DAY };\n}\n\n/**\n * The ECMAScript date-time string format, as the `Date` constructor reads it:\n * a four-digit or six-digit signed year, an optional month and day, an\n * optional time to the millisecond (longer fractions are truncated), and an\n * optional `Z` or offset. The `T` and `Z` may be lower case, and an offset\n * may omit its colon; both are what the runtime's parser accepts.\n */\nconst ISO_DATE_TIME =\n\t/^([+-]\\d{6}|\\d{4})(?:-(\\d{2})(?:-(\\d{2}))?)?(?:[Tt](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?)?([Zz]|[+-]\\d{2}:?\\d{2})?$/;\n\n/**\n * A {@link CalendarBackend} over a `Temporal` implementation, computing in\n * one named time zone. Build one with {@link createTemporalCalendar}.\n *\n * Every method answers what the `Date` backend answers for the same inputs\n * when the zone is the process's own; see the module comment for the\n * differences between `Temporal` and `Date` that are reproduced deliberately.\n * The local methods answer `NaN` for an instant or a date the backend cannot\n * represent and never throw; the four named-zone methods throw the runtime's\n * `RangeError` for a zone it does not know or an instant it cannot represent,\n * which is the contract the interface states.\n */\nexport class TemporalCalendar implements CalendarBackend {\n\t/** The IANA zone every local answer is computed in, in its canonical spelling. */\n\treadonly timeZone: string;\n\n\tprivate readonly temporal: TemporalLike;\n\tprivate readonly clock: () => number;\n\n\tconstructor(temporal: TemporalLike, options: TemporalCalendarOptions = {}) {\n\t\tassertTemporalLike(temporal);\n\t\tthis.temporal = temporal;\n\t\tconst requested = options.timeZone ?? temporal.Now.timeZoneId();\n\t\tlet probe: TemporalZonedDateTimeLike;\n\t\ttry {\n\t\t\tprobe = temporal.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(requested);\n\t\t} catch (error) {\n\t\t\tthrow ErrorFactory.config(\n\t\t\t\tCoreErrorCodes.TEMPORAL_TIME_ZONE_UNKNOWN,\n\t\t\t\t`The Temporal implementation does not know the time zone \"${requested}\"`,\n\t\t\t\t{ timeZone: requested, cause: error instanceof Error ? error.message : String(error) },\n\t\t\t);\n\t\t}\n\t\t// The canonical spelling, so a zone given as `asia/tokyo` reads back as\n\t\t// the identifier the implementation itself uses.\n\t\tthis.timeZone = probe.timeZoneId;\n\t\tthis.clock = options.now ?? (() => temporal.Now.instant().epochMilliseconds);\n\t}\n\n\tnow(): number {\n\t\treturn this.clock();\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst z = this.zoned(epochMs, this.timeZone);\n\t\tif (z === null) return NAN_FIELDS;\n\t\treturn {\n\t\t\tyear: z.year,\n\t\t\tmonth0: z.month - 1,\n\t\t\tday: z.day,\n\t\t\t// ISO's Monday 1 to Sunday 7 becomes Date's Sunday 0 to Saturday 6.\n\t\t\tweekday: z.dayOfWeek % 7,\n\t\t\thour: z.hour,\n\t\t\tminute: z.minute,\n\t\t\tsecond: z.second,\n\t\t\tmillisecond: z.millisecond,\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn this.wallClock(year, month0, day, 0, 0, 0, 0);\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// `Date`'s sequence exactly: anchor at midnight, then set the minutes\n\t\t// FIELD, which reads the hour, second and millisecond back from the\n\t\t// anchored local time. On a day whose midnight falls in a\n\t\t// daylight-saving gap the anchor resolves to 1 am, and the hour it\n\t\t// reads back is 1, which is what makes the two backends agree there.\n\t\tconst anchored = this.localMidnight(year, month0, day);\n\t\tconst a = this.fields(anchored);\n\t\tif (Number.isNaN(a.year)) return Number.NaN;\n\t\treturn this.wallClock(a.year, a.month0, a.day, a.hour, minutesPastMidnight, a.second, a.millisecond);\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\t// `setDate()`: the day field moves and the local time of day is held.\n\t\tconst f = this.fields(epochMs);\n\t\tif (Number.isNaN(f.year)) return Number.NaN;\n\t\treturn this.wallClock(f.year, f.month0, f.day + days, f.hour, f.minute, f.second, f.millisecond);\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\t// The `Date` backend's three field writes, each resolved to an instant\n\t\t// and read back before the next, so that a wall-clock time landing in\n\t\t// a transition on an intermediate date shifts the same way it does\n\t\t// there: park on the 1st, move the month, then clamp the day.\n\t\tconst f0 = this.fields(epochMs);\n\t\tif (Number.isNaN(f0.year)) return Number.NaN;\n\t\tconst dayOfMonth = f0.day;\n\t\tconst f1 = this.fields(this.wallClock(f0.year, f0.month0, 1, f0.hour, f0.minute, f0.second, f0.millisecond));\n\t\tif (Number.isNaN(f1.year)) return Number.NaN;\n\t\tconst f2 = this.fields(this.wallClock(f1.year, f1.month0 + months, f1.day, f1.hour, f1.minute, f1.second, f1.millisecond));\n\t\tif (Number.isNaN(f2.year)) return Number.NaN;\n\t\tconst day = Math.min(dayOfMonth, daysInMonth(f2.year, f2.month0));\n\t\treturn this.wallClock(f2.year, f2.month0, day, f2.hour, f2.minute, f2.second, f2.millisecond);\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\tconst z = this.zoned(epochMs, this.timeZone);\n\t\tif (z === null) return Number.NaN;\n\t\t// `getTimezoneOffset()` answers whole minutes, truncated toward zero,\n\t\t// which only shows for the local-mean-time offsets in force before a\n\t\t// zone adopted standard time (London's was -00:01:15 until 1847).\n\t\t// `|| 0` folds the -0 a small negative offset truncates to.\n\t\treturn Math.trunc(z.offsetNanoseconds / 60_000_000_000) || 0;\n\t}\n\n\tparseIso8601(text: string): number {\n\t\t// Only the format itself. The `Date` constructor falls back to a\n\t\t// legacy parser for a string the format rejects (one with a space\n\t\t// around it, say) and may guess an instant from it; the engine's own\n\t\t// gate admits only the format, so the two backends cannot disagree\n\t\t// through it, and outside it this backend answers NaN rather than guess.\n\t\tconst m = ISO_DATE_TIME.exec(text);\n\t\tif (m === null) return Number.NaN;\n\t\tconst [, yearText, monthText, dayText, hourText, minuteText, secondText, fractionText, zoneText] = m;\n\t\t// An expanded year of `-000000` names no year, by the format's own rule.\n\t\tif (yearText === \"-000000\") return Number.NaN;\n\t\tconst year = Number(yearText);\n\t\tconst month = monthText === undefined ? 1 : Number(monthText);\n\t\tconst day = dayText === undefined ? 1 : Number(dayText);\n\t\tconst hour = hourText === undefined ? 0 : Number(hourText);\n\t\tconst minute = minuteText === undefined ? 0 : Number(minuteText);\n\t\tconst second = secondText === undefined ? 0 : Number(secondText);\n\t\t// Only the first three digits of a fraction are milliseconds; the rest\n\t\t// are dropped rather than rounded, as the runtime's parser does.\n\t\tconst millisecond = fractionText === undefined ? 0 : Number(fractionText.slice(0, 3).padEnd(3, \"0\"));\n\t\t// The runtime checks a day against 31, not against the month, and lets\n\t\t// 30 February roll into March; 24:00 is the end of the day and nothing\n\t\t// past it is a time.\n\t\tif (month < 1 || month > 12 || day < 1 || day > 31) return Number.NaN;\n\t\tif (hour > 24 || minute > 59 || second > 59) return Number.NaN;\n\t\tif (hour === 24 && (minute !== 0 || second !== 0 || millisecond !== 0)) return Number.NaN;\n\n\t\t// The year is taken literally: the format has no 1900s window for a\n\t\t// year from 0 to 99, unlike the constructor.\n\t\tconst wall = normaliseWallClock(year, month - 1, day, hour, minute, second, millisecond);\n\t\tif (zoneText === undefined && hourText !== undefined) {\n\t\t\t// A date-time with no offset is local time, by the format's own rule.\n\t\t\treturn this.resolve(wall);\n\t\t}\n\t\t// A date-only string is UTC midnight, and an offset is subtracted.\n\t\tlet offsetMinutes = 0;\n\t\tif (zoneText !== undefined && zoneText !== \"Z\" && zoneText !== \"z\") {\n\t\t\tconst digits = zoneText.slice(1).replace(\":\", \"\");\n\t\t\tconst offsetHours = Number(digits.slice(0, 2));\n\t\t\tconst offsetMinutesPart = Number(digits.slice(2, 4));\n\t\t\tif (offsetHours > 23 || offsetMinutesPart > 59) return Number.NaN;\n\t\t\toffsetMinutes = (zoneText[0] === \"-\" ? -1 : 1) * (offsetHours * 60 + offsetMinutesPart);\n\t\t}\n\t\tconst instant = wall.dayNumber * MS_PER_DAY + wall.timeOfDay - offsetMinutes * 60_000;\n\t\treturn Math.abs(instant) > MAX_INSTANT ? Number.NaN : instant;\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\tconst t = clip(epochMs);\n\t\t// `toLocaleDateString()` on an invalid date, rather than the throw\n\t\t// `Intl` would raise.\n\t\tif (Number.isNaN(t)) return \"Invalid Date\";\n\t\treturn new Intl.DateTimeFormat(locale, {\n\t\t\ttimeZone: this.timeZone, weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\",\n\t\t}).format(t);\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\tconst t = clip(epochMs);\n\t\tif (Number.isNaN(t)) return \"Invalid Date\";\n\t\t// `toLocaleTimeString()` with no options is the hour, minute and second\n\t\t// in the locale's own style.\n\t\treturn new Intl.DateTimeFormat(locale, {\n\t\t\ttimeZone: this.timeZone, hour: \"numeric\", minute: \"numeric\", second: \"numeric\",\n\t\t}).format(t);\n\t}\n\n\tzoneOffsetMinutes(zone: string, epochMs: number): number {\n\t\t// A fault here is the caller's to see, as the contract states, so no\n\t\t// clip: a non-finite instant reaches `Temporal` and throws its\n\t\t// RangeError, as an unknown zone does.\n\t\tconst t = Number.isFinite(epochMs) ? Math.trunc(epochMs) : epochMs;\n\t\tconst z = this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\t// The `Date` backend reads the zone's wall clock to the second and\n\t\t// rounds the difference from the instant to whole minutes; the same\n\t\t// arithmetic on the exact offset keeps the two answers identical for\n\t\t// the pre-standard-time offsets that are not whole minutes.\n\t\tconst wallSecond = Math.floor((t + z.offsetNanoseconds / 1e6) / 1000) * 1000;\n\t\treturn Math.round((wallSecond - epochMs) / 60_000) || 0;\n\t}\n\n\tfieldsInZone(zone: string, epochMs: number): ZonedFields {\n\t\tconst t = Number.isFinite(epochMs) ? Math.trunc(epochMs) : epochMs;\n\t\tconst z = this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\treturn { year: z.year, month0: z.month - 1, day: z.day, hour: z.hour, minute: z.minute, second: z.second };\n\t}\n\n\t/** The IANA zone this backend computes in, which is what `CalendarBackend.zone` documents. */\n\tzone(): string {\n\t\treturn this.timeZone;\n\t}\n\n\tformatTimeInZone(zone: string, epochMs: number): string {\n\t\treturn timeInZone(zone, epochMs);\n\t}\n\n\tformatDateInZone(zone: string, epochMs: number): string {\n\t\treturn dateInZone(zone, epochMs);\n\t}\n\n\t/** The zoned date-time of an instant, or `null` where `Date` would answer `NaN`. */\n\tprivate zoned(epochMs: number, zone: string): TemporalZonedDateTimeLike | null {\n\t\tconst t = clip(epochMs);\n\t\tif (Number.isNaN(t)) return null;\n\t\ttry {\n\t\t\treturn this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\t} catch {\n\t\t\t// Past the range the implementation represents in this zone.\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * The instant a set of local wall-clock fields names, with the fields\n\t * normalised the way `Date`'s constructor and setters normalise them\n\t * (month 12 is next January, day 0 the last of the month before, a year\n\t * from 0 to 99 the 1900s) before the zone is consulted.\n\t */\n\tprivate wallClock(year: number, month0: number, day: number, hour: number, minute: number, second: number, millisecond: number): number {\n\t\t// The constructor's two-digit-year window, applied to the year as\n\t\t// written and before any overflow, as `Date` applies it.\n\t\tconst windowed = year >= 0 && year <= 99 ? 1900 + Math.trunc(year) : year;\n\t\treturn this.resolve(normaliseWallClock(windowed, month0, day, hour, minute, second, millisecond));\n\t}\n\n\t/**\n\t * Normalised wall-clock fields resolved to an instant in the backend's\n\t * zone, clipped to the range `Date` represents only then, as `Date` clips\n\t * last. `compatible` disambiguation is `Date`'s rule: a time in a\n\t * spring-forward gap moves later by the gap, and a time that occurs twice\n\t * on a fall-back day is its first occurrence.\n\t */\n\tprivate resolve(wall: WallClock): number {\n\t\tconst civil = civilFromDayNumber(wall.dayNumber);\n\t\tif (Number.isNaN(civil.year)) return Number.NaN;\n\t\tconst hour = Math.floor(wall.timeOfDay / 3_600_000);\n\t\tconst minute = Math.floor(wall.timeOfDay / 60_000) % 60;\n\t\tconst second = Math.floor(wall.timeOfDay / 1_000) % 60;\n\t\tconst millisecond = wall.timeOfDay % 1_000;\n\t\ttry {\n\t\t\tconst plain = this.temporal.PlainDateTime.from(\n\t\t\t\t{ year: civil.year, month: civil.month0 + 1, day: civil.day, hour, minute, second, millisecond },\n\t\t\t\t{ overflow: \"reject\" },\n\t\t\t);\n\t\t\tconst instant = plain.toZonedDateTime(this.timeZone, { disambiguation: \"compatible\" }).epochMilliseconds;\n\t\t\treturn Math.abs(instant) > MAX_INSTANT ? Number.NaN : instant;\n\t\t} catch {\n\t\t\t// Past the range the implementation represents: `Date` answers NaN.\n\t\t\treturn Number.NaN;\n\t\t}\n\t}\n}\n\n/** Refuse anything that is not a usable `Temporal` before a method can fail on it obscurely. */\nfunction assertTemporalLike(temporal: unknown): asserts temporal is TemporalLike {\n\tconst candidate = temporal as Partial<TemporalLike> | null | undefined;\n\tconst missing =\n\t\ttypeof candidate?.Now?.instant !== \"function\" ? \"Now.instant\" :\n\t\ttypeof candidate?.Now?.timeZoneId !== \"function\" ? \"Now.timeZoneId\" :\n\t\ttypeof candidate?.Instant?.fromEpochMilliseconds !== \"function\" ? \"Instant.fromEpochMilliseconds\" :\n\t\ttypeof candidate?.PlainDateTime?.from !== \"function\" ? \"PlainDateTime.from\" :\n\t\tnull;\n\tif (missing !== null) {\n\t\tthrow ErrorFactory.config(\n\t\t\tCoreErrorCodes.TEMPORAL_IMPLEMENTATION_INVALID,\n\t\t\t`createTemporalCalendar needs a Temporal implementation (globalThis.Temporal on a runtime that ships it, or a polyfill's export); the value given has no ${missing}`,\n\t\t\t{ missing },\n\t\t);\n\t}\n}\n\n/**\n * A calendar backend over the host's `Temporal`, for the engine's `calendar`\n * option.\n *\n * ```ts\n * import { createEngine } from \"solve-engine\";\n * import { createTemporalCalendar } from \"solve-engine/temporal\";\n *\n * const calendar = createTemporalCalendar(globalThis.Temporal, { timeZone: \"Asia/Tokyo\" });\n * const engine = createEngine({ calendar });\n * ```\n *\n * @param temporal - The `Temporal` implementation: `globalThis.Temporal` where the runtime ships one, or a polyfill's export.\n * @param options - The zone to compute in and, for a test, the clock to read; see {@link TemporalCalendarOptions}.\n * @returns A backend that computes every date in that zone and answers what the `Date` backend would in it.\n * @throws `TEMPORAL_IMPLEMENTATION_INVALID` when `temporal` lacks the members the backend uses, and\n * `TEMPORAL_TIME_ZONE_UNKNOWN` when the implementation does not know the zone asked for.\n */\nexport function createTemporalCalendar(temporal: TemporalLike, options: TemporalCalendarOptions = {}): TemporalCalendar {\n\treturn new TemporalCalendar(temporal, options);\n}\n"]}
1
+ {"version":3,"sources":["../src/temporal/CivilDays.ts","../src/temporal/TemporalCalendar.ts"],"names":["civilDayNumber","year","month0","day","y0","m0","d","y","m","shiftedYear","era","yearOfEra","dayOfYear","dayOfEra","civilFromDayNumber","days","z","monthFromMarch","month","NAN_FIELDS","MAX_INSTANT","MS_PER_DAY","clip","epochMs","normaliseWallClock","hour","minute","second","millisecond","time","ISO_DATE_TIME","TemporalCalendar","temporal","options","assertTemporalLike","requested","probe","error","ErrorFactory","CoreErrorCodes","minutesPastMidnight","anchored","a","f","months","f0","dayOfMonth","f1","f2","daysInMonth","text","yearText","monthText","dayText","hourText","minuteText","secondText","fractionText","zoneText","wall","offsetMinutes","digits","offsetHours","offsetMinutesPart","instant","locale","t","zone","wallSecond","timeInZone","dateInZone","windowed","civil","candidate","missing","createTemporalCalendar"],"mappings":"8EAkDO,SAASA,EAAeC,CAAAA,CAAcC,CAAAA,CAAgBC,CAAAA,CAAqB,CACjF,IAAMC,CAAAA,CAAK,IAAA,CAAK,KAAA,CAAMH,CAAI,EACpBI,CAAAA,CAAK,IAAA,CAAK,KAAA,CAAMH,CAAM,EACtBI,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMH,CAAG,EACxB,GAAI,CAAC,MAAA,CAAO,QAAA,CAASC,CAAE,CAAA,EAAK,CAAC,MAAA,CAAO,QAAA,CAASC,CAAE,CAAA,EAAK,CAAC,OAAO,QAAA,CAASC,CAAC,EAAG,OAAO,MAAA,CAAO,GAAA,CAGvF,IAAMC,EAAIH,CAAAA,C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AAA,CACzC,CAAE,KAAMQ,CAAAA,CAAM,IAAA,CAAM,MAAOA,CAAAA,CAAM,MAAA,CAAS,EAAG,GAAA,CAAKA,CAAAA,CAAM,GAAA,CAAK,IAAA,CAAA/C,EAAM,MAAA,CAAAC,CAAAA,CAAQ,MAAA,CAAAC,CAAAA,CAAQ,YAAAC,CAAY,CAAA,CAC/F,CAAE,QAAA,CAAU,QAAS,CACtB,CAAA,CACsB,gBAAgB,IAAA,CAAK,QAAA,CAAU,CAAE,cAAA,CAAgB,YAAa,CAAC,CAAA,CAAE,kBACvF,OAAO,IAAA,CAAK,GAAA,CAAIoC,CAAO,EAAI5C,CAAAA,CAAc,MAAA,CAAO,GAAA,CAAM4C,CACvD,MAAQ,CAEP,OAAO,OAAO,GACf,CACD,CACD,EAGA,SAAS9B,CAAAA,CAAmBF,CAAAA,CAAqD,CAChF,IAAMyC,CAAAA,CAAYzC,CAAAA,CACZ0C,CAAAA,CACL,OAAOD,CAAAA,EAAW,GAAA,EAAK,OAAA,EAAY,UAAA,CAAa,cAChD,OAAOA,CAAAA,EAAW,KAAK,UAAA,EAAe,UAAA,CAAa,iBACnD,OAAOA,CAAAA,EAAW,OAAA,EAAS,qBAAA,EAA0B,WAAa,+BAAA,CAClE,OAAOA,CAAAA,EAAW,aAAA,EAAe,MAAS,UAAA,CAAa,oBAAA,CACvD,IAAA,CACD,GAAIC,IAAY,IAAA,CACf,MAAMpC,EAAa,MAAA,CAClBC,CAAAA,CAAe,gCACf,CAAA,wJAAA,EAA2JmC,CAAO,CAAA,CAAA,CAClK,CAAE,QAAAA,CAAQ,CACX,CAEF,CAoBO,SAASC,CAAAA,CAAuB3C,CAAAA,CAAwBC,CAAAA,CAAmC,GAAsB,CACvH,OAAO,IAAIF,CAAAA,CAAiBC,CAAAA,CAAUC,CAAO,CAC9C","file":"chunk-3ZGFAE3Q.js","sourcesContent":["/**\n * The day arithmetic behind `Date`'s field normalisation, for the `Temporal`\n * backend.\n *\n * `Date` normalises a set of wall-clock fields before it resolves them in a\n * zone: month 13 rolls into the next year, day 0 into the month before, a\n * time past midnight into the next day, and only the final instant is\n * clipped to the range `Date` represents. That is the `MakeDay` and\n * `MakeTime` order of the ECMAScript specification, and a backend built on\n * another library has to follow it to answer what `Date` answers on the last\n * representable day and for a rolled-over literal. `Date` does this\n * arithmetic inside its own setters, where a second backend cannot reach it,\n * so it is written out here with nothing clipped.\n *\n * Under `temporal/` rather than `calendar/Gregorian.ts` because only the\n * `Temporal` backend needs it: the `Date` backend gets the same arithmetic\n * from `Date` itself, and keeping it here keeps it out of the root entry's\n * bundle. The unit spec measures it against `Date.UTC` and `setUTCFullYear`\n * wherever `Date` can represent the date.\n *\n * @module CivilDays\n */\n\n/** A calendar date as year, zero-based month and day, the shape the civil-day arithmetic exchanges. */\nexport interface CivilDate {\n\treadonly year: number;\n\t/** Zero-based month: 0 is January, 11 is December. */\n\treadonly month0: number;\n\t/** Day of the month, from 1. */\n\treadonly day: number;\n}\n\n/**\n * The day number of a calendar date, counted from 1 January 1970, by\n * arithmetic alone: no `Date`, so no clip to the range `Date` represents.\n *\n * This is the `MakeDay` step of the ECMAScript specification, which a\n * backend needs unclipped: `Date` normalises a set of fields (month 13, day\n * 0, a time past midnight) before it resolves them in a zone and clips the\n * result, so a wall-clock time on the last representable day is an instant,\n * not `NaN`, and a backend built on another library must follow the same\n * order. An overflowing month or day rolls into the adjacent year or month,\n * as {@link utcMs}'s do, and a fractional field is truncated, as `Date`\n * truncates it.\n *\n * @param year - The calendar year, read as written.\n * @param month0 - Zero-based month; overflow rolls into the adjacent year.\n * @param day - Day of the month; overflow rolls into the adjacent month.\n * @returns Whole days since 1 January 1970, negative before it, or `NaN` when a field is not finite.\n */\nexport function civilDayNumber(year: number, month0: number, day: number): number {\n\tconst y0 = Math.trunc(year);\n\tconst m0 = Math.trunc(month0);\n\tconst d = Math.trunc(day);\n\tif (!Number.isFinite(y0) || !Number.isFinite(m0) || !Number.isFinite(d)) return Number.NaN;\n\t// Normalise the month into the year first, then count from the first of\n\t// that month, so a day of 0 or 40 is a plain offset from a real month.\n\tconst y = y0 + Math.floor(m0 / 12);\n\tconst m = ((m0 % 12) + 12) % 12 + 1;\n\t// The days-from-civil arithmetic, with the year taken to start in March\n\t// so a leap day is the last day of the cycle rather than an exception.\n\tconst shiftedYear = y - (m <= 2 ? 1 : 0);\n\tconst era = Math.floor(shiftedYear / 400);\n\tconst yearOfEra = shiftedYear - era * 400;\n\tconst dayOfYear = Math.floor((153 * (m + (m > 2 ? -3 : 9)) + 2) / 5);\n\tconst dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;\n\treturn era * 146_097 + dayOfEra - 719_468 + (d - 1);\n}\n\n/**\n * The calendar date of a day number, the inverse of {@link civilDayNumber}.\n *\n * @param days - Whole days since 1 January 1970, negative before it.\n * @returns The date, or `NaN` in every field when `days` is not finite.\n */\nexport function civilFromDayNumber(days: number): CivilDate {\n\tif (!Number.isFinite(days)) return { year: Number.NaN, month0: Number.NaN, day: Number.NaN };\n\tconst z = Math.trunc(days) + 719_468;\n\tconst era = Math.floor(z / 146_097);\n\tconst dayOfEra = z - era * 146_097;\n\tconst yearOfEra = Math.floor((dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36_524) - Math.floor(dayOfEra / 146_096)) / 365);\n\tconst dayOfYear = dayOfEra - (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));\n\tconst monthFromMarch = Math.floor((5 * dayOfYear + 2) / 153);\n\tconst day = dayOfYear - Math.floor((153 * monthFromMarch + 2) / 5) + 1;\n\tconst month = monthFromMarch < 10 ? monthFromMarch + 3 : monthFromMarch - 9;\n\tconst year = yearOfEra + era * 400 + (month <= 2 ? 1 : 0);\n\treturn { year, month0: month - 1, day };\n}\n","/**\n * The `Temporal` calendar backend: the engine's date questions answered\n * through a `Temporal` implementation the host supplies, in a time zone the\n * host chooses.\n *\n * `Temporal` is the JavaScript standard library's replacement for `Date`. It\n * ships unflagged in Node 26 and in current Chrome, Firefox and Deno, but not\n * in Safari nor in Node 22 and 24, and the smallest polyfill adds about twenty\n * kilobytes gzipped to a bundle. The engine therefore imports no `Temporal`\n * and no polyfill: this module is reached only through the\n * `solve-engine/temporal` entry, and the host hands it the implementation to\n * use, `globalThis.Temporal` on a runtime that has one or a polyfill's export.\n * A host that never imports the entry pays nothing for it.\n *\n * The backend answers exactly what the `Date` backend answers. That is a\n * design constraint rather than a hope: `Temporal` and `Date` differ in what\n * they do with an out-of-range instant (`RangeError` against `NaN`), a\n * fractional millisecond (a throw against truncation), a day past the end of\n * a month (a clamp or a throw against a roll into the next month) and a year\n * from 0 to 99 (read literally against read as the 1900s), and every one of\n * those is reproduced here the way `Date` does it, because the engine's\n * results are measured against `Date` and a host switching backends must see\n * no result move. The differential suite under `__tests__/temporal/` is what\n * holds that line.\n *\n * The one thing that does change is the zone. `Date` reads the process's own\n * zone and nothing else; this backend reads the zone it was constructed with,\n * so a document can be computed in Tokyo from a server in London, or in a\n * zone the reader picks. That is the capability the backend adds, and the\n * only observable difference.\n *\n * The named-zone display strings go through the same `Intl.DateTimeFormat`\n * helpers the `Date` backend uses (`calendar/IntlZone.ts`), and the zone-free\n * arithmetic through `calendar/Gregorian.ts`, so the two backends share one\n * implementation wherever an answer does not depend on which backend is in\n * use. The one piece of arithmetic `Date` keeps inside its own setters, the\n * normalisation of overflowing fields, is written out in `CivilDays.ts`.\n *\n * @module TemporalCalendar\n */\n\nimport type { CalendarBackend, CalendarFields, ZonedFields } from \"@solve-js/calendar/CalendarBackend\";\nimport { daysInMonth } from \"@solve-js/calendar/Gregorian\";\nimport { civilDayNumber, civilFromDayNumber } from \"./CivilDays\";\nimport { dateInZone, timeInZone } from \"@solve-js/calendar/IntlZone\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { CoreErrorCodes } from \"@solve-js/errors/ErrorCode\";\n\n/**\n * The part of a `Temporal.Instant` the backend reads: its epoch milliseconds,\n * and the zoned date-time it shows in a named zone.\n */\nexport interface TemporalInstantLike {\n\treadonly epochMilliseconds: number;\n\ttoZonedDateTimeISO(timeZone: string): TemporalZonedDateTimeLike;\n}\n\n/**\n * The part of a `Temporal.ZonedDateTime` the backend reads: the calendar\n * fields (a one-based month and an ISO weekday, Monday 1 to Sunday 7, both\n * translated at the boundary), the offset, and the instant.\n */\nexport interface TemporalZonedDateTimeLike {\n\treadonly year: number;\n\t/** One-based month, 1 is January, as `Temporal` counts. */\n\treadonly month: number;\n\treadonly day: number;\n\t/** ISO weekday: Monday is 1, Sunday is 7. */\n\treadonly dayOfWeek: number;\n\treadonly hour: number;\n\treadonly minute: number;\n\treadonly second: number;\n\treadonly millisecond: number;\n\t/** The zone's offset from UTC at this instant, in nanoseconds, positive when ahead. */\n\treadonly offsetNanoseconds: number;\n\treadonly epochMilliseconds: number;\n\t/** The zone's canonical IANA identifier. */\n\treadonly timeZoneId: string;\n}\n\n/** The part of a `Temporal.PlainDateTime` the backend uses: resolving a wall-clock time to an instant in a zone. */\nexport interface TemporalPlainDateTimeLike {\n\ttoZonedDateTime(\n\t\ttimeZone: string,\n\t\toptions?: { disambiguation?: \"compatible\" | \"earlier\" | \"later\" | \"reject\" },\n\t): TemporalZonedDateTimeLike;\n}\n\n/** The wall-clock fields a `Temporal.PlainDateTime` is built from, with a one-based month. */\nexport interface TemporalDateTimeFields {\n\tyear: number;\n\t/** One-based month, 1 is January. */\n\tmonth: number;\n\tday: number;\n\thour: number;\n\tminute: number;\n\tsecond: number;\n\tmillisecond: number;\n}\n\n/**\n * The subset of the `Temporal` namespace the backend uses, as a structural\n * type, so the engine compiles and ships with no `Temporal` type installed\n * and a host passes whichever implementation it has: `globalThis.Temporal`\n * on Node 26 or a current browser, or the export of a polyfill such as\n * `temporal-polyfill`. Both satisfy this shape as they are.\n */\nexport interface TemporalLike {\n\treadonly Now: {\n\t\tinstant(): TemporalInstantLike;\n\t\ttimeZoneId(): string;\n\t};\n\treadonly Instant: {\n\t\tfromEpochMilliseconds(epochMilliseconds: number): TemporalInstantLike;\n\t};\n\treadonly PlainDateTime: {\n\t\tfrom(fields: TemporalDateTimeFields, options?: { overflow?: \"constrain\" | \"reject\" }): TemporalPlainDateTimeLike;\n\t};\n}\n\n/** What {@link createTemporalCalendar} takes beside the implementation. */\nexport interface TemporalCalendarOptions {\n\t/**\n\t * The IANA time zone the engine computes dates in (`\"Asia/Tokyo\"`,\n\t * `\"UTC\"`). Defaults to the runtime's own zone, `Temporal.Now.timeZoneId()`,\n\t * which is what the `Date` backend reads. A zone the implementation does\n\t * not know is refused at construction with `TEMPORAL_TIME_ZONE_UNKNOWN`.\n\t */\n\ttimeZone?: string;\n\t/**\n\t * The clock `now()` reads, in epoch milliseconds. Defaults to\n\t * `Temporal.Now.instant()`. A test pins a date with this: a fake-timer\n\t * library replaces `Date.now`, which the `Date` backend reads, but not\n\t * `Temporal.Now`, so this backend needs telling separately.\n\t */\n\tnow?: () => number;\n}\n\n/** The fields the `Date` backend answers for an instant it cannot represent. */\nconst NAN_FIELDS: CalendarFields = Object.freeze({\n\tyear: Number.NaN, month0: Number.NaN, day: Number.NaN, weekday: Number.NaN,\n\thour: Number.NaN, minute: Number.NaN, second: Number.NaN, millisecond: Number.NaN,\n});\n\n/** The largest magnitude `Date` represents, in milliseconds either side of the epoch. */\nconst MAX_INSTANT = 8.64e15;\n\n/** Milliseconds in a day of wall-clock fields, before any zone is consulted. */\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * An instant as `Date` would hold it: truncated to a whole millisecond, or\n * `NaN` when it is not finite or lies past the range `Date` represents. This\n * is `Date`'s own clip (its `TimeClip`), applied before an instant reaches\n * `Temporal`, which throws for both cases where `Date` answers `NaN`.\n */\nfunction clip(epochMs: number): number {\n\tif (!Number.isFinite(epochMs) || Math.abs(epochMs) > MAX_INSTANT) return Number.NaN;\n\treturn Math.trunc(epochMs);\n}\n\n/**\n * Wall-clock fields normalised the way `Date`'s `MakeDay` and `MakeTime`\n * normalise them, with nothing clipped: the day number of the date the\n * fields land on after any overflow rolls, and the time within that day.\n * Each field is truncated to an integer first, as `Date` truncates it.\n */\ninterface WallClock {\n\treadonly dayNumber: number;\n\treadonly timeOfDay: number;\n}\n\n/** `MakeDay` and `MakeTime`, then `MakeDate`, with a time past midnight carried into the day. */\nfunction normaliseWallClock(year: number, month0: number, day: number, hour: number, minute: number, second: number, millisecond: number): WallClock {\n\tconst time = Math.trunc(hour) * 3_600_000 + Math.trunc(minute) * 60_000 + Math.trunc(second) * 1_000 + Math.trunc(millisecond);\n\tconst dayNumber = civilDayNumber(year, month0, day) + Math.floor(time / MS_PER_DAY);\n\treturn { dayNumber, timeOfDay: ((time % MS_PER_DAY) + MS_PER_DAY) % MS_PER_DAY };\n}\n\n/**\n * The ECMAScript date-time string format, as the `Date` constructor reads it:\n * a four-digit or six-digit signed year, an optional month and day, an\n * optional time to the millisecond (longer fractions are truncated), and an\n * optional `Z` or offset. The `T` and `Z` may be lower case, and an offset\n * may omit its colon; both are what the runtime's parser accepts.\n */\nconst ISO_DATE_TIME =\n\t/^([+-]\\d{6}|\\d{4})(?:-(\\d{2})(?:-(\\d{2}))?)?(?:[Tt](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?)?([Zz]|[+-]\\d{2}:?\\d{2})?$/;\n\n/**\n * A {@link CalendarBackend} over a `Temporal` implementation, computing in\n * one named time zone. Build one with {@link createTemporalCalendar}.\n *\n * Every method answers what the `Date` backend answers for the same inputs\n * when the zone is the process's own; see the module comment for the\n * differences between `Temporal` and `Date` that are reproduced deliberately.\n * The local methods answer `NaN` for an instant or a date the backend cannot\n * represent and never throw; the four named-zone methods throw the runtime's\n * `RangeError` for a zone it does not know or an instant it cannot represent,\n * which is the contract the interface states.\n */\nexport class TemporalCalendar implements CalendarBackend {\n\t/** The IANA zone every local answer is computed in, in its canonical spelling. */\n\treadonly timeZone: string;\n\n\tprivate readonly temporal: TemporalLike;\n\tprivate readonly clock: () => number;\n\n\tconstructor(temporal: TemporalLike, options: TemporalCalendarOptions = {}) {\n\t\tassertTemporalLike(temporal);\n\t\tthis.temporal = temporal;\n\t\tconst requested = options.timeZone ?? temporal.Now.timeZoneId();\n\t\tlet probe: TemporalZonedDateTimeLike;\n\t\ttry {\n\t\t\tprobe = temporal.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(requested);\n\t\t} catch (error) {\n\t\t\tthrow ErrorFactory.config(\n\t\t\t\tCoreErrorCodes.TEMPORAL_TIME_ZONE_UNKNOWN,\n\t\t\t\t`The Temporal implementation does not know the time zone \"${requested}\"`,\n\t\t\t\t{ timeZone: requested, cause: error instanceof Error ? error.message : String(error) },\n\t\t\t);\n\t\t}\n\t\t// The canonical spelling, so a zone given as `asia/tokyo` reads back as\n\t\t// the identifier the implementation itself uses.\n\t\tthis.timeZone = probe.timeZoneId;\n\t\tthis.clock = options.now ?? (() => temporal.Now.instant().epochMilliseconds);\n\t}\n\n\tnow(): number {\n\t\treturn this.clock();\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst z = this.zoned(epochMs, this.timeZone);\n\t\tif (z === null) return NAN_FIELDS;\n\t\treturn {\n\t\t\tyear: z.year,\n\t\t\tmonth0: z.month - 1,\n\t\t\tday: z.day,\n\t\t\t// ISO's Monday 1 to Sunday 7 becomes Date's Sunday 0 to Saturday 6.\n\t\t\tweekday: z.dayOfWeek % 7,\n\t\t\thour: z.hour,\n\t\t\tminute: z.minute,\n\t\t\tsecond: z.second,\n\t\t\tmillisecond: z.millisecond,\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn this.wallClock(year, month0, day, 0, 0, 0, 0);\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// `Date`'s sequence exactly: anchor at midnight, then set the minutes\n\t\t// FIELD, which reads the hour, second and millisecond back from the\n\t\t// anchored local time. On a day whose midnight falls in a\n\t\t// daylight-saving gap the anchor resolves to 1 am, and the hour it\n\t\t// reads back is 1, which is what makes the two backends agree there.\n\t\tconst anchored = this.localMidnight(year, month0, day);\n\t\tconst a = this.fields(anchored);\n\t\tif (Number.isNaN(a.year)) return Number.NaN;\n\t\treturn this.wallClock(a.year, a.month0, a.day, a.hour, minutesPastMidnight, a.second, a.millisecond);\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\t// `setDate()`: the day field moves and the local time of day is held.\n\t\tconst f = this.fields(epochMs);\n\t\tif (Number.isNaN(f.year)) return Number.NaN;\n\t\treturn this.wallClock(f.year, f.month0, f.day + days, f.hour, f.minute, f.second, f.millisecond);\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\t// The `Date` backend's three field writes, each resolved to an instant\n\t\t// and read back before the next, so that a wall-clock time landing in\n\t\t// a transition on an intermediate date shifts the same way it does\n\t\t// there: park on the 1st, move the month, then clamp the day.\n\t\tconst f0 = this.fields(epochMs);\n\t\tif (Number.isNaN(f0.year)) return Number.NaN;\n\t\tconst dayOfMonth = f0.day;\n\t\tconst f1 = this.fields(this.wallClock(f0.year, f0.month0, 1, f0.hour, f0.minute, f0.second, f0.millisecond));\n\t\tif (Number.isNaN(f1.year)) return Number.NaN;\n\t\tconst f2 = this.fields(this.wallClock(f1.year, f1.month0 + months, f1.day, f1.hour, f1.minute, f1.second, f1.millisecond));\n\t\tif (Number.isNaN(f2.year)) return Number.NaN;\n\t\tconst day = Math.min(dayOfMonth, daysInMonth(f2.year, f2.month0));\n\t\treturn this.wallClock(f2.year, f2.month0, day, f2.hour, f2.minute, f2.second, f2.millisecond);\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\tconst z = this.zoned(epochMs, this.timeZone);\n\t\tif (z === null) return Number.NaN;\n\t\t// `getTimezoneOffset()` answers whole minutes, truncated toward zero,\n\t\t// which only shows for the local-mean-time offsets in force before a\n\t\t// zone adopted standard time (London's was -00:01:15 until 1847).\n\t\t// `|| 0` folds the -0 a small negative offset truncates to.\n\t\treturn Math.trunc(z.offsetNanoseconds / 60_000_000_000) || 0;\n\t}\n\n\tparseIso8601(text: string): number {\n\t\t// Only the format itself. The `Date` constructor falls back to a\n\t\t// legacy parser for a string the format rejects (one with a space\n\t\t// around it, say) and may guess an instant from it; the engine's own\n\t\t// gate admits only the format, so the two backends cannot disagree\n\t\t// through it, and outside it this backend answers NaN rather than guess.\n\t\tconst m = ISO_DATE_TIME.exec(text);\n\t\tif (m === null) return Number.NaN;\n\t\tconst [, yearText, monthText, dayText, hourText, minuteText, secondText, fractionText, zoneText] = m;\n\t\t// An expanded year of `-000000` names no year, by the format's own rule.\n\t\tif (yearText === \"-000000\") return Number.NaN;\n\t\tconst year = Number(yearText);\n\t\tconst month = monthText === undefined ? 1 : Number(monthText);\n\t\tconst day = dayText === undefined ? 1 : Number(dayText);\n\t\tconst hour = hourText === undefined ? 0 : Number(hourText);\n\t\tconst minute = minuteText === undefined ? 0 : Number(minuteText);\n\t\tconst second = secondText === undefined ? 0 : Number(secondText);\n\t\t// Only the first three digits of a fraction are milliseconds; the rest\n\t\t// are dropped rather than rounded, as the runtime's parser does.\n\t\tconst millisecond = fractionText === undefined ? 0 : Number(fractionText.slice(0, 3).padEnd(3, \"0\"));\n\t\t// The runtime checks a day against 31, not against the month, and lets\n\t\t// 30 February roll into March; 24:00 is the end of the day and nothing\n\t\t// past it is a time.\n\t\tif (month < 1 || month > 12 || day < 1 || day > 31) return Number.NaN;\n\t\tif (hour > 24 || minute > 59 || second > 59) return Number.NaN;\n\t\tif (hour === 24 && (minute !== 0 || second !== 0 || millisecond !== 0)) return Number.NaN;\n\n\t\t// The year is taken literally: the format has no 1900s window for a\n\t\t// year from 0 to 99, unlike the constructor.\n\t\tconst wall = normaliseWallClock(year, month - 1, day, hour, minute, second, millisecond);\n\t\tif (zoneText === undefined && hourText !== undefined) {\n\t\t\t// A date-time with no offset is local time, by the format's own rule.\n\t\t\treturn this.resolve(wall);\n\t\t}\n\t\t// A date-only string is UTC midnight, and an offset is subtracted.\n\t\tlet offsetMinutes = 0;\n\t\tif (zoneText !== undefined && zoneText !== \"Z\" && zoneText !== \"z\") {\n\t\t\tconst digits = zoneText.slice(1).replace(\":\", \"\");\n\t\t\tconst offsetHours = Number(digits.slice(0, 2));\n\t\t\tconst offsetMinutesPart = Number(digits.slice(2, 4));\n\t\t\tif (offsetHours > 23 || offsetMinutesPart > 59) return Number.NaN;\n\t\t\toffsetMinutes = (zoneText[0] === \"-\" ? -1 : 1) * (offsetHours * 60 + offsetMinutesPart);\n\t\t}\n\t\tconst instant = wall.dayNumber * MS_PER_DAY + wall.timeOfDay - offsetMinutes * 60_000;\n\t\treturn Math.abs(instant) > MAX_INSTANT ? Number.NaN : instant;\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\tconst t = clip(epochMs);\n\t\t// `toLocaleDateString()` on an invalid date, rather than the throw\n\t\t// `Intl` would raise.\n\t\tif (Number.isNaN(t)) return \"Invalid Date\";\n\t\treturn new Intl.DateTimeFormat(locale, {\n\t\t\ttimeZone: this.timeZone, weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\",\n\t\t}).format(t);\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\tconst t = clip(epochMs);\n\t\tif (Number.isNaN(t)) return \"Invalid Date\";\n\t\t// `toLocaleTimeString()` with no options is the hour, minute and second\n\t\t// in the locale's own style.\n\t\treturn new Intl.DateTimeFormat(locale, {\n\t\t\ttimeZone: this.timeZone, hour: \"numeric\", minute: \"numeric\", second: \"numeric\",\n\t\t}).format(t);\n\t}\n\n\tzoneOffsetMinutes(zone: string, epochMs: number): number {\n\t\t// A fault here is the caller's to see, as the contract states, so no\n\t\t// clip: a non-finite instant reaches `Temporal` and throws its\n\t\t// RangeError, as an unknown zone does.\n\t\tconst t = Number.isFinite(epochMs) ? Math.trunc(epochMs) : epochMs;\n\t\tconst z = this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\t// The `Date` backend reads the zone's wall clock to the second and\n\t\t// rounds the difference from the instant to whole minutes; the same\n\t\t// arithmetic on the exact offset keeps the two answers identical for\n\t\t// the pre-standard-time offsets that are not whole minutes.\n\t\tconst wallSecond = Math.floor((t + z.offsetNanoseconds / 1e6) / 1000) * 1000;\n\t\treturn Math.round((wallSecond - epochMs) / 60_000) || 0;\n\t}\n\n\tfieldsInZone(zone: string, epochMs: number): ZonedFields {\n\t\tconst t = Number.isFinite(epochMs) ? Math.trunc(epochMs) : epochMs;\n\t\tconst z = this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\treturn { year: z.year, month0: z.month - 1, day: z.day, hour: z.hour, minute: z.minute, second: z.second };\n\t}\n\n\t/** The IANA zone this backend computes in, which is what `CalendarBackend.zone` documents. */\n\tzone(): string {\n\t\treturn this.timeZone;\n\t}\n\n\tformatTimeInZone(zone: string, epochMs: number): string {\n\t\treturn timeInZone(zone, epochMs);\n\t}\n\n\tformatDateInZone(zone: string, epochMs: number): string {\n\t\treturn dateInZone(zone, epochMs);\n\t}\n\n\t/** The zoned date-time of an instant, or `null` where `Date` would answer `NaN`. */\n\tprivate zoned(epochMs: number, zone: string): TemporalZonedDateTimeLike | null {\n\t\tconst t = clip(epochMs);\n\t\tif (Number.isNaN(t)) return null;\n\t\ttry {\n\t\t\treturn this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\t} catch {\n\t\t\t// Past the range the implementation represents in this zone.\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * The instant a set of local wall-clock fields names, with the fields\n\t * normalised the way `Date`'s constructor and setters normalise them\n\t * (month 12 is next January, day 0 the last of the month before, a year\n\t * from 0 to 99 the 1900s) before the zone is consulted.\n\t */\n\tprivate wallClock(year: number, month0: number, day: number, hour: number, minute: number, second: number, millisecond: number): number {\n\t\t// The constructor's two-digit-year window, applied to the year as\n\t\t// written and before any overflow, as `Date` applies it.\n\t\tconst windowed = year >= 0 && year <= 99 ? 1900 + Math.trunc(year) : year;\n\t\treturn this.resolve(normaliseWallClock(windowed, month0, day, hour, minute, second, millisecond));\n\t}\n\n\t/**\n\t * Normalised wall-clock fields resolved to an instant in the backend's\n\t * zone, clipped to the range `Date` represents only then, as `Date` clips\n\t * last. `compatible` disambiguation is `Date`'s rule: a time in a\n\t * spring-forward gap moves later by the gap, and a time that occurs twice\n\t * on a fall-back day is its first occurrence.\n\t */\n\tprivate resolve(wall: WallClock): number {\n\t\tconst civil = civilFromDayNumber(wall.dayNumber);\n\t\tif (Number.isNaN(civil.year)) return Number.NaN;\n\t\tconst hour = Math.floor(wall.timeOfDay / 3_600_000);\n\t\tconst minute = Math.floor(wall.timeOfDay / 60_000) % 60;\n\t\tconst second = Math.floor(wall.timeOfDay / 1_000) % 60;\n\t\tconst millisecond = wall.timeOfDay % 1_000;\n\t\ttry {\n\t\t\tconst plain = this.temporal.PlainDateTime.from(\n\t\t\t\t{ year: civil.year, month: civil.month0 + 1, day: civil.day, hour, minute, second, millisecond },\n\t\t\t\t{ overflow: \"reject\" },\n\t\t\t);\n\t\t\tconst instant = plain.toZonedDateTime(this.timeZone, { disambiguation: \"compatible\" }).epochMilliseconds;\n\t\t\treturn Math.abs(instant) > MAX_INSTANT ? Number.NaN : instant;\n\t\t} catch {\n\t\t\t// Past the range the implementation represents: `Date` answers NaN.\n\t\t\treturn Number.NaN;\n\t\t}\n\t}\n}\n\n/** Refuse anything that is not a usable `Temporal` before a method can fail on it obscurely. */\nfunction assertTemporalLike(temporal: unknown): asserts temporal is TemporalLike {\n\tconst candidate = temporal as Partial<TemporalLike> | null | undefined;\n\tconst missing =\n\t\ttypeof candidate?.Now?.instant !== \"function\" ? \"Now.instant\" :\n\t\ttypeof candidate?.Now?.timeZoneId !== \"function\" ? \"Now.timeZoneId\" :\n\t\ttypeof candidate?.Instant?.fromEpochMilliseconds !== \"function\" ? \"Instant.fromEpochMilliseconds\" :\n\t\ttypeof candidate?.PlainDateTime?.from !== \"function\" ? \"PlainDateTime.from\" :\n\t\tnull;\n\tif (missing !== null) {\n\t\tthrow ErrorFactory.config(\n\t\t\tCoreErrorCodes.TEMPORAL_IMPLEMENTATION_INVALID,\n\t\t\t`createTemporalCalendar needs a Temporal implementation (globalThis.Temporal on a runtime that ships it, or a polyfill's export); the value given has no ${missing}`,\n\t\t\t{ missing },\n\t\t);\n\t}\n}\n\n/**\n * A calendar backend over the host's `Temporal`, for the engine's `calendar`\n * option.\n *\n * ```ts\n * import { createEngine } from \"solve-engine\";\n * import { createTemporalCalendar } from \"solve-engine/temporal\";\n *\n * const calendar = createTemporalCalendar(globalThis.Temporal, { timeZone: \"Asia/Tokyo\" });\n * const engine = createEngine({ calendar });\n * ```\n *\n * @param temporal - The `Temporal` implementation: `globalThis.Temporal` where the runtime ships one, or a polyfill's export.\n * @param options - The zone to compute in and, for a test, the clock to read; see {@link TemporalCalendarOptions}.\n * @returns A backend that computes every date in that zone and answers what the `Date` backend would in it.\n * @throws `TEMPORAL_IMPLEMENTATION_INVALID` when `temporal` lacks the members the backend uses, and\n * `TEMPORAL_TIME_ZONE_UNKNOWN` when the implementation does not know the zone asked for.\n */\nexport function createTemporalCalendar(temporal: TemporalLike, options: TemporalCalendarOptions = {}): TemporalCalendar {\n\treturn new TemporalCalendar(temporal, options);\n}\n"]}
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkU7CNADCJ_cjs=require('./chunk-U7CNADCJ.cjs'),chunkYBQOQTVL_cjs=require('./chunk-YBQOQTVL.cjs'),chunkHTAT4MGN_cjs=require('./chunk-HTAT4MGN.cjs');var N=32,L=2;function v(a){return a.shape!==void 0?a.shape:a.startTokenTypes!==void 0?[{types:a.startTokenTypes}]:[]}var x=class{constructor(e){this.rules=e;let r=e.length,t=Math.max(1,Math.ceil(r/N));this.words=t,this.scratch=new Uint32Array(t);let s=e.map(v),n=0;for(let l of s)for(let c of l)for(let f of c.types??[])n=Math.max(n,chunkYBQOQTVL_cjs.c(f));this.typeRows=n+1;let i=0;for(let l of s)i=Math.max(i,l.length);i=Math.min(i,L),this.allRules=new Uint32Array(t);for(let l=0;l<r;l++)this.allRules[l/N|0]|=1<<l%N;let u=[];for(let l=0;l<i;l++)u.push(this.buildPlane(s,l,t));this.planes=u;}buildPlane(e,r,t){let s={byType:new Uint32Array(this.typeRows*t),typeAny:new Uint32Array(t),atEnd:new Uint32Array(t),typeHasValues:new Uint8Array(this.typeRows),byValue:new Map,valueAny:new Uint32Array(t)};for(let n=0;n<e.length;n++){let i=e[n][r],u=n/N|0,l=1<<n%N,c=i?.types;if(c===void 0)s.typeAny[u]|=l,s.atEnd[u]|=l;else for(let p of c)s.byType[chunkYBQOQTVL_cjs.c(p)*t+u]|=l;let f=i?.values;if(f===void 0)s.valueAny[u]|=l;else {for(let p of f){let h=p.toLowerCase(),o=s.byValue.get(h);o===void 0&&(o=new Uint32Array(t),s.byValue.set(h,o)),o[u]|=l;}if(c===void 0)s.typeHasValues.fill(1);else for(let p of c){let h=chunkYBQOQTVL_cjs.c(p);h<this.typeRows&&(s.typeHasValues[h]=1);}}}return s}get size(){return this.rules.length}get depth(){return this.planes.length}candidates(e,r){let t=this.words,s=this.scratch,n=this.planes,i=e.length;if(n.length===0)return s.set(this.allRules),s;for(let u=0;u<n.length;u++){let l=n[u],c=r+u;if(c>=i){if(u===0)s.set(l.atEnd);else for(let o=0;o<t;o++)s[o]&=l.atEnd[o];continue}let f=e[c],p=f.typeId,h=p>=0&&p<this.typeRows?p*t:-1;if(u===0)if(h>=0)for(let o=0;o<t;o++)s[o]=l.byType[h+o]|l.typeAny[o];else s.set(l.typeAny);else if(h>=0)for(let o=0;o<t;o++)s[o]&=l.byType[h+o]|l.typeAny[o];else for(let o=0;o<t;o++)s[o]&=l.typeAny[o];if(h>=0&&l.typeHasValues[p]===1){let o=f.value,R=O(o)?o.toLowerCase():o,g=l.byValue.get(R);for(let T=0;T<t;T++)s[T]&=(g===void 0?0:g[T])|l.valueAny[T];}if(S(s))return s}return s}};function S(a){for(let e=0;e<a.length;e++)if(a[e]!==0)return false;return true}function O(a){for(let e=0;e<a.length;e++){let r=a.charCodeAt(e);if(r>=65&&r<=90)return true}return false}var B={maxPasses:100,maxTokens:1e4,onFusion:()=>{},ignoreRuleIndex:false};function C(a,e,r){let t=r[0],s=r[r.length-1],n=new chunkU7CNADCJ_cjs.a(a,chunkYBQOQTVL_cjs.c(a),e,e,t.offset,t.lineBreaks??0,t.line,t.col);return n.sourceEnd=s.sourceEnd??s.offset+s.text.length,n}function z(a,e){let r=e[e.length-1];r&&(a.sourceEnd=r.sourceEnd??r.offset+r.text.length);}var _=["NUMBER","HEX","BIGINT","FLOAT","LSHIFT","RSHIFT","BIT_AND","BIT_OR","BIT_XOR","LPAREN","RPAREN","LBRACKET","RBRACKET","COMMA","COLON","EQUALS","THEREFORE","PIPE","AMPERSAND","AT","SEMICOLON","QUESTION","EXCLAMATION","EOF","WS","NEWLINE"],M=(()=>{let a=_.map(t=>chunkYBQOQTVL_cjs.c(t)),e=Math.max(...a)+1,r=new Uint8Array(e);for(let t of a)r[t]=1;return r})(),P=new Set;function D(a){a.shape!==void 0&&a.shape.length>0||a.startTokenTypes===void 0&&a.unshapedReason===void 0&&(P.has(a.name)||(P.add(a.name),console.warn(`[TokenNormalizer] Rule "${a.name}" declares no \`shape\`, so it is tried at every token of every line and slows down documents that never use it. Declare the tokens it can start at, e.g. shape: [{ types: ["IDENT"], values: ["myword"] }, { types: ["LPAREN"] }]. If it genuinely cannot be described that way, set \`unshapedReason\` to say why and this warning will stop.`)));}var U=class{constructor(e={}){this.rules=[];this.sortedRulesCache=null;this.rulesByTokenType=new Map;this.ruleIndexCache=null;this.candidateBuffer=[];this.normalizeCalls=0;this.phraseTrie=new w;this.ruleShapesCache=null;this.options={...B,...e};}register(e){D(e),this.rules.push(e),this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null;}unregister(e){this.rules=this.rules.filter(r=>r.name!==e),this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null;}clear(){this.rules=[],this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null,this.phraseTrie=new w;}getSortedRules(){return this.sortedRulesCache===null&&(this.sortedRulesCache=[...this.rules].sort((e,r)=>r.priority-e.priority)),this.sortedRulesCache}getRuleIndex(){return this.ruleIndexCache===null&&(this.ruleIndexCache=new x(this.getSortedRules())),this.ruleIndexCache}rulesAt(e,r){if(e===null)return this.options.ignoreRuleIndex?this.getSortedRules():this.rulesForTokenType(r);let t=this.candidateBuffer;t.length=0;let s=this.getRuleIndex().rules;for(let n=0;n<e.length;n++){let i=e[n]>>>0,u=n*32;for(;i!==0;)(i&1)!==0&&t.push(s[u]),i>>>=1,u++;}return t}rulesForTokenType(e){let r=this.rulesByTokenType.get(e);return r===void 0&&(r=this.getSortedRules().filter(t=>{let s=v(t)[0];return s?.types===void 0||s.types.includes(e)}),this.rulesByTokenType.set(e,r)),r}get ruleCount(){return this.rules.length}getRuleShapes(){if(this.ruleShapesCache!==null)return this.ruleShapesCache;let e=this.getRuleIndex();return this.ruleShapesCache=this.getSortedRules().map(r=>{let t=v(r);return {name:r.name,priority:r.priority,shape:t,unshapedReason:r.unshapedReason,indexedSlots:Math.min(t.length,e.depth)}}),this.ruleShapesCache}getCandidateCounts(e){let r=this.getRuleIndex(),t=[];for(let s=0;s<e.length;s++){let n=r.candidates(e,s),i=0;for(let u=0;u<n.length;u++){let l=n[u]>>>0;for(;l!==0;)i+=l&1,l>>>=1;}t.push(i);}return t}addPhrase(e,r){this.phraseTrie.addPhrase(e,r);}getPhrases(){return this.phraseTrie.getAllPhrases()}canStartPhrase(e){return this.phraseTrie.canStart(e)}normalize(e,r){if(e.length===0)return e;let t=r??this.options.onFusion,s=this.options.maxPasses,n=this.options.maxTokens,i=this.normalizeCalls>0;i||(this.normalizeCalls=1);let u=i&&!this.options.ignoreRuleIndex,l=u?this.getRuleIndex():null,c=e,f=true,p=0;for(;f&&p<s;){f=false,p++;let h=null,o=0;for(;o<c.length;){let g=false,T=c[o].typeId;if(T>=M.length||M[T]===0){let m=this.phraseTrie.matchAt(c,o);if(m){let d=c.slice(o,o+m.consumed);h===null&&(h=c.slice(0,o));for(let A of m.replacement)h.push(A);m.consumed>1&&m.replacement.length===1&&(z(m.replacement[0],d),t({rule:m.ruleName??"phrase-trie",sourceTokens:d,fusedToken:m.replacement[0]})),o+=m.consumed,f=true;continue}}let I=u?l.candidates(c,o):null;if(I!==null&&S(I)){h!==null&&h.push(c[o]),o++;continue}for(let m of this.rulesAt(I,c[o].type)){let d=m.match(c,o);if(d){let A=c.slice(o,o+d.consumed);h===null&&(h=c.slice(0,o));for(let b of d.replacement)h.push(b);if(d.consumed>1&&d.replacement.length===1)z(d.replacement[0],A),t({rule:m.name,sourceTokens:A,fusedToken:d.replacement[0]});else if(d.consumed>1&&d.replacement.length<d.consumed)for(let b of d.replacement)t({rule:m.name,sourceTokens:A,fusedToken:b});o+=d.consumed,f=true,g=true;break}}g||(h!==null&&h.push(c[o]),o++);}if(h===null)break;let R=h;if(R.length>n)throw chunkHTAT4MGN_cjs.c.validation("NORMALIZED_TOKEN_LIMIT_EXCEEDED",`Normalized token count (${R.length}) exceeds safety limit (${n})`,{tokenCount:R.length,maxTokens:n});c=R;}return c}};var w=class{constructor(){this.startWords=new Set;this.root=new Map;}addPhrase(e,r){let t=e.toLowerCase().trim().split(/\s+/);if(t.length===0||t[0]==="")return;this.startWords.add(t[0]);let s=t[0],n;if(this.root.has(s)?n=this.root.get(s):(n={children:new Map,terminal:null},this.root.set(s,n)),t.length===1){n.terminal={tokenType:r,phrase:e,consumed:1};return}for(let i=1;i<t.length;i++){let u=t[i];n.children.has(u)||n.children.set(u,{children:new Map,terminal:null}),n=n.children.get(u);}n.terminal={tokenType:r,phrase:e,consumed:t.length};}matchAt(e,r){if(r>=e.length)return null;let t=e[r].type;if(t==="TAG"||t.startsWith("TAG_"))return null;let s=e[r].value.toLowerCase();if(!this.startWords.has(s))return null;let n=this.root.get(s);if(!n)return null;let i=null,u=1;if(n.terminal){let l=e.slice(r,r+1);i={consumed:1,replacement:[C(n.terminal.tokenType,n.terminal.phrase,l)],ruleName:n.terminal.phrase};}for(let l=r+1;l<e.length&&n?.children;l++){let c=e[l].type;if(c==="TAG"||c.startsWith("TAG_"))break;let f=e[l].value.toLowerCase();if(n=n.children.get(f),!n)break;if(u++,n.terminal){let p=e.slice(r,r+u);i={consumed:u,replacement:[C(n.terminal.tokenType,n.terminal.phrase,p)],ruleName:n.terminal.phrase};}}return i}get size(){return this.root.size}getAllPhrases(){let e={},r=(t,s)=>{t.terminal&&(e[s.join(" ")]=t.terminal.tokenType);for(let[n,i]of t.children)r(i,[...s,n]);};for(let[t,s]of this.root)r(s,[t]);return e}canStart(e){return this.startWords.has(e.toLowerCase())}};var F=new Set(["per","a","an","each","every"]),W=new Set(["to","power","increase","decrease","times","multiply","divide","by"]);function H(a=50,e){let r=e??(t=>W.has(t.toLowerCase()));return {name:"implicit:multiply",priority:a,shape:[{types:["NUMBER","RPAREN"]},{types:["IDENT","LPAREN","PI","E"]}],match(t,s){if(s+1>=t.length)return null;let n=t[s],i=t[s+1];if(!((n.type==="NUMBER"||n.type==="RPAREN")&&(i.type==="IDENT"||i.type==="LPAREN"||i.type==="PI"||i.type==="E")))return null;let l=i.value.toLowerCase();if(r(l)||F.has(l)&&t[s+2]?.type==="UNIT")return null;let c=new chunkU7CNADCJ_cjs.a("STAR",chunkYBQOQTVL_cjs.c("STAR"),"*","*",i.offset,0,i.line,i.col);return {consumed:1,replacement:[n,c]}}}}function ne(a,e){let r=[];for(let t=0;t<e;t++){let s=a[t];if(s.type==="LBRACKET")r.push(true);else if(s.type==="LPAREN"){let n=a[t-1],i=!!n&&(n.type==="MAP"||n.type==="REDUCE"||n.type==="SUM_FN"||n.type==="PROD_FN"||n.type==="IDENT"&&(n.value.toLowerCase()==="map"||n.value.toLowerCase()==="reduce"||n.value.toLowerCase()==="sum"||n.value.toLowerCase()==="prod"));r.push(i);}else (s.type==="RBRACKET"||s.type==="RPAREN")&&r.pop();}return r.length>0&&r[r.length-1]}function re(){return [H()]}exports.a=w;exports.b=C;exports.c=U;exports.d=H;exports.e=ne;exports.f=re;//# sourceMappingURL=chunk-UMW5PO42.cjs.map
2
- //# sourceMappingURL=chunk-UMW5PO42.cjs.map
1
+ 'use strict';var chunkWU7SBKVU_cjs=require('./chunk-WU7SBKVU.cjs'),chunkYBQOQTVL_cjs=require('./chunk-YBQOQTVL.cjs'),chunkSUAGBRQ7_cjs=require('./chunk-SUAGBRQ7.cjs');var N=32,L=2;function v(a){return a.shape!==void 0?a.shape:a.startTokenTypes!==void 0?[{types:a.startTokenTypes}]:[]}var x=class{constructor(e){this.rules=e;let r=e.length,t=Math.max(1,Math.ceil(r/N));this.words=t,this.scratch=new Uint32Array(t);let s=e.map(v),n=0;for(let l of s)for(let c of l)for(let f of c.types??[])n=Math.max(n,chunkYBQOQTVL_cjs.c(f));this.typeRows=n+1;let i=0;for(let l of s)i=Math.max(i,l.length);i=Math.min(i,L),this.allRules=new Uint32Array(t);for(let l=0;l<r;l++)this.allRules[l/N|0]|=1<<l%N;let u=[];for(let l=0;l<i;l++)u.push(this.buildPlane(s,l,t));this.planes=u;}buildPlane(e,r,t){let s={byType:new Uint32Array(this.typeRows*t),typeAny:new Uint32Array(t),atEnd:new Uint32Array(t),typeHasValues:new Uint8Array(this.typeRows),byValue:new Map,valueAny:new Uint32Array(t)};for(let n=0;n<e.length;n++){let i=e[n][r],u=n/N|0,l=1<<n%N,c=i?.types;if(c===void 0)s.typeAny[u]|=l,s.atEnd[u]|=l;else for(let p of c)s.byType[chunkYBQOQTVL_cjs.c(p)*t+u]|=l;let f=i?.values;if(f===void 0)s.valueAny[u]|=l;else {for(let p of f){let h=p.toLowerCase(),o=s.byValue.get(h);o===void 0&&(o=new Uint32Array(t),s.byValue.set(h,o)),o[u]|=l;}if(c===void 0)s.typeHasValues.fill(1);else for(let p of c){let h=chunkYBQOQTVL_cjs.c(p);h<this.typeRows&&(s.typeHasValues[h]=1);}}}return s}get size(){return this.rules.length}get depth(){return this.planes.length}candidates(e,r){let t=this.words,s=this.scratch,n=this.planes,i=e.length;if(n.length===0)return s.set(this.allRules),s;for(let u=0;u<n.length;u++){let l=n[u],c=r+u;if(c>=i){if(u===0)s.set(l.atEnd);else for(let o=0;o<t;o++)s[o]&=l.atEnd[o];continue}let f=e[c],p=f.typeId,h=p>=0&&p<this.typeRows?p*t:-1;if(u===0)if(h>=0)for(let o=0;o<t;o++)s[o]=l.byType[h+o]|l.typeAny[o];else s.set(l.typeAny);else if(h>=0)for(let o=0;o<t;o++)s[o]&=l.byType[h+o]|l.typeAny[o];else for(let o=0;o<t;o++)s[o]&=l.typeAny[o];if(h>=0&&l.typeHasValues[p]===1){let o=f.value,R=O(o)?o.toLowerCase():o,g=l.byValue.get(R);for(let T=0;T<t;T++)s[T]&=(g===void 0?0:g[T])|l.valueAny[T];}if(S(s))return s}return s}};function S(a){for(let e=0;e<a.length;e++)if(a[e]!==0)return false;return true}function O(a){for(let e=0;e<a.length;e++){let r=a.charCodeAt(e);if(r>=65&&r<=90)return true}return false}var B={maxPasses:100,maxTokens:1e4,onFusion:()=>{},ignoreRuleIndex:false};function C(a,e,r){let t=r[0],s=r[r.length-1],n=new chunkWU7SBKVU_cjs.a(a,chunkYBQOQTVL_cjs.c(a),e,e,t.offset,t.lineBreaks??0,t.line,t.col);return n.sourceEnd=s.sourceEnd??s.offset+s.text.length,n}function z(a,e){let r=e[e.length-1];r&&(a.sourceEnd=r.sourceEnd??r.offset+r.text.length);}var _=["NUMBER","HEX","BIGINT","FLOAT","LSHIFT","RSHIFT","BIT_AND","BIT_OR","BIT_XOR","LPAREN","RPAREN","LBRACKET","RBRACKET","COMMA","COLON","EQUALS","THEREFORE","PIPE","AMPERSAND","AT","SEMICOLON","QUESTION","EXCLAMATION","EOF","WS","NEWLINE"],M=(()=>{let a=_.map(t=>chunkYBQOQTVL_cjs.c(t)),e=Math.max(...a)+1,r=new Uint8Array(e);for(let t of a)r[t]=1;return r})(),P=new Set;function D(a){a.shape!==void 0&&a.shape.length>0||a.startTokenTypes===void 0&&a.unshapedReason===void 0&&(P.has(a.name)||(P.add(a.name),console.warn(`[TokenNormalizer] Rule "${a.name}" declares no \`shape\`, so it is tried at every token of every line and slows down documents that never use it. Declare the tokens it can start at, e.g. shape: [{ types: ["IDENT"], values: ["myword"] }, { types: ["LPAREN"] }]. If it genuinely cannot be described that way, set \`unshapedReason\` to say why and this warning will stop.`)));}var U=class{constructor(e={}){this.rules=[];this.sortedRulesCache=null;this.rulesByTokenType=new Map;this.ruleIndexCache=null;this.candidateBuffer=[];this.normalizeCalls=0;this.phraseTrie=new w;this.ruleShapesCache=null;this.options={...B,...e};}register(e){D(e),this.rules.push(e),this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null;}unregister(e){this.rules=this.rules.filter(r=>r.name!==e),this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null;}clear(){this.rules=[],this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null,this.phraseTrie=new w;}getSortedRules(){return this.sortedRulesCache===null&&(this.sortedRulesCache=[...this.rules].sort((e,r)=>r.priority-e.priority)),this.sortedRulesCache}getRuleIndex(){return this.ruleIndexCache===null&&(this.ruleIndexCache=new x(this.getSortedRules())),this.ruleIndexCache}rulesAt(e,r){if(e===null)return this.options.ignoreRuleIndex?this.getSortedRules():this.rulesForTokenType(r);let t=this.candidateBuffer;t.length=0;let s=this.getRuleIndex().rules;for(let n=0;n<e.length;n++){let i=e[n]>>>0,u=n*32;for(;i!==0;)(i&1)!==0&&t.push(s[u]),i>>>=1,u++;}return t}rulesForTokenType(e){let r=this.rulesByTokenType.get(e);return r===void 0&&(r=this.getSortedRules().filter(t=>{let s=v(t)[0];return s?.types===void 0||s.types.includes(e)}),this.rulesByTokenType.set(e,r)),r}get ruleCount(){return this.rules.length}getRuleShapes(){if(this.ruleShapesCache!==null)return this.ruleShapesCache;let e=this.getRuleIndex();return this.ruleShapesCache=this.getSortedRules().map(r=>{let t=v(r);return {name:r.name,priority:r.priority,shape:t,unshapedReason:r.unshapedReason,indexedSlots:Math.min(t.length,e.depth)}}),this.ruleShapesCache}getCandidateCounts(e){let r=this.getRuleIndex(),t=[];for(let s=0;s<e.length;s++){let n=r.candidates(e,s),i=0;for(let u=0;u<n.length;u++){let l=n[u]>>>0;for(;l!==0;)i+=l&1,l>>>=1;}t.push(i);}return t}addPhrase(e,r){this.phraseTrie.addPhrase(e,r);}getPhrases(){return this.phraseTrie.getAllPhrases()}canStartPhrase(e){return this.phraseTrie.canStart(e)}normalize(e,r){if(e.length===0)return e;let t=r??this.options.onFusion,s=this.options.maxPasses,n=this.options.maxTokens,i=this.normalizeCalls>0;i||(this.normalizeCalls=1);let u=i&&!this.options.ignoreRuleIndex,l=u?this.getRuleIndex():null,c=e,f=true,p=0;for(;f&&p<s;){f=false,p++;let h=null,o=0;for(;o<c.length;){let g=false,T=c[o].typeId;if(T>=M.length||M[T]===0){let m=this.phraseTrie.matchAt(c,o);if(m){let d=c.slice(o,o+m.consumed);h===null&&(h=c.slice(0,o));for(let A of m.replacement)h.push(A);m.consumed>1&&m.replacement.length===1&&(z(m.replacement[0],d),t({rule:m.ruleName??"phrase-trie",sourceTokens:d,fusedToken:m.replacement[0]})),o+=m.consumed,f=true;continue}}let I=u?l.candidates(c,o):null;if(I!==null&&S(I)){h!==null&&h.push(c[o]),o++;continue}for(let m of this.rulesAt(I,c[o].type)){let d=m.match(c,o);if(d){let A=c.slice(o,o+d.consumed);h===null&&(h=c.slice(0,o));for(let b of d.replacement)h.push(b);if(d.consumed>1&&d.replacement.length===1)z(d.replacement[0],A),t({rule:m.name,sourceTokens:A,fusedToken:d.replacement[0]});else if(d.consumed>1&&d.replacement.length<d.consumed)for(let b of d.replacement)t({rule:m.name,sourceTokens:A,fusedToken:b});o+=d.consumed,f=true,g=true;break}}g||(h!==null&&h.push(c[o]),o++);}if(h===null)break;let R=h;if(R.length>n)throw chunkSUAGBRQ7_cjs.c.validation("NORMALIZED_TOKEN_LIMIT_EXCEEDED",`Normalized token count (${R.length}) exceeds safety limit (${n})`,{tokenCount:R.length,maxTokens:n});c=R;}return c}};var w=class{constructor(){this.startWords=new Set;this.root=new Map;}addPhrase(e,r){let t=e.toLowerCase().trim().split(/\s+/);if(t.length===0||t[0]==="")return;this.startWords.add(t[0]);let s=t[0],n;if(this.root.has(s)?n=this.root.get(s):(n={children:new Map,terminal:null},this.root.set(s,n)),t.length===1){n.terminal={tokenType:r,phrase:e,consumed:1};return}for(let i=1;i<t.length;i++){let u=t[i];n.children.has(u)||n.children.set(u,{children:new Map,terminal:null}),n=n.children.get(u);}n.terminal={tokenType:r,phrase:e,consumed:t.length};}matchAt(e,r){if(r>=e.length)return null;let t=e[r].type;if(t==="TAG"||t.startsWith("TAG_"))return null;let s=e[r].value.toLowerCase();if(!this.startWords.has(s))return null;let n=this.root.get(s);if(!n)return null;let i=null,u=1;if(n.terminal){let l=e.slice(r,r+1);i={consumed:1,replacement:[C(n.terminal.tokenType,n.terminal.phrase,l)],ruleName:n.terminal.phrase};}for(let l=r+1;l<e.length&&n?.children;l++){let c=e[l].type;if(c==="TAG"||c.startsWith("TAG_"))break;let f=e[l].value.toLowerCase();if(n=n.children.get(f),!n)break;if(u++,n.terminal){let p=e.slice(r,r+u);i={consumed:u,replacement:[C(n.terminal.tokenType,n.terminal.phrase,p)],ruleName:n.terminal.phrase};}}return i}get size(){return this.root.size}getAllPhrases(){let e={},r=(t,s)=>{t.terminal&&(e[s.join(" ")]=t.terminal.tokenType);for(let[n,i]of t.children)r(i,[...s,n]);};for(let[t,s]of this.root)r(s,[t]);return e}canStart(e){return this.startWords.has(e.toLowerCase())}};var F=new Set(["per","a","an","each","every"]),W=new Set(["to","power","increase","decrease","times","multiply","divide","by"]);function H(a=50,e){let r=e??(t=>W.has(t.toLowerCase()));return {name:"implicit:multiply",priority:a,shape:[{types:["NUMBER","RPAREN"]},{types:["IDENT","LPAREN","PI","E"]}],match(t,s){if(s+1>=t.length)return null;let n=t[s],i=t[s+1];if(!((n.type==="NUMBER"||n.type==="RPAREN")&&(i.type==="IDENT"||i.type==="LPAREN"||i.type==="PI"||i.type==="E")))return null;let l=i.value.toLowerCase();if(r(l)||F.has(l)&&t[s+2]?.type==="UNIT")return null;let c=new chunkWU7SBKVU_cjs.a("STAR",chunkYBQOQTVL_cjs.c("STAR"),"*","*",i.offset,0,i.line,i.col);return {consumed:1,replacement:[n,c]}}}}function ne(a,e){let r=[];for(let t=0;t<e;t++){let s=a[t];if(s.type==="LBRACKET")r.push(true);else if(s.type==="LPAREN"){let n=a[t-1],i=!!n&&(n.type==="MAP"||n.type==="REDUCE"||n.type==="SUM_FN"||n.type==="PROD_FN"||n.type==="IDENT"&&(n.value.toLowerCase()==="map"||n.value.toLowerCase()==="reduce"||n.value.toLowerCase()==="sum"||n.value.toLowerCase()==="prod"));r.push(i);}else (s.type==="RBRACKET"||s.type==="RPAREN")&&r.pop();}return r.length>0&&r[r.length-1]}function re(){return [H()]}exports.a=w;exports.b=C;exports.c=U;exports.d=H;exports.e=ne;exports.f=re;//# sourceMappingURL=chunk-4DR5RBHQ.cjs.map
2
+ //# sourceMappingURL=chunk-4DR5RBHQ.cjs.map