@attocash/cli 0.1.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 (400) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +707 -0
  3. package/dist/application/app.d.ts +138 -0
  4. package/dist/application/app.js +654 -0
  5. package/dist/application/operations.d.ts +9 -0
  6. package/dist/application/operations.js +96 -0
  7. package/dist/cli/cli.d.ts +1 -0
  8. package/dist/cli/cli.js +460 -0
  9. package/dist/cli/help.d.ts +4 -0
  10. package/dist/cli/help.js +49 -0
  11. package/dist/cli/main.d.ts +2 -0
  12. package/dist/cli/main.js +13 -0
  13. package/dist/cli/onboarding.d.ts +14 -0
  14. package/dist/cli/onboarding.js +144 -0
  15. package/dist/cli/output.d.ts +2 -0
  16. package/dist/cli/output.js +231 -0
  17. package/dist/cli/terminal.d.ts +6 -0
  18. package/dist/cli/terminal.js +92 -0
  19. package/dist/cli/update-check.d.ts +1 -0
  20. package/dist/cli/update-check.js +12 -0
  21. package/dist/cli/updates.d.ts +2 -0
  22. package/dist/cli/updates.js +98 -0
  23. package/dist/core.d.ts +14 -0
  24. package/dist/core.js +14 -0
  25. package/dist/doctor/credential-probe.d.ts +7 -0
  26. package/dist/doctor/credential-probe.js +49 -0
  27. package/dist/doctor/doctor.d.ts +4 -0
  28. package/dist/doctor/doctor.js +213 -0
  29. package/dist/doctor/keyring.d.ts +7 -0
  30. package/dist/doctor/keyring.js +150 -0
  31. package/dist/doctor/profile.d.ts +19 -0
  32. package/dist/doctor/profile.js +73 -0
  33. package/dist/doctor/types.d.ts +40 -0
  34. package/dist/doctor/types.js +1 -0
  35. package/dist/domain/amount.d.ts +6 -0
  36. package/dist/domain/amount.js +27 -0
  37. package/dist/domain/errors.d.ts +10 -0
  38. package/dist/domain/errors.js +16 -0
  39. package/dist/labels/directory.d.ts +87 -0
  40. package/dist/labels/directory.js +140 -0
  41. package/dist/labels/personal.d.ts +17 -0
  42. package/dist/labels/personal.js +56 -0
  43. package/dist/labels/presentation.d.ts +154 -0
  44. package/dist/labels/presentation.js +90 -0
  45. package/dist/network/reader.d.ts +31 -0
  46. package/dist/network/reader.js +370 -0
  47. package/dist/network/retry.d.ts +7 -0
  48. package/dist/network/retry.js +53 -0
  49. package/dist/network/work.d.ts +3 -0
  50. package/dist/network/work.js +66 -0
  51. package/dist/pricing/market.d.ts +29 -0
  52. package/dist/pricing/market.js +150 -0
  53. package/dist/pricing/terms.d.ts +6 -0
  54. package/dist/pricing/terms.js +12 -0
  55. package/dist/spending/destination.d.ts +16 -0
  56. package/dist/spending/destination.js +42 -0
  57. package/dist/spending/journal.d.ts +28 -0
  58. package/dist/spending/journal.js +69 -0
  59. package/dist/spending/ledger.d.ts +118 -0
  60. package/dist/spending/ledger.js +444 -0
  61. package/dist/spending/payments.d.ts +67 -0
  62. package/dist/spending/payments.js +424 -0
  63. package/dist/spending/pool.d.ts +13 -0
  64. package/dist/spending/pool.js +38 -0
  65. package/dist/spending/reconcile.d.ts +18 -0
  66. package/dist/spending/reconcile.js +64 -0
  67. package/dist/storage/profiles.d.ts +13 -0
  68. package/dist/storage/profiles.js +86 -0
  69. package/dist/storage/secrets.d.ts +16 -0
  70. package/dist/storage/secrets.js +104 -0
  71. package/dist/storage/state.d.ts +32 -0
  72. package/dist/storage/state.js +255 -0
  73. package/dist/wallet/auto-receive.d.ts +57 -0
  74. package/dist/wallet/auto-receive.js +140 -0
  75. package/dist/wallet/defaults.d.ts +3 -0
  76. package/dist/wallet/defaults.js +26 -0
  77. package/dist/wallet/signing.d.ts +17 -0
  78. package/dist/wallet/signing.js +128 -0
  79. package/dist/wallet/types.d.ts +65 -0
  80. package/dist/wallet/types.js +1 -0
  81. package/dist/wallet/work.d.ts +29 -0
  82. package/dist/wallet/work.js +154 -0
  83. package/dist/watches/manager.d.ts +75 -0
  84. package/dist/watches/manager.js +197 -0
  85. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs +6678 -0
  86. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs.map +1 -0
  87. package/node_modules/@attocash/commons-core/LICENSE +28 -0
  88. package/node_modules/@attocash/commons-core/README.md +118 -0
  89. package/node_modules/@attocash/commons-core/commons-commons-core.d.mts +1036 -0
  90. package/node_modules/@attocash/commons-core/commons-commons-core.mjs +7701 -0
  91. package/node_modules/@attocash/commons-core/commons-commons-core.mjs.map +1 -0
  92. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs +17681 -0
  93. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs.map +1 -0
  94. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs +4 -0
  95. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs.map +1 -0
  96. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs +209 -0
  97. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs.map +1 -0
  98. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs +2284 -0
  99. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs.map +1 -0
  100. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs +6042 -0
  101. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs.map +1 -0
  102. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  103. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  104. package/node_modules/@attocash/commons-core/package.json +27 -0
  105. package/node_modules/@attocash/commons-node/LICENSE +28 -0
  106. package/node_modules/@attocash/commons-node/README.md +92 -0
  107. package/node_modules/@attocash/commons-node/commons-commons-node.d.mts +255 -0
  108. package/node_modules/@attocash/commons-node/commons-commons-node.mjs +2977 -0
  109. package/node_modules/@attocash/commons-node/commons-commons-node.mjs.map +1 -0
  110. package/node_modules/@attocash/commons-node/kotlin-logging.mjs +432 -0
  111. package/node_modules/@attocash/commons-node/kotlin-logging.mjs.map +1 -0
  112. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  113. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  114. package/node_modules/@attocash/commons-node/package.json +29 -0
  115. package/node_modules/@attocash/commons-node-remote/LICENSE +28 -0
  116. package/node_modules/@attocash/commons-node-remote/README.md +61 -0
  117. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.d.mts +122 -0
  118. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs +1810 -0
  119. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs.map +1 -0
  120. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs +432 -0
  121. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs.map +1 -0
  122. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs +8 -0
  123. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs.map +1 -0
  124. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  125. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  126. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  127. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  128. package/node_modules/@attocash/commons-node-remote/package.json +31 -0
  129. package/node_modules/@attocash/commons-transport/LICENSE +28 -0
  130. package/node_modules/@attocash/commons-transport/README.md +5 -0
  131. package/node_modules/@attocash/commons-transport/commons-commons-transport.d.mts +64 -0
  132. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs +249 -0
  133. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs.map +1 -0
  134. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs +263 -0
  135. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs.map +1 -0
  136. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs +8 -0
  137. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs.map +1 -0
  138. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs +11604 -0
  139. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs.map +1 -0
  140. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  141. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  142. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  143. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  144. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs +499 -0
  145. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs.map +1 -0
  146. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs +6456 -0
  147. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs.map +1 -0
  148. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs +83 -0
  149. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs.map +1 -0
  150. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs +1714 -0
  151. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs.map +1 -0
  152. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs +3197 -0
  153. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs.map +1 -0
  154. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs +2290 -0
  155. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs.map +1 -0
  156. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs +46 -0
  157. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs.map +1 -0
  158. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs +482 -0
  159. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs.map +1 -0
  160. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs +165 -0
  161. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs.map +1 -0
  162. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs +4 -0
  163. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs.map +1 -0
  164. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs +3222 -0
  165. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs.map +1 -0
  166. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs +4 -0
  167. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs.map +1 -0
  168. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs +1485 -0
  169. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs.map +1 -0
  170. package/node_modules/@attocash/commons-transport/package.json +29 -0
  171. package/node_modules/@attocash/commons-worker/LICENSE +28 -0
  172. package/node_modules/@attocash/commons-worker/README.md +48 -0
  173. package/node_modules/@attocash/commons-worker/commons-commons-worker.d.mts +73 -0
  174. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs +702 -0
  175. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs.map +1 -0
  176. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs +432 -0
  177. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs.map +1 -0
  178. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  179. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  180. package/node_modules/@attocash/commons-worker/package.json +29 -0
  181. package/node_modules/@attocash/commons-worker-remote/LICENSE +28 -0
  182. package/node_modules/@attocash/commons-worker-remote/README.md +60 -0
  183. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.d.mts +93 -0
  184. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs +289 -0
  185. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs.map +1 -0
  186. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs +432 -0
  187. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs.map +1 -0
  188. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs +8 -0
  189. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs.map +1 -0
  190. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  191. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  192. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  193. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  194. package/node_modules/@attocash/commons-worker-remote/package.json +31 -0
  195. package/node_modules/@js-joda/core/CHANGELOG.md +363 -0
  196. package/node_modules/@js-joda/core/CheatSheet.md +947 -0
  197. package/node_modules/@js-joda/core/LICENSE +34 -0
  198. package/node_modules/@js-joda/core/README.md +155 -0
  199. package/node_modules/@js-joda/core/bower.json +21 -0
  200. package/node_modules/@js-joda/core/dist/js-joda.d.ts +2452 -0
  201. package/node_modules/@js-joda/core/dist/js-joda.esm.js +13564 -0
  202. package/node_modules/@js-joda/core/dist/js-joda.flow.js +949 -0
  203. package/node_modules/@js-joda/core/dist/js-joda.js +13630 -0
  204. package/node_modules/@js-joda/core/dist/js-joda.js.map +1 -0
  205. package/node_modules/@js-joda/core/dist/js-joda.min.js +5 -0
  206. package/node_modules/@js-joda/core/package.json +76 -0
  207. package/node_modules/@js-joda/core/src/Clock.js +330 -0
  208. package/node_modules/@js-joda/core/src/DayOfWeek.js +451 -0
  209. package/node_modules/@js-joda/core/src/Duration.js +1205 -0
  210. package/node_modules/@js-joda/core/src/Enum.js +30 -0
  211. package/node_modules/@js-joda/core/src/Instant.js +1012 -0
  212. package/node_modules/@js-joda/core/src/LocalDate.js +1703 -0
  213. package/node_modules/@js-joda/core/src/LocalDateTime.js +1686 -0
  214. package/node_modules/@js-joda/core/src/LocalTime.js +1415 -0
  215. package/node_modules/@js-joda/core/src/MathUtil.js +236 -0
  216. package/node_modules/@js-joda/core/src/Month.js +600 -0
  217. package/node_modules/@js-joda/core/src/MonthDay.js +730 -0
  218. package/node_modules/@js-joda/core/src/OffsetDateTime.js +757 -0
  219. package/node_modules/@js-joda/core/src/OffsetTime.js +621 -0
  220. package/node_modules/@js-joda/core/src/Period.js +933 -0
  221. package/node_modules/@js-joda/core/src/StringUtil.js +43 -0
  222. package/node_modules/@js-joda/core/src/Year.js +1015 -0
  223. package/node_modules/@js-joda/core/src/YearConstants.js +21 -0
  224. package/node_modules/@js-joda/core/src/YearMonth.js +1096 -0
  225. package/node_modules/@js-joda/core/src/ZoneId.js +236 -0
  226. package/node_modules/@js-joda/core/src/ZoneIdFactory.js +201 -0
  227. package/node_modules/@js-joda/core/src/ZoneOffset.js +486 -0
  228. package/node_modules/@js-joda/core/src/ZoneRegion.js +72 -0
  229. package/node_modules/@js-joda/core/src/ZonedDateTime.js +2007 -0
  230. package/node_modules/@js-joda/core/src/_init.js +68 -0
  231. package/node_modules/@js-joda/core/src/assert.js +33 -0
  232. package/node_modules/@js-joda/core/src/chrono/ChronoLocalDate.js +230 -0
  233. package/node_modules/@js-joda/core/src/chrono/ChronoLocalDateTime.js +130 -0
  234. package/node_modules/@js-joda/core/src/chrono/ChronoZonedDateTime.js +194 -0
  235. package/node_modules/@js-joda/core/src/chrono/IsoChronology.js +235 -0
  236. package/node_modules/@js-joda/core/src/convert.js +83 -0
  237. package/node_modules/@js-joda/core/src/errors.js +54 -0
  238. package/node_modules/@js-joda/core/src/format/DateTimeBuilder.js +535 -0
  239. package/node_modules/@js-joda/core/src/format/DateTimeFormatter.js +728 -0
  240. package/node_modules/@js-joda/core/src/format/DateTimeFormatterBuilder.js +1545 -0
  241. package/node_modules/@js-joda/core/src/format/DateTimeParseContext.js +297 -0
  242. package/node_modules/@js-joda/core/src/format/DateTimePrintContext.js +138 -0
  243. package/node_modules/@js-joda/core/src/format/DecimalStyle.js +113 -0
  244. package/node_modules/@js-joda/core/src/format/EnumMap.js +70 -0
  245. package/node_modules/@js-joda/core/src/format/ParsePosition.js +31 -0
  246. package/node_modules/@js-joda/core/src/format/ResolverStyle.js +93 -0
  247. package/node_modules/@js-joda/core/src/format/SignStyle.js +38 -0
  248. package/node_modules/@js-joda/core/src/format/StringBuilder.js +47 -0
  249. package/node_modules/@js-joda/core/src/format/TextStyle.js +114 -0
  250. package/node_modules/@js-joda/core/src/format/parser/CharLiteralPrinterParser.js +46 -0
  251. package/node_modules/@js-joda/core/src/format/parser/CompositePrinterParser.js +89 -0
  252. package/node_modules/@js-joda/core/src/format/parser/FractionPrinterParser.js +162 -0
  253. package/node_modules/@js-joda/core/src/format/parser/NumberPrinterParser.js +367 -0
  254. package/node_modules/@js-joda/core/src/format/parser/OffsetIdPrinterParser.js +177 -0
  255. package/node_modules/@js-joda/core/src/format/parser/PadPrinterParserDecorator.js +81 -0
  256. package/node_modules/@js-joda/core/src/format/parser/SettingsParser.js +44 -0
  257. package/node_modules/@js-joda/core/src/format/parser/StringLiteralPrinterParser.js +39 -0
  258. package/node_modules/@js-joda/core/src/format/parser/ZoneIdPrinterParser.js +218 -0
  259. package/node_modules/@js-joda/core/src/js-joda.js +210 -0
  260. package/node_modules/@js-joda/core/src/license-preamble.js +3 -0
  261. package/node_modules/@js-joda/core/src/temporal/ChronoField.js +470 -0
  262. package/node_modules/@js-joda/core/src/temporal/ChronoUnit.js +310 -0
  263. package/node_modules/@js-joda/core/src/temporal/DefaultInterfaceTemporal.js +118 -0
  264. package/node_modules/@js-joda/core/src/temporal/IsoFields.js +859 -0
  265. package/node_modules/@js-joda/core/src/temporal/NativeJsTemporal.js +105 -0
  266. package/node_modules/@js-joda/core/src/temporal/Temporal.js +346 -0
  267. package/node_modules/@js-joda/core/src/temporal/TemporalAccessor.js +125 -0
  268. package/node_modules/@js-joda/core/src/temporal/TemporalAdjuster.js +92 -0
  269. package/node_modules/@js-joda/core/src/temporal/TemporalAdjusters.js +464 -0
  270. package/node_modules/@js-joda/core/src/temporal/TemporalAmount.js +166 -0
  271. package/node_modules/@js-joda/core/src/temporal/TemporalField.js +248 -0
  272. package/node_modules/@js-joda/core/src/temporal/TemporalQueries.js +223 -0
  273. package/node_modules/@js-joda/core/src/temporal/TemporalQueriesFactory.js +77 -0
  274. package/node_modules/@js-joda/core/src/temporal/TemporalQuery.js +107 -0
  275. package/node_modules/@js-joda/core/src/temporal/TemporalUnit.js +179 -0
  276. package/node_modules/@js-joda/core/src/temporal/ValueRange.js +257 -0
  277. package/node_modules/@js-joda/core/src/use.js +20 -0
  278. package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneId.js +31 -0
  279. package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneRules.js +162 -0
  280. package/node_modules/@js-joda/core/src/zone/ZoneOffsetTransition.js +289 -0
  281. package/node_modules/@js-joda/core/src/zone/ZoneRules.js +464 -0
  282. package/node_modules/@js-joda/core/src/zone/ZoneRulesProvider.js +36 -0
  283. package/node_modules/@noble/hashes/LICENSE +21 -0
  284. package/node_modules/@noble/hashes/README.md +563 -0
  285. package/node_modules/@noble/hashes/_blake.d.ts +21 -0
  286. package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
  287. package/node_modules/@noble/hashes/_blake.js +52 -0
  288. package/node_modules/@noble/hashes/_blake.js.map +1 -0
  289. package/node_modules/@noble/hashes/_md.d.ts +99 -0
  290. package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
  291. package/node_modules/@noble/hashes/_md.js +202 -0
  292. package/node_modules/@noble/hashes/_md.js.map +1 -0
  293. package/node_modules/@noble/hashes/_u64.d.ts +63 -0
  294. package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
  295. package/node_modules/@noble/hashes/_u64.js +84 -0
  296. package/node_modules/@noble/hashes/_u64.js.map +1 -0
  297. package/node_modules/@noble/hashes/argon2.d.ts +112 -0
  298. package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
  299. package/node_modules/@noble/hashes/argon2.js +517 -0
  300. package/node_modules/@noble/hashes/argon2.js.map +1 -0
  301. package/node_modules/@noble/hashes/blake1.d.ts +156 -0
  302. package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
  303. package/node_modules/@noble/hashes/blake1.js +560 -0
  304. package/node_modules/@noble/hashes/blake1.js.map +1 -0
  305. package/node_modules/@noble/hashes/blake2.d.ts +184 -0
  306. package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
  307. package/node_modules/@noble/hashes/blake2.js +501 -0
  308. package/node_modules/@noble/hashes/blake2.js.map +1 -0
  309. package/node_modules/@noble/hashes/blake3.d.ts +68 -0
  310. package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
  311. package/node_modules/@noble/hashes/blake3.js +284 -0
  312. package/node_modules/@noble/hashes/blake3.js.map +1 -0
  313. package/node_modules/@noble/hashes/eskdf.d.ts +92 -0
  314. package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
  315. package/node_modules/@noble/hashes/eskdf.js +218 -0
  316. package/node_modules/@noble/hashes/eskdf.js.map +1 -0
  317. package/node_modules/@noble/hashes/hkdf.d.ts +64 -0
  318. package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
  319. package/node_modules/@noble/hashes/hkdf.js +120 -0
  320. package/node_modules/@noble/hashes/hkdf.js.map +1 -0
  321. package/node_modules/@noble/hashes/hmac.d.ts +47 -0
  322. package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
  323. package/node_modules/@noble/hashes/hmac.js +93 -0
  324. package/node_modules/@noble/hashes/hmac.js.map +1 -0
  325. package/node_modules/@noble/hashes/index.d.ts +2 -0
  326. package/node_modules/@noble/hashes/index.d.ts.map +1 -0
  327. package/node_modules/@noble/hashes/index.js +35 -0
  328. package/node_modules/@noble/hashes/index.js.map +1 -0
  329. package/node_modules/@noble/hashes/legacy.d.ts +102 -0
  330. package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
  331. package/node_modules/@noble/hashes/legacy.js +327 -0
  332. package/node_modules/@noble/hashes/legacy.js.map +1 -0
  333. package/node_modules/@noble/hashes/package.json +97 -0
  334. package/node_modules/@noble/hashes/pbkdf2.d.ts +56 -0
  335. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
  336. package/node_modules/@noble/hashes/pbkdf2.js +135 -0
  337. package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
  338. package/node_modules/@noble/hashes/scrypt.d.ts +65 -0
  339. package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
  340. package/node_modules/@noble/hashes/scrypt.js +257 -0
  341. package/node_modules/@noble/hashes/scrypt.js.map +1 -0
  342. package/node_modules/@noble/hashes/sha2.d.ts +249 -0
  343. package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
  344. package/node_modules/@noble/hashes/sha2.js +458 -0
  345. package/node_modules/@noble/hashes/sha2.js.map +1 -0
  346. package/node_modules/@noble/hashes/sha3-addons.d.ts +461 -0
  347. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
  348. package/node_modules/@noble/hashes/sha3-addons.js +783 -0
  349. package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
  350. package/node_modules/@noble/hashes/sha3.d.ts +199 -0
  351. package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
  352. package/node_modules/@noble/hashes/sha3.js +431 -0
  353. package/node_modules/@noble/hashes/sha3.js.map +1 -0
  354. package/node_modules/@noble/hashes/src/_blake.ts +57 -0
  355. package/node_modules/@noble/hashes/src/_md.ts +222 -0
  356. package/node_modules/@noble/hashes/src/_u64.ts +117 -0
  357. package/node_modules/@noble/hashes/src/argon2.ts +667 -0
  358. package/node_modules/@noble/hashes/src/blake1.ts +614 -0
  359. package/node_modules/@noble/hashes/src/blake2.ts +582 -0
  360. package/node_modules/@noble/hashes/src/blake3.ts +317 -0
  361. package/node_modules/@noble/hashes/src/eskdf.ts +259 -0
  362. package/node_modules/@noble/hashes/src/hkdf.ts +133 -0
  363. package/node_modules/@noble/hashes/src/hmac.ts +126 -0
  364. package/node_modules/@noble/hashes/src/index.ts +33 -0
  365. package/node_modules/@noble/hashes/src/legacy.ts +339 -0
  366. package/node_modules/@noble/hashes/src/pbkdf2.ts +175 -0
  367. package/node_modules/@noble/hashes/src/scrypt.ts +315 -0
  368. package/node_modules/@noble/hashes/src/sha2.ts +530 -0
  369. package/node_modules/@noble/hashes/src/sha3-addons.ts +983 -0
  370. package/node_modules/@noble/hashes/src/sha3.ts +485 -0
  371. package/node_modules/@noble/hashes/src/utils.ts +848 -0
  372. package/node_modules/@noble/hashes/src/webcrypto.ts +239 -0
  373. package/node_modules/@noble/hashes/utils.d.ts +519 -0
  374. package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
  375. package/node_modules/@noble/hashes/utils.js +578 -0
  376. package/node_modules/@noble/hashes/utils.js.map +1 -0
  377. package/node_modules/@noble/hashes/webcrypto.d.ts +120 -0
  378. package/node_modules/@noble/hashes/webcrypto.d.ts.map +1 -0
  379. package/node_modules/@noble/hashes/webcrypto.js +165 -0
  380. package/node_modules/@noble/hashes/webcrypto.js.map +1 -0
  381. package/node_modules/ws/LICENSE +20 -0
  382. package/node_modules/ws/README.md +548 -0
  383. package/node_modules/ws/browser.js +8 -0
  384. package/node_modules/ws/index.js +22 -0
  385. package/node_modules/ws/lib/buffer-util.js +131 -0
  386. package/node_modules/ws/lib/constants.js +19 -0
  387. package/node_modules/ws/lib/event-target.js +292 -0
  388. package/node_modules/ws/lib/extension.js +203 -0
  389. package/node_modules/ws/lib/limiter.js +55 -0
  390. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  391. package/node_modules/ws/lib/receiver.js +743 -0
  392. package/node_modules/ws/lib/sender.js +607 -0
  393. package/node_modules/ws/lib/stream.js +161 -0
  394. package/node_modules/ws/lib/subprotocol.js +62 -0
  395. package/node_modules/ws/lib/validation.js +152 -0
  396. package/node_modules/ws/lib/websocket-server.js +562 -0
  397. package/node_modules/ws/lib/websocket.js +1407 -0
  398. package/node_modules/ws/package.json +74 -0
  399. package/node_modules/ws/wrapper.mjs +21 -0
  400. package/package.json +53 -0
@@ -0,0 +1,933 @@
1
+ /*
2
+ * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
3
+ * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
4
+ * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
+ */
6
+
7
+ import {MathUtil} from './MathUtil';
8
+ import {requireNonNull, requireInstance} from './assert';
9
+ import {DateTimeException, UnsupportedTemporalTypeException, ArithmeticException, DateTimeParseException} from './errors';
10
+
11
+ import {IsoChronology} from './chrono/IsoChronology';
12
+
13
+ import {ChronoUnit} from './temporal/ChronoUnit';
14
+ import {TemporalAmount} from './temporal/TemporalAmount';
15
+
16
+ import {LocalDate} from './LocalDate';
17
+
18
+ /**
19
+ * The pattern for parsing.
20
+ */
21
+ const PATTERN = /([-+]?)P(?:([-+]?[0-9]+)Y)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)W)?(?:([-+]?[0-9]+)D)?/;
22
+
23
+ /**
24
+ * A date-based amount of time, such as '2 years, 3 months and 4 days'.
25
+ *
26
+ * This class models a quantity or amount of time in terms of years, months and days.
27
+ * See {@link Duration} for the time-based equivalent to this class.
28
+ *
29
+ * Durations and period differ in their treatment of daylight savings time
30
+ * when added to {@link ZonedDateTime}. A {@link Duration} will add an exact
31
+ * number of seconds, thus a duration of one day is always exactly 24 hours.
32
+ * By contrast, a {@link Period} will add a conceptual day, trying to maintain
33
+ * the local time.
34
+ *
35
+ * For example, consider adding a period of one day and a duration of one day to
36
+ * 18:00 on the evening before a daylight savings gap. The {@link Period} will add
37
+ * the conceptual day and result in a {@link ZonedDateTime} at 18:00 the following day.
38
+ * By contrast, the {@link Duration} will add exactly 24 hours, resulting in a
39
+ * {@link ZonedDateTime} at 19:00 the following day (assuming a one hour DST gap).
40
+ *
41
+ * The supported units of a period are {@link ChronoUnit#YEARS},
42
+ * {@link ChronoUnit#MONTHS} and {@link ChronoUnit#DAYS}.
43
+ * All three fields are always present, but may be set to zero.
44
+ *
45
+ * The period may be used with any calendar system.
46
+ * The meaning of a 'year' or 'month' is only applied when the object is added to a date.
47
+ *
48
+ * The period is modeled as a directed amount of time, meaning that individual parts of the
49
+ * period may be negative.
50
+ *
51
+ * The months and years fields may be normalized (see {@link normalized}).
52
+ * The normalization assumes a 12 month year, so is not appropriate for all calendar systems.
53
+ *
54
+ * ### Static properties of Class {@link Period}
55
+ *
56
+ * Period.ZERO
57
+ *
58
+ * A constant for a period of zero.
59
+ *
60
+ */
61
+ export class Period extends TemporalAmount /* extends ChronoPeriod */ {
62
+
63
+ /**
64
+ * do not call the constructor directly
65
+ * use a factory method instead
66
+ *
67
+ * @param {number} years
68
+ * @param {number} months
69
+ * @param {number} days
70
+ * @private
71
+ */
72
+ constructor(years, months, days){
73
+ super();
74
+
75
+ const _years = MathUtil.safeToInt(years);
76
+ const _months = MathUtil.safeToInt(months);
77
+ const _days = MathUtil.safeToInt(days);
78
+
79
+ if( _years === 0 && _months === 0 && _days === 0 ){
80
+ if (!Period.ZERO) {
81
+ this._years = _years;
82
+ this._months = _months;
83
+ this._days = _days;
84
+ Period.ZERO = this;
85
+ }
86
+ return Period.ZERO;
87
+ }
88
+
89
+ /**
90
+ * The number of years.
91
+ */
92
+ this._years = _years;
93
+ /**
94
+ * The number of months.
95
+ */
96
+ this._months = _months;
97
+ /**
98
+ * The number of days.
99
+ */
100
+ this._days = _days;
101
+ }
102
+
103
+ //-----------------------------------------------------------------------
104
+ /**
105
+ * Obtains a {@link Period} representing a number of years.
106
+ *
107
+ * The resulting period will have the specified years.
108
+ * The months and days units will be zero.
109
+ *
110
+ * @param {number} years - the number of years, positive or negative
111
+ * @return {Period} the period of years, not null
112
+ */
113
+ static ofYears(years) {
114
+ return Period.create(years, 0, 0);
115
+ }
116
+
117
+ /**
118
+ * Obtains a {@link Period} representing a number of months.
119
+ *
120
+ * The resulting period will have the specified months.
121
+ * The years and days units will be zero.
122
+ *
123
+ * @param {number} months - the number of months, positive or negative
124
+ * @return {Period} the period of months, not null
125
+ */
126
+ static ofMonths(months) {
127
+ return Period.create(0, months, 0);
128
+ }
129
+
130
+ /**
131
+ * Obtains a {@link Period} representing a number of weeks.
132
+ *
133
+ * The resulting period will have days equal to the weeks multiplied by seven.
134
+ * The years and months units will be zero.
135
+ *
136
+ * @param {number} weeks - the number of weeks, positive or negative
137
+ * @return {Period} the period of days, not null
138
+ */
139
+ static ofWeeks(weeks) {
140
+ return Period.create(0, 0, MathUtil.safeMultiply(weeks, 7));
141
+ }
142
+
143
+ /**
144
+ * Obtains a {@link Period} representing a number of days.
145
+ *
146
+ * The resulting period will have the specified days.
147
+ * The years and months units will be zero.
148
+ *
149
+ * @param {number} days - the number of days, positive or negative
150
+ * @return {Period} the period of days, not null
151
+ */
152
+ static ofDays(days) {
153
+ return Period.create(0, 0, days);
154
+ }
155
+
156
+ //-----------------------------------------------------------------------
157
+ /**
158
+ * Obtains a {@link Period} representing a number of years, months and days.
159
+ *
160
+ * This creates an instance based on years, months and days.
161
+ *
162
+ * @param {!number} years - the amount of years, may be negative
163
+ * @param {!number} months - the amount of months, may be negative
164
+ * @param {!number} days - the amount of days, may be negative
165
+ * @return {Period} the period of years, months and days, not null
166
+ */
167
+ static of(years, months, days) {
168
+ return Period.create(years, months, days);
169
+ }
170
+
171
+ //-----------------------------------------------------------------------
172
+ /**
173
+ * Obtains an instance of {@link Period} from a temporal amount.
174
+ *
175
+ * This obtains a period based on the specified amount.
176
+ * A {@link TemporalAmount} represents an - amount of time, which may be
177
+ * date-based or time-based, which this factory extracts to a {@link Period}.
178
+ *
179
+ * The conversion loops around the set of units from the amount and uses
180
+ * the {@link ChronoUnit#YEARS}, {@link ChronoUnit#MONTHS}
181
+ * and {@link ChronoUnit#DAYS} units to create a period.
182
+ * If any other units are found then an exception is thrown.
183
+ *
184
+ * If the amount is a {@link ChronoPeriod} then it must use the ISO chronology.
185
+ *
186
+ * @param {TemporalAmount} amount - the temporal amount to convert, not null
187
+ * @return {Period} the equivalent period, not null
188
+ * @throws DateTimeException if unable to convert to a {@link Period}
189
+ * @throws ArithmeticException if the amount of years, months or days exceeds an int
190
+ */
191
+ static from(amount) {
192
+ if (amount instanceof Period) {
193
+ return amount;
194
+ }
195
+ /*
196
+ if (amount instanceof ChronoPeriod) {
197
+ if (IsoChronology.INSTANCE !== amount.chronology()) {
198
+ throw new DateTimeException('Period requires ISO chronology: ' + amount);
199
+ }
200
+ }
201
+ */
202
+ requireNonNull(amount, 'amount');
203
+ let years = 0;
204
+ let months = 0;
205
+ let days = 0;
206
+ const units = amount.units();
207
+ for (let i=0; i<units.length; i++) {
208
+ const unit = units[i];
209
+ const unitAmount = amount.get(unit);
210
+ if (unit === ChronoUnit.YEARS) {
211
+ years = MathUtil.safeToInt(unitAmount);
212
+ } else if (unit === ChronoUnit.MONTHS) {
213
+ months = MathUtil.safeToInt(unitAmount);
214
+ } else if (unit === ChronoUnit.DAYS) {
215
+ days = MathUtil.safeToInt(unitAmount);
216
+ } else {
217
+ throw new DateTimeException('Unit must be Years, Months or Days, but was ' + unit);
218
+ }
219
+ }
220
+ return Period.create(years, months, days);
221
+ }
222
+
223
+ //-----------------------------------------------------------------------
224
+ /**
225
+ * Obtains a {@link Period} consisting of the number of years, months,
226
+ * and days between two dates.
227
+ *
228
+ * The start date is included, but the end date is not.
229
+ * The period is calculated by removing complete months, then calculating
230
+ * the remaining number of days, adjusting to ensure that both have the same sign.
231
+ * The number of months is then split into years and months based on a 12 month year.
232
+ * A month is considered if the end day-of-month is greater than or equal to the start day-of-month.
233
+ * For example, from `2010-01-15` to `2011-03-18` is one year, two months and three days.
234
+ *
235
+ * The result of this method can be a negative period if the end is before the start.
236
+ * The negative sign will be the same in each of year, month and day.
237
+
238
+ * see {@link ChronoLocalDate.until}
239
+ *
240
+ * @param {LocalDate} startDate - the start date, inclusive, not null
241
+ * @param {LocalDate} endDate - the end date, exclusive, not null
242
+ * @return {Period} the period between this date and the end date, not null
243
+ */
244
+ static between(startDate, endDate) {
245
+ requireNonNull(startDate, 'startDate');
246
+ requireNonNull(endDate, 'endDate');
247
+ requireInstance(startDate, LocalDate, 'startDate');
248
+ requireInstance(endDate, LocalDate, 'endDate');
249
+ return startDate.until(endDate);
250
+ }
251
+
252
+ //-----------------------------------------------------------------------
253
+ /**
254
+ * Obtains a {@link Period} from a text string such as {@link PnYnMnD}.
255
+ *
256
+ * This will parse the string produced by {@link toString} which is
257
+ * based on the ISO-8601 period formats {@link PnYnMnD} and {@link PnW}.
258
+ *
259
+ * The string starts with an optional sign, denoted by the ASCII negative
260
+ * or positive symbol. If negative, the whole period is negated.
261
+ * The ASCII letter 'P' is next in upper or lower case.
262
+ * There are then four sections, each consisting of a number and a suffix.
263
+ * At least one of the four sections must be present.
264
+ * The sections have suffixes in ASCII of 'Y', 'M', 'W' and 'D' for
265
+ * years, months, weeks and days, accepted in upper or lower case.
266
+ * The suffixes must occur in order.
267
+ * The number part of each section must consist of ASCII digits.
268
+ * The number may be prefixed by the ASCII negative or positive symbol.
269
+ * The number must parse to an `int`.
270
+ *
271
+ * The leading plus/minus sign, and negative values for other units are
272
+ * not part of the ISO-8601 standard. In addition, ISO-8601 does not
273
+ * permit mixing between the {@link PnYnMnD} and {@link PnW} formats.
274
+ * Any week-based input is multiplied by 7 and treated as a number of days.
275
+ *
276
+ * For example, the following are valid inputs:
277
+ * <pre>
278
+ * 'P2Y' -- Period.ofYears(2)
279
+ * 'P3M' -- Period.ofMonths(3)
280
+ * 'P4W' -- Period.ofWeeks(4)
281
+ * 'P5D' -- Period.ofDays(5)
282
+ * 'P1Y2M3D' -- Period.of(1, 2, 3)
283
+ * 'P1Y2M3W4D' -- Period.of(1, 2, 25)
284
+ * 'P-1Y2M' -- Period.of(-1, 2, 0)
285
+ * '-P1Y2M' -- Period.of(-1, -2, 0)
286
+ * </pre>
287
+ *
288
+ * @param {string} text - the text to parse, not null
289
+ * @return {Period} the parsed period, not null
290
+ * @throws DateTimeParseException if the text cannot be parsed to a period
291
+ */
292
+ static parse(text) {
293
+ requireNonNull(text, 'text');
294
+ try {
295
+ return Period._parse(text);
296
+ } catch (ex){
297
+ if(ex instanceof ArithmeticException){
298
+ throw new DateTimeParseException('Text cannot be parsed to a Period', text, 0, ex);
299
+ } else {
300
+ throw ex;
301
+ }
302
+ }
303
+ }
304
+
305
+ /**
306
+ * because functions that containing a try/ catch block cant be optimized,
307
+ * we put the code in a sub function.
308
+ */
309
+ static _parse(text){
310
+ const matches = PATTERN.exec(text);
311
+ if (matches != null) {
312
+ const negate = '-' === matches[1] ? -1 : 1;
313
+ const yearMatch = matches[2];
314
+ const monthMatch = matches[3];
315
+ const weekMatch = matches[4];
316
+ const dayMatch = matches[5];
317
+ if (yearMatch != null || monthMatch != null || weekMatch != null || dayMatch != null) {
318
+ const years = Period._parseNumber(text, yearMatch, negate);
319
+ const months = Period._parseNumber(text, monthMatch, negate);
320
+ const weeks = Period._parseNumber(text, weekMatch, negate);
321
+ let days = Period._parseNumber(text, dayMatch, negate);
322
+ days = MathUtil.safeAdd(days, MathUtil.safeMultiply(weeks, 7));
323
+ return Period.create(years, months, days);
324
+ }
325
+ }
326
+ throw new DateTimeParseException('Text cannot be parsed to a Period', text, 0);
327
+ }
328
+
329
+ static _parseNumber(text, str, negate) {
330
+ if (str == null) {
331
+ return 0;
332
+ }
333
+ const val = MathUtil.parseInt(str);
334
+ return MathUtil.safeMultiply(val, negate);
335
+ }
336
+
337
+ //-----------------------------------------------------------------------
338
+ /**
339
+ * Creates an instance.
340
+ *
341
+ * @param {number} years - the amount
342
+ * @param {number} months - the amount
343
+ * @param {number} days - the amount
344
+ * @return {Duration}
345
+ */
346
+ static create(years, months, days) {
347
+ return new Period(years, months, days);
348
+ }
349
+
350
+ //-----------------------------------------------------------------------
351
+ /**
352
+ * Gets the list of units, from largest to smallest, that fully define this amount.
353
+ *
354
+ * @returns {ChronoUnit[]} list of units
355
+ */
356
+ units() {
357
+ return [ChronoUnit.YEARS, ChronoUnit.MONTHS, ChronoUnit.DAYS];
358
+ }
359
+
360
+ /**
361
+ * Gets the chronology that defines the meaning of the supported units.
362
+ *
363
+ * The period is defined by the chronology.
364
+ * It controls the supported units and restricts addition/subtraction
365
+ * to {@link ChronoLocalDate} instances of the same chronology.
366
+ *
367
+ * @return {IsoChronology} the chronology defining the period, not null
368
+ */
369
+ chronology() {
370
+ return IsoChronology.INSTANCE;
371
+ }
372
+
373
+ /**
374
+ * Gets the value of the requested unit.
375
+ *
376
+ * The supported units are chronology specific.
377
+ * They will typically be {@link ChronoUnit#YEARS},
378
+ * {@link ChronoUnit#MONTHS} and {@link ChronoUnit#DAYS}.
379
+ * Requesting an unsupported unit will throw an exception.
380
+ *
381
+ * @param {TemporalUnit} unit the {@link TemporalUnit} for which to return the value
382
+ * @return {number} the long value of the unit
383
+ * @throws DateTimeException if the unit is not supported
384
+ * @throws UnsupportedTemporalTypeException if the unit is not supported
385
+ */
386
+ get(unit) {
387
+ if (unit === ChronoUnit.YEARS) {
388
+ return this._years;
389
+ }
390
+ if (unit === ChronoUnit.MONTHS) {
391
+ return this._months;
392
+ }
393
+ if (unit === ChronoUnit.DAYS) {
394
+ return this._days;
395
+ }
396
+ throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
397
+ }
398
+
399
+ //-----------------------------------------------------------------------
400
+ /**
401
+ * Checks if all three units of this period are zero.
402
+ *
403
+ * A zero period has the value zero for the years, months and days units.
404
+ *
405
+ * @return {boolean} true if this period is zero-length
406
+ */
407
+ isZero() {
408
+ return (this === Period.ZERO);
409
+ }
410
+
411
+ /**
412
+ * Checks if any of the three units of this period are negative.
413
+ *
414
+ * This checks whether the years, months or days units are less than zero.
415
+ *
416
+ * @return {boolean} true if any unit of this period is negative
417
+ */
418
+ isNegative() {
419
+ return this._years < 0 || this._months < 0 || this._days < 0;
420
+ }
421
+
422
+ //-----------------------------------------------------------------------
423
+ /**
424
+ * Gets the amount of years of this period.
425
+ *
426
+ * This returns the years unit.
427
+ *
428
+ * The months unit is not normalized with the years unit.
429
+ * This means that a period of '15 months' is different to a period
430
+ * of '1 year and 3 months'.
431
+ *
432
+ * @return {number} the amount of years of this period, may be negative
433
+ */
434
+ years() {
435
+ return this._years;
436
+ }
437
+
438
+ /**
439
+ * Gets the amount of months of this period.
440
+ *
441
+ * This returns the months unit.
442
+ *
443
+ * The months unit is not normalized with the years unit.
444
+ * This means that a period of '15 months' is different to a period
445
+ * of '1 year and 3 months'.
446
+ *
447
+ * @return {number} the amount of months of this period, may be negative
448
+ */
449
+ months() {
450
+ return this._months;
451
+ }
452
+
453
+ /**
454
+ * Gets the amount of days of this period.
455
+ *
456
+ * This returns the days unit.
457
+ *
458
+ * @return {number} the amount of days of this period, may be negative
459
+ */
460
+ days() {
461
+ return this._days;
462
+ }
463
+
464
+ //-----------------------------------------------------------------------
465
+ /**
466
+ * Returns a copy of this period with the specified amount of years.
467
+ *
468
+ * This sets the amount of the years unit in a copy of this period.
469
+ * The months and days units are unaffected.
470
+ *
471
+ * The months unit is not normalized with the years unit.
472
+ * This means that a period of '15 months' is different to a period
473
+ * of '1 year and 3 months'.
474
+ *
475
+ * This instance is immutable and unaffected by this method call.
476
+ *
477
+ * @param {number} years - the years to represent, may be negative
478
+ * @return {Period} a {@link Period} based on this period with the requested years, not null
479
+ */
480
+ withYears(years) {
481
+ if (years === this._years) {
482
+ return this;
483
+ }
484
+ return Period.create(years, this._months, this._days);
485
+ }
486
+
487
+ /**
488
+ * Returns a copy of this period with the specified amount of months.
489
+ *
490
+ * This sets the amount of the months unit in a copy of this period.
491
+ * The years and days units are unaffected.
492
+ *
493
+ * The months unit is not normalized with the years unit.
494
+ * This means that a period of '15 months' is different to a period
495
+ * of '1 year and 3 months'.
496
+ *
497
+ * This instance is immutable and unaffected by this method call.
498
+ *
499
+ * @param {number} months - the months to represent, may be negative
500
+ * @return {Period} a {@link Period} based on this period with the requested months, not null
501
+ */
502
+ withMonths(months) {
503
+ if (months === this._months) {
504
+ return this;
505
+ }
506
+ return Period.create(this._years, months, this._days);
507
+ }
508
+
509
+ /**
510
+ * Returns a copy of this period with the specified amount of days.
511
+ *
512
+ * This sets the amount of the days unit in a copy of this period.
513
+ * The years and months units are unaffected.
514
+ *
515
+ * This instance is immutable and unaffected by this method call.
516
+ *
517
+ * @param {number} days - the days to represent, may be negative
518
+ * @return {Period} a {@link Period} based on this period with the requested days, not null
519
+ */
520
+ withDays(days) {
521
+ if (days === this._days) {
522
+ return this;
523
+ }
524
+ return Period.create(this._years, this._months, days);
525
+ }
526
+
527
+ //-----------------------------------------------------------------------
528
+ /**
529
+ * Returns a copy of this period with the specified amount added.
530
+ *
531
+ * This input amount is converted to a {@link Period} using {@link from}.
532
+ * This operates separately on the years, months and days.
533
+ *
534
+ * For example, '1 year, 6 months and 3 days' plus '2 years, 2 months and 2 days'
535
+ * returns '3 years, 8 months and 5 days'.
536
+ *
537
+ * This instance is immutable and unaffected by this method call.
538
+ *
539
+ * @param {TemporalAmount} amountToAdd - the period to add, not null
540
+ * @return {Period} a {@link Period} based on this period with the requested period added, not null
541
+ * @throws ArithmeticException if numeric overflow occurs
542
+ */
543
+ plus(amountToAdd) {
544
+ const amount = Period.from(amountToAdd);
545
+ return Period.create(
546
+ MathUtil.safeAdd(this._years, amount._years),
547
+ MathUtil.safeAdd(this._months, amount._months),
548
+ MathUtil.safeAdd(this._days, amount._days));
549
+ }
550
+
551
+ /**
552
+ * Returns a copy of this period with the specified years added.
553
+ *
554
+ * This adds the amount to the years unit in a copy of this period.
555
+ * The months and days units are unaffected.
556
+ * For example, '1 year, 6 months and 3 days' plus 2 years returns '3 years, 6 months and 3 days'.
557
+ *
558
+ * This instance is immutable and unaffected by this method call.
559
+ *
560
+ * @param {number} yearsToAdd - the years to add, positive or negative
561
+ * @return {Period} a {@link Period} based on this period with the specified years added, not null
562
+ * @throws ArithmeticException if numeric overflow occurs
563
+ */
564
+ plusYears(yearsToAdd) {
565
+ if (yearsToAdd === 0) {
566
+ return this;
567
+ }
568
+ return Period.create(MathUtil.safeToInt(MathUtil.safeAdd(this._years, yearsToAdd)), this._months, this._days);
569
+ }
570
+
571
+ /**
572
+ * Returns a copy of this period with the specified months added.
573
+ *
574
+ * This adds the amount to the months unit in a copy of this period.
575
+ * The years and days units are unaffected.
576
+ * For example, '1 year, 6 months and 3 days' plus 2 months returns '1 year, 8 months and 3 days'.
577
+ *
578
+ * This instance is immutable and unaffected by this method call.
579
+ *
580
+ * @param {number} monthsToAdd - the months to add, positive or negative
581
+ * @return {Period} a {@link Period} based on this period with the specified months added, not null
582
+ * @throws ArithmeticException if numeric overflow occurs
583
+ */
584
+ plusMonths(monthsToAdd) {
585
+ if (monthsToAdd === 0) {
586
+ return this;
587
+ }
588
+ return Period.create(this._years, MathUtil.safeToInt(MathUtil.safeAdd(this._months, monthsToAdd)), this._days);
589
+ }
590
+
591
+ /**
592
+ * Returns a copy of this period with the specified days added.
593
+ *
594
+ * This adds the amount to the days unit in a copy of this period.
595
+ * The years and months units are unaffected.
596
+ * For example, '1 year, 6 months and 3 days' plus 2 days returns '1 year, 6 months and 5 days'.
597
+ *
598
+ * This instance is immutable and unaffected by this method call.
599
+ *
600
+ * @param {number} daysToAdd - the days to add, positive or negative
601
+ * @return {Period} a {@link Period} based on this period with the specified days added, not null
602
+ * @throws ArithmeticException if numeric overflow occurs
603
+ */
604
+ plusDays(daysToAdd) {
605
+ if (daysToAdd === 0) {
606
+ return this;
607
+ }
608
+ return Period.create(this._years, this._months, MathUtil.safeToInt(MathUtil.safeAdd(this._days, daysToAdd)));
609
+ }
610
+
611
+ //-----------------------------------------------------------------------
612
+ /**
613
+ * Returns a copy of this period with the specified amount subtracted.
614
+ *
615
+ * This input amount is converted to a {@link Period} using {@link from}.
616
+ * This operates separately on the years, months and days.
617
+ *
618
+ * For example, '1 year, 6 months and 3 days' minus '2 years, 2 months and 2 days'
619
+ * returns '-1 years, 4 months and 1 day'.
620
+ *
621
+ * This instance is immutable and unaffected by this method call.
622
+ *
623
+ * @param {TemporalAmount} amountToSubtract - the period to subtract, not null
624
+ * @return {Period} a {@link Period} based on this period with the requested period subtracted, not null
625
+ * @throws ArithmeticException if numeric overflow occurs
626
+ */
627
+ minus(amountToSubtract) {
628
+ const amount = Period.from(amountToSubtract);
629
+ return Period.create(
630
+ MathUtil.safeSubtract(this._years, amount._years),
631
+ MathUtil.safeSubtract(this._months, amount._months),
632
+ MathUtil.safeSubtract(this._days, amount._days));
633
+ }
634
+
635
+ /**
636
+ * Returns a copy of this period with the specified years subtracted.
637
+ *
638
+ * This subtracts the amount from the years unit in a copy of this period.
639
+ * The months and days units are unaffected.
640
+ * For example, '1 year, 6 months and 3 days' minus 2 years returns '-1 years, 6 months and 3 days'.
641
+ *
642
+ * This instance is immutable and unaffected by this method call.
643
+ *
644
+ * @param {number} yearsToSubtract - the years to subtract, positive or negative
645
+ * @return {Period} a {@link Period} based on this period with the specified years subtracted, not null
646
+ * @throws ArithmeticException if numeric overflow occurs
647
+ */
648
+ minusYears(yearsToSubtract) {
649
+ return this.plusYears(-1 * yearsToSubtract);
650
+ }
651
+
652
+ /**
653
+ * Returns a copy of this period with the specified months subtracted.
654
+ *
655
+ * This subtracts the amount from the months unit in a copy of this period.
656
+ * The years and days units are unaffected.
657
+ * For example, '1 year, 6 months and 3 days' minus 2 months returns '1 year, 4 months and 3 days'.
658
+ *
659
+ * This instance is immutable and unaffected by this method call.
660
+ *
661
+ * @param {number} monthsToSubtract - the years to subtract, positive or negative
662
+ * @return {Period} a {@link Period} based on this period with the specified months subtracted, not null
663
+ * @throws ArithmeticException if numeric overflow occurs
664
+ */
665
+ minusMonths(monthsToSubtract) {
666
+ return this.plusMonths(-1 * monthsToSubtract);
667
+ }
668
+
669
+ /**
670
+ * Returns a copy of this period with the specified days subtracted.
671
+ *
672
+ * This subtracts the amount from the days unit in a copy of this period.
673
+ * The years and months units are unaffected.
674
+ * For example, '1 year, 6 months and 3 days' minus 2 days returns '1 year, 6 months and 1 day'.
675
+ *
676
+ * This instance is immutable and unaffected by this method call.
677
+ *
678
+ * @param {number} daysToSubtract - the months to subtract, positive or negative
679
+ * @return {Period} a {@link Period} based on this period with the specified days subtracted, not null
680
+ * @throws ArithmeticException if numeric overflow occurs
681
+ */
682
+ minusDays(daysToSubtract) {
683
+ return this.plusDays(-1 * daysToSubtract);
684
+ }
685
+
686
+ //-----------------------------------------------------------------------
687
+ /**
688
+ * Returns a new instance with each element in this period multiplied
689
+ * by the specified scalar.
690
+ *
691
+ * This simply multiplies each field, years, months, days and normalized time,
692
+ * by the scalar. No normalization is performed.
693
+ *
694
+ * @param {number} scalar - the scalar to multiply by, not null
695
+ * @return {Period} a {@link Period} based on this period with the amounts multiplied by the scalar, not null
696
+ * @throws ArithmeticException if numeric overflow occurs
697
+ */
698
+ multipliedBy(scalar) {
699
+ if (this === Period.ZERO || scalar === 1) {
700
+ return this;
701
+ }
702
+ return Period.create(
703
+ MathUtil.safeMultiply(this._years, scalar),
704
+ MathUtil.safeMultiply(this._months, scalar),
705
+ MathUtil.safeMultiply(this._days, scalar));
706
+ }
707
+
708
+ /**
709
+ * Returns a new instance with each amount in this period negated.
710
+ *
711
+ * @return {Period} a {@link Period} based on this period with the amounts negated, not null
712
+ * @throws ArithmeticException if numeric overflow occurs
713
+ */
714
+ negated() {
715
+ return this.multipliedBy(-1);
716
+ }
717
+
718
+ //-----------------------------------------------------------------------
719
+ /**
720
+ * Returns a copy of this period with the years and months normalized
721
+ * using a 12 month year.
722
+ *
723
+ * This normalizes the years and months units, leaving the days unit unchanged.
724
+ * The months unit is adjusted to have an absolute value less than 11,
725
+ * with the years unit being adjusted to compensate. For example, a period of
726
+ * '1 Year and 15 months' will be normalized to '2 years and 3 months'.
727
+ *
728
+ * The sign of the years and months units will be the same after normalization.
729
+ * For example, a period of '1 year and -25 months' will be normalized to
730
+ * '-1 year and -1 month'.
731
+ *
732
+ * This normalization uses a 12 month year which is not valid for all calendar systems.
733
+ *
734
+ * This instance is immutable and unaffected by this method call.
735
+ *
736
+ * @return {Period} a {@link Period} based on this period with excess months normalized to years, not null
737
+ * @throws ArithmeticException if numeric overflow occurs
738
+ */
739
+ normalized() {
740
+ const totalMonths = this.toTotalMonths();
741
+ const splitYears = MathUtil.intDiv(totalMonths, 12);
742
+ const splitMonths = MathUtil.intMod(totalMonths, 12); // no overflow
743
+ if (splitYears === this._years && splitMonths === this._months) {
744
+ return this;
745
+ }
746
+ return Period.create(MathUtil.safeToInt(splitYears), splitMonths, this._days);
747
+ }
748
+
749
+ /**
750
+ * Gets the total number of months in this period using a 12 month year.
751
+ *
752
+ * This returns the total number of months in the period by multiplying the
753
+ * number of years by 12 and adding the number of months.
754
+ *
755
+ * This uses a 12 month year which is not valid for all calendar systems.
756
+ *
757
+ * This instance is immutable and unaffected by this method call.
758
+ *
759
+ * @return {number} the total number of months in the period, may be negative
760
+ */
761
+ toTotalMonths() {
762
+ return this._years * 12 + this._months; // no overflow
763
+ }
764
+
765
+ //-------------------------------------------------------------------------
766
+ /**
767
+ * Adds this period to the specified temporal object.
768
+ *
769
+ * This returns a temporal object of the same observable type as the input
770
+ * with this period added.
771
+ *
772
+ * In most cases, it is clearer to reverse the calling pattern by using
773
+ * {@link Temporal#plus}.
774
+ * <pre>
775
+ * // these two lines are equivalent, but the second approach is recommended
776
+ * dateTime = thisPeriod.addTo(dateTime);
777
+ * dateTime = dateTime.plus(thisPeriod);
778
+ * </pre>
779
+ *
780
+ * The calculation will add the years, then months, then days.
781
+ * Only non-zero amounts will be added.
782
+ * If the date-time has a calendar system with a fixed number of months in a
783
+ * year, then the years and months will be combined before being added.
784
+ *
785
+ * This instance is immutable and unaffected by this method call.
786
+ *
787
+ * @param {Temporal} temporal - the temporal object to adjust, not null
788
+ * @return {Temporal} an object of the same type with the adjustment made, not null
789
+ * @throws DateTimeException if unable to add
790
+ * @throws ArithmeticException if numeric overflow occurs
791
+ */
792
+ addTo(temporal) {
793
+ requireNonNull(temporal, 'temporal');
794
+ if (this._years !== 0) {
795
+ if (this._months !== 0) {
796
+ temporal = temporal.plus(this.toTotalMonths(), ChronoUnit.MONTHS);
797
+ } else {
798
+ temporal = temporal.plus(this._years, ChronoUnit.YEARS);
799
+ }
800
+ } else if (this._months !== 0) {
801
+ temporal = temporal.plus(this._months, ChronoUnit.MONTHS);
802
+ }
803
+ if (this._days !== 0) {
804
+ temporal = temporal.plus(this._days, ChronoUnit.DAYS);
805
+ }
806
+ return temporal;
807
+ }
808
+
809
+ /**
810
+ * Subtracts this period from the specified temporal object.
811
+ *
812
+ * This returns a temporal object of the same observable type as the input
813
+ * with this period subtracted.
814
+ *
815
+ * In most cases, it is clearer to reverse the calling pattern by using
816
+ * {@link Temporal#minus}.
817
+ * <pre>
818
+ * // these two lines are equivalent, but the second approach is recommended
819
+ * dateTime = thisPeriod.subtractFrom(dateTime);
820
+ * dateTime = dateTime.minus(thisPeriod);
821
+ * </pre>
822
+ *
823
+ * The calculation operates as follows.
824
+ * First, the chronology of the temporal is checked to ensure it is ISO chronology or null.
825
+ * Second, if the months are zero, the years are added if non-zero, otherwise
826
+ * the combination of years and months is added if non-zero.
827
+ * Finally, any days are added.
828
+ *
829
+ * The calculation will subtract the years, then months, then days.
830
+ * Only non-zero amounts will be subtracted.
831
+ * If the date-time has a calendar system with a fixed number of months in a
832
+ * year, then the years and months will be combined before being subtracted.
833
+ *
834
+ * This instance is immutable and unaffected by this method call.
835
+ *
836
+ * @param {Temporal} temporal - the temporal object to adjust, not null
837
+ * @return {Temporal} an object of the same type with the adjustment made, not null
838
+ * @throws DateTimeException if unable to subtract
839
+ * @throws ArithmeticException if numeric overflow occurs
840
+ */
841
+ subtractFrom(temporal) {
842
+ requireNonNull(temporal, 'temporal');
843
+ if (this._years !== 0) {
844
+ if (this._months !== 0) {
845
+ temporal = temporal.minus(this.toTotalMonths(), ChronoUnit.MONTHS);
846
+ } else {
847
+ temporal = temporal.minus(this._years, ChronoUnit.YEARS);
848
+ }
849
+ } else if (this._months !== 0) {
850
+ temporal = temporal.minus(this._months, ChronoUnit.MONTHS);
851
+ }
852
+ if (this._days !== 0) {
853
+ temporal = temporal.minus(this._days, ChronoUnit.DAYS);
854
+ }
855
+ return temporal;
856
+ }
857
+
858
+ //-----------------------------------------------------------------------
859
+ /**
860
+ * Checks if this period is equal to another period.
861
+ *
862
+ * The comparison is based on the amounts held in the period.
863
+ * To be equal, the years, months and days units must be individually equal.
864
+ * Note that this means that a period of '15 Months' is not equal to a period
865
+ * of '1 Year and 3 Months'.
866
+ *
867
+ * @param {*} obj - the object to check, null returns false
868
+ * @return {boolean} true if this is equal to the other period
869
+ */
870
+ equals(obj) {
871
+ if (this === obj) {
872
+ return true;
873
+ }
874
+ if (obj instanceof Period) {
875
+ const other = obj;
876
+ return this._years === other._years &&
877
+ this._months === other._months &&
878
+ this._days === other._days;
879
+ }
880
+ return false;
881
+ }
882
+
883
+ /**
884
+ * A hash code for this period.
885
+ *
886
+ * @return {number} a suitable hash code
887
+ */
888
+ hashCode() {
889
+ return MathUtil.hashCode(this._years, this._months, this._days);
890
+ }
891
+
892
+ //-----------------------------------------------------------------------
893
+ /**
894
+ * Outputs this period as a string, such as {@link P6Y3M1D}.
895
+ *
896
+ * The output will be in the ISO-8601 period format.
897
+ * A zero period will be represented as zero days, 'P0D'.
898
+ *
899
+ * @return {string} a string representation of this period, not null
900
+ */
901
+ toString() {
902
+ if (this === Period.ZERO) {
903
+ return 'P0D';
904
+ } else {
905
+ let buf = 'P';
906
+ if (this._years !== 0) {
907
+ buf += '' + this._years + 'Y';
908
+ }
909
+ if (this._months !== 0) {
910
+ buf += '' + this._months + 'M';
911
+ }
912
+ if (this._days !== 0) {
913
+ buf += '' + this._days + 'D';
914
+ }
915
+ return buf;
916
+ }
917
+ }
918
+
919
+ /**
920
+ *
921
+ * @return {string} same as {@link Period.toString}
922
+ */
923
+ toJSON() {
924
+ return this.toString();
925
+ }
926
+ }
927
+
928
+ export function _init() {
929
+ /**
930
+ * A constant for a period of zero.
931
+ */
932
+ Period.ofDays(0);
933
+ }