@absoluteui/helpers 0.0.0-stage → 0.13.1

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 (221) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +47 -2
  4. package/SECURITY.md +102 -0
  5. package/dist/array/compare.d.ts +8 -0
  6. package/dist/array/compare.js +2 -0
  7. package/dist/array/index.d.ts +328 -0
  8. package/dist/array/index.js +2 -0
  9. package/dist/array/tree.d.ts +48 -0
  10. package/dist/array/tree.js +2 -0
  11. package/dist/async/batch.d.ts +103 -0
  12. package/dist/async/batch.js +2 -0
  13. package/dist/async/concurrency.d.ts +92 -0
  14. package/dist/async/concurrency.js +2 -0
  15. package/dist/async/control.d.ts +77 -0
  16. package/dist/async/control.js +2 -0
  17. package/dist/async/index.d.ts +8 -0
  18. package/dist/async/index.js +2 -0
  19. package/dist/async/signal.d.ts +95 -0
  20. package/dist/async/signal.js +2 -0
  21. package/dist/boolean/index.d.ts +83 -0
  22. package/dist/boolean/index.js +2 -0
  23. package/dist/business-calendar/days.d.ts +397 -0
  24. package/dist/business-calendar/days.js +2 -0
  25. package/dist/business-calendar/describe.d.ts +45 -0
  26. package/dist/business-calendar/describe.js +2 -0
  27. package/dist/business-calendar/engine.d.ts +305 -0
  28. package/dist/business-calendar/engine.js +2 -0
  29. package/dist/business-calendar/hours.d.ts +96 -0
  30. package/dist/business-calendar/hours.js +2 -0
  31. package/dist/business-calendar/index.d.ts +29 -0
  32. package/dist/business-calendar/index.js +2 -0
  33. package/dist/business-calendar/internal.d.ts +44 -0
  34. package/dist/business-calendar/internal.js +2 -0
  35. package/dist/business-calendar/rules.d.ts +260 -0
  36. package/dist/business-calendar/rules.js +2 -0
  37. package/dist/color/index.d.ts +200 -0
  38. package/dist/color/index.js +2 -0
  39. package/dist/color/named.d.ts +4 -0
  40. package/dist/color/named.js +2 -0
  41. package/dist/compare/index.d.ts +186 -0
  42. package/dist/compare/index.js +2 -0
  43. package/dist/convert/index.d.ts +152 -0
  44. package/dist/convert/index.js +2 -0
  45. package/dist/csv/index.d.ts +6 -0
  46. package/dist/csv/index.js +2 -0
  47. package/dist/csv/parse.d.ts +85 -0
  48. package/dist/csv/parse.js +12 -0
  49. package/dist/csv/stringify.d.ts +48 -0
  50. package/dist/csv/stringify.js +5 -0
  51. package/dist/date/calendar.d.ts +339 -0
  52. package/dist/date/calendar.js +2 -0
  53. package/dist/date/format.d.ts +66 -0
  54. package/dist/date/format.js +2 -0
  55. package/dist/date/index.d.ts +26 -0
  56. package/dist/date/index.js +2 -0
  57. package/dist/date/intervals.d.ts +110 -0
  58. package/dist/date/intervals.js +2 -0
  59. package/dist/date/intl-cache.d.ts +10 -0
  60. package/dist/date/intl-cache.js +2 -0
  61. package/dist/date/locale.d.ts +58 -0
  62. package/dist/date/locale.js +2 -0
  63. package/dist/date/plain-date.d.ts +105 -0
  64. package/dist/date/plain-date.js +2 -0
  65. package/dist/date/plain-time.d.ts +121 -0
  66. package/dist/date/plain-time.js +2 -0
  67. package/dist/date/zone.d.ts +121 -0
  68. package/dist/date/zone.js +2 -0
  69. package/dist/decimal/index.d.ts +149 -0
  70. package/dist/decimal/index.js +2 -0
  71. package/dist/ds/avl.d.ts +50 -0
  72. package/dist/ds/avl.js +2 -0
  73. package/dist/ds/bitset.d.ts +46 -0
  74. package/dist/ds/bitset.js +2 -0
  75. package/dist/ds/bloom.d.ts +41 -0
  76. package/dist/ds/bloom.js +2 -0
  77. package/dist/ds/caches.d.ts +141 -0
  78. package/dist/ds/caches.js +2 -0
  79. package/dist/ds/disjoint-set.d.ts +38 -0
  80. package/dist/ds/disjoint-set.js +2 -0
  81. package/dist/ds/emitter.d.ts +53 -0
  82. package/dist/ds/emitter.js +2 -0
  83. package/dist/ds/graph.d.ts +84 -0
  84. package/dist/ds/graph.js +2 -0
  85. package/dist/ds/heap.d.ts +49 -0
  86. package/dist/ds/heap.js +2 -0
  87. package/dist/ds/index.d.ts +20 -0
  88. package/dist/ds/index.js +2 -0
  89. package/dist/ds/internal.d.ts +19 -0
  90. package/dist/ds/internal.js +2 -0
  91. package/dist/ds/interval-tree.d.ts +49 -0
  92. package/dist/ds/interval-tree.js +2 -0
  93. package/dist/ds/linked-list.d.ts +54 -0
  94. package/dist/ds/linked-list.js +2 -0
  95. package/dist/ds/maps.d.ts +89 -0
  96. package/dist/ds/maps.js +2 -0
  97. package/dist/ds/ring.d.ts +99 -0
  98. package/dist/ds/ring.js +2 -0
  99. package/dist/ds/sorted.d.ts +104 -0
  100. package/dist/ds/sorted.js +2 -0
  101. package/dist/ds/stack.d.ts +28 -0
  102. package/dist/ds/stack.js +2 -0
  103. package/dist/ds/trie.d.ts +84 -0
  104. package/dist/ds/trie.js +2 -0
  105. package/dist/duration/index.d.ts +146 -0
  106. package/dist/duration/index.js +2 -0
  107. package/dist/encoding/index.d.ts +144 -0
  108. package/dist/encoding/index.js +2 -0
  109. package/dist/error/index.d.ts +316 -0
  110. package/dist/error/index.js +2 -0
  111. package/dist/fn/index.d.ts +129 -0
  112. package/dist/fn/index.js +2 -0
  113. package/dist/fn/memo.d.ts +46 -0
  114. package/dist/fn/memo.js +2 -0
  115. package/dist/fn/timing.d.ts +64 -0
  116. package/dist/fn/timing.js +2 -0
  117. package/dist/http/headers.d.ts +160 -0
  118. package/dist/http/headers.js +2 -0
  119. package/dist/http/index.d.ts +10 -0
  120. package/dist/http/index.js +2 -0
  121. package/dist/http/problem.d.ts +37 -0
  122. package/dist/http/problem.js +2 -0
  123. package/dist/http/response.d.ts +43 -0
  124. package/dist/http/response.js +2 -0
  125. package/dist/http/status.d.ts +169 -0
  126. package/dist/http/status.js +2 -0
  127. package/dist/index.d.ts +34 -0
  128. package/dist/index.js +2 -0
  129. package/dist/internal/keys.d.ts +6 -0
  130. package/dist/internal/keys.js +2 -0
  131. package/dist/is/index.d.ts +219 -0
  132. package/dist/is/index.js +2 -0
  133. package/dist/json/index.d.ts +9 -0
  134. package/dist/json/index.js +2 -0
  135. package/dist/json/internal.d.ts +12 -0
  136. package/dist/json/internal.js +2 -0
  137. package/dist/json/ndjson.d.ts +28 -0
  138. package/dist/json/ndjson.js +4 -0
  139. package/dist/json/parse.d.ts +45 -0
  140. package/dist/json/parse.js +2 -0
  141. package/dist/json/patch.d.ts +62 -0
  142. package/dist/json/patch.js +2 -0
  143. package/dist/json/pointer.d.ts +43 -0
  144. package/dist/json/pointer.js +2 -0
  145. package/dist/json/stringify.d.ts +42 -0
  146. package/dist/json/stringify.js +2 -0
  147. package/dist/linq/enumerable.d.ts +208 -0
  148. package/dist/linq/enumerable.js +2 -0
  149. package/dist/linq/index.d.ts +6 -0
  150. package/dist/linq/index.js +2 -0
  151. package/dist/linq/operators.d.ts +503 -0
  152. package/dist/linq/operators.js +2 -0
  153. package/dist/number/core.d.ts +164 -0
  154. package/dist/number/core.js +2 -0
  155. package/dist/number/format.d.ts +80 -0
  156. package/dist/number/format.js +2 -0
  157. package/dist/number/index.d.ts +12 -0
  158. package/dist/number/index.js +2 -0
  159. package/dist/number/internal.d.ts +18 -0
  160. package/dist/number/internal.js +2 -0
  161. package/dist/number/parse.d.ts +45 -0
  162. package/dist/number/parse.js +2 -0
  163. package/dist/number/words.d.ts +19 -0
  164. package/dist/number/words.js +2 -0
  165. package/dist/object/basic.d.ts +130 -0
  166. package/dist/object/basic.js +2 -0
  167. package/dist/object/deep.d.ts +90 -0
  168. package/dist/object/deep.js +2 -0
  169. package/dist/object/diff.d.ts +57 -0
  170. package/dist/object/diff.js +2 -0
  171. package/dist/object/index.d.ts +8 -0
  172. package/dist/object/index.js +2 -0
  173. package/dist/object/internal.d.ts +21 -0
  174. package/dist/object/internal.js +2 -0
  175. package/dist/object/path.d.ts +17 -0
  176. package/dist/object/path.js +2 -0
  177. package/dist/random/core.d.ts +14 -0
  178. package/dist/random/core.js +2 -0
  179. package/dist/random/index.d.ts +167 -0
  180. package/dist/random/index.js +2 -0
  181. package/dist/random/seeded.d.ts +27 -0
  182. package/dist/random/seeded.js +2 -0
  183. package/dist/sanitize/index.d.ts +8 -0
  184. package/dist/sanitize/index.js +2 -0
  185. package/dist/sanitize/pii.d.ts +48 -0
  186. package/dist/sanitize/pii.js +2 -0
  187. package/dist/sanitize/records.d.ts +100 -0
  188. package/dist/sanitize/records.js +2 -0
  189. package/dist/sanitize/text.d.ts +101 -0
  190. package/dist/sanitize/text.js +2 -0
  191. package/dist/set/index.d.ts +162 -0
  192. package/dist/set/index.js +2 -0
  193. package/dist/stats/index.d.ts +190 -0
  194. package/dist/stats/index.js +2 -0
  195. package/dist/string/index.d.ts +494 -0
  196. package/dist/string/index.js +8 -0
  197. package/dist/string/internal.d.ts +33 -0
  198. package/dist/string/internal.js +2 -0
  199. package/dist/string/words.d.ts +14 -0
  200. package/dist/string/words.js +2 -0
  201. package/dist/timezone/index.d.ts +76 -0
  202. package/dist/timezone/index.js +2 -0
  203. package/dist/url/index.d.ts +178 -0
  204. package/dist/url/index.js +2 -0
  205. package/dist/validate/builders.d.ts +6 -0
  206. package/dist/validate/builders.js +2 -0
  207. package/dist/validate/formats.d.ts +237 -0
  208. package/dist/validate/formats.js +2 -0
  209. package/dist/validate/index.d.ts +13 -0
  210. package/dist/validate/index.js +2 -0
  211. package/dist/validate/schema.d.ts +220 -0
  212. package/dist/validate/schema.js +2 -0
  213. package/dist/zip/index.d.ts +8 -0
  214. package/dist/zip/index.js +2 -0
  215. package/dist/zip/internal.d.ts +69 -0
  216. package/dist/zip/internal.js +2 -0
  217. package/dist/zip/reader.d.ts +56 -0
  218. package/dist/zip/reader.js +2 -0
  219. package/dist/zip/writer.d.ts +65 -0
  220. package/dist/zip/writer.js +2 -0
  221. package/package.json +150 -4
@@ -0,0 +1,58 @@
1
+ import type { IsoWeekday } from './plain-date.js';
2
+ /** Locale week conventions (CLDR weekData). */
3
+ export interface WeekInfo {
4
+ /** First day of the week, ISO numbering (1 = Monday ... 7 = Sunday). */
5
+ readonly firstDay: IsoWeekday;
6
+ /** Weekend days, ISO numbering, ascending. */
7
+ readonly weekend: readonly IsoWeekday[];
8
+ /** Days of the new year the first week of the year must contain (1-7). */
9
+ readonly minimalDays: number;
10
+ }
11
+ export interface GetWeekInfoOptions {
12
+ /** Use the engine's `getWeekInfo()`/`weekInfo` when present. Default true; false forces the embedded table. */
13
+ readonly useNative?: boolean;
14
+ }
15
+ /**
16
+ * Week conventions for a locale (default: the runtime locale): first day, weekend days, and
17
+ * minimal days of week 1. Uses `Intl.Locale#getWeekInfo()` (or the older `weekInfo` accessor)
18
+ * when present, otherwise an embedded CLDR table. Locales without a region are maximized
19
+ * (`ar` -> `ar-EG`).
20
+ * @example getWeekInfo('ar-SA') // => { firstDay: 7, weekend: [5, 6], minimalDays: 1 }
21
+ */
22
+ export declare function getWeekInfo(locale?: string, options?: GetWeekInfoOptions): WeekInfo;
23
+ /** Width of a localized name. */
24
+ export type NameStyle = 'long' | 'short' | 'narrow';
25
+ export interface NameOptions {
26
+ /** BCP 47 locale; default the runtime locale. */
27
+ readonly locale?: string;
28
+ /** Default `'long'`. */
29
+ readonly style?: NameStyle;
30
+ }
31
+ /**
32
+ * Localized weekday name.
33
+ * @example weekdayName(1, { locale: 'fr', style: 'long' }) // => 'lundi'
34
+ */
35
+ export declare function weekdayName(weekday: IsoWeekday, options?: NameOptions): string;
36
+ /**
37
+ * Seven localized weekday names starting at `firstDay` (default 1, Monday).
38
+ * @example weekdayNames('en-US', 7, 'short') // => ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
39
+ */
40
+ export declare function weekdayNames(locale?: string, firstDay?: IsoWeekday, style?: NameStyle): string[];
41
+ export interface MonthNameOptions extends NameOptions {
42
+ /**
43
+ * `'standalone'` (default, for headers and lists) or `'format'` (the form used next to a day
44
+ * number, which differs in, for example, Russian and Polish: "сентября" vs "сентябрь").
45
+ */
46
+ readonly context?: 'standalone' | 'format';
47
+ }
48
+ /**
49
+ * Localized month name for month 1-12.
50
+ * @example monthName(9, { locale: 'ru', context: 'format' }) // => 'сентября'
51
+ */
52
+ export declare function monthName(month: number, options?: MonthNameOptions): string;
53
+ /**
54
+ * Twelve localized month names (January first).
55
+ * @example monthNames('de', 'short').slice(0, 3) // => ['Jan', 'Feb', 'Mär']
56
+ * @example monthNames('en').length // => 12
57
+ */
58
+ export declare function monthNames(locale?: string, style?: NameStyle, context?: 'standalone' | 'format'): string[];
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as I}from"../error/index.js";import{assertIsoWeekday as u}from"./calendar.js";import{dateTimeFormat as y}from"./intl-cache.js";function d(e,n){return Object.fromEntries(e.split(" ").map(t=>[t,n]))}const O=Object.freeze([5,6]),N=Object.freeze([7]),S=Object.freeze({...d("AG AS BD BR BS BT BW BZ CA CO DM DO ET GT GU HK HN ID IL IN IS JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW",7),...d("AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY",6),MV:5}),A=Object.freeze({...d("BH DZ EG IL IQ JO KW LY OM QA SA SD SY YE",O),AF:Object.freeze([4,5]),IR:Object.freeze([5]),IN:N,UG:N}),E=new Set("AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL RE RU SE SJ SK SM VA".split(" ")),w=Object.freeze([6,7]),g=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=7;function L(e){const n=e??new Intl.DateTimeFormat().resolvedOptions().locale;if(typeof n!="string"||n.length>128)throw new I("HLP_INVALID_LOCALE","Invalid locale.");try{return new Intl.Locale(n)}catch(t){throw new I("HLP_INVALID_LOCALE","Invalid locale.",{cause:t})}}const f=new Map;function P(e,n={}){const t=L(e),a=n.useNative??!0,r=`${t.toString()}|${String(a)}`,i=f.get(r);if(i)return i;const s=t.region??t.maximize().region??"001";let c=S[s]??1,m=A[s]??w,k=E.has(s)?4:1;if(a){const l=t;let o;try{o=typeof l.getWeekInfo=="function"?l.getWeekInfo():l.weekInfo}catch{o=void 0}o&&(g(o.firstDay)&&(c=o.firstDay),Array.isArray(o.weekend)&&o.weekend.every(g)&&(m=Object.freeze([...o.weekend].sort((D,p)=>D-p))),typeof o.minimalDays=="number"&&Number.isInteger(o.minimalDays)&&o.minimalDays>=1&&o.minimalDays<=7&&(k=o.minimalDays))}const W=Object.freeze({firstDay:c,weekend:m,minimalDays:k});return f.size>=256&&f.clear(),f.set(r,W),W}const T=e=>Date.UTC(2024,0,e,12);function M(e,n={}){return u(e,"weekday"),y(n.locale,{weekday:n.style??"long",timeZone:"UTC"}).format(T(e))}function H(e,n=1,t="long"){u(n);const a=[];for(let r=0;r<7;r++)a.push(M((n-1+r)%7+1,e===void 0?{style:t}:{locale:e,style:t}));return a}function b(e,n={}){if(!Number.isInteger(e)||e<1||e>12)throw new I("HLP_DATE_INVALID_MONTH","Month must be an integer 1 to 12.");const t=n.style??"long",a=Date.UTC(2024,e-1,15,12);if(n.context==="format"){const i=y(n.locale,{month:t,day:"numeric",timeZone:"UTC"}).formatToParts(a).find(s=>s.type==="month");if(i)return i.value}return y(n.locale,{month:t,timeZone:"UTC"}).format(a)}function U(e,n="long",t="standalone"){const a=[];for(let r=1;r<=12;r++)a.push(b(r,e===void 0?{style:n,context:t}:{locale:e,style:n,context:t}));return a}export{P as getWeekInfo,b as monthName,U as monthNames,M as weekdayName,H as weekdayNames};
@@ -0,0 +1,105 @@
1
+ export interface PlainDate {
2
+ readonly kind: 'PlainDate';
3
+ readonly year: number;
4
+ /** 1-12 */
5
+ readonly month: number;
6
+ /** 1-31 */
7
+ readonly day: number;
8
+ }
9
+ /**
10
+ * ISO weekday: 1 = Monday ... 7 = Sunday.
11
+ * @example const saturday: IsoWeekday = 6;
12
+ */
13
+ export type IsoWeekday = 1 | 2 | 3 | 4 | 5 | 6 | 7;
14
+ /**
15
+ * Anything accepted where a date-only value is expected. Strings must be `YYYY-MM-DD`.
16
+ * @example const d: DateInput = '2026-09-29';
17
+ */
18
+ export type DateInput = PlainDate | string;
19
+ /**
20
+ * Supported year range (matches `@absoluteui/core`).
21
+ * @example plainDate(MAX_YEAR, 1, 1)
22
+ */
23
+ export declare const MAX_YEAR = 275759;
24
+ /**
25
+ * True for Gregorian leap years.
26
+ * @example isLeapYear(2024) // => true
27
+ */
28
+ export declare function isLeapYear(year: number): boolean;
29
+ /**
30
+ * Days in `month` (1-12) of `year`; 0 for an invalid month.
31
+ * @example daysInMonth(2024, 2) // => 29
32
+ */
33
+ export declare function daysInMonth(year: number, month: number): number;
34
+ /**
35
+ * 365 or 366.
36
+ * @example daysInYear(2024) // => 366
37
+ */
38
+ export declare function daysInYear(year: number): number;
39
+ /**
40
+ * Creates a validated, frozen date-only value.
41
+ * @example plainDate(2026, 2, 28)
42
+ */
43
+ export declare function plainDate(year: number, month: number, day: number): PlainDate;
44
+ /**
45
+ * Type guard for `PlainDate`-shaped values (including core's).
46
+ * @example isPlainDate(plainDate(2026, 1, 1)) // => true
47
+ */
48
+ export declare function isPlainDate(value: unknown): value is PlainDate;
49
+ /**
50
+ * Days since 1970-01-01 for a date.
51
+ * @example toEpochDay(plainDate(1970, 1, 2)) // => 1
52
+ */
53
+ export declare function toEpochDay(date: PlainDate): number;
54
+ /**
55
+ * Date for a count of days since 1970-01-01.
56
+ * @example fromEpochDay(0) // => '1970-01-01'
57
+ */
58
+ export declare function fromEpochDay(epochDay: number): PlainDate;
59
+ /**
60
+ * Parses `YYYY-MM-DD` strictly. Returns `undefined` for anything else, including
61
+ * impossible dates (`2026-02-30`) and date-times.
62
+ * @example parsePlainDate('2026-09-29')
63
+ */
64
+ export declare function parsePlainDate(text: string): PlainDate | undefined;
65
+ /**
66
+ * ISO 8601 `YYYY-MM-DD` (extended years as `+/-YYYYYY`).
67
+ * @example formatPlainDate(plainDate(2026, 9, 29)) // => '2026-09-29'
68
+ */
69
+ export declare function formatPlainDate(date: PlainDate): string;
70
+ /**
71
+ * Normalizes `PlainDate | 'YYYY-MM-DD'`; throws `HLP_INVALID_DATE` for bad strings.
72
+ * @example toPlainDate('2026-09-29')
73
+ */
74
+ export declare function toPlainDate(input: DateInput): PlainDate;
75
+ /**
76
+ * ISO weekday (1 = Monday ... 7 = Sunday).
77
+ * @example isoWeekday('2026-09-29') // => 2 // Tuesday
78
+ */
79
+ export declare function isoWeekday(date: DateInput): IsoWeekday;
80
+ /**
81
+ * Adds (or subtracts) days.
82
+ * @example addDays('2026-12-31', 1) // => '2027-01-01'
83
+ */
84
+ export declare function addDays(date: DateInput, days: number): PlainDate;
85
+ /**
86
+ * Orders two dates: `-1`, `0`, or `1`.
87
+ * @example ['2026-02-01', '2026-01-01'].sort(comparePlainDates)
88
+ */
89
+ export declare function comparePlainDates(a: DateInput, b: DateInput): -1 | 0 | 1;
90
+ /**
91
+ * Calendar days from `a` to `b` (negative when `b` is earlier), endpoints exclusive of `a`.
92
+ * @example daysBetween('2026-01-01', '2026-01-31') // => 30
93
+ */
94
+ export declare function daysBetween(a: DateInput, b: DateInput): number;
95
+ /**
96
+ * Today's date in `timeZone` (default: the runtime's zone).
97
+ * @example today('Asia/Kolkata') // e.g. '2026-09-30' (the current date in Kolkata)
98
+ */
99
+ export declare function today(timeZone?: string): PlainDate;
100
+ /**
101
+ * The calendar date of an instant (epoch ms or `Date`) as observed in `timeZone`.
102
+ * Throws `HLP_TZ_INVALID_ZONE` for an unknown zone.
103
+ * @example plainDateFromInstant(Date.UTC(2026, 0, 1, 20), 'Asia/Kolkata') // => '2026-01-02'
104
+ */
105
+ export declare function plainDateFromInstant(instant: number | Date, timeZone?: string): PlainDate;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as s}from"../error/index.js";const d=275759;function I(e){return e%4===0&&e%100!==0||e%400===0}const P=[31,28,31,30,31,30,31,31,30,31,30,31];function b(e,t){return t===2?I(e)?29:28:P[t-1]??0}function A(e){return I(e)?366:365}function y(e,t,r,n){if(!Number.isInteger(e)||e<t||e>r)throw new s("HLP_DATE_OUT_OF_RANGE","Date field out of range.",{details:{property:n,min:t,max:r}})}function h(e,t,r){return y(e,-d,d,"year"),y(t,1,12,"month"),y(r,1,b(e,t),"day"),Object.freeze({kind:"PlainDate",year:e,month:t,day:r})}function N(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.kind==="PlainDate"&&Number.isInteger(t.year)&&Number.isInteger(t.month)&&Number.isInteger(t.day)&&(t.month??0)>=1&&(t.month??0)<=12&&(t.day??0)>=1&&(t.day??0)<=b(t.year??0,t.month??0)}function f(e){const t=e.month<=2?e.year-1:e.year,r=Math.floor(t/400),n=t-r*400,o=(e.month+9)%12,u=Math.floor((153*o+2)/5)+e.day-1,i=n*365+Math.floor(n/4)-Math.floor(n/100)+u;return r*146097+i-719468}function _(e){if(!Number.isInteger(e))throw new s("HLP_DATE_OUT_OF_RANGE","Epoch day must be an integer.");const t=e+719468,r=Math.floor(t/146097),n=t-r*146097,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/146096))/365),u=n-(365*o+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*u+2)/153),l=u-Math.floor((153*i+2)/5)+1,m=i<10?i+3:i-9,a=o+r*400+(m<=2?1:0);return h(a,m,l)}const M=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/;function E(e){if(typeof e!="string"||e.length>13)return;const t=M.exec(e);if(!t)return;const r=Number(t[1]),n=Number(t[2]),o=Number(t[3]);if(t[1]!=="-000000"&&!(Math.abs(r)>d||n<1||n>12||o<1||o>b(r,n)))return h(r,n,o)}const p=(e,t=2)=>String(Math.abs(e)).padStart(t,"0");function w(e){return`${e.year>=0&&e.year<=9999?p(e.year,4):`${e.year<0?"-":"+"}${p(e.year,6)}`}-${p(e.month)}-${p(e.day)}`}function c(e){if(typeof e=="string"){const t=E(e);if(!t)throw new s("HLP_INVALID_DATE","Expected a date in YYYY-MM-DD format.");return t}if(!N(e))throw new s("HLP_INVALID_DATE","Expected a PlainDate.");return e}function T(e){return((f(c(e))+3)%7+7)%7+1}function L(e,t){return y(t,-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,"days"),_(f(c(e))+t)}function k(e,t){const r=f(c(e)),n=f(c(t));return r<n?-1:r>n?1:0}function F(e,t){return f(c(t))-f(c(e))}function O(e){return g(Date.now(),e)}const D=new Map;function g(e,t){const r=typeof e=="number"?e:e.getTime();if(!Number.isFinite(r))throw new s("HLP_INVALID_DATE","Invalid instant.");const n=t??"";let o=D.get(n);if(!o){try{o=new Intl.DateTimeFormat("en-US",{timeZone:t,era:"short",year:"numeric",month:"numeric",day:"numeric"})}catch(a){throw new s("HLP_TZ_INVALID_ZONE","Unsupported time zone identifier.",{cause:a})}D.size>=256&&D.clear(),D.set(n,o)}let u=0,i=0,l=0,m=!1;for(const a of o.formatToParts(r))a.type==="year"?u=Number(a.value):a.type==="month"?i=Number(a.value):a.type==="day"?l=Number(a.value):a.type==="era"&&(m=a.value==="BC"||a.value==="B");return h(m?1-u:u,i,l)}export{d as MAX_YEAR,L as addDays,k as comparePlainDates,F as daysBetween,b as daysInMonth,A as daysInYear,w as formatPlainDate,_ as fromEpochDay,I as isLeapYear,N as isPlainDate,T as isoWeekday,E as parsePlainDate,h as plainDate,g as plainDateFromInstant,f as toEpochDay,c as toPlainDate,O as today};
@@ -0,0 +1,121 @@
1
+ import { type DateInput, type PlainDate } from './plain-date.js';
2
+ export interface PlainTime {
3
+ readonly kind: 'PlainTime';
4
+ /** 0-23 */
5
+ readonly hour: number;
6
+ /** 0-59 */
7
+ readonly minute: number;
8
+ /** 0-59 (no leap seconds) */
9
+ readonly second: number;
10
+ /** 0-999 */
11
+ readonly millisecond: number;
12
+ }
13
+ export interface PlainDateTime {
14
+ readonly kind: 'PlainDateTime';
15
+ readonly date: PlainDate;
16
+ readonly time: PlainTime;
17
+ }
18
+ /**
19
+ * Creates a validated, frozen wall-clock time.
20
+ * @example plainTime(9, 30) // => '09:30:00'
21
+ */
22
+ export declare function plainTime(hour: number, minute?: number, second?: number, millisecond?: number): PlainTime;
23
+ /**
24
+ * Creates a frozen date-time from a date and a time (default midnight).
25
+ * @example plainDateTime('2026-03-08', plainTime(2, 30))
26
+ */
27
+ export declare function plainDateTime(date: DateInput, time?: PlainTime): PlainDateTime;
28
+ /**
29
+ * Type guard for `PlainTime`-shaped values (including core's).
30
+ * @example isPlainTime(plainTime(12)) // => true
31
+ */
32
+ export declare function isPlainTime(value: unknown): value is PlainTime;
33
+ /**
34
+ * Type guard for `PlainDateTime`-shaped values (including core's).
35
+ * @example isPlainDateTime(plainDateTime('2026-01-01')) // => true
36
+ */
37
+ export declare function isPlainDateTime(value: unknown): value is PlainDateTime;
38
+ /**
39
+ * Milliseconds since midnight.
40
+ * @example timeToMilliseconds(plainTime(1)) // => 3600000
41
+ */
42
+ export declare function timeToMilliseconds(time: PlainTime): number;
43
+ /**
44
+ * Time for milliseconds since midnight (wraps modulo one day, negative values wrap backwards).
45
+ * @example timeFromMilliseconds(5_400_000) // => '01:30:00'
46
+ */
47
+ export declare function timeFromMilliseconds(ms: number): PlainTime;
48
+ /**
49
+ * Orders two times: `-1`, `0`, or `1`.
50
+ * @example comparePlainTimes(plainTime(9), plainTime(10)) // => -1
51
+ */
52
+ export declare function comparePlainTimes(a: PlainTime, b: PlainTime): -1 | 0 | 1;
53
+ /**
54
+ * Wall-clock milliseconds as if the date-time were UTC ("local epoch"). Internal building block
55
+ * for zone conversion; exported for business-calendar arithmetic.
56
+ * @example plainDateTimeToEpochMilliseconds(plainDateTime('1970-01-02')) // => 86400000
57
+ */
58
+ export declare function plainDateTimeToEpochMilliseconds(value: PlainDateTime): number;
59
+ /**
60
+ * Orders two date-times: `-1`, `0`, or `1`.
61
+ * @example
62
+ * const a = plainDateTime('2026-10-05', plainTime(9, 0));
63
+ * const b = plainDateTime('2026-10-05', plainTime(17, 30));
64
+ * comparePlainDateTimes(a, b); // => -1
65
+ * comparePlainDateTimes(b, a); // => 1
66
+ * [b, a].sort(comparePlainDateTimes); // => [a, b]
67
+ */
68
+ export declare function comparePlainDateTimes(a: PlainDateTime, b: PlainDateTime): -1 | 0 | 1;
69
+ /**
70
+ * ISO 8601 `HH:mm:ss` plus `.SSS` when milliseconds are non-zero.
71
+ * @example formatPlainTime(plainTime(9, 5)) // => '09:05:00'
72
+ */
73
+ export declare function formatPlainTime(time: PlainTime): string;
74
+ /**
75
+ * ISO 8601 `YYYY-MM-DDTHH:mm:ss[.SSS]`.
76
+ * @example formatPlainDateTime(plainDateTime('2026-03-08', plainTime(2, 30))) // => '2026-03-08T02:30:00'
77
+ */
78
+ export declare function formatPlainDateTime(value: PlainDateTime): string;
79
+ /**
80
+ * Parses `HH:mm[:ss[.SSS]]` strictly (1-3 fraction digits). Returns `undefined` otherwise,
81
+ * including `24:00` and leap seconds.
82
+ * @example parsePlainTime('09:30') // => '09:30:00'
83
+ */
84
+ export declare function parsePlainTime(text: string): PlainTime | undefined;
85
+ /**
86
+ * Offset in milliseconds for `Z` or `+/-HH:MM[:SS]` (hours <= 23). Returns `undefined` otherwise.
87
+ * @internal Shared by the date and timezone modules.
88
+ */
89
+ export declare function parseOffsetText(text: string): number | undefined;
90
+ /** Parsed ISO 8601 date-time: wall-clock fields plus the offset when one was written. */
91
+ export interface IsoDateTimeParts {
92
+ readonly dateTime: PlainDateTime;
93
+ /** Offset in milliseconds (`Z` -> 0); `undefined` when the text had no offset. */
94
+ readonly offset: number | undefined;
95
+ }
96
+ /**
97
+ * Parses `YYYY-MM-DDTHH:mm[:ss[.SSS]]` with an optional `Z` or `+/-HH:MM` suffix. Strict:
98
+ * uppercase `T`, no spaces, no impossible dates or times. Returns `undefined` otherwise.
99
+ * @example
100
+ * parseIsoDateTime('2026-03-08T02:30:00-05:00'); // => { dateTime: '2026-03-08T02:30:00', offset: -18000000 }
101
+ * parseIsoDateTime('2026-03-08T02:30')?.offset; // => undefined // no offset in the text
102
+ * parseIsoDateTime('2026-02-30T10:00Z'); // => undefined // impossible date
103
+ */
104
+ export declare function parseIsoDateTime(text: string): IsoDateTimeParts | undefined;
105
+ /**
106
+ * Parses a date-time without an offset (`YYYY-MM-DDTHH:mm[:ss[.SSS]]`). Text with `Z` or an
107
+ * offset is rejected because it denotes an instant, not a wall-clock time.
108
+ * @example parsePlainDateTime('2026-03-08T02:30') // => '2026-03-08T02:30:00'
109
+ */
110
+ export declare function parsePlainDateTime(text: string): PlainDateTime | undefined;
111
+ /**
112
+ * Parses an ISO 8601 instant (date-time with a mandatory `Z` or `+/-HH:MM`) to epoch milliseconds.
113
+ * Returns `undefined` for text without an offset or outside the `Date` range.
114
+ * @example parseInstant('2026-03-08T07:00:00Z') // => 1772953200000
115
+ */
116
+ export declare function parseInstant(text: string): number | undefined;
117
+ /**
118
+ * ISO 8601 UTC string for an instant (`Date#toISOString`).
119
+ * @example formatInstant(0) // => '1970-01-01T00:00:00.000Z'
120
+ */
121
+ export declare function formatInstant(instant: number | Date): string;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as a}from"../error/index.js";import{formatPlainDate as P,isPlainDate as b,parsePlainDate as D,toEpochDay as _,toPlainDate as g}from"./plain-date.js";const d=864e5;function u(n,e,i){if(!Number.isInteger(n)||n<0||n>e)throw new a("HLP_DATE_OUT_OF_RANGE","Time field out of range.",{details:{property:i,min:0,max:e}})}function m(n,e=0,i=0,t=0){return u(n,23,"hour"),u(e,59,"minute"),u(i,59,"second"),u(t,999,"millisecond"),Object.freeze({kind:"PlainTime",hour:n,minute:e,second:i,millisecond:t})}function y(n,e=m(0)){if(!c(e))throw new a("HLP_INVALID_TIME","Expected a PlainTime.");return Object.freeze({kind:"PlainDateTime",date:g(n),time:e})}function c(n){if(typeof n!="object"||n===null)return!1;const e=n,i=(t,r)=>typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=r;return e.kind==="PlainTime"&&i(e.hour,23)&&i(e.minute,59)&&i(e.second,59)&&i(e.millisecond,999)}function k(n){if(typeof n!="object"||n===null)return!1;const e=n;return e.kind==="PlainDateTime"&&b(e.date)&&c(e.time)}function f(n){return((n.hour*60+n.minute)*60+n.second)*1e3+n.millisecond}function O(n){if(!Number.isInteger(n))throw new a("HLP_DATE_OUT_OF_RANGE","Milliseconds must be an integer.");let e=(n%d+d)%d;const i=Math.floor(e/36e5);e-=i*36e5;const t=Math.floor(e/6e4);e-=t*6e4;const r=Math.floor(e/1e3);return m(i,t,r,e-r*1e3)}function $(n,e){const i=f(n),t=f(e);return i<t?-1:i>t?1:0}function l(n){return _(n.date)*d+f(n.time)}function S(n,e){const i=l(n),t=l(e);return i<t?-1:i>t?1:0}const s=(n,e=2)=>String(n).padStart(e,"0");function h(n){const e=`${s(n.hour)}:${s(n.minute)}:${s(n.second)}`;return n.millisecond?`${e}.${s(n.millisecond,3)}`:e}function F(n){return`${P(n.date)}T${h(n.time)}`}const x=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/,I=/^((?:[+-]\d{2})?\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?)(Z|[+-]\d{2}:\d{2})?$/,N=/^([+-])(\d{2}):(\d{2})(?::(\d{2}))?$/;function E(n){if(typeof n!="string"||n.length>12)return;const e=x.exec(n);if(!e)return;const i=Number(e[1]),t=Number(e[2]),r=Number(e[3]??0),o=Number((e[4]??"0").padEnd(3,"0"));if(!(i>23||t>59||r>59))return m(i,t,r,o)}function M(n){if(typeof n!="string"||n.length>9)return;if(n==="Z")return 0;const e=N.exec(n);if(!e)return;const i=Number(e[2]),t=Number(e[3]),r=Number(e[4]??0);if(i>23||t>59||r>59)return;const o=((i*60+t)*60+r)*1e3;return e[1]==="-"?0-o:o}function T(n){if(typeof n!="string"||n.length>40)return;const e=I.exec(n);if(!e)return;const i=D(e[1]??""),t=E(e[2]??"");if(!i||!t)return;const r=e[3]===void 0?void 0:M(e[3]);if(!(e[3]!==void 0&&r===void 0))return Object.freeze({dateTime:y(i,t),offset:r})}function L(n){const e=T(n);return e&&e.offset===void 0?e.dateTime:void 0}const p=864e13;function j(n){const e=T(n);if(e?.offset===void 0)return;const i=l(e.dateTime)-e.offset;return Math.abs(i)>p?void 0:i}function R(n){const e=typeof n=="number"?n:n.getTime();if(!Number.isFinite(e)||Math.abs(e)>p)throw new a("HLP_INVALID_INSTANT","Expected a finite instant.");return new Date(e).toISOString()}export{S as comparePlainDateTimes,$ as comparePlainTimes,R as formatInstant,F as formatPlainDateTime,h as formatPlainTime,k as isPlainDateTime,c as isPlainTime,j as parseInstant,T as parseIsoDateTime,M as parseOffsetText,L as parsePlainDateTime,E as parsePlainTime,y as plainDateTime,l as plainDateTimeToEpochMilliseconds,m as plainTime,O as timeFromMilliseconds,f as timeToMilliseconds};
@@ -0,0 +1,121 @@
1
+ import { type DateInput } from './plain-date.js';
2
+ import { type PlainDateTime } from './plain-time.js';
3
+ /**
4
+ * An exact instant: epoch milliseconds or a valid `Date`.
5
+ * @example const i: InstantInput = Date.now();
6
+ */
7
+ export type InstantInput = number | Date;
8
+ /** How a wall-clock time that is skipped (gap) or repeated (overlap) maps to an instant. */
9
+ export type Disambiguation = 'compatible' | 'earlier' | 'later' | 'reject';
10
+ /** Normalizes an instant to epoch milliseconds; throws `HLP_INVALID_INSTANT`. */
11
+ export declare function toEpochMs(instant: InstantInput): number;
12
+ /**
13
+ * The runtime's IANA time zone (for example `'Europe/London'`).
14
+ * @example getLocalTimeZone() // e.g. 'Asia/Kolkata' (depends on the device)
15
+ */
16
+ export declare function getLocalTimeZone(): string;
17
+ /** Validates `timeZone` (default: the runtime's zone) and returns it. */
18
+ export declare function resolveTimeZone(timeZone?: string): string;
19
+ /**
20
+ * True when `timeZone` is an identifier the runtime's `Intl` accepts (IANA names, `UTC`,
21
+ * and on newer engines fixed offsets such as `'+05:30'`).
22
+ * @example isValidTimeZone('Asia/Kolkata') // => true
23
+ */
24
+ export declare function isValidTimeZone(timeZone: string): boolean;
25
+ /** Offset (local - UTC) in ms at `ms` for a validated zone. Intl resolves to whole seconds. */
26
+ export declare function offsetAtMs(ms: number, timeZone: string): number;
27
+ /**
28
+ * UTC offset in milliseconds of `timeZone` (default: runtime zone) at an instant.
29
+ * @example offsetAt(Date.UTC(2026, 0, 1), 'Asia/Kolkata') // => 19800000
30
+ */
31
+ export declare function offsetAt(instant: InstantInput, timeZone?: string): number;
32
+ /**
33
+ * Wall-clock date-time of an instant in `timeZone` (default: runtime zone).
34
+ * @example instantToZoned(Date.UTC(2026, 0, 1), 'Asia/Kolkata') // => '2026-01-01T05:30:00'
35
+ */
36
+ export declare function instantToZoned(instant: InstantInput, timeZone?: string): PlainDateTime;
37
+ /**
38
+ * Wall-clock date-time of an instant in `timeZone` (alias of the timezone module's
39
+ * `instantToZoned`, named for the date module's instant conventions).
40
+ * @example
41
+ * toPlainDateTime(Date.UTC(2026, 6, 1, 12), 'Europe/London'); // => '2026-07-01T13:00:00' // BST
42
+ * toPlainDateTime(Date.UTC(2026, 11, 1, 12), 'Europe/London'); // => '2026-12-01T12:00:00' // GMT
43
+ */
44
+ export declare function toPlainDateTime(instant: InstantInput, timeZone?: string): PlainDateTime;
45
+ /**
46
+ * Every instant at which a wall-clock time occurs: one (normal), two (overlap, clocks fell back),
47
+ * or none (gap, clocks sprang forward). Sorted ascending, epoch milliseconds.
48
+ * @example
49
+ * import { plainDateTime, plainTime } from '@absoluteui/helpers/date';
50
+ * getPossibleInstants(plainDateTime('2026-11-01', plainTime(1, 30)), 'America/New_York'); // => [Date.UTC(2026, 10, 1, 5, 30), Date.UTC(2026, 10, 1, 6, 30)] // EDT, then EST
51
+ * getPossibleInstants(plainDateTime('2026-03-08', plainTime(2, 30)), 'America/New_York'); // => [] // skipped
52
+ */
53
+ export declare function getPossibleInstants(dateTime: PlainDateTime, timeZone?: string): number[];
54
+ /**
55
+ * `'exact'`, `'ambiguous'` (overlap), or `'nonexistent'` (gap) for a wall-clock time in a zone.
56
+ * @example
57
+ * import { plainDateTime, plainTime } from '@absoluteui/helpers/date';
58
+ * getWallTimeStatus(plainDateTime('2026-03-08', plainTime(2, 30)), 'America/New_York'); // => 'nonexistent'
59
+ * getWallTimeStatus(plainDateTime('2026-11-01', plainTime(1, 30)), 'America/New_York'); // => 'ambiguous'
60
+ * getWallTimeStatus(plainDateTime('2026-11-01', plainTime(9, 0)), 'America/New_York'); // => 'exact'
61
+ */
62
+ export declare function getWallTimeStatus(dateTime: PlainDateTime, timeZone?: string): 'exact' | 'ambiguous' | 'nonexistent';
63
+ export interface ZonedToInstantOptions {
64
+ /**
65
+ * Default `'compatible'` (Temporal and RFC 5545): overlap -> earlier instant; gap -> shifted
66
+ * forward by the gap length. `'earlier'`: gap shifts backward. `'later'`: overlap -> later
67
+ * instant, gap shifts forward. `'reject'`: throws `HLP_TZ_AMBIGUOUS_TIME` / `HLP_TZ_NONEXISTENT_TIME`.
68
+ */
69
+ readonly disambiguation?: Disambiguation;
70
+ }
71
+ /**
72
+ * Converts a wall-clock date-time in `timeZone` (default: runtime zone) to epoch milliseconds.
73
+ *
74
+ * | Case | compatible | earlier | later | reject |
75
+ * |---|---|---|---|---|
76
+ * | overlap | earlier instant | earlier instant | later instant | throws |
77
+ * | gap | forward by gap | backward by gap | forward by gap | throws |
78
+ * @example
79
+ * import { plainDateTime, plainTime } from '@absoluteui/helpers/date';
80
+ * const gap = plainDateTime('2026-03-08', plainTime(2, 30)); // skipped in New York
81
+ * zonedToInstant(gap, 'America/New_York'); // => Date.UTC(2026, 2, 8, 7, 30) // 03:30 EDT
82
+ * zonedToInstant(gap, 'America/New_York', { disambiguation: 'earlier' }); // => Date.UTC(2026, 2, 8, 6, 30) // 01:30 EST
83
+ * zonedToInstant(gap, 'America/New_York', { disambiguation: 'reject' }); // => throws HLP_TZ_NONEXISTENT_TIME
84
+ */
85
+ export declare function zonedToInstant(dateTime: PlainDateTime, timeZone?: string, options?: ZonedToInstantOptions): number;
86
+ /**
87
+ * First instant (epoch ms) of a calendar day in a zone. DST-safe: when midnight is skipped
88
+ * (for example America/Santiago or Asia/Beirut at their spring transitions) it returns the
89
+ * first instant that exists on that date, as Temporal's `startOfDay` does.
90
+ * @example
91
+ * startOfDayInstant('2026-10-05', 'Asia/Kolkata'); // => Date.UTC(2026, 9, 4, 18, 30) // 00:00 IST
92
+ * startOfDayInstant('2026-03-29', 'Asia/Beirut'); // => Date.UTC(2026, 2, 28, 22) // midnight is skipped: 01:00 local (+03:00)
93
+ */
94
+ export declare function startOfDayInstant(date: DateInput, timeZone?: string): number;
95
+ /**
96
+ * Last millisecond of a calendar day in a zone (one before the next day's `startOfDayInstant`).
97
+ * @example
98
+ * endOfDayInstant('2026-11-01', 'America/New_York'); // => Date.UTC(2026, 10, 2, 5) - 1 // 23:59:59.999 EST
99
+ * endOfDayInstant('2026-11-01', 'America/New_York') - startOfDayInstant('2026-11-01', 'America/New_York'); // => 25 * 3_600_000 - 1 // a 25-hour day
100
+ */
101
+ export declare function endOfDayInstant(date: DateInput, timeZone?: string): number;
102
+ export interface TransitionSearchOptions {
103
+ /** Days to scan, 1-36600. Default 400. */
104
+ readonly searchDays?: number;
105
+ }
106
+ /**
107
+ * Next UTC-offset change strictly after `instant` (epoch ms of the first instant with the new
108
+ * offset), or `undefined` within `searchDays`. Scans day by day, then binary-searches to the
109
+ * second, so two changes less than a day apart can be missed.
110
+ * @example
111
+ * nextTransition(Date.UTC(2026, 0, 1), 'America/New_York'); // => 1772953200000 // 2026-03-08T07:00:00Z, clocks spring forward
112
+ * nextTransition(Date.UTC(2026, 0, 1), 'Asia/Kolkata'); // => undefined // no DST
113
+ */
114
+ export declare function nextTransition(instant: InstantInput, timeZone?: string, options?: TransitionSearchOptions): number | undefined;
115
+ /**
116
+ * Latest UTC-offset change strictly before `instant`, or `undefined` within `searchDays`.
117
+ * @example
118
+ * const t = previousTransition(Date.UTC(2026, 5, 1), 'America/New_York'); // => 1772953200000
119
+ * t === undefined ? undefined : new Date(t).toISOString(); // => '2026-03-08T07:00:00.000Z'
120
+ */
121
+ export declare function previousTransition(instant: InstantInput, timeZone?: string, options?: TransitionSearchOptions): number | undefined;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{LimitError as P,ValidationError as h}from"../error/index.js";import{addDays as v,fromEpochDay as E,toEpochDay as M,toPlainDate as k}from"./plain-date.js";import{plainDateTime as L,plainDateTimeToEpochMilliseconds as N,timeFromMilliseconds as O}from"./plain-time.js";const m=864e5,b=864e13;function T(t){const e=typeof t=="number"?t:t instanceof Date?t.getTime():Number.NaN;if(!Number.isFinite(e)||Math.abs(e)>b)throw new h("HLP_INVALID_INSTANT","Expected a finite instant (epoch milliseconds or a valid Date).");return e}const p=t=>Math.max(-b,Math.min(b,t)),I=new Map;function _(t){return new h("HLP_TZ_INVALID_ZONE","Unsupported time zone identifier.",t===void 0?{}:{cause:t})}function g(t){const e=I.get(t);if(e)return e;if(typeof t!="string"||t.length===0||t.length>64)throw _();let n;try{n=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch(r){throw _(r)}return I.size>=512&&I.clear(),I.set(t,n),n}function S(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function d(t){const e=t??S();return g(e),e}function j(t){try{return g(t),!0}catch{return!1}}function s(t,e){const n=Math.floor(t/1e3)*1e3;let r=0,o=1,i=1,a=0,u=0,c=0,f=!1;for(const l of g(e).formatToParts(n))switch(l.type){case"year":r=Number(l.value);break;case"month":o=Number(l.value);break;case"day":i=Number(l.value);break;case"hour":a=Number(l.value)%24;break;case"minute":u=Number(l.value);break;case"second":c=Number(l.value);break;case"era":f=l.value==="BC"||l.value==="B";break;default:break}return f&&(r=1-r),M({kind:"PlainDate",year:r,month:o,day:i})*m+((a*60+u)*60+c)*1e3-n}function B(t,e){return s(T(t),d(e))}function A(t){const e=Math.floor(t/m);return L(E(e),O(t-e*m))}function F(t,e){const n=T(t);return A(n+s(n,d(e)))}function R(t,e){return F(t,e)}function y(t,e){const n=s(p(t-m),e),r=s(p(t+m),e),o=[];for(const i of n===r?[n]:[n,r]){const a=t-i;Math.abs(a)<=b&&s(a,e)===i&&!o.includes(a)&&o.push(a)}return o.sort((i,a)=>i-a)}function Z(t,e){return y(N(t),d(e))}function X(t,e){const n=Z(t,e).length;return n===1?"exact":n>1?"ambiguous":"nonexistent"}function H(t,e,n){const r=y(t,e),[o,i]=r;if(o!==void 0&&i===void 0)return o;if(o!==void 0&&i!==void 0){if(n==="reject")throw new h("HLP_TZ_AMBIGUOUS_TIME","The wall-clock time is ambiguous in the time zone.");return n==="later"?i:o}if(n==="reject")throw new h("HLP_TZ_NONEXISTENT_TIME","The wall-clock time does not exist in the time zone.");const a=s(p(t-m),e),u=s(p(t+m),e);return T(n==="earlier"?t-u:t-a)}function G(t,e,n={}){return H(N(t),d(e),n.disambiguation??"compatible")}function x(t,e,n,r){let o=t,i=e;for(;i-o>1;){const a=o+Math.floor((i-o)/2);s(a*1e3,r)===n?o=a:i=a}return i*1e3}function z(t,e){const n=d(e),r=M(k(t))*m,o=y(r,n);if(o[0]!==void 0)return o[0];const i=s(p(r-m),n),a=s(p(r+m),n),u=Math.floor((r-a)/1e3),c=Math.ceil((r-i)/1e3);return x(u,c,s(u*1e3,n),n)}function W(t,e){return z(v(t,1),e)-1}function w(t){const e=t.searchDays??400;if(!Number.isInteger(e)||e<1)throw new h("HLP_TZ_INVALID_SEARCH","searchDays must be a positive integer.");if(e>36600)throw new P("HLP_TZ_SEARCH_LIMIT","searchDays exceeds the limit of 36600.");return e}function Y(t,e,n={}){const r=T(t),o=d(e),i=w(n);let a=r;const u=s(r,o);for(let c=1;c<=i;c++){const f=p(r+c*m);if(s(f,o)!==u)return x(Math.floor(a/1e3),Math.floor(f/1e3),u,o);if(f===b)break;a=f}}function q(t,e,n={}){const r=T(t)-1,o=d(e),i=w(n),a=s(r,o);let u=r;for(let c=1;c<=i;c++){const f=p(r-c*m),D=s(f,o);if(D!==a)return x(Math.floor(f/1e3),Math.floor(u/1e3),D,o);if(f===-b)break;u=f}}export{W as endOfDayInstant,S as getLocalTimeZone,Z as getPossibleInstants,X as getWallTimeStatus,F as instantToZoned,j as isValidTimeZone,Y as nextTransition,B as offsetAt,s as offsetAtMs,q as previousTransition,d as resolveTimeZone,z as startOfDayInstant,T as toEpochMs,R as toPlainDateTime,G as zonedToInstant};
@@ -0,0 +1,149 @@
1
+ import { type FormatNumberOptions, type LocaleInput } from '../number/index.js';
2
+ /** Rounding modes. `half-up` rounds ties away from zero; `up`/`down` are away from/toward zero. */
3
+ export type RoundingMode = 'half-up' | 'half-even' | 'half-down' | 'up' | 'down' | 'ceiling' | 'floor';
4
+ /** Anything accepted where a `Decimal` is expected. Numbers use their shortest round-trip form (`0.1` is exactly 0.1). */
5
+ export type DecimalInput = Decimal | string | number | bigint;
6
+ /** Maximum number of digits in the unscaled value. */
7
+ export declare const MAX_DECIMAL_DIGITS = 1000;
8
+ /** Maximum number of fractional digits. */
9
+ export declare const MAX_DECIMAL_SCALE = 1000;
10
+ /** Fractional digits of a division result when no `scale` is given (at least the operands' scales). */
11
+ export declare const DEFAULT_DIVISION_SCALE = 20;
12
+ export interface DecimalRoundOptions {
13
+ /** Fractional digits of the result. */
14
+ readonly scale?: number;
15
+ /** Default `'half-up'`. */
16
+ readonly rounding?: RoundingMode;
17
+ }
18
+ export interface AllocateOptions {
19
+ /** Scale of the parts (the smallest unit). Default: the amount's scale. */
20
+ readonly scale?: number;
21
+ }
22
+ /**
23
+ * Immutable decimal: `unscaled x 10^-scale`. Create with `decimal()`.
24
+ * @example decimal('0.10').add('0.20').toString() // => '0.30'
25
+ */
26
+ export declare class Decimal {
27
+ /** Integer digits without the decimal point. */
28
+ readonly unscaled: bigint;
29
+ /** Number of fractional digits (0..MAX_DECIMAL_SCALE). */
30
+ readonly scale: number;
31
+ /** Prefer `decimal()`; throws `LimitError` beyond `MAX_DECIMAL_DIGITS` / `MAX_DECIMAL_SCALE`. */
32
+ constructor(unscaled: bigint, scale?: number);
33
+ /** Sum. @example decimal('1.1').add('2.25').toString() // => '3.35' */
34
+ add(other: DecimalInput): Decimal;
35
+ /** Difference. @example decimal('1').subtract('0.9').toString() // => '0.1' */
36
+ subtract(other: DecimalInput): Decimal;
37
+ /** Exact product (scale = sum of scales), optionally rounded. @example decimal('1.5').multiply('1.5').toString() // => '2.25' */
38
+ multiply(other: DecimalInput, options?: DecimalRoundOptions): Decimal;
39
+ /**
40
+ * Quotient rounded to `scale` (default: max of `DEFAULT_DIVISION_SCALE` and both scales).
41
+ * Throws `HLP_DECIMAL_DIVIDE_BY_ZERO`.
42
+ * @example decimal(1).divide(3, { scale: 4 }).toString() // => '0.3333'
43
+ */
44
+ divide(other: DecimalInput, options?: DecimalRoundOptions): Decimal;
45
+ /** Additive inverse. @example decimal('2').negate().toString() // => '-2' */
46
+ negate(): Decimal;
47
+ /** Absolute value. @example decimal('-2.5').abs().toString() // => '2.5' */
48
+ abs(): Decimal;
49
+ /** `-1`, `0` or `1`; scale does not matter (`1.0` equals `1`). @example decimal('1.0').compare('1') // => 0 */
50
+ compare(other: DecimalInput): -1 | 0 | 1;
51
+ /** Numeric equality. @example decimal('1.50').equals('1.5') // => true */
52
+ equals(other: DecimalInput): boolean;
53
+ /** @example decimal(2).gt(1) // => true */
54
+ gt(other: DecimalInput): boolean;
55
+ /** @example decimal(2).gte(2) // => true */
56
+ gte(other: DecimalInput): boolean;
57
+ /** @example decimal(1).lt(2) // => true */
58
+ lt(other: DecimalInput): boolean;
59
+ /** @example decimal(2).lte(2) // => true */
60
+ lte(other: DecimalInput): boolean;
61
+ /** @example decimal('0.00').isZero() // => true */
62
+ isZero(): boolean;
63
+ /** @example decimal('-0.01').isNegative() // => true */
64
+ isNegative(): boolean;
65
+ /** @example decimal('0.01').isPositive() // => true */
66
+ isPositive(): boolean;
67
+ /**
68
+ * Rounds (or pads) to exactly `scale` fractional digits.
69
+ * @example decimal('2.345').round(2, 'half-even').toString() // => '2.34'
70
+ */
71
+ round(scale: number, mode?: RoundingMode): Decimal;
72
+ /** Removes trailing fractional zeros. @example decimal('1.500').normalize().toString() // => '1.5' */
73
+ normalize(): Decimal;
74
+ /** Plain string, never exponent notation; keeps the scale. @example decimal('-0.5').toString() // => '-0.5' */
75
+ toString(): string;
76
+ /** Rounded plain string with exactly `places` digits. @example decimal('1.005').toFixed(2) // => '1.01' */
77
+ toFixed(places: number, mode?: RoundingMode): string;
78
+ /**
79
+ * Nearest `number`. Lossy: doubles hold about 15–17 significant digits; keep money as `Decimal` or string.
80
+ * @example decimal('0.1').toNumber() // => 0.1
81
+ */
82
+ toNumber(): number;
83
+ /** Integer minor units (cents) for a currency with `digits` fraction digits. @example decimal('12.345').toMinorUnits(2) // => 1235n */
84
+ toMinorUnits(digits?: number, mode?: RoundingMode): bigint;
85
+ /**
86
+ * Splits by ratios with the largest-remainder method; the parts always sum exactly to the amount.
87
+ * Ties go to the earlier ratio. Throws when the amount has more digits than `scale`.
88
+ * @example decimal('100').allocate([1, 1, 1], { scale: 2 }).map(String) // => ['33.34', '33.33', '33.33']
89
+ */
90
+ allocate(ratios: readonly DecimalInput[], options?: AllocateOptions): Decimal[];
91
+ /**
92
+ * Splits into `n` near-equal parts that sum exactly to the amount.
93
+ * @example decimal('10.00').split(3).map(String) // => ['3.34', '3.33', '3.33']
94
+ */
95
+ split(n: number, options?: AllocateOptions): Decimal[];
96
+ /** `pct` percent of this amount (exact unless `scale` is given). @example decimal('200').percent('7.5').toString() // => '15.000' */
97
+ percent(pct: DecimalInput, options?: DecimalRoundOptions): Decimal;
98
+ /** What percentage this amount is of `total`. @example decimal(15).percentageOf(200, { scale: 1 }).toString() // => '7.5' */
99
+ percentageOf(total: DecimalInput, options?: DecimalRoundOptions): Decimal;
100
+ /** JSON form is the plain string (never a lossy number). @example JSON.stringify({ a: decimal('1.10') }) // => '{"a":"1.10"}' */
101
+ toJSON(): string;
102
+ /** String conversion is allowed; numeric coercion (`+d`, `d * 2`) throws to prevent silent precision loss. */
103
+ [Symbol.toPrimitive](hint: string): string;
104
+ }
105
+ export interface DecimalOptions extends DecimalRoundOptions {
106
+ /** Accept exponent notation in strings ("1e5"). Default false. */
107
+ readonly allowExponent?: boolean;
108
+ /** Parse strings with this locale's group and decimal symbols (strict grouping), e.g. "1.234,5" for `de`. */
109
+ readonly locale?: LocaleInput;
110
+ }
111
+ /**
112
+ * Creates a `Decimal`. Strings are parsed strictly (`"-12.50"`); exponents and grouping need options.
113
+ * Throws `HLP_DECIMAL_PARSE` (ValidationError) or `HLP_DECIMAL_TOO_LARGE` (LimitError).
114
+ * @example decimal('19.99').multiply(3).toString() // => '59.97'
115
+ */
116
+ export declare function decimal(value: DecimalInput, options?: DecimalOptions): Decimal;
117
+ /**
118
+ * Non-throwing `decimal()` for untrusted text: `undefined` when invalid (limit errors still throw).
119
+ * @example parseDecimal('12.3x') // => undefined
120
+ */
121
+ export declare function parseDecimal(text: string, options?: DecimalOptions): Decimal | undefined;
122
+ /** True for `Decimal` instances. @example isDecimal(decimal(1)) // => true */
123
+ export declare function isDecimal(value: unknown): value is Decimal;
124
+ /** Comparator for `Array#sort`. @example ['2', '10', '1.5'].map((s) => decimal(s)).sort(compareDecimals) */
125
+ export declare function compareDecimals(a: DecimalInput, b: DecimalInput): -1 | 0 | 1;
126
+ /** Exact sum; empty input gives `0`. @example sumDecimals(['0.1', '0.2']).toString() // => '0.3' */
127
+ export declare function sumDecimals(values: Iterable<DecimalInput>): Decimal;
128
+ /** Smallest value, or `undefined` for none. @example minDecimal('2', '1.5')?.toString() // => '1.5' */
129
+ export declare function minDecimal(...values: DecimalInput[]): Decimal | undefined;
130
+ /** Largest value, or `undefined` for none. @example maxDecimal('2', '10')?.toString() // => '10' */
131
+ export declare function maxDecimal(...values: DecimalInput[]): Decimal | undefined;
132
+ /**
133
+ * Decimal from integer minor units (cents) with `digits` fraction digits.
134
+ * @example fromMinorUnits(1999n, 2).toString() // => '19.99'
135
+ */
136
+ export declare function fromMinorUnits(minor: bigint | number, digits?: number): Decimal;
137
+ export interface FormatDecimalOptions extends Omit<FormatNumberOptions, 'style' | 'currency'> {
138
+ /** ISO 4217 code; formats as currency with the currency's default digits unless overridden. */
139
+ readonly currency?: string;
140
+ /** Currency display; see `formatCurrency`. */
141
+ readonly display?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
142
+ }
143
+ /**
144
+ * Formats through `Intl.NumberFormat` using the exact decimal string (no float conversion).
145
+ * Without `currency`, all fractional digits of the scale are shown by default.
146
+ * Intl rounds with `roundingMode` (default half-expand = `half-up`).
147
+ * @example formatDecimal(decimal('1234567890123456789.25'), { locale: 'en-US' }) // => '1,234,567,890,123,456,789.25'
148
+ */
149
+ export declare function formatDecimal(value: DecimalInput, options?: FormatDecimalOptions): string;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{HelperError as x,LimitError as D,ValidationError as m}from"../error/index.js";import{formatCurrency as y,formatNumber as C,parseNumberString as P}from"../number/index.js";const I=1e3,S=1e3,R=20,M=10n**BigInt(I),T=/^([+-]?)(\d+)(?:\.(\d+))?(?:e([+-]?\d{1,5}))?$/i,h=t=>10n**BigInt(t);function p(t){if(!Number.isInteger(t)||t<0)throw new m("HLP_DECIMAL_SCALE","The scale must be a non-negative integer.");if(t>S)throw new D("HLP_DECIMAL_TOO_LARGE","The scale exceeds the decimal limit.")}function O(t,e,n){const i=t/e,r=t%e;if(r===0n)return i;const l=t<0n==e<0n,s=l?1n:-1n,c=(r<0n?-r:r)*2n,u=e<0n?-e:e;switch(n){case"down":return i;case"up":return i+s;case"ceiling":return l?i+1n:i;case"floor":return l?i:i-1n;case"half-up":return c>=u?i+s:i;case"half-down":return c>u?i+s:i;case"half-even":return c>u||c===u&&i%2n!==0n?i+s:i}}function b(t,e,n,i){return n>=e?t*h(n-e):O(t,h(e-n),i)}function L(t,e){if(t.length>I*2+20)throw new D("HLP_DECIMAL_TOO_LONG","The decimal text exceeds the length limit.");const n=T.exec(t);if(!n)throw new m("HLP_DECIMAL_PARSE","Invalid decimal string.");const[,i="",r="0",l="",s]=n;if(s!==void 0&&!e)throw new m("HLP_DECIMAL_PARSE","Exponent notation is not allowed.");let c=l.length-(s===void 0?0:Number(s)),u=BigInt(r+l);if(c<0){if(-c>I)throw new D("HLP_DECIMAL_TOO_LARGE","The value exceeds the decimal limit.");u*=h(-c),c=0}return new o(i==="-"?-u:u,c)}function d(t){if(t instanceof o)return t;if(typeof t=="bigint")return new o(t,0);if(typeof t=="number"){if(!Number.isFinite(t))throw new m("HLP_DECIMAL_NOT_FINITE","Expected a finite number.");return L(String(t),!0)}if(typeof t=="string")return L(t,!1);throw new m("HLP_DECIMAL_PARSE","Expected a Decimal, string, number, or bigint.")}const N=(t,e)=>t<e?-1:t>e?1:0;class o{unscaled;scale;constructor(e,n=0){if(typeof e!="bigint")throw new m("HLP_DECIMAL_PARSE","The unscaled value must be a bigint.");if(p(n),e>=M||e<=-M)throw new D("HLP_DECIMAL_TOO_LARGE","The value exceeds the decimal digit limit.");this.unscaled=e,this.scale=n,Object.freeze(this)}add(e){const n=d(e),i=Math.max(this.scale,n.scale);return new o(this.unscaled*h(i-this.scale)+n.unscaled*h(i-n.scale),i)}subtract(e){return this.add(d(e).negate())}multiply(e,n={}){const i=d(e),r=this.unscaled*i.unscaled,l=this.scale+i.scale;return n.scale===void 0?new o(r,l):(p(n.scale),new o(b(r,l,n.scale,n.rounding??"half-up"),n.scale))}divide(e,n={}){const i=d(e);if(i.unscaled===0n)throw new x("HLP_DECIMAL_DIVIDE_BY_ZERO","Division by zero.",{kind:"validation"});const r=n.scale??Math.max(R,this.scale,i.scale);return p(r),new o(O(this.unscaled*h(i.scale+r),i.unscaled*h(this.scale),n.rounding??"half-up"),r)}negate(){return new o(-this.unscaled,this.scale)}abs(){return this.unscaled<0n?this.negate():this}compare(e){const n=d(e),i=Math.max(this.scale,n.scale);return N(this.unscaled*h(i-this.scale),n.unscaled*h(i-n.scale))}equals(e){return this.compare(e)===0}gt(e){return this.compare(e)>0}gte(e){return this.compare(e)>=0}lt(e){return this.compare(e)<0}lte(e){return this.compare(e)<=0}isZero(){return this.unscaled===0n}isNegative(){return this.unscaled<0n}isPositive(){return this.unscaled>0n}round(e,n="half-up"){return p(e),e===this.scale?this:new o(b(this.unscaled,this.scale,e,n),e)}normalize(){let e=this.unscaled,n=this.scale;for(;n>0&&e%10n===0n;)e/=10n,n--;return n===this.scale?this:new o(e,n)}toString(){const e=this.unscaled<0n;let n=(e?-this.unscaled:this.unscaled).toString();return this.scale>0&&(n=n.padStart(this.scale+1,"0"),n=`${n.slice(0,-this.scale)}.${n.slice(-this.scale)}`),e?`-${n}`:n}toFixed(e,n="half-up"){return this.round(e,n).toString()}toNumber(){return Number(this.toString())}toMinorUnits(e=2,n="half-up"){return this.round(e,n).unscaled}allocate(e,n={}){const i=n.scale??this.scale;if(p(i),e.length===0||e.length>1e6)throw new m("HLP_DECIMAL_ALLOCATE","Provide between 1 and 1,000,000 ratios.");const r=b(this.unscaled,this.scale,i,"down");if(b(r,i,this.scale,"down")!==this.unscaled)throw new m("HLP_DECIMAL_ALLOCATE","The amount has more fractional digits than the allocation scale.");const l=e.map(d),s=Math.max(...l.map(a=>a.scale)),c=l.map(a=>a.unscaled*h(s-a.scale));if(c.some(a=>a<0n))throw new m("HLP_DECIMAL_ALLOCATE","Ratios must not be negative.");const u=c.reduce((a,f)=>a+f,0n);if(u===0n)throw new m("HLP_DECIMAL_ALLOCATE","At least one ratio must be positive.");const E=r<0n,w=E?-r:r,g=c.map(a=>w*a/u),A=c.map((a,f)=>({i:f,r:w*a%u}));let _=w-g.reduce((a,f)=>a+f,0n);A.sort((a,f)=>a.r===f.r?a.i-f.i:a.r>f.r?-1:1);for(const{i:a}of A){if(_===0n)break;g[a]=(g[a]??0n)+1n,_--}return g.map(a=>new o(E?-a:a,i))}split(e,n={}){if(!Number.isInteger(e)||e<1||e>1e6)throw new m("HLP_DECIMAL_ALLOCATE","The part count must be an integer between 1 and 1,000,000.");return this.allocate(new Array(e).fill(1),n)}percent(e,n={}){const i=this.multiply(e),r=new o(i.unscaled,i.scale+2);return n.scale===void 0?r:r.round(n.scale,n.rounding??"half-up")}percentageOf(e,n={}){return this.multiply(100).divide(e,n)}toJSON(){return this.toString()}[Symbol.toPrimitive](e){if(e==="number")throw new x("HLP_DECIMAL_COERCION","Use toNumber() to convert a Decimal to a number explicitly.",{kind:"validation"});return this.toString()}}function H(t,e={}){let n;if(typeof t=="string"&&(e.locale!==void 0||e.allowExponent===!0)){let i=t;if(e.locale!==void 0){const r=P(t,{locale:e.locale,strict:!0});if(r===void 0||t.includes("%")||t.includes("\u066A"))throw new m("HLP_DECIMAL_PARSE","Invalid decimal string.");i=r.startsWith(".")?`0${r}`:r}n=L(i,e.allowExponent===!0)}else n=d(t);return e.scale===void 0?n:n.round(e.scale,e.rounding??"half-up")}function k(t,e={}){try{return H(t,e)}catch(n){if(n instanceof m)return;throw n}}function B(t){return t instanceof o}function G(t,e){return d(t).compare(e)}function U(t){let e=new o(0n,0);for(const n of t)e=e.add(n);return e}function $(...t){let e;for(const n of t){const i=d(n);(e===void 0||i.lt(e))&&(e=i)}return e}function z(...t){let e;for(const n of t){const i=d(n);(e===void 0||i.gt(e))&&(e=i)}return e}function V(t,e=2){if(typeof t=="number"&&!Number.isSafeInteger(t))throw new m("HLP_DECIMAL_MINOR_UNITS","Minor units must be a safe integer or bigint.");return new o(BigInt(t),e)}function q(t,e={}){const n=d(t),i=n.toString(),{currency:r,display:l,...s}=e;if(r!==void 0)return y(i,r,l?{...s,display:l}:s);const c=Math.min(n.scale,100),u=s.minimumFractionDigits===void 0&&s.maximumFractionDigits===void 0?{...s,minimumFractionDigits:c,maximumFractionDigits:c}:s;return C(i,u)}export{R as DEFAULT_DIVISION_SCALE,o as Decimal,I as MAX_DECIMAL_DIGITS,S as MAX_DECIMAL_SCALE,G as compareDecimals,H as decimal,q as formatDecimal,V as fromMinorUnits,B as isDecimal,z as maxDecimal,$ as minDecimal,k as parseDecimal,U as sumDecimals};